简体   繁体   English

使用默认的wp-editor设置在wp-admin中初始化tinymce

[英]Initialize tinymce in wp-admin with default wp-editor settings

I'm creating a metabox which contains an 'add content' button. 我正在创建一个包含“添加内容”按钮的metabox。 Everytime you press it, a box with extra content is added. 每次按下时,都会添加一个包含其他内容的框。 In the already existing blocks on pageload I use the wp_editor function which works correctly. 在页面加载的现有块中,我使用wp_editor函数,该函数可以正常工作。

Now, when I add a block of content with jQuery I want to fire tinymce init on it. 现在,当我使用jQuery添加内容块时,我想在其上启动tinymce init。 I got the following code: 我得到以下代码:

                    tinymce.init({
                        selector:'#content_'+count+
                    });

This works, it fires tinymce on the selected textarea, but I can't find how I can configure it to be exactly as the standard wp_editor.. How do I have to call it to get it exactly the same as the default editor? 这行得通,它会在选定的文本区域上触发tinymce,但是我找不到如何将其配置为与标准wp_editor完全相同的方法。如何调用它才能使其与默认编辑器完全相同?

You can check the default options wordpress uses. 您可以检查wordpress使用的默认选项。 They are located in: /wp-includes/class-wp-editor.php . 它们位于: /wp-includes/class-wp-editor.php

Instead of copying that you can more easily just extend the existing tinymce object and tell it to include your textarea with: 除了复制外,您还可以更轻松地扩展现有的tinymce对象,并告诉它包含以下内容的textarea:

tinyMCE.execCommand('mceAddControl', false, '#content_'+count); 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM