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,5 +1,12 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
assertExists,
|
|
4
|
+
createShapeId,
|
|
5
|
+
GeoShapeGeoStyle,
|
|
6
|
+
getIndicesBetween,
|
|
7
|
+
toRichText,
|
|
8
|
+
useMaybeEditor
|
|
9
|
+
} from "@tldraw/editor";
|
|
3
10
|
import * as React from "react";
|
|
4
11
|
import { EmbedDialog } from "../components/EmbedDialog.mjs";
|
|
5
12
|
import { useA11y } from "../context/a11y.mjs";
|
|
@@ -70,20 +77,26 @@ function ToolsProvider({ overrides, children }) {
|
|
|
70
77
|
onToolSelect(source, this);
|
|
71
78
|
}
|
|
72
79
|
},
|
|
73
|
-
...[...GeoShapeGeoStyle.values].map((
|
|
74
|
-
id,
|
|
75
|
-
label: `tool.${
|
|
80
|
+
...[...GeoShapeGeoStyle.values].map((geo) => ({
|
|
81
|
+
id: geo,
|
|
82
|
+
label: `tool.${geo}`,
|
|
76
83
|
meta: {
|
|
77
|
-
geo
|
|
84
|
+
geo
|
|
78
85
|
},
|
|
79
|
-
kbd:
|
|
80
|
-
icon: "geo-" +
|
|
86
|
+
kbd: geo === "rectangle" ? "r" : geo === "ellipse" ? "o" : void 0,
|
|
87
|
+
icon: "geo-" + geo,
|
|
81
88
|
onSelect(source) {
|
|
82
89
|
editor.run(() => {
|
|
83
|
-
editor.setStyleForNextShapes(GeoShapeGeoStyle,
|
|
90
|
+
editor.setStyleForNextShapes(GeoShapeGeoStyle, geo);
|
|
84
91
|
editor.setCurrentTool("geo");
|
|
85
|
-
onToolSelect(source, this, `geo-${
|
|
92
|
+
onToolSelect(source, this, `geo-${geo}`);
|
|
86
93
|
});
|
|
94
|
+
},
|
|
95
|
+
onDragStart(source, info) {
|
|
96
|
+
onDragFromToolbarToCreateShape(editor, info, {
|
|
97
|
+
createShape: (id) => editor.createShape({ id, type: "geo", props: { w: 200, h: 200, geo } })
|
|
98
|
+
});
|
|
99
|
+
trackEvent("drag-tool", { source, id: "geo" });
|
|
87
100
|
}
|
|
88
101
|
})),
|
|
89
102
|
{
|
|
@@ -94,6 +107,16 @@ function ToolsProvider({ overrides, children }) {
|
|
|
94
107
|
onSelect(source) {
|
|
95
108
|
editor.setCurrentTool("arrow");
|
|
96
109
|
onToolSelect(source, this);
|
|
110
|
+
},
|
|
111
|
+
onDragStart(source, info) {
|
|
112
|
+
onDragFromToolbarToCreateShape(editor, info, {
|
|
113
|
+
createShape: (id) => editor.createShape({
|
|
114
|
+
id,
|
|
115
|
+
type: "arrow",
|
|
116
|
+
props: { start: { x: 0, y: 0 }, end: { x: 200, y: 0 } }
|
|
117
|
+
})
|
|
118
|
+
});
|
|
119
|
+
trackEvent("drag-tool", { source, id: "arrow" });
|
|
97
120
|
}
|
|
98
121
|
},
|
|
99
122
|
{
|
|
@@ -104,6 +127,24 @@ function ToolsProvider({ overrides, children }) {
|
|
|
104
127
|
onSelect(source) {
|
|
105
128
|
editor.setCurrentTool("line");
|
|
106
129
|
onToolSelect(source, this);
|
|
130
|
+
},
|
|
131
|
+
onDragStart(source, info) {
|
|
132
|
+
onDragFromToolbarToCreateShape(editor, info, {
|
|
133
|
+
createShape: (id) => {
|
|
134
|
+
const [start, end] = getIndicesBetween(null, null, 2);
|
|
135
|
+
editor.createShape({
|
|
136
|
+
id,
|
|
137
|
+
type: "line",
|
|
138
|
+
props: {
|
|
139
|
+
points: {
|
|
140
|
+
[start]: { id: start, index: start, x: 0, y: 200 },
|
|
141
|
+
[end]: { id: end, index: end, x: 200, y: 0 }
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
trackEvent("drag-tool", { source, id: "line" });
|
|
107
148
|
}
|
|
108
149
|
},
|
|
109
150
|
{
|
|
@@ -114,6 +155,12 @@ function ToolsProvider({ overrides, children }) {
|
|
|
114
155
|
onSelect(source) {
|
|
115
156
|
editor.setCurrentTool("frame");
|
|
116
157
|
onToolSelect(source, this);
|
|
158
|
+
},
|
|
159
|
+
onDragStart(source, info) {
|
|
160
|
+
onDragFromToolbarToCreateShape(editor, info, {
|
|
161
|
+
createShape: (id) => editor.createShape({ id, type: "frame" })
|
|
162
|
+
});
|
|
163
|
+
trackEvent("drag-tool", { source, id: "frame" });
|
|
117
164
|
}
|
|
118
165
|
},
|
|
119
166
|
{
|
|
@@ -124,6 +171,16 @@ function ToolsProvider({ overrides, children }) {
|
|
|
124
171
|
onSelect(source) {
|
|
125
172
|
editor.setCurrentTool("text");
|
|
126
173
|
onToolSelect(source, this);
|
|
174
|
+
},
|
|
175
|
+
onDragStart(source, info) {
|
|
176
|
+
onDragFromToolbarToCreateShape(editor, info, {
|
|
177
|
+
createShape: (id) => editor.createShape({ id, type: "text", props: { richText: toRichText("Text") } }),
|
|
178
|
+
onDragEnd: (id) => {
|
|
179
|
+
editor.setEditingShape(id);
|
|
180
|
+
editor.emit("select-all-text", { shapeId: id });
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
trackEvent("drag-tool", { source, id: "text" });
|
|
127
184
|
}
|
|
128
185
|
},
|
|
129
186
|
{
|
|
@@ -144,6 +201,16 @@ function ToolsProvider({ overrides, children }) {
|
|
|
144
201
|
onSelect(source) {
|
|
145
202
|
editor.setCurrentTool("note");
|
|
146
203
|
onToolSelect(source, this);
|
|
204
|
+
},
|
|
205
|
+
onDragStart(source, info) {
|
|
206
|
+
onDragFromToolbarToCreateShape(editor, info, {
|
|
207
|
+
createShape: (id) => editor.createShape({ id, type: "note" }),
|
|
208
|
+
onDragEnd: (id) => {
|
|
209
|
+
editor.setEditingShape(id);
|
|
210
|
+
editor.emit("select-all-text", { shapeId: id });
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
trackEvent("drag-tool", { source, id: "note" });
|
|
147
214
|
}
|
|
148
215
|
},
|
|
149
216
|
{
|
|
@@ -184,7 +251,7 @@ function ToolsProvider({ overrides, children }) {
|
|
|
184
251
|
return overrides(editor, tools2, helpers);
|
|
185
252
|
}
|
|
186
253
|
return tools2;
|
|
187
|
-
}, [overrides, editor, helpers, onToolSelect]);
|
|
254
|
+
}, [overrides, editor, helpers, onToolSelect, trackEvent]);
|
|
188
255
|
return /* @__PURE__ */ jsx(ToolsContext.Provider, { value: tools, children });
|
|
189
256
|
}
|
|
190
257
|
function useTools() {
|
|
@@ -194,9 +261,34 @@ function useTools() {
|
|
|
194
261
|
}
|
|
195
262
|
return ctx;
|
|
196
263
|
}
|
|
264
|
+
function onDragFromToolbarToCreateShape(editor, info, opts) {
|
|
265
|
+
const { x, y } = editor.inputs.currentPagePoint;
|
|
266
|
+
const stoppingPoint = editor.markHistoryStoppingPoint("drag shape tool");
|
|
267
|
+
editor.setCurrentTool("select.translating");
|
|
268
|
+
const id = createShapeId();
|
|
269
|
+
opts.createShape(id);
|
|
270
|
+
const shape = assertExists(editor.getShape(id), "Shape not found");
|
|
271
|
+
const { w, h } = editor.getShapePageBounds(id);
|
|
272
|
+
editor.updateShape({ id, type: shape.type, x: x - w / 2, y: y - h / 2 });
|
|
273
|
+
editor.select(id);
|
|
274
|
+
editor.setCurrentTool("select.translating", {
|
|
275
|
+
...info,
|
|
276
|
+
target: "shape",
|
|
277
|
+
shape: editor.getShape(id),
|
|
278
|
+
isCreating: true,
|
|
279
|
+
creatingMarkId: stoppingPoint,
|
|
280
|
+
onCreate() {
|
|
281
|
+
editor.setCurrentTool("select.idle");
|
|
282
|
+
editor.select(id);
|
|
283
|
+
opts.onDragEnd?.(id);
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
editor.getCurrentTool().setCurrentToolIdMask(shape.type);
|
|
287
|
+
}
|
|
197
288
|
export {
|
|
198
289
|
ToolsContext,
|
|
199
290
|
ToolsProvider,
|
|
291
|
+
onDragFromToolbarToCreateShape,
|
|
200
292
|
useTools
|
|
201
293
|
};
|
|
202
294
|
//# sourceMappingURL=useTools.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/lib/ui/hooks/useTools.tsx"],
|
|
4
|
-
"sourcesContent": ["import { Editor, GeoShapeGeoStyle, useMaybeEditor } from '@tldraw/editor'\nimport * as React from 'react'\nimport { EmbedDialog } from '../components/EmbedDialog'\nimport { TLUiIconJsx } from '../components/primitives/TldrawUiIcon'\nimport { useA11y } from '../context/a11y'\nimport { TLUiEventSource, useUiEvents } from '../context/events'\nimport { TLUiIconType } from '../icon-types'\nimport { TLUiOverrideHelpers, useDefaultHelpers } from '../overrides'\nimport { TLUiTranslationKey } from './useTranslation/TLUiTranslationKey'\nimport { useTranslation } from './useTranslation/useTranslation'\n\n/** @public */\nexport interface TLUiToolItem<\n\tTranslationKey extends string = string,\n\tIconType extends string = string,\n> {\n\tid: string\n\tlabel: TranslationKey\n\tshortcutsLabel?: TranslationKey\n\ticon: IconType | TLUiIconJsx\n\tonSelect(source: TLUiEventSource): void\n\t/**\n\t * The keyboard shortcut for this tool. This is a string that can be a single key,\n\t * or a combination of keys.\n\t * For example, `cmd+z` or `cmd+shift+z` or `cmd+u,ctrl+u`, or just `v` or `a`.\n\t * We have backwards compatibility with the old system, where we used to use\n\t * symbols to denote cmd/alt/shift, using `!` for shift, `$` for cmd, and `?` for alt.\n\t */\n\tkbd?: string\n\treadonlyOk?: boolean\n\tmeta?: {\n\t\t[key: string]: any\n\t}\n}\n\n/** @public */\nexport type TLUiToolsContextType = Record<string, TLUiToolItem>\n\n/** @internal */\nexport const ToolsContext = React.createContext<null | TLUiToolsContextType>(null)\n\n/** @public */\nexport interface TLUiToolsProviderProps {\n\toverrides?(\n\t\teditor: Editor,\n\t\ttools: TLUiToolsContextType,\n\t\thelpers: Partial<TLUiOverrideHelpers>\n\t): TLUiToolsContextType\n\tchildren: React.ReactNode\n}\n\n/** @internal */\nexport function ToolsProvider({ overrides, children }: TLUiToolsProviderProps) {\n\tconst editor = useMaybeEditor()\n\tconst trackEvent = useUiEvents()\n\n\tconst a11y = useA11y()\n\tconst msg = useTranslation()\n\tconst helpers = useDefaultHelpers()\n\n\tconst onToolSelect = React.useCallback(\n\t\t(\n\t\t\tsource: TLUiEventSource,\n\t\t\ttool: TLUiToolItem<TLUiTranslationKey, TLUiIconType>,\n\t\t\tid?: string\n\t\t) => {\n\t\t\ta11y.announce({ msg: msg(tool.label) })\n\t\t\ttrackEvent('select-tool', { source, id: id ?? tool.id })\n\t\t},\n\t\t[a11y, msg, trackEvent]\n\t)\n\n\tconst tools = React.useMemo<TLUiToolsContextType>(() => {\n\t\tif (!editor) return {}\n\t\tconst toolsArray: TLUiToolItem<TLUiTranslationKey, TLUiIconType>[] = [\n\t\t\t{\n\t\t\t\tid: 'select',\n\t\t\t\tlabel: 'tool.select',\n\t\t\t\ticon: 'tool-pointer',\n\t\t\t\tkbd: 'v',\n\t\t\t\treadonlyOk: true,\n\t\t\t\tonSelect(source) {\n\t\t\t\t\tif (editor.isIn('select')) {\n\t\t\t\t\t\t// There's a quirk of select mode, where editing a shape is a sub-state of select.\n\t\t\t\t\t\t// Because the text tool can be locked/sticky, we need to make sure we exit the\n\t\t\t\t\t\t// text tool.\n\t\t\t\t\t\t//\n\t\t\t\t\t\t// psst, if you're changing this code, also change the code\n\t\t\t\t\t\t// in strange-tools.test.ts! Sadly it's duplicated there.\n\t\t\t\t\t\tconst currentNode = editor.root.getCurrent()!\n\t\t\t\t\t\tcurrentNode.exit({}, currentNode.id)\n\t\t\t\t\t\tcurrentNode.enter({}, currentNode.id)\n\t\t\t\t\t}\n\t\t\t\t\teditor.setCurrentTool('select')\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'hand',\n\t\t\t\tlabel: 'tool.hand',\n\t\t\t\ticon: 'tool-hand',\n\t\t\t\tkbd: 'h',\n\t\t\t\treadonlyOk: true,\n\t\t\t\tonSelect(source) {\n\t\t\t\t\teditor.setCurrentTool('hand')\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'eraser',\n\t\t\t\tlabel: 'tool.eraser',\n\t\t\t\ticon: 'tool-eraser',\n\t\t\t\tkbd: 'e',\n\t\t\t\tonSelect(source) {\n\t\t\t\t\teditor.setCurrentTool('eraser')\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'draw',\n\t\t\t\tlabel: 'tool.draw',\n\t\t\t\ticon: 'tool-pencil',\n\t\t\t\tkbd: 'd,b,x',\n\t\t\t\tonSelect(source) {\n\t\t\t\t\teditor.setCurrentTool('draw')\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t},\n\t\t\t...[...GeoShapeGeoStyle.values].map((id) => ({\n\t\t\t\tid,\n\t\t\t\tlabel: `tool.${id}` as TLUiTranslationKey,\n\t\t\t\tmeta: {\n\t\t\t\t\tgeo: id,\n\t\t\t\t},\n\t\t\t\tkbd: id === 'rectangle' ? 'r' : id === 'ellipse' ? 'o' : undefined,\n\t\t\t\ticon: ('geo-' + id) as TLUiIconType,\n\t\t\t\tonSelect(source: TLUiEventSource) {\n\t\t\t\t\teditor.run(() => {\n\t\t\t\t\t\teditor.setStyleForNextShapes(GeoShapeGeoStyle, id)\n\t\t\t\t\t\teditor.setCurrentTool('geo')\n\t\t\t\t\t\tonToolSelect(source, this, `geo-${id}`)\n\t\t\t\t\t})\n\t\t\t\t},\n\t\t\t})),\n\t\t\t{\n\t\t\t\tid: 'arrow',\n\t\t\t\tlabel: 'tool.arrow',\n\t\t\t\ticon: 'tool-arrow',\n\t\t\t\tkbd: 'a',\n\t\t\t\tonSelect(source) {\n\t\t\t\t\teditor.setCurrentTool('arrow')\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'line',\n\t\t\t\tlabel: 'tool.line',\n\t\t\t\ticon: 'tool-line',\n\t\t\t\tkbd: 'l',\n\t\t\t\tonSelect(source) {\n\t\t\t\t\teditor.setCurrentTool('line')\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'frame',\n\t\t\t\tlabel: 'tool.frame',\n\t\t\t\ticon: 'tool-frame',\n\t\t\t\tkbd: 'f',\n\t\t\t\tonSelect(source) {\n\t\t\t\t\teditor.setCurrentTool('frame')\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'text',\n\t\t\t\tlabel: 'tool.text',\n\t\t\t\ticon: 'tool-text',\n\t\t\t\tkbd: 't',\n\t\t\t\tonSelect(source) {\n\t\t\t\t\teditor.setCurrentTool('text')\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'asset',\n\t\t\t\tlabel: 'tool.media',\n\t\t\t\ticon: 'tool-media',\n\t\t\t\tkbd: 'cmd+u,ctrl+u',\n\t\t\t\tonSelect(source) {\n\t\t\t\t\thelpers.insertMedia()\n\t\t\t\t\tonToolSelect(source, this, 'media')\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'note',\n\t\t\t\tlabel: 'tool.note',\n\t\t\t\ticon: 'tool-note',\n\t\t\t\tkbd: 'n',\n\t\t\t\tonSelect(source) {\n\t\t\t\t\teditor.setCurrentTool('note')\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'laser',\n\t\t\t\tlabel: 'tool.laser',\n\t\t\t\treadonlyOk: true,\n\t\t\t\ticon: 'tool-laser',\n\t\t\t\tkbd: 'k',\n\t\t\t\tonSelect(source) {\n\t\t\t\t\teditor.setCurrentTool('laser')\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'embed',\n\t\t\t\tlabel: 'tool.embed',\n\t\t\t\ticon: 'dot',\n\t\t\t\tonSelect(source) {\n\t\t\t\t\thelpers.addDialog({ component: EmbedDialog })\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'highlight',\n\t\t\t\tlabel: 'tool.highlight',\n\t\t\t\ticon: 'tool-highlight',\n\t\t\t\t// TODO: pick a better shortcut\n\t\t\t\tkbd: 'shift+d',\n\t\t\t\tonSelect(source) {\n\t\t\t\t\teditor.setCurrentTool('highlight')\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t},\n\t\t]\n\n\t\ttoolsArray.forEach((t) => (t.onSelect = t.onSelect.bind(t)))\n\n\t\tconst tools = Object.fromEntries(toolsArray.map((t) => [t.id, t]))\n\n\t\tif (overrides) {\n\t\t\treturn overrides(editor, tools, helpers)\n\t\t}\n\n\t\treturn tools\n\t}, [overrides, editor, helpers, onToolSelect])\n\n\treturn <ToolsContext.Provider value={tools}>{children}</ToolsContext.Provider>\n}\n\n/** @public */\nexport function useTools() {\n\tconst ctx = React.useContext(ToolsContext)\n\n\tif (!ctx) {\n\t\tthrow new Error('useTools must be used within a ToolProvider')\n\t}\n\n\treturn ctx\n}\n"],
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import {\n\tassertExists,\n\tcreateShapeId,\n\tEditor,\n\tGeoShapeGeoStyle,\n\tgetIndicesBetween,\n\tTLLineShape,\n\tTLPointerEventInfo,\n\tTLShapeId,\n\ttoRichText,\n\tuseMaybeEditor,\n} from '@tldraw/editor'\nimport * as React from 'react'\nimport { EmbedDialog } from '../components/EmbedDialog'\nimport { TLUiIconJsx } from '../components/primitives/TldrawUiIcon'\nimport { useA11y } from '../context/a11y'\nimport { TLUiEventSource, useUiEvents } from '../context/events'\nimport { TLUiIconType } from '../icon-types'\nimport { TLUiOverrideHelpers, useDefaultHelpers } from '../overrides'\nimport { TLUiTranslationKey } from './useTranslation/TLUiTranslationKey'\nimport { useTranslation } from './useTranslation/useTranslation'\n\n/** @public */\nexport interface TLUiToolItem<\n\tTranslationKey extends string = string,\n\tIconType extends string = string,\n> {\n\tid: string\n\tlabel: TranslationKey\n\tshortcutsLabel?: TranslationKey\n\ticon: IconType | TLUiIconJsx\n\tonSelect(source: TLUiEventSource): void\n\tonDragStart?(source: TLUiEventSource, info: TLPointerEventInfo): void\n\t/**\n\t * The keyboard shortcut for this tool. This is a string that can be a single key,\n\t * or a combination of keys.\n\t * For example, `cmd+z` or `cmd+shift+z` or `cmd+u,ctrl+u`, or just `v` or `a`.\n\t * We have backwards compatibility with the old system, where we used to use\n\t * symbols to denote cmd/alt/shift, using `!` for shift, `$` for cmd, and `?` for alt.\n\t */\n\tkbd?: string\n\treadonlyOk?: boolean\n\tmeta?: {\n\t\t[key: string]: any\n\t}\n}\n\n/** @public */\nexport type TLUiToolsContextType = Record<string, TLUiToolItem>\n\n/** @internal */\nexport const ToolsContext = React.createContext<null | TLUiToolsContextType>(null)\n\n/** @public */\nexport interface TLUiToolsProviderProps {\n\toverrides?(\n\t\teditor: Editor,\n\t\ttools: TLUiToolsContextType,\n\t\thelpers: Partial<TLUiOverrideHelpers>\n\t): TLUiToolsContextType\n\tchildren: React.ReactNode\n}\n\n/** @internal */\nexport function ToolsProvider({ overrides, children }: TLUiToolsProviderProps) {\n\tconst editor = useMaybeEditor()\n\tconst trackEvent = useUiEvents()\n\n\tconst a11y = useA11y()\n\tconst msg = useTranslation()\n\tconst helpers = useDefaultHelpers()\n\n\tconst onToolSelect = React.useCallback(\n\t\t(\n\t\t\tsource: TLUiEventSource,\n\t\t\ttool: TLUiToolItem<TLUiTranslationKey, TLUiIconType>,\n\t\t\tid?: string\n\t\t) => {\n\t\t\ta11y.announce({ msg: msg(tool.label) })\n\t\t\ttrackEvent('select-tool', { source, id: id ?? tool.id })\n\t\t},\n\t\t[a11y, msg, trackEvent]\n\t)\n\n\tconst tools = React.useMemo<TLUiToolsContextType>(() => {\n\t\tif (!editor) return {}\n\t\tconst toolsArray: TLUiToolItem<TLUiTranslationKey, TLUiIconType>[] = [\n\t\t\t{\n\t\t\t\tid: 'select',\n\t\t\t\tlabel: 'tool.select',\n\t\t\t\ticon: 'tool-pointer',\n\t\t\t\tkbd: 'v',\n\t\t\t\treadonlyOk: true,\n\t\t\t\tonSelect(source) {\n\t\t\t\t\tif (editor.isIn('select')) {\n\t\t\t\t\t\t// There's a quirk of select mode, where editing a shape is a sub-state of select.\n\t\t\t\t\t\t// Because the text tool can be locked/sticky, we need to make sure we exit the\n\t\t\t\t\t\t// text tool.\n\t\t\t\t\t\t//\n\t\t\t\t\t\t// psst, if you're changing this code, also change the code\n\t\t\t\t\t\t// in strange-tools.test.ts! Sadly it's duplicated there.\n\t\t\t\t\t\tconst currentNode = editor.root.getCurrent()!\n\t\t\t\t\t\tcurrentNode.exit({}, currentNode.id)\n\t\t\t\t\t\tcurrentNode.enter({}, currentNode.id)\n\t\t\t\t\t}\n\t\t\t\t\teditor.setCurrentTool('select')\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'hand',\n\t\t\t\tlabel: 'tool.hand',\n\t\t\t\ticon: 'tool-hand',\n\t\t\t\tkbd: 'h',\n\t\t\t\treadonlyOk: true,\n\t\t\t\tonSelect(source) {\n\t\t\t\t\teditor.setCurrentTool('hand')\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'eraser',\n\t\t\t\tlabel: 'tool.eraser',\n\t\t\t\ticon: 'tool-eraser',\n\t\t\t\tkbd: 'e',\n\t\t\t\tonSelect(source) {\n\t\t\t\t\teditor.setCurrentTool('eraser')\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'draw',\n\t\t\t\tlabel: 'tool.draw',\n\t\t\t\ticon: 'tool-pencil',\n\t\t\t\tkbd: 'd,b,x',\n\t\t\t\tonSelect(source) {\n\t\t\t\t\teditor.setCurrentTool('draw')\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t},\n\t\t\t...[...GeoShapeGeoStyle.values].map((geo) => ({\n\t\t\t\tid: geo,\n\t\t\t\tlabel: `tool.${geo}` as TLUiTranslationKey,\n\t\t\t\tmeta: {\n\t\t\t\t\tgeo,\n\t\t\t\t},\n\t\t\t\tkbd: geo === 'rectangle' ? 'r' : geo === 'ellipse' ? 'o' : undefined,\n\t\t\t\ticon: ('geo-' + geo) as TLUiIconType,\n\t\t\t\tonSelect(source: TLUiEventSource) {\n\t\t\t\t\teditor.run(() => {\n\t\t\t\t\t\teditor.setStyleForNextShapes(GeoShapeGeoStyle, geo)\n\t\t\t\t\t\teditor.setCurrentTool('geo')\n\t\t\t\t\t\tonToolSelect(source, this, `geo-${geo}`)\n\t\t\t\t\t})\n\t\t\t\t},\n\t\t\t\tonDragStart(source: TLUiEventSource, info: TLPointerEventInfo) {\n\t\t\t\t\tonDragFromToolbarToCreateShape(editor, info, {\n\t\t\t\t\t\tcreateShape: (id) =>\n\t\t\t\t\t\t\teditor.createShape({ id, type: 'geo', props: { w: 200, h: 200, geo } }),\n\t\t\t\t\t})\n\t\t\t\t\ttrackEvent('drag-tool', { source, id: 'geo' })\n\t\t\t\t},\n\t\t\t})),\n\t\t\t{\n\t\t\t\tid: 'arrow',\n\t\t\t\tlabel: 'tool.arrow',\n\t\t\t\ticon: 'tool-arrow',\n\t\t\t\tkbd: 'a',\n\t\t\t\tonSelect(source) {\n\t\t\t\t\teditor.setCurrentTool('arrow')\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t\tonDragStart(source: TLUiEventSource, info: TLPointerEventInfo) {\n\t\t\t\t\tonDragFromToolbarToCreateShape(editor, info, {\n\t\t\t\t\t\tcreateShape: (id) =>\n\t\t\t\t\t\t\teditor.createShape({\n\t\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t\t\ttype: 'arrow',\n\t\t\t\t\t\t\t\tprops: { start: { x: 0, y: 0 }, end: { x: 200, y: 0 } },\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t})\n\t\t\t\t\ttrackEvent('drag-tool', { source, id: 'arrow' })\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'line',\n\t\t\t\tlabel: 'tool.line',\n\t\t\t\ticon: 'tool-line',\n\t\t\t\tkbd: 'l',\n\t\t\t\tonSelect(source) {\n\t\t\t\t\teditor.setCurrentTool('line')\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t\tonDragStart(source, info) {\n\t\t\t\t\tonDragFromToolbarToCreateShape(editor, info, {\n\t\t\t\t\t\tcreateShape: (id) => {\n\t\t\t\t\t\t\tconst [start, end] = getIndicesBetween(null, null, 2)\n\t\t\t\t\t\t\teditor.createShape<TLLineShape>({\n\t\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t\t\ttype: 'line',\n\t\t\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t\t\tpoints: {\n\t\t\t\t\t\t\t\t\t\t[start]: { id: start, index: start, x: 0, y: 200 },\n\t\t\t\t\t\t\t\t\t\t[end]: { id: end, index: end, x: 200, y: 0 },\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\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\ttrackEvent('drag-tool', { source, id: 'line' })\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'frame',\n\t\t\t\tlabel: 'tool.frame',\n\t\t\t\ticon: 'tool-frame',\n\t\t\t\tkbd: 'f',\n\t\t\t\tonSelect(source) {\n\t\t\t\t\teditor.setCurrentTool('frame')\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t\tonDragStart(source, info) {\n\t\t\t\t\tonDragFromToolbarToCreateShape(editor, info, {\n\t\t\t\t\t\tcreateShape: (id) => editor.createShape({ id, type: 'frame' }),\n\t\t\t\t\t})\n\t\t\t\t\ttrackEvent('drag-tool', { source, id: 'frame' })\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'text',\n\t\t\t\tlabel: 'tool.text',\n\t\t\t\ticon: 'tool-text',\n\t\t\t\tkbd: 't',\n\t\t\t\tonSelect(source) {\n\t\t\t\t\teditor.setCurrentTool('text')\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t\tonDragStart(source, info) {\n\t\t\t\t\tonDragFromToolbarToCreateShape(editor, info, {\n\t\t\t\t\t\tcreateShape: (id) =>\n\t\t\t\t\t\t\teditor.createShape({ id, type: 'text', props: { richText: toRichText('Text') } }),\n\t\t\t\t\t\tonDragEnd: (id) => {\n\t\t\t\t\t\t\teditor.setEditingShape(id)\n\t\t\t\t\t\t\teditor.emit('select-all-text', { shapeId: id })\n\t\t\t\t\t\t},\n\t\t\t\t\t})\n\t\t\t\t\ttrackEvent('drag-tool', { source, id: 'text' })\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'asset',\n\t\t\t\tlabel: 'tool.media',\n\t\t\t\ticon: 'tool-media',\n\t\t\t\tkbd: 'cmd+u,ctrl+u',\n\t\t\t\tonSelect(source) {\n\t\t\t\t\thelpers.insertMedia()\n\t\t\t\t\tonToolSelect(source, this, 'media')\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'note',\n\t\t\t\tlabel: 'tool.note',\n\t\t\t\ticon: 'tool-note',\n\t\t\t\tkbd: 'n',\n\t\t\t\tonSelect(source) {\n\t\t\t\t\teditor.setCurrentTool('note')\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t\tonDragStart(source, info) {\n\t\t\t\t\tonDragFromToolbarToCreateShape(editor, info, {\n\t\t\t\t\t\tcreateShape: (id) => editor.createShape({ id, type: 'note' }),\n\t\t\t\t\t\tonDragEnd: (id) => {\n\t\t\t\t\t\t\teditor.setEditingShape(id)\n\t\t\t\t\t\t\teditor.emit('select-all-text', { shapeId: id })\n\t\t\t\t\t\t},\n\t\t\t\t\t})\n\t\t\t\t\ttrackEvent('drag-tool', { source, id: 'note' })\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'laser',\n\t\t\t\tlabel: 'tool.laser',\n\t\t\t\treadonlyOk: true,\n\t\t\t\ticon: 'tool-laser',\n\t\t\t\tkbd: 'k',\n\t\t\t\tonSelect(source) {\n\t\t\t\t\teditor.setCurrentTool('laser')\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'embed',\n\t\t\t\tlabel: 'tool.embed',\n\t\t\t\ticon: 'dot',\n\t\t\t\tonSelect(source) {\n\t\t\t\t\thelpers.addDialog({ component: EmbedDialog })\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: 'highlight',\n\t\t\t\tlabel: 'tool.highlight',\n\t\t\t\ticon: 'tool-highlight',\n\t\t\t\t// TODO: pick a better shortcut\n\t\t\t\tkbd: 'shift+d',\n\t\t\t\tonSelect(source) {\n\t\t\t\t\teditor.setCurrentTool('highlight')\n\t\t\t\t\tonToolSelect(source, this)\n\t\t\t\t},\n\t\t\t},\n\t\t]\n\n\t\ttoolsArray.forEach((t) => (t.onSelect = t.onSelect.bind(t)))\n\n\t\tconst tools = Object.fromEntries(toolsArray.map((t) => [t.id, t]))\n\n\t\tif (overrides) {\n\t\t\treturn overrides(editor, tools, helpers)\n\t\t}\n\n\t\treturn tools\n\t}, [overrides, editor, helpers, onToolSelect, trackEvent])\n\n\treturn <ToolsContext.Provider value={tools}>{children}</ToolsContext.Provider>\n}\n\n/** @public */\nexport function useTools() {\n\tconst ctx = React.useContext(ToolsContext)\n\n\tif (!ctx) {\n\t\tthrow new Error('useTools must be used within a ToolProvider')\n\t}\n\n\treturn ctx\n}\n\n/**\n * Options for {@link onDragFromToolbarToCreateShape}.\n * @public\n */\nexport interface OnDragFromToolbarToCreateShapesOpts {\n\t/**\n\t * Create the shape being dragged. You don't need to worry about positioning it, as it'll be\n\t * immediately updated with the correct position.\n\t */\n\tcreateShape(id: TLShapeId): void\n\t/**\n\t * Called once the drag interaction has finished.\n\t */\n\tonDragEnd?(id: TLShapeId): void\n}\n\n/**\n * A helper method to use in {@link TLUiToolItem#onDragStart} to create a shape by dragging it from\n * the toolbar.\n * @public\n */\nexport function onDragFromToolbarToCreateShape(\n\teditor: Editor,\n\tinfo: TLPointerEventInfo,\n\topts: OnDragFromToolbarToCreateShapesOpts\n) {\n\tconst { x, y } = editor.inputs.currentPagePoint\n\n\tconst stoppingPoint = editor.markHistoryStoppingPoint('drag shape tool')\n\teditor.setCurrentTool('select.translating')\n\n\tconst id = createShapeId()\n\topts.createShape(id)\n\tconst shape = assertExists(editor.getShape(id), 'Shape not found')\n\n\tconst { w, h } = editor.getShapePageBounds(id)!\n\teditor.updateShape({ id, type: shape.type, x: x - w / 2, y: y - h / 2 })\n\teditor.select(id)\n\n\teditor.setCurrentTool('select.translating', {\n\t\t...info,\n\t\ttarget: 'shape',\n\t\tshape: editor.getShape(id),\n\t\tisCreating: true,\n\t\tcreatingMarkId: stoppingPoint,\n\t\tonCreate() {\n\t\t\teditor.setCurrentTool('select.idle')\n\t\t\teditor.select(id)\n\t\t\topts.onDragEnd?.(id)\n\t\t},\n\t})\n\n\teditor.getCurrentTool().setCurrentToolIdMask(shape.type)\n}\n"],
|
|
5
|
+
"mappings": "AAmUQ;AAnUR;AAAA,EACC;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EAIA;AAAA,EACA;AAAA,OACM;AACP,YAAY,WAAW;AACvB,SAAS,mBAAmB;AAE5B,SAAS,eAAe;AACxB,SAA0B,mBAAmB;AAE7C,SAA8B,yBAAyB;AAEvD,SAAS,sBAAsB;AA+BxB,MAAM,eAAe,MAAM,cAA2C,IAAI;AAa1E,SAAS,cAAc,EAAE,WAAW,SAAS,GAA2B;AAC9E,QAAM,SAAS,eAAe;AAC9B,QAAM,aAAa,YAAY;AAE/B,QAAM,OAAO,QAAQ;AACrB,QAAM,MAAM,eAAe;AAC3B,QAAM,UAAU,kBAAkB;AAElC,QAAM,eAAe,MAAM;AAAA,IAC1B,CACC,QACA,MACA,OACI;AACJ,WAAK,SAAS,EAAE,KAAK,IAAI,KAAK,KAAK,EAAE,CAAC;AACtC,iBAAW,eAAe,EAAE,QAAQ,IAAI,MAAM,KAAK,GAAG,CAAC;AAAA,IACxD;AAAA,IACA,CAAC,MAAM,KAAK,UAAU;AAAA,EACvB;AAEA,QAAM,QAAQ,MAAM,QAA8B,MAAM;AACvD,QAAI,CAAC,OAAQ,QAAO,CAAC;AACrB,UAAM,aAA+D;AAAA,MACpE;AAAA,QACC,IAAI;AAAA,QACJ,OAAO;AAAA,QACP,MAAM;AAAA,QACN,KAAK;AAAA,QACL,YAAY;AAAA,QACZ,SAAS,QAAQ;AAChB,cAAI,OAAO,KAAK,QAAQ,GAAG;AAO1B,kBAAM,cAAc,OAAO,KAAK,WAAW;AAC3C,wBAAY,KAAK,CAAC,GAAG,YAAY,EAAE;AACnC,wBAAY,MAAM,CAAC,GAAG,YAAY,EAAE;AAAA,UACr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16.0-next.
|
|
1
|
+
const version = "3.16.0-next.6611943ca24a";
|
|
2
2
|
const publishDates = {
|
|
3
3
|
major: "2024-09-13T14:36:29.063Z",
|
|
4
|
-
minor: "2025-08-
|
|
5
|
-
patch: "2025-08-
|
|
4
|
+
minor: "2025-08-20T10:14:38.875Z",
|
|
5
|
+
patch: "2025-08-20T10:14:38.875Z"
|
|
6
6
|
};
|
|
7
7
|
export {
|
|
8
8
|
publishDates,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/lib/ui/version.ts"],
|
|
4
|
-
"sourcesContent": ["// This file is automatically generated by internal/scripts/refresh-assets.ts.\n// Do not edit manually. Or do, I'm a comment, not a cop.\n\nexport const version = '3.16.0-next.
|
|
4
|
+
"sourcesContent": ["// This file is automatically generated by internal/scripts/refresh-assets.ts.\n// Do not edit manually. Or do, I'm a comment, not a cop.\n\nexport const version = '3.16.0-next.6611943ca24a'\nexport const publishDates = {\n\tmajor: '2024-09-13T14:36:29.063Z',\n\tminor: '2025-08-20T10:14:38.875Z',\n\tpatch: '2025-08-20T10:14:38.875Z',\n}\n"],
|
|
5
5
|
"mappings": "AAGO,MAAM,UAAU;AAChB,MAAM,eAAe;AAAA,EAC3B,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AACR;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tldraw",
|
|
3
3
|
"description": "A tiny little drawing editor.",
|
|
4
|
-
"version": "3.16.0-next.
|
|
4
|
+
"version": "3.16.0-next.6611943ca24a",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "tldraw Inc.",
|
|
7
7
|
"email": "hello@tldraw.com"
|
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
],
|
|
28
28
|
"main": "dist-cjs/index.js",
|
|
29
29
|
"scripts": {
|
|
30
|
-
"test-ci": "
|
|
31
|
-
"test": "yarn run -T
|
|
32
|
-
"test-coverage": "
|
|
30
|
+
"test-ci": "yarn run -T vitest run --passWithNoTests",
|
|
31
|
+
"test": "yarn run -T vitest --passWithNoTests",
|
|
32
|
+
"test-coverage": "yarn run -T vitest run --coverage --passWithNoTests",
|
|
33
33
|
"predev": "node ./scripts/copy-css-files.mjs",
|
|
34
34
|
"dev": "chokidar '../{editor/editor,tldraw/src/lib/ui}.css' -c 'node ./scripts/copy-css-files.mjs'",
|
|
35
35
|
"prebuild": "node ./scripts/copy-css-files.mjs",
|
|
@@ -38,7 +38,8 @@
|
|
|
38
38
|
"prepack": "yarn run -T tsx ../../internal/scripts/prepack.ts",
|
|
39
39
|
"postpack": "../../internal/scripts/postpack.sh",
|
|
40
40
|
"pack-tarball": "yarn pack",
|
|
41
|
-
"lint": "yarn run -T tsx ../../internal/scripts/lint.ts"
|
|
41
|
+
"lint": "yarn run -T tsx ../../internal/scripts/lint.ts",
|
|
42
|
+
"context": "yarn run -T tsx ../../internal/scripts/context.ts"
|
|
42
43
|
},
|
|
43
44
|
"files": [
|
|
44
45
|
"tldraw.css",
|
|
@@ -54,13 +55,13 @@
|
|
|
54
55
|
"@tiptap/pm": "^2.9.1",
|
|
55
56
|
"@tiptap/react": "^2.9.1",
|
|
56
57
|
"@tiptap/starter-kit": "^2.9.1",
|
|
57
|
-
"@tldraw/editor": "3.16.0-next.
|
|
58
|
-
"@tldraw/store": "3.16.0-next.
|
|
58
|
+
"@tldraw/editor": "3.16.0-next.6611943ca24a",
|
|
59
|
+
"@tldraw/store": "3.16.0-next.6611943ca24a",
|
|
59
60
|
"classnames": "^2.5.1",
|
|
60
61
|
"hotkeys-js": "^3.13.9",
|
|
61
62
|
"idb": "^7.1.1",
|
|
62
63
|
"lz-string": "^1.5.0",
|
|
63
|
-
"radix-ui": "^1.
|
|
64
|
+
"radix-ui": "^1.4.2"
|
|
64
65
|
},
|
|
65
66
|
"peerDependencies": {
|
|
66
67
|
"react": "^18.2.0 || ^19.0.0",
|
|
@@ -68,40 +69,16 @@
|
|
|
68
69
|
},
|
|
69
70
|
"devDependencies": {
|
|
70
71
|
"@peculiar/webcrypto": "^1.5.0",
|
|
71
|
-
"@testing-library/jest-dom": "^5.17.0",
|
|
72
72
|
"@testing-library/react": "^15.0.7",
|
|
73
73
|
"@types/classnames": "^2.3.4",
|
|
74
74
|
"@types/lz-string": "^1.5.0",
|
|
75
75
|
"@types/react": "^18.3.18",
|
|
76
76
|
"chokidar-cli": "^3.0.0",
|
|
77
|
-
"jest-canvas-mock": "^2.5.2",
|
|
78
|
-
"jest-environment-jsdom": "^29.7.0",
|
|
79
77
|
"lazyrepo": "0.0.0-alpha.27",
|
|
80
78
|
"react": "^18.3.1",
|
|
81
79
|
"react-dom": "^18.3.1",
|
|
82
|
-
"resize-observer-polyfill": "^1.5.1"
|
|
83
|
-
|
|
84
|
-
"jest": {
|
|
85
|
-
"preset": "../../internal/config/jest/node/jest-preset.js",
|
|
86
|
-
"testEnvironment": "../../../packages/utils/patchedJestJsDom.js",
|
|
87
|
-
"fakeTimers": {
|
|
88
|
-
"enableGlobally": true
|
|
89
|
-
},
|
|
90
|
-
"testPathIgnorePatterns": [
|
|
91
|
-
"^.+\\.*.css$"
|
|
92
|
-
],
|
|
93
|
-
"moduleNameMapper": {
|
|
94
|
-
"^~(.*)": "<rootDir>/src/$1",
|
|
95
|
-
"\\.(css|less|scss|sass)$": "identity-obj-proxy"
|
|
96
|
-
},
|
|
97
|
-
"setupFiles": [
|
|
98
|
-
"raf/polyfill",
|
|
99
|
-
"jest-canvas-mock",
|
|
100
|
-
"<rootDir>/setupTests.js"
|
|
101
|
-
],
|
|
102
|
-
"setupFilesAfterEnv": [
|
|
103
|
-
"../../internal/config/setupJest.ts"
|
|
104
|
-
]
|
|
80
|
+
"resize-observer-polyfill": "^1.5.1",
|
|
81
|
+
"vitest": "^3.2.4"
|
|
105
82
|
},
|
|
106
83
|
"module": "dist-esm/index.mjs",
|
|
107
84
|
"source": "src/index.ts",
|
package/src/index.ts
CHANGED
|
@@ -25,6 +25,16 @@ export { DefaultA11yAnnouncer, useSelectedShapesAnnouncer } from './lib/ui/compo
|
|
|
25
25
|
export { AccessibilityMenu } from './lib/ui/components/AccessibilityMenu'
|
|
26
26
|
export { ColorSchemeMenu } from './lib/ui/components/ColorSchemeMenu'
|
|
27
27
|
export { DefaultDialogs } from './lib/ui/components/Dialogs'
|
|
28
|
+
export {
|
|
29
|
+
TldrawUiColumn,
|
|
30
|
+
TldrawUiGrid,
|
|
31
|
+
TldrawUiOrientationProvider,
|
|
32
|
+
TldrawUiRow,
|
|
33
|
+
useTldrawUiOrientation,
|
|
34
|
+
type TldrawUiOrientationContext,
|
|
35
|
+
type TldrawUiOrientationProviderProps,
|
|
36
|
+
type TLUiLayoutProps,
|
|
37
|
+
} from './lib/ui/components/primitives/layout'
|
|
28
38
|
export {
|
|
29
39
|
TldrawUiMenuActionCheckboxItem,
|
|
30
40
|
type TLUiMenuActionCheckboxItemProps,
|
|
@@ -156,6 +166,9 @@ export {
|
|
|
156
166
|
type TLDefaultFont,
|
|
157
167
|
type TLDefaultFonts,
|
|
158
168
|
} from './lib/shapes/shared/defaultFonts'
|
|
169
|
+
export { getStrokePoints } from './lib/shapes/shared/freehand/getStrokePoints'
|
|
170
|
+
export { getSvgPathFromStrokePoints } from './lib/shapes/shared/freehand/svg'
|
|
171
|
+
export { type StrokeOptions, type StrokePoint } from './lib/shapes/shared/freehand/types'
|
|
159
172
|
export {
|
|
160
173
|
PlainTextLabel,
|
|
161
174
|
TextLabel,
|
|
@@ -598,7 +611,9 @@ export { useMenuIsOpen } from './lib/ui/hooks/useMenuIsOpen'
|
|
|
598
611
|
export { useReadonly } from './lib/ui/hooks/useReadonly'
|
|
599
612
|
export { useRelevantStyles } from './lib/ui/hooks/useRelevantStyles'
|
|
600
613
|
export {
|
|
614
|
+
onDragFromToolbarToCreateShape,
|
|
601
615
|
useTools,
|
|
616
|
+
type OnDragFromToolbarToCreateShapesOpts,
|
|
602
617
|
type TLUiToolItem,
|
|
603
618
|
type TLUiToolsContextType,
|
|
604
619
|
type TLUiToolsProviderProps,
|
|
@@ -31,7 +31,7 @@ export function TldrawScribble({ scribble, zoom, color, opacity, className }: TL
|
|
|
31
31
|
<path
|
|
32
32
|
className="tl-scribble"
|
|
33
33
|
d={d}
|
|
34
|
-
fill={color ?? `var(--color-${scribble.color})`}
|
|
34
|
+
fill={color ?? `var(--tl-color-${scribble.color})`}
|
|
35
35
|
opacity={opacity ?? scribble.opacity}
|
|
36
36
|
/>
|
|
37
37
|
</svg>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { TLArrowShape, createShapeId } from '@tldraw/editor'
|
|
2
|
+
import { vi } from 'vitest'
|
|
2
3
|
import { TestEditor } from '../../../test/TestEditor'
|
|
3
4
|
import { ArrowShapeUtil } from './ArrowShapeUtil'
|
|
4
5
|
import { updateArrowTargetState } from './arrowTargetState'
|
|
@@ -12,7 +13,7 @@ const ids = {
|
|
|
12
13
|
arrow1: createShapeId('arrow1'),
|
|
13
14
|
}
|
|
14
15
|
|
|
15
|
-
|
|
16
|
+
vi.useFakeTimers()
|
|
16
17
|
|
|
17
18
|
window.requestAnimationFrame = function requestAnimationFrame(cb) {
|
|
18
19
|
return setTimeout(cb, 1000 / 60)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { IndexKey, TLArrowShape, TLShapeId, Vec, createShapeId } from '@tldraw/editor'
|
|
2
|
+
import { vi } from 'vitest'
|
|
2
3
|
import { TestEditor } from '../../../test/TestEditor'
|
|
3
4
|
import { getArrowTargetState } from './arrowTargetState'
|
|
4
5
|
import { getArrowBindings } from './shared'
|
|
@@ -13,7 +14,7 @@ global.cancelAnimationFrame = function cancelAnimationFrame(id) {
|
|
|
13
14
|
clearTimeout(id)
|
|
14
15
|
}
|
|
15
16
|
|
|
16
|
-
|
|
17
|
+
vi.useFakeTimers()
|
|
17
18
|
|
|
18
19
|
const ids = {
|
|
19
20
|
box1: createShapeId('box1'),
|
|
@@ -242,7 +243,7 @@ describe('When pointing an end shape', () => {
|
|
|
242
243
|
},
|
|
243
244
|
})
|
|
244
245
|
|
|
245
|
-
|
|
246
|
+
vi.advanceTimersByTime(1000)
|
|
246
247
|
|
|
247
248
|
arrow = editor.getCurrentPageShapes()[editor.getCurrentPageShapes().length - 1]
|
|
248
249
|
|
|
@@ -306,7 +307,7 @@ describe('When pointing an end shape', () => {
|
|
|
306
307
|
})
|
|
307
308
|
|
|
308
309
|
// Give time for the velocity to die down
|
|
309
|
-
|
|
310
|
+
vi.advanceTimersByTime(1000)
|
|
310
311
|
|
|
311
312
|
arrow = editor.getCurrentPageShapes()[editor.getCurrentPageShapes().length - 1]
|
|
312
313
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { HALF_PI, TLArrowShape, TLShapeId, createShapeId, toRichText } from '@tldraw/editor'
|
|
2
|
+
import { vi } from 'vitest'
|
|
2
3
|
import { TestEditor } from '../../../test/TestEditor'
|
|
3
4
|
import { createOrUpdateArrowBinding, getArrowBindings } from './shared'
|
|
4
5
|
|
|
@@ -12,7 +13,7 @@ const ids = {
|
|
|
12
13
|
arrow1: createShapeId('arrow1'),
|
|
13
14
|
}
|
|
14
15
|
|
|
15
|
-
|
|
16
|
+
vi.useFakeTimers()
|
|
16
17
|
|
|
17
18
|
window.requestAnimationFrame = function requestAnimationFrame(cb) {
|
|
18
19
|
return setTimeout(cb, 1000 / 60)
|
|
@@ -217,7 +218,7 @@ describe('Other cases when arrow are moved', () => {
|
|
|
217
218
|
// When box one is not selected, unbinds box1 and keeps binding to box2
|
|
218
219
|
editor.select(ids.arrow1, ids.box2, ids.box3)
|
|
219
220
|
editor.alignShapes(editor.getSelectedShapeIds(), 'right')
|
|
220
|
-
|
|
221
|
+
vi.advanceTimersByTime(1000)
|
|
221
222
|
|
|
222
223
|
expect(bindings()).toMatchObject({
|
|
223
224
|
start: { toId: ids.box1, props: { isPrecise: false } },
|
|
@@ -227,7 +228,7 @@ describe('Other cases when arrow are moved', () => {
|
|
|
227
228
|
// maintains bindings if they would still be over the same shape (but makes them precise), but unbinds others
|
|
228
229
|
editor.select(ids.arrow1, ids.box3)
|
|
229
230
|
editor.alignShapes(editor.getSelectedShapeIds(), 'top')
|
|
230
|
-
|
|
231
|
+
vi.advanceTimersByTime(1000)
|
|
231
232
|
|
|
232
233
|
expect(bindings()).toMatchObject({
|
|
233
234
|
start: { toId: ids.box1, props: { isPrecise: true } },
|
|
@@ -244,7 +245,7 @@ describe('Other cases when arrow are moved', () => {
|
|
|
244
245
|
// When box one is not selected, unbinds box1 and keeps binding to box2
|
|
245
246
|
editor.select(ids.arrow1, ids.box2, ids.box3)
|
|
246
247
|
editor.distributeShapes(editor.getSelectedShapeIds(), 'horizontal')
|
|
247
|
-
|
|
248
|
+
vi.advanceTimersByTime(1000)
|
|
248
249
|
|
|
249
250
|
expect(bindings()).toMatchObject({
|
|
250
251
|
start: { toId: ids.box1, props: { isPrecise: false } },
|
|
@@ -254,7 +255,7 @@ describe('Other cases when arrow are moved', () => {
|
|
|
254
255
|
// unbinds when only the arrow is selected (not its bound shapes) if the arrow itself has moved
|
|
255
256
|
editor.select(ids.arrow1, ids.box3, ids.box4)
|
|
256
257
|
editor.distributeShapes(editor.getSelectedShapeIds(), 'vertical')
|
|
257
|
-
|
|
258
|
+
vi.advanceTimersByTime(1000)
|
|
258
259
|
|
|
259
260
|
// The arrow didn't actually move
|
|
260
261
|
expect(bindings()).toMatchObject({
|
|
@@ -265,7 +266,7 @@ describe('Other cases when arrow are moved', () => {
|
|
|
265
266
|
// The arrow will not move because it is still bound to another shape
|
|
266
267
|
editor.updateShapes([{ id: ids.box4, type: 'geo', y: -600 }])
|
|
267
268
|
editor.distributeShapes(editor.getSelectedShapeIds(), 'vertical')
|
|
268
|
-
|
|
269
|
+
vi.advanceTimersByTime(1000)
|
|
269
270
|
|
|
270
271
|
expect(bindings()).toMatchObject({
|
|
271
272
|
start: undefined,
|
|
@@ -31,6 +31,7 @@ import {
|
|
|
31
31
|
clamp,
|
|
32
32
|
debugFlags,
|
|
33
33
|
exhaustiveSwitchError,
|
|
34
|
+
getColorValue,
|
|
34
35
|
getDefaultColorTheme,
|
|
35
36
|
getFontsFromRichText,
|
|
36
37
|
invLerp,
|
|
@@ -785,8 +786,8 @@ export class ArrowShapeUtil extends ShapeUtil<TLArrowShape> {
|
|
|
785
786
|
lineHeight={TEXT_PROPS.lineHeight}
|
|
786
787
|
align="middle"
|
|
787
788
|
verticalAlign="middle"
|
|
789
|
+
labelColor={getColorValue(theme, shape.props.labelColor, 'solid')}
|
|
788
790
|
richText={shape.props.richText}
|
|
789
|
-
labelColor={theme[shape.props.labelColor].solid}
|
|
790
791
|
textWidth={labelPosition.box.w - ARROW_LABEL_PADDING * 2 * shape.props.scale}
|
|
791
792
|
isSelected={isSelected}
|
|
792
793
|
padding={0}
|
|
@@ -934,8 +935,8 @@ export class ArrowShapeUtil extends ShapeUtil<TLArrowShape> {
|
|
|
934
935
|
font={shape.props.font}
|
|
935
936
|
align="middle"
|
|
936
937
|
verticalAlign="middle"
|
|
938
|
+
labelColor={getColorValue(theme, shape.props.labelColor, 'solid')}
|
|
937
939
|
richText={shape.props.richText}
|
|
938
|
-
labelColor={theme[shape.props.labelColor].solid}
|
|
939
940
|
bounds={getArrowLabelPosition(this.editor, shape)
|
|
940
941
|
.box.clone()
|
|
941
942
|
.expandBy(-ARROW_LABEL_PADDING * shape.props.scale)}
|
|
@@ -1077,7 +1078,7 @@ const ArrowSvg = track(function ArrowSvg({
|
|
|
1077
1078
|
</defs>
|
|
1078
1079
|
<g
|
|
1079
1080
|
fill="none"
|
|
1080
|
-
stroke={theme
|
|
1081
|
+
stroke={getColorValue(theme, shape.props.color, 'solid')}
|
|
1081
1082
|
strokeWidth={strokeWidth}
|
|
1082
1083
|
strokeLinejoin="round"
|
|
1083
1084
|
strokeLinecap="round"
|
|
@@ -98,7 +98,7 @@ export function ElbowArrowDebug({ arrow }: { arrow: TLArrowShape }) {
|
|
|
98
98
|
y={fullBox.minY - 3}
|
|
99
99
|
fontSize={10}
|
|
100
100
|
fill="black"
|
|
101
|
-
stroke="var(--color-background)"
|
|
101
|
+
stroke="var(--tl-color-background)"
|
|
102
102
|
strokeWidth={2}
|
|
103
103
|
paintOrder="stroke"
|
|
104
104
|
>
|
|
@@ -109,7 +109,7 @@ export function ElbowArrowDebug({ arrow }: { arrow: TLArrowShape }) {
|
|
|
109
109
|
y={info.A.expanded.y}
|
|
110
110
|
fontSize={10}
|
|
111
111
|
fill="black"
|
|
112
|
-
stroke="var(--color-background)"
|
|
112
|
+
stroke="var(--tl-color-background)"
|
|
113
113
|
strokeWidth={2}
|
|
114
114
|
paintOrder="stroke"
|
|
115
115
|
>
|
|
@@ -121,7 +121,7 @@ export function ElbowArrowDebug({ arrow }: { arrow: TLArrowShape }) {
|
|
|
121
121
|
y={info.B.expanded.y}
|
|
122
122
|
fontSize={10}
|
|
123
123
|
fill="black"
|
|
124
|
-
stroke="var(--color-background)"
|
|
124
|
+
stroke="var(--tl-color-background)"
|
|
125
125
|
strokeWidth={2}
|
|
126
126
|
paintOrder="stroke"
|
|
127
127
|
>
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { TestEditor } from '../../../test/TestEditor'
|
|
2
|
-
import { DrawShapeTool } from './DrawShapeTool'
|
|
3
2
|
|
|
4
3
|
let editor: TestEditor
|
|
5
4
|
|
|
@@ -10,10 +9,6 @@ afterEach(() => {
|
|
|
10
9
|
editor?.dispose()
|
|
11
10
|
})
|
|
12
11
|
|
|
13
|
-
describe(DrawShapeTool, () => {
|
|
14
|
-
return
|
|
15
|
-
})
|
|
16
|
-
|
|
17
12
|
describe('When in the idle state', () => {
|
|
18
13
|
it('Returns to select on cancel', () => {
|
|
19
14
|
editor.setCurrentTool('draw')
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
VecLike,
|
|
15
15
|
drawShapeMigrations,
|
|
16
16
|
drawShapeProps,
|
|
17
|
+
getColorValue,
|
|
17
18
|
last,
|
|
18
19
|
lerp,
|
|
19
20
|
rng,
|
|
@@ -289,7 +290,7 @@ function DrawShapeSvg({ shape, zoomOverride }: { shape: TLDrawShape; zoomOverrid
|
|
|
289
290
|
<path
|
|
290
291
|
d={svgInk(allPointsFromSegments, options)}
|
|
291
292
|
strokeLinecap="round"
|
|
292
|
-
fill={theme
|
|
293
|
+
fill={getColorValue(theme, shape.props.color, 'solid')}
|
|
293
294
|
/>
|
|
294
295
|
</>
|
|
295
296
|
)
|
|
@@ -313,8 +314,8 @@ function DrawShapeSvg({ shape, zoomOverride }: { shape: TLDrawShape; zoomOverrid
|
|
|
313
314
|
<path
|
|
314
315
|
d={solidStrokePath}
|
|
315
316
|
strokeLinecap="round"
|
|
316
|
-
fill={isDot ? theme
|
|
317
|
-
stroke={theme
|
|
317
|
+
fill={isDot ? getColorValue(theme, shape.props.color, 'solid') : 'none'}
|
|
318
|
+
stroke={getColorValue(theme, shape.props.color, 'solid')}
|
|
318
319
|
strokeWidth={sw}
|
|
319
320
|
strokeDasharray={isDot ? 'none' : getDrawShapeStrokeDashArray(shape, sw, dotAdjustment)}
|
|
320
321
|
strokeDashoffset="0"
|
|
@@ -144,7 +144,7 @@ export class EmbedShapeUtil extends BaseBoxShapeUtil<TLEmbedShape> {
|
|
|
144
144
|
border: 0,
|
|
145
145
|
boxShadow: getRotatedBoxShadow(pageRotation),
|
|
146
146
|
borderRadius: embedInfo?.definition.overrideOutlineRadius ?? 8,
|
|
147
|
-
background: embedInfo?.definition.backgroundColor ?? 'var(--color-background)',
|
|
147
|
+
background: embedInfo?.definition.backgroundColor ?? 'var(--tl-color-background)',
|
|
148
148
|
width: w,
|
|
149
149
|
height: h,
|
|
150
150
|
}}
|