为 CKEditor 格式组合框中的项目设置样式?

Styling the items in the CKEditor Format Combo box?

在 CKEditor 4 中,"Styles" 组合框中显示的项目与其样式一起显示,演示了如果选择该项目,文本将如何设置样式。

块级格式化的 "Format" 组合框项目不是这种情况。有没有办法来解决这个问题?例如,通过 "cheating" 并手动添加 CSS class 到模仿段落样式外观的每个项目?

您可以在 config.js

中添加
  config.fontSize_style={
            element:        'font',
            attributes: { 'class': 'fs-#(size)' }
        };

这将添加 class="fs-selectedFontSize" 例如 class="fs-18"。 然后,您必须在 contents.css 或 link 您的 CSS 文件中为此类 class 添加样式。类似的技巧去CKEditor Guide官网 https://ckeditor.com/docs/ckeditor4/latest/guide/index.html