@myoc/math 0.19.502-ff5a131b0 → 0.19.504

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 (122) hide show
  1. package/dist/dev/index.js +116 -125
  2. package/dist/dev/index.js.map +4 -4
  3. package/dist/prod/index.js +1 -1
  4. package/dist/types/common/debug.d.ts +21 -0
  5. package/dist/types/common/src/appEventBus.d.ts +27 -0
  6. package/dist/types/common/src/colors.d.ts +1 -1
  7. package/dist/types/common/src/constants.d.ts +3 -0
  8. package/dist/types/common/src/index.d.ts +3 -0
  9. package/dist/types/common/src/utils.d.ts +4 -7
  10. package/dist/types/common/src/versionedSnapshotStore.d.ts +17 -0
  11. package/dist/types/element/src/Scene.d.ts +2 -0
  12. package/dist/types/element/src/arrange-algorithms/maxRects.d.ts +16 -0
  13. package/dist/types/element/src/arrowheads.d.ts +3 -0
  14. package/dist/types/element/src/arrows/focus.d.ts +27 -0
  15. package/dist/types/element/src/arrows/helpers.d.ts +5 -0
  16. package/dist/types/element/src/binding.d.ts +13 -8
  17. package/dist/types/element/src/bounds.d.ts +1 -1
  18. package/dist/types/element/src/collision.d.ts +4 -3
  19. package/dist/types/element/src/distribute.d.ts +2 -1
  20. package/dist/types/element/src/elbowArrow.d.ts +2 -0
  21. package/dist/types/element/src/index.d.ts +4 -0
  22. package/dist/types/element/src/linearElementEditor.d.ts +6 -1
  23. package/dist/types/element/src/mutateElement.d.ts +2 -0
  24. package/dist/types/element/src/selection.d.ts +5 -1
  25. package/dist/types/element/src/shapes.d.ts +2 -22
  26. package/dist/types/element/src/textElement.d.ts +1 -1
  27. package/dist/types/element/src/textWrapping.d.ts +26 -0
  28. package/dist/types/element/src/types.d.ts +6 -3
  29. package/dist/types/element/src/utils.d.ts +5 -3
  30. package/dist/types/element/src/zindex.d.ts +1 -1
  31. package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +38 -35
  32. package/dist/types/excalidraw/actions/actionAlign.d.ts +8 -8
  33. package/dist/types/excalidraw/actions/actionArrange.d.ts +2 -2
  34. package/dist/types/excalidraw/actions/actionBoundText.d.ts +27 -25
  35. package/dist/types/excalidraw/actions/actionCanvas.d.ts +159 -148
  36. package/dist/types/excalidraw/actions/actionClipboard.d.ts +28 -26
  37. package/dist/types/excalidraw/actions/actionCropEditor.d.ts +13 -12
  38. package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +43 -38
  39. package/dist/types/excalidraw/actions/actionDistribute.d.ts +4 -4
  40. package/dist/types/excalidraw/actions/actionDuplicateSelection.d.ts +2 -2
  41. package/dist/types/excalidraw/actions/actionElementLink.d.ts +9 -12
  42. package/dist/types/excalidraw/actions/actionElementLock.d.ts +28 -26
  43. package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +13 -12
  44. package/dist/types/excalidraw/actions/actionExport.d.ts +87 -380
  45. package/dist/types/excalidraw/actions/actionFlip.d.ts +4 -4
  46. package/dist/types/excalidraw/actions/actionFrame.d.ts +54 -50
  47. package/dist/types/excalidraw/actions/actionGroup.d.ts +31 -29
  48. package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +15 -12
  49. package/dist/types/excalidraw/actions/actionLink.d.ts +15 -14
  50. package/dist/types/excalidraw/actions/actionMenu.d.ts +11 -14
  51. package/dist/types/excalidraw/actions/actionProperties.d.ts +33 -31
  52. package/dist/types/excalidraw/actions/actionSelectAll.d.ts +16 -15
  53. package/dist/types/excalidraw/actions/actionSmartZoom.d.ts +2 -2
  54. package/dist/types/excalidraw/actions/actionStyles.d.ts +17 -15
  55. package/dist/types/excalidraw/actions/actionTextAutoResize.d.ts +3 -3
  56. package/dist/types/excalidraw/actions/actionToggleArrowBinding.d.ts +181 -0
  57. package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +15 -14
  58. package/dist/types/excalidraw/actions/actionToggleMidpointSnapping.d.ts +181 -0
  59. package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +15 -14
  60. package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +11 -14
  61. package/dist/types/excalidraw/actions/actionToggleStats.d.ts +15 -14
  62. package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +15 -14
  63. package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +15 -14
  64. package/dist/types/excalidraw/actions/actionZindex.d.ts +8 -8
  65. package/dist/types/excalidraw/actions/index.d.ts +2 -0
  66. package/dist/types/excalidraw/actions/shortcuts.d.ts +1 -1
  67. package/dist/types/excalidraw/actions/types.d.ts +1 -1
  68. package/dist/types/excalidraw/appState.d.ts +15 -13
  69. package/dist/types/excalidraw/charts/charts.bar.d.ts +2 -0
  70. package/dist/types/excalidraw/charts/charts.constants.d.ts +48 -0
  71. package/dist/types/excalidraw/charts/charts.helpers.d.ts +32 -0
  72. package/dist/types/excalidraw/charts/charts.line.d.ts +2 -0
  73. package/dist/types/excalidraw/charts/charts.parse.d.ts +10 -0
  74. package/dist/types/excalidraw/charts/charts.radar.d.ts +2 -0
  75. package/dist/types/excalidraw/charts/charts.types.d.ts +18 -0
  76. package/dist/types/excalidraw/charts/index.d.ts +7 -0
  77. package/dist/types/excalidraw/clipboard.d.ts +6 -7
  78. package/dist/types/excalidraw/components/App.d.ts +57 -14
  79. package/dist/types/excalidraw/components/AppStateObserver.d.ts +37 -0
  80. package/dist/types/excalidraw/components/CommandPalette/types.d.ts +1 -1
  81. package/dist/types/excalidraw/components/IconPicker.d.ts +14 -9
  82. package/dist/types/excalidraw/components/PasteChartDialog.d.ts +4 -5
  83. package/dist/types/excalidraw/components/PropertiesPopover.d.ts +1 -1
  84. package/dist/types/excalidraw/components/Range.d.ts +10 -4
  85. package/dist/types/excalidraw/components/Toast.d.ts +8 -4
  86. package/dist/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +1 -0
  87. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenu.d.ts +30 -17
  88. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuContent.d.ts +3 -2
  89. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItem.d.ts +11 -13
  90. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemCheckbox.d.ts +5 -0
  91. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuSub.d.ts +23 -0
  92. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuSubContent.d.ts +8 -0
  93. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuSubTrigger.d.ts +12 -0
  94. package/dist/types/excalidraw/components/dropdownMenu/common.d.ts +1 -1
  95. package/dist/types/excalidraw/components/dropdownMenu/dropdownMenuUtils.d.ts +2 -0
  96. package/dist/types/excalidraw/components/icons.d.ts +23 -9
  97. package/dist/types/excalidraw/components/main-menu/DefaultItems.d.ts +17 -0
  98. package/dist/types/excalidraw/components/main-menu/MainMenu.d.ts +23 -13
  99. package/dist/types/excalidraw/data/blob.d.ts +57 -56
  100. package/dist/types/excalidraw/data/filesystem.d.ts +3 -5
  101. package/dist/types/excalidraw/data/index.d.ts +2 -3
  102. package/dist/types/excalidraw/data/json.d.ts +43 -34
  103. package/dist/types/excalidraw/data/resave.d.ts +7 -2
  104. package/dist/types/excalidraw/editorPreferences.d.ts +11 -0
  105. package/dist/types/excalidraw/textAutoResizeHandle.d.ts +15 -0
  106. package/dist/types/excalidraw/types.d.ts +114 -16
  107. package/dist/types/excalidraw/wysiwyg/textWysiwyg.d.ts +5 -1
  108. package/dist/types/math/src/point.d.ts +7 -2
  109. package/dist/types/math/src/types.d.ts +25 -1
  110. package/package.json +2 -2
  111. package/dist/types/excalidraw/charts.d.ts +0 -27
  112. package/dist/types/excalidraw/components/DiagramToCodePlugin/DiagramToCodePlugin.d.ts +0 -4
  113. package/dist/types/excalidraw/components/ExcalidrawLogo.d.ts +0 -15
  114. package/dist/types/excalidraw/components/InitializeApp.d.ts +0 -10
  115. package/dist/types/excalidraw/components/footer/FooterCenter.d.ts +0 -8
  116. package/dist/types/excalidraw/components/live-collaboration/LiveCollaborationTrigger.d.ts +0 -11
  117. package/dist/types/excalidraw/components/welcome-screen/WelcomeScreen.Center.d.ts +0 -58
  118. package/dist/types/excalidraw/components/welcome-screen/WelcomeScreen.Hints.d.ts +0 -19
  119. package/dist/types/excalidraw/components/welcome-screen/WelcomeScreen.d.ts +0 -84
  120. package/dist/types/excalidraw/data/reconcile.d.ts +0 -7
  121. package/dist/types/excalidraw/index.d.ts +0 -42
  122. package/dist/types/excalidraw/polyfill.d.ts +0 -2
