mirror of
https://github.com/wanglin2/mind-map.git
synced 2026-02-21 10:27:44 +08:00
Feat:createUidForAppointNodes工具方法支持处理概要数据
This commit is contained in:
parent
1770cb98aa
commit
b0a5c8c12a
@ -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 => {
|
||||
[
|
||||
;[
|
||||
['&', '&'],
|
||||
['<', '<'],
|
||||
['>', '>']
|
||||
|
||||
Loading…
Reference in New Issue
Block a user