CKEditor 4.2.2 - allowedContent = true不起作用

Pie*_*rre 3 javascript config ckeditor

我想我已经阅读了大部分有关此问题的SO问题和CKEditor文档,但它对我不起作用.

它应该简单明了,在我的CKEditor config.js中,我有这个:

CKEDITOR.editorConfig = function(config) {
    config.allowedContent = true;
};
Run Code Online (Sandbox Code Playgroud)

但是html仍然被过滤掉了,这条代码被剥离了:

<p>
<a href="/site/public/press.pdf"><span class="icon-presseFile"></span></a>
<a href="/site/public/pics.zip"><span class="icon-pressePics"></span></a>
</p>
Run Code Online (Sandbox Code Playgroud)

进入这个:

<p>&nbsp;</p>
Run Code Online (Sandbox Code Playgroud)

<span>元素是字体的图标.

任何帮助将不胜感激.

编辑 如果我在<span>元素中添加一些文本(但我不想这样做),它是有效的

Wil*_*son 14

我发现我必须在主配置功能的OUTSIDE中添加它.

这有效:

CKEDITOR.editorConfig = function( config ) {
...
};
CKEDITOR.config.allowedContent = true;
Run Code Online (Sandbox Code Playgroud)

但这没有:

CKEDITOR.editorConfig = function( config ) {
    config.allowedContent = true;
    ...
};
Run Code Online (Sandbox Code Playgroud)


小智 7

请注意,它可能是一个流氓插件,导致config.allowedContent = true被忽略.我刚刚以12小时的成本学到了这一点.

有问题的插件会在自定义配置文件中覆盖config.allowedContent = true.因此,如果您正在撞击CKEditor上的墙壁,请尝试禁用/注释掉所有插件(config.extraPlugins).如果问题消失了,你知道其中一个插件是原因.