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
163ae6caae
commit
e3cb7b0a6b
@ -438,14 +438,22 @@ class MindMap {
|
||||
}
|
||||
// 添加必要的样式
|
||||
clone.add(SVG(`<style>${cssContent}</style>`))
|
||||
// 修正关联线箭头marker的id
|
||||
const markerList = svg.find('marker')
|
||||
if (markerList && markerList.length > 0) {
|
||||
const id = markerList[0].attr('id')
|
||||
clone.find('marker').forEach(item => {
|
||||
item.attr('id', id)
|
||||
})
|
||||
}
|
||||
// 修正defs里定义的元素的id,因为clone时defs里的元素的id会继续递增,导致和内容中引用的id对不上
|
||||
const defs = svg.find('defs')
|
||||
const defs2 = clone.find('defs')
|
||||
defs.forEach((def, defIndex) => {
|
||||
const def2 = defs2[defIndex]
|
||||
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)
|
||||
draw.transform(origTransform)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user