diff --git a/simple-mind-map/src/core/render/Render.js b/simple-mind-map/src/core/render/Render.js index 886e3f12..31913765 100644 --- a/simple-mind-map/src/core/render/Render.js +++ b/simple-mind-map/src/core/render/Render.js @@ -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|(? { - return !!item - }) + const textArr = text + .split(new RegExp('\r?\n|(? { + 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() } }) diff --git a/simple-mind-map/src/utils/index.js b/simple-mind-map/src/utils/index.js index 8541ff93..6c4684bb 100644 --- a/simple-mind-map/src/utils/index.js +++ b/simple-mind-map/src/utils/index.js @@ -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,