When using tinyMCE, is there a way to get a reference to the toolbar from an editor's instance?

1.3k views Asked by At

I'm using tinymce, inline mode, and in certain cases I need the ability to show/hide the toolbar of the active editor using javascript. It should be something like:

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

Only that given an editor instance, I couldn't find any way to get a reference to its toolbar.

Also note that there might be several toolbars on the page, but only one is displayed at any given time.

The toolbar is initialized like this:

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

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

Thanks.

1

There are 1 answers

2
Cymen On

There is a discussion about this on the TinyMCE forum. It suggests:

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