tldraw 3.16.0-next.34fddf633325 → 3.16.0-next.6611943ca24a
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 +173 -5
- package/dist-cjs/index.js +12 -1
- package/dist-cjs/index.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/shapes/arrow/ArrowShapeUtil.js +3 -3
- package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.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/draw/DrawShapeUtil.js +3 -3
- package/dist-cjs/lib/shapes/draw/DrawShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/embed/EmbedShapeUtil.js +1 -1
- package/dist-cjs/lib/shapes/embed/EmbedShapeUtil.js.map +1 -1
- package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js +12 -12
- 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 -1
- package/dist-cjs/lib/shapes/highlight/HighlightShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/image/ImageShapeUtil.js +3 -3
- package/dist-cjs/lib/shapes/image/ImageShapeUtil.js.map +1 -1
- package/dist-cjs/lib/shapes/line/LineShapeUtil.js +5 -1
- package/dist-cjs/lib/shapes/line/LineShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/note/NoteShapeUtil.js +4 -4
- package/dist-cjs/lib/shapes/note/NoteShapeUtil.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/freehand/svg.js.map +2 -2
- package/dist-cjs/lib/shapes/text/TextShapeUtil.js +2 -2
- 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/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/Translating.js.map +2 -2
- package/dist-cjs/lib/ui/TldrawUi.js +14 -0
- package/dist-cjs/lib/ui/TldrawUi.js.map +3 -3
- 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/ActionsMenu/DefaultActionsMenu.js +12 -3
- package/dist-cjs/lib/ui/components/ActionsMenu/DefaultActionsMenu.js.map +2 -2
- 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 +1 -1
- package/dist-cjs/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.js.map +1 -1
- 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 +1 -1
- 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/StylePanel/DefaultStylePanelContent.js +14 -14
- 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/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 +2 -2
- package/dist-cjs/lib/ui/components/Toolbar/ToggleToolLockedButton.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiButtonPicker.js +5 -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/TldrawUiPopover.js +3 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiPopover.js.map +3 -3
- package/dist-cjs/lib/ui/components/primitives/TldrawUiToolbar.js +19 -4
- package/dist-cjs/lib/ui/components/primitives/TldrawUiToolbar.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js +153 -152
- package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js.map +2 -2
- 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/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 -20
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js.map +2 -2
- package/dist-cjs/lib/ui/context/actions.js +16 -2
- 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/useTools.js +94 -9
- package/dist-cjs/lib/ui/hooks/useTools.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-esm/index.d.mts +173 -5
- package/dist-esm/index.mjs +19 -1
- package/dist-esm/index.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/shapes/arrow/ArrowShapeUtil.mjs +4 -3
- package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.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/draw/DrawShapeUtil.mjs +4 -3
- 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 +13 -12
- 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 -1
- package/dist-esm/lib/shapes/highlight/HighlightShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/image/ImageShapeUtil.mjs +3 -3
- package/dist-esm/lib/shapes/image/ImageShapeUtil.mjs.map +1 -1
- package/dist-esm/lib/shapes/line/LineShapeUtil.mjs +6 -1
- package/dist-esm/lib/shapes/line/LineShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs +5 -4
- package/dist-esm/lib/shapes/note/NoteShapeUtil.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/freehand/svg.mjs.map +2 -2
- package/dist-esm/lib/shapes/text/TextShapeUtil.mjs +3 -2
- 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/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/Translating.mjs.map +2 -2
- package/dist-esm/lib/ui/TldrawUi.mjs +16 -2
- package/dist-esm/lib/ui/TldrawUi.mjs.map +3 -3
- 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/ActionsMenu/DefaultActionsMenu.mjs +12 -3
- package/dist-esm/lib/ui/components/ActionsMenu/DefaultActionsMenu.mjs.map +2 -2
- 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 +1 -1
- package/dist-esm/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.mjs.map +1 -1
- 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 +1 -1
- 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/StylePanel/DefaultStylePanelContent.mjs +14 -14
- 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/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 +2 -2
- package/dist-esm/lib/ui/components/Toolbar/ToggleToolLockedButton.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiButtonPicker.mjs +6 -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/TldrawUiPopover.mjs +3 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiPopover.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiToolbar.mjs +19 -4
- package/dist-esm/lib/ui/components/primitives/TldrawUiToolbar.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs +162 -154
- package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs.map +2 -2
- 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/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 -22
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs.map +2 -2
- package/dist-esm/lib/ui/context/actions.mjs +16 -2
- 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/useTools.mjs +102 -10
- package/dist-esm/lib/ui/hooks/useTools.mjs.map +2 -2
- package/dist-esm/lib/ui/version.mjs +3 -3
- package/dist-esm/lib/ui/version.mjs.map +1 -1
- package/package.json +11 -34
- package/src/index.ts +15 -0
- package/src/lib/canvas/TldrawScribble.tsx +1 -1
- 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 +7 -6
- package/src/lib/shapes/arrow/ArrowShapeUtil.tsx +4 -3
- package/src/lib/shapes/arrow/elbow/ElbowArrowDebug.tsx +3 -3
- package/src/lib/shapes/draw/DrawShapeTool.test.ts +0 -5
- package/src/lib/shapes/draw/DrawShapeUtil.tsx +4 -3
- package/src/lib/shapes/embed/EmbedShapeUtil.tsx +1 -1
- package/src/lib/shapes/frame/FrameShapeUtil.tsx +21 -14
- 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 -1
- package/src/lib/shapes/image/ImageShapeUtil.tsx +3 -3
- package/src/lib/shapes/line/LineShapeUtil.test.tsx +4 -3
- package/src/lib/shapes/line/LineShapeUtil.tsx +6 -1
- package/src/lib/shapes/line/__snapshots__/LineShapeUtil.test.tsx.snap +2 -2
- package/src/lib/shapes/note/NoteShapeUtil.tsx +9 -4
- package/src/lib/shapes/shared/ShapeFill.tsx +5 -4
- package/src/lib/shapes/shared/freehand/svg.ts +2 -0
- package/src/lib/shapes/text/TextShapeTool.test.ts +6 -5
- package/src/lib/shapes/text/TextShapeUtil.tsx +3 -2
- package/src/lib/shapes/video/VideoShapeUtil.tsx +3 -3
- 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/Translating.ts +0 -1
- package/src/lib/ui/TldrawUi.tsx +17 -2
- package/src/lib/ui/assetUrls.ts +13 -10
- package/src/lib/ui/components/ActionsMenu/DefaultActionsMenu.tsx +15 -3
- package/src/lib/ui/components/DefaultMenuPanel.tsx +4 -3
- package/src/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.tsx +1 -1
- 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 +1 -1
- 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/StylePanel/DefaultStylePanelContent.tsx +39 -43
- 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/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 +2 -2
- package/src/lib/ui/components/primitives/TldrawUiButtonPicker.tsx +40 -37
- package/src/lib/ui/components/primitives/TldrawUiContextualToolbar.tsx +1 -1
- package/src/lib/ui/components/primitives/TldrawUiPopover.tsx +4 -2
- package/src/lib/ui/components/primitives/TldrawUiToolbar.tsx +32 -9
- package/src/lib/ui/components/primitives/TldrawUiTooltip.tsx +186 -172
- package/src/lib/ui/components/primitives/layout.tsx +107 -0
- 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 +221 -19
- package/src/lib/ui/context/actions.tsx +16 -2
- package/src/lib/ui/context/events.tsx +1 -0
- package/src/lib/ui/hooks/useTools.tsx +140 -10
- package/src/lib/ui/version.ts +3 -3
- package/src/lib/ui.css +366 -305
- package/src/lib/utils/excalidraw/__snapshots__/putExcalidrawContent.test.tsx.snap +5 -5
- package/src/lib/utils/tldr/__snapshots__/buildFromV1Document.test.ts.snap +4 -4
- package/src/test/A11y.test.tsx +3 -2
- package/src/test/ClickManager.test.ts +7 -6
- package/src/test/Editor.test.tsx +20 -19
- 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 +3 -2
- 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 +5 -4
- 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/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 +1 -1
- package/src/test/handleDeepLink.test.tsx +2 -1
- package/src/test/maxShapes.test.ts +3 -2
- package/src/test/modifiers.test.ts +5 -4
- package/src/test/navigation.test.ts +12 -11
- 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 +4 -3
- package/src/test/translating.test.ts +9 -8
- package/tldraw.css +659 -595
|
@@ -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'
|
|
@@ -15,6 +24,7 @@ import { TldrawUiDropdownMenuItem } from '../TldrawUiDropdownMenu'
|
|
|
15
24
|
import { TLUiIconJsx } from '../TldrawUiIcon'
|
|
16
25
|
import { TldrawUiKbd } from '../TldrawUiKbd'
|
|
17
26
|
import { TldrawUiToolbarButton } from '../TldrawUiToolbar'
|
|
27
|
+
import { tooltipManager } from '../TldrawUiTooltip'
|
|
18
28
|
import { useTldrawUiMenuContext } from './TldrawUiMenuContext'
|
|
19
29
|
|
|
20
30
|
/** @public */
|
|
@@ -63,6 +73,10 @@ export interface TLUiMenuItemProps<
|
|
|
63
73
|
* Whether the item is selected.
|
|
64
74
|
*/
|
|
65
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
|
|
66
80
|
}
|
|
67
81
|
|
|
68
82
|
/** @public @react */
|
|
@@ -81,6 +95,7 @@ export function TldrawUiMenuItem<
|
|
|
81
95
|
onSelect,
|
|
82
96
|
noClose,
|
|
83
97
|
isSelected,
|
|
98
|
+
onDragStart,
|
|
84
99
|
}: TLUiMenuItemProps<TranslationKey, IconType>) {
|
|
85
100
|
const { type: menuType, sourceId } = useTldrawUiMenuContext()
|
|
86
101
|
|
|
@@ -105,7 +120,6 @@ export function TldrawUiMenuItem<
|
|
|
105
120
|
type="menu"
|
|
106
121
|
data-testid={`${sourceId}.${id}`}
|
|
107
122
|
disabled={disabled}
|
|
108
|
-
title={titleStr}
|
|
109
123
|
onClick={(e) => {
|
|
110
124
|
if (noClose) {
|
|
111
125
|
preventDefault(e)
|
|
@@ -131,7 +145,6 @@ export function TldrawUiMenuItem<
|
|
|
131
145
|
return (
|
|
132
146
|
<_ContextMenu.Item
|
|
133
147
|
dir="ltr"
|
|
134
|
-
title={titleStr}
|
|
135
148
|
draggable={false}
|
|
136
149
|
className="tlui-button tlui-button__menu"
|
|
137
150
|
data-testid={`${sourceId}.${id}`}
|
|
@@ -153,20 +166,6 @@ export function TldrawUiMenuItem<
|
|
|
153
166
|
</_ContextMenu.Item>
|
|
154
167
|
)
|
|
155
168
|
}
|
|
156
|
-
case 'panel': {
|
|
157
|
-
return (
|
|
158
|
-
<TldrawUiButton
|
|
159
|
-
data-testid={`${sourceId}.${id}`}
|
|
160
|
-
type="menu"
|
|
161
|
-
title={titleStr}
|
|
162
|
-
disabled={disabled}
|
|
163
|
-
onClick={() => onSelect(sourceId)}
|
|
164
|
-
>
|
|
165
|
-
<TldrawUiButtonLabel>{labelStr}</TldrawUiButtonLabel>
|
|
166
|
-
{spinner ? <Spinner /> : icon && <TldrawUiButtonIcon icon={icon} />}
|
|
167
|
-
</TldrawUiButton>
|
|
168
|
-
)
|
|
169
|
-
}
|
|
170
169
|
case 'small-icons':
|
|
171
170
|
case 'icons': {
|
|
172
171
|
return (
|
|
@@ -207,6 +206,20 @@ export function TldrawUiMenuItem<
|
|
|
207
206
|
)
|
|
208
207
|
}
|
|
209
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
|
+
}
|
|
210
223
|
return (
|
|
211
224
|
<TldrawUiToolbarButton
|
|
212
225
|
aria-label={labelStr}
|
|
@@ -227,12 +240,26 @@ 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}
|
|
@@ -249,3 +276,178 @@ export function TldrawUiMenuItem<
|
|
|
249
276
|
}
|
|
250
277
|
}
|
|
251
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
|
+
}
|
|
@@ -36,6 +36,7 @@ import { useTranslation } from '../hooks/useTranslation/useTranslation'
|
|
|
36
36
|
import { TLUiIconType } from '../icon-types'
|
|
37
37
|
import { TLUiOverrideHelpers, useDefaultHelpers } from '../overrides'
|
|
38
38
|
import { useA11y } from './a11y'
|
|
39
|
+
import { useTldrawUiComponents } from './components'
|
|
39
40
|
import { TLUiEventSource, useUiEvents } from './events'
|
|
40
41
|
|
|
41
42
|
/** @public */
|
|
@@ -98,6 +99,7 @@ export function ActionsProvider({ overrides, children }: ActionsProviderProps) {
|
|
|
98
99
|
const _editor = useMaybeEditor()
|
|
99
100
|
const showCollaborationUi = useShowCollaborationUi()
|
|
100
101
|
const helpers = useDefaultHelpers()
|
|
102
|
+
const components = useTldrawUiComponents()
|
|
101
103
|
const trackEvent = useUiEvents()
|
|
102
104
|
const a11y = useA11y()
|
|
103
105
|
const msg = useTranslation()
|
|
@@ -176,7 +178,9 @@ export function ActionsProvider({ overrides, children }: ActionsProviderProps) {
|
|
|
176
178
|
kbd: 'cmd+alt+/,ctrl+alt+/',
|
|
177
179
|
onSelect(source) {
|
|
178
180
|
trackEvent('open-kbd-shortcuts', { source })
|
|
179
|
-
helpers.addDialog({
|
|
181
|
+
helpers.addDialog({
|
|
182
|
+
component: components.KeyboardShortcutsDialog ?? DefaultKeyboardShortcutsDialog,
|
|
183
|
+
})
|
|
180
184
|
},
|
|
181
185
|
},
|
|
182
186
|
{
|
|
@@ -1755,7 +1759,17 @@ export function ActionsProvider({ overrides, children }: ActionsProviderProps) {
|
|
|
1755
1759
|
}
|
|
1756
1760
|
|
|
1757
1761
|
return actions
|
|
1758
|
-
}, [
|
|
1762
|
+
}, [
|
|
1763
|
+
helpers,
|
|
1764
|
+
_editor,
|
|
1765
|
+
trackEvent,
|
|
1766
|
+
overrides,
|
|
1767
|
+
defaultDocumentName,
|
|
1768
|
+
showCollaborationUi,
|
|
1769
|
+
msg,
|
|
1770
|
+
a11y,
|
|
1771
|
+
components,
|
|
1772
|
+
])
|
|
1759
1773
|
|
|
1760
1774
|
return <ActionsContext.Provider value={asActions(actions)}>{children}</ActionsContext.Provider>
|
|
1761
1775
|
}
|
|
@@ -1,4 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
assertExists,
|
|
3
|
+
createShapeId,
|
|
4
|
+
Editor,
|
|
5
|
+
GeoShapeGeoStyle,
|
|
6
|
+
getIndicesBetween,
|
|
7
|
+
TLLineShape,
|
|
8
|
+
TLPointerEventInfo,
|
|
9
|
+
TLShapeId,
|
|
10
|
+
toRichText,
|
|
11
|
+
useMaybeEditor,
|
|
12
|
+
} from '@tldraw/editor'
|
|
2
13
|
import * as React from 'react'
|
|
3
14
|
import { EmbedDialog } from '../components/EmbedDialog'
|
|
4
15
|
import { TLUiIconJsx } from '../components/primitives/TldrawUiIcon'
|
|
@@ -19,6 +30,7 @@ export interface TLUiToolItem<
|
|
|
19
30
|
shortcutsLabel?: TranslationKey
|
|
20
31
|
icon: IconType | TLUiIconJsx
|
|
21
32
|
onSelect(source: TLUiEventSource): void
|
|
33
|
+
onDragStart?(source: TLUiEventSource, info: TLPointerEventInfo): void
|
|
22
34
|
/**
|
|
23
35
|
* The keyboard shortcut for this tool. This is a string that can be a single key,
|
|
24
36
|
* or a combination of keys.
|
|
@@ -126,21 +138,28 @@ export function ToolsProvider({ overrides, children }: TLUiToolsProviderProps) {
|
|
|
126
138
|
onToolSelect(source, this)
|
|
127
139
|
},
|
|
128
140
|
},
|
|
129
|
-
...[...GeoShapeGeoStyle.values].map((
|
|
130
|
-
id,
|
|
131
|
-
label: `tool.${
|
|
141
|
+
...[...GeoShapeGeoStyle.values].map((geo) => ({
|
|
142
|
+
id: geo,
|
|
143
|
+
label: `tool.${geo}` as TLUiTranslationKey,
|
|
132
144
|
meta: {
|
|
133
|
-
geo
|
|
145
|
+
geo,
|
|
134
146
|
},
|
|
135
|
-
kbd:
|
|
136
|
-
icon: ('geo-' +
|
|
147
|
+
kbd: geo === 'rectangle' ? 'r' : geo === 'ellipse' ? 'o' : undefined,
|
|
148
|
+
icon: ('geo-' + geo) as TLUiIconType,
|
|
137
149
|
onSelect(source: TLUiEventSource) {
|
|
138
150
|
editor.run(() => {
|
|
139
|
-
editor.setStyleForNextShapes(GeoShapeGeoStyle,
|
|
151
|
+
editor.setStyleForNextShapes(GeoShapeGeoStyle, geo)
|
|
140
152
|
editor.setCurrentTool('geo')
|
|
141
|
-
onToolSelect(source, this, `geo-${
|
|
153
|
+
onToolSelect(source, this, `geo-${geo}`)
|
|
142
154
|
})
|
|
143
155
|
},
|
|
156
|
+
onDragStart(source: TLUiEventSource, info: TLPointerEventInfo) {
|
|
157
|
+
onDragFromToolbarToCreateShape(editor, info, {
|
|
158
|
+
createShape: (id) =>
|
|
159
|
+
editor.createShape({ id, type: 'geo', props: { w: 200, h: 200, geo } }),
|
|
160
|
+
})
|
|
161
|
+
trackEvent('drag-tool', { source, id: 'geo' })
|
|
162
|
+
},
|
|
144
163
|
})),
|
|
145
164
|
{
|
|
146
165
|
id: 'arrow',
|
|
@@ -151,6 +170,17 @@ export function ToolsProvider({ overrides, children }: TLUiToolsProviderProps) {
|
|
|
151
170
|
editor.setCurrentTool('arrow')
|
|
152
171
|
onToolSelect(source, this)
|
|
153
172
|
},
|
|
173
|
+
onDragStart(source: TLUiEventSource, info: TLPointerEventInfo) {
|
|
174
|
+
onDragFromToolbarToCreateShape(editor, info, {
|
|
175
|
+
createShape: (id) =>
|
|
176
|
+
editor.createShape({
|
|
177
|
+
id,
|
|
178
|
+
type: 'arrow',
|
|
179
|
+
props: { start: { x: 0, y: 0 }, end: { x: 200, y: 0 } },
|
|
180
|
+
}),
|
|
181
|
+
})
|
|
182
|
+
trackEvent('drag-tool', { source, id: 'arrow' })
|
|
183
|
+
},
|
|
154
184
|
},
|
|
155
185
|
{
|
|
156
186
|
id: 'line',
|
|
@@ -161,6 +191,24 @@ export function ToolsProvider({ overrides, children }: TLUiToolsProviderProps) {
|
|
|
161
191
|
editor.setCurrentTool('line')
|
|
162
192
|
onToolSelect(source, this)
|
|
163
193
|
},
|
|
194
|
+
onDragStart(source, info) {
|
|
195
|
+
onDragFromToolbarToCreateShape(editor, info, {
|
|
196
|
+
createShape: (id) => {
|
|
197
|
+
const [start, end] = getIndicesBetween(null, null, 2)
|
|
198
|
+
editor.createShape<TLLineShape>({
|
|
199
|
+
id,
|
|
200
|
+
type: 'line',
|
|
201
|
+
props: {
|
|
202
|
+
points: {
|
|
203
|
+
[start]: { id: start, index: start, x: 0, y: 200 },
|
|
204
|
+
[end]: { id: end, index: end, x: 200, y: 0 },
|
|
205
|
+
},
|
|
206
|
+
},
|
|
207
|
+
})
|
|
208
|
+
},
|
|
209
|
+
})
|
|
210
|
+
trackEvent('drag-tool', { source, id: 'line' })
|
|
211
|
+
},
|
|
164
212
|
},
|
|
165
213
|
{
|
|
166
214
|
id: 'frame',
|
|
@@ -171,6 +219,12 @@ export function ToolsProvider({ overrides, children }: TLUiToolsProviderProps) {
|
|
|
171
219
|
editor.setCurrentTool('frame')
|
|
172
220
|
onToolSelect(source, this)
|
|
173
221
|
},
|
|
222
|
+
onDragStart(source, info) {
|
|
223
|
+
onDragFromToolbarToCreateShape(editor, info, {
|
|
224
|
+
createShape: (id) => editor.createShape({ id, type: 'frame' }),
|
|
225
|
+
})
|
|
226
|
+
trackEvent('drag-tool', { source, id: 'frame' })
|
|
227
|
+
},
|
|
174
228
|
},
|
|
175
229
|
{
|
|
176
230
|
id: 'text',
|
|
@@ -181,6 +235,17 @@ export function ToolsProvider({ overrides, children }: TLUiToolsProviderProps) {
|
|
|
181
235
|
editor.setCurrentTool('text')
|
|
182
236
|
onToolSelect(source, this)
|
|
183
237
|
},
|
|
238
|
+
onDragStart(source, info) {
|
|
239
|
+
onDragFromToolbarToCreateShape(editor, info, {
|
|
240
|
+
createShape: (id) =>
|
|
241
|
+
editor.createShape({ id, type: 'text', props: { richText: toRichText('Text') } }),
|
|
242
|
+
onDragEnd: (id) => {
|
|
243
|
+
editor.setEditingShape(id)
|
|
244
|
+
editor.emit('select-all-text', { shapeId: id })
|
|
245
|
+
},
|
|
246
|
+
})
|
|
247
|
+
trackEvent('drag-tool', { source, id: 'text' })
|
|
248
|
+
},
|
|
184
249
|
},
|
|
185
250
|
{
|
|
186
251
|
id: 'asset',
|
|
@@ -201,6 +266,16 @@ export function ToolsProvider({ overrides, children }: TLUiToolsProviderProps) {
|
|
|
201
266
|
editor.setCurrentTool('note')
|
|
202
267
|
onToolSelect(source, this)
|
|
203
268
|
},
|
|
269
|
+
onDragStart(source, info) {
|
|
270
|
+
onDragFromToolbarToCreateShape(editor, info, {
|
|
271
|
+
createShape: (id) => editor.createShape({ id, type: 'note' }),
|
|
272
|
+
onDragEnd: (id) => {
|
|
273
|
+
editor.setEditingShape(id)
|
|
274
|
+
editor.emit('select-all-text', { shapeId: id })
|
|
275
|
+
},
|
|
276
|
+
})
|
|
277
|
+
trackEvent('drag-tool', { source, id: 'note' })
|
|
278
|
+
},
|
|
204
279
|
},
|
|
205
280
|
{
|
|
206
281
|
id: 'laser',
|
|
@@ -244,7 +319,7 @@ export function ToolsProvider({ overrides, children }: TLUiToolsProviderProps) {
|
|
|
244
319
|
}
|
|
245
320
|
|
|
246
321
|
return tools
|
|
247
|
-
}, [overrides, editor, helpers, onToolSelect])
|
|
322
|
+
}, [overrides, editor, helpers, onToolSelect, trackEvent])
|
|
248
323
|
|
|
249
324
|
return <ToolsContext.Provider value={tools}>{children}</ToolsContext.Provider>
|
|
250
325
|
}
|
|
@@ -259,3 +334,58 @@ export function useTools() {
|
|
|
259
334
|
|
|
260
335
|
return ctx
|
|
261
336
|
}
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* Options for {@link onDragFromToolbarToCreateShape}.
|
|
340
|
+
* @public
|
|
341
|
+
*/
|
|
342
|
+
export interface OnDragFromToolbarToCreateShapesOpts {
|
|
343
|
+
/**
|
|
344
|
+
* Create the shape being dragged. You don't need to worry about positioning it, as it'll be
|
|
345
|
+
* immediately updated with the correct position.
|
|
346
|
+
*/
|
|
347
|
+
createShape(id: TLShapeId): void
|
|
348
|
+
/**
|
|
349
|
+
* Called once the drag interaction has finished.
|
|
350
|
+
*/
|
|
351
|
+
onDragEnd?(id: TLShapeId): void
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* A helper method to use in {@link TLUiToolItem#onDragStart} to create a shape by dragging it from
|
|
356
|
+
* the toolbar.
|
|
357
|
+
* @public
|
|
358
|
+
*/
|
|
359
|
+
export function onDragFromToolbarToCreateShape(
|
|
360
|
+
editor: Editor,
|
|
361
|
+
info: TLPointerEventInfo,
|
|
362
|
+
opts: OnDragFromToolbarToCreateShapesOpts
|
|
363
|
+
) {
|
|
364
|
+
const { x, y } = editor.inputs.currentPagePoint
|
|
365
|
+
|
|
366
|
+
const stoppingPoint = editor.markHistoryStoppingPoint('drag shape tool')
|
|
367
|
+
editor.setCurrentTool('select.translating')
|
|
368
|
+
|
|
369
|
+
const id = createShapeId()
|
|
370
|
+
opts.createShape(id)
|
|
371
|
+
const shape = assertExists(editor.getShape(id), 'Shape not found')
|
|
372
|
+
|
|
373
|
+
const { w, h } = editor.getShapePageBounds(id)!
|
|
374
|
+
editor.updateShape({ id, type: shape.type, x: x - w / 2, y: y - h / 2 })
|
|
375
|
+
editor.select(id)
|
|
376
|
+
|
|
377
|
+
editor.setCurrentTool('select.translating', {
|
|
378
|
+
...info,
|
|
379
|
+
target: 'shape',
|
|
380
|
+
shape: editor.getShape(id),
|
|
381
|
+
isCreating: true,
|
|
382
|
+
creatingMarkId: stoppingPoint,
|
|
383
|
+
onCreate() {
|
|
384
|
+
editor.setCurrentTool('select.idle')
|
|
385
|
+
editor.select(id)
|
|
386
|
+
opts.onDragEnd?.(id)
|
|
387
|
+
},
|
|
388
|
+
})
|
|
389
|
+
|
|
390
|
+
editor.getCurrentTool().setCurrentToolIdMask(shape.type)
|
|
391
|
+
}
|
package/src/lib/ui/version.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// This file is automatically generated by internal/scripts/refresh-assets.ts.
|
|
2
2
|
// Do not edit manually. Or do, I'm a comment, not a cop.
|
|
3
3
|
|
|
4
|
-
export const version = '3.16.0-next.
|
|
4
|
+
export const version = '3.16.0-next.6611943ca24a'
|
|
5
5
|
export const publishDates = {
|
|
6
6
|
major: '2024-09-13T14:36:29.063Z',
|
|
7
|
-
minor: '2025-08-
|
|
8
|
-
patch: '2025-08-
|
|
7
|
+
minor: '2025-08-20T10:14:38.875Z',
|
|
8
|
+
patch: '2025-08-20T10:14:38.875Z',
|
|
9
9
|
}
|