@layers-app/editor 0.5.10-optimization → 0.6.0-specific.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.
Files changed (44) hide show
  1. package/README.md +2 -252
  2. package/dist/index.cjs +2 -2
  3. package/dist/index.d.ts +3 -4
  4. package/dist/index.js +11 -12
  5. package/dist/layers.BAh77n3h.js +53500 -0
  6. package/dist/layers.BR_PAAvW.js +319 -0
  7. package/dist/layers.BVrvmVeX.js +343 -0
  8. package/dist/layers.BeZDS7Yo.js +1 -0
  9. package/dist/layers.C9DRKDGJ.js +1 -0
  10. package/dist/layers.Dawun4Ev.js +44715 -0
  11. package/dist/layers.DwBS80Kn.js +285 -0
  12. package/dist/layers.Zo4c9OM_.js +161 -0
  13. package/package.json +23 -66
  14. package/dist/ExcalidrawComponent-D7Z_2awF.cjs +0 -1
  15. package/dist/ExcalidrawComponent-Re4zFgLg.js +0 -283
  16. package/dist/InlineImageComponent-DHgCaPNk.cjs +0 -1
  17. package/dist/InlineImageComponent-kXhZcmF6.js +0 -265
  18. package/dist/collaboration-C7xVk0Zj.cjs +0 -4
  19. package/dist/collaboration-Cn7KizEJ.js +0 -5997
  20. package/dist/excalidraw-C-6bid_P.js +0 -16497
  21. package/dist/excalidraw-DpwKTNBz.cjs +0 -574
  22. package/dist/index-B4yOqKUQ.cjs +0 -1
  23. package/dist/index-BZu8Qnrg.cjs +0 -1
  24. package/dist/index-CFA9Drk2.cjs +0 -16
  25. package/dist/index-CX5msaMB.js +0 -296
  26. package/dist/index-CbQX0N2c.js +0 -136
  27. package/dist/index-DEC5JR_F.js +0 -60
  28. package/dist/index-Dan3tqoj.cjs +0 -1
  29. package/dist/index-WCOc4LNL.js +0 -16600
  30. package/dist/lexical-2rxs76dr.cjs +0 -41
  31. package/dist/lexical-C60GkwxR.js +0 -13122
  32. package/dist/lexical-code-DKIWiZdJ.js +0 -604
  33. package/dist/lexical-code-VafvPacU.cjs +0 -9
  34. package/dist/lexical-collab-1tX9tFVC.js +0 -1025
  35. package/dist/lexical-collab-Nk2LVpJv.cjs +0 -1
  36. package/dist/lexical-file-C52Mze5k.cjs +0 -1
  37. package/dist/lexical-file-DjHP4vVw.js +0 -43
  38. package/dist/lexical-markdown-BSl_ahWw.cjs +0 -12
  39. package/dist/lexical-markdown-DcEwQQba.js +0 -488
  40. package/dist/lodash-3PEMjFQT.cjs +0 -1
  41. package/dist/lodash-jftOdrxX.js +0 -711
  42. package/dist/stats.html +0 -4949
  43. package/dist/vendor-BrXDSyZX.js +0 -136433
  44. package/dist/vendor-Bt6Lma3y.cjs +0 -2469
