Skip to content

Commit 5414698

Browse files
author
Auto Version Bump
committed
fix: png export with margins and adjust used packages
1 parent 73c7f8f commit 5414698

File tree

8 files changed

+257
-529
lines changed

8 files changed

+257
-529
lines changed

library/lib/apollon-editor.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,12 +203,13 @@ export class ApollonEditor {
203203
}
204204

205205
const bounds = getDiagramBounds(reactFlowInstance)
206-
const margin = 10
206+
207+
const margin = 20
207208
const clip = {
208209
x: bounds.x - margin,
209210
y: bounds.y - margin,
210-
width: bounds.width + 2 * margin,
211-
height: bounds.height + 2 * margin,
211+
width: bounds.width + margin * 2,
212+
height: bounds.height + margin * 2,
212213
}
213214

214215
const svgString = getSVG(container, clip)

library/lib/utils/exportUtils.ts

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,11 @@
11
import { IPoint } from "@/edges/types"
22
import { ReactFlowInstance, type Node, type Edge, Rect } from "@xyflow/react"
33

4-
export const getSVG = (container: HTMLElement, bounds: Rect): string => {
4+
export const getSVG = (container: HTMLElement, clip: Rect): string => {
55
const emptySVG = "<svg></svg>"
66

7-
const margin = 10
8-
const clip = {
9-
x: bounds.x - margin,
10-
y: bounds.y - margin,
11-
width: bounds.width + 2 * margin,
12-
height: bounds.height + 2 * margin,
13-
}
14-
15-
const padding = 50
16-
const width = bounds.width + 2 * padding
17-
const height = bounds.height + 2 * padding
7+
const width = clip.width
8+
const height = clip.height
189

1910
const vp = container.querySelector(".react-flow__viewport")
2011

@@ -23,10 +14,7 @@ export const getSVG = (container: HTMLElement, bounds: Rect): string => {
2314
const SVG_NS = "http://www.w3.org/2000/svg"
2415
const mainSVG = document.createElementNS(SVG_NS, "svg")
2516
mainSVG.setAttribute("xmlns", "http://www.w3.org/2000/svg")
26-
mainSVG.setAttribute(
27-
"viewBox",
28-
`${clip.x} ${clip.y} ${clip.width} ${clip.height}`
29-
)
17+
mainSVG.setAttribute("viewBox", `${clip.x} ${clip.y} ${width} ${height}`)
3018
mainSVG.setAttribute("width", `${width}`)
3119
mainSVG.setAttribute("height", `${height}`)
3220

library/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@
2121
"lint:fix": "eslint --fix ."
2222
},
2323
"dependencies": {
24-
"@mui/icons-material": "6.3.1",
25-
"@mui/material": "6.3.1",
24+
"@mui/icons-material": "6.4.2",
25+
"@mui/material": "6.4.2",
2626
"@types/node": "22.13.8",
2727
"@xyflow/react": "12.3.6",
2828
"react": "18.3.1",
2929
"react-dom": "18.3.1",
3030
"uuid": "11.0.3",
31-
"y-websocket": "2.1.0",
32-
"zustand": "5.0.3"
31+
"zustand": "5.0.3",
32+
"yjs": "13.6.20"
3333
},
3434
"devDependencies": {
3535
"@eslint/js": "9.17.0",

0 commit comments

Comments
 (0)