首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在agular 5中禁用ngx-quill中的粘贴图像/视频

如何在agular 5中禁用ngx-quill中的粘贴图像/视频
EN

Stack Overflow用户
提问于 2020-08-28 11:01:14
回答 1查看 3.2K关注 0票数 0

我正在使用羽毛笔编辑器,它的工作良好,但问题是,当粘贴的文本,其中包括图像,它也粘贴在文本区域,我不想要。我怎么能让它失效?我尝试了在下面的链接上提供的格式选项,但没有用。https://github.com/quilljs/quill/issues/1108下面是html

代码语言:javascript
复制
<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)">

这是我的配置

代码语言:javascript
复制
  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两种版本

知道吗?注意:在给定的链接中提到了一个黑客,但我希望有一个适当的解决方案。

EN

回答 1

Stack Overflow用户

发布于 2020-12-22 11:31:07

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

代码语言:javascript
复制
import * as QuillNamespace from 'quill';
let Quill: any = QuillNamespace;
import QuillImageDropAndPaste from 'quill-image-drop-and-paste'
Quill.register('modules/imageDropAndPaste', QuillImageDropAndPaste);

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

代码语言:javascript
复制
 editor_modules = {
   .....
imageDropAndPaste: {
      handler: this.imageHandler1
    }
............
}

现在在处理程序中

代码语言:javascript
复制
imageHandler1 = (imageDataUrl, type, imageData)=> {
   console.log('Eating your pasted image.')
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63632511

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档