diff --git a/apps/client/src/services/note_autocomplete.ts b/apps/client/src/services/note_autocomplete.ts index 4d96d0bde..f5141e061 100644 --- a/apps/client/src/services/note_autocomplete.ts +++ b/apps/client/src/services/note_autocomplete.ts @@ -480,20 +480,10 @@ function initNoteAutocomplete($el: JQuery, options?: Options) { } case SuggestionAction.CreateNoteIntoInbox: - case SuggestionAction.CreateAndLinkNoteIntoInbox: - case SuggestionAction.CreateNoteIntoPath: - case SuggestionAction.CreateAndLinkNoteIntoPath: { - let target = "inbox"; - if ( - suggestion.action === SuggestionAction.CreateNoteIntoPath || - suggestion.action === SuggestionAction.CreateAndLinkNoteIntoPath - ) { - target = "into"; - } - + case SuggestionAction.CreateAndLinkNoteIntoInbox: { const { note } = await noteCreateService.createNote( { - target: target, + target: "inbox", title: suggestion.noteTitle, activate: true, promptForType: true, @@ -510,6 +500,30 @@ function initNoteAutocomplete($el: JQuery, options?: Options) { break; } + case SuggestionAction.CreateNoteIntoPath: + case SuggestionAction.CreateAndLinkNoteIntoPath: { + if (!suggestion.parentNoteId) return; + + const { note } = await noteCreateService.createNote( + { + parentNoteUrl: suggestion.parentNoteId, + target: "into", + title: suggestion.noteTitle, + activate: true, + promptForType: true, + }, + ); + + if (!note) return; + + const hoistedNoteId = appContext.tabManager.getActiveContext()?.hoistedNoteId; + suggestion.notePath = note?.getBestNotePathString(hoistedNoteId); + + $el.trigger("autocomplete:noteselected", [suggestion]); + $el.autocomplete("close"); + break; + } + case SuggestionAction.SearchNotes: { const searchString = suggestion.noteTitle; appContext.triggerCommand("searchNotes", { searchString });