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[]) {
let targetNtxIds = findKeyByNtxId(ntxIds[0]);
if (targetNtxIds) {
noteSplitMap.get(targetNtxIds)?.destroy();
noteSplitMap.delete(targetNtxIds);
targetNtxIds = targetNtxIds.filter(id => !ntxIds.includes(id));
if (!targetNtxIds) {
return;
}
if (targetNtxIds && targetNtxIds.length >= 2) {
noteSplitMap.get(targetNtxIds)?.destroy();
noteSplitMap.delete(targetNtxIds);
targetNtxIds = targetNtxIds.filter(id => !ntxIds.includes(id));
if (targetNtxIds.length >= 2) {
noteSplitMap.set(targetNtxIds, undefined);
createSplitInstance(targetNtxIds);
}
@@ -133,15 +135,12 @@ function delNoteSplitResizer(ntxIds: string[]) {
function moveNoteSplitResizer(ntxId: string) {
const targetNtxIds = findKeyByNtxId(ntxId);
if (targetNtxIds) {
noteSplitMap.get(targetNtxIds)?.destroy();
noteSplitMap.set(targetNtxIds, undefined);
}
if (targetNtxIds) {
createSplitInstance(targetNtxIds);
if (!targetNtxIds) {
return;
}
noteSplitMap.get(targetNtxIds)?.destroy();
noteSplitMap.set(targetNtxIds, undefined);
createSplitInstance(targetNtxIds);
}
function createSplitInstance(targetNtxIds: string[]) {

View File

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