tldraw 4.3.0-next.82cfddd7ee89 → 4.3.0-next.842fb21476f2
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 +311 -242
- package/dist-cjs/index.js +13 -5
- package/dist-cjs/index.js.map +2 -2
- package/dist-cjs/lib/bindings/arrow/ArrowBindingUtil.js.map +2 -2
- package/dist-cjs/lib/canvas/TldrawSelectionForeground.js +2 -2
- package/dist-cjs/lib/canvas/TldrawSelectionForeground.js.map +2 -2
- package/dist-cjs/lib/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 +14 -13
- 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/elbow/getElbowArrowInfo.js +1 -1
- package/dist-cjs/lib/shapes/arrow/elbow/getElbowArrowInfo.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/shared.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/bookmark/bookmarks.js.map +2 -2
- package/dist-cjs/lib/shapes/draw/DrawShapeUtil.js +25 -23
- 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/FrameShapeTool.js.map +1 -1
- package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js +6 -5
- package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/geo/GeoShapeUtil.js +146 -142
- 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 +23 -21
- 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 +6 -11
- 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 +5 -10
- package/dist-cjs/lib/shapes/note/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/HyperlinkButton.js +3 -2
- package/dist-cjs/lib/shapes/shared/HyperlinkButton.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/PlainTextLabel.js +14 -2
- package/dist-cjs/lib/shapes/shared/PlainTextLabel.js.map +3 -3
- package/dist-cjs/lib/shapes/shared/RichTextLabel.js +12 -4
- package/dist-cjs/lib/shapes/shared/RichTextLabel.js.map +3 -3
- package/dist-cjs/lib/shapes/shared/ShapeFill.js +2 -2
- package/dist-cjs/lib/shapes/shared/ShapeFill.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/crop.js +1 -0
- package/dist-cjs/lib/shapes/shared/crop.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/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/{useForceSolid.js → useEfficientZoomThreshold.js} +10 -7
- package/dist-cjs/lib/shapes/shared/useEfficientZoomThreshold.js.map +7 -0
- package/dist-cjs/lib/shapes/shared/useImageOrVideoAsset.js +1 -1
- package/dist-cjs/lib/shapes/shared/useImageOrVideoAsset.js.map +2 -2
- package/dist-cjs/lib/shapes/text/RichTextArea.js +5 -0
- package/dist-cjs/lib/shapes/text/RichTextArea.js.map +2 -2
- package/dist-cjs/lib/shapes/text/TextShapeUtil.js +5 -2
- package/dist-cjs/lib/shapes/text/TextShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/text/toolStates/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/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 +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 +10 -11
- 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 +8 -6
- 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/ActionsMenu/DefaultActionsMenuContent.js +3 -9
- package/dist-cjs/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.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/EditLinkDialog.js +11 -1
- package/dist-cjs/lib/ui/components/EditLinkDialog.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/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/menu-items.js +3 -1
- package/dist-cjs/lib/ui/components/menu-items.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/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 +149 -93
- 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 +14 -7
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuItem.js.map +2 -2
- package/dist-cjs/lib/ui/context/actions.js +7 -8
- 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/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 +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 +16 -6
- 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/{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 +11 -19
- package/dist-cjs/lib/utils/text/richText.js.map +3 -3
- 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 +311 -242
- package/dist-esm/index.mjs +14 -5
- package/dist-esm/index.mjs.map +2 -2
- package/dist-esm/lib/bindings/arrow/ArrowBindingUtil.mjs.map +2 -2
- package/dist-esm/lib/canvas/TldrawSelectionForeground.mjs +2 -2
- package/dist-esm/lib/canvas/TldrawSelectionForeground.mjs.map +2 -2
- package/dist-esm/lib/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 +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/elbow/getElbowArrowInfo.mjs +1 -1
- package/dist-esm/lib/shapes/arrow/elbow/getElbowArrowInfo.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/shared.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/bookmark/bookmarks.mjs.map +2 -2
- package/dist-esm/lib/shapes/draw/DrawShapeUtil.mjs +30 -25
- 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/FrameShapeTool.mjs.map +1 -1
- package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs +6 -5
- package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/geo/GeoShapeUtil.mjs +147 -142
- 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 +24 -22
- 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 +7 -12
- 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 +5 -10
- package/dist-esm/lib/shapes/note/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/HyperlinkButton.mjs +4 -3
- package/dist-esm/lib/shapes/shared/HyperlinkButton.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/PlainTextLabel.mjs +14 -2
- package/dist-esm/lib/shapes/shared/PlainTextLabel.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/RichTextLabel.mjs +12 -4
- package/dist-esm/lib/shapes/shared/RichTextLabel.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/ShapeFill.mjs +2 -2
- package/dist-esm/lib/shapes/shared/ShapeFill.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/crop.mjs +1 -0
- package/dist-esm/lib/shapes/shared/crop.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/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/useEfficientZoomThreshold.mjs +12 -0
- package/dist-esm/lib/shapes/shared/useEfficientZoomThreshold.mjs.map +7 -0
- package/dist-esm/lib/shapes/shared/useImageOrVideoAsset.mjs +1 -1
- package/dist-esm/lib/shapes/shared/useImageOrVideoAsset.mjs.map +2 -2
- package/dist-esm/lib/shapes/text/RichTextArea.mjs +5 -0
- package/dist-esm/lib/shapes/text/RichTextArea.mjs.map +2 -2
- package/dist-esm/lib/shapes/text/TextShapeUtil.mjs +5 -2
- package/dist-esm/lib/shapes/text/TextShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/text/toolStates/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/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 +4 -5
- package/dist-esm/lib/tools/EraserTool/childStates/Erasing.mjs.map +2 -2
- package/dist-esm/lib/tools/EraserTool/childStates/Pointing.mjs +3 -8
- 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 +10 -11
- 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 +8 -6
- 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 +6 -19
- 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/ActionsMenu/DefaultActionsMenuContent.mjs +2 -8
- package/dist-esm/lib/ui/components/ActionsMenu/DefaultActionsMenuContent.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/EditLinkDialog.mjs +11 -1
- package/dist-esm/lib/ui/components/EditLinkDialog.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/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/menu-items.mjs +4 -5
- package/dist-esm/lib/ui/components/menu-items.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/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 +157 -95
- 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 +15 -8
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuItem.mjs.map +2 -2
- package/dist-esm/lib/ui/context/actions.mjs +7 -8
- 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/menu-hooks.mjs +1 -4
- 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 +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 +17 -6
- package/dist-esm/lib/utils/excalidraw/putExcalidrawContent.mjs.map +2 -2
- package/dist-esm/lib/utils/export/exportAs.mjs +1 -3
- package/dist-esm/lib/utils/export/exportAs.mjs.map +2 -2
- package/dist-esm/lib/utils/frames/frames.mjs.map +2 -2
- package/dist-esm/lib/utils/test-helpers.mjs +21 -0
- package/dist-esm/lib/utils/test-helpers.mjs.map +7 -0
- package/dist-esm/lib/utils/text/richText.mjs +8 -5
- 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 +6 -2
- package/src/lib/Tldraw.test.tsx +46 -1
- package/src/lib/bindings/arrow/ArrowBindingUtil.ts +1 -1
- package/src/lib/canvas/TldrawSelectionForeground.tsx +6 -11
- package/src/lib/defaultEmbedDefinitions.ts +2 -1
- package/src/lib/defaultExternalContentHandlers.ts +13 -14
- 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.test.ts +2 -2
- package/src/lib/shapes/arrow/ArrowShapeUtil.tsx +16 -16
- package/src/lib/shapes/arrow/arrow-types.ts +2 -0
- 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/elbow/getElbowArrowInfo.test.ts +80 -0
- package/src/lib/shapes/arrow/elbow/getElbowArrowInfo.tsx +1 -1
- package/src/lib/shapes/arrow/shared.ts +4 -4
- package/src/lib/shapes/arrow/toolStates/Idle.tsx +4 -14
- package/src/lib/shapes/arrow/toolStates/Pointing.tsx +8 -5
- package/src/lib/shapes/bookmark/BookmarkShapeUtil.tsx +1 -1
- package/src/lib/shapes/bookmark/bookmarks.ts +3 -3
- package/src/lib/shapes/draw/DrawShapeUtil.test.ts +146 -0
- package/src/lib/shapes/draw/DrawShapeUtil.tsx +31 -27
- package/src/lib/shapes/draw/getPath.ts +31 -10
- package/src/lib/shapes/draw/toolStates/Drawing.ts +100 -90
- package/src/lib/shapes/embed/EmbedShapeUtil.tsx +8 -1
- package/src/lib/shapes/frame/FrameShapeTool.ts +1 -1
- package/src/lib/shapes/frame/FrameShapeUtil.tsx +10 -4
- package/src/lib/shapes/geo/GeoShapeUtil.test.tsx +10 -2
- package/src/lib/shapes/geo/GeoShapeUtil.tsx +228 -176
- package/src/lib/shapes/geo/toolStates/Idle.ts +5 -15
- package/src/lib/shapes/geo/toolStates/Pointing.ts +6 -6
- package/src/lib/shapes/highlight/HighlightShapeUtil.test.ts +146 -0
- package/src/lib/shapes/highlight/HighlightShapeUtil.tsx +25 -24
- 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 +2 -1
- package/src/lib/shapes/note/NoteShapeUtil.tsx +9 -10
- package/src/lib/shapes/note/noteCloning.test.ts +3 -1
- package/src/lib/shapes/note/noteHelpers.ts +2 -2
- package/src/lib/shapes/note/toolStates/Pointing.ts +5 -10
- package/src/lib/shapes/shared/HyperlinkButton.tsx +4 -3
- package/src/lib/shapes/shared/PlainTextLabel.tsx +12 -2
- package/src/lib/shapes/shared/RichTextLabel.tsx +14 -4
- package/src/lib/shapes/shared/ShapeFill.tsx +2 -2
- package/src/lib/shapes/shared/crop.ts +1 -0
- package/src/lib/shapes/shared/interpolate-props.ts +4 -4
- package/src/lib/shapes/shared/useEditablePlainText.ts +7 -3
- package/src/lib/shapes/shared/useEditableRichText.ts +7 -3
- package/src/lib/shapes/shared/useEfficientZoomThreshold.ts +10 -0
- package/src/lib/shapes/shared/useImageOrVideoAsset.ts +1 -1
- package/src/lib/shapes/text/RichTextArea.tsx +5 -0
- package/src/lib/shapes/text/TextShapeTool.test.ts +4 -4
- package/src/lib/shapes/text/TextShapeUtil.tsx +5 -0
- package/src/lib/shapes/text/toolStates/Idle.ts +4 -14
- package/src/lib/shapes/text/toolStates/Pointing.ts +8 -8
- package/src/lib/shapes/video/VideoShapeUtil.tsx +2 -1
- package/src/lib/tools/EraserTool/childStates/Erasing.ts +7 -10
- package/src/lib/tools/EraserTool/childStates/Pointing.ts +5 -20
- 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 +14 -11
- package/src/lib/tools/SelectTool/childStates/Brushing.ts +8 -11
- package/src/lib/tools/SelectTool/childStates/Crop/children/Cropping.ts +7 -6
- package/src/lib/tools/SelectTool/childStates/Crop/children/Idle.ts +3 -4
- 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 +11 -12
- package/src/lib/tools/SelectTool/childStates/EditingShape.ts +57 -16
- package/src/lib/tools/SelectTool/childStates/Idle.ts +64 -81
- package/src/lib/tools/SelectTool/childStates/PointingArrowLabel.ts +7 -8
- package/src/lib/tools/SelectTool/childStates/PointingCanvas.ts +1 -1
- package/src/lib/tools/SelectTool/childStates/PointingHandle.ts +9 -17
- 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 +4 -14
- package/src/lib/tools/SelectTool/childStates/Resizing.ts +8 -10
- package/src/lib/tools/SelectTool/childStates/Rotating.ts +2 -3
- package/src/lib/tools/SelectTool/childStates/ScribbleBrushing.ts +9 -10
- package/src/lib/tools/SelectTool/childStates/Translating.ts +16 -15
- 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/ActionsMenu/DefaultActionsMenuContent.tsx +1 -9
- 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/EditLinkDialog.tsx +16 -6
- 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/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/menu-items.tsx +9 -15
- package/src/lib/ui/components/primitives/TldrawUiContextualToolbar.tsx +5 -3
- package/src/lib/ui/components/primitives/TldrawUiSlider.tsx +2 -2
- package/src/lib/ui/components/primitives/TldrawUiTooltip.tsx +208 -113
- 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 +7 -4
- package/src/lib/ui/context/actions.tsx +15 -19
- package/src/lib/ui/context/components.tsx +1 -2
- package/src/lib/ui/hooks/menu-hooks.ts +9 -19
- package/src/lib/ui/hooks/useClipboardEvents.ts +2 -2
- package/src/lib/ui/hooks/useFlatten.ts +1 -2
- package/src/lib/ui/hooks/useKeyboardShortcuts.ts +2 -2
- package/src/lib/ui/hooks/useTools.tsx +5 -7
- 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 +19 -6
- package/src/lib/utils/export/exportAs.ts +2 -9
- package/src/lib/utils/frames/frames.ts +1 -1
- package/src/lib/utils/test-helpers.ts +60 -0
- package/src/lib/utils/text/richText.ts +9 -8
- package/src/lib/utils/tldr/buildFromV1Document.ts +21 -19
- package/src/test/Editor.test.tsx +78 -41
- package/src/test/EraserTool.test.ts +10 -12
- package/src/test/SelectTool.test.ts +11 -19
- package/src/test/TestEditor.ts +49 -51
- package/src/test/TldrawEditor.test.tsx +24 -20
- 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/bindings.test.tsx +29 -25
- package/src/test/bindingsIndex.test.tsx +4 -4
- package/src/test/commands/__snapshots__/getSvgString.test.ts.snap +10 -10
- package/src/test/commands/cameraState.test.ts +299 -0
- package/src/test/commands/createShape.test.ts +64 -0
- package/src/test/commands/createShapes.test.ts +15 -1
- package/src/test/commands/getSvgString.test.ts +2 -2
- package/src/test/commands/isShapeOfType.test.ts +44 -0
- package/src/test/commands/putContent.test.ts +80 -1
- package/src/test/commands/setCamera.test.ts +13 -11
- package/src/test/commands/stackShapes.test.ts +34 -8
- package/src/test/commands/updateShape.test.ts +67 -0
- package/src/test/commands/updateShapes.test.ts +21 -5
- 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 +52 -44
- package/src/test/customSnapping.test.tsx +77 -62
- package/src/test/drawing.test.ts +17 -10
- package/src/test/duplicate.test.ts +1 -1
- package/src/test/flipShapes.test.ts +33 -0
- package/src/test/frames.test.ts +94 -2
- package/src/test/getCulledShapes.test.tsx +11 -3
- package/src/test/getShapeAtPoint.test.ts +2 -2
- package/src/test/groups.test.tsx +7 -4
- package/src/test/modifiers.test.ts +6 -6
- package/src/test/resizing.test.ts +16 -22
- package/src/test/selection-omnibus.test.ts +13 -13
- package/src/test/shapeutils.test.ts +1 -1
- package/src/test/spacebarPanning.test.ts +28 -10
- package/src/test/styles2.test.tsx +1 -1
- package/src/test/styles3.test.ts +5 -5
- package/src/test/test-jsx.tsx +72 -57
- package/src/test/text.test.ts +15 -17
- package/src/test/translating.test.ts +6 -8
- package/src/test/ui/BackToContent.test.tsx +111 -0
- package/tldraw.css +41 -35
- package/dist-cjs/lib/shapes/shared/useForceSolid.js.map +0 -7
- 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/shapes/shared/useForceSolid.mjs +0 -9
- package/dist-esm/lib/shapes/shared/useForceSolid.mjs.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/shapes/shared/useForceSolid.ts +0 -6
- 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
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
Mat,
|
|
3
3
|
StateNode,
|
|
4
4
|
Vec,
|
|
5
|
+
b64Vecs,
|
|
5
6
|
createShapeId,
|
|
6
7
|
last,
|
|
7
8
|
snapAngle,
|
|
@@ -25,16 +26,19 @@ class Drawing extends StateNode {
|
|
|
25
26
|
lastRecordedPoint = {};
|
|
26
27
|
mergeNextPoint = false;
|
|
27
28
|
currentLineLength = 0;
|
|
29
|
+
// Cache for current segment's points to avoid repeated b64 decode/encode
|
|
30
|
+
currentSegmentPoints = [];
|
|
28
31
|
markId = null;
|
|
29
32
|
onEnter(info) {
|
|
30
33
|
this.markId = null;
|
|
31
34
|
this.info = info;
|
|
32
|
-
this.lastRecordedPoint = this.editor.inputs.
|
|
35
|
+
this.lastRecordedPoint = this.editor.inputs.getCurrentPagePoint().clone();
|
|
33
36
|
this.startShape();
|
|
34
37
|
}
|
|
35
38
|
onPointerMove() {
|
|
36
39
|
const { inputs } = this.editor;
|
|
37
|
-
|
|
40
|
+
const isPen = inputs.getIsPen();
|
|
41
|
+
if (this.isPen && !isPen) {
|
|
38
42
|
if (this.markId) {
|
|
39
43
|
this.editor.bailToMark(this.markId);
|
|
40
44
|
this.startShape();
|
|
@@ -42,8 +46,9 @@ class Drawing extends StateNode {
|
|
|
42
46
|
}
|
|
43
47
|
}
|
|
44
48
|
if (this.isPenOrStylus) {
|
|
45
|
-
|
|
46
|
-
|
|
49
|
+
const currentPagePoint = inputs.getCurrentPagePoint();
|
|
50
|
+
if (Vec.Dist(currentPagePoint, this.lastRecordedPoint) >= 1 / this.editor.getZoomLevel()) {
|
|
51
|
+
this.lastRecordedPoint = currentPagePoint.clone();
|
|
47
52
|
this.mergeNextPoint = false;
|
|
48
53
|
} else {
|
|
49
54
|
this.mergeNextPoint = true;
|
|
@@ -58,7 +63,7 @@ class Drawing extends StateNode {
|
|
|
58
63
|
switch (this.segmentMode) {
|
|
59
64
|
case "free": {
|
|
60
65
|
this.segmentMode = "starting_straight";
|
|
61
|
-
this.pagePointWhereNextSegmentChanged = this.editor.inputs.
|
|
66
|
+
this.pagePointWhereNextSegmentChanged = this.editor.inputs.getCurrentPagePoint().clone();
|
|
62
67
|
break;
|
|
63
68
|
}
|
|
64
69
|
case "starting_free": {
|
|
@@ -74,7 +79,7 @@ class Drawing extends StateNode {
|
|
|
74
79
|
switch (this.segmentMode) {
|
|
75
80
|
case "straight": {
|
|
76
81
|
this.segmentMode = "starting_free";
|
|
77
|
-
this.pagePointWhereNextSegmentChanged = this.editor.inputs.
|
|
82
|
+
this.pagePointWhereNextSegmentChanged = this.editor.inputs.getCurrentPagePoint().clone();
|
|
78
83
|
break;
|
|
79
84
|
}
|
|
80
85
|
case "starting_straight": {
|
|
@@ -88,7 +93,7 @@ class Drawing extends StateNode {
|
|
|
88
93
|
}
|
|
89
94
|
onExit() {
|
|
90
95
|
this.editor.snaps.clearIndicators();
|
|
91
|
-
this.pagePointWhereCurrentSegmentChanged = this.editor.inputs.
|
|
96
|
+
this.pagePointWhereCurrentSegmentChanged = this.editor.inputs.getCurrentPagePoint().clone();
|
|
92
97
|
}
|
|
93
98
|
canClose() {
|
|
94
99
|
return this.shapeType !== "highlight";
|
|
@@ -96,21 +101,21 @@ class Drawing extends StateNode {
|
|
|
96
101
|
getIsClosed(segments, size, scale) {
|
|
97
102
|
if (!this.canClose()) return false;
|
|
98
103
|
const strokeWidth = STROKE_SIZES[size];
|
|
99
|
-
const firstPoint = segments[0].points
|
|
104
|
+
const firstPoint = b64Vecs.decodeFirstPoint(segments[0].points);
|
|
100
105
|
const lastSegment = segments[segments.length - 1];
|
|
101
|
-
const lastPoint =
|
|
102
|
-
return firstPoint !== lastPoint && this.currentLineLength > strokeWidth * 4 * scale && Vec.DistMin(firstPoint, lastPoint, strokeWidth * 2 * scale);
|
|
106
|
+
const lastPoint = b64Vecs.decodeLastPoint(lastSegment.points);
|
|
107
|
+
return firstPoint !== null && lastPoint !== null && firstPoint !== lastPoint && this.currentLineLength > strokeWidth * 4 * scale && Vec.DistMin(firstPoint, lastPoint, strokeWidth * 2 * scale);
|
|
103
108
|
}
|
|
104
109
|
startShape() {
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
110
|
+
const inputs = this.editor.inputs;
|
|
111
|
+
const originPagePoint = inputs.getOriginPagePoint();
|
|
112
|
+
const isPen = inputs.getIsPen();
|
|
108
113
|
this.markId = this.editor.markHistoryStoppingPoint("draw start");
|
|
109
114
|
const { z = 0.5 } = this.info.point;
|
|
110
115
|
this.isPen = isPen;
|
|
111
116
|
this.isPenOrStylus = isPen || z > 0 && z < 0.5 || z > 0.5 && z < 1;
|
|
112
117
|
const pressure = this.isPenOrStylus ? z * 1.25 : 0.5;
|
|
113
|
-
this.segmentMode = this.editor.inputs.
|
|
118
|
+
this.segmentMode = this.editor.inputs.getShiftKey() ? "straight" : "free";
|
|
114
119
|
this.didJustShiftClickToExtendPreviousShapeLine = false;
|
|
115
120
|
this.lastRecordedPoint = originPagePoint.clone();
|
|
116
121
|
if (this.initialShape) {
|
|
@@ -119,23 +124,15 @@ class Drawing extends StateNode {
|
|
|
119
124
|
this.didJustShiftClickToExtendPreviousShapeLine = true;
|
|
120
125
|
const prevSegment = last(shape2.props.segments);
|
|
121
126
|
if (!prevSegment) throw Error("Expected a previous segment!");
|
|
122
|
-
const prevPoint =
|
|
127
|
+
const prevPoint = b64Vecs.decodeLastPoint(prevSegment.points);
|
|
123
128
|
if (!prevPoint) throw Error("Expected a previous point!");
|
|
124
129
|
const { x, y } = this.editor.getPointInShapeSpace(shape2, originPagePoint).toFixed();
|
|
125
130
|
const newSegment = {
|
|
126
131
|
type: this.segmentMode,
|
|
127
|
-
points: [
|
|
128
|
-
{
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
z: +pressure.toFixed(2)
|
|
132
|
-
},
|
|
133
|
-
{
|
|
134
|
-
x,
|
|
135
|
-
y,
|
|
136
|
-
z: +pressure.toFixed(2)
|
|
137
|
-
}
|
|
138
|
-
]
|
|
132
|
+
points: b64Vecs.encodePoints([
|
|
133
|
+
{ x: prevPoint.x, y: prevPoint.y, z: +pressure.toFixed(2) },
|
|
134
|
+
{ x, y, z: +pressure.toFixed(2) }
|
|
135
|
+
])
|
|
139
136
|
};
|
|
140
137
|
const prevPointPageSpace = Mat.applyToPoint(
|
|
141
138
|
this.editor.getShapePageTransform(shape2.id),
|
|
@@ -168,6 +165,8 @@ class Drawing extends StateNode {
|
|
|
168
165
|
}
|
|
169
166
|
this.pagePointWhereCurrentSegmentChanged = originPagePoint.clone();
|
|
170
167
|
const id = createShapeId();
|
|
168
|
+
const initialPoint = new Vec(0, 0, +pressure.toFixed(2));
|
|
169
|
+
this.currentSegmentPoints = [initialPoint];
|
|
171
170
|
this.editor.createShape({
|
|
172
171
|
id,
|
|
173
172
|
type: this.shapeType,
|
|
@@ -179,13 +178,7 @@ class Drawing extends StateNode {
|
|
|
179
178
|
segments: [
|
|
180
179
|
{
|
|
181
180
|
type: this.segmentMode,
|
|
182
|
-
points: [
|
|
183
|
-
{
|
|
184
|
-
x: 0,
|
|
185
|
-
y: 0,
|
|
186
|
-
z: +pressure.toFixed(2)
|
|
187
|
-
}
|
|
188
|
-
]
|
|
181
|
+
points: b64Vecs.encodePoints([initialPoint])
|
|
189
182
|
}
|
|
190
183
|
]
|
|
191
184
|
}
|
|
@@ -209,8 +202,9 @@ class Drawing extends StateNode {
|
|
|
209
202
|
const shape = this.editor.getShape(id);
|
|
210
203
|
if (!shape) return;
|
|
211
204
|
const { segments } = shape.props;
|
|
212
|
-
const
|
|
213
|
-
const
|
|
205
|
+
const currentPagePoint = inputs.getCurrentPagePoint();
|
|
206
|
+
const { x, y, z } = this.editor.getPointInShapeSpace(shape, currentPagePoint).toFixed();
|
|
207
|
+
const pressure = this.isPenOrStylus ? +(currentPagePoint.z * 1.25).toFixed(2) : 0.5;
|
|
214
208
|
const newPoint = { x, y, z: pressure };
|
|
215
209
|
switch (this.segmentMode) {
|
|
216
210
|
case "starting_straight": {
|
|
@@ -218,14 +212,14 @@ class Drawing extends StateNode {
|
|
|
218
212
|
if (pagePointWhereNextSegmentChanged === null) {
|
|
219
213
|
throw Error("We should have a point where the segment changed");
|
|
220
214
|
}
|
|
221
|
-
const hasMovedFarEnough = Vec.Dist2(pagePointWhereNextSegmentChanged, inputs.
|
|
215
|
+
const hasMovedFarEnough = Vec.Dist2(pagePointWhereNextSegmentChanged, inputs.getCurrentPagePoint()) > this.editor.options.dragDistanceSquared;
|
|
222
216
|
if (hasMovedFarEnough) {
|
|
223
217
|
this.pagePointWhereCurrentSegmentChanged = this.pagePointWhereNextSegmentChanged.clone();
|
|
224
218
|
this.pagePointWhereNextSegmentChanged = null;
|
|
225
219
|
this.segmentMode = "straight";
|
|
226
220
|
const prevSegment = last(segments);
|
|
227
221
|
if (!prevSegment) throw Error("Expected a previous segment!");
|
|
228
|
-
const prevLastPoint =
|
|
222
|
+
const prevLastPoint = b64Vecs.decodeLastPoint(prevSegment.points);
|
|
229
223
|
if (!prevLastPoint) throw Error("Expected a previous last point!");
|
|
230
224
|
let newSegment;
|
|
231
225
|
const newLastPoint = this.editor.getPointInShapeSpace(shape, this.pagePointWhereCurrentSegmentChanged).toFixed().toJson();
|
|
@@ -233,14 +227,14 @@ class Drawing extends StateNode {
|
|
|
233
227
|
this.currentLineLength += Vec.Dist(prevLastPoint, newLastPoint);
|
|
234
228
|
newSegment = {
|
|
235
229
|
type: "straight",
|
|
236
|
-
points: [
|
|
230
|
+
points: b64Vecs.encodePoints([prevLastPoint, newLastPoint])
|
|
237
231
|
};
|
|
238
232
|
const transform = this.editor.getShapePageTransform(shape);
|
|
239
233
|
this.pagePointWhereCurrentSegmentChanged = Mat.applyToPoint(transform, prevLastPoint);
|
|
240
234
|
} else {
|
|
241
235
|
newSegment = {
|
|
242
236
|
type: "straight",
|
|
243
|
-
points: [newLastPoint, newPoint]
|
|
237
|
+
points: b64Vecs.encodePoints([newLastPoint, newPoint])
|
|
244
238
|
};
|
|
245
239
|
}
|
|
246
240
|
const shapePartial = {
|
|
@@ -267,26 +261,24 @@ class Drawing extends StateNode {
|
|
|
267
261
|
if (pagePointWhereNextSegmentChanged === null) {
|
|
268
262
|
throw Error("We should have a point where the segment changed");
|
|
269
263
|
}
|
|
270
|
-
const hasMovedFarEnough = Vec.Dist2(pagePointWhereNextSegmentChanged, inputs.
|
|
264
|
+
const hasMovedFarEnough = Vec.Dist2(pagePointWhereNextSegmentChanged, inputs.getCurrentPagePoint()) > this.editor.options.dragDistanceSquared;
|
|
271
265
|
if (hasMovedFarEnough) {
|
|
272
266
|
this.pagePointWhereCurrentSegmentChanged = this.pagePointWhereNextSegmentChanged.clone();
|
|
273
267
|
this.pagePointWhereNextSegmentChanged = null;
|
|
274
268
|
this.segmentMode = "free";
|
|
275
269
|
const newSegments = segments.slice();
|
|
276
270
|
const prevStraightSegment = newSegments[newSegments.length - 1];
|
|
277
|
-
const prevPoint =
|
|
271
|
+
const prevPoint = b64Vecs.decodeLastPoint(prevStraightSegment.points);
|
|
278
272
|
if (!prevPoint) {
|
|
279
273
|
throw Error("No previous point!");
|
|
280
274
|
}
|
|
275
|
+
const interpolatedPoints = Vec.PointsBetween(prevPoint, newPoint, 6).map(
|
|
276
|
+
(p) => new Vec(toFixed(p.x), toFixed(p.y), toFixed(p.z))
|
|
277
|
+
);
|
|
278
|
+
this.currentSegmentPoints = interpolatedPoints;
|
|
281
279
|
const newFreeSegment = {
|
|
282
280
|
type: "free",
|
|
283
|
-
points:
|
|
284
|
-
...Vec.PointsBetween(prevPoint, newPoint, 6).map((p) => ({
|
|
285
|
-
x: toFixed(p.x),
|
|
286
|
-
y: toFixed(p.y),
|
|
287
|
-
z: toFixed(p.z)
|
|
288
|
-
}))
|
|
289
|
-
]
|
|
281
|
+
points: b64Vecs.encodePoints(interpolatedPoints)
|
|
290
282
|
};
|
|
291
283
|
const finalSegments = [...newSegments, newFreeSegment];
|
|
292
284
|
if (this.currentLineLength < STROKE_SIZES[shape.props.size] * 4) {
|
|
@@ -315,13 +307,15 @@ class Drawing extends StateNode {
|
|
|
315
307
|
const newSegments = segments.slice();
|
|
316
308
|
const newSegment = newSegments[newSegments.length - 1];
|
|
317
309
|
const { pagePointWhereCurrentSegmentChanged } = this;
|
|
318
|
-
const
|
|
310
|
+
const inputs2 = this.editor.inputs;
|
|
311
|
+
const ctrlKey = inputs2.getCtrlKey();
|
|
312
|
+
const currentPagePoint2 = inputs2.getCurrentPagePoint();
|
|
319
313
|
if (!pagePointWhereCurrentSegmentChanged)
|
|
320
314
|
throw Error("We should have a point where the segment changed");
|
|
321
315
|
let pagePoint;
|
|
322
316
|
let shouldSnapToAngle = false;
|
|
323
317
|
if (this.didJustShiftClickToExtendPreviousShapeLine) {
|
|
324
|
-
if (this.editor.inputs.
|
|
318
|
+
if (this.editor.inputs.getIsDragging()) {
|
|
325
319
|
shouldSnapToAngle = !ctrlKey;
|
|
326
320
|
this.didJustShiftClickToExtendPreviousShapeLine = false;
|
|
327
321
|
} else {
|
|
@@ -329,7 +323,7 @@ class Drawing extends StateNode {
|
|
|
329
323
|
} else {
|
|
330
324
|
shouldSnapToAngle = !ctrlKey;
|
|
331
325
|
}
|
|
332
|
-
let newPoint2 = this.editor.getPointInShapeSpace(shape,
|
|
326
|
+
let newPoint2 = this.editor.getPointInShapeSpace(shape, currentPagePoint2).toFixed().toJson();
|
|
333
327
|
let didSnap = false;
|
|
334
328
|
let snapSegment = void 0;
|
|
335
329
|
const shouldSnap = this.editor.user.getIsSnapMode() ? !ctrlKey : ctrlKey;
|
|
@@ -341,8 +335,8 @@ class Drawing extends StateNode {
|
|
|
341
335
|
const segment = segments[i];
|
|
342
336
|
if (!segment) break;
|
|
343
337
|
if (segment.type === "free") continue;
|
|
344
|
-
const first = segment.points
|
|
345
|
-
const lastPoint =
|
|
338
|
+
const first = b64Vecs.decodeFirstPoint(segment.points);
|
|
339
|
+
const lastPoint = b64Vecs.decodeLastPoint(segment.points);
|
|
346
340
|
if (!(first && lastPoint)) continue;
|
|
347
341
|
const nearestPointOnSegment = Vec.NearestPointOnLineSegment(
|
|
348
342
|
first,
|
|
@@ -364,9 +358,9 @@ class Drawing extends StateNode {
|
|
|
364
358
|
}
|
|
365
359
|
if (didSnap && snapSegment) {
|
|
366
360
|
const transform = this.editor.getShapePageTransform(shape);
|
|
367
|
-
const first = snapSegment.points
|
|
368
|
-
const lastPoint =
|
|
369
|
-
if (!lastPoint) throw Error("Expected a last point!");
|
|
361
|
+
const first = b64Vecs.decodeFirstPoint(snapSegment.points);
|
|
362
|
+
const lastPoint = b64Vecs.decodeLastPoint(snapSegment.points);
|
|
363
|
+
if (!first || !lastPoint) throw Error("Expected a last point!");
|
|
370
364
|
const A = Mat.applyToPoint(transform, first);
|
|
371
365
|
const B = Mat.applyToPoint(transform, lastPoint);
|
|
372
366
|
const snappedPoint = Mat.applyToPoint(transform, newPoint2);
|
|
@@ -380,24 +374,27 @@ class Drawing extends StateNode {
|
|
|
380
374
|
} else {
|
|
381
375
|
this.editor.snaps.clearIndicators();
|
|
382
376
|
if (shouldSnapToAngle) {
|
|
383
|
-
const currentAngle = Vec.Angle(pagePointWhereCurrentSegmentChanged,
|
|
377
|
+
const currentAngle = Vec.Angle(pagePointWhereCurrentSegmentChanged, currentPagePoint2);
|
|
384
378
|
const snappedAngle = snapAngle(currentAngle, 24);
|
|
385
379
|
const angleDiff = snappedAngle - currentAngle;
|
|
386
380
|
pagePoint = Vec.RotWith(
|
|
387
|
-
|
|
381
|
+
currentPagePoint2,
|
|
388
382
|
pagePointWhereCurrentSegmentChanged,
|
|
389
383
|
angleDiff
|
|
390
384
|
);
|
|
391
385
|
} else {
|
|
392
|
-
pagePoint =
|
|
386
|
+
pagePoint = currentPagePoint2.clone();
|
|
393
387
|
}
|
|
394
388
|
newPoint2 = this.editor.getPointInShapeSpace(shape, pagePoint).toFixed().toJson();
|
|
395
389
|
}
|
|
396
|
-
this.currentLineLength += Vec.Dist(newSegment.points
|
|
390
|
+
this.currentLineLength += newSegments.length && b64Vecs.decodeFirstPoint(newSegment.points) ? Vec.Dist(b64Vecs.decodeFirstPoint(newSegment.points), Vec.From(newPoint2)) : 0;
|
|
397
391
|
newSegments[newSegments.length - 1] = {
|
|
398
392
|
...newSegment,
|
|
399
393
|
type: "straight",
|
|
400
|
-
points:
|
|
394
|
+
points: b64Vecs.encodePoints([
|
|
395
|
+
b64Vecs.decodeFirstPoint(newSegment.points),
|
|
396
|
+
Vec.From(newPoint2)
|
|
397
|
+
])
|
|
401
398
|
};
|
|
402
399
|
const shapePartial = {
|
|
403
400
|
id,
|
|
@@ -418,23 +415,21 @@ class Drawing extends StateNode {
|
|
|
418
415
|
break;
|
|
419
416
|
}
|
|
420
417
|
case "free": {
|
|
421
|
-
const
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
x: newPoint.x,
|
|
428
|
-
y: newPoint.y,
|
|
429
|
-
z: z2 ? Math.max(z2, newPoint.z) : newPoint.z
|
|
430
|
-
};
|
|
418
|
+
const cachedPoints = this.currentSegmentPoints;
|
|
419
|
+
if (cachedPoints.length && this.mergeNextPoint) {
|
|
420
|
+
const lastPoint = cachedPoints[cachedPoints.length - 1];
|
|
421
|
+
lastPoint.x = newPoint.x;
|
|
422
|
+
lastPoint.y = newPoint.y;
|
|
423
|
+
lastPoint.z = lastPoint.z ? Math.max(lastPoint.z, newPoint.z) : newPoint.z;
|
|
431
424
|
} else {
|
|
432
|
-
this.currentLineLength += Vec.Dist(
|
|
433
|
-
|
|
425
|
+
this.currentLineLength += cachedPoints.length ? Vec.Dist(cachedPoints[cachedPoints.length - 1], newPoint) : 0;
|
|
426
|
+
cachedPoints.push(new Vec(newPoint.x, newPoint.y, newPoint.z));
|
|
434
427
|
}
|
|
428
|
+
const newSegments = segments.slice();
|
|
429
|
+
const newSegment = newSegments[newSegments.length - 1];
|
|
435
430
|
newSegments[newSegments.length - 1] = {
|
|
436
431
|
...newSegment,
|
|
437
|
-
points:
|
|
432
|
+
points: b64Vecs.encodePoints(cachedPoints)
|
|
438
433
|
};
|
|
439
434
|
if (this.currentLineLength < STROKE_SIZES[shape.props.size] * 4) {
|
|
440
435
|
this.currentLineLength = this.getLineLength(newSegments);
|
|
@@ -455,23 +450,26 @@ class Drawing extends StateNode {
|
|
|
455
450
|
);
|
|
456
451
|
}
|
|
457
452
|
this.editor.updateShapes([shapePartial]);
|
|
458
|
-
if (
|
|
453
|
+
if (cachedPoints.length > this.util.options.maxPointsPerShape) {
|
|
459
454
|
this.editor.updateShapes([{ id, type: this.shapeType, props: { isComplete: true } }]);
|
|
460
455
|
const newShapeId = createShapeId();
|
|
461
456
|
const props = this.editor.getShape(id).props;
|
|
462
457
|
if (!this.editor.canCreateShapes([newShapeId])) return this.cancel();
|
|
458
|
+
const currentPagePoint2 = inputs.getCurrentPagePoint();
|
|
459
|
+
const initialPoint = new Vec(0, 0, this.isPenOrStylus ? +(z * 1.25).toFixed() : 0.5);
|
|
460
|
+
this.currentSegmentPoints = [initialPoint];
|
|
463
461
|
this.editor.createShape({
|
|
464
462
|
id: newShapeId,
|
|
465
463
|
type: this.shapeType,
|
|
466
|
-
x: toFixed(
|
|
467
|
-
y: toFixed(
|
|
464
|
+
x: toFixed(currentPagePoint2.x),
|
|
465
|
+
y: toFixed(currentPagePoint2.y),
|
|
468
466
|
props: {
|
|
469
467
|
isPen: this.isPenOrStylus,
|
|
470
468
|
scale: props.scale,
|
|
471
469
|
segments: [
|
|
472
470
|
{
|
|
473
471
|
type: "free",
|
|
474
|
-
points:
|
|
472
|
+
points: b64Vecs.encodePoints([initialPoint])
|
|
475
473
|
}
|
|
476
474
|
]
|
|
477
475
|
}
|
|
@@ -482,7 +480,7 @@ class Drawing extends StateNode {
|
|
|
482
480
|
}
|
|
483
481
|
this.initialShape = structuredClone(shape2);
|
|
484
482
|
this.mergeNextPoint = false;
|
|
485
|
-
this.lastRecordedPoint =
|
|
483
|
+
this.lastRecordedPoint = currentPagePoint2.clone();
|
|
486
484
|
this.currentLineLength = 0;
|
|
487
485
|
}
|
|
488
486
|
break;
|
|
@@ -491,11 +489,10 @@ class Drawing extends StateNode {
|
|
|
491
489
|
}
|
|
492
490
|
getLineLength(segments) {
|
|
493
491
|
let length = 0;
|
|
494
|
-
for (
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
length += Vec.Dist2(B, A);
|
|
492
|
+
for (let j = 0; j < segments.length; j++) {
|
|
493
|
+
const points = b64Vecs.decodePoints(segments[j].points);
|
|
494
|
+
for (let i = 0; i < points.length - 1; i++) {
|
|
495
|
+
length += Vec.Dist2(points[i], points[i + 1]);
|
|
499
496
|
}
|
|
500
497
|
}
|
|
501
498
|
return Math.sqrt(length);
|
|
@@ -510,7 +507,7 @@ class Drawing extends StateNode {
|
|
|
510
507
|
this.complete();
|
|
511
508
|
}
|
|
512
509
|
onInterrupt() {
|
|
513
|
-
if (this.editor.inputs.
|
|
510
|
+
if (this.editor.inputs.getIsDragging()) {
|
|
514
511
|
return;
|
|
515
512
|
}
|
|
516
513
|
if (this.markId) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/lib/shapes/draw/toolStates/Drawing.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n\tMat,\n\tStateNode,\n\tTLDefaultSizeStyle,\n\tTLDrawShape,\n\tTLDrawShapeSegment,\n\tTLHighlightShape,\n\tTLKeyboardEventInfo,\n\tTLPointerEventInfo,\n\tTLShapePartial,\n\tVec,\n\tVecModel,\n\tcreateShapeId,\n\tlast,\n\tsnapAngle,\n\tstructuredClone,\n\ttoFixed,\n\tuniqueId,\n} from '@tldraw/editor'\nimport { HighlightShapeUtil } from '../../highlight/HighlightShapeUtil'\nimport { STROKE_SIZES } from '../../shared/default-shape-constants'\nimport { DrawShapeUtil } from '../DrawShapeUtil'\n\ntype DrawableShape = TLDrawShape | TLHighlightShape\n\nexport class Drawing extends StateNode {\n\tstatic override id = 'drawing'\n\n\tinfo = {} as TLPointerEventInfo\n\n\tinitialShape?: DrawableShape\n\n\toverride shapeType = this.parent.id === 'highlight' ? ('highlight' as const) : ('draw' as const)\n\n\tutil = this.editor.getShapeUtil(this.shapeType) as DrawShapeUtil | HighlightShapeUtil\n\n\tisPen = false\n\tisPenOrStylus = false\n\n\tsegmentMode = 'free' as 'free' | 'straight' | 'starting_straight' | 'starting_free'\n\n\tdidJustShiftClickToExtendPreviousShapeLine = false\n\n\tpagePointWhereCurrentSegmentChanged = {} as Vec\n\n\tpagePointWhereNextSegmentChanged = null as Vec | null\n\n\tlastRecordedPoint = {} as Vec\n\tmergeNextPoint = false\n\tcurrentLineLength = 0\n\n\tmarkId = null as null | string\n\n\toverride onEnter(info: TLPointerEventInfo) {\n\t\tthis.markId = null\n\t\tthis.info = info\n\t\tthis.lastRecordedPoint = this.editor.inputs.currentPagePoint.clone()\n\t\tthis.startShape()\n\t}\n\n\toverride onPointerMove() {\n\t\tconst { inputs } = this.editor\n\n\t\tif (this.isPen && !inputs.isPen) {\n\t\t\t// The user made a palm gesture before starting a pen gesture;\n\t\t\t// ideally we'd start the new shape here but we could also just bail\n\t\t\t// as the next interaction will work correctly\n\t\t\tif (this.markId) {\n\t\t\t\tthis.editor.bailToMark(this.markId)\n\t\t\t\tthis.startShape()\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\tif (this.isPenOrStylus) {\n\t\t\t// Don't update the shape if we haven't moved far enough from the last time we recorded a point\n\t\t\tif (\n\t\t\t\tVec.Dist(inputs.currentPagePoint, this.lastRecordedPoint) >=\n\t\t\t\t1 / this.editor.getZoomLevel()\n\t\t\t) {\n\t\t\t\tthis.lastRecordedPoint = inputs.currentPagePoint.clone()\n\t\t\t\tthis.mergeNextPoint = false\n\t\t\t} else {\n\t\t\t\tthis.mergeNextPoint = true\n\t\t\t}\n\t\t} else {\n\t\t\tthis.mergeNextPoint = false\n\t\t}\n\n\t\tthis.updateDrawingShape()\n\t}\n\n\toverride onKeyDown(info: TLKeyboardEventInfo) {\n\t\tif (info.key === 'Shift') {\n\t\t\tswitch (this.segmentMode) {\n\t\t\t\tcase 'free': {\n\t\t\t\t\t// We've just entered straight mode, go to straight mode\n\t\t\t\t\tthis.segmentMode = 'starting_straight'\n\t\t\t\t\tthis.pagePointWhereNextSegmentChanged = this.editor.inputs.currentPagePoint.clone()\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tcase 'starting_free': {\n\t\t\t\t\tthis.segmentMode = 'starting_straight'\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tthis.updateDrawingShape()\n\t}\n\n\toverride onKeyUp(info: TLKeyboardEventInfo) {\n\t\tif (info.key === 'Shift') {\n\t\t\tthis.editor.snaps.clearIndicators()\n\n\t\t\tswitch (this.segmentMode) {\n\t\t\t\tcase 'straight': {\n\t\t\t\t\t// We've just exited straight mode, go back to free mode\n\t\t\t\t\tthis.segmentMode = 'starting_free'\n\t\t\t\t\tthis.pagePointWhereNextSegmentChanged = this.editor.inputs.currentPagePoint.clone()\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tcase 'starting_straight': {\n\t\t\t\t\tthis.pagePointWhereNextSegmentChanged = null\n\t\t\t\t\tthis.segmentMode = 'free'\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tthis.updateDrawingShape()\n\t}\n\n\toverride onExit() {\n\t\tthis.editor.snaps.clearIndicators()\n\t\tthis.pagePointWhereCurrentSegmentChanged = this.editor.inputs.currentPagePoint.clone()\n\t}\n\n\tcanClose() {\n\t\treturn this.shapeType !== 'highlight'\n\t}\n\n\tgetIsClosed(segments: TLDrawShapeSegment[], size: TLDefaultSizeStyle, scale: number) {\n\t\tif (!this.canClose()) return false\n\n\t\tconst strokeWidth = STROKE_SIZES[size]\n\t\tconst firstPoint = segments[0].points[0]\n\t\tconst lastSegment = segments[segments.length - 1]\n\t\tconst lastPoint = lastSegment.points[lastSegment.points.length - 1]\n\n\t\treturn (\n\t\t\tfirstPoint !== lastPoint &&\n\t\t\tthis.currentLineLength > strokeWidth * 4 * scale &&\n\t\t\tVec.DistMin(firstPoint, lastPoint, strokeWidth * 2 * scale)\n\t\t)\n\t}\n\n\tprivate startShape() {\n\t\tconst {\n\t\t\tinputs: { originPagePoint, isPen },\n\t\t} = this.editor\n\n\t\tthis.markId = this.editor.markHistoryStoppingPoint('draw start')\n\n\t\t// If the pressure is weird, then it's probably a stylus reporting as a mouse\n\t\t// We treat pen/stylus inputs differently in the drawing tool, so we need to\n\t\t// have our own value for this. The inputs.isPen is only if the input is a regular\n\t\t// pen, like an iPad pen, which needs to trigger \"pen mode\" in order to avoid\n\t\t// accidental palm touches. We don't have to worry about that with styluses though.\n\t\tconst { z = 0.5 } = this.info.point\n\n\t\tthis.isPen = isPen\n\t\tthis.isPenOrStylus = isPen || (z > 0 && z < 0.5) || (z > 0.5 && z < 1)\n\n\t\tconst pressure = this.isPenOrStylus ? z * 1.25 : 0.5\n\n\t\tthis.segmentMode = this.editor.inputs.shiftKey ? 'straight' : 'free'\n\n\t\tthis.didJustShiftClickToExtendPreviousShapeLine = false\n\n\t\tthis.lastRecordedPoint = originPagePoint.clone()\n\n\t\tif (this.initialShape) {\n\t\t\tconst shape = this.editor.getShape<DrawableShape>(this.initialShape.id)\n\n\t\t\tif (shape && this.segmentMode === 'straight') {\n\t\t\t\t// Connect dots\n\n\t\t\t\tthis.didJustShiftClickToExtendPreviousShapeLine = true\n\n\t\t\t\tconst prevSegment = last(shape.props.segments)\n\t\t\t\tif (!prevSegment) throw Error('Expected a previous segment!')\n\t\t\t\tconst prevPoint = last(prevSegment.points)\n\t\t\t\tif (!prevPoint) throw Error('Expected a previous point!')\n\n\t\t\t\tconst { x, y } = this.editor.getPointInShapeSpace(shape, originPagePoint).toFixed()\n\n\t\t\t\tconst newSegment: TLDrawShapeSegment = {\n\t\t\t\t\ttype: this.segmentMode,\n\t\t\t\t\tpoints: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tx: prevPoint.x,\n\t\t\t\t\t\t\ty: prevPoint.y,\n\t\t\t\t\t\t\tz: +pressure.toFixed(2),\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tx,\n\t\t\t\t\t\t\ty,\n\t\t\t\t\t\t\tz: +pressure.toFixed(2),\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t}\n\n\t\t\t\t// Convert prevPoint to page space\n\t\t\t\tconst prevPointPageSpace = Mat.applyToPoint(\n\t\t\t\t\tthis.editor.getShapePageTransform(shape.id)!,\n\t\t\t\t\tprevPoint\n\t\t\t\t)\n\t\t\t\tthis.pagePointWhereCurrentSegmentChanged = prevPointPageSpace\n\t\t\t\tthis.pagePointWhereNextSegmentChanged = null\n\t\t\t\tconst segments = [...shape.props.segments, newSegment]\n\n\t\t\t\tif (this.currentLineLength < STROKE_SIZES[shape.props.size] * 4) {\n\t\t\t\t\tthis.currentLineLength = this.getLineLength(segments)\n\t\t\t\t}\n\n\t\t\t\tconst shapePartial: TLShapePartial<DrawableShape> = {\n\t\t\t\t\tid: shape.id,\n\t\t\t\t\ttype: this.shapeType,\n\t\t\t\t\tprops: {\n\t\t\t\t\t\tsegments,\n\t\t\t\t\t},\n\t\t\t\t}\n\n\t\t\t\tif (this.canClose()) {\n\t\t\t\t\t;(shapePartial as TLShapePartial<TLDrawShape>).props!.isClosed = this.getIsClosed(\n\t\t\t\t\t\tsegments,\n\t\t\t\t\t\tshape.props.size,\n\t\t\t\t\t\tshape.props.scale\n\t\t\t\t\t)\n\t\t\t\t}\n\n\t\t\t\tthis.editor.updateShapes<TLDrawShape | TLHighlightShape>([shapePartial])\n\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\t// Create a new shape\n\n\t\tthis.pagePointWhereCurrentSegmentChanged = originPagePoint.clone()\n\t\tconst id = createShapeId()\n\n\t\t// Allow this to trigger the max shapes reached alert\n\t\tthis.editor.createShape<DrawableShape>({\n\t\t\tid,\n\t\t\ttype: this.shapeType,\n\t\t\tx: originPagePoint.x,\n\t\t\ty: originPagePoint.y,\n\t\t\tprops: {\n\t\t\t\tisPen: this.isPenOrStylus,\n\t\t\t\tscale: this.editor.user.getIsDynamicResizeMode() ? 1 / this.editor.getZoomLevel() : 1,\n\t\t\t\tsegments: [\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: this.segmentMode,\n\t\t\t\t\t\tpoints: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tx: 0,\n\t\t\t\t\t\t\t\ty: 0,\n\t\t\t\t\t\t\t\tz: +pressure.toFixed(2),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t})\n\t\tconst shape = this.editor.getShape<DrawableShape>(id)\n\t\tif (!shape) {\n\t\t\tthis.cancel()\n\t\t\treturn\n\t\t}\n\t\tthis.currentLineLength = 0\n\t\tthis.initialShape = this.editor.getShape<DrawableShape>(id)\n\t}\n\n\tprivate updateDrawingShape() {\n\t\tconst { initialShape } = this\n\t\tconst { inputs } = this.editor\n\n\t\tif (!initialShape) return\n\n\t\tconst {\n\t\t\tid,\n\t\t\tprops: { size, scale },\n\t\t} = initialShape\n\n\t\tconst shape = this.editor.getShape<DrawableShape>(id)!\n\n\t\tif (!shape) return\n\n\t\tconst { segments } = shape.props\n\n\t\tconst { x, y, z } = this.editor.getPointInShapeSpace(shape, inputs.currentPagePoint).toFixed()\n\t\tconst pressure = this.isPenOrStylus ? +(inputs.currentPagePoint.z! * 1.25).toFixed(2) : 0.5\n\t\tconst newPoint = { x, y, z: pressure }\n\n\t\tswitch (this.segmentMode) {\n\t\t\tcase 'starting_straight': {\n\t\t\t\tconst { pagePointWhereNextSegmentChanged } = this\n\n\t\t\t\tif (pagePointWhereNextSegmentChanged === null) {\n\t\t\t\t\tthrow Error('We should have a point where the segment changed')\n\t\t\t\t}\n\n\t\t\t\tconst hasMovedFarEnough =\n\t\t\t\t\tVec.Dist2(pagePointWhereNextSegmentChanged, inputs.currentPagePoint) >\n\t\t\t\t\tthis.editor.options.dragDistanceSquared\n\n\t\t\t\t// Find the distance from where the pointer was when shift was released and\n\t\t\t\t// where it is now; if it's far enough away, then update the page point where\n\t\t\t\t// the current segment changed (to match the pagepoint where next segment changed)\n\t\t\t\t// and set the pagepoint where next segment changed to null.\n\t\t\t\tif (hasMovedFarEnough) {\n\t\t\t\t\tthis.pagePointWhereCurrentSegmentChanged = this.pagePointWhereNextSegmentChanged!.clone()\n\t\t\t\t\tthis.pagePointWhereNextSegmentChanged = null\n\n\t\t\t\t\t// Set the new mode\n\t\t\t\t\tthis.segmentMode = 'straight'\n\n\t\t\t\t\tconst prevSegment = last(segments)\n\t\t\t\t\tif (!prevSegment) throw Error('Expected a previous segment!')\n\n\t\t\t\t\tconst prevLastPoint = last(prevSegment.points)\n\t\t\t\t\tif (!prevLastPoint) throw Error('Expected a previous last point!')\n\n\t\t\t\t\tlet newSegment: TLDrawShapeSegment\n\n\t\t\t\t\tconst newLastPoint = this.editor\n\t\t\t\t\t\t.getPointInShapeSpace(shape, this.pagePointWhereCurrentSegmentChanged)\n\t\t\t\t\t\t.toFixed()\n\t\t\t\t\t\t.toJson()\n\n\t\t\t\t\tif (prevSegment.type === 'straight') {\n\t\t\t\t\t\tthis.currentLineLength += Vec.Dist(prevLastPoint, newLastPoint)\n\n\t\t\t\t\t\tnewSegment = {\n\t\t\t\t\t\t\ttype: 'straight',\n\t\t\t\t\t\t\tpoints: [{ ...prevLastPoint }, newLastPoint],\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst transform = this.editor.getShapePageTransform(shape)!\n\n\t\t\t\t\t\tthis.pagePointWhereCurrentSegmentChanged = Mat.applyToPoint(transform, prevLastPoint)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnewSegment = {\n\t\t\t\t\t\t\ttype: 'straight',\n\t\t\t\t\t\t\tpoints: [newLastPoint, newPoint],\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tconst shapePartial: TLShapePartial<DrawableShape> = {\n\t\t\t\t\t\tid,\n\t\t\t\t\t\ttype: this.shapeType,\n\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\tsegments: [...segments, newSegment],\n\t\t\t\t\t\t},\n\t\t\t\t\t}\n\n\t\t\t\t\tif (this.canClose()) {\n\t\t\t\t\t\t;(shapePartial as TLShapePartial<TLDrawShape>).props!.isClosed = this.getIsClosed(\n\t\t\t\t\t\t\tsegments,\n\t\t\t\t\t\t\tsize,\n\t\t\t\t\t\t\tscale\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.editor.updateShapes<TLDrawShape | TLHighlightShape>([shapePartial])\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'starting_free': {\n\t\t\t\tconst { pagePointWhereNextSegmentChanged } = this\n\n\t\t\t\tif (pagePointWhereNextSegmentChanged === null) {\n\t\t\t\t\tthrow Error('We should have a point where the segment changed')\n\t\t\t\t}\n\n\t\t\t\tconst hasMovedFarEnough =\n\t\t\t\t\tVec.Dist2(pagePointWhereNextSegmentChanged, inputs.currentPagePoint) >\n\t\t\t\t\tthis.editor.options.dragDistanceSquared\n\n\t\t\t\t// Find the distance from where the pointer was when shift was released and\n\t\t\t\t// where it is now; if it's far enough away, then update the page point where\n\t\t\t\t// the current segment changed (to match the pagepoint where next segment changed)\n\t\t\t\t// and set the pagepoint where next segment changed to null.\n\t\t\t\tif (hasMovedFarEnough) {\n\t\t\t\t\tthis.pagePointWhereCurrentSegmentChanged = this.pagePointWhereNextSegmentChanged!.clone()\n\t\t\t\t\tthis.pagePointWhereNextSegmentChanged = null\n\n\t\t\t\t\t// Set the new mode\n\t\t\t\t\tthis.segmentMode = 'free'\n\n\t\t\t\t\tconst newSegments = segments.slice()\n\t\t\t\t\tconst prevStraightSegment = newSegments[newSegments.length - 1]\n\t\t\t\t\tconst prevPoint = last(prevStraightSegment.points)\n\n\t\t\t\t\tif (!prevPoint) {\n\t\t\t\t\t\tthrow Error('No previous point!')\n\t\t\t\t\t}\n\n\t\t\t\t\t// Create the new free segment and interpolate the points between where the last line\n\t\t\t\t\t// ended and where the pointer is now\n\t\t\t\t\tconst newFreeSegment: TLDrawShapeSegment = {\n\t\t\t\t\t\ttype: 'free',\n\t\t\t\t\t\tpoints: [\n\t\t\t\t\t\t\t...Vec.PointsBetween(prevPoint, newPoint, 6).map((p) => ({\n\t\t\t\t\t\t\t\tx: toFixed(p.x),\n\t\t\t\t\t\t\t\ty: toFixed(p.y),\n\t\t\t\t\t\t\t\tz: toFixed(p.z),\n\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t],\n\t\t\t\t\t}\n\n\t\t\t\t\tconst finalSegments = [...newSegments, newFreeSegment]\n\n\t\t\t\t\tif (this.currentLineLength < STROKE_SIZES[shape.props.size] * 4) {\n\t\t\t\t\t\tthis.currentLineLength = this.getLineLength(finalSegments)\n\t\t\t\t\t}\n\n\t\t\t\t\tconst shapePartial: TLShapePartial<DrawableShape> = {\n\t\t\t\t\t\tid,\n\t\t\t\t\t\ttype: this.shapeType,\n\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\tsegments: finalSegments,\n\t\t\t\t\t\t},\n\t\t\t\t\t}\n\n\t\t\t\t\tif (this.canClose()) {\n\t\t\t\t\t\t;(shapePartial as TLShapePartial<TLDrawShape>).props!.isClosed = this.getIsClosed(\n\t\t\t\t\t\t\tfinalSegments,\n\t\t\t\t\t\t\tsize,\n\t\t\t\t\t\t\tscale\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.editor.updateShapes([shapePartial])\n\t\t\t\t}\n\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'straight': {\n\t\t\t\tconst newSegments = segments.slice()\n\t\t\t\tconst newSegment = newSegments[newSegments.length - 1]\n\n\t\t\t\tconst { pagePointWhereCurrentSegmentChanged } = this\n\t\t\t\tconst { ctrlKey, currentPagePoint } = this.editor.inputs\n\n\t\t\t\tif (!pagePointWhereCurrentSegmentChanged)\n\t\t\t\t\tthrow Error('We should have a point where the segment changed')\n\n\t\t\t\tlet pagePoint: VecModel\n\t\t\t\tlet shouldSnapToAngle = false\n\n\t\t\t\tif (this.didJustShiftClickToExtendPreviousShapeLine) {\n\t\t\t\t\tif (this.editor.inputs.isDragging) {\n\t\t\t\t\t\t// If we've just shift clicked to extend a line, only snap once we've started dragging\n\t\t\t\t\t\tshouldSnapToAngle = !ctrlKey\n\t\t\t\t\t\tthis.didJustShiftClickToExtendPreviousShapeLine = false\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// noop\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// If we're not shift clicking to extend a line, but we're holding shift, then we should snap\n\t\t\t\t\tshouldSnapToAngle = !ctrlKey // don't snap angle while snapping line\n\t\t\t\t}\n\n\t\t\t\tlet newPoint = this.editor.getPointInShapeSpace(shape, currentPagePoint).toFixed().toJson()\n\t\t\t\tlet didSnap = false\n\t\t\t\tlet snapSegment: TLDrawShapeSegment | undefined = undefined\n\n\t\t\t\tconst shouldSnap = this.editor.user.getIsSnapMode() ? !ctrlKey : ctrlKey\n\n\t\t\t\tif (shouldSnap) {\n\t\t\t\t\tif (newSegments.length > 2) {\n\t\t\t\t\t\tlet nearestPoint: VecModel | undefined = undefined\n\t\t\t\t\t\tlet minDistance = 8 / this.editor.getZoomLevel()\n\n\t\t\t\t\t\t// Don't try to snap to the last two segments\n\t\t\t\t\t\tfor (let i = 0, n = segments.length - 2; i < n; i++) {\n\t\t\t\t\t\t\tconst segment = segments[i]\n\t\t\t\t\t\t\tif (!segment) break\n\t\t\t\t\t\t\tif (segment.type === 'free') continue\n\n\t\t\t\t\t\t\tconst first = segment.points[0]\n\t\t\t\t\t\t\tconst lastPoint = last(segment.points)\n\t\t\t\t\t\t\tif (!(first && lastPoint)) continue\n\n\t\t\t\t\t\t\t// Snap to the nearest point on the segment, if it's closer than the previous snapped point\n\t\t\t\t\t\t\tconst nearestPointOnSegment = Vec.NearestPointOnLineSegment(\n\t\t\t\t\t\t\t\tfirst,\n\t\t\t\t\t\t\t\tlastPoint,\n\t\t\t\t\t\t\t\tnewPoint\n\t\t\t\t\t\t\t)\n\n\t\t\t\t\t\t\tif (Vec.DistMin(nearestPointOnSegment, newPoint, minDistance)) {\n\t\t\t\t\t\t\t\tnearestPoint = nearestPointOnSegment.toFixed().toJson()\n\t\t\t\t\t\t\t\tminDistance = Vec.Dist(nearestPointOnSegment, newPoint)\n\t\t\t\t\t\t\t\tsnapSegment = segment\n\t\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (nearestPoint) {\n\t\t\t\t\t\t\tdidSnap = true\n\t\t\t\t\t\t\tnewPoint = nearestPoint\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (didSnap && snapSegment) {\n\t\t\t\t\tconst transform = this.editor.getShapePageTransform(shape)!\n\t\t\t\t\tconst first = snapSegment.points[0]\n\t\t\t\t\tconst lastPoint = last(snapSegment.points)\n\t\t\t\t\tif (!lastPoint) throw Error('Expected a last point!')\n\n\t\t\t\t\tconst A = Mat.applyToPoint(transform, first)\n\n\t\t\t\t\tconst B = Mat.applyToPoint(transform, lastPoint)\n\n\t\t\t\t\tconst snappedPoint = Mat.applyToPoint(transform, newPoint)\n\n\t\t\t\t\tthis.editor.snaps.setIndicators([\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tid: uniqueId(),\n\t\t\t\t\t\t\ttype: 'points',\n\t\t\t\t\t\t\tpoints: [A, snappedPoint, B],\n\t\t\t\t\t\t},\n\t\t\t\t\t])\n\t\t\t\t} else {\n\t\t\t\t\tthis.editor.snaps.clearIndicators()\n\n\t\t\t\t\tif (shouldSnapToAngle) {\n\t\t\t\t\t\t// Snap line angle to nearest 15 degrees\n\t\t\t\t\t\tconst currentAngle = Vec.Angle(pagePointWhereCurrentSegmentChanged, currentPagePoint)\n\t\t\t\t\t\tconst snappedAngle = snapAngle(currentAngle, 24)\n\t\t\t\t\t\tconst angleDiff = snappedAngle - currentAngle\n\n\t\t\t\t\t\tpagePoint = Vec.RotWith(\n\t\t\t\t\t\t\tcurrentPagePoint,\n\t\t\t\t\t\t\tpagePointWhereCurrentSegmentChanged,\n\t\t\t\t\t\t\tangleDiff\n\t\t\t\t\t\t)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tpagePoint = currentPagePoint\n\t\t\t\t\t}\n\n\t\t\t\t\tnewPoint = this.editor.getPointInShapeSpace(shape, pagePoint).toFixed().toJson()\n\t\t\t\t}\n\n\t\t\t\t// If the previous segment is a one point free shape and is the first segment of the line,\n\t\t\t\t// then the user just did a click-and-immediately-press-shift to create a new straight line\n\t\t\t\t// without continuing the previous line. In this case, we want to remove the previous segment.\n\n\t\t\t\tthis.currentLineLength += Vec.Dist(newSegment.points[0], newPoint)\n\n\t\t\t\tnewSegments[newSegments.length - 1] = {\n\t\t\t\t\t...newSegment,\n\t\t\t\t\ttype: 'straight',\n\t\t\t\t\tpoints: [newSegment.points[0], newPoint],\n\t\t\t\t}\n\n\t\t\t\tconst shapePartial: TLShapePartial<DrawableShape> = {\n\t\t\t\t\tid,\n\t\t\t\t\ttype: this.shapeType,\n\t\t\t\t\tprops: {\n\t\t\t\t\t\tsegments: newSegments,\n\t\t\t\t\t},\n\t\t\t\t}\n\n\t\t\t\tif (this.canClose()) {\n\t\t\t\t\t;(shapePartial as TLShapePartial<TLDrawShape>).props!.isClosed = this.getIsClosed(\n\t\t\t\t\t\tsegments,\n\t\t\t\t\t\tsize,\n\t\t\t\t\t\tscale\n\t\t\t\t\t)\n\t\t\t\t}\n\n\t\t\t\tthis.editor.updateShapes([shapePartial])\n\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'free': {\n\t\t\t\tconst newSegments = segments.slice()\n\t\t\t\tconst newSegment = newSegments[newSegments.length - 1]\n\t\t\t\tconst newPoints = [...newSegment.points]\n\n\t\t\t\tif (newPoints.length && this.mergeNextPoint) {\n\t\t\t\t\tconst { z } = newPoints[newPoints.length - 1]\n\t\t\t\t\tnewPoints[newPoints.length - 1] = {\n\t\t\t\t\t\tx: newPoint.x,\n\t\t\t\t\t\ty: newPoint.y,\n\t\t\t\t\t\tz: z ? Math.max(z, newPoint.z) : newPoint.z,\n\t\t\t\t\t}\n\t\t\t\t\t// Note: we could recompute the line length here, but it's not really necessary\n\t\t\t\t\t// this.currentLineLength = this.getLineLength(newSegments)\n\t\t\t\t} else {\n\t\t\t\t\tthis.currentLineLength += Vec.Dist(newPoints[newPoints.length - 1], newPoint)\n\t\t\t\t\tnewPoints.push(newPoint)\n\t\t\t\t}\n\n\t\t\t\tnewSegments[newSegments.length - 1] = {\n\t\t\t\t\t...newSegment,\n\t\t\t\t\tpoints: newPoints,\n\t\t\t\t}\n\n\t\t\t\tif (this.currentLineLength < STROKE_SIZES[shape.props.size] * 4) {\n\t\t\t\t\tthis.currentLineLength = this.getLineLength(newSegments)\n\t\t\t\t}\n\n\t\t\t\tconst shapePartial: TLShapePartial<DrawableShape> = {\n\t\t\t\t\tid,\n\t\t\t\t\ttype: this.shapeType,\n\t\t\t\t\tprops: {\n\t\t\t\t\t\tsegments: newSegments,\n\t\t\t\t\t},\n\t\t\t\t}\n\n\t\t\t\tif (this.canClose()) {\n\t\t\t\t\t;(shapePartial as TLShapePartial<TLDrawShape>).props!.isClosed = this.getIsClosed(\n\t\t\t\t\t\tnewSegments,\n\t\t\t\t\t\tsize,\n\t\t\t\t\t\tscale\n\t\t\t\t\t)\n\t\t\t\t}\n\n\t\t\t\tthis.editor.updateShapes([shapePartial])\n\n\t\t\t\t// Set a maximum length for the lines array; after 200 points, complete the line.\n\t\t\t\tif (newPoints.length > this.util.options.maxPointsPerShape) {\n\t\t\t\t\tthis.editor.updateShapes([{ id, type: this.shapeType, props: { isComplete: true } }])\n\n\t\t\t\t\tconst newShapeId = createShapeId()\n\n\t\t\t\t\tconst props = this.editor.getShape<DrawableShape>(id)!.props\n\n\t\t\t\t\tif (!this.editor.canCreateShapes([newShapeId])) return this.cancel()\n\t\t\t\t\tthis.editor.createShape<DrawableShape>({\n\t\t\t\t\t\tid: newShapeId,\n\t\t\t\t\t\ttype: this.shapeType,\n\t\t\t\t\t\tx: toFixed(inputs.currentPagePoint.x),\n\t\t\t\t\t\ty: toFixed(inputs.currentPagePoint.y),\n\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\tisPen: this.isPenOrStylus,\n\t\t\t\t\t\t\tscale: props.scale,\n\t\t\t\t\t\t\tsegments: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ttype: 'free',\n\t\t\t\t\t\t\t\t\tpoints: [{ x: 0, y: 0, z: this.isPenOrStylus ? +(z! * 1.25).toFixed() : 0.5 }],\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t},\n\t\t\t\t\t})\n\n\t\t\t\t\tconst shape = this.editor.getShape<DrawableShape>(newShapeId)\n\n\t\t\t\t\tif (!shape) {\n\t\t\t\t\t\t// This would only happen if the page is full and no more shapes can be created. The bug would manifest as a crash when we try to clone the shape.\n\t\t\t\t\t\t// todo: handle this type of thing better\n\t\t\t\t\t\treturn this.cancel()\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.initialShape = structuredClone(shape)\n\t\t\t\t\tthis.mergeNextPoint = false\n\t\t\t\t\tthis.lastRecordedPoint = inputs.currentPagePoint.clone()\n\t\t\t\t\tthis.currentLineLength = 0\n\t\t\t\t}\n\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate getLineLength(segments: TLDrawShapeSegment[]) {\n\t\tlet length = 0\n\n\t\tfor (const segment of segments) {\n\t\t\tfor (let i = 0; i < segment.points.length - 1; i++) {\n\t\t\t\tconst A = segment.points[i]\n\t\t\t\tconst B = segment.points[i + 1]\n\t\t\t\tlength += Vec.Dist2(B, A)\n\t\t\t}\n\t\t}\n\n\t\treturn Math.sqrt(length)\n\t}\n\n\toverride onPointerUp() {\n\t\tthis.complete()\n\t}\n\n\toverride onCancel() {\n\t\tthis.cancel()\n\t}\n\n\toverride onComplete() {\n\t\tthis.complete()\n\t}\n\n\toverride onInterrupt() {\n\t\tif (this.editor.inputs.isDragging) {\n\t\t\treturn\n\t\t}\n\n\t\tif (this.markId) {\n\t\t\tthis.editor.bailToMark(this.markId)\n\t\t}\n\t\tthis.cancel()\n\t}\n\n\tcomplete() {\n\t\tconst { initialShape } = this\n\t\tif (!initialShape) return\n\t\tthis.editor.updateShapes([\n\t\t\t{ id: initialShape.id, type: initialShape.type, props: { isComplete: true } },\n\t\t])\n\n\t\tthis.parent.transition('idle')\n\t}\n\n\tcancel() {\n\t\tthis.parent.transition('idle', this.info)\n\t}\n}\n"],
|
|
5
|
-
"mappings": "AAAA;AAAA,EACC;AAAA,EACA;AAAA,EAQA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAEP,SAAS,oBAAoB;AAKtB,MAAM,gBAAgB,UAAU;AAAA,EACtC,OAAgB,KAAK;AAAA,EAErB,OAAO,CAAC;AAAA,EAER;AAAA,EAES,YAAY,KAAK,OAAO,OAAO,cAAe,cAAyB;AAAA,EAEhF,OAAO,KAAK,OAAO,aAAa,KAAK,SAAS;AAAA,EAE9C,QAAQ;AAAA,EACR,gBAAgB;AAAA,EAEhB,cAAc;AAAA,EAEd,6CAA6C;AAAA,EAE7C,sCAAsC,CAAC;AAAA,EAEvC,mCAAmC;AAAA,EAEnC,oBAAoB,CAAC;AAAA,EACrB,iBAAiB;AAAA,EACjB,oBAAoB;AAAA,EAEpB,SAAS;AAAA,EAEA,QAAQ,MAA0B;AAC1C,SAAK,SAAS;AACd,SAAK,OAAO;AACZ,SAAK,oBAAoB,KAAK,OAAO,OAAO,iBAAiB,MAAM;AACnE,SAAK,WAA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,KAAK,MAAM;AAAA,EACxB;AAAA,EAES,cAAc;AACtB,SAAK,SAAS;AAAA,EACf;AAAA,EAES,WAAW;AACnB,SAAK,OAAO;AAAA,EACb;AAAA,EAES,aAAa;AACrB,SAAK,SAAS;AAAA,EACf;AAAA,EAES,cAAc;AACtB,QAAI,KAAK,OAAO,OAAO,YAAY;AAClC;AAAA,IACD;AAEA,QAAI,KAAK,QAAQ;AAChB,WAAK,OAAO,WAAW,KAAK,MAAM;AAAA,IACnC;AACA,SAAK,OAAO;AAAA,EACb;AAAA,EAEA,WAAW;AACV,UAAM,EAAE,aAAa,IAAI;AACzB,QAAI,CAAC,aAAc;AACnB,SAAK,OAAO,aAAa;AAAA,MACxB,EAAE,IAAI,aAAa,IAAI,MAAM,aAAa,MAAM,OAAO,EAAE,YAAY,KAAK,EAAE;AAAA,IAC7E,CAAC;AAED,SAAK,OAAO,WAAW,MAAM;AAAA,EAC9B;AAAA,EAEA,SAAS;AACR,SAAK,OAAO,WAAW,QAAQ,KAAK,IAAI;AAAA,EACzC;AACD;",
|
|
6
|
-
"names": ["shape", "
|
|
4
|
+
"sourcesContent": ["import {\n\tMat,\n\tStateNode,\n\tTLDefaultSizeStyle,\n\tTLDrawShape,\n\tTLDrawShapeSegment,\n\tTLHighlightShape,\n\tTLKeyboardEventInfo,\n\tTLPointerEventInfo,\n\tTLShapePartial,\n\tVec,\n\tVecModel,\n\tb64Vecs,\n\tcreateShapeId,\n\tlast,\n\tsnapAngle,\n\tstructuredClone,\n\ttoFixed,\n\tuniqueId,\n} from '@tldraw/editor'\nimport { HighlightShapeUtil } from '../../highlight/HighlightShapeUtil'\nimport { STROKE_SIZES } from '../../shared/default-shape-constants'\nimport { DrawShapeUtil } from '../DrawShapeUtil'\n\ntype DrawableShape = TLDrawShape | TLHighlightShape\n\nexport class Drawing extends StateNode {\n\tstatic override id = 'drawing'\n\n\tinfo = {} as TLPointerEventInfo\n\n\tinitialShape?: DrawableShape\n\n\toverride shapeType = this.parent.id === 'highlight' ? ('highlight' as const) : ('draw' as const)\n\n\tutil = this.editor.getShapeUtil(this.shapeType) as DrawShapeUtil | HighlightShapeUtil\n\n\tisPen = false\n\tisPenOrStylus = false\n\n\tsegmentMode = 'free' as 'free' | 'straight' | 'starting_straight' | 'starting_free'\n\n\tdidJustShiftClickToExtendPreviousShapeLine = false\n\n\tpagePointWhereCurrentSegmentChanged = {} as Vec\n\n\tpagePointWhereNextSegmentChanged = null as Vec | null\n\n\tlastRecordedPoint = {} as Vec\n\tmergeNextPoint = false\n\tcurrentLineLength = 0\n\n\t// Cache for current segment's points to avoid repeated b64 decode/encode\n\tcurrentSegmentPoints: Vec[] = []\n\n\tmarkId = null as null | string\n\n\toverride onEnter(info: TLPointerEventInfo) {\n\t\tthis.markId = null\n\t\tthis.info = info\n\t\tthis.lastRecordedPoint = this.editor.inputs.getCurrentPagePoint().clone()\n\t\tthis.startShape()\n\t}\n\n\toverride onPointerMove() {\n\t\tconst { inputs } = this.editor\n\t\tconst isPen = inputs.getIsPen()\n\n\t\tif (this.isPen && !isPen) {\n\t\t\t// The user made a palm gesture before starting a pen gesture;\n\t\t\t// ideally we'd start the new shape here but we could also just bail\n\t\t\t// as the next interaction will work correctly\n\t\t\tif (this.markId) {\n\t\t\t\tthis.editor.bailToMark(this.markId)\n\t\t\t\tthis.startShape()\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\tif (this.isPenOrStylus) {\n\t\t\t// Don't update the shape if we haven't moved far enough from the last time we recorded a point\n\t\t\tconst currentPagePoint = inputs.getCurrentPagePoint()\n\t\t\tif (Vec.Dist(currentPagePoint, this.lastRecordedPoint) >= 1 / this.editor.getZoomLevel()) {\n\t\t\t\tthis.lastRecordedPoint = currentPagePoint.clone()\n\t\t\t\tthis.mergeNextPoint = false\n\t\t\t} else {\n\t\t\t\tthis.mergeNextPoint = true\n\t\t\t}\n\t\t} else {\n\t\t\tthis.mergeNextPoint = false\n\t\t}\n\n\t\tthis.updateDrawingShape()\n\t}\n\n\toverride onKeyDown(info: TLKeyboardEventInfo) {\n\t\tif (info.key === 'Shift') {\n\t\t\tswitch (this.segmentMode) {\n\t\t\t\tcase 'free': {\n\t\t\t\t\t// We've just entered straight mode, go to straight mode\n\t\t\t\t\tthis.segmentMode = 'starting_straight'\n\t\t\t\t\tthis.pagePointWhereNextSegmentChanged = this.editor.inputs.getCurrentPagePoint().clone()\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tcase 'starting_free': {\n\t\t\t\t\tthis.segmentMode = 'starting_straight'\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tthis.updateDrawingShape()\n\t}\n\n\toverride onKeyUp(info: TLKeyboardEventInfo) {\n\t\tif (info.key === 'Shift') {\n\t\t\tthis.editor.snaps.clearIndicators()\n\n\t\t\tswitch (this.segmentMode) {\n\t\t\t\tcase 'straight': {\n\t\t\t\t\t// We've just exited straight mode, go back to free mode\n\t\t\t\t\tthis.segmentMode = 'starting_free'\n\t\t\t\t\tthis.pagePointWhereNextSegmentChanged = this.editor.inputs.getCurrentPagePoint().clone()\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tcase 'starting_straight': {\n\t\t\t\t\tthis.pagePointWhereNextSegmentChanged = null\n\t\t\t\t\tthis.segmentMode = 'free'\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tthis.updateDrawingShape()\n\t}\n\n\toverride onExit() {\n\t\tthis.editor.snaps.clearIndicators()\n\t\tthis.pagePointWhereCurrentSegmentChanged = this.editor.inputs.getCurrentPagePoint().clone()\n\t}\n\n\tcanClose() {\n\t\treturn this.shapeType !== 'highlight'\n\t}\n\n\tgetIsClosed(segments: TLDrawShapeSegment[], size: TLDefaultSizeStyle, scale: number) {\n\t\tif (!this.canClose()) return false\n\n\t\tconst strokeWidth = STROKE_SIZES[size]\n\t\tconst firstPoint = b64Vecs.decodeFirstPoint(segments[0].points)\n\t\tconst lastSegment = segments[segments.length - 1]\n\t\tconst lastPoint = b64Vecs.decodeLastPoint(lastSegment.points)\n\n\t\treturn (\n\t\t\tfirstPoint !== null &&\n\t\t\tlastPoint !== null &&\n\t\t\tfirstPoint !== lastPoint &&\n\t\t\tthis.currentLineLength > strokeWidth * 4 * scale &&\n\t\t\tVec.DistMin(firstPoint, lastPoint, strokeWidth * 2 * scale)\n\t\t)\n\t}\n\n\tprivate startShape() {\n\t\tconst inputs = this.editor.inputs\n\t\tconst originPagePoint = inputs.getOriginPagePoint()\n\t\tconst isPen = inputs.getIsPen()\n\n\t\tthis.markId = this.editor.markHistoryStoppingPoint('draw start')\n\n\t\t// If the pressure is weird, then it's probably a stylus reporting as a mouse\n\t\t// We treat pen/stylus inputs differently in the drawing tool, so we need to\n\t\t// have our own value for this. The inputs.isPen is only if the input is a regular\n\t\t// pen, like an iPad pen, which needs to trigger \"pen mode\" in order to avoid\n\t\t// accidental palm touches. We don't have to worry about that with styluses though.\n\t\tconst { z = 0.5 } = this.info.point\n\n\t\tthis.isPen = isPen\n\t\tthis.isPenOrStylus = isPen || (z > 0 && z < 0.5) || (z > 0.5 && z < 1)\n\n\t\tconst pressure = this.isPenOrStylus ? z * 1.25 : 0.5\n\n\t\tthis.segmentMode = this.editor.inputs.getShiftKey() ? 'straight' : 'free'\n\n\t\tthis.didJustShiftClickToExtendPreviousShapeLine = false\n\n\t\tthis.lastRecordedPoint = originPagePoint.clone()\n\n\t\tif (this.initialShape) {\n\t\t\tconst shape = this.editor.getShape<DrawableShape>(this.initialShape.id)\n\n\t\t\tif (shape && this.segmentMode === 'straight') {\n\t\t\t\t// Connect dots\n\n\t\t\t\tthis.didJustShiftClickToExtendPreviousShapeLine = true\n\n\t\t\t\tconst prevSegment = last(shape.props.segments)\n\t\t\t\tif (!prevSegment) throw Error('Expected a previous segment!')\n\t\t\t\tconst prevPoint = b64Vecs.decodeLastPoint(prevSegment.points)\n\t\t\t\tif (!prevPoint) throw Error('Expected a previous point!')\n\n\t\t\t\tconst { x, y } = this.editor.getPointInShapeSpace(shape, originPagePoint).toFixed()\n\n\t\t\t\tconst newSegment: TLDrawShapeSegment = {\n\t\t\t\t\ttype: this.segmentMode,\n\t\t\t\t\tpoints: b64Vecs.encodePoints([\n\t\t\t\t\t\t{ x: prevPoint.x, y: prevPoint.y, z: +pressure.toFixed(2) },\n\t\t\t\t\t\t{ x, y, z: +pressure.toFixed(2) },\n\t\t\t\t\t]),\n\t\t\t\t}\n\n\t\t\t\t// Convert prevPoint to page space\n\t\t\t\tconst prevPointPageSpace = Mat.applyToPoint(\n\t\t\t\t\tthis.editor.getShapePageTransform(shape.id)!,\n\t\t\t\t\tprevPoint\n\t\t\t\t)\n\t\t\t\tthis.pagePointWhereCurrentSegmentChanged = prevPointPageSpace\n\t\t\t\tthis.pagePointWhereNextSegmentChanged = null\n\t\t\t\tconst segments = [...shape.props.segments, newSegment]\n\n\t\t\t\tif (this.currentLineLength < STROKE_SIZES[shape.props.size] * 4) {\n\t\t\t\t\tthis.currentLineLength = this.getLineLength(segments)\n\t\t\t\t}\n\n\t\t\t\tconst shapePartial: TLShapePartial<DrawableShape> = {\n\t\t\t\t\tid: shape.id,\n\t\t\t\t\ttype: this.shapeType,\n\t\t\t\t\tprops: {\n\t\t\t\t\t\tsegments,\n\t\t\t\t\t},\n\t\t\t\t}\n\n\t\t\t\tif (this.canClose()) {\n\t\t\t\t\t;(shapePartial as TLShapePartial<TLDrawShape>).props!.isClosed = this.getIsClosed(\n\t\t\t\t\t\tsegments,\n\t\t\t\t\t\tshape.props.size,\n\t\t\t\t\t\tshape.props.scale\n\t\t\t\t\t)\n\t\t\t\t}\n\n\t\t\t\tthis.editor.updateShapes([shapePartial])\n\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\t// Create a new shape\n\n\t\tthis.pagePointWhereCurrentSegmentChanged = originPagePoint.clone()\n\t\tconst id = createShapeId()\n\n\t\t// Initialize the segment points cache\n\t\tconst initialPoint = new Vec(0, 0, +pressure.toFixed(2))\n\t\tthis.currentSegmentPoints = [initialPoint]\n\n\t\t// Allow this to trigger the max shapes reached alert\n\t\tthis.editor.createShape({\n\t\t\tid,\n\t\t\ttype: this.shapeType,\n\t\t\tx: originPagePoint.x,\n\t\t\ty: originPagePoint.y,\n\t\t\tprops: {\n\t\t\t\tisPen: this.isPenOrStylus,\n\t\t\t\tscale: this.editor.user.getIsDynamicResizeMode() ? 1 / this.editor.getZoomLevel() : 1,\n\t\t\t\tsegments: [\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: this.segmentMode,\n\t\t\t\t\t\tpoints: b64Vecs.encodePoints([initialPoint]),\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t})\n\t\tconst shape = this.editor.getShape<DrawableShape>(id)\n\t\tif (!shape) {\n\t\t\tthis.cancel()\n\t\t\treturn\n\t\t}\n\t\tthis.currentLineLength = 0\n\t\tthis.initialShape = this.editor.getShape<DrawableShape>(id)\n\t}\n\n\tprivate updateDrawingShape() {\n\t\tconst { initialShape } = this\n\t\tconst { inputs } = this.editor\n\n\t\tif (!initialShape) return\n\n\t\tconst {\n\t\t\tid,\n\t\t\tprops: { size, scale },\n\t\t} = initialShape\n\n\t\tconst shape = this.editor.getShape<DrawableShape>(id)!\n\n\t\tif (!shape) return\n\n\t\tconst { segments } = shape.props\n\n\t\tconst currentPagePoint = inputs.getCurrentPagePoint()\n\t\tconst { x, y, z } = this.editor.getPointInShapeSpace(shape, currentPagePoint).toFixed()\n\t\tconst pressure = this.isPenOrStylus ? +(currentPagePoint.z! * 1.25).toFixed(2) : 0.5\n\t\tconst newPoint = { x, y, z: pressure }\n\n\t\tswitch (this.segmentMode) {\n\t\t\tcase 'starting_straight': {\n\t\t\t\tconst { pagePointWhereNextSegmentChanged } = this\n\n\t\t\t\tif (pagePointWhereNextSegmentChanged === null) {\n\t\t\t\t\tthrow Error('We should have a point where the segment changed')\n\t\t\t\t}\n\n\t\t\t\tconst hasMovedFarEnough =\n\t\t\t\t\tVec.Dist2(pagePointWhereNextSegmentChanged, inputs.getCurrentPagePoint()) >\n\t\t\t\t\tthis.editor.options.dragDistanceSquared\n\n\t\t\t\t// Find the distance from where the pointer was when shift was released and\n\t\t\t\t// where it is now; if it's far enough away, then update the page point where\n\t\t\t\t// the current segment changed (to match the pagepoint where next segment changed)\n\t\t\t\t// and set the pagepoint where next segment changed to null.\n\t\t\t\tif (hasMovedFarEnough) {\n\t\t\t\t\tthis.pagePointWhereCurrentSegmentChanged = this.pagePointWhereNextSegmentChanged!.clone()\n\t\t\t\t\tthis.pagePointWhereNextSegmentChanged = null\n\n\t\t\t\t\t// Set the new mode\n\t\t\t\t\tthis.segmentMode = 'straight'\n\n\t\t\t\t\tconst prevSegment = last(segments)\n\t\t\t\t\tif (!prevSegment) throw Error('Expected a previous segment!')\n\n\t\t\t\t\tconst prevLastPoint = b64Vecs.decodeLastPoint(prevSegment.points)\n\t\t\t\t\tif (!prevLastPoint) throw Error('Expected a previous last point!')\n\n\t\t\t\t\tlet newSegment: TLDrawShapeSegment\n\n\t\t\t\t\tconst newLastPoint = this.editor\n\t\t\t\t\t\t.getPointInShapeSpace(shape, this.pagePointWhereCurrentSegmentChanged)\n\t\t\t\t\t\t.toFixed()\n\t\t\t\t\t\t.toJson()\n\n\t\t\t\t\tif (prevSegment.type === 'straight') {\n\t\t\t\t\t\tthis.currentLineLength += Vec.Dist(prevLastPoint, newLastPoint)\n\n\t\t\t\t\t\tnewSegment = {\n\t\t\t\t\t\t\ttype: 'straight',\n\t\t\t\t\t\t\tpoints: b64Vecs.encodePoints([prevLastPoint, newLastPoint]),\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst transform = this.editor.getShapePageTransform(shape)!\n\n\t\t\t\t\t\tthis.pagePointWhereCurrentSegmentChanged = Mat.applyToPoint(transform, prevLastPoint)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnewSegment = {\n\t\t\t\t\t\t\ttype: 'straight',\n\t\t\t\t\t\t\tpoints: b64Vecs.encodePoints([newLastPoint, newPoint]),\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tconst shapePartial: TLShapePartial<DrawableShape> = {\n\t\t\t\t\t\tid,\n\t\t\t\t\t\ttype: this.shapeType,\n\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\tsegments: [...segments, newSegment],\n\t\t\t\t\t\t},\n\t\t\t\t\t}\n\n\t\t\t\t\tif (this.canClose()) {\n\t\t\t\t\t\t;(shapePartial as TLShapePartial<TLDrawShape>).props!.isClosed = this.getIsClosed(\n\t\t\t\t\t\t\tsegments,\n\t\t\t\t\t\t\tsize,\n\t\t\t\t\t\t\tscale\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.editor.updateShapes([shapePartial])\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'starting_free': {\n\t\t\t\tconst { pagePointWhereNextSegmentChanged } = this\n\n\t\t\t\tif (pagePointWhereNextSegmentChanged === null) {\n\t\t\t\t\tthrow Error('We should have a point where the segment changed')\n\t\t\t\t}\n\n\t\t\t\tconst hasMovedFarEnough =\n\t\t\t\t\tVec.Dist2(pagePointWhereNextSegmentChanged, inputs.getCurrentPagePoint()) >\n\t\t\t\t\tthis.editor.options.dragDistanceSquared\n\n\t\t\t\t// Find the distance from where the pointer was when shift was released and\n\t\t\t\t// where it is now; if it's far enough away, then update the page point where\n\t\t\t\t// the current segment changed (to match the pagepoint where next segment changed)\n\t\t\t\t// and set the pagepoint where next segment changed to null.\n\t\t\t\tif (hasMovedFarEnough) {\n\t\t\t\t\tthis.pagePointWhereCurrentSegmentChanged = this.pagePointWhereNextSegmentChanged!.clone()\n\t\t\t\t\tthis.pagePointWhereNextSegmentChanged = null\n\n\t\t\t\t\t// Set the new mode\n\t\t\t\t\tthis.segmentMode = 'free'\n\n\t\t\t\t\tconst newSegments = segments.slice()\n\t\t\t\t\tconst prevStraightSegment = newSegments[newSegments.length - 1]\n\t\t\t\t\tconst prevPoint = b64Vecs.decodeLastPoint(prevStraightSegment.points)\n\n\t\t\t\t\tif (!prevPoint) {\n\t\t\t\t\t\tthrow Error('No previous point!')\n\t\t\t\t\t}\n\n\t\t\t\t\t// Create the new free segment and interpolate the points between where the last line\n\t\t\t\t\t// ended and where the pointer is now\n\t\t\t\t\tconst interpolatedPoints = Vec.PointsBetween(prevPoint, newPoint, 6).map(\n\t\t\t\t\t\t(p) => new Vec(toFixed(p.x), toFixed(p.y), toFixed(p.z))\n\t\t\t\t\t)\n\t\t\t\t\t// Initialize cache for the new free segment\n\t\t\t\t\tthis.currentSegmentPoints = interpolatedPoints\n\n\t\t\t\t\tconst newFreeSegment: TLDrawShapeSegment = {\n\t\t\t\t\t\ttype: 'free',\n\t\t\t\t\t\tpoints: b64Vecs.encodePoints(interpolatedPoints),\n\t\t\t\t\t}\n\n\t\t\t\t\tconst finalSegments = [...newSegments, newFreeSegment]\n\n\t\t\t\t\tif (this.currentLineLength < STROKE_SIZES[shape.props.size] * 4) {\n\t\t\t\t\t\tthis.currentLineLength = this.getLineLength(finalSegments)\n\t\t\t\t\t}\n\n\t\t\t\t\tconst shapePartial: TLShapePartial<DrawableShape> = {\n\t\t\t\t\t\tid,\n\t\t\t\t\t\ttype: this.shapeType,\n\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\tsegments: finalSegments,\n\t\t\t\t\t\t},\n\t\t\t\t\t}\n\n\t\t\t\t\tif (this.canClose()) {\n\t\t\t\t\t\t;(shapePartial as TLShapePartial<TLDrawShape>).props!.isClosed = this.getIsClosed(\n\t\t\t\t\t\t\tfinalSegments,\n\t\t\t\t\t\t\tsize,\n\t\t\t\t\t\t\tscale\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.editor.updateShapes([shapePartial])\n\t\t\t\t}\n\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'straight': {\n\t\t\t\tconst newSegments = segments.slice()\n\t\t\t\tconst newSegment = newSegments[newSegments.length - 1]\n\n\t\t\t\tconst { pagePointWhereCurrentSegmentChanged } = this\n\t\t\t\tconst inputs = this.editor.inputs\n\t\t\t\tconst ctrlKey = inputs.getCtrlKey()\n\t\t\t\tconst currentPagePoint = inputs.getCurrentPagePoint()\n\n\t\t\t\tif (!pagePointWhereCurrentSegmentChanged)\n\t\t\t\t\tthrow Error('We should have a point where the segment changed')\n\n\t\t\t\tlet pagePoint: VecModel\n\t\t\t\tlet shouldSnapToAngle = false\n\n\t\t\t\tif (this.didJustShiftClickToExtendPreviousShapeLine) {\n\t\t\t\t\tif (this.editor.inputs.getIsDragging()) {\n\t\t\t\t\t\t// If we've just shift clicked to extend a line, only snap once we've started dragging\n\t\t\t\t\t\tshouldSnapToAngle = !ctrlKey\n\t\t\t\t\t\tthis.didJustShiftClickToExtendPreviousShapeLine = false\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// noop\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// If we're not shift clicking to extend a line, but we're holding shift, then we should snap\n\t\t\t\t\tshouldSnapToAngle = !ctrlKey // don't snap angle while snapping line\n\t\t\t\t}\n\n\t\t\t\tlet newPoint = this.editor.getPointInShapeSpace(shape, currentPagePoint).toFixed().toJson()\n\t\t\t\tlet didSnap = false\n\t\t\t\tlet snapSegment: TLDrawShapeSegment | undefined = undefined\n\n\t\t\t\tconst shouldSnap = this.editor.user.getIsSnapMode() ? !ctrlKey : ctrlKey\n\n\t\t\t\tif (shouldSnap) {\n\t\t\t\t\tif (newSegments.length > 2) {\n\t\t\t\t\t\tlet nearestPoint: VecModel | undefined = undefined\n\t\t\t\t\t\tlet minDistance = 8 / this.editor.getZoomLevel()\n\n\t\t\t\t\t\t// Don't try to snap to the last two segments\n\t\t\t\t\t\tfor (let i = 0, n = segments.length - 2; i < n; i++) {\n\t\t\t\t\t\t\tconst segment = segments[i]\n\t\t\t\t\t\t\tif (!segment) break\n\t\t\t\t\t\t\tif (segment.type === 'free') continue\n\n\t\t\t\t\t\t\tconst first = b64Vecs.decodeFirstPoint(segment.points)\n\t\t\t\t\t\t\tconst lastPoint = b64Vecs.decodeLastPoint(segment.points)\n\t\t\t\t\t\t\tif (!(first && lastPoint)) continue\n\n\t\t\t\t\t\t\t// Snap to the nearest point on the segment, if it's closer than the previous snapped point\n\t\t\t\t\t\t\tconst nearestPointOnSegment = Vec.NearestPointOnLineSegment(\n\t\t\t\t\t\t\t\tfirst,\n\t\t\t\t\t\t\t\tlastPoint,\n\t\t\t\t\t\t\t\tnewPoint\n\t\t\t\t\t\t\t)\n\n\t\t\t\t\t\t\tif (Vec.DistMin(nearestPointOnSegment, newPoint, minDistance)) {\n\t\t\t\t\t\t\t\tnearestPoint = nearestPointOnSegment.toFixed().toJson()\n\t\t\t\t\t\t\t\tminDistance = Vec.Dist(nearestPointOnSegment, newPoint)\n\t\t\t\t\t\t\t\tsnapSegment = segment\n\t\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (nearestPoint) {\n\t\t\t\t\t\t\tdidSnap = true\n\t\t\t\t\t\t\tnewPoint = nearestPoint\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (didSnap && snapSegment) {\n\t\t\t\t\tconst transform = this.editor.getShapePageTransform(shape)!\n\t\t\t\t\tconst first = b64Vecs.decodeFirstPoint(snapSegment.points)\n\t\t\t\t\tconst lastPoint = b64Vecs.decodeLastPoint(snapSegment.points)\n\t\t\t\t\tif (!first || !lastPoint) throw Error('Expected a last point!')\n\n\t\t\t\t\tconst A = Mat.applyToPoint(transform, first)\n\n\t\t\t\t\tconst B = Mat.applyToPoint(transform, lastPoint)\n\n\t\t\t\t\tconst snappedPoint = Mat.applyToPoint(transform, newPoint)\n\n\t\t\t\t\tthis.editor.snaps.setIndicators([\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tid: uniqueId(),\n\t\t\t\t\t\t\ttype: 'points',\n\t\t\t\t\t\t\tpoints: [A, snappedPoint, B],\n\t\t\t\t\t\t},\n\t\t\t\t\t])\n\t\t\t\t} else {\n\t\t\t\t\tthis.editor.snaps.clearIndicators()\n\n\t\t\t\t\tif (shouldSnapToAngle) {\n\t\t\t\t\t\t// Snap line angle to nearest 15 degrees\n\t\t\t\t\t\tconst currentAngle = Vec.Angle(pagePointWhereCurrentSegmentChanged, currentPagePoint)\n\t\t\t\t\t\tconst snappedAngle = snapAngle(currentAngle, 24)\n\t\t\t\t\t\tconst angleDiff = snappedAngle - currentAngle\n\n\t\t\t\t\t\tpagePoint = Vec.RotWith(\n\t\t\t\t\t\t\tcurrentPagePoint,\n\t\t\t\t\t\t\tpagePointWhereCurrentSegmentChanged,\n\t\t\t\t\t\t\tangleDiff\n\t\t\t\t\t\t)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tpagePoint = currentPagePoint.clone()\n\t\t\t\t\t}\n\n\t\t\t\t\tnewPoint = this.editor.getPointInShapeSpace(shape, pagePoint).toFixed().toJson()\n\t\t\t\t}\n\n\t\t\t\t// If the previous segment is a one point free shape and is the first segment of the line,\n\t\t\t\t// then the user just did a click-and-immediately-press-shift to create a new straight line\n\t\t\t\t// without continuing the previous line. In this case, we want to remove the previous segment.\n\n\t\t\t\tthis.currentLineLength +=\n\t\t\t\t\tnewSegments.length && b64Vecs.decodeFirstPoint(newSegment.points)\n\t\t\t\t\t\t? Vec.Dist(b64Vecs.decodeFirstPoint(newSegment.points)!, Vec.From(newPoint))\n\t\t\t\t\t\t: 0\n\n\t\t\t\tnewSegments[newSegments.length - 1] = {\n\t\t\t\t\t...newSegment,\n\t\t\t\t\ttype: 'straight',\n\t\t\t\t\tpoints: b64Vecs.encodePoints([\n\t\t\t\t\t\tb64Vecs.decodeFirstPoint(newSegment.points)!,\n\t\t\t\t\t\tVec.From(newPoint),\n\t\t\t\t\t]),\n\t\t\t\t}\n\n\t\t\t\tconst shapePartial: TLShapePartial<DrawableShape> = {\n\t\t\t\t\tid,\n\t\t\t\t\ttype: this.shapeType,\n\t\t\t\t\tprops: {\n\t\t\t\t\t\tsegments: newSegments,\n\t\t\t\t\t},\n\t\t\t\t}\n\n\t\t\t\tif (this.canClose()) {\n\t\t\t\t\t;(shapePartial as TLShapePartial<TLDrawShape>).props!.isClosed = this.getIsClosed(\n\t\t\t\t\t\tsegments,\n\t\t\t\t\t\tsize,\n\t\t\t\t\t\tscale\n\t\t\t\t\t)\n\t\t\t\t}\n\n\t\t\t\tthis.editor.updateShapes([shapePartial])\n\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'free': {\n\t\t\t\t// Use cached points instead of decoding from b64 on every update\n\t\t\t\tconst cachedPoints = this.currentSegmentPoints\n\n\t\t\t\tif (cachedPoints.length && this.mergeNextPoint) {\n\t\t\t\t\tconst lastPoint = cachedPoints[cachedPoints.length - 1]\n\t\t\t\t\tlastPoint.x = newPoint.x\n\t\t\t\t\tlastPoint.y = newPoint.y\n\t\t\t\t\tlastPoint.z = lastPoint.z ? Math.max(lastPoint.z, newPoint.z) : newPoint.z\n\t\t\t\t\t// Note: we could recompute the line length here, but it's not really necessary\n\t\t\t\t\t// this.currentLineLength = this.getLineLength(newSegments)\n\t\t\t\t} else {\n\t\t\t\t\tthis.currentLineLength += cachedPoints.length\n\t\t\t\t\t\t? Vec.Dist(cachedPoints[cachedPoints.length - 1], newPoint)\n\t\t\t\t\t\t: 0\n\t\t\t\t\tcachedPoints.push(new Vec(newPoint.x, newPoint.y, newPoint.z))\n\t\t\t\t}\n\n\t\t\t\tconst newSegments = segments.slice()\n\t\t\t\tconst newSegment = newSegments[newSegments.length - 1]\n\t\t\t\tnewSegments[newSegments.length - 1] = {\n\t\t\t\t\t...newSegment,\n\t\t\t\t\tpoints: b64Vecs.encodePoints(cachedPoints),\n\t\t\t\t}\n\n\t\t\t\tif (this.currentLineLength < STROKE_SIZES[shape.props.size] * 4) {\n\t\t\t\t\tthis.currentLineLength = this.getLineLength(newSegments)\n\t\t\t\t}\n\n\t\t\t\tconst shapePartial: TLShapePartial<DrawableShape> = {\n\t\t\t\t\tid,\n\t\t\t\t\ttype: this.shapeType,\n\t\t\t\t\tprops: {\n\t\t\t\t\t\tsegments: newSegments,\n\t\t\t\t\t},\n\t\t\t\t}\n\n\t\t\t\tif (this.canClose()) {\n\t\t\t\t\t;(shapePartial as TLShapePartial<TLDrawShape>).props!.isClosed = this.getIsClosed(\n\t\t\t\t\t\tnewSegments,\n\t\t\t\t\t\tsize,\n\t\t\t\t\t\tscale\n\t\t\t\t\t)\n\t\t\t\t}\n\n\t\t\t\tthis.editor.updateShapes([shapePartial])\n\n\t\t\t\t// Set a maximum length for the lines array; after 200 points, complete the line.\n\t\t\t\tif (cachedPoints.length > this.util.options.maxPointsPerShape) {\n\t\t\t\t\tthis.editor.updateShapes([{ id, type: this.shapeType, props: { isComplete: true } }])\n\n\t\t\t\t\tconst newShapeId = createShapeId()\n\n\t\t\t\t\tconst props = this.editor.getShape<DrawableShape>(id)!.props\n\n\t\t\t\t\tif (!this.editor.canCreateShapes([newShapeId])) return this.cancel()\n\t\t\t\t\tconst currentPagePoint = inputs.getCurrentPagePoint()\n\n\t\t\t\t\t// Reset cache for the new shape's segment\n\t\t\t\t\tconst initialPoint = new Vec(0, 0, this.isPenOrStylus ? +(z! * 1.25).toFixed() : 0.5)\n\t\t\t\t\tthis.currentSegmentPoints = [initialPoint]\n\n\t\t\t\t\tthis.editor.createShape({\n\t\t\t\t\t\tid: newShapeId,\n\t\t\t\t\t\ttype: this.shapeType,\n\t\t\t\t\t\tx: toFixed(currentPagePoint.x),\n\t\t\t\t\t\ty: toFixed(currentPagePoint.y),\n\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\tisPen: this.isPenOrStylus,\n\t\t\t\t\t\t\tscale: props.scale,\n\t\t\t\t\t\t\tsegments: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ttype: 'free',\n\t\t\t\t\t\t\t\t\tpoints: b64Vecs.encodePoints([initialPoint]),\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t},\n\t\t\t\t\t})\n\n\t\t\t\t\tconst shape = this.editor.getShape<DrawableShape>(newShapeId)\n\n\t\t\t\t\tif (!shape) {\n\t\t\t\t\t\t// This would only happen if the page is full and no more shapes can be created. The bug would manifest as a crash when we try to clone the shape.\n\t\t\t\t\t\t// todo: handle this type of thing better\n\t\t\t\t\t\treturn this.cancel()\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.initialShape = structuredClone(shape)\n\t\t\t\t\tthis.mergeNextPoint = false\n\t\t\t\t\tthis.lastRecordedPoint = currentPagePoint.clone()\n\t\t\t\t\tthis.currentLineLength = 0\n\t\t\t\t}\n\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate getLineLength(segments: TLDrawShapeSegment[]) {\n\t\tlet length = 0\n\n\t\tfor (let j = 0; j < segments.length; j++) {\n\t\t\tconst points = b64Vecs.decodePoints(segments[j].points)\n\t\t\tfor (let i = 0; i < points.length - 1; i++) {\n\t\t\t\tlength += Vec.Dist2(points[i], points[i + 1])\n\t\t\t}\n\t\t}\n\n\t\treturn Math.sqrt(length)\n\t}\n\n\toverride onPointerUp() {\n\t\tthis.complete()\n\t}\n\n\toverride onCancel() {\n\t\tthis.cancel()\n\t}\n\n\toverride onComplete() {\n\t\tthis.complete()\n\t}\n\n\toverride onInterrupt() {\n\t\tif (this.editor.inputs.getIsDragging()) {\n\t\t\treturn\n\t\t}\n\n\t\tif (this.markId) {\n\t\t\tthis.editor.bailToMark(this.markId)\n\t\t}\n\t\tthis.cancel()\n\t}\n\n\tcomplete() {\n\t\tconst { initialShape } = this\n\t\tif (!initialShape) return\n\t\tthis.editor.updateShapes([\n\t\t\t{ id: initialShape.id, type: initialShape.type, props: { isComplete: true } },\n\t\t])\n\n\t\tthis.parent.transition('idle')\n\t}\n\n\tcancel() {\n\t\tthis.parent.transition('idle', this.info)\n\t}\n}\n"],
|
|
5
|
+
"mappings": "AAAA;AAAA,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BAAU,IAAI,MAAM,OAAO,CAAC,GAAG,OAAO,IAAI,CAAC,CAAC;AAAA,MAC7C;AAAA,IACD;AAEA,WAAO,KAAK,KAAK,MAAM;AAAA,EACxB;AAAA,EAES,cAAc;AACtB,SAAK,SAAS;AAAA,EACf;AAAA,EAES,WAAW;AACnB,SAAK,OAAO;AAAA,EACb;AAAA,EAES,aAAa;AACrB,SAAK,SAAS;AAAA,EACf;AAAA,EAES,cAAc;AACtB,QAAI,KAAK,OAAO,OAAO,cAAc,GAAG;AACvC;AAAA,IACD;AAEA,QAAI,KAAK,QAAQ;AAChB,WAAK,OAAO,WAAW,KAAK,MAAM;AAAA,IACnC;AACA,SAAK,OAAO;AAAA,EACb;AAAA,EAEA,WAAW;AACV,UAAM,EAAE,aAAa,IAAI;AACzB,QAAI,CAAC,aAAc;AACnB,SAAK,OAAO,aAAa;AAAA,MACxB,EAAE,IAAI,aAAa,IAAI,MAAM,aAAa,MAAM,OAAO,EAAE,YAAY,KAAK,EAAE;AAAA,IAC7E,CAAC;AAED,SAAK,OAAO,WAAW,MAAM;AAAA,EAC9B;AAAA,EAEA,SAAS;AACR,SAAK,OAAO,WAAW,QAAQ,KAAK,IAAI;AAAA,EACzC;AACD;",
|
|
6
|
+
"names": ["shape", "inputs", "currentPagePoint", "newPoint"]
|
|
7
7
|
}
|
|
@@ -28,6 +28,11 @@ class EmbedShapeUtil extends BaseBoxShapeUtil {
|
|
|
28
28
|
static props = embedShapeProps;
|
|
29
29
|
static migrations = embedShapeMigrations;
|
|
30
30
|
static embedDefinitions = DEFAULT_EMBED_DEFINITIONS;
|
|
31
|
+
canEditWhileLocked(shape) {
|
|
32
|
+
const result = this.getEmbedDefinition(shape.props.url);
|
|
33
|
+
if (!result) return true;
|
|
34
|
+
return result.definition.canEditWhileLocked ?? true;
|
|
35
|
+
}
|
|
31
36
|
static setEmbedDefinitions(embedDefinitions) {
|
|
32
37
|
EmbedShapeUtil.embedDefinitions = embedDefinitions;
|
|
33
38
|
}
|
|
@@ -162,6 +167,7 @@ class EmbedShapeUtil extends BaseBoxShapeUtil {
|
|
|
162
167
|
frameBorder: "0",
|
|
163
168
|
referrerPolicy: "no-referrer-when-downgrade",
|
|
164
169
|
tabIndex: isEditing ? 0 : -1,
|
|
170
|
+
allowFullScreen: true,
|
|
165
171
|
style: {
|
|
166
172
|
border: 0,
|
|
167
173
|
pointerEvents: isInteractive ? "auto" : "none",
|