@excalidraw/math 0.18.0-1118751 → 0.18.0-143b5b6

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 (59) hide show
  1. package/dist/types/common/src/constants.d.ts +3 -0
  2. package/dist/types/common/src/utils.d.ts +5 -0
  3. package/dist/types/element/src/binding.d.ts +8 -0
  4. package/dist/types/element/src/collision.d.ts +6 -0
  5. package/dist/types/element/src/index.d.ts +1 -0
  6. package/dist/types/element/src/listMarker.d.ts +34 -0
  7. package/dist/types/element/src/newElement.d.ts +15 -1
  8. package/dist/types/element/src/textElement.d.ts +7 -0
  9. package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +27 -3
  10. package/dist/types/excalidraw/actions/actionBoundText.d.ts +18 -2
  11. package/dist/types/excalidraw/actions/actionCanvas.d.ts +63 -7
  12. package/dist/types/excalidraw/actions/actionClipboard.d.ts +18 -2
  13. package/dist/types/excalidraw/actions/actionCropEditor.d.ts +9 -1
  14. package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +27 -3
  15. package/dist/types/excalidraw/actions/actionDeselect.d.ts +12 -1
  16. package/dist/types/excalidraw/actions/actionElementLink.d.ts +9 -1
  17. package/dist/types/excalidraw/actions/actionElementLock.d.ts +18 -2
  18. package/dist/types/excalidraw/actions/actionExport.d.ts +18 -2
  19. package/dist/types/excalidraw/actions/actionFrame.d.ts +27 -3
  20. package/dist/types/excalidraw/actions/actionGroup.d.ts +18 -2
  21. package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +9 -1
  22. package/dist/types/excalidraw/actions/actionLink.d.ts +9 -1
  23. package/dist/types/excalidraw/actions/actionMenu.d.ts +9 -1
  24. package/dist/types/excalidraw/actions/actionProperties.d.ts +18 -2
  25. package/dist/types/excalidraw/actions/actionSelectAll.d.ts +9 -1
  26. package/dist/types/excalidraw/actions/actionStyles.d.ts +9 -1
  27. package/dist/types/excalidraw/actions/actionToggleArrowBinding.d.ts +9 -1
  28. package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +9 -1
  29. package/dist/types/excalidraw/actions/actionToggleMidpointSnapping.d.ts +9 -1
  30. package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +9 -1
  31. package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +9 -1
  32. package/dist/types/excalidraw/actions/actionToggleShowHints.d.ts +197 -0
  33. package/dist/types/excalidraw/actions/actionToggleStats.d.ts +9 -1
  34. package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +9 -1
  35. package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +9 -1
  36. package/dist/types/excalidraw/actions/index.d.ts +1 -0
  37. package/dist/types/excalidraw/actions/types.d.ts +1 -1
  38. package/dist/types/excalidraw/appState.d.ts +1 -0
  39. package/dist/types/excalidraw/components/App.arrowText.d.ts +5 -39
  40. package/dist/types/excalidraw/components/App.clipboard.d.ts +31 -0
  41. package/dist/types/excalidraw/components/App.d.ts +58 -258
  42. package/dist/types/excalidraw/components/App.duplicate.d.ts +52 -2
  43. package/dist/types/excalidraw/components/App.modifiers.d.ts +38 -0
  44. package/dist/types/excalidraw/components/App.pan.d.ts +8 -0
  45. package/dist/types/excalidraw/components/App.selectionTool.d.ts +57 -0
  46. package/dist/types/excalidraw/components/App.text.d.ts +146 -0
  47. package/dist/types/excalidraw/components/App.textTool.d.ts +140 -0
  48. package/dist/types/excalidraw/components/App.viewport.d.ts +41 -1
  49. package/dist/types/excalidraw/components/FileDropOverlay.d.ts +2 -0
  50. package/dist/types/excalidraw/components/LibraryMenuSection.d.ts +6 -2
  51. package/dist/types/excalidraw/components/LibraryUnit.d.ts +7 -2
  52. package/dist/types/excalidraw/components/Tooltip.d.ts +15 -1
  53. package/dist/types/excalidraw/components/main-menu/DefaultItems.d.ts +1 -0
  54. package/dist/types/excalidraw/data/blob.d.ts +18 -2
  55. package/dist/types/excalidraw/data/json.d.ts +9 -1
  56. package/dist/types/excalidraw/types.d.ts +35 -13
  57. package/dist/types/excalidraw/viewport.d.ts +22 -1
  58. package/dist/types/excalidraw/wysiwyg/textWysiwyg.d.ts +12 -1
  59. package/package.json +2 -2
@@ -1,9 +1,8 @@
1
1
  import React from "react";
2
2
  import { AppEventBus, type EXPORT_IMAGE_TYPES, Emitter, type EditorInterface, type StylesPanelMode } from "@excalidraw/common";
