MarkdownEditing icon indicating copy to clipboard operation
MarkdownEditing copied to clipboard

Paste Image from clipboard

Open cropse opened this issue 7 years ago • 4 comments

Hi: It might be a convenience feature when user wants to paste images in Markdown immediately, with Pillow package would be feasible?

There is few modify I expect:

  • [ ] pillow package include
  • [ ] image folder/path in user setting
  • [ ] key binding for paste image

If it is a great feature good to have, I can take time to implement it, How about that?

cropse avatar Apr 06 '17 03:04 cropse

@cropse This is an interesting idea, definitely worth a try. I can think of some challenges:

  1. How well does ST supports customizing pasting image event?
  2. How to handle different image format?
  3. There are two ways (AFAIK) of copying images: one is copying pixels (e.g. screenshot), another one is copying image file.
  4. Is your solution portable across OSX, Linux, Win?
  5. Where do you put image files? In actual files or blobs? If former, is it customizable for each project? If latter, will it affect editing experience?
  6. Markdown is intended to generate HTML. All images should ultimately be loaded by web browser through URL. How do you map file system path to web path?

felixhao28 avatar Jun 13 '17 03:06 felixhao28

It would be great if i could oauth into github and then be uploading them into https://user-images.githubusercontent.com/, then the image URL can populate automagically.... like this:

image

@felixhao28 @cropse

fotoflo avatar Dec 22 '17 03:12 fotoflo

Uploading to Github (or any public web content storage) is one way of serving the image. This also poses a risk that web content is loaded from different servers. CORS is enabled for images but you will expect users to have direct and stable network access to Github, which might be a problem for users behind firewalls or on internal networks. More often, I see markdown writers serve images locally (e.g. Gitlab, wiki, blog).

If we are going to implement this feature. We can start from mapping local file path to relative URI. There is an open PR #486 that handles local file mapping that we can leverage.

felixhao28 avatar Dec 22 '17 06:12 felixhao28

There is this plugin which I cannot get to work, but it I guess it would be a starting point. https://github.com/robinchenyu/imagepaste I think they have the right idea, save in a subfolder as PNG and insert the relative path ./subfolder/pasteimage.png at the point of the cursor. By the way, options about what to name the image might be useful. For example, prefix of current document's file name, current date/time, or incremental number etc.

bao7uo avatar Jan 22 '18 14:01 bao7uo