@dwelle/excalidraw 0.3.10 → 0.3.14

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 (36) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/README_NEXT.md +32 -0
  3. package/dist/excalidraw-assets/vendor-1018b0a7e7e60d808384.js +2 -0
  4. package/dist/excalidraw-assets/vendor-1018b0a7e7e60d808384.js.LICENSE.txt +14 -0
  5. package/dist/excalidraw-assets-dev/image-9f771c114a0a3ad7b334.js +42 -0
  6. package/dist/excalidraw-assets-dev/vendor-bb07a412033591d5470d.js +344 -0
  7. package/dist/excalidraw.development.js +63 -31
  8. package/dist/excalidraw.production.min.js +1 -1
  9. package/package.json +2 -2
  10. package/types/actions/types.d.ts +3 -1
  11. package/types/appState.d.ts +3 -5
  12. package/types/clipboard.d.ts +3 -3
  13. package/types/components/App.d.ts +2 -1
  14. package/types/components/ClearCanvas.d.ts +6 -0
  15. package/types/components/ImageExportDialog.d.ts +3 -2
  16. package/types/components/JSONExportDialog.d.ts +4 -3
  17. package/types/components/LayerUI.d.ts +3 -2
  18. package/types/components/LibraryUnit.d.ts +2 -2
  19. package/types/constants.d.ts +2 -1
  20. package/types/data/filesystem.d.ts +1 -1
  21. package/types/data/index.d.ts +2 -2
  22. package/types/data/json.d.ts +3 -3
  23. package/types/data/resave.d.ts +2 -2
  24. package/types/data/restore.d.ts +2 -1
  25. package/types/data/types.d.ts +3 -1
  26. package/types/element/image.d.ts +3 -3
  27. package/types/packages/excalidraw/dist/excalidraw-assets/vendor-1018b0a7e7e60d808384.d.ts +0 -0
  28. package/types/packages/excalidraw/dist/excalidraw-assets-dev/image-9f771c114a0a3ad7b334.d.ts +0 -0
  29. package/types/packages/excalidraw/dist/excalidraw-assets-dev/vendor-bb07a412033591d5470d.d.ts +0 -0
  30. package/types/packages/excalidraw/index.d.ts +2 -1
  31. package/types/packages/utils.d.ts +4 -3
  32. package/types/renderer/renderElement.d.ts +2 -2
  33. package/types/renderer/renderScene.d.ts +2 -2
  34. package/types/scene/export.d.ts +3 -4
  35. package/types/shapes.d.ts +1 -1
  36. package/types/types.d.ts +6 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dwelle/excalidraw",
3
- "version": "0.3.10",
3
+ "version": "0.3.14",
4
4
  "main": "main.js",
5
5
  "types": "types/packages/excalidraw/index.d.ts",
