Ckeditor:设置自定义允许内容时,样式集不起作用
在我的Ckeditor配置中,我有一个自定义的allowedContent。我不使用Ckeditor:设置自定义允许内容时,样式集不起作用,ckeditor,Ckeditor,在我的Ckeditor配置中,我有一个自定义的allowedContent。我不使用allowedContent:true,因为我不想在span标记中使用style属性 这就是我允许的内容 allowedContent : 'span[class]; a[!href](*); caption; div; em; h1; h2; h3; h4; h5; h6; hr; i; img; li; ol; p[*]{*}; pre; strong; sub; sup; table; thead; t
allowedContent:true
,因为我不想在span标记中使用style属性
这就是我允许的内容
allowedContent : 'span[class]; a[!href](*); caption; div; em; h1; h2; h3; h4; h5; h6; hr; i; img; li; ol; p[*]{*}; pre; strong; sub; sup; table; thead; tbody; tfoot; td; th; tr; tt; u; ul; dl; dt; dd; iframe;'
使用此配置,span标记上不再允许使用样式属性
问题在于我的样式集:
stylesSet:
- { name: "style 1", element: ['div', 'p', 'a', 'span'], attributes: { class:"display_only_in_popup" } }
- { name: "style 2", element: ['div', 'p', 'a', 'span'], attributes: { class:"blockquote" } }
- { name: "style 3", element: ['div', 'p', 'a', 'span'], attributes: { class:"note" } }
- { name: "style 4", element: ['p', 'span'], attributes: { class:"highlight" } }
- { name: "style 5", element: 'span', attributes: { class:"visuallyhidden" } }
以前,当我拥有allowedContent:true
时,我能够看到并使用我的所有5个样式集,但现在,由于某种原因,我只能在样式字段中看到“样式5”
是否可以在不使用allowedContent:true
的情况下保留我的5个样式集
非常感谢您的5个样式集似乎都使用了
class
属性,但是您的allowedContent
规则只允许class
属性用于span
元素
我建议将allowedContent
规则更改为:
allowedContent : '*[class]; a[!href](*); caption; div; em; h1; h2; h3; h4; h5; h6; hr; i; img; li; ol; p[*]{*}; pre; strong; sub; sup; table; thead; tbody; tfoot; td; th; tr; tt; u; ul; dl; dt; dd; iframe;'
或者,如果您想更明确一些:
allowedContent : 'div[class]; p[class]; a[class]; span[class]; a[!href](*); caption; div; em; h1; h2; h3; h4; h5; h6; hr; i; img; li; ol; p[*]{*}; pre; strong; sub; sup; table; thead; tbody; tfoot; td; th; tr; tt; u; ul; dl; dt; dd; iframe;'
请参阅
注意:我无法测试此代码,请在注释中告诉我它是否完成了此任务。我会将
allowedContent
保留为其默认值,并对extralallowedcontent