@zsviczian/excalidraw 0.11.0-obsidian-6 → 0.11.0-obsidian-9

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 (64) hide show
  1. package/dist/excalidraw.development.js +92 -81
  2. package/dist/excalidraw.production.min.js +1 -1
  3. package/package.json +4 -4
  4. package/types/actions/actionAddToLibrary.d.ts +18 -6
  5. package/types/actions/actionAlign.d.ts +18 -0
  6. package/types/actions/actionBoundText.d.ts +123 -0
  7. package/types/actions/actionCanvas.d.ts +72 -19
  8. package/types/actions/actionClipboard.d.ts +50 -10
  9. package/types/actions/actionDeleteSelected.d.ts +19 -6
  10. package/types/actions/actionDistribute.d.ts +6 -0
  11. package/types/actions/actionDuplicateSelection.d.ts +3 -0
  12. package/types/actions/actionExport.d.ts +71 -18
  13. package/types/actions/actionFinalize.d.ts +13 -6
  14. package/types/actions/actionFlip.d.ts +6 -0
  15. package/types/actions/actionGroup.d.ts +6 -0
  16. package/types/actions/actionMenu.d.ts +29 -6
  17. package/types/actions/actionNavigate.d.ts +3 -0
  18. package/types/actions/actionProperties.d.ts +82 -26
  19. package/types/actions/actionSelectAll.d.ts +3 -0
  20. package/types/actions/actionStyles.d.ts +11 -2
  21. package/types/actions/actionToggleGridMode.d.ts +9 -2
  22. package/types/actions/actionToggleLock.d.ts +17 -0
  23. package/types/actions/actionToggleStats.d.ts +8 -2
  24. package/types/actions/actionToggleViewMode.d.ts +9 -2
  25. package/types/actions/actionToggleZenMode.d.ts +9 -2
  26. package/types/actions/actionZindex.d.ts +12 -0
  27. package/types/actions/index.d.ts +3 -2
  28. package/types/actions/manager.d.ts +3 -3
  29. package/types/actions/shortcuts.d.ts +1 -1
  30. package/types/actions/types.d.ts +7 -9
  31. package/types/appState.d.ts +9 -4
  32. package/types/clipboard.d.ts +1 -1
  33. package/types/components/Actions.d.ts +5 -4
  34. package/types/components/App.d.ts +6 -5
  35. package/types/components/ImageExportDialog.d.ts +2 -2
  36. package/types/components/JSONExportDialog.d.ts +2 -2
  37. package/types/components/ToolButton.d.ts +3 -0
  38. package/types/constants.d.ts +1 -0
  39. package/types/createInverseContext.d.ts +20 -1
  40. package/types/data/index.d.ts +1 -1
  41. package/types/data/json.d.ts +1 -0
  42. package/types/data/restore.d.ts +1 -1
  43. package/types/element/Hyperlink.d.ts +9 -3
  44. package/types/element/dragElements.d.ts +1 -1
  45. package/types/element/linearElementEditor.d.ts +6 -3
  46. package/types/element/sizeHelpers.d.ts +2 -1
  47. package/types/element/textElement.d.ts +1 -2
  48. package/types/element/typeChecks.d.ts +5 -5
  49. package/types/element/types.d.ts +1 -0
  50. package/types/excalidraw-app/app_constants.d.ts +13 -1
  51. package/types/excalidraw-app/collab/CollabWrapper.d.ts +20 -8
  52. package/types/excalidraw-app/collab/Portal.d.ts +2 -2
  53. package/types/excalidraw-app/collab/reconciliation.d.ts +9 -0
  54. package/types/excalidraw-app/data/FileManager.d.ts +66 -0
  55. package/types/excalidraw-app/data/firebase.d.ts +11 -11
  56. package/types/excalidraw-app/data/index.d.ts +32 -27
  57. package/types/excalidraw-app/data/localStorage.d.ts +19 -19
  58. package/types/excalidraw-app/data/tabSync.d.ts +9 -0
  59. package/types/packages/excalidraw/index.d.ts +5 -1
  60. package/types/packages/utils.d.ts +1 -1
  61. package/types/scene/Scene.d.ts +1 -1
  62. package/types/shapes.d.ts +1 -1
  63. package/types/types.d.ts +14 -3
  64. package/types/utils.d.ts +7 -2
@@ -1,8 +1,17 @@
1
1
  import { ImportedDataState } from "../../data/types";
2
2
  import { ExcalidrawElement } from "../../element/types";
