@quadrats/react 1.1.9 → 1.1.10

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,5 +1,6 @@
1
1
  import { ReactFileUploader } from './typings';
2
2
  export interface CreateReactFileUploaderOptions {
3
3
  type?: string;
4
+ onError?: VoidFunction;
4
5
  }
5
6
  export declare function createReactFileUploader(options?: CreateReactFileUploaderOptions): ReactFileUploader;
@@ -5,4 +5,5 @@ import { ReactImage } from './typings';
5
5
  export type CreateReactImageOptions<Hosting extends string> = CreateImageOptions<Hosting>;
6
6
  export declare function createReactImage<Hosting extends string>(options?: CreateReactImageOptions<Hosting>, getUploadOptions?: (image: Image<Hosting, QuadratsReactEditor>) => FileUploaderUploadOptions & {
7
7
  type?: string;
8
+ onError?: VoidFunction;
8
9
  }): ReactImage<Hosting>;
@@ -96,7 +96,7 @@ function createReactImage(options = {}, getUploadOptions) {
96
96
  * Insert each image when upload options are set.
97
97
  */
98
98
  if (uploadOptions) {
99
- const createFileUploaderElement = createFileUploaderElementByType((_a = uploadOptions.type) !== null && _a !== void 0 ? _a : FILE_UPLOADER_TYPE);
99
+ const createFileUploaderElement = createFileUploaderElementByType((_a = uploadOptions.type) !== null && _a !== void 0 ? _a : FILE_UPLOADER_TYPE, { onError: uploadOptions.onError });
100
100
  Array.from(files).reduce((prev, file) => __awaiter(this, void 0, void 0, function* () {
101
101
  yield prev;
102
102
  return createFileUploaderElement(editor, file, uploadOptions).then((fileUploaderElement) => {
@@ -293,7 +293,7 @@ function createReactImage(options = {}, getUploadOptions) {
293
293
  * Insert each image when upload options are set.
294
294
  */
295
295
  if (uploadOptions) {
296
- const createFileUploaderElement = fileUploader.createFileUploaderElementByType((_a = uploadOptions.type) !== null && _a !== void 0 ? _a : fileUploader.FILE_UPLOADER_TYPE);
296
+ const createFileUploaderElement = fileUploader.createFileUploaderElementByType((_a = uploadOptions.type) !== null && _a !== void 0 ? _a : fileUploader.FILE_UPLOADER_TYPE, { onError: uploadOptions.onError });
297
297
  Array.from(files).reduce((prev, file) => tslib.__awaiter(this, void 0, void 0, function* () {
298
298
  yield prev;
299
299
  return createFileUploaderElement(editor, file, uploadOptions).then((fileUploaderElement) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quadrats/react",
3
- "version": "1.1.9",
3
+ "version": "1.1.10",
4
4
  "description": "",
5
5
  "author": "Rytass",
6
6
  "homepage": "https://github.com/Quadrats/quadrats#readme",
@@ -20,7 +20,7 @@
20
20
  "url": "https://github.com/Quadrats/quadrats/issues"
21
21
  },
22
22
  "dependencies": {
23
- "@quadrats/common": "^1.1.9",
23
+ "@quadrats/common": "^1.1.10",
24
24
  "@quadrats/core": "^1.1.9",
25
25
  "@quadrats/icons": "^1.1.9",
26
26
  "@quadrats/locales": "^1.1.9",
@@ -84,7 +84,7 @@ function readFileAsBase64(file) {
84
84
  resolve(reader.result);
85
85
  }
86
86
  };
87
- reader.onerror = () => reject(reader.error);
87
+ reader.addEventListener('error', () => reject(reader.error));
88
88
  reader.readAsDataURL(file);
89
89
  });
90
90
  }
package/utils/upload.js CHANGED
@@ -8,7 +8,7 @@ function readFileAsBase64(file) {
8
8
  resolve(reader.result);
9
9
  }
10
10
  };
11
- reader.onerror = () => reject(reader.error);
11
+ reader.addEventListener('error', () => reject(reader.error));
12
12
  reader.readAsDataURL(file);
13
13
  });
14
14
  }