Skip to content

Configurable default attachment path (#1215)#2048

Open
soy-chrislo wants to merge 1 commit into
silverbulletmd:mainfrom
soy-chrislo:fix/1215-default-attachment-path
Open

Configurable default attachment path (#1215)#2048
soy-chrislo wants to merge 1 commit into
silverbulletmd:mainfrom
soy-chrislo:fix/1215-default-attachment-path

Conversation

@soy-chrislo

Copy link
Copy Markdown

Closes #1215.

Adds an attachmentPath setting 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 resolveMarkdownLink already 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 (resolveAttachmentPath in plug-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 the editor.* syscalls that upload.ts/editor_paste.ts need, 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 attachmentPath for consistency with other flat settings like shortWikiLinks, but happy to rename if there's a preferred convention for this kind of thing.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FR: Configure default path for attachment

1 participant