Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Uncaught (in promise) DOMException: Read permission denied

I’m building RichText editor using Tiptap and one of my menu button has the following action on Click:

  async function handleHtmlPaste() {
    // editor?.chain().focus().run();
    const text = await navigator.clipboard.readText();
    // let text = `<h1 style="margin-left: 0px!important;">Test</h1><h2 style="margin-left: 0px!important;">Basic text formatting</h2>`;
    editor
      ?.chain()
      .focus()
      .command((props) => {
        props.view.pasteHTML(text);
        return true;
      });

    return true;
  }

Unfortunately, I’m getting the following error: Uncaught (in promise) DOMException: Read permission denied. What is the reason?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

When you call navigator.clipboard.readText() browser pops up a message like,

Website wants to see text and images on the clipboard?

enter image description here

And asks the user’s permission whether to allow or deny. You will get this error for 3 reasons:

  1. User denied the access request.
  2. At the OS level, The browser doesn’t have permission to access the clipboard. (Happens mostly on MacOS)
  3. If it is a Chromium Extension, You might need to add clipboardRead under permissions in manifest.json

Also, Check the current site permission status

enter image description here

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading