MarkdownEditing
MarkdownEditing copied to clipboard
Paste Image from clipboard
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 This is an interesting idea, definitely worth a try. I can think of some challenges:
- How well does ST supports customizing pasting image event?
- How to handle different image format?
- There are two ways (AFAIK) of copying images: one is copying pixels (e.g. screenshot), another one is copying image file.
- Is your solution portable across OSX, Linux, Win?
- 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?
- 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?
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:
@felixhao28 @cropse
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.
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.