@@ -1,15 +1,15 @@
1
1
  import type { IMAGE_MIME_TYPES, UserIdleState, throttleRAF, MIME_TYPES, ColorTuple, EditorInterface } 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, ArrangeAlgorithms, 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, ArrangeAlgorithms, BindMode, ExcalidrawTextElement } 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
+ import type { GlobalPoint } from "@excalidraw/math";
7
8
  import type { Action } from "./actions/types";
8
9
  import type { Spreadsheet } from "./charts";
9
10
  import type { ClipboardData } from "./clipboard";
10
11
  import type App from "./components/App";
11
12
  import type Library from "./data/library";
12
- import type { FileSystemHandle } from "./data/filesystem";
13
13
  import type { ContextMenuItems } from "./components/ContextMenu";
14
14
  import type { SnapLine } from "./snapping";
15
15
  import type { ImportedDataState } from "./data/types";
@@ -17,6 +17,7 @@ import type { Language } from "./i18n";
17
17
  import type { isOverScrollBars } from "./scene/scrollbars";
18
18
  import type React from "react";
19
19
  import type { JSX } from "react";
20
+ export type { App };
20
21
  export type SocketId = string & {
21
22
  _brand: "SocketId";
22
23
  };
@@ -128,6 +129,7 @@ export type StaticCanvasAppState = Readonly<_CommonCanvasAppState & {
128
129
  croppingElementId: AppState["croppingElementId"];
129
130
  }>;
