fix(submit): render the configured body placeholder in TinyMCE

WordPress 打包的 TinyMCE 4.9 不含官方 placeholder 插件,tinymce.init 里的
placeholder 配置被静默忽略,投稿页「投稿内容占位符」从未显示过。

新增主题插件 assets/js/front-submit-placeholder.js:正文为空时插入一个
data-mce-bogus 的占位段落,有内容即移除;序列化 / 解析都剔除该段落,
字数统计也跳过它,提示文字不会写进文章。

- 经典投稿表单与创作者工作台都通过 external_plugins 加载
  (WordPress 会丢弃名字已在 plugins 列表里的外部插件)
- 占位样式写进 iframe 的 content CSS:submit-editor.css 与
  editor-content-style.ts

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
kate522andClaude Opus 5 committed 2026-11-09 19:01:28 +08:00
1 parent beb898b1ab
commit 44a03fd5f4
8 files changed
+228 -3

No files matched your search

@@ -19,6 +19,17 @@ body {
letter-spacing: 0.01em;
}
p { margin: 0 0 1.1em; }
/*
* 正文占位符:TinyMCE 4.9 没有内置 placeholder 插件,由主题插件
* (front-submit-placeholder.js)在正文为空时插入这个不可编辑的段落。
*/
.jio-editor-placeholder {
color: #b9bfbc;
cursor: text;
pointer-events: none;
user-select: none;
}
h1, h2, h3, h4, h5, h6 { margin: 1.5em 0 0.65em; line-height: 1.4; }
img, iframe { max-width: 100%; }
img { height: auto; }
+4
View File
@@ -376,6 +376,10 @@ function Studio(): JSX.Element {
toolbar2: '',
toolbar3: '',
plugins: 'paste,link,lists,wordpress,wplink',
// WordPress 打包的 TinyMCE 没有 placeholder 插件,占位符由主题插件实现。
external_plugins: bootstrap.creator?.placeholderPlugin
? { jio_placeholder: bootstrap.creator.placeholderPlugin }
: undefined,
wpautop: true,
body_class: 'jio-creator__tinymce',
content_css: bootstrap.creator?.contentCss || '',