jupyterlab-vimrc icon indicating copy to clipboard operation
jupyterlab-vimrc copied to clipboard

Paste from the system clipboard

Open banderlog opened this issue 3 years ago • 2 comments

With jupyterlab-vimrc and {"unnamedplus": true} I was able to copy TO clipboard system register, but not FROM it. Is there a way to do it in both ways with vimkeys (all works with CTRL+V)

There was a similar yanking to clipboard problem, and that was the reason: https://github.com/codemirror/CodeMirror/issues/6341

@ianhi had proposed the workable solution: https://github.com/codemirror/CodeMirror/issues/3075#issuecomment-612319694 Now it is the part of this repo and works perfectly under jupyter-lab.

Can it also be implemented for the paste function?

banderlog avatar May 10 '21 14:05 banderlog

Look like it could be implemented with navigator.clipboard.readText()

But, From the browser compatibility hidden section on the same page (click on * under firefox column):

Firefox only supports reading the clipboard in browser extensions, using the "clipboardRead" extension permission.

From the https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Interact_with_the_clipboard:

Firefox supports the "clipboardRead" permission from version 54, but only supports pasting into elements in content editable mode, which for content scripts only works with a

But at the https://developer.mozilla.org/en-US/docs/Web/API/Clipboard/read we read:

Note: At this time, while Firefox does implement read(), it does not recognize the "clipboard-read" permission, so attempting to use the Permissions API to manage access to the API will not work.

And from https://bugzilla.mozilla.org/show_bug.cgi?id=1312260:

Firefox only allows extensions with the clipboardRead extension permission to use the navigator.clipboard.read (with dom.events.asyncClipboard.dataTransfer pref) / readText (without pref) APIs. Ordinary web content cannot use the API, as announced at the time of the intent-to-implement: https://groups.google.com/d/msg/mozilla.dev.platform/skHoHwfapEY/VQZZXvNxAQAJ

The navigator.clipboard.readText API was briefly exposed to ordinary web content in Firefox 63, but this has been fixed (i.e. removed) in 64: see bug 1479935 and bug 1483552.

I am bad in JS and web development, but from my point of view it can't be done only in some sort of firefox extension, which is not looks like jupyter-lab friendly way

banderlog avatar May 10 '21 15:05 banderlog

I am bad in JS and web development, but from my point of view it can't be done only in some sort of firefox extension, which is not looks like jupyter-lab friendly way

Sorry I didn't respond earlier. Tragically this was also my takeaway :(. If there is a firefox extension that enables this on localhost then I think we could work towards this - but I don't.

So until then I think we're stuck with entering insert mode and doing Ctrl-V.

ianhi avatar Feb 15 '22 05:02 ianhi