0

我正在使用羽毛笔编辑器,它工作正常,但问题是在粘贴包含图像的文本时,它也将它粘贴到我不想要的文本区域中。我怎么能禁用它?我尝试了以下链接中给出的格式选项,但没有用。 https://github.com/quilljs/quill/issues/1108 以下是html

<quill-editor #textArea [placeholder]="attribute.name"
            [formControl]="specsForm.controls[attribute.id].controls.value" [required]="attribute.isRequired"
            [readOnly]="isProductAttributeDefected || attribute.isReadOnly " [disableControl]="isProductAttributeDefected || attribute.isReadOnly"
            [maxLength]="attribute.maxLength" [modules]="editorConfig" (onEditorCreated)="editorInit($event, attribute.id, specsForm, false)">

这是我在 ts 中的配置

  public editorConfig: {
modules: {
    toolbar: [
        [{ header: [1, 2, false] }],
        ['bold', 'italic', 'underline'],
        ['code-block']
    ]
},
placeholder: 'Compose an epic...',
    theme: 'snow',  // or 'bubble'
  formats: [
      'background',
      'bold',
      'color',
      'font',
      'code',
      'italic',
      'link',
      'size',
      'strike',
      'script',
      'underline',
      'blockquote',
      'header',
      'indent',
      'list',
      'align',
      'direction',
      'code-block',
      'formula'
      // 'image'
      // 'video'
  ]

};

我尝试了 5.2.0 和 6.2.0 版本

任何想法?注意:给定链接上提到了一个黑客,但我想有一个适当的解决方案

4

1 回答 1

0

很抱歉这个迟到的答案,但为了避免将图像粘贴到羽毛笔编辑器中,您可以添加一个不会改变编辑器的图像处理程序。但是要在粘贴图像时调用处理程序,您需要quill-image-drop-and-paste模块。

import * as QuillNamespace from 'quill';
let Quill: any = QuillNamespace;
import QuillImageDropAndPaste from 'quill-image-drop-and-paste'
Quill.register('modules/imageDropAndPaste', QuillImageDropAndPaste);

现在在您的编辑器配置中,添加处理程序引用

 editor_modules = {
   .....
imageDropAndPaste: {
      handler: this.imageHandler1
    }
............
}

现在在处理程序中

imageHandler1 = (imageDataUrl, type, imageData)=> {
   console.log('Eating your pasted image.')
}
于 2020-12-22T11:31:07.193 回答