@techzyapp/ui-library 1.0.29 → 1.0.30

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,806 +0,0 @@
1
- import { jsx as r, jsxs as x, Fragment as Ge } from "react/jsx-runtime";
2
- import { useRef as I, useState as p, useCallback as Le, useEffect as L, forwardRef as Ke } from "react";
3
- import { clsx as Je } from "clsx";
4
- import { DecoratorNode as xe, $applyNodeReplacement as Me, $getSelection as P, $isRangeSelection as q, $isElementNode as Qe, SELECTION_CHANGE_COMMAND as We, COMMAND_PRIORITY_LOW as ie, CAN_UNDO_COMMAND as Xe, CAN_REDO_COMMAND as Ze, UNDO_COMMAND as Ye, REDO_COMMAND as et, $createParagraphNode as ke, FORMAT_ELEMENT_COMMAND as tt, FORMAT_TEXT_COMMAND as rt, $getRoot as Se, $insertNodes as ot, $setSelection as nt, $isParagraphNode as it } from "lexical";
5
- import { LexicalComposer as lt } from "@lexical/react/LexicalComposer";
6
- import { useLexicalComposerContext as Oe } from "@lexical/react/LexicalComposerContext";
7
- import { RichTextPlugin as at } from "@lexical/react/LexicalRichTextPlugin";
8
- import { ContentEditable as ct } from "@lexical/react/LexicalContentEditable";
9
- import { LexicalErrorBoundary as st } from "@lexical/react/LexicalErrorBoundary";
10
- import { HistoryPlugin as mt } from "@lexical/react/LexicalHistoryPlugin";
11
- import { ListPlugin as dt } from "@lexical/react/LexicalListPlugin";
12
- import { CheckListPlugin as ut } from "@lexical/react/LexicalCheckListPlugin";
13
- import { LinkPlugin as pt } from "@lexical/react/LexicalLinkPlugin";
14
- import { MarkdownShortcutPlugin as ht } from "@lexical/react/LexicalMarkdownShortcutPlugin";
15
- import { ELEMENT_TRANSFORMERS as _t, TEXT_FORMAT_TRANSFORMERS as ft, TEXT_MATCH_TRANSFORMERS as gt } from "@lexical/markdown";
16
- import { $isHeadingNode as bt, $isQuoteNode as vt, $createQuoteNode as yt, $createHeadingNode as Ct, HeadingNode as Nt, QuoteNode as Tt } from "@lexical/rich-text";
17
- import { ListNode as Re, REMOVE_LIST_COMMAND as Et, INSERT_UNORDERED_LIST_COMMAND as Lt, INSERT_ORDERED_LIST_COMMAND as xt, INSERT_CHECK_LIST_COMMAND as Mt, ListItemNode as kt } from "@lexical/list";
18
- import { $isLinkNode as be, TOGGLE_LINK_COMMAND as St, LinkNode as Ae } from "@lexical/link";
19
- import { $generateHtmlFromNodes as Ot, $generateNodesFromDOM as Rt } from "@lexical/html";
20
- import { u as At } from "./formContext-B7ln1Miy.js";
21
- import { T as ve } from "./Typography-CJv5AnRP.js";
22
- import { t as Dt } from "./toastStore-Cx_JOKwS.js";
23
- import { $getSelectionStyleValueForProperty as ye, $patchStyleText as Ce, $setBlocksType as le } from "@lexical/selection";
24
- import { $findMatchingParent as It, $getNearestNodeOfType as jt, mergeRegister as Ut, $insertNodeToNearestRoot as ae } from "@lexical/utils";
25
- import { B as V } from "./Button-CWMNNiia.js";
26
- import { C as wt, D as Ft } from "./ColorPickerPanel-DZjN8NNn.js";
27
- import { D as O } from "./Divider-LtH3dLgw.js";
28
- import { D as ce } from "./Dropdown--1mNTVZJ.js";
29
- import { F as $t } from "./FloatingPanel-CeSOtE_D.js";
30
- import { I as u } from "./Icon-DaTvzLBu.js";
31
- import { I as R } from "./IconButton-GU3Ud4Zg.js";
32
- import { a as z } from "./List-CZwNGxuP.js";
33
- import { M as Bt } from "./Modal-DHP2R3K3.js";
34
- import { T as Ht } from "./TextField-SGYWviFf.js";
35
- import { a as se } from "./ConfigProvider-BbsI15b-.js";
36
- const Pt = /^(?:https?:|mailto:|tel:|ftp:|#|\/|\?|\.)/i, qt = /^[a-z][a-z0-9+.-]*:/i;
37
- function me(o) {
38
- const t = o.trim();
39
- return t === "" ? "" : Pt.test(t) || !qt.test(t) ? t : "#";
40
- }
41
- function De(o) {
42
- const t = o.trim();
43
- if (/^data:(?:image|video)\//i.test(t) || /^blob:/i.test(t)) return t;
44
- const i = me(t);
45
- return i === "#" ? "" : i;
46
- }
47
- function Vt(o) {
48
- return o instanceof HTMLImageElement && o.src ? { node: G(o.getAttribute("src") ?? o.src, o.alt) } : null;
49
- }
50
- class K extends xe {
51
- static getType() {
52
- return "tz-image";
53
- }
54
- static clone(t) {
55
- return new K(t.__src, t.__alt, t.__key);
56
- }
57
- constructor(t, i = "", n) {
58
- super(n), this.__src = De(t), this.__alt = i;
59
- }
60
- static importJSON(t) {
61
- return G(t.src, t.alt);
62
- }
63
- exportJSON() {
64
- return { ...super.exportJSON(), type: "tz-image", version: 1, src: this.__src, alt: this.__alt };
65
- }
66
- static importDOM() {
67
- return { img: () => ({ conversion: Vt, priority: 0 }) };
68
- }
69
- exportDOM() {
70
- const t = document.createElement("img");
71
- return t.setAttribute("src", this.__src), t.setAttribute("alt", this.__alt), { element: t };
72
- }
73
- /** A block wrapper; the actual `<img>` is rendered by {@link decorate}. */
74
- createDOM() {
75
- const t = document.createElement("div");
76
- return t.style.display = "contents", t;
77
- }
78
- updateDOM() {
79
- return !1;
80
- }
81
- getSrc() {
82
- return this.__src;
83
- }
84
- getAltText() {
85
- return this.__alt;
86
- }
87
- decorate() {
88
- return /* @__PURE__ */ r("img", { src: this.__src, alt: this.__alt, draggable: !1 });
89
- }
90
- }
91
- function G(o, t = "") {
92
- return Me(new K(o, t));
93
- }
94
- function Ne(o) {
95
- return /\.(mp4|webm|ogg|ogv|mov|m4v)(\?.*)?$/i.test(o);
96
- }
97
- function zt(o) {
98
- const t = o.match(
99
- /(?:youtube\.com\/(?:watch\?(?:.*&)?v=|embed\/|shorts\/)|youtu\.be\/)([\w-]{11})/
100
- );
101
- if (t) return `https://www.youtube.com/embed/${t[1]}`;
102
- const i = o.match(/vimeo\.com\/(?:video\/)?(\d+)/);
103
- return i ? `https://player.vimeo.com/video/${i[1]}` : o;
104
- }
105
- function Te(o) {
106
- var i;
107
- const t = o.getAttribute("src") || ((i = o.querySelector("source")) == null ? void 0 : i.getAttribute("src"));
108
- return t ? { node: de(t) } : null;
109
- }
110
- class J extends xe {
111
- static getType() {
112
- return "tz-video";
113
- }
114
- static clone(t) {
115
- return new J(t.__src, t.__key);
116
- }
117
- constructor(t, i) {
118
- super(i), this.__src = De(t);
119
- }
120
- static importJSON(t) {
121
- return de(t.src);
122
- }
123
- exportJSON() {
124
- return { ...super.exportJSON(), type: "tz-video", version: 1, src: this.__src };
125
- }
126
- static importDOM() {
127
- return {
128
- iframe: () => ({ conversion: Te, priority: 0 }),
129
- video: () => ({ conversion: Te, priority: 0 })
130
- };
131
- }
132
- exportDOM() {
133
- if (Ne(this.__src)) {
134
- const i = document.createElement("video");
135
- return i.setAttribute("src", this.__src), i.setAttribute("controls", "true"), { element: i };
136
- }
137
- const t = document.createElement("iframe");
138
- return t.setAttribute("src", this.__src), t.setAttribute("frameborder", "0"), t.setAttribute("allowfullscreen", "true"), t.setAttribute(
139
- "allow",
140
- "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
141
- ), { element: t };
142
- }
143
- /** A block wrapper; the actual media element is rendered by {@link decorate}. */
144
- createDOM() {
145
- const t = document.createElement("div");
146
- return t.style.display = "contents", t;
147
- }
148
- updateDOM() {
149
- return !1;
150
- }
151
- getSrc() {
152
- return this.__src;
153
- }
154
- decorate() {
155
- return Ne(this.__src) ? /* @__PURE__ */ r("video", { src: this.__src, controls: !0 }) : /* @__PURE__ */ r(Gt, { src: this.__src });
156
- }
157
- }
158
- function Gt({ src: o }) {
159
- const t = se();
160
- return /* @__PURE__ */ r("div", { className: "tz-rte-embed", children: /* @__PURE__ */ r(
161
- "iframe",
162
- {
163
- src: o,
164
- title: t("rte.embeddedVideo"),
165
- frameBorder: 0,
166
- allow: "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",
167
- allowFullScreen: !0
168
- }
169
- ) });
170
- }
171
- function de(o) {
172
- return Me(new J(zt(o)));
173
- }
174
- const Kt = "_editor_16j1l_1", Jt = "_label_16j1l_9", Qt = "_required_16j1l_15", Wt = "_helper_16j1l_18", Xt = "_control_16j1l_24", Zt = "_error_16j1l_38", Yt = "_disabled_16j1l_45", er = "_toolbar_16j1l_51", tr = "_sm_16j1l_67", rr = "_md_16j1l_71", or = "_lg_16j1l_75", nr = "_colorGlyph_16j1l_81", ir = "_colorBar_16j1l_89", lr = "_shell_16j1l_107", ar = "_content_16j1l_110", cr = "_placeholder_16j1l_123", sr = "_paragraph_16j1l_146", mr = "_h1_16j1l_152", dr = "_h2_16j1l_153", ur = "_h3_16j1l_154", pr = "_h4_16j1l_155", hr = "_h5_16j1l_156", _r = "_h6_16j1l_157", fr = "_quote_16j1l_176", gr = "_ul_16j1l_183", br = "_ol_16j1l_188", vr = "_li_16j1l_193", yr = "_nestedLi_16j1l_196", Cr = "_liChecked_16j1l_200", Nr = "_liUnchecked_16j1l_201", Tr = "_link_16j1l_238", Er = "_bold_16j1l_245", Lr = "_italic_16j1l_248", xr = "_underline_16j1l_251", Mr = "_strike_16j1l_254", kr = "_codeInline_16j1l_260", l = {
175
- editor: Kt,
176
- label: Jt,
177
- required: Qt,
178
- helper: Wt,
179
- control: Xt,
180
- error: Zt,
181
- disabled: Yt,
182
- toolbar: er,
183
- sm: tr,
184
- md: rr,
185
- lg: or,
186
- colorGlyph: nr,
187
- colorBar: ir,
188
- shell: lr,
189
- content: ar,
190
- placeholder: cr,
191
- paragraph: sr,
192
- h1: mr,
193
- h2: dr,
194
- h3: ur,
195
- h4: pr,
196
- h5: hr,
197
- h6: _r,
198
- quote: fr,
199
- ul: gr,
200
- ol: br,
201
- li: vr,
202
- nestedLi: yr,
203
- liChecked: Cr,
204
- liUnchecked: Nr,
205
- link: Tr,
206
- bold: Er,
207
- italic: Lr,
208
- underline: xr,
209
- strike: Mr,
210
- codeInline: kr
211
- }, Sr = {
212
- paragraph: "Paragraph",
213
- h1: "Heading 1",
214
- h2: "Heading 2",
215
- h3: "Heading 3",
216
- quote: "Quote",
217
- bullet: "Bullet List",
218
- number: "Numbered List",
219
- check: "Check List"
220
- }, Or = [
221
- { type: "paragraph", icon: "Text" },
222
- { type: "h1", icon: "Hashtag" },
223
- { type: "h2", icon: "Hashtag" },
224
- { type: "h3", icon: "Hashtag" }
225
- ], Rr = [
226
- { value: "left", labelKey: "rte.alignLeft", icon: "TextalignLeft" },
227
- { value: "center", labelKey: "rte.alignCenter", icon: "TextalignCenter" },
228
- { value: "right", labelKey: "rte.alignRight", icon: "TextalignRight" }
229
- ], Ar = ["10px", "12px", "14px", "16px", "18px", "20px"], Dr = { sm: "12px", md: "14px", lg: "16px" };
230
- function Ir({ color: o, size: t }) {
231
- return /* @__PURE__ */ x("span", { className: l.colorGlyph, children: [
232
- /* @__PURE__ */ r(u, { name: "Brush", size: t }),
233
- /* @__PURE__ */ r(
234
- "span",
235
- {
236
- className: l.colorBar,
237
- style: { borderColor: `transparent transparent ${o || "currentColor"} transparent` },
238
- "aria-hidden": "true"
239
- }
240
- )
241
- ] });
242
- }
243
- function jr({ size: o, disabled: t, onImageUpload: i }) {
244
- const n = se(), s = (e) => Sr[e] ?? e, [c] = Oe(), g = I(null), [y, d] = p(!1), [_, Q] = p(!1), [M, W] = p(!1), [j, X] = p(!1), [Z, Y] = p(""), [v, k] = p("paragraph"), [b, f] = p("left"), [A, D] = p(""), [U, w] = p(""), [F, $] = p(!1), S = I(null), [ee, h] = p(!1), [Ie, je] = p(!1), [m, te] = p(null), [ue, pe] = p(""), re = Le(() => {
245
- const e = P();
246
- if (!q(e)) return;
247
- d(e.hasFormat("bold")), Q(e.hasFormat("italic")), W(e.hasFormat("underline")), w(ye(e, "color", "")), D(ye(e, "font-size", ""));
248
- const a = e.anchor.getNode(), T = a.getParent(), N = be(a) ? a : be(T) ? T : null;
249
- X(N !== null), Y((N == null ? void 0 : N.getURL()) ?? "");
250
- const E = a.getKey() === "root" ? a : It(a, (ze) => {
251
- const ge = ze.getParent();
252
- return ge === null || ge.getKey() === "root";
253
- }) ?? a.getTopLevelElement();
254
- f(Qe(E) && E.getFormatType() || "left");
255
- const H = jt(a, Re);
256
- H ? k(H.getListType()) : bt(E) ? k(E.getTag()) : vt(E) ? k("quote") : k("paragraph");
257
- }, []);
258
- L(() => Ut(
259
- c.registerUpdateListener(({ editorState: e }) => e.read(re)),
260
- c.registerCommand(
261
- We,
262
- () => (re(), !1),
263
- ie
264
- ),
265
- c.registerCommand(
266
- Xe,
267
- (e) => (h(e), !1),
268
- ie
269
- ),
270
- c.registerCommand(
271
- Ze,
272
- (e) => (je(e), !1),
273
- ie
274
- )
275
- ), [c, re]);
276
- const oe = (e) => c.dispatchCommand(rt, e), Ue = (e) => c.dispatchCommand(tt, e), we = (e) => {
277
- w(e), c.update(() => {
278
- const a = P();
279
- q(a) && Ce(a, { color: e || null });
280
- });
281
- }, Fe = (e) => {
282
- D(e), c.update(() => {
283
- const a = P();
284
- q(a) && Ce(a, { "font-size": e || null });
285
- });
286
- }, B = (e) => {
287
- if (e === "bullet" || e === "number" || e === "check") {
288
- if (v === e)
289
- c.dispatchCommand(Et, void 0);
290
- else {
291
- const a = e === "bullet" ? Lt : e === "number" ? xt : Mt;
292
- c.dispatchCommand(a, void 0);
293
- }
294
- return;
295
- }
296
- c.update(() => {
297
- const a = P();
298
- q(a) && (e === "paragraph" ? le(a, () => ke()) : e === "quote" ? le(a, () => yt()) : le(a, () => Ct(e)));
299
- });
300
- }, $e = () => B(v === "quote" ? "paragraph" : "quote"), ne = (e, a = "") => {
301
- pe(a), te(e);
302
- }, he = () => te(null), Be = () => {
303
- m == null || m.onConfirm(ue.trim()), te(null);
304
- }, He = () => ne(
305
- {
306
- icon: "Link2",
307
- title: n("rte.linkTitle"),
308
- label: n("rte.linkUrl"),
309
- placeholder: "https://example.com",
310
- confirmLabel: n(j ? "common.update" : "common.insert"),
311
- // an empty value removes the link (matches the old prompt behavior); sanitize the scheme
312
- onConfirm: (e) => c.dispatchCommand(St, e === "" ? null : me(e))
313
- },
314
- Z
315
- // prefill the current link's URL when the cursor sits in one
316
- ), Pe = () => ne({
317
- icon: "GalleryAdd",
318
- title: n("rte.imageTitle"),
319
- label: n("rte.imageUrl"),
320
- placeholder: "https://example.com/image.jpg",
321
- confirmLabel: n("common.insert"),
322
- onConfirm: (e) => {
323
- e && c.update(() => ae(G(e)));
324
- }
325
- }), qe = async (e) => {
326
- var T;
327
- const a = (T = e.target.files) == null ? void 0 : T[0];
328
- if (e.target.value = "", !!a)
329
- try {
330
- const N = i ? await i(a) : await Ur(a);
331
- c.update(() => ae(G(N, a.name)));
332
- } catch {
333
- Dt.error(n("rte.imageError"));
334
- }
335
- }, Ve = () => ne({
336
- icon: "VideoSquare",
337
- title: n("rte.videoTitle"),
338
- label: n("rte.videoUrl"),
339
- placeholder: n("rte.videoUrlPlaceholder"),
340
- confirmLabel: n("common.insert"),
341
- onConfirm: (e) => {
342
- e && c.update(() => ae(de(e)));
343
- }
344
- }), C = (e, a, T, N, E) => /* @__PURE__ */ r(
345
- R,
346
- {
347
- variant: e ? "filled" : "text",
348
- color: "primary",
349
- size: o,
350
- disabled: t,
351
- "aria-label": a,
352
- "aria-pressed": e,
353
- onMouseDown: (H) => H.preventDefault(),
354
- onClick: T,
355
- children: N
356
- },
357
- E
358
- ), _e = v.startsWith("h") ? v : "paragraph", fe = A || Dr[o];
359
- return /* @__PURE__ */ x(
360
- "div",
361
- {
362
- className: l.toolbar,
363
- role: "toolbar",
364
- "aria-label": n("rte.formatting"),
365
- "aria-orientation": "horizontal",
366
- children: [
367
- /* @__PURE__ */ r(
368
- R,
369
- {
370
- variant: "text",
371
- color: "primary",
372
- size: o,
373
- disabled: t || !ee,
374
- "aria-label": n("rte.undo"),
375
- onMouseDown: (e) => e.preventDefault(),
376
- onClick: () => c.dispatchCommand(Ye, void 0),
377
- children: /* @__PURE__ */ r(u, { name: "UndoArrow" })
378
- }
379
- ),
380
- /* @__PURE__ */ r(
381
- R,
382
- {
383
- variant: "text",
384
- color: "primary",
385
- size: o,
386
- disabled: t || !Ie,
387
- "aria-label": n("rte.redo"),
388
- onMouseDown: (e) => e.preventDefault(),
389
- onClick: () => c.dispatchCommand(et, void 0),
390
- children: /* @__PURE__ */ r(u, { name: "RedoArrow" })
391
- }
392
- ),
393
- /* @__PURE__ */ r(O, { orientation: "vertical" }),
394
- /* @__PURE__ */ r(
395
- ce,
396
- {
397
- size: o,
398
- disabled: t,
399
- minWidth: !1,
400
- trigger: /* @__PURE__ */ r(
401
- V,
402
- {
403
- variant: "text",
404
- color: "primary",
405
- size: o,
406
- disabled: t,
407
- endIcon: /* @__PURE__ */ r(u, { name: "ArrowDown4" }),
408
- "aria-label": n("rte.fontSize"),
409
- onMouseDown: (e) => e.preventDefault(),
410
- children: fe
411
- }
412
- ),
413
- children: Ar.map((e) => /* @__PURE__ */ r(
414
- z,
415
- {
416
- clickable: !0,
417
- selected: e === fe,
418
- onClick: () => Fe(e),
419
- children: e
420
- },
421
- e
422
- ))
423
- }
424
- ),
425
- /* @__PURE__ */ r(O, { orientation: "vertical" }),
426
- /* @__PURE__ */ r(
427
- ce,
428
- {
429
- size: o,
430
- disabled: t,
431
- trigger: /* @__PURE__ */ r(
432
- V,
433
- {
434
- variant: "text",
435
- color: "primary",
436
- size: o,
437
- disabled: t,
438
- endIcon: /* @__PURE__ */ r(u, { name: "ArrowDown4" }),
439
- onMouseDown: (e) => e.preventDefault(),
440
- children: s(_e)
441
- }
442
- ),
443
- children: Or.map((e) => /* @__PURE__ */ r(
444
- z,
445
- {
446
- clickable: !0,
447
- selected: _e === e.type,
448
- icon: e.icon,
449
- onClick: () => B(e.type),
450
- children: s(e.type)
451
- },
452
- e.type
453
- ))
454
- }
455
- ),
456
- /* @__PURE__ */ r(O, { orientation: "vertical" }),
457
- C(y, n("rte.bold"), () => oe("bold"), /* @__PURE__ */ r(u, { name: "TextBold" })),
458
- C(_, n("rte.italic"), () => oe("italic"), /* @__PURE__ */ r(u, { name: "TextItalic" })),
459
- C(
460
- M,
461
- n("rte.underline"),
462
- () => oe("underline"),
463
- /* @__PURE__ */ r(u, { name: "TextUnderline" })
464
- ),
465
- /* @__PURE__ */ r(O, { orientation: "vertical" }),
466
- C(
467
- v === "bullet",
468
- n("rte.bulletList"),
469
- () => B("bullet"),
470
- /* @__PURE__ */ r(u, { name: "ListBullet" })
471
- ),
472
- C(
473
- v === "number",
474
- n("rte.numberedList"),
475
- () => B("number"),
476
- /* @__PURE__ */ r(u, { name: "ListNumber" })
477
- ),
478
- C(v === "quote", n("rte.quote"), $e, /* @__PURE__ */ r(u, { name: "QuoteUp" })),
479
- /* @__PURE__ */ r(O, { orientation: "vertical" }),
480
- Rr.map(
481
- (e) => C(
482
- b === e.value,
483
- n(e.labelKey),
484
- () => Ue(e.value),
485
- /* @__PURE__ */ r(u, { name: e.icon }),
486
- e.value
487
- )
488
- ),
489
- /* @__PURE__ */ r(O, { orientation: "vertical" }),
490
- /* @__PURE__ */ r(
491
- R,
492
- {
493
- ref: S,
494
- variant: "text",
495
- color: "primary",
496
- size: o,
497
- disabled: t,
498
- "aria-label": n("rte.textColor"),
499
- "aria-expanded": F,
500
- onMouseDown: (e) => e.preventDefault(),
501
- onClick: () => $((e) => !e),
502
- children: /* @__PURE__ */ r(Ir, { color: U })
503
- }
504
- ),
505
- /* @__PURE__ */ r(
506
- $t,
507
- {
508
- open: F,
509
- triggerRef: S,
510
- onClose: (e) => {
511
- var a;
512
- $(!1), e && ((a = S.current) == null || a.focus());
513
- },
514
- role: "dialog",
515
- ariaLabel: n("rte.textColor"),
516
- width: 232,
517
- children: /* @__PURE__ */ r(
518
- wt,
519
- {
520
- value: U || Ft[0],
521
- onChange: we,
522
- clearable: !1
523
- }
524
- )
525
- }
526
- ),
527
- C(j, n("rte.link"), He, /* @__PURE__ */ r(u, { name: "Link2" })),
528
- /* @__PURE__ */ x(
529
- ce,
530
- {
531
- size: o,
532
- disabled: t,
533
- minWidth: !1,
534
- trigger: /* @__PURE__ */ r(
535
- R,
536
- {
537
- variant: "text",
538
- color: "primary",
539
- size: o,
540
- disabled: t,
541
- "aria-label": n("rte.insertImage"),
542
- children: /* @__PURE__ */ r(u, { name: "GalleryAdd" })
543
- }
544
- ),
545
- children: [
546
- /* @__PURE__ */ r(z, { clickable: !0, icon: "GalleryImport", onClick: () => {
547
- var e;
548
- return (e = g.current) == null ? void 0 : e.click();
549
- }, children: n("rte.uploadImage") }),
550
- /* @__PURE__ */ r(z, { clickable: !0, icon: "Link", onClick: Pe, children: n("rte.imageByUrl") })
551
- ]
552
- }
553
- ),
554
- /* @__PURE__ */ r(
555
- R,
556
- {
557
- variant: "text",
558
- color: "primary",
559
- size: o,
560
- disabled: t,
561
- "aria-label": n("rte.insertVideo"),
562
- onClick: Ve,
563
- children: /* @__PURE__ */ r(u, { name: "VideoSquare" })
564
- }
565
- ),
566
- /* @__PURE__ */ r(
567
- "input",
568
- {
569
- ref: g,
570
- type: "file",
571
- accept: "image/*",
572
- hidden: !0,
573
- onChange: qe,
574
- "aria-hidden": "true",
575
- tabIndex: -1
576
- }
577
- ),
578
- /* @__PURE__ */ r(
579
- Bt,
580
- {
581
- open: m !== null,
582
- onClose: he,
583
- size: "sm",
584
- icon: m == null ? void 0 : m.icon,
585
- title: m == null ? void 0 : m.title,
586
- footer: /* @__PURE__ */ x(Ge, { children: [
587
- /* @__PURE__ */ r(V, { variant: "text", size: "sm", onClick: he, children: n("common.cancel") }),
588
- /* @__PURE__ */ r(V, { type: "submit", size: "sm", form: "rte-url-form", children: (m == null ? void 0 : m.confirmLabel) ?? n("common.insert") })
589
- ] }),
590
- children: /* @__PURE__ */ r(
591
- "form",
592
- {
593
- id: "rte-url-form",
594
- onSubmit: (e) => {
595
- e.preventDefault(), Be();
596
- },
597
- children: /* @__PURE__ */ r(
598
- Ht,
599
- {
600
- label: m == null ? void 0 : m.label,
601
- placeholder: m == null ? void 0 : m.placeholder,
602
- value: ue,
603
- onChange: (e) => pe(e.target.value)
604
- }
605
- )
606
- }
607
- )
608
- }
609
- )
610
- ]
611
- }
612
- );
613
- }
614
- function Ur(o) {
615
- return new Promise((t, i) => {
616
- const n = new FileReader();
617
- n.onload = () => t(n.result), n.onerror = () => i(n.error), n.readAsDataURL(o);
618
- });
619
- }
620
- const wr = {
621
- paragraph: l.paragraph,
622
- heading: {
623
- h1: l.h1,
624
- h2: l.h2,
625
- h3: l.h3,
626
- h4: l.h4,
627
- h5: l.h5,
628
- h6: l.h6
629
- },
630
- quote: l.quote,
631
- list: {
632
- ul: l.ul,
633
- ol: l.ol,
634
- listitem: l.li,
635
- listitemChecked: l.liChecked,
636
- listitemUnchecked: l.liUnchecked,
637
- nested: { listitem: l.nestedLi }
638
- },
639
- link: l.link,
640
- text: {
641
- bold: l.bold,
642
- italic: l.italic,
643
- underline: l.underline,
644
- strikethrough: l.strike,
645
- code: l.codeInline
646
- }
647
- }, Fr = [
648
- Nt,
649
- Tt,
650
- Re,
651
- kt,
652
- Ae,
653
- K,
654
- J
655
- ], $r = [
656
- ..._t,
657
- ...ft,
658
- ...gt
659
- ];
660
- function Br(o) {
661
- if (typeof document > "u") return o;
662
- const t = document.createElement("template");
663
- return t.innerHTML = o, t.content.querySelectorAll("[class]").forEach((i) => i.removeAttribute("class")), t.innerHTML;
664
- }
665
- function Hr() {
666
- const o = Se(), t = o.getFirstChild();
667
- return o.getChildrenSize() <= 1 && (t === null || it(t) && t.getChildrenSize() === 0);
668
- }
669
- function Ee(o, t) {
670
- const i = Se();
671
- if (i.clear(), t) {
672
- const n = new DOMParser().parseFromString(t, "text/html"), s = Rt(o, n);
673
- i.select(), ot(s);
674
- }
675
- i.getChildrenSize() === 0 && i.append(ke()), nt(null);
676
- }
677
- function Pr({ value: o, defaultValue: t, onChange: i, disabled: n }) {
678
- const [s] = Oe(), c = I(void 0), g = I(i);
679
- return g.current = i, L(() => s.setEditable(!n), [s, n]), L(
680
- () => s.registerNodeTransform(Ae, (y) => {
681
- const d = y.getURL(), _ = me(d);
682
- _ !== d && y.setURL(_);
683
- }),
684
- [s]
685
- ), L(() => {
686
- o !== void 0 || !t || (c.current = t, s.update(() => Ee(s, t), { tag: "history-merge" }));
687
- }, []), L(() => {
688
- o === void 0 || o === c.current || (c.current = o, s.update(() => Ee(s, o), { tag: "history-merge" }));
689
- }, [s, o]), L(
690
- () => s.registerUpdateListener(({ dirtyElements: y, dirtyLeaves: d }) => {
691
- y.size === 0 && d.size === 0 || s.read(() => {
692
- const _ = Hr() ? "" : Br(Ot(s, null));
693
- _ !== c.current && (c.current = _, g.current(_));
694
- });
695
- }),
696
- [s]
697
- ), null;
698
- }
699
- const Lo = Ke(
700
- function({
701
- label: t,
702
- size: i = "md",
703
- error: n,
704
- helperText: s,
705
- required: c = !1,
706
- disabled: g = !1,
707
- placeholder: y,
708
- name: d,
709
- value: _,
710
- defaultValue: Q,
711
- onChange: M,
712
- onImageUpload: W,
713
- minHeight: j = 220,
714
- "aria-label": X = "Rich text editor",
715
- className: Z,
716
- style: Y
717
- }, v) {
718
- const k = se(), b = At(), f = b && d ? b.field(d) : void 0, A = n ?? (f == null ? void 0 : f.error) ?? !1, D = s ?? (f == null ? void 0 : f.helperText), U = b && d ? b.values[d] : void 0, w = _ !== void 0 ? _ : b && d ? String(U ?? "") : void 0, F = Le(
719
- (h) => {
720
- b && d && b.setValue(d, h), M == null || M(h);
721
- },
722
- [b, d, M]
723
- ), $ = (h) => f == null ? void 0 : f.onBlur(h), S = I(null);
724
- L(() => {
725
- const h = S.current;
726
- h && (d ? h.setAttribute("name", d) : h.removeAttribute("name"));
727
- }, [d]);
728
- const ee = {
729
- namespace: "tz-rich-text-editor",
730
- theme: wr,
731
- nodes: Fr,
732
- editable: !g,
733
- onError: (h) => {
734
- throw h;
735
- }
736
- };
737
- return /* @__PURE__ */ x(
738
- "div",
739
- {
740
- ref: v,
741
- className: Je(
742
- l.editor,
743
- l[i],
744
- A && l.error,
745
- g && l.disabled,
746
- Z
747
- ),
748
- style: { "--tz-rte-min-height": `${j}px`, ...Y },
749
- children: [
750
- t != null && /* @__PURE__ */ x("div", { className: l.label, children: [
751
- /* @__PURE__ */ r(ve, { as: "span", variant: "bodySmall", color: "muted", children: t }),
752
- c && /* @__PURE__ */ r("span", { className: l.required, "aria-hidden": "true", children: "*" })
753
- ] }),
754
- /* @__PURE__ */ r("div", { className: l.control, children: /* @__PURE__ */ x(lt, { initialConfig: ee, children: [
755
- /* @__PURE__ */ r(jr, { size: i, disabled: g, onImageUpload: W }),
756
- /* @__PURE__ */ r("div", { className: l.shell, children: /* @__PURE__ */ r(
757
- at,
758
- {
759
- contentEditable: /* @__PURE__ */ r(
760
- ct,
761
- {
762
- ref: S,
763
- className: l.content,
764
- "aria-label": X,
765
- "aria-invalid": A || void 0,
766
- onBlur: $
767
- }
768
- ),
769
- placeholder: /* @__PURE__ */ r("div", { className: l.placeholder, children: y ?? k("rte.placeholder") }),
770
- ErrorBoundary: st
771
- }
772
- ) }),
773
- /* @__PURE__ */ r(mt, {}),
774
- /* @__PURE__ */ r(dt, {}),
775
- /* @__PURE__ */ r(ut, {}),
776
- /* @__PURE__ */ r(pt, {}),
777
- /* @__PURE__ */ r(ht, { transformers: $r }),
778
- /* @__PURE__ */ r(
779
- Pr,
780
- {
781
- value: w,
782
- defaultValue: Q,
783
- onChange: F,
784
- disabled: g
785
- }
786
- )
787
- ] }) }),
788
- D != null && /* @__PURE__ */ r(
789
- ve,
790
- {
791
- as: "span",
792
- variant: "bodySmall",
793
- color: A ? "error" : "muted",
794
- className: l.helper,
795
- children: D
796
- }
797
- )
798
- ]
799
- }
800
- );
801
- }
802
- );
803
- export {
804
- Lo as R
805
- };
806
- //# sourceMappingURL=RichTextEditor-BDAWmQrN.js.map