Improve canvas layers, heading removal and component previews in 1.5.3
This commit is contained in:
@@ -442,7 +442,7 @@ class AdminController
|
||||
if ($data['name'] === '' || mb_strlen($data['name']) > 100 || !in_array($data['status'], ['draft', 'published'], true)
|
||||
|| $data['title'] === '' || mb_strlen($data['title']) > 160 ||
|
||||
($public && $data['status'] === 'published' && $data['description'] === '') || mb_strlen($data['description']) > 300 ||
|
||||
(($data['visibility']['hero'] ?? true) && !array_key_exists('heroHtml', $data['presentation']) && $data['heading'] === '') || mb_strlen($data['heading'] . $data['accent']) > 110 ||
|
||||
mb_strlen($data['heading'] . $data['accent']) > 110 ||
|
||||
mb_strlen($data['lead']) > 600 || mb_strlen($data['alt']) > 200 ||
|
||||
($data['image_scale'] !== 0 && ($data['image_scale'] < CanvasStyle::MIN_MEDIA_SCALE || $data['image_scale'] > 100)) ||
|
||||
strlen($data['image']) > 1000 || ($data['image'] !== '' && !Html::url($data['image'], true))) {
|
||||
@@ -580,6 +580,9 @@ class AdminController
|
||||
continue;
|
||||
}
|
||||
$section = $available[$key] ?? ['key' => $key, 'title' => '', 'lead' => '', 'body' => '', 'style' => 'plain'];
|
||||
if ($isNew && ($change['style'] ?? null) === 'layout') {
|
||||
$section['style'] = 'layout';
|
||||
}
|
||||
if ($isNew && isset($change['template'])) {
|
||||
$preset = is_string($change['template']) ? BlockTemplates::find($change['template']) : null;
|
||||
if ($preset === null) {
|
||||
@@ -591,7 +594,8 @@ class AdminController
|
||||
if ($isNew && isset($change['copyOf'])) {
|
||||
$source = $change['copyOf']['key'] ?? null;
|
||||
$sourceVersion = $change['copyOf']['version'] ?? null;
|
||||
if (!is_string($source) || empty($available[$source]['feed']) || $sourceVersion !== (int) $available[$source]['version']) {
|
||||
if (!is_string($source) || !isset($available[$source]) || $available[$source]['style'] === 'hero-links'
|
||||
|| $sourceVersion !== (int) $available[$source]['version']) {
|
||||
throw new RuntimeException('原模块已变更,请刷新画布后再复制。');
|
||||
}
|
||||
$section = array_replace($available[$source], ['key' => $key]);
|
||||
@@ -647,9 +651,9 @@ class AdminController
|
||||
|
||||
private function checkSection(array $section, string $savedStyle): void
|
||||
{
|
||||
if ($section['title'] === '' || mb_strlen($section['title']) > 100 || mb_strlen($section['lead']) > 500
|
||||
if (mb_strlen($section['title']) > 100 || mb_strlen($section['lead']) > 500
|
||||
|| strlen($section['body']) > 300000 || !in_array($section['style'], [$savedStyle, 'plain', 'tinted'], true)) {
|
||||
throw new RuntimeException('请填写区块标题,并检查说明及正文长度。');
|
||||
throw new RuntimeException('请检查区块标题、简介及正文长度。');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user