Skip to content

Commit 01b95b0

Browse files
committed
fix: set node direction when adding a primary node
1 parent 3c8bd44 commit 01b95b0

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mind-elixir",
3-
"version": "4.3.2",
3+
"version": "4.3.3",
44
"type": "module",
55
"description": "Mind elixir is a free open source mind map core.",
66
"keywords": [

src/nodeOperation.ts

+5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type { Topic } from './types/dom'
55
import type { MindElixirInstance, NodeObj } from './types/index'
66
import { insertNodeObj, insertParentNodeObj, moveUpObj, moveDownObj, removeNodeObj, moveNodeObj } from './utils/objectManipulation'
77
import { addChildDom, removeNodeDom } from './utils/domManipulation'
8+
import { LEFT, RIGHT } from './const'
89

910
const typeMap: Record<string, InsertPosition> = {
1011
before: 'beforebegin',
@@ -65,6 +66,10 @@ export const insertSibling = function (this: MindElixirInstance, type: 'before'
6566
return
6667
}
6768
const newNodeObj = node || this.generateNewObj()
69+
if (!nodeObj.parent?.parent) {
70+
const direction = nodeEle.offsetParent.offsetParent.parentElement.className === 'lhs' ? LEFT : RIGHT
71+
newNodeObj.direction = direction
72+
}
6873
insertNodeObj(newNodeObj, type, nodeObj)
6974
fillParent(this.nodeData)
7075
const t = nodeEle.parentElement

src/types/index.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,9 @@ export type Options = {
150150

151151
export type Uid = string
152152

153+
export type Left = 0
154+
export type Right = 1
155+
153156
/**
154157
* MindElixir node object
155158
*
@@ -169,7 +172,7 @@ export type NodeObj = {
169172
icons?: string[]
170173
hyperLink?: string
171174
expanded?: boolean
172-
direction?: number
175+
direction?: Left | Right
173176
image?: {
174177
url: string
175178
width: number

0 commit comments

Comments
 (0)