Search code examples
tinymce

TinyMCE class name


Is there a built in TinyMCE command to change the class name of its outer-most div? I have a div which is populated with either a PHP version of TinyMCE or the jQuery version, but the TinyMCE editor's outermost div classes are different. I would preferably like to avoid having to use jQuery.

jQuery

class="mce-tinymce mce-container mce-panel"

PHP

class="wp-core-ui wp-editor-wrap tmce-active"

I don't mind if I can only change one, although it would be nice to know how to change both. I have tried

tinymce.inti({
    body_class:"classname";
});

Solution

  • From docs

    // Add a class to an element by id in the page
    tinymce.DOM.addClass('someid', 'someclass');
    
    // Add a class to an element by id inside the editor
    tinyMCE.activeEditor.dom.addClass('someid', 'someclass');