@emailmaker/filemanager 1.1.72 → 1.1.81
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/.build-meta.json +1 -1
- package/constants/index.d.ts +5 -0
- package/{file-manager-IconsTab-pUKiId5k.js → file-manager-IconsTab-B-SBqKG5.js} +132 -132
- package/{file-manager-ImageCodeGenerator-sUlzbDys.js → file-manager-ImageCodeGenerator-Bz0238mQ.js} +115 -115
- package/{file-manager-PixieEditor-Doy__jUq.js → file-manager-PixieEditor-D7KvwgMy.js} +65 -65
- package/{file-manager-hooks-vqT-4jeg.js → file-manager-hooks-B_xL38Y5.js} +1895 -1849
- package/{file-manager-useMediaListEngine-BitrHuUM.js → file-manager-useMediaListEngine-DqKdMklL.js} +2 -2
- package/file-manager.esm.js +2312 -2295
- package/file-manager.js +11 -11
- package/hooks/core/files/useFilesAPI.d.ts +1 -1
- package/hooks/core/useFiles.d.ts +1 -1
- package/package.json +1 -1
- package/types.d.ts +2 -0
- package/utils/buildSourceFileName.d.ts +6 -0
- package/utils/buildSourceFileName.test.d.ts +1 -0
- package/utils/fileExtensions.d.ts +10 -0
- package/utils/fileExtensions.test.d.ts +1 -0
- package/utils/resolveUploadFileName.d.ts +15 -0
- package/utils/resolveUploadFileName.test.d.ts +1 -0
- package/utils/urlNormalization.d.ts +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { D as e, E as t, F as n, H as r, P as i, Q as a, R as o, T as s, et as c, f as l, ft as u, it as ee, q as d, y as f } from "./file-manager-hooks-B_xL38Y5.js";
|
|
2
2
|
import { i as p, t as te } from "./file-manager-urls-DN9gaYil.js";
|
|
3
3
|
import m from "react";
|
|
4
4
|
import { Button as h, Modal as ne } from "antd";
|
|
@@ -74,10 +74,10 @@ function oe(e, t) {
|
|
|
74
74
|
if (e === "svg") return new Blob([t], { type: "image/svg+xml" });
|
|
75
75
|
let n = `image/${e}`;
|
|
76
76
|
if (t.startsWith("data:")) {
|
|
77
|
-
let e =
|
|
78
|
-
return e && e.startsWith("image/") && (n = e), C(t.replace(/data:image\/[^;]+;base64,/, ""),
|
|
77
|
+
let e = a(t);
|
|
78
|
+
return e && e.startsWith("image/") && (n = e), C(t.replace(/data:image\/[^;]+;base64,/, ""), c(n));
|
|
79
79
|
}
|
|
80
|
-
return C(t,
|
|
80
|
+
return C(t, c(n));
|
|
81
81
|
}
|
|
82
82
|
function w(e) {
|
|
83
83
|
return new Promise((t, n) => {
|
|
@@ -85,8 +85,8 @@ function w(e) {
|
|
|
85
85
|
r.onload = () => t(r.result), r.onerror = () => n(r.error ?? /* @__PURE__ */ Error("Failed to convert blob to data URL")), r.readAsDataURL(e);
|
|
86
86
|
});
|
|
87
87
|
}
|
|
88
|
-
var T = ({ visible:
|
|
89
|
-
let { t: x } =
|
|
88
|
+
var T = ({ visible: a, onClose: _, file: v, onSave: y, onSaveCopy: b }) => {
|
|
89
|
+
let { t: x } = d(), C = m.useRef(null), T = o(), se = l(), { options: E, actions: ce } = r(), { i18n: D } = d(), { config: O } = E, { setCurrentMenuFile: k } = ce, { getFileData: A, resolveFileForEditByUrl: j } = se, [M, N] = m.useState(!1), [P, F] = m.useState(null), [I, L] = m.useState(""), [R, z] = m.useState(!1), [B, V] = m.useState(!1), [H, U] = m.useState(null), W = m.useRef(!1), G = m.useRef(void 0), K = m.useRef(void 0), q = m.useRef("saveCopy"), J = m.useRef(void 0);
|
|
90
90
|
G.current = y, K.current = b, m.useEffect(() => {
|
|
91
91
|
v && !W.current && (async () => {
|
|
92
92
|
if (J.current !== v) {
|
|
@@ -130,23 +130,23 @@ var T = ({ visible: c, onClose: _, file: v, onSave: y, onSaveCopy: b }) => {
|
|
|
130
130
|
}
|
|
131
131
|
}, [A, x]);
|
|
132
132
|
m.useEffect(() => {
|
|
133
|
-
if (!P &&
|
|
133
|
+
if (!P && a && H) {
|
|
134
134
|
let e = !1;
|
|
135
135
|
return (async () => {
|
|
136
136
|
N(!0);
|
|
137
137
|
try {
|
|
138
|
-
let
|
|
139
|
-
if (!
|
|
140
|
-
if (!
|
|
141
|
-
let
|
|
142
|
-
if (!
|
|
143
|
-
let [,
|
|
144
|
-
if (!
|
|
145
|
-
if (
|
|
146
|
-
if (!/^[A-Za-z0-9+/]+=*$/.test(
|
|
138
|
+
let n = await Y(H);
|
|
139
|
+
if (!n || typeof n != "string" || n.trim() === "") throw Error("Invalid image data: empty or null");
|
|
140
|
+
if (!n.startsWith("data:")) throw Error("Invalid image data: not a valid data URL");
|
|
141
|
+
let r = n.match(/^data:([^;]+);base64,(.+)$/);
|
|
142
|
+
if (!r) throw Error("Invalid image data: malformed data URL format");
|
|
143
|
+
let [, i, a] = r;
|
|
144
|
+
if (!i.startsWith("image/")) throw Error(`Invalid image data: unsupported MIME type ${i}`);
|
|
145
|
+
if (a.length < 10) throw Error("Invalid image data: base64 content too short");
|
|
146
|
+
if (!/^[A-Za-z0-9+/]+=*$/.test(a)) throw Error("Invalid image data: corrupted base64 content");
|
|
147
147
|
if (!e) {
|
|
148
|
-
F(
|
|
149
|
-
let e =
|
|
148
|
+
F(n);
|
|
149
|
+
let e = t(H, "image/png");
|
|
150
150
|
L(e.mimeType);
|
|
151
151
|
}
|
|
152
152
|
} catch (t) {
|
|
@@ -175,67 +175,67 @@ var T = ({ visible: c, onClose: _, file: v, onSave: y, onSaveCopy: b }) => {
|
|
|
175
175
|
P,
|
|
176
176
|
_,
|
|
177
177
|
x,
|
|
178
|
-
|
|
178
|
+
a
|
|
179
179
|
]);
|
|
180
|
-
let X = m.useCallback(async (
|
|
181
|
-
let
|
|
182
|
-
if (
|
|
183
|
-
let
|
|
180
|
+
let X = m.useCallback(async (t, n, r) => {
|
|
181
|
+
let i = await oe(r, t), a = c(i.type || `image/${r}`), o = O?.compessorUrl ?? O?.compressorUrl;
|
|
182
|
+
if (a.startsWith("image/")) try {
|
|
183
|
+
let t = await f(new File([i], n, { type: a }), {
|
|
184
184
|
maxSizeMB: O?.compressMaxSize,
|
|
185
185
|
maxWidthOrHeight: O?.compressMaxWidthOrHeight,
|
|
186
|
-
mimeType:
|
|
187
|
-
fileName:
|
|
188
|
-
libURL:
|
|
189
|
-
enableCompression:
|
|
186
|
+
mimeType: a,
|
|
187
|
+
fileName: n,
|
|
188
|
+
libURL: o,
|
|
189
|
+
enableCompression: e(O, a)
|
|
190
190
|
});
|
|
191
|
-
|
|
191
|
+
i = t, a = t.type;
|
|
192
192
|
} catch (e) {
|
|
193
193
|
console.warn("Image preparation failed, using original:", e);
|
|
194
194
|
}
|
|
195
195
|
return {
|
|
196
|
-
blob:
|
|
197
|
-
mimeType:
|
|
198
|
-
thumbnailDataUrl: await w(
|
|
196
|
+
blob: i,
|
|
197
|
+
mimeType: a,
|
|
198
|
+
thumbnailDataUrl: await w(i)
|
|
199
199
|
};
|
|
200
|
-
}, [O]), Z = m.useCallback(async (e, t,
|
|
201
|
-
let o =
|
|
200
|
+
}, [O]), Z = m.useCallback(async (e, t, r, a) => {
|
|
201
|
+
let o = a === "save" ? G.current : K.current;
|
|
202
202
|
if (!H || !o) return;
|
|
203
203
|
let s = typeof H == "object" && H ? H : null, c = null;
|
|
204
204
|
try {
|
|
205
205
|
N(!0);
|
|
206
|
-
let { blob:
|
|
206
|
+
let { blob: n, mimeType: i, thumbnailDataUrl: s } = await X(e, t, r), l = {
|
|
207
207
|
...H,
|
|
208
208
|
thumbnail: s,
|
|
209
|
-
size:
|
|
209
|
+
size: n.size,
|
|
210
210
|
date: (/* @__PURE__ */ new Date()).toISOString().split("T")[0],
|
|
211
|
-
type:
|
|
211
|
+
type: i,
|
|
212
212
|
folderId: H.folderId || "",
|
|
213
213
|
name: H.name || t,
|
|
214
214
|
extension: H.extension || (H.name || t).split(".").pop()?.toLowerCase() || ""
|
|
215
215
|
};
|
|
216
216
|
c = l;
|
|
217
217
|
let u = await o(l, {
|
|
218
|
-
blob:
|
|
219
|
-
mimeType:
|
|
218
|
+
blob: n,
|
|
219
|
+
mimeType: i,
|
|
220
220
|
thumbnail: s,
|
|
221
|
-
mode:
|
|
221
|
+
mode: a
|
|
222
222
|
});
|
|
223
223
|
if (u) return N(!1), u;
|
|
224
|
-
throw Error(x(
|
|
224
|
+
throw Error(x(a === "saveCopy" ? "Failed to save image copy" : "Failed to save changes"));
|
|
225
225
|
} catch (e) {
|
|
226
226
|
console.error("Error saving:", e);
|
|
227
|
-
let
|
|
227
|
+
let r = c ?? s;
|
|
228
228
|
if (!e?.notificationShown) {
|
|
229
|
-
let o = i(e), s =
|
|
229
|
+
let o = i(e), s = n(o?.code, x) ?? o?.message ?? x(a === "saveCopy" ? "Failed to save image copy" : "Error saving image");
|
|
230
230
|
T.error({
|
|
231
|
-
id:
|
|
231
|
+
id: a === "saveCopy" ? "IMAGE_SAVE_COPY_FAILED" : "IMAGE_SAVE_FAILED",
|
|
232
232
|
message: s,
|
|
233
233
|
placement: "bottomRight",
|
|
234
234
|
data: {
|
|
235
|
-
itemId:
|
|
236
|
-
itemName:
|
|
237
|
-
folderId:
|
|
238
|
-
thumbnail:
|
|
235
|
+
itemId: r?.id ?? void 0,
|
|
236
|
+
itemName: r?.name ?? t,
|
|
237
|
+
folderId: r?.folderId ?? null,
|
|
238
|
+
thumbnail: r?.thumbnail
|
|
239
239
|
},
|
|
240
240
|
innerException: e
|
|
241
241
|
});
|
|
@@ -253,9 +253,9 @@ var T = ({ visible: c, onClose: _, file: v, onSave: y, onSaveCopy: b }) => {
|
|
|
253
253
|
return;
|
|
254
254
|
}
|
|
255
255
|
q.current = e;
|
|
256
|
-
let n = H.name || "edited-image", r =
|
|
256
|
+
let n = H.name || "edited-image", r = t(H, I);
|
|
257
257
|
try {
|
|
258
|
-
await S.tools?.export.save(n.replace(/\.[^/.]+$/, ""), r.pixieFormat,
|
|
258
|
+
await S.tools?.export.save(n.replace(/\.[^/.]+$/, ""), r.pixieFormat, s.QUALITY);
|
|
259
259
|
} catch (t) {
|
|
260
260
|
console.error("🎨 Error saving through the button:", t);
|
|
261
261
|
try {
|
|
@@ -270,21 +270,21 @@ var T = ({ visible: c, onClose: _, file: v, onSave: y, onSaveCopy: b }) => {
|
|
|
270
270
|
I,
|
|
271
271
|
Z
|
|
272
272
|
]), $ = m.useCallback(async () => {
|
|
273
|
-
if (!(!P || !
|
|
273
|
+
if (!(!P || !a || !R || W.current)) try {
|
|
274
274
|
W.current = !0;
|
|
275
275
|
let e = C.current, n = 0;
|
|
276
276
|
for (; n < 20 && (e.clientWidth === 0 || e.clientHeight === 0);) await new Promise((e) => setTimeout(e, 50)), n++;
|
|
277
|
-
let r = O?.locale ? O?.locale.replace("_", "-") : "en", i = matchMedia("(prefers-color-scheme: dark)").matches ? ee :
|
|
278
|
-
Object.entries(
|
|
279
|
-
let n =
|
|
280
|
-
|
|
277
|
+
let r = O?.locale ? O?.locale.replace("_", "-") : "en", i = matchMedia("(prefers-color-scheme: dark)").matches ? ee : u, a = O?.theme === "system" ? i : O?.theme, o = (O?.locale || D.language || "en").split("-")[0].split("_")[0], c = (D.getResourceBundle(o, "translation") || {}).pixie || {}, l = (e) => e.split(" ").map((e) => e.charAt(0).toUpperCase() + e.slice(1).toLowerCase()).join(" "), d = {};
|
|
278
|
+
Object.entries(c).forEach(([e, t]) => {
|
|
279
|
+
let n = l(e);
|
|
280
|
+
d[n] = t, d[e] = t;
|
|
281
281
|
});
|
|
282
|
-
let
|
|
282
|
+
let f = { [r]: d }, p = t(H, I), m = {
|
|
283
283
|
selector: "#pixie-editor",
|
|
284
284
|
baseUrl: te(O?.baseUrl || "", O?.assetsUrl || "assets/image-editor"),
|
|
285
285
|
image: P,
|
|
286
286
|
activeLanguage: r,
|
|
287
|
-
languages:
|
|
287
|
+
languages: f,
|
|
288
288
|
ui: {
|
|
289
289
|
activeTheme: a,
|
|
290
290
|
mode: "inline",
|
|
@@ -326,7 +326,7 @@ var T = ({ visible: c, onClose: _, file: v, onSave: y, onSaveCopy: b }) => {
|
|
|
326
326
|
tools: {
|
|
327
327
|
export: {
|
|
328
328
|
defaultFormat: p.pixieFormat,
|
|
329
|
-
defaultQuality:
|
|
329
|
+
defaultQuality: s.QUALITY,
|
|
330
330
|
defaultName: H?.name?.replace(/\.[^/.]+$/, "") || "image"
|
|
331
331
|
},
|
|
332
332
|
text: {
|
|
@@ -475,7 +475,7 @@ var T = ({ visible: c, onClose: _, file: v, onSave: y, onSaveCopy: b }) => {
|
|
|
475
475
|
H,
|
|
476
476
|
I,
|
|
477
477
|
P,
|
|
478
|
-
|
|
478
|
+
a,
|
|
479
479
|
R,
|
|
480
480
|
O?.locale,
|
|
481
481
|
O?.theme,
|
|
@@ -488,14 +488,14 @@ var T = ({ visible: c, onClose: _, file: v, onSave: y, onSaveCopy: b }) => {
|
|
|
488
488
|
x
|
|
489
489
|
]);
|
|
490
490
|
m.useEffect(() => {
|
|
491
|
-
|
|
491
|
+
a && P && R && $();
|
|
492
492
|
}, [
|
|
493
|
-
|
|
493
|
+
a,
|
|
494
494
|
P,
|
|
495
495
|
R,
|
|
496
496
|
$
|
|
497
497
|
]), m.useEffect(() => {
|
|
498
|
-
if (!
|
|
498
|
+
if (!a) {
|
|
499
499
|
try {
|
|
500
500
|
S.close();
|
|
501
501
|
} catch (e) {
|
|
@@ -510,11 +510,11 @@ var T = ({ visible: c, onClose: _, file: v, onSave: y, onSaveCopy: b }) => {
|
|
|
510
510
|
console.warn("Error closing Pixie when unmounting:", e);
|
|
511
511
|
}
|
|
512
512
|
};
|
|
513
|
-
}, [
|
|
513
|
+
}, [a]);
|
|
514
514
|
let le = !!H?.id && O?.features?.enableUpdateFile !== !1;
|
|
515
515
|
return /* @__PURE__ */ g(ne, {
|
|
516
516
|
title: H?.name ? x("Editing: {{name}}", { name: H.name }) : x("Editing image"),
|
|
517
|
-
open:
|
|
517
|
+
open: a,
|
|
518
518
|
closeIcon: null,
|
|
519
519
|
onCancel: _,
|
|
520
520
|
afterOpenChange: (e) => z(e),
|
|
@@ -562,7 +562,7 @@ var T = ({ visible: c, onClose: _, file: v, onSave: y, onSaveCopy: b }) => {
|
|
|
562
562
|
width: "100%",
|
|
563
563
|
height: "100%"
|
|
564
564
|
},
|
|
565
|
-
children: [
|
|
565
|
+
children: [a && !B ? /* @__PURE__ */ g("div", {
|
|
566
566
|
style: {
|
|
567
567
|
position: "absolute",
|
|
568
568
|
inset: 0,
|
|
@@ -594,4 +594,4 @@ var T = ({ visible: c, onClose: _, file: v, onSave: y, onSaveCopy: b }) => {
|
|
|
594
594
|
//#endregion
|
|
595
595
|
export { T as PixieEditor };
|
|
596
596
|
|
|
597
|
-
//# sourceMappingURL=file-manager-PixieEditor-
|
|
597
|
+
//# sourceMappingURL=file-manager-PixieEditor-D7KvwgMy.js.map
|