@@ -136,6 +136,17 @@ export const insertSibling = function(el, node) {
136136 } )
137137}
138138
139+ /**
140+ * @function
141+ * @instance
142+ * @name insertBefore
143+ * @memberof NodeOperation
144+ * @description Create a sibling node before the selected node.
145+ * @param {TargetElement } el - Target element return by E('...'), default value: currentTarget.
146+ * @param {node } node - New node information.
147+ * @example
148+ * insertBefore(E('bd4313fbac40284b'))
149+ */
139150export const insertBefore = function ( el , node ) {
140151 const nodeEle = el || this . currentNode
141152 if ( ! nodeEle ) return
@@ -171,6 +182,17 @@ export const insertBefore = function(el, node) {
171182 } )
172183}
173184
185+ /**
186+ * @function
187+ * @instance
188+ * @name insertParent
189+ * @memberof NodeOperation
190+ * @description Create a parent node of the selected node.
191+ * @param {TargetElement } el - Target element return by E('...'), default value: currentTarget.
192+ * @param {node } node - New node information.
193+ * @example
194+ * insertParent(E('bd4313fbac40284b'))
195+ */
174196export const insertParent = function ( el , node ) {
175197 const nodeEle = el || this . currentNode
176198 if ( ! nodeEle ) return
@@ -183,18 +205,19 @@ export const insertParent = function(el, node) {
183205 addParentLink ( this . nodeData )
184206 const grp0 = nodeEle . parentElement . parentElement
185207 console . time ( 'insertParent_DOM' )
186- const { grp, top } = this . createGroup ( newNodeObj )
187- // console.log(grp)
208+ const { grp, top } = this . createGroup ( newNodeObj , true )
188209 const children = grp0 . parentNode
189210 children . insertBefore ( grp , grp0 . nextSibling )
190211
191- // const c = $d.createElement('children')
192- // c.appendChild(grp0)
193- // top.appendChild(createExpander(true))
194- // top.parentElement.insertBefore(c, top.nextSibling)
195- grp0 . remove ( )
212+ const c = $d . createElement ( 'children' )
213+ c . appendChild ( grp0 )
214+ top . appendChild ( createExpander ( true ) )
215+ top . parentElement . insertBefore ( c , top . nextSibling )
216+
196217 if ( children . className === 'box' ) {
197- this . processPrimaryNode ( grp , newNodeObj )
218+ grp . className = grp0 . className
219+ grp0 . className = ''
220+ grp0 . querySelector ( '.svg3rd' ) . remove ( )
198221 this . linkDiv ( )
199222 } else {
200223 this . linkDiv ( grp . offsetParent )
@@ -421,7 +444,7 @@ export const removeNode = function(el) {
421444 * @instance
422445 * @name moveNode
423446 * @memberof NodeOperation
424- * @description Move the target node to another node (as child node).
447+ * @description Move a node to another node (as child node).
425448 * @param {TargetElement } from - The target you want to move.
426449 * @param {TargetElement } to - The target(as parent node) you want to move to.
427450 * @example
@@ -479,6 +502,17 @@ export const moveNode = function(from, to) {
479502 console . timeEnd ( 'moveNode' )
480503}
481504
505+ /**
506+ * @function
507+ * @instance
508+ * @name moveNodeBefore
509+ * @memberof NodeOperation
510+ * @description Move a node and become previous node of another node.
511+ * @param {TargetElement } from
512+ * @param {TargetElement } to
513+ * @example
514+ * moveNodeBefore(E('bd4313fbac402842'),E('bd4313fbac402839'))
515+ */
482516export const moveNodeBefore = function ( from , to ) {
483517 const fromObj = from . nodeObj
484518 const toObj = to . nodeObj
@@ -498,6 +532,17 @@ export const moveNodeBefore = function(from, to) {
498532 } )
499533}
500534
535+ /**
536+ * @function
537+ * @instance
538+ * @name moveNodeAfter
539+ * @memberof NodeOperation
540+ * @description Move a node and become next node of another node.
541+ * @param {TargetElement } from
542+ * @param {TargetElement } to
543+ * @example
544+ * moveNodeAfter(E('bd4313fbac402842'),E('bd4313fbac402839'))
545+ */
501546export const moveNodeAfter = function ( from , to ) {
502547 const fromObj = from . nodeObj
503548 const toObj = to . nodeObj
0 commit comments