diff --git a/package.json b/package.json index cde5c4d..6f83655 100644 --- a/package.json +++ b/package.json @@ -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": [ diff --git a/src/nodeOperation.ts b/src/nodeOperation.ts index 93888a1..ecdde9d 100644 --- a/src/nodeOperation.ts +++ b/src/nodeOperation.ts @@ -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 = { before: 'beforebegin', @@ -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 diff --git a/src/types/index.ts b/src/types/index.ts index d0654a2..f6caa47 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -150,6 +150,9 @@ export type Options = { export type Uid = string +export type Left = 0 +export type Right = 1 + /** * MindElixir node object * @@ -169,7 +172,7 @@ export type NodeObj = { icons?: string[] hyperLink?: string expanded?: boolean - direction?: number + direction?: Left | Right image?: { url: string width: number