@bigbluebutton/tldraw 2.0.0-alpha.34 → 2.0.0-alpha.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-cjs/index.js +4 -4
- package/dist-cjs/index.js.map +1 -1
- package/dist-cjs/lib/Tldraw.js +1 -2
- package/dist-cjs/lib/Tldraw.js.map +1 -1
- package/dist-cjs/lib/canvas/TldrawHandles.js +1 -2
- package/dist-cjs/lib/canvas/TldrawHandles.js.map +1 -1
- package/dist-cjs/lib/canvas/TldrawHoveredShapeIndicator.js +1 -2
- package/dist-cjs/lib/canvas/TldrawHoveredShapeIndicator.js.map +1 -1
- package/dist-cjs/lib/canvas/TldrawScribble.js +1 -2
- package/dist-cjs/lib/canvas/TldrawScribble.js.map +1 -1
- package/dist-cjs/lib/canvas/TldrawSelectionBackground.js +1 -2
- package/dist-cjs/lib/canvas/TldrawSelectionBackground.js.map +1 -1
- package/dist-cjs/lib/canvas/TldrawSelectionForeground.js +1 -2
- package/dist-cjs/lib/canvas/TldrawSelectionForeground.js.map +1 -1
- package/dist-cjs/lib/defaultExternalContentHandlers.js +3 -6
- package/dist-cjs/lib/defaultExternalContentHandlers.js.map +1 -1
- package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js +7 -14
- package/dist-cjs/lib/shapes/arrow/ArrowShapeUtil.js.map +1 -1
- package/dist-cjs/lib/shapes/arrow/toolStates/Idle.js +1 -2
- package/dist-cjs/lib/shapes/arrow/toolStates/Idle.js.map +1 -1
- package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.js +6 -12
- package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.js.map +1 -1
- package/dist-cjs/lib/shapes/draw/toolStates/Drawing.js +12 -24
- package/dist-cjs/lib/shapes/draw/toolStates/Drawing.js.map +1 -1
- package/dist-cjs/lib/shapes/embed/EmbedShapeUtil.js +1 -2
- package/dist-cjs/lib/shapes/embed/EmbedShapeUtil.js.map +1 -1
- package/dist-cjs/lib/shapes/frame/FrameShapeTool.js +4 -8
- package/dist-cjs/lib/shapes/frame/FrameShapeTool.js.map +1 -1
- package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js +3 -6
- package/dist-cjs/lib/shapes/frame/FrameShapeUtil.js.map +1 -1
- package/dist-cjs/lib/shapes/frame/components/FrameHeading.js +1 -2
- package/dist-cjs/lib/shapes/frame/components/FrameHeading.js.map +1 -1
- package/dist-cjs/lib/shapes/frame/components/FrameLabelInput.js +4 -8
- package/dist-cjs/lib/shapes/frame/components/FrameLabelInput.js.map +1 -1
- package/dist-cjs/lib/shapes/geo/toolStates/Idle.js +1 -2
- package/dist-cjs/lib/shapes/geo/toolStates/Idle.js.map +1 -1
- package/dist-cjs/lib/shapes/geo/toolStates/Pointing.js +2 -4
- package/dist-cjs/lib/shapes/geo/toolStates/Pointing.js.map +1 -1
- package/dist-cjs/lib/shapes/image/ImageShapeUtil.js +5 -10
- package/dist-cjs/lib/shapes/image/ImageShapeUtil.js.map +1 -1
- package/dist-cjs/lib/shapes/line/components/svg.js +1 -2
- package/dist-cjs/lib/shapes/line/components/svg.js.map +1 -1
- package/dist-cjs/lib/shapes/line/toolStates/Pointing.js +5 -10
- package/dist-cjs/lib/shapes/line/toolStates/Pointing.js.map +1 -1
- package/dist-cjs/lib/shapes/poll/components/CustomizedAxisTick.js +1 -2
- package/dist-cjs/lib/shapes/poll/components/CustomizedAxisTick.js.map +1 -1
- package/dist-cjs/lib/shapes/poll/components/poll-content.js +1 -2
- package/dist-cjs/lib/shapes/poll/components/poll-content.js.map +1 -1
- package/dist-cjs/lib/shapes/shared/TextHelpers.js +2 -4
- package/dist-cjs/lib/shapes/shared/TextHelpers.js.map +1 -1
- package/dist-cjs/lib/shapes/shared/createTextSvgElementFromSpans.js +1 -2
- package/dist-cjs/lib/shapes/shared/createTextSvgElementFromSpans.js.map +1 -1
- package/dist-cjs/lib/shapes/shared/defaultStyleDefs.js +8 -16
- package/dist-cjs/lib/shapes/shared/defaultStyleDefs.js.map +1 -1
- package/dist-cjs/lib/shapes/shared/freehand/getStrokePoints.js +6 -12
- package/dist-cjs/lib/shapes/shared/freehand/getStrokePoints.js.map +1 -1
- package/dist-cjs/lib/shapes/shared/freehand/setStrokePointRadii.js +1 -2
- package/dist-cjs/lib/shapes/shared/freehand/setStrokePointRadii.js.map +1 -1
- package/dist-cjs/lib/shapes/shared/freehand/svgInk.js +2 -4
- package/dist-cjs/lib/shapes/shared/freehand/svgInk.js.map +1 -1
- package/dist-cjs/lib/shapes/shared/useEditableText.js +5 -10
- package/dist-cjs/lib/shapes/shared/useEditableText.js.map +1 -1
- package/dist-cjs/lib/shapes/text/TextShapeUtil.js +6 -12
- package/dist-cjs/lib/shapes/text/TextShapeUtil.js.map +1 -1
- package/dist-cjs/lib/shapes/text/toolStates/Idle.js +1 -2
- package/dist-cjs/lib/shapes/text/toolStates/Idle.js.map +1 -1
- package/dist-cjs/lib/shapes/text/toolStates/Pointing.js +1 -2
- package/dist-cjs/lib/shapes/text/toolStates/Pointing.js.map +1 -1
- package/dist-cjs/lib/shapes/video/VideoShapeUtil.js +2 -4
- package/dist-cjs/lib/shapes/video/VideoShapeUtil.js.map +1 -1
- package/dist-cjs/lib/tools/EraserTool/childStates/Erasing.js +2 -4
- package/dist-cjs/lib/tools/EraserTool/childStates/Erasing.js.map +1 -1
- package/dist-cjs/lib/tools/SelectTool/DragAndDropManager.js +1 -2
- package/dist-cjs/lib/tools/SelectTool/DragAndDropManager.js.map +1 -1
- package/dist-cjs/lib/tools/SelectTool/childStates/Brushing.js +25 -30
- package/dist-cjs/lib/tools/SelectTool/childStates/Brushing.js.map +1 -1
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/Idle.js +12 -24
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/Idle.js.map +1 -1
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.js +1 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.js.map +1 -1
- package/dist-cjs/lib/tools/SelectTool/childStates/Cropping.js +8 -16
- package/dist-cjs/lib/tools/SelectTool/childStates/Cropping.js.map +1 -1
- package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js +3 -6
- package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js.map +1 -1
- package/dist-cjs/lib/tools/SelectTool/childStates/EditingShape.js +2 -4
- package/dist-cjs/lib/tools/SelectTool/childStates/EditingShape.js.map +1 -1
- package/dist-cjs/lib/tools/SelectTool/childStates/Idle.js +21 -42
- package/dist-cjs/lib/tools/SelectTool/childStates/Idle.js.map +1 -1
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingCropHandle.js +1 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingCropHandle.js.map +1 -1
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingSelection.js +1 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingSelection.js.map +1 -1
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingShape.js +1 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingShape.js.map +1 -1
- package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js +5 -10
- package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js.map +1 -1
- package/dist-cjs/lib/tools/SelectTool/childStates/Rotating.js +2 -4
- package/dist-cjs/lib/tools/SelectTool/childStates/Rotating.js.map +1 -1
- package/dist-cjs/lib/tools/SelectTool/childStates/ScribbleBrushing.js +1 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/ScribbleBrushing.js.map +1 -1
- package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js +4 -8
- package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js.map +1 -1
- package/dist-cjs/lib/tools/SelectTool/children/DraggingHandle.js +3 -6
- package/dist-cjs/lib/tools/SelectTool/children/DraggingHandle.js.map +1 -1
- package/dist-cjs/lib/tools/selection-logic/updateHoveredId.js +1 -2
- package/dist-cjs/lib/tools/selection-logic/updateHoveredId.js.map +1 -1
- package/dist-cjs/lib/ui/assetUrls.js +1 -2
- package/dist-cjs/lib/ui/assetUrls.js.map +1 -1
- package/dist-cjs/lib/ui/components/ActionsMenu.js +2 -4
- package/dist-cjs/lib/ui/components/ActionsMenu.js.map +1 -1
- package/dist-cjs/lib/ui/components/BackToContent.js +1 -2
- package/dist-cjs/lib/ui/components/BackToContent.js.map +1 -1
- package/dist-cjs/lib/ui/components/ContextMenu.js +3 -6
- package/dist-cjs/lib/ui/components/ContextMenu.js.map +1 -1
- package/dist-cjs/lib/ui/components/DebugPanel.js +2 -4
- package/dist-cjs/lib/ui/components/DebugPanel.js.map +1 -1
- package/dist-cjs/lib/ui/components/EditLinkDialog.js +2 -4
- package/dist-cjs/lib/ui/components/EditLinkDialog.js.map +1 -1
- package/dist-cjs/lib/ui/components/EmbedDialog.js +1 -2
- package/dist-cjs/lib/ui/components/EmbedDialog.js.map +1 -1
- package/dist-cjs/lib/ui/components/FollowingIndicator.js +2 -4
- package/dist-cjs/lib/ui/components/FollowingIndicator.js.map +1 -1
- package/dist-cjs/lib/ui/components/HelpMenu.js +2 -4
- package/dist-cjs/lib/ui/components/HelpMenu.js.map +1 -1
- package/dist-cjs/lib/ui/components/KeyboardShortcutsDialog.js +2 -4
- package/dist-cjs/lib/ui/components/KeyboardShortcutsDialog.js.map +1 -1
- package/dist-cjs/lib/ui/components/Menu.js +5 -10
- package/dist-cjs/lib/ui/components/Menu.js.map +1 -1
- package/dist-cjs/lib/ui/components/NavigationZone/Minimap.js +3 -6
- package/dist-cjs/lib/ui/components/NavigationZone/Minimap.js.map +1 -1
- package/dist-cjs/lib/ui/components/PageMenu/PageMenu.js +5 -10
- package/dist-cjs/lib/ui/components/PageMenu/PageMenu.js.map +1 -1
- package/dist-cjs/lib/ui/components/PenModeToggle.js +1 -2
- package/dist-cjs/lib/ui/components/PenModeToggle.js.map +1 -1
- package/dist-cjs/lib/ui/components/StylePanel/DoubleDropdownPicker.js +1 -2
- package/dist-cjs/lib/ui/components/StylePanel/DoubleDropdownPicker.js.map +1 -1
- package/dist-cjs/lib/ui/components/StylePanel/StylePanel.js +1 -2
- package/dist-cjs/lib/ui/components/StylePanel/StylePanel.js.map +1 -1
- package/dist-cjs/lib/ui/components/Toasts.js +1 -2
- package/dist-cjs/lib/ui/components/Toasts.js.map +1 -1
- package/dist-cjs/lib/ui/components/Toolbar/ToggleToolLockedButton.js +1 -2
- package/dist-cjs/lib/ui/components/Toolbar/ToggleToolLockedButton.js.map +1 -1
- package/dist-cjs/lib/ui/components/TrashButton.js +1 -2
- package/dist-cjs/lib/ui/components/TrashButton.js.map +1 -1
- package/dist-cjs/lib/ui/components/primitives/ButtonPicker.js +2 -4
- package/dist-cjs/lib/ui/components/primitives/ButtonPicker.js.map +1 -1
- package/dist-cjs/lib/ui/components/primitives/Input.js +1 -2
- package/dist-cjs/lib/ui/components/primitives/Input.js.map +1 -1
- package/dist-cjs/lib/ui/components/primitives/Slider.js +1 -2
- package/dist-cjs/lib/ui/components/primitives/Slider.js.map +1 -1
- package/dist-cjs/lib/ui/hooks/clipboard/pasteExcalidrawContent.js +2 -4
- package/dist-cjs/lib/ui/hooks/clipboard/pasteExcalidrawContent.js.map +1 -1
- package/dist-cjs/lib/ui/hooks/menuHelpers.js +5 -10
- package/dist-cjs/lib/ui/hooks/menuHelpers.js.map +1 -1
- package/dist-cjs/lib/ui/hooks/useActions.js +73 -146
- package/dist-cjs/lib/ui/hooks/useActions.js.map +1 -1
- package/dist-cjs/lib/ui/hooks/useClipboardEvents.js +6 -12
- package/dist-cjs/lib/ui/hooks/useClipboardEvents.js.map +1 -1
- package/dist-cjs/lib/ui/hooks/useHighDpiCanvas.js +1 -2
- package/dist-cjs/lib/ui/hooks/useHighDpiCanvas.js.map +1 -1
- package/dist-cjs/lib/ui/hooks/useInsertMedia.js +1 -2
- package/dist-cjs/lib/ui/hooks/useInsertMedia.js.map +1 -1
- package/dist-cjs/lib/ui/hooks/useKeyboardShortcuts.js +8 -16
- package/dist-cjs/lib/ui/hooks/useKeyboardShortcuts.js.map +1 -1
- package/dist-cjs/lib/ui/hooks/useMenuIsOpen.js +1 -2
- package/dist-cjs/lib/ui/hooks/useMenuIsOpen.js.map +1 -1
- package/dist-cjs/lib/ui/hooks/useMenuSchema.js +2 -4
- package/dist-cjs/lib/ui/hooks/useMenuSchema.js.map +1 -1
- package/dist-cjs/lib/ui/hooks/usePreloadAssets.js +2 -4
- package/dist-cjs/lib/ui/hooks/usePreloadAssets.js.map +1 -1
- package/dist-cjs/lib/ui/hooks/usePreloadIcons.js +1 -2
- package/dist-cjs/lib/ui/hooks/usePreloadIcons.js.map +1 -1
- package/dist-cjs/lib/ui/hooks/usePrint.js +2 -4
- package/dist-cjs/lib/ui/hooks/usePrint.js.map +1 -1
- package/dist-cjs/lib/ui/hooks/useRevelantStyles.js +1 -2
- package/dist-cjs/lib/ui/hooks/useRevelantStyles.js.map +1 -1
- package/dist-cjs/lib/utils/assets/is-gif-animated.js +9 -0
- package/dist-cjs/lib/utils/assets/is-gif-animated.js.map +1 -1
- package/dist-cjs/lib/utils/export/export.js +2 -4
- package/dist-cjs/lib/utils/export/export.js.map +1 -1
- package/dist-cjs/lib/utils/export/exportAs.js +1 -2
- package/dist-cjs/lib/utils/export/exportAs.js.map +1 -1
- package/dist-cjs/lib/utils/frames/frames.js +4 -8
- package/dist-cjs/lib/utils/frames/frames.js.map +1 -1
- package/dist-cjs/lib/utils/static-assets/assetUrls.js +1 -2
- package/dist-cjs/lib/utils/static-assets/assetUrls.js.map +1 -1
- package/dist-cjs/lib/utils/tldr/buildFromV1Document.js +10 -20
- package/dist-cjs/lib/utils/tldr/buildFromV1Document.js.map +1 -1
- package/dist-cjs/lib/utils/tldr/file.js +1 -2
- package/dist-cjs/lib/utils/tldr/file.js.map +1 -1
- package/dist-esm/lib/Tldraw.mjs +1 -2
- package/dist-esm/lib/Tldraw.mjs.map +1 -1
- package/dist-esm/lib/canvas/TldrawHandles.mjs +1 -2
- package/dist-esm/lib/canvas/TldrawHandles.mjs.map +1 -1
- package/dist-esm/lib/canvas/TldrawHoveredShapeIndicator.mjs +1 -2
- package/dist-esm/lib/canvas/TldrawHoveredShapeIndicator.mjs.map +1 -1
- package/dist-esm/lib/canvas/TldrawScribble.mjs +1 -2
- package/dist-esm/lib/canvas/TldrawScribble.mjs.map +1 -1
- package/dist-esm/lib/canvas/TldrawSelectionBackground.mjs +1 -2
- package/dist-esm/lib/canvas/TldrawSelectionBackground.mjs.map +1 -1
- package/dist-esm/lib/canvas/TldrawSelectionForeground.mjs +1 -2
- package/dist-esm/lib/canvas/TldrawSelectionForeground.mjs.map +1 -1
- package/dist-esm/lib/defaultExternalContentHandlers.mjs +3 -6
- package/dist-esm/lib/defaultExternalContentHandlers.mjs.map +1 -1
- package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs +7 -14
- package/dist-esm/lib/shapes/arrow/ArrowShapeUtil.mjs.map +1 -1
- package/dist-esm/lib/shapes/arrow/toolStates/Idle.mjs +1 -2
- package/dist-esm/lib/shapes/arrow/toolStates/Idle.mjs.map +1 -1
- package/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs +6 -12
- package/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs.map +1 -1
- package/dist-esm/lib/shapes/draw/toolStates/Drawing.mjs +12 -24
- package/dist-esm/lib/shapes/draw/toolStates/Drawing.mjs.map +1 -1
- package/dist-esm/lib/shapes/embed/EmbedShapeUtil.mjs +1 -2
- package/dist-esm/lib/shapes/embed/EmbedShapeUtil.mjs.map +1 -1
- package/dist-esm/lib/shapes/frame/FrameShapeTool.mjs +4 -8
- package/dist-esm/lib/shapes/frame/FrameShapeTool.mjs.map +1 -1
- package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs +3 -6
- package/dist-esm/lib/shapes/frame/FrameShapeUtil.mjs.map +1 -1
- package/dist-esm/lib/shapes/frame/components/FrameHeading.mjs +1 -2
- package/dist-esm/lib/shapes/frame/components/FrameHeading.mjs.map +1 -1
- package/dist-esm/lib/shapes/frame/components/FrameLabelInput.mjs +4 -8
- package/dist-esm/lib/shapes/frame/components/FrameLabelInput.mjs.map +1 -1
- package/dist-esm/lib/shapes/geo/toolStates/Idle.mjs +1 -2
- package/dist-esm/lib/shapes/geo/toolStates/Idle.mjs.map +1 -1
- package/dist-esm/lib/shapes/geo/toolStates/Pointing.mjs +2 -4
- package/dist-esm/lib/shapes/geo/toolStates/Pointing.mjs.map +1 -1
- package/dist-esm/lib/shapes/image/ImageShapeUtil.mjs +5 -10
- package/dist-esm/lib/shapes/image/ImageShapeUtil.mjs.map +1 -1
- package/dist-esm/lib/shapes/line/components/svg.mjs +1 -2
- package/dist-esm/lib/shapes/line/components/svg.mjs.map +1 -1
- package/dist-esm/lib/shapes/line/toolStates/Pointing.mjs +5 -10
- package/dist-esm/lib/shapes/line/toolStates/Pointing.mjs.map +1 -1
- package/dist-esm/lib/shapes/poll/components/CustomizedAxisTick.mjs +1 -2
- package/dist-esm/lib/shapes/poll/components/CustomizedAxisTick.mjs.map +1 -1
- package/dist-esm/lib/shapes/poll/components/poll-content.mjs +1 -2
- package/dist-esm/lib/shapes/poll/components/poll-content.mjs.map +1 -1
- package/dist-esm/lib/shapes/shared/TextHelpers.mjs +2 -4
- package/dist-esm/lib/shapes/shared/TextHelpers.mjs.map +1 -1
- package/dist-esm/lib/shapes/shared/createTextSvgElementFromSpans.mjs +1 -2
- package/dist-esm/lib/shapes/shared/createTextSvgElementFromSpans.mjs.map +1 -1
- package/dist-esm/lib/shapes/shared/defaultStyleDefs.mjs +8 -16
- package/dist-esm/lib/shapes/shared/defaultStyleDefs.mjs.map +1 -1
- package/dist-esm/lib/shapes/shared/freehand/getStrokePoints.mjs +6 -12
- package/dist-esm/lib/shapes/shared/freehand/getStrokePoints.mjs.map +1 -1
- package/dist-esm/lib/shapes/shared/freehand/setStrokePointRadii.mjs +1 -2
- package/dist-esm/lib/shapes/shared/freehand/setStrokePointRadii.mjs.map +1 -1
- package/dist-esm/lib/shapes/shared/freehand/svgInk.mjs +2 -4
- package/dist-esm/lib/shapes/shared/freehand/svgInk.mjs.map +1 -1
- package/dist-esm/lib/shapes/shared/useEditableText.mjs +5 -10
- package/dist-esm/lib/shapes/shared/useEditableText.mjs.map +1 -1
- package/dist-esm/lib/shapes/text/TextShapeUtil.mjs +6 -12
- package/dist-esm/lib/shapes/text/TextShapeUtil.mjs.map +1 -1
- package/dist-esm/lib/shapes/text/toolStates/Idle.mjs +1 -2
- package/dist-esm/lib/shapes/text/toolStates/Idle.mjs.map +1 -1
- package/dist-esm/lib/shapes/text/toolStates/Pointing.mjs +1 -2
- package/dist-esm/lib/shapes/text/toolStates/Pointing.mjs.map +1 -1
- package/dist-esm/lib/shapes/video/VideoShapeUtil.mjs +2 -4
- package/dist-esm/lib/shapes/video/VideoShapeUtil.mjs.map +1 -1
- package/dist-esm/lib/tools/EraserTool/childStates/Erasing.mjs +2 -4
- package/dist-esm/lib/tools/EraserTool/childStates/Erasing.mjs.map +1 -1
- package/dist-esm/lib/tools/SelectTool/DragAndDropManager.mjs +1 -2
- package/dist-esm/lib/tools/SelectTool/DragAndDropManager.mjs.map +1 -1
- package/dist-esm/lib/tools/SelectTool/childStates/Brushing.mjs +25 -30
- package/dist-esm/lib/tools/SelectTool/childStates/Brushing.mjs.map +1 -1
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/Idle.mjs +12 -24
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/Idle.mjs.map +1 -1
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.mjs +1 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/children/TranslatingCrop.mjs.map +1 -1
- package/dist-esm/lib/tools/SelectTool/childStates/Cropping.mjs +8 -16
- package/dist-esm/lib/tools/SelectTool/childStates/Cropping.mjs.map +1 -1
- package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs +3 -6
- package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs.map +1 -1
- package/dist-esm/lib/tools/SelectTool/childStates/EditingShape.mjs +2 -4
- package/dist-esm/lib/tools/SelectTool/childStates/EditingShape.mjs.map +1 -1
- package/dist-esm/lib/tools/SelectTool/childStates/Idle.mjs +21 -42
- package/dist-esm/lib/tools/SelectTool/childStates/Idle.mjs.map +1 -1
- package/dist-esm/lib/tools/SelectTool/childStates/PointingCropHandle.mjs +1 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingCropHandle.mjs.map +1 -1
- package/dist-esm/lib/tools/SelectTool/childStates/PointingSelection.mjs +1 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingSelection.mjs.map +1 -1
- package/dist-esm/lib/tools/SelectTool/childStates/PointingShape.mjs +1 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingShape.mjs.map +1 -1
- package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs +5 -10
- package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs.map +1 -1
- package/dist-esm/lib/tools/SelectTool/childStates/Rotating.mjs +2 -4
- package/dist-esm/lib/tools/SelectTool/childStates/Rotating.mjs.map +1 -1
- package/dist-esm/lib/tools/SelectTool/childStates/ScribbleBrushing.mjs +1 -2
- package/dist-esm/lib/tools/SelectTool/childStates/ScribbleBrushing.mjs.map +1 -1
- package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs +4 -8
- package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs.map +1 -1
- package/dist-esm/lib/tools/SelectTool/children/DraggingHandle.mjs +3 -6
- package/dist-esm/lib/tools/SelectTool/children/DraggingHandle.mjs.map +1 -1
- package/dist-esm/lib/tools/selection-logic/updateHoveredId.mjs +1 -2
- package/dist-esm/lib/tools/selection-logic/updateHoveredId.mjs.map +1 -1
- package/dist-esm/lib/ui/assetUrls.mjs +1 -2
- package/dist-esm/lib/ui/assetUrls.mjs.map +1 -1
- package/dist-esm/lib/ui/components/ActionsMenu.mjs +2 -4
- package/dist-esm/lib/ui/components/ActionsMenu.mjs.map +1 -1
- package/dist-esm/lib/ui/components/BackToContent.mjs +1 -2
- package/dist-esm/lib/ui/components/BackToContent.mjs.map +1 -1
- package/dist-esm/lib/ui/components/ContextMenu.mjs +3 -6
- package/dist-esm/lib/ui/components/ContextMenu.mjs.map +1 -1
- package/dist-esm/lib/ui/components/DebugPanel.mjs +2 -4
- package/dist-esm/lib/ui/components/DebugPanel.mjs.map +1 -1
- package/dist-esm/lib/ui/components/EditLinkDialog.mjs +2 -4
- package/dist-esm/lib/ui/components/EditLinkDialog.mjs.map +1 -1
- package/dist-esm/lib/ui/components/EmbedDialog.mjs +1 -2
- package/dist-esm/lib/ui/components/EmbedDialog.mjs.map +1 -1
- package/dist-esm/lib/ui/components/FollowingIndicator.mjs +2 -4
- package/dist-esm/lib/ui/components/FollowingIndicator.mjs.map +1 -1
- package/dist-esm/lib/ui/components/HelpMenu.mjs +2 -4
- package/dist-esm/lib/ui/components/HelpMenu.mjs.map +1 -1
- package/dist-esm/lib/ui/components/KeyboardShortcutsDialog.mjs +2 -4
- package/dist-esm/lib/ui/components/KeyboardShortcutsDialog.mjs.map +1 -1
- package/dist-esm/lib/ui/components/Menu.mjs +5 -10
- package/dist-esm/lib/ui/components/Menu.mjs.map +1 -1
- package/dist-esm/lib/ui/components/NavigationZone/Minimap.mjs +3 -6
- package/dist-esm/lib/ui/components/NavigationZone/Minimap.mjs.map +1 -1
- package/dist-esm/lib/ui/components/PageMenu/PageMenu.mjs +5 -10
- package/dist-esm/lib/ui/components/PageMenu/PageMenu.mjs.map +1 -1
- package/dist-esm/lib/ui/components/PenModeToggle.mjs +1 -2
- package/dist-esm/lib/ui/components/PenModeToggle.mjs.map +1 -1
- package/dist-esm/lib/ui/components/StylePanel/DoubleDropdownPicker.mjs +1 -2
- package/dist-esm/lib/ui/components/StylePanel/DoubleDropdownPicker.mjs.map +1 -1
- package/dist-esm/lib/ui/components/StylePanel/StylePanel.mjs +1 -2
- package/dist-esm/lib/ui/components/StylePanel/StylePanel.mjs.map +1 -1
- package/dist-esm/lib/ui/components/Toasts.mjs +1 -2
- package/dist-esm/lib/ui/components/Toasts.mjs.map +1 -1
- package/dist-esm/lib/ui/components/Toolbar/ToggleToolLockedButton.mjs +1 -2
- package/dist-esm/lib/ui/components/Toolbar/ToggleToolLockedButton.mjs.map +1 -1
- package/dist-esm/lib/ui/components/TrashButton.mjs +1 -2
- package/dist-esm/lib/ui/components/TrashButton.mjs.map +1 -1
- package/dist-esm/lib/ui/components/primitives/ButtonPicker.mjs +2 -4
- package/dist-esm/lib/ui/components/primitives/ButtonPicker.mjs.map +1 -1
- package/dist-esm/lib/ui/components/primitives/Input.mjs +1 -2
- package/dist-esm/lib/ui/components/primitives/Input.mjs.map +1 -1
- package/dist-esm/lib/ui/components/primitives/Slider.mjs +1 -2
- package/dist-esm/lib/ui/components/primitives/Slider.mjs.map +1 -1
- package/dist-esm/lib/ui/hooks/clipboard/pasteExcalidrawContent.mjs +2 -4
- package/dist-esm/lib/ui/hooks/clipboard/pasteExcalidrawContent.mjs.map +1 -1
- package/dist-esm/lib/ui/hooks/menuHelpers.mjs +5 -10
- package/dist-esm/lib/ui/hooks/menuHelpers.mjs.map +1 -1
- package/dist-esm/lib/ui/hooks/useActions.mjs +73 -146
- package/dist-esm/lib/ui/hooks/useActions.mjs.map +1 -1
- package/dist-esm/lib/ui/hooks/useClipboardEvents.mjs +6 -12
- package/dist-esm/lib/ui/hooks/useClipboardEvents.mjs.map +1 -1
- package/dist-esm/lib/ui/hooks/useHighDpiCanvas.mjs +1 -2
- package/dist-esm/lib/ui/hooks/useHighDpiCanvas.mjs.map +1 -1
- package/dist-esm/lib/ui/hooks/useInsertMedia.mjs +1 -2
- package/dist-esm/lib/ui/hooks/useInsertMedia.mjs.map +1 -1
- package/dist-esm/lib/ui/hooks/useKeyboardShortcuts.mjs +8 -16
- package/dist-esm/lib/ui/hooks/useKeyboardShortcuts.mjs.map +1 -1
- package/dist-esm/lib/ui/hooks/useMenuIsOpen.mjs +1 -2
- package/dist-esm/lib/ui/hooks/useMenuIsOpen.mjs.map +1 -1
- package/dist-esm/lib/ui/hooks/useMenuSchema.mjs +2 -4
- package/dist-esm/lib/ui/hooks/useMenuSchema.mjs.map +1 -1
- package/dist-esm/lib/ui/hooks/usePreloadAssets.mjs +2 -4
- package/dist-esm/lib/ui/hooks/usePreloadAssets.mjs.map +1 -1
- package/dist-esm/lib/ui/hooks/usePreloadIcons.mjs +1 -2
- package/dist-esm/lib/ui/hooks/usePreloadIcons.mjs.map +1 -1
- package/dist-esm/lib/ui/hooks/usePrint.mjs +2 -4
- package/dist-esm/lib/ui/hooks/usePrint.mjs.map +1 -1
- package/dist-esm/lib/ui/hooks/useRevelantStyles.mjs +1 -2
- package/dist-esm/lib/ui/hooks/useRevelantStyles.mjs.map +1 -1
- package/dist-esm/lib/utils/assets/is-gif-animated.mjs +9 -0
- package/dist-esm/lib/utils/assets/is-gif-animated.mjs.map +1 -1
- package/dist-esm/lib/utils/export/export.mjs +2 -4
- package/dist-esm/lib/utils/export/export.mjs.map +1 -1
- package/dist-esm/lib/utils/export/exportAs.mjs +1 -2
- package/dist-esm/lib/utils/export/exportAs.mjs.map +1 -1
- package/dist-esm/lib/utils/frames/frames.mjs +4 -8
- package/dist-esm/lib/utils/frames/frames.mjs.map +1 -1
- package/dist-esm/lib/utils/static-assets/assetUrls.mjs +1 -2
- package/dist-esm/lib/utils/static-assets/assetUrls.mjs.map +1 -1
- package/dist-esm/lib/utils/tldr/buildFromV1Document.mjs +10 -20
- package/dist-esm/lib/utils/tldr/buildFromV1Document.mjs.map +1 -1
- package/dist-esm/lib/utils/tldr/file.mjs +1 -2
- package/dist-esm/lib/utils/tldr/file.mjs.map +1 -1
- package/package.json +2 -2
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/lib/utils/tldr/file.ts"],
|
|
4
4
|
"sourcesContent": ["import {\n\tEditor,\n\tFileHelpers,\n\tMigrationFailureReason,\n\tMigrationResult,\n\tRecordId,\n\tResult,\n\tSerializedSchema,\n\tSerializedStore,\n\tT,\n\tTLAsset,\n\tTLAssetId,\n\tTLRecord,\n\tTLSchema,\n\tTLStore,\n\tUnknownRecord,\n\tcreateTLStore,\n\texhaustiveSwitchError,\n\tpartition,\n\ttransact,\n} from '@bigbluebutton/editor'\nimport { TLUiToastsContextType } from '../../ui/hooks/useToastsProvider'\nimport { TLUiTranslationKey } from '../../ui/hooks/useTranslation/TLUiTranslationKey'\nimport { buildFromV1Document } from '../tldr/buildFromV1Document'\n\n/** @public */\nexport const TLDRAW_FILE_MIMETYPE = 'application/vnd.tldraw+json' as const\n\n/** @public */\nexport const TLDRAW_FILE_EXTENSION = '.tldr' as const\n\n// When incrementing this, you'll need to update parseTldrawJsonFile to handle\n// both your new changes and the old file format\nconst LATEST_TLDRAW_FILE_FORMAT_VERSION = 1\n\n/** @public */\nexport interface TldrawFile {\n\ttldrawFileFormatVersion: number\n\tschema: SerializedSchema\n\trecords: UnknownRecord[]\n}\n\nconst tldrawFileValidator: T.Validator<TldrawFile> = T.object({\n\ttldrawFileFormatVersion: T.nonZeroInteger,\n\tschema: T.object({\n\t\tschemaVersion: T.positiveInteger,\n\t\tstoreVersion: T.positiveInteger,\n\t\trecordVersions: T.dict(\n\t\t\tT.string,\n\t\t\tT.object({\n\t\t\t\tversion: T.positiveInteger,\n\t\t\t\tsubTypeVersions: T.dict(T.string, T.positiveInteger).optional(),\n\t\t\t\tsubTypeKey: T.string.optional(),\n\t\t\t})\n\t\t),\n\t}),\n\trecords: T.arrayOf(\n\t\tT.object({\n\t\t\tid: T.string as T.Validator<RecordId<any>>,\n\t\t\ttypeName: T.string,\n\t\t}).allowUnknownProperties()\n\t),\n})\n\n/** @public */\nexport function isV1File(data: any) {\n\ttry {\n\t\tif (data.document?.version) {\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t} catch (e) {\n\t\treturn false\n\t}\n}\n\n/** @public */\nexport type TldrawFileParseError =\n\t| { type: 'v1File'; data: any }\n\t| { type: 'notATldrawFile'; cause: unknown }\n\t| { type: 'fileFormatVersionTooNew'; version: number }\n\t| { type: 'migrationFailed'; reason: MigrationFailureReason }\n\t| { type: 'invalidRecords'; cause: unknown }\n\n/** @public */\nexport function parseTldrawJsonFile({\n\tjson,\n\tschema,\n}: {\n\tschema: TLSchema\n\tjson: string\n}): Result<TLStore, TldrawFileParseError> {\n\t// first off, we parse .json file and check it matches the general shape of\n\t// a tldraw file\n\tlet data\n\ttry {\n\t\tdata = tldrawFileValidator.validate(JSON.parse(json))\n\t} catch (e) {\n\t\t// could be a v1 file!\n\t\ttry {\n\t\t\tdata = JSON.parse(json)\n\t\t\tif (isV1File(data)) {\n\t\t\t\treturn Result.err({ type: 'v1File', data })\n\t\t\t}\n\t\t} catch (e) {\n\t\t\t// noop\n\t\t}\n\n\t\treturn Result.err({ type: 'notATldrawFile', cause: e })\n\t}\n\n\t// if the file format version isn't supported, we can't open it - it's\n\t// probably from a newer version of tldraw\n\tif (data.tldrawFileFormatVersion > LATEST_TLDRAW_FILE_FORMAT_VERSION) {\n\t\treturn Result.err({\n\t\t\ttype: 'fileFormatVersionTooNew',\n\t\t\tversion: data.tldrawFileFormatVersion,\n\t\t})\n\t}\n\n\t// even if the file version is up to date, it might contain old-format\n\t// records. lets create a store with the records and migrate it to the\n\t// latest version\n\tlet migrationResult: MigrationResult<SerializedStore<TLRecord>>\n\ttry {\n\t\tconst storeSnapshot = Object.fromEntries(data.records.map((r) => [r.id, r as TLRecord]))\n\t\tmigrationResult = schema.migrateStoreSnapshot({ store: storeSnapshot, schema: data.schema })\n\t} catch (e) {\n\t\t// junk data in the migration\n\t\treturn Result.err({ type: 'invalidRecords', cause: e })\n\t}\n\t// if the migration failed, we can't open the file\n\tif (migrationResult.type === 'error') {\n\t\treturn Result.err({ type: 'migrationFailed', reason: migrationResult.reason })\n\t}\n\n\t// at this stage, the store should have records at the latest versions, so\n\t// we should be able to validate them. if any of the records at this stage\n\t// are invalid, we don't open the file\n\ttry {\n\t\treturn Result.ok(\n\t\t\tcreateTLStore({\n\t\t\t\tinitialData: migrationResult.value,\n\t\t\t\tschema,\n\t\t\t})\n\t\t)\n\t} catch (e) {\n\t\t// junk data in the records (they're not validated yet!) could cause the\n\t\t// migrations to crash. We treat any throw from a migration as an\n\t\t// invalid record\n\t\treturn Result.err({ type: 'invalidRecords', cause: e })\n\t}\n}\n\n/** @public */\nexport async function serializeTldrawJson(store: TLStore): Promise<string> {\n\tconst records: TLRecord[] = []\n\tconst usedAssets = new Set<TLAssetId | null>()\n\tconst assets: TLAsset[] = []\n\tfor (const record of store.allRecords()) {\n\t\tswitch (record.typeName) {\n\t\t\tcase 'asset':\n\t\t\t\tif (\n\t\t\t\t\trecord.type !== 'bookmark' &&\n\t\t\t\t\trecord.props.src &&\n\t\t\t\t\t!record.props.src.startsWith('data:')\n\t\t\t\t) {\n\t\t\t\t\tlet assetSrcToSave\n\t\t\t\t\ttry {\n\t\t\t\t\t\t// try to save the asset as a base64 string\n\t\t\t\t\t\tassetSrcToSave = await FileHelpers.fileToBase64(\n\t\t\t\t\t\t\tawait (await fetch(record.props.src)).blob()\n\t\t\t\t\t\t)\n\t\t\t\t\t} catch {\n\t\t\t\t\t\t// if that fails, just save the original src\n\t\t\t\t\t\tassetSrcToSave = record.props.src\n\t\t\t\t\t}\n\n\t\t\t\t\tassets.push({\n\t\t\t\t\t\t...record,\n\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\t...record.props,\n\t\t\t\t\t\t\tsrc: assetSrcToSave,\n\t\t\t\t\t\t},\n\t\t\t\t\t})\n\t\t\t\t} else {\n\t\t\t\t\tassets.push(record)\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\tcase 'shape':\n\t\t\t\tif ('assetId' in record.props) {\n\t\t\t\t\tusedAssets.add(record.props.assetId)\n\t\t\t\t}\n\t\t\t\trecords.push(record)\n\t\t\t\tbreak\n\t\t\tdefault:\n\t\t\t\trecords.push(record)\n\t\t\t\tbreak\n\t\t}\n\t}\n\tconst recordsToSave = records.concat(assets.filter((a) => usedAssets.has(a.id)))\n\n\treturn JSON.stringify({\n\t\ttldrawFileFormatVersion: LATEST_TLDRAW_FILE_FORMAT_VERSION,\n\t\tschema: store.schema.serialize(),\n\t\trecords: recordsToSave,\n\t})\n}\n\n/** @public */\nexport async function serializeTldrawJsonBlob(store: TLStore): Promise<Blob> {\n\treturn new Blob([await serializeTldrawJson(store)], { type: TLDRAW_FILE_MIMETYPE })\n}\n\n/** @internal */\nexport async function parseAndLoadDocument(\n\teditor: Editor,\n\tdocument: string,\n\tmsg: (id: TLUiTranslationKey | Exclude<string, TLUiTranslationKey>) => string,\n\taddToast: TLUiToastsContextType['addToast'],\n\tonV1FileLoad?: () => void,\n\tforceDarkMode?: boolean\n) {\n\tconst parseFileResult = parseTldrawJsonFile({\n\t\tschema: editor.store.schema,\n\t\tjson: document,\n\t})\n\tif (!parseFileResult.ok) {\n\t\tlet description\n\t\tswitch (parseFileResult.error.type) {\n\t\t\tcase 'notATldrawFile':\n\t\t\t\teditor.annotateError(parseFileResult.error.cause, {\n\t\t\t\t\torigin: 'file-system.open.parse',\n\t\t\t\t\twillCrashApp: false,\n\t\t\t\t\ttags: { parseErrorType: parseFileResult.error.type },\n\t\t\t\t})\n\t\t\t\treportError(parseFileResult.error.cause)\n\t\t\t\tdescription = msg('file-system.file-open-error.not-a-tldraw-file')\n\t\t\t\tbreak\n\t\t\tcase 'fileFormatVersionTooNew':\n\t\t\t\tdescription = msg('file-system.file-open-error.file-format-version-too-new')\n\t\t\t\tbreak\n\t\t\tcase 'migrationFailed':\n\t\t\t\tif (parseFileResult.error.reason === MigrationFailureReason.TargetVersionTooNew) {\n\t\t\t\t\tdescription = msg('file-system.file-open-error.file-format-version-too-new')\n\t\t\t\t} else {\n\t\t\t\t\tdescription = msg('file-system.file-open-error.generic-corrupted-file')\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\tcase 'invalidRecords':\n\t\t\t\teditor.annotateError(parseFileResult.error.cause, {\n\t\t\t\t\torigin: 'file-system.open.parse',\n\t\t\t\t\twillCrashApp: false,\n\t\t\t\t\ttags: { parseErrorType: parseFileResult.error.type },\n\t\t\t\t})\n\t\t\t\treportError(parseFileResult.error.cause)\n\t\t\t\tdescription = msg('file-system.file-open-error.generic-corrupted-file')\n\t\t\t\tbreak\n\t\t\tcase 'v1File': {\n\t\t\t\tbuildFromV1Document(editor, parseFileResult.error.data.document)\n\t\t\t\tonV1FileLoad?.()\n\t\t\t\treturn\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\texhaustiveSwitchError(parseFileResult.error, 'type')\n\t\t}\n\t\taddToast({\n\t\t\ttitle: msg('file-system.file-open-error.title'),\n\t\t\tdescription,\n\t\t})\n\n\t\treturn\n\t}\n\n\t// tldraw file contain the full state of the app,\n\t// including ephemeral data. it up to the opener to\n\t// decide what to restore and what to retain. Here, we\n\t// just restore everything, so if the user has opened\n\t// this file before they'll get their camera etc.\n\t// restored. we could change this in the future.\n\ttransact(() => {\n\t\tconst isFocused = editor.getInstanceState().isFocused\n\t\teditor.store.clear()\n\t\tconst [shapes, nonShapes] = partition(\n\t\t\tparseFileResult.value.allRecords(),\n\t\t\t(record) => record.typeName === 'shape'\n\t\t)\n\t\teditor.store.put(nonShapes, 'initialize')\n\t\teditor.store.ensureStoreIsUsable()\n\t\teditor.store.put(shapes, 'initialize')\n\t\teditor.history.clear()\n\t\teditor.updateViewportScreenBounds()\n\t\teditor.updateRenderingBounds()\n\n\t\tconst bounds = editor.getCurrentPageBounds()\n\t\tif (bounds) {\n\t\t\teditor.zoomToBounds(bounds, 1)\n\t\t}\n\t\teditor.updateInstanceState({ isFocused })\n\t})\n\n\tif (forceDarkMode) editor.user.updateUserPreferences({ isDarkMode: true })\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA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|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/lib/Tldraw.tsx"],
|
|
4
4
|
"sourcesContent": ["import {\n\tCanvas,\n\tEditor,\n\tErrorScreen,\n\tLoadingScreen,\n\tStoreSnapshot,\n\tTLOnMountHandler,\n\tTLRecord,\n\tTLStore,\n\tTLStoreWithStatus,\n\tTldrawEditor,\n\tTldrawEditorBaseProps,\n\tTldrawEditorProps,\n\tassert,\n\tuseEditor,\n\tuseShallowArrayIdentity,\n\tuseShallowObjectIdentity,\n} from '@bigbluebutton/editor'\nimport { useCallback, useDebugValue, useLayoutEffect, useMemo, useRef } from 'react'\nimport { TldrawHandles } from './canvas/TldrawHandles'\nimport { TldrawHoveredShapeIndicator } from './canvas/TldrawHoveredShapeIndicator'\nimport { TldrawScribble } from './canvas/TldrawScribble'\nimport { TldrawSelectionBackground } from './canvas/TldrawSelectionBackground'\nimport { TldrawSelectionForeground } from './canvas/TldrawSelectionForeground'\nimport {\n\tTLExternalContentProps,\n\tregisterDefaultExternalContentHandlers,\n} from './defaultExternalContentHandlers'\nimport { defaultShapeTools } from './defaultShapeTools'\nimport { defaultShapeUtils } from './defaultShapeUtils'\nimport { registerDefaultSideEffects } from './defaultSideEffects'\nimport { defaultTools } from './defaultTools'\nimport { TldrawUi, TldrawUiProps } from './ui/TldrawUi'\nimport { ContextMenu } from './ui/components/ContextMenu'\nimport { usePreloadAssets } from './ui/hooks/usePreloadAssets'\nimport { useDefaultEditorAssetsWithOverrides } from './utils/static-assets/assetUrls'\n\n/** @public */\nexport type TldrawProps = TldrawEditorBaseProps &\n\t(\n\t\t| {\n\t\t\t\tstore: TLStore | TLStoreWithStatus\n\t\t }\n\t\t| {\n\t\t\t\tstore?: undefined\n\t\t\t\tpersistenceKey?: string\n\t\t\t\tsessionId?: string\n\t\t\t\tdefaultName?: string\n\t\t\t\t/**\n\t\t\t\t * A snapshot to load for the store's initial data / schema.\n\t\t\t\t */\n\t\t\t\tsnapshot?: StoreSnapshot<TLRecord>\n\t\t }\n\t) &\n\tTldrawUiProps &\n\tPartial<TLExternalContentProps>\n\n/** @public */\nexport function Tldraw(props: TldrawProps) {\n\tconst {\n\t\tchildren,\n\t\tmaxImageDimension,\n\t\tmaxAssetSize,\n\t\tacceptedImageMimeTypes,\n\t\tacceptedVideoMimeTypes,\n\t\tonMount,\n\t\t...rest\n\t} = props\n\n\tconst components = useShallowObjectIdentity(rest.components ?? {})\n\tconst shapeUtils = useShallowArrayIdentity(rest.shapeUtils ?? [])\n\tconst tools = useShallowArrayIdentity(rest.tools ?? [])\n\n\tconst withDefaults: TldrawEditorProps = {\n\t\tinitialState: 'select',\n\t\t...rest,\n\t\tcomponents: useMemo(\n\t\t\t() => ({\n\t\t\t\tScribble: TldrawScribble,\n\t\t\t\tCollaboratorScribble: TldrawScribble,\n\t\t\t\tSelectionForeground: TldrawSelectionForeground,\n\t\t\t\tSelectionBackground: TldrawSelectionBackground,\n\t\t\t\tHandles: TldrawHandles,\n\t\t\t\tHoveredShapeIndicator: TldrawHoveredShapeIndicator,\n\t\t\t\t...components,\n\t\t\t}),\n\t\t\t[components]\n\t\t),\n\t\tshapeUtils: useMemo(() => [...defaultShapeUtils, ...shapeUtils], [shapeUtils]),\n\t\ttools: useMemo(() => [...defaultTools, ...defaultShapeTools, ...tools], [tools]),\n\t}\n\n\tconst assets = useDefaultEditorAssetsWithOverrides(rest.assetUrls)\n\n\tconst { done: preloadingComplete, error: preloadingError } = usePreloadAssets(assets)\n\n\tif (preloadingError) {\n\t\treturn <ErrorScreen>Could not load assets. Please refresh the page.</ErrorScreen>\n\t}\n\n\tif (!preloadingComplete) {\n\t\treturn <LoadingScreen>Loading assets...</LoadingScreen>\n\t}\n\n\treturn (\n\t\t<TldrawEditor {...withDefaults}>\n\t\t\t<TldrawUi {...withDefaults}>\n\t\t\t\t<ContextMenu>\n\t\t\t\t\t<Canvas />\n\t\t\t\t</ContextMenu>\n\t\t\t\t<InsideOfEditorContext\n\t\t\t\t\tmaxImageDimension={maxImageDimension}\n\t\t\t\t\tmaxAssetSize={maxAssetSize}\n\t\t\t\t\tacceptedImageMimeTypes={acceptedImageMimeTypes}\n\t\t\t\t\tacceptedVideoMimeTypes={acceptedVideoMimeTypes}\n\t\t\t\t\tonMount={onMount}\n\t\t\t\t/>\n\t\t\t\t{children}\n\t\t\t</TldrawUi>\n\t\t</TldrawEditor>\n\t)\n}\n\n// We put these hooks into a component here so that they can run inside of the context provided by TldrawEditor.\nfunction InsideOfEditorContext({\n\tmaxImageDimension = 1000,\n\tmaxAssetSize = 10 * 1024 * 1024, // 10mb\n\tacceptedImageMimeTypes = ['image/jpeg', 'image/png', 'image/gif', 'image/svg+xml'],\n\tacceptedVideoMimeTypes = ['video/mp4', 'video/quicktime'],\n\tonMount,\n}: Partial<TLExternalContentProps & { onMount: TLOnMountHandler }>) {\n\tconst editor = useEditor()\n\n\tconst onMountEvent = useEvent((editor: Editor) => {\n\t\tconst unsubs: (void | (() => void) | undefined)[] = []\n\n\t\tunsubs.push(...registerDefaultSideEffects(editor))\n\n\t\t// for content handling, first we register the default handlers...\n\t\tregisterDefaultExternalContentHandlers(editor, {\n\t\t\tmaxImageDimension,\n\t\t\tmaxAssetSize,\n\t\t\tacceptedImageMimeTypes,\n\t\t\tacceptedVideoMimeTypes,\n\t\t})\n\n\t\t// ...then we run the onMount prop, which may override the above\n\t\tunsubs.push(onMount?.(editor))\n\n\t\treturn () => {\n\t\t\tunsubs.forEach((fn) => fn?.())\n\t\t}\n\t})\n\n\tuseLayoutEffect(() => {\n\t\tif (editor) return onMountEvent?.(editor)\n\t}, [editor, onMountEvent])\n\n\treturn null\n}\n\n// duped from tldraw editor\nfunction useEvent<Args extends Array<unknown>, Result>(\n\thandler: (...args: Args) => Result\n): (...args: Args) => Result {\n\tconst handlerRef = useRef<(...args: Args) => Result>()\n\n\tuseLayoutEffect(() => {\n\t\thandlerRef.current = handler\n\t})\n\n\tuseDebugValue(handler)\n\n\treturn useCallback((...args: Args) => {\n\t\tconst fn = handlerRef.current\n\t\tassert(fn, 'fn does not exist')\n\t\treturn fn(...args)\n\t}, [])\n}\n"],
|
|
5
|
-
"mappings": "AAiGS,cASN,YATM;AAjGT;AAAA,EACC;AAAA,EAEA;AAAA,EACA;AAAA,EAMA;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,aAAa,eAAe,iBAAiB,SAAS,cAAc;AAC7E,SAAS,qBAAqB;AAC9B,SAAS,mCAAmC;AAC5C,SAAS,sBAAsB;AAC/B,SAAS,iCAAiC;AAC1C,SAAS,iCAAiC;AAC1C;AAAA,EAEC;AAAA,OACM;AACP,SAAS,yBAAyB;AAClC,SAAS,yBAAyB;AAClC,SAAS,kCAAkC;AAC3C,SAAS,oBAAoB;AAC7B,SAAS,gBAA+B;AACxC,SAAS,mBAAmB;AAC5B,SAAS,wBAAwB;AACjC,SAAS,2CAA2C;AAuB7C,SAAS,OAAO,OAAoB;AAC1C,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACJ,IAAI;AAEJ,QAAM,aAAa,yBAAyB,KAAK,cAAc,CAAC,CAAC;AACjE,QAAM,aAAa,wBAAwB,KAAK,cAAc,CAAC,CAAC;AAChE,QAAM,QAAQ,wBAAwB,KAAK,SAAS,CAAC,CAAC;AAEtD,QAAM,eAAkC;AAAA,IACvC,cAAc;AAAA,IACd,GAAG;AAAA,IACH,YAAY;AAAA,MACX,OAAO;AAAA,QACN,UAAU;AAAA,QACV,sBAAsB;AAAA,QACtB,qBAAqB;AAAA,QACrB,qBAAqB;AAAA,QACrB,SAAS;AAAA,QACT,uBAAuB;AAAA,QACvB,GAAG;AAAA,MACJ;AAAA,MACA,CAAC,UAAU;AAAA,IACZ;AAAA,IACA,YAAY,QAAQ,MAAM,CAAC,GAAG,mBAAmB,GAAG,UAAU,GAAG,CAAC,UAA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AAErB,SAAO,YAAY,IAAI,SAAe;AACrC,UAAM,KAAK,WAAW;AACtB,WAAO,IAAI,mBAAmB;AAC9B,WAAO,GAAG,GAAG,IAAI;AAAA,EAClB,GAAG,CAAC,CAAC;AACN;",
|
|
6
6
|
"names": ["editor"]
|
|
7
7
|
}
|
|
@@ -7,8 +7,7 @@ const TldrawHandles = ({ children }) => {
|
|
|
7
7
|
() => editor.isInAny("select.idle", "select.pointing_handle"),
|
|
8
8
|
[editor]
|
|
9
9
|
);
|
|
10
|
-
if (!shouldDisplayHandles)
|
|
11
|
-
return null;
|
|
10
|
+
if (!shouldDisplayHandles) return null;
|
|
12
11
|
return /* @__PURE__ */ jsx("svg", { className: "tl-user-handles tl-overlays__item", children });
|
|
13
12
|
};
|
|
14
13
|
export {
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/lib/canvas/TldrawHandles.tsx"],
|
|
4
4
|
"sourcesContent": ["import { TLHandlesComponent, useEditor, useValue } from '@bigbluebutton/editor'\n\n/** @public */\nexport const TldrawHandles: TLHandlesComponent = ({ children }) => {\n\tconst editor = useEditor()\n\tconst shouldDisplayHandles = useValue(\n\t\t'shouldDisplayHandles',\n\t\t() => editor.isInAny('select.idle', 'select.pointing_handle'),\n\t\t[editor]\n\t)\n\n\tif (!shouldDisplayHandles) return null\n\n\treturn <svg className=\"tl-user-handles tl-overlays__item\">{children}</svg>\n}\n"],
|
|
5
|
-
"mappings": "AAaQ;AAbR,SAA6B,WAAW,gBAAgB;AAGjD,MAAM,gBAAoC,CAAC,EAAE,SAAS,MAAM;AAClE,QAAM,SAAS,UAAU;AACzB,QAAM,uBAAuB;AAAA,IAC5B;AAAA,IACA,MAAM,OAAO,QAAQ,eAAe,wBAAwB;AAAA,IAC5D,CAAC,MAAM;AAAA,EACR;AAEA,MAAI,CAAC
|
|
5
|
+
"mappings": "AAaQ;AAbR,SAA6B,WAAW,gBAAgB;AAGjD,MAAM,gBAAoC,CAAC,EAAE,SAAS,MAAM;AAClE,QAAM,SAAS,UAAU;AACzB,QAAM,uBAAuB;AAAA,IAC5B;AAAA,IACA,MAAM,OAAO,QAAQ,eAAe,wBAAwB;AAAA,IAC5D,CAAC,MAAM;AAAA,EACR;AAEA,MAAI,CAAC,qBAAsB,QAAO;AAElC,SAAO,oBAAC,SAAI,WAAU,qCAAqC,UAAS;AACrE;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -16,8 +16,7 @@ const TldrawHoveredShapeIndicator = ({ shapeId }) => {
|
|
|
16
16
|
},
|
|
17
17
|
[editor]
|
|
18
18
|
);
|
|
19
|
-
if (!showHoveredShapeIndicator)
|
|
20
|
-
return null;
|
|
19
|
+
if (!showHoveredShapeIndicator) return null;
|
|
21
20
|
return /* @__PURE__ */ jsx(ShapeIndicator, { className: "tl-user-indicator__hovered", id: shapeId });
|
|
22
21
|
};
|
|
23
22
|
export {
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/lib/canvas/TldrawHoveredShapeIndicator.tsx"],
|
|
4
4
|
"sourcesContent": ["import {\n\tShapeIndicator,\n\tTLHoveredShapeIndicatorComponent,\n\tuseEditor,\n\tuseValue,\n} from '@bigbluebutton/editor'\n\n/** @public */\nexport const TldrawHoveredShapeIndicator: TLHoveredShapeIndicatorComponent = ({ shapeId }) => {\n\tconst editor = useEditor()\n\tconst showHoveredShapeIndicator = useValue(\n\t\t'show hovered',\n\t\t() => {\n\t\t\t// When the editor is editing a shape and hovering that shape,\n\t\t\t// don't show its indicator; but DO show other hover indicators\n\t\t\tif (editor.isIn('select.editing_shape')) {\n\t\t\t\treturn editor.getHoveredShapeId() !== editor.getEditingShapeId()\n\t\t\t}\n\n\t\t\t// Otherise, only show the hovered indicator when the editor\n\t\t\t// is in the idle state\n\t\t\treturn editor.isInAny('select.idle')\n\t\t},\n\t\t[editor]\n\t)\n\tif (!showHoveredShapeIndicator) return null\n\treturn <ShapeIndicator className=\"tl-user-indicator__hovered\" id={shapeId} />\n}\n\n//\n"],
|
|
5
|
-
"mappings": "AA0BQ;AA1BR;AAAA,EACC;AAAA,EAEA;AAAA,EACA;AAAA,OACM;AAGA,MAAM,8BAAgE,CAAC,EAAE,QAAQ,MAAM;AAC7F,QAAM,SAAS,UAAU;AACzB,QAAM,4BAA4B;AAAA,IACjC;AAAA,IACA,MAAM;AAGL,UAAI,OAAO,KAAK,sBAAsB,GAAG;AACxC,eAAO,OAAO,kBAAkB,MAAM,OAAO,kBAAkB;AAAA,MAChE;AAIA,aAAO,OAAO,QAAQ,aAAa;AAAA,IACpC;AAAA,IACA,CAAC,MAAM;AAAA,EACR;AACA,MAAI,CAAC
|
|
5
|
+
"mappings": "AA0BQ;AA1BR;AAAA,EACC;AAAA,EAEA;AAAA,EACA;AAAA,OACM;AAGA,MAAM,8BAAgE,CAAC,EAAE,QAAQ,MAAM;AAC7F,QAAM,SAAS,UAAU;AACzB,QAAM,4BAA4B;AAAA,IACjC;AAAA,IACA,MAAM;AAGL,UAAI,OAAO,KAAK,sBAAsB,GAAG;AACxC,eAAO,OAAO,kBAAkB,MAAM,OAAO,kBAAkB;AAAA,MAChE;AAIA,aAAO,OAAO,QAAQ,aAAa;AAAA,IACpC;AAAA,IACA,CAAC,MAAM;AAAA,EACR;AACA,MAAI,CAAC,0BAA2B,QAAO;AACvC,SAAO,oBAAC,kBAAe,WAAU,8BAA6B,IAAI,SAAS;AAC5E;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -9,8 +9,7 @@ const TldrawScribble = ({
|
|
|
9
9
|
opacity,
|
|
10
10
|
className
|
|
11
11
|
}) => {
|
|
12
|
-
if (!scribble.points.length)
|
|
13
|
-
return null;
|
|
12
|
+
if (!scribble.points.length) return null;
|
|
14
13
|
const stroke = getStroke(scribble.points, {
|
|
15
14
|
size: scribble.size / zoom,
|
|
16
15
|
start: { taper: scribble.taper, easing: EASINGS.linear },
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/lib/canvas/TldrawScribble.tsx"],
|
|
4
4
|
"sourcesContent": ["import { EASINGS, TLScribbleComponent, getSvgPathFromPoints } from '@bigbluebutton/editor'\nimport classNames from 'classnames'\nimport { getStroke } from '../shapes/shared/freehand/getStroke'\n\n/** @public */\nexport const TldrawScribble: TLScribbleComponent = ({\n\tscribble,\n\tzoom,\n\tcolor,\n\topacity,\n\tclassName,\n}) => {\n\tif (!scribble.points.length) return null\n\n\tconst stroke = getStroke(scribble.points, {\n\t\tsize: scribble.size / zoom,\n\t\tstart: { taper: scribble.taper, easing: EASINGS.linear },\n\t\tlast: scribble.state === 'stopping',\n\t\tsimulatePressure: false,\n\t\tstreamline: 0.32,\n\t})\n\n\tlet d: string\n\n\tif (stroke.length < 4) {\n\t\t// the stroke will be 3 points as a sort of shrugging fail state, so let's draw a dot instead\n\t\tconst r = scribble.size / zoom / 2\n\t\tconst { x, y } = scribble.points[scribble.points.length - 1]\n\t\td = `M ${x - r},${y} a ${r},${r} 0 1,0 ${r * 2},0 a ${r},${r} 0 1,0 ${-r * 2},0`\n\t} else {\n\t\t// If we do have a stroke, then draw the stroke path\n\t\td = getSvgPathFromPoints(stroke)\n\t}\n\n\treturn (\n\t\t<svg className={className ? classNames('tl-overlays__item', className) : className}>\n\t\t\t<path\n\t\t\t\tclassName=\"tl-scribble\"\n\t\t\t\td={d}\n\t\t\t\tfill={color ?? `var(--color-${scribble.color})`}\n\t\t\t\topacity={opacity ?? scribble.opacity}\n\t\t\t/>\n\t\t</svg>\n\t)\n}\n"],
|
|
5
|
-
"mappings": "AAoCG;AApCH,SAAS,SAA8B,4BAA4B;AACnE,OAAO,gBAAgB;AACvB,SAAS,iBAAiB;AAGnB,MAAM,iBAAsC,CAAC;AAAA,EACnD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,MAAM;AACL,MAAI,CAAC,SAAS,OAAO
|
|
5
|
+
"mappings": "AAoCG;AApCH,SAAS,SAA8B,4BAA4B;AACnE,OAAO,gBAAgB;AACvB,SAAS,iBAAiB;AAGnB,MAAM,iBAAsC,CAAC;AAAA,EACnD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,MAAM;AACL,MAAI,CAAC,SAAS,OAAO,OAAQ,QAAO;AAEpC,QAAM,SAAS,UAAU,SAAS,QAAQ;AAAA,IACzC,MAAM,SAAS,OAAO;AAAA,IACtB,OAAO,EAAE,OAAO,SAAS,OAAO,QAAQ,QAAQ,OAAO;AAAA,IACvD,MAAM,SAAS,UAAU;AAAA,IACzB,kBAAkB;AAAA,IAClB,YAAY;AAAA,EACb,CAAC;AAED,MAAI;AAEJ,MAAI,OAAO,SAAS,GAAG;AAEtB,UAAM,IAAI,SAAS,OAAO,OAAO;AACjC,UAAM,EAAE,GAAG,EAAE,IAAI,SAAS,OAAO,SAAS,OAAO,SAAS,CAAC;AAC3D,QAAI,KAAK,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;AAAA,EAC7E,OAAO;AAEN,QAAI,qBAAqB,MAAM;AAAA,EAChC;AAEA,SACC,oBAAC,SAAI,WAAW,YAAY,WAAW,qBAAqB,SAAS,IAAI,WACxE;AAAA,IAAC;AAAA;AAAA,MACA,WAAU;AAAA,MACV;AAAA,MACA,MAAM,SAAS,eAAe,SAAS,KAAK;AAAA,MAC5C,SAAS,WAAW,SAAS;AAAA;AAAA,EAC9B,GACD;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -18,8 +18,7 @@ const TldrawSelectionBackground = ({ bounds, rotation }) => {
|
|
|
18
18
|
),
|
|
19
19
|
[editor]
|
|
20
20
|
);
|
|
21
|
-
if (!shouldDisplay)
|
|
22
|
-
return null;
|
|
21
|
+
if (!shouldDisplay) return null;
|
|
23
22
|
return /* @__PURE__ */ jsx(DefaultSelectionBackground, { bounds, rotation });
|
|
24
23
|
};
|
|
25
24
|
export {
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/lib/canvas/TldrawSelectionBackground.tsx"],
|
|
4
4
|
"sourcesContent": ["import {\n\tDefaultSelectionBackground,\n\tTLSelectionBackgroundComponent,\n\tuseEditor,\n\tuseValue,\n} from '@bigbluebutton/editor'\n\n/** @public */\nexport const TldrawSelectionBackground: TLSelectionBackgroundComponent = ({ bounds, rotation }) => {\n\tconst editor = useEditor()\n\n\tconst shouldDisplay = useValue(\n\t\t'should display',\n\t\t() =>\n\t\t\teditor.isInAny(\n\t\t\t\t'select.idle',\n\t\t\t\t'select.brushing',\n\t\t\t\t'select.scribble_brushing',\n\t\t\t\t'select.pointing_shape',\n\t\t\t\t'select.pointing_selection',\n\t\t\t\t'text.resizing'\n\t\t\t),\n\t\t[editor]\n\t)\n\n\tif (!shouldDisplay) return null\n\n\treturn <DefaultSelectionBackground bounds={bounds} rotation={rotation} />\n}\n"],
|
|
5
|
-
"mappings": "AA2BQ;AA3BR;AAAA,EACC;AAAA,EAEA;AAAA,EACA;AAAA,OACM;AAGA,MAAM,4BAA4D,CAAC,EAAE,QAAQ,SAAS,MAAM;AAClG,QAAM,SAAS,UAAU;AAEzB,QAAM,gBAAgB;AAAA,IACrB;AAAA,IACA,MACC,OAAO;AAAA,MACN;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,IACD,CAAC,MAAM;AAAA,EACR;AAEA,MAAI,CAAC
|
|
5
|
+
"mappings": "AA2BQ;AA3BR;AAAA,EACC;AAAA,EAEA;AAAA,EACA;AAAA,OACM;AAGA,MAAM,4BAA4D,CAAC,EAAE,QAAQ,SAAS,MAAM;AAClG,QAAM,SAAS,UAAU;AAEzB,QAAM,gBAAgB;AAAA,IACrB;AAAA,IACA,MACC,OAAO;AAAA,MACN;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,IACD,CAAC,MAAM;AAAA,EACR;AAEA,MAAI,CAAC,cAAe,QAAO;AAE3B,SAAO,oBAAC,8BAA2B,QAAgB,UAAoB;AACxE;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -35,8 +35,7 @@ const TldrawSelectionForeground = track(
|
|
|
35
35
|
x: -expandOutlineBy,
|
|
36
36
|
y: -expandOutlineBy
|
|
37
37
|
});
|
|
38
|
-
if (!bounds)
|
|
39
|
-
return null;
|
|
38
|
+
if (!bounds) return null;
|
|
40
39
|
bounds = bounds.clone().expandBy(expandOutlineBy).zeroFix();
|
|
41
40
|
const zoom = editor.getZoomLevel();
|
|
42
41
|
const isChangingStyle = editor.getInstanceState().isChangingStyle;
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/lib/canvas/TldrawSelectionForeground.tsx"],
|
|
4
4
|
"sourcesContent": ["import {\n\tBox2d,\n\tRotateCorner,\n\tTLEmbedShape,\n\tTLSelectionForegroundComponent,\n\tTLTextShape,\n\tgetCursor,\n\ttoDomPrecision,\n\ttrack,\n\tuseEditor,\n\tuseSelectionEvents,\n\tuseTransform,\n\tuseValue,\n} from '@bigbluebutton/editor'\nimport classNames from 'classnames'\nimport { useRef } from 'react'\nimport { useReadonly } from '../ui/hooks/useReadonly'\nimport { TldrawCropHandles } from './TldrawCropHandles'\n\n/** @public */\nexport const TldrawSelectionForeground: TLSelectionForegroundComponent = track(\n\tfunction TldrawSelectionForeground({ bounds, rotation }: { bounds: Box2d; rotation: number }) {\n\t\tconst editor = useEditor()\n\t\tconst rSvg = useRef<SVGSVGElement>(null)\n\n\t\tconst isReadonlyMode = useReadonly()\n\t\tconst topEvents = useSelectionEvents('top')\n\t\tconst rightEvents = useSelectionEvents('right')\n\t\tconst bottomEvents = useSelectionEvents('bottom')\n\t\tconst leftEvents = useSelectionEvents('left')\n\t\tconst topLeftEvents = useSelectionEvents('top_left')\n\t\tconst topRightEvents = useSelectionEvents('top_right')\n\t\tconst bottomRightEvents = useSelectionEvents('bottom_right')\n\t\tconst bottomLeftEvents = useSelectionEvents('bottom_left')\n\n\t\tconst isDefaultCursor =\n\t\t\t!editor.getIsMenuOpen() && editor.getInstanceState().cursor.type === 'default'\n\t\tconst isCoarsePointer = editor.getInstanceState().isCoarsePointer\n\n\t\tconst shapes = editor.getSelectedShapes()\n\t\tconst onlyShape = editor.getOnlySelectedShape()\n\t\tconst isLockedShape = onlyShape && editor.isShapeOrAncestorLocked(onlyShape)\n\n\t\t// if all shapes have an expandBy for the selection outline, we can expand by the l\n\t\tconst expandOutlineBy = onlyShape\n\t\t\t? editor.getShapeUtil(onlyShape).expandSelectionOutlinePx(onlyShape)\n\t\t\t: 0\n\n\t\tuseTransform(rSvg, bounds?.x, bounds?.y, 1, editor.getSelectionRotation(), {\n\t\t\tx: -expandOutlineBy,\n\t\t\ty: -expandOutlineBy,\n\t\t})\n\n\t\tif (!bounds) return null\n\t\tbounds = bounds.clone().expandBy(expandOutlineBy).zeroFix()\n\n\t\tconst zoom = editor.getZoomLevel()\n\t\tconst isChangingStyle = editor.getInstanceState().isChangingStyle\n\n\t\tconst width = bounds.width\n\t\tconst height = bounds.height\n\n\t\tconst size = 8 / zoom\n\t\tconst isTinyX = width < size * 2\n\t\tconst isTinyY = height < size * 2\n\n\t\tconst isSmallX = width < size * 4\n\t\tconst isSmallY = height < size * 4\n\t\tconst isSmallCropX = width < size * 5\n\t\tconst isSmallCropY = height < size * 5\n\n\t\tconst mobileHandleMultiplier = isCoarsePointer ? 1.75 : 1\n\t\tconst targetSize = (6 / zoom) * mobileHandleMultiplier\n\n\t\tconst targetSizeX = (isSmallX ? targetSize / 2 : targetSize) * (mobileHandleMultiplier * 0.75)\n\t\tconst targetSizeY = (isSmallY ? targetSize / 2 : targetSize) * (mobileHandleMultiplier * 0.75)\n\n\t\tconst showSelectionBounds =\n\t\t\t(onlyShape ? !editor.getShapeUtil(onlyShape).hideSelectionBoundsFg(onlyShape) : true) &&\n\t\t\t!isChangingStyle\n\n\t\tlet shouldDisplayBox =\n\t\t\t(showSelectionBounds &&\n\t\t\t\teditor.isInAny(\n\t\t\t\t\t'select.idle',\n\t\t\t\t\t'select.brushing',\n\t\t\t\t\t'select.scribble_brushing',\n\t\t\t\t\t'select.pointing_canvas',\n\t\t\t\t\t'select.pointing_selection',\n\t\t\t\t\t'select.pointing_shape',\n\t\t\t\t\t'select.crop.idle',\n\t\t\t\t\t'select.crop.pointing_crop',\n\t\t\t\t\t'select.pointing_resize_handle',\n\t\t\t\t\t'select.pointing_crop_handle'\n\t\t\t\t)) ||\n\t\t\t(showSelectionBounds &&\n\t\t\t\teditor.isIn('select.resizing') &&\n\t\t\t\tonlyShape &&\n\t\t\t\teditor.isShapeOfType<TLTextShape>(onlyShape, 'text'))\n\n\t\tif (onlyShape && shouldDisplayBox) {\n\t\t\tif (editor.environment.isFirefox && editor.isShapeOfType<TLEmbedShape>(onlyShape, 'embed')) {\n\t\t\t\tshouldDisplayBox = false\n\t\t\t}\n\t\t}\n\n\t\tconst showCropHandles =\n\t\t\teditor.isInAny(\n\t\t\t\t'select.pointing_crop_handle',\n\t\t\t\t'select.crop.idle',\n\t\t\t\t'select.crop.pointing_crop'\n\t\t\t) &&\n\t\t\t!isChangingStyle &&\n\t\t\t!isReadonlyMode\n\n\t\tconst shouldDisplayControls =\n\t\t\teditor.isInAny(\n\t\t\t\t'select.idle',\n\t\t\t\t'select.pointing_selection',\n\t\t\t\t'select.pointing_shape',\n\t\t\t\t'select.crop.idle'\n\t\t\t) &&\n\t\t\t!isChangingStyle &&\n\t\t\t!isReadonlyMode\n\n\t\tconst showCornerRotateHandles =\n\t\t\t!isCoarsePointer &&\n\t\t\t!(isTinyX || isTinyY) &&\n\t\t\t(shouldDisplayControls || showCropHandles) &&\n\t\t\t(onlyShape ? !editor.getShapeUtil(onlyShape).hideRotateHandle(onlyShape) : true) &&\n\t\t\t!isLockedShape\n\n\t\tconst showMobileRotateHandle =\n\t\t\tisCoarsePointer &&\n\t\t\t(!isSmallX || !isSmallY) &&\n\t\t\t(shouldDisplayControls || showCropHandles) &&\n\t\t\t(onlyShape ? !editor.getShapeUtil(onlyShape).hideRotateHandle(onlyShape) : true) &&\n\t\t\t!isLockedShape\n\n\t\tconst showResizeHandles =\n\t\t\tshouldDisplayControls &&\n\t\t\t(onlyShape\n\t\t\t\t? editor.getShapeUtil(onlyShape).canResize(onlyShape) &&\n\t\t\t\t !editor.getShapeUtil(onlyShape).hideResizeHandles(onlyShape)\n\t\t\t\t: true) &&\n\t\t\t!showCropHandles &&\n\t\t\t!isLockedShape\n\n\t\tconst hideAlternateCornerHandles = isTinyX || isTinyY\n\t\tconst showOnlyOneHandle = isTinyX && isTinyY\n\t\tconst hideAlternateCropHandles = isSmallCropX || isSmallCropY\n\n\t\tconst showHandles = showResizeHandles || showCropHandles\n\t\tconst hideRotateCornerHandles = !showCornerRotateHandles\n\t\tconst hideMobileRotateHandle = !shouldDisplayControls || !showMobileRotateHandle\n\t\tconst hideTopLeftCorner = !shouldDisplayControls || !showHandles\n\t\tconst hideTopRightCorner = !shouldDisplayControls || !showHandles || hideAlternateCornerHandles\n\t\tconst hideBottomLeftCorner =\n\t\t\t!shouldDisplayControls || !showHandles || hideAlternateCornerHandles\n\t\tconst hideBottomRightCorner =\n\t\t\t!shouldDisplayControls || !showHandles || (showOnlyOneHandle && !showCropHandles)\n\n\t\tlet hideEdgeTargetsDueToCoarsePointer = isCoarsePointer\n\n\t\tif (\n\t\t\thideEdgeTargetsDueToCoarsePointer &&\n\t\t\tshapes.every((shape) => editor.getShapeUtil(shape).isAspectRatioLocked(shape))\n\t\t) {\n\t\t\thideEdgeTargetsDueToCoarsePointer = false\n\t\t}\n\n\t\t// If we're showing crop handles, then show the edges too.\n\t\t// If we're showing resize handles, then show the edges only\n\t\t// if we're not hiding them for some other reason\n\t\tlet hideEdgeTargets = true\n\n\t\tif (showCropHandles) {\n\t\t\thideEdgeTargets = hideAlternateCropHandles\n\t\t} else if (showResizeHandles) {\n\t\t\thideEdgeTargets =\n\t\t\t\thideAlternateCornerHandles || showOnlyOneHandle || hideEdgeTargetsDueToCoarsePointer\n\t\t}\n\n\t\tconst textHandleHeight = Math.min(24 / zoom, height - targetSizeY * 3)\n\t\tconst showTextResizeHandles =\n\t\t\tshouldDisplayControls &&\n\t\t\tisCoarsePointer &&\n\t\t\tonlyShape &&\n\t\t\teditor.isShapeOfType<TLTextShape>(onlyShape, 'text') &&\n\t\t\ttextHandleHeight * zoom >= 4\n\n\t\treturn (\n\t\t\t<svg\n\t\t\t\tclassName=\"tl-overlays__item tl-selection__fg tl-svg-context\"\n\t\t\t\tdata-testid=\"selection-foreground\"\n\t\t\t>\n\t\t\t\t<g ref={rSvg}>\n\t\t\t\t\t{shouldDisplayBox && (\n\t\t\t\t\t\t<rect\n\t\t\t\t\t\t\tclassName={classNames('tl-selection__fg__outline')}\n\t\t\t\t\t\t\twidth={toDomPrecision(width)}\n\t\t\t\t\t\t\theight={toDomPrecision(height)}\n\t\t\t\t\t\t/>\n\t\t\t\t\t)}\n\t\t\t\t\t<RotateCornerHandle\n\t\t\t\t\t\tdata-testid=\"selection.rotate.top-left\"\n\t\t\t\t\t\tcx={0}\n\t\t\t\t\t\tcy={0}\n\t\t\t\t\t\ttargetSize={targetSize}\n\t\t\t\t\t\tcorner=\"top_left_rotate\"\n\t\t\t\t\t\tcursor={isDefaultCursor ? getCursor('nwse-rotate', rotation) : undefined}\n\t\t\t\t\t\tisHidden={hideRotateCornerHandles}\n\t\t\t\t\t/>\n\t\t\t\t\t<RotateCornerHandle\n\t\t\t\t\t\tdata-testid=\"selection.rotate.top-right\"\n\t\t\t\t\t\tcx={width + targetSize * 3}\n\t\t\t\t\t\tcy={0}\n\t\t\t\t\t\ttargetSize={targetSize}\n\t\t\t\t\t\tcorner=\"top_right_rotate\"\n\t\t\t\t\t\tcursor={isDefaultCursor ? getCursor('nesw-rotate', rotation) : undefined}\n\t\t\t\t\t\tisHidden={hideRotateCornerHandles}\n\t\t\t\t\t/>\n\t\t\t\t\t<RotateCornerHandle\n\t\t\t\t\t\tdata-testid=\"selection.rotate.bottom-left\"\n\t\t\t\t\t\tcx={0}\n\t\t\t\t\t\tcy={height + targetSize * 3}\n\t\t\t\t\t\ttargetSize={targetSize}\n\t\t\t\t\t\tcorner=\"bottom_left_rotate\"\n\t\t\t\t\t\tcursor={isDefaultCursor ? getCursor('swne-rotate', rotation) : undefined}\n\t\t\t\t\t\tisHidden={hideRotateCornerHandles}\n\t\t\t\t\t/>\n\t\t\t\t\t<RotateCornerHandle\n\t\t\t\t\t\tdata-testid=\"selection.rotate.bottom-right\"\n\t\t\t\t\t\tcx={width + targetSize * 3}\n\t\t\t\t\t\tcy={height + targetSize * 3}\n\t\t\t\t\t\ttargetSize={targetSize}\n\t\t\t\t\t\tcorner=\"bottom_right_rotate\"\n\t\t\t\t\t\tcursor={isDefaultCursor ? getCursor('senw-rotate', rotation) : undefined}\n\t\t\t\t\t\tisHidden={hideRotateCornerHandles}\n\t\t\t\t\t/>\n\t\t\t\t\t<MobileRotateHandle\n\t\t\t\t\t\tdata-testid=\"selection.rotate.mobile\"\n\t\t\t\t\t\tcx={isSmallX ? -targetSize * 1.5 : width / 2}\n\t\t\t\t\t\tcy={isSmallX ? height / 2 : -targetSize * 1.5}\n\t\t\t\t\t\tsize={size}\n\t\t\t\t\t\tisHidden={hideMobileRotateHandle}\n\t\t\t\t\t/>\n\t\t\t\t\t{/* Targets */}\n\t\t\t\t\t<rect\n\t\t\t\t\t\tclassName={classNames('tl-transparent', {\n\t\t\t\t\t\t\t'tl-hidden': hideEdgeTargets,\n\t\t\t\t\t\t})}\n\t\t\t\t\t\tdata-testid=\"selection.resize.top\"\n\t\t\t\t\t\taria-label=\"top target\"\n\t\t\t\t\t\tpointerEvents=\"all\"\n\t\t\t\t\t\tx={0}\n\t\t\t\t\t\ty={toDomPrecision(0 - (isSmallY ? targetSizeY * 2 : targetSizeY))}\n\t\t\t\t\t\twidth={toDomPrecision(width)}\n\t\t\t\t\t\theight={toDomPrecision(Math.max(1, targetSizeY * 2))}\n\t\t\t\t\t\tstyle={isDefaultCursor ? { cursor: getCursor('ns-resize', rotation) } : undefined}\n\t\t\t\t\t\t{...topEvents}\n\t\t\t\t\t/>\n\t\t\t\t\t<rect\n\t\t\t\t\t\tclassName={classNames('tl-transparent', {\n\t\t\t\t\t\t\t'tl-hidden': hideEdgeTargets,\n\t\t\t\t\t\t})}\n\t\t\t\t\t\tdata-testid=\"selection.resize.right\"\n\t\t\t\t\t\taria-label=\"right target\"\n\t\t\t\t\t\tpointerEvents=\"all\"\n\t\t\t\t\t\tx={toDomPrecision(width - (isSmallX ? 0 : targetSizeX))}\n\t\t\t\t\t\ty={0}\n\t\t\t\t\t\theight={toDomPrecision(height)}\n\t\t\t\t\t\twidth={toDomPrecision(Math.max(1, targetSizeX * 2))}\n\t\t\t\t\t\tstyle={isDefaultCursor ? { cursor: getCursor('ew-resize', rotation) } : undefined}\n\t\t\t\t\t\t{...rightEvents}\n\t\t\t\t\t/>\n\t\t\t\t\t<rect\n\t\t\t\t\t\tclassName={classNames('tl-transparent', {\n\t\t\t\t\t\t\t'tl-hidden': hideEdgeTargets,\n\t\t\t\t\t\t})}\n\t\t\t\t\t\tdata-testid=\"selection.resize.bottom\"\n\t\t\t\t\t\taria-label=\"bottom target\"\n\t\t\t\t\t\tpointerEvents=\"all\"\n\t\t\t\t\t\tx={0}\n\t\t\t\t\t\ty={toDomPrecision(height - (isSmallY ? 0 : targetSizeY))}\n\t\t\t\t\t\twidth={toDomPrecision(width)}\n\t\t\t\t\t\theight={toDomPrecision(Math.max(1, targetSizeY * 2))}\n\t\t\t\t\t\tstyle={isDefaultCursor ? { cursor: getCursor('ns-resize', rotation) } : undefined}\n\t\t\t\t\t\t{...bottomEvents}\n\t\t\t\t\t/>\n\t\t\t\t\t<rect\n\t\t\t\t\t\tclassName={classNames('tl-transparent', {\n\t\t\t\t\t\t\t'tl-hidden': hideEdgeTargets,\n\t\t\t\t\t\t})}\n\t\t\t\t\t\tdata-testid=\"selection.resize.left\"\n\t\t\t\t\t\taria-label=\"left target\"\n\t\t\t\t\t\tpointerEvents=\"all\"\n\t\t\t\t\t\tx={toDomPrecision(0 - (isSmallX ? targetSizeX * 2 : targetSizeX))}\n\t\t\t\t\t\ty={0}\n\t\t\t\t\t\theight={toDomPrecision(height)}\n\t\t\t\t\t\twidth={toDomPrecision(Math.max(1, targetSizeX * 2))}\n\t\t\t\t\t\tstyle={isDefaultCursor ? { cursor: getCursor('ew-resize', rotation) } : undefined}\n\t\t\t\t\t\t{...leftEvents}\n\t\t\t\t\t/>\n\t\t\t\t\t{/* Corner Targets */}\n\t\t\t\t\t<rect\n\t\t\t\t\t\tclassName={classNames('tl-transparent', {\n\t\t\t\t\t\t\t'tl-hidden': hideTopLeftCorner,\n\t\t\t\t\t\t})}\n\t\t\t\t\t\tdata-testid=\"selection.target.top-left\"\n\t\t\t\t\t\taria-label=\"top-left target\"\n\t\t\t\t\t\tpointerEvents=\"all\"\n\t\t\t\t\t\tx={toDomPrecision(0 - (isSmallX ? targetSizeX * 2 : targetSizeX * 1.5))}\n\t\t\t\t\t\ty={toDomPrecision(0 - (isSmallY ? targetSizeY * 2 : targetSizeY * 1.5))}\n\t\t\t\t\t\twidth={toDomPrecision(targetSizeX * 3)}\n\t\t\t\t\t\theight={toDomPrecision(targetSizeY * 3)}\n\t\t\t\t\t\tstyle={isDefaultCursor ? { cursor: getCursor('nwse-resize', rotation) } : undefined}\n\t\t\t\t\t\t{...topLeftEvents}\n\t\t\t\t\t/>\n\t\t\t\t\t<rect\n\t\t\t\t\t\tclassName={classNames('tl-transparent', {\n\t\t\t\t\t\t\t'tl-hidden': hideTopRightCorner,\n\t\t\t\t\t\t})}\n\t\t\t\t\t\tdata-testid=\"selection.target.top-right\"\n\t\t\t\t\t\taria-label=\"top-right target\"\n\t\t\t\t\t\tpointerEvents=\"all\"\n\t\t\t\t\t\tx={toDomPrecision(width - (isSmallX ? 0 : targetSizeX * 1.5))}\n\t\t\t\t\t\ty={toDomPrecision(0 - (isSmallY ? targetSizeY * 2 : targetSizeY * 1.5))}\n\t\t\t\t\t\twidth={toDomPrecision(targetSizeX * 3)}\n\t\t\t\t\t\theight={toDomPrecision(targetSizeY * 3)}\n\t\t\t\t\t\tstyle={isDefaultCursor ? { cursor: getCursor('nesw-resize', rotation) } : undefined}\n\t\t\t\t\t\t{...topRightEvents}\n\t\t\t\t\t/>\n\t\t\t\t\t<rect\n\t\t\t\t\t\tclassName={classNames('tl-transparent', {\n\t\t\t\t\t\t\t'tl-hidden': hideBottomRightCorner,\n\t\t\t\t\t\t})}\n\t\t\t\t\t\tdata-testid=\"selection.target.bottom-right\"\n\t\t\t\t\t\taria-label=\"bottom-right target\"\n\t\t\t\t\t\tpointerEvents=\"all\"\n\t\t\t\t\t\tx={toDomPrecision(width - (isSmallX ? targetSizeX : targetSizeX * 1.5))}\n\t\t\t\t\t\ty={toDomPrecision(height - (isSmallY ? targetSizeY : targetSizeY * 1.5))}\n\t\t\t\t\t\twidth={toDomPrecision(targetSizeX * 3)}\n\t\t\t\t\t\theight={toDomPrecision(targetSizeY * 3)}\n\t\t\t\t\t\tstyle={isDefaultCursor ? { cursor: getCursor('nwse-resize', rotation) } : undefined}\n\t\t\t\t\t\t{...bottomRightEvents}\n\t\t\t\t\t/>\n\t\t\t\t\t<rect\n\t\t\t\t\t\tclassName={classNames('tl-transparent', {\n\t\t\t\t\t\t\t'tl-hidden': hideBottomLeftCorner,\n\t\t\t\t\t\t})}\n\t\t\t\t\t\tdata-testid=\"selection.target.bottom-left\"\n\t\t\t\t\t\taria-label=\"bottom-left target\"\n\t\t\t\t\t\tpointerEvents=\"all\"\n\t\t\t\t\t\tx={toDomPrecision(0 - (isSmallX ? targetSizeX * 3 : targetSizeX * 1.5))}\n\t\t\t\t\t\ty={toDomPrecision(height - (isSmallY ? 0 : targetSizeY * 1.5))}\n\t\t\t\t\t\twidth={toDomPrecision(targetSizeX * 3)}\n\t\t\t\t\t\theight={toDomPrecision(targetSizeY * 3)}\n\t\t\t\t\t\tstyle={isDefaultCursor ? { cursor: getCursor('nesw-resize', rotation) } : undefined}\n\t\t\t\t\t\t{...bottomLeftEvents}\n\t\t\t\t\t/>\n\t\t\t\t\t{/* Resize Handles */}\n\t\t\t\t\t{showResizeHandles && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<rect\n\t\t\t\t\t\t\t\tdata-testid=\"selection.resize.top-left\"\n\t\t\t\t\t\t\t\tclassName={classNames('tl-corner-handle', {\n\t\t\t\t\t\t\t\t\t'tl-hidden': hideTopLeftCorner,\n\t\t\t\t\t\t\t\t})}\n\t\t\t\t\t\t\t\taria-label=\"top_left handle\"\n\t\t\t\t\t\t\t\tx={toDomPrecision(0 - size / 2)}\n\t\t\t\t\t\t\t\ty={toDomPrecision(0 - size / 2)}\n\t\t\t\t\t\t\t\twidth={toDomPrecision(size)}\n\t\t\t\t\t\t\t\theight={toDomPrecision(size)}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<rect\n\t\t\t\t\t\t\t\tdata-testid=\"selection.resize.top-right\"\n\t\t\t\t\t\t\t\tclassName={classNames('tl-corner-handle', {\n\t\t\t\t\t\t\t\t\t'tl-hidden': hideTopRightCorner,\n\t\t\t\t\t\t\t\t})}\n\t\t\t\t\t\t\t\taria-label=\"top_right handle\"\n\t\t\t\t\t\t\t\tx={toDomPrecision(width - size / 2)}\n\t\t\t\t\t\t\t\ty={toDomPrecision(0 - size / 2)}\n\t\t\t\t\t\t\t\twidth={toDomPrecision(size)}\n\t\t\t\t\t\t\t\theight={toDomPrecision(size)}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<rect\n\t\t\t\t\t\t\t\tdata-testid=\"selection.resize.bottom-right\"\n\t\t\t\t\t\t\t\tclassName={classNames('tl-corner-handle', {\n\t\t\t\t\t\t\t\t\t'tl-hidden': hideBottomRightCorner,\n\t\t\t\t\t\t\t\t})}\n\t\t\t\t\t\t\t\taria-label=\"bottom_right handle\"\n\t\t\t\t\t\t\t\tx={toDomPrecision(width - size / 2)}\n\t\t\t\t\t\t\t\ty={toDomPrecision(height - size / 2)}\n\t\t\t\t\t\t\t\twidth={toDomPrecision(size)}\n\t\t\t\t\t\t\t\theight={toDomPrecision(size)}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<rect\n\t\t\t\t\t\t\t\tdata-testid=\"selection.resize.bottom-left\"\n\t\t\t\t\t\t\t\tclassName={classNames('tl-corner-handle', {\n\t\t\t\t\t\t\t\t\t'tl-hidden': hideBottomLeftCorner,\n\t\t\t\t\t\t\t\t})}\n\t\t\t\t\t\t\t\taria-label=\"bottom_left handle\"\n\t\t\t\t\t\t\t\tx={toDomPrecision(0 - size / 2)}\n\t\t\t\t\t\t\t\ty={toDomPrecision(height - size / 2)}\n\t\t\t\t\t\t\t\twidth={toDomPrecision(size)}\n\t\t\t\t\t\t\t\theight={toDomPrecision(size)}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</>\n\t\t\t\t\t)}\n\t\t\t\t\t{showTextResizeHandles && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<rect\n\t\t\t\t\t\t\t\tdata-testid=\"selection.text-resize.left.handle\"\n\t\t\t\t\t\t\t\tclassName=\"tl-text-handle\"\n\t\t\t\t\t\t\t\taria-label=\"bottom_left handle\"\n\t\t\t\t\t\t\t\tx={toDomPrecision(0 - size / 4)}\n\t\t\t\t\t\t\t\ty={toDomPrecision(height / 2 - textHandleHeight / 2)}\n\t\t\t\t\t\t\t\trx={size / 4}\n\t\t\t\t\t\t\t\twidth={toDomPrecision(size / 2)}\n\t\t\t\t\t\t\t\theight={toDomPrecision(textHandleHeight)}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<rect\n\t\t\t\t\t\t\t\tdata-testid=\"selection.text-resize.right.handle\"\n\t\t\t\t\t\t\t\tclassName=\"tl-text-handle\"\n\t\t\t\t\t\t\t\taria-label=\"bottom_left handle\"\n\t\t\t\t\t\t\t\trx={size / 4}\n\t\t\t\t\t\t\t\tx={toDomPrecision(width - size / 4)}\n\t\t\t\t\t\t\t\ty={toDomPrecision(height / 2 - textHandleHeight / 2)}\n\t\t\t\t\t\t\t\twidth={toDomPrecision(size / 2)}\n\t\t\t\t\t\t\t\theight={toDomPrecision(textHandleHeight)}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</>\n\t\t\t\t\t)}\n\t\t\t\t\t{/* Crop Handles */}\n\t\t\t\t\t{showCropHandles && (\n\t\t\t\t\t\t<TldrawCropHandles\n\t\t\t\t\t\t\t{...{\n\t\t\t\t\t\t\t\tsize,\n\t\t\t\t\t\t\t\twidth,\n\t\t\t\t\t\t\t\theight,\n\t\t\t\t\t\t\t\thideAlternateHandles: hideAlternateCropHandles,\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t/>\n\t\t\t\t\t)}\n\t\t\t\t</g>\n\t\t\t</svg>\n\t\t)\n\t}\n)\n\nexport const RotateCornerHandle = function RotateCornerHandle({\n\tcx,\n\tcy,\n\ttargetSize,\n\tcorner,\n\tcursor,\n\tisHidden,\n\t'data-testid': testId,\n}: {\n\tcx: number\n\tcy: number\n\ttargetSize: number\n\tcorner: RotateCorner\n\tcursor?: string\n\tisHidden: boolean\n\t'data-testid'?: string\n}) {\n\tconst events = useSelectionEvents(corner)\n\treturn (\n\t\t<rect\n\t\t\tclassName={classNames('tl-transparent', 'tl-rotate-corner', { 'tl-hidden': isHidden })}\n\t\t\tdata-testid={testId}\n\t\t\taria-label={`${corner} target`}\n\t\t\tpointerEvents=\"all\"\n\t\t\tx={toDomPrecision(cx - targetSize * 3)}\n\t\t\ty={toDomPrecision(cy - targetSize * 3)}\n\t\t\twidth={toDomPrecision(Math.max(1, targetSize * 3))}\n\t\t\theight={toDomPrecision(Math.max(1, targetSize * 3))}\n\t\t\tcursor={cursor}\n\t\t\t{...events}\n\t\t/>\n\t)\n}\n\nconst SQUARE_ROOT_PI = Math.sqrt(Math.PI)\n\nexport const MobileRotateHandle = function RotateHandle({\n\tcx,\n\tcy,\n\tsize,\n\tisHidden,\n\t'data-testid': testId,\n}: {\n\tcx: number\n\tcy: number\n\tsize: number\n\tisHidden: boolean\n\t'data-testid'?: string\n}) {\n\tconst events = useSelectionEvents('mobile_rotate')\n\n\tconst editor = useEditor()\n\tconst zoom = useValue('zoom level', () => editor.getZoomLevel(), [editor])\n\tconst bgRadius = Math.max(14 * (1 / zoom), 20 / Math.max(1, zoom))\n\n\treturn (\n\t\t<g>\n\t\t\t<circle\n\t\t\t\tdata-testid={testId}\n\t\t\t\tpointerEvents=\"all\"\n\t\t\t\tclassName={classNames('tl-transparent', 'tl-mobile-rotate__bg', { 'tl-hidden': isHidden })}\n\t\t\t\tcx={cx}\n\t\t\t\tcy={cy}\n\t\t\t\tr={bgRadius}\n\t\t\t\t{...events}\n\t\t\t/>\n\t\t\t<circle\n\t\t\t\tclassName={classNames('tl-mobile-rotate__fg', { 'tl-hidden': isHidden })}\n\t\t\t\tcx={cx}\n\t\t\t\tcy={cy}\n\t\t\t\tr={size / SQUARE_ROOT_PI}\n\t\t\t/>\n\t\t</g>\n\t)\n}\n"],
|
|
5
|
-
"mappings": "AAsMM,SAqKA,UArKA,KAqKA,YArKA;AAtMN;AAAA,EAMC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,OAAO,gBAAgB;AACvB,SAAS,cAAc;AACvB,SAAS,mBAAmB;AAC5B,SAAS,yBAAyB;AAG3B,MAAM,4BAA4D;AAAA,EACxE,SAASA,2BAA0B,EAAE,QAAQ,SAAS,GAAwC;AAC7F,UAAM,SAAS,UAAU;AACzB,UAAM,OAAO,OAAsB,IAAI;AAEvC,UAAM,iBAAiB,YAAY;AACnC,UAAM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
|
6
6
|
"names": ["TldrawSelectionForeground", "RotateCornerHandle"]
|
|
7
7
|
}
|
|
@@ -123,8 +123,7 @@ function registerDefaultExternalContentHandlers(editor, {
|
|
|
123
123
|
type: "file",
|
|
124
124
|
file: new File([text], "asset.svg", { type: "image/svg+xml" })
|
|
125
125
|
});
|
|
126
|
-
if (!asset)
|
|
127
|
-
throw Error("Could not create an asset");
|
|
126
|
+
if (!asset) throw Error("Could not create an asset");
|
|
128
127
|
createShapesForAssets(editor, [asset], position);
|
|
129
128
|
});
|
|
130
129
|
editor.registerExternalContentHandler("embed", ({ point, url, embed }) => {
|
|
@@ -253,8 +252,7 @@ function registerDefaultExternalContentHandlers(editor, {
|
|
|
253
252
|
if (!asset) {
|
|
254
253
|
shouldAlsoCreateAsset = true;
|
|
255
254
|
const bookmarkAsset = await editor.getAssetForExternalContent({ type: "url", url });
|
|
256
|
-
if (!bookmarkAsset)
|
|
257
|
-
throw Error("Could not create an asset");
|
|
255
|
+
if (!bookmarkAsset) throw Error("Could not create an asset");
|
|
258
256
|
asset = bookmarkAsset;
|
|
259
257
|
}
|
|
260
258
|
editor.batch(() => {
|
|
@@ -274,8 +272,7 @@ function registerDefaultExternalContentHandlers(editor, {
|
|
|
274
272
|
});
|
|
275
273
|
}
|
|
276
274
|
async function createShapesForAssets(editor, assets, position) {
|
|
277
|
-
if (!assets.length)
|
|
278
|
-
return [];
|
|
275
|
+
if (!assets.length) return [];
|
|
279
276
|
const currentPoint = Vec2d.From(position);
|
|
280
277
|
const partials = [];
|
|
281
278
|
for (const asset of assets) {
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/lib/defaultExternalContentHandlers.ts"],
|
|
4
4
|
"sourcesContent": ["import {\n\tAssetRecordType,\n\tEditor,\n\tMediaHelpers,\n\tTLAsset,\n\tTLAssetId,\n\tTLBookmarkShape,\n\tTLEmbedShape,\n\tTLShapeId,\n\tTLShapePartial,\n\tTLTextShape,\n\tTLTextShapeProps,\n\tVec2d,\n\tVecLike,\n\tcompact,\n\tcreateShapeId,\n\tgetHashForString,\n} from '@bigbluebutton/editor'\nimport { FONT_FAMILIES, FONT_SIZES, TEXT_PROPS } from './shapes/shared/default-shape-constants'\nimport { containBoxSize, getResizedImageDataUrl, isGifAnimated } from './utils/assets/assets'\nimport { getEmbedInfo } from './utils/embeds/embeds'\nimport { cleanupText, isRightToLeftLanguage, truncateStringWithEllipsis } from './utils/text/text'\n\n/** @public */\nexport type TLExternalContentProps = {\n\t// The maximum dimension (width or height) of an image. Images larger than this will be rescaled to fit. Defaults to infinity.\n\tmaxImageDimension: number\n\t// The maximum size (in bytes) of an asset. Assets larger than this will be rejected. Defaults to 10mb (10 * 1024 * 1024).\n\tmaxAssetSize: number\n\t// The mime types of images that are allowed to be handled. Defaults to ['image/jpeg', 'image/png', 'image/gif', 'image/svg+xml'].\n\tacceptedImageMimeTypes: string[]\n\t// The mime types of videos that are allowed to be handled. Defaults to ['video/mp4', 'video/webm', 'video/quicktime'].\n\tacceptedVideoMimeTypes: string[]\n}\n\nexport function registerDefaultExternalContentHandlers(\n\teditor: Editor,\n\t{\n\t\tmaxImageDimension,\n\t\tmaxAssetSize,\n\t\tacceptedImageMimeTypes,\n\t\tacceptedVideoMimeTypes,\n\t}: TLExternalContentProps\n) {\n\t// files -> asset\n\teditor.registerExternalAssetHandler('file', async ({ file }) => {\n\t\treturn await new Promise((resolve, reject) => {\n\t\t\tif (\n\t\t\t\t!acceptedImageMimeTypes.includes(file.type) &&\n\t\t\t\t!acceptedVideoMimeTypes.includes(file.type)\n\t\t\t) {\n\t\t\t\tconsole.warn(`File type not allowed: ${file.type}`)\n\t\t\t\treject()\n\t\t\t}\n\n\t\t\tif (file.size > maxAssetSize) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`File size too big: ${(file.size / 1024).toFixed()}kb > ${(\n\t\t\t\t\t\tmaxAssetSize / 1024\n\t\t\t\t\t).toFixed()}kb`\n\t\t\t\t)\n\t\t\t\treject()\n\t\t\t}\n\n\t\t\tconst reader = new FileReader()\n\t\t\treader.onerror = () => reject(reader.error)\n\t\t\treader.onload = async () => {\n\t\t\t\tlet dataUrl = reader.result as string\n\n\t\t\t\t// Hack to make .mov videos work via dataURL.\n\t\t\t\tif (file.type === 'video/quicktime' && dataUrl.includes('video/quicktime')) {\n\t\t\t\t\tdataUrl = dataUrl.replace('video/quicktime', 'video/mp4')\n\t\t\t\t}\n\n\t\t\t\tconst isImageType = acceptedImageMimeTypes.includes(file.type)\n\n\t\t\t\tlet size: {\n\t\t\t\t\tw: number\n\t\t\t\t\th: number\n\t\t\t\t}\n\t\t\t\tlet isAnimated: boolean\n\n\t\t\t\tif (isImageType) {\n\t\t\t\t\tsize = await MediaHelpers.getImageSizeFromSrc(dataUrl)\n\t\t\t\t\tisAnimated = file.type === 'image/gif' && (await isGifAnimated(file))\n\t\t\t\t} else {\n\t\t\t\t\tisAnimated = true\n\t\t\t\t\tsize = await MediaHelpers.getVideoSizeFromSrc(dataUrl)\n\t\t\t\t}\n\n\t\t\t\tif (isFinite(maxImageDimension)) {\n\t\t\t\t\tconst resizedSize = containBoxSize(size, { w: maxImageDimension, h: maxImageDimension })\n\t\t\t\t\tif (size !== resizedSize && (file.type === 'image/jpeg' || file.type === 'image/png')) {\n\t\t\t\t\t\tsize = resizedSize\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Always rescale the image\n\t\t\t\tif (file.type === 'image/jpeg' || file.type === 'image/png') {\n\t\t\t\t\tdataUrl = await getResizedImageDataUrl(dataUrl, size.w, size.h, {\n\t\t\t\t\t\ttype: file.type,\n\t\t\t\t\t\tquality: 0.92,\n\t\t\t\t\t})\n\t\t\t\t}\n\n\t\t\t\tconst assetId: TLAssetId = AssetRecordType.createId(getHashForString(dataUrl))\n\n\t\t\t\tconst asset = AssetRecordType.create({\n\t\t\t\t\tid: assetId,\n\t\t\t\t\ttype: isImageType ? 'image' : 'video',\n\t\t\t\t\ttypeName: 'asset',\n\t\t\t\t\tprops: {\n\t\t\t\t\t\tname: file.name,\n\t\t\t\t\t\tsrc: dataUrl,\n\t\t\t\t\t\tw: size.w,\n\t\t\t\t\t\th: size.h,\n\t\t\t\t\t\tmimeType: file.type,\n\t\t\t\t\t\tisAnimated,\n\t\t\t\t\t},\n\t\t\t\t})\n\n\t\t\t\tresolve(asset)\n\t\t\t}\n\n\t\t\treader.readAsDataURL(file)\n\t\t})\n\t})\n\n\t// urls -> bookmark asset\n\teditor.registerExternalAssetHandler('url', async ({ url }) => {\n\t\tlet meta: { image: string; title: string; description: string }\n\n\t\ttry {\n\t\t\tconst resp = await fetch(url, { method: 'GET', mode: 'no-cors' })\n\t\t\tconst html = await resp.text()\n\t\t\tconst doc = new DOMParser().parseFromString(html, 'text/html')\n\t\t\tmeta = {\n\t\t\t\timage: doc.head.querySelector('meta[property=\"og:image\"]')?.getAttribute('content') ?? '',\n\t\t\t\ttitle:\n\t\t\t\t\tdoc.head.querySelector('meta[property=\"og:title\"]')?.getAttribute('content') ??\n\t\t\t\t\ttruncateStringWithEllipsis(url, 32),\n\t\t\t\tdescription:\n\t\t\t\t\tdoc.head.querySelector('meta[property=\"og:description\"]')?.getAttribute('content') ?? '',\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconsole.error(error)\n\t\t\tmeta = { image: '', title: truncateStringWithEllipsis(url, 32), description: '' }\n\t\t}\n\n\t\t// Create the bookmark asset from the meta\n\t\treturn {\n\t\t\tid: AssetRecordType.createId(getHashForString(url)),\n\t\t\ttypeName: 'asset',\n\t\t\ttype: 'bookmark',\n\t\t\tprops: {\n\t\t\t\tsrc: url,\n\t\t\t\tdescription: meta.description,\n\t\t\t\timage: meta.image,\n\t\t\t\ttitle: meta.title,\n\t\t\t},\n\t\t\tmeta: {},\n\t\t}\n\t})\n\n\t// svg text\n\teditor.registerExternalContentHandler('svg-text', async ({ point, text }) => {\n\t\tconst position =\n\t\t\tpoint ??\n\t\t\t(editor.inputs.shiftKey ? editor.inputs.currentPagePoint : editor.getViewportPageCenter())\n\n\t\tconst svg = new DOMParser().parseFromString(text, 'image/svg+xml').querySelector('svg')\n\t\tif (!svg) {\n\t\t\tthrow new Error('No <svg/> element present')\n\t\t}\n\n\t\tlet width = parseFloat(svg.getAttribute('width') || '0')\n\t\tlet height = parseFloat(svg.getAttribute('height') || '0')\n\n\t\tif (!(width && height)) {\n\t\t\tdocument.body.appendChild(svg)\n\t\t\tconst box = svg.getBoundingClientRect()\n\t\t\tdocument.body.removeChild(svg)\n\n\t\t\twidth = box.width\n\t\t\theight = box.height\n\t\t}\n\n\t\tconst asset = await editor.getAssetForExternalContent({\n\t\t\ttype: 'file',\n\t\t\tfile: new File([text], 'asset.svg', { type: 'image/svg+xml' }),\n\t\t})\n\n\t\tif (!asset) throw Error('Could not create an asset')\n\n\t\tcreateShapesForAssets(editor, [asset], position)\n\t})\n\n\t// embeds\n\teditor.registerExternalContentHandler('embed', ({ point, url, embed }) => {\n\t\tconst position =\n\t\t\tpoint ??\n\t\t\t(editor.inputs.shiftKey ? editor.inputs.currentPagePoint : editor.getViewportPageCenter())\n\n\t\tconst { width, height } = embed\n\n\t\tconst id = createShapeId()\n\n\t\tconst shapePartial: TLShapePartial<TLEmbedShape> = {\n\t\t\tid,\n\t\t\ttype: 'embed',\n\t\t\tx: position.x - (width || 450) / 2,\n\t\t\ty: position.y - (height || 450) / 2,\n\t\t\tprops: {\n\t\t\t\tw: width,\n\t\t\t\th: height,\n\t\t\t\turl,\n\t\t\t},\n\t\t}\n\n\t\teditor.createShapes([shapePartial]).select(id)\n\t})\n\n\t// files\n\teditor.registerExternalContentHandler('files', async ({ point, files }) => {\n\t\tconst position =\n\t\t\tpoint ??\n\t\t\t(editor.inputs.shiftKey ? editor.inputs.currentPagePoint : editor.getViewportPageCenter())\n\n\t\tconst pagePoint = new Vec2d(position.x, position.y)\n\n\t\tconst assets: TLAsset[] = []\n\n\t\tawait Promise.all(\n\t\t\tfiles.map(async (file, i) => {\n\t\t\t\tif (file.size > maxAssetSize) {\n\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t`File size too big: ${(file.size / 1024).toFixed()}kb > ${(\n\t\t\t\t\t\t\tmaxAssetSize / 1024\n\t\t\t\t\t\t).toFixed()}kb`\n\t\t\t\t\t)\n\t\t\t\t\treturn null\n\t\t\t\t}\n\n\t\t\t\t// Use mime type instead of file ext, this is because\n\t\t\t\t// window.navigator.clipboard does not preserve file names\n\t\t\t\t// of copied files.\n\t\t\t\tif (!file.type) {\n\t\t\t\t\tthrow new Error('No mime type')\n\t\t\t\t}\n\n\t\t\t\t// We can only accept certain extensions (either images or a videos)\n\t\t\t\tif (!acceptedImageMimeTypes.concat(acceptedVideoMimeTypes).includes(file.type)) {\n\t\t\t\t\tconsole.warn(`${file.name} not loaded - Extension not allowed.`)\n\t\t\t\t\treturn null\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tconst asset = await editor.getAssetForExternalContent({ type: 'file', file })\n\n\t\t\t\t\tif (!asset) {\n\t\t\t\t\t\tthrow Error('Could not create an asset')\n\t\t\t\t\t}\n\n\t\t\t\t\tassets[i] = asset\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconsole.error(error)\n\t\t\t\t\treturn null\n\t\t\t\t}\n\t\t\t})\n\t\t)\n\n\t\tcreateShapesForAssets(editor, compact(assets), pagePoint)\n\t})\n\n\t// text\n\teditor.registerExternalContentHandler('text', async ({ point, text }) => {\n\t\tconst p =\n\t\t\tpoint ??\n\t\t\t(editor.inputs.shiftKey ? editor.inputs.currentPagePoint : editor.getViewportPageCenter())\n\n\t\tconst defaultProps = editor.getShapeUtil<TLTextShape>('text').getDefaultProps()\n\n\t\tconst textToPaste = cleanupText(text)\n\n\t\t// Measure the text with default values\n\t\tlet w: number\n\t\tlet h: number\n\t\tlet autoSize: boolean\n\t\tlet align = 'middle' as TLTextShapeProps['align']\n\n\t\tconst isMultiLine = textToPaste.split('\\n').length > 1\n\n\t\t// check whether the text contains the most common characters in RTL languages\n\t\tconst isRtl = isRightToLeftLanguage(textToPaste)\n\n\t\tif (isMultiLine) {\n\t\t\talign = isMultiLine ? (isRtl ? 'end' : 'start') : 'middle'\n\t\t}\n\n\t\tconst rawSize = editor.textMeasure.measureText(textToPaste, {\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: null,\n\t\t})\n\n\t\tconst minWidth = Math.min(\n\t\t\tisMultiLine ? editor.getViewportPageBounds().width * 0.9 : 920,\n\t\t\tMath.max(200, editor.getViewportPageBounds().width * 0.9)\n\t\t)\n\n\t\tif (rawSize.w > minWidth) {\n\t\t\tconst shrunkSize = editor.textMeasure.measureText(textToPaste, {\n\t\t\t\t...TEXT_PROPS,\n\t\t\t\tfontFamily: FONT_FAMILIES[defaultProps.font],\n\t\t\t\tfontSize: FONT_SIZES[defaultProps.size],\n\t\t\t\tmaxWidth: minWidth,\n\t\t\t})\n\t\t\tw = shrunkSize.w\n\t\t\th = shrunkSize.h\n\t\t\tautoSize = false\n\t\t\talign = isRtl ? 'end' : 'start'\n\t\t} else {\n\t\t\t// autosize is fine\n\t\t\tw = rawSize.w\n\t\t\th = rawSize.h\n\t\t\tautoSize = true\n\t\t}\n\n\t\tif (p.y - h / 2 < editor.getViewportPageBounds().minY + 40) {\n\t\t\tp.y = editor.getViewportPageBounds().minY + 40 + h / 2\n\t\t}\n\n\t\teditor.createShapes<TLTextShape>([\n\t\t\t{\n\t\t\t\tid: createShapeId(),\n\t\t\t\ttype: 'text',\n\t\t\t\tx: p.x - w / 2,\n\t\t\t\ty: p.y - h / 2,\n\t\t\t\tprops: {\n\t\t\t\t\ttext: textToPaste,\n\t\t\t\t\t// if the text has more than one line, align it to the left\n\t\t\t\t\talign,\n\t\t\t\t\tautoSize,\n\t\t\t\t\tw,\n\t\t\t\t},\n\t\t\t},\n\t\t])\n\t})\n\n\t// url\n\teditor.registerExternalContentHandler('url', async ({ point, url }) => {\n\t\t// try to paste as an embed first\n\t\tconst embedInfo = getEmbedInfo(url)\n\n\t\tif (embedInfo) {\n\t\t\treturn editor.putExternalContent({\n\t\t\t\ttype: 'embed',\n\t\t\t\turl: embedInfo.url,\n\t\t\t\tpoint,\n\t\t\t\tembed: embedInfo.definition,\n\t\t\t})\n\t\t}\n\n\t\tconst position =\n\t\t\tpoint ??\n\t\t\t(editor.inputs.shiftKey ? editor.inputs.currentPagePoint : editor.getViewportPageCenter())\n\n\t\tconst assetId: TLAssetId = AssetRecordType.createId(getHashForString(url))\n\t\tconst shape = createEmptyBookmarkShape(editor, url, position)\n\n\t\t// Use an existing asset if we have one, or else else create a new one\n\t\tlet asset = editor.getAsset(assetId) as TLAsset\n\t\tlet shouldAlsoCreateAsset = false\n\t\tif (!asset) {\n\t\t\tshouldAlsoCreateAsset = true\n\t\t\tconst bookmarkAsset = await editor.getAssetForExternalContent({ type: 'url', url })\n\t\t\tif (!bookmarkAsset) throw Error('Could not create an asset')\n\t\t\tasset = bookmarkAsset\n\t\t}\n\n\t\teditor.batch(() => {\n\t\t\tif (shouldAlsoCreateAsset) {\n\t\t\t\teditor.createAssets([asset])\n\t\t\t}\n\n\t\t\teditor.updateShapes([\n\t\t\t\t{\n\t\t\t\t\tid: shape.id,\n\t\t\t\t\ttype: shape.type,\n\t\t\t\t\tprops: {\n\t\t\t\t\t\tassetId: asset.id,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t])\n\t\t})\n\t})\n}\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 = Vec2d.From(position)\n\tconst partials: TLShapePartial[] = []\n\n\tfor (const asset of assets) {\n\t\tswitch (asset.type) {\n\t\t\tcase 'bookmark': {\n\t\t\t\tpartials.push({\n\t\t\t\t\tid: createShapeId(),\n\t\t\t\t\ttype: 'bookmark',\n\t\t\t\t\tx: currentPoint.x - 150,\n\t\t\t\t\ty: currentPoint.y - 160,\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\turl: asset.props.src,\n\t\t\t\t\t},\n\t\t\t\t})\n\n\t\t\t\tcurrentPoint.x += 300\n\t\t\t\tbreak\n\t\t\t}\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 - asset.props.w / 2,\n\t\t\t\t\ty: currentPoint.y - asset.props.h / 2,\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 - asset.props.w / 2,\n\t\t\t\t\ty: currentPoint.y - asset.props.h / 2,\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.batch(() => {\n\t\t// Create any assets\n\t\tconst assetsToCreate = assets.filter((asset) => !editor.getAsset(asset.id))\n\t\tif (assetsToCreate.length) {\n\t\t\teditor.createAssets(assetsToCreate)\n\t\t}\n\n\t\t// Create the shapes\n\t\teditor.createShapes(partials).select(...partials.map((p) => p.id))\n\n\t\t// Re-position shapes so that the center of the group is at the provided point\n\t\tcenterSelectionAroundPoint(editor, position)\n\t})\n\n\treturn partials.map((p) => p.id)\n}\n\nfunction 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 = Vec2d.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\n\t// Zoom out to fit the shapes, if necessary\n\tselectionPageBounds = editor.getSelectionPageBounds()\n\tif (selectionPageBounds && !viewportPageBounds.contains(selectionPageBounds)) {\n\t\teditor.zoomToSelection()\n\t}\n}\n\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.batch(() => {\n\t\teditor.createShapes([partial]).select(partial.id)\n\t\tcenterSelectionAroundPoint(editor, position)\n\t})\n\n\treturn editor.getShape(partial.id) as TLBookmarkShape\n}\n"],
|
|
5
|
-
"mappings": "AAAA;AAAA,EACC;AAAA,EAEA;AAAA,EASA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,eAAe,YAAY,kBAAkB;AACtD,SAAS,gBAAgB,wBAAwB,qB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AAI;AAAA,IAChB,SAAS;AAAA,IACT,OAAO;AAAA,MACN,SAAS;AAAA,MACT;AAAA,IACD;AAAA,EACD;AAEA,SAAO,MAAM,MAAM;AAClB,WAAO,aAAa,CAAC,OAAO,CAAC,EAAE,OAAO,QAAQ,EAAE;AAChD,+BAA2B,QAAQ,QAAQ;AAAA,EAC5C,CAAC;AAED,SAAO,OAAO,SAAS,QAAQ,EAAE;AAClC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -173,8 +173,7 @@ class ArrowShapeUtil extends ShapeUtil {
|
|
|
173
173
|
const B = Vec2d.Add(med, v);
|
|
174
174
|
const point2 = Vec2d.NearestPointOnLineSegment(A, B, handle, false);
|
|
175
175
|
let bend = Vec2d.Dist(point2, med);
|
|
176
|
-
if (Vec2d.Clockwise(point2, end, med))
|
|
177
|
-
bend *= -1;
|
|
176
|
+
if (Vec2d.Clockwise(point2, end, med)) bend *= -1;
|
|
178
177
|
return { id: shape.id, type: shape.type, props: { bend } };
|
|
179
178
|
}
|
|
180
179
|
const next = deepCopy(shape);
|
|
@@ -377,8 +376,7 @@ class ArrowShapeUtil extends ShapeUtil {
|
|
|
377
376
|
const changeIndex = React.useMemo(() => {
|
|
378
377
|
return this.editor.environment.isSafari ? globalRenderIndex += 1 : 0;
|
|
379
378
|
}, [shape]);
|
|
380
|
-
if (!info?.isValid)
|
|
381
|
-
return null;
|
|
379
|
+
if (!info?.isValid) return null;
|
|
382
380
|
const strokeWidth = STROKE_SIZES[shape.props.size];
|
|
383
381
|
const as = info.start.arrowhead && getArrowheadPathForType(info, "start", strokeWidth);
|
|
384
382
|
const ae = info.end.arrowhead && getArrowheadPathForType(info, "end", strokeWidth);
|
|
@@ -522,10 +520,8 @@ class ArrowShapeUtil extends ShapeUtil {
|
|
|
522
520
|
const bounds = geometry.bounds;
|
|
523
521
|
const labelGeometry = shape.props.text.trim() ? geometry.children[1] : null;
|
|
524
522
|
const isEditing = useIsEditing(shape.id);
|
|
525
|
-
if (!info)
|
|
526
|
-
|
|
527
|
-
if (Vec2d.Equals(start, end))
|
|
528
|
-
return null;
|
|
523
|
+
if (!info) return null;
|
|
524
|
+
if (Vec2d.Equals(start, end)) return null;
|
|
529
525
|
const strokeWidth = STROKE_SIZES[shape.props.size];
|
|
530
526
|
const as = info.start.arrowhead && getArrowheadPathForType(info, "start", strokeWidth);
|
|
531
527
|
const ae = info.end.arrowhead && getArrowheadPathForType(info, "end", strokeWidth);
|
|
@@ -641,8 +637,7 @@ class ArrowShapeUtil extends ShapeUtil {
|
|
|
641
637
|
const info = this.editor.getArrowInfo(shape);
|
|
642
638
|
const strokeWidth = STROKE_SIZES[shape.props.size];
|
|
643
639
|
const g = document.createElementNS("http://www.w3.org/2000/svg", "g");
|
|
644
|
-
if (!info)
|
|
645
|
-
return g;
|
|
640
|
+
if (!info) return g;
|
|
646
641
|
const as = info.start.arrowhead && getArrowheadPathForType(info, "start", strokeWidth);
|
|
647
642
|
const ae = info.end.arrowhead && getArrowheadPathForType(info, "end", strokeWidth);
|
|
648
643
|
const geometry = this.editor.getShapeGeometry(shape);
|
|
@@ -660,10 +655,8 @@ class ArrowShapeUtil extends ShapeUtil {
|
|
|
660
655
|
rect.setAttribute("height", bounds.height + 200 + "");
|
|
661
656
|
rect.setAttribute("fill", "white");
|
|
662
657
|
mask.appendChild(rect);
|
|
663
|
-
if (as)
|
|
664
|
-
|
|
665
|
-
if (ae)
|
|
666
|
-
mask.appendChild(getArrowheadSvgMask(ae, info.end.arrowhead));
|
|
658
|
+
if (as) mask.appendChild(getArrowheadSvgMask(as, info.start.arrowhead));
|
|
659
|
+
if (ae) mask.appendChild(getArrowheadSvgMask(ae, info.end.arrowhead));
|
|
667
660
|
if (labelGeometry) {
|
|
668
661
|
const labelMask = document.createElementNS("http://www.w3.org/2000/svg", "rect");
|
|
669
662
|
labelMask.setAttribute("x", labelGeometry.x + "");
|