CKEditor 4 attribute filtering is stripping any occurrence "href" from anchor tags put into the editor. I have a plugin which creates links that contain some "custom" attributes. A link looks something like this:
<a href="#" document-href="abc123">Some Link</a>
The CKEditor returns the link in this form when I call getData():
<a href="#" document->Some Link</a>
Is there a way to instruct CKEditor to stop filtering link attributes? Does anyone happen to know where in the source this regex is so I can fix it?
Thanks!
CKEditor 4 attribute filtering is stripping any occurrence "href" from anchor tags put into the editor. I have a plugin which creates links that contain some "custom" attributes. A link looks something like this:
<a href="#" document-href="abc123">Some Link</a>
The CKEditor returns the link in this form when I call getData():
<a href="#" document->Some Link</a>
Is there a way to instruct CKEditor to stop filtering link attributes? Does anyone happen to know where in the source this regex is so I can fix it?
Thanks!
Share Improve this question asked Apr 3, 2013 at 18:28 NickNick 19.7k52 gold badges190 silver badges313 bronze badges2 Answers
Reset to default 4I've just checked this link on CKEditor 4.1 - the output is:
<p><a href="#">Some Link</a></p>
Since 4.1 the document-href
is stripped because it is now allowed in the editor. You have to add an Advanced Content Filter rule - e.g.:
config.extraAllowedContent = 'a[!href,document-href]';
And then it would work in 4.1. Before 4.1 it should work by default, without setting anything.
However there's a bug in CKEditor's HTML parser. It does not parse correctly sth-href
attributes on links so a result is a sth-
attribute.
For now I advice you to change the name of this attribute to data-url
or whatever else without href
ending.
I created a ticket: https://dev.ckeditor./ticket/10298
try setting this in config file.
config.allowedContent = true;
also if its getting filtered on insert then you can try this:
//var yourAnchor = '<a href="#" document-href="abc123">Some Link</a>';
editor.insertHtml(yourAnchor, 'unfiltered_html');