Skip to content

Add file prefix format option to Bear importer#510

Open
KrauseFx wants to merge 1 commit intoobsidianmd:masterfrom
KrauseFx:bear-file-prefix-format
Open

Add file prefix format option to Bear importer#510
KrauseFx wants to merge 1 commit intoobsidianmd:masterfrom
KrauseFx:bear-file-prefix-format

Conversation

@KrauseFx
Copy link
Copy Markdown

@KrauseFx KrauseFx commented Mar 1, 2026

Adds a File prefix format option to the Bear importer, matching the Apple Notes behavior for note filenames.

This lets users prefix imported Bear note names with creation dates using a format like YYYY-MM-DD, or leave it blank for no prefix.

Apple Notes implementation similar to https://github.com/obsidianmd/obsidian-importer/blob/master/src/formats/apple-notes.ts

image

Copy link
Copy Markdown
Contributor

@tgrosinger tgrosinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making this improvement!

I'm wondering if the note prefix should apply to attachments too, like it does in the Apple Notes importer format?

t.onChange(v => updatePrefix(v));
// In practice, users may click Import while focus is still in this field.
// 'change' may not fire yet, so persist on each keystroke too.
t.inputEl.addEventListener('input', () => updatePrefix(t.inputEl.value));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not think this is necessary. In my testing I see that the onChange hook is called before this listener every time I press a key.

async import(ctx: ImportContext): Promise<void> {
// The importer modal clears/rebuilds its DOM before import runs, so read from
// persisted settings here instead of trusting the now-detached input element.
this.filePrefixFormat = localStorage.getItem(LOCAL_STORAGE_KEY) || '';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why this is necessary. this.filePrefixFormat is the same before and after this line in my testing.


idMapping[metadata?.id] = {
filename: fileName,
filename: file.basename,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this need to change?

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.

2 participants