From 1795773af943b4ed3cde36e0cdf419c976f01125 Mon Sep 17 00:00:00 2001 From: wanglin2 <1013335014@qq.com> Date: Tue, 28 Mar 2023 20:01:52 +0800 Subject: [PATCH] =?UTF-8?q?Break=20change=EF=BC=9A=E8=8A=82=E7=82=B9?= =?UTF-8?q?=E6=BF=80=E6=B4=BB=E6=A0=B7=E5=BC=8F=E5=8F=AA=E8=83=BD=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E5=BD=A2=E7=8A=B6=E7=9B=B8=E5=85=B3=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- simple-mind-map/package.json | 2 +- simple-mind-map/src/Node.js | 14 +++++++++----- simple-mind-map/src/Render.js | 4 ++-- simple-mind-map/src/themes/default.js | 6 +----- web/src/pages/Doc/en/changelog/index.md | 14 ++++++++++++++ web/src/pages/Doc/en/changelog/index.vue | 10 ++++++++++ web/src/pages/Doc/en/node/index.md | 6 ++++++ web/src/pages/Doc/en/node/index.vue | 5 +++++ web/src/pages/Doc/zh/changelog/index.md | 14 ++++++++++++++ web/src/pages/Doc/zh/changelog/index.vue | 10 ++++++++++ web/src/pages/Doc/zh/node/index.md | 6 ++++++ web/src/pages/Doc/zh/node/index.vue | 5 +++++ 12 files changed, 83 insertions(+), 13 deletions(-) diff --git a/simple-mind-map/package.json b/simple-mind-map/package.json index ccc78cac..2b1ee325 100644 --- a/simple-mind-map/package.json +++ b/simple-mind-map/package.json @@ -1,6 +1,6 @@ { "name": "simple-mind-map", - "version": "0.4.7", + "version": "0.5.0", "description": "一个简单的web在线思维导图", "authors": [ { diff --git a/simple-mind-map/src/Node.js b/simple-mind-map/src/Node.js index 52a4c8d5..d411e056 100644 --- a/simple-mind-map/src/Node.js +++ b/simple-mind-map/src/Node.js @@ -55,6 +55,7 @@ class Node { this.children = opt.children || [] // 节点内容的容器 this.group = null + this.shapeNode = null// 节点形状节点 // 节点内容对象 this._imgData = null this._iconData = null @@ -426,7 +427,6 @@ class Node { } // 创建超链接节点 - createHyperlinkNode() { let { hyperlink, hyperlinkTitle } = this.nodeData.data if (!hyperlink) { @@ -561,10 +561,8 @@ class Node { this.draw.add(this.group) this.update(true) // 节点形状 - const shape = this.getShape() - this.style[shape === 'rectangle' ? 'rect' : 'shape']( - this.shapeInstance.createShape() - ) + this.shapeNode = this.shapeInstance.createShape() + this.updateNodeShape() // 图片节点 let imgHeight = 0 if (this._imgData) { @@ -751,6 +749,12 @@ class Node { } } + // 更新节点形状样式 + updateNodeShape() { + const shape = this.getShape() + this.style[shape === 'rectangle' ? 'rect' : 'shape'](this.shapeNode) + } + // 递归渲染 render(callback = () => {}) { // 节点 diff --git a/simple-mind-map/src/Render.js b/simple-mind-map/src/Render.js index 85399d78..64df860a 100644 --- a/simple-mind-map/src/Render.js +++ b/simple-mind-map/src/Render.js @@ -305,7 +305,7 @@ class Render { node.nodeData.data.isActive = true this.addActiveNode(node) setTimeout(() => { - node.renderNode() + node.updateNodeShape() }, 0) } }, @@ -676,7 +676,7 @@ class Render { this.setNodeData(node, { isActive: active }) - node.renderNode() + node.updateNodeShape() } // 设置节点是否展开 diff --git a/simple-mind-map/src/themes/default.js b/simple-mind-map/src/themes/default.js index 3436b7fa..0f2ad5ad 100644 --- a/simple-mind-map/src/themes/default.js +++ b/simple-mind-map/src/themes/default.js @@ -142,14 +142,10 @@ export default { // 简单来说,会改变节点大小的都不支持在激活时设置,为了性能考虑,节点切换激活态时不会重新计算节点大小 export const supportActiveStyle = [ 'fillColor', - 'color', - 'fontWeight', - 'fontStyle', 'borderColor', 'borderWidth', 'borderDasharray', - 'borderRadius', - 'textDecoration' + 'borderRadius' ] export const lineStyleProps = ['lineColor', 'lineDasharray', 'lineWidth'] diff --git a/web/src/pages/Doc/en/changelog/index.md b/web/src/pages/Doc/en/changelog/index.md index 9a6b402e..dbd7989e 100644 --- a/web/src/pages/Doc/en/changelog/index.md +++ b/web/src/pages/Doc/en/changelog/index.md @@ -1,5 +1,19 @@ # Changelog +## 0.5.0 + +modify: Starting from version 0.5.0, considering performance issues, the node activation state can only modify shape related styles: + +```js +[ + 'fillColor', + 'borderColor', + 'borderWidth', + 'borderDasharray', + 'borderRadius' +] +``` + ## 0.4.7 optimization: 1.During rich text editing, when initially focusing, all are no longer selected by default; 2.When editing rich text, use the node fill color as the background color to avoid being invisible when the node color is white. 3.Node activation state switching no longer triggers history. 4.Triggering history multiple times in a short time will only add the last data. 5.Optimize the addition of historical records. When there is a rollback, delete the historical data after the current pointer when adding a new record again. diff --git a/web/src/pages/Doc/en/changelog/index.vue b/web/src/pages/Doc/en/changelog/index.vue index 46210955..314bf9c8 100644 --- a/web/src/pages/Doc/en/changelog/index.vue +++ b/web/src/pages/Doc/en/changelog/index.vue @@ -1,6 +1,16 @@