添加文本按钮的Tinymce

时间:2012-09-11 14:45:29

标签: tinymce

我正在尝试在TinyMce编辑器之外实现一个按钮,它会在单击时将文本添加到活动编辑器。 我怎么能这样做?

(例如:我的网站上有一个按钮,应该将“Test”添加到编辑器中,但它没有。)

感谢您的帮助:)

1 个答案:

答案 0 :(得分:3)

将此代码添加到按钮的onClick:

// the editor id is the same id of your textarea, default "content" in case your textarea does not have an id

tinymce.get('your_editor_id').execCommand('mceInsertContent', false, "Test");

如果您的网页上只有一个编辑器,您也可以使用tinymce.activeEditor代替tinymce.get('your_editor_id')