@excalidraw/excalidraw 0.15.2-2a4799d → 0.15.2-45a57d7

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@excalidraw/excalidraw",
3
- "version": "0.15.2-2a4799d",
3
+ "version": "0.15.2-45a57d7",
4
4
  "main": "main.js",
5
5
  "types": "types/packages/excalidraw/index.d.ts",
6
6
  "files": [
@@ -1,5 +1,5 @@
1
1
  import { ExcalidrawElement, NonDeletedExcalidrawElement } from "./element/types";
2
- import { AppState, BinaryFiles } from "./types";
2
+ import { BinaryFiles } from "./types";
3
3
  import { Spreadsheet } from "./charts";
4
4
  export interface ClipboardData {
5
5
  spreadsheet?: Spreadsheet;
@@ -11,7 +11,7 @@ export interface ClipboardData {
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, files: BinaryFiles | null) => Promise<void>;
14
+ export declare const copyToClipboard: (elements: readonly NonDeletedExcalidrawElement[], files: BinaryFiles | null) => Promise<string | undefined>;
15
15
  /**
16
16
  * Retrieves content from system clipboard (either from ClipboardEvent or
17
17
  * via async clipboard API if supported)
@@ -82,19 +82,32 @@ export declare const DEFAULT_VERTICAL_ALIGN = "top";
82
82
  export declare const DEFAULT_VERSION = "{version}";
83
83
  export declare const CANVAS_ONLY_ACTIONS: string[];
84
84
  export declare const GRID_SIZE = 20;
85
+ export declare const IMAGE_MIME_TYPES: {
86
+ readonly svg: "image/svg+xml";
87
+ readonly png: "image/png";
88
+ readonly jpg: "image/jpeg";
89
+ readonly gif: "image/gif";
90
+ readonly webp: "image/webp";
91
+ readonly bmp: "image/bmp";
92
+ readonly ico: "image/x-icon";
93
+ readonly avif: "image/avif";
94
+ readonly jfif: "image/jfif";
95
+ };
85
96
  export declare const MIME_TYPES: {
86
- readonly excalidraw: "application/vnd.excalidraw+json";
87
- readonly excalidrawlib: "application/vnd.excalidrawlib+json";
88
- readonly json: "application/json";
89
97
  readonly svg: "image/svg+xml";
90
- readonly "excalidraw.svg": "image/svg+xml";
91
98
  readonly png: "image/png";
92
- readonly "excalidraw.png": "image/png";
93
99
  readonly jpg: "image/jpeg";
94
100
  readonly gif: "image/gif";
95
101
  readonly webp: "image/webp";
96
102
  readonly bmp: "image/bmp";
97
103
  readonly ico: "image/x-icon";
104
+ readonly avif: "image/avif";
105
+ readonly jfif: "image/jfif";
106
+ readonly json: "application/json";
107
+ readonly excalidraw: "application/vnd.excalidraw+json";
108
+ readonly excalidrawlib: "application/vnd.excalidrawlib+json";
109
+ readonly "excalidraw.svg": "image/svg+xml";
110
+ readonly "excalidraw.png": "image/png";
98
111
  readonly binary: "application/octet-stream";
99
112
  };
100
113
  export declare const EXPORT_DATA_TYPES: {
@@ -132,7 +145,6 @@ export declare const MAX_DECIMALS_FOR_SVG_EXPORT = 2;
132
145
  export declare const EXPORT_SCALES: number[];
133
146
  export declare const DEFAULT_EXPORT_PADDING = 10;
134
147
  export declare const DEFAULT_MAX_IMAGE_WIDTH_OR_HEIGHT = 1440;
135
- export declare const ALLOWED_IMAGE_MIME_TYPES: readonly ["image/png", "image/jpeg", "image/svg+xml", "image/gif", "image/webp", "image/bmp", "image/x-icon"];
136
148
  export declare const MAX_ALLOWED_FILE_BYTES: number;
137
149
  export declare const SVG_NS = "http://www.w3.org/2000/svg";
138
150
  export declare const ENCRYPTION_KEY_BITS = 128;
@@ -1,4 +1,4 @@
1
- import { ALLOWED_IMAGE_MIME_TYPES, MIME_TYPES } from "../constants";
1
+ import { IMAGE_MIME_TYPES, MIME_TYPES } from "../constants";
2
2
  import { ExcalidrawElement, FileId } from "../element/types";
3
3
  import { AppState, DataURL, LibraryItem } from "../types";
4
4
  import { ValueOf } from "../utility-types";
@@ -9,7 +9,7 @@ export declare const getFileHandleType: (handle: FileSystemHandle | null) => str
9
9
  export declare const isImageFileHandleType: (type: string | null) => type is "svg" | "png";
10
10
  export declare const isImageFileHandle: (handle: FileSystemHandle | null) => boolean;
11
11
  export declare const isSupportedImageFile: (blob: Blob | null | undefined) => blob is Blob & {
12
- type: (typeof ALLOWED_IMAGE_MIME_TYPES)[number];
12
+ type: ValueOf<typeof IMAGE_MIME_TYPES>;
13
13
  };
14
14
  export declare const loadSceneOrLibraryFromBlob: (blob: Blob | File, localAppState: AppState | null, localElements: readonly ExcalidrawElement[] | null, fileHandle?: FileSystemHandle | null) => Promise<{
15
15
  type: "application/vnd.excalidraw+json";
@@ -1,5 +1,6 @@
1
1
  import { FileSystemHandle, supported as nativeFileSystemSupported } from "browser-fs-access";
2
- declare type FILE_EXTENSION = "gif" | "jpg" | "png" | "excalidraw.png" | "svg" | "excalidraw.svg" | "json" | "excalidraw" | "excalidrawlib";
2
+ import { MIME_TYPES } from "../constants";
3
+ declare type FILE_EXTENSION = Exclude<keyof typeof MIME_TYPES, "binary">;
3
4
  export declare const fileOpen: <M extends boolean | undefined = false>(opts: {
4
5
  extensions?: FILE_EXTENSION[] | undefined;
5
6
  description: string;
@@ -10,7 +10,17 @@ 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" | "image/webp" | "image/bmp" | "image/x-icon";
13
+ mimeType: import("../utility-types").ValueOf<{
14
+ readonly svg: "image/svg+xml";
15
+ readonly png: "image/png";
16
+ readonly jpg: "image/jpeg";
17
+ readonly gif: "image/gif";
18
+ readonly webp: "image/webp";
19
+ readonly bmp: "image/bmp";
20
+ readonly ico: "image/x-icon";
21
+ readonly avif: "image/avif";
22
+ readonly jfif: "image/jfif";
23
+ }>;
14
24
  }>;
15
25
  /** includes errored files because they cache was updated nonetheless */
16
26
  updatedFiles: Map<FileId, true>;
@@ -77,6 +77,11 @@ export declare const duplicateElement: <TElement extends ExcalidrawElement>(edit
77
77
  * it's advised to supply the whole elements array, or sets of elements that
78
78
  * are encapsulated (such as library items), if the purpose is to retain
79
79
  * bindings to the cloned elements intact.
80
+ *
81
+ * NOTE by default does not randomize or regenerate anything except the id.
80
82
  */
81
- export declare const duplicateElements: (elements: readonly ExcalidrawElement[]) => ExcalidrawElement[];
83
+ export declare const duplicateElements: (elements: readonly ExcalidrawElement[], opts?: {
84
+ /** NOTE also updates version flags and `updated` */
85
+ randomizeSeed: boolean;
86
+ }) => ExcalidrawElement[];
82
87
  export {};
@@ -71,8 +71,8 @@ export declare const getTextBindableContainerAtPosition: (elements: readonly Exc
71
71
  declare const VALID_CONTAINER_TYPES: Set<string>;
72
72
  export declare const isValidTextContainer: (element: ExcalidrawElement) => boolean;
73
73
  export declare const computeContainerDimensionForBoundText: (dimension: number, containerType: ExtractSetType<typeof VALID_CONTAINER_TYPES>) => number;
74
- export declare const getMaxContainerWidth: (container: ExcalidrawElement) => number;
75
- export declare const getMaxContainerHeight: (container: ExcalidrawElement) => number;
74
+ export declare const getBoundTextMaxWidth: (container: ExcalidrawElement) => number;
75
+ export declare const getBoundTextMaxHeight: (container: ExcalidrawElement, boundTextElement: ExcalidrawTextElementWithContainer) => number;
76
76
  export declare const isMeasureTextSupported: () => boolean;
77
77
  export declare const getDefaultLineHeight: (fontFamily: FontFamilyValues) => number & {
78
78
  _brand: "unitlessLineHeight";
package/types/types.d.ts CHANGED
@@ -13,9 +13,9 @@ import { isOverScrollBars } from "./scene";
13
13
  import { MaybeTransformHandleType } from "./element/transformHandles";
14
14
  import Library from "./data/library";
15
15
  import type { FileSystemHandle } from "./data/filesystem";
16
- import type { ALLOWED_IMAGE_MIME_TYPES, MIME_TYPES } from "./constants";
16
+ import type { IMAGE_MIME_TYPES, MIME_TYPES } from "./constants";
17
17
  import { ContextMenuItems } from "./components/ContextMenu";
18
- import { Merge, ForwardRef } from "./utility-types";
18
+ import { Merge, ForwardRef, ValueOf } from "./utility-types";
19
19
  import React from "react";
20
20
  export declare type Point = Readonly<RoughPoint>;
21
21
  export declare type Collaborator = {
@@ -38,7 +38,7 @@ export declare type DataURL = string & {
38
38
  _brand: "DataURL";
39
39
  };
40
40
  export declare type BinaryFileData = {
41
- mimeType: typeof ALLOWED_IMAGE_MIME_TYPES[number] | typeof MIME_TYPES.binary;
41
+ mimeType: ValueOf<typeof IMAGE_MIME_TYPES> | typeof MIME_TYPES.binary;
42
42
  id: FileId;
43
43
  dataURL: DataURL;
44
44
  /**
@@ -310,7 +310,7 @@ export declare type AppClassProperties = {
310
310
  library: Library;
311
311
  imageCache: Map<FileId, {
312
312
  image: HTMLImageElement | Promise<HTMLImageElement>;
313
- mimeType: typeof ALLOWED_IMAGE_MIME_TYPES[number];
313
+ mimeType: ValueOf<typeof IMAGE_MIME_TYPES>;
314
314
  }>;
315
315
  files: BinaryFiles;
316
316
  device: App["device"];