@excalidraw/math 0.18.0-4ce38fb → 0.18.0-4ce8305

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 (82) hide show
  1. package/dist/types/common/src/utils.d.ts +7 -1
  2. package/dist/types/element/src/align.d.ts +4 -1
  3. package/dist/types/element/src/binding.d.ts +36 -0
  4. package/dist/types/element/src/bounds.d.ts +10 -2
  5. package/dist/types/element/src/collision.d.ts +7 -0
  6. package/dist/types/element/src/cropElement.d.ts +36 -4
  7. package/dist/types/element/src/delta.d.ts +7 -1
  8. package/dist/types/element/src/distribute.d.ts +4 -1
  9. package/dist/types/element/src/dragElements.d.ts +8 -3
  10. package/dist/types/element/src/elbowArrow.d.ts +5 -0
  11. package/dist/types/element/src/embeddable.d.ts +2 -1
  12. package/dist/types/element/src/groups.d.ts +1 -6
  13. package/dist/types/element/src/image.d.ts +5 -2
  14. package/dist/types/element/src/index.d.ts +1 -0
  15. package/dist/types/element/src/linearElementEditor.d.ts +4 -1
  16. package/dist/types/element/src/listMarker.d.ts +7 -2
  17. package/dist/types/element/src/newElement.d.ts +3 -1
  18. package/dist/types/element/src/renderElement.d.ts +10 -0
  19. package/dist/types/element/src/renderEnvironment.d.ts +66 -0
  20. package/dist/types/element/src/resizeElements.d.ts +15 -5
  21. package/dist/types/element/src/selection.d.ts +1 -7
  22. package/dist/types/element/src/shape.d.ts +2 -0
  23. package/dist/types/element/src/stickyNote.d.ts +8 -0
  24. package/dist/types/element/src/textElement.d.ts +3 -2
  25. package/dist/types/element/src/textMeasurements.d.ts +15 -11
  26. package/dist/types/element/src/textWrapping.d.ts +3 -2
  27. package/dist/types/element/src/transform.d.ts +5 -1
  28. package/dist/types/excalidraw/actions/actionBoundText.d.ts +46 -221
  29. package/dist/types/excalidraw/actions/actionCanvas.d.ts +6 -6
  30. package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +4 -588
  31. package/dist/types/excalidraw/actions/actionDeselect.d.ts +1 -1
  32. package/dist/types/excalidraw/actions/actionExport.d.ts +7 -7
  33. package/dist/types/excalidraw/actions/actionFrame.d.ts +41 -525
  34. package/dist/types/excalidraw/actions/actionGroup.d.ts +2 -2
  35. package/dist/types/excalidraw/actions/actionSelectAll.d.ts +1 -1
  36. package/dist/types/excalidraw/actions/actionToggleWrap.d.ts +12 -0
  37. package/dist/types/excalidraw/actions/index.d.ts +1 -0
  38. package/dist/types/excalidraw/actions/shortcuts.d.ts +1 -1
  39. package/dist/types/excalidraw/actions/types.d.ts +1 -1
  40. package/dist/types/excalidraw/appState.d.ts +7 -7
  41. package/dist/types/excalidraw/charts/charts.bar.d.ts +2 -1
  42. package/dist/types/excalidraw/charts/charts.helpers.d.ts +6 -5
  43. package/dist/types/excalidraw/charts/charts.line.d.ts +2 -1
  44. package/dist/types/excalidraw/charts/charts.radar.d.ts +2 -1
  45. package/dist/types/excalidraw/charts/index.d.ts +2 -1
  46. package/dist/types/excalidraw/components/App.d.ts +34 -20
  47. package/dist/types/excalidraw/components/App.host.d.ts +102 -0
  48. package/dist/types/excalidraw/components/App.modifiers.d.ts +38 -0
  49. package/dist/types/excalidraw/components/App.selection.d.ts +265 -0
  50. package/dist/types/excalidraw/components/App.selectionTool.d.ts +93 -0
  51. package/dist/types/excalidraw/components/App.viewport.d.ts +13 -3
  52. package/dist/types/excalidraw/components/App.wrap.d.ts +31 -0
  53. package/dist/types/excalidraw/components/ConvertElementTypePopup.d.ts +2 -1
  54. package/dist/types/excalidraw/components/Stats/utils.d.ts +4 -2
  55. package/dist/types/excalidraw/components/TTDDialog/MermaidToExcalidraw.d.ts +2 -1
  56. package/dist/types/excalidraw/components/TTDDialog/TTDDialogOutput.d.ts +5 -2
  57. package/dist/types/excalidraw/components/TTDDialog/TTDPreviewPanel.d.ts +5 -2
  58. package/dist/types/excalidraw/components/TTDDialog/TextToDiagram.d.ts +2 -1
  59. package/dist/types/excalidraw/components/TTDDialog/common.d.ts +4 -1
  60. package/dist/types/excalidraw/components/TTDDialog/hooks/useTextGeneration.d.ts +3 -2
  61. package/dist/types/excalidraw/components/TTDDialog/types.d.ts +14 -1
  62. package/dist/types/excalidraw/components/TTDDialog/utils/mermaidError.d.ts +27 -1
  63. package/dist/types/excalidraw/components/Tooltip.d.ts +11 -1
  64. package/dist/types/excalidraw/components/TopPicksDnD/topPicksDnD.d.ts +1 -1
  65. package/dist/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +0 -1
  66. package/dist/types/excalidraw/components/hyperlink/Hyperlink.d.ts +3 -2
  67. package/dist/types/excalidraw/components/hyperlink/helpers.d.ts +13 -2
  68. package/dist/types/excalidraw/data/blob.d.ts +14 -14
  69. package/dist/types/excalidraw/data/index.d.ts +3 -3
  70. package/dist/types/excalidraw/data/json.d.ts +7 -7
  71. package/dist/types/excalidraw/fonts/Fonts.d.ts +9 -6
  72. package/dist/types/excalidraw/history.d.ts +10 -4
  73. package/dist/types/excalidraw/reactUtils.d.ts +1 -1
  74. package/dist/types/excalidraw/renderer/animation.d.ts +11 -4
  75. package/dist/types/excalidraw/renderer/staticScene.d.ts +11 -6
  76. package/dist/types/excalidraw/scene/Renderer.d.ts +1 -1
  77. package/dist/types/excalidraw/scene/export.d.ts +343 -20
  78. package/dist/types/excalidraw/scene/types.d.ts +23 -1
  79. package/dist/types/excalidraw/types.d.ts +49 -1
  80. package/dist/types/utils/src/index.d.ts +3 -1
  81. package/package.json +2 -2
  82. package/dist/types/utils/src/export.d.ts +0 -36
