Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
feat(split): allow closing any split pane
SiriusXT44475853df09
diff --git a/apps/client/src/widgets/buttons/close_pane_button.tsx b/apps/client/src/widgets/buttons/close_pane_button.tsxindex c171d0d8ef..726c5c49e0 100644--- a/apps/client/src/widgets/buttons/close_pane_button.tsx+++ b/apps/client/src/widgets/buttons/close_pane_button.tsx@@ -8,7 +8,7 @@ export default function ClosePaneButton() {const [ isEnabled, setIsEnabled ] = useState(false);function refresh() {- setIsEnabled(!!(noteContext && !!noteContext.mainNtxId));+ setIsEnabled(!!noteContext);}useTriliumEvent("noteContextReorder", refresh);diff --git a/apps/client/src/widgets/containers/split_note_container.ts b/apps/client/src/widgets/containers/split_note_container.tsindex 8298d59893..90e77c0211 100644--- a/apps/client/src/widgets/containers/split_note_container.ts+++ b/apps/client/src/widgets/containers/split_note_container.ts@@ -100,9 +100,23 @@ export default class SplitNoteContainer extends FlexContainer<SplitNoteWidget> {}async closeThisNoteSplitCommand({ ntxId }: CommandListenerData<"closeThisNoteSplit">) {- if (ntxId) {- await appContext.tabManager.removeNoteContext(ntxId);+ if (!ntxId) return;+ const contexts = appContext.tabManager.noteContexts;++ const currentIndex = contexts.findIndex((c) => c.ntxId === ntxId);+ if (currentIndex === -1) return;++ const isRemoveMainContext = !contexts[currentIndex].mainNtxId;+ if (isRemoveMainContext && currentIndex + 1 <= contexts.length) {+ const ntxIds = contexts.map((c) => c.ntxId).filter((c) => !!c) as string[];+ this.triggerCommand("noteContextReorder", {+ ntxIdsInOrder: ntxIds,+ oldMainNtxId: ntxId,+ newMainNtxId: ntxIds[currentIndex + 1]+ });}++ await appContext.tabManager.removeNoteContext(ntxId);}async moveThisNoteSplitCommand({ ntxId, isMovingLeft }: CommandListenerData<"moveThisNoteSplit">) {