Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TinyMCE use <div align="center"> instead of <div style="text-align: center">?

I am using TinyMCE 3.2.5 and by default when you click the center align button it uses an inline style <div style="text-align=center">. I would like tinyMCE to use <div align="center"> instead of the inline style.

I know setting inline_styles: false in the configuration works. But I would like to use inline styles for everything but alignment.

How would I go about changing this?

like image 309
Matt MacLean Avatar asked Jul 16 '09 22:07

Matt MacLean


People also ask

How do I align something to the center of a div?

You can do this by setting the display property to "flex." Then define the align-items and justify-content property to “center.” This will tell the browser to center the flex item (the div within the div) vertically and horizontally.

How do I align text to the center of a container?

To just center the text inside an element, use text-align: center; This text is centered.

How do I center an item in JavaScript?

To center text in JavaScript, do this: element. style. textAlign = 'center' .


1 Answers

tinyMCE.init({
        ...
        'formats' : {
        'alignleft' : {'selector' : 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', attributes: {"align":  'left'}},
        'aligncenter' : {'selector' : 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', attributes: {"align":  'center'}},
        'alignright' : {'selector' : 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', attributes: {"align":  'right'}},
        'alignfull' : {'selector' : 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', attributes: {"align":  'justify'}}
    }
})
like image 73
Jane Avatar answered Sep 20 '22 13:09

Jane