tldraw 3.16.0-canary.ffdf566dd0a8 → 3.16.0-internal.51e99e128bd4
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 +173 -5
- package/dist-cjs/index.js +12 -1
- package/dist-cjs/index.js.map +2 -2
- package/dist-cjs/lib/canvas/TldrawScribble.js +1 -1
- package/dist-cjs/lib/canvas/TldrawScribble.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js +3 -3
- package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/elbow/ElbowArrowDebug.js +3 -3
- package/dist-cjs/lib/shapes/arrow/elbow/ElbowArrowDebug.js.map +1 -1
- package/dist-cjs/lib/shapes/draw/DrawShapeUtil.js +3 -3
- package/dist-cjs/lib/shapes/draw/DrawShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/embed/EmbedShapeUtil.js +1 -1
- package/dist-cjs/lib/shapes/embed/EmbedShapeUtil.js.map +1 -1
- package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js +12 -12
- package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/frame/components/FrameHeading.js +1 -1
- package/dist-cjs/lib/shapes/frame/components/FrameHeading.js.map +2 -2
- package/dist-cjs/lib/shapes/geo/GeoShapeUtil.js +2 -2
- package/dist-cjs/lib/shapes/geo/GeoShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/geo/components/GeoShapeBody.js +2 -1
- package/dist-cjs/lib/shapes/geo/components/GeoShapeBody.js.map +2 -2
- package/dist-cjs/lib/shapes/highlight/HighlightShapeUtil.js +5 -1
- package/dist-cjs/lib/shapes/highlight/HighlightShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/image/ImageShapeUtil.js +3 -3
- package/dist-cjs/lib/shapes/image/ImageShapeUtil.js.map +1 -1
- package/dist-cjs/lib/shapes/line/LineShapeUtil.js +5 -1
- package/dist-cjs/lib/shapes/line/LineShapeUtil.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/shared/ShapeFill.js +4 -4
- package/dist-cjs/lib/shapes/shared/ShapeFill.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/freehand/svg.js.map +2 -2
- package/dist-cjs/lib/shapes/text/TextShapeUtil.js +2 -2
- package/dist-cjs/lib/shapes/text/TextShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/video/VideoShapeUtil.js +3 -3
- package/dist-cjs/lib/shapes/video/VideoShapeUtil.js.map +1 -1
- package/dist-cjs/lib/tools/EraserTool/childStates/Erasing.js +25 -1
- package/dist-cjs/lib/tools/EraserTool/childStates/Erasing.js.map +2 -2
- package/dist-cjs/lib/tools/EraserTool/childStates/Pointing.js +12 -0
- package/dist-cjs/lib/tools/EraserTool/childStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js.map +2 -2
- package/dist-cjs/lib/ui/TldrawUi.js +14 -0
- package/dist-cjs/lib/ui/TldrawUi.js.map +3 -3
- package/dist-cjs/lib/ui/assetUrls.js +13 -10
- package/dist-cjs/lib/ui/assetUrls.js.map +2 -2
- package/dist-cjs/lib/ui/components/ActionsMenu/DefaultActionsMenu.js +12 -3
- package/dist-cjs/lib/ui/components/ActionsMenu/DefaultActionsMenu.js.map +2 -2
- package/dist-cjs/lib/ui/components/DefaultMenuPanel.js +3 -2
- package/dist-cjs/lib/ui/components/DefaultMenuPanel.js.map +2 -2
- package/dist-cjs/lib/ui/components/Minimap/MinimapManager.js +4 -4
- package/dist-cjs/lib/ui/components/Minimap/MinimapManager.js.map +2 -2
- package/dist-cjs/lib/ui/components/MobileStylePanel.js +5 -3
- package/dist-cjs/lib/ui/components/MobileStylePanel.js.map +2 -2
- package/dist-cjs/lib/ui/components/NavigationPanel/DefaultNavigationPanel.js +1 -1
- package/dist-cjs/lib/ui/components/NavigationPanel/DefaultNavigationPanel.js.map +2 -2
- package/dist-cjs/lib/ui/components/PageMenu/DefaultPageMenu.js +2 -1
- package/dist-cjs/lib/ui/components/PageMenu/DefaultPageMenu.js.map +2 -2
- package/dist-cjs/lib/ui/components/SharePanel/PeopleMenuItem.js +3 -2
- package/dist-cjs/lib/ui/components/SharePanel/PeopleMenuItem.js.map +2 -2
- package/dist-cjs/lib/ui/components/SharePanel/UserPresenceColorPicker.js +2 -2
- package/dist-cjs/lib/ui/components/SharePanel/UserPresenceColorPicker.js.map +2 -2
- package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanelContent.js +14 -14
- package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanelContent.js.map +2 -2
- package/dist-cjs/lib/ui/components/StylePanel/DoubleDropdownPicker.js +3 -3
- package/dist-cjs/lib/ui/components/StylePanel/DoubleDropdownPicker.js.map +2 -2
- package/dist-cjs/lib/ui/components/StylePanel/DropdownPicker.js +26 -25
- package/dist-cjs/lib/ui/components/StylePanel/DropdownPicker.js.map +3 -3
- package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbarContent.js +1 -1
- package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbarContent.js.map +2 -2
- package/dist-cjs/lib/ui/components/Toolbar/DefaultToolbar.js +66 -21
- package/dist-cjs/lib/ui/components/Toolbar/DefaultToolbar.js.map +3 -3
- package/dist-cjs/lib/ui/components/Toolbar/OverflowingToolbar.js +189 -80
- package/dist-cjs/lib/ui/components/Toolbar/OverflowingToolbar.js.map +3 -3
- package/dist-cjs/lib/ui/components/Toolbar/ToggleToolLockedButton.js +2 -2
- package/dist-cjs/lib/ui/components/Toolbar/ToggleToolLockedButton.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiButtonPicker.js +5 -16
- package/dist-cjs/lib/ui/components/primitives/TldrawUiButtonPicker.js.map +3 -3
- package/dist-cjs/lib/ui/components/primitives/TldrawUiContextualToolbar.js +1 -1
- package/dist-cjs/lib/ui/components/primitives/TldrawUiContextualToolbar.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiPopover.js +3 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiPopover.js.map +3 -3
- package/dist-cjs/lib/ui/components/primitives/TldrawUiToolbar.js +19 -4
- package/dist-cjs/lib/ui/components/primitives/TldrawUiToolbar.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js +153 -152
- package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/layout.js +76 -0
- package/dist-cjs/lib/ui/components/primitives/layout.js.map +7 -0
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuContext.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuGroup.js +25 -12
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuGroup.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js +154 -20
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js.map +2 -2
- package/dist-cjs/lib/ui/context/events.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/useTools.js +94 -9
- package/dist-cjs/lib/ui/hooks/useTools.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 +173 -5
- package/dist-esm/index.mjs +19 -1
- package/dist-esm/index.mjs.map +2 -2
- package/dist-esm/lib/canvas/TldrawScribble.mjs +1 -1
- package/dist-esm/lib/canvas/TldrawScribble.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs +4 -3
- package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/elbow/ElbowArrowDebug.mjs +3 -3
- package/dist-esm/lib/shapes/arrow/elbow/ElbowArrowDebug.mjs.map +1 -1
- package/dist-esm/lib/shapes/draw/DrawShapeUtil.mjs +4 -3
- package/dist-esm/lib/shapes/draw/DrawShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/embed/EmbedShapeUtil.mjs +1 -1
- package/dist-esm/lib/shapes/embed/EmbedShapeUtil.mjs.map +1 -1
- package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs +13 -12
- package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/frame/components/FrameHeading.mjs +1 -1
- package/dist-esm/lib/shapes/frame/components/FrameHeading.mjs.map +2 -2
- package/dist-esm/lib/shapes/geo/GeoShapeUtil.mjs +3 -2
- package/dist-esm/lib/shapes/geo/GeoShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/geo/components/GeoShapeBody.mjs +2 -1
- package/dist-esm/lib/shapes/geo/components/GeoShapeBody.mjs.map +2 -2
- package/dist-esm/lib/shapes/highlight/HighlightShapeUtil.mjs +6 -1
- package/dist-esm/lib/shapes/highlight/HighlightShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/image/ImageShapeUtil.mjs +3 -3
- package/dist-esm/lib/shapes/image/ImageShapeUtil.mjs.map +1 -1
- package/dist-esm/lib/shapes/line/LineShapeUtil.mjs +6 -1
- package/dist-esm/lib/shapes/line/LineShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs +5 -4
- package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/ShapeFill.mjs +5 -4
- package/dist-esm/lib/shapes/shared/ShapeFill.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/freehand/svg.mjs.map +2 -2
- package/dist-esm/lib/shapes/text/TextShapeUtil.mjs +3 -2
- package/dist-esm/lib/shapes/text/TextShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/video/VideoShapeUtil.mjs +3 -3
- package/dist-esm/lib/shapes/video/VideoShapeUtil.mjs.map +1 -1
- package/dist-esm/lib/tools/EraserTool/childStates/Erasing.mjs +26 -1
- package/dist-esm/lib/tools/EraserTool/childStates/Erasing.mjs.map +2 -2
- package/dist-esm/lib/tools/EraserTool/childStates/Pointing.mjs +13 -0
- package/dist-esm/lib/tools/EraserTool/childStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs.map +2 -2
- package/dist-esm/lib/ui/TldrawUi.mjs +16 -2
- package/dist-esm/lib/ui/TldrawUi.mjs.map +3 -3
- package/dist-esm/lib/ui/assetUrls.mjs +13 -10
- package/dist-esm/lib/ui/assetUrls.mjs.map +2 -2
- package/dist-esm/lib/ui/components/ActionsMenu/DefaultActionsMenu.mjs +12 -3
- package/dist-esm/lib/ui/components/ActionsMenu/DefaultActionsMenu.mjs.map +2 -2
- package/dist-esm/lib/ui/components/DefaultMenuPanel.mjs +3 -2
- package/dist-esm/lib/ui/components/DefaultMenuPanel.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Minimap/MinimapManager.mjs +4 -4
- package/dist-esm/lib/ui/components/Minimap/MinimapManager.mjs.map +2 -2
- package/dist-esm/lib/ui/components/MobileStylePanel.mjs +6 -3
- package/dist-esm/lib/ui/components/MobileStylePanel.mjs.map +2 -2
- package/dist-esm/lib/ui/components/NavigationPanel/DefaultNavigationPanel.mjs +1 -1
- package/dist-esm/lib/ui/components/NavigationPanel/DefaultNavigationPanel.mjs.map +2 -2
- package/dist-esm/lib/ui/components/PageMenu/DefaultPageMenu.mjs +2 -1
- package/dist-esm/lib/ui/components/PageMenu/DefaultPageMenu.mjs.map +2 -2
- package/dist-esm/lib/ui/components/SharePanel/PeopleMenuItem.mjs +3 -2
- package/dist-esm/lib/ui/components/SharePanel/PeopleMenuItem.mjs.map +2 -2
- package/dist-esm/lib/ui/components/SharePanel/UserPresenceColorPicker.mjs +2 -2
- package/dist-esm/lib/ui/components/SharePanel/UserPresenceColorPicker.mjs.map +2 -2
- package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanelContent.mjs +14 -14
- package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanelContent.mjs.map +2 -2
- package/dist-esm/lib/ui/components/StylePanel/DoubleDropdownPicker.mjs +3 -3
- package/dist-esm/lib/ui/components/StylePanel/DoubleDropdownPicker.mjs.map +2 -2
- package/dist-esm/lib/ui/components/StylePanel/DropdownPicker.mjs +26 -25
- package/dist-esm/lib/ui/components/StylePanel/DropdownPicker.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbarContent.mjs +1 -1
- package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbarContent.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Toolbar/DefaultToolbar.mjs +56 -21
- package/dist-esm/lib/ui/components/Toolbar/DefaultToolbar.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Toolbar/OverflowingToolbar.mjs +192 -81
- package/dist-esm/lib/ui/components/Toolbar/OverflowingToolbar.mjs.map +3 -3
- package/dist-esm/lib/ui/components/Toolbar/ToggleToolLockedButton.mjs +2 -2
- package/dist-esm/lib/ui/components/Toolbar/ToggleToolLockedButton.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiButtonPicker.mjs +6 -6
- package/dist-esm/lib/ui/components/primitives/TldrawUiButtonPicker.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiContextualToolbar.mjs +1 -1
- package/dist-esm/lib/ui/components/primitives/TldrawUiContextualToolbar.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiPopover.mjs +3 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiPopover.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiToolbar.mjs +19 -4
- package/dist-esm/lib/ui/components/primitives/TldrawUiToolbar.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs +162 -154
- package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/layout.mjs +46 -0
- package/dist-esm/lib/ui/components/primitives/layout.mjs.map +7 -0
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuContext.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuGroup.mjs +25 -12
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuGroup.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs +162 -22
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs.map +2 -2
- package/dist-esm/lib/ui/context/events.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/useTools.mjs +102 -10
- package/dist-esm/lib/ui/hooks/useTools.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 +11 -34
- package/src/index.ts +15 -0
- package/src/lib/canvas/TldrawScribble.tsx +1 -1
- package/src/lib/shapes/arrow/ArrowShapeOptions.test.ts +2 -1
- package/src/lib/shapes/arrow/ArrowShapeTool.test.ts +4 -3
- package/src/lib/shapes/arrow/ArrowShapeUtil.test.ts +7 -6
- package/src/lib/shapes/arrow/ArrowShapeUtil.tsx +4 -3
- package/src/lib/shapes/arrow/elbow/ElbowArrowDebug.tsx +3 -3
- package/src/lib/shapes/draw/DrawShapeTool.test.ts +0 -5
- package/src/lib/shapes/draw/DrawShapeUtil.tsx +4 -3
- package/src/lib/shapes/embed/EmbedShapeUtil.tsx +1 -1
- package/src/lib/shapes/frame/FrameShapeUtil.tsx +21 -14
- package/src/lib/shapes/frame/components/FrameHeading.tsx +1 -1
- package/src/lib/shapes/geo/GeoShapeUtil.tsx +3 -2
- package/src/lib/shapes/geo/components/GeoShapeBody.tsx +2 -2
- package/src/lib/shapes/highlight/HighlightShapeUtil.tsx +7 -1
- package/src/lib/shapes/image/ImageShapeUtil.tsx +3 -3
- package/src/lib/shapes/line/LineShapeUtil.test.tsx +4 -3
- package/src/lib/shapes/line/LineShapeUtil.tsx +6 -1
- package/src/lib/shapes/line/__snapshots__/LineShapeUtil.test.tsx.snap +2 -2
- package/src/lib/shapes/note/NoteShapeUtil.tsx +9 -4
- package/src/lib/shapes/shared/ShapeFill.tsx +5 -4
- package/src/lib/shapes/shared/freehand/svg.ts +2 -0
- package/src/lib/shapes/text/TextShapeTool.test.ts +6 -5
- package/src/lib/shapes/text/TextShapeUtil.tsx +3 -2
- package/src/lib/shapes/video/VideoShapeUtil.tsx +3 -3
- package/src/lib/tools/EraserTool/childStates/Erasing.ts +34 -1
- package/src/lib/tools/EraserTool/childStates/Pointing.ts +20 -0
- package/src/lib/tools/SelectTool/childStates/Translating.ts +0 -1
- package/src/lib/ui/TldrawUi.tsx +17 -2
- package/src/lib/ui/assetUrls.ts +13 -10
- package/src/lib/ui/components/ActionsMenu/DefaultActionsMenu.tsx +15 -3
- package/src/lib/ui/components/DefaultMenuPanel.tsx +4 -3
- package/src/lib/ui/components/Minimap/MinimapManager.ts +4 -4
- package/src/lib/ui/components/MobileStylePanel.tsx +9 -6
- package/src/lib/ui/components/NavigationPanel/DefaultNavigationPanel.tsx +1 -1
- package/src/lib/ui/components/PageMenu/DefaultPageMenu.tsx +3 -2
- package/src/lib/ui/components/SharePanel/PeopleMenuItem.tsx +4 -3
- package/src/lib/ui/components/SharePanel/UserPresenceColorPicker.tsx +3 -3
- package/src/lib/ui/components/StylePanel/DefaultStylePanelContent.tsx +39 -43
- package/src/lib/ui/components/StylePanel/DoubleDropdownPicker.tsx +3 -3
- package/src/lib/ui/components/StylePanel/DropdownPicker.tsx +7 -6
- package/src/lib/ui/components/Toolbar/DefaultImageToolbarContent.tsx +1 -1
- package/src/lib/ui/components/Toolbar/DefaultToolbar.tsx +55 -23
- package/src/lib/ui/components/Toolbar/OverflowingToolbar.tsx +212 -61
- package/src/lib/ui/components/Toolbar/ToggleToolLockedButton.tsx +2 -2
- package/src/lib/ui/components/primitives/TldrawUiButtonPicker.tsx +40 -37
- package/src/lib/ui/components/primitives/TldrawUiContextualToolbar.tsx +1 -1
- package/src/lib/ui/components/primitives/TldrawUiPopover.tsx +4 -2
- package/src/lib/ui/components/primitives/TldrawUiToolbar.tsx +32 -9
- package/src/lib/ui/components/primitives/TldrawUiTooltip.tsx +186 -172
- package/src/lib/ui/components/primitives/layout.tsx +107 -0
- package/src/lib/ui/components/primitives/menus/TldrawUiMenuContext.tsx +0 -1
- package/src/lib/ui/components/primitives/menus/TldrawUiMenuGroup.tsx +29 -16
- package/src/lib/ui/components/primitives/menus/TldrawUiMenuItem.tsx +221 -19
- package/src/lib/ui/context/events.tsx +1 -0
- package/src/lib/ui/hooks/useTools.tsx +140 -10
- package/src/lib/ui/version.ts +3 -3
- package/src/lib/ui.css +363 -305
- package/src/lib/utils/excalidraw/__snapshots__/putExcalidrawContent.test.tsx.snap +5 -5
- package/src/lib/utils/tldr/__snapshots__/buildFromV1Document.test.ts.snap +4 -4
- package/src/test/A11y.test.tsx +3 -2
- package/src/test/ClickManager.test.ts +7 -6
- package/src/test/Editor.test.tsx +20 -19
- package/src/test/EraserTool.test.ts +184 -13
- package/src/test/HandTool.test.ts +10 -9
- package/src/test/HighlightShape.test.ts +2 -1
- package/src/test/SelectTool.test.ts +3 -2
- package/src/test/TLUserPreferences.test.ts +4 -3
- package/src/test/TestEditor.ts +13 -15
- package/src/test/TldrawEditor.test.tsx +11 -10
- package/src/test/ZoomTool.test.ts +7 -6
- package/src/test/__snapshots__/drawing.test.ts.snap +2 -2
- package/src/test/__snapshots__/groups.test.tsx.snap +6 -6
- package/src/test/__snapshots__/resizing.test.ts.snap +2 -2
- package/src/test/arrows-megabus.test.tsx +5 -4
- package/src/test/bindings.test.tsx +24 -37
- package/src/test/bookmark-shapes.test.ts +1 -8
- package/src/test/commands/__snapshots__/getSvgString.test.ts.snap +23 -7
- package/src/test/commands/__snapshots__/packShapes.test.ts.snap +8 -8
- package/src/test/commands/__snapshots__/zoomToFit.test.ts.snap +2 -2
- package/src/test/commands/alignShapes.test.tsx +25 -24
- package/src/test/commands/animationSpeed.test.ts +2 -1
- package/src/test/commands/centerOnPoint.test.ts +3 -2
- package/src/test/commands/clipboard.test.ts +3 -2
- package/src/test/commands/createShapes.test.ts +2 -1
- package/src/test/commands/deleteShapes.test.ts +2 -1
- package/src/test/commands/distributeShapes.test.tsx +11 -10
- package/src/test/commands/getSvgString.test.ts +2 -1
- package/src/test/commands/packShapes.test.ts +5 -4
- package/src/test/commands/resizeShape.test.ts +2 -1
- package/src/test/commands/rotateShapes.test.ts +7 -6
- package/src/test/commands/setCamera.test.ts +4 -3
- package/src/test/commands/setCurrentPage.test.ts +3 -2
- package/src/test/commands/stackShapes.test.ts +11 -10
- package/src/test/commands/stretch.test.tsx +13 -12
- package/src/test/createDeepLink.test.tsx +2 -1
- package/src/test/cropping.test.ts +3 -2
- package/src/test/drawing.test.ts +2 -1
- package/src/test/flipShapes.test.ts +4 -3
- package/src/test/frames.test.ts +25 -24
- package/src/test/getCulledShapes.test.tsx +3 -2
- package/src/test/groups.test.tsx +1 -1
- package/src/test/handleDeepLink.test.tsx +2 -1
- package/src/test/maxShapes.test.ts +3 -2
- package/src/test/modifiers.test.ts +5 -4
- package/src/test/navigation.test.ts +12 -11
- package/src/test/panning.test.ts +2 -1
- package/src/test/perf/perf.test.ts +2 -1
- package/src/test/registerDeepLinkListener.test.tsx +10 -9
- package/src/test/resizing.test.ts +39 -38
- package/src/test/select.test.tsx +4 -3
- package/src/test/selection-omnibus.test.ts +11 -10
- package/src/test/shapeutils.test.ts +4 -3
- package/src/test/translating.test.ts +9 -8
- package/tldraw.css +656 -595
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { PageRecordType, Vec, createShapeId } from '@tldraw/editor'
|
|
2
|
+
import { vi } from 'vitest'
|
|
2
3
|
import { TestEditor } from './TestEditor'
|
|
3
4
|
import { TL } from './test-jsx'
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
vi.useFakeTimers()
|
|
6
7
|
|
|
7
8
|
let editor: TestEditor
|
|
8
9
|
|
|
@@ -20,20 +21,20 @@ beforeEach(() => {
|
|
|
20
21
|
test('it creates a listener that updates the current url', async () => {
|
|
21
22
|
const unlisten = editor.registerDeepLinkListener()
|
|
22
23
|
|
|
23
|
-
|
|
24
|
+
vi.advanceTimersByTime(1000)
|
|
24
25
|
expect(window.location.href).toMatchInlineSnapshot(`"http://localhost/test?d=v0.0.1080.720.page"`)
|
|
25
26
|
|
|
26
27
|
const pageId = PageRecordType.createId('foo')
|
|
27
28
|
editor.createPage({ id: pageId })
|
|
28
29
|
editor.setCurrentPage(pageId)
|
|
29
30
|
|
|
30
|
-
|
|
31
|
+
vi.advanceTimersByTime(1000)
|
|
31
32
|
|
|
32
33
|
expect(window.location.href).toMatchInlineSnapshot(`"http://localhost/test?d=v0.0.1080.720.foo"`)
|
|
33
34
|
|
|
34
35
|
editor.pan({ x: 100, y: 100 })
|
|
35
36
|
|
|
36
|
-
|
|
37
|
+
vi.advanceTimersByTime(1000)
|
|
37
38
|
|
|
38
39
|
expect(window.location.href).toMatchInlineSnapshot(
|
|
39
40
|
`"http://localhost/test?d=v-100.-100.1080.720.foo"`
|
|
@@ -43,7 +44,7 @@ test('it creates a listener that updates the current url', async () => {
|
|
|
43
44
|
|
|
44
45
|
editor.pan({ x: 500, y: 500 })
|
|
45
46
|
|
|
46
|
-
|
|
47
|
+
vi.advanceTimersByTime(1000)
|
|
47
48
|
|
|
48
49
|
expect(window.location.href).toMatchInlineSnapshot(
|
|
49
50
|
`"http://localhost/test?d=v-100.-100.1080.720.foo"`
|
|
@@ -75,7 +76,7 @@ test('it allows specifying a page target', async () => {
|
|
|
75
76
|
param: 'foo',
|
|
76
77
|
})
|
|
77
78
|
|
|
78
|
-
|
|
79
|
+
vi.advanceTimersByTime(1000)
|
|
79
80
|
|
|
80
81
|
// no shapes yet
|
|
81
82
|
expect(window.location.href).toMatchInlineSnapshot(`"http://localhost/test?foo=ppage"`)
|
|
@@ -87,19 +88,19 @@ test('it allows specifying a page target', async () => {
|
|
|
87
88
|
<TL.geo id={boxB} x={1000} y={1000} w={100} h={100} />,
|
|
88
89
|
])
|
|
89
90
|
|
|
90
|
-
|
|
91
|
+
vi.advanceTimersByTime(1000)
|
|
91
92
|
expect(window.location.href).toMatchInlineSnapshot(`"http://localhost/test?foo=sa"`)
|
|
92
93
|
|
|
93
94
|
editor.pan({ x: -1000, y: -1000 })
|
|
94
95
|
|
|
95
|
-
|
|
96
|
+
vi.advanceTimersByTime(1000)
|
|
96
97
|
expect(window.location.href).toMatchInlineSnapshot(`"http://localhost/test?foo=sb"`)
|
|
97
98
|
|
|
98
99
|
unlisten()
|
|
99
100
|
|
|
100
101
|
editor.pan({ x: 1000, y: 1000 })
|
|
101
102
|
|
|
102
|
-
|
|
103
|
+
vi.advanceTimersByTime(1000)
|
|
103
104
|
expect(window.location.href).toMatchInlineSnapshot(`"http://localhost/test?foo=sb"`)
|
|
104
105
|
expect(getNearestShape().id).toBe(boxA)
|
|
105
106
|
})
|
|
@@ -15,12 +15,13 @@ import {
|
|
|
15
15
|
rotateSelectionHandle,
|
|
16
16
|
toRichText,
|
|
17
17
|
} from '@tldraw/editor'
|
|
18
|
+
import { vi } from 'vitest'
|
|
18
19
|
import { NoteShapeUtil } from '../lib/shapes/note/NoteShapeUtil'
|
|
19
20
|
import { TestEditor } from './TestEditor'
|
|
20
21
|
import { getSnapLines } from './getSnapLines'
|
|
21
22
|
import { roundedBox } from './roundedBox'
|
|
22
23
|
|
|
23
|
-
|
|
24
|
+
vi.useFakeTimers()
|
|
24
25
|
|
|
25
26
|
const ORDERED_ROTATE_CORNERS: TLSelectionHandle[] = [
|
|
26
27
|
'top_left_rotate',
|
|
@@ -544,7 +545,7 @@ describe('Reisizing a selection of multiple shapes', () => {
|
|
|
544
545
|
// └──────────────────O
|
|
545
546
|
|
|
546
547
|
editor.pointerMove(15, 8, { altKey: false, shiftKey: true })
|
|
547
|
-
|
|
548
|
+
vi.advanceTimersByTime(200)
|
|
548
549
|
|
|
549
550
|
expect(roundedBox(editor.getSelectionPageBounds()!)).toMatchObject({ w: 15, h: 15 })
|
|
550
551
|
expect(roundedPageBounds(ids.boxA)).toMatchObject({ x: 0, y: 0, w: 5, h: 5 })
|
|
@@ -593,7 +594,7 @@ describe('Reisizing a selection of multiple shapes', () => {
|
|
|
593
594
|
editor.pointerDown(30, 20, { target: 'selection', handle: 'top_left_rotate' })
|
|
594
595
|
editor.pointerMove(20, 20, { shiftKey: true })
|
|
595
596
|
editor.pointerUp(20, 20, { shiftKey: false })
|
|
596
|
-
|
|
597
|
+
vi.advanceTimersByTime(200)
|
|
597
598
|
|
|
598
599
|
expect(editor.getShape(ids.boxB)!.rotation).toBeCloseTo(canonicalizeRotation(-PI / 2))
|
|
599
600
|
|
|
@@ -740,7 +741,7 @@ describe('Reisizing a selection of multiple shapes', () => {
|
|
|
740
741
|
// └──────────────────O
|
|
741
742
|
|
|
742
743
|
editor.pointerMove(15, 8, { altKey: false, shiftKey: true })
|
|
743
|
-
|
|
744
|
+
vi.advanceTimersByTime(200)
|
|
744
745
|
|
|
745
746
|
expect(roundedBox(editor.getSelectionPageBounds()!)).toMatchObject({ w: 15, h: 15 })
|
|
746
747
|
expect(roundedPageBounds(ids.boxA)).toMatchObject({ x: 0, y: 0, w: 5, h: 5 })
|
|
@@ -2364,7 +2365,7 @@ describe('snapping while resizing a shape that has been rotated by multiples of
|
|
|
2364
2365
|
.select(ids.boxX)
|
|
2365
2366
|
.pointerDown(100, 70, { target: 'selection', handle: 'top' })
|
|
2366
2367
|
.pointerMove(121, 70, { ctrlKey: true, shiftKey: false })
|
|
2367
|
-
|
|
2368
|
+
vi.advanceTimersByTime(200)
|
|
2368
2369
|
|
|
2369
2370
|
expect(editor.getShapePageBounds(ids.boxX)!).toMatchObject({
|
|
2370
2371
|
x: 40,
|
|
@@ -2432,7 +2433,7 @@ describe('snapping while resizing a shape that has been rotated by multiples of
|
|
|
2432
2433
|
.select(ids.boxX)
|
|
2433
2434
|
.pointerDown(70, 40, { target: 'selection', handle: 'bottom' })
|
|
2434
2435
|
.pointerMove(70, 18, { ctrlKey: true, shiftKey: false })
|
|
2435
|
-
|
|
2436
|
+
vi.advanceTimersByTime(200)
|
|
2436
2437
|
|
|
2437
2438
|
expect(editor.getShapePageBounds(ids.boxX)!.x).toBeCloseTo(40)
|
|
2438
2439
|
expect(editor.getShapePageBounds(ids.boxX)!.y).toBeCloseTo(20)
|
|
@@ -2564,7 +2565,7 @@ describe('snapping while resizing a shape that has been rotated by multiples of
|
|
|
2564
2565
|
.select(ids.boxX)
|
|
2565
2566
|
.pointerDown(100, 70, { target: 'selection', handle: 'right' })
|
|
2566
2567
|
.pointerMove(121, 70, { ctrlKey: true, shiftKey: false })
|
|
2567
|
-
|
|
2568
|
+
vi.advanceTimersByTime(200)
|
|
2568
2569
|
|
|
2569
2570
|
expect(editor.getShapePageBounds(ids.boxX)!.x).toBeCloseTo(40)
|
|
2570
2571
|
expect(editor.getShapePageBounds(ids.boxX)!.y).toBeCloseTo(40)
|
|
@@ -3824,36 +3825,36 @@ describe('shapes that have do not resize', () => {
|
|
|
3824
3825
|
// })
|
|
3825
3826
|
// })
|
|
3826
3827
|
|
|
3827
|
-
describe('bugs', () => {
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
})
|
|
3828
|
+
// describe('bugs', () => {
|
|
3829
|
+
// it('resizing a zero width shape', () => {
|
|
3830
|
+
// // Draw shapes can no longer have zero width / height
|
|
3831
|
+
// const shapeId = createShapeId()
|
|
3832
|
+
// app
|
|
3833
|
+
// .createShapes([
|
|
3834
|
+
// {
|
|
3835
|
+
// id: shapeId,
|
|
3836
|
+
// type: 'draw',
|
|
3837
|
+
// x: 0,
|
|
3838
|
+
// y: 0,
|
|
3839
|
+
// props: {
|
|
3840
|
+
// segments: [
|
|
3841
|
+
// {
|
|
3842
|
+
// type: 'straight',
|
|
3843
|
+
// points: [
|
|
3844
|
+
// { x: 0, y: 0 },
|
|
3845
|
+
// { x: 0, y: 100 },
|
|
3846
|
+
// ],
|
|
3847
|
+
// },
|
|
3848
|
+
// ],
|
|
3849
|
+
// },
|
|
3850
|
+
// },
|
|
3851
|
+
// ])
|
|
3852
|
+
// .select(shapeId)
|
|
3853
|
+
// expect(editor.selectionRotatedBounds!.width).toBe(0)
|
|
3854
|
+
// editor.pointerDown(0, 100, { target: 'selection', handle: 'bottom_right' }).pointerMove(10, 110)
|
|
3855
|
+
// expect(editor.selectionRotatedBounds!.width).toBe(0)
|
|
3856
|
+
// })
|
|
3857
|
+
// })
|
|
3857
3858
|
|
|
3858
3859
|
it('uses the cross cursor when create resizing', () => {
|
|
3859
3860
|
editor.setCurrentTool('geo')
|
|
@@ -3942,7 +3943,7 @@ describe('When resizing near the edges of the screen', () => {
|
|
|
3942
3943
|
handle: 'top_left',
|
|
3943
3944
|
})
|
|
3944
3945
|
.pointerMove(-1, -1) // into the edge scrolling distance
|
|
3945
|
-
|
|
3946
|
+
vi.advanceTimersByTime(1000)
|
|
3946
3947
|
const after = editor.getShape<TLGeoShape>(ids.boxA)!
|
|
3947
3948
|
expect(after.x).toBeLessThan(before.x)
|
|
3948
3949
|
expect(after.y).toBeLessThan(before.y)
|
package/src/test/select.test.tsx
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { vi } from 'vitest'
|
|
1
2
|
import { SelectTool } from '../lib/tools/SelectTool/SelectTool'
|
|
2
3
|
import { TestEditor } from './TestEditor'
|
|
3
4
|
import { TL } from './test-jsx'
|
|
@@ -28,12 +29,12 @@ describe(SelectTool, () => {
|
|
|
28
29
|
// clicking on the input will preserve selection, however you can
|
|
29
30
|
// click on the shape itself to select it as usual.
|
|
30
31
|
// clicking on the shape should not do anything
|
|
31
|
-
//
|
|
32
|
+
// vi.advanceTimersByTime(1000)
|
|
32
33
|
// editor.pointerDown(50, 50, shapeId)
|
|
33
34
|
// expect(editor.currentPageState.editingShapeId).toBe(shapeId)
|
|
34
35
|
|
|
35
36
|
// clicking outside the shape should end editing
|
|
36
|
-
|
|
37
|
+
vi.advanceTimersByTime(1000)
|
|
37
38
|
|
|
38
39
|
editor.pointerDown(150, 150).pointerUp()
|
|
39
40
|
expect(editor.getCurrentPageState().editingShapeId).toBe(null)
|
|
@@ -51,7 +52,7 @@ describe(SelectTool, () => {
|
|
|
51
52
|
expect(editor.getCurrentPageState().editingShapeId).toBe(shapeId)
|
|
52
53
|
|
|
53
54
|
// clicking outside the shape should end editing
|
|
54
|
-
|
|
55
|
+
vi.advanceTimersByTime(1000)
|
|
55
56
|
|
|
56
57
|
editor.pointerDown(150, 150).pointerUp()
|
|
57
58
|
expect(editor.getCurrentPageState().editingShapeId).toBe(null)
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
tlenv,
|
|
8
8
|
toRichText,
|
|
9
9
|
} from '@tldraw/editor'
|
|
10
|
+
import { vi } from 'vitest'
|
|
10
11
|
import { TestEditor } from './TestEditor'
|
|
11
12
|
|
|
12
13
|
let editor: TestEditor
|
|
@@ -1652,7 +1653,7 @@ describe('shift brushes to add to the selection', () => {
|
|
|
1652
1653
|
editor.keyUp('Shift')
|
|
1653
1654
|
// there's a timer here—we should keep the shift mode until the timer expires
|
|
1654
1655
|
expect(editor.getSelectedShapeIds()).toEqual([ids.box2, ids.box1])
|
|
1655
|
-
|
|
1656
|
+
vi.advanceTimersByTime(500)
|
|
1656
1657
|
// once the timer expires, we should be back in regular mode
|
|
1657
1658
|
expect(editor.getSelectedShapeIds()).toEqual([ids.box1])
|
|
1658
1659
|
editor.keyDown('Shift')
|
|
@@ -1722,7 +1723,7 @@ describe('scribble brushes to add to the selection', () => {
|
|
|
1722
1723
|
editor.pointerMove(50, 50)
|
|
1723
1724
|
expect(editor.getSelectedShapeIds()).toEqual([ids.box1, ids.box2])
|
|
1724
1725
|
editor.keyUp('Shift')
|
|
1725
|
-
|
|
1726
|
+
vi.advanceTimersByTime(500)
|
|
1726
1727
|
expect(editor.getSelectedShapeIds()).toEqual([ids.box1])
|
|
1727
1728
|
editor.keyDown('Shift')
|
|
1728
1729
|
expect(editor.getSelectedShapeIds()).toEqual([ids.box1, ids.box2])
|
|
@@ -1739,7 +1740,7 @@ describe('scribble brushes to add to the selection', () => {
|
|
|
1739
1740
|
expect(editor.getSelectedShapeIds()).toEqual([ids.box4])
|
|
1740
1741
|
editor.keyUp('Alt') // scribble
|
|
1741
1742
|
expect(editor.getSelectedShapeIds()).toEqual([ids.box4]) // still in timer
|
|
1742
|
-
|
|
1743
|
+
vi.advanceTimersByTime(1000) // let timer expire
|
|
1743
1744
|
expect(editor.getSelectedShapeIds()).toEqual([ids.box3, ids.box4]) // brushed!
|
|
1744
1745
|
editor.keyDown('Alt') // scribble
|
|
1745
1746
|
expect(editor.getSelectedShapeIds()).toEqual([ids.box4]) // back to brushed only
|
|
@@ -1824,7 +1825,7 @@ describe('When brushing close to the edges of the screen', () => {
|
|
|
1824
1825
|
editor.pointerMove(300, 300)
|
|
1825
1826
|
editor.pointerDown()
|
|
1826
1827
|
editor.pointerMove(0, 0)
|
|
1827
|
-
|
|
1828
|
+
vi.advanceTimersByTime(100)
|
|
1828
1829
|
editor.pointerUp()
|
|
1829
1830
|
const camera2 = editor.getCamera()
|
|
1830
1831
|
expect(camera2.x).toBeGreaterThan(camera1.x) // for some reason > is left
|
|
@@ -1837,7 +1838,7 @@ describe('When brushing close to the edges of the screen', () => {
|
|
|
1837
1838
|
editor.pointerMove(300, 300)
|
|
1838
1839
|
editor.pointerDown()
|
|
1839
1840
|
editor.pointerMove(100, 100)
|
|
1840
|
-
|
|
1841
|
+
vi.advanceTimersByTime(100)
|
|
1841
1842
|
editor.pointerUp()
|
|
1842
1843
|
const camera2 = editor.getCamera()
|
|
1843
1844
|
// should NOT have moved the camera by edge scrolling
|
|
@@ -1851,7 +1852,7 @@ describe('When brushing close to the edges of the screen', () => {
|
|
|
1851
1852
|
editor.pointerMove(300, 300)
|
|
1852
1853
|
editor.pointerDown()
|
|
1853
1854
|
editor.pointerMove(100, 100)
|
|
1854
|
-
|
|
1855
|
+
vi.advanceTimersByTime(100)
|
|
1855
1856
|
editor.pointerUp()
|
|
1856
1857
|
const camera4 = editor.getCamera()
|
|
1857
1858
|
// should NOT have moved the camera by edge scrolling because the edge is now "inset"
|
|
@@ -1860,7 +1861,7 @@ describe('When brushing close to the edges of the screen', () => {
|
|
|
1860
1861
|
|
|
1861
1862
|
editor.pointerDown()
|
|
1862
1863
|
editor.pointerMove(90, 90) // off the edge of the component
|
|
1863
|
-
|
|
1864
|
+
vi.advanceTimersByTime(100)
|
|
1864
1865
|
const camera5 = editor.getCamera()
|
|
1865
1866
|
// should have moved the camera by edge scrolling off the component edge
|
|
1866
1867
|
expect(camera5.x).toBeGreaterThan(camera4.x)
|
|
@@ -1882,7 +1883,7 @@ describe('When brushing close to the edges of the screen', () => {
|
|
|
1882
1883
|
editor.pointerMove(0, 0)
|
|
1883
1884
|
// still only box 1...
|
|
1884
1885
|
expect(editor.getSelectedShapeIds()).toEqual([ids.box1])
|
|
1885
|
-
|
|
1886
|
+
vi.advanceTimersByTime(100)
|
|
1886
1887
|
// ...but now viewport will have moved to select box2 as well
|
|
1887
1888
|
expect(editor.getSelectedShapeIds()).toEqual([ids.box1, ids.box2])
|
|
1888
1889
|
editor.pointerUp()
|
|
@@ -1902,7 +1903,7 @@ describe('When brushing close to the edges of the screen', () => {
|
|
|
1902
1903
|
expect(editor.getSelectedShapeIds()).toEqual([ids.box1])
|
|
1903
1904
|
editor.pointerMove(0, 0)
|
|
1904
1905
|
expect(editor.getSelectedShapeIds()).toEqual([ids.box1])
|
|
1905
|
-
|
|
1906
|
+
vi.advanceTimersByTime(100)
|
|
1906
1907
|
expect(editor.getSelectedShapeIds()).toEqual([ids.box1])
|
|
1907
1908
|
editor.pointerUp()
|
|
1908
1909
|
})
|
|
@@ -2199,7 +2200,7 @@ describe('long press', () => {
|
|
|
2199
2200
|
it('works correctly with screenbounds offset', () => {
|
|
2200
2201
|
editor.updateViewportScreenBounds(new Box(100, 100, 800, 600))
|
|
2201
2202
|
editor.pointerDown(201, 202)
|
|
2202
|
-
|
|
2203
|
+
vi.advanceTimersByTime(1000)
|
|
2203
2204
|
// without the fix added in this PR, it would have been 1, 2
|
|
2204
2205
|
expect(editor.inputs.currentScreenPoint).toMatchObject({ x: 101, y: 102 })
|
|
2205
2206
|
})
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createShapeId, TLFrameShape, TLGeoShape, TLLineShape } from '@tldraw/editor'
|
|
2
|
+
import { vi } from 'vitest'
|
|
2
3
|
import { TestEditor } from './TestEditor'
|
|
3
4
|
|
|
4
5
|
let editor: TestEditor
|
|
@@ -155,7 +156,7 @@ describe('When interacting with a shape...', () => {
|
|
|
155
156
|
it('fires double click handler event', () => {
|
|
156
157
|
const util = editor.getShapeUtil<TLGeoShape>('geo')
|
|
157
158
|
|
|
158
|
-
const fnStart =
|
|
159
|
+
const fnStart = vi.fn()
|
|
159
160
|
util.onDoubleClick = fnStart
|
|
160
161
|
|
|
161
162
|
editor.doubleClick(50, 50, ids.box2)
|
|
@@ -353,7 +354,7 @@ describe('When interacting with a shape...', () => {
|
|
|
353
354
|
it('Uses the shape utils onClick handler', () => {
|
|
354
355
|
const util = editor.getShapeUtil<TLFrameShape>('frame')
|
|
355
356
|
|
|
356
|
-
const fnClick =
|
|
357
|
+
const fnClick = vi.fn()
|
|
357
358
|
util.onClick = fnClick
|
|
358
359
|
|
|
359
360
|
editor.pointerDown(50, 50, ids.frame1)
|
|
@@ -367,7 +368,7 @@ describe('When interacting with a shape...', () => {
|
|
|
367
368
|
it('Uses the shape utils onClick handler', () => {
|
|
368
369
|
const util = editor.getShapeUtil<TLFrameShape>('frame')
|
|
369
370
|
|
|
370
|
-
const fnClick =
|
|
371
|
+
const fnClick = vi.fn((shape: any) => {
|
|
371
372
|
return {
|
|
372
373
|
...shape,
|
|
373
374
|
x: 100,
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
Vec,
|
|
12
12
|
createShapeId,
|
|
13
13
|
} from '@tldraw/editor'
|
|
14
|
+
import { vi } from 'vitest'
|
|
14
15
|
import { getArrowBindings } from '../lib/shapes/arrow/shared'
|
|
15
16
|
import { TranslatingInfo } from '../lib/tools/SelectTool/childStates/Translating'
|
|
16
17
|
import { TestEditor } from './TestEditor'
|
|
@@ -41,7 +42,7 @@ const ids = {
|
|
|
41
42
|
}
|
|
42
43
|
|
|
43
44
|
beforeEach(() => {
|
|
44
|
-
console.error =
|
|
45
|
+
console.error = vi.fn()
|
|
45
46
|
editor = new TestEditor({
|
|
46
47
|
options: {
|
|
47
48
|
adjacentShapeMargin: 20,
|
|
@@ -154,7 +155,7 @@ describe('When translating...', () => {
|
|
|
154
155
|
// We'll continue moving in the x position, but now we'll also move in the y position.
|
|
155
156
|
// The speed in the y position is smaller since we are further away from the edge.
|
|
156
157
|
.pointerMove(0, 25)
|
|
157
|
-
|
|
158
|
+
vi.advanceTimersByTime(100)
|
|
158
159
|
editor.pointerUp()
|
|
159
160
|
|
|
160
161
|
const after = editor.getShape<TLGeoShape>(ids.box1)!
|
|
@@ -254,7 +255,7 @@ describe('When cloning...', () => {
|
|
|
254
255
|
|
|
255
256
|
// Stop cloning!
|
|
256
257
|
editor.keyUp('Alt')
|
|
257
|
-
|
|
258
|
+
vi.advanceTimersByTime(500)
|
|
258
259
|
|
|
259
260
|
editor.expectShapeToMatch({ id: ids.box1, x: 20, y: 0 }) // A should be at the translated position...
|
|
260
261
|
expect(editor.getShape(newShape.id)).toBeUndefined() // And the new node should be gone!
|
|
@@ -289,7 +290,7 @@ describe('When cloning...', () => {
|
|
|
289
290
|
editor.keyUp('Alt')
|
|
290
291
|
|
|
291
292
|
// wait 500ms
|
|
292
|
-
|
|
293
|
+
vi.advanceTimersByTime(500)
|
|
293
294
|
editor
|
|
294
295
|
.expectShapeToMatch({ id: ids.box1, x: 20, y: 0 }) // A should be at the translated position...
|
|
295
296
|
.expectShapeToMatch({ id: ids.box2, x: 210, y: 190 }) // B should be at the translated position...
|
|
@@ -327,7 +328,7 @@ describe('When cloning...', () => {
|
|
|
327
328
|
// Stop cloning!
|
|
328
329
|
editor.keyUp('Alt')
|
|
329
330
|
// wait 500ms
|
|
330
|
-
|
|
331
|
+
vi.advanceTimersByTime(500)
|
|
331
332
|
|
|
332
333
|
editor.expectShapeToMatch({ id: ids.box2, x: 210, y: 190 }) // B should be at the translated position...
|
|
333
334
|
expect(editor.getShape(cloneB.id)).toBeUndefined() // And the new node A should be gone!
|
|
@@ -352,7 +353,7 @@ describe('When cloning...', () => {
|
|
|
352
353
|
expect(editor.getCurrentPageShapes().length).toBe(count1 + 3) // 2 new box and group
|
|
353
354
|
|
|
354
355
|
editor.keyUp('Alt')
|
|
355
|
-
|
|
356
|
+
vi.advanceTimersByTime(500)
|
|
356
357
|
|
|
357
358
|
expect(editor.getCurrentPageShapes().length).toBe(count1) // 2 new box and group
|
|
358
359
|
|
|
@@ -500,7 +501,7 @@ describe('snapping with single shapes', () => {
|
|
|
500
501
|
|
|
501
502
|
// release ctrl key and it unsnaps
|
|
502
503
|
editor.keyUp('Control')
|
|
503
|
-
|
|
504
|
+
vi.advanceTimersByTime(200)
|
|
504
505
|
|
|
505
506
|
expect(editor.getShape(ids.box2)!).toMatchObject({ x: 11, y: 0 })
|
|
506
507
|
|
|
@@ -2325,7 +2326,7 @@ it('preserves z-indexes when translating', () => {
|
|
|
2325
2326
|
editor.pointerDown(50, 50)
|
|
2326
2327
|
editor.pointerMove(60, 60)
|
|
2327
2328
|
|
|
2328
|
-
|
|
2329
|
+
vi.advanceTimersByTime(500)
|
|
2329
2330
|
|
|
2330
2331
|
const ordered2 = editor.getCurrentPageShapesSorted().map((s) => s.id)
|
|
2331
2332
|
expect(ordered2.indexOf(box1.id)).toBe(0)
|