@zsviczian/excalidraw 0.16.1-obsidian-3 → 0.16.1-obsidian-5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zsviczian/excalidraw",
3
- "version": "0.16.1-obsidian-3",
3
+ "version": "0.16.1-obsidian-5",
4
4
  "main": "main.js",
5
5
  "types": "types/packages/excalidraw/index.d.ts",
6
6
  "files": [
@@ -56,12 +56,6 @@ export declare const actionClearCanvas: {
56
56
  pinnedScripts: string[] | undefined;
57
57
  customPens: any[] | undefined;
58
58
  name: string;
59
- toast: {
60
- message: string;
61
- closable?: boolean | undefined;
62
- duration?: number | undefined;
63
- } | null;
64
- collaborators: Map<string, import("../types").Collaborator>;
65
59
  contextMenu: {
66
60
  items: import("../components/ContextMenu").ContextMenuItems;
67
61
  top: number;
@@ -134,6 +128,11 @@ export declare const actionClearCanvas: {
134
128
  };
135
129
  selectedElementsAreBeingDragged: boolean;
136
130
  shouldCacheIgnoreZoom: boolean;
131
+ toast: {
132
+ message: string;
133
+ closable?: boolean | undefined;
134
+ duration?: number | undefined;
135
+ } | null;
137
136
  zenModeEnabled: boolean;
138
137
  previousGridSize: number | null;
139
138
  viewModeEnabled: boolean;
@@ -142,6 +141,7 @@ export declare const actionClearCanvas: {
142
141
  };
143
142
  editingGroupId: string | null;
144
143
  fileHandle: import("browser-fs-access").FileSystemHandle | null;
144
+ collaborators: Map<string, import("../types").Collaborator>;
145
145
  currentChartType: import("../element/types").ChartType;
146
146
  pendingImageElementId: string | null;
147
147
  showHyperlinkPopup: false | "editor" | "info";
@@ -367,6 +367,7 @@ export declare const actionCut: {
367
367
  multiElement: null;
368
368
  activeEmbeddable: null;
369
369
  selectedElementIds: {};
370
+ selectedGroupIds: {};
370
371
  contextMenu: {
371
372
  items: import("../components/ContextMenu").ContextMenuItems;
372
373
  top: number;
@@ -446,9 +447,6 @@ export declare const actionCut: {
446
447
  gridSize: number | null;
447
448
  previousGridSize: number | null;
448
449
  viewModeEnabled: boolean;
449
- selectedGroupIds: {
450
- [groupId: string]: boolean;
451
- };
452
450
  editingGroupId: string | null;
453
451
  width: number;
454
452
  height: number;
@@ -343,6 +343,7 @@ export declare const actionDeleteSelected: {
343
343
  multiElement: null;
344
344
  activeEmbeddable: null;
345
345
  selectedElementIds: {};
346
+ selectedGroupIds: {};
346
347
  contextMenu: {
347
348
  items: import("../components/ContextMenu").ContextMenuItems;
348
349
  top: number;
@@ -422,9 +423,6 @@ export declare const actionDeleteSelected: {
422
423
  gridSize: number | null;
423
424
  previousGridSize: number | null;
424
425
  viewModeEnabled: boolean;
425
- selectedGroupIds: {
426
- [groupId: string]: boolean;
427
- };
428
426
  editingGroupId: string | null;
429
427
  width: number;
430
428
  height: number;
@@ -802,7 +802,11 @@ export declare const actionSaveFileToDisk: {
802
802
  perform: (elements: readonly import("../element/types").ExcalidrawElement[], appState: Readonly<import("../types").AppState>, value: any, app: import("../types").AppClassProperties) => Promise<{
803
803
  commitToHistory: false;
804
804
  appState: {
805
+ openDialog: null;
805
806
  fileHandle: import("browser-fs-access").FileSystemHandle | null;
807
+ toast: {
808
+ message: string;
809
+ };
806
810
  contextMenu: {
807
811
  items: import("../components/ContextMenu").ContextMenuItems;
808
812
  top: number;
@@ -873,7 +877,6 @@ export declare const actionSaveFileToDisk: {
873
877
  name: string;
874
878
  tab?: string | undefined;
875
879
  } | null;
876
- openDialog: "imageExport" | "help" | "jsonExport" | null;
877
880
  defaultSidebarDockedPreference: boolean;
878
881
  lastPointerDownWith: import("../element/types").PointerType;
879
882
  selectedElementIds: Readonly<{
@@ -884,11 +887,6 @@ export declare const actionSaveFileToDisk: {
884
887
  };
885
888
  selectedElementsAreBeingDragged: boolean;
886
889
  shouldCacheIgnoreZoom: boolean;
887
- toast: {
888
- message: string;
889
- closable?: boolean | undefined;
890
- duration?: number | undefined;
891
- } | null;
892
890
  zenModeEnabled: boolean;
893
891
  theme: Theme;
894
892
  gridSize: number | null;
@@ -970,13 +968,6 @@ export declare const actionLoadScene: {
970
968
  locked: boolean;
971
969
  } & import("../types").ActiveTool;
972
970
  name: string;
973
- toast: {
974
- message: string;
975
- closable?: boolean | undefined;
976
- duration?: number | undefined;
977
- } | null;
978
- collaborators: Map<string, import("../types").Collaborator>;
979
- penMode: boolean;
980
971
  contextMenu: {
981
972
  items: import("../components/ContextMenu").ContextMenuItems;
982
973
  top: number;
@@ -1007,6 +998,7 @@ export declare const actionLoadScene: {
1007
998
  elementsToHighlight: import("../element/types").NonDeleted<import("../element/types").ExcalidrawElement>[] | null;
1008
999
  editingElement: import("../element/types").NonDeletedExcalidrawElement | null;
1009
1000
  editingLinearElement: import("../element/linearElementEditor").LinearElementEditor | null;
1001
+ penMode: boolean;
1010
1002
  penDetected: boolean;
1011
1003
  exportBackground: boolean;
1012
1004
  exportEmbedScene: boolean;
@@ -1052,6 +1044,11 @@ export declare const actionLoadScene: {
1052
1044
  };
1053
1045
  selectedElementsAreBeingDragged: boolean;
1054
1046
  shouldCacheIgnoreZoom: boolean;
1047
+ toast: {
1048
+ message: string;
1049
+ closable?: boolean | undefined;
1050
+ duration?: number | undefined;
1051
+ } | null;
1055
1052
  zenModeEnabled: boolean;
1056
1053
  theme: Theme;
1057
1054
  gridSize: number | null;
@@ -1062,6 +1059,7 @@ export declare const actionLoadScene: {
1062
1059
  };
1063
1060
  editingGroupId: string | null;
1064
1061
  fileHandle: import("browser-fs-access").FileSystemHandle | null;
1062
+ collaborators: Map<string, import("../types").Collaborator>;
1065
1063
  showStats: boolean;
1066
1064
  currentChartType: import("../element/types").ChartType;
1067
1065
  pasteDialog: {
@@ -6,8 +6,8 @@ export declare const clearAppStateForLocalStorage: (appState: Partial<AppState>)
6
6
  locked: boolean;
7
7
  } & import("./types").ActiveTool) | undefined;
8
8
  name?: string | undefined;
9
- penMode?: boolean | undefined;
10
9
  showWelcomeScreen?: boolean | undefined;
10
+ penMode?: boolean | undefined;
11
11
  penDetected?: boolean | undefined;
12
12
  exportBackground?: boolean | undefined;
13
13
  exportEmbedScene?: boolean | undefined;
@@ -1,11 +1,16 @@
1
1
  import { ExcalidrawElement, NonDeletedExcalidrawElement } from "./element/types";
2
2
  import { BinaryFiles } from "./types";
3
3
  import { Spreadsheet } from "./charts";
4
+ export type PastedMixedContent = {
5
+ type: "text" | "imageUrl";
6
+ value: string;
7
+ }[];
4
8
  export interface ClipboardData {
5
9
  spreadsheet?: Spreadsheet;
6
10
  elements?: readonly ExcalidrawElement[];
7
11
  files?: BinaryFiles;
8
12
  text?: string;
13
+ mixedContent?: PastedMixedContent;
9
14
  errorMessage?: string;
10
15
  programmaticAPI?: boolean;
11
16
  }
@@ -13,11 +18,6 @@ export declare const probablySupportsClipboardReadText: boolean;
13
18
  export declare const probablySupportsClipboardWriteText: boolean;
14
19
  export declare const probablySupportsClipboardBlob: boolean;
15
20
  export declare const copyToClipboard: (elements: readonly NonDeletedExcalidrawElement[], files: BinaryFiles | null) => Promise<string | undefined>;
16
- /**
17
- * Retrieves content from system clipboard (either from ClipboardEvent or
18
- * via async clipboard API if supported)
19
- */
20
- export declare const getSystemClipboard: (event: ClipboardEvent | null) => Promise<string>;
21
21
  /**
22
22
  * Attempts to parse clipboard. Prefers system clipboard.
23
23
  */
@@ -1,5 +1,5 @@
1
1
  import { ActionManager } from "../actions/manager";
2
- import { ExcalidrawElement, PointerType } from "../element/types";
2
+ import { ExcalidrawElement } from "../element/types";
3
3
  import { AppClassProperties, UIAppState, Zoom } from "../types";
4
4
  import "./Actions.scss";
5
5
  export declare const SelectedShapeActions: ({ appState, elements, renderAction, }: {
@@ -7,12 +7,8 @@ export declare const SelectedShapeActions: ({ appState, elements, renderAction,
7
7
  elements: readonly ExcalidrawElement[];
8
8
  renderAction: ActionManager["renderAction"];
9
9
  }) => import("react/jsx-runtime").JSX.Element;
10
- export declare const ShapesSwitcher: ({ interactiveCanvas, activeTool, onImageAction, appState, app, }: {
11
- interactiveCanvas: HTMLCanvasElement | null;
10
+ export declare const ShapesSwitcher: ({ activeTool, appState, app, }: {
12
11
  activeTool: UIAppState["activeTool"];
13
- onImageAction: (data: {
14
- pointerType: PointerType | null;
15
- }) => void;
16
12
  appState: UIAppState;
17
13
  app: AppClassProperties;
18
14
  }) => import("react/jsx-runtime").JSX.Element;
@@ -3,13 +3,14 @@ import { RoughCanvas } from "roughjs/bin/canvas";
3
3
  import { ActionManager } from "../actions/manager";
4
4
  import { EXPORT_IMAGE_TYPES } from "../constants";
5
5
  import { LinearElementEditor } from "../element/linearElementEditor";
6
- import { ExcalidrawElement, ExcalidrawLinearElement, NonDeletedExcalidrawElement } from "../element/types";
6
+ import { ExcalidrawElement, ExcalidrawLinearElement, NonDeleted, NonDeletedExcalidrawElement } from "../element/types";
7
7
  import History from "../history";
8
8
  import Scene from "../scene/Scene";
9
9
  import { AppClassProperties, AppProps, AppState, ExcalidrawImperativeAPI, BinaryFiles, LibraryItems, SceneData, Device, FrameNameBoundsCache, SidebarName, SidebarTabName, ToolType } from "../types";
10
10
  import { FileSystemHandle } from "../data/filesystem";
11
11
  import { Renderer } from "../scene/Renderer";
12
12
  import { LaserPathManager } from "./LaserTool/LaserPathManager";
13
+ import { Emitter } from "../emitter";
13
14
  export declare let showFourthFont: boolean;
14
15
  export declare const ExcalidrawContainerContext: React.Context<{
15
16
  container: HTMLDivElement | null;
@@ -64,6 +65,147 @@ declare class App extends React.Component<AppProps, AppState> {
64
65
  };
65
66
  allowMobileMode: boolean;
66
67
  laserPathManager: LaserPathManager;
68
+ onChangeEmitter: Emitter<[elements: readonly ExcalidrawElement[], appState: AppState, files: BinaryFiles]>;
69
+ onPointerDownEmitter: Emitter<[activeTool: {
70
+ lastActiveTool: import("../types").ActiveTool | null;
71
+ locked: boolean;
72
+ } & import("../types").ActiveTool, pointerDownState: Readonly<{
73
+ origin: Readonly<{
74
+ x: number;
75
+ y: number;
76
+ }>;
77
+ originInGrid: Readonly<{
78
+ x: number;
79
+ y: number;
80
+ }>;
81
+ scrollbars: {
82
+ isOverEither: boolean;
83
+ isOverHorizontal: boolean;
84
+ isOverVertical: boolean;
85
+ };
86
+ lastCoords: {
87
+ x: number;
88
+ y: number;
89
+ };
90
+ originalElements: Map<string, NonDeleted<ExcalidrawElement>>;
91
+ resize: {
92
+ handleType: import("../element/transformHandles").MaybeTransformHandleType;
93
+ isResizing: boolean;
94
+ offset: {
95
+ x: number;
96
+ y: number;
97
+ };
98
+ arrowDirection: "end" | "origin";
99
+ center: {
100
+ x: number;
101
+ y: number;
102
+ };
103
+ };
104
+ hit: {
105
+ element: NonDeleted<ExcalidrawElement> | null;
106
+ allHitElements: NonDeleted<ExcalidrawElement>[];
107
+ wasAddedToSelection: boolean;
108
+ hasBeenDuplicated: boolean;
109
+ hasHitCommonBoundingBoxOfSelectedElements: boolean;
110
+ };
111
+ withCmdOrCtrl: boolean;
112
+ drag: {
113
+ hasOccurred: boolean;
114
+ offset: {
115
+ x: number;
116
+ y: number;
117
+ } | null;
118
+ };
119
+ eventListeners: {
120
+ onMove: {
121
+ (...args: any[]): void;
122
+ flush(): void;
123
+ cancel(): void;
124
+ } | null;
125
+ onUp: ((event: PointerEvent) => void) | null;
126
+ onKeyDown: ((event: KeyboardEvent) => void) | null;
127
+ onKeyUp: ((event: KeyboardEvent) => void) | null;
128
+ };
129
+ boxSelection: {
130
+ hasOccurred: boolean;
131
+ };
132
+ elementIdsToErase: {
133
+ [key: string]: {
134
+ opacity: number;
135
+ erase: boolean;
136
+ };
137
+ };
138
+ }>, event: React.PointerEvent<HTMLElement>]>;
139
+ onPointerUpEmitter: Emitter<[activeTool: {
140
+ lastActiveTool: import("../types").ActiveTool | null;
141
+ locked: boolean;
142
+ } & import("../types").ActiveTool, pointerDownState: Readonly<{
143
+ origin: Readonly<{
144
+ x: number;
145
+ y: number;
146
+ }>;
147
+ originInGrid: Readonly<{
148
+ x: number;
149
+ y: number;
150
+ }>;
151
+ scrollbars: {
152
+ isOverEither: boolean;
153
+ isOverHorizontal: boolean;
154
+ isOverVertical: boolean;
155
+ };
156
+ lastCoords: {
157
+ x: number;
158
+ y: number;
159
+ };
160
+ originalElements: Map<string, NonDeleted<ExcalidrawElement>>;
161
+ resize: {
162
+ handleType: import("../element/transformHandles").MaybeTransformHandleType;
163
+ isResizing: boolean;
164
+ offset: {
165
+ x: number;
166
+ y: number;
167
+ };
168
+ arrowDirection: "end" | "origin";
169
+ center: {
170
+ x: number;
171
+ y: number;
172
+ };
173
+ };
174
+ hit: {
175
+ element: NonDeleted<ExcalidrawElement> | null;
176
+ allHitElements: NonDeleted<ExcalidrawElement>[];
177
+ wasAddedToSelection: boolean;
178
+ hasBeenDuplicated: boolean;
179
+ hasHitCommonBoundingBoxOfSelectedElements: boolean;
180
+ };
181
+ withCmdOrCtrl: boolean;
182
+ drag: {
183
+ hasOccurred: boolean;
184
+ offset: {
185
+ x: number;
186
+ y: number;
187
+ } | null;
188
+ };
189
+ eventListeners: {
190
+ onMove: {
191
+ (...args: any[]): void;
192
+ flush(): void;
193
+ cancel(): void;
194
+ } | null;
195
+ onUp: ((event: PointerEvent) => void) | null;
196
+ onKeyDown: ((event: KeyboardEvent) => void) | null;
197
+ onKeyUp: ((event: KeyboardEvent) => void) | null;
198
+ };
199
+ boxSelection: {
200
+ hasOccurred: boolean;
201
+ };
202
+ elementIdsToErase: {
203
+ [key: string]: {
204
+ opacity: number;
205
+ erase: boolean;
206
+ };
207
+ };
208
+ }>, event: PointerEvent]>;
67
209
  constructor(props: AppProps);
68
210
  private onWindowMessage;
69
211
  private updateEmbeddableRef;
@@ -120,6 +262,7 @@ declare class App extends React.Component<AppProps, AppState> {
120
262
  retainSeed?: boolean;
121
263
  fitToContent?: boolean;
122
264
  }) => void;
265
+ private addElementsFromMixedContentPaste;
123
266
  private addTextFromPaste;
124
267
  setAppState: React.Component<any, AppState>["setState"];
125
268
  removePointer: (event: React.PointerEvent<HTMLElement> | PointerEvent) => void;
@@ -192,11 +335,16 @@ declare class App extends React.Component<AppProps, AppState> {
192
335
  private onKeyDown;
193
336
  private onWheel;
194
337
  private onKeyUp;
195
- setActiveTool: (tool: {
196
- type: ToolType;
338
+ setActiveTool: (tool: (({
339
+ type: Exclude<ToolType, "image">;
197
340
  } | {
341
+ type: Extract<ToolType, "image">;
342
+ insertOnCanvasDirectly?: boolean;
343
+ }) | {
198
344
  type: "custom";
199
345
  customType: string;
346
+ }) & {
347
+ locked?: boolean;
200
348
  }) => void;
201
349
  private setCursor;
202
350
  private resetCursor;
@@ -10,7 +10,6 @@ interface LayerUIProps {
10
10
  appState: UIAppState;
11
11
  files: BinaryFiles;
12
12
  canvas: HTMLCanvasElement;
13
- interactiveCanvas: HTMLCanvasElement | null;
14
13
  setAppState: React.Component<any, AppState>["setState"];
15
14
  elements: readonly NonDeletedExcalidrawElement[];
16
15
  onLockToggle: () => void;
@@ -21,14 +20,11 @@ interface LayerUIProps {
21
20
  renderTopRightUI?: ExcalidrawProps["renderTopRightUI"];
22
21
  renderCustomStats?: ExcalidrawProps["renderCustomStats"];
23
22
  UIOptions: AppProps["UIOptions"];
24
- onImageAction: (data: {
25
- insertOnCanvasDirectly: boolean;
26
- }) => void;
27
23
  onExportImage: AppClassProperties["onExportImage"];
28
24
  renderWelcomeScreen: boolean;
29
25
  children?: React.ReactNode;
30
26
  app: AppClassProperties;
31
27
  isCollaborating: boolean;
32
28
  }
33
- declare const _default: React.MemoExoticComponent<({ actionManager, appState, files, setAppState, elements, canvas, interactiveCanvas, onLockToggle, onHandToolToggle, onPenModeToggle, showExitZenModeBtn, renderTopRightUI, renderCustomStats, UIOptions, onImageAction, onExportImage, renderWelcomeScreen, children, app, isCollaborating, }: LayerUIProps) => import("react/jsx-runtime").JSX.Element>;
29
+ declare const _default: React.MemoExoticComponent<({ actionManager, appState, files, setAppState, elements, canvas, onLockToggle, onHandToolToggle, onPenModeToggle, showExitZenModeBtn, renderTopRightUI, renderCustomStats, UIOptions, onExportImage, renderWelcomeScreen, children, app, isCollaborating, }: LayerUIProps) => import("react/jsx-runtime").JSX.Element>;
34
30
  export default _default;
@@ -12,10 +12,6 @@ type MobileMenuProps = {
12
12
  onLockToggle: () => void;
13
13
  onHandToolToggle: () => void;
14
14
  onPenModeToggle: () => void;
15
- interactiveCanvas: HTMLCanvasElement | null;
16
- onImageAction: (data: {
17
- insertOnCanvasDirectly: boolean;
18
- }) => void;
19
15
  renderTopRightUI?: (isMobile: boolean, appState: UIAppState) => JSX.Element | null;
20
16
  renderCustomStats?: ExcalidrawProps["renderCustomStats"];
21
17
  renderSidebars: () => JSX.Element | null;
@@ -23,5 +19,5 @@ type MobileMenuProps = {
23
19
  renderWelcomeScreen: boolean;
24
20
  app: AppClassProperties;
25
21
  };
26
- export declare const MobileMenu: ({ appState, elements, actionManager, setAppState, onLockToggle, onHandToolToggle, onPenModeToggle, interactiveCanvas, onImageAction, renderTopRightUI, renderCustomStats, renderSidebars, device, renderWelcomeScreen, app, }: MobileMenuProps) => import("react/jsx-runtime").JSX.Element;
22
+ export declare const MobileMenu: ({ appState, elements, actionManager, setAppState, onLockToggle, onHandToolToggle, onPenModeToggle, renderTopRightUI, renderCustomStats, renderSidebars, device, renderWelcomeScreen, app, }: MobileMenuProps) => import("react/jsx-runtime").JSX.Element;
27
23
  export {};
@@ -217,6 +217,11 @@ export declare const PRECEDING_ELEMENT_KEY = "__precedingElement__";
217
217
  export declare const COLOR_NAMES: {
218
218
  [key: string]: string;
219
219
  };
220
+ export declare const ROUGHNESS: {
221
+ readonly architect: 0;
222
+ readonly artist: 1;
223
+ readonly cartoonist: 2;
224
+ };
220
225
  export declare const DEFAULT_ELEMENT_PROPS: {
221
226
  strokeColor: ExcalidrawElement["strokeColor"];
222
227
  backgroundColor: ExcalidrawElement["backgroundColor"];
@@ -0,0 +1,5 @@
1
+ import { AppState } from "./types";
2
+ export declare const resetCursor: (interactiveCanvas: HTMLCanvasElement | null) => void;
3
+ export declare const setCursor: (interactiveCanvas: HTMLCanvasElement | null, cursor: string) => void;
4
+ export declare const setEraserCursor: (interactiveCanvas: HTMLCanvasElement | null, theme: AppState["theme"]) => void;
5
+ export declare const setCursorForShape: (interactiveCanvas: HTMLCanvasElement | null, appState: Pick<AppState, "activeTool" | "theme">) => void;
@@ -21,7 +21,7 @@ export declare const loadSceneOrLibraryFromBlob: (blob: Blob | File, localAppSta
21
21
  export declare const loadFromBlob: (blob: Blob, localAppState: AppState | null, localElements: readonly ExcalidrawElement[] | null, fileHandle?: FileSystemHandle | null) => Promise<import("./restore").RestoredDataState>;
22
22
  export declare const parseLibraryJSON: (json: string, defaultStatus?: LibraryItem["status"]) => LibraryItem[];
23
23
  export declare const loadLibraryFromBlob: (blob: Blob, defaultStatus?: LibraryItem["status"]) => Promise<LibraryItem[]>;
24
- export declare const canvasToBlob: (canvas: HTMLCanvasElement) => Promise<Blob>;
24
+ export declare const canvasToBlob: (canvas: HTMLCanvasElement | Promise<HTMLCanvasElement>) => Promise<Blob>;
25
25
  /** generates SHA-1 digest from supplied file (if not supported, falls back
26
26
  to a 40-char base64 random id) */
27
27
  export declare const generateIdFromFile: (file: File) => Promise<FileId>;
@@ -35,6 +35,7 @@ export declare const resizeImageFile: (file: File, opts: {
35
35
  export declare const SVGStringToFile: (SVGString: string, filename?: string) => File & {
36
36
  type: typeof MIME_TYPES.svg;
37
37
  };
38
+ export declare const ImageURLToFile: (imageUrl: string, filename?: string) => Promise<File | undefined>;
38
39
  export declare const getFileFromEvent: (event: React.DragEvent<HTMLDivElement>) => Promise<{
39
40
  file: File | null;
40
41
  fileHandle: FileSystemHandle | null;
@@ -8,5 +8,5 @@ export declare const newElementWith: <TElement extends ExcalidrawElement>(elemen
8
8
  *
9
9
  * NOTE: does not trigger re-render.
10
10
  */
11
- export declare const bumpVersion: (element: Mutable<ExcalidrawElement>, version?: ExcalidrawElement["version"]) => Mutable<ExcalidrawElement>;
11
+ export declare const bumpVersion: <T extends Mutable<ExcalidrawElement>>(element: T, version?: ExcalidrawElement["version"]) => T;
12
12
  export {};
@@ -0,0 +1,20 @@
1
+ type Subscriber<T extends any[]> = (...payload: T) => void;
2
+ export declare class Emitter<T extends any[] = []> {
3
+ subscribers: Subscriber<T>[];
4
+ value: T | undefined;
5
+ private updateOnChangeOnly;
6
+ constructor(opts?: {
7
+ initialState?: T;
8
+ updateOnChangeOnly?: boolean;
9
+ });
10
+ /**
11
+ * Attaches subscriber
12
+ *
13
+ * @returns unsubscribe function
14
+ */
15
+ on(...handlers: Subscriber<T>[] | Subscriber<T>[][]): () => void;
16
+ off(...handlers: Subscriber<T>[] | Subscriber<T>[][]): void;
17
+ trigger(...payload: T): any[];
18
+ destroy(): void;
19
+ }
20
+ export {};
package/types/frame.d.ts CHANGED
@@ -17,10 +17,18 @@ export declare const groupsAreCompletelyOutOfFrame: (elements: readonly NonDelet
17
17
  * Returns a map of frameId to frame elements. Includes empty frames.
18
18
  */
19
19
  export declare const groupByFrames: (elements: readonly ExcalidrawElement[]) => Map<string, ExcalidrawElement[]>;
20
- export declare const getFrameElements: (allElements: ExcalidrawElementsIncludingDeleted, frameId: string) => ExcalidrawElement[];
20
+ export declare const getFrameElements: (allElements: ExcalidrawElementsIncludingDeleted, frameId: string, opts?: {
21
+ includeBoundArrows?: boolean;
22
+ }) => ExcalidrawElement[];
21
23
  export declare const getElementsInResizingFrame: (allElements: ExcalidrawElementsIncludingDeleted, frame: ExcalidrawFrameElement, appState: AppState) => ExcalidrawElement[];
22
24
  export declare const getElementsInNewFrame: (allElements: ExcalidrawElementsIncludingDeleted, frame: ExcalidrawFrameElement) => ExcalidrawElement[];
23
25
  export declare const getContainingFrame: (element: ExcalidrawElement, elementsMap?: Map<string, ExcalidrawElement>) => ExcalidrawFrameElement | null;
26
+ export declare const isValidFrameChild: (element: ExcalidrawElement) => boolean;
27
+ /**
28
+ * Retains (or repairs for target frame) the ordering invriant where children
29
+ * elements come right before the parent frame:
30
+ * [el, el, child, child, frame, el]
31
+ */
24
32
  export declare const addElementsToFrame: (allElements: ExcalidrawElementsIncludingDeleted, elementsToAdd: NonDeletedExcalidrawElement[], frame: ExcalidrawFrameElement) => ExcalidrawElement[];
25
33
  export declare const removeElementsFromFrame: (allElements: ExcalidrawElementsIncludingDeleted, elementsToRemove: NonDeletedExcalidrawElement[], appState: AppState) => ExcalidrawElement[];
26
34
  export declare const removeAllElementsFromFrame: (allElements: ExcalidrawElementsIncludingDeleted, frame: ExcalidrawFrameElement, appState: AppState) => ExcalidrawElement[];
package/types/types.d.ts CHANGED
@@ -498,6 +498,7 @@ export type PointerDownState = Readonly<{
498
498
  };
499
499
  };
500
500
  }>;
501
+ type UnsubscribeCallback = () => void;
501
502
  export type ExcalidrawImperativeAPI = {
502
503
  updateScene: InstanceType<typeof App>["updateScene"];
503
504
  updateLibrary: InstanceType<typeof Library>["updateLibrary"];
@@ -537,6 +538,9 @@ export type ExcalidrawImperativeAPI = {
537
538
  * used in conjunction with view mode (props.viewModeEnabled).
538
539
  */
539
540
  updateFrameRendering: InstanceType<typeof App>["updateFrameRendering"];
541
+ onChange: (callback: (elements: readonly ExcalidrawElement[], appState: AppState, files: BinaryFiles) => void) => UnsubscribeCallback;
542
+ onPointerDown: (callback: (activeTool: AppState["activeTool"], pointerDownState: PointerDownState, event: React.PointerEvent<HTMLElement>) => void) => UnsubscribeCallback;
543
+ onPointerUp: (callback: (activeTool: AppState["activeTool"], pointerDownState: PointerDownState, event: PointerEvent) => void) => UnsubscribeCallback;
540
544
  };
541
545
  export type Device = Readonly<{
542
546
  isSmScreen: boolean;
package/types/utils.d.ts CHANGED
@@ -79,18 +79,16 @@ export declare const chunk: <T extends unknown>(array: readonly T[], size: numbe
79
79
  export declare const selectNode: (node: Element) => void;
80
80
  export declare const removeSelection: () => void;
81
81
  export declare const distance: (x: number, y: number) => number;
82
- export declare const updateActiveTool: (appState: Pick<AppState, "activeTool">, data: ({
82
+ export declare const updateActiveTool: (appState: Pick<AppState, "activeTool">, data: (({
83
83
  type: ToolType;
84
84
  } | {
85
85
  type: "custom";
86
86
  customType: string;
87
+ }) & {
88
+ locked?: boolean;
87
89
  }) & {
88
90
  lastActiveToolBeforeEraser?: ActiveTool | null;
89
91
  }) => AppState["activeTool"];
90
- export declare const resetCursor: (interactiveCanvas: HTMLCanvasElement | null) => void;
91
- export declare const setCursor: (interactiveCanvas: HTMLCanvasElement | null, cursor: string) => void;
92
- export declare const setEraserCursor: (interactiveCanvas: HTMLCanvasElement | null, theme: AppState["theme"]) => void;
93
- export declare const setCursorForShape: (interactiveCanvas: HTMLCanvasElement | null, appState: Pick<AppState, "activeTool" | "theme">) => void;
94
92
  export declare const isFullScreen: () => boolean;
95
93
  export declare const allowFullScreen: () => Promise<void>;
96
94
  export declare const exitFullScreen: () => Promise<void>;