Files
mce/templates/MetaLab-2026/html/posts/new.html
Victor_Jay 22a302315a feat: wangEditor 替换为 ByteMD Markdown 编辑器
- 移除 wangEditor 5 库文件(1.27MB JS + 14KB CSS,含手动 hack)
- 集成 ByteMD 1.22.0(基于 CodeMirror 5,不依赖 contentEditable)
- 编辑器输出 Markdown 原文,后端 goldmark + bluemonday 双重防护渲染 HTML
- 删除 editor.js 中 scrollIntoView hack、code-lang-label DOM 注入、PreviewAPI 调用
- 清理 posts.css 中 ~200 行 wangEditor 样式覆盖(w-e-* 类名)
- 清理 show.html 中 code-lang-label JS 注入(goldmark 自带 language-xxx class)
- 更新 CSP 安全策略:移除 CodeMirror 注释,保留 esm.sh CDN
- go.mod:bluemonday 和 goldmark 均保留为直接依赖(纵深防御)
2026-05-28 02:16:50 +08:00

53 lines
1.8 KiB
HTML

{{template "layout/header.html" .}}
<link rel="stylesheet" href="https://esm.sh/bytemd@1.22.0/dist/index.css">
<link rel="stylesheet" href="https://esm.sh/highlight.js@11.9.0/styles/github.css">
<style>
/* ByteMD 编辑器容器适配全高布局 */
#editor-container {
flex: 1;
overflow: hidden;
min-height: 0;
height: 100%;
}
#editor-container .bytemd {
height: 100%;
}
</style>
<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}}">
{{/* 标题区域 */}}
<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>
{{/* 编辑器主体 */}}
<div class="editor-main">
<div class="editor-pane" id="editorPane">
<div id="editor-container" data-value="{{if .Post}}{{.Post.Body}}{{end}}"></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>
<span class="status-item" id="btnFullscreen" style="cursor:pointer" title="全屏编辑 (F11)">全屏</span>
<button type="submit" class="btn btn-primary btn-submit">{{if .Post}}保存修改{{else}}发布帖子{{end}}</button>
</div>
</form>
</div>
{{template "layout/footer.html" .}}
<script type="module" src="/static/js/editor.js"></script>