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