[英]how call a TinyMCE plugin function?
如何調用tinymce插件函數?
tinymce.activeEditor.plugins.customplugin.customfunction(customvar);
不工作!
tinymce.activeEditor.plugins.customplugin.customfunction(customvar);
是調用這樣一個函數的正確方法。 請注意,需要設置tinymce.activeEditor
才能使用它。 tinymce.activeEditor
,當用戶點擊編輯器時,會設置tinymce.activeEditor
。 否則使用
tinymce.get('your_editor_id_here').plugins.customplugin.customfunction(customvar);
您的函數調用可能還有另一個原因:要調用的函數需要像保存插件中的函數getInfo
, _save
和_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!');
}
}
然后:
tinymce.get('your_editor_id_here').plugins.myplugin.myFunction();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.