@mbs-dev/react-editor 1.13.1 → 1.13.2

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/dist/Editor.js CHANGED
@@ -92,7 +92,6 @@ var uploaderConfig = function (apiUrl, imageUrl, selectionRef) { return ({
92
92
  var _this = this;
93
93
  var _a;
94
94
  var fn = this.jodit;
95
- var data = ((_a = e === null || e === void 0 ? void 0 : e.data) !== null && _a !== void 0 ? _a : e);
96
95
  var restoreToLastCaret = function () {
97
96
  var _a, _b;
98
97
  var saved = selectionRef === null || selectionRef === void 0 ? void 0 : selectionRef.current;
@@ -125,8 +124,8 @@ var uploaderConfig = function (apiUrl, imageUrl, selectionRef) { return ({
125
124
  selectionRef.current = null;
126
125
  }
127
126
  };
128
- if ((data === null || data === void 0 ? void 0 : data.files) && data.files.length) {
129
- data.files.forEach(function (filename, idx) {
127
+ if (((_a = e === null || e === void 0 ? void 0 : e.data) === null || _a === void 0 ? void 0 : _a.files) && e.data.files.length) {
128
+ e.data.files.forEach(function (filename) {
130
129
  var _a;
131
130
  var src = imageUrl ? "".concat(imageUrl, "/").concat(filename) : filename;
132
131
  restoreToLastCaret();
@@ -143,9 +142,7 @@ var uploaderConfig = function (apiUrl, imageUrl, selectionRef) { return ({
143
142
  elm.setAttribute('href', src);
144
143
  elm.setAttribute('target', '_blank');
145
144
  elm.setAttribute('rel', 'noopener noreferrer');
146
- elm.textContent =
147
- ((data === null || data === void 0 ? void 0 : data.origineFileName) && data.origineFileName[idx]) ||
148
- getDisplayNameFromPath(filename);
145
+ elm.textContent = getDisplayNameFromPath(filename);
149
146
  fn.s.insertNode(elm);
150
147
  if ((_a = fn === null || fn === void 0 ? void 0 : fn.s) === null || _a === void 0 ? void 0 : _a.setCursorAfter) {
151
148
  try {
@@ -158,27 +155,19 @@ var uploaderConfig = function (apiUrl, imageUrl, selectionRef) { return ({
158
155
  }
159
156
  });
160
157
  }
161
- if (typeof (data === null || data === void 0 ? void 0 : data.error) !== 'undefined') {
162
- return Number(data.error) === 0;
163
- }
164
158
  return !!(e === null || e === void 0 ? void 0 : e.success);
165
159
  },
166
160
  getMessage: function (e) {
167
- var _a, _b;
168
- var data = ((_a = e === null || e === void 0 ? void 0 : e.data) !== null && _a !== void 0 ? _a : e);
169
- if (typeof (data === null || data === void 0 ? void 0 : data.msg) === 'string')
170
- return data.msg;
171
- return ((_b = e === null || e === void 0 ? void 0 : e.data) === null || _b === void 0 ? void 0 : _b.messages) && Array.isArray(e.data.messages)
172
- ? e.data.messages.join('')
173
- : '';
161
+ var _a;
162
+ return ((_a = e === null || e === void 0 ? void 0 : e.data) === null || _a === void 0 ? void 0 : _a.messages) && Array.isArray(e.data.messages) ? e.data.messages.join('') : '';
174
163
  },
175
164
  process: function (resp) {
176
- var _a, _b, _c, _d;
165
+ var files = [];
166
+ files.unshift(resp === null || resp === void 0 ? void 0 : resp.data);
177
167
  return {
178
- files: (_a = resp === null || resp === void 0 ? void 0 : resp.data) === null || _a === void 0 ? void 0 : _a.files,
179
- origineFileName: (_b = resp === null || resp === void 0 ? void 0 : resp.data) === null || _b === void 0 ? void 0 : _b.origineFileName,
180
- error: (_c = resp === null || resp === void 0 ? void 0 : resp.data) === null || _c === void 0 ? void 0 : _c.error,
181
- msg: (_d = resp === null || resp === void 0 ? void 0 : resp.data) === null || _d === void 0 ? void 0 : _d.msg,
168
+ files: resp === null || resp === void 0 ? void 0 : resp.data,
169
+ error: resp === null || resp === void 0 ? void 0 : resp.msg,
170
+ msg: resp === null || resp === void 0 ? void 0 : resp.msg,
182
171
  };
183
172
  },
184
173
  error: function (e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mbs-dev/react-editor",
3
- "version": "1.13.1",
3
+ "version": "1.13.2",
4
4
  "description": "react editor",
5
5
  "main": "dist/index.js",
6
6
  "types": "types/index.d.ts",
package/src/Editor.tsx CHANGED
@@ -58,13 +58,6 @@ export const uploaderConfig = (apiUrl?: string, imageUrl?: string, selectionRef?
58
58
  isSuccess(this: any, e: any): boolean {
59
59
  const fn = this.jodit;
60
60
 
61
- const data = (e?.data ?? e) as {
62
- files?: string[];
63
- origineFileName?: string[];
64
- error?: number;
65
- msg?: string;
66
- };
67
-
68
61
  const restoreToLastCaret = () => {
69
62
  const saved = selectionRef?.current;
70
63
 
@@ -99,8 +92,8 @@ export const uploaderConfig = (apiUrl?: string, imageUrl?: string, selectionRef?
99
92
  }
100
93
  };
101
94
 
102
- if (data?.files && data.files.length) {
103
- data.files.forEach((filename: string, idx: number) => {
95
+ if (e?.data?.files && e.data.files.length) {
96
+ e.data.files.forEach((filename: string) => {
104
97
  const src = imageUrl ? `${imageUrl}/${filename}` : filename;
105
98
 
106
99
  // ✅ Restore caret BEFORE inserting anything (image or file)
@@ -119,11 +112,7 @@ export const uploaderConfig = (apiUrl?: string, imageUrl?: string, selectionRef?
119
112
  elm.setAttribute('href', src);
120
113
  elm.setAttribute('target', '_blank');
121
114
  elm.setAttribute('rel', 'noopener noreferrer');
122
-
123
- // ✅ Display origineFileName for files (not images)
124
- elm.textContent =
125
- (data?.origineFileName && data.origineFileName[idx]) ||
126
- getDisplayNameFromPath(filename);
115
+ elm.textContent = getDisplayNameFromPath(filename);
127
116
 
128
117
  fn.s.insertNode(elm);
129
118
 
@@ -140,26 +129,19 @@ export const uploaderConfig = (apiUrl?: string, imageUrl?: string, selectionRef?
140
129
  });
141
130
  }
142
131
 
143
- if (typeof data?.error !== 'undefined') {
144
- return Number(data.error) === 0;
145
- }
146
-
147
132
  return !!e?.success;
148
133
  },
149
134
  getMessage(e: any): string {
150
- const data = (e?.data ?? e) as { msg?: string; messages?: unknown };
151
- if (typeof data?.msg === 'string') return data.msg;
152
-
153
- return e?.data?.messages && Array.isArray(e.data.messages)
154
- ? e.data.messages.join('')
155
- : '';
135
+ return e?.data?.messages && Array.isArray(e.data.messages) ? e.data.messages.join('') : '';
156
136
  },
157
- process(resp: any): any {
137
+ process(resp: any): { files: any[]; error: string; msg: string } {
138
+ const files: any[] = [];
139
+ files.unshift(resp?.data);
140
+
158
141
  return {
159
- files: resp?.data?.files,
160
- origineFileName: resp?.data?.origineFileName,
161
- error: resp?.data?.error,
162
- msg: resp?.data?.msg,
142
+ files: resp?.data,
143
+ error: resp?.msg,
144
+ msg: resp?.msg,
163
145
  };
164
146
  },
165
147
  error(this: any, e: Error): void {
package/types/Editor.d.ts CHANGED
@@ -14,7 +14,11 @@ export declare const uploaderConfig: (apiUrl?: string, imageUrl?: string, select
14
14
  prepareData(formdata: FormData): FormData;
15
15
  isSuccess(this: any, e: any): boolean;
16
16
  getMessage(e: any): string;
17
- process(resp: any): any;
17
+ process(resp: any): {
18
+ files: any[];
19
+ error: string;
20
+ msg: string;
21
+ };
18
22
  error(this: any, e: Error): void;
19
23
  defaultHandlerError(this: any, e: any): void;
20
24
  };