3
- import { AppState, UserIdleState } from "../../types";
4
- export declare const generateEncryptionKey: () => Promise<string | undefined>;
5
- export declare const SOCKET_SERVER: string;
3
+ import { AppState, BinaryFiles, UserIdleState } from "../../types";
4
+ /**
5
+ * Right now the reason why we resolve connection params (url, polling...)
6
+ * from upstream is to allow changing the params immediately when needed without
7
+ * having to wait for clients to update the SW.
8
+ *
9
+ * If REACT_APP_WS_SERVER_URL env is set, we use that instead (useful for forks)
10
+ */
11
+ export declare const getCollabServer: () => Promise<{
12
+ url: string;
13
+ polling: boolean;
14
+ }>;
6
15
  export declare type EncryptedData = {
7
16
  data: ArrayBuffer;
8
17
  iv: Uint8Array;
@@ -48,9 +57,6 @@ export declare type SocketUpdateDataIncoming = SocketUpdateDataSource[keyof Sock
48
57
  export declare type SocketUpdateData = SocketUpdateDataSource[keyof SocketUpdateDataSource] & {
49
58
  _brand: "socketUpdateData";
50
59
  };
51
- export declare const createIV: () => Uint8Array;
52
- export declare const encryptAESGEM: (data: Uint8Array, key: string) => Promise<EncryptedData>;
53
- export declare const decryptAESGEM: (data: ArrayBuffer, key: string, iv: Uint8Array) => Promise<SocketUpdateDataIncoming>;
54
60
  export declare const getCollaborationLinkData: (link: string) => {
55
61
  roomId: string;
56
62
  roomKey: string;
@@ -63,22 +69,19 @@ export declare const getCollaborationLink: (data: {
63
69
  roomId: string;
64
70
  roomKey: string;
65
71
  }) => string;
66
- export declare const getImportedKey: (key: string, usage: KeyUsage) => Promise<CryptoKey>;
67
- export declare const decryptImported: (iv: ArrayBuffer, encrypted: ArrayBuffer, privateKey: string) => Promise<ArrayBuffer>;
68
72
  export declare const loadScene: (id: string | null, privateKey: string | null, localDataState: ImportedDataState | undefined | null) => Promise<{
69
73
  elements: ExcalidrawElement[];
70
74
  appState: {
71
- theme: "light" | "dark";
75
+ elementType: "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "image" | "freedraw" | "eraser";
76
+ scrollX: number;
77
+ scrollY: number;
78
+ viewBackgroundColor: string;
72
79
  zoom: Readonly<{
73
80
  value: import("../../types").NormalizedZoomValue;
74
- translation: Readonly<{
75
- x: number;
76
- y: number;
77
- }>;
78
81
  }>;
79
- scrollX: number;
80
- scrollY: number;
81
- files: Record<string, import("../../types").BinaryFileData>;
82
+ shouldCacheIgnoreZoom: boolean;
83
+ theme: string;
84
+ name: string;
82
85
  isLoading: boolean;
83
86
  errorMessage: string | null;
84
87
  draggingElement: import("../../element/types").NonDeletedExcalidrawElement | null;
@@ -90,8 +93,9 @@ export declare const loadScene: (id: string | null, privateKey: string | null, l
90
93
  suggestedBindings: import("../../element/binding").SuggestedBinding[];
91
94
  editingElement: import("../../element/types").NonDeletedExcalidrawElement | null;
92
95
  editingLinearElement: import("../../element/linearElementEditor").LinearElementEditor | null;
93
- elementType: "line" | "selection" | "rectangle" | "diamond" | "ellipse" | "image" | "text" | "arrow" | "freedraw";
94
96
  elementLocked: boolean;
97
+ penMode: boolean;
98
+ penDetected: boolean;
95
99
  exportBackground: boolean;
96
100
  exportEmbedScene: boolean;
97
101
  exportWithDarkMode: boolean;
@@ -110,10 +114,8 @@ export declare const loadScene: (id: string | null, privateKey: string | null, l
110
114
  currentItemStartArrowhead: import("../../element/types").Arrowhead | null;
111
115
  currentItemEndArrowhead: import("../../element/types").Arrowhead | null;
112
116
  currentItemLinearStrokeSharpness: import("../../element/types").StrokeSharpness;
113
- viewBackgroundColor: string;
114
117
  cursorButton: "up" | "down";
115
118
  scrolledOutside: boolean;
116
- name: string;
117
119
  isResizing: boolean;
118
120
  isRotating: boolean;
119
121
  openMenu: "canvas" | "shape" | null;
@@ -125,7 +127,6 @@ export declare const loadScene: (id: string | null, privateKey: string | null, l
125
127
  previousSelectedElementIds: {
126
128
  [id: string]: boolean;
127
129
  };
128
- shouldCacheIgnoreZoom: boolean;
129
130
  showHelpDialog: boolean;
130
131
  toastMessage: string | null;
131
132
  zenModeEnabled: boolean;
@@ -136,7 +137,7 @@ export declare const loadScene: (id: string | null, privateKey: string | null, l
136
137
  };
137
138
  editingGroupId: string | null;
138
139
  isLibraryOpen: boolean;
139
- fileHandle: import("@dwelle/browser-fs-access").FileSystemHandle | null;
140
+ fileHandle: import("browser-fs-access").FileSystemHandle | null;
140
141
  collaborators: Map<string, import("../../types").Collaborator>;
141
142
  showStats: boolean;
142
143
  currentChartType: import("../../element/types").ChartType;
@@ -148,12 +149,16 @@ export declare const loadScene: (id: string | null, privateKey: string | null, l
148
149
  data: import("../../charts").Spreadsheet;
149
150
  };
150
151
  pendingImageElement: import("../../element/types").NonDeleted<import("../../element/types").ExcalidrawImageElement> | null;
152
+ showHyperlinkPopup: false | "info" | "editor";
153
+ linkOpacity: number;
154
+ trayModeEnabled: boolean;
155
+ colorPalette: {
156
+ canvasBackground?: string[] | undefined;
157
+ elementBackground?: string[] | undefined;
158
+ elementStroke?: string[] | undefined;
159
+ };
151
160
  };
161
+ files: BinaryFiles;
152
162
  commitToHistory: boolean;
153
163
  }>;
154
- export declare const exportToBackend: (elements: readonly ExcalidrawElement[], appState: AppState) => Promise<void>;
155
- export declare const encryptData: (key: string, data: Uint8Array | Blob | File | string) => Promise<{
156
- encryptedBuffer: ArrayBuffer;
157
- iv: Uint8Array;
158
- }>;
159
- export declare const decryptData: (iv: ArrayBuffer, encrypted: ArrayBuffer, privateKey: string) => Promise<ArrayBuffer>;
164
+ export declare const exportToBackend: (elements: readonly ExcalidrawElement[], appState: AppState, files: BinaryFiles) => Promise<void>;
@@ -1,29 +1,24 @@
1
1
  import { ExcalidrawElement } from "../../element/types";
2
2
  import { AppState } from "../../types";
3
- export declare const STORAGE_KEYS: {
4
- LOCAL_STORAGE_ELEMENTS: string;
5
- LOCAL_STORAGE_APP_STATE: string;
6
- LOCAL_STORAGE_COLLAB: string;
7
- LOCAL_STORAGE_KEY_COLLAB_FORCE_FLAG: string;
8
- };
9
3
  export declare const saveUsernameToLocalStorage: (username: string) => void;
10
4
  export declare const importUsernameFromLocalStorage: () => string | null;
11
5
  export declare const saveToLocalStorage: (elements: readonly ExcalidrawElement[], appState: AppState) => void;
12
6
  export declare const importFromLocalStorage: () => {
13
7
  elements: ExcalidrawElement[];
14
8
  appState: {
15
- theme: "light" | "dark";
9
+ elementType: "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "image" | "freedraw" | "eraser";
10
+ scrollX: number;
11
+ scrollY: number;
12
+ viewBackgroundColor: string;
16
13
  zoom: Readonly<{
17
14
  value: import("../../types").NormalizedZoomValue;
18
- translation: Readonly<{
19
- x: number;
20
- y: number;
21
- }>;
22
15
  }>;
23
- scrollX: number;
24
- scrollY: number;
25
- elementType: "line" | "selection" | "rectangle" | "diamond" | "ellipse" | "image" | "text" | "arrow" | "freedraw";
16
+ shouldCacheIgnoreZoom: boolean;
17
+ theme: string;
18
+ name: string;
26
19
  elementLocked: boolean;
20
+ penMode: boolean;
21
+ penDetected: boolean;
27
22
  exportBackground: boolean;
28
23
  exportEmbedScene: boolean;
29
24
  exportWithDarkMode: boolean;
@@ -42,10 +37,8 @@ export declare const importFromLocalStorage: () => {
42
37
  currentItemStartArrowhead: import("../../element/types").Arrowhead | null;
43
38
  currentItemEndArrowhead: import("../../element/types").Arrowhead | null;
44
39
  currentItemLinearStrokeSharpness: import("../../element/types").StrokeSharpness;
45
- viewBackgroundColor: string;
46
40
  cursorButton: "up" | "down";
47
41
  scrolledOutside: boolean;
48
- name: string;
49
42
  openMenu: "canvas" | "shape" | null;
50
43
  lastPointerDownWith: import("../../element/types").PointerType;
51
44
  selectedElementIds: {
@@ -54,7 +47,6 @@ export declare const importFromLocalStorage: () => {
54
47
  previousSelectedElementIds: {
55
48
  [id: string]: boolean;
56
49
  };
57
- shouldCacheIgnoreZoom: boolean;
58
50
  zenModeEnabled: boolean;
59
51
  gridSize: number | null;
60
52
  selectedGroupIds: {
@@ -63,7 +55,6 @@ export declare const importFromLocalStorage: () => {
63
55
  editingGroupId: string | null;
64
56
  showStats: boolean;
65
57
  currentChartType: import("../../element/types").ChartType;
66
- files: Record<string, import("../../types").BinaryFileData>;
67
58
  isLoading: boolean;
68
59
  errorMessage: string | null;
69
60
  draggingElement: import("../../element/types").NonDeletedExcalidrawElement | null;
@@ -82,7 +73,7 @@ export declare const importFromLocalStorage: () => {
82
73
  toastMessage: string | null;
83
74
  viewModeEnabled: boolean;
84
75
  isLibraryOpen: boolean;
85
- fileHandle: import("@dwelle/browser-fs-access").FileSystemHandle | null;
76
+ fileHandle: import("browser-fs-access").FileSystemHandle | null;
86
77
  collaborators: Map<string, import("../../types").Collaborator>;
87
78
  pasteDialog: {
88
79
  shown: false;
@@ -92,7 +83,16 @@ export declare const importFromLocalStorage: () => {
92
83
  data: import("../../charts").Spreadsheet;
93
84
  };
94
85
  pendingImageElement: import("../../element/types").NonDeleted<import("../../element/types").ExcalidrawImageElement> | null;
86
+ showHyperlinkPopup: false | "info" | "editor";
87
+ linkOpacity: number;
88
+ trayModeEnabled: boolean;
89
+ colorPalette: {
90
+ canvasBackground?: string[] | undefined;
91
+ elementBackground?: string[] | undefined;
92
+ elementStroke?: string[] | undefined;
93
+ };
95
94
  } | null;
96
95
  };
97
96
  export declare const getElementsStorageSize: () => number;
98
97
  export declare const getTotalStorageSize: () => number;
98
+ export declare const getLibraryItemsFromStorage: () => any;
@@ -0,0 +1,9 @@
1
+ declare const LOCAL_STATE_VERSIONS: {
2
+ "version-dataState": number;
3
+ "version-files": number;
4
+ };
5
+ declare type BrowserStateTypes = keyof typeof LOCAL_STATE_VERSIONS;
6
+ export declare const isBrowserStorageStateNewer: (type: BrowserStateTypes) => boolean;
7
+ export declare const updateBrowserStateVersion: (type: BrowserStateTypes) => void;
8
+ export declare const resetBrowserStateVersions: () => void;
9
+ export {};
@@ -9,7 +9,11 @@ export default _default;
9
9
  export { getSceneVersion, isInvisiblySmallElement, getNonDeletedElements, } from "../../element";
10
10
  export { defaultLang, languages } from "../../i18n";
11
11
  export { restore, restoreAppState, restoreElements } from "../../data/restore";
12
- export { exportToCanvas, exportToBlob, exportToSvg, serializeAsJSON, loadLibraryFromBlob, loadFromBlob, getFreeDrawSvgPath, getCommonBoundingBox, getMaximumGroups, intersectElementWithLine, determineFocusDistance, measureText, } from "../../packages/utils";
12
+ export { exportToCanvas, exportToBlob, exportToSvg, serializeAsJSON, serializeLibraryAsJSON, loadLibraryFromBlob, loadFromBlob, getFreeDrawSvgPath, getCommonBoundingBox, //zsviczian
13
+ getMaximumGroups, //zsviczian
14
+ intersectElementWithLine, //zsviczian
15
+ determineFocusDistance, //zsviczian
16
+ measureText, } from "../../packages/utils";
13
17
  export { isLinearElement } from "../../element/typeChecks";
14
18
  export { FONT_FAMILY, THEME } from "../../constants";
15
19
  export { mutateElement, newElementWith, bumpVersion, } from "../../element/mutateElement";
@@ -19,7 +19,7 @@ export declare const exportToBlob: (opts: ExportOpts & {
19
19
  export declare const exportToSvg: ({ elements, appState, files, exportPadding, }: Omit<ExportOpts, "getDimensions"> & {
20
20
  exportPadding?: number | undefined;
21
21
  }) => Promise<SVGSVGElement>;
22
- export { serializeAsJSON } from "../data/json";
22
+ export { serializeAsJSON, serializeLibraryAsJSON } from "../data/json";
23
23
  export { loadFromBlob, loadLibraryFromBlob } from "../data/blob";
24
24
  export { getFreeDrawSvgPath } from "../renderer/renderElement";
25
25
  export { getCommonBoundingBox } from "../element/bounds";
@@ -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/shapes.d.ts CHANGED
@@ -14,7 +14,7 @@ export declare const SHAPES: readonly [{
14
14
  }, {
15
15
  readonly icon: JSX.Element;
16
16
  readonly value: "ellipse";
17
- readonly key: "e";
17
+ readonly key: "o";
18
18
  }, {
19
19
  readonly icon: JSX.Element;
20
20
  readonly value: "arrow";
package/types/types.d.ts CHANGED
@@ -53,8 +53,11 @@ export declare type AppState = {
53
53
  suggestedBindings: SuggestedBinding[];
54
54
  editingElement: NonDeletedExcalidrawElement | null;
55
55
  editingLinearElement: LinearElementEditor | null;
56
- elementType: typeof SHAPES[number]["value"] | "eraser";
57
- elementLocked: boolean;
56
+ activeTool: {
57
+ type: typeof SHAPES[number]["value"] | "eraser";
58
+ lastActiveToolBeforeEraser: typeof SHAPES[number]["value"] | null;
59
+ locked: boolean;
60
+ };
58
61
  penMode: boolean;
59
62
  penDetected: boolean;
60
63
  exportBackground: boolean;
@@ -268,6 +271,7 @@ export declare type AppClassProperties = {
268
271
  mimeType: typeof ALLOWED_IMAGE_MIME_TYPES[number];
269
272
  }>;
270
273
  files: BinaryFiles;
274
+ deviceType: App["deviceType"];
271
275
  };
272
276
  export declare type PointerDownState = Readonly<{
273
277
  origin: Readonly<{
@@ -323,7 +327,10 @@ export declare type PointerDownState = Readonly<{
323
327
  hasOccurred: boolean;
324
328
  };
325
329
  elementIdsToErase: {
326
- [key: ExcalidrawElement["id"]]: boolean;
330
+ [key: ExcalidrawElement["id"]]: {
331
+ opacity: ExcalidrawElement["opacity"];
332
+ erase: boolean;
333
+ };
327
334
  };
328
335
  }>;
329
336
  export declare type ExcalidrawImperativeAPI = {
@@ -354,4 +361,8 @@ export declare type ExcalidrawImperativeAPI = {
354
361
  bringToFront: (elements: readonly ExcalidrawElement[]) => void;
355
362
  restore: InstanceType<typeof App>["restore"];
356
363
  };
364
+ export declare type DeviceType = {
365
+ isMobile: boolean;
366
+ isTouchScreen: boolean;
367
+ };
357
368
  export {};
package/types/utils.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { EVENT } from "./constants";
2
2
  import { FontFamilyValues, FontString } from "./element/types";
3
- import { Zoom } from "./types";
3
+ import { AppState, Zoom } from "./types";
4
4
  export declare const setDateTimeForTests: (dateTime: string) => void;
5
5
  export declare const getDateTime: () => string;
6
6
  export declare const capitalizeString: (str: string) => string;
@@ -31,7 +31,8 @@ export declare const removeSelection: () => void;
31
31
  export declare const distance: (x: number, y: number) => number;
32
32
  export declare const resetCursor: (canvas: HTMLCanvasElement | null) => void;
33
33
  export declare const setCursor: (canvas: HTMLCanvasElement | null, cursor: string) => void;
34
- export declare const setCursorForShape: (canvas: HTMLCanvasElement | null, shape: string) => void;
34
+ export declare const setEraserCursor: (canvas: HTMLCanvasElement | null, theme: AppState["theme"]) => void;
35
+ export declare const setCursorForShape: (canvas: HTMLCanvasElement | null, appState: AppState) => void;
35
36
  export declare const isFullScreen: () => boolean;
36
37
  export declare const allowFullScreen: () => Promise<void>;
37
38
  export declare const exitFullScreen: () => Promise<void>;
@@ -116,3 +117,7 @@ export declare const isTestEnv: () => boolean;
116
117
  export declare const wrapEvent: <T extends Event>(name: EVENT, nativeEvent: T) => CustomEvent<{
117
118
  nativeEvent: T;
118
119
  }>;
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";
123
+ export declare const isPromiseLike: (value: any) => value is Promise<any>;