Fix:修复导出图片时节点连线的箭头、关联线的箭头、渐变背景丢失的问题
This commit is contained in:
parent
163ae6caae
commit
e3cb7b0a6b
@ -438,14 +438,22 @@ class MindMap {
|
|||||||
}
|
}
|
||||||
// 添加必要的样式
|
// 添加必要的样式
|
||||||
clone.add(SVG(`<style>${cssContent}</style>`))
|
clone.add(SVG(`<style>${cssContent}</style>`))
|
||||||
// 修正关联线箭头marker的id
|
// 修正defs里定义的元素的id,因为clone时defs里的元素的id会继续递增,导致和内容中引用的id对不上
|
||||||
const markerList = svg.find('marker')
|
const defs = svg.find('defs')
|
||||||
if (markerList && markerList.length > 0) {
|
const defs2 = clone.find('defs')
|
||||||
const id = markerList[0].attr('id')
|
defs.forEach((def, defIndex) => {
|
||||||
clone.find('marker').forEach(item => {
|
const def2 = defs2[defIndex]
|
||||||
item.attr('id', id)
|
if (!def2) return
|
||||||
})
|
const children = def.children()
|
||||||
}
|
const children2 = def2.children()
|
||||||
|
for (let i = 0; i < children.length; i++) {
|
||||||
|
const child = children[i]
|
||||||
|
const child2 = children2[i]
|
||||||
|
if (child && child2) {
|
||||||
|
child2.attr('id', child.attr('id'))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
// 恢复原先的大小和变换信息
|
// 恢复原先的大小和变换信息
|
||||||
svg.size(origWidth, origHeight)
|
svg.size(origWidth, origHeight)
|
||||||
draw.transform(origTransform)
|
draw.transform(origTransform)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user