Skip to content

Commit b3404e3

Browse files
committed
fix: ensure .lhs and .rhs are found correctly
1 parent 4797e47 commit b3404e3

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

package.json

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

src/dev.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ mind.init(example)
6868
const m2 = new MindElixir({
6969
el: '#map2',
7070
selectionContainer: 'body', // use body to make selection usable when transform is not 0
71+
direction: MindElixir.SIDE,
7172
})
7273
m2.init(data)
7374

src/utils/domManipulation.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
1-
import { fillParent } from '.'
21
import { LEFT, RIGHT, SIDE } from '../const'
32
import { rmSubline } from '../nodeOperation'
43
import type { MindElixirInstance, NodeObj } from '../types'
54
import type { Topic, Wrapper } from '../types/dom'
6-
import { findEle, createExpander } from './dom'
5+
import { createExpander } from './dom'
76

87
// Judge new added node L or R
9-
export const judgeDirection = function (direction: number, obj: NodeObj) {
8+
export const judgeDirection = function ({ map, direction }: MindElixirInstance, obj: NodeObj) {
109
if (direction === LEFT) {
1110
return LEFT
1211
} else if (direction === RIGHT) {
1312
return RIGHT
1413
} else if (direction === SIDE) {
15-
const l = document.querySelector('.lhs')?.childElementCount || 0
16-
const r = document.querySelector('.rhs')?.childElementCount || 0
14+
const l = map.querySelector('.lhs')?.childElementCount || 0
15+
const r = map.querySelector('.rhs')?.childElementCount || 0
1716
if (l <= r) {
1817
obj.direction = LEFT
1918
return LEFT
@@ -38,7 +37,7 @@ export const addChildDom = function (mei: MindElixirInstance, to: Topic, wrapper
3837
}
3938
mei.linkDiv(wrapper.offsetParent as Wrapper)
4039
} else if (top.tagName === 'ME-ROOT') {
41-
const direction = judgeDirection(mei.direction, tpc.nodeObj)
40+
const direction = judgeDirection(mei, tpc.nodeObj)
4241
if (direction === LEFT) {
4342
mei.container.querySelector('.lhs')?.appendChild(wrapper)
4443
} else {

src/utils/svg.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export const createSvgGroup = function (d: string, arrowd1: string, arrowd2: str
5858
export const editSvgText = function (mei: MindElixirInstance, textEl: SVGTextElement, onblur: (div: HTMLDivElement) => void) {
5959
console.time('editSummary')
6060
if (!textEl) return
61-
const div = document.createElement('div')
61+
const div = $d.createElement('div')
6262
mei.nodes.appendChild(div)
6363
const origin = textEl.innerHTML
6464
div.id = 'input-box'

0 commit comments

Comments
 (0)