Reputation: 2498
In CKEditor there are allowedContent
and extraAllowedContent
options in the config. I understand how allowedContent
allows you to say what tags and attributes will be left by the ACF but why is there allowedContent
and extraAllowedContent
? Don't they do the same thing?
One thing I have found is when wanting to allow iframes it only seems to work if you put iframe[*]
in extraAllowedContent
; it does not work if you put it in allowedContent
.
Why? What is the difference?
Upvotes: 6
Views: 4333
Reputation: 5560
Setting allowedContent
manually instructs the editor to ignore completely the allowed markup specified by enabled plugins (e.g. the list plugin "registers" <ul>
and <li>
tags). It may result in removing features from CKEditor. For example if you use the Standard preset and you allow just iframe[*]
, then most of the buttons will "disappear" (like Bold, List, Table) fro the toolbar, because you no longer allow elements like <strong>
, <ul>
, <li>
and so on.
extraAllowedContent
, as the name suggests, lets you extend the list of allowed tags/attributes that CKEditor will allow by default. What CKEditor supports by default directly depends on what features you did enable.
The following link explains it really well: https://docs.ckeditor.com/ckeditor4/docs/#!/guide/dev_acf
One thing I have found is when wanting to allow iframes it only seems to work if you put iframe[*] in extraAllowedContent; it does not work if you put it in allowedContent.
It looks like you made a mistake in the code because I just checked that case and it works as expected (the iframe element is left in the content, all other markup is removed, most of the toolbar buttons disappeared).
Last but not least, instead of just enabling the iframe element with extraAllowedContent, consider adding another plugin to CKEditor that correctly handles editing iframes (https://ckeditor.com/cke4/addon/iframe). If you add it to your build, it will automatically allow <iframe>
elements.
Upvotes: 8