@excalidraw/element 0.18.0-063e025 → 0.18.0-1118751

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 (154) hide show
  1. package/dist/dev/index.js +13047 -9808
  2. package/dist/dev/index.js.map +4 -4
  3. package/dist/prod/index.js +19 -19
  4. package/dist/types/common/src/colors.d.ts +22 -0
  5. package/dist/types/common/src/constants.d.ts +54 -0
  6. package/dist/types/common/src/keys.d.ts +4 -0
  7. package/dist/types/common/src/points.d.ts +1 -1
  8. package/dist/types/common/src/random.d.ts +7 -0
  9. package/dist/types/common/src/utils.d.ts +1 -1
  10. package/dist/types/element/src/Scene.d.ts +1 -1
  11. package/dist/types/element/src/arrowEndpointText.d.ts +49 -0
  12. package/dist/types/element/src/arrows/focus.d.ts +5 -2
  13. package/dist/types/element/src/binding.d.ts +15 -8
  14. package/dist/types/element/src/bucketFill.d.ts +110 -0
  15. package/dist/types/element/src/collision.d.ts +8 -5
  16. package/dist/types/element/src/comparisons.d.ts +7 -5
  17. package/dist/types/element/src/convertToShape.d.ts +23 -0
  18. package/dist/types/element/src/delta.d.ts +23 -1
  19. package/dist/types/element/src/dragElements.d.ts +27 -0
  20. package/dist/types/element/src/duplicate.d.ts +60 -0
  21. package/dist/types/element/src/flowchart.d.ts +10 -6
  22. package/dist/types/element/src/frame.d.ts +2 -2
  23. package/dist/types/element/src/groups.d.ts +1 -1
  24. package/dist/types/element/src/index.d.ts +4 -0
  25. package/dist/types/element/src/linearElementEditor.d.ts +17 -0
  26. package/dist/types/element/src/mutateElement.d.ts +1 -1
  27. package/dist/types/element/src/newElement.d.ts +37 -2
  28. package/dist/types/element/src/renderElement.d.ts +21 -4
  29. package/dist/types/element/src/selection.d.ts +1 -1
  30. package/dist/types/element/src/shape.d.ts +27 -1
  31. package/dist/types/element/src/sizeHelpers.d.ts +6 -0
  32. package/dist/types/element/src/sortElements.d.ts +10 -0
  33. package/dist/types/element/src/stickyNote.d.ts +183 -0
  34. package/dist/types/element/src/textElement.d.ts +7 -3
  35. package/dist/types/element/src/transform.d.ts +25 -6
  36. package/dist/types/element/src/typeChecks.d.ts +3 -2
  37. package/dist/types/element/src/types.d.ts +35 -6
  38. package/dist/types/element/src/utils.d.ts +15 -4
  39. package/dist/types/element/src/zindex.d.ts +1 -1
  40. package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +48 -9
  41. package/dist/types/excalidraw/actions/actionAlign.d.ts +6 -6
  42. package/dist/types/excalidraw/actions/actionBoundText.d.ts +32 -6
  43. package/dist/types/excalidraw/actions/actionCanvas.d.ts +173 -576
  44. package/dist/types/excalidraw/actions/actionClipboard.d.ts +32 -6
  45. package/dist/types/excalidraw/actions/actionCropEditor.d.ts +16 -3
  46. package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +50 -10
  47. package/dist/types/excalidraw/actions/actionDeselect.d.ts +13 -3
  48. package/dist/types/excalidraw/actions/actionDistribute.d.ts +2 -2
  49. package/dist/types/excalidraw/actions/actionElementLink.d.ts +16 -3
  50. package/dist/types/excalidraw/actions/actionElementLock.d.ts +32 -6
  51. package/dist/types/excalidraw/actions/actionExport.d.ts +34 -8
  52. package/dist/types/excalidraw/actions/actionFinalize.d.ts +1 -0
  53. package/dist/types/excalidraw/actions/actionFrame.d.ts +99 -185
  54. package/dist/types/excalidraw/actions/actionGroup.d.ts +33 -7
  55. package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +68 -4
  56. package/dist/types/excalidraw/actions/actionLink.d.ts +16 -3
  57. package/dist/types/excalidraw/actions/actionMenu.d.ts +16 -3
  58. package/dist/types/excalidraw/actions/actionProperties.d.ts +45 -12
  59. package/dist/types/excalidraw/actions/actionSelectAll.d.ts +16 -3
  60. package/dist/types/excalidraw/actions/actionStyles.d.ts +17 -4
  61. package/dist/types/excalidraw/actions/actionTextAutoResize.d.ts +1 -1
  62. package/dist/types/excalidraw/actions/actionToggleArrowBinding.d.ts +16 -3
  63. package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +16 -3
  64. package/dist/types/excalidraw/actions/actionToggleMidpointSnapping.d.ts +16 -3
  65. package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +16 -3
  66. package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +16 -3
  67. package/dist/types/excalidraw/actions/actionToggleStats.d.ts +16 -3
  68. package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +17 -4
  69. package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +16 -3
  70. package/dist/types/excalidraw/actions/colorTargets.d.ts +39 -0
  71. package/dist/types/excalidraw/actions/index.d.ts +1 -2
  72. package/dist/types/excalidraw/actions/manager.d.ts +1 -0
  73. package/dist/types/excalidraw/actions/shortcuts.d.ts +1 -1
  74. package/dist/types/excalidraw/actions/types.d.ts +5 -1
  75. package/dist/types/excalidraw/appState.d.ts +26 -5
  76. package/dist/types/excalidraw/components/Actions.d.ts +16 -10
  77. package/dist/types/excalidraw/components/App.arrowText.d.ts +104 -0
  78. package/dist/types/excalidraw/components/App.bucketFill.d.ts +48 -0
  79. package/dist/types/excalidraw/components/App.cursor.d.ts +38 -0
  80. package/dist/types/excalidraw/components/App.d.ts +468 -99
  81. package/dist/types/excalidraw/components/App.drawshape.d.ts +55 -0
  82. package/dist/types/excalidraw/components/App.duplicate.d.ts +51 -0
  83. package/dist/types/excalidraw/components/App.flowchart.d.ts +21 -0
  84. package/dist/types/excalidraw/components/App.pan.d.ts +54 -0
  85. package/dist/types/excalidraw/components/App.toolDrag.d.ts +63 -0
  86. package/dist/types/excalidraw/components/App.viewport.d.ts +73 -0
  87. package/dist/types/excalidraw/components/App.wheel.d.ts +26 -0
  88. package/dist/types/excalidraw/components/ColorPicker/ColorPicker.d.ts +8 -2
  89. package/dist/types/excalidraw/components/ColorPicker/CustomColorList.d.ts +3 -1
  90. package/dist/types/excalidraw/components/ColorPicker/Picker.d.ts +5 -1
  91. package/dist/types/excalidraw/components/ColorPicker/PickerColorList.d.ts +9 -2
  92. package/dist/types/excalidraw/components/ColorPicker/ShadeList.d.ts +4 -2
  93. package/dist/types/excalidraw/components/ColorPicker/TopPicks.d.ts +8 -1
  94. package/dist/types/excalidraw/components/ColorPicker/colorTopPicksDnD.d.ts +11 -0
  95. package/dist/types/excalidraw/components/ColorPicker/keyboardNavHandlers.d.ts +2 -1
  96. package/dist/types/excalidraw/components/FontPicker/FontPicker.d.ts +4 -1
  97. package/dist/types/excalidraw/components/FontPicker/FontPickerList.d.ts +6 -1
  98. package/dist/types/excalidraw/components/FontPicker/fontTopPicksDnD.d.ts +12 -0
  99. package/dist/types/excalidraw/components/IconButton.d.ts +48 -0
  100. package/dist/types/excalidraw/components/LaserPointerButton.d.ts +2 -4
  101. package/dist/types/excalidraw/components/LayerUI.d.ts +5 -2
  102. package/dist/types/excalidraw/components/LockButton.d.ts +3 -4
  103. package/dist/types/excalidraw/components/MagicButton.d.ts +0 -2
  104. package/dist/types/excalidraw/components/MobileMenu.d.ts +4 -4
  105. package/dist/types/excalidraw/components/MobileToolbar.d.ts +9 -0
  106. package/dist/types/excalidraw/components/PenModeButton.d.ts +2 -5
  107. package/dist/types/excalidraw/components/Popover.d.ts +1 -3
  108. package/dist/types/excalidraw/components/{ButtonIcon.d.ts → RadioButton.d.ts} +2 -5
  109. package/dist/types/excalidraw/components/ToolPopover.d.ts +3 -6
  110. package/dist/types/excalidraw/components/Toolbar.d.ts +11 -0
  111. package/dist/types/excalidraw/components/Tools.d.ts +151 -0
  112. package/dist/types/excalidraw/components/TopPicksDnD/TopPicksContextMenu.d.ts +14 -0
  113. package/dist/types/excalidraw/components/TopPicksDnD/TopPicksTip.d.ts +11 -0
  114. package/dist/types/excalidraw/components/TopPicksDnD/topPicksDnD.d.ts +58 -0
  115. package/dist/types/excalidraw/components/UserList.d.ts +3 -2
  116. package/dist/types/excalidraw/components/ViewportStatusFrame/ViewportStatusFrame.d.ts +11 -0
  117. package/dist/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +2 -0
  118. package/dist/types/excalidraw/components/canvases/NewElementCanvas.d.ts +2 -0
  119. package/dist/types/excalidraw/components/footer/Footer.d.ts +3 -1
  120. package/dist/types/excalidraw/components/icons.d.ts +5 -1
  121. package/dist/types/excalidraw/components/main-menu/DefaultItems.d.ts +2 -1
  122. package/dist/types/excalidraw/components/positionElementBesideCursor.d.ts +26 -0
  123. package/dist/types/excalidraw/components/shapeActionPredicates.d.ts +39 -0
  124. package/dist/types/excalidraw/data/blob.d.ts +36 -10
  125. package/dist/types/excalidraw/data/json.d.ts +18 -5
  126. package/dist/types/excalidraw/drawShapeTrail.d.ts +16 -0
  127. package/dist/types/excalidraw/fonts/Fonts.d.ts +3 -2
  128. package/dist/types/excalidraw/hooks/useTextEditorFocus.d.ts +5 -5
  129. package/dist/types/excalidraw/lasso/utils.d.ts +2 -0
  130. package/dist/types/excalidraw/renderOverrides.d.ts +9 -0
  131. package/dist/types/excalidraw/renderer/helpers.d.ts +25 -0
  132. package/dist/types/excalidraw/renderer/interactiveScene.d.ts +1 -1
  133. package/dist/types/excalidraw/scene/Renderer.d.ts +64 -2
  134. package/dist/types/excalidraw/scene/index.d.ts +1 -1
  135. package/dist/types/excalidraw/scene/types.d.ts +6 -1
  136. package/dist/types/excalidraw/types.d.ts +341 -21
  137. package/dist/types/excalidraw/viewport.d.ts +31 -66
  138. package/dist/types/laser-pointer/src/state.d.ts +1 -0
  139. package/dist/types/math/src/curve.d.ts +19 -12
  140. package/dist/types/math/src/index.d.ts +1 -0
  141. package/dist/types/math/src/pca.d.ts +79 -0
  142. package/dist/types/math/src/polygon.d.ts +25 -1
  143. package/dist/types/math/src/segment.d.ts +6 -0
  144. package/dist/types/utils/src/export.d.ts +1 -0
  145. package/dist/types/utils/src/shape.d.ts +2 -2
  146. package/package.json +4 -4
  147. package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +0 -173
  148. package/dist/types/excalidraw/components/FollowMode/FollowMode.d.ts +0 -10
  149. package/dist/types/excalidraw/components/HandButton.d.ts +0 -10
  150. package/dist/types/excalidraw/components/MobileToolBar.d.ts +0 -10
  151. package/dist/types/excalidraw/components/ToolButton.d.ts +0 -49
  152. package/dist/types/excalidraw/components/shapes.d.ts +0 -270
  153. package/dist/types/excalidraw/cursor.d.ts +0 -5
  154. package/dist/types/excalidraw/scene/zoom.d.ts +0 -12
