Create new notes in the open note's notebook when not in a notebook view

This commit is contained in:
Yuri Karamian
2026-06-08 01:20:21 +02:00
parent 0d0ecee06e
commit e2702bdd51
+13 -1
View File
@@ -375,7 +375,19 @@
calYear = today.getFullYear(); calYear = today.getFullYear();
return; 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 { try {
const entry = await createNote(nbRelative, 'Untitled'); const entry = await createNote(nbRelative, 'Untitled');
noteCache.clear(); noteCache.clear();