New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clipboard access through Extensions API #4972

Closed
fabiodamasceno opened this Issue Apr 5, 2016 · 8 comments

Comments

Projects
None yet
6 participants
@fabiodamasceno
Copy link

fabiodamasceno commented Apr 5, 2016

  • VSCode Version:0.10.11
  • OS Version: Windows 10, Mac OSX El Captain

Hi, I'm developing console-wrapper , that is an extension for javascript console.log (other languages support will be added soon) and I need some access for clipboard content in Extensions API. I think this methods should be enough for most of cases:

  • vscode.clipboard.getContent()
  • vscode.clipboard.setContent()

Some event handlers should be useful, too, like:

-vscode.clipboard.beforeContentLoad()
-vscode.clipboard.onContentLoad()
-vscode.clipboard.onContentLoaded()

Steps for the extension:

  • user copy some text;
    • when ctrl+shift+q text is wrapped with console.log and inserted at below line.

hugs,

@jrieken

This comment has been minimized.

Copy link
Member

jrieken commented Apr 6, 2016

Closing as duplicate of #217.

We don't plan to implement that in VS Code but advise to use a node module like https://github.com/xavi-/node-copy-paste. This is to reduce complexity in the VS Code API because otherwise we have to handle/describe all sorts of clipboard data (think of images and other binary data).

@brianwhited

This comment has been minimized.

Copy link

brianwhited commented Jun 3, 2016

@jrieken the node-copy-paste module only copies text. This will not work for images. I am attempting to create a markdown extension that will allow the user to copy an image to their clipboard and paste it into their markdown document. When the paste occurs, the extension will save the image to an appropriately named folder and insert the text to display the image when the markdown is compiled. I know this is a closed ticket, but most tickets I have seen in regards to copy/paste reference back to this one.

@jrieken

This comment has been minimized.

Copy link
Member

jrieken commented Jun 6, 2016

Unsure about that. The docs about copy says

Takes either a string, array, object, or readable stream.

The last (readable stream) sounds interesting to me

@JakeGinnivan

This comment has been minimized.

Copy link

JakeGinnivan commented Jul 14, 2016

@brianwhited how did you go creating that extension?

@brianwhited

This comment has been minimized.

Copy link

brianwhited commented Jul 14, 2016

@JakeGinnivan I wasn't able to complete this due to not being able to access the clipboard fully. I have not tried since the newest update (1.3) because of time constraints at work. I will be revisiting this shortly. Do you have any suggestions?

@mushanshitiancai

This comment has been minimized.

Copy link

mushanshitiancai commented Aug 21, 2016

@brianwhited I want to create a extension to paste image to markdown too!

@jrieken @brianwhited I tried node-copy-pastemodule ,it can't handle image in clipboard(just return empty string).

But I found there is a useful function in Electron API:

clipboard.readImage([type])
Returns the content in the clipboard as a NativeImage.

clipboard.writeImage(image[, type])
Writes image to the clipboard.

But not like Atom,VSCode can't access to Electron API,see #3011

So, how to do ?

@mushanshitiancai

This comment has been minimized.

Copy link

mushanshitiancai commented Aug 23, 2016

@brianwhited I post a extension that can paste image from clipboard Paste Image

Because I use applescript to handle image in clipboard, so it only work in MacOS.

@bgse

This comment has been minimized.

Copy link
Contributor

bgse commented Nov 9, 2016

@jrieken The node-copy-paste is not an ideal solution, for example on default Ubuntu installation it will require the user to install xclip.

@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 18, 2017

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.