@bigbluebutton/tldraw 2.0.0-alpha.19
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/LICENSE +190 -0
- package/dist-cjs/index.d.ts +2954 -0
- package/dist-cjs/index.js +216 -0
- package/dist-cjs/index.js.map +7 -0
- package/dist-cjs/lib/Tldraw.js +136 -0
- package/dist-cjs/lib/Tldraw.js.map +7 -0
- package/dist-cjs/lib/canvas/TldrawCropHandles.js +164 -0
- package/dist-cjs/lib/canvas/TldrawCropHandles.js.map +7 -0
- package/dist-cjs/lib/canvas/TldrawHandles.js +37 -0
- package/dist-cjs/lib/canvas/TldrawHandles.js.map +7 -0
- package/dist-cjs/lib/canvas/TldrawHoveredShapeIndicator.js +42 -0
- package/dist-cjs/lib/canvas/TldrawHoveredShapeIndicator.js.map +7 -0
- package/dist-cjs/lib/canvas/TldrawScribble.js +72 -0
- package/dist-cjs/lib/canvas/TldrawScribble.js.map +7 -0
- package/dist-cjs/lib/canvas/TldrawSelectionBackground.js +44 -0
- package/dist-cjs/lib/canvas/TldrawSelectionBackground.js.map +7 -0
- package/dist-cjs/lib/canvas/TldrawSelectionForeground.js +509 -0
- package/dist-cjs/lib/canvas/TldrawSelectionForeground.js.map +7 -0
- package/dist-cjs/lib/defaultExternalContentHandlers.js +400 -0
- package/dist-cjs/lib/defaultExternalContentHandlers.js.map +7 -0
- package/dist-cjs/lib/defaultShapeTools.js +42 -0
- package/dist-cjs/lib/defaultShapeTools.js.map +7 -0
- package/dist-cjs/lib/defaultShapeUtils.js +50 -0
- package/dist-cjs/lib/defaultShapeUtils.js.map +7 -0
- package/dist-cjs/lib/defaultSideEffects.js +69 -0
- package/dist-cjs/lib/defaultSideEffects.js.map +7 -0
- package/dist-cjs/lib/defaultTools.js +30 -0
- package/dist-cjs/lib/defaultTools.js.map +7 -0
- package/dist-cjs/lib/shapes/arrow/ArrowShapeTool.js +33 -0
- package/dist-cjs/lib/shapes/arrow/ArrowShapeTool.js.map +7 -0
- package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js +805 -0
- package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js.map +7 -0
- package/dist-cjs/lib/shapes/arrow/components/ArrowTextLabel.js +114 -0
- package/dist-cjs/lib/shapes/arrow/components/ArrowTextLabel.js.map +7 -0
- package/dist-cjs/lib/shapes/arrow/toolStates/Idle.js +53 -0
- package/dist-cjs/lib/shapes/arrow/toolStates/Idle.js.map +7 -0
- package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.js +182 -0
- package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.js.map +7 -0
- package/dist-cjs/lib/shapes/bookmark/BookmarkShapeUtil.js +163 -0
- package/dist-cjs/lib/shapes/bookmark/BookmarkShapeUtil.js.map +7 -0
- package/dist-cjs/lib/shapes/draw/DrawShapeTool.js +37 -0
- package/dist-cjs/lib/shapes/draw/DrawShapeTool.js.map +7 -0
- package/dist-cjs/lib/shapes/draw/DrawShapeUtil.js +243 -0
- package/dist-cjs/lib/shapes/draw/DrawShapeUtil.js.map +7 -0
- package/dist-cjs/lib/shapes/draw/getPath.js +102 -0
- package/dist-cjs/lib/shapes/draw/getPath.js.map +7 -0
- package/dist-cjs/lib/shapes/draw/toolStates/Drawing.js +556 -0
- package/dist-cjs/lib/shapes/draw/toolStates/Drawing.js.map +7 -0
- package/dist-cjs/lib/shapes/draw/toolStates/Idle.js +37 -0
- package/dist-cjs/lib/shapes/draw/toolStates/Idle.js.map +7 -0
- package/dist-cjs/lib/shapes/embed/EmbedShapeUtil.js +192 -0
- package/dist-cjs/lib/shapes/embed/EmbedShapeUtil.js.map +7 -0
- package/dist-cjs/lib/shapes/frame/FrameShapeTool.js +66 -0
- package/dist-cjs/lib/shapes/frame/FrameShapeTool.js.map +7 -0
- package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js +234 -0
- package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js.map +7 -0
- package/dist-cjs/lib/shapes/frame/components/FrameHeading.js +106 -0
- package/dist-cjs/lib/shapes/frame/components/FrameHeading.js.map +7 -0
- package/dist-cjs/lib/shapes/frame/components/FrameLabelInput.js +101 -0
- package/dist-cjs/lib/shapes/frame/components/FrameLabelInput.js.map +7 -0
- package/dist-cjs/lib/shapes/geo/GeoShapeTool.js +33 -0
- package/dist-cjs/lib/shapes/geo/GeoShapeTool.js.map +7 -0
- package/dist-cjs/lib/shapes/geo/GeoShapeUtil.js +999 -0
- package/dist-cjs/lib/shapes/geo/GeoShapeUtil.js.map +7 -0
- package/dist-cjs/lib/shapes/geo/cloudOutline.js +288 -0
- package/dist-cjs/lib/shapes/geo/cloudOutline.js.map +7 -0
- package/dist-cjs/lib/shapes/geo/components/DashStyleCloud.js +124 -0
- package/dist-cjs/lib/shapes/geo/components/DashStyleCloud.js.map +7 -0
- package/dist-cjs/lib/shapes/geo/components/DashStyleEllipse.js +123 -0
- package/dist-cjs/lib/shapes/geo/components/DashStyleEllipse.js.map +7 -0
- package/dist-cjs/lib/shapes/geo/components/DashStyleOval.js +118 -0
- package/dist-cjs/lib/shapes/geo/components/DashStyleOval.js.map +7 -0
- package/dist-cjs/lib/shapes/geo/components/DashStylePolygon.js +155 -0
- package/dist-cjs/lib/shapes/geo/components/DashStylePolygon.js.map +7 -0
- package/dist-cjs/lib/shapes/geo/components/DrawStyleCloud.js +79 -0
- package/dist-cjs/lib/shapes/geo/components/DrawStyleCloud.js.map +7 -0
- package/dist-cjs/lib/shapes/geo/components/DrawStyleEllipse.js +133 -0
- package/dist-cjs/lib/shapes/geo/components/DrawStyleEllipse.js.map +7 -0
- package/dist-cjs/lib/shapes/geo/components/DrawStylePolygon.js +93 -0
- package/dist-cjs/lib/shapes/geo/components/DrawStylePolygon.js.map +7 -0
- package/dist-cjs/lib/shapes/geo/components/SolidStyleCloud.js +79 -0
- package/dist-cjs/lib/shapes/geo/components/SolidStyleCloud.js.map +7 -0
- package/dist-cjs/lib/shapes/geo/components/SolidStyleEllipse.js +84 -0
- package/dist-cjs/lib/shapes/geo/components/SolidStyleEllipse.js.map +7 -0
- package/dist-cjs/lib/shapes/geo/components/SolidStyleOval.js +99 -0
- package/dist-cjs/lib/shapes/geo/components/SolidStyleOval.js.map +7 -0
- package/dist-cjs/lib/shapes/geo/components/SolidStylePolygon.js +86 -0
- package/dist-cjs/lib/shapes/geo/components/SolidStylePolygon.js.map +7 -0
- package/dist-cjs/lib/shapes/geo/helpers.js +53 -0
- package/dist-cjs/lib/shapes/geo/helpers.js.map +7 -0
- package/dist-cjs/lib/shapes/geo/toolStates/Idle.js +53 -0
- package/dist-cjs/lib/shapes/geo/toolStates/Idle.js.map +7 -0
- package/dist-cjs/lib/shapes/geo/toolStates/Pointing.js +118 -0
- package/dist-cjs/lib/shapes/geo/toolStates/Pointing.js.map +7 -0
- package/dist-cjs/lib/shapes/highlight/HighlightShapeTool.js +37 -0
- package/dist-cjs/lib/shapes/highlight/HighlightShapeTool.js.map +7 -0
- package/dist-cjs/lib/shapes/highlight/HighlightShapeUtil.js +208 -0
- package/dist-cjs/lib/shapes/highlight/HighlightShapeUtil.js.map +7 -0
- package/dist-cjs/lib/shapes/image/ImageShapeUtil.js +262 -0
- package/dist-cjs/lib/shapes/image/ImageShapeUtil.js.map +7 -0
- package/dist-cjs/lib/shapes/line/LineShapeTool.js +33 -0
- package/dist-cjs/lib/shapes/line/LineShapeTool.js.map +7 -0
- package/dist-cjs/lib/shapes/line/LineShapeUtil.js +359 -0
- package/dist-cjs/lib/shapes/line/LineShapeUtil.js.map +7 -0
- package/dist-cjs/lib/shapes/line/components/getLinePath.js +88 -0
- package/dist-cjs/lib/shapes/line/components/getLinePath.js.map +7 -0
- package/dist-cjs/lib/shapes/line/components/svg.js +73 -0
- package/dist-cjs/lib/shapes/line/components/svg.js.map +7 -0
- package/dist-cjs/lib/shapes/line/toolStates/Idle.js +39 -0
- package/dist-cjs/lib/shapes/line/toolStates/Idle.js.map +7 -0
- package/dist-cjs/lib/shapes/line/toolStates/Pointing.js +145 -0
- package/dist-cjs/lib/shapes/line/toolStates/Pointing.js.map +7 -0
- package/dist-cjs/lib/shapes/note/NoteShapeTool.js +33 -0
- package/dist-cjs/lib/shapes/note/NoteShapeTool.js.map +7 -0
- package/dist-cjs/lib/shapes/note/NoteShapeUtil.js +205 -0
- package/dist-cjs/lib/shapes/note/NoteShapeUtil.js.map +7 -0
- package/dist-cjs/lib/shapes/note/toolStates/Idle.js +37 -0
- package/dist-cjs/lib/shapes/note/toolStates/Idle.js.map +7 -0
- package/dist-cjs/lib/shapes/note/toolStates/Pointing.js +114 -0
- package/dist-cjs/lib/shapes/note/toolStates/Pointing.js.map +7 -0
- package/dist-cjs/lib/shapes/shared/HyperlinkButton.js +65 -0
- package/dist-cjs/lib/shapes/shared/HyperlinkButton.js.map +7 -0
- package/dist-cjs/lib/shapes/shared/ShapeFill.js +117 -0
- package/dist-cjs/lib/shapes/shared/ShapeFill.js.map +7 -0
- package/dist-cjs/lib/shapes/shared/TextHelpers.js +228 -0
- package/dist-cjs/lib/shapes/shared/TextHelpers.js.map +7 -0
- package/dist-cjs/lib/shapes/shared/TextLabel.js +138 -0
- package/dist-cjs/lib/shapes/shared/TextLabel.js.map +7 -0
- package/dist-cjs/lib/shapes/shared/createTextSvgElementFromSpans.js +75 -0
- package/dist-cjs/lib/shapes/shared/createTextSvgElementFromSpans.js.map +7 -0
- package/dist-cjs/lib/shapes/shared/default-shape-constants.js +72 -0
- package/dist-cjs/lib/shapes/shared/default-shape-constants.js.map +7 -0
- package/dist-cjs/lib/shapes/shared/defaultStyleDefs.js +252 -0
- package/dist-cjs/lib/shapes/shared/defaultStyleDefs.js.map +7 -0
- package/dist-cjs/lib/shapes/shared/freehand/getStroke.js +33 -0
- package/dist-cjs/lib/shapes/shared/freehand/getStroke.js.map +7 -0
- package/dist-cjs/lib/shapes/shared/freehand/getStrokeOutlinePoints.js +175 -0
- package/dist-cjs/lib/shapes/shared/freehand/getStrokeOutlinePoints.js.map +7 -0
- package/dist-cjs/lib/shapes/shared/freehand/getStrokePoints.js +144 -0
- package/dist-cjs/lib/shapes/shared/freehand/getStrokePoints.js.map +7 -0
- package/dist-cjs/lib/shapes/shared/freehand/getStrokeRadius.js +27 -0
- package/dist-cjs/lib/shapes/shared/freehand/getStrokeRadius.js.map +7 -0
- package/dist-cjs/lib/shapes/shared/freehand/setStrokePointRadii.js +101 -0
- package/dist-cjs/lib/shapes/shared/freehand/setStrokePointRadii.js.map +7 -0
- package/dist-cjs/lib/shapes/shared/freehand/svg.js +56 -0
- package/dist-cjs/lib/shapes/shared/freehand/svg.js.map +7 -0
- package/dist-cjs/lib/shapes/shared/freehand/svgInk.js +163 -0
- package/dist-cjs/lib/shapes/shared/freehand/svgInk.js.map +7 -0
- package/dist-cjs/lib/shapes/shared/freehand/types.js +17 -0
- package/dist-cjs/lib/shapes/shared/freehand/types.js.map +7 -0
- package/dist-cjs/lib/shapes/shared/getBrowserCanvasMaxSize.js +52 -0
- package/dist-cjs/lib/shapes/shared/getBrowserCanvasMaxSize.js.map +7 -0
- package/dist-cjs/lib/shapes/shared/getPerfectDashProps.js +96 -0
- package/dist-cjs/lib/shapes/shared/getPerfectDashProps.js.map +7 -0
- package/dist-cjs/lib/shapes/shared/getTextLabelSvgElement.js +56 -0
- package/dist-cjs/lib/shapes/shared/getTextLabelSvgElement.js.map +7 -0
- package/dist-cjs/lib/shapes/shared/legacyProps.js +42 -0
- package/dist-cjs/lib/shapes/shared/legacyProps.js.map +7 -0
- package/dist-cjs/lib/shapes/shared/polygon-helpers.js +116 -0
- package/dist-cjs/lib/shapes/shared/polygon-helpers.js.map +7 -0
- package/dist-cjs/lib/shapes/shared/resizeBox.js +117 -0
- package/dist-cjs/lib/shapes/shared/resizeBox.js.map +7 -0
- package/dist-cjs/lib/shapes/shared/resizeScaled.js +48 -0
- package/dist-cjs/lib/shapes/shared/resizeScaled.js.map +7 -0
- package/dist-cjs/lib/shapes/shared/rotated-box-shadow.js +50 -0
- package/dist-cjs/lib/shapes/shared/rotated-box-shadow.js.map +7 -0
- package/dist-cjs/lib/shapes/shared/useColorSpace.js +39 -0
- package/dist-cjs/lib/shapes/shared/useColorSpace.js.map +7 -0
- package/dist-cjs/lib/shapes/shared/useEditableText.js +179 -0
- package/dist-cjs/lib/shapes/shared/useEditableText.js.map +7 -0
- package/dist-cjs/lib/shapes/shared/useForceSolid.js +29 -0
- package/dist-cjs/lib/shapes/shared/useForceSolid.js.map +7 -0
- package/dist-cjs/lib/shapes/shared/usePrefersReducedMotion.js +38 -0
- package/dist-cjs/lib/shapes/shared/usePrefersReducedMotion.js.map +7 -0
- package/dist-cjs/lib/shapes/text/TextShapeTool.js +33 -0
- package/dist-cjs/lib/shapes/text/TextShapeTool.js.map +7 -0
- package/dist-cjs/lib/shapes/text/TextShapeUtil.js +341 -0
- package/dist-cjs/lib/shapes/text/TextShapeUtil.js.map +7 -0
- package/dist-cjs/lib/shapes/text/toolStates/Idle.js +62 -0
- package/dist-cjs/lib/shapes/text/toolStates/Idle.js.map +7 -0
- package/dist-cjs/lib/shapes/text/toolStates/Pointing.js +109 -0
- package/dist-cjs/lib/shapes/text/toolStates/Pointing.js.map +7 -0
- package/dist-cjs/lib/shapes/video/VideoShapeUtil.js +202 -0
- package/dist-cjs/lib/shapes/video/VideoShapeUtil.js.map +7 -0
- package/dist-cjs/lib/tools/EraserTool/EraserTool.js +36 -0
- package/dist-cjs/lib/tools/EraserTool/EraserTool.js.map +7 -0
- package/dist-cjs/lib/tools/EraserTool/childStates/Erasing.js +111 -0
- package/dist-cjs/lib/tools/EraserTool/childStates/Erasing.js.map +7 -0
- package/dist-cjs/lib/tools/EraserTool/childStates/Idle.js +34 -0
- package/dist-cjs/lib/tools/EraserTool/childStates/Idle.js.map +7 -0
- package/dist-cjs/lib/tools/EraserTool/childStates/Pointing.js +84 -0
- package/dist-cjs/lib/tools/EraserTool/childStates/Pointing.js.map +7 -0
- package/dist-cjs/lib/tools/HandTool/HandTool.js +58 -0
- package/dist-cjs/lib/tools/HandTool/HandTool.js.map +7 -0
- package/dist-cjs/lib/tools/HandTool/childStates/Dragging.js +58 -0
- package/dist-cjs/lib/tools/HandTool/childStates/Dragging.js.map +7 -0
- package/dist-cjs/lib/tools/HandTool/childStates/Idle.js +37 -0
- package/dist-cjs/lib/tools/HandTool/childStates/Idle.js.map +7 -0
- package/dist-cjs/lib/tools/HandTool/childStates/Pointing.js +55 -0
- package/dist-cjs/lib/tools/HandTool/childStates/Pointing.js.map +7 -0
- package/dist-cjs/lib/tools/LaserTool/LaserTool.js +35 -0
- package/dist-cjs/lib/tools/LaserTool/LaserTool.js.map +7 -0
- package/dist-cjs/lib/tools/LaserTool/childStates/Idle.js +31 -0
- package/dist-cjs/lib/tools/LaserTool/childStates/Idle.js.map +7 -0
- package/dist-cjs/lib/tools/LaserTool/childStates/Lasering.js +66 -0
- package/dist-cjs/lib/tools/LaserTool/childStates/Lasering.js.map +7 -0
- package/dist-cjs/lib/tools/SelectTool/DragAndDropManager.js +100 -0
- package/dist-cjs/lib/tools/SelectTool/DragAndDropManager.js.map +7 -0
- package/dist-cjs/lib/tools/SelectTool/SelectTool.js +70 -0
- package/dist-cjs/lib/tools/SelectTool/SelectTool.js.map +7 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/Brushing.js +145 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/Brushing.js.map +7 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/Crop.js +33 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/Crop.js.map +7 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/Idle.js +204 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/Idle.js.map +7 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.js +39 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.js.map +7 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.js +101 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.js.map +7 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.js +58 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.js.map +7 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/crop-constants.js +25 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/crop-constants.js.map +7 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/Cropping.js +210 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/Cropping.js.map +7 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js +230 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js.map +7 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/EditingShape.js +121 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/EditingShape.js.map +7 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/Idle.js +461 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/Idle.js.map +7 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingCanvas.js +56 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingCanvas.js.map +7 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingCropHandle.js +89 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingCropHandle.js.map +7 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingHandle.js +67 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingHandle.js.map +7 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingResizeHandle.js +91 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingResizeHandle.js.map +7 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingRotateHandle.js +83 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingRotateHandle.js.map +7 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingSelection.js +73 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingSelection.js.map +7 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingShape.js +176 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingShape.js.map +7 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js +371 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js.map +7 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/Rotating.js +148 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/Rotating.js.map +7 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/ScribbleBrushing.js +140 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/ScribbleBrushing.js.map +7 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js +315 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js.map +7 -0
- package/dist-cjs/lib/tools/SelectTool/children/DraggingHandle.js +230 -0
- package/dist-cjs/lib/tools/SelectTool/children/DraggingHandle.js.map +7 -0
- package/dist-cjs/lib/tools/ZoomTool/ZoomTool.js +79 -0
- package/dist-cjs/lib/tools/ZoomTool/ZoomTool.js.map +7 -0
- package/dist-cjs/lib/tools/ZoomTool/childStates/Idle.js +35 -0
- package/dist-cjs/lib/tools/ZoomTool/childStates/Idle.js.map +7 -0
- package/dist-cjs/lib/tools/ZoomTool/childStates/Pointing.js +55 -0
- package/dist-cjs/lib/tools/ZoomTool/childStates/Pointing.js.map +7 -0
- package/dist-cjs/lib/tools/ZoomTool/childStates/ZoomBrushing.js +72 -0
- package/dist-cjs/lib/tools/ZoomTool/childStates/ZoomBrushing.js.map +7 -0
- package/dist-cjs/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.js +41 -0
- package/dist-cjs/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.js.map +7 -0
- package/dist-cjs/lib/tools/selection-logic/getShouldEnterCropModeOnPointerDown.js +28 -0
- package/dist-cjs/lib/tools/selection-logic/getShouldEnterCropModeOnPointerDown.js.map +7 -0
- package/dist-cjs/lib/tools/selection-logic/selectOnCanvasPointerUp.js +80 -0
- package/dist-cjs/lib/tools/selection-logic/selectOnCanvasPointerUp.js.map +7 -0
- package/dist-cjs/lib/tools/selection-logic/updateHoveredId.js +47 -0
- package/dist-cjs/lib/tools/selection-logic/updateHoveredId.js.map +7 -0
- package/dist-cjs/lib/ui/TldrawUi.js +155 -0
- package/dist-cjs/lib/ui/TldrawUi.js.map +7 -0
- package/dist-cjs/lib/ui/TldrawUiContextProvider.js +57 -0
- package/dist-cjs/lib/ui/TldrawUiContextProvider.js.map +7 -0
- package/dist-cjs/lib/ui/assetUrls.js +67 -0
- package/dist-cjs/lib/ui/assetUrls.js.map +7 -0
- package/dist-cjs/lib/ui/components/ActionsMenu.js +96 -0
- package/dist-cjs/lib/ui/components/ActionsMenu.js.map +7 -0
- package/dist-cjs/lib/ui/components/BackToContent.js +67 -0
- package/dist-cjs/lib/ui/components/BackToContent.js.map +7 -0
- package/dist-cjs/lib/ui/components/ContextMenu.js +214 -0
- package/dist-cjs/lib/ui/components/ContextMenu.js.map +7 -0
- package/dist-cjs/lib/ui/components/DebugPanel.js +334 -0
- package/dist-cjs/lib/ui/components/DebugPanel.js.map +7 -0
- package/dist-cjs/lib/ui/components/Dialogs.js +64 -0
- package/dist-cjs/lib/ui/components/Dialogs.js.map +7 -0
- package/dist-cjs/lib/ui/components/DuplicateButton.js +47 -0
- package/dist-cjs/lib/ui/components/DuplicateButton.js.map +7 -0
- package/dist-cjs/lib/ui/components/EditLinkDialog.js +161 -0
- package/dist-cjs/lib/ui/components/EditLinkDialog.js.map +7 -0
- package/dist-cjs/lib/ui/components/EmbedDialog.js +152 -0
- package/dist-cjs/lib/ui/components/EmbedDialog.js.map +7 -0
- package/dist-cjs/lib/ui/components/FollowingIndicator.js +41 -0
- package/dist-cjs/lib/ui/components/FollowingIndicator.js.map +7 -0
- package/dist-cjs/lib/ui/components/HTMLCanvas.js +66 -0
- package/dist-cjs/lib/ui/components/HTMLCanvas.js.map +7 -0
- package/dist-cjs/lib/ui/components/HelpMenu.js +116 -0
- package/dist-cjs/lib/ui/components/HelpMenu.js.map +7 -0
- package/dist-cjs/lib/ui/components/KeyboardShortcutsDialog.js +74 -0
- package/dist-cjs/lib/ui/components/KeyboardShortcutsDialog.js.map +7 -0
- package/dist-cjs/lib/ui/components/LanguageMenu.js +60 -0
- package/dist-cjs/lib/ui/components/LanguageMenu.js.map +7 -0
- package/dist-cjs/lib/ui/components/Menu.js +139 -0
- package/dist-cjs/lib/ui/components/Menu.js.map +7 -0
- package/dist-cjs/lib/ui/components/MenuZone.js +51 -0
- package/dist-cjs/lib/ui/components/MenuZone.js.map +7 -0
- package/dist-cjs/lib/ui/components/MobileStylePanel.js +69 -0
- package/dist-cjs/lib/ui/components/MobileStylePanel.js.map +7 -0
- package/dist-cjs/lib/ui/components/MoveToPageMenu.js +142 -0
- package/dist-cjs/lib/ui/components/MoveToPageMenu.js.map +7 -0
- package/dist-cjs/lib/ui/components/NavigationZone/Minimap.js +208 -0
- package/dist-cjs/lib/ui/components/NavigationZone/Minimap.js.map +7 -0
- package/dist-cjs/lib/ui/components/NavigationZone/MinimapManager.js +293 -0
- package/dist-cjs/lib/ui/components/NavigationZone/MinimapManager.js.map +7 -0
- package/dist-cjs/lib/ui/components/NavigationZone/NavigationZone.js +103 -0
- package/dist-cjs/lib/ui/components/NavigationZone/NavigationZone.js.map +7 -0
- package/dist-cjs/lib/ui/components/NavigationZone/ZoomMenu.js +118 -0
- package/dist-cjs/lib/ui/components/NavigationZone/ZoomMenu.js.map +7 -0
- package/dist-cjs/lib/ui/components/OfflineIndicator/OfflineIndicator.js +47 -0
- package/dist-cjs/lib/ui/components/OfflineIndicator/OfflineIndicator.js.map +7 -0
- package/dist-cjs/lib/ui/components/PageMenu/PageItemInput.js +63 -0
- package/dist-cjs/lib/ui/components/PageMenu/PageItemInput.js.map +7 -0
- package/dist-cjs/lib/ui/components/PageMenu/PageItemSubmenu.js +88 -0
- package/dist-cjs/lib/ui/components/PageMenu/PageItemSubmenu.js.map +7 -0
- package/dist-cjs/lib/ui/components/PageMenu/PageMenu.js +395 -0
- package/dist-cjs/lib/ui/components/PageMenu/PageMenu.js.map +7 -0
- package/dist-cjs/lib/ui/components/PageMenu/edit-pages-shared.js +45 -0
- package/dist-cjs/lib/ui/components/PageMenu/edit-pages-shared.js.map +7 -0
- package/dist-cjs/lib/ui/components/PenModeToggle.js +45 -0
- package/dist-cjs/lib/ui/components/PenModeToggle.js.map +7 -0
- package/dist-cjs/lib/ui/components/RedoButton.js +49 -0
- package/dist-cjs/lib/ui/components/RedoButton.js.map +7 -0
- package/dist-cjs/lib/ui/components/Spinner.js +41 -0
- package/dist-cjs/lib/ui/components/Spinner.js.map +7 -0
- package/dist-cjs/lib/ui/components/StopFollowing.js +45 -0
- package/dist-cjs/lib/ui/components/StopFollowing.js.map +7 -0
- package/dist-cjs/lib/ui/components/StylePanel/DoubleDropdownPicker.js +138 -0
- package/dist-cjs/lib/ui/components/StylePanel/DoubleDropdownPicker.js.map +7 -0
- package/dist-cjs/lib/ui/components/StylePanel/DropdownPicker.js +89 -0
- package/dist-cjs/lib/ui/components/StylePanel/DropdownPicker.js.map +7 -0
- package/dist-cjs/lib/ui/components/StylePanel/StylePanel.js +313 -0
- package/dist-cjs/lib/ui/components/StylePanel/StylePanel.js.map +7 -0
- package/dist-cjs/lib/ui/components/StylePanel/styles.js +119 -0
- package/dist-cjs/lib/ui/components/StylePanel/styles.js.map +7 -0
- package/dist-cjs/lib/ui/components/Toasts.js +101 -0
- package/dist-cjs/lib/ui/components/Toasts.js.map +7 -0
- package/dist-cjs/lib/ui/components/Toolbar/ToggleToolLockedButton.js +73 -0
- package/dist-cjs/lib/ui/components/Toolbar/ToggleToolLockedButton.js.map +7 -0
- package/dist-cjs/lib/ui/components/Toolbar/Toolbar.js +247 -0
- package/dist-cjs/lib/ui/components/Toolbar/Toolbar.js.map +7 -0
- package/dist-cjs/lib/ui/components/TrashButton.js +51 -0
- package/dist-cjs/lib/ui/components/TrashButton.js.map +7 -0
- package/dist-cjs/lib/ui/components/UndoButton.js +49 -0
- package/dist-cjs/lib/ui/components/UndoButton.js.map +7 -0
- package/dist-cjs/lib/ui/components/primitives/Button.js +79 -0
- package/dist-cjs/lib/ui/components/primitives/Button.js.map +7 -0
- package/dist-cjs/lib/ui/components/primitives/ButtonPicker.js +121 -0
- package/dist-cjs/lib/ui/components/primitives/ButtonPicker.js.map +7 -0
- package/dist-cjs/lib/ui/components/primitives/Dialog.js +70 -0
- package/dist-cjs/lib/ui/components/primitives/Dialog.js.map +7 -0
- package/dist-cjs/lib/ui/components/primitives/DropdownMenu.js +187 -0
- package/dist-cjs/lib/ui/components/primitives/DropdownMenu.js.map +7 -0
- package/dist-cjs/lib/ui/components/primitives/Icon.js +71 -0
- package/dist-cjs/lib/ui/components/primitives/Icon.js.map +7 -0
- package/dist-cjs/lib/ui/components/primitives/Input.js +155 -0
- package/dist-cjs/lib/ui/components/primitives/Input.js.map +7 -0
- package/dist-cjs/lib/ui/components/primitives/Kbd.js +29 -0
- package/dist-cjs/lib/ui/components/primitives/Kbd.js.map +7 -0
- package/dist-cjs/lib/ui/components/primitives/Popover.js +69 -0
- package/dist-cjs/lib/ui/components/primitives/Popover.js.map +7 -0
- package/dist-cjs/lib/ui/components/primitives/Slider.js +69 -0
- package/dist-cjs/lib/ui/components/primitives/Slider.js.map +7 -0
- package/dist-cjs/lib/ui/components/primitives/shared.js +44 -0
- package/dist-cjs/lib/ui/components/primitives/shared.js.map +7 -0
- package/dist-cjs/lib/ui/constants.js +25 -0
- package/dist-cjs/lib/ui/constants.js.map +7 -0
- package/dist-cjs/lib/ui/hooks/clipboard/pasteExcalidrawContent.js +454 -0
- package/dist-cjs/lib/ui/hooks/clipboard/pasteExcalidrawContent.js.map +7 -0
- package/dist-cjs/lib/ui/hooks/clipboard/pasteFiles.js +37 -0
- package/dist-cjs/lib/ui/hooks/clipboard/pasteFiles.js.map +7 -0
- package/dist-cjs/lib/ui/hooks/clipboard/pasteTldrawContent.js +32 -0
- package/dist-cjs/lib/ui/hooks/clipboard/pasteTldrawContent.js.map +7 -0
- package/dist-cjs/lib/ui/hooks/clipboard/pasteUrl.js +48 -0
- package/dist-cjs/lib/ui/hooks/clipboard/pasteUrl.js.map +7 -0
- package/dist-cjs/lib/ui/hooks/menuHelpers.js +172 -0
- package/dist-cjs/lib/ui/hooks/menuHelpers.js.map +7 -0
- package/dist-cjs/lib/ui/hooks/useActions.js +1152 -0
- package/dist-cjs/lib/ui/hooks/useActions.js.map +7 -0
- package/dist-cjs/lib/ui/hooks/useActionsMenuSchema.js +112 -0
- package/dist-cjs/lib/ui/hooks/useActionsMenuSchema.js.map +7 -0
- package/dist-cjs/lib/ui/hooks/useAssetUrls.js +41 -0
- package/dist-cjs/lib/ui/hooks/useAssetUrls.js.map +7 -0
- package/dist-cjs/lib/ui/hooks/useBreakpoint.js +64 -0
- package/dist-cjs/lib/ui/hooks/useBreakpoint.js.map +7 -0
- package/dist-cjs/lib/ui/hooks/useCanRedo.js +29 -0
- package/dist-cjs/lib/ui/hooks/useCanRedo.js.map +7 -0
- package/dist-cjs/lib/ui/hooks/useCanUndo.js +29 -0
- package/dist-cjs/lib/ui/hooks/useCanUndo.js.map +7 -0
- package/dist-cjs/lib/ui/hooks/useClipboardEvents.js +463 -0
- package/dist-cjs/lib/ui/hooks/useClipboardEvents.js.map +7 -0
- package/dist-cjs/lib/ui/hooks/useContextMenuSchema.js +228 -0
- package/dist-cjs/lib/ui/hooks/useContextMenuSchema.js.map +7 -0
- package/dist-cjs/lib/ui/hooks/useCopyAs.js +47 -0
- package/dist-cjs/lib/ui/hooks/useCopyAs.js.map +7 -0
- package/dist-cjs/lib/ui/hooks/useDialogsProvider.js +108 -0
- package/dist-cjs/lib/ui/hooks/useDialogsProvider.js.map +7 -0
- package/dist-cjs/lib/ui/hooks/useEditorEvents.js +43 -0
- package/dist-cjs/lib/ui/hooks/useEditorEvents.js.map +7 -0
- package/dist-cjs/lib/ui/hooks/useEventsProvider.js +47 -0
- package/dist-cjs/lib/ui/hooks/useEventsProvider.js.map +7 -0
- package/dist-cjs/lib/ui/hooks/useExportAs.js +51 -0
- package/dist-cjs/lib/ui/hooks/useExportAs.js.map +7 -0
- package/dist-cjs/lib/ui/hooks/useHasLinkShapeSelected.js +36 -0
- package/dist-cjs/lib/ui/hooks/useHasLinkShapeSelected.js.map +7 -0
- package/dist-cjs/lib/ui/hooks/useHelpMenuSchema.js +103 -0
- package/dist-cjs/lib/ui/hooks/useHelpMenuSchema.js.map +7 -0
- package/dist-cjs/lib/ui/hooks/useHighDpiCanvas.js +35 -0
- package/dist-cjs/lib/ui/hooks/useHighDpiCanvas.js.map +7 -0
- package/dist-cjs/lib/ui/hooks/useInsertMedia.js +57 -0
- package/dist-cjs/lib/ui/hooks/useInsertMedia.js.map +7 -0
- package/dist-cjs/lib/ui/hooks/useKeyboardShortcuts.js +138 -0
- package/dist-cjs/lib/ui/hooks/useKeyboardShortcuts.js.map +7 -0
- package/dist-cjs/lib/ui/hooks/useKeyboardShortcutsSchema.js +134 -0
- package/dist-cjs/lib/ui/hooks/useKeyboardShortcutsSchema.js.map +7 -0
- package/dist-cjs/lib/ui/hooks/useLocalStorageState.js +59 -0
- package/dist-cjs/lib/ui/hooks/useLocalStorageState.js.map +7 -0
- package/dist-cjs/lib/ui/hooks/useMenuIsOpen.js +74 -0
- package/dist-cjs/lib/ui/hooks/useMenuIsOpen.js.map +7 -0
- package/dist-cjs/lib/ui/hooks/useMenuSchema.js +260 -0
- package/dist-cjs/lib/ui/hooks/useMenuSchema.js.map +7 -0
- package/dist-cjs/lib/ui/hooks/useOnlyFlippableShape.js +38 -0
- package/dist-cjs/lib/ui/hooks/useOnlyFlippableShape.js.map +7 -0
- package/dist-cjs/lib/ui/hooks/usePreloadAssets.js +106 -0
- package/dist-cjs/lib/ui/hooks/usePreloadAssets.js.map +7 -0
- package/dist-cjs/lib/ui/hooks/usePreloadIcons.js +51 -0
- package/dist-cjs/lib/ui/hooks/usePreloadIcons.js.map +7 -0
- package/dist-cjs/lib/ui/hooks/usePrint.js +220 -0
- package/dist-cjs/lib/ui/hooks/usePrint.js.map +7 -0
- package/dist-cjs/lib/ui/hooks/useReadonly.js +29 -0
- package/dist-cjs/lib/ui/hooks/useReadonly.js.map +7 -0
- package/dist-cjs/lib/ui/hooks/useRevelantStyles.js +45 -0
- package/dist-cjs/lib/ui/hooks/useRevelantStyles.js.map +7 -0
- package/dist-cjs/lib/ui/hooks/useShowAutoSizeToggle.js +36 -0
- package/dist-cjs/lib/ui/hooks/useShowAutoSizeToggle.js.map +7 -0
- package/dist-cjs/lib/ui/hooks/useToastsProvider.js +53 -0
- package/dist-cjs/lib/ui/hooks/useToastsProvider.js.map +7 -0
- package/dist-cjs/lib/ui/hooks/useToolbarSchema.js +99 -0
- package/dist-cjs/lib/ui/hooks/useToolbarSchema.js.map +7 -0
- package/dist-cjs/lib/ui/hooks/useTools.js +235 -0
- package/dist-cjs/lib/ui/hooks/useTools.js.map +7 -0
- package/dist-cjs/lib/ui/hooks/useTranslation/TLUiTranslationKey.js +17 -0
- package/dist-cjs/lib/ui/hooks/useTranslation/TLUiTranslationKey.js.map +7 -0
- package/dist-cjs/lib/ui/hooks/useTranslation/defaultTranslation.js +377 -0
- package/dist-cjs/lib/ui/hooks/useTranslation/defaultTranslation.js.map +7 -0
- package/dist-cjs/lib/ui/hooks/useTranslation/translations.js +67 -0
- package/dist-cjs/lib/ui/hooks/useTranslation/translations.js.map +7 -0
- package/dist-cjs/lib/ui/hooks/useTranslation/useLanguages.js +32 -0
- package/dist-cjs/lib/ui/hooks/useTranslation/useLanguages.js.map +7 -0
- package/dist-cjs/lib/ui/hooks/useTranslation/useTranslation.js +101 -0
- package/dist-cjs/lib/ui/hooks/useTranslation/useTranslation.js.map +7 -0
- package/dist-cjs/lib/ui/icon-types.js +190 -0
- package/dist-cjs/lib/ui/icon-types.js.map +7 -0
- package/dist-cjs/lib/ui/overrides.js +178 -0
- package/dist-cjs/lib/ui/overrides.js.map +7 -0
- package/dist-cjs/lib/ui/version.js +25 -0
- package/dist-cjs/lib/ui/version.js.map +7 -0
- package/dist-cjs/lib/utils/assets/assets.js +91 -0
- package/dist-cjs/lib/utils/assets/assets.js.map +7 -0
- package/dist-cjs/lib/utils/assets/is-gif-animated.js +74 -0
- package/dist-cjs/lib/utils/assets/is-gif-animated.js.map +7 -0
- package/dist-cjs/lib/utils/assets.js +91 -0
- package/dist-cjs/lib/utils/assets.js.map +7 -0
- package/dist-cjs/lib/utils/embeds/embeds.js +85 -0
- package/dist-cjs/lib/utils/embeds/embeds.js.map +7 -0
- package/dist-cjs/lib/utils/export/copyAs.js +116 -0
- package/dist-cjs/lib/utils/export/copyAs.js.map +7 -0
- package/dist-cjs/lib/utils/export/export.js +117 -0
- package/dist-cjs/lib/utils/export/export.js.map +7 -0
- package/dist-cjs/lib/utils/export/exportAs.js +88 -0
- package/dist-cjs/lib/utils/export/exportAs.js.map +7 -0
- package/dist-cjs/lib/utils/frames/frames.js +92 -0
- package/dist-cjs/lib/utils/frames/frames.js.map +7 -0
- package/dist-cjs/lib/utils/static-assets/assetUrls.js +48 -0
- package/dist-cjs/lib/utils/static-assets/assetUrls.js.map +7 -0
- package/dist-cjs/lib/utils/text/text.js +57 -0
- package/dist-cjs/lib/utils/text/text.js.map +7 -0
- package/dist-cjs/lib/utils/tldr/buildFromV1Document.js +792 -0
- package/dist-cjs/lib/utils/tldr/buildFromV1Document.js.map +7 -0
- package/dist-cjs/lib/utils/tldr/file.js +230 -0
- package/dist-cjs/lib/utils/tldr/file.js.map +7 -0
- package/dist-esm/index.d.mts +2954 -0
- package/dist-esm/index.mjs +234 -0
- package/dist-esm/index.mjs.map +7 -0
- package/dist-esm/lib/Tldraw.mjs +127 -0
- package/dist-esm/lib/Tldraw.mjs.map +7 -0
- package/dist-esm/lib/canvas/TldrawCropHandles.mjs +134 -0
- package/dist-esm/lib/canvas/TldrawCropHandles.mjs.map +7 -0
- package/dist-esm/lib/canvas/TldrawHandles.mjs +17 -0
- package/dist-esm/lib/canvas/TldrawHandles.mjs.map +7 -0
- package/dist-esm/lib/canvas/TldrawHoveredShapeIndicator.mjs +26 -0
- package/dist-esm/lib/canvas/TldrawHoveredShapeIndicator.mjs.map +7 -0
- package/dist-esm/lib/canvas/TldrawScribble.mjs +42 -0
- package/dist-esm/lib/canvas/TldrawScribble.mjs.map +7 -0
- package/dist-esm/lib/canvas/TldrawSelectionBackground.mjs +28 -0
- package/dist-esm/lib/canvas/TldrawSelectionBackground.mjs.map +7 -0
- package/dist-esm/lib/canvas/TldrawSelectionForeground.mjs +487 -0
- package/dist-esm/lib/canvas/TldrawSelectionForeground.mjs.map +7 -0
- package/dist-esm/lib/defaultExternalContentHandlers.mjs +387 -0
- package/dist-esm/lib/defaultExternalContentHandlers.mjs.map +7 -0
- package/dist-esm/lib/defaultShapeTools.mjs +22 -0
- package/dist-esm/lib/defaultShapeTools.mjs.map +7 -0
- package/dist-esm/lib/defaultShapeUtils.mjs +30 -0
- package/dist-esm/lib/defaultShapeUtils.mjs.map +7 -0
- package/dist-esm/lib/defaultSideEffects.mjs +49 -0
- package/dist-esm/lib/defaultSideEffects.mjs.map +7 -0
- package/dist-esm/lib/defaultTools.mjs +10 -0
- package/dist-esm/lib/defaultTools.mjs.map +7 -0
- package/dist-esm/lib/shapes/arrow/ArrowShapeTool.mjs +13 -0
- package/dist-esm/lib/shapes/arrow/ArrowShapeTool.mjs.map +7 -0
- package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs +808 -0
- package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs.map +7 -0
- package/dist-esm/lib/shapes/arrow/components/ArrowTextLabel.mjs +84 -0
- package/dist-esm/lib/shapes/arrow/components/ArrowTextLabel.mjs.map +7 -0
- package/dist-esm/lib/shapes/arrow/toolStates/Idle.mjs +33 -0
- package/dist-esm/lib/shapes/arrow/toolStates/Idle.mjs.map +7 -0
- package/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs +162 -0
- package/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs.map +7 -0
- package/dist-esm/lib/shapes/bookmark/BookmarkShapeUtil.mjs +154 -0
- package/dist-esm/lib/shapes/bookmark/BookmarkShapeUtil.mjs.map +7 -0
- package/dist-esm/lib/shapes/draw/DrawShapeTool.mjs +17 -0
- package/dist-esm/lib/shapes/draw/DrawShapeTool.mjs.map +7 -0
- package/dist-esm/lib/shapes/draw/DrawShapeUtil.mjs +237 -0
- package/dist-esm/lib/shapes/draw/DrawShapeUtil.mjs.map +7 -0
- package/dist-esm/lib/shapes/draw/getPath.mjs +87 -0
- package/dist-esm/lib/shapes/draw/getPath.mjs.map +7 -0
- package/dist-esm/lib/shapes/draw/toolStates/Drawing.mjs +546 -0
- package/dist-esm/lib/shapes/draw/toolStates/Drawing.mjs.map +7 -0
- package/dist-esm/lib/shapes/draw/toolStates/Idle.mjs +17 -0
- package/dist-esm/lib/shapes/draw/toolStates/Idle.mjs.map +7 -0
- package/dist-esm/lib/shapes/embed/EmbedShapeUtil.mjs +181 -0
- package/dist-esm/lib/shapes/embed/EmbedShapeUtil.mjs.map +7 -0
- package/dist-esm/lib/shapes/frame/FrameShapeTool.mjs +46 -0
- package/dist-esm/lib/shapes/frame/FrameShapeTool.mjs.map +7 -0
- package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs +216 -0
- package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs.map +7 -0
- package/dist-esm/lib/shapes/frame/components/FrameHeading.mjs +93 -0
- package/dist-esm/lib/shapes/frame/components/FrameHeading.mjs.map +7 -0
- package/dist-esm/lib/shapes/frame/components/FrameLabelInput.mjs +81 -0
- package/dist-esm/lib/shapes/frame/components/FrameLabelInput.mjs.map +7 -0
- package/dist-esm/lib/shapes/geo/GeoShapeTool.mjs +13 -0
- package/dist-esm/lib/shapes/geo/GeoShapeTool.mjs.map +7 -0
- package/dist-esm/lib/shapes/geo/GeoShapeUtil.mjs +1010 -0
- package/dist-esm/lib/shapes/geo/GeoShapeUtil.mjs.map +7 -0
- package/dist-esm/lib/shapes/geo/cloudOutline.mjs +275 -0
- package/dist-esm/lib/shapes/geo/cloudOutline.mjs.map +7 -0
- package/dist-esm/lib/shapes/geo/components/DashStyleCloud.mjs +102 -0
- package/dist-esm/lib/shapes/geo/components/DashStyleCloud.mjs.map +7 -0
- package/dist-esm/lib/shapes/geo/components/DashStyleEllipse.mjs +101 -0
- package/dist-esm/lib/shapes/geo/components/DashStyleEllipse.mjs.map +7 -0
- package/dist-esm/lib/shapes/geo/components/DashStyleOval.mjs +93 -0
- package/dist-esm/lib/shapes/geo/components/DashStyleOval.mjs.map +7 -0
- package/dist-esm/lib/shapes/geo/components/DashStylePolygon.mjs +130 -0
- package/dist-esm/lib/shapes/geo/components/DashStylePolygon.mjs.map +7 -0
- package/dist-esm/lib/shapes/geo/components/DrawStyleCloud.mjs +54 -0
- package/dist-esm/lib/shapes/geo/components/DrawStyleCloud.mjs.map +7 -0
- package/dist-esm/lib/shapes/geo/components/DrawStyleEllipse.mjs +116 -0
- package/dist-esm/lib/shapes/geo/components/DrawStyleEllipse.mjs.map +7 -0
- package/dist-esm/lib/shapes/geo/components/DrawStylePolygon.mjs +68 -0
- package/dist-esm/lib/shapes/geo/components/DrawStylePolygon.mjs.map +7 -0
- package/dist-esm/lib/shapes/geo/components/SolidStyleCloud.mjs +54 -0
- package/dist-esm/lib/shapes/geo/components/SolidStyleCloud.mjs.map +7 -0
- package/dist-esm/lib/shapes/geo/components/SolidStyleEllipse.mjs +59 -0
- package/dist-esm/lib/shapes/geo/components/SolidStyleEllipse.mjs.map +7 -0
- package/dist-esm/lib/shapes/geo/components/SolidStyleOval.mjs +74 -0
- package/dist-esm/lib/shapes/geo/components/SolidStyleOval.mjs.map +7 -0
- package/dist-esm/lib/shapes/geo/components/SolidStylePolygon.mjs +61 -0
- package/dist-esm/lib/shapes/geo/components/SolidStylePolygon.mjs.map +7 -0
- package/dist-esm/lib/shapes/geo/helpers.mjs +33 -0
- package/dist-esm/lib/shapes/geo/helpers.mjs.map +7 -0
- package/dist-esm/lib/shapes/geo/toolStates/Idle.mjs +33 -0
- package/dist-esm/lib/shapes/geo/toolStates/Idle.mjs.map +7 -0
- package/dist-esm/lib/shapes/geo/toolStates/Pointing.mjs +104 -0
- package/dist-esm/lib/shapes/geo/toolStates/Pointing.mjs.map +7 -0
- package/dist-esm/lib/shapes/highlight/HighlightShapeTool.mjs +17 -0
- package/dist-esm/lib/shapes/highlight/HighlightShapeTool.mjs.map +7 -0
- package/dist-esm/lib/shapes/highlight/HighlightShapeUtil.mjs +198 -0
- package/dist-esm/lib/shapes/highlight/HighlightShapeUtil.mjs.map +7 -0
- package/dist-esm/lib/shapes/image/ImageShapeUtil.mjs +252 -0
- package/dist-esm/lib/shapes/image/ImageShapeUtil.mjs.map +7 -0
- package/dist-esm/lib/shapes/line/LineShapeTool.mjs +13 -0
- package/dist-esm/lib/shapes/line/LineShapeTool.mjs.map +7 -0
- package/dist-esm/lib/shapes/line/LineShapeUtil.mjs +357 -0
- package/dist-esm/lib/shapes/line/LineShapeUtil.mjs.map +7 -0
- package/dist-esm/lib/shapes/line/components/getLinePath.mjs +68 -0
- package/dist-esm/lib/shapes/line/components/getLinePath.mjs.map +7 -0
- package/dist-esm/lib/shapes/line/components/svg.mjs +57 -0
- package/dist-esm/lib/shapes/line/components/svg.mjs.map +7 -0
- package/dist-esm/lib/shapes/line/toolStates/Idle.mjs +19 -0
- package/dist-esm/lib/shapes/line/toolStates/Idle.mjs.map +7 -0
- package/dist-esm/lib/shapes/line/toolStates/Pointing.mjs +134 -0
- package/dist-esm/lib/shapes/line/toolStates/Pointing.mjs.map +7 -0
- package/dist-esm/lib/shapes/note/NoteShapeTool.mjs +13 -0
- package/dist-esm/lib/shapes/note/NoteShapeTool.mjs.map +7 -0
- package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs +193 -0
- package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs.map +7 -0
- package/dist-esm/lib/shapes/note/toolStates/Idle.mjs +17 -0
- package/dist-esm/lib/shapes/note/toolStates/Idle.mjs.map +7 -0
- package/dist-esm/lib/shapes/note/toolStates/Pointing.mjs +97 -0
- package/dist-esm/lib/shapes/note/toolStates/Pointing.mjs.map +7 -0
- package/dist-esm/lib/shapes/shared/HyperlinkButton.mjs +35 -0
- package/dist-esm/lib/shapes/shared/HyperlinkButton.mjs.map +7 -0
- package/dist-esm/lib/shapes/shared/ShapeFill.mjs +93 -0
- package/dist-esm/lib/shapes/shared/ShapeFill.mjs.map +7 -0
- package/dist-esm/lib/shapes/shared/TextHelpers.mjs +208 -0
- package/dist-esm/lib/shapes/shared/TextHelpers.mjs.map +7 -0
- package/dist-esm/lib/shapes/shared/TextLabel.mjs +112 -0
- package/dist-esm/lib/shapes/shared/TextLabel.mjs.map +7 -0
- package/dist-esm/lib/shapes/shared/createTextSvgElementFromSpans.mjs +57 -0
- package/dist-esm/lib/shapes/shared/createTextSvgElementFromSpans.mjs.map +7 -0
- package/dist-esm/lib/shapes/shared/default-shape-constants.mjs +52 -0
- package/dist-esm/lib/shapes/shared/default-shape-constants.mjs.map +7 -0
- package/dist-esm/lib/shapes/shared/defaultStyleDefs.mjs +240 -0
- package/dist-esm/lib/shapes/shared/defaultStyleDefs.mjs.map +7 -0
- package/dist-esm/lib/shapes/shared/freehand/getStroke.mjs +13 -0
- package/dist-esm/lib/shapes/shared/freehand/getStroke.mjs.map +7 -0
- package/dist-esm/lib/shapes/shared/freehand/getStrokeOutlinePoints.mjs +155 -0
- package/dist-esm/lib/shapes/shared/freehand/getStrokeOutlinePoints.mjs.map +7 -0
- package/dist-esm/lib/shapes/shared/freehand/getStrokePoints.mjs +124 -0
- package/dist-esm/lib/shapes/shared/freehand/getStrokePoints.mjs.map +7 -0
- package/dist-esm/lib/shapes/shared/freehand/getStrokeRadius.mjs +7 -0
- package/dist-esm/lib/shapes/shared/freehand/getStrokeRadius.mjs.map +7 -0
- package/dist-esm/lib/shapes/shared/freehand/setStrokePointRadii.mjs +81 -0
- package/dist-esm/lib/shapes/shared/freehand/setStrokePointRadii.mjs.map +7 -0
- package/dist-esm/lib/shapes/shared/freehand/svg.mjs +36 -0
- package/dist-esm/lib/shapes/shared/freehand/svg.mjs.map +7 -0
- package/dist-esm/lib/shapes/shared/freehand/svgInk.mjs +150 -0
- package/dist-esm/lib/shapes/shared/freehand/svgInk.mjs.map +7 -0
- package/dist-esm/lib/shapes/shared/freehand/types.mjs +1 -0
- package/dist-esm/lib/shapes/shared/freehand/types.mjs.map +7 -0
- package/dist-esm/lib/shapes/shared/getBrowserCanvasMaxSize.mjs +22 -0
- package/dist-esm/lib/shapes/shared/getBrowserCanvasMaxSize.mjs.map +7 -0
- package/dist-esm/lib/shapes/shared/getPerfectDashProps.mjs +76 -0
- package/dist-esm/lib/shapes/shared/getPerfectDashProps.mjs.map +7 -0
- package/dist-esm/lib/shapes/shared/getTextLabelSvgElement.mjs +36 -0
- package/dist-esm/lib/shapes/shared/getTextLabelSvgElement.mjs.map +7 -0
- package/dist-esm/lib/shapes/shared/legacyProps.mjs +22 -0
- package/dist-esm/lib/shapes/shared/legacyProps.mjs.map +7 -0
- package/dist-esm/lib/shapes/shared/polygon-helpers.mjs +96 -0
- package/dist-esm/lib/shapes/shared/polygon-helpers.mjs.map +7 -0
- package/dist-esm/lib/shapes/shared/resizeBox.mjs +99 -0
- package/dist-esm/lib/shapes/shared/resizeBox.mjs.map +7 -0
- package/dist-esm/lib/shapes/shared/resizeScaled.mjs +28 -0
- package/dist-esm/lib/shapes/shared/resizeScaled.mjs.map +7 -0
- package/dist-esm/lib/shapes/shared/rotated-box-shadow.mjs +30 -0
- package/dist-esm/lib/shapes/shared/rotated-box-shadow.mjs.map +7 -0
- package/dist-esm/lib/shapes/shared/useColorSpace.mjs +19 -0
- package/dist-esm/lib/shapes/shared/useColorSpace.mjs.map +7 -0
- package/dist-esm/lib/shapes/shared/useEditableText.mjs +165 -0
- package/dist-esm/lib/shapes/shared/useEditableText.mjs.map +7 -0
- package/dist-esm/lib/shapes/shared/useForceSolid.mjs +9 -0
- package/dist-esm/lib/shapes/shared/useForceSolid.mjs.map +7 -0
- package/dist-esm/lib/shapes/shared/usePrefersReducedMotion.mjs +18 -0
- package/dist-esm/lib/shapes/shared/usePrefersReducedMotion.mjs.map +7 -0
- package/dist-esm/lib/shapes/text/TextShapeTool.mjs +13 -0
- package/dist-esm/lib/shapes/text/TextShapeTool.mjs.map +7 -0
- package/dist-esm/lib/shapes/text/TextShapeUtil.mjs +334 -0
- package/dist-esm/lib/shapes/text/TextShapeUtil.mjs.map +7 -0
- package/dist-esm/lib/shapes/text/toolStates/Idle.mjs +42 -0
- package/dist-esm/lib/shapes/text/toolStates/Idle.mjs.map +7 -0
- package/dist-esm/lib/shapes/text/toolStates/Pointing.mjs +89 -0
- package/dist-esm/lib/shapes/text/toolStates/Pointing.mjs.map +7 -0
- package/dist-esm/lib/shapes/video/VideoShapeUtil.mjs +180 -0
- package/dist-esm/lib/shapes/video/VideoShapeUtil.mjs.map +7 -0
- package/dist-esm/lib/tools/EraserTool/EraserTool.mjs +16 -0
- package/dist-esm/lib/tools/EraserTool/EraserTool.mjs.map +7 -0
- package/dist-esm/lib/tools/EraserTool/childStates/Erasing.mjs +95 -0
- package/dist-esm/lib/tools/EraserTool/childStates/Erasing.mjs.map +7 -0
- package/dist-esm/lib/tools/EraserTool/childStates/Idle.mjs +14 -0
- package/dist-esm/lib/tools/EraserTool/childStates/Idle.mjs.map +7 -0
- package/dist-esm/lib/tools/EraserTool/childStates/Pointing.mjs +67 -0
- package/dist-esm/lib/tools/EraserTool/childStates/Pointing.mjs.map +7 -0
- package/dist-esm/lib/tools/HandTool/HandTool.mjs +38 -0
- package/dist-esm/lib/tools/HandTool/HandTool.mjs.map +7 -0
- package/dist-esm/lib/tools/HandTool/childStates/Dragging.mjs +38 -0
- package/dist-esm/lib/tools/HandTool/childStates/Dragging.mjs.map +7 -0
- package/dist-esm/lib/tools/HandTool/childStates/Idle.mjs +17 -0
- package/dist-esm/lib/tools/HandTool/childStates/Idle.mjs.map +7 -0
- package/dist-esm/lib/tools/HandTool/childStates/Pointing.mjs +35 -0
- package/dist-esm/lib/tools/HandTool/childStates/Pointing.mjs.map +7 -0
- package/dist-esm/lib/tools/LaserTool/LaserTool.mjs +15 -0
- package/dist-esm/lib/tools/LaserTool/LaserTool.mjs.map +7 -0
- package/dist-esm/lib/tools/LaserTool/childStates/Idle.mjs +11 -0
- package/dist-esm/lib/tools/LaserTool/childStates/Idle.mjs.map +7 -0
- package/dist-esm/lib/tools/LaserTool/childStates/Lasering.mjs +46 -0
- package/dist-esm/lib/tools/LaserTool/childStates/Lasering.mjs.map +7 -0
- package/dist-esm/lib/tools/SelectTool/DragAndDropManager.mjs +80 -0
- package/dist-esm/lib/tools/SelectTool/DragAndDropManager.mjs.map +7 -0
- package/dist-esm/lib/tools/SelectTool/SelectTool.mjs +50 -0
- package/dist-esm/lib/tools/SelectTool/SelectTool.mjs.map +7 -0
- package/dist-esm/lib/tools/SelectTool/childStates/Brushing.mjs +131 -0
- package/dist-esm/lib/tools/SelectTool/childStates/Brushing.mjs.map +7 -0
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/Crop.mjs +13 -0
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/Crop.mjs.map +7 -0
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/Idle.mjs +187 -0
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/Idle.mjs.map +7 -0
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.mjs +19 -0
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.mjs.map +7 -0
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.mjs +81 -0
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.mjs.map +7 -0
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.mjs +40 -0
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.mjs.map +7 -0
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/crop-constants.mjs +5 -0
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/crop-constants.mjs.map +7 -0
- package/dist-esm/lib/tools/SelectTool/childStates/Cropping.mjs +194 -0
- package/dist-esm/lib/tools/SelectTool/childStates/Cropping.mjs.map +7 -0
- package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs +217 -0
- package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs.map +7 -0
- package/dist-esm/lib/tools/SelectTool/childStates/EditingShape.mjs +103 -0
- package/dist-esm/lib/tools/SelectTool/childStates/EditingShape.mjs.map +7 -0
- package/dist-esm/lib/tools/SelectTool/childStates/Idle.mjs +447 -0
- package/dist-esm/lib/tools/SelectTool/childStates/Idle.mjs.map +7 -0
- package/dist-esm/lib/tools/SelectTool/childStates/PointingCanvas.mjs +36 -0
- package/dist-esm/lib/tools/SelectTool/childStates/PointingCanvas.mjs.map +7 -0
- package/dist-esm/lib/tools/SelectTool/childStates/PointingCropHandle.mjs +69 -0
- package/dist-esm/lib/tools/SelectTool/childStates/PointingCropHandle.mjs.map +7 -0
- package/dist-esm/lib/tools/SelectTool/childStates/PointingHandle.mjs +47 -0
- package/dist-esm/lib/tools/SelectTool/childStates/PointingHandle.mjs.map +7 -0
- package/dist-esm/lib/tools/SelectTool/childStates/PointingResizeHandle.mjs +73 -0
- package/dist-esm/lib/tools/SelectTool/childStates/PointingResizeHandle.mjs.map +7 -0
- package/dist-esm/lib/tools/SelectTool/childStates/PointingRotateHandle.mjs +63 -0
- package/dist-esm/lib/tools/SelectTool/childStates/PointingRotateHandle.mjs.map +7 -0
- package/dist-esm/lib/tools/SelectTool/childStates/PointingSelection.mjs +55 -0
- package/dist-esm/lib/tools/SelectTool/childStates/PointingSelection.mjs.map +7 -0
- package/dist-esm/lib/tools/SelectTool/childStates/PointingShape.mjs +159 -0
- package/dist-esm/lib/tools/SelectTool/childStates/PointingShape.mjs.map +7 -0
- package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs +360 -0
- package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs.map +7 -0
- package/dist-esm/lib/tools/SelectTool/childStates/Rotating.mjs +136 -0
- package/dist-esm/lib/tools/SelectTool/childStates/Rotating.mjs.map +7 -0
- package/dist-esm/lib/tools/SelectTool/childStates/ScribbleBrushing.mjs +125 -0
- package/dist-esm/lib/tools/SelectTool/childStates/ScribbleBrushing.mjs.map +7 -0
- package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs +302 -0
- package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs.map +7 -0
- package/dist-esm/lib/tools/SelectTool/children/DraggingHandle.mjs +217 -0
- package/dist-esm/lib/tools/SelectTool/children/DraggingHandle.mjs.map +7 -0
- package/dist-esm/lib/tools/ZoomTool/ZoomTool.mjs +61 -0
- package/dist-esm/lib/tools/ZoomTool/ZoomTool.mjs.map +7 -0
- package/dist-esm/lib/tools/ZoomTool/childStates/Idle.mjs +15 -0
- package/dist-esm/lib/tools/ZoomTool/childStates/Idle.mjs.map +7 -0
- package/dist-esm/lib/tools/ZoomTool/childStates/Pointing.mjs +35 -0
- package/dist-esm/lib/tools/ZoomTool/childStates/Pointing.mjs.map +7 -0
- package/dist-esm/lib/tools/ZoomTool/childStates/ZoomBrushing.mjs +52 -0
- package/dist-esm/lib/tools/ZoomTool/childStates/ZoomBrushing.mjs.map +7 -0
- package/dist-esm/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.mjs +21 -0
- package/dist-esm/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.mjs.map +7 -0
- package/dist-esm/lib/tools/selection-logic/getShouldEnterCropModeOnPointerDown.mjs +8 -0
- package/dist-esm/lib/tools/selection-logic/getShouldEnterCropModeOnPointerDown.mjs.map +7 -0
- package/dist-esm/lib/tools/selection-logic/selectOnCanvasPointerUp.mjs +60 -0
- package/dist-esm/lib/tools/selection-logic/selectOnCanvasPointerUp.mjs.map +7 -0
- package/dist-esm/lib/tools/selection-logic/updateHoveredId.mjs +27 -0
- package/dist-esm/lib/tools/selection-logic/updateHoveredId.mjs.map +7 -0
- package/dist-esm/lib/ui/TldrawUi.mjs +125 -0
- package/dist-esm/lib/ui/TldrawUi.mjs.map +7 -0
- package/dist-esm/lib/ui/TldrawUiContextProvider.mjs +37 -0
- package/dist-esm/lib/ui/TldrawUiContextProvider.mjs.map +7 -0
- package/dist-esm/lib/ui/assetUrls.mjs +47 -0
- package/dist-esm/lib/ui/assetUrls.mjs.map +7 -0
- package/dist-esm/lib/ui/components/ActionsMenu.mjs +66 -0
- package/dist-esm/lib/ui/components/ActionsMenu.mjs.map +7 -0
- package/dist-esm/lib/ui/components/BackToContent.mjs +47 -0
- package/dist-esm/lib/ui/components/BackToContent.mjs.map +7 -0
- package/dist-esm/lib/ui/components/ContextMenu.mjs +184 -0
- package/dist-esm/lib/ui/components/ContextMenu.mjs.map +7 -0
- package/dist-esm/lib/ui/components/DebugPanel.mjs +315 -0
- package/dist-esm/lib/ui/components/DebugPanel.mjs.map +7 -0
- package/dist-esm/lib/ui/components/Dialogs.mjs +34 -0
- package/dist-esm/lib/ui/components/Dialogs.mjs.map +7 -0
- package/dist-esm/lib/ui/components/DuplicateButton.mjs +27 -0
- package/dist-esm/lib/ui/components/DuplicateButton.mjs.map +7 -0
- package/dist-esm/lib/ui/components/EditLinkDialog.mjs +131 -0
- package/dist-esm/lib/ui/components/EditLinkDialog.mjs.map +7 -0
- package/dist-esm/lib/ui/components/EmbedDialog.mjs +122 -0
- package/dist-esm/lib/ui/components/EmbedDialog.mjs.map +7 -0
- package/dist-esm/lib/ui/components/FollowingIndicator.mjs +21 -0
- package/dist-esm/lib/ui/components/FollowingIndicator.mjs.map +7 -0
- package/dist-esm/lib/ui/components/HTMLCanvas.mjs +36 -0
- package/dist-esm/lib/ui/components/HTMLCanvas.mjs.map +7 -0
- package/dist-esm/lib/ui/components/HelpMenu.mjs +86 -0
- package/dist-esm/lib/ui/components/HelpMenu.mjs.map +7 -0
- package/dist-esm/lib/ui/components/KeyboardShortcutsDialog.mjs +44 -0
- package/dist-esm/lib/ui/components/KeyboardShortcutsDialog.mjs.map +7 -0
- package/dist-esm/lib/ui/components/LanguageMenu.mjs +30 -0
- package/dist-esm/lib/ui/components/LanguageMenu.mjs.map +7 -0
- package/dist-esm/lib/ui/components/Menu.mjs +109 -0
- package/dist-esm/lib/ui/components/Menu.mjs.map +7 -0
- package/dist-esm/lib/ui/components/MenuZone.mjs +31 -0
- package/dist-esm/lib/ui/components/MenuZone.mjs.map +7 -0
- package/dist-esm/lib/ui/components/MobileStylePanel.mjs +54 -0
- package/dist-esm/lib/ui/components/MobileStylePanel.mjs.map +7 -0
- package/dist-esm/lib/ui/components/MoveToPageMenu.mjs +112 -0
- package/dist-esm/lib/ui/components/MoveToPageMenu.mjs.map +7 -0
- package/dist-esm/lib/ui/components/NavigationZone/Minimap.mjs +191 -0
- package/dist-esm/lib/ui/components/NavigationZone/Minimap.mjs.map +7 -0
- package/dist-esm/lib/ui/components/NavigationZone/MinimapManager.mjs +279 -0
- package/dist-esm/lib/ui/components/NavigationZone/MinimapManager.mjs.map +7 -0
- package/dist-esm/lib/ui/components/NavigationZone/NavigationZone.mjs +83 -0
- package/dist-esm/lib/ui/components/NavigationZone/NavigationZone.mjs.map +7 -0
- package/dist-esm/lib/ui/components/NavigationZone/ZoomMenu.mjs +88 -0
- package/dist-esm/lib/ui/components/NavigationZone/ZoomMenu.mjs.map +7 -0
- package/dist-esm/lib/ui/components/OfflineIndicator/OfflineIndicator.mjs +17 -0
- package/dist-esm/lib/ui/components/OfflineIndicator/OfflineIndicator.mjs.map +7 -0
- package/dist-esm/lib/ui/components/PageMenu/PageItemInput.mjs +43 -0
- package/dist-esm/lib/ui/components/PageMenu/PageItemInput.mjs.map +7 -0
- package/dist-esm/lib/ui/components/PageMenu/PageItemSubmenu.mjs +58 -0
- package/dist-esm/lib/ui/components/PageMenu/PageItemSubmenu.mjs.map +7 -0
- package/dist-esm/lib/ui/components/PageMenu/PageMenu.mjs +381 -0
- package/dist-esm/lib/ui/components/PageMenu/PageMenu.mjs.map +7 -0
- package/dist-esm/lib/ui/components/PageMenu/edit-pages-shared.mjs +29 -0
- package/dist-esm/lib/ui/components/PageMenu/edit-pages-shared.mjs.map +7 -0
- package/dist-esm/lib/ui/components/PenModeToggle.mjs +25 -0
- package/dist-esm/lib/ui/components/PenModeToggle.mjs.map +7 -0
- package/dist-esm/lib/ui/components/RedoButton.mjs +29 -0
- package/dist-esm/lib/ui/components/RedoButton.mjs.map +7 -0
- package/dist-esm/lib/ui/components/Spinner.mjs +21 -0
- package/dist-esm/lib/ui/components/Spinner.mjs.map +7 -0
- package/dist-esm/lib/ui/components/StopFollowing.mjs +25 -0
- package/dist-esm/lib/ui/components/StopFollowing.mjs.map +7 -0
- package/dist-esm/lib/ui/components/StylePanel/DoubleDropdownPicker.mjs +108 -0
- package/dist-esm/lib/ui/components/StylePanel/DoubleDropdownPicker.mjs.map +7 -0
- package/dist-esm/lib/ui/components/StylePanel/DropdownPicker.mjs +59 -0
- package/dist-esm/lib/ui/components/StylePanel/DropdownPicker.mjs.map +7 -0
- package/dist-esm/lib/ui/components/StylePanel/StylePanel.mjs +297 -0
- package/dist-esm/lib/ui/components/StylePanel/StylePanel.mjs.map +7 -0
- package/dist-esm/lib/ui/components/StylePanel/styles.mjs +99 -0
- package/dist-esm/lib/ui/components/StylePanel/styles.mjs.map +7 -0
- package/dist-esm/lib/ui/components/Toasts.mjs +71 -0
- package/dist-esm/lib/ui/components/Toasts.mjs.map +7 -0
- package/dist-esm/lib/ui/components/Toolbar/ToggleToolLockedButton.mjs +43 -0
- package/dist-esm/lib/ui/components/Toolbar/ToggleToolLockedButton.mjs.map +7 -0
- package/dist-esm/lib/ui/components/Toolbar/Toolbar.mjs +217 -0
- package/dist-esm/lib/ui/components/Toolbar/Toolbar.mjs.map +7 -0
- package/dist-esm/lib/ui/components/TrashButton.mjs +31 -0
- package/dist-esm/lib/ui/components/TrashButton.mjs.map +7 -0
- package/dist-esm/lib/ui/components/UndoButton.mjs +29 -0
- package/dist-esm/lib/ui/components/UndoButton.mjs.map +7 -0
- package/dist-esm/lib/ui/components/primitives/Button.mjs +49 -0
- package/dist-esm/lib/ui/components/primitives/Button.mjs.map +7 -0
- package/dist-esm/lib/ui/components/primitives/ButtonPicker.mjs +96 -0
- package/dist-esm/lib/ui/components/primitives/ButtonPicker.mjs.map +7 -0
- package/dist-esm/lib/ui/components/primitives/Dialog.mjs +40 -0
- package/dist-esm/lib/ui/components/primitives/Dialog.mjs.map +7 -0
- package/dist-esm/lib/ui/components/primitives/DropdownMenu.mjs +157 -0
- package/dist-esm/lib/ui/components/primitives/DropdownMenu.mjs.map +7 -0
- package/dist-esm/lib/ui/components/primitives/Icon.mjs +41 -0
- package/dist-esm/lib/ui/components/primitives/Icon.mjs.map +7 -0
- package/dist-esm/lib/ui/components/primitives/Input.mjs +125 -0
- package/dist-esm/lib/ui/components/primitives/Input.mjs.map +7 -0
- package/dist-esm/lib/ui/components/primitives/Kbd.mjs +9 -0
- package/dist-esm/lib/ui/components/primitives/Kbd.mjs.map +7 -0
- package/dist-esm/lib/ui/components/primitives/Popover.mjs +39 -0
- package/dist-esm/lib/ui/components/primitives/Popover.mjs.map +7 -0
- package/dist-esm/lib/ui/components/primitives/Slider.mjs +49 -0
- package/dist-esm/lib/ui/components/primitives/Slider.mjs.map +7 -0
- package/dist-esm/lib/ui/components/primitives/shared.mjs +24 -0
- package/dist-esm/lib/ui/components/primitives/shared.mjs.map +7 -0
- package/dist-esm/lib/ui/constants.mjs +5 -0
- package/dist-esm/lib/ui/constants.mjs.map +7 -0
- package/dist-esm/lib/ui/hooks/clipboard/pasteExcalidrawContent.mjs +444 -0
- package/dist-esm/lib/ui/hooks/clipboard/pasteExcalidrawContent.mjs.map +7 -0
- package/dist-esm/lib/ui/hooks/clipboard/pasteFiles.mjs +17 -0
- package/dist-esm/lib/ui/hooks/clipboard/pasteFiles.mjs.map +7 -0
- package/dist-esm/lib/ui/hooks/clipboard/pasteTldrawContent.mjs +12 -0
- package/dist-esm/lib/ui/hooks/clipboard/pasteTldrawContent.mjs.map +7 -0
- package/dist-esm/lib/ui/hooks/clipboard/pasteUrl.mjs +28 -0
- package/dist-esm/lib/ui/hooks/clipboard/pasteUrl.mjs.map +7 -0
- package/dist-esm/lib/ui/hooks/menuHelpers.mjs +157 -0
- package/dist-esm/lib/ui/hooks/menuHelpers.mjs.map +7 -0
- package/dist-esm/lib/ui/hooks/useActions.mjs +1132 -0
- package/dist-esm/lib/ui/hooks/useActions.mjs.map +7 -0
- package/dist-esm/lib/ui/hooks/useActionsMenuSchema.mjs +87 -0
- package/dist-esm/lib/ui/hooks/useActionsMenuSchema.mjs.map +7 -0
- package/dist-esm/lib/ui/hooks/useAssetUrls.mjs +21 -0
- package/dist-esm/lib/ui/hooks/useAssetUrls.mjs.map +7 -0
- package/dist-esm/lib/ui/hooks/useBreakpoint.mjs +34 -0
- package/dist-esm/lib/ui/hooks/useBreakpoint.mjs.map +7 -0
- package/dist-esm/lib/ui/hooks/useCanRedo.mjs +9 -0
- package/dist-esm/lib/ui/hooks/useCanRedo.mjs.map +7 -0
- package/dist-esm/lib/ui/hooks/useCanUndo.mjs +9 -0
- package/dist-esm/lib/ui/hooks/useCanUndo.mjs.map +7 -0
- package/dist-esm/lib/ui/hooks/useClipboardEvents.mjs +448 -0
- package/dist-esm/lib/ui/hooks/useClipboardEvents.mjs.map +7 -0
- package/dist-esm/lib/ui/hooks/useContextMenuSchema.mjs +208 -0
- package/dist-esm/lib/ui/hooks/useContextMenuSchema.mjs.map +7 -0
- package/dist-esm/lib/ui/hooks/useCopyAs.mjs +27 -0
- package/dist-esm/lib/ui/hooks/useCopyAs.mjs.map +7 -0
- package/dist-esm/lib/ui/hooks/useDialogsProvider.mjs +88 -0
- package/dist-esm/lib/ui/hooks/useDialogsProvider.mjs.map +7 -0
- package/dist-esm/lib/ui/hooks/useEditorEvents.mjs +23 -0
- package/dist-esm/lib/ui/hooks/useEditorEvents.mjs.map +7 -0
- package/dist-esm/lib/ui/hooks/useEventsProvider.mjs +17 -0
- package/dist-esm/lib/ui/hooks/useEventsProvider.mjs.map +7 -0
- package/dist-esm/lib/ui/hooks/useExportAs.mjs +31 -0
- package/dist-esm/lib/ui/hooks/useExportAs.mjs.map +7 -0
- package/dist-esm/lib/ui/hooks/useHasLinkShapeSelected.mjs +16 -0
- package/dist-esm/lib/ui/hooks/useHasLinkShapeSelected.mjs.map +7 -0
- package/dist-esm/lib/ui/hooks/useHelpMenuSchema.mjs +73 -0
- package/dist-esm/lib/ui/hooks/useHelpMenuSchema.mjs.map +7 -0
- package/dist-esm/lib/ui/hooks/useHighDpiCanvas.mjs +15 -0
- package/dist-esm/lib/ui/hooks/useHighDpiCanvas.mjs.map +7 -0
- package/dist-esm/lib/ui/hooks/useInsertMedia.mjs +37 -0
- package/dist-esm/lib/ui/hooks/useInsertMedia.mjs.map +7 -0
- package/dist-esm/lib/ui/hooks/useKeyboardShortcuts.mjs +108 -0
- package/dist-esm/lib/ui/hooks/useKeyboardShortcuts.mjs.map +7 -0
- package/dist-esm/lib/ui/hooks/useKeyboardShortcutsSchema.mjs +104 -0
- package/dist-esm/lib/ui/hooks/useKeyboardShortcutsSchema.mjs.map +7 -0
- package/dist-esm/lib/ui/hooks/useLocalStorageState.mjs +29 -0
- package/dist-esm/lib/ui/hooks/useLocalStorageState.mjs.map +7 -0
- package/dist-esm/lib/ui/hooks/useMenuIsOpen.mjs +54 -0
- package/dist-esm/lib/ui/hooks/useMenuIsOpen.mjs.map +7 -0
- package/dist-esm/lib/ui/hooks/useMenuSchema.mjs +239 -0
- package/dist-esm/lib/ui/hooks/useMenuSchema.mjs.map +7 -0
- package/dist-esm/lib/ui/hooks/useOnlyFlippableShape.mjs +21 -0
- package/dist-esm/lib/ui/hooks/useOnlyFlippableShape.mjs.map +7 -0
- package/dist-esm/lib/ui/hooks/usePreloadAssets.mjs +86 -0
- package/dist-esm/lib/ui/hooks/usePreloadAssets.mjs.map +7 -0
- package/dist-esm/lib/ui/hooks/usePreloadIcons.mjs +31 -0
- package/dist-esm/lib/ui/hooks/usePreloadIcons.mjs.map +7 -0
- package/dist-esm/lib/ui/hooks/usePrint.mjs +200 -0
- package/dist-esm/lib/ui/hooks/usePrint.mjs.map +7 -0
- package/dist-esm/lib/ui/hooks/useReadonly.mjs +9 -0
- package/dist-esm/lib/ui/hooks/useReadonly.mjs.map +7 -0
- package/dist-esm/lib/ui/hooks/useRevelantStyles.mjs +33 -0
- package/dist-esm/lib/ui/hooks/useRevelantStyles.mjs.map +7 -0
- package/dist-esm/lib/ui/hooks/useShowAutoSizeToggle.mjs +16 -0
- package/dist-esm/lib/ui/hooks/useShowAutoSizeToggle.mjs.map +7 -0
- package/dist-esm/lib/ui/hooks/useToastsProvider.mjs +33 -0
- package/dist-esm/lib/ui/hooks/useToastsProvider.mjs.map +7 -0
- package/dist-esm/lib/ui/hooks/useToolbarSchema.mjs +69 -0
- package/dist-esm/lib/ui/hooks/useToolbarSchema.mjs.map +7 -0
- package/dist-esm/lib/ui/hooks/useTools.mjs +205 -0
- package/dist-esm/lib/ui/hooks/useTools.mjs.map +7 -0
- package/dist-esm/lib/ui/hooks/useTranslation/TLUiTranslationKey.mjs +1 -0
- package/dist-esm/lib/ui/hooks/useTranslation/TLUiTranslationKey.mjs.map +7 -0
- package/dist-esm/lib/ui/hooks/useTranslation/defaultTranslation.mjs +357 -0
- package/dist-esm/lib/ui/hooks/useTranslation/defaultTranslation.mjs.map +7 -0
- package/dist-esm/lib/ui/hooks/useTranslation/translations.mjs +47 -0
- package/dist-esm/lib/ui/hooks/useTranslation/translations.mjs.map +7 -0
- package/dist-esm/lib/ui/hooks/useTranslation/useLanguages.mjs +12 -0
- package/dist-esm/lib/ui/hooks/useTranslation/useLanguages.mjs.map +7 -0
- package/dist-esm/lib/ui/hooks/useTranslation/useTranslation.mjs +71 -0
- package/dist-esm/lib/ui/hooks/useTranslation/useTranslation.mjs.map +7 -0
- package/dist-esm/lib/ui/icon-types.mjs +170 -0
- package/dist-esm/lib/ui/icon-types.mjs.map +7 -0
- package/dist-esm/lib/ui/overrides.mjs +158 -0
- package/dist-esm/lib/ui/overrides.mjs.map +7 -0
- package/dist-esm/lib/ui/version.mjs +5 -0
- package/dist-esm/lib/ui/version.mjs.map +7 -0
- package/dist-esm/lib/utils/assets/assets.mjs +61 -0
- package/dist-esm/lib/utils/assets/assets.mjs.map +7 -0
- package/dist-esm/lib/utils/assets/is-gif-animated.mjs +54 -0
- package/dist-esm/lib/utils/assets/is-gif-animated.mjs.map +7 -0
- package/dist-esm/lib/utils/assets.mjs +61 -0
- package/dist-esm/lib/utils/assets.mjs.map +7 -0
- package/dist-esm/lib/utils/embeds/embeds.mjs +65 -0
- package/dist-esm/lib/utils/embeds/embeds.mjs.map +7 -0
- package/dist-esm/lib/utils/export/copyAs.mjs +96 -0
- package/dist-esm/lib/utils/export/copyAs.mjs.map +7 -0
- package/dist-esm/lib/utils/export/export.mjs +97 -0
- package/dist-esm/lib/utils/export/export.mjs.map +7 -0
- package/dist-esm/lib/utils/export/exportAs.mjs +68 -0
- package/dist-esm/lib/utils/export/exportAs.mjs.map +7 -0
- package/dist-esm/lib/utils/frames/frames.mjs +76 -0
- package/dist-esm/lib/utils/frames/frames.mjs.map +7 -0
- package/dist-esm/lib/utils/static-assets/assetUrls.mjs +28 -0
- package/dist-esm/lib/utils/static-assets/assetUrls.mjs.map +7 -0
- package/dist-esm/lib/utils/text/text.mjs +37 -0
- package/dist-esm/lib/utils/text/text.mjs.map +7 -0
- package/dist-esm/lib/utils/tldr/buildFromV1Document.mjs +779 -0
- package/dist-esm/lib/utils/tldr/buildFromV1Document.mjs.map +7 -0
- package/dist-esm/lib/utils/tldr/file.mjs +219 -0
- package/dist-esm/lib/utils/tldr/file.mjs.map +7 -0
- package/package.json +105 -0
- package/src/index.ts +174 -0
- package/src/lib/Tldraw.test.tsx +78 -0
- package/src/lib/Tldraw.tsx +179 -0
- package/src/lib/canvas/TldrawCropHandles.tsx +126 -0
- package/src/lib/canvas/TldrawHandles.tsx +15 -0
- package/src/lib/canvas/TldrawHoveredShapeIndicator.tsx +30 -0
- package/src/lib/canvas/TldrawScribble.tsx +45 -0
- package/src/lib/canvas/TldrawSelectionBackground.tsx +29 -0
- package/src/lib/canvas/TldrawSelectionForeground.tsx +526 -0
- package/src/lib/defaultExternalContentHandlers.ts +533 -0
- package/src/lib/defaultShapeTools.ts +20 -0
- package/src/lib/defaultShapeUtils.ts +29 -0
- package/src/lib/defaultSideEffects.ts +48 -0
- package/src/lib/defaultTools.ts +8 -0
- package/src/lib/shapes/arrow/ArrowShapeTool.test.ts +558 -0
- package/src/lib/shapes/arrow/ArrowShapeTool.ts +12 -0
- package/src/lib/shapes/arrow/ArrowShapeUtil.test.ts +595 -0
- package/src/lib/shapes/arrow/ArrowShapeUtil.tsx +1036 -0
- package/src/lib/shapes/arrow/components/ArrowTextLabel.tsx +87 -0
- package/src/lib/shapes/arrow/toolStates/Idle.ts +37 -0
- package/src/lib/shapes/arrow/toolStates/Pointing.ts +190 -0
- package/src/lib/shapes/bookmark/BookmarkShapeUtil.tsx +196 -0
- package/src/lib/shapes/draw/DrawShapeTool.test.ts +52 -0
- package/src/lib/shapes/draw/DrawShapeTool.ts +17 -0
- package/src/lib/shapes/draw/DrawShapeUtil.tsx +298 -0
- package/src/lib/shapes/draw/getPath.ts +108 -0
- package/src/lib/shapes/draw/toolStates/Drawing.ts +722 -0
- package/src/lib/shapes/draw/toolStates/Idle.ts +17 -0
- package/src/lib/shapes/embed/EmbedShapeUtil.tsx +218 -0
- package/src/lib/shapes/frame/FrameShapeTool.test.ts +169 -0
- package/src/lib/shapes/frame/FrameShapeTool.ts +53 -0
- package/src/lib/shapes/frame/FrameShapeUtil.tsx +258 -0
- package/src/lib/shapes/frame/components/FrameHeading.tsx +115 -0
- package/src/lib/shapes/frame/components/FrameLabelInput.tsx +85 -0
- package/src/lib/shapes/geo/GeoShapeTool.test.ts +191 -0
- package/src/lib/shapes/geo/GeoShapeTool.ts +11 -0
- package/src/lib/shapes/geo/GeoShapeUtil.tsx +1153 -0
- package/src/lib/shapes/geo/cloudOutline.ts +391 -0
- package/src/lib/shapes/geo/components/DashStyleCloud.tsx +135 -0
- package/src/lib/shapes/geo/components/DashStyleEllipse.tsx +117 -0
- package/src/lib/shapes/geo/components/DashStyleOval.tsx +102 -0
- package/src/lib/shapes/geo/components/DashStylePolygon.tsx +152 -0
- package/src/lib/shapes/geo/components/DrawStyleCloud.tsx +65 -0
- package/src/lib/shapes/geo/components/DrawStyleEllipse.tsx +145 -0
- package/src/lib/shapes/geo/components/DrawStylePolygon.tsx +263 -0
- package/src/lib/shapes/geo/components/SolidStyleCloud.tsx +65 -0
- package/src/lib/shapes/geo/components/SolidStyleEllipse.tsx +68 -0
- package/src/lib/shapes/geo/components/SolidStyleOval.tsx +83 -0
- package/src/lib/shapes/geo/components/SolidStylePolygon.tsx +77 -0
- package/src/lib/shapes/geo/helpers.ts +34 -0
- package/src/lib/shapes/geo/toolStates/Idle.ts +38 -0
- package/src/lib/shapes/geo/toolStates/Pointing.ts +131 -0
- package/src/lib/shapes/highlight/HighlightShapeTool.test.ts +3 -0
- package/src/lib/shapes/highlight/HighlightShapeTool.ts +17 -0
- package/src/lib/shapes/highlight/HighlightShapeUtil.tsx +255 -0
- package/src/lib/shapes/image/ImageShapeUtil.tsx +313 -0
- package/src/lib/shapes/line/LineShapeTool.test.ts +228 -0
- package/src/lib/shapes/line/LineShapeTool.ts +12 -0
- package/src/lib/shapes/line/LineShapeUtil.test.ts +222 -0
- package/src/lib/shapes/line/LineShapeUtil.tsx +421 -0
- package/src/lib/shapes/line/__snapshots__/LineShapeUtil.test.ts.snap +41 -0
- package/src/lib/shapes/line/components/getLinePath.ts +91 -0
- package/src/lib/shapes/line/components/svg.ts +62 -0
- package/src/lib/shapes/line/toolStates/Idle.ts +20 -0
- package/src/lib/shapes/line/toolStates/Pointing.ts +165 -0
- package/src/lib/shapes/note/NoteShapeTool.test.ts +146 -0
- package/src/lib/shapes/note/NoteShapeTool.ts +11 -0
- package/src/lib/shapes/note/NoteShapeUtil.tsx +221 -0
- package/src/lib/shapes/note/toolStates/Idle.ts +17 -0
- package/src/lib/shapes/note/toolStates/Pointing.ts +121 -0
- package/src/lib/shapes/shared/HyperlinkButton.tsx +30 -0
- package/src/lib/shapes/shared/ShapeFill.tsx +113 -0
- package/src/lib/shapes/shared/TextHelpers.ts +289 -0
- package/src/lib/shapes/shared/TextLabel.tsx +131 -0
- package/src/lib/shapes/shared/createTextSvgElementFromSpans.ts +101 -0
- package/src/lib/shapes/shared/default-shape-constants.ts +57 -0
- package/src/lib/shapes/shared/defaultStyleDefs.tsx +276 -0
- package/src/lib/shapes/shared/freehand/getStroke.ts +23 -0
- package/src/lib/shapes/shared/freehand/getStrokeOutlinePoints.ts +333 -0
- package/src/lib/shapes/shared/freehand/getStrokePoints.ts +187 -0
- package/src/lib/shapes/shared/freehand/getStrokeRadius.ts +13 -0
- package/src/lib/shapes/shared/freehand/setStrokePointRadii.ts +127 -0
- package/src/lib/shapes/shared/freehand/svg.ts +50 -0
- package/src/lib/shapes/shared/freehand/svgInk.ts +195 -0
- package/src/lib/shapes/shared/freehand/types.ts +49 -0
- package/src/lib/shapes/shared/getBrowserCanvasMaxSize.tsx +28 -0
- package/src/lib/shapes/shared/getPerfectDashProps.ts +96 -0
- package/src/lib/shapes/shared/getTextLabelSvgElement.ts +42 -0
- package/src/lib/shapes/shared/legacyProps.ts +25 -0
- package/src/lib/shapes/shared/polygon-helpers.ts +131 -0
- package/src/lib/shapes/shared/resizeBox.ts +130 -0
- package/src/lib/shapes/shared/resizeScaled.ts +40 -0
- package/src/lib/shapes/shared/rotated-box-shadow.ts +29 -0
- package/src/lib/shapes/shared/useColorSpace.tsx +21 -0
- package/src/lib/shapes/shared/useEditableText.ts +211 -0
- package/src/lib/shapes/shared/useForceSolid.ts +6 -0
- package/src/lib/shapes/shared/usePrefersReducedMotion.tsx +18 -0
- package/src/lib/shapes/text/TextShapeTool.test.ts +157 -0
- package/src/lib/shapes/text/TextShapeTool.ts +11 -0
- package/src/lib/shapes/text/TextShapeUtil.tsx +401 -0
- package/src/lib/shapes/text/toolStates/Idle.ts +47 -0
- package/src/lib/shapes/text/toolStates/Pointing.ts +105 -0
- package/src/lib/shapes/video/VideoShapeUtil.tsx +215 -0
- package/src/lib/tools/EraserTool/EraserTool.ts +15 -0
- package/src/lib/tools/EraserTool/childStates/Erasing.ts +131 -0
- package/src/lib/tools/EraserTool/childStates/Idle.ts +13 -0
- package/src/lib/tools/EraserTool/childStates/Pointing.ts +93 -0
- package/src/lib/tools/HandTool/HandTool.ts +40 -0
- package/src/lib/tools/HandTool/childStates/Dragging.ts +45 -0
- package/src/lib/tools/HandTool/childStates/Idle.ts +17 -0
- package/src/lib/tools/HandTool/childStates/Pointing.ts +39 -0
- package/src/lib/tools/LaserTool/LaserTool.ts +14 -0
- package/src/lib/tools/LaserTool/childStates/Idle.ts +9 -0
- package/src/lib/tools/LaserTool/childStates/Lasering.ts +53 -0
- package/src/lib/tools/SelectTool/DragAndDropManager.ts +112 -0
- package/src/lib/tools/SelectTool/SelectTool.ts +49 -0
- package/src/lib/tools/SelectTool/childStates/Brushing.ts +206 -0
- package/src/lib/tools/SelectTool/childStates/Crop/Crop.ts +10 -0
- package/src/lib/tools/SelectTool/childStates/Crop/children/Idle.ts +217 -0
- package/src/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.ts +19 -0
- package/src/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.ts +108 -0
- package/src/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.ts +64 -0
- package/src/lib/tools/SelectTool/childStates/Crop/crop-constants.ts +2 -0
- package/src/lib/tools/SelectTool/childStates/Cropping.ts +249 -0
- package/src/lib/tools/SelectTool/childStates/DraggingHandle.ts +308 -0
- package/src/lib/tools/SelectTool/childStates/EditingShape.ts +130 -0
- package/src/lib/tools/SelectTool/childStates/Idle.ts +575 -0
- package/src/lib/tools/SelectTool/childStates/PointingCanvas.ts +41 -0
- package/src/lib/tools/SelectTool/childStates/PointingCropHandle.ts +83 -0
- package/src/lib/tools/SelectTool/childStates/PointingHandle.ts +56 -0
- package/src/lib/tools/SelectTool/childStates/PointingResizeHandle.ts +90 -0
- package/src/lib/tools/SelectTool/childStates/PointingRotateHandle.ts +76 -0
- package/src/lib/tools/SelectTool/childStates/PointingSelection.ts +71 -0
- package/src/lib/tools/SelectTool/childStates/PointingShape.ts +218 -0
- package/src/lib/tools/SelectTool/childStates/Resizing.ts +511 -0
- package/src/lib/tools/SelectTool/childStates/Rotating.ts +175 -0
- package/src/lib/tools/SelectTool/childStates/ScribbleBrushing.ts +167 -0
- package/src/lib/tools/SelectTool/childStates/Translating.ts +418 -0
- package/src/lib/tools/SelectTool/children/DraggingHandle.ts +308 -0
- package/src/lib/tools/ZoomTool/ZoomTool.ts +72 -0
- package/src/lib/tools/ZoomTool/childStates/Idle.ts +15 -0
- package/src/lib/tools/ZoomTool/childStates/Pointing.ts +39 -0
- package/src/lib/tools/ZoomTool/childStates/ZoomBrushing.ts +62 -0
- package/src/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.ts +20 -0
- package/src/lib/tools/selection-logic/getShouldEnterCropModeOnPointerDown.ts +10 -0
- package/src/lib/tools/selection-logic/selectOnCanvasPointerUp.ts +94 -0
- package/src/lib/tools/selection-logic/selection.tldr +1041 -0
- package/src/lib/tools/selection-logic/updateHoveredId.ts +32 -0
- package/src/lib/ui/TldrawUi.tsx +195 -0
- package/src/lib/ui/TldrawUiContextProvider.tsx +99 -0
- package/src/lib/ui/assetUrls.ts +57 -0
- package/src/lib/ui/components/ActionsMenu.tsx +75 -0
- package/src/lib/ui/components/BackToContent.tsx +55 -0
- package/src/lib/ui/components/ContextMenu.tsx +234 -0
- package/src/lib/ui/components/DebugPanel.tsx +355 -0
- package/src/lib/ui/components/Dialogs.tsx +52 -0
- package/src/lib/ui/components/DuplicateButton.tsx +23 -0
- package/src/lib/ui/components/EditLinkDialog.tsx +180 -0
- package/src/lib/ui/components/EmbedDialog.tsx +143 -0
- package/src/lib/ui/components/FollowingIndicator.tsx +16 -0
- package/src/lib/ui/components/HTMLCanvas.tsx +54 -0
- package/src/lib/ui/components/HelpMenu.tsx +109 -0
- package/src/lib/ui/components/KeyboardShortcutsDialog.tsx +62 -0
- package/src/lib/ui/components/LanguageMenu.tsx +38 -0
- package/src/lib/ui/components/Menu.tsx +129 -0
- package/src/lib/ui/components/MenuZone.tsx +35 -0
- package/src/lib/ui/components/MobileStylePanel.tsx +61 -0
- package/src/lib/ui/components/MoveToPageMenu.tsx +104 -0
- package/src/lib/ui/components/NavigationZone/Minimap.tsx +245 -0
- package/src/lib/ui/components/NavigationZone/MinimapManager.ts +382 -0
- package/src/lib/ui/components/NavigationZone/NavigationZone.tsx +81 -0
- package/src/lib/ui/components/NavigationZone/ZoomMenu.tsx +87 -0
- package/src/lib/ui/components/OfflineIndicator/OfflineIndicator.tsx +17 -0
- package/src/lib/ui/components/PageMenu/PageItemInput.tsx +46 -0
- package/src/lib/ui/components/PageMenu/PageItemSubmenu.tsx +86 -0
- package/src/lib/ui/components/PageMenu/PageMenu.tsx +415 -0
- package/src/lib/ui/components/PageMenu/edit-pages-shared.ts +32 -0
- package/src/lib/ui/components/PenModeToggle.tsx +24 -0
- package/src/lib/ui/components/RedoButton.tsx +26 -0
- package/src/lib/ui/components/Spinner.tsx +22 -0
- package/src/lib/ui/components/StopFollowing.tsx +23 -0
- package/src/lib/ui/components/StylePanel/DoubleDropdownPicker.tsx +150 -0
- package/src/lib/ui/components/StylePanel/DropdownPicker.tsx +76 -0
- package/src/lib/ui/components/StylePanel/StylePanel.tsx +332 -0
- package/src/lib/ui/components/StylePanel/styles.tsx +100 -0
- package/src/lib/ui/components/Toasts.tsx +104 -0
- package/src/lib/ui/components/Toolbar/ToggleToolLockedButton.tsx +45 -0
- package/src/lib/ui/components/Toolbar/Toolbar.tsx +281 -0
- package/src/lib/ui/components/TrashButton.tsx +28 -0
- package/src/lib/ui/components/UndoButton.tsx +26 -0
- package/src/lib/ui/components/primitives/Button.tsx +69 -0
- package/src/lib/ui/components/primitives/ButtonPicker.tsx +128 -0
- package/src/lib/ui/components/primitives/Dialog.tsx +57 -0
- package/src/lib/ui/components/primitives/DropdownMenu.tsx +229 -0
- package/src/lib/ui/components/primitives/Icon.tsx +55 -0
- package/src/lib/ui/components/primitives/Input.tsx +165 -0
- package/src/lib/ui/components/primitives/Kbd.tsx +17 -0
- package/src/lib/ui/components/primitives/Popover.tsx +61 -0
- package/src/lib/ui/components/primitives/Slider.tsx +62 -0
- package/src/lib/ui/components/primitives/shared.ts +40 -0
- package/src/lib/ui/constants.ts +2 -0
- package/src/lib/ui/hooks/clipboard/pasteExcalidrawContent.ts +514 -0
- package/src/lib/ui/hooks/clipboard/pasteFiles.ts +31 -0
- package/src/lib/ui/hooks/clipboard/pasteTldrawContent.ts +19 -0
- package/src/lib/ui/hooks/clipboard/pasteUrl.ts +44 -0
- package/src/lib/ui/hooks/menuHelpers.ts +247 -0
- package/src/lib/ui/hooks/useActions.tsx +1180 -0
- package/src/lib/ui/hooks/useActionsMenuSchema.tsx +123 -0
- package/src/lib/ui/hooks/useAssetUrls.tsx +28 -0
- package/src/lib/ui/hooks/useBreakpoint.tsx +42 -0
- package/src/lib/ui/hooks/useCanRedo.ts +7 -0
- package/src/lib/ui/hooks/useCanUndo.ts +7 -0
- package/src/lib/ui/hooks/useClipboardEvents.ts +705 -0
- package/src/lib/ui/hooks/useContextMenuSchema.tsx +260 -0
- package/src/lib/ui/hooks/useCopyAs.ts +26 -0
- package/src/lib/ui/hooks/useDialogsProvider.tsx +128 -0
- package/src/lib/ui/hooks/useEditorEvents.ts +23 -0
- package/src/lib/ui/hooks/useEventsProvider.tsx +129 -0
- package/src/lib/ui/hooks/useExportAs.ts +30 -0
- package/src/lib/ui/hooks/useHasLinkShapeSelected.ts +17 -0
- package/src/lib/ui/hooks/useHelpMenuSchema.tsx +105 -0
- package/src/lib/ui/hooks/useHighDpiCanvas.ts +14 -0
- package/src/lib/ui/hooks/useInsertMedia.ts +35 -0
- package/src/lib/ui/hooks/useKeyboardShortcuts.ts +121 -0
- package/src/lib/ui/hooks/useKeyboardShortcutsSchema.tsx +127 -0
- package/src/lib/ui/hooks/useLocalStorageState.ts +30 -0
- package/src/lib/ui/hooks/useMenuIsOpen.ts +73 -0
- package/src/lib/ui/hooks/useMenuSchema.tsx +280 -0
- package/src/lib/ui/hooks/useOnlyFlippableShape.ts +29 -0
- package/src/lib/ui/hooks/usePreloadAssets.ts +120 -0
- package/src/lib/ui/hooks/usePreloadIcons.ts +38 -0
- package/src/lib/ui/hooks/usePrint.ts +223 -0
- package/src/lib/ui/hooks/useReadonly.ts +7 -0
- package/src/lib/ui/hooks/useRevelantStyles.ts +38 -0
- package/src/lib/ui/hooks/useShowAutoSizeToggle.ts +17 -0
- package/src/lib/ui/hooks/useToastsProvider.tsx +75 -0
- package/src/lib/ui/hooks/useToolbarSchema.tsx +99 -0
- package/src/lib/ui/hooks/useTools.tsx +245 -0
- package/src/lib/ui/hooks/useTranslation/TLUiTranslationKey.ts +356 -0
- package/src/lib/ui/hooks/useTranslation/defaultTranslation.ts +367 -0
- package/src/lib/ui/hooks/useTranslation/translations.ts +74 -0
- package/src/lib/ui/hooks/useTranslation/useLanguages.tsx +10 -0
- package/src/lib/ui/hooks/useTranslation/useTranslation.tsx +117 -0
- package/src/lib/ui/icon-types.ts +337 -0
- package/src/lib/ui/overrides.ts +211 -0
- package/src/lib/ui/version.ts +1 -0
- package/src/lib/ui.css +1603 -0
- package/src/lib/utils/assets/assets.ts +103 -0
- package/src/lib/utils/assets/is-gif-animated.ts +106 -0
- package/src/lib/utils/assets.ts +103 -0
- package/src/lib/utils/embeds/embeds.test.ts +612 -0
- package/src/lib/utils/embeds/embeds.ts +99 -0
- package/src/lib/utils/export/copyAs.ts +139 -0
- package/src/lib/utils/export/export.ts +128 -0
- package/src/lib/utils/export/exportAs.ts +94 -0
- package/src/lib/utils/frames/frames.ts +101 -0
- package/src/lib/utils/static-assets/assetUrls.ts +41 -0
- package/src/lib/utils/text/text.test.ts +11 -0
- package/src/lib/utils/text/text.ts +59 -0
- package/src/lib/utils/tldr/buildFromV1Document.ts +1171 -0
- package/src/lib/utils/tldr/file.ts +303 -0
- package/src/test/ClickManager.test.ts +258 -0
- package/src/test/Editor.test.tsx +647 -0
- package/src/test/EraserTool.test.ts +446 -0
- package/src/test/HandTool.test.ts +191 -0
- package/src/test/HighlightShape.test.ts +24 -0
- package/src/test/LaserTool.test.ts +3 -0
- package/src/test/SelectTool.test.ts +445 -0
- package/src/test/TLSessionStateSnapshot.test.ts +152 -0
- package/src/test/TLUserPreferences.test.ts +123 -0
- package/src/test/TestEditor.test.ts +7 -0
- package/src/test/TestEditor.ts +661 -0
- package/src/test/TldrawEditor.test.tsx +377 -0
- package/src/test/ZoomTool.test.ts +210 -0
- package/src/test/__snapshots__/groups.test.ts.snap +46 -0
- package/src/test/__snapshots__/resizing.test.ts.snap +43 -0
- package/src/test/arrowBindingsIndex.test.tsx +295 -0
- package/src/test/arrows-megabus.test.ts +652 -0
- package/src/test/assets.test.ts +38 -0
- package/src/test/bookmark-shapes.test.ts +141 -0
- package/src/test/cleanup.test.ts +127 -0
- package/src/test/commands/__snapshots__/getSvg.test.ts.snap +174 -0
- package/src/test/commands/__snapshots__/packShapes.test.ts.snap +185 -0
- package/src/test/commands/__snapshots__/zoomToFit.test.ts.snap +12 -0
- package/src/test/commands/alignShapes.test.tsx +388 -0
- package/src/test/commands/allShapesCommonBounds.test.ts +91 -0
- package/src/test/commands/animateShapes.test.ts +3 -0
- package/src/test/commands/animateToShape.test.ts +3 -0
- package/src/test/commands/animationSpeed.test.ts +38 -0
- package/src/test/commands/blur.test.ts +3 -0
- package/src/test/commands/cancel.test.ts +3 -0
- package/src/test/commands/centerOnPoint.test.ts +21 -0
- package/src/test/commands/clipboard.test.ts +481 -0
- package/src/test/commands/complete.test.ts +3 -0
- package/src/test/commands/createPage.test.ts +65 -0
- package/src/test/commands/createShapes.test.ts +141 -0
- package/src/test/commands/deletePage.test.ts +79 -0
- package/src/test/commands/deleteShapes.test.ts +113 -0
- package/src/test/commands/distributeShapes.test.ts +232 -0
- package/src/test/commands/duplicatePage.test.ts +55 -0
- package/src/test/commands/getContent.test.ts +9 -0
- package/src/test/commands/getInitialMetaForShape.test.ts +21 -0
- package/src/test/commands/getSvg.test.ts +110 -0
- package/src/test/commands/groupShapes.test.ts +42 -0
- package/src/test/commands/guide.md +12 -0
- package/src/test/commands/interrupt.test.ts +3 -0
- package/src/test/commands/lockShapes.test.ts +176 -0
- package/src/test/commands/moveShapesToPage.test.ts +254 -0
- package/src/test/commands/nudge.test.ts +292 -0
- package/src/test/commands/packShapes.test.ts +62 -0
- package/src/test/commands/pageToScreen.test.ts +25 -0
- package/src/test/commands/pan.test.ts +32 -0
- package/src/test/commands/penmode.test.ts +27 -0
- package/src/test/commands/pinch.test.ts +11 -0
- package/src/test/commands/putContent.test.ts +39 -0
- package/src/test/commands/reorderShapes.test.ts +950 -0
- package/src/test/commands/reparentShapesById.test.ts +162 -0
- package/src/test/commands/resetZoom.test.ts +30 -0
- package/src/test/commands/resizeShape.test.ts +58 -0
- package/src/test/commands/rotateShapes.test.ts +82 -0
- package/src/test/commands/screenToPage.test.ts +246 -0
- package/src/test/commands/setAppState.test.ts +9 -0
- package/src/test/commands/setBrush.test.ts +38 -0
- package/src/test/commands/setCurrentPage.test.ts +88 -0
- package/src/test/commands/setPageState.test.ts +9 -0
- package/src/test/commands/setSelectedIds.test.ts +57 -0
- package/src/test/commands/setSelectedTool.test.ts +23 -0
- package/src/test/commands/setSettings.test.ts +9 -0
- package/src/test/commands/setStyle.test.ts +11 -0
- package/src/test/commands/squash.test.ts +13 -0
- package/src/test/commands/stackShapes.test.ts +227 -0
- package/src/test/commands/stretch.test.tsx +245 -0
- package/src/test/commands/ungroup.test.ts +17 -0
- package/src/test/commands/updateShapes.test.ts +192 -0
- package/src/test/commands/updateViewportPageBounds.test.ts +123 -0
- package/src/test/commands/zoomIn.test.ts +43 -0
- package/src/test/commands/zoomOut.test.ts +31 -0
- package/src/test/commands/zoomToBounds.test.ts +50 -0
- package/src/test/commands/zoomToFit.test.ts +20 -0
- package/src/test/commands/zoomToSelection.test.ts +42 -0
- package/src/test/cropping.test.ts +1033 -0
- package/src/test/drawing.test.ts +262 -0
- package/src/test/duplicate.test.ts +217 -0
- package/src/test/flipShapes.test.ts +581 -0
- package/src/test/frames.test.ts +995 -0
- package/src/test/getShapeAtPoint.test.ts +168 -0
- package/src/test/getSnapLines.ts +25 -0
- package/src/test/groups.test.ts +2005 -0
- package/src/test/middleMouseButtonPanning.test.ts +31 -0
- package/src/test/modifiers.test.ts +36 -0
- package/src/test/panning.test.ts +25 -0
- package/src/test/parentsToChildrenWithIndexes.test.ts +117 -0
- package/src/test/paste.test.ts +494 -0
- package/src/test/renderingShapes.test.tsx +223 -0
- package/src/test/resizeBox.test.ts +106 -0
- package/src/test/resizing.test.ts +3901 -0
- package/src/test/rotating.test.ts +321 -0
- package/src/test/roundedBox.ts +13 -0
- package/src/test/select.test.tsx +172 -0
- package/src/test/selection-omnibus.test.ts +1710 -0
- package/src/test/shapeIdsInCurrentPage.test.ts +75 -0
- package/src/test/shapeutils.test.ts +204 -0
- package/src/test/spacebarPanning.test.ts +50 -0
- package/src/test/styles2.test.tsx +199 -0
- package/src/test/styles3.test.ts +70 -0
- package/src/test/test-jsx.tsx +134 -0
- package/src/test/testutils/getSnapLines.ts +25 -0
- package/src/test/testutils/roundedBox.ts +13 -0
- package/src/test/text.test.ts +269 -0
- package/src/test/translating-snapping.test.ts +584 -0
- package/src/test/translating.test.ts +1829 -0
- package/src/test/viewport-following.test.ts +18 -0
- package/tldraw.css +3264 -0
|
@@ -0,0 +1,1829 @@
|
|
|
1
|
+
import {
|
|
2
|
+
GapsSnapLine,
|
|
3
|
+
PointsSnapLine,
|
|
4
|
+
SnapLine,
|
|
5
|
+
TLArrowShape,
|
|
6
|
+
TLShapeId,
|
|
7
|
+
TLShapePartial,
|
|
8
|
+
Vec2d,
|
|
9
|
+
createShapeId,
|
|
10
|
+
} from '@bigbluebutton/editor'
|
|
11
|
+
import { TestEditor } from './TestEditor'
|
|
12
|
+
import { getSnapLines } from './getSnapLines'
|
|
13
|
+
|
|
14
|
+
let editor: TestEditor
|
|
15
|
+
|
|
16
|
+
afterEach(() => {
|
|
17
|
+
editor?.dispose()
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
const ids = {
|
|
21
|
+
frame1: createShapeId('frame1'),
|
|
22
|
+
frame2: createShapeId('frame2'),
|
|
23
|
+
box1: createShapeId('box1'),
|
|
24
|
+
box2: createShapeId('box2'),
|
|
25
|
+
line1: createShapeId('line1'),
|
|
26
|
+
boxD: createShapeId('boxD'),
|
|
27
|
+
boxE: createShapeId('boxE'),
|
|
28
|
+
boxF: createShapeId('boxF'),
|
|
29
|
+
boxG: createShapeId('boxG'),
|
|
30
|
+
boxH: createShapeId('boxH'),
|
|
31
|
+
boxX: createShapeId('boxX'),
|
|
32
|
+
|
|
33
|
+
boxT: createShapeId('boxT'),
|
|
34
|
+
|
|
35
|
+
lineA: createShapeId('lineA'),
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
beforeEach(() => {
|
|
39
|
+
console.error = jest.fn()
|
|
40
|
+
editor = new TestEditor()
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
const getNumSnapPoints = (snap: SnapLine): number => {
|
|
44
|
+
return snap.type === 'points' ? snap.points.length : (null as any as number)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function assertGaps(snap: SnapLine): asserts snap is GapsSnapLine {
|
|
48
|
+
expect(snap.type).toBe('gaps')
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function getGapAndPointLines(snaps: SnapLine[]) {
|
|
52
|
+
const gapLines = snaps.filter((snap) => snap.type === 'gaps') as GapsSnapLine[]
|
|
53
|
+
const pointLines = snaps.filter((snap) => snap.type === 'points') as PointsSnapLine[]
|
|
54
|
+
return { gapLines, pointLines }
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const box = (id: TLShapeId, x: number, y: number, w = 10, h = 10): TLShapePartial => ({
|
|
58
|
+
type: 'geo',
|
|
59
|
+
id,
|
|
60
|
+
x,
|
|
61
|
+
y,
|
|
62
|
+
props: {
|
|
63
|
+
w,
|
|
64
|
+
h,
|
|
65
|
+
},
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
describe('When translating...', () => {
|
|
69
|
+
beforeEach(() => {
|
|
70
|
+
editor.createShapes([
|
|
71
|
+
{
|
|
72
|
+
id: ids.box1,
|
|
73
|
+
type: 'geo',
|
|
74
|
+
x: 10,
|
|
75
|
+
y: 10,
|
|
76
|
+
props: {
|
|
77
|
+
w: 100,
|
|
78
|
+
h: 100,
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
id: ids.box2,
|
|
83
|
+
type: 'geo',
|
|
84
|
+
x: 200,
|
|
85
|
+
y: 200,
|
|
86
|
+
props: {
|
|
87
|
+
w: 100,
|
|
88
|
+
h: 100,
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
id: ids.line1,
|
|
93
|
+
type: 'line',
|
|
94
|
+
x: 100,
|
|
95
|
+
y: 100,
|
|
96
|
+
},
|
|
97
|
+
])
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
it('enters and exits the translating state', () => {
|
|
101
|
+
editor
|
|
102
|
+
.pointerDown(50, 50, ids.box1)
|
|
103
|
+
.expectToBeIn('select.pointing_shape')
|
|
104
|
+
.pointerMove(50, 40)
|
|
105
|
+
.expectToBeIn('select.translating')
|
|
106
|
+
.pointerUp()
|
|
107
|
+
.expectToBeIn('select.idle')
|
|
108
|
+
})
|
|
109
|
+
|
|
110
|
+
it('exits the translating state when canceled', () => {
|
|
111
|
+
editor
|
|
112
|
+
.pointerDown(50, 50, ids.box1)
|
|
113
|
+
.pointerMove(50, 40) // [0, -10]
|
|
114
|
+
.expectToBeIn('select.translating')
|
|
115
|
+
.cancel()
|
|
116
|
+
.expectToBeIn('select.idle')
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
it('translates a single shape', () => {
|
|
120
|
+
editor
|
|
121
|
+
.pointerDown(50, 50, ids.box1)
|
|
122
|
+
.pointerMove(50, 40) // [0, -10]
|
|
123
|
+
.expectShapeToMatch({ id: ids.box1, x: 10, y: 0 })
|
|
124
|
+
.pointerMove(100, 100) // [50, 50]
|
|
125
|
+
.expectShapeToMatch({ id: ids.box1, x: 60, y: 60 })
|
|
126
|
+
.pointerUp()
|
|
127
|
+
.expectShapeToMatch({ id: ids.box1, x: 60, y: 60 })
|
|
128
|
+
})
|
|
129
|
+
|
|
130
|
+
it('translates multiple shapes', () => {
|
|
131
|
+
editor
|
|
132
|
+
.select(ids.box1, ids.box2)
|
|
133
|
+
.pointerDown(50, 50, ids.box1)
|
|
134
|
+
.pointerMove(50, 40) // [0, -10]
|
|
135
|
+
.expectShapeToMatch({ id: ids.box1, x: 10, y: 0 }, { id: ids.box2, x: 200, y: 190 })
|
|
136
|
+
.pointerMove(100, 100) // [50, 50]
|
|
137
|
+
.expectShapeToMatch({ id: ids.box1, x: 60, y: 60 }, { id: ids.box2, x: 250, y: 250 })
|
|
138
|
+
.pointerUp()
|
|
139
|
+
.expectShapeToMatch({ id: ids.box1, x: 60, y: 60 }, { id: ids.box2, x: 250, y: 250 })
|
|
140
|
+
})
|
|
141
|
+
})
|
|
142
|
+
|
|
143
|
+
describe('When cloning...', () => {
|
|
144
|
+
beforeEach(() => {
|
|
145
|
+
editor.createShapes([
|
|
146
|
+
{
|
|
147
|
+
id: ids.box1,
|
|
148
|
+
type: 'geo',
|
|
149
|
+
x: 10,
|
|
150
|
+
y: 10,
|
|
151
|
+
props: {
|
|
152
|
+
w: 100,
|
|
153
|
+
h: 100,
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
id: ids.box2,
|
|
158
|
+
type: 'geo',
|
|
159
|
+
x: 200,
|
|
160
|
+
y: 200,
|
|
161
|
+
props: {
|
|
162
|
+
w: 100,
|
|
163
|
+
h: 100,
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
id: ids.line1,
|
|
168
|
+
type: 'line',
|
|
169
|
+
x: 100,
|
|
170
|
+
y: 100,
|
|
171
|
+
},
|
|
172
|
+
])
|
|
173
|
+
})
|
|
174
|
+
|
|
175
|
+
it('clones a single shape and restores when stopping cloning', () => {
|
|
176
|
+
expect(editor.getCurrentPageShapeIds().size).toBe(3)
|
|
177
|
+
expect(editor.getCurrentPageShapeIds().size).toBe(3)
|
|
178
|
+
editor.select(ids.box1).pointerDown(50, 50, ids.box1).pointerMove(50, 40) // [0, -10]
|
|
179
|
+
expect(editor.getCurrentPageShapeIds().size).toBe(3)
|
|
180
|
+
editor.expectShapeToMatch({ id: ids.box1, x: 10, y: 0 }) // Translated A...
|
|
181
|
+
|
|
182
|
+
// Start cloning!
|
|
183
|
+
editor.keyDown('Alt')
|
|
184
|
+
expect(editor.getCurrentPageShapeIds().size).toBe(4)
|
|
185
|
+
const newShape = editor.getSelectedShapes()[0]
|
|
186
|
+
expect(newShape.id).not.toBe(ids.box1)
|
|
187
|
+
|
|
188
|
+
editor
|
|
189
|
+
.expectShapeToMatch({ id: ids.box1, x: 10, y: 10 }) // A should be back to original position...
|
|
190
|
+
.expectShapeToMatch({ id: newShape.id, x: 10, y: 0 }) // New node should be at A's previous position
|
|
191
|
+
.pointerMove(60, 40) // [10, -10]
|
|
192
|
+
.expectShapeToMatch({ id: ids.box1, x: 10, y: 10 }) // No movement on A
|
|
193
|
+
.expectShapeToMatch({ id: newShape.id, x: 20, y: 0 }) // Clone should be moving
|
|
194
|
+
|
|
195
|
+
// Stop cloning!
|
|
196
|
+
editor.keyUp('Alt')
|
|
197
|
+
jest.advanceTimersByTime(500)
|
|
198
|
+
|
|
199
|
+
editor.expectShapeToMatch({ id: ids.box1, x: 20, y: 0 }) // A should be at the translated position...
|
|
200
|
+
expect(editor.getShape(newShape.id)).toBeUndefined() // And the new node should be gone!
|
|
201
|
+
})
|
|
202
|
+
|
|
203
|
+
it('clones multiple single shape and restores when stopping cloning', () => {
|
|
204
|
+
editor.select(ids.box1, ids.box2).pointerDown(50, 50, ids.box1).pointerMove(50, 40) // [0, -10]
|
|
205
|
+
expect(editor.getCurrentPageShapeIds().size).toBe(3)
|
|
206
|
+
editor.expectShapeToMatch({ id: ids.box1, x: 10, y: 0 }) // Translated A...
|
|
207
|
+
editor.expectShapeToMatch({ id: ids.box2, x: 200, y: 190 }) // Translated B...
|
|
208
|
+
|
|
209
|
+
// Start cloning!
|
|
210
|
+
editor.keyDown('Alt')
|
|
211
|
+
expect(editor.getCurrentPageShapeIds().size).toBe(5) // Two new shapes!
|
|
212
|
+
const newShapeA = editor.getShape(editor.getSelectedShapeIds()[0])!
|
|
213
|
+
const newShapeB = editor.getShape(editor.getSelectedShapeIds()[1])!
|
|
214
|
+
expect(newShapeA).toBeDefined()
|
|
215
|
+
expect(newShapeB).toBeDefined()
|
|
216
|
+
|
|
217
|
+
editor
|
|
218
|
+
.expectShapeToMatch({ id: ids.box1, x: 10, y: 10 }) // A should be back to original position...
|
|
219
|
+
.expectShapeToMatch({ id: ids.box2, x: 200, y: 200 }) // B should be back to original position...
|
|
220
|
+
.expectShapeToMatch({ id: newShapeA.id, x: 10, y: 0 }) // New node should be at A's previous position
|
|
221
|
+
.expectShapeToMatch({ id: newShapeB.id, x: 200, y: 190 }) // New node should be at B's previous position
|
|
222
|
+
.pointerMove(60, 40) // [10, -10]
|
|
223
|
+
.expectShapeToMatch({ id: ids.box1, x: 10, y: 10 }) // No movement on A
|
|
224
|
+
.expectShapeToMatch({ id: ids.box2, x: 200, y: 200 }) // No movement on B
|
|
225
|
+
.expectShapeToMatch({ id: newShapeA.id, x: 20, y: 0 }) // Clone A should be moving
|
|
226
|
+
.expectShapeToMatch({ id: newShapeB.id, x: 210, y: 190 }) // Clone B should be moving
|
|
227
|
+
|
|
228
|
+
// Stop cloning!
|
|
229
|
+
editor.keyUp('Alt')
|
|
230
|
+
|
|
231
|
+
// wait 500ms
|
|
232
|
+
jest.advanceTimersByTime(500)
|
|
233
|
+
editor
|
|
234
|
+
.expectShapeToMatch({ id: ids.box1, x: 20, y: 0 }) // A should be at the translated position...
|
|
235
|
+
.expectShapeToMatch({ id: ids.box2, x: 210, y: 190 }) // B should be at the translated position...
|
|
236
|
+
expect(editor.getShape(newShapeA.id)).toBeUndefined() // And the new node A should be gone!
|
|
237
|
+
expect(editor.getShape(newShapeB.id)).toBeUndefined() // And the new node B should be gone!
|
|
238
|
+
})
|
|
239
|
+
|
|
240
|
+
it('clones a parent and its descendants and removes descendants when stopping cloning', () => {
|
|
241
|
+
editor.updateShapes([{ id: ids.line1, type: 'geo', parentId: ids.box2 }])
|
|
242
|
+
expect(editor.getShape(ids.line1)!.parentId).toBe(ids.box2)
|
|
243
|
+
editor.select(ids.box2).pointerDown(250, 250, ids.box2).pointerMove(250, 240) // [0, -10]
|
|
244
|
+
|
|
245
|
+
expect(editor.getCurrentPageShapeIds().size).toBe(3)
|
|
246
|
+
editor.keyDown('Alt', { altKey: true })
|
|
247
|
+
expect(editor.getCurrentPageShapeIds().size).toBe(5) // Creates a clone of B and C (its descendant)
|
|
248
|
+
|
|
249
|
+
const newShapeA = editor.getShape(editor.getSelectedShapeIds()[0])!
|
|
250
|
+
const newShapeB = editor.getShape(editor.getSortedChildIdsForParent(newShapeA.id)[0])!
|
|
251
|
+
|
|
252
|
+
expect(newShapeA).toBeDefined()
|
|
253
|
+
expect(newShapeB).toBeDefined()
|
|
254
|
+
|
|
255
|
+
const cloneB = newShapeA.x === editor.getShape(ids.box2)!.x ? newShapeA : newShapeB
|
|
256
|
+
const cloneC = newShapeA.x === editor.getShape(ids.box2)!.x ? newShapeB : newShapeA
|
|
257
|
+
|
|
258
|
+
editor
|
|
259
|
+
.expectShapeToMatch({ id: ids.box2, x: 200, y: 200 }) // B should be back to original position...
|
|
260
|
+
.expectShapeToMatch({ id: cloneB.id, x: 200, y: 190 }) // New node should be at A's previous position
|
|
261
|
+
.expectShapeToMatch({ id: cloneC.id, x: 100, y: 100 }) // New node should be at B's previous position
|
|
262
|
+
.pointerMove(260, 240) // [10, -10]
|
|
263
|
+
.expectShapeToMatch({ id: ids.box2, x: 200, y: 200 }) // No movement on B
|
|
264
|
+
.expectShapeToMatch({ id: cloneB.id, x: 210, y: 190 }) // Clone A should be moving
|
|
265
|
+
.expectShapeToMatch({ id: cloneC.id, x: 100, y: 100 }) // New node should be at B's previous position
|
|
266
|
+
|
|
267
|
+
// Stop cloning!
|
|
268
|
+
editor.keyUp('Alt')
|
|
269
|
+
// wait 500ms
|
|
270
|
+
jest.advanceTimersByTime(500)
|
|
271
|
+
|
|
272
|
+
editor.expectShapeToMatch({ id: ids.box2, x: 210, y: 190 }) // B should be at the translated position...
|
|
273
|
+
expect(editor.getShape(cloneB.id)).toBeUndefined() // And the new node A should be gone!
|
|
274
|
+
expect(editor.getShape(cloneC.id)).toBeUndefined() // And the new node B should be gone!
|
|
275
|
+
})
|
|
276
|
+
|
|
277
|
+
it('Clones twice', () => {
|
|
278
|
+
const groupId = createShapeId('g')
|
|
279
|
+
editor.groupShapes([ids.box1, ids.box2], groupId)
|
|
280
|
+
const count1 = editor.getCurrentPageShapes().length
|
|
281
|
+
|
|
282
|
+
editor.pointerDown(50, 50, { shape: editor.getShape(groupId)!, target: 'shape' })
|
|
283
|
+
editor.expectToBeIn('select.pointing_shape')
|
|
284
|
+
|
|
285
|
+
editor.pointerMove(199, 199)
|
|
286
|
+
editor.expectToBeIn('select.translating')
|
|
287
|
+
expect(editor.getCurrentPageShapes().length).toBe(count1) // 2 new box and group
|
|
288
|
+
|
|
289
|
+
editor.keyDown('Alt')
|
|
290
|
+
|
|
291
|
+
editor.expectToBeIn('select.translating')
|
|
292
|
+
expect(editor.getCurrentPageShapes().length).toBe(count1 + 3) // 2 new box and group
|
|
293
|
+
|
|
294
|
+
editor.keyUp('Alt')
|
|
295
|
+
jest.advanceTimersByTime(500)
|
|
296
|
+
|
|
297
|
+
expect(editor.getCurrentPageShapes().length).toBe(count1) // 2 new box and group
|
|
298
|
+
|
|
299
|
+
editor.keyDown('Alt')
|
|
300
|
+
|
|
301
|
+
expect(editor.getCurrentPageShapes().length).toBe(count1 + 3) // 2 new box and group
|
|
302
|
+
})
|
|
303
|
+
})
|
|
304
|
+
|
|
305
|
+
describe('When translating shapes that are descendants of a rotated shape...', () => {
|
|
306
|
+
beforeEach(() => {
|
|
307
|
+
editor.createShapes([
|
|
308
|
+
{
|
|
309
|
+
id: ids.box1,
|
|
310
|
+
type: 'geo',
|
|
311
|
+
x: 10,
|
|
312
|
+
y: 10,
|
|
313
|
+
props: {
|
|
314
|
+
w: 100,
|
|
315
|
+
h: 100,
|
|
316
|
+
},
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
id: ids.box2,
|
|
320
|
+
type: 'geo',
|
|
321
|
+
x: 200,
|
|
322
|
+
y: 200,
|
|
323
|
+
props: {
|
|
324
|
+
w: 100,
|
|
325
|
+
h: 100,
|
|
326
|
+
},
|
|
327
|
+
},
|
|
328
|
+
{
|
|
329
|
+
id: ids.line1,
|
|
330
|
+
type: 'line',
|
|
331
|
+
x: 100,
|
|
332
|
+
y: 100,
|
|
333
|
+
},
|
|
334
|
+
])
|
|
335
|
+
})
|
|
336
|
+
|
|
337
|
+
it('Translates correctly', () => {
|
|
338
|
+
editor.createShapes([
|
|
339
|
+
{
|
|
340
|
+
id: ids.boxD,
|
|
341
|
+
parentId: ids.box1,
|
|
342
|
+
type: 'geo',
|
|
343
|
+
x: 20,
|
|
344
|
+
y: 20,
|
|
345
|
+
props: {
|
|
346
|
+
w: 10,
|
|
347
|
+
h: 10,
|
|
348
|
+
},
|
|
349
|
+
},
|
|
350
|
+
])
|
|
351
|
+
|
|
352
|
+
const shapeA = editor.getShape(ids.box1)!
|
|
353
|
+
const shapeD = editor.getShape(ids.boxD)!
|
|
354
|
+
|
|
355
|
+
expect(editor.getPageCenter(shapeA)).toMatchObject(new Vec2d(60, 60))
|
|
356
|
+
expect(editor.getShapeGeometry(shapeD).center).toMatchObject(new Vec2d(5, 5))
|
|
357
|
+
expect(editor.getPageCenter(shapeD)).toMatchObject(new Vec2d(35, 35))
|
|
358
|
+
|
|
359
|
+
const rads = 0
|
|
360
|
+
|
|
361
|
+
expect(editor.getPageCenter(shapeA)).toMatchObject(new Vec2d(60, 60))
|
|
362
|
+
|
|
363
|
+
// Expect the node's page position to be rotated around its parent's page center
|
|
364
|
+
expect(editor.getPageCenter(shapeD)).toMatchObject(
|
|
365
|
+
new Vec2d(35, 35).rotWith(editor.getPageCenter(shapeA)!, rads)
|
|
366
|
+
)
|
|
367
|
+
|
|
368
|
+
const centerD = editor.getPageCenter(shapeD)!.clone().toFixed()
|
|
369
|
+
|
|
370
|
+
editor
|
|
371
|
+
.select(ids.boxD)
|
|
372
|
+
.pointerDown(centerD.x, centerD.y, ids.boxD)
|
|
373
|
+
.pointerMove(centerD.x, centerD.y - 10)
|
|
374
|
+
.pointerMove(centerD.x, centerD.y - 10)
|
|
375
|
+
.pointerUp()
|
|
376
|
+
|
|
377
|
+
expect(editor.getPageCenter(shapeD)).toMatchObject(new Vec2d(centerD.x, centerD.y - 10))
|
|
378
|
+
|
|
379
|
+
const centerA = editor.getPageCenter(shapeA)!.clone().toFixed()
|
|
380
|
+
|
|
381
|
+
editor
|
|
382
|
+
.select(ids.box1)
|
|
383
|
+
.pointerDown(centerA.x, centerA.y, ids.box1)
|
|
384
|
+
.pointerMove(centerA.x, centerA.y - 100)
|
|
385
|
+
.pointerUp()
|
|
386
|
+
|
|
387
|
+
const centerB = editor.getPageCenter(shapeA)!.clone().toFixed()
|
|
388
|
+
|
|
389
|
+
expect(centerB).toMatchObject({ x: centerA.x, y: centerA.y - 100 })
|
|
390
|
+
})
|
|
391
|
+
})
|
|
392
|
+
|
|
393
|
+
describe('snapping with single shapes', () => {
|
|
394
|
+
beforeEach(() => {
|
|
395
|
+
// 0 10 20 30
|
|
396
|
+
// ┌──────┐ ┌──────┐
|
|
397
|
+
// │ A │ │ B │
|
|
398
|
+
// └──────┘ └──────┘
|
|
399
|
+
editor.createShapes([
|
|
400
|
+
{
|
|
401
|
+
id: ids.box1,
|
|
402
|
+
type: 'geo',
|
|
403
|
+
x: 0,
|
|
404
|
+
y: 0,
|
|
405
|
+
props: { w: 10, h: 10 },
|
|
406
|
+
},
|
|
407
|
+
{
|
|
408
|
+
id: ids.box2,
|
|
409
|
+
type: 'geo',
|
|
410
|
+
x: 20,
|
|
411
|
+
y: 0,
|
|
412
|
+
props: { w: 10, h: 10 },
|
|
413
|
+
},
|
|
414
|
+
])
|
|
415
|
+
})
|
|
416
|
+
|
|
417
|
+
it('happens when the ctrl key is pressed', () => {
|
|
418
|
+
// 0 10 11 21
|
|
419
|
+
// ┌──────┐ ┌──────┐
|
|
420
|
+
// │ │ │ │ <- dragging left
|
|
421
|
+
// └──────┘ └──────┘
|
|
422
|
+
//
|
|
423
|
+
// │
|
|
424
|
+
// │ press ctrl
|
|
425
|
+
// ▼
|
|
426
|
+
//
|
|
427
|
+
// 0 10 20
|
|
428
|
+
// ┌──────┬──────┐
|
|
429
|
+
// │ │ │ *snap*
|
|
430
|
+
// └──────┴──────┘
|
|
431
|
+
|
|
432
|
+
editor.pointerDown(25, 5, ids.box2).pointerMove(16, 5)
|
|
433
|
+
|
|
434
|
+
// expect box B to be at 11, 0
|
|
435
|
+
expect(editor.getShape(ids.box2)!).toMatchObject({ x: 11, y: 0 })
|
|
436
|
+
|
|
437
|
+
// press ctrl key and it snaps to 10, 0
|
|
438
|
+
editor.keyDown('Control')
|
|
439
|
+
expect(editor.getShape(ids.box2)!).toMatchObject({ x: 10, y: 0 })
|
|
440
|
+
|
|
441
|
+
// release ctrl key and it unsnaps
|
|
442
|
+
editor.keyUp('Control')
|
|
443
|
+
jest.advanceTimersByTime(200)
|
|
444
|
+
|
|
445
|
+
expect(editor.getShape(ids.box2)!).toMatchObject({ x: 11, y: 0 })
|
|
446
|
+
|
|
447
|
+
// press ctrl and release the pointer and it should stay snapped
|
|
448
|
+
editor.keyDown('Control')
|
|
449
|
+
expect(editor.getShape(ids.box2)!).toMatchObject({ x: 10, y: 0 })
|
|
450
|
+
|
|
451
|
+
editor.pointerUp(16, 5, { ctrlKey: true })
|
|
452
|
+
expect(editor.getShape(ids.box2)!).toMatchObject({ x: 10, y: 0 })
|
|
453
|
+
})
|
|
454
|
+
|
|
455
|
+
it('snaps to the center point as well as all four corners of a bounding box', () => {
|
|
456
|
+
// ┌──────┐
|
|
457
|
+
// │ B │
|
|
458
|
+
// └──────┘
|
|
459
|
+
// ┌──────┐
|
|
460
|
+
// │ A │
|
|
461
|
+
// └──────┘
|
|
462
|
+
editor.pointerDown(25, 5, ids.box2).pointerMove(-6, -6, { ctrlKey: true })
|
|
463
|
+
expect(editor.getShape(ids.box2)!).toMatchObject({ x: -10, y: -10 })
|
|
464
|
+
|
|
465
|
+
// ┌──────┐
|
|
466
|
+
// │ B │
|
|
467
|
+
// └──────┘
|
|
468
|
+
// ┌──────┐
|
|
469
|
+
// │ A │
|
|
470
|
+
// └──────┘
|
|
471
|
+
editor.pointerMove(16, -6, { ctrlKey: true })
|
|
472
|
+
expect(editor.getShape(ids.box2)!).toMatchObject({ x: 10, y: -10 })
|
|
473
|
+
|
|
474
|
+
// ┌──────┐
|
|
475
|
+
// │ A │
|
|
476
|
+
// └──────┘
|
|
477
|
+
// ┌──────┐
|
|
478
|
+
// │ B │
|
|
479
|
+
// └──────┘
|
|
480
|
+
editor.pointerMove(16, 16, { ctrlKey: true })
|
|
481
|
+
expect(editor.getShape(ids.box2)!).toMatchObject({ x: 10, y: 10 })
|
|
482
|
+
|
|
483
|
+
// ┌──────┐
|
|
484
|
+
// │ A │
|
|
485
|
+
// └──────┘
|
|
486
|
+
// ┌──────┐
|
|
487
|
+
// │ B │
|
|
488
|
+
// └──────┘
|
|
489
|
+
editor.pointerMove(-6, 16, { ctrlKey: true })
|
|
490
|
+
expect(editor.getShape(ids.box2)!).toMatchObject({ x: -10, y: 10 })
|
|
491
|
+
|
|
492
|
+
// ┌──────┐
|
|
493
|
+
// │ AB │
|
|
494
|
+
// └──────┘
|
|
495
|
+
editor.pointerMove(6, 6, { ctrlKey: true })
|
|
496
|
+
expect(editor.getShape(ids.box2)!).toMatchObject({ x: 0, y: 0 })
|
|
497
|
+
})
|
|
498
|
+
|
|
499
|
+
it('creates snap lines + points to render in the UI', () => {
|
|
500
|
+
// 0 10
|
|
501
|
+
// ┌──────┐ ┼
|
|
502
|
+
// │ │
|
|
503
|
+
// └──────┘ ┼ one line, four points
|
|
504
|
+
// │
|
|
505
|
+
// │
|
|
506
|
+
// │
|
|
507
|
+
// │11 21
|
|
508
|
+
// ┼ ┌──────┐
|
|
509
|
+
// │ │
|
|
510
|
+
// ┼ └──────┘
|
|
511
|
+
|
|
512
|
+
editor.pointerDown(25, 5, ids.box2).pointerMove(16, 35, { ctrlKey: true })
|
|
513
|
+
expect(editor.snaps.getLines()?.length).toBe(1)
|
|
514
|
+
|
|
515
|
+
expect(getNumSnapPoints(editor.snaps.getLines()![0])).toBe(4)
|
|
516
|
+
})
|
|
517
|
+
|
|
518
|
+
it('shows all the horizonal lines + points where the bounding boxes align', () => {
|
|
519
|
+
// x─────x────────────────────x─────x
|
|
520
|
+
// ┌─────┐ ┌─────┐
|
|
521
|
+
// │ x──┼────────────────────┼──x │
|
|
522
|
+
// └─────┘ └─────┘
|
|
523
|
+
// x─────x────────────────────x─────x
|
|
524
|
+
editor.pointerDown(25, 5, ids.box2).pointerMove(36, 5, { ctrlKey: true })
|
|
525
|
+
|
|
526
|
+
const snaps = editor.snaps.getLines()!.sort((a, b) => getNumSnapPoints(a) - getNumSnapPoints(b))
|
|
527
|
+
expect(snaps.length).toBe(3)
|
|
528
|
+
|
|
529
|
+
// center snap line
|
|
530
|
+
expect(getNumSnapPoints(snaps[0])).toBe(2)
|
|
531
|
+
|
|
532
|
+
// top and bottom lines
|
|
533
|
+
expect(getNumSnapPoints(snaps[1])).toBe(4)
|
|
534
|
+
expect(getNumSnapPoints(snaps[2])).toBe(4)
|
|
535
|
+
})
|
|
536
|
+
|
|
537
|
+
it('shows all the vertical lines + points where the bounding boxes align', () => {
|
|
538
|
+
// x ┌─────┐ x
|
|
539
|
+
// │ │ x │ │
|
|
540
|
+
// x └──┼──┘ x
|
|
541
|
+
// │ │ │
|
|
542
|
+
// x ┌──┼──┐ x
|
|
543
|
+
// │ │ x │ │
|
|
544
|
+
// x └─────┘ x
|
|
545
|
+
editor.pointerDown(25, 5, ids.box2).pointerMove(5, 45, { ctrlKey: true })
|
|
546
|
+
|
|
547
|
+
const snaps = editor.snaps.getLines()!.sort((a, b) => getNumSnapPoints(a) - getNumSnapPoints(b))
|
|
548
|
+
expect(snaps.length).toBe(3)
|
|
549
|
+
|
|
550
|
+
// center snap line
|
|
551
|
+
expect(getNumSnapPoints(snaps[0])).toBe(2)
|
|
552
|
+
|
|
553
|
+
// left and right lines
|
|
554
|
+
expect(getNumSnapPoints(snaps[1])).toBe(4)
|
|
555
|
+
expect(getNumSnapPoints(snaps[2])).toBe(4)
|
|
556
|
+
})
|
|
557
|
+
|
|
558
|
+
it('does not snap to shapes that are not visible in the viewport', () => {
|
|
559
|
+
// move A off screen
|
|
560
|
+
editor.updateShapes([{ id: ids.box1, type: 'geo', x: -20 }])
|
|
561
|
+
|
|
562
|
+
editor.pointerDown(25, 5, ids.box2).pointerMove(36, 5, { ctrlKey: true })
|
|
563
|
+
expect(editor.snaps.getLines()!.length).toBe(0)
|
|
564
|
+
|
|
565
|
+
editor.updateShapes([{ id: ids.box1, type: 'geo', x: editor.getViewportScreenBounds().w + 10 }])
|
|
566
|
+
editor.pointerMove(33, 5, { ctrlKey: true })
|
|
567
|
+
|
|
568
|
+
expect(editor.snaps.getLines()!.length).toBe(0)
|
|
569
|
+
editor.updateShapes([{ id: ids.box1, type: 'geo', y: -20 }])
|
|
570
|
+
|
|
571
|
+
editor.pointerMove(5, 5, { ctrlKey: true })
|
|
572
|
+
expect(editor.snaps.getLines()!.length).toBe(0)
|
|
573
|
+
|
|
574
|
+
editor.updateShapes([
|
|
575
|
+
{ id: ids.box1, type: 'geo', x: 0, y: editor.getViewportScreenBounds().h + 10 },
|
|
576
|
+
])
|
|
577
|
+
|
|
578
|
+
editor.pointerMove(5, 5, { ctrlKey: true })
|
|
579
|
+
expect(editor.snaps.getLines()!.length).toBe(0)
|
|
580
|
+
})
|
|
581
|
+
|
|
582
|
+
it('does not snap on the Y axis if the shift key is pressed', () => {
|
|
583
|
+
// ┌──────┐ ──────►
|
|
584
|
+
// ┌──────┐ │ B │ drag with shift
|
|
585
|
+
// │ A │ └──────┘
|
|
586
|
+
// └──────┘
|
|
587
|
+
|
|
588
|
+
// move B up one pixel
|
|
589
|
+
editor.updateShapes([{ id: ids.box2, type: 'geo', y: editor.getShape(ids.box2)!.y - 1 }])
|
|
590
|
+
|
|
591
|
+
editor.pointerDown(25, 5, ids.box2).pointerMove(36, 5, { ctrlKey: true })
|
|
592
|
+
|
|
593
|
+
// should snap without shift key
|
|
594
|
+
expect(editor.getShape(ids.box2)).toMatchObject({ x: 31, y: 0 })
|
|
595
|
+
|
|
596
|
+
editor.keyDown('Shift')
|
|
597
|
+
// should unsnap with shift key
|
|
598
|
+
expect(editor.getShape(ids.box2)).toMatchObject({ x: 31, y: -1 })
|
|
599
|
+
// and continue not snapping while moving
|
|
600
|
+
editor.pointerMove(45, 5, { ctrlKey: true, shiftKey: true })
|
|
601
|
+
expect(editor.getShape(ids.box2)).toMatchObject({ x: 40, y: -1 })
|
|
602
|
+
|
|
603
|
+
// should still snap to things on the X axis
|
|
604
|
+
editor.createShapes([{ type: 'geo', id: ids.line1, x: 100, y: 0, props: { w: 10, h: 10 } }])
|
|
605
|
+
editor.pointerMove(106, 5, { ctrlKey: true, shiftKey: true })
|
|
606
|
+
expect(editor.getShape(ids.box2)).toMatchObject({ x: 100, y: -1 })
|
|
607
|
+
})
|
|
608
|
+
|
|
609
|
+
it('does not snap on the X axis if the shift key is pressed', () => {
|
|
610
|
+
// ┌──────┐
|
|
611
|
+
// │ A │
|
|
612
|
+
// └──────┘
|
|
613
|
+
//
|
|
614
|
+
// ┌──────┐ │
|
|
615
|
+
// │ B │ drag with shift │
|
|
616
|
+
// └──────┘ ▼
|
|
617
|
+
|
|
618
|
+
// move B into place
|
|
619
|
+
editor.updateShapes([{ id: ids.box2, type: 'geo', x: 1, y: 20 }])
|
|
620
|
+
|
|
621
|
+
editor.pointerDown(6, 25, ids.box2).pointerMove(6, 35, { ctrlKey: true })
|
|
622
|
+
|
|
623
|
+
// should snap without shift key
|
|
624
|
+
expect(editor.getShape(ids.box2)).toMatchObject({ x: 0, y: 30 })
|
|
625
|
+
|
|
626
|
+
editor.keyDown('Shift')
|
|
627
|
+
// should unsnap with shift key
|
|
628
|
+
expect(editor.getShape(ids.box2)).toMatchObject({ x: 1, y: 30 })
|
|
629
|
+
// and continue not snapping while moving
|
|
630
|
+
editor.pointerMove(6, 50, { ctrlKey: true, shiftKey: true })
|
|
631
|
+
expect(editor.getShape(ids.box2)).toMatchObject({ x: 1, y: 45 })
|
|
632
|
+
|
|
633
|
+
// should still snap to things on the Y axis
|
|
634
|
+
editor.createShapes([{ type: 'geo', id: ids.line1, x: 20, y: 100, props: { w: 10, h: 10 } }])
|
|
635
|
+
editor.pointerMove(6, 106, { ctrlKey: true, shiftKey: true })
|
|
636
|
+
expect(editor.getShape(ids.box2)).toMatchObject({ x: 1, y: 100 })
|
|
637
|
+
})
|
|
638
|
+
})
|
|
639
|
+
|
|
640
|
+
describe('snapping with multiple shapes', () => {
|
|
641
|
+
beforeEach(() => {
|
|
642
|
+
// 0 100 200 300
|
|
643
|
+
// ┌──────┐ ┌──────┐
|
|
644
|
+
// │ A │ │ B │
|
|
645
|
+
// └──────┘ └──────┘
|
|
646
|
+
//
|
|
647
|
+
// ┌────────────────────┐
|
|
648
|
+
// │ │
|
|
649
|
+
// │ │
|
|
650
|
+
// │ │
|
|
651
|
+
// │ C │
|
|
652
|
+
// │ │
|
|
653
|
+
// │ │
|
|
654
|
+
// └────────────────────┘
|
|
655
|
+
editor.createShapes([
|
|
656
|
+
{
|
|
657
|
+
id: ids.box1,
|
|
658
|
+
type: 'geo',
|
|
659
|
+
x: 0,
|
|
660
|
+
y: 0,
|
|
661
|
+
props: { w: 100, h: 100 },
|
|
662
|
+
},
|
|
663
|
+
{
|
|
664
|
+
id: ids.box2,
|
|
665
|
+
type: 'geo',
|
|
666
|
+
x: 200,
|
|
667
|
+
y: 0,
|
|
668
|
+
props: { w: 100, h: 100 },
|
|
669
|
+
},
|
|
670
|
+
{
|
|
671
|
+
id: ids.line1,
|
|
672
|
+
type: 'geo',
|
|
673
|
+
x: 0,
|
|
674
|
+
y: 200,
|
|
675
|
+
props: { w: 300, h: 300 },
|
|
676
|
+
},
|
|
677
|
+
])
|
|
678
|
+
})
|
|
679
|
+
|
|
680
|
+
it("will not snap to inidivual shape's edges", () => {
|
|
681
|
+
// 0 100 200 300
|
|
682
|
+
// ┌──────┐ ┌──────┐
|
|
683
|
+
// │ A │ │ B │
|
|
684
|
+
// └──────┘ └──────┘
|
|
685
|
+
//
|
|
686
|
+
// ┌────────────────────┐
|
|
687
|
+
// │ │
|
|
688
|
+
// │ │
|
|
689
|
+
// │ │
|
|
690
|
+
// │ C │
|
|
691
|
+
// │ │
|
|
692
|
+
// │ │
|
|
693
|
+
// └────────────────────┘
|
|
694
|
+
|
|
695
|
+
editor.select(ids.box1, ids.box2)
|
|
696
|
+
editor.pointerDown(50, 50, ids.box1).pointerMove(249, 50, { ctrlKey: true })
|
|
697
|
+
expect(editor.getShape(ids.box1)!).toMatchObject({ x: 199, y: 0 })
|
|
698
|
+
})
|
|
699
|
+
|
|
700
|
+
it("will snap to the selection's bounding box", () => {
|
|
701
|
+
// 0 100 200 300
|
|
702
|
+
// ┌──────┐ ┌──────┐
|
|
703
|
+
// │ A │ │ B │
|
|
704
|
+
// └──────┘ └──────┘
|
|
705
|
+
// ┌────────────────────┐
|
|
706
|
+
// │ │
|
|
707
|
+
// │ │
|
|
708
|
+
// │ │
|
|
709
|
+
// │ C │
|
|
710
|
+
// │ │
|
|
711
|
+
// │ │
|
|
712
|
+
// └────────────────────┘
|
|
713
|
+
|
|
714
|
+
editor.select(ids.box1, ids.box2)
|
|
715
|
+
editor.pointerDown(50, 50, ids.box1).pointerMove(349, 50, { ctrlKey: true })
|
|
716
|
+
expect(editor.getShape(ids.box1)!).toMatchObject({ x: 300, y: 0 })
|
|
717
|
+
})
|
|
718
|
+
})
|
|
719
|
+
|
|
720
|
+
describe('Snap-between behavior', () => {
|
|
721
|
+
beforeEach(() => {
|
|
722
|
+
editor?.dispose()
|
|
723
|
+
})
|
|
724
|
+
it('snaps a shape horizontally between two others', () => {
|
|
725
|
+
// ┌─────┐ ┌─────┐
|
|
726
|
+
// │ │ │ │
|
|
727
|
+
// │ │ │ │
|
|
728
|
+
// │ │ │ │
|
|
729
|
+
// │ A │ │ B │
|
|
730
|
+
// │ │ ┌───┐ │ │
|
|
731
|
+
// │ ├──┼──┤ C ├──┼──┤ │
|
|
732
|
+
// │ │ └───┘ │ │
|
|
733
|
+
// └─────┘ └─────┘
|
|
734
|
+
editor.createShapes([
|
|
735
|
+
{ type: 'geo', id: ids.box1, x: 0, y: 0, props: { w: 50, h: 100 } },
|
|
736
|
+
{ type: 'geo', id: ids.box2, x: 200, y: 0, props: { w: 50, h: 100 } },
|
|
737
|
+
{ type: 'geo', id: ids.line1, x: 50, y: 0, props: { w: 10, h: 10 } },
|
|
738
|
+
])
|
|
739
|
+
|
|
740
|
+
// the midpoint is 125 and c is 10 wide so it should snap to 120 if we put it at 121
|
|
741
|
+
editor.pointerDown(55, 5, ids.line1).pointerMove(126, 67, { ctrlKey: true })
|
|
742
|
+
expect(editor.getShape(ids.line1)).toMatchObject({ x: 120, y: 62 })
|
|
743
|
+
expect(editor.snaps.getLines()?.length).toBe(1)
|
|
744
|
+
const line = editor.snaps.getLines()![0]
|
|
745
|
+
assertGaps(line)
|
|
746
|
+
expect(line.gaps.length).toBe(2)
|
|
747
|
+
})
|
|
748
|
+
it('shows horizontal point snaps at the same time as horizontal gap snaps', () => {
|
|
749
|
+
// ┌─────┐ ┌─────┐
|
|
750
|
+
// │ │ │ │
|
|
751
|
+
// │ │ │ │
|
|
752
|
+
// │ │ │ │
|
|
753
|
+
// │ A │ │ B │
|
|
754
|
+
// │ │ │ │
|
|
755
|
+
// │ │ ┌───┐ │ │
|
|
756
|
+
// │ ├──┼──┤ C ├──┼──┤ │
|
|
757
|
+
// └─────┘ └───┘ └─────┘
|
|
758
|
+
// x─────x─────x───x─────x─────x
|
|
759
|
+
editor.createShapes([
|
|
760
|
+
{ type: 'geo', id: ids.box1, x: 0, y: 0, props: { w: 50, h: 100 } },
|
|
761
|
+
{ type: 'geo', id: ids.box2, x: 200, y: 0, props: { w: 50, h: 100 } },
|
|
762
|
+
{ type: 'geo', id: ids.line1, x: 50, y: 0, props: { w: 10, h: 10 } },
|
|
763
|
+
])
|
|
764
|
+
|
|
765
|
+
editor.pointerDown(55, 5, ids.line1).pointerMove(126, 94, { ctrlKey: true })
|
|
766
|
+
expect(editor.getShape(ids.line1)).toMatchObject({ x: 120, y: 90 })
|
|
767
|
+
const { gapLines, pointLines } = getGapAndPointLines(editor.snaps.getLines()!)
|
|
768
|
+
expect(gapLines).toHaveLength(1)
|
|
769
|
+
expect(pointLines).toHaveLength(1)
|
|
770
|
+
expect(gapLines[0].gaps.length).toBe(2)
|
|
771
|
+
expect(pointLines[0].points.length).toBe(6)
|
|
772
|
+
})
|
|
773
|
+
it('shows vertical point snaps at the same time as horizontal gap snaps', () => {
|
|
774
|
+
// ┌─────┐ ┌─────┐
|
|
775
|
+
// │ │ │ │
|
|
776
|
+
// │ │ │ │
|
|
777
|
+
// │ │ │ │
|
|
778
|
+
// │ A │ │ B │
|
|
779
|
+
// │ │ ┌───┐ │ │
|
|
780
|
+
// │ ├──┼──┤ C ├──┼──┤ │ x
|
|
781
|
+
// │ │ └───┘ │ │ │
|
|
782
|
+
// └─────┘ └─────┘ │
|
|
783
|
+
// │
|
|
784
|
+
// ┌───────┐ │
|
|
785
|
+
// │ D │ x
|
|
786
|
+
// └───────┘
|
|
787
|
+
editor.createShapes([
|
|
788
|
+
{ type: 'geo', id: ids.box1, x: 0, y: 0, props: { w: 50, h: 100 } },
|
|
789
|
+
{ type: 'geo', id: ids.box2, x: 200, y: 0, props: { w: 50, h: 100 } },
|
|
790
|
+
{ type: 'geo', id: ids.line1, x: 50, y: 0, props: { w: 10, h: 10 } },
|
|
791
|
+
{ type: 'geo', id: ids.boxD, x: 75, y: 150, props: { w: 100, h: 10 } },
|
|
792
|
+
])
|
|
793
|
+
|
|
794
|
+
// the midpoint is 125 and c is 10 wide so it should snap to 120 if we put it at 121
|
|
795
|
+
editor.pointerDown(55, 5, ids.line1).pointerMove(126, 67, { ctrlKey: true })
|
|
796
|
+
expect(editor.getShape(ids.line1)).toMatchObject({ x: 120, y: 62 })
|
|
797
|
+
const { gapLines, pointLines } = getGapAndPointLines(editor.snaps.getLines()!)
|
|
798
|
+
expect(gapLines).toHaveLength(1)
|
|
799
|
+
expect(pointLines).toHaveLength(1)
|
|
800
|
+
|
|
801
|
+
expect(gapLines[0].gaps.length).toBe(2)
|
|
802
|
+
expect(pointLines[0].points.length).toBe(2)
|
|
803
|
+
})
|
|
804
|
+
it('snaps a shape vertically between two others', () => {
|
|
805
|
+
// ┌──────────────────────────┐
|
|
806
|
+
// │ │
|
|
807
|
+
// │ A │
|
|
808
|
+
// │ │
|
|
809
|
+
// └─────┬────────────────────┘
|
|
810
|
+
// │
|
|
811
|
+
// ─┼─
|
|
812
|
+
// │
|
|
813
|
+
// ┌─┴─┐
|
|
814
|
+
// │ C │
|
|
815
|
+
// └─┬─┘
|
|
816
|
+
// │
|
|
817
|
+
// ─┼─
|
|
818
|
+
// │
|
|
819
|
+
// ┌─────┴────────────────────┐
|
|
820
|
+
// │ │
|
|
821
|
+
// │ B │
|
|
822
|
+
// │ │
|
|
823
|
+
// └──────────────────────────┘
|
|
824
|
+
editor.createShapes([
|
|
825
|
+
{ type: 'geo', id: ids.box1, x: 0, y: 0, props: { w: 100, h: 50 } },
|
|
826
|
+
{ type: 'geo', id: ids.box2, x: 0, y: 200, props: { w: 100, h: 50 } },
|
|
827
|
+
{ type: 'geo', id: ids.line1, x: 50, y: 150, props: { w: 10, h: 10 } },
|
|
828
|
+
])
|
|
829
|
+
// the midpoint is 125 and c is 10 wide so it should snap to 120 if we put it at 121
|
|
830
|
+
editor.pointerDown(55, 155, ids.line1).pointerMove(27, 126, { ctrlKey: true })
|
|
831
|
+
expect(editor.getShape(ids.line1)).toMatchObject({ x: 22, y: 120 })
|
|
832
|
+
expect(editor.snaps.getLines()?.length).toBe(1)
|
|
833
|
+
assertGaps(editor.snaps.getLines()![0])
|
|
834
|
+
const { gapLines } = getGapAndPointLines(editor.snaps.getLines()!)
|
|
835
|
+
expect(gapLines[0].gaps.length).toBe(2)
|
|
836
|
+
})
|
|
837
|
+
it('shows vertical snap points at the same time as vertical gaps', () => {
|
|
838
|
+
// x ┌──────────────────────────┐
|
|
839
|
+
// │ │ │
|
|
840
|
+
// │ │ A │
|
|
841
|
+
// │ │ │
|
|
842
|
+
// x └─┬────────────────────────┘
|
|
843
|
+
// │ │
|
|
844
|
+
// │ ─┼─
|
|
845
|
+
// │ │
|
|
846
|
+
// x ┌─┴─┐
|
|
847
|
+
// │ │ C │
|
|
848
|
+
// x └─┬─┘
|
|
849
|
+
// │ │
|
|
850
|
+
// │ ─┼─
|
|
851
|
+
// │ │
|
|
852
|
+
// x ┌─┴────────────────────────┐
|
|
853
|
+
// │ │ │
|
|
854
|
+
// │ │ B │
|
|
855
|
+
// │ │ │
|
|
856
|
+
// x └──────────────────────────┘
|
|
857
|
+
editor.createShapes([
|
|
858
|
+
{ type: 'geo', id: ids.box1, x: 0, y: 0, props: { w: 100, h: 50 } },
|
|
859
|
+
{ type: 'geo', id: ids.box2, x: 0, y: 200, props: { w: 100, h: 50 } },
|
|
860
|
+
{ type: 'geo', id: ids.line1, x: 50, y: 150, props: { w: 10, h: 10 } },
|
|
861
|
+
])
|
|
862
|
+
// the midpoint is 125 and c is 10 wide so it should snap to 120 if we put it at 121
|
|
863
|
+
editor.pointerDown(55, 155, ids.line1).pointerMove(6, 126, { ctrlKey: true })
|
|
864
|
+
expect(editor.getShape(ids.line1)).toMatchObject({ x: 0, y: 120 })
|
|
865
|
+
|
|
866
|
+
const { gapLines, pointLines } = getGapAndPointLines(editor.snaps.getLines()!)
|
|
867
|
+
expect(gapLines).toHaveLength(1)
|
|
868
|
+
expect(pointLines).toHaveLength(1)
|
|
869
|
+
expect(gapLines[0].gaps.length).toBe(2)
|
|
870
|
+
expect(pointLines[0].points.length).toBe(6)
|
|
871
|
+
})
|
|
872
|
+
it('shows horizontal snap points at the same time as vertical gaps', () => {
|
|
873
|
+
// ┌──────────────────────────┐
|
|
874
|
+
// │ │
|
|
875
|
+
// │ A │
|
|
876
|
+
// │ │
|
|
877
|
+
// └────┬─────────────────────┘
|
|
878
|
+
// │
|
|
879
|
+
// ─┼─ D┌───────────┐
|
|
880
|
+
// │ │ │
|
|
881
|
+
// C┌─┴─┐ │ │
|
|
882
|
+
// │ x─┼───────┼─────x │
|
|
883
|
+
// └─┬─┘ │ │
|
|
884
|
+
// │ │ │
|
|
885
|
+
// ─┼─ └───────────┘
|
|
886
|
+
// │
|
|
887
|
+
// ┌────┴─────────────────────┐
|
|
888
|
+
// │ │
|
|
889
|
+
// │ B │
|
|
890
|
+
// │ │
|
|
891
|
+
// └──────────────────────────┘
|
|
892
|
+
editor.createShapes([
|
|
893
|
+
{ type: 'geo', id: ids.box1, x: 0, y: 0, props: { w: 100, h: 50 } },
|
|
894
|
+
{ type: 'geo', id: ids.box2, x: 0, y: 200, props: { w: 100, h: 50 } },
|
|
895
|
+
{ type: 'geo', id: ids.line1, x: 50, y: 150, props: { w: 10, h: 10 } },
|
|
896
|
+
{ type: 'geo', id: ids.boxD, x: 50, y: 75, props: { w: 10, h: 100 } },
|
|
897
|
+
])
|
|
898
|
+
// the midpoint is 125 and c is 10 wide so it should snap to 120 if we put it at 121
|
|
899
|
+
editor.pointerDown(55, 155, ids.line1).pointerMove(27, 126, { ctrlKey: true })
|
|
900
|
+
expect(editor.getShape(ids.line1)).toMatchObject({ x: 22, y: 120 })
|
|
901
|
+
|
|
902
|
+
const { gapLines, pointLines } = getGapAndPointLines(editor.snaps.getLines()!)
|
|
903
|
+
expect(gapLines).toHaveLength(1)
|
|
904
|
+
expect(pointLines).toHaveLength(1)
|
|
905
|
+
expect(gapLines[0].gaps).toHaveLength(2)
|
|
906
|
+
expect(pointLines[0].points).toHaveLength(2)
|
|
907
|
+
})
|
|
908
|
+
it('can happen on multiple axes at the same time', () => {
|
|
909
|
+
// ┌──────────────────────────┐
|
|
910
|
+
// │ │
|
|
911
|
+
// │ A │
|
|
912
|
+
// ┌─────┐ │ ┌─────┐ │
|
|
913
|
+
// │ │ └─────┬─────────┼─────┼────┘
|
|
914
|
+
// │ │ │ │ │
|
|
915
|
+
// │ │ ─┼─ │ │
|
|
916
|
+
// │ D │ │ │ B │
|
|
917
|
+
// │ │ ┌─┴─┐ │ │
|
|
918
|
+
// │ ├───┼───┤ E ├───┼───┤ │
|
|
919
|
+
// │ │ └─┬─┘ │ │
|
|
920
|
+
// └─────┘ │ └─────┘
|
|
921
|
+
// ─┼─
|
|
922
|
+
// │
|
|
923
|
+
// ┌─────┴────────────────────┐
|
|
924
|
+
// │ │
|
|
925
|
+
// │ C │
|
|
926
|
+
// │ │
|
|
927
|
+
// └──────────────────────────┘
|
|
928
|
+
editor.createShapes([
|
|
929
|
+
{ type: 'geo', id: ids.box1, x: 50, y: 0, props: { w: 200, h: 50 } },
|
|
930
|
+
{ type: 'geo', id: ids.box2, x: 150, y: 50, props: { w: 50, h: 100 } },
|
|
931
|
+
{ type: 'geo', id: ids.line1, x: 50, y: 200, props: { w: 200, h: 50 } },
|
|
932
|
+
{ type: 'geo', id: ids.boxD, x: 0, y: 50, props: { w: 50, h: 100 } },
|
|
933
|
+
{ type: 'geo', id: ids.boxE, x: 0, y: 0, props: { w: 10, h: 10 } },
|
|
934
|
+
])
|
|
935
|
+
editor.pointerDown(5, 5, ids.boxE).pointerMove(101, 126, { ctrlKey: true })
|
|
936
|
+
expect(editor.getShape(ids.boxE)).toMatchObject({ x: 95, y: 120 })
|
|
937
|
+
expect(editor.snaps.getLines()?.length).toBe(2)
|
|
938
|
+
assertGaps(editor.snaps.getLines()![0])
|
|
939
|
+
assertGaps(editor.snaps.getLines()![1])
|
|
940
|
+
const { gapLines } = getGapAndPointLines(editor.snaps.getLines()!)
|
|
941
|
+
expect(gapLines[0].gaps.length).toBe(2)
|
|
942
|
+
expect(gapLines[1].gaps.length).toBe(2)
|
|
943
|
+
})
|
|
944
|
+
it('will expand a horizontal and vertical selections outwards if possible', () => {
|
|
945
|
+
// ┌───┐
|
|
946
|
+
// │ E │
|
|
947
|
+
// └─┬─┘
|
|
948
|
+
// ┼
|
|
949
|
+
// ┌─┴─┐
|
|
950
|
+
// │ F │
|
|
951
|
+
// └─┬─┘
|
|
952
|
+
// ┼
|
|
953
|
+
// ┌───┐ ┌───┐ ┌─┴─┐ ┌───┐ ┌───┐
|
|
954
|
+
// │ A ├─┼─┤ B ├─┼─┤ X ├─┼─┤ C ├─┼─┤ D │
|
|
955
|
+
// └───┘ └───┘ └─┬─┘ └───┘ └───┘
|
|
956
|
+
// ┼
|
|
957
|
+
// ┌─┴─┐
|
|
958
|
+
// │ G │
|
|
959
|
+
// └─┬─┘
|
|
960
|
+
// ┼
|
|
961
|
+
// ┌─┴─┐
|
|
962
|
+
// │ H │
|
|
963
|
+
// └───┘
|
|
964
|
+
// dragging X
|
|
965
|
+
|
|
966
|
+
editor.createShapes([
|
|
967
|
+
box(ids.box1, 0, 40),
|
|
968
|
+
box(ids.box2, 20, 40),
|
|
969
|
+
box(ids.line1, 60, 40),
|
|
970
|
+
box(ids.boxD, 80, 40),
|
|
971
|
+
box(ids.boxE, 40, 0),
|
|
972
|
+
box(ids.boxF, 40, 20),
|
|
973
|
+
box(ids.boxG, 40, 60),
|
|
974
|
+
box(ids.boxH, 40, 80),
|
|
975
|
+
|
|
976
|
+
box(ids.boxX, 0, 0),
|
|
977
|
+
])
|
|
978
|
+
|
|
979
|
+
editor.pointerDown(5, 5, ids.boxX).pointerMove(46, 46, { ctrlKey: true })
|
|
980
|
+
expect(editor.getShape(ids.boxX)).toMatchObject({ x: 40, y: 40 })
|
|
981
|
+
|
|
982
|
+
const { gapLines, pointLines } = getGapAndPointLines(editor.snaps.getLines()!)
|
|
983
|
+
expect(gapLines).toHaveLength(2)
|
|
984
|
+
expect(gapLines[0].gaps).toHaveLength(4)
|
|
985
|
+
expect(gapLines[1].gaps).toHaveLength(4)
|
|
986
|
+
|
|
987
|
+
// it should also have snap lines for all the edge/center alignments
|
|
988
|
+
expect(pointLines).toHaveLength(6)
|
|
989
|
+
})
|
|
990
|
+
|
|
991
|
+
it('will show multiple non-overlapping snap-betweens on the same axis', () => {
|
|
992
|
+
// ┌─────┐ ┌─────┐
|
|
993
|
+
// │ A │ │ B │
|
|
994
|
+
// └──┬──┘ └──┬──┘
|
|
995
|
+
// ┼ ┼
|
|
996
|
+
// ┌──┴─────────┴──┐
|
|
997
|
+
// │ X drag │
|
|
998
|
+
// └──┬─────────┬──┘
|
|
999
|
+
// ┼ ┼
|
|
1000
|
+
// ┌──┴──┐ ┌──┴──┐
|
|
1001
|
+
// │ C │ │ D │
|
|
1002
|
+
// └─────┘ └─────┘
|
|
1003
|
+
|
|
1004
|
+
editor.createShapes([
|
|
1005
|
+
box(ids.box1, 0, 0),
|
|
1006
|
+
box(ids.box2, 20, 0),
|
|
1007
|
+
box(ids.line1, 0, 40),
|
|
1008
|
+
box(ids.boxD, 20, 40),
|
|
1009
|
+
box(ids.boxX, 50, 20, 30),
|
|
1010
|
+
])
|
|
1011
|
+
|
|
1012
|
+
editor.pointerDown(65, 25, ids.boxX).pointerMove(16, 25, { ctrlKey: true })
|
|
1013
|
+
expect(editor.getShape(ids.boxX)).toMatchObject({ x: 0, y: 20 })
|
|
1014
|
+
|
|
1015
|
+
const { gapLines, pointLines } = getGapAndPointLines(editor.snaps.getLines()!)
|
|
1016
|
+
expect(gapLines).toHaveLength(2)
|
|
1017
|
+
expect(gapLines[0].gaps).toHaveLength(2)
|
|
1018
|
+
expect(gapLines[1].gaps).toHaveLength(2)
|
|
1019
|
+
|
|
1020
|
+
// check outer edge snaps too
|
|
1021
|
+
expect(pointLines).toHaveLength(2)
|
|
1022
|
+
expect(pointLines[0].points).toHaveLength(6)
|
|
1023
|
+
expect(pointLines[1].points).toHaveLength(6)
|
|
1024
|
+
})
|
|
1025
|
+
|
|
1026
|
+
it('should not snap horizontally if the shape is larger than the gap', () => {
|
|
1027
|
+
// ┌─────┐ ┌─────┐
|
|
1028
|
+
// │ │ │ │
|
|
1029
|
+
// │ A │ │ B │
|
|
1030
|
+
// │ │ │ │
|
|
1031
|
+
// │ │ │ │
|
|
1032
|
+
// ┌──────┼─────┼─────────────┼─────┼──────┐
|
|
1033
|
+
// │ │ │ │ │ │
|
|
1034
|
+
// │ │ │ X │ │ │ ◄─── drag
|
|
1035
|
+
// │ │ │ │ │ │
|
|
1036
|
+
// └──────┼─────┼─────────────┼─────┼──────┘
|
|
1037
|
+
// │ │ │ │
|
|
1038
|
+
// │ │ │ │
|
|
1039
|
+
// │ │ │ │
|
|
1040
|
+
// └─────┘ └─────┘
|
|
1041
|
+
//
|
|
1042
|
+
// no snap to center gap between A + B
|
|
1043
|
+
editor.createShapes([
|
|
1044
|
+
box(ids.box1, 20, 0, 10, 100),
|
|
1045
|
+
box(ids.box2, 70, 0, 10, 100),
|
|
1046
|
+
box(ids.boxX, 0, 50, 100, 10),
|
|
1047
|
+
])
|
|
1048
|
+
|
|
1049
|
+
editor.pointerDown(50, 55, ids.boxX).pointerMove(51, 66, { ctrlKey: true })
|
|
1050
|
+
|
|
1051
|
+
expect(editor.getShape(ids.boxX)).toMatchObject({ x: 1, y: 61 })
|
|
1052
|
+
expect(editor.snaps.getLines()?.length).toBe(0)
|
|
1053
|
+
})
|
|
1054
|
+
|
|
1055
|
+
it('should work if the thing being dragged is a selection', () => {
|
|
1056
|
+
// selection
|
|
1057
|
+
// ┌─────────────────────────┐
|
|
1058
|
+
// │ │ ┌────────┐
|
|
1059
|
+
// ┌────────┐ │ ┌────────────┐ │ │ │
|
|
1060
|
+
// │ │ │ │ │ │ │ │
|
|
1061
|
+
// │ │ │ │ C │ │ │ │
|
|
1062
|
+
// │ A ├───┼───┤ ┌────┐ └────────────┘ ├───┼───┤ B │
|
|
1063
|
+
// │ │ │ │ │ │ │ │
|
|
1064
|
+
// │ │ │ │ D │ │ │ │
|
|
1065
|
+
// └────────┘ │ └────┘ │ └────────┘
|
|
1066
|
+
// └─────────────────────────┘
|
|
1067
|
+
editor.createShapes([
|
|
1068
|
+
box(ids.box1, 0, 50, 50, 100),
|
|
1069
|
+
box(ids.box2, 350, 0, 50, 100),
|
|
1070
|
+
box(ids.line1, 200, 10, 100, 10),
|
|
1071
|
+
box(ids.boxD, 100, 80, 10, 50),
|
|
1072
|
+
])
|
|
1073
|
+
|
|
1074
|
+
editor.select(ids.line1, ids.boxD)
|
|
1075
|
+
|
|
1076
|
+
editor.pointerDown(200, 50, ids.line1).pointerMove(201, 61, { ctrlKey: true })
|
|
1077
|
+
|
|
1078
|
+
expect(editor.getShape(ids.line1)).toMatchObject({ x: 200, y: 21 })
|
|
1079
|
+
|
|
1080
|
+
const { gapLines, pointLines } = getGapAndPointLines(editor.snaps.getLines()!)
|
|
1081
|
+
|
|
1082
|
+
expect(gapLines).toHaveLength(1)
|
|
1083
|
+
expect(pointLines).toHaveLength(0)
|
|
1084
|
+
|
|
1085
|
+
expect(gapLines[0].gaps).toHaveLength(2)
|
|
1086
|
+
|
|
1087
|
+
const sortedGaps = gapLines[0].gaps.sort((a, b) => a.startEdge[0].x - b.startEdge[0].x)
|
|
1088
|
+
|
|
1089
|
+
expect(sortedGaps[0].startEdge[0].x).toBeCloseTo(50)
|
|
1090
|
+
expect(sortedGaps[0].endEdge[0].x).toBeCloseTo(100)
|
|
1091
|
+
|
|
1092
|
+
expect(sortedGaps[1].startEdge[0].x).toBeCloseTo(300)
|
|
1093
|
+
expect(sortedGaps[1].endEdge[0].x).toBeCloseTo(350)
|
|
1094
|
+
})
|
|
1095
|
+
})
|
|
1096
|
+
|
|
1097
|
+
describe('Snap-next-to behavior', () => {
|
|
1098
|
+
beforeEach(() => {
|
|
1099
|
+
editor?.dispose()
|
|
1100
|
+
})
|
|
1101
|
+
it('snaps a shape to the left of two others, matching the gap size', () => {
|
|
1102
|
+
// ┌───┐
|
|
1103
|
+
// │ X │
|
|
1104
|
+
// └───┘ ┌───┐ ┌───┐
|
|
1105
|
+
// │ A │ │ B │
|
|
1106
|
+
// └───┘ └───┘
|
|
1107
|
+
// │
|
|
1108
|
+
// │ drag x down
|
|
1109
|
+
// ▼
|
|
1110
|
+
//
|
|
1111
|
+
// ┌───┐ ┌───┐ ┌───┐
|
|
1112
|
+
// │ X ├────┼────┤ A ├────┼────┤ B │ *snap*
|
|
1113
|
+
// └───┘ └───┘ └───┘
|
|
1114
|
+
editor.createShapes([box(ids.boxX, 0, 0), box(ids.box1, 50, 10), box(ids.box2, 100, 10)])
|
|
1115
|
+
|
|
1116
|
+
editor.pointerDown(5, 5, ids.boxX).pointerMove(6, 16, { ctrlKey: true })
|
|
1117
|
+
expect(editor.getShape(ids.boxX)).toMatchObject({ x: 0, y: 10 })
|
|
1118
|
+
|
|
1119
|
+
const { gapLines, pointLines } = getGapAndPointLines(editor.snaps.getLines()!)
|
|
1120
|
+
|
|
1121
|
+
expect(gapLines).toHaveLength(1)
|
|
1122
|
+
expect(gapLines[0].gaps).toHaveLength(2)
|
|
1123
|
+
|
|
1124
|
+
// also check the outer edge snaps
|
|
1125
|
+
expect(pointLines).toHaveLength(3)
|
|
1126
|
+
})
|
|
1127
|
+
|
|
1128
|
+
it('expands the selection to the right for left snap-besides ', () => {
|
|
1129
|
+
// ┌───┐
|
|
1130
|
+
// │ X │
|
|
1131
|
+
// └───┘ ┌───┐ ┌───┐ ┌───┐ ┌───┐
|
|
1132
|
+
// │ A │ │ B │ │ C │ │ D │
|
|
1133
|
+
// └───┘ └───┘ └───┘ └───┘
|
|
1134
|
+
// │
|
|
1135
|
+
// │ drag x down
|
|
1136
|
+
// ▼
|
|
1137
|
+
//
|
|
1138
|
+
// ┌───┐ ┌───┐ ┌───┐ ┌───┐ ┌───┐
|
|
1139
|
+
// │ X ├────┼────┤ A ├────┼────┤ B ├────┼────┤ C ├────┼────┤ D │
|
|
1140
|
+
// └───┘ └───┘ └───┘ └───┘ └───┘
|
|
1141
|
+
//
|
|
1142
|
+
// *snap*
|
|
1143
|
+
//
|
|
1144
|
+
editor.createShapes([
|
|
1145
|
+
box(ids.boxX, 0, 0),
|
|
1146
|
+
box(ids.box1, 50, 10),
|
|
1147
|
+
box(ids.box2, 100, 10),
|
|
1148
|
+
box(ids.line1, 150, 10),
|
|
1149
|
+
box(ids.boxD, 200, 10),
|
|
1150
|
+
])
|
|
1151
|
+
|
|
1152
|
+
editor.pointerDown(5, 5, ids.boxX).pointerMove(6, 16, { ctrlKey: true })
|
|
1153
|
+
expect(editor.getShape(ids.boxX)).toMatchObject({ x: 0, y: 10 })
|
|
1154
|
+
|
|
1155
|
+
const { gapLines, pointLines } = getGapAndPointLines(editor.snaps.getLines()!)
|
|
1156
|
+
|
|
1157
|
+
expect(gapLines).toHaveLength(1)
|
|
1158
|
+
expect(gapLines[0].gaps).toHaveLength(4)
|
|
1159
|
+
|
|
1160
|
+
// also check the outer edge snaps
|
|
1161
|
+
expect(pointLines).toHaveLength(3)
|
|
1162
|
+
})
|
|
1163
|
+
|
|
1164
|
+
it('snaps a shape to the right of two others, matching the gap size', () => {
|
|
1165
|
+
// ┌───┐
|
|
1166
|
+
// │ X │
|
|
1167
|
+
// ┌───┐ ┌───┐ └───┘
|
|
1168
|
+
// │ A │ │ B │
|
|
1169
|
+
// └───┘ └───┘
|
|
1170
|
+
// │
|
|
1171
|
+
// │ drag X down
|
|
1172
|
+
// ▼
|
|
1173
|
+
//
|
|
1174
|
+
// ┌───┐ ┌───┐ ┌───┐
|
|
1175
|
+
// │ A ├────┼────┤ B ├────┼────┤ X │ *snap*
|
|
1176
|
+
// └───┘ └───┘ └───┘
|
|
1177
|
+
editor.createShapes([box(ids.box1, 0, 10), box(ids.box2, 50, 10), box(ids.boxX, 100, 0)])
|
|
1178
|
+
|
|
1179
|
+
editor.pointerDown(105, 5, ids.boxX).pointerMove(106, 16, { ctrlKey: true })
|
|
1180
|
+
expect(editor.getShape(ids.boxX)).toMatchObject({ x: 100, y: 10 })
|
|
1181
|
+
|
|
1182
|
+
const { gapLines, pointLines } = getGapAndPointLines(editor.snaps.getLines()!)
|
|
1183
|
+
|
|
1184
|
+
expect(gapLines).toHaveLength(1)
|
|
1185
|
+
expect(gapLines[0].gaps).toHaveLength(2)
|
|
1186
|
+
|
|
1187
|
+
// also check the outer edge snaps
|
|
1188
|
+
expect(pointLines).toHaveLength(3)
|
|
1189
|
+
})
|
|
1190
|
+
it('expands the selection to the left for right snap-besides ', () => {
|
|
1191
|
+
// ┌───┐
|
|
1192
|
+
// │ X │
|
|
1193
|
+
// ┌───┐ ┌───┐ ┌───┐ ┌───┐ └───┘
|
|
1194
|
+
// │ A │ │ B │ │ C │ │ D │
|
|
1195
|
+
// └───┘ └───┘ └───┘ └───┘
|
|
1196
|
+
// │
|
|
1197
|
+
// drag x down │
|
|
1198
|
+
// ▼
|
|
1199
|
+
//
|
|
1200
|
+
// ┌───┐ ┌───┐ ┌───┐ ┌───┐ ┌───┐
|
|
1201
|
+
// │ A ├────┼────┤ B ├────┼────┤ C ├────┼────┤ D ├────┼────┤ x │
|
|
1202
|
+
// └───┘ └───┘ └───┘ └───┘ └───┘
|
|
1203
|
+
//
|
|
1204
|
+
// *snap*
|
|
1205
|
+
editor.createShapes([
|
|
1206
|
+
box(ids.box1, 0, 10),
|
|
1207
|
+
box(ids.box2, 50, 10),
|
|
1208
|
+
box(ids.line1, 100, 10),
|
|
1209
|
+
box(ids.boxD, 150, 10),
|
|
1210
|
+
box(ids.boxX, 200, 0),
|
|
1211
|
+
])
|
|
1212
|
+
|
|
1213
|
+
editor.pointerDown(205, 5, ids.boxX).pointerMove(206, 16, { ctrlKey: true })
|
|
1214
|
+
expect(editor.getShape(ids.boxX)).toMatchObject({ x: 200, y: 10 })
|
|
1215
|
+
|
|
1216
|
+
const { gapLines, pointLines } = getGapAndPointLines(editor.snaps.getLines()!)
|
|
1217
|
+
|
|
1218
|
+
expect(gapLines).toHaveLength(1)
|
|
1219
|
+
expect(gapLines[0].gaps).toHaveLength(4)
|
|
1220
|
+
|
|
1221
|
+
// also check the outer edge snaps
|
|
1222
|
+
expect(pointLines).toHaveLength(3)
|
|
1223
|
+
})
|
|
1224
|
+
it('snaps a shape above two others, matching the gap size', () => {
|
|
1225
|
+
// ┌───┐ ┌───┐
|
|
1226
|
+
// │ X │ │ X │
|
|
1227
|
+
// └───┘ └─┬─┘
|
|
1228
|
+
// drag X ┼
|
|
1229
|
+
// ┌───┐ ┌─┴─┐
|
|
1230
|
+
// │ A │ ────► │ A │ *snap*
|
|
1231
|
+
// └───┘ └─┬─┘
|
|
1232
|
+
// ┼
|
|
1233
|
+
// ┌───┐ ┌─┴─┐
|
|
1234
|
+
// │ B │ │ B │
|
|
1235
|
+
// └───┘ └───┘
|
|
1236
|
+
editor.createShapes([box(ids.boxX, 0, 0), box(ids.box1, 10, 20), box(ids.box2, 10, 40)])
|
|
1237
|
+
|
|
1238
|
+
editor.pointerDown(5, 5, ids.boxX).pointerMove(16, 6, { ctrlKey: true })
|
|
1239
|
+
|
|
1240
|
+
expect(editor.getShape(ids.boxX)).toMatchObject({ x: 10, y: 0 })
|
|
1241
|
+
|
|
1242
|
+
const { gapLines, pointLines } = getGapAndPointLines(editor.snaps.getLines()!)
|
|
1243
|
+
|
|
1244
|
+
expect(gapLines).toHaveLength(1)
|
|
1245
|
+
expect(gapLines[0].gaps).toHaveLength(2)
|
|
1246
|
+
|
|
1247
|
+
// also check the outer edge snaps
|
|
1248
|
+
expect(pointLines).toHaveLength(3)
|
|
1249
|
+
})
|
|
1250
|
+
|
|
1251
|
+
it('expands the selection downwards for top snap-besides ', () => {
|
|
1252
|
+
// ┌───┐ ┌───┐
|
|
1253
|
+
// │ X │ │ X │
|
|
1254
|
+
// └───┘ └─┬─┘
|
|
1255
|
+
// drag X ┼
|
|
1256
|
+
// ┌───┐ ┌─┴─┐
|
|
1257
|
+
// │ A │ ────► │ A │ *snap*
|
|
1258
|
+
// └───┘ └─┬─┘
|
|
1259
|
+
// ┼
|
|
1260
|
+
// ┌───┐ ┌─┴─┐
|
|
1261
|
+
// │ B │ │ B │
|
|
1262
|
+
// └───┘ └─┬─┘
|
|
1263
|
+
// ┼
|
|
1264
|
+
// ┌───┐ ┌─┴─┐
|
|
1265
|
+
// │ C │ │ C │
|
|
1266
|
+
// └───┘ └─┬─┘
|
|
1267
|
+
// ┼
|
|
1268
|
+
// ┌───┐ ┌─┴─┐
|
|
1269
|
+
// │ D │ │ D │
|
|
1270
|
+
// └───┘ └───┘
|
|
1271
|
+
|
|
1272
|
+
editor.createShapes([
|
|
1273
|
+
box(ids.boxX, 0, 0),
|
|
1274
|
+
box(ids.box1, 10, 20),
|
|
1275
|
+
box(ids.box2, 10, 40),
|
|
1276
|
+
box(ids.line1, 10, 60),
|
|
1277
|
+
box(ids.boxD, 10, 80),
|
|
1278
|
+
])
|
|
1279
|
+
|
|
1280
|
+
editor.pointerDown(5, 5, ids.boxX).pointerMove(16, 6, { ctrlKey: true })
|
|
1281
|
+
|
|
1282
|
+
expect(editor.getShape(ids.boxX)).toMatchObject({ x: 10, y: 0 })
|
|
1283
|
+
|
|
1284
|
+
const { gapLines, pointLines } = getGapAndPointLines(editor.snaps.getLines()!)
|
|
1285
|
+
|
|
1286
|
+
expect(gapLines).toHaveLength(1)
|
|
1287
|
+
expect(gapLines[0].gaps).toHaveLength(4)
|
|
1288
|
+
|
|
1289
|
+
// also check the outer edge snaps
|
|
1290
|
+
expect(pointLines).toHaveLength(3)
|
|
1291
|
+
})
|
|
1292
|
+
|
|
1293
|
+
it('snaps a shape below two others, matching the gap size', () => {
|
|
1294
|
+
// ┌───┐ ┌───┐
|
|
1295
|
+
// │ A │ │ A │
|
|
1296
|
+
// └───┘ └─┬─┘
|
|
1297
|
+
// ┼
|
|
1298
|
+
// ┌───┐ ┌─┴─┐
|
|
1299
|
+
// │ B │ │ B │
|
|
1300
|
+
// └───┘ └─┬─┘
|
|
1301
|
+
// ┼
|
|
1302
|
+
// ┌───┐ drag X ┌─┴─┐ *snap*
|
|
1303
|
+
// │ X │ │ X │
|
|
1304
|
+
// └───┘ ────► └───┘
|
|
1305
|
+
editor.createShapes([box(ids.box1, 10, 0), box(ids.box2, 10, 20), box(ids.boxX, 0, 40)])
|
|
1306
|
+
|
|
1307
|
+
editor.pointerDown(5, 45, ids.boxX).pointerMove(16, 46, { ctrlKey: true })
|
|
1308
|
+
|
|
1309
|
+
expect(editor.getShape(ids.boxX)).toMatchObject({ x: 10, y: 40 })
|
|
1310
|
+
|
|
1311
|
+
const { gapLines, pointLines } = getGapAndPointLines(editor.snaps.getLines()!)
|
|
1312
|
+
|
|
1313
|
+
expect(gapLines).toHaveLength(1)
|
|
1314
|
+
expect(gapLines[0].gaps).toHaveLength(2)
|
|
1315
|
+
|
|
1316
|
+
// also check the outer edge snaps
|
|
1317
|
+
expect(pointLines).toHaveLength(3)
|
|
1318
|
+
})
|
|
1319
|
+
|
|
1320
|
+
it('expands the selection upwards for bottom snap-besides ', () => {
|
|
1321
|
+
// ┌───┐ ┌───┐
|
|
1322
|
+
// │ A │ │ A │
|
|
1323
|
+
// └───┘ └─┬─┘
|
|
1324
|
+
// ┼
|
|
1325
|
+
// ┌───┐ ┌─┴─┐
|
|
1326
|
+
// │ B │ │ B │
|
|
1327
|
+
// └───┘ └─┬─┘
|
|
1328
|
+
// ┼
|
|
1329
|
+
// ┌───┐ ┌─┴─┐
|
|
1330
|
+
// │ C │ │ C │
|
|
1331
|
+
// └───┘ └─┬─┘
|
|
1332
|
+
// ┼
|
|
1333
|
+
// ┌───┐ ┌─┴─┐
|
|
1334
|
+
// │ D │ │ D │
|
|
1335
|
+
// └───┘ └─┬─┘
|
|
1336
|
+
// ┼
|
|
1337
|
+
// ┌───┐ drag X ┌─┴─┐ *snap*
|
|
1338
|
+
// │ X │ │ X │
|
|
1339
|
+
// └───┘ ────► └───┘
|
|
1340
|
+
editor.createShapes([
|
|
1341
|
+
box(ids.box1, 10, 0),
|
|
1342
|
+
box(ids.box2, 10, 20),
|
|
1343
|
+
box(ids.line1, 10, 40),
|
|
1344
|
+
box(ids.boxD, 10, 60),
|
|
1345
|
+
box(ids.boxX, 0, 80),
|
|
1346
|
+
])
|
|
1347
|
+
|
|
1348
|
+
editor.pointerDown(5, 85, ids.boxX).pointerMove(16, 86, { ctrlKey: true })
|
|
1349
|
+
|
|
1350
|
+
expect(editor.getShape(ids.boxX)).toMatchObject({ x: 10, y: 80 })
|
|
1351
|
+
|
|
1352
|
+
const { gapLines, pointLines } = getGapAndPointLines(editor.snaps.getLines()!)
|
|
1353
|
+
|
|
1354
|
+
expect(gapLines).toHaveLength(1)
|
|
1355
|
+
expect(gapLines[0].gaps).toHaveLength(4)
|
|
1356
|
+
|
|
1357
|
+
// also check the outer edge snaps
|
|
1358
|
+
expect(pointLines).toHaveLength(3)
|
|
1359
|
+
})
|
|
1360
|
+
|
|
1361
|
+
it('should work if the thing being dragged is a selection', () => {
|
|
1362
|
+
// selection
|
|
1363
|
+
// ┌─────────────────────────┐
|
|
1364
|
+
// │ │
|
|
1365
|
+
// ┌────────┐ ┌────────┐ │ ┌────────────┐ │
|
|
1366
|
+
// │ │ │ │ │ │ C │ │
|
|
1367
|
+
// │ │ │ │ │ │ │ │
|
|
1368
|
+
// │ A ├───┼───┤ B ├───┼───┤ ┌────┐ └────────────┘ │
|
|
1369
|
+
// │ │ │ │ │ │ D │ │
|
|
1370
|
+
// │ │ │ │ │ │ │ │
|
|
1371
|
+
// └────────┘ └────────┘ │ └────┘ │
|
|
1372
|
+
// └─────────────────────────┘
|
|
1373
|
+
editor.createShapes([
|
|
1374
|
+
box(ids.box1, 0, 50, 50, 100),
|
|
1375
|
+
box(ids.box2, 100, 50, 50, 100),
|
|
1376
|
+
box(ids.line1, 300, 10, 100, 10),
|
|
1377
|
+
box(ids.boxD, 200, 80, 10, 50),
|
|
1378
|
+
])
|
|
1379
|
+
|
|
1380
|
+
editor.select(ids.line1, ids.boxD)
|
|
1381
|
+
|
|
1382
|
+
editor.pointerDown(300, 50, ids.line1).pointerMove(301, 101, { ctrlKey: true })
|
|
1383
|
+
|
|
1384
|
+
expect(editor.getShape(ids.boxD)).toMatchObject({ x: 200, y: 131 })
|
|
1385
|
+
|
|
1386
|
+
const { gapLines, pointLines } = getGapAndPointLines(editor.snaps.getLines()!)
|
|
1387
|
+
|
|
1388
|
+
expect(gapLines).toHaveLength(1)
|
|
1389
|
+
expect(pointLines).toHaveLength(0)
|
|
1390
|
+
|
|
1391
|
+
expect(gapLines[0].gaps).toHaveLength(2)
|
|
1392
|
+
|
|
1393
|
+
const sortedGaps = gapLines[0].gaps.sort((a, b) => a.startEdge[0].x - b.startEdge[0].x)
|
|
1394
|
+
|
|
1395
|
+
expect(sortedGaps[0].startEdge[0].x).toBeCloseTo(50)
|
|
1396
|
+
expect(sortedGaps[0].endEdge[0].x).toBeCloseTo(100)
|
|
1397
|
+
|
|
1398
|
+
expect(sortedGaps[1].startEdge[0].x).toBeCloseTo(150)
|
|
1399
|
+
expect(sortedGaps[1].endEdge[0].x).toBeCloseTo(200)
|
|
1400
|
+
})
|
|
1401
|
+
})
|
|
1402
|
+
|
|
1403
|
+
describe('translating while the grid is enabled', () => {
|
|
1404
|
+
it('does not snap to the grid', () => {
|
|
1405
|
+
// 0 20 50 70
|
|
1406
|
+
// ┌───┐ ┌───┐
|
|
1407
|
+
// │ A │ │ B │
|
|
1408
|
+
// └───┘ └───┘
|
|
1409
|
+
editor.createShapes([box(ids.box1, 0, 0, 20, 20), box(ids.box2, 50, 0, 20, 20)])
|
|
1410
|
+
|
|
1411
|
+
editor.updateInstanceState({ isGridMode: true })
|
|
1412
|
+
|
|
1413
|
+
// try to snap A to B
|
|
1414
|
+
// doesn't work because of the grid
|
|
1415
|
+
|
|
1416
|
+
// 0 20 50 70
|
|
1417
|
+
// ┌───┬┬───┐
|
|
1418
|
+
// │ A ││ B │
|
|
1419
|
+
// └───┴┴───┘
|
|
1420
|
+
|
|
1421
|
+
editor.select(ids.box1).pointerDown(10, 10, ids.box1).pointerMove(39, 10)
|
|
1422
|
+
|
|
1423
|
+
// rounds to nearest 10
|
|
1424
|
+
expect(editor.getShapePageBounds(ids.box1)!.x).toEqual(30)
|
|
1425
|
+
|
|
1426
|
+
// engage snap mode and it should indeed snap to B
|
|
1427
|
+
|
|
1428
|
+
// 0 20 50 70
|
|
1429
|
+
// ┌───┬───┐
|
|
1430
|
+
// │ A │ B │
|
|
1431
|
+
// └───┴───┘
|
|
1432
|
+
editor.keyDown('Control')
|
|
1433
|
+
expect(editor.getShapePageBounds(ids.box1)!.x).toEqual(30)
|
|
1434
|
+
|
|
1435
|
+
// and we can move the box anywhere if there are no snaps nearby
|
|
1436
|
+
editor.pointerMove(-19, -32, { ctrlKey: true })
|
|
1437
|
+
expect(editor.getShapePageBounds(ids.box1)!).toMatchObject({ x: -29, y: -42 })
|
|
1438
|
+
})
|
|
1439
|
+
})
|
|
1440
|
+
|
|
1441
|
+
describe('snap lines', () => {
|
|
1442
|
+
it('should show up for all matching snaps, even if the axis is locked', () => {
|
|
1443
|
+
// 0 60 200
|
|
1444
|
+
//
|
|
1445
|
+
// ┌─────────────┐ ┌─────────────┐
|
|
1446
|
+
// │ A │ │ B │
|
|
1447
|
+
// │ │ │ │
|
|
1448
|
+
// ◄──────── │ │ │ │
|
|
1449
|
+
// │ │ │ │
|
|
1450
|
+
// │ │ │ │
|
|
1451
|
+
// 100 └─────────────┘ └─────────────┘
|
|
1452
|
+
//
|
|
1453
|
+
// hold shift and
|
|
1454
|
+
// drag A left to C
|
|
1455
|
+
//
|
|
1456
|
+
// 200 ┌─────────────┐
|
|
1457
|
+
// │ C │
|
|
1458
|
+
// │ │
|
|
1459
|
+
// │ │
|
|
1460
|
+
// │ │
|
|
1461
|
+
// │ │
|
|
1462
|
+
// └─────────────┘
|
|
1463
|
+
//
|
|
1464
|
+
//
|
|
1465
|
+
// ────────────────────────────────────────────────────────
|
|
1466
|
+
//
|
|
1467
|
+
//
|
|
1468
|
+
// 0 *snap* 100 200
|
|
1469
|
+
//
|
|
1470
|
+
// x─────────────x──────────────────x─────────────x
|
|
1471
|
+
// │ A │ │ B │
|
|
1472
|
+
// │ │ │ │
|
|
1473
|
+
// │ x──────┼──────────────────┼──────x │
|
|
1474
|
+
// │ │ │ │ │
|
|
1475
|
+
// │ │ │ │ │
|
|
1476
|
+
// 100 x──────┼──────x──────────────────x─────────────x
|
|
1477
|
+
// │ │ │
|
|
1478
|
+
// │ │ │
|
|
1479
|
+
// │ │ │
|
|
1480
|
+
// │ │ │
|
|
1481
|
+
// │ │ │
|
|
1482
|
+
// 200 x──────┼──────x
|
|
1483
|
+
// │ C │ │
|
|
1484
|
+
// │ │ │
|
|
1485
|
+
// │ x │
|
|
1486
|
+
// │ │
|
|
1487
|
+
// │ │
|
|
1488
|
+
// x─────────────x
|
|
1489
|
+
editor.createShapes([
|
|
1490
|
+
box(ids.box1, 60, 0, 100, 100),
|
|
1491
|
+
box(ids.box2, 200, 0, 100, 100),
|
|
1492
|
+
box(ids.line1, 0, 200, 100, 100),
|
|
1493
|
+
])
|
|
1494
|
+
|
|
1495
|
+
editor
|
|
1496
|
+
.select(ids.box1)
|
|
1497
|
+
.pointerDown(110, 50, ids.box1)
|
|
1498
|
+
.pointerMove(49, 52, { shiftKey: true, ctrlKey: true })
|
|
1499
|
+
|
|
1500
|
+
expect(editor.getShape(ids.box1)).toMatchObject({
|
|
1501
|
+
x: 0,
|
|
1502
|
+
y: 0,
|
|
1503
|
+
props: { w: 100, h: 100 },
|
|
1504
|
+
})
|
|
1505
|
+
|
|
1506
|
+
expect(getSnapLines(editor)).toMatchInlineSnapshot(`
|
|
1507
|
+
Array [
|
|
1508
|
+
"0,0 0,100 0,200 0,300",
|
|
1509
|
+
"0,0 100,0 200,0 300,0",
|
|
1510
|
+
"0,100 100,100 200,100 300,100",
|
|
1511
|
+
"100,0 100,100 100,200 100,300",
|
|
1512
|
+
"50,50 250,50",
|
|
1513
|
+
"50,50 50,250",
|
|
1514
|
+
]
|
|
1515
|
+
`)
|
|
1516
|
+
})
|
|
1517
|
+
})
|
|
1518
|
+
|
|
1519
|
+
describe('translating a shape with a child', () => {
|
|
1520
|
+
it('should not snap to the child', () => {
|
|
1521
|
+
// 0 1 11 50
|
|
1522
|
+
// ┌───────────────────┐
|
|
1523
|
+
// │ ┌───┐ │
|
|
1524
|
+
// │ │ B │ │
|
|
1525
|
+
// │ └───┘ │
|
|
1526
|
+
// │ │
|
|
1527
|
+
// │ A │
|
|
1528
|
+
// │ │
|
|
1529
|
+
// │ │
|
|
1530
|
+
// │ │
|
|
1531
|
+
// └───────────────────┘
|
|
1532
|
+
editor.createShapes([box(ids.box1, 0, 0, 50, 50), box(ids.box2, 1, 1)])
|
|
1533
|
+
editor.updateShapes([{ id: ids.box2, type: 'geo', parentId: ids.box1 }])
|
|
1534
|
+
|
|
1535
|
+
editor.pointerDown(25, 25, ids.box1).pointerMove(50, 25, { ctrlKey: true })
|
|
1536
|
+
|
|
1537
|
+
expect(editor.snaps.getLines()?.length).toBe(0)
|
|
1538
|
+
expect(editor.getShape(ids.box1)).toMatchObject({
|
|
1539
|
+
x: 25,
|
|
1540
|
+
y: 0,
|
|
1541
|
+
props: { w: 50, h: 50 },
|
|
1542
|
+
})
|
|
1543
|
+
expect(editor.getShape(ids.box2)).toMatchObject({ x: 1, y: 1, props: { w: 10, h: 10 } })
|
|
1544
|
+
expect(editor.getShapePageBounds(ids.box2)).toMatchObject({
|
|
1545
|
+
x: 26,
|
|
1546
|
+
y: 1,
|
|
1547
|
+
w: 10,
|
|
1548
|
+
h: 10,
|
|
1549
|
+
})
|
|
1550
|
+
})
|
|
1551
|
+
})
|
|
1552
|
+
|
|
1553
|
+
describe('translating a shape with a bound shape', () => {
|
|
1554
|
+
it('should not snap to arrows', () => {
|
|
1555
|
+
// 100 200
|
|
1556
|
+
// ┌───────────────────┐
|
|
1557
|
+
// │ ┌───┐ ┌───┐ │
|
|
1558
|
+
// │ │ A │ ---> │ B │ │
|
|
1559
|
+
// │ └───┘ └───┘ │
|
|
1560
|
+
// └───────────────────┘
|
|
1561
|
+
editor.createShapes([box(ids.box1, 0, 0, 100, 100), box(ids.box2, 200, 0, 100, 100)])
|
|
1562
|
+
|
|
1563
|
+
// Create an arrow starting within the first box and ending within the second box
|
|
1564
|
+
editor.setCurrentTool('arrow').pointerDown(50, 50).pointerMove(250, 50).pointerUp()
|
|
1565
|
+
|
|
1566
|
+
// 100 200
|
|
1567
|
+
// ┌───────────────────┐
|
|
1568
|
+
// │ ┌───┐ │
|
|
1569
|
+
// │ , │ B │ │
|
|
1570
|
+
// │ ┌───┐ └───┘ │
|
|
1571
|
+
// | │ A │ |
|
|
1572
|
+
// | └───┘ |
|
|
1573
|
+
// └───────────────────┘
|
|
1574
|
+
|
|
1575
|
+
expect(editor.getShape(editor.getSelectedShapeIds()[0])?.type).toBe('arrow')
|
|
1576
|
+
|
|
1577
|
+
editor.pointerDown(50, 50, ids.box1).pointerMove(84, 110, { ctrlKey: true })
|
|
1578
|
+
|
|
1579
|
+
expect(editor.snaps.getLines().length).toBe(0)
|
|
1580
|
+
})
|
|
1581
|
+
|
|
1582
|
+
it('should preserve arrow bindings', () => {
|
|
1583
|
+
const arrow1 = createShapeId('arrow1')
|
|
1584
|
+
editor.createShapes([
|
|
1585
|
+
{ id: ids.box1, type: 'geo', x: 100, y: 100, props: { w: 100, h: 100 } },
|
|
1586
|
+
{ id: ids.box2, type: 'geo', x: 300, y: 300, props: { w: 100, h: 100 } },
|
|
1587
|
+
{
|
|
1588
|
+
id: arrow1,
|
|
1589
|
+
type: 'arrow',
|
|
1590
|
+
x: 150,
|
|
1591
|
+
y: 150,
|
|
1592
|
+
props: {
|
|
1593
|
+
start: {
|
|
1594
|
+
type: 'binding',
|
|
1595
|
+
isExact: false,
|
|
1596
|
+
boundShapeId: ids.box1,
|
|
1597
|
+
normalizedAnchor: { x: 0.5, y: 0.5 },
|
|
1598
|
+
isPrecise: false,
|
|
1599
|
+
},
|
|
1600
|
+
end: {
|
|
1601
|
+
type: 'binding',
|
|
1602
|
+
isExact: false,
|
|
1603
|
+
boundShapeId: ids.box2,
|
|
1604
|
+
normalizedAnchor: { x: 0.5, y: 0.5 },
|
|
1605
|
+
isPrecise: false,
|
|
1606
|
+
},
|
|
1607
|
+
},
|
|
1608
|
+
},
|
|
1609
|
+
])
|
|
1610
|
+
|
|
1611
|
+
editor.select(ids.box1, arrow1)
|
|
1612
|
+
editor.pointerDown(150, 150, ids.box1).pointerMove(0, 0)
|
|
1613
|
+
|
|
1614
|
+
expect(editor.getShape(ids.box1)).toMatchObject({ x: -50, y: -50 })
|
|
1615
|
+
expect(editor.getShape(arrow1)).toMatchObject({
|
|
1616
|
+
props: { start: { type: 'binding' }, end: { type: 'binding' } },
|
|
1617
|
+
})
|
|
1618
|
+
})
|
|
1619
|
+
|
|
1620
|
+
it('breaks arrow bindings when cloning', () => {
|
|
1621
|
+
const arrow1 = createShapeId('arrow1')
|
|
1622
|
+
editor.createShapes([
|
|
1623
|
+
{ id: ids.box1, type: 'geo', x: 100, y: 100, props: { w: 100, h: 100 } },
|
|
1624
|
+
{ id: ids.box2, type: 'geo', x: 300, y: 300, props: { w: 100, h: 100 } },
|
|
1625
|
+
{
|
|
1626
|
+
id: arrow1,
|
|
1627
|
+
type: 'arrow',
|
|
1628
|
+
x: 150,
|
|
1629
|
+
y: 150,
|
|
1630
|
+
props: {
|
|
1631
|
+
start: {
|
|
1632
|
+
type: 'binding',
|
|
1633
|
+
isExact: false,
|
|
1634
|
+
boundShapeId: ids.box1,
|
|
1635
|
+
normalizedAnchor: { x: 0.5, y: 0.5 },
|
|
1636
|
+
isPrecise: false,
|
|
1637
|
+
},
|
|
1638
|
+
end: {
|
|
1639
|
+
type: 'binding',
|
|
1640
|
+
isExact: false,
|
|
1641
|
+
boundShapeId: ids.box2,
|
|
1642
|
+
normalizedAnchor: { x: 0.5, y: 0.5 },
|
|
1643
|
+
isPrecise: false,
|
|
1644
|
+
},
|
|
1645
|
+
},
|
|
1646
|
+
},
|
|
1647
|
+
])
|
|
1648
|
+
|
|
1649
|
+
editor.select(ids.box1, arrow1)
|
|
1650
|
+
editor.pointerDown(150, 150, ids.box1).pointerMove(0, 0, { altKey: true })
|
|
1651
|
+
|
|
1652
|
+
expect(editor.getShape(ids.box1)).toMatchObject({ x: 100, y: 100 })
|
|
1653
|
+
expect(editor.getShape(arrow1)).toMatchObject({
|
|
1654
|
+
props: { start: { type: 'binding' }, end: { type: 'binding' } },
|
|
1655
|
+
})
|
|
1656
|
+
|
|
1657
|
+
const newArrow = editor
|
|
1658
|
+
.getCurrentPageShapes()
|
|
1659
|
+
.find((s) => editor.isShapeOfType<TLArrowShape>(s, 'arrow') && s.id !== arrow1)
|
|
1660
|
+
expect(newArrow).toMatchObject({
|
|
1661
|
+
props: { start: { type: 'binding' }, end: { type: 'point' } },
|
|
1662
|
+
})
|
|
1663
|
+
})
|
|
1664
|
+
})
|
|
1665
|
+
|
|
1666
|
+
describe('When dragging a shape onto a parent', () => {
|
|
1667
|
+
it('reparents the shape', () => {
|
|
1668
|
+
editor.createShapes([
|
|
1669
|
+
{
|
|
1670
|
+
id: ids.frame1,
|
|
1671
|
+
type: 'frame',
|
|
1672
|
+
x: 0,
|
|
1673
|
+
y: 0,
|
|
1674
|
+
props: {
|
|
1675
|
+
w: 200,
|
|
1676
|
+
h: 200,
|
|
1677
|
+
},
|
|
1678
|
+
},
|
|
1679
|
+
{
|
|
1680
|
+
id: ids.box1,
|
|
1681
|
+
type: 'geo',
|
|
1682
|
+
x: 500,
|
|
1683
|
+
y: 500,
|
|
1684
|
+
props: {
|
|
1685
|
+
w: 100,
|
|
1686
|
+
h: 100,
|
|
1687
|
+
},
|
|
1688
|
+
},
|
|
1689
|
+
])
|
|
1690
|
+
|
|
1691
|
+
editor.pointerDown(550, 550, ids.box1).pointerMove(100, 100).pointerUp()
|
|
1692
|
+
expect(editor.getShape(ids.box1)?.parentId).toBe(ids.frame1)
|
|
1693
|
+
})
|
|
1694
|
+
|
|
1695
|
+
it('does not reparent the shape when the parent is clipped', () => {
|
|
1696
|
+
editor.createShapes([
|
|
1697
|
+
{
|
|
1698
|
+
id: ids.frame1,
|
|
1699
|
+
type: 'frame',
|
|
1700
|
+
x: 0,
|
|
1701
|
+
y: 0,
|
|
1702
|
+
props: {
|
|
1703
|
+
w: 200,
|
|
1704
|
+
h: 200,
|
|
1705
|
+
},
|
|
1706
|
+
},
|
|
1707
|
+
{
|
|
1708
|
+
id: ids.frame2,
|
|
1709
|
+
type: 'frame',
|
|
1710
|
+
x: 200,
|
|
1711
|
+
y: 200,
|
|
1712
|
+
props: {
|
|
1713
|
+
w: 500,
|
|
1714
|
+
h: 500,
|
|
1715
|
+
},
|
|
1716
|
+
},
|
|
1717
|
+
{
|
|
1718
|
+
id: ids.box1,
|
|
1719
|
+
type: 'geo',
|
|
1720
|
+
x: 500,
|
|
1721
|
+
y: 500,
|
|
1722
|
+
props: {
|
|
1723
|
+
w: 100,
|
|
1724
|
+
h: 100,
|
|
1725
|
+
},
|
|
1726
|
+
},
|
|
1727
|
+
])
|
|
1728
|
+
|
|
1729
|
+
// drop the frame2 onto frame 1
|
|
1730
|
+
editor.reparentShapes([ids.frame2], ids.frame1)
|
|
1731
|
+
expect(editor.getShape(ids.frame2)?.parentId).toBe(ids.frame1)
|
|
1732
|
+
|
|
1733
|
+
// drop box1 onto the CLIPPED part of frame2
|
|
1734
|
+
editor.pointerDown(550, 550, ids.box1).pointerMove(350, 350).pointerUp()
|
|
1735
|
+
|
|
1736
|
+
// It should not become the child of frame2 because it is clipped
|
|
1737
|
+
expect(editor.getShape(ids.box1)?.parentId).toBe(editor.getCurrentPageId())
|
|
1738
|
+
})
|
|
1739
|
+
})
|
|
1740
|
+
|
|
1741
|
+
describe('When dragging shapes', () => {
|
|
1742
|
+
it('should drag and undo and redo', () => {
|
|
1743
|
+
editor.deleteShapes(editor.getCurrentPageShapes())
|
|
1744
|
+
|
|
1745
|
+
editor.setCurrentTool('arrow').pointerMove(0, 0).pointerDown().pointerMove(100, 100).pointerUp()
|
|
1746
|
+
|
|
1747
|
+
editor.expectShapeToMatch({
|
|
1748
|
+
id: editor.getCurrentPageShapes()[0]!.id,
|
|
1749
|
+
x: 0,
|
|
1750
|
+
y: 0,
|
|
1751
|
+
})
|
|
1752
|
+
|
|
1753
|
+
editor.setCurrentTool('geo').pointerMove(-10, 100).pointerDown().pointerUp()
|
|
1754
|
+
|
|
1755
|
+
editor.expectShapeToMatch({
|
|
1756
|
+
id: editor.getCurrentPageShapes()[1]!.id,
|
|
1757
|
+
x: -110,
|
|
1758
|
+
y: 0,
|
|
1759
|
+
})
|
|
1760
|
+
|
|
1761
|
+
editor
|
|
1762
|
+
.selectAll()
|
|
1763
|
+
.pointerMove(50, 50)
|
|
1764
|
+
.pointerDown()
|
|
1765
|
+
.pointerMove(100, 50)
|
|
1766
|
+
.pointerUp()
|
|
1767
|
+
.expectShapeToMatch({
|
|
1768
|
+
id: editor.getCurrentPageShapes()[0]!.id,
|
|
1769
|
+
x: 50, // 50 to the right
|
|
1770
|
+
y: 0,
|
|
1771
|
+
})
|
|
1772
|
+
.expectShapeToMatch({
|
|
1773
|
+
id: editor.getCurrentPageShapes()[1]!.id,
|
|
1774
|
+
x: -60, // 50 to the right
|
|
1775
|
+
y: 0,
|
|
1776
|
+
})
|
|
1777
|
+
|
|
1778
|
+
editor
|
|
1779
|
+
.undo()
|
|
1780
|
+
.expectShapeToMatch({
|
|
1781
|
+
id: editor.getCurrentPageShapes()[0]!.id,
|
|
1782
|
+
x: 0, // 50 to the right
|
|
1783
|
+
y: 0,
|
|
1784
|
+
})
|
|
1785
|
+
.expectShapeToMatch({
|
|
1786
|
+
id: editor.getCurrentPageShapes()[1]!.id,
|
|
1787
|
+
x: -110, // 50 to the right
|
|
1788
|
+
y: 0,
|
|
1789
|
+
})
|
|
1790
|
+
})
|
|
1791
|
+
})
|
|
1792
|
+
|
|
1793
|
+
it('clones a single shape simply', () => {
|
|
1794
|
+
editor
|
|
1795
|
+
// create a note shape
|
|
1796
|
+
.setCurrentTool('note')
|
|
1797
|
+
.pointerMove(50, 50)
|
|
1798
|
+
.click()
|
|
1799
|
+
|
|
1800
|
+
expect(editor.getOnlySelectedShape()).toBe(editor.getCurrentPageShapes()[0])
|
|
1801
|
+
expect(editor.getHoveredShape()).toBe(editor.getCurrentPageShapes()[0])
|
|
1802
|
+
|
|
1803
|
+
// click on the canvas to deselect
|
|
1804
|
+
editor.pointerMove(200, 50).click()
|
|
1805
|
+
|
|
1806
|
+
expect(editor.getOnlySelectedShape()).toBe(null)
|
|
1807
|
+
expect(editor.getHoveredShape()).toBe(undefined)
|
|
1808
|
+
|
|
1809
|
+
// move back over the the shape
|
|
1810
|
+
editor.pointerMove(50, 50)
|
|
1811
|
+
|
|
1812
|
+
expect(editor.getOnlySelectedShape()).toBe(null)
|
|
1813
|
+
expect(editor.getHoveredShape()).toBe(editor.getCurrentPageShapes()[0])
|
|
1814
|
+
|
|
1815
|
+
// start dragging the shape
|
|
1816
|
+
editor
|
|
1817
|
+
.pointerDown()
|
|
1818
|
+
.pointerMove(50, 500)
|
|
1819
|
+
// start cloning
|
|
1820
|
+
.keyDown('Alt')
|
|
1821
|
+
// stop dragging
|
|
1822
|
+
.pointerUp()
|
|
1823
|
+
|
|
1824
|
+
expect(editor.getCurrentPageShapes()).toHaveLength(2)
|
|
1825
|
+
const [, sticky2] = editor.getCurrentPageShapes()
|
|
1826
|
+
expect(editor.getOnlySelectedShape()).toBe(sticky2)
|
|
1827
|
+
expect(editor.getEditingShape()).toBe(undefined)
|
|
1828
|
+
expect(editor.getHoveredShape()).toBe(sticky2)
|
|
1829
|
+
})
|