From b0a5c8c12a0edf7a869c0c75b24ce902800b1155 Mon Sep 17 00:00:00 2001 From: wanglin2 <1013335014@qq.com> Date: Sat, 1 Feb 2025 11:29:00 +0800 Subject: [PATCH] =?UTF-8?q?Feat:createUidForAppointNodes=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E6=94=AF=E6=8C=81=E5=A4=84=E7=90=86=E6=A6=82?= =?UTF-8?q?=E8=A6=81=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- simple-mind-map/src/utils/index.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/simple-mind-map/src/utils/index.js b/simple-mind-map/src/utils/index.js index 59af46da..94d42aab 100644 --- a/simple-mind-map/src/utils/index.js +++ b/simple-mind-map/src/utils/index.js @@ -508,7 +508,7 @@ export const loadImage = imgFile => { // 移除字符串中的html实体 export const removeHTMLEntities = str => { - [[' ', ' ']].forEach(item => { + ;[[' ', ' ']].forEach(item => { str = str.replace(new RegExp(item[0], 'g'), item[1]) }) return str @@ -1002,7 +1002,8 @@ export const addDataToAppointNodes = (appointNodes, data = {}) => { export const createUidForAppointNodes = ( appointNodes, createNewId = false, - handle = null + handle = null, + handleGeneralization = false ) => { const walk = list => { list.forEach(node => { @@ -1012,6 +1013,14 @@ export const createUidForAppointNodes = ( if (createNewId || isUndef(node.data.uid)) { node.data.uid = createUid() } + if (handleGeneralization) { + const generalizationList = formatGetNodeGeneralization(node.data) + generalizationList.forEach(gNode => { + if (createNewId || isUndef(gNode.uid)) { + gNode.uid = createUid() + } + }) + } handle && handle(node) if (node.children && node.children.length > 0) { walk(node.children) @@ -1060,7 +1069,7 @@ export const generateColorByContent = str => { // html转义 export const htmlEscape = str => { - [ + ;[ ['&', '&'], ['<', '<'], ['>', '>']