@excalidraw/excalidraw 0.18.0-3bdaafe → 0.18.0-414182f

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.
@@ -176,6 +176,13 @@ export declare const IMAGE_MIME_TYPES: {
176
176
  readonly avif: "image/avif";
177
177
  readonly jfif: "image/jfif";
178
178
  };
179
+ export declare const STRING_MIME_TYPES: {
180
+ readonly text: "text/plain";
181
+ readonly html: "text/html";
182
+ readonly json: "application/json";
183
+ readonly excalidraw: "application/vnd.excalidraw+json";
184
+ readonly excalidrawlib: "application/vnd.excalidrawlib+json";
185
+ };
179
186
  export declare const MIME_TYPES: {
180
187
  readonly svg: "image/svg+xml";
181
188
  readonly png: "image/png";
@@ -186,14 +193,14 @@ export declare const MIME_TYPES: {
186
193
  readonly ico: "image/x-icon";
187
194
  readonly avif: "image/avif";
188
195
  readonly jfif: "image/jfif";
196
+ readonly "excalidraw.svg": "image/svg+xml";
197
+ readonly "excalidraw.png": "image/png";
198
+ readonly binary: "application/octet-stream";
189
199
  readonly text: "text/plain";
190
200
  readonly html: "text/html";
191
201
  readonly json: "application/json";
192
202
  readonly excalidraw: "application/vnd.excalidraw+json";
193
203
  readonly excalidrawlib: "application/vnd.excalidrawlib+json";
194
- readonly "excalidraw.svg": "image/svg+xml";
195
- readonly "excalidraw.png": "image/png";
196
- readonly binary: "application/octet-stream";
197
204
  };
198
205
  export declare const ALLOWED_PASTE_MIME_TYPES: readonly ["text/plain", "text/html", ...("image/svg+xml" | "image/png" | "image/jpeg" | "image/gif" | "image/webp" | "image/bmp" | "image/x-icon" | "image/avif" | "image/jfif")[]];
199
206
  export declare const EXPORT_IMAGE_TYPES: {
@@ -1,5 +1,8 @@
1
1
  import { ALLOWED_PASTE_MIME_TYPES } from "@excalidraw/common";
2
+ import type { ValueOf } from "@excalidraw/common/utility-types";
3
+ import type { IMAGE_MIME_TYPES, STRING_MIME_TYPES } from "@excalidraw/common";
2
4
  import type { ExcalidrawElement, NonDeletedExcalidrawElement } from "@excalidraw/element/types";
5
+ import type { FileSystemHandle } from "./data/filesystem";
3
6
  import type { Spreadsheet } from "./charts";
4
7
  import type { BinaryFiles } from "./types";
5
8
  export type PastedMixedContent = {
@@ -57,10 +60,67 @@ export declare const readSystemClipboard: () => Promise<{
57
60
  "image/avif"?: string | File | undefined;
58
61
  "image/jfif"?: string | File | undefined;
59
62
  }>;
63
+ type AllowedParsedDataTransferItem = {
64
+ type: ValueOf<typeof IMAGE_MIME_TYPES>;
65
+ kind: "file";
66
+ file: File;
67
+ fileHandle: FileSystemHandle | null;
68
+ } | {
69
+ type: ValueOf<typeof STRING_MIME_TYPES>;
70
+ kind: "string";
71
+ value: string;
72
+ };
73
+ type ParsedDataTransferItem = {
74
+ type: string;
75
+ kind: "file";
76
+ file: File;
77
+ fileHandle: FileSystemHandle | null;
78
+ } | {
79
+ type: string;
80
+ kind: "string";
81
+ value: string;
82
+ };
83
+ type ParsedDataTransferItemType<T extends AllowedParsedDataTransferItem["type"]> = AllowedParsedDataTransferItem & {
84
+ type: T;
85
+ };
86
+ export type ParsedDataTransferFile = Extract<AllowedParsedDataTransferItem, {
87
+ kind: "file";
88
+ }>;
89
+ type ParsedDataTranferList = ParsedDataTransferItem[] & {
90
+ /**
91
+ * Only allows filtering by known `string` data types, since `file`
92
+ * types can have multiple items of the same type (e.g. multiple image files)
93
+ * unlike `string` data transfer items.
94
+ */
95
+ findByType: typeof findDataTransferItemType;
96
+ /**
97
+ * Only allows filtering by known `string` data types, since `file`
98
+ * types can have multiple items of the same type (e.g. multiple image files)
99
+ * unlike `string` data transfer items.
100
+ */
101
+ getData: typeof getDataTransferItemData;
102
+ getFiles: typeof getDataTransferFiles;
103
+ };
104
+ declare const findDataTransferItemType: <T extends ValueOf<{
105
+ readonly text: "text/plain";
106
+ readonly html: "text/html";
107
+ readonly json: "application/json";
108
+ readonly excalidraw: "application/vnd.excalidraw+json";
109
+ readonly excalidrawlib: "application/vnd.excalidrawlib+json";
110
+ }>>(this: ParsedDataTranferList, type: T) => ParsedDataTransferItemType<T> | null;
111
+ declare const getDataTransferItemData: <T extends ValueOf<{
112
+ readonly text: "text/plain";
113
+ readonly html: "text/html";
114
+ readonly json: "application/json";
115
+ readonly excalidraw: "application/vnd.excalidraw+json";
116
+ readonly excalidrawlib: "application/vnd.excalidrawlib+json";
117
+ }>>(this: ParsedDataTranferList, type: T) => ParsedDataTransferItemType<ValueOf<typeof STRING_MIME_TYPES>>["value"] | null;
118
+ declare const getDataTransferFiles: (this: ParsedDataTranferList) => ParsedDataTransferFile[];
119
+ export declare const parseDataTransferEvent: (event: ClipboardEvent | DragEvent | React.DragEvent<HTMLDivElement>) => Promise<ParsedDataTranferList>;
60
120
  /**
61
121
  * Attempts to parse clipboard event.
62
122
  */
63
- export declare const parseClipboard: (event: ClipboardEvent, isPlainPaste?: boolean) => Promise<ClipboardData>;
123
+ export declare const parseClipboard: (dataList: ParsedDataTranferList, isPlainPaste?: boolean) => Promise<ClipboardData>;
64
124
  export declare const copyBlobToClipboardAsPng: (blob: Blob | Promise<Blob>) => Promise<void>;
65
125
  export declare const copyTextToSystemClipboard: (text: string | null, clipboardEvent?: ClipboardEvent | null) => Promise<void>;
66
126
  export declare const isClipboardEvent: (event: React.SyntheticEvent | Event) => event is ClipboardEvent;
@@ -40,13 +40,6 @@ export declare const SVGStringToFile: (SVGString: string, filename?: string) =>
40
40
  type: typeof MIME_TYPES.svg;
41
41
  };
42
42
  export declare const ImageURLToFile: (imageUrl: string, filename?: string) => Promise<File | undefined>;
43
- export declare const getFilesFromEvent: (event: React.DragEvent<HTMLDivElement> | ClipboardEvent) => Promise<({
44
- file: File;
45
- fileHandle: FileSystemHandle | null;
46
- } | {
47
- file: null;
48
- fileHandle: null;
49
- })[]>;
50
43
  export declare const getFileHandle: (event: DragEvent | React.DragEvent | DataTransferItem) => Promise<FileSystemHandle | null>;
51
44
  export declare const createFile: (blob: File | Blob | ArrayBuffer, mimeType: ValueOf<typeof MIME_TYPES>, name: string | undefined) => File;
52
45
  /** attempts to detect correct mimeType if none is set, or if an image
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@excalidraw/excalidraw",
3
- "version": "0.18.0-3bdaafe",
3
+ "version": "0.18.0-414182f",
4
4
  "type": "module",
5
5
  "types": "./dist/types/excalidraw/index.d.ts",
6
6
  "main": "./dist/prod/index.js",
@@ -79,9 +79,9 @@
79
79
  },
80
80
  "dependencies": {
81
81
  "@braintree/sanitize-url": "6.0.2",
82
- "@excalidraw/common": "0.18.0-3bdaafe",
83
- "@excalidraw/element": "0.18.0-3bdaafe",
84
- "@excalidraw/math": "0.18.0-3bdaafe",
82
+ "@excalidraw/common": "0.18.0-414182f",
83
+ "@excalidraw/element": "0.18.0-414182f",
84
+ "@excalidraw/math": "0.18.0-414182f",
85
85
  "@excalidraw/laser-pointer": "1.3.1",
86
86
  "@excalidraw/mermaid-to-excalidraw": "1.1.3",
87
87
  "@excalidraw/random-username": "1.1.0",