如何用TinyMCE替换元素
问题描述:
I'm using TinyMCE and i'm creating a new plugin.
I need, in this plugin, to replace something i have selected in the text by an other thing.
With this : var inst = tinyMCE.activeEditor;
i can have a instance of my editor.
How can i retrieve my selection ? How can i replace my selection by, for example <span>MYSELECTION</span>
?
Thanks !
我正在使用TinyMCE,我正在创建一个新的插件。 p>
在这个插件中,我需要用其他东西替换我在文本中选择的东西。 p>
使用这个: 如何检索我的选择? 如何替换我的选择,例如 谢谢! p>
div> var inst = tinyMCE.activeEditor; code> 我可以拥有我的编辑器实例。 p>
&lt; span&gt; MYSELECTION&lt; / span&gt; code>? p>
答
Try this:
<a href="#" onclick="tinyMCE.execCommand('mceReplaceContent',false,'<span>{$selection}</span>');return false;">[Replace selection]</a>
EDIT: About retrieving selection see this question.