tldraw 3.16.0-internal.51e99e128bd4 → 3.16.0-internal.a478398270c6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-cjs/index.d.ts +23 -297
- package/dist-cjs/index.js +2 -30
- package/dist-cjs/index.js.map +2 -2
- package/dist-cjs/lib/TldrawImage.js +2 -5
- package/dist-cjs/lib/TldrawImage.js.map +3 -3
- package/dist-cjs/lib/canvas/TldrawCropHandles.js +1 -1
- package/dist-cjs/lib/canvas/TldrawCropHandles.js.map +2 -2
- package/dist-cjs/lib/canvas/TldrawHandles.js +1 -1
- package/dist-cjs/lib/canvas/TldrawHandles.js.map +2 -2
- package/dist-cjs/lib/canvas/TldrawOverlays.js +1 -1
- package/dist-cjs/lib/canvas/TldrawOverlays.js.map +2 -2
- package/dist-cjs/lib/canvas/TldrawScribble.js +1 -1
- package/dist-cjs/lib/canvas/TldrawScribble.js.map +2 -2
- package/dist-cjs/lib/canvas/TldrawSelectionForeground.js +271 -279
- package/dist-cjs/lib/canvas/TldrawSelectionForeground.js.map +2 -2
- package/dist-cjs/lib/defaultExternalContentHandlers.js +0 -1
- package/dist-cjs/lib/defaultExternalContentHandlers.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js +44 -27
- package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/arrowLabel.js +4 -16
- package/dist-cjs/lib/shapes/arrow/arrowLabel.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/arrowTargetState.js +1 -1
- package/dist-cjs/lib/shapes/arrow/arrowTargetState.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/elbow/ElbowArrowDebug.js +3 -3
- package/dist-cjs/lib/shapes/arrow/elbow/ElbowArrowDebug.js.map +1 -1
- package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.js +0 -3
- package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/shapes/draw/DrawShapeUtil.js +6 -3
- package/dist-cjs/lib/shapes/draw/DrawShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/embed/EmbedShapeUtil.js +1 -1
- package/dist-cjs/lib/shapes/embed/EmbedShapeUtil.js.map +1 -1
- package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js +17 -17
- package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/frame/components/FrameHeading.js +1 -1
- package/dist-cjs/lib/shapes/frame/components/FrameHeading.js.map +2 -2
- package/dist-cjs/lib/shapes/geo/GeoShapeUtil.js +2 -2
- package/dist-cjs/lib/shapes/geo/GeoShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/geo/components/GeoShapeBody.js +1 -2
- package/dist-cjs/lib/shapes/geo/components/GeoShapeBody.js.map +2 -2
- package/dist-cjs/lib/shapes/highlight/HighlightShapeUtil.js +4 -5
- package/dist-cjs/lib/shapes/highlight/HighlightShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/image/ImageShapeUtil.js +3 -3
- package/dist-cjs/lib/shapes/image/ImageShapeUtil.js.map +1 -1
- package/dist-cjs/lib/shapes/line/LineShapeUtil.js +5 -20
- package/dist-cjs/lib/shapes/line/LineShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/note/NoteShapeUtil.js +5 -6
- package/dist-cjs/lib/shapes/note/NoteShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/PathBuilder.js +3 -21
- package/dist-cjs/lib/shapes/shared/PathBuilder.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/PlainTextLabel.js +0 -1
- package/dist-cjs/lib/shapes/shared/PlainTextLabel.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/RichTextLabel.js +2 -5
- package/dist-cjs/lib/shapes/shared/RichTextLabel.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/ShapeFill.js +4 -4
- package/dist-cjs/lib/shapes/shared/ShapeFill.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/SvgTextLabel.js +3 -4
- package/dist-cjs/lib/shapes/shared/SvgTextLabel.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/freehand/svg.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/usePrefersReducedMotion.js +1 -10
- package/dist-cjs/lib/shapes/shared/usePrefersReducedMotion.js.map +2 -2
- package/dist-cjs/lib/shapes/text/TextShapeUtil.js +13 -7
- package/dist-cjs/lib/shapes/text/TextShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/video/VideoShapeUtil.js +3 -3
- package/dist-cjs/lib/shapes/video/VideoShapeUtil.js.map +1 -1
- package/dist-cjs/lib/styles.js.map +2 -2
- package/dist-cjs/lib/tools/EraserTool/childStates/Erasing.js +1 -25
- package/dist-cjs/lib/tools/EraserTool/childStates/Erasing.js.map +2 -2
- package/dist-cjs/lib/tools/EraserTool/childStates/Pointing.js +0 -12
- package/dist-cjs/lib/tools/EraserTool/childStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.js +1 -7
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js +22 -43
- package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Idle.js +15 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Idle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingShape.js +0 -5
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingShape.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js +0 -8
- package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Rotating.js +0 -8
- package/dist-cjs/lib/tools/SelectTool/childStates/Rotating.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js +0 -8
- package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js.map +2 -2
- package/dist-cjs/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.js.map +2 -2
- package/dist-cjs/lib/ui/TldrawUi.js +0 -14
- package/dist-cjs/lib/ui/TldrawUi.js.map +3 -3
- package/dist-cjs/lib/ui/components/A11y.js +12 -14
- package/dist-cjs/lib/ui/components/A11y.js.map +2 -2
- package/dist-cjs/lib/ui/components/ActionsMenu/DefaultActionsMenu.js +3 -12
- package/dist-cjs/lib/ui/components/ActionsMenu/DefaultActionsMenu.js.map +2 -2
- package/dist-cjs/lib/ui/components/DefaultMenuPanel.js +2 -3
- package/dist-cjs/lib/ui/components/DefaultMenuPanel.js.map +2 -2
- package/dist-cjs/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.js +1 -51
- package/dist-cjs/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.js.map +2 -2
- package/dist-cjs/lib/ui/components/MainMenu/DefaultMainMenuContent.js +2 -3
- package/dist-cjs/lib/ui/components/MainMenu/DefaultMainMenuContent.js.map +2 -2
- package/dist-cjs/lib/ui/components/Minimap/MinimapManager.js +4 -4
- package/dist-cjs/lib/ui/components/Minimap/MinimapManager.js.map +2 -2
- package/dist-cjs/lib/ui/components/MobileStylePanel.js +3 -5
- package/dist-cjs/lib/ui/components/MobileStylePanel.js.map +2 -2
- package/dist-cjs/lib/ui/components/NavigationPanel/DefaultNavigationPanel.js +5 -4
- package/dist-cjs/lib/ui/components/NavigationPanel/DefaultNavigationPanel.js.map +2 -2
- package/dist-cjs/lib/ui/components/PageMenu/DefaultPageMenu.js +1 -2
- package/dist-cjs/lib/ui/components/PageMenu/DefaultPageMenu.js.map +2 -2
- package/dist-cjs/lib/ui/components/SharePanel/PeopleMenuItem.js +2 -3
- package/dist-cjs/lib/ui/components/SharePanel/PeopleMenuItem.js.map +2 -2
- package/dist-cjs/lib/ui/components/SharePanel/UserPresenceColorPicker.js +2 -2
- package/dist-cjs/lib/ui/components/SharePanel/UserPresenceColorPicker.js.map +2 -2
- package/dist-cjs/lib/ui/components/Spinner.js +25 -2
- package/dist-cjs/lib/ui/components/Spinner.js.map +2 -2
- package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanel.js +0 -2
- package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanel.js.map +2 -2
- package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanelContent.js +139 -171
- package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanelContent.js.map +2 -2
- package/dist-cjs/lib/ui/components/StylePanel/DoubleDropdownPicker.js +3 -3
- package/dist-cjs/lib/ui/components/StylePanel/DoubleDropdownPicker.js.map +2 -2
- package/dist-cjs/lib/ui/components/StylePanel/DropdownPicker.js +25 -26
- package/dist-cjs/lib/ui/components/StylePanel/DropdownPicker.js.map +3 -3
- package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbar.js +7 -21
- package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbar.js.map +3 -3
- package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbarContent.js +1 -1
- package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbarContent.js.map +2 -2
- package/dist-cjs/lib/ui/components/Toolbar/DefaultToolbar.js +21 -66
- package/dist-cjs/lib/ui/components/Toolbar/DefaultToolbar.js.map +3 -3
- package/dist-cjs/lib/ui/components/Toolbar/OverflowingToolbar.js +80 -189
- package/dist-cjs/lib/ui/components/Toolbar/OverflowingToolbar.js.map +3 -3
- package/dist-cjs/lib/ui/components/Toolbar/ToggleToolLockedButton.js +4 -5
- package/dist-cjs/lib/ui/components/Toolbar/ToggleToolLockedButton.js.map +2 -2
- package/dist-cjs/lib/ui/components/menu-items.js +0 -22
- package/dist-cjs/lib/ui/components/menu-items.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/Button/TldrawUiButtonIcon.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiButtonPicker.js +16 -7
- package/dist-cjs/lib/ui/components/primitives/TldrawUiButtonPicker.js.map +3 -3
- package/dist-cjs/lib/ui/components/primitives/TldrawUiContextualToolbar.js +1 -1
- package/dist-cjs/lib/ui/components/primitives/TldrawUiContextualToolbar.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiDialog.js +1 -1
- package/dist-cjs/lib/ui/components/primitives/TldrawUiDialog.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiIcon.js +1 -35
- package/dist-cjs/lib/ui/components/primitives/TldrawUiIcon.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiPopover.js +2 -3
- package/dist-cjs/lib/ui/components/primitives/TldrawUiPopover.js.map +3 -3
- package/dist-cjs/lib/ui/components/primitives/TldrawUiSlider.js +2 -6
- package/dist-cjs/lib/ui/components/primitives/TldrawUiSlider.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiToolbar.js +7 -31
- package/dist-cjs/lib/ui/components/primitives/TldrawUiToolbar.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuCheckboxItem.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuContext.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuGroup.js +12 -25
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuGroup.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js +22 -154
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js.map +2 -2
- package/dist-cjs/lib/ui/context/TldrawUiContextProvider.js +2 -3
- package/dist-cjs/lib/ui/context/TldrawUiContextProvider.js.map +2 -2
- package/dist-cjs/lib/ui/context/actions.js +8 -57
- package/dist-cjs/lib/ui/context/actions.js.map +2 -2
- package/dist-cjs/lib/ui/context/events.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/menu-hooks.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/useKeyboardShortcuts.js +2 -2
- package/dist-cjs/lib/ui/hooks/useKeyboardShortcuts.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/useTools.js +9 -94
- package/dist-cjs/lib/ui/hooks/useTools.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/useTranslation/TLUiTranslationKey.js.map +1 -1
- package/dist-cjs/lib/ui/hooks/useTranslation/defaultTranslation.js +0 -11
- package/dist-cjs/lib/ui/hooks/useTranslation/defaultTranslation.js.map +2 -2
- package/dist-cjs/lib/ui/kbd-utils.js +1 -2
- package/dist-cjs/lib/ui/kbd-utils.js.map +2 -2
- package/dist-cjs/lib/ui/version.js +3 -3
- package/dist-cjs/lib/ui/version.js.map +1 -1
- package/dist-cjs/lib/utils/excalidraw/putExcalidrawContent.js +1 -1
- package/dist-cjs/lib/utils/excalidraw/putExcalidrawContent.js.map +2 -2
- package/dist-cjs/lib/utils/tldr/buildFromV1Document.js +2 -3
- package/dist-cjs/lib/utils/tldr/buildFromV1Document.js.map +2 -2
- package/dist-esm/index.d.mts +23 -297
- package/dist-esm/index.mjs +4 -51
- package/dist-esm/index.mjs.map +2 -2
- package/dist-esm/lib/TldrawImage.mjs +2 -5
- package/dist-esm/lib/TldrawImage.mjs.map +2 -2
- package/dist-esm/lib/canvas/TldrawCropHandles.mjs +1 -1
- package/dist-esm/lib/canvas/TldrawCropHandles.mjs.map +2 -2
- package/dist-esm/lib/canvas/TldrawHandles.mjs +1 -1
- package/dist-esm/lib/canvas/TldrawHandles.mjs.map +2 -2
- package/dist-esm/lib/canvas/TldrawOverlays.mjs +1 -1
- package/dist-esm/lib/canvas/TldrawOverlays.mjs.map +2 -2
- package/dist-esm/lib/canvas/TldrawScribble.mjs +1 -1
- package/dist-esm/lib/canvas/TldrawScribble.mjs.map +2 -2
- package/dist-esm/lib/canvas/TldrawSelectionForeground.mjs +271 -279
- package/dist-esm/lib/canvas/TldrawSelectionForeground.mjs.map +2 -2
- package/dist-esm/lib/defaultExternalContentHandlers.mjs +0 -1
- package/dist-esm/lib/defaultExternalContentHandlers.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs +44 -30
- package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/arrowLabel.mjs +5 -19
- package/dist-esm/lib/shapes/arrow/arrowLabel.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/arrowTargetState.mjs +1 -1
- package/dist-esm/lib/shapes/arrow/arrowTargetState.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/elbow/ElbowArrowDebug.mjs +3 -3
- package/dist-esm/lib/shapes/arrow/elbow/ElbowArrowDebug.mjs.map +1 -1
- package/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs +0 -3
- package/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/shapes/draw/DrawShapeUtil.mjs +6 -4
- package/dist-esm/lib/shapes/draw/DrawShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/embed/EmbedShapeUtil.mjs +1 -1
- package/dist-esm/lib/shapes/embed/EmbedShapeUtil.mjs.map +1 -1
- package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs +17 -18
- package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/frame/components/FrameHeading.mjs +1 -1
- package/dist-esm/lib/shapes/frame/components/FrameHeading.mjs.map +2 -2
- package/dist-esm/lib/shapes/geo/GeoShapeUtil.mjs +2 -3
- package/dist-esm/lib/shapes/geo/GeoShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/geo/components/GeoShapeBody.mjs +1 -2
- package/dist-esm/lib/shapes/geo/components/GeoShapeBody.mjs.map +2 -2
- package/dist-esm/lib/shapes/highlight/HighlightShapeUtil.mjs +4 -6
- package/dist-esm/lib/shapes/highlight/HighlightShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/image/ImageShapeUtil.mjs +3 -3
- package/dist-esm/lib/shapes/image/ImageShapeUtil.mjs.map +1 -1
- package/dist-esm/lib/shapes/line/LineShapeUtil.mjs +5 -21
- package/dist-esm/lib/shapes/line/LineShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs +5 -7
- package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/PathBuilder.mjs +3 -22
- package/dist-esm/lib/shapes/shared/PathBuilder.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/PlainTextLabel.mjs +0 -1
- package/dist-esm/lib/shapes/shared/PlainTextLabel.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/RichTextLabel.mjs +2 -5
- package/dist-esm/lib/shapes/shared/RichTextLabel.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/ShapeFill.mjs +4 -5
- package/dist-esm/lib/shapes/shared/ShapeFill.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/SvgTextLabel.mjs +3 -4
- package/dist-esm/lib/shapes/shared/SvgTextLabel.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/freehand/svg.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/usePrefersReducedMotion.mjs +1 -10
- package/dist-esm/lib/shapes/shared/usePrefersReducedMotion.mjs.map +2 -2
- package/dist-esm/lib/shapes/text/TextShapeUtil.mjs +13 -8
- package/dist-esm/lib/shapes/text/TextShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/video/VideoShapeUtil.mjs +3 -3
- package/dist-esm/lib/shapes/video/VideoShapeUtil.mjs.map +1 -1
- package/dist-esm/lib/styles.mjs.map +2 -2
- package/dist-esm/lib/tools/EraserTool/childStates/Erasing.mjs +1 -26
- package/dist-esm/lib/tools/EraserTool/childStates/Erasing.mjs.map +2 -2
- package/dist-esm/lib/tools/EraserTool/childStates/Pointing.mjs +0 -13
- package/dist-esm/lib/tools/EraserTool/childStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.mjs +1 -7
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs +22 -43
- package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Idle.mjs +15 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Idle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingShape.mjs +0 -5
- package/dist-esm/lib/tools/SelectTool/childStates/PointingShape.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs +0 -8
- package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Rotating.mjs +0 -8
- package/dist-esm/lib/tools/SelectTool/childStates/Rotating.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs +0 -8
- package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs.map +2 -2
- package/dist-esm/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.mjs.map +2 -2
- package/dist-esm/lib/ui/TldrawUi.mjs +2 -16
- package/dist-esm/lib/ui/TldrawUi.mjs.map +3 -3
- package/dist-esm/lib/ui/components/A11y.mjs +12 -14
- package/dist-esm/lib/ui/components/A11y.mjs.map +2 -2
- package/dist-esm/lib/ui/components/ActionsMenu/DefaultActionsMenu.mjs +3 -12
- package/dist-esm/lib/ui/components/ActionsMenu/DefaultActionsMenu.mjs.map +2 -2
- package/dist-esm/lib/ui/components/DefaultMenuPanel.mjs +2 -3
- package/dist-esm/lib/ui/components/DefaultMenuPanel.mjs.map +2 -2
- package/dist-esm/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.mjs +1 -51
- package/dist-esm/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.mjs.map +2 -2
- package/dist-esm/lib/ui/components/MainMenu/DefaultMainMenuContent.mjs +3 -3
- package/dist-esm/lib/ui/components/MainMenu/DefaultMainMenuContent.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Minimap/MinimapManager.mjs +4 -4
- package/dist-esm/lib/ui/components/Minimap/MinimapManager.mjs.map +2 -2
- package/dist-esm/lib/ui/components/MobileStylePanel.mjs +3 -6
- package/dist-esm/lib/ui/components/MobileStylePanel.mjs.map +2 -2
- package/dist-esm/lib/ui/components/NavigationPanel/DefaultNavigationPanel.mjs +5 -4
- package/dist-esm/lib/ui/components/NavigationPanel/DefaultNavigationPanel.mjs.map +2 -2
- package/dist-esm/lib/ui/components/PageMenu/DefaultPageMenu.mjs +1 -2
- package/dist-esm/lib/ui/components/PageMenu/DefaultPageMenu.mjs.map +2 -2
- package/dist-esm/lib/ui/components/SharePanel/PeopleMenuItem.mjs +2 -3
- package/dist-esm/lib/ui/components/SharePanel/PeopleMenuItem.mjs.map +2 -2
- package/dist-esm/lib/ui/components/SharePanel/UserPresenceColorPicker.mjs +2 -2
- package/dist-esm/lib/ui/components/SharePanel/UserPresenceColorPicker.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Spinner.mjs +26 -3
- package/dist-esm/lib/ui/components/Spinner.mjs.map +2 -2
- package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanel.mjs +1 -3
- package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanel.mjs.map +2 -2
- package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanelContent.mjs +139 -171
- package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanelContent.mjs.map +2 -2
- package/dist-esm/lib/ui/components/StylePanel/DoubleDropdownPicker.mjs +3 -3
- package/dist-esm/lib/ui/components/StylePanel/DoubleDropdownPicker.mjs.map +2 -2
- package/dist-esm/lib/ui/components/StylePanel/DropdownPicker.mjs +25 -26
- package/dist-esm/lib/ui/components/StylePanel/DropdownPicker.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbar.mjs +9 -23
- package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbar.mjs.map +3 -3
- package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbarContent.mjs +1 -1
- package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbarContent.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Toolbar/DefaultToolbar.mjs +21 -56
- package/dist-esm/lib/ui/components/Toolbar/DefaultToolbar.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Toolbar/OverflowingToolbar.mjs +81 -192
- package/dist-esm/lib/ui/components/Toolbar/OverflowingToolbar.mjs.map +3 -3
- package/dist-esm/lib/ui/components/Toolbar/ToggleToolLockedButton.mjs +4 -5
- package/dist-esm/lib/ui/components/Toolbar/ToggleToolLockedButton.mjs.map +2 -2
- package/dist-esm/lib/ui/components/menu-items.mjs +0 -22
- package/dist-esm/lib/ui/components/menu-items.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/Button/TldrawUiButtonIcon.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiButtonPicker.mjs +6 -8
- package/dist-esm/lib/ui/components/primitives/TldrawUiButtonPicker.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiContextualToolbar.mjs +1 -1
- package/dist-esm/lib/ui/components/primitives/TldrawUiContextualToolbar.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiDialog.mjs +1 -1
- package/dist-esm/lib/ui/components/primitives/TldrawUiDialog.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiIcon.mjs +2 -36
- package/dist-esm/lib/ui/components/primitives/TldrawUiIcon.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiPopover.mjs +2 -3
- package/dist-esm/lib/ui/components/primitives/TldrawUiPopover.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiSlider.mjs +2 -6
- package/dist-esm/lib/ui/components/primitives/TldrawUiSlider.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiToolbar.mjs +7 -31
- package/dist-esm/lib/ui/components/primitives/TldrawUiToolbar.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuCheckboxItem.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuContext.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuGroup.mjs +12 -25
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuGroup.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs +24 -162
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs.map +2 -2
- package/dist-esm/lib/ui/context/TldrawUiContextProvider.mjs +2 -3
- package/dist-esm/lib/ui/context/TldrawUiContextProvider.mjs.map +2 -2
- package/dist-esm/lib/ui/context/actions.mjs +8 -57
- package/dist-esm/lib/ui/context/actions.mjs.map +2 -2
- package/dist-esm/lib/ui/context/events.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/menu-hooks.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/useKeyboardShortcuts.mjs +2 -2
- package/dist-esm/lib/ui/hooks/useKeyboardShortcuts.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/useTools.mjs +10 -102
- package/dist-esm/lib/ui/hooks/useTools.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/useTranslation/defaultTranslation.mjs +0 -11
- package/dist-esm/lib/ui/hooks/useTranslation/defaultTranslation.mjs.map +2 -2
- package/dist-esm/lib/ui/kbd-utils.mjs +1 -2
- package/dist-esm/lib/ui/kbd-utils.mjs.map +2 -2
- package/dist-esm/lib/ui/version.mjs +3 -3
- package/dist-esm/lib/ui/version.mjs.map +1 -1
- package/dist-esm/lib/utils/excalidraw/putExcalidrawContent.mjs +1 -1
- package/dist-esm/lib/utils/excalidraw/putExcalidrawContent.mjs.map +2 -2
- package/dist-esm/lib/utils/tldr/buildFromV1Document.mjs +2 -3
- package/dist-esm/lib/utils/tldr/buildFromV1Document.mjs.map +2 -2
- package/package.json +34 -12
- package/src/index.ts +2 -39
- package/src/lib/TldrawImage.tsx +2 -6
- package/src/lib/canvas/TldrawCropHandles.tsx +1 -3
- package/src/lib/canvas/TldrawHandles.tsx +1 -5
- package/src/lib/canvas/TldrawOverlays.tsx +1 -1
- package/src/lib/canvas/TldrawScribble.tsx +1 -1
- package/src/lib/canvas/TldrawSelectionForeground.tsx +1 -5
- package/src/lib/defaultExternalContentHandlers.ts +1 -2
- package/src/lib/shapes/arrow/ArrowShapeOptions.test.ts +1 -2
- package/src/lib/shapes/arrow/ArrowShapeTool.test.ts +3 -4
- package/src/lib/shapes/arrow/ArrowShapeUtil.test.ts +11 -12
- package/src/lib/shapes/arrow/ArrowShapeUtil.tsx +46 -30
- package/src/lib/shapes/arrow/arrowLabel.ts +3 -23
- package/src/lib/shapes/arrow/arrowTargetState.ts +1 -2
- package/src/lib/shapes/arrow/elbow/ElbowArrowDebug.tsx +3 -3
- package/src/lib/shapes/arrow/toolStates/Pointing.tsx +0 -3
- package/src/lib/shapes/draw/DrawShapeTool.test.ts +5 -0
- package/src/lib/shapes/draw/DrawShapeUtil.tsx +7 -4
- package/src/lib/shapes/embed/EmbedShapeUtil.tsx +1 -1
- package/src/lib/shapes/frame/FrameShapeUtil.tsx +21 -26
- package/src/lib/shapes/frame/components/FrameHeading.tsx +1 -1
- package/src/lib/shapes/geo/GeoShapeUtil.tsx +2 -3
- package/src/lib/shapes/geo/components/GeoShapeBody.tsx +2 -2
- package/src/lib/shapes/highlight/HighlightShapeUtil.tsx +4 -7
- package/src/lib/shapes/image/ImageShapeUtil.tsx +3 -3
- package/src/lib/shapes/line/LineShapeUtil.test.tsx +3 -4
- package/src/lib/shapes/line/LineShapeUtil.tsx +6 -25
- package/src/lib/shapes/line/__snapshots__/LineShapeUtil.test.tsx.snap +2 -2
- package/src/lib/shapes/note/NoteShapeUtil.tsx +4 -10
- package/src/lib/shapes/shared/PathBuilder.test.tsx +1 -1
- package/src/lib/shapes/shared/PathBuilder.tsx +1 -35
- package/src/lib/shapes/shared/PlainTextLabel.tsx +0 -1
- package/src/lib/shapes/shared/RichTextLabel.tsx +0 -4
- package/src/lib/shapes/shared/ShapeFill.tsx +4 -5
- package/src/lib/shapes/shared/SvgTextLabel.tsx +2 -4
- package/src/lib/shapes/shared/freehand/svg.ts +0 -2
- package/src/lib/shapes/shared/usePrefersReducedMotion.tsx +1 -11
- package/src/lib/shapes/text/TextShapeTool.test.ts +5 -6
- package/src/lib/shapes/text/TextShapeUtil.tsx +14 -8
- package/src/lib/shapes/video/VideoShapeUtil.tsx +3 -3
- package/src/lib/styles.tsx +1 -3
- package/src/lib/tools/EraserTool/childStates/Erasing.ts +1 -34
- package/src/lib/tools/EraserTool/childStates/Pointing.ts +0 -20
- package/src/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.ts +1 -8
- package/src/lib/tools/SelectTool/childStates/DraggingHandle.tsx +30 -54
- package/src/lib/tools/SelectTool/childStates/Idle.ts +24 -2
- package/src/lib/tools/SelectTool/childStates/PointingShape.ts +0 -7
- package/src/lib/tools/SelectTool/childStates/Resizing.ts +1 -12
- package/src/lib/tools/SelectTool/childStates/Rotating.ts +0 -11
- package/src/lib/tools/SelectTool/childStates/Translating.ts +1 -11
- package/src/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.ts +0 -1
- package/src/lib/ui/TldrawUi.tsx +2 -17
- package/src/lib/ui/components/A11y.tsx +13 -15
- package/src/lib/ui/components/ActionsMenu/DefaultActionsMenu.tsx +3 -15
- package/src/lib/ui/components/DefaultMenuPanel.tsx +3 -4
- package/src/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.tsx +0 -40
- package/src/lib/ui/components/MainMenu/DefaultMainMenuContent.tsx +2 -4
- package/src/lib/ui/components/Minimap/MinimapManager.ts +4 -4
- package/src/lib/ui/components/MobileStylePanel.tsx +6 -9
- package/src/lib/ui/components/NavigationPanel/DefaultNavigationPanel.tsx +5 -4
- package/src/lib/ui/components/PageMenu/DefaultPageMenu.tsx +2 -3
- package/src/lib/ui/components/SharePanel/PeopleMenuItem.tsx +3 -4
- package/src/lib/ui/components/SharePanel/UserPresenceColorPicker.tsx +3 -3
- package/src/lib/ui/components/Spinner.tsx +24 -2
- package/src/lib/ui/components/StylePanel/DefaultStylePanel.tsx +1 -3
- package/src/lib/ui/components/StylePanel/DefaultStylePanelContent.tsx +106 -146
- package/src/lib/ui/components/StylePanel/DoubleDropdownPicker.tsx +3 -3
- package/src/lib/ui/components/StylePanel/DropdownPicker.tsx +6 -7
- package/src/lib/ui/components/Toolbar/DefaultImageToolbar.tsx +9 -25
- package/src/lib/ui/components/Toolbar/DefaultImageToolbarContent.tsx +1 -1
- package/src/lib/ui/components/Toolbar/DefaultToolbar.tsx +23 -55
- package/src/lib/ui/components/Toolbar/OverflowingToolbar.tsx +61 -212
- package/src/lib/ui/components/Toolbar/ToggleToolLockedButton.tsx +12 -17
- package/src/lib/ui/components/menu-items.tsx +0 -25
- package/src/lib/ui/components/primitives/Button/TldrawUiButtonIcon.tsx +2 -2
- package/src/lib/ui/components/primitives/TldrawUiButtonPicker.tsx +35 -40
- package/src/lib/ui/components/primitives/TldrawUiContextualToolbar.tsx +1 -1
- package/src/lib/ui/components/primitives/TldrawUiDialog.tsx +1 -1
- package/src/lib/ui/components/primitives/TldrawUiIcon.tsx +3 -41
- package/src/lib/ui/components/primitives/TldrawUiPopover.tsx +2 -4
- package/src/lib/ui/components/primitives/TldrawUiSlider.tsx +1 -6
- package/src/lib/ui/components/primitives/TldrawUiToolbar.tsx +12 -56
- package/src/lib/ui/components/primitives/menus/TldrawUiMenuCheckboxItem.tsx +2 -2
- package/src/lib/ui/components/primitives/menus/TldrawUiMenuContext.tsx +1 -0
- package/src/lib/ui/components/primitives/menus/TldrawUiMenuGroup.tsx +16 -29
- package/src/lib/ui/components/primitives/menus/TldrawUiMenuItem.tsx +23 -224
- package/src/lib/ui/context/TldrawUiContextProvider.tsx +20 -23
- package/src/lib/ui/context/actions.tsx +9 -59
- package/src/lib/ui/context/events.tsx +2 -6
- package/src/lib/ui/hooks/menu-hooks.ts +0 -1
- package/src/lib/ui/hooks/useKeyboardShortcuts.ts +2 -3
- package/src/lib/ui/hooks/useTools.tsx +11 -142
- package/src/lib/ui/hooks/useTranslation/TLUiTranslationKey.ts +0 -11
- package/src/lib/ui/hooks/useTranslation/defaultTranslation.ts +0 -11
- package/src/lib/ui/kbd-utils.ts +1 -2
- package/src/lib/ui/version.ts +3 -3
- package/src/lib/ui.css +314 -414
- package/src/lib/utils/excalidraw/__snapshots__/putExcalidrawContent.test.tsx.snap +7 -21
- package/src/lib/utils/excalidraw/putExcalidrawContent.ts +1 -1
- package/src/lib/utils/tldr/__snapshots__/buildFromV1Document.test.ts.snap +7 -28
- package/src/lib/utils/tldr/buildFromV1Document.ts +1 -2
- package/src/test/A11y.test.tsx +2 -3
- package/src/test/ClickManager.test.ts +6 -7
- package/src/test/Editor.test.tsx +20 -21
- package/src/test/EraserTool.test.ts +13 -184
- package/src/test/HandTool.test.ts +9 -10
- package/src/test/HighlightShape.test.ts +1 -2
- package/src/test/SelectTool.test.ts +13 -40
- package/src/test/TLUserPreferences.test.ts +3 -4
- package/src/test/TestEditor.ts +15 -13
- package/src/test/TldrawEditor.test.tsx +10 -11
- package/src/test/ZoomTool.test.ts +6 -7
- package/src/test/__snapshots__/drawing.test.ts.snap +2 -2
- package/src/test/__snapshots__/groups.test.tsx.snap +6 -6
- package/src/test/__snapshots__/resizing.test.ts.snap +2 -2
- package/src/test/arrows-megabus.test.tsx +10 -17
- package/src/test/bindings.test.tsx +37 -24
- package/src/test/bookmark-shapes.test.ts +8 -1
- package/src/test/commands/__snapshots__/getSvgString.test.ts.snap +7 -23
- package/src/test/commands/__snapshots__/packShapes.test.ts.snap +8 -8
- package/src/test/commands/__snapshots__/zoomToFit.test.ts.snap +2 -2
- package/src/test/commands/alignShapes.test.tsx +24 -25
- package/src/test/commands/animationSpeed.test.ts +1 -2
- package/src/test/commands/centerOnPoint.test.ts +2 -3
- package/src/test/commands/clipboard.test.ts +2 -3
- package/src/test/commands/createShapes.test.ts +1 -2
- package/src/test/commands/deletePage.test.ts +1 -84
- package/src/test/commands/deleteShapes.test.ts +1 -2
- package/src/test/commands/distributeShapes.test.tsx +10 -11
- package/src/test/commands/getSvgString.test.ts +1 -2
- package/src/test/commands/packShapes.test.ts +4 -5
- package/src/test/commands/resizeShape.test.ts +1 -2
- package/src/test/commands/rotateShapes.test.ts +6 -7
- package/src/test/commands/setCamera.test.ts +3 -4
- package/src/test/commands/setCurrentPage.test.ts +2 -3
- package/src/test/commands/stackShapes.test.ts +10 -11
- package/src/test/commands/stretch.test.tsx +12 -13
- package/src/test/createDeepLink.test.tsx +1 -2
- package/src/test/cropping.test.ts +2 -3
- package/src/test/drawing.test.ts +1 -2
- package/src/test/flipShapes.test.ts +3 -4
- package/src/test/frames.test.ts +24 -25
- package/src/test/getCulledShapes.test.tsx +2 -3
- package/src/test/groups.test.tsx +2 -2
- package/src/test/handleDeepLink.test.tsx +1 -2
- package/src/test/maxShapes.test.ts +2 -3
- package/src/test/modifiers.test.ts +4 -5
- package/src/test/navigation.test.ts +9 -264
- package/src/test/panning.test.ts +1 -2
- package/src/test/perf/perf.test.ts +1 -2
- package/src/test/registerDeepLinkListener.test.tsx +9 -10
- package/src/test/resizing.test.ts +38 -39
- package/src/test/select.test.tsx +3 -4
- package/src/test/selection-omnibus.test.ts +10 -11
- package/src/test/shapeutils.test.ts +48 -398
- package/src/test/translating.test.ts +9 -10
- package/tldraw.css +627 -726
- package/dist-cjs/lib/ui/components/AccessibilityMenu.js +0 -35
- package/dist-cjs/lib/ui/components/AccessibilityMenu.js.map +0 -7
- package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js +0 -268
- package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js.map +0 -7
- package/dist-cjs/lib/ui/components/primitives/layout.js +0 -76
- package/dist-cjs/lib/ui/components/primitives/layout.js.map +0 -7
- package/dist-esm/lib/ui/components/AccessibilityMenu.mjs +0 -19
- package/dist-esm/lib/ui/components/AccessibilityMenu.mjs.map +0 -7
- package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs +0 -245
- package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs.map +0 -7
- package/dist-esm/lib/ui/components/primitives/layout.mjs +0 -46
- package/dist-esm/lib/ui/components/primitives/layout.mjs.map +0 -7
- package/src/lib/ui/components/AccessibilityMenu.tsx +0 -20
- package/src/lib/ui/components/primitives/TldrawUiTooltip.tsx +0 -327
- package/src/lib/ui/components/primitives/layout.tsx +0 -107
- package/src/test/inner-outer-margin.test.ts +0 -315
|
@@ -6,8 +6,6 @@ import { StrokePoint } from './types'
|
|
|
6
6
|
*
|
|
7
7
|
* @param points - The stroke points returned from perfect-freehand
|
|
8
8
|
* @param closed - Whether the shape is closed
|
|
9
|
-
*
|
|
10
|
-
* @public
|
|
11
9
|
*/
|
|
12
10
|
export function getSvgPathFromStrokePoints(points: StrokePoint[], closed = false): string {
|
|
13
11
|
const len = points.length
|
|
@@ -1,20 +1,10 @@
|
|
|
1
|
-
import { useMaybeEditor, useValue } from '@tldraw/editor'
|
|
2
1
|
import { useEffect, useState } from 'react'
|
|
3
2
|
|
|
4
3
|
/** @public */
|
|
5
4
|
export function usePrefersReducedMotion() {
|
|
6
|
-
const editor = useMaybeEditor()
|
|
7
|
-
const animationSpeed = useValue('animationSpeed', () => editor?.user.getAnimationSpeed(), [
|
|
8
|
-
editor,
|
|
9
|
-
])
|
|
10
5
|
const [prefersReducedMotion, setPrefersReducedMotion] = useState(false)
|
|
11
6
|
|
|
12
7
|
useEffect(() => {
|
|
13
|
-
if (animationSpeed !== undefined) {
|
|
14
|
-
setPrefersReducedMotion(animationSpeed === 0 ? true : false)
|
|
15
|
-
return
|
|
16
|
-
}
|
|
17
|
-
|
|
18
8
|
if (typeof window === 'undefined' || !('matchMedia' in window)) return
|
|
19
9
|
const mql = window.matchMedia('(prefers-reduced-motion: reduce)')
|
|
20
10
|
const handler = () => {
|
|
@@ -23,7 +13,7 @@ export function usePrefersReducedMotion() {
|
|
|
23
13
|
handler()
|
|
24
14
|
mql.addEventListener('change', handler)
|
|
25
15
|
return () => mql.removeEventListener('change', handler)
|
|
26
|
-
}, [
|
|
16
|
+
}, [])
|
|
27
17
|
|
|
28
18
|
return prefersReducedMotion
|
|
29
19
|
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { DefaultTextAlignStyle, TLTextShape, toRichText } from '@tldraw/editor'
|
|
2
|
-
import { vi } from 'vitest'
|
|
3
2
|
import { TestEditor } from '../../../test/TestEditor'
|
|
4
3
|
import { TextShapeTool } from './TextShapeTool'
|
|
5
4
|
|
|
6
5
|
let editor: TestEditor
|
|
7
|
-
|
|
6
|
+
jest.useFakeTimers()
|
|
8
7
|
|
|
9
8
|
beforeEach(() => {
|
|
10
9
|
editor = new TestEditor()
|
|
@@ -116,7 +115,7 @@ describe('When in the pointing state', () => {
|
|
|
116
115
|
|
|
117
116
|
// Go back to start and wait a little to satisfy the time requirement
|
|
118
117
|
editor.pointerMove(0, 0)
|
|
119
|
-
|
|
118
|
+
jest.advanceTimersByTime(200)
|
|
120
119
|
|
|
121
120
|
// y axis doesn't matter
|
|
122
121
|
editor.pointerMove(0, 100)
|
|
@@ -188,7 +187,7 @@ describe('When resizing', () => {
|
|
|
188
187
|
it('bails on escape while resizing and returns to text.idle', () => {
|
|
189
188
|
editor.setCurrentTool('text')
|
|
190
189
|
editor.pointerDown(0, 0)
|
|
191
|
-
|
|
190
|
+
jest.advanceTimersByTime(200)
|
|
192
191
|
editor.pointerMove(100, 100)
|
|
193
192
|
editor.expectToBeIn('select.resizing')
|
|
194
193
|
editor.cancel()
|
|
@@ -199,7 +198,7 @@ describe('When resizing', () => {
|
|
|
199
198
|
it('does not bails on interrupt while resizing', () => {
|
|
200
199
|
editor.setCurrentTool('text')
|
|
201
200
|
editor.pointerDown(0, 0)
|
|
202
|
-
|
|
201
|
+
jest.advanceTimersByTime(200)
|
|
203
202
|
editor.pointerMove(100, 100)
|
|
204
203
|
editor.expectToBeIn('select.resizing')
|
|
205
204
|
editor.interrupt()
|
|
@@ -211,7 +210,7 @@ describe('When resizing', () => {
|
|
|
211
210
|
const x = 0
|
|
212
211
|
const y = 0
|
|
213
212
|
editor.pointerDown(x, y)
|
|
214
|
-
|
|
213
|
+
jest.advanceTimersByTime(200)
|
|
215
214
|
editor.pointerMove(x + 100, y + 100)
|
|
216
215
|
expect(editor.getCurrentPageShapes()[0]).toMatchObject({
|
|
217
216
|
x,
|
|
@@ -11,7 +11,6 @@ import {
|
|
|
11
11
|
TLTextShape,
|
|
12
12
|
Vec,
|
|
13
13
|
createComputedCache,
|
|
14
|
-
getColorValue,
|
|
15
14
|
getDefaultColorTheme,
|
|
16
15
|
getFontsFromRichText,
|
|
17
16
|
isEqual,
|
|
@@ -136,7 +135,7 @@ export class TextShapeUtil extends ShapeUtil<TLTextShape> {
|
|
|
136
135
|
align={textAlign}
|
|
137
136
|
verticalAlign="middle"
|
|
138
137
|
richText={richText}
|
|
139
|
-
labelColor={
|
|
138
|
+
labelColor={theme[color].solid}
|
|
140
139
|
isSelected={isSelected}
|
|
141
140
|
textWidth={width}
|
|
142
141
|
textHeight={height}
|
|
@@ -172,7 +171,7 @@ export class TextShapeUtil extends ShapeUtil<TLTextShape> {
|
|
|
172
171
|
align={shape.props.textAlign}
|
|
173
172
|
verticalAlign="middle"
|
|
174
173
|
richText={shape.props.richText}
|
|
175
|
-
labelColor={
|
|
174
|
+
labelColor={theme[shape.props.color].solid}
|
|
176
175
|
bounds={exportBounds}
|
|
177
176
|
padding={0}
|
|
178
177
|
/>
|
|
@@ -304,26 +303,33 @@ export class TextShapeUtil extends ShapeUtil<TLTextShape> {
|
|
|
304
303
|
}
|
|
305
304
|
|
|
306
305
|
function getTextSize(editor: Editor, props: TLTextShape['props']) {
|
|
307
|
-
const { font, richText, size, w } = props
|
|
306
|
+
const { font, richText, autoSize, size, w } = props
|
|
308
307
|
|
|
309
|
-
const minWidth = 16
|
|
308
|
+
const minWidth = autoSize ? 16 : Math.max(16, w)
|
|
310
309
|
const fontSize = FONT_SIZES[size]
|
|
311
310
|
|
|
312
|
-
const
|
|
311
|
+
const cw = autoSize
|
|
312
|
+
? null
|
|
313
|
+
: // `measureText` floors the number so we need to do the same here to avoid issues.
|
|
314
|
+
Math.floor(Math.max(minWidth, w))
|
|
313
315
|
|
|
314
316
|
const html = renderHtmlFromRichTextForMeasurement(editor, richText)
|
|
315
317
|
const result = editor.textMeasure.measureHtml(html, {
|
|
316
318
|
...TEXT_PROPS,
|
|
317
319
|
fontFamily: FONT_FAMILIES[font],
|
|
318
320
|
fontSize: fontSize,
|
|
319
|
-
maxWidth:
|
|
321
|
+
maxWidth: cw,
|
|
320
322
|
})
|
|
321
323
|
|
|
322
324
|
// If we're autosizing the measureText will essentially `Math.floor`
|
|
323
325
|
// the numbers so `19` rather than `19.3`, this means we must +1 to
|
|
324
326
|
// whatever we get to avoid wrapping.
|
|
327
|
+
if (autoSize) {
|
|
328
|
+
result.w += 1
|
|
329
|
+
}
|
|
330
|
+
|
|
325
331
|
return {
|
|
326
|
-
width:
|
|
332
|
+
width: Math.max(minWidth, result.w),
|
|
327
333
|
height: Math.max(fontSize, result.h),
|
|
328
334
|
}
|
|
329
335
|
}
|
|
@@ -142,9 +142,9 @@ const VideoShape = memo(function VideoShape({ shape }: { shape: TLVideoShape })
|
|
|
142
142
|
<HTMLContainer
|
|
143
143
|
id={shape.id}
|
|
144
144
|
style={{
|
|
145
|
-
color: 'var(--
|
|
146
|
-
backgroundColor: asset ? 'transparent' : 'var(--
|
|
147
|
-
border: asset ? 'none' : '1px solid var(--
|
|
145
|
+
color: 'var(--color-text-3)',
|
|
146
|
+
backgroundColor: asset ? 'transparent' : 'var(--color-low)',
|
|
147
|
+
border: asset ? 'none' : '1px solid var(--color-low-border)',
|
|
148
148
|
}}
|
|
149
149
|
>
|
|
150
150
|
<div className="tl-counter-scaled">
|
package/src/lib/styles.tsx
CHANGED
|
@@ -4,7 +4,6 @@ import {
|
|
|
4
4
|
TLGroupShape,
|
|
5
5
|
TLPointerEventInfo,
|
|
6
6
|
TLShapeId,
|
|
7
|
-
isAccelKey,
|
|
8
7
|
pointInPolygon,
|
|
9
8
|
} from '@tldraw/editor'
|
|
10
9
|
|
|
@@ -16,15 +15,7 @@ export class Erasing extends StateNode {
|
|
|
16
15
|
private markId = ''
|
|
17
16
|
private excludedShapeIds = new Set<TLShapeId>()
|
|
18
17
|
|
|
19
|
-
_isHoldingAccelKey = false
|
|
20
|
-
_firstErasingShapeId: TLShapeId | null = null
|
|
21
|
-
_erasingShapeIds: TLShapeId[] = []
|
|
22
|
-
|
|
23
18
|
override onEnter(info: TLPointerEventInfo) {
|
|
24
|
-
this._isHoldingAccelKey = isAccelKey(this.editor.inputs)
|
|
25
|
-
this._firstErasingShapeId = this.editor.getErasingShapeIds()[0] // the first one should be the first one we hit... is it?
|
|
26
|
-
this._erasingShapeIds = this.editor.getErasingShapeIds()
|
|
27
|
-
|
|
28
19
|
this.markId = this.editor.markHistoryStoppingPoint('erase scribble begin')
|
|
29
20
|
this.info = info
|
|
30
21
|
|
|
@@ -85,16 +76,6 @@ export class Erasing extends StateNode {
|
|
|
85
76
|
this.complete()
|
|
86
77
|
}
|
|
87
78
|
|
|
88
|
-
override onKeyUp() {
|
|
89
|
-
this._isHoldingAccelKey = isAccelKey(this.editor.inputs)
|
|
90
|
-
this.update()
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
override onKeyDown() {
|
|
94
|
-
this._isHoldingAccelKey = isAccelKey(this.editor.inputs)
|
|
95
|
-
this.update()
|
|
96
|
-
}
|
|
97
|
-
|
|
98
79
|
update() {
|
|
99
80
|
const { editor, excludedShapeIds } = this
|
|
100
81
|
const erasingShapeIds = editor.getErasingShapeIds()
|
|
@@ -106,7 +87,6 @@ export class Erasing extends StateNode {
|
|
|
106
87
|
|
|
107
88
|
this.pushPointToScribble()
|
|
108
89
|
|
|
109
|
-
// Otherwise, erasing shapes are all the shapes that were hit before plus any new shapes that are hit
|
|
110
90
|
const erasing = new Set<TLShapeId>(erasingShapeIds)
|
|
111
91
|
const minDist = this.editor.options.hitTestMargin / zoomLevel
|
|
112
92
|
|
|
@@ -141,31 +121,18 @@ export class Erasing extends StateNode {
|
|
|
141
121
|
if (geometry.hitTestLineSegment(A, B, minDist)) {
|
|
142
122
|
erasing.add(editor.getOutermostSelectableShape(shape).id)
|
|
143
123
|
}
|
|
144
|
-
|
|
145
|
-
this._erasingShapeIds = [...erasing]
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
// If the user is holding the meta / ctrl key, we should only erase the first shape we hit
|
|
149
|
-
if (this._isHoldingAccelKey && this._firstErasingShapeId) {
|
|
150
|
-
const erasingShapeId = this._firstErasingShapeId
|
|
151
|
-
if (erasingShapeId && this.editor.getShape(erasingShapeId)) {
|
|
152
|
-
editor.setErasingShapes([erasingShapeId])
|
|
153
|
-
}
|
|
154
|
-
return
|
|
155
124
|
}
|
|
156
125
|
|
|
157
126
|
// Remove the hit shapes, except if they're in the list of excluded shapes
|
|
158
127
|
// (these excluded shapes will be any frames or groups the pointer was inside of
|
|
159
128
|
// when the user started erasing)
|
|
160
|
-
this.editor.setErasingShapes(
|
|
129
|
+
this.editor.setErasingShapes([...erasing].filter((id) => !excludedShapeIds.has(id)))
|
|
161
130
|
}
|
|
162
131
|
|
|
163
132
|
complete() {
|
|
164
133
|
const { editor } = this
|
|
165
134
|
editor.deleteShapes(editor.getCurrentPageState().erasingShapeIds)
|
|
166
135
|
this.parent.transition('idle')
|
|
167
|
-
this._erasingShapeIds = []
|
|
168
|
-
this._firstErasingShapeId = null
|
|
169
136
|
}
|
|
170
137
|
|
|
171
138
|
cancel() {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import {
|
|
2
|
-
isAccelKey,
|
|
3
2
|
StateNode,
|
|
4
3
|
TLFrameShape,
|
|
5
4
|
TLGroupShape,
|
|
@@ -10,11 +9,7 @@ import {
|
|
|
10
9
|
export class Pointing extends StateNode {
|
|
11
10
|
static override id = 'pointing'
|
|
12
11
|
|
|
13
|
-
_isHoldingAccelKey = false
|
|
14
|
-
|
|
15
12
|
override onEnter() {
|
|
16
|
-
this._isHoldingAccelKey = isAccelKey(this.editor.inputs)
|
|
17
|
-
|
|
18
13
|
const zoomLevel = this.editor.getZoomLevel()
|
|
19
14
|
const currentPageShapesSorted = this.editor.getCurrentPageRenderingShapesSorted()
|
|
20
15
|
const {
|
|
@@ -50,25 +45,12 @@ export class Pointing extends StateNode {
|
|
|
50
45
|
}
|
|
51
46
|
|
|
52
47
|
erasing.add(hitShape.id)
|
|
53
|
-
|
|
54
|
-
// If the user is holding the meta / ctrl key, stop after the first shape
|
|
55
|
-
if (this._isHoldingAccelKey) {
|
|
56
|
-
break
|
|
57
|
-
}
|
|
58
48
|
}
|
|
59
49
|
}
|
|
60
50
|
|
|
61
51
|
this.editor.setErasingShapes([...erasing])
|
|
62
52
|
}
|
|
63
53
|
|
|
64
|
-
override onKeyUp() {
|
|
65
|
-
this._isHoldingAccelKey = isAccelKey(this.editor.inputs)
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
override onKeyDown() {
|
|
69
|
-
this._isHoldingAccelKey = isAccelKey(this.editor.inputs)
|
|
70
|
-
}
|
|
71
|
-
|
|
72
54
|
override onLongPress(info: TLPointerEventInfo) {
|
|
73
55
|
this.startErasing(info)
|
|
74
56
|
}
|
|
@@ -80,8 +62,6 @@ export class Pointing extends StateNode {
|
|
|
80
62
|
}
|
|
81
63
|
|
|
82
64
|
override onPointerMove(info: TLPointerEventInfo) {
|
|
83
|
-
if (this._isHoldingAccelKey) return
|
|
84
|
-
|
|
85
65
|
if (this.editor.inputs.isDragging) {
|
|
86
66
|
this.startErasing(info)
|
|
87
67
|
}
|
|
@@ -9,18 +9,11 @@ export class PointingCrop extends StateNode {
|
|
|
9
9
|
|
|
10
10
|
override onPointerMove(info: TLPointerEventInfo) {
|
|
11
11
|
if (this.editor.inputs.isDragging) {
|
|
12
|
-
this.
|
|
12
|
+
this.editor.setCurrentTool('select.crop.translating_crop', info)
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
override onLongPress(info: TLPointerEventInfo) {
|
|
16
|
-
this.startDragging(info)
|
|
17
|
-
}
|
|
18
15
|
|
|
19
16
|
override onPointerUp(info: TLPointerEventInfo) {
|
|
20
17
|
this.editor.setCurrentTool('select.crop.idle', info)
|
|
21
18
|
}
|
|
22
|
-
|
|
23
|
-
startDragging(info: TLPointerEventInfo) {
|
|
24
|
-
this.editor.setCurrentTool('select.crop.translating_crop', info)
|
|
25
|
-
}
|
|
26
19
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import {
|
|
2
|
-
Mat,
|
|
3
2
|
StateNode,
|
|
4
3
|
TLArrowShape,
|
|
5
4
|
TLHandle,
|
|
@@ -27,20 +26,20 @@ export type DraggingHandleInfo = TLPointerEventInfo & {
|
|
|
27
26
|
export class DraggingHandle extends StateNode {
|
|
28
27
|
static override id = 'dragging_handle'
|
|
29
28
|
|
|
30
|
-
shapeId
|
|
31
|
-
initialHandle
|
|
32
|
-
initialAdjacentHandle
|
|
33
|
-
initialPagePoint
|
|
29
|
+
shapeId = '' as TLShapeId
|
|
30
|
+
initialHandle = {} as TLHandle
|
|
31
|
+
initialAdjacentHandle = null as TLHandle | null
|
|
32
|
+
initialPagePoint = {} as Vec
|
|
34
33
|
|
|
35
|
-
markId
|
|
36
|
-
initialPageTransform
|
|
37
|
-
initialPageRotation
|
|
34
|
+
markId = ''
|
|
35
|
+
initialPageTransform: any
|
|
36
|
+
initialPageRotation: any
|
|
38
37
|
|
|
39
|
-
info
|
|
38
|
+
info = {} as DraggingHandleInfo
|
|
40
39
|
|
|
41
40
|
isPrecise = false
|
|
42
|
-
isPreciseId
|
|
43
|
-
pointingId
|
|
41
|
+
isPreciseId = null as TLShapeId | null
|
|
42
|
+
pointingId = null as TLShapeId | null
|
|
44
43
|
|
|
45
44
|
override onEnter(info: DraggingHandleInfo) {
|
|
46
45
|
const { shape, isCreating, creatingMarkId, handle } = info
|
|
@@ -67,6 +66,26 @@ export class DraggingHandle extends StateNode {
|
|
|
67
66
|
|
|
68
67
|
this.initialHandle = structuredClone(handle)
|
|
69
68
|
|
|
69
|
+
if (this.editor.isShapeOfType<TLLineShape>(shape, 'line')) {
|
|
70
|
+
// For line shapes, if we're dragging a "create" handle, then
|
|
71
|
+
// create a new vertex handle at that point; and make this handle
|
|
72
|
+
// the handle that we're dragging.
|
|
73
|
+
if (this.initialHandle.type === 'create') {
|
|
74
|
+
this.editor.updateShape({
|
|
75
|
+
...shape,
|
|
76
|
+
props: {
|
|
77
|
+
points: {
|
|
78
|
+
...shape.props.points,
|
|
79
|
+
[handle.index]: { id: handle.index, index: handle.index, x: handle.x, y: handle.y },
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
})
|
|
83
|
+
const handlesAfter = this.editor.getShapeHandles(shape)!
|
|
84
|
+
const handleAfter = handlesAfter.find((h) => h.index === handle.index)!
|
|
85
|
+
this.initialHandle = structuredClone(handleAfter)
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
70
89
|
this.initialPageTransform = this.editor.getShapePageTransform(shape)!
|
|
71
90
|
this.initialPageRotation = this.initialPageTransform.rotation()
|
|
72
91
|
this.initialPagePoint = this.editor.inputs.originPagePoint.clone()
|
|
@@ -116,19 +135,6 @@ export class DraggingHandle extends StateNode {
|
|
|
116
135
|
}
|
|
117
136
|
// -->
|
|
118
137
|
|
|
119
|
-
// Call onHandleDragStart callback
|
|
120
|
-
const handleDragInfo = {
|
|
121
|
-
handle: this.initialHandle,
|
|
122
|
-
isPrecise: this.isPrecise,
|
|
123
|
-
isCreatingShape: !!this.info.isCreating,
|
|
124
|
-
initial: shape,
|
|
125
|
-
}
|
|
126
|
-
const util = this.editor.getShapeUtil(shape)
|
|
127
|
-
const startChanges = util.onHandleDragStart?.(shape, handleDragInfo)
|
|
128
|
-
if (startChanges) {
|
|
129
|
-
this.editor.updateShapes([{ ...startChanges, id: shape.id, type: shape.type }])
|
|
130
|
-
}
|
|
131
|
-
|
|
132
138
|
this.update()
|
|
133
139
|
|
|
134
140
|
this.editor.select(this.shapeId)
|
|
@@ -198,22 +204,6 @@ export class DraggingHandle extends StateNode {
|
|
|
198
204
|
this.editor.snaps.clearIndicators()
|
|
199
205
|
kickoutOccludedShapes(this.editor, [this.shapeId])
|
|
200
206
|
|
|
201
|
-
// Call onHandleDragEnd callback before state transitions
|
|
202
|
-
const shape = this.editor.getShape(this.shapeId)
|
|
203
|
-
if (shape) {
|
|
204
|
-
const util = this.editor.getShapeUtil(shape)
|
|
205
|
-
const handleDragInfo = {
|
|
206
|
-
handle: this.initialHandle,
|
|
207
|
-
isPrecise: this.isPrecise,
|
|
208
|
-
isCreatingShape: !!this.info.isCreating,
|
|
209
|
-
initial: this.info.shape,
|
|
210
|
-
}
|
|
211
|
-
const endChanges = util.onHandleDragEnd?.(shape, handleDragInfo)
|
|
212
|
-
if (endChanges) {
|
|
213
|
-
this.editor.updateShapes([{ ...endChanges, id: shape.id, type: shape.type }])
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
|
|
217
207
|
const { onInteractionEnd } = this.info
|
|
218
208
|
if (this.editor.getInstanceState().isToolLocked && onInteractionEnd) {
|
|
219
209
|
// Return to the tool that was active before this one,
|
|
@@ -226,19 +216,6 @@ export class DraggingHandle extends StateNode {
|
|
|
226
216
|
}
|
|
227
217
|
|
|
228
218
|
private cancel() {
|
|
229
|
-
// Call onHandleDragCancel callback before bailing to mark
|
|
230
|
-
const shape = this.editor.getShape(this.shapeId)
|
|
231
|
-
if (shape) {
|
|
232
|
-
const util = this.editor.getShapeUtil(shape)
|
|
233
|
-
const handleDragInfo = {
|
|
234
|
-
handle: this.initialHandle,
|
|
235
|
-
isPrecise: this.isPrecise,
|
|
236
|
-
isCreatingShape: !!this.info.isCreating,
|
|
237
|
-
initial: this.info.shape,
|
|
238
|
-
}
|
|
239
|
-
util.onHandleDragCancel?.(shape, handleDragInfo)
|
|
240
|
-
}
|
|
241
|
-
|
|
242
219
|
this.editor.bailToMark(this.markId)
|
|
243
220
|
this.editor.snaps.clearIndicators()
|
|
244
221
|
|
|
@@ -307,7 +284,6 @@ export class DraggingHandle extends StateNode {
|
|
|
307
284
|
const changes = util.onHandleDrag?.(shape, {
|
|
308
285
|
handle: nextHandle,
|
|
309
286
|
isPrecise: this.isPrecise || altKey,
|
|
310
|
-
isCreatingShape: !!this.info.isCreating,
|
|
311
287
|
initial: initial,
|
|
312
288
|
})
|
|
313
289
|
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Editor,
|
|
3
|
+
Group2d,
|
|
3
4
|
StateNode,
|
|
4
5
|
TLAdjacentDirection,
|
|
6
|
+
TLArrowShape,
|
|
5
7
|
TLClickEventInfo,
|
|
6
8
|
TLGroupShape,
|
|
7
9
|
TLKeyboardEventInfo,
|
|
@@ -16,7 +18,6 @@ import {
|
|
|
16
18
|
pointInPolygon,
|
|
17
19
|
toRichText,
|
|
18
20
|
} from '@tldraw/editor'
|
|
19
|
-
import { isOverArrowLabel } from '../../../shapes/arrow/arrowLabel'
|
|
20
21
|
import { getHitShapeOnCanvasPointerDown } from '../../selection-logic/getHitShapeOnCanvasPointerDown'
|
|
21
22
|
import { getShouldEnterCropMode } from '../../selection-logic/getShouldEnterCropModeOnPointerDown'
|
|
22
23
|
import { selectOnCanvasPointerUp } from '../../selection-logic/selectOnCanvasPointerUp'
|
|
@@ -97,6 +98,12 @@ export class Idle extends StateNode {
|
|
|
97
98
|
case 'shape': {
|
|
98
99
|
const { shape } = info
|
|
99
100
|
|
|
101
|
+
if (this.isOverArrowLabelTest(shape)) {
|
|
102
|
+
// We're moving the label on a shape.
|
|
103
|
+
this.parent.transition('pointing_arrow_label', info)
|
|
104
|
+
break
|
|
105
|
+
}
|
|
106
|
+
|
|
100
107
|
if (this.editor.isShapeOrAncestorLocked(shape)) {
|
|
101
108
|
this.parent.transition('pointing_canvas', info)
|
|
102
109
|
break
|
|
@@ -588,7 +595,22 @@ export class Idle extends StateNode {
|
|
|
588
595
|
isOverArrowLabelTest(shape: TLShape | undefined) {
|
|
589
596
|
if (!shape) return false
|
|
590
597
|
|
|
591
|
-
|
|
598
|
+
// todo: Extract into general hit test for arrows
|
|
599
|
+
if (this.editor.isShapeOfType<TLArrowShape>(shape, 'arrow')) {
|
|
600
|
+
const pointInShapeSpace = this.editor.getPointInShapeSpace(
|
|
601
|
+
shape,
|
|
602
|
+
this.editor.inputs.currentPagePoint
|
|
603
|
+
)
|
|
604
|
+
// How should we handle multiple labels? Do shapes ever have multiple labels?
|
|
605
|
+
const labelGeometry = this.editor.getShapeGeometry<Group2d>(shape).children[1]
|
|
606
|
+
// Knowing what we know about arrows... if the shape has no text in its label,
|
|
607
|
+
// then the label geometry should not be there.
|
|
608
|
+
if (labelGeometry && pointInPolygon(pointInShapeSpace, labelGeometry.vertices)) {
|
|
609
|
+
return true
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
return false
|
|
592
614
|
}
|
|
593
615
|
|
|
594
616
|
handleDoubleClickOnCanvas(info: TLClickEventInfo) {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { StateNode, TLPointerEventInfo, TLShape } from '@tldraw/editor'
|
|
2
|
-
import { isOverArrowLabel } from '../../../shapes/arrow/arrowLabel'
|
|
3
2
|
import { getTextLabels } from '../../../utils/shapes/shapes'
|
|
4
3
|
|
|
5
4
|
export class PointingShape extends StateNode {
|
|
@@ -211,12 +210,6 @@ export class PointingShape extends StateNode {
|
|
|
211
210
|
|
|
212
211
|
override onPointerMove(info: TLPointerEventInfo) {
|
|
213
212
|
if (this.editor.inputs.isDragging) {
|
|
214
|
-
if (isOverArrowLabel(this.editor, this.hitShape)) {
|
|
215
|
-
// We're moving the label on a shape.
|
|
216
|
-
this.parent.transition('pointing_arrow_label', { ...info, shape: this.hitShape })
|
|
217
|
-
return
|
|
218
|
-
}
|
|
219
|
-
|
|
220
213
|
if (this.didCtrlOnEnter) {
|
|
221
214
|
this.parent.transition('brushing', info)
|
|
222
215
|
} else {
|
|
@@ -122,19 +122,8 @@ export class Resizing extends StateNode {
|
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
private cancel() {
|
|
125
|
-
//
|
|
126
|
-
const { shapeSnapshots } = this.snapshot
|
|
127
|
-
|
|
128
|
-
shapeSnapshots.forEach(({ shape }) => {
|
|
129
|
-
const current = this.editor.getShape(shape.id)
|
|
130
|
-
if (current) {
|
|
131
|
-
const util = this.editor.getShapeUtil(shape)
|
|
132
|
-
util.onResizeCancel?.(shape, current)
|
|
133
|
-
}
|
|
134
|
-
})
|
|
135
|
-
|
|
125
|
+
// Restore initial models
|
|
136
126
|
this.editor.bailToMark(this.markId)
|
|
137
|
-
|
|
138
127
|
if (this.info.onInteractionEnd) {
|
|
139
128
|
this.editor.setCurrentTool(this.info.onInteractionEnd, {})
|
|
140
129
|
} else {
|
|
@@ -109,17 +109,6 @@ export class Rotating extends StateNode {
|
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
private cancel() {
|
|
112
|
-
// Call onRotateCancel callback before bailing to mark
|
|
113
|
-
const { shapeSnapshots } = this.snapshot
|
|
114
|
-
|
|
115
|
-
shapeSnapshots.forEach(({ shape }) => {
|
|
116
|
-
const current = this.editor.getShape(shape.id)
|
|
117
|
-
if (current) {
|
|
118
|
-
const util = this.editor.getShapeUtil(shape)
|
|
119
|
-
util.onRotateCancel?.(shape, current)
|
|
120
|
-
}
|
|
121
|
-
})
|
|
122
|
-
|
|
123
112
|
this.editor.bailToMark(this.markId)
|
|
124
113
|
if (this.info.onInteractionEnd) {
|
|
125
114
|
this.editor.setCurrentTool(this.info.onInteractionEnd, this.info)
|
|
@@ -28,6 +28,7 @@ export type TranslatingInfo = TLPointerEventInfo & {
|
|
|
28
28
|
isCreating?: boolean
|
|
29
29
|
creatingMarkId?: string
|
|
30
30
|
onCreate?(): void
|
|
31
|
+
didStartInPit?: boolean
|
|
31
32
|
onInteractionEnd?: string
|
|
32
33
|
}
|
|
33
34
|
|
|
@@ -202,17 +203,6 @@ export class Translating extends StateNode {
|
|
|
202
203
|
}
|
|
203
204
|
|
|
204
205
|
private cancel() {
|
|
205
|
-
// Call onTranslateCancel callback before resetting
|
|
206
|
-
const { movingShapes } = this.snapshot
|
|
207
|
-
|
|
208
|
-
movingShapes.forEach((shape) => {
|
|
209
|
-
const current = this.editor.getShape(shape.id)
|
|
210
|
-
if (current) {
|
|
211
|
-
const util = this.editor.getShapeUtil(shape)
|
|
212
|
-
util.onTranslateCancel?.(shape, current)
|
|
213
|
-
}
|
|
214
|
-
})
|
|
215
|
-
|
|
216
206
|
this.reset()
|
|
217
207
|
if (this.info.onInteractionEnd) {
|
|
218
208
|
this.editor.setCurrentTool(this.info.onInteractionEnd)
|
package/src/lib/ui/TldrawUi.tsx
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { tlenv, useEditor, useReactor, useValue } from '@tldraw/editor'
|
|
2
2
|
import classNames from 'classnames'
|
|
3
|
-
import React, { ReactNode,
|
|
3
|
+
import React, { ReactNode, useRef, useState } from 'react'
|
|
4
4
|
import { TLUiAssetUrlOverrides } from './assetUrls'
|
|
5
5
|
import { SkipToMainContent } from './components/A11y'
|
|
6
6
|
import { FollowingIndicator } from './components/FollowingIndicator'
|
|
7
7
|
import { TldrawUiButton } from './components/primitives/Button/TldrawUiButton'
|
|
8
8
|
import { TldrawUiButtonIcon } from './components/primitives/Button/TldrawUiButtonIcon'
|
|
9
|
-
import { PORTRAIT_BREAKPOINT
|
|
9
|
+
import { PORTRAIT_BREAKPOINT } from './constants'
|
|
10
10
|
import {
|
|
11
11
|
TLUiContextProviderProps,
|
|
12
12
|
TldrawUiContextProvider,
|
|
@@ -160,19 +160,6 @@ const TldrawUiContent = React.memo(function TldrawUI() {
|
|
|
160
160
|
|
|
161
161
|
const { 'toggle-focus-mode': toggleFocus } = useActions()
|
|
162
162
|
|
|
163
|
-
const { breakpointsAbove, breakpointsBelow } = useMemo(() => {
|
|
164
|
-
const breakpointsAbove = []
|
|
165
|
-
const breakpointsBelow = []
|
|
166
|
-
for (let bp = 0; bp < PORTRAIT_BREAKPOINTS.length; bp++) {
|
|
167
|
-
if (bp <= breakpoint) {
|
|
168
|
-
breakpointsAbove.push(bp)
|
|
169
|
-
} else {
|
|
170
|
-
breakpointsBelow.push(bp)
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
return { breakpointsAbove, breakpointsBelow }
|
|
174
|
-
}, [breakpoint])
|
|
175
|
-
|
|
176
163
|
return (
|
|
177
164
|
<div
|
|
178
165
|
className={classNames('tlui-layout', {
|
|
@@ -182,8 +169,6 @@ const TldrawUiContent = React.memo(function TldrawUI() {
|
|
|
182
169
|
// But when the virtual keyboard is closing we want to wait a bit before showing it again.
|
|
183
170
|
data-iseditinganything={hideToolbarWhileEditing}
|
|
184
171
|
data-breakpoint={breakpoint}
|
|
185
|
-
data-breakpoints-above={breakpointsAbove.join(' ')}
|
|
186
|
-
data-breakpoints-below={breakpointsBelow.join(' ')}
|
|
187
172
|
>
|
|
188
173
|
<SkipToMainContent />
|
|
189
174
|
{isFocusMode ? (
|