@tldraw/editor 3.16.0-internal.a478398270c6 → 3.16.0-internal.f8b97f0c414f
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 +350 -142
- package/dist-cjs/index.js +13 -6
- package/dist-cjs/index.js.map +2 -2
- package/dist-cjs/lib/TldrawEditor.js +10 -8
- package/dist-cjs/lib/TldrawEditor.js.map +2 -2
- package/dist-cjs/lib/components/MenuClickCapture.js +0 -5
- package/dist-cjs/lib/components/MenuClickCapture.js.map +2 -2
- package/dist-cjs/lib/components/SVGContainer.js +1 -1
- package/dist-cjs/lib/components/SVGContainer.js.map +2 -2
- package/dist-cjs/lib/components/Shape.js +11 -36
- package/dist-cjs/lib/components/Shape.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultBrush.js +1 -1
- package/dist-cjs/lib/components/default-components/DefaultBrush.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultCanvas.js +15 -24
- package/dist-cjs/lib/components/default-components/DefaultCanvas.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultCollaboratorHint.js +2 -2
- package/dist-cjs/lib/components/default-components/DefaultCollaboratorHint.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultCursor.js +1 -1
- package/dist-cjs/lib/components/default-components/DefaultCursor.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultErrorFallback.js +1 -1
- package/dist-cjs/lib/components/default-components/DefaultErrorFallback.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultGrid.js +1 -1
- package/dist-cjs/lib/components/default-components/DefaultGrid.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultHandles.js +1 -1
- package/dist-cjs/lib/components/default-components/DefaultHandles.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultScribble.js +1 -1
- package/dist-cjs/lib/components/default-components/DefaultScribble.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultShapeIndicator.js +9 -1
- package/dist-cjs/lib/components/default-components/DefaultShapeIndicator.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultShapeWrapper.js +53 -0
- package/dist-cjs/lib/components/default-components/DefaultShapeWrapper.js.map +7 -0
- package/dist-cjs/lib/components/default-components/DefaultSnapIndictor.js +1 -1
- package/dist-cjs/lib/components/default-components/DefaultSnapIndictor.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultSpinner.js +27 -15
- package/dist-cjs/lib/components/default-components/DefaultSpinner.js.map +3 -3
- package/dist-cjs/lib/config/TLUserPreferences.js +15 -3
- package/dist-cjs/lib/config/TLUserPreferences.js.map +2 -2
- package/dist-cjs/lib/editor/Editor.js +174 -180
- package/dist-cjs/lib/editor/Editor.js.map +2 -2
- package/dist-cjs/lib/editor/derivations/notVisibleShapes.js +4 -0
- package/dist-cjs/lib/editor/derivations/notVisibleShapes.js.map +2 -2
- package/dist-cjs/lib/editor/derivations/parentsToChildren.js.map +2 -2
- package/dist-cjs/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.js +14 -4
- package/dist-cjs/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.js.map +2 -2
- package/dist-cjs/lib/editor/shapes/BaseBoxShapeUtil.js.map +1 -1
- package/dist-cjs/lib/editor/shapes/ShapeUtil.js +23 -0
- package/dist-cjs/lib/editor/shapes/ShapeUtil.js.map +2 -2
- package/dist-cjs/lib/editor/tools/BaseBoxShapeTool/BaseBoxShapeTool.js.map +2 -2
- package/dist-cjs/lib/editor/tools/StateNode.js +20 -1
- package/dist-cjs/lib/editor/tools/StateNode.js.map +2 -2
- package/dist-cjs/lib/editor/types/misc-types.js.map +1 -1
- package/dist-cjs/lib/exports/getSvgJsx.js +35 -16
- package/dist-cjs/lib/exports/getSvgJsx.js.map +2 -2
- package/dist-cjs/lib/hooks/useCanvasEvents.js +44 -35
- package/dist-cjs/lib/hooks/useCanvasEvents.js.map +2 -2
- package/dist-cjs/lib/hooks/useDocumentEvents.js +5 -5
- package/dist-cjs/lib/hooks/useDocumentEvents.js.map +2 -2
- package/dist-cjs/lib/hooks/useEditor.js +1 -4
- package/dist-cjs/lib/hooks/useEditor.js.map +2 -2
- package/dist-cjs/lib/hooks/useEditorComponents.js +2 -0
- package/dist-cjs/lib/hooks/useEditorComponents.js.map +2 -2
- package/dist-cjs/lib/hooks/useFixSafariDoubleTapZoomPencilEvents.js +1 -2
- package/dist-cjs/lib/hooks/useFixSafariDoubleTapZoomPencilEvents.js.map +2 -2
- package/dist-cjs/lib/hooks/useGestureEvents.js +1 -1
- package/dist-cjs/lib/hooks/useGestureEvents.js.map +2 -2
- package/dist-cjs/lib/hooks/useHandleEvents.js +3 -3
- package/dist-cjs/lib/hooks/useHandleEvents.js.map +2 -2
- package/dist-cjs/lib/hooks/usePassThroughMouseOverEvents.js +4 -1
- package/dist-cjs/lib/hooks/usePassThroughMouseOverEvents.js.map +2 -2
- package/dist-cjs/lib/hooks/usePassThroughWheelEvents.js +4 -1
- package/dist-cjs/lib/hooks/usePassThroughWheelEvents.js.map +2 -2
- package/dist-cjs/lib/hooks/useSelectionEvents.js +4 -4
- package/dist-cjs/lib/hooks/useSelectionEvents.js.map +2 -2
- package/dist-cjs/lib/{utils/nearestMultiple.js → hooks/useStateAttribute.js} +15 -14
- package/dist-cjs/lib/hooks/useStateAttribute.js.map +7 -0
- package/dist-cjs/lib/license/LicenseManager.js +140 -53
- package/dist-cjs/lib/license/LicenseManager.js.map +2 -2
- package/dist-cjs/lib/license/LicenseProvider.js +39 -1
- package/dist-cjs/lib/license/LicenseProvider.js.map +2 -2
- package/dist-cjs/lib/license/Watermark.js +75 -13
- package/dist-cjs/lib/license/Watermark.js.map +3 -3
- package/dist-cjs/lib/license/useLicenseManagerState.js.map +2 -2
- package/dist-cjs/lib/options.js +7 -0
- package/dist-cjs/lib/options.js.map +2 -2
- package/dist-cjs/lib/primitives/Box.js +3 -0
- package/dist-cjs/lib/primitives/Box.js.map +2 -2
- package/dist-cjs/lib/primitives/Vec.js +0 -4
- package/dist-cjs/lib/primitives/Vec.js.map +2 -2
- package/dist-cjs/lib/primitives/geometry/Arc2d.js +1 -1
- package/dist-cjs/lib/primitives/geometry/Arc2d.js.map +2 -2
- package/dist-cjs/lib/primitives/geometry/Circle2d.js +1 -1
- package/dist-cjs/lib/primitives/geometry/Circle2d.js.map +2 -2
- package/dist-cjs/lib/primitives/geometry/CubicBezier2d.js +3 -1
- package/dist-cjs/lib/primitives/geometry/CubicBezier2d.js.map +2 -2
- package/dist-cjs/lib/primitives/geometry/Ellipse2d.js +1 -1
- package/dist-cjs/lib/primitives/geometry/Ellipse2d.js.map +2 -2
- package/dist-cjs/lib/primitives/geometry/Geometry2d.js +50 -20
- package/dist-cjs/lib/primitives/geometry/Geometry2d.js.map +2 -2
- package/dist-cjs/lib/primitives/geometry/Group2d.js +8 -1
- package/dist-cjs/lib/primitives/geometry/Group2d.js.map +2 -2
- package/dist-cjs/lib/primitives/geometry/geometry-constants.js +2 -2
- package/dist-cjs/lib/primitives/geometry/geometry-constants.js.map +2 -2
- package/dist-cjs/lib/primitives/intersect.js +4 -4
- package/dist-cjs/lib/primitives/intersect.js.map +2 -2
- package/dist-cjs/lib/primitives/utils.js +4 -0
- package/dist-cjs/lib/primitives/utils.js.map +2 -2
- package/dist-cjs/lib/utils/EditorAtom.js +45 -0
- package/dist-cjs/lib/utils/EditorAtom.js.map +7 -0
- package/dist-cjs/lib/utils/dom.js +12 -1
- package/dist-cjs/lib/utils/dom.js.map +2 -2
- package/dist-cjs/lib/utils/getPointerInfo.js +2 -2
- package/dist-cjs/lib/utils/getPointerInfo.js.map +2 -2
- package/dist-cjs/lib/utils/reparenting.js +2 -35
- package/dist-cjs/lib/utils/reparenting.js.map +3 -3
- package/dist-cjs/lib/utils/sync/TLLocalSyncClient.js +0 -1
- package/dist-cjs/lib/utils/sync/TLLocalSyncClient.js.map +2 -2
- package/dist-cjs/version.js +3 -3
- package/dist-cjs/version.js.map +1 -1
- package/dist-esm/index.d.mts +350 -142
- package/dist-esm/index.mjs +24 -8
- package/dist-esm/index.mjs.map +2 -2
- package/dist-esm/lib/TldrawEditor.mjs +11 -9
- package/dist-esm/lib/TldrawEditor.mjs.map +2 -2
- package/dist-esm/lib/components/MenuClickCapture.mjs +0 -5
- package/dist-esm/lib/components/MenuClickCapture.mjs.map +2 -2
- package/dist-esm/lib/components/SVGContainer.mjs +1 -1
- package/dist-esm/lib/components/SVGContainer.mjs.map +2 -2
- package/dist-esm/lib/components/Shape.mjs +11 -36
- package/dist-esm/lib/components/Shape.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultBrush.mjs +1 -1
- package/dist-esm/lib/components/default-components/DefaultBrush.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultCanvas.mjs +16 -25
- package/dist-esm/lib/components/default-components/DefaultCanvas.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultCollaboratorHint.mjs +2 -2
- package/dist-esm/lib/components/default-components/DefaultCollaboratorHint.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultCursor.mjs +1 -1
- package/dist-esm/lib/components/default-components/DefaultCursor.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultErrorFallback.mjs +1 -1
- package/dist-esm/lib/components/default-components/DefaultErrorFallback.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultGrid.mjs +1 -1
- package/dist-esm/lib/components/default-components/DefaultGrid.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultHandles.mjs +1 -1
- package/dist-esm/lib/components/default-components/DefaultHandles.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultScribble.mjs +1 -1
- package/dist-esm/lib/components/default-components/DefaultScribble.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultShapeIndicator.mjs +9 -1
- package/dist-esm/lib/components/default-components/DefaultShapeIndicator.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultShapeWrapper.mjs +23 -0
- package/dist-esm/lib/components/default-components/DefaultShapeWrapper.mjs.map +7 -0
- package/dist-esm/lib/components/default-components/DefaultSnapIndictor.mjs +1 -1
- package/dist-esm/lib/components/default-components/DefaultSnapIndictor.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultSpinner.mjs +17 -15
- package/dist-esm/lib/components/default-components/DefaultSpinner.mjs.map +2 -2
- package/dist-esm/lib/config/TLUserPreferences.mjs +15 -3
- package/dist-esm/lib/config/TLUserPreferences.mjs.map +2 -2
- package/dist-esm/lib/editor/Editor.mjs +174 -180
- package/dist-esm/lib/editor/Editor.mjs.map +2 -2
- package/dist-esm/lib/editor/derivations/notVisibleShapes.mjs +4 -0
- package/dist-esm/lib/editor/derivations/notVisibleShapes.mjs.map +2 -2
- package/dist-esm/lib/editor/derivations/parentsToChildren.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.mjs +14 -4
- package/dist-esm/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.mjs.map +2 -2
- package/dist-esm/lib/editor/shapes/BaseBoxShapeUtil.mjs.map +1 -1
- package/dist-esm/lib/editor/shapes/ShapeUtil.mjs +23 -0
- package/dist-esm/lib/editor/shapes/ShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/editor/tools/BaseBoxShapeTool/BaseBoxShapeTool.mjs.map +2 -2
- package/dist-esm/lib/editor/tools/StateNode.mjs +20 -1
- package/dist-esm/lib/editor/tools/StateNode.mjs.map +2 -2
- package/dist-esm/lib/exports/getSvgJsx.mjs +36 -16
- package/dist-esm/lib/exports/getSvgJsx.mjs.map +2 -2
- package/dist-esm/lib/hooks/useCanvasEvents.mjs +47 -37
- package/dist-esm/lib/hooks/useCanvasEvents.mjs.map +2 -2
- package/dist-esm/lib/hooks/useDocumentEvents.mjs +11 -6
- package/dist-esm/lib/hooks/useDocumentEvents.mjs.map +2 -2
- package/dist-esm/lib/hooks/useEditor.mjs +1 -4
- package/dist-esm/lib/hooks/useEditor.mjs.map +2 -2
- package/dist-esm/lib/hooks/useEditorComponents.mjs +4 -0
- package/dist-esm/lib/hooks/useEditorComponents.mjs.map +2 -2
- package/dist-esm/lib/hooks/useFixSafariDoubleTapZoomPencilEvents.mjs +2 -3
- package/dist-esm/lib/hooks/useFixSafariDoubleTapZoomPencilEvents.mjs.map +2 -2
- package/dist-esm/lib/hooks/useGestureEvents.mjs +2 -2
- package/dist-esm/lib/hooks/useGestureEvents.mjs.map +2 -2
- package/dist-esm/lib/hooks/useHandleEvents.mjs +9 -4
- package/dist-esm/lib/hooks/useHandleEvents.mjs.map +2 -2
- package/dist-esm/lib/hooks/usePassThroughMouseOverEvents.mjs +4 -1
- package/dist-esm/lib/hooks/usePassThroughMouseOverEvents.mjs.map +2 -2
- package/dist-esm/lib/hooks/usePassThroughWheelEvents.mjs +4 -1
- package/dist-esm/lib/hooks/usePassThroughWheelEvents.mjs.map +2 -2
- package/dist-esm/lib/hooks/useSelectionEvents.mjs +6 -5
- package/dist-esm/lib/hooks/useSelectionEvents.mjs.map +2 -2
- package/dist-esm/lib/hooks/useStateAttribute.mjs +15 -0
- package/dist-esm/lib/hooks/useStateAttribute.mjs.map +7 -0
- package/dist-esm/lib/license/LicenseManager.mjs +141 -54
- package/dist-esm/lib/license/LicenseManager.mjs.map +2 -2
- package/dist-esm/lib/license/LicenseProvider.mjs +39 -2
- package/dist-esm/lib/license/LicenseProvider.mjs.map +2 -2
- package/dist-esm/lib/license/Watermark.mjs +76 -14
- package/dist-esm/lib/license/Watermark.mjs.map +3 -3
- package/dist-esm/lib/license/useLicenseManagerState.mjs.map +2 -2
- package/dist-esm/lib/options.mjs +7 -0
- package/dist-esm/lib/options.mjs.map +2 -2
- package/dist-esm/lib/primitives/Box.mjs +4 -1
- package/dist-esm/lib/primitives/Box.mjs.map +2 -2
- package/dist-esm/lib/primitives/Vec.mjs +0 -4
- 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 +2 -2
- package/dist-esm/lib/primitives/geometry/Circle2d.mjs.map +2 -2
- package/dist-esm/lib/primitives/geometry/CubicBezier2d.mjs +3 -1
- package/dist-esm/lib/primitives/geometry/CubicBezier2d.mjs.map +2 -2
- package/dist-esm/lib/primitives/geometry/Ellipse2d.mjs +2 -2
- package/dist-esm/lib/primitives/geometry/Ellipse2d.mjs.map +2 -2
- package/dist-esm/lib/primitives/geometry/Geometry2d.mjs +53 -21
- package/dist-esm/lib/primitives/geometry/Geometry2d.mjs.map +2 -2
- package/dist-esm/lib/primitives/geometry/Group2d.mjs +8 -1
- package/dist-esm/lib/primitives/geometry/Group2d.mjs.map +2 -2
- package/dist-esm/lib/primitives/geometry/geometry-constants.mjs +2 -2
- package/dist-esm/lib/primitives/geometry/geometry-constants.mjs.map +2 -2
- package/dist-esm/lib/primitives/intersect.mjs +5 -5
- package/dist-esm/lib/primitives/intersect.mjs.map +2 -2
- package/dist-esm/lib/primitives/utils.mjs +4 -0
- package/dist-esm/lib/primitives/utils.mjs.map +2 -2
- package/dist-esm/lib/utils/EditorAtom.mjs +25 -0
- package/dist-esm/lib/utils/EditorAtom.mjs.map +7 -0
- package/dist-esm/lib/utils/dom.mjs +12 -1
- package/dist-esm/lib/utils/dom.mjs.map +2 -2
- package/dist-esm/lib/utils/getPointerInfo.mjs +2 -2
- package/dist-esm/lib/utils/getPointerInfo.mjs.map +2 -2
- package/dist-esm/lib/utils/reparenting.mjs +3 -40
- package/dist-esm/lib/utils/reparenting.mjs.map +2 -2
- package/dist-esm/lib/utils/sync/TLLocalSyncClient.mjs +0 -1
- package/dist-esm/lib/utils/sync/TLLocalSyncClient.mjs.map +2 -2
- package/dist-esm/version.mjs +3 -3
- package/dist-esm/version.mjs.map +1 -1
- package/editor.css +327 -315
- package/package.json +16 -38
- package/src/index.ts +19 -10
- package/src/lib/TldrawEditor.tsx +16 -21
- package/src/lib/components/MenuClickCapture.tsx +0 -8
- package/src/lib/components/SVGContainer.tsx +1 -1
- package/src/lib/components/Shape.tsx +12 -33
- package/src/lib/components/default-components/DefaultBrush.tsx +1 -1
- package/src/lib/components/default-components/DefaultCanvas.tsx +13 -24
- package/src/lib/components/default-components/DefaultCollaboratorHint.tsx +2 -2
- package/src/lib/components/default-components/DefaultCursor.tsx +1 -1
- package/src/lib/components/default-components/DefaultErrorFallback.tsx +1 -1
- package/src/lib/components/default-components/DefaultGrid.tsx +1 -1
- package/src/lib/components/default-components/DefaultHandles.tsx +5 -1
- package/src/lib/components/default-components/DefaultScribble.tsx +1 -1
- package/src/lib/components/default-components/DefaultShapeIndicator.tsx +6 -2
- package/src/lib/components/default-components/DefaultShapeWrapper.tsx +35 -0
- package/src/lib/components/default-components/DefaultSnapIndictor.tsx +1 -1
- package/src/lib/components/default-components/DefaultSpinner.tsx +12 -12
- package/src/lib/config/TLUserPreferences.ts +15 -1
- package/src/lib/editor/Editor.test.ts +512 -8
- package/src/lib/editor/Editor.ts +252 -267
- package/src/lib/editor/derivations/notVisibleShapes.ts +6 -0
- package/src/lib/editor/derivations/parentsToChildren.ts +1 -1
- package/src/lib/editor/managers/ClickManager/ClickManager.test.ts +15 -14
- package/src/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.test.ts +16 -15
- package/src/lib/editor/managers/FocusManager/FocusManager.test.ts +49 -48
- package/src/lib/editor/managers/FontManager/FontManager.test.ts +38 -27
- package/src/lib/editor/managers/HistoryManager/HistoryManager.test.ts +7 -6
- package/src/lib/editor/managers/ScribbleManager/ScribbleManager.test.ts +12 -11
- package/src/lib/editor/managers/SnapManager/SnapManager.test.ts +57 -50
- package/src/lib/editor/managers/TextManager/TextManager.test.ts +51 -26
- package/src/lib/editor/managers/TickManager/TickManager.test.ts +14 -13
- package/src/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.test.ts +55 -26
- package/src/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.ts +14 -1
- package/src/lib/editor/shapes/BaseBoxShapeUtil.tsx +2 -2
- package/src/lib/editor/shapes/ShapeUtil.ts +108 -8
- package/src/lib/editor/tools/BaseBoxShapeTool/BaseBoxShapeTool.ts +2 -1
- package/src/lib/editor/tools/StateNode.test.ts +285 -0
- package/src/lib/editor/tools/StateNode.ts +27 -1
- package/src/lib/editor/types/misc-types.ts +73 -7
- package/src/lib/exports/getSvgJsx.test.ts +874 -0
- package/src/lib/exports/getSvgJsx.tsx +78 -21
- package/src/lib/hooks/useCanvasEvents.ts +60 -47
- package/src/lib/hooks/useDocumentEvents.ts +11 -6
- package/src/lib/hooks/useEditor.tsx +6 -5
- package/src/lib/hooks/useEditorComponents.tsx +8 -2
- package/src/lib/hooks/useFixSafariDoubleTapZoomPencilEvents.ts +2 -2
- package/src/lib/hooks/useGestureEvents.ts +2 -2
- package/src/lib/hooks/useHandleEvents.ts +9 -4
- package/src/lib/hooks/usePassThroughMouseOverEvents.ts +4 -1
- package/src/lib/hooks/usePassThroughWheelEvents.ts +6 -1
- package/src/lib/hooks/useSelectionEvents.ts +6 -5
- package/src/lib/hooks/useStateAttribute.ts +15 -0
- package/src/lib/license/LicenseManager.test.ts +724 -383
- package/src/lib/license/LicenseManager.ts +201 -58
- package/src/lib/license/LicenseProvider.tsx +74 -2
- package/src/lib/license/Watermark.test.tsx +2 -1
- package/src/lib/license/Watermark.tsx +81 -14
- package/src/lib/license/useLicenseManagerState.ts +2 -2
- package/src/lib/options.ts +8 -0
- package/src/lib/primitives/Box.test.ts +126 -0
- package/src/lib/primitives/Box.ts +10 -1
- package/src/lib/primitives/Vec.ts +0 -5
- package/src/lib/primitives/geometry/Arc2d.ts +2 -2
- package/src/lib/primitives/geometry/Circle2d.ts +2 -2
- package/src/lib/primitives/geometry/CubicBezier2d.ts +4 -1
- package/src/lib/primitives/geometry/Ellipse2d.ts +2 -2
- package/src/lib/primitives/geometry/Geometry2d.test.ts +420 -0
- package/src/lib/primitives/geometry/Geometry2d.ts +78 -21
- package/src/lib/primitives/geometry/Group2d.ts +10 -1
- package/src/lib/primitives/geometry/geometry-constants.ts +2 -1
- package/src/lib/primitives/intersect.test.ts +946 -0
- package/src/lib/primitives/intersect.ts +12 -5
- package/src/lib/primitives/utils.ts +11 -0
- package/src/lib/test/InFrontOfTheCanvas.test.tsx +187 -0
- package/src/lib/utils/EditorAtom.ts +37 -0
- package/src/lib/utils/dom.test.ts +94 -0
- package/src/lib/utils/dom.ts +38 -1
- package/src/lib/utils/getPointerInfo.ts +2 -1
- package/src/lib/utils/reparenting.ts +3 -69
- package/src/lib/utils/sync/LocalIndexedDb.test.ts +2 -1
- package/src/lib/utils/sync/TLLocalSyncClient.test.ts +15 -15
- package/src/lib/utils/sync/TLLocalSyncClient.ts +0 -1
- package/src/version.ts +3 -3
- package/dist-cjs/lib/utils/nearestMultiple.js.map +0 -7
- package/dist-esm/lib/utils/nearestMultiple.mjs +0 -14
- package/dist-esm/lib/utils/nearestMultiple.mjs.map +0 -7
- package/src/lib/test/currentToolIdMask.test.ts +0 -49
- package/src/lib/utils/nearestMultiple.ts +0 -13
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tldraw/editor",
|
|
3
|
-
"description": "
|
|
4
|
-
"version": "3.16.0-internal.
|
|
3
|
+
"description": "tldraw infinite canvas SDK (editor).",
|
|
4
|
+
"version": "3.16.0-internal.f8b97f0c414f",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "tldraw Inc.",
|
|
7
7
|
"email": "hello@tldraw.com"
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
},
|
|
18
18
|
"keywords": [
|
|
19
19
|
"tldraw",
|
|
20
|
+
"sdk",
|
|
20
21
|
"drawing",
|
|
21
22
|
"app",
|
|
22
23
|
"development",
|
|
@@ -33,27 +34,28 @@
|
|
|
33
34
|
"src"
|
|
34
35
|
],
|
|
35
36
|
"scripts": {
|
|
36
|
-
"test-ci": "
|
|
37
|
-
"test": "yarn run -T
|
|
37
|
+
"test-ci": "yarn run -T vitest run --passWithNoTests",
|
|
38
|
+
"test": "yarn run -T vitest --passWithNoTests",
|
|
38
39
|
"benchmark": "yarn run -T tsx ./internal/scripts/benchmark.ts",
|
|
39
|
-
"test-coverage": "
|
|
40
|
+
"test-coverage": "yarn run -T vitest run --coverage --passWithNoTests",
|
|
40
41
|
"build": "yarn run -T tsx ../../internal/scripts/build-package.ts",
|
|
41
42
|
"build-api": "yarn run -T tsx ../../internal/scripts/build-api.ts",
|
|
42
43
|
"prepack": "yarn run -T tsx ../../internal/scripts/prepack.ts",
|
|
43
44
|
"postpack": "../../internal/scripts/postpack.sh",
|
|
44
45
|
"pack-tarball": "yarn pack",
|
|
45
|
-
"lint": "yarn run -T tsx ../../internal/scripts/lint.ts"
|
|
46
|
+
"lint": "yarn run -T tsx ../../internal/scripts/lint.ts",
|
|
47
|
+
"context": "yarn run -T tsx ../../internal/scripts/context.ts"
|
|
46
48
|
},
|
|
47
49
|
"dependencies": {
|
|
48
50
|
"@tiptap/core": "^2.9.1",
|
|
49
51
|
"@tiptap/pm": "^2.9.1",
|
|
50
52
|
"@tiptap/react": "^2.9.1",
|
|
51
|
-
"@tldraw/state": "3.16.0-internal.
|
|
52
|
-
"@tldraw/state-react": "3.16.0-internal.
|
|
53
|
-
"@tldraw/store": "3.16.0-internal.
|
|
54
|
-
"@tldraw/tlschema": "3.16.0-internal.
|
|
55
|
-
"@tldraw/utils": "3.16.0-internal.
|
|
56
|
-
"@tldraw/validate": "3.16.0-internal.
|
|
53
|
+
"@tldraw/state": "3.16.0-internal.f8b97f0c414f",
|
|
54
|
+
"@tldraw/state-react": "3.16.0-internal.f8b97f0c414f",
|
|
55
|
+
"@tldraw/store": "3.16.0-internal.f8b97f0c414f",
|
|
56
|
+
"@tldraw/tlschema": "3.16.0-internal.f8b97f0c414f",
|
|
57
|
+
"@tldraw/utils": "3.16.0-internal.f8b97f0c414f",
|
|
58
|
+
"@tldraw/validate": "3.16.0-internal.f8b97f0c414f",
|
|
57
59
|
"@types/core-js": "^2.5.8",
|
|
58
60
|
"@use-gesture/react": "^10.3.1",
|
|
59
61
|
"classnames": "^2.5.1",
|
|
@@ -68,41 +70,17 @@
|
|
|
68
70
|
},
|
|
69
71
|
"devDependencies": {
|
|
70
72
|
"@peculiar/webcrypto": "^1.5.0",
|
|
71
|
-
"@testing-library/jest-dom": "^5.17.0",
|
|
72
73
|
"@testing-library/react": "^15.0.7",
|
|
73
74
|
"@types/benchmark": "^2.1.5",
|
|
74
75
|
"@types/react": "^18.3.18",
|
|
75
76
|
"@types/wicg-file-system-access": "^2020.9.8",
|
|
76
77
|
"benchmark": "^2.1.4",
|
|
77
78
|
"fake-indexeddb": "^4.0.2",
|
|
78
|
-
"jest-canvas-mock": "^2.5.2",
|
|
79
|
-
"jest-environment-jsdom": "^29.7.0",
|
|
80
79
|
"lazyrepo": "0.0.0-alpha.27",
|
|
81
80
|
"react": "^18.3.1",
|
|
82
81
|
"react-dom": "^18.3.1",
|
|
83
|
-
"resize-observer-polyfill": "^1.5.1"
|
|
84
|
-
|
|
85
|
-
"jest": {
|
|
86
|
-
"preset": "../../internal/config/jest/node/jest-preset.js",
|
|
87
|
-
"testEnvironment": "../../../packages/utils/patchedJestJsDom.js",
|
|
88
|
-
"fakeTimers": {
|
|
89
|
-
"enableGlobally": true
|
|
90
|
-
},
|
|
91
|
-
"testPathIgnorePatterns": [
|
|
92
|
-
"^.+\\.*.css$"
|
|
93
|
-
],
|
|
94
|
-
"moduleNameMapper": {
|
|
95
|
-
"^~(.*)": "<rootDir>/src/$1",
|
|
96
|
-
"\\.(css|less|scss|sass)$": "identity-obj-proxy"
|
|
97
|
-
},
|
|
98
|
-
"setupFiles": [
|
|
99
|
-
"raf/polyfill",
|
|
100
|
-
"jest-canvas-mock",
|
|
101
|
-
"<rootDir>/setupTests.js"
|
|
102
|
-
],
|
|
103
|
-
"setupFilesAfterEnv": [
|
|
104
|
-
"../../internal/config/setupJest.ts"
|
|
105
|
-
]
|
|
82
|
+
"resize-observer-polyfill": "^1.5.1",
|
|
83
|
+
"vitest": "^3.2.4"
|
|
106
84
|
},
|
|
107
85
|
"module": "dist-esm/index.mjs",
|
|
108
86
|
"source": "src/index.ts",
|
package/src/index.ts
CHANGED
|
@@ -67,6 +67,10 @@ export {
|
|
|
67
67
|
DefaultShapeIndicators,
|
|
68
68
|
type TLShapeIndicatorsProps,
|
|
69
69
|
} from './lib/components/default-components/DefaultShapeIndicators'
|
|
70
|
+
export {
|
|
71
|
+
DefaultShapeWrapper,
|
|
72
|
+
type TLShapeWrapperProps,
|
|
73
|
+
} from './lib/components/default-components/DefaultShapeWrapper'
|
|
70
74
|
export {
|
|
71
75
|
DefaultSnapIndicator,
|
|
72
76
|
type TLSnapIndicatorProps,
|
|
@@ -261,9 +265,10 @@ export {
|
|
|
261
265
|
type TLCameraMoveOptions,
|
|
262
266
|
type TLCameraOptions,
|
|
263
267
|
type TLExportType,
|
|
268
|
+
type TLGetShapeAtPointOptions,
|
|
264
269
|
type TLImageExportOptions,
|
|
265
270
|
type TLSvgExportOptions,
|
|
266
|
-
type
|
|
271
|
+
type TLUpdatePointerOptions,
|
|
267
272
|
} from './lib/editor/types/misc-types'
|
|
268
273
|
export {
|
|
269
274
|
type TLAdjacentDirection,
|
|
@@ -287,7 +292,13 @@ export {
|
|
|
287
292
|
type ContainerProviderProps,
|
|
288
293
|
} from './lib/hooks/useContainer'
|
|
289
294
|
export { getCursor } from './lib/hooks/useCursor'
|
|
290
|
-
export {
|
|
295
|
+
export {
|
|
296
|
+
EditorContext,
|
|
297
|
+
EditorProvider,
|
|
298
|
+
useEditor,
|
|
299
|
+
useMaybeEditor,
|
|
300
|
+
type EditorProviderProps,
|
|
301
|
+
} from './lib/hooks/useEditor'
|
|
291
302
|
export { useEditorComponents } from './lib/hooks/useEditorComponents'
|
|
292
303
|
export type { TLEditorComponents } from './lib/hooks/useEditorComponents'
|
|
293
304
|
export { useEvent, useReactiveEvent } from './lib/hooks/useEvent'
|
|
@@ -319,9 +330,11 @@ export {
|
|
|
319
330
|
type InvalidLicenseReason,
|
|
320
331
|
type LicenseFromKeyResult,
|
|
321
332
|
type LicenseInfo,
|
|
333
|
+
type LicenseState,
|
|
322
334
|
type TestEnvironment,
|
|
323
335
|
type ValidLicenseKeyResult,
|
|
324
336
|
} from './lib/license/LicenseManager'
|
|
337
|
+
export { LICENSE_TIMEOUT } from './lib/license/LicenseProvider'
|
|
325
338
|
export { defaultTldrawOptions, type TldrawOptions } from './lib/options'
|
|
326
339
|
export {
|
|
327
340
|
Box,
|
|
@@ -340,6 +353,7 @@ export { CubicBezier2d } from './lib/primitives/geometry/CubicBezier2d'
|
|
|
340
353
|
export { CubicSpline2d } from './lib/primitives/geometry/CubicSpline2d'
|
|
341
354
|
export { Edge2d } from './lib/primitives/geometry/Edge2d'
|
|
342
355
|
export { Ellipse2d } from './lib/primitives/geometry/Ellipse2d'
|
|
356
|
+
export { getVerticesCountForArcLength } from './lib/primitives/geometry/geometry-constants'
|
|
343
357
|
export {
|
|
344
358
|
Geometry2d,
|
|
345
359
|
Geometry2dFilters,
|
|
@@ -433,11 +447,14 @@ export {
|
|
|
433
447
|
export {
|
|
434
448
|
activeElementShouldCaptureKeys,
|
|
435
449
|
loopToHtmlElement,
|
|
450
|
+
markEventAsHandled,
|
|
436
451
|
preventDefault,
|
|
437
452
|
releasePointerCapture,
|
|
438
453
|
setPointerCapture,
|
|
439
454
|
stopEventPropagation,
|
|
455
|
+
wasEventAlreadyHandled,
|
|
440
456
|
} from './lib/utils/dom'
|
|
457
|
+
export { EditorAtom } from './lib/utils/EditorAtom'
|
|
441
458
|
export { getIncrementedName } from './lib/utils/getIncrementedName'
|
|
442
459
|
export { getPointerInfo } from './lib/utils/getPointerInfo'
|
|
443
460
|
export { getSvgPathFromPoints } from './lib/utils/getSvgPathFromPoints'
|
|
@@ -471,14 +488,6 @@ export { type TLStoreWithStatus } from './lib/utils/sync/StoreWithStatus'
|
|
|
471
488
|
export { uniq } from './lib/utils/uniq'
|
|
472
489
|
export { openWindow } from './lib/utils/window-open'
|
|
473
490
|
|
|
474
|
-
/**
|
|
475
|
-
* @deprecated Licensing is now enabled in the tldraw SDK.
|
|
476
|
-
* @public */
|
|
477
|
-
export function debugEnableLicensing() {
|
|
478
|
-
// noop
|
|
479
|
-
return
|
|
480
|
-
}
|
|
481
|
-
|
|
482
491
|
registerTldrawLibraryVersion(
|
|
483
492
|
(globalThis as any).TLDRAW_LIBRARY_NAME,
|
|
484
493
|
(globalThis as any).TLDRAW_LIBRARY_VERSION,
|
package/src/lib/TldrawEditor.tsx
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { MigrationSequence, Store } from '@tldraw/store'
|
|
2
2
|
import { TLShape, TLStore, TLStoreSnapshot } from '@tldraw/tlschema'
|
|
3
|
-
import {
|
|
3
|
+
import { annotateError, Required } from '@tldraw/utils'
|
|
4
|
+
import classNames from 'classnames'
|
|
4
5
|
import React, {
|
|
5
|
-
ReactNode,
|
|
6
6
|
memo,
|
|
7
|
+
ReactNode,
|
|
7
8
|
useCallback,
|
|
8
9
|
useEffect,
|
|
9
10
|
useLayoutEffect,
|
|
@@ -12,16 +13,14 @@ import React, {
|
|
|
12
13
|
useState,
|
|
13
14
|
useSyncExternalStore,
|
|
14
15
|
} from 'react'
|
|
15
|
-
|
|
16
|
-
import classNames from 'classnames'
|
|
17
16
|
import { version } from '../version'
|
|
18
|
-
import { OptionalErrorBoundary } from './components/ErrorBoundary'
|
|
19
17
|
import { DefaultErrorFallback } from './components/default-components/DefaultErrorFallback'
|
|
20
|
-
import {
|
|
18
|
+
import { OptionalErrorBoundary } from './components/ErrorBoundary'
|
|
21
19
|
import { TLStoreBaseOptions } from './config/createTLStore'
|
|
22
|
-
import {
|
|
20
|
+
import { createTLUser, TLUser } from './config/createTLUser'
|
|
23
21
|
import { TLAnyBindingUtilConstructor } from './config/defaultBindings'
|
|
24
22
|
import { TLAnyShapeUtilConstructor } from './config/defaultShapes'
|
|
23
|
+
import { TLEditorSnapshot } from './config/TLEditorSnapshot'
|
|
25
24
|
import { Editor } from './editor/Editor'
|
|
26
25
|
import { TLStateNodeConstructor } from './editor/tools/StateNode'
|
|
27
26
|
import { TLCameraOptions } from './editor/types/misc-types'
|
|
@@ -39,12 +38,13 @@ import { useForceUpdate } from './hooks/useForceUpdate'
|
|
|
39
38
|
import { useShallowObjectIdentity } from './hooks/useIdentity'
|
|
40
39
|
import { useLocalStore } from './hooks/useLocalStore'
|
|
41
40
|
import { useRefState } from './hooks/useRefState'
|
|
41
|
+
import { useStateAttribute } from './hooks/useStateAttribute'
|
|
42
42
|
import { useZoomCss } from './hooks/useZoomCss'
|
|
43
43
|
import { LicenseProvider } from './license/LicenseProvider'
|
|
44
44
|
import { Watermark } from './license/Watermark'
|
|
45
45
|
import { TldrawOptions } from './options'
|
|
46
46
|
import { TLDeepLinkOptions } from './utils/deepLinks'
|
|
47
|
-
import {
|
|
47
|
+
import { markEventAsHandled } from './utils/dom'
|
|
48
48
|
import { TLTextOptions } from './utils/richText'
|
|
49
49
|
import { TLStoreWithStatus } from './utils/sync/StoreWithStatus'
|
|
50
50
|
|
|
@@ -188,13 +188,6 @@ export interface TldrawEditorBaseProps {
|
|
|
188
188
|
*/
|
|
189
189
|
deepLinks?: true | TLDeepLinkOptions
|
|
190
190
|
|
|
191
|
-
/**
|
|
192
|
-
* Predicate for whether or not a shape should be hidden.
|
|
193
|
-
*
|
|
194
|
-
* @deprecated Use {@link TldrawEditorBaseProps#getShapeVisibility} instead.
|
|
195
|
-
*/
|
|
196
|
-
isShapeHidden?(shape: TLShape, editor: Editor): boolean
|
|
197
|
-
|
|
198
191
|
/**
|
|
199
192
|
* Provides a way to hide shapes.
|
|
200
193
|
*
|
|
@@ -282,7 +275,7 @@ export const TldrawEditor = memo(function TldrawEditor({
|
|
|
282
275
|
data-tldraw={version}
|
|
283
276
|
draggable={false}
|
|
284
277
|
className={classNames(`${TL_CONTAINER_CLASS} tl-theme__light`, className)}
|
|
285
|
-
onPointerDown={
|
|
278
|
+
onPointerDown={markEventAsHandled}
|
|
286
279
|
tabIndex={-1}
|
|
287
280
|
role="application"
|
|
288
281
|
aria-label={_options?.branding ?? 'tldraw'}
|
|
@@ -411,8 +404,6 @@ function TldrawEditorWithReadyStore({
|
|
|
411
404
|
options,
|
|
412
405
|
licenseKey,
|
|
413
406
|
deepLinks: _deepLinks,
|
|
414
|
-
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
415
|
-
isShapeHidden,
|
|
416
407
|
getShapeVisibility,
|
|
417
408
|
assetUrls,
|
|
418
409
|
}: Required<
|
|
@@ -472,7 +463,6 @@ function TldrawEditorWithReadyStore({
|
|
|
472
463
|
textOptions,
|
|
473
464
|
options,
|
|
474
465
|
licenseKey,
|
|
475
|
-
isShapeHidden,
|
|
476
466
|
getShapeVisibility,
|
|
477
467
|
fontAssetUrls: assetUrls?.fonts,
|
|
478
468
|
})
|
|
@@ -508,7 +498,6 @@ function TldrawEditorWithReadyStore({
|
|
|
508
498
|
user,
|
|
509
499
|
setEditor,
|
|
510
500
|
licenseKey,
|
|
511
|
-
isShapeHidden,
|
|
512
501
|
getShapeVisibility,
|
|
513
502
|
textOptions,
|
|
514
503
|
assetUrls,
|
|
@@ -585,8 +574,13 @@ function TldrawEditorWithReadyStore({
|
|
|
585
574
|
if (editor !== fontLoadingState?.editor) {
|
|
586
575
|
fontLoadingState = null
|
|
587
576
|
}
|
|
588
|
-
|
|
577
|
+
useLayoutEffect(() => {
|
|
589
578
|
if (!editor) return
|
|
579
|
+
if (editor.options.maxFontsToLoadBeforeRender === 0) {
|
|
580
|
+
setFontLoadingState({ editor, isLoaded: true })
|
|
581
|
+
return
|
|
582
|
+
}
|
|
583
|
+
|
|
590
584
|
let isCancelled = false
|
|
591
585
|
|
|
592
586
|
setFontLoadingState({ editor, isLoaded: false })
|
|
@@ -646,6 +640,7 @@ function Layout({ children, onMount }: { children: ReactNode; onMount?: TLOnMoun
|
|
|
646
640
|
useCursor()
|
|
647
641
|
useDarkMode()
|
|
648
642
|
useForceUpdate()
|
|
643
|
+
useStateAttribute()
|
|
649
644
|
useOnMount((editor) => {
|
|
650
645
|
const teardownStore = editor.store.props.onMount(editor)
|
|
651
646
|
const teardownCallback = onMount?.(editor)
|
|
@@ -50,12 +50,6 @@ export function MenuClickCapture() {
|
|
|
50
50
|
// Do nothing unless we're pointing
|
|
51
51
|
if (!rPointerState.current.isDown) return
|
|
52
52
|
|
|
53
|
-
// If we're already dragging, pass on the event as it is
|
|
54
|
-
if (rPointerState.current.isDragging) {
|
|
55
|
-
canvasEvents.onPointerMove?.(e)
|
|
56
|
-
return
|
|
57
|
-
}
|
|
58
|
-
|
|
59
53
|
if (
|
|
60
54
|
// We're pointing, but are we dragging?
|
|
61
55
|
Vec.Dist2(rPointerState.current.start, new Vec(e.clientX, e.clientY)) >
|
|
@@ -75,8 +69,6 @@ export function MenuClickCapture() {
|
|
|
75
69
|
clientY: y,
|
|
76
70
|
button: 0,
|
|
77
71
|
})
|
|
78
|
-
// call the pointer move with the current pointer position
|
|
79
|
-
canvasEvents.onPointerMove?.(e)
|
|
80
72
|
}
|
|
81
73
|
},
|
|
82
74
|
[canvasEvents, editor]
|
|
@@ -7,7 +7,7 @@ export type SVGContainerProps = React.ComponentProps<'svg'>
|
|
|
7
7
|
/** @public @react */
|
|
8
8
|
export function SVGContainer({ children, className = '', ...rest }: SVGContainerProps) {
|
|
9
9
|
return (
|
|
10
|
-
<svg {...rest} className={classNames('tl-svg-container', className)}>
|
|
10
|
+
<svg {...rest} className={classNames('tl-svg-container', className)} aria-hidden="true">
|
|
11
11
|
{children}
|
|
12
12
|
</svg>
|
|
13
13
|
)
|
|
@@ -28,7 +28,6 @@ export const Shape = memo(function Shape({
|
|
|
28
28
|
index,
|
|
29
29
|
backgroundIndex,
|
|
30
30
|
opacity,
|
|
31
|
-
dprMultiple,
|
|
32
31
|
}: {
|
|
33
32
|
id: TLShapeId
|
|
34
33
|
shape: TLShape
|
|
@@ -36,11 +35,10 @@ export const Shape = memo(function Shape({
|
|
|
36
35
|
index: number
|
|
37
36
|
backgroundIndex: number
|
|
38
37
|
opacity: number
|
|
39
|
-
dprMultiple: number
|
|
40
38
|
}) {
|
|
41
39
|
const editor = useEditor()
|
|
42
40
|
|
|
43
|
-
const { ShapeErrorFallback } = useEditorComponents()
|
|
41
|
+
const { ShapeErrorFallback, ShapeWrapper } = useEditorComponents()
|
|
44
42
|
|
|
45
43
|
const containerRef = useRef<HTMLDivElement>(null)
|
|
46
44
|
const bgContainerRef = useRef<HTMLDivElement>(null)
|
|
@@ -91,18 +89,14 @@ export const Shape = memo(function Shape({
|
|
|
91
89
|
}
|
|
92
90
|
|
|
93
91
|
// Width / Height
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
const widthRemainder = bounds.w % dprMultiple
|
|
97
|
-
const heightRemainder = bounds.h % dprMultiple
|
|
98
|
-
const width = widthRemainder === 0 ? bounds.w : bounds.w + (dprMultiple - widthRemainder)
|
|
99
|
-
const height = heightRemainder === 0 ? bounds.h : bounds.h + (dprMultiple - heightRemainder)
|
|
92
|
+
const width = Math.max(bounds.width, 1)
|
|
93
|
+
const height = Math.max(bounds.height, 1)
|
|
100
94
|
|
|
101
95
|
if (width !== prev.width || height !== prev.height) {
|
|
102
|
-
setStyleProperty(containerRef.current, 'width',
|
|
103
|
-
setStyleProperty(containerRef.current, 'height',
|
|
104
|
-
setStyleProperty(bgContainerRef.current, 'width',
|
|
105
|
-
setStyleProperty(bgContainerRef.current, 'height',
|
|
96
|
+
setStyleProperty(containerRef.current, 'width', width + 'px')
|
|
97
|
+
setStyleProperty(containerRef.current, 'height', height + 'px')
|
|
98
|
+
setStyleProperty(bgContainerRef.current, 'width', width + 'px')
|
|
99
|
+
setStyleProperty(bgContainerRef.current, 'height', height + 'px')
|
|
106
100
|
prev.width = width
|
|
107
101
|
prev.height = height
|
|
108
102
|
}
|
|
@@ -145,37 +139,22 @@ export const Shape = memo(function Shape({
|
|
|
145
139
|
[editor]
|
|
146
140
|
)
|
|
147
141
|
|
|
148
|
-
if (!shape) return null
|
|
149
|
-
|
|
150
|
-
const isFilledShape = 'fill' in shape.props && shape.props.fill !== 'none'
|
|
142
|
+
if (!shape || !ShapeWrapper) return null
|
|
151
143
|
|
|
152
144
|
return (
|
|
153
145
|
<>
|
|
154
146
|
{util.backgroundComponent && (
|
|
155
|
-
<
|
|
156
|
-
ref={bgContainerRef}
|
|
157
|
-
className="tl-shape tl-shape-background"
|
|
158
|
-
data-shape-type={shape.type}
|
|
159
|
-
data-shape-id={shape.id}
|
|
160
|
-
draggable={false}
|
|
161
|
-
>
|
|
147
|
+
<ShapeWrapper ref={bgContainerRef} shape={shape} isBackground={true}>
|
|
162
148
|
<OptionalErrorBoundary fallback={ShapeErrorFallback} onError={annotateError}>
|
|
163
149
|
<InnerShapeBackground shape={shape} util={util} />
|
|
164
150
|
</OptionalErrorBoundary>
|
|
165
|
-
</
|
|
151
|
+
</ShapeWrapper>
|
|
166
152
|
)}
|
|
167
|
-
<
|
|
168
|
-
ref={containerRef}
|
|
169
|
-
className="tl-shape"
|
|
170
|
-
data-shape-type={shape.type}
|
|
171
|
-
data-shape-is-filled={isFilledShape}
|
|
172
|
-
data-shape-id={shape.id}
|
|
173
|
-
draggable={false}
|
|
174
|
-
>
|
|
153
|
+
<ShapeWrapper ref={containerRef} shape={shape} isBackground={false}>
|
|
175
154
|
<OptionalErrorBoundary fallback={ShapeErrorFallback as any} onError={annotateError}>
|
|
176
155
|
<InnerShape shape={shape} util={util} />
|
|
177
156
|
</OptionalErrorBoundary>
|
|
178
|
-
</
|
|
157
|
+
</ShapeWrapper>
|
|
179
158
|
</>
|
|
180
159
|
)
|
|
181
160
|
})
|
|
@@ -21,7 +21,7 @@ export const DefaultBrush = ({ brush, color, opacity, className }: TLBrushProps)
|
|
|
21
21
|
const h = toDomPrecision(Math.max(1, brush.h))
|
|
22
22
|
|
|
23
23
|
return (
|
|
24
|
-
<svg className="tl-overlays__item" ref={rSvg}>
|
|
24
|
+
<svg className="tl-overlays__item" ref={rSvg} aria-hidden="true">
|
|
25
25
|
{color ? (
|
|
26
26
|
<g className="tl-brush" opacity={opacity}>
|
|
27
27
|
<rect width={w} height={h} fill={color} opacity={0.75} />
|
|
@@ -21,8 +21,7 @@ import { Mat } from '../../primitives/Mat'
|
|
|
21
21
|
import { Vec } from '../../primitives/Vec'
|
|
22
22
|
import { toDomPrecision } from '../../primitives/utils'
|
|
23
23
|
import { debugFlags } from '../../utils/debug-flags'
|
|
24
|
-
import { setStyleProperty } from '../../utils/dom'
|
|
25
|
-
import { nearestMultiple } from '../../utils/nearestMultiple'
|
|
24
|
+
import { markEventAsHandled, setStyleProperty } from '../../utils/dom'
|
|
26
25
|
import { GeometryDebuggingView } from '../GeometryDebuggingView'
|
|
27
26
|
import { LiveCollaborators } from '../LiveCollaborators'
|
|
28
27
|
import { MenuClickCapture } from '../MenuClickCapture'
|
|
@@ -139,7 +138,7 @@ export function DefaultCanvas({ className }: TLCanvasComponentProps) {
|
|
|
139
138
|
data-testid="canvas"
|
|
140
139
|
{...events}
|
|
141
140
|
>
|
|
142
|
-
<svg className="tl-svg-context">
|
|
141
|
+
<svg className="tl-svg-context" aria-hidden="true">
|
|
143
142
|
<defs>
|
|
144
143
|
{shapeSvgDefs}
|
|
145
144
|
<CursorDef />
|
|
@@ -173,10 +172,18 @@ export function DefaultCanvas({ className }: TLCanvasComponentProps) {
|
|
|
173
172
|
<LiveCollaborators />
|
|
174
173
|
</div>
|
|
175
174
|
</div>
|
|
175
|
+
<div
|
|
176
|
+
className="tl-canvas__in-front"
|
|
177
|
+
onPointerDown={markEventAsHandled}
|
|
178
|
+
onPointerUp={markEventAsHandled}
|
|
179
|
+
onTouchStart={markEventAsHandled}
|
|
180
|
+
onTouchEnd={markEventAsHandled}
|
|
181
|
+
>
|
|
182
|
+
<InFrontOfTheCanvasWrapper />
|
|
183
|
+
</div>
|
|
176
184
|
<MovingCameraHitTestBlocker />
|
|
177
185
|
</div>
|
|
178
186
|
<MenuClickCapture />
|
|
179
|
-
<InFrontOfTheCanvasWrapper />
|
|
180
187
|
</>
|
|
181
188
|
)
|
|
182
189
|
}
|
|
@@ -390,18 +397,9 @@ function ShapesWithSVGs() {
|
|
|
390
397
|
|
|
391
398
|
const renderingShapes = useValue('rendering shapes', () => editor.getRenderingShapes(), [editor])
|
|
392
399
|
|
|
393
|
-
const dprMultiple = useValue(
|
|
394
|
-
'dpr multiple',
|
|
395
|
-
() =>
|
|
396
|
-
// dprMultiple is the smallest number we can multiply dpr by to get an integer
|
|
397
|
-
// it's usually 1, 2, or 4 (for e.g. dpr of 2, 2.5 and 2.25 respectively)
|
|
398
|
-
nearestMultiple(Math.floor(editor.getInstanceState().devicePixelRatio * 100) / 100),
|
|
399
|
-
[editor]
|
|
400
|
-
)
|
|
401
|
-
|
|
402
400
|
return renderingShapes.map((result) => (
|
|
403
401
|
<Fragment key={result.id + '_fragment'}>
|
|
404
|
-
<Shape {...result}
|
|
402
|
+
<Shape {...result} />
|
|
405
403
|
<DebugSvgCopy id={result.id} mode="iframe" />
|
|
406
404
|
</Fragment>
|
|
407
405
|
))
|
|
@@ -436,19 +434,10 @@ function ShapesToDisplay() {
|
|
|
436
434
|
|
|
437
435
|
const renderingShapes = useValue('rendering shapes', () => editor.getRenderingShapes(), [editor])
|
|
438
436
|
|
|
439
|
-
const dprMultiple = useValue(
|
|
440
|
-
'dpr multiple',
|
|
441
|
-
() =>
|
|
442
|
-
// dprMultiple is the smallest number we can multiply dpr by to get an integer
|
|
443
|
-
// it's usually 1, 2, or 4 (for e.g. dpr of 2, 2.5 and 2.25 respectively)
|
|
444
|
-
nearestMultiple(Math.floor(editor.getInstanceState().devicePixelRatio * 100) / 100),
|
|
445
|
-
[editor]
|
|
446
|
-
)
|
|
447
|
-
|
|
448
437
|
return (
|
|
449
438
|
<>
|
|
450
439
|
{renderingShapes.map((result) => (
|
|
451
|
-
<Shape key={result.id + '_shape'} {...result}
|
|
440
|
+
<Shape key={result.id + '_shape'} {...result} />
|
|
452
441
|
))}
|
|
453
442
|
{tlenv.isSafari && <ReflowIfNeeded />}
|
|
454
443
|
</>
|
|
@@ -39,12 +39,12 @@ export function DefaultCollaboratorHint({
|
|
|
39
39
|
const cursorHintId = useSharedSafeId('cursor_hint')
|
|
40
40
|
|
|
41
41
|
return (
|
|
42
|
-
<svg ref={rSvg} className={classNames('tl-overlays__item', className)}>
|
|
42
|
+
<svg ref={rSvg} className={classNames('tl-overlays__item', className)} aria-hidden="true">
|
|
43
43
|
<use
|
|
44
44
|
href={`#${cursorHintId}`}
|
|
45
45
|
color={color}
|
|
46
46
|
strokeWidth={3}
|
|
47
|
-
stroke="var(--color-background)"
|
|
47
|
+
stroke="var(--tl-color-background)"
|
|
48
48
|
/>
|
|
49
49
|
<use href={`#${cursorHintId}`} color={color} opacity={opacity} />
|
|
50
50
|
</svg>
|
|
@@ -33,7 +33,7 @@ export const DefaultCursor = memo(function DefaultCursor({
|
|
|
33
33
|
|
|
34
34
|
return (
|
|
35
35
|
<div ref={rCursor} className={classNames('tl-overlays__item', className)}>
|
|
36
|
-
<svg className="tl-cursor">
|
|
36
|
+
<svg className="tl-cursor" aria-hidden="true">
|
|
37
37
|
<use href={`#${cursorId}`} color={color} />
|
|
38
38
|
</svg>
|
|
39
39
|
{chatMessage ? (
|
|
@@ -75,7 +75,7 @@ export const DefaultErrorFallback: TLErrorFallbackComponent = ({ error, editor }
|
|
|
75
75
|
|
|
76
76
|
// if we can't find a theme class from the app or from a parent, we have
|
|
77
77
|
// to fall back on using a media query:
|
|
78
|
-
if (typeof window !== 'undefined' &&
|
|
78
|
+
if (typeof window !== 'undefined' && window.matchMedia) {
|
|
79
79
|
setIsDarkMode(window.matchMedia('(prefers-color-scheme: dark)').matches)
|
|
80
80
|
}
|
|
81
81
|
}, [isDarkModeFromApp])
|
|
@@ -16,7 +16,7 @@ export function DefaultGrid({ x, y, z, size }: TLGridProps) {
|
|
|
16
16
|
const editor = useEditor()
|
|
17
17
|
const { gridSteps } = editor.options
|
|
18
18
|
return (
|
|
19
|
-
<svg className="tl-grid" version="1.1" xmlns="http://www.w3.org/2000/svg">
|
|
19
|
+
<svg className="tl-grid" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
|
20
20
|
<defs>
|
|
21
21
|
{gridSteps.map(({ min, mid, step }, i) => {
|
|
22
22
|
const s = step * size * z
|
|
@@ -7,5 +7,9 @@ export interface TLHandlesProps {
|
|
|
7
7
|
|
|
8
8
|
/** @public @react */
|
|
9
9
|
export const DefaultHandles = ({ children }: TLHandlesProps) => {
|
|
10
|
-
return
|
|
10
|
+
return (
|
|
11
|
+
<svg className="tl-user-handles tl-overlays__item" aria-hidden="true">
|
|
12
|
+
{children}
|
|
13
|
+
</svg>
|
|
14
|
+
)
|
|
11
15
|
}
|
|
@@ -21,7 +21,7 @@ export function DefaultScribble({ scribble, zoom, color, opacity, className }: T
|
|
|
21
21
|
<path
|
|
22
22
|
className="tl-scribble"
|
|
23
23
|
d={getSvgPathFromPoints(scribble.points, false)}
|
|
24
|
-
stroke={color ?? `var(--color-${scribble.color})`}
|
|
24
|
+
stroke={color ?? `var(--tl-color-${scribble.color})`}
|
|
25
25
|
fill="none"
|
|
26
26
|
strokeWidth={8 / zoom}
|
|
27
27
|
opacity={opacity ?? scribble.opacity}
|
|
@@ -86,8 +86,12 @@ export const DefaultShapeIndicator = memo(function DefaultShapeIndicator({
|
|
|
86
86
|
}, [hidden])
|
|
87
87
|
|
|
88
88
|
return (
|
|
89
|
-
<svg ref={rIndicator} className={classNames('tl-overlays__item', className)}>
|
|
90
|
-
<g
|
|
89
|
+
<svg ref={rIndicator} className={classNames('tl-overlays__item', className)} aria-hidden="true">
|
|
90
|
+
<g
|
|
91
|
+
className="tl-shape-indicator"
|
|
92
|
+
stroke={color ?? 'var(--tl-color-selected)'}
|
|
93
|
+
opacity={opacity}
|
|
94
|
+
>
|
|
91
95
|
<InnerIndicator editor={editor} id={shapeId} />
|
|
92
96
|
</g>
|
|
93
97
|
</svg>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { TLShape } from '@tldraw/tlschema'
|
|
2
|
+
import classNames from 'classnames'
|
|
3
|
+
import { forwardRef, ReactNode } from 'react'
|
|
4
|
+
|
|
5
|
+
/** @public */
|
|
6
|
+
export interface TLShapeWrapperProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
7
|
+
/** The shape being rendered. */
|
|
8
|
+
shape: TLShape
|
|
9
|
+
/** Whether this is the shapes regular, or background component. */
|
|
10
|
+
isBackground: boolean
|
|
11
|
+
/** The shape's rendered component. */
|
|
12
|
+
children: ReactNode
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** @public @react */
|
|
16
|
+
export const DefaultShapeWrapper = forwardRef(function DefaultShapeWrapper(
|
|
17
|
+
{ children, shape, isBackground, ...props }: TLShapeWrapperProps,
|
|
18
|
+
ref: React.Ref<HTMLDivElement>
|
|
19
|
+
) {
|
|
20
|
+
const isFilledShape = 'fill' in shape.props && shape.props.fill !== 'none'
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<div
|
|
24
|
+
ref={ref}
|
|
25
|
+
data-shape-type={shape.type}
|
|
26
|
+
data-shape-is-filled={isBackground ? undefined : isFilledShape}
|
|
27
|
+
data-shape-id={shape.id}
|
|
28
|
+
draggable={false}
|
|
29
|
+
{...props}
|
|
30
|
+
className={classNames('tl-shape', isBackground && 'tl-shape-background', props.className)}
|
|
31
|
+
>
|
|
32
|
+
{children}
|
|
33
|
+
</div>
|
|
34
|
+
)
|
|
35
|
+
})
|
|
@@ -163,7 +163,7 @@ export interface TLSnapIndicatorProps {
|
|
|
163
163
|
/** @public @react */
|
|
164
164
|
export function DefaultSnapIndicator({ className, line, zoom }: TLSnapIndicatorProps) {
|
|
165
165
|
return (
|
|
166
|
-
<svg className={classNames('tl-overlays__item', className)}>
|
|
166
|
+
<svg className={classNames('tl-overlays__item', className)} aria-hidden="true">
|
|
167
167
|
{line.type === 'points' ? (
|
|
168
168
|
<PointsSnapIndicator {...line} zoom={zoom} />
|
|
169
169
|
) : line.type === 'gaps' ? (
|