Files
laysense.cn/app/view/admin-editor.php
T

33 lines
1.7 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
use App\Content\View;
use App\Content\Html;
$e = View::escape(...);
?>
<div class="editor" data-editor data-format="<?= $format ?>">
<label for="editor-text">正文(<?= $format === 'markdown' ? 'Markdown' : 'HTML' ?>)</label>
<div class="editor-toolbar">
<div role="group" aria-label="插入格式">
<button type="button" data-insert="heading">小标题</button>
<button type="button" data-insert="bold">粗体</button>
<button type="button" data-insert="list">列表</button>
<button type="button" data-insert="link">链接</button>
</div>
<?php if ($format === 'html'): ?>
<button type="button" data-rich-media>插入媒体</button>
<button type="button" data-source-toggle aria-pressed="false">HTML 源码</button>
<?php else: ?>
<button data-preview-button type="button" aria-controls="editor-preview" aria-expanded="false">预览正文</button>
<?php endif ?>
</div>
<?php if ($format === 'html'): ?>
<div class="rich studio-rich" contenteditable="true" role="textbox" aria-multiline="true" aria-label="可视化正文" data-rich-canvas hidden><?= Html::sanitize($body) ?></div>
<p class="field-note" data-rich-status role="status" hidden></p>
<?php endif ?>
<textarea id="editor-text" name="body" rows="15" spellcheck="false"><?= $e($body) ?></textarea>
<?php if ($format === 'html'): ?>
<p class="field-note">可以直接编辑文字,插入链接、图片、音视频。复杂区块可切换到 HTML 源码调整。</p>
<?php endif ?>
<div class="editor-preview rich prose" id="editor-preview" aria-live="polite" hidden></div>
</div>