使用tinyMCE时,有没有办法从编辑器的实例获取对工具栏的引用?

时间:2015-06-14 07:05:10

标签: javascript tinymce tinymce-4

我正在使用tinymce,内联模式,在某些情况下,我需要能够使用javascript显示/隐藏活动编辑器的工具栏。 它应该是这样的:

tinymce.activeEditor.getToolbar() // getToolbar doesn't exist

只有在给定编辑器实例的情况下,我找不到任何方法来获取对其工具栏的引用。

另请注意,页面上可能有多个工具栏,但在任何给定时间只显示一个工具栏。

工具栏初始化如下:

     tinymce.init({
                selector: "#" + id,

                menubar: false,
                inline: true,
                theme: "modern",
                oninit: "setPlainText"
                ...

感谢。

1 个答案:

答案 0 :(得分:1)

有一个discussion about this on the TinyMCE forum。它表明:

...
    setup: function (theEditor) {
        theEditor.on('focus', function () {
            $(this.contentAreaContainer.parentElement).find("div.mce-toolbar-grp").show();
        });
        theEditor.on('blur', function () {
            $(this.contentAreaContainer.parentElement).find("div.mce-toolbar-grp").hide();
        });
        theEditor.on("init", function() {
            $(this.contentAreaContainer.parentElement).find("div.mce-toolbar-grp").hide();
        });
    }
...
相关问题