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

Markdown: Drop (or paste) image, file destination: relative path #193752

Closed
mrienstra opened this issue Sep 22, 2023 · 5 comments · Fixed by #200883
Closed

Markdown: Drop (or paste) image, file destination: relative path #193752

mrienstra opened this issue Sep 22, 2023 · 5 comments · Fixed by #200883
Assignees
Labels
feature-request Request for new features or functionality markdown Markdown support issues verification-needed Verification of issue is requested verified Verification succeeded

Comments

@mrienstra
Copy link
Contributor

As per docs/languages/markdown#_inserting-images-and-links-to-files:

By default VS Code automatically copies dropped or pasted images outside of the workspace into your workspace. The markdown.copyFiles.destination setting controls where the new image file should be created.

It would be useful to add two more variables containing the relative path.

Using the same example file as the docs (/docs/api/readme.md), and the same glob pattern ("/docs/**/*"):

  1. Relative to the workspace, e.g. /docs/api/. This would be the same path that is returned by the "Copy Relative Path" command (copyRelativePathCommandHandler), minus the filename. I'll tentatively call this documentRelativeDirName.
  2. Relative to the glob path, in this case, given a glob pattern of "/docs/**/*", the path relative to /docs/ would be /api/. I'll tentatively call this documentGlobRelativeDirName.

These would be useful if a project wishes to place all images within, say, /src/assets/.

Using (1) above, an image dragged or pasted into /docs/api/readme.md would be copied into /src/assets/docs/api/readme/ (for the destination "/src/assets/${documentRelativeDirName}/"), and using (2), into /src/assets/api/readme/ (for the destination "/src/assets/${documentGlobRelativeDirName}/").

(the names documentRelativeDirName & documentGlobRelativeDirName are not intended to be thoughtful suggestions, just throwing them out as examples to facilitate discussion)

As this comment points out, documentDirName provides the absolute file system path, rather than the workspace-relative path as some might expect.

References:

@mjbvz mjbvz added feature-request Request for new features or functionality markdown Markdown support issues labels Nov 20, 2023
@vscodenpa vscodenpa added this to the Backlog Candidates milestone Nov 20, 2023
@vscodenpa
Copy link

This feature request is now a candidate for our backlog. The community has 60 days to upvote the issue. If it receives 20 upvotes we will move it to our backlog. If not, we will close it. To learn more about how we handle feature requests, please see our documentation.

Happy Coding!

@mjbvz
Copy link
Collaborator

mjbvz commented Dec 14, 2023

Adding:

  • documentRelativeDirName — Relative path to document parent directory: docs/release-notes
  • documentFilePath — Absolute path to file: /user/me/project/docs/release-notes/file.md
  • documentRelativeFilePath — Relative path to file: docs/release-notes/file.md

Skipping documentGlobRelativeDirName as there's no precedent in other places we use snippet type substitution

@vscodenpa vscodenpa added unreleased Patch has not yet been released in VS Code Insiders insiders-released Patch has been released in VS Code Insiders and removed unreleased Patch has not yet been released in VS Code Insiders labels Dec 14, 2023
@mjbvz mjbvz added the verification-needed Verification of issue is requested label Jan 22, 2024
@hediet hediet added the verification-found Issue verification failed label Jan 24, 2024
@hediet hediet reopened this Jan 24, 2024
@vscodenpa vscodenpa removed the insiders-released Patch has been released in VS Code Insiders label Jan 24, 2024
@hediet
Copy link
Member

hediet commented Jan 24, 2024

Roopening, as the feature is not discoverable without documenting the new placeholders:

Code_-_Insiders_i29C8Z9r14

The feature itself works.

@mrienstra
Copy link
Contributor Author

mrienstra commented Jan 24, 2024

Thanks @hediet! Looks like that documentation is coming from "configuration.markdown.copyFiles.destination" in extensions/markdown-language-features/package.nls.json#L67. Decided to just throw together a quick PR since it's a fairly straightforward fix.

PS: and thank you @mjbvz for adding those new variables back in December, much appreciated!!! 🙇‍♀️

@mjbvz mjbvz closed this as completed Jan 25, 2024
@mjbvz mjbvz added the unreleased Patch has not yet been released in VS Code Insiders label Jan 25, 2024
@vscodenpa vscodenpa removed the unreleased Patch has not yet been released in VS Code Insiders label Jan 25, 2024
@vscodenpa
Copy link

Issue marked as unreleased but unable to locate closing commit in issue timeline. You can manually reference a commit by commenting \closedWith someCommitSha, or directly add the insiders-released label if you know this has already been releaased

@vscodenpa vscodenpa added the unreleased Patch has not yet been released in VS Code Insiders label Jan 25, 2024
@aiday-mar aiday-mar removed the verification-needed Verification of issue is requested label Jan 25, 2024
@rzhao271 rzhao271 added verification-needed Verification of issue is requested and removed verification-found Issue verification failed labels Jan 25, 2024
@vscodenpa vscodenpa removed the unreleased Patch has not yet been released in VS Code Insiders label Jan 26, 2024
@hediet hediet added the verified Verification succeeded label Jan 26, 2024
@aiday-mar aiday-mar added this to the December / January 2024 milestone Feb 6, 2024
@microsoft microsoft locked and limited conversation to collaborators Jun 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality markdown Markdown support issues verification-needed Verification of issue is requested verified Verification succeeded
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants