tldraw 3.16.0-canary.ffdf566dd0a8 → 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 +19 -125
- package/dist-cjs/index.js +2 -19
- 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/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 +41 -24
- 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/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 +3 -0
- package/dist-cjs/lib/shapes/draw/DrawShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js +5 -5
- package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/highlight/HighlightShapeUtil.js +3 -0
- package/dist-cjs/lib/shapes/highlight/HighlightShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/line/LineShapeUtil.js +4 -15
- package/dist-cjs/lib/shapes/line/LineShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/note/NoteShapeUtil.js +1 -2
- 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/SvgTextLabel.js +3 -4
- package/dist-cjs/lib/shapes/shared/SvgTextLabel.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 +11 -5
- package/dist-cjs/lib/shapes/text/TextShapeUtil.js.map +2 -2
- package/dist-cjs/lib/styles.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/assetUrls.js +13 -10
- package/dist-cjs/lib/ui/assetUrls.js.map +2 -2
- 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/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/NavigationPanel/DefaultNavigationPanel.js +4 -3
- package/dist-cjs/lib/ui/components/NavigationPanel/DefaultNavigationPanel.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 +136 -168
- package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanelContent.js.map +2 -2
- 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/OverflowingToolbar.js +3 -3
- package/dist-cjs/lib/ui/components/Toolbar/OverflowingToolbar.js.map +2 -2
- package/dist-cjs/lib/ui/components/Toolbar/ToggleToolLockedButton.js +2 -3
- 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 +0 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiButtonPicker.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/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 +3 -12
- 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/TldrawUiMenuItem.js +2 -0
- 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.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 +19 -125
- package/dist-esm/index.mjs +4 -33
- 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/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 +41 -26
- 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/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 +3 -0
- package/dist-esm/lib/shapes/draw/DrawShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs +5 -5
- package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/highlight/HighlightShapeUtil.mjs +3 -0
- package/dist-esm/lib/shapes/highlight/HighlightShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/line/LineShapeUtil.mjs +4 -15
- package/dist-esm/lib/shapes/line/LineShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs +1 -2
- 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/SvgTextLabel.mjs +3 -4
- package/dist-esm/lib/shapes/shared/SvgTextLabel.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 +11 -5
- package/dist-esm/lib/shapes/text/TextShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/styles.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/assetUrls.mjs +13 -10
- package/dist-esm/lib/ui/assetUrls.mjs.map +2 -2
- 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/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/NavigationPanel/DefaultNavigationPanel.mjs +4 -3
- package/dist-esm/lib/ui/components/NavigationPanel/DefaultNavigationPanel.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 +136 -168
- package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanelContent.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/OverflowingToolbar.mjs +3 -3
- package/dist-esm/lib/ui/components/Toolbar/OverflowingToolbar.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Toolbar/ToggleToolLockedButton.mjs +2 -3
- 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 +0 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiButtonPicker.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/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 +3 -12
- 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/TldrawUiMenuItem.mjs +2 -0
- 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.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 +3 -4
- package/src/index.ts +2 -24
- 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/TldrawSelectionForeground.tsx +1 -5
- package/src/lib/defaultExternalContentHandlers.ts +1 -2
- package/src/lib/shapes/arrow/ArrowShapeUtil.test.ts +5 -5
- package/src/lib/shapes/arrow/ArrowShapeUtil.tsx +43 -26
- package/src/lib/shapes/arrow/arrowLabel.ts +3 -23
- package/src/lib/shapes/arrow/arrowTargetState.ts +1 -2
- package/src/lib/shapes/arrow/toolStates/Pointing.tsx +0 -3
- package/src/lib/shapes/draw/DrawShapeUtil.tsx +4 -0
- package/src/lib/shapes/frame/FrameShapeUtil.tsx +7 -5
- package/src/lib/shapes/highlight/HighlightShapeUtil.tsx +3 -0
- package/src/lib/shapes/line/LineShapeUtil.tsx +5 -19
- package/src/lib/shapes/note/NoteShapeUtil.tsx +0 -1
- 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/SvgTextLabel.tsx +2 -4
- package/src/lib/shapes/shared/usePrefersReducedMotion.tsx +1 -11
- package/src/lib/shapes/text/TextShapeUtil.tsx +12 -5
- package/src/lib/styles.tsx +1 -3
- 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 +0 -11
- package/src/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.ts +0 -1
- package/src/lib/ui/assetUrls.ts +13 -10
- package/src/lib/ui/components/A11y.tsx +13 -15
- 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/NavigationPanel/DefaultNavigationPanel.tsx +4 -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 +127 -171
- package/src/lib/ui/components/Toolbar/DefaultImageToolbar.tsx +9 -25
- package/src/lib/ui/components/Toolbar/OverflowingToolbar.tsx +3 -3
- 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 +0 -2
- 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/TldrawUiSlider.tsx +1 -6
- package/src/lib/ui/components/primitives/TldrawUiToolbar.tsx +3 -24
- package/src/lib/ui/components/primitives/menus/TldrawUiMenuCheckboxItem.tsx +2 -2
- package/src/lib/ui/components/primitives/menus/TldrawUiMenuItem.tsx +4 -3
- 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 -5
- 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 +1 -2
- 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 +23 -65
- package/src/lib/utils/excalidraw/__snapshots__/putExcalidrawContent.test.tsx.snap +2 -16
- package/src/lib/utils/excalidraw/putExcalidrawContent.ts +1 -1
- package/src/lib/utils/tldr/__snapshots__/buildFromV1Document.test.ts.snap +3 -24
- package/src/lib/utils/tldr/buildFromV1Document.ts +1 -2
- package/src/test/Editor.test.tsx +1 -1
- package/src/test/SelectTool.test.ts +11 -37
- package/src/test/arrows-megabus.test.tsx +6 -12
- package/src/test/commands/__snapshots__/getSvgString.test.ts.snap +2 -2
- package/src/test/commands/deletePage.test.ts +1 -84
- package/src/test/groups.test.tsx +1 -1
- package/src/test/navigation.test.ts +0 -254
- package/src/test/shapeutils.test.ts +45 -394
- package/src/test/translating.test.ts +1 -1
- package/tldraw.css +50 -88
- 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 -267
- package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.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 -237
- package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs.map +0 -7
- package/src/lib/ui/components/AccessibilityMenu.tsx +0 -20
- package/src/lib/ui/components/primitives/TldrawUiTooltip.tsx +0 -313
- package/src/test/inner-outer-margin.test.ts +0 -315
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createShapeId, TLFrameShape, TLGeoShape
|
|
1
|
+
import { createShapeId, TLFrameShape, TLGeoShape } from '@tldraw/editor'
|
|
2
2
|
import { TestEditor } from './TestEditor'
|
|
3
3
|
|
|
4
4
|
let editor: TestEditor
|
|
@@ -11,8 +11,6 @@ const ids = {
|
|
|
11
11
|
frame1: createShapeId('frame1'),
|
|
12
12
|
box1: createShapeId('box1'),
|
|
13
13
|
box2: createShapeId('box2'),
|
|
14
|
-
line1: createShapeId('line1'),
|
|
15
|
-
page1: createShapeId('page1'),
|
|
16
14
|
}
|
|
17
15
|
|
|
18
16
|
beforeEach(() => {
|
|
@@ -58,93 +56,34 @@ describe('When interacting with a shape...', () => {
|
|
|
58
56
|
// Set start / change / end events on only the geo shape
|
|
59
57
|
const util = editor.getShapeUtil<TLFrameShape>('frame')
|
|
60
58
|
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
util.onRotateStart = () => {
|
|
64
|
-
calls.push('start')
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
util.onRotate = () => {
|
|
68
|
-
calls.push('change')
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
util.onRotateEnd = () => {
|
|
72
|
-
calls.push('end')
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
editor.selectAll()
|
|
76
|
-
expect(editor.getSelectedShapeIds()).toMatchObject([ids.frame1, ids.box1])
|
|
77
|
-
|
|
78
|
-
editor.pointerDown(300, 300, {
|
|
79
|
-
target: 'selection',
|
|
80
|
-
handle: 'bottom_right_rotate',
|
|
81
|
-
})
|
|
82
|
-
|
|
83
|
-
// Should not have called any callbacks yet
|
|
84
|
-
expect(calls).toEqual([])
|
|
85
|
-
|
|
86
|
-
editor.pointerMove(200, 200)
|
|
87
|
-
|
|
88
|
-
// Should have called start once and change at least once now
|
|
89
|
-
expect(calls).toEqual(['start', 'change'])
|
|
90
|
-
|
|
91
|
-
editor.pointerMove(200, 210)
|
|
92
|
-
|
|
93
|
-
// Should have called start once and change multiple times
|
|
94
|
-
expect(calls).toEqual(['start', 'change', 'change'])
|
|
95
|
-
|
|
96
|
-
editor.pointerUp(200, 210)
|
|
97
|
-
|
|
98
|
-
// Should have called end once now
|
|
99
|
-
expect(calls).toEqual(['start', 'change', 'change', 'change', 'end'])
|
|
100
|
-
})
|
|
101
|
-
|
|
102
|
-
it('fires rotate cancel events', () => {
|
|
103
|
-
const util = editor.getShapeUtil<TLFrameShape>('frame')
|
|
104
|
-
|
|
105
|
-
const calls: string[] = []
|
|
106
|
-
|
|
107
|
-
util.onRotateStart = () => {
|
|
108
|
-
calls.push('start')
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
util.onRotate = () => {
|
|
112
|
-
calls.push('change')
|
|
113
|
-
}
|
|
59
|
+
const fnStart = jest.fn()
|
|
60
|
+
util.onRotateStart = fnStart
|
|
114
61
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}
|
|
62
|
+
const fnChange = jest.fn()
|
|
63
|
+
util.onRotate = fnChange
|
|
118
64
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
65
|
+
const fnEnd = jest.fn()
|
|
66
|
+
util.onRotateEnd = fnEnd
|
|
122
67
|
|
|
123
68
|
editor.selectAll()
|
|
124
69
|
expect(editor.getSelectedShapeIds()).toMatchObject([ids.frame1, ids.box1])
|
|
125
70
|
|
|
126
|
-
editor
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
editor.pointerMove(200, 200)
|
|
135
|
-
|
|
136
|
-
// Should have called start once and change at least once now
|
|
137
|
-
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)
|
|
138
78
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
// Should have called start once and change multiple times
|
|
142
|
-
expect(calls).toEqual(['start', 'change', 'change'])
|
|
79
|
+
// Once on start (for frame only)
|
|
80
|
+
expect(fnStart).toHaveBeenCalledTimes(1)
|
|
143
81
|
|
|
144
|
-
|
|
82
|
+
// Once on start, once during the move
|
|
83
|
+
expect(fnChange).toHaveBeenCalledTimes(2)
|
|
145
84
|
|
|
146
|
-
//
|
|
147
|
-
expect(
|
|
85
|
+
// Once on end
|
|
86
|
+
expect(fnEnd).toHaveBeenCalledTimes(1)
|
|
148
87
|
})
|
|
149
88
|
|
|
150
89
|
it('cleans up events', () => {
|
|
@@ -166,19 +105,14 @@ describe('When interacting with a shape...', () => {
|
|
|
166
105
|
it('Fires resisizing events', () => {
|
|
167
106
|
const util = editor.getShapeUtil<TLFrameShape>('frame')
|
|
168
107
|
|
|
169
|
-
const
|
|
170
|
-
|
|
171
|
-
util.onResizeStart = () => {
|
|
172
|
-
calls.push('start')
|
|
173
|
-
}
|
|
108
|
+
const fnStart = jest.fn()
|
|
109
|
+
util.onResizeStart = fnStart
|
|
174
110
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
}
|
|
111
|
+
const fnChange = jest.fn()
|
|
112
|
+
util.onResize = fnChange
|
|
178
113
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
}
|
|
114
|
+
const fnEnd = jest.fn()
|
|
115
|
+
util.onResizeEnd = fnEnd
|
|
182
116
|
|
|
183
117
|
editor.selectAll()
|
|
184
118
|
expect(editor.getSelectedShapeIds()).toMatchObject([ids.frame1, ids.box1])
|
|
@@ -189,165 +123,48 @@ describe('When interacting with a shape...', () => {
|
|
|
189
123
|
})
|
|
190
124
|
|
|
191
125
|
editor.expectToBeIn('select.pointing_resize_handle')
|
|
192
|
-
|
|
193
|
-
// Should not have called any callbacks yet
|
|
194
|
-
expect(calls).toEqual([])
|
|
195
|
-
|
|
196
126
|
editor.pointerMove(200, 200)
|
|
197
127
|
editor.expectToBeIn('select.resizing')
|
|
198
|
-
|
|
199
|
-
// Should have called start once and change at least once now
|
|
200
|
-
expect(calls).toEqual(['start', 'change'])
|
|
201
|
-
|
|
202
128
|
editor.pointerMove(200, 210)
|
|
203
|
-
|
|
204
|
-
// Should have called start once and change multiple times
|
|
205
|
-
expect(calls).toEqual(['start', 'change', 'change'])
|
|
206
|
-
|
|
207
129
|
editor.pointerUp(200, 210)
|
|
208
130
|
editor.expectToBeIn('select.idle')
|
|
209
131
|
|
|
210
|
-
//
|
|
211
|
-
expect(
|
|
212
|
-
})
|
|
213
|
-
|
|
214
|
-
it('Fires resizing cancel events', () => {
|
|
215
|
-
const util = editor.getShapeUtil<TLFrameShape>('frame')
|
|
216
|
-
|
|
217
|
-
const calls: string[] = []
|
|
218
|
-
|
|
219
|
-
util.onResizeStart = () => {
|
|
220
|
-
calls.push('start')
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
util.onResize = () => {
|
|
224
|
-
calls.push('change')
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
util.onResizeEnd = () => {
|
|
228
|
-
calls.push('end')
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
util.onResizeCancel = () => {
|
|
232
|
-
calls.push('cancel')
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
editor.selectAll()
|
|
236
|
-
expect(editor.getSelectedShapeIds()).toMatchObject([ids.frame1, ids.box1])
|
|
237
|
-
|
|
238
|
-
editor.pointerDown(300, 300, {
|
|
239
|
-
target: 'selection',
|
|
240
|
-
handle: 'bottom_right',
|
|
241
|
-
})
|
|
242
|
-
|
|
243
|
-
editor.expectToBeIn('select.pointing_resize_handle')
|
|
244
|
-
|
|
245
|
-
// Should not have called any callbacks yet
|
|
246
|
-
expect(calls).toEqual([])
|
|
247
|
-
|
|
248
|
-
editor.pointerMove(200, 200)
|
|
249
|
-
editor.expectToBeIn('select.resizing')
|
|
250
|
-
|
|
251
|
-
// Should have called start once and change at least once now
|
|
252
|
-
expect(calls).toEqual(['start', 'change'])
|
|
253
|
-
|
|
254
|
-
editor.pointerMove(200, 210)
|
|
255
|
-
|
|
256
|
-
// Should have called start once and change multiple times
|
|
257
|
-
expect(calls).toEqual(['start', 'change', 'change'])
|
|
132
|
+
// Once on start (for frame only)
|
|
133
|
+
expect(fnStart).toHaveBeenCalledTimes(1)
|
|
258
134
|
|
|
259
|
-
|
|
135
|
+
// Once on start, once during the resize
|
|
136
|
+
expect(fnChange).toHaveBeenCalledTimes(2)
|
|
260
137
|
|
|
261
|
-
//
|
|
262
|
-
expect(
|
|
138
|
+
// Once on end
|
|
139
|
+
expect(fnEnd).toHaveBeenCalledTimes(1)
|
|
263
140
|
})
|
|
264
141
|
|
|
265
142
|
it('Fires translating events', () => {
|
|
266
143
|
const util = editor.getShapeUtil<TLFrameShape>('frame')
|
|
267
144
|
|
|
268
|
-
const
|
|
269
|
-
|
|
270
|
-
util.onTranslateStart = () => {
|
|
271
|
-
calls.push('start')
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
util.onTranslate = () => {
|
|
275
|
-
calls.push('change')
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
util.onTranslateEnd = () => {
|
|
279
|
-
calls.push('end')
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
editor.selectAll()
|
|
283
|
-
expect(editor.getSelectedShapeIds()).toMatchObject([ids.frame1, ids.box1])
|
|
284
|
-
|
|
285
|
-
// Translate the shapes...
|
|
286
|
-
editor.pointerDown(50, 50, ids.box1)
|
|
287
|
-
|
|
288
|
-
// Should not have called any callbacks yet
|
|
289
|
-
expect(calls).toEqual([])
|
|
290
|
-
|
|
291
|
-
editor.pointerMove(50, 40)
|
|
292
|
-
|
|
293
|
-
// Should have called start once and change at least once now
|
|
294
|
-
expect(calls).toEqual(['start', 'change'])
|
|
295
|
-
|
|
296
|
-
editor.pointerMove(50, 35)
|
|
297
|
-
|
|
298
|
-
// Should have called start once and change multiple times
|
|
299
|
-
expect(calls).toEqual(['start', 'change', 'change'])
|
|
300
|
-
|
|
301
|
-
editor.pointerUp(50, 35)
|
|
302
|
-
|
|
303
|
-
// Should have called end once now
|
|
304
|
-
expect(calls).toEqual(['start', 'change', 'change', 'change', 'end'])
|
|
305
|
-
})
|
|
306
|
-
|
|
307
|
-
it('Fires translating cancel events', () => {
|
|
308
|
-
const util = editor.getShapeUtil<TLFrameShape>('frame')
|
|
309
|
-
|
|
310
|
-
const calls: string[] = []
|
|
311
|
-
|
|
312
|
-
util.onTranslateStart = () => {
|
|
313
|
-
calls.push('start')
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
util.onTranslate = () => {
|
|
317
|
-
calls.push('change')
|
|
318
|
-
}
|
|
145
|
+
const fnStart = jest.fn()
|
|
146
|
+
util.onTranslateStart = fnStart
|
|
319
147
|
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
}
|
|
148
|
+
const fnChange = jest.fn()
|
|
149
|
+
util.onTranslate = fnChange
|
|
323
150
|
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
}
|
|
151
|
+
const fnEnd = jest.fn()
|
|
152
|
+
util.onTranslateEnd = fnEnd
|
|
327
153
|
|
|
328
154
|
editor.selectAll()
|
|
329
155
|
expect(editor.getSelectedShapeIds()).toMatchObject([ids.frame1, ids.box1])
|
|
330
156
|
|
|
331
157
|
// Translate the shapes...
|
|
332
|
-
editor.pointerDown(50, 50, ids.box1)
|
|
333
|
-
|
|
334
|
-
// Should not have called any callbacks yet
|
|
335
|
-
expect(calls).toEqual([])
|
|
336
|
-
|
|
337
|
-
editor.pointerMove(50, 40)
|
|
158
|
+
editor.pointerDown(50, 50, ids.box1).pointerMove(50, 40).pointerUp(50, 40)
|
|
338
159
|
|
|
339
|
-
//
|
|
340
|
-
expect(
|
|
341
|
-
|
|
342
|
-
editor.pointerMove(50, 35)
|
|
343
|
-
|
|
344
|
-
// Should have called start once and change multiple times
|
|
345
|
-
expect(calls).toEqual(['start', 'change', 'change'])
|
|
160
|
+
// Once on start for frame
|
|
161
|
+
expect(fnStart).toHaveBeenCalledTimes(1)
|
|
346
162
|
|
|
347
|
-
|
|
163
|
+
// Once on start, once during the move
|
|
164
|
+
expect(fnChange).toHaveBeenCalledTimes(2)
|
|
348
165
|
|
|
349
|
-
//
|
|
350
|
-
expect(
|
|
166
|
+
// Once on end
|
|
167
|
+
expect(fnEnd).toHaveBeenCalledTimes(1)
|
|
351
168
|
})
|
|
352
169
|
|
|
353
170
|
it('Uses the shape utils onClick handler', () => {
|
|
@@ -384,170 +201,4 @@ describe('When interacting with a shape...', () => {
|
|
|
384
201
|
// it should not be selected.
|
|
385
202
|
expect(editor.getSelectedShapeIds().length).toBe(0)
|
|
386
203
|
})
|
|
387
|
-
|
|
388
|
-
it('Fires handle dragging events', () => {
|
|
389
|
-
const util = editor.getShapeUtil<TLLineShape>('line')
|
|
390
|
-
|
|
391
|
-
const calls: string[] = []
|
|
392
|
-
|
|
393
|
-
util.onHandleDragStart = () => {
|
|
394
|
-
calls.push('start')
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
util.onHandleDrag = () => {
|
|
398
|
-
calls.push('change')
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
util.onHandleDragEnd = () => {
|
|
402
|
-
calls.push('end')
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
util.onHandleDragCancel = () => {
|
|
406
|
-
calls.push('cancel')
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
// Create a line shape with handles
|
|
410
|
-
const lineShape: TLLineShape = {
|
|
411
|
-
id: ids.line1,
|
|
412
|
-
type: 'line',
|
|
413
|
-
typeName: 'shape',
|
|
414
|
-
parentId: ids.page1,
|
|
415
|
-
index: 'a1' as any,
|
|
416
|
-
x: 100,
|
|
417
|
-
y: 100,
|
|
418
|
-
rotation: 0,
|
|
419
|
-
isLocked: false,
|
|
420
|
-
opacity: 1,
|
|
421
|
-
meta: {},
|
|
422
|
-
props: {
|
|
423
|
-
dash: 'draw',
|
|
424
|
-
size: 'm',
|
|
425
|
-
color: 'black',
|
|
426
|
-
spline: 'line',
|
|
427
|
-
scale: 1,
|
|
428
|
-
points: {
|
|
429
|
-
a1: { id: 'a1', index: 'a1' as any, x: 0, y: 0 },
|
|
430
|
-
a2: { id: 'a2', index: 'a2' as any, x: 100, y: 100 },
|
|
431
|
-
},
|
|
432
|
-
},
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
editor.createShapes([lineShape])
|
|
436
|
-
|
|
437
|
-
// Get the handle point
|
|
438
|
-
const handlePagePoint = editor
|
|
439
|
-
.getShapePageTransform(lineShape.id)!
|
|
440
|
-
.applyToPoint(lineShape.props.points['a2'])
|
|
441
|
-
|
|
442
|
-
editor.pointerDown(handlePagePoint.x, handlePagePoint.y, {
|
|
443
|
-
target: 'handle',
|
|
444
|
-
shape: editor.getShape(lineShape.id)!,
|
|
445
|
-
handle: { id: 'a2', type: 'vertex', index: 'a2' as any, x: 100, y: 100 },
|
|
446
|
-
})
|
|
447
|
-
|
|
448
|
-
editor.expectToBeIn('select.pointing_handle')
|
|
449
|
-
|
|
450
|
-
// Should not have called any callbacks yet
|
|
451
|
-
expect(calls).toEqual([])
|
|
452
|
-
|
|
453
|
-
editor.pointerMove(handlePagePoint.x + 20, handlePagePoint.y + 20) // Larger move to trigger drag
|
|
454
|
-
editor.expectToBeIn('select.dragging_handle')
|
|
455
|
-
|
|
456
|
-
// Should have called start once and change at least once now
|
|
457
|
-
expect(calls).toEqual(['start', 'change'])
|
|
458
|
-
|
|
459
|
-
editor.pointerMove(150, 150)
|
|
460
|
-
|
|
461
|
-
// Should have called start once and change multiple times
|
|
462
|
-
expect(calls).toEqual(['start', 'change', 'change'])
|
|
463
|
-
|
|
464
|
-
editor.pointerUp(150, 150)
|
|
465
|
-
editor.expectToBeIn('select.idle')
|
|
466
|
-
|
|
467
|
-
// Should have called end once now
|
|
468
|
-
expect(calls).toEqual(['start', 'change', 'change', 'end'])
|
|
469
|
-
})
|
|
470
|
-
|
|
471
|
-
it('Fires handle dragging cancel events', () => {
|
|
472
|
-
const util = editor.getShapeUtil<TLLineShape>('line')
|
|
473
|
-
|
|
474
|
-
const calls: string[] = []
|
|
475
|
-
|
|
476
|
-
util.onHandleDragStart = () => {
|
|
477
|
-
calls.push('start')
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
util.onHandleDrag = () => {
|
|
481
|
-
calls.push('change')
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
util.onHandleDragEnd = () => {
|
|
485
|
-
calls.push('end')
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
util.onHandleDragCancel = () => {
|
|
489
|
-
calls.push('cancel')
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
// Create a line shape with handles
|
|
493
|
-
const lineShape: TLLineShape = {
|
|
494
|
-
id: ids.line1,
|
|
495
|
-
type: 'line',
|
|
496
|
-
typeName: 'shape',
|
|
497
|
-
parentId: ids.page1,
|
|
498
|
-
index: 'a1' as any,
|
|
499
|
-
x: 100,
|
|
500
|
-
y: 100,
|
|
501
|
-
rotation: 0,
|
|
502
|
-
isLocked: false,
|
|
503
|
-
opacity: 1,
|
|
504
|
-
meta: {},
|
|
505
|
-
props: {
|
|
506
|
-
dash: 'draw',
|
|
507
|
-
size: 'm',
|
|
508
|
-
color: 'black',
|
|
509
|
-
spline: 'line',
|
|
510
|
-
scale: 1,
|
|
511
|
-
points: {
|
|
512
|
-
a1: { id: 'a1', index: 'a1' as any, x: 0, y: 0 },
|
|
513
|
-
a2: { id: 'a2', index: 'a2' as any, x: 100, y: 100 },
|
|
514
|
-
},
|
|
515
|
-
},
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
editor.createShapes([lineShape])
|
|
519
|
-
|
|
520
|
-
// Get the handle point
|
|
521
|
-
const handlePagePoint = editor
|
|
522
|
-
.getShapePageTransform(lineShape.id)!
|
|
523
|
-
.applyToPoint(lineShape.props.points['a2'])
|
|
524
|
-
|
|
525
|
-
editor.pointerDown(handlePagePoint.x, handlePagePoint.y, {
|
|
526
|
-
target: 'handle',
|
|
527
|
-
shape: editor.getShape(lineShape.id)!,
|
|
528
|
-
handle: { id: 'a2', type: 'vertex', index: 'a2' as any, x: 100, y: 100 },
|
|
529
|
-
})
|
|
530
|
-
|
|
531
|
-
editor.expectToBeIn('select.pointing_handle')
|
|
532
|
-
|
|
533
|
-
// Should not have called any callbacks yet
|
|
534
|
-
expect(calls).toEqual([])
|
|
535
|
-
|
|
536
|
-
editor.pointerMove(handlePagePoint.x + 20, handlePagePoint.y + 20) // Larger move to trigger drag
|
|
537
|
-
editor.expectToBeIn('select.dragging_handle')
|
|
538
|
-
|
|
539
|
-
// Should have called start once and change at least once now
|
|
540
|
-
expect(calls).toEqual(['start', 'change'])
|
|
541
|
-
|
|
542
|
-
editor.pointerMove(150, 150)
|
|
543
|
-
|
|
544
|
-
// Should have called start once and change multiple times
|
|
545
|
-
expect(calls).toEqual(['start', 'change', 'change'])
|
|
546
|
-
|
|
547
|
-
editor.cancel()
|
|
548
|
-
editor.expectToBeIn('select.idle')
|
|
549
|
-
|
|
550
|
-
// Should have called cancel instead of end
|
|
551
|
-
expect(calls).toEqual(['start', 'change', 'change', 'cancel'])
|
|
552
|
-
})
|
|
553
204
|
})
|
|
@@ -151,7 +151,7 @@ describe('When translating...', () => {
|
|
|
151
151
|
editor
|
|
152
152
|
// The change is bigger than expected because the camera moves
|
|
153
153
|
.expectShapeToMatch({ id: ids.box1, x: -65, y: 10 })
|
|
154
|
-
// We'll continue moving in the x
|
|
154
|
+
// We'll continue moving in the x postion, but now we'll also move in the y position.
|
|
155
155
|
// The speed in the y position is smaller since we are further away from the edge.
|
|
156
156
|
.pointerMove(0, 25)
|
|
157
157
|
jest.advanceTimersByTime(100)
|