mirror of
https://github.com/wanglin2/mind-map.git
synced 2026-02-17 22:08:25 +08:00
Fix:修复同时给存在上下级关系的节点添加概要时概要重叠的问题
This commit is contained in:
@@ -24,7 +24,8 @@ import {
|
||||
getNodeIndexInNodeList,
|
||||
setDataToClipboard,
|
||||
getDataFromClipboard,
|
||||
htmlEscape
|
||||
htmlEscape,
|
||||
checkHasSupSubRelation
|
||||
} from '../../utils'
|
||||
import { shapeList } from './node/Shape'
|
||||
import { lineStyleProps } from '../../themes/default'
|
||||
@@ -888,9 +889,11 @@ class Render {
|
||||
)
|
||||
} else {
|
||||
text = htmlEscape(text)
|
||||
const textArr = text.split(new RegExp('\r?\n|(?<!\n)\r', 'g')).filter(item => {
|
||||
return !!item
|
||||
})
|
||||
const textArr = text
|
||||
.split(new RegExp('\r?\n|(?<!\n)\r', 'g'))
|
||||
.filter(item => {
|
||||
return !!item
|
||||
})
|
||||
// 判断是否需要根据换行自动分割节点
|
||||
if (textArr.length > 1 && handleIsSplitByWrapOnPasteCreateNewNode) {
|
||||
handleIsSplitByWrapOnPasteCreateNewNode()
|
||||
@@ -1416,9 +1419,11 @@ class Render {
|
||||
expand: true
|
||||
})
|
||||
})
|
||||
const hasSupSubRelation = checkHasSupSubRelation(this.activeNodeList)
|
||||
this.mindMap.render(() => {
|
||||
// 修复祖先节点存在概要时位置未更新的问题
|
||||
if (hasAncestorsExistGeneralization) {
|
||||
// 修复同时给存在上下级关系的节点添加概要时重叠的问题
|
||||
if (hasSupSubRelation || hasAncestorsExistGeneralization) {
|
||||
this.mindMap.render()
|
||||
}
|
||||
})
|
||||
|
||||
@@ -722,6 +722,21 @@ export const getTopAncestorsFomNodeList = list => {
|
||||
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 = (
|
||||
minx1,
|
||||
|
||||
Reference in New Issue
Block a user