- 编辑器:Tiptap 替换为 Vditor 3.11.2(wysiwyg 模式,本地托管 5.8MB,去 CDN) - 存储:Body 字段从 HTML 改为 Markdown,去除 BodyHTML,新增 Excerpt 列表摘要 - 安全:去除 bluemonday 依赖(MD 纯文本无 XSS 风险),go.mod 已清理 - Shortcode:新增 [zone:type:params] 扩展语法,支持活动/游戏/投票/资源卡片 - 图片上传:POST /api/posts/upload-image 直接返回 Vditor 原生响应格式 - 草稿:localStorage 键名改为 draft_post_body_md,与旧 HTML 草稿隔离 - 详情页:Vditor.method.min.js 客户端 MD → HTML 渲染,去 highlight.js CDN - 样式:去 Tiptap 样式 ~190 行,精简工具栏 CSS,新增卡片样式 - 文档:vditor-migration-plan.md 完整记录迁移决策、架构、用法
47 lines
1.7 KiB
HTML
47 lines
1.7 KiB
HTML
{{template "layout/header.html" .}}
|
|
<body>
|
|
|
|
{{template "layout/nav.html" .}}
|
|
|
|
<div class="editor-layout">
|
|
<form id="postForm" class="editor-form">
|
|
<input type="hidden" id="postId" value="{{if .Post}}{{.Post.ID}}{{end}}">
|
|
{{/* 编辑模式下传入已有的 MD 内容 */}}
|
|
{{if .Post}}
|
|
<textarea id="editBody" style="display:none">{{.Post.Body}}</textarea>
|
|
{{end}}
|
|
|
|
{{/* 标题区域 */}}
|
|
<div class="editor-header">
|
|
<input type="text" id="postTitle" class="editor-title-input"
|
|
value="{{if .Post}}{{.Post.Title}}{{end}}"
|
|
placeholder="输入文章标题..."
|
|
maxlength="200" required autofocus>
|
|
</div>
|
|
|
|
{{/* Vditor 编辑器容器(工具栏+编辑区由 Vditor 自动生成) */}}
|
|
<div class="editor-main">
|
|
<div class="editor-pane">
|
|
<div id="vditor"></div>
|
|
</div>
|
|
</div>
|
|
|
|
{{/* 状态栏 */}}
|
|
<div class="editor-statusbar">
|
|
<span class="status-item" id="wordCount">0 字</span>
|
|
<span class="status-item status-draft" id="draftStatus" style="display:none">草稿已保存</span>
|
|
<span class="status-spacer"></span>
|
|
<button type="submit" class="btn btn-primary btn-submit">{{if .Post}}保存修改{{else}}发布帖子{{end}}</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
|
|
{{template "layout/footer.html" .}}
|
|
|
|
<link rel="stylesheet" href="/static/vditor/dist/index.css">
|
|
<script src="/static/vditor/dist/index.min.js"></script>
|
|
<script src="/static/js/common.js"></script>
|
|
<script type="module" src="/static/js/editor.js"></script>
|
|
</body>
|
|
</html>
|