@zsviczian/excalidraw 0.9.0-obsidian-image-support-6 → 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.
@@ -1,3 +1,9 @@
1
+ /*
2
+ object-assign
3
+ (c) Sindre Sorhus
4
+ @license MIT
5
+ */
6
+
1
7
  /*!
2
8
 
3
9
  pica
@@ -5,4 +11,13 @@ https://github.com/nodeca/pica
5
11
 
6
12
  */
7
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
+
8
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-image-support-6",
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": [
@@ -67,7 +67,7 @@ export declare const zoomToFitElements: (elements: readonly ExcalidrawElement[],
67
67
  showHelpDialog: boolean;
68
68
  toastMessage: string | null;
69
69
  zenModeEnabled: boolean;
70
- theme: "light" | "dark";
70
+ theme: string;
71
71
  gridSize: number | null;
72
72
  viewModeEnabled: boolean;
73
73
  selectedGroupIds: {
@@ -2,7 +2,7 @@ import { ExcalidrawElement } from "./element/types";
2
2
  import { AppState, NormalizedZoomValue } from "./types";
3
3
  export declare const getDefaultAppState: () => Omit<AppState, "offsetTop" | "offsetLeft" | "width" | "height">;
4
4
  export declare const clearAppStateForLocalStorage: (appState: Partial<AppState>, elements: readonly ExcalidrawElement[]) => {
5
- theme?: "light" | "dark" | undefined;
5
+ theme?: string | undefined;
6
6
  zoom?: Readonly<{
7
7
  value: NormalizedZoomValue;
8
8
  translation: Readonly<{
@@ -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 {};
@@ -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;
@@ -112,3 +116,5 @@ export declare const MAX_DECIMALS_FOR_SVG_EXPORT = 2;
112
116
  export declare const EXPORT_SCALES: number[];
113
117
  export declare const DEFAULT_EXPORT_PADDING = 10;
114
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,3 +1,4 @@
1
+ import { ALLOWED_IMAGE_MIME_TYPES } from "../constants";
1
2
  import { ExcalidrawElement, FileId } from "../element/types";
2
3
  import { AppState, DataURL } from "../types";
3
4
  import { FileSystemHandle } from "./filesystem";
@@ -6,11 +7,16 @@ 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;
9
- export declare const isImageFile: (blob: Blob | null | undefined) => blob is Blob;
10
+ export declare const isSupportedImageFile: (blob: Blob | null | undefined) => blob is Blob & {
11
+ type: typeof ALLOWED_IMAGE_MIME_TYPES[number];
12
+ };
10
13
  export declare const loadFromBlob: (blob: Blob, localAppState: AppState | null, localElements: readonly ExcalidrawElement[] | null) => Promise<import("./restore").RestoredDataState>;
11
14
  export declare const loadLibraryFromBlob: (blob: Blob) => Promise<ImportedLibraryData>;
12
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) */
13
18
  export declare const generateIdFromFile: (file: File) => Promise<FileId>;
14
19
  export declare const getDataURL: (file: Blob | File) => Promise<DataURL>;
15
20
  export declare const dataURLToFile: (dataURL: DataURL, filename?: string) => File;
16
21
  export declare const resizeImageFile: (file: File, maxWidthOrHeight: number) => Promise<File>;
22
+ export declare const getDataURLMimeType: (dataURL: DataURL) => string;
@@ -1,9 +1,10 @@
1
1
  import { Point } from "../types";
2
- import { FONT_FAMILY } from "../constants";
2
+ import { FONT_FAMILY, THEME } from "../constants";
3
3
  export declare type ChartType = "bar" | "line";
4
4
  export declare type FillStyle = "hachure" | "cross-hatch" | "solid";
5
5
  export declare type FontFamilyKeys = keyof typeof FONT_FAMILY;
6
6
  export declare type FontFamilyValues = typeof FONT_FAMILY[FontFamilyKeys];
7
+ export declare type Theme = typeof THEME[keyof typeof THEME];
7
8
  export declare type FontString = string & {
8
9
  _brand: "fontString";
9
10
  };
@@ -61,7 +62,7 @@ export declare type ExcalidrawImageElement = _ExcalidrawElementBase & Readonly<{
61
62
  type: "image";
62
63
  fileId: FileId | null;
63
64
  /** whether respective file is persisted */
64
- status: "pending" | "saved";
65
+ status: "pending" | "saved" | "error";
65
66
  /** X and Y scale factors <-1, 1>, used for image axis flipping */
66
67
  scale: [number, number];
67
68
  }>;
@@ -10,4 +10,4 @@ export { getSceneVersion, getElementMap, isInvisiblySmallElement, } from "../../
10
10
  export { defaultLang, languages } from "../../i18n";
11
11
  export { restore, restoreAppState, restoreElements } from "../../data/restore";
12
12
  export { exportToCanvas, exportToBlob, exportToSvg, serializeAsJSON, loadLibraryFromBlob, loadFromBlob, getFreeDrawSvgPath, } from "../../packages/utils";
13
- export { FONT_FAMILY } from "../../constants";
13
+ export { FONT_FAMILY, THEME } from "../../constants";
@@ -44,7 +44,9 @@ export namespace module {
44
44
  } | {
45
45
  loader: string;
46
46
  options: {
47
- presets: string[];
47
+ presets: (string | (string | {
48
+ runtime: string;
49
+ })[])[];
48
50
  plugins: string[];
49
51
  transpileOnly?: undefined;
50
52
  configFile?: undefined;
package/types/types.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { PointerType, ExcalidrawLinearElement, NonDeletedExcalidrawElement, NonDeleted, TextAlign, ExcalidrawElement, GroupId, ExcalidrawBindableElement, Arrowhead, ChartType, FontFamilyValues, FileId, ExcalidrawTextElement, ExcalidrawImageElement } from "./element/types";
2
+ import { PointerType, ExcalidrawLinearElement, NonDeletedExcalidrawElement, NonDeleted, TextAlign, ExcalidrawElement, GroupId, ExcalidrawBindableElement, Arrowhead, ChartType, FontFamilyValues, FileId, ExcalidrawTextElement, ExcalidrawImageElement, Theme } from "./element/types";
3
3
  import { SHAPES } from "./shapes";
4
4
  import { Point as RoughPoint } from "roughjs/bin/geometry";
5
5
  import { LinearElementEditor } from "./element/linearElementEditor";
@@ -38,6 +38,7 @@ export declare type BinaryFileData = {
38
38
  dataURL: DataURL;
39
39
  created: number;
40
40
  };
41
+ export declare type BinaryFileMetadata = Omit<BinaryFileData, "dataURL">;
41
42
  export declare type AppState = {
42
43
  files: Record<ExcalidrawElement["id"], BinaryFileData>;
43
44
  isLoading: boolean;
@@ -93,7 +94,7 @@ export declare type AppState = {
93
94
  showHelpDialog: boolean;
94
95
  toastMessage: string | null;
95
96
  zenModeEnabled: boolean;
96
- theme: "light" | "dark";
97
+ theme: Theme;
97
98
  gridSize: number | null;
98
99
  viewModeEnabled: boolean;
99
100
  /** top-most selected groups (i.e. does not include nested groups) */
@@ -178,7 +179,7 @@ export interface ExcalidrawProps {
178
179
  zenModeEnabled?: boolean;
179
180
  gridModeEnabled?: boolean;
180
181
  libraryReturnUrl?: string;
181
- theme?: "dark" | "light";
182
+ theme?: Theme;
182
183
  name?: string;
183
184
  renderCustomStats?: (elements: readonly NonDeletedExcalidrawElement[], appState: AppState) => JSX.Element;
184
185
  UIOptions?: UIOptions;
@@ -300,7 +301,7 @@ export declare type ExcalidrawImperativeAPI = {
300
301
  refresh: InstanceType<typeof App>["refresh"];
301
302
  importLibrary: InstanceType<typeof App>["importLibraryFromUrl"];
302
303
  setToastMessage: InstanceType<typeof App>["setToastMessage"];
303
- addFiles: (data: AppState["files"][number][]) => void;
304
+ addFiles: (data: BinaryFileData[]) => void;
304
305
  readyPromise: ResolvablePromise<ExcalidrawImperativeAPI>;
305
306
  ready: true;
306
307
  id: string;