From f0ce4c9db679ccad8cba9832dda76713d69b41b7 Mon Sep 17 00:00:00 2001 From: HK-SHAO Date: Fri, 15 Sep 2023 17:07:19 +0800 Subject: [PATCH] fix: interface SVG was changed by mistake When setting up an export of different sizes, click the Copy Image button or the Download button, and the SVG size of the user interface changes --- src/lib/components/Actions.svelte | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lib/components/Actions.svelte b/src/lib/components/Actions.svelte index a038712e..0256dca1 100644 --- a/src/lib/components/Actions.svelte +++ b/src/lib/components/Actions.svelte @@ -15,6 +15,10 @@ `mermaid-diagram-${dayjs().format('YYYY-MM-DD-HHmmss')}.${ext}`; const getBase64SVG = (svg?: HTMLElement, width?: number, height?: number): string => { + if (svg) { + // Prevents the SVG size of the interface from being changed + svg = svg.cloneNode(true) as HTMLElement; + } height && svg?.setAttribute('height', `${height}px`); width && svg?.setAttribute('width', `${width}px`); // Workaround https://stackoverflow.com/questions/28690643/firefox-error-rendering-an-svg-image-to-html5-canvas-with-drawimage if (!svg) {