tldraw 4.2.2 → 4.2.3
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 +242 -311
- package/dist-cjs/index.js +5 -13
- package/dist-cjs/index.js.map +2 -2
- package/dist-cjs/lib/bindings/arrow/ArrowBindingUtil.js.map +2 -2
- package/dist-cjs/lib/canvas/TldrawSelectionForeground.js +4 -7
- package/dist-cjs/lib/canvas/TldrawSelectionForeground.js.map +2 -2
- package/dist-cjs/lib/defaultEmbedDefinitions.js.map +2 -2
- package/dist-cjs/lib/defaultExternalContentHandlers.js +5 -5
- package/dist-cjs/lib/defaultExternalContentHandlers.js.map +2 -2
- package/dist-cjs/lib/defaultSideEffects.js +1 -6
- package/dist-cjs/lib/defaultSideEffects.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js +13 -14
- package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/arrow-types.js.map +1 -1
- package/dist-cjs/lib/shapes/arrow/arrowLabel.js +1 -1
- 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/elbowArrowSnapLines.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/shared.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/toolStates/Idle.js +10 -4
- package/dist-cjs/lib/shapes/arrow/toolStates/Idle.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.js +4 -7
- package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/shapes/bookmark/BookmarkShapeUtil.js +1 -1
- package/dist-cjs/lib/shapes/bookmark/BookmarkShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/bookmark/bookmarks.js.map +2 -2
- package/dist-cjs/lib/shapes/draw/DrawShapeUtil.js +22 -24
- package/dist-cjs/lib/shapes/draw/DrawShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/draw/getPath.js +11 -20
- package/dist-cjs/lib/shapes/draw/getPath.js.map +2 -2
- package/dist-cjs/lib/shapes/draw/toolStates/Drawing.js +86 -82
- package/dist-cjs/lib/shapes/draw/toolStates/Drawing.js.map +3 -3
- package/dist-cjs/lib/shapes/embed/EmbedShapeUtil.js +0 -6
- package/dist-cjs/lib/shapes/embed/EmbedShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/frame/FrameShapeTool.js.map +1 -1
- package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js +5 -6
- package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/geo/GeoShapeUtil.js +142 -146
- package/dist-cjs/lib/shapes/geo/GeoShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/geo/toolStates/Idle.js +10 -5
- package/dist-cjs/lib/shapes/geo/toolStates/Idle.js.map +2 -2
- package/dist-cjs/lib/shapes/geo/toolStates/Pointing.js +3 -3
- package/dist-cjs/lib/shapes/geo/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/shapes/highlight/HighlightShapeUtil.js +21 -23
- package/dist-cjs/lib/shapes/highlight/HighlightShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/line/toolStates/Pointing.js +3 -3
- package/dist-cjs/lib/shapes/line/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/shapes/note/NoteShapeUtil.js +11 -6
- package/dist-cjs/lib/shapes/note/NoteShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/note/noteHelpers.js.map +2 -2
- package/dist-cjs/lib/shapes/note/toolStates/Pointing.js +10 -5
- package/dist-cjs/lib/shapes/note/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/HyperlinkButton.js +2 -3
- package/dist-cjs/lib/shapes/shared/HyperlinkButton.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/PlainTextLabel.js +2 -14
- package/dist-cjs/lib/shapes/shared/PlainTextLabel.js.map +3 -3
- package/dist-cjs/lib/shapes/shared/RichTextLabel.js +4 -12
- package/dist-cjs/lib/shapes/shared/RichTextLabel.js.map +3 -3
- package/dist-cjs/lib/shapes/shared/ShapeFill.js +2 -2
- package/dist-cjs/lib/shapes/shared/ShapeFill.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/crop.js +0 -1
- package/dist-cjs/lib/shapes/shared/crop.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/interpolate-props.js +3 -3
- package/dist-cjs/lib/shapes/shared/interpolate-props.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/useEditablePlainText.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/useEditableRichText.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/{useEfficientZoomThreshold.js → useForceSolid.js} +7 -10
- package/dist-cjs/lib/shapes/shared/useForceSolid.js.map +7 -0
- package/dist-cjs/lib/shapes/shared/useImageOrVideoAsset.js +1 -1
- package/dist-cjs/lib/shapes/shared/useImageOrVideoAsset.js.map +2 -2
- package/dist-cjs/lib/shapes/text/RichTextArea.js +0 -5
- package/dist-cjs/lib/shapes/text/RichTextArea.js.map +2 -2
- package/dist-cjs/lib/shapes/text/TextShapeUtil.js +2 -5
- package/dist-cjs/lib/shapes/text/TextShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/text/toolStates/Idle.js +10 -4
- package/dist-cjs/lib/shapes/text/toolStates/Idle.js.map +2 -2
- package/dist-cjs/lib/shapes/text/toolStates/Pointing.js +5 -7
- package/dist-cjs/lib/shapes/text/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/shapes/video/VideoShapeUtil.js +1 -1
- package/dist-cjs/lib/shapes/video/VideoShapeUtil.js.map +2 -2
- package/dist-cjs/lib/tools/EraserTool/childStates/Erasing.js +5 -4
- package/dist-cjs/lib/tools/EraserTool/childStates/Erasing.js.map +2 -2
- package/dist-cjs/lib/tools/EraserTool/childStates/Pointing.js +4 -2
- package/dist-cjs/lib/tools/EraserTool/childStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/tools/HandTool/HandTool.js +5 -3
- package/dist-cjs/lib/tools/HandTool/HandTool.js.map +2 -2
- package/dist-cjs/lib/tools/HandTool/childStates/Dragging.js +2 -3
- package/dist-cjs/lib/tools/HandTool/childStates/Dragging.js.map +2 -2
- package/dist-cjs/lib/tools/HandTool/childStates/Pointing.js +1 -1
- package/dist-cjs/lib/tools/HandTool/childStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/tools/LaserTool/childStates/Lasering.js +1 -1
- package/dist-cjs/lib/tools/LaserTool/childStates/Lasering.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/DragAndDropManager.js +11 -10
- package/dist-cjs/lib/tools/SelectTool/DragAndDropManager.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Brushing.js +5 -6
- package/dist-cjs/lib/tools/SelectTool/childStates/Brushing.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/Cropping.js +6 -4
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/Cropping.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/Idle.js +1 -1
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/Idle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.js +1 -1
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/PointingCropHandle.js +1 -1
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/PointingCropHandle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.js +1 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.js +1 -1
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js +6 -8
- package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/EditingShape.js +11 -38
- package/dist-cjs/lib/tools/SelectTool/childStates/EditingShape.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Idle.js +50 -42
- package/dist-cjs/lib/tools/SelectTool/childStates/Idle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingArrowLabel.js +6 -6
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingArrowLabel.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingCanvas.js +1 -1
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingCanvas.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingHandle.js +14 -4
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingHandle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingResizeHandle.js +1 -1
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingResizeHandle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingRotateHandle.js +1 -1
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingRotateHandle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingSelection.js +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingSelection.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingShape.js +13 -4
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingShape.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js +6 -5
- package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Rotating.js +3 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Rotating.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/ScribbleBrushing.js +6 -7
- package/dist-cjs/lib/tools/SelectTool/childStates/ScribbleBrushing.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js +11 -13
- package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/selectHelpers.js +4 -15
- package/dist-cjs/lib/tools/SelectTool/selectHelpers.js.map +2 -2
- package/dist-cjs/lib/tools/ZoomTool/ZoomTool.js +1 -1
- package/dist-cjs/lib/tools/ZoomTool/ZoomTool.js.map +2 -2
- package/dist-cjs/lib/tools/ZoomTool/childStates/Pointing.js +3 -3
- package/dist-cjs/lib/tools/ZoomTool/childStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/tools/ZoomTool/childStates/ZoomBrushing.js +6 -5
- package/dist-cjs/lib/tools/ZoomTool/childStates/ZoomBrushing.js.map +2 -2
- package/dist-cjs/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.js +3 -1
- package/dist-cjs/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.js.map +2 -2
- package/dist-cjs/lib/{utils/test-helpers.js → tools/selection-logic/getShouldEnterCropModeOnPointerDown.js} +8 -21
- package/dist-cjs/lib/tools/selection-logic/getShouldEnterCropModeOnPointerDown.js.map +7 -0
- package/dist-cjs/lib/tools/selection-logic/selectOnCanvasPointerUp.js +1 -1
- package/dist-cjs/lib/tools/selection-logic/selectOnCanvasPointerUp.js.map +2 -2
- package/dist-cjs/lib/tools/selection-logic/updateHoveredShapeId.js +1 -1
- package/dist-cjs/lib/tools/selection-logic/updateHoveredShapeId.js.map +2 -2
- package/dist-cjs/lib/ui/TldrawUi.js +2 -2
- package/dist-cjs/lib/ui/TldrawUi.js.map +2 -2
- package/dist-cjs/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.js +9 -3
- package/dist-cjs/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.js.map +2 -2
- package/dist-cjs/lib/ui/components/ContextMenu/DefaultContextMenu.js +3 -1
- package/dist-cjs/lib/ui/components/ContextMenu/DefaultContextMenu.js.map +2 -2
- package/dist-cjs/lib/ui/components/CursorChatBubble.js +1 -1
- package/dist-cjs/lib/ui/components/CursorChatBubble.js.map +2 -2
- package/dist-cjs/lib/ui/components/DefaultDebugPanel.js +21 -1
- package/dist-cjs/lib/ui/components/DefaultDebugPanel.js.map +2 -2
- package/dist-cjs/lib/ui/components/EditLinkDialog.js +1 -11
- package/dist-cjs/lib/ui/components/EditLinkDialog.js.map +2 -2
- package/dist-cjs/lib/ui/components/HelperButtons/StopFollowing.js.map +2 -2
- package/dist-cjs/lib/ui/components/Minimap/DefaultMinimap.js +1 -1
- package/dist-cjs/lib/ui/components/Minimap/DefaultMinimap.js.map +2 -2
- package/dist-cjs/lib/ui/components/OfflineIndicator/OfflineIndicator.js +15 -2
- package/dist-cjs/lib/ui/components/OfflineIndicator/OfflineIndicator.js.map +3 -3
- package/dist-cjs/lib/ui/components/PageMenu/PageItemInput.js +1 -3
- package/dist-cjs/lib/ui/components/PageMenu/PageItemInput.js.map +2 -2
- package/dist-cjs/lib/ui/components/SharePanel/PeopleMenu.js +0 -6
- package/dist-cjs/lib/ui/components/SharePanel/PeopleMenu.js.map +2 -2
- package/dist-cjs/lib/ui/components/Toolbar/AltTextEditor.js.map +2 -2
- package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbar.js +1 -1
- package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbar.js.map +2 -2
- package/dist-cjs/lib/ui/components/Toolbar/DefaultRichTextToolbar.js +1 -1
- package/dist-cjs/lib/ui/components/Toolbar/DefaultRichTextToolbar.js.map +2 -2
- package/dist-cjs/lib/ui/components/TopPanel/CenteredTopPanelContainer.js.map +1 -1
- package/dist-cjs/lib/ui/components/TopPanel/DefaultTopPanel.js +32 -0
- package/dist-cjs/lib/ui/components/TopPanel/DefaultTopPanel.js.map +7 -0
- package/dist-cjs/lib/ui/components/menu-items.js +1 -3
- package/dist-cjs/lib/ui/components/menu-items.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiContextualToolbar.js +1 -3
- package/dist-cjs/lib/ui/components/primitives/TldrawUiContextualToolbar.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiSlider.js +1 -1
- package/dist-cjs/lib/ui/components/primitives/TldrawUiSlider.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js +93 -149
- package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuActionCheckboxItem.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuActionItem.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js +1 -1
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js.map +2 -2
- package/dist-cjs/lib/ui/context/actions.js +8 -7
- package/dist-cjs/lib/ui/context/actions.js.map +2 -2
- package/dist-cjs/lib/ui/context/components.js +2 -1
- package/dist-cjs/lib/ui/context/components.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/menu-hooks.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/useClipboardEvents.js +2 -2
- package/dist-cjs/lib/ui/hooks/useClipboardEvents.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/useFlatten.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 +5 -4
- package/dist-cjs/lib/ui/hooks/useTools.js.map +2 -2
- package/dist-cjs/lib/ui/version.js +3 -3
- package/dist-cjs/lib/ui/version.js.map +1 -1
- package/dist-cjs/lib/utils/excalidraw/putExcalidrawContent.js +6 -16
- package/dist-cjs/lib/utils/excalidraw/putExcalidrawContent.js.map +2 -2
- package/dist-cjs/lib/utils/export/exportAs.js.map +2 -2
- package/dist-cjs/lib/utils/frames/frames.js.map +2 -2
- package/dist-cjs/lib/utils/text/richText.js +2 -4
- package/dist-cjs/lib/utils/text/richText.js.map +2 -2
- package/dist-cjs/lib/utils/text/textDirection.js +51 -0
- package/dist-cjs/lib/utils/text/textDirection.js.map +7 -0
- package/dist-cjs/lib/utils/tldr/buildFromV1Document.js +2 -7
- package/dist-cjs/lib/utils/tldr/buildFromV1Document.js.map +2 -2
- package/dist-esm/index.d.mts +242 -311
- package/dist-esm/index.mjs +5 -14
- package/dist-esm/index.mjs.map +2 -2
- package/dist-esm/lib/bindings/arrow/ArrowBindingUtil.mjs.map +2 -2
- package/dist-esm/lib/canvas/TldrawSelectionForeground.mjs +4 -8
- package/dist-esm/lib/canvas/TldrawSelectionForeground.mjs.map +2 -2
- package/dist-esm/lib/defaultEmbedDefinitions.mjs.map +2 -2
- package/dist-esm/lib/defaultExternalContentHandlers.mjs +5 -5
- package/dist-esm/lib/defaultExternalContentHandlers.mjs.map +2 -2
- package/dist-esm/lib/defaultSideEffects.mjs +1 -6
- package/dist-esm/lib/defaultSideEffects.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs +15 -15
- package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/arrowLabel.mjs +1 -1
- 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/elbowArrowSnapLines.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/shared.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/toolStates/Idle.mjs +10 -4
- package/dist-esm/lib/shapes/arrow/toolStates/Idle.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs +4 -7
- package/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/shapes/bookmark/BookmarkShapeUtil.mjs +1 -1
- package/dist-esm/lib/shapes/bookmark/BookmarkShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/bookmark/bookmarks.mjs.map +2 -2
- package/dist-esm/lib/shapes/draw/DrawShapeUtil.mjs +24 -29
- package/dist-esm/lib/shapes/draw/DrawShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/draw/getPath.mjs +11 -21
- package/dist-esm/lib/shapes/draw/getPath.mjs.map +2 -2
- package/dist-esm/lib/shapes/draw/toolStates/Drawing.mjs +86 -83
- package/dist-esm/lib/shapes/draw/toolStates/Drawing.mjs.map +3 -3
- package/dist-esm/lib/shapes/embed/EmbedShapeUtil.mjs +0 -6
- package/dist-esm/lib/shapes/embed/EmbedShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/frame/FrameShapeTool.mjs.map +1 -1
- package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs +5 -6
- package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/geo/GeoShapeUtil.mjs +142 -147
- package/dist-esm/lib/shapes/geo/GeoShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/geo/toolStates/Idle.mjs +10 -5
- package/dist-esm/lib/shapes/geo/toolStates/Idle.mjs.map +2 -2
- package/dist-esm/lib/shapes/geo/toolStates/Pointing.mjs +3 -3
- package/dist-esm/lib/shapes/geo/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/shapes/highlight/HighlightShapeUtil.mjs +22 -24
- package/dist-esm/lib/shapes/highlight/HighlightShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/line/toolStates/Pointing.mjs +3 -3
- package/dist-esm/lib/shapes/line/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs +12 -7
- package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/note/noteHelpers.mjs.map +2 -2
- package/dist-esm/lib/shapes/note/toolStates/Pointing.mjs +10 -5
- package/dist-esm/lib/shapes/note/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/HyperlinkButton.mjs +3 -4
- package/dist-esm/lib/shapes/shared/HyperlinkButton.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/PlainTextLabel.mjs +2 -14
- package/dist-esm/lib/shapes/shared/PlainTextLabel.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/RichTextLabel.mjs +4 -12
- package/dist-esm/lib/shapes/shared/RichTextLabel.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/ShapeFill.mjs +2 -2
- package/dist-esm/lib/shapes/shared/ShapeFill.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/crop.mjs +0 -1
- package/dist-esm/lib/shapes/shared/crop.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/interpolate-props.mjs +4 -4
- package/dist-esm/lib/shapes/shared/interpolate-props.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/useEditablePlainText.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/useEditableRichText.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/useForceSolid.mjs +9 -0
- package/dist-esm/lib/shapes/shared/useForceSolid.mjs.map +7 -0
- package/dist-esm/lib/shapes/shared/useImageOrVideoAsset.mjs +1 -1
- package/dist-esm/lib/shapes/shared/useImageOrVideoAsset.mjs.map +2 -2
- package/dist-esm/lib/shapes/text/RichTextArea.mjs +0 -5
- package/dist-esm/lib/shapes/text/RichTextArea.mjs.map +2 -2
- package/dist-esm/lib/shapes/text/TextShapeUtil.mjs +2 -5
- package/dist-esm/lib/shapes/text/TextShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/text/toolStates/Idle.mjs +10 -4
- package/dist-esm/lib/shapes/text/toolStates/Idle.mjs.map +2 -2
- package/dist-esm/lib/shapes/text/toolStates/Pointing.mjs +5 -7
- package/dist-esm/lib/shapes/text/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/shapes/video/VideoShapeUtil.mjs +1 -1
- package/dist-esm/lib/shapes/video/VideoShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/tools/EraserTool/childStates/Erasing.mjs +5 -4
- package/dist-esm/lib/tools/EraserTool/childStates/Erasing.mjs.map +2 -2
- package/dist-esm/lib/tools/EraserTool/childStates/Pointing.mjs +8 -3
- package/dist-esm/lib/tools/EraserTool/childStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/tools/HandTool/HandTool.mjs +5 -3
- package/dist-esm/lib/tools/HandTool/HandTool.mjs.map +2 -2
- package/dist-esm/lib/tools/HandTool/childStates/Dragging.mjs +2 -3
- package/dist-esm/lib/tools/HandTool/childStates/Dragging.mjs.map +2 -2
- package/dist-esm/lib/tools/HandTool/childStates/Pointing.mjs +1 -1
- package/dist-esm/lib/tools/HandTool/childStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/tools/LaserTool/childStates/Lasering.mjs +1 -1
- package/dist-esm/lib/tools/LaserTool/childStates/Lasering.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/DragAndDropManager.mjs +11 -10
- package/dist-esm/lib/tools/SelectTool/DragAndDropManager.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Brushing.mjs +5 -6
- package/dist-esm/lib/tools/SelectTool/childStates/Brushing.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/Cropping.mjs +6 -4
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/Cropping.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/Idle.mjs +1 -1
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/Idle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.mjs +1 -1
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCropHandle.mjs +1 -1
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCropHandle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.mjs +1 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.mjs +1 -1
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs +6 -8
- package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/EditingShape.mjs +11 -38
- package/dist-esm/lib/tools/SelectTool/childStates/EditingShape.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Idle.mjs +51 -43
- package/dist-esm/lib/tools/SelectTool/childStates/Idle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingArrowLabel.mjs +6 -6
- package/dist-esm/lib/tools/SelectTool/childStates/PointingArrowLabel.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingCanvas.mjs +1 -1
- package/dist-esm/lib/tools/SelectTool/childStates/PointingCanvas.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingHandle.mjs +19 -6
- package/dist-esm/lib/tools/SelectTool/childStates/PointingHandle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingResizeHandle.mjs +1 -1
- package/dist-esm/lib/tools/SelectTool/childStates/PointingResizeHandle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingRotateHandle.mjs +1 -1
- package/dist-esm/lib/tools/SelectTool/childStates/PointingRotateHandle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingSelection.mjs +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingSelection.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingShape.mjs +13 -4
- package/dist-esm/lib/tools/SelectTool/childStates/PointingShape.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs +6 -5
- package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Rotating.mjs +3 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Rotating.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/ScribbleBrushing.mjs +6 -7
- package/dist-esm/lib/tools/SelectTool/childStates/ScribbleBrushing.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs +11 -13
- package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/selectHelpers.mjs +4 -17
- package/dist-esm/lib/tools/SelectTool/selectHelpers.mjs.map +2 -2
- package/dist-esm/lib/tools/ZoomTool/ZoomTool.mjs +1 -1
- package/dist-esm/lib/tools/ZoomTool/ZoomTool.mjs.map +2 -2
- package/dist-esm/lib/tools/ZoomTool/childStates/Pointing.mjs +3 -3
- package/dist-esm/lib/tools/ZoomTool/childStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/tools/ZoomTool/childStates/ZoomBrushing.mjs +6 -5
- package/dist-esm/lib/tools/ZoomTool/childStates/ZoomBrushing.mjs.map +2 -2
- package/dist-esm/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.mjs +3 -1
- package/dist-esm/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.mjs.map +2 -2
- package/dist-esm/lib/tools/selection-logic/getShouldEnterCropModeOnPointerDown.mjs +8 -0
- package/dist-esm/lib/tools/selection-logic/getShouldEnterCropModeOnPointerDown.mjs.map +7 -0
- package/dist-esm/lib/tools/selection-logic/selectOnCanvasPointerUp.mjs +1 -1
- package/dist-esm/lib/tools/selection-logic/selectOnCanvasPointerUp.mjs.map +2 -2
- package/dist-esm/lib/tools/selection-logic/updateHoveredShapeId.mjs +1 -1
- package/dist-esm/lib/tools/selection-logic/updateHoveredShapeId.mjs.map +2 -2
- package/dist-esm/lib/ui/TldrawUi.mjs +2 -2
- package/dist-esm/lib/ui/TldrawUi.mjs.map +2 -2
- package/dist-esm/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.mjs +8 -2
- package/dist-esm/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.mjs.map +2 -2
- package/dist-esm/lib/ui/components/ContextMenu/DefaultContextMenu.mjs +3 -1
- package/dist-esm/lib/ui/components/ContextMenu/DefaultContextMenu.mjs.map +2 -2
- package/dist-esm/lib/ui/components/CursorChatBubble.mjs +1 -1
- package/dist-esm/lib/ui/components/CursorChatBubble.mjs.map +2 -2
- package/dist-esm/lib/ui/components/DefaultDebugPanel.mjs +30 -3
- package/dist-esm/lib/ui/components/DefaultDebugPanel.mjs.map +2 -2
- package/dist-esm/lib/ui/components/EditLinkDialog.mjs +1 -11
- package/dist-esm/lib/ui/components/EditLinkDialog.mjs.map +2 -2
- package/dist-esm/lib/ui/components/HelperButtons/StopFollowing.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Minimap/DefaultMinimap.mjs +1 -1
- package/dist-esm/lib/ui/components/Minimap/DefaultMinimap.mjs.map +2 -2
- package/dist-esm/lib/ui/components/OfflineIndicator/OfflineIndicator.mjs +6 -3
- package/dist-esm/lib/ui/components/OfflineIndicator/OfflineIndicator.mjs.map +2 -2
- package/dist-esm/lib/ui/components/PageMenu/PageItemInput.mjs +1 -3
- package/dist-esm/lib/ui/components/PageMenu/PageItemInput.mjs.map +2 -2
- package/dist-esm/lib/ui/components/SharePanel/PeopleMenu.mjs +0 -6
- package/dist-esm/lib/ui/components/SharePanel/PeopleMenu.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Toolbar/AltTextEditor.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbar.mjs +1 -1
- package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbar.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Toolbar/DefaultRichTextToolbar.mjs +1 -1
- package/dist-esm/lib/ui/components/Toolbar/DefaultRichTextToolbar.mjs.map +2 -2
- package/dist-esm/lib/ui/components/TopPanel/CenteredTopPanelContainer.mjs.map +1 -1
- package/dist-esm/lib/ui/components/TopPanel/DefaultTopPanel.mjs +12 -0
- package/dist-esm/lib/ui/components/TopPanel/DefaultTopPanel.mjs.map +7 -0
- package/dist-esm/lib/ui/components/menu-items.mjs +5 -4
- package/dist-esm/lib/ui/components/menu-items.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiContextualToolbar.mjs +1 -3
- package/dist-esm/lib/ui/components/primitives/TldrawUiContextualToolbar.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiSlider.mjs +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiSlider.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs +95 -157
- package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuActionCheckboxItem.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuActionItem.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs +2 -2
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs.map +2 -2
- package/dist-esm/lib/ui/context/actions.mjs +8 -7
- package/dist-esm/lib/ui/context/actions.mjs.map +2 -2
- package/dist-esm/lib/ui/context/components.mjs +2 -1
- package/dist-esm/lib/ui/context/components.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/menu-hooks.mjs +4 -1
- package/dist-esm/lib/ui/hooks/menu-hooks.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/useClipboardEvents.mjs +2 -2
- package/dist-esm/lib/ui/hooks/useClipboardEvents.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/useFlatten.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 +5 -4
- package/dist-esm/lib/ui/hooks/useTools.mjs.map +2 -2
- package/dist-esm/lib/ui/version.mjs +3 -3
- package/dist-esm/lib/ui/version.mjs.map +1 -1
- package/dist-esm/lib/utils/excalidraw/putExcalidrawContent.mjs +6 -17
- package/dist-esm/lib/utils/excalidraw/putExcalidrawContent.mjs.map +2 -2
- package/dist-esm/lib/utils/export/exportAs.mjs +3 -1
- package/dist-esm/lib/utils/export/exportAs.mjs.map +2 -2
- package/dist-esm/lib/utils/frames/frames.mjs.map +2 -2
- package/dist-esm/lib/utils/text/richText.mjs +2 -5
- package/dist-esm/lib/utils/text/richText.mjs.map +2 -2
- package/dist-esm/lib/utils/text/textDirection.mjs +31 -0
- package/dist-esm/lib/utils/text/textDirection.mjs.map +7 -0
- package/dist-esm/lib/utils/tldr/buildFromV1Document.mjs +2 -8
- package/dist-esm/lib/utils/tldr/buildFromV1Document.mjs.map +2 -2
- package/package.json +16 -18
- package/src/index.ts +2 -6
- package/src/lib/Tldraw.test.tsx +1 -46
- package/src/lib/bindings/arrow/ArrowBindingUtil.ts +1 -1
- package/src/lib/canvas/TldrawSelectionForeground.tsx +9 -20
- package/src/lib/defaultEmbedDefinitions.ts +0 -1
- package/src/lib/defaultExternalContentHandlers.ts +14 -13
- package/src/lib/defaultSideEffects.ts +1 -6
- package/src/lib/shapes/arrow/ArrowShapeOptions.test.ts +133 -40
- package/src/lib/shapes/arrow/ArrowShapeTool.test.ts +8 -8
- package/src/lib/shapes/arrow/ArrowShapeUtil.test.ts +2 -2
- package/src/lib/shapes/arrow/ArrowShapeUtil.tsx +16 -16
- package/src/lib/shapes/arrow/arrow-types.ts +0 -2
- package/src/lib/shapes/arrow/arrowLabel.ts +2 -2
- package/src/lib/shapes/arrow/arrowTargetState.ts +2 -2
- package/src/lib/shapes/arrow/elbow/elbowArrowSnapLines.tsx +3 -3
- package/src/lib/shapes/arrow/shared.ts +4 -4
- package/src/lib/shapes/arrow/toolStates/Idle.tsx +14 -4
- package/src/lib/shapes/arrow/toolStates/Pointing.tsx +5 -8
- package/src/lib/shapes/bookmark/BookmarkShapeUtil.tsx +1 -1
- package/src/lib/shapes/bookmark/bookmarks.ts +3 -3
- package/src/lib/shapes/draw/DrawShapeUtil.tsx +26 -30
- package/src/lib/shapes/draw/getPath.ts +10 -31
- package/src/lib/shapes/draw/toolStates/Drawing.ts +90 -100
- package/src/lib/shapes/embed/EmbedShapeUtil.tsx +1 -8
- package/src/lib/shapes/frame/FrameShapeTool.ts +1 -1
- package/src/lib/shapes/frame/FrameShapeUtil.tsx +4 -10
- package/src/lib/shapes/geo/GeoShapeUtil.test.tsx +2 -10
- package/src/lib/shapes/geo/GeoShapeUtil.tsx +176 -228
- package/src/lib/shapes/geo/toolStates/Idle.ts +15 -5
- package/src/lib/shapes/geo/toolStates/Pointing.ts +6 -6
- package/src/lib/shapes/highlight/HighlightShapeUtil.tsx +24 -25
- package/src/lib/shapes/line/LineShapeTool.test.ts +6 -6
- package/src/lib/shapes/line/LineShapeUtil.test.tsx +5 -5
- package/src/lib/shapes/line/toolStates/Pointing.ts +4 -4
- package/src/lib/shapes/note/NoteShapeTool.test.ts +1 -2
- package/src/lib/shapes/note/NoteShapeUtil.tsx +10 -9
- package/src/lib/shapes/note/noteCloning.test.ts +1 -3
- package/src/lib/shapes/note/noteHelpers.ts +2 -2
- package/src/lib/shapes/note/toolStates/Pointing.ts +10 -5
- package/src/lib/shapes/shared/HyperlinkButton.tsx +3 -4
- package/src/lib/shapes/shared/PlainTextLabel.tsx +2 -12
- package/src/lib/shapes/shared/RichTextLabel.tsx +4 -14
- package/src/lib/shapes/shared/ShapeFill.tsx +2 -2
- package/src/lib/shapes/shared/crop.ts +0 -1
- package/src/lib/shapes/shared/interpolate-props.ts +4 -4
- package/src/lib/shapes/shared/useEditablePlainText.ts +3 -7
- package/src/lib/shapes/shared/useEditableRichText.ts +3 -7
- package/src/lib/shapes/shared/useForceSolid.ts +6 -0
- package/src/lib/shapes/shared/useImageOrVideoAsset.ts +1 -1
- package/src/lib/shapes/text/RichTextArea.tsx +0 -5
- package/src/lib/shapes/text/TextShapeTool.test.ts +4 -4
- package/src/lib/shapes/text/TextShapeUtil.tsx +0 -5
- package/src/lib/shapes/text/toolStates/Idle.ts +14 -4
- package/src/lib/shapes/text/toolStates/Pointing.ts +8 -8
- package/src/lib/shapes/video/VideoShapeUtil.tsx +1 -2
- package/src/lib/tools/EraserTool/childStates/Erasing.ts +10 -7
- package/src/lib/tools/EraserTool/childStates/Pointing.ts +20 -5
- package/src/lib/tools/HandTool/HandTool.ts +5 -3
- package/src/lib/tools/HandTool/childStates/Dragging.ts +2 -3
- package/src/lib/tools/HandTool/childStates/Pointing.ts +1 -1
- package/src/lib/tools/LaserTool/childStates/Lasering.ts +1 -1
- package/src/lib/tools/SelectTool/DragAndDropManager.ts +11 -14
- package/src/lib/tools/SelectTool/childStates/Brushing.ts +11 -8
- package/src/lib/tools/SelectTool/childStates/Crop/children/Cropping.ts +6 -7
- package/src/lib/tools/SelectTool/childStates/Crop/children/Idle.ts +4 -3
- package/src/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.ts +1 -1
- package/src/lib/tools/SelectTool/childStates/Crop/children/PointingCropHandle.ts +1 -1
- package/src/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.ts +1 -2
- package/src/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.ts +1 -1
- package/src/lib/tools/SelectTool/childStates/DraggingHandle.tsx +12 -11
- package/src/lib/tools/SelectTool/childStates/EditingShape.ts +16 -57
- package/src/lib/tools/SelectTool/childStates/Idle.ts +81 -64
- package/src/lib/tools/SelectTool/childStates/PointingArrowLabel.ts +8 -7
- package/src/lib/tools/SelectTool/childStates/PointingCanvas.ts +1 -1
- package/src/lib/tools/SelectTool/childStates/PointingHandle.ts +17 -9
- package/src/lib/tools/SelectTool/childStates/PointingResizeHandle.ts +1 -1
- package/src/lib/tools/SelectTool/childStates/PointingRotateHandle.ts +1 -1
- package/src/lib/tools/SelectTool/childStates/PointingSelection.ts +4 -4
- package/src/lib/tools/SelectTool/childStates/PointingShape.ts +14 -4
- package/src/lib/tools/SelectTool/childStates/Resizing.ts +10 -8
- package/src/lib/tools/SelectTool/childStates/Rotating.ts +3 -2
- package/src/lib/tools/SelectTool/childStates/ScribbleBrushing.ts +10 -9
- package/src/lib/tools/SelectTool/childStates/Translating.ts +15 -16
- package/src/lib/tools/SelectTool/selectHelpers.ts +4 -39
- package/src/lib/tools/ZoomTool/ZoomTool.ts +1 -1
- package/src/lib/tools/ZoomTool/childStates/Pointing.ts +3 -3
- package/src/lib/tools/ZoomTool/childStates/ZoomBrushing.ts +6 -5
- package/src/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.ts +3 -1
- package/src/lib/tools/selection-logic/getShouldEnterCropModeOnPointerDown.ts +10 -0
- package/src/lib/tools/selection-logic/selectOnCanvasPointerUp.ts +1 -1
- package/src/lib/tools/selection-logic/updateHoveredShapeId.ts +1 -1
- package/src/lib/ui/TldrawUi.tsx +2 -5
- package/src/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.tsx +9 -1
- package/src/lib/ui/components/ContextMenu/DefaultContextMenu.tsx +3 -1
- package/src/lib/ui/components/CursorChatBubble.tsx +2 -2
- package/src/lib/ui/components/DefaultDebugPanel.tsx +42 -3
- package/src/lib/ui/components/EditLinkDialog.tsx +6 -16
- package/src/lib/ui/components/HelperButtons/StopFollowing.tsx +2 -2
- package/src/lib/ui/components/Minimap/DefaultMinimap.tsx +1 -1
- package/src/lib/ui/components/OfflineIndicator/OfflineIndicator.tsx +5 -6
- package/src/lib/ui/components/PageMenu/PageItemInput.tsx +1 -3
- package/src/lib/ui/components/SharePanel/PeopleMenu.tsx +0 -8
- package/src/lib/ui/components/Toolbar/AltTextEditor.tsx +2 -2
- package/src/lib/ui/components/Toolbar/DefaultImageToolbar.tsx +1 -1
- package/src/lib/ui/components/Toolbar/DefaultRichTextToolbar.tsx +1 -1
- package/src/lib/ui/components/TopPanel/CenteredTopPanelContainer.tsx +1 -1
- package/src/lib/ui/components/TopPanel/DefaultTopPanel.tsx +10 -0
- package/src/lib/ui/components/menu-items.tsx +15 -9
- package/src/lib/ui/components/primitives/TldrawUiContextualToolbar.tsx +3 -5
- package/src/lib/ui/components/primitives/TldrawUiSlider.tsx +2 -2
- package/src/lib/ui/components/primitives/TldrawUiTooltip.tsx +113 -208
- package/src/lib/ui/components/primitives/menus/TldrawUiMenuActionCheckboxItem.tsx +1 -1
- package/src/lib/ui/components/primitives/menus/TldrawUiMenuActionItem.tsx +1 -1
- package/src/lib/ui/components/primitives/menus/TldrawUiMenuItem.tsx +2 -2
- package/src/lib/ui/context/actions.tsx +19 -15
- package/src/lib/ui/context/components.tsx +2 -1
- package/src/lib/ui/hooks/menu-hooks.ts +19 -9
- package/src/lib/ui/hooks/useClipboardEvents.ts +2 -2
- package/src/lib/ui/hooks/useFlatten.ts +2 -1
- package/src/lib/ui/hooks/useKeyboardShortcuts.ts +2 -2
- package/src/lib/ui/hooks/useTools.tsx +7 -5
- package/src/lib/ui/version.ts +3 -3
- package/src/lib/ui.css +29 -31
- package/src/lib/utils/excalidraw/__snapshots__/putExcalidrawContent.test.tsx.snap +48 -12
- package/src/lib/utils/excalidraw/putExcalidrawContent.ts +6 -19
- package/src/lib/utils/export/exportAs.ts +9 -2
- package/src/lib/utils/frames/frames.ts +1 -1
- package/src/lib/utils/text/richText.ts +5 -6
- package/src/lib/utils/text/textDirection.ts +32 -0
- package/src/lib/utils/tldr/buildFromV1Document.ts +19 -21
- package/src/test/Editor.test.tsx +41 -78
- package/src/test/EraserTool.test.ts +12 -10
- package/src/test/SelectTool.test.ts +19 -11
- package/src/test/TestEditor.ts +51 -49
- package/src/test/TldrawEditor.test.tsx +20 -24
- package/src/test/__snapshots__/drawing.test.ts.snap +1257 -3
- package/src/test/__snapshots__/resizing.test.ts.snap +12 -3
- package/src/test/arrows-megabus.test.tsx +1 -1
- package/src/test/bindings.test.tsx +25 -29
- package/src/test/bindingsIndex.test.tsx +4 -4
- package/src/test/commands/__snapshots__/getSvgString.test.ts.snap +10 -10
- package/src/test/commands/createShapes.test.ts +1 -15
- package/src/test/commands/getSvgString.test.ts +2 -2
- package/src/test/commands/putContent.test.ts +1 -80
- package/src/test/commands/setCamera.test.ts +11 -13
- package/src/test/commands/stackShapes.test.ts +8 -34
- package/src/test/commands/updateShapes.test.ts +5 -21
- package/src/test/commands/zoomToBounds.test.ts +3 -19
- package/src/test/commands/zoomToSelection.test.ts +3 -14
- package/src/test/custom-clipping.test.ts +44 -52
- package/src/test/customSnapping.test.tsx +62 -77
- package/src/test/drawing.test.ts +10 -17
- package/src/test/duplicate.test.ts +1 -1
- package/src/test/flipShapes.test.ts +0 -33
- package/src/test/frames.test.ts +2 -94
- package/src/test/getCulledShapes.test.tsx +3 -11
- package/src/test/getShapeAtPoint.test.ts +2 -2
- package/src/test/groups.test.tsx +4 -7
- package/src/test/modifiers.test.ts +6 -6
- package/src/test/resizing.test.ts +22 -16
- package/src/test/selection-omnibus.test.ts +13 -13
- package/src/test/shapeutils.test.ts +1 -1
- package/src/test/spacebarPanning.test.ts +10 -28
- package/src/test/styles2.test.tsx +1 -1
- package/src/test/styles3.test.ts +5 -5
- package/src/test/test-jsx.tsx +57 -72
- package/src/test/text.test.ts +17 -15
- package/src/test/translating.test.ts +8 -6
- package/tldraw.css +41 -45
- package/dist-cjs/lib/shapes/shared/useEfficientZoomThreshold.js.map +0 -7
- package/dist-cjs/lib/utils/test-helpers.js.map +0 -7
- package/dist-esm/lib/shapes/shared/useEfficientZoomThreshold.mjs +0 -12
- package/dist-esm/lib/shapes/shared/useEfficientZoomThreshold.mjs.map +0 -7
- package/dist-esm/lib/utils/test-helpers.mjs +0 -21
- package/dist-esm/lib/utils/test-helpers.mjs.map +0 -7
- package/src/lib/shapes/draw/DrawShapeUtil.test.ts +0 -146
- package/src/lib/shapes/highlight/HighlightShapeUtil.test.ts +0 -146
- package/src/lib/shapes/shared/useEfficientZoomThreshold.ts +0 -10
- package/src/lib/utils/test-helpers.ts +0 -60
- package/src/test/commands/cameraState.test.ts +0 -299
- package/src/test/commands/createShape.test.ts +0 -64
- package/src/test/commands/isShapeOfType.test.ts +0 -44
- package/src/test/commands/updateShape.test.ts +0 -67
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
resizeBox,
|
|
9
9
|
StateNode,
|
|
10
10
|
T,
|
|
11
|
+
TLBaseShape,
|
|
11
12
|
TLEventHandlers,
|
|
12
13
|
TLGeoShape,
|
|
13
14
|
TLResizeInfo,
|
|
@@ -18,24 +19,19 @@ import {
|
|
|
18
19
|
} from '@tldraw/editor'
|
|
19
20
|
import { TestEditor } from './TestEditor'
|
|
20
21
|
|
|
21
|
-
const CIRCLE_CLIP_TYPE = 'circle-clip'
|
|
22
|
-
|
|
23
|
-
declare module '@tldraw/tlschema' {
|
|
24
|
-
export interface TLGlobalShapePropsMap {
|
|
25
|
-
[CIRCLE_CLIP_TYPE]: { w: number; h: number }
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
22
|
// Custom Circle Clip Shape Definition
|
|
30
|
-
export type CircleClipShape =
|
|
23
|
+
export type CircleClipShape = TLBaseShape<
|
|
24
|
+
'circle-clip',
|
|
25
|
+
{
|
|
26
|
+
w: number
|
|
27
|
+
h: number
|
|
28
|
+
}
|
|
29
|
+
>
|
|
31
30
|
|
|
32
31
|
export const isClippingEnabled$ = atom('isClippingEnabled', true)
|
|
33
32
|
|
|
34
|
-
// The stroke width used when rendering the circle
|
|
35
|
-
const STROKE_WIDTH = 2
|
|
36
|
-
|
|
37
33
|
export class CircleClipShapeUtil extends BaseBoxShapeUtil<CircleClipShape> {
|
|
38
|
-
static override type =
|
|
34
|
+
static override type = 'circle-clip' as const
|
|
39
35
|
static override props: RecordProps<CircleClipShape> = {
|
|
40
36
|
w: T.number,
|
|
41
37
|
h: T.number,
|
|
@@ -67,20 +63,17 @@ export class CircleClipShapeUtil extends BaseBoxShapeUtil<CircleClipShape> {
|
|
|
67
63
|
}
|
|
68
64
|
|
|
69
65
|
override getClipPath(shape: CircleClipShape): Vec[] | undefined {
|
|
70
|
-
// Generate a polygon approximation of the circle
|
|
71
|
-
// We inset the clip path by half the stroke width so that children are
|
|
72
|
-
// clipped to the inner edge of the stroke, not the center line.
|
|
66
|
+
// Generate a polygon approximation of the circle
|
|
73
67
|
const centerX = shape.props.w / 2
|
|
74
68
|
const centerY = shape.props.h / 2
|
|
75
|
-
const
|
|
76
|
-
const clipRadius = outerRadius - STROKE_WIDTH / 2
|
|
69
|
+
const radius = Math.min(shape.props.w, shape.props.h) / 2
|
|
77
70
|
const segments = 48 // More segments = smoother circle
|
|
78
71
|
|
|
79
72
|
const points: Vec[] = []
|
|
80
73
|
for (let i = 0; i < segments; i++) {
|
|
81
74
|
const angle = (i / segments) * Math.PI * 2
|
|
82
|
-
const x = centerX + Math.cos(angle) *
|
|
83
|
-
const y = centerY + Math.sin(angle) *
|
|
75
|
+
const x = centerX + Math.cos(angle) * radius
|
|
76
|
+
const y = centerY + Math.sin(angle) * radius
|
|
84
77
|
points.push(new Vec(x, y))
|
|
85
78
|
}
|
|
86
79
|
|
|
@@ -118,10 +111,10 @@ export class CircleClipShapeTool extends StateNode {
|
|
|
118
111
|
|
|
119
112
|
override onPointerDown(info: Parameters<TLEventHandlers['onPointerDown']>[0]) {
|
|
120
113
|
if (info.target === 'canvas') {
|
|
121
|
-
const originPagePoint = this.editor.inputs
|
|
114
|
+
const { originPagePoint } = this.editor.inputs
|
|
122
115
|
|
|
123
|
-
this.editor.createShape({
|
|
124
|
-
type:
|
|
116
|
+
this.editor.createShape<CircleClipShape>({
|
|
117
|
+
type: 'circle-clip',
|
|
125
118
|
x: originPagePoint.x - 100,
|
|
126
119
|
y: originPagePoint.y - 100,
|
|
127
120
|
props: {
|
|
@@ -160,9 +153,9 @@ beforeEach(() => {
|
|
|
160
153
|
describe('CircleClipShapeUtil', () => {
|
|
161
154
|
describe('shape creation and properties', () => {
|
|
162
155
|
it('should create a circle clip shape with default properties', () => {
|
|
163
|
-
editor.createShape({
|
|
156
|
+
editor.createShape<CircleClipShape>({
|
|
164
157
|
id: ids.circleClip1,
|
|
165
|
-
type:
|
|
158
|
+
type: 'circle-clip',
|
|
166
159
|
x: 100,
|
|
167
160
|
y: 100,
|
|
168
161
|
props: {
|
|
@@ -179,9 +172,9 @@ describe('CircleClipShapeUtil', () => {
|
|
|
179
172
|
})
|
|
180
173
|
|
|
181
174
|
it('should use default props when not specified', () => {
|
|
182
|
-
editor.createShape({
|
|
175
|
+
editor.createShape<CircleClipShape>({
|
|
183
176
|
id: ids.circleClip1,
|
|
184
|
-
type:
|
|
177
|
+
type: 'circle-clip',
|
|
185
178
|
x: 100,
|
|
186
179
|
y: 100,
|
|
187
180
|
props: {},
|
|
@@ -195,9 +188,9 @@ describe('CircleClipShapeUtil', () => {
|
|
|
195
188
|
|
|
196
189
|
describe('geometry and clipping', () => {
|
|
197
190
|
it('should generate correct circle geometry', () => {
|
|
198
|
-
editor.createShape({
|
|
191
|
+
editor.createShape<CircleClipShape>({
|
|
199
192
|
id: ids.circleClip1,
|
|
200
|
-
type:
|
|
193
|
+
type: 'circle-clip',
|
|
201
194
|
x: 100,
|
|
202
195
|
y: 100,
|
|
203
196
|
props: {
|
|
@@ -217,9 +210,9 @@ describe('CircleClipShapeUtil', () => {
|
|
|
217
210
|
})
|
|
218
211
|
|
|
219
212
|
it('should generate clip path for circle', () => {
|
|
220
|
-
editor.createShape({
|
|
213
|
+
editor.createShape<CircleClipShape>({
|
|
221
214
|
id: ids.circleClip1,
|
|
222
|
-
type:
|
|
215
|
+
type: 'circle-clip',
|
|
223
216
|
x: 100,
|
|
224
217
|
y: 100,
|
|
225
218
|
props: {
|
|
@@ -239,23 +232,22 @@ describe('CircleClipShapeUtil', () => {
|
|
|
239
232
|
|
|
240
233
|
// Should be a polygon approximation of a circle
|
|
241
234
|
// Check that points are roughly in a circle pattern
|
|
242
|
-
|
|
243
|
-
const
|
|
244
|
-
const
|
|
245
|
-
const clipRadius = 99 // min(w, h) / 2 - STROKE_WIDTH / 2 = 100 - 1
|
|
235
|
+
const centerX = 100 // shape.x
|
|
236
|
+
const centerY = 100 // shape.y
|
|
237
|
+
const radius = 100 // min(w, h) / 2
|
|
246
238
|
|
|
247
239
|
clipPath.forEach((point) => {
|
|
248
240
|
const distance = Math.sqrt(Math.pow(point.x - centerX, 2) + Math.pow(point.y - centerY, 2))
|
|
249
|
-
expect(distance).toBeCloseTo(
|
|
241
|
+
expect(distance).toBeCloseTo(radius, 0)
|
|
250
242
|
})
|
|
251
243
|
})
|
|
252
244
|
})
|
|
253
245
|
|
|
254
246
|
describe('child clipping behavior', () => {
|
|
255
247
|
it('should clip children when clipping is enabled', () => {
|
|
256
|
-
editor.createShape({
|
|
248
|
+
editor.createShape<CircleClipShape>({
|
|
257
249
|
id: ids.circleClip1,
|
|
258
|
-
type:
|
|
250
|
+
type: 'circle-clip',
|
|
259
251
|
x: 100,
|
|
260
252
|
y: 100,
|
|
261
253
|
props: {
|
|
@@ -264,7 +256,7 @@ describe('CircleClipShapeUtil', () => {
|
|
|
264
256
|
},
|
|
265
257
|
})
|
|
266
258
|
|
|
267
|
-
editor.createShape({
|
|
259
|
+
editor.createShape<TLTextShape>({
|
|
268
260
|
id: ids.text1,
|
|
269
261
|
type: 'text',
|
|
270
262
|
x: 0,
|
|
@@ -287,9 +279,9 @@ describe('CircleClipShapeUtil', () => {
|
|
|
287
279
|
it('should not clip children when clipping is disabled', () => {
|
|
288
280
|
isClippingEnabled$.set(false)
|
|
289
281
|
|
|
290
|
-
editor.createShape({
|
|
282
|
+
editor.createShape<CircleClipShape>({
|
|
291
283
|
id: ids.circleClip1,
|
|
292
|
-
type:
|
|
284
|
+
type: 'circle-clip',
|
|
293
285
|
x: 100,
|
|
294
286
|
y: 100,
|
|
295
287
|
props: {
|
|
@@ -298,7 +290,7 @@ describe('CircleClipShapeUtil', () => {
|
|
|
298
290
|
},
|
|
299
291
|
})
|
|
300
292
|
|
|
301
|
-
editor.createShape({
|
|
293
|
+
editor.createShape<TLTextShape>({
|
|
302
294
|
id: ids.text1,
|
|
303
295
|
type: 'text',
|
|
304
296
|
x: 0,
|
|
@@ -322,9 +314,9 @@ describe('CircleClipShapeUtil', () => {
|
|
|
322
314
|
describe('Integration tests', () => {
|
|
323
315
|
it('should create and manage circle clip shapes with children', () => {
|
|
324
316
|
// Create circle clip shape
|
|
325
|
-
editor.createShape({
|
|
317
|
+
editor.createShape<CircleClipShape>({
|
|
326
318
|
id: ids.circleClip1,
|
|
327
|
-
type:
|
|
319
|
+
type: 'circle-clip',
|
|
328
320
|
x: 100,
|
|
329
321
|
y: 100,
|
|
330
322
|
props: {
|
|
@@ -334,7 +326,7 @@ describe('Integration tests', () => {
|
|
|
334
326
|
})
|
|
335
327
|
|
|
336
328
|
// Add text child
|
|
337
|
-
editor.createShape({
|
|
329
|
+
editor.createShape<TLTextShape>({
|
|
338
330
|
id: ids.text1,
|
|
339
331
|
type: 'text',
|
|
340
332
|
x: 50,
|
|
@@ -346,7 +338,7 @@ describe('Integration tests', () => {
|
|
|
346
338
|
})
|
|
347
339
|
|
|
348
340
|
// Add geo child
|
|
349
|
-
editor.createShape({
|
|
341
|
+
editor.createShape<TLGeoShape>({
|
|
350
342
|
id: ids.geo1,
|
|
351
343
|
type: 'geo',
|
|
352
344
|
x: 150,
|
|
@@ -383,9 +375,9 @@ describe('Integration tests', () => {
|
|
|
383
375
|
|
|
384
376
|
it('should handle multiple circle clip shapes independently', () => {
|
|
385
377
|
// Create two circle clip shapes
|
|
386
|
-
editor.createShape({
|
|
378
|
+
editor.createShape<CircleClipShape>({
|
|
387
379
|
id: ids.circleClip1,
|
|
388
|
-
type:
|
|
380
|
+
type: 'circle-clip',
|
|
389
381
|
x: 100,
|
|
390
382
|
y: 100,
|
|
391
383
|
props: {
|
|
@@ -394,9 +386,9 @@ describe('Integration tests', () => {
|
|
|
394
386
|
},
|
|
395
387
|
})
|
|
396
388
|
|
|
397
|
-
editor.createShape({
|
|
389
|
+
editor.createShape<CircleClipShape>({
|
|
398
390
|
id: ids.circleClip2,
|
|
399
|
-
type:
|
|
391
|
+
type: 'circle-clip',
|
|
400
392
|
x: 400,
|
|
401
393
|
y: 100,
|
|
402
394
|
props: {
|
|
@@ -406,7 +398,7 @@ describe('Integration tests', () => {
|
|
|
406
398
|
})
|
|
407
399
|
|
|
408
400
|
// Add children to both
|
|
409
|
-
editor.createShape({
|
|
401
|
+
editor.createShape<TLTextShape>({
|
|
410
402
|
id: ids.text1,
|
|
411
403
|
type: 'text',
|
|
412
404
|
x: 0,
|
|
@@ -417,7 +409,7 @@ describe('Integration tests', () => {
|
|
|
417
409
|
},
|
|
418
410
|
})
|
|
419
411
|
|
|
420
|
-
editor.createShape({
|
|
412
|
+
editor.createShape<TLTextShape>({
|
|
421
413
|
id: ids.geo1,
|
|
422
414
|
type: 'text',
|
|
423
415
|
x: 0,
|
|
@@ -4,10 +4,10 @@ import {
|
|
|
4
4
|
Polyline2d,
|
|
5
5
|
ShapeUtil,
|
|
6
6
|
TLAnyShapeUtilConstructor,
|
|
7
|
+
TLBaseShape,
|
|
7
8
|
TLHandle,
|
|
8
9
|
TLHandleDragInfo,
|
|
9
10
|
TLLineShape,
|
|
10
|
-
TLShape,
|
|
11
11
|
TLShapeId,
|
|
12
12
|
Vec,
|
|
13
13
|
VecModel,
|
|
@@ -16,19 +16,13 @@ import {
|
|
|
16
16
|
import { TestEditor } from './TestEditor'
|
|
17
17
|
import { TL } from './test-jsx'
|
|
18
18
|
|
|
19
|
-
const TEST1_TYPE = 'test1'
|
|
20
|
-
|
|
21
|
-
declare module '@tldraw/tlschema' {
|
|
22
|
-
export interface TLGlobalShapePropsMap {
|
|
23
|
-
[TEST1_TYPE]: { w: number; h: number; boundsSnapPoints: VecModel[] | null }
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
type Test1Shape = TLShape<typeof TEST1_TYPE>
|
|
28
|
-
|
|
29
19
|
describe('custom shape bounds snapping - translate', () => {
|
|
30
|
-
|
|
31
|
-
|
|
20
|
+
type TestShape = TLBaseShape<
|
|
21
|
+
'test',
|
|
22
|
+
{ w: number; h: number; boundsSnapPoints: VecModel[] | null }
|
|
23
|
+
>
|
|
24
|
+
class TestShapeUtil extends BaseBoxShapeUtil<TestShape> {
|
|
25
|
+
static override type = 'test'
|
|
32
26
|
override getDefaultProps() {
|
|
33
27
|
return { w: 100, h: 100, boundsSnapPoints: null }
|
|
34
28
|
}
|
|
@@ -38,7 +32,7 @@ describe('custom shape bounds snapping - translate', () => {
|
|
|
38
32
|
override indicator() {
|
|
39
33
|
throw new Error('Method not implemented.')
|
|
40
34
|
}
|
|
41
|
-
override getBoundsSnapGeometry(shape:
|
|
35
|
+
override getBoundsSnapGeometry(shape: TestShape) {
|
|
42
36
|
return {
|
|
43
37
|
points: shape.props.boundsSnapPoints ?? undefined,
|
|
44
38
|
}
|
|
@@ -52,14 +46,14 @@ describe('custom shape bounds snapping - translate', () => {
|
|
|
52
46
|
editor = new TestEditor({ shapeUtils })
|
|
53
47
|
ids = editor.createShapesFromJsx([
|
|
54
48
|
<TL.geo ref="box" x={0} y={0} w={100} h={100} />,
|
|
55
|
-
<TL.
|
|
49
|
+
<TL.test ref="test" x={200} y={200} w={100} h={100} boundsSnapPoints={null} />,
|
|
56
50
|
])
|
|
57
51
|
})
|
|
58
52
|
|
|
59
53
|
describe('with default boundSnapPoints', () => {
|
|
60
54
|
test('normal snapping works with default boundSnapPoints when moving test shape', () => {
|
|
61
55
|
// start translating the test shape
|
|
62
|
-
editor.setSelectedShapes([ids.
|
|
56
|
+
editor.setSelectedShapes([ids.test]).pointerDown(250, 250)
|
|
63
57
|
|
|
64
58
|
// move the left edge of the test shape to the right edge of the box shape - it should snap
|
|
65
59
|
editor.pointerMove(155, 250, undefined, { ctrlKey: true })
|
|
@@ -90,15 +84,15 @@ describe('custom shape bounds snapping - translate', () => {
|
|
|
90
84
|
|
|
91
85
|
describe('with only the center in boundSnapPoints', () => {
|
|
92
86
|
beforeEach(() => {
|
|
93
|
-
editor.updateShape({
|
|
94
|
-
id: ids.
|
|
95
|
-
type:
|
|
87
|
+
editor.updateShape<TestShape>({
|
|
88
|
+
id: ids.test,
|
|
89
|
+
type: 'test',
|
|
96
90
|
props: { boundsSnapPoints: [{ x: 50, y: 50 }] },
|
|
97
91
|
})
|
|
98
92
|
})
|
|
99
93
|
|
|
100
94
|
describe('when moving the test shape', () => {
|
|
101
|
-
beforeEach(() => editor.select(ids.
|
|
95
|
+
beforeEach(() => editor.select(ids.test).pointerDown(250, 250))
|
|
102
96
|
|
|
103
97
|
test('does not snap its edges to the box edges', () => {
|
|
104
98
|
editor.pointerMove(155, 250, undefined, { ctrlKey: true })
|
|
@@ -132,15 +126,15 @@ describe('custom shape bounds snapping - translate', () => {
|
|
|
132
126
|
|
|
133
127
|
describe('with empty boundSnapPoints', () => {
|
|
134
128
|
beforeEach(() => {
|
|
135
|
-
editor.updateShape({
|
|
136
|
-
id: ids.
|
|
137
|
-
type:
|
|
129
|
+
editor.updateShape<TestShape>({
|
|
130
|
+
id: ids.test,
|
|
131
|
+
type: 'test',
|
|
138
132
|
props: { boundsSnapPoints: [] },
|
|
139
133
|
})
|
|
140
134
|
})
|
|
141
135
|
|
|
142
136
|
test('test shape does not snap to anything', () => {
|
|
143
|
-
editor.select(ids.
|
|
137
|
+
editor.select(ids.test).pointerDown(250, 250)
|
|
144
138
|
|
|
145
139
|
// try to snap our left edge to the right edge of the box shape - it should not snap
|
|
146
140
|
editor.pointerMove(155, 250, undefined, { ctrlKey: true })
|
|
@@ -169,11 +163,10 @@ describe('custom shape bounds snapping - translate', () => {
|
|
|
169
163
|
})
|
|
170
164
|
})
|
|
171
165
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
[TEST2_TYPE]: {
|
|
166
|
+
describe('custom handle snapping', () => {
|
|
167
|
+
type TestShape = TLBaseShape<
|
|
168
|
+
'test',
|
|
169
|
+
{
|
|
177
170
|
w: number
|
|
178
171
|
h: number
|
|
179
172
|
ownHandle: VecModel
|
|
@@ -183,15 +176,10 @@ declare module '@tldraw/tlschema' {
|
|
|
183
176
|
selfSnapPoints: VecModel[] | 'default'
|
|
184
177
|
handleSnapType?: 'point' | 'align'
|
|
185
178
|
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
describe('custom handle snapping', () => {
|
|
192
|
-
class TestShapeUtil extends BaseBoxShapeUtil<Test2Shape> {
|
|
193
|
-
static override type = TEST2_TYPE
|
|
194
|
-
override getDefaultProps(): Test2Shape['props'] {
|
|
179
|
+
>
|
|
180
|
+
class TestShapeUtil extends BaseBoxShapeUtil<TestShape> {
|
|
181
|
+
static override type = 'test'
|
|
182
|
+
override getDefaultProps(): TestShape['props'] {
|
|
195
183
|
return {
|
|
196
184
|
w: 100,
|
|
197
185
|
h: 100,
|
|
@@ -208,7 +196,7 @@ describe('custom handle snapping', () => {
|
|
|
208
196
|
override indicator() {
|
|
209
197
|
throw new Error('Method not implemented.')
|
|
210
198
|
}
|
|
211
|
-
override getHandleSnapGeometry(shape:
|
|
199
|
+
override getHandleSnapGeometry(shape: TestShape) {
|
|
212
200
|
const { handleOutline, handlePoints, selfSnapOutline, selfSnapPoints } = shape.props
|
|
213
201
|
return {
|
|
214
202
|
outline:
|
|
@@ -226,7 +214,7 @@ describe('custom handle snapping', () => {
|
|
|
226
214
|
getSelfSnapPoints: selfSnapPoints === 'default' ? undefined : () => selfSnapPoints,
|
|
227
215
|
}
|
|
228
216
|
}
|
|
229
|
-
override getHandles(shape:
|
|
217
|
+
override getHandles(shape: TestShape): TLHandle[] {
|
|
230
218
|
const handle: TLHandle = {
|
|
231
219
|
id: 'handle',
|
|
232
220
|
label: 'handle',
|
|
@@ -245,7 +233,7 @@ describe('custom handle snapping', () => {
|
|
|
245
233
|
|
|
246
234
|
return [handle]
|
|
247
235
|
}
|
|
248
|
-
override onHandleDrag(shape:
|
|
236
|
+
override onHandleDrag(shape: TestShape, { handle }: TLHandleDragInfo<TestShape>) {
|
|
249
237
|
return { ...shape, props: { ...shape.props, ownHandle: { x: handle.x, y: handle.y } } }
|
|
250
238
|
}
|
|
251
239
|
}
|
|
@@ -265,7 +253,7 @@ describe('custom handle snapping', () => {
|
|
|
265
253
|
a2: { id: 'a2', index: 'a2' as IndexKey, x: 100, y: 100 },
|
|
266
254
|
}}
|
|
267
255
|
/>,
|
|
268
|
-
<TL.
|
|
256
|
+
<TL.test ref="test" x={200} y={200} w={100} h={100} boundsSnapPoints={null} />,
|
|
269
257
|
])
|
|
270
258
|
})
|
|
271
259
|
|
|
@@ -308,9 +296,9 @@ describe('custom handle snapping', () => {
|
|
|
308
296
|
|
|
309
297
|
describe('with empty handleSnapGeometry.outline', () => {
|
|
310
298
|
beforeEach(() => {
|
|
311
|
-
editor.updateShape({
|
|
312
|
-
id: ids.
|
|
313
|
-
type:
|
|
299
|
+
editor.updateShape<TestShape>({
|
|
300
|
+
id: ids.test,
|
|
301
|
+
type: 'test',
|
|
314
302
|
props: { handleOutline: null },
|
|
315
303
|
})
|
|
316
304
|
})
|
|
@@ -325,9 +313,9 @@ describe('custom handle snapping', () => {
|
|
|
325
313
|
|
|
326
314
|
describe('with custom handleSnapGeometry.outline', () => {
|
|
327
315
|
beforeEach(() => {
|
|
328
|
-
editor.updateShape({
|
|
329
|
-
id: ids.
|
|
330
|
-
type:
|
|
316
|
+
editor.updateShape<TestShape>({
|
|
317
|
+
id: ids.test,
|
|
318
|
+
type: 'test',
|
|
331
319
|
props: {
|
|
332
320
|
// a diagonal line from the top left to the bottom right
|
|
333
321
|
handleOutline: [
|
|
@@ -372,9 +360,9 @@ describe('custom handle snapping', () => {
|
|
|
372
360
|
|
|
373
361
|
describe('with custom handleSnapGeometry.points', () => {
|
|
374
362
|
beforeEach(() => {
|
|
375
|
-
editor.updateShape({
|
|
376
|
-
id: ids.
|
|
377
|
-
type:
|
|
363
|
+
editor.updateShape<TestShape>({
|
|
364
|
+
id: ids.test,
|
|
365
|
+
type: 'test',
|
|
378
366
|
props: {
|
|
379
367
|
handlePoints: [
|
|
380
368
|
{ x: 30, y: 30 },
|
|
@@ -399,12 +387,12 @@ describe('custom handle snapping', () => {
|
|
|
399
387
|
|
|
400
388
|
describe('with custom handleSnapGeometry.points along the outline', () => {
|
|
401
389
|
beforeEach(() => {
|
|
402
|
-
editor.updateShape({
|
|
403
|
-
id: ids.
|
|
404
|
-
type:
|
|
390
|
+
editor.updateShape<TestShape>({
|
|
391
|
+
id: ids.test,
|
|
392
|
+
type: 'test',
|
|
405
393
|
props: {
|
|
406
394
|
handlePoints: editor
|
|
407
|
-
.getShapeGeometry(ids.
|
|
395
|
+
.getShapeGeometry(ids.test)
|
|
408
396
|
.bounds.cornersAndCenter.map(({ x, y }) => ({ x, y })),
|
|
409
397
|
},
|
|
410
398
|
})
|
|
@@ -438,9 +426,9 @@ describe('custom handle snapping', () => {
|
|
|
438
426
|
describe('self snapping', () => {
|
|
439
427
|
beforeEach(() => {
|
|
440
428
|
editor.deleteShape(ids.line)
|
|
441
|
-
editor.updateShape({
|
|
442
|
-
id: ids.
|
|
443
|
-
type:
|
|
429
|
+
editor.updateShape<TestShape>({
|
|
430
|
+
id: ids.test,
|
|
431
|
+
type: 'test',
|
|
444
432
|
x: 0,
|
|
445
433
|
y: 0,
|
|
446
434
|
props: {
|
|
@@ -449,12 +437,12 @@ describe('custom handle snapping', () => {
|
|
|
449
437
|
})
|
|
450
438
|
})
|
|
451
439
|
function startDraggingOwnHandle() {
|
|
452
|
-
const shape = editor.select(ids.
|
|
440
|
+
const shape = editor.select(ids.test).getOnlySelectedShape()!
|
|
453
441
|
const handles = editor.getShapeHandles(shape)!
|
|
454
442
|
editor.pointerDown(0, 0, { target: 'handle', shape, handle: handles[0] })
|
|
455
443
|
}
|
|
456
444
|
function ownHandlePosition() {
|
|
457
|
-
const shape = editor.select(ids.
|
|
445
|
+
const shape = editor.select(ids.test).getOnlySelectedShape()!
|
|
458
446
|
const handle = editor.getShapeHandles(shape)![0]
|
|
459
447
|
return { x: handle.x, y: handle.y }
|
|
460
448
|
}
|
|
@@ -474,9 +462,9 @@ describe('custom handle snapping', () => {
|
|
|
474
462
|
})
|
|
475
463
|
describe('with custom self snap outline & points', () => {
|
|
476
464
|
beforeEach(() => {
|
|
477
|
-
editor.updateShape({
|
|
478
|
-
id: ids.
|
|
479
|
-
type:
|
|
465
|
+
editor.updateShape<TestShape>({
|
|
466
|
+
id: ids.test,
|
|
467
|
+
type: 'test',
|
|
480
468
|
props: {
|
|
481
469
|
selfSnapOutline: [
|
|
482
470
|
{ x: 20, y: 50 },
|
|
@@ -518,9 +506,9 @@ describe('custom handle snapping', () => {
|
|
|
518
506
|
|
|
519
507
|
describe('with snapType set to align', () => {
|
|
520
508
|
beforeEach(() => {
|
|
521
|
-
editor.updateShape({
|
|
522
|
-
id: ids.
|
|
523
|
-
type:
|
|
509
|
+
editor.updateShape<TestShape>({
|
|
510
|
+
id: ids.test,
|
|
511
|
+
type: 'test',
|
|
524
512
|
props: {
|
|
525
513
|
selfSnapPoints: [
|
|
526
514
|
{ x: 20, y: 50 },
|
|
@@ -555,24 +543,19 @@ describe('custom handle snapping', () => {
|
|
|
555
543
|
})
|
|
556
544
|
})
|
|
557
545
|
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
[BEZIER_TYPE]: {
|
|
546
|
+
describe('custom adjacent handle for shift snapping', () => {
|
|
547
|
+
type BezierShape = TLBaseShape<
|
|
548
|
+
'bezier',
|
|
549
|
+
{
|
|
563
550
|
start: VecModel
|
|
564
551
|
cp1: VecModel
|
|
565
552
|
cp2: VecModel
|
|
566
553
|
end: VecModel
|
|
567
554
|
}
|
|
568
|
-
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
type BezierShape = TLShape<typeof BEZIER_TYPE>
|
|
555
|
+
>
|
|
572
556
|
|
|
573
|
-
describe('custom adjacent handle for shift snapping', () => {
|
|
574
557
|
class BezierShapeUtil extends ShapeUtil<BezierShape> {
|
|
575
|
-
static override type =
|
|
558
|
+
static override type = 'bezier'
|
|
576
559
|
override getDefaultProps() {
|
|
577
560
|
return {
|
|
578
561
|
start: { x: 0, y: 0 },
|
|
@@ -649,6 +632,8 @@ describe('custom adjacent handle for shift snapping', () => {
|
|
|
649
632
|
ref="bezier"
|
|
650
633
|
x={0}
|
|
651
634
|
y={0}
|
|
635
|
+
w={100}
|
|
636
|
+
h={100}
|
|
652
637
|
start={{ x: 0, y: 0 }}
|
|
653
638
|
cp1={{ x: 50, y: 0 }}
|
|
654
639
|
cp2={{ x: 50, y: 100 }}
|
package/src/test/drawing.test.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { TLDrawShape, TLHighlightShape, last } from '@tldraw/editor'
|
|
2
2
|
import { vi } from 'vitest'
|
|
3
|
-
import { TEST_DRAW_SHAPE_SCREEN_POINTS } from './drawing.data'
|
|
4
|
-
import { base64ToPoints } from './test-jsx'
|
|
5
3
|
import { TestEditor } from './TestEditor'
|
|
4
|
+
import { TEST_DRAW_SHAPE_SCREEN_POINTS } from './drawing.data'
|
|
6
5
|
|
|
7
6
|
vi.useFakeTimers()
|
|
8
7
|
|
|
@@ -78,7 +77,7 @@ for (const toolType of ['draw', 'highlight'] as const) {
|
|
|
78
77
|
const segment = shape.props.segments[0]
|
|
79
78
|
expect(segment.type).toBe('straight')
|
|
80
79
|
|
|
81
|
-
const points =
|
|
80
|
+
const points = segment.points
|
|
82
81
|
expect(points.length).toBe(2)
|
|
83
82
|
})
|
|
84
83
|
|
|
@@ -177,9 +176,8 @@ for (const toolType of ['draw', 'highlight'] as const) {
|
|
|
177
176
|
|
|
178
177
|
const shape = editor.getCurrentPageShapes()[0] as DrawableShape
|
|
179
178
|
const segment = shape.props.segments[0]
|
|
180
|
-
|
|
181
|
-
expect(points[1].
|
|
182
|
-
expect(points[1].y).toBeCloseTo(snappedY)
|
|
179
|
+
expect(segment.points[1].x).toBeCloseTo(snappedX)
|
|
180
|
+
expect(segment.points[1].y).toBeCloseTo(snappedY)
|
|
183
181
|
})
|
|
184
182
|
|
|
185
183
|
it('Doesnt snap to 15 degree angle when cmd is held', () => {
|
|
@@ -192,9 +190,8 @@ for (const toolType of ['draw', 'highlight'] as const) {
|
|
|
192
190
|
|
|
193
191
|
const shape = editor.getCurrentPageShapes()[0] as DrawableShape
|
|
194
192
|
const segment = shape.props.segments[0]
|
|
195
|
-
|
|
196
|
-
expect(points[1].
|
|
197
|
-
expect(points[1].y).toBeCloseTo(y)
|
|
193
|
+
expect(segment.points[1].x).toBeCloseTo(x)
|
|
194
|
+
expect(segment.points[1].y).toBeCloseTo(y)
|
|
198
195
|
})
|
|
199
196
|
|
|
200
197
|
it('Snaps to start or end of straight segments in self when shift + cmd is held', () => {
|
|
@@ -212,15 +209,13 @@ for (const toolType of ['draw', 'highlight'] as const) {
|
|
|
212
209
|
|
|
213
210
|
const shape1 = editor.getCurrentPageShapes()[0] as DrawableShape
|
|
214
211
|
const segment1 = last(shape1.props.segments)!
|
|
215
|
-
const
|
|
216
|
-
const point1 = last(points1)!
|
|
212
|
+
const point1 = last(segment1.points)!
|
|
217
213
|
expect(point1.x).toBe(1)
|
|
218
214
|
|
|
219
215
|
editor.keyDown('Meta')
|
|
220
216
|
const shape2 = editor.getCurrentPageShapes()[0] as DrawableShape
|
|
221
217
|
const segment2 = last(shape2.props.segments)!
|
|
222
|
-
const
|
|
223
|
-
const point2 = last(points2)!
|
|
218
|
+
const point2 = last(segment2.points)!
|
|
224
219
|
expect(point2.x).toBe(0)
|
|
225
220
|
})
|
|
226
221
|
|
|
@@ -239,15 +234,13 @@ for (const toolType of ['draw', 'highlight'] as const) {
|
|
|
239
234
|
|
|
240
235
|
const shape1 = editor.getCurrentPageShapes()[0] as DrawableShape
|
|
241
236
|
const segment1 = last(shape1.props.segments)!
|
|
242
|
-
const
|
|
243
|
-
const point1 = last(points1)!
|
|
237
|
+
const point1 = last(segment1.points)!
|
|
244
238
|
expect(point1.x).toBe(1)
|
|
245
239
|
|
|
246
240
|
editor.keyDown('Meta')
|
|
247
241
|
const shape2 = editor.getCurrentPageShapes()[0] as DrawableShape
|
|
248
242
|
const segment2 = last(shape2.props.segments)!
|
|
249
|
-
const
|
|
250
|
-
const point2 = last(points2)!
|
|
243
|
+
const point2 = last(segment2.points)!
|
|
251
244
|
expect(point2.x).toBe(0)
|
|
252
245
|
})
|
|
253
246
|
|
|
@@ -295,7 +295,7 @@ describe('When duplicating shapes that include arrows', () => {
|
|
|
295
295
|
.select(
|
|
296
296
|
...editor
|
|
297
297
|
.getCurrentPageShapes()
|
|
298
|
-
.filter((s) => editor.isShapeOfType(s, 'arrow'))
|
|
298
|
+
.filter((s) => editor.isShapeOfType<TLArrowShape>(s, 'arrow'))
|
|
299
299
|
.map((s) => s.id)
|
|
300
300
|
)
|
|
301
301
|
|