tldraw 3.16.0-canary.ffdf566dd0a8 → 3.16.0-internal.a478398270c6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-cjs/index.d.ts +19 -125
- package/dist-cjs/index.js +2 -19
- package/dist-cjs/index.js.map +2 -2
- package/dist-cjs/lib/TldrawImage.js +2 -5
- package/dist-cjs/lib/TldrawImage.js.map +3 -3
- package/dist-cjs/lib/canvas/TldrawCropHandles.js +1 -1
- package/dist-cjs/lib/canvas/TldrawCropHandles.js.map +2 -2
- package/dist-cjs/lib/canvas/TldrawHandles.js +1 -1
- package/dist-cjs/lib/canvas/TldrawHandles.js.map +2 -2
- package/dist-cjs/lib/canvas/TldrawOverlays.js +1 -1
- package/dist-cjs/lib/canvas/TldrawOverlays.js.map +2 -2
- package/dist-cjs/lib/canvas/TldrawSelectionForeground.js +271 -279
- package/dist-cjs/lib/canvas/TldrawSelectionForeground.js.map +2 -2
- package/dist-cjs/lib/defaultExternalContentHandlers.js +0 -1
- package/dist-cjs/lib/defaultExternalContentHandlers.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js +41 -24
- package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/arrowLabel.js +4 -16
- package/dist-cjs/lib/shapes/arrow/arrowLabel.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/arrowTargetState.js +1 -1
- package/dist-cjs/lib/shapes/arrow/arrowTargetState.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.js +0 -3
- package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/shapes/draw/DrawShapeUtil.js +3 -0
- package/dist-cjs/lib/shapes/draw/DrawShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js +5 -5
- package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/highlight/HighlightShapeUtil.js +3 -0
- package/dist-cjs/lib/shapes/highlight/HighlightShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/line/LineShapeUtil.js +4 -15
- package/dist-cjs/lib/shapes/line/LineShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/note/NoteShapeUtil.js +1 -2
- package/dist-cjs/lib/shapes/note/NoteShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/PathBuilder.js +3 -21
- package/dist-cjs/lib/shapes/shared/PathBuilder.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/PlainTextLabel.js +0 -1
- package/dist-cjs/lib/shapes/shared/PlainTextLabel.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/RichTextLabel.js +2 -5
- package/dist-cjs/lib/shapes/shared/RichTextLabel.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/SvgTextLabel.js +3 -4
- package/dist-cjs/lib/shapes/shared/SvgTextLabel.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/usePrefersReducedMotion.js +1 -10
- package/dist-cjs/lib/shapes/shared/usePrefersReducedMotion.js.map +2 -2
- package/dist-cjs/lib/shapes/text/TextShapeUtil.js +11 -5
- package/dist-cjs/lib/shapes/text/TextShapeUtil.js.map +2 -2
- package/dist-cjs/lib/styles.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.js +1 -7
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js +22 -43
- package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Idle.js +15 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Idle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingShape.js +0 -5
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingShape.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js +0 -8
- package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Rotating.js +0 -8
- package/dist-cjs/lib/tools/SelectTool/childStates/Rotating.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js +0 -8
- package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js.map +2 -2
- package/dist-cjs/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.js.map +2 -2
- package/dist-cjs/lib/ui/assetUrls.js +13 -10
- package/dist-cjs/lib/ui/assetUrls.js.map +2 -2
- package/dist-cjs/lib/ui/components/A11y.js +12 -14
- package/dist-cjs/lib/ui/components/A11y.js.map +2 -2
- package/dist-cjs/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.js +1 -51
- package/dist-cjs/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.js.map +2 -2
- package/dist-cjs/lib/ui/components/MainMenu/DefaultMainMenuContent.js +2 -3
- package/dist-cjs/lib/ui/components/MainMenu/DefaultMainMenuContent.js.map +2 -2
- package/dist-cjs/lib/ui/components/NavigationPanel/DefaultNavigationPanel.js +4 -3
- package/dist-cjs/lib/ui/components/NavigationPanel/DefaultNavigationPanel.js.map +2 -2
- package/dist-cjs/lib/ui/components/Spinner.js +25 -2
- package/dist-cjs/lib/ui/components/Spinner.js.map +2 -2
- package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanel.js +0 -2
- package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanel.js.map +2 -2
- package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanelContent.js +136 -168
- package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanelContent.js.map +2 -2
- package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbar.js +7 -21
- package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbar.js.map +3 -3
- package/dist-cjs/lib/ui/components/Toolbar/OverflowingToolbar.js +3 -3
- package/dist-cjs/lib/ui/components/Toolbar/OverflowingToolbar.js.map +2 -2
- package/dist-cjs/lib/ui/components/Toolbar/ToggleToolLockedButton.js +2 -3
- package/dist-cjs/lib/ui/components/Toolbar/ToggleToolLockedButton.js.map +2 -2
- package/dist-cjs/lib/ui/components/menu-items.js +0 -22
- package/dist-cjs/lib/ui/components/menu-items.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/Button/TldrawUiButtonIcon.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiButtonPicker.js +0 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiButtonPicker.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiDialog.js +1 -1
- package/dist-cjs/lib/ui/components/primitives/TldrawUiDialog.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiIcon.js +1 -35
- package/dist-cjs/lib/ui/components/primitives/TldrawUiIcon.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiSlider.js +2 -6
- package/dist-cjs/lib/ui/components/primitives/TldrawUiSlider.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiToolbar.js +3 -12
- package/dist-cjs/lib/ui/components/primitives/TldrawUiToolbar.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuCheckboxItem.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js +2 -0
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js.map +2 -2
- package/dist-cjs/lib/ui/context/TldrawUiContextProvider.js +2 -3
- package/dist-cjs/lib/ui/context/TldrawUiContextProvider.js.map +2 -2
- package/dist-cjs/lib/ui/context/actions.js +8 -57
- package/dist-cjs/lib/ui/context/actions.js.map +2 -2
- package/dist-cjs/lib/ui/context/events.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/menu-hooks.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/useKeyboardShortcuts.js +2 -2
- package/dist-cjs/lib/ui/hooks/useKeyboardShortcuts.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/useTools.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/useTranslation/TLUiTranslationKey.js.map +1 -1
- package/dist-cjs/lib/ui/hooks/useTranslation/defaultTranslation.js +0 -11
- package/dist-cjs/lib/ui/hooks/useTranslation/defaultTranslation.js.map +2 -2
- package/dist-cjs/lib/ui/kbd-utils.js +1 -2
- package/dist-cjs/lib/ui/kbd-utils.js.map +2 -2
- package/dist-cjs/lib/ui/version.js +3 -3
- package/dist-cjs/lib/ui/version.js.map +1 -1
- package/dist-cjs/lib/utils/excalidraw/putExcalidrawContent.js +1 -1
- package/dist-cjs/lib/utils/excalidraw/putExcalidrawContent.js.map +2 -2
- package/dist-cjs/lib/utils/tldr/buildFromV1Document.js +2 -3
- package/dist-cjs/lib/utils/tldr/buildFromV1Document.js.map +2 -2
- package/dist-esm/index.d.mts +19 -125
- package/dist-esm/index.mjs +4 -33
- package/dist-esm/index.mjs.map +2 -2
- package/dist-esm/lib/TldrawImage.mjs +2 -5
- package/dist-esm/lib/TldrawImage.mjs.map +2 -2
- package/dist-esm/lib/canvas/TldrawCropHandles.mjs +1 -1
- package/dist-esm/lib/canvas/TldrawCropHandles.mjs.map +2 -2
- package/dist-esm/lib/canvas/TldrawHandles.mjs +1 -1
- package/dist-esm/lib/canvas/TldrawHandles.mjs.map +2 -2
- package/dist-esm/lib/canvas/TldrawOverlays.mjs +1 -1
- package/dist-esm/lib/canvas/TldrawOverlays.mjs.map +2 -2
- package/dist-esm/lib/canvas/TldrawSelectionForeground.mjs +271 -279
- package/dist-esm/lib/canvas/TldrawSelectionForeground.mjs.map +2 -2
- package/dist-esm/lib/defaultExternalContentHandlers.mjs +0 -1
- package/dist-esm/lib/defaultExternalContentHandlers.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs +41 -26
- package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/arrowLabel.mjs +5 -19
- package/dist-esm/lib/shapes/arrow/arrowLabel.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/arrowTargetState.mjs +1 -1
- package/dist-esm/lib/shapes/arrow/arrowTargetState.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs +0 -3
- package/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/shapes/draw/DrawShapeUtil.mjs +3 -0
- package/dist-esm/lib/shapes/draw/DrawShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs +5 -5
- package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/highlight/HighlightShapeUtil.mjs +3 -0
- package/dist-esm/lib/shapes/highlight/HighlightShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/line/LineShapeUtil.mjs +4 -15
- package/dist-esm/lib/shapes/line/LineShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs +1 -2
- package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/PathBuilder.mjs +3 -22
- package/dist-esm/lib/shapes/shared/PathBuilder.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/PlainTextLabel.mjs +0 -1
- package/dist-esm/lib/shapes/shared/PlainTextLabel.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/RichTextLabel.mjs +2 -5
- package/dist-esm/lib/shapes/shared/RichTextLabel.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/SvgTextLabel.mjs +3 -4
- package/dist-esm/lib/shapes/shared/SvgTextLabel.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/usePrefersReducedMotion.mjs +1 -10
- package/dist-esm/lib/shapes/shared/usePrefersReducedMotion.mjs.map +2 -2
- package/dist-esm/lib/shapes/text/TextShapeUtil.mjs +11 -5
- package/dist-esm/lib/shapes/text/TextShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/styles.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.mjs +1 -7
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs +22 -43
- package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Idle.mjs +15 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Idle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingShape.mjs +0 -5
- package/dist-esm/lib/tools/SelectTool/childStates/PointingShape.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs +0 -8
- package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Rotating.mjs +0 -8
- package/dist-esm/lib/tools/SelectTool/childStates/Rotating.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs +0 -8
- package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs.map +2 -2
- package/dist-esm/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.mjs.map +2 -2
- package/dist-esm/lib/ui/assetUrls.mjs +13 -10
- package/dist-esm/lib/ui/assetUrls.mjs.map +2 -2
- package/dist-esm/lib/ui/components/A11y.mjs +12 -14
- package/dist-esm/lib/ui/components/A11y.mjs.map +2 -2
- package/dist-esm/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.mjs +1 -51
- package/dist-esm/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.mjs.map +2 -2
- package/dist-esm/lib/ui/components/MainMenu/DefaultMainMenuContent.mjs +3 -3
- package/dist-esm/lib/ui/components/MainMenu/DefaultMainMenuContent.mjs.map +2 -2
- package/dist-esm/lib/ui/components/NavigationPanel/DefaultNavigationPanel.mjs +4 -3
- package/dist-esm/lib/ui/components/NavigationPanel/DefaultNavigationPanel.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Spinner.mjs +26 -3
- package/dist-esm/lib/ui/components/Spinner.mjs.map +2 -2
- package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanel.mjs +1 -3
- package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanel.mjs.map +2 -2
- package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanelContent.mjs +136 -168
- package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanelContent.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbar.mjs +9 -23
- package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbar.mjs.map +3 -3
- package/dist-esm/lib/ui/components/Toolbar/OverflowingToolbar.mjs +3 -3
- package/dist-esm/lib/ui/components/Toolbar/OverflowingToolbar.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Toolbar/ToggleToolLockedButton.mjs +2 -3
- package/dist-esm/lib/ui/components/Toolbar/ToggleToolLockedButton.mjs.map +2 -2
- package/dist-esm/lib/ui/components/menu-items.mjs +0 -22
- package/dist-esm/lib/ui/components/menu-items.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/Button/TldrawUiButtonIcon.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiButtonPicker.mjs +0 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiButtonPicker.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiDialog.mjs +1 -1
- package/dist-esm/lib/ui/components/primitives/TldrawUiDialog.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiIcon.mjs +2 -36
- package/dist-esm/lib/ui/components/primitives/TldrawUiIcon.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiSlider.mjs +2 -6
- package/dist-esm/lib/ui/components/primitives/TldrawUiSlider.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiToolbar.mjs +3 -12
- package/dist-esm/lib/ui/components/primitives/TldrawUiToolbar.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuCheckboxItem.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs +2 -0
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs.map +2 -2
- package/dist-esm/lib/ui/context/TldrawUiContextProvider.mjs +2 -3
- package/dist-esm/lib/ui/context/TldrawUiContextProvider.mjs.map +2 -2
- package/dist-esm/lib/ui/context/actions.mjs +8 -57
- package/dist-esm/lib/ui/context/actions.mjs.map +2 -2
- package/dist-esm/lib/ui/context/events.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/menu-hooks.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/useKeyboardShortcuts.mjs +2 -2
- package/dist-esm/lib/ui/hooks/useKeyboardShortcuts.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/useTools.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/useTranslation/defaultTranslation.mjs +0 -11
- package/dist-esm/lib/ui/hooks/useTranslation/defaultTranslation.mjs.map +2 -2
- package/dist-esm/lib/ui/kbd-utils.mjs +1 -2
- package/dist-esm/lib/ui/kbd-utils.mjs.map +2 -2
- package/dist-esm/lib/ui/version.mjs +3 -3
- package/dist-esm/lib/ui/version.mjs.map +1 -1
- package/dist-esm/lib/utils/excalidraw/putExcalidrawContent.mjs +1 -1
- package/dist-esm/lib/utils/excalidraw/putExcalidrawContent.mjs.map +2 -2
- package/dist-esm/lib/utils/tldr/buildFromV1Document.mjs +2 -3
- package/dist-esm/lib/utils/tldr/buildFromV1Document.mjs.map +2 -2
- package/package.json +3 -4
- package/src/index.ts +2 -24
- package/src/lib/TldrawImage.tsx +2 -6
- package/src/lib/canvas/TldrawCropHandles.tsx +1 -3
- package/src/lib/canvas/TldrawHandles.tsx +1 -5
- package/src/lib/canvas/TldrawOverlays.tsx +1 -1
- package/src/lib/canvas/TldrawSelectionForeground.tsx +1 -5
- package/src/lib/defaultExternalContentHandlers.ts +1 -2
- package/src/lib/shapes/arrow/ArrowShapeUtil.test.ts +5 -5
- package/src/lib/shapes/arrow/ArrowShapeUtil.tsx +43 -26
- package/src/lib/shapes/arrow/arrowLabel.ts +3 -23
- package/src/lib/shapes/arrow/arrowTargetState.ts +1 -2
- package/src/lib/shapes/arrow/toolStates/Pointing.tsx +0 -3
- package/src/lib/shapes/draw/DrawShapeUtil.tsx +4 -0
- package/src/lib/shapes/frame/FrameShapeUtil.tsx +7 -5
- package/src/lib/shapes/highlight/HighlightShapeUtil.tsx +3 -0
- package/src/lib/shapes/line/LineShapeUtil.tsx +5 -19
- package/src/lib/shapes/note/NoteShapeUtil.tsx +0 -1
- package/src/lib/shapes/shared/PathBuilder.test.tsx +1 -1
- package/src/lib/shapes/shared/PathBuilder.tsx +1 -35
- package/src/lib/shapes/shared/PlainTextLabel.tsx +0 -1
- package/src/lib/shapes/shared/RichTextLabel.tsx +0 -4
- package/src/lib/shapes/shared/SvgTextLabel.tsx +2 -4
- package/src/lib/shapes/shared/usePrefersReducedMotion.tsx +1 -11
- package/src/lib/shapes/text/TextShapeUtil.tsx +12 -5
- package/src/lib/styles.tsx +1 -3
- package/src/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.ts +1 -8
- package/src/lib/tools/SelectTool/childStates/DraggingHandle.tsx +30 -54
- package/src/lib/tools/SelectTool/childStates/Idle.ts +24 -2
- package/src/lib/tools/SelectTool/childStates/PointingShape.ts +0 -7
- package/src/lib/tools/SelectTool/childStates/Resizing.ts +1 -12
- package/src/lib/tools/SelectTool/childStates/Rotating.ts +0 -11
- package/src/lib/tools/SelectTool/childStates/Translating.ts +0 -11
- package/src/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.ts +0 -1
- package/src/lib/ui/assetUrls.ts +13 -10
- package/src/lib/ui/components/A11y.tsx +13 -15
- package/src/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.tsx +0 -40
- package/src/lib/ui/components/MainMenu/DefaultMainMenuContent.tsx +2 -4
- package/src/lib/ui/components/NavigationPanel/DefaultNavigationPanel.tsx +4 -3
- package/src/lib/ui/components/Spinner.tsx +24 -2
- package/src/lib/ui/components/StylePanel/DefaultStylePanel.tsx +1 -3
- package/src/lib/ui/components/StylePanel/DefaultStylePanelContent.tsx +127 -171
- package/src/lib/ui/components/Toolbar/DefaultImageToolbar.tsx +9 -25
- package/src/lib/ui/components/Toolbar/OverflowingToolbar.tsx +3 -3
- package/src/lib/ui/components/Toolbar/ToggleToolLockedButton.tsx +12 -17
- package/src/lib/ui/components/menu-items.tsx +0 -25
- package/src/lib/ui/components/primitives/Button/TldrawUiButtonIcon.tsx +2 -2
- package/src/lib/ui/components/primitives/TldrawUiButtonPicker.tsx +0 -2
- package/src/lib/ui/components/primitives/TldrawUiDialog.tsx +1 -1
- package/src/lib/ui/components/primitives/TldrawUiIcon.tsx +3 -41
- package/src/lib/ui/components/primitives/TldrawUiSlider.tsx +1 -6
- package/src/lib/ui/components/primitives/TldrawUiToolbar.tsx +3 -24
- package/src/lib/ui/components/primitives/menus/TldrawUiMenuCheckboxItem.tsx +2 -2
- package/src/lib/ui/components/primitives/menus/TldrawUiMenuItem.tsx +4 -3
- package/src/lib/ui/context/TldrawUiContextProvider.tsx +20 -23
- package/src/lib/ui/context/actions.tsx +9 -59
- package/src/lib/ui/context/events.tsx +2 -5
- package/src/lib/ui/hooks/menu-hooks.ts +0 -1
- package/src/lib/ui/hooks/useKeyboardShortcuts.ts +2 -3
- package/src/lib/ui/hooks/useTools.tsx +1 -2
- package/src/lib/ui/hooks/useTranslation/TLUiTranslationKey.ts +0 -11
- package/src/lib/ui/hooks/useTranslation/defaultTranslation.ts +0 -11
- package/src/lib/ui/kbd-utils.ts +1 -2
- package/src/lib/ui/version.ts +3 -3
- package/src/lib/ui.css +23 -65
- package/src/lib/utils/excalidraw/__snapshots__/putExcalidrawContent.test.tsx.snap +2 -16
- package/src/lib/utils/excalidraw/putExcalidrawContent.ts +1 -1
- package/src/lib/utils/tldr/__snapshots__/buildFromV1Document.test.ts.snap +3 -24
- package/src/lib/utils/tldr/buildFromV1Document.ts +1 -2
- package/src/test/Editor.test.tsx +1 -1
- package/src/test/SelectTool.test.ts +11 -37
- package/src/test/arrows-megabus.test.tsx +6 -12
- package/src/test/commands/__snapshots__/getSvgString.test.ts.snap +2 -2
- package/src/test/commands/deletePage.test.ts +1 -84
- package/src/test/groups.test.tsx +1 -1
- package/src/test/navigation.test.ts +0 -254
- package/src/test/shapeutils.test.ts +45 -394
- package/src/test/translating.test.ts +1 -1
- package/tldraw.css +50 -88
- package/dist-cjs/lib/ui/components/AccessibilityMenu.js +0 -35
- package/dist-cjs/lib/ui/components/AccessibilityMenu.js.map +0 -7
- package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js +0 -267
- package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js.map +0 -7
- package/dist-esm/lib/ui/components/AccessibilityMenu.mjs +0 -19
- package/dist-esm/lib/ui/components/AccessibilityMenu.mjs.map +0 -7
- package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs +0 -237
- package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs.map +0 -7
- package/src/lib/ui/components/AccessibilityMenu.tsx +0 -20
- package/src/lib/ui/components/primitives/TldrawUiTooltip.tsx +0 -313
- package/src/test/inner-outer-margin.test.ts +0 -315
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import classNames from "classnames";
|
|
3
|
-
import {
|
|
3
|
+
import { memo, useLayoutEffect, useRef } from "react";
|
|
4
4
|
import { useAssetUrls } from "../../context/asset-urls.mjs";
|
|
5
5
|
const TldrawUiIcon = memo(function TldrawUiIcon2({
|
|
6
6
|
label,
|
|
@@ -10,40 +10,6 @@ const TldrawUiIcon = memo(function TldrawUiIcon2({
|
|
|
10
10
|
color,
|
|
11
11
|
className,
|
|
12
12
|
...props
|
|
13
|
-
}) {
|
|
14
|
-
if (typeof icon === "string") {
|
|
15
|
-
return /* @__PURE__ */ jsx(
|
|
16
|
-
TldrawUIIconInner,
|
|
17
|
-
{
|
|
18
|
-
label,
|
|
19
|
-
small,
|
|
20
|
-
invertIcon,
|
|
21
|
-
icon,
|
|
22
|
-
color,
|
|
23
|
-
className,
|
|
24
|
-
...props
|
|
25
|
-
}
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
return cloneElement(icon, {
|
|
29
|
-
...props,
|
|
30
|
-
className: classNames({ "tlui-icon__small": small }, className, icon.props.className),
|
|
31
|
-
"aria-label": label,
|
|
32
|
-
style: {
|
|
33
|
-
color,
|
|
34
|
-
transform: invertIcon ? "scale(-1, 1)" : void 0,
|
|
35
|
-
...icon.props.style
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
function TldrawUIIconInner({
|
|
40
|
-
label,
|
|
41
|
-
small,
|
|
42
|
-
invertIcon,
|
|
43
|
-
icon,
|
|
44
|
-
color,
|
|
45
|
-
className,
|
|
46
|
-
...props
|
|
47
13
|
}) {
|
|
48
14
|
const assetUrls = useAssetUrls();
|
|
49
15
|
const asset = assetUrls.icons[icon] ?? assetUrls.icons["question-mark-circle"];
|
|
@@ -84,7 +50,7 @@ function TldrawUIIconInner({
|
|
|
84
50
|
}
|
|
85
51
|
}
|
|
86
52
|
);
|
|
87
|
-
}
|
|
53
|
+
});
|
|
88
54
|
export {
|
|
89
55
|
TldrawUiIcon
|
|
90
56
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/lib/ui/components/primitives/TldrawUiIcon.tsx"],
|
|
4
|
-
"sourcesContent": ["import classNames from 'classnames'\nimport {
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import classNames from 'classnames'\nimport { memo, useLayoutEffect, useRef } from 'react'\nimport { useAssetUrls } from '../../context/asset-urls'\nimport { TLUiIconType } from '../../icon-types'\n\n/** @public */\nexport interface TLUiIconProps extends React.HTMLAttributes<HTMLDivElement> {\n\ticon: TLUiIconType | Exclude<string, TLUiIconType>\n\tlabel: string\n\tsmall?: boolean\n\tcolor?: string\n\tchildren?: undefined\n\tinvertIcon?: boolean\n\tcrossOrigin?: 'anonymous' | 'use-credentials'\n}\n\n/** @public @react */\nexport const TldrawUiIcon = memo(function TldrawUiIcon({\n\tlabel,\n\tsmall,\n\tinvertIcon,\n\ticon,\n\tcolor,\n\tclassName,\n\t...props\n}: TLUiIconProps) {\n\tconst assetUrls = useAssetUrls()\n\tconst asset = assetUrls.icons[icon as TLUiIconType] ?? assetUrls.icons['question-mark-circle']\n\tconst ref = useRef<HTMLDivElement>(null)\n\n\tuseLayoutEffect(() => {\n\t\tif (!asset) {\n\t\t\tconsole.error(`Icon not found: ${icon}. Add it to the assetUrls.icons object.`)\n\t\t}\n\n\t\tif (ref?.current) {\n\t\t\t// HACK: Fix for <https://linear.app/tldraw/issue/TLD-1700/dragging-around-with-the-handtool-makes-lots-of-requests-for-icons>\n\t\t\t// It seems that passing `WebkitMask` to react will cause a render on each call, no idea why... but this appears to be the fix.\n\t\t\t// @ts-ignore\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-deprecated\n\t\t\tref.current.style.webkitMask = `url(${asset}) center 100% / 100% no-repeat`\n\t\t}\n\t}, [ref, asset, icon])\n\n\tif (icon === 'none') {\n\t\treturn (\n\t\t\t<div\n\t\t\t\tclassName={classNames(\n\t\t\t\t\t'tlui-icon tlui-icon__placeholder',\n\t\t\t\t\t{ 'tlui-icon__small': small },\n\t\t\t\t\tclassName\n\t\t\t\t)}\n\t\t\t\t{...props}\n\t\t\t/>\n\t\t)\n\t}\n\n\treturn (\n\t\t<div\n\t\t\t{...props}\n\t\t\tref={ref}\n\t\t\taria-label={label}\n\t\t\trole=\"img\"\n\t\t\tclassName={classNames('tlui-icon', { 'tlui-icon__small': small }, className)}\n\t\t\tstyle={{\n\t\t\t\tcolor,\n\t\t\t\tmask: `url(${asset}) center 100% / 100% no-repeat`,\n\t\t\t\ttransform: invertIcon ? 'scale(-1, 1)' : undefined,\n\t\t\t}}\n\t\t/>\n\t)\n})\n"],
|
|
5
|
+
"mappings": "AA8CG;AA9CH,OAAO,gBAAgB;AACvB,SAAS,MAAM,iBAAiB,cAAc;AAC9C,SAAS,oBAAoB;AAetB,MAAM,eAAe,KAAK,SAASA,cAAa;AAAA,EACtD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACJ,GAAkB;AACjB,QAAM,YAAY,aAAa;AAC/B,QAAM,QAAQ,UAAU,MAAM,IAAoB,KAAK,UAAU,MAAM,sBAAsB;AAC7F,QAAM,MAAM,OAAuB,IAAI;AAEvC,kBAAgB,MAAM;AACrB,QAAI,CAAC,OAAO;AACX,cAAQ,MAAM,mBAAmB,IAAI,yCAAyC;AAAA,IAC/E;AAEA,QAAI,KAAK,SAAS;AAKjB,UAAI,QAAQ,MAAM,aAAa,OAAO,KAAK;AAAA,IAC5C;AAAA,EACD,GAAG,CAAC,KAAK,OAAO,IAAI,CAAC;AAErB,MAAI,SAAS,QAAQ;AACpB,WACC;AAAA,MAAC;AAAA;AAAA,QACA,WAAW;AAAA,UACV;AAAA,UACA,EAAE,oBAAoB,MAAM;AAAA,UAC5B;AAAA,QACD;AAAA,QACC,GAAG;AAAA;AAAA,IACL;AAAA,EAEF;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACC,GAAG;AAAA,MACJ;AAAA,MACA,cAAY;AAAA,MACZ,MAAK;AAAA,MACL,WAAW,WAAW,aAAa,EAAE,oBAAoB,MAAM,GAAG,SAAS;AAAA,MAC3E,OAAO;AAAA,QACN;AAAA,QACA,MAAM,OAAO,KAAK;AAAA,QAClB,WAAW,aAAa,iBAAiB;AAAA,MAC1C;AAAA;AAAA,EACD;AAEF,CAAC;",
|
|
6
6
|
"names": ["TldrawUiIcon"]
|
|
7
7
|
}
|
|
@@ -10,8 +10,7 @@ const TldrawUiSlider = React.forwardRef(function Slider({
|
|
|
10
10
|
value,
|
|
11
11
|
label,
|
|
12
12
|
onValueChange,
|
|
13
|
-
["data-testid"]: testId
|
|
14
|
-
ariaValueModifier = 1
|
|
13
|
+
["data-testid"]: testId
|
|
15
14
|
}, ref) {
|
|
16
15
|
const msg = useTranslation();
|
|
17
16
|
const [tabIndex, setTabIndex] = useState(-1);
|
|
@@ -52,10 +51,7 @@ const TldrawUiSlider = React.forwardRef(function Slider({
|
|
|
52
51
|
value !== null && /* @__PURE__ */ jsx(
|
|
53
52
|
_Slider.Thumb,
|
|
54
53
|
{
|
|
55
|
-
"aria-
|
|
56
|
-
"aria-valuenow": value * ariaValueModifier,
|
|
57
|
-
"aria-valuemax": steps * ariaValueModifier,
|
|
58
|
-
"aria-label": title + " \u2014 " + msg(label),
|
|
54
|
+
"aria-label": msg("style-panel.opacity"),
|
|
59
55
|
className: "tlui-slider__thumb",
|
|
60
56
|
dir: "ltr",
|
|
61
57
|
ref,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/lib/ui/components/primitives/TldrawUiSlider.tsx"],
|
|
4
|
-
"sourcesContent": ["import { Slider as _Slider } from 'radix-ui'\nimport React, { useCallback, useEffect, useState } from 'react'\nimport { TLUiTranslationKey } from '../../hooks/useTranslation/TLUiTranslationKey'\nimport { useTranslation } from '../../hooks/useTranslation/useTranslation'\n\n/** @public */\nexport interface TLUiSliderProps {\n\tmin?: number\n\tsteps: number\n\tvalue: number | null\n\tlabel: string\n\ttitle: string\n\tonValueChange(value: number): void\n\tonHistoryMark(id: string): void\n\t'data-testid'?: string\n
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import { Slider as _Slider } from 'radix-ui'\nimport React, { useCallback, useEffect, useState } from 'react'\nimport { TLUiTranslationKey } from '../../hooks/useTranslation/TLUiTranslationKey'\nimport { useTranslation } from '../../hooks/useTranslation/useTranslation'\n\n/** @public */\nexport interface TLUiSliderProps {\n\tmin?: number\n\tsteps: number\n\tvalue: number | null\n\tlabel: string\n\ttitle: string\n\tonValueChange(value: number): void\n\tonHistoryMark(id: string): void\n\t'data-testid'?: string\n}\n\n/** @public @react */\nexport const TldrawUiSlider = React.forwardRef<HTMLDivElement, TLUiSliderProps>(function Slider(\n\t{\n\t\tonHistoryMark,\n\t\ttitle,\n\t\tmin,\n\t\tsteps,\n\t\tvalue,\n\t\tlabel,\n\t\tonValueChange,\n\t\t['data-testid']: testId,\n\t}: TLUiSliderProps,\n\tref\n) {\n\tconst msg = useTranslation()\n\n\t// XXX: Radix starts out our slider with a tabIndex of 0\n\t// This causes some tab focusing issues, most prevelant in MobileStylePanel,\n\t// where it grabs the focus. This works around it.\n\tconst [tabIndex, setTabIndex] = useState(-1)\n\tuseEffect(() => {\n\t\tsetTabIndex(0)\n\t}, [])\n\n\tconst handleValueChange = useCallback(\n\t\t(value: number[]) => {\n\t\t\tonValueChange(value[0])\n\t\t},\n\t\t[onValueChange]\n\t)\n\n\tconst handlePointerDown = useCallback(() => {\n\t\tonHistoryMark('click slider')\n\t}, [onHistoryMark])\n\n\t// N.B. Annoying. For a11y purposes, we need Tab to work.\n\t// For some reason, Radix has some custom behavior here\n\t// that interferes with tabbing past the slider and then\n\t// you get stuck in the slider.\n\tconst handleKeyEvent = useCallback((event: React.KeyboardEvent) => {\n\t\tif (event.key === 'Tab') {\n\t\t\tevent.stopPropagation()\n\t\t}\n\t}, [])\n\n\treturn (\n\t\t<div className=\"tlui-slider__container\">\n\t\t\t<_Slider.Root\n\t\t\t\tdata-testid={testId}\n\t\t\t\tclassName=\"tlui-slider\"\n\t\t\t\tdir=\"ltr\"\n\t\t\t\tmin={min ?? 0}\n\t\t\t\tmax={steps}\n\t\t\t\tstep={1}\n\t\t\t\tvalue={value !== null ? [value] : undefined}\n\t\t\t\tonPointerDown={handlePointerDown}\n\t\t\t\tonValueChange={handleValueChange}\n\t\t\t\tonKeyDownCapture={handleKeyEvent}\n\t\t\t\tonKeyUpCapture={handleKeyEvent}\n\t\t\t\ttitle={title + ' \u2014 ' + msg(label as TLUiTranslationKey)}\n\t\t\t>\n\t\t\t\t<_Slider.Track className=\"tlui-slider__track\" dir=\"ltr\">\n\t\t\t\t\t{value !== null && <_Slider.Range className=\"tlui-slider__range\" dir=\"ltr\" />}\n\t\t\t\t</_Slider.Track>\n\t\t\t\t{value !== null && (\n\t\t\t\t\t<_Slider.Thumb\n\t\t\t\t\t\taria-label={msg('style-panel.opacity')}\n\t\t\t\t\t\tclassName=\"tlui-slider__thumb\"\n\t\t\t\t\t\tdir=\"ltr\"\n\t\t\t\t\t\tref={ref}\n\t\t\t\t\t\ttabIndex={tabIndex}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t</_Slider.Root>\n\t\t</div>\n\t)\n})\n"],
|
|
5
|
+
"mappings": "AAgEG,SAeqB,KAfrB;AAhEH,SAAS,UAAU,eAAe;AAClC,OAAO,SAAS,aAAa,WAAW,gBAAgB;AAExD,SAAS,sBAAsB;AAexB,MAAM,iBAAiB,MAAM,WAA4C,SAAS,OACxF;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,CAAC,aAAa,GAAG;AAClB,GACA,KACC;AACD,QAAM,MAAM,eAAe;AAK3B,QAAM,CAAC,UAAU,WAAW,IAAI,SAAS,EAAE;AAC3C,YAAU,MAAM;AACf,gBAAY,CAAC;AAAA,EACd,GAAG,CAAC,CAAC;AAEL,QAAM,oBAAoB;AAAA,IACzB,CAACA,WAAoB;AACpB,oBAAcA,OAAM,CAAC,CAAC;AAAA,IACvB;AAAA,IACA,CAAC,aAAa;AAAA,EACf;AAEA,QAAM,oBAAoB,YAAY,MAAM;AAC3C,kBAAc,cAAc;AAAA,EAC7B,GAAG,CAAC,aAAa,CAAC;AAMlB,QAAM,iBAAiB,YAAY,CAAC,UAA+B;AAClE,QAAI,MAAM,QAAQ,OAAO;AACxB,YAAM,gBAAgB;AAAA,IACvB;AAAA,EACD,GAAG,CAAC,CAAC;AAEL,SACC,oBAAC,SAAI,WAAU,0BACd;AAAA,IAAC,QAAQ;AAAA,IAAR;AAAA,MACA,eAAa;AAAA,MACb,WAAU;AAAA,MACV,KAAI;AAAA,MACJ,KAAK,OAAO;AAAA,MACZ,KAAK;AAAA,MACL,MAAM;AAAA,MACN,OAAO,UAAU,OAAO,CAAC,KAAK,IAAI;AAAA,MAClC,eAAe;AAAA,MACf,eAAe;AAAA,MACf,kBAAkB;AAAA,MAClB,gBAAgB;AAAA,MAChB,OAAO,QAAQ,aAAQ,IAAI,KAA2B;AAAA,MAEtD;AAAA,4BAAC,QAAQ,OAAR,EAAc,WAAU,sBAAqB,KAAI,OAChD,oBAAU,QAAQ,oBAAC,QAAQ,OAAR,EAAc,WAAU,sBAAqB,KAAI,OAAM,GAC5E;AAAA,QACC,UAAU,QACV;AAAA,UAAC,QAAQ;AAAA,UAAR;AAAA,YACA,cAAY,IAAI,qBAAqB;AAAA,YACrC,WAAU;AAAA,YACV,KAAI;AAAA,YACJ;AAAA,YACA;AAAA;AAAA,QACD;AAAA;AAAA;AAAA,EAEF,GACD;AAEF,CAAC;",
|
|
6
6
|
"names": ["value"]
|
|
7
7
|
}
|
|
@@ -2,7 +2,6 @@ import { jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import classnames from "classnames";
|
|
3
3
|
import { Toolbar as _Toolbar } from "radix-ui";
|
|
4
4
|
import React from "react";
|
|
5
|
-
import { TldrawUiTooltip } from "./TldrawUiTooltip.mjs";
|
|
6
5
|
const TldrawUiToolbar = React.forwardRef(
|
|
7
6
|
({ children, className, label, ...props }, ref) => {
|
|
8
7
|
return /* @__PURE__ */ jsx(
|
|
@@ -18,8 +17,8 @@ const TldrawUiToolbar = React.forwardRef(
|
|
|
18
17
|
}
|
|
19
18
|
);
|
|
20
19
|
const TldrawUiToolbarButton = React.forwardRef(
|
|
21
|
-
({ asChild, children, type, isActive,
|
|
22
|
-
|
|
20
|
+
({ asChild, children, type, isActive, ...props }, ref) => {
|
|
21
|
+
return /* @__PURE__ */ jsx(
|
|
23
22
|
_Toolbar.Button,
|
|
24
23
|
{
|
|
25
24
|
ref,
|
|
@@ -27,13 +26,10 @@ const TldrawUiToolbarButton = React.forwardRef(
|
|
|
27
26
|
draggable: false,
|
|
28
27
|
"data-isactive": isActive,
|
|
29
28
|
...props,
|
|
30
|
-
title: void 0,
|
|
31
29
|
className: classnames("tlui-button", `tlui-button__${type}`, props.className),
|
|
32
30
|
children
|
|
33
31
|
}
|
|
34
32
|
);
|
|
35
|
-
const tooltipContent = tooltip || props.title;
|
|
36
|
-
return /* @__PURE__ */ jsx(TldrawUiTooltip, { content: tooltipContent, children: button });
|
|
37
33
|
}
|
|
38
34
|
);
|
|
39
35
|
const TldrawUiToolbarToggleGroup = ({
|
|
@@ -47,7 +43,6 @@ const TldrawUiToolbarToggleGroup = ({
|
|
|
47
43
|
{
|
|
48
44
|
type,
|
|
49
45
|
...props,
|
|
50
|
-
role: "radiogroup",
|
|
51
46
|
className: classnames("tlui-toolbar-toggle-group", className),
|
|
52
47
|
children
|
|
53
48
|
}
|
|
@@ -58,14 +53,12 @@ const TldrawUiToolbarToggleItem = ({
|
|
|
58
53
|
className,
|
|
59
54
|
type,
|
|
60
55
|
value,
|
|
61
|
-
tooltip,
|
|
62
56
|
...props
|
|
63
57
|
}) => {
|
|
64
|
-
|
|
58
|
+
return /* @__PURE__ */ jsx(
|
|
65
59
|
_Toolbar.ToggleItem,
|
|
66
60
|
{
|
|
67
61
|
...props,
|
|
68
|
-
title: void 0,
|
|
69
62
|
className: classnames(
|
|
70
63
|
"tlui-button",
|
|
71
64
|
`tlui-button__${type}`,
|
|
@@ -76,8 +69,6 @@ const TldrawUiToolbarToggleItem = ({
|
|
|
76
69
|
children
|
|
77
70
|
}
|
|
78
71
|
);
|
|
79
|
-
const tooltipContent = tooltip || props.title;
|
|
80
|
-
return /* @__PURE__ */ jsx(TldrawUiTooltip, { content: tooltipContent, children: toggleItem });
|
|
81
72
|
};
|
|
82
73
|
export {
|
|
83
74
|
TldrawUiToolbar,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/lib/ui/components/primitives/TldrawUiToolbar.tsx"],
|
|
4
|
-
"sourcesContent": ["import classnames from 'classnames'\nimport { Toolbar as _Toolbar } from 'radix-ui'\nimport React from 'react'\
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import classnames from 'classnames'\nimport { Toolbar as _Toolbar } from 'radix-ui'\nimport React from 'react'\n\n/** @public */\nexport interface TLUiToolbarProps extends React.HTMLAttributes<HTMLDivElement> {\n\tchildren?: React.ReactNode\n\tclassName?: string\n\tdir?: 'ltr' | 'rtl'\n\tlabel: string\n}\n\n/** @public @react */\nexport const TldrawUiToolbar = React.forwardRef<HTMLDivElement, TLUiToolbarProps>(\n\t({ children, className, label, ...props }: TLUiToolbarProps, ref) => {\n\t\treturn (\n\t\t\t<_Toolbar.Root\n\t\t\t\tref={ref}\n\t\t\t\t{...props}\n\t\t\t\tclassName={classnames('tlui-toolbar-container', className)}\n\t\t\t\taria-label={label}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</_Toolbar.Root>\n\t\t)\n\t}\n)\n\n/** @public */\nexport interface TLUiToolbarButtonProps extends React.HTMLAttributes<HTMLButtonElement> {\n\tasChild?: boolean\n\tchildren?: React.ReactNode\n\tclassName?: string\n\tdisabled?: boolean\n\tisActive?: boolean\n\ttype: 'icon' | 'tool' | 'menu'\n}\n\n/** @public @react */\nexport const TldrawUiToolbarButton = React.forwardRef<HTMLButtonElement, TLUiToolbarButtonProps>(\n\t({ asChild, children, type, isActive, ...props }: TLUiToolbarButtonProps, ref) => {\n\t\treturn (\n\t\t\t<_Toolbar.Button\n\t\t\t\tref={ref}\n\t\t\t\tasChild={asChild}\n\t\t\t\tdraggable={false}\n\t\t\t\tdata-isactive={isActive}\n\t\t\t\t{...props}\n\t\t\t\tclassName={classnames('tlui-button', `tlui-button__${type}`, props.className)}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</_Toolbar.Button>\n\t\t)\n\t}\n)\n\n/** @public */\nexport interface TLUiToolbarToggleGroupProps extends React.HTMLAttributes<HTMLDivElement> {\n\tchildren?: React.ReactNode\n\tclassName?: string\n\tdir?: 'ltr' | 'rtl'\n\t// TODO: fix up this type later\n\tdefaultValue?: any\n\ttype: 'single' | 'multiple'\n}\n\n/** @public @react */\nexport const TldrawUiToolbarToggleGroup = ({\n\tchildren,\n\tclassName,\n\ttype,\n\t...props\n}: TLUiToolbarToggleGroupProps) => {\n\treturn (\n\t\t<_Toolbar.ToggleGroup\n\t\t\ttype={type}\n\t\t\t{...props}\n\t\t\tclassName={classnames('tlui-toolbar-toggle-group', className)}\n\t\t>\n\t\t\t{children}\n\t\t</_Toolbar.ToggleGroup>\n\t)\n}\n\n/** @public */\nexport interface TLUiToolbarToggleItemProps extends React.HTMLAttributes<HTMLButtonElement> {\n\tchildren?: React.ReactNode\n\tclassName?: string\n\ttype: 'icon' | 'tool'\n\tvalue: string\n}\n\n/** @public @react */\nexport const TldrawUiToolbarToggleItem = ({\n\tchildren,\n\tclassName,\n\ttype,\n\tvalue,\n\t...props\n}: TLUiToolbarToggleItemProps) => {\n\treturn (\n\t\t<_Toolbar.ToggleItem\n\t\t\t{...props}\n\t\t\tclassName={classnames(\n\t\t\t\t'tlui-button',\n\t\t\t\t`tlui-button__${type}`,\n\t\t\t\t'tlui-toolbar-toggle-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AAgB,IAAI;AAAA,QACpB;AAAA,QACA;AAAA,MACD;AAAA,MACA;AAAA,MAEC;AAAA;AAAA,EACF;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/lib/ui/components/primitives/menus/TldrawUiMenuCheckboxItem.tsx"],
|
|
4
|
-
"sourcesContent": ["import { preventDefault } from '@tldraw/editor'\nimport { ContextMenu as _ContextMenu, DropdownMenu as _DropdownMenu } from 'radix-ui'\nimport { unwrapLabel } from '../../../context/actions'\nimport { TLUiEventSource } from '../../../context/events'\nimport { useReadonly } from '../../../hooks/useReadonly'\nimport { TLUiTranslationKey } from '../../../hooks/useTranslation/TLUiTranslationKey'\nimport { useTranslation } from '../../../hooks/useTranslation/useTranslation'\nimport { TldrawUiIcon
|
|
5
|
-
"mappings": "AAuDI,SAWC,KAXD;AAvDJ,SAAS,sBAAsB;AAC/B,SAAS,eAAe,cAAc,gBAAgB,qBAAqB;AAC3E,SAAS,mBAAmB;AAE5B,SAAS,mBAAmB;AAE5B,SAAS,sBAAsB;AAC/B,SAAS,
|
|
4
|
+
"sourcesContent": ["import { preventDefault } from '@tldraw/editor'\nimport { ContextMenu as _ContextMenu, DropdownMenu as _DropdownMenu } from 'radix-ui'\nimport { unwrapLabel } from '../../../context/actions'\nimport { TLUiEventSource } from '../../../context/events'\nimport { useReadonly } from '../../../hooks/useReadonly'\nimport { TLUiTranslationKey } from '../../../hooks/useTranslation/TLUiTranslationKey'\nimport { useTranslation } from '../../../hooks/useTranslation/useTranslation'\nimport { TldrawUiIcon } from '../TldrawUiIcon'\nimport { TldrawUiKbd } from '../TldrawUiKbd'\nimport { useTldrawUiMenuContext } from './TldrawUiMenuContext'\n\n/** @public */\nexport interface TLUiMenuCheckboxItemProps<\n\tTranslationKey extends string = string,\n\tIconType extends string = string,\n> {\n\ticon?: IconType\n\tid: string\n\tkbd?: string\n\ttitle?: string\n\tlabel?: TranslationKey | { [key: string]: TranslationKey }\n\treadonlyOk?: boolean\n\tonSelect(source: TLUiEventSource): Promise<void> | void\n\ttoggle?: boolean\n\tchecked?: boolean\n\tdisabled?: boolean\n}\n\n/** @public @react */\nexport function TldrawUiMenuCheckboxItem<\n\tTranslationKey extends string = string,\n\tIconType extends string = string,\n>({\n\tid,\n\tkbd,\n\tlabel,\n\treadonlyOk,\n\tonSelect,\n\ttoggle = false,\n\tdisabled = false,\n\tchecked = false,\n}: TLUiMenuCheckboxItemProps<TranslationKey, IconType>) {\n\tconst { type: menuType, sourceId } = useTldrawUiMenuContext()\n\tconst isReadonlyMode = useReadonly()\n\tconst msg = useTranslation()\n\n\t// If the editor is in readonly mode and the item is not marked as readonlyok, return null\n\tif (isReadonlyMode && !readonlyOk) return null\n\n\tconst labelToUse = unwrapLabel(label, menuType)\n\tconst labelStr = labelToUse ? msg(labelToUse as TLUiTranslationKey) : undefined\n\n\tswitch (menuType) {\n\t\tcase 'menu': {\n\t\t\treturn (\n\t\t\t\t<_DropdownMenu.CheckboxItem\n\t\t\t\t\tdir=\"ltr\"\n\t\t\t\t\tclassName=\"tlui-button tlui-button__menu tlui-button__checkbox\"\n\t\t\t\t\ttitle={labelStr}\n\t\t\t\t\tonSelect={(e) => {\n\t\t\t\t\t\tonSelect?.(sourceId)\n\t\t\t\t\t\tpreventDefault(e)\n\t\t\t\t\t}}\n\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\tchecked={checked}\n\t\t\t\t>\n\t\t\t\t\t<TldrawUiIcon\n\t\t\t\t\t\tsmall\n\t\t\t\t\t\tlabel={msg(checked ? 'ui.checked' : 'ui.unchecked')}\n\t\t\t\t\t\ticon={toggle ? (checked ? 'toggle-on' : 'toggle-off') : checked ? 'check' : 'none'}\n\t\t\t\t\t/>\n\t\t\t\t\t{labelStr && (\n\t\t\t\t\t\t<span className=\"tlui-button__label\" draggable={false}>\n\t\t\t\t\t\t\t{labelStr}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t)}\n\t\t\t\t\t{kbd && <TldrawUiKbd>{kbd}</TldrawUiKbd>}\n\t\t\t\t</_DropdownMenu.CheckboxItem>\n\t\t\t)\n\t\t}\n\t\tcase 'context-menu': {\n\t\t\treturn (\n\t\t\t\t<_ContextMenu.CheckboxItem\n\t\t\t\t\tkey={id}\n\t\t\t\t\tclassName=\"tlui-button tlui-button__menu tlui-button__checkbox\"\n\t\t\t\t\tdir=\"ltr\"\n\t\t\t\t\ttitle={labelStr}\n\t\t\t\t\tonSelect={(e) => {\n\t\t\t\t\t\tonSelect(sourceId)\n\t\t\t\t\t\tpreventDefault(e)\n\t\t\t\t\t}}\n\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\tchecked={checked}\n\t\t\t\t>\n\t\t\t\t\t<TldrawUiIcon\n\t\t\t\t\t\tsmall\n\t\t\t\t\t\tlabel={msg(checked ? 'ui.checked' : 'ui.unchecked')}\n\t\t\t\t\t\ticon={toggle ? (checked ? 'toggle-on' : 'toggle-off') : checked ? 'check' : 'none'}\n\t\t\t\t\t/>\n\t\t\t\t\t{labelStr && (\n\t\t\t\t\t\t<span className=\"tlui-button__label\" draggable={false}>\n\t\t\t\t\t\t\t{labelStr}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t)}\n\t\t\t\t\t{kbd && <TldrawUiKbd>{kbd}</TldrawUiKbd>}\n\t\t\t\t</_ContextMenu.CheckboxItem>\n\t\t\t)\n\t\t}\n\t\tdefault: {\n\t\t\t// no checkbox items in actions menu\n\t\t\treturn null\n\t\t}\n\t}\n}\n"],
|
|
5
|
+
"mappings": "AAuDI,SAWC,KAXD;AAvDJ,SAAS,sBAAsB;AAC/B,SAAS,eAAe,cAAc,gBAAgB,qBAAqB;AAC3E,SAAS,mBAAmB;AAE5B,SAAS,mBAAmB;AAE5B,SAAS,sBAAsB;AAC/B,SAAS,oBAAoB;AAC7B,SAAS,mBAAmB;AAC5B,SAAS,8BAA8B;AAoBhC,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ClD,MAAM,SAAU,UAAU,cAAc,eAAgB,UAAU,UAAU;AAAA;AAAA,YAC7E;AAAA,YACC,YACA,oBAAC,UAAK,WAAU,sBAAqB,WAAW,OAC9C,oBACF;AAAA,YAEA,OAAO,oBAAC,eAAa,eAAI;AAAA;AAAA;AAAA,QArBrB;AAAA,MAsBN;AAAA,IAEF;AAAA,IACA,SAAS;AAER,aAAO;AAAA,IACR;AAAA,EACD;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -152,6 +152,7 @@ function TldrawUiMenuItem({
|
|
|
152
152
|
preventDefault(e);
|
|
153
153
|
onSelect("toolbar");
|
|
154
154
|
},
|
|
155
|
+
role: "option",
|
|
155
156
|
title: titleStr,
|
|
156
157
|
type: "tool",
|
|
157
158
|
children: /* @__PURE__ */ jsx(TldrawUiButtonIcon, { icon })
|
|
@@ -170,6 +171,7 @@ function TldrawUiMenuItem({
|
|
|
170
171
|
"data-value": id,
|
|
171
172
|
disabled,
|
|
172
173
|
onClick: () => onSelect("toolbar"),
|
|
174
|
+
role: "option",
|
|
173
175
|
title: titleStr,
|
|
174
176
|
type: "icon",
|
|
175
177
|
children: /* @__PURE__ */ jsx(TldrawUiButtonIcon, { icon })
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/lib/ui/components/primitives/menus/TldrawUiMenuItem.tsx"],
|
|
4
|
-
"sourcesContent": ["import { exhaustiveSwitchError, preventDefault } from '@tldraw/editor'\nimport { ContextMenu as _ContextMenu } from 'radix-ui'\nimport { useState } from 'react'\nimport { unwrapLabel } from '../../../context/actions'\nimport { TLUiEventSource } from '../../../context/events'\nimport { useReadonly } from '../../../hooks/useReadonly'\nimport { TLUiTranslationKey } from '../../../hooks/useTranslation/TLUiTranslationKey'\nimport { useTranslation } from '../../../hooks/useTranslation/useTranslation'\nimport { kbdStr } from '../../../kbd-utils'\nimport { Spinner } from '../../Spinner'\nimport { TldrawUiButton } from '../Button/TldrawUiButton'\nimport { TldrawUiButtonIcon } from '../Button/TldrawUiButtonIcon'\nimport { TldrawUiButtonLabel } from '../Button/TldrawUiButtonLabel'\nimport { TldrawUiDropdownMenuItem } from '../TldrawUiDropdownMenu'\nimport {
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import { exhaustiveSwitchError, preventDefault } from '@tldraw/editor'\nimport { ContextMenu as _ContextMenu } from 'radix-ui'\nimport { useState } from 'react'\nimport { unwrapLabel } from '../../../context/actions'\nimport { TLUiEventSource } from '../../../context/events'\nimport { useReadonly } from '../../../hooks/useReadonly'\nimport { TLUiTranslationKey } from '../../../hooks/useTranslation/TLUiTranslationKey'\nimport { useTranslation } from '../../../hooks/useTranslation/useTranslation'\nimport { kbdStr } from '../../../kbd-utils'\nimport { Spinner } from '../../Spinner'\nimport { TldrawUiButton } from '../Button/TldrawUiButton'\nimport { TldrawUiButtonIcon } from '../Button/TldrawUiButtonIcon'\nimport { TldrawUiButtonLabel } from '../Button/TldrawUiButtonLabel'\nimport { TldrawUiDropdownMenuItem } from '../TldrawUiDropdownMenu'\nimport { TldrawUiKbd } from '../TldrawUiKbd'\nimport { TldrawUiToolbarButton } from '../TldrawUiToolbar'\nimport { useTldrawUiMenuContext } from './TldrawUiMenuContext'\n\n/** @public */\nexport interface TLUiMenuItemProps<\n\tTranslationKey extends string = string,\n\tIconType extends string = string,\n> {\n\tid: string\n\t/**\n\t * The icon to display on the item. Icons are only shown in certain menu types.\n\t */\n\ticon?: IconType\n\t/**\n\t * An icon to display to the left of the menu item.\n\t */\n\ticonLeft?: IconType\n\t/**\n\t * The keyboard shortcut to display on the item.\n\t */\n\tkbd?: string\n\t/**\n\t * The label to display on the item. If it's a string, it will be translated. If it's an object, the keys will be used as the language keys and the values will be translated.\n\t */\n\tlabel?: TranslationKey | { [key: string]: TranslationKey }\n\t/**\n\t * If the editor is in readonly mode and the item is not marked as readonlyok, it will not be rendered.\n\t */\n\treadonlyOk?: boolean\n\t/**\n\t * The function to call when the item is clicked.\n\t */\n\tonSelect(source: TLUiEventSource): Promise<void> | void\n\t/**\n\t * Whether this item should be disabled.\n\t */\n\tdisabled?: boolean\n\t/**\n\t * Prevent the menu from closing when the item is clicked\n\t */\n\tnoClose?: boolean\n\t/**\n\t * Whether to show a spinner on the item.\n\t */\n\tspinner?: boolean\n\t/**\n\t * Whether the item is selected.\n\t */\n\tisSelected?: boolean\n}\n\n/** @public @react */\nexport function TldrawUiMenuItem<\n\tTranslationKey extends string = string,\n\tIconType extends string = string,\n>({\n\tdisabled = false,\n\tspinner = false,\n\treadonlyOk = false,\n\tid,\n\tkbd,\n\tlabel,\n\ticon,\n\ticonLeft,\n\tonSelect,\n\tnoClose,\n\tisSelected,\n}: TLUiMenuItemProps<TranslationKey, IconType>) {\n\tconst { type: menuType, sourceId } = useTldrawUiMenuContext()\n\n\tconst msg = useTranslation()\n\n\tconst [disableClicks, setDisableClicks] = useState(false)\n\n\tconst isReadonlyMode = useReadonly()\n\tif (isReadonlyMode && !readonlyOk) return null\n\n\tconst labelToUse = unwrapLabel(label, menuType)\n\tconst kbdToUse = kbd ? kbdStr(kbd) : undefined\n\n\tconst labelStr = labelToUse ? msg(labelToUse as TLUiTranslationKey) : undefined\n\tconst titleStr = labelStr && kbdToUse ? `${labelStr} ${kbdToUse}` : labelStr\n\n\tswitch (menuType) {\n\t\tcase 'menu': {\n\t\t\treturn (\n\t\t\t\t<TldrawUiDropdownMenuItem>\n\t\t\t\t\t<TldrawUiButton\n\t\t\t\t\t\ttype=\"menu\"\n\t\t\t\t\t\tdata-testid={`${sourceId}.${id}`}\n\t\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\t\ttitle={titleStr}\n\t\t\t\t\t\tonClick={(e) => {\n\t\t\t\t\t\t\tif (noClose) {\n\t\t\t\t\t\t\t\tpreventDefault(e)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (disableClicks) {\n\t\t\t\t\t\t\t\tsetDisableClicks(false)\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tonSelect(sourceId)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}}\n\t\t\t\t\t>\n\t\t\t\t\t\t{iconLeft && <TldrawUiButtonIcon icon={iconLeft} small />}\n\t\t\t\t\t\t<TldrawUiButtonLabel>{labelStr}</TldrawUiButtonLabel>\n\t\t\t\t\t\t{kbd && <TldrawUiKbd>{kbd}</TldrawUiKbd>}\n\t\t\t\t\t</TldrawUiButton>\n\t\t\t\t</TldrawUiDropdownMenuItem>\n\t\t\t)\n\t\t}\n\t\tcase 'context-menu': {\n\t\t\t// Hide disabled context menu items\n\t\t\tif (disabled) return null\n\n\t\t\treturn (\n\t\t\t\t<_ContextMenu.Item\n\t\t\t\t\tdir=\"ltr\"\n\t\t\t\t\ttitle={titleStr}\n\t\t\t\t\tdraggable={false}\n\t\t\t\t\tclassName=\"tlui-button tlui-button__menu\"\n\t\t\t\t\tdata-testid={`${sourceId}.${id}`}\n\t\t\t\t\tonSelect={(e) => {\n\t\t\t\t\t\tif (noClose) preventDefault(e)\n\t\t\t\t\t\tif (disableClicks) {\n\t\t\t\t\t\t\tsetDisableClicks(false)\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tonSelect(sourceId)\n\t\t\t\t\t\t}\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\t<span className=\"tlui-button__label\" draggable={false}>\n\t\t\t\t\t\t{labelStr}\n\t\t\t\t\t</span>\n\t\t\t\t\t{iconLeft && <TldrawUiButtonIcon icon={iconLeft} small />}\n\t\t\t\t\t{kbd && <TldrawUiKbd>{kbd}</TldrawUiKbd>}\n\t\t\t\t\t{spinner && <Spinner />}\n\t\t\t\t</_ContextMenu.Item>\n\t\t\t)\n\t\t}\n\t\tcase 'panel': {\n\t\t\treturn (\n\t\t\t\t<TldrawUiButton\n\t\t\t\t\tdata-testid={`${sourceId}.${id}`}\n\t\t\t\t\ttype=\"menu\"\n\t\t\t\t\ttitle={titleStr}\n\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\tonClick={() => onSelect(sourceId)}\n\t\t\t\t>\n\t\t\t\t\t<TldrawUiButtonLabel>{labelStr}</TldrawUiButtonLabel>\n\t\t\t\t\t{spinner ? <Spinner /> : icon && <TldrawUiButtonIcon icon={icon} />}\n\t\t\t\t</TldrawUiButton>\n\t\t\t)\n\t\t}\n\t\tcase 'small-icons':\n\t\tcase 'icons': {\n\t\t\treturn (\n\t\t\t\t<TldrawUiToolbarButton\n\t\t\t\t\tdata-testid={`${sourceId}.${id}`}\n\t\t\t\t\ttype=\"icon\"\n\t\t\t\t\ttitle={titleStr}\n\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\tonClick={() => onSelect(sourceId)}\n\t\t\t\t>\n\t\t\t\t\t<TldrawUiButtonIcon icon={icon!} small />\n\t\t\t\t</TldrawUiToolbarButton>\n\t\t\t)\n\t\t}\n\t\tcase 'keyboard-shortcuts': {\n\t\t\tif (!kbd) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`Menu item '${label}' isn't shown in the keyboard shortcuts dialog because it doesn't have a keyboard shortcut.`\n\t\t\t\t)\n\t\t\t\treturn null\n\t\t\t}\n\n\t\t\treturn (\n\t\t\t\t<div className=\"tlui-shortcuts-dialog__key-pair\" data-testid={`${sourceId}.${id}`}>\n\t\t\t\t\t<div className=\"tlui-shortcuts-dialog__key-pair__key\">{labelStr}</div>\n\t\t\t\t\t<div className=\"tlui-shortcuts-dialog__key-pair__value\">\n\t\t\t\t\t\t<TldrawUiKbd visibleOnMobileLayout>{kbd}</TldrawUiKbd>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t)\n\t\t}\n\t\tcase 'helper-buttons': {\n\t\t\treturn (\n\t\t\t\t<TldrawUiButton type=\"low\" onClick={() => onSelect(sourceId)}>\n\t\t\t\t\t<TldrawUiButtonIcon icon={icon!} />\n\t\t\t\t\t<TldrawUiButtonLabel>{labelStr}</TldrawUiButtonLabel>\n\t\t\t\t</TldrawUiButton>\n\t\t\t)\n\t\t}\n\t\tcase 'toolbar': {\n\t\t\treturn (\n\t\t\t\t<TldrawUiToolbarButton\n\t\t\t\t\taria-label={labelStr}\n\t\t\t\t\taria-pressed={isSelected ? 'true' : 'false'}\n\t\t\t\t\tdata-testid={`tools.${id}`}\n\t\t\t\t\tdata-value={id}\n\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\tonClick={() => onSelect('toolbar')}\n\t\t\t\t\tonTouchStart={(e) => {\n\t\t\t\t\t\tpreventDefault(e)\n\t\t\t\t\t\tonSelect('toolbar')\n\t\t\t\t\t}}\n\t\t\t\t\trole=\"option\"\n\t\t\t\t\ttitle={titleStr}\n\t\t\t\t\ttype=\"tool\"\n\t\t\t\t>\n\t\t\t\t\t<TldrawUiButtonIcon icon={icon!} />\n\t\t\t\t</TldrawUiToolbarButton>\n\t\t\t)\n\t\t}\n\t\tcase 'toolbar-overflow': {\n\t\t\treturn (\n\t\t\t\t<TldrawUiToolbarButton\n\t\t\t\t\taria-label={labelStr}\n\t\t\t\t\taria-pressed={isSelected ? 'true' : 'false'}\n\t\t\t\t\tisActive={isSelected}\n\t\t\t\t\tclassName=\"tlui-button-grid__button\"\n\t\t\t\t\tdata-testid={`tools.more.${id}`}\n\t\t\t\t\tdata-value={id}\n\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\tonClick={() => onSelect('toolbar')}\n\t\t\t\t\trole=\"option\"\n\t\t\t\t\ttitle={titleStr}\n\t\t\t\t\ttype=\"icon\"\n\t\t\t\t>\n\t\t\t\t\t<TldrawUiButtonIcon icon={icon!} />\n\t\t\t\t</TldrawUiToolbarButton>\n\t\t\t)\n\t\t}\n\t\tdefault: {\n\t\t\tthrow exhaustiveSwitchError(menuType)\n\t\t}\n\t}\n}\n"],
|
|
5
|
+
"mappings": "AAsGK,SAgBc,KAhBd;AAtGL,SAAS,uBAAuB,sBAAsB;AACtD,SAAS,eAAe,oBAAoB;AAC5C,SAAS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L,OAAO;AAAA,UACP,MAAK;AAAA,UAEL,8BAAC,sBAAmB,MAAa;AAAA;AAAA,MAClC;AAAA,IAEF;AAAA,IACA,SAAS;AACR,YAAM,sBAAsB,QAAQ;AAAA,IACrC;AAAA,EACD;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { defaultUserPreferences, track, useMaybeEditor } from "@tldraw/editor";
|
|
3
3
|
import { useDefaultUiAssetUrlsWithOverrides } from "../assetUrls.mjs";
|
|
4
|
-
import { TldrawUiTooltipProvider } from "../components/primitives/TldrawUiTooltip.mjs";
|
|
5
4
|
import { ToolsProvider } from "../hooks/useTools.mjs";
|
|
6
5
|
import { TldrawUiTranslationProvider } from "../hooks/useTranslation/useTranslation.mjs";
|
|
7
6
|
import {
|
|
@@ -27,14 +26,14 @@ const TldrawUiContextProvider = track(function TldrawUiContextProvider2({
|
|
|
27
26
|
children
|
|
28
27
|
}) {
|
|
29
28
|
const editor = useMaybeEditor();
|
|
30
|
-
return /* @__PURE__ */ jsx(MimeTypeContext.Provider, { value: mediaMimeTypes, children: /* @__PURE__ */ jsx(
|
|
29
|
+
return /* @__PURE__ */ jsx(MimeTypeContext.Provider, { value: mediaMimeTypes, children: /* @__PURE__ */ jsx(AssetUrlsProvider, { assetUrls: useDefaultUiAssetUrlsWithOverrides(assetUrls), children: /* @__PURE__ */ jsx(
|
|
31
30
|
TldrawUiTranslationProvider,
|
|
32
31
|
{
|
|
33
32
|
overrides: useMergedTranslationOverrides(overrides),
|
|
34
33
|
locale: editor?.user.getLocale() ?? defaultUserPreferences.locale,
|
|
35
34
|
children: /* @__PURE__ */ jsx(TldrawUiEventsProvider, { onEvent: onUiEvent, children: /* @__PURE__ */ jsx(TldrawUiToastsProvider, { children: /* @__PURE__ */ jsx(TldrawUiDialogsProvider, { context: "tla", children: /* @__PURE__ */ jsx(TldrawUiA11yProvider, { children: /* @__PURE__ */ jsx(BreakPointProvider, { forceMobile, children: /* @__PURE__ */ jsx(TldrawUiComponentsProvider, { overrides: components, children: /* @__PURE__ */ jsx(InternalProviders, { overrides, children }) }) }) }) }) }) })
|
|
36
35
|
}
|
|
37
|
-
) }) })
|
|
36
|
+
) }) });
|
|
38
37
|
});
|
|
39
38
|
function InternalProviders({
|
|
40
39
|
overrides,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/lib/ui/context/TldrawUiContextProvider.tsx"],
|
|
4
|
-
"sourcesContent": ["import { RecursivePartial, defaultUserPreferences, track, useMaybeEditor } from '@tldraw/editor'\nimport { ReactNode } from 'react'\nimport { TLUiAssetUrls, useDefaultUiAssetUrlsWithOverrides } from '../assetUrls'\nimport {
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import { RecursivePartial, defaultUserPreferences, track, useMaybeEditor } from '@tldraw/editor'\nimport { ReactNode } from 'react'\nimport { TLUiAssetUrls, useDefaultUiAssetUrlsWithOverrides } from '../assetUrls'\nimport { ToolsProvider } from '../hooks/useTools'\nimport { TldrawUiTranslationProvider } from '../hooks/useTranslation/useTranslation'\nimport {\n\tMimeTypeContext,\n\tTLUiOverrides,\n\tuseMergedOverrides,\n\tuseMergedTranslationOverrides,\n} from '../overrides'\nimport { TldrawUiA11yProvider } from './a11y'\nimport { ActionsProvider } from './actions'\nimport { AssetUrlsProvider } from './asset-urls'\nimport { BreakPointProvider } from './breakpoints'\nimport { TLUiComponents, TldrawUiComponentsProvider } from './components'\nimport { TldrawUiDialogsProvider } from './dialogs'\nimport { TLUiEventHandler, TldrawUiEventsProvider } from './events'\nimport { TldrawUiToastsProvider } from './toasts'\n\n/** @public */\nexport interface TLUiContextProviderProps {\n\t/**\n\t * Urls for where to find fonts and other assets for the UI.\n\t */\n\tassetUrls?: RecursivePartial<TLUiAssetUrls>\n\n\t/**\n\t * Overrides for the UI.\n\t */\n\toverrides?: TLUiOverrides | TLUiOverrides[]\n\n\t/**\n\t * Overrides for the UI components.\n\t */\n\tcomponents?: TLUiComponents\n\n\t/**\n\t * Callback for when an event occurs in the UI.\n\t */\n\tonUiEvent?: TLUiEventHandler\n\n\t/**\n\t * Whether to always should the mobile breakpoints.\n\t */\n\tforceMobile?: boolean\n\n\t/**\n\t * The component's children.\n\t */\n\tchildren?: ReactNode\n\n\t/**\n\t * Supported mime types for media files.\n\t */\n\tmediaMimeTypes?: string[]\n}\n\n/** @public @react */\nexport const TldrawUiContextProvider = track(function TldrawUiContextProvider({\n\toverrides,\n\tcomponents,\n\tassetUrls,\n\tonUiEvent,\n\tforceMobile,\n\tmediaMimeTypes,\n\tchildren,\n}: TLUiContextProviderProps) {\n\t// To allow mounting the sidebar without an editor running, we use a 'maybe' editor here\n\t// The sidebar makes use of toasts and dialogs etc, which typically require an editor to be present\n\t// but we are overriding the providers to allow them to be used without an editor.\n\tconst editor = useMaybeEditor()\n\treturn (\n\t\t<MimeTypeContext.Provider value={mediaMimeTypes}>\n\t\t\t<AssetUrlsProvider assetUrls={useDefaultUiAssetUrlsWithOverrides(assetUrls)}>\n\t\t\t\t<TldrawUiTranslationProvider\n\t\t\t\t\toverrides={useMergedTranslationOverrides(overrides)}\n\t\t\t\t\tlocale={editor?.user.getLocale() ?? defaultUserPreferences.locale}\n\t\t\t\t>\n\t\t\t\t\t<TldrawUiEventsProvider onEvent={onUiEvent}>\n\t\t\t\t\t\t<TldrawUiToastsProvider>\n\t\t\t\t\t\t\t<TldrawUiDialogsProvider context={'tla'}>\n\t\t\t\t\t\t\t\t<TldrawUiA11yProvider>\n\t\t\t\t\t\t\t\t\t<BreakPointProvider forceMobile={forceMobile}>\n\t\t\t\t\t\t\t\t\t\t<TldrawUiComponentsProvider overrides={components}>\n\t\t\t\t\t\t\t\t\t\t\t<InternalProviders overrides={overrides}>{children}</InternalProviders>\n\t\t\t\t\t\t\t\t\t\t</TldrawUiComponentsProvider>\n\t\t\t\t\t\t\t\t\t</BreakPointProvider>\n\t\t\t\t\t\t\t\t</TldrawUiA11yProvider>\n\t\t\t\t\t\t\t</TldrawUiDialogsProvider>\n\t\t\t\t\t\t</TldrawUiToastsProvider>\n\t\t\t\t\t</TldrawUiEventsProvider>\n\t\t\t\t</TldrawUiTranslationProvider>\n\t\t\t</AssetUrlsProvider>\n\t\t</MimeTypeContext.Provider>\n\t)\n})\n\nfunction InternalProviders({\n\toverrides,\n\tchildren,\n}: Omit<TLUiContextProviderProps, 'assetBaseUrl'>) {\n\tconst mergedOverrides = useMergedOverrides(overrides)\n\treturn (\n\t\t<ActionsProvider overrides={mergedOverrides.actions}>\n\t\t\t<ToolsProvider overrides={mergedOverrides.tools}>{children}</ToolsProvider>\n\t\t</ActionsProvider>\n\t)\n}\n"],
|
|
5
|
+
"mappings": "AAqFW;AArFX,SAA2B,wBAAwB,OAAO,sBAAsB;AAEhF,SAAwB,0CAA0C;AAClE,SAAS,qBAAqB;AAC9B,SAAS,mCAAmC;AAC5C;AAAA,EACC;AAAA,EAEA;AAAA,EACA;AAAA,OACM;AACP,SAAS,4BAA4B;AACrC,SAAS,uBAAuB;AAChC,SAAS,yBAAyB;AAClC,SAAS,0BAA0B;AACnC,SAAyB,kCAAkC;AAC3D,SAAS,+BAA+B;AACxC,SAA2B,8BAA8B;AACzD,SAAS,8BAA8B;AAyChC,MAAM,0BAA0B,MAAM,SAASA,yBAAwB;AAAA,EAC7E;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAA6B;AAI5B,QAAM,SAAS,eAAe;AAC9B,SACC,oBAAC,gBAAgB,UAAhB,EAAyB,OAAO,gBAChC,8BAAC,qBAAkB,WAAW,mCAAmC,SAAS,GACzE;AAAA,IAAC;AAAA;AAAA,MACA,WAAW,8BAA8B,SAAS;AAAA,MAClD,QAAQ,QAAQ,KAAK,UAAU,KAAK,uBAAuB;AAAA,MAE3D,8BAAC,0BAAuB,SAAS,WAChC,8BAAC,0BACA,8BAAC,2BAAwB,SAAS,OACjC,8BAAC,wBACA,8BAAC,sBAAmB,aACnB,8BAAC,8BAA2B,WAAW,YACtC,8BAAC,qBAAkB,WAAuB,UAAS,GACpD,GACD,GACD,GACD,GACD,GACD;AAAA;AAAA,EACD,GACD,GACD;AAEF,CAAC;AAED,SAAS,kBAAkB;AAAA,EAC1B;AAAA,EACA;AACD,GAAmD;AAClD,QAAM,kBAAkB,mBAAmB,SAAS;AACpD,SACC,oBAAC,mBAAgB,WAAW,gBAAgB,SAC3C,8BAAC,iBAAc,WAAW,gBAAgB,OAAQ,UAAS,GAC5D;AAEF;",
|
|
6
6
|
"names": ["TldrawUiContextProvider"]
|
|
7
7
|
}
|
|
@@ -18,7 +18,6 @@ import { fitFrameToContent, removeFrame } from "../../utils/frames/frames.mjs";
|
|
|
18
18
|
import { generateShapeAnnouncementMessage } from "../components/A11y.mjs";
|
|
19
19
|
import { EditLinkDialog } from "../components/EditLinkDialog.mjs";
|
|
20
20
|
import { EmbedDialog } from "../components/EmbedDialog.mjs";
|
|
21
|
-
import { DefaultKeyboardShortcutsDialog } from "../components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialog.mjs";
|
|
22
21
|
import { useShowCollaborationUi } from "../hooks/useCollaborationStatus.mjs";
|
|
23
22
|
import { flattenShapesToImages } from "../hooks/useFlatten.mjs";
|
|
24
23
|
import { useTranslation } from "../hooks/useTranslation/useTranslation.mjs";
|
|
@@ -98,15 +97,6 @@ function ActionsProvider({ overrides, children }) {
|
|
|
98
97
|
helpers.addDialog({ component: EmbedDialog });
|
|
99
98
|
}
|
|
100
99
|
},
|
|
101
|
-
{
|
|
102
|
-
id: "open-kbd-shortcuts",
|
|
103
|
-
label: "action.open-kbd-shortcuts",
|
|
104
|
-
kbd: "cmd+alt+/,ctrl+alt+/",
|
|
105
|
-
onSelect(source) {
|
|
106
|
-
trackEvent("open-kbd-shortcuts", { source });
|
|
107
|
-
helpers.addDialog({ component: DefaultKeyboardShortcutsDialog });
|
|
108
|
-
}
|
|
109
|
-
},
|
|
110
100
|
{
|
|
111
101
|
id: "insert-media",
|
|
112
102
|
label: "action.insert-media",
|
|
@@ -412,6 +402,7 @@ function ActionsProvider({ overrides, children }) {
|
|
|
412
402
|
y: 0
|
|
413
403
|
};
|
|
414
404
|
}
|
|
405
|
+
if (!editor.canCreateShapes(ids)) return;
|
|
415
406
|
editor.markHistoryStoppingPoint("duplicate shapes");
|
|
416
407
|
editor.duplicateShapes(ids, offset);
|
|
417
408
|
if (instanceState.duplicateProps) {
|
|
@@ -898,19 +889,16 @@ function ActionsProvider({ overrides, children }) {
|
|
|
898
889
|
id: "rotate-cw",
|
|
899
890
|
label: "action.rotate-cw",
|
|
900
891
|
icon: "rotate-cw",
|
|
901
|
-
kbd: "shift+.,shift+alt+.",
|
|
902
892
|
onSelect(source) {
|
|
903
893
|
if (!canApplySelectionAction()) return;
|
|
904
894
|
if (mustGoBackToSelectToolFirst()) return;
|
|
905
|
-
|
|
906
|
-
trackEvent("rotate-cw", { source, fine: isFine });
|
|
895
|
+
trackEvent("rotate-cw", { source });
|
|
907
896
|
editor.markHistoryStoppingPoint("rotate-cw");
|
|
908
897
|
editor.run(() => {
|
|
909
|
-
const
|
|
910
|
-
const
|
|
911
|
-
const dontUseOffset = approximately(offset, 0) || approximately(offset, rotation);
|
|
898
|
+
const offset = editor.getSelectionRotation() % (HALF_PI / 2);
|
|
899
|
+
const dontUseOffset = approximately(offset, 0) || approximately(offset, HALF_PI / 2);
|
|
912
900
|
const selectedShapeIds = editor.getSelectedShapeIds();
|
|
913
|
-
editor.rotateShapesBy(selectedShapeIds,
|
|
901
|
+
editor.rotateShapesBy(selectedShapeIds, HALF_PI / 2 - (dontUseOffset ? 0 : offset));
|
|
914
902
|
kickoutOccludedShapes(editor, selectedShapeIds);
|
|
915
903
|
});
|
|
916
904
|
}
|
|
@@ -919,20 +907,16 @@ function ActionsProvider({ overrides, children }) {
|
|
|
919
907
|
id: "rotate-ccw",
|
|
920
908
|
label: "action.rotate-ccw",
|
|
921
909
|
icon: "rotate-ccw",
|
|
922
|
-
// omg double comma
|
|
923
|
-
kbd: "shift+,,shift+alt+,",
|
|
924
910
|
onSelect(source) {
|
|
925
911
|
if (!canApplySelectionAction()) return;
|
|
926
912
|
if (mustGoBackToSelectToolFirst()) return;
|
|
927
|
-
|
|
928
|
-
trackEvent("rotate-ccw", { source, fine: isFine });
|
|
913
|
+
trackEvent("rotate-ccw", { source });
|
|
929
914
|
editor.markHistoryStoppingPoint("rotate-ccw");
|
|
930
915
|
editor.run(() => {
|
|
931
|
-
const
|
|
932
|
-
const offset = editor.getSelectionRotation() % rotation;
|
|
916
|
+
const offset = editor.getSelectionRotation() % (HALF_PI / 2);
|
|
933
917
|
const offsetCloseToZero = approximately(offset, 0);
|
|
934
918
|
const selectedShapeIds = editor.getSelectedShapeIds();
|
|
935
|
-
editor.rotateShapesBy(selectedShapeIds, offsetCloseToZero ? -
|
|
919
|
+
editor.rotateShapesBy(selectedShapeIds, offsetCloseToZero ? -(HALF_PI / 2) : -offset);
|
|
936
920
|
kickoutOccludedShapes(editor, selectedShapeIds);
|
|
937
921
|
});
|
|
938
922
|
}
|
|
@@ -1109,36 +1093,6 @@ function ActionsProvider({ overrides, children }) {
|
|
|
1109
1093
|
},
|
|
1110
1094
|
checkbox: true
|
|
1111
1095
|
},
|
|
1112
|
-
{
|
|
1113
|
-
id: "toggle-keyboard-shortcuts",
|
|
1114
|
-
label: {
|
|
1115
|
-
default: "action.toggle-keyboard-shortcuts",
|
|
1116
|
-
menu: "action.toggle-keyboard-shortcuts.menu"
|
|
1117
|
-
},
|
|
1118
|
-
readonlyOk: true,
|
|
1119
|
-
onSelect(source) {
|
|
1120
|
-
trackEvent("toggle-keyboard-shortcuts", { source });
|
|
1121
|
-
editor.user.updateUserPreferences({
|
|
1122
|
-
areKeyboardShortcutsEnabled: !editor.user.getAreKeyboardShortcutsEnabled()
|
|
1123
|
-
});
|
|
1124
|
-
},
|
|
1125
|
-
checkbox: true
|
|
1126
|
-
},
|
|
1127
|
-
{
|
|
1128
|
-
id: "toggle-ui-labels",
|
|
1129
|
-
label: {
|
|
1130
|
-
default: "action.toggle-ui-labels",
|
|
1131
|
-
menu: "action.toggle-ui-labels.menu"
|
|
1132
|
-
},
|
|
1133
|
-
readonlyOk: true,
|
|
1134
|
-
onSelect(source) {
|
|
1135
|
-
trackEvent("toggle-ui-labels", { source });
|
|
1136
|
-
editor.user.updateUserPreferences({
|
|
1137
|
-
showUiLabels: !editor.user.getShowUiLabels()
|
|
1138
|
-
});
|
|
1139
|
-
},
|
|
1140
|
-
checkbox: true
|
|
1141
|
-
},
|
|
1142
1096
|
{
|
|
1143
1097
|
id: "toggle-edge-scrolling",
|
|
1144
1098
|
label: {
|
|
@@ -1422,7 +1376,6 @@ function ActionsProvider({ overrides, children }) {
|
|
|
1422
1376
|
id: "adjust-shape-styles",
|
|
1423
1377
|
label: "a11y.adjust-shape-styles",
|
|
1424
1378
|
kbd: "cmd+Enter,ctrl+Enter",
|
|
1425
|
-
isRequiredA11yAction: true,
|
|
1426
1379
|
onSelect: async (source) => {
|
|
1427
1380
|
if (!canApplySelectionAction()) return;
|
|
1428
1381
|
const firstButton = editor.getContainer().querySelector(".tlui-style-panel button");
|
|
@@ -1433,7 +1386,6 @@ function ActionsProvider({ overrides, children }) {
|
|
|
1433
1386
|
{
|
|
1434
1387
|
id: "a11y-open-context-menu",
|
|
1435
1388
|
kbd: "cmd+shift+Enter,ctrl+shift+Enter",
|
|
1436
|
-
isRequiredA11yAction: true,
|
|
1437
1389
|
readonlyOk: true,
|
|
1438
1390
|
onSelect: async (source) => {
|
|
1439
1391
|
if (!canApplySelectionAction()) return;
|
|
@@ -1474,7 +1426,6 @@ function ActionsProvider({ overrides, children }) {
|
|
|
1474
1426
|
id: "a11y-repeat-shape-announce",
|
|
1475
1427
|
kbd: "alt+r",
|
|
1476
1428
|
label: "a11y.repeat-shape",
|
|
1477
|
-
isRequiredA11yAction: true,
|
|
1478
1429
|
readonlyOk: true,
|
|
1479
1430
|
onSelect: async (source) => {
|
|
1480
1431
|
const selectedShapeIds = editor.getSelectedShapeIds();
|