@tldraw/editor 4.6.0-canary.b9b3bfdc07c7 → 4.6.0-canary.ba8f2c41e1ba
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 +870 -118
- package/dist-cjs/index.js +20 -6
- package/dist-cjs/index.js.map +3 -3
- package/dist-cjs/lib/TldrawEditor.js +59 -14
- package/dist-cjs/lib/TldrawEditor.js.map +3 -3
- package/dist-cjs/lib/components/LiveCollaborators.js +1 -0
- package/dist-cjs/lib/components/LiveCollaborators.js.map +2 -2
- package/dist-cjs/lib/components/MenuClickCapture.js +99 -38
- package/dist-cjs/lib/components/MenuClickCapture.js.map +2 -2
- package/dist-cjs/lib/components/default-components/CanvasShapeIndicators.js +10 -3
- package/dist-cjs/lib/components/default-components/CanvasShapeIndicators.js.map +3 -3
- package/dist-cjs/lib/components/default-components/DefaultCanvas.js +4 -2
- package/dist-cjs/lib/components/default-components/DefaultCanvas.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultCollaboratorHint.js +1 -1
- package/dist-cjs/lib/components/default-components/DefaultCollaboratorHint.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultErrorFallback.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultShapeIndicator.js +1 -1
- package/dist-cjs/lib/components/default-components/DefaultShapeIndicator.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultShapeIndicators.js +1 -0
- package/dist-cjs/lib/components/default-components/DefaultShapeIndicators.js.map +2 -2
- package/dist-cjs/lib/config/{createTLUser.js → createTLCurrentUser.js} +9 -9
- package/dist-cjs/lib/config/createTLCurrentUser.js.map +7 -0
- package/dist-cjs/lib/config/createTLStore.js +31 -1
- package/dist-cjs/lib/config/createTLStore.js.map +2 -2
- package/dist-cjs/lib/config/defaultAssets.js +36 -0
- package/dist-cjs/lib/config/defaultAssets.js.map +7 -0
- package/dist-cjs/lib/config/defaultShapes.js.map +2 -2
- package/dist-cjs/lib/editor/Editor.js +828 -363
- package/dist-cjs/lib/editor/Editor.js.map +3 -3
- package/dist-cjs/lib/editor/assets/AssetUtil.js +67 -0
- package/dist-cjs/lib/editor/assets/AssetUtil.js.map +7 -0
- package/dist-cjs/lib/editor/bindings/BindingUtil.js +1 -0
- package/dist-cjs/lib/editor/bindings/BindingUtil.js.map +1 -1
- package/dist-cjs/lib/editor/managers/ClickManager/ClickManager.js +26 -64
- package/dist-cjs/lib/editor/managers/ClickManager/ClickManager.js.map +2 -2
- package/dist-cjs/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.js +2 -1
- package/dist-cjs/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.js.map +2 -2
- package/dist-cjs/lib/editor/managers/FocusManager/FocusManager.js +15 -53
- package/dist-cjs/lib/editor/managers/FocusManager/FocusManager.js.map +1 -1
- package/dist-cjs/lib/editor/managers/FontManager/FontManager.js +2 -0
- package/dist-cjs/lib/editor/managers/FontManager/FontManager.js.map +2 -2
- package/dist-cjs/lib/editor/managers/HistoryManager/HistoryManager.js +2 -0
- package/dist-cjs/lib/editor/managers/HistoryManager/HistoryManager.js.map +1 -1
- package/dist-cjs/lib/editor/managers/InputsManager/InputsManager.js +83 -112
- package/dist-cjs/lib/editor/managers/InputsManager/InputsManager.js.map +2 -2
- package/dist-cjs/lib/editor/managers/PerformanceManager/PerformanceApiAdapter.js +80 -0
- package/dist-cjs/lib/editor/managers/PerformanceManager/PerformanceApiAdapter.js.map +7 -0
- package/dist-cjs/lib/editor/managers/PerformanceManager/PerformanceManager.js +466 -0
- package/dist-cjs/lib/editor/managers/PerformanceManager/PerformanceManager.js.map +7 -0
- package/dist-cjs/lib/editor/managers/PerformanceManager/perf-types.js +17 -0
- package/dist-cjs/lib/editor/managers/PerformanceManager/perf-types.js.map +7 -0
- package/dist-cjs/lib/editor/managers/ScribbleManager/ScribbleManager.js +1 -0
- package/dist-cjs/lib/editor/managers/ScribbleManager/ScribbleManager.js.map +1 -1
- package/dist-cjs/lib/editor/managers/SnapManager/BoundsSnaps.js +22 -56
- package/dist-cjs/lib/editor/managers/SnapManager/BoundsSnaps.js.map +2 -2
- package/dist-cjs/lib/editor/managers/SnapManager/HandleSnaps.js +12 -52
- package/dist-cjs/lib/editor/managers/SnapManager/HandleSnaps.js.map +2 -2
- package/dist-cjs/lib/editor/managers/SnapManager/SnapManager.js +20 -56
- package/dist-cjs/lib/editor/managers/SnapManager/SnapManager.js.map +1 -1
- package/dist-cjs/lib/editor/managers/SpatialIndexManager/SpatialIndexManager.js +5 -4
- package/dist-cjs/lib/editor/managers/SpatialIndexManager/SpatialIndexManager.js.map +2 -2
- package/dist-cjs/lib/editor/managers/TextManager/TextManager.js +103 -30
- package/dist-cjs/lib/editor/managers/TextManager/TextManager.js.map +2 -2
- package/dist-cjs/lib/editor/managers/ThemeManager/ThemeManager.js +107 -0
- package/dist-cjs/lib/editor/managers/ThemeManager/ThemeManager.js.map +7 -0
- package/dist-cjs/lib/editor/managers/ThemeManager/defaultThemes.js +586 -0
- package/dist-cjs/lib/editor/managers/ThemeManager/defaultThemes.js.map +7 -0
- package/dist-cjs/lib/editor/managers/TickManager/TickManager.js +17 -55
- package/dist-cjs/lib/editor/managers/TickManager/TickManager.js.map +1 -1
- package/dist-cjs/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.js +65 -72
- package/dist-cjs/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.js.map +2 -2
- package/dist-cjs/lib/editor/shapes/ShapeUtil.js +22 -2
- package/dist-cjs/lib/editor/shapes/ShapeUtil.js.map +2 -2
- package/dist-cjs/lib/editor/shapes/group/GroupShapeUtil.js +1 -1
- package/dist-cjs/lib/editor/shapes/group/GroupShapeUtil.js.map +2 -2
- package/dist-cjs/lib/editor/shapes/shared/getPerfectDashProps.js +6 -0
- package/dist-cjs/lib/editor/shapes/shared/getPerfectDashProps.js.map +2 -2
- package/dist-cjs/lib/editor/tools/StateNode.js +15 -17
- package/dist-cjs/lib/editor/tools/StateNode.js.map +2 -2
- package/dist-cjs/lib/editor/types/SvgExportContext.js.map +2 -2
- package/dist-cjs/lib/editor/types/clipboard-types.js.map +1 -1
- package/dist-cjs/lib/editor/types/external-content.js.map +1 -1
- package/dist-cjs/lib/exports/ExportDelay.js +13 -53
- package/dist-cjs/lib/exports/ExportDelay.js.map +1 -1
- package/dist-cjs/lib/exports/FontEmbedder.js +14 -57
- package/dist-cjs/lib/exports/FontEmbedder.js.map +1 -1
- package/dist-cjs/lib/exports/StyleEmbedder.js +2 -1
- package/dist-cjs/lib/exports/StyleEmbedder.js.map +2 -2
- package/dist-cjs/lib/exports/getSvgJsx.js +12 -7
- package/dist-cjs/lib/exports/getSvgJsx.js.map +2 -2
- package/dist-cjs/lib/globals/environment.js +18 -1
- package/dist-cjs/lib/globals/environment.js.map +2 -2
- package/dist-cjs/lib/hooks/useCanvasEvents.js +25 -4
- package/dist-cjs/lib/hooks/useCanvasEvents.js.map +2 -2
- package/dist-cjs/lib/hooks/{useIsDarkMode.js → useColorMode.js} +14 -10
- package/dist-cjs/lib/hooks/useColorMode.js.map +7 -0
- package/dist-cjs/lib/hooks/useCursor.js +3 -7
- package/dist-cjs/lib/hooks/useCursor.js.map +2 -2
- package/dist-cjs/lib/hooks/useDarkMode.js +4 -4
- package/dist-cjs/lib/hooks/useDarkMode.js.map +2 -2
- package/dist-cjs/lib/hooks/useEditorComponents.js.map +2 -2
- package/dist-cjs/lib/hooks/useGestureEvents.js +171 -127
- package/dist-cjs/lib/hooks/useGestureEvents.js.map +3 -3
- package/dist-cjs/lib/hooks/useLocalStore.js.map +2 -2
- package/dist-cjs/lib/options.js +5 -0
- package/dist-cjs/lib/options.js.map +2 -2
- package/dist-cjs/lib/primitives/Box.js +26 -26
- package/dist-cjs/lib/primitives/Box.js.map +2 -2
- package/dist-cjs/lib/primitives/Vec.js +4 -1
- package/dist-cjs/lib/primitives/Vec.js.map +2 -2
- package/dist-cjs/lib/primitives/geometry/Arc2d.js +2 -2
- package/dist-cjs/lib/primitives/geometry/Arc2d.js.map +2 -2
- package/dist-cjs/lib/primitives/geometry/Circle2d.js +3 -2
- package/dist-cjs/lib/primitives/geometry/Circle2d.js.map +2 -2
- package/dist-cjs/lib/primitives/geometry/CubicSpline2d.js +1 -1
- package/dist-cjs/lib/primitives/geometry/CubicSpline2d.js.map +1 -1
- package/dist-cjs/lib/primitives/geometry/Ellipse2d.js +4 -3
- package/dist-cjs/lib/primitives/geometry/Ellipse2d.js.map +2 -2
- package/dist-cjs/lib/primitives/geometry/Geometry2d.js +12 -9
- package/dist-cjs/lib/primitives/geometry/Geometry2d.js.map +2 -2
- package/dist-cjs/lib/primitives/geometry/Polyline2d.js +2 -2
- package/dist-cjs/lib/primitives/geometry/Polyline2d.js.map +2 -2
- package/dist-cjs/lib/primitives/geometry/Stadium2d.js +2 -1
- package/dist-cjs/lib/primitives/geometry/Stadium2d.js.map +2 -2
- package/dist-cjs/lib/utils/EditorAtom.js +2 -0
- package/dist-cjs/lib/utils/EditorAtom.js.map +1 -1
- package/dist-cjs/lib/utils/SharedStylesMap.js +1 -1
- package/dist-cjs/lib/utils/SharedStylesMap.js.map +1 -1
- package/dist-cjs/lib/utils/getSvgPathFromPoints.js.map +2 -2
- package/dist-cjs/lib/utils/reparenting.js +2 -1
- package/dist-cjs/lib/utils/reparenting.js.map +2 -2
- package/dist-cjs/lib/utils/richText.js.map +2 -2
- package/dist-cjs/lib/utils/runtime.js +2 -1
- package/dist-cjs/lib/utils/runtime.js.map +2 -2
- package/dist-cjs/lib/utils/sync/TLLocalSyncClient.js +5 -2
- package/dist-cjs/lib/utils/sync/TLLocalSyncClient.js.map +2 -2
- package/dist-cjs/lib/utils/sync/hardReset.js +0 -8
- package/dist-cjs/lib/utils/sync/hardReset.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 +870 -118
- package/dist-esm/index.mjs +28 -10
- package/dist-esm/index.mjs.map +2 -2
- package/dist-esm/lib/TldrawEditor.mjs +62 -14
- package/dist-esm/lib/TldrawEditor.mjs.map +3 -3
- package/dist-esm/lib/components/LiveCollaborators.mjs +1 -0
- package/dist-esm/lib/components/LiveCollaborators.mjs.map +2 -2
- package/dist-esm/lib/components/MenuClickCapture.mjs +100 -39
- package/dist-esm/lib/components/MenuClickCapture.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/CanvasShapeIndicators.mjs +10 -3
- package/dist-esm/lib/components/default-components/CanvasShapeIndicators.mjs.map +3 -3
- package/dist-esm/lib/components/default-components/DefaultCanvas.mjs +4 -2
- package/dist-esm/lib/components/default-components/DefaultCanvas.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultCollaboratorHint.mjs +1 -1
- package/dist-esm/lib/components/default-components/DefaultCollaboratorHint.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultErrorFallback.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 -0
- package/dist-esm/lib/components/default-components/DefaultShapeIndicators.mjs.map +2 -2
- package/dist-esm/lib/config/{createTLUser.mjs → createTLCurrentUser.mjs} +6 -6
- package/dist-esm/lib/config/createTLCurrentUser.mjs.map +7 -0
- package/dist-esm/lib/config/createTLStore.mjs +37 -2
- package/dist-esm/lib/config/createTLStore.mjs.map +2 -2
- package/dist-esm/lib/config/defaultAssets.mjs +16 -0
- package/dist-esm/lib/config/defaultAssets.mjs.map +7 -0
- package/dist-esm/lib/config/defaultShapes.mjs.map +2 -2
- package/dist-esm/lib/editor/Editor.mjs +831 -365
- package/dist-esm/lib/editor/Editor.mjs.map +3 -3
- package/dist-esm/lib/editor/assets/AssetUtil.mjs +47 -0
- package/dist-esm/lib/editor/assets/AssetUtil.mjs.map +7 -0
- package/dist-esm/lib/editor/bindings/BindingUtil.mjs +1 -0
- package/dist-esm/lib/editor/bindings/BindingUtil.mjs.map +1 -1
- package/dist-esm/lib/editor/managers/ClickManager/ClickManager.mjs +26 -64
- package/dist-esm/lib/editor/managers/ClickManager/ClickManager.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.mjs +2 -1
- package/dist-esm/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/FocusManager/FocusManager.mjs +15 -53
- package/dist-esm/lib/editor/managers/FocusManager/FocusManager.mjs.map +1 -1
- package/dist-esm/lib/editor/managers/FontManager/FontManager.mjs +2 -0
- package/dist-esm/lib/editor/managers/FontManager/FontManager.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/HistoryManager/HistoryManager.mjs +2 -0
- package/dist-esm/lib/editor/managers/HistoryManager/HistoryManager.mjs.map +1 -1
- package/dist-esm/lib/editor/managers/InputsManager/InputsManager.mjs +83 -112
- package/dist-esm/lib/editor/managers/InputsManager/InputsManager.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/PerformanceManager/PerformanceApiAdapter.mjs +60 -0
- package/dist-esm/lib/editor/managers/PerformanceManager/PerformanceApiAdapter.mjs.map +7 -0
- package/dist-esm/lib/editor/managers/PerformanceManager/PerformanceManager.mjs +438 -0
- package/dist-esm/lib/editor/managers/PerformanceManager/PerformanceManager.mjs.map +7 -0
- package/dist-esm/lib/editor/managers/PerformanceManager/perf-types.mjs +1 -0
- package/dist-esm/lib/editor/managers/PerformanceManager/perf-types.mjs.map +7 -0
- package/dist-esm/lib/editor/managers/ScribbleManager/ScribbleManager.mjs +1 -0
- package/dist-esm/lib/editor/managers/ScribbleManager/ScribbleManager.mjs.map +1 -1
- package/dist-esm/lib/editor/managers/SnapManager/BoundsSnaps.mjs +22 -56
- package/dist-esm/lib/editor/managers/SnapManager/BoundsSnaps.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/SnapManager/HandleSnaps.mjs +12 -52
- package/dist-esm/lib/editor/managers/SnapManager/HandleSnaps.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/SnapManager/SnapManager.mjs +20 -56
- package/dist-esm/lib/editor/managers/SnapManager/SnapManager.mjs.map +1 -1
- package/dist-esm/lib/editor/managers/SpatialIndexManager/SpatialIndexManager.mjs +5 -4
- package/dist-esm/lib/editor/managers/SpatialIndexManager/SpatialIndexManager.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/TextManager/TextManager.mjs +103 -30
- package/dist-esm/lib/editor/managers/TextManager/TextManager.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/ThemeManager/ThemeManager.mjs +89 -0
- package/dist-esm/lib/editor/managers/ThemeManager/ThemeManager.mjs.map +7 -0
- package/dist-esm/lib/editor/managers/ThemeManager/defaultThemes.mjs +568 -0
- package/dist-esm/lib/editor/managers/ThemeManager/defaultThemes.mjs.map +7 -0
- package/dist-esm/lib/editor/managers/TickManager/TickManager.mjs +17 -55
- package/dist-esm/lib/editor/managers/TickManager/TickManager.mjs.map +1 -1
- package/dist-esm/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.mjs +65 -72
- package/dist-esm/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.mjs.map +2 -2
- package/dist-esm/lib/editor/shapes/ShapeUtil.mjs +22 -2
- package/dist-esm/lib/editor/shapes/ShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/editor/shapes/group/GroupShapeUtil.mjs +1 -1
- package/dist-esm/lib/editor/shapes/group/GroupShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/editor/shapes/shared/getPerfectDashProps.mjs +6 -0
- package/dist-esm/lib/editor/shapes/shared/getPerfectDashProps.mjs.map +2 -2
- package/dist-esm/lib/editor/tools/StateNode.mjs +15 -17
- package/dist-esm/lib/editor/tools/StateNode.mjs.map +2 -2
- package/dist-esm/lib/editor/types/SvgExportContext.mjs.map +2 -2
- package/dist-esm/lib/exports/ExportDelay.mjs +13 -53
- package/dist-esm/lib/exports/ExportDelay.mjs.map +1 -1
- package/dist-esm/lib/exports/FontEmbedder.mjs +14 -57
- package/dist-esm/lib/exports/FontEmbedder.mjs.map +1 -1
- package/dist-esm/lib/exports/StyleEmbedder.mjs +2 -1
- package/dist-esm/lib/exports/StyleEmbedder.mjs.map +2 -2
- package/dist-esm/lib/exports/getSvgJsx.mjs +12 -10
- package/dist-esm/lib/exports/getSvgJsx.mjs.map +2 -2
- package/dist-esm/lib/globals/environment.mjs +18 -1
- package/dist-esm/lib/globals/environment.mjs.map +2 -2
- package/dist-esm/lib/hooks/useCanvasEvents.mjs +25 -4
- package/dist-esm/lib/hooks/useCanvasEvents.mjs.map +2 -2
- package/dist-esm/lib/hooks/useColorMode.mjs +19 -0
- package/dist-esm/lib/hooks/useColorMode.mjs.map +7 -0
- package/dist-esm/lib/hooks/useCursor.mjs +3 -7
- package/dist-esm/lib/hooks/useCursor.mjs.map +2 -2
- package/dist-esm/lib/hooks/useDarkMode.mjs +4 -4
- package/dist-esm/lib/hooks/useDarkMode.mjs.map +2 -2
- package/dist-esm/lib/hooks/useEditorComponents.mjs.map +2 -2
- package/dist-esm/lib/hooks/useGestureEvents.mjs +171 -127
- package/dist-esm/lib/hooks/useGestureEvents.mjs.map +3 -3
- package/dist-esm/lib/hooks/useLocalStore.mjs.map +2 -2
- package/dist-esm/lib/options.mjs +5 -0
- package/dist-esm/lib/options.mjs.map +2 -2
- package/dist-esm/lib/primitives/Box.mjs +26 -26
- package/dist-esm/lib/primitives/Box.mjs.map +2 -2
- package/dist-esm/lib/primitives/Vec.mjs +4 -1
- package/dist-esm/lib/primitives/Vec.mjs.map +2 -2
- package/dist-esm/lib/primitives/geometry/Arc2d.mjs +2 -2
- package/dist-esm/lib/primitives/geometry/Arc2d.mjs.map +2 -2
- package/dist-esm/lib/primitives/geometry/Circle2d.mjs +3 -2
- package/dist-esm/lib/primitives/geometry/Circle2d.mjs.map +2 -2
- package/dist-esm/lib/primitives/geometry/CubicSpline2d.mjs +1 -1
- package/dist-esm/lib/primitives/geometry/CubicSpline2d.mjs.map +1 -1
- package/dist-esm/lib/primitives/geometry/Ellipse2d.mjs +4 -3
- package/dist-esm/lib/primitives/geometry/Ellipse2d.mjs.map +2 -2
- package/dist-esm/lib/primitives/geometry/Geometry2d.mjs +12 -9
- package/dist-esm/lib/primitives/geometry/Geometry2d.mjs.map +2 -2
- package/dist-esm/lib/primitives/geometry/Polyline2d.mjs +2 -2
- package/dist-esm/lib/primitives/geometry/Polyline2d.mjs.map +2 -2
- package/dist-esm/lib/primitives/geometry/Stadium2d.mjs +2 -1
- package/dist-esm/lib/primitives/geometry/Stadium2d.mjs.map +2 -2
- package/dist-esm/lib/utils/EditorAtom.mjs +2 -0
- package/dist-esm/lib/utils/EditorAtom.mjs.map +1 -1
- package/dist-esm/lib/utils/SharedStylesMap.mjs +1 -1
- package/dist-esm/lib/utils/SharedStylesMap.mjs.map +1 -1
- package/dist-esm/lib/utils/getSvgPathFromPoints.mjs.map +2 -2
- package/dist-esm/lib/utils/reparenting.mjs +2 -1
- package/dist-esm/lib/utils/reparenting.mjs.map +2 -2
- package/dist-esm/lib/utils/richText.mjs.map +2 -2
- package/dist-esm/lib/utils/runtime.mjs +2 -1
- package/dist-esm/lib/utils/runtime.mjs.map +2 -2
- package/dist-esm/lib/utils/sync/TLLocalSyncClient.mjs +5 -2
- package/dist-esm/lib/utils/sync/TLLocalSyncClient.mjs.map +2 -2
- package/dist-esm/lib/utils/sync/hardReset.mjs +0 -8
- package/dist-esm/lib/utils/sync/hardReset.mjs.map +2 -2
- package/dist-esm/version.mjs +3 -3
- package/dist-esm/version.mjs.map +1 -1
- package/editor.css +13 -37
- package/package.json +7 -8
- package/src/index.ts +44 -14
- package/src/lib/TldrawEditor.tsx +99 -20
- package/src/lib/components/LiveCollaborators.tsx +8 -2
- package/src/lib/components/MenuClickCapture.tsx +129 -49
- package/src/lib/components/default-components/CanvasShapeIndicators.tsx +14 -3
- package/src/lib/components/default-components/DefaultCanvas.tsx +5 -2
- package/src/lib/components/default-components/DefaultCollaboratorHint.tsx +1 -1
- package/src/lib/components/default-components/DefaultErrorFallback.tsx +1 -0
- package/src/lib/components/default-components/DefaultShapeIndicator.tsx +2 -2
- package/src/lib/components/default-components/DefaultShapeIndicators.tsx +2 -0
- package/src/lib/config/TLEditorSnapshot.test.ts +1 -1
- package/src/lib/config/{createTLUser.ts → createTLCurrentUser.ts} +9 -9
- package/src/lib/config/createTLStore.ts +58 -3
- package/src/lib/config/defaultAssets.ts +19 -0
- package/src/lib/config/defaultShapes.ts +1 -1
- package/src/lib/editor/Editor.ts +501 -37
- package/src/lib/editor/assets/AssetUtil.ts +85 -0
- package/src/lib/editor/managers/ClickManager/ClickManager.ts +1 -1
- package/src/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.ts +1 -1
- package/src/lib/editor/managers/FontManager/FontManager.test.ts +9 -2
- package/src/lib/editor/managers/FontManager/FontManager.ts +1 -67
- package/src/lib/editor/managers/InputsManager/InputsManager.ts +42 -30
- package/src/lib/editor/managers/PerformanceManager/PerformanceApiAdapter.ts +82 -0
- package/src/lib/editor/managers/PerformanceManager/PerformanceManager.test.ts +522 -0
- package/src/lib/editor/managers/PerformanceManager/PerformanceManager.ts +583 -0
- package/src/lib/editor/managers/PerformanceManager/perf-types.ts +196 -0
- package/src/lib/editor/managers/SnapManager/BoundsSnaps.ts +1 -1
- package/src/lib/editor/managers/SnapManager/HandleSnaps.ts +1 -1
- package/src/lib/editor/managers/SpatialIndexManager/SpatialIndexManager.ts +5 -5
- package/src/lib/editor/managers/TextManager/TextManager.test.ts +18 -4
- package/src/lib/editor/managers/TextManager/TextManager.ts +140 -34
- package/src/lib/editor/managers/ThemeManager/ThemeManager.ts +116 -0
- package/src/lib/editor/managers/ThemeManager/defaultThemes.ts +605 -0
- package/src/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.test.ts +25 -31
- package/src/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.ts +7 -5
- package/src/lib/editor/shapes/ShapeUtil.ts +41 -5
- package/src/lib/editor/shapes/group/GroupShapeUtil.tsx +1 -1
- package/src/lib/editor/shapes/shared/getPerfectDashProps.ts +7 -0
- package/src/lib/editor/tools/StateNode.ts +16 -18
- package/src/lib/editor/types/SvgExportContext.tsx +5 -0
- package/src/lib/editor/types/clipboard-types.ts +2 -1
- package/src/lib/editor/types/external-content.ts +1 -0
- package/src/lib/exports/StyleEmbedder.ts +1 -1
- package/src/lib/exports/getSvgJsx.tsx +22 -16
- package/src/lib/globals/environment.ts +18 -0
- package/src/lib/hooks/useCanvasEvents.ts +40 -3
- package/src/lib/hooks/{useIsDarkMode.ts → useColorMode.ts} +9 -5
- package/src/lib/hooks/useCursor.ts +3 -7
- package/src/lib/hooks/useDarkMode.ts +4 -4
- package/src/lib/hooks/useEditorComponents.tsx +1 -1
- package/src/lib/hooks/useGestureEvents.ts +240 -168
- package/src/lib/hooks/useLocalStore.ts +1 -1
- package/src/lib/options.ts +122 -0
- package/src/lib/primitives/Box.test.ts +30 -0
- package/src/lib/primitives/Box.ts +26 -26
- package/src/lib/primitives/Vec.ts +1 -1
- package/src/lib/primitives/geometry/Arc2d.ts +2 -2
- package/src/lib/primitives/geometry/Circle2d.ts +2 -2
- package/src/lib/primitives/geometry/CubicSpline2d.ts +1 -1
- package/src/lib/primitives/geometry/Ellipse2d.ts +3 -3
- package/src/lib/primitives/geometry/Geometry2d.test.ts +21 -0
- package/src/lib/primitives/geometry/Geometry2d.ts +10 -9
- package/src/lib/primitives/geometry/Polyline2d.ts +2 -2
- package/src/lib/primitives/geometry/Stadium2d.ts +1 -1
- package/src/lib/utils/SharedStylesMap.ts +1 -1
- package/src/lib/utils/getSvgPathFromPoints.ts +1 -1
- package/src/lib/utils/reparenting.ts +6 -2
- package/src/lib/utils/richText.ts +1 -1
- package/src/lib/utils/runtime.ts +3 -1
- package/src/lib/utils/sync/TLLocalSyncClient.test.ts +1 -1
- package/src/lib/utils/sync/TLLocalSyncClient.ts +2 -1
- package/src/lib/utils/sync/hardReset.ts +0 -8
- package/src/version.ts +3 -3
- package/dist-cjs/lib/config/createTLUser.js.map +0 -7
- package/dist-cjs/lib/hooks/useIsDarkMode.js.map +0 -7
- package/dist-esm/lib/config/createTLUser.mjs.map +0 -7
- package/dist-esm/lib/hooks/useIsDarkMode.mjs +0 -15
- package/dist-esm/lib/hooks/useIsDarkMode.mjs.map +0 -7
package/dist-cjs/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Atom } from '@tldraw/state';
|
|
2
2
|
import { AtomSet } from '@tldraw/store';
|
|
3
|
+
import { Awaitable } from '@tldraw/utils';
|
|
3
4
|
import { BoxModel } from '@tldraw/tlschema';
|
|
4
5
|
import { ComponentType } from 'react';
|
|
5
6
|
import { Computed } from '@tldraw/state';
|
|
@@ -56,9 +57,12 @@ import { TLCamera } from '@tldraw/tlschema';
|
|
|
56
57
|
import { TLCreateShapePartial } from '@tldraw/tlschema';
|
|
57
58
|
import { TLCursor } from '@tldraw/tlschema';
|
|
58
59
|
import { TLCursorType } from '@tldraw/tlschema';
|
|
60
|
+
import { TLDefaultColor } from '@tldraw/tlschema';
|
|
61
|
+
import { TLDefaultColorStyle } from '@tldraw/tlschema';
|
|
59
62
|
import { TLDefaultDashStyle } from '@tldraw/tlschema';
|
|
60
63
|
import { TLDefaultHorizontalAlignStyle } from '@tldraw/tlschema';
|
|
61
64
|
import { TLDocument } from '@tldraw/tlschema';
|
|
65
|
+
import { TLFontFace } from '@tldraw/tlschema';
|
|
62
66
|
import { TLGroupShape } from '@tldraw/tlschema';
|
|
63
67
|
import { TLHandle } from '@tldraw/tlschema';
|
|
64
68
|
import { TLImageAsset } from '@tldraw/tlschema';
|
|
@@ -80,8 +84,15 @@ import { TLStore } from '@tldraw/tlschema';
|
|
|
80
84
|
import { TLStoreProps } from '@tldraw/tlschema';
|
|
81
85
|
import { TLStoreSchema } from '@tldraw/tlschema';
|
|
82
86
|
import { TLStoreSnapshot } from '@tldraw/tlschema';
|
|
87
|
+
import { TLTheme } from '@tldraw/tlschema';
|
|
88
|
+
import { TLThemeColors } from '@tldraw/tlschema';
|
|
89
|
+
import { TLThemeId } from '@tldraw/tlschema';
|
|
90
|
+
import { TLThemes } from '@tldraw/tlschema';
|
|
91
|
+
import { TLUnknownAsset } from '@tldraw/tlschema';
|
|
83
92
|
import { TLUnknownBinding } from '@tldraw/tlschema';
|
|
84
93
|
import { TLUnknownShape } from '@tldraw/tlschema';
|
|
94
|
+
import { TLUser } from '@tldraw/tlschema';
|
|
95
|
+
import { TLUserStore } from '@tldraw/tlschema';
|
|
85
96
|
import { TLVideoAsset } from '@tldraw/tlschema';
|
|
86
97
|
import { UnknownRecord } from '@tldraw/store';
|
|
87
98
|
import { VecModel } from '@tldraw/tlschema';
|
|
@@ -144,6 +155,51 @@ export declare class Arc2d extends Geometry2d {
|
|
|
144
155
|
*/
|
|
145
156
|
export declare function areAnglesCompatible(a: number, b: number): boolean;
|
|
146
157
|
|
|
158
|
+
/**
|
|
159
|
+
* Abstract base class for defining asset-type-specific behavior.
|
|
160
|
+
*
|
|
161
|
+
* Each asset type (image, video, bookmark, etc.) has a corresponding AssetUtil that handles
|
|
162
|
+
* type-specific operations like determining supported MIME types and creating assets from files.
|
|
163
|
+
*
|
|
164
|
+
* @public
|
|
165
|
+
*/
|
|
166
|
+
export declare abstract class AssetUtil<Asset extends TLAsset = TLAsset> {
|
|
167
|
+
editor: Editor;
|
|
168
|
+
/** Configure this asset util's {@link AssetUtil.options | `options`}. */
|
|
169
|
+
static configure<T extends TLAssetUtilConstructor<any, any>>(this: T, options: T extends new (...args: any[]) => {
|
|
170
|
+
options: infer Options;
|
|
171
|
+
} ? Partial<Options> : never): T;
|
|
172
|
+
constructor(editor: Editor);
|
|
173
|
+
/**
|
|
174
|
+
* Options for this asset util. Override this to provide customization options for your asset.
|
|
175
|
+
* Use {@link AssetUtil.configure} to customize existing asset utils.
|
|
176
|
+
*/
|
|
177
|
+
options: {};
|
|
178
|
+
static props?: RecordProps<TLUnknownAsset>;
|
|
179
|
+
static migrations?: LegacyMigrations | MigrationSequence | TLPropsMigrations;
|
|
180
|
+
/**
|
|
181
|
+
* The type of the asset util, which should match the asset's type.
|
|
182
|
+
*/
|
|
183
|
+
static type: string;
|
|
184
|
+
/**
|
|
185
|
+
* Get the default props for an asset of this type.
|
|
186
|
+
*/
|
|
187
|
+
abstract getDefaultProps(): Asset['props'];
|
|
188
|
+
/**
|
|
189
|
+
* Get the MIME types that this asset type supports.
|
|
190
|
+
* Return an empty array if this asset type doesn't support files (e.g. bookmarks).
|
|
191
|
+
*/
|
|
192
|
+
getSupportedMimeTypes(): readonly string[];
|
|
193
|
+
/**
|
|
194
|
+
* Check whether this asset type accepts a given MIME type.
|
|
195
|
+
*/
|
|
196
|
+
acceptsMimeType(mimeType: string): boolean;
|
|
197
|
+
/**
|
|
198
|
+
* Create an asset from a file. Return null if this asset type can't handle the file.
|
|
199
|
+
*/
|
|
200
|
+
getAssetFromFile(_file: File, _assetId: TLAssetId): Promise<Asset | null>;
|
|
201
|
+
}
|
|
202
|
+
|
|
147
203
|
/** @public */
|
|
148
204
|
export declare function average(A: VecLike, B: VecLike): string;
|
|
149
205
|
|
|
@@ -164,6 +220,12 @@ export declare abstract class BaseBoxShapeUtil<Shape extends TLBaseBoxShape> ext
|
|
|
164
220
|
getInterpolatedProps(startShape: Shape, endShape: Shape, t: number): Shape['props'];
|
|
165
221
|
}
|
|
166
222
|
|
|
223
|
+
/** @public */
|
|
224
|
+
export declare interface BatchMeasurementRequest {
|
|
225
|
+
html: string;
|
|
226
|
+
opts: TLMeasureTextOpts;
|
|
227
|
+
}
|
|
228
|
+
|
|
167
229
|
/**
|
|
168
230
|
* Options passed to {@link BindingUtil.onBeforeChange} and {@link BindingUtil.onAfterChange},
|
|
169
231
|
* describing the data associated with a binding being changed.
|
|
@@ -711,6 +773,12 @@ export declare function createDeepLinkString(deepLink: TLDeepLink): string;
|
|
|
711
773
|
*/
|
|
712
774
|
export declare function createSessionStateSnapshotSignal(store: TLStore): Signal<null | TLSessionStateSnapshot>;
|
|
713
775
|
|
|
776
|
+
/** @public */
|
|
777
|
+
export declare function createTLCurrentUser(opts?: {
|
|
778
|
+
setUserPreferences?: ((userPreferences: TLUserPreferences) => void) | undefined;
|
|
779
|
+
userPreferences?: Signal<TLUserPreferences, unknown> | undefined;
|
|
780
|
+
}): TLCurrentUser;
|
|
781
|
+
|
|
714
782
|
/**
|
|
715
783
|
* A helper for creating a TLStore schema from either an object with shapeUtils, bindingUtils, and
|
|
716
784
|
* migrations, or a schema.
|
|
@@ -728,13 +796,7 @@ export declare function createTLSchemaFromUtils(opts: TLStoreSchemaOptions): Sto
|
|
|
728
796
|
*
|
|
729
797
|
* @public
|
|
730
798
|
*/
|
|
731
|
-
export declare function createTLStore({ initialData, defaultName, id, assets, onMount, collaboration, ...rest }?: TLStoreOptions): TLStore;
|
|
732
|
-
|
|
733
|
-
/** @public */
|
|
734
|
-
export declare function createTLUser(opts?: {
|
|
735
|
-
setUserPreferences?: ((userPreferences: TLUserPreferences) => void) | undefined;
|
|
736
|
-
userPreferences?: Signal<TLUserPreferences, unknown> | undefined;
|
|
737
|
-
}): TLUser;
|
|
799
|
+
export declare function createTLStore({ initialData, defaultName, id, assets, users, onMount, collaboration, themes, ...rest }?: TLStoreOptions): TLStore;
|
|
738
800
|
|
|
739
801
|
/** @public */
|
|
740
802
|
export declare class CubicBezier2d extends Polyline2d {
|
|
@@ -809,6 +871,13 @@ export declare interface DebugFlagDefaults<T> {
|
|
|
809
871
|
|
|
810
872
|
/* Excluded from this release type: DEFAULT_CAMERA_OPTIONS */
|
|
811
873
|
|
|
874
|
+
/**
|
|
875
|
+
* The default theme definition containing color palettes for both light and dark modes.
|
|
876
|
+
*
|
|
877
|
+
* @public
|
|
878
|
+
*/
|
|
879
|
+
export declare const DEFAULT_THEME: TLTheme;
|
|
880
|
+
|
|
812
881
|
/** @public @react */
|
|
813
882
|
export declare function DefaultBackground(): JSX.Element;
|
|
814
883
|
|
|
@@ -923,7 +992,11 @@ export declare const defaultTldrawOptions: {
|
|
|
923
992
|
readonly maxShapesPerPage: 4000;
|
|
924
993
|
readonly multiClickDurationMs: 200;
|
|
925
994
|
readonly nonce: undefined;
|
|
995
|
+
readonly onBeforeCopyToClipboard: undefined;
|
|
996
|
+
readonly onBeforePasteFromClipboard: undefined;
|
|
997
|
+
readonly onClipboardPasteRaw: undefined;
|
|
926
998
|
readonly quickZoomPreservesScreenBounds: true;
|
|
999
|
+
readonly rightClickPanning: true;
|
|
927
1000
|
readonly snapThreshold: 8;
|
|
928
1001
|
readonly spacebarPanning: true;
|
|
929
1002
|
readonly temporaryAssetPreviewLifetimeMs: 180000;
|
|
@@ -932,6 +1005,7 @@ export declare const defaultTldrawOptions: {
|
|
|
932
1005
|
readonly tooltipDelayMs: 700;
|
|
933
1006
|
readonly uiCoarseDragDistanceSquared: 625;
|
|
934
1007
|
readonly uiDragDistanceSquared: 16;
|
|
1008
|
+
readonly useCanvasIndicators: true;
|
|
935
1009
|
readonly zoomToFitPadding: 128;
|
|
936
1010
|
};
|
|
937
1011
|
|
|
@@ -953,6 +1027,9 @@ export declare const defaultUserPreferences: Readonly<{
|
|
|
953
1027
|
name: "";
|
|
954
1028
|
}>;
|
|
955
1029
|
|
|
1030
|
+
/** @public */
|
|
1031
|
+
export declare const defaultUserStore: TLUserStore;
|
|
1032
|
+
|
|
956
1033
|
/**
|
|
957
1034
|
* Convert degrees to radians.
|
|
958
1035
|
*
|
|
@@ -1028,7 +1105,7 @@ export declare class EdgeScrollManager {
|
|
|
1028
1105
|
/** @public */
|
|
1029
1106
|
export declare class Editor extends EventEmitter<TLEventMap> {
|
|
1030
1107
|
readonly id: string;
|
|
1031
|
-
constructor({ store, user, shapeUtils, bindingUtils, tools, getContainer, cameraOptions, initialState, autoFocus,
|
|
1108
|
+
constructor({ store, user, shapeUtils, bindingUtils, assetUtils: assetUtilConstructors, tools, getContainer, cameraOptions, initialState, autoFocus, options: _options, textOptions: _textOptions, getShapeVisibility, colorScheme, fontAssetUrls, themes, initialTheme }: TLEditorOptions);
|
|
1032
1109
|
private readonly _getShapeVisibility?;
|
|
1033
1110
|
private getIsShapeHiddenCache;
|
|
1034
1111
|
isShapeHidden(shapeOrId: TLShape | TLShapeId): boolean;
|
|
@@ -1091,7 +1168,13 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
1091
1168
|
* @public
|
|
1092
1169
|
*/
|
|
1093
1170
|
readonly snaps: SnapManager;
|
|
1094
|
-
|
|
1171
|
+
/**
|
|
1172
|
+
* A manager for performance measurement hooks.
|
|
1173
|
+
*
|
|
1174
|
+
* @public
|
|
1175
|
+
*/
|
|
1176
|
+
readonly performance: PerformanceManager;
|
|
1177
|
+
/* Excluded from this release type: _spatialIndex */
|
|
1095
1178
|
/**
|
|
1096
1179
|
* A manager for the any asynchronous events and making sure they're
|
|
1097
1180
|
* cleaned up upon disposal.
|
|
@@ -1110,6 +1193,7 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
1110
1193
|
* @public
|
|
1111
1194
|
*/
|
|
1112
1195
|
readonly user: UserPreferencesManager;
|
|
1196
|
+
/* Excluded from this release type: _themeManager */
|
|
1113
1197
|
/**
|
|
1114
1198
|
* A helper for measuring text.
|
|
1115
1199
|
*
|
|
@@ -1160,6 +1244,83 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
1160
1244
|
* @public
|
|
1161
1245
|
*/
|
|
1162
1246
|
dispose(): void;
|
|
1247
|
+
/**
|
|
1248
|
+
* Get the current color mode (`'light'` or `'dark'`), based on the user's dark mode preference.
|
|
1249
|
+
*
|
|
1250
|
+
* @public
|
|
1251
|
+
*/
|
|
1252
|
+
getColorMode(): 'dark' | 'light';
|
|
1253
|
+
/**
|
|
1254
|
+
* Set the color mode. Note that this is a convenience method that passes the mode to
|
|
1255
|
+
* `user.updateUserPreferences`, which is the source of truth for the user's color mode preference.
|
|
1256
|
+
*
|
|
1257
|
+
* @public
|
|
1258
|
+
*/
|
|
1259
|
+
setColorMode(mode: 'dark' | 'light'): this;
|
|
1260
|
+
/**
|
|
1261
|
+
* Get the id of the current theme.
|
|
1262
|
+
*
|
|
1263
|
+
* @public
|
|
1264
|
+
*/
|
|
1265
|
+
getCurrentThemeId(): TLThemeId;
|
|
1266
|
+
/**
|
|
1267
|
+
* Get the current theme definition.
|
|
1268
|
+
*
|
|
1269
|
+
* @public
|
|
1270
|
+
*/
|
|
1271
|
+
getCurrentTheme(): TLTheme;
|
|
1272
|
+
/**
|
|
1273
|
+
* Set the current theme by id.
|
|
1274
|
+
*
|
|
1275
|
+
* @public
|
|
1276
|
+
*/
|
|
1277
|
+
setCurrentTheme(id: TLThemeId): this;
|
|
1278
|
+
/**
|
|
1279
|
+
* Get all registered theme definitions.
|
|
1280
|
+
*
|
|
1281
|
+
* @public
|
|
1282
|
+
*/
|
|
1283
|
+
getThemes(): TLThemes;
|
|
1284
|
+
/**
|
|
1285
|
+
* Get a single theme definition by id.
|
|
1286
|
+
*
|
|
1287
|
+
* @public
|
|
1288
|
+
*/
|
|
1289
|
+
getTheme(id: TLThemeId): TLTheme | undefined;
|
|
1290
|
+
/**
|
|
1291
|
+
* Replace all theme definitions, or update them via a callback that receives a deep copy.
|
|
1292
|
+
* The `'default'` theme must always be present in the result.
|
|
1293
|
+
*
|
|
1294
|
+
* @example
|
|
1295
|
+
* ```ts
|
|
1296
|
+
* // Replace all themes
|
|
1297
|
+
* editor.updateThemes({ default: myDefaultTheme, ocean: myOceanTheme })
|
|
1298
|
+
*
|
|
1299
|
+
* // Update via callback
|
|
1300
|
+
* editor.updateThemes((themes) => {
|
|
1301
|
+
* delete themes.ocean
|
|
1302
|
+
* return themes
|
|
1303
|
+
* })
|
|
1304
|
+
* ```
|
|
1305
|
+
*
|
|
1306
|
+
* @public
|
|
1307
|
+
*/
|
|
1308
|
+
updateThemes(themes: ((themes: TLThemes) => TLThemes) | TLThemes): this;
|
|
1309
|
+
/**
|
|
1310
|
+
* Register or update a single theme definition. The theme is keyed by its `id` property.
|
|
1311
|
+
*
|
|
1312
|
+
* @example
|
|
1313
|
+
* ```ts
|
|
1314
|
+
* // Override a property on the default theme
|
|
1315
|
+
* editor.updateTheme({ ...editor.getTheme('default')!, fontSize: 24 })
|
|
1316
|
+
*
|
|
1317
|
+
* // Register a new theme
|
|
1318
|
+
* editor.updateTheme({ id: 'ocean', ...myOceanTheme })
|
|
1319
|
+
* ```
|
|
1320
|
+
*
|
|
1321
|
+
* @public
|
|
1322
|
+
*/
|
|
1323
|
+
updateTheme(theme: TLTheme): this;
|
|
1163
1324
|
/**
|
|
1164
1325
|
* A map of shape utility classes (TLShapeUtils) by shape type.
|
|
1165
1326
|
*
|
|
@@ -1168,6 +1329,7 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
1168
1329
|
shapeUtils: {
|
|
1169
1330
|
readonly [K in string]?: ShapeUtil<TLShape>;
|
|
1170
1331
|
};
|
|
1332
|
+
/* Excluded from this release type: _shapeUtilsByAssetType */
|
|
1171
1333
|
styleProps: {
|
|
1172
1334
|
[key: string]: Map<StyleProp<any>, string>;
|
|
1173
1335
|
};
|
|
@@ -1199,6 +1361,15 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
1199
1361
|
hasShapeUtil(shape: TLShape | TLShapePartial<TLShape>): boolean;
|
|
1200
1362
|
hasShapeUtil(type: TLShape['type']): boolean;
|
|
1201
1363
|
hasShapeUtil<T extends ShapeUtil>(type: T extends ShapeUtil<infer R> ? R['type'] : string): boolean;
|
|
1364
|
+
/**
|
|
1365
|
+
* Get the shape util that handles the given asset type.
|
|
1366
|
+
* Returns the shape util whose {@link ShapeUtil.handledAssetTypes} includes
|
|
1367
|
+
* the given asset type, or undefined if none matches.
|
|
1368
|
+
*
|
|
1369
|
+
* @param assetType - The asset type string.
|
|
1370
|
+
* @public
|
|
1371
|
+
*/
|
|
1372
|
+
getShapeUtilForAssetType(assetType: string): ShapeUtil | undefined;
|
|
1202
1373
|
/**
|
|
1203
1374
|
* A map of shape utility classes (TLShapeUtils) by shape type.
|
|
1204
1375
|
*
|
|
@@ -1229,6 +1400,40 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
1229
1400
|
type: S['type'];
|
|
1230
1401
|
} | S): BindingUtil<S>;
|
|
1231
1402
|
getBindingUtil<T extends BindingUtil>(type: T extends BindingUtil<infer R> ? R['type'] : string): T;
|
|
1403
|
+
/**
|
|
1404
|
+
* A map of asset utility classes by asset type.
|
|
1405
|
+
*
|
|
1406
|
+
* @public
|
|
1407
|
+
*/
|
|
1408
|
+
assetUtils: {
|
|
1409
|
+
readonly [K in string]?: AssetUtil<TLAsset>;
|
|
1410
|
+
};
|
|
1411
|
+
/**
|
|
1412
|
+
* Get an asset util from an asset or asset type.
|
|
1413
|
+
*
|
|
1414
|
+
* @param arg - An asset, asset type string, or object with type.
|
|
1415
|
+
*
|
|
1416
|
+
* @public
|
|
1417
|
+
*/
|
|
1418
|
+
getAssetUtil<S extends TLAsset>(asset: {
|
|
1419
|
+
type: S['type'];
|
|
1420
|
+
} | S): AssetUtil<S>;
|
|
1421
|
+
getAssetUtil(type: string): AssetUtil;
|
|
1422
|
+
/**
|
|
1423
|
+
* Returns true if the editor has an asset util for the given asset type.
|
|
1424
|
+
*
|
|
1425
|
+
* @public
|
|
1426
|
+
*/
|
|
1427
|
+
hasAssetUtil(arg: {
|
|
1428
|
+
type: string;
|
|
1429
|
+
} | string): boolean;
|
|
1430
|
+
/**
|
|
1431
|
+
* Get the asset util that accepts the given MIME type.
|
|
1432
|
+
* Returns null if no registered asset util accepts the MIME type.
|
|
1433
|
+
*
|
|
1434
|
+
* @public
|
|
1435
|
+
*/
|
|
1436
|
+
getAssetUtilForMimeType(mimeType: string): AssetUtil | null;
|
|
1232
1437
|
/**
|
|
1233
1438
|
* A manager for the editor's history.
|
|
1234
1439
|
*
|
|
@@ -2259,6 +2464,32 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
2259
2464
|
* @public
|
|
2260
2465
|
*/
|
|
2261
2466
|
getCollaboratorsOnCurrentPage(): TLInstancePresence[];
|
|
2467
|
+
/**
|
|
2468
|
+
* Get the current user's ID for attribution purposes.
|
|
2469
|
+
* Also ensures a `user:` record exists in the store for the current user.
|
|
2470
|
+
* Returns `null` when the user store has no current user.
|
|
2471
|
+
*
|
|
2472
|
+
* @public
|
|
2473
|
+
*/
|
|
2474
|
+
getAttributionUserId(): null | string;
|
|
2475
|
+
/* Excluded from this release type: _ensureUserRecord */
|
|
2476
|
+
/**
|
|
2477
|
+
* Resolve a display name for a user ID. Asks the
|
|
2478
|
+
* {@link @tldraw/tlschema#TLUserStore} first (the app's source of truth),
|
|
2479
|
+
* falling back to the `user:` record in the store.
|
|
2480
|
+
*
|
|
2481
|
+
* @public
|
|
2482
|
+
*/
|
|
2483
|
+
getAttributionDisplayName(userId: null | string): null | string;
|
|
2484
|
+
/**
|
|
2485
|
+
* Resolve a user record by ID. Asks the
|
|
2486
|
+
* {@link @tldraw/tlschema#TLUserStore} first (the app's source of truth),
|
|
2487
|
+
* falling back to the `user:` record in the store.
|
|
2488
|
+
*
|
|
2489
|
+
* @public
|
|
2490
|
+
*/
|
|
2491
|
+
getAttributionUser(userId: null | string): null | TLUser;
|
|
2492
|
+
/* Excluded from this release type: _getReferencedUserIds */
|
|
2262
2493
|
private _isLockedOnFollowingUser;
|
|
2263
2494
|
/**
|
|
2264
2495
|
* Start viewport-following a user.
|
|
@@ -4353,6 +4584,35 @@ export declare interface Geometry2dOptions extends TransformedGeometry2dOptions
|
|
|
4353
4584
|
*/
|
|
4354
4585
|
export declare function getArcMeasure(A: number, B: number, sweepFlag: number, largeArcFlag: number): number;
|
|
4355
4586
|
|
|
4587
|
+
/**
|
|
4588
|
+
* Resolves a color style value to its actual CSS color string for a given theme and variant.
|
|
4589
|
+
* If the color is not a default theme color, returns the color value as-is.
|
|
4590
|
+
*
|
|
4591
|
+
* @param colors - The color palette for the current color mode (e.g. `theme.colors[colorMode]`)
|
|
4592
|
+
* @param color - The color style value to resolve
|
|
4593
|
+
* @param variant - Which variant of the color to return (solid, fill, pattern, etc.)
|
|
4594
|
+
* @returns The CSS color string for the specified color and variant
|
|
4595
|
+
*
|
|
4596
|
+
* @example
|
|
4597
|
+
* ```ts
|
|
4598
|
+
* import { getColorValue } from 'tldraw'
|
|
4599
|
+
*
|
|
4600
|
+
* const colors = editor.getCurrentTheme().colors[editor.getColorMode()]
|
|
4601
|
+
*
|
|
4602
|
+
* // Get the solid variant of red
|
|
4603
|
+
* const redSolid = getColorValue(colors, 'red', 'solid') // '#e03131'
|
|
4604
|
+
*
|
|
4605
|
+
* // Get the fill variant of blue
|
|
4606
|
+
* const blueFill = getColorValue(colors, 'blue', 'fill') // '#4465e9'
|
|
4607
|
+
*
|
|
4608
|
+
* // Custom color passes through unchanged
|
|
4609
|
+
* const customColor = getColorValue(colors, '#ff0000', 'solid') // '#ff0000'
|
|
4610
|
+
* ```
|
|
4611
|
+
*
|
|
4612
|
+
* @public
|
|
4613
|
+
*/
|
|
4614
|
+
export declare function getColorValue(colors: TLThemeColors, color: string | TLDefaultColorStyle, variant: keyof TLDefaultColor): string;
|
|
4615
|
+
|
|
4356
4616
|
/** @public */
|
|
4357
4617
|
export declare function getCursor(cursor: TLCursorType, rotation?: number, color?: string): string;
|
|
4358
4618
|
|
|
@@ -4523,7 +4783,7 @@ export declare class GroupShapeUtil extends ShapeUtil<TLGroupShape> {
|
|
|
4523
4783
|
static type: "group";
|
|
4524
4784
|
static props: RecordProps<TLGroupShape>;
|
|
4525
4785
|
static migrations: TLPropsMigrations;
|
|
4526
|
-
hideSelectionBoundsFg(): boolean;
|
|
4786
|
+
hideSelectionBoundsFg(shape: TLGroupShape): boolean;
|
|
4527
4787
|
canBind(): boolean;
|
|
4528
4788
|
canResize(): boolean;
|
|
4529
4789
|
canResizeChildren(): boolean;
|
|
@@ -4809,6 +5069,12 @@ export declare class InputsManager {
|
|
|
4809
5069
|
get isPointing(): boolean;
|
|
4810
5070
|
set isPointing(isPointing: boolean);
|
|
4811
5071
|
/* Excluded from this release type: setIsPointing */
|
|
5072
|
+
private _isRightPointing;
|
|
5073
|
+
/**
|
|
5074
|
+
* Whether the user is right-click pointing (before drag threshold).
|
|
5075
|
+
*/
|
|
5076
|
+
getIsRightPointing(): boolean;
|
|
5077
|
+
/* Excluded from this release type: setIsRightPointing */
|
|
4812
5078
|
private _isPinching;
|
|
4813
5079
|
/**
|
|
4814
5080
|
* Whether the user is pinching.
|
|
@@ -5165,6 +5431,94 @@ export declare function parseDeepLinkString(deepLinkString: string): TLDeepLink;
|
|
|
5165
5431
|
/** @public */
|
|
5166
5432
|
export declare type PerfectDashTerminal = 'none' | 'outset' | 'skip';
|
|
5167
5433
|
|
|
5434
|
+
/**
|
|
5435
|
+
* Optional adapter that pipes PerformanceManager events into browser
|
|
5436
|
+
* `performance.mark()` / `performance.measure()` for DevTools integration.
|
|
5437
|
+
*
|
|
5438
|
+
* Tree-shakeable — only included if imported.
|
|
5439
|
+
*
|
|
5440
|
+
* @example
|
|
5441
|
+
* ```ts
|
|
5442
|
+
* const adapter = new PerformanceApiAdapter(editor.performance)
|
|
5443
|
+
* // ... later
|
|
5444
|
+
* adapter.dispose()
|
|
5445
|
+
* ```
|
|
5446
|
+
*
|
|
5447
|
+
* @public
|
|
5448
|
+
*/
|
|
5449
|
+
export declare class PerformanceApiAdapter {
|
|
5450
|
+
private cleanups;
|
|
5451
|
+
constructor(perfManager: PerformanceManager);
|
|
5452
|
+
/** Remove all listeners and stop piping events. @public */
|
|
5453
|
+
dispose(): void;
|
|
5454
|
+
}
|
|
5455
|
+
|
|
5456
|
+
/**
|
|
5457
|
+
* Manages performance event subscriptions for the editor. Available as `editor.performance`.
|
|
5458
|
+
*
|
|
5459
|
+
* Listeners are lazy — internal editor hooks (frame, shape events) are only attached while
|
|
5460
|
+
* at least one subscriber exists, so there is zero overhead when unused.
|
|
5461
|
+
*
|
|
5462
|
+
* @example
|
|
5463
|
+
* ```ts
|
|
5464
|
+
* const unsub = editor.performance.on('interaction-end', (event) => {
|
|
5465
|
+
* console.log(`${event.name}: ${event.fps.toFixed(1)} fps, p95=${event.p95FrameTime.toFixed(1)}ms`)
|
|
5466
|
+
* })
|
|
5467
|
+
* ```
|
|
5468
|
+
*
|
|
5469
|
+
* @public
|
|
5470
|
+
*/
|
|
5471
|
+
export declare class PerformanceManager {
|
|
5472
|
+
/* Excluded from this release type: emitter */
|
|
5473
|
+
private editor;
|
|
5474
|
+
private activeInteraction;
|
|
5475
|
+
private activeCamera;
|
|
5476
|
+
private frameCleanup;
|
|
5477
|
+
private shapeCreatedCleanup;
|
|
5478
|
+
private shapeEditedCleanup;
|
|
5479
|
+
private shapeDeletedCleanup;
|
|
5480
|
+
private loafObserver;
|
|
5481
|
+
constructor(editor: Editor);
|
|
5482
|
+
/**
|
|
5483
|
+
* Subscribe to a performance event. Returns an unsubscribe function.
|
|
5484
|
+
*
|
|
5485
|
+
* @example
|
|
5486
|
+
* ```ts
|
|
5487
|
+
* const unsub = editor.performance.on('interaction-end', (event) => {
|
|
5488
|
+
* sendToAnalytics({ name: event.name, fps: event.fps, p95: event.p95FrameTime })
|
|
5489
|
+
* })
|
|
5490
|
+
* // later: unsub()
|
|
5491
|
+
* ```
|
|
5492
|
+
*
|
|
5493
|
+
* @public
|
|
5494
|
+
*/
|
|
5495
|
+
on<K extends keyof TLPerfEventMap>(event: K, fn: (...args: TLPerfEventMap[K]) => void): () => void;
|
|
5496
|
+
/**
|
|
5497
|
+
* Subscribe to a performance event once. The listener is removed after the first invocation.
|
|
5498
|
+
* Returns an unsubscribe function for early removal.
|
|
5499
|
+
*
|
|
5500
|
+
* @public
|
|
5501
|
+
*/
|
|
5502
|
+
once<K extends keyof TLPerfEventMap>(event: K, fn: (...args: TLPerfEventMap[K]) => void): () => void;
|
|
5503
|
+
/* Excluded from this release type: dispose */
|
|
5504
|
+
/* Excluded from this release type: _notifyInteractionStart */
|
|
5505
|
+
/* Excluded from this release type: _notifyInteractionEnd */
|
|
5506
|
+
/* Excluded from this release type: _notifyCameraOperation */
|
|
5507
|
+
/* Excluded from this release type: _notifyUndoRedo */
|
|
5508
|
+
private _startCameraSession;
|
|
5509
|
+
private _endCameraSession;
|
|
5510
|
+
private _onFrame;
|
|
5511
|
+
private _onShapesCreated;
|
|
5512
|
+
private _onShapesEdited;
|
|
5513
|
+
private _onShapesDeleted;
|
|
5514
|
+
private _startLoafObserver;
|
|
5515
|
+
private _stopLoafObserver;
|
|
5516
|
+
private _needsFrameListener;
|
|
5517
|
+
private _needsLoafObserver;
|
|
5518
|
+
private _maybeAttachLazyListeners;
|
|
5519
|
+
private _maybeDetachLazyListeners;
|
|
5520
|
+
}
|
|
5521
|
+
|
|
5168
5522
|
/**
|
|
5169
5523
|
* Find the approximate perimeter of an ellipse.
|
|
5170
5524
|
*
|
|
@@ -5359,6 +5713,16 @@ export declare function resizeScaled(shape: TLBaseShape<any, {
|
|
|
5359
5713
|
y: number;
|
|
5360
5714
|
};
|
|
5361
5715
|
|
|
5716
|
+
/**
|
|
5717
|
+
* Resolve a partial set of user-provided themes into a complete `TLThemes`
|
|
5718
|
+
* record by merging with `DEFAULT_THEME`. The result is suitable for passing to
|
|
5719
|
+
* `registerColorsFromThemes`, `registerFontsFromThemes`, and the
|
|
5720
|
+
* `ThemeManager` constructor.
|
|
5721
|
+
*
|
|
5722
|
+
* @public
|
|
5723
|
+
*/
|
|
5724
|
+
export declare function resolveThemes(themes?: Partial<TLThemes>): TLThemes;
|
|
5725
|
+
|
|
5362
5726
|
/** @public */
|
|
5363
5727
|
export declare type RichTextFontVisitor = (node: TiptapNode, state: RichTextFontVisitorState, addFont: (font: TLFontFace) => void) => RichTextFontVisitorState;
|
|
5364
5728
|
|
|
@@ -5640,12 +6004,32 @@ export declare abstract class ShapeUtil<Shape extends TLShape = TLShape> {
|
|
|
5640
6004
|
* @public
|
|
5641
6005
|
*/
|
|
5642
6006
|
static type: string;
|
|
6007
|
+
/**
|
|
6008
|
+
* The asset types that this shape can be created from.
|
|
6009
|
+
* When a file is dropped on the canvas, the editor finds the shape util
|
|
6010
|
+
* whose `handledAssetTypes` includes the asset's type and calls
|
|
6011
|
+
* {@link ShapeUtil.createShapeForAsset} to produce the shape.
|
|
6012
|
+
*
|
|
6013
|
+
* @public
|
|
6014
|
+
*/
|
|
6015
|
+
static handledAssetTypes?: readonly string[];
|
|
5643
6016
|
/**
|
|
5644
6017
|
* Get the default props for a shape.
|
|
5645
6018
|
*
|
|
5646
6019
|
* @public
|
|
5647
6020
|
*/
|
|
5648
6021
|
abstract getDefaultProps(): Shape['props'];
|
|
6022
|
+
/**
|
|
6023
|
+
* Create a shape partial for placing an asset on the canvas.
|
|
6024
|
+
* Only called for shapes whose constructor declares matching
|
|
6025
|
+
* {@link ShapeUtil.handledAssetTypes | `handledAssetTypes`}.
|
|
6026
|
+
*
|
|
6027
|
+
* @param asset - The asset to create a shape for.
|
|
6028
|
+
* @param position - Where to place the shape.
|
|
6029
|
+
* @returns A shape partial, or null if this shape can't be created for the asset.
|
|
6030
|
+
* @public
|
|
6031
|
+
*/
|
|
6032
|
+
createShapeForAsset?(asset: TLAsset, position: VecModel): null | TLShapePartial;
|
|
5649
6033
|
/**
|
|
5650
6034
|
* Get the shape's geometry.
|
|
5651
6035
|
*
|
|
@@ -5726,7 +6110,7 @@ export declare abstract class ShapeUtil<Shape extends TLShape = TLShape> {
|
|
|
5726
6110
|
*
|
|
5727
6111
|
* @public
|
|
5728
6112
|
*/
|
|
5729
|
-
canBind(
|
|
6113
|
+
canBind(opts: TLShapeUtilCanBindOpts): boolean;
|
|
5730
6114
|
/**
|
|
5731
6115
|
* Whether the shape can be double clicked to edit.
|
|
5732
6116
|
*
|
|
@@ -5907,7 +6291,7 @@ export declare abstract class ShapeUtil<Shape extends TLShape = TLShape> {
|
|
|
5907
6291
|
* @param type - The shape type.
|
|
5908
6292
|
* @public
|
|
5909
6293
|
*/
|
|
5910
|
-
canReceiveNewChildrenOfType(shape: Shape,
|
|
6294
|
+
canReceiveNewChildrenOfType(shape: Shape, type: TLShape['type']): boolean;
|
|
5911
6295
|
/**
|
|
5912
6296
|
* Get the shape as an SVG object.
|
|
5913
6297
|
*
|
|
@@ -5947,6 +6331,14 @@ export declare abstract class ShapeUtil<Shape extends TLShape = TLShape> {
|
|
|
5947
6331
|
*/
|
|
5948
6332
|
getHandleSnapGeometry(shape: Shape): HandleSnapGeometry;
|
|
5949
6333
|
getText(shape: Shape): string | undefined;
|
|
6334
|
+
/**
|
|
6335
|
+
* Return user IDs referenced in shape-specific props.
|
|
6336
|
+
* Used when copying shapes to include referenced users on the clipboard.
|
|
6337
|
+
* Override this if your shape stores user IDs in custom props.
|
|
6338
|
+
*
|
|
6339
|
+
* @public
|
|
6340
|
+
*/
|
|
6341
|
+
getReferencedUserIds(shape: Shape): string[];
|
|
5950
6342
|
getAriaDescriptor(shape: Shape): string | undefined;
|
|
5951
6343
|
/**
|
|
5952
6344
|
* A callback called just before a shape is created. This method provides a last chance to modify
|
|
@@ -6342,6 +6734,8 @@ export declare abstract class StateNode implements Partial<TLEventHandlers> {
|
|
|
6342
6734
|
static children?: () => TLStateNodeConstructor[];
|
|
6343
6735
|
static isLockable: boolean;
|
|
6344
6736
|
static useCoalescedEvents: boolean;
|
|
6737
|
+
/** Set to `true` in subclasses to emit interaction-start/end performance events when this state is entered/exited. */
|
|
6738
|
+
static trackPerformance: boolean;
|
|
6345
6739
|
id: string;
|
|
6346
6740
|
type: 'branch' | 'leaf' | 'root';
|
|
6347
6741
|
shapeType?: string;
|
|
@@ -6476,6 +6870,10 @@ export declare interface SvgExportContext {
|
|
|
6476
6870
|
* Whether the export should be in dark mode.
|
|
6477
6871
|
*/
|
|
6478
6872
|
readonly isDarkMode: boolean;
|
|
6873
|
+
/**
|
|
6874
|
+
* The color mode to use for this export.
|
|
6875
|
+
*/
|
|
6876
|
+
readonly colorMode: 'dark' | 'light';
|
|
6479
6877
|
/**
|
|
6480
6878
|
* The scale of the export - how much CSS pixels will be scaled up/down by.
|
|
6481
6879
|
*/
|
|
@@ -6507,15 +6905,18 @@ export declare const TAB_ID: string;
|
|
|
6507
6905
|
export declare class TextManager {
|
|
6508
6906
|
editor: Editor;
|
|
6509
6907
|
private elm;
|
|
6908
|
+
private poolElms;
|
|
6510
6909
|
constructor(editor: Editor);
|
|
6910
|
+
private createMeasurementEl;
|
|
6911
|
+
private resetElementStyles;
|
|
6511
6912
|
private setElementStyles;
|
|
6913
|
+
private getMeasureStyles;
|
|
6512
6914
|
dispose(): void;
|
|
6513
|
-
|
|
6514
|
-
|
|
6515
|
-
|
|
6516
|
-
|
|
6517
|
-
|
|
6518
|
-
};
|
|
6915
|
+
private ensurePoolSize;
|
|
6916
|
+
private getPoolItem;
|
|
6917
|
+
measureHtmlBatch(requests: BatchMeasurementRequest[]): TLMeasuredTextSize[];
|
|
6918
|
+
measureText(textToMeasure: string, opts: TLMeasureTextOpts): TLMeasuredTextSize;
|
|
6919
|
+
measureHtml(html: string, opts: TLMeasureTextOpts): TLMeasuredTextSize;
|
|
6519
6920
|
/**
|
|
6520
6921
|
* Given an html element, measure the position of each span of unbroken
|
|
6521
6922
|
* word/white-space characters within any text nodes it contains.
|
|
@@ -6543,6 +6944,47 @@ export declare class TextManager {
|
|
|
6543
6944
|
}[];
|
|
6544
6945
|
}
|
|
6545
6946
|
|
|
6947
|
+
/**
|
|
6948
|
+
* Manages the editor's color themes.
|
|
6949
|
+
*
|
|
6950
|
+
* Stores named theme definitions (each containing light and dark color palettes
|
|
6951
|
+
* alongside shared properties like font size). The current theme is resolved by
|
|
6952
|
+
* combining the current theme name with the user's color mode preference.
|
|
6953
|
+
*
|
|
6954
|
+
* **Terminology:**
|
|
6955
|
+
* - **Theme** (`TLTheme`): A named set of colors and typographic values for both light and dark modes.
|
|
6956
|
+
* - **Color mode** (`'light' | 'dark'`): The resolved appearance mode, derived from the user's
|
|
6957
|
+
* `colorScheme` preference (`'light' | 'dark' | 'system'`). Access via `getColorMode()`.
|
|
6958
|
+
*
|
|
6959
|
+
* @public
|
|
6960
|
+
*/
|
|
6961
|
+
export declare class ThemeManager {
|
|
6962
|
+
private readonly editor;
|
|
6963
|
+
private readonly _themes;
|
|
6964
|
+
private readonly _currentThemeId;
|
|
6965
|
+
constructor(editor: Editor, options: {
|
|
6966
|
+
initial: TLThemeId;
|
|
6967
|
+
themes: TLThemes;
|
|
6968
|
+
});
|
|
6969
|
+
/** Get the current color mode based on the user's dark mode preference. */
|
|
6970
|
+
getColorMode(): 'dark' | 'light';
|
|
6971
|
+
/** Get all registered theme definitions. */
|
|
6972
|
+
getThemes(): TLThemes;
|
|
6973
|
+
/** Get a single theme definition by id. */
|
|
6974
|
+
getTheme(id: TLThemeId): TLTheme | undefined;
|
|
6975
|
+
/** Get the id of the current theme. */
|
|
6976
|
+
getCurrentThemeId(): TLThemeId;
|
|
6977
|
+
getCurrentTheme(): TLTheme;
|
|
6978
|
+
/** Set the current theme by id. The theme must have been previously registered. */
|
|
6979
|
+
setCurrentTheme(id: TLThemeId): void;
|
|
6980
|
+
/** Replace all theme definitions, or update them via a callback that receives a deep copy. */
|
|
6981
|
+
updateThemes(themes: ((themes: TLThemes) => TLThemes) | TLThemes): void;
|
|
6982
|
+
/** Register or update a named theme definition. */
|
|
6983
|
+
updateTheme(theme: TLTheme): void;
|
|
6984
|
+
/** Clean up any resources held by the manager. */
|
|
6985
|
+
dispose(): void;
|
|
6986
|
+
}
|
|
6987
|
+
|
|
6546
6988
|
/* Excluded from this release type: TickManager */
|
|
6547
6989
|
|
|
6548
6990
|
/**
|
|
@@ -6561,12 +7003,23 @@ export declare type TiptapNode = Node_2;
|
|
|
6561
7003
|
/** @public */
|
|
6562
7004
|
export declare type TLAdjacentDirection = 'down' | 'left' | 'next' | 'prev' | 'right' | 'up';
|
|
6563
7005
|
|
|
7006
|
+
/** @public */
|
|
7007
|
+
export declare type TLAnyAssetUtilConstructor = TLAssetUtilConstructor<any>;
|
|
7008
|
+
|
|
6564
7009
|
/** @public */
|
|
6565
7010
|
export declare type TLAnyBindingUtilConstructor = TLBindingUtilConstructor<any>;
|
|
6566
7011
|
|
|
6567
7012
|
/** @public */
|
|
6568
7013
|
export declare type TLAnyShapeUtilConstructor = TLShapeUtilConstructor<any>;
|
|
6569
7014
|
|
|
7015
|
+
/** @public */
|
|
7016
|
+
export declare interface TLAssetUtilConstructor<T extends TLAsset = TLAsset, U extends AssetUtil<T> = AssetUtil<T>> {
|
|
7017
|
+
new (editor: Editor): U;
|
|
7018
|
+
type: T['type'];
|
|
7019
|
+
props?: RecordProps<T>;
|
|
7020
|
+
migrations?: LegacyMigrations | MigrationSequence | TLPropsMigrations;
|
|
7021
|
+
}
|
|
7022
|
+
|
|
6570
7023
|
/** @public */
|
|
6571
7024
|
export declare type TLBaseBoxShape = ExtractShapeByProps<{
|
|
6572
7025
|
h: number;
|
|
@@ -6656,6 +7109,29 @@ export declare interface TLCameraConstraints {
|
|
|
6656
7109
|
};
|
|
6657
7110
|
}
|
|
6658
7111
|
|
|
7112
|
+
/**
|
|
7113
|
+
* Emitted when a camera operation ends (after a 50ms debounce), with aggregated frame time stats.
|
|
7114
|
+
* @public
|
|
7115
|
+
*/
|
|
7116
|
+
export declare interface TLCameraEndPerfEvent extends TLPerfFrameTimeStats {
|
|
7117
|
+
/** Whether this was a pan or zoom operation. */
|
|
7118
|
+
type: 'panning' | 'zooming';
|
|
7119
|
+
/** Total shapes on the current page. */
|
|
7120
|
+
shapeCount: number;
|
|
7121
|
+
/** Number of shapes visible (not culled) in the viewport. */
|
|
7122
|
+
visibleShapeCount: number;
|
|
7123
|
+
/** Number of shapes culled (off-screen) from rendering. */
|
|
7124
|
+
culledShapeCount: number;
|
|
7125
|
+
/** Viewport width in screen pixels. */
|
|
7126
|
+
viewportWidth: number;
|
|
7127
|
+
/** Viewport height in screen pixels. */
|
|
7128
|
+
viewportHeight: number;
|
|
7129
|
+
/** Camera zoom level (`camera.z`) at session end. */
|
|
7130
|
+
zoomLevel: number;
|
|
7131
|
+
/** `performance.now()` when the camera session ended. */
|
|
7132
|
+
timestamp: number;
|
|
7133
|
+
}
|
|
7134
|
+
|
|
6659
7135
|
/** @public */
|
|
6660
7136
|
export declare interface TLCameraMoveOptions {
|
|
6661
7137
|
/** Whether to move the camera immediately, rather than on the next tick. */
|
|
@@ -6694,6 +7170,17 @@ export declare interface TLCameraOptions {
|
|
|
6694
7170
|
constraints?: TLCameraConstraints;
|
|
6695
7171
|
}
|
|
6696
7172
|
|
|
7173
|
+
/**
|
|
7174
|
+
* Emitted when a camera operation (pan or zoom) begins.
|
|
7175
|
+
* @public
|
|
7176
|
+
*/
|
|
7177
|
+
export declare interface TLCameraStartPerfEvent {
|
|
7178
|
+
/** Whether this is a pan or zoom operation. */
|
|
7179
|
+
type: 'panning' | 'zooming';
|
|
7180
|
+
/** `performance.now()` when the camera session started. */
|
|
7181
|
+
timestamp: number;
|
|
7182
|
+
}
|
|
7183
|
+
|
|
6697
7184
|
/** @public */
|
|
6698
7185
|
export declare type TLCancelEvent = (info: TLCancelEventInfo) => void;
|
|
6699
7186
|
|
|
@@ -6727,6 +7214,40 @@ export declare type TLCLickEventName = 'double_click' | 'quadruple_click' | 'tri
|
|
|
6727
7214
|
/** @public */
|
|
6728
7215
|
export declare type TLClickState = 'idle' | 'overflow' | 'pendingDouble' | 'pendingOverflow' | 'pendingQuadruple' | 'pendingTriple';
|
|
6729
7216
|
|
|
7217
|
+
/**
|
|
7218
|
+
* Raw clipboard paste payload, before tldraw parses clipboard contents into {@link TLExternalContent}.
|
|
7219
|
+
*
|
|
7220
|
+
* - `native-event`: from the `paste` event — `clipboardData` is available synchronously (unlike async
|
|
7221
|
+
* `navigator.clipboard.read()`).
|
|
7222
|
+
* - `clipboard-read`: from an explicit `navigator.clipboard.read()` call — only `ClipboardItem[]`
|
|
7223
|
+
* exists
|
|
7224
|
+
* (no `DataTransfer`).
|
|
7225
|
+
*
|
|
7226
|
+
* @public
|
|
7227
|
+
*/
|
|
7228
|
+
export declare type TLClipboardPasteRawInfo = {
|
|
7229
|
+
readonly clipboardData: DataTransfer | null;
|
|
7230
|
+
readonly editor: Editor;
|
|
7231
|
+
readonly event: ClipboardEvent;
|
|
7232
|
+
readonly point: undefined | VecLike;
|
|
7233
|
+
readonly source: 'native-event';
|
|
7234
|
+
} | {
|
|
7235
|
+
readonly clipboardItems: readonly ClipboardItem[];
|
|
7236
|
+
readonly editor: Editor;
|
|
7237
|
+
readonly point: undefined | VecLike;
|
|
7238
|
+
readonly source: 'clipboard-read';
|
|
7239
|
+
};
|
|
7240
|
+
|
|
7241
|
+
/**
|
|
7242
|
+
* Identifies how a clipboard write was triggered (copy vs cut, keyboard vs menu).
|
|
7243
|
+
*
|
|
7244
|
+
* @public
|
|
7245
|
+
*/
|
|
7246
|
+
export declare interface TLClipboardWriteInfo {
|
|
7247
|
+
readonly operation: 'copy' | 'cut';
|
|
7248
|
+
readonly source: 'menu' | 'native';
|
|
7249
|
+
}
|
|
7250
|
+
|
|
6730
7251
|
/** @public */
|
|
6731
7252
|
export declare interface TLCollaboratorHintProps {
|
|
6732
7253
|
userId: string;
|
|
@@ -6754,6 +7275,7 @@ export declare interface TLContent {
|
|
|
6754
7275
|
rootShapeIds: TLShapeId[];
|
|
6755
7276
|
assets: TLAsset[];
|
|
6756
7277
|
schema: SerializedSchema;
|
|
7278
|
+
users?: TLUser[];
|
|
6757
7279
|
}
|
|
6758
7280
|
|
|
6759
7281
|
/**
|
|
@@ -6775,6 +7297,12 @@ export declare interface TLCropInfo<T extends TLShape> {
|
|
|
6775
7297
|
aspectRatioLocked?: boolean;
|
|
6776
7298
|
}
|
|
6777
7299
|
|
|
7300
|
+
/** @public */
|
|
7301
|
+
export declare interface TLCurrentUser {
|
|
7302
|
+
readonly userPreferences: Signal<TLUserPreferences>;
|
|
7303
|
+
readonly setUserPreferences: (userPreferences: TLUserPreferences) => void;
|
|
7304
|
+
}
|
|
7305
|
+
|
|
6778
7306
|
/** @public */
|
|
6779
7307
|
export declare interface TLCursorProps {
|
|
6780
7308
|
userId: string;
|
|
@@ -6875,6 +7403,10 @@ export declare interface TldrawEditorBaseProps {
|
|
|
6875
7403
|
* An array of binding utils to use in the editor.
|
|
6876
7404
|
*/
|
|
6877
7405
|
bindingUtils?: readonly TLAnyBindingUtilConstructor[];
|
|
7406
|
+
/**
|
|
7407
|
+
* An array of asset utils to use in the editor.
|
|
7408
|
+
*/
|
|
7409
|
+
assetUtils?: readonly TLAnyAssetUtilConstructor[];
|
|
6878
7410
|
/**
|
|
6879
7411
|
* An array of tools to add to the editor's state chart.
|
|
6880
7412
|
*/
|
|
@@ -6902,11 +7434,23 @@ export declare interface TldrawEditorBaseProps {
|
|
|
6902
7434
|
/**
|
|
6903
7435
|
* The user interacting with the editor.
|
|
6904
7436
|
*/
|
|
6905
|
-
user?:
|
|
7437
|
+
user?: TLCurrentUser;
|
|
6906
7438
|
/**
|
|
6907
|
-
*
|
|
7439
|
+
* The editor's color scheme. Defaults to `'light'`.
|
|
7440
|
+
*
|
|
7441
|
+
* - `'light'` - Always use light mode.
|
|
7442
|
+
* - `'dark'` - Always use dark mode.
|
|
7443
|
+
* - `'system'` - Follow the OS color scheme preference.
|
|
6908
7444
|
*/
|
|
6909
|
-
|
|
7445
|
+
colorScheme?: 'dark' | 'light' | 'system';
|
|
7446
|
+
/**
|
|
7447
|
+
* Named themes for the editor.
|
|
7448
|
+
*/
|
|
7449
|
+
themes?: Partial<TLThemes>;
|
|
7450
|
+
/**
|
|
7451
|
+
* The id of the initially active theme. Defaults to `'default'`.
|
|
7452
|
+
*/
|
|
7453
|
+
initialTheme?: TLThemeId;
|
|
6910
7454
|
/**
|
|
6911
7455
|
* Camera options for the editor.
|
|
6912
7456
|
*
|
|
@@ -7124,6 +7668,12 @@ export declare interface TldrawOptions {
|
|
|
7124
7668
|
* When false, the spacebar will not pan the camera.
|
|
7125
7669
|
*/
|
|
7126
7670
|
readonly spacebarPanning: boolean;
|
|
7671
|
+
/**
|
|
7672
|
+
* Whether to allow right-click + drag to pan the camera. When true, right-click + drag pans the
|
|
7673
|
+
* camera and a static right-click opens the context menu at the release position. When false,
|
|
7674
|
+
* right-click opens the context menu on press (no drag-to-pan).
|
|
7675
|
+
*/
|
|
7676
|
+
readonly rightClickPanning: boolean;
|
|
7127
7677
|
/**
|
|
7128
7678
|
* The default padding (in pixels) used when zooming to fit content in the viewport.
|
|
7129
7679
|
* This affects methods like `zoomToFit()`, `zoomToSelection()`, and `zoomToBounds()`.
|
|
@@ -7166,6 +7716,78 @@ export declare interface TldrawOptions {
|
|
|
7166
7716
|
* viewport's page dimensions regardless of overview zoom changes.
|
|
7167
7717
|
*/
|
|
7168
7718
|
readonly quickZoomPreservesScreenBounds: boolean;
|
|
7719
|
+
/**
|
|
7720
|
+
* Whether to use 2D canvas rendering for shape indicators. When true (default),
|
|
7721
|
+
* shapes that support it will render indicators on a 2D canvas for better
|
|
7722
|
+
* performance. When false, all indicators use legacy SVG rendering.
|
|
7723
|
+
*/
|
|
7724
|
+
readonly useCanvasIndicators: boolean;
|
|
7725
|
+
/**
|
|
7726
|
+
* Called before content is written to the clipboard during a copy or cut operation.
|
|
7727
|
+
* Receives the serialized content (shapes, bindings, assets) and can filter or transform
|
|
7728
|
+
* it before it reaches the clipboard.
|
|
7729
|
+
*
|
|
7730
|
+
* Return a modified `TLContent` object to change what is copied or cut. Return `false` to
|
|
7731
|
+
* cancel the clipboard write (for cut, the selected shapes are not removed). Return `void`
|
|
7732
|
+
* (or `undefined`) to pass through unchanged. You may return a `Promise` of those values if
|
|
7733
|
+
* the hook is async.
|
|
7734
|
+
*
|
|
7735
|
+
* @example
|
|
7736
|
+
* ```tsx
|
|
7737
|
+
* // Filter out "locked" shapes from copy
|
|
7738
|
+
* onBeforeCopyToClipboard({ content, operation }) {
|
|
7739
|
+
* return {
|
|
7740
|
+
* ...content,
|
|
7741
|
+
* shapes: content.shapes.filter(s => !s.meta.locked),
|
|
7742
|
+
* rootShapeIds: content.rootShapeIds.filter(id =>
|
|
7743
|
+
* content.shapes.find(s => s.id === id && !s.meta.locked)
|
|
7744
|
+
* ),
|
|
7745
|
+
* }
|
|
7746
|
+
* }
|
|
7747
|
+
* ```
|
|
7748
|
+
*/
|
|
7749
|
+
onBeforeCopyToClipboard?(info: {
|
|
7750
|
+
content: TLContent;
|
|
7751
|
+
editor: Editor;
|
|
7752
|
+
} & TLClipboardWriteInfo): Awaitable<false | TLContent | void>;
|
|
7753
|
+
/**
|
|
7754
|
+
* Called before pasted content is processed and shapes are created. Receives the parsed
|
|
7755
|
+
* external content from the clipboard and can filter, transform, or cancel it.
|
|
7756
|
+
*
|
|
7757
|
+
* Return `false` to cancel the paste. Return a modified content object to transform it.
|
|
7758
|
+
* Return `void` (or `undefined`) to pass through unchanged. You may return a `Promise` of
|
|
7759
|
+
* those values if the hook is async.
|
|
7760
|
+
*
|
|
7761
|
+
* This only fires for clipboard paste operations (keyboard shortcuts and menu actions),
|
|
7762
|
+
* not for file drops or programmatic `putExternalContent` calls.
|
|
7763
|
+
*
|
|
7764
|
+
* @example
|
|
7765
|
+
* ```tsx
|
|
7766
|
+
* // Block pasting of image files
|
|
7767
|
+
* onBeforePasteFromClipboard({ content }) {
|
|
7768
|
+
* if (content.type === 'files') {
|
|
7769
|
+
* const nonImages = content.files.filter(f => !f.type.startsWith('image/'))
|
|
7770
|
+
* if (nonImages.length === 0) return false
|
|
7771
|
+
* return { ...content, files: nonImages }
|
|
7772
|
+
* }
|
|
7773
|
+
* }
|
|
7774
|
+
* ```
|
|
7775
|
+
*/
|
|
7776
|
+
onBeforePasteFromClipboard?(info: {
|
|
7777
|
+
content: TLExternalContent<unknown>;
|
|
7778
|
+
editor: Editor;
|
|
7779
|
+
point?: VecLike;
|
|
7780
|
+
source: 'clipboard-read' | 'native-event';
|
|
7781
|
+
}): Awaitable<false | TLExternalContent<unknown> | void>;
|
|
7782
|
+
/**
|
|
7783
|
+
* Called first for keyboard and menu paste, **before** tldraw handles or parses clipboard data
|
|
7784
|
+
* (and before {@link TldrawOptions.onBeforePasteFromClipboard}).
|
|
7785
|
+
*
|
|
7786
|
+
* Return `false` to cancel tldraw's default paste handling for this gesture (same convention as
|
|
7787
|
+
* {@link TldrawOptions.onBeforePasteFromClipboard}). Use this when you handle paste yourself from
|
|
7788
|
+
* raw clipboard data, or to block the gesture entirely. Return `void` (or `undefined`) to continue.
|
|
7789
|
+
*/
|
|
7790
|
+
onClipboardPasteRaw?(info: TLClipboardPasteRawInfo): false | void;
|
|
7169
7791
|
/**
|
|
7170
7792
|
* Called when content is dropped on the canvas. Provides the page position
|
|
7171
7793
|
* where the drop occurred and the underlying drag event object.
|
|
@@ -7233,18 +7855,17 @@ export declare interface TLEditorOptions {
|
|
|
7233
7855
|
*/
|
|
7234
7856
|
bindingUtils: readonly TLAnyBindingUtilConstructor[];
|
|
7235
7857
|
/**
|
|
7236
|
-
* An array of
|
|
7858
|
+
* An array of asset utils to use in the editor. These will be used to handle asset-type-specific behavior.
|
|
7237
7859
|
*/
|
|
7238
|
-
|
|
7860
|
+
assetUtils?: readonly TLAnyAssetUtilConstructor[];
|
|
7239
7861
|
/**
|
|
7240
|
-
*
|
|
7241
|
-
* given, the body element will be used.
|
|
7862
|
+
* An array of tools to use in the editor. These will be used to handle events and manage user interactions in the editor.
|
|
7242
7863
|
*/
|
|
7243
|
-
|
|
7864
|
+
tools: readonly TLStateNodeConstructor[];
|
|
7244
7865
|
/**
|
|
7245
7866
|
* A user defined externally to replace the default user.
|
|
7246
7867
|
*/
|
|
7247
|
-
user?:
|
|
7868
|
+
user?: TLCurrentUser;
|
|
7248
7869
|
/**
|
|
7249
7870
|
* The editor's initial active tool (or other state node id).
|
|
7250
7871
|
*/
|
|
@@ -7253,27 +7874,15 @@ export declare interface TLEditorOptions {
|
|
|
7253
7874
|
* Whether to automatically focus the editor when it mounts.
|
|
7254
7875
|
*/
|
|
7255
7876
|
autoFocus?: boolean;
|
|
7256
|
-
/**
|
|
7257
|
-
* Whether to infer dark mode from the user's system preferences. Defaults to false.
|
|
7258
|
-
*/
|
|
7259
|
-
inferDarkMode?: boolean;
|
|
7260
|
-
/**
|
|
7261
|
-
* Options for the editor's camera.
|
|
7262
|
-
*
|
|
7263
|
-
* @deprecated Use `options.cameraOptions` instead. This will be removed in a future release.
|
|
7264
|
-
*/
|
|
7265
|
-
cameraOptions?: Partial<TLCameraOptions>;
|
|
7266
|
-
options?: Partial<TldrawOptions>;
|
|
7267
|
-
/**
|
|
7268
|
-
* Text options for the editor.
|
|
7269
|
-
*
|
|
7270
|
-
* @deprecated Use `options.text` instead. This prop will be removed in a future release.
|
|
7271
|
-
*/
|
|
7272
|
-
textOptions?: TLTextOptions;
|
|
7273
7877
|
licenseKey?: string;
|
|
7274
7878
|
fontAssetUrls?: {
|
|
7275
7879
|
[key: string]: string | undefined;
|
|
7276
7880
|
};
|
|
7881
|
+
/**
|
|
7882
|
+
* Should return a containing html element which has all the styles applied to the editor. If not
|
|
7883
|
+
* given, the body element will be used.
|
|
7884
|
+
*/
|
|
7885
|
+
getContainer(): HTMLElement;
|
|
7277
7886
|
/**
|
|
7278
7887
|
* Provides a way to hide shapes.
|
|
7279
7888
|
*
|
|
@@ -7290,6 +7899,40 @@ export declare interface TLEditorOptions {
|
|
|
7290
7899
|
* @param editor - The editor instance.
|
|
7291
7900
|
*/
|
|
7292
7901
|
getShapeVisibility?(shape: TLShape, editor: Editor): 'hidden' | 'inherit' | 'visible' | null | undefined;
|
|
7902
|
+
/**
|
|
7903
|
+
* Named theme definitions for the editor. Each theme contains shared
|
|
7904
|
+
* properties (font size, line height, stroke width) and color palettes
|
|
7905
|
+
* for both light and dark modes.
|
|
7906
|
+
*/
|
|
7907
|
+
themes?: Partial<TLThemes>;
|
|
7908
|
+
/**
|
|
7909
|
+
* The id of the initially active theme. Defaults to `'default'`.
|
|
7910
|
+
*/
|
|
7911
|
+
initialTheme?: TLThemeId;
|
|
7912
|
+
/**
|
|
7913
|
+
* The editor's color scheme preference, controls the default color mode. Defaults to `'light'`.
|
|
7914
|
+
*
|
|
7915
|
+
* - `'light'` - Always use light mode.
|
|
7916
|
+
* - `'dark'` - Always use dark mode.
|
|
7917
|
+
* - `'system'` - Follow the OS color scheme preference.
|
|
7918
|
+
*/
|
|
7919
|
+
colorScheme?: 'dark' | 'light' | 'system';
|
|
7920
|
+
/**
|
|
7921
|
+
* Additional configuration options for the tldraw editor.
|
|
7922
|
+
*/
|
|
7923
|
+
options?: Partial<TldrawOptions>;
|
|
7924
|
+
/**
|
|
7925
|
+
* Options for the editor's camera.
|
|
7926
|
+
*
|
|
7927
|
+
* @deprecated Use `options.cameraOptions` instead. This will be removed in a future release.
|
|
7928
|
+
*/
|
|
7929
|
+
cameraOptions?: Partial<TLCameraOptions>;
|
|
7930
|
+
/**
|
|
7931
|
+
* Text options for the editor.
|
|
7932
|
+
*
|
|
7933
|
+
* @deprecated Use `options.text` instead. This prop will be removed in a future release.
|
|
7934
|
+
*/
|
|
7935
|
+
textOptions?: TLTextOptions;
|
|
7293
7936
|
}
|
|
7294
7937
|
|
|
7295
7938
|
/**
|
|
@@ -7348,6 +7991,7 @@ export declare const tlenv: {
|
|
|
7348
7991
|
*/
|
|
7349
7992
|
export declare const tlenvReactive: Atom< {
|
|
7350
7993
|
isCoarsePointer: boolean;
|
|
7994
|
+
supportsP3ColorSpace: boolean;
|
|
7351
7995
|
}, unknown>;
|
|
7352
7996
|
|
|
7353
7997
|
/** @public */
|
|
@@ -7476,6 +8120,7 @@ export declare interface TLFileReplaceExternalContent extends TLBaseExternalCont
|
|
|
7476
8120
|
type: 'file-replace';
|
|
7477
8121
|
file: File;
|
|
7478
8122
|
shapeId: TLShapeId;
|
|
8123
|
+
/** @deprecated This field is no longer used by the default handler. It may be removed in a future version. */
|
|
7479
8124
|
isImage: boolean;
|
|
7480
8125
|
}
|
|
7481
8126
|
|
|
@@ -7487,69 +8132,18 @@ export declare interface TLFilesExternalContent extends TLBaseExternalContent {
|
|
|
7487
8132
|
}
|
|
7488
8133
|
|
|
7489
8134
|
/**
|
|
7490
|
-
*
|
|
7491
|
-
* ones in the
|
|
7492
|
-
* {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face | css `@font-face` rule}.
|
|
8135
|
+
* Emitted every animation frame when at least one `'frame'` listener is registered.
|
|
7493
8136
|
* @public
|
|
7494
8137
|
*/
|
|
7495
|
-
export declare interface
|
|
7496
|
-
/**
|
|
7497
|
-
|
|
7498
|
-
|
|
7499
|
-
|
|
7500
|
-
|
|
7501
|
-
|
|
7502
|
-
|
|
7503
|
-
|
|
7504
|
-
*/
|
|
7505
|
-
readonly src: TLFontFaceSource;
|
|
7506
|
-
/**
|
|
7507
|
-
* See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/ascent-override | `ascent-override`}.
|
|
7508
|
-
*/
|
|
7509
|
-
readonly ascentOverride?: string;
|
|
7510
|
-
/**
|
|
7511
|
-
* See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/descent-override | `descent-override`}.
|
|
7512
|
-
*/
|
|
7513
|
-
readonly descentOverride?: string;
|
|
7514
|
-
/**
|
|
7515
|
-
* See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-stretch | `font-stretch`}.
|
|
7516
|
-
*/
|
|
7517
|
-
readonly stretch?: string;
|
|
7518
|
-
/**
|
|
7519
|
-
* See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-style | `font-style`}.
|
|
7520
|
-
*/
|
|
7521
|
-
readonly style?: string;
|
|
7522
|
-
/**
|
|
7523
|
-
* See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-weight | `font-weight`}.
|
|
7524
|
-
*/
|
|
7525
|
-
readonly weight?: string;
|
|
7526
|
-
/**
|
|
7527
|
-
* See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-feature-settings | `font-feature-settings`}.
|
|
7528
|
-
*/
|
|
7529
|
-
readonly featureSettings?: string;
|
|
7530
|
-
/**
|
|
7531
|
-
* See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/line-gap-override | `line-gap-override`}.
|
|
7532
|
-
*/
|
|
7533
|
-
readonly lineGapOverride?: string;
|
|
7534
|
-
/**
|
|
7535
|
-
* See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/unicode-range | `unicode-range`}.
|
|
7536
|
-
*/
|
|
7537
|
-
readonly unicodeRange?: string;
|
|
7538
|
-
}
|
|
7539
|
-
|
|
7540
|
-
/**
|
|
7541
|
-
* Represents the `src` property of a {@link TLFontFace}.
|
|
7542
|
-
* See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/src | `src`} for details of the properties here.
|
|
7543
|
-
* @public
|
|
7544
|
-
*/
|
|
7545
|
-
export declare interface TLFontFaceSource {
|
|
7546
|
-
/**
|
|
7547
|
-
* A URL from which to load the font. If the value here is a key in
|
|
7548
|
-
* {@link tldraw#TLEditorAssetUrls.fonts}, the value from there will be used instead.
|
|
7549
|
-
*/
|
|
7550
|
-
url: string;
|
|
7551
|
-
format?: string;
|
|
7552
|
-
tech?: string;
|
|
8138
|
+
export declare interface TLFramePerfEvent {
|
|
8139
|
+
/** Time since the last frame in ms. */
|
|
8140
|
+
elapsed: number;
|
|
8141
|
+
/** Total shapes on the current page. */
|
|
8142
|
+
shapeCount: number;
|
|
8143
|
+
/** Number of shapes culled (off-screen) from rendering. */
|
|
8144
|
+
culledShapeCount: number;
|
|
8145
|
+
/** Number of shapes visible (not culled) in the viewport. */
|
|
8146
|
+
visibleShapeCount: number;
|
|
7553
8147
|
}
|
|
7554
8148
|
|
|
7555
8149
|
/** Additional options for the {@link ShapeUtil.getGeometry} method.
|
|
@@ -7694,6 +8288,38 @@ export declare type TLIndicatorPath = {
|
|
|
7694
8288
|
path: Path2D;
|
|
7695
8289
|
} | Path2D;
|
|
7696
8290
|
|
|
8291
|
+
/**
|
|
8292
|
+
* Emitted when an interaction state is exited, with aggregated frame time stats.
|
|
8293
|
+
* @public
|
|
8294
|
+
*/
|
|
8295
|
+
export declare interface TLInteractionEndPerfEvent extends TLPerfFrameTimeStats {
|
|
8296
|
+
/** The state node id (e.g. `'translating'`). */
|
|
8297
|
+
name: string;
|
|
8298
|
+
/** Full tool path (e.g. `'select.translating'`). */
|
|
8299
|
+
path: string;
|
|
8300
|
+
/** Total shapes on the current page. */
|
|
8301
|
+
shapeCount: number;
|
|
8302
|
+
/** Breakdown of selected shape types at interaction start (e.g. `{ geo: 2, draw: 1 }`). */
|
|
8303
|
+
selectedShapeTypes: Record<string, number>;
|
|
8304
|
+
/** Camera zoom level (`camera.z`) at interaction end. */
|
|
8305
|
+
zoomLevel: number;
|
|
8306
|
+
/** `performance.now()` when the interaction ended. */
|
|
8307
|
+
timestamp: number;
|
|
8308
|
+
}
|
|
8309
|
+
|
|
8310
|
+
/**
|
|
8311
|
+
* Emitted when an interaction state (e.g. translating, resizing) is entered.
|
|
8312
|
+
* @public
|
|
8313
|
+
*/
|
|
8314
|
+
export declare interface TLInteractionStartPerfEvent {
|
|
8315
|
+
/** The state node id (e.g. `'translating'`). */
|
|
8316
|
+
name: string;
|
|
8317
|
+
/** Full tool path (e.g. `'select.translating'`). */
|
|
8318
|
+
path: string;
|
|
8319
|
+
/** `performance.now()` when the interaction started. */
|
|
8320
|
+
timestamp: number;
|
|
8321
|
+
}
|
|
8322
|
+
|
|
7697
8323
|
/** @public */
|
|
7698
8324
|
export declare type TLInterruptEvent = (info: TLInterruptEventInfo) => void;
|
|
7699
8325
|
|
|
@@ -7743,6 +8369,11 @@ export declare interface TLLoadSnapshotOptions {
|
|
|
7743
8369
|
forceOverwriteSessionState?: boolean;
|
|
7744
8370
|
}
|
|
7745
8371
|
|
|
8372
|
+
/** @public */
|
|
8373
|
+
export declare type TLMeasuredTextSize = BoxModel & {
|
|
8374
|
+
scrollWidth: number;
|
|
8375
|
+
};
|
|
8376
|
+
|
|
7746
8377
|
/** @public */
|
|
7747
8378
|
export declare interface TLMeasureTextOpts {
|
|
7748
8379
|
fontStyle: string;
|
|
@@ -7936,6 +8567,94 @@ export declare const tlmenus: {
|
|
|
7936
8567
|
*/
|
|
7937
8568
|
export declare type TLOnMountHandler = (editor: Editor) => (() => undefined | void) | undefined | void;
|
|
7938
8569
|
|
|
8570
|
+
/**
|
|
8571
|
+
* Map of all performance event names to their payload types.
|
|
8572
|
+
* Used with {@link PerformanceManager.on} and {@link PerformanceManager.once}.
|
|
8573
|
+
* @public
|
|
8574
|
+
*/
|
|
8575
|
+
export declare interface TLPerfEventMap {
|
|
8576
|
+
/** An interaction state was entered. */
|
|
8577
|
+
'interaction-start': [TLInteractionStartPerfEvent];
|
|
8578
|
+
/** An interaction state was exited, with aggregated frame time stats. */
|
|
8579
|
+
'interaction-end': [TLInteractionEndPerfEvent];
|
|
8580
|
+
/** A camera operation (pan/zoom) began. */
|
|
8581
|
+
'camera-start': [TLCameraStartPerfEvent];
|
|
8582
|
+
/** A camera operation ended (after debounce), with aggregated frame time stats. */
|
|
8583
|
+
'camera-end': [TLCameraEndPerfEvent];
|
|
8584
|
+
/** Shapes were created. */
|
|
8585
|
+
'shapes-created': [TLShapeOperationPerfEvent];
|
|
8586
|
+
/** Shapes were updated. */
|
|
8587
|
+
'shapes-updated': [TLShapeOperationPerfEvent];
|
|
8588
|
+
/** Shapes were deleted. */
|
|
8589
|
+
'shapes-deleted': [TLShapeOperationPerfEvent];
|
|
8590
|
+
/** An animation frame was rendered. Only fires when listeners are registered. */
|
|
8591
|
+
frame: [TLFramePerfEvent];
|
|
8592
|
+
/** An undo operation was performed. */
|
|
8593
|
+
undo: [TLUndoRedoPerfEvent];
|
|
8594
|
+
/** A redo operation was performed. */
|
|
8595
|
+
redo: [TLUndoRedoPerfEvent];
|
|
8596
|
+
}
|
|
8597
|
+
|
|
8598
|
+
/**
|
|
8599
|
+
* Common frame time statistics shared by interaction and camera end events.
|
|
8600
|
+
* @public
|
|
8601
|
+
*/
|
|
8602
|
+
export declare interface TLPerfFrameTimeStats {
|
|
8603
|
+
/** Total duration of the session in ms. */
|
|
8604
|
+
duration: number;
|
|
8605
|
+
/** Average frames per second during the session. */
|
|
8606
|
+
fps: number;
|
|
8607
|
+
/** Total number of frames recorded. */
|
|
8608
|
+
frameCount: number;
|
|
8609
|
+
/** Mean frame duration in ms. */
|
|
8610
|
+
avgFrameTime: number;
|
|
8611
|
+
/** Median (p50) frame duration in ms. */
|
|
8612
|
+
medianFrameTime: number;
|
|
8613
|
+
/** 95th percentile frame duration in ms. */
|
|
8614
|
+
p95FrameTime: number;
|
|
8615
|
+
/** 99th percentile frame duration in ms. */
|
|
8616
|
+
p99FrameTime: number;
|
|
8617
|
+
/** Shortest frame duration in ms. */
|
|
8618
|
+
minFrameTime: number;
|
|
8619
|
+
/** Longest frame duration in ms. */
|
|
8620
|
+
maxFrameTime: number;
|
|
8621
|
+
/** Raw frame durations for local analysis. Exclude when sending to analytics. */
|
|
8622
|
+
frameTimes: number[];
|
|
8623
|
+
/**
|
|
8624
|
+
* Long animation frames observed during this period (Chromium 123+).
|
|
8625
|
+
* Only present when the browser supports the Long Animation Frames API and
|
|
8626
|
+
* at least one long frame was observed.
|
|
8627
|
+
* Exclude when sending to analytics — entries are large and contain script URLs.
|
|
8628
|
+
*/
|
|
8629
|
+
longAnimationFrames?: TLPerfLongAnimationFrame[];
|
|
8630
|
+
}
|
|
8631
|
+
|
|
8632
|
+
/**
|
|
8633
|
+
* A long animation frame observed by the browser during an interaction.
|
|
8634
|
+
* Available only in browsers that support the Long Animation Frames API (Chromium 123+).
|
|
8635
|
+
* @public
|
|
8636
|
+
*/
|
|
8637
|
+
export declare interface TLPerfLongAnimationFrame {
|
|
8638
|
+
/** Frame start time (relative to timeOrigin). */
|
|
8639
|
+
startTime: number;
|
|
8640
|
+
/** Total frame duration in ms. */
|
|
8641
|
+
duration: number;
|
|
8642
|
+
/** Time the main thread was blocked in ms. */
|
|
8643
|
+
blockingDuration: number;
|
|
8644
|
+
/** Scripts that contributed to the long frame. */
|
|
8645
|
+
scripts: TLPerfLongAnimationFrameScript[];
|
|
8646
|
+
}
|
|
8647
|
+
|
|
8648
|
+
/** A script attribution entry from a long animation frame. @public */
|
|
8649
|
+
export declare interface TLPerfLongAnimationFrameScript {
|
|
8650
|
+
/** The script source URL (may be empty for inline scripts). */
|
|
8651
|
+
sourceURL: string;
|
|
8652
|
+
/** The function name or invoker description. */
|
|
8653
|
+
invoker: string;
|
|
8654
|
+
/** Time spent in this script in ms. */
|
|
8655
|
+
duration: number;
|
|
8656
|
+
}
|
|
8657
|
+
|
|
7939
8658
|
/** @public */
|
|
7940
8659
|
export declare type TLPinchEvent = (info: TLPinchEventInfo) => void;
|
|
7941
8660
|
|
|
@@ -8123,6 +8842,21 @@ export declare interface TLShapeIndicatorsProps {
|
|
|
8123
8842
|
showAll?: boolean;
|
|
8124
8843
|
}
|
|
8125
8844
|
|
|
8845
|
+
/**
|
|
8846
|
+
* Emitted when shapes are created, updated, or deleted.
|
|
8847
|
+
* @public
|
|
8848
|
+
*/
|
|
8849
|
+
export declare interface TLShapeOperationPerfEvent {
|
|
8850
|
+
/** The operation type. */
|
|
8851
|
+
operation: 'create' | 'delete' | 'update';
|
|
8852
|
+
/** Number of shapes affected. */
|
|
8853
|
+
count: number;
|
|
8854
|
+
/** Breakdown by shape type (e.g. `{ geo: 2, draw: 1 }`). */
|
|
8855
|
+
shapeTypes: Record<string, number>;
|
|
8856
|
+
/** `performance.now()` when the operation occurred. */
|
|
8857
|
+
timestamp: number;
|
|
8858
|
+
}
|
|
8859
|
+
|
|
8126
8860
|
/**
|
|
8127
8861
|
* Options passed to {@link ShapeUtil.canBeLaidOut}.
|
|
8128
8862
|
*
|
|
@@ -8180,6 +8914,7 @@ export declare interface TLShapeUtilConstructor<T extends TLShape, U extends Sha
|
|
|
8180
8914
|
type: T['type'];
|
|
8181
8915
|
props?: RecordProps<T>;
|
|
8182
8916
|
migrations?: LegacyMigrations | MigrationSequence | TLPropsMigrations;
|
|
8917
|
+
handledAssetTypes?: readonly string[];
|
|
8183
8918
|
}
|
|
8184
8919
|
|
|
8185
8920
|
/** @public */
|
|
@@ -8207,6 +8942,7 @@ export declare interface TLStateNodeConstructor {
|
|
|
8207
8942
|
children?(): TLStateNodeConstructor[];
|
|
8208
8943
|
isLockable: boolean;
|
|
8209
8944
|
useCoalescedEvents: boolean;
|
|
8945
|
+
trackPerformance: boolean;
|
|
8210
8946
|
}
|
|
8211
8947
|
|
|
8212
8948
|
/** @public */
|
|
@@ -8219,6 +8955,14 @@ export declare interface TLStoreBaseOptions {
|
|
|
8219
8955
|
defaultName?: string;
|
|
8220
8956
|
/** How should this store upload & resolve assets? */
|
|
8221
8957
|
assets?: TLAssetStore;
|
|
8958
|
+
/**
|
|
8959
|
+
* Named theme definitions. When provided, custom color names are automatically
|
|
8960
|
+
* registered before the store is constructed so persisted data with those
|
|
8961
|
+
* colors passes validation on load.
|
|
8962
|
+
*/
|
|
8963
|
+
themes?: Partial<TLThemes>;
|
|
8964
|
+
/** How should this store resolve users for attribution? */
|
|
8965
|
+
users?: TLUserStore;
|
|
8222
8966
|
/** Called when the store is connected to an {@link @tldraw/editor#Editor}. */
|
|
8223
8967
|
onMount?(editor: Editor): (() => void) | void;
|
|
8224
8968
|
}
|
|
@@ -8238,6 +8982,7 @@ export declare type TLStoreOptions = TLStoreBaseOptions & {
|
|
|
8238
8982
|
|
|
8239
8983
|
/** @public */
|
|
8240
8984
|
export declare type TLStoreSchemaOptions = {
|
|
8985
|
+
assetUtils?: readonly TLAnyAssetUtilConstructor[];
|
|
8241
8986
|
bindingUtils?: readonly TLAnyBindingUtilConstructor[];
|
|
8242
8987
|
migrations?: readonly MigrationSequence[];
|
|
8243
8988
|
records?: Record<string, CustomRecordInfo>;
|
|
@@ -8375,6 +9120,19 @@ export declare interface TLTldrawExternalContentSource {
|
|
|
8375
9120
|
data: TLContent;
|
|
8376
9121
|
}
|
|
8377
9122
|
|
|
9123
|
+
/**
|
|
9124
|
+
* Emitted after an undo or redo operation.
|
|
9125
|
+
* @public
|
|
9126
|
+
*/
|
|
9127
|
+
export declare interface TLUndoRedoPerfEvent {
|
|
9128
|
+
/** Whether this was an undo or redo. */
|
|
9129
|
+
type: 'redo' | 'undo';
|
|
9130
|
+
/** Number of undo steps remaining. */
|
|
9131
|
+
undoDepth: number;
|
|
9132
|
+
/** Number of redo steps remaining. */
|
|
9133
|
+
redoDepth: number;
|
|
9134
|
+
}
|
|
9135
|
+
|
|
8378
9136
|
/** @public */
|
|
8379
9137
|
export declare interface TLUpdatePointerOptions {
|
|
8380
9138
|
/** Whether to update the pointer immediately, rather than on the next tick. */
|
|
@@ -8406,12 +9164,6 @@ export declare interface TLUrlExternalContent extends TLBaseExternalContent {
|
|
|
8406
9164
|
url: string;
|
|
8407
9165
|
}
|
|
8408
9166
|
|
|
8409
|
-
/** @public */
|
|
8410
|
-
export declare interface TLUser {
|
|
8411
|
-
readonly userPreferences: Signal<TLUserPreferences>;
|
|
8412
|
-
readonly setUserPreferences: (userPreferences: TLUserPreferences) => void;
|
|
8413
|
-
}
|
|
8414
|
-
|
|
8415
9167
|
/**
|
|
8416
9168
|
* A user of tldraw
|
|
8417
9169
|
*
|
|
@@ -8512,6 +9264,9 @@ export declare function uniq<T>(array: {
|
|
|
8512
9264
|
readonly length: number;
|
|
8513
9265
|
} | null | undefined): T[];
|
|
8514
9266
|
|
|
9267
|
+
/** @public */
|
|
9268
|
+
export declare function useColorMode(): 'dark' | 'light';
|
|
9269
|
+
|
|
8515
9270
|
/** @public */
|
|
8516
9271
|
export declare function useContainer(): HTMLElement;
|
|
8517
9272
|
|
|
@@ -8550,9 +9305,6 @@ export declare function useGlobalMenuIsOpen(id: string, onChange?: (isOpen: bool
|
|
|
8550
9305
|
/** @public */
|
|
8551
9306
|
export declare function useIsCropping(shapeId: TLShapeId): boolean;
|
|
8552
9307
|
|
|
8553
|
-
/** @public */
|
|
8554
|
-
export declare function useIsDarkMode(): boolean;
|
|
8555
|
-
|
|
8556
9308
|
/** @public */
|
|
8557
9309
|
export declare function useIsEditing(shapeId: TLShapeId): boolean;
|
|
8558
9310
|
|
|
@@ -8590,11 +9342,11 @@ export declare function usePresence(userId: string): null | TLInstancePresence;
|
|
|
8590
9342
|
/** @public */
|
|
8591
9343
|
export declare class UserPreferencesManager {
|
|
8592
9344
|
private readonly user;
|
|
8593
|
-
private readonly
|
|
9345
|
+
private readonly colorScheme;
|
|
8594
9346
|
systemColorScheme: Atom<"dark" | "light", unknown>;
|
|
8595
9347
|
disposables: Set<() => void>;
|
|
8596
9348
|
dispose(): void;
|
|
8597
|
-
constructor(user:
|
|
9349
|
+
constructor(user: TLCurrentUser, colorScheme: 'dark' | 'light' | 'system');
|
|
8598
9350
|
updateUserPreferences(userPreferences: Partial<TLUserPreferences>): void;
|
|
8599
9351
|
getUserPreferences(): {
|
|
8600
9352
|
animationSpeed: number;
|
|
@@ -8665,10 +9417,10 @@ export declare function useSvgExportContext(): null | SvgExportContext;
|
|
|
8665
9417
|
/**
|
|
8666
9418
|
* @public
|
|
8667
9419
|
*/
|
|
8668
|
-
export declare function
|
|
9420
|
+
export declare function useTldrawCurrentUser(opts: {
|
|
8669
9421
|
setUserPreferences?: (userPreferences: TLUserPreferences) => void;
|
|
8670
9422
|
userPreferences?: Signal<TLUserPreferences> | TLUserPreferences;
|
|
8671
|
-
}):
|
|
9423
|
+
}): TLCurrentUser;
|
|
8672
9424
|
|
|
8673
9425
|
/** @public */
|
|
8674
9426
|
export declare function useTLSchemaFromUtils(opts: TLStoreSchemaOptions): StoreSchema<TLRecord, TLStoreProps>;
|