From 53c4d3945a2e34380b2f65ec0165c76f28db1712 Mon Sep 17 00:00:00 2001 From: wanglin2 <1013335014@qq.com> Date: Thu, 15 Jul 2021 09:46:27 +0800 Subject: [PATCH] =?UTF-8?q?'=E4=BC=98=E5=8C=96'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- simple-mind-map/example/exampleData.js | 71 ++++++++++++++++++- simple-mind-map/src/Node.js | 3 +- simple-mind-map/src/View.js | 3 + .../src/layouts/OrganizationStructure.js | 2 +- 4 files changed, 75 insertions(+), 4 deletions(-) diff --git a/simple-mind-map/example/exampleData.js b/simple-mind-map/example/exampleData.js index e0e4c742..693e0630 100644 --- a/simple-mind-map/example/exampleData.js +++ b/simple-mind-map/example/exampleData.js @@ -783,18 +783,85 @@ const data3 = { } } +const data4 = { + "root": { + "data": { + "text": "根节点" + }, + "children": [ + { + "data": { + "text": "二级节点1" + }, + "children": [ + { + "data": { + "text": "子节点1-1" + }, + "children": [ + { + "data": { + "text": "子节点1-1-1" + }, + "children": [] + }, + { + "data": { + "text": "子节点1-1-2" + }, + "children": [] + } + ] + }, + { + "data": { + "text": "子节点1-2" + }, + "children": [ + { + "data": { + "text": "子节点1-2-1" + }, + "children": [] + }, + { + "data": { + "text": "子节点1-2-2" + }, + "children": [] + } + ] + }, + { + "data": { + "text": "子节点1-3" + }, + "children": [] + } + ] + }, + { + "data": { + "text": "二级节点2" + } + } + ] + } +} + export default { // ...data1, ...data2, // ...data3, + // ...data4, "theme": { "template": "default", "config": { // 自定义配置... } }, - "layout": "logicalStructure", + // "layout": "logicalStructure", // "layout": "mindMap", // "layout": "catalogOrganization" - // "layout": "organizationStructure" + "layout": "organizationStructure" } \ No newline at end of file diff --git a/simple-mind-map/src/Node.js b/simple-mind-map/src/Node.js index 6ca5f0ee..2cd1f117 100644 --- a/simple-mind-map/src/Node.js +++ b/simple-mind-map/src/Node.js @@ -551,7 +551,8 @@ class Node { this.active(e) }) // 双击事件 - this.group.on('dblclick', () => { + this.group.on('dblclick', (e) => { + e.stopPropagation() this.mindMap.emit('node_dblclick', this) }) // 右键菜单事件 diff --git a/simple-mind-map/src/View.js b/simple-mind-map/src/View.js index 4ea4764a..75660ff6 100644 --- a/simple-mind-map/src/View.js +++ b/simple-mind-map/src/View.js @@ -39,6 +39,9 @@ class View { this.mindMap.keyCommand.addShortcut('Control+Enter', () => { this.reset() }) + this.mindMap.svg.on('dblclick', () => { + this.reset() + }) // 拖动视图 this.mindMap.event.on('mousedown', () => { this.sx = this.x diff --git a/simple-mind-map/src/layouts/OrganizationStructure.js b/simple-mind-map/src/layouts/OrganizationStructure.js index e776344d..02cd7e0a 100644 --- a/simple-mind-map/src/layouts/OrganizationStructure.js +++ b/simple-mind-map/src/layouts/OrganizationStructure.js @@ -165,7 +165,7 @@ class OrganizationStructure extends Base { let maxx = 0 let len = node.children.length node.children.forEach((item, index) => { - let x2 = item.left +item.width / 2 + let x2 = item.left + item.width / 2 let y2 = item.top if (index === 0) { minx = x2