@excalidraw/excalidraw 0.16.1-6920-3a6028b → 0.16.1-6920-d3d0bd0

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": "@excalidraw/excalidraw",
3
- "version": "0.16.1-6920-3a6028b",
3
+ "version": "0.16.1-6920-d3d0bd0",
4
4
  "main": "main.js",
5
5
  "types": "types/packages/excalidraw/index.d.ts",
6
6
  "files": [
@@ -3,10 +3,132 @@ export declare const actionCopy: {
3
3
  trackEvent: {
4
4
  category: "element";
5
5
  };
6
- perform: (elements: readonly import("../element/types").ExcalidrawElement[], appState: Readonly<import("../types").AppState>, _: any, app: import("../types").AppClassProperties) => {
6
+ perform: (elements: readonly import("../element/types").ExcalidrawElement[], appState: Readonly<import("../types").AppState>, event: ClipboardEvent | null, app: import("../types").AppClassProperties) => Promise<{
7
7
  commitToHistory: false;
8
- };
9
- predicate: (elements: readonly import("../element/types").ExcalidrawElement[], appState: import("../types").AppState, appProps: import("../types").ExcalidrawProps, app: import("../types").AppClassProperties) => boolean;
8
+ appState: {
9
+ errorMessage: any;
10
+ contextMenu: {
11
+ items: import("../components/ContextMenu").ContextMenuItems;
12
+ top: number;
13
+ left: number;
14
+ } | null;
15
+ showWelcomeScreen: boolean;
16
+ isLoading: boolean;
17
+ activeEmbeddable: {
18
+ element: import("../element/types").NonDeletedExcalidrawElement;
19
+ state: "active" | "hover";
20
+ } | null;
21
+ draggingElement: import("../element/types").NonDeletedExcalidrawElement | null;
22
+ resizingElement: import("../element/types").NonDeletedExcalidrawElement | null;
23
+ multiElement: import("../element/types").NonDeleted<import("../element/types").ExcalidrawLinearElement> | null;
24
+ selectionElement: import("../element/types").NonDeletedExcalidrawElement | null;
25
+ isBindingEnabled: boolean;
26
+ startBoundElement: import("../element/types").NonDeleted<import("../element/types").ExcalidrawBindableElement> | null;
27
+ suggestedBindings: import("../element/binding").SuggestedBinding[];
28
+ frameToHighlight: import("../element/types").NonDeleted<import("../element/types").ExcalidrawFrameElement> | null;
29
+ frameRendering: {
30
+ enabled: boolean;
31
+ name: boolean;
32
+ outline: boolean;
33
+ clip: boolean;
34
+ };
35
+ editingFrame: string | null;
36
+ elementsToHighlight: import("../element/types").NonDeleted<import("../element/types").ExcalidrawElement>[] | null;
37
+ editingElement: import("../element/types").NonDeletedExcalidrawElement | null;
38
+ editingLinearElement: import("../element/linearElementEditor").LinearElementEditor | null;
39
+ activeTool: {
40
+ lastActiveTool: import("../types").ActiveTool | null;
41
+ locked: boolean;
42
+ } & import("../types").ActiveTool;
43
+ penMode: boolean;
44
+ penDetected: boolean;
45
+ exportBackground: boolean;
46
+ exportEmbedScene: boolean;
47
+ exportWithDarkMode: boolean;
48
+ exportScale: number;
49
+ currentItemStrokeColor: string;
50
+ currentItemBackgroundColor: string;
51
+ currentItemFillStyle: import("../element/types").FillStyle;
52
+ currentItemStrokeWidth: number;
53
+ currentItemStrokeStyle: import("../element/types").StrokeStyle;
54
+ currentItemRoughness: number;
55
+ currentItemOpacity: number;
56
+ currentItemFontFamily: number;
57
+ currentItemFontSize: number;
58
+ currentItemTextAlign: string;
59
+ currentItemStartArrowhead: import("../element/types").Arrowhead | null;
60
+ currentItemEndArrowhead: import("../element/types").Arrowhead | null;
61
+ currentItemRoundness: import("../element/types").StrokeRoundness;
62
+ viewBackgroundColor: string;
63
+ scrollX: number;
64
+ scrollY: number;
65
+ cursorButton: "up" | "down";
66
+ scrolledOutside: boolean;
67
+ name: string;
68
+ isResizing: boolean;
69
+ isRotating: boolean;
70
+ zoom: Readonly<{
71
+ value: import("../types").NormalizedZoomValue;
72
+ }>;
73
+ openMenu: "canvas" | "shape" | null;
74
+ openPopup: "canvasBackground" | "elementBackground" | "elementStroke" | null;
75
+ openSidebar: {
76
+ name: string;
77
+ tab?: string | undefined;
78
+ } | null;
79
+ openDialog: "mermaid" | "imageExport" | "help" | "jsonExport" | null;
80
+ defaultSidebarDockedPreference: boolean;
81
+ lastPointerDownWith: import("../element/types").PointerType;
82
+ selectedElementIds: Readonly<{
83
+ [id: string]: true;
84
+ }>;
85
+ previousSelectedElementIds: {
86
+ [id: string]: true;
87
+ };
88
+ selectedElementsAreBeingDragged: boolean;
89
+ shouldCacheIgnoreZoom: boolean;
90
+ toast: {
91
+ message: string;
92
+ closable?: boolean | undefined;
93
+ duration?: number | undefined;
94
+ } | null;
95
+ zenModeEnabled: boolean;
96
+ theme: import("../element/types").Theme;
97
+ gridSize: number | null;
98
+ viewModeEnabled: boolean;
99
+ selectedGroupIds: {
100
+ [groupId: string]: boolean;
101
+ };
102
+ editingGroupId: string | null;
103
+ width: number;
104
+ height: number;
105
+ offsetTop: number;
106
+ offsetLeft: number;
107
+ fileHandle: import("browser-fs-access").FileSystemHandle | null;
108
+ collaborators: Map<string, import("../types").Collaborator>;
109
+ showStats: boolean;
110
+ currentChartType: import("../element/types").ChartType;
111
+ pasteDialog: {
112
+ shown: false;
113
+ data: null;
114
+ } | {
115
+ shown: true;
116
+ data: import("../charts").Spreadsheet;
117
+ };
118
+ pendingImageElementId: string | null;
119
+ showHyperlinkPopup: false | "editor" | "info";
120
+ selectedLinearElement: import("../element/linearElementEditor").LinearElementEditor | null;
121
+ snapLines: readonly import("../snapping").SnapLine[];
122
+ originSnapOffset: {
123
+ x: number;
124
+ y: number;
125
+ } | null;
126
+ objectsSnapModeEnabled: boolean;
127
+ };
128
+ } | {
129
+ commitToHistory: false;
130
+ appState?: undefined;
131
+ }>;
10
132
  contextItemLabel: string;
11
133
  keyTest: undefined;
12
134
  } & {
@@ -17,10 +139,132 @@ export declare const actionPaste: {
17
139
  trackEvent: {
18
140
  category: "element";
19
141
  };
20
- perform: (elements: any, appStates: any, data: any, app: import("../types").AppClassProperties) => {
142
+ perform: (elements: readonly import("../element/types").ExcalidrawElement[], appState: Readonly<import("../types").AppState>, data: any, app: import("../types").AppClassProperties) => Promise<false | {
21
143
  commitToHistory: false;
22
- };
23
- predicate: (elements: readonly import("../element/types").ExcalidrawElement[], appState: import("../types").AppState, appProps: import("../types").ExcalidrawProps, app: import("../types").AppClassProperties) => boolean;
144
+ appState: {
145
+ errorMessage: string;
146
+ contextMenu: {
147
+ items: import("../components/ContextMenu").ContextMenuItems;
148
+ top: number;
149
+ left: number;
150
+ } | null;
151
+ showWelcomeScreen: boolean;
152
+ isLoading: boolean;
153
+ activeEmbeddable: {
154
+ element: import("../element/types").NonDeletedExcalidrawElement;
155
+ state: "active" | "hover";
156
+ } | null;
157
+ draggingElement: import("../element/types").NonDeletedExcalidrawElement | null;
158
+ resizingElement: import("../element/types").NonDeletedExcalidrawElement | null;
159
+ multiElement: import("../element/types").NonDeleted<import("../element/types").ExcalidrawLinearElement> | null;
160
+ selectionElement: import("../element/types").NonDeletedExcalidrawElement | null;
161
+ isBindingEnabled: boolean;
162
+ startBoundElement: import("../element/types").NonDeleted<import("../element/types").ExcalidrawBindableElement> | null;
163
+ suggestedBindings: import("../element/binding").SuggestedBinding[];
164
+ frameToHighlight: import("../element/types").NonDeleted<import("../element/types").ExcalidrawFrameElement> | null;
165
+ frameRendering: {
166
+ enabled: boolean;
167
+ name: boolean;
168
+ outline: boolean;
169
+ clip: boolean;
170
+ };
171
+ editingFrame: string | null;
172
+ elementsToHighlight: import("../element/types").NonDeleted<import("../element/types").ExcalidrawElement>[] | null;
173
+ editingElement: import("../element/types").NonDeletedExcalidrawElement | null;
174
+ editingLinearElement: import("../element/linearElementEditor").LinearElementEditor | null;
175
+ activeTool: {
176
+ lastActiveTool: import("../types").ActiveTool | null;
177
+ locked: boolean;
178
+ } & import("../types").ActiveTool;
179
+ penMode: boolean;
180
+ penDetected: boolean;
181
+ exportBackground: boolean;
182
+ exportEmbedScene: boolean;
183
+ exportWithDarkMode: boolean;
184
+ exportScale: number;
185
+ currentItemStrokeColor: string;
186
+ currentItemBackgroundColor: string;
187
+ currentItemFillStyle: import("../element/types").FillStyle;
188
+ currentItemStrokeWidth: number;
189
+ currentItemStrokeStyle: import("../element/types").StrokeStyle;
190
+ currentItemRoughness: number;
191
+ currentItemOpacity: number;
192
+ currentItemFontFamily: number;
193
+ currentItemFontSize: number;
194
+ currentItemTextAlign: string;
195
+ currentItemStartArrowhead: import("../element/types").Arrowhead | null;
196
+ currentItemEndArrowhead: import("../element/types").Arrowhead | null;
197
+ currentItemRoundness: import("../element/types").StrokeRoundness;
198
+ viewBackgroundColor: string;
199
+ scrollX: number;
200
+ scrollY: number;
201
+ cursorButton: "up" | "down";
202
+ scrolledOutside: boolean;
203
+ name: string;
204
+ isResizing: boolean;
205
+ isRotating: boolean;
206
+ zoom: Readonly<{
207
+ value: import("../types").NormalizedZoomValue;
208
+ }>;
209
+ openMenu: "canvas" | "shape" | null;
210
+ openPopup: "canvasBackground" | "elementBackground" | "elementStroke" | null;
211
+ openSidebar: {
212
+ name: string;
213
+ tab?: string | undefined;
214
+ } | null;
215
+ openDialog: "mermaid" | "imageExport" | "help" | "jsonExport" | null;
216
+ defaultSidebarDockedPreference: boolean;
217
+ lastPointerDownWith: import("../element/types").PointerType;
218
+ selectedElementIds: Readonly<{
219
+ [id: string]: true;
220
+ }>;
221
+ previousSelectedElementIds: {
222
+ [id: string]: true;
223
+ };
224
+ selectedElementsAreBeingDragged: boolean;
225
+ shouldCacheIgnoreZoom: boolean;
226
+ toast: {
227
+ message: string;
228
+ closable?: boolean | undefined;
229
+ duration?: number | undefined;
230
+ } | null;
231
+ zenModeEnabled: boolean;
232
+ theme: import("../element/types").Theme;
233
+ gridSize: number | null;
234
+ viewModeEnabled: boolean;
235
+ selectedGroupIds: {
236
+ [groupId: string]: boolean;
237
+ };
238
+ editingGroupId: string | null;
239
+ width: number;
240
+ height: number;
241
+ offsetTop: number;
242
+ offsetLeft: number;
243
+ fileHandle: import("browser-fs-access").FileSystemHandle | null;
244
+ collaborators: Map<string, import("../types").Collaborator>;
245
+ showStats: boolean;
246
+ currentChartType: import("../element/types").ChartType;
247
+ pasteDialog: {
248
+ shown: false;
249
+ data: null;
250
+ } | {
251
+ shown: true;
252
+ data: import("../charts").Spreadsheet;
253
+ };
254
+ pendingImageElementId: string | null;
255
+ showHyperlinkPopup: false | "editor" | "info";
256
+ selectedLinearElement: import("../element/linearElementEditor").LinearElementEditor | null;
257
+ snapLines: readonly import("../snapping").SnapLine[];
258
+ originSnapOffset: {
259
+ x: number;
260
+ y: number;
261
+ } | null;
262
+ objectsSnapModeEnabled: boolean;
263
+ };
264
+ } | {
265
+ commitToHistory: false;
266
+ appState?: undefined;
267
+ }>;
24
268
  contextItemLabel: string;
25
269
  keyTest: undefined;
26
270
  } & {
@@ -31,7 +275,7 @@ export declare const actionCut: {
31
275
  trackEvent: {
32
276
  category: "element";
33
277
  };
34
- perform: (elements: readonly import("../element/types").ExcalidrawElement[], appState: Readonly<import("../types").AppState>, data: any, app: import("../types").AppClassProperties) => false | {
278
+ perform: (elements: readonly import("../element/types").ExcalidrawElement[], appState: Readonly<import("../types").AppState>, event: ClipboardEvent | null, app: import("../types").AppClassProperties) => false | {
35
279
  elements: import("../element/types").ExcalidrawElement[];
36
280
  appState: {
37
281
  editingLinearElement: null;
@@ -422,7 +666,6 @@ export declare const actionCut: {
422
666
  };
423
667
  commitToHistory: boolean;
424
668
  };
425
- predicate: (elements: readonly import("../element/types").ExcalidrawElement[], appState: import("../types").AppState, appProps: import("../types").ExcalidrawProps, app: import("../types").AppClassProperties) => boolean;
426
669
  contextItemLabel: string;
427
670
  keyTest: (event: import("react").KeyboardEvent<Element> | KeyboardEvent) => boolean;
428
671
  } & {
@@ -12,7 +12,7 @@ export declare class ActionManager {
12
12
  registerAction(action: Action): void;
13
13
  registerAll(actions: readonly Action[]): void;
14
14
  handleKeyDown(event: React.KeyboardEvent | KeyboardEvent): boolean;
15
- executeAction(action: Action, source?: ActionSource, value?: any): void;
15
+ executeAction<T extends Action>(action: T, source?: ActionSource, value?: Parameters<T["perform"]>[2]): void;
16
16
  /**
17
17
  * @param data additional data sent to the PanelComponent
18
18
  */
@@ -1,6 +1,7 @@
1
1
  import { ExcalidrawElement, NonDeletedExcalidrawElement } from "./element/types";
2
2
  import { BinaryFiles } from "./types";
3
3
  import { Spreadsheet } from "./charts";
4
+ import { ALLOWED_PASTE_MIME_TYPES } from "./constants";
4
5
  export type PastedMixedContent = {
5
6
  type: "text" | "imageUrl";
6
7
  value: string;
@@ -14,13 +15,30 @@ export interface ClipboardData {
14
15
  errorMessage?: string;
15
16
  programmaticAPI?: boolean;
16
17
  }
18
+ type AllowedPasteMimeTypes = typeof ALLOWED_PASTE_MIME_TYPES[number];
17
19
  export declare const probablySupportsClipboardReadText: boolean;
18
20
  export declare const probablySupportsClipboardWriteText: boolean;
19
21
  export declare const probablySupportsClipboardBlob: boolean;
20
- export declare const copyToClipboard: (elements: readonly NonDeletedExcalidrawElement[], files: BinaryFiles | null) => Promise<string | undefined>;
22
+ export declare const createPasteEvent: ({ types, files, }: {
23
+ types?: {
24
+ "text/plain"?: string | undefined;
25
+ "text/html"?: string | undefined;
26
+ } | undefined;
27
+ files?: File[] | undefined;
28
+ }) => ClipboardEvent;
29
+ export declare const serializeAsClipboardJSON: ({ elements, files, }: {
30
+ elements: readonly NonDeletedExcalidrawElement[];
31
+ files: BinaryFiles | null;
32
+ }) => string;
33
+ export declare const copyToClipboard: (elements: readonly NonDeletedExcalidrawElement[], files: BinaryFiles | null, clipboardEvent?: ClipboardEvent | null) => Promise<void>;
34
+ export declare const readSystemClipboard: () => Promise<{
35
+ "text/plain"?: string | undefined;
36
+ "text/html"?: string | undefined;
37
+ }>;
21
38
  /**
22
39
  * Attempts to parse clipboard. Prefers system clipboard.
23
40
  */
24
- export declare const parseClipboard: (event: ClipboardEvent | null, isPlainPaste?: boolean) => Promise<ClipboardData>;
41
+ export declare const parseClipboard: (event: ClipboardEvent, isPlainPaste?: boolean) => Promise<ClipboardData>;
25
42
  export declare const copyBlobToClipboardAsPng: (blob: Blob | Promise<Blob>) => Promise<void>;
26
- export declare const copyTextToSystemClipboard: (text: string | null) => Promise<void>;
43
+ export declare const copyTextToSystemClipboard: (text: string | null, clipboardEvent?: ClipboardEvent | null) => Promise<void>;
44
+ export {};
@@ -244,12 +244,10 @@ declare class App extends React.Component<AppProps, AppState> {
244
244
  private onScroll;
245
245
  private onCut;
246
246
  private onCopy;
247
- private cutAll;
248
- private copyAll;
249
247
  private static resetTapTwice;
250
248
  private onTouchStart;
251
249
  private onTouchEnd;
252
- pasteFromClipboard: (event: ClipboardEvent | null) => Promise<void>;
250
+ pasteFromClipboard: (event: ClipboardEvent) => Promise<void>;
253
251
  addElementsFromPasteOrLibrary: (opts: {
254
252
  elements: readonly ExcalidrawElement[];
255
253
  files: BinaryFiles | null;
@@ -9,7 +9,8 @@ type ContextMenuProps = {
9
9
  items: ContextMenuItems;
10
10
  top: number;
11
11
  left: number;
12
+ onClose: (callback?: () => void) => void;
12
13
  };
13
14
  export declare const CONTEXT_MENU_SEPARATOR = "separator";
14
- export declare const ContextMenu: React.MemoExoticComponent<({ actionManager, items, top, left }: ContextMenuProps) => JSX.Element>;
15
+ export declare const ContextMenu: React.MemoExoticComponent<({ actionManager, items, top, left, onClose }: ContextMenuProps) => JSX.Element>;
15
16
  export {};
@@ -122,6 +122,7 @@ export declare const IMAGE_MIME_TYPES: {
122
122
  readonly avif: "image/avif";
123
123
  readonly jfif: "image/jfif";
124
124
  };
125
+ export declare const ALLOWED_PASTE_MIME_TYPES: readonly ["text/plain", "text/html"];
125
126
  export declare const MIME_TYPES: {
126
127
  readonly svg: "image/svg+xml";
127
128
  readonly png: "image/png";
@@ -52,7 +52,7 @@ export type ValidContainer = {
52
52
  verticalAlign?: VerticalAlign;
53
53
  } & MarkOptional<ElementConstructorOpts, "x" | "y">;
54
54
  } & ElementConstructorOpts;
55
- export type ExcalidrawElementSkeleton = Extract<Exclude<ExcalidrawElement, ExcalidrawSelectionElement>, ExcalidrawEmbeddableElement | ExcalidrawFreeDrawElement | ExcalidrawFrameElement> | ({
55
+ export type ExcalidrawElementSkeleton = Extract<Exclude<ExcalidrawElement, ExcalidrawSelectionElement>, ExcalidrawEmbeddableElement | ExcalidrawFreeDrawElement> | ({
56
56
  type: Extract<ExcalidrawLinearElement["type"], "line">;
57
57
  x: number;
58
58
  y: number;
@@ -67,7 +67,11 @@ export type ExcalidrawElementSkeleton = Extract<Exclude<ExcalidrawElement, Excal
67
67
  x: number;
68
68
  y: number;
69
69
  fileId: FileId;
70
- } & Partial<ExcalidrawImageElement>);
70
+ } & Partial<ExcalidrawImageElement>) | ({
71
+ type: "frame";
72
+ children: readonly ExcalidrawElement["id"][];
73
+ name?: string;
74
+ } & Partial<ExcalidrawFrameElement>);
71
75
  export declare const convertToExcalidrawElements: (elementsSkeleton: ExcalidrawElementSkeleton[] | null, opts?: {
72
76
  regenerateIds: boolean;
73
77
  }) => ExcalidrawElement[];
@@ -9,7 +9,9 @@ export declare const newEmbeddableElement: (opts: {
9
9
  type: "embeddable";
10
10
  validated: ExcalidrawEmbeddableElement["validated"];
11
11
  } & ElementConstructorOpts) => NonDeleted<ExcalidrawEmbeddableElement>;
12
- export declare const newFrameElement: (opts: ElementConstructorOpts) => NonDeleted<ExcalidrawFrameElement>;
12
+ export declare const newFrameElement: (opts: {
13
+ name?: string;
14
+ } & ElementConstructorOpts) => NonDeleted<ExcalidrawFrameElement>;
13
15
  export declare const newTextElement: (opts: {
14
16
  text: string;
15
17
  fontSize?: number;
@@ -1,7 +1,6 @@
1
1
  import { NonDeletedExcalidrawElement } from "../element/types";
2
2
  import { AppState, BinaryFiles } from "../types";
3
3
  import { serializeAsJSON } from "../data/json";
4
- export declare const SVG_EXPORT_TAG = "<!-- svg-source:excalidraw -->";
5
4
  export declare const exportToCanvas: (elements: readonly NonDeletedExcalidrawElement[], appState: AppState, files: BinaryFiles, { exportBackground, exportPadding, viewBackgroundColor, }: {
6
5
  exportBackground: boolean;
7
6
  exportPadding?: number | undefined;
package/types/utils.d.ts CHANGED
@@ -195,3 +195,5 @@ export declare const memoize: <T extends Record<string, any>, R extends unknown>
195
195
  clear: () => void;
196
196
  };
197
197
  export declare const isRenderThrottlingEnabled: () => boolean;
198
+ /** Checks if value is inside given collection. Useful for type-safety. */
199
+ export declare const isMemberOf: <T extends string>(collection: Set<T> | Record<T, any> | Map<T, any> | readonly T[], value: string) => value is T;