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
|
@@ -3,6 +3,7 @@ import { ReactNode } from 'react'
|
|
|
3
3
|
import { unwrapLabel } from '../../../context/actions'
|
|
4
4
|
import { TLUiTranslationKey } from '../../../hooks/useTranslation/TLUiTranslationKey'
|
|
5
5
|
import { useTranslation } from '../../../hooks/useTranslation/useTranslation'
|
|
6
|
+
import { TldrawUiColumn, TldrawUiGrid, TldrawUiRow, useTldrawUiOrientation } from '../layout'
|
|
6
7
|
import { TldrawUiDropdownMenuGroup } from '../TldrawUiDropdownMenu'
|
|
7
8
|
import { useTldrawUiMenuContext } from './TldrawUiMenuContext'
|
|
8
9
|
|
|
@@ -19,25 +20,19 @@ export interface TLUiMenuGroupProps<TranslationKey extends string = string> {
|
|
|
19
20
|
|
|
20
21
|
/** @public @react */
|
|
21
22
|
export function TldrawUiMenuGroup({ id, label, className, children }: TLUiMenuGroupProps) {
|
|
22
|
-
const
|
|
23
|
+
const menu = useTldrawUiMenuContext()
|
|
24
|
+
const { orientation } = useTldrawUiOrientation()
|
|
23
25
|
const msg = useTranslation()
|
|
24
|
-
const labelToUse = unwrapLabel(label,
|
|
26
|
+
const labelToUse = unwrapLabel(label, menu.type)
|
|
25
27
|
const labelStr = labelToUse ? msg(labelToUse as TLUiTranslationKey) : undefined
|
|
26
28
|
|
|
27
|
-
switch (
|
|
28
|
-
case 'panel': {
|
|
29
|
-
return (
|
|
30
|
-
<div
|
|
31
|
-
className={classNames('tlui-menu__group', className)}
|
|
32
|
-
data-testid={`${sourceId}-group.${id}`}
|
|
33
|
-
>
|
|
34
|
-
{children}
|
|
35
|
-
</div>
|
|
36
|
-
)
|
|
37
|
-
}
|
|
29
|
+
switch (menu.type) {
|
|
38
30
|
case 'menu': {
|
|
39
31
|
return (
|
|
40
|
-
<TldrawUiDropdownMenuGroup
|
|
32
|
+
<TldrawUiDropdownMenuGroup
|
|
33
|
+
className={className}
|
|
34
|
+
data-testid={`${menu.sourceId}-group.${id}`}
|
|
35
|
+
>
|
|
41
36
|
{children}
|
|
42
37
|
</TldrawUiDropdownMenuGroup>
|
|
43
38
|
)
|
|
@@ -47,7 +42,7 @@ export function TldrawUiMenuGroup({ id, label, className, children }: TLUiMenuGr
|
|
|
47
42
|
<div
|
|
48
43
|
dir="ltr"
|
|
49
44
|
className={classNames('tlui-menu__group', className)}
|
|
50
|
-
data-testid={`${sourceId}-group.${id}`}
|
|
45
|
+
data-testid={`${menu.sourceId}-group.${id}`}
|
|
51
46
|
>
|
|
52
47
|
{children}
|
|
53
48
|
</div>
|
|
@@ -56,12 +51,30 @@ export function TldrawUiMenuGroup({ id, label, className, children }: TLUiMenuGr
|
|
|
56
51
|
case 'keyboard-shortcuts': {
|
|
57
52
|
// todo: if groups need a label, let's give em a label
|
|
58
53
|
return (
|
|
59
|
-
<div className="tlui-shortcuts-dialog__group" data-testid={`${sourceId}-group.${id}`}>
|
|
54
|
+
<div className="tlui-shortcuts-dialog__group" data-testid={`${menu.sourceId}-group.${id}`}>
|
|
60
55
|
<h2 className="tlui-shortcuts-dialog__group__title">{labelStr}</h2>
|
|
61
56
|
<div className="tlui-shortcuts-dialog__group__content">{children}</div>
|
|
62
57
|
</div>
|
|
63
58
|
)
|
|
64
59
|
}
|
|
60
|
+
case 'toolbar': {
|
|
61
|
+
const Layout = orientation === 'horizontal' ? TldrawUiRow : TldrawUiColumn
|
|
62
|
+
return (
|
|
63
|
+
<Layout className="tlui-main-toolbar__group" data-testid={`${menu.sourceId}-group.${id}`}>
|
|
64
|
+
{children}
|
|
65
|
+
</Layout>
|
|
66
|
+
)
|
|
67
|
+
}
|
|
68
|
+
case 'toolbar-overflow': {
|
|
69
|
+
return (
|
|
70
|
+
<TldrawUiGrid
|
|
71
|
+
className="tlui-main-toolbar__group"
|
|
72
|
+
data-testid={`${menu.sourceId}-group.${id}`}
|
|
73
|
+
>
|
|
74
|
+
{children}
|
|
75
|
+
</TldrawUiGrid>
|
|
76
|
+
)
|
|
77
|
+
}
|
|
65
78
|
default: {
|
|
66
79
|
return children
|
|
67
80
|
}
|
|
@@ -1,9 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
exhaustiveSwitchError,
|
|
3
|
+
getPointerInfo,
|
|
4
|
+
preventDefault,
|
|
5
|
+
TLPointerEventInfo,
|
|
6
|
+
useEditor,
|
|
7
|
+
Vec,
|
|
8
|
+
VecModel,
|
|
9
|
+
} from '@tldraw/editor'
|
|
2
10
|
import { ContextMenu as _ContextMenu } from 'radix-ui'
|
|
3
|
-
import { useState } from 'react'
|
|
11
|
+
import { useMemo, useState } from 'react'
|
|
4
12
|
import { unwrapLabel } from '../../../context/actions'
|
|
5
13
|
import { TLUiEventSource } from '../../../context/events'
|
|
6
14
|
import { useReadonly } from '../../../hooks/useReadonly'
|
|
15
|
+
import { TLUiToolItem } from '../../../hooks/useTools'
|
|
7
16
|
import { TLUiTranslationKey } from '../../../hooks/useTranslation/TLUiTranslationKey'
|
|
8
17
|
import { useTranslation } from '../../../hooks/useTranslation/useTranslation'
|
|
9
18
|
import { kbdStr } from '../../../kbd-utils'
|
|
@@ -12,8 +21,10 @@ import { TldrawUiButton } from '../Button/TldrawUiButton'
|
|
|
12
21
|
import { TldrawUiButtonIcon } from '../Button/TldrawUiButtonIcon'
|
|
13
22
|
import { TldrawUiButtonLabel } from '../Button/TldrawUiButtonLabel'
|
|
14
23
|
import { TldrawUiDropdownMenuItem } from '../TldrawUiDropdownMenu'
|
|
24
|
+
import { TLUiIconJsx } from '../TldrawUiIcon'
|
|
15
25
|
import { TldrawUiKbd } from '../TldrawUiKbd'
|
|
16
26
|
import { TldrawUiToolbarButton } from '../TldrawUiToolbar'
|
|
27
|
+
import { tooltipManager } from '../TldrawUiTooltip'
|
|
17
28
|
import { useTldrawUiMenuContext } from './TldrawUiMenuContext'
|
|
18
29
|
|
|
19
30
|
/** @public */
|
|
@@ -25,11 +36,11 @@ export interface TLUiMenuItemProps<
|
|
|
25
36
|
/**
|
|
26
37
|
* The icon to display on the item. Icons are only shown in certain menu types.
|
|
27
38
|
*/
|
|
28
|
-
icon?: IconType
|
|
39
|
+
icon?: IconType | TLUiIconJsx
|
|
29
40
|
/**
|
|
30
41
|
* An icon to display to the left of the menu item.
|
|
31
42
|
*/
|
|
32
|
-
iconLeft?: IconType
|
|
43
|
+
iconLeft?: IconType | TLUiIconJsx
|
|
33
44
|
/**
|
|
34
45
|
* The keyboard shortcut to display on the item.
|
|
35
46
|
*/
|
|
@@ -62,6 +73,10 @@ export interface TLUiMenuItemProps<
|
|
|
62
73
|
* Whether the item is selected.
|
|
63
74
|
*/
|
|
64
75
|
isSelected?: boolean
|
|
76
|
+
/**
|
|
77
|
+
* The function to call when the item is dragged. If this is provided, the item will be draggable.
|
|
78
|
+
*/
|
|
79
|
+
onDragStart?(source: TLUiEventSource, info: TLPointerEventInfo): void
|
|
65
80
|
}
|
|
66
81
|
|
|
67
82
|
/** @public @react */
|
|
@@ -80,6 +95,7 @@ export function TldrawUiMenuItem<
|
|
|
80
95
|
onSelect,
|
|
81
96
|
noClose,
|
|
82
97
|
isSelected,
|
|
98
|
+
onDragStart,
|
|
83
99
|
}: TLUiMenuItemProps<TranslationKey, IconType>) {
|
|
84
100
|
const { type: menuType, sourceId } = useTldrawUiMenuContext()
|
|
85
101
|
|
|
@@ -104,7 +120,6 @@ export function TldrawUiMenuItem<
|
|
|
104
120
|
type="menu"
|
|
105
121
|
data-testid={`${sourceId}.${id}`}
|
|
106
122
|
disabled={disabled}
|
|
107
|
-
title={titleStr}
|
|
108
123
|
onClick={(e) => {
|
|
109
124
|
if (noClose) {
|
|
110
125
|
preventDefault(e)
|
|
@@ -130,7 +145,6 @@ export function TldrawUiMenuItem<
|
|
|
130
145
|
return (
|
|
131
146
|
<_ContextMenu.Item
|
|
132
147
|
dir="ltr"
|
|
133
|
-
title={titleStr}
|
|
134
148
|
draggable={false}
|
|
135
149
|
className="tlui-button tlui-button__menu"
|
|
136
150
|
data-testid={`${sourceId}.${id}`}
|
|
@@ -152,20 +166,6 @@ export function TldrawUiMenuItem<
|
|
|
152
166
|
</_ContextMenu.Item>
|
|
153
167
|
)
|
|
154
168
|
}
|
|
155
|
-
case 'panel': {
|
|
156
|
-
return (
|
|
157
|
-
<TldrawUiButton
|
|
158
|
-
data-testid={`${sourceId}.${id}`}
|
|
159
|
-
type="menu"
|
|
160
|
-
title={titleStr}
|
|
161
|
-
disabled={disabled}
|
|
162
|
-
onClick={() => onSelect(sourceId)}
|
|
163
|
-
>
|
|
164
|
-
<TldrawUiButtonLabel>{labelStr}</TldrawUiButtonLabel>
|
|
165
|
-
{spinner ? <Spinner /> : icon && <TldrawUiButtonIcon icon={icon} />}
|
|
166
|
-
</TldrawUiButton>
|
|
167
|
-
)
|
|
168
|
-
}
|
|
169
169
|
case 'small-icons':
|
|
170
170
|
case 'icons': {
|
|
171
171
|
return (
|
|
@@ -206,6 +206,20 @@ export function TldrawUiMenuItem<
|
|
|
206
206
|
)
|
|
207
207
|
}
|
|
208
208
|
case 'toolbar': {
|
|
209
|
+
if (onDragStart) {
|
|
210
|
+
return (
|
|
211
|
+
<DraggableToolbarButton
|
|
212
|
+
id={id}
|
|
213
|
+
icon={icon}
|
|
214
|
+
onSelect={onSelect}
|
|
215
|
+
onDragStart={onDragStart}
|
|
216
|
+
labelToUse={labelToUse}
|
|
217
|
+
titleStr={titleStr}
|
|
218
|
+
disabled={disabled}
|
|
219
|
+
isSelected={isSelected}
|
|
220
|
+
/>
|
|
221
|
+
)
|
|
222
|
+
}
|
|
209
223
|
return (
|
|
210
224
|
<TldrawUiToolbarButton
|
|
211
225
|
aria-label={labelStr}
|
|
@@ -218,7 +232,6 @@ export function TldrawUiMenuItem<
|
|
|
218
232
|
preventDefault(e)
|
|
219
233
|
onSelect('toolbar')
|
|
220
234
|
}}
|
|
221
|
-
role="option"
|
|
222
235
|
title={titleStr}
|
|
223
236
|
type="tool"
|
|
224
237
|
>
|
|
@@ -227,17 +240,30 @@ export function TldrawUiMenuItem<
|
|
|
227
240
|
)
|
|
228
241
|
}
|
|
229
242
|
case 'toolbar-overflow': {
|
|
243
|
+
if (onDragStart) {
|
|
244
|
+
return (
|
|
245
|
+
<DraggableToolbarButton
|
|
246
|
+
id={id}
|
|
247
|
+
icon={icon}
|
|
248
|
+
onSelect={onSelect}
|
|
249
|
+
onDragStart={onDragStart}
|
|
250
|
+
labelToUse={labelToUse}
|
|
251
|
+
titleStr={titleStr}
|
|
252
|
+
disabled={disabled}
|
|
253
|
+
isSelected={isSelected}
|
|
254
|
+
overflow
|
|
255
|
+
/>
|
|
256
|
+
)
|
|
257
|
+
}
|
|
230
258
|
return (
|
|
231
259
|
<TldrawUiToolbarButton
|
|
232
260
|
aria-label={labelStr}
|
|
233
261
|
aria-pressed={isSelected ? 'true' : 'false'}
|
|
234
262
|
isActive={isSelected}
|
|
235
|
-
className="tlui-button-grid__button"
|
|
236
263
|
data-testid={`tools.more.${id}`}
|
|
237
264
|
data-value={id}
|
|
238
265
|
disabled={disabled}
|
|
239
266
|
onClick={() => onSelect('toolbar')}
|
|
240
|
-
role="option"
|
|
241
267
|
title={titleStr}
|
|
242
268
|
type="icon"
|
|
243
269
|
>
|
|
@@ -250,3 +276,178 @@ export function TldrawUiMenuItem<
|
|
|
250
276
|
}
|
|
251
277
|
}
|
|
252
278
|
}
|
|
279
|
+
|
|
280
|
+
function useDraggableEvents(
|
|
281
|
+
onDragStart: TLUiToolItem['onDragStart'],
|
|
282
|
+
onSelect: TLUiToolItem['onSelect']
|
|
283
|
+
) {
|
|
284
|
+
const editor = useEditor()
|
|
285
|
+
const events = useMemo(() => {
|
|
286
|
+
let state = { name: 'idle' } as
|
|
287
|
+
| {
|
|
288
|
+
name: 'idle'
|
|
289
|
+
}
|
|
290
|
+
| {
|
|
291
|
+
name: 'pointing'
|
|
292
|
+
screenSpaceStart: VecModel
|
|
293
|
+
}
|
|
294
|
+
| {
|
|
295
|
+
name: 'dragging'
|
|
296
|
+
screenSpaceStart: VecModel
|
|
297
|
+
}
|
|
298
|
+
| {
|
|
299
|
+
name: 'dragged'
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
function handlePointerDown(e: React.PointerEvent<HTMLButtonElement>) {
|
|
303
|
+
state = {
|
|
304
|
+
name: 'pointing',
|
|
305
|
+
screenSpaceStart: { x: e.clientX, y: e.clientY },
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
e.currentTarget.setPointerCapture(e.pointerId)
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
function handlePointerMove(e: React.PointerEvent<HTMLButtonElement>) {
|
|
312
|
+
if ((e as any).isSpecialRedispatchedEvent) return
|
|
313
|
+
|
|
314
|
+
if (state.name === 'pointing') {
|
|
315
|
+
const distanceSq = Vec.Dist2(state.screenSpaceStart, { x: e.clientX, y: e.clientY })
|
|
316
|
+
if (
|
|
317
|
+
distanceSq >
|
|
318
|
+
(editor.getInstanceState().isCoarsePointer
|
|
319
|
+
? editor.options.uiCoarseDragDistanceSquared
|
|
320
|
+
: editor.options.uiDragDistanceSquared)
|
|
321
|
+
) {
|
|
322
|
+
const screenSpaceStart = state.screenSpaceStart
|
|
323
|
+
state = {
|
|
324
|
+
name: 'dragging',
|
|
325
|
+
screenSpaceStart,
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
editor.run(() => {
|
|
329
|
+
editor.setCurrentTool('select')
|
|
330
|
+
|
|
331
|
+
// Set origin point
|
|
332
|
+
editor.dispatch({
|
|
333
|
+
type: 'pointer',
|
|
334
|
+
target: 'canvas',
|
|
335
|
+
name: 'pointer_down',
|
|
336
|
+
...getPointerInfo(e),
|
|
337
|
+
point: screenSpaceStart,
|
|
338
|
+
})
|
|
339
|
+
|
|
340
|
+
// Pointer down potentially selects shapes, so we need to deselect them.
|
|
341
|
+
editor.selectNone()
|
|
342
|
+
|
|
343
|
+
// start drag
|
|
344
|
+
onDragStart?.('toolbar', {
|
|
345
|
+
type: 'pointer',
|
|
346
|
+
target: 'canvas',
|
|
347
|
+
name: 'pointer_move',
|
|
348
|
+
...getPointerInfo(e),
|
|
349
|
+
point: screenSpaceStart,
|
|
350
|
+
})
|
|
351
|
+
|
|
352
|
+
tooltipManager.hideAllTooltips()
|
|
353
|
+
editor.getContainer().focus()
|
|
354
|
+
})
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
function handlePointerUp(e: React.PointerEvent<HTMLButtonElement>) {
|
|
360
|
+
if ((e as any).isSpecialRedispatchedEvent) return
|
|
361
|
+
|
|
362
|
+
e.currentTarget.releasePointerCapture(e.pointerId)
|
|
363
|
+
|
|
364
|
+
editor.dispatch({
|
|
365
|
+
type: 'pointer',
|
|
366
|
+
target: 'canvas',
|
|
367
|
+
name: 'pointer_up',
|
|
368
|
+
...getPointerInfo(e),
|
|
369
|
+
})
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
function handleClick() {
|
|
373
|
+
if (state.name === 'dragging' || state.name === 'dragged') {
|
|
374
|
+
state = { name: 'idle' }
|
|
375
|
+
return true
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
state = { name: 'idle' }
|
|
379
|
+
onSelect?.('toolbar')
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
return {
|
|
383
|
+
onPointerDown: handlePointerDown,
|
|
384
|
+
onPointerMove: handlePointerMove,
|
|
385
|
+
onPointerUp: handlePointerUp,
|
|
386
|
+
onClick: handleClick,
|
|
387
|
+
}
|
|
388
|
+
}, [onDragStart, editor, onSelect])
|
|
389
|
+
|
|
390
|
+
return events
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
function DraggableToolbarButton({
|
|
394
|
+
id,
|
|
395
|
+
labelToUse,
|
|
396
|
+
titleStr,
|
|
397
|
+
disabled,
|
|
398
|
+
isSelected,
|
|
399
|
+
icon,
|
|
400
|
+
onSelect,
|
|
401
|
+
onDragStart,
|
|
402
|
+
overflow,
|
|
403
|
+
}: {
|
|
404
|
+
id: string
|
|
405
|
+
disabled: boolean
|
|
406
|
+
labelToUse?: string
|
|
407
|
+
titleStr?: string
|
|
408
|
+
isSelected?: boolean
|
|
409
|
+
icon: TLUiMenuItemProps['icon']
|
|
410
|
+
onSelect: TLUiMenuItemProps['onSelect']
|
|
411
|
+
onDragStart: TLUiMenuItemProps['onDragStart']
|
|
412
|
+
overflow?: boolean
|
|
413
|
+
}) {
|
|
414
|
+
const events = useDraggableEvents(onDragStart, onSelect)
|
|
415
|
+
|
|
416
|
+
if (overflow) {
|
|
417
|
+
return (
|
|
418
|
+
<TldrawUiToolbarButton
|
|
419
|
+
aria-label={labelToUse}
|
|
420
|
+
aria-pressed={isSelected ? 'true' : 'false'}
|
|
421
|
+
isActive={isSelected}
|
|
422
|
+
className="tlui-button-grid__button"
|
|
423
|
+
data-testid={`tools.more.${id}`}
|
|
424
|
+
data-value={id}
|
|
425
|
+
disabled={disabled}
|
|
426
|
+
title={titleStr}
|
|
427
|
+
type="icon"
|
|
428
|
+
{...events}
|
|
429
|
+
>
|
|
430
|
+
<TldrawUiButtonIcon icon={icon!} />
|
|
431
|
+
</TldrawUiToolbarButton>
|
|
432
|
+
)
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
return (
|
|
436
|
+
<TldrawUiToolbarButton
|
|
437
|
+
aria-label={labelToUse}
|
|
438
|
+
aria-pressed={isSelected ? 'true' : 'false'}
|
|
439
|
+
data-testid={`tools.${id}`}
|
|
440
|
+
data-value={id}
|
|
441
|
+
disabled={disabled}
|
|
442
|
+
onTouchStart={(e) => {
|
|
443
|
+
preventDefault(e)
|
|
444
|
+
onSelect('toolbar')
|
|
445
|
+
}}
|
|
446
|
+
title={titleStr}
|
|
447
|
+
type="tool"
|
|
448
|
+
{...events}
|
|
449
|
+
>
|
|
450
|
+
<TldrawUiButtonIcon icon={icon!} />
|
|
451
|
+
</TldrawUiToolbarButton>
|
|
452
|
+
)
|
|
453
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { RecursivePartial, defaultUserPreferences, track, useMaybeEditor } from '@tldraw/editor'
|
|
2
2
|
import { ReactNode } from 'react'
|
|
3
3
|
import { TLUiAssetUrls, useDefaultUiAssetUrlsWithOverrides } from '../assetUrls'
|
|
4
|
+
import { TldrawUiTooltipProvider } from '../components/primitives/TldrawUiTooltip'
|
|
4
5
|
import { ToolsProvider } from '../hooks/useTools'
|
|
5
6
|
import { TldrawUiTranslationProvider } from '../hooks/useTranslation/useTranslation'
|
|
6
7
|
import {
|
|
@@ -72,26 +73,28 @@ export const TldrawUiContextProvider = track(function TldrawUiContextProvider({
|
|
|
72
73
|
const editor = useMaybeEditor()
|
|
73
74
|
return (
|
|
74
75
|
<MimeTypeContext.Provider value={mediaMimeTypes}>
|
|
75
|
-
<
|
|
76
|
-
<
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
<
|
|
82
|
-
<
|
|
83
|
-
<
|
|
84
|
-
<
|
|
85
|
-
<
|
|
86
|
-
<
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
76
|
+
<TldrawUiTooltipProvider>
|
|
77
|
+
<AssetUrlsProvider assetUrls={useDefaultUiAssetUrlsWithOverrides(assetUrls)}>
|
|
78
|
+
<TldrawUiTranslationProvider
|
|
79
|
+
overrides={useMergedTranslationOverrides(overrides)}
|
|
80
|
+
locale={editor?.user.getLocale() ?? defaultUserPreferences.locale}
|
|
81
|
+
>
|
|
82
|
+
<TldrawUiEventsProvider onEvent={onUiEvent}>
|
|
83
|
+
<TldrawUiToastsProvider>
|
|
84
|
+
<TldrawUiDialogsProvider context={'tla'}>
|
|
85
|
+
<TldrawUiA11yProvider>
|
|
86
|
+
<BreakPointProvider forceMobile={forceMobile}>
|
|
87
|
+
<TldrawUiComponentsProvider overrides={components}>
|
|
88
|
+
<InternalProviders overrides={overrides}>{children}</InternalProviders>
|
|
89
|
+
</TldrawUiComponentsProvider>
|
|
90
|
+
</BreakPointProvider>
|
|
91
|
+
</TldrawUiA11yProvider>
|
|
92
|
+
</TldrawUiDialogsProvider>
|
|
93
|
+
</TldrawUiToastsProvider>
|
|
94
|
+
</TldrawUiEventsProvider>
|
|
95
|
+
</TldrawUiTranslationProvider>
|
|
96
|
+
</AssetUrlsProvider>
|
|
97
|
+
</TldrawUiTooltipProvider>
|
|
95
98
|
</MimeTypeContext.Provider>
|
|
96
99
|
)
|
|
97
100
|
})
|
|
@@ -28,6 +28,7 @@ import { fitFrameToContent, removeFrame } from '../../utils/frames/frames'
|
|
|
28
28
|
import { generateShapeAnnouncementMessage } from '../components/A11y'
|
|
29
29
|
import { EditLinkDialog } from '../components/EditLinkDialog'
|
|
30
30
|
import { EmbedDialog } from '../components/EmbedDialog'
|
|
31
|
+
import { DefaultKeyboardShortcutsDialog } from '../components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialog'
|
|
31
32
|
import { useShowCollaborationUi } from '../hooks/useCollaborationStatus'
|
|
32
33
|
import { flattenShapesToImages } from '../hooks/useFlatten'
|
|
33
34
|
import { TLUiTranslationKey } from '../hooks/useTranslation/TLUiTranslationKey'
|
|
@@ -35,6 +36,7 @@ import { useTranslation } from '../hooks/useTranslation/useTranslation'
|
|
|
35
36
|
import { TLUiIconType } from '../icon-types'
|
|
36
37
|
import { TLUiOverrideHelpers, useDefaultHelpers } from '../overrides'
|
|
37
38
|
import { useA11y } from './a11y'
|
|
39
|
+
import { useTldrawUiComponents } from './components'
|
|
38
40
|
import { TLUiEventSource, useUiEvents } from './events'
|
|
39
41
|
|
|
40
42
|
/** @public */
|
|
@@ -42,12 +44,13 @@ export interface TLUiActionItem<
|
|
|
42
44
|
TransationKey extends string = string,
|
|
43
45
|
IconType extends string = string,
|
|
44
46
|
> {
|
|
45
|
-
icon?: IconType
|
|
47
|
+
icon?: IconType | React.ReactElement
|
|
46
48
|
id: string
|
|
47
49
|
kbd?: string
|
|
48
50
|
label?: TransationKey | { [key: string]: TransationKey }
|
|
49
51
|
readonlyOk?: boolean
|
|
50
52
|
checkbox?: boolean
|
|
53
|
+
isRequiredA11yAction?: boolean
|
|
51
54
|
onSelect(source: TLUiEventSource): Promise<void> | void
|
|
52
55
|
}
|
|
53
56
|
|
|
@@ -96,6 +99,7 @@ export function ActionsProvider({ overrides, children }: ActionsProviderProps) {
|
|
|
96
99
|
const _editor = useMaybeEditor()
|
|
97
100
|
const showCollaborationUi = useShowCollaborationUi()
|
|
98
101
|
const helpers = useDefaultHelpers()
|
|
102
|
+
const components = useTldrawUiComponents()
|
|
99
103
|
const trackEvent = useUiEvents()
|
|
100
104
|
const a11y = useA11y()
|
|
101
105
|
const msg = useTranslation()
|
|
@@ -168,6 +172,17 @@ export function ActionsProvider({ overrides, children }: ActionsProviderProps) {
|
|
|
168
172
|
helpers.addDialog({ component: EmbedDialog })
|
|
169
173
|
},
|
|
170
174
|
},
|
|
175
|
+
{
|
|
176
|
+
id: 'open-kbd-shortcuts',
|
|
177
|
+
label: 'action.open-kbd-shortcuts',
|
|
178
|
+
kbd: 'cmd+alt+/,ctrl+alt+/',
|
|
179
|
+
onSelect(source) {
|
|
180
|
+
trackEvent('open-kbd-shortcuts', { source })
|
|
181
|
+
helpers.addDialog({
|
|
182
|
+
component: components.KeyboardShortcutsDialog ?? DefaultKeyboardShortcutsDialog,
|
|
183
|
+
})
|
|
184
|
+
},
|
|
185
|
+
},
|
|
171
186
|
{
|
|
172
187
|
id: 'insert-media',
|
|
173
188
|
label: 'action.insert-media',
|
|
@@ -502,7 +517,6 @@ export function ActionsProvider({ overrides, children }: ActionsProviderProps) {
|
|
|
502
517
|
}
|
|
503
518
|
}
|
|
504
519
|
|
|
505
|
-
if (!editor.canCreateShapes(ids)) return
|
|
506
520
|
editor.markHistoryStoppingPoint('duplicate shapes')
|
|
507
521
|
editor.duplicateShapes(ids, offset)
|
|
508
522
|
|
|
@@ -1027,17 +1041,20 @@ export function ActionsProvider({ overrides, children }: ActionsProviderProps) {
|
|
|
1027
1041
|
id: 'rotate-cw',
|
|
1028
1042
|
label: 'action.rotate-cw',
|
|
1029
1043
|
icon: 'rotate-cw',
|
|
1044
|
+
kbd: 'shift+.,shift+alt+.',
|
|
1030
1045
|
onSelect(source) {
|
|
1031
1046
|
if (!canApplySelectionAction()) return
|
|
1032
1047
|
if (mustGoBackToSelectToolFirst()) return
|
|
1033
1048
|
|
|
1034
|
-
|
|
1049
|
+
const isFine = editor.inputs.altKey
|
|
1050
|
+
trackEvent('rotate-cw', { source, fine: isFine })
|
|
1035
1051
|
editor.markHistoryStoppingPoint('rotate-cw')
|
|
1036
1052
|
editor.run(() => {
|
|
1037
|
-
const
|
|
1038
|
-
const
|
|
1053
|
+
const rotation = HALF_PI / (isFine ? 96 : 6)
|
|
1054
|
+
const offset = editor.getSelectionRotation() % rotation
|
|
1055
|
+
const dontUseOffset = approximately(offset, 0) || approximately(offset, rotation)
|
|
1039
1056
|
const selectedShapeIds = editor.getSelectedShapeIds()
|
|
1040
|
-
editor.rotateShapesBy(selectedShapeIds,
|
|
1057
|
+
editor.rotateShapesBy(selectedShapeIds, rotation - (dontUseOffset ? 0 : offset))
|
|
1041
1058
|
kickoutOccludedShapes(editor, selectedShapeIds)
|
|
1042
1059
|
})
|
|
1043
1060
|
},
|
|
@@ -1046,17 +1063,21 @@ export function ActionsProvider({ overrides, children }: ActionsProviderProps) {
|
|
|
1046
1063
|
id: 'rotate-ccw',
|
|
1047
1064
|
label: 'action.rotate-ccw',
|
|
1048
1065
|
icon: 'rotate-ccw',
|
|
1066
|
+
// omg double comma
|
|
1067
|
+
kbd: 'shift+,,shift+alt+,',
|
|
1049
1068
|
onSelect(source) {
|
|
1050
1069
|
if (!canApplySelectionAction()) return
|
|
1051
1070
|
if (mustGoBackToSelectToolFirst()) return
|
|
1052
1071
|
|
|
1053
|
-
|
|
1072
|
+
const isFine = editor.inputs.altKey
|
|
1073
|
+
trackEvent('rotate-ccw', { source, fine: isFine })
|
|
1054
1074
|
editor.markHistoryStoppingPoint('rotate-ccw')
|
|
1055
1075
|
editor.run(() => {
|
|
1056
|
-
const
|
|
1076
|
+
const rotation = HALF_PI / (isFine ? 96 : 6)
|
|
1077
|
+
const offset = editor.getSelectionRotation() % rotation
|
|
1057
1078
|
const offsetCloseToZero = approximately(offset, 0)
|
|
1058
1079
|
const selectedShapeIds = editor.getSelectedShapeIds()
|
|
1059
|
-
editor.rotateShapesBy(selectedShapeIds, offsetCloseToZero ? -
|
|
1080
|
+
editor.rotateShapesBy(selectedShapeIds, offsetCloseToZero ? -rotation : -offset)
|
|
1060
1081
|
kickoutOccludedShapes(editor, selectedShapeIds)
|
|
1061
1082
|
})
|
|
1062
1083
|
},
|
|
@@ -1234,6 +1255,36 @@ export function ActionsProvider({ overrides, children }: ActionsProviderProps) {
|
|
|
1234
1255
|
},
|
|
1235
1256
|
checkbox: true,
|
|
1236
1257
|
},
|
|
1258
|
+
{
|
|
1259
|
+
id: 'toggle-keyboard-shortcuts',
|
|
1260
|
+
label: {
|
|
1261
|
+
default: 'action.toggle-keyboard-shortcuts',
|
|
1262
|
+
menu: 'action.toggle-keyboard-shortcuts.menu',
|
|
1263
|
+
},
|
|
1264
|
+
readonlyOk: true,
|
|
1265
|
+
onSelect(source) {
|
|
1266
|
+
trackEvent('toggle-keyboard-shortcuts', { source })
|
|
1267
|
+
editor.user.updateUserPreferences({
|
|
1268
|
+
areKeyboardShortcutsEnabled: !editor.user.getAreKeyboardShortcutsEnabled(),
|
|
1269
|
+
})
|
|
1270
|
+
},
|
|
1271
|
+
checkbox: true,
|
|
1272
|
+
},
|
|
1273
|
+
{
|
|
1274
|
+
id: 'toggle-ui-labels',
|
|
1275
|
+
label: {
|
|
1276
|
+
default: 'action.toggle-ui-labels',
|
|
1277
|
+
menu: 'action.toggle-ui-labels.menu',
|
|
1278
|
+
},
|
|
1279
|
+
readonlyOk: true,
|
|
1280
|
+
onSelect(source) {
|
|
1281
|
+
trackEvent('toggle-ui-labels', { source })
|
|
1282
|
+
editor.user.updateUserPreferences({
|
|
1283
|
+
showUiLabels: !editor.user.getShowUiLabels(),
|
|
1284
|
+
})
|
|
1285
|
+
},
|
|
1286
|
+
checkbox: true,
|
|
1287
|
+
},
|
|
1237
1288
|
{
|
|
1238
1289
|
id: 'toggle-edge-scrolling',
|
|
1239
1290
|
label: {
|
|
@@ -1530,6 +1581,7 @@ export function ActionsProvider({ overrides, children }: ActionsProviderProps) {
|
|
|
1530
1581
|
id: 'adjust-shape-styles',
|
|
1531
1582
|
label: 'a11y.adjust-shape-styles',
|
|
1532
1583
|
kbd: 'cmd+Enter,ctrl+Enter',
|
|
1584
|
+
isRequiredA11yAction: true,
|
|
1533
1585
|
onSelect: async (source) => {
|
|
1534
1586
|
if (!canApplySelectionAction()) return
|
|
1535
1587
|
|
|
@@ -1543,6 +1595,7 @@ export function ActionsProvider({ overrides, children }: ActionsProviderProps) {
|
|
|
1543
1595
|
{
|
|
1544
1596
|
id: 'a11y-open-context-menu',
|
|
1545
1597
|
kbd: 'cmd+shift+Enter,ctrl+shift+Enter',
|
|
1598
|
+
isRequiredA11yAction: true,
|
|
1546
1599
|
readonlyOk: true,
|
|
1547
1600
|
onSelect: async (source) => {
|
|
1548
1601
|
if (!canApplySelectionAction()) return
|
|
@@ -1595,6 +1648,7 @@ export function ActionsProvider({ overrides, children }: ActionsProviderProps) {
|
|
|
1595
1648
|
id: 'a11y-repeat-shape-announce',
|
|
1596
1649
|
kbd: 'alt+r',
|
|
1597
1650
|
label: 'a11y.repeat-shape',
|
|
1651
|
+
isRequiredA11yAction: true,
|
|
1598
1652
|
readonlyOk: true,
|
|
1599
1653
|
onSelect: async (source) => {
|
|
1600
1654
|
const selectedShapeIds = editor.getSelectedShapeIds()
|
|
@@ -1705,7 +1759,17 @@ export function ActionsProvider({ overrides, children }: ActionsProviderProps) {
|
|
|
1705
1759
|
}
|
|
1706
1760
|
|
|
1707
1761
|
return actions
|
|
1708
|
-
}, [
|
|
1762
|
+
}, [
|
|
1763
|
+
helpers,
|
|
1764
|
+
_editor,
|
|
1765
|
+
trackEvent,
|
|
1766
|
+
overrides,
|
|
1767
|
+
defaultDocumentName,
|
|
1768
|
+
showCollaborationUi,
|
|
1769
|
+
msg,
|
|
1770
|
+
a11y,
|
|
1771
|
+
components,
|
|
1772
|
+
])
|
|
1709
1773
|
|
|
1710
1774
|
return <ActionsContext.Provider value={asActions(actions)}>{children}</ActionsContext.Provider>
|
|
1711
1775
|
}
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
import { CursorChatBubble } from '../components/CursorChatBubble'
|
|
13
13
|
import { DefaultDebugMenu } from '../components/DebugMenu/DefaultDebugMenu'
|
|
14
14
|
import { DefaultDebugPanel } from '../components/DefaultDebugPanel'
|
|
15
|
+
import { DefaultFollowingIndicator } from '../components/DefaultFollowingIndicator'
|
|
15
16
|
import { DefaultMenuPanel } from '../components/DefaultMenuPanel'
|
|
16
17
|
import { DefaultDialogs } from '../components/Dialogs'
|
|
17
18
|
import { TLUiHelpMenuProps } from '../components/HelpMenu/DefaultHelpMenu'
|
|
@@ -72,6 +73,7 @@ export interface TLUiComponents {
|
|
|
72
73
|
Dialogs?: ComponentType | null
|
|
73
74
|
Toasts?: ComponentType | null
|
|
74
75
|
A11y?: ComponentType | null
|
|
76
|
+
FollowingIndicator?: ComponentType | null
|
|
75
77
|
}
|
|
76
78
|
|
|
77
79
|
const TldrawUiComponentsContext = createContext<TLUiComponents | null>(null)
|
|
@@ -119,6 +121,7 @@ export function TldrawUiComponentsProvider({
|
|
|
119
121
|
Dialogs: DefaultDialogs,
|
|
120
122
|
Toasts: DefaultToasts,
|
|
121
123
|
A11y: DefaultA11yAnnouncer,
|
|
124
|
+
FollowingIndicator: DefaultFollowingIndicator,
|
|
122
125
|
..._overrides,
|
|
123
126
|
}),
|
|
124
127
|
[_overrides, showCollaborationUi]
|