Tinymce使用按钮添加文本
我正在尝试在TinyMce编辑器外实现一个按钮,该按钮将在单击时向活动编辑器添加文本。 我该怎么做 (例如:我的网站上有一个按钮,应该在编辑器中添加“Test”,但它没有)Tinymce使用按钮添加文本,tinymce,Tinymce,我正在尝试在TinyMce编辑器外实现一个按钮,该按钮将在单击时向活动编辑器添加文本。 我该怎么做 (例如:我的网站上有一个按钮,应该在编辑器中添加“Test”,但它没有) 感谢您的帮助:)将此代码添加到单击按钮时: // 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').
感谢您的帮助:)将此代码添加到单击按钮时:
// 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')
,这就是我得到的:(代码通过循环,这就是它重复的原因。此外-错误来自chrome的开发工具)然后尝试使用get方法获取编辑器实例。“UncaughtTypeError:无法调用null的方法'execCommand'”—我猜发生这种情况是因为tinymce.activeEditor未在该点设置。当用户单击编辑器实例时,设置activeEditor。如果页面上只有一个编辑器,也可以使用tinymce.editors[0]