tldraw 3.16.0-internal.51e99e128bd4 → 3.16.0-internal.a478398270c6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-cjs/index.d.ts +23 -297
- package/dist-cjs/index.js +2 -30
- package/dist-cjs/index.js.map +2 -2
- package/dist-cjs/lib/TldrawImage.js +2 -5
- package/dist-cjs/lib/TldrawImage.js.map +3 -3
- package/dist-cjs/lib/canvas/TldrawCropHandles.js +1 -1
- package/dist-cjs/lib/canvas/TldrawCropHandles.js.map +2 -2
- package/dist-cjs/lib/canvas/TldrawHandles.js +1 -1
- package/dist-cjs/lib/canvas/TldrawHandles.js.map +2 -2
- package/dist-cjs/lib/canvas/TldrawOverlays.js +1 -1
- package/dist-cjs/lib/canvas/TldrawOverlays.js.map +2 -2
- package/dist-cjs/lib/canvas/TldrawScribble.js +1 -1
- package/dist-cjs/lib/canvas/TldrawScribble.js.map +2 -2
- package/dist-cjs/lib/canvas/TldrawSelectionForeground.js +271 -279
- package/dist-cjs/lib/canvas/TldrawSelectionForeground.js.map +2 -2
- package/dist-cjs/lib/defaultExternalContentHandlers.js +0 -1
- package/dist-cjs/lib/defaultExternalContentHandlers.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js +44 -27
- package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/arrowLabel.js +4 -16
- package/dist-cjs/lib/shapes/arrow/arrowLabel.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/arrowTargetState.js +1 -1
- package/dist-cjs/lib/shapes/arrow/arrowTargetState.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/elbow/ElbowArrowDebug.js +3 -3
- package/dist-cjs/lib/shapes/arrow/elbow/ElbowArrowDebug.js.map +1 -1
- package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.js +0 -3
- package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/shapes/draw/DrawShapeUtil.js +6 -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 +17 -17
- package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/frame/components/FrameHeading.js +1 -1
- package/dist-cjs/lib/shapes/frame/components/FrameHeading.js.map +2 -2
- package/dist-cjs/lib/shapes/geo/GeoShapeUtil.js +2 -2
- package/dist-cjs/lib/shapes/geo/GeoShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/geo/components/GeoShapeBody.js +1 -2
- package/dist-cjs/lib/shapes/geo/components/GeoShapeBody.js.map +2 -2
- package/dist-cjs/lib/shapes/highlight/HighlightShapeUtil.js +4 -5
- 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 -20
- package/dist-cjs/lib/shapes/line/LineShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/note/NoteShapeUtil.js +5 -6
- package/dist-cjs/lib/shapes/note/NoteShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/PathBuilder.js +3 -21
- package/dist-cjs/lib/shapes/shared/PathBuilder.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/PlainTextLabel.js +0 -1
- package/dist-cjs/lib/shapes/shared/PlainTextLabel.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/RichTextLabel.js +2 -5
- package/dist-cjs/lib/shapes/shared/RichTextLabel.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/ShapeFill.js +4 -4
- package/dist-cjs/lib/shapes/shared/ShapeFill.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/SvgTextLabel.js +3 -4
- package/dist-cjs/lib/shapes/shared/SvgTextLabel.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/freehand/svg.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/usePrefersReducedMotion.js +1 -10
- package/dist-cjs/lib/shapes/shared/usePrefersReducedMotion.js.map +2 -2
- package/dist-cjs/lib/shapes/text/TextShapeUtil.js +13 -7
- package/dist-cjs/lib/shapes/text/TextShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/video/VideoShapeUtil.js +3 -3
- package/dist-cjs/lib/shapes/video/VideoShapeUtil.js.map +1 -1
- package/dist-cjs/lib/styles.js.map +2 -2
- package/dist-cjs/lib/tools/EraserTool/childStates/Erasing.js +1 -25
- package/dist-cjs/lib/tools/EraserTool/childStates/Erasing.js.map +2 -2
- package/dist-cjs/lib/tools/EraserTool/childStates/Pointing.js +0 -12
- package/dist-cjs/lib/tools/EraserTool/childStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.js +1 -7
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js +22 -43
- package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Idle.js +15 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Idle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingShape.js +0 -5
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingShape.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js +0 -8
- package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Rotating.js +0 -8
- package/dist-cjs/lib/tools/SelectTool/childStates/Rotating.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js +0 -8
- package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js.map +2 -2
- package/dist-cjs/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.js.map +2 -2
- package/dist-cjs/lib/ui/TldrawUi.js +0 -14
- package/dist-cjs/lib/ui/TldrawUi.js.map +3 -3
- package/dist-cjs/lib/ui/components/A11y.js +12 -14
- package/dist-cjs/lib/ui/components/A11y.js.map +2 -2
- package/dist-cjs/lib/ui/components/ActionsMenu/DefaultActionsMenu.js +3 -12
- package/dist-cjs/lib/ui/components/ActionsMenu/DefaultActionsMenu.js.map +2 -2
- package/dist-cjs/lib/ui/components/DefaultMenuPanel.js +2 -3
- package/dist-cjs/lib/ui/components/DefaultMenuPanel.js.map +2 -2
- package/dist-cjs/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.js +1 -51
- package/dist-cjs/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.js.map +2 -2
- package/dist-cjs/lib/ui/components/MainMenu/DefaultMainMenuContent.js +2 -3
- package/dist-cjs/lib/ui/components/MainMenu/DefaultMainMenuContent.js.map +2 -2
- package/dist-cjs/lib/ui/components/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 +3 -5
- package/dist-cjs/lib/ui/components/MobileStylePanel.js.map +2 -2
- package/dist-cjs/lib/ui/components/NavigationPanel/DefaultNavigationPanel.js +5 -4
- package/dist-cjs/lib/ui/components/NavigationPanel/DefaultNavigationPanel.js.map +2 -2
- package/dist-cjs/lib/ui/components/PageMenu/DefaultPageMenu.js +1 -2
- package/dist-cjs/lib/ui/components/PageMenu/DefaultPageMenu.js.map +2 -2
- package/dist-cjs/lib/ui/components/SharePanel/PeopleMenuItem.js +2 -3
- package/dist-cjs/lib/ui/components/SharePanel/PeopleMenuItem.js.map +2 -2
- package/dist-cjs/lib/ui/components/SharePanel/UserPresenceColorPicker.js +2 -2
- package/dist-cjs/lib/ui/components/SharePanel/UserPresenceColorPicker.js.map +2 -2
- package/dist-cjs/lib/ui/components/Spinner.js +25 -2
- package/dist-cjs/lib/ui/components/Spinner.js.map +2 -2
- package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanel.js +0 -2
- package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanel.js.map +2 -2
- package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanelContent.js +139 -171
- 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 +25 -26
- package/dist-cjs/lib/ui/components/StylePanel/DropdownPicker.js.map +3 -3
- package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbar.js +7 -21
- package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbar.js.map +3 -3
- package/dist-cjs/lib/ui/components/Toolbar/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 +21 -66
- package/dist-cjs/lib/ui/components/Toolbar/DefaultToolbar.js.map +3 -3
- package/dist-cjs/lib/ui/components/Toolbar/OverflowingToolbar.js +80 -189
- package/dist-cjs/lib/ui/components/Toolbar/OverflowingToolbar.js.map +3 -3
- package/dist-cjs/lib/ui/components/Toolbar/ToggleToolLockedButton.js +4 -5
- package/dist-cjs/lib/ui/components/Toolbar/ToggleToolLockedButton.js.map +2 -2
- package/dist-cjs/lib/ui/components/menu-items.js +0 -22
- package/dist-cjs/lib/ui/components/menu-items.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/Button/TldrawUiButtonIcon.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiButtonPicker.js +16 -7
- package/dist-cjs/lib/ui/components/primitives/TldrawUiButtonPicker.js.map +3 -3
- package/dist-cjs/lib/ui/components/primitives/TldrawUiContextualToolbar.js +1 -1
- package/dist-cjs/lib/ui/components/primitives/TldrawUiContextualToolbar.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiDialog.js +1 -1
- package/dist-cjs/lib/ui/components/primitives/TldrawUiDialog.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiIcon.js +1 -35
- package/dist-cjs/lib/ui/components/primitives/TldrawUiIcon.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiPopover.js +2 -3
- package/dist-cjs/lib/ui/components/primitives/TldrawUiPopover.js.map +3 -3
- package/dist-cjs/lib/ui/components/primitives/TldrawUiSlider.js +2 -6
- package/dist-cjs/lib/ui/components/primitives/TldrawUiSlider.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiToolbar.js +7 -31
- package/dist-cjs/lib/ui/components/primitives/TldrawUiToolbar.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuCheckboxItem.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuContext.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuGroup.js +12 -25
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuGroup.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js +22 -154
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js.map +2 -2
- package/dist-cjs/lib/ui/context/TldrawUiContextProvider.js +2 -3
- package/dist-cjs/lib/ui/context/TldrawUiContextProvider.js.map +2 -2
- package/dist-cjs/lib/ui/context/actions.js +8 -57
- package/dist-cjs/lib/ui/context/actions.js.map +2 -2
- package/dist-cjs/lib/ui/context/events.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/menu-hooks.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/useKeyboardShortcuts.js +2 -2
- package/dist-cjs/lib/ui/hooks/useKeyboardShortcuts.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/useTools.js +9 -94
- package/dist-cjs/lib/ui/hooks/useTools.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/useTranslation/TLUiTranslationKey.js.map +1 -1
- package/dist-cjs/lib/ui/hooks/useTranslation/defaultTranslation.js +0 -11
- package/dist-cjs/lib/ui/hooks/useTranslation/defaultTranslation.js.map +2 -2
- package/dist-cjs/lib/ui/kbd-utils.js +1 -2
- package/dist-cjs/lib/ui/kbd-utils.js.map +2 -2
- package/dist-cjs/lib/ui/version.js +3 -3
- package/dist-cjs/lib/ui/version.js.map +1 -1
- package/dist-cjs/lib/utils/excalidraw/putExcalidrawContent.js +1 -1
- package/dist-cjs/lib/utils/excalidraw/putExcalidrawContent.js.map +2 -2
- package/dist-cjs/lib/utils/tldr/buildFromV1Document.js +2 -3
- package/dist-cjs/lib/utils/tldr/buildFromV1Document.js.map +2 -2
- package/dist-esm/index.d.mts +23 -297
- package/dist-esm/index.mjs +4 -51
- package/dist-esm/index.mjs.map +2 -2
- package/dist-esm/lib/TldrawImage.mjs +2 -5
- package/dist-esm/lib/TldrawImage.mjs.map +2 -2
- package/dist-esm/lib/canvas/TldrawCropHandles.mjs +1 -1
- package/dist-esm/lib/canvas/TldrawCropHandles.mjs.map +2 -2
- package/dist-esm/lib/canvas/TldrawHandles.mjs +1 -1
- package/dist-esm/lib/canvas/TldrawHandles.mjs.map +2 -2
- package/dist-esm/lib/canvas/TldrawOverlays.mjs +1 -1
- package/dist-esm/lib/canvas/TldrawOverlays.mjs.map +2 -2
- package/dist-esm/lib/canvas/TldrawScribble.mjs +1 -1
- package/dist-esm/lib/canvas/TldrawScribble.mjs.map +2 -2
- package/dist-esm/lib/canvas/TldrawSelectionForeground.mjs +271 -279
- package/dist-esm/lib/canvas/TldrawSelectionForeground.mjs.map +2 -2
- package/dist-esm/lib/defaultExternalContentHandlers.mjs +0 -1
- package/dist-esm/lib/defaultExternalContentHandlers.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs +44 -30
- package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/arrowLabel.mjs +5 -19
- package/dist-esm/lib/shapes/arrow/arrowLabel.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/arrowTargetState.mjs +1 -1
- package/dist-esm/lib/shapes/arrow/arrowTargetState.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/elbow/ElbowArrowDebug.mjs +3 -3
- package/dist-esm/lib/shapes/arrow/elbow/ElbowArrowDebug.mjs.map +1 -1
- package/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs +0 -3
- package/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/shapes/draw/DrawShapeUtil.mjs +6 -4
- 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 +17 -18
- 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 +2 -3
- package/dist-esm/lib/shapes/geo/GeoShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/geo/components/GeoShapeBody.mjs +1 -2
- package/dist-esm/lib/shapes/geo/components/GeoShapeBody.mjs.map +2 -2
- package/dist-esm/lib/shapes/highlight/HighlightShapeUtil.mjs +4 -6
- 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 +5 -21
- package/dist-esm/lib/shapes/line/LineShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs +5 -7
- package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/PathBuilder.mjs +3 -22
- package/dist-esm/lib/shapes/shared/PathBuilder.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/PlainTextLabel.mjs +0 -1
- package/dist-esm/lib/shapes/shared/PlainTextLabel.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/RichTextLabel.mjs +2 -5
- package/dist-esm/lib/shapes/shared/RichTextLabel.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/ShapeFill.mjs +4 -5
- package/dist-esm/lib/shapes/shared/ShapeFill.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/SvgTextLabel.mjs +3 -4
- package/dist-esm/lib/shapes/shared/SvgTextLabel.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/freehand/svg.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/usePrefersReducedMotion.mjs +1 -10
- package/dist-esm/lib/shapes/shared/usePrefersReducedMotion.mjs.map +2 -2
- package/dist-esm/lib/shapes/text/TextShapeUtil.mjs +13 -8
- package/dist-esm/lib/shapes/text/TextShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/video/VideoShapeUtil.mjs +3 -3
- package/dist-esm/lib/shapes/video/VideoShapeUtil.mjs.map +1 -1
- package/dist-esm/lib/styles.mjs.map +2 -2
- package/dist-esm/lib/tools/EraserTool/childStates/Erasing.mjs +1 -26
- package/dist-esm/lib/tools/EraserTool/childStates/Erasing.mjs.map +2 -2
- package/dist-esm/lib/tools/EraserTool/childStates/Pointing.mjs +0 -13
- package/dist-esm/lib/tools/EraserTool/childStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.mjs +1 -7
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs +22 -43
- package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Idle.mjs +15 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Idle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingShape.mjs +0 -5
- package/dist-esm/lib/tools/SelectTool/childStates/PointingShape.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs +0 -8
- package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Rotating.mjs +0 -8
- package/dist-esm/lib/tools/SelectTool/childStates/Rotating.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs +0 -8
- package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs.map +2 -2
- package/dist-esm/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.mjs.map +2 -2
- package/dist-esm/lib/ui/TldrawUi.mjs +2 -16
- package/dist-esm/lib/ui/TldrawUi.mjs.map +3 -3
- package/dist-esm/lib/ui/components/A11y.mjs +12 -14
- package/dist-esm/lib/ui/components/A11y.mjs.map +2 -2
- package/dist-esm/lib/ui/components/ActionsMenu/DefaultActionsMenu.mjs +3 -12
- package/dist-esm/lib/ui/components/ActionsMenu/DefaultActionsMenu.mjs.map +2 -2
- package/dist-esm/lib/ui/components/DefaultMenuPanel.mjs +2 -3
- package/dist-esm/lib/ui/components/DefaultMenuPanel.mjs.map +2 -2
- package/dist-esm/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.mjs +1 -51
- package/dist-esm/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.mjs.map +2 -2
- package/dist-esm/lib/ui/components/MainMenu/DefaultMainMenuContent.mjs +3 -3
- package/dist-esm/lib/ui/components/MainMenu/DefaultMainMenuContent.mjs.map +2 -2
- package/dist-esm/lib/ui/components/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 +3 -6
- package/dist-esm/lib/ui/components/MobileStylePanel.mjs.map +2 -2
- package/dist-esm/lib/ui/components/NavigationPanel/DefaultNavigationPanel.mjs +5 -4
- package/dist-esm/lib/ui/components/NavigationPanel/DefaultNavigationPanel.mjs.map +2 -2
- package/dist-esm/lib/ui/components/PageMenu/DefaultPageMenu.mjs +1 -2
- package/dist-esm/lib/ui/components/PageMenu/DefaultPageMenu.mjs.map +2 -2
- package/dist-esm/lib/ui/components/SharePanel/PeopleMenuItem.mjs +2 -3
- package/dist-esm/lib/ui/components/SharePanel/PeopleMenuItem.mjs.map +2 -2
- package/dist-esm/lib/ui/components/SharePanel/UserPresenceColorPicker.mjs +2 -2
- package/dist-esm/lib/ui/components/SharePanel/UserPresenceColorPicker.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Spinner.mjs +26 -3
- package/dist-esm/lib/ui/components/Spinner.mjs.map +2 -2
- package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanel.mjs +1 -3
- package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanel.mjs.map +2 -2
- package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanelContent.mjs +139 -171
- 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 +25 -26
- package/dist-esm/lib/ui/components/StylePanel/DropdownPicker.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbar.mjs +9 -23
- package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbar.mjs.map +3 -3
- package/dist-esm/lib/ui/components/Toolbar/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 +21 -56
- package/dist-esm/lib/ui/components/Toolbar/DefaultToolbar.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Toolbar/OverflowingToolbar.mjs +81 -192
- package/dist-esm/lib/ui/components/Toolbar/OverflowingToolbar.mjs.map +3 -3
- package/dist-esm/lib/ui/components/Toolbar/ToggleToolLockedButton.mjs +4 -5
- package/dist-esm/lib/ui/components/Toolbar/ToggleToolLockedButton.mjs.map +2 -2
- package/dist-esm/lib/ui/components/menu-items.mjs +0 -22
- package/dist-esm/lib/ui/components/menu-items.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/Button/TldrawUiButtonIcon.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiButtonPicker.mjs +6 -8
- package/dist-esm/lib/ui/components/primitives/TldrawUiButtonPicker.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiContextualToolbar.mjs +1 -1
- package/dist-esm/lib/ui/components/primitives/TldrawUiContextualToolbar.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiDialog.mjs +1 -1
- package/dist-esm/lib/ui/components/primitives/TldrawUiDialog.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiIcon.mjs +2 -36
- package/dist-esm/lib/ui/components/primitives/TldrawUiIcon.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiPopover.mjs +2 -3
- package/dist-esm/lib/ui/components/primitives/TldrawUiPopover.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiSlider.mjs +2 -6
- package/dist-esm/lib/ui/components/primitives/TldrawUiSlider.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiToolbar.mjs +7 -31
- package/dist-esm/lib/ui/components/primitives/TldrawUiToolbar.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuCheckboxItem.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuContext.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuGroup.mjs +12 -25
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuGroup.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs +24 -162
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs.map +2 -2
- package/dist-esm/lib/ui/context/TldrawUiContextProvider.mjs +2 -3
- package/dist-esm/lib/ui/context/TldrawUiContextProvider.mjs.map +2 -2
- package/dist-esm/lib/ui/context/actions.mjs +8 -57
- package/dist-esm/lib/ui/context/actions.mjs.map +2 -2
- package/dist-esm/lib/ui/context/events.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/menu-hooks.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/useKeyboardShortcuts.mjs +2 -2
- package/dist-esm/lib/ui/hooks/useKeyboardShortcuts.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/useTools.mjs +10 -102
- package/dist-esm/lib/ui/hooks/useTools.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/useTranslation/defaultTranslation.mjs +0 -11
- package/dist-esm/lib/ui/hooks/useTranslation/defaultTranslation.mjs.map +2 -2
- package/dist-esm/lib/ui/kbd-utils.mjs +1 -2
- package/dist-esm/lib/ui/kbd-utils.mjs.map +2 -2
- package/dist-esm/lib/ui/version.mjs +3 -3
- package/dist-esm/lib/ui/version.mjs.map +1 -1
- package/dist-esm/lib/utils/excalidraw/putExcalidrawContent.mjs +1 -1
- package/dist-esm/lib/utils/excalidraw/putExcalidrawContent.mjs.map +2 -2
- package/dist-esm/lib/utils/tldr/buildFromV1Document.mjs +2 -3
- package/dist-esm/lib/utils/tldr/buildFromV1Document.mjs.map +2 -2
- package/package.json +34 -12
- package/src/index.ts +2 -39
- package/src/lib/TldrawImage.tsx +2 -6
- package/src/lib/canvas/TldrawCropHandles.tsx +1 -3
- package/src/lib/canvas/TldrawHandles.tsx +1 -5
- package/src/lib/canvas/TldrawOverlays.tsx +1 -1
- package/src/lib/canvas/TldrawScribble.tsx +1 -1
- package/src/lib/canvas/TldrawSelectionForeground.tsx +1 -5
- package/src/lib/defaultExternalContentHandlers.ts +1 -2
- package/src/lib/shapes/arrow/ArrowShapeOptions.test.ts +1 -2
- package/src/lib/shapes/arrow/ArrowShapeTool.test.ts +3 -4
- package/src/lib/shapes/arrow/ArrowShapeUtil.test.ts +11 -12
- package/src/lib/shapes/arrow/ArrowShapeUtil.tsx +46 -30
- package/src/lib/shapes/arrow/arrowLabel.ts +3 -23
- package/src/lib/shapes/arrow/arrowTargetState.ts +1 -2
- package/src/lib/shapes/arrow/elbow/ElbowArrowDebug.tsx +3 -3
- package/src/lib/shapes/arrow/toolStates/Pointing.tsx +0 -3
- package/src/lib/shapes/draw/DrawShapeTool.test.ts +5 -0
- package/src/lib/shapes/draw/DrawShapeUtil.tsx +7 -4
- package/src/lib/shapes/embed/EmbedShapeUtil.tsx +1 -1
- package/src/lib/shapes/frame/FrameShapeUtil.tsx +21 -26
- package/src/lib/shapes/frame/components/FrameHeading.tsx +1 -1
- package/src/lib/shapes/geo/GeoShapeUtil.tsx +2 -3
- package/src/lib/shapes/geo/components/GeoShapeBody.tsx +2 -2
- package/src/lib/shapes/highlight/HighlightShapeUtil.tsx +4 -7
- package/src/lib/shapes/image/ImageShapeUtil.tsx +3 -3
- package/src/lib/shapes/line/LineShapeUtil.test.tsx +3 -4
- package/src/lib/shapes/line/LineShapeUtil.tsx +6 -25
- package/src/lib/shapes/line/__snapshots__/LineShapeUtil.test.tsx.snap +2 -2
- package/src/lib/shapes/note/NoteShapeUtil.tsx +4 -10
- package/src/lib/shapes/shared/PathBuilder.test.tsx +1 -1
- package/src/lib/shapes/shared/PathBuilder.tsx +1 -35
- package/src/lib/shapes/shared/PlainTextLabel.tsx +0 -1
- package/src/lib/shapes/shared/RichTextLabel.tsx +0 -4
- package/src/lib/shapes/shared/ShapeFill.tsx +4 -5
- package/src/lib/shapes/shared/SvgTextLabel.tsx +2 -4
- package/src/lib/shapes/shared/freehand/svg.ts +0 -2
- package/src/lib/shapes/shared/usePrefersReducedMotion.tsx +1 -11
- package/src/lib/shapes/text/TextShapeTool.test.ts +5 -6
- package/src/lib/shapes/text/TextShapeUtil.tsx +14 -8
- package/src/lib/shapes/video/VideoShapeUtil.tsx +3 -3
- package/src/lib/styles.tsx +1 -3
- package/src/lib/tools/EraserTool/childStates/Erasing.ts +1 -34
- package/src/lib/tools/EraserTool/childStates/Pointing.ts +0 -20
- package/src/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.ts +1 -8
- package/src/lib/tools/SelectTool/childStates/DraggingHandle.tsx +30 -54
- package/src/lib/tools/SelectTool/childStates/Idle.ts +24 -2
- package/src/lib/tools/SelectTool/childStates/PointingShape.ts +0 -7
- package/src/lib/tools/SelectTool/childStates/Resizing.ts +1 -12
- package/src/lib/tools/SelectTool/childStates/Rotating.ts +0 -11
- package/src/lib/tools/SelectTool/childStates/Translating.ts +1 -11
- package/src/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.ts +0 -1
- package/src/lib/ui/TldrawUi.tsx +2 -17
- package/src/lib/ui/components/A11y.tsx +13 -15
- package/src/lib/ui/components/ActionsMenu/DefaultActionsMenu.tsx +3 -15
- package/src/lib/ui/components/DefaultMenuPanel.tsx +3 -4
- package/src/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.tsx +0 -40
- package/src/lib/ui/components/MainMenu/DefaultMainMenuContent.tsx +2 -4
- package/src/lib/ui/components/Minimap/MinimapManager.ts +4 -4
- package/src/lib/ui/components/MobileStylePanel.tsx +6 -9
- package/src/lib/ui/components/NavigationPanel/DefaultNavigationPanel.tsx +5 -4
- package/src/lib/ui/components/PageMenu/DefaultPageMenu.tsx +2 -3
- package/src/lib/ui/components/SharePanel/PeopleMenuItem.tsx +3 -4
- package/src/lib/ui/components/SharePanel/UserPresenceColorPicker.tsx +3 -3
- package/src/lib/ui/components/Spinner.tsx +24 -2
- package/src/lib/ui/components/StylePanel/DefaultStylePanel.tsx +1 -3
- package/src/lib/ui/components/StylePanel/DefaultStylePanelContent.tsx +106 -146
- package/src/lib/ui/components/StylePanel/DoubleDropdownPicker.tsx +3 -3
- package/src/lib/ui/components/StylePanel/DropdownPicker.tsx +6 -7
- package/src/lib/ui/components/Toolbar/DefaultImageToolbar.tsx +9 -25
- package/src/lib/ui/components/Toolbar/DefaultImageToolbarContent.tsx +1 -1
- package/src/lib/ui/components/Toolbar/DefaultToolbar.tsx +23 -55
- package/src/lib/ui/components/Toolbar/OverflowingToolbar.tsx +61 -212
- package/src/lib/ui/components/Toolbar/ToggleToolLockedButton.tsx +12 -17
- package/src/lib/ui/components/menu-items.tsx +0 -25
- package/src/lib/ui/components/primitives/Button/TldrawUiButtonIcon.tsx +2 -2
- package/src/lib/ui/components/primitives/TldrawUiButtonPicker.tsx +35 -40
- package/src/lib/ui/components/primitives/TldrawUiContextualToolbar.tsx +1 -1
- package/src/lib/ui/components/primitives/TldrawUiDialog.tsx +1 -1
- package/src/lib/ui/components/primitives/TldrawUiIcon.tsx +3 -41
- package/src/lib/ui/components/primitives/TldrawUiPopover.tsx +2 -4
- package/src/lib/ui/components/primitives/TldrawUiSlider.tsx +1 -6
- package/src/lib/ui/components/primitives/TldrawUiToolbar.tsx +12 -56
- package/src/lib/ui/components/primitives/menus/TldrawUiMenuCheckboxItem.tsx +2 -2
- package/src/lib/ui/components/primitives/menus/TldrawUiMenuContext.tsx +1 -0
- package/src/lib/ui/components/primitives/menus/TldrawUiMenuGroup.tsx +16 -29
- package/src/lib/ui/components/primitives/menus/TldrawUiMenuItem.tsx +23 -224
- package/src/lib/ui/context/TldrawUiContextProvider.tsx +20 -23
- package/src/lib/ui/context/actions.tsx +9 -59
- package/src/lib/ui/context/events.tsx +2 -6
- package/src/lib/ui/hooks/menu-hooks.ts +0 -1
- package/src/lib/ui/hooks/useKeyboardShortcuts.ts +2 -3
- package/src/lib/ui/hooks/useTools.tsx +11 -142
- package/src/lib/ui/hooks/useTranslation/TLUiTranslationKey.ts +0 -11
- package/src/lib/ui/hooks/useTranslation/defaultTranslation.ts +0 -11
- package/src/lib/ui/kbd-utils.ts +1 -2
- package/src/lib/ui/version.ts +3 -3
- package/src/lib/ui.css +314 -414
- package/src/lib/utils/excalidraw/__snapshots__/putExcalidrawContent.test.tsx.snap +7 -21
- package/src/lib/utils/excalidraw/putExcalidrawContent.ts +1 -1
- package/src/lib/utils/tldr/__snapshots__/buildFromV1Document.test.ts.snap +7 -28
- package/src/lib/utils/tldr/buildFromV1Document.ts +1 -2
- package/src/test/A11y.test.tsx +2 -3
- package/src/test/ClickManager.test.ts +6 -7
- package/src/test/Editor.test.tsx +20 -21
- package/src/test/EraserTool.test.ts +13 -184
- package/src/test/HandTool.test.ts +9 -10
- package/src/test/HighlightShape.test.ts +1 -2
- package/src/test/SelectTool.test.ts +13 -40
- package/src/test/TLUserPreferences.test.ts +3 -4
- package/src/test/TestEditor.ts +15 -13
- package/src/test/TldrawEditor.test.tsx +10 -11
- package/src/test/ZoomTool.test.ts +6 -7
- 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 +10 -17
- package/src/test/bindings.test.tsx +37 -24
- package/src/test/bookmark-shapes.test.ts +8 -1
- package/src/test/commands/__snapshots__/getSvgString.test.ts.snap +7 -23
- 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 +24 -25
- package/src/test/commands/animationSpeed.test.ts +1 -2
- package/src/test/commands/centerOnPoint.test.ts +2 -3
- package/src/test/commands/clipboard.test.ts +2 -3
- package/src/test/commands/createShapes.test.ts +1 -2
- package/src/test/commands/deletePage.test.ts +1 -84
- package/src/test/commands/deleteShapes.test.ts +1 -2
- package/src/test/commands/distributeShapes.test.tsx +10 -11
- package/src/test/commands/getSvgString.test.ts +1 -2
- package/src/test/commands/packShapes.test.ts +4 -5
- package/src/test/commands/resizeShape.test.ts +1 -2
- package/src/test/commands/rotateShapes.test.ts +6 -7
- package/src/test/commands/setCamera.test.ts +3 -4
- package/src/test/commands/setCurrentPage.test.ts +2 -3
- package/src/test/commands/stackShapes.test.ts +10 -11
- package/src/test/commands/stretch.test.tsx +12 -13
- package/src/test/createDeepLink.test.tsx +1 -2
- package/src/test/cropping.test.ts +2 -3
- package/src/test/drawing.test.ts +1 -2
- package/src/test/flipShapes.test.ts +3 -4
- package/src/test/frames.test.ts +24 -25
- package/src/test/getCulledShapes.test.tsx +2 -3
- package/src/test/groups.test.tsx +2 -2
- package/src/test/handleDeepLink.test.tsx +1 -2
- package/src/test/maxShapes.test.ts +2 -3
- package/src/test/modifiers.test.ts +4 -5
- package/src/test/navigation.test.ts +9 -264
- package/src/test/panning.test.ts +1 -2
- package/src/test/perf/perf.test.ts +1 -2
- package/src/test/registerDeepLinkListener.test.tsx +9 -10
- package/src/test/resizing.test.ts +38 -39
- package/src/test/select.test.tsx +3 -4
- package/src/test/selection-omnibus.test.ts +10 -11
- package/src/test/shapeutils.test.ts +48 -398
- package/src/test/translating.test.ts +9 -10
- package/tldraw.css +627 -726
- package/dist-cjs/lib/ui/components/AccessibilityMenu.js +0 -35
- package/dist-cjs/lib/ui/components/AccessibilityMenu.js.map +0 -7
- package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js +0 -268
- package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js.map +0 -7
- package/dist-cjs/lib/ui/components/primitives/layout.js +0 -76
- package/dist-cjs/lib/ui/components/primitives/layout.js.map +0 -7
- package/dist-esm/lib/ui/components/AccessibilityMenu.mjs +0 -19
- package/dist-esm/lib/ui/components/AccessibilityMenu.mjs.map +0 -7
- package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs +0 -245
- package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs.map +0 -7
- package/dist-esm/lib/ui/components/primitives/layout.mjs +0 -46
- package/dist-esm/lib/ui/components/primitives/layout.mjs.map +0 -7
- package/src/lib/ui/components/AccessibilityMenu.tsx +0 -20
- package/src/lib/ui/components/primitives/TldrawUiTooltip.tsx +0 -327
- package/src/lib/ui/components/primitives/layout.tsx +0 -107
- package/src/test/inner-outer-margin.test.ts +0 -315
package/src/index.ts
CHANGED
|
@@ -22,19 +22,8 @@ export {
|
|
|
22
22
|
} from './lib/shapes/shared/PathBuilder'
|
|
23
23
|
export { usePrefersReducedMotion } from './lib/shapes/shared/usePrefersReducedMotion'
|
|
24
24
|
export { DefaultA11yAnnouncer, useSelectedShapesAnnouncer } from './lib/ui/components/A11y'
|
|
25
|
-
export { AccessibilityMenu } from './lib/ui/components/AccessibilityMenu'
|
|
26
25
|
export { ColorSchemeMenu } from './lib/ui/components/ColorSchemeMenu'
|
|
27
26
|
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'
|
|
38
27
|
export {
|
|
39
28
|
TldrawUiMenuActionCheckboxItem,
|
|
40
29
|
type TLUiMenuActionCheckboxItemProps,
|
|
@@ -52,7 +41,6 @@ export { TldrawUiTranslationProvider } from './lib/ui/hooks/useTranslation/useTr
|
|
|
52
41
|
// eslint-disable-next-line local/no-export-star
|
|
53
42
|
export * from '@tldraw/editor'
|
|
54
43
|
export { ArrowBindingUtil } from './lib/bindings/arrow/ArrowBindingUtil'
|
|
55
|
-
export { TldrawCropHandles, type TldrawCropHandlesProps } from './lib/canvas/TldrawCropHandles'
|
|
56
44
|
export { TldrawHandles } from './lib/canvas/TldrawHandles'
|
|
57
45
|
export { TldrawArrowHints, TldrawOverlays } from './lib/canvas/TldrawOverlays'
|
|
58
46
|
export { TldrawScribble } from './lib/canvas/TldrawScribble'
|
|
@@ -83,7 +71,6 @@ export {
|
|
|
83
71
|
defaultHandleExternalTldrawContent,
|
|
84
72
|
defaultHandleExternalUrlAsset,
|
|
85
73
|
defaultHandleExternalUrlContent,
|
|
86
|
-
getAssetInfo,
|
|
87
74
|
getMediaAssetInfoPartial,
|
|
88
75
|
registerDefaultExternalContentHandlers,
|
|
89
76
|
type TLDefaultExternalContentHandlerOpts,
|
|
@@ -166,9 +153,6 @@ export {
|
|
|
166
153
|
type TLDefaultFont,
|
|
167
154
|
type TLDefaultFonts,
|
|
168
155
|
} 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'
|
|
172
156
|
export {
|
|
173
157
|
PlainTextLabel,
|
|
174
158
|
TextLabel,
|
|
@@ -199,7 +183,6 @@ export { TldrawImage, type TldrawImageProps } from './lib/TldrawImage'
|
|
|
199
183
|
export { EraserTool } from './lib/tools/EraserTool/EraserTool'
|
|
200
184
|
export { HandTool } from './lib/tools/HandTool/HandTool'
|
|
201
185
|
export { LaserTool } from './lib/tools/LaserTool/LaserTool'
|
|
202
|
-
export { getHitShapeOnCanvasPointerDown } from './lib/tools/selection-logic/getHitShapeOnCanvasPointerDown'
|
|
203
186
|
export { SelectTool } from './lib/tools/SelectTool/SelectTool'
|
|
204
187
|
export { ZoomTool } from './lib/tools/ZoomTool/ZoomTool'
|
|
205
188
|
export {
|
|
@@ -267,7 +250,6 @@ export {
|
|
|
267
250
|
EditSubmenu,
|
|
268
251
|
ExportFileContentSubMenu,
|
|
269
252
|
ExtrasGroup,
|
|
270
|
-
LockGroup,
|
|
271
253
|
MiscMenuGroup,
|
|
272
254
|
PreferencesGroup,
|
|
273
255
|
UndoRedoGroup,
|
|
@@ -301,14 +283,12 @@ export {
|
|
|
301
283
|
ToggleEdgeScrollingItem,
|
|
302
284
|
ToggleFocusModeItem,
|
|
303
285
|
ToggleGridItem,
|
|
304
|
-
ToggleKeyboardShortcutsItem,
|
|
305
286
|
ToggleLockMenuItem,
|
|
306
287
|
TogglePasteAtCursorItem,
|
|
307
288
|
ToggleReduceMotionItem,
|
|
308
289
|
ToggleSnapModeItem,
|
|
309
290
|
ToggleToolLockItem,
|
|
310
291
|
ToggleTransparentBgMenuItem,
|
|
311
|
-
ToggleUiLabelsItem,
|
|
312
292
|
ToggleWrapModeItem,
|
|
313
293
|
UngroupMenuItem,
|
|
314
294
|
UnlockAllMenuItem,
|
|
@@ -401,11 +381,7 @@ export {
|
|
|
401
381
|
type TLUiDropdownMenuSubTriggerProps,
|
|
402
382
|
type TLUiDropdownMenuTriggerProps,
|
|
403
383
|
} from './lib/ui/components/primitives/TldrawUiDropdownMenu'
|
|
404
|
-
export {
|
|
405
|
-
TldrawUiIcon,
|
|
406
|
-
type TLUiIconJsx,
|
|
407
|
-
type TLUiIconProps,
|
|
408
|
-
} from './lib/ui/components/primitives/TldrawUiIcon'
|
|
384
|
+
export { TldrawUiIcon, type TLUiIconProps } from './lib/ui/components/primitives/TldrawUiIcon'
|
|
409
385
|
export { TldrawUiInput, type TLUiInputProps } from './lib/ui/components/primitives/TldrawUiInput'
|
|
410
386
|
export { TldrawUiKbd, type TLUiKbdProps } from './lib/ui/components/primitives/TldrawUiKbd'
|
|
411
387
|
export {
|
|
@@ -427,12 +403,6 @@ export {
|
|
|
427
403
|
type TLUiToolbarToggleGroupProps,
|
|
428
404
|
type TLUiToolbarToggleItemProps,
|
|
429
405
|
} from './lib/ui/components/primitives/TldrawUiToolbar'
|
|
430
|
-
export {
|
|
431
|
-
TldrawUiTooltip,
|
|
432
|
-
TldrawUiTooltipProvider,
|
|
433
|
-
type TldrawUiTooltipProps,
|
|
434
|
-
type TldrawUiTooltipProviderProps,
|
|
435
|
-
} from './lib/ui/components/primitives/TldrawUiTooltip'
|
|
436
406
|
export {
|
|
437
407
|
DefaultQuickActions,
|
|
438
408
|
type TLUiQuickActionsProps,
|
|
@@ -493,7 +463,6 @@ export {
|
|
|
493
463
|
EraserToolbarItem,
|
|
494
464
|
FrameToolbarItem,
|
|
495
465
|
HandToolbarItem,
|
|
496
|
-
HeartToolbarItem,
|
|
497
466
|
HexagonToolbarItem,
|
|
498
467
|
HighlightToolbarItem,
|
|
499
468
|
LaserToolbarItem,
|
|
@@ -524,10 +493,6 @@ export {
|
|
|
524
493
|
OverflowingToolbar,
|
|
525
494
|
type OverflowingToolbarProps,
|
|
526
495
|
} from './lib/ui/components/Toolbar/OverflowingToolbar'
|
|
527
|
-
export {
|
|
528
|
-
ToggleToolLockedButton,
|
|
529
|
-
type ToggleToolLockedButtonProps,
|
|
530
|
-
} from './lib/ui/components/Toolbar/ToggleToolLockedButton'
|
|
531
496
|
export {
|
|
532
497
|
CenteredTopPanelContainer,
|
|
533
498
|
type CenteredTopPanelContainerProps,
|
|
@@ -597,7 +562,7 @@ export {
|
|
|
597
562
|
type TLUiToastsContextType,
|
|
598
563
|
type TLUiToastsProviderProps,
|
|
599
564
|
} from './lib/ui/context/toasts'
|
|
600
|
-
export { useCanRedo, useCanUndo
|
|
565
|
+
export { useCanRedo, useCanUndo } from './lib/ui/hooks/menu-hooks'
|
|
601
566
|
export { useMenuClipboardEvents, useNativeClipboardEvents } from './lib/ui/hooks/useClipboardEvents'
|
|
602
567
|
export {
|
|
603
568
|
useCollaborationStatus,
|
|
@@ -611,9 +576,7 @@ export { useMenuIsOpen } from './lib/ui/hooks/useMenuIsOpen'
|
|
|
611
576
|
export { useReadonly } from './lib/ui/hooks/useReadonly'
|
|
612
577
|
export { useRelevantStyles } from './lib/ui/hooks/useRelevantStyles'
|
|
613
578
|
export {
|
|
614
|
-
onDragFromToolbarToCreateShape,
|
|
615
579
|
useTools,
|
|
616
|
-
type OnDragFromToolbarToCreateShapesOpts,
|
|
617
580
|
type TLUiToolItem,
|
|
618
581
|
type TLUiToolsContextType,
|
|
619
582
|
type TLUiToolsProviderProps,
|
package/src/lib/TldrawImage.tsx
CHANGED
|
@@ -15,7 +15,6 @@ import { memo, useEffect, useLayoutEffect, useMemo, useState } from 'react'
|
|
|
15
15
|
import { defaultBindingUtils } from './defaultBindingUtils'
|
|
16
16
|
import { defaultShapeUtils } from './defaultShapeUtils'
|
|
17
17
|
import { TLUiAssetUrlOverrides } from './ui/assetUrls'
|
|
18
|
-
import { useDefaultEditorAssetsWithOverrides } from './utils/static-assets/assetUrls'
|
|
19
18
|
import { defaultAddFontsFromNode, tipTapDefaultExtensions } from './utils/text/richText'
|
|
20
19
|
|
|
21
20
|
/** @public */
|
|
@@ -112,7 +111,6 @@ export const TldrawImage = memo(function TldrawImage(props: TldrawImageProps) {
|
|
|
112
111
|
assetUrls,
|
|
113
112
|
textOptions = defaultTextOptions,
|
|
114
113
|
} = props
|
|
115
|
-
const assetUrlsWithOverrides = useDefaultEditorAssetsWithOverrides(assetUrls)
|
|
116
114
|
|
|
117
115
|
useLayoutEffect(() => {
|
|
118
116
|
if (!container) return
|
|
@@ -131,7 +129,7 @@ export const TldrawImage = memo(function TldrawImage(props: TldrawImageProps) {
|
|
|
131
129
|
tools: [],
|
|
132
130
|
getContainer: () => tempElm,
|
|
133
131
|
licenseKey,
|
|
134
|
-
fontAssetUrls:
|
|
132
|
+
fontAssetUrls: assetUrls?.fonts,
|
|
135
133
|
textOptions,
|
|
136
134
|
})
|
|
137
135
|
|
|
@@ -140,8 +138,6 @@ export const TldrawImage = memo(function TldrawImage(props: TldrawImageProps) {
|
|
|
140
138
|
const shapeIds = editor.getCurrentPageShapeIds()
|
|
141
139
|
|
|
142
140
|
async function setSvg() {
|
|
143
|
-
// We have to wait for the fonts to load so that we can correctly measure text sizes
|
|
144
|
-
await editor.fonts.loadRequiredFontsForCurrentPage(editor.options.maxFontsToLoadBeforeRender)
|
|
145
141
|
const imageResult = await editor.toImage([...shapeIds], {
|
|
146
142
|
bounds,
|
|
147
143
|
scale,
|
|
@@ -179,7 +175,7 @@ export const TldrawImage = memo(function TldrawImage(props: TldrawImageProps) {
|
|
|
179
175
|
preserveAspectRatio,
|
|
180
176
|
licenseKey,
|
|
181
177
|
pixelRatio,
|
|
182
|
-
|
|
178
|
+
assetUrls,
|
|
183
179
|
textOptions,
|
|
184
180
|
])
|
|
185
181
|
|
|
@@ -2,7 +2,6 @@ import { toDomPrecision } from '@tldraw/editor'
|
|
|
2
2
|
import classNames from 'classnames'
|
|
3
3
|
import { useTranslation } from '../ui/hooks/useTranslation/useTranslation'
|
|
4
4
|
|
|
5
|
-
/** @public */
|
|
6
5
|
export interface TldrawCropHandlesProps {
|
|
7
6
|
size: number
|
|
8
7
|
width: number
|
|
@@ -10,7 +9,6 @@ export interface TldrawCropHandlesProps {
|
|
|
10
9
|
hideAlternateHandles: boolean
|
|
11
10
|
}
|
|
12
11
|
|
|
13
|
-
/** @public @react */
|
|
14
12
|
export function TldrawCropHandles({
|
|
15
13
|
size,
|
|
16
14
|
width,
|
|
@@ -22,7 +20,7 @@ export function TldrawCropHandles({
|
|
|
22
20
|
const msg = useTranslation()
|
|
23
21
|
|
|
24
22
|
return (
|
|
25
|
-
<svg className="tl-overlays__item"
|
|
23
|
+
<svg className="tl-overlays__item">
|
|
26
24
|
{/* Top left */}
|
|
27
25
|
<polyline
|
|
28
26
|
className="tl-corner-crop-handle"
|
|
@@ -23,9 +23,5 @@ export function TldrawHandles({ children }: TLHandlesProps) {
|
|
|
23
23
|
|
|
24
24
|
if (!shouldDisplayHandles) return null
|
|
25
25
|
|
|
26
|
-
return
|
|
27
|
-
<svg className="tl-user-handles tl-overlays__item" aria-hidden="true">
|
|
28
|
-
{children}
|
|
29
|
-
</svg>
|
|
30
|
-
)
|
|
26
|
+
return <svg className="tl-user-handles tl-overlays__item">{children}</svg>
|
|
31
27
|
}
|
|
@@ -60,7 +60,7 @@ export function TldrawArrowHints() {
|
|
|
60
60
|
{ShapeIndicator && <ShapeIndicator shapeId={targetInfo.target.id} />}
|
|
61
61
|
|
|
62
62
|
{showEdgeHints && (
|
|
63
|
-
<svg className="tl-overlays__item"
|
|
63
|
+
<svg className="tl-overlays__item">
|
|
64
64
|
<circle
|
|
65
65
|
cx={anchorInPageSpace.x}
|
|
66
66
|
cy={anchorInPageSpace.y}
|
|
@@ -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(--
|
|
34
|
+
fill={color ?? `var(--color-${scribble.color})`}
|
|
35
35
|
opacity={opacity ?? scribble.opacity}
|
|
36
36
|
/>
|
|
37
37
|
</svg>
|
|
@@ -192,11 +192,7 @@ export const TldrawSelectionForeground = track(function TldrawSelectionForegroun
|
|
|
192
192
|
textHandleHeight * zoom >= 4
|
|
193
193
|
|
|
194
194
|
return (
|
|
195
|
-
<svg
|
|
196
|
-
className="tl-overlays__item tl-selection__fg"
|
|
197
|
-
data-testid="selection-foreground"
|
|
198
|
-
aria-hidden="true"
|
|
199
|
-
>
|
|
195
|
+
<svg className="tl-overlays__item tl-selection__fg" data-testid="selection-foreground">
|
|
200
196
|
<g ref={rSvg}>
|
|
201
197
|
{shouldDisplayBox && (
|
|
202
198
|
<rect
|
|
@@ -915,8 +915,7 @@ function runFileChecks(file: File, options: TLDefaultExternalContentHandlerOpts)
|
|
|
915
915
|
return true
|
|
916
916
|
}
|
|
917
917
|
|
|
918
|
-
|
|
919
|
-
export async function getAssetInfo(
|
|
918
|
+
async function getAssetInfo(
|
|
920
919
|
file: File,
|
|
921
920
|
options: TLDefaultExternalContentHandlerOpts,
|
|
922
921
|
assetId?: TLAssetId
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { TLArrowShape, createShapeId } from '@tldraw/editor'
|
|
2
|
-
import { vi } from 'vitest'
|
|
3
2
|
import { TestEditor } from '../../../test/TestEditor'
|
|
4
3
|
import { ArrowShapeUtil } from './ArrowShapeUtil'
|
|
5
4
|
import { updateArrowTargetState } from './arrowTargetState'
|
|
@@ -13,7 +12,7 @@ const ids = {
|
|
|
13
12
|
arrow1: createShapeId('arrow1'),
|
|
14
13
|
}
|
|
15
14
|
|
|
16
|
-
|
|
15
|
+
jest.useFakeTimers()
|
|
17
16
|
|
|
18
17
|
window.requestAnimationFrame = function requestAnimationFrame(cb) {
|
|
19
18
|
return setTimeout(cb, 1000 / 60)
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { IndexKey, TLArrowShape, TLShapeId, Vec, createShapeId } from '@tldraw/editor'
|
|
2
|
-
import { vi } from 'vitest'
|
|
3
2
|
import { TestEditor } from '../../../test/TestEditor'
|
|
4
3
|
import { getArrowTargetState } from './arrowTargetState'
|
|
5
4
|
import { getArrowBindings } from './shared'
|
|
@@ -14,7 +13,7 @@ global.cancelAnimationFrame = function cancelAnimationFrame(id) {
|
|
|
14
13
|
clearTimeout(id)
|
|
15
14
|
}
|
|
16
15
|
|
|
17
|
-
|
|
16
|
+
jest.useFakeTimers()
|
|
18
17
|
|
|
19
18
|
const ids = {
|
|
20
19
|
box1: createShapeId('box1'),
|
|
@@ -243,7 +242,7 @@ describe('When pointing an end shape', () => {
|
|
|
243
242
|
},
|
|
244
243
|
})
|
|
245
244
|
|
|
246
|
-
|
|
245
|
+
jest.advanceTimersByTime(1000)
|
|
247
246
|
|
|
248
247
|
arrow = editor.getCurrentPageShapes()[editor.getCurrentPageShapes().length - 1]
|
|
249
248
|
|
|
@@ -307,7 +306,7 @@ describe('When pointing an end shape', () => {
|
|
|
307
306
|
})
|
|
308
307
|
|
|
309
308
|
// Give time for the velocity to die down
|
|
310
|
-
|
|
309
|
+
jest.advanceTimersByTime(1000)
|
|
311
310
|
|
|
312
311
|
arrow = editor.getCurrentPageShapes()[editor.getCurrentPageShapes().length - 1]
|
|
313
312
|
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { HALF_PI, TLArrowShape, TLShapeId, createShapeId
|
|
2
|
-
import { vi } from 'vitest'
|
|
1
|
+
import { HALF_PI, TLArrowShape, TLShapeId, createShapeId } from '@tldraw/editor'
|
|
3
2
|
import { TestEditor } from '../../../test/TestEditor'
|
|
4
3
|
import { createOrUpdateArrowBinding, getArrowBindings } from './shared'
|
|
5
4
|
|
|
@@ -13,7 +12,7 @@ const ids = {
|
|
|
13
12
|
arrow1: createShapeId('arrow1'),
|
|
14
13
|
}
|
|
15
14
|
|
|
16
|
-
|
|
15
|
+
jest.useFakeTimers()
|
|
17
16
|
|
|
18
17
|
window.requestAnimationFrame = function requestAnimationFrame(cb) {
|
|
19
18
|
return setTimeout(cb, 1000 / 60)
|
|
@@ -218,7 +217,7 @@ describe('Other cases when arrow are moved', () => {
|
|
|
218
217
|
// When box one is not selected, unbinds box1 and keeps binding to box2
|
|
219
218
|
editor.select(ids.arrow1, ids.box2, ids.box3)
|
|
220
219
|
editor.alignShapes(editor.getSelectedShapeIds(), 'right')
|
|
221
|
-
|
|
220
|
+
jest.advanceTimersByTime(1000)
|
|
222
221
|
|
|
223
222
|
expect(bindings()).toMatchObject({
|
|
224
223
|
start: { toId: ids.box1, props: { isPrecise: false } },
|
|
@@ -228,7 +227,7 @@ describe('Other cases when arrow are moved', () => {
|
|
|
228
227
|
// maintains bindings if they would still be over the same shape (but makes them precise), but unbinds others
|
|
229
228
|
editor.select(ids.arrow1, ids.box3)
|
|
230
229
|
editor.alignShapes(editor.getSelectedShapeIds(), 'top')
|
|
231
|
-
|
|
230
|
+
jest.advanceTimersByTime(1000)
|
|
232
231
|
|
|
233
232
|
expect(bindings()).toMatchObject({
|
|
234
233
|
start: { toId: ids.box1, props: { isPrecise: true } },
|
|
@@ -245,7 +244,7 @@ describe('Other cases when arrow are moved', () => {
|
|
|
245
244
|
// When box one is not selected, unbinds box1 and keeps binding to box2
|
|
246
245
|
editor.select(ids.arrow1, ids.box2, ids.box3)
|
|
247
246
|
editor.distributeShapes(editor.getSelectedShapeIds(), 'horizontal')
|
|
248
|
-
|
|
247
|
+
jest.advanceTimersByTime(1000)
|
|
249
248
|
|
|
250
249
|
expect(bindings()).toMatchObject({
|
|
251
250
|
start: { toId: ids.box1, props: { isPrecise: false } },
|
|
@@ -255,7 +254,7 @@ describe('Other cases when arrow are moved', () => {
|
|
|
255
254
|
// unbinds when only the arrow is selected (not its bound shapes) if the arrow itself has moved
|
|
256
255
|
editor.select(ids.arrow1, ids.box3, ids.box4)
|
|
257
256
|
editor.distributeShapes(editor.getSelectedShapeIds(), 'vertical')
|
|
258
|
-
|
|
257
|
+
jest.advanceTimersByTime(1000)
|
|
259
258
|
|
|
260
259
|
// The arrow didn't actually move
|
|
261
260
|
expect(bindings()).toMatchObject({
|
|
@@ -266,7 +265,7 @@ describe('Other cases when arrow are moved', () => {
|
|
|
266
265
|
// The arrow will not move because it is still bound to another shape
|
|
267
266
|
editor.updateShapes([{ id: ids.box4, type: 'geo', y: -600 }])
|
|
268
267
|
editor.distributeShapes(editor.getSelectedShapeIds(), 'vertical')
|
|
269
|
-
|
|
268
|
+
jest.advanceTimersByTime(1000)
|
|
270
269
|
|
|
271
270
|
expect(bindings()).toMatchObject({
|
|
272
271
|
start: undefined,
|
|
@@ -334,7 +333,7 @@ describe('Arrow labels', () => {
|
|
|
334
333
|
editor.setCurrentTool('arrow').pointerDown(10, 10).pointerMove(100, 100).pointerUp()
|
|
335
334
|
const arrowId = editor.getOnlySelectedShape()!.id
|
|
336
335
|
editor.updateShapes<TLArrowShape>([
|
|
337
|
-
{ id: arrowId, type: 'arrow', props: {
|
|
336
|
+
{ id: arrowId, type: 'arrow', props: { text: 'Test Label' } },
|
|
338
337
|
])
|
|
339
338
|
})
|
|
340
339
|
|
|
@@ -342,7 +341,7 @@ describe('Arrow labels', () => {
|
|
|
342
341
|
const arrowId = editor.getOnlySelectedShape()!.id
|
|
343
342
|
expect(arrow(arrowId)).toMatchObject({
|
|
344
343
|
props: {
|
|
345
|
-
|
|
344
|
+
text: 'Test Label',
|
|
346
345
|
},
|
|
347
346
|
})
|
|
348
347
|
})
|
|
@@ -350,11 +349,11 @@ describe('Arrow labels', () => {
|
|
|
350
349
|
it('should update the label of an arrow', () => {
|
|
351
350
|
const arrowId = editor.getOnlySelectedShape()!.id
|
|
352
351
|
editor.updateShapes<TLArrowShape>([
|
|
353
|
-
{ id: arrowId, type: 'arrow', props: {
|
|
352
|
+
{ id: arrowId, type: 'arrow', props: { text: 'New Label' } },
|
|
354
353
|
])
|
|
355
354
|
expect(arrow(arrowId)).toMatchObject({
|
|
356
355
|
props: {
|
|
357
|
-
|
|
356
|
+
text: 'New Label',
|
|
358
357
|
},
|
|
359
358
|
})
|
|
360
359
|
})
|
|
@@ -31,16 +31,13 @@ import {
|
|
|
31
31
|
clamp,
|
|
32
32
|
debugFlags,
|
|
33
33
|
exhaustiveSwitchError,
|
|
34
|
-
getColorValue,
|
|
35
34
|
getDefaultColorTheme,
|
|
36
|
-
getFontsFromRichText,
|
|
37
35
|
invLerp,
|
|
38
36
|
lerp,
|
|
39
37
|
mapObjectMapValues,
|
|
40
38
|
maybeSnapToGrid,
|
|
41
39
|
structuredClone,
|
|
42
40
|
toDomPrecision,
|
|
43
|
-
toRichText,
|
|
44
41
|
track,
|
|
45
42
|
useEditor,
|
|
46
43
|
useIsEditing,
|
|
@@ -49,11 +46,12 @@ import {
|
|
|
49
46
|
} from '@tldraw/editor'
|
|
50
47
|
import React, { useMemo } from 'react'
|
|
51
48
|
import { updateArrowTerminal } from '../../bindings/arrow/ArrowBindingUtil'
|
|
52
|
-
import { isEmptyRichText, renderPlaintextFromRichText } from '../../utils/text/richText'
|
|
53
49
|
import { PathBuilder } from '../shared/PathBuilder'
|
|
54
|
-
import {
|
|
50
|
+
import { PlainTextLabel } from '../shared/PlainTextLabel'
|
|
55
51
|
import { ShapeFill } from '../shared/ShapeFill'
|
|
52
|
+
import { SvgTextLabel } from '../shared/SvgTextLabel'
|
|
56
53
|
import { ARROW_LABEL_PADDING, STROKE_SIZES, TEXT_PROPS } from '../shared/default-shape-constants'
|
|
54
|
+
import { DefaultFontFaces } from '../shared/defaultFonts'
|
|
57
55
|
import { getFillDefForCanvas, getFillDefForExport } from '../shared/defaultStyleDefs'
|
|
58
56
|
import { useDefaultColorTheme } from '../shared/useDefaultColorTheme'
|
|
59
57
|
import { getArrowBodyPath, getArrowHandlePath } from './ArrowPath'
|
|
@@ -132,6 +130,10 @@ export class ArrowShapeUtil extends ShapeUtil<TLArrowShape> {
|
|
|
132
130
|
override canSnap() {
|
|
133
131
|
return false
|
|
134
132
|
}
|
|
133
|
+
override canTabTo(shape: TLArrowShape) {
|
|
134
|
+
const bindings = getArrowBindings(this.editor, shape)
|
|
135
|
+
return !!(bindings.start || bindings.end || shape.props.text)
|
|
136
|
+
}
|
|
135
137
|
override hideResizeHandles() {
|
|
136
138
|
return true
|
|
137
139
|
}
|
|
@@ -158,13 +160,8 @@ export class ArrowShapeUtil extends ShapeUtil<TLArrowShape> {
|
|
|
158
160
|
}
|
|
159
161
|
|
|
160
162
|
override getFontFaces(shape: TLArrowShape) {
|
|
161
|
-
if (
|
|
162
|
-
|
|
163
|
-
return getFontsFromRichText(this.editor, shape.props.richText, {
|
|
164
|
-
family: `tldraw_${shape.props.font}`,
|
|
165
|
-
weight: 'normal',
|
|
166
|
-
style: 'normal',
|
|
167
|
-
})
|
|
163
|
+
if (!shape.props.text) return EMPTY_ARRAY
|
|
164
|
+
return [DefaultFontFaces[`tldraw_${shape.props.font}`].normal.normal]
|
|
168
165
|
}
|
|
169
166
|
|
|
170
167
|
override getDefaultProps(): TLArrowShape['props'] {
|
|
@@ -181,7 +178,7 @@ export class ArrowShapeUtil extends ShapeUtil<TLArrowShape> {
|
|
|
181
178
|
end: { x: 2, y: 0 },
|
|
182
179
|
arrowheadStart: 'none',
|
|
183
180
|
arrowheadEnd: 'arrow',
|
|
184
|
-
|
|
181
|
+
text: '',
|
|
185
182
|
labelPosition: 0.5,
|
|
186
183
|
font: 'draw',
|
|
187
184
|
scale: 1,
|
|
@@ -211,7 +208,7 @@ export class ArrowShapeUtil extends ShapeUtil<TLArrowShape> {
|
|
|
211
208
|
: new Polyline2d({ points: info.route.points })
|
|
212
209
|
|
|
213
210
|
let labelGeom
|
|
214
|
-
if (isEditing ||
|
|
211
|
+
if (isEditing || shape.props.text.trim()) {
|
|
215
212
|
const labelPosition = getArrowLabelPosition(this.editor, shape)
|
|
216
213
|
if (debugFlags.debugGeometry.get()) {
|
|
217
214
|
debugGeom.push(...labelPosition.debugGeom)
|
|
@@ -283,7 +280,7 @@ export class ArrowShapeUtil extends ShapeUtil<TLArrowShape> {
|
|
|
283
280
|
}
|
|
284
281
|
|
|
285
282
|
override getText(shape: TLArrowShape) {
|
|
286
|
-
return
|
|
283
|
+
return shape.props.text
|
|
287
284
|
}
|
|
288
285
|
|
|
289
286
|
override onHandleDrag(shape: TLArrowShape, info: TLHandleDragInfo<TLArrowShape>) {
|
|
@@ -764,7 +761,7 @@ export class ArrowShapeUtil extends ShapeUtil<TLArrowShape> {
|
|
|
764
761
|
const labelPosition = getArrowLabelPosition(this.editor, shape)
|
|
765
762
|
const isSelected = shape.id === this.editor.getOnlySelectedShapeId()
|
|
766
763
|
const isEditing = this.editor.getEditingShapeId() === shape.id
|
|
767
|
-
const showArrowLabel = isEditing ||
|
|
764
|
+
const showArrowLabel = isEditing || shape.props.text
|
|
768
765
|
|
|
769
766
|
return (
|
|
770
767
|
<>
|
|
@@ -778,16 +775,17 @@ export class ArrowShapeUtil extends ShapeUtil<TLArrowShape> {
|
|
|
778
775
|
)}
|
|
779
776
|
</SVGContainer>
|
|
780
777
|
{showArrowLabel && (
|
|
781
|
-
<
|
|
778
|
+
<PlainTextLabel
|
|
782
779
|
shapeId={shape.id}
|
|
780
|
+
classNamePrefix="tl-arrow"
|
|
783
781
|
type="arrow"
|
|
784
782
|
font={shape.props.font}
|
|
785
783
|
fontSize={getArrowLabelFontSize(shape)}
|
|
786
784
|
lineHeight={TEXT_PROPS.lineHeight}
|
|
787
785
|
align="middle"
|
|
788
786
|
verticalAlign="middle"
|
|
789
|
-
|
|
790
|
-
|
|
787
|
+
text={shape.props.text}
|
|
788
|
+
labelColor={theme[shape.props.labelColor].solid}
|
|
791
789
|
textWidth={labelPosition.box.w - ARROW_LABEL_PADDING * 2 * shape.props.scale}
|
|
792
790
|
isSelected={isSelected}
|
|
793
791
|
padding={0}
|
|
@@ -812,9 +810,9 @@ export class ArrowShapeUtil extends ShapeUtil<TLArrowShape> {
|
|
|
812
810
|
const { start, end } = getArrowTerminalsInArrowSpace(this.editor, shape, info?.bindings)
|
|
813
811
|
const geometry = this.editor.getShapeGeometry<Group2d>(shape)
|
|
814
812
|
const bounds = geometry.bounds
|
|
815
|
-
const isEmpty = isEmptyRichText(shape.props.richText)
|
|
816
813
|
|
|
817
|
-
const labelGeometry =
|
|
814
|
+
const labelGeometry =
|
|
815
|
+
isEditing || shape.props.text.trim() ? (geometry.children[1] as Rectangle2d) : null
|
|
818
816
|
|
|
819
817
|
if (Vec.Equals(start, end)) return null
|
|
820
818
|
|
|
@@ -853,7 +851,7 @@ export class ArrowShapeUtil extends ShapeUtil<TLArrowShape> {
|
|
|
853
851
|
<defs>
|
|
854
852
|
<ArrowClipPath
|
|
855
853
|
radius={3.5 * shape.props.scale}
|
|
856
|
-
hasText={
|
|
854
|
+
hasText={shape.props.text.trim().length > 0}
|
|
857
855
|
bounds={bounds}
|
|
858
856
|
labelBounds={labelBounds}
|
|
859
857
|
as={clipStartArrowhead && as ? as : ''}
|
|
@@ -911,7 +909,7 @@ export class ArrowShapeUtil extends ShapeUtil<TLArrowShape> {
|
|
|
911
909
|
}
|
|
912
910
|
|
|
913
911
|
override onEditStart(shape: TLArrowShape) {
|
|
914
|
-
if (
|
|
912
|
+
if (shape.props.text.trim() === '') {
|
|
915
913
|
// editing text for the first time, so set the position to the default:
|
|
916
914
|
const labelPosition = getArrowLabelDefaultPosition(this.editor, shape)
|
|
917
915
|
this.editor.updateShape<TLArrowShape>({
|
|
@@ -922,6 +920,26 @@ export class ArrowShapeUtil extends ShapeUtil<TLArrowShape> {
|
|
|
922
920
|
}
|
|
923
921
|
}
|
|
924
922
|
|
|
923
|
+
override onEditEnd(shape: TLArrowShape) {
|
|
924
|
+
const {
|
|
925
|
+
id,
|
|
926
|
+
type,
|
|
927
|
+
props: { text },
|
|
928
|
+
} = shape
|
|
929
|
+
|
|
930
|
+
if (text.trimEnd() !== shape.props.text) {
|
|
931
|
+
this.editor.updateShapes<TLArrowShape>([
|
|
932
|
+
{
|
|
933
|
+
id,
|
|
934
|
+
type,
|
|
935
|
+
props: {
|
|
936
|
+
text: text.trimEnd(),
|
|
937
|
+
},
|
|
938
|
+
},
|
|
939
|
+
])
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
|
|
925
943
|
override toSvg(shape: TLArrowShape, ctx: SvgExportContext) {
|
|
926
944
|
ctx.addExportDef(getFillDefForExport(shape.props.fill))
|
|
927
945
|
const theme = getDefaultColorTheme(ctx)
|
|
@@ -930,18 +948,17 @@ export class ArrowShapeUtil extends ShapeUtil<TLArrowShape> {
|
|
|
930
948
|
return (
|
|
931
949
|
<g transform={`scale(${scaleFactor})`}>
|
|
932
950
|
<ArrowSvg shape={shape} shouldDisplayHandles={false} />
|
|
933
|
-
<
|
|
951
|
+
<SvgTextLabel
|
|
934
952
|
fontSize={getArrowLabelFontSize(shape)}
|
|
935
953
|
font={shape.props.font}
|
|
936
954
|
align="middle"
|
|
937
955
|
verticalAlign="middle"
|
|
938
|
-
|
|
939
|
-
|
|
956
|
+
text={shape.props.text}
|
|
957
|
+
labelColor={theme[shape.props.labelColor].solid}
|
|
940
958
|
bounds={getArrowLabelPosition(this.editor, shape)
|
|
941
959
|
.box.clone()
|
|
942
960
|
.expandBy(-ARROW_LABEL_PADDING * shape.props.scale)}
|
|
943
961
|
padding={0}
|
|
944
|
-
showTextOutline={true}
|
|
945
962
|
/>
|
|
946
963
|
</g>
|
|
947
964
|
)
|
|
@@ -1017,7 +1034,6 @@ const ArrowSvg = track(function ArrowSvg({
|
|
|
1017
1034
|
if (!geometry) return null
|
|
1018
1035
|
const bounds = Box.ZeroFix(geometry.bounds)
|
|
1019
1036
|
const bindings = getArrowBindings(editor, shape)
|
|
1020
|
-
const isEmpty = isEmptyRichText(shape.props.richText)
|
|
1021
1037
|
|
|
1022
1038
|
if (!info?.isValid) return null
|
|
1023
1039
|
|
|
@@ -1068,7 +1084,7 @@ const ArrowSvg = track(function ArrowSvg({
|
|
|
1068
1084
|
<clipPath id={clipPathId}>
|
|
1069
1085
|
<ArrowClipPath
|
|
1070
1086
|
radius={3.5 * shape.props.scale}
|
|
1071
|
-
hasText={isEditing ||
|
|
1087
|
+
hasText={isEditing || shape.props.text.trim().length > 0}
|
|
1072
1088
|
bounds={bounds}
|
|
1073
1089
|
labelBounds={labelPosition.box}
|
|
1074
1090
|
as={clipStartArrowhead && as ? as : ''}
|
|
@@ -1078,7 +1094,7 @@ const ArrowSvg = track(function ArrowSvg({
|
|
|
1078
1094
|
</defs>
|
|
1079
1095
|
<g
|
|
1080
1096
|
fill="none"
|
|
1081
|
-
stroke={
|
|
1097
|
+
stroke={theme[shape.props.color].solid}
|
|
1082
1098
|
strokeWidth={strokeWidth}
|
|
1083
1099
|
strokeLinejoin="round"
|
|
1084
1100
|
strokeLinecap="round"
|
|
@@ -9,17 +9,13 @@ import {
|
|
|
9
9
|
Polygon2d,
|
|
10
10
|
Polyline2d,
|
|
11
11
|
TLArrowShape,
|
|
12
|
-
TLShape,
|
|
13
12
|
Vec,
|
|
14
13
|
VecLike,
|
|
15
14
|
clamp,
|
|
16
15
|
createComputedCache,
|
|
17
16
|
exhaustiveSwitchError,
|
|
18
17
|
getChangedKeys,
|
|
19
|
-
pointInPolygon,
|
|
20
|
-
toRichText,
|
|
21
18
|
} from '@tldraw/editor'
|
|
22
|
-
import { isEmptyRichText, renderHtmlFromRichTextForMeasurement } from '../../utils/text/richText'
|
|
23
19
|
import {
|
|
24
20
|
ARROW_LABEL_FONT_SIZES,
|
|
25
21
|
ARROW_LABEL_PADDING,
|
|
@@ -63,18 +59,14 @@ const labelSizeCache = createComputedCache(
|
|
|
63
59
|
|
|
64
60
|
const bodyGeom = getArrowBodyGeometry(editor, shape)
|
|
65
61
|
// We use 'i' as a default label to measure against as a minimum width.
|
|
66
|
-
const
|
|
67
|
-
const html = renderHtmlFromRichTextForMeasurement(
|
|
68
|
-
editor,
|
|
69
|
-
isEmpty ? toRichText('i') : shape.props.richText
|
|
70
|
-
)
|
|
62
|
+
const text = shape.props.text || 'i'
|
|
71
63
|
|
|
72
64
|
const bodyBounds = bodyGeom.bounds
|
|
73
65
|
|
|
74
66
|
const fontSize = getArrowLabelFontSize(shape)
|
|
75
67
|
|
|
76
68
|
// First we measure the text with no constraints
|
|
77
|
-
const { w, h } = editor.textMeasure.
|
|
69
|
+
const { w, h } = editor.textMeasure.measureText(text, {
|
|
78
70
|
...TEXT_PROPS,
|
|
79
71
|
fontFamily: FONT_FAMILIES[shape.props.font],
|
|
80
72
|
fontSize,
|
|
@@ -104,7 +96,7 @@ const labelSizeCache = createComputedCache(
|
|
|
104
96
|
}
|
|
105
97
|
|
|
106
98
|
if (shouldSquish) {
|
|
107
|
-
const { w: squishedWidth, h: squishedHeight } = editor.textMeasure.
|
|
99
|
+
const { w: squishedWidth, h: squishedHeight } = editor.textMeasure.measureText(text, {
|
|
108
100
|
...TEXT_PROPS,
|
|
109
101
|
fontFamily: FONT_FAMILIES[shape.props.font],
|
|
110
102
|
fontSize,
|
|
@@ -300,15 +292,3 @@ export function getArrowLabelDefaultPosition(editor: Editor, shape: TLArrowShape
|
|
|
300
292
|
exhaustiveSwitchError(info, 'type')
|
|
301
293
|
}
|
|
302
294
|
}
|
|
303
|
-
|
|
304
|
-
/** @internal */
|
|
305
|
-
export function isOverArrowLabel(editor: Editor, shape: TLShape) {
|
|
306
|
-
if (!editor.isShapeOfType<TLArrowShape>(shape, 'arrow')) return false
|
|
307
|
-
|
|
308
|
-
const pointInShapeSpace = editor.getPointInShapeSpace(shape, editor.inputs.currentPagePoint)
|
|
309
|
-
// How should we handle multiple labels? Do shapes ever have multiple labels?
|
|
310
|
-
const labelGeometry = editor.getShapeGeometry<Group2d>(shape).children[1]
|
|
311
|
-
// Knowing what we know about arrows... if the shape has no text in its label,
|
|
312
|
-
// then the label geometry should not be there.
|
|
313
|
-
return labelGeometry && pointInPolygon(pointInShapeSpace, labelGeometry.vertices)
|
|
314
|
-
}
|