From e2702bdd511f2e8942d49d705452628f3072f442 Mon Sep 17 00:00:00 2001 From: Yuri Karamian Date: Mon, 8 Jun 2026 01:20:21 +0200 Subject: [PATCH] Create new notes in the open note's notebook when not in a notebook view --- src/lib/components/NoteList.svelte | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/lib/components/NoteList.svelte b/src/lib/components/NoteList.svelte index 4ac4b98..a9db31a 100644 --- a/src/lib/components/NoteList.svelte +++ b/src/lib/components/NoteList.svelte @@ -375,7 +375,19 @@ calYear = today.getFullYear(); return; } - const nbRelative = $viewMode === 'notebook' ? $activeNotebook?.relative_path ?? null : null; + // Target: active notebook, else the open note's folder, else root. + let nbRelative: string | null = null; + if ($viewMode === 'notebook' && $activeNotebook) { + nbRelative = $activeNotebook.relative_path || null; + } else if ($appConfig?.active_vault && $activeNotePath) { + const vaultN = $appConfig.active_vault.replace(/\\/g, '/'); + const apN = $activeNotePath.replace(/\\/g, '/'); + if (apN.startsWith(vaultN + '/')) { + const rel = apN.slice(vaultN.length + 1); + const slash = rel.lastIndexOf('/'); + if (slash > 0) nbRelative = rel.slice(0, slash); + } + } try { const entry = await createNote(nbRelative, 'Untitled'); noteCache.clear();