@mbs-dev/react-editor 1.13.3 → 1.13.4
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 +13 -17
- package/package.json +1 -1
- package/src/Editor.tsx +18 -19
- package/types/Editor.d.ts +4 -1
package/dist/Editor.js
CHANGED
|
@@ -88,9 +88,11 @@ var uploaderConfig = function (apiUrl, imageUrl, selectionRef) { return ({
|
|
|
88
88
|
prepareData: function (formdata) {
|
|
89
89
|
return formdata;
|
|
90
90
|
},
|
|
91
|
+
defaultHandlerSuccess: function () {
|
|
92
|
+
return;
|
|
93
|
+
},
|
|
91
94
|
isSuccess: function (e) {
|
|
92
95
|
var _this = this;
|
|
93
|
-
var _a, _b, _c, _d;
|
|
94
96
|
var fn = this.jodit;
|
|
95
97
|
var restoreToLastCaret = function () {
|
|
96
98
|
var _a, _b;
|
|
@@ -124,8 +126,8 @@ var uploaderConfig = function (apiUrl, imageUrl, selectionRef) { return ({
|
|
|
124
126
|
selectionRef.current = null;
|
|
125
127
|
}
|
|
126
128
|
};
|
|
127
|
-
var files = Array.isArray(
|
|
128
|
-
var origineFileName = Array.isArray(
|
|
129
|
+
var files = Array.isArray(e === null || e === void 0 ? void 0 : e.files) ? e.files : [];
|
|
130
|
+
var origineFileName = Array.isArray(e === null || e === void 0 ? void 0 : e.origineFileName) ? e.origineFileName : [];
|
|
129
131
|
if (files.length) {
|
|
130
132
|
files.forEach(function (filename, idx) {
|
|
131
133
|
var _a;
|
|
@@ -144,7 +146,7 @@ var uploaderConfig = function (apiUrl, imageUrl, selectionRef) { return ({
|
|
|
144
146
|
elm.setAttribute('href', src);
|
|
145
147
|
elm.setAttribute('target', '_blank');
|
|
146
148
|
elm.setAttribute('rel', 'noopener noreferrer');
|
|
147
|
-
var label =
|
|
149
|
+
var label = typeof origineFileName[idx] === 'string' ? origineFileName[idx].trim() : '';
|
|
148
150
|
elm.textContent = label ? label : getDisplayNameFromPath(filename);
|
|
149
151
|
fn.s.insertNode(elm);
|
|
150
152
|
if ((_a = fn === null || fn === void 0 ? void 0 : fn.s) === null || _a === void 0 ? void 0 : _a.setCursorAfter) {
|
|
@@ -160,16 +162,15 @@ var uploaderConfig = function (apiUrl, imageUrl, selectionRef) { return ({
|
|
|
160
162
|
}
|
|
161
163
|
var ok = typeof (e === null || e === void 0 ? void 0 : e.success) !== 'undefined'
|
|
162
164
|
? !!e.success
|
|
163
|
-
: (
|
|
165
|
+
: (e === null || e === void 0 ? void 0 : e.error) === 0 || (e === null || e === void 0 ? void 0 : e.error) === '0';
|
|
164
166
|
return ok;
|
|
165
167
|
},
|
|
166
168
|
getMessage: function (e) {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
return e.data.msg;
|
|
169
|
+
if (typeof (e === null || e === void 0 ? void 0 : e.msg) === 'string' && e.msg.trim()) {
|
|
170
|
+
return e.msg;
|
|
170
171
|
}
|
|
171
|
-
return (
|
|
172
|
-
? e.
|
|
172
|
+
return (e === null || e === void 0 ? void 0 : e.messages) && Array.isArray(e.messages)
|
|
173
|
+
? e.messages.join('')
|
|
173
174
|
: '';
|
|
174
175
|
},
|
|
175
176
|
process: function (resp) {
|
|
@@ -181,15 +182,10 @@ var uploaderConfig = function (apiUrl, imageUrl, selectionRef) { return ({
|
|
|
181
182
|
var success = errorCode === 0 || errorCode === '0';
|
|
182
183
|
return {
|
|
183
184
|
files: files,
|
|
184
|
-
|
|
185
|
+
origineFileName: origineFileName,
|
|
186
|
+
error: errorCode,
|
|
185
187
|
msg: msg,
|
|
186
188
|
success: success,
|
|
187
|
-
data: {
|
|
188
|
-
files: files,
|
|
189
|
-
origineFileName: origineFileName,
|
|
190
|
-
error: errorCode,
|
|
191
|
-
msg: msg,
|
|
192
|
-
},
|
|
193
189
|
};
|
|
194
190
|
},
|
|
195
191
|
error: function (e) {
|
package/package.json
CHANGED
package/src/Editor.tsx
CHANGED
|
@@ -55,6 +55,12 @@ export const uploaderConfig = (apiUrl?: string, imageUrl?: string, selectionRef?
|
|
|
55
55
|
prepareData(formdata: FormData): FormData {
|
|
56
56
|
return formdata;
|
|
57
57
|
},
|
|
58
|
+
|
|
59
|
+
// ✅ prevent Jodit default insertion (it was adding "undefined + filename")
|
|
60
|
+
defaultHandlerSuccess(this: any): void {
|
|
61
|
+
return;
|
|
62
|
+
},
|
|
63
|
+
|
|
58
64
|
isSuccess(this: any, e: any): boolean {
|
|
59
65
|
const fn = this.jodit;
|
|
60
66
|
|
|
@@ -92,8 +98,8 @@ export const uploaderConfig = (apiUrl?: string, imageUrl?: string, selectionRef?
|
|
|
92
98
|
}
|
|
93
99
|
};
|
|
94
100
|
|
|
95
|
-
const files: string[] = Array.isArray(e?.
|
|
96
|
-
const origineFileName: string[] = Array.isArray(e?.
|
|
101
|
+
const files: string[] = Array.isArray(e?.files) ? e.files : [];
|
|
102
|
+
const origineFileName: string[] = Array.isArray(e?.origineFileName) ? e.origineFileName : [];
|
|
97
103
|
|
|
98
104
|
if (files.length) {
|
|
99
105
|
files.forEach((filename: string, idx: number) => {
|
|
@@ -116,8 +122,8 @@ export const uploaderConfig = (apiUrl?: string, imageUrl?: string, selectionRef?
|
|
|
116
122
|
elm.setAttribute('target', '_blank');
|
|
117
123
|
elm.setAttribute('rel', 'noopener noreferrer');
|
|
118
124
|
|
|
119
|
-
// ✅ For files: display origineFileName (
|
|
120
|
-
const label =
|
|
125
|
+
// ✅ For files: display origineFileName ONLY (fallback if missing)
|
|
126
|
+
const label = typeof origineFileName[idx] === 'string' ? origineFileName[idx].trim() : '';
|
|
121
127
|
elm.textContent = label ? label : getDisplayNameFromPath(filename);
|
|
122
128
|
|
|
123
129
|
fn.s.insertNode(elm);
|
|
@@ -138,20 +144,20 @@ export const uploaderConfig = (apiUrl?: string, imageUrl?: string, selectionRef?
|
|
|
138
144
|
const ok =
|
|
139
145
|
typeof e?.success !== 'undefined'
|
|
140
146
|
? !!e.success
|
|
141
|
-
: e?.
|
|
147
|
+
: e?.error === 0 || e?.error === '0';
|
|
142
148
|
|
|
143
149
|
return ok;
|
|
144
150
|
},
|
|
145
151
|
getMessage(e: any): string {
|
|
146
|
-
if (typeof e?.
|
|
147
|
-
return e.
|
|
152
|
+
if (typeof e?.msg === 'string' && e.msg.trim()) {
|
|
153
|
+
return e.msg;
|
|
148
154
|
}
|
|
149
155
|
|
|
150
|
-
return e?.
|
|
151
|
-
? e.
|
|
156
|
+
return e?.messages && Array.isArray(e.messages)
|
|
157
|
+
? e.messages.join('')
|
|
152
158
|
: '';
|
|
153
159
|
},
|
|
154
|
-
process(resp: any): { files: any[]; error:
|
|
160
|
+
process(resp: any): { files: any[]; error: any; msg: string; origineFileName?: any[]; success?: boolean } {
|
|
155
161
|
const files: any[] = Array.isArray(resp?.data?.files) ? resp.data.files : [];
|
|
156
162
|
const origineFileName: any[] = Array.isArray(resp?.data?.origineFileName) ? resp.data.origineFileName : [];
|
|
157
163
|
|
|
@@ -162,17 +168,10 @@ export const uploaderConfig = (apiUrl?: string, imageUrl?: string, selectionRef?
|
|
|
162
168
|
|
|
163
169
|
return {
|
|
164
170
|
files,
|
|
165
|
-
|
|
171
|
+
origineFileName,
|
|
172
|
+
error: errorCode,
|
|
166
173
|
msg,
|
|
167
|
-
|
|
168
|
-
// Extra fields used by isSuccess/getMessage (kept compatible)
|
|
169
174
|
success,
|
|
170
|
-
data: {
|
|
171
|
-
files,
|
|
172
|
-
origineFileName,
|
|
173
|
-
error: errorCode,
|
|
174
|
-
msg,
|
|
175
|
-
},
|
|
176
175
|
} as any;
|
|
177
176
|
},
|
|
178
177
|
error(this: any, e: Error): void {
|
package/types/Editor.d.ts
CHANGED
|
@@ -12,12 +12,15 @@ export declare const uploaderConfig: (apiUrl?: string, imageUrl?: string, select
|
|
|
12
12
|
format: string;
|
|
13
13
|
method: string;
|
|
14
14
|
prepareData(formdata: FormData): FormData;
|
|
15
|
+
defaultHandlerSuccess(this: any): void;
|
|
15
16
|
isSuccess(this: any, e: any): boolean;
|
|
16
17
|
getMessage(e: any): string;
|
|
17
18
|
process(resp: any): {
|
|
18
19
|
files: any[];
|
|
19
|
-
error:
|
|
20
|
+
error: any;
|
|
20
21
|
msg: string;
|
|
22
|
+
origineFileName?: any[] | undefined;
|
|
23
|
+
success?: boolean | undefined;
|
|
21
24
|
};
|
|
22
25
|
error(this: any, e: Error): void;
|
|
23
26
|
defaultHandlerError(this: any, e: any): void;
|