Skip to content

Commit c6bbc2a

Browse files
committed
fix: fix summary display error
1 parent 6601dc3 commit c6bbc2a

File tree

4 files changed

+19
-12
lines changed

4 files changed

+19
-12
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": "3.1.2",
3+
"version": "3.1.3",
44
"type": "module",
55
"description": "Mind elixir is a free open source mind map core.",
66
"keywords": [

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ MindElixir.DARK_THEME = DARK_THEME
130130
* @memberof MindElixir
131131
* @static
132132
*/
133-
MindElixir.version = '3.1.2'
133+
MindElixir.version = '3.1.3'
134134
/**
135135
* @function
136136
* @memberof MindElixir

src/plugin/selection.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import dragMoveHelper from '../utils/dragMoveHelper'
44

55
export default function (mei: MindElixirInstance) {
66
const selection = new SelectionArea({
7-
selectables: ['#map me-tpc'],
8-
boundaries: ['#map .map-container'],
7+
selectables: ['.map-container me-tpc'],
8+
boundaries: ['.map-container'],
99
container: '.map-container',
1010
behaviour: {
1111
// Scroll configuration.

src/summary.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,13 @@ const calcRange = function (nodes: Topic[]) {
5353
}
5454
}
5555
}
56+
if (!index) throw new Error('Can not select root node.')
5657
const range = parentChains.map(chain => chain[index - 1].index).sort()
5758
const min = range[0] || 0
5859
const max = range[range.length - 1] || 0
5960
const parent = parentChains[0][index - 1].node
6061
if (parent.root) throw new Error('Please select nodes in the same main topic.')
6162

62-
// const start = parent.children![min].id
63-
// const end = parent.children![max].id
6463
return {
6564
parent: parent.id,
6665
start: min,
@@ -100,12 +99,24 @@ const createText = function (string: string, x: number, y: number, anchor: 'star
10099

101100
const getWrapper = (id: string) => findEle(id).parentElement.parentElement
102101

102+
const getDirection = function ({ parent, start }: Summary) {
103+
const parentEl = findEle(parent)
104+
const parentObj = parentEl.nodeObj
105+
let side: 'lhs' | 'rls'
106+
if (parentObj.root === true) {
107+
side = findEle(parentObj.children![start].id).closest('me-main')?.className as 'lhs' | 'rls'
108+
} else {
109+
side = parentEl.closest('me-main')?.className as 'lhs' | 'rls'
110+
}
111+
return side
112+
}
113+
103114
const drawSummary = function (mei: MindElixirInstance, summary: Summary) {
104115
const { id, text: summaryText, parent, start, end } = summary
105116
const container = mei.nodes
106117
const parentEl = findEle(parent)
107-
const side = parentEl.closest('me-main')?.className as 'lhs' | 'rls'
108118
const parentObj = parentEl.nodeObj
119+
const side = getDirection(summary)
109120
let left = Infinity
110121
let right = 0
111122
let startTop = 0
@@ -200,10 +211,6 @@ export const renderSummary = function (this: MindElixirInstance) {
200211
this.nodes.insertAdjacentElement('beforeend', this.summarySvg)
201212
}
202213

203-
const getDirection = function (id: string) {
204-
return findEle(id).closest('me-main')?.className as 'lhs' | 'rls'
205-
}
206-
207214
export const editSummary = function (this: MindElixirInstance, el: SummarySvgGroup) {
208215
console.time('editSummary')
209216
if (!el) return
@@ -218,7 +225,7 @@ export const editSummary = function (this: MindElixirInstance, el: SummarySvgGro
218225
const l = textEl.getAttribute('x') + 'px'
219226
const t = textEl.getAttribute('y') + 'px'
220227
div.style.cssText = `min-width:${100 - 8}px;position:absolute;left:${l};top:${t};`
221-
if (getDirection(el.summaryObj.parent) === 'lhs') div.style.cssText += 'transform: translate(-100%, -100%);'
228+
if (getDirection(el.summaryObj) === 'lhs') div.style.cssText += 'transform: translate(-100%, -100%);'
222229
else div.style.cssText += 'transform: translate(0, -100%);'
223230
div.focus()
224231

0 commit comments

Comments
 (0)