diff --git a/libs/components/board-state/src/tldraw-app.ts b/libs/components/board-state/src/tldraw-app.ts index 366b7c67f5..e4b7a8a34f 100644 --- a/libs/components/board-state/src/tldraw-app.ts +++ b/libs/components/board-state/src/tldraw-app.ts @@ -3840,12 +3840,9 @@ export class TldrawApp extends StateManager { }; private get_viewbox_from_svg = (svgStr: string | ArrayBuffer | null) => { - const viewBoxRegex = - /.*?viewBox=["'](-?[\d.]+[, ]+-?[\d.]+[, ][\d.]+[, ][\d.]+)["']/; - if (typeof svgStr === 'string') { - const matches = svgStr.match(viewBoxRegex); - return matches && matches.length >= 2 ? matches[1] : null; + let viewBox = new DOMParser().parseFromString(svgStr, 'text/xml'); + return viewBox.children[0].getAttribute('viewBox'); } console.warn('could not get viewbox from svg string');