From 834bdf37c335dffa0cad8e5478b8da25e711d0d5 Mon Sep 17 00:00:00 2001 From: wanglin2 <1013335014@qq.com> Date: Fri, 9 Jun 2023 17:18:02 +0800 Subject: [PATCH] =?UTF-8?q?Feat=EF=BC=9A=E6=94=AF=E6=8C=81=E6=8E=A7?= =?UTF-8?q?=E5=88=B6=E8=8A=82=E7=82=B9=E6=98=AF=E5=90=A6=E5=85=81=E8=AE=B8?= =?UTF-8?q?=E7=BC=96=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- simple-mind-map/index.js | 4 +++- simple-mind-map/src/core/render/TextEdit.js | 11 ++++++++++- web/src/pages/Doc/en/changelog/index.md | 2 +- web/src/pages/Doc/en/changelog/index.vue | 2 +- web/src/pages/Doc/en/constructor/index.md | 1 + web/src/pages/Doc/en/constructor/index.vue | 7 +++++++ web/src/pages/Doc/zh/changelog/index.md | 2 +- web/src/pages/Doc/zh/changelog/index.vue | 2 +- web/src/pages/Doc/zh/constructor/index.md | 1 + web/src/pages/Doc/zh/constructor/index.vue | 7 +++++++ 10 files changed, 33 insertions(+), 6 deletions(-) diff --git a/simple-mind-map/index.js b/simple-mind-map/index.js index 74d017fa..0e7e0f10 100644 --- a/simple-mind-map/index.js +++ b/simple-mind-map/index.js @@ -128,7 +128,9 @@ const defaultOpt = { // 是否开启按住ctrl键多选节点功能 enableCtrlKeyNodeSelection: true, // 设置为左键多选节点,右键拖动画布 - useLeftKeySelectionRightKeyDrag: false + useLeftKeySelectionRightKeyDrag: false, + // 节点即将进入编辑前的回调方法,如果该方法返回true以外的值,那么将取消编辑,函数可以返回一个值,或一个Promise,回调参数为节点实例 + beforeTextEdit: null } // 思维导图 diff --git a/simple-mind-map/src/core/render/TextEdit.js b/simple-mind-map/src/core/render/TextEdit.js index 3ceda346..888ef7e3 100644 --- a/simple-mind-map/src/core/render/TextEdit.js +++ b/simple-mind-map/src/core/render/TextEdit.js @@ -65,7 +65,16 @@ export default class TextEdit { } // 显示文本编辑框 - show(node) { + async show(node) { + if (typeof this.mindMap.opt.beforeTextEdit === 'function') { + let isShow = false + try { + isShow = await this.mindMap.opt.beforeTextEdit(node) + } catch (error) { + isShow = false + } + if (!isShow) return + } this.currentNode = node let { offsetLeft, offsetTop } = checkNodeOuter(this.mindMap, node) this.mindMap.view.translateXY(offsetLeft, offsetTop) diff --git a/web/src/pages/Doc/en/changelog/index.md b/web/src/pages/Doc/en/changelog/index.md index 313f8de6..4dcfc5af 100644 --- a/web/src/pages/Doc/en/changelog/index.md +++ b/web/src/pages/Doc/en/changelog/index.md @@ -4,7 +4,7 @@ Breaking change: Adjusted the directory structure of the simple-mind-map source code, Main impact: 1. The introduction path of the plugin needs to be modified. The constant file path needs to be modified. -New: 1.Supports one click zoom to fit the canvas function. 2.Press and hold the Ctrl key to activate the multi selection function on demand through configuration. 3.Support setting to left click to select multiple nodes and right click to drag the canvas. +New: 1.Supports one click zoom to fit the canvas function. 2.Press and hold the Ctrl key to activate the multi selection function on demand through configuration. 3.Support setting to left click to select multiple nodes and right click to drag the canvas. 4. Support controlling whether nodes are allowed to be edited. Fix: 1.Fix the issue where holding down the Ctrl key to select multiple nodes does not trigger the click event for the node. diff --git a/web/src/pages/Doc/en/changelog/index.vue b/web/src/pages/Doc/en/changelog/index.vue index 00ac383c..5a4ffc3d 100644 --- a/web/src/pages/Doc/en/changelog/index.vue +++ b/web/src/pages/Doc/en/changelog/index.vue @@ -3,7 +3,7 @@
Breaking change: Adjusted the directory structure of the simple-mind-map source code, Main impact: 1. The introduction path of the plugin needs to be modified. The constant file path needs to be modified.
-New: 1.Supports one click zoom to fit the canvas function. 2.Press and hold the Ctrl key to activate the multi selection function on demand through configuration. 3.Support setting to left click to select multiple nodes and right click to drag the canvas.
+New: 1.Supports one click zoom to fit the canvas function. 2.Press and hold the Ctrl key to activate the multi selection function on demand through configuration. 3.Support setting to left click to select multiple nodes and right click to drag the canvas. 4. Support controlling whether nodes are allowed to be edited.
Fix: 1.Fix the issue where holding down the Ctrl key to select multiple nodes does not trigger the click event for the node.
New: Supports associative text editing.
diff --git a/web/src/pages/Doc/en/constructor/index.md b/web/src/pages/Doc/en/constructor/index.md index 26e0559f..f3de24fb 100644 --- a/web/src/pages/Doc/en/constructor/index.md +++ b/web/src/pages/Doc/en/constructor/index.md @@ -66,6 +66,7 @@ const mindMap = new MindMap({ | fitPadding(v0.6.0+) | Number | 50 | The padding of mind mapping when adapting to canvas size, Unit: px | | | enableCtrlKeyNodeSelection(v0.6.0+) | Boolean | true | Whether to enable the function of holding down the Ctrl key to select multiple nodes | | | useLeftKeySelectionRightKeyDrag(v0.6.0+) | Boolean | false | Setting to left click to select multiple nodes and right click to drag the canvas. | | +| beforeTextEdit(v0.6.0+) | Function/null | null | The callback method before the node is about to enter editing. If the method returns a value other than true, the editing will be canceled. The function can return a value or a promise, and the callback parameter is the node instance | | ### Watermark config diff --git a/web/src/pages/Doc/en/constructor/index.vue b/web/src/pages/Doc/en/constructor/index.vue index 2fb28681..6c17d426 100644 --- a/web/src/pages/Doc/en/constructor/index.vue +++ b/web/src/pages/Doc/en/constructor/index.vue @@ -322,6 +322,13 @@破坏性更新:调整了simple-mind-map源码的目录结构,主要影响:1.插件的引入路径需要修改。2.constant文件路径需要修改。
-新增:1.支持一键缩放至适应画布功能。 2.按住Ctrl键多选功能可通过配置按需开启。 3.支持设置为左键多选节点,右键拖动画布。
+新增:1.支持一键缩放至适应画布功能。 2.按住Ctrl键多选功能可通过配置按需开启。 3.支持设置为左键多选节点,右键拖动画布。 4.支持控制节点是否允许编辑。
修复:1.修复按住ctrl键多选节点时不会触发节点的click事件的问题。
新增:支持关联性文本编辑。
diff --git a/web/src/pages/Doc/zh/constructor/index.md b/web/src/pages/Doc/zh/constructor/index.md index 41761614..44095928 100644 --- a/web/src/pages/Doc/zh/constructor/index.md +++ b/web/src/pages/Doc/zh/constructor/index.md @@ -66,6 +66,7 @@ const mindMap = new MindMap({ | fitPadding(v0.6.0+) | Number | 50 | 思维导图适应画布大小时的内边距,单位:px | | | enableCtrlKeyNodeSelection(v0.6.0+) | Boolean | true | 是否开启按住ctrl键多选节点的功能 | | | useLeftKeySelectionRightKeyDrag(v0.6.0+) | Boolean | false | 设置为左键多选节点,右键拖动画布 | | +| beforeTextEdit(v0.6.0+) | Function/null | null | 节点即将进入编辑前的回调方法,如果该方法返回true以外的值,那么将取消编辑,函数可以返回一个值,或一个Promise,回调参数为节点实例 | | ### 水印配置 diff --git a/web/src/pages/Doc/zh/constructor/index.vue b/web/src/pages/Doc/zh/constructor/index.vue index e086dcb7..ced413ff 100644 --- a/web/src/pages/Doc/zh/constructor/index.vue +++ b/web/src/pages/Doc/zh/constructor/index.vue @@ -322,6 +322,13 @@