{{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>
            <aside class="editor-sidebar">
                <div class="editor-sidebar-section">
                    <h4>快捷语法</h4>
                    <ul class="tips-list">
                        <li><code>#</code> <code>##</code> <code>###</code> 标题</li>
                        <li><code>**粗体**</code> <code>*斜体*</code></li>
                        <li><code>`行内代码`</code></li>
                        <li><code>```</code> 代码块</li>
                        <li><code>&gt;</code> 引用</li>
                        <li><code>-</code> 无序列表</li>
                        <li><code>[文字](链接)</code></li>
                        <li><code>![图片](链接)</code></li>
                    </ul>
                </div>
                <div class="editor-sidebar-section">
                    <h4>发布提示</h4>
                    <ul class="tips-list">
                        <li>标题控制在 50 字以内</li>
                        <li>正文清晰分段，便于阅读</li>
                        <li>代码使用代码块包裹</li>
                        <li>Ctrl+S 快速保存草稿</li>
                    </ul>
                </div>
            </aside>
        </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?v={{assetV "/static/vditor/dist/index.css"}}">
<script src="/static/vditor/dist/index.min.js?v={{assetV "/static/vditor/dist/index.min.js"}}"></script>
<script src="/static/js/common.js?v={{assetV "/static/js/common.js"}}"></script>
<script type="module" src="/static/js/editor.js?v={{assetV "/static/js/editor.js"}}"></script>
</body>
</html>
