feat: Make splits resizable

This commit is contained in:
SiriusXT 2025-09-02 20:17:01 +08:00
parent 88b748e67b
commit 5436011f8e
2 changed files with 13 additions and 16 deletions

View File

@ -119,13 +119,15 @@ function setupNoteSplitResizer(ntxIds: string[]) {
function delNoteSplitResizer(ntxIds: string[]) { function delNoteSplitResizer(ntxIds: string[]) {
let targetNtxIds = findKeyByNtxId(ntxIds[0]); let targetNtxIds = findKeyByNtxId(ntxIds[0]);
if (!targetNtxIds) {
return;
}
if (targetNtxIds) {
noteSplitMap.get(targetNtxIds)?.destroy(); noteSplitMap.get(targetNtxIds)?.destroy();
noteSplitMap.delete(targetNtxIds); noteSplitMap.delete(targetNtxIds);
targetNtxIds = targetNtxIds.filter(id => !ntxIds.includes(id)); targetNtxIds = targetNtxIds.filter(id => !ntxIds.includes(id));
}
if (targetNtxIds && targetNtxIds.length >= 2) { if (targetNtxIds.length >= 2) {
noteSplitMap.set(targetNtxIds, undefined); noteSplitMap.set(targetNtxIds, undefined);
createSplitInstance(targetNtxIds); createSplitInstance(targetNtxIds);
} }
@ -133,16 +135,13 @@ function delNoteSplitResizer(ntxIds: string[]) {
function moveNoteSplitResizer(ntxId: string) { function moveNoteSplitResizer(ntxId: string) {
const targetNtxIds = findKeyByNtxId(ntxId); const targetNtxIds = findKeyByNtxId(ntxId);
if (!targetNtxIds) {
if (targetNtxIds) { return;
}
noteSplitMap.get(targetNtxIds)?.destroy(); noteSplitMap.get(targetNtxIds)?.destroy();
noteSplitMap.set(targetNtxIds, undefined); noteSplitMap.set(targetNtxIds, undefined);
}
if (targetNtxIds) {
createSplitInstance(targetNtxIds); createSplitInstance(targetNtxIds);
} }
}
function createSplitInstance(targetNtxIds: string[]) { function createSplitInstance(targetNtxIds: string[]) {
const prevRafId = noteSplitRafMap.get(targetNtxIds); const prevRafId = noteSplitRafMap.get(targetNtxIds);

View File

@ -102,8 +102,6 @@ export default class SplitNoteContainer extends FlexContainer<SplitNoteWidget> {
async closeThisNoteSplitCommand({ ntxId }: CommandListenerData<"closeThisNoteSplit">) { async closeThisNoteSplitCommand({ ntxId }: CommandListenerData<"closeThisNoteSplit">) {
if (ntxId) { if (ntxId) {
await appContext.tabManager.removeNoteContext(ntxId); await appContext.tabManager.removeNoteContext(ntxId);
splitService.delNoteSplitResizer([ntxId]);
} }
} }