130
131
  export type InteractiveCanvasAppState = Readonly<_CommonCanvasAppState & {
132
+ activeTool: AppState["activeTool"];
131
133
  activeEmbeddable: AppState["activeEmbeddable"];
132
134
  selectionElement: AppState["selectionElement"];
133
135
  selectedGroupIds: AppState["selectedGroupIds"];
@@ -135,6 +137,7 @@ export type InteractiveCanvasAppState = Readonly<_CommonCanvasAppState & {
135
137
  multiElement: AppState["multiElement"];
136
138
  newElement: AppState["newElement"];
137
139
  isBindingEnabled: AppState["isBindingEnabled"];
140
+ isMidpointSnappingEnabled: AppState["isMidpointSnappingEnabled"];
138
141
  suggestedBinding: AppState["suggestedBinding"];
139
142
  isRotating: AppState["isRotating"];
140
143
  elementsToHighlight: AppState["elementsToHighlight"];
@@ -150,6 +153,7 @@ export type InteractiveCanvasAppState = Readonly<_CommonCanvasAppState & {
150
153
  frameRendering: AppState["frameRendering"];
151
154
  shouldCacheIgnoreZoom: AppState["shouldCacheIgnoreZoom"];
152
155
  exportScale: AppState["exportScale"];
156
+ currentItemArrowType: AppState["currentItemArrowType"];
153
157
  }>;
154
158
  export type ObservedAppState = ObservedStandaloneAppState & ObservedElementsAppState;
155
159
  export type ObservedStandaloneAppState = {
@@ -170,6 +174,25 @@ export type ObservedElementsAppState = {
170
174
  };
171
175
  export type NormaliseMode = "first" | "average";
172
176
  export type NormaliseMetric = "scale" | "height" | "width" | "size";
177
+ export type SmartZoomPreferences = {
178
+ fitToViewport?: boolean;
179
+ animate?: boolean;
180
+ duration?: number;
181
+ viewportZoomFactor?: number;
182
+ };
183
+ export type ArrangePreferences = {
184
+ algorithm?: ArrangeAlgorithms;
185
+ gap?: number;
186
+ };
187
+ export type NormalisePreferences = {
188
+ mode?: NormaliseMode;
189
+ metric?: NormaliseMetric;
190
+ };
191
+ export type EditorPreferences = {
192
+ smartZoom?: SmartZoomPreferences;
193
+ arrange?: ArrangePreferences;
194
+ normalise?: NormalisePreferences;
195
+ };
173
196
  export interface AppState {
174
197
  contextMenu: {
175
198
  items: ContextMenuItems;
@@ -215,9 +238,20 @@ export interface AppState {
215
238
  * - set on pointer down, updated during pointer move
216
239
  */
217
240
  selectionElement: NonDeletedExcalidrawElement | null;
241
+ /**
242
+ * tracking current arrow binding editor state (takes into account
243
+ * `bindingPreference` and keyboard modifiers (ctrl/alt)
244
+ */
218
245
  isBindingEnabled: boolean;
246
+ /** user arrow binding preference */
247
+ bindingPreference: "enabled" | "disabled";
248
+ /** user preference whether arrow snap to midpoints while binding */
249
+ isMidpointSnappingEnabled: boolean;
219
250
  startBoundElement: NonDeleted<ExcalidrawBindableElement> | null;
220
- suggestedBinding: NonDeleted<ExcalidrawBindableElement> | null;
251
+ suggestedBinding: {
252
+ element: NonDeleted<ExcalidrawBindableElement>;
253
+ midPoint?: GlobalPoint;
254
+ } | null;
221
255
  frameToHighlight: NonDeleted<ExcalidrawFrameLikeElement> | null;
222
256
  frameRendering: {
223
257
  enabled: boolean;
@@ -230,7 +264,7 @@ export interface AppState {
230
264
  /**
231
265
  * set when a new text is created or when an existing text is being edited
232
266
  */
233
- editingTextElement: NonDeletedExcalidrawElement | null;
267
+ editingTextElement: ExcalidrawTextElement | null;
234
268
  activeTool: {
235
269
  /**
236
270
  * indicates a previous tool we should revert back to if we deselect the
@@ -289,6 +323,10 @@ export interface AppState {
289
323
  } | {
290
324
  name: "elementLinkSelector";
291
325
  sourceElementId: ExcalidrawElement["id"];
326
+ } | {
327
+ name: "charts";
328
+ data: Spreadsheet;
329
+ rawText: string;
292
330
  };
293
331
  /**
294
332
  * Reflects user preference for whether the default sidebar should be docked.
@@ -311,7 +349,7 @@ export interface AppState {
311
349
  selectedElementsAreBeingDragged: boolean;
312
350
  shouldCacheIgnoreZoom: boolean;
313
351
  toast: {
314
- message: string;
352
+ message: React.ReactNode;
315
353
  closable?: boolean;
316
354
  duration?: number;
317
355
  } | null;
@@ -333,21 +371,13 @@ export interface AppState {
333
371
  height: number;
334
372
  offsetTop: number;
335
373
  offsetLeft: number;
336
- fileHandle: FileSystemHandle | null;
374
+ fileHandle: FileSystemFileHandle | null;
337
375
  collaborators: Map<SocketId, Collaborator>;
338
376
  stats: {
339
377
  open: boolean;
340
378
  /** bitmap. Use `STATS_PANELS` bit values */
341
379
  panels: number;
342
380
  };
343
- currentChartType: ChartType;
344
- pasteDialog: {
345
- shown: false;
346
- data: null;
347
- } | {
348
- shown: true;
349
- data: Spreadsheet;
350
- };
351
381
  showHyperlinkPopup: false | "info" | "editor";
352
382
  selectedLinearElement: LinearElementEditor | null;
353
383
  snapLines: readonly SnapLine[];
@@ -434,11 +464,36 @@ export type OnUserFollowedPayload = {
434
464
  userToFollow: UserToFollow;
435
465
  action: "FOLLOW" | "UNFOLLOW";
436
466
  };
467
+ export type OnExportProgress = {
468
+ type: "progress";
469
+ message?: React.ReactNode;
470
+ /** 0-1 range */
471
+ progress?: number;
472
+ };
437
473
  export interface ExcalidrawProps {
438
474
  onChange?: (elements: readonly OrderedExcalidrawElement[], appState: AppState, files: BinaryFiles) => void;
475
+ /**
476
+ * note: only subscribes if the props.onIncrement is defined on initial render
477
+ */
439
478
  onIncrement?: (event: DurableIncrement | EphemeralIncrement) => void;
440
479
  initialData?: (() => MaybePromise<ExcalidrawInitialDataState | null>) | MaybePromise<ExcalidrawInitialDataState | null>;
441
- excalidrawAPI?: (api: ExcalidrawImperativeAPI) => void;
480
+ /**
481
+ * Invoked as soon as the Excalidraw API is available
482
+ * NOTE editor is not yet mounted, and state is not yet initialized
483
+ */
484
+ onExcalidrawAPI?: (api: ExcalidrawImperativeAPI | null) => void;
485
+ /**
486
+ * Invoked once the editor root is mounted.
487
+ */
488
+ onMount?: (payload: ExcalidrawMountPayload) => void;
489
+ /**
490
+ * Invoked when the editor root is unmounted.
491
+ */
492
+ onUnmount?: () => void;
493
+ /**
494
+ * Invoked once the initial scene is loaded.
495
+ */
496
+ onInitialize?: (api: ExcalidrawImperativeAPI) => void;
442
497
  isCollaborating?: boolean;
443
498
  onPointerUpdate?: (payload: {
444
499
  pointer: {
@@ -475,6 +530,8 @@ export interface ExcalidrawProps {
475
530
  theme?: Theme;
476
531
  name?: string;
477
532
  renderCustomStats?: (elements: readonly NonDeletedExcalidrawElement[], appState: UIAppState) => JSX.Element;
533
+ editorPreferences?: EditorPreferences;
534
+ onEditorPreferencesChange?: (next: EditorPreferences) => void;
478
535
  UIOptions?: Partial<UIOptions>;
479
536
  detectScroll?: boolean;
480
537
  handleKeyboardGlobally?: boolean;
@@ -497,6 +554,29 @@ export interface ExcalidrawProps {
497
554
  strokeColorTopPicks?: ColorTuple;
498
555
  backgroundColorTopPicks?: ColorTuple;
499
556
  renderScrollbars?: boolean;
557
+ /**
558
+ * Called before exporting to a file.
559
+ *
560
+ * Allows the host app to intercept and delay saving until async operations
561
+ * (e.g., images are loaded) complete.
562
+ *
563
+ * If Promise/AsyncGenerator is returned, a progress toast will be shown
564
+ * until the operation completes. Generator can yield progress updates.
565
+ */
566
+ onExport?: (
567
+ /** type of export. Currently we only call for JSON exports or
568
+ * JSON-embedded PNG (which is also identified as `json` type here)*/
569
+ type: "json", data: {
570
+ elements: readonly ExcalidrawElement[];
571
+ appState: AppState;
572
+ files: BinaryFiles;
573
+ }, options: {
574
+ /** signal that gets aborted if user cancels the export (e.g. closes
575
+ * the native file picker dialog). In that case, you can either
576
+ * return immediately, or throw AbortError.
577
+ */
578
+ signal: AbortSignal;
579
+ }) => MaybePromise<void> | AsyncGenerator<OnExportProgress, void>;
500
580
  }
501
581
  export type SceneData = {
502
582
  elements?: ImportedDataState["elements"];
@@ -548,6 +628,8 @@ export type AppProps = Merge<ExcalidrawProps, {
548
628
  export type AppClassProperties = {
549
629
  props: AppProps;
550
630
  state: AppState;
631
+ api: App["api"];
632
+ sessionExportThemeOverride: App["sessionExportThemeOverride"];
551
633
  interactiveCanvas: HTMLCanvasElement | null;
552
634
  /** static canvas */
553
635
  canvas: HTMLCanvasElement;
@@ -588,7 +670,11 @@ export type AppClassProperties = {
588
670
  onPointerUpEmitter: App["onPointerUpEmitter"];
589
671
  updateEditorAtom: App["updateEditorAtom"];
590
672
  onPointerDownEmitter: App["onPointerDownEmitter"];
673
+ onEvent: App["onEvent"];
674
+ onStateChange: App["onStateChange"];
675
+ lastPointerMoveCoords: App["lastPointerMoveCoords"];
591
676
  bindModeHandler: App["bindModeHandler"];
677
+ setAppState: App["setAppState"];
592
678
  };
593
679
  export type PointerDownState = Readonly<{
594
680
  origin: Readonly<{
@@ -649,7 +735,18 @@ export type PointerDownState = Readonly<{
649
735
  };
650
736
  }>;
651
737
  export type UnsubscribeCallback = () => void;
738
+ export type ExcalidrawMountPayload = {
739
+ excalidrawAPI: ExcalidrawImperativeAPI;
740
+ container: HTMLDivElement | null;
741
+ };
742
+ export type ExcalidrawImperativeAPIEventMap = {
743
+ "editor:mount": [payload: ExcalidrawMountPayload];
744
+ "editor:initialize": [api: ExcalidrawImperativeAPI];
745
+ "editor:unmount": [];
746
+ };
652
747
  export interface ExcalidrawImperativeAPI {
748
+ /** Whether the editor has been unmounted and the API is no longer usable. */
749
+ isDestroyed: boolean;
653
750
  updateScene: InstanceType<typeof App>["updateScene"];
654
751
  applyDeltas: InstanceType<typeof App>["applyDeltas"];
655
752
  mutateElement: InstanceType<typeof App>["mutateElement"];
@@ -688,6 +785,8 @@ export interface ExcalidrawImperativeAPI {
688
785
  onPointerUp: (callback: (activeTool: AppState["activeTool"], pointerDownState: PointerDownState, event: PointerEvent) => void) => UnsubscribeCallback;
689
786
  onScrollChange: (callback: (scrollX: number, scrollY: number, zoom: Zoom) => void) => UnsubscribeCallback;
690
787
  onUserFollow: (callback: (payload: OnUserFollowedPayload) => void) => UnsubscribeCallback;
788
+ onStateChange: InstanceType<typeof App>["onStateChange"];
789
+ onEvent: InstanceType<typeof App>["onEvent"];
691
790
  }
692
791
  export type FrameNameBounds = {
693
792
  x: number;
@@ -728,4 +827,3 @@ export type Offsets = Partial<{
728
827
  bottom: number;
729
828
  left: number;
730
829
  }>;
731
- export {};
@@ -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 {};
@@ -1,4 +1,4 @@
1
- import type { LocalPoint, GlobalPoint, Radians, Degrees, Vector } from "./types";
1
+ import type { LocalPoint, GlobalPoint, Radians, Degrees, Vector, GlobalCoord, LocalCoord } from "./types";
2
2
  /**
3
3
  * Create a properly typed Point instance from the X and Y coordinates.
4
4
  *
@@ -7,6 +7,11 @@ import type { LocalPoint, GlobalPoint, Radians, Degrees, Vector } from "./types"
7
7
  * @returns The branded and created point
8
8
  */
9
9
  export declare function pointFrom<Point extends GlobalPoint | LocalPoint>(x: number, y: number): Point;
10
+ export declare function pointFrom<Coord extends GlobalCoord | LocalCoord>(coords: Coord): Coord extends GlobalCoord ? GlobalPoint : LocalPoint;
11
+ export declare function pointFrom<Point extends GlobalPoint | LocalPoint>(coords: {
12
+ x: number;
13
+ y: number;
14
+ }): Point;
10
15
  /**
11
16
  * Converts and remaps an array containing a pair of numbers to Point.
12
17
  *
@@ -52,7 +57,7 @@ export declare function pointsEqual<Point extends GlobalPoint | LocalPoint>(a: P
52
57
  * @param angle The radians to rotate the point by
53
58
  * @returns The rotated point
54
59
  */
55
- 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;
56
61
  /**
57
62
  * Rotate a point by [angle] degree.
58
63
  *
@@ -19,12 +19,24 @@ export type InclusiveRange = [number, number] & {
19
19
  _brand: "excalimath_degree";
20
20
  };
21
21
  /**
22
- * Represents a 2D position in world or canvas space. A
22
+ * Represents a 2D position in world/canvas/scene space. A
23
23
  * global coordinate.
24
24
  */
25
25
  export type GlobalPoint = [x: number, y: number] & {
26
26
  _brand: "excalimath__globalpoint";
27
27
  };
28
+ /**
29
+ * Represents a 2D position in world/canvas/scene space. A
30
+ * global coordinate.
31
+ *
32
+ * TODO remove this once we migrate the codebase to use Point tuples everywhere
33
+ */
34
+ export type GlobalCoord = {
35
+ x: number;
36
+ y: number;
37
+ } & {
38
+ _brand: "excalimath__globalcoord";
39
+ };
28
40
  /**
29
41
  * Represents a 2D position in whatever local space it's
30
42
  * needed. A local coordinate.
@@ -32,6 +44,18 @@ export type GlobalPoint = [x: number, y: number] & {
32
44
  export type LocalPoint = [x: number, y: number] & {
33
45
  _brand: "excalimath__localpoint";
34
46
  };
47
+ /**
48
+ * Represents a 2D position in whatever local space it's needed.
49
+ * A local coordinate.
50
+ *
51
+ * TODO remove this once we migrate the codebase to use Point tuples everywhere
52
+ */
53
+ export type LocalCoord = {
54
+ x: number;
55
+ y: number;
56
+ } & {
57
+ _brand: "excalimath__localcoord";
58
+ };
35
59
  /**
36
60
  * A line is an infinitely long object with no width, depth, or curvature.
37
61
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myoc/math",
3
- "version": "0.19.502-ff5a131b0",
3
+ "version": "0.19.504",
4
4
  "type": "module",
5
5
  "types": "./dist/types/math/src/index.d.ts",
6
6
  "main": "./dist/prod/index.js",
@@ -61,6 +61,6 @@
61
61
  "build:esm": "rimraf dist && node ../../scripts/buildBase.js && yarn gen:types"
62
62
  },
63
63
  "dependencies": {
64
- "@excalidraw/common": "npm:@myoc/common@0.19.502-ff5a131b0"
64
+ "@excalidraw/common": "npm:@myoc/common@0.19.504"
65
65
  }
66
66
  }
@@ -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 "./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 };
@@ -1,19 +0,0 @@
1
- declare const MenuHint: {
2
- ({ children }: {
3
- children?: React.ReactNode;
4
- }): import("react/jsx-runtime").JSX.Element;
5
- displayName: string;
6
- };
7
- declare const ToolbarHint: {
8
- ({ children }: {
9
- children?: React.ReactNode;
10
- }): import("react/jsx-runtime").JSX.Element;
11
- displayName: string;
12
- };
13
- declare const HelpHint: {
14
- ({ children }: {
15
- children?: React.ReactNode;
16
- }): import("react/jsx-runtime").JSX.Element;
17
- displayName: string;
18
- };
19
- export { HelpHint, MenuHint, ToolbarHint };
@@ -1,84 +0,0 @@
1
- import "./WelcomeScreen.scss";
2
- declare const WelcomeScreen: {
3
- (props: {
4
- children?: React.ReactNode;
5
- }): import("react/jsx-runtime").JSX.Element;
6
- displayName: string;
7
- Center: {
8
- ({ children }: {
9
- children?: React.ReactNode;
10
- }): import("react/jsx-runtime").JSX.Element;
11
- displayName: string;
12
- Logo: {
13
- ({ children }: {
14
- children?: React.ReactNode;
15
- }): import("react/jsx-runtime").JSX.Element;
16
- displayName: string;
17
- };
18
- Heading: {
19
- ({ children }: {
20
- children: React.ReactNode;
21
- }): import("react/jsx-runtime").JSX.Element;
22
- displayName: string;
23
- };
24
- Menu: {
25
- ({ children }: {
26
- children?: React.ReactNode;
27
- }): import("react/jsx-runtime").JSX.Element;
28
- displayName: string;
29
- };
30
- MenuItem: {
31
- ({ onSelect, children, icon, shortcut, className, ...props }: {
32
- onSelect: () => void;
33
- children: React.ReactNode;
34
- icon?: import("react").JSX.Element;
35
- shortcut?: string | null;
36
- } & React.ButtonHTMLAttributes<HTMLButtonElement>): import("react/jsx-runtime").JSX.Element;
37
- displayName: string;
38
- };
39
- MenuItemLink: {
40
- ({ children, href, icon, shortcut, className, ...props }: {
41
- children: React.ReactNode;
42
- href: string;
43
- icon?: import("react").JSX.Element;
44
- shortcut?: string | null;
45
- } & React.AnchorHTMLAttributes<HTMLAnchorElement>): import("react/jsx-runtime").JSX.Element;
46
- displayName: string;
47
- };
48
- MenuItemHelp: {
49
- (): import("react/jsx-runtime").JSX.Element;
50
- displayName: string;
51
- };
52
- MenuItemLoadScene: {
53
- (): import("react/jsx-runtime").JSX.Element | null;
54
- displayName: string;
55
- };
56
- MenuItemLiveCollaborationTrigger: {
57
- ({ onSelect, }: {
58
- onSelect: () => any;
59
- }): import("react/jsx-runtime").JSX.Element;
60
- displayName: string;
61
- };
62
- };
63
- Hints: {
64
- MenuHint: {
65
- ({ children }: {
66
- children?: React.ReactNode;
67
- }): import("react/jsx-runtime").JSX.Element;
68
- displayName: string;
69
- };
70
- ToolbarHint: {
71
- ({ children }: {
72
- children?: React.ReactNode;
73
- }): import("react/jsx-runtime").JSX.Element;
74
- displayName: string;
75
- };
76
- HelpHint: {
77
- ({ children }: {
78
- children?: React.ReactNode;
79
- }): import("react/jsx-runtime").JSX.Element;
80
- displayName: string;
81
- };
82
- };
83
- };
84
- export default WelcomeScreen;
@@ -1,7 +0,0 @@
1
- import type { OrderedExcalidrawElement } from "@excalidraw/element/types";
2
- import type { MakeBrand } from "@excalidraw/common/utility-types";
3
- import type { AppState } from "../types";
4
- export type ReconciledExcalidrawElement = OrderedExcalidrawElement & MakeBrand<"ReconciledElement">;
5
- export type RemoteExcalidrawElement = OrderedExcalidrawElement & MakeBrand<"RemoteExcalidrawElement">;
6
- export declare const shouldDiscardRemoteElement: (localAppState: AppState, local: OrderedExcalidrawElement | undefined, remote: RemoteExcalidrawElement) => boolean;
7
- export declare const reconcileElements: (localElements: readonly OrderedExcalidrawElement[], remoteElements: readonly RemoteExcalidrawElement[], localAppState: AppState) => ReconciledExcalidrawElement[];