@emailmaker/filemanager 1.1.93 → 1.1.102
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/assets/icon-sets/lucide.json +6275 -0
- package/assets/icon-sets/tabler.json +19336 -0
- package/components/FilerobotEditor/FilerobotEditor.d.ts +1 -0
- package/components/FilerobotEditor/cornerRadius/CornerRadiusTool.d.ts +22 -0
- package/components/FilerobotEditor/cornerRadius/__tests__/cornerRadiusMath.test.d.ts +1 -0
- package/components/FilerobotEditor/cornerRadius/__tests__/cornerRadiusOutput.test.d.ts +1 -0
- package/components/FilerobotEditor/cornerRadius/__tests__/imageEditorTools.test.d.ts +1 -0
- package/components/FilerobotEditor/cornerRadius/cornerRadiusEraser.d.ts +17 -0
- package/components/FilerobotEditor/cornerRadius/cornerRadiusMath.d.ts +38 -0
- package/components/FilerobotEditor/cornerRadius/cornerRadiusOutput.d.ts +18 -0
- package/components/FilerobotEditor/cornerRadius/imageEditorTools.d.ts +11 -0
- package/components/FilerobotEditor/cornerRadius/useCornerRadiusSync.d.ts +23 -0
- package/components/ImageIcons/iconSets.d.ts +38 -0
- package/components/ImageIcons/iconSets.test.d.ts +1 -0
- package/components/ImageIcons/iconStockSearch.d.ts +3 -1
- package/components/ImageIcons/packagedIconSets.d.ts +9 -0
- package/core.d.ts +1 -0
- package/core.esm.js +272 -259
- package/core.js +1 -1
- package/file-manager-FilerobotEditor.js +576 -0
- package/file-manager-IconsTab.js +2083 -0
- package/{file-manager-ImageCodeGenerator-m06RVQr7.js → file-manager-ImageCodeGenerator.js} +8 -8
- package/{file-manager-JsBarcode-CyaffT5b.js → file-manager-JsBarcode.js} +30 -30
- package/{file-manager-browser-DDyRNDQk.js → file-manager-browser.js} +8 -8
- package/{file-manager-hooks-UP2zpv8z.js → file-manager-hooks-BDRRCedE.js} +4792 -2384
- package/file-manager-imageEditorCropPresets-en0_jYEY.js +76 -0
- package/{file-manager-rolldown-runtime-DAVfCfog.js → file-manager-rolldown-runtime-DawGUBAG.js} +2 -2
- package/{file-manager-useMediaListEngine-B9sz3gcs.js → file-manager-urls-rCuqY9r4.js} +139 -119
- package/file-manager.esm.js +2332 -2277
- package/file-manager.js +12 -12
- package/helpers/__tests__/applyImageEditorTranslations.test.d.ts +1 -0
- package/helpers/__tests__/imageEditorCropPresets.test.d.ts +1 -0
- package/helpers/__tests__/locales.test.d.ts +1 -0
- package/helpers/applyImageEditorTranslations.d.ts +6 -0
- package/helpers/imageEditorCropPresets.d.ts +8 -0
- package/index.d.ts +2 -0
- package/package.json +5 -1
- package/types.d.ts +18 -0
- package/utils/filerobotEditorConfig.d.ts +1 -0
- package/utils/generateId.d.ts +5 -0
- package/utils/imageCompression.d.ts +10 -0
- package/utils/imageCompression.editedImage.test.d.ts +1 -0
- package/utils/imageCompression.png.test.d.ts +1 -0
- package/utils/pngCompression.d.ts +23 -0
- package/utils/pngCompression.test.d.ts +1 -0
- package/file-manager-FilerobotEditor-WbM5WTct.js +0 -330
- package/file-manager-IconsTab-CCn0Q0ng.js +0 -2434
- package/file-manager-imageEditorTranslations-CtNVql-A.js +0 -38
|
@@ -0,0 +1,576 @@
|
|
|
1
|
+
import { Ct as e, D as t, E as n, L as r, T as i, V as a, ct as o, f as s, ot as c, tt as l, y as u } from "./file-manager-hooks-BDRRCedE.js";
|
|
2
|
+
import { i as d, n as f, t as p } from "./file-manager-imageEditorCropPresets-en0_jYEY.js";
|
|
3
|
+
import m from "react";
|
|
4
|
+
import { Button as h, InputNumber as g, Modal as _, Tooltip as ee } from "antd";
|
|
5
|
+
import { jsx as v, jsxs as y } from "react/jsx-runtime";
|
|
6
|
+
import te, { TABS as b, TOOLS as ne } from "react-filerobot-image-editor";
|
|
7
|
+
import x from "konva";
|
|
8
|
+
import { TABS_TOOLS as S, TOOLS_ITEMS as C } from "react-filerobot-image-editor/lib/components/tools/tools.constants";
|
|
9
|
+
import { useStore as w } from "react-filerobot-image-editor/lib/hooks";
|
|
10
|
+
import { UPDATE_EXTRA_STATE as T } from "react-filerobot-image-editor/lib/actions";
|
|
11
|
+
import re from "react-filerobot-image-editor/lib/components/common/Slider";
|
|
12
|
+
import E from "react-filerobot-image-editor/lib/components/ToolsBar/ToolsBarItemButton";
|
|
13
|
+
var D = {
|
|
14
|
+
"em-filemanager": "em-filemanager",
|
|
15
|
+
emFilemanager: "em-filemanager",
|
|
16
|
+
filerobotEditorModal: "filerobotEditorModal",
|
|
17
|
+
filerobotEditorContainer: "filerobotEditorContainer",
|
|
18
|
+
filerobotEditorBody: "filerobotEditorBody"
|
|
19
|
+
}, O = "CornerRadius", k = "ellipse", A = "Crop";
|
|
20
|
+
function j(e, t) {
|
|
21
|
+
return Math.max(0, Math.floor(Math.min(e, t) / 2));
|
|
22
|
+
}
|
|
23
|
+
function M(e, t, n) {
|
|
24
|
+
let r = typeof e == "number" ? e : Number(e);
|
|
25
|
+
return Number.isFinite(r) ? Math.min(Math.max(Math.round(r), 0), j(t, n)) : 0;
|
|
26
|
+
}
|
|
27
|
+
function N(e, t, n) {
|
|
28
|
+
return n > 0 ? e * t / n : 0;
|
|
29
|
+
}
|
|
30
|
+
function P(e, t, n, r, i, a) {
|
|
31
|
+
let o = Math.min(a, r / 2, i / 2);
|
|
32
|
+
if (!(o > 0)) return !1;
|
|
33
|
+
let s = t + r, c = n + i;
|
|
34
|
+
return e.moveTo(t, n), e.lineTo(t + o, n), e.arcTo(t, n, t, n + o, o), e.closePath(), e.moveTo(s, n), e.lineTo(s, n + o), e.arcTo(s, n, s - o, n, o), e.closePath(), e.moveTo(s, c), e.lineTo(s - o, c), e.arcTo(s, c, s, c - o, o), e.closePath(), e.moveTo(t, c), e.lineTo(t, c - o), e.arcTo(t, c, t + o, c, o), e.closePath(), !0;
|
|
35
|
+
}
|
|
36
|
+
function F(e) {
|
|
37
|
+
let t = e;
|
|
38
|
+
return {
|
|
39
|
+
radius: t?.extra?.cornerRadius ?? 0,
|
|
40
|
+
isEllipse: t?.adjustments?.crop?.ratio === k,
|
|
41
|
+
resizeWidth: t?.resize?.width ?? 0,
|
|
42
|
+
isCropping: t?.toolId === A
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function I(e, t, n) {
|
|
46
|
+
let r = e.filter((e) => e !== n), i = r.indexOf(t);
|
|
47
|
+
return i < 0 ? [...r, n] : [
|
|
48
|
+
...r.slice(0, i + 1),
|
|
49
|
+
n,
|
|
50
|
+
...r.slice(i + 1)
|
|
51
|
+
];
|
|
52
|
+
}
|
|
53
|
+
//#endregion
|
|
54
|
+
//#region packages/file-manager/src/components/FilerobotEditor/cornerRadius/cornerRadiusEraser.ts
|
|
55
|
+
var L = ["FIE_base-layer", "FIE_design-layer"], R = "em-corner-radius-eraser";
|
|
56
|
+
function z(e, t) {
|
|
57
|
+
let n = t.getLayer(), r = Number(t.getAttr("emRadius")) || 0;
|
|
58
|
+
if (!n || r <= 0 || t.getAttr("emSuspended") && !n.getAttr("isSaving")) return;
|
|
59
|
+
let i = Number(n.getAttr("clipWidth")) || 0, a = Number(n.getAttr("clipHeight")) || 0, o = Number(n.getAttr("originalSourceInitialScale")) || 1, s = Number(t.getAttr("emResizeWidth")) || i / o;
|
|
60
|
+
e.beginPath(), P(e, Number(n.getAttr("clipX")) || 0, Number(n.getAttr("clipY")) || 0, i, a, N(r, i, s)) && e.fillShape(t);
|
|
61
|
+
}
|
|
62
|
+
function B(e) {
|
|
63
|
+
if (e) return x.stages.find((t) => e.contains(t.container()));
|
|
64
|
+
}
|
|
65
|
+
function V(e, t) {
|
|
66
|
+
for (let n of L) {
|
|
67
|
+
let r = e.findOne(`#${n}`);
|
|
68
|
+
if (!r) continue;
|
|
69
|
+
let i = r.findOne(`.${R}`);
|
|
70
|
+
i || (i = new x.Shape({
|
|
71
|
+
name: R,
|
|
72
|
+
listening: !1,
|
|
73
|
+
fill: "#000",
|
|
74
|
+
globalCompositeOperation: "destination-out",
|
|
75
|
+
sceneFunc: z
|
|
76
|
+
}), r.add(i)), i.setAttrs({
|
|
77
|
+
emRadius: t.radius,
|
|
78
|
+
emResizeWidth: t.resizeWidth,
|
|
79
|
+
emSuspended: t.suspended
|
|
80
|
+
}), i.moveToTop(), r.batchDraw();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
//#endregion
|
|
84
|
+
//#region packages/file-manager/src/components/FilerobotEditor/cornerRadius/CornerRadiusTool.tsx
|
|
85
|
+
var H = 400, U = ({ size: e = 16 }) => /* @__PURE__ */ v("svg", {
|
|
86
|
+
width: e,
|
|
87
|
+
height: e,
|
|
88
|
+
viewBox: "0 0 16 16",
|
|
89
|
+
fill: "none",
|
|
90
|
+
"aria-hidden": "true",
|
|
91
|
+
children: /* @__PURE__ */ v("path", {
|
|
92
|
+
d: "M2.5 14V8.5a6 6 0 0 1 6-6H14",
|
|
93
|
+
stroke: "currentColor",
|
|
94
|
+
strokeWidth: "1.4",
|
|
95
|
+
strokeLinecap: "round"
|
|
96
|
+
})
|
|
97
|
+
});
|
|
98
|
+
function W(e) {
|
|
99
|
+
let t = e.shownImageDimensions ?? {}, n = e.adjustments?.crop ?? {}, r = t.originalSourceInitialScale || 1;
|
|
100
|
+
return {
|
|
101
|
+
width: e.resize?.width || (n.width || t.width || 0) / r,
|
|
102
|
+
height: e.resize?.height || (n.height || t.height || 0) / r
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
var G = ({ selectTool: e, t, isSelected: n }) => {
|
|
106
|
+
let r = w(), { radius: i, isEllipse: a, resizeWidth: o, isCropping: s } = F(r), c = r.config?.[O]?.onChange, l = m.useRef({
|
|
107
|
+
radius: i,
|
|
108
|
+
isEllipse: a,
|
|
109
|
+
resizeWidth: o,
|
|
110
|
+
isCropping: s
|
|
111
|
+
});
|
|
112
|
+
return l.current = {
|
|
113
|
+
radius: i,
|
|
114
|
+
isEllipse: a,
|
|
115
|
+
resizeWidth: o,
|
|
116
|
+
isCropping: s
|
|
117
|
+
}, m.useEffect(() => {
|
|
118
|
+
c?.({
|
|
119
|
+
radius: i,
|
|
120
|
+
isEllipse: a,
|
|
121
|
+
resizeWidth: o,
|
|
122
|
+
isCropping: s
|
|
123
|
+
});
|
|
124
|
+
}, [
|
|
125
|
+
c,
|
|
126
|
+
i,
|
|
127
|
+
a,
|
|
128
|
+
o,
|
|
129
|
+
s
|
|
130
|
+
]), m.useEffect(() => () => c?.({
|
|
131
|
+
...l.current,
|
|
132
|
+
isCropping: !1
|
|
133
|
+
}), [c]), /* @__PURE__ */ v(E, {
|
|
134
|
+
className: "FIE_corner-radius-tool-button",
|
|
135
|
+
id: O,
|
|
136
|
+
label: t("cornerRadiusTool"),
|
|
137
|
+
Icon: U,
|
|
138
|
+
onClick: e,
|
|
139
|
+
isSelected: n
|
|
140
|
+
});
|
|
141
|
+
}, K = ({ t: e }) => {
|
|
142
|
+
let t = w(), { dispatch: n } = t, { radius: r, isEllipse: i } = F(t), { width: a, height: o } = W(t), s = j(a, o), c = Math.min(r, s), [l, u] = m.useState(null), d = m.useRef(!1), f = m.useRef(void 0);
|
|
143
|
+
m.useEffect(() => () => clearTimeout(f.current), []);
|
|
144
|
+
let p = (e, t) => {
|
|
145
|
+
let i = M(e, a, o);
|
|
146
|
+
i !== r && n({
|
|
147
|
+
type: T,
|
|
148
|
+
payload: {
|
|
149
|
+
cornerRadius: i,
|
|
150
|
+
dismissHistory: !t
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
}, h = (e) => {
|
|
154
|
+
p(e, !d.current), d.current = !0, clearTimeout(f.current), f.current = setTimeout(() => {
|
|
155
|
+
d.current = !1;
|
|
156
|
+
}, H);
|
|
157
|
+
}, _ = () => {
|
|
158
|
+
l !== null && (p(l, !0), u(null));
|
|
159
|
+
};
|
|
160
|
+
return i ? /* @__PURE__ */ v("span", {
|
|
161
|
+
className: "FIE_corner-radius-hint",
|
|
162
|
+
children: e("cornerRadiusEllipseHint")
|
|
163
|
+
}) : /* @__PURE__ */ y("div", {
|
|
164
|
+
className: "FIE_corner-radius-options",
|
|
165
|
+
style: {
|
|
166
|
+
display: "flex",
|
|
167
|
+
alignItems: "center",
|
|
168
|
+
gap: 12
|
|
169
|
+
},
|
|
170
|
+
children: [/* @__PURE__ */ v(re, {
|
|
171
|
+
min: 0,
|
|
172
|
+
max: s,
|
|
173
|
+
step: 1,
|
|
174
|
+
value: c,
|
|
175
|
+
width: "160px",
|
|
176
|
+
style: { margin: 0 },
|
|
177
|
+
onChange: h
|
|
178
|
+
}), /* @__PURE__ */ v(g, {
|
|
179
|
+
size: "small",
|
|
180
|
+
min: 0,
|
|
181
|
+
max: s,
|
|
182
|
+
precision: 0,
|
|
183
|
+
value: l ?? c,
|
|
184
|
+
suffix: "px",
|
|
185
|
+
style: { width: 96 },
|
|
186
|
+
onChange: (e) => u(e === null ? 0 : Number(e)),
|
|
187
|
+
onBlur: _,
|
|
188
|
+
onPressEnter: _
|
|
189
|
+
})]
|
|
190
|
+
});
|
|
191
|
+
}, q = {
|
|
192
|
+
...C,
|
|
193
|
+
[O]: {
|
|
194
|
+
id: O,
|
|
195
|
+
Item: G,
|
|
196
|
+
ItemOptions: K
|
|
197
|
+
}
|
|
198
|
+
}, J = {
|
|
199
|
+
...S,
|
|
200
|
+
[b.ADJUST]: I(S[b.ADJUST] ?? [], ne.CROP, O)
|
|
201
|
+
};
|
|
202
|
+
//#endregion
|
|
203
|
+
//#region packages/file-manager/src/components/FilerobotEditor/cornerRadius/useCornerRadiusSync.ts
|
|
204
|
+
function Y(e) {
|
|
205
|
+
let [t, n] = m.useState(!1), r = m.useCallback((t) => {
|
|
206
|
+
let r = B(e.current);
|
|
207
|
+
r && V(r, {
|
|
208
|
+
radius: t.isEllipse ? 0 : t.radius,
|
|
209
|
+
resizeWidth: t.resizeWidth,
|
|
210
|
+
suspended: t.isCropping
|
|
211
|
+
}), n(t.radius > 0 && !t.isEllipse);
|
|
212
|
+
}, [e]);
|
|
213
|
+
return {
|
|
214
|
+
isRounded: t,
|
|
215
|
+
editorConfig: m.useMemo(() => ({
|
|
216
|
+
tools: q,
|
|
217
|
+
tabsToolsIds: J,
|
|
218
|
+
onModify: (e) => r(F(e)),
|
|
219
|
+
[O]: { onChange: r }
|
|
220
|
+
}), [r])
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
//#endregion
|
|
224
|
+
//#region packages/file-manager/src/components/FilerobotEditor/cornerRadius/cornerRadiusOutput.ts
|
|
225
|
+
function X(e) {
|
|
226
|
+
return e.isRounded ? {
|
|
227
|
+
forcePng: !0,
|
|
228
|
+
canOverwrite: !!e.sourceMimeType && o(e.sourceMimeType) === "image/png"
|
|
229
|
+
} : {
|
|
230
|
+
forcePng: !1,
|
|
231
|
+
canOverwrite: !0
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
function ie(e) {
|
|
235
|
+
let t = e.lastIndexOf(".");
|
|
236
|
+
return `${t > 0 ? e.slice(0, t) : e}.png`;
|
|
237
|
+
}
|
|
238
|
+
//#endregion
|
|
239
|
+
//#region packages/file-manager/src/components/FilerobotEditor/FilerobotEditor.tsx
|
|
240
|
+
var ae = {
|
|
241
|
+
container: D.filerobotEditorContainer,
|
|
242
|
+
body: D.filerobotEditorBody
|
|
243
|
+
}, oe = { presetsItems: p }, Z = (e, t = "image/png") => fetch(`data:${t};base64,${e}`).then((e) => e.blob());
|
|
244
|
+
function se(e, t) {
|
|
245
|
+
if (e === "json") return new Blob([t], { type: "application/json" });
|
|
246
|
+
if (e === "svg") return new Blob([t], { type: "image/svg+xml" });
|
|
247
|
+
let n = `image/${e}`;
|
|
248
|
+
if (t.startsWith("data:")) {
|
|
249
|
+
let e = c(t);
|
|
250
|
+
return e && e.startsWith("image/") && (n = e), Z(t.replace(/data:image\/[^;]+;base64,/, ""), o(n));
|
|
251
|
+
}
|
|
252
|
+
return Z(t, o(n));
|
|
253
|
+
}
|
|
254
|
+
function ce(e) {
|
|
255
|
+
return new Promise((t, n) => {
|
|
256
|
+
let r = new FileReader();
|
|
257
|
+
r.onload = () => t(r.result), r.onerror = () => n(r.error ?? /* @__PURE__ */ Error("Failed to convert blob to data URL")), r.readAsDataURL(e);
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
var le = [
|
|
261
|
+
{
|
|
262
|
+
label: "Arial",
|
|
263
|
+
value: "Arial"
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
label: "Helvetica",
|
|
267
|
+
value: "Helvetica"
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
label: "Verdana",
|
|
271
|
+
value: "Verdana"
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
label: "Tahoma",
|
|
275
|
+
value: "Tahoma"
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
label: "Trebuchet MS",
|
|
279
|
+
value: "Trebuchet MS"
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
label: "Times New Roman",
|
|
283
|
+
value: "Times New Roman"
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
label: "Georgia",
|
|
287
|
+
value: "Georgia"
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
label: "Courier New",
|
|
291
|
+
value: "Courier New"
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
label: "Impact",
|
|
295
|
+
value: "Impact"
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
label: "Comic Sans MS",
|
|
299
|
+
value: "Comic Sans MS"
|
|
300
|
+
}
|
|
301
|
+
], Q = ({ visible: c, onClose: p, file: g, onSave: ne, onSaveCopy: x }) => {
|
|
302
|
+
let { t: S } = l(), C = r(), w = s(), { options: T } = a(), { i18n: re } = l(), { config: E } = T, { getFileData: O, resolveFileForEditByUrl: k } = w, [A, j] = m.useState(!1), [M, N] = m.useState(null), [P, F] = m.useState(""), [I, L] = m.useState(!1), [R, z] = m.useState(null), [B, V] = m.useState(null), H = m.useRef(void 0), U = m.useRef(void 0), W = m.useRef(void 0), G = m.useRef(void 0), K = m.useRef(null), q = Y(K);
|
|
303
|
+
H.current = ne, U.current = x, m.useEffect(() => {
|
|
304
|
+
g && (async () => {
|
|
305
|
+
if (G.current !== g) {
|
|
306
|
+
if (typeof g == "object") {
|
|
307
|
+
z(g);
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
G.current = g, j(!0);
|
|
311
|
+
try {
|
|
312
|
+
if (g.startsWith("data:")) z({
|
|
313
|
+
thumbnail: g,
|
|
314
|
+
saveWithoutFolder: !0
|
|
315
|
+
});
|
|
316
|
+
else {
|
|
317
|
+
let e = await k(g);
|
|
318
|
+
G.current === g && z(e);
|
|
319
|
+
}
|
|
320
|
+
} catch (e) {
|
|
321
|
+
console.error("Failed to load file for editor:", e), G.current === g && (G.current = null), p?.();
|
|
322
|
+
} finally {
|
|
323
|
+
j(!1);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
})();
|
|
327
|
+
}, [
|
|
328
|
+
g,
|
|
329
|
+
p,
|
|
330
|
+
k
|
|
331
|
+
]);
|
|
332
|
+
let J = m.useCallback(async (e) => {
|
|
333
|
+
if (typeof e.thumbnail == "string" && e.thumbnail.startsWith("data:")) return e.thumbnail;
|
|
334
|
+
let t = await O(e.id, !0);
|
|
335
|
+
if (!t) throw Error(S("Error loading image"));
|
|
336
|
+
return new Promise((e) => {
|
|
337
|
+
let n = new FileReader();
|
|
338
|
+
n.onload = () => e(n.result), n.readAsDataURL(t);
|
|
339
|
+
});
|
|
340
|
+
}, [O, S]);
|
|
341
|
+
m.useEffect(() => {
|
|
342
|
+
if (!M && c && R) {
|
|
343
|
+
let e = !1;
|
|
344
|
+
return (async () => {
|
|
345
|
+
j(!0);
|
|
346
|
+
try {
|
|
347
|
+
let t = await J(R);
|
|
348
|
+
if (!e) {
|
|
349
|
+
N(t);
|
|
350
|
+
let e = n(R, "image/png");
|
|
351
|
+
F(e.mimeType);
|
|
352
|
+
}
|
|
353
|
+
} catch (t) {
|
|
354
|
+
e || (C.error({
|
|
355
|
+
id: "IMAGE_DOWNLOAD_FAILED",
|
|
356
|
+
innerException: t,
|
|
357
|
+
message: S("Error loading image"),
|
|
358
|
+
placement: "bottomRight",
|
|
359
|
+
data: {}
|
|
360
|
+
}), p?.());
|
|
361
|
+
} finally {
|
|
362
|
+
j(!1);
|
|
363
|
+
}
|
|
364
|
+
})(), () => {
|
|
365
|
+
e = !0;
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
}, [
|
|
369
|
+
R,
|
|
370
|
+
J,
|
|
371
|
+
M,
|
|
372
|
+
p,
|
|
373
|
+
S,
|
|
374
|
+
c
|
|
375
|
+
]);
|
|
376
|
+
let Z = m.useCallback(async (e, n, r) => {
|
|
377
|
+
let i = await se(r, e), a = o(i.type || `image/${r}`), s = E?.compessorUrl ?? E?.compressorUrl;
|
|
378
|
+
if (a.startsWith("image/")) try {
|
|
379
|
+
let e = new File([i], n, { type: a }), r = await u(e, {
|
|
380
|
+
maxSizeMB: E?.compressMaxSize,
|
|
381
|
+
maxWidthOrHeight: E?.compressMaxWidthOrHeight,
|
|
382
|
+
mimeType: a,
|
|
383
|
+
fileName: n,
|
|
384
|
+
libURL: s,
|
|
385
|
+
enableCompression: t(E, a),
|
|
386
|
+
compressBySize: E?.compressEditedImages === !0
|
|
387
|
+
});
|
|
388
|
+
i = r, a = r.type;
|
|
389
|
+
} catch (e) {
|
|
390
|
+
console.warn("Image preparation failed, using original:", e);
|
|
391
|
+
}
|
|
392
|
+
return {
|
|
393
|
+
blob: i,
|
|
394
|
+
mimeType: a,
|
|
395
|
+
thumbnailDataUrl: await ce(i)
|
|
396
|
+
};
|
|
397
|
+
}, [E]), Q = m.useCallback(async (e, t, n, r, i = !1) => {
|
|
398
|
+
let a = r === "save" ? H.current : U.current;
|
|
399
|
+
if (R && a) try {
|
|
400
|
+
j(!0);
|
|
401
|
+
let { blob: o, mimeType: s, thumbnailDataUrl: c } = await Z(e, t, n), l = await a({
|
|
402
|
+
...R,
|
|
403
|
+
thumbnail: c,
|
|
404
|
+
size: o.size,
|
|
405
|
+
date: (/* @__PURE__ */ new Date()).toISOString().split("T")[0],
|
|
406
|
+
type: s,
|
|
407
|
+
folderId: R.folderId || "",
|
|
408
|
+
name: i ? t : R.name || t,
|
|
409
|
+
extension: i ? n : R.extension || (R.name || t).split(".").pop()?.toLowerCase() || ""
|
|
410
|
+
}, {
|
|
411
|
+
blob: o,
|
|
412
|
+
mimeType: s,
|
|
413
|
+
thumbnail: c,
|
|
414
|
+
mode: r
|
|
415
|
+
});
|
|
416
|
+
return j(!1), l;
|
|
417
|
+
} catch (e) {
|
|
418
|
+
console.error("Error saving:", e), V(String(e?.message || e)), j(!1);
|
|
419
|
+
}
|
|
420
|
+
}, [R, Z]), ue = m.useCallback((e) => {
|
|
421
|
+
if (!W.current || !R) {
|
|
422
|
+
console.error("FIE getCurrentImgData недоступен или файл не загружен");
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
425
|
+
let t = n(R, P), r = X({
|
|
426
|
+
sourceMimeType: t.mimeType,
|
|
427
|
+
isRounded: q.isRounded
|
|
428
|
+
});
|
|
429
|
+
if (e === "save" && !r.canOverwrite) return;
|
|
430
|
+
let a = r.forcePng ? {
|
|
431
|
+
extension: "png",
|
|
432
|
+
mimeType: "image/png"
|
|
433
|
+
} : t, o = r.forcePng ? ie(R.name || "edited-image") : R.name || "edited-image";
|
|
434
|
+
try {
|
|
435
|
+
let { imageData: t, designState: n } = W.current({
|
|
436
|
+
name: o.replace(/\.[^/.]+$/, ""),
|
|
437
|
+
extension: a.extension,
|
|
438
|
+
quality: i.QUALITY
|
|
439
|
+
}, void 0, !1);
|
|
440
|
+
console.log("[FIE PoC] getCurrentImgData ->", t, n);
|
|
441
|
+
let s = t.imageBase64 ?? (t.imageCanvas ? t.imageCanvas.toDataURL(a.mimeType) : void 0);
|
|
442
|
+
if (!s) throw Error("FIE не вернул ни imageBase64, ни imageCanvas");
|
|
443
|
+
Q(s, o, a.extension, e, r.forcePng);
|
|
444
|
+
} catch (e) {
|
|
445
|
+
console.error("🎨 Ошибка получения данных из FIE:", e), V(String(e?.message || e));
|
|
446
|
+
}
|
|
447
|
+
}, [
|
|
448
|
+
q.isRounded,
|
|
449
|
+
R,
|
|
450
|
+
P,
|
|
451
|
+
Q
|
|
452
|
+
]), $ = E?.locale ? E?.locale.replace("_", "-") : "en", de = m.useMemo(() => f($), [$]);
|
|
453
|
+
matchMedia(e).matches, E?.theme === "system" || E?.theme;
|
|
454
|
+
let fe = {
|
|
455
|
+
theme: void 0,
|
|
456
|
+
useBackendTranslations: !1,
|
|
457
|
+
language: $.split("-")[0] || "en",
|
|
458
|
+
translations: de,
|
|
459
|
+
tabsIds: [
|
|
460
|
+
b.ADJUST,
|
|
461
|
+
b.FINETUNE,
|
|
462
|
+
b.FILTERS,
|
|
463
|
+
b.ANNOTATE,
|
|
464
|
+
b.RESIZE
|
|
465
|
+
],
|
|
466
|
+
defaultTabId: b.ADJUST,
|
|
467
|
+
savingPixelRatio: 1,
|
|
468
|
+
previewPixelRatio: 1,
|
|
469
|
+
avoidChangesNotSavedAlertOnLeave: !0,
|
|
470
|
+
defaultSavedImageName: R?.name?.replace(/\.[^/.]+$/, "") || "image",
|
|
471
|
+
removeSaveButton: !0,
|
|
472
|
+
observePluginContainerSize: !0,
|
|
473
|
+
Crop: oe,
|
|
474
|
+
Text: {
|
|
475
|
+
fontFamily: "Arial",
|
|
476
|
+
fonts: le
|
|
477
|
+
},
|
|
478
|
+
getCurrentImgDataFnRef: W,
|
|
479
|
+
...q.editorConfig
|
|
480
|
+
}, pe = !!R?.id && E?.features?.enableUpdateFile !== !1, { canOverwrite: me } = X({
|
|
481
|
+
sourceMimeType: R ? n(R, P).mimeType : "",
|
|
482
|
+
isRounded: q.isRounded
|
|
483
|
+
});
|
|
484
|
+
return /* @__PURE__ */ v(_, {
|
|
485
|
+
title: R?.name ? S("Editing: {{name}}", { name: R.name }) : S("Editing image"),
|
|
486
|
+
open: c,
|
|
487
|
+
closeIcon: null,
|
|
488
|
+
onCancel: p,
|
|
489
|
+
afterOpenChange: (e) => L(e),
|
|
490
|
+
forceRender: !0,
|
|
491
|
+
width: "100%",
|
|
492
|
+
getContainer: T.getModalContainer,
|
|
493
|
+
className: D.filerobotEditorModal,
|
|
494
|
+
classNames: ae,
|
|
495
|
+
footer: [
|
|
496
|
+
/* @__PURE__ */ v(h, {
|
|
497
|
+
onClick: p,
|
|
498
|
+
disabled: !I || A,
|
|
499
|
+
children: S("Cancel")
|
|
500
|
+
}, "cancel"),
|
|
501
|
+
/* @__PURE__ */ v(h, {
|
|
502
|
+
type: "primary",
|
|
503
|
+
onClick: () => ue("saveCopy"),
|
|
504
|
+
loading: A,
|
|
505
|
+
children: S("Save as copy and choose")
|
|
506
|
+
}, "save-copy"),
|
|
507
|
+
...pe ? [/* @__PURE__ */ v(ee, {
|
|
508
|
+
title: me ? void 0 : S("Rounded corners are saved as a PNG copy: the original format has no transparency"),
|
|
509
|
+
children: /* @__PURE__ */ v(h, {
|
|
510
|
+
type: "primary",
|
|
511
|
+
onClick: () => ue("save"),
|
|
512
|
+
loading: A,
|
|
513
|
+
disabled: !me,
|
|
514
|
+
children: S("Save and choose")
|
|
515
|
+
})
|
|
516
|
+
}, "save")] : []
|
|
517
|
+
],
|
|
518
|
+
mask: { closable: !1 },
|
|
519
|
+
destroyOnHidden: !1,
|
|
520
|
+
children: /* @__PURE__ */ y("div", {
|
|
521
|
+
ref: K,
|
|
522
|
+
style: {
|
|
523
|
+
position: "relative",
|
|
524
|
+
width: "100%",
|
|
525
|
+
height: "100%"
|
|
526
|
+
},
|
|
527
|
+
children: [
|
|
528
|
+
c && I && M ? /* @__PURE__ */ v(te, {
|
|
529
|
+
source: M,
|
|
530
|
+
...fe
|
|
531
|
+
}) : /* @__PURE__ */ v("div", {
|
|
532
|
+
style: {
|
|
533
|
+
position: "absolute",
|
|
534
|
+
inset: 0,
|
|
535
|
+
display: "flex",
|
|
536
|
+
alignItems: "center",
|
|
537
|
+
justifyContent: "center"
|
|
538
|
+
},
|
|
539
|
+
children: /* @__PURE__ */ v("span", {
|
|
540
|
+
style: {
|
|
541
|
+
fontSize: 14,
|
|
542
|
+
color: "#555"
|
|
543
|
+
},
|
|
544
|
+
children: S("Loading editor...")
|
|
545
|
+
})
|
|
546
|
+
}),
|
|
547
|
+
B && /* @__PURE__ */ y("div", {
|
|
548
|
+
style: {
|
|
549
|
+
position: "absolute",
|
|
550
|
+
bottom: 8,
|
|
551
|
+
left: 8,
|
|
552
|
+
right: 8,
|
|
553
|
+
background: "#fff1f0",
|
|
554
|
+
border: "1px solid #ffa39e",
|
|
555
|
+
color: "#a8071a",
|
|
556
|
+
padding: 8,
|
|
557
|
+
fontSize: 12,
|
|
558
|
+
zIndex: 100
|
|
559
|
+
},
|
|
560
|
+
children: ["[FIE PoC] ", B]
|
|
561
|
+
}),
|
|
562
|
+
A && /* @__PURE__ */ v(d, { style: {
|
|
563
|
+
position: "absolute",
|
|
564
|
+
top: 0,
|
|
565
|
+
background: "var(--em-colorBgLayout)",
|
|
566
|
+
zIndex: 100,
|
|
567
|
+
opacity: .7
|
|
568
|
+
} })
|
|
569
|
+
]
|
|
570
|
+
})
|
|
571
|
+
});
|
|
572
|
+
};
|
|
573
|
+
//#endregion
|
|
574
|
+
export { Q as FilerobotEditor, Y as useCornerRadiusSync };
|
|
575
|
+
|
|
576
|
+
//# sourceMappingURL=file-manager-FilerobotEditor.js.map
|