fix delete Regex

This commit is contained in:
DiamondThree
2022-08-17 17:01:59 +08:00
parent 1deae12641
commit bb9495e69c

View File

@@ -15,13 +15,13 @@ import {
TLPointerEventHandler, TLPointerEventHandler,
TLShapeCloneHandler, TLShapeCloneHandler,
TLWheelEventHandler, TLWheelEventHandler,
Utils, Utils
} from '@tldraw/core'; } from '@tldraw/core';
import { Vec } from '@tldraw/vec'; import { Vec } from '@tldraw/vec';
import { import {
clearPrevSize, clearPrevSize,
defaultStyle, defaultStyle,
shapeUtils, shapeUtils
} from '@toeverything/components/board-shapes'; } from '@toeverything/components/board-shapes';
import { import {
AlignType, AlignType,
@@ -54,7 +54,7 @@ import {
TDUser, TDUser,
TldrawCommand, TldrawCommand,
USER_COLORS, USER_COLORS,
VIDEO_EXTENSIONS, VIDEO_EXTENSIONS
} from '@toeverything/components/board-types'; } from '@toeverything/components/board-types';
import { MIN_PAGE_WIDTH } from '@toeverything/components/editor-core'; import { MIN_PAGE_WIDTH } from '@toeverything/components/editor-core';
import { import {
@@ -67,7 +67,7 @@ import {
migrate, migrate,
openAssetFromFileSystem, openAssetFromFileSystem,
openFromFileSystem, openFromFileSystem,
saveToFileSystem, saveToFileSystem
} from './data'; } from './data';
import { getClipboard, setClipboard } from './idb-clipboard'; import { getClipboard, setClipboard } from './idb-clipboard';
import { StateManager } from './manager/state-manager'; import { StateManager } from './manager/state-manager';
@@ -3840,12 +3840,10 @@ export class TldrawApp extends StateManager<TDSnapshot> {
}; };
private get_viewbox_from_svg = (svgStr: string | ArrayBuffer | null) => { private get_viewbox_from_svg = (svgStr: string | ArrayBuffer | null) => {
const viewBoxRegex =
/.*?viewBox=["'](-?[\d.]+[, ]+-?[\d.]+[, ][\d.]+[, ][\d.]+)["']/;
if (typeof svgStr === 'string') { if (typeof svgStr === 'string') {
const matches = svgStr.match(viewBoxRegex); let viewBox = (new DOMParser()).parseFromString(svgStr, "text/xml")
return matches && matches.length >= 2 ? matches[1] : null; return viewBox.children[0].getAttribute('viewBox')
} }
console.warn('could not get viewbox from svg string'); console.warn('could not get viewbox from svg string');