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,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
|
|
@@ -41,20 +40,20 @@ beforeEach(() => {
|
|
|
41
40
|
})
|
|
42
41
|
|
|
43
42
|
describe('editor.rotateShapesBy', () => {
|
|
44
|
-
let fnStart =
|
|
45
|
-
let fnChange =
|
|
46
|
-
let fnEnd =
|
|
43
|
+
let fnStart = jest.fn()
|
|
44
|
+
let fnChange = jest.fn()
|
|
45
|
+
let fnEnd = jest.fn()
|
|
47
46
|
|
|
48
47
|
beforeEach(() => {
|
|
49
48
|
// Set start / change / end events on only the geo shape
|
|
50
49
|
const util = editor.getShapeUtil('geo')
|
|
51
50
|
|
|
52
51
|
// Bad! who did this (did I do this)
|
|
53
|
-
util.onRotateStart = fnStart =
|
|
52
|
+
util.onRotateStart = fnStart = jest.fn()
|
|
54
53
|
|
|
55
|
-
util.onRotate = fnChange =
|
|
54
|
+
util.onRotate = fnChange = jest.fn()
|
|
56
55
|
|
|
57
|
-
util.onRotateEnd = fnEnd =
|
|
56
|
+
util.onRotateEnd = fnEnd = jest.fn()
|
|
58
57
|
})
|
|
59
58
|
it('Rotates shapes and fires events', () => {
|
|
60
59
|
// Select the shape...
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Box, DEFAULT_CAMERA_OPTIONS, Vec, createShapeId } from '@tldraw/editor'
|
|
2
|
-
import { vi } from 'vitest'
|
|
3
2
|
import { TestEditor } from '../TestEditor'
|
|
4
3
|
|
|
5
4
|
let editor: TestEditor
|
|
@@ -367,14 +366,14 @@ describe('CameraOptions.zoomSpeed', () => {
|
|
|
367
366
|
editor.setCameraOptions({ ...DEFAULT_CAMERA_OPTIONS, zoomSpeed: 2 })
|
|
368
367
|
expect(editor.getCamera()).toMatchObject({ x: 0, y: 0, z: 1 })
|
|
369
368
|
editor.setCurrentTool('zoom').click()
|
|
370
|
-
|
|
369
|
+
jest.advanceTimersByTime(300)
|
|
371
370
|
expect(editor.getCamera()).toMatchObject({ x: 0, y: 0, z: 2 })
|
|
372
371
|
})
|
|
373
372
|
it('Does not affect zoom tool zooming (0.5x)', () => {
|
|
374
373
|
editor.setCameraOptions({ ...DEFAULT_CAMERA_OPTIONS, zoomSpeed: 0.5 })
|
|
375
374
|
expect(editor.getCamera()).toMatchObject({ x: 0, y: 0, z: 1 })
|
|
376
375
|
editor.setCurrentTool('zoom').click()
|
|
377
|
-
|
|
376
|
+
jest.advanceTimersByTime(300)
|
|
378
377
|
expect(editor.getCamera()).toMatchObject({ x: 0, y: 0, z: 2 })
|
|
379
378
|
})
|
|
380
379
|
it('Does not affect editor zoom method (2x)', () => {
|
|
@@ -1029,7 +1028,7 @@ describe('Allows mixed values for x and y', () => {
|
|
|
1029
1028
|
|
|
1030
1029
|
test('it animated towards the constrained viewport rather than the given viewport', () => {
|
|
1031
1030
|
// @ts-expect-error
|
|
1032
|
-
const mockAnimateToViewport = (editor._animateToViewport =
|
|
1031
|
+
const mockAnimateToViewport = (editor._animateToViewport = jest.fn())
|
|
1033
1032
|
editor.setCameraOptions({
|
|
1034
1033
|
...DEFAULT_CAMERA_OPTIONS,
|
|
1035
1034
|
constraints: {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { IndexKey, PageRecordType, TLPageId, createShapeId } from '@tldraw/editor'
|
|
2
|
-
import { vi } from 'vitest'
|
|
3
2
|
import { TestEditor } from '../TestEditor'
|
|
4
3
|
|
|
5
4
|
let editor: TestEditor
|
|
@@ -77,7 +76,7 @@ describe('setCurrentPage', () => {
|
|
|
77
76
|
it('logs an error when trying to navigate to a page that does not exist', () => {
|
|
78
77
|
const initialPageId = editor.getCurrentPageId()
|
|
79
78
|
expect(editor.getCurrentPageId()).toBe(initialPageId)
|
|
80
|
-
console.error =
|
|
79
|
+
console.error = jest.fn()
|
|
81
80
|
|
|
82
81
|
expect(() => {
|
|
83
82
|
editor.setCurrentPage('page:does-not-exist' as TLPageId)
|
|
@@ -106,7 +105,7 @@ describe('setCurrentPage', () => {
|
|
|
106
105
|
})
|
|
107
106
|
|
|
108
107
|
it('applies camera constraints', () => {
|
|
109
|
-
const spy =
|
|
108
|
+
const spy = jest.spyOn(editor, 'setCamera')
|
|
110
109
|
|
|
111
110
|
let currentPageId = editor.getCurrentPageId()
|
|
112
111
|
expect(currentPageId).toMatchInlineSnapshot(`"page:page"`)
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { createShapeId } from '@tldraw/editor'
|
|
2
|
-
import { vi } from 'vitest'
|
|
3
2
|
import { TestEditor } from '../TestEditor'
|
|
4
3
|
|
|
5
|
-
|
|
4
|
+
jest.useFakeTimers()
|
|
6
5
|
|
|
7
6
|
let editor: TestEditor
|
|
8
7
|
|
|
@@ -52,10 +51,10 @@ describe('distributeShapes command', () => {
|
|
|
52
51
|
describe('when less than three shapes are selected', () => {
|
|
53
52
|
it('does nothing', () => {
|
|
54
53
|
editor.setSelectedShapes([ids.boxA, ids.boxB])
|
|
55
|
-
const fn =
|
|
54
|
+
const fn = jest.fn()
|
|
56
55
|
editor.store.listen(fn)
|
|
57
56
|
editor.stackShapes(editor.getSelectedShapeIds(), 'horizontal', 0)
|
|
58
|
-
|
|
57
|
+
jest.advanceTimersByTime(1000)
|
|
59
58
|
expect(fn).not.toHaveBeenCalled()
|
|
60
59
|
})
|
|
61
60
|
})
|
|
@@ -66,7 +65,7 @@ describe('distributeShapes command', () => {
|
|
|
66
65
|
// @ts-expect-error
|
|
67
66
|
editor.options.adjacentShapeMargin = 1
|
|
68
67
|
editor.stackShapes(editor.getSelectedShapeIds(), 'horizontal')
|
|
69
|
-
|
|
68
|
+
jest.advanceTimersByTime(1000)
|
|
70
69
|
// 200 distance gap between c and d
|
|
71
70
|
editor.expectShapeToMatch({
|
|
72
71
|
id: ids.boxA,
|
|
@@ -93,7 +92,7 @@ describe('distributeShapes command', () => {
|
|
|
93
92
|
it('stacks the shapes based on a given value', () => {
|
|
94
93
|
editor.setSelectedShapes([ids.boxA, ids.boxB, ids.boxC, ids.boxD])
|
|
95
94
|
editor.stackShapes(editor.getSelectedShapeIds(), 'horizontal', 10)
|
|
96
|
-
|
|
95
|
+
jest.advanceTimersByTime(1000)
|
|
97
96
|
// 200 distance gap between c and d
|
|
98
97
|
editor.expectShapeToMatch({
|
|
99
98
|
id: ids.boxA,
|
|
@@ -120,7 +119,7 @@ describe('distributeShapes command', () => {
|
|
|
120
119
|
it('stacks the shapes based on the most common gap', () => {
|
|
121
120
|
editor.setSelectedShapes([ids.boxA, ids.boxB, ids.boxC, ids.boxD])
|
|
122
121
|
editor.stackShapes(editor.getSelectedShapeIds(), 'horizontal', 0)
|
|
123
|
-
|
|
122
|
+
jest.advanceTimersByTime(1000)
|
|
124
123
|
// 200 distance gap between c and d
|
|
125
124
|
editor.expectShapeToMatch({
|
|
126
125
|
id: ids.boxA,
|
|
@@ -148,7 +147,7 @@ describe('distributeShapes command', () => {
|
|
|
148
147
|
editor.updateShapes([{ id: ids.boxD, type: 'geo', x: 540, y: 700 }])
|
|
149
148
|
editor.setSelectedShapes([ids.boxA, ids.boxB, ids.boxC, ids.boxD])
|
|
150
149
|
editor.stackShapes(editor.getSelectedShapeIds(), 'horizontal', 0)
|
|
151
|
-
|
|
150
|
+
jest.advanceTimersByTime(1000)
|
|
152
151
|
editor.expectShapeToMatch({
|
|
153
152
|
id: ids.boxA,
|
|
154
153
|
x: 0,
|
|
@@ -176,7 +175,7 @@ describe('distributeShapes command', () => {
|
|
|
176
175
|
it('stacks the shapes based on a given value', () => {
|
|
177
176
|
editor.setSelectedShapes([ids.boxA, ids.boxB, ids.boxC, ids.boxD])
|
|
178
177
|
editor.stackShapes(editor.getSelectedShapeIds(), 'vertical', 10)
|
|
179
|
-
|
|
178
|
+
jest.advanceTimersByTime(1000)
|
|
180
179
|
// 200 distance gap between c and d
|
|
181
180
|
editor.expectShapeToMatch({
|
|
182
181
|
id: ids.boxA,
|
|
@@ -203,7 +202,7 @@ describe('distributeShapes command', () => {
|
|
|
203
202
|
it('stacks the shapes based on the most common gap', () => {
|
|
204
203
|
editor.setSelectedShapes([ids.boxA, ids.boxB, ids.boxC, ids.boxD])
|
|
205
204
|
editor.stackShapes(editor.getSelectedShapeIds(), 'vertical', 0)
|
|
206
|
-
|
|
205
|
+
jest.advanceTimersByTime(1000)
|
|
207
206
|
// 200 distance gap between c and d
|
|
208
207
|
editor.expectShapeToMatch({
|
|
209
208
|
id: ids.boxA,
|
|
@@ -231,7 +230,7 @@ describe('distributeShapes command', () => {
|
|
|
231
230
|
editor.updateShapes([{ id: ids.boxD, type: 'geo', x: 700, y: 540 }])
|
|
232
231
|
editor.setSelectedShapes([ids.boxA, ids.boxB, ids.boxC, ids.boxD])
|
|
233
232
|
editor.stackShapes(editor.getSelectedShapeIds(), 'vertical', 0)
|
|
234
|
-
|
|
233
|
+
jest.advanceTimersByTime(1000)
|
|
235
234
|
editor.expectShapeToMatch({
|
|
236
235
|
id: ids.boxA,
|
|
237
236
|
x: 0,
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { PI, TLShapeId } from '@tldraw/editor'
|
|
2
|
-
import { vi } from 'vitest'
|
|
3
2
|
import { TestEditor } from '../TestEditor'
|
|
4
3
|
import { TL } from '../test-jsx'
|
|
5
4
|
|
|
6
5
|
let editor: TestEditor
|
|
7
6
|
let ids: Record<string, TLShapeId>
|
|
8
7
|
|
|
9
|
-
|
|
8
|
+
jest.useFakeTimers()
|
|
10
9
|
|
|
11
10
|
function createVideoShape() {
|
|
12
11
|
return editor.createShapesFromJsx(<TL.video ref="video1" x={0} y={0} w={160} h={90} />).video1
|
|
@@ -27,10 +26,10 @@ beforeEach(() => {
|
|
|
27
26
|
describe('when less than two shapes are selected', () => {
|
|
28
27
|
it('does nothing', () => {
|
|
29
28
|
editor.setSelectedShapes([ids.boxB])
|
|
30
|
-
const fn =
|
|
29
|
+
const fn = jest.fn()
|
|
31
30
|
editor.store.listen(fn)
|
|
32
31
|
editor.stretchShapes(editor.getSelectedShapeIds(), 'horizontal')
|
|
33
|
-
|
|
32
|
+
jest.advanceTimersByTime(1000)
|
|
34
33
|
|
|
35
34
|
expect(fn).not.toHaveBeenCalled()
|
|
36
35
|
})
|
|
@@ -40,7 +39,7 @@ describe('when multiple shapes are selected', () => {
|
|
|
40
39
|
it('stretches horizontally', () => {
|
|
41
40
|
editor.selectAll()
|
|
42
41
|
editor.stretchShapes(editor.getSelectedShapeIds(), 'horizontal')
|
|
43
|
-
|
|
42
|
+
jest.advanceTimersByTime(1000)
|
|
44
43
|
editor.expectShapeToMatch(
|
|
45
44
|
{ id: ids.boxA, x: 0, y: 0, props: { w: 500 } },
|
|
46
45
|
{ id: ids.boxB, x: 0, y: 100, props: { w: 500 } },
|
|
@@ -53,7 +52,7 @@ describe('when multiple shapes are selected', () => {
|
|
|
53
52
|
editor.selectAll()
|
|
54
53
|
expect(editor.getSelectedShapes().length).toBe(4)
|
|
55
54
|
editor.stretchShapes(editor.getSelectedShapeIds(), 'horizontal')
|
|
56
|
-
|
|
55
|
+
jest.advanceTimersByTime(1000)
|
|
57
56
|
const newHeight = (500 * 9) / 16
|
|
58
57
|
editor.expectShapeToMatch(
|
|
59
58
|
{ id: ids.boxA, x: 0, y: 0, props: { w: 500 } },
|
|
@@ -66,7 +65,7 @@ describe('when multiple shapes are selected', () => {
|
|
|
66
65
|
it('stretches vertically', () => {
|
|
67
66
|
editor.selectAll()
|
|
68
67
|
editor.stretchShapes(editor.getSelectedShapeIds(), 'vertical')
|
|
69
|
-
|
|
68
|
+
jest.advanceTimersByTime(1000)
|
|
70
69
|
editor.expectShapeToMatch(
|
|
71
70
|
{ id: ids.boxA, x: 0, y: 0, props: { h: 500 } },
|
|
72
71
|
{ id: ids.boxB, x: 100, y: 0, props: { h: 500 } },
|
|
@@ -79,7 +78,7 @@ describe('when multiple shapes are selected', () => {
|
|
|
79
78
|
editor.selectAll()
|
|
80
79
|
expect(editor.getSelectedShapes().length).toBe(4)
|
|
81
80
|
editor.stretchShapes(editor.getSelectedShapeIds(), 'vertical')
|
|
82
|
-
|
|
81
|
+
jest.advanceTimersByTime(1000)
|
|
83
82
|
const newWidth = (500 * 16) / 9
|
|
84
83
|
editor.expectShapeToMatch(
|
|
85
84
|
{ id: ids.boxA, x: 0, y: 0, props: { h: 500 } },
|
|
@@ -92,7 +91,7 @@ describe('when multiple shapes are selected', () => {
|
|
|
92
91
|
it('does, undoes and redoes command', () => {
|
|
93
92
|
editor.markHistoryStoppingPoint('stretch')
|
|
94
93
|
editor.stretchShapes(editor.getSelectedShapeIds(), 'horizontal')
|
|
95
|
-
|
|
94
|
+
jest.advanceTimersByTime(1000)
|
|
96
95
|
|
|
97
96
|
editor.expectShapeToMatch({ id: ids.boxB, x: 0, props: { w: 500 } })
|
|
98
97
|
editor.undo()
|
|
@@ -107,7 +106,7 @@ describe('When shapes are the child of another shape.', () => {
|
|
|
107
106
|
editor.reparentShapes([ids.boxB], ids.boxA)
|
|
108
107
|
editor.select(ids.boxB, ids.boxC)
|
|
109
108
|
editor.stretchShapes(editor.getSelectedShapeIds(), 'horizontal')
|
|
110
|
-
|
|
109
|
+
jest.advanceTimersByTime(1000)
|
|
111
110
|
editor.expectShapeToMatch(
|
|
112
111
|
{ id: ids.boxB, x: 100, y: 100, props: { w: 400 } },
|
|
113
112
|
{ id: ids.boxC, x: 100, y: 400, props: { w: 400 } }
|
|
@@ -118,7 +117,7 @@ describe('When shapes are the child of another shape.', () => {
|
|
|
118
117
|
editor.reparentShapes([ids.boxB], ids.boxA)
|
|
119
118
|
editor.select(ids.boxB, ids.boxC)
|
|
120
119
|
editor.stretchShapes(editor.getSelectedShapeIds(), 'vertical')
|
|
121
|
-
|
|
120
|
+
jest.advanceTimersByTime(1000)
|
|
122
121
|
editor.expectShapeToMatch(
|
|
123
122
|
{ id: ids.boxB, x: 100, y: 100, props: { h: 400 } },
|
|
124
123
|
{ id: ids.boxC, x: 400, y: 100, props: { h: 400 } }
|
|
@@ -141,7 +140,7 @@ describe('When shapes are the child of a rotated shape.', () => {
|
|
|
141
140
|
|
|
142
141
|
editor.select(ids.boxA, ids.boxC)
|
|
143
142
|
editor.stretchShapes(editor.getSelectedShapeIds(), 'horizontal')
|
|
144
|
-
|
|
143
|
+
jest.advanceTimersByTime(1000)
|
|
145
144
|
editor.expectShapeToMatch(
|
|
146
145
|
{
|
|
147
146
|
id: ids.boxA,
|
|
@@ -185,7 +184,7 @@ describe('When shapes are the child of a rotated shape.', () => {
|
|
|
185
184
|
editor.selectAll()
|
|
186
185
|
|
|
187
186
|
editor.stretchShapes(editor.getSelectedShapeIds(), 'vertical')
|
|
188
|
-
|
|
187
|
+
jest.advanceTimersByTime(1000)
|
|
189
188
|
editor.expectShapeToMatch(
|
|
190
189
|
{
|
|
191
190
|
id: ids.boxA,
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { createShapeId, TLImageShape } from '@tldraw/editor'
|
|
2
|
-
import { vi } from 'vitest'
|
|
3
2
|
import { MIN_CROP_SIZE } from '../lib/shapes/shared/crop'
|
|
4
3
|
import { TestEditor } from './TestEditor'
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
jest.useFakeTimers()
|
|
7
6
|
|
|
8
7
|
let editor: TestEditor
|
|
9
8
|
|
|
@@ -496,7 +495,7 @@ describe('When in the select.crop.translating_crop state', () => {
|
|
|
496
495
|
})
|
|
497
496
|
|
|
498
497
|
editor.keyUp('Shift')
|
|
499
|
-
|
|
498
|
+
jest.advanceTimersByTime(500)
|
|
500
499
|
|
|
501
500
|
const afterShiftUp = editor.getShape<TLImageShape>(ids.imageB)!.props.crop!
|
|
502
501
|
|
package/src/test/drawing.test.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { TLDrawShape, TLHighlightShape, last } from '@tldraw/editor'
|
|
2
|
-
import { vi } from 'vitest'
|
|
3
2
|
import { TestEditor } from './TestEditor'
|
|
4
3
|
import { TEST_DRAW_SHAPE_SCREEN_POINTS } from './drawing.data'
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
jest.useFakeTimers()
|
|
7
6
|
|
|
8
7
|
let editor: TestEditor
|
|
9
8
|
|
|
@@ -10,13 +10,12 @@ import {
|
|
|
10
10
|
createBindingId,
|
|
11
11
|
createShapeId,
|
|
12
12
|
} from '@tldraw/editor'
|
|
13
|
-
import { vi } from 'vitest'
|
|
14
13
|
import { getArrowBindings } from '../lib/shapes/arrow/shared'
|
|
15
14
|
import { TestEditor } from './TestEditor'
|
|
16
15
|
|
|
17
16
|
let editor: TestEditor
|
|
18
17
|
|
|
19
|
-
|
|
18
|
+
jest.useFakeTimers()
|
|
20
19
|
|
|
21
20
|
const ids = {
|
|
22
21
|
boxA: createShapeId('boxA'),
|
|
@@ -298,7 +297,7 @@ describe('When one shape is selected', () => {
|
|
|
298
297
|
})
|
|
299
298
|
|
|
300
299
|
it('Flips the direct child shape positions if the shape is a group', async () => {
|
|
301
|
-
const fn =
|
|
300
|
+
const fn = jest.fn()
|
|
302
301
|
|
|
303
302
|
editor.selectAll()
|
|
304
303
|
editor.groupShapes(editor.getSelectedShapeIds()) // this will also select the new group
|
|
@@ -307,7 +306,7 @@ describe('When one shape is selected', () => {
|
|
|
307
306
|
editor.flipShapes(editor.getSelectedShapeIds(), 'horizontal')
|
|
308
307
|
|
|
309
308
|
// The change event should have been called
|
|
310
|
-
|
|
309
|
+
jest.runOnlyPendingTimers()
|
|
311
310
|
expect(fn).toHaveBeenCalled()
|
|
312
311
|
|
|
313
312
|
editor.expectShapeToMatch(
|
package/src/test/frames.test.ts
CHANGED
|
@@ -8,14 +8,13 @@ import {
|
|
|
8
8
|
createShapeId,
|
|
9
9
|
toRichText,
|
|
10
10
|
} from '@tldraw/editor'
|
|
11
|
-
import { vi } from 'vitest'
|
|
12
11
|
import { getArrowBindings } from '../lib/shapes/arrow/shared'
|
|
13
12
|
import { DEFAULT_FRAME_PADDING, fitFrameToContent, removeFrame } from '../lib/utils/frames/frames'
|
|
14
13
|
import { TestEditor } from './TestEditor'
|
|
15
14
|
|
|
16
15
|
let editor: TestEditor
|
|
17
16
|
|
|
18
|
-
|
|
17
|
+
jest.useFakeTimers()
|
|
19
18
|
|
|
20
19
|
beforeEach(() => {
|
|
21
20
|
editor = new TestEditor()
|
|
@@ -336,7 +335,7 @@ describe('frame shapes', () => {
|
|
|
336
335
|
// move to the center of the frame
|
|
337
336
|
editor.pointerMove(100, 100)
|
|
338
337
|
|
|
339
|
-
|
|
338
|
+
jest.advanceTimersByTime(300)
|
|
340
339
|
|
|
341
340
|
// Expect the shape to be inside the frame
|
|
342
341
|
expect(editor.getOnlySelectedShape()!.id).toBe(ids.boxA)
|
|
@@ -344,13 +343,13 @@ describe('frame shapes', () => {
|
|
|
344
343
|
|
|
345
344
|
// Move out of the frame
|
|
346
345
|
editor.pointerMove(275, 275)
|
|
347
|
-
|
|
346
|
+
jest.advanceTimersByTime(250)
|
|
348
347
|
|
|
349
348
|
expect(editor.getOnlySelectedShape()!.parentId).toBe(editor.getCurrentPageId())
|
|
350
349
|
|
|
351
350
|
// Move back into the frame
|
|
352
351
|
editor.pointerMove(150, 150)
|
|
353
|
-
|
|
352
|
+
jest.advanceTimersByTime(250)
|
|
354
353
|
|
|
355
354
|
// Expect the shape to be inside the frame again
|
|
356
355
|
expect(editor.getOnlySelectedShape()!.parentId).toBe(frameId)
|
|
@@ -385,7 +384,7 @@ describe('frame shapes', () => {
|
|
|
385
384
|
|
|
386
385
|
editor.setCurrentTool('select').select(box1.id).pointerDown(127, 127).pointerMove(132, 127)
|
|
387
386
|
|
|
388
|
-
|
|
387
|
+
jest.advanceTimersByTime(250)
|
|
389
388
|
|
|
390
389
|
expect(editor.getOnlySelectedShape()!.id).toBe(box1.id)
|
|
391
390
|
if (editor.getShape(box1)?.parentId !== frame.id) {
|
|
@@ -404,14 +403,14 @@ describe('frame shapes', () => {
|
|
|
404
403
|
editor.pointerMove(175, 175)
|
|
405
404
|
expect(editor.getOnlySelectedShape()!.parentId).toBe(frame.id)
|
|
406
405
|
|
|
407
|
-
|
|
406
|
+
jest.advanceTimersByTime(250)
|
|
408
407
|
expect(editor.getOnlySelectedShape()!.parentId).toBe(frame.id)
|
|
409
408
|
|
|
410
409
|
// Let's try that
|
|
411
410
|
editor.pointerMove(1750, 1750)
|
|
412
|
-
|
|
411
|
+
jest.advanceTimersByTime(200)
|
|
413
412
|
editor.pointerMove(175, 175)
|
|
414
|
-
|
|
413
|
+
jest.advanceTimersByTime(200)
|
|
415
414
|
|
|
416
415
|
// yay
|
|
417
416
|
expect(editor.getHintingShapeIds()).toHaveLength(1)
|
|
@@ -959,7 +958,7 @@ describe('When dragging a shape inside a group inside a frame', () => {
|
|
|
959
958
|
editor.pointerMove(150, 150).pointerDown(150, 150).pointerMove(140, 140)
|
|
960
959
|
|
|
961
960
|
expect(editor.getOnlySelectedShapeId()).toBe(ids.box1)
|
|
962
|
-
|
|
961
|
+
jest.advanceTimersByTime(300)
|
|
963
962
|
|
|
964
963
|
expect(editor.getShape(ids.box1)!.parentId).toBe(ids.group1)
|
|
965
964
|
})
|
|
@@ -974,7 +973,7 @@ it('Drags into a frame', () => {
|
|
|
974
973
|
editor.pointerDown(550, 550)
|
|
975
974
|
editor.pointerMove(250, 250)
|
|
976
975
|
|
|
977
|
-
|
|
976
|
+
jest.advanceTimersByTime(200)
|
|
978
977
|
|
|
979
978
|
expect(editor.getShape(box1)!.parentId).toBe(frame.id)
|
|
980
979
|
})
|
|
@@ -993,7 +992,7 @@ it('Allows dragging grouped shapes into frames if every shape in the group is in
|
|
|
993
992
|
editor.pointerDown(1100, 1100)
|
|
994
993
|
editor.pointerMove(250, 250)
|
|
995
994
|
|
|
996
|
-
|
|
995
|
+
jest.advanceTimersByTime(250)
|
|
997
996
|
|
|
998
997
|
expect(editor.getHintingShapeIds()).toMatchObject([frame.id])
|
|
999
998
|
|
|
@@ -1069,7 +1068,7 @@ describe('When dragging a shape', () => {
|
|
|
1069
1068
|
editor.pointerMove(30, 50)
|
|
1070
1069
|
editor.pointerUp(30, 50)
|
|
1071
1070
|
const parent = editor.getShape(rectId)?.parentId
|
|
1072
|
-
|
|
1071
|
+
jest.advanceTimersByTime(200)
|
|
1073
1072
|
expect(parent).toBe(frameId)
|
|
1074
1073
|
})
|
|
1075
1074
|
|
|
@@ -1186,7 +1185,7 @@ describe('Unparenting behavior', () => {
|
|
|
1186
1185
|
// expect(editor.getShape(rect.id)!.parentId).toBe(frame.id)
|
|
1187
1186
|
// editor.pointerDown(90, 50)
|
|
1188
1187
|
// editor.pointerMove(110, 50)
|
|
1189
|
-
//
|
|
1188
|
+
// jest.advanceTimersByTime(200)
|
|
1190
1189
|
// expect(editor.getShape(rect.id)!.parentId).toBe(editor.getCurrentPageId())
|
|
1191
1190
|
// editor.pointerUp(110, 50)
|
|
1192
1191
|
// expect(editor.getShape(rect.id)!.parentId).toBe(editor.getCurrentPageId())
|
|
@@ -1200,7 +1199,7 @@ describe('Unparenting behavior', () => {
|
|
|
1200
1199
|
expect(editor.getShape(rect.id)!.parentId).toBe(frame.id)
|
|
1201
1200
|
editor.pointerDown(90, 50)
|
|
1202
1201
|
editor.pointerMove(110, 50)
|
|
1203
|
-
|
|
1202
|
+
jest.advanceTimersByTime(200)
|
|
1204
1203
|
expect(editor.getShape(rect.id)!.parentId).toBe(editor.getCurrentPageId())
|
|
1205
1204
|
editor.pointerUp(110, 50)
|
|
1206
1205
|
expect(editor.getShape(rect.id)!.parentId).toBe(editor.getCurrentPageId())
|
|
@@ -1300,7 +1299,7 @@ describe('Unparenting behavior', () => {
|
|
|
1300
1299
|
expect(editor.getShape(triangle.id)!.parentId).toBe(frame.id)
|
|
1301
1300
|
|
|
1302
1301
|
// But after a delay, the triangle is reparented because it's not overlapping
|
|
1303
|
-
|
|
1302
|
+
jest.advanceTimersByTime(200)
|
|
1304
1303
|
expect(editor.getShape(triangle.id)!.parentId).toBe(editor.getCurrentPageId())
|
|
1305
1304
|
|
|
1306
1305
|
editor.pointerMove(50, 50)
|
|
@@ -1309,7 +1308,7 @@ describe('Unparenting behavior', () => {
|
|
|
1309
1308
|
expect(editor.getShape(triangle.id)!.parentId).toBe(editor.getCurrentPageId())
|
|
1310
1309
|
|
|
1311
1310
|
// But after a delay, the triangle is reparented because it's overlapping
|
|
1312
|
-
|
|
1311
|
+
jest.advanceTimersByTime(200)
|
|
1313
1312
|
expect(editor.getShape(triangle.id)!.parentId).toBe(frame.id)
|
|
1314
1313
|
})
|
|
1315
1314
|
|
|
@@ -1349,12 +1348,12 @@ describe('Unparenting behavior', () => {
|
|
|
1349
1348
|
expect(editor.isIn('select.translating')).toBe(true)
|
|
1350
1349
|
|
|
1351
1350
|
// Wait for reparenting to happen
|
|
1352
|
-
|
|
1351
|
+
jest.advanceTimersByTime(250)
|
|
1353
1352
|
expect(editor.getShape(largeRect.id)!.parentId).toBe(frameId)
|
|
1354
1353
|
|
|
1355
1354
|
// The large rectangle should now be reparented to the frame, even though the frame covers it
|
|
1356
1355
|
editor.pointerUp(250, 250)
|
|
1357
|
-
|
|
1356
|
+
jest.advanceTimersByTime(250)
|
|
1358
1357
|
}
|
|
1359
1358
|
|
|
1360
1359
|
// When the shape has no fill and an empty label, it should fall out of the frame
|
|
@@ -1504,7 +1503,7 @@ describe('When dragging groups or shapes within a group', () => {
|
|
|
1504
1503
|
editor.pointerDown(1100, 1100)
|
|
1505
1504
|
editor.pointerMove(250, 250)
|
|
1506
1505
|
|
|
1507
|
-
|
|
1506
|
+
jest.advanceTimersByTime(200)
|
|
1508
1507
|
|
|
1509
1508
|
expect(editor.getShape(group)!.parentId).toBe(frame.id)
|
|
1510
1509
|
})
|
|
@@ -1527,14 +1526,14 @@ describe('When dragging groups or shapes within a group', () => {
|
|
|
1527
1526
|
editor.select(rect1ID)
|
|
1528
1527
|
editor.pointerDown(15, 15)
|
|
1529
1528
|
editor.pointerMove(100, 100)
|
|
1530
|
-
|
|
1529
|
+
jest.advanceTimersByTime(200)
|
|
1531
1530
|
|
|
1532
1531
|
expect(editor.getShape(rect1ID)?.parentId).toBe(group.id)
|
|
1533
1532
|
expect(editor.getShape(rect2ID)?.parentId).toBe(group.id)
|
|
1534
1533
|
expect(group.parentId).toBe(frame.id)
|
|
1535
1534
|
|
|
1536
1535
|
editor.pointerUp(100, 100)
|
|
1537
|
-
|
|
1536
|
+
jest.advanceTimersByTime(200)
|
|
1538
1537
|
|
|
1539
1538
|
expect(editor.getShape(rect1ID)?.parentId).toBe(group.id)
|
|
1540
1539
|
expect(editor.getShape(rect2ID)?.parentId).toBe(group.id)
|
|
@@ -1559,7 +1558,7 @@ describe('When dragging groups or shapes within a group', () => {
|
|
|
1559
1558
|
editor.pointerDown(15, 15)
|
|
1560
1559
|
editor.pointerMove(200, 200)
|
|
1561
1560
|
|
|
1562
|
-
|
|
1561
|
+
jest.advanceTimersByTime(200)
|
|
1563
1562
|
expect(editor.getShape(rect1ID)?.parentId).toBe(group.id)
|
|
1564
1563
|
expect(editor.getShape(rect2ID)?.parentId).toBe(group.id)
|
|
1565
1564
|
expect(editor.getShape(group.id)?.parentId).toBe(editor.getCurrentPageId())
|
|
@@ -1588,7 +1587,7 @@ describe('When dragging groups or shapes within a group', () => {
|
|
|
1588
1587
|
editor.pointerDown(15, 15)
|
|
1589
1588
|
editor.pointerMove(200, 200)
|
|
1590
1589
|
|
|
1591
|
-
|
|
1590
|
+
jest.advanceTimersByTime(200)
|
|
1592
1591
|
expect(editor.getShape(rect1ID)?.parentId).toBe(group.id)
|
|
1593
1592
|
expect(editor.getShape(rect2ID)?.parentId).toBe(group.id)
|
|
1594
1593
|
expect(editor.getShape(group.id)?.parentId).toBe(editor.getCurrentPageId())
|
|
@@ -1639,7 +1638,7 @@ describe('When dragging groups or shapes within a group', () => {
|
|
|
1639
1638
|
editor.pointerDown(215, 215)
|
|
1640
1639
|
editor.pointerMove(15, 15)
|
|
1641
1640
|
|
|
1642
|
-
|
|
1641
|
+
jest.advanceTimersByTime(200)
|
|
1643
1642
|
expect(editor.getShape(rect1ID)?.parentId).toBe(group.id)
|
|
1644
1643
|
expect(editor.getShape(rect2ID)?.parentId).toBe(group.id)
|
|
1645
1644
|
expect(editor.getShape(group.id)?.parentId).toBe(frameID)
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Box, TLShapeId, createShapeId } from '@tldraw/editor'
|
|
2
|
-
import { vi } from 'vitest'
|
|
3
2
|
import { TestEditor } from './TestEditor'
|
|
4
3
|
import { TL } from './test-jsx'
|
|
5
4
|
|
|
@@ -29,13 +28,13 @@ it('lists shapes in viewport', () => {
|
|
|
29
28
|
|
|
30
29
|
// Move the camera 201 pixels to the right and 201 pixels down
|
|
31
30
|
editor.pan({ x: -201, y: -201 })
|
|
32
|
-
|
|
31
|
+
jest.advanceTimersByTime(500)
|
|
33
32
|
|
|
34
33
|
// A is now outside of the viewport, like D
|
|
35
34
|
expect(editor.getCulledShapes()).toStrictEqual(new Set([ids.A, ids.D]))
|
|
36
35
|
|
|
37
36
|
editor.pan({ x: -900, y: -900 })
|
|
38
|
-
|
|
37
|
+
jest.advanceTimersByTime(500)
|
|
39
38
|
// Now all shapes are outside of the viewport, except for D (which is clipped)
|
|
40
39
|
expect(editor.getCulledShapes()).toStrictEqual(new Set([ids.A, ids.B, ids.C]))
|
|
41
40
|
|
package/src/test/groups.test.tsx
CHANGED
|
@@ -1070,7 +1070,7 @@ describe('the select tool', () => {
|
|
|
1070
1070
|
// that we're doing hit testing manually—we'll catch that it was inside a shape
|
|
1071
1071
|
|
|
1072
1072
|
// editor.keyUp('Shift')
|
|
1073
|
-
//
|
|
1073
|
+
// jest.advanceTimersByTime(200)
|
|
1074
1074
|
|
|
1075
1075
|
// expect(editor.selectedShapeIds.includes(ids.boxA)).toBe(false)
|
|
1076
1076
|
// expect(editor.selectedShapeIds.includes(ids.boxB)).toBe(true)
|
|
@@ -1941,7 +1941,7 @@ describe('snapping', () => {
|
|
|
1941
1941
|
expect(editor.snaps.getIndicators().length).toBe(0)
|
|
1942
1942
|
})
|
|
1943
1943
|
|
|
1944
|
-
it('does not happen between children and
|
|
1944
|
+
it('does not happen between children and thier group', () => {
|
|
1945
1945
|
editor.select(ids.boxD)
|
|
1946
1946
|
editor.pointerDown(65, 5, ids.boxD)
|
|
1947
1947
|
editor.pointerMove(80, 105, ids.boxD, { ctrlKey: true })
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { PageRecordType, TLDeepLink, createDeepLinkString, createShapeId } from '@tldraw/editor'
|
|
2
|
-
import { vi } from 'vitest'
|
|
3
2
|
import { TestEditor } from './TestEditor'
|
|
4
3
|
import { TL } from './test-jsx'
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
jest.useFakeTimers()
|
|
7
6
|
|
|
8
7
|
let editor: TestEditor
|
|
9
8
|
|
|
@@ -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
|
|
@@ -83,7 +82,7 @@ describe('Maximum shapes behavior', () => {
|
|
|
83
82
|
})
|
|
84
83
|
|
|
85
84
|
it('should emit max-shapes event when limit is reached', () => {
|
|
86
|
-
const maxShapesHandler =
|
|
85
|
+
const maxShapesHandler = jest.fn()
|
|
87
86
|
editor.addListener('max-shapes', maxShapesHandler)
|
|
88
87
|
|
|
89
88
|
// Set up the note tool
|
|
@@ -283,7 +282,7 @@ describe('Maximum shapes behavior', () => {
|
|
|
283
282
|
expect(editor.getCurrentPageShapeIds().size).toBe(5)
|
|
284
283
|
|
|
285
284
|
// Try to create one more shape
|
|
286
|
-
const maxShapesHandler =
|
|
285
|
+
const maxShapesHandler = jest.fn()
|
|
287
286
|
editor.addListener('max-shapes', maxShapesHandler)
|
|
288
287
|
|
|
289
288
|
const extraShapeId = createShapeId('extra-shape')
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { vi } from 'vitest'
|
|
2
1
|
import { TestEditor } from './TestEditor'
|
|
3
2
|
|
|
4
3
|
let editor: TestEditor
|
|
@@ -7,14 +6,14 @@ beforeEach(() => {
|
|
|
7
6
|
editor = new TestEditor()
|
|
8
7
|
})
|
|
9
8
|
|
|
10
|
-
|
|
9
|
+
jest.useFakeTimers()
|
|
11
10
|
|
|
12
11
|
it('Shift Key', () => {
|
|
13
12
|
editor.pointerDown(0, 0)
|
|
14
13
|
editor.pointerMove(100, 100, { shiftKey: true })
|
|
15
14
|
editor.pointerMove(100, 100, { shiftKey: false })
|
|
16
15
|
expect(editor.inputs.shiftKey).toBe(true)
|
|
17
|
-
|
|
16
|
+
jest.advanceTimersByTime(200)
|
|
18
17
|
expect(editor.inputs.shiftKey).toBe(false)
|
|
19
18
|
})
|
|
20
19
|
|
|
@@ -23,7 +22,7 @@ it('Alt Key', () => {
|
|
|
23
22
|
editor.pointerMove(100, 100, { altKey: true })
|
|
24
23
|
editor.pointerMove(100, 100, { altKey: false })
|
|
25
24
|
expect(editor.inputs.altKey).toBe(true)
|
|
26
|
-
|
|
25
|
+
jest.advanceTimersByTime(200)
|
|
27
26
|
expect(editor.inputs.altKey).toBe(false)
|
|
28
27
|
})
|
|
29
28
|
|
|
@@ -32,6 +31,6 @@ it('Ctrl Key', () => {
|
|
|
32
31
|
editor.pointerMove(100, 100, { ctrlKey: true })
|
|
33
32
|
editor.pointerMove(100, 100, { ctrlKey: false })
|
|
34
33
|
expect(editor.inputs.ctrlKey).toBe(true)
|
|
35
|
-
|
|
34
|
+
jest.advanceTimersByTime(200)
|
|
36
35
|
expect(editor.inputs.ctrlKey).toBe(false)
|
|
37
36
|
})
|