@@ -2,16 +2,17 @@ import type { DragDropEvents } from "@dnd-kit-svelte/svelte";
22import type { PaneGroupProps } from "paneforge" ;
33import { settings } from "$lib/settings" ;
44
5+ export type SplitAxis = PaneGroupProps [ "direction" ] ;
56export type SplitDirection = "up" | "down" | "left" | "right" ;
67
7- export interface SplitParent {
8- direction : PaneGroupProps [ "direction" ] ;
8+ export interface SplitBranch {
9+ axis : SplitAxis ;
910 first : SplitNode ;
1011 second : SplitNode ;
1112 size ?: number ;
1213}
1314
14- export type SplitNode = SplitParent | string ;
15+ export type SplitNode = SplitBranch | string ;
1516
1617type SplitPath = "first" | "second" ;
1718
@@ -24,7 +25,7 @@ export class SplitManager {
2425 settings . state . layout = value ;
2526 }
2627
27- public insert ( target : string , newNode : string , data : SplitParent ) {
28+ public insert ( target : string , newNode : string , branch : SplitBranch ) {
2829 if ( ! this . root ) {
2930 this . root = target ;
3031 return ;
@@ -35,23 +36,23 @@ export class SplitManager {
3536
3637 this . root = this . #update( this . root , path , ( node ) => {
3738 if ( typeof node === "string" ) {
38- return { ...data , size : 50 } ;
39+ return { ...branch , size : 50 } ;
3940 }
4041
4142 return {
42- direction : data . direction ,
43+ axis : branch . axis ,
4344 first : node ,
4445 second : newNode ,
4546 size : 50 ,
4647 } ;
4748 } ) ;
4849 }
4950
50- public insertEmpty ( target : string , direction : PaneGroupProps [ "direction" ] ) {
51+ public insertEmpty ( target : string , axis : SplitAxis ) {
5152 const id = `split-${ crypto . randomUUID ( ) } ` ;
5253
5354 this . insert ( target , id , {
54- direction ,
55+ axis ,
5556 first : target ,
5657 second : id ,
5758 } ) ;
@@ -127,7 +128,7 @@ export class SplitManager {
127128 second = targetId ;
128129 }
129130
130- this . insert ( targetId , sourceId , { direction, first, second } ) ;
131+ this . insert ( targetId , sourceId , { axis : direction , first, second } ) ;
131132 }
132133 }
133134
0 commit comments