nx10 / httpgd

Asynchronous http server graphics device for R.
https://nx10.github.io/httpgd
GNU General Public License v2.0
389 stars 19 forks source link

Copy to clipboard not working on all platforms #49

Open nx10 opened 3 years ago

nx10 commented 3 years ago

Copy to clipboard is confirmed not working in:

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.

psobolewskiPhD commented 3 years ago

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 commented 3 years ago

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...

jeffreyxparker commented 3 months ago

Not working VSCode, Sublime, or Chrome