Configurable default attachment path (#1215)#2048
Open
soy-chrislo wants to merge 1 commit into
Open
Conversation
Adds an `attachmentPath` config setting that pre-fills the file name prompt shown when pasting or uploading an attachment, instead of the user having to type a folder prefix (e.g. "Assets/") every time. Reuses the existing resolveMarkdownLink absolute/relative convention (leading "/" = absolute from the space root, otherwise relative to the current page's folder), so it covers both the prefix requested in the issue and the per-note subfolder variant requested in its only comment. Empty (the default) keeps today's behavior unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1215.
Adds an
attachmentPathsetting that pre-fills the file name prompt when pasting or uploading an attachment, so you don't have to type a folder prefix every time.I went with reusing the absolute/relative convention
resolveMarkdownLinkalready uses for wikilinks instead of inventing new syntax: a leading/(e.g./Assets/) is absolute from the space root, no leading slash (e.g.attachments/) resolves relative to the current page's folder, and leaving it empty (default) keeps today's behavior untouched. This also covers what @dbsavage asked for in the comment (per-note relative folders), not just the original absolute-prefix request, without any extra work.The only new logic (
resolveAttachmentPathinplug-api/lib/resolve.ts) is unit tested. I didn't add an integration/E2E test for the full paste-to-save flow —createMockSystem()doesn't register theeditor.*syscalls thatupload.ts/editor_paste.tsneed, and mocking that whole surface felt like it'd test the mock more than the behavior. Tested manually instead: ran the server locally, uploaded and pasted a file with the setting on and off, confirmed the path prefix shows up correctly and that leaving it unset behaves exactly like before.One thing I'm not sure about: the setting name. I called it
attachmentPathfor consistency with other flat settings likeshortWikiLinks, but happy to rename if there's a preferred convention for this kind of thing.