Compare commits

..

2 Commits

Author SHA1 Message Date
SiriusXT
a22687e2d8 Merge branch 'main' into siriusbcd_close_split 2025-11-16 20:15:43 +08:00
SiriusXT
44475853df feat(split): allow closing any split pane 2025-11-16 20:12:56 +08:00
2 changed files with 17 additions and 3 deletions

View File

@@ -8,7 +8,7 @@ export default function ClosePaneButton() {
const [ isEnabled, setIsEnabled ] = useState(false);
function refresh() {
setIsEnabled(!!(noteContext && !!noteContext.mainNtxId));
setIsEnabled(!!noteContext);
}
useTriliumEvent("noteContextReorder", refresh);

View File

@@ -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">) {