0

I'm embedding a Google Docs webapp in a webview in an Electron app.

The keyboard copy-paste (Cmd+C/Cmd+V on mac) works perfectly but the web clipboard, the one triggered via menus (Edit > Copy) does not work: enter image description here

Does anyone know how to make it work in Electron?

Note that I can reproduce the issue with the Brave browser, browser based on Electron. Note also that Safari displays the same kind of notice.

I read there and there that Chromes implements some kind of exception with the Clipboard API for the google apps to make it works. I'd be interested to implement the same kind of exception with Electron.

Community
  • 1
  • 1
alexstrat
  • 101
  • 9

1 Answers1

0

Add this piece of code in webview's preload and the message disappears and clipboard works as expected:

(function () {
  window._docs_chrome_extension_exists = !0;
  window._docs_chrome_extension_features_version = 1;
  window._docs_chrome_extension_permissions = ["alarms", "clipboardRead", "clipboardWrite", "storage", "unlimitedStorage"];
})()

Indeed, by looking closely at what the Google Drive extension is doing, I realized that the extension is loading this piece of code in every tab matching Google Drive's URLs.

alexstrat
  • 101
  • 9