在tinyMCE富文本编辑器中的光标位置插入文本

Jan*_*ana 4 html javascript tinymce

我有几个下拉框,应在tinyMCE富文本编辑器中的光标位置插入动态文本(根据选择)。

我发现了很多与上述问题相关的帖子,如下所示,它当前不适用于我的代码,也没有在控制台中给出任何错误。

tinyMCE.execInstanceCommand('text',"mceInsertContent",false,"This is the text to be inserted");
// here 'text' is id of textarea on which TinyMCE is rendered
Run Code Online (Sandbox Code Playgroud)

我想当我单击下拉框时,我失去了文本编辑器中的焦点,但我仍然无法解决这个问题。

任何帮助将不胜感激。

Jan*_*ana 5

需要使用如下所示execCommand的insted ,execInstanceCommand

tinyMCE.execCommand('mceInsertContent',false,"This is the text to be inserted");
Run Code Online (Sandbox Code Playgroud)

原因是我使用了tinyMCE旧版本(2X),所以大多数命令不适用于旧API。