@excalidraw/element 0.18.0-9ba0f5d → 0.18.0-a52cd20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dev/index.js +13141 -8453
- package/dist/dev/index.js.map +4 -4
- package/dist/prod/index.js +20 -19
- package/dist/types/common/debug.d.ts +21 -0
- package/dist/types/common/src/appEventBus.d.ts +27 -0
- package/dist/types/common/src/colors.d.ts +24 -2
- package/dist/types/common/src/constants.d.ts +70 -7
- package/dist/types/common/src/index.d.ts +3 -0
- package/dist/types/common/src/keys.d.ts +4 -0
- package/dist/types/common/src/points.d.ts +1 -1
- package/dist/types/common/src/random.d.ts +7 -0
- package/dist/types/common/src/utils.d.ts +10 -50
- package/dist/types/common/src/versionedSnapshotStore.d.ts +17 -0
- package/dist/types/element/src/Scene.d.ts +9 -5
- package/dist/types/element/src/align.d.ts +2 -2
- package/dist/types/element/src/arrowEndpointText.d.ts +49 -0
- package/dist/types/element/src/arrowheads.d.ts +3 -0
- package/dist/types/element/src/arrows/focus.d.ts +30 -0
- package/dist/types/element/src/arrows/helpers.d.ts +5 -0
- package/dist/types/element/src/binding.d.ts +37 -17
- package/dist/types/element/src/bounds.d.ts +23 -8
- package/dist/types/element/src/bucketFill.d.ts +110 -0
- package/dist/types/element/src/collision.d.ts +7 -3
- package/dist/types/element/src/comparisons.d.ts +8 -5
- package/dist/types/element/src/convertToShape.d.ts +23 -0
- package/dist/types/element/src/delta.d.ts +23 -1
- package/dist/types/element/src/distribute.d.ts +3 -2
- package/dist/types/element/src/dragElements.d.ts +27 -0
- package/dist/types/element/src/duplicate.d.ts +64 -3
- package/dist/types/element/src/elbowArrow.d.ts +2 -0
- package/dist/types/element/src/embeddable.d.ts +2 -2
- package/dist/types/element/src/flowchart.d.ts +11 -7
- package/dist/types/element/src/fractionalIndex.d.ts +2 -2
- package/dist/types/element/src/frame.d.ts +11 -10
- package/dist/types/element/src/groups.d.ts +9 -9
- package/dist/types/element/src/index.d.ts +8 -1
- package/dist/types/element/src/linearElementEditor.d.ts +32 -10
- package/dist/types/element/src/mutateElement.d.ts +3 -1
- package/dist/types/element/src/newElement.d.ts +53 -3
- package/dist/types/element/src/renderElement.d.ts +21 -7
- package/dist/types/element/src/resizeElements.d.ts +2 -2
- package/dist/types/element/src/selection.d.ts +11 -7
- package/dist/types/element/src/shape.d.ts +28 -2
- package/dist/types/element/src/sizeHelpers.d.ts +6 -0
- package/dist/types/element/src/sortElements.d.ts +10 -0
- package/dist/types/element/src/stickyNote.d.ts +183 -0
- package/dist/types/element/src/textElement.d.ts +21 -10
- package/dist/types/element/src/textWrapping.d.ts +26 -0
- package/dist/types/element/src/transform.d.ts +26 -7
- package/dist/types/element/src/typeChecks.d.ts +29 -27
- package/dist/types/element/src/types.d.ts +48 -9
- package/dist/types/element/src/utils.d.ts +19 -6
- package/dist/types/element/src/visualdebug.d.ts +1 -2
- package/dist/types/element/src/zindex.d.ts +2 -2
- package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +125 -53
- package/dist/types/excalidraw/actions/actionAlign.d.ts +6 -6
- package/dist/types/excalidraw/actions/actionBoundText.d.ts +85 -37
- package/dist/types/excalidraw/actions/actionCanvas.d.ts +356 -1019
- package/dist/types/excalidraw/actions/actionClipboard.d.ts +84 -36
- package/dist/types/excalidraw/actions/actionCropEditor.d.ts +42 -18
- package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +130 -55
- package/dist/types/excalidraw/actions/actionDeselect.d.ts +182 -0
- package/dist/types/excalidraw/actions/actionDistribute.d.ts +2 -3
- package/dist/types/excalidraw/actions/actionElementLink.d.ts +38 -18
- package/dist/types/excalidraw/actions/actionElementLock.d.ts +85 -37
- package/dist/types/excalidraw/actions/actionExport.d.ts +133 -359
- package/dist/types/excalidraw/actions/actionFinalize.d.ts +1 -0
- package/dist/types/excalidraw/actions/actionFrame.d.ts +187 -236
- package/dist/types/excalidraw/actions/actionGroup.d.ts +100 -52
- package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +99 -21
- package/dist/types/excalidraw/actions/actionLink.d.ts +43 -19
- package/dist/types/excalidraw/actions/actionMenu.d.ts +38 -18
- package/dist/types/excalidraw/actions/actionProperties.d.ts +120 -56
- package/dist/types/excalidraw/actions/actionSelectAll.d.ts +46 -22
- package/dist/types/excalidraw/actions/actionStyles.d.ts +43 -18
- package/dist/types/excalidraw/actions/actionTextAutoResize.d.ts +3 -3
- package/dist/types/excalidraw/actions/{actionEmbeddable.d.ts → actionToggleArrowBinding.d.ts} +57 -32
- package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +46 -23
- package/dist/types/excalidraw/actions/actionToggleMidpointSnapping.d.ts +195 -0
- package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +43 -19
- package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +42 -23
- package/dist/types/excalidraw/actions/actionToggleShapeSwitch.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionToggleStats.d.ts +43 -19
- package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +44 -20
- package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +43 -19
- package/dist/types/excalidraw/actions/colorTargets.d.ts +39 -0
- package/dist/types/excalidraw/actions/index.d.ts +4 -2
- package/dist/types/excalidraw/actions/manager.d.ts +1 -0
- package/dist/types/excalidraw/actions/shortcuts.d.ts +1 -1
- package/dist/types/excalidraw/actions/types.d.ts +8 -4
- package/dist/types/excalidraw/{animated-trail.d.ts → animatedTrail.d.ts} +4 -3
- package/dist/types/excalidraw/appState.d.ts +39 -13
- package/dist/types/excalidraw/charts/charts.bar.d.ts +2 -0
- package/dist/types/excalidraw/charts/charts.constants.d.ts +48 -0
- package/dist/types/excalidraw/charts/charts.helpers.d.ts +32 -0
- package/dist/types/excalidraw/charts/charts.line.d.ts +2 -0
- package/dist/types/excalidraw/charts/charts.parse.d.ts +10 -0
- package/dist/types/excalidraw/charts/charts.radar.d.ts +2 -0
- package/dist/types/excalidraw/charts/charts.types.d.ts +18 -0
- package/dist/types/excalidraw/charts/index.d.ts +7 -0
- package/dist/types/excalidraw/clipboard.d.ts +6 -7
- package/dist/types/excalidraw/components/Actions.d.ts +17 -12
- package/dist/types/excalidraw/components/ActiveConfirmDialog.d.ts +1 -1
- package/dist/types/excalidraw/components/App.arrowText.d.ts +70 -0
- package/dist/types/excalidraw/components/App.bucketFill.d.ts +48 -0
- package/dist/types/excalidraw/components/App.cursor.d.ts +38 -0
- package/dist/types/excalidraw/components/App.d.ts +604 -89
- package/dist/types/excalidraw/components/App.drawshape.d.ts +55 -0
- package/dist/types/excalidraw/components/App.duplicate.d.ts +51 -0
- package/dist/types/excalidraw/components/App.flowchart.d.ts +21 -0
- package/dist/types/excalidraw/components/App.pan.d.ts +62 -0
- package/dist/types/excalidraw/components/App.textTool.d.ts +140 -0
- package/dist/types/excalidraw/components/App.toolDrag.d.ts +63 -0
- package/dist/types/excalidraw/components/App.viewport.d.ts +113 -0
- package/dist/types/excalidraw/components/App.wheel.d.ts +26 -0
- package/dist/types/excalidraw/components/AppStateObserver.d.ts +37 -0
- package/dist/types/excalidraw/components/ColorPicker/ColorPicker.d.ts +9 -3
- package/dist/types/excalidraw/components/ColorPicker/CustomColorList.d.ts +3 -1
- package/dist/types/excalidraw/components/ColorPicker/Picker.d.ts +5 -1
- package/dist/types/excalidraw/components/ColorPicker/PickerColorList.d.ts +9 -2
- package/dist/types/excalidraw/components/ColorPicker/ShadeList.d.ts +4 -2
- package/dist/types/excalidraw/components/ColorPicker/TopPicks.d.ts +8 -1
- package/dist/types/excalidraw/components/ColorPicker/colorPickerUtils.d.ts +1 -1
- package/dist/types/excalidraw/components/ColorPicker/colorTopPicksDnD.d.ts +11 -0
- package/dist/types/excalidraw/components/ColorPicker/keyboardNavHandlers.d.ts +2 -1
- package/dist/types/excalidraw/components/CommandPalette/defaultCommandPaletteItems.d.ts +1 -2
- package/dist/types/excalidraw/components/CommandPalette/types.d.ts +1 -1
- package/dist/types/excalidraw/components/ConvertElementTypePopup.d.ts +2 -2
- package/dist/types/excalidraw/components/CursorHint.d.ts +46 -0
- package/dist/types/excalidraw/components/EyeDropper.d.ts +1 -1
- package/dist/types/excalidraw/components/FileDropOverlay.d.ts +2 -0
- package/dist/types/excalidraw/components/FontPicker/FontPicker.d.ts +4 -1
- package/dist/types/excalidraw/components/FontPicker/FontPickerList.d.ts +6 -1
- package/dist/types/excalidraw/components/FontPicker/fontTopPicksDnD.d.ts +12 -0
- package/dist/types/excalidraw/components/IconButton.d.ts +48 -0
- package/dist/types/excalidraw/components/IconPicker.d.ts +14 -9
- package/dist/types/excalidraw/components/Island.d.ts +7 -0
- package/dist/types/excalidraw/components/LaserPointerButton.d.ts +2 -4
- package/dist/types/excalidraw/components/LayerUI.d.ts +5 -2
- package/dist/types/excalidraw/components/LibraryMenu.d.ts +1 -1
- package/dist/types/excalidraw/components/LibraryMenuSection.d.ts +6 -2
- package/dist/types/excalidraw/components/LibraryUnit.d.ts +7 -2
- package/dist/types/excalidraw/components/LockButton.d.ts +3 -4
- package/dist/types/excalidraw/components/MagicButton.d.ts +0 -2
- package/dist/types/excalidraw/components/MobileMenu.d.ts +4 -4
- package/dist/types/excalidraw/components/MobileToolbar.d.ts +9 -0
- package/dist/types/excalidraw/components/OverwriteConfirm/OverwriteConfirmState.d.ts +1 -1
- package/dist/types/excalidraw/components/PasteChartDialog.d.ts +4 -5
- package/dist/types/excalidraw/components/PenModeButton.d.ts +2 -5
- package/dist/types/excalidraw/components/Popover.d.ts +1 -3
- package/dist/types/excalidraw/components/PropertiesPopover.d.ts +1 -1
- package/dist/types/excalidraw/components/{ButtonIcon.d.ts → RadioButton.d.ts} +2 -5
- package/dist/types/excalidraw/components/Range.d.ts +10 -4
- package/dist/types/excalidraw/components/SVGLayer.d.ts +1 -1
- package/dist/types/excalidraw/components/SearchMenu.d.ts +1 -1
- package/dist/types/excalidraw/components/Sidebar/Sidebar.d.ts +1 -1
- package/dist/types/excalidraw/components/Stats/Angle.d.ts +2 -2
- package/dist/types/excalidraw/components/Stats/Dimension.d.ts +2 -2
- package/dist/types/excalidraw/components/Stats/DragInput.d.ts +2 -2
- package/dist/types/excalidraw/components/Stats/MultiAngle.d.ts +2 -2
- package/dist/types/excalidraw/components/Stats/MultiDimension.d.ts +2 -2
- package/dist/types/excalidraw/components/Stats/MultiPosition.d.ts +2 -2
- package/dist/types/excalidraw/components/Stats/Position.d.ts +3 -3
- package/dist/types/excalidraw/components/Stats/utils.d.ts +1 -1
- package/dist/types/excalidraw/components/TTDDialog/Chat/ChatInterface.d.ts +2 -6
- package/dist/types/excalidraw/components/TTDDialog/Chat/TTDChatPanel.d.ts +2 -1
- package/dist/types/excalidraw/components/TTDDialog/CodeMirrorEditor.d.ts +11 -0
- package/dist/types/excalidraw/components/TTDDialog/TTDContext.d.ts +4 -4
- package/dist/types/excalidraw/components/TTDDialog/TTDDialog.d.ts +11 -7
- package/dist/types/excalidraw/components/TTDDialog/TTDDialogInput.d.ts +3 -3
- package/dist/types/excalidraw/components/TTDDialog/TTDDialogOutput.d.ts +4 -1
- package/dist/types/excalidraw/components/TTDDialog/TTDWelcomeMessage.d.ts +1 -0
- package/dist/types/excalidraw/components/TTDDialog/TextToDiagram.d.ts +2 -1
- package/dist/types/excalidraw/components/TTDDialog/mermaid-lang-lite.d.ts +2 -0
- package/dist/types/excalidraw/components/TTDDialog/types.d.ts +4 -0
- package/dist/types/excalidraw/components/TTDDialog/useTTDChatStorage.d.ts +3 -3
- package/dist/types/excalidraw/components/TTDDialog/utils/mermaidAutoFix.d.ts +1 -0
- package/dist/types/excalidraw/components/TTDDialog/utils/mermaidError.d.ts +10 -0
- package/dist/types/excalidraw/components/Toast.d.ts +8 -4
- package/dist/types/excalidraw/components/ToolPopover.d.ts +3 -6
- package/dist/types/excalidraw/components/Toolbar.d.ts +11 -0
- package/dist/types/excalidraw/components/Tools.d.ts +151 -0
- package/dist/types/excalidraw/components/Tooltip.d.ts +15 -1
- package/dist/types/excalidraw/components/TopPicksDnD/TopPicksContextMenu.d.ts +14 -0
- package/dist/types/excalidraw/components/TopPicksDnD/TopPicksTip.d.ts +11 -0
- package/dist/types/excalidraw/components/TopPicksDnD/topPicksDnD.d.ts +58 -0
- package/dist/types/excalidraw/components/UserList.d.ts +3 -2
- package/dist/types/excalidraw/components/ViewportStatusFrame/ViewportStatusFrame.d.ts +11 -0
- package/dist/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +4 -1
- package/dist/types/excalidraw/components/canvases/NewElementCanvas.d.ts +3 -0
- package/dist/types/excalidraw/components/canvases/StaticCanvas.d.ts +1 -1
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenu.d.ts +30 -16
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuContent.d.ts +3 -2
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItem.d.ts +11 -12
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemCheckbox.d.ts +5 -0
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemContent.d.ts +2 -1
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemContentRadio.d.ts +2 -1
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuSub.d.ts +23 -0
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuSubContent.d.ts +8 -0
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuSubTrigger.d.ts +12 -0
- package/dist/types/excalidraw/components/dropdownMenu/common.d.ts +1 -1
- package/dist/types/excalidraw/components/dropdownMenu/dropdownMenuUtils.d.ts +2 -0
- package/dist/types/excalidraw/components/footer/Footer.d.ts +3 -1
- package/dist/types/excalidraw/components/hyperlink/helpers.d.ts +2 -2
- package/dist/types/excalidraw/components/icons.d.ts +30 -10
- package/dist/types/excalidraw/components/main-menu/DefaultItems.d.ts +26 -3
- package/dist/types/excalidraw/components/main-menu/MainMenu.d.ts +23 -14
- package/dist/types/excalidraw/components/positionElementBesideCursor.d.ts +26 -0
- package/dist/types/excalidraw/components/shapeActionPredicates.d.ts +39 -0
- package/dist/types/excalidraw/data/blob.d.ts +107 -60
- package/dist/types/excalidraw/data/filesystem.d.ts +3 -5
- package/dist/types/excalidraw/data/index.d.ts +6 -7
- package/dist/types/excalidraw/data/json.d.ts +62 -30
- package/dist/types/excalidraw/data/library.d.ts +1 -1
- package/dist/types/excalidraw/data/resave.d.ts +7 -2
- package/dist/types/excalidraw/drawShapeTrail.d.ts +16 -0
- package/dist/types/excalidraw/eraser/index.d.ts +2 -3
- package/dist/types/excalidraw/fonts/Fonts.d.ts +3 -2
- package/dist/types/excalidraw/hooks/useAppStateValue.d.ts +29 -0
- package/dist/types/excalidraw/hooks/useLibraryItemSvg.d.ts +1 -1
- package/dist/types/excalidraw/hooks/useTextEditorFocus.d.ts +5 -5
- package/dist/types/excalidraw/{laser-trails.d.ts → laserTrails.d.ts} +5 -7
- package/dist/types/excalidraw/lasso/index.d.ts +2 -3
- package/dist/types/excalidraw/lasso/utils.d.ts +2 -0
- package/dist/types/excalidraw/renderOverrides.d.ts +9 -0
- package/dist/types/excalidraw/renderer/animation.d.ts +5 -1
- package/dist/types/excalidraw/renderer/helpers.d.ts +25 -0
- package/dist/types/excalidraw/renderer/interactiveScene.d.ts +2 -4
- package/dist/types/excalidraw/scene/Renderer.d.ts +489 -20
- package/dist/types/excalidraw/scene/export.d.ts +3 -3
- package/dist/types/excalidraw/scene/index.d.ts +2 -2
- package/dist/types/excalidraw/scene/types.d.ts +7 -4
- package/dist/types/excalidraw/snapping.d.ts +7 -7
- package/dist/types/excalidraw/textAutoResizeHandle.d.ts +15 -0
- package/dist/types/excalidraw/types.d.ts +619 -42
- package/dist/types/excalidraw/viewport.d.ts +302 -0
- package/dist/types/excalidraw/wysiwyg/textWysiwyg.d.ts +12 -3
- package/dist/types/fractional-indexing/src/index.d.ts +29 -0
- package/dist/types/laser-pointer/src/index.d.ts +2 -0
- package/dist/types/laser-pointer/src/math.d.ts +16 -0
- package/dist/types/laser-pointer/src/simplify.d.ts +2 -0
- package/dist/types/laser-pointer/src/state.d.ts +36 -0
- package/dist/types/math/src/constants.d.ts +0 -1
- package/dist/types/math/src/curve.d.ts +23 -13
- package/dist/types/math/src/index.d.ts +1 -0
- package/dist/types/math/src/pca.d.ts +79 -0
- package/dist/types/math/src/point.d.ts +8 -2
- package/dist/types/math/src/polygon.d.ts +25 -1
- package/dist/types/math/src/segment.d.ts +6 -0
- package/dist/types/math/src/types.d.ts +25 -1
- package/dist/types/utils/src/export.d.ts +4 -3
- package/dist/types/utils/src/index.d.ts +1 -2
- package/dist/types/utils/src/shape.d.ts +2 -2
- package/package.json +4 -3
- package/dist/types/excalidraw/animation-frame-handler.d.ts +0 -16
- package/dist/types/excalidraw/charts.d.ts +0 -27
- package/dist/types/excalidraw/components/DiagramToCodePlugin/DiagramToCodePlugin.d.ts +0 -4
- package/dist/types/excalidraw/components/ExcalidrawLogo.d.ts +0 -15
- package/dist/types/excalidraw/components/FollowMode/FollowMode.d.ts +0 -10
- package/dist/types/excalidraw/components/HandButton.d.ts +0 -10
- package/dist/types/excalidraw/components/InitializeApp.d.ts +0 -10
- package/dist/types/excalidraw/components/MobileToolBar.d.ts +0 -10
- package/dist/types/excalidraw/components/TTDDialog/TTDDialogTrigger.d.ts +0 -8
- package/dist/types/excalidraw/components/TTDDialog/utils/TTDStreamFetch.d.ts +0 -24
- package/dist/types/excalidraw/components/ToolButton.d.ts +0 -49
- package/dist/types/excalidraw/components/footer/FooterCenter.d.ts +0 -8
- package/dist/types/excalidraw/components/live-collaboration/LiveCollaborationTrigger.d.ts +0 -11
- package/dist/types/excalidraw/components/shapes.d.ts +0 -190
- package/dist/types/excalidraw/components/welcome-screen/WelcomeScreen.Center.d.ts +0 -58
- package/dist/types/excalidraw/components/welcome-screen/WelcomeScreen.Hints.d.ts +0 -19
- package/dist/types/excalidraw/components/welcome-screen/WelcomeScreen.d.ts +0 -84
- package/dist/types/excalidraw/cursor.d.ts +0 -5
- package/dist/types/excalidraw/data/reconcile.d.ts +0 -7
- package/dist/types/excalidraw/index.d.ts +0 -46
- package/dist/types/excalidraw/polyfill.d.ts +0 -2
- package/dist/types/excalidraw/scene/scroll.d.ts +0 -18
- package/dist/types/excalidraw/scene/zoom.d.ts +0 -12
- package/dist/types/utils/src/bbox.d.ts +0 -9
- package/dist/types/utils/src/withinBounds.d.ts +0 -19
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type GlobalPoint } from "@excalidraw/math";
|
|
2
2
|
import type { LineSegment, LocalPoint } from "@excalidraw/math";
|
|
3
|
-
import type { AppState } from "@excalidraw/excalidraw/types";
|
|
3
|
+
import type { AppState, NullableGridSize } from "@excalidraw/excalidraw/types";
|
|
4
4
|
import type { Bounds } from "@excalidraw/common";
|
|
5
5
|
import { type Heading } from "./heading";
|
|
6
6
|
import type { Scene } from "./Scene";
|
|
@@ -24,17 +24,20 @@ export type BindingStrategy = {
|
|
|
24
24
|
*
|
|
25
25
|
* IMPORTANT: currently must be > 0 (this also applies to the computed gap)
|
|
26
26
|
*/
|
|
27
|
-
export declare const BASE_BINDING_GAP =
|
|
28
|
-
export declare const
|
|
29
|
-
export declare const
|
|
27
|
+
export declare const BASE_BINDING_GAP = 5;
|
|
28
|
+
export declare const BASE_ARROW_MIN_LENGTH = 10;
|
|
29
|
+
export declare const FOCUS_POINT_SIZE: number;
|
|
30
|
+
export declare const getBindingGap: (bindTarget: Pick<ExcalidrawBindableElement, "strokeWidth">) => number;
|
|
30
31
|
export declare const maxBindingDistance_simple: (zoom?: AppState["zoom"]) => number;
|
|
31
|
-
export declare const
|
|
32
|
-
|
|
32
|
+
export declare const isBindingEnabled: (appState: {
|
|
33
|
+
isBindingEnabled: AppState["isBindingEnabled"];
|
|
34
|
+
}) => boolean;
|
|
33
35
|
export declare const bindOrUnbindBindingElement: (arrow: NonDeleted<ExcalidrawArrowElement>, draggingPoints: PointsPositionUpdates, scenePointerX: number, scenePointerY: number, scene: Scene, appState: AppState, opts?: {
|
|
34
36
|
newArrow?: boolean;
|
|
35
37
|
altKey?: boolean;
|
|
36
38
|
angleLocked?: boolean;
|
|
37
39
|
initialBinding?: boolean;
|
|
40
|
+
gridSize?: NullableGridSize;
|
|
38
41
|
}) => {
|
|
39
42
|
start: BindingStrategy;
|
|
40
43
|
end: BindingStrategy;
|
|
@@ -45,33 +48,42 @@ export declare const getBindingStrategyForDraggingBindingElementEndpoints: (arro
|
|
|
45
48
|
altKey?: boolean;
|
|
46
49
|
finalize?: boolean;
|
|
47
50
|
initialBinding?: boolean;
|
|
48
|
-
|
|
51
|
+
gridSize?: NullableGridSize;
|
|
49
52
|
}) => {
|
|
50
53
|
start: BindingStrategy;
|
|
51
54
|
end: BindingStrategy;
|
|
52
55
|
};
|
|
53
56
|
export declare const bindOrUnbindBindingElements: (selectedArrows: NonDeleted<ExcalidrawArrowElement>[], scene: Scene, appState: AppState) => void;
|
|
54
|
-
export declare const bindBindingElement: (arrow: NonDeleted<ExcalidrawArrowElement>, hoveredElement: ExcalidrawBindableElement
|
|
55
|
-
export declare const unbindBindingElement: (arrow:
|
|
57
|
+
export declare const bindBindingElement: (arrow: NonDeleted<ExcalidrawArrowElement>, hoveredElement: NonDeleted<ExcalidrawBindableElement>, mode: BindMode, startOrEnd: "start" | "end", scene: Scene, zoom: AppState["zoom"], focusPoint?: GlobalPoint, shouldSnapToOutline?: boolean, isMidpointSnappingEnabled?: boolean) => void;
|
|
58
|
+
export declare const unbindBindingElement: (arrow: ExcalidrawArrowElement, startOrEnd: "start" | "end", scene: Scene) => ExcalidrawBindableElement["id"] | null;
|
|
59
|
+
export declare const reanchorBindingsToOutline: (changedElement: NonDeleted<ExcalidrawBindableElement>, scene: Scene, zoom: AppState["zoom"]) => void;
|
|
56
60
|
export declare const updateBoundElements: (changedElement: NonDeletedExcalidrawElement, scene: Scene, options?: {
|
|
57
|
-
|
|
61
|
+
/** see `getSimultaneouslyUpdatedElementIds` for how to pass it */
|
|
62
|
+
simultaneouslyUpdated?: readonly NonDeletedExcalidrawElement[];
|
|
58
63
|
changedElements?: Map<string, ExcalidrawElement>;
|
|
59
64
|
}) => void;
|
|
60
|
-
export declare const updateBindings: (latestElement:
|
|
61
|
-
simultaneouslyUpdated?: readonly
|
|
65
|
+
export declare const updateBindings: (latestElement: NonDeletedExcalidrawElement, scene: Scene, appState: AppState, options?: {
|
|
66
|
+
simultaneouslyUpdated?: readonly NonDeletedExcalidrawElement[];
|
|
62
67
|
newSize?: {
|
|
63
68
|
width: number;
|
|
64
69
|
height: number;
|
|
65
70
|
};
|
|
66
71
|
}) => void;
|
|
72
|
+
/**
|
|
73
|
+
* The id set of `simultaneouslyUpdated`, shared by every `updateBoundElements()`
|
|
74
|
+
* call given the same array. Pass one array instance for all elements of an
|
|
75
|
+
* operation, and don't change its membership after the first lookup, or the
|
|
76
|
+
* cached ids go stale.
|
|
77
|
+
*/
|
|
78
|
+
export declare const getSimultaneouslyUpdatedElementIds: (simultaneouslyUpdated: readonly ExcalidrawElement[] | undefined) => ReadonlySet<ExcalidrawElement["id"]>;
|
|
67
79
|
export declare const getHeadingForElbowArrowSnap: (p: Readonly<GlobalPoint>, otherPoint: Readonly<GlobalPoint>, bindableElement: ExcalidrawBindableElement | undefined | null, aabb: Bounds | undefined | null, origPoint: GlobalPoint, elementsMap: ElementsMap, zoom?: AppState["zoom"]) => Heading;
|
|
68
|
-
export declare const bindPointToSnapToElementOutline: (arrowElement: ExcalidrawArrowElement, bindableElement: ExcalidrawBindableElement, startOrEnd: "start" | "end", elementsMap: ElementsMap, customIntersector?: LineSegment<GlobalPoint
|
|
80
|
+
export declare const bindPointToSnapToElementOutline: (arrowElement: ExcalidrawArrowElement, bindableElement: ExcalidrawBindableElement, startOrEnd: "start" | "end", elementsMap: ElementsMap, zoom: AppState["zoom"], customIntersector?: LineSegment<GlobalPoint>, isMidpointSnappingEnabled?: boolean) => GlobalPoint;
|
|
69
81
|
export declare const avoidRectangularCorner: (arrowElement: ExcalidrawArrowElement, bindTarget: ExcalidrawBindableElement, elementsMap: ElementsMap, p: GlobalPoint) => GlobalPoint;
|
|
70
|
-
export declare const updateBoundPoint: (arrow: NonDeleted<ExcalidrawArrowElement>, startOrEnd: "startBinding" | "endBinding", binding: FixedPointBinding | null | undefined, bindableElement: ExcalidrawBindableElement, elementsMap: ElementsMap,
|
|
71
|
-
export declare const calculateFixedPointForElbowArrowBinding: (linearElement: NonDeleted<ExcalidrawElbowArrowElement>, hoveredElement: ExcalidrawBindableElement, startOrEnd: "start" | "end", elementsMap: ElementsMap) => {
|
|
82
|
+
export declare const updateBoundPoint: (arrow: NonDeleted<ExcalidrawArrowElement>, startOrEnd: "startBinding" | "endBinding", binding: FixedPointBinding | null | undefined, bindableElement: ExcalidrawBindableElement, elementsMap: ElementsMap, dragging?: boolean) => LocalPoint | null;
|
|
83
|
+
export declare const calculateFixedPointForElbowArrowBinding: (linearElement: NonDeleted<ExcalidrawElbowArrowElement>, hoveredElement: ExcalidrawBindableElement, startOrEnd: "start" | "end", elementsMap: ElementsMap, zoom: AppState["zoom"], shouldSnapToOutline?: boolean, isMidpointSnappingEnabled?: boolean) => {
|
|
72
84
|
fixedPoint: FixedPoint;
|
|
73
85
|
};
|
|
74
|
-
export declare const calculateFixedPointForNonElbowArrowBinding: (linearElement: NonDeleted<ExcalidrawArrowElement>, hoveredElement: ExcalidrawBindableElement
|
|
86
|
+
export declare const calculateFixedPointForNonElbowArrowBinding: (linearElement: NonDeleted<ExcalidrawArrowElement>, hoveredElement: NonDeleted<ExcalidrawBindableElement>, startOrEnd: "start" | "end", elementsMap: ElementsMap, focusPoint?: GlobalPoint) => {
|
|
75
87
|
fixedPoint: FixedPoint;
|
|
76
88
|
};
|
|
77
89
|
export declare const fixDuplicatedBindingsAfterDuplication: (duplicatedElements: ExcalidrawElement[], origIdToDuplicateId: Map<ExcalidrawElement["id"], ExcalidrawElement["id"]>, duplicateElementsMap: NonDeletedSceneElementsMap) => void;
|
|
@@ -120,5 +132,13 @@ export declare class BindableElement {
|
|
|
120
132
|
export declare const getGlobalFixedPointForBindableElement: (fixedPointRatio: FixedPoint, element: ExcalidrawBindableElement, elementsMap: ElementsMap) => GlobalPoint;
|
|
121
133
|
export declare const getGlobalFixedPoints: (arrow: ExcalidrawArrowElement, elementsMap: ElementsMap) => [GlobalPoint, GlobalPoint];
|
|
122
134
|
export declare const getArrowLocalFixedPoints: (arrow: ExcalidrawElbowArrowElement, elementsMap: ElementsMap) => LocalPoint[];
|
|
123
|
-
export declare const
|
|
135
|
+
export declare const isFixedPoint: (fixedPoint: any) => fixedPoint is FixedPointBinding["fixedPoint"];
|
|
136
|
+
export declare const normalizeFixedPoint: <T extends FixedPoint>(fixedPoint: T) => FixedPoint;
|
|
124
137
|
export declare const getBindingSideMidPoint: (binding: FixedPointBinding, elementsMap: ElementsMap) => GlobalPoint | LocalPoint | null;
|
|
138
|
+
/**
|
|
139
|
+
* Binds an arrow endpoint to an explicit fixed point on a bindable element,
|
|
140
|
+
* bypassing the "derive the ratio from where the endpoint currently is"
|
|
141
|
+
* strategy used when dragging. Needed when the binding target is placed to fit
|
|
142
|
+
* the arrow rather than the other way round.
|
|
143
|
+
*/
|
|
144
|
+
export declare const bindBindingElementToFixedPoint: (arrow: NonDeleted<ExcalidrawArrowElement>, bindableElement: NonDeleted<ExcalidrawBindableElement>, startOrEnd: "start" | "end", fixedPoint: FixedPoint, scene: Scene) => void;
|
|
@@ -2,7 +2,7 @@ import { type Bounds } from "@excalidraw/common";
|
|
|
2
2
|
import type { Degrees, GlobalPoint, LineSegment, LocalPoint } from "@excalidraw/math";
|
|
3
3
|
import type { AppState } from "@excalidraw/excalidraw/types";
|
|
4
4
|
import type { Drawable, Op } from "roughjs/bin/core";
|
|
5
|
-
import type { Arrowhead, ElementsMap, ElementsMapOrArray, ExcalidrawElement,
|
|
5
|
+
import type { Arrowhead, ElementsMap, ElementsMapOrArray, ExcalidrawElement, ExcalidrawLinearElement, NonDeleted, NonDeletedExcalidrawElement } from "./types";
|
|
6
6
|
export type RectangleBox = {
|
|
7
7
|
x: number;
|
|
8
8
|
y: number;
|
|
@@ -38,24 +38,20 @@ export declare const getRectangleBoxAbsoluteCoords: (boxSceneCoords: RectangleBo
|
|
|
38
38
|
export declare const getDiamondPoints: (element: ExcalidrawElement) => number[];
|
|
39
39
|
export declare const getCubicBezierCurveBound: (p0: GlobalPoint, p1: GlobalPoint, p2: GlobalPoint, p3: GlobalPoint) => Bounds;
|
|
40
40
|
export declare const getMinMaxXYFromCurvePathOps: (ops: Op[], transformXY?: (p: GlobalPoint) => GlobalPoint) => Bounds;
|
|
41
|
-
export declare const getBoundsFromPoints: (points:
|
|
41
|
+
export declare const getBoundsFromPoints: <P extends GlobalPoint | LocalPoint>(points: readonly P[], padding?: number) => Bounds;
|
|
42
42
|
/** @returns number in pixels */
|
|
43
43
|
export declare const getArrowheadSize: (arrowhead: Arrowhead) => number;
|
|
44
44
|
/** @returns number in degrees */
|
|
45
45
|
export declare const getArrowheadAngle: (arrowhead: Arrowhead) => Degrees;
|
|
46
|
-
export declare const getArrowheadPoints: (element: ExcalidrawLinearElement, shape: Drawable[], position: "start" | "end", arrowhead: Arrowhead) => number[] | null;
|
|
46
|
+
export declare const getArrowheadPoints: (element: ExcalidrawLinearElement, shape: Drawable[], position: "start" | "end", arrowhead: Arrowhead, offsetMultiplier?: number) => number[] | null;
|
|
47
47
|
export declare const getElementBounds: (element: ExcalidrawElement, elementsMap: ElementsMap, nonRotated?: boolean) => Bounds;
|
|
48
48
|
export declare const getCommonBounds: (elements: ElementsMapOrArray, elementsMap?: ElementsMap) => Bounds;
|
|
49
|
-
export declare const getDraggedElementsBounds: (elements:
|
|
49
|
+
export declare const getDraggedElementsBounds: (elements: readonly NonDeletedExcalidrawElement[], dragOffset: {
|
|
50
50
|
x: number;
|
|
51
51
|
y: number;
|
|
52
52
|
}) => number[];
|
|
53
53
|
export declare const getResizedElementAbsoluteCoords: (element: ExcalidrawElement, nextWidth: number, nextHeight: number, normalizePoints: boolean) => Bounds;
|
|
54
54
|
export declare const getElementPointsCoords: (element: ExcalidrawLinearElement, points: readonly (readonly [number, number])[]) => Bounds;
|
|
55
|
-
export declare const getClosestElementBounds: (elements: readonly ExcalidrawElement[], from: {
|
|
56
|
-
x: number;
|
|
57
|
-
y: number;
|
|
58
|
-
}) => Bounds;
|
|
59
55
|
export interface BoundingBox {
|
|
60
56
|
minX: number;
|
|
61
57
|
minY: number;
|
|
@@ -77,5 +73,24 @@ export declare const getCenterForBounds: (bounds: Bounds) => GlobalPoint;
|
|
|
77
73
|
*/
|
|
78
74
|
export declare const aabbForElement: (element: Readonly<ExcalidrawElement>, elementsMap: ElementsMap, offset?: [number, number, number, number]) => Bounds;
|
|
79
75
|
export declare const pointInsideBounds: <P extends GlobalPoint | LocalPoint>(p: P, bounds: Bounds) => boolean;
|
|
76
|
+
export declare const pointInsideBoundsInclusive: <P extends GlobalPoint | LocalPoint>(p: P, bounds: Bounds) => boolean;
|
|
80
77
|
export declare const doBoundsIntersect: (bounds1: Bounds | null, bounds2: Bounds | null) => boolean;
|
|
78
|
+
export declare const boundsContainBounds: (outerBounds: Bounds, innerBounds: Bounds) => boolean;
|
|
79
|
+
/**
|
|
80
|
+
* High level helper to get elements overlapping a bounding box.
|
|
81
|
+
* It can be used to get elements overlapping a selection box, for example.
|
|
82
|
+
*
|
|
83
|
+
*/
|
|
84
|
+
export declare const elementsOverlappingBBox: <T extends ExcalidrawElement>({ elements, elementsMap, bounds, type, excludeElementsInFrames, shouldIgnoreElementFromSelection, }: {
|
|
85
|
+
elements: readonly T[];
|
|
86
|
+
elementsMap?: ElementsMap;
|
|
87
|
+
bounds: Bounds | ExcalidrawElement;
|
|
88
|
+
/**
|
|
89
|
+
* - overlap: elements overlapping or inside bounds
|
|
90
|
+
* - contain: elements inside bounds
|
|
91
|
+
**/
|
|
92
|
+
type: "contain" | "overlap";
|
|
93
|
+
excludeElementsInFrames?: boolean;
|
|
94
|
+
shouldIgnoreElementFromSelection?: (element: T) => boolean;
|
|
95
|
+
}) => T[];
|
|
81
96
|
export declare const elementCenterPoint: (element: ExcalidrawElement, elementsMap: ElementsMap, xOffset?: number, yOffset?: number) => GlobalPoint;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import type { GlobalPoint } from "@excalidraw/math";
|
|
2
|
+
import type { ElementsMap, ExcalidrawElement, ExcalidrawLineElement, NonDeletedExcalidrawElement } from "./types";
|
|
3
|
+
export type BucketFillOptions = {
|
|
4
|
+
/**
|
|
5
|
+
* geometric fidelity: vertices closer than this collapse to the same graph
|
|
6
|
+
* node, and a node this close to a stroke splits it (T-junction). Keep
|
|
7
|
+
* SMALL — every merge can relocate a vertex by up to this distance, so
|
|
8
|
+
* this value is the upper bound on how far the filled shape may deviate
|
|
9
|
+
* from the actual strokes.
|
|
10
|
+
*/
|
|
11
|
+
snapEpsilon: number;
|
|
12
|
+
/**
|
|
13
|
+
* connectivity: loose stroke ends within this distance of another stroke
|
|
14
|
+
* are bridged with a connector edge so the region reads as closed. Also
|
|
15
|
+
* used as broad-phase padding around the owner bounds. Unlike
|
|
16
|
+
* `snapEpsilon` this does not affect the shape's fidelity (bridges add
|
|
17
|
+
* edges; they never move existing vertices).
|
|
18
|
+
*/
|
|
19
|
+
gapTolerance: number;
|
|
20
|
+
/** discard faces / polygons smaller than this absolute area */
|
|
21
|
+
minArea: number;
|
|
22
|
+
/** bail out with `too_complex` above this many input segments */
|
|
23
|
+
maxBoundarySegments: number;
|
|
24
|
+
/** cap on the number of generated polygon points */
|
|
25
|
+
maxGeneratedPoints: number;
|
|
26
|
+
/**
|
|
27
|
+
* initial half-extent of the owner-less search box around the click
|
|
28
|
+
* (doubles up to 3 times while the found face touches the box frontier)
|
|
29
|
+
*/
|
|
30
|
+
fallbackSearchRadius: number;
|
|
31
|
+
};
|
|
32
|
+
export declare const DEFAULT_BUCKET_FILL_OPTIONS: BucketFillOptions;
|
|
33
|
+
export type BucketFillFailureReason = "no_owner" | "open_region" | "too_complex" | "too_small" | "invalid_polygon";
|
|
34
|
+
/**
|
|
35
|
+
* Where the generated fill element belongs in the scene order, expressed
|
|
36
|
+
* relative to an existing element so the caller can resolve it against
|
|
37
|
+
* whatever (e.g. deleted-inclusive) array it inserts into.
|
|
38
|
+
*/
|
|
39
|
+
export type BucketFillInsertion = {
|
|
40
|
+
placement: "above" | "below";
|
|
41
|
+
elementId: ExcalidrawElement["id"];
|
|
42
|
+
};
|
|
43
|
+
export type BucketFillGeometryResult = {
|
|
44
|
+
ok: true;
|
|
45
|
+
/**
|
|
46
|
+
* the closed element under the click, or null for fills resolved by
|
|
47
|
+
* the owner-less fallback (regions formed by open lines)
|
|
48
|
+
*/
|
|
49
|
+
ownerId: ExcalidrawElement["id"] | null;
|
|
50
|
+
boundaryElementIds: ExcalidrawElement["id"][];
|
|
51
|
+
/**
|
|
52
|
+
* closed polygon ring in scene coordinates. When the region contains
|
|
53
|
+
* islands, this is a keyhole path: the hole contours are spliced in
|
|
54
|
+
* via zero-width bridges, so it still renders as one polygon with
|
|
55
|
+
* unpainted hole interiors
|
|
56
|
+
*/
|
|
57
|
+
scenePoints: GlobalPoint[];
|
|
58
|
+
insertion: BucketFillInsertion;
|
|
59
|
+
} | {
|
|
60
|
+
ok: false;
|
|
61
|
+
reason: BucketFillFailureReason;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Whether the element visually paints an opaque background fill — i.e. can
|
|
65
|
+
* actually hide outlines beneath it. Element types that never render their
|
|
66
|
+
* `backgroundColor` (text, image, frames), see-through fill styles
|
|
67
|
+
* (hachure/cross-hatch), partial element opacity, and colors with an alpha
|
|
68
|
+
* channel below 1 (`#RRGGBBAA`, `rgba(…)`) all don't count — anything under
|
|
69
|
+
* them shows through.
|
|
70
|
+
*
|
|
71
|
+
* Shared with the app layer's z-order pass so "covers" means the same thing
|
|
72
|
+
* in boundary clipping and in fill insertion.
|
|
73
|
+
*/
|
|
74
|
+
export declare const rendersOpaqueFill: (element: ExcalidrawElement) => boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Whether the element renders as pure paint the bucket tool could have
|
|
77
|
+
* produced: a closed, visible line polygon with a background and no visible
|
|
78
|
+
* stroke. Recognition is by SHAPE, not by a metadata marker — any marker
|
|
79
|
+
* would go stale the moment the user restyles a fill, and a hand-drawn
|
|
80
|
+
* strokeless background polygon is indistinguishable from a generated fill
|
|
81
|
+
* anyway. Such paint never becomes an owner and is what the app layer
|
|
82
|
+
* restyles in place on re-click (see `isRestylableFill`).
|
|
83
|
+
*/
|
|
84
|
+
export declare const isBucketFillCompatible: (element: ExcalidrawElement) => element is ExcalidrawLineElement;
|
|
85
|
+
export declare const computeBucketFillPolygon: (args: {
|
|
86
|
+
point: GlobalPoint;
|
|
87
|
+
elements: readonly NonDeletedExcalidrawElement[];
|
|
88
|
+
elementsMap: ElementsMap;
|
|
89
|
+
options?: Partial<BucketFillOptions>;
|
|
90
|
+
}) => BucketFillGeometryResult;
|
|
91
|
+
/**
|
|
92
|
+
* Whether the element the click landed on is a fill the bucket tool should
|
|
93
|
+
* restyle in place (instead of stacking an identical fill on top), given
|
|
94
|
+
* the computed region.
|
|
95
|
+
*
|
|
96
|
+
* Fill-compatibility is decided by shape (`isBucketFillCompatible`): a fill
|
|
97
|
+
* the user gave a stroke to has been repurposed into an outline and
|
|
98
|
+
* participates as a boundary instead of being restyled.
|
|
99
|
+
*
|
|
100
|
+
* One guard on top: the computed region's net area and bounds must match
|
|
101
|
+
* the element's. Without it, a click inside a shape drawn ON TOP of a
|
|
102
|
+
* filled region would recolor the underlying fill instead of filling that
|
|
103
|
+
* shape; a click on a since-subdivided part of an old fill likewise
|
|
104
|
+
* creates a new (smaller) fill rather than restyling the old one.
|
|
105
|
+
*/
|
|
106
|
+
export declare const isRestylableFill: (args: {
|
|
107
|
+
hitElement: ExcalidrawElement;
|
|
108
|
+
scenePoints: readonly GlobalPoint[];
|
|
109
|
+
elementsMap: ElementsMap;
|
|
110
|
+
}) => boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { GlobalPoint, LineSegment } from "@excalidraw/math";
|
|
2
|
-
import type { FrameNameBounds } from "@excalidraw/excalidraw/types";
|
|
2
|
+
import type { AppState, FrameNameBounds } from "@excalidraw/excalidraw/types";
|
|
3
3
|
import type { ElementsMap, ExcalidrawBindableElement, ExcalidrawElement, NonDeleted, NonDeletedExcalidrawElement, NonDeletedSceneElementsMap, Ordered } from "./types";
|
|
4
4
|
export declare const shouldTestInside: (element: ExcalidrawElement) => boolean;
|
|
5
5
|
export type HitTestArgs = {
|
|
@@ -14,8 +14,12 @@ export declare const hitElementItself: ({ point, element, threshold, elementsMap
|
|
|
14
14
|
export declare const hitElementBoundingBox: (point: GlobalPoint, element: ExcalidrawElement, elementsMap: ElementsMap, tolerance?: number) => boolean;
|
|
15
15
|
export declare const hitElementBoundingBoxOnly: (hitArgs: HitTestArgs, elementsMap: ElementsMap) => boolean;
|
|
16
16
|
export declare const hitElementBoundText: (point: GlobalPoint, element: ExcalidrawElement, elementsMap: ElementsMap) => boolean;
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
/**
|
|
18
|
+
* All elements an arrow endpoint at the point could bind to. Always includes
|
|
19
|
+
* the result of `getHoveredElementForBinding` for the same arguments.
|
|
20
|
+
*/
|
|
21
|
+
export declare const getAllHoveredElementAtPoint: (point: Readonly<GlobalPoint>, elements: readonly Ordered<NonDeletedExcalidrawElement>[], elementsMap: NonDeletedSceneElementsMap, zoom: AppState["zoom"]) => NonDeleted<ExcalidrawBindableElement>[];
|
|
22
|
+
export declare const getHoveredElementForBinding: (point: Readonly<GlobalPoint>, elements: readonly Ordered<NonDeletedExcalidrawElement>[], elementsMap: NonDeletedSceneElementsMap, zoom: AppState["zoom"]) => NonDeleted<ExcalidrawBindableElement> | null;
|
|
19
23
|
/**
|
|
20
24
|
* Intersect a line with an element for binding test
|
|
21
25
|
*
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import type { ElementOrToolType } from "@excalidraw/excalidraw/types";
|
|
2
|
-
export declare const hasBackground: (type: ElementOrToolType) => type is "line" | "rectangle" | "diamond" | "ellipse" | "embeddable" | "iframe" | "freedraw";
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const
|
|
5
|
-
export declare const
|
|
6
|
-
export declare const
|
|
2
|
+
export declare const hasBackground: (type: ElementOrToolType) => type is "line" | "rectangle" | "stickynote" | "diamond" | "ellipse" | "embeddable" | "iframe" | "freedraw" | "autoshape" | "bucketfill";
|
|
3
|
+
export declare const hasFillStyle: (type: ElementOrToolType) => type is "line" | "rectangle" | "diamond" | "ellipse" | "embeddable" | "iframe" | "freedraw" | "autoshape" | "bucketfill";
|
|
4
|
+
export declare const hasStrokeColor: (type: ElementOrToolType) => type is "line" | "arrow" | "text" | "rectangle" | "stickynote" | "diamond" | "ellipse" | "embeddable" | "freedraw" | "autoshape";
|
|
5
|
+
export declare const hasStrokeWidth: (type: ElementOrToolType) => type is "line" | "arrow" | "rectangle" | "diamond" | "ellipse" | "embeddable" | "iframe" | "freedraw" | "autoshape";
|
|
6
|
+
export declare const hasStrokeStyle: (type: ElementOrToolType) => type is "line" | "arrow" | "rectangle" | "diamond" | "ellipse" | "embeddable" | "iframe" | "autoshape";
|
|
7
|
+
export declare const hasRoughness: (type: ElementOrToolType) => type is "line" | "arrow" | "rectangle" | "stickynote" | "diamond" | "ellipse" | "embeddable" | "iframe" | "autoshape";
|
|
8
|
+
export declare const hasFreedrawMode: (type: ElementOrToolType) => type is "freedraw";
|
|
9
|
+
export declare const canChangeRoundness: (type: ElementOrToolType) => type is "line" | "rectangle" | "stickynote" | "diamond" | "embeddable" | "iframe" | "image";
|
|
7
10
|
export declare const toolIsArrow: (type: ElementOrToolType) => type is "arrow";
|
|
8
11
|
export declare const canHaveArrowheads: (type: ElementOrToolType) => type is "arrow";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { App, AppState } from "@excalidraw/excalidraw/types";
|
|
2
|
+
import type { LocalPoint, GlobalPoint } from "@excalidraw/math";
|
|
3
|
+
import type { Bounds } from "@excalidraw/common";
|
|
4
|
+
import type { ExcalidrawArrowElement, ExcalidrawDiamondElement, ExcalidrawElement, ExcalidrawEllipseElement, ExcalidrawFreeDrawElement, ExcalidrawFrameLikeElement, ExcalidrawRectangleElement, ElementsMap, NonDeleted, ExcalidrawLineElement } from "@excalidraw/element/types";
|
|
5
|
+
declare global {
|
|
6
|
+
interface Window {
|
|
7
|
+
LAST_POINTS?: readonly GlobalPoint[];
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
type NonDeletedRecognizedShapeElement = NonDeleted<ExcalidrawRectangleElement | ExcalidrawEllipseElement | ExcalidrawDiamondElement | ExcalidrawArrowElement | ExcalidrawLineElement | ExcalidrawFreeDrawElement>;
|
|
11
|
+
type Shape = NonDeletedRecognizedShapeElement["type"];
|
|
12
|
+
interface ShapeRecognitionResult<P extends LocalPoint | GlobalPoint> {
|
|
13
|
+
type: Shape;
|
|
14
|
+
points: readonly P[];
|
|
15
|
+
boundingBox: Bounds;
|
|
16
|
+
}
|
|
17
|
+
export declare const recognizeShape: <P extends LocalPoint | GlobalPoint>(points: P[], previousElement: ExcalidrawElement | null, zoom?: number) => ShapeRecognitionResult<P>;
|
|
18
|
+
export declare const convertToShape: (points: GlobalPoint[], appState: AppState, elementsMap: ElementsMap, previousElement: ExcalidrawElement | null, frames?: readonly ExcalidrawFrameLikeElement[]) => NonDeletedRecognizedShapeElement | undefined;
|
|
19
|
+
export declare const convertToShapeHandlePointerMoveFromPointerDown: (app: App, pointerCoords: {
|
|
20
|
+
x: number;
|
|
21
|
+
y: number;
|
|
22
|
+
}) => boolean;
|
|
23
|
+
export {};
|
|
@@ -192,7 +192,29 @@ export declare class ElementsDelta implements DeltaContainer<SceneElementsMap> {
|
|
|
192
192
|
private static createGetter;
|
|
193
193
|
private static applyDelta;
|
|
194
194
|
/**
|
|
195
|
-
*
|
|
195
|
+
* Whether an element looks different after the delta — and the layout that
|
|
196
|
+
* followed it — was applied. The input to history's "skip entries with no
|
|
197
|
+
* visible change" loop.
|
|
198
|
+
*
|
|
199
|
+
* Both sides are first reduced to what actually paints:
|
|
200
|
+
* - a missing or deleted element paints nothing;
|
|
201
|
+
* - an empty text element paints nothing either — unless it carries arrow
|
|
202
|
+
* bindings (an arrow may end at it) or sits on an arrow (an empty label
|
|
203
|
+
* still cuts the arrow's gap);
|
|
204
|
+
* so an empty label's deletion or restoration compares as nothing against
|
|
205
|
+
* nothing. Two painting elements are then compared property by property:
|
|
206
|
+
* - `version`, `versionNonce`, `updated`, `created` are metadata, and
|
|
207
|
+
* `index` is covered by the separate z-order check (`reorderElements`);
|
|
208
|
+
* - `boundElements` is compared as `type:id` references with references to
|
|
209
|
+
* empty labels dropped, so adding or removing an empty label's reference
|
|
210
|
+
* is not visible on its own, and binding repair that rebuilt equal
|
|
211
|
+
* objects is not either;
|
|
212
|
+
* - everything else counts. Nested arrays (`points`, binding fixed points)
|
|
213
|
+
* compare by reference, which can only over-report a change — the safe
|
|
214
|
+
* direction, where undo stops one entry early.
|
|
215
|
+
*
|
|
216
|
+
* `previousElements` holds only `idsToCheck` (see `applyTo`); the label
|
|
217
|
+
* lookups it serves are for elements whose labels are in that set.
|
|
196
218
|
*/
|
|
197
219
|
private static checkForVisibleDifference;
|
|
198
220
|
/**
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { AppState } from "@excalidraw/excalidraw/types";
|
|
2
|
-
import type {
|
|
2
|
+
import type { Scene } from "./Scene";
|
|
3
|
+
import type { ElementsMap, NonDeletedExcalidrawElement } from "./types";
|
|
3
4
|
export interface Distribution {
|
|
4
5
|
space: "between";
|
|
5
6
|
axis: "x" | "y";
|
|
6
7
|
}
|
|
7
|
-
export declare const distributeElements: (selectedElements:
|
|
8
|
+
export declare const distributeElements: (selectedElements: NonDeletedExcalidrawElement[], elementsMap: ElementsMap, distribution: Distribution, appState: Readonly<AppState>, scene: Scene) => NonDeletedExcalidrawElement[];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { AppState, NormalizedZoomValue, NullableGridSize, PointerDownState } from "@excalidraw/excalidraw/types";
|
|
2
2
|
import type { NonDeletedExcalidrawElement } from "@excalidraw/element/types";
|
|
3
3
|
import type { Scene } from "./Scene";
|
|
4
|
+
import type { ExcalidrawTextElement } from "./types";
|
|
4
5
|
export declare const dragSelectedElements: (pointerDownState: PointerDownState, _selectedElements: NonDeletedExcalidrawElement[], offset: {
|
|
5
6
|
x: number;
|
|
6
7
|
y: number;
|
|
@@ -9,6 +10,32 @@ export declare const dragSelectedElements: (pointerDownState: PointerDownState,
|
|
|
9
10
|
y: number;
|
|
10
11
|
}, gridSize: NullableGridSize) => void;
|
|
11
12
|
export declare const getDragOffsetXY: (selectedElements: NonDeletedExcalidrawElement[], x: number, y: number) => [number, number];
|
|
13
|
+
/**
|
|
14
|
+
* Sizes a text element as it is dragged out.
|
|
15
|
+
*
|
|
16
|
+
* A dragged text pins one point and grows away from it; `anchorRatio` says
|
|
17
|
+
* where along the box that point sits — 0 for its left edge, 1 for its right,
|
|
18
|
+
* 0.5 for its centre.
|
|
19
|
+
*
|
|
20
|
+
* A free text pins the point the drag started from and takes the ratio from
|
|
21
|
+
* the drag direction, so it can be pulled either way. A text bound to an arrow
|
|
22
|
+
* endpoint instead pins whatever the binding placed it against and takes the
|
|
23
|
+
* ratio from its alignment — which is also what keeps it from growing back
|
|
24
|
+
* over the arrow, since dragging that way makes no progress rather than
|
|
25
|
+
* flipping the box around.
|
|
26
|
+
*/
|
|
27
|
+
export declare const dragNewTextElement: ({ newElement, anchorX, anchorRatio, pointerX, nextY, zoom, scene, informMutation, }: {
|
|
28
|
+
newElement: ExcalidrawTextElement;
|
|
29
|
+
anchorX: number;
|
|
30
|
+
/** 0 = anchored by its left edge, 1 = by its right, 0.5 = by its centre */
|
|
31
|
+
anchorRatio: number;
|
|
32
|
+
pointerX: number;
|
|
33
|
+
/** free text re-tops itself to the drag origin; a bound one must not move */
|
|
34
|
+
nextY?: number;
|
|
35
|
+
zoom: NormalizedZoomValue;
|
|
36
|
+
scene: Scene;
|
|
37
|
+
informMutation?: boolean;
|
|
38
|
+
}) => void;
|
|
12
39
|
export declare const dragNewElement: ({ newElement, elementType, originX, originY, x, y, width, height, shouldMaintainAspectRatio, shouldResizeFromCenter, zoom, scene, widthAspectRatio, originOffset, informMutation, }: {
|
|
13
40
|
newElement: NonDeletedExcalidrawElement;
|
|
14
41
|
elementType: AppState["activeTool"]["type"];
|
|
@@ -1,6 +1,32 @@
|
|
|
1
1
|
import type { Mutable } from "@excalidraw/common/utility-types";
|
|
2
2
|
import type { AppState } from "@excalidraw/excalidraw/types";
|
|
3
|
-
import type { ExcalidrawElement, GroupId } from "./types";
|
|
3
|
+
import type { ExcalidrawElement, GroupId, NonDeletedExcalidrawElement } from "./types";
|
|
4
|
+
/**
|
|
5
|
+
* Lookups supplied to the host's `props.onDuplicate`, covering just the
|
|
6
|
+
* elements taking part in the duplication.
|
|
7
|
+
*/
|
|
8
|
+
export type OnDuplicateData = {
|
|
9
|
+
/** the duplicates, by their id */
|
|
10
|
+
duplicateElements: ReadonlyMap<ExcalidrawElement["id"], ExcalidrawElement>;
|
|
11
|
+
/**
|
|
12
|
+
* The elements the duplicates were made from, by their id.
|
|
13
|
+
*
|
|
14
|
+
* On paste and library insert these are the inserted elements, which aren't
|
|
15
|
+
* part of the scene (though they may share ids with the scene elements they
|
|
16
|
+
* were copied from).
|
|
17
|
+
*/
|
|
18
|
+
originalElements: ReadonlyMap<ExcalidrawElement["id"], ExcalidrawElement>;
|
|
19
|
+
/**
|
|
20
|
+
* id of an original -> id of its duplicate (e.g. to remap element ids you
|
|
21
|
+
* keep in `customData`, which the duplicate copied from its original)
|
|
22
|
+
*/
|
|
23
|
+
origIdToDuplicateId: ReadonlyMap<ExcalidrawElement["id"], ExcalidrawElement["id"]>;
|
|
24
|
+
/**
|
|
25
|
+
* id of a duplicate -> id of its original (e.g. to look up the original in
|
|
26
|
+
* `originalElements` while modifying the duplicate)
|
|
27
|
+
*/
|
|
28
|
+
duplicateIdToOrigId: ReadonlyMap<ExcalidrawElement["id"], ExcalidrawElement["id"]>;
|
|
29
|
+
};
|
|
4
30
|
/**
|
|
5
31
|
* Duplicate an element, often used in the alt-drag operation.
|
|
6
32
|
* Note that this method has gotten a bit complicated since the
|
|
@@ -31,6 +57,7 @@ export declare const duplicateElements: (opts: {
|
|
|
31
57
|
* user interaction.
|
|
32
58
|
*/
|
|
33
59
|
type: "everything";
|
|
60
|
+
preserveFrameChildrenOrder?: boolean;
|
|
34
61
|
} | {
|
|
35
62
|
/**
|
|
36
63
|
* Duplicates specified elements and inserts them back into the array
|
|
@@ -46,10 +73,44 @@ export declare const duplicateElements: (opts: {
|
|
|
46
73
|
selectedGroupIds: AppState["selectedGroupIds"];
|
|
47
74
|
};
|
|
48
75
|
})) => {
|
|
49
|
-
duplicatedElements:
|
|
50
|
-
duplicateElementsMap: Map<string,
|
|
76
|
+
duplicatedElements: NonDeletedExcalidrawElement[];
|
|
77
|
+
duplicateElementsMap: Map<string, NonDeletedExcalidrawElement>;
|
|
78
|
+
origElementsMap: Map<string, ExcalidrawElement>;
|
|
51
79
|
elementsWithDuplicates: ExcalidrawElement[];
|
|
52
80
|
origIdToDuplicateId: Map<string, string>;
|
|
81
|
+
duplicateIdToOrigId: Map<string, string>;
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Folds the elements returned by the host (`props.onDuplicate`) back into the
|
|
85
|
+
* duplicates the editor created, so that everything that follows (frame
|
|
86
|
+
* assignment, bound text redraw, selection, alt-drag handover) can keep
|
|
87
|
+
* working with the editor's own objects, whether the host mutated the
|
|
88
|
+
* duplicates or returned new objects for them.
|
|
89
|
+
*
|
|
90
|
+
* - A returned element with a duplicate's id is shallow-merged into that
|
|
91
|
+
* duplicate, which takes its place in the returned array. Properties the
|
|
92
|
+
* host omits are kept, so that a partial element can't invalidate the
|
|
93
|
+
* duplicate. Safe only because the duplicates are fresh (not in the scene or
|
|
94
|
+
* the store snapshot yet), which is why nothing but the passed duplicates is
|
|
95
|
+
* ever merged into. Since the merge goes around `mutateElement`, what may
|
|
96
|
+
* have been cached for the duplicate by then is invalidated here.
|
|
97
|
+
* - A duplicate missing from the returned array (or returned as deleted) is
|
|
98
|
+
* vetoed. So is the bound text of a vetoed container. What the remaining
|
|
99
|
+
* duplicates reference of the vetoed ones is cleared, as if those were never
|
|
100
|
+
* part of the duplication (see `fixDuplicatedBindingsAfterDuplication`).
|
|
101
|
+
* - Any other returned element is used as is (existing elements must not be
|
|
102
|
+
* mutated, so the host replaces them).
|
|
103
|
+
* - `false` vetoes all the duplicates.
|
|
104
|
+
*
|
|
105
|
+
* @returns next elements, and the duplicates that weren't vetoed
|
|
106
|
+
*/
|
|
107
|
+
export declare const reconcileDuplicatedElements: <TDuplicate extends ExcalidrawElement>(
|
|
108
|
+
/** what the host returned from `props.onDuplicate`, if anything */
|
|
109
|
+
hostElements: readonly ExcalidrawElement[] | void | false,
|
|
110
|
+
/** elements that were passed to the host */
|
|
111
|
+
nextElements: ExcalidrawElement[], duplicatedElements: TDuplicate[]) => {
|
|
112
|
+
elements: ExcalidrawElement[];
|
|
113
|
+
duplicatedElements: TDuplicate[];
|
|
53
114
|
};
|
|
54
115
|
/**
|
|
55
116
|
* Clones ExcalidrawElement data structure. Does not regenerate id, nonce, or
|
|
@@ -13,5 +13,7 @@ export declare const updateElbowArrowPoints: (arrow: Readonly<ExcalidrawElbowArr
|
|
|
13
13
|
endBinding?: FixedPointBinding | null;
|
|
14
14
|
}, options?: {
|
|
15
15
|
isDragging?: boolean;
|
|
16
|
+
isBindingEnabled?: boolean;
|
|
17
|
+
isMidpointSnappingEnabled?: boolean;
|
|
16
18
|
}) => ElementUpdate<ExcalidrawElbowArrowElement>;
|
|
17
19
|
export declare const validateElbowPoints: <P extends GlobalPoint | LocalPoint>(points: readonly P[], tolerance?: number) => boolean;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { ExcalidrawProps } from "@excalidraw/excalidraw/types";
|
|
2
2
|
import type { MarkRequired } from "@excalidraw/common/utility-types";
|
|
3
|
-
import type {
|
|
3
|
+
import type { ExcalidrawIframeLikeElement, IframeData, NonDeletedExcalidrawElement } from "./types";
|
|
4
4
|
type IframeDataWithSandbox = MarkRequired<IframeData, "sandbox">;
|
|
5
5
|
export declare const createSrcDoc: (body: string) => string;
|
|
6
6
|
export declare const getEmbedLink: (link: string | null | undefined) => IframeDataWithSandbox | null;
|
|
7
|
-
export declare const createPlaceholderEmbeddableLabel: (element: ExcalidrawIframeLikeElement) =>
|
|
7
|
+
export declare const createPlaceholderEmbeddableLabel: (element: ExcalidrawIframeLikeElement) => NonDeletedExcalidrawElement;
|
|
8
8
|
export declare const maybeParseEmbedSrc: (str: string) => string;
|
|
9
9
|
export declare const embeddableURLValidator: (url: string | null | undefined, validateEmbeddable: ExcalidrawProps["validateEmbeddable"]) => boolean;
|
|
10
10
|
export {};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { AppState, PendingExcalidrawElements } from "@excalidraw/excalidraw/types";
|
|
2
|
-
import { type
|
|
2
|
+
import { type NonDeleted, type ElementsMap, type ExcalidrawElement, type ExcalidrawFlowchartNodeElement, type NonDeletedExcalidrawElement } from "./types";
|
|
3
3
|
import type { Scene } from "./Scene";
|
|
4
|
-
type LinkDirection = "up" | "right" | "down" | "left";
|
|
5
|
-
export declare const
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
export type LinkDirection = "up" | "right" | "down" | "left";
|
|
5
|
+
export declare const addNewNodes: (startNode: NonDeleted<ExcalidrawFlowchartNodeElement>, appState: AppState, direction: LinkDirection, scene: Scene, numberOfNodes: number, stickyCrossStart?: number | null) => {
|
|
6
|
+
nodes: NonDeletedExcalidrawElement[];
|
|
7
|
+
crossStart: number;
|
|
8
|
+
};
|
|
8
9
|
export declare class FlowChartNavigator {
|
|
9
10
|
isExploring: boolean;
|
|
10
11
|
private sameLevelNodes;
|
|
@@ -13,14 +14,17 @@ export declare class FlowChartNavigator {
|
|
|
13
14
|
private visitedNodes;
|
|
14
15
|
clear(): void;
|
|
15
16
|
exploreByDirection(element: ExcalidrawElement, elementsMap: ElementsMap, direction: LinkDirection): ExcalidrawElement["id"] | null;
|
|
17
|
+
private static getNodeRelatives;
|
|
18
|
+
private static getSuccessors;
|
|
19
|
+
private static getPredecessors;
|
|
16
20
|
}
|
|
17
21
|
export declare class FlowChartCreator {
|
|
18
22
|
isCreatingChart: boolean;
|
|
19
23
|
private numberOfNodes;
|
|
20
24
|
private direction;
|
|
25
|
+
private clusterCrossStart;
|
|
21
26
|
pendingNodes: PendingExcalidrawElements | null;
|
|
22
|
-
createNodes(startNode: ExcalidrawFlowchartNodeElement
|
|
27
|
+
createNodes(startNode: NonDeleted<ExcalidrawFlowchartNodeElement>, appState: AppState, direction: LinkDirection, scene: Scene): void;
|
|
23
28
|
clear(): void;
|
|
24
29
|
}
|
|
25
30
|
export declare const isNodeInFlowchart: (element: ExcalidrawFlowchartNodeElement, elementsMap: ElementsMap) => boolean;
|
|
26
|
-
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ElementsMap, ExcalidrawElement, OrderedExcalidrawElement, SceneElementsMap } from "./types";
|
|
1
|
+
import type { ElementsMap, ExcalidrawElement, Ordered, OrderedExcalidrawElement, SceneElementsMap } from "./types";
|
|
2
2
|
export declare class InvalidFractionalIndexError extends Error {
|
|
3
3
|
code: "ELEMENT_HAS_INVALID_INDEX";
|
|
4
4
|
}
|
|
@@ -48,7 +48,7 @@ export declare const syncMovedIndices: (elements: readonly ExcalidrawElement[],
|
|
|
48
48
|
*
|
|
49
49
|
* WARN: in edge cases it could modify the elements which were not moved, as it's impossible to guess the actually moved elements from the elements array itself.
|
|
50
50
|
*/
|
|
51
|
-
export declare const syncInvalidIndices: (elements: readonly
|
|
51
|
+
export declare const syncInvalidIndices: <T extends ExcalidrawElement>(elements: readonly T[]) => Ordered<T>[];
|
|
52
52
|
/**
|
|
53
53
|
* Synchronizes all invalid fractional indices within the array order by creating new instances of elements with corrected indices.
|
|
54
54
|
*
|