-
-
Notifications
You must be signed in to change notification settings - Fork 21
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
Drag and Drop to create Markdown images in MDX files #322
Comments
How far should this be taken? What should we generate?
|
I would suggest just copying the relatively simple VS Code implementation for a start - only handle single files, and insert (using relative paths):
And only allow drag + drop to I think that's probably the 80% or even 90% use case. |
I like the idea of starting with inserting images using markdown syntax to get started. The inserted image node should contain a path relative to the MDX file. I think we should consider supporting other file types (Video files? URLs?) afterwards. We also need to figure out is this is going to be part of the VSCode extension, or if the language server can somehow support this. |
Wonder if this Copy external media files into workspace on drop or paste for Markdown from VS Code 1.79 (May 2023) is going to also just work out of the box, when this feature is implemented 😍 Coping.a.file.into.the.workspace.by.drag.and.dropping.it.mp4 |
When dropping an image, the image is downloaded next to the file, and a markdown link is generated. When text is dropped, the text is inserted as-is. This only works in VS Code. This uses a naive text-based approach. This is very similar to the implementation for markdown files that’s builtin to VS Code. Closes #322
When dropping an image, the image is downloaded next to the file, and a markdown link is generated. When text is dropped, the text is inserted as-is. This only works in VS Code. This uses a naive text-based approach. This is very similar to the implementation for markdown files that’s builtin to VS Code. Closes #322
When dropping an image, the image is downloaded next to the file, and a markdown link is generated. When text is dropped, the text is inserted as-is. This only works in VS Code. This uses a naive text-based approach. This is very similar to the implementation for markdown files that’s builtin to VS Code. Closes #322
When dropping an image, the image is downloaded next to the file, and a markdown link is generated. When text is dropped, the text is inserted as-is. This only works in VS Code. This uses a naive text-based approach. This is very similar to the implementation for markdown files that’s builtin to VS Code. Closes #322
This comment has been minimized.
This comment has been minimized.
Thanks for the PR and review at #345 @remcohaszing @wooorm 🙌 One question regarding this note from #345:
When dragging and dropping an existing image from the VS Code tree (eg. an image which is either a sibling or in a different directory), I am guessing that it doesn't download the image again, right? |
It doesn’t handle images dragged from the file tree apparently, only from the web. But it definitely makes sense to do so. I’ll fix that right away. |
A mime type of `uri-list` is for example files dragged from the VSCode tree view. Images are turnes into Markdown images. These are detected based on a hardcoded list of file extensions. Other URIs are inserted as-is. If the dragged URI uses the same scheme as the document it was dragged in, a relative path is inserted. Otherwise the full URI is used. Closes #322
A mime type of `uri-list` is for example files dragged from the VSCode tree view. Images are turnes into Markdown images. These are detected based on a hardcoded list of file extensions. Other URIs are inserted as-is. If the dragged URI uses the same scheme as the document it was dragged in, a relative path is inserted. Otherwise the full URI is used. Closes #322
Thanks @remcohaszing , awesome 🚀 I judge from the I will be one of your first testers and will be happy to also do my bit to push the feature on social media too 🙌 |
Yes. I really want to implement #349 in this release. That’s currently the only blocker (but not a hard one). Expect a release very soon. I love the enthousiasm and would love your feedback and any promotion on social media ❤️ |
Released in Re promotion: feel free to retweet https://twitter.com/remcohaszing/status/1722621607620059512 😄 |
Finally got some time to look at this. Just trying to make a video of this feature for X/Twitter and I'm having trouble activating the feature. Am I doing something wrong? I would expect that dragging a Kapture.2023-11-26.at.15.53.17.mp4 |
I’ve confirmed and found the problem. You can drop images from external sources, but not reference local files. I’m working on it right now. |
This was using `URL.canParse`, which isn’t available in the Node.js version used by VSCode. This failed silently. This is fixed by using strict parse mode from `vscode-uri`. Closes #322
This was using `URL.canParse`, which isn’t available in the Node.js version used by VSCode. This failed silently. This is fixed by using strict parse mode from `vscode-uri`. Closes #322
This was using `URL.canParse`, which isn’t available in the Node.js version used by VSCode. This failed silently. This is fixed by using strict parse mode from `vscode-uri`. Closes #322
This comment has been minimized.
This comment has been minimized.
@remcohaszing I was making a video to test this just now, and it almost works! The path seems to be 1 level incorrect though (the Kapture.2023-12-17.at.13.54.20.mp4Paths:
|
Fixed in 31f1912. |
Great, just tested this in 1.6.1 of the VS Code and it works, thanks! 🚀 did some posts about it: |
I edited this issue to be image-only and moved the video parts to a new issue: |
Initial checklist
Problem
Quickly authoring MDX documents by dragging and dropping images is a nice DX
There is a drag and drop feature introduced in VS Code 1.70 (thanks @mjbvz) that allowed for handling dropped files (either from the VS Code explorer, editor tabs, the OS, or other applications) (extension sample) - activate this feature by holding shift while dragging a file.
With Markdown files (
*.md
), VS Code allows for creating a Markdown image:Changing.how.an.image.is.dropped.using.the.drop.selector.widget.mp4
It would be amazing if creating Markdown images with drag and drop was also supported in an MDX file. Currently, as of VS Code 1.78, it just inserts the path:
vscode-1.78-april-2023-drag-drop-mdx.mp4
Solution
Apparently in VS Code 1.78 (April 2023) - or maybe earlier - there is an option for extensions to contribute their own options to this list:
Source: https://code.visualstudio.com/updates/v1_78#_drop-selector
Maybe this would be the way to contribute this action of "Insert Markdown Image"
Alternatives
Installing the Drag And Drop Import Relative Path extension by @ElecTreeFrying
The text was updated successfully, but these errors were encountered: