4

我正在使用ngx-quill编辑器,到目前为止它具有我需要的所有功能。但是,我没有看到有关如何删除来自剪贴板的文本的背景颜色和字体颜色的任何选项。

我想保留除颜色之外的所有其他格式。这可能吗?

4

2 回答 2

6

对于和我有同样问题的人,我设法找到了解决方法。

在我看来:

<quill-editor (onEditorCreated)='editorInit($event)'></quill-editor>

在我的控制器上

editorInit(quill: any){
    quill.clipboard.addMatcher(Node.ELEMENT_NODE, function(node, delta){
      delta.forEach(e => {
        if(e.attributes){
          e.attributes.color = '';
          e.attributes.background = '';
        }
      });
      return delta;
    });
  }
于 2020-01-06T09:33:28.660 回答
0
  • 如果您不想使用@manoyanx 的答案中提到的事件侦听器来删除颜色和背景,您可以使用

      const myQuillEditorFormats = ["background", "bold", "color", "font", "code", "italic", "link", "size", "strike", "script", "underline", "blockquote", "header", "indent", "list", "align", "direction", "code-block", "formula", "image", "video"];
    
  • 在上面的myQuillEditorFormats数组中,我添加了所有默认的羽毛笔编辑器选项。您可以专门删除您不想要的选项。

  • 然后在你的 NgModule 的导入中

      QuillModule.forRoot({ formats: quillEditorFormats })
    

来源:https ://quilljs.com/docs/formats/

于 2021-08-16T10:53:44.527 回答