tldraw 4.3.0-next.f4772c19540d → 4.4.0-canary.29afdff6bb04
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -2
- package/dist-cjs/index.d.ts +311 -242
- package/dist-cjs/index.js +13 -5
- package/dist-cjs/index.js.map +2 -2
- package/dist-cjs/lib/bindings/arrow/ArrowBindingUtil.js.map +2 -2
- package/dist-cjs/lib/canvas/TldrawSelectionForeground.js +2 -2
- package/dist-cjs/lib/canvas/TldrawSelectionForeground.js.map +2 -2
- package/dist-cjs/lib/defaultEmbedDefinitions.js +1 -1
- package/dist-cjs/lib/defaultEmbedDefinitions.js.map +2 -2
- package/dist-cjs/lib/defaultExternalContentHandlers.js +5 -5
- package/dist-cjs/lib/defaultExternalContentHandlers.js.map +2 -2
- package/dist-cjs/lib/defaultSideEffects.js +6 -1
- package/dist-cjs/lib/defaultSideEffects.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js +14 -13
- package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/arrow-types.js.map +1 -1
- package/dist-cjs/lib/shapes/arrow/arrowLabel.js +1 -1
- package/dist-cjs/lib/shapes/arrow/arrowLabel.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/arrowTargetState.js +1 -1
- package/dist-cjs/lib/shapes/arrow/arrowTargetState.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/elbow/elbowArrowSnapLines.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/elbow/getElbowArrowInfo.js +1 -1
- package/dist-cjs/lib/shapes/arrow/elbow/getElbowArrowInfo.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/shared.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/toolStates/Idle.js +4 -10
- package/dist-cjs/lib/shapes/arrow/toolStates/Idle.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.js +7 -4
- package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/shapes/bookmark/BookmarkShapeUtil.js +1 -1
- package/dist-cjs/lib/shapes/bookmark/BookmarkShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/bookmark/bookmarks.js.map +2 -2
- package/dist-cjs/lib/shapes/draw/DrawShapeUtil.js +25 -23
- package/dist-cjs/lib/shapes/draw/DrawShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/draw/getPath.js +20 -11
- package/dist-cjs/lib/shapes/draw/getPath.js.map +2 -2
- package/dist-cjs/lib/shapes/draw/toolStates/Drawing.js +82 -86
- package/dist-cjs/lib/shapes/draw/toolStates/Drawing.js.map +3 -3
- package/dist-cjs/lib/shapes/embed/EmbedShapeUtil.js +6 -0
- package/dist-cjs/lib/shapes/embed/EmbedShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/frame/FrameShapeTool.js.map +1 -1
- package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js +7 -13
- package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/geo/GeoShapeUtil.js +146 -142
- package/dist-cjs/lib/shapes/geo/GeoShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/geo/toolStates/Idle.js +5 -10
- package/dist-cjs/lib/shapes/geo/toolStates/Idle.js.map +2 -2
- package/dist-cjs/lib/shapes/geo/toolStates/Pointing.js +3 -3
- package/dist-cjs/lib/shapes/geo/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/shapes/highlight/HighlightShapeUtil.js +23 -21
- package/dist-cjs/lib/shapes/highlight/HighlightShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/line/toolStates/Pointing.js +3 -3
- package/dist-cjs/lib/shapes/line/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/shapes/note/NoteShapeUtil.js +6 -11
- package/dist-cjs/lib/shapes/note/NoteShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/note/noteHelpers.js.map +2 -2
- package/dist-cjs/lib/shapes/note/toolStates/Pointing.js +5 -10
- package/dist-cjs/lib/shapes/note/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/HyperlinkButton.js +3 -2
- package/dist-cjs/lib/shapes/shared/HyperlinkButton.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/PlainTextLabel.js +14 -2
- package/dist-cjs/lib/shapes/shared/PlainTextLabel.js.map +3 -3
- package/dist-cjs/lib/shapes/shared/RichTextLabel.js +12 -4
- package/dist-cjs/lib/shapes/shared/RichTextLabel.js.map +3 -3
- package/dist-cjs/lib/shapes/shared/ShapeFill.js +2 -2
- package/dist-cjs/lib/shapes/shared/ShapeFill.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/crop.js +1 -0
- package/dist-cjs/lib/shapes/shared/crop.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/interpolate-props.js +3 -3
- package/dist-cjs/lib/shapes/shared/interpolate-props.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/useEditablePlainText.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/useEditableRichText.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/{useForceSolid.js → useEfficientZoomThreshold.js} +10 -7
- package/dist-cjs/lib/shapes/shared/useEfficientZoomThreshold.js.map +7 -0
- package/dist-cjs/lib/shapes/shared/useImageOrVideoAsset.js +1 -1
- package/dist-cjs/lib/shapes/shared/useImageOrVideoAsset.js.map +2 -2
- package/dist-cjs/lib/shapes/text/RichTextArea.js +5 -0
- package/dist-cjs/lib/shapes/text/RichTextArea.js.map +2 -2
- package/dist-cjs/lib/shapes/text/TextShapeUtil.js +5 -2
- package/dist-cjs/lib/shapes/text/TextShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/text/toolStates/Idle.js +4 -10
- package/dist-cjs/lib/shapes/text/toolStates/Idle.js.map +2 -2
- package/dist-cjs/lib/shapes/text/toolStates/Pointing.js +7 -5
- package/dist-cjs/lib/shapes/text/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/shapes/video/VideoShapeUtil.js +1 -1
- package/dist-cjs/lib/shapes/video/VideoShapeUtil.js.map +2 -2
- package/dist-cjs/lib/tools/EraserTool/childStates/Erasing.js +12 -6
- package/dist-cjs/lib/tools/EraserTool/childStates/Erasing.js.map +2 -2
- package/dist-cjs/lib/tools/EraserTool/childStates/Pointing.js +2 -4
- package/dist-cjs/lib/tools/EraserTool/childStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/tools/HandTool/HandTool.js +3 -5
- package/dist-cjs/lib/tools/HandTool/HandTool.js.map +2 -2
- package/dist-cjs/lib/tools/HandTool/childStates/Dragging.js +3 -2
- package/dist-cjs/lib/tools/HandTool/childStates/Dragging.js.map +2 -2
- package/dist-cjs/lib/tools/HandTool/childStates/Pointing.js +1 -1
- package/dist-cjs/lib/tools/HandTool/childStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/tools/LaserTool/childStates/Lasering.js +1 -1
- package/dist-cjs/lib/tools/LaserTool/childStates/Lasering.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/DragAndDropManager.js +10 -11
- package/dist-cjs/lib/tools/SelectTool/DragAndDropManager.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Brushing.js +20 -6
- package/dist-cjs/lib/tools/SelectTool/childStates/Brushing.js.map +3 -3
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/Cropping.js +4 -6
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/Cropping.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/Idle.js +1 -1
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/Idle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.js +1 -1
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/PointingCropHandle.js +1 -1
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/PointingCropHandle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.js +2 -1
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.js +1 -1
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js +8 -6
- package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/EditingShape.js +38 -11
- package/dist-cjs/lib/tools/SelectTool/childStates/EditingShape.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Idle.js +42 -50
- package/dist-cjs/lib/tools/SelectTool/childStates/Idle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingArrowLabel.js +6 -6
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingArrowLabel.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingCanvas.js +1 -1
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingCanvas.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingHandle.js +4 -14
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingHandle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingResizeHandle.js +1 -1
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingResizeHandle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingRotateHandle.js +1 -1
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingRotateHandle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingSelection.js +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingSelection.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingShape.js +4 -13
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingShape.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js +5 -6
- package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Rotating.js +2 -3
- package/dist-cjs/lib/tools/SelectTool/childStates/Rotating.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/ScribbleBrushing.js +22 -8
- package/dist-cjs/lib/tools/SelectTool/childStates/ScribbleBrushing.js.map +3 -3
- package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js +13 -11
- package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/selectHelpers.js +15 -4
- package/dist-cjs/lib/tools/SelectTool/selectHelpers.js.map +2 -2
- package/dist-cjs/lib/tools/ZoomTool/ZoomTool.js +1 -1
- package/dist-cjs/lib/tools/ZoomTool/ZoomTool.js.map +2 -2
- package/dist-cjs/lib/tools/ZoomTool/childStates/Pointing.js +3 -3
- package/dist-cjs/lib/tools/ZoomTool/childStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/tools/ZoomTool/childStates/ZoomBrushing.js +5 -6
- package/dist-cjs/lib/tools/ZoomTool/childStates/ZoomBrushing.js.map +2 -2
- package/dist-cjs/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.js +1 -3
- package/dist-cjs/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.js.map +2 -2
- package/dist-cjs/lib/tools/selection-logic/selectOnCanvasPointerUp.js +1 -1
- package/dist-cjs/lib/tools/selection-logic/selectOnCanvasPointerUp.js.map +2 -2
- package/dist-cjs/lib/tools/selection-logic/updateHoveredShapeId.js +1 -1
- package/dist-cjs/lib/tools/selection-logic/updateHoveredShapeId.js.map +2 -2
- package/dist-cjs/lib/ui/TldrawUi.js +2 -2
- package/dist-cjs/lib/ui/TldrawUi.js.map +2 -2
- package/dist-cjs/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.js +3 -9
- package/dist-cjs/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.js.map +2 -2
- package/dist-cjs/lib/ui/components/ContextMenu/DefaultContextMenu.js +1 -3
- package/dist-cjs/lib/ui/components/ContextMenu/DefaultContextMenu.js.map +2 -2
- package/dist-cjs/lib/ui/components/CursorChatBubble.js +1 -1
- package/dist-cjs/lib/ui/components/CursorChatBubble.js.map +2 -2
- package/dist-cjs/lib/ui/components/DefaultDebugPanel.js +2 -22
- package/dist-cjs/lib/ui/components/DefaultDebugPanel.js.map +2 -2
- package/dist-cjs/lib/ui/components/EditLinkDialog.js +11 -1
- package/dist-cjs/lib/ui/components/EditLinkDialog.js.map +2 -2
- package/dist-cjs/lib/ui/components/HelperButtons/BackToContent.js +1 -1
- package/dist-cjs/lib/ui/components/HelperButtons/BackToContent.js.map +2 -2
- package/dist-cjs/lib/ui/components/HelperButtons/StopFollowing.js.map +2 -2
- package/dist-cjs/lib/ui/components/Minimap/DefaultMinimap.js +1 -1
- package/dist-cjs/lib/ui/components/Minimap/DefaultMinimap.js.map +2 -2
- package/dist-cjs/lib/ui/components/OfflineIndicator/OfflineIndicator.js +2 -15
- package/dist-cjs/lib/ui/components/OfflineIndicator/OfflineIndicator.js.map +3 -3
- package/dist-cjs/lib/ui/components/PageMenu/PageItemInput.js +3 -1
- package/dist-cjs/lib/ui/components/PageMenu/PageItemInput.js.map +2 -2
- package/dist-cjs/lib/ui/components/SharePanel/PeopleMenu.js +6 -0
- package/dist-cjs/lib/ui/components/SharePanel/PeopleMenu.js.map +2 -2
- package/dist-cjs/lib/ui/components/Toolbar/AltTextEditor.js.map +2 -2
- package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbar.js +1 -1
- package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbar.js.map +2 -2
- package/dist-cjs/lib/ui/components/Toolbar/DefaultRichTextToolbar.js +1 -1
- package/dist-cjs/lib/ui/components/Toolbar/DefaultRichTextToolbar.js.map +2 -2
- package/dist-cjs/lib/ui/components/TopPanel/CenteredTopPanelContainer.js.map +1 -1
- package/dist-cjs/lib/ui/components/menu-items.js +3 -1
- package/dist-cjs/lib/ui/components/menu-items.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiContextualToolbar.js +3 -1
- package/dist-cjs/lib/ui/components/primitives/TldrawUiContextualToolbar.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiSlider.js +1 -1
- package/dist-cjs/lib/ui/components/primitives/TldrawUiSlider.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js +149 -93
- package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuActionCheckboxItem.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuActionItem.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js +14 -7
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js.map +2 -2
- package/dist-cjs/lib/ui/context/actions.js +7 -8
- package/dist-cjs/lib/ui/context/actions.js.map +2 -2
- package/dist-cjs/lib/ui/context/components.js +1 -2
- package/dist-cjs/lib/ui/context/components.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/menu-hooks.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/useClipboardEvents.js +2 -2
- package/dist-cjs/lib/ui/hooks/useClipboardEvents.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/useFlatten.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/useKeyboardShortcuts.js +2 -2
- package/dist-cjs/lib/ui/hooks/useKeyboardShortcuts.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/useTools.js +4 -5
- package/dist-cjs/lib/ui/hooks/useTools.js.map +2 -2
- package/dist-cjs/lib/ui/version.js +3 -3
- package/dist-cjs/lib/ui/version.js.map +1 -1
- package/dist-cjs/lib/utils/excalidraw/putExcalidrawContent.js +16 -6
- package/dist-cjs/lib/utils/excalidraw/putExcalidrawContent.js.map +2 -2
- package/dist-cjs/lib/utils/export/exportAs.js.map +2 -2
- package/dist-cjs/lib/utils/frames/frames.js.map +2 -2
- package/dist-cjs/lib/{tools/selection-logic/getShouldEnterCropModeOnPointerDown.js → utils/test-helpers.js} +21 -8
- package/dist-cjs/lib/utils/test-helpers.js.map +7 -0
- package/dist-cjs/lib/utils/text/richText.js +15 -19
- package/dist-cjs/lib/utils/text/richText.js.map +3 -3
- package/dist-cjs/lib/utils/tldr/buildFromV1Document.js +7 -2
- package/dist-cjs/lib/utils/tldr/buildFromV1Document.js.map +2 -2
- package/dist-esm/index.d.mts +311 -242
- package/dist-esm/index.mjs +14 -5
- package/dist-esm/index.mjs.map +2 -2
- package/dist-esm/lib/bindings/arrow/ArrowBindingUtil.mjs.map +2 -2
- package/dist-esm/lib/canvas/TldrawSelectionForeground.mjs +2 -2
- package/dist-esm/lib/canvas/TldrawSelectionForeground.mjs.map +2 -2
- package/dist-esm/lib/defaultEmbedDefinitions.mjs +1 -1
- package/dist-esm/lib/defaultEmbedDefinitions.mjs.map +2 -2
- package/dist-esm/lib/defaultExternalContentHandlers.mjs +5 -5
- package/dist-esm/lib/defaultExternalContentHandlers.mjs.map +2 -2
- package/dist-esm/lib/defaultSideEffects.mjs +6 -1
- package/dist-esm/lib/defaultSideEffects.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs +15 -15
- package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/arrowLabel.mjs +1 -1
- package/dist-esm/lib/shapes/arrow/arrowLabel.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/arrowTargetState.mjs +1 -1
- package/dist-esm/lib/shapes/arrow/arrowTargetState.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/elbow/elbowArrowSnapLines.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/elbow/getElbowArrowInfo.mjs +1 -1
- package/dist-esm/lib/shapes/arrow/elbow/getElbowArrowInfo.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/shared.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/toolStates/Idle.mjs +4 -10
- package/dist-esm/lib/shapes/arrow/toolStates/Idle.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs +7 -4
- package/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/shapes/bookmark/BookmarkShapeUtil.mjs +1 -1
- package/dist-esm/lib/shapes/bookmark/BookmarkShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/bookmark/bookmarks.mjs.map +2 -2
- package/dist-esm/lib/shapes/draw/DrawShapeUtil.mjs +30 -25
- package/dist-esm/lib/shapes/draw/DrawShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/draw/getPath.mjs +21 -11
- package/dist-esm/lib/shapes/draw/getPath.mjs.map +2 -2
- package/dist-esm/lib/shapes/draw/toolStates/Drawing.mjs +83 -86
- package/dist-esm/lib/shapes/draw/toolStates/Drawing.mjs.map +3 -3
- package/dist-esm/lib/shapes/embed/EmbedShapeUtil.mjs +6 -0
- package/dist-esm/lib/shapes/embed/EmbedShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/frame/FrameShapeTool.mjs.map +1 -1
- package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs +7 -13
- package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/geo/GeoShapeUtil.mjs +147 -142
- package/dist-esm/lib/shapes/geo/GeoShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/geo/toolStates/Idle.mjs +5 -10
- package/dist-esm/lib/shapes/geo/toolStates/Idle.mjs.map +2 -2
- package/dist-esm/lib/shapes/geo/toolStates/Pointing.mjs +3 -3
- package/dist-esm/lib/shapes/geo/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/shapes/highlight/HighlightShapeUtil.mjs +24 -22
- package/dist-esm/lib/shapes/highlight/HighlightShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/line/toolStates/Pointing.mjs +3 -3
- package/dist-esm/lib/shapes/line/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs +7 -12
- package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/note/noteHelpers.mjs.map +2 -2
- package/dist-esm/lib/shapes/note/toolStates/Pointing.mjs +5 -10
- package/dist-esm/lib/shapes/note/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/HyperlinkButton.mjs +4 -3
- package/dist-esm/lib/shapes/shared/HyperlinkButton.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/PlainTextLabel.mjs +14 -2
- package/dist-esm/lib/shapes/shared/PlainTextLabel.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/RichTextLabel.mjs +12 -4
- package/dist-esm/lib/shapes/shared/RichTextLabel.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/ShapeFill.mjs +2 -2
- package/dist-esm/lib/shapes/shared/ShapeFill.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/crop.mjs +1 -0
- package/dist-esm/lib/shapes/shared/crop.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/interpolate-props.mjs +4 -4
- package/dist-esm/lib/shapes/shared/interpolate-props.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/useEditablePlainText.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/useEditableRichText.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/useEfficientZoomThreshold.mjs +12 -0
- package/dist-esm/lib/shapes/shared/useEfficientZoomThreshold.mjs.map +7 -0
- package/dist-esm/lib/shapes/shared/useImageOrVideoAsset.mjs +1 -1
- package/dist-esm/lib/shapes/shared/useImageOrVideoAsset.mjs.map +2 -2
- package/dist-esm/lib/shapes/text/RichTextArea.mjs +5 -0
- package/dist-esm/lib/shapes/text/RichTextArea.mjs.map +2 -2
- package/dist-esm/lib/shapes/text/TextShapeUtil.mjs +5 -2
- package/dist-esm/lib/shapes/text/TextShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/text/toolStates/Idle.mjs +4 -10
- package/dist-esm/lib/shapes/text/toolStates/Idle.mjs.map +2 -2
- package/dist-esm/lib/shapes/text/toolStates/Pointing.mjs +7 -5
- package/dist-esm/lib/shapes/text/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/shapes/video/VideoShapeUtil.mjs +1 -1
- package/dist-esm/lib/shapes/video/VideoShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/tools/EraserTool/childStates/Erasing.mjs +13 -6
- package/dist-esm/lib/tools/EraserTool/childStates/Erasing.mjs.map +2 -2
- package/dist-esm/lib/tools/EraserTool/childStates/Pointing.mjs +3 -8
- package/dist-esm/lib/tools/EraserTool/childStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/tools/HandTool/HandTool.mjs +3 -5
- package/dist-esm/lib/tools/HandTool/HandTool.mjs.map +2 -2
- package/dist-esm/lib/tools/HandTool/childStates/Dragging.mjs +3 -2
- package/dist-esm/lib/tools/HandTool/childStates/Dragging.mjs.map +2 -2
- package/dist-esm/lib/tools/HandTool/childStates/Pointing.mjs +1 -1
- package/dist-esm/lib/tools/HandTool/childStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/tools/LaserTool/childStates/Lasering.mjs +1 -1
- package/dist-esm/lib/tools/LaserTool/childStates/Lasering.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/DragAndDropManager.mjs +10 -11
- package/dist-esm/lib/tools/SelectTool/DragAndDropManager.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Brushing.mjs +20 -6
- package/dist-esm/lib/tools/SelectTool/childStates/Brushing.mjs.map +3 -3
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/Cropping.mjs +4 -6
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/Cropping.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/Idle.mjs +1 -1
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/Idle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.mjs +1 -1
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCropHandle.mjs +1 -1
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCropHandle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.mjs +2 -1
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.mjs +1 -1
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs +8 -6
- package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/EditingShape.mjs +38 -11
- package/dist-esm/lib/tools/SelectTool/childStates/EditingShape.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Idle.mjs +43 -51
- package/dist-esm/lib/tools/SelectTool/childStates/Idle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingArrowLabel.mjs +6 -6
- package/dist-esm/lib/tools/SelectTool/childStates/PointingArrowLabel.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingCanvas.mjs +1 -1
- package/dist-esm/lib/tools/SelectTool/childStates/PointingCanvas.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingHandle.mjs +6 -19
- package/dist-esm/lib/tools/SelectTool/childStates/PointingHandle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingResizeHandle.mjs +1 -1
- package/dist-esm/lib/tools/SelectTool/childStates/PointingResizeHandle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingRotateHandle.mjs +1 -1
- package/dist-esm/lib/tools/SelectTool/childStates/PointingRotateHandle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingSelection.mjs +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingSelection.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingShape.mjs +4 -13
- package/dist-esm/lib/tools/SelectTool/childStates/PointingShape.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs +5 -6
- package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Rotating.mjs +2 -3
- package/dist-esm/lib/tools/SelectTool/childStates/Rotating.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/ScribbleBrushing.mjs +23 -8
- package/dist-esm/lib/tools/SelectTool/childStates/ScribbleBrushing.mjs.map +3 -3
- package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs +13 -11
- package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/selectHelpers.mjs +17 -4
- package/dist-esm/lib/tools/SelectTool/selectHelpers.mjs.map +2 -2
- package/dist-esm/lib/tools/ZoomTool/ZoomTool.mjs +1 -1
- package/dist-esm/lib/tools/ZoomTool/ZoomTool.mjs.map +2 -2
- package/dist-esm/lib/tools/ZoomTool/childStates/Pointing.mjs +3 -3
- package/dist-esm/lib/tools/ZoomTool/childStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/tools/ZoomTool/childStates/ZoomBrushing.mjs +5 -6
- package/dist-esm/lib/tools/ZoomTool/childStates/ZoomBrushing.mjs.map +2 -2
- package/dist-esm/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.mjs +1 -3
- package/dist-esm/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.mjs.map +2 -2
- package/dist-esm/lib/tools/selection-logic/selectOnCanvasPointerUp.mjs +1 -1
- package/dist-esm/lib/tools/selection-logic/selectOnCanvasPointerUp.mjs.map +2 -2
- package/dist-esm/lib/tools/selection-logic/updateHoveredShapeId.mjs +1 -1
- package/dist-esm/lib/tools/selection-logic/updateHoveredShapeId.mjs.map +2 -2
- package/dist-esm/lib/ui/TldrawUi.mjs +2 -2
- package/dist-esm/lib/ui/TldrawUi.mjs.map +2 -2
- package/dist-esm/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.mjs +2 -8
- package/dist-esm/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.mjs.map +2 -2
- package/dist-esm/lib/ui/components/ContextMenu/DefaultContextMenu.mjs +1 -3
- package/dist-esm/lib/ui/components/ContextMenu/DefaultContextMenu.mjs.map +2 -2
- package/dist-esm/lib/ui/components/CursorChatBubble.mjs +1 -1
- package/dist-esm/lib/ui/components/CursorChatBubble.mjs.map +2 -2
- package/dist-esm/lib/ui/components/DefaultDebugPanel.mjs +4 -31
- package/dist-esm/lib/ui/components/DefaultDebugPanel.mjs.map +2 -2
- package/dist-esm/lib/ui/components/EditLinkDialog.mjs +11 -1
- package/dist-esm/lib/ui/components/EditLinkDialog.mjs.map +2 -2
- package/dist-esm/lib/ui/components/HelperButtons/BackToContent.mjs +1 -1
- package/dist-esm/lib/ui/components/HelperButtons/BackToContent.mjs.map +2 -2
- package/dist-esm/lib/ui/components/HelperButtons/StopFollowing.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Minimap/DefaultMinimap.mjs +1 -1
- package/dist-esm/lib/ui/components/Minimap/DefaultMinimap.mjs.map +2 -2
- package/dist-esm/lib/ui/components/OfflineIndicator/OfflineIndicator.mjs +3 -6
- package/dist-esm/lib/ui/components/OfflineIndicator/OfflineIndicator.mjs.map +2 -2
- package/dist-esm/lib/ui/components/PageMenu/PageItemInput.mjs +3 -1
- package/dist-esm/lib/ui/components/PageMenu/PageItemInput.mjs.map +2 -2
- package/dist-esm/lib/ui/components/SharePanel/PeopleMenu.mjs +6 -0
- package/dist-esm/lib/ui/components/SharePanel/PeopleMenu.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Toolbar/AltTextEditor.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbar.mjs +1 -1
- package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbar.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Toolbar/DefaultRichTextToolbar.mjs +1 -1
- package/dist-esm/lib/ui/components/Toolbar/DefaultRichTextToolbar.mjs.map +2 -2
- package/dist-esm/lib/ui/components/TopPanel/CenteredTopPanelContainer.mjs.map +1 -1
- package/dist-esm/lib/ui/components/menu-items.mjs +4 -5
- package/dist-esm/lib/ui/components/menu-items.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiContextualToolbar.mjs +3 -1
- package/dist-esm/lib/ui/components/primitives/TldrawUiContextualToolbar.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiSlider.mjs +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiSlider.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs +157 -95
- package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuActionCheckboxItem.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuActionItem.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs +15 -8
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs.map +2 -2
- package/dist-esm/lib/ui/context/actions.mjs +7 -8
- package/dist-esm/lib/ui/context/actions.mjs.map +2 -2
- package/dist-esm/lib/ui/context/components.mjs +1 -2
- package/dist-esm/lib/ui/context/components.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/menu-hooks.mjs +1 -4
- package/dist-esm/lib/ui/hooks/menu-hooks.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/useClipboardEvents.mjs +2 -2
- package/dist-esm/lib/ui/hooks/useClipboardEvents.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/useFlatten.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/useKeyboardShortcuts.mjs +2 -2
- package/dist-esm/lib/ui/hooks/useKeyboardShortcuts.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/useTools.mjs +4 -5
- package/dist-esm/lib/ui/hooks/useTools.mjs.map +2 -2
- package/dist-esm/lib/ui/version.mjs +3 -3
- package/dist-esm/lib/ui/version.mjs.map +1 -1
- package/dist-esm/lib/utils/excalidraw/putExcalidrawContent.mjs +17 -6
- package/dist-esm/lib/utils/excalidraw/putExcalidrawContent.mjs.map +2 -2
- package/dist-esm/lib/utils/export/exportAs.mjs +1 -3
- package/dist-esm/lib/utils/export/exportAs.mjs.map +2 -2
- package/dist-esm/lib/utils/frames/frames.mjs.map +2 -2
- package/dist-esm/lib/utils/test-helpers.mjs +21 -0
- package/dist-esm/lib/utils/test-helpers.mjs.map +7 -0
- package/dist-esm/lib/utils/text/richText.mjs +12 -5
- package/dist-esm/lib/utils/text/richText.mjs.map +2 -2
- package/dist-esm/lib/utils/tldr/buildFromV1Document.mjs +8 -2
- package/dist-esm/lib/utils/tldr/buildFromV1Document.mjs.map +2 -2
- package/package.json +18 -16
- package/src/index.ts +6 -2
- package/src/lib/Tldraw.test.tsx +46 -1
- package/src/lib/bindings/arrow/ArrowBindingUtil.ts +1 -1
- package/src/lib/canvas/TldrawSelectionForeground.tsx +6 -11
- package/src/lib/defaultEmbedDefinitions.ts +2 -1
- package/src/lib/defaultExternalContentHandlers.ts +13 -14
- package/src/lib/defaultSideEffects.ts +6 -1
- package/src/lib/shapes/arrow/ArrowShapeOptions.test.ts +40 -133
- package/src/lib/shapes/arrow/ArrowShapeTool.test.ts +8 -8
- package/src/lib/shapes/arrow/ArrowShapeUtil.test.ts +2 -2
- package/src/lib/shapes/arrow/ArrowShapeUtil.tsx +16 -16
- package/src/lib/shapes/arrow/arrow-types.ts +2 -0
- package/src/lib/shapes/arrow/arrowLabel.ts +2 -2
- package/src/lib/shapes/arrow/arrowTargetState.ts +2 -2
- package/src/lib/shapes/arrow/elbow/elbowArrowSnapLines.tsx +3 -3
- package/src/lib/shapes/arrow/elbow/getElbowArrowInfo.test.ts +80 -0
- package/src/lib/shapes/arrow/elbow/getElbowArrowInfo.tsx +1 -1
- package/src/lib/shapes/arrow/shared.ts +4 -4
- package/src/lib/shapes/arrow/toolStates/Idle.tsx +4 -14
- package/src/lib/shapes/arrow/toolStates/Pointing.tsx +8 -5
- package/src/lib/shapes/bookmark/BookmarkShapeUtil.tsx +1 -1
- package/src/lib/shapes/bookmark/bookmarks.ts +3 -3
- package/src/lib/shapes/draw/DrawShapeUtil.test.ts +146 -0
- package/src/lib/shapes/draw/DrawShapeUtil.tsx +33 -27
- package/src/lib/shapes/draw/getPath.ts +31 -10
- package/src/lib/shapes/draw/toolStates/Drawing.ts +100 -90
- package/src/lib/shapes/embed/EmbedShapeUtil.tsx +8 -1
- package/src/lib/shapes/frame/FrameShapeTool.ts +1 -1
- package/src/lib/shapes/frame/FrameShapeUtil.tsx +11 -11
- package/src/lib/shapes/geo/GeoShapeUtil.test.tsx +10 -2
- package/src/lib/shapes/geo/GeoShapeUtil.tsx +228 -176
- package/src/lib/shapes/geo/toolStates/Idle.ts +5 -15
- package/src/lib/shapes/geo/toolStates/Pointing.ts +6 -6
- package/src/lib/shapes/highlight/HighlightShapeUtil.test.ts +146 -0
- package/src/lib/shapes/highlight/HighlightShapeUtil.tsx +27 -24
- package/src/lib/shapes/line/LineShapeTool.test.ts +6 -6
- package/src/lib/shapes/line/LineShapeUtil.test.tsx +5 -5
- package/src/lib/shapes/line/toolStates/Pointing.ts +4 -4
- package/src/lib/shapes/note/NoteShapeTool.test.ts +2 -1
- package/src/lib/shapes/note/NoteShapeUtil.tsx +9 -10
- package/src/lib/shapes/note/noteCloning.test.ts +3 -1
- package/src/lib/shapes/note/noteHelpers.ts +2 -2
- package/src/lib/shapes/note/toolStates/Pointing.ts +5 -10
- package/src/lib/shapes/shared/HyperlinkButton.tsx +4 -3
- package/src/lib/shapes/shared/PlainTextLabel.tsx +12 -2
- package/src/lib/shapes/shared/RichTextLabel.tsx +14 -4
- package/src/lib/shapes/shared/ShapeFill.tsx +2 -2
- package/src/lib/shapes/shared/crop.ts +1 -0
- package/src/lib/shapes/shared/interpolate-props.ts +4 -4
- package/src/lib/shapes/shared/useEditablePlainText.ts +7 -3
- package/src/lib/shapes/shared/useEditableRichText.ts +7 -3
- package/src/lib/shapes/shared/useEfficientZoomThreshold.ts +10 -0
- package/src/lib/shapes/shared/useImageOrVideoAsset.ts +1 -1
- package/src/lib/shapes/text/RichTextArea.tsx +5 -0
- package/src/lib/shapes/text/TextShapeTool.test.ts +4 -4
- package/src/lib/shapes/text/TextShapeUtil.tsx +5 -0
- package/src/lib/shapes/text/toolStates/Idle.ts +4 -14
- package/src/lib/shapes/text/toolStates/Pointing.ts +8 -8
- package/src/lib/shapes/video/VideoShapeUtil.tsx +2 -1
- package/src/lib/tools/EraserTool/childStates/Erasing.ts +21 -11
- package/src/lib/tools/EraserTool/childStates/Pointing.ts +5 -20
- package/src/lib/tools/HandTool/HandTool.ts +3 -5
- package/src/lib/tools/HandTool/childStates/Dragging.ts +3 -2
- package/src/lib/tools/HandTool/childStates/Pointing.ts +1 -1
- package/src/lib/tools/LaserTool/childStates/Lasering.ts +1 -1
- package/src/lib/tools/SelectTool/DragAndDropManager.ts +14 -11
- package/src/lib/tools/SelectTool/childStates/Brushing.ts +30 -14
- package/src/lib/tools/SelectTool/childStates/Crop/children/Cropping.ts +7 -6
- package/src/lib/tools/SelectTool/childStates/Crop/children/Idle.ts +3 -4
- package/src/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.ts +1 -1
- package/src/lib/tools/SelectTool/childStates/Crop/children/PointingCropHandle.ts +1 -1
- package/src/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.ts +2 -1
- package/src/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.ts +1 -1
- package/src/lib/tools/SelectTool/childStates/DraggingHandle.tsx +11 -12
- package/src/lib/tools/SelectTool/childStates/EditingShape.ts +57 -16
- package/src/lib/tools/SelectTool/childStates/Idle.ts +64 -81
- package/src/lib/tools/SelectTool/childStates/PointingArrowLabel.ts +7 -8
- package/src/lib/tools/SelectTool/childStates/PointingCanvas.ts +1 -1
- package/src/lib/tools/SelectTool/childStates/PointingHandle.ts +9 -17
- package/src/lib/tools/SelectTool/childStates/PointingResizeHandle.ts +1 -1
- package/src/lib/tools/SelectTool/childStates/PointingRotateHandle.ts +1 -1
- package/src/lib/tools/SelectTool/childStates/PointingSelection.ts +4 -4
- package/src/lib/tools/SelectTool/childStates/PointingShape.ts +4 -14
- package/src/lib/tools/SelectTool/childStates/Resizing.ts +8 -10
- package/src/lib/tools/SelectTool/childStates/Rotating.ts +2 -3
- package/src/lib/tools/SelectTool/childStates/ScribbleBrushing.ts +34 -14
- package/src/lib/tools/SelectTool/childStates/Translating.ts +16 -15
- package/src/lib/tools/SelectTool/selectHelpers.ts +39 -4
- package/src/lib/tools/ZoomTool/ZoomTool.ts +1 -1
- package/src/lib/tools/ZoomTool/childStates/Pointing.ts +3 -3
- package/src/lib/tools/ZoomTool/childStates/ZoomBrushing.ts +5 -6
- package/src/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.ts +1 -3
- package/src/lib/tools/selection-logic/selectOnCanvasPointerUp.ts +1 -1
- package/src/lib/tools/selection-logic/updateHoveredShapeId.ts +1 -1
- package/src/lib/ui/TldrawUi.tsx +5 -2
- package/src/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.tsx +1 -9
- package/src/lib/ui/components/ContextMenu/DefaultContextMenu.tsx +1 -3
- package/src/lib/ui/components/CursorChatBubble.tsx +2 -2
- package/src/lib/ui/components/DefaultDebugPanel.tsx +4 -43
- package/src/lib/ui/components/EditLinkDialog.tsx +16 -6
- package/src/lib/ui/components/HelperButtons/BackToContent.tsx +1 -1
- package/src/lib/ui/components/HelperButtons/StopFollowing.tsx +2 -2
- package/src/lib/ui/components/Minimap/DefaultMinimap.tsx +1 -1
- package/src/lib/ui/components/OfflineIndicator/OfflineIndicator.tsx +6 -5
- package/src/lib/ui/components/PageMenu/PageItemInput.tsx +3 -1
- package/src/lib/ui/components/SharePanel/PeopleMenu.tsx +8 -0
- package/src/lib/ui/components/Toolbar/AltTextEditor.tsx +2 -2
- package/src/lib/ui/components/Toolbar/DefaultImageToolbar.tsx +1 -1
- package/src/lib/ui/components/Toolbar/DefaultRichTextToolbar.tsx +1 -1
- package/src/lib/ui/components/TopPanel/CenteredTopPanelContainer.tsx +1 -1
- package/src/lib/ui/components/menu-items.tsx +9 -15
- package/src/lib/ui/components/primitives/TldrawUiContextualToolbar.tsx +5 -3
- package/src/lib/ui/components/primitives/TldrawUiSlider.tsx +2 -2
- package/src/lib/ui/components/primitives/TldrawUiTooltip.tsx +208 -113
- package/src/lib/ui/components/primitives/menus/TldrawUiMenuActionCheckboxItem.tsx +1 -1
- package/src/lib/ui/components/primitives/menus/TldrawUiMenuActionItem.tsx +1 -1
- package/src/lib/ui/components/primitives/menus/TldrawUiMenuItem.tsx +7 -4
- package/src/lib/ui/context/actions.tsx +15 -19
- package/src/lib/ui/context/components.tsx +1 -2
- package/src/lib/ui/hooks/menu-hooks.ts +9 -19
- package/src/lib/ui/hooks/useClipboardEvents.ts +2 -2
- package/src/lib/ui/hooks/useFlatten.ts +1 -2
- package/src/lib/ui/hooks/useKeyboardShortcuts.ts +2 -2
- package/src/lib/ui/hooks/useTools.tsx +5 -7
- package/src/lib/ui/version.ts +3 -3
- package/src/lib/ui.css +27 -23
- package/src/lib/utils/excalidraw/__snapshots__/putExcalidrawContent.test.tsx.snap +12 -48
- package/src/lib/utils/excalidraw/putExcalidrawContent.ts +19 -6
- package/src/lib/utils/export/exportAs.ts +2 -9
- package/src/lib/utils/frames/frames.ts +1 -1
- package/src/lib/utils/test-helpers.ts +62 -0
- package/src/lib/utils/text/richText.ts +13 -8
- package/src/lib/utils/tldr/buildFromV1Document.ts +21 -19
- package/src/test/Editor.test.tsx +78 -41
- package/src/test/EraserTool.test.ts +10 -12
- package/src/test/SelectTool.test.ts +11 -19
- package/src/test/TestEditor.ts +49 -51
- package/src/test/TldrawEditor.test.tsx +24 -20
- package/src/test/__snapshots__/drawing.test.ts.snap +3 -1257
- package/src/test/__snapshots__/resizing.test.ts.snap +3 -12
- package/src/test/arrows-megabus.test.tsx +1 -1
- package/src/test/bindings.test.tsx +29 -25
- package/src/test/bindingsIndex.test.tsx +4 -4
- package/src/test/commands/__snapshots__/getSvgString.test.ts.snap +10 -10
- package/src/test/commands/cameraState.test.ts +299 -0
- package/src/test/commands/createShape.test.ts +64 -0
- package/src/test/commands/createShapes.test.ts +15 -1
- package/src/test/commands/getSvgString.test.ts +2 -2
- package/src/test/commands/isShapeOfType.test.ts +44 -0
- package/src/test/commands/putContent.test.ts +80 -1
- package/src/test/commands/setCamera.test.ts +13 -11
- package/src/test/commands/stackShapes.test.ts +34 -8
- package/src/test/commands/updateShape.test.ts +67 -0
- package/src/test/commands/updateShapes.test.ts +21 -5
- package/src/test/commands/zoomToBounds.test.ts +19 -3
- package/src/test/commands/zoomToSelection.test.ts +14 -3
- package/src/test/custom-clipping.test.ts +52 -44
- package/src/test/customSnapping.test.tsx +77 -62
- package/src/test/drawing.test.ts +17 -10
- package/src/test/duplicate.test.ts +1 -1
- package/src/test/flipShapes.test.ts +33 -0
- package/src/test/frames.test.ts +94 -2
- package/src/test/getCulledShapes.test.tsx +11 -3
- package/src/test/getShapeAtPoint.test.ts +2 -2
- package/src/test/groups.test.tsx +7 -4
- package/src/test/modifiers.test.ts +6 -6
- package/src/test/notVisibleShapes.test.ts +698 -0
- package/src/test/resizing.test.ts +16 -22
- package/src/test/selection-omnibus.test.ts +13 -13
- package/src/test/shapeutils.test.ts +1 -1
- package/src/test/spacebarPanning.test.ts +28 -10
- package/src/test/styles2.test.tsx +1 -1
- package/src/test/styles3.test.ts +5 -5
- package/src/test/test-jsx.tsx +72 -57
- package/src/test/text.test.ts +15 -17
- package/src/test/translating.test.ts +6 -8
- package/src/test/ui/BackToContent.test.tsx +111 -0
- package/tldraw.css +41 -35
- package/dist-cjs/lib/shapes/shared/useForceSolid.js.map +0 -7
- package/dist-cjs/lib/tools/selection-logic/getShouldEnterCropModeOnPointerDown.js.map +0 -7
- package/dist-cjs/lib/ui/components/TopPanel/DefaultTopPanel.js +0 -32
- package/dist-cjs/lib/ui/components/TopPanel/DefaultTopPanel.js.map +0 -7
- package/dist-cjs/lib/utils/text/textDirection.js +0 -51
- package/dist-cjs/lib/utils/text/textDirection.js.map +0 -7
- package/dist-esm/lib/shapes/shared/useForceSolid.mjs +0 -9
- package/dist-esm/lib/shapes/shared/useForceSolid.mjs.map +0 -7
- package/dist-esm/lib/tools/selection-logic/getShouldEnterCropModeOnPointerDown.mjs +0 -8
- package/dist-esm/lib/tools/selection-logic/getShouldEnterCropModeOnPointerDown.mjs.map +0 -7
- package/dist-esm/lib/ui/components/TopPanel/DefaultTopPanel.mjs +0 -12
- package/dist-esm/lib/ui/components/TopPanel/DefaultTopPanel.mjs.map +0 -7
- package/dist-esm/lib/utils/text/textDirection.mjs +0 -31
- package/dist-esm/lib/utils/text/textDirection.mjs.map +0 -7
- package/src/lib/shapes/shared/useForceSolid.ts +0 -6
- package/src/lib/tools/selection-logic/getShouldEnterCropModeOnPointerDown.ts +0 -10
- package/src/lib/ui/components/TopPanel/DefaultTopPanel.tsx +0 -10
- package/src/lib/utils/text/textDirection.ts +0 -32
|
@@ -20,6 +20,7 @@ import { NoteShapeUtil } from '../lib/shapes/note/NoteShapeUtil'
|
|
|
20
20
|
import { TestEditor } from './TestEditor'
|
|
21
21
|
import { getSnapLines } from './getSnapLines'
|
|
22
22
|
import { roundedBox } from './roundedBox'
|
|
23
|
+
import { createDrawSegments } from './test-jsx'
|
|
23
24
|
|
|
24
25
|
vi.useFakeTimers()
|
|
25
26
|
|
|
@@ -904,15 +905,12 @@ describe('When resizing a shape with children', () => {
|
|
|
904
905
|
x: 100,
|
|
905
906
|
y: 100,
|
|
906
907
|
props: {
|
|
907
|
-
segments: [
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
],
|
|
914
|
-
},
|
|
915
|
-
],
|
|
908
|
+
segments: createDrawSegments([
|
|
909
|
+
[
|
|
910
|
+
{ x: 0, y: 0, z: 0.5 },
|
|
911
|
+
{ x: 100, y: 100, z: 0.5 },
|
|
912
|
+
],
|
|
913
|
+
]),
|
|
916
914
|
},
|
|
917
915
|
},
|
|
918
916
|
])
|
|
@@ -3876,10 +3874,8 @@ it('uses the cross cursor when create resizing', () => {
|
|
|
3876
3874
|
describe('Resizing text from the right edge', () => {
|
|
3877
3875
|
it('Resizes text from the right edge', () => {
|
|
3878
3876
|
const id = createShapeId()
|
|
3879
|
-
editor.createShapes
|
|
3880
|
-
editor.updateShapes
|
|
3881
|
-
{ id, type: 'text', props: { richText: toRichText('Hello World') } },
|
|
3882
|
-
]) // auto size
|
|
3877
|
+
editor.createShapes([{ id, type: 'text', props: { richText: toRichText('H') } }])
|
|
3878
|
+
editor.updateShapes([{ id, type: 'text', props: { richText: toRichText('Hello World') } }]) // auto size
|
|
3883
3879
|
|
|
3884
3880
|
editor.select(id)
|
|
3885
3881
|
|
|
@@ -3905,10 +3901,8 @@ describe('Resizing text from the right edge', () => {
|
|
|
3905
3901
|
editor.updateInstanceState({ isCoarsePointer: true })
|
|
3906
3902
|
|
|
3907
3903
|
const id = createShapeId()
|
|
3908
|
-
editor.createShapes
|
|
3909
|
-
editor.updateShapes
|
|
3910
|
-
{ id, type: 'text', props: { richText: toRichText('Hello World') } },
|
|
3911
|
-
]) // auto size
|
|
3904
|
+
editor.createShapes([{ id, type: 'text', props: { richText: toRichText('H') } }])
|
|
3905
|
+
editor.updateShapes([{ id, type: 'text', props: { richText: toRichText('Hello World') } }]) // auto size
|
|
3912
3906
|
|
|
3913
3907
|
editor.select(id)
|
|
3914
3908
|
|
|
@@ -3954,7 +3948,7 @@ describe('When resizing near the edges of the screen', () => {
|
|
|
3954
3948
|
|
|
3955
3949
|
describe('resizing text with autosize true', () => {
|
|
3956
3950
|
it('resizes text from the right side', () => {
|
|
3957
|
-
editor.createShape
|
|
3951
|
+
editor.createShape({
|
|
3958
3952
|
type: 'text',
|
|
3959
3953
|
x: 0,
|
|
3960
3954
|
y: 0,
|
|
@@ -3980,7 +3974,7 @@ describe('resizing text with autosize true', () => {
|
|
|
3980
3974
|
})
|
|
3981
3975
|
|
|
3982
3976
|
it('resizes text from the right side when alt key is pressed', () => {
|
|
3983
|
-
editor.createShape
|
|
3977
|
+
editor.createShape({
|
|
3984
3978
|
type: 'text',
|
|
3985
3979
|
x: 0,
|
|
3986
3980
|
y: 0,
|
|
@@ -4007,7 +4001,7 @@ describe('resizing text with autosize true', () => {
|
|
|
4007
4001
|
})
|
|
4008
4002
|
|
|
4009
4003
|
it('resizes text from the left side', () => {
|
|
4010
|
-
editor.createShape
|
|
4004
|
+
editor.createShape({
|
|
4011
4005
|
type: 'text',
|
|
4012
4006
|
x: 0,
|
|
4013
4007
|
y: 0,
|
|
@@ -4033,7 +4027,7 @@ describe('resizing text with autosize true', () => {
|
|
|
4033
4027
|
})
|
|
4034
4028
|
|
|
4035
4029
|
it('resizes text from the left side when alt is pressed', () => {
|
|
4036
|
-
editor.createShape
|
|
4030
|
+
editor.createShape({
|
|
4037
4031
|
type: 'text',
|
|
4038
4032
|
x: 0,
|
|
4039
4033
|
y: 0,
|
|
@@ -4062,7 +4056,7 @@ describe('resizing text with autosize true', () => {
|
|
|
4062
4056
|
|
|
4063
4057
|
describe('cancelling a resize operation', () => {
|
|
4064
4058
|
it('undoes any changes since the start of the resize operation', () => {
|
|
4065
|
-
editor.createShape
|
|
4059
|
+
editor.createShape({
|
|
4066
4060
|
type: 'geo',
|
|
4067
4061
|
x: 0,
|
|
4068
4062
|
y: 0,
|
|
@@ -76,7 +76,7 @@ describe('Hovering shapes', () => {
|
|
|
76
76
|
editor.pointerMove(50, 50)
|
|
77
77
|
expect(editor.getHoveredShapeId()).toBe(null)
|
|
78
78
|
|
|
79
|
-
editor.updateShape
|
|
79
|
+
editor.updateShape({
|
|
80
80
|
id: ids.box1,
|
|
81
81
|
type: 'geo',
|
|
82
82
|
props: { richText: toRichText('hello') },
|
|
@@ -88,7 +88,7 @@ describe('Hovering shapes', () => {
|
|
|
88
88
|
})
|
|
89
89
|
|
|
90
90
|
it('selects a shape with a full label on pointer down', () => {
|
|
91
|
-
editor.updateShape
|
|
91
|
+
editor.updateShape({
|
|
92
92
|
id: ids.box1,
|
|
93
93
|
type: 'geo',
|
|
94
94
|
props: { richText: toRichText('hello') },
|
|
@@ -462,7 +462,7 @@ describe('when shape is hollow', () => {
|
|
|
462
462
|
describe('when shape is a frame', () => {
|
|
463
463
|
let frame1: TLFrameShape
|
|
464
464
|
beforeEach(() => {
|
|
465
|
-
editor.createShape
|
|
465
|
+
editor.createShape({ id: ids.frame1, type: 'frame', props: { w: 100, h: 100 } })
|
|
466
466
|
frame1 = editor.getShape<TLFrameShape>(ids.frame1)!
|
|
467
467
|
})
|
|
468
468
|
|
|
@@ -517,8 +517,8 @@ describe('when shape is a frame', () => {
|
|
|
517
517
|
describe('When a shape is behind a frame', () => {
|
|
518
518
|
beforeEach(() => {
|
|
519
519
|
editor.selectAll().deleteShapes(editor.getSelectedShapeIds())
|
|
520
|
-
editor.createShape
|
|
521
|
-
editor.createShape
|
|
520
|
+
editor.createShape({ id: ids.box1, type: 'geo', x: 25, y: 25 })
|
|
521
|
+
editor.createShape({ id: ids.frame1, type: 'frame', props: { w: 100, h: 100 } })
|
|
522
522
|
})
|
|
523
523
|
|
|
524
524
|
it('does not select the shape when clicked inside', () => {
|
|
@@ -548,8 +548,8 @@ describe('when shape is inside of a frame', () => {
|
|
|
548
548
|
let frame1: TLFrameShape
|
|
549
549
|
let box1: TLGeoShape
|
|
550
550
|
beforeEach(() => {
|
|
551
|
-
editor.createShape
|
|
552
|
-
editor.createShape
|
|
551
|
+
editor.createShape({ id: ids.frame1, type: 'frame', props: { w: 100, h: 100 } })
|
|
552
|
+
editor.createShape({
|
|
553
553
|
id: ids.box1,
|
|
554
554
|
parentId: ids.frame1,
|
|
555
555
|
type: 'geo',
|
|
@@ -703,15 +703,15 @@ describe('when a frame has multiple children', () => {
|
|
|
703
703
|
let box2: TLGeoShape
|
|
704
704
|
beforeEach(() => {
|
|
705
705
|
editor
|
|
706
|
-
.createShape
|
|
707
|
-
.createShape
|
|
706
|
+
.createShape({ id: ids.frame1, type: 'frame', props: { w: 100, h: 100 } })
|
|
707
|
+
.createShape({
|
|
708
708
|
id: ids.box1,
|
|
709
709
|
parentId: ids.frame1,
|
|
710
710
|
type: 'geo',
|
|
711
711
|
x: 25,
|
|
712
712
|
y: 25,
|
|
713
713
|
})
|
|
714
|
-
.createShape
|
|
714
|
+
.createShape({
|
|
715
715
|
id: ids.box2,
|
|
716
716
|
parentId: ids.frame1,
|
|
717
717
|
type: 'geo',
|
|
@@ -849,7 +849,7 @@ describe('When shapes are overlapping', () => {
|
|
|
849
849
|
let box4: TLGeoShape
|
|
850
850
|
let box5: TLGeoShape
|
|
851
851
|
beforeEach(() => {
|
|
852
|
-
editor.createShapes
|
|
852
|
+
editor.createShapes([
|
|
853
853
|
{
|
|
854
854
|
id: ids.box1,
|
|
855
855
|
type: 'geo',
|
|
@@ -2194,7 +2194,7 @@ describe('long press', () => {
|
|
|
2194
2194
|
it('works correctly with screenbounds offset', () => {
|
|
2195
2195
|
editor.updateViewportScreenBounds(new Box(100, 100, 800, 600))
|
|
2196
2196
|
editor.pointerDown(201, 202)
|
|
2197
|
-
expect(editor.inputs.
|
|
2197
|
+
expect(editor.inputs.getCurrentScreenPoint()).toMatchObject({ x: 101, y: 102 })
|
|
2198
2198
|
})
|
|
2199
2199
|
|
|
2200
2200
|
it('works correctly with screenbounds offset', () => {
|
|
@@ -2202,7 +2202,7 @@ describe('long press', () => {
|
|
|
2202
2202
|
editor.pointerDown(201, 202)
|
|
2203
2203
|
vi.advanceTimersByTime(1000)
|
|
2204
2204
|
// without the fix added in this PR, it would have been 1, 2
|
|
2205
|
-
expect(editor.inputs.
|
|
2205
|
+
expect(editor.inputs.getCurrentScreenPoint()).toMatchObject({ x: 101, y: 102 })
|
|
2206
2206
|
})
|
|
2207
2207
|
})
|
|
2208
2208
|
|
|
@@ -470,7 +470,7 @@ describe('When interacting with a shape...', () => {
|
|
|
470
470
|
})
|
|
471
471
|
|
|
472
472
|
it('Fires handle dragging cancel events', () => {
|
|
473
|
-
const util = editor.getShapeUtil
|
|
473
|
+
const util = editor.getShapeUtil('line')
|
|
474
474
|
|
|
475
475
|
const calls: string[] = []
|
|
476
476
|
|
|
@@ -16,16 +16,16 @@ beforeEach(() => {
|
|
|
16
16
|
|
|
17
17
|
it('Sets cursor and state correctly', () => {
|
|
18
18
|
expect(editor.getInstanceState().cursor.type).toBe('default')
|
|
19
|
-
expect(editor.inputs.
|
|
19
|
+
expect(editor.inputs.getIsPanning()).toBe(false)
|
|
20
20
|
editor.keyDown(' ')
|
|
21
|
-
expect(editor.inputs.
|
|
21
|
+
expect(editor.inputs.getIsPanning()).toBe(true)
|
|
22
22
|
expect(editor.getInstanceState().cursor.type).toBe('grab')
|
|
23
23
|
editor.pointerDown(0, 0)
|
|
24
24
|
expect(editor.getInstanceState().cursor.type).toBe('grabbing')
|
|
25
25
|
editor.pointerUp(0, 0)
|
|
26
26
|
expect(editor.getInstanceState().cursor.type).toBe('grab')
|
|
27
27
|
editor.keyUp(' ')
|
|
28
|
-
expect(editor.inputs.
|
|
28
|
+
expect(editor.inputs.getIsPanning()).toBe(false)
|
|
29
29
|
expect(editor.getInstanceState().cursor.type).toBe('default')
|
|
30
30
|
})
|
|
31
31
|
|
|
@@ -37,16 +37,34 @@ it('When holding spacebar and clicking and dragging, it pans the camera', () =>
|
|
|
37
37
|
editor.keyUp(' ')
|
|
38
38
|
})
|
|
39
39
|
|
|
40
|
-
it('When
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
editor.
|
|
40
|
+
it('When spacebar is held during pointer interaction, it activates panning', () => {
|
|
41
|
+
// This test verifies that holding spacebar prevents pointer events from
|
|
42
|
+
// being sent to the state chart, and instead activates panning mode.
|
|
43
|
+
editor.select(ids.box1)
|
|
44
|
+
|
|
45
|
+
// Start with pointer down on the shape
|
|
46
|
+
editor.pointerDown(150, 150, ids.box1)
|
|
44
47
|
|
|
48
|
+
// Hold spacebar before moving - should activate panning
|
|
45
49
|
editor.keyDown(' ')
|
|
46
|
-
editor.
|
|
47
|
-
editor.
|
|
48
|
-
|
|
50
|
+
expect(editor.inputs.getIsPanning()).toBe(true)
|
|
51
|
+
expect(editor.getInstanceState().cursor.type).toBe('grabbing') // 'grabbing' because pointer is down
|
|
52
|
+
|
|
53
|
+
// Moving the pointer should pan the camera, not translate the shape
|
|
54
|
+
const initialCamera = editor.getCamera()
|
|
55
|
+
editor.pointerMove(100, 100)
|
|
56
|
+
|
|
57
|
+
// Camera should have moved (panning)
|
|
58
|
+
const newCamera = editor.getCamera()
|
|
59
|
+
expect(newCamera.x).not.toBe(initialCamera.x)
|
|
60
|
+
expect(newCamera.y).not.toBe(initialCamera.y)
|
|
61
|
+
|
|
62
|
+
// Shape should not have moved (not translating)
|
|
63
|
+
editor.expectShapeToMatch({ id: ids.box1, x: 100, y: 100 })
|
|
64
|
+
|
|
65
|
+
editor.pointerUp()
|
|
49
66
|
editor.keyUp(' ')
|
|
67
|
+
expect(editor.inputs.getIsPanning()).toBe(false)
|
|
50
68
|
})
|
|
51
69
|
|
|
52
70
|
it('When holding spacebar, pressing the arrow keys moves over by one viewport', () => {
|
package/src/test/styles3.test.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createShapeId, toRichText } from '@tldraw/editor'
|
|
2
2
|
import { TestEditor } from './TestEditor'
|
|
3
3
|
|
|
4
4
|
let editor: TestEditor
|
|
@@ -14,7 +14,7 @@ afterEach(() => {
|
|
|
14
14
|
it("When changing the style of a geo shape, if the text label is empty, don't measure it", () => {
|
|
15
15
|
const id = createShapeId()
|
|
16
16
|
|
|
17
|
-
editor.createShapes
|
|
17
|
+
editor.createShapes([
|
|
18
18
|
{
|
|
19
19
|
id,
|
|
20
20
|
type: 'geo',
|
|
@@ -29,7 +29,7 @@ it("When changing the style of a geo shape, if the text label is empty, don't me
|
|
|
29
29
|
|
|
30
30
|
const boundsBefore = editor.getShapeGeometry(id).bounds
|
|
31
31
|
|
|
32
|
-
editor.updateShapes
|
|
32
|
+
editor.updateShapes([
|
|
33
33
|
{
|
|
34
34
|
id,
|
|
35
35
|
type: 'geo',
|
|
@@ -43,7 +43,7 @@ it("When changing the style of a geo shape, if the text label is empty, don't me
|
|
|
43
43
|
it('When changing the style of a geo shape, if the text label has text, measure it and possibly update the size', () => {
|
|
44
44
|
const id = createShapeId()
|
|
45
45
|
|
|
46
|
-
editor.createShapes
|
|
46
|
+
editor.createShapes([
|
|
47
47
|
{
|
|
48
48
|
id,
|
|
49
49
|
type: 'geo',
|
|
@@ -58,7 +58,7 @@ it('When changing the style of a geo shape, if the text label has text, measure
|
|
|
58
58
|
|
|
59
59
|
const boundsBefore = editor.getShapeGeometry(id).bounds!
|
|
60
60
|
|
|
61
|
-
editor.updateShapes
|
|
61
|
+
editor.updateShapes([
|
|
62
62
|
{
|
|
63
63
|
id,
|
|
64
64
|
type: 'geo',
|
package/src/test/test-jsx.tsx
CHANGED
|
@@ -5,8 +5,7 @@ import {
|
|
|
5
5
|
TLBinding,
|
|
6
6
|
TLBindingCreate,
|
|
7
7
|
TLBindingId,
|
|
8
|
-
|
|
9
|
-
TLDefaultShape,
|
|
8
|
+
TLShape,
|
|
10
9
|
TLShapeId,
|
|
11
10
|
TLShapePartial,
|
|
12
11
|
ZERO_INDEX_KEY,
|
|
@@ -20,9 +19,13 @@ import {
|
|
|
20
19
|
} from '@tldraw/editor'
|
|
21
20
|
import React, { Fragment } from 'react'
|
|
22
21
|
|
|
22
|
+
// Re-export test helpers from their new location
|
|
23
|
+
export { base64ToPoints, createDrawSegments, pointsToBase64 } from '../lib/utils/test-helpers'
|
|
24
|
+
|
|
23
25
|
const shapeTypeSymbol = Symbol('shapeJsx')
|
|
24
26
|
const assetTypeSymbol = Symbol('assetJsx')
|
|
25
27
|
const bindingTypeSymbol = Symbol('bindingJsx')
|
|
28
|
+
|
|
26
29
|
interface CommonShapeProps {
|
|
27
30
|
x?: number
|
|
28
31
|
y?: number
|
|
@@ -34,7 +37,6 @@ interface CommonShapeProps {
|
|
|
34
37
|
opacity?: number
|
|
35
38
|
}
|
|
36
39
|
|
|
37
|
-
type ShapeByType<Type extends TLDefaultShape['type']> = Extract<TLDefaultShape, { type: Type }>
|
|
38
40
|
type FormatShapeProps<Props extends object> = {
|
|
39
41
|
[K in keyof Props]?: Props[K] extends TLAssetId
|
|
40
42
|
? TLAssetId | React.JSX.Element
|
|
@@ -42,24 +44,39 @@ type FormatShapeProps<Props extends object> = {
|
|
|
42
44
|
? TLAssetId | React.JSX.Element | null
|
|
43
45
|
: Props[K]
|
|
44
46
|
}
|
|
45
|
-
type PropsForShape<Type extends
|
|
46
|
-
|
|
47
|
-
: CommonShapeProps & Record<string, unknown>
|
|
47
|
+
type PropsForShape<Type extends TLShape['type']> = CommonShapeProps &
|
|
48
|
+
FormatShapeProps<TLShape<Type>['props']>
|
|
48
49
|
|
|
49
50
|
type AssetByType<Type extends TLAsset['type']> = Extract<TLAsset, { type: Type }>
|
|
50
51
|
type PropsForAsset<Type extends string> = Type extends TLAsset['type']
|
|
51
52
|
? Partial<AssetByType<Type>['props']>
|
|
52
53
|
: Record<string, unknown>
|
|
53
54
|
|
|
54
|
-
interface
|
|
55
|
+
interface BindingReactConnections {
|
|
55
56
|
from?: string | TLShapeId
|
|
56
57
|
to: string | TLShapeId
|
|
57
58
|
}
|
|
58
59
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
interface CommonBindingReactProps extends BindingReactConnections {
|
|
61
|
+
ref?: string
|
|
62
|
+
id?: TLBindingId
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
type ReactPropsForBinding<Type extends TLBinding['type']> = CommonBindingReactProps &
|
|
66
|
+
Partial<TLBinding<Type>['props']>
|
|
67
|
+
|
|
68
|
+
type BindingToCreate = TLBinding extends infer E
|
|
69
|
+
? E extends TLBinding
|
|
70
|
+
? {
|
|
71
|
+
type: E['type']
|
|
72
|
+
props: Partial<TLBinding<E['type']>['props']>
|
|
73
|
+
id: TLBindingId | undefined
|
|
74
|
+
parentId: TLShapeId | undefined
|
|
75
|
+
ref: string | undefined
|
|
76
|
+
connections: BindingReactConnections
|
|
77
|
+
}
|
|
78
|
+
: never
|
|
79
|
+
: never
|
|
63
80
|
|
|
64
81
|
const createElement = (
|
|
65
82
|
type: typeof shapeTypeSymbol | typeof assetTypeSymbol | typeof bindingTypeSymbol,
|
|
@@ -90,10 +107,9 @@ const tlBinding = new Proxy(
|
|
|
90
107
|
return createElement(bindingTypeSymbol, key as string)
|
|
91
108
|
},
|
|
92
109
|
}
|
|
93
|
-
) as {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
>
|
|
110
|
+
) as {
|
|
111
|
+
[K in TLBinding['type']]: (props: ReactPropsForBinding<K>) => null
|
|
112
|
+
}
|
|
97
113
|
|
|
98
114
|
/**
|
|
99
115
|
* TL - jsx helpers for creating tldraw shapes in test cases
|
|
@@ -112,8 +128,8 @@ export const TL = new Proxy(
|
|
|
112
128
|
},
|
|
113
129
|
}
|
|
114
130
|
) as { asset: typeof tlAsset; binding: typeof tlBinding } & {
|
|
115
|
-
[K in
|
|
116
|
-
}
|
|
131
|
+
[K in TLShape['type']]: (props: PropsForShape<K>) => null
|
|
132
|
+
}
|
|
117
133
|
|
|
118
134
|
export function shapesFromJsx(shapes: React.JSX.Element | Array<React.JSX.Element>, idPrefix = '') {
|
|
119
135
|
const ids = { bindings: {} } as Record<string, TLShapeId> & {
|
|
@@ -122,12 +138,7 @@ export function shapesFromJsx(shapes: React.JSX.Element | Array<React.JSX.Elemen
|
|
|
122
138
|
const currentPageShapes: Array<TLShapePartial> = []
|
|
123
139
|
const assets: Array<TLAsset> = []
|
|
124
140
|
|
|
125
|
-
const bindingsToCreate: Array<
|
|
126
|
-
type: string
|
|
127
|
-
props: Record<string, unknown>
|
|
128
|
-
parentId: TLShapeId | undefined
|
|
129
|
-
ref: string | undefined
|
|
130
|
-
}> = []
|
|
141
|
+
const bindingsToCreate: Array<BindingToCreate> = []
|
|
131
142
|
|
|
132
143
|
function addChildren(
|
|
133
144
|
children: React.JSX.Element | Array<React.JSX.Element>,
|
|
@@ -152,10 +163,21 @@ export function shapesFromJsx(shapes: React.JSX.Element | Array<React.JSX.Elemen
|
|
|
152
163
|
}
|
|
153
164
|
|
|
154
165
|
if (el.type[bindingTypeSymbol]) {
|
|
155
|
-
const bindingType = (el.type as any)[bindingTypeSymbol] as
|
|
156
|
-
const
|
|
157
|
-
|
|
158
|
-
|
|
166
|
+
const bindingType = (el.type as any)[bindingTypeSymbol] as TLBinding['type']
|
|
167
|
+
const { id, from, to, ref, ...props } = el.props
|
|
168
|
+
const bindingRef: unknown = (el as any).ref || ref
|
|
169
|
+
assert(
|
|
170
|
+
bindingRef === undefined || typeof bindingRef === 'string',
|
|
171
|
+
'ref must be string or undefined'
|
|
172
|
+
)
|
|
173
|
+
bindingsToCreate.push({
|
|
174
|
+
type: bindingType,
|
|
175
|
+
props,
|
|
176
|
+
id,
|
|
177
|
+
parentId,
|
|
178
|
+
ref: bindingRef,
|
|
179
|
+
connections: { from, to },
|
|
180
|
+
})
|
|
159
181
|
} else {
|
|
160
182
|
const shapeType = (el.type as any)[shapeTypeSymbol] as string
|
|
161
183
|
if (!shapeType) {
|
|
@@ -239,55 +261,48 @@ export function shapesFromJsx(shapes: React.JSX.Element | Array<React.JSX.Elemen
|
|
|
239
261
|
addChildren(shapes)
|
|
240
262
|
|
|
241
263
|
const bindings: TLBindingCreate[] = []
|
|
242
|
-
for (const binding of bindingsToCreate) {
|
|
264
|
+
for (const { id, parentId, ref, connections, ...binding } of bindingsToCreate) {
|
|
243
265
|
let fromId: TLShapeId, toId: TLShapeId
|
|
244
|
-
if (
|
|
245
|
-
assert(typeof
|
|
246
|
-
if (isShapeId(
|
|
247
|
-
fromId =
|
|
266
|
+
if (connections.from) {
|
|
267
|
+
assert(typeof connections.from === 'string', 'from must be a ref string or a shape id')
|
|
268
|
+
if (isShapeId(connections.from)) {
|
|
269
|
+
fromId = connections.from
|
|
248
270
|
} else {
|
|
249
|
-
assert(ids[
|
|
250
|
-
fromId = ids[
|
|
271
|
+
assert(ids[connections.from], `Ref not found: ${connections.from}`)
|
|
272
|
+
fromId = ids[connections.from]
|
|
251
273
|
}
|
|
252
|
-
} else if (
|
|
253
|
-
fromId =
|
|
274
|
+
} else if (parentId) {
|
|
275
|
+
fromId = parentId
|
|
254
276
|
} else {
|
|
255
277
|
throw new Error('from must be specified, or binding must be a child of a shape')
|
|
256
278
|
}
|
|
257
279
|
|
|
258
|
-
assert(
|
|
259
|
-
assert(typeof
|
|
260
|
-
if (isShapeId(
|
|
261
|
-
toId =
|
|
280
|
+
assert(connections.to, 'to must be specified')
|
|
281
|
+
assert(typeof connections.to === 'string', 'to must be a ref string or a shape id')
|
|
282
|
+
if (isShapeId(connections.to)) {
|
|
283
|
+
toId = connections.to
|
|
262
284
|
} else {
|
|
263
|
-
assert(ids[
|
|
264
|
-
toId = ids[
|
|
285
|
+
assert(ids[connections.to], `Ref not found: ${connections.to}`)
|
|
286
|
+
toId = ids[connections.to]
|
|
265
287
|
}
|
|
266
288
|
|
|
267
|
-
let bindingId
|
|
268
|
-
if (
|
|
269
|
-
assert(typeof
|
|
270
|
-
assert(!ids.bindings[
|
|
271
|
-
assert(!bindingId, `Cannot use both ref and id on binding: ${
|
|
272
|
-
bindingId = createBindingId(`${idPrefix}${
|
|
273
|
-
ids.bindings[
|
|
289
|
+
let bindingId = id
|
|
290
|
+
if (ref) {
|
|
291
|
+
assert(typeof ref === 'string', 'binding ref must be string')
|
|
292
|
+
assert(!ids.bindings[ref], `Duplicate ref: ${ref}`)
|
|
293
|
+
assert(!bindingId, `Cannot use both ref and id on binding: ${ref}`)
|
|
294
|
+
bindingId = createBindingId(`${idPrefix}${ref}`)
|
|
295
|
+
ids.bindings[ref] = bindingId
|
|
274
296
|
}
|
|
275
297
|
if (!bindingId) {
|
|
276
298
|
bindingId = createBindingId()
|
|
277
299
|
}
|
|
278
300
|
|
|
279
|
-
const props = { ...binding.props }
|
|
280
|
-
delete props.ref
|
|
281
|
-
delete props.id
|
|
282
|
-
delete props.from
|
|
283
|
-
delete props.to
|
|
284
|
-
|
|
285
301
|
bindings.push({
|
|
302
|
+
...binding,
|
|
286
303
|
id: bindingId,
|
|
287
|
-
type: binding.type,
|
|
288
304
|
fromId,
|
|
289
305
|
toId,
|
|
290
|
-
props,
|
|
291
306
|
})
|
|
292
307
|
}
|
|
293
308
|
|
package/src/test/text.test.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createShapeId, toRichText } from '@tldraw/editor'
|
|
2
2
|
import { TestEditor } from './TestEditor'
|
|
3
3
|
|
|
4
4
|
let editor: TestEditor
|
|
@@ -13,7 +13,7 @@ afterEach(() => {
|
|
|
13
13
|
describe('When editing text', () => {
|
|
14
14
|
it('preserves the top center when center aligned', () => {
|
|
15
15
|
const id = createShapeId()
|
|
16
|
-
editor.createShapes
|
|
16
|
+
editor.createShapes([
|
|
17
17
|
{
|
|
18
18
|
id,
|
|
19
19
|
type: 'text',
|
|
@@ -27,7 +27,7 @@ describe('When editing text', () => {
|
|
|
27
27
|
},
|
|
28
28
|
])
|
|
29
29
|
const boundsA = editor.getShapePageBounds(id)
|
|
30
|
-
editor.updateShapes
|
|
30
|
+
editor.updateShapes([
|
|
31
31
|
{
|
|
32
32
|
id,
|
|
33
33
|
type: 'text',
|
|
@@ -47,7 +47,7 @@ describe('When editing text', () => {
|
|
|
47
47
|
|
|
48
48
|
it('preserved the right center when center aligned and rotated 90deg', () => {
|
|
49
49
|
const id = createShapeId()
|
|
50
|
-
editor.createShapes
|
|
50
|
+
editor.createShapes([
|
|
51
51
|
{
|
|
52
52
|
id,
|
|
53
53
|
type: 'text',
|
|
@@ -63,9 +63,7 @@ describe('When editing text', () => {
|
|
|
63
63
|
])
|
|
64
64
|
|
|
65
65
|
const boundsA = editor.getShapePageBounds(id)!
|
|
66
|
-
editor.updateShapes
|
|
67
|
-
{ id, type: 'text', props: { richText: toRichText('Hello, world!') } },
|
|
68
|
-
])
|
|
66
|
+
editor.updateShapes([{ id, type: 'text', props: { richText: toRichText('Hello, world!') } }])
|
|
69
67
|
const boundsB = editor.getShapePageBounds(id)!
|
|
70
68
|
expect(boundsA.x).toBeCloseTo(boundsB.x)
|
|
71
69
|
expect(boundsA.y).not.toBeCloseTo(boundsB.y)
|
|
@@ -75,7 +73,7 @@ describe('When editing text', () => {
|
|
|
75
73
|
|
|
76
74
|
it('preserves the top left corner when start aligned', () => {
|
|
77
75
|
const id = createShapeId()
|
|
78
|
-
editor.createShapes
|
|
76
|
+
editor.createShapes([
|
|
79
77
|
{
|
|
80
78
|
id,
|
|
81
79
|
type: 'text',
|
|
@@ -89,7 +87,7 @@ describe('When editing text', () => {
|
|
|
89
87
|
},
|
|
90
88
|
])
|
|
91
89
|
const boundsA = editor.getShapePageBounds(id)
|
|
92
|
-
editor.updateShapes
|
|
90
|
+
editor.updateShapes([
|
|
93
91
|
{
|
|
94
92
|
id,
|
|
95
93
|
type: 'text',
|
|
@@ -109,7 +107,7 @@ describe('When editing text', () => {
|
|
|
109
107
|
|
|
110
108
|
it('preserves the top right edge when end aligned', () => {
|
|
111
109
|
const id = createShapeId()
|
|
112
|
-
editor.createShapes
|
|
110
|
+
editor.createShapes([
|
|
113
111
|
{
|
|
114
112
|
id,
|
|
115
113
|
type: 'text',
|
|
@@ -123,7 +121,7 @@ describe('When editing text', () => {
|
|
|
123
121
|
},
|
|
124
122
|
])
|
|
125
123
|
const boundsA = editor.getShapePageBounds(id)
|
|
126
|
-
editor.updateShapes
|
|
124
|
+
editor.updateShapes([
|
|
127
125
|
{
|
|
128
126
|
id,
|
|
129
127
|
type: 'text',
|
|
@@ -145,7 +143,7 @@ describe('When editing text', () => {
|
|
|
145
143
|
describe('When changing text size', () => {
|
|
146
144
|
it('preserves the center when center aligned', () => {
|
|
147
145
|
const id = createShapeId()
|
|
148
|
-
editor.createShapes
|
|
146
|
+
editor.createShapes([
|
|
149
147
|
{
|
|
150
148
|
id,
|
|
151
149
|
type: 'text',
|
|
@@ -160,7 +158,7 @@ describe('When changing text size', () => {
|
|
|
160
158
|
},
|
|
161
159
|
])
|
|
162
160
|
const boundsA = editor.getShapePageBounds(id)
|
|
163
|
-
editor.updateShapes
|
|
161
|
+
editor.updateShapes([
|
|
164
162
|
{
|
|
165
163
|
id,
|
|
166
164
|
type: 'text',
|
|
@@ -180,7 +178,7 @@ describe('When changing text size', () => {
|
|
|
180
178
|
|
|
181
179
|
it('preserves the center left point when start aligned', () => {
|
|
182
180
|
const id = createShapeId()
|
|
183
|
-
editor.createShapes
|
|
181
|
+
editor.createShapes([
|
|
184
182
|
{
|
|
185
183
|
id,
|
|
186
184
|
type: 'text',
|
|
@@ -195,7 +193,7 @@ describe('When changing text size', () => {
|
|
|
195
193
|
},
|
|
196
194
|
])
|
|
197
195
|
const boundsA = editor.getShapePageBounds(id)
|
|
198
|
-
editor.updateShapes
|
|
196
|
+
editor.updateShapes([
|
|
199
197
|
{
|
|
200
198
|
id,
|
|
201
199
|
type: 'text',
|
|
@@ -215,7 +213,7 @@ describe('When changing text size', () => {
|
|
|
215
213
|
|
|
216
214
|
it('preserves the top right edge when end aligned', () => {
|
|
217
215
|
const id = createShapeId()
|
|
218
|
-
editor.createShapes
|
|
216
|
+
editor.createShapes([
|
|
219
217
|
{
|
|
220
218
|
id,
|
|
221
219
|
type: 'text',
|
|
@@ -230,7 +228,7 @@ describe('When changing text size', () => {
|
|
|
230
228
|
},
|
|
231
229
|
])
|
|
232
230
|
const boundsA = editor.getShapePageBounds(id)
|
|
233
|
-
editor.updateShapes
|
|
231
|
+
editor.updateShapes([
|
|
234
232
|
{
|
|
235
233
|
id,
|
|
236
234
|
type: 'text',
|