javascript 停止 CKEditor 删除 div
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16799778/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Stop CKEditor removing divs
提问by xonorageous
I've installed CKEditor in the backend of my website. I've got the following problem when switching from code view to wysiwyg view. The code I'm inserting is like:
我已经在我的网站后端安装了 CKEditor。从代码视图切换到所见即所得视图时,我遇到了以下问题。我插入的代码是这样的:
<div class="span4">
<p>Some text here</p>
</div>
When I switch back to view mode CKEditor automatically removes the div surrounding the paragraph.
当我切换回查看模式时,CKEditor 会自动删除段落周围的 div。
Can anyone please help me to remove this problem? I don't mind staying in code view but I do like working in the view mode for writing longer text.
任何人都可以帮我解决这个问题吗?我不介意留在代码视图中,但我确实喜欢在视图模式下工作以编写更长的文本。
Thanks in advance.
提前致谢。
回答by Spons
Like AlfonsoMl said, this has something to do with the Advanced Content Filter
就像 AlfonsoMl 说的,这与高级内容过滤器有关
For all support about this look here: http://docs.ckeditor.com/#!/guide/dev_advanced_content_filter
有关此查看的所有支持:http: //docs.ckeditor.com/#!/guide/dev_advanced_content_filter
or put the following line in your config to disable the content filter. (It's better to configure it)
或在您的配置中添加以下行以禁用内容过滤器。(最好配置一下)
CKEDITOR.config.allowedContent = true;
回答by oleq
Instead of disabling the ACF feature, use config.extraAllowedContent:
而不是禁用 ACF 功能,使用config.extraAllowedContent:
editor.config.extraAllowedContent = 'div(span4)';
or
或者
editor.config.extraAllowedContent = 'div(*)';
回答by Sijo Thomas Maprayil
var editor1=CKEDITOR.replace('editor1');
editor1.config.allowedContent = true;