TinyMCE is adding \n
as well as paragraph tags to my text. Regardless of the apply_source_formatting
settings value.
ie.
Source Text:
<blockquote><div class="cite">Person said:</div><div class="message"><p>ffgfgf</p></div></blockquote>
What TinyMCE Re-formats it to:
<blockquote>\n<div class=\"cite\">Person said:</div>\n<div class=\"message\">\n<p>ffgfgf</p>\n</div>\n</blockquote>\n<p id=\"mce_1\"> </p>
How can I get TimyMCE to stop adding new line characters like this? It really messes with the formatting on the other end when the text is submitted.
Investigating the source code of TinyMce I've found, that in the Writer.js
(now Writer.ts
) class, the setting that is checked before inserting \n
is called indent
.
/**
* Writes the a end element such as </p>.
*
* @method end
* @param {String} name Name of the element.
*/
end: function(name) {
var value;
html.push('</', name, '>');
if (indent && indentAfter[name] && html.length > 0) {
value = html[html.length - 1];
if (value.length > 0 && value !== '\n') {
html.push('\n');
}
}
},
So adding indent: false
to the settings object seems to fix it.
tinymce.init({
selector: 'textarea', // change this value according to your HTML
indent: false,
});
I'd still classify this as a rather hackish fix as the indent
-setting is not documented anywhere.
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