tldraw 4.3.0-canary.d8da2a99f394 → 4.3.0-canary.e1766dd4eab3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-cjs/index.d.ts +26 -5
- package/dist-cjs/index.js +2 -1
- package/dist-cjs/index.js.map +2 -2
- package/dist-cjs/lib/bindings/arrow/ArrowBindingUtil.js.map +2 -2
- package/dist-cjs/lib/canvas/TldrawSelectionForeground.js +2 -2
- package/dist-cjs/lib/canvas/TldrawSelectionForeground.js.map +2 -2
- package/dist-cjs/lib/defaultExternalContentHandlers.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js +9 -12
- package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/arrow-types.js.map +1 -1
- package/dist-cjs/lib/shapes/arrow/arrowLabel.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/arrowTargetState.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/elbow/elbowArrowSnapLines.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/shared.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/shapes/bookmark/bookmarks.js.map +2 -2
- package/dist-cjs/lib/shapes/draw/DrawShapeUtil.js +3 -3
- package/dist-cjs/lib/shapes/draw/DrawShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/draw/toolStates/Drawing.js.map +2 -2
- package/dist-cjs/lib/shapes/embed/EmbedShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/frame/FrameShapeTool.js.map +1 -1
- package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js +1 -1
- package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/geo/GeoShapeUtil.js +10 -6
- package/dist-cjs/lib/shapes/geo/GeoShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/geo/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/shapes/highlight/HighlightShapeUtil.js +1 -1
- package/dist-cjs/lib/shapes/highlight/HighlightShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/line/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/shapes/note/NoteShapeUtil.js +5 -5
- package/dist-cjs/lib/shapes/note/NoteShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/note/noteHelpers.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/HyperlinkButton.js +2 -1
- package/dist-cjs/lib/shapes/shared/HyperlinkButton.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/PlainTextLabel.js +14 -2
- package/dist-cjs/lib/shapes/shared/PlainTextLabel.js.map +3 -3
- package/dist-cjs/lib/shapes/shared/RichTextLabel.js +11 -3
- package/dist-cjs/lib/shapes/shared/RichTextLabel.js.map +3 -3
- package/dist-cjs/lib/shapes/shared/ShapeFill.js +2 -2
- package/dist-cjs/lib/shapes/shared/ShapeFill.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/crop.js +1 -0
- package/dist-cjs/lib/shapes/shared/crop.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/useEditablePlainText.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/useEditableRichText.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/{useForceSolid.js → useEfficientZoomThreshold.js} +10 -7
- package/dist-cjs/lib/shapes/shared/useEfficientZoomThreshold.js.map +7 -0
- package/dist-cjs/lib/shapes/shared/useImageOrVideoAsset.js +1 -1
- package/dist-cjs/lib/shapes/shared/useImageOrVideoAsset.js.map +2 -2
- package/dist-cjs/lib/shapes/text/TextShapeUtil.js +5 -2
- package/dist-cjs/lib/shapes/text/TextShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/text/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/shapes/video/VideoShapeUtil.js +1 -1
- package/dist-cjs/lib/shapes/video/VideoShapeUtil.js.map +2 -2
- package/dist-cjs/lib/tools/EraserTool/childStates/Erasing.js.map +2 -2
- package/dist-cjs/lib/tools/EraserTool/childStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/DragAndDropManager.js +1 -4
- package/dist-cjs/lib/tools/SelectTool/DragAndDropManager.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Brushing.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/Idle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js +1 -1
- package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/EditingShape.js +30 -10
- package/dist-cjs/lib/tools/SelectTool/childStates/EditingShape.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Idle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingArrowLabel.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingHandle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingSelection.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/ScribbleBrushing.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js.map +2 -2
- package/dist-cjs/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.js +3 -9
- package/dist-cjs/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.js.map +2 -2
- package/dist-cjs/lib/ui/components/EditLinkDialog.js +11 -1
- package/dist-cjs/lib/ui/components/EditLinkDialog.js.map +2 -2
- package/dist-cjs/lib/ui/components/Toolbar/AltTextEditor.js.map +2 -2
- package/dist-cjs/lib/ui/components/ZoomMenu/DefaultZoomMenu.js +1 -1
- package/dist-cjs/lib/ui/components/ZoomMenu/DefaultZoomMenu.js.map +2 -2
- package/dist-cjs/lib/ui/components/menu-items.js +3 -1
- package/dist-cjs/lib/ui/components/menu-items.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiSlider.js +1 -1
- package/dist-cjs/lib/ui/components/primitives/TldrawUiSlider.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js +143 -88
- package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js +1 -1
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js.map +2 -2
- package/dist-cjs/lib/ui/context/actions.js +1 -2
- package/dist-cjs/lib/ui/context/actions.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/menu-hooks.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/useFlatten.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/useTools.js.map +2 -2
- package/dist-cjs/lib/ui/version.js +3 -3
- package/dist-cjs/lib/ui/version.js.map +1 -1
- package/dist-cjs/lib/utils/excalidraw/putExcalidrawContent.js +8 -0
- package/dist-cjs/lib/utils/excalidraw/putExcalidrawContent.js.map +2 -2
- package/dist-cjs/lib/utils/export/exportAs.js.map +2 -2
- package/dist-cjs/lib/utils/frames/frames.js.map +2 -2
- package/dist-cjs/lib/utils/text/richText.js +7 -17
- package/dist-cjs/lib/utils/text/richText.js.map +3 -3
- package/dist-cjs/lib/utils/tldr/buildFromV1Document.js.map +2 -2
- package/dist-esm/index.d.mts +26 -5
- package/dist-esm/index.mjs +3 -1
- package/dist-esm/index.mjs.map +2 -2
- package/dist-esm/lib/bindings/arrow/ArrowBindingUtil.mjs.map +2 -2
- package/dist-esm/lib/canvas/TldrawSelectionForeground.mjs +2 -2
- package/dist-esm/lib/canvas/TldrawSelectionForeground.mjs.map +2 -2
- package/dist-esm/lib/defaultExternalContentHandlers.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs +10 -14
- package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/arrowLabel.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/arrowTargetState.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/elbow/elbowArrowSnapLines.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/shared.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/shapes/bookmark/bookmarks.mjs.map +2 -2
- package/dist-esm/lib/shapes/draw/DrawShapeUtil.mjs +3 -3
- package/dist-esm/lib/shapes/draw/DrawShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/draw/toolStates/Drawing.mjs.map +2 -2
- package/dist-esm/lib/shapes/embed/EmbedShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/frame/FrameShapeTool.mjs.map +1 -1
- package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs +1 -1
- package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/geo/GeoShapeUtil.mjs +10 -6
- package/dist-esm/lib/shapes/geo/GeoShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/geo/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/shapes/highlight/HighlightShapeUtil.mjs +1 -1
- package/dist-esm/lib/shapes/highlight/HighlightShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/line/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs +5 -5
- package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/note/noteHelpers.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/HyperlinkButton.mjs +3 -2
- package/dist-esm/lib/shapes/shared/HyperlinkButton.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/PlainTextLabel.mjs +14 -2
- package/dist-esm/lib/shapes/shared/PlainTextLabel.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/RichTextLabel.mjs +11 -3
- package/dist-esm/lib/shapes/shared/RichTextLabel.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/ShapeFill.mjs +2 -2
- package/dist-esm/lib/shapes/shared/ShapeFill.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/crop.mjs +1 -0
- package/dist-esm/lib/shapes/shared/crop.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/useEditablePlainText.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/useEditableRichText.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/useEfficientZoomThreshold.mjs +12 -0
- package/dist-esm/lib/shapes/shared/useEfficientZoomThreshold.mjs.map +7 -0
- package/dist-esm/lib/shapes/shared/useImageOrVideoAsset.mjs +1 -1
- package/dist-esm/lib/shapes/shared/useImageOrVideoAsset.mjs.map +2 -2
- package/dist-esm/lib/shapes/text/TextShapeUtil.mjs +5 -2
- package/dist-esm/lib/shapes/text/TextShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/text/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/shapes/video/VideoShapeUtil.mjs +1 -1
- package/dist-esm/lib/shapes/video/VideoShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/tools/EraserTool/childStates/Erasing.mjs.map +2 -2
- package/dist-esm/lib/tools/EraserTool/childStates/Pointing.mjs +1 -4
- package/dist-esm/lib/tools/EraserTool/childStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/DragAndDropManager.mjs +1 -4
- package/dist-esm/lib/tools/SelectTool/DragAndDropManager.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Brushing.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/Idle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs +1 -1
- package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/EditingShape.mjs +30 -10
- package/dist-esm/lib/tools/SelectTool/childStates/EditingShape.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Idle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingArrowLabel.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingHandle.mjs +1 -4
- package/dist-esm/lib/tools/SelectTool/childStates/PointingHandle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingSelection.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/ScribbleBrushing.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs.map +2 -2
- package/dist-esm/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.mjs +2 -8
- package/dist-esm/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.mjs.map +2 -2
- package/dist-esm/lib/ui/components/EditLinkDialog.mjs +11 -1
- package/dist-esm/lib/ui/components/EditLinkDialog.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Toolbar/AltTextEditor.mjs.map +2 -2
- package/dist-esm/lib/ui/components/ZoomMenu/DefaultZoomMenu.mjs +1 -1
- package/dist-esm/lib/ui/components/ZoomMenu/DefaultZoomMenu.mjs.map +2 -2
- package/dist-esm/lib/ui/components/menu-items.mjs +4 -5
- package/dist-esm/lib/ui/components/menu-items.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiSlider.mjs +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiSlider.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs +151 -90
- package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs +2 -2
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs.map +2 -2
- package/dist-esm/lib/ui/context/actions.mjs +1 -2
- package/dist-esm/lib/ui/context/actions.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/menu-hooks.mjs +1 -4
- package/dist-esm/lib/ui/hooks/menu-hooks.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/useFlatten.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/useTools.mjs.map +2 -2
- package/dist-esm/lib/ui/version.mjs +3 -3
- package/dist-esm/lib/ui/version.mjs.map +1 -1
- package/dist-esm/lib/utils/excalidraw/putExcalidrawContent.mjs +8 -0
- package/dist-esm/lib/utils/excalidraw/putExcalidrawContent.mjs.map +2 -2
- package/dist-esm/lib/utils/export/exportAs.mjs +1 -3
- package/dist-esm/lib/utils/export/exportAs.mjs.map +2 -2
- package/dist-esm/lib/utils/frames/frames.mjs.map +2 -2
- package/dist-esm/lib/utils/text/richText.mjs +3 -3
- package/dist-esm/lib/utils/text/richText.mjs.map +2 -2
- package/dist-esm/lib/utils/tldr/buildFromV1Document.mjs.map +2 -2
- package/package.json +10 -10
- package/src/index.ts +1 -0
- package/src/lib/bindings/arrow/ArrowBindingUtil.ts +1 -1
- package/src/lib/canvas/TldrawSelectionForeground.tsx +6 -11
- package/src/lib/defaultExternalContentHandlers.ts +3 -4
- package/src/lib/shapes/arrow/ArrowShapeUtil.test.ts +2 -2
- package/src/lib/shapes/arrow/ArrowShapeUtil.tsx +11 -13
- package/src/lib/shapes/arrow/arrow-types.ts +2 -0
- package/src/lib/shapes/arrow/arrowLabel.ts +1 -1
- package/src/lib/shapes/arrow/arrowTargetState.ts +1 -1
- package/src/lib/shapes/arrow/elbow/elbowArrowSnapLines.tsx +3 -3
- package/src/lib/shapes/arrow/shared.ts +4 -4
- package/src/lib/shapes/arrow/toolStates/Pointing.tsx +1 -1
- package/src/lib/shapes/bookmark/bookmarks.ts +3 -3
- package/src/lib/shapes/draw/DrawShapeUtil.tsx +3 -3
- package/src/lib/shapes/draw/toolStates/Drawing.ts +4 -4
- package/src/lib/shapes/embed/EmbedShapeUtil.tsx +1 -1
- package/src/lib/shapes/frame/FrameShapeTool.ts +1 -1
- package/src/lib/shapes/frame/FrameShapeUtil.tsx +1 -1
- package/src/lib/shapes/geo/GeoShapeUtil.test.tsx +10 -2
- package/src/lib/shapes/geo/GeoShapeUtil.tsx +9 -4
- package/src/lib/shapes/geo/toolStates/Pointing.ts +3 -3
- package/src/lib/shapes/highlight/HighlightShapeUtil.tsx +1 -1
- package/src/lib/shapes/line/LineShapeTool.test.ts +6 -6
- package/src/lib/shapes/line/LineShapeUtil.test.tsx +5 -5
- package/src/lib/shapes/line/toolStates/Pointing.ts +1 -1
- package/src/lib/shapes/note/NoteShapeTool.test.ts +2 -1
- package/src/lib/shapes/note/NoteShapeUtil.tsx +7 -8
- package/src/lib/shapes/note/noteHelpers.ts +2 -2
- package/src/lib/shapes/shared/HyperlinkButton.tsx +3 -2
- package/src/lib/shapes/shared/PlainTextLabel.tsx +12 -2
- package/src/lib/shapes/shared/RichTextLabel.tsx +13 -3
- package/src/lib/shapes/shared/ShapeFill.tsx +2 -2
- package/src/lib/shapes/shared/crop.ts +1 -0
- package/src/lib/shapes/shared/useEditablePlainText.ts +7 -3
- package/src/lib/shapes/shared/useEditableRichText.ts +7 -3
- package/src/lib/shapes/shared/useEfficientZoomThreshold.ts +10 -0
- package/src/lib/shapes/shared/useImageOrVideoAsset.ts +1 -1
- package/src/lib/shapes/text/TextShapeTool.test.ts +4 -4
- package/src/lib/shapes/text/TextShapeUtil.tsx +5 -0
- package/src/lib/shapes/text/toolStates/Pointing.ts +1 -1
- package/src/lib/shapes/video/VideoShapeUtil.tsx +2 -1
- package/src/lib/tools/EraserTool/childStates/Erasing.ts +3 -5
- package/src/lib/tools/EraserTool/childStates/Pointing.ts +3 -16
- package/src/lib/tools/SelectTool/DragAndDropManager.ts +2 -4
- package/src/lib/tools/SelectTool/childStates/Brushing.ts +2 -6
- package/src/lib/tools/SelectTool/childStates/Crop/children/Idle.ts +2 -3
- package/src/lib/tools/SelectTool/childStates/DraggingHandle.tsx +4 -7
- package/src/lib/tools/SelectTool/childStates/EditingShape.ts +46 -15
- package/src/lib/tools/SelectTool/childStates/Idle.ts +6 -10
- package/src/lib/tools/SelectTool/childStates/PointingArrowLabel.ts +1 -1
- package/src/lib/tools/SelectTool/childStates/PointingHandle.ts +4 -12
- package/src/lib/tools/SelectTool/childStates/PointingSelection.ts +2 -2
- package/src/lib/tools/SelectTool/childStates/Resizing.ts +2 -4
- package/src/lib/tools/SelectTool/childStates/ScribbleBrushing.ts +2 -4
- package/src/lib/tools/SelectTool/childStates/Translating.ts +1 -3
- package/src/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.tsx +1 -9
- package/src/lib/ui/components/EditLinkDialog.tsx +16 -6
- package/src/lib/ui/components/Toolbar/AltTextEditor.tsx +2 -2
- package/src/lib/ui/components/ZoomMenu/DefaultZoomMenu.tsx +1 -1
- package/src/lib/ui/components/menu-items.tsx +9 -15
- package/src/lib/ui/components/primitives/TldrawUiSlider.tsx +2 -2
- package/src/lib/ui/components/primitives/TldrawUiTooltip.tsx +196 -108
- package/src/lib/ui/components/primitives/menus/TldrawUiMenuItem.tsx +2 -2
- package/src/lib/ui/context/actions.tsx +9 -13
- package/src/lib/ui/hooks/menu-hooks.ts +9 -19
- package/src/lib/ui/hooks/useFlatten.ts +1 -2
- package/src/lib/ui/hooks/useTools.tsx +1 -2
- package/src/lib/ui/version.ts +3 -3
- package/src/lib/utils/excalidraw/putExcalidrawContent.ts +8 -0
- package/src/lib/utils/export/exportAs.ts +2 -9
- package/src/lib/utils/frames/frames.ts +1 -1
- package/src/lib/utils/text/richText.ts +3 -3
- package/src/lib/utils/tldr/buildFromV1Document.ts +12 -17
- package/src/test/Editor.test.tsx +38 -12
- package/src/test/SelectTool.test.ts +11 -19
- package/src/test/TestEditor.ts +1 -4
- package/src/test/TldrawEditor.test.tsx +21 -18
- package/src/test/bindings.test.tsx +29 -25
- package/src/test/bindingsIndex.test.tsx +4 -4
- package/src/test/commands/__snapshots__/getSvgString.test.ts.snap +2 -2
- package/src/test/commands/cameraState.test.ts +299 -0
- package/src/test/commands/createShape.test.ts +64 -0
- package/src/test/commands/createShapes.test.ts +15 -1
- package/src/test/commands/getSvgString.test.ts +2 -2
- package/src/test/commands/isShapeOfType.test.ts +44 -0
- package/src/test/commands/putContent.test.ts +80 -1
- package/src/test/commands/updateShape.test.ts +67 -0
- package/src/test/commands/updateShapes.test.ts +21 -5
- package/src/test/custom-clipping.test.ts +36 -35
- package/src/test/customSnapping.test.tsx +77 -62
- package/src/test/duplicate.test.ts +1 -1
- package/src/test/frames.test.ts +2 -2
- package/src/test/getCulledShapes.test.tsx +11 -3
- package/src/test/getShapeAtPoint.test.ts +2 -2
- package/src/test/groups.test.tsx +6 -3
- package/src/test/resizing.test.ts +9 -13
- package/src/test/selection-omnibus.test.ts +11 -11
- package/src/test/shapeutils.test.ts +1 -1
- package/src/test/styles2.test.tsx +1 -1
- package/src/test/styles3.test.ts +5 -5
- package/src/test/test-jsx.tsx +69 -57
- package/src/test/text.test.ts +15 -17
- package/src/test/translating.test.ts +6 -8
- package/tldraw.css +8 -4
- package/dist-cjs/lib/shapes/shared/useForceSolid.js.map +0 -7
- package/dist-esm/lib/shapes/shared/useForceSolid.mjs +0 -9
- package/dist-esm/lib/shapes/shared/useForceSolid.mjs.map +0 -7
- package/src/lib/shapes/shared/useForceSolid.ts +0 -6
|
@@ -4,7 +4,6 @@ import {
|
|
|
4
4
|
Editor,
|
|
5
5
|
GeoShapeGeoStyle,
|
|
6
6
|
getIndicesBetween,
|
|
7
|
-
TLLineShape,
|
|
8
7
|
TLPointerEventInfo,
|
|
9
8
|
TLShapeId,
|
|
10
9
|
toRichText,
|
|
@@ -195,7 +194,7 @@ export function ToolsProvider({ overrides, children }: TLUiToolsProviderProps) {
|
|
|
195
194
|
onDragFromToolbarToCreateShape(editor, info, {
|
|
196
195
|
createShape: (id) => {
|
|
197
196
|
const [start, end] = getIndicesBetween(null, null, 2)
|
|
198
|
-
editor.createShape
|
|
197
|
+
editor.createShape({
|
|
199
198
|
id,
|
|
200
199
|
type: 'line',
|
|
201
200
|
props: {
|
package/src/lib/ui/version.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// This file is automatically generated by internal/scripts/refresh-assets.ts.
|
|
2
2
|
// Do not edit manually. Or do, I'm a comment, not a cop.
|
|
3
3
|
|
|
4
|
-
export const version = '4.3.0-canary.
|
|
4
|
+
export const version = '4.3.0-canary.e1766dd4eab3'
|
|
5
5
|
export const publishDates = {
|
|
6
6
|
major: '2025-09-18T14:39:22.803Z',
|
|
7
|
-
minor: '2025-
|
|
8
|
-
patch: '2025-
|
|
7
|
+
minor: '2025-12-09T14:08:32.660Z',
|
|
8
|
+
patch: '2025-12-09T14:08:32.660Z',
|
|
9
9
|
}
|
|
@@ -133,6 +133,7 @@ export async function putExcalidrawContent(
|
|
|
133
133
|
...base,
|
|
134
134
|
type: 'geo',
|
|
135
135
|
props: {
|
|
136
|
+
...editor.getShapeUtil('geo').getDefaultProps(),
|
|
136
137
|
geo: element.type,
|
|
137
138
|
url: element.link ?? '',
|
|
138
139
|
w: element.width,
|
|
@@ -152,6 +153,7 @@ export async function putExcalidrawContent(
|
|
|
152
153
|
...base,
|
|
153
154
|
type: 'draw',
|
|
154
155
|
props: {
|
|
156
|
+
...editor.getShapeUtil('draw').getDefaultProps(),
|
|
155
157
|
dash: getDash(element),
|
|
156
158
|
size: strokeWidthsToSizes[element.strokeWidth],
|
|
157
159
|
color: colorsToColors[element.strokeColor] ?? 'black',
|
|
@@ -180,6 +182,7 @@ export async function putExcalidrawContent(
|
|
|
180
182
|
...base,
|
|
181
183
|
type: 'line',
|
|
182
184
|
props: {
|
|
185
|
+
...editor.getShapeUtil('line').getDefaultProps(),
|
|
183
186
|
dash: getDash(element),
|
|
184
187
|
size: strokeWidthsToSizes[element.strokeWidth],
|
|
185
188
|
color: colorsToColors[element.strokeColor] ?? 'black',
|
|
@@ -221,6 +224,7 @@ export async function putExcalidrawContent(
|
|
|
221
224
|
...base,
|
|
222
225
|
type: 'arrow',
|
|
223
226
|
props: {
|
|
227
|
+
...editor.getShapeUtil('arrow').getDefaultProps(),
|
|
224
228
|
richText: toRichText(text),
|
|
225
229
|
kind: element.elbowed ? 'elbow' : 'arc',
|
|
226
230
|
bend: getBend(element, start, end),
|
|
@@ -243,6 +247,7 @@ export async function putExcalidrawContent(
|
|
|
243
247
|
toId: startTargetId,
|
|
244
248
|
props: {
|
|
245
249
|
terminal: 'start',
|
|
250
|
+
snap: 'none',
|
|
246
251
|
normalizedAnchor: { x: 0.5, y: 0.5 },
|
|
247
252
|
isPrecise: false,
|
|
248
253
|
isExact: false,
|
|
@@ -259,6 +264,7 @@ export async function putExcalidrawContent(
|
|
|
259
264
|
toId: endTargetId,
|
|
260
265
|
props: {
|
|
261
266
|
terminal: 'end',
|
|
267
|
+
snap: 'none',
|
|
262
268
|
normalizedAnchor: { x: 0.5, y: 0.5 },
|
|
263
269
|
isPrecise: false,
|
|
264
270
|
isExact: false,
|
|
@@ -275,6 +281,7 @@ export async function putExcalidrawContent(
|
|
|
275
281
|
...base,
|
|
276
282
|
type: 'text',
|
|
277
283
|
props: {
|
|
284
|
+
...editor.getShapeUtil('text').getDefaultProps(),
|
|
278
285
|
size,
|
|
279
286
|
scale,
|
|
280
287
|
font: fontFamilyToFontType[element.fontFamily] ?? 'draw',
|
|
@@ -310,6 +317,7 @@ export async function putExcalidrawContent(
|
|
|
310
317
|
...base,
|
|
311
318
|
type: 'image',
|
|
312
319
|
props: {
|
|
320
|
+
...editor.getShapeUtil('image').getDefaultProps(),
|
|
313
321
|
w: element.width,
|
|
314
322
|
h: element.height,
|
|
315
323
|
assetId,
|
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Editor,
|
|
3
|
-
sanitizeId,
|
|
4
|
-
TLExportType,
|
|
5
|
-
TLFrameShape,
|
|
6
|
-
TLImageExportOptions,
|
|
7
|
-
TLShapeId,
|
|
8
|
-
} from '@tldraw/editor'
|
|
1
|
+
import { Editor, sanitizeId, TLExportType, TLImageExportOptions, TLShapeId } from '@tldraw/editor'
|
|
9
2
|
|
|
10
3
|
/** @public */
|
|
11
4
|
export interface ExportAsOptions extends TLImageExportOptions {
|
|
@@ -35,7 +28,7 @@ export async function exportAs(
|
|
|
35
28
|
name = `shapes at ${getTimestamp()}`
|
|
36
29
|
if (ids.length === 1) {
|
|
37
30
|
const first = editor.getShape(ids[0])!
|
|
38
|
-
if (editor.isShapeOfType
|
|
31
|
+
if (editor.isShapeOfType(first, 'frame')) {
|
|
39
32
|
name = first.props.name || 'frame'
|
|
40
33
|
} else {
|
|
41
34
|
name = `${sanitizeId(first.id)} at ${getTimestamp()}`
|
|
@@ -22,7 +22,7 @@ export function removeFrame(editor: Editor, ids: TLShapeId[]) {
|
|
|
22
22
|
const frames = compact(
|
|
23
23
|
ids
|
|
24
24
|
.map((id) => editor.getShape<TLFrameShape>(id))
|
|
25
|
-
.filter((f) => f && editor.isShapeOfType
|
|
25
|
+
.filter((f) => f && editor.isShapeOfType(f, 'frame'))
|
|
26
26
|
)
|
|
27
27
|
if (!frames.length) return
|
|
28
28
|
|
|
@@ -6,10 +6,10 @@ import {
|
|
|
6
6
|
generateText,
|
|
7
7
|
JSONContent,
|
|
8
8
|
} from '@tiptap/core'
|
|
9
|
-
import Code from '@tiptap/extension-code'
|
|
10
|
-
import Highlight from '@tiptap/extension-highlight'
|
|
9
|
+
import { Code } from '@tiptap/extension-code'
|
|
10
|
+
import { Highlight } from '@tiptap/extension-highlight'
|
|
11
11
|
import { Node } from '@tiptap/pm/model'
|
|
12
|
-
import StarterKit from '@tiptap/starter-kit'
|
|
12
|
+
import { StarterKit } from '@tiptap/starter-kit'
|
|
13
13
|
import {
|
|
14
14
|
Editor,
|
|
15
15
|
getOwnProperty,
|
|
@@ -12,14 +12,9 @@ import {
|
|
|
12
12
|
TLDefaultHorizontalAlignStyle,
|
|
13
13
|
TLDefaultSizeStyle,
|
|
14
14
|
TLDefaultTextAlignStyle,
|
|
15
|
-
TLDrawShape,
|
|
16
15
|
TLGeoShape,
|
|
17
|
-
TLImageShape,
|
|
18
|
-
TLNoteShape,
|
|
19
16
|
TLPageId,
|
|
20
17
|
TLShapeId,
|
|
21
|
-
TLTextShape,
|
|
22
|
-
TLVideoShape,
|
|
23
18
|
Vec,
|
|
24
19
|
VecModel,
|
|
25
20
|
clamp,
|
|
@@ -187,7 +182,7 @@ export function buildFromV1Document(editor: Editor, _document: unknown) {
|
|
|
187
182
|
|
|
188
183
|
switch (v1Shape.type) {
|
|
189
184
|
case TLV1ShapeType.Sticky: {
|
|
190
|
-
editor.createShapes
|
|
185
|
+
editor.createShapes([
|
|
191
186
|
{
|
|
192
187
|
...inCommon,
|
|
193
188
|
type: 'note',
|
|
@@ -203,7 +198,7 @@ export function buildFromV1Document(editor: Editor, _document: unknown) {
|
|
|
203
198
|
break
|
|
204
199
|
}
|
|
205
200
|
case TLV1ShapeType.Rectangle: {
|
|
206
|
-
editor.createShapes
|
|
201
|
+
editor.createShapes([
|
|
207
202
|
{
|
|
208
203
|
...inCommon,
|
|
209
204
|
type: 'geo',
|
|
@@ -225,7 +220,7 @@ export function buildFromV1Document(editor: Editor, _document: unknown) {
|
|
|
225
220
|
|
|
226
221
|
const pageBoundsBeforeLabel = editor.getShapePageBounds(inCommon.id)!
|
|
227
222
|
|
|
228
|
-
editor.updateShapes
|
|
223
|
+
editor.updateShapes([
|
|
229
224
|
{
|
|
230
225
|
id: inCommon.id,
|
|
231
226
|
type: 'geo',
|
|
@@ -259,7 +254,7 @@ export function buildFromV1Document(editor: Editor, _document: unknown) {
|
|
|
259
254
|
break
|
|
260
255
|
}
|
|
261
256
|
case TLV1ShapeType.Triangle: {
|
|
262
|
-
editor.createShapes
|
|
257
|
+
editor.createShapes([
|
|
263
258
|
{
|
|
264
259
|
...inCommon,
|
|
265
260
|
type: 'geo',
|
|
@@ -280,7 +275,7 @@ export function buildFromV1Document(editor: Editor, _document: unknown) {
|
|
|
280
275
|
|
|
281
276
|
const pageBoundsBeforeLabel = editor.getShapePageBounds(inCommon.id)!
|
|
282
277
|
|
|
283
|
-
editor.updateShapes
|
|
278
|
+
editor.updateShapes([
|
|
284
279
|
{
|
|
285
280
|
id: inCommon.id,
|
|
286
281
|
type: 'geo',
|
|
@@ -314,7 +309,7 @@ export function buildFromV1Document(editor: Editor, _document: unknown) {
|
|
|
314
309
|
break
|
|
315
310
|
}
|
|
316
311
|
case TLV1ShapeType.Ellipse: {
|
|
317
|
-
editor.createShapes
|
|
312
|
+
editor.createShapes([
|
|
318
313
|
{
|
|
319
314
|
...inCommon,
|
|
320
315
|
type: 'geo',
|
|
@@ -335,7 +330,7 @@ export function buildFromV1Document(editor: Editor, _document: unknown) {
|
|
|
335
330
|
|
|
336
331
|
const pageBoundsBeforeLabel = editor.getShapePageBounds(inCommon.id)!
|
|
337
332
|
|
|
338
|
-
editor.updateShapes
|
|
333
|
+
editor.updateShapes([
|
|
339
334
|
{
|
|
340
335
|
id: inCommon.id,
|
|
341
336
|
type: 'geo',
|
|
@@ -375,7 +370,7 @@ export function buildFromV1Document(editor: Editor, _document: unknown) {
|
|
|
375
370
|
break
|
|
376
371
|
}
|
|
377
372
|
|
|
378
|
-
editor.createShapes
|
|
373
|
+
editor.createShapes([
|
|
379
374
|
{
|
|
380
375
|
...inCommon,
|
|
381
376
|
type: 'draw',
|
|
@@ -400,7 +395,7 @@ export function buildFromV1Document(editor: Editor, _document: unknown) {
|
|
|
400
395
|
const v2Bend = (dist * -v1Bend) / 2
|
|
401
396
|
|
|
402
397
|
// Could also be a line... but we'll use it as an arrow anyway
|
|
403
|
-
editor.createShapes
|
|
398
|
+
editor.createShapes([
|
|
404
399
|
{
|
|
405
400
|
...inCommon,
|
|
406
401
|
type: 'arrow',
|
|
@@ -429,7 +424,7 @@ export function buildFromV1Document(editor: Editor, _document: unknown) {
|
|
|
429
424
|
break
|
|
430
425
|
}
|
|
431
426
|
case TLV1ShapeType.Text: {
|
|
432
|
-
editor.createShapes
|
|
427
|
+
editor.createShapes([
|
|
433
428
|
{
|
|
434
429
|
...inCommon,
|
|
435
430
|
type: 'text',
|
|
@@ -453,7 +448,7 @@ export function buildFromV1Document(editor: Editor, _document: unknown) {
|
|
|
453
448
|
return
|
|
454
449
|
}
|
|
455
450
|
|
|
456
|
-
editor.createShapes
|
|
451
|
+
editor.createShapes([
|
|
457
452
|
{
|
|
458
453
|
...inCommon,
|
|
459
454
|
type: 'image',
|
|
@@ -474,7 +469,7 @@ export function buildFromV1Document(editor: Editor, _document: unknown) {
|
|
|
474
469
|
return
|
|
475
470
|
}
|
|
476
471
|
|
|
477
|
-
editor.createShapes
|
|
472
|
+
editor.createShapes([
|
|
478
473
|
{
|
|
479
474
|
...inCommon,
|
|
480
475
|
type: 'video',
|
package/src/test/Editor.test.tsx
CHANGED
|
@@ -472,12 +472,20 @@ describe('isFocused', () => {
|
|
|
472
472
|
})
|
|
473
473
|
})
|
|
474
474
|
|
|
475
|
+
const BLORG_TYPE = 'blorg'
|
|
476
|
+
|
|
477
|
+
declare module '@tldraw/tlschema' {
|
|
478
|
+
export interface TLGlobalShapePropsMap {
|
|
479
|
+
[BLORG_TYPE]: { w: number; h: number }
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
|
|
475
483
|
describe('getShapeUtil', () => {
|
|
476
484
|
let myUtil: any
|
|
477
485
|
|
|
478
486
|
beforeEach(() => {
|
|
479
487
|
class _MyFakeShapeUtil extends BaseBoxShapeUtil<any> {
|
|
480
|
-
static override type =
|
|
488
|
+
static override type = BLORG_TYPE
|
|
481
489
|
|
|
482
490
|
getDefaultProps() {
|
|
483
491
|
return {
|
|
@@ -519,16 +527,22 @@ describe('getShapeUtil', () => {
|
|
|
519
527
|
})
|
|
520
528
|
|
|
521
529
|
it('throws if that shape type isnt registered', () => {
|
|
522
|
-
const myMissingShape = { type: 'missing' }
|
|
523
|
-
expect(() =>
|
|
524
|
-
|
|
525
|
-
|
|
530
|
+
const myMissingShape = { type: 'missing' }
|
|
531
|
+
expect(() =>
|
|
532
|
+
editor.getShapeUtil(
|
|
533
|
+
// @ts-expect-error
|
|
534
|
+
myMissingShape
|
|
535
|
+
)
|
|
536
|
+
).toThrowErrorMatchingInlineSnapshot(`[Error: No shape util found for type "missing"]`)
|
|
526
537
|
})
|
|
527
538
|
|
|
528
539
|
it('throws if that type isnt registered', () => {
|
|
529
|
-
expect(() =>
|
|
530
|
-
|
|
531
|
-
|
|
540
|
+
expect(() =>
|
|
541
|
+
editor.getShapeUtil(
|
|
542
|
+
// @ts-expect-error
|
|
543
|
+
'missing'
|
|
544
|
+
)
|
|
545
|
+
).toThrowErrorMatchingInlineSnapshot(`[Error: No shape util found for type "missing"]`)
|
|
532
546
|
})
|
|
533
547
|
})
|
|
534
548
|
|
|
@@ -866,9 +880,19 @@ describe('instance.isReadonly', () => {
|
|
|
866
880
|
})
|
|
867
881
|
})
|
|
868
882
|
|
|
883
|
+
const MY_CUSTOM_SHAPE_TYPE = 'myCustomShape'
|
|
884
|
+
|
|
885
|
+
type MyCustomShape = TLShape<typeof MY_CUSTOM_SHAPE_TYPE>
|
|
886
|
+
|
|
887
|
+
declare module '@tldraw/tlschema' {
|
|
888
|
+
export interface TLGlobalShapePropsMap {
|
|
889
|
+
[MY_CUSTOM_SHAPE_TYPE]: { w: number; h: number }
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
|
|
869
893
|
describe('the geometry cache', () => {
|
|
870
|
-
class CustomShapeUtil extends BaseBoxShapeUtil<
|
|
871
|
-
static override type =
|
|
894
|
+
class CustomShapeUtil extends BaseBoxShapeUtil<MyCustomShape> {
|
|
895
|
+
static override type = MY_CUSTOM_SHAPE_TYPE
|
|
872
896
|
|
|
873
897
|
getDefaultProps() {
|
|
874
898
|
return {
|
|
@@ -894,9 +918,11 @@ describe('the geometry cache', () => {
|
|
|
894
918
|
editor = new TestEditor({
|
|
895
919
|
shapeUtils: [CustomShapeUtil],
|
|
896
920
|
})
|
|
897
|
-
const { A } = editor.createShapesFromJsx([
|
|
921
|
+
const { A } = editor.createShapesFromJsx([
|
|
922
|
+
<TL.myCustomShape ref="A" x={0} y={0} w={100} h={100} />,
|
|
923
|
+
])
|
|
898
924
|
expect(editor.getShapePageBounds(A)!.width).toBe(100)
|
|
899
|
-
editor.updateShape({ id: A, type: '
|
|
925
|
+
editor.updateShape({ id: A, type: 'myCustomShape', meta: { double: true } })
|
|
900
926
|
expect(editor.getShapePageBounds(A)!.width).toBe(200)
|
|
901
927
|
})
|
|
902
928
|
})
|
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
IndexKey,
|
|
3
|
-
TLArrowShape,
|
|
4
|
-
TLGeoShape,
|
|
5
|
-
TLNoteShape,
|
|
6
|
-
TLTextShape,
|
|
7
|
-
createShapeId,
|
|
8
|
-
toRichText,
|
|
9
|
-
} from '@tldraw/editor'
|
|
1
|
+
import { IndexKey, createShapeId, toRichText } from '@tldraw/editor'
|
|
10
2
|
import { vi } from 'vitest'
|
|
11
3
|
import { TestEditor } from './TestEditor'
|
|
12
4
|
|
|
@@ -61,7 +53,7 @@ describe('TLSelectTool.Idle', () => {
|
|
|
61
53
|
describe.skip('Edit on type', () => {
|
|
62
54
|
it('Starts editing shape on key down if shape does auto-edit on key stroke', () => {
|
|
63
55
|
const id = createShapeId()
|
|
64
|
-
editor.createShapes
|
|
56
|
+
editor.createShapes([
|
|
65
57
|
{
|
|
66
58
|
id,
|
|
67
59
|
type: 'note',
|
|
@@ -85,7 +77,7 @@ describe.skip('Edit on type', () => {
|
|
|
85
77
|
|
|
86
78
|
it('Does not start editing on excluded keys', () => {
|
|
87
79
|
const id = createShapeId()
|
|
88
|
-
editor.createShapes
|
|
80
|
+
editor.createShapes([
|
|
89
81
|
{
|
|
90
82
|
id,
|
|
91
83
|
type: 'note',
|
|
@@ -102,7 +94,7 @@ describe.skip('Edit on type', () => {
|
|
|
102
94
|
|
|
103
95
|
it('Ignores key down if altKey or ctrlKey is pressed', () => {
|
|
104
96
|
const id = createShapeId()
|
|
105
|
-
editor.createShapes
|
|
97
|
+
editor.createShapes([
|
|
106
98
|
{
|
|
107
99
|
id,
|
|
108
100
|
type: 'note',
|
|
@@ -270,7 +262,7 @@ describe('DraggingHandle', () => {
|
|
|
270
262
|
|
|
271
263
|
describe('PointingLabel', () => {
|
|
272
264
|
it('Enters from pointing_arrow_label and exits to idle', () => {
|
|
273
|
-
editor.createShapes
|
|
265
|
+
editor.createShapes([
|
|
274
266
|
{
|
|
275
267
|
id: ids.arrow1,
|
|
276
268
|
type: 'arrow',
|
|
@@ -302,7 +294,7 @@ describe('PointingLabel', () => {
|
|
|
302
294
|
})
|
|
303
295
|
|
|
304
296
|
it('Bails on escape', () => {
|
|
305
|
-
editor.createShapes
|
|
297
|
+
editor.createShapes([
|
|
306
298
|
{
|
|
307
299
|
id: ids.arrow1,
|
|
308
300
|
type: 'arrow',
|
|
@@ -329,7 +321,7 @@ describe('PointingLabel', () => {
|
|
|
329
321
|
})
|
|
330
322
|
|
|
331
323
|
it('Doesnt go into pointing_arrow_label mode if not selecting the arrow shape', () => {
|
|
332
|
-
editor.createShapes
|
|
324
|
+
editor.createShapes([
|
|
333
325
|
{
|
|
334
326
|
id: ids.arrow1,
|
|
335
327
|
type: 'arrow',
|
|
@@ -406,7 +398,7 @@ describe('When double clicking the selection edge', () => {
|
|
|
406
398
|
.selectAll()
|
|
407
399
|
.deleteShapes(editor.getSelectedShapeIds())
|
|
408
400
|
.selectNone()
|
|
409
|
-
.createShapes
|
|
401
|
+
.createShapes([
|
|
410
402
|
{
|
|
411
403
|
id,
|
|
412
404
|
type: 'text',
|
|
@@ -464,7 +456,7 @@ describe('When editing shapes', () => {
|
|
|
464
456
|
text2: createShapeId(),
|
|
465
457
|
}
|
|
466
458
|
|
|
467
|
-
editor.createShapes
|
|
459
|
+
editor.createShapes([
|
|
468
460
|
{
|
|
469
461
|
id: ids.geo1,
|
|
470
462
|
type: 'geo',
|
|
@@ -702,7 +694,7 @@ describe('when passing a function to onInteractionEnd', () => {
|
|
|
702
694
|
},
|
|
703
695
|
}
|
|
704
696
|
|
|
705
|
-
editor.createShapes
|
|
697
|
+
editor.createShapes([arrow])
|
|
706
698
|
|
|
707
699
|
editor.setCurrentTool('select.pointing_arrow_label', {
|
|
708
700
|
shape: arrow,
|
|
@@ -828,7 +820,7 @@ describe('when passing a string to onInteractionEnd', () => {
|
|
|
828
820
|
},
|
|
829
821
|
}
|
|
830
822
|
|
|
831
|
-
editor.createShapes
|
|
823
|
+
editor.createShapes([arrow])
|
|
832
824
|
|
|
833
825
|
editor.setCurrentTool('select.pointing_arrow_label', {
|
|
834
826
|
shape: arrow,
|
package/src/test/TestEditor.ts
CHANGED
|
@@ -10,7 +10,6 @@ import {
|
|
|
10
10
|
RequiredKeys,
|
|
11
11
|
RotateCorner,
|
|
12
12
|
SelectionHandle,
|
|
13
|
-
TLArrowBinding,
|
|
14
13
|
TLArrowShape,
|
|
15
14
|
TLContent,
|
|
16
15
|
TLEditorOptions,
|
|
@@ -790,9 +789,7 @@ export class TestEditor extends Editor {
|
|
|
790
789
|
}
|
|
791
790
|
|
|
792
791
|
getArrowsBoundTo(shapeId: TLShapeId) {
|
|
793
|
-
const ids = new Set(
|
|
794
|
-
this.getBindingsToShape<TLArrowBinding>(shapeId, 'arrow').map((b) => b.fromId)
|
|
795
|
-
)
|
|
792
|
+
const ids = new Set(this.getBindingsToShape(shapeId, 'arrow').map((b) => b.fromId))
|
|
796
793
|
return compact(Array.from(ids, (id) => this.getShape<TLArrowShape>(id)))
|
|
797
794
|
}
|
|
798
795
|
}
|
|
@@ -4,8 +4,9 @@ import {
|
|
|
4
4
|
BaseBoxShapeUtil,
|
|
5
5
|
Editor,
|
|
6
6
|
HTMLContainer,
|
|
7
|
+
IndexKey,
|
|
7
8
|
TLAssetStore,
|
|
8
|
-
|
|
9
|
+
TLShape,
|
|
9
10
|
TLShapeId,
|
|
10
11
|
TldrawEditor,
|
|
11
12
|
createShapeId,
|
|
@@ -196,7 +197,7 @@ describe('<TldrawEditor />', () => {
|
|
|
196
197
|
},
|
|
197
198
|
{ type: 'embed' as const, props: { w: 100, h: 100, url: 'https://example.com' } },
|
|
198
199
|
{ type: 'frame' as const, props: { w: 100, h: 100 } },
|
|
199
|
-
{ type: 'geo' as const, props: { w: 100, h: 100, geo: 'rectangle' } },
|
|
200
|
+
{ type: 'geo' as const, props: { w: 100, h: 100, geo: 'rectangle' as const } },
|
|
200
201
|
{
|
|
201
202
|
type: 'highlight' as const,
|
|
202
203
|
props: { segments: [{ type: 'free' as const, points: [{ x: 0, y: 0, z: 0.5 }] }] },
|
|
@@ -206,8 +207,8 @@ describe('<TldrawEditor />', () => {
|
|
|
206
207
|
type: 'line' as const,
|
|
207
208
|
props: {
|
|
208
209
|
points: {
|
|
209
|
-
a1: { id: 'a1', index: 'a1', x: 0, y: 0 },
|
|
210
|
-
a2: { id: 'a2', index: 'a2', x: 100, y: 100 },
|
|
210
|
+
a1: { id: 'a1', index: 'a1' as IndexKey, x: 0, y: 0 },
|
|
211
|
+
a2: { id: 'a2', index: 'a2' as IndexKey, x: 100, y: 100 },
|
|
211
212
|
},
|
|
212
213
|
},
|
|
213
214
|
},
|
|
@@ -227,10 +228,9 @@ describe('<TldrawEditor />', () => {
|
|
|
227
228
|
editor.createShapes([
|
|
228
229
|
{
|
|
229
230
|
id,
|
|
230
|
-
|
|
231
|
+
...shapeConfig,
|
|
231
232
|
x: i * 150, // Space them out horizontally
|
|
232
233
|
y: 0,
|
|
233
|
-
props: shapeConfig.props,
|
|
234
234
|
},
|
|
235
235
|
])
|
|
236
236
|
})
|
|
@@ -285,8 +285,9 @@ describe('<TldrawEditor />', () => {
|
|
|
285
285
|
|
|
286
286
|
// we should only get one editor instance
|
|
287
287
|
expect(editorInstances.size).toBe(1)
|
|
288
|
-
//
|
|
289
|
-
|
|
288
|
+
// strict mode may cause onMount to be called twice, but the important
|
|
289
|
+
// thing is that we always get the same editor instance
|
|
290
|
+
expect(onMount).toHaveBeenCalled()
|
|
290
291
|
})
|
|
291
292
|
|
|
292
293
|
it('allows updating camera options without re-creating the editor', async () => {
|
|
@@ -456,17 +457,19 @@ describe('<TldrawEditor />', () => {
|
|
|
456
457
|
})
|
|
457
458
|
})
|
|
458
459
|
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
>
|
|
460
|
+
const CARD_TYPE = 'card'
|
|
461
|
+
|
|
462
|
+
declare module '@tldraw/tlschema' {
|
|
463
|
+
export interface TLGlobalShapePropsMap {
|
|
464
|
+
[CARD_TYPE]: { w: number; h: number }
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
467
|
|
|
468
|
+
type CardShape = TLShape<typeof CARD_TYPE>
|
|
469
|
+
|
|
470
|
+
describe('Custom shapes', () => {
|
|
468
471
|
class CardUtil extends BaseBoxShapeUtil<CardShape> {
|
|
469
|
-
static override type =
|
|
472
|
+
static override type = CARD_TYPE
|
|
470
473
|
|
|
471
474
|
override isAspectRatioLocked(_shape: CardShape) {
|
|
472
475
|
return false
|
|
@@ -508,7 +511,7 @@ describe('Custom shapes', () => {
|
|
|
508
511
|
class CardTool extends BaseBoxShapeTool {
|
|
509
512
|
static override id = 'card'
|
|
510
513
|
static override initial = 'idle'
|
|
511
|
-
override shapeType = 'card'
|
|
514
|
+
override shapeType = 'card' as const
|
|
512
515
|
}
|
|
513
516
|
|
|
514
517
|
const tools = [CardTool]
|