feat: Make splits resizable

This commit is contained in:
SiriusXT
2025-09-02 09:28:53 +08:00
parent ed56ed2be0
commit 3254069999
4 changed files with 115 additions and 9 deletions

View File

@@ -2,6 +2,7 @@ import FlexContainer from "./flex_container.js";
import appContext, { type CommandData, type CommandListenerData, type EventData, type EventNames, type NoteSwitchedContext } from "../../components/app_context.js";
import type BasicWidget from "../basic_widget.js";
import type NoteContext from "../../components/note_context.js";
import splitService from "../../services/resizer.js";
interface NoteContextEvent {
noteContext: NoteContext;
@@ -51,6 +52,10 @@ export default class SplitNoteContainer extends FlexContainer<SplitNoteWidget> {
await widget.handleEvent("setNoteContext", { noteContext });
this.child(widget);
if (noteContext.mainNtxId && noteContext.ntxId) {
splitService.setupNoteSplitResizer([noteContext.mainNtxId,noteContext.ntxId]);
}
}
async openNewNoteSplitEvent({ ntxId, notePath, hoistedNoteId, viewScope }: EventData<"openNewNoteSplit">) {
@@ -94,9 +99,11 @@ export default class SplitNoteContainer extends FlexContainer<SplitNoteWidget> {
}
}
closeThisNoteSplitCommand({ ntxId }: CommandListenerData<"closeThisNoteSplit">) {
async closeThisNoteSplitCommand({ ntxId }: CommandListenerData<"closeThisNoteSplit">) {
if (ntxId) {
appContext.tabManager.removeNoteContext(ntxId);
await appContext.tabManager.removeNoteContext(ntxId);
splitService.delNoteSplitResizer([ntxId]);
}
}
@@ -136,6 +143,8 @@ export default class SplitNoteContainer extends FlexContainer<SplitNoteWidget> {
// activate context that now contains the original note
await appContext.tabManager.activateNoteContext(isMovingLeft ? ntxIds[leftIndex + 1] : ntxIds[leftIndex]);
splitService.moveNoteSplitResizer(ntxIds[leftIndex]);
}
activeContextChangedEvent() {
@@ -154,6 +163,8 @@ export default class SplitNoteContainer extends FlexContainer<SplitNoteWidget> {
delete this.widgets[ntxId];
}
splitService.delNoteSplitResizer(ntxIds);
}
contextsReopenedEvent({ ntxId, afterNtxId }: EventData<"contextsReopened">) {