我想在链接中包装一些块标签(在HTML5中有效):
<a href="http://example.com">
<div>foo</div>
<p>bar</p>
<span>baz</span>
<strong>zoom</strong>
</a>
Run Code Online (Sandbox Code Playgroud)
但是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>
Run Code Online (Sandbox Code Playgroud)
如何禁用此行为?
在CKEditor配置中,我正在使用config.allowedContent = true;它禁用允许标签的过滤。
我们还习惯于config.autoParagraph = false;不要求将根级标签包装在段落中。
我尝试使用config.extraAllowedContent = "a p; a div";,但这似乎没有任何效果。
您可以尝试执行以下操作:
CKEDITOR.dtd.a.div = 1;
CKEDITOR.dtd.a.p = 1;
Run Code Online (Sandbox Code Playgroud)
src:http: //ckeditor.com/forums/Support/CKEditor-wont-allow-inside