@excalidraw/excalidraw 0.12.0-76cf560 → 0.12.0-78e254f

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 (45) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +56 -12
  3. package/dist/excalidraw.development.js +87 -43
  4. package/dist/excalidraw.production.min.js +1 -1
  5. package/package.json +1 -1
  6. package/types/actions/actionAddToLibrary.d.ts +6 -6
  7. package/types/actions/actionBoundText.d.ts +2 -2
  8. package/types/actions/actionCanvas.d.ts +16 -16
  9. package/types/actions/actionClipboard.d.ts +10 -10
  10. package/types/actions/actionDeleteSelected.d.ts +6 -6
  11. package/types/actions/actionExport.d.ts +18 -18
  12. package/types/actions/actionFinalize.d.ts +4 -4
  13. package/types/actions/actionLinearEditor.d.ts +2 -2
  14. package/types/actions/actionMenu.d.ts +6 -6
  15. package/types/actions/actionProperties.d.ts +26 -26
  16. package/types/actions/actionStyles.d.ts +2 -2
  17. package/types/actions/actionToggleGridMode.d.ts +2 -2
  18. package/types/actions/actionToggleLock.d.ts +2 -2
  19. package/types/actions/actionToggleStats.d.ts +2 -2
  20. package/types/actions/actionToggleViewMode.d.ts +2 -2
  21. package/types/actions/actionToggleZenMode.d.ts +2 -2
  22. package/types/appState.d.ts +2 -2
  23. package/types/components/App.d.ts +6 -1
  24. package/types/components/HintViewer.d.ts +3 -2
  25. package/types/components/LayerUI.d.ts +2 -1
  26. package/types/components/LibraryMenu.d.ts +14 -5
  27. package/types/components/LibraryMenuHeaderContent.d.ts +12 -0
  28. package/types/components/LibraryMenuItems.d.ts +2 -14
  29. package/types/components/LibraryUnit.d.ts +2 -3
  30. package/types/components/MobileMenu.d.ts +4 -3
  31. package/types/components/Sidebar/Sidebar.d.ts +73 -0
  32. package/types/components/Sidebar/SidebarHeader.d.ts +20 -0
  33. package/types/components/Sidebar/common.d.ts +15 -0
  34. package/types/components/hoc/withUpstreamOverride.d.ts +10 -0
  35. package/types/constants.d.ts +7 -1
  36. package/types/data/types.d.ts +16 -1
  37. package/types/element/Hyperlink.d.ts +2 -2
  38. package/types/element/image.d.ts +1 -1
  39. package/types/element/linearElementEditor.d.ts +3 -3
  40. package/types/keys.d.ts +3 -3
  41. package/types/packages/excalidraw/example/App.d.ts +2 -1
  42. package/types/packages/excalidraw/example/sidebar/{Sidebar.d.ts → ExampleSidebar.d.ts} +1 -1
  43. package/types/packages/excalidraw/index.d.ts +1 -0
  44. package/types/types.d.ts +8 -2
  45. package/types/components/SidebarLockButton.d.ts +0 -8
@@ -84,6 +84,9 @@ export declare const MIME_TYPES: {
84
84
  readonly "excalidraw.png": "image/png";
85
85
  readonly jpg: "image/jpeg";
86
86
  readonly gif: "image/gif";
87
+ readonly webp: "image/webp";
88
+ readonly bmp: "image/bmp";
89
+ readonly ico: "image/x-icon";
87
90
  readonly binary: "application/octet-stream";
88
91
  };
