tldraw 3.16.0-canary.ffdf566dd0a8 → 3.16.0-internal.a478398270c6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-cjs/index.d.ts +19 -125
- package/dist-cjs/index.js +2 -19
- package/dist-cjs/index.js.map +2 -2
- package/dist-cjs/lib/TldrawImage.js +2 -5
- package/dist-cjs/lib/TldrawImage.js.map +3 -3
- package/dist-cjs/lib/canvas/TldrawCropHandles.js +1 -1
- package/dist-cjs/lib/canvas/TldrawCropHandles.js.map +2 -2
- package/dist-cjs/lib/canvas/TldrawHandles.js +1 -1
- package/dist-cjs/lib/canvas/TldrawHandles.js.map +2 -2
- package/dist-cjs/lib/canvas/TldrawOverlays.js +1 -1
- package/dist-cjs/lib/canvas/TldrawOverlays.js.map +2 -2
- package/dist-cjs/lib/canvas/TldrawSelectionForeground.js +271 -279
- package/dist-cjs/lib/canvas/TldrawSelectionForeground.js.map +2 -2
- package/dist-cjs/lib/defaultExternalContentHandlers.js +0 -1
- package/dist-cjs/lib/defaultExternalContentHandlers.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js +41 -24
- package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/arrowLabel.js +4 -16
- package/dist-cjs/lib/shapes/arrow/arrowLabel.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/arrowTargetState.js +1 -1
- package/dist-cjs/lib/shapes/arrow/arrowTargetState.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.js +0 -3
- package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/shapes/draw/DrawShapeUtil.js +3 -0
- package/dist-cjs/lib/shapes/draw/DrawShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js +5 -5
- package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/highlight/HighlightShapeUtil.js +3 -0
- package/dist-cjs/lib/shapes/highlight/HighlightShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/line/LineShapeUtil.js +4 -15
- package/dist-cjs/lib/shapes/line/LineShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/note/NoteShapeUtil.js +1 -2
- package/dist-cjs/lib/shapes/note/NoteShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/PathBuilder.js +3 -21
- package/dist-cjs/lib/shapes/shared/PathBuilder.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/PlainTextLabel.js +0 -1
- package/dist-cjs/lib/shapes/shared/PlainTextLabel.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/RichTextLabel.js +2 -5
- package/dist-cjs/lib/shapes/shared/RichTextLabel.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/SvgTextLabel.js +3 -4
- package/dist-cjs/lib/shapes/shared/SvgTextLabel.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/usePrefersReducedMotion.js +1 -10
- package/dist-cjs/lib/shapes/shared/usePrefersReducedMotion.js.map +2 -2
- package/dist-cjs/lib/shapes/text/TextShapeUtil.js +11 -5
- package/dist-cjs/lib/shapes/text/TextShapeUtil.js.map +2 -2
- package/dist-cjs/lib/styles.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.js +1 -7
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js +22 -43
- package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Idle.js +15 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Idle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingShape.js +0 -5
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingShape.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js +0 -8
- package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Rotating.js +0 -8
- package/dist-cjs/lib/tools/SelectTool/childStates/Rotating.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js +0 -8
- package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js.map +2 -2
- package/dist-cjs/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.js.map +2 -2
- package/dist-cjs/lib/ui/assetUrls.js +13 -10
- package/dist-cjs/lib/ui/assetUrls.js.map +2 -2
- package/dist-cjs/lib/ui/components/A11y.js +12 -14
- package/dist-cjs/lib/ui/components/A11y.js.map +2 -2
- package/dist-cjs/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.js +1 -51
- package/dist-cjs/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.js.map +2 -2
- package/dist-cjs/lib/ui/components/MainMenu/DefaultMainMenuContent.js +2 -3
- package/dist-cjs/lib/ui/components/MainMenu/DefaultMainMenuContent.js.map +2 -2
- package/dist-cjs/lib/ui/components/NavigationPanel/DefaultNavigationPanel.js +4 -3
- package/dist-cjs/lib/ui/components/NavigationPanel/DefaultNavigationPanel.js.map +2 -2
- package/dist-cjs/lib/ui/components/Spinner.js +25 -2
- package/dist-cjs/lib/ui/components/Spinner.js.map +2 -2
- package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanel.js +0 -2
- package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanel.js.map +2 -2
- package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanelContent.js +136 -168
- package/dist-cjs/lib/ui/components/StylePanel/DefaultStylePanelContent.js.map +2 -2
- package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbar.js +7 -21
- package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbar.js.map +3 -3
- package/dist-cjs/lib/ui/components/Toolbar/OverflowingToolbar.js +3 -3
- package/dist-cjs/lib/ui/components/Toolbar/OverflowingToolbar.js.map +2 -2
- package/dist-cjs/lib/ui/components/Toolbar/ToggleToolLockedButton.js +2 -3
- package/dist-cjs/lib/ui/components/Toolbar/ToggleToolLockedButton.js.map +2 -2
- package/dist-cjs/lib/ui/components/menu-items.js +0 -22
- package/dist-cjs/lib/ui/components/menu-items.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/Button/TldrawUiButtonIcon.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiButtonPicker.js +0 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiButtonPicker.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiDialog.js +1 -1
- package/dist-cjs/lib/ui/components/primitives/TldrawUiDialog.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiIcon.js +1 -35
- package/dist-cjs/lib/ui/components/primitives/TldrawUiIcon.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiSlider.js +2 -6
- package/dist-cjs/lib/ui/components/primitives/TldrawUiSlider.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiToolbar.js +3 -12
- package/dist-cjs/lib/ui/components/primitives/TldrawUiToolbar.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuCheckboxItem.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js +2 -0
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js.map +2 -2
- package/dist-cjs/lib/ui/context/TldrawUiContextProvider.js +2 -3
- package/dist-cjs/lib/ui/context/TldrawUiContextProvider.js.map +2 -2
- package/dist-cjs/lib/ui/context/actions.js +8 -57
- package/dist-cjs/lib/ui/context/actions.js.map +2 -2
- package/dist-cjs/lib/ui/context/events.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/menu-hooks.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/useKeyboardShortcuts.js +2 -2
- package/dist-cjs/lib/ui/hooks/useKeyboardShortcuts.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/useTools.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/useTranslation/TLUiTranslationKey.js.map +1 -1
- package/dist-cjs/lib/ui/hooks/useTranslation/defaultTranslation.js +0 -11
- package/dist-cjs/lib/ui/hooks/useTranslation/defaultTranslation.js.map +2 -2
- package/dist-cjs/lib/ui/kbd-utils.js +1 -2
- package/dist-cjs/lib/ui/kbd-utils.js.map +2 -2
- package/dist-cjs/lib/ui/version.js +3 -3
- package/dist-cjs/lib/ui/version.js.map +1 -1
- package/dist-cjs/lib/utils/excalidraw/putExcalidrawContent.js +1 -1
- package/dist-cjs/lib/utils/excalidraw/putExcalidrawContent.js.map +2 -2
- package/dist-cjs/lib/utils/tldr/buildFromV1Document.js +2 -3
- package/dist-cjs/lib/utils/tldr/buildFromV1Document.js.map +2 -2
- package/dist-esm/index.d.mts +19 -125
- package/dist-esm/index.mjs +4 -33
- package/dist-esm/index.mjs.map +2 -2
- package/dist-esm/lib/TldrawImage.mjs +2 -5
- package/dist-esm/lib/TldrawImage.mjs.map +2 -2
- package/dist-esm/lib/canvas/TldrawCropHandles.mjs +1 -1
- package/dist-esm/lib/canvas/TldrawCropHandles.mjs.map +2 -2
- package/dist-esm/lib/canvas/TldrawHandles.mjs +1 -1
- package/dist-esm/lib/canvas/TldrawHandles.mjs.map +2 -2
- package/dist-esm/lib/canvas/TldrawOverlays.mjs +1 -1
- package/dist-esm/lib/canvas/TldrawOverlays.mjs.map +2 -2
- package/dist-esm/lib/canvas/TldrawSelectionForeground.mjs +271 -279
- package/dist-esm/lib/canvas/TldrawSelectionForeground.mjs.map +2 -2
- package/dist-esm/lib/defaultExternalContentHandlers.mjs +0 -1
- package/dist-esm/lib/defaultExternalContentHandlers.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs +41 -26
- package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/arrowLabel.mjs +5 -19
- package/dist-esm/lib/shapes/arrow/arrowLabel.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/arrowTargetState.mjs +1 -1
- package/dist-esm/lib/shapes/arrow/arrowTargetState.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs +0 -3
- package/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/shapes/draw/DrawShapeUtil.mjs +3 -0
- package/dist-esm/lib/shapes/draw/DrawShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs +5 -5
- package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/highlight/HighlightShapeUtil.mjs +3 -0
- package/dist-esm/lib/shapes/highlight/HighlightShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/line/LineShapeUtil.mjs +4 -15
- package/dist-esm/lib/shapes/line/LineShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs +1 -2
- package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/PathBuilder.mjs +3 -22
- package/dist-esm/lib/shapes/shared/PathBuilder.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/PlainTextLabel.mjs +0 -1
- package/dist-esm/lib/shapes/shared/PlainTextLabel.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/RichTextLabel.mjs +2 -5
- package/dist-esm/lib/shapes/shared/RichTextLabel.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/SvgTextLabel.mjs +3 -4
- package/dist-esm/lib/shapes/shared/SvgTextLabel.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/usePrefersReducedMotion.mjs +1 -10
- package/dist-esm/lib/shapes/shared/usePrefersReducedMotion.mjs.map +2 -2
- package/dist-esm/lib/shapes/text/TextShapeUtil.mjs +11 -5
- package/dist-esm/lib/shapes/text/TextShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/styles.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.mjs +1 -7
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs +22 -43
- package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Idle.mjs +15 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Idle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingShape.mjs +0 -5
- package/dist-esm/lib/tools/SelectTool/childStates/PointingShape.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs +0 -8
- package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Rotating.mjs +0 -8
- package/dist-esm/lib/tools/SelectTool/childStates/Rotating.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs +0 -8
- package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs.map +2 -2
- package/dist-esm/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.mjs.map +2 -2
- package/dist-esm/lib/ui/assetUrls.mjs +13 -10
- package/dist-esm/lib/ui/assetUrls.mjs.map +2 -2
- package/dist-esm/lib/ui/components/A11y.mjs +12 -14
- package/dist-esm/lib/ui/components/A11y.mjs.map +2 -2
- package/dist-esm/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.mjs +1 -51
- package/dist-esm/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.mjs.map +2 -2
- package/dist-esm/lib/ui/components/MainMenu/DefaultMainMenuContent.mjs +3 -3
- package/dist-esm/lib/ui/components/MainMenu/DefaultMainMenuContent.mjs.map +2 -2
- package/dist-esm/lib/ui/components/NavigationPanel/DefaultNavigationPanel.mjs +4 -3
- package/dist-esm/lib/ui/components/NavigationPanel/DefaultNavigationPanel.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Spinner.mjs +26 -3
- package/dist-esm/lib/ui/components/Spinner.mjs.map +2 -2
- package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanel.mjs +1 -3
- package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanel.mjs.map +2 -2
- package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanelContent.mjs +136 -168
- package/dist-esm/lib/ui/components/StylePanel/DefaultStylePanelContent.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbar.mjs +9 -23
- package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbar.mjs.map +3 -3
- package/dist-esm/lib/ui/components/Toolbar/OverflowingToolbar.mjs +3 -3
- package/dist-esm/lib/ui/components/Toolbar/OverflowingToolbar.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Toolbar/ToggleToolLockedButton.mjs +2 -3
- package/dist-esm/lib/ui/components/Toolbar/ToggleToolLockedButton.mjs.map +2 -2
- package/dist-esm/lib/ui/components/menu-items.mjs +0 -22
- package/dist-esm/lib/ui/components/menu-items.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/Button/TldrawUiButtonIcon.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiButtonPicker.mjs +0 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiButtonPicker.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiDialog.mjs +1 -1
- package/dist-esm/lib/ui/components/primitives/TldrawUiDialog.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiIcon.mjs +2 -36
- package/dist-esm/lib/ui/components/primitives/TldrawUiIcon.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiSlider.mjs +2 -6
- package/dist-esm/lib/ui/components/primitives/TldrawUiSlider.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiToolbar.mjs +3 -12
- package/dist-esm/lib/ui/components/primitives/TldrawUiToolbar.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuCheckboxItem.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs +2 -0
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs.map +2 -2
- package/dist-esm/lib/ui/context/TldrawUiContextProvider.mjs +2 -3
- package/dist-esm/lib/ui/context/TldrawUiContextProvider.mjs.map +2 -2
- package/dist-esm/lib/ui/context/actions.mjs +8 -57
- package/dist-esm/lib/ui/context/actions.mjs.map +2 -2
- package/dist-esm/lib/ui/context/events.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/menu-hooks.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/useKeyboardShortcuts.mjs +2 -2
- package/dist-esm/lib/ui/hooks/useKeyboardShortcuts.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/useTools.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/useTranslation/defaultTranslation.mjs +0 -11
- package/dist-esm/lib/ui/hooks/useTranslation/defaultTranslation.mjs.map +2 -2
- package/dist-esm/lib/ui/kbd-utils.mjs +1 -2
- package/dist-esm/lib/ui/kbd-utils.mjs.map +2 -2
- package/dist-esm/lib/ui/version.mjs +3 -3
- package/dist-esm/lib/ui/version.mjs.map +1 -1
- package/dist-esm/lib/utils/excalidraw/putExcalidrawContent.mjs +1 -1
- package/dist-esm/lib/utils/excalidraw/putExcalidrawContent.mjs.map +2 -2
- package/dist-esm/lib/utils/tldr/buildFromV1Document.mjs +2 -3
- package/dist-esm/lib/utils/tldr/buildFromV1Document.mjs.map +2 -2
- package/package.json +3 -4
- package/src/index.ts +2 -24
- package/src/lib/TldrawImage.tsx +2 -6
- package/src/lib/canvas/TldrawCropHandles.tsx +1 -3
- package/src/lib/canvas/TldrawHandles.tsx +1 -5
- package/src/lib/canvas/TldrawOverlays.tsx +1 -1
- package/src/lib/canvas/TldrawSelectionForeground.tsx +1 -5
- package/src/lib/defaultExternalContentHandlers.ts +1 -2
- package/src/lib/shapes/arrow/ArrowShapeUtil.test.ts +5 -5
- package/src/lib/shapes/arrow/ArrowShapeUtil.tsx +43 -26
- package/src/lib/shapes/arrow/arrowLabel.ts +3 -23
- package/src/lib/shapes/arrow/arrowTargetState.ts +1 -2
- package/src/lib/shapes/arrow/toolStates/Pointing.tsx +0 -3
- package/src/lib/shapes/draw/DrawShapeUtil.tsx +4 -0
- package/src/lib/shapes/frame/FrameShapeUtil.tsx +7 -5
- package/src/lib/shapes/highlight/HighlightShapeUtil.tsx +3 -0
- package/src/lib/shapes/line/LineShapeUtil.tsx +5 -19
- package/src/lib/shapes/note/NoteShapeUtil.tsx +0 -1
- package/src/lib/shapes/shared/PathBuilder.test.tsx +1 -1
- package/src/lib/shapes/shared/PathBuilder.tsx +1 -35
- package/src/lib/shapes/shared/PlainTextLabel.tsx +0 -1
- package/src/lib/shapes/shared/RichTextLabel.tsx +0 -4
- package/src/lib/shapes/shared/SvgTextLabel.tsx +2 -4
- package/src/lib/shapes/shared/usePrefersReducedMotion.tsx +1 -11
- package/src/lib/shapes/text/TextShapeUtil.tsx +12 -5
- package/src/lib/styles.tsx +1 -3
- package/src/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.ts +1 -8
- package/src/lib/tools/SelectTool/childStates/DraggingHandle.tsx +30 -54
- package/src/lib/tools/SelectTool/childStates/Idle.ts +24 -2
- package/src/lib/tools/SelectTool/childStates/PointingShape.ts +0 -7
- package/src/lib/tools/SelectTool/childStates/Resizing.ts +1 -12
- package/src/lib/tools/SelectTool/childStates/Rotating.ts +0 -11
- package/src/lib/tools/SelectTool/childStates/Translating.ts +0 -11
- package/src/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.ts +0 -1
- package/src/lib/ui/assetUrls.ts +13 -10
- package/src/lib/ui/components/A11y.tsx +13 -15
- package/src/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.tsx +0 -40
- package/src/lib/ui/components/MainMenu/DefaultMainMenuContent.tsx +2 -4
- package/src/lib/ui/components/NavigationPanel/DefaultNavigationPanel.tsx +4 -3
- package/src/lib/ui/components/Spinner.tsx +24 -2
- package/src/lib/ui/components/StylePanel/DefaultStylePanel.tsx +1 -3
- package/src/lib/ui/components/StylePanel/DefaultStylePanelContent.tsx +127 -171
- package/src/lib/ui/components/Toolbar/DefaultImageToolbar.tsx +9 -25
- package/src/lib/ui/components/Toolbar/OverflowingToolbar.tsx +3 -3
- package/src/lib/ui/components/Toolbar/ToggleToolLockedButton.tsx +12 -17
- package/src/lib/ui/components/menu-items.tsx +0 -25
- package/src/lib/ui/components/primitives/Button/TldrawUiButtonIcon.tsx +2 -2
- package/src/lib/ui/components/primitives/TldrawUiButtonPicker.tsx +0 -2
- package/src/lib/ui/components/primitives/TldrawUiDialog.tsx +1 -1
- package/src/lib/ui/components/primitives/TldrawUiIcon.tsx +3 -41
- package/src/lib/ui/components/primitives/TldrawUiSlider.tsx +1 -6
- package/src/lib/ui/components/primitives/TldrawUiToolbar.tsx +3 -24
- package/src/lib/ui/components/primitives/menus/TldrawUiMenuCheckboxItem.tsx +2 -2
- package/src/lib/ui/components/primitives/menus/TldrawUiMenuItem.tsx +4 -3
- package/src/lib/ui/context/TldrawUiContextProvider.tsx +20 -23
- package/src/lib/ui/context/actions.tsx +9 -59
- package/src/lib/ui/context/events.tsx +2 -5
- package/src/lib/ui/hooks/menu-hooks.ts +0 -1
- package/src/lib/ui/hooks/useKeyboardShortcuts.ts +2 -3
- package/src/lib/ui/hooks/useTools.tsx +1 -2
- package/src/lib/ui/hooks/useTranslation/TLUiTranslationKey.ts +0 -11
- package/src/lib/ui/hooks/useTranslation/defaultTranslation.ts +0 -11
- package/src/lib/ui/kbd-utils.ts +1 -2
- package/src/lib/ui/version.ts +3 -3
- package/src/lib/ui.css +23 -65
- package/src/lib/utils/excalidraw/__snapshots__/putExcalidrawContent.test.tsx.snap +2 -16
- package/src/lib/utils/excalidraw/putExcalidrawContent.ts +1 -1
- package/src/lib/utils/tldr/__snapshots__/buildFromV1Document.test.ts.snap +3 -24
- package/src/lib/utils/tldr/buildFromV1Document.ts +1 -2
- package/src/test/Editor.test.tsx +1 -1
- package/src/test/SelectTool.test.ts +11 -37
- package/src/test/arrows-megabus.test.tsx +6 -12
- package/src/test/commands/__snapshots__/getSvgString.test.ts.snap +2 -2
- package/src/test/commands/deletePage.test.ts +1 -84
- package/src/test/groups.test.tsx +1 -1
- package/src/test/navigation.test.ts +0 -254
- package/src/test/shapeutils.test.ts +45 -394
- package/src/test/translating.test.ts +1 -1
- package/tldraw.css +50 -88
- package/dist-cjs/lib/ui/components/AccessibilityMenu.js +0 -35
- package/dist-cjs/lib/ui/components/AccessibilityMenu.js.map +0 -7
- package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js +0 -267
- package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js.map +0 -7
- package/dist-esm/lib/ui/components/AccessibilityMenu.mjs +0 -19
- package/dist-esm/lib/ui/components/AccessibilityMenu.mjs.map +0 -7
- package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs +0 -237
- package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs.map +0 -7
- package/src/lib/ui/components/AccessibilityMenu.tsx +0 -20
- package/src/lib/ui/components/primitives/TldrawUiTooltip.tsx +0 -313
- package/src/test/inner-outer-margin.test.ts +0 -315
|
@@ -32,14 +32,12 @@ import {
|
|
|
32
32
|
debugFlags,
|
|
33
33
|
exhaustiveSwitchError,
|
|
34
34
|
getDefaultColorTheme,
|
|
35
|
-
getFontsFromRichText,
|
|
36
35
|
invLerp,
|
|
37
36
|
lerp,
|
|
38
37
|
mapObjectMapValues,
|
|
39
38
|
maybeSnapToGrid,
|
|
40
39
|
structuredClone,
|
|
41
40
|
toDomPrecision,
|
|
42
|
-
toRichText,
|
|
43
41
|
track,
|
|
44
42
|
useEditor,
|
|
45
43
|
useIsEditing,
|
|
@@ -48,11 +46,12 @@ import {
|
|
|
48
46
|
} from '@tldraw/editor'
|
|
49
47
|
import React, { useMemo } from 'react'
|
|
50
48
|
import { updateArrowTerminal } from '../../bindings/arrow/ArrowBindingUtil'
|
|
51
|
-
import { isEmptyRichText, renderPlaintextFromRichText } from '../../utils/text/richText'
|
|
52
49
|
import { PathBuilder } from '../shared/PathBuilder'
|
|
53
|
-
import {
|
|
50
|
+
import { PlainTextLabel } from '../shared/PlainTextLabel'
|
|
54
51
|
import { ShapeFill } from '../shared/ShapeFill'
|
|
52
|
+
import { SvgTextLabel } from '../shared/SvgTextLabel'
|
|
55
53
|
import { ARROW_LABEL_PADDING, STROKE_SIZES, TEXT_PROPS } from '../shared/default-shape-constants'
|
|
54
|
+
import { DefaultFontFaces } from '../shared/defaultFonts'
|
|
56
55
|
import { getFillDefForCanvas, getFillDefForExport } from '../shared/defaultStyleDefs'
|
|
57
56
|
import { useDefaultColorTheme } from '../shared/useDefaultColorTheme'
|
|
58
57
|
import { getArrowBodyPath, getArrowHandlePath } from './ArrowPath'
|
|
@@ -131,6 +130,10 @@ export class ArrowShapeUtil extends ShapeUtil<TLArrowShape> {
|
|
|
131
130
|
override canSnap() {
|
|
132
131
|
return false
|
|
133
132
|
}
|
|
133
|
+
override canTabTo(shape: TLArrowShape) {
|
|
134
|
+
const bindings = getArrowBindings(this.editor, shape)
|
|
135
|
+
return !!(bindings.start || bindings.end || shape.props.text)
|
|
136
|
+
}
|
|
134
137
|
override hideResizeHandles() {
|
|
135
138
|
return true
|
|
136
139
|
}
|
|
@@ -157,13 +160,8 @@ export class ArrowShapeUtil extends ShapeUtil<TLArrowShape> {
|
|
|
157
160
|
}
|
|
158
161
|
|
|
159
162
|
override getFontFaces(shape: TLArrowShape) {
|
|
160
|
-
if (
|
|
161
|
-
|
|
162
|
-
return getFontsFromRichText(this.editor, shape.props.richText, {
|
|
163
|
-
family: `tldraw_${shape.props.font}`,
|
|
164
|
-
weight: 'normal',
|
|
165
|
-
style: 'normal',
|
|
166
|
-
})
|
|
163
|
+
if (!shape.props.text) return EMPTY_ARRAY
|
|
164
|
+
return [DefaultFontFaces[`tldraw_${shape.props.font}`].normal.normal]
|
|
167
165
|
}
|
|
168
166
|
|
|
169
167
|
override getDefaultProps(): TLArrowShape['props'] {
|
|
@@ -180,7 +178,7 @@ export class ArrowShapeUtil extends ShapeUtil<TLArrowShape> {
|
|
|
180
178
|
end: { x: 2, y: 0 },
|
|
181
179
|
arrowheadStart: 'none',
|
|
182
180
|
arrowheadEnd: 'arrow',
|
|
183
|
-
|
|
181
|
+
text: '',
|
|
184
182
|
labelPosition: 0.5,
|
|
185
183
|
font: 'draw',
|
|
186
184
|
scale: 1,
|
|
@@ -210,7 +208,7 @@ export class ArrowShapeUtil extends ShapeUtil<TLArrowShape> {
|
|
|
210
208
|
: new Polyline2d({ points: info.route.points })
|
|
211
209
|
|
|
212
210
|
let labelGeom
|
|
213
|
-
if (isEditing ||
|
|
211
|
+
if (isEditing || shape.props.text.trim()) {
|
|
214
212
|
const labelPosition = getArrowLabelPosition(this.editor, shape)
|
|
215
213
|
if (debugFlags.debugGeometry.get()) {
|
|
216
214
|
debugGeom.push(...labelPosition.debugGeom)
|
|
@@ -282,7 +280,7 @@ export class ArrowShapeUtil extends ShapeUtil<TLArrowShape> {
|
|
|
282
280
|
}
|
|
283
281
|
|
|
284
282
|
override getText(shape: TLArrowShape) {
|
|
285
|
-
return
|
|
283
|
+
return shape.props.text
|
|
286
284
|
}
|
|
287
285
|
|
|
288
286
|
override onHandleDrag(shape: TLArrowShape, info: TLHandleDragInfo<TLArrowShape>) {
|
|
@@ -763,7 +761,7 @@ export class ArrowShapeUtil extends ShapeUtil<TLArrowShape> {
|
|
|
763
761
|
const labelPosition = getArrowLabelPosition(this.editor, shape)
|
|
764
762
|
const isSelected = shape.id === this.editor.getOnlySelectedShapeId()
|
|
765
763
|
const isEditing = this.editor.getEditingShapeId() === shape.id
|
|
766
|
-
const showArrowLabel = isEditing ||
|
|
764
|
+
const showArrowLabel = isEditing || shape.props.text
|
|
767
765
|
|
|
768
766
|
return (
|
|
769
767
|
<>
|
|
@@ -777,15 +775,16 @@ export class ArrowShapeUtil extends ShapeUtil<TLArrowShape> {
|
|
|
777
775
|
)}
|
|
778
776
|
</SVGContainer>
|
|
779
777
|
{showArrowLabel && (
|
|
780
|
-
<
|
|
778
|
+
<PlainTextLabel
|
|
781
779
|
shapeId={shape.id}
|
|
780
|
+
classNamePrefix="tl-arrow"
|
|
782
781
|
type="arrow"
|
|
783
782
|
font={shape.props.font}
|
|
784
783
|
fontSize={getArrowLabelFontSize(shape)}
|
|
785
784
|
lineHeight={TEXT_PROPS.lineHeight}
|
|
786
785
|
align="middle"
|
|
787
786
|
verticalAlign="middle"
|
|
788
|
-
|
|
787
|
+
text={shape.props.text}
|
|
789
788
|
labelColor={theme[shape.props.labelColor].solid}
|
|
790
789
|
textWidth={labelPosition.box.w - ARROW_LABEL_PADDING * 2 * shape.props.scale}
|
|
791
790
|
isSelected={isSelected}
|
|
@@ -811,9 +810,9 @@ export class ArrowShapeUtil extends ShapeUtil<TLArrowShape> {
|
|
|
811
810
|
const { start, end } = getArrowTerminalsInArrowSpace(this.editor, shape, info?.bindings)
|
|
812
811
|
const geometry = this.editor.getShapeGeometry<Group2d>(shape)
|
|
813
812
|
const bounds = geometry.bounds
|
|
814
|
-
const isEmpty = isEmptyRichText(shape.props.richText)
|
|
815
813
|
|
|
816
|
-
const labelGeometry =
|
|
814
|
+
const labelGeometry =
|
|
815
|
+
isEditing || shape.props.text.trim() ? (geometry.children[1] as Rectangle2d) : null
|
|
817
816
|
|
|
818
817
|
if (Vec.Equals(start, end)) return null
|
|
819
818
|
|
|
@@ -852,7 +851,7 @@ export class ArrowShapeUtil extends ShapeUtil<TLArrowShape> {
|
|
|
852
851
|
<defs>
|
|
853
852
|
<ArrowClipPath
|
|
854
853
|
radius={3.5 * shape.props.scale}
|
|
855
|
-
hasText={
|
|
854
|
+
hasText={shape.props.text.trim().length > 0}
|
|
856
855
|
bounds={bounds}
|
|
857
856
|
labelBounds={labelBounds}
|
|
858
857
|
as={clipStartArrowhead && as ? as : ''}
|
|
@@ -910,7 +909,7 @@ export class ArrowShapeUtil extends ShapeUtil<TLArrowShape> {
|
|
|
910
909
|
}
|
|
911
910
|
|
|
912
911
|
override onEditStart(shape: TLArrowShape) {
|
|
913
|
-
if (
|
|
912
|
+
if (shape.props.text.trim() === '') {
|
|
914
913
|
// editing text for the first time, so set the position to the default:
|
|
915
914
|
const labelPosition = getArrowLabelDefaultPosition(this.editor, shape)
|
|
916
915
|
this.editor.updateShape<TLArrowShape>({
|
|
@@ -921,6 +920,26 @@ export class ArrowShapeUtil extends ShapeUtil<TLArrowShape> {
|
|
|
921
920
|
}
|
|
922
921
|
}
|
|
923
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
|
+
|
|
924
943
|
override toSvg(shape: TLArrowShape, ctx: SvgExportContext) {
|
|
925
944
|
ctx.addExportDef(getFillDefForExport(shape.props.fill))
|
|
926
945
|
const theme = getDefaultColorTheme(ctx)
|
|
@@ -929,18 +948,17 @@ export class ArrowShapeUtil extends ShapeUtil<TLArrowShape> {
|
|
|
929
948
|
return (
|
|
930
949
|
<g transform={`scale(${scaleFactor})`}>
|
|
931
950
|
<ArrowSvg shape={shape} shouldDisplayHandles={false} />
|
|
932
|
-
<
|
|
951
|
+
<SvgTextLabel
|
|
933
952
|
fontSize={getArrowLabelFontSize(shape)}
|
|
934
953
|
font={shape.props.font}
|
|
935
954
|
align="middle"
|
|
936
955
|
verticalAlign="middle"
|
|
937
|
-
|
|
956
|
+
text={shape.props.text}
|
|
938
957
|
labelColor={theme[shape.props.labelColor].solid}
|
|
939
958
|
bounds={getArrowLabelPosition(this.editor, shape)
|
|
940
959
|
.box.clone()
|
|
941
960
|
.expandBy(-ARROW_LABEL_PADDING * shape.props.scale)}
|
|
942
961
|
padding={0}
|
|
943
|
-
showTextOutline={true}
|
|
944
962
|
/>
|
|
945
963
|
</g>
|
|
946
964
|
)
|
|
@@ -1016,7 +1034,6 @@ const ArrowSvg = track(function ArrowSvg({
|
|
|
1016
1034
|
if (!geometry) return null
|
|
1017
1035
|
const bounds = Box.ZeroFix(geometry.bounds)
|
|
1018
1036
|
const bindings = getArrowBindings(editor, shape)
|
|
1019
|
-
const isEmpty = isEmptyRichText(shape.props.richText)
|
|
1020
1037
|
|
|
1021
1038
|
if (!info?.isValid) return null
|
|
1022
1039
|
|
|
@@ -1067,7 +1084,7 @@ const ArrowSvg = track(function ArrowSvg({
|
|
|
1067
1084
|
<clipPath id={clipPathId}>
|
|
1068
1085
|
<ArrowClipPath
|
|
1069
1086
|
radius={3.5 * shape.props.scale}
|
|
1070
|
-
hasText={isEditing ||
|
|
1087
|
+
hasText={isEditing || shape.props.text.trim().length > 0}
|
|
1071
1088
|
bounds={bounds}
|
|
1072
1089
|
labelBounds={labelPosition.box}
|
|
1073
1090
|
as={clipStartArrowhead && as ? as : ''}
|
|
@@ -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
|
-
}
|
|
@@ -94,7 +94,7 @@ export function updateArrowTargetState({
|
|
|
94
94
|
const target = editor.getShapeAtPoint(pointInPageSpace, {
|
|
95
95
|
hitInside: true,
|
|
96
96
|
hitFrameInside: true,
|
|
97
|
-
margin: arrowKind === 'elbow' ? 8 :
|
|
97
|
+
margin: arrowKind === 'elbow' ? 8 : 0,
|
|
98
98
|
filter: (targetShape) => {
|
|
99
99
|
return (
|
|
100
100
|
!targetShape.isLocked &&
|
|
@@ -187,7 +187,6 @@ export function updateArrowTargetState({
|
|
|
187
187
|
}
|
|
188
188
|
|
|
189
189
|
const shouldSnapCenter = !isExact && precise && targetGeometryInTargetSpace.isClosed
|
|
190
|
-
// const shouldSnapEdges = !isExact && (precise || !targetGeometryInTargetSpace.isClosed)
|
|
191
190
|
const shouldSnapEdges =
|
|
192
191
|
!isExact && ((precise && arrowKind === 'elbow') || !targetGeometryInTargetSpace.isClosed)
|
|
193
192
|
const shouldSnapEdgePoints =
|
|
@@ -118,7 +118,6 @@ export class Pointing extends StateNode {
|
|
|
118
118
|
const change = util.onHandleDrag?.(shape, {
|
|
119
119
|
handle: { ...startHandle, x: 0, y: 0 },
|
|
120
120
|
isPrecise: true,
|
|
121
|
-
isCreatingShape: true,
|
|
122
121
|
initial: initial,
|
|
123
122
|
})
|
|
124
123
|
|
|
@@ -146,7 +145,6 @@ export class Pointing extends StateNode {
|
|
|
146
145
|
const change = util.onHandleDrag?.(shape, {
|
|
147
146
|
handle: { ...startHandle, x: 0, y: 0 },
|
|
148
147
|
isPrecise: this.isPrecise,
|
|
149
|
-
isCreatingShape: true,
|
|
150
148
|
initial: initial,
|
|
151
149
|
})
|
|
152
150
|
|
|
@@ -164,7 +162,6 @@ export class Pointing extends StateNode {
|
|
|
164
162
|
const change = util.onHandleDrag?.(this.editor.getShape(shape)!, {
|
|
165
163
|
handle: { ...endHandle, x: point.x, y: point.y },
|
|
166
164
|
isPrecise: false,
|
|
167
|
-
isCreatingShape: true,
|
|
168
165
|
initial: initial,
|
|
169
166
|
})
|
|
170
167
|
|
|
@@ -219,6 +219,9 @@ export class FrameShapeUtil extends BaseBoxShapeUtil<TLFrameShape> {
|
|
|
219
219
|
[shape.id]
|
|
220
220
|
)
|
|
221
221
|
|
|
222
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
223
|
+
const zoomLevel = useValue('zoom level', () => this.editor.getZoomLevel(), [this.editor])
|
|
224
|
+
|
|
222
225
|
const showFrameColors = this.options.showColors
|
|
223
226
|
|
|
224
227
|
const color = theme[shape.props.color]
|
|
@@ -233,13 +236,12 @@ export class FrameShapeUtil extends BaseBoxShapeUtil<TLFrameShape> {
|
|
|
233
236
|
<SVGContainer>
|
|
234
237
|
<rect
|
|
235
238
|
className={classNames('tl-frame__body', { 'tl-frame__creating': isCreating })}
|
|
239
|
+
width={shape.props.w + 1 / zoomLevel}
|
|
240
|
+
height={shape.props.h + 1 / zoomLevel}
|
|
236
241
|
fill={frameFill}
|
|
237
242
|
stroke={frameStroke}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
height: `calc(${shape.props.h}px + 1px / var(--tl-zoom))`,
|
|
241
|
-
transform: `translate(calc(-0.5px / var(--tl-zoom)), calc(-0.5px / var(--tl-zoom)))`,
|
|
242
|
-
}}
|
|
243
|
+
y={-0.5 / zoomLevel}
|
|
244
|
+
x={-0.5 / zoomLevel}
|
|
243
245
|
/>
|
|
244
246
|
</SVGContainer>
|
|
245
247
|
{isCreating ? null : (
|
|
@@ -35,6 +35,9 @@ export class LineShapeUtil extends ShapeUtil<TLLineShape> {
|
|
|
35
35
|
static override props = lineShapeProps
|
|
36
36
|
static override migrations = lineShapeMigrations
|
|
37
37
|
|
|
38
|
+
override canTabTo() {
|
|
39
|
+
return false
|
|
40
|
+
}
|
|
38
41
|
override hideResizeHandles() {
|
|
39
42
|
return true
|
|
40
43
|
}
|
|
@@ -145,6 +148,8 @@ export class LineShapeUtil extends ShapeUtil<TLLineShape> {
|
|
|
145
148
|
}
|
|
146
149
|
|
|
147
150
|
override onHandleDrag(shape: TLLineShape, { handle }: TLHandleDragInfo<TLLineShape>) {
|
|
151
|
+
// we should only ever be dragging vertex handles
|
|
152
|
+
if (handle.type !== 'vertex') return
|
|
148
153
|
const newPoint = maybeSnapToGrid(new Vec(handle.x, handle.y), this.editor)
|
|
149
154
|
return {
|
|
150
155
|
...shape,
|
|
@@ -158,25 +163,6 @@ export class LineShapeUtil extends ShapeUtil<TLLineShape> {
|
|
|
158
163
|
}
|
|
159
164
|
}
|
|
160
165
|
|
|
161
|
-
override onHandleDragStart(shape: TLLineShape, { handle }: TLHandleDragInfo<TLLineShape>) {
|
|
162
|
-
// For line shapes, if we're dragging a "create" handle, then
|
|
163
|
-
// create a new vertex handle at that point; and make this handle
|
|
164
|
-
// the handle that we're dragging.
|
|
165
|
-
if (handle.type === 'create') {
|
|
166
|
-
return {
|
|
167
|
-
...shape,
|
|
168
|
-
props: {
|
|
169
|
-
...shape.props,
|
|
170
|
-
points: {
|
|
171
|
-
...shape.props.points,
|
|
172
|
-
[handle.index]: { id: handle.index, index: handle.index, x: handle.x, y: handle.y },
|
|
173
|
-
},
|
|
174
|
-
},
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
return
|
|
178
|
-
}
|
|
179
|
-
|
|
180
166
|
component(shape: TLLineShape) {
|
|
181
167
|
return (
|
|
182
168
|
<SVGContainer style={{ minWidth: 50, minHeight: 50 }}>
|
|
@@ -138,7 +138,7 @@ describe('PathBuilder', () => {
|
|
|
138
138
|
.toGeometry()
|
|
139
139
|
|
|
140
140
|
expect(geometry?.toSimpleSvgPath()).toMatchInlineSnapshot(
|
|
141
|
-
`"M0,0L100,100L100,
|
|
141
|
+
`"M0,0L100,100L100,0L91.23532468849007,-7.455843959357096L81.64709960511827,-13.25483368860933L71.44121219537817,-17.39696918901332L60.82354990476352,-19.882250461825734L50.000000178767834,-20.71067750830319L39.17645046288481,-19.882250329702327L28.558788202608024,-17.396968927279783L18.35290084343114,-13.254833302292194L8.764675830847777,-7.455843455996203L6.103515630684342e-7,6.103515559630068e-7L-7.4558434559962,8.764675830847771L-13.254833302292194,18.35290084343114L-17.396968927279772,28.55878820260801L-19.882250329702327,39.17645046288479L-20.710677508303192,50.00000017876782L-19.88225046182574,60.823549904763496L-17.39696918901333,71.44121219537817L-13.254833688609331,81.64709960511824L-7.455843959357106,91.23532468849007L-1.4210854715202004e-14,99.99999999999999L0,0Z"`
|
|
142
142
|
)
|
|
143
143
|
})
|
|
144
144
|
})
|
|
@@ -10,7 +10,6 @@ import {
|
|
|
10
10
|
Geometry2dFilters,
|
|
11
11
|
Geometry2dOptions,
|
|
12
12
|
getPerfectDashProps,
|
|
13
|
-
getVerticesCountForArcLength,
|
|
14
13
|
Group2d,
|
|
15
14
|
modulate,
|
|
16
15
|
PerfectDashTerminal,
|
|
@@ -122,7 +121,6 @@ export interface CubicBezierToPathBuilderCommand extends PathBuilderCommandBase
|
|
|
122
121
|
type: 'cubic'
|
|
123
122
|
cp1: VecModel
|
|
124
123
|
cp2: VecModel
|
|
125
|
-
resolution?: number
|
|
126
124
|
}
|
|
127
125
|
|
|
128
126
|
/** @internal */
|
|
@@ -319,17 +317,8 @@ export class PathBuilder {
|
|
|
319
317
|
// Calculate the sweep angle
|
|
320
318
|
const sweepAngle = endAngle - startAngle
|
|
321
319
|
|
|
322
|
-
// Calculate the approximate arc length. General ellipse arc length is expensive - there's
|
|
323
|
-
// no closed form solution, so we have to do iterative numerical approximation. As we only
|
|
324
|
-
// use this to control the resolution of later approximations, let's cheat and just use the
|
|
325
|
-
// circular arc length with the largest radius:
|
|
326
|
-
const approximateArcLength = Math.max(rx1, ry1) * Math.abs(sweepAngle)
|
|
327
|
-
|
|
328
320
|
// Approximate the arc using cubic bezier curves
|
|
329
321
|
const numSegments = Math.min(4, Math.ceil(Math.abs(sweepAngle) / (Math.PI / 2)))
|
|
330
|
-
const resolutionPerSegment = Math.ceil(
|
|
331
|
-
getVerticesCountForArcLength(approximateArcLength) / numSegments
|
|
332
|
-
)
|
|
333
322
|
const anglePerSegment = sweepAngle / numSegments
|
|
334
323
|
|
|
335
324
|
// Helper function to compute point on ellipse
|
|
@@ -375,16 +364,7 @@ export class PathBuilder {
|
|
|
375
364
|
const cp2y = end.y - handleScale * d2.y
|
|
376
365
|
|
|
377
366
|
const bezierOpts = i === 0 ? opts : { ...opts, mergeWithPrevious: true }
|
|
378
|
-
this.
|
|
379
|
-
end.x,
|
|
380
|
-
end.y,
|
|
381
|
-
cp1x,
|
|
382
|
-
cp1y,
|
|
383
|
-
cp2x,
|
|
384
|
-
cp2y,
|
|
385
|
-
bezierOpts,
|
|
386
|
-
resolutionPerSegment
|
|
387
|
-
)
|
|
367
|
+
this.cubicBezierTo(end.x, end.y, cp1x, cp1y, cp2x, cp2y, bezierOpts)
|
|
388
368
|
}
|
|
389
369
|
|
|
390
370
|
return this
|
|
@@ -398,18 +378,6 @@ export class PathBuilder {
|
|
|
398
378
|
cp2X: number,
|
|
399
379
|
cp2Y: number,
|
|
400
380
|
opts?: PathBuilderCommandOpts
|
|
401
|
-
) {
|
|
402
|
-
return this.cubicBezierToWithResolution(x, y, cp1X, cp1Y, cp2X, cp2Y, opts)
|
|
403
|
-
}
|
|
404
|
-
private cubicBezierToWithResolution(
|
|
405
|
-
x: number,
|
|
406
|
-
y: number,
|
|
407
|
-
cp1X: number,
|
|
408
|
-
cp1Y: number,
|
|
409
|
-
cp2X: number,
|
|
410
|
-
cp2Y: number,
|
|
411
|
-
opts?: PathBuilderCommandOpts,
|
|
412
|
-
resolution?: number
|
|
413
381
|
) {
|
|
414
382
|
this.assertHasMoveTo()
|
|
415
383
|
this.commands.push({
|
|
@@ -420,7 +388,6 @@ export class PathBuilder {
|
|
|
420
388
|
cp2: { x: cp2X, y: cp2Y },
|
|
421
389
|
isClose: false,
|
|
422
390
|
opts,
|
|
423
|
-
resolution,
|
|
424
391
|
})
|
|
425
392
|
return this
|
|
426
393
|
}
|
|
@@ -1005,7 +972,6 @@ export class PathBuilderGeometry2d extends Geometry2d {
|
|
|
1005
972
|
cp1: Vec.From(command.cp1),
|
|
1006
973
|
cp2: Vec.From(command.cp2),
|
|
1007
974
|
end: Vec.From(command),
|
|
1008
|
-
resolution: command.resolution,
|
|
1009
975
|
})
|
|
1010
976
|
)
|
|
1011
977
|
break
|
|
@@ -128,7 +128,6 @@ export const RichTextLabel = React.memo(function RichTextLabel({
|
|
|
128
128
|
return (
|
|
129
129
|
<div
|
|
130
130
|
className={`${cssPrefix}-label tl-text-wrapper tl-rich-text-wrapper`}
|
|
131
|
-
aria-hidden={!isEditing}
|
|
132
131
|
data-font={font}
|
|
133
132
|
data-align={align}
|
|
134
133
|
data-hastext={!isEmpty}
|
|
@@ -194,7 +193,6 @@ export interface RichTextSVGProps {
|
|
|
194
193
|
wrap?: boolean
|
|
195
194
|
labelColor: string
|
|
196
195
|
padding: number
|
|
197
|
-
showTextOutline?: boolean
|
|
198
196
|
}
|
|
199
197
|
|
|
200
198
|
/**
|
|
@@ -212,7 +210,6 @@ export function RichTextSVG({
|
|
|
212
210
|
wrap,
|
|
213
211
|
labelColor,
|
|
214
212
|
padding,
|
|
215
|
-
showTextOutline = true,
|
|
216
213
|
}: RichTextSVGProps) {
|
|
217
214
|
const editor = useEditor()
|
|
218
215
|
const html = renderHtmlFromRichText(editor, richText)
|
|
@@ -248,7 +245,6 @@ export function RichTextSVG({
|
|
|
248
245
|
wordWrap: 'break-word' as const,
|
|
249
246
|
overflowWrap: 'break-word' as const,
|
|
250
247
|
whiteSpace: 'pre-wrap',
|
|
251
|
-
textShadow: showTextOutline ? 'var(--tl-text-outline)' : 'none',
|
|
252
248
|
}
|
|
253
249
|
|
|
254
250
|
return (
|
|
@@ -21,7 +21,6 @@ export function SvgTextLabel({
|
|
|
21
21
|
bounds,
|
|
22
22
|
padding = 16,
|
|
23
23
|
stroke = true,
|
|
24
|
-
showTextOutline = true,
|
|
25
24
|
}: {
|
|
26
25
|
fontSize: number
|
|
27
26
|
font: TLDefaultFontStyle
|
|
@@ -34,7 +33,6 @@ export function SvgTextLabel({
|
|
|
34
33
|
bounds: Box
|
|
35
34
|
padding?: number
|
|
36
35
|
stroke?: boolean
|
|
37
|
-
showTextOutline?: boolean
|
|
38
36
|
}) {
|
|
39
37
|
const editor = useEditor()
|
|
40
38
|
const theme = useDefaultColorTheme()
|
|
@@ -70,10 +68,10 @@ export function SvgTextLabel({
|
|
|
70
68
|
const mainSpans = createTextJsxFromSpans(editor, spans, opts)
|
|
71
69
|
|
|
72
70
|
let outlineSpans = null
|
|
73
|
-
if (
|
|
71
|
+
if (stroke) {
|
|
74
72
|
opts.fill = theme.background
|
|
75
73
|
opts.stroke = theme.background
|
|
76
|
-
opts.strokeWidth =
|
|
74
|
+
opts.strokeWidth = 2
|
|
77
75
|
outlineSpans = createTextJsxFromSpans(editor, spans, opts)
|
|
78
76
|
}
|
|
79
77
|
|
|
@@ -1,20 +1,10 @@
|
|
|
1
|
-
import { useMaybeEditor, useValue } from '@tldraw/editor'
|
|
2
1
|
import { useEffect, useState } from 'react'
|
|
3
2
|
|
|
4
3
|
/** @public */
|
|
5
4
|
export function usePrefersReducedMotion() {
|
|
6
|
-
const editor = useMaybeEditor()
|
|
7
|
-
const animationSpeed = useValue('animationSpeed', () => editor?.user.getAnimationSpeed(), [
|
|
8
|
-
editor,
|
|
9
|
-
])
|
|
10
5
|
const [prefersReducedMotion, setPrefersReducedMotion] = useState(false)
|
|
11
6
|
|
|
12
7
|
useEffect(() => {
|
|
13
|
-
if (animationSpeed !== undefined) {
|
|
14
|
-
setPrefersReducedMotion(animationSpeed === 0 ? true : false)
|
|
15
|
-
return
|
|
16
|
-
}
|
|
17
|
-
|
|
18
8
|
if (typeof window === 'undefined' || !('matchMedia' in window)) return
|
|
19
9
|
const mql = window.matchMedia('(prefers-reduced-motion: reduce)')
|
|
20
10
|
const handler = () => {
|
|
@@ -23,7 +13,7 @@ export function usePrefersReducedMotion() {
|
|
|
23
13
|
handler()
|
|
24
14
|
mql.addEventListener('change', handler)
|
|
25
15
|
return () => mql.removeEventListener('change', handler)
|
|
26
|
-
}, [
|
|
16
|
+
}, [])
|
|
27
17
|
|
|
28
18
|
return prefersReducedMotion
|
|
29
19
|
}
|
|
@@ -303,26 +303,33 @@ export class TextShapeUtil extends ShapeUtil<TLTextShape> {
|
|
|
303
303
|
}
|
|
304
304
|
|
|
305
305
|
function getTextSize(editor: Editor, props: TLTextShape['props']) {
|
|
306
|
-
const { font, richText, size, w } = props
|
|
306
|
+
const { font, richText, autoSize, size, w } = props
|
|
307
307
|
|
|
308
|
-
const minWidth = 16
|
|
308
|
+
const minWidth = autoSize ? 16 : Math.max(16, w)
|
|
309
309
|
const fontSize = FONT_SIZES[size]
|
|
310
310
|
|
|
311
|
-
const
|
|
311
|
+
const cw = autoSize
|
|
312
|
+
? null
|
|
313
|
+
: // `measureText` floors the number so we need to do the same here to avoid issues.
|
|
314
|
+
Math.floor(Math.max(minWidth, w))
|
|
312
315
|
|
|
313
316
|
const html = renderHtmlFromRichTextForMeasurement(editor, richText)
|
|
314
317
|
const result = editor.textMeasure.measureHtml(html, {
|
|
315
318
|
...TEXT_PROPS,
|
|
316
319
|
fontFamily: FONT_FAMILIES[font],
|
|
317
320
|
fontSize: fontSize,
|
|
318
|
-
maxWidth:
|
|
321
|
+
maxWidth: cw,
|
|
319
322
|
})
|
|
320
323
|
|
|
321
324
|
// If we're autosizing the measureText will essentially `Math.floor`
|
|
322
325
|
// the numbers so `19` rather than `19.3`, this means we must +1 to
|
|
323
326
|
// whatever we get to avoid wrapping.
|
|
327
|
+
if (autoSize) {
|
|
328
|
+
result.w += 1
|
|
329
|
+
}
|
|
330
|
+
|
|
324
331
|
return {
|
|
325
|
-
width:
|
|
332
|
+
width: Math.max(minWidth, result.w),
|
|
326
333
|
height: Math.max(fontSize, result.h),
|
|
327
334
|
}
|
|
328
335
|
}
|
package/src/lib/styles.tsx
CHANGED
|
@@ -9,18 +9,11 @@ export class PointingCrop extends StateNode {
|
|
|
9
9
|
|
|
10
10
|
override onPointerMove(info: TLPointerEventInfo) {
|
|
11
11
|
if (this.editor.inputs.isDragging) {
|
|
12
|
-
this.
|
|
12
|
+
this.editor.setCurrentTool('select.crop.translating_crop', info)
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
override onLongPress(info: TLPointerEventInfo) {
|
|
16
|
-
this.startDragging(info)
|
|
17
|
-
}
|
|
18
15
|
|
|
19
16
|
override onPointerUp(info: TLPointerEventInfo) {
|
|
20
17
|
this.editor.setCurrentTool('select.crop.idle', info)
|
|
21
18
|
}
|
|
22
|
-
|
|
23
|
-
startDragging(info: TLPointerEventInfo) {
|
|
24
|
-
this.editor.setCurrentTool('select.crop.translating_crop', info)
|
|
25
|
-
}
|
|
26
19
|
}
|