tldraw 3.16.0-internal.a478398270c6 → 3.16.0-next.15f085081fd5
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 +316 -23
- package/dist-cjs/index.js +34 -2
- 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 +16 -4
- 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 +3 -0
- package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.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/FrameShapeUtil.js +20 -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 +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 +6 -5
- package/dist-cjs/lib/shapes/note/NoteShapeUtil.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 +1 -0
- 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/freehand/svg.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/usePrefersReducedMotion.js +10 -1
- package/dist-cjs/lib/shapes/shared/usePrefersReducedMotion.js.map +2 -2
- package/dist-cjs/lib/shapes/text/TextShapeUtil.js +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 +14 -12
- 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/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 +2 -1
- package/dist-cjs/lib/ui/components/PageMenu/DefaultPageMenu.js.map +2 -2
- package/dist-cjs/lib/ui/components/SharePanel/PeopleMenuItem.js +3 -2
- package/dist-cjs/lib/ui/components/SharePanel/PeopleMenuItem.js.map +2 -2
- package/dist-cjs/lib/ui/components/SharePanel/UserPresenceColorPicker.js +2 -2
- package/dist-cjs/lib/ui/components/SharePanel/UserPresenceColorPicker.js.map +2 -2
- package/dist-cjs/lib/ui/components/Spinner.js +2 -25
- package/dist-cjs/lib/ui/components/Spinner.js.map +2 -2
- package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanel.js +2 -0
- package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanel.js.map +2 -2
- package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanelContent.js +171 -139
- 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 +26 -25
- package/dist-cjs/lib/ui/components/StylePanel/DropdownPicker.js.map +3 -3
- 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 +1 -1
- 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/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/TldrawUiButtonPicker.js +7 -16
- 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 +35 -1
- package/dist-cjs/lib/ui/components/primitives/TldrawUiIcon.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 +6 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiSlider.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiToolbar.js +31 -7
- package/dist-cjs/lib/ui/components/primitives/TldrawUiToolbar.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js +262 -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 +72 -9
- 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/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 +12 -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/tldr/buildFromV1Document.js +3 -2
- package/dist-cjs/lib/utils/tldr/buildFromV1Document.js.map +2 -2
- package/dist-esm/index.d.mts +316 -23
- package/dist-esm/index.mjs +57 -5
- 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 +19 -5
- 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 +3 -0
- package/dist-esm/lib/shapes/arrow/toolStates/Pointing.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/FrameShapeUtil.mjs +21 -17
- 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 +3 -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 +7 -5
- package/dist-esm/lib/shapes/note/NoteShapeUtil.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 +1 -0
- 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/freehand/svg.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/usePrefersReducedMotion.mjs +10 -1
- package/dist-esm/lib/shapes/shared/usePrefersReducedMotion.mjs.map +2 -2
- package/dist-esm/lib/shapes/text/TextShapeUtil.mjs +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 +14 -12
- 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/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 +2 -1
- package/dist-esm/lib/ui/components/PageMenu/DefaultPageMenu.mjs.map +2 -2
- package/dist-esm/lib/ui/components/SharePanel/PeopleMenuItem.mjs +3 -2
- package/dist-esm/lib/ui/components/SharePanel/PeopleMenuItem.mjs.map +2 -2
- package/dist-esm/lib/ui/components/SharePanel/UserPresenceColorPicker.mjs +2 -2
- package/dist-esm/lib/ui/components/SharePanel/UserPresenceColorPicker.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Spinner.mjs +3 -26
- package/dist-esm/lib/ui/components/Spinner.mjs.map +2 -2
- package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanel.mjs +3 -1
- package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanel.mjs.map +2 -2
- package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanelContent.mjs +171 -139
- 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 +26 -25
- package/dist-esm/lib/ui/components/StylePanel/DropdownPicker.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 +1 -1
- 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/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/TldrawUiButtonPicker.mjs +8 -6
- 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 +36 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiIcon.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 +6 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiSlider.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiToolbar.mjs +31 -7
- package/dist-esm/lib/ui/components/primitives/TldrawUiToolbar.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs +239 -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 +72 -9
- 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/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 +12 -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/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 +42 -3
- 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 +4 -3
- package/src/lib/shapes/arrow/ArrowShapeUtil.test.ts +12 -11
- package/src/lib/shapes/arrow/ArrowShapeUtil.tsx +30 -46
- package/src/lib/shapes/arrow/arrowLabel.ts +23 -3
- package/src/lib/shapes/arrow/arrowTargetState.ts +2 -1
- package/src/lib/shapes/arrow/elbow/ElbowArrowDebug.tsx +3 -3
- package/src/lib/shapes/arrow/toolStates/Pointing.tsx +3 -0
- 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/FrameShapeUtil.tsx +30 -21
- package/src/lib/shapes/frame/components/FrameHeading.tsx +1 -1
- package/src/lib/shapes/geo/GeoShapeUtil.tsx +3 -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 +4 -3
- 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/NoteShapeUtil.tsx +10 -4
- 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 +1 -0
- package/src/lib/shapes/shared/RichTextLabel.tsx +4 -0
- package/src/lib/shapes/shared/ShapeFill.tsx +5 -4
- package/src/lib/shapes/shared/SvgTextLabel.tsx +4 -2
- package/src/lib/shapes/shared/freehand/svg.ts +2 -0
- package/src/lib/shapes/shared/usePrefersReducedMotion.tsx +11 -1
- package/src/lib/shapes/text/TextShapeTool.test.ts +6 -5
- package/src/lib/shapes/text/TextShapeUtil.tsx +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 +15 -13
- package/src/lib/ui/components/AccessibilityMenu.tsx +20 -0
- package/src/lib/ui/components/ActionsMenu/DefaultActionsMenu.tsx +15 -3
- package/src/lib/ui/components/{FollowingIndicator.tsx → DefaultFollowingIndicator.tsx} +2 -1
- package/src/lib/ui/components/DefaultMenuPanel.tsx +4 -3
- package/src/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.tsx +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 +3 -2
- package/src/lib/ui/components/SharePanel/PeopleMenuItem.tsx +4 -3
- package/src/lib/ui/components/SharePanel/UserPresenceColorPicker.tsx +3 -3
- package/src/lib/ui/components/Spinner.tsx +2 -24
- package/src/lib/ui/components/StylePanel/DefaultStylePanel.tsx +3 -1
- package/src/lib/ui/components/StylePanel/DefaultStylePanelContent.tsx +146 -106
- package/src/lib/ui/components/StylePanel/DoubleDropdownPicker.tsx +3 -3
- package/src/lib/ui/components/StylePanel/DropdownPicker.tsx +7 -6
- package/src/lib/ui/components/Toolbar/DefaultImageToolbar.tsx +25 -9
- package/src/lib/ui/components/Toolbar/DefaultImageToolbarContent.tsx +1 -1
- package/src/lib/ui/components/Toolbar/DefaultToolbar.tsx +55 -23
- 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/TldrawUiButtonPicker.tsx +40 -35
- 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 +41 -3
- package/src/lib/ui/components/primitives/TldrawUiPopover.tsx +4 -2
- package/src/lib/ui/components/primitives/TldrawUiSlider.tsx +6 -1
- package/src/lib/ui/components/primitives/TldrawUiToolbar.tsx +56 -12
- package/src/lib/ui/components/primitives/TldrawUiTooltip.tsx +325 -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 +74 -10
- package/src/lib/ui/context/components.tsx +3 -0
- package/src/lib/ui/context/events.tsx +6 -2
- package/src/lib/ui/hooks/menu-hooks.ts +1 -0
- 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 +12 -0
- package/src/lib/ui/hooks/useTranslation/defaultTranslation.ts +12 -0
- package/src/lib/ui/kbd-utils.ts +12 -4
- package/src/lib/ui/version.ts +3 -3
- package/src/lib/ui.css +417 -314
- package/src/lib/utils/excalidraw/__snapshots__/putExcalidrawContent.test.tsx.snap +21 -7
- package/src/lib/utils/excalidraw/putExcalidrawContent.ts +1 -1
- 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 +21 -20
- 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 +11 -10
- package/src/test/ZoomTool.test.ts +7 -6
- package/src/test/__snapshots__/drawing.test.ts.snap +2 -2
- package/src/test/__snapshots__/groups.test.tsx.snap +6 -6
- package/src/test/__snapshots__/resizing.test.ts.snap +2 -2
- package/src/test/arrows-megabus.test.tsx +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/resizeShape.test.ts +2 -1
- package/src/test/commands/rotateShapes.test.ts +7 -6
- package/src/test/commands/setCamera.test.ts +4 -3
- package/src/test/commands/setCurrentPage.test.ts +3 -2
- package/src/test/commands/stackShapes.test.ts +11 -10
- package/src/test/commands/stretch.test.tsx +13 -12
- package/src/test/createDeepLink.test.tsx +2 -1
- package/src/test/cropping.test.ts +3 -2
- package/src/test/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 +3 -2
- package/src/test/groups.test.tsx +2 -2
- 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 +10 -9
- package/tldraw.css +737 -627
- package/dist-cjs/lib/ui/components/FollowingIndicator.js.map +0 -7
- package/dist-esm/lib/ui/components/FollowingIndicator.mjs.map +0 -7
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
TLTextShape,
|
|
12
12
|
Vec,
|
|
13
13
|
createComputedCache,
|
|
14
|
+
getColorValue,
|
|
14
15
|
getDefaultColorTheme,
|
|
15
16
|
getFontsFromRichText,
|
|
16
17
|
isEqual,
|
|
@@ -135,7 +136,7 @@ export class TextShapeUtil extends ShapeUtil<TLTextShape> {
|
|
|
135
136
|
align={textAlign}
|
|
136
137
|
verticalAlign="middle"
|
|
137
138
|
richText={richText}
|
|
138
|
-
labelColor={theme
|
|
139
|
+
labelColor={getColorValue(theme, color, 'solid')}
|
|
139
140
|
isSelected={isSelected}
|
|
140
141
|
textWidth={width}
|
|
141
142
|
textHeight={height}
|
|
@@ -171,7 +172,7 @@ export class TextShapeUtil extends ShapeUtil<TLTextShape> {
|
|
|
171
172
|
align={shape.props.textAlign}
|
|
172
173
|
verticalAlign="middle"
|
|
173
174
|
richText={shape.props.richText}
|
|
174
|
-
labelColor={theme
|
|
175
|
+
labelColor={getColorValue(theme, shape.props.color, 'solid')}
|
|
175
176
|
bounds={exportBounds}
|
|
176
177
|
padding={0}
|
|
177
178
|
/>
|
|
@@ -303,33 +304,26 @@ export class TextShapeUtil extends ShapeUtil<TLTextShape> {
|
|
|
303
304
|
}
|
|
304
305
|
|
|
305
306
|
function getTextSize(editor: Editor, props: TLTextShape['props']) {
|
|
306
|
-
const { font, richText,
|
|
307
|
+
const { font, richText, size, w } = props
|
|
307
308
|
|
|
308
|
-
const minWidth =
|
|
309
|
+
const minWidth = 16
|
|
309
310
|
const fontSize = FONT_SIZES[size]
|
|
310
311
|
|
|
311
|
-
const
|
|
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))
|
|
312
|
+
const maybeFixedWidth = props.autoSize ? null : Math.max(minWidth, Math.floor(w))
|
|
315
313
|
|
|
316
314
|
const html = renderHtmlFromRichTextForMeasurement(editor, richText)
|
|
317
315
|
const result = editor.textMeasure.measureHtml(html, {
|
|
318
316
|
...TEXT_PROPS,
|
|
319
317
|
fontFamily: FONT_FAMILIES[font],
|
|
320
318
|
fontSize: fontSize,
|
|
321
|
-
maxWidth:
|
|
319
|
+
maxWidth: maybeFixedWidth,
|
|
322
320
|
})
|
|
323
321
|
|
|
324
322
|
// If we're autosizing the measureText will essentially `Math.floor`
|
|
325
323
|
// the numbers so `19` rather than `19.3`, this means we must +1 to
|
|
326
324
|
// whatever we get to avoid wrapping.
|
|
327
|
-
if (autoSize) {
|
|
328
|
-
result.w += 1
|
|
329
|
-
}
|
|
330
|
-
|
|
331
325
|
return {
|
|
332
|
-
width: Math.max(minWidth, result.w),
|
|
326
|
+
width: maybeFixedWidth ?? Math.max(minWidth, result.w + 1),
|
|
333
327
|
height: Math.max(fontSize, result.h),
|
|
334
328
|
}
|
|
335
329
|
}
|
|
@@ -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(--color-text-3)',
|
|
146
|
-
backgroundColor: asset ? 'transparent' : 'var(--color-low)',
|
|
147
|
-
border: asset ? 'none' : '1px solid var(--color-low-border)',
|
|
145
|
+
color: 'var(--tl-color-text-3)',
|
|
146
|
+
backgroundColor: asset ? 'transparent' : 'var(--tl-color-low)',
|
|
147
|
+
border: asset ? 'none' : '1px solid var(--tl-color-low-border)',
|
|
148
148
|
}}
|
|
149
149
|
>
|
|
150
150
|
<div className="tl-counter-scaled">
|
package/src/lib/styles.tsx
CHANGED
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
TLGroupShape,
|
|
5
5
|
TLPointerEventInfo,
|
|
6
6
|
TLShapeId,
|
|
7
|
+
isAccelKey,
|
|
7
8
|
pointInPolygon,
|
|
8
9
|
} from '@tldraw/editor'
|
|
9
10
|
|
|
@@ -15,7 +16,15 @@ export class Erasing extends StateNode {
|
|
|
15
16
|
private markId = ''
|
|
16
17
|
private excludedShapeIds = new Set<TLShapeId>()
|
|
17
18
|
|
|
19
|
+
_isHoldingAccelKey = false
|
|
20
|
+
_firstErasingShapeId: TLShapeId | null = null
|
|
21
|
+
_erasingShapeIds: TLShapeId[] = []
|
|
22
|
+
|
|
18
23
|
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
|
+
|
|
19
28
|
this.markId = this.editor.markHistoryStoppingPoint('erase scribble begin')
|
|
20
29
|
this.info = info
|
|
21
30
|
|
|
@@ -76,6 +85,16 @@ export class Erasing extends StateNode {
|
|
|
76
85
|
this.complete()
|
|
77
86
|
}
|
|
78
87
|
|
|
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
|
+
|
|
79
98
|
update() {
|
|
80
99
|
const { editor, excludedShapeIds } = this
|
|
81
100
|
const erasingShapeIds = editor.getErasingShapeIds()
|
|
@@ -87,6 +106,7 @@ export class Erasing extends StateNode {
|
|
|
87
106
|
|
|
88
107
|
this.pushPointToScribble()
|
|
89
108
|
|
|
109
|
+
// Otherwise, erasing shapes are all the shapes that were hit before plus any new shapes that are hit
|
|
90
110
|
const erasing = new Set<TLShapeId>(erasingShapeIds)
|
|
91
111
|
const minDist = this.editor.options.hitTestMargin / zoomLevel
|
|
92
112
|
|
|
@@ -121,18 +141,31 @@ export class Erasing extends StateNode {
|
|
|
121
141
|
if (geometry.hitTestLineSegment(A, B, minDist)) {
|
|
122
142
|
erasing.add(editor.getOutermostSelectableShape(shape).id)
|
|
123
143
|
}
|
|
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
|
|
124
155
|
}
|
|
125
156
|
|
|
126
157
|
// Remove the hit shapes, except if they're in the list of excluded shapes
|
|
127
158
|
// (these excluded shapes will be any frames or groups the pointer was inside of
|
|
128
159
|
// when the user started erasing)
|
|
129
|
-
this.editor.setErasingShapes(
|
|
160
|
+
this.editor.setErasingShapes(this._erasingShapeIds.filter((id) => !excludedShapeIds.has(id)))
|
|
130
161
|
}
|
|
131
162
|
|
|
132
163
|
complete() {
|
|
133
164
|
const { editor } = this
|
|
134
165
|
editor.deleteShapes(editor.getCurrentPageState().erasingShapeIds)
|
|
135
166
|
this.parent.transition('idle')
|
|
167
|
+
this._erasingShapeIds = []
|
|
168
|
+
this._firstErasingShapeId = null
|
|
136
169
|
}
|
|
137
170
|
|
|
138
171
|
cancel() {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
isAccelKey,
|
|
2
3
|
StateNode,
|
|
3
4
|
TLFrameShape,
|
|
4
5
|
TLGroupShape,
|
|
@@ -9,7 +10,11 @@ import {
|
|
|
9
10
|
export class Pointing extends StateNode {
|
|
10
11
|
static override id = 'pointing'
|
|
11
12
|
|
|
13
|
+
_isHoldingAccelKey = false
|
|
14
|
+
|
|
12
15
|
override onEnter() {
|
|
16
|
+
this._isHoldingAccelKey = isAccelKey(this.editor.inputs)
|
|
17
|
+
|
|
13
18
|
const zoomLevel = this.editor.getZoomLevel()
|
|
14
19
|
const currentPageShapesSorted = this.editor.getCurrentPageRenderingShapesSorted()
|
|
15
20
|
const {
|
|
@@ -45,12 +50,25 @@ export class Pointing extends StateNode {
|
|
|
45
50
|
}
|
|
46
51
|
|
|
47
52
|
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
|
+
}
|
|
48
58
|
}
|
|
49
59
|
}
|
|
50
60
|
|
|
51
61
|
this.editor.setErasingShapes([...erasing])
|
|
52
62
|
}
|
|
53
63
|
|
|
64
|
+
override onKeyUp() {
|
|
65
|
+
this._isHoldingAccelKey = isAccelKey(this.editor.inputs)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
override onKeyDown() {
|
|
69
|
+
this._isHoldingAccelKey = isAccelKey(this.editor.inputs)
|
|
70
|
+
}
|
|
71
|
+
|
|
54
72
|
override onLongPress(info: TLPointerEventInfo) {
|
|
55
73
|
this.startErasing(info)
|
|
56
74
|
}
|
|
@@ -62,6 +80,8 @@ export class Pointing extends StateNode {
|
|
|
62
80
|
}
|
|
63
81
|
|
|
64
82
|
override onPointerMove(info: TLPointerEventInfo) {
|
|
83
|
+
if (this._isHoldingAccelKey) return
|
|
84
|
+
|
|
65
85
|
if (this.editor.inputs.isDragging) {
|
|
66
86
|
this.startErasing(info)
|
|
67
87
|
}
|
|
@@ -9,11 +9,18 @@ export class PointingCrop extends StateNode {
|
|
|
9
9
|
|
|
10
10
|
override onPointerMove(info: TLPointerEventInfo) {
|
|
11
11
|
if (this.editor.inputs.isDragging) {
|
|
12
|
-
this.
|
|
12
|
+
this.startDragging(info)
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
+
override onLongPress(info: TLPointerEventInfo) {
|
|
16
|
+
this.startDragging(info)
|
|
17
|
+
}
|
|
15
18
|
|
|
16
19
|
override onPointerUp(info: TLPointerEventInfo) {
|
|
17
20
|
this.editor.setCurrentTool('select.crop.idle', info)
|
|
18
21
|
}
|
|
22
|
+
|
|
23
|
+
startDragging(info: TLPointerEventInfo) {
|
|
24
|
+
this.editor.setCurrentTool('select.crop.translating_crop', info)
|
|
25
|
+
}
|
|
19
26
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
Mat,
|
|
2
3
|
StateNode,
|
|
3
4
|
TLArrowShape,
|
|
4
5
|
TLHandle,
|
|
@@ -26,20 +27,20 @@ export type DraggingHandleInfo = TLPointerEventInfo & {
|
|
|
26
27
|
export class DraggingHandle extends StateNode {
|
|
27
28
|
static override id = 'dragging_handle'
|
|
28
29
|
|
|
29
|
-
shapeId
|
|
30
|
-
initialHandle
|
|
31
|
-
initialAdjacentHandle
|
|
32
|
-
initialPagePoint
|
|
30
|
+
shapeId!: TLShapeId
|
|
31
|
+
initialHandle!: TLHandle
|
|
32
|
+
initialAdjacentHandle!: TLHandle | null
|
|
33
|
+
initialPagePoint!: Vec
|
|
33
34
|
|
|
34
|
-
markId
|
|
35
|
-
initialPageTransform
|
|
36
|
-
initialPageRotation
|
|
35
|
+
markId!: string
|
|
36
|
+
initialPageTransform!: Mat
|
|
37
|
+
initialPageRotation!: number
|
|
37
38
|
|
|
38
|
-
info
|
|
39
|
+
info!: DraggingHandleInfo
|
|
39
40
|
|
|
40
41
|
isPrecise = false
|
|
41
|
-
isPreciseId
|
|
42
|
-
pointingId
|
|
42
|
+
isPreciseId: TLShapeId | null = null
|
|
43
|
+
pointingId: TLShapeId | null = null
|
|
43
44
|
|
|
44
45
|
override onEnter(info: DraggingHandleInfo) {
|
|
45
46
|
const { shape, isCreating, creatingMarkId, handle } = info
|
|
@@ -66,26 +67,6 @@ export class DraggingHandle extends StateNode {
|
|
|
66
67
|
|
|
67
68
|
this.initialHandle = structuredClone(handle)
|
|
68
69
|
|
|
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
|
-
|
|
89
70
|
this.initialPageTransform = this.editor.getShapePageTransform(shape)!
|
|
90
71
|
this.initialPageRotation = this.initialPageTransform.rotation()
|
|
91
72
|
this.initialPagePoint = this.editor.inputs.originPagePoint.clone()
|
|
@@ -135,6 +116,19 @@ export class DraggingHandle extends StateNode {
|
|
|
135
116
|
}
|
|
136
117
|
// -->
|
|
137
118
|
|
|
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
|
+
|
|
138
132
|
this.update()
|
|
139
133
|
|
|
140
134
|
this.editor.select(this.shapeId)
|
|
@@ -204,6 +198,22 @@ export class DraggingHandle extends StateNode {
|
|
|
204
198
|
this.editor.snaps.clearIndicators()
|
|
205
199
|
kickoutOccludedShapes(this.editor, [this.shapeId])
|
|
206
200
|
|
|
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
|
+
|
|
207
217
|
const { onInteractionEnd } = this.info
|
|
208
218
|
if (this.editor.getInstanceState().isToolLocked && onInteractionEnd) {
|
|
209
219
|
// Return to the tool that was active before this one,
|
|
@@ -216,6 +226,19 @@ export class DraggingHandle extends StateNode {
|
|
|
216
226
|
}
|
|
217
227
|
|
|
218
228
|
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
|
+
|
|
219
242
|
this.editor.bailToMark(this.markId)
|
|
220
243
|
this.editor.snaps.clearIndicators()
|
|
221
244
|
|
|
@@ -284,6 +307,7 @@ export class DraggingHandle extends StateNode {
|
|
|
284
307
|
const changes = util.onHandleDrag?.(shape, {
|
|
285
308
|
handle: nextHandle,
|
|
286
309
|
isPrecise: this.isPrecise || altKey,
|
|
310
|
+
isCreatingShape: !!this.info.isCreating,
|
|
287
311
|
initial: initial,
|
|
288
312
|
})
|
|
289
313
|
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Editor,
|
|
3
|
-
Group2d,
|
|
4
3
|
StateNode,
|
|
5
4
|
TLAdjacentDirection,
|
|
6
|
-
TLArrowShape,
|
|
7
5
|
TLClickEventInfo,
|
|
8
6
|
TLGroupShape,
|
|
9
7
|
TLKeyboardEventInfo,
|
|
@@ -18,6 +16,7 @@ import {
|
|
|
18
16
|
pointInPolygon,
|
|
19
17
|
toRichText,
|
|
20
18
|
} from '@tldraw/editor'
|
|
19
|
+
import { isOverArrowLabel } from '../../../shapes/arrow/arrowLabel'
|
|
21
20
|
import { getHitShapeOnCanvasPointerDown } from '../../selection-logic/getHitShapeOnCanvasPointerDown'
|
|
22
21
|
import { getShouldEnterCropMode } from '../../selection-logic/getShouldEnterCropModeOnPointerDown'
|
|
23
22
|
import { selectOnCanvasPointerUp } from '../../selection-logic/selectOnCanvasPointerUp'
|
|
@@ -98,12 +97,6 @@ export class Idle extends StateNode {
|
|
|
98
97
|
case 'shape': {
|
|
99
98
|
const { shape } = info
|
|
100
99
|
|
|
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
|
-
|
|
107
100
|
if (this.editor.isShapeOrAncestorLocked(shape)) {
|
|
108
101
|
this.parent.transition('pointing_canvas', info)
|
|
109
102
|
break
|
|
@@ -595,22 +588,7 @@ export class Idle extends StateNode {
|
|
|
595
588
|
isOverArrowLabelTest(shape: TLShape | undefined) {
|
|
596
589
|
if (!shape) return false
|
|
597
590
|
|
|
598
|
-
|
|
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
|
|
591
|
+
return isOverArrowLabel(this.editor, shape)
|
|
614
592
|
}
|
|
615
593
|
|
|
616
594
|
handleDoubleClickOnCanvas(info: TLClickEventInfo) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { StateNode, TLPointerEventInfo, TLShape } from '@tldraw/editor'
|
|
2
|
+
import { isOverArrowLabel } from '../../../shapes/arrow/arrowLabel'
|
|
2
3
|
import { getTextLabels } from '../../../utils/shapes/shapes'
|
|
3
4
|
|
|
4
5
|
export class PointingShape extends StateNode {
|
|
@@ -210,6 +211,12 @@ export class PointingShape extends StateNode {
|
|
|
210
211
|
|
|
211
212
|
override onPointerMove(info: TLPointerEventInfo) {
|
|
212
213
|
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
|
+
|
|
213
220
|
if (this.didCtrlOnEnter) {
|
|
214
221
|
this.parent.transition('brushing', info)
|
|
215
222
|
} else {
|
|
@@ -122,8 +122,19 @@ export class Resizing extends StateNode {
|
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
private cancel() {
|
|
125
|
-
//
|
|
125
|
+
// Call onResizeCancel callback before resetting
|
|
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
|
+
|
|
126
136
|
this.editor.bailToMark(this.markId)
|
|
137
|
+
|
|
127
138
|
if (this.info.onInteractionEnd) {
|
|
128
139
|
this.editor.setCurrentTool(this.info.onInteractionEnd, {})
|
|
129
140
|
} else {
|
|
@@ -109,6 +109,17 @@ 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
|
+
|
|
112
123
|
this.editor.bailToMark(this.markId)
|
|
113
124
|
if (this.info.onInteractionEnd) {
|
|
114
125
|
this.editor.setCurrentTool(this.info.onInteractionEnd, this.info)
|
|
@@ -28,7 +28,6 @@ export type TranslatingInfo = TLPointerEventInfo & {
|
|
|
28
28
|
isCreating?: boolean
|
|
29
29
|
creatingMarkId?: string
|
|
30
30
|
onCreate?(): void
|
|
31
|
-
didStartInPit?: boolean
|
|
32
31
|
onInteractionEnd?: string
|
|
33
32
|
}
|
|
34
33
|
|
|
@@ -203,6 +202,17 @@ export class Translating extends StateNode {
|
|
|
203
202
|
}
|
|
204
203
|
|
|
205
204
|
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
|
+
|
|
206
216
|
this.reset()
|
|
207
217
|
if (this.info.onInteractionEnd) {
|
|
208
218
|
this.editor.setCurrentTool(this.info.onInteractionEnd)
|
package/src/lib/ui/TldrawUi.tsx
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { tlenv, useEditor, useReactor, useValue } from '@tldraw/editor'
|
|
2
2
|
import classNames from 'classnames'
|
|
3
|
-
import React, { ReactNode, useRef, useState } from 'react'
|
|
3
|
+
import React, { ReactNode, useMemo, useRef, useState } from 'react'
|
|
4
4
|
import { TLUiAssetUrlOverrides } from './assetUrls'
|
|
5
5
|
import { SkipToMainContent } from './components/A11y'
|
|
6
|
-
import { FollowingIndicator } from './components/FollowingIndicator'
|
|
7
6
|
import { TldrawUiButton } from './components/primitives/Button/TldrawUiButton'
|
|
8
7
|
import { TldrawUiButtonIcon } from './components/primitives/Button/TldrawUiButtonIcon'
|
|
9
|
-
import { PORTRAIT_BREAKPOINT } from './constants'
|
|
8
|
+
import { PORTRAIT_BREAKPOINT, PORTRAIT_BREAKPOINTS } from './constants'
|
|
10
9
|
import {
|
|
11
10
|
TLUiContextProviderProps,
|
|
12
11
|
TldrawUiContextProvider,
|
|
@@ -108,10 +107,6 @@ const TldrawUiContent = React.memo(function TldrawUI() {
|
|
|
108
107
|
NavigationPanel,
|
|
109
108
|
HelperButtons,
|
|
110
109
|
DebugPanel,
|
|
111
|
-
CursorChatBubble,
|
|
112
|
-
RichTextToolbar,
|
|
113
|
-
ImageToolbar,
|
|
114
|
-
VideoToolbar,
|
|
115
110
|
Toasts,
|
|
116
111
|
Dialogs,
|
|
117
112
|
A11y,
|
|
@@ -160,6 +155,19 @@ const TldrawUiContent = React.memo(function TldrawUI() {
|
|
|
160
155
|
|
|
161
156
|
const { 'toggle-focus-mode': toggleFocus } = useActions()
|
|
162
157
|
|
|
158
|
+
const { breakpointsAbove, breakpointsBelow } = useMemo(() => {
|
|
159
|
+
const breakpointsAbove = []
|
|
160
|
+
const breakpointsBelow = []
|
|
161
|
+
for (let bp = 0; bp < PORTRAIT_BREAKPOINTS.length; bp++) {
|
|
162
|
+
if (bp <= breakpoint) {
|
|
163
|
+
breakpointsAbove.push(bp)
|
|
164
|
+
} else {
|
|
165
|
+
breakpointsBelow.push(bp)
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return { breakpointsAbove, breakpointsBelow }
|
|
169
|
+
}, [breakpoint])
|
|
170
|
+
|
|
163
171
|
return (
|
|
164
172
|
<div
|
|
165
173
|
className={classNames('tlui-layout', {
|
|
@@ -169,6 +177,8 @@ const TldrawUiContent = React.memo(function TldrawUI() {
|
|
|
169
177
|
// But when the virtual keyboard is closing we want to wait a bit before showing it again.
|
|
170
178
|
data-iseditinganything={hideToolbarWhileEditing}
|
|
171
179
|
data-breakpoint={breakpoint}
|
|
180
|
+
data-breakpoints-above={breakpointsAbove.join(' ')}
|
|
181
|
+
data-breakpoints-below={breakpointsBelow.join(' ')}
|
|
172
182
|
>
|
|
173
183
|
<SkipToMainContent />
|
|
174
184
|
{isFocusMode ? (
|
|
@@ -208,13 +218,24 @@ const TldrawUiContent = React.memo(function TldrawUI() {
|
|
|
208
218
|
</div>
|
|
209
219
|
</>
|
|
210
220
|
)}
|
|
211
|
-
{RichTextToolbar && <RichTextToolbar />}
|
|
212
|
-
{ImageToolbar && <ImageToolbar />}
|
|
213
|
-
{VideoToolbar && <VideoToolbar />}
|
|
214
221
|
{Toasts && <Toasts />}
|
|
215
222
|
{Dialogs && <Dialogs />}
|
|
216
|
-
<FollowingIndicator />
|
|
217
|
-
{CursorChatBubble && <CursorChatBubble />}
|
|
218
223
|
</div>
|
|
219
224
|
)
|
|
220
225
|
})
|
|
226
|
+
|
|
227
|
+
/** @public @react */
|
|
228
|
+
export function TldrawUiInFrontOfTheCanvas() {
|
|
229
|
+
const { RichTextToolbar, ImageToolbar, VideoToolbar, CursorChatBubble, FollowingIndicator } =
|
|
230
|
+
useTldrawUiComponents()
|
|
231
|
+
|
|
232
|
+
return (
|
|
233
|
+
<>
|
|
234
|
+
{RichTextToolbar && <RichTextToolbar />}
|
|
235
|
+
{ImageToolbar && <ImageToolbar />}
|
|
236
|
+
{VideoToolbar && <VideoToolbar />}
|
|
237
|
+
{FollowingIndicator && <FollowingIndicator />}
|
|
238
|
+
{CursorChatBubble && <CursorChatBubble />}
|
|
239
|
+
</>
|
|
240
|
+
)
|
|
241
|
+
}
|
|
@@ -148,20 +148,22 @@ export const useSelectedShapesAnnouncer = () => {
|
|
|
148
148
|
if (!editor) return
|
|
149
149
|
|
|
150
150
|
const isInSelecting = editor.isIn('select.idle')
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
rPrevSelectedShapeIds.current
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
151
|
+
if (isInSelecting) {
|
|
152
|
+
const selectedShapeIds = editor.getSelectedShapeIds()
|
|
153
|
+
if (selectedShapeIds !== rPrevSelectedShapeIds.current) {
|
|
154
|
+
rPrevSelectedShapeIds.current = selectedShapeIds
|
|
155
|
+
unsafe__withoutCapture(() => {
|
|
156
|
+
const a11yLive = generateShapeAnnouncementMessage({
|
|
157
|
+
editor,
|
|
158
|
+
selectedShapeIds,
|
|
159
|
+
msg,
|
|
160
|
+
})
|
|
161
|
+
|
|
162
|
+
if (a11yLive) {
|
|
163
|
+
a11y.announce({ msg: a11yLive })
|
|
164
|
+
}
|
|
159
165
|
})
|
|
160
|
-
|
|
161
|
-
if (a11yLive) {
|
|
162
|
-
a11y.announce({ msg: a11yLive })
|
|
163
|
-
}
|
|
164
|
-
})
|
|
166
|
+
}
|
|
165
167
|
}
|
|
166
168
|
},
|
|
167
169
|
[editor, a11y, msg]
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ToggleKeyboardShortcutsItem,
|
|
3
|
+
ToggleReduceMotionItem,
|
|
4
|
+
ToggleUiLabelsItem,
|
|
5
|
+
} from './menu-items'
|
|
6
|
+
import { TldrawUiMenuGroup } from './primitives/menus/TldrawUiMenuGroup'
|
|
7
|
+
import { TldrawUiMenuSubmenu } from './primitives/menus/TldrawUiMenuSubmenu'
|
|
8
|
+
|
|
9
|
+
/** @public @react */
|
|
10
|
+
export function AccessibilityMenu() {
|
|
11
|
+
return (
|
|
12
|
+
<TldrawUiMenuSubmenu id="help menu accessibility" label="menu.accessibility">
|
|
13
|
+
<TldrawUiMenuGroup id="accessibility">
|
|
14
|
+
<ToggleReduceMotionItem />
|
|
15
|
+
<ToggleKeyboardShortcutsItem />
|
|
16
|
+
<ToggleUiLabelsItem />
|
|
17
|
+
</TldrawUiMenuGroup>
|
|
18
|
+
</TldrawUiMenuSubmenu>
|
|
19
|
+
)
|
|
20
|
+
}
|