feat(web): live markdown preview via POST /_md host glue

Markdown form fields render a dual-pane shell; official boot posts textarea input to /_md for GFM HTML without author business JS.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
cflmyandCursor committed 2026-09-18 13:01:43 +08:00
1 parent 4b7643d833
commit 6bd127a313
5 files changed
+77 -2

No files matched your search

+7 -2
View File
@@ -801,9 +801,14 @@ func RenderBodyCtx(formBag map[string]any, formID string, data, errors any, csrf
if ty == "markdown" {
rows = "18"
cls = ` class="mq-markdown" data-mq-field="markdown"`
body.WriteString(`<div class="md-field">`)
fmt.Fprintf(&body, `<textarea name="%s" rows="%s"%s%s>%s</textarea>`,
esc(name), rows, cls, reqAttr, esc(value))
body.WriteString(`<div class="mq-md-preview md-pane-preview" aria-live="polite"></div></div>`)
} else {
fmt.Fprintf(&body, `<textarea name="%s" rows="%s"%s%s>%s</textarea>`,
esc(name), rows, cls, reqAttr, esc(value))
}
fmt.Fprintf(&body, `<textarea name="%s" rows="%s"%s%s>%s</textarea>`,
esc(name), rows, cls, reqAttr, esc(value))
} else {
inputType := "text"
switch ty {
+2
View File
@@ -82,6 +82,8 @@ func TestRenderMarkdownAndLabels(t *testing.T) {
for _, want := range []string{
`data-mq-field="markdown"`,
`class="mq-markdown"`,
`class="md-field"`,
`mq-md-preview`,
">发布文章</button>",
`href="/desk/posts"`,
">返回列表</a>",