tldraw 4.3.0-next.f4772c19540d → 4.4.0-canary.1e3b436e33e4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -2
- package/dist-cjs/index.d.ts +311 -242
- package/dist-cjs/index.js +13 -5
- package/dist-cjs/index.js.map +2 -2
- package/dist-cjs/lib/bindings/arrow/ArrowBindingUtil.js.map +2 -2
- package/dist-cjs/lib/canvas/TldrawSelectionForeground.js +2 -2
- package/dist-cjs/lib/canvas/TldrawSelectionForeground.js.map +2 -2
- package/dist-cjs/lib/defaultEmbedDefinitions.js +1 -1
- package/dist-cjs/lib/defaultEmbedDefinitions.js.map +2 -2
- package/dist-cjs/lib/defaultExternalContentHandlers.js +5 -5
- package/dist-cjs/lib/defaultExternalContentHandlers.js.map +2 -2
- package/dist-cjs/lib/defaultSideEffects.js +6 -1
- package/dist-cjs/lib/defaultSideEffects.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js +14 -13
- package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/arrow-types.js.map +1 -1
- package/dist-cjs/lib/shapes/arrow/arrowLabel.js +1 -1
- package/dist-cjs/lib/shapes/arrow/arrowLabel.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/arrowTargetState.js +1 -1
- package/dist-cjs/lib/shapes/arrow/arrowTargetState.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/elbow/elbowArrowSnapLines.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/elbow/getElbowArrowInfo.js +1 -1
- package/dist-cjs/lib/shapes/arrow/elbow/getElbowArrowInfo.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/shared.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/toolStates/Idle.js +4 -10
- package/dist-cjs/lib/shapes/arrow/toolStates/Idle.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.js +7 -4
- package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/shapes/bookmark/BookmarkShapeUtil.js +1 -1
- package/dist-cjs/lib/shapes/bookmark/BookmarkShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/bookmark/bookmarks.js.map +2 -2
- package/dist-cjs/lib/shapes/draw/DrawShapeUtil.js +25 -23
- package/dist-cjs/lib/shapes/draw/DrawShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/draw/getPath.js +20 -11
- package/dist-cjs/lib/shapes/draw/getPath.js.map +2 -2
- package/dist-cjs/lib/shapes/draw/toolStates/Drawing.js +82 -86
- package/dist-cjs/lib/shapes/draw/toolStates/Drawing.js.map +3 -3
- package/dist-cjs/lib/shapes/embed/EmbedShapeUtil.js +6 -0
- package/dist-cjs/lib/shapes/embed/EmbedShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/frame/FrameShapeTool.js.map +1 -1
- package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js +7 -13
- package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/geo/GeoShapeUtil.js +146 -142
- package/dist-cjs/lib/shapes/geo/GeoShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/geo/toolStates/Idle.js +5 -10
- package/dist-cjs/lib/shapes/geo/toolStates/Idle.js.map +2 -2
- package/dist-cjs/lib/shapes/geo/toolStates/Pointing.js +3 -3
- package/dist-cjs/lib/shapes/geo/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/shapes/highlight/HighlightShapeUtil.js +23 -21
- package/dist-cjs/lib/shapes/highlight/HighlightShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/line/toolStates/Pointing.js +3 -3
- package/dist-cjs/lib/shapes/line/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/shapes/note/NoteShapeUtil.js +6 -11
- package/dist-cjs/lib/shapes/note/NoteShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/note/noteHelpers.js.map +2 -2
- package/dist-cjs/lib/shapes/note/toolStates/Pointing.js +5 -10
- package/dist-cjs/lib/shapes/note/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/HyperlinkButton.js +3 -2
- package/dist-cjs/lib/shapes/shared/HyperlinkButton.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/PlainTextLabel.js +14 -2
- package/dist-cjs/lib/shapes/shared/PlainTextLabel.js.map +3 -3
- package/dist-cjs/lib/shapes/shared/RichTextLabel.js +12 -4
- package/dist-cjs/lib/shapes/shared/RichTextLabel.js.map +3 -3
- package/dist-cjs/lib/shapes/shared/ShapeFill.js +2 -2
- package/dist-cjs/lib/shapes/shared/ShapeFill.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/crop.js +1 -0
- package/dist-cjs/lib/shapes/shared/crop.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/interpolate-props.js +3 -3
- package/dist-cjs/lib/shapes/shared/interpolate-props.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/useEditablePlainText.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/useEditableRichText.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/{useForceSolid.js → useEfficientZoomThreshold.js} +10 -7
- package/dist-cjs/lib/shapes/shared/useEfficientZoomThreshold.js.map +7 -0
- package/dist-cjs/lib/shapes/shared/useImageOrVideoAsset.js +1 -1
- package/dist-cjs/lib/shapes/shared/useImageOrVideoAsset.js.map +2 -2
- package/dist-cjs/lib/shapes/text/RichTextArea.js +5 -0
- package/dist-cjs/lib/shapes/text/RichTextArea.js.map +2 -2
- package/dist-cjs/lib/shapes/text/TextShapeUtil.js +5 -2
- package/dist-cjs/lib/shapes/text/TextShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/text/toolStates/Idle.js +4 -10
- package/dist-cjs/lib/shapes/text/toolStates/Idle.js.map +2 -2
- package/dist-cjs/lib/shapes/text/toolStates/Pointing.js +7 -5
- package/dist-cjs/lib/shapes/text/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/shapes/video/VideoShapeUtil.js +1 -1
- package/dist-cjs/lib/shapes/video/VideoShapeUtil.js.map +2 -2
- package/dist-cjs/lib/tools/EraserTool/childStates/Erasing.js +12 -6
- package/dist-cjs/lib/tools/EraserTool/childStates/Erasing.js.map +2 -2
- package/dist-cjs/lib/tools/EraserTool/childStates/Pointing.js +2 -4
- package/dist-cjs/lib/tools/EraserTool/childStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/tools/HandTool/HandTool.js +3 -5
- package/dist-cjs/lib/tools/HandTool/HandTool.js.map +2 -2
- package/dist-cjs/lib/tools/HandTool/childStates/Dragging.js +3 -2
- package/dist-cjs/lib/tools/HandTool/childStates/Dragging.js.map +2 -2
- package/dist-cjs/lib/tools/HandTool/childStates/Pointing.js +1 -1
- package/dist-cjs/lib/tools/HandTool/childStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/tools/LaserTool/childStates/Lasering.js +1 -1
- package/dist-cjs/lib/tools/LaserTool/childStates/Lasering.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/DragAndDropManager.js +10 -11
- package/dist-cjs/lib/tools/SelectTool/DragAndDropManager.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Brushing.js +20 -6
- package/dist-cjs/lib/tools/SelectTool/childStates/Brushing.js.map +3 -3
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/Cropping.js +4 -6
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/Cropping.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/Idle.js +1 -1
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/Idle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.js +1 -1
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/PointingCropHandle.js +1 -1
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/PointingCropHandle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.js +2 -1
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.js +1 -1
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js +8 -6
- package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/EditingShape.js +38 -11
- package/dist-cjs/lib/tools/SelectTool/childStates/EditingShape.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Idle.js +42 -50
- package/dist-cjs/lib/tools/SelectTool/childStates/Idle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingArrowLabel.js +6 -6
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingArrowLabel.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingCanvas.js +1 -1
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingCanvas.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingHandle.js +4 -14
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingHandle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingResizeHandle.js +1 -1
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingResizeHandle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingRotateHandle.js +1 -1
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingRotateHandle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingSelection.js +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingSelection.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingShape.js +4 -13
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingShape.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js +5 -6
- package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Rotating.js +2 -3
- package/dist-cjs/lib/tools/SelectTool/childStates/Rotating.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/ScribbleBrushing.js +22 -8
- package/dist-cjs/lib/tools/SelectTool/childStates/ScribbleBrushing.js.map +3 -3
- package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js +13 -11
- package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/selectHelpers.js +15 -4
- package/dist-cjs/lib/tools/SelectTool/selectHelpers.js.map +2 -2
- package/dist-cjs/lib/tools/ZoomTool/ZoomTool.js +1 -1
- package/dist-cjs/lib/tools/ZoomTool/ZoomTool.js.map +2 -2
- package/dist-cjs/lib/tools/ZoomTool/childStates/Pointing.js +3 -3
- package/dist-cjs/lib/tools/ZoomTool/childStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/tools/ZoomTool/childStates/ZoomBrushing.js +5 -6
- package/dist-cjs/lib/tools/ZoomTool/childStates/ZoomBrushing.js.map +2 -2
- package/dist-cjs/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.js +1 -3
- package/dist-cjs/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.js.map +2 -2
- package/dist-cjs/lib/tools/selection-logic/selectOnCanvasPointerUp.js +1 -1
- package/dist-cjs/lib/tools/selection-logic/selectOnCanvasPointerUp.js.map +2 -2
- package/dist-cjs/lib/tools/selection-logic/updateHoveredShapeId.js +1 -1
- package/dist-cjs/lib/tools/selection-logic/updateHoveredShapeId.js.map +2 -2
- package/dist-cjs/lib/ui/TldrawUi.js +2 -2
- package/dist-cjs/lib/ui/TldrawUi.js.map +2 -2
- package/dist-cjs/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.js +3 -9
- package/dist-cjs/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.js.map +2 -2
- package/dist-cjs/lib/ui/components/ContextMenu/DefaultContextMenu.js +1 -3
- package/dist-cjs/lib/ui/components/ContextMenu/DefaultContextMenu.js.map +2 -2
- package/dist-cjs/lib/ui/components/CursorChatBubble.js +1 -1
- package/dist-cjs/lib/ui/components/CursorChatBubble.js.map +2 -2
- package/dist-cjs/lib/ui/components/DefaultDebugPanel.js +2 -22
- package/dist-cjs/lib/ui/components/DefaultDebugPanel.js.map +2 -2
- package/dist-cjs/lib/ui/components/EditLinkDialog.js +11 -1
- package/dist-cjs/lib/ui/components/EditLinkDialog.js.map +2 -2
- package/dist-cjs/lib/ui/components/HelperButtons/BackToContent.js +1 -1
- package/dist-cjs/lib/ui/components/HelperButtons/BackToContent.js.map +2 -2
- package/dist-cjs/lib/ui/components/HelperButtons/StopFollowing.js.map +2 -2
- package/dist-cjs/lib/ui/components/Minimap/DefaultMinimap.js +1 -1
- package/dist-cjs/lib/ui/components/Minimap/DefaultMinimap.js.map +2 -2
- package/dist-cjs/lib/ui/components/OfflineIndicator/OfflineIndicator.js +2 -15
- package/dist-cjs/lib/ui/components/OfflineIndicator/OfflineIndicator.js.map +3 -3
- package/dist-cjs/lib/ui/components/PageMenu/PageItemInput.js +3 -1
- package/dist-cjs/lib/ui/components/PageMenu/PageItemInput.js.map +2 -2
- package/dist-cjs/lib/ui/components/SharePanel/PeopleMenu.js +6 -0
- package/dist-cjs/lib/ui/components/SharePanel/PeopleMenu.js.map +2 -2
- package/dist-cjs/lib/ui/components/Toolbar/AltTextEditor.js.map +2 -2
- package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbar.js +1 -1
- package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbar.js.map +2 -2
- package/dist-cjs/lib/ui/components/Toolbar/DefaultRichTextToolbar.js +1 -1
- package/dist-cjs/lib/ui/components/Toolbar/DefaultRichTextToolbar.js.map +2 -2
- package/dist-cjs/lib/ui/components/TopPanel/CenteredTopPanelContainer.js.map +1 -1
- package/dist-cjs/lib/ui/components/menu-items.js +3 -1
- package/dist-cjs/lib/ui/components/menu-items.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiContextualToolbar.js +3 -1
- package/dist-cjs/lib/ui/components/primitives/TldrawUiContextualToolbar.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiSlider.js +1 -1
- package/dist-cjs/lib/ui/components/primitives/TldrawUiSlider.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js +149 -93
- package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuActionCheckboxItem.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuActionItem.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js +14 -7
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js.map +2 -2
- package/dist-cjs/lib/ui/context/actions.js +7 -8
- package/dist-cjs/lib/ui/context/actions.js.map +2 -2
- package/dist-cjs/lib/ui/context/components.js +1 -2
- package/dist-cjs/lib/ui/context/components.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/menu-hooks.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/useClipboardEvents.js +2 -2
- package/dist-cjs/lib/ui/hooks/useClipboardEvents.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/useFlatten.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/useKeyboardShortcuts.js +2 -2
- package/dist-cjs/lib/ui/hooks/useKeyboardShortcuts.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/useTools.js +4 -5
- package/dist-cjs/lib/ui/hooks/useTools.js.map +2 -2
- package/dist-cjs/lib/ui/version.js +3 -3
- package/dist-cjs/lib/ui/version.js.map +1 -1
- package/dist-cjs/lib/utils/excalidraw/putExcalidrawContent.js +16 -6
- package/dist-cjs/lib/utils/excalidraw/putExcalidrawContent.js.map +2 -2
- package/dist-cjs/lib/utils/export/exportAs.js.map +2 -2
- package/dist-cjs/lib/utils/frames/frames.js.map +2 -2
- package/dist-cjs/lib/{tools/selection-logic/getShouldEnterCropModeOnPointerDown.js → utils/test-helpers.js} +21 -8
- package/dist-cjs/lib/utils/test-helpers.js.map +7 -0
- package/dist-cjs/lib/utils/text/richText.js +15 -19
- package/dist-cjs/lib/utils/text/richText.js.map +3 -3
- package/dist-cjs/lib/utils/tldr/buildFromV1Document.js +7 -2
- package/dist-cjs/lib/utils/tldr/buildFromV1Document.js.map +2 -2
- package/dist-esm/index.d.mts +311 -242
- package/dist-esm/index.mjs +14 -5
- package/dist-esm/index.mjs.map +2 -2
- package/dist-esm/lib/bindings/arrow/ArrowBindingUtil.mjs.map +2 -2
- package/dist-esm/lib/canvas/TldrawSelectionForeground.mjs +2 -2
- package/dist-esm/lib/canvas/TldrawSelectionForeground.mjs.map +2 -2
- package/dist-esm/lib/defaultEmbedDefinitions.mjs +1 -1
- package/dist-esm/lib/defaultEmbedDefinitions.mjs.map +2 -2
- package/dist-esm/lib/defaultExternalContentHandlers.mjs +5 -5
- package/dist-esm/lib/defaultExternalContentHandlers.mjs.map +2 -2
- package/dist-esm/lib/defaultSideEffects.mjs +6 -1
- package/dist-esm/lib/defaultSideEffects.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs +15 -15
- package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/arrowLabel.mjs +1 -1
- package/dist-esm/lib/shapes/arrow/arrowLabel.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/arrowTargetState.mjs +1 -1
- package/dist-esm/lib/shapes/arrow/arrowTargetState.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/elbow/elbowArrowSnapLines.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/elbow/getElbowArrowInfo.mjs +1 -1
- package/dist-esm/lib/shapes/arrow/elbow/getElbowArrowInfo.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/shared.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/toolStates/Idle.mjs +4 -10
- package/dist-esm/lib/shapes/arrow/toolStates/Idle.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs +7 -4
- package/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/shapes/bookmark/BookmarkShapeUtil.mjs +1 -1
- package/dist-esm/lib/shapes/bookmark/BookmarkShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/bookmark/bookmarks.mjs.map +2 -2
- package/dist-esm/lib/shapes/draw/DrawShapeUtil.mjs +30 -25
- package/dist-esm/lib/shapes/draw/DrawShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/draw/getPath.mjs +21 -11
- package/dist-esm/lib/shapes/draw/getPath.mjs.map +2 -2
- package/dist-esm/lib/shapes/draw/toolStates/Drawing.mjs +83 -86
- package/dist-esm/lib/shapes/draw/toolStates/Drawing.mjs.map +3 -3
- package/dist-esm/lib/shapes/embed/EmbedShapeUtil.mjs +6 -0
- package/dist-esm/lib/shapes/embed/EmbedShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/frame/FrameShapeTool.mjs.map +1 -1
- package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs +7 -13
- package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/geo/GeoShapeUtil.mjs +147 -142
- package/dist-esm/lib/shapes/geo/GeoShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/geo/toolStates/Idle.mjs +5 -10
- package/dist-esm/lib/shapes/geo/toolStates/Idle.mjs.map +2 -2
- package/dist-esm/lib/shapes/geo/toolStates/Pointing.mjs +3 -3
- package/dist-esm/lib/shapes/geo/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/shapes/highlight/HighlightShapeUtil.mjs +24 -22
- package/dist-esm/lib/shapes/highlight/HighlightShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/line/toolStates/Pointing.mjs +3 -3
- package/dist-esm/lib/shapes/line/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs +7 -12
- package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/note/noteHelpers.mjs.map +2 -2
- package/dist-esm/lib/shapes/note/toolStates/Pointing.mjs +5 -10
- package/dist-esm/lib/shapes/note/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/HyperlinkButton.mjs +4 -3
- package/dist-esm/lib/shapes/shared/HyperlinkButton.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/PlainTextLabel.mjs +14 -2
- package/dist-esm/lib/shapes/shared/PlainTextLabel.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/RichTextLabel.mjs +12 -4
- package/dist-esm/lib/shapes/shared/RichTextLabel.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/ShapeFill.mjs +2 -2
- package/dist-esm/lib/shapes/shared/ShapeFill.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/crop.mjs +1 -0
- package/dist-esm/lib/shapes/shared/crop.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/interpolate-props.mjs +4 -4
- package/dist-esm/lib/shapes/shared/interpolate-props.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/useEditablePlainText.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/useEditableRichText.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/useEfficientZoomThreshold.mjs +12 -0
- package/dist-esm/lib/shapes/shared/useEfficientZoomThreshold.mjs.map +7 -0
- package/dist-esm/lib/shapes/shared/useImageOrVideoAsset.mjs +1 -1
- package/dist-esm/lib/shapes/shared/useImageOrVideoAsset.mjs.map +2 -2
- package/dist-esm/lib/shapes/text/RichTextArea.mjs +5 -0
- package/dist-esm/lib/shapes/text/RichTextArea.mjs.map +2 -2
- package/dist-esm/lib/shapes/text/TextShapeUtil.mjs +5 -2
- package/dist-esm/lib/shapes/text/TextShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/text/toolStates/Idle.mjs +4 -10
- package/dist-esm/lib/shapes/text/toolStates/Idle.mjs.map +2 -2
- package/dist-esm/lib/shapes/text/toolStates/Pointing.mjs +7 -5
- package/dist-esm/lib/shapes/text/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/shapes/video/VideoShapeUtil.mjs +1 -1
- package/dist-esm/lib/shapes/video/VideoShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/tools/EraserTool/childStates/Erasing.mjs +13 -6
- package/dist-esm/lib/tools/EraserTool/childStates/Erasing.mjs.map +2 -2
- package/dist-esm/lib/tools/EraserTool/childStates/Pointing.mjs +3 -8
- package/dist-esm/lib/tools/EraserTool/childStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/tools/HandTool/HandTool.mjs +3 -5
- package/dist-esm/lib/tools/HandTool/HandTool.mjs.map +2 -2
- package/dist-esm/lib/tools/HandTool/childStates/Dragging.mjs +3 -2
- package/dist-esm/lib/tools/HandTool/childStates/Dragging.mjs.map +2 -2
- package/dist-esm/lib/tools/HandTool/childStates/Pointing.mjs +1 -1
- package/dist-esm/lib/tools/HandTool/childStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/tools/LaserTool/childStates/Lasering.mjs +1 -1
- package/dist-esm/lib/tools/LaserTool/childStates/Lasering.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/DragAndDropManager.mjs +10 -11
- package/dist-esm/lib/tools/SelectTool/DragAndDropManager.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Brushing.mjs +20 -6
- package/dist-esm/lib/tools/SelectTool/childStates/Brushing.mjs.map +3 -3
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/Cropping.mjs +4 -6
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/Cropping.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/Idle.mjs +1 -1
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/Idle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.mjs +1 -1
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCropHandle.mjs +1 -1
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCropHandle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.mjs +2 -1
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.mjs +1 -1
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs +8 -6
- package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/EditingShape.mjs +38 -11
- package/dist-esm/lib/tools/SelectTool/childStates/EditingShape.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Idle.mjs +43 -51
- package/dist-esm/lib/tools/SelectTool/childStates/Idle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingArrowLabel.mjs +6 -6
- package/dist-esm/lib/tools/SelectTool/childStates/PointingArrowLabel.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingCanvas.mjs +1 -1
- package/dist-esm/lib/tools/SelectTool/childStates/PointingCanvas.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingHandle.mjs +6 -19
- package/dist-esm/lib/tools/SelectTool/childStates/PointingHandle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingResizeHandle.mjs +1 -1
- package/dist-esm/lib/tools/SelectTool/childStates/PointingResizeHandle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingRotateHandle.mjs +1 -1
- package/dist-esm/lib/tools/SelectTool/childStates/PointingRotateHandle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingSelection.mjs +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingSelection.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingShape.mjs +4 -13
- package/dist-esm/lib/tools/SelectTool/childStates/PointingShape.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs +5 -6
- package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Rotating.mjs +2 -3
- package/dist-esm/lib/tools/SelectTool/childStates/Rotating.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/ScribbleBrushing.mjs +23 -8
- package/dist-esm/lib/tools/SelectTool/childStates/ScribbleBrushing.mjs.map +3 -3
- package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs +13 -11
- package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/selectHelpers.mjs +17 -4
- package/dist-esm/lib/tools/SelectTool/selectHelpers.mjs.map +2 -2
- package/dist-esm/lib/tools/ZoomTool/ZoomTool.mjs +1 -1
- package/dist-esm/lib/tools/ZoomTool/ZoomTool.mjs.map +2 -2
- package/dist-esm/lib/tools/ZoomTool/childStates/Pointing.mjs +3 -3
- package/dist-esm/lib/tools/ZoomTool/childStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/tools/ZoomTool/childStates/ZoomBrushing.mjs +5 -6
- package/dist-esm/lib/tools/ZoomTool/childStates/ZoomBrushing.mjs.map +2 -2
- package/dist-esm/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.mjs +1 -3
- package/dist-esm/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.mjs.map +2 -2
- package/dist-esm/lib/tools/selection-logic/selectOnCanvasPointerUp.mjs +1 -1
- package/dist-esm/lib/tools/selection-logic/selectOnCanvasPointerUp.mjs.map +2 -2
- package/dist-esm/lib/tools/selection-logic/updateHoveredShapeId.mjs +1 -1
- package/dist-esm/lib/tools/selection-logic/updateHoveredShapeId.mjs.map +2 -2
- package/dist-esm/lib/ui/TldrawUi.mjs +2 -2
- package/dist-esm/lib/ui/TldrawUi.mjs.map +2 -2
- package/dist-esm/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.mjs +2 -8
- package/dist-esm/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.mjs.map +2 -2
- package/dist-esm/lib/ui/components/ContextMenu/DefaultContextMenu.mjs +1 -3
- package/dist-esm/lib/ui/components/ContextMenu/DefaultContextMenu.mjs.map +2 -2
- package/dist-esm/lib/ui/components/CursorChatBubble.mjs +1 -1
- package/dist-esm/lib/ui/components/CursorChatBubble.mjs.map +2 -2
- package/dist-esm/lib/ui/components/DefaultDebugPanel.mjs +4 -31
- package/dist-esm/lib/ui/components/DefaultDebugPanel.mjs.map +2 -2
- package/dist-esm/lib/ui/components/EditLinkDialog.mjs +11 -1
- package/dist-esm/lib/ui/components/EditLinkDialog.mjs.map +2 -2
- package/dist-esm/lib/ui/components/HelperButtons/BackToContent.mjs +1 -1
- package/dist-esm/lib/ui/components/HelperButtons/BackToContent.mjs.map +2 -2
- package/dist-esm/lib/ui/components/HelperButtons/StopFollowing.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Minimap/DefaultMinimap.mjs +1 -1
- package/dist-esm/lib/ui/components/Minimap/DefaultMinimap.mjs.map +2 -2
- package/dist-esm/lib/ui/components/OfflineIndicator/OfflineIndicator.mjs +3 -6
- package/dist-esm/lib/ui/components/OfflineIndicator/OfflineIndicator.mjs.map +2 -2
- package/dist-esm/lib/ui/components/PageMenu/PageItemInput.mjs +3 -1
- package/dist-esm/lib/ui/components/PageMenu/PageItemInput.mjs.map +2 -2
- package/dist-esm/lib/ui/components/SharePanel/PeopleMenu.mjs +6 -0
- package/dist-esm/lib/ui/components/SharePanel/PeopleMenu.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Toolbar/AltTextEditor.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbar.mjs +1 -1
- package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbar.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Toolbar/DefaultRichTextToolbar.mjs +1 -1
- package/dist-esm/lib/ui/components/Toolbar/DefaultRichTextToolbar.mjs.map +2 -2
- package/dist-esm/lib/ui/components/TopPanel/CenteredTopPanelContainer.mjs.map +1 -1
- package/dist-esm/lib/ui/components/menu-items.mjs +4 -5
- package/dist-esm/lib/ui/components/menu-items.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiContextualToolbar.mjs +3 -1
- package/dist-esm/lib/ui/components/primitives/TldrawUiContextualToolbar.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiSlider.mjs +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiSlider.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs +157 -95
- package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuActionCheckboxItem.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuActionItem.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs +15 -8
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs.map +2 -2
- package/dist-esm/lib/ui/context/actions.mjs +7 -8
- package/dist-esm/lib/ui/context/actions.mjs.map +2 -2
- package/dist-esm/lib/ui/context/components.mjs +1 -2
- package/dist-esm/lib/ui/context/components.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/menu-hooks.mjs +1 -4
- package/dist-esm/lib/ui/hooks/menu-hooks.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/useClipboardEvents.mjs +2 -2
- package/dist-esm/lib/ui/hooks/useClipboardEvents.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/useFlatten.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/useKeyboardShortcuts.mjs +2 -2
- package/dist-esm/lib/ui/hooks/useKeyboardShortcuts.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/useTools.mjs +4 -5
- package/dist-esm/lib/ui/hooks/useTools.mjs.map +2 -2
- package/dist-esm/lib/ui/version.mjs +3 -3
- package/dist-esm/lib/ui/version.mjs.map +1 -1
- package/dist-esm/lib/utils/excalidraw/putExcalidrawContent.mjs +17 -6
- package/dist-esm/lib/utils/excalidraw/putExcalidrawContent.mjs.map +2 -2
- package/dist-esm/lib/utils/export/exportAs.mjs +1 -3
- package/dist-esm/lib/utils/export/exportAs.mjs.map +2 -2
- package/dist-esm/lib/utils/frames/frames.mjs.map +2 -2
- package/dist-esm/lib/utils/test-helpers.mjs +21 -0
- package/dist-esm/lib/utils/test-helpers.mjs.map +7 -0
- package/dist-esm/lib/utils/text/richText.mjs +12 -5
- package/dist-esm/lib/utils/text/richText.mjs.map +2 -2
- package/dist-esm/lib/utils/tldr/buildFromV1Document.mjs +8 -2
- package/dist-esm/lib/utils/tldr/buildFromV1Document.mjs.map +2 -2
- package/package.json +18 -16
- package/src/index.ts +6 -2
- package/src/lib/Tldraw.test.tsx +46 -1
- package/src/lib/bindings/arrow/ArrowBindingUtil.ts +1 -1
- package/src/lib/canvas/TldrawSelectionForeground.tsx +6 -11
- package/src/lib/defaultEmbedDefinitions.ts +2 -1
- package/src/lib/defaultExternalContentHandlers.ts +13 -14
- package/src/lib/defaultSideEffects.ts +6 -1
- package/src/lib/shapes/arrow/ArrowShapeOptions.test.ts +40 -133
- package/src/lib/shapes/arrow/ArrowShapeTool.test.ts +8 -8
- package/src/lib/shapes/arrow/ArrowShapeUtil.test.ts +2 -2
- package/src/lib/shapes/arrow/ArrowShapeUtil.tsx +16 -16
- package/src/lib/shapes/arrow/arrow-types.ts +2 -0
- package/src/lib/shapes/arrow/arrowLabel.ts +2 -2
- package/src/lib/shapes/arrow/arrowTargetState.ts +2 -2
- package/src/lib/shapes/arrow/elbow/elbowArrowSnapLines.tsx +3 -3
- package/src/lib/shapes/arrow/elbow/getElbowArrowInfo.test.ts +80 -0
- package/src/lib/shapes/arrow/elbow/getElbowArrowInfo.tsx +1 -1
- package/src/lib/shapes/arrow/shared.ts +4 -4
- package/src/lib/shapes/arrow/toolStates/Idle.tsx +4 -14
- package/src/lib/shapes/arrow/toolStates/Pointing.tsx +8 -5
- package/src/lib/shapes/bookmark/BookmarkShapeUtil.tsx +1 -1
- package/src/lib/shapes/bookmark/bookmarks.ts +3 -3
- package/src/lib/shapes/draw/DrawShapeUtil.test.ts +146 -0
- package/src/lib/shapes/draw/DrawShapeUtil.tsx +33 -27
- package/src/lib/shapes/draw/getPath.ts +31 -10
- package/src/lib/shapes/draw/toolStates/Drawing.ts +100 -90
- package/src/lib/shapes/embed/EmbedShapeUtil.tsx +8 -1
- package/src/lib/shapes/frame/FrameShapeTool.ts +1 -1
- package/src/lib/shapes/frame/FrameShapeUtil.tsx +11 -11
- package/src/lib/shapes/geo/GeoShapeUtil.test.tsx +10 -2
- package/src/lib/shapes/geo/GeoShapeUtil.tsx +228 -176
- package/src/lib/shapes/geo/toolStates/Idle.ts +5 -15
- package/src/lib/shapes/geo/toolStates/Pointing.ts +6 -6
- package/src/lib/shapes/highlight/HighlightShapeUtil.test.ts +146 -0
- package/src/lib/shapes/highlight/HighlightShapeUtil.tsx +27 -24
- package/src/lib/shapes/line/LineShapeTool.test.ts +6 -6
- package/src/lib/shapes/line/LineShapeUtil.test.tsx +5 -5
- package/src/lib/shapes/line/toolStates/Pointing.ts +4 -4
- package/src/lib/shapes/note/NoteShapeTool.test.ts +2 -1
- package/src/lib/shapes/note/NoteShapeUtil.tsx +9 -10
- package/src/lib/shapes/note/noteCloning.test.ts +3 -1
- package/src/lib/shapes/note/noteHelpers.ts +2 -2
- package/src/lib/shapes/note/toolStates/Pointing.ts +5 -10
- package/src/lib/shapes/shared/HyperlinkButton.tsx +4 -3
- package/src/lib/shapes/shared/PlainTextLabel.tsx +12 -2
- package/src/lib/shapes/shared/RichTextLabel.tsx +14 -4
- package/src/lib/shapes/shared/ShapeFill.tsx +2 -2
- package/src/lib/shapes/shared/crop.ts +1 -0
- package/src/lib/shapes/shared/interpolate-props.ts +4 -4
- package/src/lib/shapes/shared/useEditablePlainText.ts +7 -3
- package/src/lib/shapes/shared/useEditableRichText.ts +7 -3
- package/src/lib/shapes/shared/useEfficientZoomThreshold.ts +10 -0
- package/src/lib/shapes/shared/useImageOrVideoAsset.ts +1 -1
- package/src/lib/shapes/text/RichTextArea.tsx +5 -0
- package/src/lib/shapes/text/TextShapeTool.test.ts +4 -4
- package/src/lib/shapes/text/TextShapeUtil.tsx +5 -0
- package/src/lib/shapes/text/toolStates/Idle.ts +4 -14
- package/src/lib/shapes/text/toolStates/Pointing.ts +8 -8
- package/src/lib/shapes/video/VideoShapeUtil.tsx +2 -1
- package/src/lib/tools/EraserTool/childStates/Erasing.ts +21 -11
- package/src/lib/tools/EraserTool/childStates/Pointing.ts +5 -20
- package/src/lib/tools/HandTool/HandTool.ts +3 -5
- package/src/lib/tools/HandTool/childStates/Dragging.ts +3 -2
- package/src/lib/tools/HandTool/childStates/Pointing.ts +1 -1
- package/src/lib/tools/LaserTool/childStates/Lasering.ts +1 -1
- package/src/lib/tools/SelectTool/DragAndDropManager.ts +14 -11
- package/src/lib/tools/SelectTool/childStates/Brushing.ts +30 -14
- package/src/lib/tools/SelectTool/childStates/Crop/children/Cropping.ts +7 -6
- package/src/lib/tools/SelectTool/childStates/Crop/children/Idle.ts +3 -4
- package/src/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.ts +1 -1
- package/src/lib/tools/SelectTool/childStates/Crop/children/PointingCropHandle.ts +1 -1
- package/src/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.ts +2 -1
- package/src/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.ts +1 -1
- package/src/lib/tools/SelectTool/childStates/DraggingHandle.tsx +11 -12
- package/src/lib/tools/SelectTool/childStates/EditingShape.ts +57 -16
- package/src/lib/tools/SelectTool/childStates/Idle.ts +64 -81
- package/src/lib/tools/SelectTool/childStates/PointingArrowLabel.ts +7 -8
- package/src/lib/tools/SelectTool/childStates/PointingCanvas.ts +1 -1
- package/src/lib/tools/SelectTool/childStates/PointingHandle.ts +9 -17
- package/src/lib/tools/SelectTool/childStates/PointingResizeHandle.ts +1 -1
- package/src/lib/tools/SelectTool/childStates/PointingRotateHandle.ts +1 -1
- package/src/lib/tools/SelectTool/childStates/PointingSelection.ts +4 -4
- package/src/lib/tools/SelectTool/childStates/PointingShape.ts +4 -14
- package/src/lib/tools/SelectTool/childStates/Resizing.ts +8 -10
- package/src/lib/tools/SelectTool/childStates/Rotating.ts +2 -3
- package/src/lib/tools/SelectTool/childStates/ScribbleBrushing.ts +34 -14
- package/src/lib/tools/SelectTool/childStates/Translating.ts +16 -15
- package/src/lib/tools/SelectTool/selectHelpers.ts +39 -4
- package/src/lib/tools/ZoomTool/ZoomTool.ts +1 -1
- package/src/lib/tools/ZoomTool/childStates/Pointing.ts +3 -3
- package/src/lib/tools/ZoomTool/childStates/ZoomBrushing.ts +5 -6
- package/src/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.ts +1 -3
- package/src/lib/tools/selection-logic/selectOnCanvasPointerUp.ts +1 -1
- package/src/lib/tools/selection-logic/updateHoveredShapeId.ts +1 -1
- package/src/lib/ui/TldrawUi.tsx +5 -2
- package/src/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.tsx +1 -9
- package/src/lib/ui/components/ContextMenu/DefaultContextMenu.tsx +1 -3
- package/src/lib/ui/components/CursorChatBubble.tsx +2 -2
- package/src/lib/ui/components/DefaultDebugPanel.tsx +4 -43
- package/src/lib/ui/components/EditLinkDialog.tsx +16 -6
- package/src/lib/ui/components/HelperButtons/BackToContent.tsx +1 -1
- package/src/lib/ui/components/HelperButtons/StopFollowing.tsx +2 -2
- package/src/lib/ui/components/Minimap/DefaultMinimap.tsx +1 -1
- package/src/lib/ui/components/OfflineIndicator/OfflineIndicator.tsx +6 -5
- package/src/lib/ui/components/PageMenu/PageItemInput.tsx +3 -1
- package/src/lib/ui/components/SharePanel/PeopleMenu.tsx +8 -0
- package/src/lib/ui/components/Toolbar/AltTextEditor.tsx +2 -2
- package/src/lib/ui/components/Toolbar/DefaultImageToolbar.tsx +1 -1
- package/src/lib/ui/components/Toolbar/DefaultRichTextToolbar.tsx +1 -1
- package/src/lib/ui/components/TopPanel/CenteredTopPanelContainer.tsx +1 -1
- package/src/lib/ui/components/menu-items.tsx +9 -15
- package/src/lib/ui/components/primitives/TldrawUiContextualToolbar.tsx +5 -3
- package/src/lib/ui/components/primitives/TldrawUiSlider.tsx +2 -2
- package/src/lib/ui/components/primitives/TldrawUiTooltip.tsx +208 -113
- package/src/lib/ui/components/primitives/menus/TldrawUiMenuActionCheckboxItem.tsx +1 -1
- package/src/lib/ui/components/primitives/menus/TldrawUiMenuActionItem.tsx +1 -1
- package/src/lib/ui/components/primitives/menus/TldrawUiMenuItem.tsx +7 -4
- package/src/lib/ui/context/actions.tsx +15 -19
- package/src/lib/ui/context/components.tsx +1 -2
- package/src/lib/ui/hooks/menu-hooks.ts +9 -19
- package/src/lib/ui/hooks/useClipboardEvents.ts +2 -2
- package/src/lib/ui/hooks/useFlatten.ts +1 -2
- package/src/lib/ui/hooks/useKeyboardShortcuts.ts +2 -2
- package/src/lib/ui/hooks/useTools.tsx +5 -7
- package/src/lib/ui/version.ts +3 -3
- package/src/lib/ui.css +27 -23
- package/src/lib/utils/excalidraw/__snapshots__/putExcalidrawContent.test.tsx.snap +12 -48
- package/src/lib/utils/excalidraw/putExcalidrawContent.ts +19 -6
- package/src/lib/utils/export/exportAs.ts +2 -9
- package/src/lib/utils/frames/frames.ts +1 -1
- package/src/lib/utils/test-helpers.ts +62 -0
- package/src/lib/utils/text/richText.ts +13 -8
- package/src/lib/utils/tldr/buildFromV1Document.ts +21 -19
- package/src/test/Editor.test.tsx +78 -41
- package/src/test/EraserTool.test.ts +10 -12
- package/src/test/SelectTool.test.ts +11 -19
- package/src/test/TestEditor.ts +49 -51
- package/src/test/TldrawEditor.test.tsx +24 -20
- package/src/test/__snapshots__/drawing.test.ts.snap +3 -1257
- package/src/test/__snapshots__/resizing.test.ts.snap +3 -12
- package/src/test/arrows-megabus.test.tsx +1 -1
- package/src/test/bindings.test.tsx +29 -25
- package/src/test/bindingsIndex.test.tsx +4 -4
- package/src/test/commands/__snapshots__/getSvgString.test.ts.snap +10 -10
- package/src/test/commands/cameraState.test.ts +299 -0
- package/src/test/commands/createShape.test.ts +64 -0
- package/src/test/commands/createShapes.test.ts +15 -1
- package/src/test/commands/getSvgString.test.ts +2 -2
- package/src/test/commands/isShapeOfType.test.ts +44 -0
- package/src/test/commands/putContent.test.ts +80 -1
- package/src/test/commands/setCamera.test.ts +13 -11
- package/src/test/commands/stackShapes.test.ts +34 -8
- package/src/test/commands/updateShape.test.ts +67 -0
- package/src/test/commands/updateShapes.test.ts +21 -5
- package/src/test/commands/zoomToBounds.test.ts +19 -3
- package/src/test/commands/zoomToSelection.test.ts +14 -3
- package/src/test/custom-clipping.test.ts +52 -44
- package/src/test/customSnapping.test.tsx +77 -62
- package/src/test/drawing.test.ts +17 -10
- package/src/test/duplicate.test.ts +1 -1
- package/src/test/flipShapes.test.ts +33 -0
- package/src/test/frames.test.ts +94 -2
- package/src/test/getCulledShapes.test.tsx +11 -3
- package/src/test/getShapeAtPoint.test.ts +2 -2
- package/src/test/groups.test.tsx +7 -4
- package/src/test/modifiers.test.ts +6 -6
- package/src/test/notVisibleShapes.test.ts +698 -0
- package/src/test/resizing.test.ts +16 -22
- package/src/test/selection-omnibus.test.ts +13 -13
- package/src/test/shapeutils.test.ts +1 -1
- package/src/test/spacebarPanning.test.ts +28 -10
- package/src/test/styles2.test.tsx +1 -1
- package/src/test/styles3.test.ts +5 -5
- package/src/test/test-jsx.tsx +72 -57
- package/src/test/text.test.ts +15 -17
- package/src/test/translating.test.ts +6 -8
- package/src/test/ui/BackToContent.test.tsx +111 -0
- package/tldraw.css +41 -35
- package/dist-cjs/lib/shapes/shared/useForceSolid.js.map +0 -7
- package/dist-cjs/lib/tools/selection-logic/getShouldEnterCropModeOnPointerDown.js.map +0 -7
- package/dist-cjs/lib/ui/components/TopPanel/DefaultTopPanel.js +0 -32
- package/dist-cjs/lib/ui/components/TopPanel/DefaultTopPanel.js.map +0 -7
- package/dist-cjs/lib/utils/text/textDirection.js +0 -51
- package/dist-cjs/lib/utils/text/textDirection.js.map +0 -7
- package/dist-esm/lib/shapes/shared/useForceSolid.mjs +0 -9
- package/dist-esm/lib/shapes/shared/useForceSolid.mjs.map +0 -7
- package/dist-esm/lib/tools/selection-logic/getShouldEnterCropModeOnPointerDown.mjs +0 -8
- package/dist-esm/lib/tools/selection-logic/getShouldEnterCropModeOnPointerDown.mjs.map +0 -7
- package/dist-esm/lib/ui/components/TopPanel/DefaultTopPanel.mjs +0 -12
- package/dist-esm/lib/ui/components/TopPanel/DefaultTopPanel.mjs.map +0 -7
- package/dist-esm/lib/utils/text/textDirection.mjs +0 -31
- package/dist-esm/lib/utils/text/textDirection.mjs.map +0 -7
- package/src/lib/shapes/shared/useForceSolid.ts +0 -6
- package/src/lib/tools/selection-logic/getShouldEnterCropModeOnPointerDown.ts +0 -10
- package/src/lib/ui/components/TopPanel/DefaultTopPanel.tsx +0 -10
- package/src/lib/utils/text/textDirection.ts +0 -32
|
@@ -0,0 +1,62 @@
|
|
|
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
|
+
* Uses delta encoding for improved Float16 precision.
|
|
7
|
+
* This is useful for tests that create draw shapes with the legacy array format.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* const segments = [{ type: 'free', path: pointsToBase64([{x: 0, y: 0, z: 0.5}]) }]
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
export function pointsToBase64(points: VecModel[]): string {
|
|
17
|
+
return b64Vecs.encodePoints(points)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Helper function to convert base64 string back to VecModel[] points.
|
|
22
|
+
* Decodes delta-encoded points to absolute coordinates.
|
|
23
|
+
* This is useful for tests that need to inspect draw shape points.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* const points = base64ToPoints(shape.props.segments[0].path)
|
|
28
|
+
* expect(points[0].x).toBe(0)
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @public
|
|
32
|
+
*/
|
|
33
|
+
export function base64ToPoints(base64: string): VecModel[] {
|
|
34
|
+
return b64Vecs.decodePoints(base64)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Helper function to create draw shape segments from legacy array format.
|
|
39
|
+
* This allows tests to use the old format while the shape uses the new base64 format.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```ts
|
|
43
|
+
* editor.createShapes([{
|
|
44
|
+
* type: 'draw',
|
|
45
|
+
* props: {
|
|
46
|
+
* segments: createDrawSegments([[{x: 0, y: 0}, {x: 10, y: 10}]])
|
|
47
|
+
* }
|
|
48
|
+
* }])
|
|
49
|
+
* ```
|
|
50
|
+
* @public
|
|
51
|
+
*/
|
|
52
|
+
export function createDrawSegments(
|
|
53
|
+
pointArrays: VecModel[][],
|
|
54
|
+
type: 'free' | 'straight' = 'free'
|
|
55
|
+
): TLDrawShapeSegment[] {
|
|
56
|
+
return compressLegacySegments(
|
|
57
|
+
pointArrays.map((points) => ({
|
|
58
|
+
type,
|
|
59
|
+
points,
|
|
60
|
+
}))
|
|
61
|
+
)
|
|
62
|
+
}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Extension,
|
|
3
3
|
Extensions,
|
|
4
|
+
extensions,
|
|
4
5
|
generateHTML,
|
|
5
6
|
generateJSON,
|
|
6
7
|
generateText,
|
|
7
8
|
JSONContent,
|
|
8
9
|
} from '@tiptap/core'
|
|
9
|
-
import Code from '@tiptap/extension-code'
|
|
10
|
-
import Highlight from '@tiptap/extension-highlight'
|
|
10
|
+
import { Code } from '@tiptap/extension-code'
|
|
11
|
+
import { Highlight } from '@tiptap/extension-highlight'
|
|
11
12
|
import { Node } from '@tiptap/pm/model'
|
|
12
|
-
import StarterKit from '@tiptap/starter-kit'
|
|
13
|
+
import { StarterKit } from '@tiptap/starter-kit'
|
|
13
14
|
import {
|
|
14
15
|
Editor,
|
|
15
16
|
getOwnProperty,
|
|
@@ -19,7 +20,6 @@ import {
|
|
|
19
20
|
WeakCache,
|
|
20
21
|
} from '@tldraw/editor'
|
|
21
22
|
import { DefaultFontFaces } from '../../shapes/shared/defaultFonts'
|
|
22
|
-
import { TextDirection } from './textDirection'
|
|
23
23
|
|
|
24
24
|
/** @public */
|
|
25
25
|
export const KeyboardShiftEnterTweakExtension = Extension.create({
|
|
@@ -56,10 +56,18 @@ export const tipTapDefaultExtensions: Extensions = [
|
|
|
56
56
|
openOnClick: false,
|
|
57
57
|
autolink: true,
|
|
58
58
|
},
|
|
59
|
+
// Prevent trailing paragraph insertion after lists (fixes #7641)
|
|
60
|
+
trailingNode: {
|
|
61
|
+
notAfter: ['paragraph', 'bulletList', 'orderedList', 'listItem'],
|
|
62
|
+
},
|
|
59
63
|
}),
|
|
60
64
|
Highlight,
|
|
61
65
|
KeyboardShiftEnterTweakExtension,
|
|
62
|
-
|
|
66
|
+
|
|
67
|
+
// N.B. We disable the text direction core extension in RichTextArea,
|
|
68
|
+
// but we add it back in again here in our own extensions list so that
|
|
69
|
+
// people can omit/override it if they want to.
|
|
70
|
+
extensions.TextDirection.configure({ direction: 'auto' }),
|
|
63
71
|
]
|
|
64
72
|
|
|
65
73
|
// todo: bust this if the editor changes, too
|
|
@@ -88,7 +96,6 @@ export function renderHtmlFromRichText(editor: Editor, richText: TLRichText) {
|
|
|
88
96
|
* @param editor - The editor instance.
|
|
89
97
|
* @param richText - The rich text content.
|
|
90
98
|
*
|
|
91
|
-
*
|
|
92
99
|
* @public
|
|
93
100
|
*/
|
|
94
101
|
export function renderHtmlFromRichTextForMeasurement(editor: Editor, richText: TLRichText) {
|
|
@@ -111,7 +118,6 @@ export function isEmptyRichText(richText: TLRichText) {
|
|
|
111
118
|
* @param editor - The editor instance.
|
|
112
119
|
* @param richText - The rich text content.
|
|
113
120
|
*
|
|
114
|
-
*
|
|
115
121
|
* @public
|
|
116
122
|
*/
|
|
117
123
|
export function renderPlaintextFromRichText(editor: Editor, richText: TLRichText) {
|
|
@@ -131,7 +137,6 @@ export function renderPlaintextFromRichText(editor: Editor, richText: TLRichText
|
|
|
131
137
|
* @param editor - The editor instance.
|
|
132
138
|
* @param richText - The rich text content.
|
|
133
139
|
*
|
|
134
|
-
*
|
|
135
140
|
* @public
|
|
136
141
|
*/
|
|
137
142
|
export function renderRichTextFromHTML(editor: Editor, html: string): TLRichText {
|
|
@@ -12,16 +12,12 @@ import {
|
|
|
12
12
|
TLDefaultHorizontalAlignStyle,
|
|
13
13
|
TLDefaultSizeStyle,
|
|
14
14
|
TLDefaultTextAlignStyle,
|
|
15
|
-
TLDrawShape,
|
|
16
15
|
TLGeoShape,
|
|
17
|
-
TLImageShape,
|
|
18
|
-
TLNoteShape,
|
|
19
16
|
TLPageId,
|
|
20
17
|
TLShapeId,
|
|
21
|
-
TLTextShape,
|
|
22
|
-
TLVideoShape,
|
|
23
18
|
Vec,
|
|
24
19
|
VecModel,
|
|
20
|
+
b64Vecs,
|
|
25
21
|
clamp,
|
|
26
22
|
createShapeId,
|
|
27
23
|
fetch,
|
|
@@ -187,7 +183,7 @@ export function buildFromV1Document(editor: Editor, _document: unknown) {
|
|
|
187
183
|
|
|
188
184
|
switch (v1Shape.type) {
|
|
189
185
|
case TLV1ShapeType.Sticky: {
|
|
190
|
-
editor.createShapes
|
|
186
|
+
editor.createShapes([
|
|
191
187
|
{
|
|
192
188
|
...inCommon,
|
|
193
189
|
type: 'note',
|
|
@@ -203,7 +199,7 @@ export function buildFromV1Document(editor: Editor, _document: unknown) {
|
|
|
203
199
|
break
|
|
204
200
|
}
|
|
205
201
|
case TLV1ShapeType.Rectangle: {
|
|
206
|
-
editor.createShapes
|
|
202
|
+
editor.createShapes([
|
|
207
203
|
{
|
|
208
204
|
...inCommon,
|
|
209
205
|
type: 'geo',
|
|
@@ -225,7 +221,7 @@ export function buildFromV1Document(editor: Editor, _document: unknown) {
|
|
|
225
221
|
|
|
226
222
|
const pageBoundsBeforeLabel = editor.getShapePageBounds(inCommon.id)!
|
|
227
223
|
|
|
228
|
-
editor.updateShapes
|
|
224
|
+
editor.updateShapes([
|
|
229
225
|
{
|
|
230
226
|
id: inCommon.id,
|
|
231
227
|
type: 'geo',
|
|
@@ -259,7 +255,7 @@ export function buildFromV1Document(editor: Editor, _document: unknown) {
|
|
|
259
255
|
break
|
|
260
256
|
}
|
|
261
257
|
case TLV1ShapeType.Triangle: {
|
|
262
|
-
editor.createShapes
|
|
258
|
+
editor.createShapes([
|
|
263
259
|
{
|
|
264
260
|
...inCommon,
|
|
265
261
|
type: 'geo',
|
|
@@ -280,7 +276,7 @@ export function buildFromV1Document(editor: Editor, _document: unknown) {
|
|
|
280
276
|
|
|
281
277
|
const pageBoundsBeforeLabel = editor.getShapePageBounds(inCommon.id)!
|
|
282
278
|
|
|
283
|
-
editor.updateShapes
|
|
279
|
+
editor.updateShapes([
|
|
284
280
|
{
|
|
285
281
|
id: inCommon.id,
|
|
286
282
|
type: 'geo',
|
|
@@ -314,7 +310,7 @@ export function buildFromV1Document(editor: Editor, _document: unknown) {
|
|
|
314
310
|
break
|
|
315
311
|
}
|
|
316
312
|
case TLV1ShapeType.Ellipse: {
|
|
317
|
-
editor.createShapes
|
|
313
|
+
editor.createShapes([
|
|
318
314
|
{
|
|
319
315
|
...inCommon,
|
|
320
316
|
type: 'geo',
|
|
@@ -335,7 +331,7 @@ export function buildFromV1Document(editor: Editor, _document: unknown) {
|
|
|
335
331
|
|
|
336
332
|
const pageBoundsBeforeLabel = editor.getShapePageBounds(inCommon.id)!
|
|
337
333
|
|
|
338
|
-
editor.updateShapes
|
|
334
|
+
editor.updateShapes([
|
|
339
335
|
{
|
|
340
336
|
id: inCommon.id,
|
|
341
337
|
type: 'geo',
|
|
@@ -375,7 +371,10 @@ export function buildFromV1Document(editor: Editor, _document: unknown) {
|
|
|
375
371
|
break
|
|
376
372
|
}
|
|
377
373
|
|
|
378
|
-
|
|
374
|
+
const points = v1Shape.points.map(getV2Point)
|
|
375
|
+
const base64Points = b64Vecs.encodePoints(points)
|
|
376
|
+
|
|
377
|
+
editor.createShapes([
|
|
379
378
|
{
|
|
380
379
|
...inCommon,
|
|
381
380
|
type: 'draw',
|
|
@@ -386,7 +385,10 @@ export function buildFromV1Document(editor: Editor, _document: unknown) {
|
|
|
386
385
|
dash: getV2Dash(v1Shape.style.dash),
|
|
387
386
|
isPen: false,
|
|
388
387
|
isComplete: v1Shape.isComplete,
|
|
389
|
-
segments: [{ type: 'free',
|
|
388
|
+
segments: [{ type: 'free', path: base64Points }],
|
|
389
|
+
scale: 1,
|
|
390
|
+
scaleX: 1,
|
|
391
|
+
scaleY: 1,
|
|
390
392
|
},
|
|
391
393
|
},
|
|
392
394
|
])
|
|
@@ -400,7 +402,7 @@ export function buildFromV1Document(editor: Editor, _document: unknown) {
|
|
|
400
402
|
const v2Bend = (dist * -v1Bend) / 2
|
|
401
403
|
|
|
402
404
|
// Could also be a line... but we'll use it as an arrow anyway
|
|
403
|
-
editor.createShapes
|
|
405
|
+
editor.createShapes([
|
|
404
406
|
{
|
|
405
407
|
...inCommon,
|
|
406
408
|
type: 'arrow',
|
|
@@ -429,7 +431,7 @@ export function buildFromV1Document(editor: Editor, _document: unknown) {
|
|
|
429
431
|
break
|
|
430
432
|
}
|
|
431
433
|
case TLV1ShapeType.Text: {
|
|
432
|
-
editor.createShapes
|
|
434
|
+
editor.createShapes([
|
|
433
435
|
{
|
|
434
436
|
...inCommon,
|
|
435
437
|
type: 'text',
|
|
@@ -453,7 +455,7 @@ export function buildFromV1Document(editor: Editor, _document: unknown) {
|
|
|
453
455
|
return
|
|
454
456
|
}
|
|
455
457
|
|
|
456
|
-
editor.createShapes
|
|
458
|
+
editor.createShapes([
|
|
457
459
|
{
|
|
458
460
|
...inCommon,
|
|
459
461
|
type: 'image',
|
|
@@ -474,7 +476,7 @@ export function buildFromV1Document(editor: Editor, _document: unknown) {
|
|
|
474
476
|
return
|
|
475
477
|
}
|
|
476
478
|
|
|
477
|
-
editor.createShapes
|
|
479
|
+
editor.createShapes([
|
|
478
480
|
{
|
|
479
481
|
...inCommon,
|
|
480
482
|
type: 'video',
|
|
@@ -523,7 +525,7 @@ export function buildFromV1Document(editor: Editor, _document: unknown) {
|
|
|
523
525
|
const util = editor.getShapeUtil<TLArrowShape>('arrow')
|
|
524
526
|
|
|
525
527
|
// dumb but necessary
|
|
526
|
-
editor.inputs.
|
|
528
|
+
editor.inputs.setCtrlKey(false)
|
|
527
529
|
|
|
528
530
|
for (const handleId of ['start', 'end'] as const) {
|
|
529
531
|
const bindingId = v1Shape.handles[handleId].bindingId
|
package/src/test/Editor.test.tsx
CHANGED
|
@@ -143,17 +143,17 @@ describe('shapes that are moved to another page', () => {
|
|
|
143
143
|
it('Begins dragging from pointer move', () => {
|
|
144
144
|
editor.pointerDown(0, 0)
|
|
145
145
|
editor.pointerMove(2, 2)
|
|
146
|
-
expect(editor.inputs.
|
|
146
|
+
expect(editor.inputs.getIsDragging()).toBe(false)
|
|
147
147
|
editor.pointerMove(10, 10)
|
|
148
|
-
expect(editor.inputs.
|
|
148
|
+
expect(editor.inputs.getIsDragging()).toBe(true)
|
|
149
149
|
})
|
|
150
150
|
|
|
151
151
|
it('Begins dragging from wheel', () => {
|
|
152
152
|
editor.pointerDown(0, 0)
|
|
153
153
|
editor.wheel(2, 2)
|
|
154
|
-
expect(editor.inputs.
|
|
154
|
+
expect(editor.inputs.getIsDragging()).toBe(false)
|
|
155
155
|
editor.wheel(10, 10)
|
|
156
|
-
expect(editor.inputs.
|
|
156
|
+
expect(editor.inputs.getIsDragging()).toBe(true)
|
|
157
157
|
})
|
|
158
158
|
|
|
159
159
|
it('Does not create an undo stack item when first clicking on an empty canvas', () => {
|
|
@@ -266,36 +266,47 @@ describe('Editor.TickManager', () => {
|
|
|
266
266
|
// usually this is called by the app's tick manager, using the elapsed time
|
|
267
267
|
// between two animation frames, but we're calling it directly here.
|
|
268
268
|
const tick = (ms: number) => {
|
|
269
|
-
|
|
270
|
-
editor._tickManager.updatePointerVelocity(ms)
|
|
269
|
+
editor.inputs.updatePointerVelocity(ms)
|
|
271
270
|
}
|
|
272
271
|
|
|
273
272
|
// 1. pointer velocity should be 0 when there is no movement
|
|
274
|
-
expect(editor.inputs.
|
|
273
|
+
expect(editor.inputs.getPointerVelocity().toJson()).toCloselyMatchObject({ x: 0, y: 0 })
|
|
275
274
|
|
|
276
275
|
editor.pointerMove(10, 10)
|
|
277
276
|
|
|
278
277
|
// 2. moving is not enough, we also need to wait a frame before the velocity is updated
|
|
279
|
-
expect(editor.inputs.
|
|
278
|
+
expect(editor.inputs.getPointerVelocity().toJson()).toCloselyMatchObject({ x: 0, y: 0 })
|
|
280
279
|
|
|
281
280
|
// 3. once time passes, the pointer velocity should be updated
|
|
282
281
|
tick(16)
|
|
283
|
-
expect(editor.inputs.
|
|
282
|
+
expect(editor.inputs.getPointerVelocity().toJson()).toCloselyMatchObject({
|
|
283
|
+
x: 0.3125,
|
|
284
|
+
y: 0.3125,
|
|
285
|
+
})
|
|
284
286
|
|
|
285
287
|
// 4. let's do it again, it should be updated again. move, tick, measure
|
|
286
288
|
editor.pointerMove(20, 20)
|
|
287
289
|
tick(16)
|
|
288
|
-
expect(editor.inputs.
|
|
290
|
+
expect(editor.inputs.getPointerVelocity().toJson()).toCloselyMatchObject({
|
|
291
|
+
x: 0.46875,
|
|
292
|
+
y: 0.46875,
|
|
293
|
+
})
|
|
289
294
|
|
|
290
295
|
// 5. if we tick again without movement, the velocity should decay
|
|
291
296
|
tick(16)
|
|
292
297
|
|
|
293
|
-
expect(editor.inputs.
|
|
298
|
+
expect(editor.inputs.getPointerVelocity().toJson()).toCloselyMatchObject({
|
|
299
|
+
x: 0.23437,
|
|
300
|
+
y: 0.23437,
|
|
301
|
+
})
|
|
294
302
|
|
|
295
303
|
// 6. if updatePointerVelocity is (for whatever reason) called with an elapsed time of zero milliseconds, it should be ignored
|
|
296
304
|
tick(0)
|
|
297
305
|
|
|
298
|
-
expect(editor.inputs.
|
|
306
|
+
expect(editor.inputs.getPointerVelocity().toJson()).toCloselyMatchObject({
|
|
307
|
+
x: 0.23437,
|
|
308
|
+
y: 0.23437,
|
|
309
|
+
})
|
|
299
310
|
})
|
|
300
311
|
})
|
|
301
312
|
|
|
@@ -472,12 +483,20 @@ describe('isFocused', () => {
|
|
|
472
483
|
})
|
|
473
484
|
})
|
|
474
485
|
|
|
486
|
+
const BLORG_TYPE = 'blorg'
|
|
487
|
+
|
|
488
|
+
declare module '@tldraw/tlschema' {
|
|
489
|
+
export interface TLGlobalShapePropsMap {
|
|
490
|
+
[BLORG_TYPE]: { w: number; h: number }
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
|
|
475
494
|
describe('getShapeUtil', () => {
|
|
476
495
|
let myUtil: any
|
|
477
496
|
|
|
478
497
|
beforeEach(() => {
|
|
479
498
|
class _MyFakeShapeUtil extends BaseBoxShapeUtil<any> {
|
|
480
|
-
static override type =
|
|
499
|
+
static override type = BLORG_TYPE
|
|
481
500
|
|
|
482
501
|
getDefaultProps() {
|
|
483
502
|
return {
|
|
@@ -519,16 +538,22 @@ describe('getShapeUtil', () => {
|
|
|
519
538
|
})
|
|
520
539
|
|
|
521
540
|
it('throws if that shape type isnt registered', () => {
|
|
522
|
-
const myMissingShape = { type: 'missing' }
|
|
523
|
-
expect(() =>
|
|
524
|
-
|
|
525
|
-
|
|
541
|
+
const myMissingShape = { type: 'missing' }
|
|
542
|
+
expect(() =>
|
|
543
|
+
editor.getShapeUtil(
|
|
544
|
+
// @ts-expect-error
|
|
545
|
+
myMissingShape
|
|
546
|
+
)
|
|
547
|
+
).toThrowErrorMatchingInlineSnapshot(`[Error: No shape util found for type "missing"]`)
|
|
526
548
|
})
|
|
527
549
|
|
|
528
550
|
it('throws if that type isnt registered', () => {
|
|
529
|
-
expect(() =>
|
|
530
|
-
|
|
531
|
-
|
|
551
|
+
expect(() =>
|
|
552
|
+
editor.getShapeUtil(
|
|
553
|
+
// @ts-expect-error
|
|
554
|
+
'missing'
|
|
555
|
+
)
|
|
556
|
+
).toThrowErrorMatchingInlineSnapshot(`[Error: No shape util found for type "missing"]`)
|
|
532
557
|
})
|
|
533
558
|
})
|
|
534
559
|
|
|
@@ -663,9 +688,9 @@ describe('middle-click panning', () => {
|
|
|
663
688
|
button: 1,
|
|
664
689
|
})
|
|
665
690
|
editor.pointerMove(100, 100)
|
|
666
|
-
expect(editor.inputs.
|
|
691
|
+
expect(editor.inputs.getIsPanning()).toBe(true)
|
|
667
692
|
editor.pointerUp(100, 100)
|
|
668
|
-
expect(editor.inputs.
|
|
693
|
+
expect(editor.inputs.getIsPanning()).toBe(false)
|
|
669
694
|
})
|
|
670
695
|
|
|
671
696
|
it('does not clear thee isPanning state if the space bar is down', () => {
|
|
@@ -674,51 +699,51 @@ describe('middle-click panning', () => {
|
|
|
674
699
|
button: 1,
|
|
675
700
|
})
|
|
676
701
|
editor.pointerMove(100, 100)
|
|
677
|
-
expect(editor.inputs.
|
|
702
|
+
expect(editor.inputs.getIsPanning()).toBe(true)
|
|
678
703
|
editor.keyDown(' ')
|
|
679
704
|
editor.pointerUp(100, 100, {
|
|
680
705
|
button: 1,
|
|
681
706
|
})
|
|
682
|
-
expect(editor.inputs.
|
|
707
|
+
expect(editor.inputs.getIsPanning()).toBe(true)
|
|
683
708
|
|
|
684
709
|
editor.keyUp(' ')
|
|
685
|
-
expect(editor.inputs.
|
|
710
|
+
expect(editor.inputs.getIsPanning()).toBe(false)
|
|
686
711
|
})
|
|
687
712
|
})
|
|
688
713
|
|
|
689
714
|
describe('dragging', () => {
|
|
690
715
|
it('drags correctly at 100% zoom', () => {
|
|
691
|
-
expect(editor.inputs.
|
|
716
|
+
expect(editor.inputs.getIsDragging()).toBe(false)
|
|
692
717
|
editor.pointerMove(0, 0).pointerDown()
|
|
693
|
-
expect(editor.inputs.
|
|
718
|
+
expect(editor.inputs.getIsDragging()).toBe(false)
|
|
694
719
|
editor.pointerMove(0, 1)
|
|
695
|
-
expect(editor.inputs.
|
|
720
|
+
expect(editor.inputs.getIsDragging()).toBe(false)
|
|
696
721
|
editor.pointerMove(0, 5)
|
|
697
|
-
expect(editor.inputs.
|
|
722
|
+
expect(editor.inputs.getIsDragging()).toBe(true)
|
|
698
723
|
})
|
|
699
724
|
|
|
700
725
|
it('drags correctly at 150% zoom', () => {
|
|
701
726
|
editor.setCamera({ x: 0, y: 0, z: 8 }).forceTick()
|
|
702
727
|
|
|
703
|
-
expect(editor.inputs.
|
|
728
|
+
expect(editor.inputs.getIsDragging()).toBe(false)
|
|
704
729
|
editor.pointerMove(0, 0).pointerDown()
|
|
705
|
-
expect(editor.inputs.
|
|
730
|
+
expect(editor.inputs.getIsDragging()).toBe(false)
|
|
706
731
|
editor.pointerMove(0, 2)
|
|
707
|
-
expect(editor.inputs.
|
|
732
|
+
expect(editor.inputs.getIsDragging()).toBe(false)
|
|
708
733
|
editor.pointerMove(0, 5)
|
|
709
|
-
expect(editor.inputs.
|
|
734
|
+
expect(editor.inputs.getIsDragging()).toBe(true)
|
|
710
735
|
})
|
|
711
736
|
|
|
712
737
|
it('drags correctly at 50% zoom', () => {
|
|
713
738
|
editor.setCamera({ x: 0, y: 0, z: 0.1 }).forceTick()
|
|
714
739
|
|
|
715
|
-
expect(editor.inputs.
|
|
740
|
+
expect(editor.inputs.getIsDragging()).toBe(false)
|
|
716
741
|
editor.pointerMove(0, 0).pointerDown()
|
|
717
|
-
expect(editor.inputs.
|
|
742
|
+
expect(editor.inputs.getIsDragging()).toBe(false)
|
|
718
743
|
editor.pointerMove(0, 2)
|
|
719
|
-
expect(editor.inputs.
|
|
744
|
+
expect(editor.inputs.getIsDragging()).toBe(false)
|
|
720
745
|
editor.pointerMove(0, 5)
|
|
721
|
-
expect(editor.inputs.
|
|
746
|
+
expect(editor.inputs.getIsDragging()).toBe(true)
|
|
722
747
|
})
|
|
723
748
|
})
|
|
724
749
|
|
|
@@ -866,9 +891,19 @@ describe('instance.isReadonly', () => {
|
|
|
866
891
|
})
|
|
867
892
|
})
|
|
868
893
|
|
|
894
|
+
const MY_CUSTOM_SHAPE_TYPE = 'myCustomShape'
|
|
895
|
+
|
|
896
|
+
type MyCustomShape = TLShape<typeof MY_CUSTOM_SHAPE_TYPE>
|
|
897
|
+
|
|
898
|
+
declare module '@tldraw/tlschema' {
|
|
899
|
+
export interface TLGlobalShapePropsMap {
|
|
900
|
+
[MY_CUSTOM_SHAPE_TYPE]: { w: number; h: number }
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
|
|
869
904
|
describe('the geometry cache', () => {
|
|
870
|
-
class CustomShapeUtil extends BaseBoxShapeUtil<
|
|
871
|
-
static override type =
|
|
905
|
+
class CustomShapeUtil extends BaseBoxShapeUtil<MyCustomShape> {
|
|
906
|
+
static override type = MY_CUSTOM_SHAPE_TYPE
|
|
872
907
|
|
|
873
908
|
getDefaultProps() {
|
|
874
909
|
return {
|
|
@@ -894,9 +929,11 @@ describe('the geometry cache', () => {
|
|
|
894
929
|
editor = new TestEditor({
|
|
895
930
|
shapeUtils: [CustomShapeUtil],
|
|
896
931
|
})
|
|
897
|
-
const { A } = editor.createShapesFromJsx([
|
|
932
|
+
const { A } = editor.createShapesFromJsx([
|
|
933
|
+
<TL.myCustomShape ref="A" x={0} y={0} w={100} h={100} />,
|
|
934
|
+
])
|
|
898
935
|
expect(editor.getShapePageBounds(A)!.width).toBe(100)
|
|
899
|
-
editor.updateShape({ id: A, type: '
|
|
936
|
+
editor.updateShape({ id: A, type: 'myCustomShape', meta: { double: true } })
|
|
900
937
|
expect(editor.getShapePageBounds(A)!.width).toBe(200)
|
|
901
938
|
})
|
|
902
939
|
})
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createShapeId } from '@tldraw/editor'
|
|
2
2
|
import { vi } from 'vitest'
|
|
3
|
+
import { createDrawSegments } from './test-jsx'
|
|
3
4
|
import { TestEditor } from './TestEditor'
|
|
4
5
|
|
|
5
6
|
let editor: TestEditor
|
|
@@ -72,18 +73,15 @@ beforeEach(() => {
|
|
|
72
73
|
x: 0,
|
|
73
74
|
y: 300,
|
|
74
75
|
props: {
|
|
75
|
-
segments: [
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
],
|
|
85
|
-
},
|
|
86
|
-
],
|
|
76
|
+
segments: createDrawSegments([
|
|
77
|
+
[
|
|
78
|
+
{ x: 0, y: 0 },
|
|
79
|
+
{ x: 2, y: 50 },
|
|
80
|
+
{ x: 10, y: 100 },
|
|
81
|
+
{ x: 48, y: 100 },
|
|
82
|
+
{ x: 100, y: 100 },
|
|
83
|
+
],
|
|
84
|
+
]),
|
|
87
85
|
},
|
|
88
86
|
},
|
|
89
87
|
])
|
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
IndexKey,
|
|
3
|
-
TLArrowShape,
|
|
4
|
-
TLGeoShape,
|
|
5
|
-
TLNoteShape,
|
|
6
|
-
TLTextShape,
|
|
7
|
-
createShapeId,
|
|
8
|
-
toRichText,
|
|
9
|
-
} from '@tldraw/editor'
|
|
1
|
+
import { IndexKey, createShapeId, toRichText } from '@tldraw/editor'
|
|
10
2
|
import { vi } from 'vitest'
|
|
11
3
|
import { TestEditor } from './TestEditor'
|
|
12
4
|
|
|
@@ -61,7 +53,7 @@ describe('TLSelectTool.Idle', () => {
|
|
|
61
53
|
describe.skip('Edit on type', () => {
|
|
62
54
|
it('Starts editing shape on key down if shape does auto-edit on key stroke', () => {
|
|
63
55
|
const id = createShapeId()
|
|
64
|
-
editor.createShapes
|
|
56
|
+
editor.createShapes([
|
|
65
57
|
{
|
|
66
58
|
id,
|
|
67
59
|
type: 'note',
|
|
@@ -85,7 +77,7 @@ describe.skip('Edit on type', () => {
|
|
|
85
77
|
|
|
86
78
|
it('Does not start editing on excluded keys', () => {
|
|
87
79
|
const id = createShapeId()
|
|
88
|
-
editor.createShapes
|
|
80
|
+
editor.createShapes([
|
|
89
81
|
{
|
|
90
82
|
id,
|
|
91
83
|
type: 'note',
|
|
@@ -102,7 +94,7 @@ describe.skip('Edit on type', () => {
|
|
|
102
94
|
|
|
103
95
|
it('Ignores key down if altKey or ctrlKey is pressed', () => {
|
|
104
96
|
const id = createShapeId()
|
|
105
|
-
editor.createShapes
|
|
97
|
+
editor.createShapes([
|
|
106
98
|
{
|
|
107
99
|
id,
|
|
108
100
|
type: 'note',
|
|
@@ -270,7 +262,7 @@ describe('DraggingHandle', () => {
|
|
|
270
262
|
|
|
271
263
|
describe('PointingLabel', () => {
|
|
272
264
|
it('Enters from pointing_arrow_label and exits to idle', () => {
|
|
273
|
-
editor.createShapes
|
|
265
|
+
editor.createShapes([
|
|
274
266
|
{
|
|
275
267
|
id: ids.arrow1,
|
|
276
268
|
type: 'arrow',
|
|
@@ -302,7 +294,7 @@ describe('PointingLabel', () => {
|
|
|
302
294
|
})
|
|
303
295
|
|
|
304
296
|
it('Bails on escape', () => {
|
|
305
|
-
editor.createShapes
|
|
297
|
+
editor.createShapes([
|
|
306
298
|
{
|
|
307
299
|
id: ids.arrow1,
|
|
308
300
|
type: 'arrow',
|
|
@@ -329,7 +321,7 @@ describe('PointingLabel', () => {
|
|
|
329
321
|
})
|
|
330
322
|
|
|
331
323
|
it('Doesnt go into pointing_arrow_label mode if not selecting the arrow shape', () => {
|
|
332
|
-
editor.createShapes
|
|
324
|
+
editor.createShapes([
|
|
333
325
|
{
|
|
334
326
|
id: ids.arrow1,
|
|
335
327
|
type: 'arrow',
|
|
@@ -406,7 +398,7 @@ describe('When double clicking the selection edge', () => {
|
|
|
406
398
|
.selectAll()
|
|
407
399
|
.deleteShapes(editor.getSelectedShapeIds())
|
|
408
400
|
.selectNone()
|
|
409
|
-
.createShapes
|
|
401
|
+
.createShapes([
|
|
410
402
|
{
|
|
411
403
|
id,
|
|
412
404
|
type: 'text',
|
|
@@ -464,7 +456,7 @@ describe('When editing shapes', () => {
|
|
|
464
456
|
text2: createShapeId(),
|
|
465
457
|
}
|
|
466
458
|
|
|
467
|
-
editor.createShapes
|
|
459
|
+
editor.createShapes([
|
|
468
460
|
{
|
|
469
461
|
id: ids.geo1,
|
|
470
462
|
type: 'geo',
|
|
@@ -702,7 +694,7 @@ describe('when passing a function to onInteractionEnd', () => {
|
|
|
702
694
|
},
|
|
703
695
|
}
|
|
704
696
|
|
|
705
|
-
editor.createShapes
|
|
697
|
+
editor.createShapes([arrow])
|
|
706
698
|
|
|
707
699
|
editor.setCurrentTool('select.pointing_arrow_label', {
|
|
708
700
|
shape: arrow,
|
|
@@ -828,7 +820,7 @@ describe('when passing a string to onInteractionEnd', () => {
|
|
|
828
820
|
},
|
|
829
821
|
}
|
|
830
822
|
|
|
831
|
-
editor.createShapes
|
|
823
|
+
editor.createShapes([arrow])
|
|
832
824
|
|
|
833
825
|
editor.setCurrentTool('select.pointing_arrow_label', {
|
|
834
826
|
shape: arrow,
|