@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
|
@@ -2,9 +2,11 @@ import { updateBoundElements } from "./binding";
|
|
|
2
2
|
import { getCommonBounds } from "./bounds";
|
|
3
3
|
import { mutateElement } from "./mutateElement";
|
|
4
4
|
import { getPerfectElementSize } from "./sizeHelpers";
|
|
5
|
-
import { getBoundTextElement } from "./textElement";
|
|
5
|
+
import { getBoundTextElement, getMinTextElementWidth } from "./textElement";
|
|
6
6
|
import { getGridPoint } from "../math";
|
|
7
|
-
import { isArrowElement, isFrameLikeElement } from "./typeChecks";
|
|
7
|
+
import { isArrowElement, isFrameLikeElement, isTextElement, } from "./typeChecks";
|
|
8
|
+
import { getFontString } from "../utils";
|
|
9
|
+
import { TEXT_AUTOWRAP_THRESHOLD } from "../constants";
|
|
8
10
|
export const dragSelectedElements = (pointerDownState, selectedElements, offset, appState, scene, snapOffset, gridSize) => {
|
|
9
11
|
// we do not want a frame and its elements to be selected at the same time
|
|
10
12
|
// but when it happens (due to some bug), we want to avoid updating element
|
|
@@ -68,7 +70,7 @@ export const getDragOffsetXY = (selectedElements, x, y) => {
|
|
|
68
70
|
const [x1, y1] = getCommonBounds(selectedElements);
|
|
69
71
|
return [x - x1, y - y1];
|
|
70
72
|
};
|
|
71
|
-
export const dragNewElement = (draggingElement, elementType, originX, originY, x, y, width, height, shouldMaintainAspectRatio, shouldResizeFromCenter,
|
|
73
|
+
export const dragNewElement = (draggingElement, elementType, originX, originY, x, y, width, height, shouldMaintainAspectRatio, shouldResizeFromCenter, zoom,
|
|
72
74
|
/** whether to keep given aspect ratio when `isResizeWithSidesSameLength` is
|
|
73
75
|
true */
|
|
74
76
|
widthAspectRatio, originOffset = null) => {
|
|
@@ -99,12 +101,34 @@ widthAspectRatio, originOffset = null) => {
|
|
|
99
101
|
newX = originX - width / 2;
|
|
100
102
|
newY = originY - height / 2;
|
|
101
103
|
}
|
|
104
|
+
let textAutoResize = null;
|
|
105
|
+
// NOTE this should apply only to creating text elements, not existing
|
|
106
|
+
// (once we rewrite appState.draggingElement to actually mean dragging
|
|
107
|
+
// elements)
|
|
108
|
+
if (isTextElement(draggingElement)) {
|
|
109
|
+
height = draggingElement.height;
|
|
110
|
+
const minWidth = getMinTextElementWidth(getFontString({
|
|
111
|
+
fontSize: draggingElement.fontSize,
|
|
112
|
+
fontFamily: draggingElement.fontFamily,
|
|
113
|
+
}), draggingElement.lineHeight);
|
|
114
|
+
width = Math.max(width, minWidth);
|
|
115
|
+
if (Math.abs(x - originX) > TEXT_AUTOWRAP_THRESHOLD / zoom) {
|
|
116
|
+
textAutoResize = {
|
|
117
|
+
autoResize: false,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
newY = originY;
|
|
121
|
+
if (shouldResizeFromCenter) {
|
|
122
|
+
newX = originX - width / 2;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
102
125
|
if (width !== 0 && height !== 0) {
|
|
103
126
|
mutateElement(draggingElement, {
|
|
104
127
|
x: newX + (originOffset?.x ?? 0),
|
|
105
128
|
y: newY + (originOffset?.y ?? 0),
|
|
106
129
|
width,
|
|
107
130
|
height,
|
|
131
|
+
...textAutoResize,
|
|
108
132
|
});
|
|
109
133
|
}
|
|
110
134
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { ExcalidrawProps } from "../types";
|
|
3
|
-
import { ExcalidrawElement, ExcalidrawIframeLikeElement, IframeData } from "./types";
|
|
4
|
-
import { MarkRequired } from "../utility-types";
|
|
2
|
+
import type { ExcalidrawProps } from "../types";
|
|
3
|
+
import type { ExcalidrawElement, ExcalidrawIframeLikeElement, IframeData } from "./types";
|
|
4
|
+
import type { MarkRequired } from "../utility-types";
|
|
5
5
|
type IframeDataWithSandbox = MarkRequired<IframeData, "sandbox">;
|
|
6
6
|
export declare const createSrcDoc: (body: string) => string;
|
|
7
7
|
export declare const getEmbedLink: (link: string | null | undefined) => IframeDataWithSandbox | null;
|
|
@@ -146,7 +146,10 @@ export declare const actionSetEmbeddableAsActiveTool: {
|
|
|
146
146
|
isSpeaking?: boolean | undefined;
|
|
147
147
|
isMuted?: boolean | undefined;
|
|
148
148
|
}>>;
|
|
149
|
-
|
|
149
|
+
stats: {
|
|
150
|
+
open: boolean;
|
|
151
|
+
panels: number;
|
|
152
|
+
};
|
|
150
153
|
currentChartType: import("./types").ChartType;
|
|
151
154
|
pasteDialog: {
|
|
152
155
|
shown: false;
|
|
@@ -167,7 +170,7 @@ export declare const actionSetEmbeddableAsActiveTool: {
|
|
|
167
170
|
userToFollow: import("../types").UserToFollow | null;
|
|
168
171
|
followedBy: Set<import("../types").SocketId>;
|
|
169
172
|
};
|
|
170
|
-
storeAction:
|
|
173
|
+
storeAction: "none";
|
|
171
174
|
};
|
|
172
175
|
} & {
|
|
173
176
|
keyTest?: undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AppClassProperties, DataURL, BinaryFiles } from "../types";
|
|
2
|
-
import { ExcalidrawElement, FileId, InitializedExcalidrawImageElement } from "./types";
|
|
1
|
+
import type { AppClassProperties, DataURL, BinaryFiles } from "../types";
|
|
2
|
+
import type { ExcalidrawElement, FileId, InitializedExcalidrawImageElement } from "./types";
|
|
3
3
|
export declare const loadHTMLImageElement: (dataURL: DataURL) => Promise<HTMLImageElement>;
|
|
4
4
|
/** NOTE: updates cache even if already populated with given image. Thus,
|
|
5
5
|
* you should filter out the images upstream if you want to optimize this. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ExcalidrawElement, NonDeletedExcalidrawElement, NonDeleted } from "./types";
|
|
2
|
-
export { newElement, newTextElement,
|
|
1
|
+
import type { ExcalidrawElement, NonDeletedExcalidrawElement, NonDeleted } from "./types";
|
|
2
|
+
export { newElement, newTextElement, refreshTextDimensions, newLinearElement, newImageElement, duplicateElement, } from "./newElement";
|
|
3
3
|
export { getElementAbsoluteCoords, getElementBounds, getCommonBounds, getDiamondPoints, getArrowheadPoints, getClosestElementBounds, } from "./bounds";
|
|
4
4
|
export { OMIT_SIDES_FOR_MULTIPLE_ELEMENTS, getTransformHandlesFromCoords, getTransformHandles, } from "./transformHandles";
|
|
5
5
|
export { resizeTest, getCursorForResizingElement, getElementWithTransformHandleType, getTransformHandleTypeFromCoords, } from "./resizeTest";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isInvisiblySmallElement } from "./sizeHelpers";
|
|
2
2
|
import { isLinearElementType } from "./typeChecks";
|
|
3
|
-
export { newElement, newTextElement,
|
|
3
|
+
export { newElement, newTextElement, refreshTextDimensions, newLinearElement, newImageElement, duplicateElement, } from "./newElement";
|
|
4
4
|
export { getElementAbsoluteCoords, getElementBounds, getCommonBounds, getDiamondPoints, getArrowheadPoints, getClosestElementBounds, } from "./bounds";
|
|
5
5
|
export { OMIT_SIDES_FOR_MULTIPLE_ELEMENTS, getTransformHandlesFromCoords, getTransformHandles, } from "./transformHandles";
|
|
6
6
|
export { resizeTest, getCursorForResizingElement, getElementWithTransformHandleType, getTransformHandleTypeFromCoords, } from "./resizeTest";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { NonDeleted, ExcalidrawLinearElement, ExcalidrawElement, PointBinding, ExcalidrawBindableElement, ExcalidrawTextElementWithContainer, ElementsMap, NonDeletedSceneElementsMap } from "./types";
|
|
3
|
-
import { Bounds } from "./bounds";
|
|
4
|
-
import { Point, AppState, PointerCoords, InteractiveCanvasAppState, AppClassProperties } from "../types";
|
|
5
|
-
import { Store } from "../store";
|
|
2
|
+
import type { NonDeleted, ExcalidrawLinearElement, ExcalidrawElement, PointBinding, ExcalidrawBindableElement, ExcalidrawTextElementWithContainer, ElementsMap, NonDeletedSceneElementsMap } from "./types";
|
|
3
|
+
import type { Bounds } from "./bounds";
|
|
4
|
+
import type { Point, AppState, PointerCoords, InteractiveCanvasAppState, AppClassProperties } from "../types";
|
|
5
|
+
import type { Store } from "../store";
|
|
6
6
|
declare const editorMidPointsCache: {
|
|
7
7
|
version: number | null;
|
|
8
8
|
points: (Point | null)[];
|
|
@@ -253,7 +253,10 @@ export declare class LinearElementEditor {
|
|
|
253
253
|
isSpeaking?: boolean | undefined;
|
|
254
254
|
isMuted?: boolean | undefined;
|
|
255
255
|
}>>;
|
|
256
|
-
|
|
256
|
+
stats: {
|
|
257
|
+
open: boolean;
|
|
258
|
+
panels: number;
|
|
259
|
+
};
|
|
257
260
|
currentChartType: import("./types").ChartType;
|
|
258
261
|
pasteDialog: {
|
|
259
262
|
shown: false;
|
|
@@ -186,7 +186,7 @@ export class LinearElementEditor {
|
|
|
186
186
|
]);
|
|
187
187
|
}
|
|
188
188
|
const bindingElement = isBindingEnabled(appState)
|
|
189
|
-
? getHoveredElementForBinding(tupleToCoors(LinearElementEditor.getPointAtIndexGlobalCoordinates(element, selectedPoint, elementsMap)),
|
|
189
|
+
? getHoveredElementForBinding(tupleToCoors(LinearElementEditor.getPointAtIndexGlobalCoordinates(element, selectedPoint, elementsMap)), elementsMap)
|
|
190
190
|
: null;
|
|
191
191
|
bindings[selectedPoint === 0 ? "startBindingElement" : "endBindingElement"] = bindingElement;
|
|
192
192
|
}
|
|
@@ -359,7 +359,7 @@ export class LinearElementEditor {
|
|
|
359
359
|
},
|
|
360
360
|
selectedPointsIndices: [element.points.length - 1],
|
|
361
361
|
lastUncommittedPoint: null,
|
|
362
|
-
endBindingElement: getHoveredElementForBinding(scenePointer,
|
|
362
|
+
endBindingElement: getHoveredElementForBinding(scenePointer, elementsMap),
|
|
363
363
|
};
|
|
364
364
|
ret.didAddPoint = true;
|
|
365
365
|
return ret;
|
|
@@ -661,12 +661,15 @@ export class LinearElementEditor {
|
|
|
661
661
|
const nextPoints = points.map((point, idx) => {
|
|
662
662
|
const selectedPointData = targetPoints.find((p) => p.index === idx);
|
|
663
663
|
if (selectedPointData) {
|
|
664
|
-
if (
|
|
664
|
+
if (selectedPointData.index === 0) {
|
|
665
665
|
return point;
|
|
666
666
|
}
|
|
667
667
|
const deltaX = selectedPointData.point[0] - points[selectedPointData.index][0];
|
|
668
668
|
const deltaY = selectedPointData.point[1] - points[selectedPointData.index][1];
|
|
669
|
-
return [
|
|
669
|
+
return [
|
|
670
|
+
point[0] + deltaX - offsetX,
|
|
671
|
+
point[1] + deltaY - offsetY,
|
|
672
|
+
];
|
|
670
673
|
}
|
|
671
674
|
return offsetX || offsetY
|
|
672
675
|
? [point[0] - offsetX, point[1] - offsetY]
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ExcalidrawElement } from "./types";
|
|
2
|
-
import { Mutable } from "../utility-types";
|
|
1
|
+
import type { ExcalidrawElement } from "./types";
|
|
2
|
+
import type { Mutable } from "../utility-types";
|
|
3
3
|
export type ElementUpdate<TElement extends ExcalidrawElement> = Omit<Partial<TElement>, "id" | "version" | "versionNonce" | "updated">;
|
|
4
4
|
export declare const mutateElement: <TElement extends Mutable<ExcalidrawElement>>(element: TElement, updates: ElementUpdate<TElement>, informMutation?: boolean) => TElement;
|
|
5
5
|
export declare const newElementWith: <TElement extends ExcalidrawElement>(element: TElement, updates: ElementUpdate<TElement>) => TElement;
|
|
@@ -71,7 +71,7 @@ export const mutateElement = (element, updates, informMutation = true) => {
|
|
|
71
71
|
element.versionNonce = randomInteger();
|
|
72
72
|
element.updated = getUpdatedTimestamp();
|
|
73
73
|
if (informMutation) {
|
|
74
|
-
Scene.getScene(element)?.
|
|
74
|
+
Scene.getScene(element)?.triggerUpdate();
|
|
75
75
|
}
|
|
76
76
|
return element;
|
|
77
77
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ExcalidrawElement, ExcalidrawImageElement, ExcalidrawTextElement, ExcalidrawLinearElement, ExcalidrawGenericElement, NonDeleted, TextAlign, GroupId, VerticalAlign, Arrowhead, ExcalidrawFreeDrawElement, FontFamilyValues, ExcalidrawTextContainer, ExcalidrawFrameElement, ExcalidrawEmbeddableElement, ExcalidrawMagicFrameElement, ExcalidrawIframeElement, ElementsMap } from "./types";
|
|
2
|
-
import { AppState } from "../types";
|
|
3
|
-
import { MarkOptional, Mutable } from "../utility-types";
|
|
1
|
+
import type { ExcalidrawElement, ExcalidrawImageElement, ExcalidrawTextElement, ExcalidrawLinearElement, ExcalidrawGenericElement, NonDeleted, TextAlign, GroupId, VerticalAlign, Arrowhead, ExcalidrawFreeDrawElement, FontFamilyValues, ExcalidrawTextContainer, ExcalidrawFrameElement, ExcalidrawEmbeddableElement, ExcalidrawMagicFrameElement, ExcalidrawIframeElement, ElementsMap } from "./types";
|
|
2
|
+
import type { AppState } from "../types";
|
|
3
|
+
import type { MarkOptional, Mutable } from "../utility-types";
|
|
4
4
|
export type ElementConstructorOpts = MarkOptional<Omit<ExcalidrawGenericElement, "id" | "type" | "isDeleted" | "updated">, "width" | "height" | "angle" | "groupIds" | "frameId" | "index" | "boundElements" | "seed" | "version" | "versionNonce" | "link" | "strokeStyle" | "fillStyle" | "strokeColor" | "backgroundColor" | "roughness" | "strokeWidth" | "roundness" | "locked" | "opacity" | "customData">;
|
|
5
5
|
export declare const newElement: (opts: {
|
|
6
6
|
type: ExcalidrawGenericElement["type"];
|
|
@@ -19,6 +19,7 @@ export declare const newMagicFrameElement: (opts: {
|
|
|
19
19
|
} & ElementConstructorOpts) => NonDeleted<ExcalidrawMagicFrameElement>;
|
|
20
20
|
export declare const newTextElement: (opts: {
|
|
21
21
|
text: string;
|
|
22
|
+
originalText?: string;
|
|
22
23
|
fontSize?: number;
|
|
23
24
|
fontFamily?: FontFamilyValues;
|
|
24
25
|
textAlign?: TextAlign;
|
|
@@ -26,6 +27,7 @@ export declare const newTextElement: (opts: {
|
|
|
26
27
|
containerId?: ExcalidrawTextContainer["id"] | null;
|
|
27
28
|
lineHeight?: ExcalidrawTextElement["lineHeight"];
|
|
28
29
|
strokeWidth?: ExcalidrawTextElement["strokeWidth"];
|
|
30
|
+
autoResize?: ExcalidrawTextElement["autoResize"];
|
|
29
31
|
} & ElementConstructorOpts) => NonDeleted<ExcalidrawTextElement>;
|
|
30
32
|
export declare const refreshTextDimensions: (textElement: ExcalidrawTextElement, container: ExcalidrawTextContainer | null, elementsMap: ElementsMap, text?: string) => {
|
|
31
33
|
x: number;
|
|
@@ -34,11 +36,6 @@ export declare const refreshTextDimensions: (textElement: ExcalidrawTextElement,
|
|
|
34
36
|
height: number;
|
|
35
37
|
text: string;
|
|
36
38
|
} | undefined;
|
|
37
|
-
export declare const updateTextElement: (textElement: ExcalidrawTextElement, container: ExcalidrawTextContainer | null, elementsMap: ElementsMap, { text, isDeleted, originalText, }: {
|
|
38
|
-
text: string;
|
|
39
|
-
isDeleted?: boolean | undefined;
|
|
40
|
-
originalText: string;
|
|
41
|
-
}) => ExcalidrawTextElement;
|
|
42
39
|
export declare const newFreeDrawElement: (opts: {
|
|
43
40
|
type: "freedraw";
|
|
44
41
|
points?: ExcalidrawFreeDrawElement["points"];
|
|
@@ -85,7 +85,7 @@ export const newTextElement = (opts) => {
|
|
|
85
85
|
const textAlign = opts.textAlign || DEFAULT_TEXT_ALIGN;
|
|
86
86
|
const verticalAlign = opts.verticalAlign || DEFAULT_VERTICAL_ALIGN;
|
|
87
87
|
const offsets = getTextElementPositionOffsets({ textAlign, verticalAlign }, metrics);
|
|
88
|
-
const
|
|
88
|
+
const textElementProps = {
|
|
89
89
|
..._newElementBase("text", opts),
|
|
90
90
|
text,
|
|
91
91
|
fontSize,
|
|
@@ -97,19 +97,26 @@ export const newTextElement = (opts) => {
|
|
|
97
97
|
width: metrics.width,
|
|
98
98
|
height: metrics.height,
|
|
99
99
|
containerId: opts.containerId || null,
|
|
100
|
-
originalText: text,
|
|
100
|
+
originalText: opts.originalText ?? text,
|
|
101
|
+
autoResize: opts.autoResize ?? true,
|
|
101
102
|
lineHeight,
|
|
102
|
-
}
|
|
103
|
+
};
|
|
104
|
+
const textElement = newElementWith(textElementProps, {});
|
|
103
105
|
return textElement;
|
|
104
106
|
};
|
|
105
107
|
const getAdjustedDimensions = (element, elementsMap, nextText) => {
|
|
106
|
-
|
|
108
|
+
let { width: nextWidth, height: nextHeight } = measureText(nextText, getFontString(element), element.lineHeight);
|
|
109
|
+
// wrapped text
|
|
110
|
+
if (!element.autoResize) {
|
|
111
|
+
nextWidth = element.width;
|
|
112
|
+
}
|
|
107
113
|
const { textAlign, verticalAlign } = element;
|
|
108
114
|
let x;
|
|
109
115
|
let y;
|
|
110
116
|
if (textAlign === "center" &&
|
|
111
117
|
verticalAlign === VERTICAL_ALIGN.MIDDLE &&
|
|
112
|
-
!element.containerId
|
|
118
|
+
!element.containerId &&
|
|
119
|
+
element.autoResize) {
|
|
113
120
|
const prevMetrics = measureText(element.text, getFontString(element), element.lineHeight);
|
|
114
121
|
const offsets = getTextElementPositionOffsets(element, {
|
|
115
122
|
width: nextWidth - prevMetrics.width,
|
|
@@ -142,19 +149,14 @@ export const refreshTextDimensions = (textElement, container, elementsMap, text
|
|
|
142
149
|
if (textElement.isDeleted) {
|
|
143
150
|
return;
|
|
144
151
|
}
|
|
145
|
-
if (container) {
|
|
146
|
-
text = wrapText(text, getFontString(textElement),
|
|
152
|
+
if (container || !textElement.autoResize) {
|
|
153
|
+
text = wrapText(text, getFontString(textElement), container
|
|
154
|
+
? getBoundTextMaxWidth(container, textElement)
|
|
155
|
+
: textElement.width);
|
|
147
156
|
}
|
|
148
157
|
const dimensions = getAdjustedDimensions(textElement, elementsMap, text);
|
|
149
158
|
return { text, ...dimensions };
|
|
150
159
|
};
|
|
151
|
-
export const updateTextElement = (textElement, container, elementsMap, { text, isDeleted, originalText, }) => {
|
|
152
|
-
return newElementWith(textElement, {
|
|
153
|
-
originalText,
|
|
154
|
-
isDeleted: isDeleted ?? textElement.isDeleted,
|
|
155
|
-
...refreshTextDimensions(textElement, container, elementsMap, originalText),
|
|
156
|
-
});
|
|
157
|
-
};
|
|
158
160
|
export const newFreeDrawElement = (opts) => {
|
|
159
161
|
return {
|
|
160
162
|
..._newElementBase(opts.type, opts),
|
|
@@ -1,8 +1,16 @@
|
|
|
1
|
-
import { ExcalidrawLinearElement, NonDeletedExcalidrawElement, NonDeleted, ElementsMap } from "./types";
|
|
2
|
-
import { MaybeTransformHandleType, TransformHandleDirection } from "./transformHandles";
|
|
3
|
-
import { PointerDownState } from "../types";
|
|
1
|
+
import type { ExcalidrawLinearElement, ExcalidrawTextElement, NonDeletedExcalidrawElement, NonDeleted, ElementsMap } from "./types";
|
|
2
|
+
import type { MaybeTransformHandleType, TransformHandleDirection } from "./transformHandles";
|
|
3
|
+
import type { PointerDownState } from "../types";
|
|
4
4
|
export declare const normalizeAngle: (angle: number) => number;
|
|
5
5
|
export declare const transformElements: (originalElements: PointerDownState["originalElements"], transformHandleType: MaybeTransformHandleType, selectedElements: readonly NonDeletedExcalidrawElement[], elementsMap: ElementsMap, shouldRotateWithDiscreteAngle: boolean, shouldResizeFromCenter: boolean, shouldMaintainAspectRatio: boolean, pointerX: number, pointerY: number, centerX: number, centerY: number) => boolean;
|
|
6
|
+
export declare const rescalePointsInElement: (element: NonDeletedExcalidrawElement, width: number, height: number, normalizePoints: boolean) => {
|
|
7
|
+
points: (readonly [number, number])[];
|
|
8
|
+
} | {
|
|
9
|
+
points?: undefined;
|
|
10
|
+
};
|
|
11
|
+
export declare const measureFontSizeFromWidth: (element: NonDeleted<ExcalidrawTextElement>, elementsMap: ElementsMap, nextWidth: number) => {
|
|
12
|
+
size: number;
|
|
13
|
+
} | null;
|
|
6
14
|
export declare const resizeSingleElement: (originalElements: PointerDownState["originalElements"], shouldMaintainAspectRatio: boolean, element: NonDeletedExcalidrawElement, elementsMap: ElementsMap, transformHandleDirection: TransformHandleDirection, shouldResizeFromCenter: boolean, pointerX: number, pointerY: number) => void;
|
|
7
15
|
export declare const resizeMultipleElements: (originalElements: PointerDownState["originalElements"], selectedElements: readonly NonDeletedExcalidrawElement[], elementsMap: ElementsMap, transformHandleType: TransformHandleDirection, shouldResizeFromCenter: boolean, shouldMaintainAspectRatio: boolean, pointerX: number, pointerY: number) => void;
|
|
8
16
|
export declare const getResizeOffsetXY: (transformHandleType: MaybeTransformHandleType, selectedElements: NonDeletedExcalidrawElement[], elementsMap: ElementsMap, x: number, y: number) => [number, number];
|
|
@@ -7,7 +7,7 @@ import { mutateElement } from "./mutateElement";
|
|
|
7
7
|
import { getFontString } from "../utils";
|
|
8
8
|
import { updateBoundElements } from "./binding";
|
|
9
9
|
import Scene from "../scene/Scene";
|
|
10
|
-
import { getApproxMinLineWidth, getBoundTextElement, getBoundTextElementId, getContainerElement, handleBindTextResize, getBoundTextMaxWidth, getApproxMinLineHeight, } from "./textElement";
|
|
10
|
+
import { getApproxMinLineWidth, getBoundTextElement, getBoundTextElementId, getContainerElement, handleBindTextResize, getBoundTextMaxWidth, getApproxMinLineHeight, wrapText, measureText, getMinTextElementWidth, } from "./textElement";
|
|
11
11
|
import { LinearElementEditor } from "./linearElementEditor";
|
|
12
12
|
import { isInGroup } from "../groups";
|
|
13
13
|
export const normalizeAngle = (angle) => {
|
|
@@ -27,12 +27,8 @@ export const transformElements = (originalElements, transformHandleType, selecte
|
|
|
27
27
|
rotateSingleElement(element, elementsMap, pointerX, pointerY, shouldRotateWithDiscreteAngle);
|
|
28
28
|
updateBoundElements(element, elementsMap);
|
|
29
29
|
}
|
|
30
|
-
else if (isTextElement(element) &&
|
|
31
|
-
(transformHandleType
|
|
32
|
-
transformHandleType === "ne" ||
|
|
33
|
-
transformHandleType === "sw" ||
|
|
34
|
-
transformHandleType === "se")) {
|
|
35
|
-
resizeSingleTextElement(element, elementsMap, transformHandleType, shouldResizeFromCenter, pointerX, pointerY);
|
|
30
|
+
else if (isTextElement(element) && transformHandleType) {
|
|
31
|
+
resizeSingleTextElement(originalElements, element, elementsMap, transformHandleType, shouldResizeFromCenter, pointerX, pointerY);
|
|
36
32
|
updateBoundElements(element, elementsMap);
|
|
37
33
|
}
|
|
38
34
|
else if (transformHandleType) {
|
|
@@ -77,12 +73,12 @@ const rotateSingleElement = (element, elementsMap, pointerX, pointerY, shouldRot
|
|
|
77
73
|
}
|
|
78
74
|
}
|
|
79
75
|
};
|
|
80
|
-
const rescalePointsInElement = (element, width, height, normalizePoints) => isLinearElement(element) || isFreeDrawElement(element)
|
|
76
|
+
export const rescalePointsInElement = (element, width, height, normalizePoints) => isLinearElement(element) || isFreeDrawElement(element)
|
|
81
77
|
? {
|
|
82
78
|
points: rescalePoints(0, width, rescalePoints(1, height, element.points, normalizePoints), normalizePoints),
|
|
83
79
|
}
|
|
84
80
|
: {};
|
|
85
|
-
const measureFontSizeFromWidth = (element, elementsMap, nextWidth) => {
|
|
81
|
+
export const measureFontSizeFromWidth = (element, elementsMap, nextWidth) => {
|
|
86
82
|
// We only use width to scale font on resize
|
|
87
83
|
let width = element.width;
|
|
88
84
|
const hasContainer = isBoundToContainer(element);
|
|
@@ -100,23 +96,25 @@ const measureFontSizeFromWidth = (element, elementsMap, nextWidth) => {
|
|
|
100
96
|
size: nextFontSize,
|
|
101
97
|
};
|
|
102
98
|
};
|
|
103
|
-
const resizeSingleTextElement = (element, elementsMap, transformHandleType, shouldResizeFromCenter, pointerX, pointerY) => {
|
|
99
|
+
const resizeSingleTextElement = (originalElements, element, elementsMap, transformHandleType, shouldResizeFromCenter, pointerX, pointerY) => {
|
|
104
100
|
const [x1, y1, x2, y2, cx, cy] = getElementAbsoluteCoords(element, elementsMap);
|
|
105
101
|
// rotation pointer with reverse angle
|
|
106
102
|
const [rotatedX, rotatedY] = rotate(pointerX, pointerY, cx, cy, -element.angle);
|
|
107
103
|
let scaleX = 0;
|
|
108
104
|
let scaleY = 0;
|
|
109
|
-
if (transformHandleType
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
105
|
+
if (transformHandleType !== "e" && transformHandleType !== "w") {
|
|
106
|
+
if (transformHandleType.includes("e")) {
|
|
107
|
+
scaleX = (rotatedX - x1) / (x2 - x1);
|
|
108
|
+
}
|
|
109
|
+
if (transformHandleType.includes("w")) {
|
|
110
|
+
scaleX = (x2 - rotatedX) / (x2 - x1);
|
|
111
|
+
}
|
|
112
|
+
if (transformHandleType.includes("n")) {
|
|
113
|
+
scaleY = (y2 - rotatedY) / (y2 - y1);
|
|
114
|
+
}
|
|
115
|
+
if (transformHandleType.includes("s")) {
|
|
116
|
+
scaleY = (rotatedY - y1) / (y2 - y1);
|
|
117
|
+
}
|
|
120
118
|
}
|
|
121
119
|
const scale = Math.max(scaleX, scaleY);
|
|
122
120
|
if (scale > 0) {
|
|
@@ -171,6 +169,60 @@ const resizeSingleTextElement = (element, elementsMap, transformHandleType, shou
|
|
|
171
169
|
y: nextY,
|
|
172
170
|
});
|
|
173
171
|
}
|
|
172
|
+
if (transformHandleType === "e" || transformHandleType === "w") {
|
|
173
|
+
const stateAtResizeStart = originalElements.get(element.id);
|
|
174
|
+
const [x1, y1, x2, y2] = getResizedElementAbsoluteCoords(stateAtResizeStart, stateAtResizeStart.width, stateAtResizeStart.height, true);
|
|
175
|
+
const startTopLeft = [x1, y1];
|
|
176
|
+
const startBottomRight = [x2, y2];
|
|
177
|
+
const startCenter = centerPoint(startTopLeft, startBottomRight);
|
|
178
|
+
const rotatedPointer = rotatePoint([pointerX, pointerY], startCenter, -stateAtResizeStart.angle);
|
|
179
|
+
const [esx1, , esx2] = getResizedElementAbsoluteCoords(element, element.width, element.height, true);
|
|
180
|
+
const boundsCurrentWidth = esx2 - esx1;
|
|
181
|
+
const atStartBoundsWidth = startBottomRight[0] - startTopLeft[0];
|
|
182
|
+
const minWidth = getMinTextElementWidth(getFontString({
|
|
183
|
+
fontSize: element.fontSize,
|
|
184
|
+
fontFamily: element.fontFamily,
|
|
185
|
+
}), element.lineHeight);
|
|
186
|
+
let scaleX = atStartBoundsWidth / boundsCurrentWidth;
|
|
187
|
+
if (transformHandleType.includes("e")) {
|
|
188
|
+
scaleX = (rotatedPointer[0] - startTopLeft[0]) / boundsCurrentWidth;
|
|
189
|
+
}
|
|
190
|
+
if (transformHandleType.includes("w")) {
|
|
191
|
+
scaleX = (startBottomRight[0] - rotatedPointer[0]) / boundsCurrentWidth;
|
|
192
|
+
}
|
|
193
|
+
const newWidth = element.width * scaleX < minWidth ? minWidth : element.width * scaleX;
|
|
194
|
+
const text = wrapText(element.originalText, getFontString(element), Math.abs(newWidth));
|
|
195
|
+
const metrics = measureText(text, getFontString(element), element.lineHeight);
|
|
196
|
+
const eleNewHeight = metrics.height;
|
|
197
|
+
const [newBoundsX1, newBoundsY1, newBoundsX2, newBoundsY2] = getResizedElementAbsoluteCoords(stateAtResizeStart, newWidth, eleNewHeight, true);
|
|
198
|
+
const newBoundsWidth = newBoundsX2 - newBoundsX1;
|
|
199
|
+
const newBoundsHeight = newBoundsY2 - newBoundsY1;
|
|
200
|
+
let newTopLeft = [...startTopLeft];
|
|
201
|
+
if (["n", "w", "nw"].includes(transformHandleType)) {
|
|
202
|
+
newTopLeft = [
|
|
203
|
+
startBottomRight[0] - Math.abs(newBoundsWidth),
|
|
204
|
+
startTopLeft[1],
|
|
205
|
+
];
|
|
206
|
+
}
|
|
207
|
+
// adjust topLeft to new rotation point
|
|
208
|
+
const angle = stateAtResizeStart.angle;
|
|
209
|
+
const rotatedTopLeft = rotatePoint(newTopLeft, startCenter, angle);
|
|
210
|
+
const newCenter = [
|
|
211
|
+
newTopLeft[0] + Math.abs(newBoundsWidth) / 2,
|
|
212
|
+
newTopLeft[1] + Math.abs(newBoundsHeight) / 2,
|
|
213
|
+
];
|
|
214
|
+
const rotatedNewCenter = rotatePoint(newCenter, startCenter, angle);
|
|
215
|
+
newTopLeft = rotatePoint(rotatedTopLeft, rotatedNewCenter, -angle);
|
|
216
|
+
const resizedElement = {
|
|
217
|
+
width: Math.abs(newWidth),
|
|
218
|
+
height: Math.abs(metrics.height),
|
|
219
|
+
x: newTopLeft[0],
|
|
220
|
+
y: newTopLeft[1],
|
|
221
|
+
text,
|
|
222
|
+
autoResize: false,
|
|
223
|
+
};
|
|
224
|
+
mutateElement(element, resizedElement);
|
|
225
|
+
}
|
|
174
226
|
};
|
|
175
227
|
export const resizeSingleElement = (originalElements, shouldMaintainAspectRatio, element, elementsMap, transformHandleDirection, shouldResizeFromCenter, pointerX, pointerY) => {
|
|
176
228
|
const stateAtResizeStart = originalElements.get(element.id);
|
|
@@ -541,7 +593,7 @@ export const resizeMultipleElements = (originalElements, selectedElements, eleme
|
|
|
541
593
|
handleBindTextResize(element, elementsMap, transformHandleType, true);
|
|
542
594
|
}
|
|
543
595
|
}
|
|
544
|
-
Scene.getScene(elementsAndUpdates[0].element)?.
|
|
596
|
+
Scene.getScene(elementsAndUpdates[0].element)?.triggerUpdate();
|
|
545
597
|
};
|
|
546
598
|
const rotateMultipleElements = (originalElements, elements, elementsMap, pointerX, pointerY, shouldRotateWithDiscreteAngle, centerX, centerY) => {
|
|
547
599
|
let centerAngle = (5 * Math.PI) / 2 + Math.atan2(pointerY - centerY, pointerX - centerX);
|
|
@@ -574,7 +626,7 @@ const rotateMultipleElements = (originalElements, elements, elementsMap, pointer
|
|
|
574
626
|
}, false);
|
|
575
627
|
}
|
|
576
628
|
});
|
|
577
|
-
Scene.getScene(elements[0])?.
|
|
629
|
+
Scene.getScene(elements[0])?.triggerUpdate();
|
|
578
630
|
};
|
|
579
631
|
export const getResizeOffsetXY = (transformHandleType, selectedElements, elementsMap, x, y) => {
|
|
580
632
|
const [x1, y1, x2, y2] = selectedElements.length === 1
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ExcalidrawElement, PointerType, NonDeletedExcalidrawElement, ElementsMap } from "./types";
|
|
2
|
-
import { MaybeTransformHandleType } from "./transformHandles";
|
|
3
|
-
import { AppState, Device, Zoom } from "../types";
|
|
4
|
-
import { Bounds } from "./bounds";
|
|
1
|
+
import type { ExcalidrawElement, PointerType, NonDeletedExcalidrawElement, ElementsMap } from "./types";
|
|
2
|
+
import type { MaybeTransformHandleType } from "./transformHandles";
|
|
3
|
+
import type { AppState, Device, Zoom } from "../types";
|
|
4
|
+
import type { Bounds } from "./bounds";
|
|
5
5
|
export declare const resizeTest: (element: NonDeletedExcalidrawElement, elementsMap: ElementsMap, appState: AppState, x: number, y: number, zoom: Zoom, pointerType: PointerType, device: Device) => MaybeTransformHandleType;
|
|
6
6
|
export declare const getElementWithTransformHandleType: (elements: readonly NonDeletedExcalidrawElement[], appState: AppState, scenePointerX: number, scenePointerY: number, zoom: Zoom, pointerType: PointerType, elementsMap: ElementsMap, device: Device) => {
|
|
7
7
|
element: NonDeletedExcalidrawElement;
|
|
@@ -28,10 +28,8 @@ export const resizeTest = (element, elementsMap, appState, x, y, zoom, pointerTy
|
|
|
28
28
|
}
|
|
29
29
|
if (canResizeFromSides(device)) {
|
|
30
30
|
const [x1, y1, x2, y2, cx, cy] = getElementAbsoluteCoords(element, elementsMap);
|
|
31
|
-
//
|
|
32
|
-
|
|
33
|
-
if (element.type !== "text" &&
|
|
34
|
-
!(isLinearElement(element) && element.points.length <= 2)) {
|
|
31
|
+
// do not resize from the sides for linear elements with only two points
|
|
32
|
+
if (!(isLinearElement(element) && element.points.length <= 2)) {
|
|
35
33
|
const SPACING = SIDE_RESIZING_THRESHOLD / zoom.value;
|
|
36
34
|
const sides = getSelectionBorders([x1 - SPACING, y1 - SPACING], [x2 + SPACING, y2 + SPACING], [cx, cy], angleToDegrees(element.angle));
|
|
37
35
|
for (const [dir, side] of Object.entries(sides)) {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { NonDeletedExcalidrawElement } from "./types";
|
|
2
|
-
import { UIAppState } from "../types";
|
|
1
|
+
import type { NonDeletedExcalidrawElement } from "./types";
|
|
2
|
+
import type { UIAppState } from "../types";
|
|
3
3
|
export declare const showSelectedShapeActions: (appState: UIAppState, elements: readonly NonDeletedExcalidrawElement[]) => boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ElementsMap, ExcalidrawElement } from "./types";
|
|
2
|
-
import { AppState, Zoom } from "../types";
|
|
1
|
+
import type { ElementsMap, ExcalidrawElement } from "./types";
|
|
2
|
+
import type { AppState, Zoom } from "../types";
|
|
3
3
|
export declare const isInvisiblySmallElement: (element: ExcalidrawElement) => boolean;
|
|
4
4
|
export declare const isElementInViewport: (element: ExcalidrawElement, width: number, height: number, viewTransformations: {
|
|
5
5
|
zoom: Zoom;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ExcalidrawElement } from "./types";
|
|
1
|
+
import type { ExcalidrawElement } from "./types";
|
|
2
2
|
export declare const normalizeElementOrder: (elements: readonly ExcalidrawElement[]) => readonly ExcalidrawElement[];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ElementsMap, ExcalidrawElement, ExcalidrawElementType, ExcalidrawTextContainer, ExcalidrawTextElement, ExcalidrawTextElementWithContainer, FontFamilyValues, FontString, NonDeletedExcalidrawElement } from "./types";
|
|
2
|
-
import { MaybeTransformHandleType } from "./transformHandles";
|
|
3
|
-
import { AppState } from "../types";
|
|
4
|
-
import { ExtractSetType, MakeBrand } from "../utility-types";
|
|
1
|
+
import type { ElementsMap, ExcalidrawElement, ExcalidrawElementType, ExcalidrawTextContainer, ExcalidrawTextElement, ExcalidrawTextElementWithContainer, FontFamilyValues, FontString, NonDeletedExcalidrawElement } from "./types";
|
|
2
|
+
import type { MaybeTransformHandleType } from "./transformHandles";
|
|
3
|
+
import type { AppState } from "../types";
|
|
4
|
+
import type { ExtractSetType, MakeBrand } from "../utility-types";
|
|
5
5
|
export declare const normalizeText: (text: string) => string;
|
|
6
6
|
export declare const redrawTextBoundingBox: (textElement: ExcalidrawTextElement, container: ExcalidrawElement | null, elementsMap: ElementsMap, informMutation?: boolean) => void;
|
|
7
7
|
export declare const bindTextToShapeAfterDuplication: (newElements: ExcalidrawElement[], oldElements: ExcalidrawElement[], oldIdToDuplicatedId: Map<ExcalidrawElement["id"], ExcalidrawElement["id"]>) => void;
|
|
@@ -87,4 +87,5 @@ export declare const FONT_METRICS: Record<number, {
|
|
|
87
87
|
export declare const getDefaultLineHeight: (fontFamily: FontFamilyValues) => number & {
|
|
88
88
|
_brand: "unitlessLineHeight";
|
|
89
89
|
};
|
|
90
|
+
export declare const getMinTextElementWidth: (font: FontString, lineHeight: ExcalidrawTextElement["lineHeight"]) => number;
|
|
90
91
|
export {};
|
|
@@ -24,12 +24,17 @@ export const redrawTextBoundingBox = (textElement, container, elementsMap, infor
|
|
|
24
24
|
angle: container?.angle ?? textElement.angle,
|
|
25
25
|
};
|
|
26
26
|
boundTextUpdates.text = textElement.text;
|
|
27
|
-
if (container) {
|
|
28
|
-
maxWidth =
|
|
27
|
+
if (container || !textElement.autoResize) {
|
|
28
|
+
maxWidth = container
|
|
29
|
+
? getBoundTextMaxWidth(container, textElement)
|
|
30
|
+
: textElement.width;
|
|
29
31
|
boundTextUpdates.text = wrapText(textElement.originalText, getFontString(textElement), maxWidth);
|
|
30
32
|
}
|
|
31
33
|
const metrics = measureText(boundTextUpdates.text, getFontString(textElement), textElement.lineHeight);
|
|
32
|
-
|
|
34
|
+
// Note: only update width for unwrapped text and bound texts (which always have autoResize set to true)
|
|
35
|
+
if (textElement.autoResize) {
|
|
36
|
+
boundTextUpdates.width = metrics.width;
|
|
37
|
+
}
|
|
33
38
|
boundTextUpdates.height = metrics.height;
|
|
34
39
|
if (container) {
|
|
35
40
|
const maxContainerHeight = getBoundTextMaxHeight(container, textElement);
|
|
@@ -661,3 +666,6 @@ export const getDefaultLineHeight = (fontFamily) => {
|
|
|
661
666
|
}
|
|
662
667
|
return DEFAULT_LINE_HEIGHT[DEFAULT_FONT_FAMILY];
|
|
663
668
|
};
|
|
669
|
+
export const getMinTextElementWidth = (font, lineHeight) => {
|
|
670
|
+
return measureText("", font, lineHeight).width + BOUND_TEXT_PADDING * 2;
|
|
671
|
+
};
|
|
@@ -1,16 +1,22 @@
|
|
|
1
|
-
import { ExcalidrawElement, ExcalidrawTextElement } from "./types";
|
|
2
|
-
import App from "../components/App";
|
|
3
|
-
export declare const textWysiwyg: ({ id, onChange, onSubmit, getViewportCoords, element, canvas, excalidrawContainer, app, }: {
|
|
1
|
+
import type { ExcalidrawElement, ExcalidrawTextElement } from "./types";
|
|
2
|
+
import type App from "../components/App";
|
|
3
|
+
export declare const textWysiwyg: ({ id, onChange, onSubmit, getViewportCoords, element, canvas, excalidrawContainer, app, autoSelect, }: {
|
|
4
4
|
id: ExcalidrawElement["id"];
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* textWysiwyg only deals with `originalText`
|
|
7
|
+
*
|
|
8
|
+
* Note: `text`, which can be wrapped and therefore different from `originalText`,
|
|
9
|
+
* is derived from `originalText`
|
|
10
|
+
*/
|
|
11
|
+
onChange?: ((nextOriginalText: string) => void) | undefined;
|
|
6
12
|
onSubmit: (data: {
|
|
7
|
-
text: string;
|
|
8
13
|
viaKeyboard: boolean;
|
|
9
|
-
|
|
14
|
+
nextOriginalText: string;
|
|
10
15
|
}) => void;
|
|
11
16
|
getViewportCoords: (x: number, y: number) => [number, number];
|
|
12
17
|
element: ExcalidrawTextElement;
|
|
13
18
|
canvas: HTMLCanvasElement;
|
|
14
19
|
excalidrawContainer: HTMLDivElement | null;
|
|
15
20
|
app: App;
|
|
21
|
+
autoSelect?: boolean | undefined;
|
|
16
22
|
}) => void;
|