@excalidraw/excalidraw 0.17.1-88812e0 → 0.17.1-96eeec5
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 +2 -0
- package/dist/browser/dev/excalidraw-assets-dev/{chunk-47LVF2XL.js → chunk-DEYXWPUO.js} +4933 -1520
- package/dist/browser/dev/excalidraw-assets-dev/chunk-DEYXWPUO.js.map +7 -0
- package/dist/browser/dev/excalidraw-assets-dev/{chunk-XOM7LNOU.js → chunk-EM6LVGFW.js} +27 -4
- package/dist/browser/dev/excalidraw-assets-dev/chunk-EM6LVGFW.js.map +7 -0
- package/dist/browser/dev/excalidraw-assets-dev/{dist-ITJNUBZF.js → dist-6QVAH5JA.js} +36 -14
- package/dist/browser/dev/excalidraw-assets-dev/dist-6QVAH5JA.js.map +7 -0
- package/dist/browser/dev/excalidraw-assets-dev/{en-TR4QLF5E.js → en-AZFA5HJJ.js} +4 -2
- package/dist/browser/dev/excalidraw-assets-dev/{image-LHMGJWTI.js → image-5XCR4WHS.js} +2 -2
- package/dist/browser/dev/index.css +157 -62
- package/dist/browser/dev/index.css.map +3 -3
- package/dist/browser/dev/index.js +12016 -7663
- package/dist/browser/dev/index.js.map +4 -4
- package/dist/browser/prod/excalidraw-assets/{chunk-5SYIAZGL.js → chunk-7DXALCB2.js} +5 -5
- package/dist/browser/prod/excalidraw-assets/chunk-ODWTVSS7.js +68 -0
- package/dist/browser/prod/excalidraw-assets/dist-567JAXHK.js +7 -0
- package/dist/browser/prod/excalidraw-assets/en-6E7MYLWO.js +1 -0
- package/dist/browser/prod/excalidraw-assets/image-LQAMCFQI.js +1 -0
- package/dist/browser/prod/index.css +1 -1
- package/dist/browser/prod/index.js +69 -51
- package/dist/dev/{en-XW4JO6VX.json → en-EB2MBPAV.json} +24 -3
- package/dist/dev/index.css +157 -62
- package/dist/dev/index.css.map +3 -3
- package/dist/dev/index.js +18250 -16114
- package/dist/dev/index.js.map +4 -4
- package/dist/excalidraw/actions/actionAddToLibrary.d.ts +15 -6
- package/dist/excalidraw/actions/actionAlign.d.ts +8 -8
- package/dist/excalidraw/actions/actionBoundText.d.ts +14 -8
- package/dist/excalidraw/actions/actionBoundText.js +3 -1
- package/dist/excalidraw/actions/actionCanvas.d.ts +64 -28
- package/dist/excalidraw/actions/actionCanvas.js +1 -1
- package/dist/excalidraw/actions/actionClipboard.d.ts +40 -19
- package/dist/excalidraw/actions/actionDeleteSelected.d.ts +17 -8
- package/dist/excalidraw/actions/actionDistribute.d.ts +4 -4
- package/dist/excalidraw/actions/actionDuplicateSelection.d.ts +3 -3
- package/dist/excalidraw/actions/actionElementLock.d.ts +11 -5
- package/dist/excalidraw/actions/actionExport.d.ts +48 -21
- package/dist/excalidraw/actions/actionFinalize.d.ts +11 -5
- package/dist/excalidraw/actions/actionFinalize.js +1 -1
- package/dist/excalidraw/actions/actionFlip.d.ts +4 -4
- package/dist/excalidraw/actions/actionFlip.js +5 -6
- package/dist/excalidraw/actions/actionFrame.d.ts +328 -8
- package/dist/excalidraw/actions/actionGroup.d.ts +320 -4
- package/dist/excalidraw/actions/actionHistory.d.ts +3 -3
- package/dist/excalidraw/actions/actionHistory.js +4 -4
- package/dist/excalidraw/actions/actionLinearEditor.d.ts +9 -4
- package/dist/excalidraw/actions/actionLinearEditor.js +19 -4
- package/dist/excalidraw/actions/actionLink.d.ts +5 -2
- package/dist/excalidraw/actions/actionMenu.d.ts +15 -6
- package/dist/excalidraw/actions/actionNavigate.d.ts +11 -5
- package/dist/excalidraw/actions/actionProperties.d.ts +67 -28
- package/dist/excalidraw/actions/actionProperties.js +1 -1
- package/dist/excalidraw/actions/actionSelectAll.d.ts +6 -3
- package/dist/excalidraw/actions/actionStyles.d.ts +9 -3
- package/dist/excalidraw/actions/actionTextAutoResize.d.ts +17 -0
- package/dist/excalidraw/actions/actionTextAutoResize.js +38 -0
- package/dist/excalidraw/actions/actionToggleGridMode.d.ts +6 -3
- package/dist/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +5 -2
- package/dist/excalidraw/actions/actionToggleStats.d.ts +6 -2
- package/dist/excalidraw/actions/actionToggleStats.js +4 -3
- package/dist/excalidraw/actions/actionToggleViewMode.d.ts +5 -2
- package/dist/excalidraw/actions/actionToggleZenMode.d.ts +5 -2
- 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/animated-trail.d.ts +2 -2
- package/dist/excalidraw/appState.d.ts +5 -2
- package/dist/excalidraw/appState.js +6 -3
- package/dist/excalidraw/change.d.ts +4 -4
- package/dist/excalidraw/change.js +14 -7
- package/dist/excalidraw/charts.d.ts +1 -1
- 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 +9 -6
- package/dist/excalidraw/components/App.d.ts +10 -16
- package/dist/excalidraw/components/App.js +190 -142
- package/dist/excalidraw/components/ButtonIconSelect.js +1 -1
- 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 +1 -1
- package/dist/excalidraw/components/ColorPicker/Picker.d.ts +3 -3
- 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/HelpDialog.js +1 -1
- package/dist/excalidraw/components/HintViewer.d.ts +1 -1
- 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/PublishLibrary.d.ts +1 -1
- package/dist/excalidraw/components/SVGLayer.d.ts +1 -1
- 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 +52 -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 +67 -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 +197 -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 +100 -0
- package/dist/excalidraw/components/Stats/Position.d.ts +13 -0
- package/dist/excalidraw/components/Stats/Position.js +39 -0
- package/dist/excalidraw/components/Stats/index.d.ts +16 -0
- package/dist/excalidraw/components/Stats/index.js +78 -0
- package/dist/excalidraw/components/Stats/utils.d.ts +25 -0
- package/dist/excalidraw/components/Stats/utils.js +158 -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 +4 -4
- 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/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 +2 -2
- package/dist/excalidraw/components/dropdownMenu/DropdownMenuItem.js +2 -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 +6 -2
- package/dist/excalidraw/components/icons.js +22 -6
- package/dist/excalidraw/constants.d.ts +8 -2
- package/dist/excalidraw/constants.js +8 -1
- 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/resave.d.ts +2 -2
- package/dist/excalidraw/data/restore.d.ts +3 -3
- package/dist/excalidraw/data/restore.js +16 -1
- package/dist/excalidraw/data/transform.d.ts +3 -3
- 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 +7 -21
- package/dist/excalidraw/element/binding.js +127 -102
- package/dist/excalidraw/element/bounds.d.ts +3 -3
- package/dist/excalidraw/element/collision.d.ts +3 -3
- package/dist/excalidraw/element/collision.js +1 -1
- package/dist/excalidraw/element/containerCache.d.ts +1 -1
- package/dist/excalidraw/element/dragElements.d.ts +4 -4
- package/dist/excalidraw/element/dragElements.js +27 -3
- package/dist/excalidraw/element/embeddable.d.ts +8 -5
- 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 +8 -5
- package/dist/excalidraw/element/linearElementEditor.js +7 -4
- package/dist/excalidraw/element/mutateElement.d.ts +2 -2
- package/dist/excalidraw/element/mutateElement.js +1 -1
- package/dist/excalidraw/element/newElement.d.ts +5 -8
- package/dist/excalidraw/element/newElement.js +16 -14
- package/dist/excalidraw/element/resizeElements.d.ts +11 -3
- package/dist/excalidraw/element/resizeElements.js +75 -23
- package/dist/excalidraw/element/resizeTest.d.ts +4 -4
- package/dist/excalidraw/element/resizeTest.js +2 -4
- 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 +5 -4
- package/dist/excalidraw/element/textElement.js +11 -3
- package/dist/excalidraw/element/textWysiwyg.d.ts +12 -6
- package/dist/excalidraw/element/textWysiwyg.js +38 -17
- package/dist/excalidraw/element/transformHandles.d.ts +3 -3
- package/dist/excalidraw/element/transformHandles.js +0 -10
- package/dist/excalidraw/element/typeChecks.d.ts +4 -4
- package/dist/excalidraw/element/types.d.ts +11 -4
- package/dist/excalidraw/emitter.d.ts +1 -1
- package/dist/excalidraw/fractionalIndex.d.ts +1 -1
- package/dist/excalidraw/fractionalIndex.js +2 -4
- package/dist/excalidraw/frame.d.ts +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 +4 -4
- 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 +1 -1
- package/dist/excalidraw/jotai.d.ts +1 -1
- package/dist/excalidraw/laser-trails.d.ts +3 -2
- package/dist/excalidraw/locales/en.json +24 -3
- package/dist/excalidraw/math.d.ts +4 -2
- package/dist/excalidraw/math.js +6 -0
- package/dist/excalidraw/mermaid.d.ts +2 -0
- package/dist/excalidraw/mermaid.js +28 -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 +32 -6
- package/dist/excalidraw/renderer/renderElement.d.ts +4 -4
- package/dist/excalidraw/renderer/renderElement.js +5 -5
- 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/scene/Fonts.d.ts +2 -4
- package/dist/excalidraw/scene/Fonts.js +12 -15
- 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 +17 -8
- package/dist/excalidraw/scene/Shape.d.ts +1 -1
- package/dist/excalidraw/scene/ShapeCache.d.ts +4 -4
- package/dist/excalidraw/scene/comparisons.d.ts +2 -2
- package/dist/excalidraw/scene/export.d.ts +2 -2
- package/dist/excalidraw/scene/export.js +2 -2
- 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 +7 -0
- package/dist/excalidraw/shapes.js +40 -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 +25 -20
- package/dist/excalidraw/utils.d.ts +4 -4
- package/dist/excalidraw/zindex.d.ts +2 -2
- package/dist/prod/{en-XW4JO6VX.json → en-EB2MBPAV.json} +24 -3
- package/dist/prod/index.css +1 -1
- package/dist/prod/index.js +39 -39
- package/dist/utils/bbox.d.ts +2 -2
- package/dist/utils/collision.d.ts +1 -1
- package/dist/utils/export.d.ts +2 -2
- package/dist/utils/geometry/geometry.d.ts +1 -1
- package/dist/utils/geometry/shape.d.ts +1 -1
- package/dist/utils/withinBounds.d.ts +1 -1
- package/history.ts +4 -4
- package/package.json +2 -2
- package/dist/browser/dev/excalidraw-assets-dev/chunk-47LVF2XL.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/excalidraw-assets/chunk-4SNEEDZH.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-ISQJGWLB.js +0 -1
- package/dist/excalidraw/components/Stats.d.ts +0 -11
- package/dist/excalidraw/components/Stats.js +0 -13
- /package/dist/browser/dev/excalidraw-assets-dev/{en-TR4QLF5E.js.map → en-AZFA5HJJ.js.map} +0 -0
- /package/dist/browser/dev/excalidraw-assets-dev/{image-LHMGJWTI.js.map → image-5XCR4WHS.js.map} +0 -0
|
@@ -11,8 +11,6 @@ import { Section } from "./Section";
|
|
|
11
11
|
import { SCROLLBAR_WIDTH, SCROLLBAR_MARGIN } from "../scene/scrollbars";
|
|
12
12
|
import { LockButton } from "./LockButton";
|
|
13
13
|
import { PenModeButton } from "./PenModeButton";
|
|
14
|
-
import { Stats } from "./Stats";
|
|
15
|
-
import { actionToggleStats } from "../actions";
|
|
16
14
|
import { HandButton } from "./HandButton";
|
|
17
15
|
import { isHandToolActive } from "../appState";
|
|
18
16
|
import { useTunnels } from "../context/tunnels";
|
|
@@ -27,9 +25,7 @@ export const MobileMenu = ({ appState, elements, actionManager, setAppState, onL
|
|
|
27
25
|
}
|
|
28
26
|
return (_jsxs("div", { className: "App-toolbar-content", children: [_jsx(MainMenuTunnel.Out, {}), actionManager.renderAction("toggleEditMenu"), actionManager.renderAction("undo"), actionManager.renderAction("redo"), actionManager.renderAction(appState.multiElement ? "finalize" : "duplicateSelection"), actionManager.renderAction("deleteSelectedElements")] }));
|
|
29
27
|
};
|
|
30
|
-
return (_jsxs(_Fragment, { children: [renderSidebars(), !appState.viewModeEnabled && renderToolbar(),
|
|
31
|
-
actionManager.executeAction(actionToggleStats);
|
|
32
|
-
}, renderCustomStats: renderCustomStats })), _jsx("div", { className: "App-bottom-bar", style: {
|
|
28
|
+
return (_jsxs(_Fragment, { children: [renderSidebars(), !appState.viewModeEnabled && renderToolbar(), _jsx("div", { className: "App-bottom-bar", style: {
|
|
33
29
|
marginBottom: SCROLLBAR_WIDTH + SCROLLBAR_MARGIN * 2,
|
|
34
30
|
marginLeft: SCROLLBAR_WIDTH + SCROLLBAR_MARGIN * 2,
|
|
35
31
|
marginRight: SCROLLBAR_WIDTH + SCROLLBAR_MARGIN * 2,
|
|
@@ -37,7 +33,7 @@ export const MobileMenu = ({ appState, elements, actionManager, setAppState, onL
|
|
|
37
33
|
!appState.viewModeEnabled &&
|
|
38
34
|
showSelectedShapeActions(appState, elements) ? (_jsx(Section, { className: "App-mobile-menu", heading: "selectedShapeActions", children: _jsx(SelectedShapeActions, { appState: appState, elementsMap: app.scene.getNonDeletedElementsMap(), renderAction: actionManager.renderAction }) })) : null, _jsxs("footer", { className: "App-toolbar", children: [renderAppToolbar(), appState.scrolledOutside &&
|
|
39
35
|
!appState.openMenu &&
|
|
40
|
-
!appState.openSidebar && (_jsx("button", { className: "scroll-back-to-content", onClick: () => {
|
|
36
|
+
!appState.openSidebar && (_jsx("button", { type: "button", className: "scroll-back-to-content", onClick: () => {
|
|
41
37
|
setAppState((appState) => ({
|
|
42
38
|
...calculateScrollCenter(elements, appState),
|
|
43
39
|
}));
|
|
@@ -35,7 +35,7 @@ const ChartPreviewBtn = (props) => {
|
|
|
35
35
|
previewNode.replaceChildren();
|
|
36
36
|
};
|
|
37
37
|
}, [props.spreadsheet, props.chartType, props.selected]);
|
|
38
|
-
return (_jsx("button", { className: "ChartPreview", onClick: () => {
|
|
38
|
+
return (_jsx("button", { type: "button", className: "ChartPreview", onClick: () => {
|
|
39
39
|
if (chartElements) {
|
|
40
40
|
props.onClick(props.chartType, chartElements);
|
|
41
41
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { LibraryItems, UIAppState } from "../types";
|
|
2
|
+
import type { LibraryItems, UIAppState } from "../types";
|
|
3
3
|
import "./PublishLibrary.scss";
|
|
4
4
|
declare const PublishLibrary: ({ onClose, libraryItems, appState, onSuccess, onError, updateItemsInStorage, onRemove, }: {
|
|
5
5
|
onClose: () => void;
|
|
@@ -4,7 +4,7 @@ import { useEffect, useLayoutEffect, useRef, useState, forwardRef, useImperative
|
|
|
4
4
|
import { Island } from "../Island";
|
|
5
5
|
import { atom, useSetAtom } from "jotai";
|
|
6
6
|
import { jotaiScope } from "../../jotai";
|
|
7
|
-
import { SidebarPropsContext
|
|
7
|
+
import { SidebarPropsContext } from "./common";
|
|
8
8
|
import { SidebarHeader } from "./SidebarHeader";
|
|
9
9
|
import clsx from "clsx";
|
|
10
10
|
import { useDevice, useExcalidrawSetAppState } from "../App";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { SidebarTriggerProps } from "./common";
|
|
2
|
+
import type { SidebarTriggerProps } from "./common";
|
|
3
3
|
import "./SidebarTrigger.scss";
|
|
4
4
|
export declare const SidebarTrigger: {
|
|
5
5
|
({ name, tab, icon, title, children, onToggle, className, style, }: SidebarTriggerProps): JSX.Element;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { ExcalidrawElement } from "../../element/types";
|
|
3
|
+
import type Scene from "../../scene/Scene";
|
|
4
|
+
import type { AppState } from "../../types";
|
|
5
|
+
interface AngleProps {
|
|
6
|
+
element: ExcalidrawElement;
|
|
7
|
+
scene: Scene;
|
|
8
|
+
appState: AppState;
|
|
9
|
+
property: "angle";
|
|
10
|
+
}
|
|
11
|
+
declare const Angle: ({ element, scene, appState, property }: AngleProps) => JSX.Element;
|
|
12
|
+
export default Angle;
|
|
@@ -0,0 +1,52 @@
|
|
|
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 { degreeToRadian, radianToDegree } from "../../math";
|
|
6
|
+
import { angleIcon } from "../icons";
|
|
7
|
+
import DragInput from "./DragInput";
|
|
8
|
+
import { getStepSizedValue, isPropertyEditable, updateBindings } from "./utils";
|
|
9
|
+
const STEP_SIZE = 15;
|
|
10
|
+
const handleDegreeChange = ({ accumulatedChange, originalElements, shouldChangeByStepSize, nextValue, scene, }) => {
|
|
11
|
+
const elementsMap = scene.getNonDeletedElementsMap();
|
|
12
|
+
const origElement = originalElements[0];
|
|
13
|
+
if (origElement) {
|
|
14
|
+
const latestElement = elementsMap.get(origElement.id);
|
|
15
|
+
if (!latestElement) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (nextValue !== undefined) {
|
|
19
|
+
const nextAngle = degreeToRadian(nextValue);
|
|
20
|
+
mutateElement(latestElement, {
|
|
21
|
+
angle: nextAngle,
|
|
22
|
+
});
|
|
23
|
+
updateBindings(latestElement, elementsMap);
|
|
24
|
+
const boundTextElement = getBoundTextElement(latestElement, elementsMap);
|
|
25
|
+
if (boundTextElement && !isArrowElement(latestElement)) {
|
|
26
|
+
mutateElement(boundTextElement, { angle: nextAngle });
|
|
27
|
+
}
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const originalAngleInDegrees = Math.round(radianToDegree(origElement.angle) * 100) / 100;
|
|
31
|
+
const changeInDegrees = Math.round(accumulatedChange);
|
|
32
|
+
let nextAngleInDegrees = (originalAngleInDegrees + changeInDegrees) % 360;
|
|
33
|
+
if (shouldChangeByStepSize) {
|
|
34
|
+
nextAngleInDegrees = getStepSizedValue(nextAngleInDegrees, STEP_SIZE);
|
|
35
|
+
}
|
|
36
|
+
nextAngleInDegrees =
|
|
37
|
+
nextAngleInDegrees < 0 ? nextAngleInDegrees + 360 : nextAngleInDegrees;
|
|
38
|
+
const nextAngle = degreeToRadian(nextAngleInDegrees);
|
|
39
|
+
mutateElement(latestElement, {
|
|
40
|
+
angle: nextAngle,
|
|
41
|
+
});
|
|
42
|
+
updateBindings(latestElement, elementsMap);
|
|
43
|
+
const boundTextElement = getBoundTextElement(latestElement, elementsMap);
|
|
44
|
+
if (boundTextElement && !isArrowElement(latestElement)) {
|
|
45
|
+
mutateElement(boundTextElement, { angle: nextAngle });
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
const Angle = ({ element, scene, appState, property }) => {
|
|
50
|
+
return (_jsx(DragInput, { label: "A", icon: angleIcon, value: Math.round((radianToDegree(element.angle) % 360) * 100) / 100, elements: [element], dragInputCallback: handleDegreeChange, editable: isPropertyEditable(element, "angle"), scene: scene, appState: appState, property: property }));
|
|
51
|
+
};
|
|
52
|
+
export default Angle;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
interface CollapsibleProps {
|
|
3
|
+
label: React.ReactNode;
|
|
4
|
+
open: boolean;
|
|
5
|
+
openTrigger: () => void;
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
}
|
|
8
|
+
declare const Collapsible: ({ label, open, openTrigger, children, }: CollapsibleProps) => JSX.Element;
|
|
9
|
+
export default Collapsible;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { InlineIcon } from "../InlineIcon";
|
|
3
|
+
import { collapseDownIcon, collapseUpIcon } from "../icons";
|
|
4
|
+
const Collapsible = ({ label, open, openTrigger, children, }) => {
|
|
5
|
+
return (_jsxs(_Fragment, { children: [_jsxs("div", { style: {
|
|
6
|
+
cursor: "pointer",
|
|
7
|
+
display: "flex",
|
|
8
|
+
justifyContent: "space-between",
|
|
9
|
+
alignItems: "center",
|
|
10
|
+
}, onClick: openTrigger, children: [label, _jsx(InlineIcon, { icon: open ? collapseUpIcon : collapseDownIcon })] }), open && _jsx(_Fragment, { children: children })] }));
|
|
11
|
+
};
|
|
12
|
+
export default Collapsible;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { ExcalidrawElement } from "../../element/types";
|
|
3
|
+
import type Scene from "../../scene/Scene";
|
|
4
|
+
import type { AppState } from "../../types";
|
|
5
|
+
interface DimensionDragInputProps {
|
|
6
|
+
property: "width" | "height";
|
|
7
|
+
element: ExcalidrawElement;
|
|
8
|
+
scene: Scene;
|
|
9
|
+
appState: AppState;
|
|
10
|
+
}
|
|
11
|
+
declare const DimensionDragInput: ({ property, element, scene, appState, }: DimensionDragInputProps) => JSX.Element;
|
|
12
|
+
export default DimensionDragInput;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import DragInput from "./DragInput";
|
|
3
|
+
import { getStepSizedValue, isPropertyEditable, resizeElement } from "./utils";
|
|
4
|
+
import { MIN_WIDTH_OR_HEIGHT } from "../../constants";
|
|
5
|
+
const STEP_SIZE = 10;
|
|
6
|
+
const _shouldKeepAspectRatio = (element) => {
|
|
7
|
+
return element.type === "image";
|
|
8
|
+
};
|
|
9
|
+
const handleDimensionChange = ({ accumulatedChange, originalElements, originalElementsMap, shouldKeepAspectRatio, shouldChangeByStepSize, nextValue, property, scene, }) => {
|
|
10
|
+
const elementsMap = scene.getNonDeletedElementsMap();
|
|
11
|
+
const origElement = originalElements[0];
|
|
12
|
+
if (origElement) {
|
|
13
|
+
const keepAspectRatio = shouldKeepAspectRatio || _shouldKeepAspectRatio(origElement);
|
|
14
|
+
const aspectRatio = origElement.width / origElement.height;
|
|
15
|
+
if (nextValue !== undefined) {
|
|
16
|
+
const nextWidth = Math.max(property === "width"
|
|
17
|
+
? nextValue
|
|
18
|
+
: keepAspectRatio
|
|
19
|
+
? nextValue * aspectRatio
|
|
20
|
+
: origElement.width, MIN_WIDTH_OR_HEIGHT);
|
|
21
|
+
const nextHeight = Math.max(property === "height"
|
|
22
|
+
? nextValue
|
|
23
|
+
: keepAspectRatio
|
|
24
|
+
? nextValue / aspectRatio
|
|
25
|
+
: origElement.height, MIN_WIDTH_OR_HEIGHT);
|
|
26
|
+
resizeElement(nextWidth, nextHeight, keepAspectRatio, origElement, elementsMap);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const changeInWidth = property === "width" ? accumulatedChange : 0;
|
|
30
|
+
const changeInHeight = property === "height" ? accumulatedChange : 0;
|
|
31
|
+
let nextWidth = Math.max(0, origElement.width + changeInWidth);
|
|
32
|
+
if (property === "width") {
|
|
33
|
+
if (shouldChangeByStepSize) {
|
|
34
|
+
nextWidth = getStepSizedValue(nextWidth, STEP_SIZE);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
nextWidth = Math.round(nextWidth);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
let nextHeight = Math.max(0, origElement.height + changeInHeight);
|
|
41
|
+
if (property === "height") {
|
|
42
|
+
if (shouldChangeByStepSize) {
|
|
43
|
+
nextHeight = getStepSizedValue(nextHeight, STEP_SIZE);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
nextHeight = Math.round(nextHeight);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (keepAspectRatio) {
|
|
50
|
+
if (property === "width") {
|
|
51
|
+
nextHeight = Math.round((nextWidth / aspectRatio) * 100) / 100;
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
nextWidth = Math.round(nextHeight * aspectRatio * 100) / 100;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
nextHeight = Math.max(MIN_WIDTH_OR_HEIGHT, nextHeight);
|
|
58
|
+
nextWidth = Math.max(MIN_WIDTH_OR_HEIGHT, nextWidth);
|
|
59
|
+
resizeElement(nextWidth, nextHeight, keepAspectRatio, origElement, elementsMap);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
const DimensionDragInput = ({ property, element, scene, appState, }) => {
|
|
63
|
+
const value = Math.round((property === "width" ? element.width : element.height) * 100) /
|
|
64
|
+
100;
|
|
65
|
+
return (_jsx(DragInput, { label: property === "width" ? "W" : "H", elements: [element], dragInputCallback: handleDimensionChange, value: value, editable: isPropertyEditable(element, property), scene: scene, appState: appState, property: property }));
|
|
66
|
+
};
|
|
67
|
+
export default DimensionDragInput;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { ElementsMap, ExcalidrawElement } from "../../element/types";
|
|
3
|
+
import type { StatsInputProperty } from "./utils";
|
|
4
|
+
import type Scene from "../../scene/Scene";
|
|
5
|
+
import "./DragInput.scss";
|
|
6
|
+
import type { AppState } from "../../types";
|
|
7
|
+
export type DragInputCallbackType<P extends StatsInputProperty, E = ExcalidrawElement> = (props: {
|
|
8
|
+
accumulatedChange: number;
|
|
9
|
+
instantChange: number;
|
|
10
|
+
originalElements: readonly E[];
|
|
11
|
+
originalElementsMap: ElementsMap;
|
|
12
|
+
shouldKeepAspectRatio: boolean;
|
|
13
|
+
shouldChangeByStepSize: boolean;
|
|
14
|
+
nextValue?: number;
|
|
15
|
+
property: P;
|
|
16
|
+
scene: Scene;
|
|
17
|
+
originalAppState: AppState;
|
|
18
|
+
}) => void;
|
|
19
|
+
interface StatsDragInputProps<T extends StatsInputProperty, E = ExcalidrawElement> {
|
|
20
|
+
label: string | React.ReactNode;
|
|
21
|
+
icon?: React.ReactNode;
|
|
22
|
+
value: number | "Mixed";
|
|
23
|
+
elements: readonly E[];
|
|
24
|
+
editable?: boolean;
|
|
25
|
+
shouldKeepAspectRatio?: boolean;
|
|
26
|
+
dragInputCallback: DragInputCallbackType<T, E>;
|
|
27
|
+
property: T;
|
|
28
|
+
scene: Scene;
|
|
29
|
+
appState: AppState;
|
|
30
|
+
}
|
|
31
|
+
declare const StatsDragInput: <T extends StatsInputProperty, E extends ExcalidrawElement = ExcalidrawElement>({ label, icon, dragInputCallback, value, elements, editable, shouldKeepAspectRatio, property, scene, appState, }: StatsDragInputProps<T, E>) => JSX.Element | null;
|
|
32
|
+
export default StatsDragInput;
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef, useState } from "react";
|
|
3
|
+
import { EVENT } from "../../constants";
|
|
4
|
+
import { KEYS } from "../../keys";
|
|
5
|
+
import { deepCopyElement } from "../../element/newElement";
|
|
6
|
+
import clsx from "clsx";
|
|
7
|
+
import { useApp } from "../App";
|
|
8
|
+
import { InlineIcon } from "../InlineIcon";
|
|
9
|
+
import { SMALLEST_DELTA } from "./utils";
|
|
10
|
+
import { StoreAction } from "../../store";
|
|
11
|
+
import "./DragInput.scss";
|
|
12
|
+
import { cloneJSON } from "../../utils";
|
|
13
|
+
const StatsDragInput = ({ label, icon, dragInputCallback, value, elements, editable = true, shouldKeepAspectRatio, property, scene, appState, }) => {
|
|
14
|
+
const app = useApp();
|
|
15
|
+
const inputRef = useRef(null);
|
|
16
|
+
const labelRef = useRef(null);
|
|
17
|
+
const [inputValue, setInputValue] = useState(value.toString());
|
|
18
|
+
const stateRef = useRef(null);
|
|
19
|
+
if (!stateRef.current) {
|
|
20
|
+
stateRef.current = {
|
|
21
|
+
originalAppState: cloneJSON(appState),
|
|
22
|
+
originalElements: elements,
|
|
23
|
+
lastUpdatedValue: inputValue,
|
|
24
|
+
updatePending: false,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
const inputValue = value.toString();
|
|
29
|
+
setInputValue(inputValue);
|
|
30
|
+
stateRef.current.lastUpdatedValue = inputValue;
|
|
31
|
+
}, [value]);
|
|
32
|
+
const handleInputValue = (updatedValue, elements, appState) => {
|
|
33
|
+
if (!stateRef.current.updatePending) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
stateRef.current.updatePending = false;
|
|
37
|
+
const parsed = Number(updatedValue);
|
|
38
|
+
if (isNaN(parsed)) {
|
|
39
|
+
setInputValue(value.toString());
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const rounded = Number(parsed.toFixed(2));
|
|
43
|
+
const original = Number(value);
|
|
44
|
+
// only update when
|
|
45
|
+
// 1. original was "Mixed" and we have a new value
|
|
46
|
+
// 2. original was not "Mixed" and the difference between a new value and previous value is greater
|
|
47
|
+
// than the smallest delta allowed, which is 0.01
|
|
48
|
+
// reason: idempotent to avoid unnecessary
|
|
49
|
+
if (isNaN(original) || Math.abs(rounded - original) >= SMALLEST_DELTA) {
|
|
50
|
+
stateRef.current.lastUpdatedValue = updatedValue;
|
|
51
|
+
dragInputCallback({
|
|
52
|
+
accumulatedChange: 0,
|
|
53
|
+
instantChange: 0,
|
|
54
|
+
originalElements: elements,
|
|
55
|
+
originalElementsMap: app.scene.getNonDeletedElementsMap(),
|
|
56
|
+
shouldKeepAspectRatio: shouldKeepAspectRatio,
|
|
57
|
+
shouldChangeByStepSize: false,
|
|
58
|
+
nextValue: rounded,
|
|
59
|
+
property,
|
|
60
|
+
scene,
|
|
61
|
+
originalAppState: appState,
|
|
62
|
+
});
|
|
63
|
+
app.syncActionResult({ storeAction: StoreAction.CAPTURE });
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
const handleInputValueRef = useRef(handleInputValue);
|
|
67
|
+
handleInputValueRef.current = handleInputValue;
|
|
68
|
+
// make sure that clicking on canvas (which umounts the component)
|
|
69
|
+
// updates current input value (blur isn't triggered)
|
|
70
|
+
useEffect(() => {
|
|
71
|
+
const input = inputRef.current;
|
|
72
|
+
return () => {
|
|
73
|
+
const nextValue = input?.value;
|
|
74
|
+
if (nextValue) {
|
|
75
|
+
handleInputValueRef.current(nextValue, stateRef.current.originalElements, stateRef.current.originalAppState);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
}, [
|
|
79
|
+
// we need to track change of `editable` state as mount/unmount
|
|
80
|
+
// because react doesn't trigger `blur` when a an input is blurred due
|
|
81
|
+
// to being disabled (https://github.com/facebook/react/issues/9142).
|
|
82
|
+
// As such, if we keep rendering disabled inputs, then change in selection
|
|
83
|
+
// to an element that has a given property as non-editable would not trigger
|
|
84
|
+
// blur/unmount and wouldn't update the value.
|
|
85
|
+
editable,
|
|
86
|
+
]);
|
|
87
|
+
if (!editable) {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
return (_jsxs("div", { className: clsx("drag-input-container", !editable && "disabled"), "data-testid": label, children: [_jsx("div", { className: "drag-input-label", ref: labelRef, onPointerDown: (event) => {
|
|
91
|
+
if (inputRef.current && editable) {
|
|
92
|
+
let startValue = Number(inputRef.current.value);
|
|
93
|
+
if (isNaN(startValue)) {
|
|
94
|
+
startValue = 0;
|
|
95
|
+
}
|
|
96
|
+
let lastPointer = null;
|
|
97
|
+
let originalElementsMap = app.scene
|
|
98
|
+
.getNonDeletedElements()
|
|
99
|
+
.reduce((acc, element) => {
|
|
100
|
+
acc.set(element.id, deepCopyElement(element));
|
|
101
|
+
return acc;
|
|
102
|
+
}, new Map());
|
|
103
|
+
let originalElements = elements.map((element) => originalElementsMap.get(element.id));
|
|
104
|
+
const originalAppState = cloneJSON(appState);
|
|
105
|
+
let accumulatedChange = null;
|
|
106
|
+
document.body.classList.add("excalidraw-cursor-resize");
|
|
107
|
+
const onPointerMove = (event) => {
|
|
108
|
+
if (!accumulatedChange) {
|
|
109
|
+
accumulatedChange = 0;
|
|
110
|
+
}
|
|
111
|
+
if (lastPointer &&
|
|
112
|
+
originalElementsMap !== null &&
|
|
113
|
+
originalElements !== null &&
|
|
114
|
+
accumulatedChange !== null) {
|
|
115
|
+
const instantChange = event.clientX - lastPointer.x;
|
|
116
|
+
accumulatedChange += instantChange;
|
|
117
|
+
dragInputCallback({
|
|
118
|
+
accumulatedChange,
|
|
119
|
+
instantChange,
|
|
120
|
+
originalElements,
|
|
121
|
+
originalElementsMap,
|
|
122
|
+
shouldKeepAspectRatio: shouldKeepAspectRatio,
|
|
123
|
+
shouldChangeByStepSize: event.shiftKey,
|
|
124
|
+
property,
|
|
125
|
+
scene,
|
|
126
|
+
originalAppState,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
lastPointer = {
|
|
130
|
+
x: event.clientX,
|
|
131
|
+
y: event.clientY,
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
window.addEventListener(EVENT.POINTER_MOVE, onPointerMove, false);
|
|
135
|
+
window.addEventListener(EVENT.POINTER_UP, () => {
|
|
136
|
+
window.removeEventListener(EVENT.POINTER_MOVE, onPointerMove, false);
|
|
137
|
+
app.syncActionResult({ storeAction: StoreAction.CAPTURE });
|
|
138
|
+
lastPointer = null;
|
|
139
|
+
accumulatedChange = null;
|
|
140
|
+
originalElements = null;
|
|
141
|
+
originalElementsMap = null;
|
|
142
|
+
document.body.classList.remove("excalidraw-cursor-resize");
|
|
143
|
+
}, false);
|
|
144
|
+
}
|
|
145
|
+
}, onPointerEnter: () => {
|
|
146
|
+
if (labelRef.current) {
|
|
147
|
+
labelRef.current.style.cursor = "ew-resize";
|
|
148
|
+
}
|
|
149
|
+
}, children: icon ? _jsx(InlineIcon, { icon: icon }) : label }), _jsx("input", { className: "drag-input", autoComplete: "off", spellCheck: "false", onKeyDown: (event) => {
|
|
150
|
+
if (editable) {
|
|
151
|
+
const eventTarget = event.target;
|
|
152
|
+
if (eventTarget instanceof HTMLInputElement &&
|
|
153
|
+
event.key === KEYS.ENTER) {
|
|
154
|
+
handleInputValue(eventTarget.value, elements, appState);
|
|
155
|
+
app.focusContainer();
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}, ref: inputRef, value: inputValue, onChange: (event) => {
|
|
159
|
+
stateRef.current.updatePending = true;
|
|
160
|
+
setInputValue(event.target.value);
|
|
161
|
+
}, onFocus: (event) => {
|
|
162
|
+
event.target.select();
|
|
163
|
+
stateRef.current.originalElements = elements;
|
|
164
|
+
stateRef.current.originalAppState = cloneJSON(appState);
|
|
165
|
+
}, onBlur: (event) => {
|
|
166
|
+
if (!inputValue) {
|
|
167
|
+
setInputValue(value.toString());
|
|
168
|
+
}
|
|
169
|
+
else if (editable) {
|
|
170
|
+
handleInputValue(event.target.value, stateRef.current.originalElements, stateRef.current.originalAppState);
|
|
171
|
+
}
|
|
172
|
+
}, disabled: !editable })] }));
|
|
173
|
+
};
|
|
174
|
+
export default StatsDragInput;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { ExcalidrawElement } from "../../element/types";
|
|
3
|
+
import type Scene from "../../scene/Scene";
|
|
4
|
+
import type { AppState } from "../../types";
|
|
5
|
+
interface FontSizeProps {
|
|
6
|
+
element: ExcalidrawElement;
|
|
7
|
+
scene: Scene;
|
|
8
|
+
appState: AppState;
|
|
9
|
+
property: "fontSize";
|
|
10
|
+
}
|
|
11
|
+
declare const FontSize: ({ element, scene, appState, property }: FontSizeProps) => JSX.Element | null;
|
|
12
|
+
export default FontSize;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import StatsDragInput from "./DragInput";
|
|
3
|
+
import { mutateElement } from "../../element/mutateElement";
|
|
4
|
+
import { getStepSizedValue } from "./utils";
|
|
5
|
+
import { fontSizeIcon } from "../icons";
|
|
6
|
+
import { isTextElement, redrawTextBoundingBox } from "../../element";
|
|
7
|
+
import { hasBoundTextElement } from "../../element/typeChecks";
|
|
8
|
+
import { getBoundTextElement } from "../../element/textElement";
|
|
9
|
+
const MIN_FONT_SIZE = 4;
|
|
10
|
+
const STEP_SIZE = 4;
|
|
11
|
+
const handleFontSizeChange = ({ accumulatedChange, originalElements, shouldChangeByStepSize, nextValue, scene, }) => {
|
|
12
|
+
const elementsMap = scene.getNonDeletedElementsMap();
|
|
13
|
+
const origElement = originalElements[0];
|
|
14
|
+
if (origElement) {
|
|
15
|
+
const latestElement = elementsMap.get(origElement.id);
|
|
16
|
+
if (!latestElement || !isTextElement(latestElement)) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
let nextFontSize;
|
|
20
|
+
if (nextValue !== undefined) {
|
|
21
|
+
nextFontSize = Math.max(Math.round(nextValue), MIN_FONT_SIZE);
|
|
22
|
+
}
|
|
23
|
+
else if (origElement.type === "text") {
|
|
24
|
+
const originalFontSize = Math.round(origElement.fontSize);
|
|
25
|
+
const changeInFontSize = Math.round(accumulatedChange);
|
|
26
|
+
nextFontSize = Math.max(originalFontSize + changeInFontSize, MIN_FONT_SIZE);
|
|
27
|
+
if (shouldChangeByStepSize) {
|
|
28
|
+
nextFontSize = getStepSizedValue(nextFontSize, STEP_SIZE);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (nextFontSize) {
|
|
32
|
+
mutateElement(latestElement, {
|
|
33
|
+
fontSize: nextFontSize,
|
|
34
|
+
});
|
|
35
|
+
redrawTextBoundingBox(latestElement, scene.getContainerElement(latestElement), scene.getNonDeletedElementsMap());
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
const FontSize = ({ element, scene, appState, property }) => {
|
|
40
|
+
const _element = isTextElement(element)
|
|
41
|
+
? element
|
|
42
|
+
: hasBoundTextElement(element)
|
|
43
|
+
? getBoundTextElement(element, scene.getNonDeletedElementsMap())
|
|
44
|
+
: null;
|
|
45
|
+
if (!_element) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
return (_jsx(StatsDragInput, { label: "F", value: Math.round(_element.fontSize * 10) / 10, elements: [_element], dragInputCallback: handleFontSizeChange, icon: fontSizeIcon, appState: appState, scene: scene, property: property }));
|
|
49
|
+
};
|
|
50
|
+
export default FontSize;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { ExcalidrawElement } from "../../element/types";
|
|
3
|
+
import type Scene from "../../scene/Scene";
|
|
4
|
+
import type { AppState } from "../../types";
|
|
5
|
+
interface MultiAngleProps {
|
|
6
|
+
elements: readonly ExcalidrawElement[];
|
|
7
|
+
scene: Scene;
|
|
8
|
+
appState: AppState;
|
|
9
|
+
property: "angle";
|
|
10
|
+
}
|
|
11
|
+
declare const MultiAngle: ({ elements, scene, appState, property, }: MultiAngleProps) => JSX.Element;
|
|
12
|
+
export default MultiAngle;
|
|
@@ -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;
|