1- import { fillParent } from '.'
21import { LEFT , RIGHT , SIDE } from '../const'
32import { rmSubline } from '../nodeOperation'
43import type { MindElixirInstance , NodeObj } from '../types'
54import type { Topic , Wrapper } from '../types/dom'
6- import { findEle , createExpander } from './dom'
5+ import { createExpander } from './dom'
76
87// Judge new added node L or R
9- export const judgeDirection = function ( direction : number , obj : NodeObj ) {
8+ export const judgeDirection = function ( { map , direction } : MindElixirInstance , obj : NodeObj ) {
109 if ( direction === LEFT ) {
1110 return LEFT
1211 } else if ( direction === RIGHT ) {
1312 return RIGHT
1413 } else if ( direction === SIDE ) {
15- const l = document . querySelector ( '.lhs' ) ?. childElementCount || 0
16- const r = document . querySelector ( '.rhs' ) ?. childElementCount || 0
14+ const l = map . querySelector ( '.lhs' ) ?. childElementCount || 0
15+ const r = map . querySelector ( '.rhs' ) ?. childElementCount || 0
1716 if ( l <= r ) {
1817 obj . direction = LEFT
1918 return LEFT
@@ -38,7 +37,7 @@ export const addChildDom = function (mei: MindElixirInstance, to: Topic, wrapper
3837 }
3938 mei . linkDiv ( wrapper . offsetParent as Wrapper )
4039 } else if ( top . tagName === 'ME-ROOT' ) {
41- const direction = judgeDirection ( mei . direction , tpc . nodeObj )
40+ const direction = judgeDirection ( mei , tpc . nodeObj )
4241 if ( direction === LEFT ) {
4342 mei . container . querySelector ( '.lhs' ) ?. appendChild ( wrapper )
4443 } else {
0 commit comments