如何防止TinyMCE 5删除\ r \ n

问题描述 投票:0回答:1

我希望TinyMCE 5.0保留换行符的原始内容,与现在在Wordpress中使用的相同。

示例:

这是第一行\ r \ n这是第二行。

如何运作:

这是第一行,这是第二行。

我期望的是:

这是第一行

这是第二行。

我将此配置添加到Tinymce.init:

remove_linebreaks: false,
force_br_newlines: false,
force_p_newlines: false,
forced_root_block: '',
keep_styles: false,
fix_list_elements:true,
entity_encoding:"raw",
extended_valid_elements : '*[*]',
cleanup: false,
cleanup_on_startup: false,
trim_span_elements: false,
verify_html : false,
end_container_on_empty_block:true,
remove_trailing_brs: false,

插件:插件:

plugins: [
  'advlist autolink lists link image charmap print preview anchor',
  'searchreplace visualblocks code fullscreen, textpattern',
  'insertdatetime media table paste code help wordcount'
],

但是它仍然删除了我的换行符。我该如何解决?

javascript wordpress tinymce line-breaks resource-cleanup
1个回答
1
投票

TinyMCE是HTML编辑器-您的换行符不是HTML,因此TinyMCE的HTML验证代码正在删除它们。

如果想保留新行的效果,则需要先将其转换为有效的HTML,然后再尝试将其加载到TinyMCE中。您可以将该字符组合转换为<br><p>...</p>,以获得换行效果。

© www.soinside.com 2019 - 2024. All rights reserved.