@levo-so/site-runtime 0.2.2 → 0.2.3

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,912 +0,0 @@
1
- "use client";
2
- import { a as e, i as t, n, r, s as i } from "./ThemeProvider-Cm2jJC7a.js";
3
- import { a, i as o, n as s, o as c, r as l, t as u } from "./Tooltip-Bx-BfR7T.js";
4
- import { a as d, i as f, n as p, o as m, r as h } from "./Popover-B76-bN-a.js";
5
- import { forwardRef as g, useEffect as _, useState as v } from "react";
6
- import { Fragment as y, jsx as b, jsxs as x } from "react/jsx-runtime";
7
- import { useController as S } from "react-hook-form";
8
- import { c as C } from "react/compiler-runtime";
9
- import w from "clsx";
10
- import { IconAlignCenter as T, IconAlignJustified as E, IconAlignLeft as ee, IconAlignRight as te, IconArrowBackUp as D, IconArrowForwardUp as O, IconBold as k, IconChevronDown as A, IconCode as j, IconCornerDownLeft as M, IconExternalLink as ne, IconH1 as N, IconH2 as P, IconH3 as F, IconH4 as I, IconH5 as L, IconH6 as R, IconItalic as z, IconLink as re, IconList as B, IconListNumbers as V, IconPencil as H, IconPilcrow as U, IconRotate2 as W, IconStrikethrough as G, IconSubscript as K, IconSuperscript as q, IconTrash as J, IconUnderline as Y } from "@tabler/icons-react";
11
- import { Extension as X, findParentNodeClosestToPos as Z } from "@tiptap/core";
12
- import { AllSelection as ie, NodeSelection as Q, TextSelection as ae } from "@tiptap/pm/state";
13
- import { CellSelection as oe, cellAround as se } from "@tiptap/pm/tables";
14
- import { Subscript as ce } from "@tiptap/extension-subscript";
15
- import { Superscript as le } from "@tiptap/extension-superscript";
16
- import { Typography as ue } from "@tiptap/extension-typography";
17
- import { UniqueID as de } from "@tiptap/extension-unique-id";
18
- import { Placeholder as fe, Selection as pe } from "@tiptap/extensions";
19
- import { StarterKit as me } from "@tiptap/starter-kit";
20
- import { EditorContent as he, EditorContext as ge, useCurrentEditor as _e, useEditor as ve, useEditorState as ye } from "@tiptap/react";
21
- //#region ../../libraries/editor-core/dist/utils/getSelectedNodeOfType.js
22
- function be(e, t) {
23
- let n = [], r = new Set(t);
24
- if (e instanceof oe) return e.forEachCell((e, t) => {
25
- r.has(e.type.name) && n.push({
26
- node: e,
27
- pos: t
28
- });
29
- }), n;
30
- if (e instanceof Q) {
31
- let { node: t, from: i } = e;
32
- return t && r.has(t.type.name) && n.push({
33
- node: t,
34
- pos: i
35
- }), n;
36
- }
37
- let { $anchor: i } = e, a = se(i);
38
- if (a) {
39
- let t = e.$anchor.doc.nodeAt(a.pos);
40
- if (t && r.has(t.type.name)) return n.push({
41
- node: t,
42
- pos: a.pos
43
- }), n;
44
- }
45
- let o = Z(i, (e) => r.has(e.type.name));
46
- return o && n.push({
47
- node: o.node,
48
- pos: o.pos
49
- }), n;
50
- }
51
- //#endregion
52
- //#region ../../libraries/editor-core/dist/utils/updateNodesAttr.js
53
- function xe(e, t, n, r) {
54
- if (!t.length) return !1;
55
- let i = !1;
56
- for (let { pos: a } of t) {
57
- let t = e.doc.nodeAt(a);
58
- if (!t) continue;
59
- let o = t.attrs[n], s = typeof r == "function" ? r(o) : r;
60
- if (o === s) continue;
61
- let c = { ...t.attrs };
62
- s === void 0 ? delete c[n] : c[n] = s, e.setNodeMarkup(a, void 0, c), i = !0;
63
- }
64
- return i;
65
- }
66
- //#endregion
67
- //#region ../../libraries/editor-core/dist/extensions/nodeStyling/nodeAlignment.js
68
- function Se(e, t, n) {
69
- if (e.length === 0) return null;
70
- for (let r of e) if ((r.node.attrs?.[t] ?? null) !== n) return n;
71
- return null;
72
- }
73
- var Ce = X.create({
74
- name: "textAlign",
75
- addOptions() {
76
- return {
77
- types: [
78
- "paragraph",
79
- "heading",
80
- "quote",
81
- "blockquoteFigure",
82
- "tableCell",
83
- "tableHeader"
84
- ],
85
- useStyle: !0,
86
- textAlignValues: [
87
- "left",
88
- "center",
89
- "right",
90
- "justify"
91
- ],
92
- verticalAlignValues: [
93
- "top",
94
- "middle",
95
- "bottom"
96
- ]
97
- };
98
- },
99
- addGlobalAttributes() {
100
- return [{
101
- types: this.options.types,
102
- attributes: {
103
- textAlign: {
104
- default: null,
105
- parseHTML: (e) => {
106
- let t = e.style?.textAlign;
107
- if (t && this.options.textAlignValues.includes(t)) return t;
108
- let n = e.getAttribute("data-text-align");
109
- return n && this.options.textAlignValues.includes(n) ? n : null;
110
- },
111
- renderHTML: (e) => {
112
- let t = e.textAlign;
113
- return !t || !this.options.textAlignValues.includes(t) ? {} : this.options.useStyle ? { style: `text-align: ${t}` } : { "data-text-align": t };
114
- }
115
- },
116
- nodeVerticalAlign: {
117
- default: null,
118
- parseHTML: (e) => {
119
- let t = e.style?.verticalAlign;
120
- if (t && this.options.verticalAlignValues.includes(t)) return t;
121
- let n = e.getAttribute("data-vertical-align");
122
- return n && this.options.verticalAlignValues.includes(n) ? n : null;
123
- },
124
- renderHTML: (e) => {
125
- let t = e.nodeVerticalAlign;
126
- return !t || !this.options.verticalAlignValues.includes(t) ? {} : this.options.useStyle ? { style: `vertical-align: ${t}` } : { "data-vertical-align": t };
127
- }
128
- }
129
- }
130
- }];
131
- },
132
- addCommands() {
133
- let e = (e, t) => (n) => ({ state: r, tr: i }) => {
134
- let a = be(r.selection, this.options.types);
135
- return a.length === 0 ? !1 : xe(i, a, e, t(a, n));
136
- };
137
- return {
138
- setNodeTextAlign: e("textAlign", (e, t) => !t || !this.options.textAlignValues.includes(t) ? null : t),
139
- unsetNodeTextAlign: e("textAlign", () => null),
140
- toggleNodeTextAlign: e("textAlign", (e, t) => !t || !this.options.textAlignValues.includes(t) ? null : Se(e, "textAlign", t)),
141
- setNodeVAlign: e("nodeVerticalAlign", (e, t) => !t || !this.options.verticalAlignValues.includes(t) ? null : t),
142
- unsetNodeVAlign: e("nodeVerticalAlign", () => null),
143
- toggleNodeVAlign: e("nodeVerticalAlign", (e, t) => !t || !this.options.verticalAlignValues.includes(t) ? null : Se(e, "nodeVerticalAlign", t)),
144
- setNodeAlignment: (e, t) => ({ state: n, tr: r }) => {
145
- let i = be(n.selection, this.options.types);
146
- if (i.length === 0) return !1;
147
- let a = !1;
148
- for (let { node: n, pos: o } of i) {
149
- let i = { ...n.attrs };
150
- e && this.options.textAlignValues.includes(e) && (i.textAlign = e, a = !0), t && this.options.verticalAlignValues.includes(t) && (i.nodeVerticalAlign = t, a = !0), a && r.setNodeMarkup(o, void 0, i);
151
- }
152
- return a;
153
- },
154
- unsetNodeAlignment: () => ({ state: e, tr: t }) => {
155
- let n = be(e.selection, this.options.types);
156
- if (n.length === 0) return !1;
157
- let r = !1;
158
- for (let { node: e, pos: i } of n) {
159
- let n = e.attrs?.textAlign ?? null, a = e.attrs?.nodeVerticalAlign ?? null;
160
- if (n || a) {
161
- let n = {
162
- ...e.attrs,
163
- textAlign: null,
164
- nodeVerticalAlign: null
165
- };
166
- t.setNodeMarkup(i, void 0, n), r = !0;
167
- }
168
- }
169
- return r;
170
- }
171
- };
172
- }
173
- }), we = (e = { placeholder: "Write something ..." }) => [
174
- me.configure({
175
- blockquote: !1,
176
- codeBlock: !1,
177
- horizontalRule: !1,
178
- dropcursor: { width: 2 },
179
- link: {
180
- openOnClick: !1,
181
- HTMLAttributes: { target: "_blank" }
182
- }
183
- }),
184
- fe.configure({ placeholder: e?.placeholder }),
185
- ue,
186
- pe,
187
- le,
188
- ce,
189
- Ce,
190
- de.configure({ types: [
191
- "paragraph",
192
- "heading",
193
- "bulletList",
194
- "orderedList"
195
- ] })
196
- ], Te = "_261ja30", Ee = "_261ja31", $ = g((t, n) => {
197
- let r = C(27), i, a, o, c, d, f, p;
198
- r[0] === t ? (i = r[1], a = r[2], o = r[3], c = r[4], d = r[5], f = r[6], p = r[7]) : ({label: c, Icon: i, isActive: o, iconSize: f, trailing: p, className: a, ...d} = t, r[0] = t, r[1] = i, r[2] = a, r[3] = o, r[4] = c, r[5] = d, r[6] = f, r[7] = p);
199
- let m = f === void 0 ? 16 : f, h = o || void 0, g = o && "_1vaxhty0", _;
200
- r[8] !== a || r[9] !== g ? (_ = w(g, a), r[8] = a, r[9] = g, r[10] = _) : _ = r[10];
201
- let v;
202
- r[11] !== i || r[12] !== m ? (v = /* @__PURE__ */ b(i, { size: m }), r[11] = i, r[12] = m, r[13] = v) : v = r[13];
203
- let y;
204
- r[14] !== c || r[15] !== d || r[16] !== n || r[17] !== h || r[18] !== _ || r[19] !== v || r[20] !== p ? (y = /* @__PURE__ */ b(s, {
205
- onPointerDown: De,
206
- render: /* @__PURE__ */ x(e, {
207
- ref: n,
208
- type: "button",
209
- variant: "ghost",
210
- size: "sm",
211
- tabIndex: -1,
212
- "aria-label": c,
213
- "aria-pressed": h,
214
- className: _,
215
- ...d,
216
- children: [v, p]
217
- })
218
- }), r[14] = c, r[15] = d, r[16] = n, r[17] = h, r[18] = _, r[19] = v, r[20] = p, r[21] = y) : y = r[21];
219
- let S;
220
- r[22] === c ? S = r[23] : (S = /* @__PURE__ */ b(l, { children: c }), r[22] = c, r[23] = S);
221
- let T;
222
- return r[24] !== y || r[25] !== S ? (T = /* @__PURE__ */ x(u, { children: [y, S] }), r[24] = y, r[25] = S, r[26] = T) : T = r[26], T;
223
- });
224
- $.displayName = "ToolbarButton";
225
- function De(e) {
226
- return e.preventDefault();
227
- }
228
- //#endregion
229
- //#region ../../libraries/react-collection/dist/components/editor/utils.js
230
- var Oe = [
231
- "paragraph",
232
- "heading",
233
- "bulletList",
234
- "orderedList",
235
- "taskList",
236
- "codeBlock"
237
- ], ke = [
238
- "tableCell",
239
- "tableHeader",
240
- "quoteCaption",
241
- "detailsSummary"
242
- ], Ae = (e) => {
243
- if (!e) return !1;
244
- let { $from: t } = e.state.selection;
245
- for (let e = t.depth; e > 0; e--) if (ke.includes(t.node(e).type.name)) return !0;
246
- return !1;
247
- }, je = (e, t) => {
248
- if (!e || t.length === 0) return !1;
249
- let { selection: n } = e.state, r = new Set(t);
250
- if (n instanceof Q) {
251
- let e = n.node?.type?.name;
252
- return !!e && r.has(e);
253
- }
254
- if (n instanceof ae || n instanceof ie) {
255
- let t = !0;
256
- return e.state.doc.nodesBetween(n.from, n.to, (e) => e.isTextblock && !r.has(e.type.name) ? (t = !1, !1) : t), t;
257
- }
258
- return !1;
259
- }, Me = /[\0-\x20\xA0\u1680\u180E\u2000-\u2029\u205F\u3000]/g, Ne = [
260
- "http",
261
- "https",
262
- "ftp",
263
- "ftps",
264
- "mailto",
265
- "tel",
266
- "callto",
267
- "sms"
268
- ], Pe = (e, t) => {
269
- try {
270
- let n = new URL(e, t), r = n.href.replace(Me, ""), i = RegExp(`^(?:(?:${Ne.join("|")}):|[^a-z]|[a-z0-9+.\\-]+(?:[^a-z+.\\-:]|$))`, "i");
271
- if (r.match(i)) return n.href;
272
- } catch {}
273
- return "#";
274
- }, Fe = (e, t = []) => {
275
- let { tr: n } = e.state, { selection: r } = n;
276
- return r.empty ? !1 : (r.ranges.forEach((e) => {
277
- n.doc.nodesBetween(e.$from.pos, e.$to.pos, (e, r) => (e.isInline && e.marks.forEach((i) => {
278
- t.includes(i.type.name) || n.removeMark(r, r + e.nodeSize, i.type);
279
- }), !0));
280
- }), e.view.dispatch(n), e.commands.focus(), !0);
281
- }, Ie = (e) => {
282
- let { selection: t } = e.state;
283
- if (t.empty) return !1;
284
- for (let n of t.ranges) {
285
- let t = !1;
286
- if (e.state.doc.nodesBetween(n.$from.pos, n.$to.pos, (e) => e.isInline && e.marks.length > 0 ? (t = !0, !1) : !0), t) return !0;
287
- }
288
- return !1;
289
- }, Le = "j67x6z0", Re = "j67x6z1", ze = "_5pk5r80", Be = (e) => {
290
- let t = C(50), { editor: n } = e, [r, i] = v(!1), { isActive: a, currentUrl: o } = ye({
291
- editor: n,
292
- selector: Ve
293
- }) ?? {
294
- isActive: !1,
295
- currentUrl: ""
296
- }, [c, g] = v(o), y, S;
297
- t[0] !== o || t[1] !== r ? (y = () => {
298
- r && g(o);
299
- }, S = [r, o], t[0] = o, t[1] = r, t[2] = y, t[3] = S) : (y = t[2], S = t[3]), _(y, S);
300
- let w;
301
- t[4] !== n || t[5] !== c ? (w = () => {
302
- c && (n.chain().focus().extendMarkRange("link").setLink({ href: c }).run(), i(!1));
303
- }, t[4] = n, t[5] = c, t[6] = w) : w = t[6];
304
- let T = w, E;
305
- t[7] === n ? E = t[8] : (E = () => {
306
- n.chain().focus().extendMarkRange("link").unsetLink().run(), g(""), i(!1);
307
- }, t[7] = n, t[8] = E);
308
- let ee = E, te;
309
- t[9] === c ? te = t[10] : (te = () => {
310
- let e = Pe(c, window.location.href);
311
- e !== "#" && window.open(e, "_blank", "noopener,noreferrer");
312
- }, t[9] = c, t[10] = te);
313
- let D = te, O;
314
- t[11] === Symbol.for("react.memo_cache_sentinel") ? (O = (e) => {
315
- e.preventDefault(), i(!0);
316
- }, t[11] = O) : O = t[11];
317
- let k;
318
- t[12] === a ? k = t[13] : (k = /* @__PURE__ */ b(m, {
319
- onPointerDown: He,
320
- render: /* @__PURE__ */ b($, {
321
- label: "Link",
322
- Icon: re,
323
- isActive: a,
324
- onClick: O
325
- })
326
- }), t[12] = a, t[13] = k);
327
- let A;
328
- t[14] === Symbol.for("react.memo_cache_sentinel") ? (A = (e) => g(e.target.value), t[14] = A) : A = t[14];
329
- let j;
330
- t[15] === T ? j = t[16] : (j = (e) => {
331
- e.key === "Enter" && (e.preventDefault(), T());
332
- }, t[15] = T, t[16] = j);
333
- let N;
334
- t[17] !== j || t[18] !== c ? (N = /* @__PURE__ */ b("input", {
335
- className: Re,
336
- value: c,
337
- onChange: A,
338
- onKeyDown: j,
339
- placeholder: "Paste a link..."
340
- }), t[17] = j, t[18] = c, t[19] = N) : N = t[19];
341
- let P = !c && !a, F;
342
- t[20] === Symbol.for("react.memo_cache_sentinel") ? (F = /* @__PURE__ */ b(M, { size: 16 }), t[20] = F) : F = t[20];
343
- let I;
344
- t[21] !== T || t[22] !== P ? (I = /* @__PURE__ */ b(s, { render: /* @__PURE__ */ b("button", {
345
- type: "button",
346
- className: ze,
347
- onClick: T,
348
- disabled: P,
349
- "aria-label": "Apply link",
350
- children: F
351
- }) }), t[21] = T, t[22] = P, t[23] = I) : I = t[23];
352
- let L;
353
- t[24] === Symbol.for("react.memo_cache_sentinel") ? (L = /* @__PURE__ */ b(l, { children: "Apply link" }), t[24] = L) : L = t[24];
354
- let R;
355
- t[25] === I ? R = t[26] : (R = /* @__PURE__ */ x(u, { children: [I, L] }), t[25] = I, t[26] = R);
356
- let z = !c && !a, B;
357
- t[27] === Symbol.for("react.memo_cache_sentinel") ? (B = /* @__PURE__ */ b(ne, { size: 16 }), t[27] = B) : B = t[27];
358
- let V;
359
- t[28] !== D || t[29] !== z ? (V = /* @__PURE__ */ b(s, { render: /* @__PURE__ */ b("button", {
360
- type: "button",
361
- className: ze,
362
- onClick: D,
363
- disabled: z,
364
- "aria-label": "Open in new window",
365
- children: B
366
- }) }), t[28] = D, t[29] = z, t[30] = V) : V = t[30];
367
- let H;
368
- t[31] === Symbol.for("react.memo_cache_sentinel") ? (H = /* @__PURE__ */ b(l, { children: "Open in new window" }), t[31] = H) : H = t[31];
369
- let U;
370
- t[32] === V ? U = t[33] : (U = /* @__PURE__ */ x(u, { children: [V, H] }), t[32] = V, t[33] = U);
371
- let W = !c && !a, G;
372
- t[34] === Symbol.for("react.memo_cache_sentinel") ? (G = /* @__PURE__ */ b(J, { size: 16 }), t[34] = G) : G = t[34];
373
- let K;
374
- t[35] !== ee || t[36] !== W ? (K = /* @__PURE__ */ b(s, { render: /* @__PURE__ */ b("button", {
375
- type: "button",
376
- className: ze,
377
- onClick: ee,
378
- disabled: W,
379
- "aria-label": "Remove link",
380
- children: G
381
- }) }), t[35] = ee, t[36] = W, t[37] = K) : K = t[37];
382
- let q;
383
- t[38] === Symbol.for("react.memo_cache_sentinel") ? (q = /* @__PURE__ */ b(l, { children: "Remove link" }), t[38] = q) : q = t[38];
384
- let Y;
385
- t[39] === K ? Y = t[40] : (Y = /* @__PURE__ */ x(u, { children: [K, q] }), t[39] = K, t[40] = Y);
386
- let X;
387
- t[41] !== N || t[42] !== R || t[43] !== U || t[44] !== Y ? (X = /* @__PURE__ */ b(f, { children: /* @__PURE__ */ b(h, {
388
- side: "bottom",
389
- align: "center",
390
- children: /* @__PURE__ */ x(d.Popup, {
391
- className: Le,
392
- children: [
393
- N,
394
- R,
395
- U,
396
- Y
397
- ]
398
- })
399
- }) }), t[41] = N, t[42] = R, t[43] = U, t[44] = Y, t[45] = X) : X = t[45];
400
- let Z;
401
- return t[46] !== r || t[47] !== X || t[48] !== k ? (Z = /* @__PURE__ */ x(p, {
402
- open: r,
403
- onOpenChange: i,
404
- children: [k, X]
405
- }), t[46] = r, t[47] = X, t[48] = k, t[49] = Z) : Z = t[49], Z;
406
- };
407
- function Ve(e) {
408
- let { editor: t } = e;
409
- return {
410
- isActive: t.isActive("link"),
411
- currentUrl: t.getAttributes("link")?.href ?? ""
412
- };
413
- }
414
- function He(e) {
415
- return e.preventDefault();
416
- }
417
- //#endregion
418
- //#region ../../libraries/react-collection/dist/components/editor/menus/TurnIntoMenu.cssm.js
419
- var Ue = "_1keigwl0", We = "_1keigwl1 _5pk5r80", Ge = (e) => (t) => t.chain().focus().setHeading({ level: e }).run(), Ke = [
420
- {
421
- type: "paragraph",
422
- label: "Text",
423
- Icon: U,
424
- isActive: (e) => e.isActive("paragraph"),
425
- canApply: (e) => e.can().setParagraph() || e.can().clearNodes(),
426
- apply: (e) => e.chain().focus().setParagraph().run()
427
- },
428
- {
429
- type: "heading_1",
430
- label: "Heading 1",
431
- Icon: N,
432
- isActive: (e) => e.isActive("heading", { level: 1 }),
433
- canApply: (e) => e.can().setHeading({ level: 1 }) || e.can().clearNodes(),
434
- apply: Ge(1)
435
- },
436
- {
437
- type: "heading_2",
438
- label: "Heading 2",
439
- Icon: P,
440
- isActive: (e) => e.isActive("heading", { level: 2 }),
441
- canApply: (e) => e.can().setHeading({ level: 2 }) || e.can().clearNodes(),
442
- apply: Ge(2)
443
- },
444
- {
445
- type: "heading_3",
446
- label: "Heading 3",
447
- Icon: F,
448
- isActive: (e) => e.isActive("heading", { level: 3 }),
449
- canApply: (e) => e.can().setHeading({ level: 3 }) || e.can().clearNodes(),
450
- apply: Ge(3)
451
- },
452
- {
453
- type: "heading_4",
454
- label: "Heading 4",
455
- Icon: I,
456
- isActive: (e) => e.isActive("heading", { level: 4 }),
457
- canApply: (e) => e.can().setHeading({ level: 4 }) || e.can().clearNodes(),
458
- apply: Ge(4)
459
- },
460
- {
461
- type: "heading_5",
462
- label: "Heading 5",
463
- Icon: L,
464
- isActive: (e) => e.isActive("heading", { level: 5 }),
465
- canApply: (e) => e.can().setHeading({ level: 5 }) || e.can().clearNodes(),
466
- apply: Ge(5)
467
- },
468
- {
469
- type: "heading_6",
470
- label: "Heading 6",
471
- Icon: R,
472
- isActive: (e) => e.isActive("heading", { level: 6 }),
473
- canApply: (e) => e.can().setHeading({ level: 6 }) || e.can().clearNodes(),
474
- apply: Ge(6)
475
- },
476
- {
477
- type: "bulletList",
478
- label: "Bullet List",
479
- Icon: B,
480
- isActive: (e) => e.isActive("bulletList"),
481
- canApply: (e) => e.can().toggleBulletList() || e.can().clearNodes(),
482
- apply: (e) => e.chain().focus().toggleBulletList().run()
483
- },
484
- {
485
- type: "orderedList",
486
- label: "Ordered List",
487
- Icon: V,
488
- isActive: (e) => e.isActive("orderedList"),
489
- canApply: (e) => e.can().toggleOrderedList() || e.can().clearNodes(),
490
- apply: (e) => e.chain().focus().toggleOrderedList().run()
491
- }
492
- ], qe = (e) => {
493
- let t = C(19), { editor: n } = e, [r, i] = v(!1), { activeBlock: a, canConvert: o, structural: s } = ye({
494
- editor: n,
495
- selector: Je
496
- }) ?? {
497
- activeBlock: null,
498
- canConvert: !1,
499
- structural: !1
500
- }, c = a?.Icon ?? H, l = a?.label ?? "Turn Into", u = s || !o, g, _;
501
- t[0] === Symbol.for("react.memo_cache_sentinel") ? (g = /* @__PURE__ */ b(A, { size: 12 }), _ = (e) => {
502
- e.preventDefault(), i(!0);
503
- }, t[0] = g, t[1] = _) : (g = t[0], _ = t[1]);
504
- let y;
505
- t[2] !== c || t[3] !== u || t[4] !== l ? (y = /* @__PURE__ */ b(m, {
506
- onPointerDown: Ye,
507
- render: /* @__PURE__ */ b($, {
508
- label: l,
509
- Icon: c,
510
- disabled: u,
511
- trailing: g,
512
- onClick: _
513
- })
514
- }), t[2] = c, t[3] = u, t[4] = l, t[5] = y) : y = t[5];
515
- let S;
516
- if (t[6] !== a?.type || t[7] !== n) {
517
- let e;
518
- t[9] === a?.type ? e = t[10] : (e = (e) => a?.type !== e.type, t[9] = a?.type, t[10] = e);
519
- let r;
520
- t[11] === n ? r = t[12] : (r = (e) => /* @__PURE__ */ x("button", {
521
- type: "button",
522
- className: We,
523
- disabled: !e.canApply(n),
524
- onClick: () => {
525
- e.apply(n), i(!1);
526
- },
527
- children: [/* @__PURE__ */ b(e.Icon, { size: 16 }), /* @__PURE__ */ b("span", { children: e.label })]
528
- }, e.type), t[11] = n, t[12] = r), S = Ke.filter(e).map(r), t[6] = a?.type, t[7] = n, t[8] = S;
529
- } else S = t[8];
530
- let w;
531
- t[13] === S ? w = t[14] : (w = /* @__PURE__ */ b(f, { children: /* @__PURE__ */ b(h, {
532
- side: "bottom",
533
- align: "start",
534
- children: /* @__PURE__ */ b(d.Popup, {
535
- className: Ue,
536
- children: S
537
- })
538
- }) }), t[13] = S, t[14] = w);
539
- let T;
540
- return t[15] !== r || t[16] !== y || t[17] !== w ? (T = /* @__PURE__ */ x(p, {
541
- open: r,
542
- onOpenChange: i,
543
- children: [y, w]
544
- }), t[15] = r, t[16] = y, t[17] = w, t[18] = T) : T = t[18], T;
545
- };
546
- function Je(e) {
547
- let { editor: t } = e;
548
- return {
549
- activeBlock: Ke.find((e) => e.isActive(t)) ?? null,
550
- canConvert: je(t, Oe),
551
- structural: Ae(t)
552
- };
553
- }
554
- function Ye(e) {
555
- return e.preventDefault();
556
- }
557
- //#endregion
558
- //#region ../../libraries/react-collection/dist/components/editor/Toolbar.js
559
- var Xe = [
560
- {
561
- mark: "bold",
562
- label: "Bold",
563
- Icon: k
564
- },
565
- {
566
- mark: "italic",
567
- label: "Italic",
568
- Icon: z
569
- },
570
- {
571
- mark: "underline",
572
- label: "Underline",
573
- Icon: Y
574
- },
575
- {
576
- mark: "strike",
577
- label: "Strike",
578
- Icon: G
579
- },
580
- {
581
- mark: "code",
582
- label: "Code",
583
- Icon: j
584
- }
585
- ], Ze = [{
586
- mark: "superscript",
587
- label: "Superscript",
588
- Icon: q
589
- }, {
590
- mark: "subscript",
591
- label: "Subscript",
592
- Icon: K
593
- }], Qe = [
594
- {
595
- align: "left",
596
- label: "Align left",
597
- Icon: ee
598
- },
599
- {
600
- align: "center",
601
- label: "Align center",
602
- Icon: T
603
- },
604
- {
605
- align: "right",
606
- label: "Align right",
607
- Icon: te
608
- },
609
- {
610
- align: "justify",
611
- label: "Align justify",
612
- Icon: E
613
- }
614
- ], $e = (e) => {
615
- let t = C(9), { editor: n, mark: r, label: i, Icon: a } = e, { isActive: o, canExecute: s } = ye({
616
- editor: n,
617
- selector: (e) => {
618
- let { editor: t } = e;
619
- return {
620
- isActive: t.isActive(r),
621
- canExecute: t.isEditable && t.can().toggleMark(r)
622
- };
623
- }
624
- }) ?? {
625
- isActive: !1,
626
- canExecute: !1
627
- }, c = !s, l;
628
- t[0] !== n || t[1] !== r ? (l = () => n.chain().focus().toggleMark(r).run(), t[0] = n, t[1] = r, t[2] = l) : l = t[2];
629
- let u;
630
- return t[3] !== a || t[4] !== o || t[5] !== i || t[6] !== c || t[7] !== l ? (u = /* @__PURE__ */ b($, {
631
- label: i,
632
- Icon: a,
633
- isActive: o,
634
- disabled: c,
635
- onClick: l
636
- }), t[3] = a, t[4] = o, t[5] = i, t[6] = c, t[7] = l, t[8] = u) : u = t[8], u;
637
- }, et = (e) => {
638
- let t = C(9), { editor: n, align: r, label: i, Icon: a } = e, { isActive: o, canExecute: s } = ye({
639
- editor: n,
640
- selector: (e) => {
641
- let { editor: t } = e;
642
- return {
643
- isActive: t.isActive({ textAlign: r }),
644
- canExecute: t.isEditable && t.can().setNodeTextAlign(r)
645
- };
646
- }
647
- }) ?? {
648
- isActive: !1,
649
- canExecute: !1
650
- }, c = !s, l;
651
- t[0] !== r || t[1] !== n ? (l = () => n.chain().focus().setNodeTextAlign(r).run(), t[0] = r, t[1] = n, t[2] = l) : l = t[2];
652
- let u;
653
- return t[3] !== a || t[4] !== o || t[5] !== i || t[6] !== c || t[7] !== l ? (u = /* @__PURE__ */ b($, {
654
- label: i,
655
- Icon: a,
656
- isActive: o,
657
- disabled: c,
658
- onClick: l
659
- }), t[3] = a, t[4] = o, t[5] = i, t[6] = c, t[7] = l, t[8] = u) : u = t[8], u;
660
- }, tt = (e) => {
661
- let t = C(5), { editor: n } = e, r = !(ye({
662
- editor: n,
663
- selector: at
664
- }) ?? !1), i;
665
- t[0] === n ? i = t[1] : (i = () => n.chain().focus().undo().run(), t[0] = n, t[1] = i);
666
- let a;
667
- return t[2] !== r || t[3] !== i ? (a = /* @__PURE__ */ b($, {
668
- label: "Undo",
669
- Icon: D,
670
- disabled: r,
671
- onClick: i
672
- }), t[2] = r, t[3] = i, t[4] = a) : a = t[4], a;
673
- }, nt = (e) => {
674
- let t = C(5), { editor: n } = e, r = !(ye({
675
- editor: n,
676
- selector: ot
677
- }) ?? !1), i;
678
- t[0] === n ? i = t[1] : (i = () => n.chain().focus().redo().run(), t[0] = n, t[1] = i);
679
- let a;
680
- return t[2] !== r || t[3] !== i ? (a = /* @__PURE__ */ b($, {
681
- label: "Redo",
682
- Icon: O,
683
- disabled: r,
684
- onClick: i
685
- }), t[2] = r, t[3] = i, t[4] = a) : a = t[4], a;
686
- }, rt = (e) => {
687
- let t = C(5), { editor: n } = e, r = !(ye({
688
- editor: n,
689
- selector: st
690
- }) ?? !1), i;
691
- t[0] === n ? i = t[1] : (i = () => Fe(n), t[0] = n, t[1] = i);
692
- let a;
693
- return t[2] !== r || t[3] !== i ? (a = /* @__PURE__ */ b($, {
694
- label: "Reset formatting",
695
- Icon: W,
696
- disabled: r,
697
- onClick: i
698
- }), t[2] = r, t[3] = i, t[4] = a) : a = t[4], a;
699
- }, it = (e) => {
700
- let n = C(33), { children: r } = e, { editor: i } = _e();
701
- if (!i) return null;
702
- let a;
703
- n[0] === i ? a = n[1] : (a = /* @__PURE__ */ b("div", {
704
- className: Ee,
705
- children: /* @__PURE__ */ b(qe, { editor: i })
706
- }), n[0] = i, n[1] = a);
707
- let o;
708
- n[2] === Symbol.for("react.memo_cache_sentinel") ? (o = /* @__PURE__ */ b(t, { orientation: "vertical" }), n[2] = o) : o = n[2];
709
- let s;
710
- n[3] === i ? s = n[4] : (s = Xe.map((e) => /* @__PURE__ */ b($e, {
711
- editor: i,
712
- ...e
713
- }, e.mark)), n[3] = i, n[4] = s);
714
- let c;
715
- n[5] === s ? c = n[6] : (c = /* @__PURE__ */ b("div", {
716
- className: Ee,
717
- children: s
718
- }), n[5] = s, n[6] = c);
719
- let l;
720
- n[7] === Symbol.for("react.memo_cache_sentinel") ? (l = /* @__PURE__ */ b(t, { orientation: "vertical" }), n[7] = l) : l = n[7];
721
- let u;
722
- n[8] === i ? u = n[9] : (u = /* @__PURE__ */ b("div", {
723
- className: Ee,
724
- children: /* @__PURE__ */ b(Be, { editor: i })
725
- }), n[8] = i, n[9] = u);
726
- let d;
727
- n[10] === Symbol.for("react.memo_cache_sentinel") ? (d = /* @__PURE__ */ b(t, { orientation: "vertical" }), n[10] = d) : d = n[10];
728
- let f;
729
- n[11] === i ? f = n[12] : (f = Qe.map((e) => /* @__PURE__ */ b(et, {
730
- editor: i,
731
- ...e
732
- }, e.align)), n[11] = i, n[12] = f);
733
- let p;
734
- n[13] === f ? p = n[14] : (p = /* @__PURE__ */ b("div", {
735
- className: Ee,
736
- children: f
737
- }), n[13] = f, n[14] = p);
738
- let m;
739
- n[15] === Symbol.for("react.memo_cache_sentinel") ? (m = /* @__PURE__ */ b(t, { orientation: "vertical" }), n[15] = m) : m = n[15];
740
- let h;
741
- n[16] === i ? h = n[17] : (h = Ze.map((e) => /* @__PURE__ */ b($e, {
742
- editor: i,
743
- ...e
744
- }, e.mark)), n[16] = i, n[17] = h);
745
- let g;
746
- n[18] === h ? g = n[19] : (g = /* @__PURE__ */ b("div", {
747
- className: Ee,
748
- children: h
749
- }), n[18] = h, n[19] = g);
750
- let _;
751
- n[20] === Symbol.for("react.memo_cache_sentinel") ? (_ = /* @__PURE__ */ b(t, { orientation: "vertical" }), n[20] = _) : _ = n[20];
752
- let v;
753
- n[21] === i ? v = n[22] : (v = /* @__PURE__ */ x("div", {
754
- className: Ee,
755
- children: [
756
- /* @__PURE__ */ b(rt, { editor: i }),
757
- /* @__PURE__ */ b(tt, { editor: i }),
758
- /* @__PURE__ */ b(nt, { editor: i })
759
- ]
760
- }), n[21] = i, n[22] = v);
761
- let S;
762
- n[23] === r ? S = n[24] : (S = r && /* @__PURE__ */ x(y, { children: [/* @__PURE__ */ b(t, { orientation: "vertical" }), /* @__PURE__ */ b("div", {
763
- className: "_261ja31",
764
- children: r
765
- })] }), n[23] = r, n[24] = S);
766
- let w;
767
- return n[25] !== a || n[26] !== g || n[27] !== v || n[28] !== S || n[29] !== c || n[30] !== u || n[31] !== p ? (w = /* @__PURE__ */ x("div", {
768
- className: Te,
769
- children: [
770
- a,
771
- o,
772
- c,
773
- l,
774
- u,
775
- d,
776
- p,
777
- m,
778
- g,
779
- _,
780
- v,
781
- S
782
- ]
783
- }), n[25] = a, n[26] = g, n[27] = v, n[28] = S, n[29] = c, n[30] = u, n[31] = p, n[32] = w) : w = n[32], w;
784
- };
785
- function at(e) {
786
- let { editor: t } = e;
787
- return t.isEditable && t.can().undo();
788
- }
789
- function ot(e) {
790
- let { editor: t } = e;
791
- return t.isEditable && t.can().redo();
792
- }
793
- function st(e) {
794
- let { editor: t } = e;
795
- return t.isEditable && Ie(t);
796
- }
797
- //#endregion
798
- //#region ../../libraries/react-collection/dist/widgets/richTextWidget/RichTextWidget.cssm.js
799
- var ct = "_1vx76w30", lt = "_1vx76w33", ut = "_1vx76w34", dt = "_12oclrg0", ft = "u2k86a0", pt = {
800
- baseSpacing: "var(--_1q6hy0o0)",
801
- highlight: "var(--_1q6hy0o1)",
802
- highlightForeground: "var(--_1q6hy0o2)"
803
- }, mt = (e) => {
804
- let t = C(7), { children: r, theme: i } = e, o = i?.className, s;
805
- t[0] === o ? s = t[1] : (s = w(a, ft, o), t[0] = o, t[1] = s);
806
- let c = i?.style, l = i?.portalToThemeRoot, u;
807
- return t[2] !== r || t[3] !== s || t[4] !== c || t[5] !== l ? (u = /* @__PURE__ */ b(n, {
808
- className: s,
809
- style: c,
810
- portalToThemeRoot: l,
811
- children: r
812
- }), t[2] = r, t[3] = s, t[4] = c, t[5] = l, t[6] = u) : u = t[6], u;
813
- }, ht = { style: c(pt)({ baseSpacing: ".875rem" }) }, gt = (e) => {
814
- let n = C(58), { field: a } = e, [s, c] = v(!1), { key: l, label: u, helper_text: d, readonly: f, placeholder: p } = a, m = l === void 0 ? "" : l, h = u === void 0 ? "" : u, g = d === void 0 ? "" : d, y = f === void 0 ? !1 : f, T;
815
- n[0] === a ? T = n[1] : (T = i(a), n[0] = a, n[1] = T);
816
- let E;
817
- n[2] !== m || n[3] !== T ? (E = {
818
- name: m,
819
- rules: T
820
- }, n[2] = m, n[3] = T, n[4] = E) : E = n[4];
821
- let { field: ee, fieldState: te } = S(E), { value: D, onBlur: O, onChange: k, disabled: A } = ee, j = p || "Write something ...", M;
822
- n[5] === j ? M = n[6] : (M = we({ placeholder: j }), n[5] = j, n[6] = M);
823
- let ne = D || "", N = !A && !y, P;
824
- n[7] === Symbol.for("react.memo_cache_sentinel") ? (P = { attributes: {
825
- autocomplete: "off",
826
- autocorrect: "off",
827
- autocapitalize: "off",
828
- class: dt
829
- } }, n[7] = P) : P = n[7];
830
- let F;
831
- n[8] === k ? F = n[9] : (F = (e) => {
832
- let { editor: t } = e;
833
- return k(t.getHTML());
834
- }, n[8] = k, n[9] = F);
835
- let I;
836
- n[10] !== ne || n[11] !== N || n[12] !== F || n[13] !== M ? (I = {
837
- extensions: M,
838
- content: ne,
839
- editable: N,
840
- editorProps: P,
841
- onUpdate: F,
842
- immediatelyRender: !1
843
- }, n[10] = ne, n[11] = N, n[12] = F, n[13] = M, n[14] = I) : I = n[14];
844
- let L = ve(I), R;
845
- n[15] !== L || n[16] !== s || n[17] !== D ? (R = () => {
846
- L?.commands && !s && (L.commands.setContent(D || "", { emitUpdate: !1 }), c(!0));
847
- }, n[15] = L, n[16] = s, n[17] = D, n[18] = R) : R = n[18];
848
- let z;
849
- n[19] === D ? z = n[20] : (z = [D], n[19] = D, n[20] = z), _(R, z);
850
- let re, B;
851
- n[21] !== A || n[22] !== L || n[23] !== y ? (re = () => {
852
- L && L.setEditable(!A && !y, !1);
853
- }, B = [
854
- L,
855
- A,
856
- y
857
- ], n[21] = A, n[22] = L, n[23] = y, n[24] = re, n[25] = B) : (re = n[24], B = n[25]), _(re, B);
858
- let V, H;
859
- n[26] !== L || n[27] !== O ? (V = () => {
860
- if (L) return L.on("blur", O), () => {
861
- L.off("blur", O);
862
- };
863
- }, H = [L, O], n[26] = L, n[27] = O, n[28] = V, n[29] = H) : (V = n[28], H = n[29]), _(V, H);
864
- let U = te?.error?.message, W = !!a?.required, G = A && "_1vx76w31", K = y && "_1vx76w32", q;
865
- n[30] !== G || n[31] !== K ? (q = w(ct, G, K), n[30] = G, n[31] = K, n[32] = q) : q = n[32];
866
- let J;
867
- n[33] === L ? J = n[34] : (J = { editor: L }, n[33] = L, n[34] = J);
868
- let Y, X;
869
- n[35] === Symbol.for("react.memo_cache_sentinel") ? (Y = /* @__PURE__ */ b(it, {}), X = /* @__PURE__ */ b(t, { orientation: "horizontal" }), n[35] = Y, n[36] = X) : (Y = n[35], X = n[36]);
870
- let Z;
871
- n[37] === L?.commands ? Z = n[38] : (Z = () => L?.commands.focus(), n[37] = L?.commands, n[38] = Z);
872
- let ie;
873
- n[39] === L ? ie = n[40] : (ie = /* @__PURE__ */ b(he, { editor: L }), n[39] = L, n[40] = ie);
874
- let Q;
875
- n[41] !== Z || n[42] !== ie ? (Q = /* @__PURE__ */ x("div", {
876
- className: lt,
877
- children: [
878
- Y,
879
- X,
880
- /* @__PURE__ */ b("div", {
881
- className: ut,
882
- onClick: Z,
883
- children: ie
884
- })
885
- ]
886
- }), n[41] = Z, n[42] = ie, n[43] = Q) : Q = n[43];
887
- let ae;
888
- n[44] !== J || n[45] !== Q ? (ae = /* @__PURE__ */ b(mt, {
889
- theme: ht,
890
- children: /* @__PURE__ */ b(o, { children: /* @__PURE__ */ b(ge.Provider, {
891
- value: J,
892
- children: Q
893
- }) })
894
- }), n[44] = J, n[45] = Q, n[46] = ae) : ae = n[46];
895
- let oe;
896
- n[47] !== q || n[48] !== ae ? (oe = /* @__PURE__ */ b("div", {
897
- className: q,
898
- children: ae
899
- }), n[47] = q, n[48] = ae, n[49] = oe) : oe = n[49];
900
- let se;
901
- return n[50] !== g || n[51] !== m || n[52] !== h || n[53] !== y || n[54] !== U || n[55] !== W || n[56] !== oe ? (se = /* @__PURE__ */ b(r, {
902
- error: U,
903
- helperText: g,
904
- readOnly: y,
905
- label: h,
906
- htmlFor: m,
907
- isRequired: W,
908
- children: oe
909
- }), n[50] = g, n[51] = m, n[52] = h, n[53] = y, n[54] = U, n[55] = W, n[56] = oe, n[57] = se) : se = n[57], se;
910
- };
911
- //#endregion
912
- export { gt as RichTextWidget, gt as default };