5

I have a Google Spreadsheet file that displays a custom dialog using SpreadsheetApp.getUi().ShowModalDialog(...).

There is a script in this dialog box that saves some user values to the clipboard navigator.clipboard.writeText(...)

This construct worked great until today. Now when I try to access the clipboard, I get an error

"NotAllowedError: Disabled in this document by Feature Policy."

I don't know how it was before, but now in the iframe container of the dialog box there is no permission for clipboard. Chrome and Firefox have the same result

<iframe id="sandboxFrame" allow="accelerometer *; ambient-light-sensor *; autoplay *; camera *; encrypted-media *; fullscreen *; geolocation *; gyroscope *; magnetometer *; microphone *; midi *; payment *; picture-in-picture *; speaker *; usb *; vibrate *; vr *" sandbox="allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts" src="https://n-u5k3jk3vgvz7z7zd77h6oqbtfn7mio6cjscfeoi-0lu-script.googleusercontent.com/userCodeAppPanel">
</iframe>

Is there any way to set permission for Clipboard API in Apps Script html dialogs?

Marios
  • 26,333
  • 8
  • 32
  • 52
Stanislav
  • 51
  • 4
  • This should be modified by Google. Consider creating a issue in the issuetracker and link the issue you created here for wider audience. See [tag info page](https://stackoverflow.com/tags/google-apps-script/info) for more details. Also [edit] your question to show browser variances. Does Firefox or other browsers show the same behavior? – TheMaster Apr 25 '20 at 04:24
  • 1
    I use this is a dialog box and a web app `var textbox=document.getElementById(id); textbox.select(); document.execCommand('copy');` – Cooper Apr 25 '20 at 21:27
  • 1
    If you are in an iframe with no clipboard allowed execCommand with copy / cut / paste options don't work – Stanislav Apr 27 '20 at 01:37
  • Create a issue. That's the only way. – TheMaster Apr 27 '20 at 05:00
  • As @TheMaster said. Please, open an issue on [Issue Tracker](https://issuetracker.google.com/issues/new?component=191640&template=823905) and describe in detail the situation you are having – alberto vielma Apr 27 '20 at 09:18
  • Where is reported issue URL? – Kos Jun 23 '20 at 10:56
  • This one https://issuetracker.google.com/issues/36760406 ? – Kos Jun 23 '20 at 11:07
  • Related: https://stackoverflow.com/questions/57681314/add-content-of-showmodaldialog-to-the-clipboard-google-script – TheMaster Sep 25 '20 at 12:30

0 Answers0