3
3
  import { LinearElementEditor, Scene, Store, type ElementUpdate, StoreDelta, type ApplyToOptions } from "@excalidraw/element";
4
- import type { LocalPoint, Radians } from "@excalidraw/math";
5
- import type { ExcalidrawElement, ExcalidrawTextElement, NonDeleted, NonDeletedExcalidrawElement, ExcalidrawTextContainer, ExcalidrawFrameLikeElement, ExcalidrawIframeElement, ExcalidrawEmbeddableElement, Ordered, SceneElementsMap } from "@excalidraw/element/types";
6
- import type { ArrowEndpoint, TransformHandleDirection } from "@excalidraw/element";
4
+ import type { ExcalidrawElement, NonDeleted, NonDeletedExcalidrawElement, ExcalidrawFrameLikeElement, ExcalidrawIframeElement, ExcalidrawEmbeddableElement, Ordered, SceneElementsMap } from "@excalidraw/element/types";
5
+ import type { TransformHandleDirection } from "@excalidraw/element";
7
6
  import type { Mutable } from "@excalidraw/common/utility-types";
8
7
  import { ActionManager } from "../actions/manager";
9
8
  import { History } from "../history";
@@ -16,19 +15,24 @@ import { isOverScrollBars } from "../scene/scrollbars";
16
15
  import { LassoTrail } from "../lasso";
17
16
  import { EraserTrail } from "../eraser";
18
17
  import { AppArrowText } from "./App.arrowText";
18
+ import { AppClipboard } from "./App.clipboard";
19
+ import { AppText } from "./App.text";
20
+ import { AppTextTool } from "./App.textTool";
19
21
  import { AppBucketFill } from "./App.bucketFill";
20
22
  import { AppToolDrag } from "./App.toolDrag";
21
23
  import { AppCursor } from "./App.cursor";
22
24
  import { AppDrawShape } from "./App.drawshape";
23
25
  import { AppDuplicate } from "./App.duplicate";
24
26
  import { AppFlowchart } from "./App.flowchart";
27
+ import { AppModifiers } from "./App.modifiers";
25
28
  import { AppPan } from "./App.pan";
26
29
  import { AppViewport } from "./App.viewport";
27
30
  import { AppWheel } from "./App.wheel";
31
+ import { AppSelectionTool } from "./App.selectionTool";
28
32
  import { CursorHints } from "./CursorHint";
29
33
  import { type OnStateChange } from "./AppStateObserver";
30
34
  import type { ExportedElements } from "../data";
31
- import type { AppClassProperties, AppProps, AppState, ElementRenderOverrides, ExcalidrawImperativeAPI, BinaryFiles, LibraryItems, SceneData, FrameNameBoundsCache, SidebarName, SidebarTabName, KeyboardModifiersObject, ToolType, OnUserFollowedPayload, ExcalidrawImperativeAPIEventMap, GenerateDiagramToCode, NullableGridSize, UIConfig } from "../types";
35
+ import type { AppClassProperties, AppProps, AppState, ElementRenderOverrides, ExcalidrawImperativeAPI, BinaryFiles, LibraryItems, PointerDownState, SceneData, FrameNameBoundsCache, SidebarName, SidebarTabName, KeyboardModifiersObject, ToolType, OnUserFollowedPayload, ExcalidrawImperativeAPIEventMap, GenerateDiagramToCode, NullableGridSize, UIConfig } from "../types";
32
36
  import type { RoughCanvas } from "roughjs/bin/canvas";
33
37
  import type { ActionResult } from "../actions/types";
