This commit is contained in:
wanglin2 2021-07-15 09:46:27 +08:00
parent acad210d57
commit 53c4d3945a
4 changed files with 75 additions and 4 deletions

View File

@ -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 { export default {
// ...data1, // ...data1,
...data2, ...data2,
// ...data3, // ...data3,
// ...data4,
"theme": { "theme": {
"template": "default", "template": "default",
"config": { "config": {
// 自定义配置... // 自定义配置...
} }
}, },
"layout": "logicalStructure", // "layout": "logicalStructure",
// "layout": "mindMap", // "layout": "mindMap",
// "layout": "catalogOrganization" // "layout": "catalogOrganization"
// "layout": "organizationStructure" "layout": "organizationStructure"
} }

View File

@ -551,7 +551,8 @@ class Node {
this.active(e) this.active(e)
}) })
// 双击事件 // 双击事件
this.group.on('dblclick', () => { this.group.on('dblclick', (e) => {
e.stopPropagation()
this.mindMap.emit('node_dblclick', this) this.mindMap.emit('node_dblclick', this)
}) })
// 右键菜单事件 // 右键菜单事件

View File

@ -39,6 +39,9 @@ class View {
this.mindMap.keyCommand.addShortcut('Control+Enter', () => { this.mindMap.keyCommand.addShortcut('Control+Enter', () => {
this.reset() this.reset()
}) })
this.mindMap.svg.on('dblclick', () => {
this.reset()
})
// 拖动视图 // 拖动视图
this.mindMap.event.on('mousedown', () => { this.mindMap.event.on('mousedown', () => {
this.sx = this.x this.sx = this.x

View File

@ -165,7 +165,7 @@ class OrganizationStructure extends Base {
let maxx = 0 let maxx = 0
let len = node.children.length let len = node.children.length
node.children.forEach((item, index) => { node.children.forEach((item, index) => {
let x2 = item.left +item.width / 2 let x2 = item.left + item.width / 2
let y2 = item.top let y2 = item.top
if (index === 0) { if (index === 0) {
minx = x2 minx = x2