修复先给自身添加概要,再给下级添加概要会出现概要重叠的问题

This commit is contained in:
wanglin2 2023-11-20 17:05:00 +08:00
parent bc2a5b214f
commit 4db6bda193
2 changed files with 21 additions and 2 deletions

View File

@ -1400,10 +1400,12 @@ class Render {
if (this.activeNodeList.length <= 0) {
return
}
let hasAncestorsExistGeneralization = false
this.activeNodeList.forEach(node => {
if (node.getData('generalization') || node.isRoot) {
return
}
hasAncestorsExistGeneralization = node.ancestorHasGeneralization()
this.mindMap.execCommand('SET_NODE_DATA', node, {
generalization: data || {
text: this.mindMap.opt.defaultGeneralizationText
@ -1414,7 +1416,12 @@ class Render {
expand: true
})
})
this.mindMap.render()
this.mindMap.render(() => {
// 修复祖先节点存在概要时位置未更新的问题
if (hasAncestorsExistGeneralization) {
this.mindMap.render()
}
})
}
// 删除节点概要

View File

@ -849,7 +849,7 @@ class Node {
return this.customLeft !== undefined && this.customTop !== undefined
}
// 检查节点是否存在自定义位置的祖先节点
// 检查节点是否存在自定义位置的祖先节点,包含自身
ancestorHasCustomPosition() {
let node = this
while (node) {
@ -861,6 +861,18 @@ class Node {
return false
}
// 检查是否存在概要的祖先节点
ancestorHasGeneralization() {
let node = this.parent
while (node) {
if (node.getData('generalization')) {
return true
}
node = node.parent
}
return false
}
// 添加子节点
addChildren(node) {
this.children.push(node)