How to prevent image drag-n-drop in ngx-Quill

Discussão em 'Angular' iniciado por Vlad Astakhov, Abril 14, 2025.

  1. I decided to use Quill in Angular project but can't find any working solution on how to handle or prevent images from being dropped into editor, it places base64 images anyway. I tried to apply matchers, event listeners, Quill modules and other possible solutions but Quill seemingly ignores everything.

    Here is my config:

    Quill.register('modules/blotFormatter', BlotFormatter);
    Quill.register(VideoBlot);
    Quill.register(AudioBlot);
    this.editorConfig = {
    toolbar: {
    container: this.toolbar,
    handlers: {
    undo: () => this.quill.history.undo(),
    redo: () => this.quill.history.redo(),
    image: () => this.imageHandler(),
    video: () => this.videoHandler(),
    audio: () => this.audioHandler()
    }
    },
    history: { delay: 500, maxStack: 500, userOnly: true },
    blotFormatter: {},
    clipboard: {
    allowed: {
    tags: [
    /*allowed tags*/
    ],
    attributes: ['href', 'rel', 'target', 'class']
    },
    handleImagePaste: (image) => {
    if (this.allowImagePaste) {
    this.blobService.upload([image]).subscribe({
    next: (i) => {
    const range = this.quill.getSelection();
    this.quill.insertEmbed(
    range.index,
    'image',
    i.itemsList[0].url,
    'user'
    );
    },
    error: this.errorService.errorOccurred
    });
    }
    }
    }
    };```

    Continue reading...

Compartilhe esta Página