@excalidraw/common 0.18.0-abeeaeb → 0.18.0-afa3a65
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 +91 -10
- package/dist/dev/index.js.map +2 -2
- package/dist/prod/index.js +3 -3
- package/dist/types/common/src/colors.d.ts +8 -0
- package/dist/types/common/src/constants.d.ts +44 -0
- package/dist/types/common/src/keys.d.ts +2 -0
- package/dist/types/common/src/random.d.ts +7 -0
- package/dist/types/element/src/Scene.d.ts +1 -1
- package/dist/types/element/src/comparisons.d.ts +5 -3
- package/dist/types/element/src/delta.d.ts +23 -1
- package/dist/types/element/src/flowchart.d.ts +5 -1
- package/dist/types/element/src/frame.d.ts +2 -2
- package/dist/types/element/src/index.d.ts +1 -0
- package/dist/types/element/src/linearElementEditor.d.ts +10 -0
- package/dist/types/element/src/mutateElement.d.ts +1 -1
- package/dist/types/element/src/newElement.d.ts +24 -2
- package/dist/types/element/src/sizeHelpers.d.ts +6 -0
- package/dist/types/element/src/stickyNote.d.ts +183 -0
- package/dist/types/element/src/textElement.d.ts +2 -1
- package/dist/types/element/src/transform.d.ts +25 -6
- package/dist/types/element/src/typeChecks.d.ts +3 -2
- package/dist/types/element/src/types.d.ts +35 -6
- package/dist/types/element/src/utils.d.ts +7 -3
- package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +12 -0
- package/dist/types/excalidraw/actions/actionAlign.d.ts +6 -6
- package/dist/types/excalidraw/actions/actionBoundText.d.ts +8 -0
- package/dist/types/excalidraw/actions/actionCanvas.d.ts +28 -0
- package/dist/types/excalidraw/actions/actionClipboard.d.ts +8 -0
- package/dist/types/excalidraw/actions/actionCropEditor.d.ts +4 -0
- package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +13 -1
- package/dist/types/excalidraw/actions/actionDeselect.d.ts +4 -0
- package/dist/types/excalidraw/actions/actionDistribute.d.ts +2 -2
- package/dist/types/excalidraw/actions/actionElementLink.d.ts +4 -0
- package/dist/types/excalidraw/actions/actionElementLock.d.ts +8 -0
- package/dist/types/excalidraw/actions/actionExport.d.ts +8 -0
- package/dist/types/excalidraw/actions/actionFinalize.d.ts +1 -0
- package/dist/types/excalidraw/actions/actionFrame.d.ts +63 -1
- package/dist/types/excalidraw/actions/actionGroup.d.ts +8 -0
- package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +55 -1
- package/dist/types/excalidraw/actions/actionLink.d.ts +4 -0
- package/dist/types/excalidraw/actions/actionMenu.d.ts +4 -0
- package/dist/types/excalidraw/actions/actionProperties.d.ts +18 -6
- package/dist/types/excalidraw/actions/actionSelectAll.d.ts +4 -0
- package/dist/types/excalidraw/actions/actionStyles.d.ts +5 -1
- package/dist/types/excalidraw/actions/actionToggleArrowBinding.d.ts +4 -0
- package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +4 -0
- package/dist/types/excalidraw/actions/actionToggleMidpointSnapping.d.ts +4 -0
- package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +4 -0
- package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +4 -0
- package/dist/types/excalidraw/actions/actionToggleStats.d.ts +4 -0
- package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +4 -0
- package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +4 -0
- package/dist/types/excalidraw/actions/colorTargets.d.ts +39 -0
- package/dist/types/excalidraw/appState.d.ts +4 -0
- package/dist/types/excalidraw/components/App.arrowText.d.ts +40 -8
- package/dist/types/excalidraw/components/App.cursor.d.ts +8 -0
- package/dist/types/excalidraw/components/App.d.ts +92 -6
- package/dist/types/excalidraw/components/App.toolDrag.d.ts +63 -0
- package/dist/types/excalidraw/components/IconButton.d.ts +2 -0
- package/dist/types/excalidraw/components/Tools.d.ts +7 -2
- package/dist/types/excalidraw/components/canvases/NewElementCanvas.d.ts +2 -0
- package/dist/types/excalidraw/components/icons.d.ts +1 -0
- package/dist/types/excalidraw/components/shapeActionPredicates.d.ts +2 -2
- package/dist/types/excalidraw/data/blob.d.ts +8 -0
- package/dist/types/excalidraw/data/json.d.ts +4 -0
- package/dist/types/excalidraw/fonts/Fonts.d.ts +3 -2
- package/dist/types/excalidraw/hooks/useTextEditorFocus.d.ts +5 -5
- package/dist/types/excalidraw/renderer/helpers.d.ts +25 -0
- package/dist/types/excalidraw/renderer/interactiveScene.d.ts +1 -1
- package/dist/types/excalidraw/scene/Renderer.d.ts +50 -1
- package/dist/types/excalidraw/scene/index.d.ts +1 -1
- package/dist/types/excalidraw/scene/types.d.ts +1 -0
- package/dist/types/excalidraw/types.d.ts +30 -2
- package/dist/types/excalidraw/viewport.d.ts +4 -0
- package/dist/types/math/src/curve.d.ts +19 -12
- package/dist/types/math/src/segment.d.ts +6 -0
- package/dist/types/utils/src/export.d.ts +1 -0
- package/dist/types/utils/src/shape.d.ts +2 -2
- package/package.json +1 -1
|
@@ -3,6 +3,7 @@ import { AppEventBus, type EXPORT_IMAGE_TYPES, Emitter, type EditorInterface, ty
|
|
|
3
3
|
import { LinearElementEditor, Scene, Store, type ElementUpdate, StoreDelta, type ApplyToOptions } from "@excalidraw/element";
|
|
4
4
|
import type { LocalPoint, Radians } from "@excalidraw/math";
|
|
5
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";
|
|
6
7
|
import type { Mutable } from "@excalidraw/common/utility-types";
|
|
7
8
|
import { ActionManager } from "../actions/manager";
|
|
8
9
|
import { History } from "../history";
|
|
@@ -16,6 +17,7 @@ import { LassoTrail } from "../lasso";
|
|
|
16
17
|
import { EraserTrail } from "../eraser";
|
|
17
18
|
import { AppArrowText } from "./App.arrowText";
|
|
18
19
|
import { AppBucketFill } from "./App.bucketFill";
|
|
20
|
+
import { AppToolDrag } from "./App.toolDrag";
|
|
19
21
|
import { AppCursor } from "./App.cursor";
|
|
20
22
|
import { AppDrawShape } from "./App.drawshape";
|
|
21
23
|
import { AppFlowchart } from "./App.flowchart";
|
|
@@ -82,6 +84,8 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
82
84
|
editorInterface: EditorInterface;
|
|
83
85
|
private stylesPanelMode;
|
|
84
86
|
private excalidrawContainerRef;
|
|
87
|
+
get ownerDocument(): Document;
|
|
88
|
+
get ownerWindow(): Window & typeof globalThis;
|
|
85
89
|
scene: Scene;
|
|
86
90
|
fonts: Fonts;
|
|
87
91
|
renderer: Renderer;
|
|
@@ -93,7 +97,7 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
93
97
|
library: AppClassProperties["library"];
|
|
94
98
|
libraryItemsFromStorage: LibraryItems | undefined;
|
|
95
99
|
id: string;
|
|
96
|
-
|
|
100
|
+
store: Store;
|
|
97
101
|
private history;
|
|
98
102
|
excalidrawContainerValue: {
|
|
99
103
|
container: HTMLDivElement | null;
|
|
@@ -119,6 +123,7 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
119
123
|
private appStateObserver;
|
|
120
124
|
onStateChange: OnStateChange;
|
|
121
125
|
bucketFill: AppBucketFill;
|
|
126
|
+
toolDrag: AppToolDrag;
|
|
122
127
|
flowchart: AppFlowchart;
|
|
123
128
|
cursor: AppCursor;
|
|
124
129
|
arrowText: AppArrowText;
|
|
@@ -127,6 +132,13 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
127
132
|
private textWysiwygSubmitHandler;
|
|
128
133
|
hitLinkElement?: NonDeletedExcalidrawElement;
|
|
129
134
|
lastPointerDownEvent: React.PointerEvent<HTMLElement> | null;
|
|
135
|
+
/**
|
|
136
|
+
* the handle of the resize in progress while `state.isResizing` — for UI
|
|
137
|
+
* that words itself by handle (a sticky note's corners resize
|
|
138
|
+
* proportionally, its edges freely); not app state, so it costs no
|
|
139
|
+
* re-render of its own
|
|
140
|
+
*/
|
|
141
|
+
activeResizeHandle: TransformHandleDirection | null;
|
|
130
142
|
lastPointerUpEvent: React.PointerEvent<HTMLElement> | PointerEvent | null;
|
|
131
143
|
lastPointerUpIsDoubleClick: boolean;
|
|
132
144
|
lastPointerMoveEvent: PointerEvent | null;
|
|
@@ -185,6 +197,7 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
185
197
|
wasAddedToSelection: boolean;
|
|
186
198
|
hasBeenDuplicated: boolean;
|
|
187
199
|
hasHitCommonBoundingBoxOfSelectedElements: boolean;
|
|
200
|
+
arrowLabel: boolean;
|
|
188
201
|
};
|
|
189
202
|
withCmdOrCtrl: boolean;
|
|
190
203
|
drag: {
|
|
@@ -247,6 +260,7 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
247
260
|
wasAddedToSelection: boolean;
|
|
248
261
|
hasBeenDuplicated: boolean;
|
|
249
262
|
hasHitCommonBoundingBoxOfSelectedElements: boolean;
|
|
263
|
+
arrowLabel: boolean;
|
|
250
264
|
};
|
|
251
265
|
withCmdOrCtrl: boolean;
|
|
252
266
|
drag: {
|
|
@@ -363,6 +377,11 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
363
377
|
getEffectiveGridSize: () => NullableGridSize;
|
|
364
378
|
private getTextCreationGridPoint;
|
|
365
379
|
private getHTMLIFrameElement;
|
|
380
|
+
/**
|
|
381
|
+
* AI-generated iframe elements aren't interactive while their generation
|
|
382
|
+
* is still in progress (the partial content is render-only).
|
|
383
|
+
*/
|
|
384
|
+
private isIframeLikeInteractive;
|
|
366
385
|
private handleIframeLikeElementHover;
|
|
367
386
|
/** @returns true if iframe-like element click handled */
|
|
368
387
|
private handleIframeLikeCenterClick;
|
|
@@ -571,9 +590,12 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
571
590
|
}) & {
|
|
572
591
|
preferSelected?: boolean;
|
|
573
592
|
}): NonDeleted<ExcalidrawElement> | null;
|
|
574
|
-
|
|
593
|
+
getElementsAtPosition(x: number, y: number, opts?: {
|
|
594
|
+
includeBoundTextElement?: boolean;
|
|
595
|
+
includeLockedElements?: boolean;
|
|
596
|
+
}): NonDeleted<ExcalidrawElement>[];
|
|
575
597
|
getElementHitThreshold(element: ExcalidrawElement): number;
|
|
576
|
-
|
|
598
|
+
hitElement(x: number, y: number, element: NonDeletedExcalidrawElement, considerBoundingBox?: boolean): boolean;
|
|
577
599
|
getTextBindableContainerAtPosition(x: number, y: number): (Readonly<{
|
|
578
600
|
id: string;
|
|
579
601
|
x: number;
|
|
@@ -601,6 +623,7 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
601
623
|
frameId: string | null;
|
|
602
624
|
boundElements: readonly import("@excalidraw/element/types").BoundElement[] | null;
|
|
603
625
|
updated: number;
|
|
626
|
+
created: number | null;
|
|
604
627
|
link: string | null;
|
|
605
628
|
locked: boolean;
|
|
606
629
|
customData?: Record<string, any>;
|
|
@@ -635,6 +658,43 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
635
658
|
frameId: string | null;
|
|
636
659
|
boundElements: readonly import("@excalidraw/element/types").BoundElement[] | null;
|
|
637
660
|
updated: number;
|
|
661
|
+
created: number | null;
|
|
662
|
+
link: string | null;
|
|
663
|
+
locked: boolean;
|
|
664
|
+
customData?: Record<string, any>;
|
|
665
|
+
}> & Readonly<{
|
|
666
|
+
type: "stickynote";
|
|
667
|
+
baseHeight: number;
|
|
668
|
+
}> & {
|
|
669
|
+
isDeleted: false;
|
|
670
|
+
}) | (Readonly<{
|
|
671
|
+
id: string;
|
|
672
|
+
x: number;
|
|
673
|
+
y: number;
|
|
674
|
+
strokeColor: string;
|
|
675
|
+
backgroundColor: string;
|
|
676
|
+
fillStyle: import("@excalidraw/element/types").FillStyle;
|
|
677
|
+
strokeWidth: number;
|
|
678
|
+
strokeStyle: import("@excalidraw/element/types").StrokeStyle;
|
|
679
|
+
roundness: null | {
|
|
680
|
+
type: import("@excalidraw/element/types").RoundnessType;
|
|
681
|
+
value?: number;
|
|
682
|
+
};
|
|
683
|
+
roughness: number;
|
|
684
|
+
opacity: number;
|
|
685
|
+
width: number;
|
|
686
|
+
height: number;
|
|
687
|
+
angle: Radians;
|
|
688
|
+
seed: number;
|
|
689
|
+
version: number;
|
|
690
|
+
versionNonce: number;
|
|
691
|
+
index: import("@excalidraw/element/types").FractionalIndex | null;
|
|
692
|
+
isDeleted: boolean;
|
|
693
|
+
groupIds: readonly import("@excalidraw/element/types").GroupId[];
|
|
694
|
+
frameId: string | null;
|
|
695
|
+
boundElements: readonly import("@excalidraw/element/types").BoundElement[] | null;
|
|
696
|
+
updated: number;
|
|
697
|
+
created: number | null;
|
|
638
698
|
link: string | null;
|
|
639
699
|
locked: boolean;
|
|
640
700
|
customData?: Record<string, any>;
|
|
@@ -669,6 +729,7 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
669
729
|
frameId: string | null;
|
|
670
730
|
boundElements: readonly import("@excalidraw/element/types").BoundElement[] | null;
|
|
671
731
|
updated: number;
|
|
732
|
+
created: number | null;
|
|
672
733
|
link: string | null;
|
|
673
734
|
locked: boolean;
|
|
674
735
|
customData?: Record<string, any>;
|
|
@@ -703,6 +764,7 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
703
764
|
frameId: string | null;
|
|
704
765
|
boundElements: readonly import("@excalidraw/element/types").BoundElement[] | null;
|
|
705
766
|
updated: number;
|
|
767
|
+
created: number | null;
|
|
706
768
|
link: string | null;
|
|
707
769
|
locked: boolean;
|
|
708
770
|
customData?: Record<string, any>;
|
|
@@ -731,7 +793,25 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
731
793
|
* so the whole create-and-type lands in a single entry.
|
|
732
794
|
*/
|
|
733
795
|
private isEditingTextContent;
|
|
734
|
-
|
|
796
|
+
startTextEditing: ({ sceneX, sceneY, insertAtParentCenter, container, autoEdit, initialCaretSceneCoords, arrowEndpoint, }: {
|
|
797
|
+
/** X position to insert text at */
|
|
798
|
+
sceneX: number;
|
|
799
|
+
/** Y position to insert text at */
|
|
800
|
+
sceneY: number;
|
|
801
|
+
/** whether to attempt to insert at element center if applicable */
|
|
802
|
+
insertAtParentCenter?: boolean;
|
|
803
|
+
container?: ExcalidrawTextContainer | null;
|
|
804
|
+
autoEdit?: boolean;
|
|
805
|
+
initialCaretSceneCoords?: {
|
|
806
|
+
x: number;
|
|
807
|
+
y: number;
|
|
808
|
+
};
|
|
809
|
+
/**
|
|
810
|
+
* creates the text as a label for this arrow endpoint: the binding then
|
|
811
|
+
* dictates the text's position and alignment, overriding (sceneX, sceneY)
|
|
812
|
+
*/
|
|
813
|
+
arrowEndpoint?: ArrowEndpoint | null;
|
|
814
|
+
}) => void;
|
|
735
815
|
private startImageCropping;
|
|
736
816
|
private finishImageCropping;
|
|
737
817
|
private shouldHandleBrowserCanvasDoubleClick;
|
|
@@ -784,6 +864,10 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
784
864
|
private handleCanvasPointerMove;
|
|
785
865
|
private handleEraser;
|
|
786
866
|
private handleTouchMove;
|
|
867
|
+
/**
|
|
868
|
+
* Applies the hover affordances of a selected linear element: the cursor,
|
|
869
|
+
* plus the hovered-handle state that renders them highlighted.
|
|
870
|
+
*/
|
|
787
871
|
handleHoverSelectedLinearElement(linearElementEditor: LinearElementEditor, scenePointerX: number, scenePointerY: number): void;
|
|
788
872
|
private handleCanvasPointerDown;
|
|
789
873
|
private handleCanvasPointerUp;
|
|
@@ -826,8 +910,10 @@ declare class App extends React.Component<AppProps, AppState> {
|
|
|
826
910
|
}) => NonDeleted<ExcalidrawEmbeddableElement> | undefined;
|
|
827
911
|
private newImagePlaceholder;
|
|
828
912
|
private handleLinearElementOnPointerDown;
|
|
829
|
-
|
|
830
|
-
|
|
913
|
+
getCurrentItemRoundness(elementType: "selection" | "rectangle" | "stickynote" | "diamond" | "ellipse" | "iframe" | "embeddable"): {
|
|
914
|
+
type: 2 | 3;
|
|
915
|
+
} | null;
|
|
916
|
+
getCurrentItemStrokeWidth(elementType: ExcalidrawElement["type"]): number;
|
|
831
917
|
private createGenericElementOnPointerDown;
|
|
832
918
|
private createFrameElementOnPointerDown;
|
|
833
919
|
private maybeCacheReferenceSnapPoints;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { ExcalidrawNonSelectionElement, NonDeleted } from "@excalidraw/element/types";
|
|
2
|
+
import type App from "./App";
|
|
3
|
+
import type { ToolType } from "../types";
|
|
4
|
+
type ScenePoint = {
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
};
|
|
8
|
+
/** what a drag places: any element the new-element canvas can preview */
|
|
9
|
+
type DraggedElement = NonDeleted<ExcalidrawNonSelectionElement>;
|
|
10
|
+
/**
|
|
11
|
+
* A tool the user can drag out of the toolbar to drop a default-sized element
|
|
12
|
+
* where the pointer is released.
|
|
13
|
+
*/
|
|
14
|
+
type DraggableTool = {
|
|
15
|
+
/** the element the drop creates, centered on the pointer */
|
|
16
|
+
createElement: (app: App, center: ScenePoint) => DraggedElement;
|
|
17
|
+
/** what the tool does once its element is on the canvas (e.g. start editing) */
|
|
18
|
+
onDrop?: (app: App, element: DraggedElement) => void;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* The tools that can be dragged out of the toolbar. Add an entry to make a
|
|
22
|
+
* tool's button draggable — the gesture, preview and drop are shared.
|
|
23
|
+
*/
|
|
24
|
+
export declare const DRAGGABLE_TOOLS: Partial<Record<ToolType, DraggableTool>>;
|
|
25
|
+
/** CSS opacity of the preview canvas while dragging */
|
|
26
|
+
export declare const TOOL_DRAG_PREVIEW_OPACITY = 0.5;
|
|
27
|
+
/**
|
|
28
|
+
* Dragging a tool out of the toolbar. The preview element exists only here
|
|
29
|
+
* until the drop — it is not in the scene, the store or the history, so
|
|
30
|
+
* collaborators never see it and an aborted drag leaves nothing behind. It
|
|
31
|
+
* is painted by the `NewElementCanvas`, drawn exactly as it will land, with
|
|
32
|
+
* the canvas itself made translucent.
|
|
33
|
+
*
|
|
34
|
+
* The button arms on pointerdown; the drag starts once the pointer has
|
|
35
|
+
* moved `DRAGGING_THRESHOLD`, so a plain click still selects the tool. The
|
|
36
|
+
* gesture lives on the owner window (the pointer leaves the button at once),
|
|
37
|
+
* like the other pointer gestures in `App`.
|
|
38
|
+
*/
|
|
39
|
+
export declare class AppToolDrag {
|
|
40
|
+
private app;
|
|
41
|
+
constructor(app: App);
|
|
42
|
+
/** the element under the pointer while dragging, `null` otherwise */
|
|
43
|
+
preview: DraggedElement | null;
|
|
44
|
+
private armed;
|
|
45
|
+
private tool;
|
|
46
|
+
private type;
|
|
47
|
+
static isDraggable: (type: ToolType) => boolean;
|
|
48
|
+
isDragging: () => boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Arm a drag from a tool button's pointerdown. Returns whether the tool is
|
|
51
|
+
* draggable (the caller lets a non-draggable press fall through).
|
|
52
|
+
*/
|
|
53
|
+
handleButtonPointerDown: (type: ToolType, event: PointerEvent) => boolean;
|
|
54
|
+
private onPointerMove;
|
|
55
|
+
private onPointerUp;
|
|
56
|
+
private onKeyDown;
|
|
57
|
+
/** drop the gesture without a trace */
|
|
58
|
+
cancel: () => void;
|
|
59
|
+
private isOverCanvas;
|
|
60
|
+
private addListeners;
|
|
61
|
+
private removeListeners;
|
|
62
|
+
}
|
|
63
|
+
export {};
|
|
@@ -41,6 +41,8 @@ type IconButtonProps = (IconButtonBaseProps & {
|
|
|
41
41
|
onSelect?(data: {
|
|
42
42
|
pointerType: PointerType | null;
|
|
43
43
|
}): void;
|
|
44
|
+
/** the press that may become a click — e.g. to arm a drag out of the toolbar */
|
|
45
|
+
onPointerDown?(event: React.PointerEvent<HTMLButtonElement>): void;
|
|
44
46
|
});
|
|
45
47
|
export declare const IconButton: React.ForwardRefExoticComponent<IconButtonProps & React.RefAttributes<unknown>>;
|
|
46
48
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AppClassProperties, AppState, ToolType, UIAppState } from "../types";
|
|
2
2
|
export type ToolConfig = {
|
|
3
3
|
icon: React.ReactNode;
|
|
4
|
-
/** letter shortcut(s) — the first one is shown in tooltips */
|
|
4
|
+
/** letter shortcut(s) — the first one is shown in tooltips and badges */
|
|
5
5
|
letterKey?: string | readonly string[];
|
|
6
6
|
/** whether `letterKey` requires Shift to be held (e.g. Shift+X) */
|
|
7
7
|
shiftKey?: boolean;
|
|
@@ -31,6 +31,7 @@ export declare const TOOLS: {
|
|
|
31
31
|
line: ToolConfig;
|
|
32
32
|
freedraw: ToolConfig;
|
|
33
33
|
text: ToolConfig;
|
|
34
|
+
stickynote: ToolConfig;
|
|
34
35
|
image: ToolConfig;
|
|
35
36
|
eraser: ToolConfig;
|
|
36
37
|
frame: ToolConfig;
|
|
@@ -49,7 +50,7 @@ export declare const TOGGLE_TOOLS: readonly (ToolType | "custom")[];
|
|
|
49
50
|
export declare const getToolLetter: (type: ToolbarToolType) => string | undefined;
|
|
50
51
|
/** human-readable shortcut hint, e.g. "R or 2", used in tooltips & aria */
|
|
51
52
|
export declare const getToolShortcut: (type: ToolbarToolType) => string;
|
|
52
|
-
export declare const findShapeByKey: (key: string, app: AppClassProperties, shiftKey?: boolean) => "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "embeddable" | "image" | "frame" | "freedraw" | "lasso" | "eraser" | "hand" | "laser" | "autoshape" | "bucketfill" | null;
|
|
53
|
+
export declare const findShapeByKey: (key: string, app: AppClassProperties, shiftKey?: boolean) => "line" | "arrow" | "text" | "selection" | "rectangle" | "stickynote" | "diamond" | "ellipse" | "embeddable" | "image" | "frame" | "freedraw" | "lasso" | "eraser" | "hand" | "laser" | "autoshape" | "bucketfill" | null;
|
|
53
54
|
/**
|
|
54
55
|
* Whether a toolbar entry activating the given tool renders disabled — true
|
|
55
56
|
* when the active tool is host-controlled (`props.activeTool`) and the entry
|
|
@@ -99,6 +100,10 @@ export declare const TextToolButton: {
|
|
|
99
100
|
({ app, activeTool, hideKeyBinding, hideShortcut, }: ToolButtonComponentProps): import("react/jsx-runtime").JSX.Element;
|
|
100
101
|
displayName: string;
|
|
101
102
|
};
|
|
103
|
+
export declare const StickyNoteToolButton: {
|
|
104
|
+
({ app, activeTool, hideKeyBinding, hideShortcut, }: ToolButtonComponentProps): import("react/jsx-runtime").JSX.Element;
|
|
105
|
+
displayName: string;
|
|
106
|
+
};
|
|
102
107
|
export declare const ImageToolButton: {
|
|
103
108
|
({ app, activeTool, hideKeyBinding, hideShortcut, }: ToolButtonComponentProps): import("react/jsx-runtime").JSX.Element;
|
|
104
109
|
displayName: string;
|
|
@@ -10,6 +10,8 @@ interface NewElementCanvasProps {
|
|
|
10
10
|
scale: number;
|
|
11
11
|
rc: RoughCanvas;
|
|
12
12
|
renderConfig: StaticCanvasRenderConfig;
|
|
13
|
+
/** CSS opacity of the whole canvas — a translucent preview of a finished element */
|
|
14
|
+
opacity?: number;
|
|
13
15
|
}
|
|
14
16
|
declare const NewElementCanvas: (props: NewElementCanvasProps) => import("react/jsx-runtime").JSX.Element;
|
|
15
17
|
export default NewElementCanvas;
|
|
@@ -200,6 +200,7 @@ export declare const alertTriangleIcon: import("react/jsx-runtime").JSX.Element;
|
|
|
200
200
|
export declare const eyeDropperIconSvgPaths: readonly ["M4 16l11.7 -11.7a1 1 0 0 1 1.4 0l2.6 2.6a1 1 0 0 1 0 1.4l-11.7 11.7h-4v-4z", "M11 7l6 6"];
|
|
201
201
|
export declare const eyeDropperIcon: import("react/jsx-runtime").JSX.Element;
|
|
202
202
|
export declare const frameToolIcon: import("react/jsx-runtime").JSX.Element;
|
|
203
|
+
export declare const stickyNoteToolIcon: import("react/jsx-runtime").JSX.Element;
|
|
203
204
|
export declare const mermaidLogoIcon: import("react/jsx-runtime").JSX.Element;
|
|
204
205
|
export declare const RetryIcon: import("react/jsx-runtime").JSX.Element;
|
|
205
206
|
export declare const stackPushIcon: import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { ExcalidrawElement, NonDeletedElementsMap, NonDeletedSceneElementsMap } from "@excalidraw/element/types";
|
|
1
|
+
import type { ElementsMap, ExcalidrawElement, NonDeletedElementsMap, NonDeletedSceneElementsMap } from "@excalidraw/element/types";
|
|
2
2
|
import type { AppClassProperties, UIAppState } from "../types";
|
|
3
3
|
export declare const canChangeStrokeColor: (appState: UIAppState, targetElements: ExcalidrawElement[]) => boolean;
|
|
4
|
-
export declare const canChangeBackgroundColor: (appState: UIAppState, targetElements: ExcalidrawElement[]) => boolean;
|
|
4
|
+
export declare const canChangeBackgroundColor: (appState: UIAppState, targetElements: ExcalidrawElement[], elementsMap: ElementsMap) => boolean;
|
|
5
5
|
/**
|
|
6
6
|
* Single source of truth for "which shape-action controls are relevant right
|
|
7
7
|
* now". Each flag answers whether a given control should be shown, given the
|
|
@@ -82,6 +82,8 @@ fileHandle?: FileSystemFileHandle | null) => Promise<{
|
|
|
82
82
|
exportWithDarkMode: boolean;
|
|
83
83
|
exportScale: number;
|
|
84
84
|
currentItemStrokeColor: string;
|
|
85
|
+
currentItemStickynoteStrokeColor: string;
|
|
86
|
+
currentItemStickynoteBackgroundColor: string;
|
|
85
87
|
currentItemBackgroundColor: string;
|
|
86
88
|
currentItemFillStyle: ExcalidrawElement["fillStyle"];
|
|
87
89
|
currentItemStrokeWidthKey: import("@excalidraw/common").StrokeWidthKey;
|
|
@@ -179,6 +181,8 @@ fileHandle?: FileSystemFileHandle | null) => Promise<{
|
|
|
179
181
|
elementStroke: readonly string[] | null;
|
|
180
182
|
elementBackground: readonly string[] | null;
|
|
181
183
|
bucketFill: readonly string[] | null;
|
|
184
|
+
stickyNoteStroke: readonly string[] | null;
|
|
185
|
+
stickyNoteBackground: readonly string[] | null;
|
|
182
186
|
};
|
|
183
187
|
};
|
|
184
188
|
files: import("../types").BinaryFiles;
|
|
@@ -256,6 +260,8 @@ fileHandle?: FileSystemFileHandle | null) => Promise<{
|
|
|
256
260
|
exportWithDarkMode: boolean;
|
|
257
261
|
exportScale: number;
|
|
258
262
|
currentItemStrokeColor: string;
|
|
263
|
+
currentItemStickynoteStrokeColor: string;
|
|
264
|
+
currentItemStickynoteBackgroundColor: string;
|
|
259
265
|
currentItemBackgroundColor: string;
|
|
260
266
|
currentItemFillStyle: ExcalidrawElement["fillStyle"];
|
|
261
267
|
currentItemStrokeWidthKey: import("@excalidraw/common").StrokeWidthKey;
|
|
@@ -353,6 +359,8 @@ fileHandle?: FileSystemFileHandle | null) => Promise<{
|
|
|
353
359
|
elementStroke: readonly string[] | null;
|
|
354
360
|
elementBackground: readonly string[] | null;
|
|
355
361
|
bucketFill: readonly string[] | null;
|
|
362
|
+
stickyNoteStroke: readonly string[] | null;
|
|
363
|
+
stickyNoteBackground: readonly string[] | null;
|
|
356
364
|
};
|
|
357
365
|
};
|
|
358
366
|
files: import("../types").BinaryFiles;
|
|
@@ -80,6 +80,8 @@ export declare const loadFromJSON: (localAppState: AppState, localElements: read
|
|
|
80
80
|
exportWithDarkMode: boolean;
|
|
81
81
|
exportScale: number;
|
|
82
82
|
currentItemStrokeColor: string;
|
|
83
|
+
currentItemStickynoteStrokeColor: string;
|
|
84
|
+
currentItemStickynoteBackgroundColor: string;
|
|
83
85
|
currentItemBackgroundColor: string;
|
|
84
86
|
currentItemFillStyle: ExcalidrawElement["fillStyle"];
|
|
85
87
|
currentItemStrokeWidthKey: import("@excalidraw/common").StrokeWidthKey;
|
|
@@ -177,6 +179,8 @@ export declare const loadFromJSON: (localAppState: AppState, localElements: read
|
|
|
177
179
|
elementStroke: readonly string[] | null;
|
|
178
180
|
elementBackground: readonly string[] | null;
|
|
179
181
|
bucketFill: readonly string[] | null;
|
|
182
|
+
stickyNoteStroke: readonly string[] | null;
|
|
183
|
+
stickyNoteBackground: readonly string[] | null;
|
|
180
184
|
};
|
|
181
185
|
};
|
|
182
186
|
files: BinaryFiles;
|
|
@@ -15,7 +15,8 @@ export declare class Fonts {
|
|
|
15
15
|
fontFaces: ExcalidrawFontFace[];
|
|
16
16
|
}>;
|
|
17
17
|
private readonly scene;
|
|
18
|
-
|
|
18
|
+
private readonly ownerDocument;
|
|
19
|
+
constructor(scene: Scene, ownerDocument?: Document);
|
|
19
20
|
/**
|
|
20
21
|
* Get all the font families for the given scene.
|
|
21
22
|
*/
|
|
@@ -36,7 +37,7 @@ export declare class Fonts {
|
|
|
36
37
|
/**
|
|
37
38
|
* Load font faces for passed elements - use when the scene is unavailable (i.e. export).
|
|
38
39
|
*/
|
|
39
|
-
static loadElementsFonts: (elements: readonly ExcalidrawElement[]) => Promise<FontFace[]>;
|
|
40
|
+
static loadElementsFonts: (elements: readonly ExcalidrawElement[], ownerDocument?: Document) => Promise<FontFace[]>;
|
|
40
41
|
/**
|
|
41
42
|
* Generate CSS @font-face declarations for the given elements.
|
|
42
43
|
*/
|
|
@@ -2,13 +2,13 @@ export type CaretPosition = {
|
|
|
2
2
|
start: number;
|
|
3
3
|
end: number;
|
|
4
4
|
};
|
|
5
|
-
export declare const saveCaretPosition: () => CaretPosition | null;
|
|
6
|
-
export declare const restoreCaretPosition: (position: CaretPosition | null) => void;
|
|
7
|
-
export declare const withCaretPositionPreservation: (callback: () => void, isCompactMode: boolean, isEditingText: boolean, onPreventClose?: () => void) => void;
|
|
8
|
-
export declare const useTextEditorFocus: () => {
|
|
5
|
+
export declare const saveCaretPosition: (ownerDocument?: Document) => CaretPosition | null;
|
|
6
|
+
export declare const restoreCaretPosition: (position: CaretPosition | null, ownerDocument?: Document) => void;
|
|
7
|
+
export declare const withCaretPositionPreservation: (callback: () => void, isCompactMode: boolean, isEditingText: boolean, onPreventClose?: () => void, ownerDocument?: Document) => void;
|
|
8
|
+
export declare const useTextEditorFocus: (ownerDocument?: Document) => {
|
|
9
9
|
saveCaretPosition: () => void;
|
|
10
10
|
restoreCaretPosition: () => void;
|
|
11
11
|
clearSavedPosition: () => void;
|
|
12
12
|
hasSavedPosition: boolean;
|
|
13
13
|
};
|
|
14
|
-
export declare const temporarilyDisableTextEditorBlur: (duration?: number) => void;
|
|
14
|
+
export declare const temporarilyDisableTextEditorBlur: (ownerDocument?: Document, duration?: number) => void;
|
|
@@ -1,6 +1,31 @@
|
|
|
1
1
|
import type { StaticCanvasRenderConfig } from "../scene/types";
|
|
2
2
|
import type { AppState, StaticCanvasAppState } from "../types";
|
|
3
|
+
export declare const DEFAULT_SELECTION_COLOR = "#6965db";
|
|
4
|
+
/**
|
|
5
|
+
* Returns the theme's selection color (`--color-selection`), read from the
|
|
6
|
+
* computed style of any element inside the editor container so that host
|
|
7
|
+
* overrides are respected. Falls back to the default when unavailable.
|
|
8
|
+
*/
|
|
9
|
+
export declare const getSelectionColor: (element: Element | null | undefined) => string;
|
|
3
10
|
export declare const fillCircle: (context: CanvasRenderingContext2D, cx: number, cy: number, radius: number, stroke: boolean, fill?: boolean) => void;
|
|
11
|
+
/**
|
|
12
|
+
* The scroll the renderers draw at: the real one, rounded to whole device
|
|
13
|
+
* pixels. Panning writes a fractional scroll (pointer delta ÷ zoom), and an
|
|
14
|
+
* element's cached bitmap blitted at a fractional device offset gets
|
|
15
|
+
* resampled — so as the fraction drifts under a pan, every element pulses
|
|
16
|
+
* between crisp and soft. A whole-pixel scroll moves the scene the way a
|
|
17
|
+
* browser scrolls a page: each element keeps its own, constant sub-pixel
|
|
18
|
+
* phase and a pan never changes how anything is filtered. The difference
|
|
19
|
+
* stays under half a device pixel, so hit-testing and DOM overlays keep
|
|
20
|
+
* using the real scroll. Identity when nothing needs to change.
|
|
21
|
+
*/
|
|
22
|
+
export declare const snapScrollToDevicePixels: <T extends {
|
|
23
|
+
scrollX: number;
|
|
24
|
+
scrollY: number;
|
|
25
|
+
zoom: {
|
|
26
|
+
value: number;
|
|
27
|
+
};
|
|
28
|
+
}>(appState: T, scale: number) => T;
|
|
4
29
|
export declare const getNormalizedCanvasDimensions: (canvas: HTMLCanvasElement, scale: number) => [number, number];
|
|
5
30
|
export declare const bootstrapCanvas: ({ canvas, scale, normalizedWidth, normalizedHeight, theme, isExporting, viewBackgroundColor, }: {
|
|
6
31
|
canvas: HTMLCanvasElement;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getScrollBars } from "../scene/scrollbars";
|
|
2
2
|
import type { InteractiveSceneRenderConfig } from "../scene/types";
|
|
3
|
-
declare const _renderInteractiveScene: ({ app, canvas, elementsMap, visibleElements, selectedElements, allElementsMap, scale, appState, renderConfig, editorInterface, animationState, deltaTime, }: InteractiveSceneRenderConfig) => {
|
|
3
|
+
declare const _renderInteractiveScene: ({ app, canvas, elementsMap, visibleElements, selectedElements, allElementsMap, scale, appState: unsnappedAppState, renderConfig, editorInterface, animationState, deltaTime, }: InteractiveSceneRenderConfig) => {
|
|
4
4
|
scrollBars?: ReturnType<typeof getScrollBars>;
|
|
5
5
|
animationState?: typeof animationState;
|
|
6
6
|
};
|
|
@@ -53,6 +53,7 @@ export declare class Renderer {
|
|
|
53
53
|
frameId: string | null;
|
|
54
54
|
boundElements: readonly import("@excalidraw/element/types").BoundElement[] | null;
|
|
55
55
|
updated: number;
|
|
56
|
+
created: number | null;
|
|
56
57
|
link: string | null;
|
|
57
58
|
locked: boolean;
|
|
58
59
|
customData?: Record<string, any>;
|
|
@@ -92,6 +93,7 @@ export declare class Renderer {
|
|
|
92
93
|
frameId: string | null;
|
|
93
94
|
boundElements: readonly import("@excalidraw/element/types").BoundElement[] | null;
|
|
94
95
|
updated: number;
|
|
96
|
+
created: number | null;
|
|
95
97
|
link: string | null;
|
|
96
98
|
locked: boolean;
|
|
97
99
|
customData?: Record<string, any>;
|
|
@@ -126,6 +128,43 @@ export declare class Renderer {
|
|
|
126
128
|
frameId: string | null;
|
|
127
129
|
boundElements: readonly import("@excalidraw/element/types").BoundElement[] | null;
|
|
128
130
|
updated: number;
|
|
131
|
+
created: number | null;
|
|
132
|
+
link: string | null;
|
|
133
|
+
locked: boolean;
|
|
134
|
+
customData?: Record<string, any>;
|
|
135
|
+
}> & Readonly<{
|
|
136
|
+
type: "stickynote";
|
|
137
|
+
baseHeight: number;
|
|
138
|
+
}> & {
|
|
139
|
+
isDeleted: false;
|
|
140
|
+
}) | (Readonly<{
|
|
141
|
+
id: string;
|
|
142
|
+
x: number;
|
|
143
|
+
y: number;
|
|
144
|
+
strokeColor: string;
|
|
145
|
+
backgroundColor: string;
|
|
146
|
+
fillStyle: import("@excalidraw/element/types").FillStyle;
|
|
147
|
+
strokeWidth: number;
|
|
148
|
+
strokeStyle: import("@excalidraw/element/types").StrokeStyle;
|
|
149
|
+
roundness: null | {
|
|
150
|
+
type: import("@excalidraw/element/types").RoundnessType;
|
|
151
|
+
value?: number;
|
|
152
|
+
};
|
|
153
|
+
roughness: number;
|
|
154
|
+
opacity: number;
|
|
155
|
+
width: number;
|
|
156
|
+
height: number;
|
|
157
|
+
angle: import("@excalidraw/math").Radians;
|
|
158
|
+
seed: number;
|
|
159
|
+
version: number;
|
|
160
|
+
versionNonce: number;
|
|
161
|
+
index: import("@excalidraw/element/types").FractionalIndex | null;
|
|
162
|
+
isDeleted: boolean;
|
|
163
|
+
groupIds: readonly import("@excalidraw/element/types").GroupId[];
|
|
164
|
+
frameId: string | null;
|
|
165
|
+
boundElements: readonly import("@excalidraw/element/types").BoundElement[] | null;
|
|
166
|
+
updated: number;
|
|
167
|
+
created: number | null;
|
|
129
168
|
link: string | null;
|
|
130
169
|
locked: boolean;
|
|
131
170
|
customData?: Record<string, any>;
|
|
@@ -160,6 +199,7 @@ export declare class Renderer {
|
|
|
160
199
|
frameId: string | null;
|
|
161
200
|
boundElements: readonly import("@excalidraw/element/types").BoundElement[] | null;
|
|
162
201
|
updated: number;
|
|
202
|
+
created: number | null;
|
|
163
203
|
link: string | null;
|
|
164
204
|
locked: boolean;
|
|
165
205
|
customData?: Record<string, any>;
|
|
@@ -194,6 +234,7 @@ export declare class Renderer {
|
|
|
194
234
|
frameId: string | null;
|
|
195
235
|
boundElements: readonly import("@excalidraw/element/types").BoundElement[] | null;
|
|
196
236
|
updated: number;
|
|
237
|
+
created: number | null;
|
|
197
238
|
link: string | null;
|
|
198
239
|
locked: boolean;
|
|
199
240
|
customData?: Record<string, any>;
|
|
@@ -228,6 +269,7 @@ export declare class Renderer {
|
|
|
228
269
|
frameId: string | null;
|
|
229
270
|
boundElements: readonly import("@excalidraw/element/types").BoundElement[] | null;
|
|
230
271
|
updated: number;
|
|
272
|
+
created: number | null;
|
|
231
273
|
link: string | null;
|
|
232
274
|
locked: boolean;
|
|
233
275
|
customData?: Record<string, any>;
|
|
@@ -265,6 +307,7 @@ export declare class Renderer {
|
|
|
265
307
|
frameId: string | null;
|
|
266
308
|
boundElements: readonly import("@excalidraw/element/types").BoundElement[] | null;
|
|
267
309
|
updated: number;
|
|
310
|
+
created: number | null;
|
|
268
311
|
link: string | null;
|
|
269
312
|
locked: boolean;
|
|
270
313
|
customData?: Record<string, any>;
|
|
@@ -303,6 +346,7 @@ export declare class Renderer {
|
|
|
303
346
|
frameId: string | null;
|
|
304
347
|
boundElements: readonly import("@excalidraw/element/types").BoundElement[] | null;
|
|
305
348
|
updated: number;
|
|
349
|
+
created: number | null;
|
|
306
350
|
link: string | null;
|
|
307
351
|
locked: boolean;
|
|
308
352
|
customData?: Record<string, any>;
|
|
@@ -338,6 +382,7 @@ export declare class Renderer {
|
|
|
338
382
|
frameId: string | null;
|
|
339
383
|
boundElements: readonly import("@excalidraw/element/types").BoundElement[] | null;
|
|
340
384
|
updated: number;
|
|
385
|
+
created: number | null;
|
|
341
386
|
link: string | null;
|
|
342
387
|
locked: boolean;
|
|
343
388
|
customData?: Record<string, any>;
|
|
@@ -373,6 +418,7 @@ export declare class Renderer {
|
|
|
373
418
|
frameId: string | null;
|
|
374
419
|
boundElements: readonly import("@excalidraw/element/types").BoundElement[] | null;
|
|
375
420
|
updated: number;
|
|
421
|
+
created: number | null;
|
|
376
422
|
link: string | null;
|
|
377
423
|
locked: boolean;
|
|
378
424
|
customData?: Record<string, any>;
|
|
@@ -380,15 +426,17 @@ export declare class Renderer {
|
|
|
380
426
|
type: "text";
|
|
381
427
|
fontSize: number;
|
|
382
428
|
fontFamily: import("@excalidraw/element/types").FontFamilyValues;
|
|
429
|
+
baseFontSize: number | null;
|
|
383
430
|
text: string;
|
|
384
431
|
textAlign: import("@excalidraw/element/types").TextAlign;
|
|
385
432
|
verticalAlign: import("@excalidraw/element/types").VerticalAlign;
|
|
386
|
-
containerId: import("@excalidraw/element/types").
|
|
433
|
+
containerId: import("@excalidraw/element/types").ExcalidrawTextContainer["id"] | null;
|
|
387
434
|
originalText: string;
|
|
388
435
|
autoResize: boolean;
|
|
389
436
|
lineHeight: number & {
|
|
390
437
|
_brand: "unitlessLineHeight";
|
|
391
438
|
};
|
|
439
|
+
labelPosition?: number | null;
|
|
392
440
|
}> & {
|
|
393
441
|
isDeleted: false;
|
|
394
442
|
}) | (Readonly<{
|
|
@@ -418,6 +466,7 @@ export declare class Renderer {
|
|
|
418
466
|
frameId: string | null;
|
|
419
467
|
boundElements: readonly import("@excalidraw/element/types").BoundElement[] | null;
|
|
420
468
|
updated: number;
|
|
469
|
+
created: number | null;
|
|
421
470
|
link: string | null;
|
|
422
471
|
locked: boolean;
|
|
423
472
|
customData?: Record<string, any>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { isSomeElementSelected, getElementsWithinSelection, getSelectedElements, getTargetElements, } from "@excalidraw/element";
|
|
2
2
|
export { getScrollToContentState } from "../viewport";
|
|
3
|
-
export { hasBackground, hasStrokeWidth, hasStrokeStyle, hasFreedrawMode, canHaveArrowheads, canChangeRoundness, } from "@excalidraw/element";
|
|
3
|
+
export { hasBackground, hasFillStyle, hasRoughness, hasStrokeWidth, hasStrokeStyle, hasFreedrawMode, canHaveArrowheads, canChangeRoundness, } from "@excalidraw/element";
|
|
4
4
|
export { getNormalizedZoom, getNormalizedGridSize, getNormalizedGridStep, } from "./normalize";
|