@layers-app/editor 0.5.8-optimization → 0.5.10-optimization
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/README.md +0 -19
- package/dist/ExcalidrawComponent-D7Z_2awF.cjs +1 -0
- package/dist/ExcalidrawComponent-Re4zFgLg.js +283 -0
- package/dist/InlineImageComponent-DHgCaPNk.cjs +1 -0
- package/dist/InlineImageComponent-kXhZcmF6.js +265 -0
- package/dist/collaboration-C7xVk0Zj.cjs +4 -0
- package/dist/collaboration-Cn7KizEJ.js +5997 -0
- package/dist/excalidraw-C-6bid_P.js +16497 -0
- package/dist/excalidraw-DpwKTNBz.cjs +574 -0
- package/dist/index-B4yOqKUQ.cjs +1 -0
- package/dist/index-BZu8Qnrg.cjs +1 -0
- package/dist/index-CFA9Drk2.cjs +16 -0
- package/dist/index-CX5msaMB.js +296 -0
- package/dist/index-CbQX0N2c.js +136 -0
- package/dist/index-DEC5JR_F.js +60 -0
- package/dist/index-Dan3tqoj.cjs +1 -0
- package/dist/index-WCOc4LNL.js +16600 -0
- package/dist/index.cjs +2 -2
- package/dist/index.js +12 -13
- package/dist/lexical-2rxs76dr.cjs +41 -0
- package/dist/lexical-C60GkwxR.js +13122 -0
- package/dist/lexical-code-DKIWiZdJ.js +604 -0
- package/dist/lexical-code-VafvPacU.cjs +9 -0
- package/dist/lexical-collab-1tX9tFVC.js +1025 -0
- package/dist/lexical-collab-Nk2LVpJv.cjs +1 -0
- package/dist/lexical-file-C52Mze5k.cjs +1 -0
- package/dist/lexical-file-DjHP4vVw.js +43 -0
- package/dist/lexical-markdown-BSl_ahWw.cjs +12 -0
- package/dist/lexical-markdown-DcEwQQba.js +488 -0
- package/dist/lodash-3PEMjFQT.cjs +1 -0
- package/dist/lodash-jftOdrxX.js +711 -0
- package/dist/stats.html +4949 -0
- package/dist/vendor-BrXDSyZX.js +136433 -0
- package/dist/vendor-Bt6Lma3y.cjs +2469 -0
- package/package.json +42 -74
- package/dist/layers.8yssqxrI.js +0 -6774
- package/dist/layers.B8z-e4Vg.js +0 -7
- package/dist/layers.BQLznd92.js +0 -4
- package/dist/layers.BVRvG1mv.js +0 -3
- package/dist/layers.BjCQNcdJ.js +0 -341
- package/dist/layers.BnVn2uMi.js +0 -7723
- package/dist/layers.CLcioDq5.js +0 -2511
- package/dist/layers.CTSBFg3j.js +0 -1
- package/dist/layers.CoCZDINv.js +0 -864
- package/dist/layers.D0ZtUpST.js +0 -2
- package/dist/layers.D2zjLyjP.js +0 -6
- package/dist/layers.DNCgFYS7.js +0 -27
- package/dist/layers.Dt_Jdn4Y.js +0 -2227
- package/dist/layers.DwX5sVtx.js +0 -1
- package/dist/layers.QjAkD17S.js +0 -3677
- package/dist/layers.pre7B8K-.js +0 -530
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
import { jsx as l, jsxs as Y } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as Z, useState as u, useContext as K, useEffect as g } from "react";
|
|
3
|
+
import { useTranslation as ee } from "react-i18next";
|
|
4
|
+
import { a1 as te, x as z, z as ie, av as oe } from "./lexical-C60GkwxR.js";
|
|
5
|
+
import { LoadingOverlay as ae } from "@mantine/core";
|
|
6
|
+
import { showErrorNotification as ne } from "@layers-app/shared";
|
|
7
|
+
import { u as se, C as re, m as M, b as le, c as de, e as L, t as he, U as ge, f as ue, h as me, R as fe, p as T } from "./index-WCOc4LNL.js";
|
|
8
|
+
const $ = (t) => {
|
|
9
|
+
const {
|
|
10
|
+
width: m,
|
|
11
|
+
height: n,
|
|
12
|
+
isLoading: d,
|
|
13
|
+
isError: v,
|
|
14
|
+
src: f,
|
|
15
|
+
id: c,
|
|
16
|
+
altText: p,
|
|
17
|
+
imageRef: w,
|
|
18
|
+
maxWidth: h
|
|
19
|
+
} = t;
|
|
20
|
+
return /* @__PURE__ */ Y(
|
|
21
|
+
"div",
|
|
22
|
+
{
|
|
23
|
+
className: "media-wrapper",
|
|
24
|
+
style: {
|
|
25
|
+
width: m,
|
|
26
|
+
height: n,
|
|
27
|
+
display: "inline-flex",
|
|
28
|
+
position: "relative"
|
|
29
|
+
},
|
|
30
|
+
children: [
|
|
31
|
+
/* @__PURE__ */ l(
|
|
32
|
+
ae,
|
|
33
|
+
{
|
|
34
|
+
visible: d,
|
|
35
|
+
zIndex: 1e3,
|
|
36
|
+
overlayProps: { backgroundOpacity: 0.5 },
|
|
37
|
+
loaderProps: { size: 24, color: "black" }
|
|
38
|
+
}
|
|
39
|
+
),
|
|
40
|
+
/* @__PURE__ */ l(
|
|
41
|
+
ce,
|
|
42
|
+
{
|
|
43
|
+
className: null,
|
|
44
|
+
src: f,
|
|
45
|
+
altText: p,
|
|
46
|
+
imageRef: w,
|
|
47
|
+
width: "inherit",
|
|
48
|
+
height: "inherit",
|
|
49
|
+
maxWidth: h || "auto",
|
|
50
|
+
id: c
|
|
51
|
+
}
|
|
52
|
+
)
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
};
|
|
57
|
+
function ce({
|
|
58
|
+
altText: t,
|
|
59
|
+
className: m,
|
|
60
|
+
imageRef: n,
|
|
61
|
+
src: d,
|
|
62
|
+
width: v,
|
|
63
|
+
height: f,
|
|
64
|
+
maxWidth: c,
|
|
65
|
+
id: p
|
|
66
|
+
}) {
|
|
67
|
+
const [w, h] = u(!1);
|
|
68
|
+
return /* @__PURE__ */ l(
|
|
69
|
+
"img",
|
|
70
|
+
{
|
|
71
|
+
className: `${m || void 0} ${w ? "" : "loading"}`,
|
|
72
|
+
src: d,
|
|
73
|
+
alt: t,
|
|
74
|
+
ref: n,
|
|
75
|
+
style: {
|
|
76
|
+
height: f,
|
|
77
|
+
maxWidth: c,
|
|
78
|
+
width: v
|
|
79
|
+
},
|
|
80
|
+
onLoad: () => {
|
|
81
|
+
d.includes("splash") ? setTimeout(() => {
|
|
82
|
+
h(!0);
|
|
83
|
+
}, 100) : h(!0);
|
|
84
|
+
},
|
|
85
|
+
draggable: "false",
|
|
86
|
+
"data-id": p
|
|
87
|
+
}
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
function Se({
|
|
91
|
+
src: t,
|
|
92
|
+
altText: m,
|
|
93
|
+
nodeKey: n,
|
|
94
|
+
width: d,
|
|
95
|
+
height: v,
|
|
96
|
+
maxWidth: f,
|
|
97
|
+
showCaption: c,
|
|
98
|
+
caption: p,
|
|
99
|
+
id: w,
|
|
100
|
+
create: h,
|
|
101
|
+
alignment: j
|
|
102
|
+
}) {
|
|
103
|
+
var _, F;
|
|
104
|
+
const R = Z(null), [b, I] = u(!0), [r] = te(), [C, W] = u(!0), [s, y] = u({
|
|
105
|
+
width: 0,
|
|
106
|
+
height: 0
|
|
107
|
+
}), { start: B, cancel: G } = se(), [V, A] = u(0), { fetchUploadMedia: P, fetchDeleteMedia: U, maxFileSize: pe } = K(re), E = M.has(t) && (((_ = M.get(t)) == null ? void 0 : _.mediaNodeKeys.length) === 0 || ((F = M.get(t)) == null ? void 0 : F.mediaNodeKeys.length) === void 0 || t.trim() === ""), { t: N } = ee(), [we, q] = u(0);
|
|
108
|
+
g(() => r.registerDecoratorListener(() => {
|
|
109
|
+
q((e) => e + 1);
|
|
110
|
+
}), [E]), g(() => {
|
|
111
|
+
if (!t || t.startsWith("data:image/") || !t.trim()) {
|
|
112
|
+
I(!1);
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
const e = new Image();
|
|
116
|
+
e.src = t, e.onload = () => I(!1), e.onerror = () => {
|
|
117
|
+
I(!1);
|
|
118
|
+
};
|
|
119
|
+
}, [t, E]);
|
|
120
|
+
const J = (e, o) => {
|
|
121
|
+
r.update(() => {
|
|
122
|
+
oe(null);
|
|
123
|
+
const i = z(n);
|
|
124
|
+
L(i) && i.setWidthAndHeight(e, o);
|
|
125
|
+
});
|
|
126
|
+
}, { historyState: O } = le(), {
|
|
127
|
+
settings: { showNestedEditorTreeView: k }
|
|
128
|
+
} = de(), [S, x] = u(!1);
|
|
129
|
+
function Q(e) {
|
|
130
|
+
return e.endsWith(".svg") || e.includes("image/svg+xml");
|
|
131
|
+
}
|
|
132
|
+
function X(e) {
|
|
133
|
+
return new Promise((o, i) => {
|
|
134
|
+
if (Q(e)) {
|
|
135
|
+
o(0);
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
const a = new Image();
|
|
139
|
+
a.src = e, a.onload = () => {
|
|
140
|
+
o(a.width);
|
|
141
|
+
}, a.onerror = () => {
|
|
142
|
+
i(new Error("Failed to load image"));
|
|
143
|
+
};
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
g(() => {
|
|
147
|
+
h && x(!0);
|
|
148
|
+
}, [h]), g(() => {
|
|
149
|
+
let e = d, o = v, i = 100;
|
|
150
|
+
(t.includes("unsplash") ? t.trim() : !E && t.trim() || t.includes("upload-src-editor")) && t !== "upload" && X(t).then((a) => {
|
|
151
|
+
typeof e == "number" && e < i && a < i ? (W(!0), y({
|
|
152
|
+
width: e,
|
|
153
|
+
height: o
|
|
154
|
+
})) : a < i ? (W(!0), y({
|
|
155
|
+
width: "auto",
|
|
156
|
+
height: "auto"
|
|
157
|
+
})) : (y({
|
|
158
|
+
width: a,
|
|
159
|
+
height: a
|
|
160
|
+
}), W(!1));
|
|
161
|
+
}).catch((a) => {
|
|
162
|
+
console.warn("Ошибка при загрузке изображения:", a.message);
|
|
163
|
+
});
|
|
164
|
+
}, [t, E]), g(() => {
|
|
165
|
+
s.width && s.height && C && r.update(() => {
|
|
166
|
+
const e = z(n);
|
|
167
|
+
L(e) && e.setWidthAndHeight(s.width, s.height);
|
|
168
|
+
});
|
|
169
|
+
}, [s.width, s.height, C]), g(() => {
|
|
170
|
+
const e = document.documentElement;
|
|
171
|
+
he(S, e);
|
|
172
|
+
}, [S]), g(() => r.registerCommand(
|
|
173
|
+
ge,
|
|
174
|
+
(e) => (t === "upload" && D(e), !1),
|
|
175
|
+
ie
|
|
176
|
+
), [t, b]);
|
|
177
|
+
const H = (e, o) => {
|
|
178
|
+
I(!1), r.update(() => {
|
|
179
|
+
const i = z(n);
|
|
180
|
+
L(i) && (i.setSrc(e), i.setId(o));
|
|
181
|
+
});
|
|
182
|
+
}, D = (e) => {
|
|
183
|
+
I(!0);
|
|
184
|
+
const o = B();
|
|
185
|
+
P && P(
|
|
186
|
+
e[0],
|
|
187
|
+
(i, a) => {
|
|
188
|
+
H(i, a), A(0);
|
|
189
|
+
},
|
|
190
|
+
(i) => {
|
|
191
|
+
i && ne({
|
|
192
|
+
message: N("editor.gallery.errorFile")
|
|
193
|
+
}), A(0), H("", "");
|
|
194
|
+
},
|
|
195
|
+
o,
|
|
196
|
+
(i) => {
|
|
197
|
+
A(i);
|
|
198
|
+
}
|
|
199
|
+
);
|
|
200
|
+
};
|
|
201
|
+
return !t || t === "upload" ? /* @__PURE__ */ l(
|
|
202
|
+
ue,
|
|
203
|
+
{
|
|
204
|
+
uploading: !1,
|
|
205
|
+
onUpload: (e) => {
|
|
206
|
+
!P || !e.length || (D(e), x(!1));
|
|
207
|
+
},
|
|
208
|
+
popoverProps: {
|
|
209
|
+
opened: S,
|
|
210
|
+
position: "bottom",
|
|
211
|
+
onChange: x
|
|
212
|
+
},
|
|
213
|
+
onChange: (e) => {
|
|
214
|
+
x(!1), r.update(() => {
|
|
215
|
+
const o = z(n);
|
|
216
|
+
L(o) && o.setSrc(e);
|
|
217
|
+
});
|
|
218
|
+
},
|
|
219
|
+
children: /* @__PURE__ */ l(
|
|
220
|
+
me,
|
|
221
|
+
{
|
|
222
|
+
title: N("editor.image.add_photo"),
|
|
223
|
+
icon: "photo",
|
|
224
|
+
onClick: () => x(!S),
|
|
225
|
+
isLoading: b,
|
|
226
|
+
progress: V,
|
|
227
|
+
onAfterCancel: () => {
|
|
228
|
+
G(), I(!1);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
)
|
|
232
|
+
}
|
|
233
|
+
) : C ? /* @__PURE__ */ l(
|
|
234
|
+
$,
|
|
235
|
+
{
|
|
236
|
+
width: s.width,
|
|
237
|
+
height: s.height,
|
|
238
|
+
isLoading: b,
|
|
239
|
+
isError: !1,
|
|
240
|
+
isIcon: C,
|
|
241
|
+
src: t,
|
|
242
|
+
id: w,
|
|
243
|
+
editor: r,
|
|
244
|
+
nodeKey: n,
|
|
245
|
+
fetchDeleteMedia: U,
|
|
246
|
+
altText: m,
|
|
247
|
+
imageRef: R,
|
|
248
|
+
maxWidth: f,
|
|
249
|
+
showCaption: c,
|
|
250
|
+
caption: p,
|
|
251
|
+
isCollabActive: !1,
|
|
252
|
+
historyState: O,
|
|
253
|
+
showNestedEditorTreeView: k,
|
|
254
|
+
t: N
|
|
255
|
+
}
|
|
256
|
+
) : /* @__PURE__ */ l(
|
|
257
|
+
fe,
|
|
258
|
+
{
|
|
259
|
+
editor: r,
|
|
260
|
+
isIcon: C,
|
|
261
|
+
width: T(d),
|
|
262
|
+
height: T(v),
|
|
263
|
+
initialWidth: s.width || "",
|
|
264
|
+
initialHeight: s.height || "",
|
|
265
|
+
onResizeEnd: J,
|
|
266
|
+
alignment: j,
|
|
267
|
+
children: /* @__PURE__ */ l(
|
|
268
|
+
$,
|
|
269
|
+
{
|
|
270
|
+
width: "inherit",
|
|
271
|
+
height: "inherit",
|
|
272
|
+
isLoading: b,
|
|
273
|
+
isError: !1,
|
|
274
|
+
isIcon: C,
|
|
275
|
+
src: t,
|
|
276
|
+
id: w,
|
|
277
|
+
editor: r,
|
|
278
|
+
nodeKey: n,
|
|
279
|
+
fetchDeleteMedia: U,
|
|
280
|
+
altText: m,
|
|
281
|
+
imageRef: R,
|
|
282
|
+
maxWidth: f,
|
|
283
|
+
showCaption: c,
|
|
284
|
+
caption: p,
|
|
285
|
+
isCollabActive: !1,
|
|
286
|
+
historyState: O,
|
|
287
|
+
showNestedEditorTreeView: k,
|
|
288
|
+
t: N
|
|
289
|
+
}
|
|
290
|
+
)
|
|
291
|
+
}
|
|
292
|
+
);
|
|
293
|
+
}
|
|
294
|
+
export {
|
|
295
|
+
Se as default
|
|
296
|
+
};
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { jsx as l } from "react/jsx-runtime";
|
|
2
|
+
import { useState as d, useEffect as M, Suspense as w, lazy as z, useCallback as B } from "react";
|
|
3
|
+
import { useTranslation as L } from "react-i18next";
|
|
4
|
+
import { useMantineColorScheme as T, Loader as D } from "@mantine/core";
|
|
5
|
+
import { BottomDrawerWithoutHeader as y } from "@layers-app/shared";
|
|
6
|
+
async function N() {
|
|
7
|
+
return (await import("./excalidraw-C-6bid_P.js").then((o) => o.i)).Excalidraw;
|
|
8
|
+
}
|
|
9
|
+
async function W(r) {
|
|
10
|
+
const { exportToSvg: o } = await import("./excalidraw-C-6bid_P.js").then((s) => s.i);
|
|
11
|
+
return o(r);
|
|
12
|
+
}
|
|
13
|
+
const j = {
|
|
14
|
+
en: "en-US",
|
|
15
|
+
ru: "ru-RU",
|
|
16
|
+
fr: "fr-FR",
|
|
17
|
+
de: "de-DE",
|
|
18
|
+
es: "es-ES",
|
|
19
|
+
it: "it-IT",
|
|
20
|
+
pt: "pt-BR",
|
|
21
|
+
zh: "zh-CN",
|
|
22
|
+
ja: "ja-JP",
|
|
23
|
+
ko: "ko-KR",
|
|
24
|
+
ar: "ar-SA",
|
|
25
|
+
hi: "hi-IN",
|
|
26
|
+
nl: "nl-NL",
|
|
27
|
+
tr: "tr-TR",
|
|
28
|
+
pl: "pl-PL",
|
|
29
|
+
sv: "sv-SE",
|
|
30
|
+
cs: "cs-CZ",
|
|
31
|
+
uk: "uk-UA",
|
|
32
|
+
ro: "ro-RO",
|
|
33
|
+
fi: "fi-FI",
|
|
34
|
+
da: "da-DK",
|
|
35
|
+
no: "no-NO",
|
|
36
|
+
el: "el-GR",
|
|
37
|
+
he: "he-IL",
|
|
38
|
+
th: "th-TH",
|
|
39
|
+
id: "id-ID",
|
|
40
|
+
ms: "ms-MY",
|
|
41
|
+
vi: "vi-VN"
|
|
42
|
+
}, H = z(
|
|
43
|
+
() => N().then((r) => (import("./excalidraw-C-6bid_P.js").then((o) => o.a), { default: r }))
|
|
44
|
+
), I = () => {
|
|
45
|
+
const [r, o] = d(
|
|
46
|
+
null
|
|
47
|
+
), s = B(
|
|
48
|
+
(c) => o(c),
|
|
49
|
+
[]
|
|
50
|
+
);
|
|
51
|
+
return [r, s];
|
|
52
|
+
};
|
|
53
|
+
function G({
|
|
54
|
+
onSave: r,
|
|
55
|
+
initialElements: o,
|
|
56
|
+
initialAppState: s,
|
|
57
|
+
initialFiles: c,
|
|
58
|
+
isShown: t = !1,
|
|
59
|
+
onDelete: u,
|
|
60
|
+
onClose: f,
|
|
61
|
+
isEdited: h
|
|
62
|
+
}) {
|
|
63
|
+
const [n, m] = I(), { i18n: g } = L(), { colorScheme: k } = T(), [i, x] = d(o), [v, C] = d(c);
|
|
64
|
+
M(() => {
|
|
65
|
+
t && setTimeout(() => {
|
|
66
|
+
n == null || n.refresh();
|
|
67
|
+
}, 500);
|
|
68
|
+
}, [t, n == null ? void 0 : n.refresh]);
|
|
69
|
+
const E = () => {
|
|
70
|
+
if (i && i.filter((e) => !e.isDeleted).length > 0) {
|
|
71
|
+
const e = n == null ? void 0 : n.getAppState(), a = {
|
|
72
|
+
exportBackground: e == null ? void 0 : e.exportBackground,
|
|
73
|
+
exportScale: e == null ? void 0 : e.exportScale,
|
|
74
|
+
exportWithDarkMode: (e == null ? void 0 : e.theme) === "dark",
|
|
75
|
+
isBindingEnabled: e == null ? void 0 : e.isBindingEnabled,
|
|
76
|
+
isLoading: e == null ? void 0 : e.isLoading,
|
|
77
|
+
name: e == null ? void 0 : e.name,
|
|
78
|
+
theme: e == null ? void 0 : e.theme,
|
|
79
|
+
viewBackgroundColor: e == null ? void 0 : e.viewBackgroundColor,
|
|
80
|
+
viewModeEnabled: e == null ? void 0 : e.viewModeEnabled,
|
|
81
|
+
zenModeEnabled: e == null ? void 0 : e.zenModeEnabled,
|
|
82
|
+
zoom: e == null ? void 0 : e.zoom
|
|
83
|
+
};
|
|
84
|
+
r(i, a, v);
|
|
85
|
+
} else
|
|
86
|
+
u();
|
|
87
|
+
}, b = (e, a, R) => {
|
|
88
|
+
(e == null ? void 0 : e.length) !== (o == null ? void 0 : o.length) && (h.current = !0), x(e), C(R);
|
|
89
|
+
};
|
|
90
|
+
return /* @__PURE__ */ l(
|
|
91
|
+
y,
|
|
92
|
+
{
|
|
93
|
+
opened: t,
|
|
94
|
+
onClose: f,
|
|
95
|
+
onSave: E,
|
|
96
|
+
className: "excaildraw-modal",
|
|
97
|
+
closeOnEscape: !1,
|
|
98
|
+
children: /* @__PURE__ */ l(
|
|
99
|
+
w,
|
|
100
|
+
{
|
|
101
|
+
fallback: /* @__PURE__ */ l(
|
|
102
|
+
"div",
|
|
103
|
+
{
|
|
104
|
+
style: {
|
|
105
|
+
display: "flex",
|
|
106
|
+
justifyContent: "center",
|
|
107
|
+
alignItems: "center",
|
|
108
|
+
height: "100%",
|
|
109
|
+
minHeight: "400px"
|
|
110
|
+
},
|
|
111
|
+
children: /* @__PURE__ */ l(D, { size: "lg" })
|
|
112
|
+
}
|
|
113
|
+
),
|
|
114
|
+
children: /* @__PURE__ */ l(
|
|
115
|
+
H,
|
|
116
|
+
{
|
|
117
|
+
langCode: j[g.language],
|
|
118
|
+
theme: k,
|
|
119
|
+
onChange: b,
|
|
120
|
+
excalidrawAPI: m,
|
|
121
|
+
initialData: {
|
|
122
|
+
appState: { ...s || { isLoading: !1 } },
|
|
123
|
+
elements: o,
|
|
124
|
+
files: c
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
)
|
|
128
|
+
}
|
|
129
|
+
)
|
|
130
|
+
}
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
export {
|
|
134
|
+
G as E,
|
|
135
|
+
W as e
|
|
136
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { jsx as f } from "react/jsx-runtime";
|
|
2
|
+
import { useState as n, useRef as u, useEffect as E } from "react";
|
|
3
|
+
import { w as m, a1 as p, a4 as w } from "./lexical-C60GkwxR.js";
|
|
4
|
+
import { E as C, g as N, $ as x } from "./index-WCOc4LNL.js";
|
|
5
|
+
import { E as g } from "./index-CbQX0N2c.js";
|
|
6
|
+
const S = m(
|
|
7
|
+
"INSERT_EXCALIDRAW_COMMAND"
|
|
8
|
+
);
|
|
9
|
+
function P() {
|
|
10
|
+
const [t] = p(), [i, a] = n(!1), [e, l] = n(
|
|
11
|
+
null
|
|
12
|
+
), r = u(null);
|
|
13
|
+
return E(() => {
|
|
14
|
+
if (!t.hasNodes([C]))
|
|
15
|
+
throw new Error(
|
|
16
|
+
"ExcalidrawPlugin: ExcalidrawNode not registered on editor"
|
|
17
|
+
);
|
|
18
|
+
return t.registerCommand(
|
|
19
|
+
S,
|
|
20
|
+
() => {
|
|
21
|
+
a(!0);
|
|
22
|
+
const o = N();
|
|
23
|
+
return l(o), !0;
|
|
24
|
+
},
|
|
25
|
+
w
|
|
26
|
+
);
|
|
27
|
+
}, [t]), /* @__PURE__ */ f(
|
|
28
|
+
g,
|
|
29
|
+
{
|
|
30
|
+
initialElements: [],
|
|
31
|
+
initialAppState: {},
|
|
32
|
+
initialFiles: {},
|
|
33
|
+
isShown: i,
|
|
34
|
+
onDelete: () => {
|
|
35
|
+
a(!1);
|
|
36
|
+
},
|
|
37
|
+
onClose: () => {
|
|
38
|
+
a(!1), r.current = !1;
|
|
39
|
+
},
|
|
40
|
+
onSave: (o, d, c) => {
|
|
41
|
+
t.update(() => {
|
|
42
|
+
const s = x();
|
|
43
|
+
s.setData(
|
|
44
|
+
JSON.stringify({
|
|
45
|
+
appState: d,
|
|
46
|
+
elements: o,
|
|
47
|
+
files: c
|
|
48
|
+
})
|
|
49
|
+
), e && e.getParent() && (e == null || e.replace(s));
|
|
50
|
+
}), a(!1);
|
|
51
|
+
},
|
|
52
|
+
closeOnClickOutside: !1,
|
|
53
|
+
isEdited: r
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
export {
|
|
58
|
+
S as INSERT_EXCALIDRAW_COMMAND,
|
|
59
|
+
P as default
|
|
60
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("react/jsx-runtime"),r=require("react"),a=require("./lexical-2rxs76dr.cjs"),s=require("./index-CFA9Drk2.cjs"),w=require("./index-BZu8Qnrg.cjs"),c=a.re("INSERT_EXCALIDRAW_COMMAND");function A(){const[t]=a.o(),[d,n]=r.useState(!1),[e,u]=r.useState(null),o=r.useRef(null);r.useEffect(()=>{if(!t.hasNodes([s.ExcalidrawNode]))throw new Error("ExcalidrawPlugin: ExcalidrawNode not registered on editor");return t.registerCommand(c,()=>{n(!0);const i=s.getCurrentElement();return u(i),!0},a.Ki)},[t]);const E=()=>{n(!1),o.current=!1},f=()=>{n(!1)},x=(i,N,C)=>{t.update(()=>{const l=s.$createExcalidrawNode();l.setData(JSON.stringify({appState:N,elements:i,files:C})),e&&e.getParent()&&(e==null||e.replace(l))}),n(!1)};return S.jsx(w.ExcalidrawModal,{initialElements:[],initialAppState:{},initialFiles:{},isShown:d,onDelete:f,onClose:E,onSave:x,closeOnClickOutside:!1,isEdited:o})}exports.INSERT_EXCALIDRAW_COMMAND=c;exports.default=A;
|