使用自定义文本格式定义(https://ckeditor.com/docs/ckeditor4/latest/examples/format.html)时,可以向标记定义添加属性,如下所示:
config.format_tags = 'p;h1';
config.format_p = { element: 'p'};
config.format_h1 = { element: 'h1', attributes: { 'class': 'lorem-ipsum' } };我的问题是,当从下拉列表中应用h1时,lorem-ipsum类被添加了,但当返回到p时,lorem-ipsum类并没有被删除。我尝试过使用attributes: false、attributes: null、attributes: {},但在标签之间切换时,没有什么能让它们消失。
这个问题在CKEDITOR demo:https://ckeditor.com/docs/ckeditor4/latest/examples/format.html的自定义文本格式定义标题下可见。当改变标签时,他们的类保持不变。
那么,当从格式下拉列表中更改标签时,如何删除类?
发布于 2020-12-16 21:41:06
这个变通方法是有效的(我在版本中检查了它。4.6.2):
config.format_p = { element : 'p', attributes: {'class' : ''} };在这种情况下,如果切换到p,该属性将消失。
https://stackoverflow.com/questions/59878761
复制相似问题