tldraw 4.2.2 → 4.2.3
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 +242 -311
- package/dist-cjs/index.js +5 -13
- 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 +4 -7
- package/dist-cjs/lib/canvas/TldrawSelectionForeground.js.map +2 -2
- package/dist-cjs/lib/defaultEmbedDefinitions.js.map +2 -2
- package/dist-cjs/lib/defaultExternalContentHandlers.js +5 -5
- package/dist-cjs/lib/defaultExternalContentHandlers.js.map +2 -2
- package/dist-cjs/lib/defaultSideEffects.js +1 -6
- package/dist-cjs/lib/defaultSideEffects.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js +13 -14
- 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 +1 -1
- package/dist-cjs/lib/shapes/arrow/arrowLabel.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/arrowTargetState.js +1 -1
- 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/Idle.js +10 -4
- package/dist-cjs/lib/shapes/arrow/toolStates/Idle.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.js +4 -7
- package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/shapes/bookmark/BookmarkShapeUtil.js +1 -1
- package/dist-cjs/lib/shapes/bookmark/BookmarkShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/bookmark/bookmarks.js.map +2 -2
- package/dist-cjs/lib/shapes/draw/DrawShapeUtil.js +22 -24
- package/dist-cjs/lib/shapes/draw/DrawShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/draw/getPath.js +11 -20
- package/dist-cjs/lib/shapes/draw/getPath.js.map +2 -2
- package/dist-cjs/lib/shapes/draw/toolStates/Drawing.js +86 -82
- package/dist-cjs/lib/shapes/draw/toolStates/Drawing.js.map +3 -3
- package/dist-cjs/lib/shapes/embed/EmbedShapeUtil.js +0 -6
- 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 +5 -6
- package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/geo/GeoShapeUtil.js +142 -146
- package/dist-cjs/lib/shapes/geo/GeoShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/geo/toolStates/Idle.js +10 -5
- package/dist-cjs/lib/shapes/geo/toolStates/Idle.js.map +2 -2
- package/dist-cjs/lib/shapes/geo/toolStates/Pointing.js +3 -3
- package/dist-cjs/lib/shapes/geo/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/shapes/highlight/HighlightShapeUtil.js +21 -23
- package/dist-cjs/lib/shapes/highlight/HighlightShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/line/toolStates/Pointing.js +3 -3
- package/dist-cjs/lib/shapes/line/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/shapes/note/NoteShapeUtil.js +11 -6
- 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/note/toolStates/Pointing.js +10 -5
- package/dist-cjs/lib/shapes/note/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/HyperlinkButton.js +2 -3
- package/dist-cjs/lib/shapes/shared/HyperlinkButton.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/PlainTextLabel.js +2 -14
- package/dist-cjs/lib/shapes/shared/PlainTextLabel.js.map +3 -3
- package/dist-cjs/lib/shapes/shared/RichTextLabel.js +4 -12
- 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 +0 -1
- package/dist-cjs/lib/shapes/shared/crop.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/interpolate-props.js +3 -3
- package/dist-cjs/lib/shapes/shared/interpolate-props.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/{useEfficientZoomThreshold.js → useForceSolid.js} +7 -10
- package/dist-cjs/lib/shapes/shared/useForceSolid.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/RichTextArea.js +0 -5
- package/dist-cjs/lib/shapes/text/RichTextArea.js.map +2 -2
- package/dist-cjs/lib/shapes/text/TextShapeUtil.js +2 -5
- package/dist-cjs/lib/shapes/text/TextShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/text/toolStates/Idle.js +10 -4
- package/dist-cjs/lib/shapes/text/toolStates/Idle.js.map +2 -2
- package/dist-cjs/lib/shapes/text/toolStates/Pointing.js +5 -7
- 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 +5 -4
- package/dist-cjs/lib/tools/EraserTool/childStates/Erasing.js.map +2 -2
- package/dist-cjs/lib/tools/EraserTool/childStates/Pointing.js +4 -2
- package/dist-cjs/lib/tools/EraserTool/childStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/tools/HandTool/HandTool.js +5 -3
- package/dist-cjs/lib/tools/HandTool/HandTool.js.map +2 -2
- package/dist-cjs/lib/tools/HandTool/childStates/Dragging.js +2 -3
- package/dist-cjs/lib/tools/HandTool/childStates/Dragging.js.map +2 -2
- package/dist-cjs/lib/tools/HandTool/childStates/Pointing.js +1 -1
- package/dist-cjs/lib/tools/HandTool/childStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/tools/LaserTool/childStates/Lasering.js +1 -1
- package/dist-cjs/lib/tools/LaserTool/childStates/Lasering.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/DragAndDropManager.js +11 -10
- package/dist-cjs/lib/tools/SelectTool/DragAndDropManager.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Brushing.js +5 -6
- package/dist-cjs/lib/tools/SelectTool/childStates/Brushing.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/Cropping.js +6 -4
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/Cropping.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/Idle.js +1 -1
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/Idle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.js +1 -1
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/PointingCropHandle.js +1 -1
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/PointingCropHandle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.js +1 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.js +1 -1
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js +6 -8
- package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/EditingShape.js +11 -38
- package/dist-cjs/lib/tools/SelectTool/childStates/EditingShape.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Idle.js +50 -42
- package/dist-cjs/lib/tools/SelectTool/childStates/Idle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingArrowLabel.js +6 -6
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingArrowLabel.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingCanvas.js +1 -1
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingCanvas.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingHandle.js +14 -4
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingHandle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingResizeHandle.js +1 -1
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingResizeHandle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingRotateHandle.js +1 -1
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingRotateHandle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingSelection.js +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingSelection.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingShape.js +13 -4
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingShape.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js +6 -5
- package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Rotating.js +3 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Rotating.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/ScribbleBrushing.js +6 -7
- package/dist-cjs/lib/tools/SelectTool/childStates/ScribbleBrushing.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js +11 -13
- package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/selectHelpers.js +4 -15
- package/dist-cjs/lib/tools/SelectTool/selectHelpers.js.map +2 -2
- package/dist-cjs/lib/tools/ZoomTool/ZoomTool.js +1 -1
- package/dist-cjs/lib/tools/ZoomTool/ZoomTool.js.map +2 -2
- package/dist-cjs/lib/tools/ZoomTool/childStates/Pointing.js +3 -3
- package/dist-cjs/lib/tools/ZoomTool/childStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/tools/ZoomTool/childStates/ZoomBrushing.js +6 -5
- package/dist-cjs/lib/tools/ZoomTool/childStates/ZoomBrushing.js.map +2 -2
- package/dist-cjs/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.js +3 -1
- package/dist-cjs/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.js.map +2 -2
- package/dist-cjs/lib/{utils/test-helpers.js → tools/selection-logic/getShouldEnterCropModeOnPointerDown.js} +8 -21
- package/dist-cjs/lib/tools/selection-logic/getShouldEnterCropModeOnPointerDown.js.map +7 -0
- package/dist-cjs/lib/tools/selection-logic/selectOnCanvasPointerUp.js +1 -1
- package/dist-cjs/lib/tools/selection-logic/selectOnCanvasPointerUp.js.map +2 -2
- package/dist-cjs/lib/tools/selection-logic/updateHoveredShapeId.js +1 -1
- package/dist-cjs/lib/tools/selection-logic/updateHoveredShapeId.js.map +2 -2
- package/dist-cjs/lib/ui/TldrawUi.js +2 -2
- package/dist-cjs/lib/ui/TldrawUi.js.map +2 -2
- package/dist-cjs/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.js +9 -3
- package/dist-cjs/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.js.map +2 -2
- package/dist-cjs/lib/ui/components/ContextMenu/DefaultContextMenu.js +3 -1
- package/dist-cjs/lib/ui/components/ContextMenu/DefaultContextMenu.js.map +2 -2
- package/dist-cjs/lib/ui/components/CursorChatBubble.js +1 -1
- package/dist-cjs/lib/ui/components/CursorChatBubble.js.map +2 -2
- package/dist-cjs/lib/ui/components/DefaultDebugPanel.js +21 -1
- package/dist-cjs/lib/ui/components/DefaultDebugPanel.js.map +2 -2
- package/dist-cjs/lib/ui/components/EditLinkDialog.js +1 -11
- package/dist-cjs/lib/ui/components/EditLinkDialog.js.map +2 -2
- package/dist-cjs/lib/ui/components/HelperButtons/StopFollowing.js.map +2 -2
- package/dist-cjs/lib/ui/components/Minimap/DefaultMinimap.js +1 -1
- package/dist-cjs/lib/ui/components/Minimap/DefaultMinimap.js.map +2 -2
- package/dist-cjs/lib/ui/components/OfflineIndicator/OfflineIndicator.js +15 -2
- package/dist-cjs/lib/ui/components/OfflineIndicator/OfflineIndicator.js.map +3 -3
- package/dist-cjs/lib/ui/components/PageMenu/PageItemInput.js +1 -3
- package/dist-cjs/lib/ui/components/PageMenu/PageItemInput.js.map +2 -2
- package/dist-cjs/lib/ui/components/SharePanel/PeopleMenu.js +0 -6
- package/dist-cjs/lib/ui/components/SharePanel/PeopleMenu.js.map +2 -2
- package/dist-cjs/lib/ui/components/Toolbar/AltTextEditor.js.map +2 -2
- package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbar.js +1 -1
- package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbar.js.map +2 -2
- package/dist-cjs/lib/ui/components/Toolbar/DefaultRichTextToolbar.js +1 -1
- package/dist-cjs/lib/ui/components/Toolbar/DefaultRichTextToolbar.js.map +2 -2
- package/dist-cjs/lib/ui/components/TopPanel/CenteredTopPanelContainer.js.map +1 -1
- package/dist-cjs/lib/ui/components/TopPanel/DefaultTopPanel.js +32 -0
- package/dist-cjs/lib/ui/components/TopPanel/DefaultTopPanel.js.map +7 -0
- package/dist-cjs/lib/ui/components/menu-items.js +1 -3
- package/dist-cjs/lib/ui/components/menu-items.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiContextualToolbar.js +1 -3
- package/dist-cjs/lib/ui/components/primitives/TldrawUiContextualToolbar.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 +93 -149
- package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuActionCheckboxItem.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuActionItem.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 +8 -7
- package/dist-cjs/lib/ui/context/actions.js.map +2 -2
- package/dist-cjs/lib/ui/context/components.js +2 -1
- package/dist-cjs/lib/ui/context/components.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/menu-hooks.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/useClipboardEvents.js +2 -2
- package/dist-cjs/lib/ui/hooks/useClipboardEvents.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/useFlatten.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/useKeyboardShortcuts.js +2 -2
- package/dist-cjs/lib/ui/hooks/useKeyboardShortcuts.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/useTools.js +5 -4
- 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 +6 -16
- 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 +2 -4
- package/dist-cjs/lib/utils/text/richText.js.map +2 -2
- package/dist-cjs/lib/utils/text/textDirection.js +51 -0
- package/dist-cjs/lib/utils/text/textDirection.js.map +7 -0
- package/dist-cjs/lib/utils/tldr/buildFromV1Document.js +2 -7
- package/dist-cjs/lib/utils/tldr/buildFromV1Document.js.map +2 -2
- package/dist-esm/index.d.mts +242 -311
- package/dist-esm/index.mjs +5 -14
- 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 +4 -8
- package/dist-esm/lib/canvas/TldrawSelectionForeground.mjs.map +2 -2
- package/dist-esm/lib/defaultEmbedDefinitions.mjs.map +2 -2
- package/dist-esm/lib/defaultExternalContentHandlers.mjs +5 -5
- package/dist-esm/lib/defaultExternalContentHandlers.mjs.map +2 -2
- package/dist-esm/lib/defaultSideEffects.mjs +1 -6
- package/dist-esm/lib/defaultSideEffects.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs +15 -15
- package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/arrowLabel.mjs +1 -1
- package/dist-esm/lib/shapes/arrow/arrowLabel.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/arrowTargetState.mjs +1 -1
- 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/Idle.mjs +10 -4
- package/dist-esm/lib/shapes/arrow/toolStates/Idle.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs +4 -7
- package/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/shapes/bookmark/BookmarkShapeUtil.mjs +1 -1
- package/dist-esm/lib/shapes/bookmark/BookmarkShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/bookmark/bookmarks.mjs.map +2 -2
- package/dist-esm/lib/shapes/draw/DrawShapeUtil.mjs +24 -29
- package/dist-esm/lib/shapes/draw/DrawShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/draw/getPath.mjs +11 -21
- package/dist-esm/lib/shapes/draw/getPath.mjs.map +2 -2
- package/dist-esm/lib/shapes/draw/toolStates/Drawing.mjs +86 -83
- package/dist-esm/lib/shapes/draw/toolStates/Drawing.mjs.map +3 -3
- package/dist-esm/lib/shapes/embed/EmbedShapeUtil.mjs +0 -6
- 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 +5 -6
- package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/geo/GeoShapeUtil.mjs +142 -147
- package/dist-esm/lib/shapes/geo/GeoShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/geo/toolStates/Idle.mjs +10 -5
- package/dist-esm/lib/shapes/geo/toolStates/Idle.mjs.map +2 -2
- package/dist-esm/lib/shapes/geo/toolStates/Pointing.mjs +3 -3
- package/dist-esm/lib/shapes/geo/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/shapes/highlight/HighlightShapeUtil.mjs +22 -24
- package/dist-esm/lib/shapes/highlight/HighlightShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/line/toolStates/Pointing.mjs +3 -3
- package/dist-esm/lib/shapes/line/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs +12 -7
- 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/note/toolStates/Pointing.mjs +10 -5
- package/dist-esm/lib/shapes/note/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/HyperlinkButton.mjs +3 -4
- package/dist-esm/lib/shapes/shared/HyperlinkButton.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/PlainTextLabel.mjs +2 -14
- package/dist-esm/lib/shapes/shared/PlainTextLabel.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/RichTextLabel.mjs +4 -12
- 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 +0 -1
- package/dist-esm/lib/shapes/shared/crop.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/interpolate-props.mjs +4 -4
- package/dist-esm/lib/shapes/shared/interpolate-props.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/useForceSolid.mjs +9 -0
- package/dist-esm/lib/shapes/shared/useForceSolid.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/RichTextArea.mjs +0 -5
- package/dist-esm/lib/shapes/text/RichTextArea.mjs.map +2 -2
- package/dist-esm/lib/shapes/text/TextShapeUtil.mjs +2 -5
- package/dist-esm/lib/shapes/text/TextShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/text/toolStates/Idle.mjs +10 -4
- package/dist-esm/lib/shapes/text/toolStates/Idle.mjs.map +2 -2
- package/dist-esm/lib/shapes/text/toolStates/Pointing.mjs +5 -7
- 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 +5 -4
- package/dist-esm/lib/tools/EraserTool/childStates/Erasing.mjs.map +2 -2
- package/dist-esm/lib/tools/EraserTool/childStates/Pointing.mjs +8 -3
- package/dist-esm/lib/tools/EraserTool/childStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/tools/HandTool/HandTool.mjs +5 -3
- package/dist-esm/lib/tools/HandTool/HandTool.mjs.map +2 -2
- package/dist-esm/lib/tools/HandTool/childStates/Dragging.mjs +2 -3
- package/dist-esm/lib/tools/HandTool/childStates/Dragging.mjs.map +2 -2
- package/dist-esm/lib/tools/HandTool/childStates/Pointing.mjs +1 -1
- package/dist-esm/lib/tools/HandTool/childStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/tools/LaserTool/childStates/Lasering.mjs +1 -1
- package/dist-esm/lib/tools/LaserTool/childStates/Lasering.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/DragAndDropManager.mjs +11 -10
- package/dist-esm/lib/tools/SelectTool/DragAndDropManager.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Brushing.mjs +5 -6
- package/dist-esm/lib/tools/SelectTool/childStates/Brushing.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/Cropping.mjs +6 -4
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/Cropping.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/Idle.mjs +1 -1
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/Idle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.mjs +1 -1
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCropHandle.mjs +1 -1
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/PointingCropHandle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.mjs +1 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.mjs +1 -1
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs +6 -8
- package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/EditingShape.mjs +11 -38
- package/dist-esm/lib/tools/SelectTool/childStates/EditingShape.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Idle.mjs +51 -43
- package/dist-esm/lib/tools/SelectTool/childStates/Idle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingArrowLabel.mjs +6 -6
- package/dist-esm/lib/tools/SelectTool/childStates/PointingArrowLabel.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingCanvas.mjs +1 -1
- package/dist-esm/lib/tools/SelectTool/childStates/PointingCanvas.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingHandle.mjs +19 -6
- package/dist-esm/lib/tools/SelectTool/childStates/PointingHandle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingResizeHandle.mjs +1 -1
- package/dist-esm/lib/tools/SelectTool/childStates/PointingResizeHandle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingRotateHandle.mjs +1 -1
- package/dist-esm/lib/tools/SelectTool/childStates/PointingRotateHandle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingSelection.mjs +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingSelection.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingShape.mjs +13 -4
- package/dist-esm/lib/tools/SelectTool/childStates/PointingShape.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs +6 -5
- package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Rotating.mjs +3 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Rotating.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/ScribbleBrushing.mjs +6 -7
- package/dist-esm/lib/tools/SelectTool/childStates/ScribbleBrushing.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs +11 -13
- package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/selectHelpers.mjs +4 -17
- package/dist-esm/lib/tools/SelectTool/selectHelpers.mjs.map +2 -2
- package/dist-esm/lib/tools/ZoomTool/ZoomTool.mjs +1 -1
- package/dist-esm/lib/tools/ZoomTool/ZoomTool.mjs.map +2 -2
- package/dist-esm/lib/tools/ZoomTool/childStates/Pointing.mjs +3 -3
- package/dist-esm/lib/tools/ZoomTool/childStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/tools/ZoomTool/childStates/ZoomBrushing.mjs +6 -5
- package/dist-esm/lib/tools/ZoomTool/childStates/ZoomBrushing.mjs.map +2 -2
- package/dist-esm/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.mjs +3 -1
- package/dist-esm/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.mjs.map +2 -2
- 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 +1 -1
- package/dist-esm/lib/tools/selection-logic/selectOnCanvasPointerUp.mjs.map +2 -2
- package/dist-esm/lib/tools/selection-logic/updateHoveredShapeId.mjs +1 -1
- package/dist-esm/lib/tools/selection-logic/updateHoveredShapeId.mjs.map +2 -2
- package/dist-esm/lib/ui/TldrawUi.mjs +2 -2
- package/dist-esm/lib/ui/TldrawUi.mjs.map +2 -2
- package/dist-esm/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.mjs +8 -2
- package/dist-esm/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.mjs.map +2 -2
- package/dist-esm/lib/ui/components/ContextMenu/DefaultContextMenu.mjs +3 -1
- package/dist-esm/lib/ui/components/ContextMenu/DefaultContextMenu.mjs.map +2 -2
- package/dist-esm/lib/ui/components/CursorChatBubble.mjs +1 -1
- package/dist-esm/lib/ui/components/CursorChatBubble.mjs.map +2 -2
- package/dist-esm/lib/ui/components/DefaultDebugPanel.mjs +30 -3
- package/dist-esm/lib/ui/components/DefaultDebugPanel.mjs.map +2 -2
- package/dist-esm/lib/ui/components/EditLinkDialog.mjs +1 -11
- package/dist-esm/lib/ui/components/EditLinkDialog.mjs.map +2 -2
- package/dist-esm/lib/ui/components/HelperButtons/StopFollowing.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Minimap/DefaultMinimap.mjs +1 -1
- package/dist-esm/lib/ui/components/Minimap/DefaultMinimap.mjs.map +2 -2
- package/dist-esm/lib/ui/components/OfflineIndicator/OfflineIndicator.mjs +6 -3
- package/dist-esm/lib/ui/components/OfflineIndicator/OfflineIndicator.mjs.map +2 -2
- package/dist-esm/lib/ui/components/PageMenu/PageItemInput.mjs +1 -3
- package/dist-esm/lib/ui/components/PageMenu/PageItemInput.mjs.map +2 -2
- package/dist-esm/lib/ui/components/SharePanel/PeopleMenu.mjs +0 -6
- package/dist-esm/lib/ui/components/SharePanel/PeopleMenu.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Toolbar/AltTextEditor.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbar.mjs +1 -1
- package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbar.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Toolbar/DefaultRichTextToolbar.mjs +1 -1
- package/dist-esm/lib/ui/components/Toolbar/DefaultRichTextToolbar.mjs.map +2 -2
- package/dist-esm/lib/ui/components/TopPanel/CenteredTopPanelContainer.mjs.map +1 -1
- package/dist-esm/lib/ui/components/TopPanel/DefaultTopPanel.mjs +12 -0
- package/dist-esm/lib/ui/components/TopPanel/DefaultTopPanel.mjs.map +7 -0
- package/dist-esm/lib/ui/components/menu-items.mjs +5 -4
- package/dist-esm/lib/ui/components/menu-items.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiContextualToolbar.mjs +1 -3
- package/dist-esm/lib/ui/components/primitives/TldrawUiContextualToolbar.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 +95 -157
- package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuActionCheckboxItem.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuActionItem.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 +8 -7
- package/dist-esm/lib/ui/context/actions.mjs.map +2 -2
- package/dist-esm/lib/ui/context/components.mjs +2 -1
- package/dist-esm/lib/ui/context/components.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/menu-hooks.mjs +4 -1
- package/dist-esm/lib/ui/hooks/menu-hooks.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/useClipboardEvents.mjs +2 -2
- package/dist-esm/lib/ui/hooks/useClipboardEvents.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/useFlatten.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/useKeyboardShortcuts.mjs +2 -2
- package/dist-esm/lib/ui/hooks/useKeyboardShortcuts.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/useTools.mjs +5 -4
- 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 +6 -17
- package/dist-esm/lib/utils/excalidraw/putExcalidrawContent.mjs.map +2 -2
- package/dist-esm/lib/utils/export/exportAs.mjs +3 -1
- 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 +2 -5
- package/dist-esm/lib/utils/text/richText.mjs.map +2 -2
- package/dist-esm/lib/utils/text/textDirection.mjs +31 -0
- package/dist-esm/lib/utils/text/textDirection.mjs.map +7 -0
- package/dist-esm/lib/utils/tldr/buildFromV1Document.mjs +2 -8
- package/dist-esm/lib/utils/tldr/buildFromV1Document.mjs.map +2 -2
- package/package.json +16 -18
- package/src/index.ts +2 -6
- package/src/lib/Tldraw.test.tsx +1 -46
- package/src/lib/bindings/arrow/ArrowBindingUtil.ts +1 -1
- package/src/lib/canvas/TldrawSelectionForeground.tsx +9 -20
- package/src/lib/defaultEmbedDefinitions.ts +0 -1
- package/src/lib/defaultExternalContentHandlers.ts +14 -13
- package/src/lib/defaultSideEffects.ts +1 -6
- package/src/lib/shapes/arrow/ArrowShapeOptions.test.ts +133 -40
- package/src/lib/shapes/arrow/ArrowShapeTool.test.ts +8 -8
- package/src/lib/shapes/arrow/ArrowShapeUtil.test.ts +2 -2
- package/src/lib/shapes/arrow/ArrowShapeUtil.tsx +16 -16
- package/src/lib/shapes/arrow/arrow-types.ts +0 -2
- package/src/lib/shapes/arrow/arrowLabel.ts +2 -2
- package/src/lib/shapes/arrow/arrowTargetState.ts +2 -2
- 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/Idle.tsx +14 -4
- package/src/lib/shapes/arrow/toolStates/Pointing.tsx +5 -8
- package/src/lib/shapes/bookmark/BookmarkShapeUtil.tsx +1 -1
- package/src/lib/shapes/bookmark/bookmarks.ts +3 -3
- package/src/lib/shapes/draw/DrawShapeUtil.tsx +26 -30
- package/src/lib/shapes/draw/getPath.ts +10 -31
- package/src/lib/shapes/draw/toolStates/Drawing.ts +90 -100
- package/src/lib/shapes/embed/EmbedShapeUtil.tsx +1 -8
- package/src/lib/shapes/frame/FrameShapeTool.ts +1 -1
- package/src/lib/shapes/frame/FrameShapeUtil.tsx +4 -10
- package/src/lib/shapes/geo/GeoShapeUtil.test.tsx +2 -10
- package/src/lib/shapes/geo/GeoShapeUtil.tsx +176 -228
- package/src/lib/shapes/geo/toolStates/Idle.ts +15 -5
- package/src/lib/shapes/geo/toolStates/Pointing.ts +6 -6
- package/src/lib/shapes/highlight/HighlightShapeUtil.tsx +24 -25
- 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 +4 -4
- package/src/lib/shapes/note/NoteShapeTool.test.ts +1 -2
- package/src/lib/shapes/note/NoteShapeUtil.tsx +10 -9
- package/src/lib/shapes/note/noteCloning.test.ts +1 -3
- package/src/lib/shapes/note/noteHelpers.ts +2 -2
- package/src/lib/shapes/note/toolStates/Pointing.ts +10 -5
- package/src/lib/shapes/shared/HyperlinkButton.tsx +3 -4
- package/src/lib/shapes/shared/PlainTextLabel.tsx +2 -12
- package/src/lib/shapes/shared/RichTextLabel.tsx +4 -14
- package/src/lib/shapes/shared/ShapeFill.tsx +2 -2
- package/src/lib/shapes/shared/crop.ts +0 -1
- package/src/lib/shapes/shared/interpolate-props.ts +4 -4
- package/src/lib/shapes/shared/useEditablePlainText.ts +3 -7
- package/src/lib/shapes/shared/useEditableRichText.ts +3 -7
- package/src/lib/shapes/shared/useForceSolid.ts +6 -0
- package/src/lib/shapes/shared/useImageOrVideoAsset.ts +1 -1
- package/src/lib/shapes/text/RichTextArea.tsx +0 -5
- package/src/lib/shapes/text/TextShapeTool.test.ts +4 -4
- package/src/lib/shapes/text/TextShapeUtil.tsx +0 -5
- package/src/lib/shapes/text/toolStates/Idle.ts +14 -4
- package/src/lib/shapes/text/toolStates/Pointing.ts +8 -8
- package/src/lib/shapes/video/VideoShapeUtil.tsx +1 -2
- package/src/lib/tools/EraserTool/childStates/Erasing.ts +10 -7
- package/src/lib/tools/EraserTool/childStates/Pointing.ts +20 -5
- package/src/lib/tools/HandTool/HandTool.ts +5 -3
- package/src/lib/tools/HandTool/childStates/Dragging.ts +2 -3
- package/src/lib/tools/HandTool/childStates/Pointing.ts +1 -1
- package/src/lib/tools/LaserTool/childStates/Lasering.ts +1 -1
- package/src/lib/tools/SelectTool/DragAndDropManager.ts +11 -14
- package/src/lib/tools/SelectTool/childStates/Brushing.ts +11 -8
- package/src/lib/tools/SelectTool/childStates/Crop/children/Cropping.ts +6 -7
- package/src/lib/tools/SelectTool/childStates/Crop/children/Idle.ts +4 -3
- package/src/lib/tools/SelectTool/childStates/Crop/children/PointingCrop.ts +1 -1
- package/src/lib/tools/SelectTool/childStates/Crop/children/PointingCropHandle.ts +1 -1
- package/src/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.ts +1 -2
- package/src/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.ts +1 -1
- package/src/lib/tools/SelectTool/childStates/DraggingHandle.tsx +12 -11
- package/src/lib/tools/SelectTool/childStates/EditingShape.ts +16 -57
- package/src/lib/tools/SelectTool/childStates/Idle.ts +81 -64
- package/src/lib/tools/SelectTool/childStates/PointingArrowLabel.ts +8 -7
- package/src/lib/tools/SelectTool/childStates/PointingCanvas.ts +1 -1
- package/src/lib/tools/SelectTool/childStates/PointingHandle.ts +17 -9
- package/src/lib/tools/SelectTool/childStates/PointingResizeHandle.ts +1 -1
- package/src/lib/tools/SelectTool/childStates/PointingRotateHandle.ts +1 -1
- package/src/lib/tools/SelectTool/childStates/PointingSelection.ts +4 -4
- package/src/lib/tools/SelectTool/childStates/PointingShape.ts +14 -4
- package/src/lib/tools/SelectTool/childStates/Resizing.ts +10 -8
- package/src/lib/tools/SelectTool/childStates/Rotating.ts +3 -2
- package/src/lib/tools/SelectTool/childStates/ScribbleBrushing.ts +10 -9
- package/src/lib/tools/SelectTool/childStates/Translating.ts +15 -16
- package/src/lib/tools/SelectTool/selectHelpers.ts +4 -39
- package/src/lib/tools/ZoomTool/ZoomTool.ts +1 -1
- package/src/lib/tools/ZoomTool/childStates/Pointing.ts +3 -3
- package/src/lib/tools/ZoomTool/childStates/ZoomBrushing.ts +6 -5
- package/src/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.ts +3 -1
- package/src/lib/tools/selection-logic/getShouldEnterCropModeOnPointerDown.ts +10 -0
- package/src/lib/tools/selection-logic/selectOnCanvasPointerUp.ts +1 -1
- package/src/lib/tools/selection-logic/updateHoveredShapeId.ts +1 -1
- package/src/lib/ui/TldrawUi.tsx +2 -5
- package/src/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.tsx +9 -1
- package/src/lib/ui/components/ContextMenu/DefaultContextMenu.tsx +3 -1
- package/src/lib/ui/components/CursorChatBubble.tsx +2 -2
- package/src/lib/ui/components/DefaultDebugPanel.tsx +42 -3
- package/src/lib/ui/components/EditLinkDialog.tsx +6 -16
- package/src/lib/ui/components/HelperButtons/StopFollowing.tsx +2 -2
- package/src/lib/ui/components/Minimap/DefaultMinimap.tsx +1 -1
- package/src/lib/ui/components/OfflineIndicator/OfflineIndicator.tsx +5 -6
- package/src/lib/ui/components/PageMenu/PageItemInput.tsx +1 -3
- package/src/lib/ui/components/SharePanel/PeopleMenu.tsx +0 -8
- package/src/lib/ui/components/Toolbar/AltTextEditor.tsx +2 -2
- package/src/lib/ui/components/Toolbar/DefaultImageToolbar.tsx +1 -1
- package/src/lib/ui/components/Toolbar/DefaultRichTextToolbar.tsx +1 -1
- package/src/lib/ui/components/TopPanel/CenteredTopPanelContainer.tsx +1 -1
- package/src/lib/ui/components/TopPanel/DefaultTopPanel.tsx +10 -0
- package/src/lib/ui/components/menu-items.tsx +15 -9
- package/src/lib/ui/components/primitives/TldrawUiContextualToolbar.tsx +3 -5
- package/src/lib/ui/components/primitives/TldrawUiSlider.tsx +2 -2
- package/src/lib/ui/components/primitives/TldrawUiTooltip.tsx +113 -208
- package/src/lib/ui/components/primitives/menus/TldrawUiMenuActionCheckboxItem.tsx +1 -1
- package/src/lib/ui/components/primitives/menus/TldrawUiMenuActionItem.tsx +1 -1
- package/src/lib/ui/components/primitives/menus/TldrawUiMenuItem.tsx +2 -2
- package/src/lib/ui/context/actions.tsx +19 -15
- package/src/lib/ui/context/components.tsx +2 -1
- package/src/lib/ui/hooks/menu-hooks.ts +19 -9
- package/src/lib/ui/hooks/useClipboardEvents.ts +2 -2
- package/src/lib/ui/hooks/useFlatten.ts +2 -1
- package/src/lib/ui/hooks/useKeyboardShortcuts.ts +2 -2
- package/src/lib/ui/hooks/useTools.tsx +7 -5
- package/src/lib/ui/version.ts +3 -3
- package/src/lib/ui.css +29 -31
- package/src/lib/utils/excalidraw/__snapshots__/putExcalidrawContent.test.tsx.snap +48 -12
- package/src/lib/utils/excalidraw/putExcalidrawContent.ts +6 -19
- package/src/lib/utils/export/exportAs.ts +9 -2
- package/src/lib/utils/frames/frames.ts +1 -1
- package/src/lib/utils/text/richText.ts +5 -6
- package/src/lib/utils/text/textDirection.ts +32 -0
- package/src/lib/utils/tldr/buildFromV1Document.ts +19 -21
- package/src/test/Editor.test.tsx +41 -78
- package/src/test/EraserTool.test.ts +12 -10
- package/src/test/SelectTool.test.ts +19 -11
- package/src/test/TestEditor.ts +51 -49
- package/src/test/TldrawEditor.test.tsx +20 -24
- package/src/test/__snapshots__/drawing.test.ts.snap +1257 -3
- package/src/test/__snapshots__/resizing.test.ts.snap +12 -3
- package/src/test/arrows-megabus.test.tsx +1 -1
- package/src/test/bindings.test.tsx +25 -29
- package/src/test/bindingsIndex.test.tsx +4 -4
- package/src/test/commands/__snapshots__/getSvgString.test.ts.snap +10 -10
- package/src/test/commands/createShapes.test.ts +1 -15
- package/src/test/commands/getSvgString.test.ts +2 -2
- package/src/test/commands/putContent.test.ts +1 -80
- package/src/test/commands/setCamera.test.ts +11 -13
- package/src/test/commands/stackShapes.test.ts +8 -34
- package/src/test/commands/updateShapes.test.ts +5 -21
- package/src/test/commands/zoomToBounds.test.ts +3 -19
- package/src/test/commands/zoomToSelection.test.ts +3 -14
- package/src/test/custom-clipping.test.ts +44 -52
- package/src/test/customSnapping.test.tsx +62 -77
- package/src/test/drawing.test.ts +10 -17
- package/src/test/duplicate.test.ts +1 -1
- package/src/test/flipShapes.test.ts +0 -33
- package/src/test/frames.test.ts +2 -94
- package/src/test/getCulledShapes.test.tsx +3 -11
- package/src/test/getShapeAtPoint.test.ts +2 -2
- package/src/test/groups.test.tsx +4 -7
- package/src/test/modifiers.test.ts +6 -6
- package/src/test/resizing.test.ts +22 -16
- package/src/test/selection-omnibus.test.ts +13 -13
- package/src/test/shapeutils.test.ts +1 -1
- package/src/test/spacebarPanning.test.ts +10 -28
- package/src/test/styles2.test.tsx +1 -1
- package/src/test/styles3.test.ts +5 -5
- package/src/test/test-jsx.tsx +57 -72
- package/src/test/text.test.ts +17 -15
- package/src/test/translating.test.ts +8 -6
- package/tldraw.css +41 -45
- package/dist-cjs/lib/shapes/shared/useEfficientZoomThreshold.js.map +0 -7
- package/dist-cjs/lib/utils/test-helpers.js.map +0 -7
- package/dist-esm/lib/shapes/shared/useEfficientZoomThreshold.mjs +0 -12
- package/dist-esm/lib/shapes/shared/useEfficientZoomThreshold.mjs.map +0 -7
- package/dist-esm/lib/utils/test-helpers.mjs +0 -21
- package/dist-esm/lib/utils/test-helpers.mjs.map +0 -7
- package/src/lib/shapes/draw/DrawShapeUtil.test.ts +0 -146
- package/src/lib/shapes/highlight/HighlightShapeUtil.test.ts +0 -146
- package/src/lib/shapes/shared/useEfficientZoomThreshold.ts +0 -10
- package/src/lib/utils/test-helpers.ts +0 -60
- package/src/test/commands/cameraState.test.ts +0 -299
- package/src/test/commands/createShape.test.ts +0 -64
- package/src/test/commands/isShapeOfType.test.ts +0 -44
- package/src/test/commands/updateShape.test.ts +0 -67
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../src/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.ts"],
|
|
4
|
-
"sourcesContent": ["import { ShapeWithCrop, StateNode, TLKeyboardEventInfo, TLPointerEventInfo } from '@tldraw/editor'\nimport { getTranslateCroppedImageChange } from './crop_helpers'\n\ntype Snapshot = ReturnType<TranslatingCrop['createSnapshot']>\n\nexport class TranslatingCrop extends StateNode {\n\tstatic override id = 'translating_crop'\n\n\tinfo = {} as TLPointerEventInfo & {\n\t\ttarget: 'shape'\n\t\tisCreating?: boolean\n\t\tonInteractionEnd?: string\n\t}\n\n\tmarkId = ''\n\n\tprivate snapshot = {} as any as Snapshot\n\n\toverride onEnter(\n\t\tinfo: TLPointerEventInfo & {\n\t\t\ttarget: 'shape'\n\t\t\tisCreating?: boolean\n\t\t\tonInteractionEnd?: string\n\t\t}\n\t) {\n\t\tthis.info = info\n\t\tthis.snapshot = this.createSnapshot()\n\n\t\tthis.markId = this.editor.markHistoryStoppingPoint('translating_crop')\n\t\tthis.editor.setCursor({ type: 'move', rotation: 0 })\n\t\tthis.updateShapes()\n\t}\n\n\toverride onExit() {\n\t\tthis.editor.setCursor({ type: 'default', rotation: 0 })\n\t}\n\n\toverride onPointerMove() {\n\t\tthis.updateShapes()\n\t}\n\n\toverride onPointerUp() {\n\t\tthis.complete()\n\t}\n\n\toverride onComplete() {\n\t\tthis.complete()\n\t}\n\n\toverride onCancel() {\n\t\tthis.cancel()\n\t}\n\n\toverride onKeyDown(info: TLKeyboardEventInfo) {\n\t\tswitch (info.key) {\n\t\t\tcase 'Alt':\n\t\t\tcase 'Shift': {\n\t\t\t\tthis.updateShapes()\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\n\toverride onKeyUp(info: TLKeyboardEventInfo) {\n\t\tswitch (info.key) {\n\t\t\tcase 'Enter': {\n\t\t\t\tthis.complete()\n\t\t\t\treturn\n\t\t\t}\n\t\t\tcase 'Alt':\n\t\t\tcase 'Shift': {\n\t\t\t\tthis.updateShapes()\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected complete() {\n\t\tthis.updateShapes()\n\t\tthis.editor.setCurrentTool('select.crop.idle', this.info)\n\t}\n\n\tprivate cancel() {\n\t\tthis.editor.bailToMark(this.markId)\n\t\tthis.editor.setCurrentTool('select.crop.idle', this.info)\n\t}\n\n\tprivate createSnapshot() {\n\t\tconst shape = this.editor.getOnlySelectedShape() as ShapeWithCrop\n\t\treturn { shape }\n\t}\n\n\tprotected updateShapes() {\n\t\tconst shape = this.snapshot.shape as ShapeWithCrop\n\n\t\tif (!shape) return\n\n\t\tconst originPagePoint
|
|
5
|
-
"mappings": "AAAA,SAAwB,iBAA0D;AAClF,SAAS,sCAAsC;AAIxC,MAAM,wBAAwB,UAAU;AAAA,EAC9C,OAAgB,KAAK;AAAA,EAErB,OAAO,CAAC;AAAA,EAMR,SAAS;AAAA,EAED,WAAW,CAAC;AAAA,EAEX,QACR,MAKC;AACD,SAAK,OAAO;AACZ,SAAK,WAAW,KAAK,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from '@tldraw/editor'\nimport { getTranslateCroppedImageChange } from './crop_helpers'\n\ntype Snapshot = ReturnType<TranslatingCrop['createSnapshot']>\n\nexport class TranslatingCrop extends StateNode {\n\tstatic override id = 'translating_crop'\n\n\tinfo = {} as TLPointerEventInfo & {\n\t\ttarget: 'shape'\n\t\tisCreating?: boolean\n\t\tonInteractionEnd?: string\n\t}\n\n\tmarkId = ''\n\n\tprivate snapshot = {} as any as Snapshot\n\n\toverride onEnter(\n\t\tinfo: TLPointerEventInfo & {\n\t\t\ttarget: 'shape'\n\t\t\tisCreating?: boolean\n\t\t\tonInteractionEnd?: string\n\t\t}\n\t) {\n\t\tthis.info = info\n\t\tthis.snapshot = this.createSnapshot()\n\n\t\tthis.markId = this.editor.markHistoryStoppingPoint('translating_crop')\n\t\tthis.editor.setCursor({ type: 'move', rotation: 0 })\n\t\tthis.updateShapes()\n\t}\n\n\toverride onExit() {\n\t\tthis.editor.setCursor({ type: 'default', rotation: 0 })\n\t}\n\n\toverride onPointerMove() {\n\t\tthis.updateShapes()\n\t}\n\n\toverride onPointerUp() {\n\t\tthis.complete()\n\t}\n\n\toverride onComplete() {\n\t\tthis.complete()\n\t}\n\n\toverride onCancel() {\n\t\tthis.cancel()\n\t}\n\n\toverride onKeyDown(info: TLKeyboardEventInfo) {\n\t\tswitch (info.key) {\n\t\t\tcase 'Alt':\n\t\t\tcase 'Shift': {\n\t\t\t\tthis.updateShapes()\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\n\toverride onKeyUp(info: TLKeyboardEventInfo) {\n\t\tswitch (info.key) {\n\t\t\tcase 'Enter': {\n\t\t\t\tthis.complete()\n\t\t\t\treturn\n\t\t\t}\n\t\t\tcase 'Alt':\n\t\t\tcase 'Shift': {\n\t\t\t\tthis.updateShapes()\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected complete() {\n\t\tthis.updateShapes()\n\t\tthis.editor.setCurrentTool('select.crop.idle', this.info)\n\t}\n\n\tprivate cancel() {\n\t\tthis.editor.bailToMark(this.markId)\n\t\tthis.editor.setCurrentTool('select.crop.idle', this.info)\n\t}\n\n\tprivate createSnapshot() {\n\t\tconst shape = this.editor.getOnlySelectedShape() as ShapeWithCrop\n\t\treturn { shape }\n\t}\n\n\tprotected updateShapes() {\n\t\tconst shape = this.snapshot.shape as ShapeWithCrop\n\n\t\tif (!shape) return\n\n\t\tconst { originPagePoint, currentPagePoint } = this.editor.inputs\n\t\tconst delta = currentPagePoint.clone().sub(originPagePoint)\n\t\tconst partial = getTranslateCroppedImageChange(this.editor, shape, delta)\n\n\t\tif (partial) {\n\t\t\tthis.editor.updateShapes([partial])\n\t\t}\n\t}\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAwB,iBAA0D;AAClF,SAAS,sCAAsC;AAIxC,MAAM,wBAAwB,UAAU;AAAA,EAC9C,OAAgB,KAAK;AAAA,EAErB,OAAO,CAAC;AAAA,EAMR,SAAS;AAAA,EAED,WAAW,CAAC;AAAA,EAEX,QACR,MAKC;AACD,SAAK,OAAO;AACZ,SAAK,WAAW,KAAK,eAAe;AAEpC,SAAK,SAAS,KAAK,OAAO,yBAAyB,kBAAkB;AACrE,SAAK,OAAO,UAAU,EAAE,MAAM,QAAQ,UAAU,EAAE,CAAC;AACnD,SAAK,aAAa;AAAA,EACnB;AAAA,EAES,SAAS;AACjB,SAAK,OAAO,UAAU,EAAE,MAAM,WAAW,UAAU,EAAE,CAAC;AAAA,EACvD;AAAA,EAES,gBAAgB;AACxB,SAAK,aAAa;AAAA,EACnB;AAAA,EAES,cAAc;AACtB,SAAK,SAAS;AAAA,EACf;AAAA,EAES,aAAa;AACrB,SAAK,SAAS;AAAA,EACf;AAAA,EAES,WAAW;AACnB,SAAK,OAAO;AAAA,EACb;AAAA,EAES,UAAU,MAA2B;AAC7C,YAAQ,KAAK,KAAK;AAAA,MACjB,KAAK;AAAA,MACL,KAAK,SAAS;AACb,aAAK,aAAa;AAClB;AAAA,MACD;AAAA,IACD;AAAA,EACD;AAAA,EAES,QAAQ,MAA2B;AAC3C,YAAQ,KAAK,KAAK;AAAA,MACjB,KAAK,SAAS;AACb,aAAK,SAAS;AACd;AAAA,MACD;AAAA,MACA,KAAK;AAAA,MACL,KAAK,SAAS;AACb,aAAK,aAAa;AAAA,MACnB;AAAA,IACD;AAAA,EACD;AAAA,EAEU,WAAW;AACpB,SAAK,aAAa;AAClB,SAAK,OAAO,eAAe,oBAAoB,KAAK,IAAI;AAAA,EACzD;AAAA,EAEQ,SAAS;AAChB,SAAK,OAAO,WAAW,KAAK,MAAM;AAClC,SAAK,OAAO,eAAe,oBAAoB,KAAK,IAAI;AAAA,EACzD;AAAA,EAEQ,iBAAiB;AACxB,UAAM,QAAQ,KAAK,OAAO,qBAAqB;AAC/C,WAAO,EAAE,MAAM;AAAA,EAChB;AAAA,EAEU,eAAe;AACxB,UAAM,QAAQ,KAAK,SAAS;AAE5B,QAAI,CAAC,MAAO;AAEZ,UAAM,EAAE,iBAAiB,iBAAiB,IAAI,KAAK,OAAO;AAC1D,UAAM,QAAQ,iBAAiB,MAAM,EAAE,IAAI,eAAe;AAC1D,UAAM,UAAU,+BAA+B,KAAK,QAAQ,OAAO,KAAK;AAExE,QAAI,SAAS;AACZ,WAAK,OAAO,aAAa,CAAC,OAAO,CAAC;AAAA,IACnC;AAAA,EACD;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -8,7 +8,7 @@ function getTranslateCroppedImageChange(editor, shape, delta) {
|
|
|
8
8
|
if (!oldCrop) {
|
|
9
9
|
return;
|
|
10
10
|
}
|
|
11
|
-
const flatten = editor.inputs.
|
|
11
|
+
const flatten = editor.inputs.shiftKey ? Math.abs(delta.x) < Math.abs(delta.y) ? "x" : "y" : null;
|
|
12
12
|
if (flatten === "x") {
|
|
13
13
|
delta.x = 0;
|
|
14
14
|
} else if (flatten === "y") {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../src/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.ts"],
|
|
4
|
-
"sourcesContent": ["import { Editor, ShapeWithCrop, TLShapePartial, Vec, clamp, structuredClone } from '@tldraw/editor'\nimport { getUncroppedSize } from '../../../../../shapes/shared/crop'\n\nexport function getTranslateCroppedImageChange(editor: Editor, shape: ShapeWithCrop, delta: Vec) {\n\tif (!shape) {\n\t\tthrow Error('Needs to translate a cropped shape!')\n\t}\n\n\tconst { crop: oldCrop } = shape.props\n\tif (!oldCrop) {\n\t\t// can't translate a shape that doesn't have an existing crop\n\t\treturn\n\t}\n\n\tconst flatten: 'x' | 'y' | null = editor.inputs.
|
|
5
|
-
"mappings": "AAAA,SAAqD,OAAO,uBAAuB;AACnF,SAAS,wBAAwB;AAE1B,SAAS,+BAA+B,QAAgB,OAAsB,OAAY;AAChG,MAAI,CAAC,OAAO;AACX,UAAM,MAAM,qCAAqC;AAAA,EAClD;AAEA,QAAM,EAAE,MAAM,QAAQ,IAAI,MAAM;AAChC,MAAI,CAAC,SAAS;AAEb;AAAA,EACD;AAEA,QAAM,UAA4B,OAAO,OAAO,
|
|
4
|
+
"sourcesContent": ["import { Editor, ShapeWithCrop, TLShapePartial, Vec, clamp, structuredClone } from '@tldraw/editor'\nimport { getUncroppedSize } from '../../../../../shapes/shared/crop'\n\nexport function getTranslateCroppedImageChange(editor: Editor, shape: ShapeWithCrop, delta: Vec) {\n\tif (!shape) {\n\t\tthrow Error('Needs to translate a cropped shape!')\n\t}\n\n\tconst { crop: oldCrop } = shape.props\n\tif (!oldCrop) {\n\t\t// can't translate a shape that doesn't have an existing crop\n\t\treturn\n\t}\n\n\tconst flatten: 'x' | 'y' | null = editor.inputs.shiftKey\n\t\t? Math.abs(delta.x) < Math.abs(delta.y)\n\t\t\t? 'x'\n\t\t\t: 'y'\n\t\t: null\n\n\tif (flatten === 'x') {\n\t\tdelta.x = 0\n\t} else if (flatten === 'y') {\n\t\tdelta.y = 0\n\t}\n\n\tdelta.rot(-shape.rotation)\n\n\tconst { w, h } = getUncroppedSize(shape.props, oldCrop)\n\tconst xCropSize = oldCrop.bottomRight.x - oldCrop.topLeft.x\n\tconst yCropSize = oldCrop.bottomRight.y - oldCrop.topLeft.y\n\tconst newCrop = structuredClone(oldCrop)\n\n\tconst xMinWithCrop = 1 - xCropSize\n\tconst yMinWithCrop = 1 - yCropSize\n\tnewCrop.topLeft.x = clamp(newCrop.topLeft.x - delta.x / w, 0, xMinWithCrop)\n\tnewCrop.topLeft.y = clamp(newCrop.topLeft.y - delta.y / h, 0, yMinWithCrop)\n\n\tnewCrop.bottomRight.x = newCrop.topLeft.x + xCropSize\n\tnewCrop.bottomRight.y = newCrop.topLeft.y + yCropSize\n\n\tconst partial: TLShapePartial<typeof shape> = {\n\t\tid: shape.id,\n\t\ttype: shape.type,\n\t\tprops: {\n\t\t\tcrop: newCrop,\n\t\t},\n\t}\n\n\treturn partial\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAqD,OAAO,uBAAuB;AACnF,SAAS,wBAAwB;AAE1B,SAAS,+BAA+B,QAAgB,OAAsB,OAAY;AAChG,MAAI,CAAC,OAAO;AACX,UAAM,MAAM,qCAAqC;AAAA,EAClD;AAEA,QAAM,EAAE,MAAM,QAAQ,IAAI,MAAM;AAChC,MAAI,CAAC,SAAS;AAEb;AAAA,EACD;AAEA,QAAM,UAA4B,OAAO,OAAO,WAC7C,KAAK,IAAI,MAAM,CAAC,IAAI,KAAK,IAAI,MAAM,CAAC,IACnC,MACA,MACD;AAEH,MAAI,YAAY,KAAK;AACpB,UAAM,IAAI;AAAA,EACX,WAAW,YAAY,KAAK;AAC3B,UAAM,IAAI;AAAA,EACX;AAEA,QAAM,IAAI,CAAC,MAAM,QAAQ;AAEzB,QAAM,EAAE,GAAG,EAAE,IAAI,iBAAiB,MAAM,OAAO,OAAO;AACtD,QAAM,YAAY,QAAQ,YAAY,IAAI,QAAQ,QAAQ;AAC1D,QAAM,YAAY,QAAQ,YAAY,IAAI,QAAQ,QAAQ;AAC1D,QAAM,UAAU,gBAAgB,OAAO;AAEvC,QAAM,eAAe,IAAI;AACzB,QAAM,eAAe,IAAI;AACzB,UAAQ,QAAQ,IAAI,MAAM,QAAQ,QAAQ,IAAI,MAAM,IAAI,GAAG,GAAG,YAAY;AAC1E,UAAQ,QAAQ,IAAI,MAAM,QAAQ,QAAQ,IAAI,MAAM,IAAI,GAAG,GAAG,YAAY;AAE1E,UAAQ,YAAY,IAAI,QAAQ,QAAQ,IAAI;AAC5C,UAAQ,YAAY,IAAI,QAAQ,QAAQ,IAAI;AAE5C,QAAM,UAAwC;AAAA,IAC7C,IAAI,MAAM;AAAA,IACV,MAAM,MAAM;AAAA,IACZ,OAAO;AAAA,MACN,MAAM;AAAA,IACP;AAAA,EACD;AAEA,SAAO;AACR;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -47,7 +47,7 @@ class DraggingHandle extends StateNode {
|
|
|
47
47
|
this.initialHandle = structuredClone(handle);
|
|
48
48
|
this.initialPageTransform = this.editor.getShapePageTransform(shape);
|
|
49
49
|
this.initialPageRotation = this.initialPageTransform.rotation();
|
|
50
|
-
this.initialPagePoint = this.editor.inputs.
|
|
50
|
+
this.initialPagePoint = this.editor.inputs.originPagePoint.clone();
|
|
51
51
|
this.editor.setCursor({ type: isCreating ? "cross" : "grabbing", rotation: 0 });
|
|
52
52
|
const handles = this.editor.getShapeHandles(shape).sort(sortByIndex);
|
|
53
53
|
const index = handles.findIndex((h) => h.id === info.handle.id);
|
|
@@ -166,7 +166,7 @@ class DraggingHandle extends StateNode {
|
|
|
166
166
|
};
|
|
167
167
|
const endChanges = util.onHandleDragEnd?.(shape, handleDragInfo);
|
|
168
168
|
if (endChanges) {
|
|
169
|
-
this.editor.updateShapes([{ ...endChanges, id: shape.id }]);
|
|
169
|
+
this.editor.updateShapes([{ ...endChanges, id: shape.id, type: shape.type }]);
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
172
|
const { onInteractionEnd } = this.info;
|
|
@@ -212,12 +212,10 @@ class DraggingHandle extends StateNode {
|
|
|
212
212
|
const { editor, shapeId, initialPagePoint } = this;
|
|
213
213
|
const { initialHandle, initialPageRotation, initialAdjacentHandle } = this;
|
|
214
214
|
const isSnapMode = this.editor.user.getIsSnapMode();
|
|
215
|
-
const {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
const altKey = editor.inputs.getAltKey();
|
|
220
|
-
const pointerVelocity = editor.inputs.getPointerVelocity();
|
|
215
|
+
const {
|
|
216
|
+
snaps,
|
|
217
|
+
inputs: { currentPagePoint, shiftKey, ctrlKey, altKey, pointerVelocity }
|
|
218
|
+
} = editor;
|
|
221
219
|
const initial = this.info.shape;
|
|
222
220
|
const shape = editor.getShape(shapeId);
|
|
223
221
|
if (!shape) return;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/lib/tools/SelectTool/childStates/DraggingHandle.tsx"],
|
|
4
|
-
"sourcesContent": ["import {\n\tMat,\n\tStateNode,\n\tTLArrowShape,\n\tTLHandle,\n\tTLLineShape,\n\tTLPointerEventInfo,\n\tTLShapeId,\n\tTLShapePartial,\n\tVec,\n\tkickoutOccludedShapes,\n\tsnapAngle,\n\tsortByIndex,\n\tstructuredClone,\n\twarnOnce,\n} from '@tldraw/editor'\nimport { ArrowShapeUtil } from '../../../shapes/arrow/ArrowShapeUtil'\nimport { clearArrowTargetState } from '../../../shapes/arrow/arrowTargetState'\nimport { getArrowBindings } from '../../../shapes/arrow/shared'\n\nexport type DraggingHandleInfo = TLPointerEventInfo & {\n\tshape: TLArrowShape | TLLineShape\n\ttarget: 'handle'\n\tonInteractionEnd?: string | (() => void)\n\tisCreating?: boolean\n\tcreatingMarkId?: string\n}\n\nexport class DraggingHandle extends StateNode {\n\tstatic override id = 'dragging_handle'\n\n\tshapeId!: TLShapeId\n\tinitialHandle!: TLHandle\n\tinitialAdjacentHandle!: TLHandle | null\n\tinitialPagePoint!: Vec\n\n\tmarkId!: string\n\tinitialPageTransform!: Mat\n\tinitialPageRotation!: number\n\n\tinfo!: DraggingHandleInfo\n\n\tisPrecise = false\n\tisPreciseId: TLShapeId | null = null\n\tpointingId: TLShapeId | null = null\n\n\toverride onEnter(info: DraggingHandleInfo) {\n\t\tconst { shape, isCreating, creatingMarkId, handle } = info\n\t\tthis.info = info\n\t\tif (typeof info.onInteractionEnd === 'string') {\n\t\t\tthis.parent.setCurrentToolIdMask(info.onInteractionEnd)\n\t\t}\n\t\tthis.shapeId = shape.id\n\t\tthis.markId = ''\n\n\t\tif (isCreating) {\n\t\t\tif (creatingMarkId) {\n\t\t\t\tthis.markId = creatingMarkId\n\t\t\t} else {\n\t\t\t\t// handle legacy implicit `creating:{shapeId}` marks\n\t\t\t\tconst markId = this.editor.getMarkIdMatching(\n\t\t\t\t\t`creating:${this.editor.getOnlySelectedShapeId()}`\n\t\t\t\t)\n\t\t\t\tif (markId) {\n\t\t\t\t\tthis.markId = markId\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tthis.markId = this.editor.markHistoryStoppingPoint('dragging handle')\n\t\t}\n\n\t\tthis.initialHandle = structuredClone(handle)\n\n\t\tthis.initialPageTransform = this.editor.getShapePageTransform(shape)!\n\t\tthis.initialPageRotation = this.initialPageTransform.rotation()\n\t\tthis.initialPagePoint = this.editor.inputs.getOriginPagePoint().clone()\n\n\t\tthis.editor.setCursor({ type: isCreating ? 'cross' : 'grabbing', rotation: 0 })\n\n\t\tconst handles = this.editor.getShapeHandles(shape)!.sort(sortByIndex)\n\t\tconst index = handles.findIndex((h) => h.id === info.handle.id)\n\n\t\t// Find the adjacent handle\n\t\tthis.initialAdjacentHandle = null\n\n\t\t// First, check if the handle specifies a custom reference handle\n\t\tif (info.handle.snapReferenceHandleId) {\n\t\t\tconst customHandle = handles.find((h) => h.id === info.handle.snapReferenceHandleId)\n\t\t\tif (customHandle) {\n\t\t\t\tthis.initialAdjacentHandle = customHandle\n\t\t\t}\n\t\t}\n\n\t\t// If no custom reference handle, use default behavior\n\t\tif (!this.initialAdjacentHandle) {\n\t\t\t// Start from the handle and work forward\n\t\t\tfor (let i = index + 1; i < handles.length; i++) {\n\t\t\t\tconst handle = handles[i]\n\t\t\t\tif (handle.type === 'vertex' && handle.id !== 'middle' && handle.id !== info.handle.id) {\n\t\t\t\t\tthis.initialAdjacentHandle = handle\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// If still no handle, start from the end and work backward\n\t\t\tif (!this.initialAdjacentHandle) {\n\t\t\t\tfor (let i = handles.length - 1; i >= 0; i--) {\n\t\t\t\t\tconst handle = handles[i]\n\t\t\t\t\tif (handle.type === 'vertex' && handle.id !== 'middle' && handle.id !== info.handle.id) {\n\t\t\t\t\t\tthis.initialAdjacentHandle = handle\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// <!-- Only relevant to arrows\n\t\tif (this.editor.isShapeOfType(shape, 'arrow')) {\n\t\t\tconst initialBinding = getArrowBindings(this.editor, shape)[info.handle.id as 'start' | 'end']\n\n\t\t\tthis.isPrecise = false\n\n\t\t\tif (initialBinding) {\n\t\t\t\tthis.isPrecise = initialBinding.props.isPrecise\n\t\t\t\tif (this.isPrecise) {\n\t\t\t\t\tthis.isPreciseId = initialBinding.toId\n\t\t\t\t} else {\n\t\t\t\t\tthis.resetExactTimeout()\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// -->\n\n\t\t// Call onHandleDragStart callback\n\t\tconst handleDragInfo = {\n\t\t\thandle: this.initialHandle,\n\t\t\tisPrecise: this.isPrecise,\n\t\t\tisCreatingShape: !!this.info.isCreating,\n\t\t\tinitial: shape,\n\t\t}\n\t\tconst util = this.editor.getShapeUtil(shape)\n\t\tconst startChanges = util.onHandleDragStart?.(shape, handleDragInfo)\n\t\tif (startChanges) {\n\t\t\tthis.editor.updateShapes([{ ...startChanges, id: shape.id, type: shape.type }])\n\t\t}\n\n\t\tthis.update()\n\n\t\tthis.editor.select(this.shapeId)\n\t}\n\n\t// Only relevant to arrows\n\tprivate exactTimeout = -1\n\n\t// Only relevant to arrows\n\tprivate resetExactTimeout() {\n\t\tconst arrowUtil = this.editor.getShapeUtil<ArrowShapeUtil>('arrow')\n\t\tconst timeoutValue = arrowUtil.options.pointingPreciseTimeout\n\n\t\tif (this.exactTimeout !== -1) {\n\t\t\tthis.clearExactTimeout()\n\t\t}\n\n\t\tthis.exactTimeout = this.editor.timers.setTimeout(() => {\n\t\t\tif (this.getIsActive() && !this.isPrecise) {\n\t\t\t\tthis.isPrecise = true\n\t\t\t\tthis.isPreciseId = this.pointingId\n\t\t\t\tthis.update()\n\t\t\t}\n\t\t\tthis.exactTimeout = -1\n\t\t}, timeoutValue)\n\t}\n\n\t// Only relevant to arrows\n\tprivate clearExactTimeout() {\n\t\tif (this.exactTimeout !== -1) {\n\t\t\tclearTimeout(this.exactTimeout)\n\t\t\tthis.exactTimeout = -1\n\t\t}\n\t}\n\n\toverride onPointerMove() {\n\t\tthis.update()\n\t}\n\n\toverride onKeyDown() {\n\t\tthis.update()\n\t}\n\n\toverride onKeyUp() {\n\t\tthis.update()\n\t}\n\n\toverride onPointerUp() {\n\t\tthis.complete()\n\t}\n\n\toverride onComplete() {\n\t\tthis.update()\n\t\tthis.complete()\n\t}\n\n\toverride onCancel() {\n\t\tthis.cancel()\n\t}\n\n\toverride onExit() {\n\t\tthis.parent.setCurrentToolIdMask(undefined)\n\t\tclearArrowTargetState(this.editor)\n\t\tthis.editor.snaps.clearIndicators()\n\n\t\tthis.editor.setCursor({ type: 'default', rotation: 0 })\n\t}\n\n\tprivate complete() {\n\t\tthis.editor.snaps.clearIndicators()\n\t\tkickoutOccludedShapes(this.editor, [this.shapeId])\n\n\t\t// Call onHandleDragEnd callback before state transitions\n\t\tconst shape = this.editor.getShape(this.shapeId)\n\t\tif (shape) {\n\t\t\tconst util = this.editor.getShapeUtil(shape)\n\t\t\tconst handleDragInfo = {\n\t\t\t\thandle: this.initialHandle,\n\t\t\t\tisPrecise: this.isPrecise,\n\t\t\t\tisCreatingShape: !!this.info.isCreating,\n\t\t\t\tinitial: this.info.shape,\n\t\t\t}\n\t\t\tconst endChanges = util.onHandleDragEnd?.(shape, handleDragInfo)\n\t\t\tif (endChanges) {\n\t\t\t\tthis.editor.updateShapes([{ ...endChanges, id: shape.id }])\n\t\t\t}\n\t\t}\n\n\t\tconst { onInteractionEnd } = this.info\n\t\tif (onInteractionEnd) {\n\t\t\tif (typeof onInteractionEnd === 'string') {\n\t\t\t\tif (this.editor.getInstanceState().isToolLocked && onInteractionEnd) {\n\t\t\t\t\t// Return to the tool that was active before this one but only if tool lock is turned on!\n\t\t\t\t\tthis.editor.setCurrentTool(onInteractionEnd, { shapeId: this.shapeId })\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tonInteractionEnd?.()\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\tthis.parent.transition('idle')\n\t}\n\n\tprivate cancel() {\n\t\t// Call onHandleDragCancel callback before bailing to mark\n\t\tconst shape = this.editor.getShape(this.shapeId)\n\t\tif (shape) {\n\t\t\tconst util = this.editor.getShapeUtil(shape)\n\t\t\tconst handleDragInfo = {\n\t\t\t\thandle: this.initialHandle,\n\t\t\t\tisPrecise: this.isPrecise,\n\t\t\t\tisCreatingShape: !!this.info.isCreating,\n\t\t\t\tinitial: this.info.shape,\n\t\t\t}\n\t\t\tutil.onHandleDragCancel?.(shape, handleDragInfo)\n\t\t}\n\n\t\tthis.editor.bailToMark(this.markId)\n\t\tthis.editor.snaps.clearIndicators()\n\n\t\tconst { onInteractionEnd } = this.info\n\t\tif (onInteractionEnd) {\n\t\t\tif (typeof onInteractionEnd === 'string') {\n\t\t\t\t// Return to the tool that was active before this one, whether tool lock is turned on or not!\n\t\t\t\tthis.editor.setCurrentTool(onInteractionEnd, { shapeId: this.shapeId })\n\t\t\t} else {\n\t\t\t\tonInteractionEnd?.()\n\t\t\t}\n\t\t\treturn\n\t\t}\n\n\t\tthis.parent.transition('idle')\n\t}\n\n\tprivate update() {\n\t\tconst { editor, shapeId, initialPagePoint } = this\n\t\tconst { initialHandle, initialPageRotation, initialAdjacentHandle } = this\n\t\tconst isSnapMode = this.editor.user.getIsSnapMode()\n\t\tconst { snaps } = editor\n\t\tconst currentPagePoint = editor.inputs.getCurrentPagePoint()\n\t\tconst shiftKey = editor.inputs.getShiftKey()\n\t\tconst ctrlKey = editor.inputs.getCtrlKey()\n\t\tconst altKey = editor.inputs.getAltKey()\n\t\tconst pointerVelocity = editor.inputs.getPointerVelocity()\n\n\t\tconst initial = this.info.shape\n\n\t\tconst shape = editor.getShape(shapeId)\n\t\tif (!shape) return\n\t\tconst util = editor.getShapeUtil(shape)\n\n\t\tconst initialBinding = editor.isShapeOfType(shape, 'arrow')\n\t\t\t? getArrowBindings(editor, shape)[initialHandle.id as 'start' | 'end']\n\t\t\t: undefined\n\n\t\tlet point = currentPagePoint\n\t\t\t.clone()\n\t\t\t.sub(initialPagePoint)\n\t\t\t.rot(-initialPageRotation)\n\t\t\t.add(initialHandle)\n\n\t\tif (shiftKey && initialAdjacentHandle && initialHandle.id !== 'middle') {\n\t\t\tconst angle = Vec.Angle(initialAdjacentHandle, point)\n\t\t\tconst snappedAngle = snapAngle(angle, 24)\n\t\t\tconst angleDifference = snappedAngle - angle\n\t\t\tpoint = Vec.RotWith(point, initialAdjacentHandle, angleDifference)\n\t\t}\n\n\t\t// Clear any existing snaps\n\t\teditor.snaps.clearIndicators()\n\n\t\tlet nextHandle = { ...initialHandle, x: point.x, y: point.y }\n\n\t\tlet canSnap = false\n\t\t// eslint-disable-next-line @typescript-eslint/no-deprecated\n\t\tif (initialHandle.canSnap && initialHandle.snapType) {\n\t\t\twarnOnce(\n\t\t\t\t'canSnap is deprecated. Cannot use both canSnap and snapType together - snapping disabled. Please use only snapType.'\n\t\t\t)\n\t\t} else {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-deprecated\n\t\t\tcanSnap = initialHandle.canSnap || initialHandle.snapType !== undefined\n\t\t}\n\n\t\tif (canSnap && (isSnapMode ? !ctrlKey : ctrlKey)) {\n\t\t\t// We're snapping\n\t\t\tconst pageTransform = editor.getShapePageTransform(shape.id)\n\t\t\tif (!pageTransform) throw Error('Expected a page transform')\n\n\t\t\tconst snap = snaps.handles.snapHandle({ currentShapeId: shapeId, handle: nextHandle })\n\n\t\t\tif (snap) {\n\t\t\t\tsnap.nudge.rot(-editor.getShapeParentTransform(shape)!.rotation())\n\t\t\t\tpoint.add(snap.nudge)\n\t\t\t\tnextHandle = { ...initialHandle, x: point.x, y: point.y }\n\t\t\t}\n\t\t}\n\n\t\tconst changes = util.onHandleDrag?.(shape, {\n\t\t\thandle: nextHandle,\n\t\t\tisPrecise: this.isPrecise || altKey,\n\t\t\tisCreatingShape: !!this.info.isCreating,\n\t\t\tinitial: initial,\n\t\t})\n\n\t\tconst next: TLShapePartial<any> = { id: shape.id, type: shape.type, ...changes }\n\n\t\t// Arrows\n\t\tif (initialHandle.type === 'vertex' && this.editor.isShapeOfType(shape, 'arrow')) {\n\t\t\tconst bindingAfter = getArrowBindings(editor, shape)[initialHandle.id as 'start' | 'end']\n\n\t\t\tif (bindingAfter) {\n\t\t\t\tif (initialBinding?.toId !== bindingAfter.toId) {\n\t\t\t\t\tthis.pointingId = bindingAfter.toId\n\t\t\t\t\tthis.isPrecise = pointerVelocity.len() < 0.5 || altKey\n\t\t\t\t\tthis.isPreciseId = this.isPrecise ? bindingAfter.toId : null\n\t\t\t\t\tthis.resetExactTimeout()\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (initialBinding) {\n\t\t\t\t\tthis.pointingId = null\n\t\t\t\t\tthis.isPrecise = false\n\t\t\t\t\tthis.isPreciseId = null\n\t\t\t\t\tthis.resetExactTimeout()\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (changes) {\n\t\t\teditor.updateShapes([next])\n\t\t}\n\t}\n}\n"],
|
|
5
|
-
"mappings": "AAAA;AAAA,EAEC;AAAA,EAOA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAEP,SAAS,6BAA6B;AACtC,SAAS,wBAAwB;AAU1B,MAAM,uBAAuB,UAAU;AAAA,EAC7C,OAAgB,KAAK;AAAA,EAErB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EAEA,YAAY;AAAA,EACZ,cAAgC;AAAA,EAChC,aAA+B;AAAA,EAEtB,QAAQ,MAA0B;AAC1C,UAAM,EAAE,OAAO,YAAY,gBAAgB,OAAO,IAAI;AACtD,SAAK,OAAO;AACZ,QAAI,OAAO,KAAK,qBAAqB,UAAU;AAC9C,WAAK,OAAO,qBAAqB,KAAK,gBAAgB;AAAA,IACvD;AACA,SAAK,UAAU,MAAM;AACrB,SAAK,SAAS;AAEd,QAAI,YAAY;AACf,UAAI,gBAAgB;AACnB,aAAK,SAAS;AAAA,MACf,OAAO;AAEN,cAAM,SAAS,KAAK,OAAO;AAAA,UAC1B,YAAY,KAAK,OAAO,uBAAuB,CAAC;AAAA,QACjD;AACA,YAAI,QAAQ;AACX,eAAK,SAAS;AAAA,QACf;AAAA,MACD;AAAA,IACD,OAAO;AACN,WAAK,SAAS,KAAK,OAAO,yBAAyB,iBAAiB;AAAA,IACrE;AAEA,SAAK,gBAAgB,gBAAgB,MAAM;AAE3C,SAAK,uBAAuB,KAAK,OAAO,sBAAsB,KAAK;AACnE,SAAK,sBAAsB,KAAK,qBAAqB,SAAS;AAC9D,SAAK,mBAAmB,KAAK,OAAO,OAAO,
|
|
4
|
+
"sourcesContent": ["import {\n\tMat,\n\tStateNode,\n\tTLArrowShape,\n\tTLHandle,\n\tTLLineShape,\n\tTLPointerEventInfo,\n\tTLShapeId,\n\tTLShapePartial,\n\tVec,\n\tkickoutOccludedShapes,\n\tsnapAngle,\n\tsortByIndex,\n\tstructuredClone,\n\twarnOnce,\n} from '@tldraw/editor'\nimport { ArrowShapeUtil } from '../../../shapes/arrow/ArrowShapeUtil'\nimport { clearArrowTargetState } from '../../../shapes/arrow/arrowTargetState'\nimport { getArrowBindings } from '../../../shapes/arrow/shared'\n\nexport type DraggingHandleInfo = TLPointerEventInfo & {\n\tshape: TLArrowShape | TLLineShape\n\ttarget: 'handle'\n\tonInteractionEnd?: string | (() => void)\n\tisCreating?: boolean\n\tcreatingMarkId?: string\n}\n\nexport class DraggingHandle extends StateNode {\n\tstatic override id = 'dragging_handle'\n\n\tshapeId!: TLShapeId\n\tinitialHandle!: TLHandle\n\tinitialAdjacentHandle!: TLHandle | null\n\tinitialPagePoint!: Vec\n\n\tmarkId!: string\n\tinitialPageTransform!: Mat\n\tinitialPageRotation!: number\n\n\tinfo!: DraggingHandleInfo\n\n\tisPrecise = false\n\tisPreciseId: TLShapeId | null = null\n\tpointingId: TLShapeId | null = null\n\n\toverride onEnter(info: DraggingHandleInfo) {\n\t\tconst { shape, isCreating, creatingMarkId, handle } = info\n\t\tthis.info = info\n\t\tif (typeof info.onInteractionEnd === 'string') {\n\t\t\tthis.parent.setCurrentToolIdMask(info.onInteractionEnd)\n\t\t}\n\t\tthis.shapeId = shape.id\n\t\tthis.markId = ''\n\n\t\tif (isCreating) {\n\t\t\tif (creatingMarkId) {\n\t\t\t\tthis.markId = creatingMarkId\n\t\t\t} else {\n\t\t\t\t// handle legacy implicit `creating:{shapeId}` marks\n\t\t\t\tconst markId = this.editor.getMarkIdMatching(\n\t\t\t\t\t`creating:${this.editor.getOnlySelectedShapeId()}`\n\t\t\t\t)\n\t\t\t\tif (markId) {\n\t\t\t\t\tthis.markId = markId\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tthis.markId = this.editor.markHistoryStoppingPoint('dragging handle')\n\t\t}\n\n\t\tthis.initialHandle = structuredClone(handle)\n\n\t\tthis.initialPageTransform = this.editor.getShapePageTransform(shape)!\n\t\tthis.initialPageRotation = this.initialPageTransform.rotation()\n\t\tthis.initialPagePoint = this.editor.inputs.originPagePoint.clone()\n\n\t\tthis.editor.setCursor({ type: isCreating ? 'cross' : 'grabbing', rotation: 0 })\n\n\t\tconst handles = this.editor.getShapeHandles(shape)!.sort(sortByIndex)\n\t\tconst index = handles.findIndex((h) => h.id === info.handle.id)\n\n\t\t// Find the adjacent handle\n\t\tthis.initialAdjacentHandle = null\n\n\t\t// First, check if the handle specifies a custom reference handle\n\t\tif (info.handle.snapReferenceHandleId) {\n\t\t\tconst customHandle = handles.find((h) => h.id === info.handle.snapReferenceHandleId)\n\t\t\tif (customHandle) {\n\t\t\t\tthis.initialAdjacentHandle = customHandle\n\t\t\t}\n\t\t}\n\n\t\t// If no custom reference handle, use default behavior\n\t\tif (!this.initialAdjacentHandle) {\n\t\t\t// Start from the handle and work forward\n\t\t\tfor (let i = index + 1; i < handles.length; i++) {\n\t\t\t\tconst handle = handles[i]\n\t\t\t\tif (handle.type === 'vertex' && handle.id !== 'middle' && handle.id !== info.handle.id) {\n\t\t\t\t\tthis.initialAdjacentHandle = handle\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// If still no handle, start from the end and work backward\n\t\t\tif (!this.initialAdjacentHandle) {\n\t\t\t\tfor (let i = handles.length - 1; i >= 0; i--) {\n\t\t\t\t\tconst handle = handles[i]\n\t\t\t\t\tif (handle.type === 'vertex' && handle.id !== 'middle' && handle.id !== info.handle.id) {\n\t\t\t\t\t\tthis.initialAdjacentHandle = handle\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// <!-- Only relevant to arrows\n\t\tif (this.editor.isShapeOfType<TLArrowShape>(shape, 'arrow')) {\n\t\t\tconst initialBinding = getArrowBindings(this.editor, shape)[info.handle.id as 'start' | 'end']\n\n\t\t\tthis.isPrecise = false\n\n\t\t\tif (initialBinding) {\n\t\t\t\tthis.isPrecise = initialBinding.props.isPrecise\n\t\t\t\tif (this.isPrecise) {\n\t\t\t\t\tthis.isPreciseId = initialBinding.toId\n\t\t\t\t} else {\n\t\t\t\t\tthis.resetExactTimeout()\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// -->\n\n\t\t// Call onHandleDragStart callback\n\t\tconst handleDragInfo = {\n\t\t\thandle: this.initialHandle,\n\t\t\tisPrecise: this.isPrecise,\n\t\t\tisCreatingShape: !!this.info.isCreating,\n\t\t\tinitial: shape,\n\t\t}\n\t\tconst util = this.editor.getShapeUtil(shape)\n\t\tconst startChanges = util.onHandleDragStart?.(shape, handleDragInfo)\n\t\tif (startChanges) {\n\t\t\tthis.editor.updateShapes([{ ...startChanges, id: shape.id, type: shape.type }])\n\t\t}\n\n\t\tthis.update()\n\n\t\tthis.editor.select(this.shapeId)\n\t}\n\n\t// Only relevant to arrows\n\tprivate exactTimeout = -1\n\n\t// Only relevant to arrows\n\tprivate resetExactTimeout() {\n\t\tconst arrowUtil = this.editor.getShapeUtil<ArrowShapeUtil>('arrow')\n\t\tconst timeoutValue = arrowUtil.options.pointingPreciseTimeout\n\n\t\tif (this.exactTimeout !== -1) {\n\t\t\tthis.clearExactTimeout()\n\t\t}\n\n\t\tthis.exactTimeout = this.editor.timers.setTimeout(() => {\n\t\t\tif (this.getIsActive() && !this.isPrecise) {\n\t\t\t\tthis.isPrecise = true\n\t\t\t\tthis.isPreciseId = this.pointingId\n\t\t\t\tthis.update()\n\t\t\t}\n\t\t\tthis.exactTimeout = -1\n\t\t}, timeoutValue)\n\t}\n\n\t// Only relevant to arrows\n\tprivate clearExactTimeout() {\n\t\tif (this.exactTimeout !== -1) {\n\t\t\tclearTimeout(this.exactTimeout)\n\t\t\tthis.exactTimeout = -1\n\t\t}\n\t}\n\n\toverride onPointerMove() {\n\t\tthis.update()\n\t}\n\n\toverride onKeyDown() {\n\t\tthis.update()\n\t}\n\n\toverride onKeyUp() {\n\t\tthis.update()\n\t}\n\n\toverride onPointerUp() {\n\t\tthis.complete()\n\t}\n\n\toverride onComplete() {\n\t\tthis.update()\n\t\tthis.complete()\n\t}\n\n\toverride onCancel() {\n\t\tthis.cancel()\n\t}\n\n\toverride onExit() {\n\t\tthis.parent.setCurrentToolIdMask(undefined)\n\t\tclearArrowTargetState(this.editor)\n\t\tthis.editor.snaps.clearIndicators()\n\n\t\tthis.editor.setCursor({ type: 'default', rotation: 0 })\n\t}\n\n\tprivate complete() {\n\t\tthis.editor.snaps.clearIndicators()\n\t\tkickoutOccludedShapes(this.editor, [this.shapeId])\n\n\t\t// Call onHandleDragEnd callback before state transitions\n\t\tconst shape = this.editor.getShape(this.shapeId)\n\t\tif (shape) {\n\t\t\tconst util = this.editor.getShapeUtil(shape)\n\t\t\tconst handleDragInfo = {\n\t\t\t\thandle: this.initialHandle,\n\t\t\t\tisPrecise: this.isPrecise,\n\t\t\t\tisCreatingShape: !!this.info.isCreating,\n\t\t\t\tinitial: this.info.shape,\n\t\t\t}\n\t\t\tconst endChanges = util.onHandleDragEnd?.(shape, handleDragInfo)\n\t\t\tif (endChanges) {\n\t\t\t\tthis.editor.updateShapes([{ ...endChanges, id: shape.id, type: shape.type }])\n\t\t\t}\n\t\t}\n\n\t\tconst { onInteractionEnd } = this.info\n\t\tif (onInteractionEnd) {\n\t\t\tif (typeof onInteractionEnd === 'string') {\n\t\t\t\tif (this.editor.getInstanceState().isToolLocked && onInteractionEnd) {\n\t\t\t\t\t// Return to the tool that was active before this one but only if tool lock is turned on!\n\t\t\t\t\tthis.editor.setCurrentTool(onInteractionEnd, { shapeId: this.shapeId })\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tonInteractionEnd?.()\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\tthis.parent.transition('idle')\n\t}\n\n\tprivate cancel() {\n\t\t// Call onHandleDragCancel callback before bailing to mark\n\t\tconst shape = this.editor.getShape(this.shapeId)\n\t\tif (shape) {\n\t\t\tconst util = this.editor.getShapeUtil(shape)\n\t\t\tconst handleDragInfo = {\n\t\t\t\thandle: this.initialHandle,\n\t\t\t\tisPrecise: this.isPrecise,\n\t\t\t\tisCreatingShape: !!this.info.isCreating,\n\t\t\t\tinitial: this.info.shape,\n\t\t\t}\n\t\t\tutil.onHandleDragCancel?.(shape, handleDragInfo)\n\t\t}\n\n\t\tthis.editor.bailToMark(this.markId)\n\t\tthis.editor.snaps.clearIndicators()\n\n\t\tconst { onInteractionEnd } = this.info\n\t\tif (onInteractionEnd) {\n\t\t\tif (typeof onInteractionEnd === 'string') {\n\t\t\t\t// Return to the tool that was active before this one, whether tool lock is turned on or not!\n\t\t\t\tthis.editor.setCurrentTool(onInteractionEnd, { shapeId: this.shapeId })\n\t\t\t} else {\n\t\t\t\tonInteractionEnd?.()\n\t\t\t}\n\t\t\treturn\n\t\t}\n\n\t\tthis.parent.transition('idle')\n\t}\n\n\tprivate update() {\n\t\tconst { editor, shapeId, initialPagePoint } = this\n\t\tconst { initialHandle, initialPageRotation, initialAdjacentHandle } = this\n\t\tconst isSnapMode = this.editor.user.getIsSnapMode()\n\t\tconst {\n\t\t\tsnaps,\n\t\t\tinputs: { currentPagePoint, shiftKey, ctrlKey, altKey, pointerVelocity },\n\t\t} = editor\n\n\t\tconst initial = this.info.shape\n\n\t\tconst shape = editor.getShape(shapeId)\n\t\tif (!shape) return\n\t\tconst util = editor.getShapeUtil(shape)\n\n\t\tconst initialBinding = editor.isShapeOfType<TLArrowShape>(shape, 'arrow')\n\t\t\t? getArrowBindings(editor, shape)[initialHandle.id as 'start' | 'end']\n\t\t\t: undefined\n\n\t\tlet point = currentPagePoint\n\t\t\t.clone()\n\t\t\t.sub(initialPagePoint)\n\t\t\t.rot(-initialPageRotation)\n\t\t\t.add(initialHandle)\n\n\t\tif (shiftKey && initialAdjacentHandle && initialHandle.id !== 'middle') {\n\t\t\tconst angle = Vec.Angle(initialAdjacentHandle, point)\n\t\t\tconst snappedAngle = snapAngle(angle, 24)\n\t\t\tconst angleDifference = snappedAngle - angle\n\t\t\tpoint = Vec.RotWith(point, initialAdjacentHandle, angleDifference)\n\t\t}\n\n\t\t// Clear any existing snaps\n\t\teditor.snaps.clearIndicators()\n\n\t\tlet nextHandle = { ...initialHandle, x: point.x, y: point.y }\n\n\t\tlet canSnap = false\n\t\t// eslint-disable-next-line @typescript-eslint/no-deprecated\n\t\tif (initialHandle.canSnap && initialHandle.snapType) {\n\t\t\twarnOnce(\n\t\t\t\t'canSnap is deprecated. Cannot use both canSnap and snapType together - snapping disabled. Please use only snapType.'\n\t\t\t)\n\t\t} else {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-deprecated\n\t\t\tcanSnap = initialHandle.canSnap || initialHandle.snapType !== undefined\n\t\t}\n\n\t\tif (canSnap && (isSnapMode ? !ctrlKey : ctrlKey)) {\n\t\t\t// We're snapping\n\t\t\tconst pageTransform = editor.getShapePageTransform(shape.id)\n\t\t\tif (!pageTransform) throw Error('Expected a page transform')\n\n\t\t\tconst snap = snaps.handles.snapHandle({ currentShapeId: shapeId, handle: nextHandle })\n\n\t\t\tif (snap) {\n\t\t\t\tsnap.nudge.rot(-editor.getShapeParentTransform(shape)!.rotation())\n\t\t\t\tpoint.add(snap.nudge)\n\t\t\t\tnextHandle = { ...initialHandle, x: point.x, y: point.y }\n\t\t\t}\n\t\t}\n\n\t\tconst changes = util.onHandleDrag?.(shape, {\n\t\t\thandle: nextHandle,\n\t\t\tisPrecise: this.isPrecise || altKey,\n\t\t\tisCreatingShape: !!this.info.isCreating,\n\t\t\tinitial: initial,\n\t\t})\n\n\t\tconst next: TLShapePartial<any> = { id: shape.id, type: shape.type, ...changes }\n\n\t\t// Arrows\n\t\tif (\n\t\t\tinitialHandle.type === 'vertex' &&\n\t\t\tthis.editor.isShapeOfType<TLArrowShape>(shape, 'arrow')\n\t\t) {\n\t\t\tconst bindingAfter = getArrowBindings(editor, shape)[initialHandle.id as 'start' | 'end']\n\n\t\t\tif (bindingAfter) {\n\t\t\t\tif (initialBinding?.toId !== bindingAfter.toId) {\n\t\t\t\t\tthis.pointingId = bindingAfter.toId\n\t\t\t\t\tthis.isPrecise = pointerVelocity.len() < 0.5 || altKey\n\t\t\t\t\tthis.isPreciseId = this.isPrecise ? bindingAfter.toId : null\n\t\t\t\t\tthis.resetExactTimeout()\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (initialBinding) {\n\t\t\t\t\tthis.pointingId = null\n\t\t\t\t\tthis.isPrecise = false\n\t\t\t\t\tthis.isPreciseId = null\n\t\t\t\t\tthis.resetExactTimeout()\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (changes) {\n\t\t\teditor.updateShapes([next])\n\t\t}\n\t}\n}\n"],
|
|
5
|
+
"mappings": "AAAA;AAAA,EAEC;AAAA,EAOA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAEP,SAAS,6BAA6B;AACtC,SAAS,wBAAwB;AAU1B,MAAM,uBAAuB,UAAU;AAAA,EAC7C,OAAgB,KAAK;AAAA,EAErB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EAEA,YAAY;AAAA,EACZ,cAAgC;AAAA,EAChC,aAA+B;AAAA,EAEtB,QAAQ,MAA0B;AAC1C,UAAM,EAAE,OAAO,YAAY,gBAAgB,OAAO,IAAI;AACtD,SAAK,OAAO;AACZ,QAAI,OAAO,KAAK,qBAAqB,UAAU;AAC9C,WAAK,OAAO,qBAAqB,KAAK,gBAAgB;AAAA,IACvD;AACA,SAAK,UAAU,MAAM;AACrB,SAAK,SAAS;AAEd,QAAI,YAAY;AACf,UAAI,gBAAgB;AACnB,aAAK,SAAS;AAAA,MACf,OAAO;AAEN,cAAM,SAAS,KAAK,OAAO;AAAA,UAC1B,YAAY,KAAK,OAAO,uBAAuB,CAAC;AAAA,QACjD;AACA,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A,IACD,CAAC;AAED,UAAM,OAA4B,EAAE,IAAI,MAAM,IAAI,MAAM,MAAM,MAAM,GAAG,QAAQ;AAG/E,QACC,cAAc,SAAS,YACvB,KAAK,OAAO,cAA4B,OAAO,OAAO,GACrD;AACD,YAAM,eAAe,iBAAiB,QAAQ,KAAK,EAAE,cAAc,EAAqB;AAExF,UAAI,cAAc;AACjB,YAAI,gBAAgB,SAAS,aAAa,MAAM;AAC/C,eAAK,aAAa,aAAa;AAC/B,eAAK,YAAY,gBAAgB,IAAI,IAAI,OAAO;AAChD,eAAK,cAAc,KAAK,YAAY,aAAa,OAAO;AACxD,eAAK,kBAAkB;AAAA,QACxB;AAAA,MACD,OAAO;AACN,YAAI,gBAAgB;AACnB,eAAK,aAAa;AAClB,eAAK,YAAY;AACjB,eAAK,cAAc;AACnB,eAAK,kBAAkB;AAAA,QACxB;AAAA,MACD;AAAA,IACD;AAEA,QAAI,SAAS;AACZ,aAAO,aAAa,CAAC,IAAI,CAAC;AAAA,IAC3B;AAAA,EACD;AACD;",
|
|
6
6
|
"names": ["handle"]
|
|
7
7
|
}
|
|
@@ -8,18 +8,12 @@ import { getHitShapeOnCanvasPointerDown } from "../../selection-logic/getHitShap
|
|
|
8
8
|
import { updateHoveredShapeId } from "../../selection-logic/updateHoveredShapeId.mjs";
|
|
9
9
|
class EditingShape extends StateNode {
|
|
10
10
|
static id = "editing_shape";
|
|
11
|
-
|
|
11
|
+
hitShapeForPointerUp = null;
|
|
12
12
|
info = {};
|
|
13
|
-
didPointerDownOnEditingShape = false;
|
|
14
|
-
isTextInputFocused() {
|
|
15
|
-
const container = this.editor.getContainer();
|
|
16
|
-
return container.contains(document.activeElement) && (document.activeElement?.nodeName === "INPUT" || document.activeElement?.nodeName === "TEXTAREA" || document.activeElement?.isContentEditable);
|
|
17
|
-
}
|
|
18
13
|
onEnter(info) {
|
|
19
14
|
const editingShape = this.editor.getEditingShape();
|
|
20
15
|
if (!editingShape) throw Error("Entered editing state without an editing shape");
|
|
21
|
-
this.
|
|
22
|
-
this.didPointerDownOnEditingShape = false;
|
|
16
|
+
this.hitShapeForPointerUp = null;
|
|
23
17
|
this.info = info;
|
|
24
18
|
if (info.isCreatingTextWhileToolLocked) {
|
|
25
19
|
this.parent.setCurrentToolIdMask("text");
|
|
@@ -38,26 +32,14 @@ class EditingShape extends StateNode {
|
|
|
38
32
|
}
|
|
39
33
|
}
|
|
40
34
|
onPointerMove(info) {
|
|
41
|
-
if (this.
|
|
35
|
+
if (this.hitShapeForPointerUp && this.editor.inputs.isDragging) {
|
|
42
36
|
if (this.editor.getIsReadonly()) return;
|
|
43
|
-
if (this.
|
|
44
|
-
this.editor.select(this.
|
|
37
|
+
if (this.hitShapeForPointerUp.isLocked) return;
|
|
38
|
+
this.editor.select(this.hitShapeForPointerUp);
|
|
45
39
|
this.parent.transition("translating", info);
|
|
46
|
-
this.
|
|
40
|
+
this.hitShapeForPointerUp = null;
|
|
47
41
|
return;
|
|
48
42
|
}
|
|
49
|
-
if (this.didPointerDownOnEditingShape && this.editor.inputs.isDragging) {
|
|
50
|
-
if (this.editor.getIsReadonly()) return;
|
|
51
|
-
const editingShape = this.editor.getEditingShape();
|
|
52
|
-
if (!editingShape || editingShape.isLocked) return;
|
|
53
|
-
if (!this.isTextInputFocused()) {
|
|
54
|
-
this.editor.select(editingShape);
|
|
55
|
-
this.parent.transition("translating", info);
|
|
56
|
-
this.didPointerDownOnEditingShape = false;
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
this.didPointerDownOnEditingShape = false;
|
|
60
|
-
}
|
|
61
43
|
switch (info.target) {
|
|
62
44
|
case "shape":
|
|
63
45
|
case "canvas": {
|
|
@@ -67,8 +49,7 @@ class EditingShape extends StateNode {
|
|
|
67
49
|
}
|
|
68
50
|
}
|
|
69
51
|
onPointerDown(info) {
|
|
70
|
-
this.
|
|
71
|
-
this.didPointerDownOnEditingShape = false;
|
|
52
|
+
this.hitShapeForPointerUp = null;
|
|
72
53
|
switch (info.target) {
|
|
73
54
|
// N.B. This bit of logic has a bit of history to it.
|
|
74
55
|
// There was a PR that got rid of this logic: https://github.com/tldraw/tldraw/pull/4237
|
|
@@ -104,14 +85,13 @@ class EditingShape extends StateNode {
|
|
|
104
85
|
if (textLabel && !isEmptyTextShape) {
|
|
105
86
|
const pointInShapeSpace = this.editor.getPointInShapeSpace(
|
|
106
87
|
selectingShape,
|
|
107
|
-
this.editor.inputs.
|
|
88
|
+
this.editor.inputs.currentPagePoint
|
|
108
89
|
);
|
|
109
90
|
if (textLabel.bounds.containsPoint(pointInShapeSpace, 0) && textLabel.hitTestPoint(pointInShapeSpace)) {
|
|
110
91
|
if (selectingShape.id === editingShape.id) {
|
|
111
|
-
this.didPointerDownOnEditingShape = true;
|
|
112
92
|
return;
|
|
113
93
|
} else {
|
|
114
|
-
this.
|
|
94
|
+
this.hitShapeForPointerUp = selectingShape;
|
|
115
95
|
this.editor.markHistoryStoppingPoint("editing on pointer up");
|
|
116
96
|
this.editor.select(selectingShape.id);
|
|
117
97
|
return;
|
|
@@ -136,16 +116,9 @@ class EditingShape extends StateNode {
|
|
|
136
116
|
this.editor.root.handleEvent(info);
|
|
137
117
|
}
|
|
138
118
|
onPointerUp(info) {
|
|
139
|
-
|
|
140
|
-
this.didPointerDownOnEditingShape = false;
|
|
141
|
-
if (!this.isTextInputFocused()) {
|
|
142
|
-
this.editor.getRichTextEditor()?.commands.focus("all");
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
const hitShape = this.hitLabelOnShapeForPointerUp;
|
|
119
|
+
const hitShape = this.hitShapeForPointerUp;
|
|
147
120
|
if (!hitShape) return;
|
|
148
|
-
this.
|
|
121
|
+
this.hitShapeForPointerUp = null;
|
|
149
122
|
const util = this.editor.getShapeUtil(hitShape);
|
|
150
123
|
if (hitShape.isLocked) return;
|
|
151
124
|
if (this.editor.getIsReadonly()) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/lib/tools/SelectTool/childStates/EditingShape.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n\tStateNode,\n\tTLCancelEventInfo,\n\tTLCompleteEventInfo,\n\ttlenv,\n\tTLPointerEventInfo,\n\tTLShape,\n} from '@tldraw/editor'\nimport { getTextLabels } from '../../../utils/shapes/shapes'\nimport { renderPlaintextFromRichText } from '../../../utils/text/richText'\nimport { getHitShapeOnCanvasPointerDown } from '../../selection-logic/getHitShapeOnCanvasPointerDown'\nimport { updateHoveredShapeId } from '../../selection-logic/updateHoveredShapeId'\n\ninterface EditingShapeInfo {\n\tisCreatingTextWhileToolLocked?: boolean\n}\n\nexport class EditingShape extends StateNode {\n\tstatic override id = 'editing_shape'\n\n\
|
|
5
|
-
"mappings": "AAAA;AAAA,EACC;AAAA,EAGA;AAAA,
|
|
4
|
+
"sourcesContent": ["import {\n\tStateNode,\n\tTLCancelEventInfo,\n\tTLCompleteEventInfo,\n\ttlenv,\n\tTLFrameShape,\n\tTLPointerEventInfo,\n\tTLShape,\n\tTLTextShape,\n} from '@tldraw/editor'\nimport { getTextLabels } from '../../../utils/shapes/shapes'\nimport { renderPlaintextFromRichText } from '../../../utils/text/richText'\nimport { getHitShapeOnCanvasPointerDown } from '../../selection-logic/getHitShapeOnCanvasPointerDown'\nimport { updateHoveredShapeId } from '../../selection-logic/updateHoveredShapeId'\n\ninterface EditingShapeInfo {\n\tisCreatingTextWhileToolLocked?: boolean\n}\n\nexport class EditingShape extends StateNode {\n\tstatic override id = 'editing_shape'\n\n\thitShapeForPointerUp: TLShape | null = null\n\tprivate info = {} as EditingShapeInfo\n\n\toverride onEnter(info: EditingShapeInfo) {\n\t\tconst editingShape = this.editor.getEditingShape()\n\t\tif (!editingShape) throw Error('Entered editing state without an editing shape')\n\t\tthis.hitShapeForPointerUp = null\n\n\t\tthis.info = info\n\n\t\tif (info.isCreatingTextWhileToolLocked) {\n\t\t\tthis.parent.setCurrentToolIdMask('text')\n\t\t}\n\n\t\tupdateHoveredShapeId(this.editor)\n\t\tthis.editor.select(editingShape)\n\t}\n\n\toverride onExit() {\n\t\tconst { editingShapeId } = this.editor.getCurrentPageState()\n\t\tif (!editingShapeId) return\n\n\t\t// Clear the editing shape\n\t\tthis.editor.setEditingShape(null)\n\n\t\tupdateHoveredShapeId.cancel()\n\n\t\tif (this.info.isCreatingTextWhileToolLocked) {\n\t\t\tthis.parent.setCurrentToolIdMask(undefined)\n\t\t\tthis.editor.setCurrentTool('text', {})\n\t\t}\n\t}\n\n\toverride onPointerMove(info: TLPointerEventInfo) {\n\t\t// In the case where on pointer down we hit a shape's label, we need to check if the user is dragging.\n\t\t// and if they are, we need to transition to translating instead.\n\t\tif (this.hitShapeForPointerUp && this.editor.inputs.isDragging) {\n\t\t\tif (this.editor.getIsReadonly()) return\n\t\t\tif (this.hitShapeForPointerUp.isLocked) return\n\t\t\tthis.editor.select(this.hitShapeForPointerUp)\n\t\t\tthis.parent.transition('translating', info)\n\t\t\tthis.hitShapeForPointerUp = null\n\t\t\treturn\n\t\t}\n\n\t\tswitch (info.target) {\n\t\t\tcase 'shape':\n\t\t\tcase 'canvas': {\n\t\t\t\tupdateHoveredShapeId(this.editor)\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\n\toverride onPointerDown(info: TLPointerEventInfo) {\n\t\tthis.hitShapeForPointerUp = null\n\n\t\tswitch (info.target) {\n\t\t\t// N.B. This bit of logic has a bit of history to it.\n\t\t\t// There was a PR that got rid of this logic: https://github.com/tldraw/tldraw/pull/4237\n\t\t\t// But here we bring it back to help support the new rich text world.\n\t\t\t// The original issue which is visible in the video attachments in the PR now seem\n\t\t\t// to have been resolved anyway via some other layer.\n\t\t\tcase 'canvas': {\n\t\t\t\tconst hitShape = getHitShapeOnCanvasPointerDown(this.editor, true /* hitLabels */)\n\t\t\t\tif (hitShape) {\n\t\t\t\t\tthis.onPointerDown({\n\t\t\t\t\t\t...info,\n\t\t\t\t\t\tshape: hitShape,\n\t\t\t\t\t\ttarget: 'shape',\n\t\t\t\t\t})\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'shape': {\n\t\t\t\tconst { shape: selectingShape } = info\n\t\t\t\tconst editingShape = this.editor.getEditingShape()\n\n\t\t\t\tif (!editingShape) {\n\t\t\t\t\tthrow Error('Expected an editing shape!')\n\t\t\t\t}\n\n\t\t\t\t// for shapes with labels, check to see if the click was inside of the shape's label\n\t\t\t\tconst geometry = this.editor.getShapeUtil(selectingShape).getGeometry(selectingShape)\n\t\t\t\tconst textLabels = getTextLabels(geometry)\n\t\t\t\tconst textLabel = textLabels.length === 1 ? textLabels[0] : undefined\n\t\t\t\t// N.B. One nuance here is that we want empty text fields to be removed from the canvas when the user clicks away from them.\n\t\t\t\tconst isEmptyTextShape =\n\t\t\t\t\tthis.editor.isShapeOfType<TLTextShape>(editingShape, 'text') &&\n\t\t\t\t\trenderPlaintextFromRichText(this.editor, editingShape.props.richText).trim() === ''\n\t\t\t\tif (textLabel && !isEmptyTextShape) {\n\t\t\t\t\tconst pointInShapeSpace = this.editor.getPointInShapeSpace(\n\t\t\t\t\t\tselectingShape,\n\t\t\t\t\t\tthis.editor.inputs.currentPagePoint\n\t\t\t\t\t)\n\t\t\t\t\tif (\n\t\t\t\t\t\ttextLabel.bounds.containsPoint(pointInShapeSpace, 0) &&\n\t\t\t\t\t\ttextLabel.hitTestPoint(pointInShapeSpace)\n\t\t\t\t\t) {\n\t\t\t\t\t\t// it's a hit to the label!\n\t\t\t\t\t\tif (selectingShape.id === editingShape.id) {\n\t\t\t\t\t\t\t// If we clicked on the editing geo / arrow shape's label, do nothing\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthis.hitShapeForPointerUp = selectingShape\n\n\t\t\t\t\t\t\tthis.editor.markHistoryStoppingPoint('editing on pointer up')\n\t\t\t\t\t\t\tthis.editor.select(selectingShape.id)\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif (selectingShape.id === editingShape.id) {\n\t\t\t\t\t\t// If we clicked on a frame, while editing its heading, cancel editing\n\t\t\t\t\t\tif (this.editor.isShapeOfType<TLFrameShape>(selectingShape, 'frame')) {\n\t\t\t\t\t\t\tthis.editor.setEditingShape(null)\n\t\t\t\t\t\t\tthis.parent.transition('idle', info)\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// If we clicked on the editing shape (which isn't a shape with a label), do nothing\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// But if we clicked on a different shape of the same type, transition to pointing_shape instead\n\t\t\t\t\t\tthis.parent.transition('pointing_shape', info)\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\t// still here? Cancel editing and transition back to select idle\n\t\tthis.parent.transition('idle', info)\n\t\t// then feed the pointer down event back into the state chart as if it happened in that state\n\t\tthis.editor.root.handleEvent(info)\n\t}\n\n\toverride onPointerUp(info: TLPointerEventInfo) {\n\t\t// If we're not dragging, and it's a hit to the label, begin editing the shape.\n\t\tconst hitShape = this.hitShapeForPointerUp\n\t\tif (!hitShape) return\n\t\tthis.hitShapeForPointerUp = null\n\n\t\t// Stay in edit mode to maintain flow of editing.\n\t\tconst util = this.editor.getShapeUtil(hitShape)\n\t\tif (hitShape.isLocked) return\n\n\t\tif (this.editor.getIsReadonly()) {\n\t\t\tif (!util.canEditInReadonly(hitShape)) {\n\t\t\t\tthis.parent.transition('pointing_shape', info)\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\tthis.editor.select(hitShape.id)\n\n\t\tconst currentEditingShape = this.editor.getEditingShape()\n\t\tconst isEditToEditAction = currentEditingShape && currentEditingShape.id !== hitShape.id\n\t\tthis.editor.setEditingShape(hitShape.id)\n\n\t\tconst isMobile = tlenv.isIos || tlenv.isAndroid\n\t\tif (!isMobile || !isEditToEditAction) {\n\t\t\tthis.editor.emit('place-caret', { shapeId: hitShape.id, point: info.point })\n\t\t} else if (isMobile && isEditToEditAction) {\n\t\t\tthis.editor.emit('select-all-text', { shapeId: hitShape.id })\n\t\t}\n\t\tupdateHoveredShapeId(this.editor)\n\t}\n\n\toverride onComplete(info: TLCompleteEventInfo) {\n\t\tthis.editor.getContainer().focus()\n\t\tthis.parent.transition('idle', info)\n\t}\n\n\toverride onCancel(info: TLCancelEventInfo) {\n\t\tthis.editor.getContainer().focus()\n\t\tthis.parent.transition('idle', info)\n\t}\n}\n"],
|
|
5
|
+
"mappings": "AAAA;AAAA,EACC;AAAA,EAGA;AAAA,OAKM;AACP,SAAS,qBAAqB;AAC9B,SAAS,mCAAmC;AAC5C,SAAS,sCAAsC;AAC/C,SAAS,4BAA4B;AAM9B,MAAM,qBAAqB,UAAU;AAAA,EAC3C,OAAgB,KAAK;AAAA,EAErB,uBAAuC;AAAA,EAC/B,OAAO,CAAC;AAAA,EAEP,QAAQ,MAAwB;AACxC,UAAM,eAAe,KAAK,OAAO,gBAAgB;AACjD,QAAI,CAAC,aAAc,OAAM,MAAM,gDAAgD;AAC/E,SAAK,uBAAuB;AAE5B,SAAK,OAAO;AAEZ,QAAI,KAAK,+BAA+B;AACvC,WAAK,OAAO,qBAAqB,MAAM;AAAA,IACxC;AAEA,yBAAqB,KAAK,MAAM;AAChC,SAAK,OAAO,OAAO,YAAY;AAAA,EAChC;AAAA,EAES,SAAS;AACjB,UAAM,EAAE,eAAe,IAAI,KAAK,OAAO,oBAAoB;AAC3D,QAAI,CAAC,eAAgB;AAGrB,SAAK,OAAO,gBAAgB,IAAI;AAEhC,yBAAqB,OAAO;AAE5B,QAAI,KAAK,KAAK,+BAA+B;AAC5C,WAAK,OAAO,qBAAqB,MAAS;AAC1C,WAAK,OAAO,eAAe,QAAQ,CAAC,CAAC;AAAA,IACtC;AAAA,EACD;AAAA,EAES,cAAc,MAA0B;AAG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KAAK,eAAe,EAAE,SAAS,SAAS,IAAI,OAAO,KAAK,MAAM,CAAC;AAAA,IAC5E,WAAW,YAAY,oBAAoB;AAC1C,WAAK,OAAO,KAAK,mBAAmB,EAAE,SAAS,SAAS,GAAG,CAAC;AAAA,IAC7D;AACA,yBAAqB,KAAK,MAAM;AAAA,EACjC;AAAA,EAES,WAAW,MAA2B;AAC9C,SAAK,OAAO,aAAa,EAAE,MAAM;AACjC,SAAK,OAAO,WAAW,QAAQ,IAAI;AAAA,EACpC;AAAA,EAES,SAAS,MAAyB;AAC1C,SAAK,OAAO,aAAa,EAAE,MAAM;AACjC,SAAK,OAAO,WAAW,QAAQ,IAAI;AAAA,EACpC;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -9,9 +9,10 @@ import {
|
|
|
9
9
|
} from "@tldraw/editor";
|
|
10
10
|
import { isOverArrowLabel } from "../../../shapes/arrow/arrowLabel.mjs";
|
|
11
11
|
import { getHitShapeOnCanvasPointerDown } from "../../selection-logic/getHitShapeOnCanvasPointerDown.mjs";
|
|
12
|
+
import { getShouldEnterCropMode } from "../../selection-logic/getShouldEnterCropModeOnPointerDown.mjs";
|
|
12
13
|
import { selectOnCanvasPointerUp } from "../../selection-logic/selectOnCanvasPointerUp.mjs";
|
|
13
14
|
import { updateHoveredShapeId } from "../../selection-logic/updateHoveredShapeId.mjs";
|
|
14
|
-
import {
|
|
15
|
+
import { startEditingShapeWithLabel } from "../selectHelpers.mjs";
|
|
15
16
|
const SKIPPED_KEYS_FOR_AUTO_EDITING = [
|
|
16
17
|
"Delete",
|
|
17
18
|
"Backspace",
|
|
@@ -38,6 +39,7 @@ class Idle extends StateNode {
|
|
|
38
39
|
updateHoveredShapeId(this.editor);
|
|
39
40
|
}
|
|
40
41
|
onPointerDown(info) {
|
|
42
|
+
const shouldEnterCropMode = info.ctrlKey && getShouldEnterCropMode(this.editor);
|
|
41
43
|
switch (info.target) {
|
|
42
44
|
case "canvas": {
|
|
43
45
|
const hitShape = getHitShapeOnCanvasPointerDown(this.editor);
|
|
@@ -51,7 +53,9 @@ class Idle extends StateNode {
|
|
|
51
53
|
}
|
|
52
54
|
const selectedShapeIds = this.editor.getSelectedShapeIds();
|
|
53
55
|
const onlySelectedShape = this.editor.getOnlySelectedShape();
|
|
54
|
-
const
|
|
56
|
+
const {
|
|
57
|
+
inputs: { currentPagePoint }
|
|
58
|
+
} = this.editor;
|
|
55
59
|
if (selectedShapeIds.length > 1 || onlySelectedShape && !this.editor.getShapeUtil(onlySelectedShape).hideSelectionBoundsBg(onlySelectedShape)) {
|
|
56
60
|
if (isPointInRotatedSelectionBounds(this.editor, currentPagePoint)) {
|
|
57
61
|
this.onPointerDown({
|
|
@@ -75,7 +79,7 @@ class Idle extends StateNode {
|
|
|
75
79
|
}
|
|
76
80
|
case "handle": {
|
|
77
81
|
if (this.editor.getIsReadonly()) break;
|
|
78
|
-
if (this.editor.inputs.
|
|
82
|
+
if (this.editor.inputs.altKey) {
|
|
79
83
|
this.parent.transition("pointing_shape", info);
|
|
80
84
|
} else {
|
|
81
85
|
this.parent.transition("pointing_handle", info);
|
|
@@ -104,8 +108,7 @@ class Idle extends StateNode {
|
|
|
104
108
|
case "top_right":
|
|
105
109
|
case "bottom_left":
|
|
106
110
|
case "bottom_right": {
|
|
107
|
-
|
|
108
|
-
if (info.ctrlKey && this.editor.canCropShape(onlySelectedShape)) {
|
|
111
|
+
if (shouldEnterCropMode) {
|
|
109
112
|
this.parent.transition("crop.pointing_crop_handle", info);
|
|
110
113
|
} else {
|
|
111
114
|
if (info.accelKey) {
|
|
@@ -134,13 +137,12 @@ class Idle extends StateNode {
|
|
|
134
137
|
}
|
|
135
138
|
}
|
|
136
139
|
onDoubleClick(info) {
|
|
137
|
-
if (this.editor.inputs.
|
|
140
|
+
if (this.editor.inputs.shiftKey || info.phase !== "up") return;
|
|
138
141
|
if (info.ctrlKey || info.shiftKey) return;
|
|
139
142
|
switch (info.target) {
|
|
140
143
|
case "canvas": {
|
|
141
144
|
const hoveredShape = this.editor.getHoveredShape();
|
|
142
|
-
const
|
|
143
|
-
const hitShape = hoveredShape && !this.editor.isShapeOfType(hoveredShape, "group") ? hoveredShape : this.editor.getSelectedShapeAtPoint(currentPagePoint) ?? this.editor.getShapeAtPoint(currentPagePoint, {
|
|
145
|
+
const hitShape = hoveredShape && !this.editor.isShapeOfType(hoveredShape, "group") ? hoveredShape : this.editor.getSelectedShapeAtPoint(this.editor.inputs.currentPagePoint) ?? this.editor.getShapeAtPoint(this.editor.inputs.currentPagePoint, {
|
|
144
146
|
margin: this.editor.options.hitTestMargin / this.editor.getZoomLevel(),
|
|
145
147
|
hitInside: false
|
|
146
148
|
});
|
|
@@ -166,31 +168,20 @@ class Idle extends StateNode {
|
|
|
166
168
|
});
|
|
167
169
|
return;
|
|
168
170
|
}
|
|
169
|
-
if (!this.editor.inputs.
|
|
171
|
+
if (!this.editor.inputs.shiftKey) {
|
|
170
172
|
this.handleDoubleClickOnCanvas(info);
|
|
171
173
|
}
|
|
172
174
|
break;
|
|
173
175
|
}
|
|
174
176
|
case "selection": {
|
|
177
|
+
if (this.editor.getIsReadonly()) break;
|
|
175
178
|
const onlySelectedShape = this.editor.getOnlySelectedShape();
|
|
176
179
|
if (onlySelectedShape) {
|
|
177
180
|
const util = this.editor.getShapeUtil(onlySelectedShape);
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
if (this.editor.getIsReadonly()) {
|
|
181
|
-
if (this.editor.canEditShape(onlySelectedShape, {
|
|
182
|
-
type: isCorner ? "double-click-corner" : isEdge ? "double-click-edge" : "double-click"
|
|
183
|
-
})) {
|
|
184
|
-
this.startEditingShape(
|
|
185
|
-
onlySelectedShape,
|
|
186
|
-
info,
|
|
187
|
-
true
|
|
188
|
-
/* select all */
|
|
189
|
-
);
|
|
190
|
-
}
|
|
191
|
-
break;
|
|
181
|
+
if (!this.canInteractWithShapeInReadOnly(onlySelectedShape)) {
|
|
182
|
+
return;
|
|
192
183
|
}
|
|
193
|
-
if (
|
|
184
|
+
if (info.handle === "right" || info.handle === "left" || info.handle === "top" || info.handle === "bottom") {
|
|
194
185
|
const change = util.onDoubleClickEdge?.(onlySelectedShape, info);
|
|
195
186
|
if (change) {
|
|
196
187
|
this.editor.markHistoryStoppingPoint("double click edge");
|
|
@@ -199,7 +190,7 @@ class Idle extends StateNode {
|
|
|
199
190
|
return;
|
|
200
191
|
}
|
|
201
192
|
}
|
|
202
|
-
if (
|
|
193
|
+
if (info.handle === "top_left" || info.handle === "top_right" || info.handle === "bottom_right" || info.handle === "bottom_left") {
|
|
203
194
|
const change = util.onDoubleClickCorner?.(onlySelectedShape, info);
|
|
204
195
|
if (change) {
|
|
205
196
|
this.editor.markHistoryStoppingPoint("double click corner");
|
|
@@ -208,11 +199,11 @@ class Idle extends StateNode {
|
|
|
208
199
|
return;
|
|
209
200
|
}
|
|
210
201
|
}
|
|
211
|
-
if (this.editor.
|
|
202
|
+
if (util.canCrop(onlySelectedShape) && !this.editor.isShapeOrAncestorLocked(onlySelectedShape)) {
|
|
212
203
|
this.parent.transition("crop", info);
|
|
213
204
|
return;
|
|
214
205
|
}
|
|
215
|
-
if (this.
|
|
206
|
+
if (this.shouldStartEditingShape(onlySelectedShape)) {
|
|
216
207
|
this.startEditingShape(
|
|
217
208
|
onlySelectedShape,
|
|
218
209
|
info,
|
|
@@ -240,7 +231,7 @@ class Idle extends StateNode {
|
|
|
240
231
|
this.parent.transition("crop", info);
|
|
241
232
|
return;
|
|
242
233
|
}
|
|
243
|
-
if (this.
|
|
234
|
+
if (this.shouldStartEditingShape(shape)) {
|
|
244
235
|
this.startEditingShape(
|
|
245
236
|
shape,
|
|
246
237
|
info,
|
|
@@ -260,7 +251,7 @@ class Idle extends StateNode {
|
|
|
260
251
|
if (changes) {
|
|
261
252
|
this.editor.updateShapes([changes]);
|
|
262
253
|
} else {
|
|
263
|
-
if (this.
|
|
254
|
+
if (this.shouldStartEditingShape(shape)) {
|
|
264
255
|
this.startEditingShape(
|
|
265
256
|
shape,
|
|
266
257
|
info,
|
|
@@ -276,7 +267,7 @@ class Idle extends StateNode {
|
|
|
276
267
|
switch (info.target) {
|
|
277
268
|
case "canvas": {
|
|
278
269
|
const hoveredShape = this.editor.getHoveredShape();
|
|
279
|
-
const hitShape = hoveredShape && !this.editor.isShapeOfType(hoveredShape, "group") ? hoveredShape : this.editor.getShapeAtPoint(this.editor.inputs.
|
|
270
|
+
const hitShape = hoveredShape && !this.editor.isShapeOfType(hoveredShape, "group") ? hoveredShape : this.editor.getShapeAtPoint(this.editor.inputs.currentPagePoint, {
|
|
280
271
|
margin: this.editor.options.hitTestMargin / this.editor.getZoomLevel(),
|
|
281
272
|
hitInside: false,
|
|
282
273
|
hitLabels: true,
|
|
@@ -294,7 +285,9 @@ class Idle extends StateNode {
|
|
|
294
285
|
}
|
|
295
286
|
const selectedShapeIds = this.editor.getSelectedShapeIds();
|
|
296
287
|
const onlySelectedShape = this.editor.getOnlySelectedShape();
|
|
297
|
-
const
|
|
288
|
+
const {
|
|
289
|
+
inputs: { currentPagePoint }
|
|
290
|
+
} = this.editor;
|
|
298
291
|
if (selectedShapeIds.length > 1 || onlySelectedShape && !this.editor.getShapeUtil(onlySelectedShape).hideSelectionBoundsBg(onlySelectedShape)) {
|
|
299
292
|
if (isPointInRotatedSelectionBounds(this.editor, currentPagePoint)) {
|
|
300
293
|
this.onRightClick({
|
|
@@ -363,7 +356,7 @@ class Idle extends StateNode {
|
|
|
363
356
|
const onlySelectedShape = this.editor.getOnlySelectedShape();
|
|
364
357
|
if (onlySelectedShape && // If it's a note shape, then edit on type
|
|
365
358
|
this.editor.isShapeOfType(onlySelectedShape, "note") && // If it's not locked or anything
|
|
366
|
-
this.
|
|
359
|
+
this.shouldStartEditingShape(onlySelectedShape)) {
|
|
367
360
|
this.startEditingShape(
|
|
368
361
|
onlySelectedShape,
|
|
369
362
|
{
|
|
@@ -415,7 +408,7 @@ class Idle extends StateNode {
|
|
|
415
408
|
return;
|
|
416
409
|
}
|
|
417
410
|
const onlySelectedShape = this.editor.getOnlySelectedShape();
|
|
418
|
-
if (onlySelectedShape && this.
|
|
411
|
+
if (onlySelectedShape && this.shouldStartEditingShape(onlySelectedShape)) {
|
|
419
412
|
this.startEditingShape(
|
|
420
413
|
onlySelectedShape,
|
|
421
414
|
{
|
|
@@ -428,7 +421,7 @@ class Idle extends StateNode {
|
|
|
428
421
|
);
|
|
429
422
|
return;
|
|
430
423
|
}
|
|
431
|
-
if (this.editor
|
|
424
|
+
if (getShouldEnterCropMode(this.editor)) {
|
|
432
425
|
this.parent.transition("crop", info);
|
|
433
426
|
}
|
|
434
427
|
break;
|
|
@@ -442,14 +435,16 @@ class Idle extends StateNode {
|
|
|
442
435
|
}
|
|
443
436
|
}
|
|
444
437
|
}
|
|
438
|
+
shouldStartEditingShape(shape = this.editor.getOnlySelectedShape()) {
|
|
439
|
+
if (!shape) return false;
|
|
440
|
+
if (this.editor.isShapeOrAncestorLocked(shape) && shape.type !== "embed") return false;
|
|
441
|
+
if (!this.canInteractWithShapeInReadOnly(shape)) return false;
|
|
442
|
+
return this.editor.getShapeUtil(shape).canEdit(shape);
|
|
443
|
+
}
|
|
445
444
|
startEditingShape(shape, info, shouldSelectAll) {
|
|
446
|
-
|
|
445
|
+
if (this.editor.isShapeOrAncestorLocked(shape) && shape.type !== "embed") return;
|
|
447
446
|
this.editor.markHistoryStoppingPoint("editing shape");
|
|
448
|
-
|
|
449
|
-
startEditingShapeWithRichText(editor, shape, { selectAll: shouldSelectAll });
|
|
450
|
-
} else {
|
|
451
|
-
editor.setEditingShape(shape);
|
|
452
|
-
}
|
|
447
|
+
startEditingShapeWithLabel(this.editor, shape, shouldSelectAll);
|
|
453
448
|
this.parent.transition("editing_shape", info);
|
|
454
449
|
}
|
|
455
450
|
isOverArrowLabelTest(shape) {
|
|
@@ -461,7 +456,7 @@ class Idle extends StateNode {
|
|
|
461
456
|
if (!this.editor.options.createTextOnCanvasDoubleClick) return;
|
|
462
457
|
this.editor.markHistoryStoppingPoint("creating text shape");
|
|
463
458
|
const id = createShapeId();
|
|
464
|
-
const { x, y } = this.editor.inputs.
|
|
459
|
+
const { x, y } = this.editor.inputs.currentPagePoint;
|
|
465
460
|
this.editor.createShapes([
|
|
466
461
|
{
|
|
467
462
|
id,
|
|
@@ -476,8 +471,15 @@ class Idle extends StateNode {
|
|
|
476
471
|
]);
|
|
477
472
|
const shape = this.editor.getShape(id);
|
|
478
473
|
if (!shape) return;
|
|
479
|
-
|
|
480
|
-
|
|
474
|
+
const util = this.editor.getShapeUtil(shape);
|
|
475
|
+
if (this.editor.getIsReadonly()) {
|
|
476
|
+
if (!util.canEditInReadonly(shape)) {
|
|
477
|
+
return;
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
this.editor.setEditingShape(id);
|
|
481
|
+
this.editor.select(id);
|
|
482
|
+
this.parent.transition("editing_shape", info);
|
|
481
483
|
}
|
|
482
484
|
nudgeSelectedShapes(ephemeral = false) {
|
|
483
485
|
const {
|
|
@@ -499,6 +501,12 @@ class Idle extends StateNode {
|
|
|
499
501
|
this.editor.nudgeShapes(selectedShapeIds, delta.mul(step));
|
|
500
502
|
kickoutOccludedShapes(this.editor, selectedShapeIds);
|
|
501
503
|
}
|
|
504
|
+
canInteractWithShapeInReadOnly(shape) {
|
|
505
|
+
if (!this.editor.getIsReadonly()) return true;
|
|
506
|
+
const util = this.editor.getShapeUtil(shape);
|
|
507
|
+
if (util.canEditInReadonly(shape)) return true;
|
|
508
|
+
return false;
|
|
509
|
+
}
|
|
502
510
|
}
|
|
503
511
|
const MAJOR_NUDGE_FACTOR = 10;
|
|
504
512
|
const MINOR_NUDGE_FACTOR = 1;
|