Ckeditor:stylesSet在我设置自定义的allowedContent时不起作用

use*_*ser 5 ckeditor

在我的Ckeditor配置中,我有一个自定义的allowedContent.我不使用,allowedContent:true因为我不想在span标签中允许style属性

所以这是我的allowedContent

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;'
Run Code Online (Sandbox Code Playgroud)

使用此配置,span标记上不再允许样式属性

问题出在我的stylesSets上:

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" } }
Run Code Online (Sandbox Code Playgroud)

以前,当我有allowedContent:true,我能够看到并使用我的所有5个样式集,但现在,由于某种原因,我只看到样式字段中的"样式5"

是否可以不使用我的5个样式集allowedContent:true

非常感谢

Gyu*_*Fox 1

看来您的 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;'
Run Code Online (Sandbox Code Playgroud)

或者如果你想更明确:

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;'
Run Code Online (Sandbox Code Playgroud)

请参阅此处的文档

注意:我无法测试此代码,如果它可以正常工作,请在评论中告诉我。