tldraw 4.3.0-canary.9c474ef3fad5 → 4.3.0-canary.a2419250444e
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 +285 -237
- package/dist-cjs/index.js +12 -5
- package/dist-cjs/index.js.map +2 -2
- package/dist-cjs/lib/defaultEmbedDefinitions.js +1 -1
- 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 +6 -1
- package/dist-cjs/lib/defaultSideEffects.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js +6 -2
- package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js.map +2 -2
- 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/getElbowArrowInfo.js +1 -1
- package/dist-cjs/lib/shapes/arrow/elbow/getElbowArrowInfo.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/toolStates/Idle.js +4 -10
- package/dist-cjs/lib/shapes/arrow/toolStates/Idle.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.js +7 -4
- 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/draw/DrawShapeUtil.js +22 -20
- package/dist-cjs/lib/shapes/draw/DrawShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/draw/getPath.js +20 -11
- package/dist-cjs/lib/shapes/draw/getPath.js.map +2 -2
- package/dist-cjs/lib/shapes/draw/toolStates/Drawing.js +82 -86
- package/dist-cjs/lib/shapes/draw/toolStates/Drawing.js.map +3 -3
- package/dist-cjs/lib/shapes/embed/EmbedShapeUtil.js +6 -0
- package/dist-cjs/lib/shapes/embed/EmbedShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js +5 -4
- package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/geo/GeoShapeUtil.js +136 -136
- package/dist-cjs/lib/shapes/geo/GeoShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/geo/toolStates/Idle.js +5 -10
- 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 +22 -20
- 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 +1 -6
- package/dist-cjs/lib/shapes/note/NoteShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/note/toolStates/Pointing.js +5 -10
- package/dist-cjs/lib/shapes/note/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/HyperlinkButton.js +1 -1
- package/dist-cjs/lib/shapes/shared/HyperlinkButton.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/RichTextLabel.js +1 -1
- package/dist-cjs/lib/shapes/shared/RichTextLabel.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/text/RichTextArea.js +5 -0
- package/dist-cjs/lib/shapes/text/RichTextArea.js.map +2 -2
- package/dist-cjs/lib/shapes/text/toolStates/Idle.js +4 -10
- package/dist-cjs/lib/shapes/text/toolStates/Idle.js.map +2 -2
- package/dist-cjs/lib/shapes/text/toolStates/Pointing.js +7 -5
- package/dist-cjs/lib/shapes/text/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/tools/EraserTool/childStates/Erasing.js +4 -5
- package/dist-cjs/lib/tools/EraserTool/childStates/Erasing.js.map +2 -2
- package/dist-cjs/lib/tools/EraserTool/childStates/Pointing.js +2 -4
- package/dist-cjs/lib/tools/EraserTool/childStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/tools/HandTool/HandTool.js +3 -5
- package/dist-cjs/lib/tools/HandTool/HandTool.js.map +2 -2
- package/dist-cjs/lib/tools/HandTool/childStates/Dragging.js +3 -2
- 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 +9 -7
- package/dist-cjs/lib/tools/SelectTool/DragAndDropManager.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Brushing.js +6 -5
- package/dist-cjs/lib/tools/SelectTool/childStates/Brushing.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/Cropping.js +4 -6
- 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 +2 -1
- 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 +7 -5
- package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/EditingShape.js +38 -11
- package/dist-cjs/lib/tools/SelectTool/childStates/EditingShape.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Idle.js +42 -50
- 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 +4 -14
- 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 +4 -13
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingShape.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js +5 -6
- package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Rotating.js +2 -3
- package/dist-cjs/lib/tools/SelectTool/childStates/Rotating.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/ScribbleBrushing.js +7 -6
- package/dist-cjs/lib/tools/SelectTool/childStates/ScribbleBrushing.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js +13 -11
- package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/selectHelpers.js +15 -4
- 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 +5 -6
- package/dist-cjs/lib/tools/ZoomTool/childStates/ZoomBrushing.js.map +2 -2
- package/dist-cjs/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.js +1 -3
- package/dist-cjs/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.js.map +2 -2
- 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/ContextMenu/DefaultContextMenu.js +1 -3
- 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 +1 -21
- package/dist-cjs/lib/ui/components/DefaultDebugPanel.js.map +2 -2
- package/dist-cjs/lib/ui/components/HelperButtons/BackToContent.js +1 -1
- package/dist-cjs/lib/ui/components/HelperButtons/BackToContent.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 +2 -15
- package/dist-cjs/lib/ui/components/OfflineIndicator/OfflineIndicator.js.map +3 -3
- package/dist-cjs/lib/ui/components/PageMenu/PageItemInput.js +3 -1
- package/dist-cjs/lib/ui/components/PageMenu/PageItemInput.js.map +2 -2
- package/dist-cjs/lib/ui/components/SharePanel/PeopleMenu.js +6 -0
- package/dist-cjs/lib/ui/components/SharePanel/PeopleMenu.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/ZoomMenu/DefaultZoomMenu.js +1 -1
- package/dist-cjs/lib/ui/components/ZoomMenu/DefaultZoomMenu.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiContextualToolbar.js +3 -1
- package/dist-cjs/lib/ui/components/primitives/TldrawUiContextualToolbar.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiTooltip.js +6 -5
- 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 +13 -6
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js.map +2 -2
- package/dist-cjs/lib/ui/context/actions.js +6 -6
- package/dist-cjs/lib/ui/context/actions.js.map +2 -2
- package/dist-cjs/lib/ui/context/components.js +1 -2
- package/dist-cjs/lib/ui/context/components.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/useKeyboardShortcuts.js +2 -2
- package/dist-cjs/lib/ui/hooks/useKeyboardShortcuts.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/useTools.js +4 -5
- package/dist-cjs/lib/ui/hooks/useTools.js.map +2 -2
- package/dist-cjs/lib/ui/version.js +3 -3
- package/dist-cjs/lib/ui/version.js.map +1 -1
- package/dist-cjs/lib/utils/excalidraw/putExcalidrawContent.js +8 -6
- package/dist-cjs/lib/utils/excalidraw/putExcalidrawContent.js.map +2 -2
- package/dist-cjs/lib/{tools/selection-logic/getShouldEnterCropModeOnPointerDown.js → utils/test-helpers.js} +21 -8
- package/dist-cjs/lib/utils/test-helpers.js.map +7 -0
- package/dist-cjs/lib/utils/text/richText.js +4 -2
- package/dist-cjs/lib/utils/text/richText.js.map +2 -2
- package/dist-cjs/lib/utils/tldr/buildFromV1Document.js +7 -2
- package/dist-cjs/lib/utils/tldr/buildFromV1Document.js.map +2 -2
- package/dist-esm/index.d.mts +285 -237
- package/dist-esm/index.mjs +12 -5
- package/dist-esm/index.mjs.map +2 -2
- package/dist-esm/lib/defaultEmbedDefinitions.mjs +1 -1
- 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 +6 -1
- package/dist-esm/lib/defaultSideEffects.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs +6 -2
- 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/getElbowArrowInfo.mjs +1 -1
- package/dist-esm/lib/shapes/arrow/elbow/getElbowArrowInfo.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/toolStates/Idle.mjs +4 -10
- package/dist-esm/lib/shapes/arrow/toolStates/Idle.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs +7 -4
- 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/draw/DrawShapeUtil.mjs +27 -22
- package/dist-esm/lib/shapes/draw/DrawShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/draw/getPath.mjs +21 -11
- package/dist-esm/lib/shapes/draw/getPath.mjs.map +2 -2
- package/dist-esm/lib/shapes/draw/toolStates/Drawing.mjs +83 -86
- package/dist-esm/lib/shapes/draw/toolStates/Drawing.mjs.map +3 -3
- package/dist-esm/lib/shapes/embed/EmbedShapeUtil.mjs +6 -0
- package/dist-esm/lib/shapes/embed/EmbedShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs +5 -4
- package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/geo/GeoShapeUtil.mjs +137 -136
- package/dist-esm/lib/shapes/geo/GeoShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/geo/toolStates/Idle.mjs +5 -10
- 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 +23 -21
- 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 +2 -7
- package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/note/toolStates/Pointing.mjs +5 -10
- package/dist-esm/lib/shapes/note/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/HyperlinkButton.mjs +1 -1
- package/dist-esm/lib/shapes/shared/HyperlinkButton.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/RichTextLabel.mjs +1 -1
- package/dist-esm/lib/shapes/shared/RichTextLabel.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/text/RichTextArea.mjs +5 -0
- package/dist-esm/lib/shapes/text/RichTextArea.mjs.map +2 -2
- package/dist-esm/lib/shapes/text/toolStates/Idle.mjs +4 -10
- package/dist-esm/lib/shapes/text/toolStates/Idle.mjs.map +2 -2
- package/dist-esm/lib/shapes/text/toolStates/Pointing.mjs +7 -5
- package/dist-esm/lib/shapes/text/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/tools/EraserTool/childStates/Erasing.mjs +4 -5
- package/dist-esm/lib/tools/EraserTool/childStates/Erasing.mjs.map +2 -2
- package/dist-esm/lib/tools/EraserTool/childStates/Pointing.mjs +2 -4
- package/dist-esm/lib/tools/EraserTool/childStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/tools/HandTool/HandTool.mjs +3 -5
- package/dist-esm/lib/tools/HandTool/HandTool.mjs.map +2 -2
- package/dist-esm/lib/tools/HandTool/childStates/Dragging.mjs +3 -2
- 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 +9 -7
- package/dist-esm/lib/tools/SelectTool/DragAndDropManager.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Brushing.mjs +6 -5
- package/dist-esm/lib/tools/SelectTool/childStates/Brushing.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/Cropping.mjs +4 -6
- 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 +2 -1
- 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 +7 -5
- package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/EditingShape.mjs +38 -11
- package/dist-esm/lib/tools/SelectTool/childStates/EditingShape.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Idle.mjs +43 -51
- 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 +5 -15
- 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 +4 -13
- package/dist-esm/lib/tools/SelectTool/childStates/PointingShape.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs +5 -6
- package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Rotating.mjs +2 -3
- package/dist-esm/lib/tools/SelectTool/childStates/Rotating.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/ScribbleBrushing.mjs +7 -6
- package/dist-esm/lib/tools/SelectTool/childStates/ScribbleBrushing.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs +13 -11
- package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/selectHelpers.mjs +17 -4
- 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 +5 -6
- package/dist-esm/lib/tools/ZoomTool/childStates/ZoomBrushing.mjs.map +2 -2
- package/dist-esm/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.mjs +1 -3
- package/dist-esm/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.mjs.map +2 -2
- 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/ContextMenu/DefaultContextMenu.mjs +1 -3
- 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 +3 -30
- package/dist-esm/lib/ui/components/DefaultDebugPanel.mjs.map +2 -2
- package/dist-esm/lib/ui/components/HelperButtons/BackToContent.mjs +1 -1
- package/dist-esm/lib/ui/components/HelperButtons/BackToContent.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 +3 -6
- package/dist-esm/lib/ui/components/OfflineIndicator/OfflineIndicator.mjs.map +2 -2
- package/dist-esm/lib/ui/components/PageMenu/PageItemInput.mjs +3 -1
- package/dist-esm/lib/ui/components/PageMenu/PageItemInput.mjs.map +2 -2
- package/dist-esm/lib/ui/components/SharePanel/PeopleMenu.mjs +6 -0
- package/dist-esm/lib/ui/components/SharePanel/PeopleMenu.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/ZoomMenu/DefaultZoomMenu.mjs +1 -1
- package/dist-esm/lib/ui/components/ZoomMenu/DefaultZoomMenu.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiContextualToolbar.mjs +3 -1
- package/dist-esm/lib/ui/components/primitives/TldrawUiContextualToolbar.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiTooltip.mjs +6 -5
- 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 +13 -6
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs.map +2 -2
- package/dist-esm/lib/ui/context/actions.mjs +6 -6
- package/dist-esm/lib/ui/context/actions.mjs.map +2 -2
- package/dist-esm/lib/ui/context/components.mjs +1 -2
- package/dist-esm/lib/ui/context/components.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/useKeyboardShortcuts.mjs +2 -2
- package/dist-esm/lib/ui/hooks/useKeyboardShortcuts.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/useTools.mjs +4 -5
- 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 +9 -6
- package/dist-esm/lib/utils/excalidraw/putExcalidrawContent.mjs.map +2 -2
- package/dist-esm/lib/utils/test-helpers.mjs +21 -0
- package/dist-esm/lib/utils/test-helpers.mjs.map +7 -0
- package/dist-esm/lib/utils/text/richText.mjs +5 -2
- package/dist-esm/lib/utils/text/richText.mjs.map +2 -2
- package/dist-esm/lib/utils/tldr/buildFromV1Document.mjs +8 -2
- package/dist-esm/lib/utils/tldr/buildFromV1Document.mjs.map +2 -2
- package/package.json +18 -16
- package/src/index.ts +5 -2
- package/src/lib/Tldraw.test.tsx +46 -1
- package/src/lib/defaultEmbedDefinitions.ts +2 -1
- package/src/lib/defaultExternalContentHandlers.ts +10 -10
- package/src/lib/defaultSideEffects.ts +6 -1
- package/src/lib/shapes/arrow/ArrowShapeOptions.test.ts +40 -133
- package/src/lib/shapes/arrow/ArrowShapeTool.test.ts +8 -8
- package/src/lib/shapes/arrow/ArrowShapeUtil.tsx +6 -4
- package/src/lib/shapes/arrow/arrowLabel.ts +1 -1
- package/src/lib/shapes/arrow/arrowTargetState.ts +1 -1
- package/src/lib/shapes/arrow/elbow/getElbowArrowInfo.test.ts +80 -0
- package/src/lib/shapes/arrow/elbow/getElbowArrowInfo.tsx +1 -1
- package/src/lib/shapes/arrow/toolStates/Idle.tsx +4 -14
- package/src/lib/shapes/arrow/toolStates/Pointing.tsx +7 -4
- package/src/lib/shapes/bookmark/BookmarkShapeUtil.tsx +1 -1
- package/src/lib/shapes/draw/DrawShapeUtil.test.ts +146 -0
- package/src/lib/shapes/draw/DrawShapeUtil.tsx +28 -24
- package/src/lib/shapes/draw/getPath.ts +31 -10
- package/src/lib/shapes/draw/toolStates/Drawing.ts +96 -86
- package/src/lib/shapes/embed/EmbedShapeUtil.tsx +7 -0
- package/src/lib/shapes/frame/FrameShapeUtil.tsx +9 -3
- package/src/lib/shapes/geo/GeoShapeUtil.tsx +219 -172
- package/src/lib/shapes/geo/toolStates/Idle.ts +5 -15
- package/src/lib/shapes/geo/toolStates/Pointing.ts +3 -3
- package/src/lib/shapes/highlight/HighlightShapeUtil.test.ts +146 -0
- package/src/lib/shapes/highlight/HighlightShapeUtil.tsx +24 -23
- package/src/lib/shapes/line/toolStates/Pointing.ts +3 -3
- package/src/lib/shapes/note/NoteShapeUtil.tsx +2 -2
- package/src/lib/shapes/note/noteCloning.test.ts +3 -1
- package/src/lib/shapes/note/toolStates/Pointing.ts +5 -10
- package/src/lib/shapes/shared/HyperlinkButton.tsx +1 -1
- package/src/lib/shapes/shared/RichTextLabel.tsx +1 -1
- package/src/lib/shapes/shared/interpolate-props.ts +4 -4
- package/src/lib/shapes/text/RichTextArea.tsx +5 -0
- package/src/lib/shapes/text/toolStates/Idle.ts +4 -14
- package/src/lib/shapes/text/toolStates/Pointing.ts +7 -7
- package/src/lib/tools/EraserTool/childStates/Erasing.ts +4 -5
- package/src/lib/tools/EraserTool/childStates/Pointing.ts +2 -4
- package/src/lib/tools/HandTool/HandTool.ts +3 -5
- package/src/lib/tools/HandTool/childStates/Dragging.ts +3 -2
- 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 +12 -7
- package/src/lib/tools/SelectTool/childStates/Brushing.ts +6 -5
- package/src/lib/tools/SelectTool/childStates/Crop/children/Cropping.ts +7 -6
- package/src/lib/tools/SelectTool/childStates/Crop/children/Idle.ts +1 -1
- 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 +2 -1
- package/src/lib/tools/SelectTool/childStates/Crop/children/crop_helpers.ts +1 -1
- package/src/lib/tools/SelectTool/childStates/DraggingHandle.tsx +7 -5
- package/src/lib/tools/SelectTool/childStates/EditingShape.ts +55 -12
- package/src/lib/tools/SelectTool/childStates/Idle.ts +58 -71
- package/src/lib/tools/SelectTool/childStates/PointingArrowLabel.ts +6 -7
- package/src/lib/tools/SelectTool/childStates/PointingCanvas.ts +1 -1
- package/src/lib/tools/SelectTool/childStates/PointingHandle.ts +5 -5
- 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 +2 -2
- package/src/lib/tools/SelectTool/childStates/PointingShape.ts +4 -14
- package/src/lib/tools/SelectTool/childStates/Resizing.ts +6 -6
- package/src/lib/tools/SelectTool/childStates/Rotating.ts +2 -3
- package/src/lib/tools/SelectTool/childStates/ScribbleBrushing.ts +7 -6
- package/src/lib/tools/SelectTool/childStates/Translating.ts +15 -12
- package/src/lib/tools/SelectTool/selectHelpers.ts +39 -4
- 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 +5 -6
- package/src/lib/tools/selection-logic/getHitShapeOnCanvasPointerDown.ts +1 -3
- 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 +5 -2
- package/src/lib/ui/components/ContextMenu/DefaultContextMenu.tsx +1 -3
- package/src/lib/ui/components/CursorChatBubble.tsx +2 -2
- package/src/lib/ui/components/DefaultDebugPanel.tsx +3 -42
- package/src/lib/ui/components/HelperButtons/BackToContent.tsx +1 -1
- 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 +6 -5
- package/src/lib/ui/components/PageMenu/PageItemInput.tsx +3 -1
- package/src/lib/ui/components/SharePanel/PeopleMenu.tsx +8 -0
- 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/ZoomMenu/DefaultZoomMenu.tsx +1 -1
- package/src/lib/ui/components/primitives/TldrawUiContextualToolbar.tsx +5 -3
- package/src/lib/ui/components/primitives/TldrawUiTooltip.tsx +12 -5
- 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 +5 -2
- package/src/lib/ui/context/actions.tsx +6 -6
- package/src/lib/ui/context/components.tsx +1 -2
- package/src/lib/ui/hooks/useClipboardEvents.ts +2 -2
- package/src/lib/ui/hooks/useKeyboardShortcuts.ts +2 -2
- package/src/lib/ui/hooks/useTools.tsx +4 -5
- package/src/lib/ui/version.ts +3 -3
- package/src/lib/ui.css +27 -23
- package/src/lib/utils/excalidraw/__snapshots__/putExcalidrawContent.test.tsx.snap +12 -48
- package/src/lib/utils/excalidraw/putExcalidrawContent.ts +11 -6
- package/src/lib/utils/test-helpers.ts +60 -0
- package/src/lib/utils/text/richText.ts +6 -5
- package/src/lib/utils/tldr/buildFromV1Document.ts +9 -2
- package/src/test/Editor.test.tsx +40 -29
- package/src/test/EraserTool.test.ts +10 -12
- package/src/test/TestEditor.ts +48 -47
- package/src/test/TldrawEditor.test.tsx +3 -2
- package/src/test/__snapshots__/drawing.test.ts.snap +3 -1257
- package/src/test/__snapshots__/resizing.test.ts.snap +3 -12
- package/src/test/arrows-megabus.test.tsx +1 -1
- package/src/test/commands/__snapshots__/getSvgString.test.ts.snap +8 -8
- package/src/test/commands/setCamera.test.ts +13 -11
- package/src/test/commands/stackShapes.test.ts +34 -8
- package/src/test/commands/zoomToBounds.test.ts +19 -3
- package/src/test/commands/zoomToSelection.test.ts +14 -3
- package/src/test/custom-clipping.test.ts +16 -9
- package/src/test/drawing.test.ts +17 -10
- package/src/test/flipShapes.test.ts +33 -0
- package/src/test/frames.test.ts +92 -0
- package/src/test/groups.test.tsx +1 -1
- package/src/test/modifiers.test.ts +6 -6
- package/src/test/resizing.test.ts +7 -9
- package/src/test/selection-omnibus.test.ts +2 -2
- package/src/test/spacebarPanning.test.ts +28 -10
- package/src/test/test-jsx.tsx +3 -0
- package/src/test/ui/BackToContent.test.tsx +111 -0
- package/tldraw.css +33 -31
- package/dist-cjs/lib/tools/selection-logic/getShouldEnterCropModeOnPointerDown.js.map +0 -7
- package/dist-cjs/lib/ui/components/TopPanel/DefaultTopPanel.js +0 -32
- package/dist-cjs/lib/ui/components/TopPanel/DefaultTopPanel.js.map +0 -7
- package/dist-cjs/lib/utils/text/textDirection.js +0 -51
- package/dist-cjs/lib/utils/text/textDirection.js.map +0 -7
- package/dist-esm/lib/tools/selection-logic/getShouldEnterCropModeOnPointerDown.mjs +0 -8
- package/dist-esm/lib/tools/selection-logic/getShouldEnterCropModeOnPointerDown.mjs.map +0 -7
- package/dist-esm/lib/ui/components/TopPanel/DefaultTopPanel.mjs +0 -12
- package/dist-esm/lib/ui/components/TopPanel/DefaultTopPanel.mjs.map +0 -7
- package/dist-esm/lib/utils/text/textDirection.mjs +0 -31
- package/dist-esm/lib/utils/text/textDirection.mjs.map +0 -7
- package/src/lib/tools/selection-logic/getShouldEnterCropModeOnPointerDown.ts +0 -10
- package/src/lib/ui/components/TopPanel/DefaultTopPanel.tsx +0 -10
- package/src/lib/utils/text/textDirection.ts +0 -32
|
@@ -92,10 +92,13 @@ export class DragAndDropManager {
|
|
|
92
92
|
this.intervalTimerId = this.editor.timers.setInterval(
|
|
93
93
|
() => {
|
|
94
94
|
skip2of3FramesWhileMovingFast++
|
|
95
|
-
if (
|
|
95
|
+
if (
|
|
96
|
+
skip2of3FramesWhileMovingFast % 3 &&
|
|
97
|
+
this.editor.inputs.getPointerVelocity().len() > 0.5
|
|
98
|
+
) {
|
|
96
99
|
return
|
|
97
100
|
}
|
|
98
|
-
this.updateDraggingShapes(editor.inputs.
|
|
101
|
+
this.updateDraggingShapes(editor.inputs.getCurrentPagePoint(), cb)
|
|
99
102
|
},
|
|
100
103
|
movingShapes.length > 10 ? SLOW_POINTER_LAG_DURATION : FAST_POINTER_LAG_DURATION
|
|
101
104
|
)
|
|
@@ -103,9 +106,10 @@ export class DragAndDropManager {
|
|
|
103
106
|
|
|
104
107
|
dropShapes(shapes: TLShape[]) {
|
|
105
108
|
const { editor } = this
|
|
106
|
-
|
|
109
|
+
const currentPagePoint = editor.inputs.getCurrentPagePoint()
|
|
110
|
+
this.updateDraggingShapes(currentPagePoint)
|
|
107
111
|
|
|
108
|
-
const draggingOverShape = editor.getDraggingOverShape(
|
|
112
|
+
const draggingOverShape = editor.getDraggingOverShape(currentPagePoint, shapes)
|
|
109
113
|
|
|
110
114
|
if (draggingOverShape) {
|
|
111
115
|
const util = editor.getShapeUtil(draggingOverShape)
|
|
@@ -147,8 +151,9 @@ export class DragAndDropManager {
|
|
|
147
151
|
// This is the shape under the pointer that can handle at least one of the dragging shapes
|
|
148
152
|
const nextDraggingOverShape = editor.getDraggingOverShape(point, this.shapesToActuallyMove)
|
|
149
153
|
|
|
150
|
-
const
|
|
151
|
-
this.prevPagePoint.
|
|
154
|
+
const currentPagePoint = editor.inputs.getCurrentPagePoint()
|
|
155
|
+
const cursorDidMove = !this.prevPagePoint.equals(currentPagePoint)
|
|
156
|
+
this.prevPagePoint.setTo(currentPagePoint)
|
|
152
157
|
|
|
153
158
|
editor.run(() => {
|
|
154
159
|
if (this.prevDraggingOverShape?.id === nextDraggingOverShape?.id) {
|
|
@@ -156,7 +161,7 @@ export class DragAndDropManager {
|
|
|
156
161
|
cursorDidMove &&
|
|
157
162
|
nextDraggingOverShape &&
|
|
158
163
|
isShapeId(nextDraggingOverShape.id) &&
|
|
159
|
-
!editor.inputs.
|
|
164
|
+
!editor.inputs.getPreviousPagePoint().equals(currentPagePoint)
|
|
160
165
|
) {
|
|
161
166
|
// If the cursor moved, call onDragShapesOver for the previous dragging over shape
|
|
162
167
|
const util = editor.getShapeUtil(nextDraggingOverShape)
|
|
@@ -31,7 +31,7 @@ export class Brushing extends StateNode {
|
|
|
31
31
|
|
|
32
32
|
override onEnter(info: TLPointerEventInfo & { target: 'canvas' }) {
|
|
33
33
|
const { editor } = this
|
|
34
|
-
const
|
|
34
|
+
const altKey = editor.inputs.getAltKey()
|
|
35
35
|
|
|
36
36
|
this.isWrapMode = editor.user.getIsWrapMode()
|
|
37
37
|
|
|
@@ -96,7 +96,7 @@ export class Brushing extends StateNode {
|
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
override onKeyDown(info: TLKeyboardEventInfo) {
|
|
99
|
-
if (this.editor.inputs.
|
|
99
|
+
if (this.editor.inputs.getAltKey()) {
|
|
100
100
|
this.parent.transition('scribble_brushing', info)
|
|
101
101
|
} else {
|
|
102
102
|
this.hitTestShapes()
|
|
@@ -114,9 +114,10 @@ export class Brushing extends StateNode {
|
|
|
114
114
|
|
|
115
115
|
private hitTestShapes() {
|
|
116
116
|
const { editor, excludedShapeIds, isWrapMode } = this
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
|
|
117
|
+
const originPagePoint = editor.inputs.getOriginPagePoint()
|
|
118
|
+
const currentPagePoint = editor.inputs.getCurrentPagePoint()
|
|
119
|
+
const shiftKey = editor.inputs.getShiftKey()
|
|
120
|
+
const ctrlKey = editor.inputs.getCtrlKey()
|
|
120
121
|
|
|
121
122
|
// We'll be collecting shape ids of selected shapes; if we're holding shift key, we start from our initial shapes
|
|
122
123
|
const results = new Set(shiftKey ? this.initialSelectedShapeIds : [])
|
|
@@ -83,9 +83,12 @@ export class Cropping extends StateNode {
|
|
|
83
83
|
const util = this.editor.getShapeUtil<ShapeWithCrop>(shape.type)
|
|
84
84
|
if (!util) return
|
|
85
85
|
|
|
86
|
-
const
|
|
87
|
-
const currentPagePoint = this.editor.inputs
|
|
88
|
-
|
|
86
|
+
const shiftKey = this.editor.inputs.getShiftKey()
|
|
87
|
+
const currentPagePoint = this.editor.inputs
|
|
88
|
+
.getCurrentPagePoint()
|
|
89
|
+
.clone()
|
|
90
|
+
.sub(cursorHandleOffset)
|
|
91
|
+
const originPagePoint = this.editor.inputs.getOriginPagePoint().clone().sub(cursorHandleOffset)
|
|
89
92
|
const change = currentPagePoint.clone().sub(originPagePoint).rot(-shape.rotation)
|
|
90
93
|
|
|
91
94
|
const crop = shape.props.crop ?? getDefaultCrop()
|
|
@@ -145,9 +148,7 @@ export class Cropping extends StateNode {
|
|
|
145
148
|
|
|
146
149
|
private createSnapshot() {
|
|
147
150
|
const selectionRotation = this.editor.getSelectionRotation()
|
|
148
|
-
const
|
|
149
|
-
inputs: { originPagePoint },
|
|
150
|
-
} = this.editor
|
|
151
|
+
const originPagePoint = this.editor.inputs.getOriginPagePoint()
|
|
151
152
|
|
|
152
153
|
const shape = this.editor.getOnlySelectedShape() as ShapeWithCrop
|
|
153
154
|
|
|
@@ -112,7 +112,7 @@ export class Idle extends StateNode {
|
|
|
112
112
|
override onDoubleClick(info: TLClickEventInfo) {
|
|
113
113
|
// Without this, the double click's "settle" would trigger the reset
|
|
114
114
|
// after the user double clicked the edge to begin cropping
|
|
115
|
-
if (this.editor.inputs.
|
|
115
|
+
if (this.editor.inputs.getShiftKey() || info.phase !== 'up') return
|
|
116
116
|
|
|
117
117
|
const croppingShapeId = this.editor.getCroppingShapeId()
|
|
118
118
|
if (!croppingShapeId) return
|
|
@@ -94,7 +94,8 @@ export class TranslatingCrop extends StateNode {
|
|
|
94
94
|
|
|
95
95
|
if (!shape) return
|
|
96
96
|
|
|
97
|
-
const
|
|
97
|
+
const originPagePoint = this.editor.inputs.getOriginPagePoint()
|
|
98
|
+
const currentPagePoint = this.editor.inputs.getCurrentPagePoint()
|
|
98
99
|
const delta = currentPagePoint.clone().sub(originPagePoint)
|
|
99
100
|
const partial = getTranslateCroppedImageChange(this.editor, shape, delta)
|
|
100
101
|
|
|
@@ -12,7 +12,7 @@ export function getTranslateCroppedImageChange(editor: Editor, shape: ShapeWithC
|
|
|
12
12
|
return
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
const flatten: 'x' | 'y' | null = editor.inputs.
|
|
15
|
+
const flatten: 'x' | 'y' | null = editor.inputs.getShiftKey()
|
|
16
16
|
? Math.abs(delta.x) < Math.abs(delta.y)
|
|
17
17
|
? 'x'
|
|
18
18
|
: 'y'
|
|
@@ -73,7 +73,7 @@ export class DraggingHandle extends StateNode {
|
|
|
73
73
|
|
|
74
74
|
this.initialPageTransform = this.editor.getShapePageTransform(shape)!
|
|
75
75
|
this.initialPageRotation = this.initialPageTransform.rotation()
|
|
76
|
-
this.initialPagePoint = this.editor.inputs.
|
|
76
|
+
this.initialPagePoint = this.editor.inputs.getOriginPagePoint().clone()
|
|
77
77
|
|
|
78
78
|
this.editor.setCursor({ type: isCreating ? 'cross' : 'grabbing', rotation: 0 })
|
|
79
79
|
|
|
@@ -284,10 +284,12 @@ export class DraggingHandle extends StateNode {
|
|
|
284
284
|
const { editor, shapeId, initialPagePoint } = this
|
|
285
285
|
const { initialHandle, initialPageRotation, initialAdjacentHandle } = this
|
|
286
286
|
const isSnapMode = this.editor.user.getIsSnapMode()
|
|
287
|
-
const {
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
287
|
+
const { snaps } = editor
|
|
288
|
+
const currentPagePoint = editor.inputs.getCurrentPagePoint()
|
|
289
|
+
const shiftKey = editor.inputs.getShiftKey()
|
|
290
|
+
const ctrlKey = editor.inputs.getCtrlKey()
|
|
291
|
+
const altKey = editor.inputs.getAltKey()
|
|
292
|
+
const pointerVelocity = editor.inputs.getPointerVelocity()
|
|
291
293
|
|
|
292
294
|
const initial = this.info.shape
|
|
293
295
|
|
|
@@ -18,13 +18,25 @@ interface EditingShapeInfo {
|
|
|
18
18
|
export class EditingShape extends StateNode {
|
|
19
19
|
static override id = 'editing_shape'
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
hitLabelOnShapeForPointerUp: TLShape | null = null
|
|
22
22
|
private info = {} as EditingShapeInfo
|
|
23
|
+
private didPointerDownOnEditingShape = false
|
|
24
|
+
|
|
25
|
+
private isTextInputFocused(): boolean {
|
|
26
|
+
const container = this.editor.getContainer()
|
|
27
|
+
return (
|
|
28
|
+
container.contains(document.activeElement) &&
|
|
29
|
+
(document.activeElement?.nodeName === 'INPUT' ||
|
|
30
|
+
document.activeElement?.nodeName === 'TEXTAREA' ||
|
|
31
|
+
(document.activeElement as HTMLElement)?.isContentEditable)
|
|
32
|
+
)
|
|
33
|
+
}
|
|
23
34
|
|
|
24
35
|
override onEnter(info: EditingShapeInfo) {
|
|
25
36
|
const editingShape = this.editor.getEditingShape()
|
|
26
37
|
if (!editingShape) throw Error('Entered editing state without an editing shape')
|
|
27
|
-
this.
|
|
38
|
+
this.hitLabelOnShapeForPointerUp = null
|
|
39
|
+
this.didPointerDownOnEditingShape = false
|
|
28
40
|
|
|
29
41
|
this.info = info
|
|
30
42
|
|
|
@@ -54,15 +66,34 @@ export class EditingShape extends StateNode {
|
|
|
54
66
|
override onPointerMove(info: TLPointerEventInfo) {
|
|
55
67
|
// In the case where on pointer down we hit a shape's label, we need to check if the user is dragging.
|
|
56
68
|
// and if they are, we need to transition to translating instead.
|
|
57
|
-
if (this.
|
|
69
|
+
if (this.hitLabelOnShapeForPointerUp && this.editor.inputs.getIsDragging()) {
|
|
58
70
|
if (this.editor.getIsReadonly()) return
|
|
59
|
-
if (this.
|
|
60
|
-
|
|
71
|
+
if (this.hitLabelOnShapeForPointerUp.isLocked) return
|
|
72
|
+
|
|
73
|
+
this.editor.select(this.hitLabelOnShapeForPointerUp)
|
|
61
74
|
this.parent.transition('translating', info)
|
|
62
|
-
this.
|
|
75
|
+
this.hitLabelOnShapeForPointerUp = null
|
|
63
76
|
return
|
|
64
77
|
}
|
|
65
78
|
|
|
79
|
+
// Check if dragging from editing shape with blurred input
|
|
80
|
+
if (this.didPointerDownOnEditingShape && this.editor.inputs.isDragging) {
|
|
81
|
+
if (this.editor.getIsReadonly()) return
|
|
82
|
+
|
|
83
|
+
const editingShape = this.editor.getEditingShape()
|
|
84
|
+
if (!editingShape || editingShape.isLocked) return
|
|
85
|
+
|
|
86
|
+
if (!this.isTextInputFocused()) {
|
|
87
|
+
// Input blurred during drag - exit edit mode and start translating
|
|
88
|
+
this.editor.select(editingShape)
|
|
89
|
+
this.parent.transition('translating', info)
|
|
90
|
+
this.didPointerDownOnEditingShape = false
|
|
91
|
+
return
|
|
92
|
+
}
|
|
93
|
+
// Input still focused - user is selecting text, stay in edit mode
|
|
94
|
+
this.didPointerDownOnEditingShape = false
|
|
95
|
+
}
|
|
96
|
+
|
|
66
97
|
switch (info.target) {
|
|
67
98
|
case 'shape':
|
|
68
99
|
case 'canvas': {
|
|
@@ -73,7 +104,8 @@ export class EditingShape extends StateNode {
|
|
|
73
104
|
}
|
|
74
105
|
|
|
75
106
|
override onPointerDown(info: TLPointerEventInfo) {
|
|
76
|
-
this.
|
|
107
|
+
this.hitLabelOnShapeForPointerUp = null
|
|
108
|
+
this.didPointerDownOnEditingShape = false
|
|
77
109
|
|
|
78
110
|
switch (info.target) {
|
|
79
111
|
// N.B. This bit of logic has a bit of history to it.
|
|
@@ -112,7 +144,7 @@ export class EditingShape extends StateNode {
|
|
|
112
144
|
if (textLabel && !isEmptyTextShape) {
|
|
113
145
|
const pointInShapeSpace = this.editor.getPointInShapeSpace(
|
|
114
146
|
selectingShape,
|
|
115
|
-
this.editor.inputs.
|
|
147
|
+
this.editor.inputs.getCurrentPagePoint()
|
|
116
148
|
)
|
|
117
149
|
if (
|
|
118
150
|
textLabel.bounds.containsPoint(pointInShapeSpace, 0) &&
|
|
@@ -120,10 +152,11 @@ export class EditingShape extends StateNode {
|
|
|
120
152
|
) {
|
|
121
153
|
// it's a hit to the label!
|
|
122
154
|
if (selectingShape.id === editingShape.id) {
|
|
123
|
-
//
|
|
155
|
+
// Track click on editing shape for drag detection
|
|
156
|
+
this.didPointerDownOnEditingShape = true
|
|
124
157
|
return
|
|
125
158
|
} else {
|
|
126
|
-
this.
|
|
159
|
+
this.hitLabelOnShapeForPointerUp = selectingShape
|
|
127
160
|
|
|
128
161
|
this.editor.markHistoryStoppingPoint('editing on pointer up')
|
|
129
162
|
this.editor.select(selectingShape.id)
|
|
@@ -156,10 +189,20 @@ export class EditingShape extends StateNode {
|
|
|
156
189
|
}
|
|
157
190
|
|
|
158
191
|
override onPointerUp(info: TLPointerEventInfo) {
|
|
192
|
+
if (this.didPointerDownOnEditingShape) {
|
|
193
|
+
this.didPointerDownOnEditingShape = false
|
|
194
|
+
if (!this.isTextInputFocused()) {
|
|
195
|
+
// We clicked on the text label, which blured the input.
|
|
196
|
+
// We want to stay in edit mode and select all the text.
|
|
197
|
+
this.editor.getRichTextEditor()?.commands.focus('all')
|
|
198
|
+
return
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
159
202
|
// If we're not dragging, and it's a hit to the label, begin editing the shape.
|
|
160
|
-
const hitShape = this.
|
|
203
|
+
const hitShape = this.hitLabelOnShapeForPointerUp
|
|
161
204
|
if (!hitShape) return
|
|
162
|
-
this.
|
|
205
|
+
this.hitLabelOnShapeForPointerUp = null
|
|
163
206
|
|
|
164
207
|
// Stay in edit mode to maintain flow of editing.
|
|
165
208
|
const util = this.editor.getShapeUtil(hitShape)
|
|
@@ -16,10 +16,9 @@ import {
|
|
|
16
16
|
} from '@tldraw/editor'
|
|
17
17
|
import { isOverArrowLabel } from '../../../shapes/arrow/arrowLabel'
|
|
18
18
|
import { getHitShapeOnCanvasPointerDown } from '../../selection-logic/getHitShapeOnCanvasPointerDown'
|
|
19
|
-
import { getShouldEnterCropMode } from '../../selection-logic/getShouldEnterCropModeOnPointerDown'
|
|
20
19
|
import { selectOnCanvasPointerUp } from '../../selection-logic/selectOnCanvasPointerUp'
|
|
21
20
|
import { updateHoveredShapeId } from '../../selection-logic/updateHoveredShapeId'
|
|
22
|
-
import {
|
|
21
|
+
import { hasRichText, startEditingShapeWithRichText } from '../selectHelpers'
|
|
23
22
|
|
|
24
23
|
const SKIPPED_KEYS_FOR_AUTO_EDITING = [
|
|
25
24
|
'Delete',
|
|
@@ -53,8 +52,6 @@ export class Idle extends StateNode {
|
|
|
53
52
|
}
|
|
54
53
|
|
|
55
54
|
override onPointerDown(info: TLPointerEventInfo) {
|
|
56
|
-
const shouldEnterCropMode = info.ctrlKey && getShouldEnterCropMode(this.editor)
|
|
57
|
-
|
|
58
55
|
switch (info.target) {
|
|
59
56
|
case 'canvas': {
|
|
60
57
|
// Check to see if we hit any shape under the pointer; if so,
|
|
@@ -71,9 +68,7 @@ export class Idle extends StateNode {
|
|
|
71
68
|
|
|
72
69
|
const selectedShapeIds = this.editor.getSelectedShapeIds()
|
|
73
70
|
const onlySelectedShape = this.editor.getOnlySelectedShape()
|
|
74
|
-
const
|
|
75
|
-
inputs: { currentPagePoint },
|
|
76
|
-
} = this.editor
|
|
71
|
+
const currentPagePoint = this.editor.inputs.getCurrentPagePoint()
|
|
77
72
|
|
|
78
73
|
if (
|
|
79
74
|
selectedShapeIds.length > 1 ||
|
|
@@ -106,7 +101,7 @@ export class Idle extends StateNode {
|
|
|
106
101
|
}
|
|
107
102
|
case 'handle': {
|
|
108
103
|
if (this.editor.getIsReadonly()) break
|
|
109
|
-
if (this.editor.inputs.
|
|
104
|
+
if (this.editor.inputs.getAltKey()) {
|
|
110
105
|
this.parent.transition('pointing_shape', info)
|
|
111
106
|
} else {
|
|
112
107
|
// If we're holding ctrl key, we might select it, or start brushing...
|
|
@@ -136,7 +131,8 @@ export class Idle extends StateNode {
|
|
|
136
131
|
case 'top_right':
|
|
137
132
|
case 'bottom_left':
|
|
138
133
|
case 'bottom_right': {
|
|
139
|
-
|
|
134
|
+
const onlySelectedShape = this.editor.getOnlySelectedShape()
|
|
135
|
+
if (info.ctrlKey && this.editor.canCropShape(onlySelectedShape)) {
|
|
140
136
|
this.parent.transition('crop.pointing_crop_handle', info)
|
|
141
137
|
} else {
|
|
142
138
|
if (info.accelKey) {
|
|
@@ -171,7 +167,7 @@ export class Idle extends StateNode {
|
|
|
171
167
|
}
|
|
172
168
|
|
|
173
169
|
override onDoubleClick(info: TLClickEventInfo) {
|
|
174
|
-
if (this.editor.inputs.
|
|
170
|
+
if (this.editor.inputs.getShiftKey() || info.phase !== 'up') return
|
|
175
171
|
|
|
176
172
|
// We don't want to double click while toggling shapes
|
|
177
173
|
if (info.ctrlKey || info.shiftKey) return
|
|
@@ -187,11 +183,12 @@ export class Idle extends StateNode {
|
|
|
187
183
|
// of the shape yet because that also creates text shapes, and can produce
|
|
188
184
|
// unexpected results when working "inside of" a hollow shape.
|
|
189
185
|
|
|
186
|
+
const currentPagePoint = this.editor.inputs.getCurrentPagePoint()
|
|
190
187
|
const hitShape =
|
|
191
188
|
hoveredShape && !this.editor.isShapeOfType(hoveredShape, 'group')
|
|
192
189
|
? hoveredShape
|
|
193
|
-
: (this.editor.getSelectedShapeAtPoint(
|
|
194
|
-
this.editor.getShapeAtPoint(
|
|
190
|
+
: (this.editor.getSelectedShapeAtPoint(currentPagePoint) ??
|
|
191
|
+
this.editor.getShapeAtPoint(currentPagePoint, {
|
|
195
192
|
margin: this.editor.options.hitTestMargin / this.editor.getZoomLevel(),
|
|
196
193
|
hitInside: false,
|
|
197
194
|
}))
|
|
@@ -232,30 +229,45 @@ export class Idle extends StateNode {
|
|
|
232
229
|
return
|
|
233
230
|
}
|
|
234
231
|
|
|
235
|
-
if (!this.editor.inputs.
|
|
232
|
+
if (!this.editor.inputs.getShiftKey()) {
|
|
236
233
|
this.handleDoubleClickOnCanvas(info)
|
|
237
234
|
}
|
|
238
235
|
break
|
|
239
236
|
}
|
|
240
237
|
case 'selection': {
|
|
241
|
-
if (this.editor.getIsReadonly()) break
|
|
242
|
-
|
|
243
238
|
const onlySelectedShape = this.editor.getOnlySelectedShape()
|
|
244
239
|
|
|
245
240
|
if (onlySelectedShape) {
|
|
246
241
|
const util = this.editor.getShapeUtil(onlySelectedShape)
|
|
247
|
-
|
|
248
|
-
if (!this.canInteractWithShapeInReadOnly(onlySelectedShape)) {
|
|
249
|
-
return
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
// Test edges for an onDoubleClickEdge handler
|
|
253
|
-
if (
|
|
242
|
+
const isEdge =
|
|
254
243
|
info.handle === 'right' ||
|
|
255
244
|
info.handle === 'left' ||
|
|
256
245
|
info.handle === 'top' ||
|
|
257
246
|
info.handle === 'bottom'
|
|
258
|
-
|
|
247
|
+
const isCorner =
|
|
248
|
+
info.handle === 'top_left' ||
|
|
249
|
+
info.handle === 'top_right' ||
|
|
250
|
+
info.handle === 'bottom_right' ||
|
|
251
|
+
info.handle === 'bottom_left'
|
|
252
|
+
|
|
253
|
+
if (this.editor.getIsReadonly()) {
|
|
254
|
+
// includes readonly check
|
|
255
|
+
if (
|
|
256
|
+
this.editor.canEditShape(onlySelectedShape, {
|
|
257
|
+
type: isCorner
|
|
258
|
+
? 'double-click-corner'
|
|
259
|
+
: isEdge
|
|
260
|
+
? 'double-click-edge'
|
|
261
|
+
: 'double-click',
|
|
262
|
+
})
|
|
263
|
+
) {
|
|
264
|
+
this.startEditingShape(onlySelectedShape, info, true /* select all */)
|
|
265
|
+
}
|
|
266
|
+
break
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
// Test edges for an onDoubleClickEdge handler
|
|
270
|
+
if (isEdge) {
|
|
259
271
|
const change = util.onDoubleClickEdge?.(onlySelectedShape, info)
|
|
260
272
|
if (change) {
|
|
261
273
|
this.editor.markHistoryStoppingPoint('double click edge')
|
|
@@ -265,12 +277,7 @@ export class Idle extends StateNode {
|
|
|
265
277
|
}
|
|
266
278
|
}
|
|
267
279
|
|
|
268
|
-
if (
|
|
269
|
-
info.handle === 'top_left' ||
|
|
270
|
-
info.handle === 'top_right' ||
|
|
271
|
-
info.handle === 'bottom_right' ||
|
|
272
|
-
info.handle === 'bottom_left'
|
|
273
|
-
) {
|
|
280
|
+
if (isCorner) {
|
|
274
281
|
const change = util.onDoubleClickCorner?.(onlySelectedShape, info)
|
|
275
282
|
if (change) {
|
|
276
283
|
this.editor.markHistoryStoppingPoint('double click corner')
|
|
@@ -279,16 +286,14 @@ export class Idle extends StateNode {
|
|
|
279
286
|
return
|
|
280
287
|
}
|
|
281
288
|
}
|
|
289
|
+
|
|
282
290
|
// For corners OR edges but NOT rotation corners
|
|
283
|
-
if (
|
|
284
|
-
util.canCrop(onlySelectedShape) &&
|
|
285
|
-
!this.editor.isShapeOrAncestorLocked(onlySelectedShape)
|
|
286
|
-
) {
|
|
291
|
+
if (this.editor.canCropShape(onlySelectedShape)) {
|
|
287
292
|
this.parent.transition('crop', info)
|
|
288
293
|
return
|
|
289
294
|
}
|
|
290
295
|
|
|
291
|
-
if (this.
|
|
296
|
+
if (this.editor.canEditShape(onlySelectedShape)) {
|
|
292
297
|
this.startEditingShape(onlySelectedShape, info, true /* select all */)
|
|
293
298
|
}
|
|
294
299
|
}
|
|
@@ -319,7 +324,7 @@ export class Idle extends StateNode {
|
|
|
319
324
|
}
|
|
320
325
|
|
|
321
326
|
// If the shape can edit, then begin editing
|
|
322
|
-
if (this.
|
|
327
|
+
if (this.editor.canEditShape(shape)) {
|
|
323
328
|
this.startEditingShape(shape, info, true /* select all */)
|
|
324
329
|
} else {
|
|
325
330
|
// If the shape's double click handler has not created a change,
|
|
@@ -341,7 +346,7 @@ export class Idle extends StateNode {
|
|
|
341
346
|
} else {
|
|
342
347
|
// If the shape's double click handler has not created a change,
|
|
343
348
|
// and if the shape can edit, then begin editing the shape.
|
|
344
|
-
if (this.
|
|
349
|
+
if (this.editor.canEditShape(shape)) {
|
|
345
350
|
this.startEditingShape(shape, info, true /* select all */)
|
|
346
351
|
}
|
|
347
352
|
}
|
|
@@ -356,7 +361,7 @@ export class Idle extends StateNode {
|
|
|
356
361
|
const hitShape =
|
|
357
362
|
hoveredShape && !this.editor.isShapeOfType(hoveredShape, 'group')
|
|
358
363
|
? hoveredShape
|
|
359
|
-
: this.editor.getShapeAtPoint(this.editor.inputs.
|
|
364
|
+
: this.editor.getShapeAtPoint(this.editor.inputs.getCurrentPagePoint(), {
|
|
360
365
|
margin: this.editor.options.hitTestMargin / this.editor.getZoomLevel(),
|
|
361
366
|
hitInside: false,
|
|
362
367
|
hitLabels: true,
|
|
@@ -376,9 +381,7 @@ export class Idle extends StateNode {
|
|
|
376
381
|
|
|
377
382
|
const selectedShapeIds = this.editor.getSelectedShapeIds()
|
|
378
383
|
const onlySelectedShape = this.editor.getOnlySelectedShape()
|
|
379
|
-
const
|
|
380
|
-
inputs: { currentPagePoint },
|
|
381
|
-
} = this.editor
|
|
384
|
+
const currentPagePoint = this.editor.inputs.getCurrentPagePoint()
|
|
382
385
|
|
|
383
386
|
if (
|
|
384
387
|
selectedShapeIds.length > 1 ||
|
|
@@ -471,7 +474,7 @@ export class Idle extends StateNode {
|
|
|
471
474
|
// If it's a note shape, then edit on type
|
|
472
475
|
this.editor.isShapeOfType(onlySelectedShape, 'note') &&
|
|
473
476
|
// If it's not locked or anything
|
|
474
|
-
this.
|
|
477
|
+
this.editor.canEditShape(onlySelectedShape)
|
|
475
478
|
) {
|
|
476
479
|
this.startEditingShape(
|
|
477
480
|
onlySelectedShape,
|
|
@@ -532,7 +535,10 @@ export class Idle extends StateNode {
|
|
|
532
535
|
|
|
533
536
|
// If the only selected shape is editable, then begin editing it
|
|
534
537
|
const onlySelectedShape = this.editor.getOnlySelectedShape()
|
|
535
|
-
if (
|
|
538
|
+
if (
|
|
539
|
+
onlySelectedShape &&
|
|
540
|
+
this.editor.canEditShape(onlySelectedShape, { type: 'press_enter' })
|
|
541
|
+
) {
|
|
536
542
|
this.startEditingShape(
|
|
537
543
|
onlySelectedShape,
|
|
538
544
|
{
|
|
@@ -546,7 +552,7 @@ export class Idle extends StateNode {
|
|
|
546
552
|
}
|
|
547
553
|
|
|
548
554
|
// If the only selected shape is croppable, then begin cropping it
|
|
549
|
-
if (
|
|
555
|
+
if (this.editor.canCropShape(onlySelectedShape)) {
|
|
550
556
|
this.parent.transition('crop', info)
|
|
551
557
|
}
|
|
552
558
|
break
|
|
@@ -561,23 +567,18 @@ export class Idle extends StateNode {
|
|
|
561
567
|
}
|
|
562
568
|
}
|
|
563
569
|
|
|
564
|
-
private shouldStartEditingShape(
|
|
565
|
-
shape: TLShape | null = this.editor.getOnlySelectedShape()
|
|
566
|
-
): boolean {
|
|
567
|
-
if (!shape) return false
|
|
568
|
-
if (this.editor.isShapeOrAncestorLocked(shape) && shape.type !== 'embed') return false
|
|
569
|
-
if (!this.canInteractWithShapeInReadOnly(shape)) return false
|
|
570
|
-
return this.editor.getShapeUtil(shape).canEdit(shape)
|
|
571
|
-
}
|
|
572
|
-
|
|
573
570
|
private startEditingShape(
|
|
574
571
|
shape: TLShape,
|
|
575
572
|
info: TLClickEventInfo | TLKeyboardEventInfo,
|
|
576
573
|
shouldSelectAll?: boolean
|
|
577
574
|
) {
|
|
578
|
-
|
|
575
|
+
const { editor } = this
|
|
579
576
|
this.editor.markHistoryStoppingPoint('editing shape')
|
|
580
|
-
|
|
577
|
+
if (hasRichText(shape)) {
|
|
578
|
+
startEditingShapeWithRichText(editor, shape, { selectAll: shouldSelectAll })
|
|
579
|
+
} else {
|
|
580
|
+
editor.setEditingShape(shape)
|
|
581
|
+
}
|
|
581
582
|
this.parent.transition('editing_shape', info)
|
|
582
583
|
}
|
|
583
584
|
|
|
@@ -597,7 +598,7 @@ export class Idle extends StateNode {
|
|
|
597
598
|
|
|
598
599
|
const id = createShapeId()
|
|
599
600
|
|
|
600
|
-
const { x, y } = this.editor.inputs.
|
|
601
|
+
const { x, y } = this.editor.inputs.getCurrentPagePoint()
|
|
601
602
|
|
|
602
603
|
// Allow this to trigger the max shapes reached alert
|
|
603
604
|
this.editor.createShapes([
|
|
@@ -616,16 +617,9 @@ export class Idle extends StateNode {
|
|
|
616
617
|
const shape = this.editor.getShape(id)
|
|
617
618
|
if (!shape) return
|
|
618
619
|
|
|
619
|
-
|
|
620
|
-
if (this.editor.getIsReadonly()) {
|
|
621
|
-
if (!util.canEditInReadonly(shape)) {
|
|
622
|
-
return
|
|
623
|
-
}
|
|
624
|
-
}
|
|
620
|
+
if (!this.editor.canEditShape(shape)) return
|
|
625
621
|
|
|
626
|
-
this.editor
|
|
627
|
-
this.editor.select(id)
|
|
628
|
-
this.parent.transition('editing_shape', info)
|
|
622
|
+
startEditingShapeWithRichText(this.editor, id, { info })
|
|
629
623
|
}
|
|
630
624
|
|
|
631
625
|
private nudgeSelectedShapes(ephemeral = false) {
|
|
@@ -665,13 +659,6 @@ export class Idle extends StateNode {
|
|
|
665
659
|
this.editor.nudgeShapes(selectedShapeIds, delta.mul(step))
|
|
666
660
|
kickoutOccludedShapes(this.editor, selectedShapeIds)
|
|
667
661
|
}
|
|
668
|
-
|
|
669
|
-
private canInteractWithShapeInReadOnly(shape: TLShape) {
|
|
670
|
-
if (!this.editor.getIsReadonly()) return true
|
|
671
|
-
const util = this.editor.getShapeUtil(shape)
|
|
672
|
-
if (util.canEditInReadonly(shape)) return true
|
|
673
|
-
return false
|
|
674
|
-
}
|
|
675
662
|
}
|
|
676
663
|
|
|
677
664
|
export const MAJOR_NUDGE_FACTOR = 10
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
getArrowBodyGeometry,
|
|
12
12
|
getArrowLabelDefaultPosition,
|
|
13
13
|
} from '../../../shapes/arrow/arrowLabel'
|
|
14
|
+
import { startEditingShapeWithRichText } from '../selectHelpers'
|
|
14
15
|
|
|
15
16
|
export class PointingArrowLabel extends StateNode {
|
|
16
17
|
static override id = 'pointing_arrow_label'
|
|
@@ -54,7 +55,7 @@ export class PointingArrowLabel extends StateNode {
|
|
|
54
55
|
if (!labelGeometry) {
|
|
55
56
|
throw Error(`Expected to find an arrow label geometry for shape: ${shape.id}`)
|
|
56
57
|
}
|
|
57
|
-
const
|
|
58
|
+
const currentPagePoint = this.editor.inputs.getCurrentPagePoint()
|
|
58
59
|
const pointInShapeSpace = this.editor.getPointInShapeSpace(shape, currentPagePoint)
|
|
59
60
|
|
|
60
61
|
this._labelDragOffset = Vec.Sub(labelGeometry.center, pointInShapeSpace)
|
|
@@ -81,7 +82,7 @@ export class PointingArrowLabel extends StateNode {
|
|
|
81
82
|
private _labelDragOffset = new Vec(0, 0)
|
|
82
83
|
|
|
83
84
|
override onPointerMove() {
|
|
84
|
-
const
|
|
85
|
+
const isDragging = this.editor.inputs.getIsDragging()
|
|
85
86
|
if (!isDragging) return
|
|
86
87
|
|
|
87
88
|
if (this.didCtrlOnEnter) {
|
|
@@ -97,7 +98,7 @@ export class PointingArrowLabel extends StateNode {
|
|
|
97
98
|
const transform = this.editor.getShapePageTransform(shape.id)
|
|
98
99
|
|
|
99
100
|
const pointInShapeSpace = this.editor
|
|
100
|
-
.getPointInShapeSpace(shape, this.editor.inputs.
|
|
101
|
+
.getPointInShapeSpace(shape, this.editor.inputs.getCurrentPagePoint())
|
|
101
102
|
.add(this._labelDragOffset)
|
|
102
103
|
|
|
103
104
|
const defaultLabelPosition = getArrowLabelDefaultPosition(this.editor, shape)
|
|
@@ -137,10 +138,8 @@ export class PointingArrowLabel extends StateNode {
|
|
|
137
138
|
|
|
138
139
|
if (this.didDrag || !this.wasAlreadySelected) {
|
|
139
140
|
this.complete()
|
|
140
|
-
} else if (
|
|
141
|
-
|
|
142
|
-
this.editor.setEditingShape(shape.id)
|
|
143
|
-
this.editor.setCurrentTool('select.editing_shape')
|
|
141
|
+
} else if (this.editor.canEditShape(shape)) {
|
|
142
|
+
startEditingShapeWithRichText(this.editor, shape.id)
|
|
144
143
|
}
|
|
145
144
|
}
|
|
146
145
|
|