我对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
内部使用不同的regex来保护>...<
之间的所有东西,比如/(?:\>)([^<]*?)(?:\<)/g
https://regex101.com/r/eV4dO0/1,但是没有运气。
发布于 2015-04-13 15:38:53
我想保持源格式的原样。这个是可能的吗?
,不,不是。内容在返回给您之前,会通过解析器、过滤器、作者和浏览器的DOM多次传递。您不能期望保留每个制表符或空格字符,这些字符在内容方面并不重要。请记住,CKEditor不是代码编辑器--它是WYSIWYG编辑器。
发布于 2022-01-21 17:07:27
请将CKeditor的这两行添加到Config文件中
config.protectedSource = [/\r|\n/g];
config.allowedContent = true;
https://stackoverflow.com/questions/29603854
复制相似问题