@zsviczian/excalidraw 0.9.0-obsidian-13 → 0.9.0-obsidian-image-support-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 (48) hide show
  1. package/CHANGELOG.md +61 -8
  2. package/README.md +1 -1
  3. package/dist/excalidraw-assets-dev/{image-7e0eecf06fd4ae95db83.js → image-4d82da8a5abfcee0a489.js} +1 -1
  4. package/dist/excalidraw.development.js +129 -64
  5. package/dist/excalidraw.production.min.js +1 -1
  6. package/dist/excalidraw.production.min.js.LICENSE.txt +22 -0
  7. package/package.json +1 -1
  8. package/types/actions/actionCanvas.d.ts +4 -2
  9. package/types/actions/manager.d.ts +3 -11
  10. package/types/actions/types.d.ts +2 -8
  11. package/types/appState.d.ts +10 -4
  12. package/types/clipboard.d.ts +1 -0
  13. package/types/components/Actions.d.ts +5 -2
  14. package/types/components/App.d.ts +21 -5
  15. package/types/components/DarkModeToggle.d.ts +3 -3
  16. package/types/components/InitializeApp.d.ts +2 -10
  17. package/types/components/LayerUI.d.ts +4 -1
  18. package/types/components/LibraryUnit.d.ts +3 -2
  19. package/types/components/MobileMenu.d.ts +4 -1
  20. package/types/components/ToolButton.d.ts +5 -2
  21. package/types/components/icons.d.ts +41 -40
  22. package/types/constants.d.ts +8 -0
  23. package/types/data/blob.d.ts +13 -2
  24. package/types/data/encode.d.ts +29 -1
  25. package/types/data/json.d.ts +1 -1
  26. package/types/element/collision.d.ts +2 -2
  27. package/types/element/dragElements.d.ts +1 -1
  28. package/types/element/index.d.ts +2 -1
  29. package/types/element/mutateElement.d.ts +1 -1
  30. package/types/element/newElement.d.ts +4 -1
  31. package/types/element/resizeElements.d.ts +3 -3
  32. package/types/element/typeChecks.d.ts +3 -1
  33. package/types/element/types.d.ts +16 -3
  34. package/types/keys.d.ts +4 -3
  35. package/types/packages/excalidraw/dist/excalidraw-assets-dev/image-4d82da8a5abfcee0a489.d.ts +0 -0
  36. package/types/packages/excalidraw/index.d.ts +1 -1
  37. package/types/packages/excalidraw/webpack.prod.config.d.ts +3 -1
  38. package/types/packages/utils.d.ts +1 -1
  39. package/types/renderer/renderElement.d.ts +3 -2
  40. package/types/renderer/renderScene.d.ts +3 -2
  41. package/types/scene/export.d.ts +2 -1
  42. package/types/scene/types.d.ts +3 -2
  43. package/types/shapes.d.ts +5 -1
  44. package/types/types.d.ts +29 -4
  45. package/types/utils.d.ts +1 -0
  46. package/types/zindex.d.ts +2 -2
  47. package/dist/excalidraw-assets-dev/image-bd6a627ff1bbdbae8366.js +0 -32
  48. package/dist/excalidraw-assets-dev/vendor-ac67d7e09cdab8faffe3.js +0 -323
@@ -1 +1,23 @@
1
+ /*
2
+ object-assign
3
+ (c) Sindre Sorhus
4
+ @license MIT
5
+ */
6
+
7
+ /*!
8
+
9
+ pica
10
+ https://github.com/nodeca/pica
11
+
12
+ */
13
+
14
+ /** @license React v17.0.2
15
+ * react-jsx-runtime.production.min.js
16
+ *
17
+ * Copyright (c) Facebook, Inc. and its affiliates.
18
+ *
19
+ * This source code is licensed under the MIT license found in the
20
+ * LICENSE file in the root directory of this source tree.
21
+ */
22
+
1
23
  // @license © 2020 Google LLC. Licensed under the Apache License, Version 2.0.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zsviczian/excalidraw",
3
- "version": "0.9.0-obsidian-13",
3
+ "version": "0.9.0-obsidian-image-support-9",
4
4
  "main": "main.js",
5
5
  "types": "types/packages/excalidraw/index.d.ts",
