I use CKeditor for editing rich HTML pages, but some javascript functionality relies on special attributes of the <a>
tags that triggers them.
Those are rare cases, just a few records on a database of 5000+ records need to trigger this functionality, and this particular js module needs special attributes as a way of parametrization:
<a href="#" data-from="ROM" data-to="NYC" data-promo="8373794">Buy your tickets</a>
CKeditor allows me to add those attributes (by editing the source code of the entry), but when the client edits the page the editor removes them and breaks that functionality.
Instructing my client to not edit this particular record seems unprofessional. Changing to another WYSIWYG editor may work, but I see that as the last resort.
CKEditor has to have a solution to that!
If you want to allow all If you want to disable Advanced Content Filter, set CKEDITOR. config. allowedContent to true. All available editor features will be activated and input data will not be filtered.
I found it:
The special configuration option:
extraAllowedContent: '*[*]{*}(*)'
did the trick.
So the constructor I use is:
$('.wysiwyg').ckeditor({
toolbar : 'Basic',
extraAllowedContent: '*[*]{*}(*)'
});
Note that it's the "EXTRA" allowed content option, so it does not overwrite the default.
Update: It turns out that my special attribute had some & in it, and CKEditor was replacing them with the HTML entity &
. I added these two options:
entities: false,
basicEntities: false,
but they prevented that from happening in text nodes only, not inside attributes. Then I found this option:
forceSimpleAmpersand: true
and it worked. It'll be okay for now, but if eventually I have to put &
as part of any value --the entity, not just the & (this is usually required in content sharing links)-- the editor will break them, changing them to plain &.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With