有没有反正阻止CKEditor 4过滤我的锚标签属性? [英] Is there anyway to stop CKEditor 4 from filtering my anchor tag attributes?
问题描述
CKEditor 4属性过滤从放置到编辑器中的锚标签中剥离任何出现的href。我有一个插件创建包含一些自定义属性的链接。链接看起来像这样:
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>
CKEditor在调用getData()时返回此形式的链接:
The CKEditor returns the link in this form when I call getData():
<a href="#" document->Some Link</a>
有没有办法指示CKEditor停止过滤链接属性?
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?
谢谢!
推荐答案
我刚刚在CKEditor 4.1上检查过这个链接 - 输出是:
I've just checked this link on CKEditor 4.1 - the output is:
<p><a href="#">Some Link</a></p>
自4.1以来, document-href
因为它现在允许在编辑器中。您必须添加高级内容过滤器规则,例如:
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]';
然后它将在4.1中工作。在4.1之前它应该默认工作,不设置任何东西。
And then it would work in 4.1. Before 4.1 it should work by default, without setting anything.
但 CKEditor的HTML解析器有一个错误。它不能正确解析链接上的 sth-href
属性,因此结果是 sth -
属性。
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.
现在我建议你将这个属性的名称改为 data-url
或其他不带 href
结尾。
For now I advice you to change the name of this attribute to data-url
or whatever else without href
ending.
我创建了一张票: https://dev.ckeditor.com/ticket/10298
这篇关于有没有反正阻止CKEditor 4过滤我的锚标签属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!