Skip to content

Commit

Permalink
fix: set node direction when adding a primary node
Browse files Browse the repository at this point in the history
  • Loading branch information
SSShooter committed Nov 15, 2024
1 parent 3c8bd44 commit 01b95b0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mind-elixir",
"version": "4.3.2",
"version": "4.3.3",
"type": "module",
"description": "Mind elixir is a free open source mind map core.",
"keywords": [
Expand Down
5 changes: 5 additions & 0 deletions src/nodeOperation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type { Topic } from './types/dom'
import type { MindElixirInstance, NodeObj } from './types/index'
import { insertNodeObj, insertParentNodeObj, moveUpObj, moveDownObj, removeNodeObj, moveNodeObj } from './utils/objectManipulation'
import { addChildDom, removeNodeDom } from './utils/domManipulation'
import { LEFT, RIGHT } from './const'

const typeMap: Record<string, InsertPosition> = {
before: 'beforebegin',
Expand Down Expand Up @@ -65,6 +66,10 @@ export const insertSibling = function (this: MindElixirInstance, type: 'before'
return
}
const newNodeObj = node || this.generateNewObj()
if (!nodeObj.parent?.parent) {
const direction = nodeEle.offsetParent.offsetParent.parentElement.className === 'lhs' ? LEFT : RIGHT
newNodeObj.direction = direction
}
insertNodeObj(newNodeObj, type, nodeObj)
fillParent(this.nodeData)
const t = nodeEle.parentElement
Expand Down
5 changes: 4 additions & 1 deletion src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ export type Options = {

export type Uid = string

export type Left = 0
export type Right = 1

/**
* MindElixir node object
*
Expand All @@ -169,7 +172,7 @@ export type NodeObj = {
icons?: string[]
hyperLink?: string
expanded?: boolean
direction?: number
direction?: Left | Right
image?: {
url: string
width: number
Expand Down

0 comments on commit 01b95b0

Please sign in to comment.