问题
I am using ckeditor 4.5.7 and I want the user to insert arbitrary HTML code into the page. For now the users cannot even insert tags like <h3>test</h3>
- the <h3>
tags are automatically converted to <p>
after the data is saved (this is occurring in a SharePoint page).
As per docs here - http://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-allowedContent - and multiple topics here on StackOverflow, I have set this option in config.js to disable content filtering but it seems it has no effect:
config.allowedContent = true;
I also tried listing specific tags in this option, as well as in config.extraAllowedContent, but none of it seems to have any effect. Any tags like <h1>
are stripped anyway.
What else could I have missed?
回答1:
My first thought was to check the CKEDITOR.filter.disallowedContentRules
. As noted here, "They have precedence over allowed content rules." However, the Disallowed Content Guide notes: "It is not possible to disallow content when the Advanced Content Filter is disabled by setting CKEDITOR.config.allowedContent to true
."
Without knowing more about your config, my recommendation is to use Comandeer's jsfiddle for discovering what your allowed content is.
回答2:
Turns out the solution was on the SharePoint side. It was SharePoint that was stripping the HTML tags.
The multi-line text field that contained CKEditor had this property:
textfield.SPRichTextMode = SPRichTextMode.Compatible;
After removing this line it worked.
来源:https://stackoverflow.com/questions/40078356/ckeditor-4-5-7-strips-html-tags-despite-config-allowedcontent-true