6
6
  "files": [
@@ -16,6 +16,7 @@ export declare const zoomToFitElements: (elements: readonly ExcalidrawElement[],
16
16
  }>;
17
17
  scrollX: number;
18
18
  scrollY: number;
19
+ files: Record<string, import("../types").BinaryFileData>;
19
20
  isLoading: boolean;
20
21
  errorMessage: string | null;
21
22
  draggingElement: import("../element/types").NonDeletedExcalidrawElement | null;
@@ -27,7 +28,7 @@ export declare const zoomToFitElements: (elements: readonly ExcalidrawElement[],
27
28
  suggestedBindings: import("../element/binding").SuggestedBinding[];
28
29
  editingElement: import("../element/types").NonDeletedExcalidrawElement | null;
29
30
  editingLinearElement: import("../element/linearElementEditor").LinearElementEditor | null;
30
- elementType: "line" | "selection" | "rectangle" | "diamond" | "ellipse" | "text" | "arrow" | "freedraw";
31
+ elementType: "line" | "selection" | "rectangle" | "diamond" | "ellipse" | "image" | "text" | "arrow" | "freedraw";
31
32
  elementLocked: boolean;
32
33
  exportBackground: boolean;
33
34
  exportEmbedScene: boolean;
@@ -66,7 +67,7 @@ export declare const zoomToFitElements: (elements: readonly ExcalidrawElement[],
66
67
  showHelpDialog: boolean;
67
68
  toastMessage: string | null;
68
69
  zenModeEnabled: boolean;
69
- theme: "light" | "dark";
70
+ theme: string;
70
71
  gridSize: number | null;
71
72
  viewModeEnabled: boolean;
72
73
  selectedGroupIds: {
@@ -89,6 +90,7 @@ export declare const zoomToFitElements: (elements: readonly ExcalidrawElement[],
89
90
  shown: true;
90
91
  data: import("../charts").Spreadsheet;
91
92
  };
93
+ pendingImageElement: import("../element/types").NonDeleted<import("../element/types").ExcalidrawImageElement> | null;
92
94
  };
93
95
  commitToHistory: boolean;
94
96
  };
@@ -1,21 +1,14 @@
1
1
  import React from "react";
2
2
  import { Action, ActionsManagerInterface, UpdaterFn, ActionName, ActionResult, PanelComponentProps } from "./types";
3
3
  import { ExcalidrawElement } from "../element/types";
4
- import { AppProps, AppState } from "../types";
5
- import Library from "../data/library";
6
- declare type App = {
7
- canvas: HTMLCanvasElement | null;
8
- focusContainer: () => void;
9
- props: AppProps;
10
- library: Library;
11
- };
4
+ import { AppClassProperties, AppState } from "../types";
12
5
  export declare class ActionManager implements ActionsManagerInterface {
13
6
  actions: Record<ActionName, Action>;
14
7
  updater: (actionResult: ActionResult | Promise<ActionResult>) => void;
15
8
  getAppState: () => Readonly<AppState>;
16
9
  getElementsIncludingDeleted: () => readonly ExcalidrawElement[];
17
- app: App;
18
- constructor(updater: UpdaterFn, getAppState: () => AppState, getElementsIncludingDeleted: () => readonly ExcalidrawElement[], app: App);
10
+ app: AppClassProperties;
11
+ constructor(updater: UpdaterFn, getAppState: () => AppState, getElementsIncludingDeleted: () => readonly ExcalidrawElement[], app: AppClassProperties);
19
12
  registerAction(action: Action): void;
20
13
  registerAll(actions: readonly Action[]): void;
21
14
  handleKeyDown(event: React.KeyboardEvent | KeyboardEvent): boolean;
@@ -25,4 +18,3 @@ export declare class ActionManager implements ActionsManagerInterface {
25
18
  */
26
19
  renderAction: (name: ActionName, data?: PanelComponentProps["data"]) => JSX.Element | null;
27
20
  }
28
- export {};
@@ -1,7 +1,6 @@
1
1
  import React from "react";
2
2
  import { ExcalidrawElement } from "../element/types";
3
- import { AppState, ExcalidrawProps } from "../types";
4
- import Library from "../data/library";
3
+ import { AppClassProperties, AppState, ExcalidrawProps } from "../types";
5
4
  import { ToolButtonSize } from "../components/ToolButton";
6
5
  /** if false, the action should be prevented */
7
6
  export declare type ActionResult = {
@@ -10,12 +9,7 @@ export declare type ActionResult = {
10
9
  commitToHistory: boolean;
11
10
  syncHistory?: boolean;
12
11
  } | false;
13
- declare type AppAPI = {
14
- canvas: HTMLCanvasElement | null;
15
- focusContainer(): void;
16
- library: Library;
17
- };
18
- declare type ActionFn = (elements: readonly ExcalidrawElement[], appState: Readonly<AppState>, formData: any, app: AppAPI) => ActionResult | Promise<ActionResult>;
12
+ declare type ActionFn = (elements: readonly ExcalidrawElement[], appState: Readonly<AppState>, formData: any, app: AppClassProperties) => ActionResult | Promise<ActionResult>;
19
13
  export declare type UpdaterFn = (res: ActionResult) => void;
20
14
  export declare type ActionFilterFn = (action: Action) => void;
21
15
  export declare type ActionName = "copy" | "cut" | "paste" | "copyAsPng" | "copyAsSvg" | "sendBackward" | "bringForward" | "sendToBack" | "bringToFront" | "copyStyles" | "selectAll" | "pasteStyles" | "gridMode" | "zenMode" | "stats" | "changeStrokeColor" | "changeBackgroundColor" | "changeFillStyle" | "changeStrokeWidth" | "changeStrokeShape" | "changeSloppiness" | "changeStrokeStyle" | "changeArrowhead" | "changeOpacity" | "changeFontSize" | "toggleCanvasMenu" | "toggleEditMenu" | "undo" | "redo" | "finalize" | "changeProjectName" | "changeExportBackground" | "changeExportEmbedScene" | "changeExportScale" | "saveToActiveFile" | "saveFileToDisk" | "loadScene" | "duplicateSelection" | "deleteSelectedElements" | "changeViewBackgroundColor" | "clearCanvas" | "zoomIn" | "zoomOut" | "resetZoom" | "zoomToFit" | "zoomToSelection" | "changeFontFamily" | "changeTextAlign" | "toggleFullScreen" | "toggleShortcuts" | "group" | "ungroup" | "goToCollaborator" | "addToLibrary" | "changeSharpness" | "alignTop" | "alignBottom" | "alignLeft" | "alignRight" | "alignVerticallyCentered" | "alignHorizontallyCentered" | "distributeHorizontally" | "distributeVertically" | "flipHorizontal" | "flipVertical" | "viewMode" | "exportWithDarkMode" | "toggleTheme";
@@ -1,6 +1,8 @@
1
+ import { ExcalidrawElement } from "./element/types";
1
2
  import { AppState, NormalizedZoomValue } from "./types";
2
3
  export declare const getDefaultAppState: () => Omit<AppState, "offsetTop" | "offsetLeft" | "width" | "height">;
3
- export declare const clearAppStateForLocalStorage: (appState: Partial<AppState>) => {
4
+ export declare const clearAppStateForLocalStorage: (appState: Partial<AppState>, elements: readonly ExcalidrawElement[]) => {
5
+ theme?: string | undefined;
4
6
  zoom?: Readonly<{
5
7
  value: NormalizedZoomValue;
6
8
  translation: Readonly<{
@@ -10,7 +12,7 @@ export declare const clearAppStateForLocalStorage: (appState: Partial<AppState>)
10
12
  }> | undefined;
11
13
  scrollX?: number | undefined;
12
14
  scrollY?: number | undefined;
13
- elementType?: "line" | "selection" | "rectangle" | "diamond" | "ellipse" | "text" | "arrow" | "freedraw" | undefined;
15
+ elementType?: "line" | "selection" | "rectangle" | "diamond" | "ellipse" | "image" | "text" | "arrow" | "freedraw" | undefined;
14
16
  elementLocked?: boolean | undefined;
15
17
  exportBackground?: boolean | undefined;
16
18
  exportEmbedScene?: boolean | undefined;
@@ -44,7 +46,6 @@ export declare const clearAppStateForLocalStorage: (appState: Partial<AppState>)
44
46
  } | undefined;
45
47
  shouldCacheIgnoreZoom?: boolean | undefined;
46
48
  zenModeEnabled?: boolean | undefined;
47
- theme?: "light" | "dark" | undefined;
48
49
  gridSize?: number | null | undefined;
49
50
  selectedGroupIds?: {
50
51
  [groupId: string]: boolean;
@@ -53,7 +54,12 @@ export declare const clearAppStateForLocalStorage: (appState: Partial<AppState>)
53
54
  showStats?: boolean | undefined;
54
55
  currentChartType?: import("./element/types").ChartType | undefined;
55
56
  };
56
- export declare const cleanAppStateForExport: (appState: Partial<AppState>) => {
57
+ export declare const cleanAppStateForExport: (appState: Partial<AppState>, elements: readonly ExcalidrawElement[]) => {
58
+ files?: Record<string, import("./types").BinaryFileData> | undefined;
59
+ viewBackgroundColor?: string | undefined;
60
+ gridSize?: number | null | undefined;
61
+ };
62
+ export declare const clearAppStateForDatabase: (appState: Partial<AppState>, elements: readonly ExcalidrawElement[]) => {
57
63
  viewBackgroundColor?: string | undefined;
58
64
  gridSize?: number | null | undefined;
59
65
  };
@@ -4,6 +4,7 @@ import { Spreadsheet } from "./charts";
4
4
  export interface ClipboardData {
5
5
  spreadsheet?: Spreadsheet;
6
6
  elements?: readonly ExcalidrawElement[];
7
+ files?: AppState["files"];
7
8
  text?: string;
8
9
  errorMessage?: string;
9
10
  }
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
  import { ActionManager } from "../actions/manager";
3
- import { ExcalidrawElement } from "../element/types";
3
+ import { ExcalidrawElement, PointerType } from "../element/types";
4
4
  import { AppState, Zoom } from "../types";
5
5
  export declare const SelectedShapeActions: ({ appState, elements, renderAction, elementType, }: {
6
6
  appState: AppState;
@@ -8,10 +8,13 @@ export declare const SelectedShapeActions: ({ appState, elements, renderAction,
8
8
  renderAction: ActionManager["renderAction"];
9
9
  elementType: ExcalidrawElement["type"];
10
10
  }) => JSX.Element;
11
- export declare const ShapesSwitcher: ({ canvas, elementType, setAppState, }: {
11
+ export declare const ShapesSwitcher: ({ canvas, elementType, setAppState, onImageAction, }: {
12
12
  canvas: HTMLCanvasElement | null;
13
13
  elementType: ExcalidrawElement["type"];
14
14
  setAppState: React.Component<any, AppState>["setState"];
15
+ onImageAction: (data: {
16
+ pointerType: PointerType | null;
17
+ }) => void;
15
18
  }) => JSX.Element;
16
19
  export declare const ZoomActions: ({ renderAction, zoom, }: {
17
20
  renderAction: ActionManager["renderAction"];
@@ -1,17 +1,16 @@
1
1
  import React from "react";
2
2
  import { RoughCanvas } from "roughjs/bin/canvas";
3
3
  import { ActionManager } from "../actions/manager";
4
- import Library from "../data/library";
5
4
  import { ExcalidrawElement } from "../element/types";
6
5
  import History from "../history";
7
- import { AppProps, AppState, LibraryItems, SceneData } from "../types";
6
+ import { AppClassProperties, AppProps, AppState, ExcalidrawImperativeAPI, LibraryItems, SceneData } from "../types";
8
7
  export declare const useIsMobile: () => boolean;
9
8
  export declare const useExcalidrawContainer: () => {
10
9
  container: HTMLDivElement | null;
11
10
  id: string | null;
12
11
  };
13
12
  declare class App extends React.Component<AppProps, AppState> {
14
- canvas: HTMLCanvasElement | null;
13
+ canvas: AppClassProperties["canvas"];
15
14
  rc: RoughCanvas | null;
16
15
  unmounted: boolean;
17
16
  actionManager: ActionManager;
@@ -22,15 +21,16 @@ declare class App extends React.Component<AppProps, AppState> {
22
21
  private scene;
23
22
  private resizeObserver;
24
23
  private nearestScrollableContainer;
25
- library: Library;
24
+ library: AppClassProperties["library"];
26
25
  libraryItemsFromStorage: LibraryItems | undefined;
27
26
  private id;
28
27
  private history;
29
28
  private excalidrawContainerValue;
29
+ imageCache: AppClassProperties["imageCache"];
30
30
  constructor(props: AppProps);
31
31
  private renderCanvas;
32
32
  render(): JSX.Element;
33
- focusContainer: () => void;
33
+ focusContainer: AppClassProperties["focusContainer"];
34
34
  getSceneElementsIncludingDeleted: () => readonly ExcalidrawElement[];
35
35
  getSceneElements: () => readonly import("../element/types").NonDeletedExcalidrawElement[];
36
36
  private syncActionResult;
@@ -73,6 +73,8 @@ declare class App extends React.Component<AppProps, AppState> {
73
73
  clearToast: () => void;
74
74
  setToastMessage: (toastMessage: string) => void;
75
75
  restoreFileFromShare: () => Promise<void>;
76
+ /** adds supplied files to existing files in the appState */
77
+ addFiles: ExcalidrawImperativeAPI["addFiles"];
76
78
  updateScene: <K extends keyof AppState>(sceneData: {
77
79
  elements?: SceneData["elements"];
78
80
  appState?: Pick<AppState, K> | null | undefined;
@@ -112,6 +114,7 @@ declare class App extends React.Component<AppProps, AppState> {
112
114
  private isHittingCommonBoundingBoxOfSelectedElements;
113
115
  private handleTextOnPointerDown;
114
116
  private handleFreeDrawElementOnPointerDown;
117
+ private createImageElement;
115
118
  private handleLinearElementOnPointerDown;
116
119
  private createGenericElementOnPointerDown;
117
120
  private onKeyDownFromPointerDownHandler;
@@ -119,6 +122,19 @@ declare class App extends React.Component<AppProps, AppState> {
119
122
  private onPointerMoveFromPointerDownHandler;
120
123
  private handlePointerMoveOverScrollbars;
121
124
  private onPointerUpFromPointerDownHandler;
125
+ private initializeImage;
126
+ /**
127
+ * inserts image into elements array and rerenders
128
+ */
129
+ private insertImageElement;
130
+ private setImagePreviewCursor;
131
+ private onImageAction;
132
+ private initializeImageDimensions;
133
+ /** populates image cache and re-renders if needed */
134
+ private refreshImages;
135
+ /** generally you should use `refreshImages()` directly if you need to render
136
+ * new images. This is just a failsafe */
137
+ private scheduleImageRefresh;
122
138
  private updateBindingEnabledOnPointerMove;
123
139
  private maybeSuggestBindingAtCursor;
124
140
  private maybeSuggestBindingForLinearElementAtCursor;
@@ -1,8 +1,8 @@
1
1
  /// <reference types="react" />
2
2
  import "./ToolIcon.scss";
3
- export declare type Appearence = "light" | "dark";
3
+ import { Theme } from "../element/types";
4
4
  export declare const DarkModeToggle: (props: {
5
- value: Appearence;
6
- onChange: (value: Appearence) => void;
5
+ value: Theme;
6
+ onChange: (value: Theme) => void;
7
7
  title?: string | undefined;
8
8
  }) => JSX.Element;
@@ -2,15 +2,7 @@ import React from "react";
2
2
  import { Language } from "../i18n";
3
3
  interface Props {
4
4
  langCode: Language["code"];
5
+ children: React.ReactElement;
5
6
  }
6
- interface State {
7
- isLoading: boolean;
8
- }
9
- export declare class InitializeApp extends React.Component<Props, State> {
10
- state: {
11
- isLoading: boolean;
12
- };
13
- componentDidMount(): Promise<void>;
14
- render(): React.ReactNode;
15
- }
7
+ export declare const InitializeApp: (props: Props) => JSX.Element;
16
8
  export {};
@@ -28,6 +28,9 @@ interface LayerUIProps {
28
28
  focusContainer: () => void;
29
29
  library: Library;
30
30
  id: string;
31
+ onImageAction: (data: {
32
+ insertOnCanvasDirectly: boolean;
33
+ }) => void;
31
34
  }
32
- declare const _default: React.MemoExoticComponent<({ actionManager, appState, setAppState, canvas, elements, onCollabButtonClick, onLockToggle, onInsertElements, zenModeEnabled, showExitZenModeBtn, showThemeBtn, toggleZenMode, isCollaborating, renderTopRightUI, renderCustomFooter, viewModeEnabled, libraryReturnUrl, UIOptions, focusContainer, library, id, }: LayerUIProps) => JSX.Element>;
35
+ declare const _default: React.MemoExoticComponent<({ actionManager, appState, setAppState, canvas, elements, onCollabButtonClick, onLockToggle, onInsertElements, zenModeEnabled, showExitZenModeBtn, showThemeBtn, toggleZenMode, isCollaborating, renderTopRightUI, renderCustomFooter, viewModeEnabled, libraryReturnUrl, UIOptions, focusContainer, library, id, onImageAction, }: LayerUIProps) => JSX.Element>;
33
36
  export default _default;
@@ -1,8 +1,9 @@
1
1
  /// <reference types="react" />
2
- import { LibraryItem } from "../types";
2
+ import { AppState, LibraryItem } from "../types";
3
3
  import "./LibraryUnit.scss";
4
- export declare const LibraryUnit: ({ elements, pendingElements, onRemoveFromLibrary, onClick, }: {
4
+ export declare const LibraryUnit: ({ elements, files, pendingElements, onRemoveFromLibrary, onClick, }: {
5
5
  elements?: LibraryItem | undefined;
6
+ files: AppState["files"];
6
7
  pendingElements?: LibraryItem | undefined;
7
8
  onRemoveFromLibrary: () => void;
8
9
  onClick: () => void;
@@ -17,6 +17,9 @@ declare type MobileMenuProps = {
17
17
  renderCustomFooter?: (isMobile: boolean, appState: AppState) => JSX.Element;
18
18
  viewModeEnabled: boolean;
19
19
  showThemeBtn: boolean;
20
+ onImageAction: (data: {
21
+ insertOnCanvasDirectly: boolean;
22
+ }) => void;
20
23
  };
21
- export declare const MobileMenu: ({ appState, elements, libraryMenu, actionManager, renderJSONExportDialog, renderImageExportDialog, setAppState, onCollabButtonClick, onLockToggle, canvas, isCollaborating, renderCustomFooter, viewModeEnabled, showThemeBtn, }: MobileMenuProps) => JSX.Element;
24
+ export declare const MobileMenu: ({ appState, elements, libraryMenu, actionManager, renderJSONExportDialog, renderImageExportDialog, setAppState, onCollabButtonClick, onLockToggle, canvas, isCollaborating, renderCustomFooter, viewModeEnabled, showThemeBtn, onImageAction, }: MobileMenuProps) => JSX.Element;
22
25
  export {};
@@ -1,5 +1,6 @@
1
1
  import "./ToolIcon.scss";
2
2
  import React from "react";
3
+ import { PointerType } from "../element/types";
3
4
  export declare type ToolButtonSize = "small" | "medium";
4
5
  declare type ToolButtonBaseProps = {
5
6
  icon?: React.ReactNode;
@@ -21,7 +22,7 @@ declare type ToolButtonBaseProps = {
21
22
  declare type ToolButtonProps = (ToolButtonBaseProps & {
22
23
  type: "button";
23
24
  children?: React.ReactNode;
24
- onClick?(): void;
25
+ onClick?(event: React.MouseEvent): void;
25
26
  }) | (ToolButtonBaseProps & {
26
27
  type: "icon";
27
28
  children?: React.ReactNode;
@@ -29,7 +30,9 @@ declare type ToolButtonProps = (ToolButtonBaseProps & {
29
30
  }) | (ToolButtonBaseProps & {
30
31
  type: "radio";
31
32
  checked: boolean;
32
- onChange?(): void;
33
+ onChange?(data: {
34
+ pointerType: PointerType | null;
35
+ }): void;
33
36
  });
34
37
  export declare const ToolButton: React.ForwardRefExoticComponent<ToolButtonProps & React.RefAttributes<unknown>>;
35
38
  export {};
@@ -1,4 +1,5 @@
1
1
  import React from "react";
2
+ import { Theme } from "../element/types";
2
3
  declare type Opts = {
3
4
  width?: number;
4
5
  height?: number;
@@ -28,40 +29,40 @@ export declare const shareIOS: JSX.Element;
28
29
  export declare const shareWindows: JSX.Element;
29
30
  export declare const resetZoom: JSX.Element;
30
31
  export declare const BringForwardIcon: React.MemoExoticComponent<({ theme }: {
31
- theme: "light" | "dark";
32
+ theme: Theme;
32
33
  }) => JSX.Element>;
33
34
  export declare const SendBackwardIcon: React.MemoExoticComponent<({ theme }: {
34
- theme: "light" | "dark";
35
+ theme: Theme;
35
36
  }) => JSX.Element>;
36
37
  export declare const BringToFrontIcon: React.MemoExoticComponent<({ theme }: {
37
- theme: "light" | "dark";
38
+ theme: Theme;
38
39
  }) => JSX.Element>;
39
40
  export declare const SendToBackIcon: React.MemoExoticComponent<({ theme }: {
40
- theme: "light" | "dark";
41
+ theme: Theme;
41
42
  }) => JSX.Element>;
42
43
  export declare const AlignTopIcon: React.MemoExoticComponent<({ theme }: {
43
- theme: "light" | "dark";
44
+ theme: Theme;
44
45
  }) => JSX.Element>;
45
46
  export declare const AlignBottomIcon: React.MemoExoticComponent<({ theme }: {
46
- theme: "light" | "dark";
47
+ theme: Theme;
47
48
  }) => JSX.Element>;
48
49
  export declare const AlignLeftIcon: React.MemoExoticComponent<({ theme }: {
49
- theme: "light" | "dark";
50
+ theme: Theme;
50
51
  }) => JSX.Element>;
51
52
  export declare const AlignRightIcon: React.MemoExoticComponent<({ theme }: {
52
- theme: "light" | "dark";
53
+ theme: Theme;
53
54
  }) => JSX.Element>;
54
55
  export declare const DistributeHorizontallyIcon: React.MemoExoticComponent<({ theme }: {
55
- theme: "light" | "dark";
56
+ theme: Theme;
56
57
  }) => JSX.Element>;
57
58
  export declare const DistributeVerticallyIcon: React.MemoExoticComponent<({ theme }: {
58
- theme: "light" | "dark";
59
+ theme: Theme;
59
60
  }) => JSX.Element>;
60
61
  export declare const CenterVerticallyIcon: React.MemoExoticComponent<({ theme }: {
61
- theme: "light" | "dark";
62
+ theme: Theme;
62
63
  }) => JSX.Element>;
63
64
  export declare const CenterHorizontallyIcon: React.MemoExoticComponent<({ theme }: {
64
- theme: "light" | "dark";
65
+ theme: Theme;
65
66
  }) => JSX.Element>;
66
67
  export declare const users: JSX.Element;
67
68
  export declare const start: JSX.Element;
@@ -72,91 +73,91 @@ export declare const clone: JSX.Element;
72
73
  export declare const shield: JSX.Element;
73
74
  export declare const file: JSX.Element;
74
75
  export declare const GroupIcon: React.MemoExoticComponent<({ theme }: {
75
- theme: "light" | "dark";
76
+ theme: Theme;
76
77
  }) => JSX.Element>;
77
78
  export declare const UngroupIcon: React.MemoExoticComponent<({ theme }: {
78
- theme: "light" | "dark";
79
+ theme: Theme;
79
80
  }) => JSX.Element>;
80
81
  export declare const FillHachureIcon: React.MemoExoticComponent<({ theme }: {
81
- theme: "light" | "dark";
82
+ theme: Theme;
82
83
  }) => JSX.Element>;
83
84
  export declare const FillCrossHatchIcon: React.MemoExoticComponent<({ theme }: {
84
- theme: "light" | "dark";
85
+ theme: Theme;
85
86
  }) => JSX.Element>;
86
87
  export declare const FillSolidIcon: React.MemoExoticComponent<({ theme }: {
87
- theme: "light" | "dark";
88
+ theme: Theme;
88
89
  }) => JSX.Element>;
89
90
  export declare const StrokeWidthIcon: React.MemoExoticComponent<({ theme, strokeWidth }: {
90
- theme: "light" | "dark";
91
+ theme: Theme;
91
92
  strokeWidth: number;
92
93
  }) => JSX.Element>;
93
94
  export declare const StrokeStyleSolidIcon: React.MemoExoticComponent<({ theme }: {
94
- theme: "light" | "dark";
95
+ theme: Theme;
95
96
  }) => JSX.Element>;
96
97
  export declare const StrokeStyleDashedIcon: React.MemoExoticComponent<({ theme }: {
97
- theme: "light" | "dark";
98
+ theme: Theme;
98
99
  }) => JSX.Element>;
99
100
  export declare const StrokeStyleDottedIcon: React.MemoExoticComponent<({ theme }: {
100
- theme: "light" | "dark";
101
+ theme: Theme;
101
102
  }) => JSX.Element>;
102
103
  export declare const SloppinessArchitectIcon: React.MemoExoticComponent<({ theme }: {
103
- theme: "light" | "dark";
104
+ theme: Theme;
104
105
  }) => JSX.Element>;
105
106
  export declare const SloppinessArtistIcon: React.MemoExoticComponent<({ theme }: {
106
- theme: "light" | "dark";
107
+ theme: Theme;
107
108
  }) => JSX.Element>;
108
109
  export declare const SloppinessCartoonistIcon: React.MemoExoticComponent<({ theme }: {
109
- theme: "light" | "dark";
110
+ theme: Theme;
110
111
  }) => JSX.Element>;
111
112
  export declare const EdgeSharpIcon: React.MemoExoticComponent<({ theme }: {
112
- theme: "light" | "dark";
113
+ theme: Theme;
113
114
  }) => JSX.Element>;
114
115
  export declare const EdgeRoundIcon: React.MemoExoticComponent<({ theme }: {
115
- theme: "light" | "dark";
116
+ theme: Theme;
116
117
  }) => JSX.Element>;
117
118
  export declare const ArrowheadNoneIcon: React.MemoExoticComponent<({ theme }: {
118
- theme: "light" | "dark";
119
+ theme: Theme;
119
120
  }) => JSX.Element>;
120
121
  export declare const ArrowheadArrowIcon: React.MemoExoticComponent<({ theme, flip }: {
121
- theme: "light" | "dark";
122
+ theme: Theme;
122
123
  flip?: boolean | undefined;
123
124
  }) => JSX.Element>;
124
125
  export declare const ArrowheadDotIcon: React.MemoExoticComponent<({ theme, flip }: {
125
- theme: "light" | "dark";
126
+ theme: Theme;
126
127
  flip?: boolean | undefined;
127
128
  }) => JSX.Element>;
128
129
  export declare const ArrowheadBarIcon: React.MemoExoticComponent<({ theme, flip }: {
129
- theme: "light" | "dark";
130
+ theme: Theme;
130
131
  flip?: boolean | undefined;
131
132
  }) => JSX.Element>;
132
133
  export declare const FontSizeSmallIcon: React.MemoExoticComponent<({ theme }: {
133
- theme: "light" | "dark";
134
+ theme: Theme;
134
135
  }) => JSX.Element>;
135
136
  export declare const FontSizeMediumIcon: React.MemoExoticComponent<({ theme }: {
136
- theme: "light" | "dark";
137
+ theme: Theme;
137
138
  }) => JSX.Element>;
138
139
  export declare const FontSizeLargeIcon: React.MemoExoticComponent<({ theme }: {
139
- theme: "light" | "dark";
140
+ theme: Theme;
140
141
  }) => JSX.Element>;
141
142
  export declare const FontSizeExtraLargeIcon: React.MemoExoticComponent<({ theme }: {
142
- theme: "light" | "dark";
143
+ theme: Theme;
143
144
  }) => JSX.Element>;
144
145
  export declare const FontFamilyHandDrawnIcon: React.MemoExoticComponent<({ theme }: {
145
- theme: "light" | "dark";
146
+ theme: Theme;
146
147
  }) => JSX.Element>;
147
148
  export declare const FontFamilyNormalIcon: React.MemoExoticComponent<({ theme }: {
148
- theme: "light" | "dark";
149
+ theme: Theme;
149
150
  }) => JSX.Element>;
150
151
  export declare const FontFamilyCodeIcon: React.MemoExoticComponent<({ theme }: {
151
- theme: "light" | "dark";
152
+ theme: Theme;
152
153
  }) => JSX.Element>;
153
154
  export declare const TextAlignLeftIcon: React.MemoExoticComponent<({ theme }: {
154
- theme: "light" | "dark";
155
+ theme: Theme;
155
156
  }) => JSX.Element>;
156
157
  export declare const TextAlignCenterIcon: React.MemoExoticComponent<({ theme }: {
157
- theme: "light" | "dark";
158
+ theme: Theme;
158
159
  }) => JSX.Element>;
159
160
  export declare const TextAlignRightIcon: React.MemoExoticComponent<({ theme }: {
160
- theme: "light" | "dark";
161
+ theme: Theme;
161
162
  }) => JSX.Element>;
162
163
  export {};
@@ -61,6 +61,10 @@ export declare const FONT_FAMILY: {
61
61
  Helvetica: number;
62
62
  Cascadia: number;
63
63
  };
64
+ export declare const THEME: {
65
+ LIGHT: string;
66
+ DARK: string;
67
+ };
64
68
  export declare const WINDOWS_EMOJI_FALLBACK_FONT = "Segoe UI Emoji";
65
69
  export declare const DEFAULT_FONT_SIZE = 20;
66
70
  export declare const DEFAULT_FONT_FAMILY: FontFamilyValues;
@@ -82,6 +86,7 @@ export declare const EXPORT_SOURCE: string;
82
86
  export declare const STORAGE_KEYS: {
83
87
  readonly LOCAL_STORAGE_LIBRARY: "excalidraw-library";
84
88
  };
89
+ export declare const IMAGE_RENDER_TIMEOUT = 500;
85
90
  export declare const TAP_TWICE_TIMEOUT = 300;
86
91
  export declare const TOUCH_CTX_MENU_TIMEOUT = 500;
87
92
  export declare const TITLE_TIMEOUT = 10000;
@@ -110,3 +115,6 @@ export declare const MQ_MAX_HEIGHT_LANDSCAPE = 500;
110
115
  export declare const MAX_DECIMALS_FOR_SVG_EXPORT = 2;
111
116
  export declare const EXPORT_SCALES: number[];
112
117
  export declare const DEFAULT_EXPORT_PADDING = 10;
118
+ export declare const DEFAULT_MAX_IMAGE_WIDTH_OR_HEIGHT = 1440;
119
+ export declare const ALLOWED_IMAGE_MIME_TYPES: readonly ["image/png", "image/jpeg", "image/svg+xml"];
120
+ export declare const MAX_ALLOWED_FILE_BYTES: number;
@@ -1,11 +1,22 @@
1
- import { ExcalidrawElement } from "../element/types";
2
- import { AppState } from "../types";
1
+ import { ALLOWED_IMAGE_MIME_TYPES } from "../constants";
2
+ import { ExcalidrawElement, FileId } from "../element/types";
3
+ import { AppState, DataURL } from "../types";
3
4
  import { FileSystemHandle } from "./filesystem";
4
5
  import { ImportedLibraryData } from "./types";
5
6
  export declare const getMimeType: (blob: Blob | string) => string;
6
7
  export declare const getFileHandleType: (handle: FileSystemHandle | null) => string | null;
7
8
  export declare const isImageFileHandleType: (type: string | null) => type is "svg" | "png";
8
9
  export declare const isImageFileHandle: (handle: FileSystemHandle | null) => boolean;
10
+ export declare const isSupportedImageFile: (blob: Blob | null | undefined) => blob is Blob & {
11
+ type: typeof ALLOWED_IMAGE_MIME_TYPES[number];
12
+ };
9
13
  export declare const loadFromBlob: (blob: Blob, localAppState: AppState | null, localElements: readonly ExcalidrawElement[] | null) => Promise<import("./restore").RestoredDataState>;
10
14
  export declare const loadLibraryFromBlob: (blob: Blob) => Promise<ImportedLibraryData>;
11
15
  export declare const canvasToBlob: (canvas: HTMLCanvasElement) => Promise<Blob>;
16
+ /** generates SHA-1 digest from supplied file (if not supported, falls back
17
+ to a 40-char base64 random id) */
18
+ export declare const generateIdFromFile: (file: File) => Promise<FileId>;
19
+ export declare const getDataURL: (file: Blob | File) => Promise<DataURL>;
20
+ export declare const dataURLToFile: (dataURL: DataURL, filename?: string) => File;
21
+ export declare const resizeImageFile: (file: File, maxWidthOrHeight: number) => Promise<File>;
22
+ export declare const getDataURLMimeType: (dataURL: DataURL) => string;
@@ -1,4 +1,4 @@
1
- export declare const toByteString: (data: string | Uint8Array) => Promise<string>;
1
+ export declare const toByteString: (data: string | Uint8Array | ArrayBuffer) => Promise<string>;
2
2
  /**
3
3
  * @param isByteString set to true if already byte string to prevent bloat
4
4
  * due to reencoding
@@ -22,4 +22,32 @@ export declare const encode: ({ text, compress, }: {
22
22
  compress?: boolean | undefined;
23
23
  }) => Promise<EncodedData>;
24
24
  export declare const decode: (data: EncodedData) => Promise<string>;
25
+ /**
26
+ * The returned buffer has following format:
27
+ * `[]` refers to a buffers wrapper (see `concatBuffers`)
28
+ *
29
+ * [
30
+ * encodingMetadataBuffer,
31
+ * iv,
32
+ * [
33
+ * contentsMetadataBuffer
34
+ * contentsBuffer
35
+ * ]
36
+ * ]
37
+ */
38
+ export declare const compressData: <T extends Record<string, any> = never>(dataBuffer: Uint8Array, options: {
39
+ encryptionKey: string;
40
+ } & ([T] extends [never] ? {
41
+ metadata?: T | undefined;
42
+ } : {
43
+ metadata: T;
44
+ })) => Promise<Uint8Array>;
45
+ export declare const decompressData: <T extends Record<string, any>>(bufferView: Uint8Array, options: {
46
+ decryptionKey: string;
47
+ }) => Promise<{
48
+ /** metadata source is always JSON so we can decode it here */
49
+ metadata: T;
50
+ /** data can be anything so the caller must decode it */
51
+ data: Uint8Array;
52
+ }>;
25
53
  export {};
@@ -2,7 +2,7 @@ import { ExcalidrawElement } from "../element/types";
2
2
  import { AppState } from "../types";
3
3
  import { ImportedDataState } from "./types";
4
4
  import Library from "./library";
5
- export declare const serializeAsJSON: (elements: readonly ExcalidrawElement[], appState: Partial<AppState>) => string;
5
+ export declare const serializeAsJSON: (elements: readonly ExcalidrawElement[], appState: Partial<AppState>, type: "local" | "database") => string;
6
6
  export declare const saveAsJSON: (elements: readonly ExcalidrawElement[], appState: AppState) => Promise<{
7
7
  fileHandle: import("@dwelle/browser-fs-access").FileSystemHandle | null;
8
8
  }>;