34
38
  declare const editorLifecycleEventBehavior: {
@@ -87,6 +91,7 @@ declare class App extends React.Component<AppProps, AppState> {
87
91
  editorInterface: EditorInterface;
88
92
  private stylesPanelMode;
89
93
  private excalidrawContainerRef;
94
+ private zenModeTransitionTimer;
90
95
  get ownerDocument(): Document;
91
96
  get ownerWindow(): Window & typeof globalThis;
92
97
  scene: Scene;
@@ -132,10 +137,13 @@ declare class App extends React.Component<AppProps, AppState> {
132
137
  cursor: AppCursor;
133
138
  arrowText: AppArrowText;
134
139
  pan: AppPan;
140
+ textTool: AppTextTool;
141
+ clipboard: AppClipboard;
142
+ text: AppText;
135
143
  viewport: AppViewport;
136
144
  wheel: AppWheel;
145
+ selectionTool: AppSelectionTool;
137
146
  bindModeHandler: ReturnType<typeof setTimeout> | null;
138
- private textWysiwygSubmitHandler;
139
147
  hitLinkElement?: NonDeletedExcalidrawElement;
140
148
  lastPointerDownEvent: React.PointerEvent<HTMLElement> | null;
141
149
  /**
@@ -201,7 +209,10 @@ declare class App extends React.Component<AppProps, AppState> {
201
209
  element: NonDeleted<ExcalidrawElement> | null;
202
210
  allHitElements: NonDeleted<ExcalidrawElement>[];
203
211
  wasAddedToSelection: boolean;
212
+ cycleTarget: NonDeleted<ExcalidrawElement> | null;
204
213
  hasBeenDuplicated: boolean;
214
+ advancedListMarkers: readonly import("@excalidraw/element").ListMarkerAdvance[];
215
+ editedTextId: import("@excalidraw/element/types").ExcalidrawTextElement["id"] | null;
205
216
  hasHitCommonBoundingBoxOfSelectedElements: boolean;
206
217
  arrowLabel: boolean;
207
218
  };
@@ -264,7 +275,10 @@ declare class App extends React.Component<AppProps, AppState> {
264
275
  element: NonDeleted<ExcalidrawElement> | null;
265
276
  allHitElements: NonDeleted<ExcalidrawElement>[];
266
277
  wasAddedToSelection: boolean;
278
+ cycleTarget: NonDeleted<ExcalidrawElement> | null;
267
279
  hasBeenDuplicated: boolean;
280
+ advancedListMarkers: readonly import("@excalidraw/element").ListMarkerAdvance[];
281
+ editedTextId: import("@excalidraw/element/types").ExcalidrawTextElement["id"] | null;
268
282
  hasHitCommonBoundingBoxOfSelectedElements: boolean;
269
283
  arrowLabel: boolean;
270
284
  };
@@ -297,6 +311,7 @@ declare class App extends React.Component<AppProps, AppState> {
297
311
  }>]>;
298
312
  missingPointerEventCleanupEmitter: Emitter<[event: PointerEvent | null]>;
299
313
  onRemoveEventListenersEmitter: Emitter<[]>;
314
+ modifiers: AppModifiers;
300
315
  api: ExcalidrawImperativeAPI;
301
316
  private elementRenderOverrides;
302
317
  /** offsets of `elementRenderOverrides`; keeps its identity while they don't change */
@@ -387,7 +402,6 @@ declare class App extends React.Component<AppProps, AppState> {
387
402
  * If disabled, returns null.
388
403
  */
389
404
  getEffectiveGridSize: () => NullableGridSize;
390
- private getTextCreationGridPoint;
391
405
  private getHTMLIFrameElement;
392
406
  /**
393
407
  * AI-generated iframe elements aren't interactive while their generation
@@ -434,6 +448,8 @@ declare class App extends React.Component<AppProps, AppState> {
434
448
  private onBlur;
435
449
  private onUnload;
436
450
  private disableEvent;
451
+ private isFileDropEnabled;
452
+ private onDragOver;
437
453
  private handleNavigationModeKeyDown;
438
454
  /**
439
455
  * PageUp/PageDown scroll the canvas by a page — vertically, or
@@ -478,16 +494,20 @@ declare class App extends React.Component<AppProps, AppState> {
478
494
  private onFullscreenChange;
479
495
  private removeEventListeners;
480
496
  private addEventListeners;
497
+ getSnapshotBeforeUpdate(prevProps: AppProps, prevState: AppState): null;
498
+ /**
499
+ * Flags the container while toggling zen mode so that UI chrome
500
+ * (backgrounds etc.) animates only then, and hover transitions stay
501
+ * instant. A data attribute so that React doesn't reset it on re-render.
502
+ */
503
+ private markZenModeTransition;
504
+ private unmarkZenModeTransition;
481
505
  componentDidUpdate(prevProps: AppProps, prevState: AppState): void;
482
506
  private renderInteractiveSceneCallback;
483
507
  private onScroll;
484
- private onCut;
485
- private onCopy;
486
508
  private static resetTapTwice;
487
509
  private onTouchStart;
488
510
  private onTouchEnd;
489
- private insertClipboardContent;
490
- pasteFromClipboard: (event: ClipboardEvent) => Promise<void>;
491
511
  addElementsFromPasteOrLibrary: (opts: {
492
512
  elements: readonly ExcalidrawElement[];
493
513
  files: BinaryFiles | null;
@@ -499,8 +519,6 @@ declare class App extends React.Component<AppProps, AppState> {
499
519
  fit?: SetViewportOptions["fit"];
500
520
  preserveFrameChildrenOrder?: boolean;
501
521
  }) => void;
502
- private addElementsFromMixedContentPaste;
503
- private addTextFromPaste;
504
522
  setAppState: React.Component<any, AppState>["setState"];
505
523
  removePointer: (event: React.PointerEvent<HTMLElement> | PointerEvent) => void;
506
524
  toggleLock: (source?: "keyboard" | "ui") => void;
@@ -512,9 +530,11 @@ declare class App extends React.Component<AppProps, AppState> {
512
530
  * imperative API emitter */
513
531
  emitUserFollowIntent: (payload: OnUserFollowedPayload) => void;
514
532
  /** emits an UNFOLLOW intent if currently following someone — use on
515
- * user-initiated viewport changes which should break follow mode */
533
+ * viewport changes that take the view over from the followed user (user
534
+ * pans and zooms, `setViewport` navigation) */
516
535
  requestUnfollow: () => void;
517
536
  setToast: (toast: AppState["toast"]) => void;
537
+ private showSceneReplacedToast;
518
538
  restoreFileFromShare: () => Promise<void>;
519
539
  /**
520
540
  * adds supplied files to existing files in the appState.
@@ -590,13 +610,7 @@ declare class App extends React.Component<AppProps, AppState> {
590
610
  private onGestureStart;
591
611
  private onGestureChange;
592
612
  private onGestureEnd;
593
- private handleTextWysiwyg;
594
- private deselectElements;
595
- private getSelectedTextElement;
596
- private getSelectedTextEditingContainerAtPosition;
597
- getTextElementAtPosition(x: number, y: number): NonDeleted<ExcalidrawTextElement> | null;
598
- private isHittingTextAutoResizeHandle;
599
- private handleTextAutoResizeHandlePointerDown;
613
+ deselectElements(): void;
600
614
  getElementAtPosition(x: number, y: number, opts?: ({
601
615
  includeBoundTextElement?: boolean;
602
616
  includeLockedElements?: boolean;
@@ -609,230 +623,22 @@ declare class App extends React.Component<AppProps, AppState> {
609
623
  includeBoundTextElement?: boolean;
610
624
  includeLockedElements?: boolean;
611
625
  }): NonDeleted<ExcalidrawElement>[];
612
- getElementHitThreshold(element: ExcalidrawElement): number;
613
- hitElement(x: number, y: number, element: NonDeletedExcalidrawElement, considerBoundingBox?: boolean): boolean;
614
- getTextBindableContainerAtPosition(x: number, y: number): (Readonly<{
615
- id: string;
616
- x: number;
617
- y: number;
618
- strokeColor: string;
619
- backgroundColor: string;
620
- fillStyle: import("@excalidraw/element/types").FillStyle;
621
- strokeWidth: number;
622
- strokeStyle: import("@excalidraw/element/types").StrokeStyle;
623
- roundness: null | {
624
- type: import("@excalidraw/element/types").RoundnessType;
625
- value?: number;
626
- };
627
- roughness: number;
628
- opacity: number;
629
- width: number;
630
- height: number;
631
- angle: Radians;
632
- seed: number;
633
- version: number;
634
- versionNonce: number;
635
- index: import("@excalidraw/element/types").FractionalIndex | null;
636
- isDeleted: boolean;
637
- groupIds: readonly import("@excalidraw/element/types").GroupId[];
638
- frameId: string | null;
639
- boundElements: readonly import("@excalidraw/element/types").BoundElement[] | null;
640
- updated: number;
641
- created: number | null;
642
- link: string | null;
643
- locked: boolean;
644
- customData?: Record<string, any>;
645
- }> & {
646
- type: "rectangle";
647
- } & {
648
- isDeleted: false;
649
- }) | (Readonly<{
650
- id: string;
651
- x: number;
652
- y: number;
653
- strokeColor: string;
654
- backgroundColor: string;
655
- fillStyle: import("@excalidraw/element/types").FillStyle;
656
- strokeWidth: number;
657
- strokeStyle: import("@excalidraw/element/types").StrokeStyle;
658
- roundness: null | {
659
- type: import("@excalidraw/element/types").RoundnessType;
660
- value?: number;
661
- };
662
- roughness: number;
663
- opacity: number;
664
- width: number;
665
- height: number;
666
- angle: Radians;
667
- seed: number;
668
- version: number;
669
- versionNonce: number;
670
- index: import("@excalidraw/element/types").FractionalIndex | null;
671
- isDeleted: boolean;
672
- groupIds: readonly import("@excalidraw/element/types").GroupId[];
673
- frameId: string | null;
674
- boundElements: readonly import("@excalidraw/element/types").BoundElement[] | null;
675
- updated: number;
676
- created: number | null;
677
- link: string | null;
678
- locked: boolean;
679
- customData?: Record<string, any>;
680
- }> & Readonly<{
681
- type: "stickynote";
682
- baseHeight: number;
683
- }> & {
684
- isDeleted: false;
685
- }) | (Readonly<{
686
- id: string;
687
- x: number;
688
- y: number;
689
- strokeColor: string;
690
- backgroundColor: string;
691
- fillStyle: import("@excalidraw/element/types").FillStyle;
692
- strokeWidth: number;
693
- strokeStyle: import("@excalidraw/element/types").StrokeStyle;
694
- roundness: null | {
695
- type: import("@excalidraw/element/types").RoundnessType;
696
- value?: number;
697
- };
698
- roughness: number;
699
- opacity: number;
700
- width: number;
701
- height: number;
702
- angle: Radians;
703
- seed: number;
704
- version: number;
705
- versionNonce: number;
706
- index: import("@excalidraw/element/types").FractionalIndex | null;
707
- isDeleted: boolean;
708
- groupIds: readonly import("@excalidraw/element/types").GroupId[];
709
- frameId: string | null;
710
- boundElements: readonly import("@excalidraw/element/types").BoundElement[] | null;
711
- updated: number;
712
- created: number | null;
713
- link: string | null;
714
- locked: boolean;
715
- customData?: Record<string, any>;
716
- }> & {
717
- type: "diamond";
718
- } & {
719
- isDeleted: false;
720
- }) | (Readonly<{
721
- id: string;
722
- x: number;
723
- y: number;
724
- strokeColor: string;
725
- backgroundColor: string;
726
- fillStyle: import("@excalidraw/element/types").FillStyle;
727
- strokeWidth: number;
728
- strokeStyle: import("@excalidraw/element/types").StrokeStyle;
729
- roundness: null | {
730
- type: import("@excalidraw/element/types").RoundnessType;
731
- value?: number;
732
- };
733
- roughness: number;
734
- opacity: number;
735
- width: number;
736
- height: number;
737
- angle: Radians;
738
- seed: number;
739
- version: number;
740
- versionNonce: number;
741
- index: import("@excalidraw/element/types").FractionalIndex | null;
742
- isDeleted: boolean;
743
- groupIds: readonly import("@excalidraw/element/types").GroupId[];
744
- frameId: string | null;
745
- boundElements: readonly import("@excalidraw/element/types").BoundElement[] | null;
746
- updated: number;
747
- created: number | null;
748
- link: string | null;
749
- locked: boolean;
750
- customData?: Record<string, any>;
751
- }> & {
752
- type: "ellipse";
753
- } & {
754
- isDeleted: false;
755
- }) | (Readonly<{
756
- id: string;
757
- x: number;
758
- y: number;
759
- strokeColor: string;
760
- backgroundColor: string;
761
- fillStyle: import("@excalidraw/element/types").FillStyle;
762
- strokeWidth: number;
763
- strokeStyle: import("@excalidraw/element/types").StrokeStyle;
764
- roundness: null | {
765
- type: import("@excalidraw/element/types").RoundnessType;
766
- value?: number;
767
- };
768
- roughness: number;
769
- opacity: number;
770
- width: number;
771
- height: number;
772
- angle: Radians;
773
- seed: number;
774
- version: number;
775
- versionNonce: number;
776
- index: import("@excalidraw/element/types").FractionalIndex | null;
777
- isDeleted: boolean;
778
- groupIds: readonly import("@excalidraw/element/types").GroupId[];
779
- frameId: string | null;
780
- boundElements: readonly import("@excalidraw/element/types").BoundElement[] | null;
781
- updated: number;
782
- created: number | null;
783
- link: string | null;
784
- locked: boolean;
785
- customData?: Record<string, any>;
786
- }> & Readonly<{
787
- type: "line" | "arrow";
788
- points: readonly LocalPoint[];
789
- startBinding: import("@excalidraw/element/types").FixedPointBinding | null;
790
- endBinding: import("@excalidraw/element/types").FixedPointBinding | null;
791
- startArrowhead: import("@excalidraw/element/types").Arrowhead | null;
792
- endArrowhead: import("@excalidraw/element/types").Arrowhead | null;
793
- }> & Readonly<{
794
- type: "arrow";
795
- elbowed: boolean;
796
- }> & {
797
- isDeleted: false;
798
- }) | null;
799
626
  /**
800
- * Whether a text element's content is still being authored.
801
- *
802
- * Creating a text reverts the tool to selection during pointerdown, so the
803
- * pointerup that follows looks like an ordinary canvas click and would
804
- * capture the still-empty element as a history entry of its own. Undo would
805
- * then rewind only the typing, restoring an invisible, zero-content element
806
- * (and, for an endpoint label, leaving the arrow bound to it) rather than
807
- * removing it. The editor's own submit captures the finished text instead,
808
- * so the whole create-and-type lands in a single entry.
627
+ * Whether the element's frame clips it away at the position — hitting a
628
+ * frame's element from outside the frame is not considered a hit.
809
629
  */
810
- private isEditingTextContent;
811
- startTextEditing: ({ sceneX, sceneY, insertAtParentCenter, container, autoEdit, initialCaretSceneCoords, arrowEndpoint, }: {
812
- /** X position to insert text at */
813
- sceneX: number;
814
- /** Y position to insert text at */
815
- sceneY: number;
816
- /** whether to attempt to insert at element center if applicable */
817
- insertAtParentCenter?: boolean;
818
- container?: ExcalidrawTextContainer | null;
819
- autoEdit?: boolean;
820
- initialCaretSceneCoords?: {
821
- x: number;
822
- y: number;
823
- };
824
- /**
825
- * creates the text as a label for this arrow endpoint: the binding then
826
- * dictates the text's position and alignment, overriding (sceneX, sceneY)
827
- */
828
- arrowEndpoint?: ArrowEndpoint | null;
829
- }) => void;
630
+ isClippedByFrameAt(x: number, y: number, element: ExcalidrawElement): boolean;
631
+ getElementHitThreshold(element: ExcalidrawElement): number;
632
+ hitElement(x: number, y: number, element: NonDeletedExcalidrawElement, considerBoundingBox?: boolean): boolean;
830
633
  private startImageCropping;
831
- private finishImageCropping;
634
+ finishImageCropping: () => void;
832
635
  private shouldHandleBrowserCanvasDoubleClick;
833
636
  private handleCanvasDoubleClick;
834
637
  private handleCanvasClick;
835
- private getElementLinkAtPosition;
638
+ getElementLinkAtPosition: (scenePointer: Readonly<{
639
+ x: number;
640
+ y: number;
641
+ }>, hitElementMightBeLocked: NonDeletedExcalidrawElement | null) => NonDeletedExcalidrawElement | undefined;
836
642
  private handleElementLinkClick;
837
643
  /**
838
644
  * Applies (or clears) the element-link hover affordances — pointer cursor
@@ -885,6 +691,13 @@ declare class App extends React.Component<AppProps, AppState> {
885
691
  */
886
692
  handleHoverSelectedLinearElement(linearElementEditor: LinearElementEditor, scenePointerX: number, scenePointerY: number): void;
887
693
  private handleCanvasPointerDown;
694
+ /**
695
+ * The browser took the pointer over (scroll, pinch, palm rejection): no
696
+ * pointerup will follow, so the gesture is torn down here and now — the
697
+ * same cleanup a lost pointerup gets at the next press, only not left
698
+ * lying in wait for it, where its replay would tangle with that press.
699
+ */
700
+ private handleCanvasPointerCancel;
888
701
  private handleCanvasPointerUp;
889
702
  private maybeOpenContextMenuAfterPointerDownOnTouchDevices;
890
703
  private resetContextMenuTimer;
@@ -902,14 +715,6 @@ declare class App extends React.Component<AppProps, AppState> {
902
715
  private updateMultiTouchGesture;
903
716
  private initialPointerDownState;
904
717
  private handleDraggingScrollBar;
905
- private clearSelectionIfNotUsingSelection;
906
- /**
907
- * @returns whether the pointer event has been completely handled
908
- */
909
- private handleSelectionOnPointerDown;
910
- private isASelectedElement;
911
- private isHittingCommonBoundingBoxOfSelectedElements;
912
- private handleTextOnPointerDown;
913
718
  private handleFreeDrawElementOnPointerDown;
914
719
  insertIframeElement: ({ sceneX, sceneY, width, height, }: {
915
720
  sceneX: number;
@@ -956,11 +761,14 @@ declare class App extends React.Component<AppProps, AppState> {
956
761
  /** generally you should use `addNewImagesToImageCache()` directly if you need
957
762
  * to render new images. This is just a failsafe */
958
763
  private scheduleImageRefresh;
959
- private clearSelection;
960
764
  private handleInteractiveCanvasRef;
961
- private insertImages;
765
+ insertImages: (imageFiles: File[], sceneX: number, sceneY: number) => Promise<void>;
962
766
  private handleAppOnDrop;
963
- loadFileToCanvas: (file: File, fileHandle: FileSystemFileHandle | null) => Promise<void>;
767
+ /** @returns true if the file replaced the scene */
768
+ loadFileToCanvas: (file: File, fileHandle: FileSystemFileHandle | null, insertPosition?: {
769
+ clientX: number;
770
+ clientY: number;
771
+ }) => Promise<true | undefined>;
964
772
  private handleCanvasContextMenu;
965
773
  /** opens the context menu for the element under the pointer, or the canvas */
966
774
  openContextMenu: (pointer: {
@@ -969,16 +777,8 @@ declare class App extends React.Component<AppProps, AppState> {
969
777
  button?: number;
970
778
  pointerType?: string;
971
779
  }) => void;
972
- private maybeDragNewGenericElement;
973
- private maybeHandleCrop;
974
- private maybeHandleResize;
780
+ maybeDragNewGenericElement: (pointerDownState: PointerDownState, event: MouseEvent | KeyboardEvent, informMutation?: boolean) => void;
975
781
  private getContextMenuItems;
976
- getTextWysiwygSnappedToCenterPosition(x: number, y: number, appState: AppState, container?: ExcalidrawTextContainer | null): {
977
- viewportX: number;
978
- viewportY: number;
979
- elementCenterX: number;
980
- elementCenterY: number;
981
- } | undefined;
982
782
  savePointer: (x: number, y: number, button: "up" | "down") => void;
983
783
  resetShouldCacheIgnoreZoomDebounced: {
984
784
  (): void;
@@ -1,5 +1,5 @@
1
1
  import { duplicateElements } from "@excalidraw/element";
2
- import type { ExcalidrawElement } from "@excalidraw/element/types";
2
+ import type { ExcalidrawElement, ExcalidrawTextElement } from "@excalidraw/element/types";
3
3
  import type { PointerDownState } from "../types";
4
4
  import type App from "./App";
5
5
  type Duplication = Pick<ReturnType<typeof duplicateElements>, "duplicatedElements" | "duplicateElementsMap" | "origElementsMap" | "origIdToDuplicateId" | "duplicateIdToOrigId">;
@@ -11,7 +11,11 @@ type Duplication = Pick<ReturnType<typeof duplicateElements>, "duplicatedElement
11
11
  */
12
12
  export declare class AppDuplicate {
13
13
  private app;
14
- constructor(app: App);
14
+ private dependencies;
15
+ constructor(app: App, dependencies: {
16
+ /** pointers currently down */
17
+ getPointerCount: () => number;
18
+ });
15
19
  /**
16
20
  * Hands the duplication over to the host's `props.onDuplicate` (if any),
17
21
  * and reconciles what it returned with the duplicates.
@@ -24,6 +28,52 @@ export declare class AppDuplicate {
24
28
  elements: ExcalidrawElement[];
25
29
  duplicatedElements: import("@excalidraw/element/types").NonDeletedExcalidrawElement[];
26
30
  };
31
+ /**
32
+ * Runs `update` once what's pending is committed, capturing what it changes
33
+ * (if it returns `true`) as a separate undo step.
34
+ */
35
+ private afterCommit;
36
+ /**
37
+ * Advances the list markers of the duplicated texts (`1.` -> `2.`) once
38
+ * the duplication is committed, as a separate undo step, so that undo
39
+ * reverts the markers first.
40
+ */
41
+ advanceListMarkers: (duplicatedElements: readonly ExcalidrawElement[]) => void;
42
+ /**
43
+ * The text whose editing an alt-press on it ended, while the press is
44
+ * handed over to the canvas (see `handOverTextEditorPress()`).
45
+ */
46
+ handedOverTextId: ExcalidrawTextElement["id"] | null;
47
+ /**
48
+ * An alt-press on the text being edited, once it ended the editing, is
49
+ * handed over to the canvas, for the text to be alt-dragged (duplicated) as
50
+ * on the canvas — its duplicate is then edited on drop.
51
+ */
52
+ handOverTextEditorPress: (event: PointerEvent, textElementId: ExcalidrawTextElement["id"]) => void;
53
+ /**
54
+ * The pointer down a handed-over press is replayed as (see
55
+ * `handOverTextEditorPress()`) moves what was edited — the text, or its
56
+ * container — and nothing beneath the editor, which reaches past the text:
57
+ * no resize handle, nor an arrow's point, midpoint or label.
58
+ *
59
+ * @returns `false` if the pointer down isn't a handed-over press
60
+ */
61
+ hitEditedElement: (pointerDownState: PointerDownState) => boolean;
62
+ /**
63
+ * On alt-drag drop: the list markers advanced along with the drag go back,
64
+ * for the drag to be committed as is, and forth again once it is, as
65
+ * a separate undo step (before the browser gets to paint either).
66
+ *
67
+ * A duplicate is then edited (once the drop is committed): a single list
68
+ * item with text after its marker, with that text selected (`1. |foo|`),
69
+ * as it's likely to differ from the original's — or else the duplicate of
70
+ * the text the drag ended the editing of, with all of it selected.
71
+ */
72
+ commitDraggedDuplicates: ({ hit }: PointerDownState, { editText, }: {
73
+ /** `false` if the drag didn't end with a genuine pointerup */
74
+ editText: boolean;
75
+ }) => void;
76
+ private editDuplicatedText;
27
77
  /**
28
78
  * Duplicates elements so that they end up centered at the scene coords
29
79
  * (and in the frame at that point, if any). Doesn't update the scene.
@@ -0,0 +1,38 @@
1
+ import { Emitter } from "@excalidraw/common";
2
+ export type HeldModifiers = Readonly<{
3
+ alt: boolean;
4
+ shift: boolean;
5
+ /** Ctrl, or Cmd on macOS */
6
+ ctrlOrCmd: boolean;
7
+ }>;
8
+ /**
9
+ * The modifier keys held over the editor, synced from the flags of its
10
+ * keyboard and pointer events. Kept out of appState so that pressing one
11
+ * re-renders only its subscribers (e.g. the hint).
12
+ */
13
+ export declare class AppModifiers {
14
+ private held;
15
+ /** fires with a new snapshot whenever a modifier is pressed or released */
16
+ readonly onChange: Emitter<[held: Readonly<{
17
+ alt: boolean;
18
+ shift: boolean;
19
+ /** Ctrl, or Cmd on macOS */
20
+ ctrlOrCmd: boolean;
21
+ }>]>;
22
+ get: () => HeldModifiers;
23
+ /**
24
+ * A hook re-rendering on the held modifiers: all of them, or with
25
+ * `modifier`, only on that one being pressed or released.
26
+ */
27
+ useHeld(): HeldModifiers;
28
+ useHeld(modifier: keyof HeldModifiers): boolean;
29
+ sync: (event: {
30
+ altKey: boolean;
31
+ shiftKey: boolean;
32
+ ctrlKey: boolean;
33
+ metaKey: boolean;
34
+ }) => void;
35
+ /** releases them all — e.g. on blur, as Alt+Tab never delivers the keyup */
36
+ reset: () => void;
37
+ private set;
38
+ }
@@ -33,10 +33,18 @@ export declare class AppPan {
33
33
  constructor(app: App, dependencies: {
34
34
  /** pointers currently down (a two-finger gesture is not a pan) */
35
35
  getPointerCount: () => number;
36
+ /** a scrollbar being dragged (App's own drag, not a pan session) */
37
+ isDraggingScrollBar: () => boolean;
36
38
  });
37
39
  isActive: () => boolean;
38
40
  isSpaceHeld: () => boolean;
39
41
  setSpaceHeld: (held: boolean) => void;
42
+ /**
43
+ * Whether the pointer is navigating the viewport rather than acting on the
44
+ * scene — space held to pan, a pan in progress, a scrollbar drag, or the
45
+ * hand tool. Hover and cursor then belong to the navigation.
46
+ */
47
+ isNavigating: () => boolean;
40
48
  /** applies the pointer move still waiting for its frame, if any */
41
49
  flushMove: () => void;
42
50
  /** ends the active session, if any — pointerup may never arrive (the user
@@ -0,0 +1,57 @@
1
+ import type { ExcalidrawElement, NonDeletedSceneElementsMap } from "@excalidraw/element/types";
2
+ import type React from "react";
3
+ import type { PointerDownState } from "../types";
4
+ import type App from "./App";
5
+ /**
6
+ * The selection tool's (and the lasso's) selection: what a pointer down
7
+ * selects, what a click (a pointer up without a drag) does to the selection —
8
+ * including alt-click cycling through the overlapping elements — and the
9
+ * selection's transform handles (resizing, rotating, cropping).
10
+ */
11
+ export declare class AppSelectionTool {
12
+ private app;
13
+ constructor(app: App);
14
+ clearSelectionIfNotUsingSelection: () => void;
15
+ /**
16
+ * @returns whether the pointer event has been completely handled
17
+ */
18
+ handleSelectionOnPointerDown: (event: React.PointerEvent<HTMLElement>, pointerDownState: PointerDownState) => boolean;
19
+ maybeHandleCrop: (pointerDownState: PointerDownState, event: MouseEvent | KeyboardEvent) => boolean;
20
+ maybeHandleResize: (pointerDownState: PointerDownState, event: MouseEvent | KeyboardEvent) => boolean;
21
+ /**
22
+ * Updates the selection on a click (no drag): the element below the
23
+ * selected one on an alt-click, the clicked element added to or removed
24
+ * from the selection with shift, or selected, and the selection cleared
25
+ * by a click hitting only a bounding box.
26
+ *
27
+ * @returns whether the pointer event has been completely handled
28
+ */
29
+ handleSelectionOnPointerUp: (childEvent: PointerEvent, pointerDownState: PointerDownState, elementsMap: NonDeletedSceneElementsMap) => boolean;
30
+ clearSelection(hitElement: ExcalidrawElement | null): void;
31
+ isASelectedElement(hitElement: ExcalidrawElement | null): boolean;
32
+ isHittingCommonBoundingBoxOfSelectedElements(point: Readonly<{
33
+ x: number;
34
+ y: number;
35
+ }>, selectedElements: readonly ExcalidrawElement[]): boolean;
36
+ /** whether an alt-click on the selection (over other elements) cycles it */
37
+ canCycleSelection: () => boolean;
38
+ /**
39
+ * The selectable unit (an element, or the group a click would select) an
40
+ * element belongs to. Inside an edited group, its elements are units of
41
+ * their own.
42
+ */
43
+ private getSelectableUnit;
44
+ /**
45
+ * The selected unit, if an alt-click can cycle away from it: exactly one
46
+ * is selected, and neither the linear nor the crop editor is open.
47
+ */
48
+ private getCyclableSelectedUnit;
49
+ /**
50
+ * The element an alt-click selects: the selectable unit below the selected
51
+ * one among the hit elements, wrapping around to the topmost — or `null`
52
+ * unless it's an alt-click, the selection can cycle, and it's under the
53
+ * pointer. Inside an edited group, it cycles through the group's elements
54
+ * only, never leaving the group.
55
+ */
56
+ private getSelectionCycleTarget;
57
+ }