@@ -56,10 +56,10 @@ export const insertSibling = function (this: MindElixirInstance, type: 'before'
5656 const nodeEle = el || this . currentNode
5757 if ( ! nodeEle ) return
5858 const nodeObj = nodeEle . nodeObj
59- if ( nodeObj . root === true ) {
59+ if ( ! nodeObj . parent ) {
6060 this . addChild ( )
6161 return
62- } else if ( nodeObj . parent ?. root === true && nodeObj . parent ?. children ?. length === 1 ) {
62+ } else if ( ! nodeObj . parent ?. parent && nodeObj . parent ?. children ?. length === 1 ) {
6363 // add at least one node to another side
6464 this . addChild ( findEle ( nodeObj . parent ! . id ) , node )
6565 return
@@ -93,7 +93,7 @@ export const insertParent = function (this: MindElixirInstance, el?: Topic, node
9393 if ( ! nodeEle ) return
9494 rmSubline ( nodeEle )
9595 const nodeObj = nodeEle . nodeObj
96- if ( nodeObj . root === true ) {
96+ if ( ! nodeObj . parent ) {
9797 return
9898 }
9999 const newNodeObj = node || this . generateNewObj ( )
@@ -210,7 +210,7 @@ export const removeNode = function (this: MindElixirInstance, el?: Topic) {
210210 const tpc = el || this . currentNode
211211 if ( ! tpc ) return
212212 const nodeObj = tpc . nodeObj
213- if ( nodeObj . root === true ) {
213+ if ( ! nodeObj . parent ) {
214214 throw new Error ( 'Can not remove root node' )
215215 }
216216 const siblings = nodeObj . parent ! . children !
@@ -239,7 +239,7 @@ export const removeNodes = function (this: MindElixirInstance, tpcs: Topic[]) {
239239 tpcs = unionTopics ( tpcs )
240240 for ( const tpc of tpcs ) {
241241 const nodeObj = tpc . nodeObj
242- if ( nodeObj . root === true ) {
242+ if ( ! nodeObj . parent ) {
243243 continue
244244 }
245245 const siblingLength = removeNodeObj ( nodeObj )
0 commit comments