Fix:修复在@svgdotjs/svg.js库版本为3.0.16时报错的问题

This commit is contained in:
街角小林 2024-07-25 18:05:22 +08:00
parent 418b24b039
commit 194571d5fe
2 changed files with 4 additions and 4 deletions

View File

@ -528,6 +528,7 @@ class Node {
textContentNested.add(foreignObject)
textContentOffsetX += this._postfixData.width
}
this.group.add(textContentNested)
// 文字内容整体
textContentNested.translate(
width / 2 - textContentNested.bbox().width / 2,
@ -535,7 +536,6 @@ class Node {
imgHeight + // 图片高度
(imgHeight > 0 && textContentHeight > 0 ? this.blockContentMargin : 0) // 和图片的间距
)
this.group.add(textContentNested)
addHoverNode()
this.mindMap.emit('node_layout_end', this)
}

View File

@ -1,5 +1,5 @@
import btnsSvg from '../../../svg/btns'
import { SVG, Circle, G } from '@svgdotjs/svg.js'
import { SVG, Circle, G, Text } from '@svgdotjs/svg.js'
// 创建展开收起按钮的内容节点
function createExpandNodeContent() {
@ -10,7 +10,7 @@ function createExpandNodeContent() {
// 根据配置判断是否显示数量按钮
if (this.mindMap.opt.isShowExpandNum) {
// 展开的节点
this._openExpandNode = SVG().text()
this._openExpandNode = new Text()
// 文本垂直居中
this._openExpandNode.attr({
'text-anchor': 'middle',
@ -79,7 +79,7 @@ function updateExpandBtnNode() {
// 计算子节点数量
let count = this.sumNode(this.nodeData.children)
count = expandBtnNumHandler(count)
node.text(count)
node.text(String(count))
} else {
this._fillExpandNode.stroke('none')
}