@layers-app/editor 0.0.10 → 0.0.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.
- package/dist/index.js +2 -2
- package/dist/index.umd.cjs +52 -1926
- package/dist/layers.BngHKUYL.js +37817 -0
- package/dist/{DSD.DDmZJfof.js → layers.C4lrr1t_.js} +23 -23
- package/dist/layers.D95tWX8p.js +16605 -0
- package/dist/{DSD.AwtUbg5v.js → layers.DKx4HQvO.js} +10 -10
- package/dist/{DSD.xqZnHMlT.js → layers.DWcfRy1Z.js} +76 -76
- package/dist/{DSD.RjfD_Vp_.js → layers.DwVbMntu.js} +21 -21
- package/dist/layers.qcUUnbCI.js +281 -0
- package/package.json +2 -2
- package/dist/DSD.CEKnmfYP.js +0 -5658
- package/dist/DSD.CLhKx58f.js +0 -103219
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
import { jsx as o, jsxs as G } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as V, useState as I, useContext as q, useEffect as w } from "react";
|
|
3
|
+
import { useTranslation as J } from "react-i18next";
|
|
4
|
+
import { l as Q, u as X, C as Y, a as Z, b as K, c as C, $ as E, t as ee, I as te, E as ie, d as oe, R as ne, F as ae } from "./layers.BngHKUYL.js";
|
|
5
|
+
import { LoadingOverlay as T, Flex as se, Alert as re } from "@mantine/core";
|
|
6
|
+
import { IconInfoCircle as le } from "@tabler/icons-react";
|
|
7
|
+
const j = (t) => {
|
|
8
|
+
const {
|
|
9
|
+
width: c,
|
|
10
|
+
height: a,
|
|
11
|
+
isLoading: s,
|
|
12
|
+
isError: d,
|
|
13
|
+
src: g,
|
|
14
|
+
id: f,
|
|
15
|
+
altText: u,
|
|
16
|
+
imageRef: b,
|
|
17
|
+
maxWidth: v
|
|
18
|
+
} = t;
|
|
19
|
+
return /* @__PURE__ */ G(
|
|
20
|
+
"div",
|
|
21
|
+
{
|
|
22
|
+
className: "media-wrapper",
|
|
23
|
+
style: {
|
|
24
|
+
width: c,
|
|
25
|
+
height: a,
|
|
26
|
+
display: "inline-flex",
|
|
27
|
+
position: "relative"
|
|
28
|
+
},
|
|
29
|
+
children: [
|
|
30
|
+
/* @__PURE__ */ o(
|
|
31
|
+
T,
|
|
32
|
+
{
|
|
33
|
+
visible: s,
|
|
34
|
+
zIndex: 1e3,
|
|
35
|
+
overlayProps: { backgroundOpacity: 0.5 },
|
|
36
|
+
loaderProps: { size: 24, color: "black" }
|
|
37
|
+
}
|
|
38
|
+
),
|
|
39
|
+
/* @__PURE__ */ o(
|
|
40
|
+
T,
|
|
41
|
+
{
|
|
42
|
+
visible: d,
|
|
43
|
+
zIndex: 1e3,
|
|
44
|
+
overlayProps: { backgroundOpacity: 0.5 },
|
|
45
|
+
loaderProps: {
|
|
46
|
+
children: /* @__PURE__ */ o(se, { bg: "white", maw: 300, justify: "center", children: /* @__PURE__ */ o(
|
|
47
|
+
re,
|
|
48
|
+
{
|
|
49
|
+
variant: "light",
|
|
50
|
+
color: "red",
|
|
51
|
+
title: "Ошибка загрузки",
|
|
52
|
+
icon: /* @__PURE__ */ o(le, {}),
|
|
53
|
+
children: "Попробуйте загрузить заново."
|
|
54
|
+
}
|
|
55
|
+
) })
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
),
|
|
59
|
+
/* @__PURE__ */ o(
|
|
60
|
+
de,
|
|
61
|
+
{
|
|
62
|
+
className: null,
|
|
63
|
+
src: g,
|
|
64
|
+
altText: u,
|
|
65
|
+
imageRef: b,
|
|
66
|
+
width: "inherit",
|
|
67
|
+
height: "inherit",
|
|
68
|
+
maxWidth: v || "auto",
|
|
69
|
+
id: f
|
|
70
|
+
}
|
|
71
|
+
)
|
|
72
|
+
]
|
|
73
|
+
}
|
|
74
|
+
);
|
|
75
|
+
};
|
|
76
|
+
function de({
|
|
77
|
+
altText: t,
|
|
78
|
+
className: c,
|
|
79
|
+
imageRef: a,
|
|
80
|
+
src: s,
|
|
81
|
+
width: d,
|
|
82
|
+
height: g,
|
|
83
|
+
maxWidth: f,
|
|
84
|
+
id: u
|
|
85
|
+
}) {
|
|
86
|
+
return /* @__PURE__ */ o(
|
|
87
|
+
"img",
|
|
88
|
+
{
|
|
89
|
+
className: c || void 0,
|
|
90
|
+
src: s,
|
|
91
|
+
alt: t,
|
|
92
|
+
ref: a,
|
|
93
|
+
style: {
|
|
94
|
+
height: g,
|
|
95
|
+
maxWidth: f,
|
|
96
|
+
width: d
|
|
97
|
+
},
|
|
98
|
+
draggable: "false",
|
|
99
|
+
"data-id": u
|
|
100
|
+
}
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
function pe({
|
|
104
|
+
src: t,
|
|
105
|
+
altText: c,
|
|
106
|
+
nodeKey: a,
|
|
107
|
+
width: s,
|
|
108
|
+
height: d,
|
|
109
|
+
maxWidth: g,
|
|
110
|
+
showCaption: f,
|
|
111
|
+
caption: u,
|
|
112
|
+
id: b,
|
|
113
|
+
create: v,
|
|
114
|
+
alignment: _
|
|
115
|
+
}) {
|
|
116
|
+
const z = V(null), [R, y] = I(!0), [k, D] = I(!1), { isCollabActive: A } = Q(), [h] = X(), [m, S] = I(!0), [r, W] = I({
|
|
117
|
+
width: 0,
|
|
118
|
+
height: 0
|
|
119
|
+
}), { fetchUploadImage: F, fetchDeleteImage: L } = q(Y), { t: N } = J();
|
|
120
|
+
w(() => {
|
|
121
|
+
if (!t || t.startsWith("data:image/")) {
|
|
122
|
+
y(!1);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
const e = new Image();
|
|
126
|
+
e.src = t, e.onload = () => y(!1), e.onerror = () => {
|
|
127
|
+
y(!1), D(!0);
|
|
128
|
+
};
|
|
129
|
+
}, [t]);
|
|
130
|
+
const U = (e, n) => {
|
|
131
|
+
h.update(() => {
|
|
132
|
+
ae(null);
|
|
133
|
+
const l = C(a);
|
|
134
|
+
E(l) && l.setWidthAndHeight(e, n);
|
|
135
|
+
});
|
|
136
|
+
}, { historyState: O } = Z(), {
|
|
137
|
+
settings: { showNestedEditorTreeView: H }
|
|
138
|
+
} = K(), [x, p] = I(!1);
|
|
139
|
+
function $(e) {
|
|
140
|
+
return e.endsWith(".svg") || e.includes("image/svg+xml");
|
|
141
|
+
}
|
|
142
|
+
function B(e) {
|
|
143
|
+
return new Promise((n, l) => {
|
|
144
|
+
if ($(e)) {
|
|
145
|
+
n(0);
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
const i = new Image();
|
|
149
|
+
i.src = e, i.onload = () => {
|
|
150
|
+
n(i.width);
|
|
151
|
+
}, i.onerror = () => {
|
|
152
|
+
l(new Error("Failed to load image"));
|
|
153
|
+
};
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
return w(() => {
|
|
157
|
+
v && p(!0);
|
|
158
|
+
}, [v]), w(() => {
|
|
159
|
+
let e = s, n = d, l = 100;
|
|
160
|
+
t && B(t).then((i) => {
|
|
161
|
+
typeof e == "number" && e < l && i < l ? (S(!0), W({
|
|
162
|
+
width: e,
|
|
163
|
+
height: n
|
|
164
|
+
})) : i < l ? (S(!0), W({
|
|
165
|
+
width: "auto",
|
|
166
|
+
height: "auto"
|
|
167
|
+
})) : (W({
|
|
168
|
+
width: i,
|
|
169
|
+
height: i
|
|
170
|
+
}), S(!1));
|
|
171
|
+
});
|
|
172
|
+
}, [t]), w(() => {
|
|
173
|
+
r.width && r.height && m && h.update(() => {
|
|
174
|
+
const e = C(a);
|
|
175
|
+
E(e) && e.setWidthAndHeight(r.width, r.height);
|
|
176
|
+
});
|
|
177
|
+
}, [r.width, r.height, m]), w(() => {
|
|
178
|
+
const e = document.documentElement;
|
|
179
|
+
ee(x, e);
|
|
180
|
+
}, [x]), t ? m ? /* @__PURE__ */ o(
|
|
181
|
+
j,
|
|
182
|
+
{
|
|
183
|
+
width: r.width,
|
|
184
|
+
height: r.height,
|
|
185
|
+
isLoading: R,
|
|
186
|
+
isError: k,
|
|
187
|
+
isIcon: m,
|
|
188
|
+
src: t,
|
|
189
|
+
id: b,
|
|
190
|
+
editor: h,
|
|
191
|
+
nodeKey: a,
|
|
192
|
+
fetchDeleteImage: L,
|
|
193
|
+
altText: c,
|
|
194
|
+
imageRef: z,
|
|
195
|
+
maxWidth: g,
|
|
196
|
+
showCaption: f,
|
|
197
|
+
caption: u,
|
|
198
|
+
isCollabActive: A,
|
|
199
|
+
historyState: O,
|
|
200
|
+
showNestedEditorTreeView: H,
|
|
201
|
+
t: N
|
|
202
|
+
}
|
|
203
|
+
) : /* @__PURE__ */ o(
|
|
204
|
+
ne,
|
|
205
|
+
{
|
|
206
|
+
editor: h,
|
|
207
|
+
isIcon: m,
|
|
208
|
+
width: typeof s == "string" && s.includes("%") ? parseFloat(s) : s,
|
|
209
|
+
height: typeof d == "string" && d.includes("%") ? parseFloat(d) : s,
|
|
210
|
+
initialWidth: r.width || "",
|
|
211
|
+
initialHeight: r.height || "",
|
|
212
|
+
onResizeEnd: U,
|
|
213
|
+
alignment: _,
|
|
214
|
+
children: /* @__PURE__ */ o(
|
|
215
|
+
j,
|
|
216
|
+
{
|
|
217
|
+
width: "inherit",
|
|
218
|
+
height: "inherit",
|
|
219
|
+
isLoading: R,
|
|
220
|
+
isError: k,
|
|
221
|
+
isIcon: m,
|
|
222
|
+
src: t,
|
|
223
|
+
id: b,
|
|
224
|
+
editor: h,
|
|
225
|
+
nodeKey: a,
|
|
226
|
+
fetchDeleteImage: L,
|
|
227
|
+
altText: c,
|
|
228
|
+
imageRef: z,
|
|
229
|
+
maxWidth: g,
|
|
230
|
+
showCaption: f,
|
|
231
|
+
caption: u,
|
|
232
|
+
isCollabActive: A,
|
|
233
|
+
historyState: O,
|
|
234
|
+
showNestedEditorTreeView: H,
|
|
235
|
+
t: N
|
|
236
|
+
}
|
|
237
|
+
)
|
|
238
|
+
}
|
|
239
|
+
) : /* @__PURE__ */ o(
|
|
240
|
+
te,
|
|
241
|
+
{
|
|
242
|
+
uploading: !1,
|
|
243
|
+
onUpload: (e) => {
|
|
244
|
+
!F || !e.length || (e.forEach((n, l) => {
|
|
245
|
+
F(n, (i, M) => {
|
|
246
|
+
l === 0 ? h.update(() => {
|
|
247
|
+
const P = C(a);
|
|
248
|
+
E(P) && (P.setSrc(i), P.setId(M));
|
|
249
|
+
}) : h.dispatchCommand(oe, {
|
|
250
|
+
altText: "",
|
|
251
|
+
src: i,
|
|
252
|
+
id: M
|
|
253
|
+
});
|
|
254
|
+
});
|
|
255
|
+
}), p(!1));
|
|
256
|
+
},
|
|
257
|
+
popoverProps: {
|
|
258
|
+
opened: x,
|
|
259
|
+
position: "bottom",
|
|
260
|
+
onChange: p
|
|
261
|
+
},
|
|
262
|
+
onChange: (e) => {
|
|
263
|
+
p(!1), h.update(() => {
|
|
264
|
+
const n = C(a);
|
|
265
|
+
E(n) && n.setSrc(e);
|
|
266
|
+
});
|
|
267
|
+
},
|
|
268
|
+
children: /* @__PURE__ */ o(
|
|
269
|
+
ie,
|
|
270
|
+
{
|
|
271
|
+
title: N("editor.image.add_photo"),
|
|
272
|
+
icon: "photo",
|
|
273
|
+
onClick: () => p(!x)
|
|
274
|
+
}
|
|
275
|
+
)
|
|
276
|
+
}
|
|
277
|
+
);
|
|
278
|
+
}
|
|
279
|
+
export {
|
|
280
|
+
pe as default
|
|
281
|
+
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@layers-app/editor",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.11",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"start": "vite",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"sass": "^1.71.1",
|
|
69
69
|
"typescript": "^5.5.4",
|
|
70
70
|
"typescript-eslint": "^8.2.0",
|
|
71
|
-
"vite": "^
|
|
71
|
+
"vite": "^6.2.2",
|
|
72
72
|
"vite-plugin-commonjs": "^0.10.1",
|
|
73
73
|
"vite-plugin-css-injected-by-js": "^3.5.0",
|
|
74
74
|
"vite-plugin-dts": "^4.0.0-beta.1",
|