@excalidraw/element 0.18.0-2874f9e → 0.18.0-2a82821

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 (144) hide show
  1. package/dist/dev/index.js +5228 -4610
  2. package/dist/dev/index.js.map +4 -4
  3. package/dist/prod/index.js +19 -18
  4. package/dist/types/common/src/appEventBus.d.ts +27 -0
  5. package/dist/types/common/src/colors.d.ts +2 -2
  6. package/dist/types/common/src/constants.d.ts +9 -7
  7. package/dist/types/common/src/index.d.ts +2 -0
  8. package/dist/types/common/src/utils.d.ts +1 -3
  9. package/dist/types/common/src/versionedSnapshotStore.d.ts +17 -0
  10. package/dist/types/element/src/Scene.d.ts +7 -3
  11. package/dist/types/element/src/arrowheads.d.ts +3 -0
  12. package/dist/types/element/src/binding.d.ts +3 -4
  13. package/dist/types/element/src/bounds.d.ts +22 -3
  14. package/dist/types/element/src/comparisons.d.ts +1 -0
  15. package/dist/types/element/src/duplicate.d.ts +1 -0
  16. package/dist/types/element/src/elbowArrow.d.ts +2 -0
  17. package/dist/types/element/src/frame.d.ts +7 -6
  18. package/dist/types/element/src/index.d.ts +1 -0
  19. package/dist/types/element/src/linearElementEditor.d.ts +5 -2
  20. package/dist/types/element/src/mutateElement.d.ts +2 -0
  21. package/dist/types/element/src/newElement.d.ts +1 -0
  22. package/dist/types/element/src/selection.d.ts +7 -3
  23. package/dist/types/element/src/shape.d.ts +1 -1
  24. package/dist/types/element/src/textElement.d.ts +1 -1
  25. package/dist/types/element/src/textWrapping.d.ts +26 -0
  26. package/dist/types/element/src/typeChecks.d.ts +1 -0
  27. package/dist/types/element/src/types.d.ts +11 -2
  28. package/dist/types/element/src/utils.d.ts +2 -2
  29. package/dist/types/element/src/visualdebug.d.ts +1 -2
  30. package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +35 -38
  31. package/dist/types/excalidraw/actions/actionBoundText.d.ts +25 -27
  32. package/dist/types/excalidraw/actions/actionCanvas.d.ts +144 -156
  33. package/dist/types/excalidraw/actions/actionClipboard.d.ts +24 -26
  34. package/dist/types/excalidraw/actions/actionCropEditor.d.ts +12 -13
  35. package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +36 -39
  36. package/dist/types/excalidraw/actions/actionDeselect.d.ts +160 -0
  37. package/dist/types/excalidraw/actions/actionElementLink.d.ts +8 -13
  38. package/dist/types/excalidraw/actions/actionElementLock.d.ts +24 -26
  39. package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +12 -13
  40. package/dist/types/excalidraw/actions/actionExport.d.ts +67 -349
  41. package/dist/types/excalidraw/actions/actionFrame.d.ts +49 -52
  42. package/dist/types/excalidraw/actions/actionGroup.d.ts +25 -27
  43. package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +13 -13
  44. package/dist/types/excalidraw/actions/actionLink.d.ts +12 -13
  45. package/dist/types/excalidraw/actions/actionMenu.d.ts +8 -13
  46. package/dist/types/excalidraw/actions/actionProperties.d.ts +36 -29
  47. package/dist/types/excalidraw/actions/actionSelectAll.d.ts +12 -13
  48. package/dist/types/excalidraw/actions/actionStyles.d.ts +12 -12
  49. package/dist/types/excalidraw/actions/actionTextAutoResize.d.ts +3 -3
  50. package/dist/types/excalidraw/actions/actionToggleArrowBinding.d.ts +173 -0
  51. package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +12 -13
  52. package/dist/types/excalidraw/actions/actionToggleMidpointSnapping.d.ts +173 -0
  53. package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +12 -13
  54. package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +8 -13
  55. package/dist/types/excalidraw/actions/actionToggleStats.d.ts +12 -13
  56. package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +12 -13
  57. package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +12 -13
  58. package/dist/types/excalidraw/actions/index.d.ts +4 -1
  59. package/dist/types/excalidraw/actions/types.d.ts +1 -1
  60. package/dist/types/excalidraw/{animated-trail.d.ts → animatedTrail.d.ts} +4 -3
  61. package/dist/types/excalidraw/appState.d.ts +6 -2
  62. package/dist/types/excalidraw/charts/charts.bar.d.ts +2 -0
  63. package/dist/types/excalidraw/charts/charts.constants.d.ts +48 -0
  64. package/dist/types/excalidraw/charts/charts.helpers.d.ts +32 -0
  65. package/dist/types/excalidraw/charts/charts.line.d.ts +2 -0
  66. package/dist/types/excalidraw/charts/charts.parse.d.ts +10 -0
  67. package/dist/types/excalidraw/charts/charts.radar.d.ts +2 -0
  68. package/dist/types/excalidraw/charts/charts.types.d.ts +18 -0
  69. package/dist/types/excalidraw/charts/index.d.ts +7 -0
  70. package/dist/types/excalidraw/clipboard.d.ts +2 -5
  71. package/dist/types/excalidraw/components/ActiveConfirmDialog.d.ts +1 -1
  72. package/dist/types/excalidraw/components/App.d.ts +54 -14
  73. package/dist/types/excalidraw/components/AppStateObserver.d.ts +37 -0
  74. package/dist/types/excalidraw/components/ColorPicker/colorPickerUtils.d.ts +1 -1
  75. package/dist/types/excalidraw/components/CommandPalette/defaultCommandPaletteItems.d.ts +1 -2
  76. package/dist/types/excalidraw/components/ConvertElementTypePopup.d.ts +1 -1
  77. package/dist/types/excalidraw/components/EyeDropper.d.ts +1 -1
  78. package/dist/types/excalidraw/components/IconPicker.d.ts +14 -9
  79. package/dist/types/excalidraw/components/LibraryMenu.d.ts +1 -1
  80. package/dist/types/excalidraw/components/OverwriteConfirm/OverwriteConfirmState.d.ts +1 -1
  81. package/dist/types/excalidraw/components/PasteChartDialog.d.ts +4 -5
  82. package/dist/types/excalidraw/components/Range.d.ts +10 -4
  83. package/dist/types/excalidraw/components/SVGLayer.d.ts +1 -1
  84. package/dist/types/excalidraw/components/SearchMenu.d.ts +1 -1
  85. package/dist/types/excalidraw/components/Sidebar/Sidebar.d.ts +1 -1
  86. package/dist/types/excalidraw/components/TTDDialog/CodeMirrorEditor.d.ts +11 -0
  87. package/dist/types/excalidraw/components/TTDDialog/TTDContext.d.ts +4 -4
  88. package/dist/types/excalidraw/components/TTDDialog/TTDDialogInput.d.ts +3 -3
  89. package/dist/types/excalidraw/components/TTDDialog/TTDDialogOutput.d.ts +4 -1
  90. package/dist/types/excalidraw/components/TTDDialog/mermaid-lang-lite.d.ts +2 -0
  91. package/dist/types/excalidraw/components/TTDDialog/useTTDChatStorage.d.ts +3 -3
  92. package/dist/types/excalidraw/components/TTDDialog/utils/mermaidAutoFix.d.ts +1 -0
  93. package/dist/types/excalidraw/components/TTDDialog/utils/mermaidError.d.ts +10 -0
  94. package/dist/types/excalidraw/components/Toast.d.ts +8 -4
  95. package/dist/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +2 -1
  96. package/dist/types/excalidraw/components/canvases/NewElementCanvas.d.ts +1 -0
  97. package/dist/types/excalidraw/components/canvases/StaticCanvas.d.ts +1 -1
  98. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemContentRadio.d.ts +2 -1
  99. package/dist/types/excalidraw/components/icons.d.ts +19 -8
  100. package/dist/types/excalidraw/components/main-menu/DefaultItems.d.ts +9 -3
  101. package/dist/types/excalidraw/components/shapes.d.ts +7 -0
  102. package/dist/types/excalidraw/data/blob.d.ts +31 -34
  103. package/dist/types/excalidraw/data/filesystem.d.ts +3 -5
  104. package/dist/types/excalidraw/data/index.d.ts +2 -3
  105. package/dist/types/excalidraw/data/json.d.ts +30 -23
  106. package/dist/types/excalidraw/data/library.d.ts +1 -1
  107. package/dist/types/excalidraw/data/resave.d.ts +7 -2
  108. package/dist/types/excalidraw/eraser/index.d.ts +2 -3
  109. package/dist/types/excalidraw/hooks/useLibraryItemSvg.d.ts +1 -1
  110. package/dist/types/excalidraw/{laser-trails.d.ts → laserTrails.d.ts} +5 -7
  111. package/dist/types/excalidraw/lasso/index.d.ts +2 -3
  112. package/dist/types/excalidraw/renderer/animation.d.ts +4 -1
  113. package/dist/types/excalidraw/scene/Renderer.d.ts +426 -19
  114. package/dist/types/excalidraw/scene/index.d.ts +1 -1
  115. package/dist/types/excalidraw/textAutoResizeHandle.d.ts +15 -0
  116. package/dist/types/excalidraw/types.d.ts +110 -18
  117. package/dist/types/excalidraw/wysiwyg/textWysiwyg.d.ts +5 -1
  118. package/dist/types/fractional-indexing/src/index.d.ts +29 -0
  119. package/dist/types/laser-pointer/src/index.d.ts +2 -0
  120. package/dist/types/laser-pointer/src/math.d.ts +16 -0
  121. package/dist/types/laser-pointer/src/simplify.d.ts +2 -0
  122. package/dist/types/laser-pointer/src/state.d.ts +35 -0
  123. package/dist/types/math/src/constants.d.ts +0 -1
  124. package/dist/types/math/src/curve.d.ts +4 -1
  125. package/dist/types/math/src/point.d.ts +2 -1
  126. package/dist/types/utils/src/index.d.ts +1 -2
  127. package/package.json +4 -3
  128. package/dist/types/excalidraw/animation-frame-handler.d.ts +0 -16
  129. package/dist/types/excalidraw/charts.d.ts +0 -27
  130. package/dist/types/excalidraw/components/DiagramToCodePlugin/DiagramToCodePlugin.d.ts +0 -4
  131. package/dist/types/excalidraw/components/ExcalidrawLogo.d.ts +0 -15
  132. package/dist/types/excalidraw/components/InitializeApp.d.ts +0 -10
  133. package/dist/types/excalidraw/components/TTDDialog/TTDDialogTrigger.d.ts +0 -8
  134. package/dist/types/excalidraw/components/TTDDialog/utils/TTDStreamFetch.d.ts +0 -24
  135. package/dist/types/excalidraw/components/footer/FooterCenter.d.ts +0 -8
  136. package/dist/types/excalidraw/components/live-collaboration/LiveCollaborationTrigger.d.ts +0 -11
  137. package/dist/types/excalidraw/components/welcome-screen/WelcomeScreen.Center.d.ts +0 -58
  138. package/dist/types/excalidraw/components/welcome-screen/WelcomeScreen.Hints.d.ts +0 -19
  139. package/dist/types/excalidraw/components/welcome-screen/WelcomeScreen.d.ts +0 -84
  140. package/dist/types/excalidraw/data/reconcile.d.ts +0 -7
  141. package/dist/types/excalidraw/index.d.ts +0 -47
  142. package/dist/types/excalidraw/polyfill.d.ts +0 -2
  143. package/dist/types/utils/src/bbox.d.ts +0 -9
  144. package/dist/types/utils/src/withinBounds.d.ts +0 -19
