ckeditor 5 禁用内容过滤

Sca*_*eUp 6 ckeditor ckeditor5

我注意到,当从编辑器中提取数据时,它会过滤一些类和样式。我想使用与编辑器使用完全相同的样式。

所以,我有两个问题需要解决。

  1. 我怎样才能防止发生类和样式的过滤。
  2. 如何将 CSS 提取到单独的文件中?

我知道在使用以前的 ckeditor 版本时,您可以使用以下内容来防止其过滤:

config.allowedContent = true;
Run Code Online (Sandbox Code Playgroud)

Vee*_*eeK 0

您可以使用 CKEditor 5 中的常规 HTML 支持插件。文档中的更多信息

这就是我用来根据我的需要启用某些功能的方法。您可以根据您的实施进行定制。

ClassicEditor.create(richEditorElem, {
  htmlSupport: {
    allow: [
      {
        name: /^(div|ul|li|ol|a|button|p|h[1-6])$/,
        classes: true,
        styles: true
      }
    ]
  }
}).then( editor => {

}).catch( error => {
    console.error( error );
});
Run Code Online (Sandbox Code Playgroud)