Description
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/**/*"
):
- 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 thisdocumentRelativeDirName
. - 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 thisdocumentGlobRelativeDirName
.
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:
- substitution map: extensions/markdown-language-features/src/languageFeatures/copyFiles/copyFiles.ts#L149-L160 (link points to current latest commit)
- powers
copyFiles.ts
: https://github.com/microsoft/vscode-uri - description provided in settings: extensions/markdown-language-features/package.nls.json#L66