@zsviczian/excalidraw 0.17.1-obsidian-47 → 0.17.1-obsidian-48

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 (73) hide show
  1. package/dist/excalidraw.development.js +248 -127
  2. package/dist/excalidraw.production.min.js +1 -1
  3. package/package.json +1 -1
  4. package/types/excalidraw/actions/actionAddToLibrary.d.ts +3 -3
  5. package/types/excalidraw/actions/actionBoundText.d.ts +2 -2
  6. package/types/excalidraw/actions/actionCanvas.d.ts +18 -18
  7. package/types/excalidraw/actions/actionClipboard.d.ts +10 -10
  8. package/types/excalidraw/actions/actionDeleteSelected.d.ts +6 -6
  9. package/types/excalidraw/actions/actionDuplicateSelection.d.ts +1 -1
  10. package/types/excalidraw/actions/actionElementLock.d.ts +2 -2
  11. package/types/excalidraw/actions/actionExport.d.ts +15 -15
  12. package/types/excalidraw/actions/actionFinalize.d.ts +2 -2
  13. package/types/excalidraw/actions/actionFrame.d.ts +4 -4
  14. package/types/excalidraw/actions/actionGroup.d.ts +2 -2
  15. package/types/excalidraw/actions/actionLinearEditor.d.ts +1 -1
  16. package/types/excalidraw/actions/actionLink.d.ts +1 -1
  17. package/types/excalidraw/actions/actionMenu.d.ts +3 -3
  18. package/types/excalidraw/actions/actionNavigate.d.ts +2 -2
  19. package/types/excalidraw/actions/actionProperties.d.ts +14 -14
  20. package/types/excalidraw/actions/actionSelectAll.d.ts +1 -1
  21. package/types/excalidraw/actions/actionStyles.d.ts +1 -1
  22. package/types/excalidraw/actions/actionToggleGridMode.d.ts +1 -1
  23. package/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +1 -1
  24. package/types/excalidraw/actions/actionToggleStats.d.ts +1 -1
  25. package/types/excalidraw/actions/actionToggleViewMode.d.ts +1 -1
  26. package/types/excalidraw/actions/actionToggleZenMode.d.ts +1 -1
  27. package/types/excalidraw/actions/actionZindex.d.ts +2 -2
  28. package/types/excalidraw/appState.d.ts +8 -8
  29. package/types/excalidraw/clipboard.d.ts +2 -2
  30. package/types/excalidraw/components/App.d.ts +2 -2
  31. package/types/excalidraw/components/hyperlink/helpers.d.ts +4 -3
  32. package/types/excalidraw/element/binding.d.ts +12 -10
  33. package/types/excalidraw/element/bounds.d.ts +6 -4
  34. package/types/excalidraw/element/collision.d.ts +6 -5
  35. package/types/excalidraw/element/embeddable.d.ts +1 -1
  36. package/types/excalidraw/element/heading.d.ts +5 -4
  37. package/types/excalidraw/element/linearElementEditor.d.ts +20 -237
  38. package/types/excalidraw/element/resizeElements.d.ts +1 -2
  39. package/types/excalidraw/element/resizeTest.d.ts +3 -2
  40. package/types/excalidraw/element/routing.d.ts +2 -2
  41. package/types/excalidraw/element/textElement.d.ts +1 -1
  42. package/types/excalidraw/element/transformHandles.d.ts +4 -3
  43. package/types/excalidraw/element/typeChecks.d.ts +0 -3
  44. package/types/excalidraw/element/types.d.ts +7 -6
  45. package/types/excalidraw/obsidianUtils.d.ts +1 -0
  46. package/types/excalidraw/points.d.ts +3 -3
  47. package/types/excalidraw/shapes.d.ts +19 -4
  48. package/types/excalidraw/snapping.d.ts +13 -10
  49. package/types/excalidraw/types.d.ts +0 -2
  50. package/types/excalidraw/utils.d.ts +3 -4
  51. package/types/excalidraw/visualdebug.d.ts +4 -3
  52. package/types/excalidraw/zindex.d.ts +2 -2
  53. package/types/math/angle.d.ts +17 -0
  54. package/types/math/arc.d.ts +6 -0
  55. package/types/math/curve.d.ts +32 -0
  56. package/types/math/ga/ga.d.ts +63 -0
  57. package/types/math/ga/gadirections.d.ts +8 -0
  58. package/types/math/ga/galines.d.ts +22 -0
  59. package/types/math/ga/gapoints.d.ts +7 -0
  60. package/types/math/ga/gatransforms.d.ts +10 -0
  61. package/types/math/index.d.ts +12 -0
  62. package/types/math/line.d.ts +26 -0
  63. package/types/math/point.d.ts +140 -0
  64. package/types/math/polygon.d.ts +5 -0
  65. package/types/math/range.d.ts +44 -0
  66. package/types/math/segment.d.ts +32 -0
  67. package/types/math/triangle.d.ts +11 -0
  68. package/types/math/types.d.ts +96 -0
  69. package/types/math/utils.d.ts +5 -0
  70. package/types/math/vector.d.ts +88 -0
  71. package/types/utils/bbox.d.ts +7 -9
  72. package/types/utils/collision.d.ts +9 -4
  73. package/types/utils/geometry/shape.d.ts +38 -23
@@ -1,11 +1,12 @@
1
1
  import type { NonDeleted, ExcalidrawLinearElement, ExcalidrawElement, PointBinding, ExcalidrawBindableElement, ExcalidrawTextElementWithContainer, ElementsMap, NonDeletedSceneElementsMap, OrderedExcalidrawElement, SceneElementsMap } from "./types";
2
2
  import type { Bounds } from "./bounds";
3
- import type { Point, AppState, PointerCoords, InteractiveCanvasAppState, AppClassProperties, NullableGridSize } from "../types";
3
+ import type { AppState, PointerCoords, InteractiveCanvasAppState, AppClassProperties, NullableGridSize } from "../types";
4
4
  import type { Store } from "../store";
