Skip to content

Commit 23ed5ce

Browse files
fix: v0.16.2 fix wrong position of svg element
1 parent 67d465f commit 23ed5ce

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mind-elixir",
3-
"version": "0.16.1",
3+
"version": "0.16.2",
44
"description": "Mind elixir is a free open source mind map core.",
55
"main": "dist/MindElixir.js",
66
"scripts": {
@@ -49,5 +49,8 @@
4949
"webpack-bundle-analyzer": "^3.3.2",
5050
"webpack-cli": "^3.3.2",
5151
"webpack-dev-server": "^3.5.1"
52+
},
53+
"dependencies": {
54+
"@babel/runtime": "^7.15.4"
5255
}
5356
}

painter/index.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import Canvg from 'canvg'
2+
3+
let head = `<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">`
24
let IMG_PADDING = 40
35
let $d = document
4-
// calculate distances to center from top,left,bottom,right
5-
66
let maxTop, maxBottom, maxLeft, maxRight, svgHeight, svgWidth
77

88
function initVar() {
@@ -14,18 +14,18 @@ function initVar() {
1414
svgWidth = 0
1515
}
1616

17-
let head = `<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">`
1817
function generateSvgDom() {
1918
let primaryNodes = $d.querySelectorAll('.box > grp, root')
2019
let svgContent = ''
20+
// calculate distance to center from top, left, bottom, right
2121
for (let i = 0; i < primaryNodes.length; i++) {
2222
let primaryNode = primaryNodes[i]
2323
let rect = primaryNode.getBoundingClientRect()
2424
let top = primaryNode.offsetTop
2525
let bottom = top + rect.height
2626
let left = primaryNode.offsetLeft
2727
let right = left + rect.width
28-
// console.log(top, bottom, left, right)
28+
2929
if (top < maxTop) {
3030
maxTop = top
3131
}
@@ -38,11 +38,16 @@ function generateSvgDom() {
3838
if (right > maxRight) {
3939
maxRight = right
4040
}
41+
}
42+
43+
for (let i = 0; i < primaryNodes.length; i++) {
44+
let primaryNode = primaryNodes[i]
45+
if(primaryNode.tagName === 'ROOT') continue
4146
svgContent += PrimaryToSvg(primaryNode)
4247
}
4348
console.log(maxTop, maxBottom, maxLeft, maxRight)
4449
svgContent += RootToSvg()
45-
// 需要添加图片边缘padding
50+
// image margin
4651
svgHeight = maxBottom - maxTop + IMG_PADDING * 2
4752
svgWidth = maxRight - maxLeft + IMG_PADDING * 2
4853
// svgContent += customLinkTransform()

0 commit comments

Comments
 (0)