6
6
  "files": [
@@ -40,7 +40,7 @@
40
40
  "@babel/core": "7.14.8",
41
41
  "@babel/plugin-transform-arrow-functions": "7.14.5",
42
42
  "@babel/plugin-transform-async-to-generator": "7.14.5",
43
- "@babel/plugin-transform-runtime": "7.14.5",
43
+ "@babel/plugin-transform-runtime": "7.15.8",
44
44
  "@babel/plugin-transform-typescript": "7.14.6",
45
45
  "@babel/preset-env": "7.14.9",
46
46
  "@babel/preset-react": "7.14.5",
@@ -1,13 +1,15 @@
1
1
  import React from "react";
2
2
  import { ExcalidrawElement } from "../element/types";
3
- import { AppClassProperties, AppState, ExcalidrawProps } from "../types";
3
+ import { AppClassProperties, AppState, ExcalidrawProps, BinaryFiles } from "../types";
4
4
  import { ToolButtonSize } from "../components/ToolButton";
5
5
  /** if false, the action should be prevented */
6
6
  export declare type ActionResult = {
7
7
  elements?: readonly ExcalidrawElement[] | null;
8
8
  appState?: MarkOptional<AppState, "offsetTop" | "offsetLeft" | "width" | "height"> | null;
9
+ files?: BinaryFiles | null;
9
10
  commitToHistory: boolean;
10
11
  syncHistory?: boolean;
12
+ replaceFiles?: boolean;
11
13
  } | false;
12
14
  declare type ActionFn = (elements: readonly ExcalidrawElement[], appState: Readonly<AppState>, formData: any, app: AppClassProperties) => ActionResult | Promise<ActionResult>;
13
15
  export declare type UpdaterFn = (res: ActionResult) => void;
@@ -1,7 +1,6 @@
1
- import { ExcalidrawElement } from "./element/types";
2
1
  import { AppState, NormalizedZoomValue } from "./types";
3
2
  export declare const getDefaultAppState: () => Omit<AppState, "offsetTop" | "offsetLeft" | "width" | "height">;
4
- export declare const clearAppStateForLocalStorage: (appState: Partial<AppState>, elements: readonly ExcalidrawElement[]) => {
3
+ export declare const clearAppStateForLocalStorage: (appState: Partial<AppState>) => {
5
4
  theme?: string | undefined;
6
5
  zoom?: Readonly<{
7
6
  value: NormalizedZoomValue;
@@ -54,12 +53,11 @@ export declare const clearAppStateForLocalStorage: (appState: Partial<AppState>,
54
53
  showStats?: boolean | undefined;
55
54
  currentChartType?: import("./element/types").ChartType | undefined;
56
55
  };
57
- export declare const cleanAppStateForExport: (appState: Partial<AppState>, elements: readonly ExcalidrawElement[]) => {
58
- files?: Record<string, import("./types").BinaryFileData> | undefined;
56
+ export declare const cleanAppStateForExport: (appState: Partial<AppState>) => {
59
57
  viewBackgroundColor?: string | undefined;
60
58
  gridSize?: number | null | undefined;
61
59
  };
62
- export declare const clearAppStateForDatabase: (appState: Partial<AppState>, elements: readonly ExcalidrawElement[]) => {
60
+ export declare const clearAppStateForDatabase: (appState: Partial<AppState>) => {
63
61
  viewBackgroundColor?: string | undefined;
64
62
  gridSize?: number | null | undefined;
65
63
  };
@@ -1,17 +1,17 @@
1
1
  import { ExcalidrawElement, NonDeletedExcalidrawElement } from "./element/types";
2
- import { AppState } from "./types";
2
+ import { AppState, BinaryFiles } from "./types";
3
3
  import { Spreadsheet } from "./charts";
4
4
  export interface ClipboardData {
5
5
  spreadsheet?: Spreadsheet;
6
6
  elements?: readonly ExcalidrawElement[];
7
- files?: AppState["files"];
7
+ files?: BinaryFiles;
8
8
  text?: string;
9
9
  errorMessage?: string;
10
10
  }
11
11
  export declare const probablySupportsClipboardReadText: boolean;
12
12
  export declare const probablySupportsClipboardWriteText: boolean;
13
13
  export declare const probablySupportsClipboardBlob: boolean;
14
- export declare const copyToClipboard: (elements: readonly NonDeletedExcalidrawElement[], appState: AppState) => Promise<void>;
14
+ export declare const copyToClipboard: (elements: readonly NonDeletedExcalidrawElement[], appState: AppState, files: BinaryFiles) => Promise<void>;
15
15
  /**
16
16
  * Attemps to parse clipboard. Prefers system clipboard.
17
17
  */
@@ -3,7 +3,7 @@ import { RoughCanvas } from "roughjs/bin/canvas";
3
3
  import { ActionManager } from "../actions/manager";
4
4
  import { ExcalidrawElement } from "../element/types";
5
5
  import History from "../history";
6
- import { AppClassProperties, AppProps, AppState, ExcalidrawImperativeAPI, LibraryItems, SceneData } from "../types";
6
+ import { AppClassProperties, AppProps, AppState, ExcalidrawImperativeAPI, BinaryFiles, LibraryItems, SceneData } from "../types";
7
7
  export declare const useIsMobile: () => boolean;
8
8
  export declare const useExcalidrawContainer: () => {
9
9
  container: HTMLDivElement | null;
@@ -26,6 +26,7 @@ declare class App extends React.Component<AppProps, AppState> {
26
26
  private id;
27
27
  private history;
28
28
  private excalidrawContainerValue;
29
+ files: BinaryFiles;
29
30
  imageCache: AppClassProperties["imageCache"];
30
31
  constructor(props: AppProps);
31
32
  private renderCanvas;
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ import "./ClearCanvas.scss";
3
+ declare const ClearCanvas: ({ onConfirm }: {
4
+ onConfirm: () => void;
5
+ }) => JSX.Element;
6
+ export default ClearCanvas;
@@ -1,13 +1,14 @@
1
1
  /// <reference types="react" />
2
2
  import { ActionsManagerInterface } from "../actions/types";
3
3
  import { NonDeletedExcalidrawElement } from "../element/types";
4
- import { AppState } from "../types";
4
+ import { AppState, BinaryFiles } from "../types";
5
5
  import "./ExportDialog.scss";
6
6
  export declare const ErrorCanvasPreview: () => JSX.Element;
7
7
  export declare type ExportCB = (elements: readonly NonDeletedExcalidrawElement[], scale?: number) => void;
8
- export declare const ImageExportDialog: ({ elements, appState, exportPadding, actionManager, onExportToPng, onExportToSvg, onExportToClipboard, }: {
8
+ export declare const ImageExportDialog: ({ elements, appState, files, exportPadding, actionManager, onExportToPng, onExportToSvg, onExportToClipboard, }: {
9
9
  appState: AppState;
10
10
  elements: readonly NonDeletedExcalidrawElement[];
11
+ files: BinaryFiles;
11
12
  exportPadding?: number | undefined;
12
13
  actionManager: ActionsManagerInterface;
13
14
  onExportToPng: ExportCB;
@@ -1,12 +1,13 @@
1
1
  /// <reference types="react" />
2
2
  import { ActionsManagerInterface } from "../actions/types";
3
3
  import { NonDeletedExcalidrawElement } from "../element/types";
4
- import { AppState, CanvasActions } from "../types";
4
+ import { AppState, CanvasActions, BinaryFiles } from "../types";
5
5
  import "./ExportDialog.scss";
6
6
  export declare type ExportCB = (elements: readonly NonDeletedExcalidrawElement[], scale?: number) => void;
7
- export declare const JSONExportDialog: ({ elements, appState, actionManager, exportOpts, canvas, }: {
8
- appState: AppState;
7
+ export declare const JSONExportDialog: ({ elements, appState, files, actionManager, exportOpts, canvas, }: {
9
8
  elements: readonly NonDeletedExcalidrawElement[];
9
+ appState: AppState;
10
+ files: BinaryFiles;
10
11
  actionManager: ActionsManagerInterface;
11
12
  exportOpts: CanvasActions["export"];
12
13
  canvas: HTMLCanvasElement | null;
@@ -2,13 +2,14 @@ import React from "react";
2
2
  import { ActionManager } from "../actions/manager";
3
3
  import { NonDeletedExcalidrawElement } from "../element/types";
4
4
  import { Language } from "../i18n";
5
- import { AppProps, AppState, ExcalidrawProps } from "../types";
5
+ import { AppProps, AppState, ExcalidrawProps, BinaryFiles } from "../types";
6
6
  import "./LayerUI.scss";
7
7
  import Library from "../data/library";
8
8
  interface LayerUIProps {
9
9
  onHomeButtonClick?: () => void;
10
10
  actionManager: ActionManager;
11
11
  appState: AppState;
12
+ files: BinaryFiles;
12
13
  canvas: HTMLCanvasElement | null;
13
14
  setAppState: React.Component<any, AppState>["setState"];
14
15
  elements: readonly NonDeletedExcalidrawElement[];
@@ -33,5 +34,5 @@ interface LayerUIProps {
33
34
  insertOnCanvasDirectly: boolean;
34
35
  }) => void;
35
36
  }
36
- declare const _default: React.MemoExoticComponent<({ onHomeButtonClick, 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>;
37
+ declare const _default: React.MemoExoticComponent<({ onHomeButtonClick, actionManager, appState, files, setAppState, canvas, elements, onCollabButtonClick, onLockToggle, onInsertElements, zenModeEnabled, showExitZenModeBtn, showThemeBtn, toggleZenMode, isCollaborating, renderTopRightUI, renderCustomFooter, viewModeEnabled, libraryReturnUrl, UIOptions, focusContainer, library, id, onImageAction, }: LayerUIProps) => JSX.Element>;
37
38
  export default _default;
@@ -1,9 +1,9 @@
1
1
  /// <reference types="react" />
2
- import { AppState, LibraryItem } from "../types";
2
+ import { BinaryFiles, LibraryItem } from "../types";
3
3
  import "./LibraryUnit.scss";
4
4
  export declare const LibraryUnit: ({ elements, files, pendingElements, onRemoveFromLibrary, onClick, }: {
5
5
  elements?: LibraryItem | undefined;
6
- files: AppState["files"];
6
+ files: BinaryFiles;
7
7
  pendingElements?: LibraryItem | undefined;
8
8
  onRemoveFromLibrary: () => void;
9
9
  onClick: () => void;
@@ -80,6 +80,7 @@ export declare const MIME_TYPES: {
80
80
  readonly svg: "image/svg+xml";
81
81
  readonly png: "image/png";
82
82
  readonly jpg: "image/jpeg";
83
+ readonly gif: "image/gif";
83
84
  readonly binary: "application/octet-stream";
84
85
  };
85
86
  export declare const EXPORT_DATA_TYPES: {
@@ -125,6 +126,6 @@ export declare const MAX_DECIMALS_FOR_SVG_EXPORT = 2;
125
126
  export declare const EXPORT_SCALES: number[];
126
127
  export declare const DEFAULT_EXPORT_PADDING = 10;
127
128
  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"];
129
+ export declare const ALLOWED_IMAGE_MIME_TYPES: readonly ["image/png", "image/jpeg", "image/svg+xml", "image/gif"];
129
130
  export declare const MAX_ALLOWED_FILE_BYTES: number;
130
131
  export declare const SVG_NS = "http://www.w3.org/2000/svg";
@@ -1,5 +1,5 @@
1
1
  import { FileWithHandle, FileSystemHandle, supported as nativeFileSystemSupported } from "@dwelle/browser-fs-access";
2
- declare type FILE_EXTENSION = "jpg" | "png" | "svg" | "json" | "excalidraw" | "excalidrawlib";
2
+ declare type FILE_EXTENSION = "gif" | "jpg" | "png" | "svg" | "json" | "excalidraw" | "excalidrawlib";
3
3
  export declare const fileOpen: <M extends boolean | undefined = false>(opts: {
4
4
  extensions?: FILE_EXTENSION[] | undefined;
5
5
  description?: string | undefined;
@@ -1,10 +1,10 @@
1
1
  import { NonDeletedExcalidrawElement } from "../element/types";
2
2
  import { ExportType } from "../scene/types";
3
- import { AppState } from "../types";
3
+ import { AppState, BinaryFiles } from "../types";
4
4
  import { FileSystemHandle } from "./filesystem";
5
5
  export { loadFromBlob } from "./blob";
6
6
  export { loadFromJSON, saveAsJSON } from "./json";
7
- export declare const exportCanvas: (type: ExportType, elements: readonly NonDeletedExcalidrawElement[], appState: AppState, { exportBackground, exportPadding, viewBackgroundColor, name, fileHandle, }: {
7
+ export declare const exportCanvas: (type: ExportType, elements: readonly NonDeletedExcalidrawElement[], appState: AppState, files: BinaryFiles, { exportBackground, exportPadding, viewBackgroundColor, name, fileHandle, }: {
8
8
  exportBackground: boolean;
9
9
  exportPadding?: number | undefined;
10
10
  viewBackgroundColor: string;
@@ -1,9 +1,9 @@
1
1
  import { ExcalidrawElement } from "../element/types";
2
- import { AppState } from "../types";
2
+ import { AppState, BinaryFiles } 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>, type: "local" | "database") => string;
6
- export declare const saveAsJSON: (elements: readonly ExcalidrawElement[], appState: AppState) => Promise<{
5
+ export declare const serializeAsJSON: (elements: readonly ExcalidrawElement[], appState: Partial<AppState>, files: BinaryFiles, type: "local" | "database") => string;
6
+ export declare const saveAsJSON: (elements: readonly ExcalidrawElement[], appState: AppState, files: BinaryFiles) => Promise<{
7
7
  fileHandle: import("@dwelle/browser-fs-access").FileSystemHandle | null;
8
8
  }>;
9
9
  export declare const loadFromJSON: (localAppState: AppState, localElements: readonly ExcalidrawElement[] | null) => Promise<import("./restore").RestoredDataState>;
@@ -1,5 +1,5 @@
1
1
  import { ExcalidrawElement } from "../element/types";
2
- import { AppState } from "../types";
3
- export declare const resaveAsImageWithScene: (elements: readonly ExcalidrawElement[], appState: AppState) => Promise<{
2
+ import { AppState, BinaryFiles } from "../types";
3
+ export declare const resaveAsImageWithScene: (elements: readonly ExcalidrawElement[], appState: AppState, files: BinaryFiles) => Promise<{
4
4
  fileHandle: import("@dwelle/browser-fs-access").FileSystemHandle;
5
5
  }>;
@@ -1,11 +1,12 @@
1
1
  import { ExcalidrawElement } from "../element/types";
2
- import { AppState } from "../types";
2
+ import { AppState, BinaryFiles } from "../types";
3
3
  import { ImportedDataState } from "./types";
4
4
  declare type RestoredAppState = Omit<AppState, "offsetTop" | "offsetLeft" | "width" | "height">;
5
5
  export declare const AllowedExcalidrawElementTypes: Record<ExcalidrawElement["type"], true>;
6
6
  export declare type RestoredDataState = {
7
7
  elements: ExcalidrawElement[];
8
8
  appState: RestoredAppState;
9
+ files: BinaryFiles;
9
10
  };
10
11
  export declare const restoreElements: (elements: ImportedDataState["elements"], localElements: readonly ExcalidrawElement[] | null | undefined) => ExcalidrawElement[];
11
12
  export declare const restoreAppState: (appState: ImportedDataState["appState"], localAppState: Partial<AppState> | null | undefined) => RestoredAppState;
@@ -1,5 +1,5 @@
1
1
  import { ExcalidrawElement } from "../element/types";
2
- import { AppState, LibraryItems } from "../types";
2
+ import { AppState, BinaryFiles, LibraryItems } from "../types";
3
3
  import type { cleanAppStateForExport } from "../appState";
4
4
  export interface ExportedDataState {
5
5
  type: string;
@@ -7,6 +7,7 @@ export interface ExportedDataState {
7
7
  source: string;
8
8
  elements: readonly ExcalidrawElement[];
9
9
  appState: ReturnType<typeof cleanAppStateForExport>;
10
+ files: BinaryFiles | undefined;
10
11
  }
11
12
  export interface ImportedDataState {
12
13
  type?: string;
@@ -16,6 +17,7 @@ export interface ImportedDataState {
16
17
  appState?: Readonly<Partial<AppState>> | null;
17
18
  scrollToContent?: boolean;
18
19
  libraryItems?: LibraryItems;
20
+ files?: BinaryFiles;
19
21
  }
20
22
  export interface ExportedLibraryData {
21
23
  type: string;
@@ -1,16 +1,16 @@
1
- import { AppClassProperties, AppState, DataURL } from "../types";
1
+ import { AppClassProperties, DataURL, BinaryFiles } from "../types";
2
2
  import { ExcalidrawElement, FileId, InitializedExcalidrawImageElement } from "./types";
3
3
  export declare const loadHTMLImageElement: (dataURL: DataURL) => Promise<HTMLImageElement>;
4
4
  /** NOTE: updates cache even if already populated with given image. Thus,
5
5
  * you should filter out the images upstream if you want to optimize this. */
6
6
  export declare const updateImageCache: ({ fileIds, files, imageCache, }: {
7
7
  fileIds: FileId[];
8
- files: AppState["files"];
8
+ files: BinaryFiles;
9
9
  imageCache: AppClassProperties["imageCache"];
10
10
  }) => Promise<{
11
11
  imageCache: Map<FileId, {
12
12
  image: HTMLImageElement | Promise<HTMLImageElement>;
13
- mimeType: "image/svg+xml" | "image/png" | "image/jpeg";
13
+ mimeType: "image/svg+xml" | "image/png" | "image/jpeg" | "image/gif";
14
14
  }>;
15
15
  /** includes errored files because they cache was updated nonetheless */
16
16
  updatedFiles: Map<FileId, true>;
@@ -6,10 +6,11 @@ import { ExcalidrawAPIRefValue, ExcalidrawProps } from "../../types";
6
6
  declare type PublicExcalidrawProps = Omit<ExcalidrawProps, "forwardedRef">;
7
7
  declare const _default: React.MemoExoticComponent<React.ForwardRefExoticComponent<PublicExcalidrawProps & React.RefAttributes<ExcalidrawAPIRefValue>>>;
8
8
  export default _default;
9
- export { getSceneVersion, getElementMap, isInvisiblySmallElement, } from "../../element";
9
+ export { getSceneVersion, getElementMap, isInvisiblySmallElement, getNonDeletedElements, } from "../../element";
10
10
  export { defaultLang, languages } from "../../i18n";
11
11
  export { restore, restoreElements, restoreAppState } from "../../data/restore";
12
12
  export { exportToBlob, exportToCanvas, exportToSvg, serializeAsJSON, loadLibraryFromBlob, loadFromBlob, getFreeDrawSvgPath, } from "../../packages/utils";
13
+ export { isLinearElement } from "../../element/typeChecks";
13
14
  export { FONT_FAMILY, THEME } from "../../constants";
14
15
  export { exportToClipboard } from "../utils";
15
16
  export { getDefaultAppState } from "../../appState";
@@ -1,20 +1,21 @@
1
- import { AppState } from "../types";
1
+ import { AppState, BinaryFiles } from "../types";
2
2
  import { ExcalidrawElement } from "../element/types";
3
3
  declare type ExportOpts = {
4
4
  elements: readonly ExcalidrawElement[];
5
5
  appState?: Partial<Omit<AppState, "offsetTop" | "offsetLeft">>;
6
+ files: BinaryFiles | null;
6
7
  getDimensions?: (width: number, height: number) => {
7
8
  width: number;
8
9
  height: number;
9
10
  scale: number;
10
11
  };
11
12
  };
12
- export declare const exportToCanvas: ({ elements, appState, getDimensions, }: ExportOpts) => Promise<HTMLCanvasElement>;
13
+ export declare const exportToCanvas: ({ elements, appState, files, getDimensions, }: ExportOpts) => Promise<HTMLCanvasElement>;
13
14
  export declare const exportToBlob: (opts: ExportOpts & {
14
15
  mimeType?: string;
15
16
  quality?: number;
16
17
  }) => Promise<Blob | null>;
17
- export declare const exportToSvg: ({ elements, appState, exportPadding, }: Omit<ExportOpts, "getDimensions"> & {
18
+ export declare const exportToSvg: ({ elements, appState, files, exportPadding, }: Omit<ExportOpts, "getDimensions"> & {
18
19
  exportPadding?: number | undefined;
19
20
  }) => Promise<SVGSVGElement>;
20
21
  export declare const exportToClipboard: (opts: ExportOpts & {
@@ -3,7 +3,7 @@ import { RoughCanvas } from "roughjs/bin/canvas";
3
3
  import { Drawable, Options } from "roughjs/bin/core";
4
4
  import { RoughSVG } from "roughjs/bin/svg";
5
5
  import { SceneState } from "../scene/types";
6
- import { AppState, Zoom } from "../types";
6
+ import { BinaryFiles, Zoom } from "../types";
7
7
  export interface ExcalidrawElementWithCanvas {
8
8
  element: ExcalidrawElement | ExcalidrawTextElement;
9
9
  canvas: HTMLCanvasElement;
@@ -17,7 +17,7 @@ export declare const invalidateShapeForElement: (element: ExcalidrawElement) =>
17
17
  export declare const clearRenderCache: () => void;
18
18
  export declare const generateRoughOptions: (element: ExcalidrawElement, continuousPath?: boolean) => Options;
19
19
  export declare const renderElement: (element: NonDeletedExcalidrawElement, rc: RoughCanvas, context: CanvasRenderingContext2D, renderOptimizations: boolean, sceneState: SceneState) => void;
20
- export declare const renderElementToSvg: (element: NonDeletedExcalidrawElement, rsvg: RoughSVG, svgRoot: SVGElement, files: AppState["files"], offsetX?: number | undefined, offsetY?: number | undefined) => void;
20
+ export declare const renderElementToSvg: (element: NonDeletedExcalidrawElement, rsvg: RoughSVG, svgRoot: SVGElement, files: BinaryFiles, offsetX?: number | undefined, offsetY?: number | undefined) => void;
21
21
  export declare let pathsCache: WeakMap<ExcalidrawFreeDrawElement, Path2D>;
22
22
  export declare function generateFreeDrawShape(element: ExcalidrawFreeDrawElement): Path2D;
23
23
  export declare function getFreeDrawPath2D(element: ExcalidrawFreeDrawElement): Path2D | undefined;
@@ -1,6 +1,6 @@
1
1
  import { RoughCanvas } from "roughjs/bin/canvas";
2
2
  import { RoughSVG } from "roughjs/bin/svg";
3
- import { AppState } from "../types";
3
+ import { AppState, BinaryFiles } from "../types";
4
4
  import { NonDeletedExcalidrawElement } from "../element/types";
5
5
  import { SceneState } from "../scene/types";
6
6
  export declare const renderScene: (elements: readonly NonDeletedExcalidrawElement[], appState: AppState, selectionElement: NonDeletedExcalidrawElement | null, scale: number, rc: RoughCanvas, canvas: HTMLCanvasElement, sceneState: SceneState, { renderScrollbars, renderSelection, renderOptimizations, renderGrid, isExport, }?: {
@@ -16,7 +16,7 @@ export declare const renderScene: (elements: readonly NonDeletedExcalidrawElemen
16
16
  atLeastOneVisibleElement: boolean;
17
17
  scrollBars: import("../scene/types").ScrollBars | undefined;
18
18
  };
19
- export declare const renderSceneToSvg: (elements: readonly NonDeletedExcalidrawElement[], rsvg: RoughSVG, svgRoot: SVGElement, files: AppState["files"], { offsetX, offsetY, }?: {
19
+ export declare const renderSceneToSvg: (elements: readonly NonDeletedExcalidrawElement[], rsvg: RoughSVG, svgRoot: SVGElement, files: BinaryFiles, { offsetX, offsetY, }?: {
20
20
  offsetX?: number | undefined;
21
21
  offsetY?: number | undefined;
22
22
  }) => void;
@@ -1,7 +1,7 @@
1
1
  import { NonDeletedExcalidrawElement } from "../element/types";
2
- import { AppState } from "../types";
2
+ import { AppState, BinaryFiles } from "../types";
3
3
  export declare const SVG_EXPORT_TAG = "<!-- svg-source:excalidraw -->";
4
- export declare const exportToCanvas: (elements: readonly NonDeletedExcalidrawElement[], appState: AppState, { exportBackground, exportPadding, viewBackgroundColor, }: {
4
+ export declare const exportToCanvas: (elements: readonly NonDeletedExcalidrawElement[], appState: AppState, files: BinaryFiles, { exportBackground, exportPadding, viewBackgroundColor, }: {
5
5
  exportBackground: boolean;
6
6
  exportPadding?: number | undefined;
7
7
  viewBackgroundColor: string;
@@ -16,6 +16,5 @@ export declare const exportToSvg: (elements: readonly NonDeletedExcalidrawElemen
16
16
  viewBackgroundColor: string;
17
17
  exportWithDarkMode?: boolean;
18
18
  exportEmbedScene?: boolean;
19
- files: AppState["files"];
20
- }) => Promise<SVGSVGElement>;
19
+ }, files: BinaryFiles | null) => Promise<SVGSVGElement>;
21
20
  export declare const getExportSize: (elements: readonly NonDeletedExcalidrawElement[], exportPadding: number, scale: number) => [number, number];
package/types/shapes.d.ts CHANGED
@@ -34,6 +34,6 @@ export declare const SHAPES: readonly [{
34
34
  }, {
35
35
  readonly icon: JSX.Element;
36
36
  readonly value: "image";
37
- readonly key: "i";
37
+ readonly key: null;
38
38
  }];
39
39
  export declare const findShapeByKey: (key: string) => "line" | "selection" | "rectangle" | "diamond" | "ellipse" | "image" | "text" | "arrow" | "freedraw" | null;
package/types/types.d.ts CHANGED
@@ -41,8 +41,8 @@ export declare type BinaryFileData = {
41
41
  created: number;
42
42
  };
43
43
  export declare type BinaryFileMetadata = Omit<BinaryFileData, "dataURL">;
44
+ export declare type BinaryFiles = Record<ExcalidrawElement["id"], BinaryFileData>;
44
45
  export declare type AppState = {
45
- files: Record<ExcalidrawElement["id"], BinaryFileData>;
46
46
  isLoading: boolean;
47
47
  errorMessage: string | null;
48
48
  draggingElement: NonDeletedExcalidrawElement | null;
@@ -164,7 +164,7 @@ declare type InitialData = ImportedDataState & {
164
164
  };
165
165
  export interface ExcalidrawProps {
166
166
  id?: string | null;
167
- onChange?: (elements: readonly ExcalidrawElement[], appState: AppState, id?: string | null) => void;
167
+ onChange?: (elements: readonly ExcalidrawElement[], appState: AppState, files: BinaryFiles, id?: string | null) => void;
168
168
  onHomeButtonClick?: () => void;
169
169
  initialData?: InitialData | null | Promise<InitialData | null>;
170
170
  user?: {
@@ -212,8 +212,8 @@ export declare enum UserIdleState {
212
212
  }
213
213
  export declare type ExportOpts = {
214
214
  saveFileToDisk?: boolean;
215
- onExportToBackend?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: AppState, canvas: HTMLCanvasElement | null) => void;
216
- renderCustomUI?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: AppState, canvas: HTMLCanvasElement | null) => JSX.Element;
215
+ onExportToBackend?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: AppState, files: BinaryFiles, canvas: HTMLCanvasElement | null) => void;
216
+ renderCustomUI?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: AppState, files: BinaryFiles, canvas: HTMLCanvasElement | null) => JSX.Element;
217
217
  };
218
218
  export declare type CanvasActions = {
219
219
  changeViewBackgroundColor?: boolean;
@@ -245,6 +245,7 @@ export declare type AppClassProperties = {
245
245
  image: HTMLImageElement | Promise<HTMLImageElement>;
246
246
  mimeType: typeof ALLOWED_IMAGE_MIME_TYPES[number];
247
247
  }>;
248
+ files: BinaryFiles;
248
249
  };
249
250
  export declare type PointerDownState = Readonly<{
250
251
  origin: Readonly<{
@@ -306,6 +307,7 @@ export declare type ExcalidrawImperativeAPI = {
306
307
  scrollToContent: InstanceType<typeof App>["scrollToContent"];
307
308
  getSceneElements: InstanceType<typeof App>["getSceneElements"];
308
309
  getAppState: () => InstanceType<typeof App>["state"];
310
+ getFiles: () => InstanceType<typeof App>["files"];
309
311
  refresh: InstanceType<typeof App>["refresh"];
310
312
  importLibrary: InstanceType<typeof App>["importLibraryFromUrl"];
311
313
  setToastMessage: InstanceType<typeof App>["setToastMessage"];