zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
48.33k stars 2.87k forks source link

Adding Feature To Allow Copy/Paste From Clipboard #18112

Open longbuivan opened 3 weeks ago

longbuivan commented 3 weeks ago

Check for existing issues

Describe the feature

Currently, Zed editor does not support the ability to copy and paste images directly from the clipboard. This feature is essential for improving user workflow and efficiency, enabling seamless interaction with external sources. Implementing clipboard support would allow users to easily transfer text between Zed and other applications, enhancing productivity and flexibility.

If applicable, add mockups / screenshots to help present your vision of the feature

No response

Rhelvetican commented 3 weeks ago

This might be a little hard because different languages have different ways to represent an image.

Also pardon me for asking but did you write the description by AI?

intrd commented 3 weeks ago

In Sublime, there's a plugin that solves this in a simple way:

image

The plugin: https://github.com/robinchenyu/imagepaste/

image

How to do this on Zed? any pointing?

Rhelvetican commented 3 weeks ago

@intrd By referencing it (in not .md and similar languages), you mean pasting the (presumably relative) path to the image?

For Rust we can use include_bytes!(<path>).

notpeter commented 2 weeks ago

@longbuivan If I am understanding this request correctly, you would like to have functionality similar to GitHub when editing a Markdown document, whereby when you paste image data from the clipboard it does the following:

  1. Creates an image file from the pasted clipboard data in a folder adjacent to the file you are currently editing. The folder/filename would be based on the filename of the currently edited file (e.g. ImagePaste for ImagePaste.py)
  2. The relative path of that new file is pasted into the buffer, ./ImagePaste/ImagePaste001.png.
  3. When editing a Markdown file instead of ./ImagePaste/ImagePaste001.png you'd get ![](./ImagePaste/ImagePaste001.png)

Nifty.

intrd commented 2 weeks ago

Yes, it's exactly that, @notpeter. I think it's a good idea for an extension, not a Zed built-in feature.