0

I am working on an extension made on react, and the paste from the clipboard function is working fine in the browser but not working on the extension. Code I am using:

async function onPasteHandler(): Promise<void> {
   const text = await navigator.clipboard.readText();
   console.log("text", text);
   setValue(text);
 }
  • Assuming this is a listener for `paste` event, you should read the event's clipboardData directly: [example](https://stackoverflow.com/questions/2176861/javascript-get-clipboard-data-on-paste-event-cross-browser). – wOxxOm Jun 14 '22 at 10:42

1 Answers1

0

I think you are calling that function in content_scripts js file only, if you want to work in your extension as well then you must be calling it in your popup.html file as well. It's because content_script, background_script, and popup files work in complete isolation and are independent of each other.

minni minhaj
  • 152
  • 1
  • 4