@dwelle/excalidraw 0.3.56 → 0.3.59-restoreLibraryItems

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/CHANGELOG.md +15 -1
  2. package/README_NEXT.md +18 -0
  3. package/dist/excalidraw.development.js +44 -44
  4. package/dist/excalidraw.production.min.js +1 -1
  5. package/package.json +1 -1
  6. package/types/actions/actionAddToLibrary.d.ts +9 -3
  7. package/types/actions/actionAlign.d.ts +18 -0
  8. package/types/actions/actionBoundText.d.ts +8 -1
  9. package/types/actions/actionCanvas.d.ts +42 -9
  10. package/types/actions/actionClipboard.d.ts +22 -5
  11. package/types/actions/actionDeleteSelected.d.ts +10 -3
  12. package/types/actions/actionDistribute.d.ts +6 -0
  13. package/types/actions/actionDuplicateSelection.d.ts +3 -0
  14. package/types/actions/actionExport.d.ts +44 -9
  15. package/types/actions/actionFinalize.d.ts +5 -2
  16. package/types/actions/actionFlip.d.ts +6 -0
  17. package/types/actions/actionGroup.d.ts +6 -0
  18. package/types/actions/actionMenu.d.ts +20 -3
  19. package/types/actions/actionNavigate.d.ts +3 -0
  20. package/types/actions/actionProperties.d.ts +43 -13
  21. package/types/actions/actionSelectAll.d.ts +3 -0
  22. package/types/actions/actionStyles.d.ts +8 -1
  23. package/types/actions/actionToggleGridMode.d.ts +6 -1
  24. package/types/actions/actionToggleStats.d.ts +5 -1
  25. package/types/actions/actionToggleViewMode.d.ts +6 -1
  26. package/types/actions/actionToggleZenMode.d.ts +6 -1
  27. package/types/actions/actionZindex.d.ts +12 -0
  28. package/types/actions/manager.d.ts +3 -3
  29. package/types/actions/types.d.ts +6 -8
  30. package/types/appState.d.ts +2 -1
  31. package/types/components/App.d.ts +1 -1
  32. package/types/components/ImageExportDialog.d.ts +2 -2
  33. package/types/components/JSONExportDialog.d.ts +2 -2
  34. package/types/data/library.d.ts +1 -2
  35. package/types/element/Hyperlink.d.ts +6 -2
  36. package/types/element/linearElementEditor.d.ts +2 -1
  37. package/types/packages/excalidraw/index.d.ts +1 -1
  38. package/types/scene/Scene.d.ts +1 -1
  39. package/types/types.d.ts +3 -1
  40. package/types/utils.d.ts +2 -0
@@ -2,6 +2,10 @@
2
2
  import { AppState } from "../types";
