httpgd icon indicating copy to clipboard operation
httpgd copied to clipboard

Copy to clipboard not working on all platforms

Open nx10 opened this issue 4 years ago • 3 comments

Copy to clipboard is confirmed not working in:

  • Safari 14.0.2 (macOS Big Sur 11.1)
  • VSCode webview (1.52.1)

Safari throws "NotAllowedError: The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission."

Maybe calling the clipboard API wrapped in the image load callback is not allowed?

It not working in the VSCode webview might be caused by IFrame security settings. (Needs further investigation)

The associated code is https://github.com/nx10/httpgd/blob/abe90b9a3a1662e3d651b4fd1da458eb88804dba/inst/www/httpgd.ts#L486-L502

Thank you @psobolewskiPhD for the bug report.

nx10 avatar Jan 08 '21 14:01 nx10

Here's the error in JS Console on Big Sur Safari 14.0.2

Unhandled Promise Rejection: NotAllowedError: The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission. It flags:

N (anonymous function)
N rejectPromise
N write
f (anonymous function)

Specially line 416 of httpgd.js: (_b = (_a = navigator.clipboard).write) === null || _b === void 0 ? void 0 : _b.call(_a, [new ClipboardItem({ 'image/png': blob })]); }); Specifically this: _b.call(_a, [new ClipboardItem({ 'image/png': blob })])

psobolewskiPhD avatar Jan 14 '21 17:01 psobolewskiPhD

In VSCode I tried to use the Webview Dev tools, but it just shows an iframe with httpgd http link in another iframe image The VSCode WebView issue could be related to: https://github.com/microsoft/vscode/issues/65452#issuecomment-586036474 but the other keybindings (save, clear) work...

psobolewskiPhD avatar Jan 14 '21 19:01 psobolewskiPhD