Fix:修复跨层级复制节点时,节点的富文本样式没有更新的问题

This commit is contained in:
街角小林 2024-07-26 17:05:09 +08:00
parent 38c6966d13
commit f92146a1f4
3 changed files with 16 additions and 3 deletions

View File

@ -1482,7 +1482,18 @@ class Render {
node.nodeData.children.push(
...data.map(item => {
const newData = simpleDeepClone(item)
createUidForAppointNodes([newData], true)
createUidForAppointNodes([newData], true, node => {
// 可能跨层级复制,那么富文本样式需要更新
if (this.mindMap.richText) {
// 如果设置了自定义样式那么不需要更新
if (
this.mindMap.richText.checkNodeHasCustomRichTextStyle(node.data)
) {
return
}
node.data.resetRichText = true
}
})
return newData
})
)

View File

@ -13,6 +13,7 @@ import {
nodeRichTextToTextWithWrap
} from '../utils'
import { CONSTANTS } from '../constants/constant'
import Node from '../core/render/node/Node'
let extended = false
@ -676,7 +677,7 @@ class RichText {
'textDecoration',
'color'
]
const nodeData = node.getData()
const nodeData = node instanceof Node ? node.getData() : node
for (let i = 0; i < list.length; i++) {
if (nodeData[list[i]] !== undefined) {
return true

View File

@ -948,7 +948,7 @@ export const addDataToAppointNodes = (appointNodes, data = {}) => {
// 给指定的节点列表树数据添加uid会修改原数据
// createNewId默认为false即如果节点不存在uid的话会创建新的uid。如果传true那么无论节点数据原来是否存在uid都会创建新的uid
export const createUidForAppointNodes = (appointNodes, createNewId = false) => {
export const createUidForAppointNodes = (appointNodes, createNewId = false, handle = null) => {
const walk = list => {
list.forEach(node => {
if (!node.data) {
@ -957,6 +957,7 @@ export const createUidForAppointNodes = (appointNodes, createNewId = false) => {
if (createNewId || isUndef(node.data.uid)) {
node.data.uid = createUid()
}
handle && handle(node)
if (node.children && node.children.length > 0) {
walk(node.children)
}