3
3
  export declare const actionToggleGridMode: {
4
4
  name: "gridMode";
5
+ trackEvent: {
6
+ category: "canvas";
7
+ predicate: (appState: Readonly<AppState>) => boolean;
8
+ };
5
9
  perform(elements: readonly import("../element/types").ExcalidrawElement[], appState: Readonly<AppState>): {
6
10
  appState: {
7
11
  gridSize: number | null;
@@ -18,8 +22,9 @@ export declare const actionToggleGridMode: {
18
22
  editingLinearElement: import("../element/linearElementEditor").LinearElementEditor | null;
19
23
  activeTool: {
20
24
  type: "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "image" | "freedraw" | "eraser";
25
+ lastActiveToolBeforeEraser: "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "image" | "freedraw" | null;
26
+ locked: boolean;
21
27
  };
22
- elementLocked: boolean;
23
28
  penMode: boolean;
24
29
  penDetected: boolean;
25
30
  exportBackground: boolean;
@@ -1,6 +1,9 @@
1
1
  /// <reference types="react" />
2
2
  export declare const actionToggleStats: {
3
3
  name: "stats";
4
+ trackEvent: {
5
+ category: "menu";
6
+ };
4
7
  perform(elements: readonly import("../element/types").ExcalidrawElement[], appState: Readonly<import("../types").AppState>): {
5
8
  appState: {
6
9
  showStats: boolean;
@@ -17,8 +20,9 @@ export declare const actionToggleStats: {
17
20
  editingLinearElement: import("../element/linearElementEditor").LinearElementEditor | null;
18
21
  activeTool: {
19
22
  type: "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "image" | "freedraw" | "eraser";
23
+ lastActiveToolBeforeEraser: "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "image" | "freedraw" | null;
24
+ locked: boolean;
20
25
  };
21
- elementLocked: boolean;
22
26
  penMode: boolean;
23
27
  penDetected: boolean;
24
28
  exportBackground: boolean;
@@ -1,6 +1,10 @@
1
1
  /// <reference types="react" />
2
2
  export declare const actionToggleViewMode: {
3
3
  name: "viewMode";
4
+ trackEvent: {
5
+ category: "canvas";
6
+ predicate: (appState: Readonly<import("../types").AppState>) => boolean;
7
+ };
4
8
  perform(elements: readonly import("../element/types").ExcalidrawElement[], appState: Readonly<import("../types").AppState>): {
5
9
  appState: {
6
10
  viewModeEnabled: boolean;
@@ -17,8 +21,9 @@ export declare const actionToggleViewMode: {
17
21
  editingLinearElement: import("../element/linearElementEditor").LinearElementEditor | null;
18
22
  activeTool: {
19
23
  type: "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "image" | "freedraw" | "eraser";
24
+ lastActiveToolBeforeEraser: "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "image" | "freedraw" | null;
25
+ locked: boolean;
20
26
  };
21
- elementLocked: boolean;
22
27
  penMode: boolean;
23
28
  penDetected: boolean;
24
29
  exportBackground: boolean;
@@ -1,6 +1,10 @@
1
1
  /// <reference types="react" />
2
2
  export declare const actionToggleZenMode: {
3
3
  name: "zenMode";
4
+ trackEvent: {
5
+ category: "canvas";
6
+ predicate: (appState: Readonly<import("../types").AppState>) => boolean;
7
+ };
4
8
  perform(elements: readonly import("../element/types").ExcalidrawElement[], appState: Readonly<import("../types").AppState>): {
5
9
  appState: {
6
10
  zenModeEnabled: boolean;
@@ -17,8 +21,9 @@ export declare const actionToggleZenMode: {
17
21
  editingLinearElement: import("../element/linearElementEditor").LinearElementEditor | null;
18
22
  activeTool: {
19
23
  type: "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "image" | "freedraw" | "eraser";
24
+ lastActiveToolBeforeEraser: "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "image" | "freedraw" | null;
25
+ locked: boolean;
20
26
  };
21
- elementLocked: boolean;
22
27
  penMode: boolean;
23
28
  penDetected: boolean;
24
29
  exportBackground: boolean;
@@ -1,6 +1,9 @@
1
1
  import React from "react";
2
2
  export declare const actionSendBackward: {
3
3
  name: "sendBackward";
4
+ trackEvent: {
5
+ category: "element";
6
+ };
4
7
  perform: (elements: readonly import("../element/types").ExcalidrawElement[], appState: Readonly<import("../types").AppState>) => {
5
8
  elements: (import("../element/types").ExcalidrawLinearElement | import("../element/types").ExcalidrawSelectionElement | import("../element/types").ExcalidrawRectangleElement | import("../element/types").ExcalidrawDiamondElement | import("../element/types").ExcalidrawEllipseElement | import("../element/types").ExcalidrawImageElement | import("../element/types").ExcalidrawTextElement | import("../element/types").ExcalidrawFreeDrawElement)[];
6
9
  appState: Readonly<import("../types").AppState>;
@@ -15,6 +18,9 @@ export declare const actionSendBackward: {
15
18
  };
16
19
  export declare const actionBringForward: {
17
20
  name: "bringForward";
21
+ trackEvent: {
22
+ category: "element";
23
+ };
18
24
  perform: (elements: readonly import("../element/types").ExcalidrawElement[], appState: Readonly<import("../types").AppState>) => {
19
25
  elements: (import("../element/types").ExcalidrawLinearElement | import("../element/types").ExcalidrawSelectionElement | import("../element/types").ExcalidrawRectangleElement | import("../element/types").ExcalidrawDiamondElement | import("../element/types").ExcalidrawEllipseElement | import("../element/types").ExcalidrawImageElement | import("../element/types").ExcalidrawTextElement | import("../element/types").ExcalidrawFreeDrawElement)[];
20
26
  appState: Readonly<import("../types").AppState>;
@@ -29,6 +35,9 @@ export declare const actionBringForward: {
29
35
  };
30
36
  export declare const actionSendToBack: {
31
37
  name: "sendToBack";
38
+ trackEvent: {
39
+ category: "element";
40
+ };
32
41
  perform: (elements: readonly import("../element/types").ExcalidrawElement[], appState: Readonly<import("../types").AppState>) => {
33
42
  elements: readonly import("../element/types").ExcalidrawElement[];
34
43
  appState: Readonly<import("../types").AppState>;
@@ -42,6 +51,9 @@ export declare const actionSendToBack: {
42
51
  };
43
52
  export declare const actionBringToFront: {
44
53
  name: "bringToFront";
54
+ trackEvent: {
55
+ category: "element";
56
+ };
45
57
  perform: (elements: readonly import("../element/types").ExcalidrawElement[], appState: Readonly<import("../types").AppState>) => {
46
58
  elements: readonly import("../element/types").ExcalidrawElement[];
47
59
  appState: Readonly<import("../types").AppState>;
@@ -1,8 +1,8 @@
1
1
  import React from "react";
2
- import { Action, ActionsManagerInterface, UpdaterFn, ActionName, ActionResult, PanelComponentProps } from "./types";
2
+ import { Action, UpdaterFn, ActionName, ActionResult, PanelComponentProps, ActionSource } from "./types";
3
3
  import { ExcalidrawElement } from "../element/types";
4
4
  import { AppClassProperties, AppState } from "../types";
5
- export declare class ActionManager implements ActionsManagerInterface {
5
+ export declare class ActionManager {
6
6
  actions: Record<ActionName, Action>;
7
7
  updater: (actionResult: ActionResult | Promise<ActionResult>) => void;
8
8
  getAppState: () => Readonly<AppState>;
@@ -12,7 +12,7 @@ export declare class ActionManager implements ActionsManagerInterface {
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): void;
15
+ executeAction(action: Action, source?: ActionSource): void;
16
16
  /**
17
17
  * @param data additional data sent to the PanelComponent
18
18
  */
@@ -2,6 +2,7 @@ import React from "react";
2
2
  import { ExcalidrawElement } from "../element/types";
3
3
  import { AppClassProperties, AppState, ExcalidrawProps, BinaryFiles } from "../types";
4
4
  import { ToolButtonSize } from "../components/ToolButton";
5
+ export declare type ActionSource = "ui" | "keyboard" | "contextMenu" | "api";
5
6
  /** if false, the action should be prevented */
6
7
  export declare type ActionResult = {
7
8
  elements?: readonly ExcalidrawElement[] | null;
@@ -34,13 +35,10 @@ export interface Action {
34
35
  contextItemLabel?: string | ((elements: readonly ExcalidrawElement[], appState: Readonly<AppState>) => string);
35
36
  contextItemPredicate?: (elements: readonly ExcalidrawElement[], appState: AppState) => boolean;
36
37
  checked?: (appState: Readonly<AppState>) => boolean;
37
- trackEvent?: boolean | ((action: Action, type: "ui" | "keyboard" | "api", value: any) => void);
38
- }
39
- export interface ActionsManagerInterface {
40
- actions: Record<ActionName, Action>;
41
- registerAction: (action: Action) => void;
42
- handleKeyDown: (event: React.KeyboardEvent | KeyboardEvent) => boolean;
43
- renderAction: (name: ActionName) => React.ReactElement | null;
44
- executeAction: (action: Action) => void;
38
+ trackEvent: false | {
39
+ category: "toolbar" | "element" | "canvas" | "export" | "history" | "menu" | "collab" | "hyperlink";
40
+ action?: string;
41
+ predicate?: (appState: Readonly<AppState>, elements: readonly ExcalidrawElement[], value: any) => boolean;
42
+ };
45
43
  }
46
44
  export {};
@@ -3,6 +3,8 @@ export declare const getDefaultAppState: () => Omit<AppState, "offsetTop" | "off
3
3
  export declare const clearAppStateForLocalStorage: (appState: Partial<AppState>) => {
4
4
  activeTool?: {
5
5
  type: "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "image" | "freedraw" | "eraser";
6
+ lastActiveToolBeforeEraser: "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "image" | "freedraw" | null;
7
+ locked: boolean;
6
8
  } | undefined;
7
9
  scrollX?: number | undefined;
8
10
  scrollY?: number | undefined;
@@ -13,7 +15,6 @@ export declare const clearAppStateForLocalStorage: (appState: Partial<AppState>)
13
15
  shouldCacheIgnoreZoom?: boolean | undefined;
14
16
  theme?: string | undefined;
15
17
  name?: string | undefined;
16
- elementLocked?: boolean | undefined;
17
18
  penMode?: boolean | undefined;
18
19
  penDetected?: boolean | undefined;
19
20
  exportBackground?: boolean | undefined;
@@ -74,7 +74,7 @@ declare class App extends React.Component<AppProps, AppState> {
74
74
  private addTextFromPaste;
75
75
  setAppState: (obj: any) => void;
76
76
  removePointer: (event: React.PointerEvent<HTMLElement> | PointerEvent) => void;
77
- toggleLock: () => void;
77
+ toggleLock: (source?: "keyboard" | "ui") => void;
78
78
  togglePenMode: () => void;
79
79
  toggleZenMode: () => void;
80
80
  toggleStats: () => void;
@@ -1,8 +1,8 @@
1
1
  /// <reference types="react" />
2
- import { ActionsManagerInterface } from "../actions/types";
3
2
  import { NonDeletedExcalidrawElement } from "../element/types";
4
3
  import { AppState, BinaryFiles } from "../types";
5
4
  import "./ExportDialog.scss";
5
+ import { ActionManager } from "../actions/manager";
6
6
  export declare const ErrorCanvasPreview: () => JSX.Element;
7
7
  export declare type ExportCB = (elements: readonly NonDeletedExcalidrawElement[], scale?: number) => void;
8
8
  export declare const ImageExportDialog: ({ elements, appState, files, exportPadding, actionManager, onExportToPng, onExportToSvg, onExportToClipboard, }: {
@@ -10,7 +10,7 @@ export declare const ImageExportDialog: ({ elements, appState, files, exportPadd
10
10
  elements: readonly NonDeletedExcalidrawElement[];
11
11
  files: BinaryFiles;
12
12
  exportPadding?: number | undefined;
13
- actionManager: ActionsManagerInterface;
13
+ actionManager: ActionManager;
14
14
  onExportToPng: ExportCB;
15
15
  onExportToSvg: ExportCB;
16
16
  onExportToClipboard: ExportCB;
@@ -1,14 +1,14 @@
1
1
  /// <reference types="react" />
2
- import { ActionsManagerInterface } from "../actions/types";
3
2
  import { NonDeletedExcalidrawElement } from "../element/types";
4
3
  import { AppState, CanvasActions, BinaryFiles } from "../types";
5
4
  import "./ExportDialog.scss";
5
+ import { ActionManager } from "../actions/manager";
6
6
  export declare type ExportCB = (elements: readonly NonDeletedExcalidrawElement[], scale?: number) => void;
7
7
  export declare const JSONExportDialog: ({ elements, appState, files, actionManager, exportOpts, canvas, }: {
8
8
  elements: readonly NonDeletedExcalidrawElement[];
9
9
  appState: AppState;
10
10
  files: BinaryFiles;
11
- actionManager: ActionsManagerInterface;
11
+ actionManager: ActionManager;
12
12
  exportOpts: CanvasActions["export"];
13
13
  canvas: HTMLCanvasElement | null;
14
14
  }) => JSX.Element;
@@ -5,9 +5,8 @@ declare class Library {
5
5
  private app;
6
6
  constructor(app: App);
7
7
  resetLibrary: () => Promise<void>;
8
- restoreLibraryItem: (libraryItem: LibraryItem) => LibraryItem | null;
9
8
  /** imports library (currently merges, removing duplicates) */
10
- importLibrary(blob: Blob, defaultStatus?: string): Promise<void>;
9
+ importLibrary(blob: Blob, defaultStatus?: LibraryItem["status"]): Promise<void>;
11
10
  loadLibrary: () => Promise<LibraryItems>;
12
11
  saveLibrary: (items: LibraryItems) => Promise<void>;
13
12
  }
@@ -32,8 +32,9 @@ export declare const actionLink: {
32
32
  editingLinearElement: import("./linearElementEditor").LinearElementEditor | null;
33
33
  activeTool: {
34
34
  type: "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "image" | "freedraw" | "eraser";
35
+ lastActiveToolBeforeEraser: "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "image" | "freedraw" | null;
36
+ locked: boolean;
35
37
  };
36
- elementLocked: boolean;
37
38
  penMode: boolean;
38
39
  penDetected: boolean;
39
40
  exportBackground: boolean;
@@ -104,7 +105,10 @@ export declare const actionLink: {
104
105
  };
105
106
  commitToHistory: true;
106
107
  };
107
- trackEvent: (action: import("../actions/types").Action, source: "ui" | "keyboard" | "api") => void;
108
+ trackEvent: {
109
+ category: "hyperlink";
110
+ action: string;
111
+ };
108
112
  keyTest: (event: KeyboardEvent | import("react").KeyboardEvent<Element>) => boolean;
109
113
  contextItemLabel: (elements: readonly import("./types").ExcalidrawElement[], appState: Readonly<AppState>) => "labels.link.edit" | "labels.link.create";
110
114
  contextItemPredicate: (elements: readonly import("./types").ExcalidrawElement[], appState: AppState) => boolean;
@@ -98,8 +98,9 @@ export declare class LinearElementEditor {
98
98
  editingElement: import("./types").NonDeletedExcalidrawElement | null;
99
99
  activeTool: {
100
100
  type: "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "image" | "freedraw" | "eraser";
101
+ lastActiveToolBeforeEraser: "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "image" | "freedraw" | null;
102
+ locked: boolean;
101
103
  };
102
- elementLocked: boolean;
103
104
  penMode: boolean;
104
105
  penDetected: boolean;
105
106
  exportBackground: boolean;
@@ -8,7 +8,7 @@ declare const _default: React.MemoExoticComponent<React.ForwardRefExoticComponen
8
8
  export default _default;
9
9
  export { getSceneVersion, isInvisiblySmallElement, getNonDeletedElements, } from "../../element";
10
10
  export { defaultLang, languages } from "../../i18n";
11
- export { restore, restoreElements, restoreAppState } from "../../data/restore";
11
+ export { restore, restoreAppState, restoreElements, restoreLibraryItems, } from "../../data/restore";
12
12
  export { exportToBlob, exportToCanvas, exportToSvg, serializeAsJSON, loadLibraryFromBlob, loadFromBlob, getFreeDrawSvgPath, } from "../../packages/utils";
13
13
  export { isLinearElement } from "../../element/typeChecks";
14
14
  export { mutateElement, newElementWith, bumpVersion, } from "../../element/mutateElement";
@@ -15,7 +15,7 @@ declare class Scene {
15
15
  private elementsMap;
16
16
  getElementsIncludingDeleted(): readonly ExcalidrawElement[];
17
17
  getElements(): readonly NonDeletedExcalidrawElement[];
18
- getElement(id: ExcalidrawElement["id"]): ExcalidrawElement | null;
18
+ getElement<T extends ExcalidrawElement>(id: T["id"]): T | null;
19
19
  getNonDeletedElement(id: ExcalidrawElement["id"]): NonDeleted<ExcalidrawElement> | null;
20
20
  getNonDeletedElements(ids: readonly ExcalidrawElement["id"][]): NonDeleted<ExcalidrawElement>[];
21
21
  replaceAllElements(nextElements: readonly ExcalidrawElement[]): void;
package/types/types.d.ts CHANGED
@@ -56,8 +56,9 @@ export declare type AppState = {
56
56
  editingLinearElement: LinearElementEditor | null;
57
57
  activeTool: {
58
58
  type: typeof SHAPES[number]["value"] | "eraser";
59
+ lastActiveToolBeforeEraser: typeof SHAPES[number]["value"] | null;
60
+ locked: boolean;
59
61
  };
60
- elementLocked: boolean;
61
62
  penMode: boolean;
62
63
  penDetected: boolean;
63
64
  exportBackground: boolean;
@@ -265,6 +266,7 @@ export declare type AppClassProperties = {
265
266
  mimeType: typeof ALLOWED_IMAGE_MIME_TYPES[number];
266
267
  }>;
267
268
  files: BinaryFiles;
269
+ deviceType: App["deviceType"];
268
270
  };
269
271
  export declare type PointerDownState = Readonly<{
270
272
  origin: Readonly<{
package/types/utils.d.ts CHANGED
@@ -118,3 +118,5 @@ export declare const wrapEvent: <T extends Event>(name: EVENT, nativeEvent: T) =
118
118
  nativeEvent: T;
119
119
  }>;
120
120
  export declare const updateObject: <T extends Record<string, any>>(obj: T, updates: Partial<T>) => T;
121
+ export declare const isPrimitive: (val: any) => boolean;
122
+ export declare const getFrame: () => "top" | "iframe";