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