Opsional
Opsional

Reputation: 543

Add custom class to tinyMCE body with custom button

i try add custom class to body tinyMCE with custom button but not working. I don't know why.

This my tinyMCE custom button code:

(function() {
    tinymce.PluginManager.add( 'columns', function( editor, url ) {
        // Add Button to Visual Editor Toolbar
        editor.addButton('columns', {
            title: 'Insert Column',
            cmd: 'columns',
            image: url + '/columns.jpg',
        });

        editor.addCommand('columns', function() {
            jQuery( 'body#tinymce' ).addClass( 'middle' );
            jQuery(editor.iframeHTML).addClass( 'middle' );
        });

    });
})();

Please give me solutions to make code working. Thanks.

Upvotes: 0

Views: 640

Answers (1)

m.kerkeni
m.kerkeni

Reputation: 247

Try to change this code

editor.addCommand('columns', function() {
    jQuery( 'body#tinymce' ).addClass( 'middle' );
    jQuery(editor.iframeHTML).addClass( 'middle' );
});

by this

 editor.addCommand('columns', function() {
     var b = editor.getBody();
     b.className = b.className + " middle"; 
 });

Upvotes: 1

Related Questions