From 13f3c2c20c7e7ee87fa9669a0c417700e6514701 Mon Sep 17 00:00:00 2001 From: warlee <824691958@qq.com> Date: Tue, 8 Aug 2023 17:21:05 +0800 Subject: [PATCH 1/4] =?UTF-8?q?-=20=E7=A7=BB=E5=8A=A8=E7=AB=AF=E6=89=8B?= =?UTF-8?q?=E5=8A=BF=E7=BC=A9=E6=94=BE=E4=BC=98=E5=8C=96:=20=E6=8C=89?= =?UTF-8?q?=E7=BA=BF=E6=80=A7=E5=85=B3=E7=B3=BB=E8=BF=9B=E8=A1=8C=E7=BC=A9?= =?UTF-8?q?=E6=94=BE,=E5=8F=8C=E6=8C=87=E4=BD=8D=E7=A7=BB=E5=8F=AF?= =?UTF-8?q?=E4=BB=A5=E8=B0=83=E6=95=B4=E7=94=BB=E5=B8=83=E4=BD=8D=E7=BD=AE?= =?UTF-8?q?;=20-=20=E6=8B=96=E5=8A=A8=E7=94=BB=E5=B8=83=E4=BC=98=E5=8C=96:?= =?UTF-8?q?=20=E5=8F=AA=E8=AF=BB=E6=A8=A1=E5=BC=8F=E6=8B=96=E6=8B=BD?= =?UTF-8?q?=E7=94=BB=E5=B8=83=E6=97=B6=E7=82=B9=E5=87=BB=E5=9C=A8=E5=AD=90?= =?UTF-8?q?=E5=85=83=E7=B4=A0=E4=B8=8A=E6=97=B6=E6=97=A0=E6=B3=95=E6=8B=96?= =?UTF-8?q?=E5=8A=A8=E9=97=AE=E9=A2=98=E5=A4=84=E7=90=86(=E5=8F=AA?= =?UTF-8?q?=E8=AF=BB=E6=A8=A1=E5=BC=8F=E6=8B=96=E6=8B=BD,=E9=BC=A0?= =?UTF-8?q?=E6=A0=87=E4=B8=AD=E9=94=AE=E6=8B=96=E6=8B=BD,=E7=A7=BB?= =?UTF-8?q?=E5=8A=A8=E7=AB=AF=E6=8B=96=E6=8B=BD)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- simple-mind-map/src/core/render/node/Node.js | 4 ++-- simple-mind-map/src/plugins/RichText.js | 7 +++++- simple-mind-map/src/plugins/TouchEvent.js | 25 ++++++++++++++------ 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/simple-mind-map/src/core/render/node/Node.js b/simple-mind-map/src/core/render/node/Node.js index 9c0c8910..e3fb06b0 100644 --- a/simple-mind-map/src/core/render/node/Node.js +++ b/simple-mind-map/src/core/render/node/Node.js @@ -388,7 +388,7 @@ class Node { if (this.isRoot && e.which === 3 && !this.mindMap.opt.readonly) { e.stopPropagation() } - if (!this.isRoot && !this.mindMap.opt.readonly) { + if (!this.isRoot && e.which !== 2 && !this.mindMap.opt.readonly) { e.stopPropagation() } // 多选和取消多选 @@ -414,7 +414,7 @@ class Node { this.mindMap.emit('node_mousedown', this, e) }) this.group.on('mouseup', e => { - if (!this.isRoot && !this.mindMap.opt.readonly) { + if (!this.isRoot && e.which !== 2 && !this.mindMap.opt.readonly) { e.stopPropagation() } this.mindMap.emit('node_mouseup', this, e) diff --git a/simple-mind-map/src/plugins/RichText.js b/simple-mind-map/src/plugins/RichText.js index 1a640b2e..48140620 100644 --- a/simple-mind-map/src/plugins/RichText.js +++ b/simple-mind-map/src/plugins/RichText.js @@ -163,7 +163,7 @@ class RichText { let scaleX = rect.width / originWidth let scaleY = rect.height / originHeight // 内边距 - const paddingX = 6 + const paddingX = 14 const paddingY = 4 if (!this.textEditNode) { this.textEditNode = document.createElement('div') @@ -195,6 +195,11 @@ class RichText { this.mindMap.opt.textAutoWrapWidth + paddingX * 2 + 'px' this.textEditNode.style.transform = `scale(${scaleX}, ${scaleY})` this.textEditNode.style.transformOrigin = 'left top' + this.textEditNode.style.borderRadius = (node.style.merge('borderRadius') || 5) + 'px' + if(node.style.merge('shape') == 'roundedRectangle'){ + this.textEditNode.style.borderRadius = '50px'; + } + if (!node.nodeData.data.richText) { // 还不是富文本的情况 let text = node.nodeData.data.text.split(/\n/gim).join('
') diff --git a/simple-mind-map/src/plugins/TouchEvent.js b/simple-mind-map/src/plugins/TouchEvent.js index ea8681b4..1d297820 100644 --- a/simple-mind-map/src/plugins/TouchEvent.js +++ b/simple-mind-map/src/plugins/TouchEvent.js @@ -33,6 +33,7 @@ class TouchEvent { // 手指按下事件 onTouchstart(e) { this.touchesNum = e.touches.length + this.touchScaleViewBefore = false; if (this.touchesNum === 1) { let touch = e.touches[0] this.singleTouchstartEvent = touch @@ -57,14 +58,23 @@ class TouchEvent { let { x: touch2ClientX, y: touch2ClientY } = this.mindMap.toPos(touch2.clientX, touch2.clientY) let cx = (touch1ClientX + touch2ClientX) / 2 let cy = (touch1ClientY + touch2ClientY) / 2 - if (distance > this.doubleTouchmoveDistance) { - // 放大 - this.mindMap.view.enlarge(cx, cy, true) - } else { - // 缩小 - this.mindMap.view.narrow(cx, cy, true) + + // 手势缩放,基于最开始的位置进行缩放(基于前一个位置缩放不是线性关系); 缩放同时支持位置拖动 + var view = this.mindMap.view; + if(!this.touchScaleViewBefore){ + this.touchScaleViewBefore = {distance:distance,scale:view.scale,x:view.x,y:view.y,cx:cx,cy:cy}; + return; } - this.doubleTouchmoveDistance = distance + + var viewBefore = this.touchScaleViewBefore; + var scale = viewBefore.scale * (distance / viewBefore.distance); + if(Math.abs(distance - viewBefore.distance) <= 10){scale = viewBefore.scale;} + var ratio = (1 - scale / viewBefore.scale); + view.scale = scale < 0.1 ? 0.1 : scale; + view.x = viewBefore.x + (cx - viewBefore.x) * ratio + (cx - viewBefore.cx)*scale; + view.y = viewBefore.y + (cy - viewBefore.y) * ratio + (cy - viewBefore.cy)*scale; + view.transform(); + this.mindMap.emit('scale',scale); } } @@ -92,6 +102,7 @@ class TouchEvent { this.touchesNum = 0 this.singleTouchstartEvent = null this.doubleTouchmoveDistance = 0 + this.touchScaleViewBefore = null; } // 发送鼠标事件 From 2ce0d4cd11b36aeac68576e8ce7dced1cb763c5e Mon Sep 17 00:00:00 2001 From: warlee <824691958@qq.com> Date: Mon, 7 Aug 2023 21:59:10 +0800 Subject: [PATCH 2/4] no message --- .gitignore | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index cf78998b..f1c0e085 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ node_modules .DS_Store -dist_electron \ No newline at end of file +dist_electron +app.css +dist +index.html \ No newline at end of file From 099d4cd78eb678fab0f041b3523ce0ed98450cac Mon Sep 17 00:00:00 2001 From: warlee <824691958@qq.com> Date: Wed, 9 Aug 2023 18:56:14 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E7=94=BB=E5=B8=83=E8=83=8C=E6=99=AF?= =?UTF-8?q?=E5=9B=BE=E4=B8=BAnone=E6=97=B6=E5=A4=84=E7=90=86=E4=B8=BA?= =?UTF-8?q?=E7=A9=BA.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- simple-mind-map/src/core/render/node/Style.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/simple-mind-map/src/core/render/node/Style.js b/simple-mind-map/src/core/render/node/Style.js index 99e7def9..9cd452d2 100644 --- a/simple-mind-map/src/core/render/node/Style.js +++ b/simple-mind-map/src/core/render/node/Style.js @@ -17,7 +17,7 @@ class Style { // 设置新样式 let { backgroundColor, backgroundImage, backgroundRepeat, backgroundPosition, backgroundSize } = themeConfig el.style.backgroundColor = backgroundColor - if (backgroundImage) { + if (backgroundImage && backgroundImage !== 'none') { el.style.backgroundImage = `url(${backgroundImage})` el.style.backgroundRepeat = backgroundRepeat el.style.backgroundPosition = backgroundPosition From 765d0ee212d04bde8f9af1bcc68e03a7e729b943 Mon Sep 17 00:00:00 2001 From: warlee <824691958@qq.com> Date: Wed, 9 Aug 2023 18:58:52 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E8=BF=98=E5=8E=9F.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index f1c0e085..cf78998b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,3 @@ node_modules .DS_Store -dist_electron -app.css -dist -index.html \ No newline at end of file +dist_electron \ No newline at end of file