@excalidraw/math 0.18.0-1118751 → 0.18.0-1440f2d

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.
Files changed (127) hide show
  1. package/dist/types/common/src/constants.d.ts +4 -0
  2. package/dist/types/common/src/utils.d.ts +12 -1
  3. package/dist/types/element/src/align.d.ts +4 -1
  4. package/dist/types/element/src/binding.d.ts +70 -0
  5. package/dist/types/element/src/bounds.d.ts +10 -2
  6. package/dist/types/element/src/collision.d.ts +13 -0
  7. package/dist/types/element/src/cropElement.d.ts +36 -4
  8. package/dist/types/element/src/delta.d.ts +7 -1
  9. package/dist/types/element/src/distribute.d.ts +4 -1
  10. package/dist/types/element/src/dragElements.d.ts +8 -3
  11. package/dist/types/element/src/elbowArrow.d.ts +5 -0
  12. package/dist/types/element/src/embeddable.d.ts +2 -1
  13. package/dist/types/element/src/flowchart.d.ts +1 -7
  14. package/dist/types/element/src/frame.d.ts +19 -1
  15. package/dist/types/element/src/groups.d.ts +1 -6
  16. package/dist/types/element/src/image.d.ts +5 -2
  17. package/dist/types/element/src/index.d.ts +2 -0
  18. package/dist/types/element/src/linearElementEditor.d.ts +4 -1
  19. package/dist/types/element/src/listMarker.d.ts +39 -0
  20. package/dist/types/element/src/newElement.d.ts +17 -1
  21. package/dist/types/element/src/renderElement.d.ts +10 -0
  22. package/dist/types/element/src/renderEnvironment.d.ts +66 -0
  23. package/dist/types/element/src/resizeElements.d.ts +15 -5
  24. package/dist/types/element/src/selection.d.ts +1 -7
  25. package/dist/types/element/src/shape.d.ts +2 -0
  26. package/dist/types/element/src/stickyNote.d.ts +8 -0
  27. package/dist/types/element/src/textElement.d.ts +10 -2
  28. package/dist/types/element/src/textMeasurements.d.ts +15 -11
  29. package/dist/types/element/src/textWrapping.d.ts +3 -2
  30. package/dist/types/element/src/transform.d.ts +5 -1
  31. package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +30 -3
  32. package/dist/types/excalidraw/actions/actionBoundText.d.ts +56 -214
  33. package/dist/types/excalidraw/actions/actionCanvas.d.ts +76 -16
  34. package/dist/types/excalidraw/actions/actionClipboard.d.ts +20 -2
  35. package/dist/types/excalidraw/actions/actionCropEditor.d.ts +10 -1
  36. package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +4 -564
  37. package/dist/types/excalidraw/actions/actionDeselect.d.ts +14 -2
  38. package/dist/types/excalidraw/actions/actionElementLink.d.ts +10 -1
  39. package/dist/types/excalidraw/actions/actionElementLock.d.ts +20 -2
  40. package/dist/types/excalidraw/actions/actionExport.d.ts +27 -9
  41. package/dist/types/excalidraw/actions/actionFrame.d.ts +71 -528
  42. package/dist/types/excalidraw/actions/actionGroup.d.ts +22 -4
  43. package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +10 -1
  44. package/dist/types/excalidraw/actions/actionLink.d.ts +10 -1
  45. package/dist/types/excalidraw/actions/actionMenu.d.ts +10 -1
  46. package/dist/types/excalidraw/actions/actionProperties.d.ts +20 -2
  47. package/dist/types/excalidraw/actions/actionSelectAll.d.ts +11 -2
  48. package/dist/types/excalidraw/actions/actionStyles.d.ts +10 -1
  49. package/dist/types/excalidraw/actions/actionToggleArrowBinding.d.ts +10 -1
  50. package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +10 -1
  51. package/dist/types/excalidraw/actions/actionToggleMidpointSnapping.d.ts +10 -1
  52. package/dist/types/excalidraw/actions/actionToggleMinimap.d.ts +201 -0
  53. package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +10 -1
  54. package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +10 -1
  55. package/dist/types/excalidraw/actions/actionToggleShowHints.d.ts +198 -0
  56. package/dist/types/excalidraw/actions/actionToggleStats.d.ts +10 -1
  57. package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +10 -1
  58. package/dist/types/excalidraw/actions/actionToggleWrap.d.ts +12 -0
  59. package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +10 -1
  60. package/dist/types/excalidraw/actions/index.d.ts +3 -0
  61. package/dist/types/excalidraw/actions/shortcuts.d.ts +1 -1
  62. package/dist/types/excalidraw/actions/types.d.ts +1 -1
  63. package/dist/types/excalidraw/appState.d.ts +9 -7
  64. package/dist/types/excalidraw/charts/charts.bar.d.ts +2 -1
  65. package/dist/types/excalidraw/charts/charts.helpers.d.ts +6 -5
  66. package/dist/types/excalidraw/charts/charts.line.d.ts +2 -1
  67. package/dist/types/excalidraw/charts/charts.radar.d.ts +2 -1
  68. package/dist/types/excalidraw/charts/index.d.ts +2 -1
  69. package/dist/types/excalidraw/components/Actions.d.ts +9 -2
  70. package/dist/types/excalidraw/components/App.arrowText.d.ts +5 -39
  71. package/dist/types/excalidraw/components/App.clipboard.d.ts +31 -0
  72. package/dist/types/excalidraw/components/App.d.ts +79 -264
  73. package/dist/types/excalidraw/components/App.duplicate.d.ts +52 -2
  74. package/dist/types/excalidraw/components/App.host.d.ts +102 -0
  75. package/dist/types/excalidraw/components/App.modifiers.d.ts +38 -0
  76. package/dist/types/excalidraw/components/App.pan.d.ts +8 -0
  77. package/dist/types/excalidraw/components/App.selection.d.ts +265 -0
  78. package/dist/types/excalidraw/components/App.selectionTool.d.ts +93 -0
  79. package/dist/types/excalidraw/components/App.text.d.ts +146 -0
  80. package/dist/types/excalidraw/components/App.textTool.d.ts +140 -0
  81. package/dist/types/excalidraw/components/App.viewport.d.ts +64 -4
  82. package/dist/types/excalidraw/components/App.wheel.d.ts +6 -2
  83. package/dist/types/excalidraw/components/App.wrap.d.ts +31 -0
  84. package/dist/types/excalidraw/components/ConvertElementTypePopup.d.ts +2 -1
  85. package/dist/types/excalidraw/components/FileDropOverlay.d.ts +2 -0
  86. package/dist/types/excalidraw/components/LibraryMenuSection.d.ts +6 -2
  87. package/dist/types/excalidraw/components/LibraryUnit.d.ts +7 -2
  88. package/dist/types/excalidraw/components/Minimap/Minimap.d.ts +15 -0
  89. package/dist/types/excalidraw/components/Minimap/MinimapAnnouncementDot.d.ts +10 -0
  90. package/dist/types/excalidraw/components/Minimap/minimap-controller.chunk.d.ts +90 -0
  91. package/dist/types/excalidraw/components/Minimap/minimap-shared.chunk.d.ts +122 -0
  92. package/dist/types/excalidraw/components/Minimap/minimap-worker.chunk.d.ts +12 -0
  93. package/dist/types/excalidraw/components/Stats/utils.d.ts +4 -2
  94. package/dist/types/excalidraw/components/TTDDialog/MermaidToExcalidraw.d.ts +2 -1
  95. package/dist/types/excalidraw/components/TTDDialog/TTDDialogOutput.d.ts +5 -2
  96. package/dist/types/excalidraw/components/TTDDialog/TTDPreviewPanel.d.ts +5 -2
  97. package/dist/types/excalidraw/components/TTDDialog/TextToDiagram.d.ts +2 -1
  98. package/dist/types/excalidraw/components/TTDDialog/common.d.ts +4 -1
  99. package/dist/types/excalidraw/components/TTDDialog/hooks/useTextGeneration.d.ts +3 -2
  100. package/dist/types/excalidraw/components/TTDDialog/types.d.ts +14 -1
  101. package/dist/types/excalidraw/components/TTDDialog/utils/mermaidError.d.ts +16 -0
  102. package/dist/types/excalidraw/components/Tooltip.d.ts +26 -2
  103. package/dist/types/excalidraw/components/TopPicksDnD/topPicksDnD.d.ts +1 -1
  104. package/dist/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +0 -1
  105. package/dist/types/excalidraw/components/footer/Footer.d.ts +3 -1
  106. package/dist/types/excalidraw/components/hyperlink/Hyperlink.d.ts +3 -2
  107. package/dist/types/excalidraw/components/hyperlink/helpers.d.ts +13 -2
  108. package/dist/types/excalidraw/components/icons.d.ts +1 -0
  109. package/dist/types/excalidraw/components/main-menu/DefaultItems.d.ts +2 -0
  110. package/dist/types/excalidraw/data/blob.d.ts +34 -16
  111. package/dist/types/excalidraw/data/index.d.ts +3 -3
  112. package/dist/types/excalidraw/data/json.d.ts +17 -8
  113. package/dist/types/excalidraw/fonts/Fonts.d.ts +9 -6
  114. package/dist/types/excalidraw/history.d.ts +10 -4
  115. package/dist/types/excalidraw/mermaid.d.ts +7 -0
  116. package/dist/types/excalidraw/reactUtils.d.ts +1 -1
  117. package/dist/types/excalidraw/renderer/animation.d.ts +11 -4
  118. package/dist/types/excalidraw/renderer/staticScene.d.ts +11 -6
  119. package/dist/types/excalidraw/scene/Renderer.d.ts +1 -1
  120. package/dist/types/excalidraw/scene/export.d.ts +343 -20
  121. package/dist/types/excalidraw/scene/types.d.ts +23 -1
  122. package/dist/types/excalidraw/types.d.ts +83 -14
  123. package/dist/types/excalidraw/viewport.d.ts +23 -1
  124. package/dist/types/excalidraw/wysiwyg/textWysiwyg.d.ts +12 -1
  125. package/dist/types/utils/src/index.d.ts +3 -1
  126. package/package.json +2 -2
  127. package/dist/types/utils/src/export.d.ts +0 -36
