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?
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.
To just center the text inside an element, use text-align: center; This text is centered.
To center text in JavaScript, do this: element. style. textAlign = 'center' .
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'}}
}
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With