tldraw 4.2.2 → 4.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-cjs/index.d.ts +242 -311
- package/dist-cjs/index.js +5 -13
- package/dist-cjs/index.js.map +2 -2
- package/dist-cjs/lib/bindings/arrow/ArrowBindingUtil.js.map +2 -2
- package/dist-cjs/lib/canvas/TldrawSelectionForeground.js +4 -7
- package/dist-cjs/lib/canvas/TldrawSelectionForeground.js.map +2 -2
- package/dist-cjs/lib/defaultEmbedDefinitions.js.map +2 -2
- package/dist-cjs/lib/defaultExternalContentHandlers.js +5 -5
- package/dist-cjs/lib/defaultExternalContentHandlers.js.map +2 -2
- package/dist-cjs/lib/defaultSideEffects.js +1 -6
- package/dist-cjs/lib/defaultSideEffects.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js +13 -14
- package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/arrow-types.js.map +1 -1
- package/dist-cjs/lib/shapes/arrow/arrowLabel.js +1 -1
- package/dist-cjs/lib/shapes/arrow/arrowLabel.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/arrowTargetState.js +1 -1
- package/dist-cjs/lib/shapes/arrow/arrowTargetState.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/elbow/elbowArrowSnapLines.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/shared.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/toolStates/Idle.js +10 -4
- package/dist-cjs/lib/shapes/arrow/toolStates/Idle.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.js +4 -7
- package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/shapes/bookmark/BookmarkShapeUtil.js +1 -1
- package/dist-cjs/lib/shapes/bookmark/BookmarkShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/bookmark/bookmarks.js.map +2 -2
- package/dist-cjs/lib/shapes/draw/DrawShapeUtil.js +22 -24
- package/dist-cjs/lib/shapes/draw/DrawShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/draw/getPath.js +11 -20
- package/dist-cjs/lib/shapes/draw/getPath.js.map +2 -2
- package/dist-cjs/lib/shapes/draw/toolStates/Drawing.js +86 -82
- package/dist-cjs/lib/shapes/draw/toolStates/Drawing.js.map +3 -3
- package/dist-cjs/lib/shapes/embed/EmbedShapeUtil.js +0 -6
- package/dist-cjs/lib/shapes/embed/EmbedShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/frame/FrameShapeTool.js.map +1 -1
- package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js +5 -6
- package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/geo/GeoShapeUtil.js +142 -146
- package/dist-cjs/lib/shapes/geo/GeoShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/geo/toolStates/Idle.js +10 -5
- package/dist-cjs/lib/shapes/geo/toolStates/Idle.js.map +2 -2
- package/dist-cjs/lib/shapes/geo/toolStates/Pointing.js +3 -3
- package/dist-cjs/lib/shapes/geo/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/shapes/highlight/HighlightShapeUtil.js +21 -23
- package/dist-cjs/lib/shapes/highlight/HighlightShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/line/toolStates/Pointing.js +3 -3
- package/dist-cjs/lib/shapes/line/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/shapes/note/NoteShapeUtil.js +11 -6
- package/dist-cjs/lib/shapes/note/NoteShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/note/noteHelpers.js.map +2 -2
- package/dist-cjs/lib/shapes/note/toolStates/Pointing.js +10 -5
- package/dist-cjs/lib/shapes/note/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/HyperlinkButton.js +2 -3
- package/dist-cjs/lib/shapes/shared/HyperlinkButton.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/PlainTextLabel.js +2 -14
- package/dist-cjs/lib/shapes/shared/PlainTextLabel.js.map +3 -3
- package/dist-cjs/lib/shapes/shared/RichTextLabel.js +4 -12
- package/dist-cjs/lib/shapes/shared/RichTextLabel.js.map +3 -3
- package/dist-cjs/lib/shapes/shared/ShapeFill.js +2 -2
- package/dist-cjs/lib/shapes/shared/ShapeFill.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/crop.js +0 -1
- package/dist-cjs/lib/shapes/shared/crop.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/interpolate-props.js +3 -3
- package/dist-cjs/lib/shapes/shared/interpolate-props.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/useEditablePlainText.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/useEditableRichText.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/{useEfficientZoomThreshold.js → useForceSolid.js} +7 -10
- package/dist-cjs/lib/shapes/shared/useForceSolid.js.map +7 -0
- package/dist-cjs/lib/shapes/shared/useImageOrVideoAsset.js +1 -1
- package/dist-cjs/lib/shapes/shared/useImageOrVideoAsset.js.map +2 -2
- package/dist-cjs/lib/shapes/text/RichTextArea.js +0 -5
- package/dist-cjs/lib/shapes/text/RichTextArea.js.map +2 -2
- package/dist-cjs/lib/shapes/text/TextShapeUtil.js +2 -5
- package/dist-cjs/lib/shapes/text/TextShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/text/toolStates/Idle.js +10 -4
- package/dist-cjs/lib/shapes/text/toolStates/Idle.js.map +2 -2
- package/dist-cjs/lib/shapes/text/toolStates/Pointing.js +5 -7
- package/dist-cjs/lib/shapes/text/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/shapes/video/VideoShapeUtil.js +1 -1
- package/dist-cjs/lib/shapes/video/VideoShapeUtil.js.map +2 -2
- package/dist-cjs/lib/tools/EraserTool/childStates/Erasing.js +5 -4
- package/dist-cjs/lib/tools/EraserTool/childStates/Erasing.js.map +2 -2
- package/dist-cjs/lib/tools/EraserTool/childStates/Pointing.js +4 -2
- package/dist-cjs/lib/tools/EraserTool/childStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/tools/HandTool/HandTool.js +5 -3
- package/dist-cjs/lib/tools/HandTool/HandTool.js.map +2 -2
- package/dist-cjs/lib/tools/HandTool/childStates/Dragging.js +2 -3
- package/dist-cjs/lib/tools/HandTool/childStates/Dragging.js.map +2 -2
- package/dist-cjs/lib/tools/HandTool/childStates/Pointing.js +1 -1
- package/dist-cjs/lib/tools/HandTool/childStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/tools/LaserTool/childStates/Lasering.js +1 -1
- package/dist-cjs/lib/tools/LaserTool/childStates/Lasering.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/DragAndDropManager.js +11 -10
- package/dist-cjs/lib/tools/SelectTool/DragAndDropManager.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Brushing.js +5 -6
- package/dist-cjs/lib/tools/SelectTool/childStates/Brushing.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/Cropping.js +6 -4
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/Cropping.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/Idle.js +1 -1
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/Idle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.js +1 -1
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/PointingCropHandle.js +1 -1
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/PointingCropHandle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.js +1 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.js +1 -1
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js +6 -8
- package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/EditingShape.js +11 -38
- package/dist-cjs/lib/tools/SelectTool/childStates/EditingShape.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Idle.js +50 -42
- package/dist-cjs/lib/tools/SelectTool/childStates/Idle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingArrowLabel.js +6 -6
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingArrowLabel.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingCanvas.js +1 -1
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingCanvas.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingHandle.js +14 -4
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingHandle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingResizeHandle.js +1 -1
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingResizeHandle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingRotateHandle.js +1 -1
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingRotateHandle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingSelection.js +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingSelection.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingShape.js +13 -4
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingShape.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js +6 -5
- package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Rotating.js +3 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Rotating.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/ScribbleBrushing.js +6 -7
- package/dist-cjs/lib/tools/SelectTool/childStates/ScribbleBrushing.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js +11 -13
- package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/selectHelpers.js +4 -15
- package/dist-cjs/lib/tools/SelectTool/selectHelpers.js.map +2 -2
- package/dist-cjs/lib/tools/ZoomTool/ZoomTool.js +1 -1
- package/dist-cjs/lib/tools/ZoomTool/ZoomTool.js.map +2 -2
- package/dist-cjs/lib/tools/ZoomTool/childStates/Pointing.js +3 -3
- package/dist-cjs/lib/tools/ZoomTool/childStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/tools/ZoomTool/childStates/ZoomBrushing.js +6 -5
- package/dist-cjs/lib/tools/ZoomTool/childStates/ZoomBrushing.js.map +2 -2
- package/dist-cjs/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.js +3 -1
- package/dist-cjs/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.js.map +2 -2
- package/dist-cjs/lib/{utils/test-helpers.js → tools/selection-logic/getShouldEnterCropModeOnPointerDown.js} +8 -21
- package/dist-cjs/lib/tools/selection-logic/getShouldEnterCropModeOnPointerDown.js.map +7 -0
- package/dist-cjs/lib/tools/selection-logic/selectOnCanvasPointerUp.js +1 -1
- package/dist-cjs/lib/tools/selection-logic/selectOnCanvasPointerUp.js.map +2 -2
- package/dist-cjs/lib/tools/selection-logic/updateHoveredShapeId.js +1 -1
- package/dist-cjs/lib/tools/selection-logic/updateHoveredShapeId.js.map +2 -2
- package/dist-cjs/lib/ui/TldrawUi.js +2 -2
- package/dist-cjs/lib/ui/TldrawUi.js.map +2 -2
- package/dist-cjs/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.js +9 -3
- package/dist-cjs/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.js.map +2 -2
- package/dist-cjs/lib/ui/components/ContextMenu/DefaultContextMenu.js +3 -1
- package/dist-cjs/lib/ui/components/ContextMenu/DefaultContextMenu.js.map +2 -2
- package/dist-cjs/lib/ui/components/CursorChatBubble.js +1 -1
- package/dist-cjs/lib/ui/components/CursorChatBubble.js.map +2 -2
- package/dist-cjs/lib/ui/components/DefaultDebugPanel.js +21 -1
- package/dist-cjs/lib/ui/components/DefaultDebugPanel.js.map +2 -2
- package/dist-cjs/lib/ui/components/EditLinkDialog.js +1 -11
- package/dist-cjs/lib/ui/components/EditLinkDialog.js.map +2 -2
- package/dist-cjs/lib/ui/components/HelperButtons/StopFollowing.js.map +2 -2
- package/dist-cjs/lib/ui/components/Minimap/DefaultMinimap.js +1 -1
- package/dist-cjs/lib/ui/components/Minimap/DefaultMinimap.js.map +2 -2
- package/dist-cjs/lib/ui/components/OfflineIndicator/OfflineIndicator.js +15 -2
- package/dist-cjs/lib/ui/components/OfflineIndicator/OfflineIndicator.js.map +3 -3
- package/dist-cjs/lib/ui/components/PageMenu/PageItemInput.js +1 -3
- package/dist-cjs/lib/ui/components/PageMenu/PageItemInput.js.map +2 -2
- package/dist-cjs/lib/ui/components/SharePanel/PeopleMenu.js +0 -6
- package/dist-cjs/lib/ui/components/SharePanel/PeopleMenu.js.map +2 -2
- package/dist-cjs/lib/ui/components/Toolbar/AltTextEditor.js.map +2 -2
- package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbar.js +1 -1
- package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbar.js.map +2 -2
- package/dist-cjs/lib/ui/components/Toolbar/DefaultRichTextToolbar.js +1 -1
- package/dist-cjs/lib/ui/components/Toolbar/DefaultRichTextToolbar.js.map +2 -2
- package/dist-cjs/lib/ui/components/TopPanel/CenteredTopPanelContainer.js.map +1 -1
- package/dist-cjs/lib/ui/components/TopPanel/DefaultTopPanel.js +32 -0
- package/dist-cjs/lib/ui/components/TopPanel/DefaultTopPanel.js.map +7 -0
- package/dist-cjs/lib/ui/components/menu-items.js +1 -3
- package/dist-cjs/lib/ui/components/menu-items.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiContextualToolbar.js +1 -3
- package/dist-cjs/lib/ui/components/primitives/TldrawUiContextualToolbar.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiSlider.js +1 -1
- package/dist-cjs/lib/ui/components/primitives/TldrawUiSlider.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js +93 -149
- package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuActionCheckboxItem.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuActionItem.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js +1 -1
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js.map +2 -2
- package/dist-cjs/lib/ui/context/actions.js +8 -7
- package/dist-cjs/lib/ui/context/actions.js.map +2 -2
- package/dist-cjs/lib/ui/context/components.js +2 -1
- package/dist-cjs/lib/ui/context/components.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/menu-hooks.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/useClipboardEvents.js +2 -2
- package/dist-cjs/lib/ui/hooks/useClipboardEvents.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/useFlatten.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/useKeyboardShortcuts.js +2 -2
- package/dist-cjs/lib/ui/hooks/useKeyboardShortcuts.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/useTools.js +5 -4
- package/dist-cjs/lib/ui/hooks/useTools.js.map +2 -2
- package/dist-cjs/lib/ui/version.js +3 -3
- package/dist-cjs/lib/ui/version.js.map +1 -1
- package/dist-cjs/lib/utils/excalidraw/putExcalidrawContent.js +6 -16
- package/dist-cjs/lib/utils/excalidraw/putExcalidrawContent.js.map +2 -2
- package/dist-cjs/lib/utils/export/exportAs.js.map +2 -2
- package/dist-cjs/lib/utils/frames/frames.js.map +2 -2
- package/dist-cjs/lib/utils/text/richText.js +2 -4
- package/dist-cjs/lib/utils/text/richText.js.map +2 -2
- package/dist-cjs/lib/utils/text/textDirection.js +51 -0
- package/dist-cjs/lib/utils/text/textDirection.js.map +7 -0
- package/dist-cjs/lib/utils/tldr/buildFromV1Document.js +2 -7
- package/dist-cjs/lib/utils/tldr/buildFromV1Document.js.map +2 -2
- package/dist-esm/index.d.mts +242 -311
- package/dist-esm/index.mjs +5 -14
- package/dist-esm/index.mjs.map +2 -2
- package/dist-esm/lib/bindings/arrow/ArrowBindingUtil.mjs.map +2 -2
- package/dist-esm/lib/canvas/TldrawSelectionForeground.mjs +4 -8
- package/dist-esm/lib/canvas/TldrawSelectionForeground.mjs.map +2 -2
- package/dist-esm/lib/defaultEmbedDefinitions.mjs.map +2 -2
- package/dist-esm/lib/defaultExternalContentHandlers.mjs +5 -5
- package/dist-esm/lib/defaultExternalContentHandlers.mjs.map +2 -2
- package/dist-esm/lib/defaultSideEffects.mjs +1 -6
- package/dist-esm/lib/defaultSideEffects.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs +15 -15
- package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/arrowLabel.mjs +1 -1
- package/dist-esm/lib/shapes/arrow/arrowLabel.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/arrowTargetState.mjs +1 -1
- package/dist-esm/lib/shapes/arrow/arrowTargetState.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/elbow/elbowArrowSnapLines.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/shared.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/toolStates/Idle.mjs +10 -4
- package/dist-esm/lib/shapes/arrow/toolStates/Idle.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs +4 -7
- package/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/shapes/bookmark/BookmarkShapeUtil.mjs +1 -1
- package/dist-esm/lib/shapes/bookmark/BookmarkShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/bookmark/bookmarks.mjs.map +2 -2
- package/dist-esm/lib/shapes/draw/DrawShapeUtil.mjs +24 -29
- package/dist-esm/lib/shapes/draw/DrawShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/draw/getPath.mjs +11 -21
- package/dist-esm/lib/shapes/draw/getPath.mjs.map +2 -2
- package/dist-esm/lib/shapes/draw/toolStates/Drawing.mjs +86 -83
- package/dist-esm/lib/shapes/draw/toolStates/Drawing.mjs.map +3 -3
- package/dist-esm/lib/shapes/embed/EmbedShapeUtil.mjs +0 -6
- package/dist-esm/lib/shapes/embed/EmbedShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/frame/FrameShapeTool.mjs.map +1 -1
- package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs +5 -6
- package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/geo/GeoShapeUtil.mjs +142 -147
- package/dist-esm/lib/shapes/geo/GeoShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/geo/toolStates/Idle.mjs +10 -5
- package/dist-esm/lib/shapes/geo/toolStates/Idle.mjs.map +2 -2
- package/dist-esm/lib/shapes/geo/toolStates/Pointing.mjs +3 -3
- package/dist-esm/lib/shapes/geo/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/shapes/highlight/HighlightShapeUtil.mjs +22 -24
- package/dist-esm/lib/shapes/highlight/HighlightShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/line/toolStates/Pointing.mjs +3 -3
- package/dist-esm/lib/shapes/line/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs +12 -7
- package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/note/noteHelpers.mjs.map +2 -2
- package/dist-esm/lib/shapes/note/toolStates/Pointing.mjs +10 -5
- package/dist-esm/lib/shapes/note/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/HyperlinkButton.mjs +3 -4
- package/dist-esm/lib/shapes/shared/HyperlinkButton.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/PlainTextLabel.mjs +2 -14
- package/dist-esm/lib/shapes/shared/PlainTextLabel.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/RichTextLabel.mjs +4 -12
- package/dist-esm/lib/shapes/shared/RichTextLabel.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/ShapeFill.mjs +2 -2
- package/dist-esm/lib/shapes/shared/ShapeFill.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/crop.mjs +0 -1
- package/dist-esm/lib/shapes/shared/crop.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/interpolate-props.mjs +4 -4
- package/dist-esm/lib/shapes/shared/interpolate-props.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/useEditablePlainText.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/useEditableRichText.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/useForceSolid.mjs +9 -0
- package/dist-esm/lib/shapes/shared/useForceSolid.mjs.map +7 -0
- package/dist-esm/lib/shapes/shared/useImageOrVideoAsset.mjs +1 -1
- package/dist-esm/lib/shapes/shared/useImageOrVideoAsset.mjs.map +2 -2
- package/dist-esm/lib/shapes/text/RichTextArea.mjs +0 -5
- package/dist-esm/lib/shapes/text/RichTextArea.mjs.map +2 -2
- package/dist-esm/lib/shapes/text/TextShapeUtil.mjs +2 -5
- package/dist-esm/lib/shapes/text/TextShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/text/toolStates/Idle.mjs +10 -4
- package/dist-esm/lib/shapes/text/toolStates/Idle.mjs.map +2 -2
- package/dist-esm/lib/shapes/text/toolStates/Pointing.mjs +5 -7
- package/dist-esm/lib/shapes/text/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/shapes/video/VideoShapeUtil.mjs +1 -1
- package/dist-esm/lib/shapes/video/VideoShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/tools/EraserTool/childStates/Erasing.mjs +5 -4
- package/dist-esm/lib/tools/EraserTool/childStates/Erasing.mjs.map +2 -2
- package/dist-esm/lib/tools/EraserTool/childStates/Pointing.mjs +8 -3
- package/dist-esm/lib/tools/EraserTool/childStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/tools/HandTool/HandTool.mjs +5 -3
- package/dist-esm/lib/tools/HandTool/HandTool.mjs.map +2 -2
- package/dist-esm/lib/tools/HandTool/childStates/Dragging.mjs +2 -3
- package/dist-esm/lib/tools/HandTool/childStates/Dragging.mjs.map +2 -2
- package/dist-esm/lib/tools/HandTool/childStates/Pointing.mjs +1 -1
- package/dist-esm/lib/tools/HandTool/childStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/tools/LaserTool/childStates/Lasering.mjs +1 -1
- package/dist-esm/lib/tools/LaserTool/childStates/Lasering.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/DragAndDropManager.mjs +11 -10
- package/dist-esm/lib/tools/SelectTool/DragAndDropManager.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Brushing.mjs +5 -6
- package/dist-esm/lib/tools/SelectTool/childStates/Brushing.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/Cropping.mjs +6 -4
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/Cropping.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/Idle.mjs +1 -1
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/Idle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.mjs +1 -1
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCropHandle.mjs +1 -1
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCropHandle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.mjs +1 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.mjs +1 -1
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs +6 -8
- package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/EditingShape.mjs +11 -38
- package/dist-esm/lib/tools/SelectTool/childStates/EditingShape.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Idle.mjs +51 -43
- package/dist-esm/lib/tools/SelectTool/childStates/Idle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingArrowLabel.mjs +6 -6
- package/dist-esm/lib/tools/SelectTool/childStates/PointingArrowLabel.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingCanvas.mjs +1 -1
- package/dist-esm/lib/tools/SelectTool/childStates/PointingCanvas.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingHandle.mjs +19 -6
- package/dist-esm/lib/tools/SelectTool/childStates/PointingHandle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingResizeHandle.mjs +1 -1
- package/dist-esm/lib/tools/SelectTool/childStates/PointingResizeHandle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingRotateHandle.mjs +1 -1
- package/dist-esm/lib/tools/SelectTool/childStates/PointingRotateHandle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingSelection.mjs +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingSelection.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingShape.mjs +13 -4
- package/dist-esm/lib/tools/SelectTool/childStates/PointingShape.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs +6 -5
- package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Rotating.mjs +3 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Rotating.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/ScribbleBrushing.mjs +6 -7
- package/dist-esm/lib/tools/SelectTool/childStates/ScribbleBrushing.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs +11 -13
- package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/selectHelpers.mjs +4 -17
- package/dist-esm/lib/tools/SelectTool/selectHelpers.mjs.map +2 -2
- package/dist-esm/lib/tools/ZoomTool/ZoomTool.mjs +1 -1
- package/dist-esm/lib/tools/ZoomTool/ZoomTool.mjs.map +2 -2
- package/dist-esm/lib/tools/ZoomTool/childStates/Pointing.mjs +3 -3
- package/dist-esm/lib/tools/ZoomTool/childStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/tools/ZoomTool/childStates/ZoomBrushing.mjs +6 -5
- package/dist-esm/lib/tools/ZoomTool/childStates/ZoomBrushing.mjs.map +2 -2
- package/dist-esm/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.mjs +3 -1
- package/dist-esm/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.mjs.map +2 -2
- package/dist-esm/lib/tools/selection-logic/getShouldEnterCropModeOnPointerDown.mjs +8 -0
- package/dist-esm/lib/tools/selection-logic/getShouldEnterCropModeOnPointerDown.mjs.map +7 -0
- package/dist-esm/lib/tools/selection-logic/selectOnCanvasPointerUp.mjs +1 -1
- package/dist-esm/lib/tools/selection-logic/selectOnCanvasPointerUp.mjs.map +2 -2
- package/dist-esm/lib/tools/selection-logic/updateHoveredShapeId.mjs +1 -1
- package/dist-esm/lib/tools/selection-logic/updateHoveredShapeId.mjs.map +2 -2
- package/dist-esm/lib/ui/TldrawUi.mjs +2 -2
- package/dist-esm/lib/ui/TldrawUi.mjs.map +2 -2
- package/dist-esm/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.mjs +8 -2
- package/dist-esm/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.mjs.map +2 -2
- package/dist-esm/lib/ui/components/ContextMenu/DefaultContextMenu.mjs +3 -1
- package/dist-esm/lib/ui/components/ContextMenu/DefaultContextMenu.mjs.map +2 -2
- package/dist-esm/lib/ui/components/CursorChatBubble.mjs +1 -1
- package/dist-esm/lib/ui/components/CursorChatBubble.mjs.map +2 -2
- package/dist-esm/lib/ui/components/DefaultDebugPanel.mjs +30 -3
- package/dist-esm/lib/ui/components/DefaultDebugPanel.mjs.map +2 -2
- package/dist-esm/lib/ui/components/EditLinkDialog.mjs +1 -11
- package/dist-esm/lib/ui/components/EditLinkDialog.mjs.map +2 -2
- package/dist-esm/lib/ui/components/HelperButtons/StopFollowing.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Minimap/DefaultMinimap.mjs +1 -1
- package/dist-esm/lib/ui/components/Minimap/DefaultMinimap.mjs.map +2 -2
- package/dist-esm/lib/ui/components/OfflineIndicator/OfflineIndicator.mjs +6 -3
- package/dist-esm/lib/ui/components/OfflineIndicator/OfflineIndicator.mjs.map +2 -2
- package/dist-esm/lib/ui/components/PageMenu/PageItemInput.mjs +1 -3
- package/dist-esm/lib/ui/components/PageMenu/PageItemInput.mjs.map +2 -2
- package/dist-esm/lib/ui/components/SharePanel/PeopleMenu.mjs +0 -6
- package/dist-esm/lib/ui/components/SharePanel/PeopleMenu.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Toolbar/AltTextEditor.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbar.mjs +1 -1
- package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbar.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Toolbar/DefaultRichTextToolbar.mjs +1 -1
- package/dist-esm/lib/ui/components/Toolbar/DefaultRichTextToolbar.mjs.map +2 -2
- package/dist-esm/lib/ui/components/TopPanel/CenteredTopPanelContainer.mjs.map +1 -1
- package/dist-esm/lib/ui/components/TopPanel/DefaultTopPanel.mjs +12 -0
- package/dist-esm/lib/ui/components/TopPanel/DefaultTopPanel.mjs.map +7 -0
- package/dist-esm/lib/ui/components/menu-items.mjs +5 -4
- package/dist-esm/lib/ui/components/menu-items.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiContextualToolbar.mjs +1 -3
- package/dist-esm/lib/ui/components/primitives/TldrawUiContextualToolbar.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiSlider.mjs +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiSlider.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs +95 -157
- package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuActionCheckboxItem.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuActionItem.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs +2 -2
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs.map +2 -2
- package/dist-esm/lib/ui/context/actions.mjs +8 -7
- package/dist-esm/lib/ui/context/actions.mjs.map +2 -2
- package/dist-esm/lib/ui/context/components.mjs +2 -1
- package/dist-esm/lib/ui/context/components.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/menu-hooks.mjs +4 -1
- package/dist-esm/lib/ui/hooks/menu-hooks.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/useClipboardEvents.mjs +2 -2
- package/dist-esm/lib/ui/hooks/useClipboardEvents.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/useFlatten.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/useKeyboardShortcuts.mjs +2 -2
- package/dist-esm/lib/ui/hooks/useKeyboardShortcuts.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/useTools.mjs +5 -4
- package/dist-esm/lib/ui/hooks/useTools.mjs.map +2 -2
- package/dist-esm/lib/ui/version.mjs +3 -3
- package/dist-esm/lib/ui/version.mjs.map +1 -1
- package/dist-esm/lib/utils/excalidraw/putExcalidrawContent.mjs +6 -17
- package/dist-esm/lib/utils/excalidraw/putExcalidrawContent.mjs.map +2 -2
- package/dist-esm/lib/utils/export/exportAs.mjs +3 -1
- package/dist-esm/lib/utils/export/exportAs.mjs.map +2 -2
- package/dist-esm/lib/utils/frames/frames.mjs.map +2 -2
- package/dist-esm/lib/utils/text/richText.mjs +2 -5
- package/dist-esm/lib/utils/text/richText.mjs.map +2 -2
- package/dist-esm/lib/utils/text/textDirection.mjs +31 -0
- package/dist-esm/lib/utils/text/textDirection.mjs.map +7 -0
- package/dist-esm/lib/utils/tldr/buildFromV1Document.mjs +2 -8
- package/dist-esm/lib/utils/tldr/buildFromV1Document.mjs.map +2 -2
- package/package.json +16 -18
- package/src/index.ts +2 -6
- package/src/lib/Tldraw.test.tsx +1 -46
- package/src/lib/bindings/arrow/ArrowBindingUtil.ts +1 -1
- package/src/lib/canvas/TldrawSelectionForeground.tsx +9 -20
- package/src/lib/defaultEmbedDefinitions.ts +0 -1
- package/src/lib/defaultExternalContentHandlers.ts +14 -13
- package/src/lib/defaultSideEffects.ts +1 -6
- package/src/lib/shapes/arrow/ArrowShapeOptions.test.ts +133 -40
- package/src/lib/shapes/arrow/ArrowShapeTool.test.ts +8 -8
- package/src/lib/shapes/arrow/ArrowShapeUtil.test.ts +2 -2
- package/src/lib/shapes/arrow/ArrowShapeUtil.tsx +16 -16
- package/src/lib/shapes/arrow/arrow-types.ts +0 -2
- package/src/lib/shapes/arrow/arrowLabel.ts +2 -2
- package/src/lib/shapes/arrow/arrowTargetState.ts +2 -2
- package/src/lib/shapes/arrow/elbow/elbowArrowSnapLines.tsx +3 -3
- package/src/lib/shapes/arrow/shared.ts +4 -4
- package/src/lib/shapes/arrow/toolStates/Idle.tsx +14 -4
- package/src/lib/shapes/arrow/toolStates/Pointing.tsx +5 -8
- package/src/lib/shapes/bookmark/BookmarkShapeUtil.tsx +1 -1
- package/src/lib/shapes/bookmark/bookmarks.ts +3 -3
- package/src/lib/shapes/draw/DrawShapeUtil.tsx +26 -30
- package/src/lib/shapes/draw/getPath.ts +10 -31
- package/src/lib/shapes/draw/toolStates/Drawing.ts +90 -100
- package/src/lib/shapes/embed/EmbedShapeUtil.tsx +1 -8
- package/src/lib/shapes/frame/FrameShapeTool.ts +1 -1
- package/src/lib/shapes/frame/FrameShapeUtil.tsx +4 -10
- package/src/lib/shapes/geo/GeoShapeUtil.test.tsx +2 -10
- package/src/lib/shapes/geo/GeoShapeUtil.tsx +176 -228
- package/src/lib/shapes/geo/toolStates/Idle.ts +15 -5
- package/src/lib/shapes/geo/toolStates/Pointing.ts +6 -6
- package/src/lib/shapes/highlight/HighlightShapeUtil.tsx +24 -25
- package/src/lib/shapes/line/LineShapeTool.test.ts +6 -6
- package/src/lib/shapes/line/LineShapeUtil.test.tsx +5 -5
- package/src/lib/shapes/line/toolStates/Pointing.ts +4 -4
- package/src/lib/shapes/note/NoteShapeTool.test.ts +1 -2
- package/src/lib/shapes/note/NoteShapeUtil.tsx +10 -9
- package/src/lib/shapes/note/noteCloning.test.ts +1 -3
- package/src/lib/shapes/note/noteHelpers.ts +2 -2
- package/src/lib/shapes/note/toolStates/Pointing.ts +10 -5
- package/src/lib/shapes/shared/HyperlinkButton.tsx +3 -4
- package/src/lib/shapes/shared/PlainTextLabel.tsx +2 -12
- package/src/lib/shapes/shared/RichTextLabel.tsx +4 -14
- package/src/lib/shapes/shared/ShapeFill.tsx +2 -2
- package/src/lib/shapes/shared/crop.ts +0 -1
- package/src/lib/shapes/shared/interpolate-props.ts +4 -4
- package/src/lib/shapes/shared/useEditablePlainText.ts +3 -7
- package/src/lib/shapes/shared/useEditableRichText.ts +3 -7
- package/src/lib/shapes/shared/useForceSolid.ts +6 -0
- package/src/lib/shapes/shared/useImageOrVideoAsset.ts +1 -1
- package/src/lib/shapes/text/RichTextArea.tsx +0 -5
- package/src/lib/shapes/text/TextShapeTool.test.ts +4 -4
- package/src/lib/shapes/text/TextShapeUtil.tsx +0 -5
- package/src/lib/shapes/text/toolStates/Idle.ts +14 -4
- package/src/lib/shapes/text/toolStates/Pointing.ts +8 -8
- package/src/lib/shapes/video/VideoShapeUtil.tsx +1 -2
- package/src/lib/tools/EraserTool/childStates/Erasing.ts +10 -7
- package/src/lib/tools/EraserTool/childStates/Pointing.ts +20 -5
- package/src/lib/tools/HandTool/HandTool.ts +5 -3
- package/src/lib/tools/HandTool/childStates/Dragging.ts +2 -3
- package/src/lib/tools/HandTool/childStates/Pointing.ts +1 -1
- package/src/lib/tools/LaserTool/childStates/Lasering.ts +1 -1
- package/src/lib/tools/SelectTool/DragAndDropManager.ts +11 -14
- package/src/lib/tools/SelectTool/childStates/Brushing.ts +11 -8
- package/src/lib/tools/SelectTool/childStates/Crop/children/Cropping.ts +6 -7
- package/src/lib/tools/SelectTool/childStates/Crop/children/Idle.ts +4 -3
- package/src/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.ts +1 -1
- package/src/lib/tools/SelectTool/childStates/Crop/children/PointingCropHandle.ts +1 -1
- package/src/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.ts +1 -2
- package/src/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.ts +1 -1
- package/src/lib/tools/SelectTool/childStates/DraggingHandle.tsx +12 -11
- package/src/lib/tools/SelectTool/childStates/EditingShape.ts +16 -57
- package/src/lib/tools/SelectTool/childStates/Idle.ts +81 -64
- package/src/lib/tools/SelectTool/childStates/PointingArrowLabel.ts +8 -7
- package/src/lib/tools/SelectTool/childStates/PointingCanvas.ts +1 -1
- package/src/lib/tools/SelectTool/childStates/PointingHandle.ts +17 -9
- package/src/lib/tools/SelectTool/childStates/PointingResizeHandle.ts +1 -1
- package/src/lib/tools/SelectTool/childStates/PointingRotateHandle.ts +1 -1
- package/src/lib/tools/SelectTool/childStates/PointingSelection.ts +4 -4
- package/src/lib/tools/SelectTool/childStates/PointingShape.ts +14 -4
- package/src/lib/tools/SelectTool/childStates/Resizing.ts +10 -8
- package/src/lib/tools/SelectTool/childStates/Rotating.ts +3 -2
- package/src/lib/tools/SelectTool/childStates/ScribbleBrushing.ts +10 -9
- package/src/lib/tools/SelectTool/childStates/Translating.ts +15 -16
- package/src/lib/tools/SelectTool/selectHelpers.ts +4 -39
- package/src/lib/tools/ZoomTool/ZoomTool.ts +1 -1
- package/src/lib/tools/ZoomTool/childStates/Pointing.ts +3 -3
- package/src/lib/tools/ZoomTool/childStates/ZoomBrushing.ts +6 -5
- package/src/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.ts +3 -1
- package/src/lib/tools/selection-logic/getShouldEnterCropModeOnPointerDown.ts +10 -0
- package/src/lib/tools/selection-logic/selectOnCanvasPointerUp.ts +1 -1
- package/src/lib/tools/selection-logic/updateHoveredShapeId.ts +1 -1
- package/src/lib/ui/TldrawUi.tsx +2 -5
- package/src/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.tsx +9 -1
- package/src/lib/ui/components/ContextMenu/DefaultContextMenu.tsx +3 -1
- package/src/lib/ui/components/CursorChatBubble.tsx +2 -2
- package/src/lib/ui/components/DefaultDebugPanel.tsx +42 -3
- package/src/lib/ui/components/EditLinkDialog.tsx +6 -16
- package/src/lib/ui/components/HelperButtons/StopFollowing.tsx +2 -2
- package/src/lib/ui/components/Minimap/DefaultMinimap.tsx +1 -1
- package/src/lib/ui/components/OfflineIndicator/OfflineIndicator.tsx +5 -6
- package/src/lib/ui/components/PageMenu/PageItemInput.tsx +1 -3
- package/src/lib/ui/components/SharePanel/PeopleMenu.tsx +0 -8
- package/src/lib/ui/components/Toolbar/AltTextEditor.tsx +2 -2
- package/src/lib/ui/components/Toolbar/DefaultImageToolbar.tsx +1 -1
- package/src/lib/ui/components/Toolbar/DefaultRichTextToolbar.tsx +1 -1
- package/src/lib/ui/components/TopPanel/CenteredTopPanelContainer.tsx +1 -1
- package/src/lib/ui/components/TopPanel/DefaultTopPanel.tsx +10 -0
- package/src/lib/ui/components/menu-items.tsx +15 -9
- package/src/lib/ui/components/primitives/TldrawUiContextualToolbar.tsx +3 -5
- package/src/lib/ui/components/primitives/TldrawUiSlider.tsx +2 -2
- package/src/lib/ui/components/primitives/TldrawUiTooltip.tsx +113 -208
- package/src/lib/ui/components/primitives/menus/TldrawUiMenuActionCheckboxItem.tsx +1 -1
- package/src/lib/ui/components/primitives/menus/TldrawUiMenuActionItem.tsx +1 -1
- package/src/lib/ui/components/primitives/menus/TldrawUiMenuItem.tsx +2 -2
- package/src/lib/ui/context/actions.tsx +19 -15
- package/src/lib/ui/context/components.tsx +2 -1
- package/src/lib/ui/hooks/menu-hooks.ts +19 -9
- package/src/lib/ui/hooks/useClipboardEvents.ts +2 -2
- package/src/lib/ui/hooks/useFlatten.ts +2 -1
- package/src/lib/ui/hooks/useKeyboardShortcuts.ts +2 -2
- package/src/lib/ui/hooks/useTools.tsx +7 -5
- package/src/lib/ui/version.ts +3 -3
- package/src/lib/ui.css +29 -31
- package/src/lib/utils/excalidraw/__snapshots__/putExcalidrawContent.test.tsx.snap +48 -12
- package/src/lib/utils/excalidraw/putExcalidrawContent.ts +6 -19
- package/src/lib/utils/export/exportAs.ts +9 -2
- package/src/lib/utils/frames/frames.ts +1 -1
- package/src/lib/utils/text/richText.ts +5 -6
- package/src/lib/utils/text/textDirection.ts +32 -0
- package/src/lib/utils/tldr/buildFromV1Document.ts +19 -21
- package/src/test/Editor.test.tsx +41 -78
- package/src/test/EraserTool.test.ts +12 -10
- package/src/test/SelectTool.test.ts +19 -11
- package/src/test/TestEditor.ts +51 -49
- package/src/test/TldrawEditor.test.tsx +20 -24
- package/src/test/__snapshots__/drawing.test.ts.snap +1257 -3
- package/src/test/__snapshots__/resizing.test.ts.snap +12 -3
- package/src/test/arrows-megabus.test.tsx +1 -1
- package/src/test/bindings.test.tsx +25 -29
- package/src/test/bindingsIndex.test.tsx +4 -4
- package/src/test/commands/__snapshots__/getSvgString.test.ts.snap +10 -10
- package/src/test/commands/createShapes.test.ts +1 -15
- package/src/test/commands/getSvgString.test.ts +2 -2
- package/src/test/commands/putContent.test.ts +1 -80
- package/src/test/commands/setCamera.test.ts +11 -13
- package/src/test/commands/stackShapes.test.ts +8 -34
- package/src/test/commands/updateShapes.test.ts +5 -21
- package/src/test/commands/zoomToBounds.test.ts +3 -19
- package/src/test/commands/zoomToSelection.test.ts +3 -14
- package/src/test/custom-clipping.test.ts +44 -52
- package/src/test/customSnapping.test.tsx +62 -77
- package/src/test/drawing.test.ts +10 -17
- package/src/test/duplicate.test.ts +1 -1
- package/src/test/flipShapes.test.ts +0 -33
- package/src/test/frames.test.ts +2 -94
- package/src/test/getCulledShapes.test.tsx +3 -11
- package/src/test/getShapeAtPoint.test.ts +2 -2
- package/src/test/groups.test.tsx +4 -7
- package/src/test/modifiers.test.ts +6 -6
- package/src/test/resizing.test.ts +22 -16
- package/src/test/selection-omnibus.test.ts +13 -13
- package/src/test/shapeutils.test.ts +1 -1
- package/src/test/spacebarPanning.test.ts +10 -28
- package/src/test/styles2.test.tsx +1 -1
- package/src/test/styles3.test.ts +5 -5
- package/src/test/test-jsx.tsx +57 -72
- package/src/test/text.test.ts +17 -15
- package/src/test/translating.test.ts +8 -6
- package/tldraw.css +41 -45
- package/dist-cjs/lib/shapes/shared/useEfficientZoomThreshold.js.map +0 -7
- package/dist-cjs/lib/utils/test-helpers.js.map +0 -7
- package/dist-esm/lib/shapes/shared/useEfficientZoomThreshold.mjs +0 -12
- package/dist-esm/lib/shapes/shared/useEfficientZoomThreshold.mjs.map +0 -7
- package/dist-esm/lib/utils/test-helpers.mjs +0 -21
- package/dist-esm/lib/utils/test-helpers.mjs.map +0 -7
- package/src/lib/shapes/draw/DrawShapeUtil.test.ts +0 -146
- package/src/lib/shapes/highlight/HighlightShapeUtil.test.ts +0 -146
- package/src/lib/shapes/shared/useEfficientZoomThreshold.ts +0 -10
- package/src/lib/utils/test-helpers.ts +0 -60
- package/src/test/commands/cameraState.test.ts +0 -299
- package/src/test/commands/createShape.test.ts +0 -64
- package/src/test/commands/isShapeOfType.test.ts +0 -44
- package/src/test/commands/updateShape.test.ts +0 -67
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import { createShapeId, TLDrawShape } from '@tldraw/editor'
|
|
2
|
-
import { TestEditor } from '../../../test/TestEditor'
|
|
3
|
-
import { createDrawSegments, pointsToBase64 } from '../../utils/test-helpers'
|
|
4
|
-
|
|
5
|
-
let editor: TestEditor
|
|
6
|
-
|
|
7
|
-
beforeEach(() => {
|
|
8
|
-
editor = new TestEditor()
|
|
9
|
-
})
|
|
10
|
-
|
|
11
|
-
afterEach(() => {
|
|
12
|
-
editor?.dispose()
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
describe('DrawShapeUtil dot detection', () => {
|
|
16
|
-
const shapeId = createShapeId('test-draw')
|
|
17
|
-
|
|
18
|
-
function createDrawShape(segments: TLDrawShape['props']['segments']): TLDrawShape {
|
|
19
|
-
editor.createShapes([
|
|
20
|
-
{
|
|
21
|
-
id: shapeId,
|
|
22
|
-
type: 'draw',
|
|
23
|
-
props: { segments },
|
|
24
|
-
},
|
|
25
|
-
])
|
|
26
|
-
return editor.getShape(shapeId) as TLDrawShape
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
describe('getIsDot behavior via hideResizeHandles', () => {
|
|
30
|
-
it('treats a shape with one segment and zero points as a dot', () => {
|
|
31
|
-
const shape = createDrawShape([{ type: 'free', points: '' }])
|
|
32
|
-
const util = editor.getShapeUtil('draw')
|
|
33
|
-
expect(util.hideResizeHandles(shape)).toBe(true)
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
it('treats a shape with one segment and one point as a dot', () => {
|
|
37
|
-
const shape = createDrawShape(createDrawSegments([[{ x: 0, y: 0, z: 0.5 }]]))
|
|
38
|
-
const util = editor.getShapeUtil('draw')
|
|
39
|
-
expect(util.hideResizeHandles(shape)).toBe(true)
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
it('treats a shape with one segment and two points as NOT a dot', () => {
|
|
43
|
-
const shape = createDrawShape(
|
|
44
|
-
createDrawSegments([
|
|
45
|
-
[
|
|
46
|
-
{ x: 0, y: 0, z: 0.5 },
|
|
47
|
-
{ x: 10, y: 10, z: 0.5 },
|
|
48
|
-
],
|
|
49
|
-
])
|
|
50
|
-
)
|
|
51
|
-
const util = editor.getShapeUtil('draw')
|
|
52
|
-
expect(util.hideResizeHandles(shape)).toBe(false)
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
it('treats a shape with one segment and many points as NOT a dot', () => {
|
|
56
|
-
const shape = createDrawShape(
|
|
57
|
-
createDrawSegments([
|
|
58
|
-
[
|
|
59
|
-
{ x: 0, y: 0, z: 0.5 },
|
|
60
|
-
{ x: 10, y: 10, z: 0.5 },
|
|
61
|
-
{ x: 20, y: 5, z: 0.5 },
|
|
62
|
-
{ x: 30, y: 15, z: 0.5 },
|
|
63
|
-
],
|
|
64
|
-
])
|
|
65
|
-
)
|
|
66
|
-
const util = editor.getShapeUtil('draw')
|
|
67
|
-
expect(util.hideResizeHandles(shape)).toBe(false)
|
|
68
|
-
})
|
|
69
|
-
|
|
70
|
-
it('treats a shape with multiple segments as NOT a dot', () => {
|
|
71
|
-
const shape = createDrawShape(
|
|
72
|
-
createDrawSegments([[{ x: 0, y: 0, z: 0.5 }], [{ x: 10, y: 10, z: 0.5 }]])
|
|
73
|
-
)
|
|
74
|
-
const util = editor.getShapeUtil('draw')
|
|
75
|
-
expect(util.hideResizeHandles(shape)).toBe(false)
|
|
76
|
-
})
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
describe('hideRotateHandle mirrors hideResizeHandles for dots', () => {
|
|
80
|
-
it('hides rotate handle for dots', () => {
|
|
81
|
-
const shape = createDrawShape(createDrawSegments([[{ x: 0, y: 0, z: 0.5 }]]))
|
|
82
|
-
const util = editor.getShapeUtil('draw')
|
|
83
|
-
expect(util.hideRotateHandle(shape)).toBe(true)
|
|
84
|
-
})
|
|
85
|
-
|
|
86
|
-
it('shows rotate handle for non-dots', () => {
|
|
87
|
-
const shape = createDrawShape(
|
|
88
|
-
createDrawSegments([
|
|
89
|
-
[
|
|
90
|
-
{ x: 0, y: 0, z: 0.5 },
|
|
91
|
-
{ x: 10, y: 10, z: 0.5 },
|
|
92
|
-
],
|
|
93
|
-
])
|
|
94
|
-
)
|
|
95
|
-
const util = editor.getShapeUtil('draw')
|
|
96
|
-
expect(util.hideRotateHandle(shape)).toBe(false)
|
|
97
|
-
})
|
|
98
|
-
})
|
|
99
|
-
|
|
100
|
-
describe('hideSelectionBoundsFg mirrors hideResizeHandles for dots', () => {
|
|
101
|
-
it('hides selection bounds for dots', () => {
|
|
102
|
-
const shape = createDrawShape(createDrawSegments([[{ x: 0, y: 0, z: 0.5 }]]))
|
|
103
|
-
const util = editor.getShapeUtil('draw')
|
|
104
|
-
expect(util.hideSelectionBoundsFg(shape)).toBe(true)
|
|
105
|
-
})
|
|
106
|
-
|
|
107
|
-
it('shows selection bounds for non-dots', () => {
|
|
108
|
-
const shape = createDrawShape(
|
|
109
|
-
createDrawSegments([
|
|
110
|
-
[
|
|
111
|
-
{ x: 0, y: 0, z: 0.5 },
|
|
112
|
-
{ x: 10, y: 10, z: 0.5 },
|
|
113
|
-
],
|
|
114
|
-
])
|
|
115
|
-
)
|
|
116
|
-
const util = editor.getShapeUtil('draw')
|
|
117
|
-
expect(util.hideSelectionBoundsFg(shape)).toBe(false)
|
|
118
|
-
})
|
|
119
|
-
})
|
|
120
|
-
|
|
121
|
-
describe('base64 encoding boundary conditions', () => {
|
|
122
|
-
it('correctly handles the boundary at exactly 16 base64 characters (2 points)', () => {
|
|
123
|
-
// Each point is 8 base64 characters (3 Float16s = 6 bytes = 8 base64 chars)
|
|
124
|
-
// 2 points = 16 characters, which should NOT be a dot
|
|
125
|
-
const twoPointsBase64 = pointsToBase64([
|
|
126
|
-
{ x: 0, y: 0, z: 0.5 },
|
|
127
|
-
{ x: 1, y: 1, z: 0.5 },
|
|
128
|
-
])
|
|
129
|
-
expect(twoPointsBase64.length).toBe(16)
|
|
130
|
-
|
|
131
|
-
const shape = createDrawShape([{ type: 'free', points: twoPointsBase64 }])
|
|
132
|
-
const util = editor.getShapeUtil('draw')
|
|
133
|
-
expect(util.hideResizeHandles(shape)).toBe(false)
|
|
134
|
-
})
|
|
135
|
-
|
|
136
|
-
it('correctly handles the boundary at exactly 8 base64 characters (1 point)', () => {
|
|
137
|
-
// 1 point = 8 characters, which should be a dot
|
|
138
|
-
const onePointBase64 = pointsToBase64([{ x: 0, y: 0, z: 0.5 }])
|
|
139
|
-
expect(onePointBase64.length).toBe(8)
|
|
140
|
-
|
|
141
|
-
const shape = createDrawShape([{ type: 'free', points: onePointBase64 }])
|
|
142
|
-
const util = editor.getShapeUtil('draw')
|
|
143
|
-
expect(util.hideResizeHandles(shape)).toBe(true)
|
|
144
|
-
})
|
|
145
|
-
})
|
|
146
|
-
})
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import { createShapeId, TLHighlightShape } from '@tldraw/editor'
|
|
2
|
-
import { TestEditor } from '../../../test/TestEditor'
|
|
3
|
-
import { createDrawSegments, pointsToBase64 } from '../../utils/test-helpers'
|
|
4
|
-
|
|
5
|
-
let editor: TestEditor
|
|
6
|
-
|
|
7
|
-
beforeEach(() => {
|
|
8
|
-
editor = new TestEditor()
|
|
9
|
-
})
|
|
10
|
-
|
|
11
|
-
afterEach(() => {
|
|
12
|
-
editor?.dispose()
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
describe('HighlightShapeUtil dot detection', () => {
|
|
16
|
-
const shapeId = createShapeId('test-highlight')
|
|
17
|
-
|
|
18
|
-
function createHighlightShape(segments: TLHighlightShape['props']['segments']): TLHighlightShape {
|
|
19
|
-
editor.createShapes([
|
|
20
|
-
{
|
|
21
|
-
id: shapeId,
|
|
22
|
-
type: 'highlight',
|
|
23
|
-
props: { segments },
|
|
24
|
-
},
|
|
25
|
-
])
|
|
26
|
-
return editor.getShape(shapeId) as TLHighlightShape
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
describe('getIsDot behavior via hideResizeHandles', () => {
|
|
30
|
-
it('treats a shape with one segment and zero points as a dot', () => {
|
|
31
|
-
const shape = createHighlightShape([{ type: 'free', points: '' }])
|
|
32
|
-
const util = editor.getShapeUtil('highlight')
|
|
33
|
-
expect(util.hideResizeHandles(shape)).toBe(true)
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
it('treats a shape with one segment and one point as a dot', () => {
|
|
37
|
-
const shape = createHighlightShape(createDrawSegments([[{ x: 0, y: 0, z: 0.5 }]]))
|
|
38
|
-
const util = editor.getShapeUtil('highlight')
|
|
39
|
-
expect(util.hideResizeHandles(shape)).toBe(true)
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
it('treats a shape with one segment and two points as NOT a dot', () => {
|
|
43
|
-
const shape = createHighlightShape(
|
|
44
|
-
createDrawSegments([
|
|
45
|
-
[
|
|
46
|
-
{ x: 0, y: 0, z: 0.5 },
|
|
47
|
-
{ x: 10, y: 10, z: 0.5 },
|
|
48
|
-
],
|
|
49
|
-
])
|
|
50
|
-
)
|
|
51
|
-
const util = editor.getShapeUtil('highlight')
|
|
52
|
-
expect(util.hideResizeHandles(shape)).toBe(false)
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
it('treats a shape with one segment and many points as NOT a dot', () => {
|
|
56
|
-
const shape = createHighlightShape(
|
|
57
|
-
createDrawSegments([
|
|
58
|
-
[
|
|
59
|
-
{ x: 0, y: 0, z: 0.5 },
|
|
60
|
-
{ x: 10, y: 10, z: 0.5 },
|
|
61
|
-
{ x: 20, y: 5, z: 0.5 },
|
|
62
|
-
{ x: 30, y: 15, z: 0.5 },
|
|
63
|
-
],
|
|
64
|
-
])
|
|
65
|
-
)
|
|
66
|
-
const util = editor.getShapeUtil('highlight')
|
|
67
|
-
expect(util.hideResizeHandles(shape)).toBe(false)
|
|
68
|
-
})
|
|
69
|
-
|
|
70
|
-
it('treats a shape with multiple segments as NOT a dot', () => {
|
|
71
|
-
const shape = createHighlightShape(
|
|
72
|
-
createDrawSegments([[{ x: 0, y: 0, z: 0.5 }], [{ x: 10, y: 10, z: 0.5 }]])
|
|
73
|
-
)
|
|
74
|
-
const util = editor.getShapeUtil('highlight')
|
|
75
|
-
expect(util.hideResizeHandles(shape)).toBe(false)
|
|
76
|
-
})
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
describe('hideRotateHandle mirrors hideResizeHandles for dots', () => {
|
|
80
|
-
it('hides rotate handle for dots', () => {
|
|
81
|
-
const shape = createHighlightShape(createDrawSegments([[{ x: 0, y: 0, z: 0.5 }]]))
|
|
82
|
-
const util = editor.getShapeUtil('highlight')
|
|
83
|
-
expect(util.hideRotateHandle(shape)).toBe(true)
|
|
84
|
-
})
|
|
85
|
-
|
|
86
|
-
it('shows rotate handle for non-dots', () => {
|
|
87
|
-
const shape = createHighlightShape(
|
|
88
|
-
createDrawSegments([
|
|
89
|
-
[
|
|
90
|
-
{ x: 0, y: 0, z: 0.5 },
|
|
91
|
-
{ x: 10, y: 10, z: 0.5 },
|
|
92
|
-
],
|
|
93
|
-
])
|
|
94
|
-
)
|
|
95
|
-
const util = editor.getShapeUtil('highlight')
|
|
96
|
-
expect(util.hideRotateHandle(shape)).toBe(false)
|
|
97
|
-
})
|
|
98
|
-
})
|
|
99
|
-
|
|
100
|
-
describe('hideSelectionBoundsFg mirrors hideResizeHandles for dots', () => {
|
|
101
|
-
it('hides selection bounds for dots', () => {
|
|
102
|
-
const shape = createHighlightShape(createDrawSegments([[{ x: 0, y: 0, z: 0.5 }]]))
|
|
103
|
-
const util = editor.getShapeUtil('highlight')
|
|
104
|
-
expect(util.hideSelectionBoundsFg(shape)).toBe(true)
|
|
105
|
-
})
|
|
106
|
-
|
|
107
|
-
it('shows selection bounds for non-dots', () => {
|
|
108
|
-
const shape = createHighlightShape(
|
|
109
|
-
createDrawSegments([
|
|
110
|
-
[
|
|
111
|
-
{ x: 0, y: 0, z: 0.5 },
|
|
112
|
-
{ x: 10, y: 10, z: 0.5 },
|
|
113
|
-
],
|
|
114
|
-
])
|
|
115
|
-
)
|
|
116
|
-
const util = editor.getShapeUtil('highlight')
|
|
117
|
-
expect(util.hideSelectionBoundsFg(shape)).toBe(false)
|
|
118
|
-
})
|
|
119
|
-
})
|
|
120
|
-
|
|
121
|
-
describe('base64 encoding boundary conditions', () => {
|
|
122
|
-
it('correctly handles the boundary at exactly 16 base64 characters (2 points)', () => {
|
|
123
|
-
// Each point is 8 base64 characters (3 Float16s = 6 bytes = 8 base64 chars)
|
|
124
|
-
// 2 points = 16 characters, which should NOT be a dot
|
|
125
|
-
const twoPointsBase64 = pointsToBase64([
|
|
126
|
-
{ x: 0, y: 0, z: 0.5 },
|
|
127
|
-
{ x: 1, y: 1, z: 0.5 },
|
|
128
|
-
])
|
|
129
|
-
expect(twoPointsBase64.length).toBe(16)
|
|
130
|
-
|
|
131
|
-
const shape = createHighlightShape([{ type: 'free', points: twoPointsBase64 }])
|
|
132
|
-
const util = editor.getShapeUtil('highlight')
|
|
133
|
-
expect(util.hideResizeHandles(shape)).toBe(false)
|
|
134
|
-
})
|
|
135
|
-
|
|
136
|
-
it('correctly handles the boundary at exactly 8 base64 characters (1 point)', () => {
|
|
137
|
-
// 1 point = 8 characters, which should be a dot
|
|
138
|
-
const onePointBase64 = pointsToBase64([{ x: 0, y: 0, z: 0.5 }])
|
|
139
|
-
expect(onePointBase64.length).toBe(8)
|
|
140
|
-
|
|
141
|
-
const shape = createHighlightShape([{ type: 'free', points: onePointBase64 }])
|
|
142
|
-
const util = editor.getShapeUtil('highlight')
|
|
143
|
-
expect(util.hideResizeHandles(shape)).toBe(true)
|
|
144
|
-
})
|
|
145
|
-
})
|
|
146
|
-
})
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { useEditor, useValue } from '@tldraw/editor'
|
|
2
|
-
|
|
3
|
-
/** Returns true when zoomed out far enough that shapes should render in a simplified "solid" style. */
|
|
4
|
-
export function useEfficientZoomThreshold(threshold = 0.25) {
|
|
5
|
-
const editor = useEditor()
|
|
6
|
-
return useValue('efficient zoom threshold', () => editor.getEfficientZoomLevel() < threshold, [
|
|
7
|
-
editor,
|
|
8
|
-
threshold,
|
|
9
|
-
])
|
|
10
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import type { TLDrawShapeSegment, VecModel } from '@tldraw/editor'
|
|
2
|
-
import { b64Vecs, compressLegacySegments } from '@tldraw/editor'
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Helper function to convert draw shape points from VecModel[] to base64 string.
|
|
6
|
-
* This is useful for tests that create draw shapes with the legacy array format.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```ts
|
|
10
|
-
* const segments = [{ type: 'free', points: pointsToBase64([{x: 0, y: 0, z: 0.5}]) }]
|
|
11
|
-
* ```
|
|
12
|
-
*
|
|
13
|
-
* @public
|
|
14
|
-
*/
|
|
15
|
-
export function pointsToBase64(points: VecModel[]): string {
|
|
16
|
-
return b64Vecs.encodePoints(points)
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Helper function to convert base64 string back to VecModel[] points.
|
|
21
|
-
* This is useful for tests that need to inspect draw shape points.
|
|
22
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
* ```ts
|
|
25
|
-
* const points = base64ToPoints(shape.props.segments[0].points)
|
|
26
|
-
* expect(points[0].x).toBe(0)
|
|
27
|
-
* ```
|
|
28
|
-
*
|
|
29
|
-
* @public
|
|
30
|
-
*/
|
|
31
|
-
export function base64ToPoints(base64: string): VecModel[] {
|
|
32
|
-
return b64Vecs.decodePoints(base64)
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Helper function to create draw shape segments from legacy array format.
|
|
37
|
-
* This allows tests to use the old format while the shape uses the new base64 format.
|
|
38
|
-
*
|
|
39
|
-
* @example
|
|
40
|
-
* ```ts
|
|
41
|
-
* editor.createShapes([{
|
|
42
|
-
* type: 'draw',
|
|
43
|
-
* props: {
|
|
44
|
-
* segments: createDrawSegments([[{x: 0, y: 0}, {x: 10, y: 10}]])
|
|
45
|
-
* }
|
|
46
|
-
* }])
|
|
47
|
-
* ```
|
|
48
|
-
* @public
|
|
49
|
-
*/
|
|
50
|
-
export function createDrawSegments(
|
|
51
|
-
pointArrays: VecModel[][],
|
|
52
|
-
type: 'free' | 'straight' = 'free'
|
|
53
|
-
): TLDrawShapeSegment[] {
|
|
54
|
-
return compressLegacySegments(
|
|
55
|
-
pointArrays.map((points) => ({
|
|
56
|
-
type,
|
|
57
|
-
points,
|
|
58
|
-
}))
|
|
59
|
-
)
|
|
60
|
-
}
|
|
@@ -1,299 +0,0 @@
|
|
|
1
|
-
import { Box } from '@tldraw/editor'
|
|
2
|
-
import { TestEditor } from '../TestEditor'
|
|
3
|
-
|
|
4
|
-
let editor: TestEditor
|
|
5
|
-
|
|
6
|
-
beforeEach(() => {
|
|
7
|
-
editor = new TestEditor()
|
|
8
|
-
editor.updateViewportScreenBounds(new Box(0, 0, 1600, 900))
|
|
9
|
-
})
|
|
10
|
-
|
|
11
|
-
describe('getCameraState', () => {
|
|
12
|
-
it('starts as idle', () => {
|
|
13
|
-
expect(editor.getCameraState()).toBe('idle')
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
it('becomes moving when the camera changes via setCamera', () => {
|
|
17
|
-
expect(editor.getCameraState()).toBe('idle')
|
|
18
|
-
editor.setCamera({ x: 100, y: 100, z: 1 })
|
|
19
|
-
expect(editor.getCameraState()).toBe('moving')
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
it('becomes moving when the camera changes via pan', () => {
|
|
23
|
-
expect(editor.getCameraState()).toBe('idle')
|
|
24
|
-
editor.pan({ x: 100, y: 100 })
|
|
25
|
-
expect(editor.getCameraState()).toBe('moving')
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
it('becomes moving when the camera changes via zoomIn', () => {
|
|
29
|
-
expect(editor.getCameraState()).toBe('idle')
|
|
30
|
-
editor.zoomIn(undefined, { immediate: true })
|
|
31
|
-
expect(editor.getCameraState()).toBe('moving')
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
it('returns to idle after the timeout elapses', () => {
|
|
35
|
-
expect(editor.getCameraState()).toBe('idle')
|
|
36
|
-
editor.setCamera({ x: 100, y: 100, z: 1 })
|
|
37
|
-
expect(editor.getCameraState()).toBe('moving')
|
|
38
|
-
|
|
39
|
-
// The default timeout is 64ms (options.cameraMovingTimeoutMs)
|
|
40
|
-
// Each tick is 16ms, so we need ~4 ticks to elapse
|
|
41
|
-
editor.forceTick(5)
|
|
42
|
-
expect(editor.getCameraState()).toBe('idle')
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
it('stays moving while camera continues to change', () => {
|
|
46
|
-
expect(editor.getCameraState()).toBe('idle')
|
|
47
|
-
editor.setCamera({ x: 100, y: 100, z: 1 })
|
|
48
|
-
expect(editor.getCameraState()).toBe('moving')
|
|
49
|
-
|
|
50
|
-
// Move again before timeout elapses
|
|
51
|
-
editor.forceTick(2)
|
|
52
|
-
editor.setCamera({ x: 200, y: 200, z: 1 })
|
|
53
|
-
expect(editor.getCameraState()).toBe('moving')
|
|
54
|
-
|
|
55
|
-
// Move again
|
|
56
|
-
editor.forceTick(2)
|
|
57
|
-
editor.setCamera({ x: 300, y: 300, z: 1 })
|
|
58
|
-
expect(editor.getCameraState()).toBe('moving')
|
|
59
|
-
|
|
60
|
-
// Now let it settle
|
|
61
|
-
editor.forceTick(5)
|
|
62
|
-
expect(editor.getCameraState()).toBe('idle')
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
it('stays idle when camera position does not actually change', () => {
|
|
66
|
-
expect(editor.getCameraState()).toBe('idle')
|
|
67
|
-
|
|
68
|
-
// Setting the same camera position should not trigger moving state
|
|
69
|
-
const currentCamera = editor.getCamera()
|
|
70
|
-
editor.setCamera({ x: currentCamera.x, y: currentCamera.y, z: currentCamera.z })
|
|
71
|
-
expect(editor.getCameraState()).toBe('idle')
|
|
72
|
-
})
|
|
73
|
-
|
|
74
|
-
it('does not add multiple tick listeners when camera changes rapidly', () => {
|
|
75
|
-
// This test verifies the fix: we should not have redundant listeners
|
|
76
|
-
expect(editor.getCameraState()).toBe('idle')
|
|
77
|
-
|
|
78
|
-
// Change camera multiple times rapidly
|
|
79
|
-
editor.setCamera({ x: 100, y: 100, z: 1 })
|
|
80
|
-
editor.setCamera({ x: 200, y: 200, z: 1 })
|
|
81
|
-
editor.setCamera({ x: 300, y: 300, z: 1 })
|
|
82
|
-
|
|
83
|
-
expect(editor.getCameraState()).toBe('moving')
|
|
84
|
-
|
|
85
|
-
// After timeout, should return to idle exactly once
|
|
86
|
-
// If there were multiple listeners, the state might behave unexpectedly
|
|
87
|
-
editor.forceTick(5)
|
|
88
|
-
expect(editor.getCameraState()).toBe('idle')
|
|
89
|
-
})
|
|
90
|
-
|
|
91
|
-
it('resets timeout when camera changes while already moving', () => {
|
|
92
|
-
expect(editor.getCameraState()).toBe('idle')
|
|
93
|
-
editor.setCamera({ x: 100, y: 100, z: 1 })
|
|
94
|
-
expect(editor.getCameraState()).toBe('moving')
|
|
95
|
-
|
|
96
|
-
// Wait almost until timeout
|
|
97
|
-
editor.forceTick(3)
|
|
98
|
-
expect(editor.getCameraState()).toBe('moving')
|
|
99
|
-
|
|
100
|
-
// Change camera again - should reset timeout
|
|
101
|
-
editor.setCamera({ x: 200, y: 200, z: 1 })
|
|
102
|
-
expect(editor.getCameraState()).toBe('moving')
|
|
103
|
-
|
|
104
|
-
// Wait 3 more ticks - would have been idle if timeout wasn't reset
|
|
105
|
-
editor.forceTick(3)
|
|
106
|
-
expect(editor.getCameraState()).toBe('moving')
|
|
107
|
-
|
|
108
|
-
// Now let it fully settle
|
|
109
|
-
editor.forceTick(3)
|
|
110
|
-
expect(editor.getCameraState()).toBe('idle')
|
|
111
|
-
})
|
|
112
|
-
})
|
|
113
|
-
|
|
114
|
-
describe('camera state with zoom', () => {
|
|
115
|
-
it('becomes moving on zoomOut', () => {
|
|
116
|
-
expect(editor.getCameraState()).toBe('idle')
|
|
117
|
-
editor.zoomOut(undefined, { immediate: true })
|
|
118
|
-
expect(editor.getCameraState()).toBe('moving')
|
|
119
|
-
})
|
|
120
|
-
|
|
121
|
-
it('becomes moving on centerOnPoint', () => {
|
|
122
|
-
expect(editor.getCameraState()).toBe('idle')
|
|
123
|
-
editor.centerOnPoint({ x: 500, y: 500 })
|
|
124
|
-
expect(editor.getCameraState()).toBe('moving')
|
|
125
|
-
})
|
|
126
|
-
|
|
127
|
-
it('becomes moving on zoomToFit', () => {
|
|
128
|
-
// Create a shape so zoomToFit has something to fit
|
|
129
|
-
editor.createShape({ type: 'geo', x: 100, y: 100, props: { w: 200, h: 200 } })
|
|
130
|
-
expect(editor.getCameraState()).toBe('idle')
|
|
131
|
-
editor.zoomToFit({ immediate: true })
|
|
132
|
-
expect(editor.getCameraState()).toBe('moving')
|
|
133
|
-
})
|
|
134
|
-
})
|
|
135
|
-
|
|
136
|
-
describe('getDebouncedZoomLevel', () => {
|
|
137
|
-
it('returns the current zoom level when camera is idle', () => {
|
|
138
|
-
expect(editor.getCameraState()).toBe('idle')
|
|
139
|
-
expect(editor.getDebouncedZoomLevel()).toBe(editor.getZoomLevel())
|
|
140
|
-
|
|
141
|
-
// Change zoom and let it settle
|
|
142
|
-
editor.zoomIn(undefined, { immediate: true })
|
|
143
|
-
editor.forceTick(5)
|
|
144
|
-
expect(editor.getCameraState()).toBe('idle')
|
|
145
|
-
expect(editor.getDebouncedZoomLevel()).toBe(editor.getZoomLevel())
|
|
146
|
-
})
|
|
147
|
-
|
|
148
|
-
it('captures zoom when camera starts moving', () => {
|
|
149
|
-
expect(editor.getCameraState()).toBe('idle')
|
|
150
|
-
|
|
151
|
-
// Start zooming - the debounced zoom is captured when movement starts
|
|
152
|
-
editor.zoomIn(undefined, { immediate: true })
|
|
153
|
-
expect(editor.getCameraState()).toBe('moving')
|
|
154
|
-
|
|
155
|
-
// The debounced zoom is captured at the moment movement starts (after first change)
|
|
156
|
-
const capturedZoom = editor.getDebouncedZoomLevel()
|
|
157
|
-
expect(capturedZoom).toBe(editor.getZoomLevel())
|
|
158
|
-
})
|
|
159
|
-
|
|
160
|
-
it('keeps captured zoom during continued camera movement', () => {
|
|
161
|
-
// Start zooming
|
|
162
|
-
editor.zoomIn(undefined, { immediate: true })
|
|
163
|
-
const capturedZoom = editor.getDebouncedZoomLevel()
|
|
164
|
-
expect(editor.getCameraState()).toBe('moving')
|
|
165
|
-
|
|
166
|
-
// Zoom again while still moving - debounced value should stay the same
|
|
167
|
-
editor.zoomIn(undefined, { immediate: true })
|
|
168
|
-
expect(editor.getCameraState()).toBe('moving')
|
|
169
|
-
expect(editor.getDebouncedZoomLevel()).toBe(capturedZoom)
|
|
170
|
-
|
|
171
|
-
// But current zoom should have changed
|
|
172
|
-
expect(editor.getZoomLevel()).not.toBe(capturedZoom)
|
|
173
|
-
})
|
|
174
|
-
|
|
175
|
-
it('updates debounced zoom when camera becomes idle again', () => {
|
|
176
|
-
// Start zooming
|
|
177
|
-
editor.zoomIn(undefined, { immediate: true })
|
|
178
|
-
const capturedZoom = editor.getDebouncedZoomLevel()
|
|
179
|
-
|
|
180
|
-
// Zoom again while moving to change the current zoom
|
|
181
|
-
editor.zoomIn(undefined, { immediate: true })
|
|
182
|
-
expect(editor.getDebouncedZoomLevel()).toBe(capturedZoom)
|
|
183
|
-
|
|
184
|
-
// Let camera settle
|
|
185
|
-
editor.forceTick(5)
|
|
186
|
-
expect(editor.getCameraState()).toBe('idle')
|
|
187
|
-
|
|
188
|
-
// Debounced zoom should now match current zoom
|
|
189
|
-
expect(editor.getDebouncedZoomLevel()).toBe(editor.getZoomLevel())
|
|
190
|
-
})
|
|
191
|
-
|
|
192
|
-
it('captures new zoom at the start of each new movement', () => {
|
|
193
|
-
// First zoom and settle
|
|
194
|
-
editor.zoomIn(undefined, { immediate: true })
|
|
195
|
-
const firstCapturedZoom = editor.getDebouncedZoomLevel()
|
|
196
|
-
editor.forceTick(5)
|
|
197
|
-
expect(editor.getCameraState()).toBe('idle')
|
|
198
|
-
|
|
199
|
-
// Second zoom - should capture new zoom level
|
|
200
|
-
editor.zoomIn(undefined, { immediate: true })
|
|
201
|
-
expect(editor.getCameraState()).toBe('moving')
|
|
202
|
-
// The captured zoom should be different from the first capture
|
|
203
|
-
expect(editor.getDebouncedZoomLevel()).not.toBe(firstCapturedZoom)
|
|
204
|
-
// And it should match the current zoom (since we just started moving)
|
|
205
|
-
expect(editor.getDebouncedZoomLevel()).toBe(editor.getZoomLevel())
|
|
206
|
-
})
|
|
207
|
-
|
|
208
|
-
describe('with debouncedZoom option disabled', () => {
|
|
209
|
-
let editorWithoutDebouncedZoom: TestEditor
|
|
210
|
-
|
|
211
|
-
beforeEach(() => {
|
|
212
|
-
editorWithoutDebouncedZoom = new TestEditor({
|
|
213
|
-
options: { debouncedZoom: false },
|
|
214
|
-
})
|
|
215
|
-
editorWithoutDebouncedZoom.updateViewportScreenBounds(new Box(0, 0, 1600, 900))
|
|
216
|
-
})
|
|
217
|
-
|
|
218
|
-
it('always returns the current zoom level even when camera is moving', () => {
|
|
219
|
-
const initialZoom = editorWithoutDebouncedZoom.getZoomLevel()
|
|
220
|
-
|
|
221
|
-
editorWithoutDebouncedZoom.zoomIn(undefined, { immediate: true })
|
|
222
|
-
expect(editorWithoutDebouncedZoom.getCameraState()).toBe('moving')
|
|
223
|
-
|
|
224
|
-
// Should return the current zoom, not the captured one
|
|
225
|
-
expect(editorWithoutDebouncedZoom.getDebouncedZoomLevel()).toBe(
|
|
226
|
-
editorWithoutDebouncedZoom.getZoomLevel()
|
|
227
|
-
)
|
|
228
|
-
expect(editorWithoutDebouncedZoom.getDebouncedZoomLevel()).not.toBe(initialZoom)
|
|
229
|
-
})
|
|
230
|
-
})
|
|
231
|
-
})
|
|
232
|
-
|
|
233
|
-
describe('getEfficientZoomLevel', () => {
|
|
234
|
-
it('returns current zoom level when below shape threshold', () => {
|
|
235
|
-
// Default threshold is 500 shapes, we have 0
|
|
236
|
-
expect(editor.getZoomLevel()).toBe(editor.getEfficientZoomLevel())
|
|
237
|
-
|
|
238
|
-
// Add a few shapes - still below threshold
|
|
239
|
-
for (let i = 0; i < 10; i++) {
|
|
240
|
-
editor.createShape({ type: 'geo', x: i * 100, y: 0, props: { w: 50, h: 50 } })
|
|
241
|
-
}
|
|
242
|
-
expect(editor.getCurrentPageShapeIds().size).toBe(10)
|
|
243
|
-
|
|
244
|
-
// Start zooming
|
|
245
|
-
editor.zoomIn(undefined, { immediate: true })
|
|
246
|
-
expect(editor.getCameraState()).toBe('moving')
|
|
247
|
-
|
|
248
|
-
// Should still return current zoom because we're below threshold
|
|
249
|
-
expect(editor.getEfficientZoomLevel()).toBe(editor.getZoomLevel())
|
|
250
|
-
})
|
|
251
|
-
|
|
252
|
-
describe('with many shapes above threshold', () => {
|
|
253
|
-
let editorWithManyShapes: TestEditor
|
|
254
|
-
|
|
255
|
-
beforeEach(() => {
|
|
256
|
-
// Use a lower threshold for testing
|
|
257
|
-
editorWithManyShapes = new TestEditor({
|
|
258
|
-
options: { debouncedZoomThreshold: 5 },
|
|
259
|
-
})
|
|
260
|
-
editorWithManyShapes.updateViewportScreenBounds(new Box(0, 0, 1600, 900))
|
|
261
|
-
|
|
262
|
-
// Add shapes above the threshold
|
|
263
|
-
for (let i = 0; i < 10; i++) {
|
|
264
|
-
editorWithManyShapes.createShape({
|
|
265
|
-
type: 'geo',
|
|
266
|
-
x: i * 100,
|
|
267
|
-
y: 0,
|
|
268
|
-
props: { w: 50, h: 50 },
|
|
269
|
-
})
|
|
270
|
-
}
|
|
271
|
-
})
|
|
272
|
-
|
|
273
|
-
it('returns debounced zoom level when above shape threshold and camera is moving', () => {
|
|
274
|
-
// First zoom to capture a debounced value
|
|
275
|
-
editorWithManyShapes.zoomIn(undefined, { immediate: true })
|
|
276
|
-
const capturedZoom = editorWithManyShapes.getEfficientZoomLevel()
|
|
277
|
-
expect(editorWithManyShapes.getCameraState()).toBe('moving')
|
|
278
|
-
|
|
279
|
-
// Zoom again while still moving
|
|
280
|
-
editorWithManyShapes.zoomIn(undefined, { immediate: true })
|
|
281
|
-
expect(editorWithManyShapes.getCameraState()).toBe('moving')
|
|
282
|
-
|
|
283
|
-
// Should return the captured zoom, not the current zoom
|
|
284
|
-
expect(editorWithManyShapes.getEfficientZoomLevel()).toBe(capturedZoom)
|
|
285
|
-
expect(editorWithManyShapes.getEfficientZoomLevel()).not.toBe(
|
|
286
|
-
editorWithManyShapes.getZoomLevel()
|
|
287
|
-
)
|
|
288
|
-
})
|
|
289
|
-
|
|
290
|
-
it('returns current zoom level when above threshold but camera is idle', () => {
|
|
291
|
-
editorWithManyShapes.zoomIn(undefined, { immediate: true })
|
|
292
|
-
editorWithManyShapes.forceTick(5)
|
|
293
|
-
expect(editorWithManyShapes.getCameraState()).toBe('idle')
|
|
294
|
-
|
|
295
|
-
// Should return current zoom because camera is idle
|
|
296
|
-
expect(editorWithManyShapes.getEfficientZoomLevel()).toBe(editorWithManyShapes.getZoomLevel())
|
|
297
|
-
})
|
|
298
|
-
})
|
|
299
|
-
})
|