@@ -1,4 +1,5 @@
1
1
  export declare const applyDarkModeFilter: (color: string, enable?: boolean) => string;
2
+ export declare const removeDarkModeFilter: (color: string) => string;
2
3
  export type ColorTuple = readonly [string, string, string, string, string];
3
4
  export type ColorPaletteCustom = {
4
5
  [key: string]: ColorTuple | string;
@@ -28,8 +29,16 @@ export declare const COLOR_PALETTE: {
28
29
  };
29
30
  export type ColorPalette = typeof COLOR_PALETTE;
30
31
  export type ColorPickerColor = keyof typeof COLOR_PALETTE;
32
+ /** number of slots in the color-picker top-picks strip — the strip layout is
33
+ * sized for exactly this many swatches, and pick customization (replace /
34
+ * reorder) preserves it */
35
+ export declare const COLOR_TOP_PICKS_SLOTS = 5;
31
36
  export declare const DEFAULT_ELEMENT_STROKE_PICKS: ColorTuple;
32
37
  export declare const DEFAULT_ELEMENT_BACKGROUND_PICKS: ColorTuple;
38
+ export declare const BUCKET_FILL_BACKGROUND_PICKS: ColorTuple;
39
+ export declare const DEFAULT_STICKY_NOTE_BG = "#ffdf6b";
40
+ export declare const STICKY_NOTE_STROKE_PICKS: ColorTuple;
41
+ export declare const STICKY_NOTE_BACKGROUND_PICKS: ColorTuple;
33
42
  export declare const DEFAULT_CANVAS_BACKGROUND_PICKS: ColorTuple;
34
43
  export declare const DEFAULT_ELEMENT_STROKE_COLOR_PALETTE: {
35
44
  readonly cyan: readonly ["#e3fafc", "#99e9f2", "#3bc9db", "#15aabf", "#0c8599"];
@@ -67,12 +76,25 @@ export declare const DEFAULT_ELEMENT_BACKGROUND_COLOR_PALETTE: {
67
76
  };
68
77
  export declare const getAllColorsSpecificShade: (index: 0 | 1 | 2 | 3 | 4) => ("#fff5f5" | "#ffc9c9" | "#ff8787" | "#fa5252" | "#e03131" | "#fff0f6" | "#fcc2d7" | "#f783ac" | "#e64980" | "#c2255c" | "#f8f0fc" | "#eebefa" | "#da77f2" | "#be4bdb" | "#9c36b5" | "#f3f0ff" | "#d0bfff" | "#9775fa" | "#7950f2" | "#6741d9" | "#e7f5ff" | "#a5d8ff" | "#4dabf7" | "#228be6" | "#1971c2" | "#e3fafc" | "#99e9f2" | "#3bc9db" | "#15aabf" | "#0c8599" | "#e6fcf5" | "#96f2d7" | "#38d9a9" | "#12b886" | "#099268" | "#ebfbee" | "#b2f2bb" | "#69db7c" | "#40c057" | "#2f9e44" | "#fff9db" | "#ffec99" | "#ffd43b" | "#fab005" | "#f08c00" | "#fff4e6" | "#ffd8a8" | "#ffa94d" | "#fd7e14" | "#e8590c")[];
69
78
  export declare const rgbToHex: (r: number, g: number, b: number, a?: number) => string;
79
+ /**
80
+ * @returns the color with its alpha replaced by `alpha` (as #RRGGBBAA), or the
81
+ * input unchanged if it's not a valid color
82
+ */
83
+ export declare const setColorAlpha: (color: string, alpha: number) => string;
70
84
  /**
71
85
  * @returns #RRGGBB or #RRGGBBAA based on color containing non-opaque alpha,
72
86
  * null if not valid color
73
87
  */
74
88
  export declare const colorToHex: (color: string) => string | null;
75
89
  export declare const isTransparent: (color: string) => boolean;
90
+ /**
91
+ * Whether the color is fully opaque (alpha exactly 1).
92
+ *
93
+ * NOT the negation of `isTransparent`, which is true only at alpha 0 — a
94
+ * partial-alpha color (`#RRGGBBAA`, `rgba(…, 0.5)`) is neither transparent
95
+ * (it renders) nor opaque (what's beneath shows through it).
96
+ */
97
+ export declare const isOpaqueColor: (color: string) => boolean;
76
98
  export declare const COLOR_OUTLINE_CONTRAST_THRESHOLD = 240;
77
99
  export declare const isColorDark: (color: string, threshold?: number) => boolean;
78
100
  /**
@@ -1,5 +1,6 @@
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;
@@ -52,6 +53,7 @@ export declare enum EVENT {
52
53
  POINTER_MOVE = "pointermove",
53
54
  POINTER_DOWN = "pointerdown",
54
55
  POINTER_UP = "pointerup",
56
+ POINTER_CANCEL = "pointercancel",
55
57
  STATE_CHANGE = "statechange",
56
58
  WHEEL = "wheel",
57
59
  TOUCH_START = "touchstart",
@@ -150,7 +152,53 @@ export declare const FRAME_STYLE: {
150
152
  };
151
153
  export declare const MIN_FONT_SIZE = 1;
152
154
  export declare const DEFAULT_FONT_SIZE = 20;
155
+ export declare const STICKY_NOTE_MIN_FONT_SIZE = 16;
156
+ export declare const STICKY_NOTE_MAX_FONT_SIZE = 512;
157
+ export declare const STICKY_NOTE_FALLBACK_FONT_SIZE = 28;
158
+ export declare const STICKY_NOTE_FONT_STEP = 2;
159
+ export declare const STICKY_NOTE_PADDING = 16;
160
+ /**
161
+ * The creation-date footer: a 20px text row under the label body plus a 12px
162
+ * gap above it, inside the note's bottom padding. Reserved for every note —
163
+ * also when `created` is unknown — so geometry never depends on data
164
+ * availability. The label is chosen by width bucket, never measured, so
165
+ * painting stays measurement-free (the server has no text measurer):
166
+ * `minBodyWidthForYear` is the worst case ("30 May 2026") in the system sans
167
+ * stack at 12px, with margin for wider fallbacks such as DejaVu Sans.
168
+ */
169
+ /**
170
+ * The creation-date footer of a sticky note. The label body ends `height`
171
+ * above the note's bottom padding, and the date's baseline sits
172
+ * `baselineFromBottom` above the note's bottom edge — so the 12px glyphs
173
+ * (~9px above the baseline, ~3px below) end up roughly 11px from the edge
174
+ * with a ~13px gap to the label body above them.
175
+ */
176
+ export declare const STICKY_NOTE_FOOTER: {
177
+ readonly height: 20;
178
+ readonly fontSize: 12;
179
+ readonly fontFamily: "Helvetica, Arial, sans-serif";
180
+ readonly baselineFromBottom: 14;
181
+ readonly opacity: 1;
182
+ readonly minBodyWidthForYear: 80;
183
+ };
184
+ /**
185
+ * outer height → label body height: top + bottom padding + footer. The body
186
+ * is what the label is fitted into; a middle-aligned label is still centered
187
+ * in the whole padded note when it fits (see `computeBoundTextPosition`).
188
+ */
189
+ export declare const STICKY_NOTE_BODY_INSET_Y: number;
190
+ export declare const DEFAULT_STICKY_NOTE_SIZE = 250;
191
+ export declare const STICKY_NOTE_MIN_SIZE = 75;
192
+ export declare const STICKY_NOTE_SHADOW_OFFSET = 3;
193
+ export declare const STICKY_NOTE_SHADOW_OPACITY = 0.16;
194
+ export declare const STICKY_NOTE_EDGE_SHADOW_WIDTH = 0.5;
195
+ export declare const STICKY_NOTE_EDGE_SHADOW_OPACITY = 0.08;
153
196
  export declare const DEFAULT_FONT_FAMILY: FontFamilyValues;
197
+ /** number of slots in the font-picker top-picks strip — pick customization
198
+ * (replace / reorder) preserves it. Must equal `DEFAULT_FONTS.length` in
199
+ * `packages/excalidraw/components/FontPicker/FontPicker.tsx` (enforced by
200
+ * `fontTopPicks.test.ts`) */
201
+ export declare const FONT_TOP_PICKS_SLOTS = 3;
154
202
  export declare const DEFAULT_TEXT_ALIGN = "left";
155
203
  export declare const DEFAULT_VERTICAL_ALIGN = "top";
156
204
  export declare const DEFAULT_VERSION = "{version}";
@@ -227,6 +275,8 @@ export declare const SCROLL_TIMEOUT = 100;
227
275
  export declare const ZOOM_STEP = 0.1;
228
276
  export declare const MIN_ZOOM = 0.1;
229
277
  export declare const MAX_ZOOM = 30;
278
+ /** 100% zoom, for computations that have no editor zoom to go by */
279
+ export declare const DEFAULT_ZOOM: AppState["zoom"];
230
280
  export declare const HYPERLINK_TOOLTIP_DELAY = 300;
231
281
  export declare const IDLE_THRESHOLD = 60000;
232
282
  export declare const ACTIVE_THRESHOLD = 3000;
@@ -262,6 +312,7 @@ export declare const TEXT_ALIGN: {
262
312
  RIGHT: string;
263
313
  };
264
314
  export declare const ELEMENT_READY_TO_ERASE_OPACITY = 20;
315
+ export declare const ELEMENT_PENDING_DRAW_SHAPE_OPACITY = 70;
265
316
  export declare const DEFAULT_PROPORTIONAL_RADIUS = 0.25;
266
317
  export declare const DEFAULT_ADAPTIVE_RADIUS = 32;
267
318
  export declare const ROUNDNESS: {
@@ -312,8 +363,11 @@ export declare const TOOL_TYPE: {
312
363
  readonly hand: "hand";
313
364
  readonly frame: "frame";
314
365
  readonly magicframe: "magicframe";
366
+ readonly stickynote: "stickynote";
315
367
  readonly embeddable: "embeddable";
316
368
  readonly laser: "laser";
369
+ readonly autoshape: "autoshape";
370
+ readonly bucketfill: "bucketfill";
317
371
  };
318
372
  export declare const EDITOR_LS_KEYS: {
319
373
  readonly OAI_API_KEY: "excalidraw-oai-api-key";
@@ -46,6 +46,7 @@ export declare const KEYS: {
46
46
  readonly SUBTRACT: "-";
47
47
  readonly SLASH: "/";
48
48
  readonly A: "a";
49
+ readonly B: "b";
49
50
  readonly C: "c";
50
51
  readonly D: "d";
51
52
  readonly E: "e";
@@ -54,6 +55,7 @@ export declare const KEYS: {
54
55
  readonly H: "h";
55
56
  readonly I: "i";
56
57
  readonly L: "l";
58
+ readonly N: "n";
57
59
  readonly O: "o";
58
60
  readonly P: "p";
59
61
  readonly Q: "q";
@@ -101,6 +103,7 @@ export declare const KeyCodeMap: Map<ValueOf<{
101
103
  readonly SUBTRACT: "-";
102
104
  readonly SLASH: "/";
103
105
  readonly A: "a";
106
+ readonly B: "b";
104
107
  readonly C: "c";
105
108
  readonly D: "d";
106
109
  readonly E: "e";
@@ -109,6 +112,7 @@ export declare const KeyCodeMap: Map<ValueOf<{
109
112
  readonly H: "h";
110
113
  readonly I: "i";
111
114
  readonly L: "l";
115
+ readonly N: "n";
112
116
  readonly O: "o";
113
117
  readonly P: "p";
114
118
  readonly Q: "q";
@@ -6,4 +6,4 @@ export declare const getSizeFromPoints: (points: readonly (GlobalPoint | LocalPo
6
6
  };
7
7
  /** @arg dimension, 0 for rescaling only x, 1 for y */
8
8
  export declare const rescalePoints: <Point extends GlobalPoint | LocalPoint>(dimension: 0 | 1, newSize: number, points: readonly Point[], normalize: boolean) => Point[];
9
- export declare const getGridPoint: (x: number, y: number, gridSize: NullableGridSize) => [number, number];
9
+ export declare const getGridPoint: (x: number, y: number, gridSize: NullableGridSize) => GlobalPoint;
@@ -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;
@@ -51,7 +51,7 @@ export declare const updateActiveTool: (appState: Pick<AppState, "activeTool">,
51
51
  locked?: boolean;
52
52
  fromSelection?: boolean;
53
53
  }) & {
54
- lastActiveToolBeforeEraser?: ActiveTool | null;
54
+ lastActiveTool?: ActiveTool | null;
55
55
  }) => AppState["activeTool"];
56
56
  export declare const isFullScreen: () => boolean;
57
57
  export declare const allowFullScreen: () => Promise<void>;
@@ -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;
@@ -0,0 +1,49 @@
1
+ import type { GlobalPoint } from "@excalidraw/math";
2
+ import type { AppState } from "@excalidraw/excalidraw/types";
3
+ import type { ElementsMap, ExcalidrawArrowElement, ExcalidrawTextElement, FixedPoint, NonDeleted, NonDeletedExcalidrawElement, TextAlign, VerticalAlign } from "./types";
4
+ export type ArrowEndpoint = {
5
+ arrow: NonDeleted<ExcalidrawArrowElement>;
6
+ startOrEnd: "start" | "end";
7
+ };
8
+ /**
9
+ * Finds a free (unbound) arrow endpoint under the cursor, front-most first.
10
+ * Used by the text tool to offer creating a text label anchored to the tip of
11
+ * an arrow.
12
+ */
13
+ export declare const getUnboundArrowEndpointAtPoint: (scenePointer: GlobalPoint, elements: readonly NonDeletedExcalidrawElement[], elementsMap: ElementsMap, zoom: AppState["zoom"]) => ArrowEndpoint | null;
14
+ /**
15
+ * Describes how a text element should be created so that it reads as a label
16
+ * for the given arrow endpoint.
17
+ *
18
+ * The arrow is treated as fixed: rather than routing the arrow to the text, we
19
+ * pick the side of the text the arrow should attach to (the one it already
20
+ * points at), and place the text so that side's midpoint lands on the existing
21
+ * endpoint. The alignment returned pins that same midpoint while the text is
22
+ * typed, so the arrow doesn't swing around during editing.
23
+ */
24
+ export declare const getTextBindingForArrowEndpoint: (arrow: NonDeleted<ExcalidrawArrowElement>, startOrEnd: "start" | "end", elementsMap: ElementsMap,
25
+ /**
26
+ * stroke width the text will be created with — the binding gap is derived
27
+ * from the *bind target*, so using the arrow's would offset the anchor by
28
+ * half the difference between the two
29
+ */
30
+ targetStrokeWidth: number) => {
31
+ /** the text-local ratio the arrow binds to (a side midpoint) */
32
+ fixedPoint: FixedPoint;
33
+ textAlign: TextAlign;
34
+ verticalAlign: VerticalAlign;
35
+ /** scene position the text's bound side midpoint should sit at */
36
+ anchor: GlobalPoint;
37
+ } | null;
38
+ /**
39
+ * Whether an arrow endpoint is bound to this text — i.e. the text serves as an
40
+ * arrow-endpoint label. Checked on the arrows' own bindings: the text's
41
+ * `boundElements` only says an arrow relates to it, while the binding on the
42
+ * arrow is the authoritative side of the relationship.
43
+ */
44
+ export declare const isEndpointBoundText: (text: ExcalidrawTextElement, elementsMap: ElementsMap) => boolean;
45
+ /** the anchor a text bound to an arrow endpoint grows away from */
46
+ export declare const getEndpointBoundTextDragAnchor: (newElement: ExcalidrawTextElement) => {
47
+ anchorRatio: number;
48
+ anchorX: number;
49
+ };
@@ -1,7 +1,7 @@
1
1
  import { type GlobalPoint } from "@excalidraw/math";
2
2
  import type { AppState, NullableGridSize } from "@excalidraw/excalidraw/types";
3
3
  import { LinearElementEditor } from "../linearElementEditor";
4
- import type { ElementsMap, ExcalidrawArrowElement, ExcalidrawBindableElement, NonDeletedSceneElementsMap } from "../types";
4
+ import type { ElementsMap, ExcalidrawArrowElement, ExcalidrawBindableElement, FixedPointBinding, NonDeletedSceneElementsMap } from "../types";
5
5
  import type { Scene } from "../Scene";
6
6
  export declare const isFocusPointVisible: (focusPoint: GlobalPoint, arrow: ExcalidrawArrowElement, bindableElement: ExcalidrawBindableElement, elementsMap: ElementsMap, appState: {
7
7
  isBindingEnabled: AppState["isBindingEnabled"];
@@ -22,6 +22,9 @@ export declare const handleFocusPointPointerDown: (arrow: ExcalidrawArrowElement
22
22
  x: number;
23
23
  y: number;
24
24
  };
25
+ arrowOtherEndpointInitialBinding: FixedPointBinding | null;
26
+ };
27
+ export declare const handleFocusPointPointerUp: (linearElementEditor: LinearElementEditor, scene: Scene) => {
28
+ arrowOtherEndpointInitialBinding: null;
25
29
  };
26
- export declare const handleFocusPointPointerUp: (linearElementEditor: LinearElementEditor, scene: Scene) => void;
27
30
  export declare const handleFocusPointHover: (arrow: ExcalidrawArrowElement, scenePointerX: number, scenePointerY: number, scene: Scene, appState: AppState) => "start" | "end" | null;
@@ -1,6 +1,6 @@
1
1
  import { type GlobalPoint } from "@excalidraw/math";
2
2
  import type { LineSegment, LocalPoint } from "@excalidraw/math";
3
- import type { AppState } from "@excalidraw/excalidraw/types";
3
+ import type { AppState, NullableGridSize } from "@excalidraw/excalidraw/types";
4
4
  import type { Bounds } from "@excalidraw/common";
5
5
  import { type Heading } from "./heading";
6
6
  import type { Scene } from "./Scene";
@@ -25,10 +25,9 @@ export type BindingStrategy = {
25
25
  * IMPORTANT: currently must be > 0 (this also applies to the computed gap)
26
26
  */
27
27
  export declare const BASE_BINDING_GAP = 5;
28
- export declare const BASE_BINDING_GAP_ELBOW = 5;
29
28
  export declare const BASE_ARROW_MIN_LENGTH = 10;
30
29
  export declare const FOCUS_POINT_SIZE: number;
31
- export declare const getBindingGap: (bindTarget: ExcalidrawBindableElement, opts: Pick<ExcalidrawArrowElement, "elbowed">) => number;
30
+ export declare const getBindingGap: (bindTarget: Pick<ExcalidrawBindableElement, "strokeWidth">) => number;
32
31
  export declare const maxBindingDistance_simple: (zoom?: AppState["zoom"]) => number;
33
32
  export declare const isBindingEnabled: (appState: {
34
33
  isBindingEnabled: AppState["isBindingEnabled"];
@@ -38,6 +37,7 @@ export declare const bindOrUnbindBindingElement: (arrow: NonDeleted<ExcalidrawAr
38
37
  altKey?: boolean;
39
38
  angleLocked?: boolean;
40
39
  initialBinding?: boolean;
40
+ gridSize?: NullableGridSize;
41
41
  }) => {
42
42
  start: BindingStrategy;
43
43
  end: BindingStrategy;
@@ -48,14 +48,15 @@ export declare const getBindingStrategyForDraggingBindingElementEndpoints: (arro
48
48
  altKey?: boolean;
49
49
  finalize?: boolean;
50
50
  initialBinding?: boolean;
51
- zoom?: AppState["zoom"];
51
+ gridSize?: NullableGridSize;
52
52
  }) => {
53
53
  start: BindingStrategy;
54
54
  end: BindingStrategy;
55
55
  };
56
56
  export declare const bindOrUnbindBindingElements: (selectedArrows: NonDeleted<ExcalidrawArrowElement>[], scene: Scene, appState: AppState) => void;
57
- export declare const bindBindingElement: (arrow: NonDeleted<ExcalidrawArrowElement>, hoveredElement: NonDeleted<ExcalidrawBindableElement>, mode: BindMode, startOrEnd: "start" | "end", scene: Scene, focusPoint?: GlobalPoint, shouldSnapToOutline?: boolean) => void;
57
+ export declare const bindBindingElement: (arrow: NonDeleted<ExcalidrawArrowElement>, hoveredElement: NonDeleted<ExcalidrawBindableElement>, mode: BindMode, startOrEnd: "start" | "end", scene: Scene, zoom: AppState["zoom"], focusPoint?: GlobalPoint, shouldSnapToOutline?: boolean, isMidpointSnappingEnabled?: boolean) => void;
58
58
  export declare const unbindBindingElement: (arrow: ExcalidrawArrowElement, startOrEnd: "start" | "end", scene: Scene) => ExcalidrawBindableElement["id"] | null;
59
+ export declare const reanchorBindingsToOutline: (changedElement: NonDeleted<ExcalidrawBindableElement>, scene: Scene, zoom: AppState["zoom"]) => void;
59
60
  export declare const updateBoundElements: (changedElement: NonDeletedExcalidrawElement, scene: Scene, options?: {
60
61
  simultaneouslyUpdated?: readonly NonDeletedExcalidrawElement[];
61
62
  changedElements?: Map<string, ExcalidrawElement>;
@@ -68,11 +69,10 @@ export declare const updateBindings: (latestElement: NonDeletedExcalidrawElement
68
69
  };
69
70
  }) => void;
70
71
  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;
71
- export declare const bindPointToSnapToElementOutline: (arrowElement: ExcalidrawArrowElement, bindableElement: ExcalidrawBindableElement, startOrEnd: "start" | "end", elementsMap: ElementsMap, customIntersector?: LineSegment<GlobalPoint>, isMidpointSnappingEnabled?: boolean) => GlobalPoint;
72
+ export declare const bindPointToSnapToElementOutline: (arrowElement: ExcalidrawArrowElement, bindableElement: ExcalidrawBindableElement, startOrEnd: "start" | "end", elementsMap: ElementsMap, zoom: AppState["zoom"], customIntersector?: LineSegment<GlobalPoint>, isMidpointSnappingEnabled?: boolean) => GlobalPoint;
72
73
  export declare const avoidRectangularCorner: (arrowElement: ExcalidrawArrowElement, bindTarget: ExcalidrawBindableElement, elementsMap: ElementsMap, p: GlobalPoint) => GlobalPoint;
73
- export declare const snapToMid: (bindTarget: ExcalidrawBindableElement, elementsMap: ElementsMap, p: GlobalPoint, tolerance?: number, arrowElement?: ExcalidrawArrowElement) => GlobalPoint | undefined;
74
74
  export declare const updateBoundPoint: (arrow: NonDeleted<ExcalidrawArrowElement>, startOrEnd: "startBinding" | "endBinding", binding: FixedPointBinding | null | undefined, bindableElement: ExcalidrawBindableElement, elementsMap: ElementsMap, dragging?: boolean) => LocalPoint | null;
75
- export declare const calculateFixedPointForElbowArrowBinding: (linearElement: NonDeleted<ExcalidrawElbowArrowElement>, hoveredElement: ExcalidrawBindableElement, startOrEnd: "start" | "end", elementsMap: ElementsMap, shouldSnapToOutline?: boolean, isMidpointSnappingEnabled?: boolean) => {
75
+ export declare const calculateFixedPointForElbowArrowBinding: (linearElement: NonDeleted<ExcalidrawElbowArrowElement>, hoveredElement: ExcalidrawBindableElement, startOrEnd: "start" | "end", elementsMap: ElementsMap, zoom: AppState["zoom"], shouldSnapToOutline?: boolean, isMidpointSnappingEnabled?: boolean) => {
76
76
  fixedPoint: FixedPoint;
77
77
  };
78
78
  export declare const calculateFixedPointForNonElbowArrowBinding: (linearElement: NonDeleted<ExcalidrawArrowElement>, hoveredElement: NonDeleted<ExcalidrawBindableElement>, startOrEnd: "start" | "end", elementsMap: ElementsMap, focusPoint?: GlobalPoint) => {
@@ -127,3 +127,10 @@ export declare const getArrowLocalFixedPoints: (arrow: ExcalidrawElbowArrowEleme
127
127
  export declare const isFixedPoint: (fixedPoint: any) => fixedPoint is FixedPointBinding["fixedPoint"];
128
128
  export declare const normalizeFixedPoint: <T extends FixedPoint>(fixedPoint: T) => FixedPoint;
129
129
  export declare const getBindingSideMidPoint: (binding: FixedPointBinding, elementsMap: ElementsMap) => GlobalPoint | LocalPoint | null;
130
+ /**
131
+ * Binds an arrow endpoint to an explicit fixed point on a bindable element,
132
+ * bypassing the "derive the ratio from where the endpoint currently is"
133
+ * strategy used when dragging. Needed when the binding target is placed to fit
134
+ * the arrow rather than the other way round.
135
+ */
136
+ export declare const bindBindingElementToFixedPoint: (arrow: NonDeleted<ExcalidrawArrowElement>, bindableElement: NonDeleted<ExcalidrawBindableElement>, startOrEnd: "start" | "end", fixedPoint: FixedPoint, scene: Scene) => void;
@@ -0,0 +1,110 @@
1
+ import type { GlobalPoint } from "@excalidraw/math";
2
+ import type { ElementsMap, ExcalidrawElement, ExcalidrawLineElement, NonDeletedExcalidrawElement } from "./types";
3
+ export type BucketFillOptions = {
4
+ /**
5
+ * geometric fidelity: vertices closer than this collapse to the same graph
6
+ * node, and a node this close to a stroke splits it (T-junction). Keep
7
+ * SMALL — every merge can relocate a vertex by up to this distance, so
8
+ * this value is the upper bound on how far the filled shape may deviate
9
+ * from the actual strokes.
10
+ */
11
+ snapEpsilon: number;
12
+ /**
13
+ * connectivity: loose stroke ends within this distance of another stroke
14
+ * are bridged with a connector edge so the region reads as closed. Also
15
+ * used as broad-phase padding around the owner bounds. Unlike
16
+ * `snapEpsilon` this does not affect the shape's fidelity (bridges add
17
+ * edges; they never move existing vertices).
18
+ */
19
+ gapTolerance: number;
20
+ /** discard faces / polygons smaller than this absolute area */
21
+ minArea: number;
22
+ /** bail out with `too_complex` above this many input segments */
23
+ maxBoundarySegments: number;
24
+ /** cap on the number of generated polygon points */
25
+ maxGeneratedPoints: number;
26
+ /**
27
+ * initial half-extent of the owner-less search box around the click
28
+ * (doubles up to 3 times while the found face touches the box frontier)
29
+ */
30
+ fallbackSearchRadius: number;
31
+ };
32
+ export declare const DEFAULT_BUCKET_FILL_OPTIONS: BucketFillOptions;
33
+ export type BucketFillFailureReason = "no_owner" | "open_region" | "too_complex" | "too_small" | "invalid_polygon";
34
+ /**
35
+ * Where the generated fill element belongs in the scene order, expressed
36
+ * relative to an existing element so the caller can resolve it against
37
+ * whatever (e.g. deleted-inclusive) array it inserts into.
38
+ */
39
+ export type BucketFillInsertion = {
40
+ placement: "above" | "below";
41
+ elementId: ExcalidrawElement["id"];
42
+ };
43
+ export type BucketFillGeometryResult = {
44
+ ok: true;
45
+ /**
46
+ * the closed element under the click, or null for fills resolved by
47
+ * the owner-less fallback (regions formed by open lines)
48
+ */
49
+ ownerId: ExcalidrawElement["id"] | null;
50
+ boundaryElementIds: ExcalidrawElement["id"][];
51
+ /**
52
+ * closed polygon ring in scene coordinates. When the region contains
53
+ * islands, this is a keyhole path: the hole contours are spliced in
54
+ * via zero-width bridges, so it still renders as one polygon with
55
+ * unpainted hole interiors
56
+ */
57
+ scenePoints: GlobalPoint[];
58
+ insertion: BucketFillInsertion;
59
+ } | {
60
+ ok: false;
61
+ reason: BucketFillFailureReason;
62
+ };
63
+ /**
64
+ * Whether the element visually paints an opaque background fill — i.e. can
65
+ * actually hide outlines beneath it. Element types that never render their
66
+ * `backgroundColor` (text, image, frames), see-through fill styles
67
+ * (hachure/cross-hatch), partial element opacity, and colors with an alpha
68
+ * channel below 1 (`#RRGGBBAA`, `rgba(…)`) all don't count — anything under
69
+ * them shows through.
70
+ *
71
+ * Shared with the app layer's z-order pass so "covers" means the same thing
72
+ * in boundary clipping and in fill insertion.
73
+ */
74
+ export declare const rendersOpaqueFill: (element: ExcalidrawElement) => boolean;
75
+ /**
76
+ * Whether the element renders as pure paint the bucket tool could have
77
+ * produced: a closed, visible line polygon with a background and no visible
78
+ * stroke. Recognition is by SHAPE, not by a metadata marker — any marker
79
+ * would go stale the moment the user restyles a fill, and a hand-drawn
80
+ * strokeless background polygon is indistinguishable from a generated fill
81
+ * anyway. Such paint never becomes an owner and is what the app layer
82
+ * restyles in place on re-click (see `isRestylableFill`).
83
+ */
84
+ export declare const isBucketFillCompatible: (element: ExcalidrawElement) => element is ExcalidrawLineElement;
85
+ export declare const computeBucketFillPolygon: (args: {
86
+ point: GlobalPoint;
87
+ elements: readonly NonDeletedExcalidrawElement[];
88
+ elementsMap: ElementsMap;
89
+ options?: Partial<BucketFillOptions>;
90
+ }) => BucketFillGeometryResult;
91
+ /**
92
+ * Whether the element the click landed on is a fill the bucket tool should
93
+ * restyle in place (instead of stacking an identical fill on top), given
94
+ * the computed region.
95
+ *
96
+ * Fill-compatibility is decided by shape (`isBucketFillCompatible`): a fill
97
+ * the user gave a stroke to has been repurposed into an outline and
98
+ * participates as a boundary instead of being restyled.
99
+ *
100
+ * One guard on top: the computed region's net area and bounds must match
101
+ * the element's. Without it, a click inside a shape drawn ON TOP of a
102
+ * filled region would recolor the underlying fill instead of filling that
103
+ * shape; a click on a since-subdivided part of an old fill likewise
104
+ * creates a new (smaller) fill rather than restyling the old one.
105
+ */
106
+ export declare const isRestylableFill: (args: {
107
+ hitElement: ExcalidrawElement;
108
+ scenePoints: readonly GlobalPoint[];
109
+ elementsMap: ElementsMap;
110
+ }) => boolean;
@@ -1,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,12 @@ export declare const hitElementItself: ({ point, element, threshold, elementsMap
14
14
  export declare const hitElementBoundingBox: (point: GlobalPoint, element: ExcalidrawElement, elementsMap: ElementsMap, tolerance?: number) => boolean;
15
15
  export declare const hitElementBoundingBoxOnly: (hitArgs: HitTestArgs, elementsMap: ElementsMap) => boolean;
16
16
  export declare const hitElementBoundText: (point: GlobalPoint, element: ExcalidrawElement, elementsMap: ElementsMap) => boolean;
17
- 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
+ * All elements an arrow endpoint at the point could bind to. Always includes
19
+ * the result of `getHoveredElementForBinding` for the same arguments.
20
+ */
21
+ export declare const getAllHoveredElementAtPoint: (point: Readonly<GlobalPoint>, elements: readonly Ordered<NonDeletedExcalidrawElement>[], elementsMap: NonDeletedSceneElementsMap, zoom: AppState["zoom"]) => NonDeleted<ExcalidrawBindableElement>[];
22
+ export declare const getHoveredElementForBinding: (point: Readonly<GlobalPoint>, elements: readonly Ordered<NonDeletedExcalidrawElement>[], elementsMap: NonDeletedSceneElementsMap, zoom: AppState["zoom"]) => NonDeleted<ExcalidrawBindableElement> | null;
20
23
  /**
21
24
  * Intersect a line with an element for binding test
22
25
  *
@@ -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";
3
- export declare const hasStrokeColor: (type: ElementOrToolType) => type is "line" | "arrow" | "text" | "rectangle" | "diamond" | "ellipse" | "embeddable" | "freedraw";
4
- export declare const hasStrokeWidth: (type: ElementOrToolType) => type is "line" | "arrow" | "rectangle" | "diamond" | "ellipse" | "embeddable" | "iframe" | "freedraw";
5
- export declare const hasStrokeStyle: (type: ElementOrToolType) => type is "line" | "arrow" | "rectangle" | "diamond" | "ellipse" | "embeddable" | "iframe";
2
+ export declare const hasBackground: (type: ElementOrToolType) => type is "line" | "rectangle" | "stickynote" | "diamond" | "ellipse" | "embeddable" | "iframe" | "freedraw" | "autoshape" | "bucketfill";
3
+ export declare const hasFillStyle: (type: ElementOrToolType) => type is "line" | "rectangle" | "diamond" | "ellipse" | "embeddable" | "iframe" | "freedraw" | "autoshape" | "bucketfill";
4
+ export declare const hasStrokeColor: (type: ElementOrToolType) => type is "line" | "arrow" | "text" | "rectangle" | "stickynote" | "diamond" | "ellipse" | "embeddable" | "freedraw" | "autoshape";
5
+ export declare const hasStrokeWidth: (type: ElementOrToolType) => type is "line" | "arrow" | "rectangle" | "diamond" | "ellipse" | "embeddable" | "iframe" | "freedraw" | "autoshape";
6
+ export declare const hasStrokeStyle: (type: ElementOrToolType) => type is "line" | "arrow" | "rectangle" | "diamond" | "ellipse" | "embeddable" | "iframe" | "autoshape";
7
+ export declare const hasRoughness: (type: ElementOrToolType) => type is "line" | "arrow" | "rectangle" | "stickynote" | "diamond" | "ellipse" | "embeddable" | "iframe" | "autoshape";
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";
@@ -0,0 +1,23 @@
1
+ import type { App, AppState } from "@excalidraw/excalidraw/types";
2
+ import type { LocalPoint, GlobalPoint } from "@excalidraw/math";
3
+ import type { Bounds } from "@excalidraw/common";
4
+ import type { ExcalidrawArrowElement, ExcalidrawDiamondElement, ExcalidrawElement, ExcalidrawEllipseElement, ExcalidrawFreeDrawElement, ExcalidrawFrameLikeElement, ExcalidrawRectangleElement, ElementsMap, NonDeleted, ExcalidrawLineElement } from "@excalidraw/element/types";
5
+ declare global {
6
+ interface Window {
7
+ LAST_POINTS?: readonly GlobalPoint[];
8
+ }
9
+ }
10
+ type NonDeletedRecognizedShapeElement = NonDeleted<ExcalidrawRectangleElement | ExcalidrawEllipseElement | ExcalidrawDiamondElement | ExcalidrawArrowElement | ExcalidrawLineElement | ExcalidrawFreeDrawElement>;
11
+ type Shape = NonDeletedRecognizedShapeElement["type"];
12
+ interface ShapeRecognitionResult<P extends LocalPoint | GlobalPoint> {
13
+ type: Shape;
14
+ points: readonly P[];
15
+ boundingBox: Bounds;
16
+ }
17
+ export declare const recognizeShape: <P extends LocalPoint | GlobalPoint>(points: P[], previousElement: ExcalidrawElement | null, zoom?: number) => ShapeRecognitionResult<P>;
18
+ export declare const convertToShape: (points: GlobalPoint[], appState: AppState, elementsMap: ElementsMap, previousElement: ExcalidrawElement | null, frames?: readonly ExcalidrawFrameLikeElement[]) => NonDeletedRecognizedShapeElement | undefined;
19
+ export declare const convertToShapeHandlePointerMoveFromPointerDown: (app: App, pointerCoords: {
20
+ x: number;
21
+ y: number;
22
+ }) => boolean;
23
+ export {};
@@ -192,7 +192,29 @@ export declare class ElementsDelta implements DeltaContainer<SceneElementsMap> {
192
192
  private static createGetter;
193
193
  private static applyDelta;
194
194
  /**
195
- * Check for visible changes regardless of whether they were removed, added or updated.
195
+ * Whether an element looks different after the delta — and the layout that
196
+ * followed it — was applied. The input to history's "skip entries with no
197
+ * visible change" loop.
198
+ *
199
+ * Both sides are first reduced to what actually paints:
200
+ * - a missing or deleted element paints nothing;
201
+ * - an empty text element paints nothing either — unless it carries arrow
202
+ * bindings (an arrow may end at it) or sits on an arrow (an empty label
203
+ * still cuts the arrow's gap);
204
+ * so an empty label's deletion or restoration compares as nothing against
205
+ * nothing. Two painting elements are then compared property by property:
206
+ * - `version`, `versionNonce`, `updated`, `created` are metadata, and
207
+ * `index` is covered by the separate z-order check (`reorderElements`);
208
+ * - `boundElements` is compared as `type:id` references with references to
209
+ * empty labels dropped, so adding or removing an empty label's reference
210
+ * is not visible on its own, and binding repair that rebuilt equal
211
+ * objects is not either;
212
+ * - everything else counts. Nested arrays (`points`, binding fixed points)
213
+ * compare by reference, which can only over-report a change — the safe
214
+ * direction, where undo stops one entry early.
215
+ *
216
+ * `previousElements` holds only `idsToCheck` (see `applyTo`); the label
217
+ * lookups it serves are for elements whose labels are in that set.
196
218
  */
197
219
  private static checkForVisibleDifference;
198
220
  /**
@@ -1,6 +1,7 @@
1
1
  import type { AppState, NormalizedZoomValue, NullableGridSize, PointerDownState } from "@excalidraw/excalidraw/types";
2
2
  import type { NonDeletedExcalidrawElement } from "@excalidraw/element/types";
3
3
  import type { Scene } from "./Scene";
4
+ import type { ExcalidrawTextElement } from "./types";
4
5
  export declare const dragSelectedElements: (pointerDownState: PointerDownState, _selectedElements: NonDeletedExcalidrawElement[], offset: {
5
6
  x: number;
6
7
  y: number;
@@ -9,6 +10,32 @@ export declare const dragSelectedElements: (pointerDownState: PointerDownState,
9
10
  y: number;
10
11
  }, gridSize: NullableGridSize) => void;
11
12
  export declare const getDragOffsetXY: (selectedElements: NonDeletedExcalidrawElement[], x: number, y: number) => [number, number];
13
+ /**
14
+ * Sizes a text element as it is dragged out.
15
+ *
16
+ * A dragged text pins one point and grows away from it; `anchorRatio` says
17
+ * where along the box that point sits — 0 for its left edge, 1 for its right,
18
+ * 0.5 for its centre.
19
+ *
20
+ * A free text pins the point the drag started from and takes the ratio from
21
+ * the drag direction, so it can be pulled either way. A text bound to an arrow
22
+ * endpoint instead pins whatever the binding placed it against and takes the
23
+ * ratio from its alignment — which is also what keeps it from growing back
24
+ * over the arrow, since dragging that way makes no progress rather than
25
+ * flipping the box around.
26
+ */
27
+ export declare const dragNewTextElement: ({ newElement, anchorX, anchorRatio, pointerX, nextY, zoom, scene, informMutation, }: {
28
+ newElement: ExcalidrawTextElement;
29
+ anchorX: number;
30
+ /** 0 = anchored by its left edge, 1 = by its right, 0.5 = by its centre */
31
+ anchorRatio: number;
32
+ pointerX: number;
33
+ /** free text re-tops itself to the drag origin; a bound one must not move */
34
+ nextY?: number;
35
+ zoom: NormalizedZoomValue;
36
+ scene: Scene;
37
+ informMutation?: boolean;
38
+ }) => void;
12
39
  export declare const dragNewElement: ({ newElement, elementType, originX, originY, x, y, width, height, shouldMaintainAspectRatio, shouldResizeFromCenter, zoom, scene, widthAspectRatio, originOffset, informMutation, }: {
13
40
  newElement: NonDeletedExcalidrawElement;
14
41
  elementType: AppState["activeTool"]["type"];