我想阻止html实体转换。它在每次按键时转换实体。
我已经试过了
entity_encoding: "named",
entities: '160,nbsp,38,amp,60,lt,62,gt'
和
entity_encoding: "named",
entities: ' '
还有别的事要做吗?这是我的TinyMCE初始化,
tinymce.init({
selector: selector,
apply_source_formatting:true,
entity_encoding: "named",
entities: '160,nbsp,38,amp,60,lt,62,gt',
force_p_newlines: force_p,
forced_root_block: forced_root,
valid_elements: "*[*]",
invalid_elements: invalid_elms,
valid_children: "+span[div],+th[input]",
extended_valid_elements: "sc[id],dd[*],dt[*],monospace[*],input[*]",
custom_elements: "~sc,~monospace,~input",
table_toolbar: "",
menubar: false,
save_enablewhendirty: false,
toolbar1: toolbar_icons,
plugins: [plugins_str],
inline: true,
formats: format_array_new,
resize: true,
toolbar_sticky: true,
contextmenu: false,
remove_script_host: false,
skin_url: this._global.tinymceUrl + "/skins/ui/oxide",
autofocus: true,
fixed_toolbar_container: "#editor-toolbar",
draggable_modal: true,
paste_auto_cleanup_on_paste: true,
paste_remove_spans: true,
paste_remove_styles: true,
paste_text_sticky: true,
paste_strip_class_attributes: "all",
paste_retain_style_properties: "",
paste_as_text: true,
});
发布于 2020-04-15 22:10:43
在处理包含任意类型的多个空格字符串的内容时,TinyMCE将(与配置设置无关)混合使用硬空格(
)和常规空格。
例如,如果您键入一个字母,按空格键5次,然后另一个字母TinyMCE将以如下形式结束:
a b
这样做有几个原因:
当TinyMCE序列化程序运行时,空间管理是进程的一部分,而不是您可以禁用的东西。
你能做的就是包装你不想修改的硬空格。如果您加载不间断空格TinyMCE插件,则有一个用于此功能的配置选项:
https://www.tiny.cloud/docs/plugins/nonbreaking/#nonbreaking_wrap
因为默认情况下这是“开”的,当你加载不间断空格插件时,你会看到,如果你使用菜单插入/不间断空格,你会得到类似这样的结果:
<span class="mce-nbsp-wrap" contenteditable="false"> </span>
除了具有适当类的span之外,这没有什么“魔力”。如果您想以这种方式包装任何硬空间,TinyMCE将不会在空间管理过程中修改该空间。
发布于 2021-05-06 01:06:29
因为我已经在这个问题上挣扎了很多,而且正如Michael Fromin的回答中所描述的那样,因为标准nbsp
给HTML中的富文本编辑器带来了一系列问题,所以我决定完全跳过使用nbsp
,而使用另一个Unicode不间断的空格,如下所述:https://en.wikipedia.org/wiki/Non-breaking_space#Width_variation
更具体地说,我最终使用了"Figure space“字符,它呈现为比正常情况下更宽的空格(取决于字体),但在大多数情况下可能比细的不间断空格更好。我创建了一个自定义按钮,它在内容中添加了这个特殊字符。
只需确保您使用的任何字体都支持此字形,特别是当您正在为PDF等其他输出处理生成的HTML时。
https://stackoverflow.com/questions/61221847
复制相似问题