@@ -0,0 +1,285 @@
1
+ import { jsx as d, jsxs as J } from "react/jsx-runtime";
2
+ import { useRef as Q, useState as I, useContext as X, useEffect as g } from "react";
3
+ import { useTranslation as Y } from "react-i18next";
4
+ import { l as Z, o as K, C as ee, m as P, u as te, a as ie, b as L, $ as W, t as oe, U as ae, I as ne, c as se, E as re, R as de, p as F, d as le } from "./layers.Dawun4Ev.js";
5
+ import { LoadingOverlay as he } from "@mantine/core";
6
+ import { showErrorNotification as ge } from "@layers-app/shared";
7
+ const T = (t) => {
8
+ const {
9
+ width: u,
10
+ height: n,
11
+ isLoading: l,
12
+ isError: v,
13
+ src: m,
14
+ id: f,
15
+ altText: c,
16
+ imageRef: p,
17
+ maxWidth: h
18
+ } = t;
19
+ return /* @__PURE__ */ J(
20
+ "div",
21
+ {
22
+ className: "media-wrapper",
23
+ style: {
24
+ width: u,
25
+ height: n,
26
+ display: "inline-flex",
27
+ position: "relative"
28
+ },
29
+ children: [
30
+ /* @__PURE__ */ d(
31
+ he,
32
+ {
33
+ visible: l,
34
+ zIndex: 1e3,
35
+ overlayProps: { backgroundOpacity: 0.5 },
36
+ loaderProps: { size: 24, color: "black" }
37
+ }
38
+ ),
39
+ /* @__PURE__ */ d(
40
+ ue,
41
+ {
42
+ className: null,
43
+ src: m,
44
+ altText: c,
45
+ imageRef: p,
46
+ width: "inherit",
47
+ height: "inherit",
48
+ maxWidth: h || "auto",
49
+ id: f
50
+ }
51
+ )
52
+ ]
53
+ }
54
+ );
55
+ };
56
+ function ue({
57
+ altText: t,
58
+ className: u,
59
+ imageRef: n,
60
+ src: l,
61
+ width: v,
62
+ height: m,
63
+ maxWidth: f,
64
+ id: c
65
+ }) {
66
+ const [p, h] = I(!1);
67
+ return /* @__PURE__ */ d(
68
+ "img",
69
+ {
70
+ className: `${u || void 0} ${p ? "" : "loading"}`,
71
+ src: l,
72
+ alt: t,
73
+ ref: n,
74
+ style: {
75
+ height: m,
76
+ maxWidth: f,
77
+ width: v
78
+ },
79
+ onLoad: () => {
80
+ l.includes("splash") ? setTimeout(() => {
81
+ h(!0);
82
+ }, 100) : h(!0);
83
+ },
84
+ draggable: "false",
85
+ "data-id": c
86
+ }
87
+ );
88
+ }
89
+ function xe({
90
+ src: t,
91
+ altText: u,
92
+ nodeKey: n,
93
+ width: l,
94
+ height: v,
95
+ maxWidth: m,
96
+ showCaption: f,
97
+ caption: c,
98
+ id: p,
99
+ create: h,
100
+ alignment: j
101
+ }) {
102
+ var _, $;
103
+ const R = Q(null), [E, C] = I(!0), { isCollabActive: A } = Z(), [r] = K(), [w, y] = I(!0), [s, z] = I({
104
+ width: 0,
105
+ height: 0
106
+ }), { fetchUploadMedia: M, fetchDeleteMedia: O, maxFileSize: me } = X(ee), b = P.has(t) && (((_ = P.get(t)) == null ? void 0 : _.mediaNodeKeys.length) === 0 || (($ = P.get(t)) == null ? void 0 : $.mediaNodeKeys.length) === void 0 || t.trim() === ""), { t: N } = Y(), [fe, B] = I(0);
107
+ g(() => r.registerDecoratorListener(() => {
108
+ B((e) => e + 1);
109
+ }), [b]), g(() => {
110
+ if (!t || t.startsWith("data:image/") || !t.trim()) {
111
+ C(!1);
112
+ return;
113
+ }
114
+ const e = new Image();
115
+ e.src = t, e.onload = () => C(!1), e.onerror = () => {
116
+ C(!1);
117
+ };
118
+ }, [t, b]);
119
+ const G = (e, i) => {
120
+ r.update(() => {
121
+ le(null);
122
+ const o = L(n);
123
+ W(o) && o.setWidthAndHeight(e, i);
124
+ });
125
+ }, { historyState: U } = te(), {
126
+ settings: { showNestedEditorTreeView: k }
127
+ } = ie(), [S, x] = I(!1);
128
+ function V(e) {
129
+ return e.endsWith(".svg") || e.includes("image/svg+xml");
130
+ }
131
+ function q(e) {
132
+ return new Promise((i, o) => {
133
+ if (V(e)) {
134
+ i(0);
135
+ return;
136
+ }
137
+ const a = new Image();
138
+ a.src = e, a.onload = () => {
139
+ i(a.width);
140
+ }, a.onerror = () => {
141
+ o(new Error("Failed to load image"));
142
+ };
143
+ });
144
+ }
145
+ g(() => {
146
+ h && x(!0);
147
+ }, [h]), g(() => {
148
+ let e = l, i = v, o = 100;
149
+ (t.includes("unsplash") ? t.trim() : !b && t.trim() || t.includes("upload-src-editor")) && t !== "upload" && q(t).then((a) => {
150
+ typeof e == "number" && e < o && a < o ? (y(!0), z({
151
+ width: e,
152
+ height: i
153
+ })) : a < o ? (y(!0), z({
154
+ width: "auto",
155
+ height: "auto"
156
+ })) : (z({
157
+ width: a,
158
+ height: a
159
+ }), y(!1));
160
+ }).catch((a) => {
161
+ console.warn("Ошибка при загрузке изображения:", a.message);
162
+ });
163
+ }, [t, b]), g(() => {
164
+ s.width && s.height && w && r.update(() => {
165
+ const e = L(n);
166
+ W(e) && e.setWidthAndHeight(s.width, s.height);
167
+ });
168
+ }, [s.width, s.height, w]), g(() => {
169
+ const e = document.documentElement;
170
+ oe(S, e);
171
+ }, [S]), g(() => r.registerCommand(
172
+ ae,
173
+ (e) => (t === "upload" && D(e), !1),
174
+ ne
175
+ ), [t, E]);
176
+ const H = (e, i) => {
177
+ C(!1), r.update(() => {
178
+ const o = L(n);
179
+ W(o) && (o.setSrc(e), o.setId(i));
180
+ });
181
+ }, D = (e) => {
182
+ C(!0), M && M(
183
+ e[0],
184
+ (i, o) => {
185
+ H(i, o);
186
+ },
187
+ (i) => {
188
+ i && ge({
189
+ message: N("editor.gallery.errorFile")
190
+ }), H("", "");
191
+ }
192
+ );
193
+ };
194
+ return !t || t === "upload" ? /* @__PURE__ */ d(
195
+ se,
196
+ {
197
+ uploading: !1,
198
+ onUpload: (e) => {
199
+ !M || !e.length || (D(e), x(!1));
200
+ },
201
+ popoverProps: {
202
+ opened: S,
203
+ position: "bottom",
204
+ onChange: x
205
+ },
206
+ onChange: (e) => {
207
+ x(!1), r.update(() => {
208
+ const i = L(n);
209
+ W(i) && i.setSrc(e);
210
+ });
211
+ },
212
+ children: /* @__PURE__ */ d(
213
+ re,
214
+ {
215
+ title: N("editor.image.add_photo"),
216
+ icon: "photo",
217
+ onClick: () => x(!S),
218
+ isLoading: E
219
+ }
220
+ )
221
+ }
222
+ ) : w ? /* @__PURE__ */ d(
223
+ T,
224
+ {
225
+ width: s.width,
226
+ height: s.height,
227
+ isLoading: E,
228
+ isError: !1,
229
+ isIcon: w,
230
+ src: t,
231
+ id: p,
232
+ editor: r,
233
+ nodeKey: n,
234
+ fetchDeleteMedia: O,
235
+ altText: u,
236
+ imageRef: R,
237
+ maxWidth: m,
238
+ showCaption: f,
239
+ caption: c,
240
+ isCollabActive: A,
241
+ historyState: U,
242
+ showNestedEditorTreeView: k,
243
+ t: N
244
+ }
245
+ ) : /* @__PURE__ */ d(
246
+ de,
247
+ {
248
+ editor: r,
249
+ isIcon: w,
250
+ width: F(l),
251
+ height: F(v),
252
+ initialWidth: s.width || "",
253
+ initialHeight: s.height || "",
254
+ onResizeEnd: G,
255
+ alignment: j,
256
+ children: /* @__PURE__ */ d(
257
+ T,
258
+ {
259
+ width: "inherit",
260
+ height: "inherit",
261
+ isLoading: E,
262
+ isError: !1,
263
+ isIcon: w,
264
+ src: t,
265
+ id: p,
266
+ editor: r,
267
+ nodeKey: n,
268
+ fetchDeleteMedia: O,
269
+ altText: u,
270
+ imageRef: R,
271
+ maxWidth: m,
272
+ showCaption: f,
273
+ caption: c,
274
+ isCollabActive: A,
275
+ historyState: U,
276
+ showNestedEditorTreeView: k,
277
+ t: N
278
+ }
279
+ )
280
+ }
281
+ );
282
+ }
283
+ export {
284
+ xe as default
285
+ };