@@ -4,6 +4,8 @@ export { DEFAULT_STICKY_NOTE_BG } from "./colors";
4
4
  export declare const supportsResizeObserver: boolean;
5
5
  export declare const APP_NAME = "Excalidraw";
6
6
  export declare const TEXT_AUTOWRAP_THRESHOLD = 36;
7
+ export declare const TEXT_VIEWPORT_PADDING = 20;
8
+ export declare const TEXT_MAX_WRAP_WIDTH = 800;
7
9
  export declare const DRAGGING_THRESHOLD = 10;
8
10
  export declare const MINIMUM_ARROW_SIZE = 20;
9
11
  export declare const LINE_CONFIRM_THRESHOLD = 8;
@@ -272,6 +274,7 @@ export declare const TOUCH_CTX_MENU_TIMEOUT = 500;
272
274
  export declare const TITLE_TIMEOUT = 10000;
273
275
  export declare const VERSION_TIMEOUT = 30000;
274
276
  export declare const SCROLL_TIMEOUT = 100;
277
+ export declare const ZEN_MODE_TRANSITION_DURATION = 250;
275
278
  export declare const ZOOM_STEP = 0.1;
276
279
  export declare const MIN_ZOOM = 0.1;
277
280
  export declare const MAX_ZOOM = 30;
@@ -373,6 +376,7 @@ export declare const EDITOR_LS_KEYS: {
373
376
  readonly OAI_API_KEY: "excalidraw-oai-api-key";
374
377
  readonly MERMAID_TO_EXCALIDRAW: "mermaid-to-excalidraw";
375
378
  readonly PUBLISH_LIBRARY: "publish-library-data";
379
+ readonly MINIMAP_ANNOUNCEMENT_DISMISSED: "excalidraw-minimap-announcement-dismissed";
376
380
  };
377
381
  /**
378
382
  * not translated as this is used only in public, stateless API as default value
@@ -6,6 +6,12 @@ import type { EVENT } from "./constants";
6
6
  export declare const setDateTimeForTests: (dateTime: string) => void;
7
7
  export declare const getDateTime: () => string;
8
8
  export declare const capitalizeString: (str: string) => string;
9
+ /**
10
+ * Resolves the window owning `target`, so that we keep working when the editor
11
+ * is rendered into another document. Accepts a `Document` as well, in which
12
+ * case its `defaultView` is used. Falls back to the module realm's window.
13
+ */
14
+ export declare const getTargetWindow: (target: Element | EventTarget | Document | null) => (Window & typeof globalThis) | null;
9
15
  export declare const isToolIcon: (target: Element | EventTarget | null) => target is HTMLElement;
10
16
  export declare const isInputLike: (target: Element | EventTarget | null) => target is HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement | HTMLBRElement | HTMLDivElement;
11
17
  export declare const isInteractive: (target: Element | EventTarget | null) => boolean;
@@ -25,7 +31,7 @@ export declare const debounce: <T extends any[]>(fn: (...args: T) => void, timeo
25
31
  flush(): void;
26
32
  cancel(): void;
27
33
  };
