lens-extensions icon indicating copy to clipboard operation
lens-extensions copied to clipboard

Unable to use Clipboard Functionality inside iframe

Open cannarelladev opened this issue 1 year ago • 0 comments

I didn't find a way to use the navigator.clipboard functionality to create a copy button through a callback like:

const copy = async () => { return await navigator.clipboard.writeText(generateCommand); };

This because of Lens extensions are rendered inside an iframe, and, for a Cross-Origin security policies, this functionality is forbidden. It's a big problem that can be solved adding some "info" to the iframe declaration:

<iframe .... allow="clipboard-write"></iframe>

The console error actually received is: Uncaught (in promise) DOMException: The Clipboard API has been blocked because of a permissions policy applied to the current document. See https://goo.gl/EuHzyv for more details.

Is it possible to find a solution like the proposed one or something something else suggested by you? For the extension that i'm developing will be an important and critical feature.

thanks in advance

cannarelladev avatar Jul 08 '22 14:07 cannarelladev