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
|
@@ -4,10 +4,10 @@ import {
|
|
|
4
4
|
Polyline2d,
|
|
5
5
|
ShapeUtil,
|
|
6
6
|
TLAnyShapeUtilConstructor,
|
|
7
|
-
TLBaseShape,
|
|
8
7
|
TLHandle,
|
|
9
8
|
TLHandleDragInfo,
|
|
10
9
|
TLLineShape,
|
|
10
|
+
TLShape,
|
|
11
11
|
TLShapeId,
|
|
12
12
|
Vec,
|
|
13
13
|
VecModel,
|
|
@@ -16,13 +16,19 @@ import {
|
|
|
16
16
|
import { TestEditor } from './TestEditor'
|
|
17
17
|
import { TL } from './test-jsx'
|
|
18
18
|
|
|
19
|
+
const TEST1_TYPE = 'test1'
|
|
20
|
+
|
|
21
|
+
declare module '@tldraw/tlschema' {
|
|
22
|
+
export interface TLGlobalShapePropsMap {
|
|
23
|
+
[TEST1_TYPE]: { w: number; h: number; boundsSnapPoints: VecModel[] | null }
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
type Test1Shape = TLShape<typeof TEST1_TYPE>
|
|
28
|
+
|
|
19
29
|
describe('custom shape bounds snapping - translate', () => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
{ w: number; h: number; boundsSnapPoints: VecModel[] | null }
|
|
23
|
-
>
|
|
24
|
-
class TestShapeUtil extends BaseBoxShapeUtil<TestShape> {
|
|
25
|
-
static override type = 'test'
|
|
30
|
+
class TestShapeUtil extends BaseBoxShapeUtil<Test1Shape> {
|
|
31
|
+
static override type = TEST1_TYPE
|
|
26
32
|
override getDefaultProps() {
|
|
27
33
|
return { w: 100, h: 100, boundsSnapPoints: null }
|
|
28
34
|
}
|
|
@@ -32,7 +38,7 @@ describe('custom shape bounds snapping - translate', () => {
|
|
|
32
38
|
override indicator() {
|
|
33
39
|
throw new Error('Method not implemented.')
|
|
34
40
|
}
|
|
35
|
-
override getBoundsSnapGeometry(shape:
|
|
41
|
+
override getBoundsSnapGeometry(shape: Test1Shape) {
|
|
36
42
|
return {
|
|
37
43
|
points: shape.props.boundsSnapPoints ?? undefined,
|
|
38
44
|
}
|
|
@@ -46,14 +52,14 @@ describe('custom shape bounds snapping - translate', () => {
|
|
|
46
52
|
editor = new TestEditor({ shapeUtils })
|
|
47
53
|
ids = editor.createShapesFromJsx([
|
|
48
54
|
<TL.geo ref="box" x={0} y={0} w={100} h={100} />,
|
|
49
|
-
<TL.
|
|
55
|
+
<TL.test1 ref="test1" x={200} y={200} w={100} h={100} boundsSnapPoints={null} />,
|
|
50
56
|
])
|
|
51
57
|
})
|
|
52
58
|
|
|
53
59
|
describe('with default boundSnapPoints', () => {
|
|
54
60
|
test('normal snapping works with default boundSnapPoints when moving test shape', () => {
|
|
55
61
|
// start translating the test shape
|
|
56
|
-
editor.setSelectedShapes([ids.
|
|
62
|
+
editor.setSelectedShapes([ids.test1]).pointerDown(250, 250)
|
|
57
63
|
|
|
58
64
|
// move the left edge of the test shape to the right edge of the box shape - it should snap
|
|
59
65
|
editor.pointerMove(155, 250, undefined, { ctrlKey: true })
|
|
@@ -84,15 +90,15 @@ describe('custom shape bounds snapping - translate', () => {
|
|
|
84
90
|
|
|
85
91
|
describe('with only the center in boundSnapPoints', () => {
|
|
86
92
|
beforeEach(() => {
|
|
87
|
-
editor.updateShape
|
|
88
|
-
id: ids.
|
|
89
|
-
type:
|
|
93
|
+
editor.updateShape({
|
|
94
|
+
id: ids.test1,
|
|
95
|
+
type: TEST1_TYPE,
|
|
90
96
|
props: { boundsSnapPoints: [{ x: 50, y: 50 }] },
|
|
91
97
|
})
|
|
92
98
|
})
|
|
93
99
|
|
|
94
100
|
describe('when moving the test shape', () => {
|
|
95
|
-
beforeEach(() => editor.select(ids.
|
|
101
|
+
beforeEach(() => editor.select(ids.test1).pointerDown(250, 250))
|
|
96
102
|
|
|
97
103
|
test('does not snap its edges to the box edges', () => {
|
|
98
104
|
editor.pointerMove(155, 250, undefined, { ctrlKey: true })
|
|
@@ -126,15 +132,15 @@ describe('custom shape bounds snapping - translate', () => {
|
|
|
126
132
|
|
|
127
133
|
describe('with empty boundSnapPoints', () => {
|
|
128
134
|
beforeEach(() => {
|
|
129
|
-
editor.updateShape
|
|
130
|
-
id: ids.
|
|
131
|
-
type:
|
|
135
|
+
editor.updateShape({
|
|
136
|
+
id: ids.test1,
|
|
137
|
+
type: TEST1_TYPE,
|
|
132
138
|
props: { boundsSnapPoints: [] },
|
|
133
139
|
})
|
|
134
140
|
})
|
|
135
141
|
|
|
136
142
|
test('test shape does not snap to anything', () => {
|
|
137
|
-
editor.select(ids.
|
|
143
|
+
editor.select(ids.test1).pointerDown(250, 250)
|
|
138
144
|
|
|
139
145
|
// try to snap our left edge to the right edge of the box shape - it should not snap
|
|
140
146
|
editor.pointerMove(155, 250, undefined, { ctrlKey: true })
|
|
@@ -163,10 +169,11 @@ describe('custom shape bounds snapping - translate', () => {
|
|
|
163
169
|
})
|
|
164
170
|
})
|
|
165
171
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
172
|
+
const TEST2_TYPE = 'test2'
|
|
173
|
+
|
|
174
|
+
declare module '@tldraw/tlschema' {
|
|
175
|
+
export interface TLGlobalShapePropsMap {
|
|
176
|
+
[TEST2_TYPE]: {
|
|
170
177
|
w: number
|
|
171
178
|
h: number
|
|
172
179
|
ownHandle: VecModel
|
|
@@ -176,10 +183,15 @@ describe('custom handle snapping', () => {
|
|
|
176
183
|
selfSnapPoints: VecModel[] | 'default'
|
|
177
184
|
handleSnapType?: 'point' | 'align'
|
|
178
185
|
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
type Test2Shape = TLShape<typeof TEST2_TYPE>
|
|
190
|
+
|
|
191
|
+
describe('custom handle snapping', () => {
|
|
192
|
+
class TestShapeUtil extends BaseBoxShapeUtil<Test2Shape> {
|
|
193
|
+
static override type = TEST2_TYPE
|
|
194
|
+
override getDefaultProps(): Test2Shape['props'] {
|
|
183
195
|
return {
|
|
184
196
|
w: 100,
|
|
185
197
|
h: 100,
|
|
@@ -196,7 +208,7 @@ describe('custom handle snapping', () => {
|
|
|
196
208
|
override indicator() {
|
|
197
209
|
throw new Error('Method not implemented.')
|
|
198
210
|
}
|
|
199
|
-
override getHandleSnapGeometry(shape:
|
|
211
|
+
override getHandleSnapGeometry(shape: Test2Shape) {
|
|
200
212
|
const { handleOutline, handlePoints, selfSnapOutline, selfSnapPoints } = shape.props
|
|
201
213
|
return {
|
|
202
214
|
outline:
|
|
@@ -214,7 +226,7 @@ describe('custom handle snapping', () => {
|
|
|
214
226
|
getSelfSnapPoints: selfSnapPoints === 'default' ? undefined : () => selfSnapPoints,
|
|
215
227
|
}
|
|
216
228
|
}
|
|
217
|
-
override getHandles(shape:
|
|
229
|
+
override getHandles(shape: Test2Shape): TLHandle[] {
|
|
218
230
|
const handle: TLHandle = {
|
|
219
231
|
id: 'handle',
|
|
220
232
|
label: 'handle',
|
|
@@ -233,7 +245,7 @@ describe('custom handle snapping', () => {
|
|
|
233
245
|
|
|
234
246
|
return [handle]
|
|
235
247
|
}
|
|
236
|
-
override onHandleDrag(shape:
|
|
248
|
+
override onHandleDrag(shape: Test2Shape, { handle }: TLHandleDragInfo<Test2Shape>) {
|
|
237
249
|
return { ...shape, props: { ...shape.props, ownHandle: { x: handle.x, y: handle.y } } }
|
|
238
250
|
}
|
|
239
251
|
}
|
|
@@ -253,7 +265,7 @@ describe('custom handle snapping', () => {
|
|
|
253
265
|
a2: { id: 'a2', index: 'a2' as IndexKey, x: 100, y: 100 },
|
|
254
266
|
}}
|
|
255
267
|
/>,
|
|
256
|
-
<TL.
|
|
268
|
+
<TL.test2 ref="test2" x={200} y={200} w={100} h={100} />,
|
|
257
269
|
])
|
|
258
270
|
})
|
|
259
271
|
|
|
@@ -296,9 +308,9 @@ describe('custom handle snapping', () => {
|
|
|
296
308
|
|
|
297
309
|
describe('with empty handleSnapGeometry.outline', () => {
|
|
298
310
|
beforeEach(() => {
|
|
299
|
-
editor.updateShape
|
|
300
|
-
id: ids.
|
|
301
|
-
type:
|
|
311
|
+
editor.updateShape({
|
|
312
|
+
id: ids.test2,
|
|
313
|
+
type: TEST2_TYPE,
|
|
302
314
|
props: { handleOutline: null },
|
|
303
315
|
})
|
|
304
316
|
})
|
|
@@ -313,9 +325,9 @@ describe('custom handle snapping', () => {
|
|
|
313
325
|
|
|
314
326
|
describe('with custom handleSnapGeometry.outline', () => {
|
|
315
327
|
beforeEach(() => {
|
|
316
|
-
editor.updateShape
|
|
317
|
-
id: ids.
|
|
318
|
-
type:
|
|
328
|
+
editor.updateShape({
|
|
329
|
+
id: ids.test2,
|
|
330
|
+
type: TEST2_TYPE,
|
|
319
331
|
props: {
|
|
320
332
|
// a diagonal line from the top left to the bottom right
|
|
321
333
|
handleOutline: [
|
|
@@ -360,9 +372,9 @@ describe('custom handle snapping', () => {
|
|
|
360
372
|
|
|
361
373
|
describe('with custom handleSnapGeometry.points', () => {
|
|
362
374
|
beforeEach(() => {
|
|
363
|
-
editor.updateShape
|
|
364
|
-
id: ids.
|
|
365
|
-
type:
|
|
375
|
+
editor.updateShape({
|
|
376
|
+
id: ids.test2,
|
|
377
|
+
type: TEST2_TYPE,
|
|
366
378
|
props: {
|
|
367
379
|
handlePoints: [
|
|
368
380
|
{ x: 30, y: 30 },
|
|
@@ -387,12 +399,12 @@ describe('custom handle snapping', () => {
|
|
|
387
399
|
|
|
388
400
|
describe('with custom handleSnapGeometry.points along the outline', () => {
|
|
389
401
|
beforeEach(() => {
|
|
390
|
-
editor.updateShape
|
|
391
|
-
id: ids.
|
|
392
|
-
type:
|
|
402
|
+
editor.updateShape({
|
|
403
|
+
id: ids.test2,
|
|
404
|
+
type: TEST2_TYPE,
|
|
393
405
|
props: {
|
|
394
406
|
handlePoints: editor
|
|
395
|
-
.getShapeGeometry(ids.
|
|
407
|
+
.getShapeGeometry(ids.test2)
|
|
396
408
|
.bounds.cornersAndCenter.map(({ x, y }) => ({ x, y })),
|
|
397
409
|
},
|
|
398
410
|
})
|
|
@@ -426,9 +438,9 @@ describe('custom handle snapping', () => {
|
|
|
426
438
|
describe('self snapping', () => {
|
|
427
439
|
beforeEach(() => {
|
|
428
440
|
editor.deleteShape(ids.line)
|
|
429
|
-
editor.updateShape
|
|
430
|
-
id: ids.
|
|
431
|
-
type:
|
|
441
|
+
editor.updateShape({
|
|
442
|
+
id: ids.test2,
|
|
443
|
+
type: TEST2_TYPE,
|
|
432
444
|
x: 0,
|
|
433
445
|
y: 0,
|
|
434
446
|
props: {
|
|
@@ -437,12 +449,12 @@ describe('custom handle snapping', () => {
|
|
|
437
449
|
})
|
|
438
450
|
})
|
|
439
451
|
function startDraggingOwnHandle() {
|
|
440
|
-
const shape = editor.select(ids.
|
|
452
|
+
const shape = editor.select(ids.test2).getOnlySelectedShape()!
|
|
441
453
|
const handles = editor.getShapeHandles(shape)!
|
|
442
454
|
editor.pointerDown(0, 0, { target: 'handle', shape, handle: handles[0] })
|
|
443
455
|
}
|
|
444
456
|
function ownHandlePosition() {
|
|
445
|
-
const shape = editor.select(ids.
|
|
457
|
+
const shape = editor.select(ids.test2).getOnlySelectedShape()!
|
|
446
458
|
const handle = editor.getShapeHandles(shape)![0]
|
|
447
459
|
return { x: handle.x, y: handle.y }
|
|
448
460
|
}
|
|
@@ -462,9 +474,9 @@ describe('custom handle snapping', () => {
|
|
|
462
474
|
})
|
|
463
475
|
describe('with custom self snap outline & points', () => {
|
|
464
476
|
beforeEach(() => {
|
|
465
|
-
editor.updateShape
|
|
466
|
-
id: ids.
|
|
467
|
-
type:
|
|
477
|
+
editor.updateShape({
|
|
478
|
+
id: ids.test2,
|
|
479
|
+
type: TEST2_TYPE,
|
|
468
480
|
props: {
|
|
469
481
|
selfSnapOutline: [
|
|
470
482
|
{ x: 20, y: 50 },
|
|
@@ -506,9 +518,9 @@ describe('custom handle snapping', () => {
|
|
|
506
518
|
|
|
507
519
|
describe('with snapType set to align', () => {
|
|
508
520
|
beforeEach(() => {
|
|
509
|
-
editor.updateShape
|
|
510
|
-
id: ids.
|
|
511
|
-
type:
|
|
521
|
+
editor.updateShape({
|
|
522
|
+
id: ids.test2,
|
|
523
|
+
type: TEST2_TYPE,
|
|
512
524
|
props: {
|
|
513
525
|
selfSnapPoints: [
|
|
514
526
|
{ x: 20, y: 50 },
|
|
@@ -543,19 +555,24 @@ describe('custom handle snapping', () => {
|
|
|
543
555
|
})
|
|
544
556
|
})
|
|
545
557
|
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
558
|
+
const BEZIER_TYPE = 'bezier'
|
|
559
|
+
|
|
560
|
+
declare module '@tldraw/tlschema' {
|
|
561
|
+
export interface TLGlobalShapePropsMap {
|
|
562
|
+
[BEZIER_TYPE]: {
|
|
550
563
|
start: VecModel
|
|
551
564
|
cp1: VecModel
|
|
552
565
|
cp2: VecModel
|
|
553
566
|
end: VecModel
|
|
554
567
|
}
|
|
555
|
-
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
type BezierShape = TLShape<typeof BEZIER_TYPE>
|
|
556
572
|
|
|
573
|
+
describe('custom adjacent handle for shift snapping', () => {
|
|
557
574
|
class BezierShapeUtil extends ShapeUtil<BezierShape> {
|
|
558
|
-
static override type =
|
|
575
|
+
static override type = BEZIER_TYPE
|
|
559
576
|
override getDefaultProps() {
|
|
560
577
|
return {
|
|
561
578
|
start: { x: 0, y: 0 },
|
|
@@ -632,8 +649,6 @@ describe('custom adjacent handle for shift snapping', () => {
|
|
|
632
649
|
ref="bezier"
|
|
633
650
|
x={0}
|
|
634
651
|
y={0}
|
|
635
|
-
w={100}
|
|
636
|
-
h={100}
|
|
637
652
|
start={{ x: 0, y: 0 }}
|
|
638
653
|
cp1={{ x: 50, y: 0 }}
|
|
639
654
|
cp2={{ x: 50, y: 100 }}
|
|
@@ -295,7 +295,7 @@ describe('When duplicating shapes that include arrows', () => {
|
|
|
295
295
|
.select(
|
|
296
296
|
...editor
|
|
297
297
|
.getCurrentPageShapes()
|
|
298
|
-
.filter((s) => editor.isShapeOfType
|
|
298
|
+
.filter((s) => editor.isShapeOfType(s, 'arrow'))
|
|
299
299
|
.map((s) => s.id)
|
|
300
300
|
)
|
|
301
301
|
|
package/src/test/frames.test.ts
CHANGED
|
@@ -1363,13 +1363,13 @@ describe('Unparenting behavior', () => {
|
|
|
1363
1363
|
|
|
1364
1364
|
// When the shape has a fill, it should not fall out of the frame
|
|
1365
1365
|
editor.undo()
|
|
1366
|
-
editor.updateShape
|
|
1366
|
+
editor.updateShape({ ...largeRect, props: { fill: 'solid' } })
|
|
1367
1367
|
dragOntoFrame()
|
|
1368
1368
|
expect(editor.getShape(largeRect.id)!.parentId).toBe(frameId)
|
|
1369
1369
|
|
|
1370
1370
|
// When the shape has a label and that label is on top of the frame, it should not fall out of the frame
|
|
1371
1371
|
editor.undo()
|
|
1372
|
-
editor.updateShape
|
|
1372
|
+
editor.updateShape({
|
|
1373
1373
|
...largeRect,
|
|
1374
1374
|
props: { fill: 'none', richText: toRichText('hello') },
|
|
1375
1375
|
})
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
Box,
|
|
4
4
|
RecordProps,
|
|
5
5
|
T,
|
|
6
|
-
|
|
6
|
+
TLShape,
|
|
7
7
|
TLShapeId,
|
|
8
8
|
createShapeId,
|
|
9
9
|
} from '@tldraw/editor'
|
|
@@ -11,11 +11,19 @@ import { vi } from 'vitest'
|
|
|
11
11
|
import { TestEditor } from './TestEditor'
|
|
12
12
|
import { TL } from './test-jsx'
|
|
13
13
|
|
|
14
|
+
const UNCULLABLE_TYPE = 'uncullable'
|
|
15
|
+
|
|
16
|
+
declare module '@tldraw/tlschema' {
|
|
17
|
+
export interface TLGlobalShapePropsMap {
|
|
18
|
+
[UNCULLABLE_TYPE]: { w: number; h: number }
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
14
22
|
// Custom uncullable shape type for testing canCull override
|
|
15
|
-
type UncullableShape =
|
|
23
|
+
type UncullableShape = TLShape<typeof UNCULLABLE_TYPE>
|
|
16
24
|
|
|
17
25
|
class UncullableShapeUtil extends BaseBoxShapeUtil<UncullableShape> {
|
|
18
|
-
static override type =
|
|
26
|
+
static override type = UNCULLABLE_TYPE
|
|
19
27
|
static override props: RecordProps<UncullableShape> = {
|
|
20
28
|
w: T.number,
|
|
21
29
|
h: T.number,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TLShape, createShapeId, toRichText } from '@tldraw/editor'
|
|
2
2
|
import { TestEditor } from './TestEditor'
|
|
3
3
|
|
|
4
4
|
let editor: TestEditor
|
|
@@ -146,7 +146,7 @@ describe('with hitLabels=true', () => {
|
|
|
146
146
|
it('hits geo shape label behind overlapping hollow shape', () => {
|
|
147
147
|
// label is empty
|
|
148
148
|
expect(editor.getShapeAtPoint({ x: 350, y: 350 }, opts)?.id).toBe(ids.box3)
|
|
149
|
-
editor.updateShape
|
|
149
|
+
editor.updateShape({
|
|
150
150
|
id: ids.box2,
|
|
151
151
|
type: 'geo',
|
|
152
152
|
props: { richText: toRichText('hello') },
|
package/src/test/groups.test.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Box,
|
|
3
|
+
ExtractShapeByProps,
|
|
3
4
|
GroupShapeUtil,
|
|
4
5
|
TLArrowShape,
|
|
5
6
|
TLGroupShape,
|
|
@@ -35,14 +36,16 @@ const ids = {
|
|
|
35
36
|
groupA: createShapeId('groupA'),
|
|
36
37
|
}
|
|
37
38
|
|
|
39
|
+
type BoxShape = ExtractShapeByProps<{ fill: string }>
|
|
40
|
+
|
|
38
41
|
const box = (
|
|
39
42
|
id: TLShapeId,
|
|
40
43
|
x: number,
|
|
41
44
|
y: number,
|
|
42
45
|
w = 10,
|
|
43
46
|
h = 10,
|
|
44
|
-
fill = 'solid'
|
|
45
|
-
): TLShapePartial => ({
|
|
47
|
+
fill: BoxShape['props']['fill'] = 'solid'
|
|
48
|
+
): TLShapePartial<BoxShape> => ({
|
|
46
49
|
type: 'geo',
|
|
47
50
|
id,
|
|
48
51
|
x,
|
|
@@ -1980,7 +1983,7 @@ describe('Group opacity', () => {
|
|
|
1980
1983
|
editor.setOpacityForNextShapes(0.5)
|
|
1981
1984
|
editor.groupShapes(editor.getSelectedShapeIds())
|
|
1982
1985
|
const group = editor.getShape(onlySelectedId())!
|
|
1983
|
-
assert(editor.isShapeOfType
|
|
1986
|
+
assert(editor.isShapeOfType(group, 'group'))
|
|
1984
1987
|
expect(group.opacity).toBe(1)
|
|
1985
1988
|
})
|
|
1986
1989
|
})
|
|
@@ -3876,10 +3876,8 @@ it('uses the cross cursor when create resizing', () => {
|
|
|
3876
3876
|
describe('Resizing text from the right edge', () => {
|
|
3877
3877
|
it('Resizes text from the right edge', () => {
|
|
3878
3878
|
const id = createShapeId()
|
|
3879
|
-
editor.createShapes
|
|
3880
|
-
editor.updateShapes
|
|
3881
|
-
{ id, type: 'text', props: { richText: toRichText('Hello World') } },
|
|
3882
|
-
]) // auto size
|
|
3879
|
+
editor.createShapes([{ id, type: 'text', props: { richText: toRichText('H') } }])
|
|
3880
|
+
editor.updateShapes([{ id, type: 'text', props: { richText: toRichText('Hello World') } }]) // auto size
|
|
3883
3881
|
|
|
3884
3882
|
editor.select(id)
|
|
3885
3883
|
|
|
@@ -3905,10 +3903,8 @@ describe('Resizing text from the right edge', () => {
|
|
|
3905
3903
|
editor.updateInstanceState({ isCoarsePointer: true })
|
|
3906
3904
|
|
|
3907
3905
|
const id = createShapeId()
|
|
3908
|
-
editor.createShapes
|
|
3909
|
-
editor.updateShapes
|
|
3910
|
-
{ id, type: 'text', props: { richText: toRichText('Hello World') } },
|
|
3911
|
-
]) // auto size
|
|
3906
|
+
editor.createShapes([{ id, type: 'text', props: { richText: toRichText('H') } }])
|
|
3907
|
+
editor.updateShapes([{ id, type: 'text', props: { richText: toRichText('Hello World') } }]) // auto size
|
|
3912
3908
|
|
|
3913
3909
|
editor.select(id)
|
|
3914
3910
|
|
|
@@ -3954,7 +3950,7 @@ describe('When resizing near the edges of the screen', () => {
|
|
|
3954
3950
|
|
|
3955
3951
|
describe('resizing text with autosize true', () => {
|
|
3956
3952
|
it('resizes text from the right side', () => {
|
|
3957
|
-
editor.createShape
|
|
3953
|
+
editor.createShape({
|
|
3958
3954
|
type: 'text',
|
|
3959
3955
|
x: 0,
|
|
3960
3956
|
y: 0,
|
|
@@ -3980,7 +3976,7 @@ describe('resizing text with autosize true', () => {
|
|
|
3980
3976
|
})
|
|
3981
3977
|
|
|
3982
3978
|
it('resizes text from the right side when alt key is pressed', () => {
|
|
3983
|
-
editor.createShape
|
|
3979
|
+
editor.createShape({
|
|
3984
3980
|
type: 'text',
|
|
3985
3981
|
x: 0,
|
|
3986
3982
|
y: 0,
|
|
@@ -4007,7 +4003,7 @@ describe('resizing text with autosize true', () => {
|
|
|
4007
4003
|
})
|
|
4008
4004
|
|
|
4009
4005
|
it('resizes text from the left side', () => {
|
|
4010
|
-
editor.createShape
|
|
4006
|
+
editor.createShape({
|
|
4011
4007
|
type: 'text',
|
|
4012
4008
|
x: 0,
|
|
4013
4009
|
y: 0,
|
|
@@ -4033,7 +4029,7 @@ describe('resizing text with autosize true', () => {
|
|
|
4033
4029
|
})
|
|
4034
4030
|
|
|
4035
4031
|
it('resizes text from the left side when alt is pressed', () => {
|
|
4036
|
-
editor.createShape
|
|
4032
|
+
editor.createShape({
|
|
4037
4033
|
type: 'text',
|
|
4038
4034
|
x: 0,
|
|
4039
4035
|
y: 0,
|
|
@@ -4062,7 +4058,7 @@ describe('resizing text with autosize true', () => {
|
|
|
4062
4058
|
|
|
4063
4059
|
describe('cancelling a resize operation', () => {
|
|
4064
4060
|
it('undoes any changes since the start of the resize operation', () => {
|
|
4065
|
-
editor.createShape
|
|
4061
|
+
editor.createShape({
|
|
4066
4062
|
type: 'geo',
|
|
4067
4063
|
x: 0,
|
|
4068
4064
|
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',
|
|
@@ -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
|
|
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',
|