优化代码:将render类的setNodeStyle和setNodeStyles方法的公共逻辑提取到richText插件
This commit is contained in:
parent
22b56fb8dc
commit
1caf2c7f15
@ -1158,14 +1158,9 @@ class Render {
|
|||||||
}
|
}
|
||||||
// 如果开启了富文本,则需要应用到富文本上
|
// 如果开启了富文本,则需要应用到富文本上
|
||||||
if (this.mindMap.richText) {
|
if (this.mindMap.richText) {
|
||||||
let config = this.mindMap.richText.normalStyleToRichTextStyle({
|
this.mindMap.richText.setNotActiveNodeStyle(node, {
|
||||||
[prop]: value
|
[prop]: value
|
||||||
})
|
})
|
||||||
if (Object.keys(config).length > 0) {
|
|
||||||
this.mindMap.richText.showEditText(node)
|
|
||||||
this.mindMap.richText.formatAllText(config)
|
|
||||||
this.mindMap.richText.hideEditText([node])
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
this.setNodeDataRender(node, data)
|
this.setNodeDataRender(node, data)
|
||||||
// 更新了连线的样式
|
// 更新了连线的样式
|
||||||
@ -1179,12 +1174,7 @@ class Render {
|
|||||||
let data = { ...style }
|
let data = { ...style }
|
||||||
// 如果开启了富文本,则需要应用到富文本上
|
// 如果开启了富文本,则需要应用到富文本上
|
||||||
if (this.mindMap.richText) {
|
if (this.mindMap.richText) {
|
||||||
let config = this.mindMap.richText.normalStyleToRichTextStyle(style)
|
this.mindMap.richText.setNotActiveNodeStyle(node, style)
|
||||||
if (Object.keys(config).length > 0) {
|
|
||||||
this.mindMap.richText.showEditText(node)
|
|
||||||
this.mindMap.richText.formatAllText(config)
|
|
||||||
this.mindMap.richText.hideEditText([node])
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
this.setNodeDataRender(node, data)
|
this.setNodeDataRender(node, data)
|
||||||
// 更新了连线的样式
|
// 更新了连线的样式
|
||||||
|
|||||||
@ -564,6 +564,16 @@ class RichText {
|
|||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 给未激活的节点设置富文本样式
|
||||||
|
setNotActiveNodeStyle(node, style) {
|
||||||
|
const config = this.normalStyleToRichTextStyle(style)
|
||||||
|
if (Object.keys(config).length > 0) {
|
||||||
|
this.showEditText(node)
|
||||||
|
this.formatAllText(config)
|
||||||
|
this.hideEditText([node])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 处理导出为图片
|
// 处理导出为图片
|
||||||
async handleExportPng(node) {
|
async handleExportPng(node) {
|
||||||
let el = document.createElement('div')
|
let el = document.createElement('div')
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user