@tldraw/editor 5.5.0-next.b6a9f7cd7be2 → 5.5.0-next.c91b2de0a423
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-cjs/index.d.ts +47 -23
- package/dist-cjs/index.js +1 -1
- package/dist-cjs/index.js.map +2 -2
- package/dist-cjs/lib/TldrawEditor.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultCanvas.js +5 -1
- package/dist-cjs/lib/components/default-components/DefaultCanvas.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultErrorFallback.js +2 -5
- package/dist-cjs/lib/components/default-components/DefaultErrorFallback.js.map +3 -3
- package/dist-cjs/lib/components/default-components/DefaultSpinner.js.map +2 -2
- package/dist-cjs/lib/editor/Editor.js +24 -26
- package/dist-cjs/lib/editor/Editor.js.map +2 -2
- package/dist-cjs/lib/editor/managers/ClickManager/ClickManager.js +3 -2
- package/dist-cjs/lib/editor/managers/ClickManager/ClickManager.js.map +2 -2
- package/dist-cjs/lib/editor/managers/EditorManager.js +11 -2
- package/dist-cjs/lib/editor/managers/EditorManager.js.map +2 -2
- package/dist-cjs/lib/editor/managers/PerformanceManager/PerformanceManager.js +49 -63
- package/dist-cjs/lib/editor/managers/PerformanceManager/PerformanceManager.js.map +2 -2
- package/dist-cjs/lib/editor/managers/ScribbleManager/ScribbleManager.js +1 -1
- package/dist-cjs/lib/editor/managers/ScribbleManager/ScribbleManager.js.map +2 -2
- package/dist-cjs/lib/editor/managers/SnapManager/BoundsSnaps.js +24 -24
- package/dist-cjs/lib/editor/managers/SnapManager/BoundsSnaps.js.map +2 -2
- package/dist-cjs/lib/editor/managers/SnapManager/HandleSnaps.js +7 -1
- package/dist-cjs/lib/editor/managers/SnapManager/HandleSnaps.js.map +2 -2
- package/dist-cjs/lib/editor/managers/SnapManager/SnapManager.js +4 -3
- package/dist-cjs/lib/editor/managers/SnapManager/SnapManager.js.map +2 -2
- package/dist-cjs/lib/editor/types/external-content.js.map +1 -1
- package/dist-cjs/lib/hooks/EditorComponentsContext.js.map +2 -2
- package/dist-cjs/lib/utils/debug-flags.js +0 -6
- package/dist-cjs/lib/utils/debug-flags.js.map +2 -2
- package/dist-cjs/lib/utils/sync/LocalIndexedDb.js +19 -8
- package/dist-cjs/lib/utils/sync/LocalIndexedDb.js.map +2 -2
- package/dist-cjs/lib/utils/sync/TLLocalSyncClient.js +3 -0
- package/dist-cjs/lib/utils/sync/TLLocalSyncClient.js.map +2 -2
- package/dist-cjs/version.js +3 -3
- package/dist-cjs/version.js.map +1 -1
- package/dist-esm/index.d.mts +47 -23
- package/dist-esm/index.mjs +4 -2
- package/dist-esm/index.mjs.map +2 -2
- package/dist-esm/lib/TldrawEditor.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultCanvas.mjs +5 -1
- package/dist-esm/lib/components/default-components/DefaultCanvas.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultErrorFallback.mjs +2 -5
- package/dist-esm/lib/components/default-components/DefaultErrorFallback.mjs.map +3 -3
- package/dist-esm/lib/components/default-components/DefaultSpinner.mjs.map +2 -2
- package/dist-esm/lib/editor/Editor.mjs +24 -26
- package/dist-esm/lib/editor/Editor.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/ClickManager/ClickManager.mjs +3 -2
- package/dist-esm/lib/editor/managers/ClickManager/ClickManager.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/EditorManager.mjs +11 -2
- package/dist-esm/lib/editor/managers/EditorManager.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/PerformanceManager/PerformanceManager.mjs +49 -63
- package/dist-esm/lib/editor/managers/PerformanceManager/PerformanceManager.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/ScribbleManager/ScribbleManager.mjs +1 -1
- package/dist-esm/lib/editor/managers/ScribbleManager/ScribbleManager.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/SnapManager/BoundsSnaps.mjs +24 -24
- package/dist-esm/lib/editor/managers/SnapManager/BoundsSnaps.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/SnapManager/HandleSnaps.mjs +7 -1
- package/dist-esm/lib/editor/managers/SnapManager/HandleSnaps.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/SnapManager/SnapManager.mjs +4 -3
- package/dist-esm/lib/editor/managers/SnapManager/SnapManager.mjs.map +2 -2
- package/dist-esm/lib/hooks/EditorComponentsContext.mjs.map +2 -2
- package/dist-esm/lib/utils/debug-flags.mjs +0 -6
- package/dist-esm/lib/utils/debug-flags.mjs.map +2 -2
- package/dist-esm/lib/utils/sync/LocalIndexedDb.mjs +19 -8
- package/dist-esm/lib/utils/sync/LocalIndexedDb.mjs.map +2 -2
- package/dist-esm/lib/utils/sync/TLLocalSyncClient.mjs +3 -0
- package/dist-esm/lib/utils/sync/TLLocalSyncClient.mjs.map +2 -2
- package/dist-esm/version.mjs +3 -3
- package/dist-esm/version.mjs.map +1 -1
- package/package.json +7 -7
- package/src/index.ts +5 -1
- package/src/lib/TldrawEditor.tsx +8 -6
- package/src/lib/components/default-components/DefaultCanvas.tsx +7 -1
- package/src/lib/components/default-components/DefaultErrorFallback.tsx +13 -5
- package/src/lib/components/default-components/DefaultSpinner.tsx +4 -1
- package/src/lib/editor/Editor.test.ts +45 -0
- package/src/lib/editor/Editor.ts +40 -35
- package/src/lib/editor/managers/ClickManager/ClickManager.test.ts +1 -0
- package/src/lib/editor/managers/ClickManager/ClickManager.ts +3 -2
- package/src/lib/editor/managers/EditorManager.test.ts +32 -1
- package/src/lib/editor/managers/EditorManager.ts +15 -3
- package/src/lib/editor/managers/PerformanceManager/PerformanceManager.test.ts +80 -0
- package/src/lib/editor/managers/PerformanceManager/PerformanceManager.ts +54 -81
- package/src/lib/editor/managers/ScribbleManager/ScribbleManager.ts +1 -1
- package/src/lib/editor/managers/SnapManager/BoundsSnaps.ts +32 -36
- package/src/lib/editor/managers/SnapManager/HandleSnaps.ts +13 -2
- package/src/lib/editor/managers/SnapManager/SnapManager.test.ts +13 -0
- package/src/lib/editor/managers/SnapManager/SnapManager.ts +6 -4
- package/src/lib/editor/types/external-content.ts +5 -0
- package/src/lib/hooks/EditorComponentsContext.tsx +2 -1
- package/src/lib/utils/debug-flags.ts +0 -6
- package/src/lib/utils/sync/LocalIndexedDb.test.ts +93 -1
- package/src/lib/utils/sync/LocalIndexedDb.ts +23 -8
- package/src/lib/utils/sync/TLLocalSyncClient.test.ts +21 -1
- package/src/lib/utils/sync/TLLocalSyncClient.ts +6 -0
- package/src/version.ts +3 -3
|
@@ -43,10 +43,7 @@ var import_dom = require("../../utils/dom");
|
|
|
43
43
|
var import_runtime = require("../../utils/runtime");
|
|
44
44
|
var import_ErrorBoundary = require("../ErrorBoundary");
|
|
45
45
|
const BASE_ERROR_URL = "https://github.com/tldraw/tldraw/issues/new";
|
|
46
|
-
|
|
47
|
-
error,
|
|
48
|
-
editor
|
|
49
|
-
}) {
|
|
46
|
+
function DefaultErrorFallback({ error, editor }) {
|
|
50
47
|
const containerRef = (0, import_react.useRef)(null);
|
|
51
48
|
const [shouldShowError, setShouldShowError] = (0, import_react.useState)(process.env.NODE_ENV === "development");
|
|
52
49
|
const [didCopy, setDidCopy] = (0, import_react.useState)(false);
|
|
@@ -207,5 +204,5 @@ My browser: ${navigator.userAgent}`
|
|
|
207
204
|
]
|
|
208
205
|
}
|
|
209
206
|
);
|
|
210
|
-
}
|
|
207
|
+
}
|
|
211
208
|
//# sourceMappingURL=DefaultErrorFallback.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/lib/components/default-components/DefaultErrorFallback.tsx"],
|
|
4
|
-
"sourcesContent": ["import { useValue } from '@tldraw/state-react'\nimport { noop } from '@tldraw/utils'\nimport classNames from 'classnames'\nimport { ComponentType, useEffect, useLayoutEffect, useRef, useState } from 'react'\nimport { Editor } from '../../editor/Editor'\nimport { getOwnerDocument } from '../../exports/domUtils'\nimport { useEditorComponents } from '../../hooks/EditorComponentsContext'\nimport { EditorProvider } from '../../hooks/useEditor'\nimport { getGlobalWindow } from '../../utils/dom'\nimport { hardResetEditor, refreshPage } from '../../utils/runtime'\nimport { ErrorBoundary } from '../ErrorBoundary'\n\nconst BASE_ERROR_URL = 'https://github.com/tldraw/tldraw/issues/new'\n\n/** @public */\nexport
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
6
|
-
"names": ["
|
|
4
|
+
"sourcesContent": ["import { useValue } from '@tldraw/state-react'\nimport { noop } from '@tldraw/utils'\nimport classNames from 'classnames'\nimport { ComponentType, useEffect, useLayoutEffect, useRef, useState } from 'react'\nimport { Editor } from '../../editor/Editor'\nimport { getOwnerDocument } from '../../exports/domUtils'\nimport { useEditorComponents } from '../../hooks/EditorComponentsContext'\nimport { EditorProvider } from '../../hooks/useEditor'\nimport { getGlobalWindow } from '../../utils/dom'\nimport { hardResetEditor, refreshPage } from '../../utils/runtime'\nimport { ErrorBoundary } from '../ErrorBoundary'\n\nconst BASE_ERROR_URL = 'https://github.com/tldraw/tldraw/issues/new'\n\n/** @public */\nexport interface TLErrorFallbackProps {\n\t/** The error that was caught. */\n\terror: unknown\n\t/**\n\t * Only set when the caller renders the fallback with an editor; the editor's own error\n\t * boundaries pass just `error`.\n\t */\n\teditor?: Editor\n}\n\n/** @public */\nexport type TLErrorFallbackComponent = ComponentType<TLErrorFallbackProps>\n\n/** @public @react */\nexport function DefaultErrorFallback({ error, editor }: TLErrorFallbackProps) {\n\tconst containerRef = useRef<HTMLDivElement>(null)\n\tconst [shouldShowError, setShouldShowError] = useState(process.env.NODE_ENV === 'development')\n\tconst [didCopy, setDidCopy] = useState(false)\n\tconst [shouldShowResetConfirmation, setShouldShowResetConfirmation] = useState(false)\n\n\tlet Canvas: React.ComponentType | null = null\n\ttry {\n\t\t// eslint-disable-next-line react-hooks/rules-of-hooks\n\t\tconst components = useEditorComponents()\n\t\tCanvas = components.Canvas ?? null\n\t} catch {\n\t\t// allow this to fail silently\n\t}\n\n\tconst errorMessage = error instanceof Error ? error.message : String(error)\n\tconst errorStack = error instanceof Error ? error.stack : null\n\n\tconst isDarkModeFromApp = useValue(\n\t\t'isDarkMode',\n\t\t() => {\n\t\t\ttry {\n\t\t\t\tif (editor) {\n\t\t\t\t\treturn editor.user.getIsDarkMode()\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t// we're in a funky error state so this might not work for spooky\n\t\t\t\t// reasons. if not, we'll have another attempt later:\n\t\t\t}\n\t\t\treturn null\n\t\t},\n\t\t[editor]\n\t)\n\tconst [isDarkMode, setIsDarkMode] = useState<null | boolean>(null)\n\tuseLayoutEffect(() => {\n\t\t// if we found a theme class from the app, we can just use that\n\t\tif (isDarkModeFromApp !== null) {\n\t\t\tsetIsDarkMode(isDarkModeFromApp)\n\t\t}\n\n\t\t// do any of our parents have a theme class? if yes then we can just\n\t\t// rely on that and don't need to set our own class\n\t\tlet parent = containerRef.current?.parentElement\n\t\tlet foundParentThemeClass = false\n\t\twhile (parent) {\n\t\t\tif (\n\t\t\t\tparent.classList.contains('tl-theme__dark') ||\n\t\t\t\tparent.classList.contains('tl-theme__light')\n\t\t\t) {\n\t\t\t\tfoundParentThemeClass = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tparent = parent.parentElement\n\t\t}\n\t\tif (foundParentThemeClass) {\n\t\t\tsetIsDarkMode(null)\n\t\t\treturn\n\t\t}\n\n\t\t// if we can't find a theme class from the app or from a parent, we have\n\t\t// to fall back on using a media query:\n\t\tif (typeof window !== 'undefined' && getGlobalWindow().matchMedia) {\n\t\t\tsetIsDarkMode(getGlobalWindow().matchMedia('(prefers-color-scheme: dark)').matches)\n\t\t}\n\t}, [isDarkModeFromApp])\n\n\tuseEffect(() => {\n\t\tif (didCopy) {\n\t\t\tconst timeout = editor?.timers.setTimeout(() => {\n\t\t\t\tsetDidCopy(false)\n\t\t\t}, 2000)\n\t\t\treturn () => clearTimeout(timeout)\n\t\t}\n\t}, [didCopy, editor])\n\n\tconst copyError = () => {\n\t\tconst doc = getOwnerDocument(containerRef.current)\n\t\tconst textarea = doc.createElement('textarea')\n\t\ttextarea.value = errorStack ?? errorMessage\n\t\tdoc.body.appendChild(textarea)\n\t\ttextarea.select()\n\t\t// eslint-disable-next-line @typescript-eslint/no-deprecated\n\t\tdoc.execCommand('copy')\n\t\ttextarea.remove()\n\t\tsetDidCopy(true)\n\t}\n\n\tconst refresh = () => {\n\t\trefreshPage()\n\t}\n\n\tconst resetLocalState = async () => {\n\t\thardResetEditor()\n\t}\n\n\tconst url = new URL(BASE_ERROR_URL)\n\turl.searchParams.set('title', errorMessage)\n\turl.searchParams.set('labels', `bug`)\n\turl.searchParams.set(\n\t\t'body',\n\t\t`Hey, I ran into an error while using tldraw:\n\n\\`\\`\\`js\n${errorStack ?? errorMessage}\n\\`\\`\\`\n\nMy browser: ${navigator.userAgent}`\n\t)\n\n\treturn (\n\t\t<div\n\t\t\tref={containerRef}\n\t\t\tclassName={classNames(\n\t\t\t\t'tl-container tl-error-boundary',\n\t\t\t\t// error-boundary is sometimes used outside of the theme\n\t\t\t\t// container, so we need to provide it with a theme for our\n\t\t\t\t// styles to work correctly\n\t\t\t\tisDarkMode === null ? '' : isDarkMode ? 'tl-theme__dark' : 'tl-theme__light'\n\t\t\t)}\n\t\t>\n\t\t\t<div className=\"tl-error-boundary__overlay\" />\n\t\t\t{editor && (\n\t\t\t\t// opportunistically attempt to render the canvas to reassure\n\t\t\t\t// the user that their document is still there. there's a good\n\t\t\t\t// chance this won't work (ie the error that we're currently\n\t\t\t\t// notifying the user about originates in the canvas) so it's\n\t\t\t\t// not a big deal if it doesn't work - in that case we just have\n\t\t\t\t// a plain grey background.\n\t\t\t\t<ErrorBoundary onError={noop} fallback={() => null}>\n\t\t\t\t\t<EditorProvider editor={editor}>\n\t\t\t\t\t\t<div className=\"tl-overlay tl-error-boundary__canvas\">{Canvas ? <Canvas /> : null}</div>\n\t\t\t\t\t</EditorProvider>\n\t\t\t\t</ErrorBoundary>\n\t\t\t)}\n\t\t\t<div\n\t\t\t\tclassName={classNames('tl-modal', 'tl-error-boundary__content', {\n\t\t\t\t\t'tl-error-boundary__content__expanded': shouldShowError && !shouldShowResetConfirmation,\n\t\t\t\t})}\n\t\t\t>\n\t\t\t\t{shouldShowResetConfirmation ? (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<h2>Are you sure?</h2>\n\t\t\t\t\t\t<p>Resetting your data will delete your drawing and cannot be undone.</p>\n\t\t\t\t\t\t<div className=\"tl-error-boundary__content__actions\">\n\t\t\t\t\t\t\t<button className=\"tlui-button\" onClick={() => setShouldShowResetConfirmation(false)}>\n\t\t\t\t\t\t\t\tCancel\n\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t<button className=\"tlui-button tl-error-boundary__reset\" onClick={resetLocalState}>\n\t\t\t\t\t\t\t\tReset data\n\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</>\n\t\t\t\t) : (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<h2>Something went wrong</h2>\n\t\t\t\t\t\t<p>Please refresh your browser.</p>\n\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\tIf the issue continues after refreshing, you may need to reset the tldraw data stored\n\t\t\t\t\t\t\ton your device.\n\t\t\t\t\t\t</p>\n\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\t<strong>Note:</strong> Resetting will erase your current project and any unsaved work.\n\t\t\t\t\t\t</p>\n\t\t\t\t\t\t{process.env.NODE_ENV !== 'production' && (\n\t\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\t\tIf you're developing with the SDK and need help, join us on{' '}\n\t\t\t\t\t\t\t\t<a href=\"https://discord.tldraw.com/?utm_source=sdk&utm_medium=organic&utm_campaign=error-screen\">\n\t\t\t\t\t\t\t\t\tDiscord\n\t\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t\t\t.\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t)}\n\t\t\t\t\t\t{shouldShowError && (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\tMessage:\n\t\t\t\t\t\t\t\t<h4>\n\t\t\t\t\t\t\t\t\t<code>{errorMessage}</code>\n\t\t\t\t\t\t\t\t</h4>\n\t\t\t\t\t\t\t\tStack trace:\n\t\t\t\t\t\t\t\t<div className=\"tl-error-boundary__content__error\">\n\t\t\t\t\t\t\t\t\t<pre>\n\t\t\t\t\t\t\t\t\t\t<code>{errorStack ?? errorMessage}</code>\n\t\t\t\t\t\t\t\t\t</pre>\n\t\t\t\t\t\t\t\t\t<button className=\"tlui-button\" onClick={copyError}>\n\t\t\t\t\t\t\t\t\t\t{didCopy ? 'Copied!' : 'Copy'}\n\t\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t)}\n\t\t\t\t\t\t<div className=\"tl-error-boundary__content__actions\">\n\t\t\t\t\t\t\t<button className=\"tlui-button\" onClick={() => setShouldShowError(!shouldShowError)}>\n\t\t\t\t\t\t\t\t{shouldShowError ? 'Hide details' : 'Show details'}\n\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t<div className=\"tl-error-boundary__content__actions__group\">\n\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\tclassName=\"tlui-button tl-error-boundary__reset\"\n\t\t\t\t\t\t\t\t\tonClick={() => setShouldShowResetConfirmation(true)}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\tReset data\n\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t\t<button className=\"tlui-button tl-error-boundary__refresh\" onClick={refresh}>\n\t\t\t\t\t\t\t\t\tRefresh page\n\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</>\n\t\t\t\t)}\n\t\t\t</div>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AAY,QACxB;AAAA,mBACD;AAAA,iBACD;AAAA,cAED,6CAAC,SAAI,WAAU,uCACd;AAAA,4DAAC,YAAO,WAAU,eAAc,SAAS,MAAM,mBAAmB,CAAC,eAAe,GAChF,4BAAkB,iBAAiB,gBACrC;AAAA,gBACA,6CAAC,SAAI,WAAU,8CACd;AAAA;AAAA,oBAAC;AAAA;AAAA,sBACA,WAAU;AAAA,sBACV,SAAS,MAAM,+BAA+B,IAAI;AAAA,sBAClD;AAAA;AAAA,kBAED;AAAA,kBACA,4CAAC,YAAO,WAAU,0CAAyC,SAAS,SAAS,0BAE7E;AAAA,mBACD;AAAA,iBACD;AAAA,eACD;AAAA;AAAA,QAEF;AAAA;AAAA;AAAA,EACD;AAEF;",
|
|
6
|
+
"names": ["classNames"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/lib/components/default-components/DefaultSpinner.tsx"],
|
|
4
|
-
"sourcesContent": ["import classNames from 'classnames'\n\n/** @public @react */\nexport function DefaultSpinner(props:
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["import classNames from 'classnames'\n\n/** @public */\nexport type TLSpinnerProps = React.SVGProps<SVGSVGElement>\n\n/** @public @react */\nexport function DefaultSpinner(props: TLSpinnerProps) {\n\treturn (\n\t\t<svg\n\t\t\twidth={16}\n\t\t\theight={16}\n\t\t\tviewBox=\"0 0 16 16\"\n\t\t\taria-hidden=\"false\"\n\t\t\t{...props}\n\t\t\tclassName={classNames('tl-spinner', props.className)}\n\t\t>\n\t\t\t<g strokeWidth={2} fill=\"none\" fillRule=\"evenodd\">\n\t\t\t\t<circle strokeOpacity={0.25} cx={8} cy={8} r={7} stroke=\"currentColor\" />\n\t\t\t\t<path strokeLinecap=\"round\" d=\"M15 8c0-4.5-4.5-7-7-7\" stroke=\"currentColor\" />\n\t\t\t</g>\n\t\t</svg>\n\t)\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBG;AAhBH,wBAAuB;AAMhB,SAAS,eAAe,OAAuB;AACrD,SACC;AAAA,IAAC;AAAA;AAAA,MACA,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,SAAQ;AAAA,MACR,eAAY;AAAA,MACX,GAAG;AAAA,MACJ,eAAW,kBAAAA,SAAW,cAAc,MAAM,SAAS;AAAA,MAEnD,uDAAC,OAAE,aAAa,GAAG,MAAK,QAAO,UAAS,WACvC;AAAA,oDAAC,YAAO,eAAe,MAAM,IAAI,GAAG,IAAI,GAAG,GAAG,GAAG,QAAO,gBAAe;AAAA,QACvE,4CAAC,UAAK,eAAc,SAAQ,GAAE,yBAAwB,QAAO,gBAAe;AAAA,SAC7E;AAAA;AAAA,EACD;AAEF;",
|
|
6
6
|
"names": ["classNames"]
|
|
7
7
|
}
|
|
@@ -1408,7 +1408,7 @@ class Editor extends import_eventemitter3.default {
|
|
|
1408
1408
|
updateInstanceState(partial, historyOptions) {
|
|
1409
1409
|
this._updateInstanceState(partial, { history: "ignore", ...historyOptions });
|
|
1410
1410
|
if (partial.isChangingStyle !== void 0) {
|
|
1411
|
-
clearTimeout(this._isChangingStyleTimeout);
|
|
1411
|
+
this.timers.clearTimeout(this._isChangingStyleTimeout);
|
|
1412
1412
|
if (partial.isChangingStyle === true) {
|
|
1413
1413
|
this._isChangingStyleTimeout = this.timers.setTimeout(() => {
|
|
1414
1414
|
this._updateInstanceState({ isChangingStyle: false }, { history: "ignore" });
|
|
@@ -7822,22 +7822,22 @@ class Editor extends import_eventemitter3.default {
|
|
|
7822
7822
|
const releaseCtrl = this._ctrlKeyTimeout !== -1;
|
|
7823
7823
|
const releaseMeta = this._metaKeyTimeout !== -1;
|
|
7824
7824
|
if (releaseShift) {
|
|
7825
|
-
clearTimeout(this._shiftKeyTimeout);
|
|
7825
|
+
this.timers.clearTimeout(this._shiftKeyTimeout);
|
|
7826
7826
|
this._shiftKeyTimeout = -1;
|
|
7827
7827
|
this.inputs.setShiftKey(false);
|
|
7828
7828
|
}
|
|
7829
7829
|
if (releaseAlt) {
|
|
7830
|
-
clearTimeout(this._altKeyTimeout);
|
|
7830
|
+
this.timers.clearTimeout(this._altKeyTimeout);
|
|
7831
7831
|
this._altKeyTimeout = -1;
|
|
7832
7832
|
this.inputs.setAltKey(false);
|
|
7833
7833
|
}
|
|
7834
7834
|
if (releaseCtrl) {
|
|
7835
|
-
clearTimeout(this._ctrlKeyTimeout);
|
|
7835
|
+
this.timers.clearTimeout(this._ctrlKeyTimeout);
|
|
7836
7836
|
this._ctrlKeyTimeout = -1;
|
|
7837
7837
|
this.inputs.setCtrlKey(false);
|
|
7838
7838
|
}
|
|
7839
7839
|
if (releaseMeta) {
|
|
7840
|
-
clearTimeout(this._metaKeyTimeout);
|
|
7840
|
+
this.timers.clearTimeout(this._metaKeyTimeout);
|
|
7841
7841
|
this._metaKeyTimeout = -1;
|
|
7842
7842
|
this.inputs.setMetaKey(false);
|
|
7843
7843
|
}
|
|
@@ -7951,28 +7951,28 @@ class Editor extends import_eventemitter3.default {
|
|
|
7951
7951
|
return;
|
|
7952
7952
|
}
|
|
7953
7953
|
if (info.shiftKey) {
|
|
7954
|
-
clearTimeout(this._shiftKeyTimeout);
|
|
7954
|
+
this.timers.clearTimeout(this._shiftKeyTimeout);
|
|
7955
7955
|
this._shiftKeyTimeout = -1;
|
|
7956
7956
|
inputs.setShiftKey(true);
|
|
7957
7957
|
} else if (!info.shiftKey && inputs.getShiftKey() && this._shiftKeyTimeout === -1) {
|
|
7958
7958
|
this._shiftKeyTimeout = this.timers.setTimeout(this._releaseShiftKey, 150);
|
|
7959
7959
|
}
|
|
7960
7960
|
if (info.altKey) {
|
|
7961
|
-
clearTimeout(this._altKeyTimeout);
|
|
7961
|
+
this.timers.clearTimeout(this._altKeyTimeout);
|
|
7962
7962
|
this._altKeyTimeout = -1;
|
|
7963
7963
|
inputs.setAltKey(true);
|
|
7964
7964
|
} else if (!info.altKey && inputs.getAltKey() && this._altKeyTimeout === -1) {
|
|
7965
7965
|
this._altKeyTimeout = this.timers.setTimeout(this._releaseAltKey, 150);
|
|
7966
7966
|
}
|
|
7967
7967
|
if (info.ctrlKey) {
|
|
7968
|
-
clearTimeout(this._ctrlKeyTimeout);
|
|
7968
|
+
this.timers.clearTimeout(this._ctrlKeyTimeout);
|
|
7969
7969
|
this._ctrlKeyTimeout = -1;
|
|
7970
7970
|
inputs.setCtrlKey(true);
|
|
7971
7971
|
} else if (!info.ctrlKey && inputs.getCtrlKey() && this._ctrlKeyTimeout === -1) {
|
|
7972
7972
|
this._ctrlKeyTimeout = this.timers.setTimeout(this._releaseCtrlKey, 150);
|
|
7973
7973
|
}
|
|
7974
7974
|
if (info.metaKey && info.name !== "key_up") {
|
|
7975
|
-
clearTimeout(this._metaKeyTimeout);
|
|
7975
|
+
this.timers.clearTimeout(this._metaKeyTimeout);
|
|
7976
7976
|
this._metaKeyTimeout = -1;
|
|
7977
7977
|
inputs.setMetaKey(true);
|
|
7978
7978
|
} else if (!info.metaKey && inputs.getMetaKey() && this._metaKeyTimeout === -1) {
|
|
@@ -7986,8 +7986,7 @@ class Editor extends import_eventemitter3.default {
|
|
|
7986
7986
|
const cameraOptions = this._cameraOptions.__unsafe__getWithoutCapture();
|
|
7987
7987
|
switch (type) {
|
|
7988
7988
|
case "pinch": {
|
|
7989
|
-
|
|
7990
|
-
clearTimeout(this._longPressTimeout);
|
|
7989
|
+
this.timers.clearTimeout(this._longPressTimeout);
|
|
7991
7990
|
this.inputs.updateFromEvent(info);
|
|
7992
7991
|
switch (info.name) {
|
|
7993
7992
|
case "pinch_start": {
|
|
@@ -8008,6 +8007,7 @@ class Editor extends import_eventemitter3.default {
|
|
|
8008
8007
|
}
|
|
8009
8008
|
case "pinch": {
|
|
8010
8009
|
if (!inputs.getIsPinching()) return;
|
|
8010
|
+
if (cameraOptions.isLocked) return;
|
|
8011
8011
|
const {
|
|
8012
8012
|
point: { z = 1 },
|
|
8013
8013
|
delta: { x: dx, y: dy }
|
|
@@ -8063,7 +8063,7 @@ class Editor extends import_eventemitter3.default {
|
|
|
8063
8063
|
const { panSpeed, zoomSpeed } = cameraOptions;
|
|
8064
8064
|
let wheelBehavior = cameraOptions.wheelBehavior;
|
|
8065
8065
|
const inputMode = this.user.getUserPreferences().inputMode;
|
|
8066
|
-
if (inputMode !== null) {
|
|
8066
|
+
if (inputMode !== null && wheelBehavior !== "none") {
|
|
8067
8067
|
wheelBehavior = inputMode === "trackpad" ? "pan" : "zoom";
|
|
8068
8068
|
}
|
|
8069
8069
|
if (wheelBehavior !== "none") {
|
|
@@ -8115,12 +8115,12 @@ class Editor extends import_eventemitter3.default {
|
|
|
8115
8115
|
}
|
|
8116
8116
|
case "pointer": {
|
|
8117
8117
|
if (inputs.getIsPinching()) return;
|
|
8118
|
-
this.inputs.updateFromEvent(info);
|
|
8119
8118
|
const { isPen } = info;
|
|
8120
8119
|
const { isPenMode } = instanceState;
|
|
8120
|
+
if (isPenMode && !isPen) return;
|
|
8121
|
+
this.inputs.updateFromEvent(info);
|
|
8121
8122
|
switch (info.name) {
|
|
8122
8123
|
case "pointer_down": {
|
|
8123
|
-
if (isPenMode && !isPen) return;
|
|
8124
8124
|
this._releaseDebouncedModifiers();
|
|
8125
8125
|
if (!this.inputs.getIsPanning()) {
|
|
8126
8126
|
this._longPressTimeout = this.timers.setTimeout(() => {
|
|
@@ -8149,7 +8149,7 @@ class Editor extends import_eventemitter3.default {
|
|
|
8149
8149
|
this.updateInstanceState({ isPenMode: true });
|
|
8150
8150
|
this.interrupt();
|
|
8151
8151
|
}
|
|
8152
|
-
if (info.button === import_constants.STYLUS_ERASER_BUTTON) {
|
|
8152
|
+
if (info.button === import_constants.STYLUS_ERASER_BUTTON && this.getStateDescendant("eraser")) {
|
|
8153
8153
|
this._restoreToolId = this.getCurrentToolId();
|
|
8154
8154
|
this.complete();
|
|
8155
8155
|
this.setCurrentTool("eraser");
|
|
@@ -8158,10 +8158,10 @@ class Editor extends import_eventemitter3.default {
|
|
|
8158
8158
|
this._prevCursor = this.getInstanceState().cursor.type;
|
|
8159
8159
|
}
|
|
8160
8160
|
this.inputs.setIsPanning(true);
|
|
8161
|
-
clearTimeout(this._longPressTimeout);
|
|
8161
|
+
this.timers.clearTimeout(this._longPressTimeout);
|
|
8162
8162
|
} else if (info.button === import_constants.RIGHT_MOUSE_BUTTON && this.options.rightClickPanning) {
|
|
8163
8163
|
this.inputs.setIsRightPointing(true);
|
|
8164
|
-
clearTimeout(this._longPressTimeout);
|
|
8164
|
+
this.timers.clearTimeout(this._longPressTimeout);
|
|
8165
8165
|
return this;
|
|
8166
8166
|
}
|
|
8167
8167
|
if (this.inputs.getIsPanning()) {
|
|
@@ -8172,7 +8172,6 @@ class Editor extends import_eventemitter3.default {
|
|
|
8172
8172
|
break;
|
|
8173
8173
|
}
|
|
8174
8174
|
case "pointer_move": {
|
|
8175
|
-
if (!isPen && isPenMode) return;
|
|
8176
8175
|
const { x: cx, y: cy, z: cz } = (0, import_state.unsafe__withoutCapture)(() => this.getCamera());
|
|
8177
8176
|
if (this.inputs.getIsRightPointing() && !this.inputs.getIsPanning()) {
|
|
8178
8177
|
const currentScreenPoint = this.inputs.getCurrentScreenPoint();
|
|
@@ -8203,16 +8202,15 @@ class Editor extends import_eventemitter3.default {
|
|
|
8203
8202
|
}
|
|
8204
8203
|
if (inputs.getIsPointing() && !inputs.getIsDragging() && import_Vec.Vec.Dist2(inputs.getOriginPagePoint(), inputs.getCurrentPagePoint()) * this.getZoomLevel() > (instanceState.isCoarsePointer ? this.options.coarseDragDistanceSquared : this.options.dragDistanceSquared) / cz) {
|
|
8205
8204
|
inputs.setIsDragging(true);
|
|
8206
|
-
clearTimeout(this._longPressTimeout);
|
|
8205
|
+
this.timers.clearTimeout(this._longPressTimeout);
|
|
8207
8206
|
}
|
|
8208
8207
|
break;
|
|
8209
8208
|
}
|
|
8210
8209
|
case "pointer_up": {
|
|
8211
8210
|
inputs.setIsDragging(false);
|
|
8212
8211
|
inputs.setIsPointing(false);
|
|
8213
|
-
clearTimeout(this._longPressTimeout);
|
|
8212
|
+
this.timers.clearTimeout(this._longPressTimeout);
|
|
8214
8213
|
inputs.buttons.delete(info.button);
|
|
8215
|
-
if (instanceState.isPenMode && !isPen) return;
|
|
8216
8214
|
if (this.inputs.getIsRightPointing() && !this.inputs.getIsPanning()) {
|
|
8217
8215
|
this.inputs.setIsRightPointing(false);
|
|
8218
8216
|
this._selectedShapeIdsAtPointerDown = [];
|
|
@@ -8268,7 +8266,7 @@ class Editor extends import_eventemitter3.default {
|
|
|
8268
8266
|
});
|
|
8269
8267
|
}
|
|
8270
8268
|
} else {
|
|
8271
|
-
if (info.button === import_constants.STYLUS_ERASER_BUTTON) {
|
|
8269
|
+
if (info.button === import_constants.STYLUS_ERASER_BUTTON && this.getStateDescendant("eraser")) {
|
|
8272
8270
|
this.complete();
|
|
8273
8271
|
this.setCurrentTool(this._restoreToolId);
|
|
8274
8272
|
}
|
|
@@ -8295,7 +8293,7 @@ class Editor extends import_eventemitter3.default {
|
|
|
8295
8293
|
}
|
|
8296
8294
|
this.inputs.setIsPanning(true);
|
|
8297
8295
|
this.inputs.setIsSpacebarPanning(true);
|
|
8298
|
-
clearTimeout(this._longPressTimeout);
|
|
8296
|
+
this.timers.clearTimeout(this._longPressTimeout);
|
|
8299
8297
|
this.setCursor({
|
|
8300
8298
|
type: this.inputs.getIsPointing() ? "grabbing" : "grab",
|
|
8301
8299
|
rotation: 0
|
|
@@ -8321,7 +8319,7 @@ class Editor extends import_eventemitter3.default {
|
|
|
8321
8319
|
break;
|
|
8322
8320
|
}
|
|
8323
8321
|
}
|
|
8324
|
-
if (offset) {
|
|
8322
|
+
if (offset && !cameraOptions.isLocked) {
|
|
8325
8323
|
const bounds = this.getViewportPageBounds();
|
|
8326
8324
|
const next = bounds.clone().translate(offset.mulV({ x: bounds.w, y: bounds.h }));
|
|
8327
8325
|
this._animateToViewport(next, { animation: { duration: 320 } });
|
|
@@ -8361,7 +8359,7 @@ class Editor extends import_eventemitter3.default {
|
|
|
8361
8359
|
this.setCurrentTool("select");
|
|
8362
8360
|
}
|
|
8363
8361
|
const { isPenMode } = this.store.unsafeGetWithoutCapture(import_tlschema.TLINSTANCE_ID);
|
|
8364
|
-
if (info.isPen
|
|
8362
|
+
if (!isPenMode || info.isPen) {
|
|
8365
8363
|
const clickInfo = this._clickManager.handlePointerEvent(info);
|
|
8366
8364
|
if (info.name !== clickInfo.name) {
|
|
8367
8365
|
this.root.handleEvent(info);
|
|
@@ -8383,7 +8381,7 @@ class Editor extends import_eventemitter3.default {
|
|
|
8383
8381
|
maybeTrackPerformance(name) {
|
|
8384
8382
|
if (import_debug_flags.debugFlags.measurePerformance.get()) {
|
|
8385
8383
|
if (this.performanceTracker.isStarted()) {
|
|
8386
|
-
clearTimeout(this.performanceTrackerTimeout);
|
|
8384
|
+
this.timers.clearTimeout(this.performanceTrackerTimeout);
|
|
8387
8385
|
} else {
|
|
8388
8386
|
this.performanceTracker.start(name);
|
|
8389
8387
|
}
|