如何配置CKEditor以允许html块级标签包裹在锚标签中 [英] How to configure CKEditor to allow html block-level tags to be wrapped in an anchor tag
问题描述
我想在一个链接中封装几个块标记( valid in HTML5 ):
< a href =http:// example .com>
< div> foo< / div>
< p> bar< / p>
< span> baz< / span>
< strong> zoom< / strong>
< / a>但是CKEditor重写代码,使得链接被放置在块标签内,并且允许包装内联标签作为一个标签。上述代码替换为以下代码: < div>< a href =http://example.com > foo< / a>< / div>
< p>< a href =http://example.com> bar< / a>< / p>
< a href =http://example.com>< span> baz< / span> < strong> zoom< / strong> < / a>
如何禁用此行为?
在CKEditor配置中,我使用 config.allowedContent = true;
,禁用对允许的标记进行过滤。
我们也使用 config.autoParagraph = false;
不要求在段落中包含根级标签。
我已尝试使用 config.extraAllowedContent =ap; a div;
,但这似乎没有任何效果。
解决方案此时CKEditor(4.2)仅仅是xHTML / HTML4编辑器。不支持HTML5 DTD(这是动态的,BTW),这是你的问题的根源。我也担心没有解决方法/配置,因为不同的DTD意味着不同的解析器,所以CKEditor不是适合你的工具。很抱歉。
您可以在这张票中找到更多资讯。
I would like to wrap a few block tags in a link (valid in HTML5):
<a href="http://example.com">
<div>foo</div>
<p>bar</p>
<span>baz</span>
<strong>zoom</strong>
</a>
But CKEditor rewrites the code such that the links are placed inside block tags and allowed to wrap inline tags as the above code is replaced with the following:
<div><a href="http://example.com">foo</a></div>
<p><a href="http://example.com">bar</a></p>
<a href="http://example.com"><span>baz</span> <strong>zoom</strong> </a>
How can I disable this behavior?
In the CKEditor config, I'm using config.allowedContent = true;
which disables the filtering of allowed tags.
We're also using config.autoParagraph = false;
to not require root-level tags to be wrapped in a paragraph.
I've tried using config.extraAllowedContent = "a p; a div";
, but this doesn't seem to have any effect.
解决方案 At the moment CKEditor (4.2) is xHTML/HTML4 editor only. There's no support support for HTML5 DTD (which is dynamic, BTW) and this is the root of your problem. I'm also afraid there's no workaround/config since different DTD means different parser, so CKEditor is not the right tool for you. Sorry.
You can find more information in this ticket.
这篇关于如何配置CKEditor以允许html块级标签包裹在锚标签中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!