Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

349
Views
How to disable image pasting in ngx-editor?

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/#/

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

@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;
}
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!