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:
1 parent
beb898b1ab
commit
44a03fd5f4
8 files changed
+228
-3
No files matched your search
@@ -76,6 +76,9 @@ final class CreatorStudio {
|
||||
|
||||
$payload = $this->bootstrap();
|
||||
$payload['creator']['contentCss'] = $content_css_url;
|
||||
// WordPress 打包的 TinyMCE 4.9 不含 placeholder 插件,
|
||||
// 占位符由主题插件实现,地址交给编辑器初始化。
|
||||
$payload['creator']['placeholderPlugin'] = $this->placeholder_plugin_url();
|
||||
$tinymce_data = $this->tinymce_payload($payload);
|
||||
|
||||
if (file_exists($plugin_path)) {
|
||||
@@ -121,6 +124,21 @@ final class CreatorStudio {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 正文占位符插件地址(带文件时间戳做缓存失效)。
|
||||
*/
|
||||
private function placeholder_plugin_url(): string {
|
||||
$path = get_template_directory() . '/assets/js/front-submit-placeholder.js';
|
||||
if (!file_exists($path)) {
|
||||
return '';
|
||||
}
|
||||
return (string) add_query_arg(
|
||||
'ver',
|
||||
(string) filemtime($path),
|
||||
get_template_directory_uri() . '/assets/js/front-submit-placeholder.js'
|
||||
);
|
||||
}
|
||||
|
||||
private function tinymce_payload(array $payload): array {
|
||||
$capabilities = is_array($payload['capabilities'] ?? null) ? $payload['capabilities'] : [];
|
||||
$base = rest_url(CreatorRest::NS);
|
||||
|
||||
Reference in new issue
Block a user