@excalidraw/excalidraw 0.17.1-d9bbf1e → 0.17.1-e63dd02
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/CHANGELOG.md +4 -0
- package/dist/browser/dev/excalidraw-assets-dev/CascadiaCode-Regular-TMZI7IJ5.woff2 +0 -0
- package/dist/browser/dev/excalidraw-assets-dev/ComicShanns-Regular-6TOETDFT.woff2 +0 -0
- package/dist/browser/dev/excalidraw-assets-dev/Excalifont-Regular-CPKEUDVM.woff2 +0 -0
- package/dist/browser/dev/excalidraw-assets-dev/LiberationSans-Regular-ZQD73GJM.woff2 +0 -0
- package/dist/browser/dev/excalidraw-assets-dev/Virgil-Regular-YHAB2VGJ.woff2 +0 -0
- package/dist/browser/dev/excalidraw-assets-dev/{chunk-XOM7LNOU.js → chunk-IT7T3AIK.js} +49 -8
- package/dist/browser/dev/excalidraw-assets-dev/chunk-IT7T3AIK.js.map +7 -0
- package/dist/browser/dev/excalidraw-assets-dev/{chunk-BLEB3M62.js → chunk-RNHSD5AR.js} +7668 -2142
- package/dist/browser/dev/excalidraw-assets-dev/chunk-RNHSD5AR.js.map +7 -0
- package/dist/browser/dev/excalidraw-assets-dev/{dist-ITJNUBZF.js → dist-DNSPZDOZ.js} +66 -32
- package/dist/browser/dev/excalidraw-assets-dev/dist-DNSPZDOZ.js.map +7 -0
- package/dist/browser/dev/excalidraw-assets-dev/{en-TR4QLF5E.js → en-XV7OZCPP.js} +8 -2
- package/dist/browser/dev/excalidraw-assets-dev/{image-ZGDDRBEN.js → image-77HZYGLG.js} +2 -2
- package/dist/browser/dev/excalidraw-assets-dev/{image-O66MQ7WQ.css → image-WDHYGKKP.css} +1 -1
- package/dist/browser/dev/excalidraw-assets-dev/{image-O66MQ7WQ.css.map → image-WDHYGKKP.css.map} +2 -2
- package/dist/browser/dev/index.css +610 -180
- package/dist/browser/dev/index.css.map +3 -3
- package/dist/browser/dev/index.js +13306 -8006
- package/dist/browser/dev/index.js.map +4 -4
- package/dist/browser/prod/excalidraw-assets/CascadiaCode-Regular-TMZI7IJ5.woff2 +0 -0
- package/dist/browser/prod/excalidraw-assets/ComicShanns-Regular-6TOETDFT.woff2 +0 -0
- package/dist/browser/prod/excalidraw-assets/Excalifont-Regular-CPKEUDVM.woff2 +0 -0
- package/dist/browser/prod/excalidraw-assets/LiberationSans-Regular-ZQD73GJM.woff2 +0 -0
- package/dist/browser/prod/excalidraw-assets/Virgil-Regular-YHAB2VGJ.woff2 +0 -0
- package/dist/browser/prod/excalidraw-assets/chunk-OYEADJSR.js +63 -0
- package/dist/browser/prod/excalidraw-assets/{chunk-5SYIAZGL.js → chunk-PDYFZJMS.js} +5 -5
- package/dist/browser/prod/excalidraw-assets/dist-NLUQPPQQ.js +7 -0
- package/dist/browser/prod/excalidraw-assets/en-YVAVVILW.js +1 -0
- package/dist/browser/prod/excalidraw-assets/image-X3GFZHNN.js +1 -0
- package/dist/browser/prod/index.css +1 -1
- package/dist/browser/prod/index.js +70 -51
- package/dist/dev/CascadiaCode-Regular-TMZI7IJ5.woff2 +0 -0
- package/dist/dev/ComicShanns-Regular-6TOETDFT.woff2 +0 -0
- package/dist/dev/Excalifont-Regular-CPKEUDVM.woff2 +0 -0
- package/dist/dev/LiberationSans-Regular-ZQD73GJM.woff2 +0 -0
- package/dist/dev/Virgil-Regular-YHAB2VGJ.woff2 +0 -0
- package/dist/dev/{en-XW4JO6VX.json → en-YNVBSAIL.json} +42 -7
- package/dist/dev/index.css +610 -180
- package/dist/dev/index.css.map +3 -3
- package/dist/dev/index.js +22165 -16833
- package/dist/dev/index.js.map +4 -4
- package/dist/excalidraw/actions/actionAddToLibrary.d.ts +24 -9
- package/dist/excalidraw/actions/actionAlign.d.ts +8 -8
- package/dist/excalidraw/actions/actionBoundText.d.ts +20 -10
- package/dist/excalidraw/actions/actionBoundText.js +3 -1
- package/dist/excalidraw/actions/actionCanvas.d.ts +100 -40
- package/dist/excalidraw/actions/actionCanvas.js +1 -1
- package/dist/excalidraw/actions/actionClipboard.d.ts +62 -26
- package/dist/excalidraw/actions/actionDeleteSelected.d.ts +28 -12
- package/dist/excalidraw/actions/actionDeleteSelected.js +24 -5
- package/dist/excalidraw/actions/actionDistribute.d.ts +4 -4
- package/dist/excalidraw/actions/actionDuplicateSelection.d.ts +3 -3
- package/dist/excalidraw/actions/actionDuplicateSelection.js +1 -2
- package/dist/excalidraw/actions/actionElementLock.d.ts +17 -7
- package/dist/excalidraw/actions/actionExport.d.ts +75 -30
- package/dist/excalidraw/actions/actionFinalize.d.ts +17 -7
- package/dist/excalidraw/actions/actionFinalize.js +2 -2
- package/dist/excalidraw/actions/actionFlip.d.ts +4 -4
- package/dist/excalidraw/actions/actionFlip.js +2 -2
- package/dist/excalidraw/actions/actionFrame.d.ts +338 -10
- package/dist/excalidraw/actions/actionGroup.d.ts +324 -4
- package/dist/excalidraw/actions/actionHistory.d.ts +3 -3
- package/dist/excalidraw/actions/actionHistory.js +8 -8
- package/dist/excalidraw/actions/actionLinearEditor.d.ts +12 -5
- package/dist/excalidraw/actions/actionLinearEditor.js +21 -5
- package/dist/excalidraw/actions/actionLink.d.ts +8 -3
- package/dist/excalidraw/actions/actionMenu.d.ts +24 -9
- package/dist/excalidraw/actions/actionNavigate.d.ts +17 -7
- package/dist/excalidraw/actions/actionProperties.d.ts +476 -82
- package/dist/excalidraw/actions/actionProperties.js +384 -59
- package/dist/excalidraw/actions/actionSelectAll.d.ts +9 -4
- package/dist/excalidraw/actions/actionStyles.d.ts +12 -4
- package/dist/excalidraw/actions/actionStyles.js +3 -2
- package/dist/excalidraw/actions/actionTextAutoResize.d.ts +17 -0
- package/dist/excalidraw/actions/actionTextAutoResize.js +38 -0
- package/dist/excalidraw/actions/actionToggleGridMode.d.ts +9 -4
- package/dist/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +8 -3
- package/dist/excalidraw/actions/actionToggleStats.d.ts +9 -3
- package/dist/excalidraw/actions/actionToggleStats.js +4 -3
- package/dist/excalidraw/actions/actionToggleViewMode.d.ts +8 -3
- package/dist/excalidraw/actions/actionToggleZenMode.d.ts +8 -3
- package/dist/excalidraw/actions/actionZindex.d.ts +8 -4
- package/dist/excalidraw/actions/actionZindex.js +4 -0
- package/dist/excalidraw/actions/manager.d.ts +3 -3
- package/dist/excalidraw/actions/register.d.ts +1 -1
- package/dist/excalidraw/actions/shortcuts.d.ts +2 -2
- package/dist/excalidraw/actions/types.d.ts +6 -6
- package/dist/excalidraw/align.d.ts +1 -1
- package/dist/excalidraw/analytics.js +9 -7
- package/dist/excalidraw/animated-trail.d.ts +2 -2
- package/dist/excalidraw/appState.d.ts +6 -2
- package/dist/excalidraw/appState.js +14 -3
- package/dist/excalidraw/binaryheap.d.ts +12 -0
- package/dist/excalidraw/binaryheap.js +93 -0
- package/dist/excalidraw/change.d.ts +6 -5
- package/dist/excalidraw/change.js +20 -11
- package/dist/excalidraw/charts.d.ts +1 -1
- package/dist/excalidraw/charts.js +0 -10
- package/dist/excalidraw/clients.d.ts +2 -2
- package/dist/excalidraw/clients.js +1 -1
- package/dist/excalidraw/clipboard.d.ts +3 -3
- package/dist/excalidraw/colors.d.ts +1 -1
- package/dist/excalidraw/components/Actions.d.ts +3 -3
- package/dist/excalidraw/components/Actions.js +14 -9
- package/dist/excalidraw/components/App.d.ts +14 -17
- package/dist/excalidraw/components/App.js +356 -217
- package/dist/excalidraw/components/ButtonIcon.d.ts +15 -0
- package/dist/excalidraw/components/ButtonIcon.js +8 -0
- package/dist/excalidraw/components/ButtonIconSelect.js +2 -3
- package/dist/excalidraw/components/ButtonSeparator.d.ts +2 -0
- package/dist/excalidraw/components/ButtonSeparator.js +7 -0
- package/dist/excalidraw/components/CheckboxItem.js +1 -1
- package/dist/excalidraw/components/ColorPicker/ColorInput.d.ts +1 -1
- package/dist/excalidraw/components/ColorPicker/ColorInput.js +1 -1
- package/dist/excalidraw/components/ColorPicker/ColorPicker.d.ts +4 -4
- package/dist/excalidraw/components/ColorPicker/ColorPicker.js +48 -80
- package/dist/excalidraw/components/ColorPicker/Picker.d.ts +3 -3
- package/dist/excalidraw/components/ColorPicker/Picker.js +1 -1
- package/dist/excalidraw/components/ColorPicker/PickerColorList.d.ts +1 -1
- package/dist/excalidraw/components/ColorPicker/PickerHeading.d.ts +1 -1
- package/dist/excalidraw/components/ColorPicker/ShadeList.d.ts +1 -1
- package/dist/excalidraw/components/ColorPicker/TopPicks.d.ts +1 -1
- package/dist/excalidraw/components/ColorPicker/colorPickerUtils.d.ts +2 -2
- package/dist/excalidraw/components/ColorPicker/colorPickerUtils.js +1 -1
- package/dist/excalidraw/components/ColorPicker/keyboardNavHandlers.d.ts +2 -2
- package/dist/excalidraw/components/ColorPicker/keyboardNavHandlers.js +1 -1
- package/dist/excalidraw/components/CommandPalette/CommandPalette.d.ts +1 -1
- package/dist/excalidraw/components/CommandPalette/CommandPalette.js +5 -5
- package/dist/excalidraw/components/CommandPalette/defaultCommandPaletteItems.d.ts +1 -1
- package/dist/excalidraw/components/CommandPalette/types.d.ts +3 -3
- package/dist/excalidraw/components/ConfirmDialog.d.ts +1 -1
- package/dist/excalidraw/components/ContextMenu.d.ts +2 -2
- package/dist/excalidraw/components/ContextMenu.js +2 -2
- package/dist/excalidraw/components/DarkModeToggle.d.ts +1 -1
- package/dist/excalidraw/components/DefaultSidebar.d.ts +2 -2
- package/dist/excalidraw/components/Dialog.js +1 -1
- package/dist/excalidraw/components/DialogActionButton.d.ts +1 -1
- package/dist/excalidraw/components/EyeDropper.d.ts +2 -2
- package/dist/excalidraw/components/FollowMode/FollowMode.d.ts +1 -1
- package/dist/excalidraw/components/FollowMode/FollowMode.js +1 -1
- package/dist/excalidraw/components/FontPicker/FontPicker.d.ts +21 -0
- package/dist/excalidraw/components/FontPicker/FontPicker.js +49 -0
- package/dist/excalidraw/components/FontPicker/FontPickerList.d.ts +25 -0
- package/dist/excalidraw/components/FontPicker/FontPickerList.js +119 -0
- package/dist/excalidraw/components/FontPicker/FontPickerTrigger.d.ts +7 -0
- package/dist/excalidraw/components/FontPicker/FontPickerTrigger.js +13 -0
- package/dist/excalidraw/components/FontPicker/keyboardNavHandlers.d.ts +14 -0
- package/dist/excalidraw/components/FontPicker/keyboardNavHandlers.js +38 -0
- package/dist/excalidraw/components/HelpDialog.js +2 -2
- package/dist/excalidraw/components/HintViewer.d.ts +1 -1
- package/dist/excalidraw/components/HintViewer.js +6 -3
- package/dist/excalidraw/components/IconPicker.js +2 -2
- package/dist/excalidraw/components/ImageExportDialog.d.ts +1 -1
- package/dist/excalidraw/components/InitializeApp.d.ts +2 -2
- package/dist/excalidraw/components/JSONExportDialog.d.ts +3 -3
- package/dist/excalidraw/components/LayerUI.d.ts +4 -4
- package/dist/excalidraw/components/LayerUI.js +10 -7
- package/dist/excalidraw/components/LibraryMenu.d.ts +2 -2
- package/dist/excalidraw/components/LibraryMenuBrowseButton.d.ts +1 -1
- package/dist/excalidraw/components/LibraryMenuControlButtons.d.ts +1 -1
- package/dist/excalidraw/components/LibraryMenuHeaderContent.d.ts +2 -2
- package/dist/excalidraw/components/LibraryMenuItems.d.ts +1 -1
- package/dist/excalidraw/components/LibraryMenuSection.d.ts +5 -4
- package/dist/excalidraw/components/LibraryUnit.d.ts +2 -2
- package/dist/excalidraw/components/LoadingMessage.d.ts +1 -1
- package/dist/excalidraw/components/MagicSettings.js +2 -2
- package/dist/excalidraw/components/MobileMenu.d.ts +3 -3
- package/dist/excalidraw/components/MobileMenu.js +2 -6
- package/dist/excalidraw/components/Modal.d.ts +1 -1
- package/dist/excalidraw/components/OverwriteConfirm/OverwriteConfirmState.d.ts +1 -1
- package/dist/excalidraw/components/PasteChartDialog.d.ts +1 -1
- package/dist/excalidraw/components/PasteChartDialog.js +1 -1
- package/dist/excalidraw/components/PropertiesPopover.d.ts +15 -0
- package/dist/excalidraw/components/PropertiesPopover.js +31 -0
- package/dist/excalidraw/components/PublishLibrary.d.ts +1 -1
- package/dist/excalidraw/components/QuickSearch.d.ts +9 -0
- package/dist/excalidraw/components/QuickSearch.js +8 -0
- package/dist/excalidraw/components/SVGLayer.d.ts +1 -1
- package/dist/excalidraw/components/ScrollableList.d.ts +9 -0
- package/dist/excalidraw/components/ScrollableList.js +8 -0
- package/dist/excalidraw/components/Sidebar/Sidebar.js +1 -1
- package/dist/excalidraw/components/Sidebar/SidebarTab.d.ts +1 -1
- package/dist/excalidraw/components/Sidebar/SidebarTabTrigger.d.ts +1 -1
- package/dist/excalidraw/components/Sidebar/SidebarTrigger.d.ts +1 -1
- package/dist/excalidraw/components/Sidebar/common.d.ts +1 -1
- package/dist/excalidraw/components/Stats/Angle.d.ts +12 -0
- package/dist/excalidraw/components/Stats/Angle.js +53 -0
- package/dist/excalidraw/components/Stats/Collapsible.d.ts +9 -0
- package/dist/excalidraw/components/Stats/Collapsible.js +12 -0
- package/dist/excalidraw/components/Stats/Dimension.d.ts +12 -0
- package/dist/excalidraw/components/Stats/Dimension.js +68 -0
- package/dist/excalidraw/components/Stats/DragInput.d.ts +32 -0
- package/dist/excalidraw/components/Stats/DragInput.js +174 -0
- package/dist/excalidraw/components/Stats/FontSize.d.ts +12 -0
- package/dist/excalidraw/components/Stats/FontSize.js +50 -0
- package/dist/excalidraw/components/Stats/MultiAngle.d.ts +12 -0
- package/dist/excalidraw/components/Stats/MultiAngle.js +66 -0
- package/dist/excalidraw/components/Stats/MultiDimension.d.ts +15 -0
- package/dist/excalidraw/components/Stats/MultiDimension.js +199 -0
- package/dist/excalidraw/components/Stats/MultiFontSize.d.ts +13 -0
- package/dist/excalidraw/components/Stats/MultiFontSize.js +72 -0
- package/dist/excalidraw/components/Stats/MultiPosition.d.ts +15 -0
- package/dist/excalidraw/components/Stats/MultiPosition.js +101 -0
- package/dist/excalidraw/components/Stats/Position.d.ts +13 -0
- package/dist/excalidraw/components/Stats/Position.js +40 -0
- package/dist/excalidraw/components/Stats/index.d.ts +16 -0
- package/dist/excalidraw/components/Stats/index.js +79 -0
- package/dist/excalidraw/components/Stats/utils.d.ts +26 -0
- package/dist/excalidraw/components/Stats/utils.js +162 -0
- package/dist/excalidraw/components/TTDDialog/MermaidToExcalidraw.d.ts +1 -1
- package/dist/excalidraw/components/TTDDialog/TTDDialog.js +2 -2
- package/dist/excalidraw/components/TTDDialog/TTDDialogInput.d.ts +1 -1
- package/dist/excalidraw/components/TTDDialog/TTDDialogPanel.d.ts +1 -1
- package/dist/excalidraw/components/TTDDialog/TTDDialogPanels.d.ts +1 -1
- package/dist/excalidraw/components/TTDDialog/TTDDialogTabs.d.ts +1 -1
- package/dist/excalidraw/components/TTDDialog/TTDDialogTrigger.d.ts +1 -1
- package/dist/excalidraw/components/TTDDialog/common.d.ts +5 -5
- package/dist/excalidraw/components/TTDDialog/common.js +3 -7
- package/dist/excalidraw/components/TextField.d.ts +1 -1
- package/dist/excalidraw/components/Toast.d.ts +1 -1
- package/dist/excalidraw/components/ToolButton.d.ts +3 -2
- package/dist/excalidraw/components/Trans.d.ts +1 -1
- package/dist/excalidraw/components/UserList.d.ts +1 -1
- package/dist/excalidraw/components/UserList.js +22 -22
- package/dist/excalidraw/components/canvases/InteractiveCanvas.d.ts +3 -2
- package/dist/excalidraw/components/canvases/InteractiveCanvas.js +4 -2
- package/dist/excalidraw/components/canvases/StaticCanvas.d.ts +2 -2
- package/dist/excalidraw/components/canvases/StaticCanvas.js +3 -2
- package/dist/excalidraw/components/dropdownMenu/DropdownMenu.d.ts +12 -3
- package/dist/excalidraw/components/dropdownMenu/DropdownMenuItem.d.ts +24 -4
- package/dist/excalidraw/components/dropdownMenu/DropdownMenuItem.js +55 -14
- package/dist/excalidraw/components/dropdownMenu/DropdownMenuItemContent.d.ts +2 -1
- package/dist/excalidraw/components/dropdownMenu/DropdownMenuItemContent.js +2 -2
- package/dist/excalidraw/components/dropdownMenu/common.d.ts +1 -1
- package/dist/excalidraw/components/dropdownMenu/common.js +3 -2
- package/dist/excalidraw/components/footer/Footer.d.ts +2 -2
- package/dist/excalidraw/components/hyperlink/Hyperlink.d.ts +2 -2
- package/dist/excalidraw/components/hyperlink/helpers.d.ts +3 -3
- package/dist/excalidraw/components/icons.d.ts +10 -2
- package/dist/excalidraw/components/icons.js +29 -6
- package/dist/excalidraw/components/main-menu/MainMenu.d.ts +12 -3
- package/dist/excalidraw/components/welcome-screen/WelcomeScreen.Center.js +2 -2
- package/dist/excalidraw/components/welcome-screen/WelcomeScreen.Hints.js +3 -3
- package/dist/excalidraw/constants.d.ts +24 -3
- package/dist/excalidraw/constants.js +28 -4
- package/dist/excalidraw/context/ui-appState.d.ts +1 -1
- package/dist/excalidraw/cursor.d.ts +1 -1
- package/dist/excalidraw/data/EditorLocalStorage.d.ts +2 -2
- package/dist/excalidraw/data/blob.d.ts +5 -5
- package/dist/excalidraw/data/filesystem.d.ts +2 -1
- package/dist/excalidraw/data/index.d.ts +4 -4
- package/dist/excalidraw/data/json.d.ts +3 -3
- package/dist/excalidraw/data/library.d.ts +3 -3
- package/dist/excalidraw/data/magic.d.ts +3 -3
- package/dist/excalidraw/data/reconcile.d.ts +3 -3
- package/dist/excalidraw/data/reconcile.js +18 -1
- package/dist/excalidraw/data/resave.d.ts +2 -2
- package/dist/excalidraw/data/restore.d.ts +3 -3
- package/dist/excalidraw/data/restore.js +58 -9
- package/dist/excalidraw/data/transform.d.ts +3 -3
- package/dist/excalidraw/data/transform.js +8 -5
- package/dist/excalidraw/data/types.d.ts +3 -3
- package/dist/excalidraw/element/ElementCanvasButtons.d.ts +1 -1
- package/dist/excalidraw/element/binding.d.ts +29 -10
- package/dist/excalidraw/element/binding.js +303 -71
- package/dist/excalidraw/element/bounds.d.ts +3 -3
- package/dist/excalidraw/element/collision.d.ts +4 -4
- package/dist/excalidraw/element/collision.js +5 -2
- package/dist/excalidraw/element/containerCache.d.ts +1 -1
- package/dist/excalidraw/element/dragElements.d.ts +6 -6
- package/dist/excalidraw/element/dragElements.js +39 -5
- package/dist/excalidraw/element/embeddable.d.ts +11 -6
- package/dist/excalidraw/element/heading.d.ts +11 -0
- package/dist/excalidraw/element/heading.js +81 -0
- package/dist/excalidraw/element/image.d.ts +2 -2
- package/dist/excalidraw/element/index.d.ts +2 -2
- package/dist/excalidraw/element/index.js +1 -1
- package/dist/excalidraw/element/linearElementEditor.d.ts +27 -16
- package/dist/excalidraw/element/linearElementEditor.js +133 -56
- package/dist/excalidraw/element/mutateElement.d.ts +3 -3
- package/dist/excalidraw/element/mutateElement.js +5 -3
- package/dist/excalidraw/element/newElement.d.ts +12 -10
- package/dist/excalidraw/element/newElement.js +31 -16
- package/dist/excalidraw/element/resizeElements.d.ts +15 -6
- package/dist/excalidraw/element/resizeElements.js +122 -46
- package/dist/excalidraw/element/resizeTest.d.ts +4 -4
- package/dist/excalidraw/element/resizeTest.js +2 -4
- package/dist/excalidraw/element/routing.d.ts +13 -0
- package/dist/excalidraw/element/routing.js +641 -0
- package/dist/excalidraw/element/showSelectedShapeActions.d.ts +2 -2
- package/dist/excalidraw/element/sizeHelpers.d.ts +2 -2
- package/dist/excalidraw/element/sortElements.d.ts +1 -1
- package/dist/excalidraw/element/textElement.d.ts +6 -28
- package/dist/excalidraw/element/textElement.js +64 -112
- package/dist/excalidraw/element/textWysiwyg.d.ts +12 -6
- package/dist/excalidraw/element/textWysiwyg.js +75 -62
- package/dist/excalidraw/element/transformHandles.d.ts +3 -3
- package/dist/excalidraw/element/transformHandles.js +7 -12
- package/dist/excalidraw/element/typeChecks.d.ts +7 -4
- package/dist/excalidraw/element/typeChecks.js +17 -0
- package/dist/excalidraw/element/types.d.ts +22 -4
- package/dist/excalidraw/emitter.d.ts +1 -1
- package/dist/excalidraw/fonts/ExcalidrawFont.d.ts +21 -0
- package/dist/excalidraw/fonts/ExcalidrawFont.js +112 -0
- package/dist/excalidraw/fonts/index.d.ts +58 -0
- package/dist/excalidraw/fonts/index.js +240 -0
- package/dist/excalidraw/fonts/metadata.d.ts +36 -0
- package/dist/excalidraw/fonts/metadata.js +91 -0
- package/dist/excalidraw/fractionalIndex.d.ts +12 -5
- package/dist/excalidraw/fractionalIndex.js +40 -10
- package/dist/excalidraw/frame.d.ts +4 -4
- package/dist/excalidraw/frame.js +3 -3
- package/dist/excalidraw/gatransforms.d.ts +1 -1
- package/dist/excalidraw/gesture.d.ts +1 -1
- package/dist/excalidraw/groups.d.ts +4 -4
- package/dist/excalidraw/history.d.ts +8 -7
- package/dist/excalidraw/history.js +8 -8
- package/dist/excalidraw/hooks/useEmitter.d.ts +1 -1
- package/dist/excalidraw/hooks/useLibraryItemSvg.d.ts +1 -1
- package/dist/excalidraw/i18n.d.ts +1 -1
- package/dist/excalidraw/index.d.ts +2 -2
- package/dist/excalidraw/index.js +3 -3
- package/dist/excalidraw/jotai.d.ts +1 -1
- package/dist/excalidraw/laser-trails.d.ts +3 -2
- package/dist/excalidraw/locales/en.json +42 -7
- package/dist/excalidraw/math.d.ts +47 -2
- package/dist/excalidraw/math.js +116 -0
- package/dist/excalidraw/mermaid.d.ts +2 -0
- package/dist/excalidraw/mermaid.js +29 -0
- package/dist/excalidraw/points.d.ts +1 -1
- package/dist/excalidraw/queue.d.ts +1 -1
- package/dist/excalidraw/renderer/helpers.d.ts +2 -2
- package/dist/excalidraw/renderer/interactiveScene.d.ts +2 -2
- package/dist/excalidraw/renderer/interactiveScene.js +64 -22
- package/dist/excalidraw/renderer/renderElement.d.ts +6 -4
- package/dist/excalidraw/renderer/renderElement.js +78 -58
- package/dist/excalidraw/renderer/renderSnaps.d.ts +1 -1
- package/dist/excalidraw/renderer/staticScene.d.ts +1 -1
- package/dist/excalidraw/renderer/staticSvgScene.d.ts +4 -4
- package/dist/excalidraw/renderer/staticSvgScene.js +2 -1
- package/dist/excalidraw/scene/Renderer.d.ts +4 -4
- package/dist/excalidraw/scene/Renderer.js +2 -3
- package/dist/excalidraw/scene/Scene.d.ts +16 -7
- package/dist/excalidraw/scene/Scene.js +26 -11
- package/dist/excalidraw/scene/Shape.d.ts +1 -1
- package/dist/excalidraw/scene/Shape.js +56 -5
- package/dist/excalidraw/scene/ShapeCache.d.ts +4 -4
- package/dist/excalidraw/scene/comparisons.d.ts +3 -2
- package/dist/excalidraw/scene/comparisons.js +1 -1
- package/dist/excalidraw/scene/export.d.ts +4 -3
- package/dist/excalidraw/scene/export.js +34 -36
- package/dist/excalidraw/scene/scroll.d.ts +2 -2
- package/dist/excalidraw/scene/scrollbars.d.ts +3 -3
- package/dist/excalidraw/scene/selection.d.ts +2 -2
- package/dist/excalidraw/scene/types.d.ts +6 -8
- package/dist/excalidraw/scene/zoom.d.ts +1 -1
- package/dist/excalidraw/shapes.d.ts +8 -0
- package/dist/excalidraw/shapes.js +57 -0
- package/dist/excalidraw/snapping.d.ts +4 -4
- package/dist/excalidraw/snapping.js +2 -1
- package/dist/excalidraw/store.d.ts +34 -4
- package/dist/excalidraw/store.js +27 -0
- package/dist/excalidraw/types.d.ts +32 -21
- package/dist/excalidraw/utils.d.ts +15 -5
- package/dist/excalidraw/utils.js +22 -0
- package/dist/excalidraw/zindex.d.ts +2 -2
- package/dist/prod/CascadiaCode-Regular-TMZI7IJ5.woff2 +0 -0
- package/dist/prod/ComicShanns-Regular-6TOETDFT.woff2 +0 -0
- package/dist/prod/Excalifont-Regular-CPKEUDVM.woff2 +0 -0
- package/dist/prod/LiberationSans-Regular-ZQD73GJM.woff2 +0 -0
- package/dist/prod/Virgil-Regular-YHAB2VGJ.woff2 +0 -0
- package/dist/prod/{en-XW4JO6VX.json → en-YNVBSAIL.json} +42 -7
- package/dist/prod/index.css +1 -1
- package/dist/prod/index.js +49 -53
- package/dist/utils/bbox.d.ts +2 -2
- package/dist/utils/collision.d.ts +1 -1
- package/dist/utils/export.d.ts +4 -3
- package/dist/utils/export.js +2 -1
- package/dist/utils/geometry/geometry.d.ts +3 -2
- package/dist/utils/geometry/geometry.js +5 -1
- package/dist/utils/geometry/shape.d.ts +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/withinBounds.d.ts +1 -1
- package/history.ts +13 -6
- package/package.json +2 -2
- package/dist/browser/dev/Cascadia-CYPE3OJC.woff2 +0 -0
- package/dist/browser/dev/Virgil-UZN6MUT6.woff2 +0 -0
- package/dist/browser/dev/excalidraw-assets-dev/chunk-BLEB3M62.js.map +0 -7
- package/dist/browser/dev/excalidraw-assets-dev/chunk-XOM7LNOU.js.map +0 -7
- package/dist/browser/dev/excalidraw-assets-dev/dist-ITJNUBZF.js.map +0 -7
- package/dist/browser/prod/Cascadia-CYPE3OJC.woff2 +0 -0
- package/dist/browser/prod/Virgil-UZN6MUT6.woff2 +0 -0
- package/dist/browser/prod/excalidraw-assets/chunk-UWBW5SR2.js +0 -55
- package/dist/browser/prod/excalidraw-assets/dist-54276HPL.js +0 -6
- package/dist/browser/prod/excalidraw-assets/en-7GPZE2Y2.js +0 -1
- package/dist/browser/prod/excalidraw-assets/image-35KQQ5EN.js +0 -1
- package/dist/dev/Cascadia-CYPE3OJC.woff2 +0 -0
- package/dist/dev/Virgil-UZN6MUT6.woff2 +0 -0
- package/dist/excalidraw/components/Stats.d.ts +0 -11
- package/dist/excalidraw/components/Stats.js +0 -13
- package/dist/excalidraw/scene/Fonts.d.ts +0 -21
- package/dist/excalidraw/scene/Fonts.js +0 -72
- package/dist/prod/Cascadia-CYPE3OJC.woff2 +0 -0
- package/dist/prod/Virgil-UZN6MUT6.woff2 +0 -0
- /package/dist/browser/dev/{Assistant-Bold-ZDZZ6JHA.woff2 → excalidraw-assets-dev/Assistant-Bold-ZDZZ6JHA.woff2} +0 -0
- /package/dist/browser/dev/{Assistant-Medium-DZ25RZU3.woff2 → excalidraw-assets-dev/Assistant-Medium-DZ25RZU3.woff2} +0 -0
- /package/dist/browser/dev/{Assistant-Regular-PLF2XOGW.woff2 → excalidraw-assets-dev/Assistant-Regular-PLF2XOGW.woff2} +0 -0
- /package/dist/browser/dev/{Assistant-SemiBold-CZ5MX6FK.woff2 → excalidraw-assets-dev/Assistant-SemiBold-CZ5MX6FK.woff2} +0 -0
- /package/dist/browser/dev/excalidraw-assets-dev/{en-TR4QLF5E.js.map → en-XV7OZCPP.js.map} +0 -0
- /package/dist/browser/dev/excalidraw-assets-dev/{image-ZGDDRBEN.js.map → image-77HZYGLG.js.map} +0 -0
- /package/dist/browser/prod/{Assistant-Bold-ZDZZ6JHA.woff2 → excalidraw-assets/Assistant-Bold-ZDZZ6JHA.woff2} +0 -0
- /package/dist/browser/prod/{Assistant-Medium-DZ25RZU3.woff2 → excalidraw-assets/Assistant-Medium-DZ25RZU3.woff2} +0 -0
- /package/dist/browser/prod/{Assistant-Regular-PLF2XOGW.woff2 → excalidraw-assets/Assistant-Regular-PLF2XOGW.woff2} +0 -0
- /package/dist/browser/prod/{Assistant-SemiBold-CZ5MX6FK.woff2 → excalidraw-assets/Assistant-SemiBold-CZ5MX6FK.woff2} +0 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { mutateElement } from "../../element/mutateElement";
|
|
3
|
+
import { getBoundTextElement } from "../../element/textElement";
|
|
4
|
+
import { isArrowElement } from "../../element/typeChecks";
|
|
5
|
+
import { isInGroup } from "../../groups";
|
|
6
|
+
import { degreeToRadian, radianToDegree } from "../../math";
|
|
7
|
+
import { angleIcon } from "../icons";
|
|
8
|
+
import DragInput from "./DragInput";
|
|
9
|
+
import { getStepSizedValue, isPropertyEditable } from "./utils";
|
|
10
|
+
const STEP_SIZE = 15;
|
|
11
|
+
const handleDegreeChange = ({ accumulatedChange, originalElements, shouldChangeByStepSize, nextValue, property, scene, }) => {
|
|
12
|
+
const elementsMap = scene.getNonDeletedElementsMap();
|
|
13
|
+
const editableLatestIndividualElements = originalElements
|
|
14
|
+
.map((el) => elementsMap.get(el.id))
|
|
15
|
+
.filter((el) => el && !isInGroup(el) && isPropertyEditable(el, property));
|
|
16
|
+
const editableOriginalIndividualElements = originalElements.filter((el) => !isInGroup(el) && isPropertyEditable(el, property));
|
|
17
|
+
if (nextValue !== undefined) {
|
|
18
|
+
const nextAngle = degreeToRadian(nextValue);
|
|
19
|
+
for (const element of editableLatestIndividualElements) {
|
|
20
|
+
if (!element) {
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
mutateElement(element, {
|
|
24
|
+
angle: nextAngle,
|
|
25
|
+
}, false);
|
|
26
|
+
const boundTextElement = getBoundTextElement(element, elementsMap);
|
|
27
|
+
if (boundTextElement && !isArrowElement(element)) {
|
|
28
|
+
mutateElement(boundTextElement, { angle: nextAngle }, false);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
scene.triggerUpdate();
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
for (let i = 0; i < editableLatestIndividualElements.length; i++) {
|
|
35
|
+
const latestElement = editableLatestIndividualElements[i];
|
|
36
|
+
if (!latestElement) {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
const originalElement = editableOriginalIndividualElements[i];
|
|
40
|
+
const originalAngleInDegrees = Math.round(radianToDegree(originalElement.angle) * 100) / 100;
|
|
41
|
+
const changeInDegrees = Math.round(accumulatedChange);
|
|
42
|
+
let nextAngleInDegrees = (originalAngleInDegrees + changeInDegrees) % 360;
|
|
43
|
+
if (shouldChangeByStepSize) {
|
|
44
|
+
nextAngleInDegrees = getStepSizedValue(nextAngleInDegrees, STEP_SIZE);
|
|
45
|
+
}
|
|
46
|
+
nextAngleInDegrees =
|
|
47
|
+
nextAngleInDegrees < 0 ? nextAngleInDegrees + 360 : nextAngleInDegrees;
|
|
48
|
+
const nextAngle = degreeToRadian(nextAngleInDegrees);
|
|
49
|
+
mutateElement(latestElement, {
|
|
50
|
+
angle: nextAngle,
|
|
51
|
+
}, false);
|
|
52
|
+
const boundTextElement = getBoundTextElement(latestElement, elementsMap);
|
|
53
|
+
if (boundTextElement && !isArrowElement(latestElement)) {
|
|
54
|
+
mutateElement(boundTextElement, { angle: nextAngle }, false);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
scene.triggerUpdate();
|
|
58
|
+
};
|
|
59
|
+
const MultiAngle = ({ elements, scene, appState, property, }) => {
|
|
60
|
+
const editableLatestIndividualElements = elements.filter((el) => !isInGroup(el) && isPropertyEditable(el, "angle"));
|
|
61
|
+
const angles = editableLatestIndividualElements.map((el) => Math.round((radianToDegree(el.angle) % 360) * 100) / 100);
|
|
62
|
+
const value = new Set(angles).size === 1 ? angles[0] : "Mixed";
|
|
63
|
+
const editable = editableLatestIndividualElements.some((el) => isPropertyEditable(el, "angle"));
|
|
64
|
+
return (_jsx(DragInput, { label: "A", icon: angleIcon, value: value, elements: elements, dragInputCallback: handleDegreeChange, editable: editable, appState: appState, scene: scene, property: property }));
|
|
65
|
+
};
|
|
66
|
+
export default MultiAngle;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { ExcalidrawElement, NonDeletedSceneElementsMap } from "../../element/types";
|
|
3
|
+
import type Scene from "../../scene/Scene";
|
|
4
|
+
import type { AppState } from "../../types";
|
|
5
|
+
import type { AtomicUnit } from "./utils";
|
|
6
|
+
interface MultiDimensionProps {
|
|
7
|
+
property: "width" | "height";
|
|
8
|
+
elements: readonly ExcalidrawElement[];
|
|
9
|
+
elementsMap: NonDeletedSceneElementsMap;
|
|
10
|
+
atomicUnits: AtomicUnit[];
|
|
11
|
+
scene: Scene;
|
|
12
|
+
appState: AppState;
|
|
13
|
+
}
|
|
14
|
+
declare const MultiDimension: ({ property, elements, elementsMap, atomicUnits, scene, appState, }: MultiDimensionProps) => JSX.Element;
|
|
15
|
+
export default MultiDimension;
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
import { getCommonBounds, isTextElement } from "../../element";
|
|
4
|
+
import { updateBoundElements } from "../../element/binding";
|
|
5
|
+
import { mutateElement } from "../../element/mutateElement";
|
|
6
|
+
import { rescalePointsInElement } from "../../element/resizeElements";
|
|
7
|
+
import { getBoundTextElement, handleBindTextResize, } from "../../element/textElement";
|
|
8
|
+
import DragInput from "./DragInput";
|
|
9
|
+
import { getAtomicUnits, getStepSizedValue, isPropertyEditable } from "./utils";
|
|
10
|
+
import { getElementsInAtomicUnit, resizeElement } from "./utils";
|
|
11
|
+
import { MIN_WIDTH_OR_HEIGHT } from "../../constants";
|
|
12
|
+
const STEP_SIZE = 10;
|
|
13
|
+
const getResizedUpdates = (anchorX, anchorY, scale, origElement) => {
|
|
14
|
+
const offsetX = origElement.x - anchorX;
|
|
15
|
+
const offsetY = origElement.y - anchorY;
|
|
16
|
+
const nextWidth = origElement.width * scale;
|
|
17
|
+
const nextHeight = origElement.height * scale;
|
|
18
|
+
const x = anchorX + offsetX * scale;
|
|
19
|
+
const y = anchorY + offsetY * scale;
|
|
20
|
+
return {
|
|
21
|
+
width: nextWidth,
|
|
22
|
+
height: nextHeight,
|
|
23
|
+
x,
|
|
24
|
+
y,
|
|
25
|
+
...rescalePointsInElement(origElement, nextWidth, nextHeight, false),
|
|
26
|
+
...(isTextElement(origElement)
|
|
27
|
+
? { fontSize: origElement.fontSize * scale }
|
|
28
|
+
: {}),
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
const resizeElementInGroup = (anchorX, anchorY, property, scale, latestElement, origElement, elementsMap, originalElementsMap, scene) => {
|
|
32
|
+
const updates = getResizedUpdates(anchorX, anchorY, scale, origElement);
|
|
33
|
+
const { width: oldWidth, height: oldHeight } = latestElement;
|
|
34
|
+
mutateElement(latestElement, updates, false);
|
|
35
|
+
const boundTextElement = getBoundTextElement(origElement, originalElementsMap);
|
|
36
|
+
if (boundTextElement) {
|
|
37
|
+
const newFontSize = boundTextElement.fontSize * scale;
|
|
38
|
+
updateBoundElements(latestElement, elementsMap, scene, {
|
|
39
|
+
oldSize: { width: oldWidth, height: oldHeight },
|
|
40
|
+
});
|
|
41
|
+
const latestBoundTextElement = elementsMap.get(boundTextElement.id);
|
|
42
|
+
if (latestBoundTextElement && isTextElement(latestBoundTextElement)) {
|
|
43
|
+
mutateElement(latestBoundTextElement, {
|
|
44
|
+
fontSize: newFontSize,
|
|
45
|
+
}, false);
|
|
46
|
+
handleBindTextResize(latestElement, elementsMap, property === "width" ? "e" : "s", true);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
const resizeGroup = (nextWidth, nextHeight, initialHeight, aspectRatio, anchor, property, latestElements, originalElements, elementsMap, originalElementsMap, scene) => {
|
|
51
|
+
// keep aspect ratio for groups
|
|
52
|
+
if (property === "width") {
|
|
53
|
+
nextHeight = Math.round((nextWidth / aspectRatio) * 100) / 100;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
nextWidth = Math.round(nextHeight * aspectRatio * 100) / 100;
|
|
57
|
+
}
|
|
58
|
+
const scale = nextHeight / initialHeight;
|
|
59
|
+
for (let i = 0; i < originalElements.length; i++) {
|
|
60
|
+
const origElement = originalElements[i];
|
|
61
|
+
const latestElement = latestElements[i];
|
|
62
|
+
resizeElementInGroup(anchor[0], anchor[1], property, scale, latestElement, origElement, elementsMap, originalElementsMap, scene);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
const handleDimensionChange = ({ accumulatedChange, originalElements, originalElementsMap, originalAppState, shouldChangeByStepSize, nextValue, scene, property, }) => {
|
|
66
|
+
const elementsMap = scene.getNonDeletedElementsMap();
|
|
67
|
+
const elements = scene.getNonDeletedElements();
|
|
68
|
+
const atomicUnits = getAtomicUnits(originalElements, originalAppState);
|
|
69
|
+
if (nextValue !== undefined) {
|
|
70
|
+
for (const atomicUnit of atomicUnits) {
|
|
71
|
+
const elementsInUnit = getElementsInAtomicUnit(atomicUnit, elementsMap, originalElementsMap);
|
|
72
|
+
if (elementsInUnit.length > 1) {
|
|
73
|
+
const latestElements = elementsInUnit.map((el) => el.latest);
|
|
74
|
+
const originalElements = elementsInUnit.map((el) => el.original);
|
|
75
|
+
const [x1, y1, x2, y2] = getCommonBounds(originalElements);
|
|
76
|
+
const initialWidth = x2 - x1;
|
|
77
|
+
const initialHeight = y2 - y1;
|
|
78
|
+
const aspectRatio = initialWidth / initialHeight;
|
|
79
|
+
const nextWidth = Math.max(MIN_WIDTH_OR_HEIGHT, property === "width" ? Math.max(0, nextValue) : initialWidth);
|
|
80
|
+
const nextHeight = Math.max(MIN_WIDTH_OR_HEIGHT, property === "height" ? Math.max(0, nextValue) : initialHeight);
|
|
81
|
+
resizeGroup(nextWidth, nextHeight, initialHeight, aspectRatio, [x1, y1], property, latestElements, originalElements, elementsMap, originalElementsMap, scene);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
const [el] = elementsInUnit;
|
|
85
|
+
const latestElement = el?.latest;
|
|
86
|
+
const origElement = el?.original;
|
|
87
|
+
if (latestElement &&
|
|
88
|
+
origElement &&
|
|
89
|
+
isPropertyEditable(latestElement, property)) {
|
|
90
|
+
let nextWidth = property === "width" ? Math.max(0, nextValue) : latestElement.width;
|
|
91
|
+
if (property === "width") {
|
|
92
|
+
if (shouldChangeByStepSize) {
|
|
93
|
+
nextWidth = getStepSizedValue(nextWidth, STEP_SIZE);
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
nextWidth = Math.round(nextWidth);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
let nextHeight = property === "height"
|
|
100
|
+
? Math.max(0, nextValue)
|
|
101
|
+
: latestElement.height;
|
|
102
|
+
if (property === "height") {
|
|
103
|
+
if (shouldChangeByStepSize) {
|
|
104
|
+
nextHeight = getStepSizedValue(nextHeight, STEP_SIZE);
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
nextHeight = Math.round(nextHeight);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
nextWidth = Math.max(MIN_WIDTH_OR_HEIGHT, nextWidth);
|
|
111
|
+
nextHeight = Math.max(MIN_WIDTH_OR_HEIGHT, nextHeight);
|
|
112
|
+
resizeElement(nextWidth, nextHeight, false, origElement, elementsMap, elements, scene, false);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
scene.triggerUpdate();
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
const changeInWidth = property === "width" ? accumulatedChange : 0;
|
|
120
|
+
const changeInHeight = property === "height" ? accumulatedChange : 0;
|
|
121
|
+
for (const atomicUnit of atomicUnits) {
|
|
122
|
+
const elementsInUnit = getElementsInAtomicUnit(atomicUnit, elementsMap, originalElementsMap);
|
|
123
|
+
if (elementsInUnit.length > 1) {
|
|
124
|
+
const latestElements = elementsInUnit.map((el) => el.latest);
|
|
125
|
+
const originalElements = elementsInUnit.map((el) => el.original);
|
|
126
|
+
const [x1, y1, x2, y2] = getCommonBounds(originalElements);
|
|
127
|
+
const initialWidth = x2 - x1;
|
|
128
|
+
const initialHeight = y2 - y1;
|
|
129
|
+
const aspectRatio = initialWidth / initialHeight;
|
|
130
|
+
let nextWidth = Math.max(0, initialWidth + changeInWidth);
|
|
131
|
+
if (property === "width") {
|
|
132
|
+
if (shouldChangeByStepSize) {
|
|
133
|
+
nextWidth = getStepSizedValue(nextWidth, STEP_SIZE);
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
nextWidth = Math.round(nextWidth);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
let nextHeight = Math.max(0, initialHeight + changeInHeight);
|
|
140
|
+
if (property === "height") {
|
|
141
|
+
if (shouldChangeByStepSize) {
|
|
142
|
+
nextHeight = getStepSizedValue(nextHeight, STEP_SIZE);
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
nextHeight = Math.round(nextHeight);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
nextWidth = Math.max(MIN_WIDTH_OR_HEIGHT, nextWidth);
|
|
149
|
+
nextHeight = Math.max(MIN_WIDTH_OR_HEIGHT, nextHeight);
|
|
150
|
+
resizeGroup(nextWidth, nextHeight, initialHeight, aspectRatio, [x1, y1], property, latestElements, originalElements, elementsMap, originalElementsMap, scene);
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
const [el] = elementsInUnit;
|
|
154
|
+
const latestElement = el?.latest;
|
|
155
|
+
const origElement = el?.original;
|
|
156
|
+
if (latestElement &&
|
|
157
|
+
origElement &&
|
|
158
|
+
isPropertyEditable(latestElement, property)) {
|
|
159
|
+
let nextWidth = Math.max(0, origElement.width + changeInWidth);
|
|
160
|
+
if (property === "width") {
|
|
161
|
+
if (shouldChangeByStepSize) {
|
|
162
|
+
nextWidth = getStepSizedValue(nextWidth, STEP_SIZE);
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
nextWidth = Math.round(nextWidth);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
let nextHeight = Math.max(0, origElement.height + changeInHeight);
|
|
169
|
+
if (property === "height") {
|
|
170
|
+
if (shouldChangeByStepSize) {
|
|
171
|
+
nextHeight = getStepSizedValue(nextHeight, STEP_SIZE);
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
nextHeight = Math.round(nextHeight);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
nextWidth = Math.max(MIN_WIDTH_OR_HEIGHT, nextWidth);
|
|
178
|
+
nextHeight = Math.max(MIN_WIDTH_OR_HEIGHT, nextHeight);
|
|
179
|
+
resizeElement(nextWidth, nextHeight, false, origElement, elementsMap, elements, scene);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
scene.triggerUpdate();
|
|
184
|
+
};
|
|
185
|
+
const MultiDimension = ({ property, elements, elementsMap, atomicUnits, scene, appState, }) => {
|
|
186
|
+
const sizes = useMemo(() => atomicUnits.map((atomicUnit) => {
|
|
187
|
+
const elementsInUnit = getElementsInAtomicUnit(atomicUnit, elementsMap);
|
|
188
|
+
if (elementsInUnit.length > 1) {
|
|
189
|
+
const [x1, y1, x2, y2] = getCommonBounds(elementsInUnit.map((el) => el.latest));
|
|
190
|
+
return (Math.round((property === "width" ? x2 - x1 : y2 - y1) * 100) / 100);
|
|
191
|
+
}
|
|
192
|
+
const [el] = elementsInUnit;
|
|
193
|
+
return (Math.round((property === "width" ? el.latest.width : el.latest.height) * 100) / 100);
|
|
194
|
+
}), [elementsMap, atomicUnits, property]);
|
|
195
|
+
const value = new Set(sizes).size === 1 ? Math.round(sizes[0] * 100) / 100 : "Mixed";
|
|
196
|
+
const editable = sizes.length > 0;
|
|
197
|
+
return (_jsx(DragInput, { label: property === "width" ? "W" : "H", elements: elements, dragInputCallback: handleDimensionChange, value: value, editable: editable, appState: appState, property: property, scene: scene }));
|
|
198
|
+
};
|
|
199
|
+
export default MultiDimension;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { ExcalidrawElement, NonDeletedSceneElementsMap } from "../../element/types";
|
|
3
|
+
import type Scene from "../../scene/Scene";
|
|
4
|
+
import type { AppState } from "../../types";
|
|
5
|
+
interface MultiFontSizeProps {
|
|
6
|
+
elements: readonly ExcalidrawElement[];
|
|
7
|
+
scene: Scene;
|
|
8
|
+
elementsMap: NonDeletedSceneElementsMap;
|
|
9
|
+
appState: AppState;
|
|
10
|
+
property: "fontSize";
|
|
11
|
+
}
|
|
12
|
+
declare const MultiFontSize: ({ elements, scene, appState, property, elementsMap, }: MultiFontSizeProps) => JSX.Element | null;
|
|
13
|
+
export default MultiFontSize;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { isTextElement, redrawTextBoundingBox } from "../../element";
|
|
3
|
+
import { mutateElement } from "../../element/mutateElement";
|
|
4
|
+
import { hasBoundTextElement } from "../../element/typeChecks";
|
|
5
|
+
import { isInGroup } from "../../groups";
|
|
6
|
+
import { fontSizeIcon } from "../icons";
|
|
7
|
+
import StatsDragInput from "./DragInput";
|
|
8
|
+
import { getStepSizedValue } from "./utils";
|
|
9
|
+
import { getBoundTextElement } from "../../element/textElement";
|
|
10
|
+
const MIN_FONT_SIZE = 4;
|
|
11
|
+
const STEP_SIZE = 4;
|
|
12
|
+
const getApplicableTextElements = (elements, elementsMap) => elements.reduce((acc, el) => {
|
|
13
|
+
if (!el || isInGroup(el)) {
|
|
14
|
+
return acc;
|
|
15
|
+
}
|
|
16
|
+
if (isTextElement(el)) {
|
|
17
|
+
acc.push(el);
|
|
18
|
+
return acc;
|
|
19
|
+
}
|
|
20
|
+
if (hasBoundTextElement(el)) {
|
|
21
|
+
const boundTextElement = getBoundTextElement(el, elementsMap);
|
|
22
|
+
if (boundTextElement) {
|
|
23
|
+
acc.push(boundTextElement);
|
|
24
|
+
return acc;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return acc;
|
|
28
|
+
}, []);
|
|
29
|
+
const handleFontSizeChange = ({ accumulatedChange, originalElements, shouldChangeByStepSize, nextValue, scene, }) => {
|
|
30
|
+
const elementsMap = scene.getNonDeletedElementsMap();
|
|
31
|
+
const latestTextElements = originalElements.map((el) => elementsMap.get(el.id));
|
|
32
|
+
let nextFontSize;
|
|
33
|
+
if (nextValue) {
|
|
34
|
+
nextFontSize = Math.max(Math.round(nextValue), MIN_FONT_SIZE);
|
|
35
|
+
for (const textElement of latestTextElements) {
|
|
36
|
+
mutateElement(textElement, {
|
|
37
|
+
fontSize: nextFontSize,
|
|
38
|
+
}, false);
|
|
39
|
+
redrawTextBoundingBox(textElement, scene.getContainerElement(textElement), elementsMap, false);
|
|
40
|
+
}
|
|
41
|
+
scene.triggerUpdate();
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
const originalTextElements = originalElements;
|
|
45
|
+
for (let i = 0; i < latestTextElements.length; i++) {
|
|
46
|
+
const latestElement = latestTextElements[i];
|
|
47
|
+
const originalElement = originalTextElements[i];
|
|
48
|
+
const originalFontSize = Math.round(originalElement.fontSize);
|
|
49
|
+
const changeInFontSize = Math.round(accumulatedChange);
|
|
50
|
+
let nextFontSize = Math.max(originalFontSize + changeInFontSize, MIN_FONT_SIZE);
|
|
51
|
+
if (shouldChangeByStepSize) {
|
|
52
|
+
nextFontSize = getStepSizedValue(nextFontSize, STEP_SIZE);
|
|
53
|
+
}
|
|
54
|
+
mutateElement(latestElement, {
|
|
55
|
+
fontSize: nextFontSize,
|
|
56
|
+
}, false);
|
|
57
|
+
redrawTextBoundingBox(latestElement, scene.getContainerElement(latestElement), elementsMap, false);
|
|
58
|
+
}
|
|
59
|
+
scene.triggerUpdate();
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
const MultiFontSize = ({ elements, scene, appState, property, elementsMap, }) => {
|
|
63
|
+
const latestTextElements = getApplicableTextElements(elements, elementsMap);
|
|
64
|
+
if (!latestTextElements.length) {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
const fontSizes = latestTextElements.map((textEl) => Math.round(textEl.fontSize * 10) / 10);
|
|
68
|
+
const value = new Set(fontSizes).size === 1 ? fontSizes[0] : "Mixed";
|
|
69
|
+
const editable = fontSizes.length > 0;
|
|
70
|
+
return (_jsx(StatsDragInput, { label: "F", icon: fontSizeIcon, elements: latestTextElements, dragInputCallback: handleFontSizeChange, value: value, editable: editable, scene: scene, property: property, appState: appState }));
|
|
71
|
+
};
|
|
72
|
+
export default MultiFontSize;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { ElementsMap, ExcalidrawElement } from "../../element/types";
|
|
3
|
+
import type Scene from "../../scene/Scene";
|
|
4
|
+
import type { AtomicUnit } from "./utils";
|
|
5
|
+
import type { AppState } from "../../types";
|
|
6
|
+
interface MultiPositionProps {
|
|
7
|
+
property: "x" | "y";
|
|
8
|
+
elements: readonly ExcalidrawElement[];
|
|
9
|
+
elementsMap: ElementsMap;
|
|
10
|
+
atomicUnits: AtomicUnit[];
|
|
11
|
+
scene: Scene;
|
|
12
|
+
appState: AppState;
|
|
13
|
+
}
|
|
14
|
+
declare const MultiPosition: ({ property, elements, elementsMap, atomicUnits, scene, appState, }: MultiPositionProps) => JSX.Element;
|
|
15
|
+
export default MultiPosition;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { rotate } from "../../math";
|
|
3
|
+
import StatsDragInput from "./DragInput";
|
|
4
|
+
import { getAtomicUnits, getStepSizedValue, isPropertyEditable } from "./utils";
|
|
5
|
+
import { getCommonBounds, isTextElement } from "../../element";
|
|
6
|
+
import { useMemo } from "react";
|
|
7
|
+
import { getElementsInAtomicUnit, moveElement } from "./utils";
|
|
8
|
+
const STEP_SIZE = 10;
|
|
9
|
+
const moveElements = (property, changeInTopX, changeInTopY, elements, originalElements, elementsMap, originalElementsMap, scene) => {
|
|
10
|
+
for (let i = 0; i < elements.length; i++) {
|
|
11
|
+
const origElement = originalElements[i];
|
|
12
|
+
const [cx, cy] = [
|
|
13
|
+
origElement.x + origElement.width / 2,
|
|
14
|
+
origElement.y + origElement.height / 2,
|
|
15
|
+
];
|
|
16
|
+
const [topLeftX, topLeftY] = rotate(origElement.x, origElement.y, cx, cy, origElement.angle);
|
|
17
|
+
const newTopLeftX = property === "x" ? Math.round(topLeftX + changeInTopX) : topLeftX;
|
|
18
|
+
const newTopLeftY = property === "y" ? Math.round(topLeftY + changeInTopY) : topLeftY;
|
|
19
|
+
moveElement(newTopLeftX, newTopLeftY, origElement, elementsMap, elements, scene, originalElementsMap, false);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
const moveGroupTo = (nextX, nextY, originalElements, elementsMap, elements, originalElementsMap, scene) => {
|
|
23
|
+
const [x1, y1, ,] = getCommonBounds(originalElements);
|
|
24
|
+
const offsetX = nextX - x1;
|
|
25
|
+
const offsetY = nextY - y1;
|
|
26
|
+
for (let i = 0; i < originalElements.length; i++) {
|
|
27
|
+
const origElement = originalElements[i];
|
|
28
|
+
const latestElement = elementsMap.get(origElement.id);
|
|
29
|
+
if (!latestElement) {
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
// bound texts are moved with their containers
|
|
33
|
+
if (!isTextElement(latestElement) || !latestElement.containerId) {
|
|
34
|
+
const [cx, cy] = [
|
|
35
|
+
latestElement.x + latestElement.width / 2,
|
|
36
|
+
latestElement.y + latestElement.height / 2,
|
|
37
|
+
];
|
|
38
|
+
const [topLeftX, topLeftY] = rotate(latestElement.x, latestElement.y, cx, cy, latestElement.angle);
|
|
39
|
+
moveElement(topLeftX + offsetX, topLeftY + offsetY, origElement, elementsMap, elements, scene, originalElementsMap, false);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
const handlePositionChange = ({ accumulatedChange, originalElements, originalElementsMap, shouldChangeByStepSize, nextValue, property, scene, originalAppState, }) => {
|
|
44
|
+
const elementsMap = scene.getNonDeletedElementsMap();
|
|
45
|
+
const elements = scene.getNonDeletedElements();
|
|
46
|
+
if (nextValue !== undefined) {
|
|
47
|
+
for (const atomicUnit of getAtomicUnits(originalElements, originalAppState)) {
|
|
48
|
+
const elementsInUnit = getElementsInAtomicUnit(atomicUnit, elementsMap, originalElementsMap);
|
|
49
|
+
if (elementsInUnit.length > 1) {
|
|
50
|
+
const [x1, y1, ,] = getCommonBounds(elementsInUnit.map((el) => el.latest));
|
|
51
|
+
const newTopLeftX = property === "x" ? nextValue : x1;
|
|
52
|
+
const newTopLeftY = property === "y" ? nextValue : y1;
|
|
53
|
+
moveGroupTo(newTopLeftX, newTopLeftY, elementsInUnit.map((el) => el.original), elementsMap, elements, originalElementsMap, scene);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
const origElement = elementsInUnit[0]?.original;
|
|
57
|
+
const latestElement = elementsInUnit[0]?.latest;
|
|
58
|
+
if (origElement &&
|
|
59
|
+
latestElement &&
|
|
60
|
+
isPropertyEditable(latestElement, property)) {
|
|
61
|
+
const [cx, cy] = [
|
|
62
|
+
origElement.x + origElement.width / 2,
|
|
63
|
+
origElement.y + origElement.height / 2,
|
|
64
|
+
];
|
|
65
|
+
const [topLeftX, topLeftY] = rotate(origElement.x, origElement.y, cx, cy, origElement.angle);
|
|
66
|
+
const newTopLeftX = property === "x" ? nextValue : topLeftX;
|
|
67
|
+
const newTopLeftY = property === "y" ? nextValue : topLeftY;
|
|
68
|
+
moveElement(newTopLeftX, newTopLeftY, origElement, elementsMap, elements, scene, originalElementsMap, false);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
scene.triggerUpdate();
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const change = shouldChangeByStepSize
|
|
76
|
+
? getStepSizedValue(accumulatedChange, STEP_SIZE)
|
|
77
|
+
: accumulatedChange;
|
|
78
|
+
const changeInTopX = property === "x" ? change : 0;
|
|
79
|
+
const changeInTopY = property === "y" ? change : 0;
|
|
80
|
+
moveElements(property, changeInTopX, changeInTopY, originalElements, originalElements, elementsMap, originalElementsMap, scene);
|
|
81
|
+
scene.triggerUpdate();
|
|
82
|
+
};
|
|
83
|
+
const MultiPosition = ({ property, elements, elementsMap, atomicUnits, scene, appState, }) => {
|
|
84
|
+
const positions = useMemo(() => atomicUnits.map((atomicUnit) => {
|
|
85
|
+
const elementsInUnit = Object.keys(atomicUnit)
|
|
86
|
+
.map((id) => elementsMap.get(id))
|
|
87
|
+
.filter((el) => el !== undefined);
|
|
88
|
+
// we're dealing with a group
|
|
89
|
+
if (elementsInUnit.length > 1) {
|
|
90
|
+
const [x1, y1] = getCommonBounds(elementsInUnit);
|
|
91
|
+
return Math.round((property === "x" ? x1 : y1) * 100) / 100;
|
|
92
|
+
}
|
|
93
|
+
const [el] = elementsInUnit;
|
|
94
|
+
const [cx, cy] = [el.x + el.width / 2, el.y + el.height / 2];
|
|
95
|
+
const [topLeftX, topLeftY] = rotate(el.x, el.y, cx, cy, el.angle);
|
|
96
|
+
return Math.round((property === "x" ? topLeftX : topLeftY) * 100) / 100;
|
|
97
|
+
}), [atomicUnits, elementsMap, property]);
|
|
98
|
+
const value = new Set(positions).size === 1 ? positions[0] : "Mixed";
|
|
99
|
+
return (_jsx(StatsDragInput, { label: property === "x" ? "X" : "Y", elements: elements, dragInputCallback: handlePositionChange, value: value, property: property, scene: scene, appState: appState }));
|
|
100
|
+
};
|
|
101
|
+
export default MultiPosition;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { ElementsMap, ExcalidrawElement } from "../../element/types";
|
|
3
|
+
import type Scene from "../../scene/Scene";
|
|
4
|
+
import type { AppState } from "../../types";
|
|
5
|
+
interface PositionProps {
|
|
6
|
+
property: "x" | "y";
|
|
7
|
+
element: ExcalidrawElement;
|
|
8
|
+
elementsMap: ElementsMap;
|
|
9
|
+
scene: Scene;
|
|
10
|
+
appState: AppState;
|
|
11
|
+
}
|
|
12
|
+
declare const Position: ({ property, element, elementsMap, scene, appState, }: PositionProps) => JSX.Element;
|
|
13
|
+
export default Position;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { rotate } from "../../math";
|
|
3
|
+
import StatsDragInput from "./DragInput";
|
|
4
|
+
import { getStepSizedValue, moveElement } from "./utils";
|
|
5
|
+
const STEP_SIZE = 10;
|
|
6
|
+
const handlePositionChange = ({ accumulatedChange, originalElements, originalElementsMap, shouldChangeByStepSize, nextValue, property, scene, }) => {
|
|
7
|
+
const elementsMap = scene.getNonDeletedElementsMap();
|
|
8
|
+
const elements = scene.getNonDeletedElements();
|
|
9
|
+
const origElement = originalElements[0];
|
|
10
|
+
const [cx, cy] = [
|
|
11
|
+
origElement.x + origElement.width / 2,
|
|
12
|
+
origElement.y + origElement.height / 2,
|
|
13
|
+
];
|
|
14
|
+
const [topLeftX, topLeftY] = rotate(origElement.x, origElement.y, cx, cy, origElement.angle);
|
|
15
|
+
if (nextValue !== undefined) {
|
|
16
|
+
const newTopLeftX = property === "x" ? nextValue : topLeftX;
|
|
17
|
+
const newTopLeftY = property === "y" ? nextValue : topLeftY;
|
|
18
|
+
moveElement(newTopLeftX, newTopLeftY, origElement, elementsMap, elements, scene, originalElementsMap);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const changeInTopX = property === "x" ? accumulatedChange : 0;
|
|
22
|
+
const changeInTopY = property === "y" ? accumulatedChange : 0;
|
|
23
|
+
const newTopLeftX = property === "x"
|
|
24
|
+
? Math.round(shouldChangeByStepSize
|
|
25
|
+
? getStepSizedValue(origElement.x + changeInTopX, STEP_SIZE)
|
|
26
|
+
: topLeftX + changeInTopX)
|
|
27
|
+
: topLeftX;
|
|
28
|
+
const newTopLeftY = property === "y"
|
|
29
|
+
? Math.round(shouldChangeByStepSize
|
|
30
|
+
? getStepSizedValue(origElement.y + changeInTopY, STEP_SIZE)
|
|
31
|
+
: topLeftY + changeInTopY)
|
|
32
|
+
: topLeftY;
|
|
33
|
+
moveElement(newTopLeftX, newTopLeftY, origElement, elementsMap, elements, scene, originalElementsMap);
|
|
34
|
+
};
|
|
35
|
+
const Position = ({ property, element, elementsMap, scene, appState, }) => {
|
|
36
|
+
const [topLeftX, topLeftY] = rotate(element.x, element.y, element.x + element.width / 2, element.y + element.height / 2, element.angle);
|
|
37
|
+
const value = Math.round((property === "x" ? topLeftX : topLeftY) * 100) / 100;
|
|
38
|
+
return (_jsx(StatsDragInput, { label: property === "x" ? "X" : "Y", elements: [element], dragInputCallback: handlePositionChange, scene: scene, value: value, property: property, appState: appState }));
|
|
39
|
+
};
|
|
40
|
+
export default Position;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { NonDeletedExcalidrawElement } from "../../element/types";
|
|
3
|
+
import type { AppState, ExcalidrawProps } from "../../types";
|
|
4
|
+
import type Scene from "../../scene/Scene";
|
|
5
|
+
interface StatsProps {
|
|
6
|
+
scene: Scene;
|
|
7
|
+
onClose: () => void;
|
|
8
|
+
renderCustomStats: ExcalidrawProps["renderCustomStats"];
|
|
9
|
+
}
|
|
10
|
+
export declare const Stats: (props: StatsProps) => JSX.Element;
|
|
11
|
+
export declare const StatsInner: import("react").MemoExoticComponent<({ scene, onClose, renderCustomStats, selectedElements, appState, sceneNonce, }: StatsProps & {
|
|
12
|
+
sceneNonce: number;
|
|
13
|
+
selectedElements: readonly NonDeletedExcalidrawElement[];
|
|
14
|
+
appState: AppState;
|
|
15
|
+
}) => JSX.Element>;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useMemo, useState, memo } from "react";
|
|
3
|
+
import { getCommonBounds } from "../../element/bounds";
|
|
4
|
+
import { t } from "../../i18n";
|
|
5
|
+
import { CloseIcon } from "../icons";
|
|
6
|
+
import { Island } from "../Island";
|
|
7
|
+
import { throttle } from "lodash";
|
|
8
|
+
import Dimension from "./Dimension";
|
|
9
|
+
import Angle from "./Angle";
|
|
10
|
+
import FontSize from "./FontSize";
|
|
11
|
+
import MultiDimension from "./MultiDimension";
|
|
12
|
+
import { elementsAreInSameGroup } from "../../groups";
|
|
13
|
+
import MultiAngle from "./MultiAngle";
|
|
14
|
+
import MultiFontSize from "./MultiFontSize";
|
|
15
|
+
import Position from "./Position";
|
|
16
|
+
import MultiPosition from "./MultiPosition";
|
|
17
|
+
import Collapsible from "./Collapsible";
|
|
18
|
+
import { useExcalidrawAppState, useExcalidrawSetAppState } from "../App";
|
|
19
|
+
import { getAtomicUnits } from "./utils";
|
|
20
|
+
import { STATS_PANELS } from "../../constants";
|
|
21
|
+
import { isElbowArrow } from "../../element/typeChecks";
|
|
22
|
+
const STATS_TIMEOUT = 50;
|
|
23
|
+
export const Stats = (props) => {
|
|
24
|
+
const appState = useExcalidrawAppState();
|
|
25
|
+
const sceneNonce = props.scene.getSceneNonce() || 1;
|
|
26
|
+
const selectedElements = props.scene.getSelectedElements({
|
|
27
|
+
selectedElementIds: appState.selectedElementIds,
|
|
28
|
+
includeBoundTextElement: false,
|
|
29
|
+
});
|
|
30
|
+
return (_jsx(StatsInner, { ...props, appState: appState, sceneNonce: sceneNonce, selectedElements: selectedElements }));
|
|
31
|
+
};
|
|
32
|
+
export const StatsInner = memo(({ scene, onClose, renderCustomStats, selectedElements, appState, sceneNonce, }) => {
|
|
33
|
+
const elements = scene.getNonDeletedElements();
|
|
34
|
+
const elementsMap = scene.getNonDeletedElementsMap();
|
|
35
|
+
const setAppState = useExcalidrawSetAppState();
|
|
36
|
+
const singleElement = selectedElements.length === 1 ? selectedElements[0] : null;
|
|
37
|
+
const multipleElements = selectedElements.length > 1 ? selectedElements : null;
|
|
38
|
+
const [sceneDimension, setSceneDimension] = useState({
|
|
39
|
+
width: 0,
|
|
40
|
+
height: 0,
|
|
41
|
+
});
|
|
42
|
+
const throttledSetSceneDimension = useMemo(() => throttle((elements) => {
|
|
43
|
+
const boundingBox = getCommonBounds(elements);
|
|
44
|
+
setSceneDimension({
|
|
45
|
+
width: Math.round(boundingBox[2]) - Math.round(boundingBox[0]),
|
|
46
|
+
height: Math.round(boundingBox[3]) - Math.round(boundingBox[1]),
|
|
47
|
+
});
|
|
48
|
+
}, STATS_TIMEOUT), []);
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
throttledSetSceneDimension(elements);
|
|
51
|
+
}, [sceneNonce, elements, throttledSetSceneDimension]);
|
|
52
|
+
useEffect(() => () => throttledSetSceneDimension.cancel(), [throttledSetSceneDimension]);
|
|
53
|
+
const atomicUnits = useMemo(() => {
|
|
54
|
+
return getAtomicUnits(selectedElements, appState);
|
|
55
|
+
}, [selectedElements, appState]);
|
|
56
|
+
return (_jsx("div", { className: "Stats", children: _jsxs(Island, { padding: 3, children: [_jsxs("div", { className: "title", children: [_jsx("h2", { children: t("stats.title") }), _jsx("div", { className: "close", onClick: onClose, children: CloseIcon })] }), _jsx(Collapsible, { label: _jsx("h3", { children: t("stats.generalStats") }), open: !!(appState.stats.panels & STATS_PANELS.generalStats), openTrigger: () => setAppState((state) => {
|
|
57
|
+
return {
|
|
58
|
+
...state,
|
|
59
|
+
stats: {
|
|
60
|
+
open: true,
|
|
61
|
+
panels: state.stats.panels ^ STATS_PANELS.generalStats,
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
}), children: _jsx("table", { children: _jsxs("tbody", { children: [_jsx("tr", { children: _jsx("th", { colSpan: 2, children: t("stats.scene") }) }), _jsxs("tr", { children: [_jsx("td", { children: t("stats.elements") }), _jsx("td", { children: elements.length })] }), _jsxs("tr", { children: [_jsx("td", { children: t("stats.width") }), _jsx("td", { children: sceneDimension.width })] }), _jsxs("tr", { children: [_jsx("td", { children: t("stats.height") }), _jsx("td", { children: sceneDimension.height })] }), renderCustomStats?.(elements, appState)] }) }) }), selectedElements.length > 0 && (_jsx("div", { id: "elementStats", style: {
|
|
65
|
+
marginTop: 12,
|
|
66
|
+
}, children: _jsxs(Collapsible, { label: _jsx("h3", { children: t("stats.elementProperties") }), open: !!(appState.stats.panels & STATS_PANELS.elementProperties), openTrigger: () => setAppState((state) => {
|
|
67
|
+
return {
|
|
68
|
+
...state,
|
|
69
|
+
stats: {
|
|
70
|
+
open: true,
|
|
71
|
+
panels: state.stats.panels ^ STATS_PANELS.elementProperties,
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
}), children: [singleElement && (_jsxs("div", { className: "sectionContent", children: [_jsx("div", { className: "elementType", children: t(`element.${singleElement.type}`) }), _jsxs("div", { className: "statsItem", children: [_jsx(Position, { element: singleElement, property: "x", elementsMap: elementsMap, scene: scene, appState: appState }), _jsx(Position, { element: singleElement, property: "y", elementsMap: elementsMap, scene: scene, appState: appState }), _jsx(Dimension, { property: "width", element: singleElement, scene: scene, appState: appState }), _jsx(Dimension, { property: "height", element: singleElement, scene: scene, appState: appState }), !isElbowArrow(singleElement) && (_jsx(Angle, { property: "angle", element: singleElement, scene: scene, appState: appState })), _jsx(FontSize, { property: "fontSize", element: singleElement, scene: scene, appState: appState })] })] })), multipleElements && (_jsxs("div", { className: "sectionContent", children: [elementsAreInSameGroup(multipleElements) && (_jsx("div", { className: "elementType", children: t("element.group") })), _jsxs("div", { className: "elementsCount", children: [_jsx("div", { children: t("stats.elements") }), _jsx("div", { children: selectedElements.length })] }), _jsxs("div", { className: "statsItem", children: [_jsx(MultiPosition, { property: "x", elements: multipleElements, elementsMap: elementsMap, atomicUnits: atomicUnits, scene: scene, appState: appState }), _jsx(MultiPosition, { property: "y", elements: multipleElements, elementsMap: elementsMap, atomicUnits: atomicUnits, scene: scene, appState: appState }), _jsx(MultiDimension, { property: "width", elements: multipleElements, elementsMap: elementsMap, atomicUnits: atomicUnits, scene: scene, appState: appState }), _jsx(MultiDimension, { property: "height", elements: multipleElements, elementsMap: elementsMap, atomicUnits: atomicUnits, scene: scene, appState: appState }), _jsx(MultiAngle, { property: "angle", elements: multipleElements, scene: scene, appState: appState }), _jsx(MultiFontSize, { property: "fontSize", elements: multipleElements, scene: scene, appState: appState, elementsMap: elementsMap })] })] }))] }) }))] }) }));
|
|
75
|
+
}, (prev, next) => {
|
|
76
|
+
return (prev.sceneNonce === next.sceneNonce &&
|
|
77
|
+
prev.selectedElements === next.selectedElements &&
|
|
78
|
+
prev.appState.stats.panels === next.appState.stats.panels);
|
|
79
|
+
});
|