mirror of
https://github.com/wanglin2/mind-map.git
synced 2026-02-21 10:27:44 +08:00
Fix:修复跨层级复制节点时,节点的富文本样式没有更新的问题
This commit is contained in:
parent
38c6966d13
commit
f92146a1f4
@ -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
|
||||
})
|
||||
)
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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)
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user