如何调用TinyMCE插件函数? [英] how call a TinyMCE plugin function?

查看:715
本文介绍了如何调用TinyMCE插件函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何调用tinymce插件函数?

  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); 

函数调用可能还有另外一个原因:
您想要的函数调用需要定义的函数 getInfo _save _nodeChange 在save插件中(参见tinymce的开发人员构建来检查插件目录中的插件)。



Save插件缩短了这里:

 (function(){
tinymce.create('tinymce.plugins.Save',{
init:function(ed ,url){
...
},

getInfo:function(){
...
},

//私有方法

_nodeChange:函数(ed,cm,n){
...
},

//私有方法
...
_save:function(){


});

//注册插件
tinymce .PluginManager.add(的ave',tinymce.plugins.Save);
})();

您可以调用此函数的 getInfo 函数插件使用以下JavaScript调用:

  tinymce.get('your_editor_id_here')。plugins.save.getInfo(); 


how can I call a tinymce plugin function?

 tinymce.activeEditor.plugins.customplugin.customfunction(customvar);

not working!

解决方案

tinymce.activeEditor.plugins.customplugin.customfunction(customvar);

is the correct way to call such a function. Be aware that tinymce.activeEditor needs to be set already in order to use it. tinymce.activeEditor gets set when the user clicks into the editor for example. Otherwise use

tinymce.get('your_editor_id_here').plugins.customplugin.customfunction(customvar);

There might be another reason for your function call not to work: The function you want to call needs to be defined like the functions getInfo, _save and _nodeChange in the save plugin (see the developer build of tinymce to inspect this plugin in the plugins directory).

The save plugin shortened here:

(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);
})();

You may call the getInfo function of this plugin using the following javascript call:

tinymce.get('your_editor_id_here').plugins.save.getInfo();

这篇关于如何调用TinyMCE插件函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