lensapp / lens-extensions

List of Lens Extensions
238 stars 51 forks source link

Unable to use Clipboard Functionality inside iframe #18

Open cannarelladev opened 2 years ago

cannarelladev commented 2 years ago

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