@@ -0,0 +1,265 @@
1
+ import { LinearElementEditor } from "@excalidraw/element";
2
+ import type { ExcalidrawElement, NonDeletedExcalidrawElement } from "@excalidraw/element/types";
3
+ import type { Mutable } from "@excalidraw/common/utility-types";
4
+ import type { CaptureUpdateActionType } from "@excalidraw/element";
5
+ import type { AppClassProperties, AppState, InteractiveCanvasAppState } from "../types";
6
+ import type App from "./App";
7
+ export declare const selectGroupsForSelectedElements: {
8
+ (appState: Pick<AppState, "selectedElementIds" | "editingGroupId">, elements: readonly NonDeletedExcalidrawElement[], prevAppState: InteractiveCanvasAppState, app: AppClassProperties | null): Mutable<Pick<InteractiveCanvasAppState, "selectedGroupIds" | "editingGroupId" | "selectedElementIds">>;
9
+ clearCache(): void;
10
+ };
11
+ /**
12
+ * The selection of the given elements alone, with their groups (within the
13
+ * edited group): a frame wins over its children, bound text is left to its
14
+ * container, and a lone line or arrow gets its line editor.
15
+ *
16
+ * @param allElements the (non-deleted) elements the selection is in
17
+ * @param deep select the elements themselves rather than their groups,
18
+ * editing their innermost group if they share it (and no group otherwise)
19
+ * — as Ctrl+click does
20
+ */
21
+ export declare const getSelectionStateForElements: (targetElements: readonly NonDeletedExcalidrawElement[], allElements: readonly NonDeletedExcalidrawElement[], appState: AppState, deep?: boolean) => Mutable<Pick<Readonly<{
22
+ zoom: AppState["zoom"];
23
+ scrollX: AppState["scrollX"];
24
+ scrollY: AppState["scrollY"];
25
+ width: AppState["width"];
26
+ height: AppState["height"];
27
+ viewModeEnabled: AppState["viewModeEnabled"];
28
+ openDialog: AppState["openDialog"];
29
+ editingGroupId: AppState["editingGroupId"];
30
+ selectedElementIds: AppState["selectedElementIds"];
31
+ frameToHighlight: AppState["frameToHighlight"];
32
+ offsetLeft: AppState["offsetLeft"];
33
+ offsetTop: AppState["offsetTop"];
34
+ theme: AppState["theme"];
35
+ } & {
36
+ activeTool: AppState["activeTool"];
37
+ activeEmbeddable: AppState["activeEmbeddable"];
38
+ selectionElement: AppState["selectionElement"];
39
+ selectedGroupIds: AppState["selectedGroupIds"];
40
+ selectedLinearElement: AppState["selectedLinearElement"];
41
+ multiElement: AppState["multiElement"];
42
+ newElement: AppState["newElement"];
43
+ isBindingEnabled: AppState["isBindingEnabled"];
44
+ isMidpointSnappingEnabled: AppState["isMidpointSnappingEnabled"];
45
+ gridModeEnabled: AppState["gridModeEnabled"];
46
+ suggestedBinding: AppState["suggestedBinding"];
47
+ textToolHover: AppState["textToolHover"];
48
+ isRotating: AppState["isRotating"];
49
+ elementsToHighlight: AppState["elementsToHighlight"];
50
+ collaborators: AppState["collaborators"];
51
+ snapLines: AppState["snapLines"];
52
+ zenModeEnabled: AppState["zenModeEnabled"];
53
+ editingTextElement: AppState["editingTextElement"];
54
+ isCropping: AppState["isCropping"];
55
+ croppingElementId: AppState["croppingElementId"];
56
+ searchMatches: AppState["searchMatches"];
57
+ activeLockedId: AppState["activeLockedId"];
58
+ hoveredElementIds: AppState["hoveredElementIds"];
59
+ frameRendering: AppState["frameRendering"];
60
+ shouldCacheIgnoreZoom: AppState["shouldCacheIgnoreZoom"];
61
+ exportScale: AppState["exportScale"];
62
+ currentItemArrowType: AppState["currentItemArrowType"];
63
+ }>, "selectedElementIds" | "editingGroupId" | "selectedGroupIds">> & {
64
+ selectedLinearElement: LinearElementEditor | null;
65
+ };
66
+ /**
67
+ * The selection with the given elements added, with their groups (within the
68
+ * edited group) — and the line editor of a lone selected line or arrow.
69
+ *
70
+ * A frame and its children aren't selected at the same time: an added frame
71
+ * deselects its children, an added child of a selected (or added) frame is
72
+ * left out, and adding elements grouped with frames deselects those frames'
73
+ * children (and leaves the added ones out). In the element link selector, the
74
+ * added elements replace the selection (unless one's group is selected).
75
+ *
76
+ * @param allElements the (non-deleted) elements the selection is in
77
+ */
78
+ export declare const getSelectionStateAddingElements: (targetElements: readonly NonDeletedExcalidrawElement[], allElements: readonly NonDeletedExcalidrawElement[], appState: AppState) => Mutable<Pick<Readonly<{
79
+ zoom: AppState["zoom"];
80
+ scrollX: AppState["scrollX"];
81
+ scrollY: AppState["scrollY"];
82
+ width: AppState["width"];
83
+ height: AppState["height"];
84
+ viewModeEnabled: AppState["viewModeEnabled"];
85
+ openDialog: AppState["openDialog"];
86
+ editingGroupId: AppState["editingGroupId"];
87
+ selectedElementIds: AppState["selectedElementIds"];
88
+ frameToHighlight: AppState["frameToHighlight"];
89
+ offsetLeft: AppState["offsetLeft"];
90
+ offsetTop: AppState["offsetTop"];
91
+ theme: AppState["theme"];
92
+ } & {
93
+ activeTool: AppState["activeTool"];
94
+ activeEmbeddable: AppState["activeEmbeddable"];
95
+ selectionElement: AppState["selectionElement"];
96
+ selectedGroupIds: AppState["selectedGroupIds"];
97
+ selectedLinearElement: AppState["selectedLinearElement"];
98
+ multiElement: AppState["multiElement"];
99
+ newElement: AppState["newElement"];
100
+ isBindingEnabled: AppState["isBindingEnabled"];
101
+ isMidpointSnappingEnabled: AppState["isMidpointSnappingEnabled"];
102
+ gridModeEnabled: AppState["gridModeEnabled"];
103
+ suggestedBinding: AppState["suggestedBinding"];
104
+ textToolHover: AppState["textToolHover"];
105
+ isRotating: AppState["isRotating"];
106
+ elementsToHighlight: AppState["elementsToHighlight"];
107
+ collaborators: AppState["collaborators"];
108
+ snapLines: AppState["snapLines"];
109
+ zenModeEnabled: AppState["zenModeEnabled"];
110
+ editingTextElement: AppState["editingTextElement"];
111
+ isCropping: AppState["isCropping"];
112
+ croppingElementId: AppState["croppingElementId"];
113
+ searchMatches: AppState["searchMatches"];
114
+ activeLockedId: AppState["activeLockedId"];
115
+ hoveredElementIds: AppState["hoveredElementIds"];
116
+ frameRendering: AppState["frameRendering"];
117
+ shouldCacheIgnoreZoom: AppState["shouldCacheIgnoreZoom"];
118
+ exportScale: AppState["exportScale"];
119
+ currentItemArrowType: AppState["currentItemArrowType"];
120
+ }>, "selectedElementIds" | "editingGroupId" | "selectedGroupIds">> & {
121
+ selectedLinearElement: LinearElementEditor | null;
122
+ };
123
+ /**
124
+ * The selection with the given elements removed — with the group they're
125
+ * selected via (if any) — and a lone remaining line or arrow getting its
126
+ * line editor.
127
+ *
128
+ * @param allElements the (non-deleted) elements the selection is in
129
+ */
130
+ export declare const getSelectionStateRemovingElements: (targetElements: readonly NonDeletedExcalidrawElement[], allElements: readonly NonDeletedExcalidrawElement[], appState: AppState) => Mutable<Pick<Readonly<{
131
+ zoom: AppState["zoom"];
132
+ scrollX: AppState["scrollX"];
133
+ scrollY: AppState["scrollY"];
134
+ width: AppState["width"];
135
+ height: AppState["height"];
136
+ viewModeEnabled: AppState["viewModeEnabled"];
137
+ openDialog: AppState["openDialog"];
138
+ editingGroupId: AppState["editingGroupId"];
139
+ selectedElementIds: AppState["selectedElementIds"];
140
+ frameToHighlight: AppState["frameToHighlight"];
141
+ offsetLeft: AppState["offsetLeft"];
142
+ offsetTop: AppState["offsetTop"];
143
+ theme: AppState["theme"];
144
+ } & {
145
+ activeTool: AppState["activeTool"];
146
+ activeEmbeddable: AppState["activeEmbeddable"];
147
+ selectionElement: AppState["selectionElement"];
148
+ selectedGroupIds: AppState["selectedGroupIds"];
149
+ selectedLinearElement: AppState["selectedLinearElement"];
150
+ multiElement: AppState["multiElement"];
151
+ newElement: AppState["newElement"];
152
+ isBindingEnabled: AppState["isBindingEnabled"];
153
+ isMidpointSnappingEnabled: AppState["isMidpointSnappingEnabled"];
154
+ gridModeEnabled: AppState["gridModeEnabled"];
155
+ suggestedBinding: AppState["suggestedBinding"];
156
+ textToolHover: AppState["textToolHover"];
157
+ isRotating: AppState["isRotating"];
158
+ elementsToHighlight: AppState["elementsToHighlight"];
159
+ collaborators: AppState["collaborators"];
160
+ snapLines: AppState["snapLines"];
161
+ zenModeEnabled: AppState["zenModeEnabled"];
162
+ editingTextElement: AppState["editingTextElement"];
163
+ isCropping: AppState["isCropping"];
164
+ croppingElementId: AppState["croppingElementId"];
165
+ searchMatches: AppState["searchMatches"];
166
+ activeLockedId: AppState["activeLockedId"];
167
+ hoveredElementIds: AppState["hoveredElementIds"];
168
+ frameRendering: AppState["frameRendering"];
169
+ shouldCacheIgnoreZoom: AppState["shouldCacheIgnoreZoom"];
170
+ exportScale: AppState["exportScale"];
171
+ currentItemArrowType: AppState["currentItemArrowType"];
172
+ }>, "selectedElementIds" | "editingGroupId" | "selectedGroupIds">> & {
173
+ selectedLinearElement: LinearElementEditor | null;
174
+ };
175
+ /** elements, or their ids — one or many */
176
+ export type ElementsOrIds = ExcalidrawElement | ExcalidrawElement["id"] | readonly (ExcalidrawElement | ExcalidrawElement["id"])[];
177
+ type SelectionChangeOptions = {
178
+ /**
179
+ * how the change is recorded for undo (see `updateScene()`) — by default,
180
+ * along with the next undoable change
181
+ */
182
+ captureUpdate?: CaptureUpdateActionType;
183
+ };
184
+ type AddOptions = SelectionChangeOptions & {
185
+ /**
186
+ * select locked elements too — e.g. for the context menu to offer unlocking
187
+ * them
188
+ */
189
+ includeLocked?: boolean;
190
+ };
191
+ type SelectOptions = AddOptions & {
192
+ /**
193
+ * select the elements themselves rather than their groups, editing their
194
+ * innermost group (if they share it) — as Ctrl+click does
195
+ */
196
+ deep?: boolean;
197
+ };
198
+ /**
199
+ * The selection: selecting elements, adding them to or removing them from
200
+ * the selection, and clearing it — keeping its rules: an element is selected
201
+ * with its group (but within the edited group), a frame and its children
202
+ * aren't selected at the same time, locked elements aren't selected, and a
203
+ * lone line or arrow gets its line editor (see the `getSelectionState*()`
204
+ * functions above).
205
+ *
206
+ * What hangs on the selection follows it: the link popup shows for a lone
207
+ * selected element with a link (or an embeddable), an embed stays active only
208
+ * while selected, cropping ends (unless the cropped image is selected again),
209
+ * and selecting (or adding) anything but the edited text ends text editing,
210
+ * submitting the text. The line editor ends once its line is deselected (see
211
+ * `componentDidUpdate()`).
212
+ *
213
+ * Elements are taken by id from the scene: missing and deleted ones are
214
+ * skipped.
215
+ */
216
+ export declare class AppSelection {
217
+ private app;
218
+ constructor(app: App);
219
+ /**
220
+ * Selects the elements alone (with their groups, unless `deep`).
221
+ */
222
+ select: (elementsOrIds: ElementsOrIds, opts?: SelectOptions) => void;
223
+ /**
224
+ * Adds the elements (with their groups) to the selection.
225
+ */
226
+ add: (elementsOrIds: ElementsOrIds, opts?: AddOptions) => void;
227
+ /**
228
+ * Removes the elements from the selection — with the group they're
229
+ * selected via.
230
+ */
231
+ remove: (elementsOrIds: ElementsOrIds, opts?: SelectionChangeOptions) => void;
232
+ /**
233
+ * Clears the selection, leaving the edited group and ending cropping.
234
+ *
235
+ * (Doesn't end text editing: starting it clears the selection.)
236
+ */
237
+ clear: (opts?: SelectionChangeOptions) => void;
238
+ /**
239
+ * Ends what changing the selection ends — cropping (unless
240
+ * `keepsCroppedImage`), and text editing (unless selecting the edited text,
241
+ * or its container) — and records the change for undo as asked.
242
+ *
243
+ * @param elements the elements being selected (or added) — none for a
244
+ * change that leaves text editing be
245
+ */
246
+ private beforeChange;
247
+ /**
248
+ * The next selection state with what follows it: the link popup — shown for
249
+ * a lone selected element with a link (or an embeddable), the link editor
250
+ * staying open if it's the same element, and hidden otherwise — and the
251
+ * active embed, which stays active only while selected.
252
+ */
253
+ private withFollowingState;
254
+ isASelectedElement(hitElement: ExcalidrawElement | null): boolean;
255
+ isHittingCommonBoundingBoxOfSelectedElements(point: Readonly<{
256
+ x: number;
257
+ y: number;
258
+ }>, selectedElements: readonly ExcalidrawElement[]): boolean;
259
+ /**
260
+ * The scene's (non-deleted) elements, by id, once each — but locked ones,
261
+ * unless `includeLocked`
262
+ */
263
+ private resolve;
264
+ }
265
+ export {};
@@ -0,0 +1,93 @@
1
+ import type { TransformHandleType } from "@excalidraw/element";
2
+ import type { ExcalidrawElement, ExcalidrawImageElement, NonDeleted, NonDeletedExcalidrawElement, NonDeletedSceneElementsMap, PointerType } from "@excalidraw/element/types";
3
+ import type React from "react";
4
+ import type { PointerDownState } from "../types";
5
+ import type App from "./App";
6
+ /**
7
+ * The selection tool's (and the lasso's) selection: what a pointer down
8
+ * selects, what a click (a pointer up without a drag) does to the selection —
9
+ * including alt-click cycling through the overlapping elements — and the
10
+ * selection's transform handles (resizing, rotating, cropping).
11
+ */
12
+ export declare class AppSelectionTool {
13
+ private app;
14
+ constructor(app: App);
15
+ clearSelectionIfNotUsingSelection: () => void;
16
+ /**
17
+ * @returns whether the pointer event has been completely handled
18
+ */
19
+ handleSelectionOnPointerDown: (event: React.PointerEvent<HTMLElement>, pointerDownState: PointerDownState) => boolean;
20
+ maybeHandleCrop: (pointerDownState: PointerDownState, event: MouseEvent | KeyboardEvent) => boolean;
21
+ /**
22
+ * In the crop editor, a double-click on a handle uncrops its side (a
23
+ * corner's two), and mirrored, the opposite side(s) too.
24
+ *
25
+ * @returns whether the double-click has been handled
26
+ */
27
+ maybeUncropSides: (image: NonDeleted<ExcalidrawImageElement>, sceneX: number, sceneY: number, mirrored: boolean) => boolean;
28
+ maybeHandleResize: (pointerDownState: PointerDownState, event: MouseEvent | KeyboardEvent) => boolean;
29
+ /**
30
+ * Drags the selection (or, in the crop editor, the image within its crop) —
31
+ * duplicating it on an alt-drag past the drag threshold.
32
+ *
33
+ * @returns whether the pointer event has been completely handled
34
+ */
35
+ handleSelectionDragOnPointerMove: (event: PointerEvent, pointerDownState: PointerDownState, pointerCoords: {
36
+ x: number;
37
+ y: number;
38
+ }, elementsMap: NonDeletedSceneElementsMap) => boolean;
39
+ /**
40
+ * Box-selects with the selection tool — the line editor's points, while
41
+ * editing a line.
42
+ */
43
+ handleBoxSelectionOnPointerMove: (event: PointerEvent, pointerDownState: PointerDownState) => void;
44
+ /**
45
+ * After dragging the selection: the dragged elements join the frame they're
46
+ * dropped in, or leave theirs (and the edited group, if they leave it).
47
+ */
48
+ handleSelectionDragOnPointerUp: (childEvent: PointerEvent) => void;
49
+ /**
50
+ * The selection's transform handle at the scene point, if any — with its
51
+ * element, for a lone selected element.
52
+ *
53
+ * A lone selected element has none while the line editor is open or one of
54
+ * its line points is hovered, nor does an elbow arrow, a two-point line or
55
+ * arrow, or (on mobile devices) any line or arrow. The selection has none in
56
+ * the element link selector.
57
+ */
58
+ getTransformHandleAt(selectedElements: readonly NonDeletedExcalidrawElement[], sceneX: number, sceneY: number, pointerType: PointerType): {
59
+ element?: NonDeletedExcalidrawElement;
60
+ transformHandleType: TransformHandleType;
61
+ } | null;
62
+ /**
63
+ * Updates the selection on a click (no drag): the element below the
64
+ * selected one on an alt-click, the clicked element added to or removed
65
+ * from the selection with shift, or selected, and the selection cleared
66
+ * by a click hitting only a bounding box.
67
+ *
68
+ * @returns whether the pointer event has been completely handled
69
+ */
70
+ handleSelectionOnPointerUp: (childEvent: PointerEvent, pointerDownState: PointerDownState, elementsMap: NonDeletedSceneElementsMap) => boolean;
71
+ clearSelection(hitElement: ExcalidrawElement | null): void;
72
+ /** whether an alt-click on the selection (over other elements) cycles it */
73
+ canCycleSelection: () => boolean;
74
+ /**
75
+ * The selectable unit (an element, or the group a click would select) an
76
+ * element belongs to. Inside an edited group, its elements are units of
77
+ * their own.
78
+ */
79
+ private getSelectableUnit;
80
+ /**
81
+ * The selected unit, if an alt-click can cycle away from it: exactly one
82
+ * is selected, and neither the linear nor the crop editor is open.
83
+ */
84
+ private getCyclableSelectedUnit;
85
+ /**
86
+ * The element an alt-click selects: the selectable unit below the selected
87
+ * one among the hit elements, wrapping around to the topmost — or `null`
88
+ * unless it's an alt-click, the selection can cycle, and it's under the
89
+ * pointer. Inside an edited group, it cycles through the group's elements
90
+ * only, never leaving the group.
91
+ */
92
+ private getSelectionCycleTarget;
93
+ }
@@ -1,10 +1,16 @@
1
1
  import { type StylesPanelMode } from "@excalidraw/common";
