tldraw 3.16.0-internal.51e99e128bd4 → 3.16.0-internal.a478398270c6
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 +23 -297
- package/dist-cjs/index.js +2 -30
- package/dist-cjs/index.js.map +2 -2
- package/dist-cjs/lib/TldrawImage.js +2 -5
- package/dist-cjs/lib/TldrawImage.js.map +3 -3
- package/dist-cjs/lib/canvas/TldrawCropHandles.js +1 -1
- package/dist-cjs/lib/canvas/TldrawCropHandles.js.map +2 -2
- package/dist-cjs/lib/canvas/TldrawHandles.js +1 -1
- package/dist-cjs/lib/canvas/TldrawHandles.js.map +2 -2
- package/dist-cjs/lib/canvas/TldrawOverlays.js +1 -1
- package/dist-cjs/lib/canvas/TldrawOverlays.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/canvas/TldrawSelectionForeground.js +271 -279
- package/dist-cjs/lib/canvas/TldrawSelectionForeground.js.map +2 -2
- package/dist-cjs/lib/defaultExternalContentHandlers.js +0 -1
- package/dist-cjs/lib/defaultExternalContentHandlers.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js +44 -27
- package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/arrowLabel.js +4 -16
- package/dist-cjs/lib/shapes/arrow/arrowLabel.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/arrowTargetState.js +1 -1
- package/dist-cjs/lib/shapes/arrow/arrowTargetState.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/arrow/toolStates/Pointing.js +0 -3
- package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/shapes/draw/DrawShapeUtil.js +6 -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 +17 -17
- 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 +1 -2
- package/dist-cjs/lib/shapes/geo/components/GeoShapeBody.js.map +2 -2
- package/dist-cjs/lib/shapes/highlight/HighlightShapeUtil.js +4 -5
- 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 -20
- package/dist-cjs/lib/shapes/line/LineShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/note/NoteShapeUtil.js +5 -6
- package/dist-cjs/lib/shapes/note/NoteShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/PathBuilder.js +3 -21
- package/dist-cjs/lib/shapes/shared/PathBuilder.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/PlainTextLabel.js +0 -1
- package/dist-cjs/lib/shapes/shared/PlainTextLabel.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/RichTextLabel.js +2 -5
- package/dist-cjs/lib/shapes/shared/RichTextLabel.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/SvgTextLabel.js +3 -4
- package/dist-cjs/lib/shapes/shared/SvgTextLabel.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/freehand/svg.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/usePrefersReducedMotion.js +1 -10
- package/dist-cjs/lib/shapes/shared/usePrefersReducedMotion.js.map +2 -2
- package/dist-cjs/lib/shapes/text/TextShapeUtil.js +13 -7
- 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/styles.js.map +2 -2
- package/dist-cjs/lib/tools/EraserTool/childStates/Erasing.js +1 -25
- package/dist-cjs/lib/tools/EraserTool/childStates/Erasing.js.map +2 -2
- package/dist-cjs/lib/tools/EraserTool/childStates/Pointing.js +0 -12
- package/dist-cjs/lib/tools/EraserTool/childStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.js +1 -7
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js +22 -43
- package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Idle.js +15 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Idle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingShape.js +0 -5
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingShape.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js +0 -8
- package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Rotating.js +0 -8
- package/dist-cjs/lib/tools/SelectTool/childStates/Rotating.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js +0 -8
- package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js.map +2 -2
- package/dist-cjs/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.js.map +2 -2
- package/dist-cjs/lib/ui/TldrawUi.js +0 -14
- package/dist-cjs/lib/ui/TldrawUi.js.map +3 -3
- package/dist-cjs/lib/ui/components/A11y.js +12 -14
- package/dist-cjs/lib/ui/components/A11y.js.map +2 -2
- package/dist-cjs/lib/ui/components/ActionsMenu/DefaultActionsMenu.js +3 -12
- package/dist-cjs/lib/ui/components/ActionsMenu/DefaultActionsMenu.js.map +2 -2
- package/dist-cjs/lib/ui/components/DefaultMenuPanel.js +2 -3
- package/dist-cjs/lib/ui/components/DefaultMenuPanel.js.map +2 -2
- package/dist-cjs/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.js +1 -51
- package/dist-cjs/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.js.map +2 -2
- package/dist-cjs/lib/ui/components/MainMenu/DefaultMainMenuContent.js +2 -3
- package/dist-cjs/lib/ui/components/MainMenu/DefaultMainMenuContent.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 +3 -5
- package/dist-cjs/lib/ui/components/MobileStylePanel.js.map +2 -2
- package/dist-cjs/lib/ui/components/NavigationPanel/DefaultNavigationPanel.js +5 -4
- package/dist-cjs/lib/ui/components/NavigationPanel/DefaultNavigationPanel.js.map +2 -2
- package/dist-cjs/lib/ui/components/PageMenu/DefaultPageMenu.js +1 -2
- package/dist-cjs/lib/ui/components/PageMenu/DefaultPageMenu.js.map +2 -2
- package/dist-cjs/lib/ui/components/SharePanel/PeopleMenuItem.js +2 -3
- 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/Spinner.js +25 -2
- package/dist-cjs/lib/ui/components/Spinner.js.map +2 -2
- package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanel.js +0 -2
- package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanel.js.map +2 -2
- package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanelContent.js +139 -171
- 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 +25 -26
- package/dist-cjs/lib/ui/components/StylePanel/DropdownPicker.js.map +3 -3
- package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbar.js +7 -21
- package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbar.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 +21 -66
- package/dist-cjs/lib/ui/components/Toolbar/DefaultToolbar.js.map +3 -3
- package/dist-cjs/lib/ui/components/Toolbar/OverflowingToolbar.js +80 -189
- package/dist-cjs/lib/ui/components/Toolbar/OverflowingToolbar.js.map +3 -3
- package/dist-cjs/lib/ui/components/Toolbar/ToggleToolLockedButton.js +4 -5
- package/dist-cjs/lib/ui/components/Toolbar/ToggleToolLockedButton.js.map +2 -2
- package/dist-cjs/lib/ui/components/menu-items.js +0 -22
- package/dist-cjs/lib/ui/components/menu-items.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/Button/TldrawUiButtonIcon.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiButtonPicker.js +16 -7
- 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/TldrawUiDialog.js +1 -1
- package/dist-cjs/lib/ui/components/primitives/TldrawUiDialog.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiIcon.js +1 -35
- package/dist-cjs/lib/ui/components/primitives/TldrawUiIcon.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiPopover.js +2 -3
- package/dist-cjs/lib/ui/components/primitives/TldrawUiPopover.js.map +3 -3
- package/dist-cjs/lib/ui/components/primitives/TldrawUiSlider.js +2 -6
- package/dist-cjs/lib/ui/components/primitives/TldrawUiSlider.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiToolbar.js +7 -31
- package/dist-cjs/lib/ui/components/primitives/TldrawUiToolbar.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuCheckboxItem.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuContext.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuGroup.js +12 -25
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuGroup.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js +22 -154
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js.map +2 -2
- package/dist-cjs/lib/ui/context/TldrawUiContextProvider.js +2 -3
- package/dist-cjs/lib/ui/context/TldrawUiContextProvider.js.map +2 -2
- package/dist-cjs/lib/ui/context/actions.js +8 -57
- package/dist-cjs/lib/ui/context/actions.js.map +2 -2
- package/dist-cjs/lib/ui/context/events.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/menu-hooks.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/useKeyboardShortcuts.js +2 -2
- package/dist-cjs/lib/ui/hooks/useKeyboardShortcuts.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/useTools.js +9 -94
- package/dist-cjs/lib/ui/hooks/useTools.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/useTranslation/TLUiTranslationKey.js.map +1 -1
- package/dist-cjs/lib/ui/hooks/useTranslation/defaultTranslation.js +0 -11
- package/dist-cjs/lib/ui/hooks/useTranslation/defaultTranslation.js.map +2 -2
- package/dist-cjs/lib/ui/kbd-utils.js +1 -2
- package/dist-cjs/lib/ui/kbd-utils.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-cjs/lib/utils/excalidraw/putExcalidrawContent.js +1 -1
- package/dist-cjs/lib/utils/excalidraw/putExcalidrawContent.js.map +2 -2
- package/dist-cjs/lib/utils/tldr/buildFromV1Document.js +2 -3
- package/dist-cjs/lib/utils/tldr/buildFromV1Document.js.map +2 -2
- package/dist-esm/index.d.mts +23 -297
- package/dist-esm/index.mjs +4 -51
- package/dist-esm/index.mjs.map +2 -2
- package/dist-esm/lib/TldrawImage.mjs +2 -5
- package/dist-esm/lib/TldrawImage.mjs.map +2 -2
- package/dist-esm/lib/canvas/TldrawCropHandles.mjs +1 -1
- package/dist-esm/lib/canvas/TldrawCropHandles.mjs.map +2 -2
- package/dist-esm/lib/canvas/TldrawHandles.mjs +1 -1
- package/dist-esm/lib/canvas/TldrawHandles.mjs.map +2 -2
- package/dist-esm/lib/canvas/TldrawOverlays.mjs +1 -1
- package/dist-esm/lib/canvas/TldrawOverlays.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/canvas/TldrawSelectionForeground.mjs +271 -279
- package/dist-esm/lib/canvas/TldrawSelectionForeground.mjs.map +2 -2
- package/dist-esm/lib/defaultExternalContentHandlers.mjs +0 -1
- package/dist-esm/lib/defaultExternalContentHandlers.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs +44 -30
- package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/arrowLabel.mjs +5 -19
- package/dist-esm/lib/shapes/arrow/arrowLabel.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/arrowTargetState.mjs +1 -1
- package/dist-esm/lib/shapes/arrow/arrowTargetState.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/arrow/toolStates/Pointing.mjs +0 -3
- package/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/shapes/draw/DrawShapeUtil.mjs +6 -4
- 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 +17 -18
- 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 +2 -3
- package/dist-esm/lib/shapes/geo/GeoShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/geo/components/GeoShapeBody.mjs +1 -2
- package/dist-esm/lib/shapes/geo/components/GeoShapeBody.mjs.map +2 -2
- package/dist-esm/lib/shapes/highlight/HighlightShapeUtil.mjs +4 -6
- 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 +5 -21
- package/dist-esm/lib/shapes/line/LineShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs +5 -7
- package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/PathBuilder.mjs +3 -22
- package/dist-esm/lib/shapes/shared/PathBuilder.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/PlainTextLabel.mjs +0 -1
- package/dist-esm/lib/shapes/shared/PlainTextLabel.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/RichTextLabel.mjs +2 -5
- package/dist-esm/lib/shapes/shared/RichTextLabel.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/ShapeFill.mjs +4 -5
- package/dist-esm/lib/shapes/shared/ShapeFill.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/SvgTextLabel.mjs +3 -4
- package/dist-esm/lib/shapes/shared/SvgTextLabel.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/freehand/svg.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/usePrefersReducedMotion.mjs +1 -10
- package/dist-esm/lib/shapes/shared/usePrefersReducedMotion.mjs.map +2 -2
- package/dist-esm/lib/shapes/text/TextShapeUtil.mjs +13 -8
- 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/styles.mjs.map +2 -2
- package/dist-esm/lib/tools/EraserTool/childStates/Erasing.mjs +1 -26
- package/dist-esm/lib/tools/EraserTool/childStates/Erasing.mjs.map +2 -2
- package/dist-esm/lib/tools/EraserTool/childStates/Pointing.mjs +0 -13
- package/dist-esm/lib/tools/EraserTool/childStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.mjs +1 -7
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs +22 -43
- package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Idle.mjs +15 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Idle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingShape.mjs +0 -5
- package/dist-esm/lib/tools/SelectTool/childStates/PointingShape.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs +0 -8
- package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Rotating.mjs +0 -8
- package/dist-esm/lib/tools/SelectTool/childStates/Rotating.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs +0 -8
- package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs.map +2 -2
- package/dist-esm/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.mjs.map +2 -2
- package/dist-esm/lib/ui/TldrawUi.mjs +2 -16
- package/dist-esm/lib/ui/TldrawUi.mjs.map +3 -3
- package/dist-esm/lib/ui/components/A11y.mjs +12 -14
- package/dist-esm/lib/ui/components/A11y.mjs.map +2 -2
- package/dist-esm/lib/ui/components/ActionsMenu/DefaultActionsMenu.mjs +3 -12
- package/dist-esm/lib/ui/components/ActionsMenu/DefaultActionsMenu.mjs.map +2 -2
- package/dist-esm/lib/ui/components/DefaultMenuPanel.mjs +2 -3
- package/dist-esm/lib/ui/components/DefaultMenuPanel.mjs.map +2 -2
- package/dist-esm/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.mjs +1 -51
- package/dist-esm/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.mjs.map +2 -2
- package/dist-esm/lib/ui/components/MainMenu/DefaultMainMenuContent.mjs +3 -3
- package/dist-esm/lib/ui/components/MainMenu/DefaultMainMenuContent.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 +3 -6
- package/dist-esm/lib/ui/components/MobileStylePanel.mjs.map +2 -2
- package/dist-esm/lib/ui/components/NavigationPanel/DefaultNavigationPanel.mjs +5 -4
- package/dist-esm/lib/ui/components/NavigationPanel/DefaultNavigationPanel.mjs.map +2 -2
- package/dist-esm/lib/ui/components/PageMenu/DefaultPageMenu.mjs +1 -2
- package/dist-esm/lib/ui/components/PageMenu/DefaultPageMenu.mjs.map +2 -2
- package/dist-esm/lib/ui/components/SharePanel/PeopleMenuItem.mjs +2 -3
- 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/Spinner.mjs +26 -3
- package/dist-esm/lib/ui/components/Spinner.mjs.map +2 -2
- package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanel.mjs +1 -3
- package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanel.mjs.map +2 -2
- package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanelContent.mjs +139 -171
- 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 +25 -26
- package/dist-esm/lib/ui/components/StylePanel/DropdownPicker.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbar.mjs +9 -23
- package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbar.mjs.map +3 -3
- 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 +21 -56
- package/dist-esm/lib/ui/components/Toolbar/DefaultToolbar.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Toolbar/OverflowingToolbar.mjs +81 -192
- package/dist-esm/lib/ui/components/Toolbar/OverflowingToolbar.mjs.map +3 -3
- package/dist-esm/lib/ui/components/Toolbar/ToggleToolLockedButton.mjs +4 -5
- package/dist-esm/lib/ui/components/Toolbar/ToggleToolLockedButton.mjs.map +2 -2
- package/dist-esm/lib/ui/components/menu-items.mjs +0 -22
- package/dist-esm/lib/ui/components/menu-items.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/Button/TldrawUiButtonIcon.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiButtonPicker.mjs +6 -8
- 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/TldrawUiDialog.mjs +1 -1
- package/dist-esm/lib/ui/components/primitives/TldrawUiDialog.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiIcon.mjs +2 -36
- package/dist-esm/lib/ui/components/primitives/TldrawUiIcon.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiPopover.mjs +2 -3
- package/dist-esm/lib/ui/components/primitives/TldrawUiPopover.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiSlider.mjs +2 -6
- package/dist-esm/lib/ui/components/primitives/TldrawUiSlider.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiToolbar.mjs +7 -31
- package/dist-esm/lib/ui/components/primitives/TldrawUiToolbar.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuCheckboxItem.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuContext.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuGroup.mjs +12 -25
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuGroup.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs +24 -162
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs.map +2 -2
- package/dist-esm/lib/ui/context/TldrawUiContextProvider.mjs +2 -3
- package/dist-esm/lib/ui/context/TldrawUiContextProvider.mjs.map +2 -2
- package/dist-esm/lib/ui/context/actions.mjs +8 -57
- package/dist-esm/lib/ui/context/actions.mjs.map +2 -2
- package/dist-esm/lib/ui/context/events.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/menu-hooks.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/useKeyboardShortcuts.mjs +2 -2
- package/dist-esm/lib/ui/hooks/useKeyboardShortcuts.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/useTools.mjs +10 -102
- package/dist-esm/lib/ui/hooks/useTools.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/useTranslation/defaultTranslation.mjs +0 -11
- package/dist-esm/lib/ui/hooks/useTranslation/defaultTranslation.mjs.map +2 -2
- package/dist-esm/lib/ui/kbd-utils.mjs +1 -2
- package/dist-esm/lib/ui/kbd-utils.mjs.map +2 -2
- package/dist-esm/lib/ui/version.mjs +3 -3
- package/dist-esm/lib/ui/version.mjs.map +1 -1
- package/dist-esm/lib/utils/excalidraw/putExcalidrawContent.mjs +1 -1
- package/dist-esm/lib/utils/excalidraw/putExcalidrawContent.mjs.map +2 -2
- package/dist-esm/lib/utils/tldr/buildFromV1Document.mjs +2 -3
- package/dist-esm/lib/utils/tldr/buildFromV1Document.mjs.map +2 -2
- package/package.json +34 -12
- package/src/index.ts +2 -39
- package/src/lib/TldrawImage.tsx +2 -6
- package/src/lib/canvas/TldrawCropHandles.tsx +1 -3
- package/src/lib/canvas/TldrawHandles.tsx +1 -5
- package/src/lib/canvas/TldrawOverlays.tsx +1 -1
- package/src/lib/canvas/TldrawScribble.tsx +1 -1
- package/src/lib/canvas/TldrawSelectionForeground.tsx +1 -5
- package/src/lib/defaultExternalContentHandlers.ts +1 -2
- package/src/lib/shapes/arrow/ArrowShapeOptions.test.ts +1 -2
- package/src/lib/shapes/arrow/ArrowShapeTool.test.ts +3 -4
- package/src/lib/shapes/arrow/ArrowShapeUtil.test.ts +11 -12
- package/src/lib/shapes/arrow/ArrowShapeUtil.tsx +46 -30
- package/src/lib/shapes/arrow/arrowLabel.ts +3 -23
- package/src/lib/shapes/arrow/arrowTargetState.ts +1 -2
- package/src/lib/shapes/arrow/elbow/ElbowArrowDebug.tsx +3 -3
- package/src/lib/shapes/arrow/toolStates/Pointing.tsx +0 -3
- package/src/lib/shapes/draw/DrawShapeTool.test.ts +5 -0
- package/src/lib/shapes/draw/DrawShapeUtil.tsx +7 -4
- package/src/lib/shapes/embed/EmbedShapeUtil.tsx +1 -1
- package/src/lib/shapes/frame/FrameShapeUtil.tsx +21 -26
- package/src/lib/shapes/frame/components/FrameHeading.tsx +1 -1
- package/src/lib/shapes/geo/GeoShapeUtil.tsx +2 -3
- package/src/lib/shapes/geo/components/GeoShapeBody.tsx +2 -2
- package/src/lib/shapes/highlight/HighlightShapeUtil.tsx +4 -7
- package/src/lib/shapes/image/ImageShapeUtil.tsx +3 -3
- package/src/lib/shapes/line/LineShapeUtil.test.tsx +3 -4
- package/src/lib/shapes/line/LineShapeUtil.tsx +6 -25
- package/src/lib/shapes/line/__snapshots__/LineShapeUtil.test.tsx.snap +2 -2
- package/src/lib/shapes/note/NoteShapeUtil.tsx +4 -10
- package/src/lib/shapes/shared/PathBuilder.test.tsx +1 -1
- package/src/lib/shapes/shared/PathBuilder.tsx +1 -35
- package/src/lib/shapes/shared/PlainTextLabel.tsx +0 -1
- package/src/lib/shapes/shared/RichTextLabel.tsx +0 -4
- package/src/lib/shapes/shared/ShapeFill.tsx +4 -5
- package/src/lib/shapes/shared/SvgTextLabel.tsx +2 -4
- package/src/lib/shapes/shared/freehand/svg.ts +0 -2
- package/src/lib/shapes/shared/usePrefersReducedMotion.tsx +1 -11
- package/src/lib/shapes/text/TextShapeTool.test.ts +5 -6
- package/src/lib/shapes/text/TextShapeUtil.tsx +14 -8
- package/src/lib/shapes/video/VideoShapeUtil.tsx +3 -3
- package/src/lib/styles.tsx +1 -3
- package/src/lib/tools/EraserTool/childStates/Erasing.ts +1 -34
- package/src/lib/tools/EraserTool/childStates/Pointing.ts +0 -20
- package/src/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.ts +1 -8
- package/src/lib/tools/SelectTool/childStates/DraggingHandle.tsx +30 -54
- package/src/lib/tools/SelectTool/childStates/Idle.ts +24 -2
- package/src/lib/tools/SelectTool/childStates/PointingShape.ts +0 -7
- package/src/lib/tools/SelectTool/childStates/Resizing.ts +1 -12
- package/src/lib/tools/SelectTool/childStates/Rotating.ts +0 -11
- package/src/lib/tools/SelectTool/childStates/Translating.ts +1 -11
- package/src/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.ts +0 -1
- package/src/lib/ui/TldrawUi.tsx +2 -17
- package/src/lib/ui/components/A11y.tsx +13 -15
- package/src/lib/ui/components/ActionsMenu/DefaultActionsMenu.tsx +3 -15
- package/src/lib/ui/components/DefaultMenuPanel.tsx +3 -4
- package/src/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.tsx +0 -40
- package/src/lib/ui/components/MainMenu/DefaultMainMenuContent.tsx +2 -4
- package/src/lib/ui/components/Minimap/MinimapManager.ts +4 -4
- package/src/lib/ui/components/MobileStylePanel.tsx +6 -9
- package/src/lib/ui/components/NavigationPanel/DefaultNavigationPanel.tsx +5 -4
- package/src/lib/ui/components/PageMenu/DefaultPageMenu.tsx +2 -3
- package/src/lib/ui/components/SharePanel/PeopleMenuItem.tsx +3 -4
- package/src/lib/ui/components/SharePanel/UserPresenceColorPicker.tsx +3 -3
- package/src/lib/ui/components/Spinner.tsx +24 -2
- package/src/lib/ui/components/StylePanel/DefaultStylePanel.tsx +1 -3
- package/src/lib/ui/components/StylePanel/DefaultStylePanelContent.tsx +106 -146
- package/src/lib/ui/components/StylePanel/DoubleDropdownPicker.tsx +3 -3
- package/src/lib/ui/components/StylePanel/DropdownPicker.tsx +6 -7
- package/src/lib/ui/components/Toolbar/DefaultImageToolbar.tsx +9 -25
- package/src/lib/ui/components/Toolbar/DefaultImageToolbarContent.tsx +1 -1
- package/src/lib/ui/components/Toolbar/DefaultToolbar.tsx +23 -55
- package/src/lib/ui/components/Toolbar/OverflowingToolbar.tsx +61 -212
- package/src/lib/ui/components/Toolbar/ToggleToolLockedButton.tsx +12 -17
- package/src/lib/ui/components/menu-items.tsx +0 -25
- package/src/lib/ui/components/primitives/Button/TldrawUiButtonIcon.tsx +2 -2
- package/src/lib/ui/components/primitives/TldrawUiButtonPicker.tsx +35 -40
- package/src/lib/ui/components/primitives/TldrawUiContextualToolbar.tsx +1 -1
- package/src/lib/ui/components/primitives/TldrawUiDialog.tsx +1 -1
- package/src/lib/ui/components/primitives/TldrawUiIcon.tsx +3 -41
- package/src/lib/ui/components/primitives/TldrawUiPopover.tsx +2 -4
- package/src/lib/ui/components/primitives/TldrawUiSlider.tsx +1 -6
- package/src/lib/ui/components/primitives/TldrawUiToolbar.tsx +12 -56
- package/src/lib/ui/components/primitives/menus/TldrawUiMenuCheckboxItem.tsx +2 -2
- package/src/lib/ui/components/primitives/menus/TldrawUiMenuContext.tsx +1 -0
- package/src/lib/ui/components/primitives/menus/TldrawUiMenuGroup.tsx +16 -29
- package/src/lib/ui/components/primitives/menus/TldrawUiMenuItem.tsx +23 -224
- package/src/lib/ui/context/TldrawUiContextProvider.tsx +20 -23
- package/src/lib/ui/context/actions.tsx +9 -59
- package/src/lib/ui/context/events.tsx +2 -6
- package/src/lib/ui/hooks/menu-hooks.ts +0 -1
- package/src/lib/ui/hooks/useKeyboardShortcuts.ts +2 -3
- package/src/lib/ui/hooks/useTools.tsx +11 -142
- package/src/lib/ui/hooks/useTranslation/TLUiTranslationKey.ts +0 -11
- package/src/lib/ui/hooks/useTranslation/defaultTranslation.ts +0 -11
- package/src/lib/ui/kbd-utils.ts +1 -2
- package/src/lib/ui/version.ts +3 -3
- package/src/lib/ui.css +314 -414
- package/src/lib/utils/excalidraw/__snapshots__/putExcalidrawContent.test.tsx.snap +7 -21
- package/src/lib/utils/excalidraw/putExcalidrawContent.ts +1 -1
- package/src/lib/utils/tldr/__snapshots__/buildFromV1Document.test.ts.snap +7 -28
- package/src/lib/utils/tldr/buildFromV1Document.ts +1 -2
- package/src/test/A11y.test.tsx +2 -3
- package/src/test/ClickManager.test.ts +6 -7
- package/src/test/Editor.test.tsx +20 -21
- package/src/test/EraserTool.test.ts +13 -184
- package/src/test/HandTool.test.ts +9 -10
- package/src/test/HighlightShape.test.ts +1 -2
- package/src/test/SelectTool.test.ts +13 -40
- package/src/test/TLUserPreferences.test.ts +3 -4
- package/src/test/TestEditor.ts +15 -13
- package/src/test/TldrawEditor.test.tsx +10 -11
- package/src/test/ZoomTool.test.ts +6 -7
- 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 +10 -17
- package/src/test/bindings.test.tsx +37 -24
- package/src/test/bookmark-shapes.test.ts +8 -1
- package/src/test/commands/__snapshots__/getSvgString.test.ts.snap +7 -23
- 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 +24 -25
- package/src/test/commands/animationSpeed.test.ts +1 -2
- package/src/test/commands/centerOnPoint.test.ts +2 -3
- package/src/test/commands/clipboard.test.ts +2 -3
- package/src/test/commands/createShapes.test.ts +1 -2
- package/src/test/commands/deletePage.test.ts +1 -84
- package/src/test/commands/deleteShapes.test.ts +1 -2
- package/src/test/commands/distributeShapes.test.tsx +10 -11
- package/src/test/commands/getSvgString.test.ts +1 -2
- package/src/test/commands/packShapes.test.ts +4 -5
- package/src/test/commands/resizeShape.test.ts +1 -2
- package/src/test/commands/rotateShapes.test.ts +6 -7
- package/src/test/commands/setCamera.test.ts +3 -4
- package/src/test/commands/setCurrentPage.test.ts +2 -3
- package/src/test/commands/stackShapes.test.ts +10 -11
- package/src/test/commands/stretch.test.tsx +12 -13
- package/src/test/createDeepLink.test.tsx +1 -2
- package/src/test/cropping.test.ts +2 -3
- package/src/test/drawing.test.ts +1 -2
- package/src/test/flipShapes.test.ts +3 -4
- package/src/test/frames.test.ts +24 -25
- package/src/test/getCulledShapes.test.tsx +2 -3
- package/src/test/groups.test.tsx +2 -2
- package/src/test/handleDeepLink.test.tsx +1 -2
- package/src/test/maxShapes.test.ts +2 -3
- package/src/test/modifiers.test.ts +4 -5
- package/src/test/navigation.test.ts +9 -264
- package/src/test/panning.test.ts +1 -2
- package/src/test/perf/perf.test.ts +1 -2
- package/src/test/registerDeepLinkListener.test.tsx +9 -10
- package/src/test/resizing.test.ts +38 -39
- package/src/test/select.test.tsx +3 -4
- package/src/test/selection-omnibus.test.ts +10 -11
- package/src/test/shapeutils.test.ts +48 -398
- package/src/test/translating.test.ts +9 -10
- package/tldraw.css +627 -726
- package/dist-cjs/lib/ui/components/AccessibilityMenu.js +0 -35
- package/dist-cjs/lib/ui/components/AccessibilityMenu.js.map +0 -7
- package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js +0 -268
- package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js.map +0 -7
- package/dist-cjs/lib/ui/components/primitives/layout.js +0 -76
- package/dist-cjs/lib/ui/components/primitives/layout.js.map +0 -7
- package/dist-esm/lib/ui/components/AccessibilityMenu.mjs +0 -19
- package/dist-esm/lib/ui/components/AccessibilityMenu.mjs.map +0 -7
- package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs +0 -245
- package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs.map +0 -7
- package/dist-esm/lib/ui/components/primitives/layout.mjs +0 -46
- package/dist-esm/lib/ui/components/primitives/layout.mjs.map +0 -7
- package/src/lib/ui/components/AccessibilityMenu.tsx +0 -20
- package/src/lib/ui/components/primitives/TldrawUiTooltip.tsx +0 -327
- package/src/lib/ui/components/primitives/layout.tsx +0 -107
- package/src/test/inner-outer-margin.test.ts +0 -315
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
tlenv,
|
|
8
8
|
toRichText,
|
|
9
9
|
} from '@tldraw/editor'
|
|
10
|
-
import { vi } from 'vitest'
|
|
11
10
|
import { TestEditor } from './TestEditor'
|
|
12
11
|
|
|
13
12
|
let editor: TestEditor
|
|
@@ -1653,7 +1652,7 @@ describe('shift brushes to add to the selection', () => {
|
|
|
1653
1652
|
editor.keyUp('Shift')
|
|
1654
1653
|
// there's a timer here—we should keep the shift mode until the timer expires
|
|
1655
1654
|
expect(editor.getSelectedShapeIds()).toEqual([ids.box2, ids.box1])
|
|
1656
|
-
|
|
1655
|
+
jest.advanceTimersByTime(500)
|
|
1657
1656
|
// once the timer expires, we should be back in regular mode
|
|
1658
1657
|
expect(editor.getSelectedShapeIds()).toEqual([ids.box1])
|
|
1659
1658
|
editor.keyDown('Shift')
|
|
@@ -1723,7 +1722,7 @@ describe('scribble brushes to add to the selection', () => {
|
|
|
1723
1722
|
editor.pointerMove(50, 50)
|
|
1724
1723
|
expect(editor.getSelectedShapeIds()).toEqual([ids.box1, ids.box2])
|
|
1725
1724
|
editor.keyUp('Shift')
|
|
1726
|
-
|
|
1725
|
+
jest.advanceTimersByTime(500)
|
|
1727
1726
|
expect(editor.getSelectedShapeIds()).toEqual([ids.box1])
|
|
1728
1727
|
editor.keyDown('Shift')
|
|
1729
1728
|
expect(editor.getSelectedShapeIds()).toEqual([ids.box1, ids.box2])
|
|
@@ -1740,7 +1739,7 @@ describe('scribble brushes to add to the selection', () => {
|
|
|
1740
1739
|
expect(editor.getSelectedShapeIds()).toEqual([ids.box4])
|
|
1741
1740
|
editor.keyUp('Alt') // scribble
|
|
1742
1741
|
expect(editor.getSelectedShapeIds()).toEqual([ids.box4]) // still in timer
|
|
1743
|
-
|
|
1742
|
+
jest.advanceTimersByTime(1000) // let timer expire
|
|
1744
1743
|
expect(editor.getSelectedShapeIds()).toEqual([ids.box3, ids.box4]) // brushed!
|
|
1745
1744
|
editor.keyDown('Alt') // scribble
|
|
1746
1745
|
expect(editor.getSelectedShapeIds()).toEqual([ids.box4]) // back to brushed only
|
|
@@ -1825,7 +1824,7 @@ describe('When brushing close to the edges of the screen', () => {
|
|
|
1825
1824
|
editor.pointerMove(300, 300)
|
|
1826
1825
|
editor.pointerDown()
|
|
1827
1826
|
editor.pointerMove(0, 0)
|
|
1828
|
-
|
|
1827
|
+
jest.advanceTimersByTime(100)
|
|
1829
1828
|
editor.pointerUp()
|
|
1830
1829
|
const camera2 = editor.getCamera()
|
|
1831
1830
|
expect(camera2.x).toBeGreaterThan(camera1.x) // for some reason > is left
|
|
@@ -1838,7 +1837,7 @@ describe('When brushing close to the edges of the screen', () => {
|
|
|
1838
1837
|
editor.pointerMove(300, 300)
|
|
1839
1838
|
editor.pointerDown()
|
|
1840
1839
|
editor.pointerMove(100, 100)
|
|
1841
|
-
|
|
1840
|
+
jest.advanceTimersByTime(100)
|
|
1842
1841
|
editor.pointerUp()
|
|
1843
1842
|
const camera2 = editor.getCamera()
|
|
1844
1843
|
// should NOT have moved the camera by edge scrolling
|
|
@@ -1852,7 +1851,7 @@ describe('When brushing close to the edges of the screen', () => {
|
|
|
1852
1851
|
editor.pointerMove(300, 300)
|
|
1853
1852
|
editor.pointerDown()
|
|
1854
1853
|
editor.pointerMove(100, 100)
|
|
1855
|
-
|
|
1854
|
+
jest.advanceTimersByTime(100)
|
|
1856
1855
|
editor.pointerUp()
|
|
1857
1856
|
const camera4 = editor.getCamera()
|
|
1858
1857
|
// should NOT have moved the camera by edge scrolling because the edge is now "inset"
|
|
@@ -1861,7 +1860,7 @@ describe('When brushing close to the edges of the screen', () => {
|
|
|
1861
1860
|
|
|
1862
1861
|
editor.pointerDown()
|
|
1863
1862
|
editor.pointerMove(90, 90) // off the edge of the component
|
|
1864
|
-
|
|
1863
|
+
jest.advanceTimersByTime(100)
|
|
1865
1864
|
const camera5 = editor.getCamera()
|
|
1866
1865
|
// should have moved the camera by edge scrolling off the component edge
|
|
1867
1866
|
expect(camera5.x).toBeGreaterThan(camera4.x)
|
|
@@ -1883,7 +1882,7 @@ describe('When brushing close to the edges of the screen', () => {
|
|
|
1883
1882
|
editor.pointerMove(0, 0)
|
|
1884
1883
|
// still only box 1...
|
|
1885
1884
|
expect(editor.getSelectedShapeIds()).toEqual([ids.box1])
|
|
1886
|
-
|
|
1885
|
+
jest.advanceTimersByTime(100)
|
|
1887
1886
|
// ...but now viewport will have moved to select box2 as well
|
|
1888
1887
|
expect(editor.getSelectedShapeIds()).toEqual([ids.box1, ids.box2])
|
|
1889
1888
|
editor.pointerUp()
|
|
@@ -1903,7 +1902,7 @@ describe('When brushing close to the edges of the screen', () => {
|
|
|
1903
1902
|
expect(editor.getSelectedShapeIds()).toEqual([ids.box1])
|
|
1904
1903
|
editor.pointerMove(0, 0)
|
|
1905
1904
|
expect(editor.getSelectedShapeIds()).toEqual([ids.box1])
|
|
1906
|
-
|
|
1905
|
+
jest.advanceTimersByTime(100)
|
|
1907
1906
|
expect(editor.getSelectedShapeIds()).toEqual([ids.box1])
|
|
1908
1907
|
editor.pointerUp()
|
|
1909
1908
|
})
|
|
@@ -2200,7 +2199,7 @@ describe('long press', () => {
|
|
|
2200
2199
|
it('works correctly with screenbounds offset', () => {
|
|
2201
2200
|
editor.updateViewportScreenBounds(new Box(100, 100, 800, 600))
|
|
2202
2201
|
editor.pointerDown(201, 202)
|
|
2203
|
-
|
|
2202
|
+
jest.advanceTimersByTime(1000)
|
|
2204
2203
|
// without the fix added in this PR, it would have been 1, 2
|
|
2205
2204
|
expect(editor.inputs.currentScreenPoint).toMatchObject({ x: 101, y: 102 })
|
|
2206
2205
|
})
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { createShapeId, TLFrameShape, TLGeoShape
|
|
2
|
-
import { vi } from 'vitest'
|
|
1
|
+
import { createShapeId, TLFrameShape, TLGeoShape } from '@tldraw/editor'
|
|
3
2
|
import { TestEditor } from './TestEditor'
|
|
4
3
|
|
|
5
4
|
let editor: TestEditor
|
|
@@ -12,8 +11,6 @@ const ids = {
|
|
|
12
11
|
frame1: createShapeId('frame1'),
|
|
13
12
|
box1: createShapeId('box1'),
|
|
14
13
|
box2: createShapeId('box2'),
|
|
15
|
-
line1: createShapeId('line1'),
|
|
16
|
-
page1: createShapeId('page1'),
|
|
17
14
|
}
|
|
18
15
|
|
|
19
16
|
beforeEach(() => {
|
|
@@ -59,93 +56,34 @@ describe('When interacting with a shape...', () => {
|
|
|
59
56
|
// Set start / change / end events on only the geo shape
|
|
60
57
|
const util = editor.getShapeUtil<TLFrameShape>('frame')
|
|
61
58
|
|
|
62
|
-
const
|
|
59
|
+
const fnStart = jest.fn()
|
|
60
|
+
util.onRotateStart = fnStart
|
|
63
61
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
62
|
+
const fnChange = jest.fn()
|
|
63
|
+
util.onRotate = fnChange
|
|
67
64
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
util.onRotateEnd = () => {
|
|
73
|
-
calls.push('end')
|
|
74
|
-
}
|
|
65
|
+
const fnEnd = jest.fn()
|
|
66
|
+
util.onRotateEnd = fnEnd
|
|
75
67
|
|
|
76
68
|
editor.selectAll()
|
|
77
69
|
expect(editor.getSelectedShapeIds()).toMatchObject([ids.frame1, ids.box1])
|
|
78
70
|
|
|
79
|
-
editor
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
editor.pointerMove(200, 200)
|
|
88
|
-
|
|
89
|
-
// Should have called start once and change at least once now
|
|
90
|
-
expect(calls).toEqual(['start', 'change'])
|
|
91
|
-
|
|
92
|
-
editor.pointerMove(200, 210)
|
|
93
|
-
|
|
94
|
-
// Should have called start once and change multiple times
|
|
95
|
-
expect(calls).toEqual(['start', 'change', 'change'])
|
|
96
|
-
|
|
97
|
-
editor.pointerUp(200, 210)
|
|
98
|
-
|
|
99
|
-
// Should have called end once now
|
|
100
|
-
expect(calls).toEqual(['start', 'change', 'change', 'change', 'end'])
|
|
101
|
-
})
|
|
102
|
-
|
|
103
|
-
it('fires rotate cancel events', () => {
|
|
104
|
-
const util = editor.getShapeUtil<TLFrameShape>('frame')
|
|
105
|
-
|
|
106
|
-
const calls: string[] = []
|
|
107
|
-
|
|
108
|
-
util.onRotateStart = () => {
|
|
109
|
-
calls.push('start')
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
util.onRotate = () => {
|
|
113
|
-
calls.push('change')
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
util.onRotateEnd = () => {
|
|
117
|
-
calls.push('end')
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
util.onRotateCancel = () => {
|
|
121
|
-
calls.push('cancel')
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
editor.selectAll()
|
|
125
|
-
expect(editor.getSelectedShapeIds()).toMatchObject([ids.frame1, ids.box1])
|
|
126
|
-
|
|
127
|
-
editor.pointerDown(300, 300, {
|
|
128
|
-
target: 'selection',
|
|
129
|
-
handle: 'bottom_right_rotate',
|
|
130
|
-
})
|
|
131
|
-
|
|
132
|
-
// Should not have called any callbacks yet
|
|
133
|
-
expect(calls).toEqual([])
|
|
134
|
-
|
|
135
|
-
editor.pointerMove(200, 200)
|
|
136
|
-
|
|
137
|
-
// Should have called start once and change at least once now
|
|
138
|
-
expect(calls).toEqual(['start', 'change'])
|
|
71
|
+
editor
|
|
72
|
+
.pointerDown(300, 300, {
|
|
73
|
+
target: 'selection',
|
|
74
|
+
handle: 'bottom_right_rotate',
|
|
75
|
+
})
|
|
76
|
+
.pointerMove(200, 200)
|
|
77
|
+
.pointerUp(200, 200)
|
|
139
78
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
// Should have called start once and change multiple times
|
|
143
|
-
expect(calls).toEqual(['start', 'change', 'change'])
|
|
79
|
+
// Once on start (for frame only)
|
|
80
|
+
expect(fnStart).toHaveBeenCalledTimes(1)
|
|
144
81
|
|
|
145
|
-
|
|
82
|
+
// Once on start, once during the move
|
|
83
|
+
expect(fnChange).toHaveBeenCalledTimes(2)
|
|
146
84
|
|
|
147
|
-
//
|
|
148
|
-
expect(
|
|
85
|
+
// Once on end
|
|
86
|
+
expect(fnEnd).toHaveBeenCalledTimes(1)
|
|
149
87
|
})
|
|
150
88
|
|
|
151
89
|
it('cleans up events', () => {
|
|
@@ -156,7 +94,7 @@ describe('When interacting with a shape...', () => {
|
|
|
156
94
|
it('fires double click handler event', () => {
|
|
157
95
|
const util = editor.getShapeUtil<TLGeoShape>('geo')
|
|
158
96
|
|
|
159
|
-
const fnStart =
|
|
97
|
+
const fnStart = jest.fn()
|
|
160
98
|
util.onDoubleClick = fnStart
|
|
161
99
|
|
|
162
100
|
editor.doubleClick(50, 50, ids.box2)
|
|
@@ -167,19 +105,14 @@ describe('When interacting with a shape...', () => {
|
|
|
167
105
|
it('Fires resisizing events', () => {
|
|
168
106
|
const util = editor.getShapeUtil<TLFrameShape>('frame')
|
|
169
107
|
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
util.onResizeStart = () => {
|
|
173
|
-
calls.push('start')
|
|
174
|
-
}
|
|
108
|
+
const fnStart = jest.fn()
|
|
109
|
+
util.onResizeStart = fnStart
|
|
175
110
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
}
|
|
111
|
+
const fnChange = jest.fn()
|
|
112
|
+
util.onResize = fnChange
|
|
179
113
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
}
|
|
114
|
+
const fnEnd = jest.fn()
|
|
115
|
+
util.onResizeEnd = fnEnd
|
|
183
116
|
|
|
184
117
|
editor.selectAll()
|
|
185
118
|
expect(editor.getSelectedShapeIds()).toMatchObject([ids.frame1, ids.box1])
|
|
@@ -190,171 +123,54 @@ describe('When interacting with a shape...', () => {
|
|
|
190
123
|
})
|
|
191
124
|
|
|
192
125
|
editor.expectToBeIn('select.pointing_resize_handle')
|
|
193
|
-
|
|
194
|
-
// Should not have called any callbacks yet
|
|
195
|
-
expect(calls).toEqual([])
|
|
196
|
-
|
|
197
126
|
editor.pointerMove(200, 200)
|
|
198
127
|
editor.expectToBeIn('select.resizing')
|
|
199
|
-
|
|
200
|
-
// Should have called start once and change at least once now
|
|
201
|
-
expect(calls).toEqual(['start', 'change'])
|
|
202
|
-
|
|
203
128
|
editor.pointerMove(200, 210)
|
|
204
|
-
|
|
205
|
-
// Should have called start once and change multiple times
|
|
206
|
-
expect(calls).toEqual(['start', 'change', 'change'])
|
|
207
|
-
|
|
208
129
|
editor.pointerUp(200, 210)
|
|
209
130
|
editor.expectToBeIn('select.idle')
|
|
210
131
|
|
|
211
|
-
//
|
|
212
|
-
expect(
|
|
213
|
-
})
|
|
214
|
-
|
|
215
|
-
it('Fires resizing cancel events', () => {
|
|
216
|
-
const util = editor.getShapeUtil<TLFrameShape>('frame')
|
|
217
|
-
|
|
218
|
-
const calls: string[] = []
|
|
219
|
-
|
|
220
|
-
util.onResizeStart = () => {
|
|
221
|
-
calls.push('start')
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
util.onResize = () => {
|
|
225
|
-
calls.push('change')
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
util.onResizeEnd = () => {
|
|
229
|
-
calls.push('end')
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
util.onResizeCancel = () => {
|
|
233
|
-
calls.push('cancel')
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
editor.selectAll()
|
|
237
|
-
expect(editor.getSelectedShapeIds()).toMatchObject([ids.frame1, ids.box1])
|
|
238
|
-
|
|
239
|
-
editor.pointerDown(300, 300, {
|
|
240
|
-
target: 'selection',
|
|
241
|
-
handle: 'bottom_right',
|
|
242
|
-
})
|
|
243
|
-
|
|
244
|
-
editor.expectToBeIn('select.pointing_resize_handle')
|
|
245
|
-
|
|
246
|
-
// Should not have called any callbacks yet
|
|
247
|
-
expect(calls).toEqual([])
|
|
248
|
-
|
|
249
|
-
editor.pointerMove(200, 200)
|
|
250
|
-
editor.expectToBeIn('select.resizing')
|
|
251
|
-
|
|
252
|
-
// Should have called start once and change at least once now
|
|
253
|
-
expect(calls).toEqual(['start', 'change'])
|
|
254
|
-
|
|
255
|
-
editor.pointerMove(200, 210)
|
|
256
|
-
|
|
257
|
-
// Should have called start once and change multiple times
|
|
258
|
-
expect(calls).toEqual(['start', 'change', 'change'])
|
|
132
|
+
// Once on start (for frame only)
|
|
133
|
+
expect(fnStart).toHaveBeenCalledTimes(1)
|
|
259
134
|
|
|
260
|
-
|
|
135
|
+
// Once on start, once during the resize
|
|
136
|
+
expect(fnChange).toHaveBeenCalledTimes(2)
|
|
261
137
|
|
|
262
|
-
//
|
|
263
|
-
expect(
|
|
138
|
+
// Once on end
|
|
139
|
+
expect(fnEnd).toHaveBeenCalledTimes(1)
|
|
264
140
|
})
|
|
265
141
|
|
|
266
142
|
it('Fires translating events', () => {
|
|
267
143
|
const util = editor.getShapeUtil<TLFrameShape>('frame')
|
|
268
144
|
|
|
269
|
-
const
|
|
145
|
+
const fnStart = jest.fn()
|
|
146
|
+
util.onTranslateStart = fnStart
|
|
270
147
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
}
|
|
148
|
+
const fnChange = jest.fn()
|
|
149
|
+
util.onTranslate = fnChange
|
|
274
150
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
util.onTranslateEnd = () => {
|
|
280
|
-
calls.push('end')
|
|
281
|
-
}
|
|
151
|
+
const fnEnd = jest.fn()
|
|
152
|
+
util.onTranslateEnd = fnEnd
|
|
282
153
|
|
|
283
154
|
editor.selectAll()
|
|
284
155
|
expect(editor.getSelectedShapeIds()).toMatchObject([ids.frame1, ids.box1])
|
|
285
156
|
|
|
286
157
|
// Translate the shapes...
|
|
287
|
-
editor.pointerDown(50, 50, ids.box1)
|
|
288
|
-
|
|
289
|
-
// Should not have called any callbacks yet
|
|
290
|
-
expect(calls).toEqual([])
|
|
291
|
-
|
|
292
|
-
editor.pointerMove(50, 40)
|
|
293
|
-
|
|
294
|
-
// Should have called start once and change at least once now
|
|
295
|
-
expect(calls).toEqual(['start', 'change'])
|
|
296
|
-
|
|
297
|
-
editor.pointerMove(50, 35)
|
|
298
|
-
|
|
299
|
-
// Should have called start once and change multiple times
|
|
300
|
-
expect(calls).toEqual(['start', 'change', 'change'])
|
|
301
|
-
|
|
302
|
-
editor.pointerUp(50, 35)
|
|
303
|
-
|
|
304
|
-
// Should have called end once now
|
|
305
|
-
expect(calls).toEqual(['start', 'change', 'change', 'change', 'end'])
|
|
306
|
-
})
|
|
307
|
-
|
|
308
|
-
it('Fires translating cancel events', () => {
|
|
309
|
-
const util = editor.getShapeUtil<TLFrameShape>('frame')
|
|
310
|
-
|
|
311
|
-
const calls: string[] = []
|
|
158
|
+
editor.pointerDown(50, 50, ids.box1).pointerMove(50, 40).pointerUp(50, 40)
|
|
312
159
|
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
util.onTranslate = () => {
|
|
318
|
-
calls.push('change')
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
util.onTranslateEnd = () => {
|
|
322
|
-
calls.push('end')
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
util.onTranslateCancel = () => {
|
|
326
|
-
calls.push('cancel')
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
editor.selectAll()
|
|
330
|
-
expect(editor.getSelectedShapeIds()).toMatchObject([ids.frame1, ids.box1])
|
|
331
|
-
|
|
332
|
-
// Translate the shapes...
|
|
333
|
-
editor.pointerDown(50, 50, ids.box1)
|
|
334
|
-
|
|
335
|
-
// Should not have called any callbacks yet
|
|
336
|
-
expect(calls).toEqual([])
|
|
337
|
-
|
|
338
|
-
editor.pointerMove(50, 40)
|
|
339
|
-
|
|
340
|
-
// Should have called start once and change at least once now
|
|
341
|
-
expect(calls).toEqual(['start', 'change'])
|
|
342
|
-
|
|
343
|
-
editor.pointerMove(50, 35)
|
|
344
|
-
|
|
345
|
-
// Should have called start once and change multiple times
|
|
346
|
-
expect(calls).toEqual(['start', 'change', 'change'])
|
|
160
|
+
// Once on start for frame
|
|
161
|
+
expect(fnStart).toHaveBeenCalledTimes(1)
|
|
347
162
|
|
|
348
|
-
|
|
163
|
+
// Once on start, once during the move
|
|
164
|
+
expect(fnChange).toHaveBeenCalledTimes(2)
|
|
349
165
|
|
|
350
|
-
//
|
|
351
|
-
expect(
|
|
166
|
+
// Once on end
|
|
167
|
+
expect(fnEnd).toHaveBeenCalledTimes(1)
|
|
352
168
|
})
|
|
353
169
|
|
|
354
170
|
it('Uses the shape utils onClick handler', () => {
|
|
355
171
|
const util = editor.getShapeUtil<TLFrameShape>('frame')
|
|
356
172
|
|
|
357
|
-
const fnClick =
|
|
173
|
+
const fnClick = jest.fn()
|
|
358
174
|
util.onClick = fnClick
|
|
359
175
|
|
|
360
176
|
editor.pointerDown(50, 50, ids.frame1)
|
|
@@ -368,7 +184,7 @@ describe('When interacting with a shape...', () => {
|
|
|
368
184
|
it('Uses the shape utils onClick handler', () => {
|
|
369
185
|
const util = editor.getShapeUtil<TLFrameShape>('frame')
|
|
370
186
|
|
|
371
|
-
const fnClick =
|
|
187
|
+
const fnClick = jest.fn((shape: any) => {
|
|
372
188
|
return {
|
|
373
189
|
...shape,
|
|
374
190
|
x: 100,
|
|
@@ -385,170 +201,4 @@ describe('When interacting with a shape...', () => {
|
|
|
385
201
|
// it should not be selected.
|
|
386
202
|
expect(editor.getSelectedShapeIds().length).toBe(0)
|
|
387
203
|
})
|
|
388
|
-
|
|
389
|
-
it('Fires handle dragging events', () => {
|
|
390
|
-
const util = editor.getShapeUtil<TLLineShape>('line')
|
|
391
|
-
|
|
392
|
-
const calls: string[] = []
|
|
393
|
-
|
|
394
|
-
util.onHandleDragStart = () => {
|
|
395
|
-
calls.push('start')
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
util.onHandleDrag = () => {
|
|
399
|
-
calls.push('change')
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
util.onHandleDragEnd = () => {
|
|
403
|
-
calls.push('end')
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
util.onHandleDragCancel = () => {
|
|
407
|
-
calls.push('cancel')
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
// Create a line shape with handles
|
|
411
|
-
const lineShape: TLLineShape = {
|
|
412
|
-
id: ids.line1,
|
|
413
|
-
type: 'line',
|
|
414
|
-
typeName: 'shape',
|
|
415
|
-
parentId: ids.page1,
|
|
416
|
-
index: 'a1' as any,
|
|
417
|
-
x: 100,
|
|
418
|
-
y: 100,
|
|
419
|
-
rotation: 0,
|
|
420
|
-
isLocked: false,
|
|
421
|
-
opacity: 1,
|
|
422
|
-
meta: {},
|
|
423
|
-
props: {
|
|
424
|
-
dash: 'draw',
|
|
425
|
-
size: 'm',
|
|
426
|
-
color: 'black',
|
|
427
|
-
spline: 'line',
|
|
428
|
-
scale: 1,
|
|
429
|
-
points: {
|
|
430
|
-
a1: { id: 'a1', index: 'a1' as any, x: 0, y: 0 },
|
|
431
|
-
a2: { id: 'a2', index: 'a2' as any, x: 100, y: 100 },
|
|
432
|
-
},
|
|
433
|
-
},
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
editor.createShapes([lineShape])
|
|
437
|
-
|
|
438
|
-
// Get the handle point
|
|
439
|
-
const handlePagePoint = editor
|
|
440
|
-
.getShapePageTransform(lineShape.id)!
|
|
441
|
-
.applyToPoint(lineShape.props.points['a2'])
|
|
442
|
-
|
|
443
|
-
editor.pointerDown(handlePagePoint.x, handlePagePoint.y, {
|
|
444
|
-
target: 'handle',
|
|
445
|
-
shape: editor.getShape(lineShape.id)!,
|
|
446
|
-
handle: { id: 'a2', type: 'vertex', index: 'a2' as any, x: 100, y: 100 },
|
|
447
|
-
})
|
|
448
|
-
|
|
449
|
-
editor.expectToBeIn('select.pointing_handle')
|
|
450
|
-
|
|
451
|
-
// Should not have called any callbacks yet
|
|
452
|
-
expect(calls).toEqual([])
|
|
453
|
-
|
|
454
|
-
editor.pointerMove(handlePagePoint.x + 20, handlePagePoint.y + 20) // Larger move to trigger drag
|
|
455
|
-
editor.expectToBeIn('select.dragging_handle')
|
|
456
|
-
|
|
457
|
-
// Should have called start once and change at least once now
|
|
458
|
-
expect(calls).toEqual(['start', 'change'])
|
|
459
|
-
|
|
460
|
-
editor.pointerMove(150, 150)
|
|
461
|
-
|
|
462
|
-
// Should have called start once and change multiple times
|
|
463
|
-
expect(calls).toEqual(['start', 'change', 'change'])
|
|
464
|
-
|
|
465
|
-
editor.pointerUp(150, 150)
|
|
466
|
-
editor.expectToBeIn('select.idle')
|
|
467
|
-
|
|
468
|
-
// Should have called end once now
|
|
469
|
-
expect(calls).toEqual(['start', 'change', 'change', 'end'])
|
|
470
|
-
})
|
|
471
|
-
|
|
472
|
-
it('Fires handle dragging cancel events', () => {
|
|
473
|
-
const util = editor.getShapeUtil<TLLineShape>('line')
|
|
474
|
-
|
|
475
|
-
const calls: string[] = []
|
|
476
|
-
|
|
477
|
-
util.onHandleDragStart = () => {
|
|
478
|
-
calls.push('start')
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
util.onHandleDrag = () => {
|
|
482
|
-
calls.push('change')
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
util.onHandleDragEnd = () => {
|
|
486
|
-
calls.push('end')
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
util.onHandleDragCancel = () => {
|
|
490
|
-
calls.push('cancel')
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
// Create a line shape with handles
|
|
494
|
-
const lineShape: TLLineShape = {
|
|
495
|
-
id: ids.line1,
|
|
496
|
-
type: 'line',
|
|
497
|
-
typeName: 'shape',
|
|
498
|
-
parentId: ids.page1,
|
|
499
|
-
index: 'a1' as any,
|
|
500
|
-
x: 100,
|
|
501
|
-
y: 100,
|
|
502
|
-
rotation: 0,
|
|
503
|
-
isLocked: false,
|
|
504
|
-
opacity: 1,
|
|
505
|
-
meta: {},
|
|
506
|
-
props: {
|
|
507
|
-
dash: 'draw',
|
|
508
|
-
size: 'm',
|
|
509
|
-
color: 'black',
|
|
510
|
-
spline: 'line',
|
|
511
|
-
scale: 1,
|
|
512
|
-
points: {
|
|
513
|
-
a1: { id: 'a1', index: 'a1' as any, x: 0, y: 0 },
|
|
514
|
-
a2: { id: 'a2', index: 'a2' as any, x: 100, y: 100 },
|
|
515
|
-
},
|
|
516
|
-
},
|
|
517
|
-
}
|
|
518
|
-
|
|
519
|
-
editor.createShapes([lineShape])
|
|
520
|
-
|
|
521
|
-
// Get the handle point
|
|
522
|
-
const handlePagePoint = editor
|
|
523
|
-
.getShapePageTransform(lineShape.id)!
|
|
524
|
-
.applyToPoint(lineShape.props.points['a2'])
|
|
525
|
-
|
|
526
|
-
editor.pointerDown(handlePagePoint.x, handlePagePoint.y, {
|
|
527
|
-
target: 'handle',
|
|
528
|
-
shape: editor.getShape(lineShape.id)!,
|
|
529
|
-
handle: { id: 'a2', type: 'vertex', index: 'a2' as any, x: 100, y: 100 },
|
|
530
|
-
})
|
|
531
|
-
|
|
532
|
-
editor.expectToBeIn('select.pointing_handle')
|
|
533
|
-
|
|
534
|
-
// Should not have called any callbacks yet
|
|
535
|
-
expect(calls).toEqual([])
|
|
536
|
-
|
|
537
|
-
editor.pointerMove(handlePagePoint.x + 20, handlePagePoint.y + 20) // Larger move to trigger drag
|
|
538
|
-
editor.expectToBeIn('select.dragging_handle')
|
|
539
|
-
|
|
540
|
-
// Should have called start once and change at least once now
|
|
541
|
-
expect(calls).toEqual(['start', 'change'])
|
|
542
|
-
|
|
543
|
-
editor.pointerMove(150, 150)
|
|
544
|
-
|
|
545
|
-
// Should have called start once and change multiple times
|
|
546
|
-
expect(calls).toEqual(['start', 'change', 'change'])
|
|
547
|
-
|
|
548
|
-
editor.cancel()
|
|
549
|
-
editor.expectToBeIn('select.idle')
|
|
550
|
-
|
|
551
|
-
// Should have called cancel instead of end
|
|
552
|
-
expect(calls).toEqual(['start', 'change', 'change', 'cancel'])
|
|
553
|
-
})
|
|
554
204
|
})
|