tldraw 5.4.0-next.ebc95cf01337 → 5.4.0
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/DOCS.md +2826 -3226
- package/RELEASE_NOTES.md +190 -2
- package/dist-cjs/index.js +1 -1
- package/dist-cjs/lib/defaultExternalContentHandlers.js +30 -14
- package/dist-cjs/lib/defaultExternalContentHandlers.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/curved-arrow.js +2 -2
- package/dist-cjs/lib/shapes/arrow/curved-arrow.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/elbow/getElbowArrowInfo.js +2 -2
- package/dist-cjs/lib/shapes/arrow/elbow/getElbowArrowInfo.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/getArrowInfo.js +1 -1
- package/dist-cjs/lib/shapes/arrow/getArrowInfo.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/straight-arrow.js +2 -2
- package/dist-cjs/lib/shapes/arrow/straight-arrow.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/toolStates/Idle.js +2 -3
- package/dist-cjs/lib/shapes/arrow/toolStates/Idle.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.js +7 -5
- package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/shapes/draw/toolStates/Drawing.js +8 -6
- package/dist-cjs/lib/shapes/draw/toolStates/Drawing.js.map +2 -2
- package/dist-cjs/lib/shapes/geo/getGeoShapePath.js +3 -1
- package/dist-cjs/lib/shapes/geo/getGeoShapePath.js.map +2 -2
- package/dist-cjs/lib/shapes/geo/toolStates/Idle.js +2 -3
- package/dist-cjs/lib/shapes/geo/toolStates/Idle.js.map +2 -2
- package/dist-cjs/lib/shapes/geo/toolStates/Pointing.js +1 -1
- package/dist-cjs/lib/shapes/geo/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/shapes/line/toolStates/Pointing.js +2 -6
- package/dist-cjs/lib/shapes/line/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/shapes/note/NoteShapeUtil.js +4 -4
- package/dist-cjs/lib/shapes/note/NoteShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/note/noteHelpers.js +6 -5
- package/dist-cjs/lib/shapes/note/noteHelpers.js.map +2 -2
- package/dist-cjs/lib/shapes/note/toolStates/Pointing.js +1 -1
- package/dist-cjs/lib/shapes/note/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/crop.js +1 -1
- package/dist-cjs/lib/shapes/shared/crop.js.map +2 -2
- package/dist-cjs/lib/shapes/text/toolStates/Idle.js +1 -1
- package/dist-cjs/lib/shapes/text/toolStates/Idle.js.map +2 -2
- package/dist-cjs/lib/shapes/text/toolStates/Pointing.js +1 -0
- package/dist-cjs/lib/shapes/text/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/shapes/video/VideoShapeUtil.js +3 -2
- package/dist-cjs/lib/shapes/video/VideoShapeUtil.js.map +2 -2
- package/dist-cjs/lib/tools/EraserTool/childStates/Erasing.js +2 -0
- package/dist-cjs/lib/tools/EraserTool/childStates/Erasing.js.map +2 -2
- package/dist-cjs/lib/tools/HandTool/childStates/OneFingerZooming.js +6 -0
- package/dist-cjs/lib/tools/HandTool/childStates/OneFingerZooming.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/SelectTool.js +3 -0
- package/dist-cjs/lib/tools/SelectTool/SelectTool.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Brushing.js +1 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/Brushing.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/Crop.js +1 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/Crop.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js +1 -3
- package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Idle.js +6 -3
- package/dist-cjs/lib/tools/SelectTool/childStates/Idle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingArrowLabel.js +1 -1
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingArrowLabel.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingCanvas.js +3 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingCanvas.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingHandle.js +1 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingHandle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingShape.js +1 -1
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingShape.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js +22 -30
- package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/ScribbleBrushing.js +1 -3
- package/dist-cjs/lib/tools/SelectTool/childStates/ScribbleBrushing.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js +4 -1
- package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/selectHelpers.js +10 -0
- package/dist-cjs/lib/tools/SelectTool/selectHelpers.js.map +2 -2
- package/dist-cjs/lib/ui/components/ActionsMenu/DefaultActionsMenu.js +1 -8
- package/dist-cjs/lib/ui/components/ActionsMenu/DefaultActionsMenu.js.map +2 -2
- package/dist-cjs/lib/ui/components/ContextMenu/DefaultContextMenu.js +6 -1
- package/dist-cjs/lib/ui/components/ContextMenu/DefaultContextMenu.js.map +2 -2
- package/dist-cjs/lib/ui/components/Dialogs.js +8 -0
- package/dist-cjs/lib/ui/components/Dialogs.js.map +2 -2
- package/dist-cjs/lib/ui/components/EditLinkDialog.js +5 -5
- package/dist-cjs/lib/ui/components/EditLinkDialog.js.map +2 -2
- package/dist-cjs/lib/ui/components/Minimap/DefaultMinimap.js +4 -20
- package/dist-cjs/lib/ui/components/Minimap/DefaultMinimap.js.map +2 -2
- package/dist-cjs/lib/ui/components/StylePanel/StylePanelDoubleDropdownPicker.js +2 -0
- package/dist-cjs/lib/ui/components/StylePanel/StylePanelDoubleDropdownPicker.js.map +2 -2
- package/dist-cjs/lib/ui/components/Toolbar/AltTextEditor.js +1 -0
- package/dist-cjs/lib/ui/components/Toolbar/AltTextEditor.js.map +2 -2
- package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbarContent.js +10 -8
- package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbarContent.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiSlider.js +20 -1
- package/dist-cjs/lib/ui/components/primitives/TldrawUiSlider.js.map +2 -2
- package/dist-cjs/lib/ui/context/actions.js +8 -7
- package/dist-cjs/lib/ui/context/actions.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/useCommentingEnabled.js +1 -1
- package/dist-cjs/lib/ui/hooks/useCommentingEnabled.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-esm/index.mjs +1 -1
- package/dist-esm/lib/defaultExternalContentHandlers.mjs +30 -14
- package/dist-esm/lib/defaultExternalContentHandlers.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/curved-arrow.mjs +2 -2
- package/dist-esm/lib/shapes/arrow/curved-arrow.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/elbow/getElbowArrowInfo.mjs +2 -2
- package/dist-esm/lib/shapes/arrow/elbow/getElbowArrowInfo.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/getArrowInfo.mjs +1 -1
- package/dist-esm/lib/shapes/arrow/getArrowInfo.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/straight-arrow.mjs +2 -2
- package/dist-esm/lib/shapes/arrow/straight-arrow.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/toolStates/Idle.mjs +3 -4
- package/dist-esm/lib/shapes/arrow/toolStates/Idle.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs +7 -5
- package/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/shapes/draw/toolStates/Drawing.mjs +8 -6
- package/dist-esm/lib/shapes/draw/toolStates/Drawing.mjs.map +2 -2
- package/dist-esm/lib/shapes/geo/getGeoShapePath.mjs +3 -1
- package/dist-esm/lib/shapes/geo/getGeoShapePath.mjs.map +2 -2
- package/dist-esm/lib/shapes/geo/toolStates/Idle.mjs +3 -4
- package/dist-esm/lib/shapes/geo/toolStates/Idle.mjs.map +2 -2
- package/dist-esm/lib/shapes/geo/toolStates/Pointing.mjs +1 -1
- package/dist-esm/lib/shapes/geo/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/shapes/line/toolStates/Pointing.mjs +2 -7
- package/dist-esm/lib/shapes/line/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs +4 -4
- package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/note/noteHelpers.mjs +6 -5
- package/dist-esm/lib/shapes/note/noteHelpers.mjs.map +2 -2
- package/dist-esm/lib/shapes/note/toolStates/Pointing.mjs +1 -1
- package/dist-esm/lib/shapes/note/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/crop.mjs +1 -1
- package/dist-esm/lib/shapes/shared/crop.mjs.map +2 -2
- package/dist-esm/lib/shapes/text/toolStates/Idle.mjs +2 -2
- package/dist-esm/lib/shapes/text/toolStates/Idle.mjs.map +2 -2
- package/dist-esm/lib/shapes/text/toolStates/Pointing.mjs +1 -0
- package/dist-esm/lib/shapes/text/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/shapes/video/VideoShapeUtil.mjs +3 -2
- package/dist-esm/lib/shapes/video/VideoShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/tools/EraserTool/childStates/Erasing.mjs +2 -0
- package/dist-esm/lib/tools/EraserTool/childStates/Erasing.mjs.map +2 -2
- package/dist-esm/lib/tools/HandTool/childStates/OneFingerZooming.mjs +6 -0
- package/dist-esm/lib/tools/HandTool/childStates/OneFingerZooming.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/SelectTool.mjs +3 -0
- package/dist-esm/lib/tools/SelectTool/SelectTool.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Brushing.mjs +1 -0
- package/dist-esm/lib/tools/SelectTool/childStates/Brushing.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/Crop.mjs +1 -0
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/Crop.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs +1 -3
- package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Idle.mjs +6 -3
- package/dist-esm/lib/tools/SelectTool/childStates/Idle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingArrowLabel.mjs +1 -1
- package/dist-esm/lib/tools/SelectTool/childStates/PointingArrowLabel.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingCanvas.mjs +3 -0
- package/dist-esm/lib/tools/SelectTool/childStates/PointingCanvas.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingHandle.mjs +5 -1
- package/dist-esm/lib/tools/SelectTool/childStates/PointingHandle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingShape.mjs +1 -1
- package/dist-esm/lib/tools/SelectTool/childStates/PointingShape.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs +22 -31
- package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/ScribbleBrushing.mjs +1 -3
- package/dist-esm/lib/tools/SelectTool/childStates/ScribbleBrushing.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs +4 -1
- package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/selectHelpers.mjs +10 -0
- package/dist-esm/lib/tools/SelectTool/selectHelpers.mjs.map +2 -2
- package/dist-esm/lib/ui/components/ActionsMenu/DefaultActionsMenu.mjs +1 -8
- package/dist-esm/lib/ui/components/ActionsMenu/DefaultActionsMenu.mjs.map +2 -2
- package/dist-esm/lib/ui/components/ContextMenu/DefaultContextMenu.mjs +7 -2
- package/dist-esm/lib/ui/components/ContextMenu/DefaultContextMenu.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Dialogs.mjs +9 -1
- package/dist-esm/lib/ui/components/Dialogs.mjs.map +2 -2
- package/dist-esm/lib/ui/components/EditLinkDialog.mjs +5 -5
- package/dist-esm/lib/ui/components/EditLinkDialog.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Minimap/DefaultMinimap.mjs +5 -22
- package/dist-esm/lib/ui/components/Minimap/DefaultMinimap.mjs.map +2 -2
- package/dist-esm/lib/ui/components/StylePanel/StylePanelDoubleDropdownPicker.mjs +2 -0
- package/dist-esm/lib/ui/components/StylePanel/StylePanelDoubleDropdownPicker.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Toolbar/AltTextEditor.mjs +1 -0
- package/dist-esm/lib/ui/components/Toolbar/AltTextEditor.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbarContent.mjs +10 -8
- package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbarContent.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiSlider.mjs +20 -1
- package/dist-esm/lib/ui/components/primitives/TldrawUiSlider.mjs.map +2 -2
- package/dist-esm/lib/ui/context/actions.mjs +8 -7
- package/dist-esm/lib/ui/context/actions.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/useCommentingEnabled.mjs +2 -2
- package/dist-esm/lib/ui/hooks/useCommentingEnabled.mjs.map +2 -2
- package/dist-esm/lib/ui/version.mjs +3 -3
- package/dist-esm/lib/ui/version.mjs.map +1 -1
- package/package.json +12 -6
- package/src/lib/defaultExternalContentHandlers.test.ts +43 -0
- package/src/lib/defaultExternalContentHandlers.ts +38 -16
- package/src/lib/shapes/arrow/ArrowShapeTool.test.ts +17 -0
- package/src/lib/shapes/arrow/curved-arrow.ts +2 -2
- package/src/lib/shapes/arrow/elbow/getElbowArrowInfo.tsx +5 -3
- package/src/lib/shapes/arrow/getArrowInfo.ts +2 -1
- package/src/lib/shapes/arrow/straight-arrow.ts +2 -2
- package/src/lib/shapes/arrow/toolStates/Idle.tsx +3 -4
- package/src/lib/shapes/arrow/toolStates/Pointing.tsx +10 -6
- package/src/lib/shapes/draw/DrawShapeTool.test.ts +19 -0
- package/src/lib/shapes/draw/toolStates/Drawing.ts +12 -6
- package/src/lib/shapes/frame/FrameShapeTool.test.ts +17 -0
- package/src/lib/shapes/geo/GeoShapeTool.test.ts +28 -0
- package/src/lib/shapes/geo/getGeoShapePath.ts +3 -1
- package/src/lib/shapes/geo/toolStates/Idle.ts +3 -4
- package/src/lib/shapes/geo/toolStates/Pointing.ts +2 -1
- package/src/lib/shapes/line/LineShapeTool.test.ts +30 -1
- package/src/lib/shapes/line/toolStates/Pointing.ts +6 -7
- package/src/lib/shapes/note/NoteShapeTool.test.ts +45 -0
- package/src/lib/shapes/note/NoteShapeUtil.tsx +7 -4
- package/src/lib/shapes/note/noteHelpers.ts +18 -8
- package/src/lib/shapes/note/toolStates/Pointing.ts +2 -1
- package/src/lib/shapes/shared/crop.ts +7 -1
- package/src/lib/shapes/text/TextShapeTool.test.ts +33 -0
- package/src/lib/shapes/text/toolStates/Idle.ts +2 -2
- package/src/lib/shapes/text/toolStates/Pointing.ts +3 -0
- package/src/lib/shapes/video/VideoShapeUtil.tsx +4 -2
- package/src/lib/tools/EraserTool/childStates/Erasing.ts +5 -0
- package/src/lib/tools/HandTool/childStates/OneFingerZooming.ts +10 -0
- package/src/lib/tools/SelectTool/SelectTool.ts +4 -0
- package/src/lib/tools/SelectTool/childStates/Brushing.ts +4 -0
- package/src/lib/tools/SelectTool/childStates/Crop/Crop.ts +4 -0
- package/src/lib/tools/SelectTool/childStates/DraggingHandle.tsx +3 -4
- package/src/lib/tools/SelectTool/childStates/Idle.ts +10 -3
- package/src/lib/tools/SelectTool/childStates/PointingArrowLabel.ts +1 -1
- package/src/lib/tools/SelectTool/childStates/PointingCanvas.ts +4 -0
- package/src/lib/tools/SelectTool/childStates/PointingHandle.ts +6 -1
- package/src/lib/tools/SelectTool/childStates/PointingShape.ts +4 -1
- package/src/lib/tools/SelectTool/childStates/Resizing.ts +30 -33
- package/src/lib/tools/SelectTool/childStates/ScribbleBrushing.ts +3 -3
- package/src/lib/tools/SelectTool/childStates/Translating.ts +6 -0
- package/src/lib/tools/SelectTool/selectHelpers.ts +21 -0
- package/src/lib/ui/components/ActionsMenu/DefaultActionsMenu.tsx +3 -9
- package/src/lib/ui/components/ContextMenu/DefaultContextMenu.tsx +8 -2
- package/src/lib/ui/components/Dialogs.tsx +17 -1
- package/src/lib/ui/components/EditLinkDialog.tsx +8 -7
- package/src/lib/ui/components/Minimap/DefaultMinimap.tsx +5 -23
- package/src/lib/ui/components/StylePanel/StylePanelDoubleDropdownPicker.tsx +2 -0
- package/src/lib/ui/components/Toolbar/AltTextEditor.tsx +1 -0
- package/src/lib/ui/components/Toolbar/DefaultImageToolbarContent.tsx +13 -8
- package/src/lib/ui/components/primitives/TldrawUiSlider.test.tsx +92 -0
- package/src/lib/ui/components/primitives/TldrawUiSlider.tsx +25 -1
- package/src/lib/ui/context/actions.tsx +25 -7
- package/src/lib/ui/hooks/useCommentingEnabled.ts +5 -3
- package/src/lib/ui/version.ts +3 -3
- package/src/test/ClickManager.test.ts +18 -0
- package/src/test/Editor.test.tsx +3 -0
- package/src/test/EraserTool.test.ts +18 -2
- package/src/test/HandTool.test.ts +21 -0
- package/src/test/LaserTool.test.ts +46 -0
- package/src/test/ScribbleManager.test.ts +19 -0
- package/src/test/SelectTool.test.ts +110 -0
- package/src/test/TldrawEditor.test.tsx +18 -0
- package/src/test/VideoShapeUtil.test.tsx +126 -0
- package/src/test/actions-menu-readonly.test.tsx +37 -0
- package/src/test/commands/__snapshots__/packShapes.test.ts.snap +6 -6
- package/src/test/commands/lockShapes.test.ts +11 -0
- package/src/test/commands/packShapes.test.ts +20 -0
- package/src/test/commands/putContent.test.ts +35 -1
- package/src/test/commands/setCamera.test.ts +69 -0
- package/src/test/commands/stackShapes.test.ts +12 -0
- package/src/test/commands/updateViewportPageBounds.test.ts +8 -0
- package/src/test/cropping.test.ts +162 -0
- package/src/test/customSnapping.test.tsx +32 -0
- package/src/test/defaultHandleExternalFileContent.test.ts +86 -0
- package/src/test/drawing.test.ts +60 -1
- package/src/test/duplicate.test.ts +22 -0
- package/src/test/frames.test.ts +51 -0
- package/src/test/getShapeAtPoint.test.ts +44 -1
- package/src/test/handleDeepLink.test.tsx +15 -0
- package/src/test/minimap-wheel.test.tsx +48 -0
- package/src/test/resizing.test.ts +46 -0
- package/src/test/selection-omnibus.test.ts +50 -0
- package/src/test/spacebarPanning.test.ts +58 -0
- package/src/test/translating.test.ts +42 -0
- package/src/test/ui/AltTextEditor.test.tsx +51 -0
- package/src/test/ui/ContextMenu.test.tsx +61 -2
- package/src/test/ui/EditLinkDialog.test.tsx +77 -0
- package/src/test/ui/ImageToolbar.test.tsx +58 -0
- package/src/test/ui/StylePanel.test.tsx +33 -2
- package/src/test/ui/keyboardShortcuts.test.tsx +27 -0
- package/src/test/ui/presenceActivity.test.tsx +44 -0
- package/src/test/ui/unlockAll.test.tsx +55 -0
- package/src/test/ui-outside-editor.test.tsx +74 -0
- package/src/test/viewport-following.test.ts +29 -1
|
@@ -170,6 +170,9 @@ export class Translating extends StateNode {
|
|
|
170
170
|
this.editor.duplicateShapes(Array.from(this.editor.getSelectedShapeIds()))
|
|
171
171
|
|
|
172
172
|
this.snapshot = getTranslatingSnapshot(this.editor)
|
|
173
|
+
// The manager ignores startDraggingShapes while it is running, so it has to be
|
|
174
|
+
// cleared or it keeps reparenting the originals instead of the clones
|
|
175
|
+
this.dragAndDropManager.clear()
|
|
173
176
|
this.handleStart()
|
|
174
177
|
this.updateShapes()
|
|
175
178
|
}
|
|
@@ -179,6 +182,8 @@ export class Translating extends StateNode {
|
|
|
179
182
|
this.snapshot = this.selectionSnapshot
|
|
180
183
|
this.reset()
|
|
181
184
|
this.markId = this.editor.markHistoryStoppingPoint('translate')
|
|
185
|
+
// Same as in startCloning: the manager is still tracking the (now deleted) clones
|
|
186
|
+
this.dragAndDropManager.clear()
|
|
182
187
|
this.updateShapes()
|
|
183
188
|
}
|
|
184
189
|
|
|
@@ -439,6 +444,7 @@ function getTranslatingSnapshot(editor: Editor) {
|
|
|
439
444
|
extraHeight: noteSnapshot.shape.props.growY ?? 0,
|
|
440
445
|
noteWidth: dv.noteWidth,
|
|
441
446
|
noteHeight: dv.noteHeight,
|
|
447
|
+
excludeShapeIds: selectedShapeIds,
|
|
442
448
|
})
|
|
443
449
|
noteCenterOffset = new Vec(dv.noteWidth / 2, dv.noteHeight / 2)
|
|
444
450
|
}
|
|
@@ -48,3 +48,24 @@ export function startEditingShapeWithRichText(
|
|
|
48
48
|
editor.emit('select-all-text', { shapeId: shape.id })
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Start editing any editable shape. Shapes with rich text go through
|
|
54
|
+
* `startEditingShapeWithRichText`; editable shapes without it (frame, video, embed) would
|
|
55
|
+
* make that helper throw, so they enter the editing state directly.
|
|
56
|
+
*
|
|
57
|
+
* @internal
|
|
58
|
+
*/
|
|
59
|
+
export function startEditingShape(
|
|
60
|
+
editor: Editor,
|
|
61
|
+
shape: TLShape,
|
|
62
|
+
options: { selectAll?: boolean; info?: TLEventInfo } = {}
|
|
63
|
+
) {
|
|
64
|
+
if (!editor.canEditShape(shape)) return
|
|
65
|
+
if (hasRichText(shape)) {
|
|
66
|
+
startEditingShapeWithRichText(editor, shape, options)
|
|
67
|
+
return
|
|
68
|
+
}
|
|
69
|
+
editor.setEditingShape(shape)
|
|
70
|
+
editor.setCurrentTool('select.editing_shape', { ...options.info, target: 'shape', shape })
|
|
71
|
+
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { useEditor, useValue } from '@tldraw/editor'
|
|
2
1
|
import { ReactNode, memo } from 'react'
|
|
3
2
|
import { PORTRAIT_BREAKPOINT } from '../../constants'
|
|
4
3
|
import { useBreakpoint } from '../../context/breakpoints'
|
|
@@ -29,19 +28,14 @@ export const DefaultActionsMenu = memo(function DefaultActionsMenu({
|
|
|
29
28
|
const isReadonlyMode = useReadonly()
|
|
30
29
|
const { orientation } = useTldrawUiOrientation()
|
|
31
30
|
|
|
32
|
-
const editor = useEditor()
|
|
33
|
-
const isInAcceptableReadonlyState = useValue(
|
|
34
|
-
'should display quick actions when in readonly',
|
|
35
|
-
() => editor.isInAny('hand', 'zoom'),
|
|
36
|
-
[editor]
|
|
37
|
-
)
|
|
38
|
-
|
|
39
31
|
// Get the actions menu content, either the default component or the user's
|
|
40
32
|
// override. If there's no menu content, then the user has set it to null,
|
|
41
33
|
// so skip rendering the menu.
|
|
42
34
|
|
|
43
35
|
const content = children ?? <DefaultActionsMenuContent />
|
|
44
|
-
|
|
36
|
+
|
|
37
|
+
// Every default action edits shapes, so in readonly mode the menu would open empty
|
|
38
|
+
if (isReadonlyMode) return
|
|
45
39
|
|
|
46
40
|
return (
|
|
47
41
|
<TldrawUiPopover id="actions-menu">
|
|
@@ -6,7 +6,8 @@ import {
|
|
|
6
6
|
useValue,
|
|
7
7
|
} from '@tldraw/editor'
|
|
8
8
|
import { ContextMenu as _ContextMenu } from 'radix-ui'
|
|
9
|
-
import { ReactNode, memo, useCallback, useEffect, useRef } from 'react'
|
|
9
|
+
import { ReactNode, memo, useCallback, useContext, useEffect, useRef } from 'react'
|
|
10
|
+
import { ContextMenuPagePointContext } from '../../context/actions'
|
|
10
11
|
import { useMenuIsOpen } from '../../hooks/useMenuIsOpen'
|
|
11
12
|
import { useDirection, useTranslation } from '../../hooks/useTranslation/useTranslation'
|
|
12
13
|
import { TldrawUiMenuContextProvider } from '../primitives/menus/TldrawUiMenuContext'
|
|
@@ -74,9 +75,14 @@ export const DefaultContextMenu = memo(function DefaultContextMenu({
|
|
|
74
75
|
// interacts again.
|
|
75
76
|
const suppressDismissUntilRef = useRef(0)
|
|
76
77
|
|
|
78
|
+
const rContextMenuPagePoint = useContext(ContextMenuPagePointContext)
|
|
79
|
+
|
|
77
80
|
const cb = useCallback(
|
|
78
81
|
(isOpen: boolean) => {
|
|
79
82
|
const body = editor.getContainerDocument().body
|
|
83
|
+
if (rContextMenuPagePoint) {
|
|
84
|
+
rContextMenuPagePoint.current = isOpen ? editor.inputs.getCurrentPagePoint().clone() : null
|
|
85
|
+
}
|
|
80
86
|
if (!isOpen) {
|
|
81
87
|
const onlySelectedShape = editor.getOnlySelectedShape()
|
|
82
88
|
|
|
@@ -121,7 +127,7 @@ export const DefaultContextMenu = memo(function DefaultContextMenu({
|
|
|
121
127
|
}
|
|
122
128
|
}
|
|
123
129
|
},
|
|
124
|
-
[editor, preventEscapeFromLosingShapeFocus]
|
|
130
|
+
[editor, preventEscapeFromLosingShapeFocus, rContextMenuPagePoint]
|
|
125
131
|
)
|
|
126
132
|
|
|
127
133
|
const container = useContainer()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useContainer, useValue } from '@tldraw/editor'
|
|
2
2
|
import { Dialog as _Dialog } from 'radix-ui'
|
|
3
|
-
import { memo, useCallback } from 'react'
|
|
3
|
+
import { memo, useCallback, useRef } from 'react'
|
|
4
4
|
import { TLUiDialog, useDialogs } from '../context/dialogs'
|
|
5
5
|
import { useDirection } from '../hooks/useTranslation/useTranslation'
|
|
6
6
|
|
|
@@ -10,6 +10,7 @@ const TldrawUiDialog = ({ id, component: ModalContent, preventBackgroundClose }:
|
|
|
10
10
|
|
|
11
11
|
const container = useContainer()
|
|
12
12
|
const dir = useDirection()
|
|
13
|
+
const contentRef = useRef<HTMLDivElement>(null)
|
|
13
14
|
|
|
14
15
|
const handleOpenChange = useCallback(
|
|
15
16
|
(isOpen: boolean) => {
|
|
@@ -29,6 +30,7 @@ const TldrawUiDialog = ({ id, component: ModalContent, preventBackgroundClose }:
|
|
|
29
30
|
<_Dialog.Overlay dir={dir} className="tlui-dialog__overlay" />
|
|
30
31
|
<div dir={dir} className="tlui-dialog__positioner">
|
|
31
32
|
<_Dialog.Content
|
|
33
|
+
ref={contentRef}
|
|
32
34
|
dir={dir}
|
|
33
35
|
className="tlui-dialog__content"
|
|
34
36
|
aria-describedby={undefined}
|
|
@@ -39,6 +41,20 @@ const TldrawUiDialog = ({ id, component: ModalContent, preventBackgroundClose }:
|
|
|
39
41
|
// both a pointer press and a focus shift outside the dialog; opt out of both
|
|
40
42
|
// when the dialog asks to stay open on background interactions (escape still
|
|
41
43
|
// closes it).
|
|
44
|
+
|
|
45
|
+
// A touch press is checked against the layers at the following click rather
|
|
46
|
+
// than at the press itself, so a press that closes a dialog stacked on top of
|
|
47
|
+
// this one arrives here once this one is topmost, and reads as a press
|
|
48
|
+
// outside it. A press inside another dialog is never outside this one, and
|
|
49
|
+
// stays so after that dialog unmounts and takes the press's target with it.
|
|
50
|
+
const target = e.detail.originalEvent.target
|
|
51
|
+
const pressedDialog =
|
|
52
|
+
target instanceof Element ? target.closest('.tlui-dialog__content') : null
|
|
53
|
+
if (pressedDialog && pressedDialog !== contentRef.current) {
|
|
54
|
+
e.preventDefault()
|
|
55
|
+
return
|
|
56
|
+
}
|
|
57
|
+
|
|
42
58
|
if (preventBackgroundClose) {
|
|
43
59
|
e.preventDefault()
|
|
44
60
|
}
|
|
@@ -41,8 +41,15 @@ export const EditLinkDialog = track(function EditLinkDialog({ onClose }: TLUiDia
|
|
|
41
41
|
const editor = useEditor()
|
|
42
42
|
|
|
43
43
|
const selectedShape = editor.getOnlySelectedShape()
|
|
44
|
+
const hasShapeWithUrl = isShapeWithUrl(selectedShape)
|
|
44
45
|
|
|
45
|
-
|
|
46
|
+
// The shape can be deleted or deselected from under the open dialog (a collaborator, or a
|
|
47
|
+
// keypress reaching the canvas). Returning null on its own would leave an empty dialog frame.
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
if (!hasShapeWithUrl) onClose()
|
|
50
|
+
}, [hasShapeWithUrl, onClose])
|
|
51
|
+
|
|
52
|
+
if (!hasShapeWithUrl) {
|
|
46
53
|
return null
|
|
47
54
|
}
|
|
48
55
|
|
|
@@ -139,12 +146,6 @@ export const EditLinkDialogInner = track(function EditLinkDialogInner({
|
|
|
139
146
|
onClose()
|
|
140
147
|
}, [onClose])
|
|
141
148
|
|
|
142
|
-
if (!selectedShape) {
|
|
143
|
-
// dismiss modal
|
|
144
|
-
onClose()
|
|
145
|
-
return null
|
|
146
|
-
}
|
|
147
|
-
|
|
148
149
|
// Are we going from a valid state to an invalid state?
|
|
149
150
|
const isRemoving = rInitialValue.current && !urlInputState.valid
|
|
150
151
|
|
|
@@ -3,12 +3,11 @@ import {
|
|
|
3
3
|
TLPointerEventInfo,
|
|
4
4
|
Vec,
|
|
5
5
|
getPointerInfo,
|
|
6
|
-
isAccelKey,
|
|
7
|
-
normalizeWheel,
|
|
8
6
|
setPointerCapture,
|
|
9
7
|
useContainer,
|
|
10
8
|
useColorMode,
|
|
11
9
|
useEditor,
|
|
10
|
+
usePassThroughWheelEvents,
|
|
12
11
|
useValue,
|
|
13
12
|
} from '@tldraw/editor'
|
|
14
13
|
import * as React from 'react'
|
|
@@ -26,6 +25,9 @@ export function DefaultMinimap() {
|
|
|
26
25
|
const container = useContainer()
|
|
27
26
|
const msg = useTranslation()
|
|
28
27
|
|
|
28
|
+
const rMinimap = React.useRef<HTMLDivElement>(null)
|
|
29
|
+
usePassThroughWheelEvents(rMinimap)
|
|
30
|
+
|
|
29
31
|
const rCanvas = React.useRef<HTMLCanvasElement>(null!)
|
|
30
32
|
const rPointing = React.useRef(false)
|
|
31
33
|
const rActivePointerId = React.useRef<number | null>(null)
|
|
@@ -177,25 +179,6 @@ export function DefaultMinimap() {
|
|
|
177
179
|
[editor]
|
|
178
180
|
)
|
|
179
181
|
|
|
180
|
-
const onWheel = React.useCallback(
|
|
181
|
-
(e: React.WheelEvent<HTMLCanvasElement>) => {
|
|
182
|
-
const offset = normalizeWheel(e)
|
|
183
|
-
|
|
184
|
-
editor.dispatch({
|
|
185
|
-
type: 'wheel',
|
|
186
|
-
name: 'wheel',
|
|
187
|
-
delta: offset,
|
|
188
|
-
point: new Vec(e.clientX, e.clientY),
|
|
189
|
-
shiftKey: e.shiftKey,
|
|
190
|
-
altKey: e.altKey,
|
|
191
|
-
ctrlKey: e.metaKey || e.ctrlKey,
|
|
192
|
-
metaKey: e.metaKey,
|
|
193
|
-
accelKey: isAccelKey(e),
|
|
194
|
-
})
|
|
195
|
-
},
|
|
196
|
-
[editor]
|
|
197
|
-
)
|
|
198
|
-
|
|
199
182
|
const colorMode = useColorMode()
|
|
200
183
|
const currentThemeId = useValue('current theme id', () => editor.getCurrentThemeId(), [editor])
|
|
201
184
|
|
|
@@ -209,7 +192,7 @@ export function DefaultMinimap() {
|
|
|
209
192
|
}, [colorMode, currentThemeId, editor])
|
|
210
193
|
|
|
211
194
|
return (
|
|
212
|
-
<div className="tlui-minimap">
|
|
195
|
+
<div ref={rMinimap} className="tlui-minimap">
|
|
213
196
|
<canvas
|
|
214
197
|
ref={rCanvas}
|
|
215
198
|
role="img"
|
|
@@ -219,7 +202,6 @@ export function DefaultMinimap() {
|
|
|
219
202
|
onDoubleClick={onDoubleClick}
|
|
220
203
|
onPointerMove={onPointerMove}
|
|
221
204
|
onPointerDown={onPointerDown}
|
|
222
|
-
onWheelCapture={onWheel}
|
|
223
205
|
/>
|
|
224
206
|
</div>
|
|
225
207
|
)
|
|
@@ -112,6 +112,7 @@ function StylePanelDoubleDropdownPickerInlineInner<T extends string>(
|
|
|
112
112
|
type="icon"
|
|
113
113
|
key={item.value}
|
|
114
114
|
onClick={() => {
|
|
115
|
+
ctx.onHistoryMark('select style dropdown item')
|
|
115
116
|
onValueChange(styleA, item.value)
|
|
116
117
|
tlmenus.deleteOpenMenu(idA, editor.contextId)
|
|
117
118
|
setIsOpenA(false)
|
|
@@ -153,6 +154,7 @@ function StylePanelDoubleDropdownPickerInlineInner<T extends string>(
|
|
|
153
154
|
title={`${msg(labelB)} — ${msg(`${uiTypeB}-style.${item.value}` as TLUiTranslationKey)}`}
|
|
154
155
|
data-testid={`style.${uiTypeB}.${item.value}`}
|
|
155
156
|
onClick={() => {
|
|
157
|
+
ctx.onHistoryMark('select style dropdown item')
|
|
156
158
|
onValueChange(styleB, item.value)
|
|
157
159
|
tlmenus.deleteOpenMenu(idB, editor.contextId)
|
|
158
160
|
setIsOpenB(false)
|
|
@@ -33,6 +33,7 @@ export function AltTextEditor({ shapeId, onClose, source }: AltTextEditorProps)
|
|
|
33
33
|
trackEvent('set-alt-text', { source })
|
|
34
34
|
const shape = editor.getShape<ExtractShapeByProps<{ altText: string }>>(shapeId)
|
|
35
35
|
if (!shape) return
|
|
36
|
+
editor.markHistoryStoppingPoint('set alt text')
|
|
36
37
|
editor.updateShapes([
|
|
37
38
|
{
|
|
38
39
|
id: shape.id,
|
|
@@ -189,15 +189,20 @@ export const DefaultImageToolbarContent = track(function DefaultImageToolbarCont
|
|
|
189
189
|
|
|
190
190
|
useEffect(() => {
|
|
191
191
|
function handleKeyDown(e: KeyboardEvent) {
|
|
192
|
-
if (isManipulating)
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
}
|
|
192
|
+
if (!isManipulating) return
|
|
193
|
+
if (e.key === 'Escape') {
|
|
194
|
+
editor.cancel()
|
|
195
|
+
} else if (e.key === 'Enter') {
|
|
196
|
+
editor.complete()
|
|
197
|
+
} else {
|
|
198
|
+
return
|
|
200
199
|
}
|
|
200
|
+
onManipulatingEnd()
|
|
201
|
+
// Otherwise the keydown bubbles to the container's handler, which cancels again
|
|
202
|
+
// against select.idle and clears the selection (#10405). Leaving crop mode also
|
|
203
|
+
// unmounts the slider, so refocus the container to keep shortcuts working.
|
|
204
|
+
e.stopPropagation()
|
|
205
|
+
editor.getContainer().focus()
|
|
201
206
|
}
|
|
202
207
|
const elm = sliderRef.current
|
|
203
208
|
if (elm) {
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { fireEvent, render } from '@testing-library/react'
|
|
2
|
+
import { afterEach, describe, expect, it, vi } from 'vitest'
|
|
3
|
+
import { TldrawUiSlider } from './TldrawUiSlider'
|
|
4
|
+
|
|
5
|
+
function renderSlider() {
|
|
6
|
+
const calls: string[] = []
|
|
7
|
+
const onValueChange = vi.fn((value: number) => {
|
|
8
|
+
calls.push(`change:${value}`)
|
|
9
|
+
})
|
|
10
|
+
const onHistoryMark = vi.fn((id: string) => {
|
|
11
|
+
calls.push(`mark:${id}`)
|
|
12
|
+
})
|
|
13
|
+
const result = render(
|
|
14
|
+
<TldrawUiSlider
|
|
15
|
+
data-testid="slider"
|
|
16
|
+
value={2}
|
|
17
|
+
steps={4}
|
|
18
|
+
label="style-panel.opacity"
|
|
19
|
+
title="Opacity"
|
|
20
|
+
onValueChange={onValueChange}
|
|
21
|
+
onHistoryMark={onHistoryMark}
|
|
22
|
+
/>
|
|
23
|
+
)
|
|
24
|
+
const thumb = result.getByRole('slider')
|
|
25
|
+
return { ...result, thumb, calls, onValueChange, onHistoryMark }
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
describe('TldrawUiSlider', () => {
|
|
29
|
+
afterEach(() => {
|
|
30
|
+
vi.clearAllMocks()
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
it('marks a history stopping point before a keyboard change', () => {
|
|
34
|
+
const { thumb, calls } = renderSlider()
|
|
35
|
+
|
|
36
|
+
fireEvent.keyDown(thumb, { key: 'ArrowLeft' })
|
|
37
|
+
|
|
38
|
+
expect(calls).toEqual(['mark:keyboard slider', 'change:1'])
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
it.each(['ArrowRight', 'ArrowUp', 'ArrowDown', 'PageUp', 'PageDown', 'Home', 'End'])(
|
|
42
|
+
'marks a history stopping point for %s',
|
|
43
|
+
(key) => {
|
|
44
|
+
const { thumb, onHistoryMark, onValueChange } = renderSlider()
|
|
45
|
+
|
|
46
|
+
fireEvent.keyDown(thumb, { key })
|
|
47
|
+
|
|
48
|
+
expect(onHistoryMark).toHaveBeenCalledTimes(1)
|
|
49
|
+
expect(onValueChange).toHaveBeenCalledTimes(1)
|
|
50
|
+
}
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
it('marks once for a held key so the repeat run is a single undo step', () => {
|
|
54
|
+
const { thumb, onHistoryMark, onValueChange } = renderSlider()
|
|
55
|
+
|
|
56
|
+
fireEvent.keyDown(thumb, { key: 'ArrowLeft' })
|
|
57
|
+
fireEvent.keyDown(thumb, { key: 'ArrowLeft', repeat: true })
|
|
58
|
+
fireEvent.keyDown(thumb, { key: 'ArrowLeft', repeat: true })
|
|
59
|
+
|
|
60
|
+
expect(onHistoryMark).toHaveBeenCalledTimes(1)
|
|
61
|
+
expect(onValueChange).toHaveBeenCalledTimes(3)
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
it('marks each separate key press', () => {
|
|
65
|
+
const { thumb, onHistoryMark } = renderSlider()
|
|
66
|
+
|
|
67
|
+
fireEvent.keyDown(thumb, { key: 'ArrowLeft' })
|
|
68
|
+
fireEvent.keyDown(thumb, { key: 'ArrowLeft' })
|
|
69
|
+
fireEvent.keyDown(thumb, { key: 'ArrowLeft' })
|
|
70
|
+
|
|
71
|
+
expect(onHistoryMark).toHaveBeenCalledTimes(3)
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
it('does not mark for keys that do not change the value', () => {
|
|
75
|
+
const { thumb, onHistoryMark, onValueChange } = renderSlider()
|
|
76
|
+
|
|
77
|
+
fireEvent.keyDown(thumb, { key: 'Tab' })
|
|
78
|
+
fireEvent.keyDown(thumb, { key: 'a' })
|
|
79
|
+
fireEvent.keyDown(thumb, { key: 'Enter' })
|
|
80
|
+
|
|
81
|
+
expect(onHistoryMark).not.toHaveBeenCalled()
|
|
82
|
+
expect(onValueChange).not.toHaveBeenCalled()
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
it('still marks a history stopping point on pointer down', () => {
|
|
86
|
+
const { getByTestId, onHistoryMark } = renderSlider()
|
|
87
|
+
|
|
88
|
+
fireEvent.pointerDown(getByTestId('slider'))
|
|
89
|
+
|
|
90
|
+
expect(onHistoryMark).toHaveBeenCalledWith('click slider')
|
|
91
|
+
})
|
|
92
|
+
})
|
|
@@ -5,6 +5,17 @@ import { TLUiTranslationKey } from '../../hooks/useTranslation/TLUiTranslationKe
|
|
|
5
5
|
import { useDirection, useTranslation } from '../../hooks/useTranslation/useTranslation'
|
|
6
6
|
import { hideAllTooltips, TldrawUiTooltip } from './TldrawUiTooltip'
|
|
7
7
|
|
|
8
|
+
const SLIDER_VALUE_KEYS = new Set([
|
|
9
|
+
'ArrowUp',
|
|
10
|
+
'ArrowDown',
|
|
11
|
+
'ArrowLeft',
|
|
12
|
+
'ArrowRight',
|
|
13
|
+
'PageUp',
|
|
14
|
+
'PageDown',
|
|
15
|
+
'Home',
|
|
16
|
+
'End',
|
|
17
|
+
])
|
|
18
|
+
|
|
8
19
|
/** @public */
|
|
9
20
|
export interface TLUiSliderProps {
|
|
10
21
|
min?: number
|
|
@@ -82,6 +93,19 @@ export const TldrawUiSlider = React.forwardRef<HTMLDivElement, TLUiSliderProps>(
|
|
|
82
93
|
}
|
|
83
94
|
}, [])
|
|
84
95
|
|
|
96
|
+
// Capture phase so the mark lands before Radix's bubble-phase onKeyDown changes the value;
|
|
97
|
+
// otherwise keyboard changes squash into the preceding history entry and undo skips past them.
|
|
98
|
+
// Repeats from a held key are skipped so the run is one undo step, like a pointer drag.
|
|
99
|
+
const handleKeyDown = useCallback(
|
|
100
|
+
(event: React.KeyboardEvent) => {
|
|
101
|
+
handleKeyEvent(event)
|
|
102
|
+
if (SLIDER_VALUE_KEYS.has(event.key) && !event.repeat) {
|
|
103
|
+
onHistoryMark?.('keyboard slider')
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
[handleKeyEvent, onHistoryMark]
|
|
107
|
+
)
|
|
108
|
+
|
|
85
109
|
return (
|
|
86
110
|
<div className="tlui-slider__container">
|
|
87
111
|
<TldrawUiTooltip content={titleAndLabel}>
|
|
@@ -95,7 +119,7 @@ export const TldrawUiSlider = React.forwardRef<HTMLDivElement, TLUiSliderProps>(
|
|
|
95
119
|
value={value !== null ? [value] : undefined}
|
|
96
120
|
onPointerDown={handlePointerDown}
|
|
97
121
|
onValueChange={handleValueChange}
|
|
98
|
-
onKeyDownCapture={
|
|
122
|
+
onKeyDownCapture={handleKeyDown}
|
|
99
123
|
onKeyUpCapture={handleKeyEvent}
|
|
100
124
|
>
|
|
101
125
|
<_Slider.Track className="tlui-slider__track" dir={dir}>
|
|
@@ -63,6 +63,15 @@ export type TLUiActionsContextType = Record<string, TLUiActionItem>
|
|
|
63
63
|
/** @internal */
|
|
64
64
|
export const ActionsContext = React.createContext<TLUiActionsContextType | null>(null)
|
|
65
65
|
|
|
66
|
+
/**
|
|
67
|
+
* The page point the context menu opened at, or null while it is closed. The context menu
|
|
68
|
+
* writes it; actions that place content (paste) read it, since the pointer keeps moving
|
|
69
|
+
* over the menu after it opens (#10423).
|
|
70
|
+
*
|
|
71
|
+
* @internal
|
|
72
|
+
*/
|
|
73
|
+
export const ContextMenuPagePointContext = React.createContext<{ current: Vec | null } | null>(null)
|
|
74
|
+
|
|
66
75
|
/** @public */
|
|
67
76
|
export interface ActionsProviderProps {
|
|
68
77
|
overrides?(
|
|
@@ -109,6 +118,8 @@ export function ActionsProvider({ overrides, children }: ActionsProviderProps) {
|
|
|
109
118
|
|
|
110
119
|
const defaultDocumentName = helpers.msg('document.default-name')
|
|
111
120
|
|
|
121
|
+
const rContextMenuPagePoint = React.useRef<Vec | null>(null)
|
|
122
|
+
|
|
112
123
|
// should this be a useMemo? looks like it doesn't actually deref any reactive values
|
|
113
124
|
const actions = React.useMemo<TLUiActionsContextType>(() => {
|
|
114
125
|
const editor = _editor as Editor
|
|
@@ -587,7 +598,7 @@ export function ActionsProvider({ overrides, children }: ActionsProviderProps) {
|
|
|
587
598
|
{
|
|
588
599
|
id: 'frame-selection',
|
|
589
600
|
label: 'action.frame-selection',
|
|
590
|
-
kbd: 'cmd+alt+g',
|
|
601
|
+
kbd: 'cmd+alt+g,ctrl+alt+g',
|
|
591
602
|
onSelect(source) {
|
|
592
603
|
if (!canApplySelectionAction()) return
|
|
593
604
|
if (mustGoBackToSelectToolFirst()) return
|
|
@@ -1051,14 +1062,16 @@ export function ActionsProvider({ overrides, children }: ActionsProviderProps) {
|
|
|
1051
1062
|
label: 'action.paste',
|
|
1052
1063
|
kbd: 'cmd+v,ctrl+v',
|
|
1053
1064
|
onSelect(source) {
|
|
1065
|
+
// Resolve the point before the clipboard read: the menu closes, and clears
|
|
1066
|
+
// its point, before the read settles.
|
|
1067
|
+
const point =
|
|
1068
|
+
source === 'context-menu'
|
|
1069
|
+
? (rContextMenuPagePoint.current ?? editor.inputs.getCurrentPagePoint())
|
|
1070
|
+
: undefined
|
|
1054
1071
|
navigator.clipboard
|
|
1055
1072
|
?.read()
|
|
1056
1073
|
.then((clipboardItems) => {
|
|
1057
|
-
helpers.paste(
|
|
1058
|
-
clipboardItems,
|
|
1059
|
-
source,
|
|
1060
|
-
source === 'context-menu' ? editor.inputs.getCurrentPagePoint() : undefined
|
|
1061
|
-
)
|
|
1074
|
+
helpers.paste(clipboardItems, source, point)
|
|
1062
1075
|
})
|
|
1063
1076
|
.catch(() => {
|
|
1064
1077
|
helpers.addToast({
|
|
@@ -1480,6 +1493,7 @@ export function ActionsProvider({ overrides, children }: ActionsProviderProps) {
|
|
|
1480
1493
|
}
|
|
1481
1494
|
}
|
|
1482
1495
|
if (updates.length > 0) {
|
|
1496
|
+
editor.markHistoryStoppingPoint('unlock all')
|
|
1483
1497
|
editor.updateShapes(updates)
|
|
1484
1498
|
}
|
|
1485
1499
|
},
|
|
@@ -1977,7 +1991,11 @@ export function ActionsProvider({ overrides, children }: ActionsProviderProps) {
|
|
|
1977
1991
|
components,
|
|
1978
1992
|
])
|
|
1979
1993
|
|
|
1980
|
-
return
|
|
1994
|
+
return (
|
|
1995
|
+
<ContextMenuPagePointContext.Provider value={rContextMenuPagePoint}>
|
|
1996
|
+
<ActionsContext.Provider value={asActions(actions)}>{children}</ActionsContext.Provider>
|
|
1997
|
+
</ContextMenuPagePointContext.Provider>
|
|
1998
|
+
)
|
|
1981
1999
|
}
|
|
1982
2000
|
|
|
1983
2001
|
/** @public */
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useLicenseFeatureFlag, useMaybeLicenseManager } from '@tldraw/editor'
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Whether the commenting feature is licensed for this editor. The default comment quick action and
|
|
5
5
|
* its keyboard shortcut are hidden/disabled unless this is true. Enabled in development; in
|
|
6
6
|
* production it requires a license that includes the commenting feature (or the collaboration
|
|
7
|
-
* umbrella that grants it). Reactive: re-reads when license validation resolves.
|
|
7
|
+
* umbrella that grants it). Reactive: re-reads when license validation resolves. Works outside
|
|
8
|
+
* `<Tldraw />` too: UI mounted via `EditorProvider` resolves the license through the editor, and
|
|
9
|
+
* with no editor at all this is `false`.
|
|
8
10
|
*
|
|
9
11
|
* @internal
|
|
10
12
|
*/
|
|
11
13
|
export function useCommentingEnabled(): boolean {
|
|
12
|
-
return useLicenseFeatureFlag(
|
|
14
|
+
return useLicenseFeatureFlag(useMaybeLicenseManager(), 'commenting')
|
|
13
15
|
}
|
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 = '5.4.0
|
|
4
|
+
export const version = '5.4.0'
|
|
5
5
|
export const publishDates = {
|
|
6
6
|
major: '2026-05-06T16:28:18.473Z',
|
|
7
|
-
minor: '2026-
|
|
8
|
-
patch: '2026-
|
|
7
|
+
minor: '2026-09-02T11:04:02.901Z',
|
|
8
|
+
patch: '2026-09-02T11:04:02.901Z',
|
|
9
9
|
}
|
|
@@ -263,6 +263,24 @@ it('Cancels when click moves', () => {
|
|
|
263
263
|
expect(event.name).toBe('pointer_up')
|
|
264
264
|
})
|
|
265
265
|
|
|
266
|
+
it('Does not cancel a double click on a small move when the container is offset', () => {
|
|
267
|
+
// click points are client coordinates; comparing them against the container-relative
|
|
268
|
+
// screen point used to cancel on any movement at all in an offset container
|
|
269
|
+
editor.setScreenBounds({ x: 300, y: 100, w: 1080, h: 720 })
|
|
270
|
+
const events: any[] = []
|
|
271
|
+
editor.addListener('event', (info) => events.push(info))
|
|
272
|
+
|
|
273
|
+
editor.pointerDown(500, 400).pointerMove(501, 400).pointerUp(501, 400).pointerDown(501, 400)
|
|
274
|
+
|
|
275
|
+
expect(events).toMatchObject([
|
|
276
|
+
{ name: 'pointer_down' },
|
|
277
|
+
{ name: 'pointer_move' },
|
|
278
|
+
{ name: 'pointer_up' },
|
|
279
|
+
{ name: 'pointer_down' },
|
|
280
|
+
{ name: 'double_click', type: 'click', phase: 'down' },
|
|
281
|
+
])
|
|
282
|
+
})
|
|
283
|
+
|
|
266
284
|
it('Resets when the focus layer changes', () => {
|
|
267
285
|
const boxId = editor.testShapeID('box')
|
|
268
286
|
const otherBoxId = editor.testShapeID('otherBox')
|
package/src/test/Editor.test.tsx
CHANGED
|
@@ -913,6 +913,9 @@ describe('instance.isReadonly', () => {
|
|
|
913
913
|
expect(editor.getIsReadonly()).toBe(false)
|
|
914
914
|
mode.set('readonly')
|
|
915
915
|
expect(editor.getIsReadonly()).toBe(true)
|
|
916
|
+
|
|
917
|
+
// syncing the mode is not a user edit, so it must not show up in the undo history
|
|
918
|
+
expect(editor.getCanUndo()).toBe(false)
|
|
916
919
|
})
|
|
917
920
|
})
|
|
918
921
|
|
|
@@ -411,6 +411,22 @@ describe('When clicking and dragging', () => {
|
|
|
411
411
|
expect(editor.getShape(ids.box3)).not.toBeDefined()
|
|
412
412
|
})
|
|
413
413
|
|
|
414
|
+
it.each([
|
|
415
|
+
['exactly on the outline', 300],
|
|
416
|
+
['a pixel inside the outline', 301],
|
|
417
|
+
['a pixel outside the outline', 299],
|
|
418
|
+
])('Keeps erasing a frame pressed %s when the drag begins', (_label, x) => {
|
|
419
|
+
editor.setCurrentTool('eraser')
|
|
420
|
+
editor.pointerDown(x, 50) // on frame1's left edge, not its children
|
|
421
|
+
expect(editor.getErasingShapeIds()).toEqual([ids.frame1])
|
|
422
|
+
editor.pointerMove(325, 50) // drag inward, still in the frame, clear of box4
|
|
423
|
+
vi.advanceTimersByTime(16)
|
|
424
|
+
editor.expectToBeIn('eraser.erasing')
|
|
425
|
+
expect(editor.getErasingShapeIds()).toEqual([ids.frame1])
|
|
426
|
+
editor.pointerUp()
|
|
427
|
+
expect(editor.getShape(ids.frame1)).not.toBeDefined()
|
|
428
|
+
})
|
|
429
|
+
|
|
414
430
|
it('Only erases masked shapes when pointer is inside the mask', () => {
|
|
415
431
|
editor.setCurrentTool('eraser')
|
|
416
432
|
editor.pointerMove(425, 0)
|
|
@@ -423,8 +439,8 @@ describe('When clicking and dragging', () => {
|
|
|
423
439
|
editor.pointerUp()
|
|
424
440
|
expect(editor.getShape(ids.box3)).toBeDefined()
|
|
425
441
|
|
|
426
|
-
editor.pointerMove(375,
|
|
427
|
-
editor.pointerDown() //
|
|
442
|
+
editor.pointerMove(375, 20)
|
|
443
|
+
editor.pointerDown() // Inside frame1 (clear of its outline), above the not-masked part of box3
|
|
428
444
|
editor.pointerMove(375, 500) // Through the masked part of box3
|
|
429
445
|
expect(editor.getInstanceState().scribbles.length).toBe(1)
|
|
430
446
|
expect(editor.getErasingShapeIds()).toEqual([ids.box3])
|
|
@@ -39,6 +39,27 @@ describe(HandTool, () => {
|
|
|
39
39
|
expect(editor.getCamera().z).toBeGreaterThan(before)
|
|
40
40
|
})
|
|
41
41
|
|
|
42
|
+
it('Ends one-finger zoom when a second touch starts, instead of jumping the zoom', () => {
|
|
43
|
+
editor.setCurrentTool('hand')
|
|
44
|
+
editor.updateInstanceState({ isCoarsePointer: true })
|
|
45
|
+
|
|
46
|
+
editor.pointerDown(100, 100).pointerUp(100, 100)
|
|
47
|
+
editor.pointerDown(100, 100)
|
|
48
|
+
vi.advanceTimersByTime(editor.options.multiClickDurationMs)
|
|
49
|
+
editor.expectToBeIn('hand.one_finger_zooming')
|
|
50
|
+
|
|
51
|
+
editor.pointerMove(100, 120)
|
|
52
|
+
const zoomBeforeSecondTouch = editor.getCamera().z
|
|
53
|
+
expect(zoomBeforeSecondTouch).toBeGreaterThan(1)
|
|
54
|
+
|
|
55
|
+
// A second finger lands far away and moves; the pan/zoom must yield rather than
|
|
56
|
+
// treat the new pointer as a continuation of the first one.
|
|
57
|
+
editor.pointerDown(300, 400, { pointerId: 2 })
|
|
58
|
+
editor.expectToBeIn('hand.idle')
|
|
59
|
+
editor.pointerMove(300, 420, { pointerId: 2 })
|
|
60
|
+
expect(editor.getCamera().z).toBe(zoomBeforeSecondTouch)
|
|
61
|
+
})
|
|
62
|
+
|
|
42
63
|
it('Zooms in (not one-finger zoom) when a coarse pointer double-taps and releases', () => {
|
|
43
64
|
editor.setCurrentTool('hand')
|
|
44
65
|
editor.updateInstanceState({ isCoarsePointer: true })
|