@@ -1,7 +1,7 @@
1
- import type { IMAGE_MIME_TYPES, UserIdleState, throttleRAF, MIME_TYPES, EditorInterface } from "@excalidraw/common";
1
+ import type { IMAGE_MIME_TYPES, UserIdleState, throttleRAF, MIME_TYPES, EditorInterface, StrokeWidthKey } from "@excalidraw/common";
2
2
  import type { LinearElementEditor } from "@excalidraw/element";
3
3
  import type { MaybeTransformHandleType } from "@excalidraw/element";
4
- import type { PointerType, ExcalidrawLinearElement, NonDeletedExcalidrawElement, NonDeleted, TextAlign, ExcalidrawElement, GroupId, ExcalidrawBindableElement, Arrowhead, ChartType, FontFamilyValues, FileId, Theme, StrokeRoundness, ExcalidrawEmbeddableElement, ExcalidrawMagicFrameElement, ExcalidrawFrameLikeElement, ExcalidrawElementType, ExcalidrawIframeLikeElement, OrderedExcalidrawElement, ExcalidrawNonSelectionElement, BindMode } from "@excalidraw/element/types";
4
+ import type { PointerType, ExcalidrawLinearElement, NonDeletedExcalidrawElement, NonDeleted, TextAlign, ExcalidrawElement, GroupId, ExcalidrawBindableElement, Arrowhead, FontFamilyValues, FileId, Theme, StrokeRoundness, ExcalidrawEmbeddableElement, ExcalidrawMagicFrameElement, ExcalidrawFrameLikeElement, ExcalidrawElementType, ExcalidrawIframeLikeElement, OrderedExcalidrawElement, ExcalidrawNonSelectionElement, BindMode, ExcalidrawTextElement, StrokeVariability } from "@excalidraw/element/types";
5
5
  import type { Merge, MaybePromise, ValueOf, MakeBrand } from "@excalidraw/common/utility-types";