89
92
  export declare const EXPORT_DATA_TYPES: {
@@ -125,7 +128,7 @@ export declare const MAX_DECIMALS_FOR_SVG_EXPORT = 2;
125
128
  export declare const EXPORT_SCALES: number[];
126
129
  export declare const DEFAULT_EXPORT_PADDING = 10;
127
130
  export declare const DEFAULT_MAX_IMAGE_WIDTH_OR_HEIGHT = 1440;
128
- export declare const ALLOWED_IMAGE_MIME_TYPES: readonly ["image/png", "image/jpeg", "image/svg+xml", "image/gif"];
131
+ export declare const ALLOWED_IMAGE_MIME_TYPES: readonly ["image/png", "image/jpeg", "image/svg+xml", "image/gif", "image/webp", "image/bmp", "image/x-icon"];
129
132
  export declare const MAX_ALLOWED_FILE_BYTES: number;
130
133
  export declare const SVG_NS = "http://www.w3.org/2000/svg";
131
134
  export declare const ENCRYPTION_KEY_BITS = 128;
@@ -148,3 +151,6 @@ export declare const ELEMENT_READY_TO_ERASE_OPACITY = 20;
148
151
  export declare const COOKIES: {
149
152
  readonly AUTH_STATE_COOKIE: "excplus-auth";
150
153
  };
154
+ /** key containt id of precedeing elemnt id we use in reconciliation during
155
+ * collaboration */
156
+ export declare const PRECEDING_ELEMENT_KEY = "__precedingElement__";
@@ -10,12 +10,27 @@ export interface ExportedDataState {
10
10
  appState: ReturnType<typeof cleanAppStateForExport>;
11
11
  files: BinaryFiles | undefined;
12
12
  }
13
+ /**
14
+ * Map of legacy AppState keys, with values of:
15
+ * [<legacy type>, <new AppState proeprty>]
16
+ *
17
+ * This is a helper type used in downstream abstractions.
18
+ * Don't consume on its own.
19
+ */
20
+ export declare type LegacyAppState = {
21
+ /** @deprecated #5663 TODO remove 22-12-15 */
22
+ isLibraryOpen: [boolean, "openSidebar"];
23
+ /** @deprecated #5663 TODO remove 22-12-15 */
24
+ isLibraryMenuDocked: [boolean, "isSidebarDocked"];
25
+ };
13
26
  export interface ImportedDataState {
14
27
  type?: string;
15
28
  version?: number;
16
29
  source?: string;
17
30
  elements?: readonly ExcalidrawElement[] | null;
18
- appState?: Readonly<Partial<AppState>> | null;
31
+ appState?: Readonly<Partial<AppState & {
32
+ [T in keyof LegacyAppState]: LegacyAppState[T][0];
33
+ }>> | null;
19
34
  scrollToContent?: boolean;
20
35
  libraryItems?: LibraryItems_anyVersion;
21
36
  files?: BinaryFiles;
@@ -72,6 +72,8 @@ export declare const actionLink: {
72
72
  value: import("../types").NormalizedZoomValue;
73
73
  }>;
74
74
  openPopup: "canvasColorPicker" | "backgroundColorPicker" | "strokeColorPicker" | null;
75
+ openSidebar: "library" | "customSidebar" | null;
76
+ isSidebarDocked: boolean;
75
77
  lastPointerDownWith: import("./types").PointerType;
76
78
  selectedElementIds: {
77
79
  [id: string]: boolean;
@@ -98,8 +100,6 @@ export declare const actionLink: {
98
100
  height: number;
99
101
  offsetTop: number;
100
102
  offsetLeft: number;
101
- isLibraryOpen: boolean;
102
- isLibraryMenuDocked: boolean;
103
103
  fileHandle: import("browser-fs-access").FileSystemHandle | null;
104
104
  collaborators: Map<string, import("../types").Collaborator>;
105
105
  showStats: boolean;
@@ -10,7 +10,7 @@ export declare const updateImageCache: ({ fileIds, files, imageCache, }: {
10
10
  }) => Promise<{
11
11
  imageCache: Map<FileId, {
12
12
  image: HTMLImageElement | Promise<HTMLImageElement>;
13
- mimeType: "image/svg+xml" | "image/png" | "image/jpeg" | "image/gif";
13
+ mimeType: "image/svg+xml" | "image/png" | "image/jpeg" | "image/gif" | "image/webp" | "image/bmp" | "image/x-icon";
14
14
  }>;
15
15
  /** includes errored files because they cache was updated nonetheless */
16
16
  updatedFiles: Map<FileId, true>;
@@ -160,6 +160,8 @@ export declare class LinearElementEditor {
160
160
  }>;
161
161
  openMenu: "canvas" | "shape" | null;
162
162
  openPopup: "canvasColorPicker" | "backgroundColorPicker" | "strokeColorPicker" | null;
163
+ openSidebar: "library" | "customSidebar" | null;
164
+ isSidebarDocked: boolean;
163
165
  lastPointerDownWith: import("./types").PointerType;
164
166
  selectedElementIds: {
165
167
  [id: string]: boolean;
@@ -170,7 +172,7 @@ export declare class LinearElementEditor {
170
172
  shouldCacheIgnoreZoom: boolean;
171
173
  showHelpDialog: boolean;
172
174
  toast: {
173
- message: string; /** @returns whether point was dragged */
175
+ message: string;
174
176
  closable?: boolean | undefined;
175
177
  duration?: number | undefined;
176
178
  } | null;
@@ -186,8 +188,6 @@ export declare class LinearElementEditor {
186
188
  height: number;
187
189
  offsetTop: number;
188
190
  offsetLeft: number;
189
- isLibraryOpen: boolean;
190
- isLibraryMenuDocked: boolean;
191
191
  fileHandle: import("browser-fs-access").FileSystemHandle | null;
192
192
  collaborators: Map<string, import("../types").Collaborator>;
193
193
  showStats: boolean;
package/types/keys.d.ts CHANGED
@@ -17,11 +17,8 @@ export declare const CODES: {
17
17
  readonly SLASH: "Slash";
18
18
  readonly C: "KeyC";
19
19
  readonly D: "KeyD";
20
- readonly G: "KeyG";
21
- readonly F: "KeyF";
22
20
  readonly H: "KeyH";
23
21
  readonly V: "KeyV";
24
- readonly X: "KeyX";
25
22
  readonly Z: "KeyZ";
26
23
  readonly R: "KeyR";
27
24
  };
@@ -44,9 +41,12 @@ export declare const KEYS: {
44
41
  readonly PERIOD: ".";
45
42
  readonly COMMA: ",";
46
43
  readonly A: "a";
44
+ readonly C: "c";
47
45
  readonly D: "d";
48
46
  readonly E: "e";
47
+ readonly F: "f";
49
48
  readonly G: "g";
49
+ readonly H: "h";
50
50
  readonly I: "i";
51
51
  readonly L: "l";
52
52
  readonly O: "o";
@@ -1,7 +1,8 @@
1
+ import type * as TExcalidraw from "../index";
1
2
  import "./App.scss";
2
3
  declare global {
3
4
  interface Window {
4
- ExcalidrawLib: any;
5
+ ExcalidrawLib: typeof TExcalidraw;
5
6
  }
6
7
  }
7
8
  export default function App(): JSX.Element;
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import "./Sidebar.scss";
2
+ import "./ExampleSidebar.scss";
3
3
  export default function Sidebar({ children }: {
4
4
  children: React.ReactNode;
5
5
  }): JSX.Element;
@@ -13,3 +13,4 @@ export { FONT_FAMILY, THEME, MIME_TYPES } from "../../constants";
13
13
  export { mutateElement, newElementWith, bumpVersion, } from "../../element/mutateElement";
14
14
  export { parseLibraryTokensFromUrl, useHandleLibrary, } from "../../data/library";
15
15
  export { sceneCoordsToViewportCoords, viewportCoordsToSceneCoords, } from "../../utils";
16
+ export { Sidebar } from "../../components/Sidebar/Sidebar";
package/types/types.d.ts CHANGED
@@ -104,6 +104,8 @@ export declare type AppState = {
104
104
  zoom: Zoom;
105
105
  openMenu: "canvas" | "shape" | null;
106
106
  openPopup: "canvasColorPicker" | "backgroundColorPicker" | "strokeColorPicker" | null;
107
+ openSidebar: "library" | "customSidebar" | null;
108
+ isSidebarDocked: boolean;
107
109
  lastPointerDownWith: PointerType;
108
110
  selectedElementIds: {
109
111
  [id: string]: boolean;
@@ -133,8 +135,6 @@ export declare type AppState = {
133
135
  height: number;
134
136
  offsetTop: number;
135
137
  offsetLeft: number;
136
- isLibraryOpen: boolean;
137
- isLibraryMenuDocked: boolean;
138
138
  fileHandle: FileSystemHandle | null;
139
139
  collaborators: Map<string, Collaborator>;
140
140
  showStats: boolean;
@@ -237,6 +237,10 @@ export interface ExcalidrawProps {
237
237
  }>) => void;
238
238
  onPointerDown?: (activeTool: AppState["activeTool"], pointerDownState: PointerDownState) => void;
239
239
  onScrollChange?: (scrollX: number, scrollY: number) => void;
240
+ /**
241
+ * Render function that renders custom <Sidebar /> component.
242
+ */
243
+ renderSidebar?: () => JSX.Element | null;
240
244
  }
241
245
  export declare type SceneData = {
242
246
  elements?: ImportedDataState["elements"];
@@ -273,6 +277,7 @@ export declare type AppProps = Merge<ExcalidrawProps, {
273
277
  detectScroll: boolean;
274
278
  handleKeyboardGlobally: boolean;
275
279
  isCollaborating: boolean;
280
+ children?: React.ReactNode;
276
281
  }>;
277
282
  /** A subset of App class properties that we need to use elsewhere
278
283
  * in the app, eg Manager. Factored out into a separate type to keep DRY. */
@@ -369,6 +374,7 @@ export declare type ExcalidrawImperativeAPI = {
369
374
  setActiveTool: InstanceType<typeof App>["setActiveTool"];
370
375
  setCursor: InstanceType<typeof App>["setCursor"];
371
376
  resetCursor: InstanceType<typeof App>["resetCursor"];
377
+ toggleMenu: InstanceType<typeof App>["toggleMenu"];
372
378
  };
373
379
  export declare type Device = Readonly<{
374
380
  isSmScreen: boolean;
@@ -1,8 +0,0 @@
1
- import "./ToolIcon.scss";
2
- import "./SidebarLockButton.scss";
3
- declare type SidebarLockIconProps = {
4
- checked: boolean;
5
- onChange?(): void;
6
- };
7
- export declare const SidebarLockButton: (props: SidebarLockIconProps) => JSX.Element;
8
- export {};