From 6ffa4570d482eaff6ed524785b732218d7c2a7d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A1=97=E8=A7=92=E5=B0=8F=E6=9E=97?= <1013335014@qq.com> Date: Tue, 25 Jun 2024 09:45:59 +0800 Subject: [PATCH] =?UTF-8?q?Feat=EF=BC=9Ahide=5Ftext=5Fedit=E4=BA=8B?= =?UTF-8?q?=E4=BB=B6=E5=A2=9E=E5=8A=A0=E8=A2=AB=E7=BC=96=E8=BE=91=E8=8A=82?= =?UTF-8?q?=E7=82=B9=E7=9A=84=E5=9B=9E=E8=B0=83=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- simple-mind-map/src/core/render/TextEdit.js | 5 +++-- simple-mind-map/src/plugins/RichText.js | 2 +- web/src/pages/Doc/en/constructor/index.md | 2 +- web/src/pages/Doc/en/constructor/index.vue | 4 ++-- web/src/pages/Doc/zh/constructor/index.md | 2 +- web/src/pages/Doc/zh/constructor/index.vue | 4 ++-- 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/simple-mind-map/src/core/render/TextEdit.js b/simple-mind-map/src/core/render/TextEdit.js index 1e7377ee..e8a9ee79 100644 --- a/simple-mind-map/src/core/render/TextEdit.js +++ b/simple-mind-map/src/core/render/TextEdit.js @@ -286,7 +286,6 @@ export default class TextEdit { // 隐藏文本编辑框 hideEditTextBox() { - this.currentNode = null if (this.mindMap.richText) { return this.mindMap.richText.hideEditText() } @@ -305,8 +304,10 @@ export default class TextEdit { this.mindMap.emit( 'hide_text_edit', this.textEditNode, - this.renderer.activeNodeList + this.renderer.activeNodeList, + this.currentNode ) + this.currentNode = null this.textEditNode.style.display = 'none' this.textEditNode.innerHTML = '' this.textEditNode.style.fontFamily = 'inherit' diff --git a/simple-mind-map/src/plugins/RichText.js b/simple-mind-map/src/plugins/RichText.js index d3a5fcc3..f172557e 100644 --- a/simple-mind-map/src/plugins/RichText.js +++ b/simple-mind-map/src/plugins/RichText.js @@ -344,7 +344,7 @@ class RichText { // } this.mindMap.render() }) - this.mindMap.emit('hide_text_edit', this.textEditNode, list) + this.mindMap.emit('hide_text_edit', this.textEditNode, list, this.node) this.textEditNode.style.display = 'none' this.showTextEdit = false this.mindMap.emit('rich_text_selection_change', false) diff --git a/web/src/pages/Doc/en/constructor/index.md b/web/src/pages/Doc/en/constructor/index.md index 3398c122..68c86666 100644 --- a/web/src/pages/Doc/en/constructor/index.md +++ b/web/src/pages/Doc/en/constructor/index.md @@ -551,7 +551,7 @@ Listen to an event. Event list: | node_active | Node activation event | this (node instance), activeNodeList (current list of active nodes) | | expand_btn_click | Node expand or collapse event | this (node instance) | | before_show_text_edit | Event before node text edit box opens | | -| hide_text_edit | Node text edit box close event | textEditNode (text edit box DOM node), activeNodeList (current list of active nodes) | +| hide_text_edit | Node text edit box close event【The end of text editing for the associated line will also trigger this event, and there are no callback parameters at this time, so defensive programming is necessary】 | textEditNode (text edit box DOM node), activeNodeList (current list of active nodes) 、node(v0.10.2+, Node instance for current text editing) | | scale | Canvas zoom event | scale (zoom ratio) | | translate(v0.9.10+) | Canvas movement event | x(translate x)、y(translate y) | | node_img_dblclick(v0.2.15+) | Node image double-click event | this (node instance), e (event object) | diff --git a/web/src/pages/Doc/en/constructor/index.vue b/web/src/pages/Doc/en/constructor/index.vue index 5b090b64..49924aab 100644 --- a/web/src/pages/Doc/en/constructor/index.vue +++ b/web/src/pages/Doc/en/constructor/index.vue @@ -1438,8 +1438,8 @@ poor performance and should be used sparingly.

hide_text_edit -Node text edit box close event -textEditNode (text edit box DOM node), activeNodeList (current list of active nodes) +Node text edit box close event【The end of text editing for the associated line will also trigger this event, and there are no callback parameters at this time, so defensive programming is necessary】 +textEditNode (text edit box DOM node), activeNodeList (current list of active nodes) 、node(v0.10.2+, Node instance for current text editing) scale diff --git a/web/src/pages/Doc/zh/constructor/index.md b/web/src/pages/Doc/zh/constructor/index.md index 6b24337a..a28f37d8 100644 --- a/web/src/pages/Doc/zh/constructor/index.md +++ b/web/src/pages/Doc/zh/constructor/index.md @@ -550,7 +550,7 @@ mindMap.setTheme('主题名称') | node_active | 节点激活事件 | this(节点实例)、activeNodeList(当前激活的所有节点列表) | | expand_btn_click | 节点展开或收缩事件 | this(节点实例) | | before_show_text_edit | 节点文本编辑框即将打开事件 | | -| hide_text_edit | 节点文本编辑框关闭事件 | textEditNode(文本编辑框DOM节点)、activeNodeList(当前激活的所有节点列表) | +| hide_text_edit | 节点文本编辑框关闭事件【关联线的文本编辑结束也会触发该事件,此时没有回调参数,所以需要做好防御性编程】 | textEditNode(文本编辑框DOM节点)、activeNodeList(当前激活的所有节点列表)、node(v0.10.2+,当前文本编辑的节点实例) | | scale | 画布放大缩小事件 | scale(缩放比例) | | translate(v0.9.10+) | 画布移动事件 | x(水平位移)、y(垂直位移) | | node_img_dblclick(v0.2.15+) | 节点内图片的双击事件 | this(节点实例)、e(事件对象) | diff --git a/web/src/pages/Doc/zh/constructor/index.vue b/web/src/pages/Doc/zh/constructor/index.vue index fbb410cc..e1fa0132 100644 --- a/web/src/pages/Doc/zh/constructor/index.vue +++ b/web/src/pages/Doc/zh/constructor/index.vue @@ -1307,8 +1307,8 @@ mindMap.setTheme('主题名称') hide_text_edit -节点文本编辑框关闭事件 -textEditNode(文本编辑框DOM节点)、activeNodeList(当前激活的所有节点列表) +节点文本编辑框关闭事件【关联线的文本编辑结束也会触发该事件,此时没有回调参数,所以需要做好防御性编程】 +textEditNode(文本编辑框DOM节点)、activeNodeList(当前激活的所有节点列表)、node(v0.10.2+,当前文本编辑的节点实例) scale