forked from laysense/laysite
Add page publication history and reusable blocks
This commit is contained in:
@@ -5,6 +5,26 @@ use App\Content\View;
|
||||
|
||||
$e = View::escape(...);
|
||||
$canvas ??= false;
|
||||
if ($canvas && isset($section['mirror_id'])) {
|
||||
$source = $section['mirror_source'] ?? null;
|
||||
?>
|
||||
<section class="studio-mirror-block" data-studio-mirror data-studio-section="<?= $e($section['version']) ?>"
|
||||
data-studio-key="<?= $e($section['key']) ?>" data-studio-type="镜像区块" data-studio-mirror-title="<?= $e($section['title']) ?>">
|
||||
<div inert aria-hidden="true"><?= View::fragment('section', ['section' => $section, 'canvas' => false, 'moment' => false, 'pageSlug' => $pageSlug]) ?></div>
|
||||
<div class="studio-mirror-overlay">
|
||||
<div class="studio-mirror-note">
|
||||
<span><?= $source ? '镜像区块 · 修改请前往主区块' : '主区块已移除 · 可取消关联后编辑' ?></span>
|
||||
<?php if ($source): ?>
|
||||
<a href="/admin/pages/<?= $e($source['page_slug']) ?>?block=<?= $e(rawurlencode($source['section_key'])) ?>#blocks"
|
||||
target="_blank" rel="noopener noreferrer" data-studio-mirror-open>前往主区块 ↗</a>
|
||||
<?php endif ?>
|
||||
<button type="button" data-studio-mirror-detach>取消关联</button>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<?php
|
||||
return;
|
||||
}
|
||||
$body = $section['body'];
|
||||
$dynamic = !empty($section['feed']);
|
||||
$presentation = json_decode($section['presentation'] ?? '{}', true, flags: JSON_THROW_ON_ERROR);
|
||||
@@ -13,6 +33,9 @@ $text = static fn (string $role): string => CanvasStyle::text($presentation, $ro
|
||||
$id = static fn (string $role, string $fallback = ''): string => CanvasStyle::idAttributes($presentation, $role, $canvas, $fallback);
|
||||
$anchor = CanvasStyle::originalAnchor($presentation, 'section', $section['key']);
|
||||
$studio = $canvas ? ' data-studio-section="' . $e($section['version']) . '" data-studio-key="' . $e($section['key']) . '" data-studio-template="' . $e($presentation['template'] ?? '') . '" data-studio-type="' . $e(BlockTemplates::sectionType($section, $presentation)) . '" data-studio-source="' . $e(base64_encode($section['body'])) . '"' : '';
|
||||
if ($canvas && isset($section['main_id'])) {
|
||||
$studio .= ' data-studio-main';
|
||||
}
|
||||
if ($canvas && $dynamic) {
|
||||
$studio .= ' data-studio-dynamic data-studio-feed="' . $e($section['feed']) . '" tabindex="0"';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user