tldraw 4.3.0-canary.e5f56251a468 → 4.3.0-canary.ea88b223b83a
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 +297 -237
- package/dist-cjs/index.js +13 -5
- package/dist-cjs/index.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/getElbowArrowInfo.js +1 -1
- package/dist-cjs/lib/shapes/arrow/elbow/getElbowArrowInfo.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/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/FrameShapeUtil.js +6 -5
- 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/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/interpolate-props.js +3 -3
- package/dist-cjs/lib/shapes/shared/interpolate-props.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 +4 -5
- 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 +9 -7
- package/dist-cjs/lib/tools/SelectTool/DragAndDropManager.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Brushing.js +6 -5
- package/dist-cjs/lib/tools/SelectTool/childStates/Brushing.js.map +2 -2
- 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 +7 -5
- 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 +7 -6
- package/dist-cjs/lib/tools/SelectTool/childStates/ScribbleBrushing.js.map +2 -2
- 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 +1 -21
- package/dist-cjs/lib/ui/components/DefaultDebugPanel.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/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 +2 -3
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js.map +2 -2
- package/dist-cjs/lib/ui/context/actions.js +6 -6
- 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/useClipboardEvents.js +2 -2
- package/dist-cjs/lib/ui/hooks/useClipboardEvents.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 +8 -6
- package/dist-cjs/lib/utils/excalidraw/putExcalidrawContent.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 +11 -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 +297 -237
- package/dist-esm/index.mjs +14 -5
- package/dist-esm/index.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/getElbowArrowInfo.mjs +1 -1
- package/dist-esm/lib/shapes/arrow/elbow/getElbowArrowInfo.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/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/FrameShapeUtil.mjs +6 -5
- 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/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/interpolate-props.mjs +4 -4
- package/dist-esm/lib/shapes/shared/interpolate-props.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 +4 -5
- package/dist-esm/lib/tools/EraserTool/childStates/Erasing.mjs.map +2 -2
- package/dist-esm/lib/tools/EraserTool/childStates/Pointing.mjs +2 -4
- 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 +9 -7
- package/dist-esm/lib/tools/SelectTool/DragAndDropManager.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Brushing.mjs +6 -5
- package/dist-esm/lib/tools/SelectTool/childStates/Brushing.mjs.map +2 -2
- 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 +7 -5
- 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 +5 -15
- 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 +7 -6
- package/dist-esm/lib/tools/SelectTool/childStates/ScribbleBrushing.mjs.map +2 -2
- 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 +3 -30
- package/dist-esm/lib/ui/components/DefaultDebugPanel.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/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 +3 -1
- 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 +3 -4
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs.map +2 -2
- package/dist-esm/lib/ui/context/actions.mjs +6 -6
- 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/useClipboardEvents.mjs +2 -2
- package/dist-esm/lib/ui/hooks/useClipboardEvents.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 +9 -6
- package/dist-esm/lib/utils/excalidraw/putExcalidrawContent.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 +8 -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/canvas/TldrawSelectionForeground.tsx +2 -2
- package/src/lib/defaultEmbedDefinitions.ts +2 -1
- package/src/lib/defaultExternalContentHandlers.ts +10 -10
- 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.tsx +15 -15
- package/src/lib/shapes/arrow/arrow-types.ts +2 -0
- package/src/lib/shapes/arrow/arrowLabel.ts +1 -1
- package/src/lib/shapes/arrow/arrowTargetState.ts +1 -1
- 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/toolStates/Idle.tsx +4 -14
- package/src/lib/shapes/arrow/toolStates/Pointing.tsx +7 -4
- package/src/lib/shapes/bookmark/BookmarkShapeUtil.tsx +1 -1
- package/src/lib/shapes/draw/DrawShapeUtil.test.ts +146 -0
- package/src/lib/shapes/draw/DrawShapeUtil.tsx +31 -27
- package/src/lib/shapes/draw/getPath.ts +31 -10
- package/src/lib/shapes/draw/toolStates/Drawing.ts +96 -86
- package/src/lib/shapes/embed/EmbedShapeUtil.tsx +7 -0
- package/src/lib/shapes/frame/FrameShapeUtil.tsx +10 -4
- 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 +3 -3
- package/src/lib/shapes/highlight/HighlightShapeUtil.test.ts +146 -0
- package/src/lib/shapes/highlight/HighlightShapeUtil.tsx +25 -24
- package/src/lib/shapes/line/toolStates/Pointing.ts +3 -3
- package/src/lib/shapes/note/NoteShapeUtil.tsx +9 -10
- package/src/lib/shapes/note/noteCloning.test.ts +3 -1
- 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 +10 -1
- package/src/lib/shapes/shared/RichTextLabel.tsx +12 -3
- package/src/lib/shapes/shared/ShapeFill.tsx +2 -2
- package/src/lib/shapes/shared/interpolate-props.ts +4 -4
- 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/TextShapeUtil.tsx +5 -0
- package/src/lib/shapes/text/toolStates/Idle.ts +4 -14
- package/src/lib/shapes/text/toolStates/Pointing.ts +7 -7
- package/src/lib/shapes/video/VideoShapeUtil.tsx +2 -1
- package/src/lib/tools/EraserTool/childStates/Erasing.ts +4 -5
- package/src/lib/tools/EraserTool/childStates/Pointing.ts +2 -4
- 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 +12 -7
- package/src/lib/tools/SelectTool/childStates/Brushing.ts +6 -5
- package/src/lib/tools/SelectTool/childStates/Crop/children/Cropping.ts +7 -6
- package/src/lib/tools/SelectTool/childStates/Crop/children/Idle.ts +1 -1
- 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 +7 -5
- package/src/lib/tools/SelectTool/childStates/EditingShape.ts +55 -12
- package/src/lib/tools/SelectTool/childStates/Idle.ts +58 -71
- package/src/lib/tools/SelectTool/childStates/PointingArrowLabel.ts +6 -7
- package/src/lib/tools/SelectTool/childStates/PointingCanvas.ts +1 -1
- package/src/lib/tools/SelectTool/childStates/PointingHandle.ts +5 -5
- 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 +2 -2
- package/src/lib/tools/SelectTool/childStates/PointingShape.ts +4 -14
- package/src/lib/tools/SelectTool/childStates/Resizing.ts +6 -6
- package/src/lib/tools/SelectTool/childStates/Rotating.ts +2 -3
- package/src/lib/tools/SelectTool/childStates/ScribbleBrushing.ts +7 -6
- package/src/lib/tools/SelectTool/childStates/Translating.ts +15 -12
- 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 +3 -42
- 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/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 +3 -1
- 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 +2 -3
- package/src/lib/ui/context/actions.tsx +6 -6
- package/src/lib/ui/context/components.tsx +1 -2
- package/src/lib/ui/hooks/useClipboardEvents.ts +2 -2
- package/src/lib/ui/hooks/useKeyboardShortcuts.ts +2 -2
- package/src/lib/ui/hooks/useTools.tsx +4 -5
- 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 +11 -6
- package/src/lib/utils/test-helpers.ts +60 -0
- package/src/lib/utils/text/richText.ts +9 -8
- package/src/lib/utils/tldr/buildFromV1Document.ts +9 -2
- package/src/test/Editor.test.tsx +40 -29
- package/src/test/EraserTool.test.ts +10 -12
- package/src/test/TestEditor.ts +48 -47
- package/src/test/TldrawEditor.test.tsx +6 -4
- 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/commands/__snapshots__/getSvgString.test.ts.snap +10 -10
- package/src/test/commands/cameraState.test.ts +299 -0
- package/src/test/commands/putContent.test.ts +79 -1
- package/src/test/commands/setCamera.test.ts +13 -11
- package/src/test/commands/stackShapes.test.ts +34 -8
- 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 +16 -9
- package/src/test/drawing.test.ts +17 -10
- package/src/test/flipShapes.test.ts +33 -0
- package/src/test/frames.test.ts +92 -0
- package/src/test/groups.test.tsx +1 -1
- package/src/test/modifiers.test.ts +6 -6
- package/src/test/resizing.test.ts +7 -9
- package/src/test/selection-omnibus.test.ts +2 -2
- package/src/test/spacebarPanning.test.ts +28 -10
- package/src/test/test-jsx.tsx +3 -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
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tldraw",
|
|
3
3
|
"description": "A tiny little drawing editor.",
|
|
4
|
-
"version": "4.3.0-canary.
|
|
4
|
+
"version": "4.3.0-canary.ea88b223b83a",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "tldraw Inc.",
|
|
7
7
|
"email": "hello@tldraw.com"
|
|
@@ -55,15 +55,15 @@
|
|
|
55
55
|
"src"
|
|
56
56
|
],
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@tiptap/core": "^3.
|
|
59
|
-
"@tiptap/extension-code": "^3.
|
|
60
|
-
"@tiptap/extension-highlight": "^3.
|
|
61
|
-
"@tiptap/extension-list": "^3.
|
|
62
|
-
"@tiptap/pm": "^3.
|
|
63
|
-
"@tiptap/react": "^3.
|
|
64
|
-
"@tiptap/starter-kit": "^3.
|
|
65
|
-
"@tldraw/editor": "4.3.0-canary.
|
|
66
|
-
"@tldraw/store": "4.3.0-canary.
|
|
58
|
+
"@tiptap/core": "^3.12.1",
|
|
59
|
+
"@tiptap/extension-code": "^3.12.1",
|
|
60
|
+
"@tiptap/extension-highlight": "^3.12.1",
|
|
61
|
+
"@tiptap/extension-list": "^3.12.1",
|
|
62
|
+
"@tiptap/pm": "^3.12.1",
|
|
63
|
+
"@tiptap/react": "^3.12.1",
|
|
64
|
+
"@tiptap/starter-kit": "^3.12.1",
|
|
65
|
+
"@tldraw/editor": "4.3.0-canary.ea88b223b83a",
|
|
66
|
+
"@tldraw/store": "4.3.0-canary.ea88b223b83a",
|
|
67
67
|
"classnames": "^2.5.1",
|
|
68
68
|
"hotkeys-js": "^3.13.9",
|
|
69
69
|
"idb": "^7.1.1",
|
|
@@ -71,19 +71,21 @@
|
|
|
71
71
|
"radix-ui": "^1.4.2"
|
|
72
72
|
},
|
|
73
73
|
"peerDependencies": {
|
|
74
|
-
"react": "^18.2.0 || ^19.
|
|
75
|
-
"react-dom": "^18.2.0 || ^19.
|
|
74
|
+
"react": "^18.2.0 || ^19.2.1",
|
|
75
|
+
"react-dom": "^18.2.0 || ^19.2.1"
|
|
76
76
|
},
|
|
77
77
|
"devDependencies": {
|
|
78
78
|
"@peculiar/webcrypto": "^1.5.0",
|
|
79
|
-
"@testing-library/
|
|
79
|
+
"@testing-library/dom": "^10.0.0",
|
|
80
|
+
"@testing-library/react": "^16.0.0",
|
|
80
81
|
"@types/classnames": "^2.3.4",
|
|
81
82
|
"@types/lz-string": "^1.5.0",
|
|
82
|
-
"@types/react": "^
|
|
83
|
+
"@types/react": "^19.2.7",
|
|
84
|
+
"@types/react-dom": "^19.2.3",
|
|
83
85
|
"chokidar-cli": "^3.0.0",
|
|
84
86
|
"lazyrepo": "0.0.0-alpha.27",
|
|
85
|
-
"react": "^
|
|
86
|
-
"react-dom": "^
|
|
87
|
+
"react": "^19.2.1",
|
|
88
|
+
"react-dom": "^19.2.1",
|
|
87
89
|
"resize-observer-polyfill": "^1.5.1",
|
|
88
90
|
"vitest": "^3.2.4"
|
|
89
91
|
},
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
|
|
3
3
|
import { registerTldrawLibraryVersion } from '@tldraw/editor'
|
|
4
|
+
export { getPointsFromDrawSegment, getPointsFromDrawSegments } from './lib/shapes/draw/getPath'
|
|
4
5
|
export {
|
|
5
6
|
PathBuilder,
|
|
6
7
|
PathBuilderGeometry2d,
|
|
@@ -21,6 +22,7 @@ export {
|
|
|
21
22
|
type SolidPathBuilderOpts,
|
|
22
23
|
} from './lib/shapes/shared/PathBuilder'
|
|
23
24
|
export { usePrefersReducedMotion } from './lib/shapes/shared/usePrefersReducedMotion'
|
|
25
|
+
export { startEditingShapeWithRichText } from './lib/tools/SelectTool/selectHelpers'
|
|
24
26
|
export { DefaultA11yAnnouncer, useSelectedShapesAnnouncer } from './lib/ui/components/A11y'
|
|
25
27
|
export { AccessibilityMenu } from './lib/ui/components/AccessibilityMenu'
|
|
26
28
|
export { ColorSchemeMenu } from './lib/ui/components/ColorSchemeMenu'
|
|
@@ -176,7 +178,10 @@ export {
|
|
|
176
178
|
type TLDefaultFont,
|
|
177
179
|
type TLDefaultFonts,
|
|
178
180
|
} from './lib/shapes/shared/defaultFonts'
|
|
181
|
+
export { getStroke } from './lib/shapes/shared/freehand/getStroke'
|
|
182
|
+
export { getStrokeOutlinePoints } from './lib/shapes/shared/freehand/getStrokeOutlinePoints'
|
|
179
183
|
export { getStrokePoints } from './lib/shapes/shared/freehand/getStrokePoints'
|
|
184
|
+
export { setStrokePointRadii } from './lib/shapes/shared/freehand/setStrokePointRadii'
|
|
180
185
|
export { getSvgPathFromStrokePoints } from './lib/shapes/shared/freehand/svg'
|
|
181
186
|
export { type StrokeOptions, type StrokePoint } from './lib/shapes/shared/freehand/types'
|
|
182
187
|
export { PlainTextLabel, type PlainTextLabelProps } from './lib/shapes/shared/PlainTextLabel'
|
|
@@ -432,6 +437,7 @@ export {
|
|
|
432
437
|
type TLUiToolbarToggleItemProps,
|
|
433
438
|
} from './lib/ui/components/primitives/TldrawUiToolbar'
|
|
434
439
|
export {
|
|
440
|
+
hideAllTooltips,
|
|
435
441
|
TldrawUiTooltip,
|
|
436
442
|
TldrawUiTooltipProvider,
|
|
437
443
|
type TldrawUiTooltipProps,
|
|
@@ -566,7 +572,6 @@ export {
|
|
|
566
572
|
CenteredTopPanelContainer,
|
|
567
573
|
type CenteredTopPanelContainerProps,
|
|
568
574
|
} from './lib/ui/components/TopPanel/CenteredTopPanelContainer'
|
|
569
|
-
export { DefaultTopPanel } from './lib/ui/components/TopPanel/DefaultTopPanel'
|
|
570
575
|
export {
|
|
571
576
|
DefaultZoomMenu,
|
|
572
577
|
type TLUiZoomMenuProps,
|
|
@@ -685,7 +690,6 @@ export {
|
|
|
685
690
|
tipTapDefaultExtensions,
|
|
686
691
|
} from './lib/utils/text/richText'
|
|
687
692
|
export { truncateStringWithEllipsis } from './lib/utils/text/text'
|
|
688
|
-
export { TextDirection } from './lib/utils/text/textDirection'
|
|
689
693
|
export {
|
|
690
694
|
buildFromV1Document,
|
|
691
695
|
TLV1AlignStyle,
|
package/src/lib/Tldraw.test.tsx
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { act, screen } from '@testing-library/react'
|
|
2
2
|
import { BaseBoxShapeUtil, Editor, StateNode, TLStateNodeConstructor } from '@tldraw/editor'
|
|
3
3
|
import { useState } from 'react'
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
renderTldrawComponent,
|
|
6
|
+
renderTldrawComponentWithEditor,
|
|
7
|
+
} from '../test/testutils/renderTldrawComponent'
|
|
5
8
|
import { Tldraw } from './Tldraw'
|
|
6
9
|
|
|
7
10
|
describe('<Tldraw />', () => {
|
|
@@ -125,4 +128,46 @@ describe('<Tldraw />', () => {
|
|
|
125
128
|
expect(editor!.root.children!['hand']).toBeDefined()
|
|
126
129
|
expect(editor!.root.children!['zoom']).toBeDefined()
|
|
127
130
|
})
|
|
131
|
+
|
|
132
|
+
it('keyboard shortcuts work when hideUi is true', async () => {
|
|
133
|
+
const { editor } = await renderTldrawComponentWithEditor(
|
|
134
|
+
(onMount) => <Tldraw hideUi onMount={onMount} />,
|
|
135
|
+
{ waitForPatterns: false }
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
// Focus the editor so keyboard shortcuts are active
|
|
139
|
+
await act(async () => {
|
|
140
|
+
editor.focus()
|
|
141
|
+
})
|
|
142
|
+
|
|
143
|
+
// Start on select tool
|
|
144
|
+
expect(editor.getCurrentToolId()).toBe('select')
|
|
145
|
+
|
|
146
|
+
// Simulate pressing 'd' key to switch to draw tool
|
|
147
|
+
// hotkeys-js uses keyCode to identify keys, so we need to include it
|
|
148
|
+
await act(async () => {
|
|
149
|
+
document.body.dispatchEvent(
|
|
150
|
+
new KeyboardEvent('keydown', { key: 'd', code: 'KeyD', keyCode: 68, bubbles: true })
|
|
151
|
+
)
|
|
152
|
+
document.body.dispatchEvent(
|
|
153
|
+
new KeyboardEvent('keyup', { key: 'd', code: 'KeyD', keyCode: 68, bubbles: true })
|
|
154
|
+
)
|
|
155
|
+
})
|
|
156
|
+
|
|
157
|
+
// Should now be on draw tool
|
|
158
|
+
expect(editor.getCurrentToolId()).toBe('draw')
|
|
159
|
+
|
|
160
|
+
// Simulate pressing 'h' key to switch to hand tool
|
|
161
|
+
await act(async () => {
|
|
162
|
+
document.body.dispatchEvent(
|
|
163
|
+
new KeyboardEvent('keydown', { key: 'h', code: 'KeyH', keyCode: 72, bubbles: true })
|
|
164
|
+
)
|
|
165
|
+
document.body.dispatchEvent(
|
|
166
|
+
new KeyboardEvent('keyup', { key: 'h', code: 'KeyH', keyCode: 72, bubbles: true })
|
|
167
|
+
)
|
|
168
|
+
})
|
|
169
|
+
|
|
170
|
+
// Should now be on hand tool
|
|
171
|
+
expect(editor.getCurrentToolId()).toBe('hand')
|
|
172
|
+
})
|
|
128
173
|
})
|
|
@@ -63,7 +63,7 @@ export const TldrawSelectionForeground = track(function TldrawSelectionForegroun
|
|
|
63
63
|
|
|
64
64
|
if (onlyShape && editor.isShapeHidden(onlyShape)) return null
|
|
65
65
|
|
|
66
|
-
const zoom = editor.
|
|
66
|
+
const zoom = editor.getEfficientZoomLevel()
|
|
67
67
|
const isChangingStyle = editor.getInstanceState().isChangingStyle
|
|
68
68
|
|
|
69
69
|
const width = expandedBounds.width
|
|
@@ -532,7 +532,7 @@ export const MobileRotateHandle = function RotateHandle({
|
|
|
532
532
|
const events = useSelectionEvents('mobile_rotate')
|
|
533
533
|
|
|
534
534
|
const editor = useEditor()
|
|
535
|
-
const zoom = useValue('zoom level', () => editor.
|
|
535
|
+
const zoom = useValue('zoom level', () => editor.getEfficientZoomLevel(), [editor])
|
|
536
536
|
const bgRadius = Math.max(14 * (1 / zoom), 20 / Math.max(1, zoom))
|
|
537
537
|
const msg = useTranslation()
|
|
538
538
|
return (
|
|
@@ -626,7 +626,7 @@ export const embedShapePermissionDefaults = {
|
|
|
626
626
|
// [REASON] We want to allow embeds to link back to their original sites (e.g. YouTube).
|
|
627
627
|
'allow-popups': true,
|
|
628
628
|
// [MDN] Lets the sandboxed document open new windows without those windows inheriting the sandboxing. For example, this can safely sandbox an advertisement without forcing the same restrictions upon the page the ad links to.
|
|
629
|
-
// [REASON] We shouldn't allow popups as
|
|
629
|
+
// [REASON] We shouldn't allow popups as an embed could pretend to be us by opening a mocked version of tldraw. This is very unobvious when it is performed as an action within our app.
|
|
630
630
|
'allow-popups-to-escape-sandbox': false,
|
|
631
631
|
// [MDN] Lets the resource start a presentation session.
|
|
632
632
|
// [REASON] Prevents embed from navigating away from tldraw and pretending to be us.
|
|
@@ -669,6 +669,7 @@ export interface EmbedDefinition {
|
|
|
669
669
|
readonly instructionLink?: string
|
|
670
670
|
readonly backgroundColor?: string
|
|
671
671
|
readonly embedOnPaste?: boolean
|
|
672
|
+
readonly canEditWhileLocked?: boolean
|
|
672
673
|
// TODO: FIXME this is ugly be required because some embeds have their own border radius for example spotify embeds
|
|
673
674
|
readonly overrideOutlineRadius?: number
|
|
674
675
|
// eslint-disable-next-line @typescript-eslint/method-signature-style
|
|
@@ -307,8 +307,8 @@ export async function defaultHandleExternalSvgTextContent(
|
|
|
307
307
|
) {
|
|
308
308
|
const position =
|
|
309
309
|
point ??
|
|
310
|
-
(editor.inputs.
|
|
311
|
-
? editor.inputs.
|
|
310
|
+
(editor.inputs.getShiftKey()
|
|
311
|
+
? editor.inputs.getCurrentPagePoint()
|
|
312
312
|
: editor.getViewportPageBounds().center)
|
|
313
313
|
|
|
314
314
|
const svg = new DOMParser().parseFromString(text, 'image/svg+xml').querySelector('svg')
|
|
@@ -345,8 +345,8 @@ export function defaultHandleExternalEmbedContent<T>(
|
|
|
345
345
|
) {
|
|
346
346
|
const position =
|
|
347
347
|
point ??
|
|
348
|
-
(editor.inputs.
|
|
349
|
-
? editor.inputs.
|
|
348
|
+
(editor.inputs.getShiftKey()
|
|
349
|
+
? editor.inputs.getCurrentPagePoint()
|
|
350
350
|
: editor.getViewportPageBounds().center)
|
|
351
351
|
|
|
352
352
|
const { width, height } = embed as { width: number; height: number }
|
|
@@ -388,8 +388,8 @@ export async function defaultHandleExternalFileContent(
|
|
|
388
388
|
|
|
389
389
|
const position =
|
|
390
390
|
point ??
|
|
391
|
-
(editor.inputs.
|
|
392
|
-
? editor.inputs.
|
|
391
|
+
(editor.inputs.getShiftKey()
|
|
392
|
+
? editor.inputs.getCurrentPagePoint()
|
|
393
393
|
: editor.getViewportPageBounds().center)
|
|
394
394
|
|
|
395
395
|
const pagePoint = new Vec(position.x, position.y)
|
|
@@ -446,8 +446,8 @@ export async function defaultHandleExternalTextContent(
|
|
|
446
446
|
) {
|
|
447
447
|
const p =
|
|
448
448
|
point ??
|
|
449
|
-
(editor.inputs.
|
|
450
|
-
? editor.inputs.
|
|
449
|
+
(editor.inputs.getShiftKey()
|
|
450
|
+
? editor.inputs.getCurrentPagePoint()
|
|
451
451
|
: editor.getViewportPageBounds().center)
|
|
452
452
|
|
|
453
453
|
const defaultProps = editor.getShapeUtil<TLTextShape>('text').getDefaultProps()
|
|
@@ -568,8 +568,8 @@ export async function defaultHandleExternalUrlContent(
|
|
|
568
568
|
|
|
569
569
|
const position =
|
|
570
570
|
point ??
|
|
571
|
-
(editor.inputs.
|
|
572
|
-
? editor.inputs.
|
|
571
|
+
(editor.inputs.getShiftKey()
|
|
572
|
+
? editor.inputs.getCurrentPagePoint()
|
|
573
573
|
: editor.getViewportPageBounds().center)
|
|
574
574
|
|
|
575
575
|
// Use the new function to create the bookmark
|
|
@@ -34,10 +34,15 @@ export function registerDefaultSideEffects(editor: Editor) {
|
|
|
34
34
|
editor.getInstanceState().isToolLocked
|
|
35
35
|
) {
|
|
36
36
|
editor.setCurrentTool('select.editing_shape', {
|
|
37
|
+
target: 'shape',
|
|
38
|
+
shape: shape,
|
|
37
39
|
isCreatingTextWhileToolLocked: true,
|
|
38
40
|
})
|
|
39
41
|
} else {
|
|
40
|
-
editor.setCurrentTool('select.editing_shape'
|
|
42
|
+
editor.setCurrentTool('select.editing_shape', {
|
|
43
|
+
target: 'shape',
|
|
44
|
+
shape: shape,
|
|
45
|
+
})
|
|
41
46
|
}
|
|
42
47
|
}
|
|
43
48
|
} else if (prev.editingShapeId && !next.editingShapeId) {
|
|
@@ -48,19 +48,19 @@ describe('ArrowShapeOptions', () => {
|
|
|
48
48
|
const util = editor.getShapeUtil<ArrowShapeUtil>('arrow')
|
|
49
49
|
|
|
50
50
|
// Test without alt key, not precise
|
|
51
|
-
editor.inputs.
|
|
51
|
+
editor.inputs.setAltKey(false)
|
|
52
52
|
expect(util.options.shouldBeExact(editor, false)).toBe(false)
|
|
53
53
|
|
|
54
54
|
// Test without alt key, precise
|
|
55
|
-
editor.inputs.
|
|
55
|
+
editor.inputs.setAltKey(false)
|
|
56
56
|
expect(util.options.shouldBeExact(editor, true)).toBe(false)
|
|
57
57
|
|
|
58
58
|
// Test with alt key, not precise
|
|
59
|
-
editor.inputs.
|
|
59
|
+
editor.inputs.setAltKey(true)
|
|
60
60
|
expect(util.options.shouldBeExact(editor, false)).toBe(true)
|
|
61
61
|
|
|
62
62
|
// Test with alt key, precise
|
|
63
|
-
editor.inputs.
|
|
63
|
+
editor.inputs.setAltKey(true)
|
|
64
64
|
expect(util.options.shouldBeExact(editor, true)).toBe(true)
|
|
65
65
|
})
|
|
66
66
|
|
|
@@ -68,59 +68,19 @@ describe('ArrowShapeOptions', () => {
|
|
|
68
68
|
const util = editor.getShapeUtil<ArrowShapeUtil>('arrow')
|
|
69
69
|
|
|
70
70
|
// Test without ctrl key
|
|
71
|
-
editor.inputs.
|
|
71
|
+
editor.inputs.setCtrlKey(false)
|
|
72
72
|
expect(util.options.shouldIgnoreTargets(editor)).toBe(false)
|
|
73
73
|
|
|
74
74
|
// Test with ctrl key
|
|
75
|
-
editor.inputs.
|
|
75
|
+
editor.inputs.setCtrlKey(true)
|
|
76
76
|
expect(util.options.shouldIgnoreTargets(editor)).toBe(true)
|
|
77
77
|
})
|
|
78
78
|
})
|
|
79
79
|
|
|
80
80
|
describe('shouldIgnoreTargets option', () => {
|
|
81
|
-
it('should not bind to shapes when shouldIgnoreTargets returns true', () => {
|
|
82
|
-
editor.setCurrentTool('arrow')
|
|
83
|
-
|
|
84
|
-
// Simulate ctrl key held (default shouldIgnoreTargets behavior)
|
|
85
|
-
editor.inputs.ctrlKey = true
|
|
86
|
-
|
|
87
|
-
editor.pointerDown(50, 50) // Start outside any shape
|
|
88
|
-
editor.pointerMove(150, 150) // Move to center of box1
|
|
89
|
-
editor.pointerUp()
|
|
90
|
-
|
|
91
|
-
const createdArrow = editor
|
|
92
|
-
.getCurrentPageShapes()
|
|
93
|
-
.find((s) => s.type === 'arrow') as TLArrowShape
|
|
94
|
-
expect(createdArrow).toBeDefined()
|
|
95
|
-
|
|
96
|
-
const arrowBindings = getArrowBindings(editor, createdArrow)
|
|
97
|
-
expect(arrowBindings.start).toBeUndefined()
|
|
98
|
-
expect(arrowBindings.end).toBeUndefined()
|
|
99
|
-
})
|
|
100
|
-
|
|
101
|
-
it('should bind to shapes when shouldIgnoreTargets returns false', () => {
|
|
102
|
-
editor.setCurrentTool('arrow')
|
|
103
|
-
|
|
104
|
-
// Simulate no ctrl key (default shouldIgnoreTargets behavior)
|
|
105
|
-
editor.inputs.ctrlKey = false
|
|
106
|
-
|
|
107
|
-
editor.pointerDown(50, 50) // Start outside any shape
|
|
108
|
-
editor.pointerMove(150, 150) // Move to center of box1
|
|
109
|
-
editor.pointerUp()
|
|
110
|
-
|
|
111
|
-
const createdArrow = editor
|
|
112
|
-
.getCurrentPageShapes()
|
|
113
|
-
.find((s) => s.type === 'arrow') as TLArrowShape
|
|
114
|
-
expect(createdArrow).toBeDefined()
|
|
115
|
-
|
|
116
|
-
const arrowBindings = getArrowBindings(editor, createdArrow)
|
|
117
|
-
expect(arrowBindings.end).toBeDefined()
|
|
118
|
-
expect(arrowBindings.end?.toId).toBe(ids.box1)
|
|
119
|
-
})
|
|
120
|
-
|
|
121
81
|
it('should work with updateArrowTargetState function', () => {
|
|
122
82
|
// Test that updateArrowTargetState returns null when shouldIgnoreTargets is true
|
|
123
|
-
editor.inputs.
|
|
83
|
+
editor.inputs.setCtrlKey(true)
|
|
124
84
|
|
|
125
85
|
const targetState = updateArrowTargetState({
|
|
126
86
|
editor,
|
|
@@ -135,7 +95,7 @@ describe('ArrowShapeOptions', () => {
|
|
|
135
95
|
})
|
|
136
96
|
|
|
137
97
|
it('should return valid target state when shouldIgnoreTargets is false', () => {
|
|
138
|
-
editor.inputs.
|
|
98
|
+
editor.inputs.setCtrlKey(false)
|
|
139
99
|
|
|
140
100
|
const targetState = updateArrowTargetState({
|
|
141
101
|
editor,
|
|
@@ -153,8 +113,8 @@ describe('ArrowShapeOptions', () => {
|
|
|
153
113
|
|
|
154
114
|
describe('shouldBeExact option', () => {
|
|
155
115
|
it('should affect arrow targeting behavior when true', () => {
|
|
156
|
-
editor.inputs.
|
|
157
|
-
editor.inputs.
|
|
116
|
+
editor.inputs.setAltKey(true) // shouldBeExact = true
|
|
117
|
+
editor.inputs.setCtrlKey(false) // shouldIgnoreTargets = false
|
|
158
118
|
|
|
159
119
|
const targetState = updateArrowTargetState({
|
|
160
120
|
editor,
|
|
@@ -170,8 +130,8 @@ describe('ArrowShapeOptions', () => {
|
|
|
170
130
|
})
|
|
171
131
|
|
|
172
132
|
it('should affect arrow targeting behavior when false', () => {
|
|
173
|
-
editor.inputs.
|
|
174
|
-
editor.inputs.
|
|
133
|
+
editor.inputs.setAltKey(false) // shouldBeExact = false
|
|
134
|
+
editor.inputs.setCtrlKey(false) // shouldIgnoreTargets = false
|
|
175
135
|
|
|
176
136
|
const targetState = updateArrowTargetState({
|
|
177
137
|
editor,
|
|
@@ -194,21 +154,21 @@ describe('ArrowShapeOptions', () => {
|
|
|
194
154
|
class CustomArrowShapeUtil extends ArrowShapeUtil {
|
|
195
155
|
override options = {
|
|
196
156
|
...baseUtil.options,
|
|
197
|
-
shouldBeExact: (editor: any, _isPrecise: boolean) => editor.inputs.
|
|
157
|
+
shouldBeExact: (editor: any, _isPrecise: boolean) => editor.inputs.getShiftKey(), // Use shift instead of alt
|
|
198
158
|
}
|
|
199
159
|
}
|
|
200
160
|
|
|
201
161
|
const customUtil = new CustomArrowShapeUtil(editor)
|
|
202
162
|
|
|
203
163
|
// Test with shift key
|
|
204
|
-
editor.inputs.
|
|
205
|
-
editor.inputs.
|
|
164
|
+
editor.inputs.setShiftKey(true)
|
|
165
|
+
editor.inputs.setAltKey(false)
|
|
206
166
|
expect(customUtil.options.shouldBeExact(editor, false)).toBe(true)
|
|
207
167
|
expect(customUtil.options.shouldBeExact(editor, true)).toBe(true)
|
|
208
168
|
|
|
209
169
|
// Test without shift key
|
|
210
|
-
editor.inputs.
|
|
211
|
-
editor.inputs.
|
|
170
|
+
editor.inputs.setShiftKey(false)
|
|
171
|
+
editor.inputs.setAltKey(true) // Alt key should not matter for custom implementation
|
|
212
172
|
expect(customUtil.options.shouldBeExact(editor, false)).toBe(false)
|
|
213
173
|
expect(customUtil.options.shouldBeExact(editor, true)).toBe(false)
|
|
214
174
|
})
|
|
@@ -219,20 +179,20 @@ describe('ArrowShapeOptions', () => {
|
|
|
219
179
|
class CustomArrowShapeUtil extends ArrowShapeUtil {
|
|
220
180
|
override options = {
|
|
221
181
|
...baseUtil.options,
|
|
222
|
-
shouldIgnoreTargets: (editor: any) => editor.inputs.
|
|
182
|
+
shouldIgnoreTargets: (editor: any) => editor.inputs.getShiftKey(), // Use shift instead of ctrl
|
|
223
183
|
}
|
|
224
184
|
}
|
|
225
185
|
|
|
226
186
|
const customUtil = new CustomArrowShapeUtil(editor)
|
|
227
187
|
|
|
228
188
|
// Test with shift key
|
|
229
|
-
editor.inputs.
|
|
230
|
-
editor.inputs.
|
|
189
|
+
editor.inputs.setShiftKey(true)
|
|
190
|
+
editor.inputs.setCtrlKey(false)
|
|
231
191
|
expect(customUtil.options.shouldIgnoreTargets(editor)).toBe(true)
|
|
232
192
|
|
|
233
193
|
// Test without shift key
|
|
234
|
-
editor.inputs.
|
|
235
|
-
editor.inputs.
|
|
194
|
+
editor.inputs.setShiftKey(false)
|
|
195
|
+
editor.inputs.setCtrlKey(true) // Ctrl key should not matter for custom implementation
|
|
236
196
|
expect(customUtil.options.shouldIgnoreTargets(editor)).toBe(false)
|
|
237
197
|
})
|
|
238
198
|
|
|
@@ -244,11 +204,13 @@ describe('ArrowShapeOptions', () => {
|
|
|
244
204
|
...baseUtil.options,
|
|
245
205
|
shouldBeExact: (editor: any, isPrecise: boolean) => {
|
|
246
206
|
// Custom logic: exact when both alt and shift are pressed, and only if precise
|
|
247
|
-
return editor.inputs.
|
|
207
|
+
return editor.inputs.getAltKey() && editor.inputs.getShiftKey() && isPrecise
|
|
248
208
|
},
|
|
249
209
|
shouldIgnoreTargets: (editor: any) => {
|
|
250
210
|
// Custom logic: ignore targets when any modifier key is pressed
|
|
251
|
-
return
|
|
211
|
+
return (
|
|
212
|
+
editor.inputs.getAltKey() || editor.inputs.getCtrlKey() || editor.inputs.getShiftKey()
|
|
213
|
+
)
|
|
252
214
|
},
|
|
253
215
|
}
|
|
254
216
|
}
|
|
@@ -256,48 +218,35 @@ describe('ArrowShapeOptions', () => {
|
|
|
256
218
|
const customUtil = new CustomArrowShapeUtil(editor)
|
|
257
219
|
|
|
258
220
|
// Test shouldBeExact with both keys and precise
|
|
259
|
-
editor.inputs.
|
|
260
|
-
editor.inputs.
|
|
221
|
+
editor.inputs.setAltKey(true)
|
|
222
|
+
editor.inputs.setShiftKey(true)
|
|
261
223
|
expect(customUtil.options.shouldBeExact(editor, true)).toBe(true)
|
|
262
224
|
|
|
263
225
|
// Test shouldBeExact with both keys but not precise
|
|
264
|
-
editor.inputs.
|
|
265
|
-
editor.inputs.
|
|
226
|
+
editor.inputs.setAltKey(true)
|
|
227
|
+
editor.inputs.setShiftKey(true)
|
|
266
228
|
expect(customUtil.options.shouldBeExact(editor, false)).toBe(false)
|
|
267
229
|
|
|
268
230
|
// Test shouldBeExact with only one key
|
|
269
|
-
editor.inputs.
|
|
270
|
-
editor.inputs.
|
|
231
|
+
editor.inputs.setAltKey(true)
|
|
232
|
+
editor.inputs.setShiftKey(false)
|
|
271
233
|
expect(customUtil.options.shouldBeExact(editor, true)).toBe(false)
|
|
272
234
|
|
|
273
235
|
// Test shouldIgnoreTargets with any key
|
|
274
|
-
editor.inputs.
|
|
275
|
-
editor.inputs.
|
|
276
|
-
editor.inputs.
|
|
236
|
+
editor.inputs.setAltKey(false)
|
|
237
|
+
editor.inputs.setCtrlKey(false)
|
|
238
|
+
editor.inputs.setShiftKey(true)
|
|
277
239
|
expect(customUtil.options.shouldIgnoreTargets(editor)).toBe(true)
|
|
278
240
|
|
|
279
241
|
// Test shouldIgnoreTargets with no keys
|
|
280
|
-
editor.inputs.
|
|
281
|
-
editor.inputs.
|
|
282
|
-
editor.inputs.
|
|
242
|
+
editor.inputs.setAltKey(false)
|
|
243
|
+
editor.inputs.setCtrlKey(false)
|
|
244
|
+
editor.inputs.setShiftKey(false)
|
|
283
245
|
expect(customUtil.options.shouldIgnoreTargets(editor)).toBe(false)
|
|
284
246
|
})
|
|
285
247
|
})
|
|
286
248
|
|
|
287
249
|
describe('Integration with arrow tool states', () => {
|
|
288
|
-
it('should respect shouldIgnoreTargets in idle state', () => {
|
|
289
|
-
editor.setCurrentTool('arrow')
|
|
290
|
-
editor.expectToBeIn('arrow.idle')
|
|
291
|
-
|
|
292
|
-
// Move to a position over box1
|
|
293
|
-
editor.inputs.ctrlKey = true // shouldIgnoreTargets = true
|
|
294
|
-
editor.pointerMove(150, 150)
|
|
295
|
-
|
|
296
|
-
// The arrow tool should not show any target highlighting
|
|
297
|
-
// (This is more of an integration test - exact assertions would depend on internal state)
|
|
298
|
-
expect(editor.getCurrentToolId()).toBe('arrow')
|
|
299
|
-
})
|
|
300
|
-
|
|
301
250
|
it('should allow custom shouldBeExact logic based on isPrecise - example from arrow precise-exact', () => {
|
|
302
251
|
// This replicates the logic from the arrows-precise-exact example
|
|
303
252
|
const baseUtil = editor.getShapeUtil<ArrowShapeUtil>('arrow')
|
|
@@ -315,10 +264,10 @@ describe('ArrowShapeOptions', () => {
|
|
|
315
264
|
|
|
316
265
|
try {
|
|
317
266
|
editor.setCurrentTool('arrow')
|
|
318
|
-
editor.inputs.
|
|
267
|
+
editor.inputs.setCtrlKey(false) // Allow binding
|
|
319
268
|
|
|
320
269
|
// Set up fast pointer velocity to ensure precise remains false
|
|
321
|
-
editor.inputs.
|
|
270
|
+
editor.inputs.setPointerVelocity({ x: 2, y: 2, len: () => 2.8 } as any)
|
|
322
271
|
|
|
323
272
|
const targetState = updateArrowTargetState({
|
|
324
273
|
editor,
|
|
@@ -352,47 +301,5 @@ describe('ArrowShapeOptions', () => {
|
|
|
352
301
|
baseUtil.options.shouldBeExact = originalShouldBeExact
|
|
353
302
|
}
|
|
354
303
|
})
|
|
355
|
-
|
|
356
|
-
it('should respect shouldIgnoreTargets when starting arrow creation', () => {
|
|
357
|
-
editor.setCurrentTool('arrow')
|
|
358
|
-
|
|
359
|
-
// Start creating arrow with ctrl held (shouldIgnoreTargets = true)
|
|
360
|
-
editor.inputs.ctrlKey = true
|
|
361
|
-
editor.pointerDown(150, 150) // Start in center of box1
|
|
362
|
-
|
|
363
|
-
// Even though we're starting in a shape, no binding should be created
|
|
364
|
-
editor.pointerMove(200, 200)
|
|
365
|
-
editor.pointerUp()
|
|
366
|
-
|
|
367
|
-
const createdArrow = editor
|
|
368
|
-
.getCurrentPageShapes()
|
|
369
|
-
.find((s) => s.type === 'arrow') as TLArrowShape
|
|
370
|
-
expect(createdArrow).toBeDefined()
|
|
371
|
-
|
|
372
|
-
const arrowBindings = getArrowBindings(editor, createdArrow)
|
|
373
|
-
expect(arrowBindings.start).toBeUndefined()
|
|
374
|
-
expect(arrowBindings.end).toBeUndefined()
|
|
375
|
-
})
|
|
376
|
-
|
|
377
|
-
it('should respect shouldBeExact during arrow creation', () => {
|
|
378
|
-
editor.setCurrentTool('arrow')
|
|
379
|
-
|
|
380
|
-
// Create arrow with alt held (shouldBeExact = true)
|
|
381
|
-
editor.inputs.altKey = true
|
|
382
|
-
editor.inputs.ctrlKey = false // Allow binding
|
|
383
|
-
|
|
384
|
-
editor.pointerDown(50, 50) // Start outside shapes
|
|
385
|
-
editor.pointerMove(150, 150) // Move to center of box1
|
|
386
|
-
editor.pointerUp()
|
|
387
|
-
|
|
388
|
-
const createdArrow = editor
|
|
389
|
-
.getCurrentPageShapes()
|
|
390
|
-
.find((s) => s.type === 'arrow') as TLArrowShape
|
|
391
|
-
expect(createdArrow).toBeDefined()
|
|
392
|
-
|
|
393
|
-
const arrowBindings = getArrowBindings(editor, createdArrow)
|
|
394
|
-
expect(arrowBindings.end).toBeDefined()
|
|
395
|
-
expect(arrowBindings.end?.props.isExact).toBe(true)
|
|
396
|
-
})
|
|
397
304
|
})
|
|
398
305
|
})
|
|
@@ -144,7 +144,7 @@ describe('When pointing a start shape', () => {
|
|
|
144
144
|
expect(getArrowTargetState(editor)).not.toBeNull()
|
|
145
145
|
|
|
146
146
|
// Fake some velocity
|
|
147
|
-
editor.inputs.
|
|
147
|
+
editor.inputs.setPointerVelocity(new Vec(1, 1))
|
|
148
148
|
|
|
149
149
|
editor.pointerMove(375, 500)
|
|
150
150
|
|
|
@@ -189,7 +189,7 @@ describe('When pointing an end shape', () => {
|
|
|
189
189
|
expect(editor.getHintingShapeIds().length).toBe(0)
|
|
190
190
|
|
|
191
191
|
// Fake some velocity
|
|
192
|
-
editor.inputs.
|
|
192
|
+
editor.inputs.setPointerVelocity(new Vec(1, 1))
|
|
193
193
|
|
|
194
194
|
// Move onto shape
|
|
195
195
|
editor.pointerMove(375, 375)
|
|
@@ -227,7 +227,7 @@ describe('When pointing an end shape', () => {
|
|
|
227
227
|
it('unbinds and rebinds', () => {
|
|
228
228
|
editor.setCurrentTool('arrow').pointerDown(0, 0)
|
|
229
229
|
|
|
230
|
-
editor.inputs.
|
|
230
|
+
editor.inputs.setPointerVelocity(new Vec(1, 1))
|
|
231
231
|
|
|
232
232
|
editor.pointerMove(375, 375)
|
|
233
233
|
|
|
@@ -283,7 +283,7 @@ describe('When pointing an end shape', () => {
|
|
|
283
283
|
})
|
|
284
284
|
|
|
285
285
|
// Build up some velocity
|
|
286
|
-
editor.inputs.
|
|
286
|
+
editor.inputs.setPointerVelocity(new Vec(1, 1))
|
|
287
287
|
editor.pointerMove(325, 325)
|
|
288
288
|
expect(getArrowTargetState(editor)).not.toBeNull()
|
|
289
289
|
|
|
@@ -403,7 +403,7 @@ describe('When pointing an end shape', () => {
|
|
|
403
403
|
|
|
404
404
|
it('begins imprecise when moving quickly', () => {
|
|
405
405
|
editor.setCurrentTool('arrow').pointerDown(0, 0)
|
|
406
|
-
editor.inputs.
|
|
406
|
+
editor.inputs.setPointerVelocity(new Vec(1, 1))
|
|
407
407
|
editor.pointerMove(370, 370)
|
|
408
408
|
|
|
409
409
|
const arrow = editor.getCurrentPageShapes()[editor.getCurrentPageShapes().length - 1]
|
|
@@ -435,7 +435,7 @@ describe('When pointing an end shape', () => {
|
|
|
435
435
|
|
|
436
436
|
expect(getArrowTargetState(editor)).toBeNull()
|
|
437
437
|
|
|
438
|
-
editor.inputs.
|
|
438
|
+
editor.inputs.setPointerVelocity(new Vec(0.001, 0.001))
|
|
439
439
|
editor.pointerMove(375, 375)
|
|
440
440
|
|
|
441
441
|
arrow = editor.getCurrentPageShapes()[editor.getCurrentPageShapes().length - 1]
|
|
@@ -588,7 +588,7 @@ describe('precision timeout configuration', () => {
|
|
|
588
588
|
|
|
589
589
|
editor.setCurrentTool('arrow').pointerDown(0, 0)
|
|
590
590
|
// Use high velocity to avoid precise mode immediately
|
|
591
|
-
editor.inputs.
|
|
591
|
+
editor.inputs.setPointerVelocity(new Vec(1, 1))
|
|
592
592
|
editor.pointerMove(100, 100)
|
|
593
593
|
|
|
594
594
|
const arrow = editor.getCurrentPageShapes()[
|
|
@@ -630,7 +630,7 @@ describe('precision timeout configuration', () => {
|
|
|
630
630
|
|
|
631
631
|
editor.setCurrentTool('arrow').pointerDown(0, 0)
|
|
632
632
|
// Use high velocity to avoid precise mode immediately
|
|
633
|
-
editor.inputs.
|
|
633
|
+
editor.inputs.setPointerVelocity(new Vec(1, 1))
|
|
634
634
|
editor.pointerMove(100, 100)
|
|
635
635
|
|
|
636
636
|
const arrow = editor.getCurrentPageShapes()[
|