Skip to content
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
Closed

Clipboard access through Extensions API #4972

fabiodamasceno opened this issue Apr 5, 2016 · 8 comments
Assignees
Labels
*duplicate Issue identified as a duplicate of another issue(s)

Comments

@fabiodamasceno
Copy link

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

@jrieken jrieken closed this as completed Apr 6, 2016
@jrieken jrieken added *duplicate Issue identified as a duplicate of another issue(s) and removed *duplicate Issue identified as a duplicate of another issue(s) labels Apr 29, 2016
@brianwhited
Copy link

@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
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
Copy link

@brianwhited how did you go creating that extension?

@brianwhited
Copy link

@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
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
Copy link

@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
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.
Labels
*duplicate Issue identified as a duplicate of another issue(s)
Projects
None yet
Development

No branches or pull requests

6 participants