tldraw 3.16.0-internal.a478398270c6 → 3.16.0-internal.f8b97f0c414f
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 +471 -130
- package/dist-cjs/index.js +58 -15
- 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/TldrawImage.js +5 -2
- 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 +279 -271
- package/dist-cjs/lib/canvas/TldrawSelectionForeground.js.map +2 -2
- package/dist-cjs/lib/defaultExternalContentHandlers.js +6 -4
- package/dist-cjs/lib/defaultExternalContentHandlers.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js +27 -44
- package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/arrowLabel.js +22 -4
- package/dist-cjs/lib/shapes/arrow/arrowLabel.js.map +3 -3
- 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/elbow/elbowArrowSnapLines.js.map +1 -1
- package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.js +3 -0
- package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/shapes/bookmark/BookmarkShapeUtil.js +4 -4
- package/dist-cjs/lib/shapes/bookmark/BookmarkShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/draw/DrawShapeUtil.js +3 -6
- 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/FrameShapeTool.js.map +1 -1
- package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js +25 -18
- 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/frame/components/FrameLabelInput.js +2 -2
- package/dist-cjs/lib/shapes/frame/components/FrameLabelInput.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 -4
- 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 +20 -5
- package/dist-cjs/lib/shapes/line/LineShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/note/NoteShapeUtil.js +8 -6
- package/dist-cjs/lib/shapes/note/NoteShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/HyperlinkButton.js +4 -4
- package/dist-cjs/lib/shapes/shared/HyperlinkButton.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/PathBuilder.js +21 -3
- package/dist-cjs/lib/shapes/shared/PathBuilder.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/PlainTextLabel.js +2 -3
- package/dist-cjs/lib/shapes/shared/PlainTextLabel.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/RichTextLabel.js +5 -2
- 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 +4 -3
- package/dist-cjs/lib/shapes/shared/SvgTextLabel.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/crop.js +1 -0
- package/dist-cjs/lib/shapes/shared/crop.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/freehand/svg.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/useEditablePlainText.js +3 -4
- package/dist-cjs/lib/shapes/shared/useEditablePlainText.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/useEditableRichText.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/PlainTextArea.js +2 -2
- package/dist-cjs/lib/shapes/text/PlainTextArea.js.map +2 -2
- package/dist-cjs/lib/shapes/text/RichTextArea.js +3 -3
- package/dist-cjs/lib/shapes/text/RichTextArea.js.map +2 -2
- package/dist-cjs/lib/shapes/text/TextShapeUtil.js +7 -13
- 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 +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/tools/SelectTool/childStates/Crop/children/PointingCrop.js +7 -1
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js +43 -22
- package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Idle.js +2 -15
- package/dist-cjs/lib/tools/SelectTool/childStates/Idle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingShape.js +5 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingShape.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js +8 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Rotating.js +8 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/Rotating.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js +8 -0
- 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 +27 -12
- package/dist-cjs/lib/ui/TldrawUi.js.map +3 -3
- package/dist-cjs/lib/ui/components/A11y.js +15 -13
- package/dist-cjs/lib/ui/components/A11y.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/EditLinkDialog.js +11 -1
- package/dist-cjs/lib/ui/components/EditLinkDialog.js.map +2 -2
- package/dist-cjs/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.js +57 -7
- package/dist-cjs/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.js.map +2 -2
- package/dist-cjs/lib/ui/components/MainMenu/DefaultMainMenuContent.js +3 -2
- 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 +4 -5
- package/dist-cjs/lib/ui/components/NavigationPanel/DefaultNavigationPanel.js.map +2 -2
- package/dist-cjs/lib/ui/components/PageMenu/DefaultPageMenu.js +3 -2
- 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/Spinner.js +2 -25
- package/dist-cjs/lib/ui/components/Spinner.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 -278
- 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 -54
- 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/DefaultImageToolbar.js +21 -7
- package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbar.js.map +3 -3
- 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 +22 -0
- 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/TldrawUiContextualToolbar.js +11 -2
- 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 +35 -1
- package/dist-cjs/lib/ui/components/primitives/TldrawUiIcon.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiInput.js +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiInput.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 +23 -6
- package/dist-cjs/lib/ui/components/primitives/TldrawUiSlider.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiToolbar.js +33 -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/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 +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 +154 -22
- 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 +79 -17
- 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/menu-hooks.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/useClipboardEvents.js +1 -1
- package/dist-cjs/lib/ui/hooks/useClipboardEvents.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/useKeyboardShortcuts.js +2 -2
- package/dist-cjs/lib/ui/hooks/useKeyboardShortcuts.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/useTools.js +94 -9
- 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 +13 -0
- package/dist-cjs/lib/ui/hooks/useTranslation/defaultTranslation.js.map +2 -2
- package/dist-cjs/lib/ui/kbd-utils.js +11 -4
- 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/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-cjs/lib/utils/tldr/buildFromV1Document.js +3 -2
- package/dist-cjs/lib/utils/tldr/buildFromV1Document.js.map +2 -2
- package/dist-esm/index.d.mts +471 -130
- package/dist-esm/index.mjs +107 -32
- 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/TldrawImage.mjs +5 -2
- 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 +279 -271
- package/dist-esm/lib/canvas/TldrawSelectionForeground.mjs.map +2 -2
- package/dist-esm/lib/defaultExternalContentHandlers.mjs +6 -4
- package/dist-esm/lib/defaultExternalContentHandlers.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs +30 -44
- package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/arrowLabel.mjs +25 -5
- package/dist-esm/lib/shapes/arrow/arrowLabel.mjs.map +3 -3
- 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/elbow/elbowArrowSnapLines.mjs.map +1 -1
- package/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs +3 -0
- package/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/shapes/bookmark/BookmarkShapeUtil.mjs +5 -5
- package/dist-esm/lib/shapes/bookmark/BookmarkShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/draw/DrawShapeUtil.mjs +4 -6
- 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/FrameShapeTool.mjs.map +1 -1
- package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs +26 -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/frame/components/FrameLabelInput.mjs +3 -3
- package/dist-esm/lib/shapes/frame/components/FrameLabelInput.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 -4
- 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 +21 -5
- package/dist-esm/lib/shapes/line/LineShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs +9 -6
- package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/HyperlinkButton.mjs +5 -5
- package/dist-esm/lib/shapes/shared/HyperlinkButton.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/PathBuilder.mjs +22 -3
- package/dist-esm/lib/shapes/shared/PathBuilder.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/PlainTextLabel.mjs +2 -3
- package/dist-esm/lib/shapes/shared/PlainTextLabel.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/RichTextLabel.mjs +5 -2
- package/dist-esm/lib/shapes/shared/RichTextLabel.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/SvgTextLabel.mjs +4 -3
- package/dist-esm/lib/shapes/shared/SvgTextLabel.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/crop.mjs +1 -0
- package/dist-esm/lib/shapes/shared/crop.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/freehand/svg.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/useEditablePlainText.mjs +4 -5
- package/dist-esm/lib/shapes/shared/useEditablePlainText.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/useEditableRichText.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/PlainTextArea.mjs +3 -3
- package/dist-esm/lib/shapes/text/PlainTextArea.mjs.map +2 -2
- package/dist-esm/lib/shapes/text/RichTextArea.mjs +3 -4
- package/dist-esm/lib/shapes/text/RichTextArea.mjs.map +2 -2
- package/dist-esm/lib/shapes/text/TextShapeUtil.mjs +8 -13
- 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 +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/tools/SelectTool/childStates/Crop/children/PointingCrop.mjs +7 -1
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs +43 -22
- package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Idle.mjs +2 -15
- package/dist-esm/lib/tools/SelectTool/childStates/Idle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingShape.mjs +5 -0
- package/dist-esm/lib/tools/SelectTool/childStates/PointingShape.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs +8 -0
- package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Rotating.mjs +8 -0
- package/dist-esm/lib/tools/SelectTool/childStates/Rotating.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs +8 -0
- 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 +29 -14
- package/dist-esm/lib/ui/TldrawUi.mjs.map +3 -3
- package/dist-esm/lib/ui/components/A11y.mjs +16 -14
- package/dist-esm/lib/ui/components/A11y.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/EditLinkDialog.mjs +11 -1
- package/dist-esm/lib/ui/components/EditLinkDialog.mjs.map +2 -2
- package/dist-esm/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.mjs +57 -7
- 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 +6 -3
- package/dist-esm/lib/ui/components/MobileStylePanel.mjs.map +2 -2
- package/dist-esm/lib/ui/components/NavigationPanel/DefaultNavigationPanel.mjs +4 -5
- package/dist-esm/lib/ui/components/NavigationPanel/DefaultNavigationPanel.mjs.map +2 -2
- package/dist-esm/lib/ui/components/PageMenu/DefaultPageMenu.mjs +4 -3
- 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/Spinner.mjs +3 -26
- package/dist-esm/lib/ui/components/Spinner.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 -282
- 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/DefaultImageToolbar.mjs +23 -9
- package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbar.mjs.map +3 -3
- 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 +22 -0
- 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/TldrawUiContextualToolbar.mjs +12 -3
- 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 +36 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiIcon.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiInput.mjs +3 -3
- package/dist-esm/lib/ui/components/primitives/TldrawUiInput.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 +23 -6
- package/dist-esm/lib/ui/components/primitives/TldrawUiSlider.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiToolbar.mjs +33 -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/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 +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 +162 -24
- 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 +79 -17
- 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/menu-hooks.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/useClipboardEvents.mjs +2 -2
- package/dist-esm/lib/ui/hooks/useClipboardEvents.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/useKeyboardShortcuts.mjs +2 -2
- package/dist-esm/lib/ui/hooks/useKeyboardShortcuts.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/useTools.mjs +102 -10
- package/dist-esm/lib/ui/hooks/useTools.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/useTranslation/defaultTranslation.mjs +13 -0
- package/dist-esm/lib/ui/hooks/useTranslation/defaultTranslation.mjs.map +2 -2
- package/dist-esm/lib/ui/kbd-utils.mjs +11 -4
- 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/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/dist-esm/lib/utils/tldr/buildFromV1Document.mjs +3 -2
- package/dist-esm/lib/utils/tldr/buildFromV1Document.mjs.map +2 -2
- package/package.json +12 -34
- package/src/index.ts +80 -24
- package/src/lib/Tldraw.tsx +15 -2
- package/src/lib/TldrawImage.tsx +6 -2
- package/src/lib/canvas/TldrawCropHandles.tsx +3 -1
- package/src/lib/canvas/TldrawHandles.tsx +5 -1
- package/src/lib/canvas/TldrawOverlays.tsx +1 -1
- package/src/lib/canvas/TldrawScribble.tsx +1 -1
- package/src/lib/canvas/TldrawSelectionForeground.tsx +5 -1
- package/src/lib/defaultExternalContentHandlers.ts +14 -5
- package/src/lib/shapes/arrow/ArrowShapeOptions.test.ts +2 -1
- package/src/lib/shapes/arrow/ArrowShapeTool.test.ts +6 -5
- package/src/lib/shapes/arrow/ArrowShapeUtil.test.ts +53 -11
- package/src/lib/shapes/arrow/ArrowShapeUtil.tsx +30 -46
- package/src/lib/shapes/arrow/arrowLabel.ts +31 -3
- package/src/lib/shapes/arrow/arrowTargetState.ts +3 -2
- package/src/lib/shapes/arrow/elbow/ElbowArrowDebug.tsx +3 -3
- package/src/lib/shapes/arrow/elbow/elbowArrowSnapLines.tsx +2 -2
- package/src/lib/shapes/arrow/toolStates/Pointing.tsx +3 -0
- package/src/lib/shapes/bookmark/BookmarkShapeUtil.tsx +5 -5
- package/src/lib/shapes/draw/DrawShapeTool.test.ts +0 -5
- package/src/lib/shapes/draw/DrawShapeUtil.tsx +4 -7
- package/src/lib/shapes/embed/EmbedShapeUtil.tsx +1 -1
- package/src/lib/shapes/frame/FrameShapeTool.ts +1 -1
- package/src/lib/shapes/frame/FrameShapeUtil.tsx +35 -21
- package/src/lib/shapes/frame/components/FrameHeading.tsx +1 -1
- package/src/lib/shapes/frame/components/FrameLabelInput.tsx +3 -3
- 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 -4
- package/src/lib/shapes/image/ImageShapeUtil.tsx +6 -3
- package/src/lib/shapes/line/LineShapeUtil.test.tsx +8 -7
- package/src/lib/shapes/line/LineShapeUtil.tsx +25 -6
- package/src/lib/shapes/line/__snapshots__/LineShapeUtil.test.tsx.snap +2 -2
- package/src/lib/shapes/note/NoteShapeTool.test.ts +2 -1
- package/src/lib/shapes/note/NoteShapeUtil.tsx +11 -4
- package/src/lib/shapes/shared/HyperlinkButton.tsx +5 -5
- package/src/lib/shapes/shared/PathBuilder.test.tsx +1 -1
- package/src/lib/shapes/shared/PathBuilder.tsx +35 -1
- package/src/lib/shapes/shared/PlainTextLabel.tsx +3 -7
- package/src/lib/shapes/shared/RichTextLabel.tsx +6 -1
- package/src/lib/shapes/shared/ShapeFill.tsx +5 -4
- package/src/lib/shapes/shared/SvgTextLabel.tsx +4 -2
- package/src/lib/shapes/shared/crop.ts +1 -0
- package/src/lib/shapes/shared/freehand/svg.ts +2 -0
- package/src/lib/shapes/shared/useEditablePlainText.ts +12 -12
- package/src/lib/shapes/shared/useEditableRichText.ts +7 -3
- package/src/lib/shapes/shared/useImageOrVideoAsset.ts +0 -7
- package/src/lib/shapes/shared/usePrefersReducedMotion.tsx +11 -1
- package/src/lib/shapes/text/PlainTextArea.tsx +3 -3
- package/src/lib/shapes/text/RichTextArea.tsx +3 -4
- package/src/lib/shapes/text/TextShapeTool.test.ts +6 -5
- package/src/lib/shapes/text/TextShapeUtil.tsx +8 -14
- package/src/lib/shapes/video/VideoShapeUtil.tsx +3 -3
- package/src/lib/styles.tsx +3 -1
- package/src/lib/tools/EraserTool/childStates/Erasing.ts +34 -1
- package/src/lib/tools/EraserTool/childStates/Pointing.ts +20 -0
- package/src/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.ts +8 -1
- package/src/lib/tools/SelectTool/childStates/DraggingHandle.tsx +54 -30
- package/src/lib/tools/SelectTool/childStates/Idle.ts +2 -24
- package/src/lib/tools/SelectTool/childStates/PointingShape.ts +7 -0
- package/src/lib/tools/SelectTool/childStates/Resizing.ts +12 -1
- package/src/lib/tools/SelectTool/childStates/Rotating.ts +11 -0
- package/src/lib/tools/SelectTool/childStates/Translating.ts +11 -1
- package/src/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.ts +1 -0
- package/src/lib/ui/TldrawUi.tsx +33 -12
- package/src/lib/ui/components/A11y.tsx +17 -15
- 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/EditLinkDialog.tsx +16 -6
- package/src/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.tsx +46 -6
- package/src/lib/ui/components/MainMenu/DefaultMainMenuContent.tsx +4 -2
- 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 +4 -5
- package/src/lib/ui/components/PageMenu/DefaultPageMenu.tsx +5 -4
- 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/Spinner.tsx +2 -24
- package/src/lib/ui/components/StylePanel/DefaultStylePanel.tsx +28 -12
- package/src/lib/ui/components/StylePanel/DefaultStylePanelContent.tsx +261 -342
- package/src/lib/ui/components/{primitives/TldrawUiButtonPicker.tsx → StylePanel/StylePanelButtonPicker.tsx} +66 -48
- 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 +5 -4
- package/src/lib/ui/components/Toolbar/DefaultImageToolbar.tsx +25 -9
- 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 +17 -12
- package/src/lib/ui/components/menu-items.tsx +25 -0
- package/src/lib/ui/components/primitives/Button/TldrawUiButtonIcon.tsx +2 -2
- package/src/lib/ui/components/primitives/TldrawUiContextualToolbar.tsx +8 -3
- package/src/lib/ui/components/primitives/TldrawUiDialog.tsx +1 -1
- package/src/lib/ui/components/primitives/TldrawUiIcon.tsx +41 -3
- package/src/lib/ui/components/primitives/TldrawUiInput.tsx +3 -3
- package/src/lib/ui/components/primitives/TldrawUiPopover.tsx +4 -2
- package/src/lib/ui/components/primitives/TldrawUiSlider.tsx +54 -29
- package/src/lib/ui/components/primitives/TldrawUiToolbar.tsx +59 -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/TldrawUiMenuCheckboxItem.tsx +2 -2
- 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 +224 -23
- package/src/lib/ui/context/TldrawUiContextProvider.tsx +23 -20
- package/src/lib/ui/context/actions.tsx +81 -18
- package/src/lib/ui/context/components.tsx +3 -0
- package/src/lib/ui/context/events.tsx +7 -3
- package/src/lib/ui/hooks/menu-hooks.ts +1 -0
- package/src/lib/ui/hooks/useClipboardEvents.ts +2 -2
- package/src/lib/ui/hooks/useExportAs.ts +3 -2
- package/src/lib/ui/hooks/useKeyboardShortcuts.ts +3 -2
- package/src/lib/ui/hooks/useTools.tsx +142 -11
- package/src/lib/ui/hooks/useTranslation/TLUiTranslationKey.ts +13 -0
- package/src/lib/ui/hooks/useTranslation/defaultTranslation.ts +13 -0
- package/src/lib/ui/kbd-utils.ts +12 -4
- package/src/lib/ui/version.ts +3 -3
- package/src/lib/ui.css +432 -315
- package/src/lib/utils/excalidraw/__snapshots__/putExcalidrawContent.test.tsx.snap +21 -7
- package/src/lib/utils/excalidraw/putExcalidrawContent.ts +7 -7
- 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 +28 -7
- package/src/lib/utils/tldr/buildFromV1Document.ts +2 -1
- package/src/test/A11y.test.tsx +3 -2
- package/src/test/ClickManager.test.ts +7 -6
- package/src/test/Editor.test.tsx +56 -28
- 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 +40 -13
- package/src/test/TLUserPreferences.test.ts +4 -3
- package/src/test/TestEditor.ts +13 -15
- package/src/test/TldrawEditor.test.tsx +26 -19
- 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 +17 -10
- 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/deletePage.test.ts +84 -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/putContent.test.ts +1 -0
- 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/commands/updateShapes.test.ts +9 -5
- package/src/test/createDeepLink.test.tsx +2 -1
- package/src/test/cropping.test.ts +3 -2
- package/src/test/custom-clipping.test.ts +442 -0
- package/src/test/customSnapping.test.tsx +55 -41
- 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 +80 -4
- package/src/test/groups.test.tsx +6 -4
- package/src/test/handleDeepLink.test.tsx +2 -1
- package/src/test/inner-outer-margin.test.ts +315 -0
- package/src/test/maxShapes.test.ts +3 -2
- package/src/test/modifiers.test.ts +5 -4
- package/src/test/navigation.test.ts +264 -9
- 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 +398 -48
- package/src/test/translating.test.ts +12 -11
- package/tldraw.css +759 -630
- 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 -113
- package/dist-esm/lib/ui/components/primitives/TldrawUiButtonPicker.mjs.map +0 -7
- package/src/lib/ui/components/StylePanel/DropdownPicker.tsx +0 -109
|
@@ -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
|
-
import { createShapeId, TLFrameShape, TLGeoShape } from '@tldraw/editor'
|
|
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
|
|
@@ -11,6 +12,8 @@ const ids = {
|
|
|
11
12
|
frame1: createShapeId('frame1'),
|
|
12
13
|
box1: createShapeId('box1'),
|
|
13
14
|
box2: createShapeId('box2'),
|
|
15
|
+
line1: createShapeId('line1'),
|
|
16
|
+
page1: createShapeId('page1'),
|
|
14
17
|
}
|
|
15
18
|
|
|
16
19
|
beforeEach(() => {
|
|
@@ -56,34 +59,93 @@ describe('When interacting with a shape...', () => {
|
|
|
56
59
|
// Set start / change / end events on only the geo shape
|
|
57
60
|
const util = editor.getShapeUtil<TLFrameShape>('frame')
|
|
58
61
|
|
|
59
|
-
const
|
|
60
|
-
util.onRotateStart = fnStart
|
|
62
|
+
const calls: string[] = []
|
|
61
63
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
+
util.onRotateStart = () => {
|
|
65
|
+
calls.push('start')
|
|
66
|
+
}
|
|
64
67
|
|
|
65
|
-
|
|
66
|
-
|
|
68
|
+
util.onRotate = () => {
|
|
69
|
+
calls.push('change')
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
util.onRotateEnd = () => {
|
|
73
|
+
calls.push('end')
|
|
74
|
+
}
|
|
67
75
|
|
|
68
76
|
editor.selectAll()
|
|
69
77
|
expect(editor.getSelectedShapeIds()).toMatchObject([ids.frame1, ids.box1])
|
|
70
78
|
|
|
71
|
-
editor
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
})
|
|
76
|
-
.pointerMove(200, 200)
|
|
77
|
-
.pointerUp(200, 200)
|
|
79
|
+
editor.pointerDown(300, 300, {
|
|
80
|
+
target: 'selection',
|
|
81
|
+
handle: 'bottom_right_rotate',
|
|
82
|
+
})
|
|
78
83
|
|
|
79
|
-
//
|
|
80
|
-
expect(
|
|
84
|
+
// Should not have called any callbacks yet
|
|
85
|
+
expect(calls).toEqual([])
|
|
81
86
|
|
|
82
|
-
|
|
83
|
-
|
|
87
|
+
editor.pointerMove(200, 200)
|
|
88
|
+
|
|
89
|
+
// Should have called start once and change at least once now
|
|
90
|
+
expect(calls).toEqual(['start', 'change'])
|
|
91
|
+
|
|
92
|
+
editor.pointerMove(200, 210)
|
|
84
93
|
|
|
85
|
-
//
|
|
86
|
-
expect(
|
|
94
|
+
// Should have called start once and change multiple times
|
|
95
|
+
expect(calls).toEqual(['start', 'change', 'change'])
|
|
96
|
+
|
|
97
|
+
editor.pointerUp(200, 210)
|
|
98
|
+
|
|
99
|
+
// Should have called end once now
|
|
100
|
+
expect(calls).toEqual(['start', 'change', 'change', 'change', 'end'])
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
it('fires rotate cancel events', () => {
|
|
104
|
+
const util = editor.getShapeUtil<TLFrameShape>('frame')
|
|
105
|
+
|
|
106
|
+
const calls: string[] = []
|
|
107
|
+
|
|
108
|
+
util.onRotateStart = () => {
|
|
109
|
+
calls.push('start')
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
util.onRotate = () => {
|
|
113
|
+
calls.push('change')
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
util.onRotateEnd = () => {
|
|
117
|
+
calls.push('end')
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
util.onRotateCancel = () => {
|
|
121
|
+
calls.push('cancel')
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
editor.selectAll()
|
|
125
|
+
expect(editor.getSelectedShapeIds()).toMatchObject([ids.frame1, ids.box1])
|
|
126
|
+
|
|
127
|
+
editor.pointerDown(300, 300, {
|
|
128
|
+
target: 'selection',
|
|
129
|
+
handle: 'bottom_right_rotate',
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
// Should not have called any callbacks yet
|
|
133
|
+
expect(calls).toEqual([])
|
|
134
|
+
|
|
135
|
+
editor.pointerMove(200, 200)
|
|
136
|
+
|
|
137
|
+
// Should have called start once and change at least once now
|
|
138
|
+
expect(calls).toEqual(['start', 'change'])
|
|
139
|
+
|
|
140
|
+
editor.pointerMove(200, 210)
|
|
141
|
+
|
|
142
|
+
// Should have called start once and change multiple times
|
|
143
|
+
expect(calls).toEqual(['start', 'change', 'change'])
|
|
144
|
+
|
|
145
|
+
editor.cancel()
|
|
146
|
+
|
|
147
|
+
// Should have called cancel instead of end
|
|
148
|
+
expect(calls).toEqual(['start', 'change', 'change', 'cancel'])
|
|
87
149
|
})
|
|
88
150
|
|
|
89
151
|
it('cleans up events', () => {
|
|
@@ -94,7 +156,7 @@ describe('When interacting with a shape...', () => {
|
|
|
94
156
|
it('fires double click handler event', () => {
|
|
95
157
|
const util = editor.getShapeUtil<TLGeoShape>('geo')
|
|
96
158
|
|
|
97
|
-
const fnStart =
|
|
159
|
+
const fnStart = vi.fn()
|
|
98
160
|
util.onDoubleClick = fnStart
|
|
99
161
|
|
|
100
162
|
editor.doubleClick(50, 50, ids.box2)
|
|
@@ -105,14 +167,19 @@ describe('When interacting with a shape...', () => {
|
|
|
105
167
|
it('Fires resisizing events', () => {
|
|
106
168
|
const util = editor.getShapeUtil<TLFrameShape>('frame')
|
|
107
169
|
|
|
108
|
-
const
|
|
109
|
-
|
|
170
|
+
const calls: string[] = []
|
|
171
|
+
|
|
172
|
+
util.onResizeStart = () => {
|
|
173
|
+
calls.push('start')
|
|
174
|
+
}
|
|
110
175
|
|
|
111
|
-
|
|
112
|
-
|
|
176
|
+
util.onResize = () => {
|
|
177
|
+
calls.push('change')
|
|
178
|
+
}
|
|
113
179
|
|
|
114
|
-
|
|
115
|
-
|
|
180
|
+
util.onResizeEnd = () => {
|
|
181
|
+
calls.push('end')
|
|
182
|
+
}
|
|
116
183
|
|
|
117
184
|
editor.selectAll()
|
|
118
185
|
expect(editor.getSelectedShapeIds()).toMatchObject([ids.frame1, ids.box1])
|
|
@@ -123,54 +190,171 @@ describe('When interacting with a shape...', () => {
|
|
|
123
190
|
})
|
|
124
191
|
|
|
125
192
|
editor.expectToBeIn('select.pointing_resize_handle')
|
|
193
|
+
|
|
194
|
+
// Should not have called any callbacks yet
|
|
195
|
+
expect(calls).toEqual([])
|
|
196
|
+
|
|
126
197
|
editor.pointerMove(200, 200)
|
|
127
198
|
editor.expectToBeIn('select.resizing')
|
|
199
|
+
|
|
200
|
+
// Should have called start once and change at least once now
|
|
201
|
+
expect(calls).toEqual(['start', 'change'])
|
|
202
|
+
|
|
128
203
|
editor.pointerMove(200, 210)
|
|
204
|
+
|
|
205
|
+
// Should have called start once and change multiple times
|
|
206
|
+
expect(calls).toEqual(['start', 'change', 'change'])
|
|
207
|
+
|
|
129
208
|
editor.pointerUp(200, 210)
|
|
130
209
|
editor.expectToBeIn('select.idle')
|
|
131
210
|
|
|
132
|
-
//
|
|
133
|
-
expect(
|
|
211
|
+
// Should have called end once now
|
|
212
|
+
expect(calls).toEqual(['start', 'change', 'change', 'end'])
|
|
213
|
+
})
|
|
214
|
+
|
|
215
|
+
it('Fires resizing cancel events', () => {
|
|
216
|
+
const util = editor.getShapeUtil<TLFrameShape>('frame')
|
|
217
|
+
|
|
218
|
+
const calls: string[] = []
|
|
219
|
+
|
|
220
|
+
util.onResizeStart = () => {
|
|
221
|
+
calls.push('start')
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
util.onResize = () => {
|
|
225
|
+
calls.push('change')
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
util.onResizeEnd = () => {
|
|
229
|
+
calls.push('end')
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
util.onResizeCancel = () => {
|
|
233
|
+
calls.push('cancel')
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
editor.selectAll()
|
|
237
|
+
expect(editor.getSelectedShapeIds()).toMatchObject([ids.frame1, ids.box1])
|
|
238
|
+
|
|
239
|
+
editor.pointerDown(300, 300, {
|
|
240
|
+
target: 'selection',
|
|
241
|
+
handle: 'bottom_right',
|
|
242
|
+
})
|
|
243
|
+
|
|
244
|
+
editor.expectToBeIn('select.pointing_resize_handle')
|
|
245
|
+
|
|
246
|
+
// Should not have called any callbacks yet
|
|
247
|
+
expect(calls).toEqual([])
|
|
248
|
+
|
|
249
|
+
editor.pointerMove(200, 200)
|
|
250
|
+
editor.expectToBeIn('select.resizing')
|
|
251
|
+
|
|
252
|
+
// Should have called start once and change at least once now
|
|
253
|
+
expect(calls).toEqual(['start', 'change'])
|
|
254
|
+
|
|
255
|
+
editor.pointerMove(200, 210)
|
|
256
|
+
|
|
257
|
+
// Should have called start once and change multiple times
|
|
258
|
+
expect(calls).toEqual(['start', 'change', 'change'])
|
|
134
259
|
|
|
135
|
-
|
|
136
|
-
expect(fnChange).toHaveBeenCalledTimes(2)
|
|
260
|
+
editor.cancel()
|
|
137
261
|
|
|
138
|
-
//
|
|
139
|
-
expect(
|
|
262
|
+
// Should have called cancel instead of end
|
|
263
|
+
expect(calls).toEqual(['start', 'change', 'change', 'cancel'])
|
|
140
264
|
})
|
|
141
265
|
|
|
142
266
|
it('Fires translating events', () => {
|
|
143
267
|
const util = editor.getShapeUtil<TLFrameShape>('frame')
|
|
144
268
|
|
|
145
|
-
const
|
|
146
|
-
util.onTranslateStart = fnStart
|
|
269
|
+
const calls: string[] = []
|
|
147
270
|
|
|
148
|
-
|
|
149
|
-
|
|
271
|
+
util.onTranslateStart = () => {
|
|
272
|
+
calls.push('start')
|
|
273
|
+
}
|
|
150
274
|
|
|
151
|
-
|
|
152
|
-
|
|
275
|
+
util.onTranslate = () => {
|
|
276
|
+
calls.push('change')
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
util.onTranslateEnd = () => {
|
|
280
|
+
calls.push('end')
|
|
281
|
+
}
|
|
153
282
|
|
|
154
283
|
editor.selectAll()
|
|
155
284
|
expect(editor.getSelectedShapeIds()).toMatchObject([ids.frame1, ids.box1])
|
|
156
285
|
|
|
157
286
|
// Translate the shapes...
|
|
158
|
-
editor.pointerDown(50, 50, ids.box1)
|
|
287
|
+
editor.pointerDown(50, 50, ids.box1)
|
|
159
288
|
|
|
160
|
-
//
|
|
161
|
-
expect(
|
|
289
|
+
// Should not have called any callbacks yet
|
|
290
|
+
expect(calls).toEqual([])
|
|
291
|
+
|
|
292
|
+
editor.pointerMove(50, 40)
|
|
293
|
+
|
|
294
|
+
// Should have called start once and change at least once now
|
|
295
|
+
expect(calls).toEqual(['start', 'change'])
|
|
162
296
|
|
|
163
|
-
|
|
164
|
-
expect(fnChange).toHaveBeenCalledTimes(2)
|
|
297
|
+
editor.pointerMove(50, 35)
|
|
165
298
|
|
|
166
|
-
//
|
|
167
|
-
expect(
|
|
299
|
+
// Should have called start once and change multiple times
|
|
300
|
+
expect(calls).toEqual(['start', 'change', 'change'])
|
|
301
|
+
|
|
302
|
+
editor.pointerUp(50, 35)
|
|
303
|
+
|
|
304
|
+
// Should have called end once now
|
|
305
|
+
expect(calls).toEqual(['start', 'change', 'change', 'change', 'end'])
|
|
306
|
+
})
|
|
307
|
+
|
|
308
|
+
it('Fires translating cancel events', () => {
|
|
309
|
+
const util = editor.getShapeUtil<TLFrameShape>('frame')
|
|
310
|
+
|
|
311
|
+
const calls: string[] = []
|
|
312
|
+
|
|
313
|
+
util.onTranslateStart = () => {
|
|
314
|
+
calls.push('start')
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
util.onTranslate = () => {
|
|
318
|
+
calls.push('change')
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
util.onTranslateEnd = () => {
|
|
322
|
+
calls.push('end')
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
util.onTranslateCancel = () => {
|
|
326
|
+
calls.push('cancel')
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
editor.selectAll()
|
|
330
|
+
expect(editor.getSelectedShapeIds()).toMatchObject([ids.frame1, ids.box1])
|
|
331
|
+
|
|
332
|
+
// Translate the shapes...
|
|
333
|
+
editor.pointerDown(50, 50, ids.box1)
|
|
334
|
+
|
|
335
|
+
// Should not have called any callbacks yet
|
|
336
|
+
expect(calls).toEqual([])
|
|
337
|
+
|
|
338
|
+
editor.pointerMove(50, 40)
|
|
339
|
+
|
|
340
|
+
// Should have called start once and change at least once now
|
|
341
|
+
expect(calls).toEqual(['start', 'change'])
|
|
342
|
+
|
|
343
|
+
editor.pointerMove(50, 35)
|
|
344
|
+
|
|
345
|
+
// Should have called start once and change multiple times
|
|
346
|
+
expect(calls).toEqual(['start', 'change', 'change'])
|
|
347
|
+
|
|
348
|
+
editor.cancel()
|
|
349
|
+
|
|
350
|
+
// Should have called cancel instead of end
|
|
351
|
+
expect(calls).toEqual(['start', 'change', 'change', 'cancel'])
|
|
168
352
|
})
|
|
169
353
|
|
|
170
354
|
it('Uses the shape utils onClick handler', () => {
|
|
171
355
|
const util = editor.getShapeUtil<TLFrameShape>('frame')
|
|
172
356
|
|
|
173
|
-
const fnClick =
|
|
357
|
+
const fnClick = vi.fn()
|
|
174
358
|
util.onClick = fnClick
|
|
175
359
|
|
|
176
360
|
editor.pointerDown(50, 50, ids.frame1)
|
|
@@ -184,7 +368,7 @@ describe('When interacting with a shape...', () => {
|
|
|
184
368
|
it('Uses the shape utils onClick handler', () => {
|
|
185
369
|
const util = editor.getShapeUtil<TLFrameShape>('frame')
|
|
186
370
|
|
|
187
|
-
const fnClick =
|
|
371
|
+
const fnClick = vi.fn((shape: any) => {
|
|
188
372
|
return {
|
|
189
373
|
...shape,
|
|
190
374
|
x: 100,
|
|
@@ -201,4 +385,170 @@ describe('When interacting with a shape...', () => {
|
|
|
201
385
|
// it should not be selected.
|
|
202
386
|
expect(editor.getSelectedShapeIds().length).toBe(0)
|
|
203
387
|
})
|
|
388
|
+
|
|
389
|
+
it('Fires handle dragging events', () => {
|
|
390
|
+
const util = editor.getShapeUtil<TLLineShape>('line')
|
|
391
|
+
|
|
392
|
+
const calls: string[] = []
|
|
393
|
+
|
|
394
|
+
util.onHandleDragStart = () => {
|
|
395
|
+
calls.push('start')
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
util.onHandleDrag = () => {
|
|
399
|
+
calls.push('change')
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
util.onHandleDragEnd = () => {
|
|
403
|
+
calls.push('end')
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
util.onHandleDragCancel = () => {
|
|
407
|
+
calls.push('cancel')
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
// Create a line shape with handles
|
|
411
|
+
const lineShape: TLLineShape = {
|
|
412
|
+
id: ids.line1,
|
|
413
|
+
type: 'line',
|
|
414
|
+
typeName: 'shape',
|
|
415
|
+
parentId: ids.page1,
|
|
416
|
+
index: 'a1' as any,
|
|
417
|
+
x: 100,
|
|
418
|
+
y: 100,
|
|
419
|
+
rotation: 0,
|
|
420
|
+
isLocked: false,
|
|
421
|
+
opacity: 1,
|
|
422
|
+
meta: {},
|
|
423
|
+
props: {
|
|
424
|
+
dash: 'draw',
|
|
425
|
+
size: 'm',
|
|
426
|
+
color: 'black',
|
|
427
|
+
spline: 'line',
|
|
428
|
+
scale: 1,
|
|
429
|
+
points: {
|
|
430
|
+
a1: { id: 'a1', index: 'a1' as any, x: 0, y: 0 },
|
|
431
|
+
a2: { id: 'a2', index: 'a2' as any, x: 100, y: 100 },
|
|
432
|
+
},
|
|
433
|
+
},
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
editor.createShapes([lineShape])
|
|
437
|
+
|
|
438
|
+
// Get the handle point
|
|
439
|
+
const handlePagePoint = editor
|
|
440
|
+
.getShapePageTransform(lineShape.id)!
|
|
441
|
+
.applyToPoint(lineShape.props.points['a2'])
|
|
442
|
+
|
|
443
|
+
editor.pointerDown(handlePagePoint.x, handlePagePoint.y, {
|
|
444
|
+
target: 'handle',
|
|
445
|
+
shape: editor.getShape(lineShape.id)!,
|
|
446
|
+
handle: { id: 'a2', type: 'vertex', index: 'a2' as any, x: 100, y: 100 },
|
|
447
|
+
})
|
|
448
|
+
|
|
449
|
+
editor.expectToBeIn('select.pointing_handle')
|
|
450
|
+
|
|
451
|
+
// Should not have called any callbacks yet
|
|
452
|
+
expect(calls).toEqual([])
|
|
453
|
+
|
|
454
|
+
editor.pointerMove(handlePagePoint.x + 20, handlePagePoint.y + 20) // Larger move to trigger drag
|
|
455
|
+
editor.expectToBeIn('select.dragging_handle')
|
|
456
|
+
|
|
457
|
+
// Should have called start once and change at least once now
|
|
458
|
+
expect(calls).toEqual(['start', 'change'])
|
|
459
|
+
|
|
460
|
+
editor.pointerMove(150, 150)
|
|
461
|
+
|
|
462
|
+
// Should have called start once and change multiple times
|
|
463
|
+
expect(calls).toEqual(['start', 'change', 'change'])
|
|
464
|
+
|
|
465
|
+
editor.pointerUp(150, 150)
|
|
466
|
+
editor.expectToBeIn('select.idle')
|
|
467
|
+
|
|
468
|
+
// Should have called end once now
|
|
469
|
+
expect(calls).toEqual(['start', 'change', 'change', 'end'])
|
|
470
|
+
})
|
|
471
|
+
|
|
472
|
+
it('Fires handle dragging cancel events', () => {
|
|
473
|
+
const util = editor.getShapeUtil<TLLineShape>('line')
|
|
474
|
+
|
|
475
|
+
const calls: string[] = []
|
|
476
|
+
|
|
477
|
+
util.onHandleDragStart = () => {
|
|
478
|
+
calls.push('start')
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
util.onHandleDrag = () => {
|
|
482
|
+
calls.push('change')
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
util.onHandleDragEnd = () => {
|
|
486
|
+
calls.push('end')
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
util.onHandleDragCancel = () => {
|
|
490
|
+
calls.push('cancel')
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
// Create a line shape with handles
|
|
494
|
+
const lineShape: TLLineShape = {
|
|
495
|
+
id: ids.line1,
|
|
496
|
+
type: 'line',
|
|
497
|
+
typeName: 'shape',
|
|
498
|
+
parentId: ids.page1,
|
|
499
|
+
index: 'a1' as any,
|
|
500
|
+
x: 100,
|
|
501
|
+
y: 100,
|
|
502
|
+
rotation: 0,
|
|
503
|
+
isLocked: false,
|
|
504
|
+
opacity: 1,
|
|
505
|
+
meta: {},
|
|
506
|
+
props: {
|
|
507
|
+
dash: 'draw',
|
|
508
|
+
size: 'm',
|
|
509
|
+
color: 'black',
|
|
510
|
+
spline: 'line',
|
|
511
|
+
scale: 1,
|
|
512
|
+
points: {
|
|
513
|
+
a1: { id: 'a1', index: 'a1' as any, x: 0, y: 0 },
|
|
514
|
+
a2: { id: 'a2', index: 'a2' as any, x: 100, y: 100 },
|
|
515
|
+
},
|
|
516
|
+
},
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
editor.createShapes([lineShape])
|
|
520
|
+
|
|
521
|
+
// Get the handle point
|
|
522
|
+
const handlePagePoint = editor
|
|
523
|
+
.getShapePageTransform(lineShape.id)!
|
|
524
|
+
.applyToPoint(lineShape.props.points['a2'])
|
|
525
|
+
|
|
526
|
+
editor.pointerDown(handlePagePoint.x, handlePagePoint.y, {
|
|
527
|
+
target: 'handle',
|
|
528
|
+
shape: editor.getShape(lineShape.id)!,
|
|
529
|
+
handle: { id: 'a2', type: 'vertex', index: 'a2' as any, x: 100, y: 100 },
|
|
530
|
+
})
|
|
531
|
+
|
|
532
|
+
editor.expectToBeIn('select.pointing_handle')
|
|
533
|
+
|
|
534
|
+
// Should not have called any callbacks yet
|
|
535
|
+
expect(calls).toEqual([])
|
|
536
|
+
|
|
537
|
+
editor.pointerMove(handlePagePoint.x + 20, handlePagePoint.y + 20) // Larger move to trigger drag
|
|
538
|
+
editor.expectToBeIn('select.dragging_handle')
|
|
539
|
+
|
|
540
|
+
// Should have called start once and change at least once now
|
|
541
|
+
expect(calls).toEqual(['start', 'change'])
|
|
542
|
+
|
|
543
|
+
editor.pointerMove(150, 150)
|
|
544
|
+
|
|
545
|
+
// Should have called start once and change multiple times
|
|
546
|
+
expect(calls).toEqual(['start', 'change', 'change'])
|
|
547
|
+
|
|
548
|
+
editor.cancel()
|
|
549
|
+
editor.expectToBeIn('select.idle')
|
|
550
|
+
|
|
551
|
+
// Should have called cancel instead of end
|
|
552
|
+
expect(calls).toEqual(['start', 'change', 'change', 'cancel'])
|
|
553
|
+
})
|
|
204
554
|
})
|