2
2
  import type { NonDeletedSceneElementsMap } from "@excalidraw/element/types";
3
+ import { type AnimationKey, type AnimationScheduler } from "../renderer/animation";
3
4
  import { type SetViewportOptions } from "../viewport";
4
5
  import type { AppProps, AppState, Offsets, ScrollConstraints, ViewportOffsets, ViewportOffsetsOptions, ViewportUIName } from "../types";
5
6
  import type App from "./App";
6
- export declare const SCROLL_TO_CONTENT_ANIMATION_KEY = "animateScrollToContent";
7
- export declare const SCROLL_CONSTRAINTS_SNAP_BACK_ANIMATION_KEY = "animateScrollConstraintsSnapBack";
7
+ /** The AnimationController keys a viewport uses, unique per AppViewport so
8
+ * concurrent editors in the same window never share (or cancel) each
9
+ * other's animations. */
10
+ export type ViewportAnimationKeys = {
11
+ scrollToContent: AnimationKey;
12
+ snapBack: AnimationKey;
13
+ };
8
14
  /** single source of truth for the `--right-sidebar-width` CSS variable */
9
15
  export declare const RIGHT_SIDEBAR_WIDTH = 302;
10
16
  type Viewport = Pick<AppState, "scrollX" | "scrollY" | "zoom">;