6
6
  import type { CaptureUpdateActionType, DurableIncrement, EphemeralIncrement } from "@excalidraw/element";
7
7
  import type { GlobalPoint } from "@excalidraw/math";
@@ -10,7 +10,6 @@ import type { Spreadsheet } from "./charts";
10
10
  import type { ClipboardData } from "./clipboard";
11
11
  import type App from "./components/App";
12
12
  import type Library from "./data/library";
13
- import type { FileSystemHandle } from "./data/filesystem";
14
13
  import type { ContextMenuItems } from "./components/ContextMenu";
15
14
  import type { SnapLine } from "./snapping";
16
15
  import type { ImportedDataState } from "./data/types";
@@ -138,6 +137,7 @@ export type InteractiveCanvasAppState = Readonly<_CommonCanvasAppState & {
138
137
  multiElement: AppState["multiElement"];
139
138
  newElement: AppState["newElement"];
140
139
  isBindingEnabled: AppState["isBindingEnabled"];
140
+ isMidpointSnappingEnabled: AppState["isMidpointSnappingEnabled"];
141
141
  suggestedBinding: AppState["suggestedBinding"];
142
142
  isRotating: AppState["isRotating"];
143
143
  elementsToHighlight: AppState["elementsToHighlight"];
@@ -172,6 +172,7 @@ export type ObservedElementsAppState = {
172
172
  lockedMultiSelections: AppState["lockedMultiSelections"];
173
173
  activeLockedId: AppState["activeLockedId"];
174
174
  };
175
+ export type BoxSelectionMode = "contain" | "overlap";
175
176
  export interface AppState {
176
177
  contextMenu: {
177
178
  items: ContextMenuItems;
@@ -205,8 +206,21 @@ export interface AppState {
205
206
  * - set on pointer down, updated during pointer move
206
207
  */
207
208
  selectionElement: NonDeletedExcalidrawElement | null;
209
+ /**
210
+ * tracking current arrow binding editor state (takes into account
211
+ * `bindingPreference` and keyboard modifiers (ctrl/alt)
212
+ */
208
213
  isBindingEnabled: boolean;
209
- startBoundElement: NonDeleted<ExcalidrawBindableElement> | null;
214
+ /** user box selection preference; defaults to "contain" when unset */
215
+ boxSelectionMode: BoxSelectionMode;
216
+ /** user arrow binding preference */
217
+ bindingPreference: "enabled" | "disabled";
218
+ /** user preference whether arrow snap to midpoints while binding */
219
+ isMidpointSnappingEnabled: boolean;
220
+ /**
221
+ * The bindable element the UI highlights for the user when an arrow is
222
+ * dragged or otherwise its endpoint being close to said element.
223
+ */
210
224
  suggestedBinding: {
211
225
  element: NonDeleted<ExcalidrawBindableElement>;
212
226
  midPoint?: GlobalPoint;
@@ -223,7 +237,7 @@ export interface AppState {
223
237
  /**
224
238
  * set when a new text is created or when an existing text is being edited
225
239
  */
226
- editingTextElement: NonDeletedExcalidrawElement | null;
240
+ editingTextElement: ExcalidrawTextElement | null;
227
241
  activeTool: {
228
242
  /**
229
243
  * indicates a previous tool we should revert back to if we deselect the
@@ -246,9 +260,10 @@ export interface AppState {
246
260
  currentItemStrokeColor: string;
247
261
  currentItemBackgroundColor: string;
248
262
  currentItemFillStyle: ExcalidrawElement["fillStyle"];
249
- currentItemStrokeWidth: number;
263
+ currentItemStrokeWidthKey: StrokeWidthKey;
250
264
  currentItemStrokeStyle: ExcalidrawElement["strokeStyle"];
251
265
  currentItemRoughness: number;
266
+ currentItemStrokeVariability: StrokeVariability;
252
267
  currentItemOpacity: number;
253
268
  currentItemFontFamily: FontFamilyValues;
254
269
  currentItemFontSize: number;
@@ -285,6 +300,10 @@ export interface AppState {
285
300
  } | {
286
301
  name: "elementLinkSelector";
287
302
  sourceElementId: ExcalidrawElement["id"];
303
+ } | {
304
+ name: "charts";
305
+ data: Spreadsheet;
306
+ rawText: string;
288
307
  };
289
308
  /**
290
309
  * Reflects user preference for whether the default sidebar should be docked.
@@ -307,7 +326,7 @@ export interface AppState {
307
326
  selectedElementsAreBeingDragged: boolean;
308
327
  shouldCacheIgnoreZoom: boolean;
309
328
  toast: {
310
- message: string;
329
+ message: React.ReactNode;
311
330
  closable?: boolean;
312
331
  duration?: number;
313
332
  } | null;
@@ -329,21 +348,13 @@ export interface AppState {
329
348
  height: number;
330
349
  offsetTop: number;
331
350
  offsetLeft: number;
332
- fileHandle: FileSystemHandle | null;
351
+ fileHandle: FileSystemFileHandle | null;
333
352
  collaborators: Map<SocketId, Collaborator>;
334
353
  stats: {
335
354
  open: boolean;
336
355
  /** bitmap. Use `STATS_PANELS` bit values */
337
356
  panels: number;
338
357
  };
339
- currentChartType: ChartType;
340
- pasteDialog: {
341
- shown: false;
342
- data: null;
343
- } | {
344
- shown: true;
345
- data: Spreadsheet;
346
- };
347
358
  showHyperlinkPopup: false | "info" | "editor";
348
359
  selectedLinearElement: LinearElementEditor | null;
349
360
  snapLines: readonly SnapLine[];
@@ -382,7 +393,7 @@ export type SearchMatch = {
382
393
  showOnCanvas: boolean;
383
394
  }[];
384
395
  };
385
- export type UIAppState = Omit<AppState, "startBoundElement" | "cursorButton" | "scrollX" | "scrollY">;
396
+ export type UIAppState = Omit<AppState, "cursorButton" | "scrollX" | "scrollY">;
386
397
  export type NormalizedZoomValue = number & {
387
398
  _brand: "normalizedZoom";
388
399
  };
@@ -430,11 +441,37 @@ export type OnUserFollowedPayload = {
430
441
  userToFollow: UserToFollow;
431
442
  action: "FOLLOW" | "UNFOLLOW";
432
443
  };
444
+ export type OnExportProgress = {
445
+ type: "progress";
446
+ message?: React.ReactNode;
447
+ /** 0-1 range */
448
+ progress?: number;
449
+ };
433
450
  export interface ExcalidrawProps {
434
451
  onChange?: (elements: readonly OrderedExcalidrawElement[], appState: AppState, files: BinaryFiles) => void;
452
+ onThemeChange?: (theme: Theme | "system") => void;
453
+ /**
454
+ * note: only subscribes if the props.onIncrement is defined on initial render
455
+ */
435
456
  onIncrement?: (event: DurableIncrement | EphemeralIncrement) => void;
436
457
  initialData?: (() => MaybePromise<ExcalidrawInitialDataState | null>) | MaybePromise<ExcalidrawInitialDataState | null>;
437
- excalidrawAPI?: (api: ExcalidrawImperativeAPI) => void;
458
+ /**
459
+ * Invoked as soon as the Excalidraw API is available
460
+ * NOTE editor is not yet mounted, and state is not yet initialized
461
+ */
462
+ onExcalidrawAPI?: (api: ExcalidrawImperativeAPI | null) => void;
463
+ /**
464
+ * Invoked once the editor root is mounted.
465
+ */
466
+ onMount?: (payload: ExcalidrawMountPayload) => void;
467
+ /**
468
+ * Invoked when the editor root is unmounted.
469
+ */
470
+ onUnmount?: () => void;
471
+ /**
472
+ * Invoked once the initial scene is loaded.
473
+ */
474
+ onInitialize?: (api: ExcalidrawImperativeAPI) => void;
438
475
  isCollaborating?: boolean;
439
476
  onPointerUpdate?: (payload: {
440
477
  pointer: {
@@ -472,6 +509,10 @@ export interface ExcalidrawProps {
472
509
  name?: string;
473
510
  renderCustomStats?: (elements: readonly NonDeletedExcalidrawElement[], appState: UIAppState) => JSX.Element;
474
511
  UIOptions?: Partial<UIOptions>;
512
+ /**
513
+ * dimensions and size constraints for inserted images
514
+ */
515
+ imageOptions?: ImageOptions;
475
516
  detectScroll?: boolean;
476
517
  handleKeyboardGlobally?: boolean;
477
518
  onLibraryChange?: (libraryItems: LibraryItems) => void | Promise<any>;
@@ -491,6 +532,29 @@ export interface ExcalidrawProps {
491
532
  aiEnabled?: boolean;
492
533
  showDeprecatedFonts?: boolean;
493
534
  renderScrollbars?: boolean;
535
+ /**
536
+ * Called before exporting to a file.
537
+ *
538
+ * Allows the host app to intercept and delay saving until async operations
539
+ * (e.g., images are loaded) complete.
540
+ *
541
+ * If Promise/AsyncGenerator is returned, a progress toast will be shown
542
+ * until the operation completes. Generator can yield progress updates.
543
+ */
544
+ onExport?: (
545
+ /** type of export. Currently we only call for JSON exports or
546
+ * JSON-embedded PNG (which is also identified as `json` type here)*/
547
+ type: "json", data: {
548
+ elements: readonly ExcalidrawElement[];
549
+ appState: AppState;
550
+ files: BinaryFiles;
551
+ }, options: {
552
+ /** signal that gets aborted if user cancels the export (e.g. closes
553
+ * the native file picker dialog). In that case, you can either
554
+ * return immediately, or throw AbortError.
555
+ */
556
+ signal: AbortSignal;
557
+ }) => MaybePromise<void> | AsyncGenerator<OnExportProgress, void>;
494
558
  }
495
559
  export type SceneData = {
496
560
  elements?: ImportedDataState["elements"];
@@ -503,12 +567,21 @@ export type ExportOpts = {
503
567
  onExportToBackend?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: UIAppState, files: BinaryFiles) => void;
504
568
  renderCustomUI?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: UIAppState, files: BinaryFiles, canvas: HTMLCanvasElement) => JSX.Element;
505
569
  };
570
+ export type ImageOptions = Partial<{
571
+ maxWidthOrHeight: number;
572
+ maxFileSizeBytes: number;
573
+ }>;
506
574
  export type CanvasActions = Partial<{
507
575
  changeViewBackgroundColor: boolean;
508
576
  clearCanvas: boolean;
509
577
  export: false | ExportOpts;
510
578
  loadScene: boolean;
511
579
  saveToActiveFile: boolean;
580
+ /**
581
+ * defaults to true if `props.theme` is omitted or `props.onThemeChange`
582
+ * is supplied (at which point the theme is considered as host-app controlled),
583
+ * else default to false
584
+ * */
512
585
  toggleTheme: boolean | null;
513
586
  saveAsImage: boolean;
514
587
  }>;
@@ -532,6 +605,7 @@ export type AppProps = Merge<ExcalidrawProps, {
532
605
  export: ExportOpts;
533
606
  };
534
607
  }>;
608
+ imageOptions: Required<ImageOptions>;
535
609
  detectScroll: boolean;
536
610
  handleKeyboardGlobally: boolean;
537
611
  isCollaborating: boolean;
@@ -543,6 +617,8 @@ export type AppProps = Merge<ExcalidrawProps, {
543
617
  export type AppClassProperties = {
544
618
  props: AppProps;
545
619
  state: AppState;
620
+ api: App["api"];
621
+ sessionExportThemeOverride: App["sessionExportThemeOverride"];
546
622
  interactiveCanvas: HTMLCanvasElement | null;
547
623
  /** static canvas */
548
624
  canvas: HTMLCanvasElement;
@@ -583,8 +659,11 @@ export type AppClassProperties = {
583
659
  onPointerUpEmitter: App["onPointerUpEmitter"];
584
660
  updateEditorAtom: App["updateEditorAtom"];
585
661
  onPointerDownEmitter: App["onPointerDownEmitter"];
662
+ onEvent: App["onEvent"];
663
+ onStateChange: App["onStateChange"];
586
664
  lastPointerMoveCoords: App["lastPointerMoveCoords"];
587
665
  bindModeHandler: App["bindModeHandler"];
666
+ setAppState: App["setAppState"];
588
667
  };
589
668
  export type PointerDownState = Readonly<{
590
669
  origin: Readonly<{
@@ -645,7 +724,18 @@ export type PointerDownState = Readonly<{
645
724
  };
646
725
  }>;
647
726
  export type UnsubscribeCallback = () => void;
727
+ export type ExcalidrawMountPayload = {
728
+ excalidrawAPI: ExcalidrawImperativeAPI;
729
+ container: HTMLDivElement | null;
730
+ };
731
+ export type ExcalidrawImperativeAPIEventMap = {
732
+ "editor:mount": [payload: ExcalidrawMountPayload];
733
+ "editor:initialize": [api: ExcalidrawImperativeAPI];
734
+ "editor:unmount": [];
735
+ };
648
736
  export interface ExcalidrawImperativeAPI {
737
+ /** Whether the editor has been unmounted and the API is no longer usable. */
738
+ isDestroyed: boolean;
649
739
  updateScene: InstanceType<typeof App>["updateScene"];
650
740
  applyDeltas: InstanceType<typeof App>["applyDeltas"];
651
741
  mutateElement: InstanceType<typeof App>["mutateElement"];
@@ -683,6 +773,8 @@ export interface ExcalidrawImperativeAPI {
683
773
  onPointerUp: (callback: (activeTool: AppState["activeTool"], pointerDownState: PointerDownState, event: PointerEvent) => void) => UnsubscribeCallback;
684
774
  onScrollChange: (callback: (scrollX: number, scrollY: number, zoom: Zoom) => void) => UnsubscribeCallback;
685
775
  onUserFollow: (callback: (payload: OnUserFollowedPayload) => void) => UnsubscribeCallback;
776
+ onStateChange: InstanceType<typeof App>["onStateChange"];
777
+ onEvent: InstanceType<typeof App>["onEvent"];
686
778
  }
687
779
  export type FrameNameBounds = {
688
780
  x: number;
@@ -1,7 +1,7 @@
1
1
  import type { ExcalidrawElement, ExcalidrawTextElement } from "@excalidraw/element/types";
2
2
  import type App from "../components/App";
3
3
  type SubmitHandler = () => void;
4
- export declare const textWysiwyg: ({ id, onChange, onSubmit, getViewportCoords, element, canvas, excalidrawContainer, app, autoSelect, }: {
4
+ export declare const textWysiwyg: ({ id, onChange, onSubmit, getViewportCoords, element, canvas, excalidrawContainer, app, autoSelect, initialCaretSceneCoords, }: {
5
5
  id: ExcalidrawElement["id"];
6
6
  /**
7
7
  * textWysiwyg only deals with `originalText`
@@ -20,5 +20,9 @@ export declare const textWysiwyg: ({ id, onChange, onSubmit, getViewportCoords,
20
20
  excalidrawContainer: HTMLDivElement | null;
21
21
  app: App;
22
22
  autoSelect?: boolean;
23
+ initialCaretSceneCoords?: {
24
+ x: number;
25
+ y: number;
26
+ } | null;
23
27
  }) => SubmitHandler;
24
28
  export {};
@@ -0,0 +1,29 @@
1
+ export declare const BASE_62_DIGITS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
2
+ /**
3
+ * @param {string} key
4
+ * @param {string} digits
5
+ * @return {void}
6
+ */
7
+ export declare function validateOrderKey(key: string, digits?: string): void;
8
+ /**
9
+ * @param {string | null | undefined} a
10
+ * @param {string | null | undefined} b
11
+ * @param {string=} digits
12
+ * @return {string}
13
+ */
14
+ export declare function generateKeyBetween(a: string | null | undefined, b: string | null | undefined, digits?: string): string;
15
+ /**
16
+ * same preconditions as generateKeysBetween.
17
+ * n >= 0.
18
+ * Returns an array of n distinct keys in sorted order.
19
+ * If a and b are both null, returns [a0, a1, ...]
20
+ * If one or the other is null, returns consecutive "integer"
21
+ * keys. Otherwise, returns relatively short keys between
22
+ * a and b.
23
+ * @param {string | null | undefined} a
24
+ * @param {string | null | undefined} b
25
+ * @param {number} n
26
+ * @param {string} digits
27
+ * @return {string[]}
28
+ */
29
+ export declare function generateNKeysBetween(a: string | null | undefined, b: string | null | undefined, n: number, digits?: string): string[];
@@ -0,0 +1,2 @@
1
+ export * from "./state";
2
+ export type { Point } from "./math";
@@ -0,0 +1,16 @@
1
+ export type Point = [x: number, y: number, r: number];
2
+ export declare function add([ax, ay, ar]: Point, [bx, by, br]: Point): Point;
3
+ export declare function sub([ax, ay, ar]: Point, [bx, by, br]: Point): Point;
4
+ export declare function smul([x, y, r]: Point, s: number): Point;
5
+ export declare function norm([x, y, r]: Point): Point;
6
+ export declare function rot([x, y, r]: Point, rad: number): Point;
7
+ export declare function plerp(a: Point, b: Point, t: number): Point;
8
+ export declare function lerp(a: number, b: number, t: number): number;
9
+ export declare function angle(p: Point, p1: Point, p2: Point): number;
10
+ export declare function normAngle(a: number): number;
11
+ export declare function mag([x, y]: Point): number;
12
+ export declare function dist([ax, ay]: Point, [bx, by]: Point): number;
13
+ export declare function getCircleAndPerpendicularLineIntersectionsAtPoint(point: Point, direction: Point, radius: number): [Point, Point];
14
+ export declare function runLength(ps: Point[]): number;
15
+ export declare const clamp: (v: number, min: number, max: number) => number;
16
+ export declare function distancePointToSegment(p3: Point, p1: Point, p2: Point): number;
@@ -0,0 +1,2 @@
1
+ import { type Point } from "./math";
2
+ export declare function douglasPeucker(points: Point[], epsilon: number): Point[];
@@ -0,0 +1,35 @@
1
+ import type { Point } from "./math";
2
+ export type SizeMappingDetails = {
3
+ pressure: number;
4
+ runningLength: number;
5
+ currentIndex: number;
6
+ totalLength: number;
7
+ };
8
+ export type LaserPointerOptions = {
9
+ size: number;
10
+ streamline: number;
11
+ simplify: number;
12
+ simplifyPhase: "tail" | "output" | "input";
13
+ keepHead: boolean;
14
+ sizeMapping: (details: SizeMappingDetails) => number;
15
+ };
16
+ export declare class LaserPointer {
17
+ static defaults: LaserPointerOptions;
18
+ static constants: {
19
+ cornerDetectionMaxAngle: number;
20
+ cornerDetectionVariance: (s: number) => 1 | 0.5;
21
+ maxTailLength: number;
22
+ };
23
+ options: LaserPointerOptions;
24
+ constructor(options: Partial<LaserPointerOptions>);
25
+ originalPoints: Point[];
26
+ private stablePoints;
27
+ private tailPoints;
28
+ private isFresh;
29
+ private get lastPoint();
30
+ addPoint(point: Point): void;
31
+ close(): void;
32
+ stabilizeTail(): void;
33
+ private getSize;
34
+ getStrokeOutline(sizeOverride?: number | undefined): Point[];
35
+ }
@@ -1,3 +1,2 @@
1
- export declare const PRECISION = 0.0001;
2
1
  export declare const LegendreGaussN24TValues: number[];
3
2
  export declare const LegendreGaussN24CValues: number[];
@@ -12,7 +12,10 @@ export declare const bezierEquation: <Point extends GlobalPoint | LocalPoint>(c:
12
12
  /**
13
13
  * Computes the intersection between a cubic spline and a line segment.
14
14
  */
15
- export declare function curveIntersectLineSegment<Point extends GlobalPoint | LocalPoint>(c: Curve<Point>, l: LineSegment<Point>): Point[];
15
+ export declare function curveIntersectLineSegment<Point extends GlobalPoint | LocalPoint>(c: Curve<Point>, l: LineSegment<Point>, opts?: {
16
+ tolerance?: number;
17
+ iterLimit?: number;
18
+ }): Point[];
16
19
  /**
17
20
  * Finds the closest point on the Bezier curve from another point
18
21
  *
@@ -57,7 +57,7 @@ export declare function pointsEqual<Point extends GlobalPoint | LocalPoint>(a: P
57
57
  * @param angle The radians to rotate the point by
58
58
  * @returns The rotated point
59
59
  */
60
- export declare function pointRotateRads<Point extends GlobalPoint | LocalPoint>([x, y]: Point, [cx, cy]: Point, angle: Radians): Point;
60
+ export declare function pointRotateRads<Point extends GlobalPoint | LocalPoint>(point: Point, center: Point, angle: Radians): Point;
61
61
  /**
62
62
  * Rotate a point by [angle] degree.
63
63
  *
@@ -125,3 +125,4 @@ export declare const pointScaleFromOrigin: <P extends GlobalPoint | LocalPoint>(
125
125
  * @returns TRUE if q is indeed between p and r
126
126
  */
127
127
  export declare const isPointWithinBounds: <P extends GlobalPoint | LocalPoint>(p: P, q: P, r: P) => boolean;
128
+ export declare const isValidPoint: (point: unknown) => point is LocalPoint;
@@ -1,4 +1,3 @@
1
1
  export * from "./export";
2
- export * from "./withinBounds";
3
- export * from "./bbox";
2
+ export { elementsOverlappingBBox } from "@excalidraw/element";
4
3
  export { getCommonBounds } from "@excalidraw/element";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@excalidraw/element",
3
- "version": "0.18.0-2874f9e",
3
+ "version": "0.18.0-2a82821",
4
4
  "type": "module",
5
5
  "types": "./dist/types/element/src/index.d.ts",
6
6
  "main": "./dist/prod/index.js",
@@ -63,7 +63,8 @@
63
63
  "build:esm": "rimraf dist && node ../../scripts/buildBase.js && yarn gen:types"
64
64
  },
65
65
  "dependencies": {
66
- "@excalidraw/common": "0.18.0-2874f9e",
67
- "@excalidraw/math": "0.18.0-2874f9e"
66
+ "@excalidraw/common": "0.18.0-2a82821",
67
+ "@excalidraw/math": "0.18.0-2a82821",
68
+ "@excalidraw/fractional-indexing": "0.18.0-2a82821"
68
69
  }
69
70
  }
@@ -1,16 +0,0 @@
1
- export type AnimationCallback = (timestamp: number) => void | boolean;
2
- export type AnimationTarget = {
3
- callback: AnimationCallback;
4
- stopped: boolean;
5
- };
6
- export declare class AnimationFrameHandler {
7
- private targets;
8
- private rafIds;
9
- register(key: object, callback: AnimationCallback): void;
10
- start(key: object): void;
11
- stop(key: object): void;
12
- private constructFrame;
13
- private scheduleFrame;
14
- private cancelFrame;
15
- private onFrame;
16
- }
@@ -1,27 +0,0 @@
1
- import type { NonDeletedExcalidrawElement } from "@excalidraw/element/types";
2
- export type ChartElements = readonly NonDeletedExcalidrawElement[];
3
- export interface Spreadsheet {
4
- title: string | null;
5
- labels: string[] | null;
6
- values: number[];
7
- }
8
- export declare const NOT_SPREADSHEET = "NOT_SPREADSHEET";
9
- export declare const VALID_SPREADSHEET = "VALID_SPREADSHEET";
10
- type ParseSpreadsheetResult = {
11
- type: typeof NOT_SPREADSHEET;
12
- reason: string;
13
- } | {
14
- type: typeof VALID_SPREADSHEET;
15
- spreadsheet: Spreadsheet;
16
- };
17
- /**
18
- * @private exported for testing
19
- */
20
- export declare const tryParseNumber: (s: string) => number | null;
21
- /**
22
- * @private exported for testing
23
- */
24
- export declare const tryParseCells: (cells: string[][]) => ParseSpreadsheetResult;
25
- export declare const tryParseSpreadsheet: (text: string) => ParseSpreadsheetResult;
26
- export declare const renderSpreadsheet: (chartType: string, spreadsheet: Spreadsheet, x: number, y: number) => ChartElements;
27
- export {};
@@ -1,4 +0,0 @@
1
- import type { GenerateDiagramToCode } from "../../types";
2
- export declare const DiagramToCodePlugin: (props: {
3
- generate: GenerateDiagramToCode;
4
- }) => null;
@@ -1,15 +0,0 @@
1
- import "./ExcalidrawLogo.scss";
2
- type LogoSize = "xs" | "small" | "normal" | "large" | "custom" | "mobile";
3
- interface LogoProps {
4
- size?: LogoSize;
5
- withText?: boolean;
6
- style?: React.CSSProperties;
7
- /**
8
- * If true, the logo will not be wrapped in a Link component.
9
- * The link prop will be ignored as well.
10
- * It will merely be a plain div.
11
- */
12
- isNotLink?: boolean;
13
- }
14
- export declare const ExcalidrawLogo: ({ style, size, withText, }: LogoProps) => import("react/jsx-runtime").JSX.Element;
15
- export {};
@@ -1,10 +0,0 @@
1
- import React from "react";
2
- import type { Theme } from "@excalidraw/element/types";
3
- import type { Language } from "../i18n";
4
- interface Props {
5
- langCode: Language["code"];
6
- children: React.ReactElement;
7
- theme?: Theme;
8
- }
9
- export declare const InitializeApp: (props: Props) => import("react/jsx-runtime").JSX.Element;
10
- export {};
@@ -1,8 +0,0 @@
1
- import type { JSX, ReactNode } from "react";
2
- export declare const TTDDialogTrigger: {
3
- ({ children, icon, }: {
4
- children?: ReactNode;
5
- icon?: JSX.Element;
6
- }): import("react/jsx-runtime").JSX.Element;
7
- displayName: string;
8
- };
@@ -1,24 +0,0 @@
1
- import type { LLMMessage, TTTDDialog } from "@excalidraw/excalidraw/components/TTDDialog/types";
2
- interface StreamingOptions {
3
- url: string;
4
- messages: readonly LLMMessage[];
5
- onChunk?: (chunk: string) => void;
6
- extractRateLimits?: boolean;
7
- signal?: AbortSignal;
8
- onStreamCreated?: () => void;
9
- }
10
- export type StreamChunk = {
11
- type: "content";
12
- delta: string;
13
- } | {
14
- type: "done";
15
- finishReason: "stop" | "length" | "content_filter" | "tool_calls" | null;
16
- } | {
17
- type: "error";
18
- error: {
19
- message: string;
20
- status?: number;
21
- };
22
- };
23
- export declare function TTDStreamFetch(options: StreamingOptions): Promise<TTTDDialog.OnTextSubmitRetValue>;
24
- export {};
@@ -1,8 +0,0 @@
1
- import "./FooterCenter.scss";
2
- declare const FooterCenter: {
3
- ({ children }: {
4
- children?: React.ReactNode;
5
- }): import("react/jsx-runtime").JSX.Element;
6
- displayName: string;
7
- };
8
- export default FooterCenter;
@@ -1,11 +0,0 @@
1
- import { type EditorInterface } from "@excalidraw/common";
2
- import "./LiveCollaborationTrigger.scss";
3
- declare const LiveCollaborationTrigger: {
4
- ({ isCollaborating, onSelect, editorInterface, ...rest }: {
5
- isCollaborating: boolean;
6
- onSelect: () => void;
7
- editorInterface?: EditorInterface;
8
- } & React.ButtonHTMLAttributes<HTMLButtonElement>): import("react/jsx-runtime").JSX.Element;
9
- displayName: string;
10
- };
11
- export default LiveCollaborationTrigger;
@@ -1,58 +0,0 @@
1
- import type { JSX } from "react";
2
- declare const Center: {
3
- ({ children }: {
4
- children?: React.ReactNode;
5
- }): import("react/jsx-runtime").JSX.Element;
6
- displayName: string;
7
- Logo: {
8
- ({ children }: {
9
- children?: React.ReactNode;
10
- }): import("react/jsx-runtime").JSX.Element;
11
- displayName: string;
12
- };
13
- Heading: {
14
- ({ children }: {
15
- children: React.ReactNode;
16
- }): import("react/jsx-runtime").JSX.Element;
17
- displayName: string;
18
- };
19
- Menu: {
20
- ({ children }: {
21
- children?: React.ReactNode;
22
- }): import("react/jsx-runtime").JSX.Element;
23
- displayName: string;
24
- };
25
- MenuItem: {
26
- ({ onSelect, children, icon, shortcut, className, ...props }: {
27
- onSelect: () => void;
28
- children: React.ReactNode;
29
- icon?: JSX.Element;
30
- shortcut?: string | null;
31
- } & React.ButtonHTMLAttributes<HTMLButtonElement>): import("react/jsx-runtime").JSX.Element;
32
- displayName: string;
33
- };
34
- MenuItemLink: {
35
- ({ children, href, icon, shortcut, className, ...props }: {
36
- children: React.ReactNode;
37
- href: string;
38
- icon?: JSX.Element;
39
- shortcut?: string | null;
40
- } & React.AnchorHTMLAttributes<HTMLAnchorElement>): import("react/jsx-runtime").JSX.Element;
41
- displayName: string;
42
- };
43
- MenuItemHelp: {
44
- (): import("react/jsx-runtime").JSX.Element;
45
- displayName: string;
46
- };
47
- MenuItemLoadScene: {
48
- (): import("react/jsx-runtime").JSX.Element | null;
49
- displayName: string;
50
- };
51
- MenuItemLiveCollaborationTrigger: {
52
- ({ onSelect, }: {
53
- onSelect: () => any;
54
- }): import("react/jsx-runtime").JSX.Element;
55
- displayName: string;
56
- };
57
- };
58
- export { Center };