【发布时间】:2022-01-22 01:07:27
【问题描述】:
我正在为 CKEditor 使用以下配置:
var wysiwyg = ck.replace(el[0], {
allowedContent: true,
protectedSource: [/\r|\n/g]
});
我正在将 HTML 源代码加载到 CKEditor 中:
<div style='font-weight: bold;'>
<div>
<div> test </div>
</div>
</div>
在wysiwyg.getData() 我收到:
<div style="font-weight: bold;">
<div>
<div>test</div>
</div>
</div>
如何强制 CKEditor 根据来源保持缩进?
我尝试在 protectedSource 中使用不同的正则表达式来保护 HTML >...< 之间的所有内容,例如 /(?:\>)([^<]*?)(?:\<)/g https://regex101.com/r/eV4dO0/1 但没有运气。
【问题讨论】:
-
我使用了来自docs.ckeditor.com/#!/guide/dev_output_format 的
setRules功能,但这并不理想。我想保持源格式不变。这可能吗? -
所以您不想让
<div style='font-weight: bold;'>...</div>不可在所见即所得模式下可编辑,还是仅仅保留格式?
标签: javascript ckeditor