@excalidraw/math 0.18.0-2b1c2a9 → 0.18.0-2c3dcc0

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 (164) hide show
  1. package/dist/dev/index.js +8 -2
  2. package/dist/dev/index.js.map +2 -2
  3. package/dist/prod/index.js +1 -1
  4. package/dist/types/common/src/colors.d.ts +3 -0
  5. package/dist/types/common/src/constants.d.ts +56 -0
  6. package/dist/types/common/src/keys.d.ts +4 -0
  7. package/dist/types/common/src/random.d.ts +7 -0
  8. package/dist/types/common/src/utils.d.ts +12 -1
  9. package/dist/types/element/src/Scene.d.ts +1 -1
  10. package/dist/types/element/src/align.d.ts +4 -1
  11. package/dist/types/element/src/binding.d.ts +75 -7
  12. package/dist/types/element/src/bounds.d.ts +10 -2
  13. package/dist/types/element/src/collision.d.ts +21 -5
  14. package/dist/types/element/src/comparisons.d.ts +5 -3
  15. package/dist/types/element/src/cropElement.d.ts +36 -4
  16. package/dist/types/element/src/delta.d.ts +30 -2
  17. package/dist/types/element/src/distribute.d.ts +4 -1
  18. package/dist/types/element/src/dragElements.d.ts +8 -3
  19. package/dist/types/element/src/duplicate.d.ts +60 -0
  20. package/dist/types/element/src/elbowArrow.d.ts +5 -0
  21. package/dist/types/element/src/embeddable.d.ts +2 -1
  22. package/dist/types/element/src/flowchart.d.ts +6 -8
  23. package/dist/types/element/src/frame.d.ts +21 -3
  24. package/dist/types/element/src/groups.d.ts +1 -6
  25. package/dist/types/element/src/image.d.ts +5 -2
  26. package/dist/types/element/src/index.d.ts +3 -0
  27. package/dist/types/element/src/linearElementEditor.d.ts +4 -1
  28. package/dist/types/element/src/listMarker.d.ts +39 -0
  29. package/dist/types/element/src/mutateElement.d.ts +1 -1
  30. package/dist/types/element/src/newElement.d.ts +40 -3
  31. package/dist/types/element/src/renderElement.d.ts +31 -4
  32. package/dist/types/element/src/renderEnvironment.d.ts +66 -0
  33. package/dist/types/element/src/resizeElements.d.ts +15 -5
  34. package/dist/types/element/src/selection.d.ts +4 -10
  35. package/dist/types/element/src/shape.d.ts +17 -1
  36. package/dist/types/element/src/sizeHelpers.d.ts +6 -0
  37. package/dist/types/element/src/stickyNote.d.ts +191 -0
  38. package/dist/types/element/src/textElement.d.ts +10 -2
  39. package/dist/types/element/src/textMeasurements.d.ts +15 -11
  40. package/dist/types/element/src/textWrapping.d.ts +3 -2
  41. package/dist/types/element/src/transform.d.ts +30 -7
  42. package/dist/types/element/src/typeChecks.d.ts +3 -2
  43. package/dist/types/element/src/types.d.ts +28 -6
  44. package/dist/types/element/src/utils.d.ts +8 -1
  45. package/dist/types/element/src/zindex.d.ts +1 -1
  46. package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +48 -3
  47. package/dist/types/excalidraw/actions/actionAlign.d.ts +6 -6
  48. package/dist/types/excalidraw/actions/actionBoundText.d.ts +62 -208
  49. package/dist/types/excalidraw/actions/actionCanvas.d.ts +121 -16
  50. package/dist/types/excalidraw/actions/actionClipboard.d.ts +32 -2
  51. package/dist/types/excalidraw/actions/actionCropEditor.d.ts +16 -1
  52. package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +4 -546
  53. package/dist/types/excalidraw/actions/actionDeselect.d.ts +20 -2
  54. package/dist/types/excalidraw/actions/actionDistribute.d.ts +2 -2
  55. package/dist/types/excalidraw/actions/actionElementLink.d.ts +16 -1
  56. package/dist/types/excalidraw/actions/actionElementLock.d.ts +32 -2
  57. package/dist/types/excalidraw/actions/actionExport.d.ts +39 -9
  58. package/dist/types/excalidraw/actions/actionFrame.d.ts +92 -479
  59. package/dist/types/excalidraw/actions/actionGroup.d.ts +34 -4
  60. package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +66 -2
  61. package/dist/types/excalidraw/actions/actionLink.d.ts +16 -1
  62. package/dist/types/excalidraw/actions/actionMenu.d.ts +16 -1
  63. package/dist/types/excalidraw/actions/actionProperties.d.ts +42 -8
  64. package/dist/types/excalidraw/actions/actionSelectAll.d.ts +17 -2
  65. package/dist/types/excalidraw/actions/actionStyles.d.ts +17 -2
  66. package/dist/types/excalidraw/actions/actionTextAutoResize.d.ts +452 -6
  67. package/dist/types/excalidraw/actions/actionToggleArrowBinding.d.ts +16 -1
  68. package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +16 -1
  69. package/dist/types/excalidraw/actions/actionToggleMidpointSnapping.d.ts +16 -1
  70. package/dist/types/excalidraw/actions/actionToggleMinimap.d.ts +201 -0
  71. package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +16 -1
  72. package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +16 -1
  73. package/dist/types/excalidraw/actions/actionToggleShowHints.d.ts +198 -0
  74. package/dist/types/excalidraw/actions/actionToggleStats.d.ts +16 -1
  75. package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +16 -1
  76. package/dist/types/excalidraw/actions/actionToggleWrap.d.ts +12 -0
  77. package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +16 -1
  78. package/dist/types/excalidraw/actions/colorTargets.d.ts +39 -0
  79. package/dist/types/excalidraw/actions/index.d.ts +3 -0
  80. package/dist/types/excalidraw/actions/shortcuts.d.ts +1 -1
  81. package/dist/types/excalidraw/actions/types.d.ts +1 -1
  82. package/dist/types/excalidraw/appState.d.ts +26 -8
  83. package/dist/types/excalidraw/charts/charts.bar.d.ts +2 -1
  84. package/dist/types/excalidraw/charts/charts.helpers.d.ts +6 -5
  85. package/dist/types/excalidraw/charts/charts.line.d.ts +2 -1
  86. package/dist/types/excalidraw/charts/charts.radar.d.ts +2 -1
  87. package/dist/types/excalidraw/charts/index.d.ts +2 -1
  88. package/dist/types/excalidraw/components/Actions.d.ts +10 -2
  89. package/dist/types/excalidraw/components/App.arrowText.d.ts +5 -39
  90. package/dist/types/excalidraw/components/App.clipboard.d.ts +31 -0
  91. package/dist/types/excalidraw/components/App.d.ts +129 -218
  92. package/dist/types/excalidraw/components/App.duplicate.d.ts +101 -0
  93. package/dist/types/excalidraw/components/App.host.d.ts +102 -0
  94. package/dist/types/excalidraw/components/App.modifiers.d.ts +38 -0
  95. package/dist/types/excalidraw/components/App.pan.d.ts +62 -0
  96. package/dist/types/excalidraw/components/App.selection.d.ts +265 -0
  97. package/dist/types/excalidraw/components/App.selectionTool.d.ts +94 -0
  98. package/dist/types/excalidraw/components/App.text.d.ts +194 -0
  99. package/dist/types/excalidraw/components/App.textTool.d.ts +140 -0
  100. package/dist/types/excalidraw/components/App.toolDrag.d.ts +63 -0
  101. package/dist/types/excalidraw/components/App.viewport.d.ts +64 -4
  102. package/dist/types/excalidraw/components/App.wheel.d.ts +30 -0
  103. package/dist/types/excalidraw/components/App.wrap.d.ts +39 -0
  104. package/dist/types/excalidraw/components/ColorPicker/Picker.d.ts +2 -0
  105. package/dist/types/excalidraw/components/ColorPicker/colorTopPicksDnD.d.ts +11 -0
  106. package/dist/types/excalidraw/components/ConvertElementTypePopup.d.ts +2 -1
  107. package/dist/types/excalidraw/components/FileDropOverlay.d.ts +2 -0
  108. package/dist/types/excalidraw/components/FontPicker/FontPicker.d.ts +4 -1
  109. package/dist/types/excalidraw/components/FontPicker/FontPickerList.d.ts +6 -1
  110. package/dist/types/excalidraw/components/FontPicker/fontTopPicksDnD.d.ts +12 -0
  111. package/dist/types/excalidraw/components/IconButton.d.ts +2 -0
  112. package/dist/types/excalidraw/components/LibraryMenuSection.d.ts +6 -2
  113. package/dist/types/excalidraw/components/LibraryUnit.d.ts +7 -2
  114. package/dist/types/excalidraw/components/Minimap/Minimap.d.ts +15 -0
  115. package/dist/types/excalidraw/components/Minimap/MinimapAnnouncementDot.d.ts +10 -0
  116. package/dist/types/excalidraw/components/Minimap/minimap-controller.chunk.d.ts +90 -0
  117. package/dist/types/excalidraw/components/Minimap/minimap-shared.chunk.d.ts +122 -0
  118. package/dist/types/excalidraw/components/Minimap/minimap-worker.chunk.d.ts +12 -0
  119. package/dist/types/excalidraw/components/Stats/utils.d.ts +4 -2
  120. package/dist/types/excalidraw/components/TTDDialog/MermaidToExcalidraw.d.ts +2 -1
  121. package/dist/types/excalidraw/components/TTDDialog/TTDDialogOutput.d.ts +5 -2
  122. package/dist/types/excalidraw/components/TTDDialog/TTDPreviewPanel.d.ts +5 -2
  123. package/dist/types/excalidraw/components/TTDDialog/TextToDiagram.d.ts +2 -1
  124. package/dist/types/excalidraw/components/TTDDialog/common.d.ts +4 -1
  125. package/dist/types/excalidraw/components/TTDDialog/hooks/useTextGeneration.d.ts +3 -2
  126. package/dist/types/excalidraw/components/TTDDialog/types.d.ts +14 -1
  127. package/dist/types/excalidraw/components/TTDDialog/utils/mermaidError.d.ts +16 -0
  128. package/dist/types/excalidraw/components/Tools.d.ts +7 -2
  129. package/dist/types/excalidraw/components/Tooltip.d.ts +26 -2
  130. package/dist/types/excalidraw/components/TopPicksDnD/TopPicksContextMenu.d.ts +14 -0
  131. package/dist/types/excalidraw/components/TopPicksDnD/TopPicksTip.d.ts +11 -0
  132. package/dist/types/excalidraw/components/TopPicksDnD/topPicksDnD.d.ts +58 -0
  133. package/dist/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +0 -1
  134. package/dist/types/excalidraw/components/canvases/NewElementCanvas.d.ts +2 -0
  135. package/dist/types/excalidraw/components/footer/Footer.d.ts +3 -1
  136. package/dist/types/excalidraw/components/hyperlink/Hyperlink.d.ts +3 -2
  137. package/dist/types/excalidraw/components/hyperlink/helpers.d.ts +13 -2
  138. package/dist/types/excalidraw/components/icons.d.ts +2 -0
  139. package/dist/types/excalidraw/components/main-menu/DefaultItems.d.ts +3 -0
  140. package/dist/types/excalidraw/components/shapeActionPredicates.d.ts +2 -2
  141. package/dist/types/excalidraw/data/blob.d.ts +46 -16
  142. package/dist/types/excalidraw/data/index.d.ts +3 -3
  143. package/dist/types/excalidraw/data/json.d.ts +23 -8
  144. package/dist/types/excalidraw/fonts/Fonts.d.ts +9 -6
  145. package/dist/types/excalidraw/history.d.ts +10 -4
  146. package/dist/types/excalidraw/mermaid.d.ts +7 -0
  147. package/dist/types/excalidraw/reactUtils.d.ts +1 -1
  148. package/dist/types/excalidraw/renderOverrides.d.ts +9 -0
  149. package/dist/types/excalidraw/renderer/animation.d.ts +11 -4
  150. package/dist/types/excalidraw/renderer/helpers.d.ts +18 -0
  151. package/dist/types/excalidraw/renderer/interactiveScene.d.ts +1 -1
  152. package/dist/types/excalidraw/renderer/staticScene.d.ts +11 -6
  153. package/dist/types/excalidraw/scene/Renderer.d.ts +64 -3
  154. package/dist/types/excalidraw/scene/export.d.ts +343 -20
  155. package/dist/types/excalidraw/scene/index.d.ts +1 -1
  156. package/dist/types/excalidraw/scene/types.d.ts +26 -2
  157. package/dist/types/excalidraw/types.d.ts +191 -22
  158. package/dist/types/excalidraw/viewport.d.ts +29 -1
  159. package/dist/types/excalidraw/wysiwyg/textWysiwyg.d.ts +12 -1
  160. package/dist/types/utils/src/index.d.ts +3 -1
  161. package/dist/types/utils/src/shape.d.ts +2 -2
  162. package/package.json +2 -2
  163. package/dist/types/excalidraw/components/ColorPicker/topPicksDnD.d.ts +0 -31
  164. package/dist/types/utils/src/export.d.ts +0 -35
