Tinymce 4.x扩展插件

Tinymce 4.x扩展插件,tinymce,tinymce-4,Tinymce,Tinymce 4,我正在寻找一些关于如何扩展现有tinymce(4.x)插件的示例,例如“link”插件 链接插件打开一个对话框窗口。。。我想做的是在对话框打开时添加一个事件并修改主体(插入一些额外的HTML和click事件) 做得好似乎有问题。。。我想避免一些“在顶部”的代码,如$('#mce_13')。单击(…)并使用类似 editor.on('DialogOpen', function(e) { // if link dialog then $(e.body).append('<div

我正在寻找一些关于如何扩展现有tinymce(4.x)插件的示例,例如“link”插件

链接插件打开一个对话框窗口。。。我想做的是在对话框打开时添加一个事件并修改主体(插入一些额外的HTML和click事件)

做得好似乎有问题。。。我想避免一些“在顶部”的代码,如
$('#mce_13')。单击(…)并使用类似

editor.on('DialogOpen', function(e) {
    // if link dialog then
    $(e.body).append('<div>My HTML</div>');
});
editor.on('DialogOpen',函数(e){
//如果链接对话框,则
$(e.body).append('myhtml');
});

但是,不存在类似于
onDialogOpen
的事件。。。是否有最佳实践来实现这一点?

我成功地为模式窗口实现了这一点(我需要对打开/关闭进行回调),也许您可以在此基础上检测打开的窗口类型:

tinymce.init({
    //... code and setup here
    setup: function(editor) {
        editor.on('init',function(e) {
            setModalEvents(editor);
        });
    },
    //... and more here perhaps
});
然后函数本身:

// override modal methods to insert events
function setModalEvents(editor) {
    editor.windowManager.oldOpen = editor.windowManager.open;  // save for later
    editor.windowManager.open = function(t,r) {    // replace with our own function
        alert("modal window opened, insert callback here");
        var modal = this.oldOpen.apply(this, [t,r]);  // call original
        modal.on('close', function() {  // set event for close
            alert("modal window closed, insert callback here");
        });
        return modal; // Template plugin is dependent on this return value
    };
}

您可以在tinymce core中对其他内容执行类似的重写,因此这可能会有所帮助。

对我来说足够扩展:)