停止CKEditor删除div元素

9

我在我的网站后台安装了CKEditor。 当从代码视图切换到所见即所得视图时,我遇到了以下问题。 我插入的代码类似于:

<div class="span4">
    <p>Some text here</p>
</div>

当我切换回查看模式时,CKEditor会自动删除包围段落的div标签。请问有人能帮我解决这个问题吗?虽然我可以一直停留在代码视图中,但我更喜欢在查看模式下编写较长的文本。谢谢提前。

尝试将以下代码添加到 ckeditor 配置文件中:config.protectedSource.push( %\<.*\>.*\</.*\>%i ); - sAnS
你正在使用CKEditor 4.1吗?该版本包括一个新的“ACF”,它会删除任何未被其工具栏按钮允许的内容。 - AlfonsoML
是的,我正在使用 v4.1.1。 - xonorageous
3个回答

11

你不需要因为一个标签而禁用整个功能。 - oleq
3
你没有读懂我的帖子。看看这部分:“最好配置它”...... 我对ACF知之甚少,这正是我发布解释链接的原因。 - Spons

7

不要禁用ACF功能,使用config.extraAllowedContent代替:

editor.config.extraAllowedContent = 'div(span4)';

或者

editor.config.extraAllowedContent = 'div(*)';

2
var editor1=CKEDITOR.replace('editor1');
editor1.config.allowedContent = true;

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接