@@ -1,8 +1,12 @@
1
1
  import type { ExcalidrawElement, FontFamilyValues } from "@excalidraw/element/types";
2
2
  import type { AppProps, AppState } from "@excalidraw/excalidraw/types";
3
+ export { DEFAULT_STICKY_NOTE_BG } from "./colors";
3
4
  export declare const supportsResizeObserver: boolean;
4
5
  export declare const APP_NAME = "Excalidraw";
5
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;
9
+ export declare const TEXT_MAX_WRAP_WIDTH_ZOOMED_OUT = 2000;
6
10
  export declare const DRAGGING_THRESHOLD = 10;
7
11
  export declare const MINIMUM_ARROW_SIZE = 20;
8
12
  export declare const LINE_CONFIRM_THRESHOLD = 8;
@@ -52,6 +56,7 @@ export declare enum EVENT {
52
56
  POINTER_MOVE = "pointermove",
53
57
  POINTER_DOWN = "pointerdown",
54
58
  POINTER_UP = "pointerup",
59
+ POINTER_CANCEL = "pointercancel",
55
60
  STATE_CHANGE = "statechange",
56
61
  WHEEL = "wheel",
57
62
  TOUCH_START = "touchstart",
@@ -150,7 +155,53 @@ export declare const FRAME_STYLE: {
150
155
  };
151
156
  export declare const MIN_FONT_SIZE = 1;
152
157
  export declare const DEFAULT_FONT_SIZE = 20;
158
+ export declare const STICKY_NOTE_MIN_FONT_SIZE = 16;
159
+ export declare const STICKY_NOTE_MAX_FONT_SIZE = 512;
160
+ export declare const STICKY_NOTE_FALLBACK_FONT_SIZE = 28;
161
+ export declare const STICKY_NOTE_FONT_STEP = 2;
162
+ export declare const STICKY_NOTE_PADDING = 16;
163
+ /**
164
+ * The creation-date footer: a 20px text row under the label body plus a 12px
165
+ * gap above it, inside the note's bottom padding. Reserved for every note —
166
+ * also when `created` is unknown — so geometry never depends on data
167
+ * availability. The label is chosen by width bucket, never measured, so
168
+ * painting stays measurement-free (the server has no text measurer):
169
+ * `minBodyWidthForYear` is the worst case ("30 May 2026") in the system sans
170
+ * stack at 12px, with margin for wider fallbacks such as DejaVu Sans.
171
+ */
172
+ /**
173
+ * The creation-date footer of a sticky note. The label body ends `height`
174
+ * above the note's bottom padding, and the date's baseline sits
175
+ * `baselineFromBottom` above the note's bottom edge — so the 12px glyphs
176
+ * (~9px above the baseline, ~3px below) end up roughly 11px from the edge
177
+ * with a ~13px gap to the label body above them.
178
+ */
179
+ export declare const STICKY_NOTE_FOOTER: {
180
+ readonly height: 20;
181
+ readonly fontSize: 12;
182
+ readonly fontFamily: "Helvetica, Arial, sans-serif";
183
+ readonly baselineFromBottom: 14;
184
+ readonly opacity: 1;
185
+ readonly minBodyWidthForYear: 80;
186
+ };
187
+ /**
188
+ * outer height → label body height: top + bottom padding + footer. The body
189
+ * is what the label is fitted into; a middle-aligned label is still centered
190
+ * in the whole padded note when it fits (see `computeBoundTextPosition`).
191
+ */
192
+ export declare const STICKY_NOTE_BODY_INSET_Y: number;
193
+ export declare const DEFAULT_STICKY_NOTE_SIZE = 250;
194
+ export declare const STICKY_NOTE_MIN_SIZE = 75;
195
+ export declare const STICKY_NOTE_SHADOW_OFFSET = 3;
196
+ export declare const STICKY_NOTE_SHADOW_OPACITY = 0.16;
197
+ export declare const STICKY_NOTE_EDGE_SHADOW_WIDTH = 0.5;
198
+ export declare const STICKY_NOTE_EDGE_SHADOW_OPACITY = 0.08;
153
199
  export declare const DEFAULT_FONT_FAMILY: FontFamilyValues;
200
+ /** number of slots in the font-picker top-picks strip — pick customization
201
+ * (replace / reorder) preserves it. Must equal `DEFAULT_FONTS.length` in
202
+ * `packages/excalidraw/components/FontPicker/FontPicker.tsx` (enforced by
203
+ * `fontTopPicks.test.ts`) */
204
+ export declare const FONT_TOP_PICKS_SLOTS = 3;
154
205
  export declare const DEFAULT_TEXT_ALIGN = "left";
155
206
  export declare const DEFAULT_VERTICAL_ALIGN = "top";
156
207
  export declare const DEFAULT_VERSION = "{version}";
@@ -224,9 +275,12 @@ export declare const TOUCH_CTX_MENU_TIMEOUT = 500;
224
275
  export declare const TITLE_TIMEOUT = 10000;
225
276
  export declare const VERSION_TIMEOUT = 30000;
226
277
  export declare const SCROLL_TIMEOUT = 100;
278
+ export declare const ZEN_MODE_TRANSITION_DURATION = 250;
227
279
  export declare const ZOOM_STEP = 0.1;
228
280
  export declare const MIN_ZOOM = 0.1;
229
281
  export declare const MAX_ZOOM = 30;
282
+ /** 100% zoom, for computations that have no editor zoom to go by */
283
+ export declare const DEFAULT_ZOOM: AppState["zoom"];
230
284
  export declare const HYPERLINK_TOOLTIP_DELAY = 300;
231
285
  export declare const IDLE_THRESHOLD = 60000;
232
286
  export declare const ACTIVE_THRESHOLD = 3000;
@@ -313,6 +367,7 @@ export declare const TOOL_TYPE: {
313
367
  readonly hand: "hand";
314
368
  readonly frame: "frame";
315
369
  readonly magicframe: "magicframe";
370
+ readonly stickynote: "stickynote";
316
371
  readonly embeddable: "embeddable";
317
372
  readonly laser: "laser";
318
373
  readonly autoshape: "autoshape";
@@ -322,6 +377,7 @@ export declare const EDITOR_LS_KEYS: {
322
377
  readonly OAI_API_KEY: "excalidraw-oai-api-key";
323
378
  readonly MERMAID_TO_EXCALIDRAW: "mermaid-to-excalidraw";
324
379
  readonly PUBLISH_LIBRARY: "publish-library-data";
380
+ readonly MINIMAP_ANNOUNCEMENT_DISMISSED: "excalidraw-minimap-announcement-dismissed";
325
381
  };
326
382
  /**
327
383
  * not translated as this is used only in public, stateless API as default value
@@ -22,6 +22,7 @@ export declare const CODES: {
22
22
  readonly Y: "KeyY";
23
23
  readonly R: "KeyR";
24
24
  readonly S: "KeyS";
25
+ readonly W: "KeyW";
25
26
  };
26
27
  export declare const KEYS: {
27
28
  readonly ARROW_DOWN: "ArrowDown";
@@ -55,6 +56,7 @@ export declare const KEYS: {
55
56
  readonly H: "h";
56
57
  readonly I: "i";
57
58
  readonly L: "l";
59
+ readonly N: "n";
58
60
  readonly O: "o";
59
61
  readonly P: "p";
60
62
  readonly Q: "q";
@@ -111,6 +113,7 @@ export declare const KeyCodeMap: Map<ValueOf<{
111
113
  readonly H: "h";
112
114
  readonly I: "i";
113
115
  readonly L: "l";
116
+ readonly N: "n";
114
117
  readonly O: "o";
115
118
  readonly P: "p";
116
119
  readonly Q: "q";
@@ -156,6 +159,7 @@ export declare const KeyCodeMap: Map<ValueOf<{
156
159
  readonly Y: "KeyY";
157
160
  readonly R: "KeyR";
158
161
  readonly S: "KeyS";
162
+ readonly W: "KeyW";
159
163
  }>>;
160
164
  export declare const isLatinChar: (key: string) => boolean;
161
165
  /**
@@ -1,3 +1,10 @@
1
1
  export declare const randomInteger: () => number;
2
2
  export declare const reseed: (seed: number) => void;
3
3
  export declare const randomId: () => string;
4
+ /**
5
+ * Deterministic PRNG (mulberry32) for a given seed: same seed, same
6
+ * sequence — used where a render must be stable across frames and clients
7
+ * (e.g. the sticky note's corner jitter) and roughjs's `Random` is
8
+ * unsuitable (it degenerates for seed 0). Returns numbers in [0, 1).
9
+ */
10
+ export declare const seededRandom: (seed: number) => () => number;
@@ -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;
@@ -72,7 +72,7 @@ export declare class Scene {
72
72
  getElementIndex(elementId: string): number;
73
73
  getContainerElement: (element: (ExcalidrawElement & {
74
74
  containerId: ExcalidrawElement["id"] | null;
75
- }) | null) => import("@excalidraw/element/types").ExcalidrawLinearElement | import("@excalidraw/element/types").ExcalidrawSelectionElement | import("@excalidraw/element/types").ExcalidrawRectangleElement | import("@excalidraw/element/types").ExcalidrawDiamondElement | import("@excalidraw/element/types").ExcalidrawEllipseElement | import("@excalidraw/element/types").ExcalidrawEmbeddableElement | import("@excalidraw/element/types").ExcalidrawIframeElement | import("@excalidraw/element/types").ExcalidrawImageElement | import("@excalidraw/element/types").ExcalidrawFrameElement | import("@excalidraw/element/types").ExcalidrawMagicFrameElement | import("@excalidraw/element/types").ExcalidrawTextElement | import("@excalidraw/element/types").ExcalidrawFreeDrawElement | null;
75
+ }) | null) => import("@excalidraw/element/types").ExcalidrawLinearElement | import("@excalidraw/element/types").ExcalidrawSelectionElement | import("@excalidraw/element/types").ExcalidrawRectangleElement | import("@excalidraw/element/types").ExcalidrawStickyNoteElement | import("@excalidraw/element/types").ExcalidrawDiamondElement | import("@excalidraw/element/types").ExcalidrawEllipseElement | import("@excalidraw/element/types").ExcalidrawEmbeddableElement | import("@excalidraw/element/types").ExcalidrawIframeElement | import("@excalidraw/element/types").ExcalidrawImageElement | import("@excalidraw/element/types").ExcalidrawFrameElement | import("@excalidraw/element/types").ExcalidrawMagicFrameElement | import("@excalidraw/element/types").ExcalidrawTextElement | import("@excalidraw/element/types").ExcalidrawFreeDrawElement | null;
76
76
  getElementsFromId: (id: string) => ExcalidrawElement[];