5
5
  import type Scene from "../scene/Scene";
6
+ import { type GlobalPoint, type LocalPoint } from "../../math";
6
7
  declare const editorMidPointsCache: {
7
8
  version: number | null;
8
- points: (Point | null)[];
9
+ points: (GlobalPoint | null)[];
9
10
  zoom: number | null;
10
11
  };
11
12
  export declare class LinearElementEditor {
@@ -24,14 +25,14 @@ export declare class LinearElementEditor {
24
25
  y: number;
25
26
  }> | null;
26
27
  segmentMidpoint: {
27
- value: Point | null;
28
+ value: GlobalPoint | null;
28
29
  index: number | null;
29
30
  added: boolean;
30
31
  };
31
32
  }>;
32
33
  /** whether you're dragging a point */
33
34
  readonly isDragging: boolean;
34
- readonly lastUncommittedPoint: Point | null;
35
+ readonly lastUncommittedPoint: LocalPoint | null;
35
36
  readonly pointerOffset: Readonly<{
36
37
  x: number;
37
38
  y: number;
@@ -39,7 +40,7 @@ export declare class LinearElementEditor {
39
40
  readonly startBindingElement: ExcalidrawBindableElement | null | "keep";
40
41
  readonly endBindingElement: ExcalidrawBindableElement | null | "keep";
41
42
  readonly hoverPointIndex: number;
42
- readonly segmentMidPointHoveredCoords: Point | null;
43
+ readonly segmentMidPointHoveredCoords: GlobalPoint | null;
43
44
  constructor(element: NonDeleted<ExcalidrawLinearElement>);
44
45
  static POINT_HANDLE_SIZE: number;
45
46
  /**
@@ -59,10 +60,10 @@ export declare class LinearElementEditor {
59
60
  static getSegmentMidpointHitCoords: (linearElementEditor: LinearElementEditor, scenePointer: {
60
61
  x: number;
61
62
  y: number;
62
- }, appState: AppState, elementsMap: ElementsMap) => readonly [number, number] | null;
63
- static isSegmentTooShort(element: NonDeleted<ExcalidrawLinearElement>, startPoint: Point, endPoint: Point, zoom: AppState["zoom"]): boolean;
64
- static getSegmentMidPoint(element: NonDeleted<ExcalidrawLinearElement>, startPoint: Point, endPoint: Point, endPointIndex: number, elementsMap: ElementsMap): readonly [number, number];
65
- static getSegmentMidPointIndex(linearElementEditor: LinearElementEditor, appState: AppState, midPoint: Point, elementsMap: ElementsMap): number;
63
+ }, appState: AppState, elementsMap: ElementsMap) => GlobalPoint | null;
64
+ static isSegmentTooShort(element: NonDeleted<ExcalidrawLinearElement>, startPoint: GlobalPoint | LocalPoint, endPoint: GlobalPoint | LocalPoint, zoom: AppState["zoom"]): boolean;
65
+ static getSegmentMidPoint(element: NonDeleted<ExcalidrawLinearElement>, startPoint: GlobalPoint, endPoint: GlobalPoint, endPointIndex: number, elementsMap: ElementsMap): GlobalPoint;
66
+ static getSegmentMidPointIndex(linearElementEditor: LinearElementEditor, appState: AppState, midPoint: GlobalPoint, elementsMap: ElementsMap): number;
66
67
  static handlePointerDown(event: React.PointerEvent<HTMLElement>, app: AppClassProperties, store: Store, scenePointer: {
67
68
  x: number;
68
69
  y: number;
@@ -71,254 +72,36 @@ export declare class LinearElementEditor {
71
72
  hitElement: NonDeleted<ExcalidrawElement> | null;
72
73
  linearElementEditor: LinearElementEditor | null;
73
74
  };
74
- static arePointsEqual(point1: Point | null, point2: Point | null): boolean;
75
+ static arePointsEqual<Point extends LocalPoint | GlobalPoint>(point1: Point | null, point2: Point | null): boolean;
75
76
  static handlePointerMove(event: React.PointerEvent<HTMLCanvasElement>, scenePointerX: number, scenePointerY: number, app: AppClassProperties, elementsMap: NonDeletedSceneElementsMap | SceneElementsMap): LinearElementEditor | null;
76
77
  /** scene coords */
77
- static getPointGlobalCoordinates(element: NonDeleted<ExcalidrawLinearElement>, point: Point, elementsMap: ElementsMap): readonly [number, number];
78
+ static getPointGlobalCoordinates(element: NonDeleted<ExcalidrawLinearElement>, p: LocalPoint, elementsMap: ElementsMap): GlobalPoint;
78
79
  /** scene coords */
79
- static getPointsGlobalCoordinates(element: NonDeleted<ExcalidrawLinearElement>, elementsMap: ElementsMap): Point[];
80
+ static getPointsGlobalCoordinates(element: NonDeleted<ExcalidrawLinearElement>, elementsMap: ElementsMap): GlobalPoint[];
80
81
  static getPointAtIndexGlobalCoordinates(element: NonDeleted<ExcalidrawLinearElement>, indexMaybeFromEnd: number, // -1 for last element
81
- elementsMap: ElementsMap): Point;
82
- static pointFromAbsoluteCoords(element: NonDeleted<ExcalidrawLinearElement>, absoluteCoords: Point, elementsMap: ElementsMap): Point;
82
+ elementsMap: ElementsMap): GlobalPoint;
83
+ static pointFromAbsoluteCoords(element: NonDeleted<ExcalidrawLinearElement>, absoluteCoords: GlobalPoint, elementsMap: ElementsMap): LocalPoint;
83
84
  static getPointIndexUnderCursor(element: NonDeleted<ExcalidrawLinearElement>, elementsMap: ElementsMap, zoom: AppState["zoom"], x: number, y: number): number;
84
- static createPointAt(element: NonDeleted<ExcalidrawLinearElement>, elementsMap: ElementsMap, scenePointerX: number, scenePointerY: number, gridSize: NullableGridSize): Point;
85
+ static createPointAt(element: NonDeleted<ExcalidrawLinearElement>, elementsMap: ElementsMap, scenePointerX: number, scenePointerY: number, gridSize: NullableGridSize): LocalPoint;
85
86
  /**
86
87
  * Normalizes line points so that the start point is at [0,0]. This is
87
88
  * expected in various parts of the codebase. Also returns new x/y to account
88
89
  * for the potential normalization.
89
90
  */
90
91
  static getNormalizedPoints(element: ExcalidrawLinearElement): {
91
- points: (readonly [number, number])[];
92
+ points: LocalPoint[];
92
93
  x: number;
93
94
  y: number;
94
95
  };
95
96
  static normalizePoints(element: NonDeleted<ExcalidrawLinearElement>): void;
96
- static duplicateSelectedPoints(appState: AppState, elementsMap: NonDeletedSceneElementsMap | SceneElementsMap): false | {
97
- appState: {
98
- editingLinearElement: {
99
- selectedPointsIndices: number[];
100
- elementId: string & {
101
- _brand: "excalidrawLinearElementId";
102
- };
103
- pointerDownState: Readonly<{
104
- prevSelectedPointsIndices: readonly number[] | null;
105
- /** index */
106
- lastClickedPoint: number;
107
- lastClickedIsEndPoint: boolean;
108
- origin: Readonly<{
109
- x: number;
110
- y: number;
111
- }> | null;
112
- segmentMidpoint: {
113
- value: readonly [number, number] | null;
114
- index: number | null;
115
- added: boolean;
116
- };
117
- }>;
118
- isDragging: boolean;
119
- lastUncommittedPoint: readonly [number, number] | null;
120
- pointerOffset: Readonly<{
121
- x: number;
122
- y: number;
123
- }>;
124
- startBindingElement: ExcalidrawBindableElement | "keep" | null;
125
- endBindingElement: ExcalidrawBindableElement | "keep" | null;
126
- hoverPointIndex: number;
127
- segmentMidPointHoveredCoords: readonly [number, number] | null;
128
- };
129
- contextMenu: {
130
- items: import("../components/ContextMenu").ContextMenuItems;
131
- top: number;
132
- left: number;
133
- } | null;
134
- showWelcomeScreen: boolean;
135
- isLoading: boolean;
136
- errorMessage: import("react").ReactNode;
137
- activeEmbeddable: {
138
- element: import("./types").NonDeletedExcalidrawElement;
139
- state: "active" | "hover";
140
- } | null;
141
- newElement: NonDeleted<import("./types").ExcalidrawNonSelectionElement> | null;
142
- resizingElement: import("./types").NonDeletedExcalidrawElement | null;
143
- multiElement: NonDeleted<ExcalidrawLinearElement> | null;
144
- selectionElement: import("./types").NonDeletedExcalidrawElement | null;
145
- isBindingEnabled: boolean;
146
- startBoundElement: NonDeleted<ExcalidrawBindableElement> | null;
147
- suggestedBindings: import("./binding").SuggestedBinding[];
148
- frameToHighlight: NonDeleted<import("./types").ExcalidrawFrameLikeElement> | null;
149
- frameRendering: {
150
- enabled: boolean;
151
- name: boolean;
152
- outline: boolean;
153
- clip: boolean;
154
- };
155
- editingFrame: string | null;
156
- elementsToHighlight: NonDeleted<ExcalidrawElement>[] | null;
157
- editingTextElement: import("./types").NonDeletedExcalidrawElement | null;
158
- activeTool: {
159
- lastActiveTool: import("../types").ActiveTool | null;
160
- locked: boolean;
161
- } & import("../types").ActiveTool;
162
- penMode: boolean;
163
- penDetected: boolean;
164
- exportBackground: boolean;
165
- exportEmbedScene: boolean;
166
- exportWithDarkMode: boolean;
167
- exportScale: number;
168
- currentItemStrokeColor: string;
169
- currentItemBackgroundColor: string;
170
- currentItemFillStyle: import("./types").FillStyle;
171
- currentItemStrokeWidth: number;
172
- currentItemStrokeStyle: import("./types").StrokeStyle;
173
- currentItemRoughness: number;
174
- currentItemOpacity: number;
175
- currentItemFontFamily: number;
176
- currentItemFontSize: number;
177
- currentItemTextAlign: string;
178
- currentItemStartArrowhead: import("./types").Arrowhead | null;
179
- currentItemEndArrowhead: import("./types").Arrowhead | null;
180
- currentHoveredFontFamily: number | null;
181
- currentItemRoundness: import("./types").StrokeRoundness;
182
- currentItemArrowType: "sharp" | "round" | "elbow";
183
- viewBackgroundColor: string;
184
- scrollX: number;
185
- scrollY: number;
186
- cursorButton: "up" | "down";
187
- scrolledOutside: boolean;
188
- name: string | null;
189
- isResizing: boolean;
190
- isRotating: boolean;
191
- zoom: Readonly<{
192
- value: import("../types").NormalizedZoomValue;
193
- }>;
194
- openMenu: "canvas" | "shape" | null;
195
- openPopup: "fontFamily" | "canvasBackground" | "elementBackground" | "elementStroke" | null;
196
- openSidebar: {
197
- name: string;
198
- tab?: string | undefined;
199
- } | null;
200
- openDialog: {
201
- name: "imageExport" | "help" | "jsonExport";
202
- } | {
203
- name: "ttd";
204
- tab: "mermaid" | "text-to-diagram";
205
- } | {
206
- name: "commandPalette";
207
- } | null;
208
- defaultSidebarDockedPreference: boolean;
209
- lastPointerDownWith: import("./types").PointerType;
210
- selectedElementIds: Readonly<{
211
- [id: string]: true;
212
- }>;
213
- previousSelectedElementIds: {
214
- [id: string]: true;
215
- };
216
- selectedElementsAreBeingDragged: boolean;
217
- shouldCacheIgnoreZoom: boolean;
218
- toast: {
219
- message: string;
220
- closable?: boolean | undefined;
221
- duration?: number | undefined;
222
- } | null;
223
- zenModeEnabled: boolean;
224
- theme: import("./types").Theme;
225
- gridSize: number;
226
- gridStep: number;
227
- gridModeEnabled: boolean;
228
- viewModeEnabled: boolean;
229
- selectedGroupIds: {
230
- [groupId: string]: boolean;
231
- };
232
- editingGroupId: string | null;
233
- width: number;
234
- height: number;
235
- offsetTop: number;
236
- offsetLeft: number;
237
- fileHandle: import("browser-fs-access").FileSystemHandle | null;
238
- collaborators: Map<import("../types").SocketId, Readonly<{
239
- pointer?: import("../types").CollaboratorPointer | undefined;
240
- button?: "up" | "down" | undefined;
241
- selectedElementIds?: Readonly<{
242
- [id: string]: true;
243
- }> | undefined;
244
- username?: string | null | undefined;
245
- userState?: import("../types").UserIdleState | undefined;
246
- color?: {
247
- background: string;
248
- stroke: string;
249
- } | undefined;
250
- avatarUrl?: string | undefined;
251
- id?: string | undefined;
252
- socketId?: import("../types").SocketId | undefined;
253
- isCurrentUser?: boolean | undefined; /** whether you're dragging a point */
254
- isInCall?: boolean | undefined;
255
- isSpeaking?: boolean | undefined;
256
- isMuted?: boolean | undefined;
257
- }>>;
258
- stats: {
259
- open: boolean;
260
- panels: number;
261
- };
262
- currentChartType: import("./types").ChartType;
263
- pasteDialog: {
264
- shown: false;
265
- data: null;
266
- } | {
267
- shown: true;
268
- data: import("../charts").Spreadsheet;
269
- };
270
- pendingImageElementId: string | null;
271
- showHyperlinkPopup: false | "info" | "editor";
272
- linkOpacity: number;
273
- trayModeEnabled: boolean;
274
- colorPalette?: {
275
- canvasBackground: import("../colors").ColorPaletteCustom;
276
- elementBackground: import("../colors").ColorPaletteCustom;
277
- elementStroke: import("../colors").ColorPaletteCustom;
278
- topPicks: {
279
- canvasBackground: [string, string, string, string, string];
280
- elementStroke: [string, string, string, string, string];
281
- elementBackground: [string, string, string, string, string];
282
- };
283
- } | undefined;
284
- allowWheelZoom?: boolean | undefined;
285
- allowPinchZoom?: boolean | undefined;
286
- pinnedScripts?: string[] | undefined;
287
- customPens?: any[] | undefined;
288
- currentStrokeOptions?: any;
289
- resetCustomPen?: any;
290
- gridColor: {
291
- Bold: string;
292
- Regular: string;
293
- };
294
- highlightSearchResult: boolean;
295
- dynamicStyle: {
296
- [x: string]: string;
297
- };
298
- frameColor: {
299
- stroke: string;
300
- fill: string;
301
- nameColor: string;
302
- };
303
- invertBindingBehaviour: boolean;
304
- selectedLinearElement: LinearElementEditor | null;
305
- snapLines: readonly import("../snapping").SnapLine[];
306
- originSnapOffset: {
307
- x: number;
308
- y: number;
309
- } | null;
310
- objectsSnapModeEnabled: boolean;
311
- userToFollow: import("../types").UserToFollow | null;
312
- followedBy: Set<import("../types").SocketId>;
313
- };
314
- };
97
+ static duplicateSelectedPoints(appState: AppState, elementsMap: NonDeletedSceneElementsMap | SceneElementsMap): AppState;
315
98
  static deletePoints(element: NonDeleted<ExcalidrawLinearElement>, pointIndices: readonly number[], elementsMap: NonDeletedSceneElementsMap | SceneElementsMap): void;
316
99
  static addPoints(element: NonDeleted<ExcalidrawLinearElement>, targetPoints: {
317
- point: Point;
100
+ point: LocalPoint;
318
101
  }[], elementsMap: NonDeletedSceneElementsMap | SceneElementsMap): void;
319
102
  static movePoints(element: NonDeleted<ExcalidrawLinearElement>, targetPoints: {
320
103
  index: number;
321
- point: Point;
104
+ point: LocalPoint;
322
105
  isDragging?: boolean;
323
106
  }[], elementsMap: NonDeletedSceneElementsMap | SceneElementsMap, otherUpdates?: {
324
107
  startBinding?: PointBinding | null;
@@ -1,10 +1,9 @@
1
1
  import type { ExcalidrawLinearElement, ExcalidrawTextElement, NonDeletedExcalidrawElement, NonDeleted, ElementsMap, NonDeletedSceneElementsMap, SceneElementsMap } from "./types";
2
2
  import type { MaybeTransformHandleType, TransformHandleDirection } from "./transformHandles";
3
3
  import type { PointerDownState } from "../types";
4
- export declare const normalizeAngle: (angle: number) => number;
5
4
  export declare const transformElements: (originalElements: PointerDownState["originalElements"], transformHandleType: MaybeTransformHandleType, selectedElements: readonly NonDeletedExcalidrawElement[], elementsMap: SceneElementsMap, shouldRotateWithDiscreteAngle: boolean, shouldResizeFromCenter: boolean, shouldMaintainAspectRatio: boolean, pointerX: number, pointerY: number, centerX: number, centerY: number) => boolean;
6
5
  export declare const rescalePointsInElement: (element: NonDeletedExcalidrawElement, width: number, height: number, normalizePoints: boolean) => {
7
- points: (readonly [number, number])[];
6
+ points: import("../../math").LocalPoint[];
8
7
  } | {
9
8
  points?: undefined;
10
9
  };
@@ -2,12 +2,13 @@ import type { ExcalidrawElement, PointerType, NonDeletedExcalidrawElement, Eleme
2
2
  import type { MaybeTransformHandleType } from "./transformHandles";
3
3
  import type { AppState, Device, Zoom } from "../types";
4
4
  import type { Bounds } from "./bounds";
5
- export declare const resizeTest: (element: NonDeletedExcalidrawElement, elementsMap: ElementsMap, appState: AppState, x: number, y: number, zoom: Zoom, pointerType: PointerType, device: Device) => MaybeTransformHandleType;
5
+ import type { GlobalPoint, LocalPoint } from "../../math";
6
+ export declare const resizeTest: <Point extends GlobalPoint | LocalPoint>(element: NonDeletedExcalidrawElement, elementsMap: ElementsMap, appState: AppState, x: number, y: number, zoom: Zoom, pointerType: PointerType, device: Device) => MaybeTransformHandleType;
6
7
  export declare const getElementWithTransformHandleType: (elements: readonly NonDeletedExcalidrawElement[], appState: AppState, scenePointerX: number, scenePointerY: number, zoom: Zoom, pointerType: PointerType, elementsMap: ElementsMap, device: Device) => {
7
8
  element: NonDeletedExcalidrawElement;
8
9
  transformHandleType: MaybeTransformHandleType;
9
10
  } | null;
10
- export declare const getTransformHandleTypeFromCoords: ([x1, y1, x2, y2]: Bounds, scenePointerX: number, scenePointerY: number, zoom: Zoom, pointerType: PointerType, device: Device) => MaybeTransformHandleType;
11
+ export declare const getTransformHandleTypeFromCoords: <Point extends GlobalPoint | LocalPoint>([x1, y1, x2, y2]: Bounds, scenePointerX: number, scenePointerY: number, zoom: Zoom, pointerType: PointerType, device: Device) => MaybeTransformHandleType;
11
12
  export declare const getCursorForResizingElement: (resizingElement: {
12
13
  element?: ExcalidrawElement;
13
14
  transformHandleType: MaybeTransformHandleType;
@@ -1,6 +1,6 @@
1
- import type { Point } from "../types";
1
+ import { type LocalPoint, type Vector } from "../../math";
2
2
  import type { ExcalidrawElbowArrowElement, FixedPointBinding, NonDeletedSceneElementsMap, SceneElementsMap } from "./types";
3
- export declare const mutateElbowArrow: (arrow: ExcalidrawElbowArrowElement, elementsMap: NonDeletedSceneElementsMap | SceneElementsMap, nextPoints: readonly Point[], offset?: Point, otherUpdates?: {
3
+ export declare const mutateElbowArrow: (arrow: ExcalidrawElbowArrowElement, elementsMap: NonDeletedSceneElementsMap | SceneElementsMap, nextPoints: readonly LocalPoint[], offset?: Vector, otherUpdates?: {
4
4
  startBinding?: FixedPointBinding | null;
5
5
  endBinding?: FixedPointBinding | null;
6
6
  }, options?: {
@@ -49,7 +49,7 @@ export declare const getContainerCoords: (container: NonDeletedExcalidrawElement
49
49
  x: number;
50
50
  y: number;
51
51
  };
52
- export declare const getTextElementAngle: (textElement: ExcalidrawTextElement, container: ExcalidrawTextContainer | null) => number;
52
+ export declare const getTextElementAngle: (textElement: ExcalidrawTextElement, container: ExcalidrawTextContainer | null) => import("../../math").Radians;
53
53
  export declare const getBoundTextElementPosition: (container: ExcalidrawElement, boundTextElement: ExcalidrawTextElementWithContainer, elementsMap: ElementsMap) => {
54
54
  x: number;
55
55
  y: number;
@@ -1,6 +1,7 @@
1
1
  import type { ElementsMap, ExcalidrawElement, NonDeletedExcalidrawElement, PointerType } from "./types";
2
2
  import type { Bounds } from "./bounds";
3
3
  import type { Device, InteractiveCanvasAppState, Zoom } from "../types";
4
+ import type { Radians } from "../../math";
4
5
  export type TransformHandleDirection = "n" | "s" | "w" | "e" | "nw" | "ne" | "sw" | "se";
5
6
  export type TransformHandleType = TransformHandleDirection | "rotation";
6
7
  export type TransformHandle = Bounds;
@@ -29,9 +30,9 @@ export declare const OMIT_SIDES_FOR_FRAME: {
29
30
  };
30
31
  export declare const canResizeFromSides: (device: Device) => boolean;
31
32
  export declare const getOmitSidesForDevice: (device: Device) => {};
32
- export declare const getTransformHandlesFromCoords: ([x1, y1, x2, y2, cx, cy]: [number, number, number, number, number, number], angle: number, zoom: Zoom, pointerType: PointerType, omitSides?: {
33
- s?: boolean | undefined;
33
+ export declare const getTransformHandlesFromCoords: ([x1, y1, x2, y2, cx, cy]: [number, number, number, number, number, number], angle: Radians, zoom: Zoom, pointerType: PointerType, omitSides?: {
34
34
  e?: boolean | undefined;
35
+ s?: boolean | undefined;
35
36
  w?: boolean | undefined;
36
37
  n?: boolean | undefined;
37
38
  nw?: boolean | undefined;
@@ -41,8 +42,8 @@ export declare const getTransformHandlesFromCoords: ([x1, y1, x2, y2, cx, cy]: [
41
42
  rotation?: boolean | undefined;
42
43
  }, margin?: number) => TransformHandles;
43
44
  export declare const getTransformHandles: (element: ExcalidrawElement, zoom: Zoom, elementsMap: ElementsMap, pointerType?: PointerType, omitSides?: {
44
- s?: boolean | undefined;
45
45
  e?: boolean | undefined;
46
+ s?: boolean | undefined;
46
47
  w?: boolean | undefined;
47
48
  n?: boolean | undefined;
48
49
  nw?: boolean | undefined;
@@ -1,4 +1,3 @@
1
- import type { LineSegment } from "../../utils";
2
1
  import type { ElementOrToolType } from "../types";
3
2
  import type { MarkNonNullable } from "../utility-types";
4
3
  import type { Bounds } from "./bounds";
@@ -37,6 +36,4 @@ export declare const getDefaultRoundnessTypeForElement: (element: ExcalidrawElem
37
36
  type: 3;
38
37
  } | null;
39
38
  export declare const isFixedPointBinding: (binding: PointBinding) => binding is FixedPointBinding;
40
- export declare const isPoint: (point: unknown) => point is readonly [number, number];
41
39
  export declare const isBounds: (box: unknown) => box is Bounds;
42
- export declare const isLineSegment: (segment: unknown) => segment is LineSegment;
@@ -1,4 +1,4 @@
1
- import type { Point } from "../types";
1
+ import type { LocalPoint, Radians } from "../../math";
2
2
  import type { FONT_FAMILY, ROUNDNESS, TEXT_ALIGN, THEME, VERTICAL_ALIGN } from "../constants";
3
3
  import type { MakeBrand, MarkNonNullable, Merge, ValueOf } from "../utility-types";
4
4
  export type ChartType = "bar" | "line";
@@ -41,7 +41,7 @@ type _ExcalidrawElementBase = Readonly<{
41
41
  opacity: number;
42
42
  width: number;
43
43
  height: number;
44
- angle: number;
44
+ angle: Radians;
45
45
  /** Random integer used to seed shape generation so that the roughjs shape
46
46
  doesn't differ across renders. */
47
47
  seed: number;
@@ -143,6 +143,7 @@ export type ExcalidrawFrameLikeElement = ExcalidrawFrameElement | ExcalidrawMagi
143
143
  */
144
144
  export type ExcalidrawGenericElement = ExcalidrawSelectionElement | ExcalidrawRectangleElement | ExcalidrawDiamondElement | ExcalidrawEllipseElement;
145
145
  export type ExcalidrawFlowchartNodeElement = ExcalidrawRectangleElement | ExcalidrawDiamondElement | ExcalidrawEllipseElement;
146
+ export type ExcalidrawRectanguloidElement = ExcalidrawRectangleElement | ExcalidrawImageElement | ExcalidrawTextElement | ExcalidrawFreeDrawElement | ExcalidrawIframeLikeElement | ExcalidrawFrameLikeElement | ExcalidrawEmbeddableElement;
146
147
  /**
147
148
  * ExcalidrawElement should be JSON serializable and (eventually) contain
148
149
  * no computed data. The list of all ExcalidrawElements should be shareable
@@ -201,8 +202,8 @@ export type FixedPointBinding = Merge<PointBinding, {
201
202
  export type Arrowhead = "arrow" | "bar" | "dot" | "circle" | "circle_outline" | "triangle" | "triangle_outline" | "diamond" | "diamond_outline";
202
203
  export type ExcalidrawLinearElement = _ExcalidrawElementBase & Readonly<{
203
204
  type: "line" | "arrow";
204
- points: readonly Point[];
205
- lastCommittedPoint: Point | null;
205
+ points: readonly LocalPoint[];
206
+ lastCommittedPoint: LocalPoint | null;
206
207
  startBinding: PointBinding | null;
207
208
  endBinding: PointBinding | null;
208
209
  startArrowhead: Arrowhead | null;
@@ -219,10 +220,10 @@ export type ExcalidrawElbowArrowElement = Merge<ExcalidrawArrowElement, {
219
220
  }>;
220
221
  export type ExcalidrawFreeDrawElement = _ExcalidrawElementBase & Readonly<{
221
222
  type: "freedraw";
222
- points: readonly Point[];
223
+ points: readonly LocalPoint[];
223
224
  pressures: readonly number[];
224
225
  simulatePressure: boolean;
225
- lastCommittedPoint: Point | null;
226
+ lastCommittedPoint: LocalPoint | null;
226
227
  }>;
227
228
  export type FileId = string & {
228
229
  _brand: "FileId";
@@ -15,3 +15,4 @@ export declare function registerLocalFont(fontMetrics: FontMetadata & {
15
15
  export declare function getFontFamilies(): string[];
16
16
  export declare function registerFontsInCSS(): Promise<void>;
17
17
  export declare function getCSSFontDefinition(fontFamily: number): Promise<string>;
18
+ export declare function getArrayBufferFromBase64(url: string): ArrayBuffer;
@@ -1,7 +1,7 @@
1
- import type { Point } from "./types";
2
- export declare const getSizeFromPoints: (points: readonly Point[]) => {
1
+ import { type GlobalPoint, type LocalPoint } from "../math";
2
+ export declare const getSizeFromPoints: (points: readonly (GlobalPoint | LocalPoint)[]) => {
3
3
  width: number;
4
4
  height: number;
5
5
  };
6
6
  /** @arg dimension, 0 for rescaling only x, 1 for y */
7
- export declare const rescalePoints: (dimension: 0 | 1, newSize: number, points: readonly Point[], normalize: boolean) => Point[];
7
+ export declare const rescalePoints: <Point extends GlobalPoint | LocalPoint>(dimension: 0 | 1, newSize: number, points: readonly Point[], normalize: boolean) => Point[];
@@ -1,5 +1,8 @@
1
+ import { type GlobalPoint, type LocalPoint } from "../math";
1
2
  import { type GeometricShape } from "../utils/geometry/shape";
2
- import type { ElementsMap, ExcalidrawElement } from "./element/types";
3
+ import type { Bounds } from "./element/bounds";
4
+ import type { ElementsMap, ExcalidrawElement, ExcalidrawLinearElement, NonDeleted } from "./element/types";
5
+ import type { Zoom } from "./types";
3
6
  export declare const SHAPES: readonly [{
4
7
  readonly icon: JSX.Element;
5
8
  readonly value: "selection";
@@ -61,10 +64,22 @@ export declare const SHAPES: readonly [{
61
64
  readonly numericKey: "0";
62
65
  readonly fillable: false;
63
66
  }];
64
- export declare const findShapeByKey: (key: string) => "text" | "image" | "selection" | "rectangle" | "diamond" | "ellipse" | "arrow" | "line" | "freedraw" | "eraser" | null;
67
+ export declare const findShapeByKey: (key: string) => "line" | "text" | "arrow" | "diamond" | "selection" | "rectangle" | "ellipse" | "freedraw" | "image" | "eraser" | null;
65
68
  /**
66
69
  * get the pure geometric shape of an excalidraw element
67
70
  * which is then used for hit detection
68
71
  */
69
- export declare const getElementShape: (element: ExcalidrawElement, elementsMap: ElementsMap) => GeometricShape;
70
- export declare const getBoundTextShape: (element: ExcalidrawElement, elementsMap: ElementsMap) => GeometricShape | null;
72
+ export declare const getElementShape: <Point extends GlobalPoint | LocalPoint>(element: ExcalidrawElement, elementsMap: ElementsMap) => GeometricShape<Point>;
73
+ export declare const getBoundTextShape: <Point extends GlobalPoint | LocalPoint>(element: ExcalidrawElement, elementsMap: ElementsMap) => GeometricShape<Point> | null;
74
+ export declare const getControlPointsForBezierCurve: <P extends GlobalPoint | LocalPoint>(element: NonDeleted<ExcalidrawLinearElement>, endPoint: P) => P[] | null;
75
+ export declare const getBezierXY: <P extends GlobalPoint | LocalPoint>(p0: P, p1: P, p2: P, p3: P, t: number) => P;
76
+ export declare const getBezierCurveLength: <P extends GlobalPoint | LocalPoint>(element: NonDeleted<ExcalidrawLinearElement>, endPoint: P) => number;
77
+ export declare const mapIntervalToBezierT: <P extends GlobalPoint | LocalPoint>(element: NonDeleted<ExcalidrawLinearElement>, endPoint: P, interval: number) => number;
78
+ /**
79
+ * Get the axis-aligned bounding box for a given element
80
+ */
81
+ export declare const aabbForElement: (element: Readonly<ExcalidrawElement>, offset?: [number, number, number, number]) => Bounds;
82
+ export declare const pointInsideBounds: <P extends GlobalPoint | LocalPoint>(p: P, bounds: Bounds) => boolean;
83
+ export declare const aabbsOverlapping: (a: Bounds, b: Bounds) => boolean;
84
+ export declare const getCornerRadius: (x: number, element: ExcalidrawElement) => number;
85
+ export declare const isPathALoop: (points: ExcalidrawLinearElement["points"], zoomValue?: Zoom["value"]) => boolean;
@@ -1,13 +1,15 @@
1
+ import type { InclusiveRange } from "../math";
2
+ import { type GlobalPoint } from "../math";
1
3
  import type { Bounds } from "./element/bounds";
2
4
  import type { MaybeTransformHandleType } from "./element/transformHandles";
3
5
  import type { ElementsMap, ExcalidrawElement, NonDeletedExcalidrawElement } from "./element/types";
4
- import type { AppClassProperties, AppState, KeyboardModifiersObject, Point } from "./types";
6
+ import type { AppClassProperties, AppState, KeyboardModifiersObject, NullableGridSize } from "./types";
5
7
  export declare const getSnapDistance: (zoomValue: number) => number;
6
8
  type Vector2D = {
7
9
  x: number;
8
10
  y: number;
9
11
  };
10
- type PointPair = [Point, Point];
12
+ type PointPair = [GlobalPoint, GlobalPoint];
11
13
  export type PointSnap = {
12
14
  type: "point";
13
15
  points: PointPair;
@@ -16,9 +18,9 @@ export type PointSnap = {
16
18
  export type Gap = {
17
19
  startBounds: Bounds;
18
20
  endBounds: Bounds;
19
- startSide: [Point, Point];
20
- endSide: [Point, Point];
21
- overlap: [number, number];
21
+ startSide: [GlobalPoint, GlobalPoint];
22
+ endSide: [GlobalPoint, GlobalPoint];
23
+ overlap: InclusiveRange;
22
24
  length: number;
23
25
  };
24
26
  export type GapSnap = {
@@ -32,7 +34,7 @@ export type Snap = GapSnap | PointSnap;
32
34
  export type Snaps = Snap[];
33
35
  export type PointSnapLine = {
34
36
  type: "points";
35
- points: Point[];
37
+ points: GlobalPoint[];
36
38
  };
37
39
  export type PointerSnapLine = {
38
40
  type: "pointer";
@@ -48,8 +50,8 @@ export type SnapLine = PointSnapLine | GapSnapLine | PointerSnapLine;
48
50
  export declare class SnapCache {
49
51
  private static referenceSnapPoints;
50
52
  private static visibleGaps;
51
- static setReferenceSnapPoints: (snapPoints: Point[] | null) => void;
52
- static getReferenceSnapPoints: () => (readonly [number, number])[] | null;
53
+ static setReferenceSnapPoints: (snapPoints: GlobalPoint[] | null) => void;
54
+ static getReferenceSnapPoints: () => GlobalPoint[] | null;
53
55
  static setVisibleGaps: (gaps: {
54
56
  verticalGaps: Gap[];
55
57
  horizontalGaps: Gap[];
@@ -71,12 +73,12 @@ export declare const getElementsCorners: (elements: ExcalidrawElement[], element
71
73
  omitCenter?: boolean | undefined;
72
74
  boundingBoxCorners?: boolean | undefined;
73
75
  dragOffset?: Vector2D | undefined;
74
- }) => Point[];
76
+ }) => GlobalPoint[];
75
77
  export declare const getVisibleGaps: (elements: readonly NonDeletedExcalidrawElement[], selectedElements: ExcalidrawElement[], appState: AppState, elementsMap: ElementsMap) => {
76
78
  horizontalGaps: Gap[];
77
79
  verticalGaps: Gap[];
78
80
  };
79
- export declare const getReferenceSnapPoints: (elements: readonly NonDeletedExcalidrawElement[], selectedElements: ExcalidrawElement[], appState: AppState, elementsMap: ElementsMap) => (readonly [number, number])[];
81
+ export declare const getReferenceSnapPoints: (elements: readonly NonDeletedExcalidrawElement[], selectedElements: ExcalidrawElement[], appState: AppState, elementsMap: ElementsMap) => GlobalPoint[];
80
82
  export declare const snapDraggedElements: (elements: ExcalidrawElement[], dragOffset: Vector2D, app: AppClassProperties, event: KeyboardModifiersObject, elementsMap: ElementsMap) => {
81
83
  snapOffset: {
82
84
  x: number;
@@ -106,4 +108,5 @@ export declare const getSnapLinesAtPointer: (elements: readonly ExcalidrawElemen
106
108
  snapLines: PointerSnapLine[];
107
109
  };
108
110
  export declare const isActiveToolNonLinearSnappable: (activeToolType: AppState["activeTool"]["type"]) => boolean;
111
+ export declare const getGridPoint: (x: number, y: number, gridSize: NullableGridSize) => [number, number];
109
112
  export {};
@@ -1,7 +1,6 @@
1
1
  import type React from "react";
2
2
  import type { PointerType, ExcalidrawLinearElement, NonDeletedExcalidrawElement, NonDeleted, TextAlign, ExcalidrawElement, GroupId, ExcalidrawBindableElement, Arrowhead, ChartType, FontFamilyValues, ExcalidrawTextElement, FileId, ExcalidrawImageElement, Theme, StrokeRoundness, ExcalidrawEmbeddableElement, ExcalidrawMagicFrameElement, ExcalidrawFrameLikeElement, ExcalidrawElementType, ExcalidrawIframeLikeElement, OrderedExcalidrawElement, ExcalidrawNonSelectionElement } from "./element/types";
3
3
  import type { Action } from "./actions/types";
4
- import type { Point as RoughPoint } from "roughjs/bin/geometry";
5
4
  import type { LinearElementEditor } from "./element/linearElementEditor";
6
5
  import type { SuggestedBinding } from "./element/binding";
7
6
  import type { ImportedDataState } from "./data/types";
@@ -20,7 +19,6 @@ import type { SnapLine } from "./snapping";
20
19
  import type { Merge, MaybePromise, ValueOf, MakeBrand } from "./utility-types";
21
20
  import type { ColorPaletteCustom } from "./colors";
22
21
  import type { StoreActionType } from "./store";
23
- export type Point = Readonly<RoughPoint>;
24
22
  export type SocketId = string & {
25
23
  _brand: "SocketId";
26
24
  };
@@ -6,9 +6,9 @@ export declare const setDateTimeForTests: (dateTime: string) => void;
6
6
  export declare const getDateTime: () => string;
7
7
  export declare const capitalizeString: (str: string) => string;
8
8
  export declare const isToolIcon: (target: Element | EventTarget | null) => target is HTMLElement;
9
- export declare const isInputLike: (target: Element | EventTarget | null) => target is HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement | HTMLBRElement | HTMLDivElement;
9
+ export declare const isInputLike: (target: Element | EventTarget | null) => target is HTMLBRElement | HTMLDivElement | HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement;
10
10
  export declare const isInteractive: (target: Element | EventTarget | null) => boolean;
11
- export declare const isWritableElement: (target: Element | EventTarget | null) => target is HTMLInputElement | HTMLTextAreaElement | HTMLBRElement | HTMLDivElement;
11
+ export declare const isWritableElement: (target: Element | EventTarget | null) => target is HTMLBRElement | HTMLDivElement | HTMLInputElement | HTMLTextAreaElement;
12
12
  export declare const getFontFamilyString: ({ fontFamily, }: {
13
13
  fontFamily: FontFamilyValues;
14
14
  }) => string;
@@ -182,7 +182,7 @@ export declare const wrapEvent: <T extends Event>(name: EVENT, nativeEvent: T) =
182
182
  }>;
183
183
  export declare const updateObject: <T extends Record<string, any>>(obj: T, updates: Partial<T>) => T;
184
184
  export declare const isPrimitive: (val: any) => boolean;
185
- export declare const getFrame: () => "top" | "iframe";
185
+ export declare const getFrame: () => "iframe" | "top";
186
186
  export declare const isRunningInIframe: () => boolean;
187
187
  export declare const isPromiseLike: (value: any) => value is Promise<any>;
188
188
  export declare const queryFocusableElements: (container: HTMLElement | null) => HTMLElement[];
@@ -213,7 +213,6 @@ export declare const memoize: <T extends Record<string, any>, R extends unknown>
213
213
  /** Checks if value is inside given collection. Useful for type-safety. */
214
214
  export declare const isMemberOf: <T extends string>(collection: Set<T> | Record<T, any> | Map<T, any> | readonly T[], value: string) => value is T;
215
215
  export declare const cloneJSON: <T>(obj: T) => T;
216
- export declare const isFiniteNumber: (value: any) => value is number;
217
216
  export declare const updateStable: <T extends any[] | Record<string, any>>(prevValue: T, nextValue: T) => T;
218
217
  export declare function addEventListener<K extends keyof WindowEventMap>(target: Window & typeof globalThis, type: K, listener: (this: Window, ev: WindowEventMap[K]) => any, options?: boolean | AddEventListenerOptions): UnsubscribeCallback;
219
218
  export declare function addEventListener(target: Window & typeof globalThis, type: string, listener: (this: Window, ev: Event) => any, options?: boolean | AddEventListenerOptions): UnsubscribeCallback;