tldraw 4.3.0-canary.d8da2a99f394 → 4.3.0-canary.da3162650c27
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/README.md +0 -2
- 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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/lib/defaultEmbedDefinitions.ts"],
|
|
4
|
-
"sourcesContent": ["import { safeParseUrl } from '@tldraw/editor'\n\n// Only allow multiplayer embeds. If we add additional routes later for example '/help' this won't match\nconst TLDRAW_APP_RE = /(^\\/[f|p|r|ro|s|v]\\/[^/]+\\/?$)/\n\n/** @public */\nexport const DEFAULT_EMBED_DEFINITIONS = [\n\t{\n\t\ttype: 'tldraw',\n\t\ttitle: 'tldraw',\n\t\thostnames: ['beta.tldraw.com', 'tldraw.com', 'localhost:3000'],\n\t\tminWidth: 300,\n\t\tminHeight: 300,\n\t\twidth: 720,\n\t\theight: 500,\n\t\tdoesResize: true,\n\t\toverridePermissions: {\n\t\t\t'allow-top-navigation': true,\n\t\t},\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(TLDRAW_APP_RE)) {\n\t\t\t\t// Add the \"clean=true\" search param to the URL to hide the sidebar\n\t\t\t\turlObj.searchParams.append('embed', 'true')\n\t\t\t\treturn url\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(TLDRAW_APP_RE)) {\n\t\t\t\t// Add the \"clean=true\" search param to the URL to hide the sidebar\n\t\t\t\turlObj.searchParams.delete('embed')\n\t\t\t\treturn url\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tembedOnPaste: false,\n\t},\n\t{\n\t\ttype: 'figma',\n\t\ttitle: 'Figma',\n\t\thostnames: ['figma.com'],\n\t\twidth: 720,\n\t\theight: 500,\n\t\tdoesResize: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tif (\n\t\t\t\t!!url.match(\n\t\t\t\t\t// eslint-disable-next-line no-useless-escape\n\t\t\t\t\t/https:\\/\\/([\\w\\.-]+\\.)?figma.com\\/(file|proto|design)\\/([0-9a-zA-Z]{22,128})(?:\\/.*)?$/\n\t\t\t\t) &&\n\t\t\t\t!url.includes('figma.com/embed')\n\t\t\t) {\n\t\t\t\treturn `https://www.figma.com/embed?embed_host=share&url=${url}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(/^\\/embed\\/?$/)) {\n\t\t\t\tconst outUrl = urlObj.searchParams.get('url')\n\t\t\t\tif (outUrl) {\n\t\t\t\t\treturn outUrl\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tembedOnPaste: true,\n\t},\n\t{\n\t\ttype: 'google_maps',\n\t\ttitle: 'Google Maps',\n\t\thostnames: ['google.*'],\n\t\twidth: 720,\n\t\theight: 500,\n\t\tdoesResize: true,\n\t\toverridePermissions: {\n\t\t\t'allow-presentation': true,\n\t\t},\n\t\ttoEmbedUrl: (url) => {\n\t\t\tif (url.includes('/maps/embed?')) {\n\t\t\t\treturn url\n\t\t\t} else if (url.includes('/maps/')) {\n\t\t\t\tconst match = url.match(/@(.*?),(.*?),(.*?)(z|m)/)\n\t\t\t\tlet result: string\n\t\t\t\tif (match) {\n\t\t\t\t\tconst [, lat, lng, zoomOrMeters, mapTypeSymbol] = match\n\t\t\t\t\tconst mapType = mapTypeSymbol === 'z' ? 'roadmap' : 'satellite'\n\t\t\t\t\t// Note: This meters to zoom equation is a rough approximation and not canonical.\n\t\t\t\t\tconst z =\n\t\t\t\t\t\tmapType === 'roadmap'\n\t\t\t\t\t\t\t? zoomOrMeters\n\t\t\t\t\t\t\t: -Math.log2(parseInt(zoomOrMeters) / 14772321) / 0.8\n\t\t\t\t\tconst host = new URL(url).host.replace('www.', '')\n\t\t\t\t\tresult = `https://${host}/maps/embed/v1/view?key=${process.env.NEXT_PUBLIC_GC_API_KEY}¢er=${lat},${lng}&zoom=${z}&maptype=${mapType}`\n\t\t\t\t} else {\n\t\t\t\t\tresult = ''\n\t\t\t\t}\n\n\t\t\t\treturn result\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (!urlObj) return\n\n\t\t\tconst matches = urlObj.pathname.match(/^\\/maps\\/embed\\/v1\\/view\\/?$/)\n\t\t\tif (matches && urlObj.searchParams.has('center') && urlObj.searchParams.get('zoom')) {\n\t\t\t\tconst zoom = urlObj.searchParams.get('zoom') ?? '12'\n\t\t\t\tconst mapType = urlObj.searchParams.get('maptype') ?? 'roadmap'\n\t\t\t\t// Note: This zoom to meters equation is a rough approximation and not canonical.\n\t\t\t\tconst zoomOrMeters =\n\t\t\t\t\tmapType === 'roadmap' ? zoom : 14772321 * Math.pow(2, parseInt(zoom) * -0.8)\n\t\t\t\tconst [lat, lon] = urlObj.searchParams.get('center')!.split(',')\n\t\t\t\treturn `https://www.google.com/maps/@${lat},${lon},${zoomOrMeters}${mapType === 'roadmap' ? 'z' : 'm'}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tembedOnPaste: true,\n\t},\n\t{\n\t\ttype: 'val_town',\n\t\ttitle: 'Val Town',\n\t\thostnames: ['val.town'],\n\t\tminWidth: 260,\n\t\tminHeight: 100,\n\t\twidth: 720,\n\t\theight: 500,\n\t\tdoesResize: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\t// e.g. extract \"steveruizok/mathFact\" from https://www.val.town/v/steveruizok/mathFact\n\t\t\tconst matches = urlObj && urlObj.pathname.match(/\\/v\\/(.+)\\/?/)\n\t\t\tif (matches) {\n\t\t\t\treturn `https://www.val.town/embed/${matches[1]}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\t// e.g. extract \"steveruizok/mathFact\" from https://www.val.town/v/steveruizok/mathFact\n\t\t\tconst matches = urlObj && urlObj.pathname.match(/\\/embed\\/(.+)\\/?/)\n\t\t\tif (matches) {\n\t\t\t\treturn `https://www.val.town/v/${matches[1]}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tembedOnPaste: true,\n\t},\n\t{\n\t\ttype: 'codesandbox',\n\t\ttitle: 'CodeSandbox',\n\t\thostnames: ['codesandbox.io'],\n\t\tminWidth: 300,\n\t\tminHeight: 300,\n\t\twidth: 720,\n\t\theight: 500,\n\t\tdoesResize: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tconst matches = urlObj && urlObj.pathname.match(/\\/s\\/([^/]+)\\/?/)\n\t\t\tif (matches) {\n\t\t\t\treturn `https://codesandbox.io/embed/${matches[1]}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tconst matches = urlObj && urlObj.pathname.match(/\\/embed\\/([^/]+)\\/?/)\n\t\t\tif (matches) {\n\t\t\t\treturn `https://codesandbox.io/s/${matches[1]}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tembedOnPaste: true,\n\t},\n\t{\n\t\ttype: 'codepen',\n\t\ttitle: 'Codepen',\n\t\thostnames: ['codepen.io'],\n\t\tminWidth: 300,\n\t\tminHeight: 300,\n\t\twidth: 520,\n\t\theight: 400,\n\t\tdoesResize: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst CODEPEN_URL_REGEXP = /https:\\/\\/codepen.io\\/([^/]+)\\/pen\\/([^/]+)/\n\t\t\tconst matches = url.match(CODEPEN_URL_REGEXP)\n\t\t\tif (matches) {\n\t\t\t\tconst [_, user, id] = matches\n\t\t\t\treturn `https://codepen.io/${user}/embed/${id}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst CODEPEN_EMBED_REGEXP = /https:\\/\\/codepen.io\\/([^/]+)\\/embed\\/([^/]+)/\n\t\t\tconst matches = url.match(CODEPEN_EMBED_REGEXP)\n\t\t\tif (matches) {\n\t\t\t\tconst [_, user, id] = matches\n\t\t\t\treturn `https://codepen.io/${user}/pen/${id}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tembedOnPaste: true,\n\t},\n\t{\n\t\ttype: 'scratch',\n\t\ttitle: 'Scratch',\n\t\thostnames: ['scratch.mit.edu'],\n\t\twidth: 520,\n\t\theight: 400,\n\t\tdoesResize: false,\n\t\tembedOnPaste: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst SCRATCH_URL_REGEXP = /https?:\\/\\/scratch.mit.edu\\/projects\\/([^/]+)/\n\t\t\tconst matches = url.match(SCRATCH_URL_REGEXP)\n\t\t\tif (matches) {\n\t\t\t\tconst [_, id] = matches\n\t\t\t\treturn `https://scratch.mit.edu/projects/embed/${id}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst SCRATCH_EMBED_REGEXP = /https:\\/\\/scratch.mit.edu\\/projects\\/embed\\/([^/]+)/\n\t\t\tconst matches = url.match(SCRATCH_EMBED_REGEXP)\n\t\t\tif (matches) {\n\t\t\t\tconst [_, id] = matches\n\t\t\t\treturn `https://scratch.mit.edu/projects/${id}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\ttype: 'youtube',\n\t\ttitle: 'YouTube',\n\t\thostnames: ['*.youtube.com', 'youtube.com', 'youtu.be'],\n\t\twidth: 800,\n\t\theight: 450,\n\t\tdoesResize: true,\n\t\toverridePermissions: {\n\t\t\t'allow-presentation': true,\n\t\t\t'allow-popups-to-escape-sandbox': true,\n\t\t},\n\t\tisAspectRatioLocked: true,\n\t\tembedOnPaste: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (!urlObj) return\n\n\t\t\tconst hostname = urlObj.hostname.replace(/^www./, '')\n\t\t\tif (hostname === 'youtu.be') {\n\t\t\t\tconst videoId = urlObj.pathname.split('/').filter(Boolean)[0]\n\t\t\t\tconst searchParams = new URLSearchParams(urlObj.search)\n\t\t\t\tconst timeStart = searchParams.get('t')\n\t\t\t\tif (timeStart) {\n\t\t\t\t\tsearchParams.set('start', timeStart)\n\t\t\t\t\tsearchParams.delete('t')\n\t\t\t\t}\n\t\t\t\tconst search = searchParams.toString() ? '?' + searchParams.toString() : ''\n\t\t\t\treturn `https://www.youtube.com/embed/${videoId}${search}`\n\t\t\t} else if (\n\t\t\t\t(hostname === 'youtube.com' || hostname === 'm.youtube.com') &&\n\t\t\t\turlObj.pathname.match(/^\\/watch/)\n\t\t\t) {\n\t\t\t\tconst videoId = urlObj.searchParams.get('v')\n\t\t\t\tconst searchParams = new URLSearchParams(urlObj.search)\n\t\t\t\tsearchParams.delete('v')\n\t\t\t\tconst timeStart = searchParams.get('t')\n\t\t\t\tif (timeStart) {\n\t\t\t\t\tsearchParams.set('start', timeStart)\n\t\t\t\t\tsearchParams.delete('t')\n\t\t\t\t}\n\t\t\t\tconst search = searchParams.toString() ? '?' + searchParams.toString() : ''\n\t\t\t\treturn `https://www.youtube.com/embed/${videoId}${search}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (!urlObj) return\n\n\t\t\tconst hostname = urlObj.hostname.replace(/^www./, '')\n\t\t\tif (hostname === 'youtube.com') {\n\t\t\t\tconst matches = urlObj.pathname.match(/^\\/embed\\/([^/]+)\\/?/)\n\t\t\t\tif (matches) {\n\t\t\t\t\tconst params = new URLSearchParams(urlObj.search)\n\t\t\t\t\tparams.set('v', matches?.[1] ?? '')\n\t\t\t\t\tconst timeStart = params.get('start')\n\t\t\t\t\tif (timeStart) {\n\t\t\t\t\t\tparams.set('t', timeStart)\n\t\t\t\t\t\tparams.delete('start')\n\t\t\t\t\t}\n\t\t\t\t\treturn `https://www.youtube.com/watch?${params.toString()}`\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\ttype: 'google_calendar',\n\t\ttitle: 'Google Calendar',\n\t\thostnames: ['calendar.google.*'],\n\t\twidth: 720,\n\t\theight: 500,\n\t\tminWidth: 460,\n\t\tminHeight: 360,\n\t\tdoesResize: true,\n\t\tinstructionLink: 'https://support.google.com/calendar/answer/41207?hl=en',\n\t\toverridePermissions: {\n\t\t\t'allow-popups-to-escape-sandbox': true,\n\t\t},\n\t\tembedOnPaste: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tconst cidQs = urlObj?.searchParams.get('cid')\n\n\t\t\tif (urlObj?.pathname.match(/\\/calendar\\/u\\/0/) && cidQs) {\n\t\t\t\turlObj.pathname = '/calendar/embed'\n\n\t\t\t\tconst keys = Array.from(urlObj.searchParams.keys())\n\t\t\t\tfor (const key of keys) {\n\t\t\t\t\turlObj.searchParams.delete(key)\n\t\t\t\t}\n\t\t\t\turlObj.searchParams.set('src', cidQs)\n\t\t\t\treturn urlObj.href\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tconst srcQs = urlObj?.searchParams.get('src')\n\n\t\t\tif (urlObj?.pathname.match(/\\/calendar\\/embed/) && srcQs) {\n\t\t\t\turlObj.pathname = '/calendar/u/0'\n\t\t\t\tconst keys = Array.from(urlObj.searchParams.keys())\n\t\t\t\tfor (const key of keys) {\n\t\t\t\t\turlObj.searchParams.delete(key)\n\t\t\t\t}\n\t\t\t\turlObj.searchParams.set('cid', srcQs)\n\t\t\t\treturn urlObj.href\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\ttype: 'google_slides',\n\t\ttitle: 'Google Slides',\n\t\thostnames: ['docs.google.*'],\n\t\twidth: 720,\n\t\theight: 500,\n\t\tminWidth: 460,\n\t\tminHeight: 360,\n\t\tdoesResize: true,\n\t\toverridePermissions: {\n\t\t\t'allow-popups-to-escape-sandbox': true,\n\t\t},\n\t\tembedOnPaste: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\n\t\t\tif (urlObj?.pathname.match(/^\\/presentation/) && urlObj?.pathname.match(/\\/pub\\/?$/)) {\n\t\t\t\turlObj.pathname = urlObj.pathname.replace(/\\/pub$/, '/embed')\n\t\t\t\tconst keys = Array.from(urlObj.searchParams.keys())\n\t\t\t\tfor (const key of keys) {\n\t\t\t\t\turlObj.searchParams.delete(key)\n\t\t\t\t}\n\t\t\t\treturn urlObj.href\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\n\t\t\tif (urlObj?.pathname.match(/^\\/presentation/) && urlObj?.pathname.match(/\\/embed\\/?$/)) {\n\t\t\t\turlObj.pathname = urlObj.pathname.replace(/\\/embed$/, '/pub')\n\t\t\t\tconst keys = Array.from(urlObj.searchParams.keys())\n\t\t\t\tfor (const key of keys) {\n\t\t\t\t\turlObj.searchParams.delete(key)\n\t\t\t\t}\n\t\t\t\treturn urlObj.href\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\ttype: 'github_gist',\n\t\ttitle: 'GitHub Gist',\n\t\thostnames: ['gist.github.com'],\n\t\twidth: 720,\n\t\theight: 500,\n\t\tdoesResize: true,\n\t\tembedOnPaste: true,\n\t\t// Security warning:\n\t\t// Gists allow adding .json extensions to the URL which return JSONP.\n\t\t// Furthermore, the JSONP can include callbacks that execute arbitrary JavaScript.\n\t\t// It _is_ sandboxed by the iframe but we still want to disable it nonetheless.\n\t\t// We restrict the id to only allow hexdecimal characters to prevent this.\n\t\t// Read more:\n\t\t// https://github.com/bhaveshk90/Content-Security-Policy-CSP-Bypass-Techniques\n\t\t// https://github.com/renniepak/CSPBypass\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(/\\/([^/]+)\\/([0-9a-f]+)$/)) {\n\t\t\t\tif (!url.split('/').pop()) return\n\t\t\t\treturn url\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(/\\/([^/]+)\\/([0-9a-f]+)$/)) {\n\t\t\t\tif (!url.split('/').pop()) return\n\t\t\t\treturn url\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\ttype: 'replit',\n\t\ttitle: 'Replit',\n\t\thostnames: ['replit.com'],\n\t\twidth: 720,\n\t\theight: 500,\n\t\tdoesResize: true,\n\t\tembedOnPaste: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(/\\/@([^/]+)\\/([^/]+)/)) {\n\t\t\t\turlObj.searchParams.append('embed', 'true')\n\t\t\t\treturn urlObj.href\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (\n\t\t\t\turlObj &&\n\t\t\t\turlObj.pathname.match(/\\/@([^/]+)\\/([^/]+)/) &&\n\t\t\t\turlObj.searchParams.has('embed')\n\t\t\t) {\n\t\t\t\turlObj.searchParams.delete('embed')\n\t\t\t\treturn urlObj.href\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\ttype: 'felt',\n\t\ttitle: 'Felt',\n\t\thostnames: ['felt.com'],\n\t\twidth: 720,\n\t\theight: 500,\n\t\tdoesResize: true,\n\t\tembedOnPaste: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(/^\\/map\\//)) {\n\t\t\t\treturn urlObj.origin + '/embed' + urlObj.pathname\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(/^\\/embed\\/map\\//)) {\n\t\t\t\turlObj.pathname = urlObj.pathname.replace(/^\\/embed/, '')\n\t\t\t\treturn urlObj.href\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\ttype: 'spotify',\n\t\ttitle: 'Spotify',\n\t\thostnames: ['open.spotify.com'],\n\t\twidth: 720,\n\t\theight: 500,\n\t\tminHeight: 500,\n\t\toverrideOutlineRadius: 12,\n\t\tdoesResize: true,\n\t\tembedOnPaste: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(/^\\/(artist|album)\\//)) {\n\t\t\t\treturn urlObj.origin + '/embed' + urlObj.pathname\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(/^\\/embed\\/(artist|album)\\//)) {\n\t\t\t\treturn urlObj.origin + urlObj.pathname.replace(/^\\/embed/, '')\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\ttype: 'vimeo',\n\t\ttitle: 'Vimeo',\n\t\thostnames: ['vimeo.com', 'player.vimeo.com'],\n\t\twidth: 640,\n\t\theight: 360,\n\t\tdoesResize: true,\n\t\tisAspectRatioLocked: true,\n\t\tembedOnPaste: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.hostname === 'vimeo.com') {\n\t\t\t\tif (urlObj.pathname.match(/^\\/[0-9]+/)) {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t'https://player.vimeo.com/video/' + urlObj.pathname.split('/')[1] + '?title=0&byline=0'\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.hostname === 'player.vimeo.com') {\n\t\t\t\tconst matches = urlObj.pathname.match(/^\\/video\\/([^/]+)\\/?$/)\n\t\t\t\tif (matches) {\n\t\t\t\t\treturn 'https://vimeo.com/' + matches[1]\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\ttype: 'observable',\n\t\ttitle: 'Observable',\n\t\thostnames: ['observablehq.com'],\n\t\twidth: 720,\n\t\theight: 500,\n\t\tdoesResize: true,\n\t\tisAspectRatioLocked: false,\n\t\tbackgroundColor: '#fff',\n\t\tembedOnPaste: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(/^\\/@([^/]+)\\/([^/]+)\\/?$/)) {\n\t\t\t\treturn `${urlObj.origin}/embed${urlObj.pathname}?cell=*`\n\t\t\t}\n\t\t\tif (urlObj && urlObj.pathname.match(/^\\/d\\/([^/]+)\\/?$/)) {\n\t\t\t\tconst pathName = urlObj.pathname.replace(/^\\/d/, '')\n\t\t\t\treturn `${urlObj.origin}/embed${pathName}?cell=*`\n\t\t\t}\n\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(/^\\/embed\\/@([^/]+)\\/([^/]+)\\/?$/)) {\n\t\t\t\treturn `${urlObj.origin}${urlObj.pathname.replace('/embed', '')}#cell-*`\n\t\t\t}\n\t\t\tif (urlObj && urlObj.pathname.match(/^\\/embed\\/([^/]+)\\/?$/)) {\n\t\t\t\treturn `${urlObj.origin}${urlObj.pathname.replace('/embed', '/d')}#cell-*`\n\t\t\t}\n\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\ttype: 'desmos',\n\t\ttitle: 'Desmos',\n\t\thostnames: ['desmos.com'],\n\t\twidth: 700,\n\t\theight: 450,\n\t\tdoesResize: true,\n\t\tembedOnPaste: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (\n\t\t\t\turlObj &&\n\t\t\t\turlObj.hostname === 'www.desmos.com' &&\n\t\t\t\turlObj.pathname.match(/^\\/calculator\\/([^/]+)\\/?$/) &&\n\t\t\t\turlObj.search === '' &&\n\t\t\t\turlObj.hash === ''\n\t\t\t) {\n\t\t\t\treturn `${url}?embed`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (\n\t\t\t\turlObj &&\n\t\t\t\turlObj.hostname === 'www.desmos.com' &&\n\t\t\t\turlObj.pathname.match(/^\\/calculator\\/([^/]+)\\/?$/) &&\n\t\t\t\turlObj.search === '?embed' &&\n\t\t\t\turlObj.hash === ''\n\t\t\t) {\n\t\t\t\treturn url.replace('?embed', '')\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n] as const satisfies readonly EmbedDefinition[]\n\n/**\n * Permissions with note inline from\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#attr-sandbox\n *\n * @public\n */\nexport const embedShapePermissionDefaults = {\n\t// ========================================================================================\n\t// Disabled permissions\n\t// ========================================================================================\n\t// [MDN] Experimental: Allows for downloads to occur without a gesture from the user.\n\t// [REASON] Disabled because otherwise the <iframe/> can trick the user on behalf of us to perform an action.\n\t'allow-downloads-without-user-activation': false,\n\t// [MDN] Allows for downloads to occur with a gesture from the user.\n\t// [REASON] Disabled because otherwise the <iframe/> can trick the user on behalf of us to perform an action.\n\t'allow-downloads': false,\n\t// [MDN] Lets the resource open modal windows.\n\t// [REASON] The <iframe/> could 'window.prompt(\"Enter your tldraw password\")'.\n\t'allow-modals': false,\n\t// [MDN] Lets the resource lock the screen orientation.\n\t// [REASON] Would interfere with the tldraw interface.\n\t'allow-orientation-lock': false,\n\t// [MDN] Lets the resource use the Pointer Lock API.\n\t// [REASON] Maybe we should allow this for games embeds (scratch/codepen/codesandbox).\n\t'allow-pointer-lock': false,\n\t// [MDN] Allows popups (such as window.open(), target=\"_blank\", or showModalDialog()). If this keyword is not used, the popup will silently fail to open.\n\t// [REASON] We want to allow embeds to link back to their original sites (e.g. YouTube).\n\t'allow-popups': true,\n\t// [MDN] Lets the sandboxed document open new windows without those windows inheriting the sandboxing. For example, this can safely sandbox an advertisement without forcing the same restrictions upon the page the ad links to.\n\t// [REASON] We shouldn't allow popups as a embed could pretend to be us by opening a mocked version of tldraw. This is very unobvious when it is performed as an action within our app.\n\t'allow-popups-to-escape-sandbox': false,\n\t// [MDN] Lets the resource start a presentation session.\n\t// [REASON] Prevents embed from navigating away from tldraw and pretending to be us.\n\t'allow-presentation': false,\n\t// [MDN] Experimental: Lets the resource request access to the parent's storage capabilities with the Storage Access API.\n\t// [REASON] We don't want anyone else to access our storage.\n\t'allow-storage-access-by-user-activation': false,\n\t// [MDN] Lets the resource navigate the top-level browsing context (the one named _top).\n\t// [REASON] Prevents embed from navigating away from tldraw and pretending to be us.\n\t'allow-top-navigation': false,\n\t// [MDN] Lets the resource navigate the top-level browsing context, but only if initiated by a user gesture.\n\t// [REASON] Prevents embed from navigating away from tldraw and pretending to be us.\n\t'allow-top-navigation-by-user-activation': false,\n\t// ========================================================================================\n\t// Enabled permissions\n\t// ========================================================================================\n\t// [MDN] Lets the resource run scripts (but not create popup windows).\n\t'allow-scripts': true,\n\t// [MDN] If this token is not used, the resource is treated as being from a special origin that always fails the same-origin policy (potentially preventing access to data storage/cookies and some JavaScript APIs).\n\t'allow-same-origin': true,\n\t// [MDN] Allows the resource to submit forms. If this keyword is not used, form submission is blocked.\n\t'allow-forms': true,\n} as const\n\n/** @public */\nexport type TLEmbedShapePermissions = { [K in keyof typeof embedShapePermissionDefaults]?: boolean }\n\n/** @public */\nexport interface EmbedDefinition {\n\treadonly type: string\n\treadonly title: string\n\treadonly hostnames: readonly string[]\n\treadonly minWidth?: number\n\treadonly minHeight?: number\n\treadonly width: number\n\treadonly height: number\n\treadonly doesResize: boolean\n\treadonly isAspectRatioLocked?: boolean\n\treadonly overridePermissions?: TLEmbedShapePermissions\n\treadonly instructionLink?: string\n\treadonly backgroundColor?: string\n\treadonly embedOnPaste?: boolean\n\t// TODO: FIXME this is ugly be required because some embeds have their own border radius for example spotify embeds\n\treadonly overrideOutlineRadius?: number\n\t// eslint-disable-next-line @typescript-eslint/method-signature-style\n\treadonly toEmbedUrl: (url: string) => string | undefined\n\t// eslint-disable-next-line @typescript-eslint/method-signature-style\n\treadonly fromEmbedUrl: (url: string) => string | undefined\n}\n\n/** @public */\nexport interface CustomEmbedDefinition extends EmbedDefinition {\n\treadonly icon: string\n}\n\n/** @public */\nexport type TLEmbedDefinition = EmbedDefinition | CustomEmbedDefinition\n\n/** @public */\nexport type DefaultEmbedDefinitionType = (typeof DEFAULT_EMBED_DEFINITIONS)[number]['type']\n\nconst DEFAULT_EMBED_DEFINITION_TYPES = DEFAULT_EMBED_DEFINITIONS.map(\n\t(def) => def.type\n) as DefaultEmbedDefinitionType[]\n\n/** @public */\nexport function isDefaultEmbedDefinitionType(type: string): type is DefaultEmbedDefinitionType {\n\treturn DEFAULT_EMBED_DEFINITION_TYPES.includes(type as DefaultEmbedDefinitionType)\n}\n\n/** @public */\nexport function isCustomEmbedDefinition(\n\tdef: EmbedDefinition | CustomEmbedDefinition\n): def is CustomEmbedDefinition {\n\treturn 'icon' in def\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA6B;AAG7B,MAAM,gBAAgB;AAGf,MAAM,4BAA4B;AAAA,EACxC;AAAA,IACC,MAAM;AAAA,IACN,OAAO;AAAA,IACP,WAAW,CAAC,mBAA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AA,EAErB,eAAe;AAChB;AAuCA,MAAM,iCAAiC,0BAA0B;AAAA,EAChE,CAAC,QAAQ,IAAI;AACd;AAGO,SAAS,6BAA6B,MAAkD;AAC9F,SAAO,+BAA+B,SAAS,IAAkC;AAClF;AAGO,SAAS,wBACf,KAC+B;AAC/B,SAAO,UAAU;AAClB;",
|
|
4
|
+
"sourcesContent": ["import { safeParseUrl } from '@tldraw/editor'\n\n// Only allow multiplayer embeds. If we add additional routes later for example '/help' this won't match\nconst TLDRAW_APP_RE = /(^\\/[f|p|r|ro|s|v]\\/[^/]+\\/?$)/\n\n/** @public */\nexport const DEFAULT_EMBED_DEFINITIONS = [\n\t{\n\t\ttype: 'tldraw',\n\t\ttitle: 'tldraw',\n\t\thostnames: ['beta.tldraw.com', 'tldraw.com', 'localhost:3000'],\n\t\tminWidth: 300,\n\t\tminHeight: 300,\n\t\twidth: 720,\n\t\theight: 500,\n\t\tdoesResize: true,\n\t\toverridePermissions: {\n\t\t\t'allow-top-navigation': true,\n\t\t},\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(TLDRAW_APP_RE)) {\n\t\t\t\t// Add the \"clean=true\" search param to the URL to hide the sidebar\n\t\t\t\turlObj.searchParams.append('embed', 'true')\n\t\t\t\treturn url\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(TLDRAW_APP_RE)) {\n\t\t\t\t// Add the \"clean=true\" search param to the URL to hide the sidebar\n\t\t\t\turlObj.searchParams.delete('embed')\n\t\t\t\treturn url\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tembedOnPaste: false,\n\t},\n\t{\n\t\ttype: 'figma',\n\t\ttitle: 'Figma',\n\t\thostnames: ['figma.com'],\n\t\twidth: 720,\n\t\theight: 500,\n\t\tdoesResize: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tif (\n\t\t\t\t!!url.match(\n\t\t\t\t\t// eslint-disable-next-line no-useless-escape\n\t\t\t\t\t/https:\\/\\/([\\w\\.-]+\\.)?figma.com\\/(file|proto|design)\\/([0-9a-zA-Z]{22,128})(?:\\/.*)?$/\n\t\t\t\t) &&\n\t\t\t\t!url.includes('figma.com/embed')\n\t\t\t) {\n\t\t\t\treturn `https://www.figma.com/embed?embed_host=share&url=${url}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(/^\\/embed\\/?$/)) {\n\t\t\t\tconst outUrl = urlObj.searchParams.get('url')\n\t\t\t\tif (outUrl) {\n\t\t\t\t\treturn outUrl\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tembedOnPaste: true,\n\t},\n\t{\n\t\ttype: 'google_maps',\n\t\ttitle: 'Google Maps',\n\t\thostnames: ['google.*'],\n\t\twidth: 720,\n\t\theight: 500,\n\t\tdoesResize: true,\n\t\toverridePermissions: {\n\t\t\t'allow-presentation': true,\n\t\t},\n\t\ttoEmbedUrl: (url) => {\n\t\t\tif (url.includes('/maps/embed?')) {\n\t\t\t\treturn url\n\t\t\t} else if (url.includes('/maps/')) {\n\t\t\t\tconst match = url.match(/@(.*?),(.*?),(.*?)(z|m)/)\n\t\t\t\tlet result: string\n\t\t\t\tif (match) {\n\t\t\t\t\tconst [, lat, lng, zoomOrMeters, mapTypeSymbol] = match\n\t\t\t\t\tconst mapType = mapTypeSymbol === 'z' ? 'roadmap' : 'satellite'\n\t\t\t\t\t// Note: This meters to zoom equation is a rough approximation and not canonical.\n\t\t\t\t\tconst z =\n\t\t\t\t\t\tmapType === 'roadmap'\n\t\t\t\t\t\t\t? zoomOrMeters\n\t\t\t\t\t\t\t: -Math.log2(parseInt(zoomOrMeters) / 14772321) / 0.8\n\t\t\t\t\tconst host = new URL(url).host.replace('www.', '')\n\t\t\t\t\tresult = `https://${host}/maps/embed/v1/view?key=${process.env.NEXT_PUBLIC_GC_API_KEY}¢er=${lat},${lng}&zoom=${z}&maptype=${mapType}`\n\t\t\t\t} else {\n\t\t\t\t\tresult = ''\n\t\t\t\t}\n\n\t\t\t\treturn result\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (!urlObj) return\n\n\t\t\tconst matches = urlObj.pathname.match(/^\\/maps\\/embed\\/v1\\/view\\/?$/)\n\t\t\tif (matches && urlObj.searchParams.has('center') && urlObj.searchParams.get('zoom')) {\n\t\t\t\tconst zoom = urlObj.searchParams.get('zoom') ?? '12'\n\t\t\t\tconst mapType = urlObj.searchParams.get('maptype') ?? 'roadmap'\n\t\t\t\t// Note: This zoom to meters equation is a rough approximation and not canonical.\n\t\t\t\tconst zoomOrMeters =\n\t\t\t\t\tmapType === 'roadmap' ? zoom : 14772321 * Math.pow(2, parseInt(zoom) * -0.8)\n\t\t\t\tconst [lat, lon] = urlObj.searchParams.get('center')!.split(',')\n\t\t\t\treturn `https://www.google.com/maps/@${lat},${lon},${zoomOrMeters}${mapType === 'roadmap' ? 'z' : 'm'}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tembedOnPaste: true,\n\t},\n\t{\n\t\ttype: 'val_town',\n\t\ttitle: 'Val Town',\n\t\thostnames: ['val.town'],\n\t\tminWidth: 260,\n\t\tminHeight: 100,\n\t\twidth: 720,\n\t\theight: 500,\n\t\tdoesResize: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\t// e.g. extract \"steveruizok/mathFact\" from https://www.val.town/v/steveruizok/mathFact\n\t\t\tconst matches = urlObj && urlObj.pathname.match(/\\/v\\/(.+)\\/?/)\n\t\t\tif (matches) {\n\t\t\t\treturn `https://www.val.town/embed/${matches[1]}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\t// e.g. extract \"steveruizok/mathFact\" from https://www.val.town/v/steveruizok/mathFact\n\t\t\tconst matches = urlObj && urlObj.pathname.match(/\\/embed\\/(.+)\\/?/)\n\t\t\tif (matches) {\n\t\t\t\treturn `https://www.val.town/v/${matches[1]}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tembedOnPaste: true,\n\t},\n\t{\n\t\ttype: 'codesandbox',\n\t\ttitle: 'CodeSandbox',\n\t\thostnames: ['codesandbox.io'],\n\t\tminWidth: 300,\n\t\tminHeight: 300,\n\t\twidth: 720,\n\t\theight: 500,\n\t\tdoesResize: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tconst matches = urlObj && urlObj.pathname.match(/\\/s\\/([^/]+)\\/?/)\n\t\t\tif (matches) {\n\t\t\t\treturn `https://codesandbox.io/embed/${matches[1]}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tconst matches = urlObj && urlObj.pathname.match(/\\/embed\\/([^/]+)\\/?/)\n\t\t\tif (matches) {\n\t\t\t\treturn `https://codesandbox.io/s/${matches[1]}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tembedOnPaste: true,\n\t},\n\t{\n\t\ttype: 'codepen',\n\t\ttitle: 'Codepen',\n\t\thostnames: ['codepen.io'],\n\t\tminWidth: 300,\n\t\tminHeight: 300,\n\t\twidth: 520,\n\t\theight: 400,\n\t\tdoesResize: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst CODEPEN_URL_REGEXP = /https:\\/\\/codepen.io\\/([^/]+)\\/pen\\/([^/]+)/\n\t\t\tconst matches = url.match(CODEPEN_URL_REGEXP)\n\t\t\tif (matches) {\n\t\t\t\tconst [_, user, id] = matches\n\t\t\t\treturn `https://codepen.io/${user}/embed/${id}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst CODEPEN_EMBED_REGEXP = /https:\\/\\/codepen.io\\/([^/]+)\\/embed\\/([^/]+)/\n\t\t\tconst matches = url.match(CODEPEN_EMBED_REGEXP)\n\t\t\tif (matches) {\n\t\t\t\tconst [_, user, id] = matches\n\t\t\t\treturn `https://codepen.io/${user}/pen/${id}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tembedOnPaste: true,\n\t},\n\t{\n\t\ttype: 'scratch',\n\t\ttitle: 'Scratch',\n\t\thostnames: ['scratch.mit.edu'],\n\t\twidth: 520,\n\t\theight: 400,\n\t\tdoesResize: false,\n\t\tembedOnPaste: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst SCRATCH_URL_REGEXP = /https?:\\/\\/scratch.mit.edu\\/projects\\/([^/]+)/\n\t\t\tconst matches = url.match(SCRATCH_URL_REGEXP)\n\t\t\tif (matches) {\n\t\t\t\tconst [_, id] = matches\n\t\t\t\treturn `https://scratch.mit.edu/projects/embed/${id}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst SCRATCH_EMBED_REGEXP = /https:\\/\\/scratch.mit.edu\\/projects\\/embed\\/([^/]+)/\n\t\t\tconst matches = url.match(SCRATCH_EMBED_REGEXP)\n\t\t\tif (matches) {\n\t\t\t\tconst [_, id] = matches\n\t\t\t\treturn `https://scratch.mit.edu/projects/${id}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\ttype: 'youtube',\n\t\ttitle: 'YouTube',\n\t\thostnames: ['*.youtube.com', 'youtube.com', 'youtu.be'],\n\t\twidth: 800,\n\t\theight: 450,\n\t\tdoesResize: true,\n\t\toverridePermissions: {\n\t\t\t'allow-presentation': true,\n\t\t\t'allow-popups-to-escape-sandbox': true,\n\t\t},\n\t\tisAspectRatioLocked: true,\n\t\tembedOnPaste: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (!urlObj) return\n\n\t\t\tconst hostname = urlObj.hostname.replace(/^www./, '')\n\t\t\tif (hostname === 'youtu.be') {\n\t\t\t\tconst videoId = urlObj.pathname.split('/').filter(Boolean)[0]\n\t\t\t\tconst searchParams = new URLSearchParams(urlObj.search)\n\t\t\t\tconst timeStart = searchParams.get('t')\n\t\t\t\tif (timeStart) {\n\t\t\t\t\tsearchParams.set('start', timeStart)\n\t\t\t\t\tsearchParams.delete('t')\n\t\t\t\t}\n\t\t\t\tconst search = searchParams.toString() ? '?' + searchParams.toString() : ''\n\t\t\t\treturn `https://www.youtube.com/embed/${videoId}${search}`\n\t\t\t} else if (\n\t\t\t\t(hostname === 'youtube.com' || hostname === 'm.youtube.com') &&\n\t\t\t\turlObj.pathname.match(/^\\/watch/)\n\t\t\t) {\n\t\t\t\tconst videoId = urlObj.searchParams.get('v')\n\t\t\t\tconst searchParams = new URLSearchParams(urlObj.search)\n\t\t\t\tsearchParams.delete('v')\n\t\t\t\tconst timeStart = searchParams.get('t')\n\t\t\t\tif (timeStart) {\n\t\t\t\t\tsearchParams.set('start', timeStart)\n\t\t\t\t\tsearchParams.delete('t')\n\t\t\t\t}\n\t\t\t\tconst search = searchParams.toString() ? '?' + searchParams.toString() : ''\n\t\t\t\treturn `https://www.youtube.com/embed/${videoId}${search}`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (!urlObj) return\n\n\t\t\tconst hostname = urlObj.hostname.replace(/^www./, '')\n\t\t\tif (hostname === 'youtube.com') {\n\t\t\t\tconst matches = urlObj.pathname.match(/^\\/embed\\/([^/]+)\\/?/)\n\t\t\t\tif (matches) {\n\t\t\t\t\tconst params = new URLSearchParams(urlObj.search)\n\t\t\t\t\tparams.set('v', matches?.[1] ?? '')\n\t\t\t\t\tconst timeStart = params.get('start')\n\t\t\t\t\tif (timeStart) {\n\t\t\t\t\t\tparams.set('t', timeStart)\n\t\t\t\t\t\tparams.delete('start')\n\t\t\t\t\t}\n\t\t\t\t\treturn `https://www.youtube.com/watch?${params.toString()}`\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\ttype: 'google_calendar',\n\t\ttitle: 'Google Calendar',\n\t\thostnames: ['calendar.google.*'],\n\t\twidth: 720,\n\t\theight: 500,\n\t\tminWidth: 460,\n\t\tminHeight: 360,\n\t\tdoesResize: true,\n\t\tinstructionLink: 'https://support.google.com/calendar/answer/41207?hl=en',\n\t\toverridePermissions: {\n\t\t\t'allow-popups-to-escape-sandbox': true,\n\t\t},\n\t\tembedOnPaste: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tconst cidQs = urlObj?.searchParams.get('cid')\n\n\t\t\tif (urlObj?.pathname.match(/\\/calendar\\/u\\/0/) && cidQs) {\n\t\t\t\turlObj.pathname = '/calendar/embed'\n\n\t\t\t\tconst keys = Array.from(urlObj.searchParams.keys())\n\t\t\t\tfor (const key of keys) {\n\t\t\t\t\turlObj.searchParams.delete(key)\n\t\t\t\t}\n\t\t\t\turlObj.searchParams.set('src', cidQs)\n\t\t\t\treturn urlObj.href\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tconst srcQs = urlObj?.searchParams.get('src')\n\n\t\t\tif (urlObj?.pathname.match(/\\/calendar\\/embed/) && srcQs) {\n\t\t\t\turlObj.pathname = '/calendar/u/0'\n\t\t\t\tconst keys = Array.from(urlObj.searchParams.keys())\n\t\t\t\tfor (const key of keys) {\n\t\t\t\t\turlObj.searchParams.delete(key)\n\t\t\t\t}\n\t\t\t\turlObj.searchParams.set('cid', srcQs)\n\t\t\t\treturn urlObj.href\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\ttype: 'google_slides',\n\t\ttitle: 'Google Slides',\n\t\thostnames: ['docs.google.*'],\n\t\twidth: 720,\n\t\theight: 500,\n\t\tminWidth: 460,\n\t\tminHeight: 360,\n\t\tdoesResize: true,\n\t\toverridePermissions: {\n\t\t\t'allow-popups-to-escape-sandbox': true,\n\t\t},\n\t\tembedOnPaste: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\n\t\t\tif (urlObj?.pathname.match(/^\\/presentation/) && urlObj?.pathname.match(/\\/pub\\/?$/)) {\n\t\t\t\turlObj.pathname = urlObj.pathname.replace(/\\/pub$/, '/embed')\n\t\t\t\tconst keys = Array.from(urlObj.searchParams.keys())\n\t\t\t\tfor (const key of keys) {\n\t\t\t\t\turlObj.searchParams.delete(key)\n\t\t\t\t}\n\t\t\t\treturn urlObj.href\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\n\t\t\tif (urlObj?.pathname.match(/^\\/presentation/) && urlObj?.pathname.match(/\\/embed\\/?$/)) {\n\t\t\t\turlObj.pathname = urlObj.pathname.replace(/\\/embed$/, '/pub')\n\t\t\t\tconst keys = Array.from(urlObj.searchParams.keys())\n\t\t\t\tfor (const key of keys) {\n\t\t\t\t\turlObj.searchParams.delete(key)\n\t\t\t\t}\n\t\t\t\treturn urlObj.href\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\ttype: 'github_gist',\n\t\ttitle: 'GitHub Gist',\n\t\thostnames: ['gist.github.com'],\n\t\twidth: 720,\n\t\theight: 500,\n\t\tdoesResize: true,\n\t\tembedOnPaste: true,\n\t\t// Security warning:\n\t\t// Gists allow adding .json extensions to the URL which return JSONP.\n\t\t// Furthermore, the JSONP can include callbacks that execute arbitrary JavaScript.\n\t\t// It _is_ sandboxed by the iframe but we still want to disable it nonetheless.\n\t\t// We restrict the id to only allow hexdecimal characters to prevent this.\n\t\t// Read more:\n\t\t// https://github.com/bhaveshk90/Content-Security-Policy-CSP-Bypass-Techniques\n\t\t// https://github.com/renniepak/CSPBypass\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(/\\/([^/]+)\\/([0-9a-f]+)$/)) {\n\t\t\t\tif (!url.split('/').pop()) return\n\t\t\t\treturn url\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(/\\/([^/]+)\\/([0-9a-f]+)$/)) {\n\t\t\t\tif (!url.split('/').pop()) return\n\t\t\t\treturn url\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\ttype: 'replit',\n\t\ttitle: 'Replit',\n\t\thostnames: ['replit.com'],\n\t\twidth: 720,\n\t\theight: 500,\n\t\tdoesResize: true,\n\t\tembedOnPaste: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(/\\/@([^/]+)\\/([^/]+)/)) {\n\t\t\t\turlObj.searchParams.append('embed', 'true')\n\t\t\t\treturn urlObj.href\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (\n\t\t\t\turlObj &&\n\t\t\t\turlObj.pathname.match(/\\/@([^/]+)\\/([^/]+)/) &&\n\t\t\t\turlObj.searchParams.has('embed')\n\t\t\t) {\n\t\t\t\turlObj.searchParams.delete('embed')\n\t\t\t\treturn urlObj.href\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\ttype: 'felt',\n\t\ttitle: 'Felt',\n\t\thostnames: ['felt.com'],\n\t\twidth: 720,\n\t\theight: 500,\n\t\tdoesResize: true,\n\t\tembedOnPaste: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(/^\\/map\\//)) {\n\t\t\t\treturn urlObj.origin + '/embed' + urlObj.pathname\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(/^\\/embed\\/map\\//)) {\n\t\t\t\turlObj.pathname = urlObj.pathname.replace(/^\\/embed/, '')\n\t\t\t\treturn urlObj.href\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\ttype: 'spotify',\n\t\ttitle: 'Spotify',\n\t\thostnames: ['open.spotify.com'],\n\t\twidth: 720,\n\t\theight: 500,\n\t\tminHeight: 500,\n\t\toverrideOutlineRadius: 12,\n\t\tdoesResize: true,\n\t\tembedOnPaste: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(/^\\/(artist|album)\\//)) {\n\t\t\t\treturn urlObj.origin + '/embed' + urlObj.pathname\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(/^\\/embed\\/(artist|album)\\//)) {\n\t\t\t\treturn urlObj.origin + urlObj.pathname.replace(/^\\/embed/, '')\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\ttype: 'vimeo',\n\t\ttitle: 'Vimeo',\n\t\thostnames: ['vimeo.com', 'player.vimeo.com'],\n\t\twidth: 640,\n\t\theight: 360,\n\t\tdoesResize: true,\n\t\tisAspectRatioLocked: true,\n\t\tembedOnPaste: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.hostname === 'vimeo.com') {\n\t\t\t\tif (urlObj.pathname.match(/^\\/[0-9]+/)) {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t'https://player.vimeo.com/video/' + urlObj.pathname.split('/')[1] + '?title=0&byline=0'\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.hostname === 'player.vimeo.com') {\n\t\t\t\tconst matches = urlObj.pathname.match(/^\\/video\\/([^/]+)\\/?$/)\n\t\t\t\tif (matches) {\n\t\t\t\t\treturn 'https://vimeo.com/' + matches[1]\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\ttype: 'observable',\n\t\ttitle: 'Observable',\n\t\thostnames: ['observablehq.com'],\n\t\twidth: 720,\n\t\theight: 500,\n\t\tdoesResize: true,\n\t\tisAspectRatioLocked: false,\n\t\tbackgroundColor: '#fff',\n\t\tembedOnPaste: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(/^\\/@([^/]+)\\/([^/]+)\\/?$/)) {\n\t\t\t\treturn `${urlObj.origin}/embed${urlObj.pathname}?cell=*`\n\t\t\t}\n\t\t\tif (urlObj && urlObj.pathname.match(/^\\/d\\/([^/]+)\\/?$/)) {\n\t\t\t\tconst pathName = urlObj.pathname.replace(/^\\/d/, '')\n\t\t\t\treturn `${urlObj.origin}/embed${pathName}?cell=*`\n\t\t\t}\n\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (urlObj && urlObj.pathname.match(/^\\/embed\\/@([^/]+)\\/([^/]+)\\/?$/)) {\n\t\t\t\treturn `${urlObj.origin}${urlObj.pathname.replace('/embed', '')}#cell-*`\n\t\t\t}\n\t\t\tif (urlObj && urlObj.pathname.match(/^\\/embed\\/([^/]+)\\/?$/)) {\n\t\t\t\treturn `${urlObj.origin}${urlObj.pathname.replace('/embed', '/d')}#cell-*`\n\t\t\t}\n\n\t\t\treturn\n\t\t},\n\t},\n\t{\n\t\ttype: 'desmos',\n\t\ttitle: 'Desmos',\n\t\thostnames: ['desmos.com'],\n\t\twidth: 700,\n\t\theight: 450,\n\t\tdoesResize: true,\n\t\tembedOnPaste: true,\n\t\ttoEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (\n\t\t\t\turlObj &&\n\t\t\t\turlObj.hostname === 'www.desmos.com' &&\n\t\t\t\turlObj.pathname.match(/^\\/calculator\\/([^/]+)\\/?$/) &&\n\t\t\t\turlObj.search === '' &&\n\t\t\t\turlObj.hash === ''\n\t\t\t) {\n\t\t\t\treturn `${url}?embed`\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\tfromEmbedUrl: (url) => {\n\t\t\tconst urlObj = safeParseUrl(url)\n\t\t\tif (\n\t\t\t\turlObj &&\n\t\t\t\turlObj.hostname === 'www.desmos.com' &&\n\t\t\t\turlObj.pathname.match(/^\\/calculator\\/([^/]+)\\/?$/) &&\n\t\t\t\turlObj.search === '?embed' &&\n\t\t\t\turlObj.hash === ''\n\t\t\t) {\n\t\t\t\treturn url.replace('?embed', '')\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t},\n] as const satisfies readonly EmbedDefinition[]\n\n/**\n * Permissions with note inline from\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#attr-sandbox\n *\n * @public\n */\nexport const embedShapePermissionDefaults = {\n\t// ========================================================================================\n\t// Disabled permissions\n\t// ========================================================================================\n\t// [MDN] Experimental: Allows for downloads to occur without a gesture from the user.\n\t// [REASON] Disabled because otherwise the <iframe/> can trick the user on behalf of us to perform an action.\n\t'allow-downloads-without-user-activation': false,\n\t// [MDN] Allows for downloads to occur with a gesture from the user.\n\t// [REASON] Disabled because otherwise the <iframe/> can trick the user on behalf of us to perform an action.\n\t'allow-downloads': false,\n\t// [MDN] Lets the resource open modal windows.\n\t// [REASON] The <iframe/> could 'window.prompt(\"Enter your tldraw password\")'.\n\t'allow-modals': false,\n\t// [MDN] Lets the resource lock the screen orientation.\n\t// [REASON] Would interfere with the tldraw interface.\n\t'allow-orientation-lock': false,\n\t// [MDN] Lets the resource use the Pointer Lock API.\n\t// [REASON] Maybe we should allow this for games embeds (scratch/codepen/codesandbox).\n\t'allow-pointer-lock': false,\n\t// [MDN] Allows popups (such as window.open(), target=\"_blank\", or showModalDialog()). If this keyword is not used, the popup will silently fail to open.\n\t// [REASON] We want to allow embeds to link back to their original sites (e.g. YouTube).\n\t'allow-popups': true,\n\t// [MDN] Lets the sandboxed document open new windows without those windows inheriting the sandboxing. For example, this can safely sandbox an advertisement without forcing the same restrictions upon the page the ad links to.\n\t// [REASON] We shouldn't allow popups as an embed could pretend to be us by opening a mocked version of tldraw. This is very unobvious when it is performed as an action within our app.\n\t'allow-popups-to-escape-sandbox': false,\n\t// [MDN] Lets the resource start a presentation session.\n\t// [REASON] Prevents embed from navigating away from tldraw and pretending to be us.\n\t'allow-presentation': false,\n\t// [MDN] Experimental: Lets the resource request access to the parent's storage capabilities with the Storage Access API.\n\t// [REASON] We don't want anyone else to access our storage.\n\t'allow-storage-access-by-user-activation': false,\n\t// [MDN] Lets the resource navigate the top-level browsing context (the one named _top).\n\t// [REASON] Prevents embed from navigating away from tldraw and pretending to be us.\n\t'allow-top-navigation': false,\n\t// [MDN] Lets the resource navigate the top-level browsing context, but only if initiated by a user gesture.\n\t// [REASON] Prevents embed from navigating away from tldraw and pretending to be us.\n\t'allow-top-navigation-by-user-activation': false,\n\t// ========================================================================================\n\t// Enabled permissions\n\t// ========================================================================================\n\t// [MDN] Lets the resource run scripts (but not create popup windows).\n\t'allow-scripts': true,\n\t// [MDN] If this token is not used, the resource is treated as being from a special origin that always fails the same-origin policy (potentially preventing access to data storage/cookies and some JavaScript APIs).\n\t'allow-same-origin': true,\n\t// [MDN] Allows the resource to submit forms. If this keyword is not used, form submission is blocked.\n\t'allow-forms': true,\n} as const\n\n/** @public */\nexport type TLEmbedShapePermissions = { [K in keyof typeof embedShapePermissionDefaults]?: boolean }\n\n/** @public */\nexport interface EmbedDefinition {\n\treadonly type: string\n\treadonly title: string\n\treadonly hostnames: readonly string[]\n\treadonly minWidth?: number\n\treadonly minHeight?: number\n\treadonly width: number\n\treadonly height: number\n\treadonly doesResize: boolean\n\treadonly isAspectRatioLocked?: boolean\n\treadonly overridePermissions?: TLEmbedShapePermissions\n\treadonly instructionLink?: string\n\treadonly backgroundColor?: string\n\treadonly embedOnPaste?: boolean\n\treadonly canEditWhileLocked?: boolean\n\t// TODO: FIXME this is ugly be required because some embeds have their own border radius for example spotify embeds\n\treadonly overrideOutlineRadius?: number\n\t// eslint-disable-next-line @typescript-eslint/method-signature-style\n\treadonly toEmbedUrl: (url: string) => string | undefined\n\t// eslint-disable-next-line @typescript-eslint/method-signature-style\n\treadonly fromEmbedUrl: (url: string) => string | undefined\n}\n\n/** @public */\nexport interface CustomEmbedDefinition extends EmbedDefinition {\n\treadonly icon: string\n}\n\n/** @public */\nexport type TLEmbedDefinition = EmbedDefinition | CustomEmbedDefinition\n\n/** @public */\nexport type DefaultEmbedDefinitionType = (typeof DEFAULT_EMBED_DEFINITIONS)[number]['type']\n\nconst DEFAULT_EMBED_DEFINITION_TYPES = DEFAULT_EMBED_DEFINITIONS.map(\n\t(def) => def.type\n) as DefaultEmbedDefinitionType[]\n\n/** @public */\nexport function isDefaultEmbedDefinitionType(type: string): type is DefaultEmbedDefinitionType {\n\treturn DEFAULT_EMBED_DEFINITION_TYPES.includes(type as DefaultEmbedDefinitionType)\n}\n\n/** @public */\nexport function isCustomEmbedDefinition(\n\tdef: EmbedDefinition | CustomEmbedDefinition\n): def is CustomEmbedDefinition {\n\treturn 'icon' in def\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,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wBAAwB;AAAA;AAAA;AAAA,EAGxB,2CAA2C;AAAA;AAAA;AAAA;AAAA;AAAA,EAK3C,iBAAiB;AAAA;AAAA,EAEjB,qBAAqB;AAAA;AAAA,EAErB,eAAe;AAChB;AAwCA,MAAM,iCAAiC,0BAA0B;AAAA,EAChE,CAAC,QAAQ,IAAI;AACd;AAGO,SAAS,6BAA6B,MAAkD;AAC9F,SAAO,+BAA+B,SAAS,IAAkC;AAClF;AAGO,SAAS,wBACf,KAC+B;AAC/B,SAAO,UAAU;AAClB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -205,7 +205,7 @@ async function defaultHandleExternalUrlAsset(editor, { url }, { toasts, msg }) {
|
|
|
205
205
|
};
|
|
206
206
|
}
|
|
207
207
|
async function defaultHandleExternalSvgTextContent(editor, { point, text }) {
|
|
208
|
-
const position = point ?? (editor.inputs.
|
|
208
|
+
const position = point ?? (editor.inputs.getShiftKey() ? editor.inputs.getCurrentPagePoint() : editor.getViewportPageBounds().center);
|
|
209
209
|
const svg = new DOMParser().parseFromString(text, "image/svg+xml").querySelector("svg");
|
|
210
210
|
if (!svg) {
|
|
211
211
|
throw new Error("No <svg/> element present");
|
|
@@ -227,7 +227,7 @@ async function defaultHandleExternalSvgTextContent(editor, { point, text }) {
|
|
|
227
227
|
createShapesForAssets(editor, [asset], position);
|
|
228
228
|
}
|
|
229
229
|
function defaultHandleExternalEmbedContent(editor, { point, url, embed }) {
|
|
230
|
-
const position = point ?? (editor.inputs.
|
|
230
|
+
const position = point ?? (editor.inputs.getShiftKey() ? editor.inputs.getCurrentPagePoint() : editor.getViewportPageBounds().center);
|
|
231
231
|
const { width, height } = embed;
|
|
232
232
|
const id = (0, import_editor.createShapeId)();
|
|
233
233
|
const newPoint = (0, import_editor.maybeSnapToGrid)(
|
|
@@ -255,7 +255,7 @@ async function defaultHandleExternalFileContent(editor, { point, files }, option
|
|
|
255
255
|
toasts.addToast({ title: msg("assets.files.amount-too-many"), severity: "error" });
|
|
256
256
|
return;
|
|
257
257
|
}
|
|
258
|
-
const position = point ?? (editor.inputs.
|
|
258
|
+
const position = point ?? (editor.inputs.getShiftKey() ? editor.inputs.getCurrentPagePoint() : editor.getViewportPageBounds().center);
|
|
259
259
|
const pagePoint = new import_editor.Vec(position.x, position.y);
|
|
260
260
|
const assetPartials = [];
|
|
261
261
|
const assetsToUpdate = [];
|
|
@@ -294,7 +294,7 @@ async function defaultHandleExternalFileContent(editor, { point, files }, option
|
|
|
294
294
|
createShapesForAssets(editor, assetPartials, pagePoint);
|
|
295
295
|
}
|
|
296
296
|
async function defaultHandleExternalTextContent(editor, { point, text, html }) {
|
|
297
|
-
const p = point ?? (editor.inputs.
|
|
297
|
+
const p = point ?? (editor.inputs.getShiftKey() ? editor.inputs.getCurrentPagePoint() : editor.getViewportPageBounds().center);
|
|
298
298
|
const defaultProps = editor.getShapeUtil("text").getDefaultProps();
|
|
299
299
|
const cleanedUpPlaintext = (0, import_text.cleanupText)(text);
|
|
300
300
|
const richTextToPaste = html ? (0, import_richText.renderRichTextFromHTML)(editor, html) : (0, import_editor.toRichText)(cleanedUpPlaintext);
|
|
@@ -366,7 +366,7 @@ async function defaultHandleExternalUrlContent(editor, { point, url }, { toasts,
|
|
|
366
366
|
embed: embedInfo.definition
|
|
367
367
|
});
|
|
368
368
|
}
|
|
369
|
-
const position = point ?? (editor.inputs.
|
|
369
|
+
const position = point ?? (editor.inputs.getShiftKey() ? editor.inputs.getCurrentPagePoint() : editor.getViewportPageBounds().center);
|
|
370
370
|
const result = await (0, import_bookmarks.createBookmarkFromUrl)(editor, { url, center: position });
|
|
371
371
|
if (!result.ok) {
|
|
372
372
|
toasts.addToast({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/lib/defaultExternalContentHandlers.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n\tAssetRecordType,\n\tDEFAULT_SUPPORTED_IMAGE_TYPES,\n\tDEFAULT_SUPPORT_VIDEO_TYPES,\n\tEditor,\n\tMediaHelpers,\n\tTLAsset,\n\tTLAssetId,\n\tTLBookmarkAsset,\n\tTLBookmarkShape,\n\tTLContent,\n\tTLFileExternalAsset,\n\tTLFileReplaceExternalContent,\n\tTLImageAsset,\n\tTLImageShape,\n\tTLShapeId,\n\tTLShapePartial,\n\tTLTextShape,\n\tTLTextShapeProps,\n\tTLUrlExternalAsset,\n\tTLVideoAsset,\n\tTLVideoShape,\n\tVec,\n\tVecLike,\n\tassert,\n\tcreateShapeId,\n\tfetch,\n\tgetHashForBuffer,\n\tgetHashForString,\n\tmaybeSnapToGrid,\n\ttoRichText,\n} from '@tldraw/editor'\nimport { EmbedDefinition } from './defaultEmbedDefinitions'\nimport { createBookmarkFromUrl } from './shapes/bookmark/bookmarks'\nimport { EmbedShapeUtil } from './shapes/embed/EmbedShapeUtil'\nimport { getCroppedImageDataForReplacedImage } from './shapes/shared/crop'\nimport { FONT_FAMILIES, FONT_SIZES, TEXT_PROPS } from './shapes/shared/default-shape-constants'\nimport { TLUiToastsContextType } from './ui/context/toasts'\nimport { useTranslation } from './ui/hooks/useTranslation/useTranslation'\nimport { containBoxSize } from './utils/assets/assets'\nimport { putExcalidrawContent } from './utils/excalidraw/putExcalidrawContent'\nimport { renderRichTextFromHTML } from './utils/text/richText'\nimport { cleanupText, isRightToLeftLanguage } from './utils/text/text'\n\n/**\n * 5000px\n * @public\n */\nexport const DEFAULT_MAX_IMAGE_DIMENSION = 5000\n/**\n * 10mb\n * @public\n */\nexport const DEFAULT_MAX_ASSET_SIZE = 10 * 1024 * 1024\n\n/** @public */\nexport interface TLExternalContentProps {\n\t/**\n\t * The maximum dimension (width or height) of an image. Images larger than this will be rescaled\n\t * to fit. Defaults to infinity.\n\t */\n\tmaxImageDimension?: number\n\t/**\n\t * The maximum size (in bytes) of an asset. Assets larger than this will be rejected. Defaults\n\t * to 10mb (10 * 1024 * 1024).\n\t */\n\tmaxAssetSize?: number\n\t/**\n\t * The mime types of images that are allowed to be handled. Defaults to\n\t * DEFAULT_SUPPORTED_IMAGE_TYPES.\n\t */\n\tacceptedImageMimeTypes?: readonly string[]\n\t/**\n\t * The mime types of videos that are allowed to be handled. Defaults to\n\t * DEFAULT_SUPPORT_VIDEO_TYPES.\n\t */\n\tacceptedVideoMimeTypes?: readonly string[]\n}\n\n/** @public */\nexport interface TLDefaultExternalContentHandlerOpts extends TLExternalContentProps {\n\ttoasts: TLUiToastsContextType\n\tmsg: ReturnType<typeof useTranslation>\n}\n\n/** @public */\nexport function registerDefaultExternalContentHandlers(\n\teditor: Editor,\n\toptions: TLDefaultExternalContentHandlerOpts\n) {\n\t// files -> asset\n\teditor.registerExternalAssetHandler('file', async (externalAsset) => {\n\t\treturn defaultHandleExternalFileAsset(editor, externalAsset, options)\n\t})\n\n\t// urls -> bookmark asset\n\teditor.registerExternalAssetHandler('url', async (externalAsset) => {\n\t\treturn defaultHandleExternalUrlAsset(editor, externalAsset, options)\n\t})\n\n\t// svg text\n\teditor.registerExternalContentHandler('svg-text', async (externalContent) => {\n\t\treturn defaultHandleExternalSvgTextContent(editor, externalContent)\n\t})\n\n\t// embeds\n\teditor.registerExternalContentHandler<'embed', EmbedDefinition>('embed', (externalContent) => {\n\t\treturn defaultHandleExternalEmbedContent(editor, externalContent)\n\t})\n\n\t// files\n\teditor.registerExternalContentHandler('files', async (externalContent) => {\n\t\treturn defaultHandleExternalFileContent(editor, externalContent, options)\n\t})\n\n\t// file-replace -> asset\n\teditor.registerExternalContentHandler('file-replace', async (externalContent) => {\n\t\treturn defaultHandleExternalFileReplaceContent(editor, externalContent, options)\n\t})\n\n\t// text\n\teditor.registerExternalContentHandler('text', async (externalContent) => {\n\t\treturn defaultHandleExternalTextContent(editor, externalContent)\n\t})\n\n\t// url\n\teditor.registerExternalContentHandler('url', async (externalContent) => {\n\t\treturn defaultHandleExternalUrlContent(editor, externalContent, options)\n\t})\n\n\t// tldraw\n\teditor.registerExternalContentHandler('tldraw', async (externalContent) => {\n\t\treturn defaultHandleExternalTldrawContent(editor, externalContent)\n\t})\n\n\t// excalidraw\n\teditor.registerExternalContentHandler('excalidraw', async (externalContent) => {\n\t\treturn defaultHandleExternalExcalidrawContent(editor, externalContent)\n\t})\n}\n\n/** @public */\nexport async function defaultHandleExternalFileAsset(\n\teditor: Editor,\n\t{ file, assetId }: TLFileExternalAsset,\n\toptions: TLDefaultExternalContentHandlerOpts\n) {\n\tconst isSuccess = notifyIfFileNotAllowed(file, options)\n\tif (!isSuccess) assert(false, 'File checks failed')\n\n\tconst assetInfo = await getAssetInfo(file, options, assetId)\n\tconst result = await editor.uploadAsset(assetInfo, file)\n\tassetInfo.props.src = result.src\n\tif (result.meta) assetInfo.meta = { ...assetInfo.meta, ...result.meta }\n\n\treturn AssetRecordType.create(assetInfo)\n}\n\n/** @public */\nexport async function defaultHandleExternalFileReplaceContent(\n\teditor: Editor,\n\t{ file, shapeId, isImage }: TLFileReplaceExternalContent,\n\toptions: TLDefaultExternalContentHandlerOpts\n) {\n\tconst isSuccess = notifyIfFileNotAllowed(file, options)\n\tif (!isSuccess) assert(false, 'File checks failed')\n\n\tconst shape = editor.getShape(shapeId)\n\tif (!shape) assert(false, 'Shape not found')\n\n\tconst hash = getHashForBuffer(await file.arrayBuffer())\n\tconst assetId = AssetRecordType.createId(hash)\n\teditor.createTemporaryAssetPreview(assetId, file)\n\tconst assetInfoPartial = await getMediaAssetInfoPartial(\n\t\tfile,\n\t\tassetId,\n\t\tisImage /* isImage */,\n\t\t!isImage /* isVideo */\n\t)\n\teditor.createAssets([assetInfoPartial])\n\n\t// And update the shape\n\tif (shape.type === 'image') {\n\t\tconst imageShape = shape as TLImageShape\n\t\tconst currentCrop = imageShape.props.crop\n\n\t\t// Calculate new dimensions that preserve the current visual size of the cropped area\n\t\tlet newWidth = assetInfoPartial.props.w\n\t\tlet newHeight = assetInfoPartial.props.h\n\t\tlet newX = imageShape.x\n\t\tlet newY = imageShape.y\n\t\tlet finalCrop = currentCrop\n\n\t\tif (currentCrop) {\n\t\t\t// Use the dedicated function to calculate the new crop and dimensions\n\t\t\tconst result = getCroppedImageDataForReplacedImage(\n\t\t\t\timageShape,\n\t\t\t\tassetInfoPartial.props.w,\n\t\t\t\tassetInfoPartial.props.h\n\t\t\t)\n\n\t\t\tfinalCrop = result.crop\n\t\t\tnewWidth = result.w\n\t\t\tnewHeight = result.h\n\t\t\tnewX = result.x\n\t\t\tnewY = result.y\n\t\t}\n\n\t\teditor.updateShapes<TLImageShape>([\n\t\t\t{\n\t\t\t\tid: imageShape.id,\n\t\t\t\ttype: imageShape.type,\n\t\t\t\tprops: {\n\t\t\t\t\tassetId: assetId,\n\t\t\t\t\tcrop: finalCrop,\n\t\t\t\t\tw: newWidth,\n\t\t\t\t\th: newHeight,\n\t\t\t\t},\n\t\t\t\tx: newX,\n\t\t\t\ty: newY,\n\t\t\t},\n\t\t])\n\t} else if (shape.type === 'video') {\n\t\teditor.updateShapes<TLVideoShape>([\n\t\t\t{\n\t\t\t\tid: shape.id,\n\t\t\t\ttype: shape.type,\n\t\t\t\tprops: {\n\t\t\t\t\tassetId: assetId,\n\t\t\t\t\tw: assetInfoPartial.props.w,\n\t\t\t\t\th: assetInfoPartial.props.h,\n\t\t\t\t},\n\t\t\t},\n\t\t])\n\t}\n\n\tconst asset = (await editor.getAssetForExternalContent({\n\t\ttype: 'file',\n\t\tfile,\n\t\tassetId,\n\t})) as TLAsset\n\n\teditor.updateAssets([{ ...asset, id: assetId }])\n\n\treturn asset\n}\n\n/** @public */\nexport async function defaultHandleExternalUrlAsset(\n\teditor: Editor,\n\t{ url }: TLUrlExternalAsset,\n\t{ toasts, msg }: TLDefaultExternalContentHandlerOpts\n): Promise<TLBookmarkAsset> {\n\tlet meta: { image: string; favicon: string; title: string; description: string }\n\n\ttry {\n\t\tconst resp = await fetch(url, {\n\t\t\tmethod: 'GET',\n\t\t\tmode: 'no-cors',\n\t\t})\n\t\tconst html = await resp.text()\n\t\tconst doc = new DOMParser().parseFromString(html, 'text/html')\n\t\tmeta = {\n\t\t\timage: doc.head.querySelector('meta[property=\"og:image\"]')?.getAttribute('content') ?? '',\n\t\t\tfavicon:\n\t\t\t\tdoc.head.querySelector('link[rel=\"apple-touch-icon\"]')?.getAttribute('href') ??\n\t\t\t\tdoc.head.querySelector('link[rel=\"icon\"]')?.getAttribute('href') ??\n\t\t\t\t'',\n\t\t\ttitle: doc.head.querySelector('meta[property=\"og:title\"]')?.getAttribute('content') ?? url,\n\t\t\tdescription:\n\t\t\t\tdoc.head.querySelector('meta[property=\"og:description\"]')?.getAttribute('content') ?? '',\n\t\t}\n\t\tif (!meta.image.startsWith('http')) {\n\t\t\tmeta.image = new URL(meta.image, url).href\n\t\t}\n\t\tif (!meta.favicon.startsWith('http')) {\n\t\t\tmeta.favicon = new URL(meta.favicon, url).href\n\t\t}\n\t} catch (error) {\n\t\tconsole.error(error)\n\t\ttoasts.addToast({\n\t\t\ttitle: msg('assets.url.failed'),\n\t\t\tseverity: 'error',\n\t\t})\n\t\tmeta = { image: '', favicon: '', title: '', description: '' }\n\t}\n\n\t// Create the bookmark asset from the meta\n\treturn {\n\t\tid: AssetRecordType.createId(getHashForString(url)),\n\t\ttypeName: 'asset',\n\t\ttype: 'bookmark',\n\t\tprops: {\n\t\t\tsrc: url,\n\t\t\tdescription: meta.description,\n\t\t\timage: meta.image,\n\t\t\tfavicon: meta.favicon,\n\t\t\ttitle: meta.title,\n\t\t},\n\t\tmeta: {},\n\t} as TLBookmarkAsset\n}\n\n/** @public */\nexport async function defaultHandleExternalSvgTextContent(\n\teditor: Editor,\n\t{ point, text }: { point?: VecLike; text: string }\n) {\n\tconst position =\n\t\tpoint ??\n\t\t(editor.inputs.shiftKey\n\t\t\t? editor.inputs.currentPagePoint\n\t\t\t: editor.getViewportPageBounds().center)\n\n\tconst svg = new DOMParser().parseFromString(text, 'image/svg+xml').querySelector('svg')\n\tif (!svg) {\n\t\tthrow new Error('No <svg/> element present')\n\t}\n\n\tlet width = parseFloat(svg.getAttribute('width') || '0')\n\tlet height = parseFloat(svg.getAttribute('height') || '0')\n\n\tif (!(width && height)) {\n\t\tdocument.body.appendChild(svg)\n\t\tconst box = svg.getBoundingClientRect()\n\t\tdocument.body.removeChild(svg)\n\n\t\twidth = box.width\n\t\theight = box.height\n\t}\n\n\tconst asset = await editor.getAssetForExternalContent({\n\t\ttype: 'file',\n\t\tfile: new File([text], 'asset.svg', { type: 'image/svg+xml' }),\n\t})\n\n\tif (!asset) throw Error('Could not create an asset')\n\n\tcreateShapesForAssets(editor, [asset], position)\n}\n\n/** @public */\nexport function defaultHandleExternalEmbedContent<T>(\n\teditor: Editor,\n\t{ point, url, embed }: { point?: VecLike; url: string; embed: T }\n) {\n\tconst position =\n\t\tpoint ??\n\t\t(editor.inputs.shiftKey\n\t\t\t? editor.inputs.currentPagePoint\n\t\t\t: editor.getViewportPageBounds().center)\n\n\tconst { width, height } = embed as { width: number; height: number }\n\n\tconst id = createShapeId()\n\n\tconst newPoint = maybeSnapToGrid(\n\t\tnew Vec(position.x - (width || 450) / 2, position.y - (height || 450) / 2),\n\t\teditor\n\t)\n\tconst shapePartial: TLShapePartial = {\n\t\tid,\n\t\ttype: 'embed',\n\t\tx: newPoint.x,\n\t\ty: newPoint.y,\n\t\tprops: {\n\t\t\tw: width,\n\t\t\th: height,\n\t\t\turl,\n\t\t},\n\t}\n\n\tif (editor.canCreateShape(shapePartial)) {\n\t\teditor.createShape(shapePartial).select(id)\n\t}\n}\n\n/** @public */\nexport async function defaultHandleExternalFileContent(\n\teditor: Editor,\n\t{ point, files }: { point?: VecLike; files: File[] },\n\toptions: TLDefaultExternalContentHandlerOpts\n) {\n\tconst { acceptedImageMimeTypes = DEFAULT_SUPPORTED_IMAGE_TYPES, toasts, msg } = options\n\tif (files.length > editor.options.maxFilesAtOnce) {\n\t\ttoasts.addToast({ title: msg('assets.files.amount-too-many'), severity: 'error' })\n\t\treturn\n\t}\n\n\tconst position =\n\t\tpoint ??\n\t\t(editor.inputs.shiftKey\n\t\t\t? editor.inputs.currentPagePoint\n\t\t\t: editor.getViewportPageBounds().center)\n\n\tconst pagePoint = new Vec(position.x, position.y)\n\tconst assetPartials: TLAsset[] = []\n\tconst assetsToUpdate: {\n\t\tasset: TLAsset\n\t\tfile: File\n\t}[] = []\n\tfor (const file of files) {\n\t\tconst isSuccess = notifyIfFileNotAllowed(file, options)\n\t\tif (!isSuccess) continue\n\n\t\tconst assetInfo = await getAssetInfo(file, options)\n\t\tif (acceptedImageMimeTypes.includes(file.type)) {\n\t\t\teditor.createTemporaryAssetPreview(assetInfo.id, file)\n\t\t}\n\t\tassetPartials.push(assetInfo)\n\t\tassetsToUpdate.push({ asset: assetInfo, file })\n\t}\n\n\tPromise.allSettled(\n\t\tassetsToUpdate.map(async (assetAndFile) => {\n\t\t\ttry {\n\t\t\t\tconst newAsset = await editor.getAssetForExternalContent({\n\t\t\t\t\ttype: 'file',\n\t\t\t\t\tfile: assetAndFile.file,\n\t\t\t\t})\n\n\t\t\t\tif (!newAsset) {\n\t\t\t\t\tthrow Error('Could not create an asset')\n\t\t\t\t}\n\n\t\t\t\t// Save the new asset under the old asset's id\n\t\t\t\teditor.updateAssets([{ ...newAsset, id: assetAndFile.asset.id }])\n\t\t\t} catch (error) {\n\t\t\t\ttoasts.addToast({\n\t\t\t\t\ttitle: msg('assets.files.upload-failed'),\n\t\t\t\t\tseverity: 'error',\n\t\t\t\t})\n\t\t\t\tconsole.error(error)\n\t\t\t\teditor.deleteAssets([assetAndFile.asset.id])\n\t\t\t\treturn\n\t\t\t}\n\t\t})\n\t)\n\n\tcreateShapesForAssets(editor, assetPartials, pagePoint)\n}\n\n/** @public */\nexport async function defaultHandleExternalTextContent(\n\teditor: Editor,\n\t{ point, text, html }: { point?: VecLike; text: string; html?: string }\n) {\n\tconst p =\n\t\tpoint ??\n\t\t(editor.inputs.shiftKey\n\t\t\t? editor.inputs.currentPagePoint\n\t\t\t: editor.getViewportPageBounds().center)\n\n\tconst defaultProps = editor.getShapeUtil<TLTextShape>('text').getDefaultProps()\n\n\tconst cleanedUpPlaintext = cleanupText(text)\n\tconst richTextToPaste = html\n\t\t? renderRichTextFromHTML(editor, html)\n\t\t: toRichText(cleanedUpPlaintext)\n\n\t// todo: discuss\n\t// If we have one shape with rich text selected, update the shape's text.\n\t// const onlySelectedShape = editor.getOnlySelectedShape()\n\t// if (onlySelectedShape && 'richText' in onlySelectedShape.props) {\n\t// \teditor.updateShapes([\n\t// \t\t{\n\t// \t\t\tid: onlySelectedShape.id,\n\t// \t\t\ttype: onlySelectedShape.type,\n\t// \t\t\tprops: {\n\t// \t\t\t\trichText: richTextToPaste,\n\t// \t\t\t},\n\t// \t\t},\n\t// \t])\n\n\t// \treturn\n\t// }\n\n\t// Measure the text with default values\n\tlet w: number\n\tlet h: number\n\tlet autoSize: boolean\n\tlet align = 'middle' as TLTextShapeProps['textAlign']\n\n\tconst htmlToMeasure = html ?? cleanedUpPlaintext.replace(/\\n/g, '<br>')\n\tconst isMultiLine = html\n\t\t? richTextToPaste.content.length > 1\n\t\t: cleanedUpPlaintext.split('\\n').length > 1\n\n\t// check whether the text contains the most common characters in RTL languages\n\tconst isRtl = isRightToLeftLanguage(cleanedUpPlaintext)\n\n\tif (isMultiLine) {\n\t\talign = isMultiLine ? (isRtl ? 'end' : 'start') : 'middle'\n\t}\n\n\tconst rawSize = editor.textMeasure.measureHtml(htmlToMeasure, {\n\t\t...TEXT_PROPS,\n\t\tfontFamily: FONT_FAMILIES[defaultProps.font],\n\t\tfontSize: FONT_SIZES[defaultProps.size],\n\t\tmaxWidth: null,\n\t})\n\n\tconst minWidth = Math.min(\n\t\tisMultiLine ? editor.getViewportPageBounds().width * 0.9 : 920,\n\t\tMath.max(200, editor.getViewportPageBounds().width * 0.9)\n\t)\n\n\tif (rawSize.w > minWidth) {\n\t\tconst shrunkSize = editor.textMeasure.measureHtml(htmlToMeasure, {\n\t\t\t...TEXT_PROPS,\n\t\t\tfontFamily: FONT_FAMILIES[defaultProps.font],\n\t\t\tfontSize: FONT_SIZES[defaultProps.size],\n\t\t\tmaxWidth: minWidth,\n\t\t})\n\t\tw = shrunkSize.w\n\t\th = shrunkSize.h\n\t\tautoSize = false\n\t\talign = isRtl ? 'end' : 'start'\n\t} else {\n\t\t// autosize is fine\n\t\tw = Math.max(rawSize.w, 10)\n\t\th = Math.max(rawSize.h, 10)\n\t\tautoSize = true\n\t}\n\n\tif (p.y - h / 2 < editor.getViewportPageBounds().minY + 40) {\n\t\tp.y = editor.getViewportPageBounds().minY + 40 + h / 2\n\t}\n\n\tconst newPoint = maybeSnapToGrid(new Vec(p.x - w / 2, p.y - h / 2), editor)\n\tconst shapeId = createShapeId()\n\n\t// Allow this to trigger the max shapes reached alert\n\teditor.createShapes<TLTextShape>([\n\t\t{\n\t\t\tid: shapeId,\n\t\t\ttype: 'text',\n\t\t\tx: newPoint.x,\n\t\t\ty: newPoint.y,\n\t\t\tprops: {\n\t\t\t\trichText: richTextToPaste,\n\t\t\t\t// if the text has more than one line, align it to the left\n\t\t\t\ttextAlign: align,\n\t\t\t\tautoSize,\n\t\t\t\tw,\n\t\t\t},\n\t\t},\n\t])\n}\n\n/** @public */\nexport async function defaultHandleExternalUrlContent(\n\teditor: Editor,\n\t{ point, url }: { point?: VecLike; url: string },\n\t{ toasts, msg }: TLDefaultExternalContentHandlerOpts\n) {\n\t// try to paste as an embed first\n\tconst embedUtil = editor.getShapeUtil('embed') as EmbedShapeUtil | undefined\n\tconst embedInfo = embedUtil?.getEmbedDefinition(url)\n\n\tif (embedInfo && embedInfo.definition.embedOnPaste !== false) {\n\t\treturn editor.putExternalContent({\n\t\t\ttype: 'embed',\n\t\t\turl: embedInfo.url,\n\t\t\tpoint,\n\t\t\tembed: embedInfo.definition,\n\t\t})\n\t}\n\n\tconst position =\n\t\tpoint ??\n\t\t(editor.inputs.shiftKey\n\t\t\t? editor.inputs.currentPagePoint\n\t\t\t: editor.getViewportPageBounds().center)\n\n\t// Use the new function to create the bookmark\n\tconst result = await createBookmarkFromUrl(editor, { url, center: position })\n\n\tif (!result.ok) {\n\t\ttoasts.addToast({\n\t\t\ttitle: msg('assets.url.failed'),\n\t\t\tseverity: 'error',\n\t\t})\n\t\treturn\n\t}\n}\n\n/** @public */\nexport async function defaultHandleExternalTldrawContent(\n\teditor: Editor,\n\t{ point, content }: { point?: VecLike; content: TLContent }\n) {\n\teditor.run(() => {\n\t\tconst selectionBoundsBefore = editor.getSelectionPageBounds()\n\t\teditor.markHistoryStoppingPoint('paste')\n\n\t\t// Unlock any locked root shapes on paste\n\t\tfor (const shape of content.shapes) {\n\t\t\tif (content.rootShapeIds.includes(shape.id)) {\n\t\t\t\tshape.isLocked = false\n\t\t\t}\n\t\t}\n\n\t\teditor.putContentOntoCurrentPage(content, {\n\t\t\tpoint: point,\n\t\t\tselect: true,\n\t\t})\n\t\tconst selectedBoundsAfter = editor.getSelectionPageBounds()\n\t\tif (\n\t\t\tselectionBoundsBefore &&\n\t\t\tselectedBoundsAfter &&\n\t\t\tselectionBoundsBefore?.collides(selectedBoundsAfter)\n\t\t) {\n\t\t\t// Creates a 'puff' to show content has been pasted\n\t\t\teditor.updateInstanceState({ isChangingStyle: true })\n\t\t\teditor.timers.setTimeout(() => {\n\t\t\t\teditor.updateInstanceState({ isChangingStyle: false })\n\t\t\t}, 150)\n\t\t}\n\t})\n}\n\n/** @public */\nexport async function defaultHandleExternalExcalidrawContent(\n\teditor: Editor,\n\t{ point, content }: { point?: VecLike; content: any }\n) {\n\teditor.run(() => {\n\t\tputExcalidrawContent(editor, content, point)\n\t})\n}\n\n/** @public */\nexport async function getMediaAssetInfoPartial(\n\tfile: File,\n\tassetId: TLAssetId,\n\tisImageType: boolean,\n\tisVideoType: boolean,\n\tmaxImageDimension?: number\n) {\n\tlet fileType = file.type\n\n\tif (file.type === 'video/quicktime') {\n\t\t// hack to make .mov videos work\n\t\tfileType = 'video/mp4'\n\t}\n\n\tconst size = isImageType\n\t\t? await MediaHelpers.getImageSize(file)\n\t\t: await MediaHelpers.getVideoSize(file)\n\n\tconst isAnimated = (await MediaHelpers.isAnimated(file)) || isVideoType\n\n\tconst assetInfo = {\n\t\tid: assetId,\n\t\ttype: isImageType ? 'image' : 'video',\n\t\ttypeName: 'asset',\n\t\tprops: {\n\t\t\tname: file.name,\n\t\t\tsrc: '',\n\t\t\tw: size.w,\n\t\t\th: size.h,\n\t\t\tfileSize: file.size,\n\t\t\tmimeType: fileType,\n\t\t\tisAnimated,\n\t\t},\n\t\tmeta: {},\n\t} as TLImageAsset | TLVideoAsset\n\n\tif (maxImageDimension && isFinite(maxImageDimension)) {\n\t\tconst size = { w: assetInfo.props.w, h: assetInfo.props.h }\n\t\tconst resizedSize = containBoxSize(size, { w: maxImageDimension, h: maxImageDimension })\n\t\tif (size !== resizedSize && MediaHelpers.isStaticImageType(file.type)) {\n\t\t\tassetInfo.props.w = resizedSize.w\n\t\t\tassetInfo.props.h = resizedSize.h\n\t\t}\n\t}\n\n\treturn assetInfo\n}\n\n/**\n * A helper function for an external content handler. It creates bookmarks,\n * images or video shapes corresponding to the type of assets provided.\n *\n * @param editor - The editor instance\n *\n * @param assets - An array of asset Ids\n *\n * @param position - the position at which to create the shapes\n *\n * @public\n */\nexport async function createShapesForAssets(\n\teditor: Editor,\n\tassets: TLAsset[],\n\tposition: VecLike\n): Promise<TLShapeId[]> {\n\tif (!assets.length) return []\n\n\tconst currentPoint = Vec.From(position)\n\tconst partials: TLShapePartial[] = []\n\n\tfor (let i = 0; i < assets.length; i++) {\n\t\tconst asset = assets[i]\n\t\tswitch (asset.type) {\n\t\t\tcase 'image': {\n\t\t\t\tpartials.push({\n\t\t\t\t\tid: createShapeId(),\n\t\t\t\t\ttype: 'image',\n\t\t\t\t\tx: currentPoint.x,\n\t\t\t\t\ty: currentPoint.y,\n\t\t\t\t\topacity: 1,\n\t\t\t\t\tprops: {\n\t\t\t\t\t\tassetId: asset.id,\n\t\t\t\t\t\tw: asset.props.w,\n\t\t\t\t\t\th: asset.props.h,\n\t\t\t\t\t},\n\t\t\t\t})\n\n\t\t\t\tcurrentPoint.x += asset.props.w\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'video': {\n\t\t\t\tpartials.push({\n\t\t\t\t\tid: createShapeId(),\n\t\t\t\t\ttype: 'video',\n\t\t\t\t\tx: currentPoint.x,\n\t\t\t\t\ty: currentPoint.y,\n\t\t\t\t\topacity: 1,\n\t\t\t\t\tprops: {\n\t\t\t\t\t\tassetId: asset.id,\n\t\t\t\t\t\tw: asset.props.w,\n\t\t\t\t\t\th: asset.props.h,\n\t\t\t\t\t},\n\t\t\t\t})\n\n\t\t\t\tcurrentPoint.x += asset.props.w\n\t\t\t}\n\t\t}\n\t}\n\n\teditor.run(() => {\n\t\t// Create any assets\n\t\tconst assetsToCreate = assets.filter((asset) => !editor.getAsset(asset.id))\n\n\t\teditor.store.atomic(() => {\n\t\t\tif (editor.canCreateShapes(partials)) {\n\t\t\t\tif (assetsToCreate.length) {\n\t\t\t\t\teditor.createAssets(assetsToCreate)\n\t\t\t\t}\n\n\t\t\t\t// Create the shapes\n\t\t\t\teditor.createShapes(partials).select(...partials.map((p) => p.id))\n\n\t\t\t\t// Re-position shapes so that the center of the group is at the provided point\n\t\t\t\tcenterSelectionAroundPoint(editor, position)\n\t\t\t}\n\t\t})\n\t})\n\n\treturn partials.map((p) => p.id)\n}\n\n/**\n * Repositions selected shapes do that the center of the group is\n * at the provided position\n *\n * @param editor - The editor instance\n *\n * @param position - the point to center the shapes around\n *\n * @public\n */\nexport function centerSelectionAroundPoint(editor: Editor, position: VecLike) {\n\t// Re-position shapes so that the center of the group is at the provided point\n\tconst viewportPageBounds = editor.getViewportPageBounds()\n\tlet selectionPageBounds = editor.getSelectionPageBounds()\n\n\tif (selectionPageBounds) {\n\t\tconst offset = selectionPageBounds!.center.sub(position)\n\n\t\teditor.updateShapes(\n\t\t\teditor.getSelectedShapes().map((shape) => {\n\t\t\t\tconst localRotation = editor.getShapeParentTransform(shape).decompose().rotation\n\t\t\t\tconst localDelta = Vec.Rot(offset, -localRotation)\n\t\t\t\treturn {\n\t\t\t\t\tid: shape.id,\n\t\t\t\t\ttype: shape.type,\n\t\t\t\t\tx: shape.x! - localDelta.x,\n\t\t\t\t\ty: shape.y! - localDelta.y,\n\t\t\t\t}\n\t\t\t})\n\t\t)\n\t}\n\tselectionPageBounds = editor.getSelectionPageBounds()\n\t// align selection with the grid if necessary\n\tif (selectionPageBounds && editor.getInstanceState().isGridMode) {\n\t\tconst gridSize = editor.getDocumentSettings().gridSize\n\t\tconst topLeft = new Vec(selectionPageBounds.minX, selectionPageBounds.minY)\n\t\tconst gridSnappedPoint = topLeft.clone().snapToGrid(gridSize)\n\t\tconst delta = Vec.Sub(topLeft, gridSnappedPoint)\n\t\teditor.updateShapes(\n\t\t\teditor.getSelectedShapes().map((shape) => {\n\t\t\t\tconst newPoint = { x: shape.x! - delta.x, y: shape.y! - delta.y }\n\t\t\t\treturn {\n\t\t\t\t\tid: shape.id,\n\t\t\t\t\ttype: shape.type,\n\t\t\t\t\tx: newPoint.x,\n\t\t\t\t\ty: newPoint.y,\n\t\t\t\t}\n\t\t\t})\n\t\t)\n\t}\n\t// Zoom out to fit the shapes, if necessary\n\tselectionPageBounds = editor.getSelectionPageBounds()\n\tif (selectionPageBounds && !viewportPageBounds.contains(selectionPageBounds)) {\n\t\teditor.zoomToSelection({ animation: { duration: editor.options.animationMediumMs } })\n\t}\n}\n\n/** @public */\nexport function createEmptyBookmarkShape(\n\teditor: Editor,\n\turl: string,\n\tposition: VecLike\n): TLBookmarkShape {\n\tconst partial: TLShapePartial = {\n\t\tid: createShapeId(),\n\t\ttype: 'bookmark',\n\t\tx: position.x - 150,\n\t\ty: position.y - 160,\n\t\topacity: 1,\n\t\tprops: {\n\t\t\tassetId: null,\n\t\t\turl,\n\t\t},\n\t}\n\n\teditor.run(() => {\n\t\t// Allow this to trigger the max shapes reached alert\n\t\teditor.createShape(partial)\n\t\tif (!editor.getShape(partial.id)) return\n\t\teditor.select(partial.id)\n\t\tcenterSelectionAroundPoint(editor, position)\n\t})\n\n\treturn editor.getShape(partial.id) as TLBookmarkShape\n}\n\n/**\n * Checks if a file is allowed to be uploaded. If it is not, it will show a toast explaining why to the user.\n *\n * @param file - The file to check\n * @param options - The options for the external content handler\n * @returns True if the file is allowed, false otherwise\n * @public\n */\nexport function notifyIfFileNotAllowed(file: File, options: TLDefaultExternalContentHandlerOpts) {\n\tconst {\n\t\tacceptedImageMimeTypes = DEFAULT_SUPPORTED_IMAGE_TYPES,\n\t\tacceptedVideoMimeTypes = DEFAULT_SUPPORT_VIDEO_TYPES,\n\t\tmaxAssetSize = DEFAULT_MAX_ASSET_SIZE,\n\t\ttoasts,\n\t\tmsg,\n\t} = options\n\tconst isImageType = acceptedImageMimeTypes.includes(file.type)\n\tconst isVideoType = acceptedVideoMimeTypes.includes(file.type)\n\n\tif (!isImageType && !isVideoType) {\n\t\ttoasts.addToast({\n\t\t\ttitle: msg('assets.files.type-not-allowed'),\n\t\t\tseverity: 'error',\n\t\t})\n\t\treturn false\n\t}\n\n\tif (file.size > maxAssetSize) {\n\t\tconst formatBytes = (bytes: number): string => {\n\t\t\tif (bytes === 0) return '0 bytes'\n\n\t\t\tconst units = ['bytes', 'KB', 'MB', 'GB', 'TB', 'PB']\n\t\t\tconst base = 1024\n\t\t\tconst unitIndex = Math.floor(Math.log(bytes) / Math.log(base))\n\n\t\t\tconst value = bytes / Math.pow(base, unitIndex)\n\t\t\tconst formatted = value % 1 === 0 ? value.toString() : value.toFixed(1)\n\n\t\t\treturn `${formatted} ${units[unitIndex]}`\n\t\t}\n\n\t\ttoasts.addToast({\n\t\t\ttitle: msg('assets.files.size-too-big'),\n\t\t\tdescription: msg('assets.files.maximum-size').replace('{size}', formatBytes(maxAssetSize)),\n\t\t\tseverity: 'error',\n\t\t})\n\t\treturn false\n\t}\n\n\t// Use mime type instead of file ext, this is because\n\t// window.navigator.clipboard does not preserve file names\n\t// of copied files.\n\tif (!file.type) {\n\t\ttoasts.addToast({\n\t\t\ttitle: msg('assets.files.upload-failed'),\n\t\t\tseverity: 'error',\n\t\t})\n\t\tconsole.error('No mime type')\n\t\treturn false\n\t}\n\n\treturn true\n}\n\n/** @public */\nexport async function getAssetInfo(\n\tfile: File,\n\toptions: TLDefaultExternalContentHandlerOpts,\n\tassetId?: TLAssetId\n) {\n\tconst {\n\t\tacceptedImageMimeTypes = DEFAULT_SUPPORTED_IMAGE_TYPES,\n\t\tacceptedVideoMimeTypes = DEFAULT_SUPPORT_VIDEO_TYPES,\n\t\tmaxImageDimension = DEFAULT_MAX_IMAGE_DIMENSION,\n\t} = options\n\n\tconst isImageType = acceptedImageMimeTypes.includes(file.type)\n\tconst isVideoType = acceptedVideoMimeTypes.includes(file.type)\n\tconst hash = getHashForBuffer(await file.arrayBuffer())\n\tassetId ??= AssetRecordType.createId(hash)\n\tconst assetInfo = await getMediaAssetInfoPartial(\n\t\tfile,\n\t\tassetId,\n\t\tisImageType,\n\t\tisVideoType,\n\t\tmaxImageDimension\n\t)\n\treturn assetInfo\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBA+BO;AAEP,uBAAsC;AAEtC,kBAAoD;AACpD,qCAAsD;AAGtD,oBAA+B;AAC/B,kCAAqC;AACrC,sBAAuC;AACvC,kBAAmD;AAM5C,MAAM,8BAA8B;AAKpC,MAAM,yBAAyB,KAAK,OAAO;AAiC3C,SAAS,uCACf,QACA,SACC;AAED,SAAO,6BAA6B,QAAQ,OAAO,kBAAkB;AACpE,WAAO,+BAA+B,QAAQ,eAAe,OAAO;AAAA,EACrE,CAAC;AAGD,SAAO,6BAA6B,OAAO,OAAO,kBAAkB;AACnE,WAAO,8BAA8B,QAAQ,eAAe,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AAM,SAAS,CAAC;AAAA,IACxC;AAEA,WAAO,SAAS;AAAA,MACf,OAAO,IAAI,2BAA2B;AAAA,MACtC,aAAa,IAAI,2BAA2B,EAAE,QAAQ,UAAU,YAAY,YAAY,CAAC;AAAA,MACzF,UAAU;AAAA,IACX,CAAC;AACD,WAAO;AAAA,EACR;AAKA,MAAI,CAAC,KAAK,MAAM;AACf,WAAO,SAAS;AAAA,MACf,OAAO,IAAI,4BAA4B;AAAA,MACvC,UAAU;AAAA,IACX,CAAC;AACD,YAAQ,MAAM,cAAc;AAC5B,WAAO;AAAA,EACR;AAEA,SAAO;AACR;AAGA,eAAsB,aACrB,MACA,SACA,SACC;AACD,QAAM;AAAA,IACL,yBAAyB;AAAA,IACzB,yBAAyB;AAAA,IACzB,oBAAoB;AAAA,EACrB,IAAI;AAEJ,QAAM,cAAc,uBAAuB,SAAS,KAAK,IAAI;AAC7D,QAAM,cAAc,uBAAuB,SAAS,KAAK,IAAI;AAC7D,QAAM,WAAO,gCAAiB,MAAM,KAAK,YAAY,CAAC;AACtD,cAAY,8BAAgB,SAAS,IAAI;AACzC,QAAM,YAAY,MAAM;AAAA,IACvB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACA,SAAO;AACR;",
|
|
4
|
+
"sourcesContent": ["import {\n\tAssetRecordType,\n\tDEFAULT_SUPPORTED_IMAGE_TYPES,\n\tDEFAULT_SUPPORT_VIDEO_TYPES,\n\tEditor,\n\tMediaHelpers,\n\tTLAsset,\n\tTLAssetId,\n\tTLBookmarkAsset,\n\tTLBookmarkShape,\n\tTLContent,\n\tTLFileExternalAsset,\n\tTLFileReplaceExternalContent,\n\tTLImageAsset,\n\tTLImageShape,\n\tTLShapeId,\n\tTLShapePartial,\n\tTLTextShape,\n\tTLTextShapeProps,\n\tTLUrlExternalAsset,\n\tTLVideoAsset,\n\tVec,\n\tVecLike,\n\tassert,\n\tcreateShapeId,\n\tfetch,\n\tgetHashForBuffer,\n\tgetHashForString,\n\tmaybeSnapToGrid,\n\ttoRichText,\n} from '@tldraw/editor'\nimport { EmbedDefinition } from './defaultEmbedDefinitions'\nimport { createBookmarkFromUrl } from './shapes/bookmark/bookmarks'\nimport { EmbedShapeUtil } from './shapes/embed/EmbedShapeUtil'\nimport { getCroppedImageDataForReplacedImage } from './shapes/shared/crop'\nimport { FONT_FAMILIES, FONT_SIZES, TEXT_PROPS } from './shapes/shared/default-shape-constants'\nimport { TLUiToastsContextType } from './ui/context/toasts'\nimport { useTranslation } from './ui/hooks/useTranslation/useTranslation'\nimport { containBoxSize } from './utils/assets/assets'\nimport { putExcalidrawContent } from './utils/excalidraw/putExcalidrawContent'\nimport { renderRichTextFromHTML } from './utils/text/richText'\nimport { cleanupText, isRightToLeftLanguage } from './utils/text/text'\n\n/**\n * 5000px\n * @public\n */\nexport const DEFAULT_MAX_IMAGE_DIMENSION = 5000\n/**\n * 10mb\n * @public\n */\nexport const DEFAULT_MAX_ASSET_SIZE = 10 * 1024 * 1024\n\n/** @public */\nexport interface TLExternalContentProps {\n\t/**\n\t * The maximum dimension (width or height) of an image. Images larger than this will be rescaled\n\t * to fit. Defaults to infinity.\n\t */\n\tmaxImageDimension?: number\n\t/**\n\t * The maximum size (in bytes) of an asset. Assets larger than this will be rejected. Defaults\n\t * to 10mb (10 * 1024 * 1024).\n\t */\n\tmaxAssetSize?: number\n\t/**\n\t * The mime types of images that are allowed to be handled. Defaults to\n\t * DEFAULT_SUPPORTED_IMAGE_TYPES.\n\t */\n\tacceptedImageMimeTypes?: readonly string[]\n\t/**\n\t * The mime types of videos that are allowed to be handled. Defaults to\n\t * DEFAULT_SUPPORT_VIDEO_TYPES.\n\t */\n\tacceptedVideoMimeTypes?: readonly string[]\n}\n\n/** @public */\nexport interface TLDefaultExternalContentHandlerOpts extends TLExternalContentProps {\n\ttoasts: TLUiToastsContextType\n\tmsg: ReturnType<typeof useTranslation>\n}\n\n/** @public */\nexport function registerDefaultExternalContentHandlers(\n\teditor: Editor,\n\toptions: TLDefaultExternalContentHandlerOpts\n) {\n\t// files -> asset\n\teditor.registerExternalAssetHandler('file', async (externalAsset) => {\n\t\treturn defaultHandleExternalFileAsset(editor, externalAsset, options)\n\t})\n\n\t// urls -> bookmark asset\n\teditor.registerExternalAssetHandler('url', async (externalAsset) => {\n\t\treturn defaultHandleExternalUrlAsset(editor, externalAsset, options)\n\t})\n\n\t// svg text\n\teditor.registerExternalContentHandler('svg-text', async (externalContent) => {\n\t\treturn defaultHandleExternalSvgTextContent(editor, externalContent)\n\t})\n\n\t// embeds\n\teditor.registerExternalContentHandler<'embed', EmbedDefinition>('embed', (externalContent) => {\n\t\treturn defaultHandleExternalEmbedContent(editor, externalContent)\n\t})\n\n\t// files\n\teditor.registerExternalContentHandler('files', async (externalContent) => {\n\t\treturn defaultHandleExternalFileContent(editor, externalContent, options)\n\t})\n\n\t// file-replace -> asset\n\teditor.registerExternalContentHandler('file-replace', async (externalContent) => {\n\t\treturn defaultHandleExternalFileReplaceContent(editor, externalContent, options)\n\t})\n\n\t// text\n\teditor.registerExternalContentHandler('text', async (externalContent) => {\n\t\treturn defaultHandleExternalTextContent(editor, externalContent)\n\t})\n\n\t// url\n\teditor.registerExternalContentHandler('url', async (externalContent) => {\n\t\treturn defaultHandleExternalUrlContent(editor, externalContent, options)\n\t})\n\n\t// tldraw\n\teditor.registerExternalContentHandler('tldraw', async (externalContent) => {\n\t\treturn defaultHandleExternalTldrawContent(editor, externalContent)\n\t})\n\n\t// excalidraw\n\teditor.registerExternalContentHandler('excalidraw', async (externalContent) => {\n\t\treturn defaultHandleExternalExcalidrawContent(editor, externalContent)\n\t})\n}\n\n/** @public */\nexport async function defaultHandleExternalFileAsset(\n\teditor: Editor,\n\t{ file, assetId }: TLFileExternalAsset,\n\toptions: TLDefaultExternalContentHandlerOpts\n) {\n\tconst isSuccess = notifyIfFileNotAllowed(file, options)\n\tif (!isSuccess) assert(false, 'File checks failed')\n\n\tconst assetInfo = await getAssetInfo(file, options, assetId)\n\tconst result = await editor.uploadAsset(assetInfo, file)\n\tassetInfo.props.src = result.src\n\tif (result.meta) assetInfo.meta = { ...assetInfo.meta, ...result.meta }\n\n\treturn AssetRecordType.create(assetInfo)\n}\n\n/** @public */\nexport async function defaultHandleExternalFileReplaceContent(\n\teditor: Editor,\n\t{ file, shapeId, isImage }: TLFileReplaceExternalContent,\n\toptions: TLDefaultExternalContentHandlerOpts\n) {\n\tconst isSuccess = notifyIfFileNotAllowed(file, options)\n\tif (!isSuccess) assert(false, 'File checks failed')\n\n\tconst shape = editor.getShape(shapeId)\n\tif (!shape) assert(false, 'Shape not found')\n\n\tconst hash = getHashForBuffer(await file.arrayBuffer())\n\tconst assetId = AssetRecordType.createId(hash)\n\teditor.createTemporaryAssetPreview(assetId, file)\n\tconst assetInfoPartial = await getMediaAssetInfoPartial(\n\t\tfile,\n\t\tassetId,\n\t\tisImage /* isImage */,\n\t\t!isImage /* isVideo */\n\t)\n\teditor.createAssets([assetInfoPartial])\n\n\t// And update the shape\n\tif (shape.type === 'image') {\n\t\tconst imageShape = shape as TLImageShape\n\t\tconst currentCrop = imageShape.props.crop\n\n\t\t// Calculate new dimensions that preserve the current visual size of the cropped area\n\t\tlet newWidth = assetInfoPartial.props.w\n\t\tlet newHeight = assetInfoPartial.props.h\n\t\tlet newX = imageShape.x\n\t\tlet newY = imageShape.y\n\t\tlet finalCrop = currentCrop\n\n\t\tif (currentCrop) {\n\t\t\t// Use the dedicated function to calculate the new crop and dimensions\n\t\t\tconst result = getCroppedImageDataForReplacedImage(\n\t\t\t\timageShape,\n\t\t\t\tassetInfoPartial.props.w,\n\t\t\t\tassetInfoPartial.props.h\n\t\t\t)\n\n\t\t\tfinalCrop = result.crop\n\t\t\tnewWidth = result.w\n\t\t\tnewHeight = result.h\n\t\t\tnewX = result.x\n\t\t\tnewY = result.y\n\t\t}\n\n\t\teditor.updateShapes([\n\t\t\t{\n\t\t\t\tid: imageShape.id,\n\t\t\t\ttype: imageShape.type,\n\t\t\t\tprops: {\n\t\t\t\t\tassetId: assetId,\n\t\t\t\t\tcrop: finalCrop,\n\t\t\t\t\tw: newWidth,\n\t\t\t\t\th: newHeight,\n\t\t\t\t},\n\t\t\t\tx: newX,\n\t\t\t\ty: newY,\n\t\t\t},\n\t\t])\n\t} else if (shape.type === 'video') {\n\t\teditor.updateShapes([\n\t\t\t{\n\t\t\t\tid: shape.id,\n\t\t\t\ttype: shape.type,\n\t\t\t\tprops: {\n\t\t\t\t\tassetId: assetId,\n\t\t\t\t\tw: assetInfoPartial.props.w,\n\t\t\t\t\th: assetInfoPartial.props.h,\n\t\t\t\t},\n\t\t\t},\n\t\t])\n\t}\n\n\tconst asset = (await editor.getAssetForExternalContent({\n\t\ttype: 'file',\n\t\tfile,\n\t\tassetId,\n\t})) as TLAsset\n\n\teditor.updateAssets([{ ...asset, id: assetId }])\n\n\treturn asset\n}\n\n/** @public */\nexport async function defaultHandleExternalUrlAsset(\n\teditor: Editor,\n\t{ url }: TLUrlExternalAsset,\n\t{ toasts, msg }: TLDefaultExternalContentHandlerOpts\n): Promise<TLBookmarkAsset> {\n\tlet meta: { image: string; favicon: string; title: string; description: string }\n\n\ttry {\n\t\tconst resp = await fetch(url, {\n\t\t\tmethod: 'GET',\n\t\t\tmode: 'no-cors',\n\t\t})\n\t\tconst html = await resp.text()\n\t\tconst doc = new DOMParser().parseFromString(html, 'text/html')\n\t\tmeta = {\n\t\t\timage: doc.head.querySelector('meta[property=\"og:image\"]')?.getAttribute('content') ?? '',\n\t\t\tfavicon:\n\t\t\t\tdoc.head.querySelector('link[rel=\"apple-touch-icon\"]')?.getAttribute('href') ??\n\t\t\t\tdoc.head.querySelector('link[rel=\"icon\"]')?.getAttribute('href') ??\n\t\t\t\t'',\n\t\t\ttitle: doc.head.querySelector('meta[property=\"og:title\"]')?.getAttribute('content') ?? url,\n\t\t\tdescription:\n\t\t\t\tdoc.head.querySelector('meta[property=\"og:description\"]')?.getAttribute('content') ?? '',\n\t\t}\n\t\tif (!meta.image.startsWith('http')) {\n\t\t\tmeta.image = new URL(meta.image, url).href\n\t\t}\n\t\tif (!meta.favicon.startsWith('http')) {\n\t\t\tmeta.favicon = new URL(meta.favicon, url).href\n\t\t}\n\t} catch (error) {\n\t\tconsole.error(error)\n\t\ttoasts.addToast({\n\t\t\ttitle: msg('assets.url.failed'),\n\t\t\tseverity: 'error',\n\t\t})\n\t\tmeta = { image: '', favicon: '', title: '', description: '' }\n\t}\n\n\t// Create the bookmark asset from the meta\n\treturn {\n\t\tid: AssetRecordType.createId(getHashForString(url)),\n\t\ttypeName: 'asset',\n\t\ttype: 'bookmark',\n\t\tprops: {\n\t\t\tsrc: url,\n\t\t\tdescription: meta.description,\n\t\t\timage: meta.image,\n\t\t\tfavicon: meta.favicon,\n\t\t\ttitle: meta.title,\n\t\t},\n\t\tmeta: {},\n\t} as TLBookmarkAsset\n}\n\n/** @public */\nexport async function defaultHandleExternalSvgTextContent(\n\teditor: Editor,\n\t{ point, text }: { point?: VecLike; text: string }\n) {\n\tconst position =\n\t\tpoint ??\n\t\t(editor.inputs.getShiftKey()\n\t\t\t? editor.inputs.getCurrentPagePoint()\n\t\t\t: editor.getViewportPageBounds().center)\n\n\tconst svg = new DOMParser().parseFromString(text, 'image/svg+xml').querySelector('svg')\n\tif (!svg) {\n\t\tthrow new Error('No <svg/> element present')\n\t}\n\n\tlet width = parseFloat(svg.getAttribute('width') || '0')\n\tlet height = parseFloat(svg.getAttribute('height') || '0')\n\n\tif (!(width && height)) {\n\t\tdocument.body.appendChild(svg)\n\t\tconst box = svg.getBoundingClientRect()\n\t\tdocument.body.removeChild(svg)\n\n\t\twidth = box.width\n\t\theight = box.height\n\t}\n\n\tconst asset = await editor.getAssetForExternalContent({\n\t\ttype: 'file',\n\t\tfile: new File([text], 'asset.svg', { type: 'image/svg+xml' }),\n\t})\n\n\tif (!asset) throw Error('Could not create an asset')\n\n\tcreateShapesForAssets(editor, [asset], position)\n}\n\n/** @public */\nexport function defaultHandleExternalEmbedContent<T>(\n\teditor: Editor,\n\t{ point, url, embed }: { point?: VecLike; url: string; embed: T }\n) {\n\tconst position =\n\t\tpoint ??\n\t\t(editor.inputs.getShiftKey()\n\t\t\t? editor.inputs.getCurrentPagePoint()\n\t\t\t: editor.getViewportPageBounds().center)\n\n\tconst { width, height } = embed as { width: number; height: number }\n\n\tconst id = createShapeId()\n\n\tconst newPoint = maybeSnapToGrid(\n\t\tnew Vec(position.x - (width || 450) / 2, position.y - (height || 450) / 2),\n\t\teditor\n\t)\n\tconst shapePartial: TLShapePartial = {\n\t\tid,\n\t\ttype: 'embed',\n\t\tx: newPoint.x,\n\t\ty: newPoint.y,\n\t\tprops: {\n\t\t\tw: width,\n\t\t\th: height,\n\t\t\turl,\n\t\t},\n\t}\n\n\tif (editor.canCreateShape(shapePartial)) {\n\t\teditor.createShape(shapePartial).select(id)\n\t}\n}\n\n/** @public */\nexport async function defaultHandleExternalFileContent(\n\teditor: Editor,\n\t{ point, files }: { point?: VecLike; files: File[] },\n\toptions: TLDefaultExternalContentHandlerOpts\n) {\n\tconst { acceptedImageMimeTypes = DEFAULT_SUPPORTED_IMAGE_TYPES, toasts, msg } = options\n\tif (files.length > editor.options.maxFilesAtOnce) {\n\t\ttoasts.addToast({ title: msg('assets.files.amount-too-many'), severity: 'error' })\n\t\treturn\n\t}\n\n\tconst position =\n\t\tpoint ??\n\t\t(editor.inputs.getShiftKey()\n\t\t\t? editor.inputs.getCurrentPagePoint()\n\t\t\t: editor.getViewportPageBounds().center)\n\n\tconst pagePoint = new Vec(position.x, position.y)\n\tconst assetPartials: TLAsset[] = []\n\tconst assetsToUpdate: {\n\t\tasset: TLAsset\n\t\tfile: File\n\t}[] = []\n\tfor (const file of files) {\n\t\tconst isSuccess = notifyIfFileNotAllowed(file, options)\n\t\tif (!isSuccess) continue\n\n\t\tconst assetInfo = await getAssetInfo(file, options)\n\t\tif (acceptedImageMimeTypes.includes(file.type)) {\n\t\t\teditor.createTemporaryAssetPreview(assetInfo.id, file)\n\t\t}\n\t\tassetPartials.push(assetInfo)\n\t\tassetsToUpdate.push({ asset: assetInfo, file })\n\t}\n\n\tPromise.allSettled(\n\t\tassetsToUpdate.map(async (assetAndFile) => {\n\t\t\ttry {\n\t\t\t\tconst newAsset = await editor.getAssetForExternalContent({\n\t\t\t\t\ttype: 'file',\n\t\t\t\t\tfile: assetAndFile.file,\n\t\t\t\t})\n\n\t\t\t\tif (!newAsset) {\n\t\t\t\t\tthrow Error('Could not create an asset')\n\t\t\t\t}\n\n\t\t\t\t// Save the new asset under the old asset's id\n\t\t\t\teditor.updateAssets([{ ...newAsset, id: assetAndFile.asset.id }])\n\t\t\t} catch (error) {\n\t\t\t\ttoasts.addToast({\n\t\t\t\t\ttitle: msg('assets.files.upload-failed'),\n\t\t\t\t\tseverity: 'error',\n\t\t\t\t})\n\t\t\t\tconsole.error(error)\n\t\t\t\teditor.deleteAssets([assetAndFile.asset.id])\n\t\t\t\treturn\n\t\t\t}\n\t\t})\n\t)\n\n\tcreateShapesForAssets(editor, assetPartials, pagePoint)\n}\n\n/** @public */\nexport async function defaultHandleExternalTextContent(\n\teditor: Editor,\n\t{ point, text, html }: { point?: VecLike; text: string; html?: string }\n) {\n\tconst p =\n\t\tpoint ??\n\t\t(editor.inputs.getShiftKey()\n\t\t\t? editor.inputs.getCurrentPagePoint()\n\t\t\t: editor.getViewportPageBounds().center)\n\n\tconst defaultProps = editor.getShapeUtil<TLTextShape>('text').getDefaultProps()\n\n\tconst cleanedUpPlaintext = cleanupText(text)\n\tconst richTextToPaste = html\n\t\t? renderRichTextFromHTML(editor, html)\n\t\t: toRichText(cleanedUpPlaintext)\n\n\t// todo: discuss\n\t// If we have one shape with rich text selected, update the shape's text.\n\t// const onlySelectedShape = editor.getOnlySelectedShape()\n\t// if (onlySelectedShape && 'richText' in onlySelectedShape.props) {\n\t// \teditor.updateShapes([\n\t// \t\t{\n\t// \t\t\tid: onlySelectedShape.id,\n\t// \t\t\ttype: onlySelectedShape.type,\n\t// \t\t\tprops: {\n\t// \t\t\t\trichText: richTextToPaste,\n\t// \t\t\t},\n\t// \t\t},\n\t// \t])\n\n\t// \treturn\n\t// }\n\n\t// Measure the text with default values\n\tlet w: number\n\tlet h: number\n\tlet autoSize: boolean\n\tlet align = 'middle' as TLTextShapeProps['textAlign']\n\n\tconst htmlToMeasure = html ?? cleanedUpPlaintext.replace(/\\n/g, '<br>')\n\tconst isMultiLine = html\n\t\t? richTextToPaste.content.length > 1\n\t\t: cleanedUpPlaintext.split('\\n').length > 1\n\n\t// check whether the text contains the most common characters in RTL languages\n\tconst isRtl = isRightToLeftLanguage(cleanedUpPlaintext)\n\n\tif (isMultiLine) {\n\t\talign = isMultiLine ? (isRtl ? 'end' : 'start') : 'middle'\n\t}\n\n\tconst rawSize = editor.textMeasure.measureHtml(htmlToMeasure, {\n\t\t...TEXT_PROPS,\n\t\tfontFamily: FONT_FAMILIES[defaultProps.font],\n\t\tfontSize: FONT_SIZES[defaultProps.size],\n\t\tmaxWidth: null,\n\t})\n\n\tconst minWidth = Math.min(\n\t\tisMultiLine ? editor.getViewportPageBounds().width * 0.9 : 920,\n\t\tMath.max(200, editor.getViewportPageBounds().width * 0.9)\n\t)\n\n\tif (rawSize.w > minWidth) {\n\t\tconst shrunkSize = editor.textMeasure.measureHtml(htmlToMeasure, {\n\t\t\t...TEXT_PROPS,\n\t\t\tfontFamily: FONT_FAMILIES[defaultProps.font],\n\t\t\tfontSize: FONT_SIZES[defaultProps.size],\n\t\t\tmaxWidth: minWidth,\n\t\t})\n\t\tw = shrunkSize.w\n\t\th = shrunkSize.h\n\t\tautoSize = false\n\t\talign = isRtl ? 'end' : 'start'\n\t} else {\n\t\t// autosize is fine\n\t\tw = Math.max(rawSize.w, 10)\n\t\th = Math.max(rawSize.h, 10)\n\t\tautoSize = true\n\t}\n\n\tif (p.y - h / 2 < editor.getViewportPageBounds().minY + 40) {\n\t\tp.y = editor.getViewportPageBounds().minY + 40 + h / 2\n\t}\n\n\tconst newPoint = maybeSnapToGrid(new Vec(p.x - w / 2, p.y - h / 2), editor)\n\tconst shapeId = createShapeId()\n\n\t// Allow this to trigger the max shapes reached alert\n\teditor.createShapes([\n\t\t{\n\t\t\tid: shapeId,\n\t\t\ttype: 'text',\n\t\t\tx: newPoint.x,\n\t\t\ty: newPoint.y,\n\t\t\tprops: {\n\t\t\t\trichText: richTextToPaste,\n\t\t\t\t// if the text has more than one line, align it to the left\n\t\t\t\ttextAlign: align,\n\t\t\t\tautoSize,\n\t\t\t\tw,\n\t\t\t},\n\t\t},\n\t])\n}\n\n/** @public */\nexport async function defaultHandleExternalUrlContent(\n\teditor: Editor,\n\t{ point, url }: { point?: VecLike; url: string },\n\t{ toasts, msg }: TLDefaultExternalContentHandlerOpts\n) {\n\t// try to paste as an embed first\n\tconst embedUtil = editor.getShapeUtil('embed') as EmbedShapeUtil | undefined\n\tconst embedInfo = embedUtil?.getEmbedDefinition(url)\n\n\tif (embedInfo && embedInfo.definition.embedOnPaste !== false) {\n\t\treturn editor.putExternalContent({\n\t\t\ttype: 'embed',\n\t\t\turl: embedInfo.url,\n\t\t\tpoint,\n\t\t\tembed: embedInfo.definition,\n\t\t})\n\t}\n\n\tconst position =\n\t\tpoint ??\n\t\t(editor.inputs.getShiftKey()\n\t\t\t? editor.inputs.getCurrentPagePoint()\n\t\t\t: editor.getViewportPageBounds().center)\n\n\t// Use the new function to create the bookmark\n\tconst result = await createBookmarkFromUrl(editor, { url, center: position })\n\n\tif (!result.ok) {\n\t\ttoasts.addToast({\n\t\t\ttitle: msg('assets.url.failed'),\n\t\t\tseverity: 'error',\n\t\t})\n\t\treturn\n\t}\n}\n\n/** @public */\nexport async function defaultHandleExternalTldrawContent(\n\teditor: Editor,\n\t{ point, content }: { point?: VecLike; content: TLContent }\n) {\n\teditor.run(() => {\n\t\tconst selectionBoundsBefore = editor.getSelectionPageBounds()\n\t\teditor.markHistoryStoppingPoint('paste')\n\n\t\t// Unlock any locked root shapes on paste\n\t\tfor (const shape of content.shapes) {\n\t\t\tif (content.rootShapeIds.includes(shape.id)) {\n\t\t\t\tshape.isLocked = false\n\t\t\t}\n\t\t}\n\n\t\teditor.putContentOntoCurrentPage(content, {\n\t\t\tpoint: point,\n\t\t\tselect: true,\n\t\t})\n\t\tconst selectedBoundsAfter = editor.getSelectionPageBounds()\n\t\tif (\n\t\t\tselectionBoundsBefore &&\n\t\t\tselectedBoundsAfter &&\n\t\t\tselectionBoundsBefore?.collides(selectedBoundsAfter)\n\t\t) {\n\t\t\t// Creates a 'puff' to show content has been pasted\n\t\t\teditor.updateInstanceState({ isChangingStyle: true })\n\t\t\teditor.timers.setTimeout(() => {\n\t\t\t\teditor.updateInstanceState({ isChangingStyle: false })\n\t\t\t}, 150)\n\t\t}\n\t})\n}\n\n/** @public */\nexport async function defaultHandleExternalExcalidrawContent(\n\teditor: Editor,\n\t{ point, content }: { point?: VecLike; content: any }\n) {\n\teditor.run(() => {\n\t\tputExcalidrawContent(editor, content, point)\n\t})\n}\n\n/** @public */\nexport async function getMediaAssetInfoPartial(\n\tfile: File,\n\tassetId: TLAssetId,\n\tisImageType: boolean,\n\tisVideoType: boolean,\n\tmaxImageDimension?: number\n) {\n\tlet fileType = file.type\n\n\tif (file.type === 'video/quicktime') {\n\t\t// hack to make .mov videos work\n\t\tfileType = 'video/mp4'\n\t}\n\n\tconst size = isImageType\n\t\t? await MediaHelpers.getImageSize(file)\n\t\t: await MediaHelpers.getVideoSize(file)\n\n\tconst isAnimated = (await MediaHelpers.isAnimated(file)) || isVideoType\n\n\tconst assetInfo = {\n\t\tid: assetId,\n\t\ttype: isImageType ? 'image' : 'video',\n\t\ttypeName: 'asset',\n\t\tprops: {\n\t\t\tname: file.name,\n\t\t\tsrc: '',\n\t\t\tw: size.w,\n\t\t\th: size.h,\n\t\t\tfileSize: file.size,\n\t\t\tmimeType: fileType,\n\t\t\tisAnimated,\n\t\t},\n\t\tmeta: {},\n\t} as TLImageAsset | TLVideoAsset\n\n\tif (maxImageDimension && isFinite(maxImageDimension)) {\n\t\tconst size = { w: assetInfo.props.w, h: assetInfo.props.h }\n\t\tconst resizedSize = containBoxSize(size, { w: maxImageDimension, h: maxImageDimension })\n\t\tif (size !== resizedSize && MediaHelpers.isStaticImageType(file.type)) {\n\t\t\tassetInfo.props.w = resizedSize.w\n\t\t\tassetInfo.props.h = resizedSize.h\n\t\t}\n\t}\n\n\treturn assetInfo\n}\n\n/**\n * A helper function for an external content handler. It creates bookmarks,\n * images or video shapes corresponding to the type of assets provided.\n *\n * @param editor - The editor instance\n *\n * @param assets - An array of asset Ids\n *\n * @param position - the position at which to create the shapes\n *\n * @public\n */\nexport async function createShapesForAssets(\n\teditor: Editor,\n\tassets: TLAsset[],\n\tposition: VecLike\n): Promise<TLShapeId[]> {\n\tif (!assets.length) return []\n\n\tconst currentPoint = Vec.From(position)\n\tconst partials: TLShapePartial[] = []\n\n\tfor (let i = 0; i < assets.length; i++) {\n\t\tconst asset = assets[i]\n\t\tswitch (asset.type) {\n\t\t\tcase 'image': {\n\t\t\t\tpartials.push({\n\t\t\t\t\tid: createShapeId(),\n\t\t\t\t\ttype: 'image',\n\t\t\t\t\tx: currentPoint.x,\n\t\t\t\t\ty: currentPoint.y,\n\t\t\t\t\topacity: 1,\n\t\t\t\t\tprops: {\n\t\t\t\t\t\tassetId: asset.id,\n\t\t\t\t\t\tw: asset.props.w,\n\t\t\t\t\t\th: asset.props.h,\n\t\t\t\t\t},\n\t\t\t\t})\n\n\t\t\t\tcurrentPoint.x += asset.props.w\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'video': {\n\t\t\t\tpartials.push({\n\t\t\t\t\tid: createShapeId(),\n\t\t\t\t\ttype: 'video',\n\t\t\t\t\tx: currentPoint.x,\n\t\t\t\t\ty: currentPoint.y,\n\t\t\t\t\topacity: 1,\n\t\t\t\t\tprops: {\n\t\t\t\t\t\tassetId: asset.id,\n\t\t\t\t\t\tw: asset.props.w,\n\t\t\t\t\t\th: asset.props.h,\n\t\t\t\t\t},\n\t\t\t\t})\n\n\t\t\t\tcurrentPoint.x += asset.props.w\n\t\t\t}\n\t\t}\n\t}\n\n\teditor.run(() => {\n\t\t// Create any assets\n\t\tconst assetsToCreate = assets.filter((asset) => !editor.getAsset(asset.id))\n\n\t\teditor.store.atomic(() => {\n\t\t\tif (editor.canCreateShapes(partials)) {\n\t\t\t\tif (assetsToCreate.length) {\n\t\t\t\t\teditor.createAssets(assetsToCreate)\n\t\t\t\t}\n\n\t\t\t\t// Create the shapes\n\t\t\t\teditor.createShapes(partials).select(...partials.map((p) => p.id))\n\n\t\t\t\t// Re-position shapes so that the center of the group is at the provided point\n\t\t\t\tcenterSelectionAroundPoint(editor, position)\n\t\t\t}\n\t\t})\n\t})\n\n\treturn partials.map((p) => p.id)\n}\n\n/**\n * Repositions selected shapes do that the center of the group is\n * at the provided position\n *\n * @param editor - The editor instance\n *\n * @param position - the point to center the shapes around\n *\n * @public\n */\nexport function centerSelectionAroundPoint(editor: Editor, position: VecLike) {\n\t// Re-position shapes so that the center of the group is at the provided point\n\tconst viewportPageBounds = editor.getViewportPageBounds()\n\tlet selectionPageBounds = editor.getSelectionPageBounds()\n\n\tif (selectionPageBounds) {\n\t\tconst offset = selectionPageBounds!.center.sub(position)\n\n\t\teditor.updateShapes(\n\t\t\teditor.getSelectedShapes().map((shape) => {\n\t\t\t\tconst localRotation = editor.getShapeParentTransform(shape).decompose().rotation\n\t\t\t\tconst localDelta = Vec.Rot(offset, -localRotation)\n\t\t\t\treturn {\n\t\t\t\t\tid: shape.id,\n\t\t\t\t\ttype: shape.type,\n\t\t\t\t\tx: shape.x! - localDelta.x,\n\t\t\t\t\ty: shape.y! - localDelta.y,\n\t\t\t\t}\n\t\t\t})\n\t\t)\n\t}\n\tselectionPageBounds = editor.getSelectionPageBounds()\n\t// align selection with the grid if necessary\n\tif (selectionPageBounds && editor.getInstanceState().isGridMode) {\n\t\tconst gridSize = editor.getDocumentSettings().gridSize\n\t\tconst topLeft = new Vec(selectionPageBounds.minX, selectionPageBounds.minY)\n\t\tconst gridSnappedPoint = topLeft.clone().snapToGrid(gridSize)\n\t\tconst delta = Vec.Sub(topLeft, gridSnappedPoint)\n\t\teditor.updateShapes(\n\t\t\teditor.getSelectedShapes().map((shape) => {\n\t\t\t\tconst newPoint = { x: shape.x! - delta.x, y: shape.y! - delta.y }\n\t\t\t\treturn {\n\t\t\t\t\tid: shape.id,\n\t\t\t\t\ttype: shape.type,\n\t\t\t\t\tx: newPoint.x,\n\t\t\t\t\ty: newPoint.y,\n\t\t\t\t}\n\t\t\t})\n\t\t)\n\t}\n\t// Zoom out to fit the shapes, if necessary\n\tselectionPageBounds = editor.getSelectionPageBounds()\n\tif (selectionPageBounds && !viewportPageBounds.contains(selectionPageBounds)) {\n\t\teditor.zoomToSelection({ animation: { duration: editor.options.animationMediumMs } })\n\t}\n}\n\n/** @public */\nexport function createEmptyBookmarkShape(\n\teditor: Editor,\n\turl: string,\n\tposition: VecLike\n): TLBookmarkShape {\n\tconst partial: TLShapePartial = {\n\t\tid: createShapeId(),\n\t\ttype: 'bookmark',\n\t\tx: position.x - 150,\n\t\ty: position.y - 160,\n\t\topacity: 1,\n\t\tprops: {\n\t\t\tassetId: null,\n\t\t\turl,\n\t\t},\n\t}\n\n\teditor.run(() => {\n\t\t// Allow this to trigger the max shapes reached alert\n\t\teditor.createShape(partial)\n\t\tif (!editor.getShape(partial.id)) return\n\t\teditor.select(partial.id)\n\t\tcenterSelectionAroundPoint(editor, position)\n\t})\n\n\treturn editor.getShape(partial.id) as TLBookmarkShape\n}\n\n/**\n * Checks if a file is allowed to be uploaded. If it is not, it will show a toast explaining why to the user.\n *\n * @param file - The file to check\n * @param options - The options for the external content handler\n * @returns True if the file is allowed, false otherwise\n * @public\n */\nexport function notifyIfFileNotAllowed(file: File, options: TLDefaultExternalContentHandlerOpts) {\n\tconst {\n\t\tacceptedImageMimeTypes = DEFAULT_SUPPORTED_IMAGE_TYPES,\n\t\tacceptedVideoMimeTypes = DEFAULT_SUPPORT_VIDEO_TYPES,\n\t\tmaxAssetSize = DEFAULT_MAX_ASSET_SIZE,\n\t\ttoasts,\n\t\tmsg,\n\t} = options\n\tconst isImageType = acceptedImageMimeTypes.includes(file.type)\n\tconst isVideoType = acceptedVideoMimeTypes.includes(file.type)\n\n\tif (!isImageType && !isVideoType) {\n\t\ttoasts.addToast({\n\t\t\ttitle: msg('assets.files.type-not-allowed'),\n\t\t\tseverity: 'error',\n\t\t})\n\t\treturn false\n\t}\n\n\tif (file.size > maxAssetSize) {\n\t\tconst formatBytes = (bytes: number): string => {\n\t\t\tif (bytes === 0) return '0 bytes'\n\n\t\t\tconst units = ['bytes', 'KB', 'MB', 'GB', 'TB', 'PB']\n\t\t\tconst base = 1024\n\t\t\tconst unitIndex = Math.floor(Math.log(bytes) / Math.log(base))\n\n\t\t\tconst value = bytes / Math.pow(base, unitIndex)\n\t\t\tconst formatted = value % 1 === 0 ? value.toString() : value.toFixed(1)\n\n\t\t\treturn `${formatted} ${units[unitIndex]}`\n\t\t}\n\n\t\ttoasts.addToast({\n\t\t\ttitle: msg('assets.files.size-too-big'),\n\t\t\tdescription: msg('assets.files.maximum-size').replace('{size}', formatBytes(maxAssetSize)),\n\t\t\tseverity: 'error',\n\t\t})\n\t\treturn false\n\t}\n\n\t// Use mime type instead of file ext, this is because\n\t// window.navigator.clipboard does not preserve file names\n\t// of copied files.\n\tif (!file.type) {\n\t\ttoasts.addToast({\n\t\t\ttitle: msg('assets.files.upload-failed'),\n\t\t\tseverity: 'error',\n\t\t})\n\t\tconsole.error('No mime type')\n\t\treturn false\n\t}\n\n\treturn true\n}\n\n/** @public */\nexport async function getAssetInfo(\n\tfile: File,\n\toptions: TLDefaultExternalContentHandlerOpts,\n\tassetId?: TLAssetId\n) {\n\tconst {\n\t\tacceptedImageMimeTypes = DEFAULT_SUPPORTED_IMAGE_TYPES,\n\t\tacceptedVideoMimeTypes = DEFAULT_SUPPORT_VIDEO_TYPES,\n\t\tmaxImageDimension = DEFAULT_MAX_IMAGE_DIMENSION,\n\t} = options\n\n\tconst isImageType = acceptedImageMimeTypes.includes(file.type)\n\tconst isVideoType = acceptedVideoMimeTypes.includes(file.type)\n\tconst hash = getHashForBuffer(await file.arrayBuffer())\n\tassetId ??= AssetRecordType.createId(hash)\n\tconst assetInfo = await getMediaAssetInfoPartial(\n\t\tfile,\n\t\tassetId,\n\t\tisImageType,\n\t\tisVideoType,\n\t\tmaxImageDimension\n\t)\n\treturn assetInfo\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBA8BO;AAEP,uBAAsC;AAEtC,kBAAoD;AACpD,qCAAsD;AAGtD,oBAA+B;AAC/B,kCAAqC;AACrC,sBAAuC;AACvC,kBAAmD;AAM5C,MAAM,8BAA8B;AAKpC,MAAM,yBAAyB,KAAK,OAAO;AAiC3C,SAAS,uCACf,QACA,SACC;AAED,SAAO,6BAA6B,QAAQ,OAAO,kBAAkB;AACpE,WAAO,+BAA+B,QAAQ,eAAe,OAAO;AAAA,EACrE,CAAC;AAGD,SAAO,6BAA6B,OAAO,OAAO,kBAAkB;AACnE,WAAO,8BAA8B,QAAQ,eAAe,OAAO;AAAA,EACpE,CAAC;AAGD,SAAO,+BAA+B,YAAY,OAAO,oBAAoB;AAC5E,WAAO,oCAAoC,QAAQ,eAAe;AAAA,EACnE,CAAC;AAGD,SAAO,+BAAyD,SAAS,CAAC,oBAAoB;AAC7F,WAAO,kCAAkC,QAAQ,eAAe;AAAA,EACjE,CAAC;AAGD,SAAO,+BAA+B,SAAS,OAAO,oBAAoB;AACzE,WAAO,iCAAiC,QAAQ,iBAAiB,OAAO;AAAA,EACzE,CAAC;AAGD,SAAO,+BAA+B,gBAAgB,OAAO,oBAAoB;AAChF,WAAO,wC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AAA,IACX,CAAC;AACD,YAAQ,MAAM,cAAc;AAC5B,WAAO;AAAA,EACR;AAEA,SAAO;AACR;AAGA,eAAsB,aACrB,MACA,SACA,SACC;AACD,QAAM;AAAA,IACL,yBAAyB;AAAA,IACzB,yBAAyB;AAAA,IACzB,oBAAoB;AAAA,EACrB,IAAI;AAEJ,QAAM,cAAc,uBAAuB,SAAS,KAAK,IAAI;AAC7D,QAAM,cAAc,uBAAuB,SAAS,KAAK,IAAI;AAC7D,QAAM,WAAO,gCAAiB,MAAM,KAAK,YAAY,CAAC;AACtD,cAAY,8BAAgB,SAAS,IAAI;AACzC,QAAM,YAAY,MAAM;AAAA,IACvB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACA,SAAO;AACR;",
|
|
6
6
|
"names": ["size"]
|
|
7
7
|
}
|
|
@@ -43,10 +43,15 @@ function registerDefaultSideEffects(editor) {
|
|
|
43
43
|
const shape = editor.getEditingShape();
|
|
44
44
|
if (shape && shape.type === "text" && editor.isInAny("text.pointing", "select.resizing") && editor.getInstanceState().isToolLocked) {
|
|
45
45
|
editor.setCurrentTool("select.editing_shape", {
|
|
46
|
+
target: "shape",
|
|
47
|
+
shape,
|
|
46
48
|
isCreatingTextWhileToolLocked: true
|
|
47
49
|
});
|
|
48
50
|
} else {
|
|
49
|
-
editor.setCurrentTool("select.editing_shape"
|
|
51
|
+
editor.setCurrentTool("select.editing_shape", {
|
|
52
|
+
target: "shape",
|
|
53
|
+
shape
|
|
54
|
+
});
|
|
50
55
|
}
|
|
51
56
|
}
|
|
52
57
|
} else if (prev.editingShapeId && !next.editingShapeId) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/lib/defaultSideEffects.ts"],
|
|
4
|
-
"sourcesContent": ["import { Editor } from '@tldraw/editor'\n\n/** @public */\nexport function registerDefaultSideEffects(editor: Editor) {\n\treturn editor.sideEffects.register({\n\t\tinstance_page_state: {\n\t\t\tafterChange: (prev, next) => {\n\t\t\t\tif (prev.croppingShapeId !== next.croppingShapeId) {\n\t\t\t\t\tconst isInCroppingState = editor.isIn('select.crop')\n\t\t\t\t\tif (!prev.croppingShapeId && next.croppingShapeId) {\n\t\t\t\t\t\tif (!isInCroppingState) {\n\t\t\t\t\t\t\teditor.setCurrentTool('select.crop.idle')\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (prev.croppingShapeId && !next.croppingShapeId) {\n\t\t\t\t\t\tif (isInCroppingState) {\n\t\t\t\t\t\t\teditor.setCurrentTool('select.idle')\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (prev.editingShapeId !== next.editingShapeId) {\n\t\t\t\t\tif (!prev.editingShapeId && next.editingShapeId) {\n\t\t\t\t\t\tif (!editor.isIn('select.editing_shape')) {\n\t\t\t\t\t\t\t// Here's where we handle the special tool locking case for text\n\t\t\t\t\t\t\t// If tool lock is enabled, and we just finished editing a text\n\t\t\t\t\t\t\t// shape and are setting that shape as the new editing shape,\n\t\t\t\t\t\t\t// then create the shape with a flag that will let it know to\n\t\t\t\t\t\t\t// go back to the text tool once the edit is complete.\n\t\t\t\t\t\t\tconst shape = editor.getEditingShape()\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tshape &&\n\t\t\t\t\t\t\t\tshape.type === 'text' &&\n\t\t\t\t\t\t\t\teditor.isInAny('text.pointing', 'select.resizing') &&\n\t\t\t\t\t\t\t\teditor.getInstanceState().isToolLocked\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\teditor.setCurrentTool('select.editing_shape', {\n\t\t\t\t\t\t\t\t\tisCreatingTextWhileToolLocked: true,\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\teditor.setCurrentTool('select.editing_shape')\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (prev.editingShapeId && !next.editingShapeId) {\n\t\t\t\t\t\tif (editor.isIn('select.editing_shape')) {\n\t\t\t\t\t\t\teditor.setCurrentTool('select.idle')\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})\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,SAAS,2BAA2B,QAAgB;AAC1D,SAAO,OAAO,YAAY,SAAS;AAAA,IAClC,qBAAqB;AAAA,MACpB,aAAa,CAAC,MAAM,SAAS;AAC5B,YAAI,KAAK,oBAAoB,KAAK,iBAAiB;AAClD,gBAAM,oBAAoB,OAAO,KAAK,aAAa;AACnD,cAAI,CAAC,KAAK,mBAAmB,KAAK,iBAAiB;AAClD,gBAAI,CAAC,mBAAmB;AACvB,qBAAO,eAAe,kBAAkB;AAAA,YACzC;AAAA,UACD,WAAW,KAAK,mBAAmB,CAAC,KAAK,iBAAiB;AACzD,gBAAI,mBAAmB;AACtB,qBAAO,eAAe,aAAa;AAAA,YACpC;AAAA,UACD;AAAA,QACD;AAEA,YAAI,KAAK,mBAAmB,KAAK,gBAAgB;AAChD,cAAI,CAAC,KAAK,kBAAkB,KAAK,gBAAgB;AAChD,gBAAI,CAAC,OAAO,KAAK,sBAAsB,GAAG;AAMzC,oBAAM,QAAQ,OAAO,gBAAgB;AACrC,kBACC,SACA,MAAM,SAAS,UACf,OAAO,QAAQ,iBAAiB,iBAAiB,KACjD,OAAO,iBAAiB,EAAE,cACzB;AACD,uBAAO,eAAe,wBAAwB;AAAA,kBAC7C,+BAA+B;AAAA,gBAChC,CAAC;AAAA,cACF,OAAO;AACN,uBAAO,eAAe,
|
|
4
|
+
"sourcesContent": ["import { Editor } from '@tldraw/editor'\n\n/** @public */\nexport function registerDefaultSideEffects(editor: Editor) {\n\treturn editor.sideEffects.register({\n\t\tinstance_page_state: {\n\t\t\tafterChange: (prev, next) => {\n\t\t\t\tif (prev.croppingShapeId !== next.croppingShapeId) {\n\t\t\t\t\tconst isInCroppingState = editor.isIn('select.crop')\n\t\t\t\t\tif (!prev.croppingShapeId && next.croppingShapeId) {\n\t\t\t\t\t\tif (!isInCroppingState) {\n\t\t\t\t\t\t\teditor.setCurrentTool('select.crop.idle')\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (prev.croppingShapeId && !next.croppingShapeId) {\n\t\t\t\t\t\tif (isInCroppingState) {\n\t\t\t\t\t\t\teditor.setCurrentTool('select.idle')\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (prev.editingShapeId !== next.editingShapeId) {\n\t\t\t\t\tif (!prev.editingShapeId && next.editingShapeId) {\n\t\t\t\t\t\tif (!editor.isIn('select.editing_shape')) {\n\t\t\t\t\t\t\t// Here's where we handle the special tool locking case for text\n\t\t\t\t\t\t\t// If tool lock is enabled, and we just finished editing a text\n\t\t\t\t\t\t\t// shape and are setting that shape as the new editing shape,\n\t\t\t\t\t\t\t// then create the shape with a flag that will let it know to\n\t\t\t\t\t\t\t// go back to the text tool once the edit is complete.\n\t\t\t\t\t\t\tconst shape = editor.getEditingShape()\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tshape &&\n\t\t\t\t\t\t\t\tshape.type === 'text' &&\n\t\t\t\t\t\t\t\teditor.isInAny('text.pointing', 'select.resizing') &&\n\t\t\t\t\t\t\t\teditor.getInstanceState().isToolLocked\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\teditor.setCurrentTool('select.editing_shape', {\n\t\t\t\t\t\t\t\t\ttarget: 'shape',\n\t\t\t\t\t\t\t\t\tshape: shape,\n\t\t\t\t\t\t\t\t\tisCreatingTextWhileToolLocked: true,\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\teditor.setCurrentTool('select.editing_shape', {\n\t\t\t\t\t\t\t\t\ttarget: 'shape',\n\t\t\t\t\t\t\t\t\tshape: shape,\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} else if (prev.editingShapeId && !next.editingShapeId) {\n\t\t\t\t\t\tif (editor.isIn('select.editing_shape')) {\n\t\t\t\t\t\t\teditor.setCurrentTool('select.idle')\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})\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,SAAS,2BAA2B,QAAgB;AAC1D,SAAO,OAAO,YAAY,SAAS;AAAA,IAClC,qBAAqB;AAAA,MACpB,aAAa,CAAC,MAAM,SAAS;AAC5B,YAAI,KAAK,oBAAoB,KAAK,iBAAiB;AAClD,gBAAM,oBAAoB,OAAO,KAAK,aAAa;AACnD,cAAI,CAAC,KAAK,mBAAmB,KAAK,iBAAiB;AAClD,gBAAI,CAAC,mBAAmB;AACvB,qBAAO,eAAe,kBAAkB;AAAA,YACzC;AAAA,UACD,WAAW,KAAK,mBAAmB,CAAC,KAAK,iBAAiB;AACzD,gBAAI,mBAAmB;AACtB,qBAAO,eAAe,aAAa;AAAA,YACpC;AAAA,UACD;AAAA,QACD;AAEA,YAAI,KAAK,mBAAmB,KAAK,gBAAgB;AAChD,cAAI,CAAC,KAAK,kBAAkB,KAAK,gBAAgB;AAChD,gBAAI,CAAC,OAAO,KAAK,sBAAsB,GAAG;AAMzC,oBAAM,QAAQ,OAAO,gBAAgB;AACrC,kBACC,SACA,MAAM,SAAS,UACf,OAAO,QAAQ,iBAAiB,iBAAiB,KACjD,OAAO,iBAAiB,EAAE,cACzB;AACD,uBAAO,eAAe,wBAAwB;AAAA,kBAC7C,QAAQ;AAAA,kBACR;AAAA,kBACA,+BAA+B;AAAA,gBAChC,CAAC;AAAA,cACF,OAAO;AACN,uBAAO,eAAe,wBAAwB;AAAA,kBAC7C,QAAQ;AAAA,kBACR;AAAA,gBACD,CAAC;AAAA,cACF;AAAA,YACD;AAAA,UACD,WAAW,KAAK,kBAAkB,CAAC,KAAK,gBAAgB;AACvD,gBAAI,OAAO,KAAK,sBAAsB,GAAG;AACxC,qBAAO,eAAe,aAAa;AAAA,YACpC;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAAA,EACD,CAAC;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -33,6 +33,7 @@ var import_ShapeFill = require("../shared/ShapeFill");
|
|
|
33
33
|
var import_default_shape_constants = require("../shared/default-shape-constants");
|
|
34
34
|
var import_defaultStyleDefs = require("../shared/defaultStyleDefs");
|
|
35
35
|
var import_useDefaultColorTheme = require("../shared/useDefaultColorTheme");
|
|
36
|
+
var import_useEfficientZoomThreshold = require("../shared/useEfficientZoomThreshold");
|
|
36
37
|
var import_ArrowPath = require("./ArrowPath");
|
|
37
38
|
var import_arrowLabel = require("./arrowLabel");
|
|
38
39
|
var import_arrowTargetState = require("./arrowTargetState");
|
|
@@ -75,8 +76,13 @@ class ArrowShapeUtil extends import_editor.ShapeUtil {
|
|
|
75
76
|
elbowMinSegmentLengthToShowMidpointHandle: 20,
|
|
76
77
|
hoverPreciseTimeout: 600,
|
|
77
78
|
pointingPreciseTimeout: 320,
|
|
78
|
-
shouldBeExact
|
|
79
|
-
|
|
79
|
+
shouldBeExact(editor) {
|
|
80
|
+
return editor.inputs.getAltKey();
|
|
81
|
+
},
|
|
82
|
+
shouldIgnoreTargets(editor) {
|
|
83
|
+
return editor.inputs.getCtrlKey();
|
|
84
|
+
},
|
|
85
|
+
showTextOutline: true
|
|
80
86
|
};
|
|
81
87
|
canEdit() {
|
|
82
88
|
return true;
|
|
@@ -204,7 +210,7 @@ class ArrowShapeUtil extends import_editor.ShapeUtil {
|
|
|
204
210
|
const shapePageTransform = this.editor.getShapePageTransform(shape.id);
|
|
205
211
|
const segmentStart = shapePageTransform.applyToPoint(info.route.midpointHandle.segmentStart);
|
|
206
212
|
const segmentEnd = shapePageTransform.applyToPoint(info.route.midpointHandle.segmentEnd);
|
|
207
|
-
const segmentLength = import_editor.Vec.Dist(segmentStart, segmentEnd) * this.editor.
|
|
213
|
+
const segmentLength = import_editor.Vec.Dist(segmentStart, segmentEnd) * this.editor.getEfficientZoomLevel();
|
|
208
214
|
if (segmentLength > this.options.elbowMinSegmentLengthToShowMidpointHandle) {
|
|
209
215
|
handles.push({
|
|
210
216
|
id: "middle" /* Middle */,
|
|
@@ -276,7 +282,7 @@ class ArrowShapeUtil extends import_editor.ShapeUtil {
|
|
|
276
282
|
shapeToPageTransform.applyToPoint(axis.v(midRange.hi, 0)),
|
|
277
283
|
angle
|
|
278
284
|
);
|
|
279
|
-
const maxSnapDistance = this.options.elbowMidpointSnapDistance / this.editor.
|
|
285
|
+
const maxSnapDistance = this.options.elbowMidpointSnapDistance / this.editor.getEfficientZoomLevel();
|
|
280
286
|
const midPoint = (0, import_elbowArrowSnapLines.perpDistanceToLineAngle)(
|
|
281
287
|
shapeToPageTransform.applyToPoint(axis.v((0, import_editor.lerp)(midRange.lo, midRange.hi, 0.5), 0)),
|
|
282
288
|
angle
|
|
@@ -601,6 +607,7 @@ class ArrowShapeUtil extends import_editor.ShapeUtil {
|
|
|
601
607
|
textWidth: labelPosition.box.w - import_default_shape_constants.ARROW_LABEL_PADDING * 2 * shape.props.scale,
|
|
602
608
|
isSelected,
|
|
603
609
|
padding: 0,
|
|
610
|
+
showTextOutline: this.options.showTextOutline,
|
|
604
611
|
style: {
|
|
605
612
|
transform: `translate(${labelPosition.box.center.x}px, ${labelPosition.box.center.y}px)`
|
|
606
613
|
}
|
|
@@ -727,7 +734,7 @@ class ArrowShapeUtil extends import_editor.ShapeUtil {
|
|
|
727
734
|
richText: shape.props.richText,
|
|
728
735
|
bounds: (0, import_arrowLabel.getArrowLabelPosition)(this.editor, shape).box.clone().expandBy(-import_default_shape_constants.ARROW_LABEL_PADDING * shape.props.scale),
|
|
729
736
|
padding: 0,
|
|
730
|
-
showTextOutline:
|
|
737
|
+
showTextOutline: this.options.showTextOutline
|
|
731
738
|
}
|
|
732
739
|
)
|
|
733
740
|
] });
|
|
@@ -773,13 +780,7 @@ const ArrowSvg = (0, import_editor.track)(function ArrowSvg2({
|
|
|
773
780
|
const editor = (0, import_editor.useEditor)();
|
|
774
781
|
const theme = (0, import_useDefaultColorTheme.useDefaultColorTheme)();
|
|
775
782
|
const info = (0, import_shared.getArrowInfo)(editor, shape);
|
|
776
|
-
const isForceSolid = (0,
|
|
777
|
-
"force solid",
|
|
778
|
-
() => {
|
|
779
|
-
return editor.getZoomLevel() < 0.2;
|
|
780
|
-
},
|
|
781
|
-
[editor]
|
|
782
|
-
);
|
|
783
|
+
const isForceSolid = (0, import_useEfficientZoomThreshold.useEfficientZoomThreshold)(shape.props.scale * 0.25);
|
|
783
784
|
const clipPathId = (0, import_editor.useSharedSafeId)(shape.id + "_clip");
|
|
784
785
|
const arrowheadDotId = (0, import_editor.useSharedSafeId)("arrowhead-dot");
|
|
785
786
|
const arrowheadCrossId = (0, import_editor.useSharedSafeId)("arrowhead-cross");
|
|
@@ -800,7 +801,7 @@ const ArrowSvg = (0, import_editor.track)(function ArrowSvg2({
|
|
|
800
801
|
start: "skip",
|
|
801
802
|
end: "skip",
|
|
802
803
|
lengthRatio: 2.5,
|
|
803
|
-
strokeWidth: 2 / editor.
|
|
804
|
+
strokeWidth: 2 / editor.getEfficientZoomLevel(),
|
|
804
805
|
props: {
|
|
805
806
|
className: "tl-arrow-hint",
|
|
806
807
|
markerStart: bindings.start ? bindings.start.props.isExact ? "" : bindings.start.props.isPrecise ? `url(#${arrowheadCrossId})` : `url(#${arrowheadDotId})` : "",
|