@@ -46,7 +46,7 @@ import {
4646 updateNodeTags ,
4747 updateNodeIcons ,
4848 updateNodeHyperLink ,
49- processPrimaryNode ,
49+ judgeDirection ,
5050 setNodeTopic ,
5151 moveNodeBefore ,
5252 moveNodeAfter ,
@@ -113,7 +113,8 @@ export interface NodeElement extends HTMLElement {
113113}
114114export interface MindElixirData {
115115 nodeData : NodeObj ,
116- linkData ?: LinkObj
116+ linkData ?: LinkObj ,
117+ direction ?: number
117118}
118119export interface MindElixirInstance {
119120 mindElixirBox : HTMLElement ,
@@ -153,7 +154,7 @@ export interface MindElixirInstance {
153154 map : HTMLElement ,
154155 root : HTMLElement ,
155156 box : HTMLElement ,
156- svg2nd : SVGElement ,
157+ lines : SVGElement ,
157158 linkController :SVGElement ,
158159 P2 : HTMLElement ,
159160 P3 : HTMLElement ,
@@ -314,7 +315,7 @@ function MindElixir(this: MindElixirInstance, {
314315
315316 // infrastructure
316317
317- this . svg2nd = createLinkSvg ( 'svg2nd ' ) // main link container
318+ this . lines = createLinkSvg ( 'lines ' ) // main link container
318319
319320 this . linkController = createLinkSvg ( 'linkcontroller' ) // bezier controller container
320321 this . P2 = $d . createElement ( 'div' ) // bezier P2
@@ -329,7 +330,7 @@ function MindElixir(this: MindElixirInstance, {
329330
330331 this . map . appendChild ( this . root )
331332 this . map . appendChild ( this . box )
332- this . map . appendChild ( this . svg2nd )
333+ this . map . appendChild ( this . lines )
333334 this . map . appendChild ( this . linkController )
334335 this . map . appendChild ( this . linkSvgGroup )
335336 this . map . appendChild ( this . P2 )
@@ -340,11 +341,11 @@ function MindElixir(this: MindElixirInstance, {
340341 } else initMouseEvent ( this )
341342}
342343
343- function beforeHook ( fn :( el :any , node ?:any ) => void ) {
344+ function beforeHook ( fn :( el :any , node ?:any ) => void , fnName : string ) {
344345 return async function ( ...args :unknown [ ] ) {
345346 if (
346- ! this . before [ fn . name ] ||
347- ( await this . before [ fn . name ] . apply ( this , args ) )
347+ ! this . before [ fnName ] ||
348+ ( await this . before [ fnName ] . apply ( this , args ) )
348349 ) {
349350 fn . apply ( this , args )
350351 }
@@ -356,23 +357,23 @@ MindElixir.prototype = {
356357 getObjById,
357358 generateNewObj,
358359 // node operation
359- insertSibling : beforeHook ( insertSibling ) ,
360- insertBefore : beforeHook ( insertBefore ) ,
361- insertParent : beforeHook ( insertParent ) ,
362- addChild : beforeHook ( addChild ) ,
363- copyNode : beforeHook ( copyNode ) ,
364- moveNode : beforeHook ( moveNode ) ,
365- removeNode : beforeHook ( removeNode ) ,
366- moveUpNode : beforeHook ( moveUpNode ) ,
367- moveDownNode : beforeHook ( moveDownNode ) ,
368- beginEdit : beforeHook ( beginEdit ) ,
369- moveNodeBefore : beforeHook ( moveNodeBefore ) ,
370- moveNodeAfter : beforeHook ( moveNodeAfter ) ,
360+ insertSibling : beforeHook ( insertSibling , 'insertSibling' ) ,
361+ insertBefore : beforeHook ( insertBefore , 'insertBefore' ) ,
362+ insertParent : beforeHook ( insertParent , 'insertParent' ) ,
363+ addChild : beforeHook ( addChild , 'addChild' ) ,
364+ copyNode : beforeHook ( copyNode , 'copyNode' ) ,
365+ moveNode : beforeHook ( moveNode , 'moveNode' ) ,
366+ removeNode : beforeHook ( removeNode , 'removeNode' ) ,
367+ moveUpNode : beforeHook ( moveUpNode , 'moveUpNode' ) ,
368+ moveDownNode : beforeHook ( moveDownNode , 'moveDownNode' ) ,
369+ beginEdit : beforeHook ( beginEdit , 'beginEdit' ) ,
370+ moveNodeBefore : beforeHook ( moveNodeBefore , 'moveNodeBefore' ) ,
371+ moveNodeAfter : beforeHook ( moveNodeAfter , 'moveNodeAfter' ) ,
371372 updateNodeStyle,
372373 updateNodeTags,
373374 updateNodeIcons,
374375 updateNodeHyperLink,
375- processPrimaryNode ,
376+ judgeDirection ,
376377 setNodeTopic,
377378
378379 createLink,
@@ -413,6 +414,9 @@ MindElixir.prototype = {
413414 } ,
414415 init ( data :MindElixirData ) {
415416 if ( ! data || ! data . nodeData ) return new Error ( 'MindElixir: `data` is required' )
417+ if ( data . direction ) {
418+ this . direction = data . direction
419+ }
416420 this . nodeData = data . nodeData
417421 this . linkData = data . linkData || { }
418422 // plugin
0 commit comments