From 6723250266addd9130f636166156af6934e164f3 Mon Sep 17 00:00:00 2001 From: wanglin2 <1013335014@qq.com> Date: Tue, 21 Nov 2023 10:32:19 +0800 Subject: [PATCH] =?UTF-8?q?Fix=EF=BC=9A=E4=BF=AE=E5=A4=8D=E5=90=8C?= =?UTF-8?q?=E6=97=B6=E7=BB=99=E5=AD=98=E5=9C=A8=E4=B8=8A=E4=B8=8B=E7=BA=A7?= =?UTF-8?q?=E5=85=B3=E7=B3=BB=E7=9A=84=E8=8A=82=E7=82=B9=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=A6=82=E8=A6=81=E6=97=B6=E6=A6=82=E8=A6=81=E9=87=8D=E5=8F=A0?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- simple-mind-map/src/core/render/Render.js | 15 ++++++++++----- simple-mind-map/src/utils/index.js | 15 +++++++++++++++ 2 files changed, 25 insertions(+), 5 deletions(-) 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,