@quadrats/common 1.1.10 → 1.1.11

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.
@@ -21,6 +21,7 @@ const createFileUploaderElementByType = (type, uploaderOptions) => (editor, file
21
21
  type,
22
22
  register: (getPath, onProgress) => {
23
23
  xhr.onload = () => {
24
+ var _a;
24
25
  if (xhr.status < 400) {
25
26
  const path = getPath();
26
27
  if (path) {
@@ -31,7 +32,13 @@ const createFileUploaderElementByType = (type, uploaderOptions) => (editor, file
31
32
  }
32
33
  }
33
34
  else {
34
- throw xhr.response;
35
+ const path = getPath();
36
+ (_a = uploaderOptions === null || uploaderOptions === void 0 ? void 0 : uploaderOptions.onError) === null || _a === void 0 ? void 0 : _a.call(uploaderOptions);
37
+ if (path) {
38
+ HistoryEditor.withoutSaving(editor, () => {
39
+ Transforms.removeNodes(editor, { at: path });
40
+ });
41
+ }
35
42
  }
36
43
  };
37
44
  if (xhr.addEventListener) {
@@ -84,6 +84,7 @@ const createFileUploaderElementByType = (type, uploaderOptions) => (editor, file
84
84
  type,
85
85
  register: (getPath, onProgress) => {
86
86
  xhr.onload = () => {
87
+ var _a;
87
88
  if (xhr.status < 400) {
88
89
  const path = getPath();
89
90
  if (path) {
@@ -94,7 +95,13 @@ const createFileUploaderElementByType = (type, uploaderOptions) => (editor, file
94
95
  }
95
96
  }
96
97
  else {
97
- throw xhr.response;
98
+ const path = getPath();
99
+ (_a = uploaderOptions === null || uploaderOptions === void 0 ? void 0 : uploaderOptions.onError) === null || _a === void 0 ? void 0 : _a.call(uploaderOptions);
100
+ if (path) {
101
+ core.HistoryEditor.withoutSaving(editor, () => {
102
+ core.Transforms.removeNodes(editor, { at: path });
103
+ });
104
+ }
98
105
  }
99
106
  };
100
107
  if (xhr.addEventListener) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quadrats/common",
3
- "version": "1.1.10",
3
+ "version": "1.1.11",
4
4
  "description": "",
5
5
  "author": "Rytass",
6
6
  "homepage": "https://github.com/Quadrats/quadrats#readme",