77
77
  mutateElement<TElement extends Mutable<ExcalidrawElement>>(element: TElement, updates: ElementUpdate<TElement>, options?: {
78
78
  informMutation: boolean;
@@ -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";
@@ -25,10 +26,9 @@ export type BindingStrategy = {
25
26
  * IMPORTANT: currently must be > 0 (this also applies to the computed gap)
26
27
  */
27
28
  export declare const BASE_BINDING_GAP = 5;
28
- export declare const BASE_BINDING_GAP_ELBOW = 5;
29
29
  export declare const BASE_ARROW_MIN_LENGTH = 10;
30
30
  export declare const FOCUS_POINT_SIZE: number;
31
- export declare const getBindingGap: (bindTarget: Pick<ExcalidrawBindableElement, "strokeWidth">, opts: Pick<ExcalidrawArrowElement, "elbowed">) => number;
31
+ export declare const getBindingGap: (bindTarget: Pick<ExcalidrawBindableElement, "strokeWidth">) => number;
32
32
  export declare const maxBindingDistance_simple: (zoom?: AppState["zoom"]) => number;
33
33
  export declare const isBindingEnabled: (appState: {
34
34
  isBindingEnabled: AppState["isBindingEnabled"];
@@ -49,18 +49,78 @@ export declare const getBindingStrategyForDraggingBindingElementEndpoints: (arro
49
49
  altKey?: boolean;
50
50
  finalize?: boolean;
51
51
  initialBinding?: boolean;
52
- zoom?: AppState["zoom"];
53
52
  gridSize?: NullableGridSize;
54
53
  }) => {
55
54
  start: BindingStrategy;
56
55
  end: BindingStrategy;
57
56
  };
58
57
  export declare const bindOrUnbindBindingElements: (selectedArrows: NonDeleted<ExcalidrawArrowElement>[], scene: Scene, appState: AppState) => void;
59
- export declare const bindBindingElement: (arrow: NonDeleted<ExcalidrawArrowElement>, hoveredElement: NonDeleted<ExcalidrawBindableElement>, mode: BindMode, startOrEnd: "start" | "end", scene: Scene, focusPoint?: GlobalPoint, shouldSnapToOutline?: boolean, isMidpointSnappingEnabled?: boolean) => void;
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;
60
74
  export declare const unbindBindingElement: (arrow: ExcalidrawArrowElement, startOrEnd: "start" | "end", scene: Scene) => ExcalidrawBindableElement["id"] | null;
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;
61
118
  export declare const updateBoundElements: (changedElement: NonDeletedExcalidrawElement, scene: Scene, options?: {
119
+ /** see `getSimultaneouslyUpdatedElementIds` for how to pass it */
62
120
  simultaneouslyUpdated?: readonly NonDeletedExcalidrawElement[];
63
121
  changedElements?: Map<string, ExcalidrawElement>;
122
+ /** measures the labels of the arrows it updates (the host's, in the editor) */
123
+ renderEnvironment?: RenderEnvironment;
64
124
  }) => void;
65
125
  export declare const updateBindings: (latestElement: NonDeletedExcalidrawElement, scene: Scene, appState: AppState, options?: {
66
126
  simultaneouslyUpdated?: readonly NonDeletedExcalidrawElement[];
@@ -68,13 +128,21 @@ export declare const updateBindings: (latestElement: NonDeletedExcalidrawElement
68
128
  width: number;
69
129
  height: number;
70
130
  };
131
+ /** measures the labels of the bound arrows it updates */
132
+ renderEnvironment?: RenderEnvironment;
71
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"]>;
72
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;
73
- export declare const bindPointToSnapToElementOutline: (arrowElement: ExcalidrawArrowElement, bindableElement: ExcalidrawBindableElement, startOrEnd: "start" | "end", elementsMap: ElementsMap, customIntersector?: LineSegment<GlobalPoint>, isMidpointSnappingEnabled?: boolean) => GlobalPoint;
142
+ export declare const bindPointToSnapToElementOutline: (arrowElement: ExcalidrawArrowElement, bindableElement: ExcalidrawBindableElement, startOrEnd: "start" | "end", elementsMap: ElementsMap, zoom: AppState["zoom"], customIntersector?: LineSegment<GlobalPoint>, isMidpointSnappingEnabled?: boolean) => GlobalPoint;
74
143
  export declare const avoidRectangularCorner: (arrowElement: ExcalidrawArrowElement, bindTarget: ExcalidrawBindableElement, elementsMap: ElementsMap, p: GlobalPoint) => GlobalPoint;
75
- export declare const snapToMid: (bindTarget: ExcalidrawBindableElement, elementsMap: ElementsMap, p: GlobalPoint, tolerance?: number, arrowElement?: ExcalidrawArrowElement) => GlobalPoint | undefined;
76
144
  export declare const updateBoundPoint: (arrow: NonDeleted<ExcalidrawArrowElement>, startOrEnd: "startBinding" | "endBinding", binding: FixedPointBinding | null | undefined, bindableElement: ExcalidrawBindableElement, elementsMap: ElementsMap, dragging?: boolean) => LocalPoint | null;
77
- export declare const calculateFixedPointForElbowArrowBinding: (linearElement: NonDeleted<ExcalidrawElbowArrowElement>, hoveredElement: ExcalidrawBindableElement, startOrEnd: "start" | "end", elementsMap: ElementsMap, shouldSnapToOutline?: boolean, isMidpointSnappingEnabled?: boolean) => {
145
+ export declare const calculateFixedPointForElbowArrowBinding: (linearElement: NonDeleted<ExcalidrawElbowArrowElement>, hoveredElement: ExcalidrawBindableElement, startOrEnd: "start" | "end", elementsMap: ElementsMap, zoom: AppState["zoom"], shouldSnapToOutline?: boolean, isMidpointSnappingEnabled?: boolean) => {
78
146
  fixedPoint: FixedPoint;
79
147
  };
80
148
  export declare const calculateFixedPointForNonElbowArrowBinding: (linearElement: NonDeleted<ExcalidrawArrowElement>, hoveredElement: NonDeleted<ExcalidrawBindableElement>, startOrEnd: "start" | "end", elementsMap: ElementsMap, focusPoint?: 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;
@@ -1,6 +1,6 @@
1
1
  import type { GlobalPoint, LineSegment } from "@excalidraw/math";
2
- import type { FrameNameBounds } from "@excalidraw/excalidraw/types";
3
- import type { ElementsMap, ExcalidrawArrowElement, ExcalidrawBindableElement, ExcalidrawElement, NonDeleted, NonDeletedExcalidrawElement, NonDeletedSceneElementsMap, Ordered } from "./types";
2
+ import type { AppState, FrameNameBounds } from "@excalidraw/excalidraw/types";
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 = {
6
6
  point: GlobalPoint;
@@ -14,9 +14,25 @@ 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
- export declare const getAllHoveredElementAtPoint: (point: Readonly<GlobalPoint>, elements: readonly Ordered<NonDeletedExcalidrawElement>[], elementsMap: NonDeletedSceneElementsMap, tolerance?: number) => NonDeleted<ExcalidrawBindableElement>[];
18
- export declare const getHoveredElementForBinding: (point: Readonly<GlobalPoint>, elements: readonly Ordered<NonDeletedExcalidrawElement>[], elementsMap: NonDeletedSceneElementsMap, tolerance?: number) => NonDeleted<ExcalidrawBindableElement> | null;
19
- export declare const getHoveredElementForFocusPoint: (point: GlobalPoint, arrow: ExcalidrawArrowElement, elements: readonly Ordered<NonDeletedExcalidrawElement>[], elementsMap: NonDeletedSceneElementsMap, tolerance?: number) => NonDeleted<ExcalidrawBindableElement> | null;
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;
30
+ /**
31
+ * All elements an arrow endpoint at the point could bind to. Always includes
32
+ * the result of `getHoveredElementForBinding` for the same arguments.
33
+ */
34
+ export declare const getAllHoveredElementAtPoint: (point: Readonly<GlobalPoint>, elements: readonly Ordered<NonDeletedExcalidrawElement>[], elementsMap: NonDeletedSceneElementsMap, zoom: AppState["zoom"]) => NonDeleted<ExcalidrawBindableElement>[];
35
+ export declare const getHoveredElementForBinding: (point: Readonly<GlobalPoint>, elements: readonly Ordered<NonDeletedExcalidrawElement>[], elementsMap: NonDeletedSceneElementsMap, zoom: AppState["zoom"]) => NonDeleted<ExcalidrawBindableElement> | null;
20
36
  /**
21
37
  * Intersect a line with an element for binding test
22
38
  *
@@ -1,9 +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" | "autoshape" | "bucketfill";
3
- export declare const hasStrokeColor: (type: ElementOrToolType) => type is "line" | "arrow" | "text" | "rectangle" | "diamond" | "ellipse" | "embeddable" | "freedraw" | "autoshape";
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";
4
5
  export declare const hasStrokeWidth: (type: ElementOrToolType) => type is "line" | "arrow" | "rectangle" | "diamond" | "ellipse" | "embeddable" | "iframe" | "freedraw" | "autoshape";
5
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";
6
8
  export declare const hasFreedrawMode: (type: ElementOrToolType) => type is "freedraw";
7
- export declare const canChangeRoundness: (type: ElementOrToolType) => type is "line" | "rectangle" | "diamond" | "embeddable" | "iframe" | "image";
9
+ export declare const canChangeRoundness: (type: ElementOrToolType) => type is "line" | "rectangle" | "stickynote" | "diamond" | "embeddable" | "iframe" | "image";
8
10
  export declare const toolIsArrow: (type: ElementOrToolType) => type is "arrow";
9
11
  export declare const canHaveArrowheads: (type: ElementOrToolType) => type is "arrow";
@@ -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.
@@ -192,7 +198,29 @@ export declare class ElementsDelta implements DeltaContainer<SceneElementsMap> {
192
198
  private static createGetter;
193
199
  private static applyDelta;
194
200
  /**
195
- * Check for visible changes regardless of whether they were removed, added or updated.
201
+ * Whether an element looks different after the delta — and the layout that
202
+ * followed it — was applied. The input to history's "skip entries with no
203
+ * visible change" loop.
204
+ *
205
+ * Both sides are first reduced to what actually paints:
206
+ * - a missing or deleted element paints nothing;
207
+ * - an empty text element paints nothing either — unless it carries arrow
208
+ * bindings (an arrow may end at it) or sits on an arrow (an empty label
209
+ * still cuts the arrow's gap);
210
+ * so an empty label's deletion or restoration compares as nothing against
211
+ * nothing. Two painting elements are then compared property by property:
212
+ * - `version`, `versionNonce`, `updated`, `created` are metadata, and
213
+ * `index` is covered by the separate z-order check (`reorderElements`);
214
+ * - `boundElements` is compared as `type:id` references with references to
215
+ * empty labels dropped, so adding or removing an empty label's reference
216
+ * is not visible on its own, and binding repair that rebuilt equal
217
+ * objects is not either;
218
+ * - everything else counts. Nested arrays (`points`, binding fixed points)
219
+ * compare by reference, which can only over-report a change — the safe
220
+ * direction, where undo stops one entry early.
221
+ *
222
+ * `previousElements` holds only `idsToCheck` (see `applyTo`); the label
223
+ * lookups it serves are for elements whose labels are in that set.
196
224
  */
197
225
  private static checkForVisibleDifference;
198
226
  /**
@@ -214,7 +242,7 @@ export declare class ElementsDelta implements DeltaContainer<SceneElementsMap> {
214
242
  * should be rebound (if possible) with the current element ~ bindings should be bidirectional.
215
243
  */
216
244
  private static rebindAffected;
217
- static redrawElements(nextElements: SceneElementsMap, changedElements: Map<string, OrderedExcalidrawElement>): SceneElementsMap;
245
+ static redrawElements(nextElements: SceneElementsMap, changedElements: Map<string, OrderedExcalidrawElement>, renderEnvironment?: RenderEnvironment): SceneElementsMap;
218
246
  private static redrawTextBoundingBoxes;
219
247
  private static redrawBoundArrows;
220
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;