无论apply_source_formatting如何,TinyMCE都会添加新行(“\ n”)

时间:2016-05-13 08:28:40

标签: javascript tinymce

TinyMCE正在为我的文本添加\n以及段落标记。无论apply_source_formatting设置值如何。

来源文字:

<blockquote><div class="cite">Person said:</div><div class="message"><p>ffgfgf</p></div></blockquote>

TinyMCE将其重新格式化为:

<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\">&nbsp;</p>

如何让TimyMCE停止添加这样的新行字符?当提交文本时,它真的会混淆另一端的格式。

1 个答案:

答案 0 :(得分:6)

调查我发现的 TinyMce 的源代码,在Writer.js(现在为Writer.ts)类中,插入{{1}之前检查的设置被称为\n

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'); } } }, 添加到设置对象似乎可以修复它。

indent: false

我仍然将此归类为 hackish 修复,因为tinymce.init({ selector: 'textarea', // change this value according to your HTML indent: false, }); - 设置在任何地方都不是documented

相关问题