Bootstrap CKEditor和转义元素

vwkv1x7d  于 2022-12-07  发布在  Bootstrap
关注(0)|答案(3)|浏览(144)

I've using CKEditor for updating CMS content on my website. I also using FontAwesome, which includes set of fancy icons, that can be displayed like this

<i class="icon-envelope"></i>

The problem is that CKEditor escapes this i tag on client side, and I can't see it in source mode.
How can I allow this tag? I have tried with CONFIG.removeFormatTags = '' , but unfortunately it does not do the job.

3wabscal

3wabscal1#

因为它是空的,所以被删除。在它里面放一些不间断空格&nbsp;或零宽度空格&#8203;以保留您的标记。
你也可以从CKEDITOR.dtd.$removeEmpty对象中移除i。但是,这可能会破坏其他没有class="icon-envelope"的空<i>标签。要解决这个问题,你需要使用data processor来过滤没有class="icon-envelope"的空<i>'s。我想这很简单。

wgeznvg7

wgeznvg72#

下面的代码对我很有用..感谢Vince Kronlein指出的config.fillEmptyBlocks

CKEDITOR.editorConfig = function( config ) {
       config.fillEmptyBlocks="&#8203;";  
}
CKEDITOR.dtd.$removeEmpty['span'] = false;
CKEDITOR.dtd.$removeEmpty['i'] = false;
rseugnpd

rseugnpd3#

你可以在CKEditor中显示html代码的情况下使用&zwnj;的unicode,以在波斯语等语言中生成零宽度非连接符(迷你空格)。
我是一个很棒的人

相关问题