@layers-app/shared 0.0.26 → 0.0.28

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.
@@ -1,343 +0,0 @@
1
- import { jsxs as g, Fragment as A, jsx as n } from "react/jsx-runtime";
2
- import { useState as I, useRef as T, useCallback as S, useEffect as K, Suspense as F, useContext as U, useMemo as W } from "react";
3
- import { f as B, b as q, p as G, d as V, T as D, M, t as Y, j as P, L as z, N as H, h as _, c as J, g as Q, q as X, G as Z, V as ee, i as te, A as ae, o as ne, l as le, m as re, r as ie, s as j, Y as oe, e as se } from "./index-Vul891jq.js";
4
- import { TextInput as ce, Button as de } from "@mantine/core";
5
- function ue(e) {
6
- return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
7
- }
8
- var pe = ue(function(e) {
9
- const t = new URLSearchParams();
10
- t.append("code", e);
11
- for (let a = 1; a < arguments.length; a++) t.append("v", arguments[a]);
12
- throw Error(`Minified Lexical error #${e}; visit https://lexical.dev/docs/error?${t} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`);
13
- });
14
- function R(e) {
15
- const t = e.transform();
16
- return t !== null ? /* @__PURE__ */ new Set([t]) : /* @__PURE__ */ new Set();
17
- }
18
- function he({ initialEditor: e, children: t, initialNodes: a, initialTheme: r, skipCollabChecks: d }) {
19
- const s = T(!1), i = U(j);
20
- i == null && pe(9);
21
- const [h, { getTheme: w }] = i, N = W(() => {
22
- const o = r || w() || void 0, E = oe(i, o);
23
- if (o !== void 0 && (e._config.theme = o), e._parentEditor = h, a) for (let l of a) {
24
- let x = null, m = null;
25
- if (typeof l != "function") {
26
- const C = l;
27
- l = C.replace, x = C.with, m = C.withKlass || null;
28
- }
29
- const y = e._nodes.get(l.getType());
30
- e._nodes.set(l.getType(), { exportDOM: y ? y.exportDOM : void 0, klass: l, replace: x, replaceWithKlass: m, transforms: R(l) });
31
- }
32
- else {
33
- const l = e._nodes = new Map(h._nodes);
34
- for (const [x, m] of l) e._nodes.set(x, { exportDOM: m.exportDOM, klass: m.klass, replace: m.replace, replaceWithKlass: m.replaceWithKlass, transforms: R(m.klass) });
35
- }
36
- return e._config.namespace = h._config.namespace, e._editable = h._editable, [e, E];
37
- }, []), { isCollabActive: v, yjsDocMap: b } = se(), c = d || s.current || b.has(e.getKey());
38
- return K(() => {
39
- c && (s.current = !0);
40
- }, [c]), K(() => h.registerEditableListener((o) => {
41
- e.setEditable(o);
42
- }), [e, h]), n(j.Provider, { value: N, children: !v || c ? t : null });
43
- }
44
- function me({
45
- "data-test-id": e,
46
- children: t,
47
- className: a,
48
- onClick: r,
49
- disabled: d,
50
- small: s,
51
- title: i
52
- }) {
53
- return /* @__PURE__ */ n(de, { onClick: r, disabled: d, variant: "filled", children: t });
54
- }
55
- function fe({
56
- children: e,
57
- className: t
58
- }) {
59
- return /* @__PURE__ */ n("div", { className: t || "Placeholder__root", children: e });
60
- }
61
- function ge({
62
- children: e,
63
- label: t,
64
- className: a,
65
- ...r
66
- }) {
67
- return /* @__PURE__ */ g("div", { className: "Input__wrapper", children: [
68
- /* @__PURE__ */ n("label", { style: { marginTop: "-1em" }, className: "Input__label", children: t }),
69
- /* @__PURE__ */ n("select", { ...r, className: a || "select", children: e })
70
- ] });
71
- }
72
- function ve({
73
- label: e,
74
- value: t,
75
- onChange: a,
76
- placeholder: r = "",
77
- "data-test-id": d,
78
- type: s = "text"
79
- }) {
80
- return /* @__PURE__ */ n(
81
- ce,
82
- {
83
- type: s,
84
- placeholder: r,
85
- value: t,
86
- onChange: (i) => {
87
- a(i.target.value);
88
- },
89
- label: e,
90
- "data-test-id": d,
91
- mb: 10
92
- }
93
- );
94
- }
95
- const $ = /* @__PURE__ */ new Set();
96
- function be(e) {
97
- if (!$.has(e))
98
- throw new Promise((t) => {
99
- const a = new Image();
100
- a.src = e, a.onload = () => {
101
- $.add(e), t(null);
102
- };
103
- });
104
- }
105
- function Ce({
106
- altText: e,
107
- className: t,
108
- imageRef: a,
109
- src: r,
110
- width: d,
111
- height: s,
112
- position: i
113
- }) {
114
- return be(r), /* @__PURE__ */ n(
115
- "img",
116
- {
117
- className: t || void 0,
118
- src: r,
119
- alt: e,
120
- ref: a,
121
- "data-position": i,
122
- style: {
123
- display: "block",
124
- height: s,
125
- width: d
126
- },
127
- draggable: "false"
128
- }
129
- );
130
- }
131
- function _e({
132
- activeEditor: e,
133
- nodeKey: t,
134
- onClose: a
135
- }) {
136
- const r = e.getEditorState().read(
137
- () => B(t)
138
- ), [d, s] = I(r.getAltText()), [i, h] = I(r.getShowCaption()), [w, N] = I(r.getPosition()), v = (o) => {
139
- h(o.target.checked);
140
- }, b = (o) => {
141
- N(o.target.value);
142
- }, c = () => {
143
- const o = { altText: d, position: w, showCaption: i };
144
- r && e.update(() => {
145
- r.update(o);
146
- }), a();
147
- };
148
- return /* @__PURE__ */ g(A, { children: [
149
- /* @__PURE__ */ n("div", { style: { marginBottom: "1em" }, children: /* @__PURE__ */ n(
150
- ve,
151
- {
152
- label: "Alt-текст",
153
- placeholder: "Альтернативный текст",
154
- onChange: s,
155
- value: d,
156
- "data-test-id": "image-modal-alt-text-input"
157
- }
158
- ) }),
159
- /* @__PURE__ */ g(
160
- ge,
161
- {
162
- style: { marginBottom: "1em", width: "208px" },
163
- value: w,
164
- label: "Position",
165
- name: "position",
166
- id: "position-select",
167
- onChange: b,
168
- children: [
169
- /* @__PURE__ */ n("option", { value: "left", children: "Left" }),
170
- /* @__PURE__ */ n("option", { value: "right", children: "Right" }),
171
- /* @__PURE__ */ n("option", { value: "full", children: "Full Width" })
172
- ]
173
- }
174
- ),
175
- /* @__PURE__ */ g("div", { className: "Input__wrapper", children: [
176
- /* @__PURE__ */ n(
177
- "input",
178
- {
179
- id: "caption",
180
- type: "checkbox",
181
- checked: i,
182
- onChange: v
183
- }
184
- ),
185
- /* @__PURE__ */ n("label", { htmlFor: "caption", children: "Show Caption" })
186
- ] }),
187
- /* @__PURE__ */ n(
188
- me,
189
- {
190
- "data-test-id": "image-modal-file-upload-btn",
191
- onClick: () => c(),
192
- children: "Применить"
193
- }
194
- )
195
- ] });
196
- }
197
- function Ee({
198
- src: e,
199
- altText: t,
200
- nodeKey: a,
201
- width: r,
202
- height: d,
203
- showCaption: s,
204
- caption: i,
205
- position: h
206
- }) {
207
- const [w, N] = q(), v = T(null), b = T(null), [c, o, E] = G(a), [l] = V(), [x, m] = I(null), y = T(null), C = S(
208
- (u) => {
209
- if (c && D(M())) {
210
- u.preventDefault();
211
- const f = B(a);
212
- Y(f) && f.remove();
213
- }
214
- return !1;
215
- },
216
- [c, a]
217
- ), L = S(
218
- (u) => {
219
- const f = M(), p = b.current;
220
- if (c && D(f) && f.getNodes().length === 1) {
221
- if (s)
222
- return P(null), u.preventDefault(), i.focus(), !0;
223
- if (p !== null && p !== document.activeElement)
224
- return u.preventDefault(), p.focus(), !0;
225
- }
226
- return !1;
227
- },
228
- [i, c, s]
229
- ), O = S(
230
- (u) => y.current === i || b.current === u.target ? (P(null), l.update(() => {
231
- o(!0);
232
- const f = l.getRootElement();
233
- f !== null && f.focus();
234
- }), !0) : !1,
235
- [i, l, o]
236
- );
237
- return K(() => {
238
- let u = !0;
239
- const f = z(
240
- l.registerUpdateListener(({ editorState: p }) => {
241
- u && m(p.read(() => M()));
242
- }),
243
- l.registerCommand(
244
- te,
245
- (p, k) => (y.current = k, !1),
246
- _
247
- ),
248
- l.registerCommand(
249
- ee,
250
- (p) => {
251
- const k = p;
252
- return k.target === v.current ? (k.shiftKey ? o(!c) : (E(), o(!0)), !0) : !1;
253
- },
254
- _
255
- ),
256
- l.registerCommand(
257
- Z,
258
- (p) => p.target === v.current ? (p.preventDefault(), !0) : !1,
259
- _
260
- ),
261
- l.registerCommand(
262
- X,
263
- C,
264
- _
265
- ),
266
- l.registerCommand(
267
- Q,
268
- C,
269
- _
270
- ),
271
- l.registerCommand(J, L, _),
272
- l.registerCommand(
273
- H,
274
- O,
275
- _
276
- )
277
- );
278
- return () => {
279
- u = !1, f();
280
- };
281
- }, [
282
- E,
283
- l,
284
- c,
285
- a,
286
- C,
287
- L,
288
- O,
289
- o
290
- ]), /* @__PURE__ */ g(F, { fallback: null, children: [
291
- /* @__PURE__ */ g(A, { children: [
292
- /* @__PURE__ */ g("div", { draggable: !1, children: [
293
- /* @__PURE__ */ n(
294
- "button",
295
- {
296
- className: "image-edit-button",
297
- ref: b,
298
- onClick: () => {
299
- N("Update Inline Image", (u) => /* @__PURE__ */ n(
300
- _e,
301
- {
302
- activeEditor: l,
303
- nodeKey: a,
304
- onClose: u
305
- }
306
- ));
307
- },
308
- children: "Edit"
309
- }
310
- ),
311
- /* @__PURE__ */ n(
312
- Ce,
313
- {
314
- className: c ? `focused ${D(x) ? "draggable" : ""}` : null,
315
- src: e,
316
- altText: t,
317
- imageRef: v,
318
- width: r,
319
- height: d,
320
- position: h
321
- }
322
- )
323
- ] }),
324
- s && /* @__PURE__ */ n("div", { className: "image-caption-container", children: /* @__PURE__ */ g(he, { initialEditor: i, children: [
325
- /* @__PURE__ */ n(ae, {}),
326
- /* @__PURE__ */ n(ne, {}),
327
- /* @__PURE__ */ n(
328
- le,
329
- {
330
- contentEditable: /* @__PURE__ */ n(ie, { className: "InlineImageNode__contentEditable" }),
331
- placeholder: /* @__PURE__ */ n(fe, { className: "InlineImageNode__placeholder", children: "Enter a caption..." }),
332
- ErrorBoundary: re
333
- }
334
- )
335
- ] }) })
336
- ] }),
337
- w
338
- ] });
339
- }
340
- export {
341
- _e as UpdateInlineImageDialog,
342
- Ee as default
343
- };