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
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { vi } from 'vitest'
|
|
2
1
|
import { HandTool } from '../lib/tools/HandTool/HandTool'
|
|
3
2
|
import { TestEditor, createDefaultShapes } from './TestEditor'
|
|
4
3
|
|
|
@@ -15,7 +14,7 @@ afterEach(() => {
|
|
|
15
14
|
editor?.dispose()
|
|
16
15
|
})
|
|
17
16
|
|
|
18
|
-
|
|
17
|
+
jest.useFakeTimers()
|
|
19
18
|
|
|
20
19
|
describe(HandTool, () => {
|
|
21
20
|
it('Double taps to zoom in', () => {
|
|
@@ -23,9 +22,9 @@ describe(HandTool, () => {
|
|
|
23
22
|
expect(editor.getZoomLevel()).toBe(1)
|
|
24
23
|
editor.click()
|
|
25
24
|
editor.click() // double click!
|
|
26
|
-
|
|
25
|
+
jest.advanceTimersByTime(300)
|
|
27
26
|
expect(editor.getZoomLevel()).not.toBe(1) // animating
|
|
28
|
-
|
|
27
|
+
jest.advanceTimersByTime(300)
|
|
29
28
|
expect(editor.getZoomLevel()).toBe(2) // all done
|
|
30
29
|
})
|
|
31
30
|
|
|
@@ -35,9 +34,9 @@ describe(HandTool, () => {
|
|
|
35
34
|
editor.click()
|
|
36
35
|
editor.click()
|
|
37
36
|
editor.click() // triple click!
|
|
38
|
-
|
|
37
|
+
jest.advanceTimersByTime(300)
|
|
39
38
|
expect(editor.getZoomLevel()).not.toBe(1) // animating
|
|
40
|
-
|
|
39
|
+
jest.advanceTimersByTime(300)
|
|
41
40
|
expect(editor.getZoomLevel()).toBe(0.5) // all done
|
|
42
41
|
})
|
|
43
42
|
|
|
@@ -49,9 +48,9 @@ describe(HandTool, () => {
|
|
|
49
48
|
editor.click()
|
|
50
49
|
editor.click()
|
|
51
50
|
editor.click() // quad click!
|
|
52
|
-
|
|
51
|
+
jest.advanceTimersByTime(300)
|
|
53
52
|
expect(editor.getZoomLevel()).not.toBe(2) // animating
|
|
54
|
-
|
|
53
|
+
jest.advanceTimersByTime(300)
|
|
55
54
|
expect(editor.getZoomLevel()).toBe(1) // all done
|
|
56
55
|
})
|
|
57
56
|
|
|
@@ -63,9 +62,9 @@ describe(HandTool, () => {
|
|
|
63
62
|
editor.click()
|
|
64
63
|
editor.click()
|
|
65
64
|
editor.click() // quad click!
|
|
66
|
-
|
|
65
|
+
jest.advanceTimersByTime(300)
|
|
67
66
|
expect(editor.getZoomLevel()).not.toBe(1) // animating
|
|
68
|
-
|
|
67
|
+
jest.advanceTimersByTime(300)
|
|
69
68
|
const z = editor.getZoomLevel()
|
|
70
69
|
editor.zoomToFit() // call zoom to fit manually to compare
|
|
71
70
|
expect(editor.getZoomLevel()).toBe(z) // zoom should not have changed
|
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
createShapeId,
|
|
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
|
|
@@ -19,7 +18,7 @@ const ids = {
|
|
|
19
18
|
arrow1: createShapeId('arrow1'),
|
|
20
19
|
}
|
|
21
20
|
|
|
22
|
-
|
|
21
|
+
jest.useFakeTimers()
|
|
23
22
|
|
|
24
23
|
beforeEach(() => {
|
|
25
24
|
editor = new TestEditor()
|
|
@@ -161,7 +160,7 @@ describe('TLSelectTool.Translating', () => {
|
|
|
161
160
|
// There's a timer here! We shouldn't end the clone until the timer is done
|
|
162
161
|
expect(editor.getCurrentPageShapes().length).toBe(2)
|
|
163
162
|
|
|
164
|
-
|
|
163
|
+
jest.advanceTimersByTime(250) // tick tock
|
|
165
164
|
|
|
166
165
|
// Timer is done! We should have ended the clone.
|
|
167
166
|
expect(editor.getCurrentPageShapes().length).toBe(1)
|
|
@@ -276,27 +275,17 @@ describe('PointingLabel', () => {
|
|
|
276
275
|
type: 'arrow',
|
|
277
276
|
x: 100,
|
|
278
277
|
y: 100,
|
|
279
|
-
props: {
|
|
280
|
-
richText: toRichText('Test Label'),
|
|
281
|
-
start: { x: 0, y: 0 },
|
|
282
|
-
end: { x: 100, y: 0 },
|
|
283
|
-
},
|
|
278
|
+
props: { text: 'Test Label', end: { x: 100, y: 100 } },
|
|
284
279
|
},
|
|
285
280
|
])
|
|
286
|
-
const shape = editor.getShape(ids.arrow1)
|
|
287
|
-
|
|
288
|
-
editor.select(shape.id)
|
|
289
|
-
|
|
290
|
-
// Click at the middle of the arrow where the label would be and drag to move the label
|
|
291
|
-
editor.pointerDown(150, 100, {
|
|
281
|
+
const shape = editor.getShape(ids.arrow1)
|
|
282
|
+
editor.pointerDown(150, 150, {
|
|
292
283
|
target: 'shape',
|
|
293
284
|
shape,
|
|
294
285
|
})
|
|
295
|
-
editor.pointerMove(
|
|
286
|
+
editor.pointerMove(100, 100)
|
|
296
287
|
editor.expectToBeIn('select.pointing_arrow_label')
|
|
297
288
|
|
|
298
|
-
// Continue dragging to actually move the label, then it should go to idle
|
|
299
|
-
editor.pointerMove(170, 100)
|
|
300
289
|
editor.pointerUp()
|
|
301
290
|
editor.expectToBeIn('select.idle')
|
|
302
291
|
})
|
|
@@ -308,21 +297,16 @@ describe('PointingLabel', () => {
|
|
|
308
297
|
type: 'arrow',
|
|
309
298
|
x: 100,
|
|
310
299
|
y: 100,
|
|
311
|
-
props: {
|
|
312
|
-
richText: toRichText('Test Label'),
|
|
313
|
-
start: { x: 0, y: 0 },
|
|
314
|
-
end: { x: 100, y: 0 },
|
|
315
|
-
},
|
|
300
|
+
props: { text: 'Test Label', end: { x: 100, y: 100 } },
|
|
316
301
|
},
|
|
317
302
|
])
|
|
318
303
|
const shape = editor.getShape(ids.arrow1)
|
|
319
304
|
|
|
320
|
-
|
|
321
|
-
editor.pointerDown(150, 100, {
|
|
305
|
+
editor.pointerDown(150, 150, {
|
|
322
306
|
target: 'shape',
|
|
323
307
|
shape,
|
|
324
308
|
})
|
|
325
|
-
editor.pointerMove(
|
|
309
|
+
editor.pointerMove(100, 100)
|
|
326
310
|
editor.expectToBeIn('select.pointing_arrow_label')
|
|
327
311
|
editor.cancel()
|
|
328
312
|
editor.expectToBeIn('select.idle')
|
|
@@ -330,25 +314,14 @@ describe('PointingLabel', () => {
|
|
|
330
314
|
|
|
331
315
|
it('Doesnt go into pointing_arrow_label mode if not selecting the arrow shape', () => {
|
|
332
316
|
editor.createShapes<TLArrowShape>([
|
|
333
|
-
{
|
|
334
|
-
id: ids.arrow1,
|
|
335
|
-
type: 'arrow',
|
|
336
|
-
x: 100,
|
|
337
|
-
y: 100,
|
|
338
|
-
props: {
|
|
339
|
-
richText: toRichText(''), // Empty label
|
|
340
|
-
start: { x: 0, y: 0 },
|
|
341
|
-
end: { x: 100, y: 0 },
|
|
342
|
-
},
|
|
343
|
-
},
|
|
317
|
+
{ id: ids.arrow1, type: 'arrow', x: 100, y: 100, props: { text: 'Test Label' } },
|
|
344
318
|
])
|
|
345
|
-
const shape = editor.getShape(ids.arrow1)
|
|
346
|
-
|
|
347
|
-
editor.pointerDown(150, 100, {
|
|
319
|
+
const shape = editor.getShape(ids.arrow1)
|
|
320
|
+
editor.pointerDown(0, 150, {
|
|
348
321
|
target: 'shape',
|
|
349
322
|
shape,
|
|
350
323
|
})
|
|
351
|
-
editor.pointerMove(
|
|
324
|
+
editor.pointerMove(100, 100)
|
|
352
325
|
editor.expectToBeIn('select.translating')
|
|
353
326
|
|
|
354
327
|
editor.pointerUp()
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { TLUserPreferences, atom, createTLUser } from '@tldraw/editor'
|
|
2
|
-
import { vi } from 'vitest'
|
|
3
2
|
import { TestEditor } from './TestEditor'
|
|
4
3
|
|
|
5
4
|
let editor: TestEditor
|
|
@@ -60,7 +59,7 @@ describe('TLUserPreferences', () => {
|
|
|
60
59
|
locale: null,
|
|
61
60
|
name: null,
|
|
62
61
|
})
|
|
63
|
-
const setUserPreferences =
|
|
62
|
+
const setUserPreferences = jest.fn((preferences) => userPreferences.set(preferences))
|
|
64
63
|
|
|
65
64
|
editor = new TestEditor({
|
|
66
65
|
user: createTLUser({
|
|
@@ -81,7 +80,7 @@ describe('TLUserPreferences', () => {
|
|
|
81
80
|
id: '123',
|
|
82
81
|
name: 'blah',
|
|
83
82
|
})
|
|
84
|
-
const setUserPreferences =
|
|
83
|
+
const setUserPreferences = jest.fn((preferences) => userPreferences.set(preferences))
|
|
85
84
|
|
|
86
85
|
editor = new TestEditor({
|
|
87
86
|
user: createTLUser({
|
|
@@ -102,7 +101,7 @@ describe('TLUserPreferences', () => {
|
|
|
102
101
|
id: '123',
|
|
103
102
|
name: 'blah',
|
|
104
103
|
})
|
|
105
|
-
const setUserPreferences =
|
|
104
|
+
const setUserPreferences = jest.fn((preferences) => userPreferences.set(preferences))
|
|
106
105
|
|
|
107
106
|
editor = new TestEditor({
|
|
108
107
|
user: createTLUser({
|
package/src/test/TestEditor.ts
CHANGED
|
@@ -34,7 +34,6 @@ import {
|
|
|
34
34
|
rotateSelectionHandle,
|
|
35
35
|
tlenv,
|
|
36
36
|
} from '@tldraw/editor'
|
|
37
|
-
import { vi } from 'vitest'
|
|
38
37
|
import { defaultBindingUtils } from '../lib/defaultBindingUtils'
|
|
39
38
|
import { defaultShapeTools } from '../lib/defaultShapeTools'
|
|
40
39
|
import { defaultShapeUtils } from '../lib/defaultShapeUtils'
|
|
@@ -43,14 +42,7 @@ import { defaultTools } from '../lib/defaultTools'
|
|
|
43
42
|
import { defaultAddFontsFromNode, tipTapDefaultExtensions } from '../lib/utils/text/richText'
|
|
44
43
|
import { shapesFromJsx } from './test-jsx'
|
|
45
44
|
|
|
46
|
-
|
|
47
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
48
|
-
interface Matchers<T = any> {
|
|
49
|
-
toCloselyMatchObject(expected: any, roundToNearest?: number): void
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
vi.useFakeTimers()
|
|
45
|
+
jest.useFakeTimers()
|
|
54
46
|
|
|
55
47
|
Object.assign(navigator, {
|
|
56
48
|
clipboard: {
|
|
@@ -63,6 +55,16 @@ Object.assign(navigator, {
|
|
|
63
55
|
// @ts-expect-error
|
|
64
56
|
window.ClipboardItem = class {}
|
|
65
57
|
|
|
58
|
+
declare global {
|
|
59
|
+
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
60
|
+
namespace jest {
|
|
61
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
62
|
+
interface Matchers<R> {
|
|
63
|
+
toCloselyMatchObject(value: any, precision?: number): void
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
66
68
|
export class TestEditor extends Editor {
|
|
67
69
|
constructor(
|
|
68
70
|
options: Partial<Omit<TLEditorOptions, 'store'>> = {},
|
|
@@ -80,8 +82,8 @@ export class TestEditor extends Editor {
|
|
|
80
82
|
right: 1080,
|
|
81
83
|
}
|
|
82
84
|
// make the app full screen for the sake of the insets property
|
|
83
|
-
|
|
84
|
-
|
|
85
|
+
jest.spyOn(document.body, 'scrollWidth', 'get').mockImplementation(() => bounds.width)
|
|
86
|
+
jest.spyOn(document.body, 'scrollHeight', 'get').mockImplementation(() => bounds.height)
|
|
85
87
|
|
|
86
88
|
elm.tabIndex = 0
|
|
87
89
|
elm.getBoundingClientRect = () => bounds as DOMRect
|
|
@@ -270,12 +272,12 @@ export class TestEditor extends Editor {
|
|
|
270
272
|
* methods, or call mockRestore() to restore the actual implementation (e.g.
|
|
271
273
|
* _transformPointerDownSpy.mockRestore())
|
|
272
274
|
*/
|
|
273
|
-
_transformPointerDownSpy =
|
|
275
|
+
_transformPointerDownSpy = jest
|
|
274
276
|
.spyOn(this._clickManager, 'handlePointerEvent')
|
|
275
277
|
.mockImplementation((info) => {
|
|
276
278
|
return info
|
|
277
279
|
})
|
|
278
|
-
_transformPointerUpSpy =
|
|
280
|
+
_transformPointerUpSpy = jest
|
|
279
281
|
.spyOn(this._clickManager, 'handlePointerEvent')
|
|
280
282
|
.mockImplementation((info) => {
|
|
281
283
|
return info
|
|
@@ -12,7 +12,6 @@ import {
|
|
|
12
12
|
noop,
|
|
13
13
|
} from '@tldraw/editor'
|
|
14
14
|
import { StrictMode } from 'react'
|
|
15
|
-
import { vi } from 'vitest'
|
|
16
15
|
import { defaultShapeUtils } from '../lib/defaultShapeUtils'
|
|
17
16
|
import { defaultTools } from '../lib/defaultTools'
|
|
18
17
|
import { GeoShapeUtil } from '../lib/shapes/geo/GeoShapeUtil'
|
|
@@ -90,7 +89,7 @@ describe('<TldrawEditor />', () => {
|
|
|
90
89
|
})
|
|
91
90
|
|
|
92
91
|
it('throws if the store has different shapes to the ones passed in', async () => {
|
|
93
|
-
const spy =
|
|
92
|
+
const spy = jest.spyOn(console, 'error').mockImplementation(noop)
|
|
94
93
|
// expect(() =>
|
|
95
94
|
// render(
|
|
96
95
|
// <TldrawEditor
|
|
@@ -130,7 +129,7 @@ describe('<TldrawEditor />', () => {
|
|
|
130
129
|
|
|
131
130
|
it('Accepts fresh versions of store and calls `onMount` for each one', async () => {
|
|
132
131
|
const initialStore = createTLStore({ shapeUtils: [], bindingUtils: [] })
|
|
133
|
-
const onMount =
|
|
132
|
+
const onMount = jest.fn()
|
|
134
133
|
const rendered = await renderTldrawComponent(
|
|
135
134
|
<TldrawEditor
|
|
136
135
|
initialState="select"
|
|
@@ -140,8 +139,8 @@ describe('<TldrawEditor />', () => {
|
|
|
140
139
|
/>,
|
|
141
140
|
{ waitForPatterns: false }
|
|
142
141
|
)
|
|
143
|
-
const initialEditor = onMount.mock.lastCall
|
|
144
|
-
|
|
142
|
+
const initialEditor = onMount.mock.lastCall[0]
|
|
143
|
+
jest.spyOn(initialEditor, 'dispose')
|
|
145
144
|
expect(initialEditor.store).toBe(initialStore)
|
|
146
145
|
// re-render with the same store:
|
|
147
146
|
rendered.rerender(
|
|
@@ -162,7 +161,7 @@ describe('<TldrawEditor />', () => {
|
|
|
162
161
|
await rendered.findAllByTestId('canvas')
|
|
163
162
|
expect(initialEditor.dispose).toHaveBeenCalledTimes(1)
|
|
164
163
|
expect(onMount).toHaveBeenCalledTimes(2)
|
|
165
|
-
expect(onMount.mock.lastCall
|
|
164
|
+
expect(onMount.mock.lastCall[0].store).toBe(newStore)
|
|
166
165
|
})
|
|
167
166
|
|
|
168
167
|
it('Renders the canvas and shapes', async () => {
|
|
@@ -228,7 +227,7 @@ describe('<TldrawEditor />', () => {
|
|
|
228
227
|
|
|
229
228
|
it('renders correctly in strict mode', async () => {
|
|
230
229
|
const editorInstances = new Set<Editor>()
|
|
231
|
-
const onMount =
|
|
230
|
+
const onMount = jest.fn((editor: Editor) => {
|
|
232
231
|
editorInstances.add(editor)
|
|
233
232
|
})
|
|
234
233
|
await renderTldrawComponent(
|
|
@@ -246,7 +245,7 @@ describe('<TldrawEditor />', () => {
|
|
|
246
245
|
|
|
247
246
|
it('allows updating camera options without re-creating the editor', async () => {
|
|
248
247
|
const editors: Editor[] = []
|
|
249
|
-
const onMount =
|
|
248
|
+
const onMount = jest.fn((editor: Editor) => {
|
|
250
249
|
if (!editors.includes(editor)) editors.push(editor)
|
|
251
250
|
})
|
|
252
251
|
|
|
@@ -362,7 +361,7 @@ describe('<TldrawEditor />', () => {
|
|
|
362
361
|
})
|
|
363
362
|
|
|
364
363
|
it('passes through the `assets` prop when creating its own in-memory store', async () => {
|
|
365
|
-
const myUploadFn =
|
|
364
|
+
const myUploadFn = jest.fn()
|
|
366
365
|
const assetStore: TLAssetStore = { upload: myUploadFn }
|
|
367
366
|
|
|
368
367
|
const { editor } = await renderTldrawComponentWithEditor(
|
|
@@ -376,7 +375,7 @@ describe('<TldrawEditor />', () => {
|
|
|
376
375
|
})
|
|
377
376
|
|
|
378
377
|
it('passes through the `assets` prop when using `persistenceKey`', async () => {
|
|
379
|
-
const myUploadFn =
|
|
378
|
+
const myUploadFn = jest.fn()
|
|
380
379
|
const assetStore: TLAssetStore = { upload: myUploadFn }
|
|
381
380
|
|
|
382
381
|
const { editor } = await renderTldrawComponentWithEditor(
|
|
@@ -395,7 +394,7 @@ describe('<TldrawEditor />', () => {
|
|
|
395
394
|
})
|
|
396
395
|
|
|
397
396
|
it('will not re-create the editor if re-rendered with identical options', async () => {
|
|
398
|
-
const onMount =
|
|
397
|
+
const onMount = jest.fn()
|
|
399
398
|
|
|
400
399
|
const renderer = await renderTldrawComponent(
|
|
401
400
|
<TldrawEditor onMount={onMount} options={{ maxPages: 1 }} />,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { createShapeId } from '@tldraw/editor'
|
|
2
|
-
import { vi } from 'vitest'
|
|
3
2
|
import { TestEditor } from './TestEditor'
|
|
4
3
|
|
|
5
4
|
let editor: TestEditor
|
|
@@ -8,7 +7,7 @@ const ids = {
|
|
|
8
7
|
box1: createShapeId('box1'),
|
|
9
8
|
}
|
|
10
9
|
|
|
11
|
-
|
|
10
|
+
jest.useFakeTimers()
|
|
12
11
|
|
|
13
12
|
beforeEach(() => {
|
|
14
13
|
editor = new TestEditor()
|
|
@@ -45,7 +44,7 @@ describe('TLSelectTool.Zooming', () => {
|
|
|
45
44
|
expect(editor.getViewportPageCenter()).toMatchObject({ x: 540, y: 360 })
|
|
46
45
|
editor.click()
|
|
47
46
|
editor.expectToBeIn('zoom.idle')
|
|
48
|
-
|
|
47
|
+
jest.advanceTimersByTime(300)
|
|
49
48
|
expect(editor.getZoomLevel()).toBe(2)
|
|
50
49
|
})
|
|
51
50
|
|
|
@@ -56,7 +55,7 @@ describe('TLSelectTool.Zooming', () => {
|
|
|
56
55
|
expect(editor.getViewportPageBounds()).toMatchObject({ x: -0, y: -0, w: 1080, h: 720 })
|
|
57
56
|
expect(editor.getViewportPageCenter()).toMatchObject({ x: 540, y: 360 })
|
|
58
57
|
editor.click()
|
|
59
|
-
|
|
58
|
+
jest.advanceTimersByTime(300)
|
|
60
59
|
expect(editor.getZoomLevel()).toBe(0.5)
|
|
61
60
|
})
|
|
62
61
|
|
|
@@ -123,7 +122,7 @@ describe('TLSelectTool.Zooming', () => {
|
|
|
123
122
|
editor.expectToBeIn('zoom.zoom_brushing')
|
|
124
123
|
editor.pointerUp(change, change)
|
|
125
124
|
editor.expectToBeIn('zoom.idle')
|
|
126
|
-
|
|
125
|
+
jest.advanceTimersByTime(300)
|
|
127
126
|
expect(editor.getZoomLevel()).toBe(2)
|
|
128
127
|
expect(editor.getViewportPageBounds()).toMatchObject({
|
|
129
128
|
x: change / 2,
|
|
@@ -157,7 +156,7 @@ describe('TLSelectTool.Zooming', () => {
|
|
|
157
156
|
h: newBoundsHeight,
|
|
158
157
|
})
|
|
159
158
|
editor.pointerUp(newBoundsX + newBoundsWidth, newBoundsY + newBoundsHeight)
|
|
160
|
-
|
|
159
|
+
jest.advanceTimersByTime(300)
|
|
161
160
|
expect(editor.getZoomLevel()).toBeCloseTo(1.64)
|
|
162
161
|
expect(editor.getViewportPageBounds()).toMatchInlineSnapshot(`
|
|
163
162
|
Box {
|
|
@@ -196,7 +195,7 @@ describe('TLSelectTool.Zooming', () => {
|
|
|
196
195
|
h: newBoundsHeight,
|
|
197
196
|
})
|
|
198
197
|
editor.pointerUp()
|
|
199
|
-
|
|
198
|
+
jest.advanceTimersByTime(500)
|
|
200
199
|
expect(editor.getZoomLevel()).toBeCloseTo(originalZoomLevel / 2)
|
|
201
200
|
expect(editor.getViewportPageBounds()).toMatchObject({
|
|
202
201
|
x: -440,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
//
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`creating new shapes
|
|
3
|
+
exports[`creating new shapes pencil lines will reisze the group appropriately if the new shape changes the group bounds: box shape after second resize 1`] = `
|
|
4
4
|
{
|
|
5
5
|
"h": 40,
|
|
6
6
|
"w": 40,
|
|
@@ -9,7 +9,7 @@ exports[`creating new shapes > pencil > lines > will reisze the group appropriat
|
|
|
9
9
|
}
|
|
10
10
|
`;
|
|
11
11
|
|
|
12
|
-
exports[`creating new shapes
|
|
12
|
+
exports[`creating new shapes pencil lines will reisze the group appropriately if the new shape changes the group bounds: group shape after second resize 1`] = `
|
|
13
13
|
{
|
|
14
14
|
"h": 120,
|
|
15
15
|
"w": 120,
|
|
@@ -18,7 +18,7 @@ exports[`creating new shapes > pencil > lines > will reisze the group appropriat
|
|
|
18
18
|
}
|
|
19
19
|
`;
|
|
20
20
|
|
|
21
|
-
exports[`creating new shapes
|
|
21
|
+
exports[`creating new shapes pencil lines will reisze the group appropriately if the new shape changes the group bounds: group with line shape 1`] = `
|
|
22
22
|
Box {
|
|
23
23
|
"h": 110,
|
|
24
24
|
"w": 110,
|
|
@@ -27,7 +27,7 @@ Box {
|
|
|
27
27
|
}
|
|
28
28
|
`;
|
|
29
29
|
|
|
30
|
-
exports[`creating new shapes
|
|
30
|
+
exports[`creating new shapes pencil lines works if the shape drawing begins outside of the current group bounds: box shape after resize 1`] = `
|
|
31
31
|
{
|
|
32
32
|
"h": 50,
|
|
33
33
|
"w": 50,
|
|
@@ -36,7 +36,7 @@ exports[`creating new shapes > pencil > lines > works if the shape drawing begin
|
|
|
36
36
|
}
|
|
37
37
|
`;
|
|
38
38
|
|
|
39
|
-
exports[`creating new shapes
|
|
39
|
+
exports[`creating new shapes pencil lines works if the shape drawing begins outside of the current group bounds: group with line 1`] = `
|
|
40
40
|
{
|
|
41
41
|
"h": 200,
|
|
42
42
|
"w": 200,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
//
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`When resizing a shape with children
|
|
3
|
+
exports[`When resizing a shape with children Resizes a rotated draw shape: draw shape after rotating 1`] = `
|
|
4
4
|
{
|
|
5
5
|
"id": "shape:lineA",
|
|
6
6
|
"index": "a3",
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { TLArrowShape, TLShapeId, Vec, createShapeId } from '@tldraw/editor'
|
|
2
|
-
import { vi } from 'vitest'
|
|
3
2
|
import { getArrowBindings } from '../lib/shapes/arrow/shared'
|
|
4
3
|
import { TestEditor } from './TestEditor'
|
|
5
4
|
import { TL } from './test-jsx'
|
|
@@ -209,7 +208,7 @@ describe('When binding an arrow to a shape', () => {
|
|
|
209
208
|
|
|
210
209
|
editor.keyUp('Control')
|
|
211
210
|
expect(bindings().end).toBeUndefined() // there's a short delay here, it should still be a point
|
|
212
|
-
|
|
211
|
+
jest.advanceTimersByTime(1000) // once the timer runs out...
|
|
213
212
|
expect(bindings().end).toBeDefined()
|
|
214
213
|
|
|
215
214
|
editor.keyDown('Control') // no delay when pressing control again though
|
|
@@ -217,7 +216,7 @@ describe('When binding an arrow to a shape', () => {
|
|
|
217
216
|
|
|
218
217
|
editor.keyUp('Control')
|
|
219
218
|
editor.pointerUp()
|
|
220
|
-
|
|
219
|
+
jest.advanceTimersByTime(1000) // once the timer runs out...
|
|
221
220
|
expect(bindings().end).toBeUndefined() // still a point because interaction ended before timer ended
|
|
222
221
|
})
|
|
223
222
|
|
|
@@ -238,7 +237,7 @@ describe('When binding an arrow to a shape', () => {
|
|
|
238
237
|
// Releasing ctrl should restore binding (after timer)
|
|
239
238
|
editor.keyUp('Control')
|
|
240
239
|
expect(bindings().end).toBeUndefined() // Still no binding immediately
|
|
241
|
-
|
|
240
|
+
jest.advanceTimersByTime(1000)
|
|
242
241
|
expect(bindings().end).toBeDefined()
|
|
243
242
|
})
|
|
244
243
|
})
|
|
@@ -289,13 +288,11 @@ describe('When shapes are overlapping', () => {
|
|
|
289
288
|
editor.pointerDown(0, 50) // over nothing
|
|
290
289
|
editor.pointerMove(125, 50) // over box1 only
|
|
291
290
|
expect(bindings().end).toMatchObject({ toId: ids.box1 })
|
|
292
|
-
editor.pointerMove(175, 50) // box2 is higher but box1 is filled
|
|
293
|
-
expect(bindings().end).toMatchObject({ toId: ids.box2 })
|
|
294
|
-
editor.pointerMove(175, 70) // box2 is higher but box1 is filled, and we're inside of box2
|
|
291
|
+
editor.pointerMove(175, 50) // box2 is higher but box1 is filled?
|
|
295
292
|
expect(bindings().end).toMatchObject({ toId: ids.box1 })
|
|
296
|
-
editor.pointerMove(225,
|
|
293
|
+
editor.pointerMove(225, 50) // box3 is higher
|
|
297
294
|
expect(bindings().end).toMatchObject({ toId: ids.box3 })
|
|
298
|
-
editor.pointerMove(275,
|
|
295
|
+
editor.pointerMove(275, 50) // box4 is higher but box 3 is filled
|
|
299
296
|
expect(bindings().end).toMatchObject({ toId: ids.box3 })
|
|
300
297
|
})
|
|
301
298
|
|
|
@@ -307,18 +304,14 @@ describe('When shapes are overlapping', () => {
|
|
|
307
304
|
])
|
|
308
305
|
editor.setCurrentTool('arrow')
|
|
309
306
|
editor.pointerDown(0, 50)
|
|
310
|
-
editor.pointerMove(175, 50) // box1 is smaller even though it's behind box2
|
|
311
|
-
expect(bindings().end).toMatchObject({ toId: ids.box2 })
|
|
312
|
-
editor.pointerMove(175, 70) // box1 is smaller even though it's behind box2
|
|
307
|
+
editor.pointerMove(175, 50) // box1 is smaller even though it's behind box2
|
|
313
308
|
expect(bindings().end).toMatchObject({ toId: ids.box1 })
|
|
314
|
-
editor.pointerMove(150, 90) // box3 is smaller and at the front
|
|
315
|
-
expect(bindings().end).toMatchObject({ toId: ids.box2 })
|
|
316
|
-
editor.pointerMove(160, 90) // box3 is smaller and at the front and we're in box1 and box 3 and box 2
|
|
309
|
+
editor.pointerMove(150, 90) // box3 is smaller and at the front
|
|
317
310
|
expect(bindings().end).toMatchObject({ toId: ids.box3 })
|
|
318
311
|
editor.sendToBack([ids.box3])
|
|
319
312
|
editor.pointerMove(149, 90) // box3 is smaller, even when at the back
|
|
320
313
|
expect(bindings().end).toMatchObject({ toId: ids.box3 })
|
|
321
|
-
editor.pointerMove(175,
|
|
314
|
+
editor.pointerMove(175, 50)
|
|
322
315
|
expect(bindings().end).toMatchObject({ toId: ids.box1 })
|
|
323
316
|
})
|
|
324
317
|
})
|
|
@@ -410,7 +403,7 @@ describe('When starting an arrow inside of multiple shapes', () => {
|
|
|
410
403
|
editor.pointerDown(20, 20) // upper left
|
|
411
404
|
expect(editor.getCurrentPageShapes().length).toBe(1)
|
|
412
405
|
expect(arrow()).toBe(null)
|
|
413
|
-
|
|
406
|
+
jest.advanceTimersByTime(1000)
|
|
414
407
|
editor.pointerMove(25, 20)
|
|
415
408
|
expect(editor.getCurrentPageShapes().length).toBe(2)
|
|
416
409
|
expect(arrow()).toMatchObject({ x: 20, y: 20 })
|
|
@@ -11,7 +11,6 @@ import {
|
|
|
11
11
|
createBindingId,
|
|
12
12
|
createShapeId,
|
|
13
13
|
} from '@tldraw/editor'
|
|
14
|
-
import { vi } from 'vitest'
|
|
15
14
|
import { TestEditor } from './TestEditor'
|
|
16
15
|
import { TL } from './test-jsx'
|
|
17
16
|
|
|
@@ -24,19 +23,37 @@ const ids = {
|
|
|
24
23
|
box4: createShapeId('box4'),
|
|
25
24
|
}
|
|
26
25
|
|
|
27
|
-
const mockOnOperationComplete =
|
|
28
|
-
const mockOnBeforeDelete =
|
|
29
|
-
const mockOnAfterDelete =
|
|
30
|
-
const mockOnBeforeFromShapeDelete =
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
|
|
26
|
+
const mockOnOperationComplete = jest.fn() as jest.Mock<void, []>
|
|
27
|
+
const mockOnBeforeDelete = jest.fn() as jest.Mock<void, [BindingOnDeleteOptions<TLUnknownBinding>]>
|
|
28
|
+
const mockOnAfterDelete = jest.fn() as jest.Mock<void, [BindingOnDeleteOptions<TLUnknownBinding>]>
|
|
29
|
+
const mockOnBeforeFromShapeDelete = jest.fn() as jest.Mock<
|
|
30
|
+
void,
|
|
31
|
+
[BindingOnShapeDeleteOptions<TLUnknownBinding>]
|
|
32
|
+
>
|
|
33
|
+
const mockOnBeforeToShapeDelete = jest.fn() as jest.Mock<
|
|
34
|
+
void,
|
|
35
|
+
[BindingOnShapeDeleteOptions<TLUnknownBinding>]
|
|
36
|
+
>
|
|
37
|
+
const mockOnBeforeFromShapeIsolate = jest.fn() as jest.Mock<
|
|
38
|
+
void,
|
|
39
|
+
[BindingOnShapeIsolateOptions<TLUnknownBinding>]
|
|
40
|
+
>
|
|
41
|
+
const mockOnBeforeToShapeIsolate = jest.fn() as jest.Mock<
|
|
42
|
+
void,
|
|
43
|
+
[BindingOnShapeIsolateOptions<TLUnknownBinding>]
|
|
44
|
+
>
|
|
45
|
+
const mockOnBeforeCreate = jest.fn() as jest.Mock<void, [BindingOnCreateOptions<TLUnknownBinding>]>
|
|
46
|
+
const mockOnAfterCreate = jest.fn() as jest.Mock<void, [BindingOnCreateOptions<TLUnknownBinding>]>
|
|
47
|
+
const mockOnBeforeChange = jest.fn() as jest.Mock<void, [BindingOnChangeOptions<TLUnknownBinding>]>
|
|
48
|
+
const mockOnAfterChange = jest.fn() as jest.Mock<void, [BindingOnChangeOptions<TLUnknownBinding>]>
|
|
49
|
+
const mockOnAfterChangeFromShape = jest.fn() as jest.Mock<
|
|
50
|
+
void,
|
|
51
|
+
[BindingOnShapeChangeOptions<TLUnknownBinding>]
|
|
52
|
+
>
|
|
53
|
+
const mockOnAfterChangeToShape = jest.fn() as jest.Mock<
|
|
54
|
+
void,
|
|
55
|
+
[BindingOnShapeChangeOptions<TLUnknownBinding>]
|
|
56
|
+
>
|
|
40
57
|
|
|
41
58
|
const calls: string[] = []
|
|
42
59
|
|
|
@@ -256,11 +273,9 @@ test('copying the to shape on its own does trigger the unbind operation', () =>
|
|
|
256
273
|
})
|
|
257
274
|
|
|
258
275
|
test('cascading deletes in beforeFromShapeDelete are handled correctly', () => {
|
|
259
|
-
mockOnBeforeFromShapeDelete.mockImplementation(
|
|
260
|
-
(options
|
|
261
|
-
|
|
262
|
-
}
|
|
263
|
-
)
|
|
276
|
+
mockOnBeforeFromShapeDelete.mockImplementation((options) => {
|
|
277
|
+
editor.deleteShape(options.binding.toId)
|
|
278
|
+
})
|
|
264
279
|
|
|
265
280
|
bindShapes(ids.box1, ids.box2)
|
|
266
281
|
bindShapes(ids.box2, ids.box3)
|
|
@@ -301,11 +316,9 @@ test('cascading deletes in beforeFromShapeDelete are handled correctly', () => {
|
|
|
301
316
|
})
|
|
302
317
|
|
|
303
318
|
test('cascading deletes in beforeToShapeDelete are handled correctly', () => {
|
|
304
|
-
mockOnBeforeToShapeDelete.mockImplementation(
|
|
305
|
-
(options
|
|
306
|
-
|
|
307
|
-
}
|
|
308
|
-
)
|
|
319
|
+
mockOnBeforeToShapeDelete.mockImplementation((options) => {
|
|
320
|
+
editor.deleteShape(options.binding.fromId)
|
|
321
|
+
})
|
|
309
322
|
|
|
310
323
|
bindShapes(ids.box1, ids.box2)
|
|
311
324
|
bindShapes(ids.box2, ids.box3)
|