tldraw 5.4.0-next.ef99ab47e5ce → 5.4.0
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/DOCS.md +2826 -3226
- package/RELEASE_NOTES.md +190 -2
- package/dist-cjs/index.d.ts +264 -275
- package/dist-cjs/index.js +1 -1
- package/dist-cjs/lib/defaultExternalContentHandlers.js +32 -16
- package/dist-cjs/lib/defaultExternalContentHandlers.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/curved-arrow.js +2 -2
- package/dist-cjs/lib/shapes/arrow/curved-arrow.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/elbow/getElbowArrowInfo.js +2 -2
- package/dist-cjs/lib/shapes/arrow/elbow/getElbowArrowInfo.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/getArrowInfo.js +1 -1
- package/dist-cjs/lib/shapes/arrow/getArrowInfo.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/straight-arrow.js +2 -2
- package/dist-cjs/lib/shapes/arrow/straight-arrow.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/toolStates/Idle.js +2 -3
- package/dist-cjs/lib/shapes/arrow/toolStates/Idle.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.js +7 -5
- package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/shapes/draw/toolStates/Drawing.js +8 -6
- package/dist-cjs/lib/shapes/draw/toolStates/Drawing.js.map +2 -2
- package/dist-cjs/lib/shapes/geo/getGeoShapePath.js +3 -1
- package/dist-cjs/lib/shapes/geo/getGeoShapePath.js.map +2 -2
- package/dist-cjs/lib/shapes/geo/toolStates/Idle.js +2 -3
- package/dist-cjs/lib/shapes/geo/toolStates/Idle.js.map +2 -2
- package/dist-cjs/lib/shapes/geo/toolStates/Pointing.js +1 -1
- package/dist-cjs/lib/shapes/geo/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/shapes/line/toolStates/Pointing.js +2 -6
- package/dist-cjs/lib/shapes/line/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/shapes/note/NoteShapeUtil.js +4 -4
- package/dist-cjs/lib/shapes/note/NoteShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/note/noteHelpers.js +6 -5
- package/dist-cjs/lib/shapes/note/noteHelpers.js.map +2 -2
- package/dist-cjs/lib/shapes/note/toolStates/Pointing.js +1 -1
- package/dist-cjs/lib/shapes/note/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/crop.js +1 -1
- package/dist-cjs/lib/shapes/shared/crop.js.map +2 -2
- package/dist-cjs/lib/shapes/text/toolStates/Idle.js +1 -1
- package/dist-cjs/lib/shapes/text/toolStates/Idle.js.map +2 -2
- package/dist-cjs/lib/shapes/text/toolStates/Pointing.js +1 -0
- package/dist-cjs/lib/shapes/text/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/shapes/video/VideoShapeUtil.js +3 -2
- package/dist-cjs/lib/shapes/video/VideoShapeUtil.js.map +2 -2
- package/dist-cjs/lib/tools/EraserTool/childStates/Erasing.js +2 -0
- package/dist-cjs/lib/tools/EraserTool/childStates/Erasing.js.map +2 -2
- package/dist-cjs/lib/tools/HandTool/childStates/OneFingerZooming.js +6 -0
- package/dist-cjs/lib/tools/HandTool/childStates/OneFingerZooming.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/SelectTool.js +3 -0
- package/dist-cjs/lib/tools/SelectTool/SelectTool.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Brushing.js +1 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/Brushing.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/Crop.js +1 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/Crop.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js +1 -3
- package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Idle.js +6 -3
- package/dist-cjs/lib/tools/SelectTool/childStates/Idle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingArrowLabel.js +1 -1
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingArrowLabel.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingCanvas.js +3 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingCanvas.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingHandle.js +1 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingHandle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingShape.js +1 -1
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingShape.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js +22 -30
- package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/ScribbleBrushing.js +1 -3
- package/dist-cjs/lib/tools/SelectTool/childStates/ScribbleBrushing.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js +4 -1
- package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/selectHelpers.js +10 -0
- package/dist-cjs/lib/tools/SelectTool/selectHelpers.js.map +2 -2
- package/dist-cjs/lib/ui/TldrawUi.js +2 -3
- package/dist-cjs/lib/ui/TldrawUi.js.map +2 -2
- package/dist-cjs/lib/ui/components/ActionsMenu/DefaultActionsMenu.js +1 -11
- package/dist-cjs/lib/ui/components/ActionsMenu/DefaultActionsMenu.js.map +2 -2
- package/dist-cjs/lib/ui/components/ContextMenu/DefaultContextMenu.js +6 -1
- package/dist-cjs/lib/ui/components/ContextMenu/DefaultContextMenu.js.map +2 -2
- package/dist-cjs/lib/ui/components/ContextMenu/DefaultContextMenuContent.js +1 -1
- package/dist-cjs/lib/ui/components/ContextMenu/DefaultContextMenuContent.js.map +2 -2
- package/dist-cjs/lib/ui/components/Dialogs.js +8 -0
- package/dist-cjs/lib/ui/components/Dialogs.js.map +2 -2
- package/dist-cjs/lib/ui/components/EditLinkDialog.js +5 -5
- package/dist-cjs/lib/ui/components/EditLinkDialog.js.map +2 -2
- package/dist-cjs/lib/ui/components/Minimap/DefaultMinimap.js +4 -20
- package/dist-cjs/lib/ui/components/Minimap/DefaultMinimap.js.map +2 -2
- package/dist-cjs/lib/ui/components/SharePanel/DefaultPeopleMenuItem.js +1 -2
- package/dist-cjs/lib/ui/components/SharePanel/DefaultPeopleMenuItem.js.map +2 -2
- package/dist-cjs/lib/ui/components/StylePanel/StylePanelDoubleDropdownPicker.js +2 -0
- package/dist-cjs/lib/ui/components/StylePanel/StylePanelDoubleDropdownPicker.js.map +2 -2
- package/dist-cjs/lib/ui/components/Toolbar/AltTextEditor.js +1 -0
- package/dist-cjs/lib/ui/components/Toolbar/AltTextEditor.js.map +2 -2
- package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbarContent.js +10 -8
- package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbarContent.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiSlider.js +20 -1
- package/dist-cjs/lib/ui/components/primitives/TldrawUiSlider.js.map +2 -2
- package/dist-cjs/lib/ui/context/actions.js +8 -8
- package/dist-cjs/lib/ui/context/actions.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/useClipboardEvents.js +2 -0
- package/dist-cjs/lib/ui/hooks/useClipboardEvents.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/useCommentingEnabled.js +1 -1
- package/dist-cjs/lib/ui/hooks/useCommentingEnabled.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/useFlatten.js +42 -23
- package/dist-cjs/lib/ui/hooks/useFlatten.js.map +2 -2
- package/dist-cjs/lib/ui/version.js +3 -3
- package/dist-cjs/lib/ui/version.js.map +1 -1
- package/dist-esm/index.d.mts +264 -275
- package/dist-esm/index.mjs +1 -1
- package/dist-esm/lib/defaultExternalContentHandlers.mjs +32 -16
- package/dist-esm/lib/defaultExternalContentHandlers.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/curved-arrow.mjs +2 -2
- package/dist-esm/lib/shapes/arrow/curved-arrow.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/elbow/getElbowArrowInfo.mjs +2 -2
- package/dist-esm/lib/shapes/arrow/elbow/getElbowArrowInfo.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/getArrowInfo.mjs +1 -1
- package/dist-esm/lib/shapes/arrow/getArrowInfo.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/straight-arrow.mjs +2 -2
- package/dist-esm/lib/shapes/arrow/straight-arrow.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/toolStates/Idle.mjs +3 -4
- package/dist-esm/lib/shapes/arrow/toolStates/Idle.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs +7 -5
- package/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/shapes/draw/toolStates/Drawing.mjs +8 -6
- package/dist-esm/lib/shapes/draw/toolStates/Drawing.mjs.map +2 -2
- package/dist-esm/lib/shapes/geo/getGeoShapePath.mjs +3 -1
- package/dist-esm/lib/shapes/geo/getGeoShapePath.mjs.map +2 -2
- package/dist-esm/lib/shapes/geo/toolStates/Idle.mjs +3 -4
- package/dist-esm/lib/shapes/geo/toolStates/Idle.mjs.map +2 -2
- package/dist-esm/lib/shapes/geo/toolStates/Pointing.mjs +1 -1
- package/dist-esm/lib/shapes/geo/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/shapes/line/toolStates/Pointing.mjs +2 -7
- package/dist-esm/lib/shapes/line/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs +4 -4
- package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/note/noteHelpers.mjs +6 -5
- package/dist-esm/lib/shapes/note/noteHelpers.mjs.map +2 -2
- package/dist-esm/lib/shapes/note/toolStates/Pointing.mjs +1 -1
- package/dist-esm/lib/shapes/note/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/crop.mjs +1 -1
- package/dist-esm/lib/shapes/shared/crop.mjs.map +2 -2
- package/dist-esm/lib/shapes/text/toolStates/Idle.mjs +2 -2
- package/dist-esm/lib/shapes/text/toolStates/Idle.mjs.map +2 -2
- package/dist-esm/lib/shapes/text/toolStates/Pointing.mjs +1 -0
- package/dist-esm/lib/shapes/text/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/shapes/video/VideoShapeUtil.mjs +3 -2
- package/dist-esm/lib/shapes/video/VideoShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/tools/EraserTool/childStates/Erasing.mjs +2 -0
- package/dist-esm/lib/tools/EraserTool/childStates/Erasing.mjs.map +2 -2
- package/dist-esm/lib/tools/HandTool/childStates/OneFingerZooming.mjs +6 -0
- package/dist-esm/lib/tools/HandTool/childStates/OneFingerZooming.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/SelectTool.mjs +3 -0
- package/dist-esm/lib/tools/SelectTool/SelectTool.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Brushing.mjs +1 -0
- package/dist-esm/lib/tools/SelectTool/childStates/Brushing.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/Crop.mjs +1 -0
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/Crop.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs +1 -3
- package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Idle.mjs +6 -3
- package/dist-esm/lib/tools/SelectTool/childStates/Idle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingArrowLabel.mjs +1 -1
- package/dist-esm/lib/tools/SelectTool/childStates/PointingArrowLabel.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingCanvas.mjs +3 -0
- package/dist-esm/lib/tools/SelectTool/childStates/PointingCanvas.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingHandle.mjs +5 -1
- package/dist-esm/lib/tools/SelectTool/childStates/PointingHandle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingShape.mjs +1 -1
- package/dist-esm/lib/tools/SelectTool/childStates/PointingShape.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs +22 -31
- package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/ScribbleBrushing.mjs +1 -3
- package/dist-esm/lib/tools/SelectTool/childStates/ScribbleBrushing.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs +4 -1
- package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/selectHelpers.mjs +10 -0
- package/dist-esm/lib/tools/SelectTool/selectHelpers.mjs.map +2 -2
- package/dist-esm/lib/ui/TldrawUi.mjs +2 -3
- package/dist-esm/lib/ui/TldrawUi.mjs.map +2 -2
- package/dist-esm/lib/ui/components/ActionsMenu/DefaultActionsMenu.mjs +2 -12
- package/dist-esm/lib/ui/components/ActionsMenu/DefaultActionsMenu.mjs.map +2 -2
- package/dist-esm/lib/ui/components/ContextMenu/DefaultContextMenu.mjs +7 -2
- package/dist-esm/lib/ui/components/ContextMenu/DefaultContextMenu.mjs.map +2 -2
- package/dist-esm/lib/ui/components/ContextMenu/DefaultContextMenuContent.mjs +1 -1
- package/dist-esm/lib/ui/components/ContextMenu/DefaultContextMenuContent.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Dialogs.mjs +9 -1
- package/dist-esm/lib/ui/components/Dialogs.mjs.map +2 -2
- package/dist-esm/lib/ui/components/EditLinkDialog.mjs +5 -5
- package/dist-esm/lib/ui/components/EditLinkDialog.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Minimap/DefaultMinimap.mjs +5 -22
- package/dist-esm/lib/ui/components/Minimap/DefaultMinimap.mjs.map +2 -2
- package/dist-esm/lib/ui/components/SharePanel/DefaultPeopleMenuItem.mjs +1 -2
- package/dist-esm/lib/ui/components/SharePanel/DefaultPeopleMenuItem.mjs.map +2 -2
- package/dist-esm/lib/ui/components/StylePanel/StylePanelDoubleDropdownPicker.mjs +2 -0
- package/dist-esm/lib/ui/components/StylePanel/StylePanelDoubleDropdownPicker.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Toolbar/AltTextEditor.mjs +1 -0
- package/dist-esm/lib/ui/components/Toolbar/AltTextEditor.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbarContent.mjs +10 -8
- package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbarContent.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiSlider.mjs +20 -1
- package/dist-esm/lib/ui/components/primitives/TldrawUiSlider.mjs.map +2 -2
- package/dist-esm/lib/ui/context/actions.mjs +8 -8
- package/dist-esm/lib/ui/context/actions.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/useClipboardEvents.mjs +2 -0
- package/dist-esm/lib/ui/hooks/useClipboardEvents.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/useCommentingEnabled.mjs +2 -2
- package/dist-esm/lib/ui/hooks/useCommentingEnabled.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/useFlatten.mjs +42 -23
- package/dist-esm/lib/ui/hooks/useFlatten.mjs.map +2 -2
- package/dist-esm/lib/ui/version.mjs +3 -3
- package/dist-esm/lib/ui/version.mjs.map +1 -1
- package/package.json +12 -6
- package/src/lib/defaultExternalContentHandlers.test.ts +43 -0
- package/src/lib/defaultExternalContentHandlers.ts +40 -18
- package/src/lib/shapes/arrow/ArrowShapeTool.test.ts +17 -0
- package/src/lib/shapes/arrow/curved-arrow.ts +2 -2
- package/src/lib/shapes/arrow/elbow/getElbowArrowInfo.tsx +5 -3
- package/src/lib/shapes/arrow/getArrowInfo.ts +2 -1
- package/src/lib/shapes/arrow/straight-arrow.ts +2 -2
- package/src/lib/shapes/arrow/toolStates/Idle.tsx +3 -4
- package/src/lib/shapes/arrow/toolStates/Pointing.tsx +10 -6
- package/src/lib/shapes/draw/DrawShapeTool.test.ts +19 -0
- package/src/lib/shapes/draw/toolStates/Drawing.ts +12 -6
- package/src/lib/shapes/frame/FrameShapeTool.test.ts +17 -0
- package/src/lib/shapes/geo/GeoShapeTool.test.ts +28 -0
- package/src/lib/shapes/geo/getGeoShapePath.ts +3 -1
- package/src/lib/shapes/geo/toolStates/Idle.ts +3 -4
- package/src/lib/shapes/geo/toolStates/Pointing.ts +2 -1
- package/src/lib/shapes/line/LineShapeTool.test.ts +30 -1
- package/src/lib/shapes/line/toolStates/Pointing.ts +6 -7
- package/src/lib/shapes/note/NoteShapeTool.test.ts +45 -0
- package/src/lib/shapes/note/NoteShapeUtil.tsx +7 -4
- package/src/lib/shapes/note/noteHelpers.ts +18 -8
- package/src/lib/shapes/note/toolStates/Pointing.ts +2 -1
- package/src/lib/shapes/shared/crop.ts +7 -1
- package/src/lib/shapes/text/TextShapeTool.test.ts +33 -0
- package/src/lib/shapes/text/toolStates/Idle.ts +2 -2
- package/src/lib/shapes/text/toolStates/Pointing.ts +3 -0
- package/src/lib/shapes/video/VideoShapeUtil.tsx +4 -2
- package/src/lib/tools/EraserTool/childStates/Erasing.ts +5 -0
- package/src/lib/tools/HandTool/childStates/OneFingerZooming.ts +10 -0
- package/src/lib/tools/SelectTool/SelectTool.ts +4 -0
- package/src/lib/tools/SelectTool/childStates/Brushing.ts +4 -0
- package/src/lib/tools/SelectTool/childStates/Crop/Crop.ts +4 -0
- package/src/lib/tools/SelectTool/childStates/DraggingHandle.tsx +3 -4
- package/src/lib/tools/SelectTool/childStates/Idle.ts +10 -3
- package/src/lib/tools/SelectTool/childStates/PointingArrowLabel.ts +1 -1
- package/src/lib/tools/SelectTool/childStates/PointingCanvas.ts +4 -0
- package/src/lib/tools/SelectTool/childStates/PointingHandle.ts +6 -1
- package/src/lib/tools/SelectTool/childStates/PointingShape.ts +4 -1
- package/src/lib/tools/SelectTool/childStates/Resizing.ts +30 -33
- package/src/lib/tools/SelectTool/childStates/ScribbleBrushing.ts +3 -3
- package/src/lib/tools/SelectTool/childStates/Translating.ts +6 -0
- package/src/lib/tools/SelectTool/selectHelpers.ts +21 -0
- package/src/lib/ui/TldrawUi.tsx +1 -2
- package/src/lib/ui/components/ActionsMenu/DefaultActionsMenu.tsx +4 -14
- package/src/lib/ui/components/ContextMenu/DefaultContextMenu.tsx +8 -2
- package/src/lib/ui/components/ContextMenu/DefaultContextMenuContent.tsx +5 -1
- package/src/lib/ui/components/Dialogs.tsx +17 -1
- package/src/lib/ui/components/EditLinkDialog.tsx +8 -7
- package/src/lib/ui/components/Minimap/DefaultMinimap.tsx +5 -23
- package/src/lib/ui/components/SharePanel/DefaultPeopleMenuItem.tsx +2 -3
- package/src/lib/ui/components/StylePanel/StylePanelDoubleDropdownPicker.tsx +2 -0
- package/src/lib/ui/components/Toolbar/AltTextEditor.tsx +1 -0
- package/src/lib/ui/components/Toolbar/DefaultImageToolbarContent.tsx +13 -8
- package/src/lib/ui/components/primitives/TldrawUiSlider.test.tsx +92 -0
- package/src/lib/ui/components/primitives/TldrawUiSlider.tsx +25 -1
- package/src/lib/ui/context/actions.tsx +25 -8
- package/src/lib/ui/hooks/useClipboardEvents.ts +2 -0
- package/src/lib/ui/hooks/useCommentingEnabled.ts +5 -3
- package/src/lib/ui/hooks/useFlatten.ts +56 -23
- package/src/lib/ui/version.ts +3 -3
- package/src/lib/ui.css +7 -16
- package/src/test/ClickManager.test.ts +18 -0
- package/src/test/Editor.test.tsx +3 -0
- package/src/test/EraserTool.test.ts +18 -2
- package/src/test/HandTool.test.ts +21 -0
- package/src/test/LaserTool.test.ts +46 -0
- package/src/test/ScribbleManager.test.ts +19 -0
- package/src/test/SelectTool.test.ts +110 -0
- package/src/test/TldrawEditor.test.tsx +18 -0
- package/src/test/VideoShapeUtil.test.tsx +126 -0
- package/src/test/actions-menu-readonly.test.tsx +37 -0
- package/src/test/bookmark-shapes.test.ts +110 -0
- package/src/test/commands/__snapshots__/packShapes.test.ts.snap +6 -6
- package/src/test/commands/clipboard.test.ts +36 -1
- package/src/test/commands/lockShapes.test.ts +11 -0
- package/src/test/commands/packShapes.test.ts +20 -0
- package/src/test/commands/putContent.test.ts +35 -1
- package/src/test/commands/setCamera.test.ts +69 -0
- package/src/test/commands/stackShapes.test.ts +12 -0
- package/src/test/commands/updateViewportPageBounds.test.ts +8 -0
- package/src/test/cropping.test.ts +162 -0
- package/src/test/customSnapping.test.tsx +32 -0
- package/src/test/defaultHandleExternalFileContent.test.ts +86 -0
- package/src/test/drawing.test.ts +60 -1
- package/src/test/duplicate.test.ts +22 -0
- package/src/test/flatten.test.ts +135 -0
- package/src/test/frames.test.ts +51 -0
- package/src/test/getShapeAtPoint.test.ts +44 -1
- package/src/test/handleDeepLink.test.tsx +15 -0
- package/src/test/minimap-wheel.test.tsx +48 -0
- package/src/test/resizing.test.ts +46 -0
- package/src/test/selection-omnibus.test.ts +50 -0
- package/src/test/spacebarPanning.test.ts +58 -0
- package/src/test/translating.test.ts +42 -0
- package/src/test/ui/AltTextEditor.test.tsx +51 -0
- package/src/test/ui/ContextMenu.test.tsx +61 -2
- package/src/test/ui/EditLinkDialog.test.tsx +77 -0
- package/src/test/ui/ImageToolbar.test.tsx +58 -0
- package/src/test/ui/StylePanel.test.tsx +33 -2
- package/src/test/ui/keyboardShortcuts.test.tsx +27 -0
- package/src/test/ui/presenceActivity.test.tsx +44 -0
- package/src/test/ui/unlockAll.test.tsx +55 -0
- package/src/test/ui-outside-editor.test.tsx +74 -0
- package/src/test/viewport-following.test.ts +29 -1
- package/tldraw.css +7 -16
|
@@ -278,10 +278,10 @@ export async function defaultHandleExternalUrlAsset(
|
|
|
278
278
|
description:
|
|
279
279
|
doc.head.querySelector('meta[property="og:description"]')?.getAttribute('content') ?? '',
|
|
280
280
|
}
|
|
281
|
-
if (!meta.image.startsWith('http')) {
|
|
281
|
+
if (meta.image && !meta.image.startsWith('http')) {
|
|
282
282
|
meta.image = new URL(meta.image, url).href
|
|
283
283
|
}
|
|
284
|
-
if (!meta.favicon.startsWith('http')) {
|
|
284
|
+
if (meta.favicon && !meta.favicon.startsWith('http')) {
|
|
285
285
|
meta.favicon = new URL(meta.favicon, url).href
|
|
286
286
|
}
|
|
287
287
|
} catch (error) {
|
|
@@ -424,7 +424,19 @@ export async function defaultHandleExternalFileContent(
|
|
|
424
424
|
})
|
|
425
425
|
continue
|
|
426
426
|
}
|
|
427
|
-
|
|
427
|
+
// An undecodable image rejects here; uncaught, it aborts the whole drop,
|
|
428
|
+
// including files that already succeeded, with no toast (#10438).
|
|
429
|
+
let assetInfo: TLAsset | null
|
|
430
|
+
try {
|
|
431
|
+
assetInfo = await getAssetInfo(editor, sanitizedFile)
|
|
432
|
+
} catch (error) {
|
|
433
|
+
toasts.addToast({
|
|
434
|
+
title: msg('assets.files.upload-failed'),
|
|
435
|
+
severity: 'error',
|
|
436
|
+
})
|
|
437
|
+
console.error(error)
|
|
438
|
+
continue
|
|
439
|
+
}
|
|
428
440
|
if (!assetInfo) continue
|
|
429
441
|
if (assetInfo.type === 'image') {
|
|
430
442
|
editor.createTemporaryAssetPreview(assetInfo.id, sanitizedFile)
|
|
@@ -554,22 +566,30 @@ export async function defaultHandleExternalTextContent(
|
|
|
554
566
|
const newPoint = maybeSnapToGrid(new Vec(p.x - w / 2, p.y - h / 2), editor)
|
|
555
567
|
const shapeId = createShapeId()
|
|
556
568
|
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
569
|
+
editor.run(() => {
|
|
570
|
+
// Allow this to trigger the max shapes reached alert
|
|
571
|
+
editor.createShapes([
|
|
572
|
+
{
|
|
573
|
+
id: shapeId,
|
|
574
|
+
type: 'text',
|
|
575
|
+
x: newPoint.x,
|
|
576
|
+
y: newPoint.y,
|
|
577
|
+
props: {
|
|
578
|
+
richText: richTextToPaste,
|
|
579
|
+
// if the text has more than one line, align it to the left
|
|
580
|
+
textAlign: align,
|
|
581
|
+
autoSize,
|
|
582
|
+
w,
|
|
583
|
+
},
|
|
570
584
|
},
|
|
571
|
-
|
|
572
|
-
|
|
585
|
+
])
|
|
586
|
+
|
|
587
|
+
// createShapes silently creates nothing when the page is full, so only
|
|
588
|
+
// select the shape if it actually exists
|
|
589
|
+
if (editor.getShape(shapeId)) {
|
|
590
|
+
editor.select(shapeId)
|
|
591
|
+
}
|
|
592
|
+
})
|
|
573
593
|
}
|
|
574
594
|
|
|
575
595
|
/** @public */
|
|
@@ -623,6 +643,8 @@ export async function defaultHandleExternalUrlContent(
|
|
|
623
643
|
})
|
|
624
644
|
return
|
|
625
645
|
}
|
|
646
|
+
|
|
647
|
+
editor.select(result.value.id)
|
|
626
648
|
}
|
|
627
649
|
|
|
628
650
|
/** @public */
|
|
@@ -88,6 +88,23 @@ describe('When in the pointing state', () => {
|
|
|
88
88
|
editor.setCurrentTool('arrow').pointerDown(0, 0).pointerMove(10, 10)
|
|
89
89
|
editor.expectToBeIn('select.dragging_handle')
|
|
90
90
|
})
|
|
91
|
+
|
|
92
|
+
it('removes the pressed arrow when switching tools before dragging', () => {
|
|
93
|
+
const shapesBefore = editor.getCurrentPageShapes().length
|
|
94
|
+
editor.setCurrentTool('arrow').pointerDown(0, 0)
|
|
95
|
+
expect(editor.getCurrentPageShapes().length).toBe(shapesBefore + 1)
|
|
96
|
+
editor.setCurrentTool('geo')
|
|
97
|
+
expect(editor.getCurrentPageShapes().length).toBe(shapesBefore)
|
|
98
|
+
editor.expectToBeIn('geo.idle')
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
it('removes the pressed arrow when switching to the select tool before dragging', () => {
|
|
102
|
+
const shapesBefore = editor.getCurrentPageShapes().length
|
|
103
|
+
editor.setCurrentTool('arrow').pointerDown(0, 0)
|
|
104
|
+
editor.setCurrentTool('select')
|
|
105
|
+
expect(editor.getCurrentPageShapes().length).toBe(shapesBefore)
|
|
106
|
+
editor.expectToBeIn('select.idle')
|
|
107
|
+
})
|
|
91
108
|
})
|
|
92
109
|
|
|
93
110
|
// This could be moved to dragging_handle
|
|
@@ -182,7 +182,7 @@ export function getCurvedArrowInfo(
|
|
|
182
182
|
const strokeOffset =
|
|
183
183
|
arrowSW / 2 +
|
|
184
184
|
('size' in startShapeInfo.shape.props
|
|
185
|
-
? (theme.strokeWidth * STROKE_SIZES[startShapeInfo.shape.props.size]) / 2
|
|
185
|
+
? (theme.strokeWidth * (STROKE_SIZES[startShapeInfo.shape.props.size] ?? 0)) / 2
|
|
186
186
|
: 0)
|
|
187
187
|
offsetA = (BOUND_ARROW_OFFSET + strokeOffset) * shape.props.scale
|
|
188
188
|
minLength += strokeOffset * shape.props.scale
|
|
@@ -265,7 +265,7 @@ export function getCurvedArrowInfo(
|
|
|
265
265
|
const strokeOffset =
|
|
266
266
|
arrowSW / 2 +
|
|
267
267
|
('size' in endShapeInfo.shape.props
|
|
268
|
-
? (theme.strokeWidth * STROKE_SIZES[endShapeInfo.shape.props.size]) / 2
|
|
268
|
+
? (theme.strokeWidth * (STROKE_SIZES[endShapeInfo.shape.props.size] ?? 0)) / 2
|
|
269
269
|
: 0)
|
|
270
270
|
offsetB = (BOUND_ARROW_OFFSET + strokeOffset) * shape.props.scale
|
|
271
271
|
minLength += strokeOffset * shape.props.scale
|
|
@@ -142,12 +142,14 @@ export function getElbowArrowInfo(
|
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
// We expand the bounds of the terminals so we can route arrows around them without the arrows
|
|
145
|
-
// being too close to the shapes.
|
|
145
|
+
// being too close to the shapes. Always a separate Box from `bounds`: ElbowArrowWorkingInfo
|
|
146
|
+
// transforms `original` and `expanded` in place, so sharing one object would transform a point
|
|
147
|
+
// terminal twice (a no-op for flips, a 180° turn for rotations) and corrupt the route.
|
|
146
148
|
const expandedA = aTerminal.isPoint
|
|
147
|
-
? aTerminal.bounds
|
|
149
|
+
? aTerminal.bounds.clone()
|
|
148
150
|
: aTerminal.bounds.clone().expandBy(options.expandElbowLegLength)
|
|
149
151
|
const expandedB = bTerminal.isPoint
|
|
150
|
-
? bTerminal.bounds
|
|
152
|
+
? bTerminal.bounds.clone()
|
|
151
153
|
: bTerminal.bounds.clone().expandBy(options.expandElbowLegLength)
|
|
152
154
|
|
|
153
155
|
const common: ElbowArrowBox = {
|
|
@@ -18,8 +18,9 @@ const arrowInfoCache = createComputedCache<Editor, TLArrowInfo, TLArrowShape>(
|
|
|
18
18
|
(editor: Editor, shape: TLArrowShape): TLArrowInfo => {
|
|
19
19
|
const bindings = getArrowBindings(editor, shape)
|
|
20
20
|
const util = editor.getShapeUtil(shape)
|
|
21
|
+
// A replacement arrow util may not carry display values; fall back to the theme width.
|
|
21
22
|
const sw =
|
|
22
|
-
'
|
|
23
|
+
'getDefaultDisplayValues' in util.options && 'getCustomDisplayValues' in util.options
|
|
23
24
|
? (getDisplayValues(util as any, shape) as { strokeWidth: number }).strokeWidth
|
|
24
25
|
: editor.getCurrentTheme().strokeWidth * STROKE_SIZES[shape.props.size]
|
|
25
26
|
|
|
@@ -139,7 +139,7 @@ export function getStraightArrowInfo(
|
|
|
139
139
|
strokeOffsetA =
|
|
140
140
|
arrowSW / 2 +
|
|
141
141
|
('size' in startShapeInfo.shape.props
|
|
142
|
-
? (theme.strokeWidth * STROKE_SIZES[startShapeInfo.shape.props.size]) / 2
|
|
142
|
+
? (theme.strokeWidth * (STROKE_SIZES[startShapeInfo.shape.props.size] ?? 0)) / 2
|
|
143
143
|
: 0)
|
|
144
144
|
offsetA = (BOUND_ARROW_OFFSET + strokeOffsetA) * shape.props.scale
|
|
145
145
|
minLength += strokeOffsetA * shape.props.scale
|
|
@@ -156,7 +156,7 @@ export function getStraightArrowInfo(
|
|
|
156
156
|
strokeOffsetB =
|
|
157
157
|
arrowSW / 2 +
|
|
158
158
|
('size' in endShapeInfo.shape.props
|
|
159
|
-
? (theme.strokeWidth * STROKE_SIZES[endShapeInfo.shape.props.size]) / 2
|
|
159
|
+
? (theme.strokeWidth * (STROKE_SIZES[endShapeInfo.shape.props.size] ?? 0)) / 2
|
|
160
160
|
: 0)
|
|
161
161
|
offsetB = (BOUND_ARROW_OFFSET + strokeOffsetB) * shape.props.scale
|
|
162
162
|
minLength += strokeOffsetB * shape.props.scale
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { StateNode, TLKeyboardEventInfo, TLPointerEventInfo, TLShapeId } from '@tldraw/editor'
|
|
2
|
-
import {
|
|
2
|
+
import { startEditingShape } from '../../../tools/SelectTool/selectHelpers'
|
|
3
3
|
import { ArrowShapeUtil } from '../ArrowShapeUtil'
|
|
4
4
|
import { clearArrowTargetState, updateArrowTargetState } from '../arrowTargetState'
|
|
5
5
|
|
|
@@ -42,9 +42,8 @@ export class Idle extends StateNode {
|
|
|
42
42
|
this.update()
|
|
43
43
|
if (info.key === 'Enter') {
|
|
44
44
|
const onlySelectedShape = this.editor.getOnlySelectedShape()
|
|
45
|
-
if (this.editor.canEditShape(onlySelectedShape))
|
|
46
|
-
|
|
47
|
-
}
|
|
45
|
+
if (!this.editor.canEditShape(onlySelectedShape)) return
|
|
46
|
+
startEditingShape(this.editor, onlySelectedShape, { selectAll: true })
|
|
48
47
|
}
|
|
49
48
|
}
|
|
50
49
|
|
|
@@ -37,7 +37,12 @@ export class Pointing extends StateNode {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
override onExit() {
|
|
40
|
-
|
|
40
|
+
// The press already created the arrow, so leaving without a drag (pointer up, cancel, or a
|
|
41
|
+
// tool switch) would otherwise strand a zero-length stub on the canvas
|
|
42
|
+
if (this.shape) {
|
|
43
|
+
this.editor.bailToMark(this.markId)
|
|
44
|
+
this.shape = undefined
|
|
45
|
+
}
|
|
41
46
|
clearArrowTargetState(this.editor)
|
|
42
47
|
this.clearPreciseTimeout()
|
|
43
48
|
}
|
|
@@ -55,8 +60,11 @@ export class Pointing extends StateNode {
|
|
|
55
60
|
|
|
56
61
|
this.updateArrowShapeEndHandle()
|
|
57
62
|
|
|
63
|
+
// Hand the arrow off before exiting so onExit does not bail it away
|
|
64
|
+
const shape = this.shape
|
|
65
|
+
this.shape = undefined
|
|
58
66
|
this.editor.setCurrentTool('select.dragging_handle', {
|
|
59
|
-
shape
|
|
67
|
+
shape,
|
|
60
68
|
handle: { id: 'end', type: 'vertex', index: 'a3', x: 0, y: 0 },
|
|
61
69
|
isCreating: true,
|
|
62
70
|
creatingMarkId: this.markId || undefined,
|
|
@@ -87,10 +95,6 @@ export class Pointing extends StateNode {
|
|
|
87
95
|
}
|
|
88
96
|
|
|
89
97
|
cancel() {
|
|
90
|
-
if (this.shape) {
|
|
91
|
-
// the arrow might not have been created yet!
|
|
92
|
-
this.editor.bailToMark(this.markId)
|
|
93
|
-
}
|
|
94
98
|
this.parent.transition('idle')
|
|
95
99
|
}
|
|
96
100
|
|
|
@@ -109,6 +109,25 @@ describe('Close threshold with zoom', () => {
|
|
|
109
109
|
expect(shape.props.isClosed).toBe(true)
|
|
110
110
|
})
|
|
111
111
|
|
|
112
|
+
it('Closes a small shape with densely sampled points', () => {
|
|
113
|
+
// Match the point density of the reported shape that exposed the length calculation bug.
|
|
114
|
+
const samples = 476
|
|
115
|
+
const radius = 20
|
|
116
|
+
const center = { x: 100, y: 100 }
|
|
117
|
+
|
|
118
|
+
editor.setCurrentTool('draw')
|
|
119
|
+
editor.pointerDown(center.x + radius, center.y)
|
|
120
|
+
for (let i = 1; i <= samples; i++) {
|
|
121
|
+
const angle = (i / samples) * Math.PI * 2
|
|
122
|
+
editor.pointerMove(center.x + Math.cos(angle) * radius, center.y + Math.sin(angle) * radius)
|
|
123
|
+
}
|
|
124
|
+
editor.pointerUp()
|
|
125
|
+
|
|
126
|
+
const shapes = editor.getCurrentPageShapes() as TLDrawShape[]
|
|
127
|
+
expect(shapes).toHaveLength(1)
|
|
128
|
+
expect(shapes[0].props.isClosed).toBe(true)
|
|
129
|
+
})
|
|
130
|
+
|
|
112
131
|
it('Does not close a shape when the endpoint is far from the start', () => {
|
|
113
132
|
const shape = drawNearlyClosedShape(50)
|
|
114
133
|
expect(shape.props.isClosed).toBe(false)
|
|
@@ -233,7 +233,9 @@ export class Drawing extends StateNode {
|
|
|
233
233
|
if (this.initialShape) {
|
|
234
234
|
const shape = this.editor.getShape<DrawableShape>(this.initialShape.id)
|
|
235
235
|
|
|
236
|
-
|
|
236
|
+
// The remembered shape survives a page change; extending it from another
|
|
237
|
+
// page would silently append a segment to content the user can't see (#10400)
|
|
238
|
+
if (shape && this.segmentMode === 'straight' && this.editor.isShapeInPage(shape)) {
|
|
237
239
|
// Connect dots
|
|
238
240
|
|
|
239
241
|
this.didJustShiftClickToExtendPreviousShapeLine = true
|
|
@@ -347,8 +349,10 @@ export class Drawing extends StateNode {
|
|
|
347
349
|
throw Error('We should have a point where the segment changed')
|
|
348
350
|
}
|
|
349
351
|
|
|
352
|
+
// page-space distance against a screen-space threshold, so scale by the zoom
|
|
353
|
+
const zoom = this.editor.getZoomLevel()
|
|
350
354
|
const hasMovedFarEnough =
|
|
351
|
-
Vec.Dist2(pagePointWhereNextSegmentChanged, inputs.getCurrentPagePoint()) >
|
|
355
|
+
Vec.Dist2(pagePointWhereNextSegmentChanged, inputs.getCurrentPagePoint()) * zoom * zoom >
|
|
352
356
|
this.editor.options.dragDistanceSquared
|
|
353
357
|
|
|
354
358
|
// Find the distance from where the pointer was when shift was released and
|
|
@@ -414,8 +418,10 @@ export class Drawing extends StateNode {
|
|
|
414
418
|
throw Error('We should have a point where the segment changed')
|
|
415
419
|
}
|
|
416
420
|
|
|
421
|
+
// page-space distance against a screen-space threshold, so scale by the zoom
|
|
422
|
+
const zoom = this.editor.getZoomLevel()
|
|
417
423
|
const hasMovedFarEnough =
|
|
418
|
-
Vec.Dist2(pagePointWhereNextSegmentChanged, inputs.getCurrentPagePoint()) >
|
|
424
|
+
Vec.Dist2(pagePointWhereNextSegmentChanged, inputs.getCurrentPagePoint()) * zoom * zoom >
|
|
419
425
|
this.editor.options.dragDistanceSquared
|
|
420
426
|
|
|
421
427
|
// Find the distance from where the pointer was when shift was released and
|
|
@@ -693,7 +699,7 @@ export class Drawing extends StateNode {
|
|
|
693
699
|
const currentPagePoint = inputs.getCurrentPagePoint()
|
|
694
700
|
|
|
695
701
|
// Reset cache for the new shape's segment
|
|
696
|
-
const initialPoint = new Vec(0, 0, this.isPenOrStylus ? +(z! * 1.25).toFixed() : 0.5)
|
|
702
|
+
const initialPoint = new Vec(0, 0, this.isPenOrStylus ? +(z! * 1.25).toFixed(2) : 0.5)
|
|
697
703
|
this.currentSegmentPoints = [initialPoint]
|
|
698
704
|
|
|
699
705
|
this.editor.createShape({
|
|
@@ -733,11 +739,11 @@ export class Drawing extends StateNode {
|
|
|
733
739
|
for (let j = 0; j < segments.length; j++) {
|
|
734
740
|
const points = b64Vecs.decodePoints(segments[j].path, segments[j].dim)
|
|
735
741
|
for (let i = 0; i < points.length - 1; i++) {
|
|
736
|
-
length += Vec.
|
|
742
|
+
length += Vec.Dist(points[i], points[i + 1])
|
|
737
743
|
}
|
|
738
744
|
}
|
|
739
745
|
|
|
740
|
-
return
|
|
746
|
+
return length
|
|
741
747
|
}
|
|
742
748
|
|
|
743
749
|
override onPointerUp() {
|
|
@@ -131,6 +131,23 @@ describe('When in the pointing state', () => {
|
|
|
131
131
|
editor.expectToBeIn('frame.idle')
|
|
132
132
|
expect(editor.getCurrentPageShapes().length).toBe(1)
|
|
133
133
|
})
|
|
134
|
+
|
|
135
|
+
it('Leaves nothing behind on complete before the pointer is released', () => {
|
|
136
|
+
editor.setCurrentTool('frame')
|
|
137
|
+
editor.pointerDown(50, 50)
|
|
138
|
+
editor.expectToBeIn('frame.pointing')
|
|
139
|
+
editor.complete()
|
|
140
|
+
editor.expectToBeIn('frame.idle')
|
|
141
|
+
expect(editor.getCurrentPageShapes().length).toBe(0)
|
|
142
|
+
})
|
|
143
|
+
|
|
144
|
+
it('Does not create a frame when undo is pressed mid-press', () => {
|
|
145
|
+
editor.setCurrentTool('frame')
|
|
146
|
+
editor.pointerDown(50, 50)
|
|
147
|
+
editor.undo()
|
|
148
|
+
editor.expectToBeIn('frame.idle')
|
|
149
|
+
expect(editor.getCurrentPageShapes().length).toBe(0)
|
|
150
|
+
})
|
|
134
151
|
})
|
|
135
152
|
|
|
136
153
|
describe('When in the resizing state', () => {
|
|
@@ -209,6 +209,23 @@ describe('When in the pointing state', () => {
|
|
|
209
209
|
editor.expectToBeIn('geo.idle')
|
|
210
210
|
expect(editor.getCurrentPageShapes().length).toBe(1)
|
|
211
211
|
})
|
|
212
|
+
|
|
213
|
+
it('Leaves nothing behind on complete before the pointer is released', () => {
|
|
214
|
+
editor.setCurrentTool('geo')
|
|
215
|
+
editor.pointerDown(50, 50)
|
|
216
|
+
editor.expectToBeIn('geo.pointing')
|
|
217
|
+
editor.complete()
|
|
218
|
+
editor.expectToBeIn('geo.idle')
|
|
219
|
+
expect(editor.getCurrentPageShapes().length).toBe(0)
|
|
220
|
+
})
|
|
221
|
+
|
|
222
|
+
it('Does not create a geo when undo is pressed mid-press', () => {
|
|
223
|
+
editor.setCurrentTool('geo')
|
|
224
|
+
editor.pointerDown(50, 50)
|
|
225
|
+
editor.undo()
|
|
226
|
+
editor.expectToBeIn('geo.idle')
|
|
227
|
+
expect(editor.getCurrentPageShapes().length).toBe(0)
|
|
228
|
+
})
|
|
212
229
|
})
|
|
213
230
|
|
|
214
231
|
describe('When in the resizing state while creating a geo shape', () => {
|
|
@@ -229,6 +246,17 @@ describe('When in the resizing state while creating a geo shape', () => {
|
|
|
229
246
|
editor.expectToBeIn('select.idle')
|
|
230
247
|
})
|
|
231
248
|
|
|
249
|
+
it('Removes the pending geo shape when another tool is selected mid-drag', () => {
|
|
250
|
+
editor.setCurrentTool('geo')
|
|
251
|
+
editor.pointerDown(50, 50)
|
|
252
|
+
editor.pointerMove(100, 100)
|
|
253
|
+
editor.expectToBeIn('select.resizing')
|
|
254
|
+
expect(editor.getCurrentPageShapes().length).toBe(1)
|
|
255
|
+
editor.setCurrentTool('draw')
|
|
256
|
+
editor.expectToBeIn('draw.idle')
|
|
257
|
+
expect(editor.getCurrentPageShapes().length).toBe(0)
|
|
258
|
+
})
|
|
259
|
+
|
|
232
260
|
it('Returns to geo.idle on complete if tool lock is enabled', () => {
|
|
233
261
|
editor.updateInstanceState({ isToolLocked: true })
|
|
234
262
|
editor.setCurrentTool('geo')
|
|
@@ -447,7 +447,9 @@ function getXBoxPath(
|
|
|
447
447
|
geometry: { isInternal: true, isFilled: false },
|
|
448
448
|
})
|
|
449
449
|
.lineTo(clamp(w - sw * inset, 0, w), clamp(h - sw * inset, 0, h))
|
|
450
|
-
.moveTo(clamp(w - sw * inset, 0, w), clamp(sw * inset, 0, h)
|
|
450
|
+
.moveTo(clamp(w - sw * inset, 0, w), clamp(sw * inset, 0, h), {
|
|
451
|
+
geometry: { isInternal: true, isFilled: false },
|
|
452
|
+
})
|
|
451
453
|
.lineTo(clamp(sw * inset, 0, w), clamp(h - sw * inset, 0, h))
|
|
452
454
|
|
|
453
455
|
return path
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { StateNode, TLKeyboardEventInfo, TLPointerEventInfo } from '@tldraw/editor'
|
|
2
|
-
import {
|
|
2
|
+
import { startEditingShape } from '../../../tools/SelectTool/selectHelpers'
|
|
3
3
|
|
|
4
4
|
export class Idle extends StateNode {
|
|
5
5
|
static override id = 'idle'
|
|
@@ -16,9 +16,8 @@ export class Idle extends StateNode {
|
|
|
16
16
|
const { editor } = this
|
|
17
17
|
if (info.key === 'Enter') {
|
|
18
18
|
const onlySelectedShape = editor.getOnlySelectedShape()
|
|
19
|
-
if (editor.canEditShape(onlySelectedShape))
|
|
20
|
-
|
|
21
|
-
}
|
|
19
|
+
if (!editor.canEditShape(onlySelectedShape)) return
|
|
20
|
+
startEditingShape(editor, onlySelectedShape, { selectAll: true })
|
|
22
21
|
}
|
|
23
22
|
}
|
|
24
23
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { assert } from '@tldraw/editor'
|
|
1
|
+
import { PageRecordType, assert } from '@tldraw/editor'
|
|
2
2
|
import { TestEditor } from '../../../test/TestEditor'
|
|
3
3
|
|
|
4
4
|
let editor: TestEditor
|
|
@@ -203,6 +203,35 @@ describe('When extending the line with the shift-key in tool-lock mode', () => {
|
|
|
203
203
|
assert(editor.isShapeOfType(line, 'line'))
|
|
204
204
|
expect(Object.keys(line.props.points).length).toBe(3)
|
|
205
205
|
})
|
|
206
|
+
|
|
207
|
+
it('does not extend a line on another page after changing page', () => {
|
|
208
|
+
// regression for #10400: shift-clicking after a page change added a point
|
|
209
|
+
// to the line on the old page instead of starting a new line
|
|
210
|
+
editor.updateInstanceState({ isToolLocked: true })
|
|
211
|
+
editor
|
|
212
|
+
.setCurrentTool('line')
|
|
213
|
+
.pointerDown(0, 0, { target: 'canvas' })
|
|
214
|
+
.pointerMove(10, 10)
|
|
215
|
+
.pointerUp(10, 10)
|
|
216
|
+
|
|
217
|
+
const lineOnPage1 = editor.getCurrentPageShapes()[0]
|
|
218
|
+
assert(editor.isShapeOfType(lineOnPage1, 'line'))
|
|
219
|
+
expect(Object.keys(lineOnPage1.props.points).length).toBe(2)
|
|
220
|
+
|
|
221
|
+
const page2Id = PageRecordType.createId()
|
|
222
|
+
editor.createPage({ id: page2Id, name: 'Page 2' })
|
|
223
|
+
editor.setCurrentPage(page2Id)
|
|
224
|
+
editor.keyDown('Shift').pointerDown(20, 10, { target: 'canvas' }).pointerUp(20, 10)
|
|
225
|
+
|
|
226
|
+
expect(editor.getCurrentPageShapes()).toHaveLength(1)
|
|
227
|
+
const lineOnPage2 = editor.getCurrentPageShapes()[0]
|
|
228
|
+
assert(editor.isShapeOfType(lineOnPage2, 'line'))
|
|
229
|
+
expect(lineOnPage2.id).not.toBe(lineOnPage1.id)
|
|
230
|
+
expect(editor.isShapeInPage(lineOnPage2, page2Id)).toBe(true)
|
|
231
|
+
|
|
232
|
+
// The line on the first page is untouched
|
|
233
|
+
expect(editor.getShape(lineOnPage1.id)).toEqual(lineOnPage1)
|
|
234
|
+
})
|
|
206
235
|
})
|
|
207
236
|
|
|
208
237
|
describe('minimum bend distance for shift-clicked handles is measured in screen space', () => {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import {
|
|
2
|
-
Mat,
|
|
3
2
|
StateNode,
|
|
4
3
|
TLLineShape,
|
|
5
4
|
TLShapeId,
|
|
@@ -31,7 +30,9 @@ export class Pointing extends StateNode {
|
|
|
31
30
|
// Previously created line shape that we might be extending
|
|
32
31
|
const shape = info.shapeId && this.editor.getShape<TLLineShape>(info.shapeId)
|
|
33
32
|
|
|
34
|
-
|
|
33
|
+
// The shape id carried through idle survives a page change; extending it from
|
|
34
|
+
// another page would silently add a point to content the user can't see (#10400)
|
|
35
|
+
if (shape && inputs.getShiftKey() && this.editor.isShapeInPage(shape)) {
|
|
35
36
|
// Extending a previous shape
|
|
36
37
|
this.markId = this.editor.markHistoryStoppingPoint(`creating_line:${shape.id}`)
|
|
37
38
|
this.shape = shape
|
|
@@ -43,12 +44,10 @@ export class Pointing extends StateNode {
|
|
|
43
44
|
const endHandle = vertexHandles[vertexHandles.length - 1]
|
|
44
45
|
const prevEndHandle = vertexHandles[vertexHandles.length - 2]
|
|
45
46
|
|
|
46
|
-
const shapePagePoint = Mat.applyToPoint(
|
|
47
|
-
this.editor.getShapeParentTransform(this.shape)!,
|
|
48
|
-
new Vec(this.shape.x, this.shape.y)
|
|
49
|
-
)
|
|
50
47
|
// nudge the point slightly to avoid zero-length lines
|
|
51
|
-
const nudgedPoint =
|
|
48
|
+
const nudgedPoint = this.editor
|
|
49
|
+
.getPointInShapeSpace(this.shape, currentPagePoint)
|
|
50
|
+
.addXY(0.1, 0.1)
|
|
52
51
|
const nextPoint = maybeSnapToGrid(nudgedPoint, this.editor)
|
|
53
52
|
const points = structuredClone(this.shape.props.points)
|
|
54
53
|
|
|
@@ -143,6 +143,33 @@ describe('When in the pointing state', () => {
|
|
|
143
143
|
editor.expectToBeIn('note.idle')
|
|
144
144
|
expect(editor.getCurrentPageShapes().length).toBe(1)
|
|
145
145
|
})
|
|
146
|
+
|
|
147
|
+
it('Leaves nothing behind on complete before the pointer is released', () => {
|
|
148
|
+
editor.setCurrentTool('note')
|
|
149
|
+
editor.pointerDown(50, 50)
|
|
150
|
+
editor.expectToBeIn('note.pointing')
|
|
151
|
+
editor.complete()
|
|
152
|
+
editor.expectToBeIn('note.idle')
|
|
153
|
+
expect(editor.getCurrentPageShapes().length).toBe(0)
|
|
154
|
+
})
|
|
155
|
+
|
|
156
|
+
it('Does not create a note when undo is pressed mid-press', () => {
|
|
157
|
+
editor.setCurrentTool('note')
|
|
158
|
+
editor.pointerDown(50, 50)
|
|
159
|
+
editor.undo()
|
|
160
|
+
editor.expectToBeIn('note.idle')
|
|
161
|
+
expect(editor.getCurrentPageShapes().length).toBe(0)
|
|
162
|
+
})
|
|
163
|
+
|
|
164
|
+
it('Leaves nothing behind on complete before the pointer is released on a coarse pointer', () => {
|
|
165
|
+
editor.updateInstanceState({ isCoarsePointer: true })
|
|
166
|
+
editor.setCurrentTool('note')
|
|
167
|
+
editor.pointerDown(50, 50)
|
|
168
|
+
editor.expectToBeIn('note.pointing')
|
|
169
|
+
editor.complete()
|
|
170
|
+
editor.expectToBeIn('note.idle')
|
|
171
|
+
expect(editor.getCurrentPageShapes().length).toBe(0)
|
|
172
|
+
})
|
|
146
173
|
})
|
|
147
174
|
|
|
148
175
|
describe('Adjacent note position helpers (sticky pits)', () => {
|
|
@@ -204,6 +231,24 @@ describe('Adjacent note position helpers (sticky pits)', () => {
|
|
|
204
231
|
})
|
|
205
232
|
})
|
|
206
233
|
|
|
234
|
+
it('Falls into a pit beside the note the tool just created when tool lock is on', () => {
|
|
235
|
+
editor.updateInstanceState({ isToolLocked: true })
|
|
236
|
+
editor.setCurrentTool('note').pointerMove(100, 100).click()
|
|
237
|
+
const first = editor.getLastCreatedShape()
|
|
238
|
+
expect(first).toMatchObject({ type: 'note', x: 0, y: 0 })
|
|
239
|
+
expect(editor.getSelectedShapeIds()).toEqual([first.id])
|
|
240
|
+
|
|
241
|
+
editor.pointerMove(324, 104).click()
|
|
242
|
+
const second = editor.getLastCreatedShape()
|
|
243
|
+
expect(second.id).not.toBe(first.id)
|
|
244
|
+
editor.expectShapeToMatch({
|
|
245
|
+
...second,
|
|
246
|
+
// in the pit to the right of the first note
|
|
247
|
+
x: 220,
|
|
248
|
+
y: 0,
|
|
249
|
+
})
|
|
250
|
+
})
|
|
251
|
+
|
|
207
252
|
it('Does not create a new sticky note in a sticky pit if a note is already there', () => {
|
|
208
253
|
editor
|
|
209
254
|
.createShape({ type: 'note', x: 0, y: 0 })
|
|
@@ -308,13 +308,16 @@ export class NoteShapeUtil extends ShapeUtil<TLNoteShape> {
|
|
|
308
308
|
style: 'normal',
|
|
309
309
|
})
|
|
310
310
|
|
|
311
|
+
const themeFaces = getThemeFontFaces(this.editor.getCurrentTheme(), shape.props.font)
|
|
312
|
+
const textFaces = themeFaces ? [...themeFaces, ...fonts] : fonts
|
|
313
|
+
|
|
314
|
+
// The attribution line renders in the default sans face regardless of the note's font.
|
|
315
|
+
// Theme faces come first so an attributed note keeps its custom font (export included).
|
|
311
316
|
if (shape.props.textLastEditedBy && !isEmptyRichText(shape.props.richText)) {
|
|
312
|
-
return [...
|
|
317
|
+
return [...textFaces, DefaultFontFaces.tldraw_sans.normal.normal]
|
|
313
318
|
}
|
|
314
|
-
const themeFaces = getThemeFontFaces(this.editor.getCurrentTheme(), shape.props.font)
|
|
315
|
-
if (themeFaces) return [...themeFaces, ...fonts]
|
|
316
319
|
|
|
317
|
-
return
|
|
320
|
+
return textFaces.length ? textFaces : EMPTY_ARRAY
|
|
318
321
|
}
|
|
319
322
|
|
|
320
323
|
component(shape: TLNoteShape) {
|