@excalidraw/math 0.18.0-4e758db → 0.18.0-4f68076
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.
- package/dist/dev/index.js +8 -2
- package/dist/dev/index.js.map +2 -2
- package/dist/prod/index.js +1 -1
- package/dist/types/common/src/constants.d.ts +10 -0
- package/dist/types/common/src/utils.d.ts +5 -0
- package/dist/types/element/src/binding.d.ts +13 -7
- package/dist/types/element/src/collision.d.ts +14 -5
- package/dist/types/element/src/duplicate.d.ts +60 -0
- package/dist/types/element/src/index.d.ts +1 -0
- package/dist/types/element/src/listMarker.d.ts +34 -0
- package/dist/types/element/src/newElement.d.ts +15 -1
- package/dist/types/element/src/renderElement.d.ts +21 -4
- package/dist/types/element/src/shape.d.ts +15 -1
- package/dist/types/element/src/textElement.d.ts +7 -0
- package/dist/types/element/src/utils.d.ts +8 -1
- package/dist/types/element/src/zindex.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +30 -3
- package/dist/types/excalidraw/actions/actionBoundText.d.ts +20 -2
- package/dist/types/excalidraw/actions/actionCanvas.d.ts +70 -7
- package/dist/types/excalidraw/actions/actionClipboard.d.ts +20 -2
- package/dist/types/excalidraw/actions/actionCropEditor.d.ts +10 -1
- package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +30 -3
- package/dist/types/excalidraw/actions/actionDeselect.d.ts +13 -1
- package/dist/types/excalidraw/actions/actionElementLink.d.ts +10 -1
- package/dist/types/excalidraw/actions/actionElementLock.d.ts +20 -2
- package/dist/types/excalidraw/actions/actionExport.d.ts +20 -2
- package/dist/types/excalidraw/actions/actionFrame.d.ts +30 -3
- package/dist/types/excalidraw/actions/actionGroup.d.ts +20 -2
- package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +10 -1
- package/dist/types/excalidraw/actions/actionLink.d.ts +10 -1
- package/dist/types/excalidraw/actions/actionMenu.d.ts +10 -1
- package/dist/types/excalidraw/actions/actionProperties.d.ts +20 -2
- package/dist/types/excalidraw/actions/actionSelectAll.d.ts +10 -1
- package/dist/types/excalidraw/actions/actionStyles.d.ts +10 -1
- package/dist/types/excalidraw/actions/actionToggleArrowBinding.d.ts +10 -1
- package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +10 -1
- package/dist/types/excalidraw/actions/actionToggleMidpointSnapping.d.ts +10 -1
- package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +10 -1
- package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +10 -1
- package/dist/types/excalidraw/actions/actionToggleShowHints.d.ts +197 -0
- package/dist/types/excalidraw/actions/actionToggleStats.d.ts +10 -1
- package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +10 -1
- package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +10 -1
- package/dist/types/excalidraw/actions/index.d.ts +1 -0
- package/dist/types/excalidraw/actions/types.d.ts +1 -1
- package/dist/types/excalidraw/appState.d.ts +2 -0
- package/dist/types/excalidraw/components/App.arrowText.d.ts +5 -39
- package/dist/types/excalidraw/components/App.clipboard.d.ts +31 -0
- package/dist/types/excalidraw/components/App.d.ts +82 -262
- package/dist/types/excalidraw/components/App.duplicate.d.ts +101 -0
- package/dist/types/excalidraw/components/App.modifiers.d.ts +38 -0
- package/dist/types/excalidraw/components/App.pan.d.ts +62 -0
- package/dist/types/excalidraw/components/App.selectionTool.d.ts +57 -0
- package/dist/types/excalidraw/components/App.text.d.ts +146 -0
- package/dist/types/excalidraw/components/App.textTool.d.ts +140 -0
- package/dist/types/excalidraw/components/App.viewport.d.ts +41 -1
- package/dist/types/excalidraw/components/App.wheel.d.ts +3 -10
- package/dist/types/excalidraw/components/ColorPicker/Picker.d.ts +2 -0
- package/dist/types/excalidraw/components/ColorPicker/colorTopPicksDnD.d.ts +11 -0
- package/dist/types/excalidraw/components/FileDropOverlay.d.ts +2 -0
- package/dist/types/excalidraw/components/FontPicker/FontPicker.d.ts +4 -1
- package/dist/types/excalidraw/components/FontPicker/FontPickerList.d.ts +6 -1
- package/dist/types/excalidraw/components/FontPicker/fontTopPicksDnD.d.ts +12 -0
- package/dist/types/excalidraw/components/LibraryMenuSection.d.ts +6 -2
- package/dist/types/excalidraw/components/LibraryUnit.d.ts +7 -2
- package/dist/types/excalidraw/components/Tooltip.d.ts +15 -1
- package/dist/types/excalidraw/components/TopPicksDnD/TopPicksContextMenu.d.ts +14 -0
- package/dist/types/excalidraw/components/TopPicksDnD/TopPicksTip.d.ts +11 -0
- package/dist/types/excalidraw/components/TopPicksDnD/topPicksDnD.d.ts +58 -0
- package/dist/types/excalidraw/components/main-menu/DefaultItems.d.ts +1 -0
- package/dist/types/excalidraw/data/blob.d.ts +20 -2
- package/dist/types/excalidraw/data/json.d.ts +10 -1
- package/dist/types/excalidraw/renderOverrides.d.ts +9 -0
- package/dist/types/excalidraw/scene/Renderer.d.ts +14 -1
- package/dist/types/excalidraw/scene/types.d.ts +2 -1
- package/dist/types/excalidraw/types.d.ts +92 -19
- package/dist/types/excalidraw/viewport.d.ts +23 -1
- package/dist/types/excalidraw/wysiwyg/textWysiwyg.d.ts +12 -1
- package/package.json +2 -2
- package/dist/types/excalidraw/components/ColorPicker/topPicksDnD.d.ts +0 -31
|
@@ -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 {
|
|
5
|
-
import type {
|
|
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,17 +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";
|
|
25
|
+
import { AppDuplicate } from "./App.duplicate";
|
|
23
26
|
import { AppFlowchart } from "./App.flowchart";
|
|
27
|
+
import { AppModifiers } from "./App.modifiers";
|
|
28
|
+
import { AppPan } from "./App.pan";
|
|
24
29
|
import { AppViewport } from "./App.viewport";
|
|
25
30
|
import { AppWheel } from "./App.wheel";
|
|
31
|
+
import { AppSelectionTool } from "./App.selectionTool";
|
|
26
32
|
import { CursorHints } from "./CursorHint";
|
|
27
33
|
import { type OnStateChange } from "./AppStateObserver";
|
|
28
34
|
import type { ExportedElements } from "../data";
|
|
29
|
-
import type { AppClassProperties, AppProps, AppState, ExcalidrawImperativeAPI, BinaryFiles, LibraryItems, SceneData, FrameNameBoundsCache, SidebarName, SidebarTabName, 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";
|
|
30
36
|
import type { RoughCanvas } from "roughjs/bin/canvas";
|
|
31
37
|
import type { ActionResult } from "../actions/types";
|
|
32
38
|
declare const editorLifecycleEventBehavior: {
|
|
@@ -85,6 +91,7 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
85
91
|
editorInterface: EditorInterface;
|
|
86
92
|
private stylesPanelMode;
|
|
87
93
|
private excalidrawContainerRef;
|
|
94
|
+
private zenModeTransitionTimer;
|
|
88
95
|
get ownerDocument(): Document;
|
|
89
96
|
get ownerWindow(): Window & typeof globalThis;
|
|
90
97
|
scene: Scene;
|
|
@@ -124,14 +131,19 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
124
131
|
private appStateObserver;
|
|
125
132
|
onStateChange: OnStateChange;
|
|
126
133
|
bucketFill: AppBucketFill;
|
|
134
|
+
duplicate: AppDuplicate;
|
|
127
135
|
toolDrag: AppToolDrag;
|
|
128
136
|
flowchart: AppFlowchart;
|
|
129
137
|
cursor: AppCursor;
|
|
130
138
|
arrowText: AppArrowText;
|
|
139
|
+
pan: AppPan;
|
|
140
|
+
textTool: AppTextTool;
|
|
141
|
+
clipboard: AppClipboard;
|
|
142
|
+
text: AppText;
|
|
131
143
|
viewport: AppViewport;
|
|
132
144
|
wheel: AppWheel;
|
|
145
|
+
selectionTool: AppSelectionTool;
|
|
133
146
|
bindModeHandler: ReturnType<typeof setTimeout> | null;
|
|
134
|
-
private textWysiwygSubmitHandler;
|
|
135
147
|
hitLinkElement?: NonDeletedExcalidrawElement;
|
|
136
148
|
lastPointerDownEvent: React.PointerEvent<HTMLElement> | null;
|
|
137
149
|
/**
|
|
@@ -197,7 +209,10 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
197
209
|
element: NonDeleted<ExcalidrawElement> | null;
|
|
198
210
|
allHitElements: NonDeleted<ExcalidrawElement>[];
|
|
199
211
|
wasAddedToSelection: boolean;
|
|
212
|
+
cycleTarget: NonDeleted<ExcalidrawElement> | null;
|
|
200
213
|
hasBeenDuplicated: boolean;
|
|
214
|
+
advancedListMarkers: readonly import("@excalidraw/element").ListMarkerAdvance[];
|
|
215
|
+
editedTextId: import("@excalidraw/element/types").ExcalidrawTextElement["id"] | null;
|
|
201
216
|
hasHitCommonBoundingBoxOfSelectedElements: boolean;
|
|
202
217
|
arrowLabel: boolean;
|
|
203
218
|
};
|
|
@@ -260,7 +275,10 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
260
275
|
element: NonDeleted<ExcalidrawElement> | null;
|
|
261
276
|
allHitElements: NonDeleted<ExcalidrawElement>[];
|
|
262
277
|
wasAddedToSelection: boolean;
|
|
278
|
+
cycleTarget: NonDeleted<ExcalidrawElement> | null;
|
|
263
279
|
hasBeenDuplicated: boolean;
|
|
280
|
+
advancedListMarkers: readonly import("@excalidraw/element").ListMarkerAdvance[];
|
|
281
|
+
editedTextId: import("@excalidraw/element/types").ExcalidrawTextElement["id"] | null;
|
|
264
282
|
hasHitCommonBoundingBoxOfSelectedElements: boolean;
|
|
265
283
|
arrowLabel: boolean;
|
|
266
284
|
};
|
|
@@ -293,7 +311,14 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
293
311
|
}>]>;
|
|
294
312
|
missingPointerEventCleanupEmitter: Emitter<[event: PointerEvent | null]>;
|
|
295
313
|
onRemoveEventListenersEmitter: Emitter<[]>;
|
|
314
|
+
modifiers: AppModifiers;
|
|
296
315
|
api: ExcalidrawImperativeAPI;
|
|
316
|
+
private elementRenderOverrides;
|
|
317
|
+
/** offsets of `elementRenderOverrides`; keeps its identity while they don't change */
|
|
318
|
+
private elementRenderOffsets;
|
|
319
|
+
private renderOverridesUpdatePending;
|
|
320
|
+
private getRenderOverrideConfig;
|
|
321
|
+
private getElementRenderState;
|
|
297
322
|
private createExcalidrawAPI;
|
|
298
323
|
constructor(props: AppProps);
|
|
299
324
|
/**
|
|
@@ -377,7 +402,6 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
377
402
|
* If disabled, returns null.
|
|
378
403
|
*/
|
|
379
404
|
getEffectiveGridSize: () => NullableGridSize;
|
|
380
|
-
private getTextCreationGridPoint;
|
|
381
405
|
private getHTMLIFrameElement;
|
|
382
406
|
/**
|
|
383
407
|
* AI-generated iframe elements aren't interactive while their generation
|
|
@@ -424,6 +448,8 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
424
448
|
private onBlur;
|
|
425
449
|
private onUnload;
|
|
426
450
|
private disableEvent;
|
|
451
|
+
private isFileDropEnabled;
|
|
452
|
+
private onDragOver;
|
|
427
453
|
private handleNavigationModeKeyDown;
|
|
428
454
|
/**
|
|
429
455
|
* PageUp/PageDown scroll the canvas by a page — vertically, or
|
|
@@ -468,16 +494,20 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
468
494
|
private onFullscreenChange;
|
|
469
495
|
private removeEventListeners;
|
|
470
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;
|
|
471
505
|
componentDidUpdate(prevProps: AppProps, prevState: AppState): void;
|
|
472
506
|
private renderInteractiveSceneCallback;
|
|
473
507
|
private onScroll;
|
|
474
|
-
private onCut;
|
|
475
|
-
private onCopy;
|
|
476
508
|
private static resetTapTwice;
|
|
477
509
|
private onTouchStart;
|
|
478
510
|
private onTouchEnd;
|
|
479
|
-
private insertClipboardContent;
|
|
480
|
-
pasteFromClipboard: (event: ClipboardEvent) => Promise<void>;
|
|
481
511
|
addElementsFromPasteOrLibrary: (opts: {
|
|
482
512
|
elements: readonly ExcalidrawElement[];
|
|
483
513
|
files: BinaryFiles | null;
|
|
@@ -489,8 +519,6 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
489
519
|
fit?: SetViewportOptions["fit"];
|
|
490
520
|
preserveFrameChildrenOrder?: boolean;
|
|
491
521
|
}) => void;
|
|
492
|
-
private addElementsFromMixedContentPaste;
|
|
493
|
-
private addTextFromPaste;
|
|
494
522
|
setAppState: React.Component<any, AppState>["setState"];
|
|
495
523
|
removePointer: (event: React.PointerEvent<HTMLElement> | PointerEvent) => void;
|
|
496
524
|
toggleLock: (source?: "keyboard" | "ui") => void;
|
|
@@ -502,9 +530,11 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
502
530
|
* imperative API emitter */
|
|
503
531
|
emitUserFollowIntent: (payload: OnUserFollowedPayload) => void;
|
|
504
532
|
/** emits an UNFOLLOW intent if currently following someone — use on
|
|
505
|
-
*
|
|
533
|
+
* viewport changes that take the view over from the followed user (user
|
|
534
|
+
* pans and zooms, `setViewport` navigation) */
|
|
506
535
|
requestUnfollow: () => void;
|
|
507
536
|
setToast: (toast: AppState["toast"]) => void;
|
|
537
|
+
private showSceneReplacedToast;
|
|
508
538
|
restoreFileFromShare: () => Promise<void>;
|
|
509
539
|
/**
|
|
510
540
|
* adds supplied files to existing files in the appState.
|
|
@@ -529,6 +559,10 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
529
559
|
*/
|
|
530
560
|
captureUpdate?: SceneData["captureUpdate"];
|
|
531
561
|
}) => void;
|
|
562
|
+
/**
|
|
563
|
+
* see {@link ExcalidrawImperativeAPI.setElementRenderOverrides} for details
|
|
564
|
+
*/
|
|
565
|
+
setElementRenderOverrides: (overrides: ElementRenderOverrides | null) => void;
|
|
532
566
|
applyDeltas: (deltas: StoreDelta[], options?: ApplyToOptions) => [SceneElementsMap, AppState, boolean];
|
|
533
567
|
mutateElement: <TElement extends Mutable<ExcalidrawElement>>(element: TElement, updates: ElementUpdate<TElement>, informMutation?: boolean) => TElement;
|
|
534
568
|
triggerRender: (
|
|
@@ -576,13 +610,7 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
576
610
|
private onGestureStart;
|
|
577
611
|
private onGestureChange;
|
|
578
612
|
private onGestureEnd;
|
|
579
|
-
|
|
580
|
-
private deselectElements;
|
|
581
|
-
private getSelectedTextElement;
|
|
582
|
-
private getSelectedTextEditingContainerAtPosition;
|
|
583
|
-
getTextElementAtPosition(x: number, y: number): NonDeleted<ExcalidrawTextElement> | null;
|
|
584
|
-
private isHittingTextAutoResizeHandle;
|
|
585
|
-
private handleTextAutoResizeHandlePointerDown;
|
|
613
|
+
deselectElements(): void;
|
|
586
614
|
getElementAtPosition(x: number, y: number, opts?: ({
|
|
587
615
|
includeBoundTextElement?: boolean;
|
|
588
616
|
includeLockedElements?: boolean;
|
|
@@ -595,230 +623,22 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
595
623
|
includeBoundTextElement?: boolean;
|
|
596
624
|
includeLockedElements?: boolean;
|
|
597
625
|
}): NonDeleted<ExcalidrawElement>[];
|
|
598
|
-
getElementHitThreshold(element: ExcalidrawElement): number;
|
|
599
|
-
hitElement(x: number, y: number, element: NonDeletedExcalidrawElement, considerBoundingBox?: boolean): boolean;
|
|
600
|
-
getTextBindableContainerAtPosition(x: number, y: number): (Readonly<{
|
|
601
|
-
id: string;
|
|
602
|
-
x: number;
|
|
603
|
-
y: number;
|
|
604
|
-
strokeColor: string;
|
|
605
|
-
backgroundColor: string;
|
|
606
|
-
fillStyle: import("@excalidraw/element/types").FillStyle;
|
|
607
|
-
strokeWidth: number;
|
|
608
|
-
strokeStyle: import("@excalidraw/element/types").StrokeStyle;
|
|
609
|
-
roundness: null | {
|
|
610
|
-
type: import("@excalidraw/element/types").RoundnessType;
|
|
611
|
-
value?: number;
|
|
612
|
-
};
|
|
613
|
-
roughness: number;
|
|
614
|
-
opacity: number;
|
|
615
|
-
width: number;
|
|
616
|
-
height: number;
|
|
617
|
-
angle: Radians;
|
|
618
|
-
seed: number;
|
|
619
|
-
version: number;
|
|
620
|
-
versionNonce: number;
|
|
621
|
-
index: import("@excalidraw/element/types").FractionalIndex | null;
|
|
622
|
-
isDeleted: boolean;
|
|
623
|
-
groupIds: readonly import("@excalidraw/element/types").GroupId[];
|
|
624
|
-
frameId: string | null;
|
|
625
|
-
boundElements: readonly import("@excalidraw/element/types").BoundElement[] | null;
|
|
626
|
-
updated: number;
|
|
627
|
-
created: number | null;
|
|
628
|
-
link: string | null;
|
|
629
|
-
locked: boolean;
|
|
630
|
-
customData?: Record<string, any>;
|
|
631
|
-
}> & {
|
|
632
|
-
type: "rectangle";
|
|
633
|
-
} & {
|
|
634
|
-
isDeleted: false;
|
|
635
|
-
}) | (Readonly<{
|
|
636
|
-
id: string;
|
|
637
|
-
x: number;
|
|
638
|
-
y: number;
|
|
639
|
-
strokeColor: string;
|
|
640
|
-
backgroundColor: string;
|
|
641
|
-
fillStyle: import("@excalidraw/element/types").FillStyle;
|
|
642
|
-
strokeWidth: number;
|
|
643
|
-
strokeStyle: import("@excalidraw/element/types").StrokeStyle;
|
|
644
|
-
roundness: null | {
|
|
645
|
-
type: import("@excalidraw/element/types").RoundnessType;
|
|
646
|
-
value?: number;
|
|
647
|
-
};
|
|
648
|
-
roughness: number;
|
|
649
|
-
opacity: number;
|
|
650
|
-
width: number;
|
|
651
|
-
height: number;
|
|
652
|
-
angle: Radians;
|
|
653
|
-
seed: number;
|
|
654
|
-
version: number;
|
|
655
|
-
versionNonce: number;
|
|
656
|
-
index: import("@excalidraw/element/types").FractionalIndex | null;
|
|
657
|
-
isDeleted: boolean;
|
|
658
|
-
groupIds: readonly import("@excalidraw/element/types").GroupId[];
|
|
659
|
-
frameId: string | null;
|
|
660
|
-
boundElements: readonly import("@excalidraw/element/types").BoundElement[] | null;
|
|
661
|
-
updated: number;
|
|
662
|
-
created: number | null;
|
|
663
|
-
link: string | null;
|
|
664
|
-
locked: boolean;
|
|
665
|
-
customData?: Record<string, any>;
|
|
666
|
-
}> & Readonly<{
|
|
667
|
-
type: "stickynote";
|
|
668
|
-
baseHeight: number;
|
|
669
|
-
}> & {
|
|
670
|
-
isDeleted: false;
|
|
671
|
-
}) | (Readonly<{
|
|
672
|
-
id: string;
|
|
673
|
-
x: number;
|
|
674
|
-
y: number;
|
|
675
|
-
strokeColor: string;
|
|
676
|
-
backgroundColor: string;
|
|
677
|
-
fillStyle: import("@excalidraw/element/types").FillStyle;
|
|
678
|
-
strokeWidth: number;
|
|
679
|
-
strokeStyle: import("@excalidraw/element/types").StrokeStyle;
|
|
680
|
-
roundness: null | {
|
|
681
|
-
type: import("@excalidraw/element/types").RoundnessType;
|
|
682
|
-
value?: number;
|
|
683
|
-
};
|
|
684
|
-
roughness: number;
|
|
685
|
-
opacity: number;
|
|
686
|
-
width: number;
|
|
687
|
-
height: number;
|
|
688
|
-
angle: Radians;
|
|
689
|
-
seed: number;
|
|
690
|
-
version: number;
|
|
691
|
-
versionNonce: number;
|
|
692
|
-
index: import("@excalidraw/element/types").FractionalIndex | null;
|
|
693
|
-
isDeleted: boolean;
|
|
694
|
-
groupIds: readonly import("@excalidraw/element/types").GroupId[];
|
|
695
|
-
frameId: string | null;
|
|
696
|
-
boundElements: readonly import("@excalidraw/element/types").BoundElement[] | null;
|
|
697
|
-
updated: number;
|
|
698
|
-
created: number | null;
|
|
699
|
-
link: string | null;
|
|
700
|
-
locked: boolean;
|
|
701
|
-
customData?: Record<string, any>;
|
|
702
|
-
}> & {
|
|
703
|
-
type: "diamond";
|
|
704
|
-
} & {
|
|
705
|
-
isDeleted: false;
|
|
706
|
-
}) | (Readonly<{
|
|
707
|
-
id: string;
|
|
708
|
-
x: number;
|
|
709
|
-
y: number;
|
|
710
|
-
strokeColor: string;
|
|
711
|
-
backgroundColor: string;
|
|
712
|
-
fillStyle: import("@excalidraw/element/types").FillStyle;
|
|
713
|
-
strokeWidth: number;
|
|
714
|
-
strokeStyle: import("@excalidraw/element/types").StrokeStyle;
|
|
715
|
-
roundness: null | {
|
|
716
|
-
type: import("@excalidraw/element/types").RoundnessType;
|
|
717
|
-
value?: number;
|
|
718
|
-
};
|
|
719
|
-
roughness: number;
|
|
720
|
-
opacity: number;
|
|
721
|
-
width: number;
|
|
722
|
-
height: number;
|
|
723
|
-
angle: Radians;
|
|
724
|
-
seed: number;
|
|
725
|
-
version: number;
|
|
726
|
-
versionNonce: number;
|
|
727
|
-
index: import("@excalidraw/element/types").FractionalIndex | null;
|
|
728
|
-
isDeleted: boolean;
|
|
729
|
-
groupIds: readonly import("@excalidraw/element/types").GroupId[];
|
|
730
|
-
frameId: string | null;
|
|
731
|
-
boundElements: readonly import("@excalidraw/element/types").BoundElement[] | null;
|
|
732
|
-
updated: number;
|
|
733
|
-
created: number | null;
|
|
734
|
-
link: string | null;
|
|
735
|
-
locked: boolean;
|
|
736
|
-
customData?: Record<string, any>;
|
|
737
|
-
}> & {
|
|
738
|
-
type: "ellipse";
|
|
739
|
-
} & {
|
|
740
|
-
isDeleted: false;
|
|
741
|
-
}) | (Readonly<{
|
|
742
|
-
id: string;
|
|
743
|
-
x: number;
|
|
744
|
-
y: number;
|
|
745
|
-
strokeColor: string;
|
|
746
|
-
backgroundColor: string;
|
|
747
|
-
fillStyle: import("@excalidraw/element/types").FillStyle;
|
|
748
|
-
strokeWidth: number;
|
|
749
|
-
strokeStyle: import("@excalidraw/element/types").StrokeStyle;
|
|
750
|
-
roundness: null | {
|
|
751
|
-
type: import("@excalidraw/element/types").RoundnessType;
|
|
752
|
-
value?: number;
|
|
753
|
-
};
|
|
754
|
-
roughness: number;
|
|
755
|
-
opacity: number;
|
|
756
|
-
width: number;
|
|
757
|
-
height: number;
|
|
758
|
-
angle: Radians;
|
|
759
|
-
seed: number;
|
|
760
|
-
version: number;
|
|
761
|
-
versionNonce: number;
|
|
762
|
-
index: import("@excalidraw/element/types").FractionalIndex | null;
|
|
763
|
-
isDeleted: boolean;
|
|
764
|
-
groupIds: readonly import("@excalidraw/element/types").GroupId[];
|
|
765
|
-
frameId: string | null;
|
|
766
|
-
boundElements: readonly import("@excalidraw/element/types").BoundElement[] | null;
|
|
767
|
-
updated: number;
|
|
768
|
-
created: number | null;
|
|
769
|
-
link: string | null;
|
|
770
|
-
locked: boolean;
|
|
771
|
-
customData?: Record<string, any>;
|
|
772
|
-
}> & Readonly<{
|
|
773
|
-
type: "line" | "arrow";
|
|
774
|
-
points: readonly LocalPoint[];
|
|
775
|
-
startBinding: import("@excalidraw/element/types").FixedPointBinding | null;
|
|
776
|
-
endBinding: import("@excalidraw/element/types").FixedPointBinding | null;
|
|
777
|
-
startArrowhead: import("@excalidraw/element/types").Arrowhead | null;
|
|
778
|
-
endArrowhead: import("@excalidraw/element/types").Arrowhead | null;
|
|
779
|
-
}> & Readonly<{
|
|
780
|
-
type: "arrow";
|
|
781
|
-
elbowed: boolean;
|
|
782
|
-
}> & {
|
|
783
|
-
isDeleted: false;
|
|
784
|
-
}) | null;
|
|
785
626
|
/**
|
|
786
|
-
* Whether
|
|
787
|
-
*
|
|
788
|
-
* Creating a text reverts the tool to selection during pointerdown, so the
|
|
789
|
-
* pointerup that follows looks like an ordinary canvas click and would
|
|
790
|
-
* capture the still-empty element as a history entry of its own. Undo would
|
|
791
|
-
* then rewind only the typing, restoring an invisible, zero-content element
|
|
792
|
-
* (and, for an endpoint label, leaving the arrow bound to it) rather than
|
|
793
|
-
* removing it. The editor's own submit captures the finished text instead,
|
|
794
|
-
* 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.
|
|
795
629
|
*/
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
sceneX: number;
|
|
800
|
-
/** Y position to insert text at */
|
|
801
|
-
sceneY: number;
|
|
802
|
-
/** whether to attempt to insert at element center if applicable */
|
|
803
|
-
insertAtParentCenter?: boolean;
|
|
804
|
-
container?: ExcalidrawTextContainer | null;
|
|
805
|
-
autoEdit?: boolean;
|
|
806
|
-
initialCaretSceneCoords?: {
|
|
807
|
-
x: number;
|
|
808
|
-
y: number;
|
|
809
|
-
};
|
|
810
|
-
/**
|
|
811
|
-
* creates the text as a label for this arrow endpoint: the binding then
|
|
812
|
-
* dictates the text's position and alignment, overriding (sceneX, sceneY)
|
|
813
|
-
*/
|
|
814
|
-
arrowEndpoint?: ArrowEndpoint | null;
|
|
815
|
-
}) => 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;
|
|
816
633
|
private startImageCropping;
|
|
817
|
-
|
|
634
|
+
finishImageCropping: () => void;
|
|
818
635
|
private shouldHandleBrowserCanvasDoubleClick;
|
|
819
636
|
private handleCanvasDoubleClick;
|
|
820
637
|
private handleCanvasClick;
|
|
821
|
-
|
|
638
|
+
getElementLinkAtPosition: (scenePointer: Readonly<{
|
|
639
|
+
x: number;
|
|
640
|
+
y: number;
|
|
641
|
+
}>, hitElementMightBeLocked: NonDeletedExcalidrawElement | null) => NonDeletedExcalidrawElement | undefined;
|
|
822
642
|
private handleElementLinkClick;
|
|
823
643
|
/**
|
|
824
644
|
* Applies (or clears) the element-link hover affordances — pointer cursor
|
|
@@ -871,6 +691,13 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
871
691
|
*/
|
|
872
692
|
handleHoverSelectedLinearElement(linearElementEditor: LinearElementEditor, scenePointerX: number, scenePointerY: number): void;
|
|
873
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;
|
|
874
701
|
private handleCanvasPointerUp;
|
|
875
702
|
private maybeOpenContextMenuAfterPointerDownOnTouchDevices;
|
|
876
703
|
private resetContextMenuTimer;
|
|
@@ -880,7 +707,6 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
880
707
|
* pointerup handlers manually
|
|
881
708
|
*/
|
|
882
709
|
private maybeCleanupAfterMissingPointerUp;
|
|
883
|
-
handleCanvasPanUsingWheelOrSpaceDrag: (event: React.PointerEvent<HTMLElement> | MouseEvent) => boolean;
|
|
884
710
|
private updateGestureOnPointerDown;
|
|
885
711
|
/**
|
|
886
712
|
* Tracks the pointer within the ongoing multi-touch gesture and applies
|
|
@@ -889,14 +715,6 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
889
715
|
private updateMultiTouchGesture;
|
|
890
716
|
private initialPointerDownState;
|
|
891
717
|
private handleDraggingScrollBar;
|
|
892
|
-
private clearSelectionIfNotUsingSelection;
|
|
893
|
-
/**
|
|
894
|
-
* @returns whether the pointer event has been completely handled
|
|
895
|
-
*/
|
|
896
|
-
private handleSelectionOnPointerDown;
|
|
897
|
-
private isASelectedElement;
|
|
898
|
-
private isHittingCommonBoundingBoxOfSelectedElements;
|
|
899
|
-
private handleTextOnPointerDown;
|
|
900
718
|
private handleFreeDrawElementOnPointerDown;
|
|
901
719
|
insertIframeElement: ({ sceneX, sceneY, width, height, }: {
|
|
902
720
|
sceneX: number;
|
|
@@ -917,8 +735,8 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
917
735
|
getCurrentItemStrokeWidth(elementType: ExcalidrawElement["type"]): number;
|
|
918
736
|
private createGenericElementOnPointerDown;
|
|
919
737
|
private createFrameElementOnPointerDown;
|
|
920
|
-
|
|
921
|
-
|
|
738
|
+
maybeCacheReferenceSnapPoints(event: KeyboardModifiersObject, selectedElements: readonly NonDeletedExcalidrawElement[], recomputeAnyways?: boolean): void;
|
|
739
|
+
maybeCacheVisibleGaps(event: KeyboardModifiersObject, selectedElements: readonly NonDeletedExcalidrawElement[], recomputeAnyways?: boolean): void;
|
|
922
740
|
private onKeyDownFromPointerDownHandler;
|
|
923
741
|
private onKeyUpFromPointerDownHandler;
|
|
924
742
|
private onPointerMoveFromPointerDownHandler;
|
|
@@ -943,23 +761,25 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
943
761
|
/** generally you should use `addNewImagesToImageCache()` directly if you need
|
|
944
762
|
* to render new images. This is just a failsafe */
|
|
945
763
|
private scheduleImageRefresh;
|
|
946
|
-
private clearSelection;
|
|
947
764
|
private handleInteractiveCanvasRef;
|
|
948
|
-
|
|
765
|
+
insertImages: (imageFiles: File[], sceneX: number, sceneY: number) => Promise<void>;
|
|
949
766
|
private handleAppOnDrop;
|
|
950
|
-
|
|
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>;
|
|
951
772
|
private handleCanvasContextMenu;
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
773
|
+
/** opens the context menu for the element under the pointer, or the canvas */
|
|
774
|
+
openContextMenu: (pointer: {
|
|
775
|
+
clientX: number;
|
|
776
|
+
clientY: number;
|
|
777
|
+
button?: number;
|
|
778
|
+
pointerType?: string;
|
|
779
|
+
}) => void;
|
|
780
|
+
maybeDragNewGenericElement: (pointerDownState: PointerDownState, event: MouseEvent | KeyboardEvent, informMutation?: boolean) => void;
|
|
955
781
|
private getContextMenuItems;
|
|
956
|
-
|
|
957
|
-
viewportX: number;
|
|
958
|
-
viewportY: number;
|
|
959
|
-
elementCenterX: number;
|
|
960
|
-
elementCenterY: number;
|
|
961
|
-
} | undefined;
|
|
962
|
-
private savePointer;
|
|
782
|
+
savePointer: (x: number, y: number, button: "up" | "down") => void;
|
|
963
783
|
resetShouldCacheIgnoreZoomDebounced: {
|
|
964
784
|
(): void;
|
|
965
785
|
flush(): void;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { duplicateElements } from "@excalidraw/element";
|
|
2
|
+
import type { ExcalidrawElement, ExcalidrawTextElement } from "@excalidraw/element/types";
|
|
3
|
+
import type { PointerDownState } from "../types";
|
|
4
|
+
import type App from "./App";
|
|
5
|
+
type Duplication = Pick<ReturnType<typeof duplicateElements>, "duplicatedElements" | "duplicateElementsMap" | "origElementsMap" | "origIdToDuplicateId" | "duplicateIdToOrigId">;
|
|
6
|
+
/**
|
|
7
|
+
* Owns the duplication paths which involve the host (`props.onDuplicate`):
|
|
8
|
+
* duplicating elements into the scene (paste, library insert etc.), and
|
|
9
|
+
* duplicating the dragged selection (alt-drag). The duplicate action shares
|
|
10
|
+
* `runOnDuplicate()`.
|
|
11
|
+
*/
|
|
12
|
+
export declare class AppDuplicate {
|
|
13
|
+
private app;
|
|
14
|
+
private dependencies;
|
|
15
|
+
constructor(app: App, dependencies: {
|
|
16
|
+
/** pointers currently down */
|
|
17
|
+
getPointerCount: () => number;
|
|
18
|
+
});
|
|
19
|
+
/**
|
|
20
|
+
* Hands the duplication over to the host's `props.onDuplicate` (if any),
|
|
21
|
+
* and reconciles what it returned with the duplicates.
|
|
22
|
+
*
|
|
23
|
+
* @returns next elements, and the duplicates that weren't vetoed
|
|
24
|
+
*/
|
|
25
|
+
runOnDuplicate: (duplication: Duplication, nextElements: ExcalidrawElement[],
|
|
26
|
+
/** excludes the duplicated elements */
|
|
27
|
+
prevElements: readonly ExcalidrawElement[]) => {
|
|
28
|
+
elements: ExcalidrawElement[];
|
|
29
|
+
duplicatedElements: import("@excalidraw/element/types").NonDeletedExcalidrawElement[];
|
|
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;
|
|
77
|
+
/**
|
|
78
|
+
* Duplicates elements so that they end up centered at the scene coords
|
|
79
|
+
* (and in the frame at that point, if any). Doesn't update the scene.
|
|
80
|
+
*
|
|
81
|
+
* @returns `null` if the host vetoed the duplication
|
|
82
|
+
*/
|
|
83
|
+
duplicateAtSceneCoords: (elements: readonly ExcalidrawElement[], { x, y }: {
|
|
84
|
+
x: number;
|
|
85
|
+
y: number;
|
|
86
|
+
}, opts?: {
|
|
87
|
+
retainSeed?: boolean;
|
|
88
|
+
preserveFrameChildrenOrder?: boolean;
|
|
89
|
+
}) => {
|
|
90
|
+
nextElements: ExcalidrawElement[];
|
|
91
|
+
duplicatedElements: import("@excalidraw/element/types").NonDeletedExcalidrawElement[];
|
|
92
|
+
} | null;
|
|
93
|
+
/**
|
|
94
|
+
* Duplicates the selection being dragged: the originals go back to where
|
|
95
|
+
* the drag started, and the drag continues with the duplicates.
|
|
96
|
+
*
|
|
97
|
+
* If the host vetoes the duplication, the originals keep being dragged.
|
|
98
|
+
*/
|
|
99
|
+
duplicateDraggedSelection: (pointerDownState: PointerDownState, event: PointerEvent) => void;
|
|
100
|
+
}
|
|
101
|
+
export {};
|
|
@@ -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
|
+
}
|