Fix:修复同时给存在上下级关系的节点添加概要时概要重叠的问题

This commit is contained in:
wanglin2 2023-11-21 10:32:19 +08:00
parent 41ca8f8e46
commit 6723250266
2 changed files with 25 additions and 5 deletions

View File

@ -24,7 +24,8 @@ import {
getNodeIndexInNodeList, getNodeIndexInNodeList,
setDataToClipboard, setDataToClipboard,
getDataFromClipboard, getDataFromClipboard,
htmlEscape htmlEscape,
checkHasSupSubRelation
} from '../../utils' } from '../../utils'
import { shapeList } from './node/Shape' import { shapeList } from './node/Shape'
import { lineStyleProps } from '../../themes/default' import { lineStyleProps } from '../../themes/default'
@ -888,9 +889,11 @@ class Render {
) )
} else { } else {
text = htmlEscape(text) text = htmlEscape(text)
const textArr = text.split(new RegExp('\r?\n|(?<!\n)\r', 'g')).filter(item => { const textArr = text
return !!item .split(new RegExp('\r?\n|(?<!\n)\r', 'g'))
}) .filter(item => {
return !!item
})
// 判断是否需要根据换行自动分割节点 // 判断是否需要根据换行自动分割节点
if (textArr.length > 1 && handleIsSplitByWrapOnPasteCreateNewNode) { if (textArr.length > 1 && handleIsSplitByWrapOnPasteCreateNewNode) {
handleIsSplitByWrapOnPasteCreateNewNode() handleIsSplitByWrapOnPasteCreateNewNode()
@ -1416,9 +1419,11 @@ class Render {
expand: true expand: true
}) })
}) })
const hasSupSubRelation = checkHasSupSubRelation(this.activeNodeList)
this.mindMap.render(() => { this.mindMap.render(() => {
// 修复祖先节点存在概要时位置未更新的问题 // 修复祖先节点存在概要时位置未更新的问题
if (hasAncestorsExistGeneralization) { // 修复同时给存在上下级关系的节点添加概要时重叠的问题
if (hasSupSubRelation || hasAncestorsExistGeneralization) {
this.mindMap.render() this.mindMap.render()
} }
}) })

View File

@ -722,6 +722,21 @@ export const getTopAncestorsFomNodeList = list => {
return res return res
} }
// 从给定的节点实例列表里判断是否存在上下级关系
export const checkHasSupSubRelation = list => {
for (let i = 0; i < list.length; i++) {
const cur = list[i]
if (
list.find(item => {
return item.uid !== cur.uid && cur.isParent(item)
})
) {
return true
}
}
return false
}
// 判断两个矩形是否重叠 // 判断两个矩形是否重叠
export const checkTwoRectIsOverlap = ( export const checkTwoRectIsOverlap = (
minx1, minx1,