@tldraw/editor 4.4.0 → 4.5.0-canary.034ea85352da
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 +67 -49
- package/dist-cjs/index.js +4 -7
- package/dist-cjs/index.js.map +2 -2
- package/dist-cjs/lib/TldrawEditor.js +4 -3
- package/dist-cjs/lib/TldrawEditor.js.map +2 -2
- package/dist-cjs/lib/components/ErrorBoundary.js.map +1 -1
- package/dist-cjs/lib/components/LiveCollaborators.js +2 -2
- package/dist-cjs/lib/components/LiveCollaborators.js.map +2 -2
- package/dist-cjs/lib/components/Shape.js +2 -2
- package/dist-cjs/lib/components/Shape.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultCanvas.js +15 -15
- package/dist-cjs/lib/components/default-components/DefaultCanvas.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultErrorFallback.js +5 -6
- package/dist-cjs/lib/components/default-components/DefaultErrorFallback.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultLoadingScreen.js +3 -4
- package/dist-cjs/lib/components/default-components/DefaultLoadingScreen.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultShapeIndicator.js +2 -2
- package/dist-cjs/lib/components/default-components/DefaultShapeIndicator.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultShapeIndicators.js +2 -2
- package/dist-cjs/lib/components/default-components/DefaultShapeIndicators.js.map +2 -2
- package/dist-cjs/lib/config/TLSessionStateSnapshot.js +3 -2
- package/dist-cjs/lib/config/TLSessionStateSnapshot.js.map +2 -2
- package/dist-cjs/lib/editor/Editor.js +12 -0
- package/dist-cjs/lib/editor/Editor.js.map +2 -2
- package/dist-cjs/lib/editor/bindings/BindingUtil.js.map +1 -1
- package/dist-cjs/lib/editor/derivations/bindingsIndex.js.map +1 -1
- package/dist-cjs/lib/editor/derivations/notVisibleShapes.js.map +1 -1
- package/dist-cjs/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.js.map +1 -1
- package/dist-cjs/lib/editor/managers/FontManager/FontManager.js.map +1 -1
- package/dist-cjs/lib/editor/managers/InputsManager/InputsManager.js.map +1 -1
- package/dist-cjs/lib/editor/managers/ScribbleManager/ScribbleManager.js.map +1 -1
- package/dist-cjs/lib/editor/managers/SnapManager/BoundsSnaps.js.map +1 -1
- package/dist-cjs/lib/editor/managers/SnapManager/HandleSnaps.js.map +1 -1
- package/dist-cjs/lib/editor/managers/TextManager/TextManager.js.map +1 -1
- package/dist-cjs/lib/editor/managers/TickManager/TickManager.js.map +1 -1
- package/dist-cjs/lib/editor/shapes/shared/resizeBox.js.map +1 -1
- package/dist-cjs/lib/editor/tools/BaseBoxShapeTool/children/Pointing.js.map +1 -1
- package/dist-cjs/lib/editor/types/SvgExportContext.js.map +1 -1
- package/dist-cjs/lib/exports/exportToSvg.js.map +1 -1
- package/dist-cjs/lib/exports/getSvgJsx.js.map +1 -1
- package/dist-cjs/lib/{utils/hardResetEditor.js → hooks/EditorComponentsContext.js} +14 -8
- package/dist-cjs/lib/hooks/EditorComponentsContext.js.map +7 -0
- package/dist-cjs/lib/hooks/useCanvasEvents.js +10 -2
- package/dist-cjs/lib/hooks/useCanvasEvents.js.map +2 -2
- package/dist-cjs/lib/hooks/useEditor.js.map +1 -1
- package/dist-cjs/lib/hooks/useEditorComponents.js +4 -10
- package/dist-cjs/lib/hooks/useEditorComponents.js.map +3 -3
- package/dist-cjs/lib/options.js +2 -1
- package/dist-cjs/lib/options.js.map +2 -2
- package/dist-cjs/lib/primitives/Vec.js +10 -5
- package/dist-cjs/lib/primitives/Vec.js.map +2 -2
- package/dist-cjs/lib/utils/areShapesContentEqual.js +3 -1
- package/dist-cjs/lib/utils/areShapesContentEqual.js.map +2 -2
- package/dist-cjs/lib/utils/assets.js +4 -6
- package/dist-cjs/lib/utils/assets.js.map +2 -2
- package/dist-cjs/lib/utils/browserCanvasMaxSize.js +1 -2
- package/dist-cjs/lib/utils/browserCanvasMaxSize.js.map +2 -2
- package/dist-cjs/lib/utils/debug-flags.js.map +2 -2
- package/dist-cjs/lib/utils/deepLinks.js.map +1 -1
- package/dist-cjs/lib/utils/dom.js +3 -3
- package/dist-cjs/lib/utils/dom.js.map +2 -2
- package/dist-cjs/lib/utils/getIncrementedName.js +1 -1
- package/dist-cjs/lib/utils/getIncrementedName.js.map +2 -2
- package/dist-cjs/lib/utils/getPointerInfo.js.map +2 -2
- package/dist-cjs/lib/utils/getSvgPathFromPoints.js.map +1 -1
- package/dist-cjs/lib/utils/keyboard.js +2 -2
- package/dist-cjs/lib/utils/keyboard.js.map +2 -2
- package/dist-cjs/lib/utils/normalizeWheel.js +2 -5
- package/dist-cjs/lib/utils/normalizeWheel.js.map +2 -2
- package/dist-cjs/lib/utils/reorderShapes.js +6 -6
- package/dist-cjs/lib/utils/reorderShapes.js.map +2 -2
- package/dist-cjs/lib/utils/reparenting.js +3 -4
- package/dist-cjs/lib/utils/reparenting.js.map +2 -2
- package/dist-cjs/lib/utils/richText.js.map +1 -1
- package/dist-cjs/lib/utils/rotation.js.map +1 -1
- package/dist-cjs/lib/utils/runtime.js +12 -0
- package/dist-cjs/lib/utils/runtime.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 +67 -49
- package/dist-esm/index.mjs +8 -5
- package/dist-esm/index.mjs.map +2 -2
- package/dist-esm/lib/TldrawEditor.mjs +2 -4
- package/dist-esm/lib/TldrawEditor.mjs.map +2 -2
- package/dist-esm/lib/components/ErrorBoundary.mjs.map +1 -1
- package/dist-esm/lib/components/LiveCollaborators.mjs +1 -1
- package/dist-esm/lib/components/LiveCollaborators.mjs.map +2 -2
- package/dist-esm/lib/components/Shape.mjs +1 -1
- package/dist-esm/lib/components/Shape.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultCanvas.mjs +1 -1
- package/dist-esm/lib/components/default-components/DefaultCanvas.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultErrorFallback.mjs +2 -3
- package/dist-esm/lib/components/default-components/DefaultErrorFallback.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultLoadingScreen.mjs +2 -3
- package/dist-esm/lib/components/default-components/DefaultLoadingScreen.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultShapeIndicator.mjs +1 -1
- package/dist-esm/lib/components/default-components/DefaultShapeIndicator.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultShapeIndicators.mjs +1 -1
- package/dist-esm/lib/components/default-components/DefaultShapeIndicators.mjs.map +2 -2
- package/dist-esm/lib/config/TLSessionStateSnapshot.mjs +3 -2
- package/dist-esm/lib/config/TLSessionStateSnapshot.mjs.map +2 -2
- package/dist-esm/lib/editor/Editor.mjs +12 -0
- package/dist-esm/lib/editor/Editor.mjs.map +2 -2
- package/dist-esm/lib/editor/bindings/BindingUtil.mjs.map +1 -1
- package/dist-esm/lib/editor/derivations/bindingsIndex.mjs.map +1 -1
- package/dist-esm/lib/editor/derivations/notVisibleShapes.mjs.map +1 -1
- package/dist-esm/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.mjs.map +1 -1
- package/dist-esm/lib/editor/managers/FontManager/FontManager.mjs.map +1 -1
- package/dist-esm/lib/editor/managers/InputsManager/InputsManager.mjs.map +1 -1
- package/dist-esm/lib/editor/managers/ScribbleManager/ScribbleManager.mjs.map +1 -1
- package/dist-esm/lib/editor/managers/SnapManager/BoundsSnaps.mjs.map +1 -1
- package/dist-esm/lib/editor/managers/SnapManager/HandleSnaps.mjs.map +1 -1
- package/dist-esm/lib/editor/managers/TextManager/TextManager.mjs.map +1 -1
- package/dist-esm/lib/editor/managers/TickManager/TickManager.mjs.map +1 -1
- package/dist-esm/lib/editor/shapes/shared/resizeBox.mjs.map +1 -1
- package/dist-esm/lib/editor/tools/BaseBoxShapeTool/children/Pointing.mjs.map +1 -1
- package/dist-esm/lib/editor/types/SvgExportContext.mjs.map +1 -1
- package/dist-esm/lib/exports/exportToSvg.mjs.map +1 -1
- package/dist-esm/lib/exports/getSvgJsx.mjs.map +1 -1
- package/dist-esm/lib/hooks/EditorComponentsContext.mjs +14 -0
- package/dist-esm/lib/hooks/EditorComponentsContext.mjs.map +7 -0
- package/dist-esm/lib/hooks/useCanvasEvents.mjs +10 -2
- package/dist-esm/lib/hooks/useCanvasEvents.mjs.map +2 -2
- package/dist-esm/lib/hooks/useEditor.mjs.map +1 -1
- package/dist-esm/lib/hooks/useEditorComponents.mjs +12 -36
- package/dist-esm/lib/hooks/useEditorComponents.mjs.map +2 -2
- package/dist-esm/lib/options.mjs +2 -1
- package/dist-esm/lib/options.mjs.map +2 -2
- package/dist-esm/lib/primitives/Vec.mjs +6 -1
- package/dist-esm/lib/primitives/Vec.mjs.map +2 -2
- package/dist-esm/lib/utils/areShapesContentEqual.mjs +3 -1
- package/dist-esm/lib/utils/areShapesContentEqual.mjs.map +2 -2
- package/dist-esm/lib/utils/assets.mjs +4 -6
- package/dist-esm/lib/utils/assets.mjs.map +2 -2
- package/dist-esm/lib/utils/browserCanvasMaxSize.mjs +1 -2
- package/dist-esm/lib/utils/browserCanvasMaxSize.mjs.map +2 -2
- package/dist-esm/lib/utils/debug-flags.mjs.map +2 -2
- package/dist-esm/lib/utils/deepLinks.mjs.map +1 -1
- package/dist-esm/lib/utils/dom.mjs +3 -3
- package/dist-esm/lib/utils/dom.mjs.map +2 -2
- package/dist-esm/lib/utils/getIncrementedName.mjs +1 -1
- package/dist-esm/lib/utils/getIncrementedName.mjs.map +2 -2
- package/dist-esm/lib/utils/getPointerInfo.mjs.map +2 -2
- package/dist-esm/lib/utils/getSvgPathFromPoints.mjs.map +1 -1
- package/dist-esm/lib/utils/keyboard.mjs +2 -2
- package/dist-esm/lib/utils/keyboard.mjs.map +2 -2
- package/dist-esm/lib/utils/normalizeWheel.mjs +2 -5
- package/dist-esm/lib/utils/normalizeWheel.mjs.map +2 -2
- package/dist-esm/lib/utils/reorderShapes.mjs +6 -6
- package/dist-esm/lib/utils/reorderShapes.mjs.map +2 -2
- package/dist-esm/lib/utils/reparenting.mjs +3 -4
- package/dist-esm/lib/utils/reparenting.mjs.map +2 -2
- package/dist-esm/lib/utils/richText.mjs.map +1 -1
- package/dist-esm/lib/utils/rotation.mjs.map +1 -1
- package/dist-esm/lib/utils/runtime.mjs +12 -0
- package/dist-esm/lib/utils/runtime.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 +7 -4
- package/src/lib/TldrawEditor.tsx +3 -5
- package/src/lib/components/ErrorBoundary.tsx +1 -1
- package/src/lib/components/LiveCollaborators.tsx +1 -1
- package/src/lib/components/Shape.tsx +1 -1
- package/src/lib/components/default-components/DefaultCanvas.tsx +1 -1
- package/src/lib/components/default-components/DefaultErrorFallback.tsx +2 -3
- package/src/lib/components/default-components/DefaultLoadingScreen.tsx +6 -3
- package/src/lib/components/default-components/DefaultShapeIndicator.tsx +1 -1
- package/src/lib/components/default-components/DefaultShapeIndicators.tsx +1 -1
- package/src/lib/config/TLSessionStateSnapshot.ts +3 -2
- package/src/lib/editor/Editor.ts +16 -0
- package/src/lib/editor/bindings/BindingUtil.ts +1 -1
- package/src/lib/editor/derivations/bindingsIndex.ts +1 -1
- package/src/lib/editor/derivations/notVisibleShapes.ts +1 -1
- package/src/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.ts +1 -1
- package/src/lib/editor/managers/FontManager/FontManager.ts +1 -1
- package/src/lib/editor/managers/InputsManager/InputsManager.ts +1 -1
- package/src/lib/editor/managers/ScribbleManager/ScribbleManager.ts +1 -1
- package/src/lib/editor/managers/SnapManager/BoundsSnaps.ts +2 -2
- package/src/lib/editor/managers/SnapManager/HandleSnaps.ts +2 -2
- package/src/lib/editor/managers/TextManager/TextManager.ts +1 -1
- package/src/lib/editor/managers/TickManager/TickManager.ts +1 -1
- package/src/lib/editor/shapes/shared/resizeBox.ts +1 -1
- package/src/lib/editor/tools/BaseBoxShapeTool/children/Pointing.ts +2 -2
- package/src/lib/editor/types/SvgExportContext.tsx +1 -1
- package/src/lib/exports/exportToSvg.tsx +1 -1
- package/src/lib/exports/getSvgJsx.tsx +1 -1
- package/src/lib/hooks/EditorComponentsContext.tsx +63 -0
- package/src/lib/hooks/useCanvasEvents.ts +13 -2
- package/src/lib/hooks/useEditor.tsx +1 -1
- package/src/lib/hooks/useEditorComponents.tsx +20 -89
- package/src/lib/options.ts +11 -0
- package/src/lib/primitives/Vec.ts +7 -1
- package/src/lib/utils/areShapesContentEqual.ts +9 -2
- package/src/lib/utils/assets.ts +15 -10
- package/src/lib/utils/browserCanvasMaxSize.ts +4 -2
- package/src/lib/utils/debug-flags.ts +0 -20
- package/src/lib/utils/deepLinks.ts +1 -1
- package/src/lib/utils/dom.ts +6 -7
- package/src/lib/utils/getIncrementedName.ts +1 -1
- package/src/lib/utils/getPointerInfo.ts +1 -0
- package/src/lib/utils/getSvgPathFromPoints.ts +1 -1
- package/src/lib/utils/keyboard.ts +6 -4
- package/src/lib/utils/normalizeWheel.ts +8 -8
- package/src/lib/utils/reorderShapes.ts +17 -8
- package/src/lib/utils/reparenting.ts +5 -10
- package/src/lib/utils/richText.ts +1 -1
- package/src/lib/utils/rotation.ts +1 -1
- package/src/lib/utils/runtime.ts +26 -1
- package/src/version.ts +3 -3
- package/dist-cjs/lib/utils/hardResetEditor.js.map +0 -7
- package/dist-cjs/lib/utils/refreshPage.js +0 -28
- package/dist-cjs/lib/utils/refreshPage.js.map +0 -7
- package/dist-cjs/lib/utils/window-open.js +0 -28
- package/dist-cjs/lib/utils/window-open.js.map +0 -7
- package/dist-esm/lib/utils/hardResetEditor.mjs +0 -8
- package/dist-esm/lib/utils/hardResetEditor.mjs.map +0 -7
- package/dist-esm/lib/utils/refreshPage.mjs +0 -8
- package/dist-esm/lib/utils/refreshPage.mjs.map +0 -7
- package/dist-esm/lib/utils/window-open.mjs +0 -8
- package/dist-esm/lib/utils/window-open.mjs.map +0 -7
- package/src/lib/utils/hardResetEditor.ts +0 -6
- package/src/lib/utils/refreshPage.ts +0 -6
- package/src/lib/utils/window-open.ts +0 -16
|
@@ -1,90 +1,30 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ReactNode, useMemo } from 'react'
|
|
2
2
|
import { DefaultBackground } from '../components/default-components/DefaultBackground'
|
|
3
|
-
import { DefaultBrush
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from '../components/default-components/
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
} from '../components/default-components/DefaultCollaboratorHint'
|
|
12
|
-
import { DefaultCursor, TLCursorProps } from '../components/default-components/DefaultCursor'
|
|
13
|
-
import {
|
|
14
|
-
DefaultErrorFallback,
|
|
15
|
-
TLErrorFallbackComponent,
|
|
16
|
-
} from '../components/default-components/DefaultErrorFallback'
|
|
17
|
-
import { DefaultGrid, TLGridProps } from '../components/default-components/DefaultGrid'
|
|
18
|
-
import { DefaultHandle, TLHandleProps } from '../components/default-components/DefaultHandle'
|
|
19
|
-
import { DefaultHandles, TLHandlesProps } from '../components/default-components/DefaultHandles'
|
|
3
|
+
import { DefaultBrush } from '../components/default-components/DefaultBrush'
|
|
4
|
+
import { DefaultCanvas } from '../components/default-components/DefaultCanvas'
|
|
5
|
+
import { DefaultCollaboratorHint } from '../components/default-components/DefaultCollaboratorHint'
|
|
6
|
+
import { DefaultCursor } from '../components/default-components/DefaultCursor'
|
|
7
|
+
import { DefaultErrorFallback } from '../components/default-components/DefaultErrorFallback'
|
|
8
|
+
import { DefaultGrid } from '../components/default-components/DefaultGrid'
|
|
9
|
+
import { DefaultHandle } from '../components/default-components/DefaultHandle'
|
|
10
|
+
import { DefaultHandles } from '../components/default-components/DefaultHandles'
|
|
20
11
|
import { DefaultLoadingScreen } from '../components/default-components/DefaultLoadingScreen'
|
|
21
|
-
import { DefaultScribble
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
} from '../components/default-components/DefaultSelectionForeground'
|
|
27
|
-
import {
|
|
28
|
-
DefaultShapeErrorFallback,
|
|
29
|
-
TLShapeErrorFallbackComponent,
|
|
30
|
-
} from '../components/default-components/DefaultShapeErrorFallback'
|
|
31
|
-
import {
|
|
32
|
-
DefaultShapeIndicator,
|
|
33
|
-
TLShapeIndicatorProps,
|
|
34
|
-
} from '../components/default-components/DefaultShapeIndicator'
|
|
35
|
-
import {
|
|
36
|
-
DefaultShapeIndicatorErrorFallback,
|
|
37
|
-
TLShapeIndicatorErrorFallbackComponent,
|
|
38
|
-
} from '../components/default-components/DefaultShapeIndicatorErrorFallback'
|
|
12
|
+
import { DefaultScribble } from '../components/default-components/DefaultScribble'
|
|
13
|
+
import { DefaultSelectionForeground } from '../components/default-components/DefaultSelectionForeground'
|
|
14
|
+
import { DefaultShapeErrorFallback } from '../components/default-components/DefaultShapeErrorFallback'
|
|
15
|
+
import { DefaultShapeIndicator } from '../components/default-components/DefaultShapeIndicator'
|
|
16
|
+
import { DefaultShapeIndicatorErrorFallback } from '../components/default-components/DefaultShapeIndicatorErrorFallback'
|
|
39
17
|
import { DefaultShapeIndicators } from '../components/default-components/DefaultShapeIndicators'
|
|
40
|
-
import {
|
|
41
|
-
|
|
42
|
-
TLShapeWrapperProps,
|
|
43
|
-
} from '../components/default-components/DefaultShapeWrapper'
|
|
44
|
-
import {
|
|
45
|
-
DefaultSnapIndicator,
|
|
46
|
-
TLSnapIndicatorProps,
|
|
47
|
-
} from '../components/default-components/DefaultSnapIndictor'
|
|
18
|
+
import { DefaultShapeWrapper } from '../components/default-components/DefaultShapeWrapper'
|
|
19
|
+
import { DefaultSnapIndicator } from '../components/default-components/DefaultSnapIndictor'
|
|
48
20
|
import { DefaultSpinner } from '../components/default-components/DefaultSpinner'
|
|
49
21
|
import { DefaultSvgDefs } from '../components/default-components/DefaultSvgDefs'
|
|
22
|
+
import type { TLEditorComponents } from './EditorComponentsContext'
|
|
23
|
+
import { EditorComponentsContext } from './EditorComponentsContext'
|
|
50
24
|
import { useShallowObjectIdentity } from './useIdentity'
|
|
51
25
|
|
|
52
|
-
|
|
53
|
-
export
|
|
54
|
-
Background?: ComponentType | null
|
|
55
|
-
Brush?: ComponentType<TLBrushProps> | null
|
|
56
|
-
Canvas?: ComponentType<TLCanvasComponentProps> | null
|
|
57
|
-
CollaboratorBrush?: ComponentType<TLBrushProps> | null
|
|
58
|
-
CollaboratorCursor?: ComponentType<TLCursorProps> | null
|
|
59
|
-
CollaboratorHint?: ComponentType<TLCollaboratorHintProps> | null
|
|
60
|
-
CollaboratorScribble?: ComponentType<TLScribbleProps> | null
|
|
61
|
-
CollaboratorShapeIndicator?: ComponentType<TLShapeIndicatorProps> | null
|
|
62
|
-
Cursor?: ComponentType<TLCursorProps> | null
|
|
63
|
-
Grid?: ComponentType<TLGridProps> | null
|
|
64
|
-
Handle?: ComponentType<TLHandleProps> | null
|
|
65
|
-
Handles?: ComponentType<TLHandlesProps> | null
|
|
66
|
-
InFrontOfTheCanvas?: ComponentType | null
|
|
67
|
-
LoadingScreen?: ComponentType | null
|
|
68
|
-
OnTheCanvas?: ComponentType | null
|
|
69
|
-
Overlays?: ComponentType | null
|
|
70
|
-
Scribble?: ComponentType<TLScribbleProps> | null
|
|
71
|
-
SelectionBackground?: ComponentType<TLSelectionBackgroundProps> | null
|
|
72
|
-
SelectionForeground?: ComponentType<TLSelectionForegroundProps> | null
|
|
73
|
-
ShapeIndicator?: ComponentType<TLShapeIndicatorProps> | null
|
|
74
|
-
ShapeIndicators?: ComponentType | null
|
|
75
|
-
ShapeWrapper?: ComponentType<TLShapeWrapperProps & RefAttributes<HTMLDivElement>> | null
|
|
76
|
-
SnapIndicator?: ComponentType<TLSnapIndicatorProps> | null
|
|
77
|
-
Spinner?: ComponentType<React.SVGProps<SVGSVGElement>> | null
|
|
78
|
-
SvgDefs?: ComponentType | null
|
|
79
|
-
ZoomBrush?: ComponentType<TLBrushProps> | null
|
|
80
|
-
|
|
81
|
-
// These will always have defaults
|
|
82
|
-
ErrorFallback?: TLErrorFallbackComponent
|
|
83
|
-
ShapeErrorFallback?: TLShapeErrorFallbackComponent
|
|
84
|
-
ShapeIndicatorErrorFallback?: TLShapeIndicatorErrorFallbackComponent
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const EditorComponentsContext = createContext<null | Required<TLEditorComponents>>(null)
|
|
26
|
+
export { useEditorComponents } from './EditorComponentsContext'
|
|
27
|
+
export type { TLEditorComponents } from './EditorComponentsContext'
|
|
88
28
|
|
|
89
29
|
interface ComponentsContextProviderProps {
|
|
90
30
|
overrides?: TLEditorComponents
|
|
@@ -138,12 +78,3 @@ export function EditorComponentsProvider({
|
|
|
138
78
|
<EditorComponentsContext.Provider value={value}>{children}</EditorComponentsContext.Provider>
|
|
139
79
|
)
|
|
140
80
|
}
|
|
141
|
-
|
|
142
|
-
/** @public */
|
|
143
|
-
export function useEditorComponents() {
|
|
144
|
-
const components = useContext(EditorComponentsContext)
|
|
145
|
-
if (!components) {
|
|
146
|
-
throw new Error('useEditorComponents must be used inside of <EditorComponentsProvider />')
|
|
147
|
-
}
|
|
148
|
-
return components
|
|
149
|
-
}
|
package/src/lib/options.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ComponentType, Fragment } from 'react'
|
|
2
2
|
import { DEFAULT_CAMERA_OPTIONS } from './constants'
|
|
3
3
|
import { TLCameraOptions } from './editor/types/misc-types'
|
|
4
|
+
import { VecLike } from './primitives/Vec'
|
|
4
5
|
import { TLDeepLinkOptions } from './utils/deepLinks'
|
|
5
6
|
import { TLTextOptions } from './utils/richText'
|
|
6
7
|
|
|
@@ -155,6 +156,15 @@ export interface TldrawOptions {
|
|
|
155
156
|
* viewport's page dimensions regardless of overview zoom changes.
|
|
156
157
|
*/
|
|
157
158
|
readonly quickZoomPreservesScreenBounds: boolean
|
|
159
|
+
/**
|
|
160
|
+
* Called when content is dropped on the canvas. Provides the page position
|
|
161
|
+
* where the drop occurred and the underlying drag event object.
|
|
162
|
+
* Return true to prevent default drop handling (files, URLs, etc.)
|
|
163
|
+
*/
|
|
164
|
+
experimental__onDropOnCanvas?(options: {
|
|
165
|
+
point: VecLike
|
|
166
|
+
event: React.DragEvent<Element>
|
|
167
|
+
}): boolean
|
|
158
168
|
}
|
|
159
169
|
|
|
160
170
|
/** @public */
|
|
@@ -217,4 +227,5 @@ export const defaultTldrawOptions = {
|
|
|
217
227
|
text: {},
|
|
218
228
|
deepLinks: undefined,
|
|
219
229
|
quickZoomPreservesScreenBounds: true,
|
|
230
|
+
experimental__onDropOnCanvas: undefined,
|
|
220
231
|
} as const satisfies TldrawOptions
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { VecModel } from '@tldraw/tlschema'
|
|
2
2
|
import { EASINGS } from './easings'
|
|
3
|
-
|
|
3
|
+
function clamp(n: number, min: number, max?: number): number {
|
|
4
|
+
return Math.max(min, typeof max !== 'undefined' ? Math.min(n, max) : n)
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
function toFixed(v: number) {
|
|
8
|
+
return Math.round(v * 1e2) / 1e2
|
|
9
|
+
}
|
|
4
10
|
|
|
5
11
|
/** @public */
|
|
6
12
|
export type VecLike = Vec | VecModel
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { TLShape } from '@tldraw/tlschema'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Checks if two shapes are equal by comparing their props and meta.
|
|
5
|
+
* @param a - The first shape.
|
|
6
|
+
* @param b - The second shape.
|
|
7
|
+
* @returns True if the shapes are equal, false otherwise.
|
|
8
|
+
*/
|
|
9
|
+
export function areShapesContentEqual(a: TLShape, b: TLShape) {
|
|
10
|
+
return a.props === b.props && a.meta === b.meta
|
|
11
|
+
}
|
package/src/lib/utils/assets.ts
CHANGED
|
@@ -1,21 +1,26 @@
|
|
|
1
1
|
import { fetch } from '@tldraw/utils'
|
|
2
2
|
import { version } from '../../version'
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Converts a data URL to a file.
|
|
6
|
+
* @param url - The data URL to convert.
|
|
7
|
+
* @param filename - The name of the file.
|
|
8
|
+
* @param mimeType - The MIME type of the file.
|
|
9
|
+
* @returns A promise that resolves to a file.
|
|
10
|
+
* @public */
|
|
11
|
+
export async function dataUrlToFile(url: string, filename: string, mimeType: string) {
|
|
12
|
+
const res = await fetch(url)
|
|
13
|
+
const buf = await res.arrayBuffer()
|
|
14
|
+
return new File([buf], filename, { type: mimeType })
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
/** @internal */
|
|
16
18
|
const CDN_BASE_URL = 'https://cdn.tldraw.com'
|
|
17
19
|
|
|
18
|
-
/**
|
|
20
|
+
/**
|
|
21
|
+
* Gets the default CDN base URL.
|
|
22
|
+
* @returns The default CDN base URL.
|
|
23
|
+
* @public */
|
|
19
24
|
export function getDefaultCdnBaseUrl() {
|
|
20
25
|
return `${CDN_BASE_URL}/${version}`
|
|
21
26
|
}
|
|
@@ -90,8 +90,10 @@ const TEST_SIZES = {
|
|
|
90
90
|
/**
|
|
91
91
|
* Tests ability to read pixel data from canvas elements of various dimensions
|
|
92
92
|
* by decreasing canvas height and/or width until a test succeeds.
|
|
93
|
+
* @param dimension - The dimension to test.
|
|
94
|
+
* @returns The maximum size of the canvas for the given dimension.
|
|
93
95
|
*/
|
|
94
|
-
|
|
96
|
+
function getCanvasSize(dimension: 'width' | 'height' | 'area'): number {
|
|
95
97
|
const cropCvs = document.createElement('canvas')
|
|
96
98
|
cropCvs.width = 1
|
|
97
99
|
cropCvs.height = 1
|
|
@@ -135,7 +137,7 @@ export function getCanvasSize(dimension: 'width' | 'height' | 'area') {
|
|
|
135
137
|
}
|
|
136
138
|
|
|
137
139
|
/** @internal */
|
|
138
|
-
export function clampToBrowserMaxCanvasSize(width: number, height: number) {
|
|
140
|
+
export function clampToBrowserMaxCanvasSize(width: number, height: number): [number, number] {
|
|
139
141
|
if (
|
|
140
142
|
width <= MAX_SAFE_CANVAS_DIMENSION &&
|
|
141
143
|
height <= MAX_SAFE_CANVAS_DIMENSION &&
|
|
@@ -57,12 +57,6 @@ export const debugFlags = {
|
|
|
57
57
|
debugElbowArrows: createDebugValue('debugElbowArrows', { defaults: { all: false } }),
|
|
58
58
|
} as const
|
|
59
59
|
|
|
60
|
-
declare global {
|
|
61
|
-
interface Window {
|
|
62
|
-
tldrawLog(message: any): void
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
60
|
// --- 2. USE ---
|
|
67
61
|
// In normal code, read from debug flags directly by calling .value on them:
|
|
68
62
|
// if (debugFlags.preventDefaultLogging.value) { ... }
|
|
@@ -107,20 +101,6 @@ export function createDebugValue<T>(
|
|
|
107
101
|
})
|
|
108
102
|
}
|
|
109
103
|
|
|
110
|
-
// function createFeatureFlag<T>(
|
|
111
|
-
// name: string,
|
|
112
|
-
// {
|
|
113
|
-
// defaults,
|
|
114
|
-
// shouldStoreForSession = true,
|
|
115
|
-
// }: { defaults: DebugFlagDefaults<T>; shouldStoreForSession?: boolean }
|
|
116
|
-
// ) {
|
|
117
|
-
// return createDebugValueBase({
|
|
118
|
-
// name,
|
|
119
|
-
// defaults,
|
|
120
|
-
// shouldStoreForSession,
|
|
121
|
-
// })
|
|
122
|
-
// }
|
|
123
|
-
|
|
124
104
|
function createDebugValueBase<T>(def: DebugFlagDef<T>): DebugFlag<T> {
|
|
125
105
|
const defaultValue = getDefaultValue(def)
|
|
126
106
|
const storedValue = def.shouldStoreForSession
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BoxModel, PageRecordType, TLPageId, TLShapeId, createShapeId } from '@tldraw/tlschema'
|
|
2
2
|
import { exhaustiveSwitchError } from '@tldraw/utils'
|
|
3
|
-
import { Editor } from '../editor/Editor'
|
|
3
|
+
import type { Editor } from '../editor/Editor'
|
|
4
4
|
import { Box } from '../primitives/Box'
|
|
5
5
|
|
|
6
6
|
/** @public */
|
package/src/lib/utils/dom.ts
CHANGED
|
@@ -3,7 +3,7 @@ This is used to facilitate double clicking and pointer capture on elements.
|
|
|
3
3
|
|
|
4
4
|
The events in this file are possibly set on individual SVG elements,
|
|
5
5
|
such as handles or corner handles, rather than on HTML elements or
|
|
6
|
-
SVGSVGElements. Raw SVG
|
|
6
|
+
SVGSVGElements. Raw SVG elements do not support pointerCapture in
|
|
7
7
|
most cases, meaning that in order for pointer capture to work, we
|
|
8
8
|
need to crawl up the DOM tree to find the nearest HTML element. Then,
|
|
9
9
|
in order for that element to also call the `onPointerUp` event from
|
|
@@ -13,7 +13,6 @@ if the user clicks on a handle but the pointerup does not fire for
|
|
|
13
13
|
whatever reason.
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
-
import React from 'react'
|
|
17
16
|
import { debugFlags, pointerCaptureTrackingObject } from './debug-flags'
|
|
18
17
|
|
|
19
18
|
/** @public */
|
|
@@ -26,10 +25,10 @@ export function loopToHtmlElement(elm: Element): HTMLElement {
|
|
|
26
25
|
/**
|
|
27
26
|
* This function calls `event.preventDefault()` for you. Why is that useful?
|
|
28
27
|
*
|
|
29
|
-
*
|
|
28
|
+
* Because if you enable `window.preventDefaultLogging = true` it'll log out a message when it
|
|
30
29
|
* happens. Because we use console.warn rather than (log) you'll get a stack trace in the inspector
|
|
31
30
|
* telling you exactly where it happened. This is important because `e.preventDefault()` is the
|
|
32
|
-
* source of many bugs, but
|
|
31
|
+
* source of many bugs, but unfortunately it can't be avoided because it also stops a lot of default
|
|
33
32
|
* behaviour which doesn't make sense in our UI
|
|
34
33
|
*
|
|
35
34
|
* @param event - To prevent default on
|
|
@@ -95,13 +94,13 @@ export const setStyleProperty = (
|
|
|
95
94
|
value: string | number
|
|
96
95
|
) => {
|
|
97
96
|
if (!elm) return
|
|
98
|
-
elm.style.setProperty(property, value
|
|
97
|
+
elm.style.setProperty(property, String(value))
|
|
99
98
|
}
|
|
100
99
|
|
|
101
100
|
/** @internal */
|
|
102
|
-
export function activeElementShouldCaptureKeys(
|
|
101
|
+
export function activeElementShouldCaptureKeys(ignoreButtons = false) {
|
|
103
102
|
const { activeElement } = document
|
|
104
|
-
const elements =
|
|
103
|
+
const elements = ignoreButtons ? ['input', 'textarea'] : ['input', 'select', 'button', 'textarea']
|
|
105
104
|
return !!(
|
|
106
105
|
activeElement &&
|
|
107
106
|
((activeElement as HTMLElement).isContentEditable ||
|
|
@@ -12,7 +12,7 @@ export function getIncrementedName(name: string, others: string[]) {
|
|
|
12
12
|
|
|
13
13
|
while (set.has(result)) {
|
|
14
14
|
result = /^.*(\d+)$/.exec(result)?.[1]
|
|
15
|
-
? result.replace(/(\d+)
|
|
15
|
+
? result.replace(/(\d+)$/, (m) => {
|
|
16
16
|
return (+m + 1).toString()
|
|
17
17
|
})
|
|
18
18
|
: `${result} 1`
|
|
@@ -2,7 +2,7 @@ import { VecLike } from '../primitives/Vec'
|
|
|
2
2
|
import { average, precise } from '../primitives/utils'
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* Turn an array of points into a path of
|
|
5
|
+
* Turn an array of points into a path of quadratic curves.
|
|
6
6
|
*
|
|
7
7
|
* @param points - The points returned from perfect-freehand
|
|
8
8
|
* @param closed - Whether the stroke is closed
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { tlenv } from '../globals/environment'
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Checks if the accelerator key is pressed.
|
|
5
|
+
* @param e - The event to check.
|
|
6
|
+
* @returns True if the accelerator key is pressed, false otherwise.
|
|
7
|
+
* @internal */
|
|
8
|
+
export function isAccelKey(e: { metaKey: boolean; ctrlKey: boolean }) {
|
|
7
9
|
return tlenv.isDarwin ? e.metaKey : e.ctrlKey || e.metaKey
|
|
8
10
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
import { tlenv } from '../globals/environment'
|
|
2
|
+
|
|
2
3
|
const MAX_ZOOM_STEP = 10
|
|
3
|
-
const IS_DARWIN = /Mac|iPod|iPhone|iPad/.test(
|
|
4
|
-
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
5
|
-
typeof window === 'undefined' ? 'node' : window.navigator.platform
|
|
6
|
-
)
|
|
7
4
|
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Normalizes a wheel event, so that the delta values are consistent across different browsers or devices. Adapted from https://stackoverflow.com/a/13650579.
|
|
7
|
+
* @param event - The wheel event to normalize.
|
|
8
|
+
* @returns The normalized wheel event.
|
|
9
|
+
* @internal */
|
|
10
10
|
export function normalizeWheel(event: WheelEvent | React.WheelEvent<HTMLElement>) {
|
|
11
11
|
let { deltaY, deltaX } = event
|
|
12
12
|
let deltaZ = 0
|
|
@@ -15,7 +15,7 @@ export function normalizeWheel(event: WheelEvent | React.WheelEvent<HTMLElement>
|
|
|
15
15
|
if (event.ctrlKey || event.altKey || event.metaKey) {
|
|
16
16
|
deltaZ = (Math.abs(deltaY) > MAX_ZOOM_STEP ? MAX_ZOOM_STEP * Math.sign(deltaY) : deltaY) / 100
|
|
17
17
|
} else {
|
|
18
|
-
if (event.shiftKey && !
|
|
18
|
+
if (event.shiftKey && !tlenv.isDarwin && !tlenv.isIos) {
|
|
19
19
|
deltaX = deltaY
|
|
20
20
|
deltaY = 0
|
|
21
21
|
}
|
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import { TLParentId, TLShape, TLShapeId, TLShapePartial } from '@tldraw/tlschema'
|
|
2
2
|
import { IndexKey, compact, getIndicesBetween, sortByIndex } from '@tldraw/utils'
|
|
3
|
-
import { Editor } from '../editor/Editor'
|
|
3
|
+
import type { Editor } from '../editor/Editor'
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Gets the changes for reordering shapes.
|
|
7
|
+
* @param editor - The editor.
|
|
8
|
+
* @param operation - The operation to perform.
|
|
9
|
+
* @param ids - The ids of the shapes to reorder.
|
|
10
|
+
* @param opts - The options.
|
|
11
|
+
* @returns The changes.
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
5
14
|
export function getReorderingShapesChanges(
|
|
6
15
|
editor: Editor,
|
|
7
16
|
operation: 'toBack' | 'toFront' | 'forward' | 'backward',
|
|
@@ -160,7 +169,7 @@ function getOverlapChecker(editor: Editor, moving: Set<TLShape>) {
|
|
|
160
169
|
return { shape, bounds }
|
|
161
170
|
})
|
|
162
171
|
)
|
|
163
|
-
const
|
|
172
|
+
const isContaining = (child: TLShape) => {
|
|
164
173
|
const bounds = editor.getShapePageBounds(child)
|
|
165
174
|
if (!bounds) return false
|
|
166
175
|
return movingBounds.some((other) => {
|
|
@@ -168,7 +177,7 @@ function getOverlapChecker(editor: Editor, moving: Set<TLShape>) {
|
|
|
168
177
|
})
|
|
169
178
|
}
|
|
170
179
|
|
|
171
|
-
return
|
|
180
|
+
return isContaining
|
|
172
181
|
}
|
|
173
182
|
|
|
174
183
|
/**
|
|
@@ -187,7 +196,7 @@ function reorderForward(
|
|
|
187
196
|
changes: TLShapePartial[],
|
|
188
197
|
opts?: { considerAllShapes?: boolean }
|
|
189
198
|
) {
|
|
190
|
-
const
|
|
199
|
+
const isContaining = getOverlapChecker(editor, moving)
|
|
191
200
|
|
|
192
201
|
const len = children.length
|
|
193
202
|
|
|
@@ -211,7 +220,7 @@ function reorderForward(
|
|
|
211
220
|
}
|
|
212
221
|
case 'selecting': {
|
|
213
222
|
if (isMoving) continue
|
|
214
|
-
if (!opts?.considerAllShapes && !
|
|
223
|
+
if (!opts?.considerAllShapes && !isContaining(children[i])) continue
|
|
215
224
|
// if we find a non-moving and overlapping shape while selecting, move all selected
|
|
216
225
|
// shapes in front of the not moving shape; and start skipping
|
|
217
226
|
const { selectIndex } = state
|
|
@@ -246,7 +255,7 @@ function reorderBackward(
|
|
|
246
255
|
changes: TLShapePartial[],
|
|
247
256
|
opts?: { considerAllShapes?: boolean }
|
|
248
257
|
) {
|
|
249
|
-
const
|
|
258
|
+
const isContaining = getOverlapChecker(editor, moving)
|
|
250
259
|
|
|
251
260
|
const len = children.length
|
|
252
261
|
|
|
@@ -269,9 +278,9 @@ function reorderBackward(
|
|
|
269
278
|
}
|
|
270
279
|
case 'selecting': {
|
|
271
280
|
if (isMoving) continue
|
|
272
|
-
if (!opts?.considerAllShapes && !
|
|
281
|
+
if (!opts?.considerAllShapes && !isContaining(children[i])) continue
|
|
273
282
|
// if we find a non-moving and overlapping shape while selecting, move all selected
|
|
274
|
-
// shapes
|
|
283
|
+
// shapes behind the non-moving shape; and start skipping
|
|
275
284
|
getIndicesBetween(children[i - 1]?.index, children[i].index, state.selectIndex - i).forEach(
|
|
276
285
|
(index, k) => {
|
|
277
286
|
const child = children[i + k + 1]
|
|
@@ -6,7 +6,6 @@ import { intersectPolygonPolygon } from '../primitives/intersect'
|
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Reparents shapes that are no longer contained within their parent shapes.
|
|
9
|
-
* todo: rename me to something more descriptive, like `reparentOccludedShapes` or `reparentAutoDroppedShapes`
|
|
10
9
|
*
|
|
11
10
|
* @param editor - The editor instance.
|
|
12
11
|
* @param shapeIds - The IDs of the shapes to reparent.
|
|
@@ -62,9 +61,6 @@ export function kickoutOccludedShapes(
|
|
|
62
61
|
for (const [prevParent, lostChildrenIds] of parentsToLostChildren) {
|
|
63
62
|
const lostChildren = compact(lostChildrenIds.map((id) => editor.getShape(id)))
|
|
64
63
|
|
|
65
|
-
// Don't fall "up" into frames in front of the shape
|
|
66
|
-
// if (pageShapes.indexOf(shape) < frameSortPosition) continue shapeCheck
|
|
67
|
-
|
|
68
64
|
// Otherwise, we have no next dropping shape under the cursor, so go find
|
|
69
65
|
// all the frames on the page where the moving shapes will fall into
|
|
70
66
|
const { reparenting, remainingShapesToReparent } = getDroppedShapesToNewParents(
|
|
@@ -158,17 +154,16 @@ function getOverlappingShapes<T extends TLShape[] | TLShapeId[]>(
|
|
|
158
154
|
const parentPageBounds = editor.getShapePageBounds(shape)
|
|
159
155
|
if (!parentPageBounds) return EMPTY_ARRAY
|
|
160
156
|
|
|
157
|
+
const _shape = editor.getShape(shape)
|
|
158
|
+
if (!_shape) return EMPTY_ARRAY
|
|
159
|
+
|
|
161
160
|
const parentGeometry = editor.getShapeGeometry(shape)
|
|
162
161
|
const parentPageTransform = editor.getShapePageTransform(shape)
|
|
163
162
|
const parentPageCorners = parentPageTransform.applyToPoints(parentGeometry.vertices)
|
|
164
163
|
|
|
165
|
-
const _shape = editor.getShape(shape)
|
|
166
|
-
if (!_shape) return EMPTY_ARRAY
|
|
167
|
-
|
|
168
|
-
const pageTransform = editor.getShapePageTransform(shape)
|
|
169
164
|
const clipPath = editor.getShapeUtil(_shape.type).getClipPath?.(_shape)
|
|
170
165
|
|
|
171
|
-
const parentPageMaskVertices = clipPath ?
|
|
166
|
+
const parentPageMaskVertices = clipPath ? parentPageTransform.applyToPoints(clipPath) : undefined
|
|
172
167
|
const parentPagePolygon = parentPageMaskVertices
|
|
173
168
|
? intersectPolygonPolygon(parentPageMaskVertices, parentPageCorners)
|
|
174
169
|
: parentPageCorners
|
|
@@ -283,7 +278,7 @@ export function getDroppedShapesToNewParents(
|
|
|
283
278
|
// Are the shape and the parent part of different groups?
|
|
284
279
|
if (shapeGroupId !== parentShapeContainingGroupId) continue shapeCheck
|
|
285
280
|
|
|
286
|
-
// Is the shape
|
|
281
|
+
// Is the shape actually the ancestor of the parent?
|
|
287
282
|
if (editor.findShapeAncestor(parentShape, (s) => shape.id === s.id)) continue shapeCheck
|
|
288
283
|
|
|
289
284
|
// Convert the parent polygon to the shape's space
|
|
@@ -3,7 +3,7 @@ import { Node, Schema } from '@tiptap/pm/model'
|
|
|
3
3
|
import { EditorProviderProps } from '@tiptap/react'
|
|
4
4
|
import { TLRichText } from '@tldraw/tlschema'
|
|
5
5
|
import { assert, WeakCache } from '@tldraw/utils'
|
|
6
|
-
import { Editor } from '../editor/Editor'
|
|
6
|
+
import type { Editor } from '../editor/Editor'
|
|
7
7
|
import { TLFontFace } from '../editor/managers/FontManager/FontManager'
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isShapeId, TLShape, TLShapeId, TLShapePartial } from '@tldraw/tlschema'
|
|
2
2
|
import { compact } from '@tldraw/utils'
|
|
3
|
-
import { Editor } from '../editor/Editor'
|
|
3
|
+
import type { Editor } from '../editor/Editor'
|
|
4
4
|
import { Mat } from '../primitives/Mat'
|
|
5
5
|
import { canonicalizeRotation } from '../primitives/utils'
|
|
6
6
|
import { Vec, VecLike } from '../primitives/Vec'
|
package/src/lib/utils/runtime.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
export const runtime: {
|
|
3
3
|
openWindow(url: string, target: string, allowReferrer?: boolean): void
|
|
4
4
|
refreshPage(): void
|
|
5
|
-
hardReset(): void
|
|
5
|
+
hardReset(): Promise<void>
|
|
6
6
|
} = {
|
|
7
7
|
openWindow(url, target, allowReferrer = false) {
|
|
8
8
|
return window.open(url, target, allowReferrer ? 'noopener' : 'noopener noreferrer')
|
|
@@ -19,3 +19,28 @@ export const runtime: {
|
|
|
19
19
|
export function setRuntimeOverrides(input: Partial<typeof runtime>) {
|
|
20
20
|
Object.assign(runtime, input)
|
|
21
21
|
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Open a new window with the given URL and target. Prefer this to the window.open function, as it
|
|
25
|
+
* will work more reliably in embedded scenarios, such as our VS Code extension. See the runtime
|
|
26
|
+
* object in tldraw/editor for more details.
|
|
27
|
+
*
|
|
28
|
+
* @param url - The URL to open.
|
|
29
|
+
* @param target - The target window to open the URL in.
|
|
30
|
+
* @param allowReferrer - Whether to allow the referrer to be sent to the new window.
|
|
31
|
+
* @returns The new window object.
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
34
|
+
export function openWindow(url: string, target = '_blank', allowReferrer?: boolean) {
|
|
35
|
+
return runtime.openWindow(url, target, allowReferrer)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** @public */
|
|
39
|
+
export function refreshPage() {
|
|
40
|
+
runtime.refreshPage()
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** @public */
|
|
44
|
+
export function hardResetEditor() {
|
|
45
|
+
runtime.hardReset()
|
|
46
|
+
}
|
package/src/version.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// This file is automatically generated by internal/scripts/refresh-assets.ts.
|
|
2
2
|
// Do not edit manually. Or do, I'm a comment, not a cop.
|
|
3
3
|
|
|
4
|
-
export const version = '4.
|
|
4
|
+
export const version = '4.5.0-canary.034ea85352da'
|
|
5
5
|
export const publishDates = {
|
|
6
6
|
major: '2025-09-18T14:39:22.803Z',
|
|
7
|
-
minor: '2026-02-
|
|
8
|
-
patch: '2026-02-
|
|
7
|
+
minor: '2026-02-19T10:36:24.329Z',
|
|
8
|
+
patch: '2026-02-19T10:36:24.329Z',
|
|
9
9
|
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/lib/utils/hardResetEditor.ts"],
|
|
4
|
-
"sourcesContent": ["import { runtime } from './runtime'\n\n/** @public */\nexport function hardResetEditor() {\n\truntime.hardReset()\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAwB;AAGjB,SAAS,kBAAkB;AACjC,yBAAQ,UAAU;AACnB;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var refreshPage_exports = {};
|
|
20
|
-
__export(refreshPage_exports, {
|
|
21
|
-
refreshPage: () => refreshPage
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(refreshPage_exports);
|
|
24
|
-
var import_runtime = require("./runtime");
|
|
25
|
-
function refreshPage() {
|
|
26
|
-
import_runtime.runtime.refreshPage();
|
|
27
|
-
}
|
|
28
|
-
//# sourceMappingURL=refreshPage.js.map
|