From e676bff45310eaa9b076d798d93aa9c32990fea8 Mon Sep 17 00:00:00 2001 From: wanglin2 <1013335014@qq.com> Date: Tue, 18 Apr 2023 16:40:25 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E4=BC=98=E5=8C=96=EF=BC=9A=E5=BD=93?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E8=8A=82=E7=82=B9=E6=96=87=E6=9C=AC=E6=97=B6?= =?UTF-8?q?=E8=8A=82=E7=82=B9=E5=9C=A8=E7=94=BB=E5=B8=83=E5=A4=96=E6=97=B6?= =?UTF-8?q?=E7=A7=BB=E5=85=A5=E7=94=BB=E5=B8=83=E5=86=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- simple-mind-map/src/TextEdit.js | 4 +++- simple-mind-map/src/View.js | 7 +++++++ simple-mind-map/src/utils/index.js | 30 ++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/simple-mind-map/src/TextEdit.js b/simple-mind-map/src/TextEdit.js index f2f9330b..b371f658 100644 --- a/simple-mind-map/src/TextEdit.js +++ b/simple-mind-map/src/TextEdit.js @@ -1,4 +1,4 @@ -import { getStrWithBrFromHtml } from './utils' +import { getStrWithBrFromHtml, checkNodeOuter } from './utils' // 节点文字编辑类 export default class TextEdit { @@ -60,6 +60,8 @@ export default class TextEdit { // 显示文本编辑框 show(node) { + let { offsetLeft, offsetTop } = checkNodeOuter(this.mindMap, node) + this.mindMap.view.translateXY(offsetLeft, offsetTop) let rect = node._textData.node.node.getBoundingClientRect() if (this.mindMap.richText) { this.mindMap.richText.showEditText(node, rect) diff --git a/simple-mind-map/src/View.js b/simple-mind-map/src/View.js index 16f160bc..2898a047 100644 --- a/simple-mind-map/src/View.js +++ b/simple-mind-map/src/View.js @@ -124,6 +124,13 @@ class View { } } + // 平移x,y方向 + translateXY(x, y) { + this.x += x + this.y += y + this.transform() + } + // 平移x方向 translateX(step) { this.x += step diff --git a/simple-mind-map/src/utils/index.js b/simple-mind-map/src/utils/index.js index 3dade497..476cb974 100644 --- a/simple-mind-map/src/utils/index.js +++ b/simple-mind-map/src/utils/index.js @@ -302,4 +302,34 @@ export const nextTick = function (fn, ctx) { pending = true timerFunc(handle, 0) } +} + +// 检查节点是否超出画布 +export const checkNodeOuter = (mindMap, node) => { + let elRect = mindMap.elRect + let { scaleX, scaleY, translateX, translateY } = mindMap.draw.transform() + let { left, top, width, height } = node + let right = (left + width) * scaleX + translateX + let bottom = (top + height) * scaleY + translateY + left = left * scaleX + translateX + top = top * scaleY + translateY + let offsetLeft = 0 + let offsetTop = 0 + if (left < 0) { + offsetLeft = -left + } + if (right > elRect.width) { + offsetLeft = -(right - elRect.width) + } + if (top < 0) { + offsetTop = -top + } + if (bottom > elRect.height) { + offsetTop = -(bottom - elRect.height) + } + return { + isOuter: offsetLeft !== 0 || offsetTop !== 0, + offsetLeft, + offsetTop + } } \ No newline at end of file From f2521f663e5ce0ac9886a92fa5d4d8dfac43621c Mon Sep 17 00:00:00 2001 From: wanglin2 <1013335014@qq.com> Date: Tue, 18 Apr 2023 16:59:12 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E4=BC=98=E5=8C=96=EF=BC=9A=E5=88=87?= =?UTF-8?q?=E6=8D=A2=E7=BB=93=E6=9E=84=E6=97=B6=E9=87=8D=E7=BD=AE=E7=94=BB?= =?UTF-8?q?=E5=B8=83=E7=BC=A9=E6=94=BE=EF=BC=8C=E4=BB=A5=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E5=BD=93=E5=AD=98=E5=9C=A8=E7=BC=A9=E6=94=BE=E6=97=B6=E5=88=87?= =?UTF-8?q?=E6=8D=A2=E7=BB=93=E6=9E=84=E5=90=8E=E7=AC=AC=E4=B8=80=E6=AC=A1?= =?UTF-8?q?=E6=8B=96=E5=8A=A8=E4=BC=9A=E7=AA=81=E5=8F=98=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- simple-mind-map/index.js | 1 + simple-mind-map/src/View.js | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/simple-mind-map/index.js b/simple-mind-map/index.js index d3cdbe74..107ea996 100644 --- a/simple-mind-map/index.js +++ b/simple-mind-map/index.js @@ -281,6 +281,7 @@ class MindMap { layout = CONSTANTS.LAYOUT.LOGICAL_STRUCTURE } this.opt.layout = layout + this.view.reset() this.renderer.setLayout() this.render() } diff --git a/simple-mind-map/src/View.js b/simple-mind-map/src/View.js index 2898a047..ffe2599f 100644 --- a/simple-mind-map/src/View.js +++ b/simple-mind-map/src/View.js @@ -167,10 +167,14 @@ class View { // 恢复 reset() { + let scaleChange = this.scale !== 1 this.scale = 1 this.x = 0 this.y = 0 this.transform() + if (scaleChange) { + this.mindMap.emit('scale', this.scale) + } } // 缩小 From 8bf876d446e22bd42c3df5020643a275ab540172 Mon Sep 17 00:00:00 2001 From: wanglin2 <1013335014@qq.com> Date: Tue, 18 Apr 2023 17:11:40 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E4=BC=98=E5=8C=96=EF=BC=9A=E5=A4=9A?= =?UTF-8?q?=E9=80=89=E8=8A=82=E7=82=B9=E6=97=B6=E6=94=B9=E4=B8=BA=E8=8A=82?= =?UTF-8?q?=E7=82=B9=E5=8F=AA=E8=A6=81=E5=92=8C=E9=80=89=E5=8C=BA=E9=87=8D?= =?UTF-8?q?=E5=8F=A0=E5=B0=B1=E7=AE=97=E8=A2=AB=E9=80=89=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- simple-mind-map/src/Select.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/simple-mind-map/src/Select.js b/simple-mind-map/src/Select.js index 98a53c0a..a8c847c9 100644 --- a/simple-mind-map/src/Select.js +++ b/simple-mind-map/src/Select.js @@ -17,7 +17,7 @@ class Select { // 绑定事件 bindEvent() { - this.checkInNodes = throttle(this.checkInNodes, 500, this) + this.checkInNodes = throttle(this.checkInNodes, 300, this) this.mindMap.on('mousedown', e => { if (this.mindMap.opt.readonly) { return @@ -146,22 +146,26 @@ class Select { let bottom = (top + height) * scaleY + translateY left = left * scaleX + translateX top = top * scaleY + translateY - if (left >= minx && right <= maxx && top >= miny && bottom <= maxy) { - this.mindMap.batchExecution.push('activeNode' + node.uid, () => { + if ((left >= minx && left <= maxx || + right >= minx && right <= maxx) && + (top >= miny && top <= maxy || + bottom >= miny && bottom <= maxy) + ) { + // this.mindMap.batchExecution.push('activeNode' + node.uid, () => { if (node.nodeData.data.isActive) { return } this.mindMap.renderer.setNodeActive(node, true) this.mindMap.renderer.addActiveNode(node) - }) + // }) } else if (node.nodeData.data.isActive) { - this.mindMap.batchExecution.push('activeNode' + node.uid, () => { + // this.mindMap.batchExecution.push('activeNode' + node.uid, () => { if (!node.nodeData.data.isActive) { return } this.mindMap.renderer.setNodeActive(node, false) this.mindMap.renderer.removeActiveNode(node) - }) + // }) } }) } From e804a8f2f73745c96f3ceab3932f33d526efeb8d Mon Sep 17 00:00:00 2001 From: wanglin2 <1013335014@qq.com> Date: Tue, 18 Apr 2023 17:19:43 +0800 Subject: [PATCH 4/5] =?UTF-8?q?Demo=EF=BC=9A=E4=BF=AE=E5=A4=8D=E5=AF=8C?= =?UTF-8?q?=E6=96=87=E6=9C=AC=E7=BC=96=E8=BE=91=E6=97=B6=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E6=A0=8F=E5=B1=82=E7=BA=A7=E6=AF=94=E8=8A=82=E7=82=B9=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E6=A1=86=E4=BD=8E=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/pages/Edit/components/Edit.vue | 2 ++ 1 file changed, 2 insertions(+) diff --git a/web/src/pages/Edit/components/Edit.vue b/web/src/pages/Edit/components/Edit.vue index 5434aa04..bc7efae9 100644 --- a/web/src/pages/Edit/components/Edit.vue +++ b/web/src/pages/Edit/components/Edit.vue @@ -277,6 +277,8 @@ export default { theme: theme.template, themeConfig: theme.config, viewData: view, + nodeTextEditZIndex: 1000, + nodeNoteTooltipZIndex: 1000, customNoteContentShow: { show: (content, left, top) => { this.$bus.$emit('showNoteContent', content, left, top) From bd805836cd760ff446cf5fb8872bf685bc09a209 Mon Sep 17 00:00:00 2001 From: wanglin2 <1013335014@qq.com> Date: Tue, 18 Apr 2023 17:37:10 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E6=89=93=E5=8C=850.5.5-fix.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 2 +- simple-mind-map/package.json | 2 +- web/src/pages/Doc/en/changelog/index.md | 6 ++++++ web/src/pages/Doc/en/changelog/index.vue | 3 +++ web/src/pages/Doc/zh/changelog/index.md | 6 ++++++ web/src/pages/Doc/zh/changelog/index.vue | 3 +++ 6 files changed, 20 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index 32e46b1b..af9a7dd7 100644 --- a/index.html +++ b/index.html @@ -1 +1 @@ -一个简单的web思维导图实现
\ No newline at end of file +一个简单的web思维导图实现
\ No newline at end of file diff --git a/simple-mind-map/package.json b/simple-mind-map/package.json index 783d8696..311495d0 100644 --- a/simple-mind-map/package.json +++ b/simple-mind-map/package.json @@ -1,6 +1,6 @@ { "name": "simple-mind-map", - "version": "0.5.5", + "version": "0.5.5-fix.1", "description": "一个简单的web在线思维导图", "authors": [ { diff --git a/web/src/pages/Doc/en/changelog/index.md b/web/src/pages/Doc/en/changelog/index.md index 50b58823..f4f6088a 100644 --- a/web/src/pages/Doc/en/changelog/index.md +++ b/web/src/pages/Doc/en/changelog/index.md @@ -1,5 +1,11 @@ # Changelog +## 0.5.5-fix.1 + +Fix: 1.Fix the issue where the edit box is also outside the canvas when editing nodes outside the canvas. 2.After modifying the structure, reset the transformation to prevent the problem of sudden position changes during the first drag after switching the structure during scaling. + +optimization: 1.When multiple nodes are selected, as long as there is a cross between the node and the selection area, it is considered selected. + ## 0.5.5 New: 1.Supports configuring the padding when exporting to PNG, SVG, or PDF. 2.Support the configuration of z-index for node text editing boxes and node comment floating layer elements. 3.Support clicking on areas outside the canvas to end node editing status. diff --git a/web/src/pages/Doc/en/changelog/index.vue b/web/src/pages/Doc/en/changelog/index.vue index 0ee79ab6..c7e18164 100644 --- a/web/src/pages/Doc/en/changelog/index.vue +++ b/web/src/pages/Doc/en/changelog/index.vue @@ -1,6 +1,9 @@