I was trying to use ngx-editor for rich text editor but I want to disable the property of pasting images in the editor. Although I have removed the insert image button from the toolbar it is still pasting the images in the editor.
Link to ngx-editor doc: https://sibiraj-s.github.io/ngx-editor/#/
@HostListener('paste', ['$event'])
private pasteFromClipboard(event: KeyboardEvent): void {
event.preventDefault();
if (this.insertClipboardImage(event)) {
return;
}
}
private insertClipboardImage(event): File | null{
const pastedImage = getPastedImage(event);
if (!pastedImage)
return null;
return pastedImage;
}
private getPastedImage(event): File | null {
if (event.clipboardData) {
if (event.clipboardData.files && event.clipboardData.files.length && isImageFile(event.clipboardData.files[0])) {
return event.clipboardData.files[0];
}
}
return null;
}
private isImageFile(file: File): boolean {
return file.type.search(/^image\//i) === 0;
}