tldraw 4.3.0-canary.da35795ba8e2 → 4.3.0-canary.e1766dd4eab3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-cjs/index.d.ts +26 -5
- package/dist-cjs/index.js +2 -1
- 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/defaultExternalContentHandlers.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js +9 -12
- 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.map +2 -2
- package/dist-cjs/lib/shapes/arrow/arrowTargetState.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/elbow/elbowArrowSnapLines.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/shared.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/shapes/bookmark/bookmarks.js.map +2 -2
- package/dist-cjs/lib/shapes/draw/DrawShapeUtil.js +3 -3
- package/dist-cjs/lib/shapes/draw/DrawShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/draw/toolStates/Drawing.js.map +2 -2
- 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 +1 -1
- package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/geo/GeoShapeUtil.js +10 -6
- package/dist-cjs/lib/shapes/geo/GeoShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/geo/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/shapes/highlight/HighlightShapeUtil.js +1 -1
- package/dist-cjs/lib/shapes/highlight/HighlightShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/line/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/shapes/note/NoteShapeUtil.js +5 -5
- 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/shared/HyperlinkButton.js +2 -1
- 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 +11 -3
- 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/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/TextShapeUtil.js +5 -2
- package/dist-cjs/lib/shapes/text/TextShapeUtil.js.map +2 -2
- 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.map +2 -2
- package/dist-cjs/lib/tools/EraserTool/childStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/DragAndDropManager.js +1 -4
- package/dist-cjs/lib/tools/SelectTool/DragAndDropManager.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Brushing.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/Idle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js +1 -1
- package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/EditingShape.js +30 -10
- package/dist-cjs/lib/tools/SelectTool/childStates/EditingShape.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Idle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingArrowLabel.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingHandle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingSelection.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/ScribbleBrushing.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Translating.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/EditLinkDialog.js +11 -1
- package/dist-cjs/lib/ui/components/EditLinkDialog.js.map +2 -2
- package/dist-cjs/lib/ui/components/Toolbar/AltTextEditor.js.map +2 -2
- package/dist-cjs/lib/ui/components/ZoomMenu/DefaultZoomMenu.js +1 -1
- package/dist-cjs/lib/ui/components/ZoomMenu/DefaultZoomMenu.js.map +2 -2
- 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/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 +143 -88
- package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js +1 -1
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js.map +2 -2
- package/dist-cjs/lib/ui/context/actions.js +1 -2
- package/dist-cjs/lib/ui/context/actions.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/menu-hooks.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/useFlatten.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/useTools.js.map +2 -2
- package/dist-cjs/lib/ui/version.js +3 -3
- package/dist-cjs/lib/ui/version.js.map +1 -1
- package/dist-cjs/lib/utils/excalidraw/putExcalidrawContent.js +8 -0
- package/dist-cjs/lib/utils/excalidraw/putExcalidrawContent.js.map +2 -2
- package/dist-cjs/lib/utils/export/exportAs.js.map +2 -2
- package/dist-cjs/lib/utils/frames/frames.js.map +2 -2
- package/dist-cjs/lib/utils/text/richText.js +7 -17
- package/dist-cjs/lib/utils/text/richText.js.map +3 -3
- package/dist-cjs/lib/utils/tldr/buildFromV1Document.js.map +2 -2
- package/dist-esm/index.d.mts +26 -5
- package/dist-esm/index.mjs +3 -1
- 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/defaultExternalContentHandlers.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs +10 -14
- package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/arrowLabel.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/arrowTargetState.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/elbow/elbowArrowSnapLines.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/shared.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/shapes/bookmark/bookmarks.mjs.map +2 -2
- package/dist-esm/lib/shapes/draw/DrawShapeUtil.mjs +3 -3
- package/dist-esm/lib/shapes/draw/DrawShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/draw/toolStates/Drawing.mjs.map +2 -2
- 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 +1 -1
- package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/geo/GeoShapeUtil.mjs +10 -6
- package/dist-esm/lib/shapes/geo/GeoShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/geo/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/shapes/highlight/HighlightShapeUtil.mjs +1 -1
- package/dist-esm/lib/shapes/highlight/HighlightShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/line/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs +5 -5
- 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/shared/HyperlinkButton.mjs +3 -2
- 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 +11 -3
- 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/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/TextShapeUtil.mjs +5 -2
- package/dist-esm/lib/shapes/text/TextShapeUtil.mjs.map +2 -2
- 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.map +2 -2
- package/dist-esm/lib/tools/EraserTool/childStates/Pointing.mjs +1 -4
- package/dist-esm/lib/tools/EraserTool/childStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/DragAndDropManager.mjs +1 -4
- package/dist-esm/lib/tools/SelectTool/DragAndDropManager.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Brushing.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/Idle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs +1 -1
- package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/EditingShape.mjs +30 -10
- package/dist-esm/lib/tools/SelectTool/childStates/EditingShape.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Idle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingArrowLabel.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingHandle.mjs +1 -4
- package/dist-esm/lib/tools/SelectTool/childStates/PointingHandle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingSelection.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/ScribbleBrushing.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Translating.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/EditLinkDialog.mjs +11 -1
- package/dist-esm/lib/ui/components/EditLinkDialog.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Toolbar/AltTextEditor.mjs.map +2 -2
- package/dist-esm/lib/ui/components/ZoomMenu/DefaultZoomMenu.mjs +1 -1
- package/dist-esm/lib/ui/components/ZoomMenu/DefaultZoomMenu.mjs.map +2 -2
- 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/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 +151 -90
- package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs +2 -2
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs.map +2 -2
- package/dist-esm/lib/ui/context/actions.mjs +1 -2
- package/dist-esm/lib/ui/context/actions.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/useFlatten.mjs.map +2 -2
- 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 +8 -0
- 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/text/richText.mjs +3 -3
- package/dist-esm/lib/utils/text/richText.mjs.map +2 -2
- package/dist-esm/lib/utils/tldr/buildFromV1Document.mjs.map +2 -2
- package/package.json +10 -10
- package/src/index.ts +1 -0
- package/src/lib/bindings/arrow/ArrowBindingUtil.ts +1 -1
- package/src/lib/canvas/TldrawSelectionForeground.tsx +6 -11
- package/src/lib/defaultExternalContentHandlers.ts +3 -4
- package/src/lib/shapes/arrow/ArrowShapeUtil.test.ts +2 -2
- package/src/lib/shapes/arrow/ArrowShapeUtil.tsx +11 -13
- package/src/lib/shapes/arrow/arrow-types.ts +2 -0
- package/src/lib/shapes/arrow/arrowLabel.ts +1 -1
- package/src/lib/shapes/arrow/arrowTargetState.ts +1 -1
- package/src/lib/shapes/arrow/elbow/elbowArrowSnapLines.tsx +3 -3
- package/src/lib/shapes/arrow/shared.ts +4 -4
- package/src/lib/shapes/arrow/toolStates/Pointing.tsx +1 -1
- package/src/lib/shapes/bookmark/bookmarks.ts +3 -3
- package/src/lib/shapes/draw/DrawShapeUtil.tsx +3 -3
- package/src/lib/shapes/draw/toolStates/Drawing.ts +4 -4
- package/src/lib/shapes/embed/EmbedShapeUtil.tsx +1 -1
- package/src/lib/shapes/frame/FrameShapeTool.ts +1 -1
- package/src/lib/shapes/frame/FrameShapeUtil.tsx +1 -1
- package/src/lib/shapes/geo/GeoShapeUtil.test.tsx +10 -2
- package/src/lib/shapes/geo/GeoShapeUtil.tsx +9 -4
- package/src/lib/shapes/geo/toolStates/Pointing.ts +3 -3
- package/src/lib/shapes/highlight/HighlightShapeUtil.tsx +1 -1
- 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 +1 -1
- package/src/lib/shapes/note/NoteShapeTool.test.ts +2 -1
- package/src/lib/shapes/note/NoteShapeUtil.tsx +7 -8
- package/src/lib/shapes/note/noteHelpers.ts +2 -2
- package/src/lib/shapes/shared/HyperlinkButton.tsx +3 -2
- package/src/lib/shapes/shared/PlainTextLabel.tsx +12 -2
- package/src/lib/shapes/shared/RichTextLabel.tsx +13 -3
- package/src/lib/shapes/shared/ShapeFill.tsx +2 -2
- package/src/lib/shapes/shared/crop.ts +1 -0
- 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/TextShapeTool.test.ts +4 -4
- package/src/lib/shapes/text/TextShapeUtil.tsx +5 -0
- package/src/lib/shapes/text/toolStates/Pointing.ts +1 -1
- package/src/lib/shapes/video/VideoShapeUtil.tsx +2 -1
- package/src/lib/tools/EraserTool/childStates/Erasing.ts +3 -5
- package/src/lib/tools/EraserTool/childStates/Pointing.ts +3 -16
- package/src/lib/tools/SelectTool/DragAndDropManager.ts +2 -4
- package/src/lib/tools/SelectTool/childStates/Brushing.ts +2 -6
- package/src/lib/tools/SelectTool/childStates/Crop/children/Idle.ts +2 -3
- package/src/lib/tools/SelectTool/childStates/DraggingHandle.tsx +4 -7
- package/src/lib/tools/SelectTool/childStates/EditingShape.ts +46 -15
- package/src/lib/tools/SelectTool/childStates/Idle.ts +6 -10
- package/src/lib/tools/SelectTool/childStates/PointingArrowLabel.ts +1 -1
- package/src/lib/tools/SelectTool/childStates/PointingHandle.ts +4 -12
- package/src/lib/tools/SelectTool/childStates/PointingSelection.ts +2 -2
- package/src/lib/tools/SelectTool/childStates/Resizing.ts +2 -4
- package/src/lib/tools/SelectTool/childStates/ScribbleBrushing.ts +2 -4
- package/src/lib/tools/SelectTool/childStates/Translating.ts +1 -3
- package/src/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.tsx +1 -9
- package/src/lib/ui/components/EditLinkDialog.tsx +16 -6
- package/src/lib/ui/components/Toolbar/AltTextEditor.tsx +2 -2
- package/src/lib/ui/components/ZoomMenu/DefaultZoomMenu.tsx +1 -1
- package/src/lib/ui/components/menu-items.tsx +9 -15
- package/src/lib/ui/components/primitives/TldrawUiSlider.tsx +2 -2
- package/src/lib/ui/components/primitives/TldrawUiTooltip.tsx +196 -108
- package/src/lib/ui/components/primitives/menus/TldrawUiMenuItem.tsx +2 -2
- package/src/lib/ui/context/actions.tsx +9 -13
- package/src/lib/ui/hooks/menu-hooks.ts +9 -19
- package/src/lib/ui/hooks/useFlatten.ts +1 -2
- package/src/lib/ui/hooks/useTools.tsx +1 -2
- package/src/lib/ui/version.ts +3 -3
- package/src/lib/utils/excalidraw/putExcalidrawContent.ts +8 -0
- package/src/lib/utils/export/exportAs.ts +2 -9
- package/src/lib/utils/frames/frames.ts +1 -1
- package/src/lib/utils/text/richText.ts +3 -3
- package/src/lib/utils/tldr/buildFromV1Document.ts +12 -17
- package/src/test/Editor.test.tsx +38 -12
- package/src/test/SelectTool.test.ts +11 -19
- package/src/test/TestEditor.ts +1 -4
- package/src/test/TldrawEditor.test.tsx +21 -18
- 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 +2 -2
- 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/updateShape.test.ts +67 -0
- package/src/test/commands/updateShapes.test.ts +21 -5
- package/src/test/custom-clipping.test.ts +36 -35
- package/src/test/customSnapping.test.tsx +77 -62
- package/src/test/duplicate.test.ts +1 -1
- package/src/test/frames.test.ts +2 -2
- package/src/test/getCulledShapes.test.tsx +11 -3
- package/src/test/getShapeAtPoint.test.ts +2 -2
- package/src/test/groups.test.tsx +6 -3
- package/src/test/resizing.test.ts +9 -13
- package/src/test/selection-omnibus.test.ts +11 -11
- package/src/test/shapeutils.test.ts +1 -1
- package/src/test/styles2.test.tsx +1 -1
- package/src/test/styles3.test.ts +5 -5
- package/src/test/test-jsx.tsx +69 -57
- package/src/test/text.test.ts +15 -17
- package/src/test/translating.test.ts +6 -8
- package/tldraw.css +8 -4
- package/dist-cjs/lib/shapes/shared/useForceSolid.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/src/lib/shapes/shared/useForceSolid.ts +0 -6
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TLContent, structuredClone } from '@tldraw/editor'
|
|
1
|
+
import { TLContent, createShapeId, structuredClone } from '@tldraw/editor'
|
|
2
2
|
import { TestEditor } from '../TestEditor'
|
|
3
3
|
|
|
4
4
|
let editor: TestEditor
|
|
@@ -25,6 +25,7 @@ describe('Migrations', () => {
|
|
|
25
25
|
|
|
26
26
|
it('Throws error if any shape is invalid due to wrong type', () => {
|
|
27
27
|
const withInvalidShapeType = structuredClone(clipboardContent)
|
|
28
|
+
// @ts-expect-error
|
|
28
29
|
withInvalidShapeType.shapes[0].type = 'invalid'
|
|
29
30
|
expect(() => editor.putContentOntoCurrentPage(withInvalidShapeType)).toThrow()
|
|
30
31
|
})
|
|
@@ -37,3 +38,81 @@ describe('Migrations', () => {
|
|
|
37
38
|
expect(() => editor.putContentOntoCurrentPage(withInvalidShapeModel)).toThrow()
|
|
38
39
|
})
|
|
39
40
|
})
|
|
41
|
+
|
|
42
|
+
describe('Paste parent selection with explicit point', () => {
|
|
43
|
+
it('falls back to the page when the cursor is outside the original parent', () => {
|
|
44
|
+
const frameId = createShapeId('frame')
|
|
45
|
+
const childId = createShapeId('child')
|
|
46
|
+
|
|
47
|
+
editor.createShapes([
|
|
48
|
+
{
|
|
49
|
+
id: frameId,
|
|
50
|
+
type: 'frame',
|
|
51
|
+
x: 0,
|
|
52
|
+
y: 0,
|
|
53
|
+
props: { w: 200, h: 200 },
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
id: childId,
|
|
57
|
+
type: 'geo',
|
|
58
|
+
parentId: frameId,
|
|
59
|
+
x: 40,
|
|
60
|
+
y: 40,
|
|
61
|
+
props: { w: 60, h: 60 },
|
|
62
|
+
},
|
|
63
|
+
])
|
|
64
|
+
|
|
65
|
+
editor.select(childId)
|
|
66
|
+
editor.copy()
|
|
67
|
+
|
|
68
|
+
editor.putContentOntoCurrentPage(editor.clipboard!, {
|
|
69
|
+
point: { x: 500, y: 500 },
|
|
70
|
+
select: true,
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
const [pastedId] = editor.getSelectedShapeIds()
|
|
74
|
+
expect(editor.getShape(pastedId)?.parentId).toBe(editor.getCurrentPageId())
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
it('uses the parent under the cursor when it can accept the pasted shapes', () => {
|
|
78
|
+
const frameAId = createShapeId('frameA')
|
|
79
|
+
const frameBId = createShapeId('frameB')
|
|
80
|
+
const childId = createShapeId('child')
|
|
81
|
+
|
|
82
|
+
editor.createShapes([
|
|
83
|
+
{
|
|
84
|
+
id: frameAId,
|
|
85
|
+
type: 'frame',
|
|
86
|
+
x: 0,
|
|
87
|
+
y: 0,
|
|
88
|
+
props: { w: 200, h: 200 },
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
id: frameBId,
|
|
92
|
+
type: 'frame',
|
|
93
|
+
x: 400,
|
|
94
|
+
y: 0,
|
|
95
|
+
props: { w: 200, h: 200 },
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
id: childId,
|
|
99
|
+
type: 'geo',
|
|
100
|
+
parentId: frameAId,
|
|
101
|
+
x: 40,
|
|
102
|
+
y: 40,
|
|
103
|
+
props: { w: 60, h: 60 },
|
|
104
|
+
},
|
|
105
|
+
])
|
|
106
|
+
|
|
107
|
+
editor.select(childId)
|
|
108
|
+
editor.copy()
|
|
109
|
+
|
|
110
|
+
editor.putContentOntoCurrentPage(editor.clipboard!, {
|
|
111
|
+
point: { x: 450, y: 50 },
|
|
112
|
+
select: true,
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
const [pastedId] = editor.getSelectedShapeIds()
|
|
116
|
+
expect(editor.getShape(pastedId)?.parentId).toBe(frameBId)
|
|
117
|
+
})
|
|
118
|
+
})
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { TLArrowShape, TLGeoShape, createShapeId } from '@tldraw/editor'
|
|
2
|
+
import { TestEditor, createDefaultShapes } from '../TestEditor'
|
|
3
|
+
|
|
4
|
+
let editor: TestEditor
|
|
5
|
+
|
|
6
|
+
const ids = {
|
|
7
|
+
box1: createShapeId('box1'),
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
beforeEach(() => {
|
|
11
|
+
editor = new TestEditor()
|
|
12
|
+
editor.createShapes(createDefaultShapes())
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
it('Uses typescript generics', () => {
|
|
16
|
+
expect(() => {
|
|
17
|
+
editor.updateShape({
|
|
18
|
+
id: ids.box1,
|
|
19
|
+
type: 'geo',
|
|
20
|
+
props: {
|
|
21
|
+
// @ts-expect-error
|
|
22
|
+
w: 'OH NO',
|
|
23
|
+
},
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
// Errors when updating a shape with unknown props
|
|
27
|
+
editor.updateShape({
|
|
28
|
+
id: ids.box1,
|
|
29
|
+
type: 'geo',
|
|
30
|
+
props: {
|
|
31
|
+
// @ts-expect-error
|
|
32
|
+
foo: 'bar',
|
|
33
|
+
},
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
// error here because we are giving the wrong props to the shape
|
|
37
|
+
editor.updateShape<TLGeoShape>({
|
|
38
|
+
id: ids.box1,
|
|
39
|
+
type: 'geo',
|
|
40
|
+
props: {
|
|
41
|
+
// @ts-expect-error
|
|
42
|
+
w: 'OH NO',
|
|
43
|
+
},
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
// Yep error here because we are giving the wrong generic
|
|
47
|
+
editor.updateShape<TLArrowShape>({
|
|
48
|
+
id: ids.box1,
|
|
49
|
+
//@ts-expect-error
|
|
50
|
+
type: 'geo',
|
|
51
|
+
//@ts-expect-error
|
|
52
|
+
props: { w: 'OH NO' },
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
// All good, correct match of generic and shape type
|
|
56
|
+
editor.updateShape<TLGeoShape>({
|
|
57
|
+
id: ids.box1,
|
|
58
|
+
type: 'geo',
|
|
59
|
+
props: { w: 100 },
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
editor.updateShape<TLGeoShape>({
|
|
63
|
+
id: ids.box1,
|
|
64
|
+
type: 'geo',
|
|
65
|
+
})
|
|
66
|
+
}).toThrow()
|
|
67
|
+
})
|
|
@@ -15,22 +15,38 @@ beforeEach(() => {
|
|
|
15
15
|
|
|
16
16
|
it('Uses typescript generics', () => {
|
|
17
17
|
expect(() => {
|
|
18
|
-
// No error here because no generic, the editor doesn't know what this guy is
|
|
19
18
|
editor.updateShapes([
|
|
20
19
|
{
|
|
21
20
|
id: ids.box1,
|
|
22
21
|
type: 'geo',
|
|
23
|
-
props: {
|
|
22
|
+
props: {
|
|
23
|
+
// @ts-expect-error
|
|
24
|
+
w: 'OH NO',
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
])
|
|
28
|
+
|
|
29
|
+
// Errors when updating shapes with unknown props
|
|
30
|
+
editor.updateShapes([
|
|
31
|
+
{
|
|
32
|
+
id: ids.box1,
|
|
33
|
+
type: 'geo',
|
|
34
|
+
props: {
|
|
35
|
+
// @ts-expect-error
|
|
36
|
+
foo: 'bar',
|
|
37
|
+
},
|
|
24
38
|
},
|
|
25
39
|
])
|
|
26
40
|
|
|
27
|
-
//
|
|
41
|
+
// error here because we are giving the wrong props to the shape
|
|
28
42
|
editor.updateShapes<TLGeoShape>([
|
|
29
43
|
{
|
|
30
44
|
id: ids.box1,
|
|
31
45
|
type: 'geo',
|
|
32
|
-
|
|
33
|
-
|
|
46
|
+
props: {
|
|
47
|
+
// @ts-expect-error
|
|
48
|
+
w: 'OH NO',
|
|
49
|
+
},
|
|
34
50
|
},
|
|
35
51
|
])
|
|
36
52
|
|
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
resizeBox,
|
|
9
9
|
StateNode,
|
|
10
10
|
T,
|
|
11
|
-
TLBaseShape,
|
|
12
11
|
TLEventHandlers,
|
|
13
12
|
TLGeoShape,
|
|
14
13
|
TLResizeInfo,
|
|
@@ -19,19 +18,21 @@ import {
|
|
|
19
18
|
} from '@tldraw/editor'
|
|
20
19
|
import { TestEditor } from './TestEditor'
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
{
|
|
26
|
-
w: number
|
|
27
|
-
h: number
|
|
21
|
+
const CIRCLE_CLIP_TYPE = 'circle-clip'
|
|
22
|
+
|
|
23
|
+
declare module '@tldraw/tlschema' {
|
|
24
|
+
export interface TLGlobalShapePropsMap {
|
|
25
|
+
[CIRCLE_CLIP_TYPE]: { w: number; h: number }
|
|
28
26
|
}
|
|
29
|
-
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Custom Circle Clip Shape Definition
|
|
30
|
+
export type CircleClipShape = TLShape<typeof CIRCLE_CLIP_TYPE>
|
|
30
31
|
|
|
31
32
|
export const isClippingEnabled$ = atom('isClippingEnabled', true)
|
|
32
33
|
|
|
33
34
|
export class CircleClipShapeUtil extends BaseBoxShapeUtil<CircleClipShape> {
|
|
34
|
-
static override type =
|
|
35
|
+
static override type = CIRCLE_CLIP_TYPE
|
|
35
36
|
static override props: RecordProps<CircleClipShape> = {
|
|
36
37
|
w: T.number,
|
|
37
38
|
h: T.number,
|
|
@@ -113,8 +114,8 @@ export class CircleClipShapeTool extends StateNode {
|
|
|
113
114
|
if (info.target === 'canvas') {
|
|
114
115
|
const { originPagePoint } = this.editor.inputs
|
|
115
116
|
|
|
116
|
-
this.editor.createShape
|
|
117
|
-
type:
|
|
117
|
+
this.editor.createShape({
|
|
118
|
+
type: CIRCLE_CLIP_TYPE,
|
|
118
119
|
x: originPagePoint.x - 100,
|
|
119
120
|
y: originPagePoint.y - 100,
|
|
120
121
|
props: {
|
|
@@ -153,9 +154,9 @@ beforeEach(() => {
|
|
|
153
154
|
describe('CircleClipShapeUtil', () => {
|
|
154
155
|
describe('shape creation and properties', () => {
|
|
155
156
|
it('should create a circle clip shape with default properties', () => {
|
|
156
|
-
editor.createShape
|
|
157
|
+
editor.createShape({
|
|
157
158
|
id: ids.circleClip1,
|
|
158
|
-
type:
|
|
159
|
+
type: CIRCLE_CLIP_TYPE,
|
|
159
160
|
x: 100,
|
|
160
161
|
y: 100,
|
|
161
162
|
props: {
|
|
@@ -172,9 +173,9 @@ describe('CircleClipShapeUtil', () => {
|
|
|
172
173
|
})
|
|
173
174
|
|
|
174
175
|
it('should use default props when not specified', () => {
|
|
175
|
-
editor.createShape
|
|
176
|
+
editor.createShape({
|
|
176
177
|
id: ids.circleClip1,
|
|
177
|
-
type:
|
|
178
|
+
type: CIRCLE_CLIP_TYPE,
|
|
178
179
|
x: 100,
|
|
179
180
|
y: 100,
|
|
180
181
|
props: {},
|
|
@@ -188,9 +189,9 @@ describe('CircleClipShapeUtil', () => {
|
|
|
188
189
|
|
|
189
190
|
describe('geometry and clipping', () => {
|
|
190
191
|
it('should generate correct circle geometry', () => {
|
|
191
|
-
editor.createShape
|
|
192
|
+
editor.createShape({
|
|
192
193
|
id: ids.circleClip1,
|
|
193
|
-
type:
|
|
194
|
+
type: CIRCLE_CLIP_TYPE,
|
|
194
195
|
x: 100,
|
|
195
196
|
y: 100,
|
|
196
197
|
props: {
|
|
@@ -210,9 +211,9 @@ describe('CircleClipShapeUtil', () => {
|
|
|
210
211
|
})
|
|
211
212
|
|
|
212
213
|
it('should generate clip path for circle', () => {
|
|
213
|
-
editor.createShape
|
|
214
|
+
editor.createShape({
|
|
214
215
|
id: ids.circleClip1,
|
|
215
|
-
type:
|
|
216
|
+
type: CIRCLE_CLIP_TYPE,
|
|
216
217
|
x: 100,
|
|
217
218
|
y: 100,
|
|
218
219
|
props: {
|
|
@@ -245,9 +246,9 @@ describe('CircleClipShapeUtil', () => {
|
|
|
245
246
|
|
|
246
247
|
describe('child clipping behavior', () => {
|
|
247
248
|
it('should clip children when clipping is enabled', () => {
|
|
248
|
-
editor.createShape
|
|
249
|
+
editor.createShape({
|
|
249
250
|
id: ids.circleClip1,
|
|
250
|
-
type:
|
|
251
|
+
type: CIRCLE_CLIP_TYPE,
|
|
251
252
|
x: 100,
|
|
252
253
|
y: 100,
|
|
253
254
|
props: {
|
|
@@ -256,7 +257,7 @@ describe('CircleClipShapeUtil', () => {
|
|
|
256
257
|
},
|
|
257
258
|
})
|
|
258
259
|
|
|
259
|
-
editor.createShape
|
|
260
|
+
editor.createShape({
|
|
260
261
|
id: ids.text1,
|
|
261
262
|
type: 'text',
|
|
262
263
|
x: 0,
|
|
@@ -279,9 +280,9 @@ describe('CircleClipShapeUtil', () => {
|
|
|
279
280
|
it('should not clip children when clipping is disabled', () => {
|
|
280
281
|
isClippingEnabled$.set(false)
|
|
281
282
|
|
|
282
|
-
editor.createShape
|
|
283
|
+
editor.createShape({
|
|
283
284
|
id: ids.circleClip1,
|
|
284
|
-
type:
|
|
285
|
+
type: CIRCLE_CLIP_TYPE,
|
|
285
286
|
x: 100,
|
|
286
287
|
y: 100,
|
|
287
288
|
props: {
|
|
@@ -290,7 +291,7 @@ describe('CircleClipShapeUtil', () => {
|
|
|
290
291
|
},
|
|
291
292
|
})
|
|
292
293
|
|
|
293
|
-
editor.createShape
|
|
294
|
+
editor.createShape({
|
|
294
295
|
id: ids.text1,
|
|
295
296
|
type: 'text',
|
|
296
297
|
x: 0,
|
|
@@ -314,9 +315,9 @@ describe('CircleClipShapeUtil', () => {
|
|
|
314
315
|
describe('Integration tests', () => {
|
|
315
316
|
it('should create and manage circle clip shapes with children', () => {
|
|
316
317
|
// Create circle clip shape
|
|
317
|
-
editor.createShape
|
|
318
|
+
editor.createShape({
|
|
318
319
|
id: ids.circleClip1,
|
|
319
|
-
type:
|
|
320
|
+
type: CIRCLE_CLIP_TYPE,
|
|
320
321
|
x: 100,
|
|
321
322
|
y: 100,
|
|
322
323
|
props: {
|
|
@@ -326,7 +327,7 @@ describe('Integration tests', () => {
|
|
|
326
327
|
})
|
|
327
328
|
|
|
328
329
|
// Add text child
|
|
329
|
-
editor.createShape
|
|
330
|
+
editor.createShape({
|
|
330
331
|
id: ids.text1,
|
|
331
332
|
type: 'text',
|
|
332
333
|
x: 50,
|
|
@@ -338,7 +339,7 @@ describe('Integration tests', () => {
|
|
|
338
339
|
})
|
|
339
340
|
|
|
340
341
|
// Add geo child
|
|
341
|
-
editor.createShape
|
|
342
|
+
editor.createShape({
|
|
342
343
|
id: ids.geo1,
|
|
343
344
|
type: 'geo',
|
|
344
345
|
x: 150,
|
|
@@ -375,9 +376,9 @@ describe('Integration tests', () => {
|
|
|
375
376
|
|
|
376
377
|
it('should handle multiple circle clip shapes independently', () => {
|
|
377
378
|
// Create two circle clip shapes
|
|
378
|
-
editor.createShape
|
|
379
|
+
editor.createShape({
|
|
379
380
|
id: ids.circleClip1,
|
|
380
|
-
type:
|
|
381
|
+
type: CIRCLE_CLIP_TYPE,
|
|
381
382
|
x: 100,
|
|
382
383
|
y: 100,
|
|
383
384
|
props: {
|
|
@@ -386,9 +387,9 @@ describe('Integration tests', () => {
|
|
|
386
387
|
},
|
|
387
388
|
})
|
|
388
389
|
|
|
389
|
-
editor.createShape
|
|
390
|
+
editor.createShape({
|
|
390
391
|
id: ids.circleClip2,
|
|
391
|
-
type:
|
|
392
|
+
type: CIRCLE_CLIP_TYPE,
|
|
392
393
|
x: 400,
|
|
393
394
|
y: 100,
|
|
394
395
|
props: {
|
|
@@ -398,7 +399,7 @@ describe('Integration tests', () => {
|
|
|
398
399
|
})
|
|
399
400
|
|
|
400
401
|
// Add children to both
|
|
401
|
-
editor.createShape
|
|
402
|
+
editor.createShape({
|
|
402
403
|
id: ids.text1,
|
|
403
404
|
type: 'text',
|
|
404
405
|
x: 0,
|
|
@@ -409,7 +410,7 @@ describe('Integration tests', () => {
|
|
|
409
410
|
},
|
|
410
411
|
})
|
|
411
412
|
|
|
412
|
-
editor.createShape
|
|
413
|
+
editor.createShape({
|
|
413
414
|
id: ids.geo1,
|
|
414
415
|
type: 'text',
|
|
415
416
|
x: 0,
|