@@ -19,7 +25,7 @@ type AppViewportDependencies = {
19
25
  * AnimationController. No-op when already within the hard bounds (or when
20
26
  * there is no lock).
21
27
  */
22
- export declare const snapBackToConstraints: (state: Pick<AppState, "scrollX" | "scrollY" | "zoom" | "width" | "height" | "scrollConstraints">, onFrame: (updater: (state: Pick<AppState, "scrollX" | "scrollY" | "zoom" | "width" | "height" | "scrollConstraints">) => Viewport | null) => void, duration?: number) => void;
28
+ export declare const snapBackToConstraints: (state: Pick<AppState, "scrollX" | "scrollY" | "zoom" | "width" | "height" | "scrollConstraints">, onFrame: (updater: (state: Pick<AppState, "scrollX" | "scrollY" | "zoom" | "width" | "height" | "scrollConstraints">) => Viewport | null) => void, keys: ViewportAnimationKeys, scheduler?: AnimationScheduler, duration?: number) => void;
23
29
  /**
24
30
  * Owns viewport state transitions and App-bound viewport concerns. Pure
25
31
  * viewport geometry remains in `viewport.ts` so actions and public helpers can
@@ -34,6 +40,10 @@ export declare class AppViewport {
34
40
  };
35
41
  private activeTransition;
36
42
  private uiLastMeasured;
43
+ /** Unique per instance (see `ViewportAnimationKeys`); exposed for tests
44
+ * observing the animations. */
45
+ readonly scrollToContentAnimationKey: symbol;
46
+ readonly snapBackAnimationKey: symbol;
37
47
  constructor(app: App, dependencies: AppViewportDependencies);
38
48
  get isAnimating(): boolean;
39
49
  /** Whether a programmatic transition into a locked viewport currently owns
@@ -0,0 +1,31 @@
1
+ import type { ExcalidrawElement } from "@excalidraw/element/types";
2
+ import type { ActionResult } from "../actions/types";
3
+ import type { AppState } from "../types";
4
+ import type App from "./App";
5
+ /**
6
+ * Wraps the selection in what fits it, or unwraps it, preferring containers
7
+ * over frames:
8
+ *
9
+ * 1. a text and a container without one: binds the text to the container
10
+ * 2. texts, with any labeled containers: wraps each text in a container
11
+ * 3. labeled containers: unwraps their texts, removing the containers
12
+ * 4. a frame with any of its children, or all of a frame's children: removes
13
+ * the frame
14
+ * 5. anything else without a frame: wraps it in a frame
15
+ *
16
+ * The containers (3) removed come back in place of new ones while the
17
+ * selection it left stands, so diamonds, notes and arrows survive a toggle.
18
+ */
19
+ export declare class AppWrap {
20
+ private app;
21
+ private unwrapped;
22
+ constructor(app: App);
23
+ toggle: (elements: readonly ExcalidrawElement[], appState: Readonly<AppState>) => ActionResult;
24
+ /** frees the containers' texts, moving the containers' arrows onto them */
25
+ private unwrap;
26
+ /**
27
+ * puts the unwrapped texts back into their containers, along with the
28
+ * containers' arrows — `null` when any of them is gone
29
+ */
30
+ private rewrap;
31
+ }
@@ -1,5 +1,6 @@
1
1
  import type { ConvertibleTypes, ExcalidrawElement, ExcalidrawTextContainer, ExcalidrawTextElementWithContainer } from "@excalidraw/element/types";
2
2
  import type { Scene } from "@excalidraw/element";
3
+ import type { RenderEnvironment } from "@excalidraw/element/renderEnvironment";
3
4
  import "./ConvertElementTypePopup.scss";
4
5
  import type App from "./App";
5
6
  export declare const convertElementTypePopupAtom: import("jotai").PrimitiveAtom<{
@@ -12,7 +13,7 @@ export declare const convertElementTypePopupAtom: import("jotai").PrimitiveAtom<
12
13
  declare const ConvertElementTypePopup: ({ app }: {
13
14
  app: App;
14
15
  }) => import("react/jsx-runtime").JSX.Element;
15
- export declare const adjustBoundTextSize: (container: ExcalidrawTextContainer, boundText: ExcalidrawTextElementWithContainer, scene: Scene) => void;
16
+ export declare const adjustBoundTextSize: (container: ExcalidrawTextContainer, boundText: ExcalidrawTextElementWithContainer, scene: Scene, renderEnvironment?: RenderEnvironment) => void;
16
17
  type ConversionType = "generic" | "linear" | null;
17
18
  export declare const convertElementTypes: (app: App, { conversionType, nextType, direction, }: {
18
19
  conversionType: ConversionType;
@@ -1,5 +1,5 @@
1
1
  import type { ElementsMap, ExcalidrawElement, NonDeletedExcalidrawElement } from "@excalidraw/element/types";
2
- import type { Scene } from "@excalidraw/element";
2
+ import type { RenderEnvironment, Scene } from "@excalidraw/element";
3
3
  import type { AppState } from "../../types";
4
4
  export type StatsInputProperty = "x" | "y" | "width" | "height" | "angle" | "fontSize" | "gridStep";
5
5
  export declare const SMALLEST_DELTA = 0.01;
@@ -15,5 +15,7 @@ export declare const newOrigin: (x1: number, y1: number, w1: number, h1: number,
15
15
  x: number;
16
16
  y: number;
17
17
  };
18
- export declare const moveElement: (newTopLeftX: number, newTopLeftY: number, originalElement: NonDeletedExcalidrawElement, scene: Scene, appState: AppState, originalElementsMap: ElementsMap, shouldInformMutation?: boolean) => void;
18
+ export declare const moveElement: (newTopLeftX: number, newTopLeftY: number, originalElement: NonDeletedExcalidrawElement, scene: Scene, appState: AppState, originalElementsMap: ElementsMap, shouldInformMutation?: boolean,
19
+ /** measures the labels of the bound arrows the move moves */
20
+ renderEnvironment?: RenderEnvironment) => void;
19
21
  export declare const getAtomicUnits: (targetElements: readonly ExcalidrawElement[], appState: AppState) => AtomicUnit[];
@@ -1,7 +1,8 @@
1
1
  import "./MermaidToExcalidraw.scss";
2
2
  import type { MermaidToExcalidrawLibProps } from "./types";
3
- declare const MermaidToExcalidraw: ({ mermaidToExcalidrawLib, isActive, }: {
3
+ declare const MermaidToExcalidraw: ({ mermaidToExcalidrawLib, onRetryLoad, isActive, }: {
4
4
  mermaidToExcalidrawLib: MermaidToExcalidrawLibProps;
5
+ onRetryLoad?: () => void;
5
6
  isActive?: boolean;
6
7
  }) => import("react/jsx-runtime").JSX.Element;
7
8
  export default MermaidToExcalidraw;
@@ -1,11 +1,14 @@
1
+ import type { MermaidToExcalidrawLibProps } from "./types";
1
2
  interface TTDDialogOutputProps {
2
3
  error: Error | null;
3
4
  canvasRef: React.RefObject<HTMLDivElement | null>;
4
- loaded: boolean;
5
+ loadStatus: MermaidToExcalidrawLibProps["status"];
6
+ loadErrorReloadRequired?: boolean;
7
+ onRetryLoad?: () => void;
5
8
  hideErrorDetails?: boolean;
6
9
  sourceText?: string;
7
10
  autoFixAvailable?: boolean;
8
11
  onApplyAutoFix?: () => void;
9
12
  }
10
- export declare const TTDDialogOutput: ({ error, canvasRef, loaded, hideErrorDetails, sourceText, autoFixAvailable, onApplyAutoFix, }: TTDDialogOutputProps) => import("react/jsx-runtime").JSX.Element;
13
+ export declare const TTDDialogOutput: ({ error, canvasRef, loadStatus, loadErrorReloadRequired, onRetryLoad, hideErrorDetails, sourceText, autoFixAvailable, onApplyAutoFix, }: TTDDialogOutputProps) => import("react/jsx-runtime").JSX.Element;
11
14
  export {};
@@ -1,9 +1,12 @@
1
+ import type { MermaidToExcalidrawLibProps } from "./types";
1
2
  interface TTDPreviewPanelProps {
2
3
  canvasRef: React.RefObject<HTMLDivElement | null>;
3
4
  error: Error | null;
4
- loaded: boolean;
5
+ loadStatus: MermaidToExcalidrawLibProps["status"];
6
+ loadErrorReloadRequired?: boolean;
7
+ onRetryLoad?: () => void;
5
8
  onInsert: () => void;
6
9
  hideErrorDetails?: boolean;
7
10
  }
8
- export declare const TTDPreviewPanel: ({ canvasRef, error, loaded, onInsert, hideErrorDetails, }: TTDPreviewPanelProps) => import("react/jsx-runtime").JSX.Element;
11
+ export declare const TTDPreviewPanel: ({ canvasRef, error, loadStatus, loadErrorReloadRequired, onRetryLoad, onInsert, hideErrorDetails, }: TTDPreviewPanelProps) => import("react/jsx-runtime").JSX.Element;
9
12
  export {};
@@ -1,6 +1,7 @@
1
1
  import type { MermaidToExcalidrawLibProps, TTDPersistenceAdapter, TTTDDialog } from "./types";
2
- export declare const TextToDiagram: ({ mermaidToExcalidrawLib, onTextSubmit, renderWelcomeScreen, renderWarning, persistenceAdapter, }: {
2
+ export declare const TextToDiagram: ({ mermaidToExcalidrawLib, onRetryLoad, onTextSubmit, renderWelcomeScreen, renderWarning, persistenceAdapter, }: {
3
3
  mermaidToExcalidrawLib: MermaidToExcalidrawLibProps;
4
+ onRetryLoad?: () => void;
4
5
  onTextSubmit(props: TTTDDialog.OnTextSubmitProps): Promise<TTTDDialog.OnTextSubmitRetValue>;
5
6
  renderWelcomeScreen?: TTTDDialog.renderWelcomeScreen;
6
7
  renderWarning?: TTTDDialog.renderWarning;
@@ -1,3 +1,4 @@
1
+ import type { RenderEnvironment } from "@excalidraw/element";
1
2
  import type { NonDeletedExcalidrawElement, Theme } from "@excalidraw/element/types";
2
3
  import type { MermaidToExcalidrawLibProps } from "./types";
3
4
  import type { AppClassProperties, BinaryFiles } from "../../types";
@@ -5,7 +6,7 @@ export declare const resetPreview: ({ canvasRef, setError, }: {
5
6
  canvasRef: React.RefObject<HTMLDivElement | null>;
6
7
  setError: (error: Error | null) => void;
7
8
  }) => void;
8
- export declare const convertMermaidToExcalidraw: ({ canvasRef, mermaidToExcalidrawLib, mermaidDefinition, setError, data, theme, }: {
9
+ export declare const convertMermaidToExcalidraw: ({ canvasRef, mermaidToExcalidrawLib, mermaidDefinition, setError, data, theme, renderEnvironment, }: {
9
10
  canvasRef: React.RefObject<HTMLDivElement | null>;
10
11
  mermaidToExcalidrawLib: MermaidToExcalidrawLibProps;
11
12
  mermaidDefinition: string;
@@ -15,6 +16,8 @@ export declare const convertMermaidToExcalidraw: ({ canvasRef, mermaidToExcalidr
15
16
  files: BinaryFiles | null;
16
17
  }>;
17
18
  theme: Theme;
19
+ /** the host's environment (`app.renderEnvironment`), to measure labels with */
20
+ renderEnvironment?: RenderEnvironment;
18
21
  }) => Promise<{
19
22
  success: true;
20
23
  } | {
@@ -1,6 +1,7 @@
1
- import type { TTTDDialog } from "../types";
2
- export declare const useTextGeneration: ({ onTextSubmit, }: {
1
+ import type { MermaidToExcalidrawLibProps, TTTDDialog } from "../types";
2
+ export declare const useTextGeneration: ({ onTextSubmit, mermaidToExcalidrawLib, }: {
3
3
  onTextSubmit: (props: TTTDDialog.OnTextSubmitProps) => Promise<TTTDDialog.OnTextSubmitRetValue>;
4
+ mermaidToExcalidrawLib: MermaidToExcalidrawLibProps;
4
5
  }) => {
5
6
  onGenerate: TTTDDialog.OnGenerate;
6
7
  handleAbort: () => void;
@@ -27,6 +27,12 @@ export declare namespace TChat {
27
27
  type: "user" | "assistant" | "warning";
28
28
  warningType?: /* daily rate limit */ "messageLimitExceeded" | /* general 429 */ "rateLimitExceeded";
29
29
  content?: string;
30
+ /**
31
+ * What an assistant's diagram was rendered with: Pele, since
32
+ * `@excalidraw/mermaid-to-excalidraw` v3. Not set on (saved) messages
33
+ * from before, which were rendered with Mermaid.
34
+ */
35
+ renderer?: "pele";
30
36
  };
31
37
  type ChatHistory = {
32
38
  id: string;
@@ -57,7 +63,14 @@ export interface TTDPersistenceAdapter {
57
63
  saveChats(chats: SavedChats): Promise<void>;
58
64
  }
59
65
  export interface MermaidToExcalidrawLibProps {
60
- loaded: boolean;
66
+ /** loading state of the (lazy) lib. "error" e.g. while offline */
67
+ status: "loading" | "loaded" | "error";
68
+ /**
69
+ * set when loading failed while online (e.g. stale app version after
70
+ * a deploy, or the browser cached the failed fetch), i.e. only a page
71
+ * reload will likely recover
72
+ */
73
+ reloadRequired?: boolean;
61
74
  api: Promise<{
62
75
  parseMermaidToExcalidraw: (definition: string, config?: MermaidConfig) => Promise<MermaidToExcalidrawResult>;
63
76
  }>;
@@ -1,10 +1,36 @@
1
+ /** a lazy-loaded chunk (e.g. one of mermaid's diagram chunks) failed to load */
2
+ export declare const isModuleLoadError: (error: unknown) => boolean;
1
3
  export declare const isMermaidParseSyntaxError: (message: string) => boolean;
4
+ /** the definition doesn't start with a (known) diagram type */
5
+ export declare const isMermaidUnknownDiagramError: (message: string) => boolean;
2
6
  export declare const isMermaidAutoFixableError: (message: string) => boolean;
7
+ export type MermaidDiagramType = "flowchart" | "sequence" | "class" | "state" | "er";
8
+ /**
9
+ * Index of the line that declares the diagram type: the first one that isn't
10
+ * empty, a comment, a directive (`%%{...}%%`) or front matter (`---` block).
11
+ */
12
+ export declare const getMermaidHeaderLineIndex: (sourceText: string) => number | null;
13
+ /** The diagram type the definition declares (of those Excalidraw converts). */
14
+ export declare const getMermaidDiagramType: (sourceText: string) => MermaidDiagramType | null;
3
15
  export declare const isMermaidCaretLine: (line: string) => boolean;
4
16
  export declare const getMermaidInactiveParticipant: (message: string) => string | null;
5
17
  export declare const getMermaidErrorLineNumber: (message: string, sourceText?: string) => number | null;
18
+ /**
19
+ * The line of the source an error Mermaid (or Pele) reports on `line` is on:
20
+ * errors past its end (e.g. a missing `end`) are on its last non-empty line.
21
+ */
22
+ export declare const getMermaidSourceLineNumber: (line: number, sourceText: string) => number;
23
+ /** A line closing a block that `end`s */
24
+ export declare const MERMAID_END_LINE: RegExp;
25
+ export declare const getMermaidEndBlockOpener: (type: MermaidDiagramType | null) => RegExp | null;
6
26
  export declare const getMermaidSyntaxErrorGuidance: (message: string, sourceText?: string) => {
7
27
  summary: string;
8
28
  likelyCauses: string[];
9
29
  } | null;
10
- export declare const formatMermaidParseErrorMessage: (message: string) => string;
30
+ /** The error, reported on its line of `sourceText` (see `getMermaidSourceLineNumber`) */
31
+ export declare const withMermaidSourceLineNumber: (message: string, sourceText: string) => string;
32
+ /**
33
+ * The parse error, without the tokens it expected, and if given the source,
34
+ * on its line of it.
35
+ */
36
+ export declare const formatMermaidParseErrorMessage: (message: string, sourceText?: string) => string;
@@ -1,12 +1,22 @@
1
1
  import React from "react";
2
2
  import "./Tooltip.scss";
3
- export declare const getTooltipDiv: () => HTMLDivElement;
3
+ export declare const TOOLTIP_CLASS = "excalidraw-tooltip";
4
+ export declare const TOOLTIP_VISIBLE_CLASS = "excalidraw-tooltip--visible";
5
+ export declare const getTooltipDiv: (ownerDocument: Document) => HTMLDivElement;
6
+ /**
7
+ * Hides `ownerDocument`'s tooltip, for tooltips not shown through
8
+ * `showTooltip` (see `hideTooltip`).
9
+ */
10
+ export declare const hideDocumentTooltip: (ownerDocument: Document) => void;
4
11
  export declare const updateTooltipPosition: (tooltip: HTMLDivElement, item: {
5
12
  left: number;
6
13
  top: number;
7
14
  width: number;
8
15
  height: number;
9
16
  }, position?: "bottom" | "top") => void;
17
+ /** ms before a `delay`ed tooltip shows */
18
+ export declare const TOOLTIP_DELAY = 500;
19
+ /** Hides the tooltip `showTooltip` shows, and cancels a pending one. */
10
20
  export declare const hideTooltip: () => void;
11
21
  /**
12
22
  * Shows the tooltip for `item`. For elements that can't be wrapped