Is there anyway to stop CKEditor 4 from filtering my anchor tag attributes?

ckeditor, html, javascript, wysiwyg

Solution

I'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.com/ticket/10298

Problem

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!

Original source