Skip to content

Commit 1ebf643

Browse files
committed
feat: update insert sibling logic
1 parent 0e65856 commit 1ebf643

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/dev.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ const mind = new MindElixir(options)
6363

6464
const data = MindElixir.new('new topic')
6565
console.log(data)
66-
mind.init(example)
66+
// mind.init(example)
67+
mind.init(data)
6768
function sleep() {
6869
return new Promise<void>(res => {
6970
setTimeout(() => res(), 1000)

src/nodeOperation.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ export const insertSibling = function (this: MindElixirInstance, el?: Topic, nod
9090
if (nodeObj.root === true) {
9191
this.addChild()
9292
return
93+
} else if (nodeObj.parent?.root === true && nodeObj.parent?.children?.length === 1) {
94+
// add at least one node to another side
95+
this.addChild(findEle(nodeObj.parent!.id))
96+
return
9397
}
9498
const newNodeObj = node || this.generateNewObj()
9599
insertNodeObj(nodeObj, newNodeObj)

0 commit comments

Comments
 (0)