Tinymce 4.x extend plugin

时间秒杀一切 提交于 2019-12-04 09:42:58
Christoffer Bubach

I managed to do this for modal windows ( i needed callbacks for open/close ) maybe you could build on it to also detect what type of window is opened:

tinymce.init({
    //... code and setup here
    setup: function(editor) {
        editor.on('init',function(e) {
            setModalEvents(editor);
        });
    },
    //... and more here perhaps
});

and then the function itself:

// 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
    };
}

you could do similar overrides of other things in the tinymce core, so maybe this can be helpful.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!