Javascript 如何调用TinyMCE插件函数?
如何调用tinymce插件函数Javascript 如何调用TinyMCE插件函数?,javascript,jquery,function,tinymce,rte,Javascript,Jquery,Function,Tinymce,Rte,如何调用tinymce插件函数 tinymce.activeEditor.plugins.customplugin.customfunction(customvar); 不行 tinymce.activeEditor.plugins.customplugin.customfunction(customvar) 是调用此类函数的正确方法。 请注意,tinymce.activeEditor需要已经设置好才能使用它。 tinymce.activeEditor在用户点击编辑器时设置。 否则使用 ti
tinymce.activeEditor.plugins.customplugin.customfunction(customvar);
不行
tinymce.activeEditor.plugins.customplugin.customfunction(customvar)
是调用此类函数的正确方法。
请注意,tinymce.activeEditor
需要已经设置好才能使用它。
tinymce.activeEditor
在用户点击编辑器时设置。
否则使用
tinymce.get('your_editor_id_here').plugins.customplugin.customfunction(customvar);
函数调用不起作用可能还有另一个原因:
要调用的函数需要定义为save插件中的函数getInfo
、\u save
和\u nodeChange
(请参阅tinymce的开发者版本,以检查插件目录中的此插件)
保存插件在此缩短:
(function() {
tinymce.create('tinymce.plugins.Save', {
init : function(ed, url) {
...
},
getInfo : function() {
...
},
// Private methods
_nodeChange : function(ed, cm, n) {
...
},
// Private methods
...
_save : function() {
}
});
// Register plugin
tinymce.PluginManager.add('save', tinymce.plugins.Save);
})();
您可以使用以下javascript调用调用此插件的getInfo
函数:
tinymce.get('your_editor_id_here').plugins.save.getInfo();
将要向外界公开的功能放入
self
中
tinymce.PluginManager.add('myplugin', function(editor) {
var self = this;
var self.myFunction = myFunction(); // Put function into self!
function myFunction() {
console.log('Hello world!');
}
}
然后:
引用:此链接现在不是最新的,因为插件的更新版本现在在plugin.add()方法的参数中使用匿名函数
tinymce.get('your_editor_id_here').plugins.myplugin.myFunction();