admin管理员组文章数量:1122846
I've a custom post type in a custom plugin. In this post type, I am assigning a meta box field for some fixed hero content. This is just a textarea
that I am applying tinymce
to.
This works well, but I also need to support Gutenberg blocks for this post type. But when I add support for 'editor'
for this post type it breaks the tinymce
implementation for the custom meta box field.
tinymce
displays and I can edit the "text" of the input field, but I cannot see, edit, or click into the tinymce
"visual" editor. (The following image shows a textarea field that has text but is non-editable in the visual editor)
plugin.php:
function custom_post_type() {
register_post_type('post_type_id',
[
'show_in_rest' => true,
'supports' => ['editor'], <- editor breaks tinymce later
]
);
}
add_action('init', 'custom_post_type');
function text_area_wysiwyg_script() {
wp_enqueue_editor();
wp_enqueue_script('text-area-wysiwyg', plugin_dir_url(__FILE__) . '/js/text-area-wysiwyg.js', [], '1.0', true);
}
add_action('admin_print_footer_scripts', 'text_area_wysiwyg_script');
text-area-wysiwyg.js:
jQuery(function textAreaToWysiwyg() {
wp.editor.initialize("editor_id", {
tinymce: {
wpautop: true,
plugins : '...',
toolbar1: '...',
},
quicktags: true,
mediaButtons: false
});
});
In the JS file I've also tried:
tinymce.execCommand('mceAddEditor', true, 'editor_id');
How can I have both editor support (for Gutenberg blocks) and a custom meta field with tinymce in one post type?
本文标签: tinymcewpeditorinitialize() breaks when support for 39editor39 is added to custom post type
版权声明:本文标题:tinymce - wp.editor.initialize() breaks when support for 'editor' is added to custom post type 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736305579a1932638.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论