Ckeditor 4.5.7 条带 HTML 标签尽管 config.allowedContent = true

Ckeditor 4.5.7 strips HTML tags despite config.allowedContent = true

我使用的是 ckeditor 4.5.7,我希望用户在页面中插入任意 HTML 代码。目前,用户甚至不能插入像 <h3>test</h3> 这样的标签 - <h3> 标签会在数据保存后自动转换为 <p>(这发生在 SharePoint 页面中)。

根据此处的文档 - http://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-allowedContent - 以及 Whosebug 上的多个主题,我已在 config.js 中设置此选项以禁用内容过滤,但它似乎没有任何效果:

config.allowedContent = true;

我也尝试在此选项以及 config.extraAllowedContent 中列出特定标签,但 none 似乎没有任何效果。任何像 <h1> 这样的标签都会被删除。

我还能错过什么?

我的第一个想法是检查 CKEDITOR.filter.disallowedContentRules。正如 noted here, "They have precedence over allowed content rules." However, the Disallowed Content Guide 注释:"It is not possible to disallow content when the Advanced Content Filter is disabled by setting CKEDITOR.config.allowedContent to true."

在不了解您的配置的情况下,我的建议是使用

原来解决方案是在 SharePoint 端。是 SharePoint 剥离了 HTML 标签。

包含 CKEditor 的多行文本字段有这个 属性:

textfield.SPRichTextMode = SPRichTextMode.Compatible; 

删除此行后它起作用了。