28
- export declare const throttleRAF: <T extends any[]>(fn: (...args: T) => void) => {
34
+ export declare const throttleRAF: <T extends any[]>(fn: (...args: T) => void, ownerWindow?: Pick<Window, "requestAnimationFrame" | "cancelAnimationFrame">) => {
29
35
  (...args: T): void;
30
36
  flush(): void;
31
37
  cancel(): void;
@@ -87,6 +93,11 @@ export declare const getGlobalCSSVariable: (name: string) => string;
87
93
  * See https://github.com/excalidraw/excalidraw/pull/1722#discussion_r436340171
88
94
  */
89
95
  export declare const isRTL: (text: string) => boolean;
96
+ /**
97
+ * Checks whether the text has any RTL character, i.e. whether it may be laid
98
+ * out bidirectionally.
99
+ */
100
+ export declare const hasRTLChars: (text: string) => boolean;
90
101
  export declare const tupleToCoors: (xyTuple: readonly [number, number]) => {
91
102
  x: number;
92
103
  y: number;
@@ -1,8 +1,11 @@
1
1
  import type { AppState } from "@excalidraw/excalidraw/types";
2
+ import type { RenderEnvironment } from "./renderEnvironment";
2
3
  import type { Scene } from "./Scene";
3
4
  import type { NonDeletedExcalidrawElement } from "./types";
4
5
  export interface Alignment {
5
6
  position: "start" | "center" | "end";
6
7
  axis: "x" | "y";
7
8
  }
8
- export declare const alignElements: (selectedElements: NonDeletedExcalidrawElement[], alignment: Alignment, scene: Scene, appState: Readonly<AppState>) => NonDeletedExcalidrawElement[];
9
+ export declare const alignElements: (selectedElements: NonDeletedExcalidrawElement[], alignment: Alignment, scene: Scene, appState: Readonly<AppState>,
10
+ /** measures the labels of the bound arrows the alignment moves */
11
+ renderEnvironment?: RenderEnvironment) => NonDeletedExcalidrawElement[];
@@ -3,6 +3,7 @@ import type { LineSegment, LocalPoint } from "@excalidraw/math";
3
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
+ import type { RenderEnvironment } from "./renderEnvironment";
6
7
  import type { Scene } from "./Scene";
7
8
  import type { ElementUpdate } from "./mutateElement";
8
9
  import type { BindMode, ElementsMap, ExcalidrawArrowElement, ExcalidrawBindableElement, ExcalidrawElbowArrowElement, ExcalidrawElement, FixedPoint, FixedPointBinding, NonDeleted, NonDeletedExcalidrawElement, NonDeletedSceneElementsMap, Ordered, PointsPositionUpdates } from "./types";
@@ -55,11 +56,71 @@ export declare const getBindingStrategyForDraggingBindingElementEndpoints: (arro
55
56
  };
56
57
  export declare const bindOrUnbindBindingElements: (selectedArrows: NonDeleted<ExcalidrawArrowElement>[], scene: Scene, appState: AppState) => void;
57
58
  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;
59
+ /**
60
+ * Whether the arrow's end is bound to an element it's beyond the binding area
61
+ * of, i.e. that it couldn't be bound to in the editor (e.g. a participant's
62
+ * header in a sequence diagram, as laid out by mermaid)
63
+ */
64
+ export declare const isEndBoundBeyondBindingArea: (arrow: ExcalidrawArrowElement, startOrEnd: "start" | "end", elementsMap: NonDeletedSceneElementsMap, zoom: AppState["zoom"]) => boolean;
65
+ /**
66
+ * Extends the arrow's bound end along its end segment, by the segment's length
67
+ * (at least MIN_BOUND_END_EXTENSION), to find where it would reach the element
68
+ * it's bound to, off the element by the binding gap. Moving the end there
69
+ * restores bindings given to arrows that just fall short of their elements.
70
+ *
71
+ * @returns where to move the end to, or null if it doesn't reach the element
72
+ */
73
+ export declare const getBoundEndExtension: (arrow: ExcalidrawArrowElement, startOrEnd: "start" | "end", elementsMap: NonDeletedSceneElementsMap) => GlobalPoint | null;
58
74
  export declare const unbindBindingElement: (arrow: ExcalidrawArrowElement, startOrEnd: "start" | "end", scene: Scene) => ExcalidrawBindableElement["id"] | null;
59
75
  export declare const reanchorBindingsToOutline: (changedElement: NonDeleted<ExcalidrawBindableElement>, scene: Scene, zoom: AppState["zoom"]) => void;
76
+ /**
77
+ * Places both bound ends of `arrow` where its bindings put them on the elements
78
+ * in `elementsMap` they're bound to, and rewraps its label along it as placed.
79
+ * Leaves the label's x/y as they were (the editor derives arrow labels' x/y as
80
+ * it renders them), so callers returning the elements as data must store them
81
+ * (see `LinearElementEditor.getBoundTextElementPosition`).
82
+ */
83
+ export declare const updateBoundArrow: (arrow: NonDeleted<ExcalidrawArrowElement>, scene: Scene, elementsMap: ElementsMap,
84
+ /** measures the arrow's label */
85
+ renderEnvironment?: RenderEnvironment,
86
+ /**
87
+ * whether it's placed as what it's bound to moved: an arrow bound to one
88
+ * element at both ends then moves with it whole (its midpoints with its
89
+ * start), rather than only at its ends
90
+ */
91
+ boundElementMoved?: boolean) => void;
92
+ /** Whether `arrow` is bound to an element not in `elementIds`. */
93
+ export declare const isBoundToElementNotIn: (arrow: ExcalidrawArrowElement, elementIds: ReadonlySet<ExcalidrawElement["id"]>) => boolean;
94
+ /**
95
+ * The arrows that move with a frame being moved (with `movedElements`) but are
96
+ * bound to elements that don't (e.g. in other frames). They must neither be
97
+ * unbound, nor be left for what they're bound to to move: move everything
98
+ * else without them, and then them, with `moveFrameArrows()`.
99
+ *
100
+ * @param movedElements all the elements moving, frames included
101
+ */
102
+ export declare const getFrameArrowIdsToReattach: (movedElements: readonly ExcalidrawElement[]) => ReadonlySet<ExcalidrawElement["id"]>;
103
+ /**
104
+ * Moves the arrows (see `getFrameArrowIdsToReattach()`) by `offset` from where
105
+ * they were in `originalElements` (from where they are, without it), and puts
106
+ * their bound ends on what they're bound to: an end bound to a moved element
107
+ * thus follows it, and one bound to an unmoved element stays. Call it once
108
+ * everything else has moved.
109
+ */
110
+ export declare const moveFrameArrows: (arrowIds: ReadonlySet<ExcalidrawElement["id"]>, offset: {
111
+ x: number;
112
+ y: number;
113
+ }, scene: Scene, opts?: {
114
+ originalElements?: ElementsMap;
115
+ /** measures the arrows' labels */
116
+ renderEnvironment?: RenderEnvironment;
117
+ }) => void;
60
118
  export declare const updateBoundElements: (changedElement: NonDeletedExcalidrawElement, scene: Scene, options?: {
119
+ /** see `getSimultaneouslyUpdatedElementIds` for how to pass it */
61
120
  simultaneouslyUpdated?: readonly NonDeletedExcalidrawElement[];
62
121
  changedElements?: Map<string, ExcalidrawElement>;
122
+ /** measures the labels of the arrows it updates (the host's, in the editor) */
123
+ renderEnvironment?: RenderEnvironment;
63
124
  }) => void;
64
125
  export declare const updateBindings: (latestElement: NonDeletedExcalidrawElement, scene: Scene, appState: AppState, options?: {
65
126
  simultaneouslyUpdated?: readonly NonDeletedExcalidrawElement[];
@@ -67,7 +128,16 @@ export declare const updateBindings: (latestElement: NonDeletedExcalidrawElement
67
128
  width: number;
68
129
  height: number;
69
130
  };
131
+ /** measures the labels of the bound arrows it updates */
132
+ renderEnvironment?: RenderEnvironment;
70
133
  }) => void;
134
+ /**
135
+ * The id set of `simultaneouslyUpdated`, shared by every `updateBoundElements()`
136
+ * call given the same array. Pass one array instance for all elements of an
137
+ * operation, and don't change its membership after the first lookup, or the
138
+ * cached ids go stale.
139
+ */
140
+ export declare const getSimultaneouslyUpdatedElementIds: (simultaneouslyUpdated: readonly ExcalidrawElement[] | undefined) => ReadonlySet<ExcalidrawElement["id"]>;
71
141
  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;
72
142
  export declare const bindPointToSnapToElementOutline: (arrowElement: ExcalidrawArrowElement, bindableElement: ExcalidrawBindableElement, startOrEnd: "start" | "end", elementsMap: ElementsMap, zoom: AppState["zoom"], customIntersector?: LineSegment<GlobalPoint>, isMidpointSnappingEnabled?: boolean) => GlobalPoint;
73
143
  export declare const avoidRectangularCorner: (arrowElement: ExcalidrawArrowElement, bindTarget: ExcalidrawBindableElement, elementsMap: ElementsMap, p: GlobalPoint) => GlobalPoint;
@@ -39,10 +39,16 @@ 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
41
  export declare const getBoundsFromPoints: <P extends GlobalPoint | LocalPoint>(points: readonly P[], padding?: number) => Bounds;
42
+ export declare const CARDINALITY_ONE_OR_MANY_BAR_OFFSET = -0.25;
43
+ export declare const CARDINALITY_INNER_BAR_OFFSET = -0.5;
44
+ export declare const CARDINALITY_ZERO_CIRCLE_OFFSET = 1.5;
45
+ export declare const CARDINALITY_ZERO_CIRCLE_SCALE = 0.8;
42
46
  /** @returns number in pixels */
43
47
  export declare const getArrowheadSize: (arrowhead: Arrowhead) => number;
44
48
  /** @returns number in degrees */
45
- export declare const getArrowheadAngle: (arrowhead: Arrowhead) => Degrees;
49
+ export declare const getArrowheadAngle: (arrowhead: Arrowhead,
50
+ /** size the arrowhead is drawn at, if scaled down */
51
+ size?: number) => Degrees;
46
52
  export declare const getArrowheadPoints: (element: ExcalidrawLinearElement, shape: Drawable[], position: "start" | "end", arrowhead: Arrowhead, offsetMultiplier?: number) => number[] | null;
47
53
  export declare const getElementBounds: (element: ExcalidrawElement, elementsMap: ElementsMap, nonRotated?: boolean) => Bounds;
48
54
  export declare const getCommonBounds: (elements: ElementsMapOrArray, elementsMap?: ElementsMap) => Bounds;
@@ -81,7 +87,7 @@ export declare const boundsContainBounds: (outerBounds: Bounds, innerBounds: Bou
81
87
  * It can be used to get elements overlapping a selection box, for example.
82
88
  *
83
89
  */
84
- export declare const elementsOverlappingBBox: <T extends ExcalidrawElement>({ elements, elementsMap, bounds, type, excludeElementsInFrames, shouldIgnoreElementFromSelection, }: {
90
+ export declare const elementsOverlappingBBox: <T extends ExcalidrawElement>({ elements, elementsMap, bounds, type, excludeElementsInFrames, shouldIgnoreElementFromSelection, includeStroke, }: {
85
91
  elements: readonly T[];
86
92
  elementsMap?: ElementsMap;
87
93
  bounds: Bounds | ExcalidrawElement;
@@ -92,5 +98,7 @@ export declare const elementsOverlappingBBox: <T extends ExcalidrawElement>({ el
92
98
  type: "contain" | "overlap";
93
99
  excludeElementsInFrames?: boolean;
94
100
  shouldIgnoreElementFromSelection?: (element: T) => boolean;
101
+ /** whether elements extend by their stroke, as they render */
102
+ includeStroke?: boolean;
95
103
  }) => T[];
96
104
  export declare const elementCenterPoint: (element: ExcalidrawElement, elementsMap: ElementsMap, xOffset?: number, yOffset?: number) => GlobalPoint;
@@ -14,6 +14,19 @@ 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
+ * Whether an arrow endpoint at the point could bind to the element: inside it,
19
+ * or within binding distance of its outline. Unlike `getBindingCandidates`,
20
+ * it ignores frame clipping, as frames may not be sized yet (e.g. while
21
+ * converting skeletons, where frames are sized around their children last)
22
+ */
23
+ export declare const isPointInBindingArea: (point: GlobalPoint, element: NonDeleted<ExcalidrawBindableElement>, elementsMap: ElementsMap, zoom: AppState["zoom"]) => boolean;
24
+ /**
25
+ * Whether the element hides what is behind it from binding — an arrow's or a
26
+ * text label's. Images count as opaque, and frames once they support a
27
+ * background.
28
+ */
29
+ export declare const isOpaqueForBinding: (element: ExcalidrawElement) => boolean;
17
30
  /**
18
31
  * All elements an arrow endpoint at the point could bind to. Always includes
19
32
  * the result of `getHoveredElementForBinding` for the same arguments.
@@ -1,13 +1,45 @@
1
- import type { TransformHandleType } from "./transformHandles";
2
- import type { ElementsMap, ExcalidrawImageElement, ImageCrop } from "./types";
1
+ import type { TransformHandleDirection } from "./transformHandles";
2
+ import type { ElementsMap, ExcalidrawImageElement } from "./types";
3
3
  export declare const MINIMAL_CROP_SIZE = 10;
4
- export declare const cropElement: (element: ExcalidrawImageElement, elementsMap: ElementsMap, transformHandle: TransformHandleType, naturalWidth: number, naturalHeight: number, pointerX: number, pointerY: number, widthAspectRatio?: number) => {
4
+ /**
5
+ * Crops the image (as it was at the drag's start) as resizing it would
6
+ * resize it, as far as the image reaches.
7
+ */
8
+ export declare const cropElement: (element: ExcalidrawImageElement, elementsMap: ElementsMap, transformHandle: TransformHandleDirection, naturalWidth: number, naturalHeight: number, pointerX: number, pointerY: number, { shouldMaintainAspectRatio, shouldResizeFromCenter, }?: {
9
+ shouldMaintainAspectRatio?: boolean;
10
+ shouldResizeFromCenter?: boolean;
11
+ }) => {
5
12
  x: number;
6
13
  y: number;
7
14
  width: number;
8
15
  height: number;
9
- crop: ImageCrop | null;
16
+ crop: {
17
+ x: number;
18
+ y: number;
19
+ width: number;
20
+ height: number;
21
+ naturalWidth: number;
22
+ naturalHeight: number;
23
+ } | null;
10
24
  };
25
+ /**
26
+ * Uncrops the image on the handle's side (a corner's two); mirrored, on the
27
+ * opposite side(s) too.
28
+ */
29
+ export declare const uncropElementSides: (element: ExcalidrawImageElement, elementsMap: ElementsMap, handle: TransformHandleDirection, mirrored?: boolean) => {
30
+ x: number;
31
+ y: number;
32
+ width: number;
33
+ height: number;
34
+ crop: {
35
+ x: number;
36
+ y: number;
37
+ width: number;
38
+ height: number;
39
+ naturalWidth: number;
40
+ naturalHeight: number;
41
+ } | null;
42
+ } | null;
11
43
  export declare const getUncroppedImageElement: (element: ExcalidrawImageElement, elementsMap: ElementsMap) => ExcalidrawImageElement;
12
44
  export declare const getUncroppedWidthAndHeight: (element: ExcalidrawImageElement) => {
13
45
  width: number;
@@ -2,6 +2,7 @@ import type { ExcalidrawElement, Ordered, OrderedExcalidrawElement, SceneElement
2
2
  import type { DTO, ValueOf } from "@excalidraw/common/utility-types";
3
3
  import type { AppState, ObservedAppState } from "@excalidraw/excalidraw/types";
4
4
  import { StoreSnapshot } from "./store";
5
+ import type { RenderEnvironment } from "./renderEnvironment";
5
6
  /**
6
7
  * Represents the difference between two objects of the same type.
7
8
  *
@@ -146,6 +147,11 @@ export declare class AppStateDelta implements DeltaContainer<AppState> {
146
147
  type ElementPartial<TElement extends ExcalidrawElement = ExcalidrawElement> = Omit<Partial<Ordered<TElement>>, "id" | "updated" | "seed">;
147
148
  export type ApplyToOptions = {
148
149
  excludedProperties?: Set<keyof ElementPartial>;
150
+ /**
151
+ * measures the labels re-laid out after applying (bound texts, and the
152
+ * labels of bound arrows) -- the editor passes the host's
153
+ */
154
+ renderEnvironment?: RenderEnvironment;
149
155
  };
150
156
  /**
151
157
  * Elements change is a low level primitive to capture a change between two sets of elements.
@@ -236,7 +242,7 @@ export declare class ElementsDelta implements DeltaContainer<SceneElementsMap> {
236
242
  * should be rebound (if possible) with the current element ~ bindings should be bidirectional.
237
243
  */
238
244
  private static rebindAffected;
239
- static redrawElements(nextElements: SceneElementsMap, changedElements: Map<string, OrderedExcalidrawElement>): SceneElementsMap;
245
+ static redrawElements(nextElements: SceneElementsMap, changedElements: Map<string, OrderedExcalidrawElement>, renderEnvironment?: RenderEnvironment): SceneElementsMap;
240
246
  private static redrawTextBoundingBoxes;
241
247
  private static redrawBoundArrows;
242
248
  private static reorderElements;
@@ -1,8 +1,11 @@
1
1
  import type { AppState } from "@excalidraw/excalidraw/types";
2
+ import type { RenderEnvironment } from "./renderEnvironment";
2
3
  import type { Scene } from "./Scene";
3
4
  import type { ElementsMap, NonDeletedExcalidrawElement } from "./types";
4
5
  export interface Distribution {
5
6
  space: "between";
6
7
  axis: "x" | "y";
7
8
  }
8
- export declare const distributeElements: (selectedElements: NonDeletedExcalidrawElement[], elementsMap: ElementsMap, distribution: Distribution, appState: Readonly<AppState>, scene: Scene) => NonDeletedExcalidrawElement[];
9
+ export declare const distributeElements: (selectedElements: NonDeletedExcalidrawElement[], elementsMap: ElementsMap, distribution: Distribution, appState: Readonly<AppState>, scene: Scene,
10
+ /** measures the labels of the bound arrows the distribution moves */
11
+ renderEnvironment?: RenderEnvironment) => NonDeletedExcalidrawElement[];
@@ -1,5 +1,6 @@
1
1
  import type { AppState, NormalizedZoomValue, NullableGridSize, PointerDownState } from "@excalidraw/excalidraw/types";
2
2
  import type { NonDeletedExcalidrawElement } from "@excalidraw/element/types";
3
+ import type { RenderEnvironment } from "./renderEnvironment";
3
4
  import type { Scene } from "./Scene";
4
5
  import type { ExcalidrawTextElement } from "./types";
5
6
  export declare const dragSelectedElements: (pointerDownState: PointerDownState, _selectedElements: NonDeletedExcalidrawElement[], offset: {
@@ -8,7 +9,9 @@ export declare const dragSelectedElements: (pointerDownState: PointerDownState,
8
9
  }, scene: Scene, snapOffset: {
9
10
  x: number;
10
11
  y: number;
11
- }, gridSize: NullableGridSize) => void;
12
+ }, gridSize: NullableGridSize,
13
+ /** measures the labels of the bound arrows the drag moves */
14
+ renderEnvironment?: RenderEnvironment) => void;
12
15
  export declare const getDragOffsetXY: (selectedElements: NonDeletedExcalidrawElement[], x: number, y: number) => [number, number];
13
16
  /**
14
17
  * Sizes a text element as it is dragged out.
@@ -24,7 +27,7 @@ export declare const getDragOffsetXY: (selectedElements: NonDeletedExcalidrawEle
24
27
  * over the arrow, since dragging that way makes no progress rather than
25
28
  * flipping the box around.
26
29
  */
27
- export declare const dragNewTextElement: ({ newElement, anchorX, anchorRatio, pointerX, nextY, zoom, scene, informMutation, }: {
30
+ export declare const dragNewTextElement: ({ newElement, anchorX, anchorRatio, pointerX, nextY, zoom, scene, renderEnvironment, informMutation, }: {
28
31
  newElement: ExcalidrawTextElement;
29
32
  anchorX: number;
30
33
  /** 0 = anchored by its left edge, 1 = by its right, 0.5 = by its centre */
@@ -34,9 +37,10 @@ export declare const dragNewTextElement: ({ newElement, anchorX, anchorRatio, po
34
37
  nextY?: number;
35
38
  zoom: NormalizedZoomValue;
36
39
  scene: Scene;
40
+ renderEnvironment?: RenderEnvironment;
37
41
  informMutation?: boolean;
38
42
  }) => void;
39
- export declare const dragNewElement: ({ newElement, elementType, originX, originY, x, y, width, height, shouldMaintainAspectRatio, shouldResizeFromCenter, zoom, scene, widthAspectRatio, originOffset, informMutation, }: {
43
+ export declare const dragNewElement: ({ newElement, elementType, originX, originY, x, y, width, height, shouldMaintainAspectRatio, shouldResizeFromCenter, zoom, scene, renderEnvironment, widthAspectRatio, originOffset, informMutation, }: {
40
44
  newElement: NonDeletedExcalidrawElement;
41
45
  elementType: AppState["activeTool"]["type"];
42
46
  originX: number;
@@ -49,6 +53,7 @@ export declare const dragNewElement: ({ newElement, elementType, originX, origin
49
53
  shouldResizeFromCenter: boolean;
50
54
  zoom: NormalizedZoomValue;
51
55
  scene: Scene;
56
+ renderEnvironment?: RenderEnvironment;
52
57
  /** whether to keep given aspect ratio when `isResizeWithSidesSameLength` is
53
58
  true */
54
59
  widthAspectRatio?: number | null;
@@ -16,4 +16,9 @@ export declare const updateElbowArrowPoints: (arrow: Readonly<ExcalidrawElbowArr
16
16
  isBindingEnabled?: boolean;
17
17
  isMidpointSnappingEnabled?: boolean;
18
18
  }) => ElementUpdate<ExcalidrawElbowArrowElement>;
19
+ /**
20
+ * The update routing an elbow arrow again where it is, e.g. once its
21
+ * arrowheads change, as its route makes room for them
22
+ */
23
+ export declare const updateElbowArrowRoute: <T extends ExcalidrawElbowArrowElement>(arrow: Readonly<T>, elementsMap: NonDeletedSceneElementsMap) => ElementUpdate<T>;
19
24
  export declare const validateElbowPoints: <P extends GlobalPoint | LocalPoint>(points: readonly P[], tolerance?: number) => boolean;
@@ -1,10 +1,11 @@
1
1
  import type { ExcalidrawProps } from "@excalidraw/excalidraw/types";
2
2
  import type { MarkRequired } from "@excalidraw/common/utility-types";
3
+ import type { RenderEnvironment } from "./renderEnvironment";
3
4
  import type { ExcalidrawIframeLikeElement, IframeData, NonDeletedExcalidrawElement } from "./types";
4
5
  type IframeDataWithSandbox = MarkRequired<IframeData, "sandbox">;
5
6
  export declare const createSrcDoc: (body: string) => string;
6
7
  export declare const getEmbedLink: (link: string | null | undefined) => IframeDataWithSandbox | null;
7
- export declare const createPlaceholderEmbeddableLabel: (element: ExcalidrawIframeLikeElement) => NonDeletedExcalidrawElement;
8
+ export declare const createPlaceholderEmbeddableLabel: (element: ExcalidrawIframeLikeElement, renderEnvironment?: RenderEnvironment) => NonDeletedExcalidrawElement;
8
9
  export declare const maybeParseEmbedSrc: (str: string) => string;
9
10
  export declare const embeddableURLValidator: (url: string | null | undefined, validateEmbeddable: ExcalidrawProps["validateEmbeddable"]) => boolean;
10
11
  export {};
@@ -8,15 +8,9 @@ export declare const addNewNodes: (startNode: NonDeleted<ExcalidrawFlowchartNode
8
8
  };
9
9
  export declare class FlowChartNavigator {
10
10
  isExploring: boolean;
11
- private sameLevelNodes;
12
- private sameLevelIndex;
13
- private direction;
14
- private visitedNodes;
15
11
  clear(): void;
16
12
  exploreByDirection(element: ExcalidrawElement, elementsMap: ElementsMap, direction: LinkDirection): ExcalidrawElement["id"] | null;
17
- private static getNodeRelatives;
18
- private static getSuccessors;
19
- private static getPredecessors;
13
+ private static findNodeInDirection;
20
14
  }
21
15
  export declare class FlowChartCreator {
22
16
  isCreatingChart: boolean;
@@ -1,7 +1,7 @@
1
1
  import type { AppClassProperties, AppState, StaticCanvasAppState } from "@excalidraw/excalidraw/types";
2
2
  import type { ReadonlySetLike } from "@excalidraw/common/utility-types";
3
3
  import type { ExcalidrawElementsIncludingDeleted } from "./Scene";
4
- import type { ElementsMap, ElementsMapOrArray, ExcalidrawElement, ExcalidrawFrameLikeElement, NonDeleted, NonDeletedExcalidrawElement } from "./types";
4
+ import type { ElementsMap, ElementsMapOrArray, ExcalidrawArrowElement, ExcalidrawElement, ExcalidrawFrameLikeElement, NonDeleted, NonDeletedExcalidrawElement } from "./types";
5
5
  export declare const bindElementsToFramesAfterDuplication: (nextElements: readonly ExcalidrawElement[], origElements: readonly ExcalidrawElement[], origIdToDuplicateId: Map<ExcalidrawElement["id"], ExcalidrawElement["id"]>) => void;
6
6
  export declare function isElementIntersectingFrame(element: ExcalidrawElement, frame: ExcalidrawFrameLikeElement, elementsMap: ElementsMap): boolean;
7
7
  export declare const getElementsCompletelyInFrame: (elements: readonly ExcalidrawElement[], frame: ExcalidrawFrameLikeElement, elementsMap: ElementsMap) => ExcalidrawElement[];
@@ -34,6 +34,12 @@ export declare const getElementsInResizingFrame: (allElements: ExcalidrawElement
34
34
  export declare const getElementsInNewFrame: (elements: ExcalidrawElementsIncludingDeleted, frame: ExcalidrawFrameLikeElement, elementsMap: ElementsMap) => (import("./types").ExcalidrawLinearElement | import("./types").ExcalidrawSelectionElement | import("./types").ExcalidrawRectangleElement | import("./types").ExcalidrawStickyNoteElement | import("./types").ExcalidrawDiamondElement | import("./types").ExcalidrawEllipseElement | import("./types").ExcalidrawEmbeddableElement | import("./types").ExcalidrawIframeElement | import("./types").ExcalidrawImageElement | import("./types").ExcalidrawFrameElement | import("./types").ExcalidrawMagicFrameElement | import("./types").ExcalidrawTextElement | import("./types").ExcalidrawFreeDrawElement)[];
35
35
  export declare const omitPartialGroups: (elements: ExcalidrawElement[], frame: ExcalidrawFrameLikeElement, allElementsMap: ElementsMap) => (import("./types").ExcalidrawLinearElement | import("./types").ExcalidrawSelectionElement | import("./types").ExcalidrawRectangleElement | import("./types").ExcalidrawStickyNoteElement | import("./types").ExcalidrawDiamondElement | import("./types").ExcalidrawEllipseElement | import("./types").ExcalidrawEmbeddableElement | import("./types").ExcalidrawIframeElement | import("./types").ExcalidrawImageElement | import("./types").ExcalidrawFrameElement | import("./types").ExcalidrawMagicFrameElement | import("./types").ExcalidrawTextElement | import("./types").ExcalidrawFreeDrawElement)[];
36
36
  export declare const getContainingFrame: (element: ExcalidrawElement, elementsMap: ElementsMap) => ExcalidrawFrameLikeElement | null;
37
+ /**
38
+ * Whether frames clip the element to their bounds (as their child, or when
39
+ * dragged into them). Arrows (with their labels) aren't, so that they can
40
+ * connect elements across and out of frames.
41
+ */
42
+ export declare const isFrameClippable: (element: ExcalidrawElement, elementsMap: ElementsMap) => boolean;
37
43
  /** */
38
44
  export declare const filterElementsEligibleAsFrameChildren: (elements: readonly ExcalidrawElement[], frame: ExcalidrawFrameLikeElement) => ExcalidrawElement[];
39
45
  export declare const getCommonFrameId: (elements: readonly ExcalidrawElement[]) => string | null;
@@ -46,6 +52,18 @@ export declare const getFrameChildrenInsertionIndex: (elements: readonly Excalid
46
52
  */
47
53
  export declare const addElementsToFrame: <T extends ElementsMapOrArray>(allElements: T, elementsToAdd: ExcalidrawElement[], frame: ExcalidrawFrameLikeElement) => T;
48
54
  export declare const removeElementsFromFrame: (elementsToRemove: ReadonlySetLike<ExcalidrawElement>, elementsMap: ElementsMap) => void;
55
+ /**
56
+ * Whether one of the arrow's ends is in the frame: bound to an element in it,
57
+ * or, unbound, inside it. An arrow belongs to a frame only while one is.
58
+ */
59
+ export declare const isArrowEndInFrame: (arrow: ExcalidrawArrowElement, frame: ExcalidrawFrameLikeElement, elementsMap: ElementsMap) => boolean;
60
+ /**
61
+ * Takes the arrows among `elements`, and those bound to them, that have no end
62
+ * in their frame (see `isArrowEndInFrame()`) out of it. Call it once their ends
63
+ * (and the elements they're bound to) may have left it. Arrows in groups are
64
+ * left to their group.
65
+ */
66
+ export declare const removeArrowsWithoutEndInFrame: (elements: Iterable<ExcalidrawElement>, elementsMap: ElementsMap) => void;
49
67
  export declare const removeAllElementsFromFrame: <T extends ExcalidrawElement>(allElements: readonly T[], frame: ExcalidrawFrameLikeElement) => readonly T[];
50
68
  export declare const replaceAllElementsInFrame: <T extends ExcalidrawElement>(allElements: readonly T[], nextElementsInFrame: ExcalidrawElement[], frame: ExcalidrawFrameLikeElement) => T[];
51
69
  /** does not mutate elements, but returns new ones */
@@ -1,11 +1,6 @@
1
- import type { AppClassProperties, AppState, InteractiveCanvasAppState } from "@excalidraw/excalidraw/types";
2
- import type { Mutable } from "@excalidraw/common/utility-types";
1
+ import type { AppState, InteractiveCanvasAppState } from "@excalidraw/excalidraw/types";
3
2
  import type { GroupId, ExcalidrawElement, NonDeleted, ElementsMapOrArray, ElementsMap, NonDeletedExcalidrawElement, NonDeletedElementsMapOrArray } from "./types";
4
3
  export declare const selectGroup: (groupId: GroupId, appState: InteractiveCanvasAppState, elements: readonly NonDeletedExcalidrawElement[]) => Pick<InteractiveCanvasAppState, "selectedGroupIds" | "selectedElementIds" | "editingGroupId">;
5
- export declare const selectGroupsForSelectedElements: {
6
- (appState: Pick<AppState, "selectedElementIds" | "editingGroupId">, elements: readonly NonDeletedExcalidrawElement[], prevAppState: InteractiveCanvasAppState, app: AppClassProperties | null): Mutable<Pick<InteractiveCanvasAppState, "selectedGroupIds" | "editingGroupId" | "selectedElementIds">>;
7
- clearCache(): void;
8
- };
9
4
  /**
10
5
  * If the element's group is selected, don't render an individual
11
6
  * selection border around it.
@@ -1,12 +1,15 @@
1
1
  import type { AppClassProperties, DataURL, BinaryFiles } from "@excalidraw/excalidraw/types";
2
2
  import type { ExcalidrawElement, FileId, InitializedExcalidrawImageElement } from "./types";
3
- export declare const loadHTMLImageElement: (dataURL: DataURL) => Promise<HTMLImageElement>;
3
+ export declare const loadHTMLImageElement: (dataURL: DataURL, createImage?: () => HTMLImageElement) => 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. */
6
- export declare const updateImageCache: ({ fileIds, files, imageCache, }: {
6
+ export declare const updateImageCache: ({ fileIds, files, imageCache, createImage, }: {
7
7
  fileIds: FileId[];
8
8
  files: BinaryFiles;
9
9
  imageCache: AppClassProperties["imageCache"];
10
+ /** creates images in the owner window so cross-document scenes keep
11
+ * runtime ownership of their HTMLImageElements */
12
+ createImage?: () => HTMLImageElement;
10
13
  }) => Promise<{
11
14
  imageCache: Map<FileId, {
12
15
  image: HTMLImageElement | Promise<HTMLImageElement>;
@@ -36,10 +36,12 @@ export * from "./groups";
36
36
  export * from "./heading";
37
37
  export * from "./image";
38
38
  export * from "./linearElementEditor";
39
+ export * from "./listMarker";
39
40
  export * from "./mutateElement";
40
41
  export * from "./newElement";
41
42
  export * from "./positionElementsOnGrid";
42
43
  export * from "./renderElement";
44
+ export * from "./renderEnvironment";
43
45
  export * from "./resizeElements";
44
46
  export * from "./resizeTest";
45
47
  export * from "./Scene";
@@ -103,10 +103,10 @@ export declare class LinearElementEditor {
103
103
  static movePoints(element: NonDeleted<ExcalidrawLinearElement>, scene: Scene, pointUpdates: PointsPositionUpdates, otherUpdates?: {
104
104
  startBinding?: FixedPointBinding | null;
105
105
  endBinding?: FixedPointBinding | null;
106
- moveMidPointsWithElement?: boolean | null;
107
106
  }, options?: {
108
107
  isBindingEnabled?: boolean;
109
108
  isMidpointSnappingEnabled?: boolean;
109
+ moveMidPointsWithElement?: boolean;
110
110
  }): void;
111
111
  static shouldAddMidpoint(linearElementEditor: LinearElementEditor, pointerCoords: PointerCoords, appState: AppState, elementsMap: ElementsMap): boolean;
112
112
  static addMidpoint(linearElementEditor: LinearElementEditor, pointerCoords: PointerCoords, app: AppClassProperties, snapToGrid: boolean, scene: Scene): {
@@ -122,6 +122,9 @@ export declare class LinearElementEditor {
122
122
  */
123
123
  static getBoundTextElementCenter: (element: ExcalidrawLinearElement, elementsMap: ElementsMap) => GlobalPoint;
124
124
  static handleBoundTextDragging(linearElementEditor: LinearElementEditor, scene: Scene, pointerX: number, pointerY: number): LinearElementEditor | null;
125
+ static getPathLength(element: ExcalidrawLinearElement, elementsMap: ElementsMap): number;
126
+ /** the path parameter (0-1) of the point on the path closest to `point` */
127
+ static getPathParameterAtPoint(element: ExcalidrawLinearElement, point: GlobalPoint, elementsMap: ElementsMap): number | null;
125
128
  static getPointAtPathParameter(container: ExcalidrawLinearElement, pathParameter: number, elementsMap: ElementsMap): GlobalPoint | null;
126
129
  static getBoundTextElementPosition: (element: ExcalidrawLinearElement, boundTextElement: ExcalidrawTextElementWithContainer, elementsMap: ElementsMap) => {
127
130
  x: number;
@@ -0,0 +1,39 @@
1
+ import type { RenderEnvironment } from "./renderEnvironment";
2
+ import type { Scene } from "./Scene";
3
+ import type { ExcalidrawElement, ExcalidrawTextElement } from "./types";
4
+ /** a list marker advanced by duplication, to go back and forth */
5
+ export type ListMarkerAdvance = {
6
+ elementId: ExcalidrawTextElement["id"];
7
+ prevOriginalText: string;
8
+ nextOriginalText: string;
9
+ /**
10
+ * where the item's text (after the marker and whitespace) starts in
11
+ * `nextOriginalText` (its length if there's none)
12
+ */
13
+ contentStart: number;
14
+ /** the label's container before the label (may have) grown it */
15
+ prevContainerSize: {
16
+ width: number;
17
+ height: number;
18
+ } | null;
19
+ };
20
+ /**
21
+ * Advances the list markers of the duplicated texts and labels, so that
22
+ * duplicating `1. foo` gives `2. foo` (and `1` gives `2`).
23
+ *
24
+ * Duplicating several list items at once continues the list from the
25
+ * highest of them: duplicating `1.`, `3.`, `5.` gives `6.`, `7.`, `8.` (only
26
+ * if they're just markers, i.e. without text).
27
+ *
28
+ * Only if nothing but list items (texts, or containers with list item labels)
29
+ * is duplicated.
30
+ */
31
+ export declare const advanceDuplicatedListMarkers: (duplicatedElements: readonly ExcalidrawElement[], scene: Scene,
32
+ /** measures the re-numbered texts */
33
+ renderEnvironment?: RenderEnvironment) => ListMarkerAdvance[];
34
+ /**
35
+ * Sets the advanced list markers back (`"prev"`), or forth again (`"next"`).
36
+ */
37
+ export declare const applyListMarkerAdvances: (advances: readonly ListMarkerAdvance[], direction: "prev" | "next", scene: Scene,
38
+ /** measures the re-numbered texts */
39
+ renderEnvironment?: RenderEnvironment) => void;
@@ -1,4 +1,5 @@
1
1
  import type { MarkOptional } from "@excalidraw/common/utility-types";
2
+ import type { RenderEnvironment } from "./renderEnvironment";
2
3
  import type { ExcalidrawImageElement, ExcalidrawTextElement, ExcalidrawLinearElement, ExcalidrawGenericElement, NonDeleted, TextAlign, VerticalAlign, Arrowhead, ExcalidrawFreeDrawElement, FontFamilyValues, ExcalidrawTextContainer, ExcalidrawFrameElement, ExcalidrawEmbeddableElement, ExcalidrawMagicFrameElement, ExcalidrawIframeElement, ElementsMap, ExcalidrawArrowElement, ExcalidrawElbowArrowElement, ExcalidrawLineElement, ExcalidrawStickyNoteElement } from "./types";
3
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" | "created">;
4
5
  export declare const newElement: (opts: {
@@ -61,8 +62,23 @@ export declare const newTextElement: (opts: {
61
62
  autoResize?: ExcalidrawTextElement["autoResize"];
62
63
  labelPosition?: ExcalidrawTextElement["labelPosition"];
63
64
  baseFontSize?: ExcalidrawTextElement["baseFontSize"];
65
+ renderEnvironment?: RenderEnvironment;
64
66
  } & ElementConstructorOpts) => NonDeleted<ExcalidrawTextElement>;
65
- export declare const refreshTextDimensions: (textElement: ExcalidrawTextElement, container: ExcalidrawTextContainer | null, elementsMap: ElementsMap, text?: string) => {
67
+ export declare const refreshTextDimensions: (textElement: ExcalidrawTextElement, container: ExcalidrawTextContainer | null, elementsMap: ElementsMap, text?: string,
68
+ /**
69
+ * For a free text that grows with its content (`autoResize`): the widest
70
+ * it may grow to. Crossing it, the text stops growing and wraps at this
71
+ * width from then on (`autoResize: false`), anchored as its growth was. A
72
+ * text that is already wider keeps growing.
73
+ */
74
+ maxWidth?: number, renderEnvironment?: RenderEnvironment) => {
75
+ x: number;
76
+ y: number;
77
+ width: number;
78
+ height: number;
79
+ text: string;
80
+ autoResize: boolean;
81
+ } | {
66
82
  x: number;
67
83
  y: number;
68
84
  width: number;
@@ -1,6 +1,7 @@
1
1
  import { type GlobalPoint } from "@excalidraw/math";
2
2
  import type { AppState, StaticCanvasAppState, InteractiveCanvasAppState, ElementRenderOverrides } from "@excalidraw/excalidraw/types";
3
3
  import type { StaticCanvasRenderConfig, RenderableElementsMap, InteractiveCanvasRenderConfig } from "@excalidraw/excalidraw/scene/types";
4
+ import type { RenderEnvironment } from "./renderEnvironment";
4
5
  import type { ExcalidrawElement, ExcalidrawTextElement, NonDeletedExcalidrawElement, ExcalidrawFreeDrawElement, ExcalidrawImageElement, NonDeletedSceneElementsMap, ElementsMap } from "./types";
5
6
  import type { RoughCanvas } from "roughjs/bin/canvas";
6
7
  export type RenderPositionOffset = Readonly<{
@@ -22,6 +23,9 @@ export interface ExcalidrawElementWithCanvas {
22
23
  canvas: HTMLCanvasElement;
23
24
  theme: AppState["theme"];
24
25
  scale: number;
26
+ /** backing-store scale the bitmap was rasterized at, see StaticCanvasRenderConfig["scale"] */
27
+ deviceScale: number;
28
+ environment: RenderEnvironment;
25
29
  zoomValue: AppState["zoom"]["value"];
26
30
  canvasOffsetX: number;
27
31
  canvasOffsetY: number;
@@ -29,6 +33,12 @@ export interface ExcalidrawElementWithCanvas {
29
33
  containingFrameOpacity: number;
30
34
  }
31
35
  export declare const DEFAULT_LINK_SIZE = 14;
36
+ /**
37
+ * `save()`s the context around `draw`, restoring it even when `draw` throws:
38
+ * the scene renderer logs a failing element and carries on, and the element
39
+ * mustn't leave its transforms and clips behind for the next one.
40
+ */
41
+ export declare const withSavedContext: (context: CanvasRenderingContext2D, draw: () => void) => void;
32
42
  export declare const elementWithCanvasCache: WeakMap<ExcalidrawElement, ExcalidrawElementWithCanvas>;
33
43
  export declare const renderSelectionElement: (element: NonDeletedExcalidrawElement, context: CanvasRenderingContext2D, appState: InteractiveCanvasAppState, selectionColor: InteractiveCanvasRenderConfig["selectionColor"]) => void;
34
44
  export declare const renderElement: (element: NonDeletedExcalidrawElement, elementsMap: RenderableElementsMap, allElementsMap: NonDeletedSceneElementsMap, rc: RoughCanvas, context: CanvasRenderingContext2D, renderConfig: StaticCanvasRenderConfig, appState: StaticCanvasAppState | InteractiveCanvasAppState, renderState?: Readonly<{