CKEditor允许在<a>标签内<span>

Vij*_*har 1 html ckeditor

我想在CKEditor源代码中的<span>标签内添加标签<a>:

<a href="http://google.com"><span>Link here</span></a>
Run Code Online (Sandbox Code Playgroud)

但是当我在源模式下在CKEditor中添加HTML时,它会将其转换为:

<a href="http://google.com">Link Here</a>
Run Code Online (Sandbox Code Playgroud)

如何在内部允许HTML标记href

Rei*_*mar 7

高级内容过滤器<span>删除了此内容.显然(并且这并不奇怪)编辑器中启用的任何功能都不允许裸露的跨度(非常糟糕的非语义HTML),因此只需删除它们.

我建议你不要使用这种凌乱的HTML,因为CKEditor会在某些时候打破你的<a>+<span>双重线,因为它不知道它们应该一起编辑.

但是,如果需要使用它们,请检查以下选项:config.allowedContentconfig.extraAllowedContent.第一个允许完全禁用高级内容过滤器.


小智 7

使用extraAllowedContent过滤器:

CKEDITOR.replace('ckeditor', {
    extraAllowedContent: 'a span',
});
Run Code Online (Sandbox Code Playgroud)