gpt4 book ai didi

html - 如何配置 CKEditor 以允许将 html block 级标签包装在 anchor 标签中

转载 作者:搜寻专家 更新时间:2023-10-31 08:04:46 26 4
gpt4 key购买 nike

我想在链接中包含几个 block 标记 ( valid in HTML5 ):

<a href="http://example.com">
<div>foo</div>
<p>bar</p>
<span>baz</span>
<strong>zoom</strong>
</a>

但 CKEditor 重写了代码,将链接放置在 block 标记内,并允许将内联标记包裹起来,因为上面的代码被替换为以下代码:

<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 = "a p; a div"; , 但这似乎没有任何效果。

最佳答案

你可以尝试做类似的事情:

CKEDITOR.dtd.a.div = 1;
CKEDITOR.dtd.a.p = 1;

来源: http://ckeditor.com/forums/Support/CKEditor-wont-allow-inside

关于html - 如何配置 CKEditor 以允许将 html block 级标签包装在 anchor 标签中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19825802/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com