[w3c/editing] Support navigator.clipboard inside of Service Workers (Issue #458)

Hiya folks,
I work in devrel for Chrome Extensions. I have been helping folks migrate to [manifest v3](https://developer.chrome.com/blog/resuming-the-transition-to-mv3), and one thing that has come up a number of times in clipboard access. In the past, a background page made it easy to use standard DOM interactions with the clipboard. But with extensions moving to a service worker based background in manifest v3, it becomes a lot more complicated. While there are workarounds¹, it would _greatly_ reduce complexity of a number of extensions if the platform had access to navigator.clipboard.

In practice, I believe this would mean exposing [Clipboard](https://w3c.github.io/clipboard-apis/#clipboard) onto [WorkerNavigator](https://html.spec.whatwg.org/multipage/workers.html#the-workernavigator-object), as that is what is inherited by the service worker. 






<sub>
1. <a href="https://github.com/GoogleChrome/chrome-extensions-samples/tree/main/functional-samples/cookbook.offscreen-clipboard-write">Here</a> is a code example. We have <code>chrome.offscreen</code>, which gives the developer access to a HTML document they provide that is rendered offscreen. To copy the clipboard, you need to create the offscreenDocument singleton, send an event over RPC to the HTML document they provide, which listens for the event, then executes document.execCommand (offscreen documents don't support navigator.clipboard <a href="https://chromium-review.googlesource.com/c/chromium/src/+/5170635">as of now</a>), then responds with another RPC back to the service worker with the data they requested, and then shut down the offscreenDocument. Its a lot of indirection.</sub>

-- 
Reply to this email directly or view it on GitHub:
https://github.com/w3c/editing/issues/458
You are receiving this because you are subscribed to this thread.

Message ID: <w3c/editing/issues/458@github.com>

Received on Tuesday, 16 January 2024 20:36:16 UTC