@pibit.ai/cure-design-system 0.6.48 → 0.6.49

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 (42) hide show
  1. package/dist/_virtual/index.js +2 -3
  2. package/dist/_virtual/index2.js +3 -2
  3. package/dist/node_modules/recharts/es6/util/ReactUtils.js +1 -1
  4. package/dist/node_modules/use-sync-external-store/shim/index.js +1 -1
  5. package/dist/rich-text/index.d.ts +9 -0
  6. package/dist/rich-text/index.d.ts.map +1 -1
  7. package/dist/rich-text/index.js +37 -1
  8. package/dist/rich-text/platform.d.ts +9 -0
  9. package/dist/rich-text/platform.d.ts.map +1 -0
  10. package/dist/rich-text/platform.js +35 -0
  11. package/dist/rich-text/text-editor-button.d.ts +7 -0
  12. package/dist/rich-text/text-editor-button.d.ts.map +1 -0
  13. package/dist/rich-text/text-editor-button.js +33 -0
  14. package/dist/rich-text/text-editor-character-count.d.ts +50 -0
  15. package/dist/rich-text/text-editor-character-count.d.ts.map +1 -0
  16. package/dist/rich-text/text-editor-character-count.js +34 -0
  17. package/dist/rich-text/text-editor-extensions.d.ts +95 -0
  18. package/dist/rich-text/text-editor-extensions.d.ts.map +1 -0
  19. package/dist/rich-text/text-editor-extensions.js +553 -0
  20. package/dist/rich-text/text-editor-heading-refocus.d.ts +21 -0
  21. package/dist/rich-text/text-editor-heading-refocus.d.ts.map +1 -0
  22. package/dist/rich-text/text-editor-heading-refocus.js +24 -0
  23. package/dist/rich-text/text-editor-line-utils.d.ts +8 -0
  24. package/dist/rich-text/text-editor-line-utils.d.ts.map +1 -0
  25. package/dist/rich-text/text-editor-line-utils.js +29 -0
  26. package/dist/rich-text/text-editor-mention.d.ts +32 -0
  27. package/dist/rich-text/text-editor-mention.d.ts.map +1 -0
  28. package/dist/rich-text/text-editor-mention.js +92 -0
  29. package/dist/rich-text/text-editor-shortcuts.d.ts +9 -0
  30. package/dist/rich-text/text-editor-shortcuts.d.ts.map +1 -0
  31. package/dist/rich-text/text-editor-shortcuts.js +6 -0
  32. package/dist/rich-text/text-editor-toolbar.d.ts +15 -0
  33. package/dist/rich-text/text-editor-toolbar.d.ts.map +1 -0
  34. package/dist/rich-text/text-editor-toolbar.js +104 -0
  35. package/dist/rich-text/text-editor-tooltip.d.ts +5 -0
  36. package/dist/rich-text/text-editor-tooltip.d.ts.map +1 -0
  37. package/dist/rich-text/text-editor-tooltip.js +31 -0
  38. package/dist/rich-text/text-editor.d.ts +55 -0
  39. package/dist/rich-text/text-editor.d.ts.map +1 -0
  40. package/dist/rich-text/text-editor.js +324 -0
  41. package/dist/styles/components.css +1 -1
  42. package/package.json +12 -2
@@ -0,0 +1,553 @@
1
+ import { jsx as t, jsxs as S, Fragment as z } from "react/jsx-runtime";
2
+ import { useCallback as f, useState as N, useEffect as B, useRef as L } from "react";
3
+ import { useEditorState as u } from "@tiptap/react";
4
+ import { AlignCenter as w, AlignLeft as U, LeftIndent01 as H, Bold01 as M, Dotpoints01 as q, Type01 as O, Stars02 as P, Heading01 as $, Image01 as K, Italic01 as _, Link01 as j, List as G, Strikethrough01 as X, Underline01 as J } from "@untitledui/icons";
5
+ import { parseColor as F, DialogTrigger as Q, Popover as V, Dialog as W, RadioGroup as Y, Radio as T, ColorSwatch as D, Label as Z, ColorField as ee } from "react-aria-components";
6
+ import { cx as C } from "../utils/cn.js";
7
+ import { useRichTextEditorContext as h } from "./text-editor.js";
8
+ import { isolateCurrentLineAtCursor as I } from "./text-editor-line-utils.js";
9
+ import { EditorButton as g } from "./text-editor-button.js";
10
+ import { armHeadingRefocus as ie } from "./text-editor-heading-refocus.js";
11
+ import { getPlatformShortcutLabel as k } from "./platform.js";
12
+ import { Tooltip as te } from "../primitives/tooltip/tooltip.js";
13
+ import { InputBase as le } from "../primitives/input/input.js";
14
+ import { Select as b } from "../primitives/select/select.js";
15
+ const E = [
16
+ { id: "Inter", label: "Inter" },
17
+ { id: "Comic Sans MS, Comic Sans", label: "Comic Sans" },
18
+ { id: "serif", label: "serif" },
19
+ { id: "monospace", label: "monospace" },
20
+ { id: "cursive", label: "cursive" }
21
+ ], y = [
22
+ { id: "12px", label: "12px" },
23
+ { id: "14px", label: "14px" },
24
+ { id: "16px", label: "16px" },
25
+ { id: "18px", label: "18px" },
26
+ { id: "20px", label: "20px" },
27
+ { id: "22px", label: "22px" },
28
+ { id: "24px", label: "24px" },
29
+ { id: "26px", label: "26px" },
30
+ { id: "28px", label: "28px" },
31
+ { id: "30px", label: "30px" },
32
+ { id: "32px", label: "32px" }
33
+ ], A = [
34
+ "#181D27",
35
+ "#252B37",
36
+ "#414651",
37
+ "#535862",
38
+ "#717680",
39
+ "#A4A7AE",
40
+ "#D5D7DA",
41
+ "#FFFFFF",
42
+ "#079455",
43
+ "#1570EF",
44
+ "#444CE7",
45
+ "#6938EF",
46
+ "#BA24D5",
47
+ "#DD2590",
48
+ "#D92D20",
49
+ "#E04F16"
50
+ ], Ce = ({ className: o }) => {
51
+ const { editor: e, isDisabled: r } = h(), { isBold: l } = u({
52
+ editor: e,
53
+ selector: ({ editor: i }) => ({
54
+ isBold: (i == null ? void 0 : i.isActive("bold")) ?? !1
55
+ })
56
+ }), n = f(() => {
57
+ e.chain().focus().toggleBold().run();
58
+ }, [e]);
59
+ return /* @__PURE__ */ t(
60
+ g,
61
+ {
62
+ "aria-label": `Bold ${k(["meta"], "B")}`,
63
+ isDisabled: r,
64
+ isActive: l,
65
+ onClick: n,
66
+ className: o,
67
+ children: /* @__PURE__ */ t(M, { className: "size-5" })
68
+ }
69
+ );
70
+ }, ke = ({ className: o }) => {
71
+ const { editor: e, isDisabled: r } = h(), { isItalic: l } = u({
72
+ editor: e,
73
+ selector: ({ editor: i }) => ({
74
+ isItalic: (i == null ? void 0 : i.isActive("italic")) ?? !1
75
+ })
76
+ }), n = f(() => {
77
+ e.chain().focus().toggleItalic().run();
78
+ }, [e]);
79
+ return /* @__PURE__ */ t(
80
+ g,
81
+ {
82
+ "aria-label": `Italic ${k(["meta"], "I")}`,
83
+ isDisabled: r,
84
+ isActive: l,
85
+ onClick: n,
86
+ className: o,
87
+ children: /* @__PURE__ */ t(_, { className: "size-5" })
88
+ }
89
+ );
90
+ }, Ae = ({
91
+ className: o
92
+ }) => {
93
+ const { editor: e, isDisabled: r } = h(), { isUnderline: l } = u({
94
+ editor: e,
95
+ selector: ({ editor: i }) => ({
96
+ isUnderline: (i == null ? void 0 : i.isActive("underline")) ?? !1
97
+ })
98
+ }), n = f(() => {
99
+ e.chain().focus().toggleUnderline().run();
100
+ }, [e]);
101
+ return /* @__PURE__ */ t(
102
+ g,
103
+ {
104
+ "aria-label": `Underline ${k(["meta"], "U")}`,
105
+ isDisabled: r,
106
+ isActive: l,
107
+ onClick: n,
108
+ className: o,
109
+ children: /* @__PURE__ */ t(J, { className: "size-5" })
110
+ }
111
+ );
112
+ }, Se = ({
113
+ className: o
114
+ }) => {
115
+ const { editor: e, isDisabled: r } = h(), { isStrikethrough: l } = u({
116
+ editor: e,
117
+ selector: ({ editor: i }) => ({
118
+ isStrikethrough: (i == null ? void 0 : i.isActive("strike")) ?? !1
119
+ })
120
+ }), n = f(() => {
121
+ e.chain().focus().toggleStrike().run();
122
+ }, [e]);
123
+ return /* @__PURE__ */ t(
124
+ g,
125
+ {
126
+ "aria-label": `Strikethrough ${k(["meta", "shift"], "X")}`,
127
+ isDisabled: r,
128
+ isActive: l,
129
+ onClick: n,
130
+ className: o,
131
+ children: /* @__PURE__ */ t(X, { className: "size-5" })
132
+ }
133
+ );
134
+ }, ve = ({
135
+ className: o
136
+ }) => {
137
+ const { editor: e, isDisabled: r, lineBreakMode: l } = h(), { isBulletList: n } = u({
138
+ editor: e,
139
+ selector: ({ editor: a }) => ({
140
+ isBulletList: (a == null ? void 0 : a.isActive("bulletList")) ?? !1
141
+ })
142
+ });
143
+ return /* @__PURE__ */ t(
144
+ g,
145
+ {
146
+ "aria-label": "Bullet list",
147
+ isDisabled: r,
148
+ isActive: n,
149
+ onClick: () => {
150
+ l === "paragraph" && I(e), e.chain().focus().toggleBulletList().run();
151
+ },
152
+ className: o,
153
+ children: /* @__PURE__ */ t(q, { className: "size-5" })
154
+ }
155
+ );
156
+ }, Ne = ({
157
+ className: o
158
+ }) => {
159
+ const { editor: e, isDisabled: r } = h(), { isAlignLeft: l } = u({
160
+ editor: e,
161
+ selector: ({ editor: n }) => ({
162
+ isAlignLeft: (n == null ? void 0 : n.isActive({ textAlign: "left" })) ?? !1
163
+ })
164
+ });
165
+ return /* @__PURE__ */ t(
166
+ g,
167
+ {
168
+ "aria-label": "Left align",
169
+ isDisabled: r,
170
+ isActive: l,
171
+ onClick: () => e.chain().focus().setTextAlign("left").run(),
172
+ className: o,
173
+ children: /* @__PURE__ */ t(U, { className: "size-5" })
174
+ }
175
+ );
176
+ }, Fe = ({
177
+ className: o
178
+ }) => {
179
+ const { editor: e, isDisabled: r } = h(), { isAlignCenter: l } = u({
180
+ editor: e,
181
+ selector: ({ editor: n }) => ({
182
+ isAlignCenter: (n == null ? void 0 : n.isActive({ textAlign: "center" })) ?? !1
183
+ })
184
+ });
185
+ return /* @__PURE__ */ t(
186
+ g,
187
+ {
188
+ "aria-label": "Center align",
189
+ isDisabled: r,
190
+ isActive: l,
191
+ onClick: () => e.chain().focus().setTextAlign("center").run(),
192
+ className: o,
193
+ children: /* @__PURE__ */ t(w, { className: "size-5" })
194
+ }
195
+ );
196
+ }, Le = () => {
197
+ const { isDisabled: o } = h();
198
+ return /* @__PURE__ */ t(g, { "aria-label": "Generate", isDisabled: o, children: /* @__PURE__ */ t(P, { className: "size-5" }) });
199
+ }, Te = ({ className: o }) => {
200
+ const { editor: e, isDisabled: r } = h(), { isLink: l } = u({
201
+ editor: e,
202
+ selector: ({ editor: i }) => ({
203
+ isLink: (i == null ? void 0 : i.isActive("link")) ?? !1
204
+ })
205
+ }), n = f(() => {
206
+ const { from: i, to: a } = e.state.selection, s = i !== a;
207
+ e.isActive("link") && !s && e.chain().focus().extendMarkRange("link").run();
208
+ const m = e.getAttributes("link").href, c = window.prompt("Please enter a link", m);
209
+ if (c !== null) {
210
+ if (c === "") {
211
+ e.isActive("link") && !s ? e.chain().focus().extendMarkRange("link").unsetLink().run() : e.chain().focus().unsetLink().run();
212
+ return;
213
+ }
214
+ e.isActive("link") && !s ? e.chain().focus().extendMarkRange("link").setLink({ href: c }).run() : e.chain().focus().setLink({ href: c }).run();
215
+ }
216
+ }, [e]);
217
+ return /* @__PURE__ */ t(
218
+ g,
219
+ {
220
+ "aria-label": `Link ${k(["meta"], "K")}`,
221
+ isDisabled: r,
222
+ isActive: l,
223
+ onClick: n,
224
+ className: o,
225
+ children: /* @__PURE__ */ t(j, { className: "size-5" })
226
+ }
227
+ );
228
+ }, De = ({ className: o }) => {
229
+ const e = L(null), { editor: r, isDisabled: l } = h(), { isImage: n } = u({
230
+ editor: r,
231
+ selector: ({ editor: s }) => ({
232
+ isImage: (s == null ? void 0 : s.isActive("image")) ?? !1
233
+ })
234
+ }), i = () => {
235
+ e.current && e.current.click();
236
+ }, a = f(
237
+ (s) => {
238
+ var p;
239
+ const m = (p = s.target.files) == null ? void 0 : p[0];
240
+ if (!m) return;
241
+ const c = URL.createObjectURL(m);
242
+ r.chain().focus().setImage({ src: c }).run();
243
+ },
244
+ [r]
245
+ );
246
+ return /* @__PURE__ */ S(z, { children: [
247
+ /* @__PURE__ */ t(
248
+ "input",
249
+ {
250
+ type: "file",
251
+ ref: e,
252
+ className: "hidden",
253
+ onChange: a
254
+ }
255
+ ),
256
+ /* @__PURE__ */ t(
257
+ g,
258
+ {
259
+ "aria-label": "Insert image",
260
+ isDisabled: l,
261
+ isActive: n,
262
+ onClick: i,
263
+ className: o,
264
+ children: /* @__PURE__ */ t(K, { className: "size-5" })
265
+ }
266
+ )
267
+ ] });
268
+ }, Ee = ({ className: o }) => {
269
+ const { editor: e, isDisabled: r } = h(), [l, n] = N(), [i, a] = N(F("#7F56D9")), [s, m] = N(F(A[0]));
270
+ B(() => {
271
+ const d = ({ editor: x }) => {
272
+ n(x.getAttributes("textStyle").color);
273
+ };
274
+ return e.on("selectionUpdate", d), () => {
275
+ e.off("selectionUpdate", d);
276
+ };
277
+ }, [e]);
278
+ const c = (d) => {
279
+ d && (s.toString("hex") === i.toString("hex") && m(d), a(d));
280
+ }, p = f(
281
+ (d) => {
282
+ m(F(d));
283
+ const { from: x, to: v } = e.state.selection, R = x !== v;
284
+ e.getAttributes("textStyle").color && !R ? e.chain().focus().extendMarkRange("textStyle").setColor(d).run() : e.chain().focus().setColor(d).run();
285
+ },
286
+ [e, m]
287
+ );
288
+ return /* @__PURE__ */ S(Q, { children: [
289
+ /* @__PURE__ */ t(te, { title: "Text color", contentClassName: "text-editor-tooltip", children: /* @__PURE__ */ t(
290
+ g,
291
+ {
292
+ "aria-label": "Text color",
293
+ isDisabled: r,
294
+ className: o,
295
+ children: /* @__PURE__ */ t(
296
+ "div",
297
+ {
298
+ style: {
299
+ outlineColor: l || A[0],
300
+ backgroundColor: l || A[0]
301
+ },
302
+ className: "size-4 rounded-full ring-1 ring-black/10 ring-inset in-pressed:outline-[1.5px] in-pressed:outline-offset-2"
303
+ }
304
+ )
305
+ }
306
+ ) }),
307
+ /* @__PURE__ */ t(V, { children: /* @__PURE__ */ t(W, { className: "rounded-xl bg-primary_alt p-3 shadow-lg ring-1 ring-secondary_alt outline-none", children: /* @__PURE__ */ t("div", { className: "flex flex-col gap-3 lg:flex-row lg:items-center", children: /* @__PURE__ */ S(
308
+ Y,
309
+ {
310
+ className: "flex flex-col items-start gap-2",
311
+ value: s == null ? void 0 : s.toString("hex"),
312
+ onChange: p,
313
+ children: [
314
+ /* @__PURE__ */ t("div", { className: "grid grid-cols-8 gap-1", children: A.map((d) => /* @__PURE__ */ t(T, { value: d, className: "p-0.5", children: ({ isSelected: x, isFocused: v }) => /* @__PURE__ */ t(
315
+ D,
316
+ {
317
+ style: {
318
+ outlineColor: d
319
+ },
320
+ color: d,
321
+ className: C(
322
+ "size-4 cursor-pointer rounded-full ring-1 ring-black/10 ring-inset",
323
+ (x || v) && "outline-2 outline-offset-2"
324
+ )
325
+ }
326
+ ) }, d)) }),
327
+ /* @__PURE__ */ S("div", { className: "flex w-full shrink-0 items-center", children: [
328
+ /* @__PURE__ */ t(Z, { className: "mr-3 text-sm font-semibold text-primary", children: "Custom" }),
329
+ /* @__PURE__ */ t(T, { value: i.toString("hex"), children: ({ isSelected: d, isFocused: x }) => /* @__PURE__ */ t(z, { children: /* @__PURE__ */ t(
330
+ D,
331
+ {
332
+ style: {
333
+ outlineColor: i.toString("hex"),
334
+ backgroundColor: i.toString("hex")
335
+ },
336
+ className: C(
337
+ "mr-2 size-4 shrink-0 cursor-pointer rounded-full ring-1 ring-black/10 ring-inset",
338
+ (d || x) && "outline-2 outline-offset-2"
339
+ )
340
+ }
341
+ ) }) }),
342
+ /* @__PURE__ */ t(
343
+ ee,
344
+ {
345
+ "aria-label": "Custom color",
346
+ className: "flex min-w-0 flex-1",
347
+ value: i,
348
+ onChange: c,
349
+ children: /* @__PURE__ */ t(le, { size: "sm", wrapperClassName: "flex-1 w-23 min-w-0" })
350
+ }
351
+ )
352
+ ] })
353
+ ]
354
+ }
355
+ ) }) }) })
356
+ ] });
357
+ }, ye = ({
358
+ className: o
359
+ }) => {
360
+ const { editor: e, isDisabled: r } = h(), { currentFontFamily: l } = u({
361
+ editor: e,
362
+ selector: ({ editor: i }) => {
363
+ var a;
364
+ return {
365
+ currentFontFamily: ((a = i == null ? void 0 : i.getAttributes("textStyle")) == null ? void 0 : a.fontFamily) || E[0].id
366
+ };
367
+ }
368
+ }), n = f(
369
+ (i) => {
370
+ e.chain().focus().setFontFamily(i).run();
371
+ },
372
+ [e]
373
+ );
374
+ return /* @__PURE__ */ t(
375
+ b,
376
+ {
377
+ "aria-label": "Font family",
378
+ size: "sm",
379
+ items: E,
380
+ isDisabled: r,
381
+ className: C("w-full md:w-38", o),
382
+ selectedKey: l,
383
+ placeholderIcon: O,
384
+ onSelectionChange: n,
385
+ children: (i) => /* @__PURE__ */ t(
386
+ b.Item,
387
+ {
388
+ id: i.id,
389
+ style: {
390
+ fontFamily: i.id
391
+ },
392
+ children: i.label
393
+ }
394
+ )
395
+ }
396
+ );
397
+ }, ne = [
398
+ { id: "paragraph", label: "Paragraph" },
399
+ { id: "h1", label: "H1" },
400
+ { id: "h2", label: "H2" },
401
+ { id: "h3", label: "H3" }
402
+ ], ze = ({
403
+ className: o
404
+ }) => {
405
+ const { editor: e, isDisabled: r } = h(), l = L(null), n = L(null);
406
+ B(() => () => {
407
+ var s;
408
+ return (s = l.current) == null ? void 0 : s.call(l);
409
+ }, []);
410
+ const { currentHeading: i } = u({
411
+ editor: e,
412
+ selector: ({ editor: s }) => ({
413
+ currentHeading: s != null && s.isActive("heading", { level: 1 }) ? "h1" : s != null && s.isActive("heading", { level: 2 }) ? "h2" : s != null && s.isActive("heading", { level: 3 }) ? "h3" : "paragraph"
414
+ })
415
+ }), a = f(
416
+ (s) => {
417
+ var m;
418
+ if (!s || s === "paragraph")
419
+ e.chain().focus().setParagraph().run();
420
+ else {
421
+ const c = Number(s.replace("h", ""));
422
+ e.chain().focus().toggleHeading({ level: c }).run();
423
+ }
424
+ (m = l.current) == null || m.call(l), l.current = ie({
425
+ isInList: (c) => c instanceof Element && !!c.closest(".text-editor-heading-listbox"),
426
+ isEditor: (c) => c instanceof Node && !e.isDestroyed && e.view.dom.contains(c),
427
+ isOwnTrigger: (c) => {
428
+ var p;
429
+ return c instanceof Node && !!((p = n.current) != null && p.contains(c));
430
+ },
431
+ refocusEditor: () => {
432
+ !e.isDestroyed && !e.isFocused && e.commands.focus();
433
+ }
434
+ });
435
+ },
436
+ [e]
437
+ );
438
+ return (
439
+ // `contents` keeps layout unchanged; the wrapper only scopes "is this our trigger" checks.
440
+ /* @__PURE__ */ t("div", { ref: n, className: "contents", children: /* @__PURE__ */ t(
441
+ b,
442
+ {
443
+ "aria-label": "Heading",
444
+ size: "sm",
445
+ items: [...ne],
446
+ isDisabled: r,
447
+ className: C("w-full md:w-28", o),
448
+ selectedKey: i,
449
+ placeholderIcon: $,
450
+ listBoxClassName: "text-editor-heading-listbox",
451
+ onSelectionChange: a,
452
+ children: (s) => /* @__PURE__ */ t(b.Item, { id: s.id, children: s.label })
453
+ }
454
+ ) })
455
+ );
456
+ }, Be = ({
457
+ className: o
458
+ }) => {
459
+ const { editor: e, isDisabled: r, lineBreakMode: l } = h(), { isOrderedList: n } = u({
460
+ editor: e,
461
+ selector: ({ editor: a }) => ({
462
+ isOrderedList: (a == null ? void 0 : a.isActive("orderedList")) ?? !1
463
+ })
464
+ });
465
+ return /* @__PURE__ */ t(
466
+ g,
467
+ {
468
+ "aria-label": "Numbered list",
469
+ isDisabled: r,
470
+ isActive: n,
471
+ onClick: () => {
472
+ l === "paragraph" && I(e), e.chain().focus().toggleOrderedList().run();
473
+ },
474
+ className: o,
475
+ children: /* @__PURE__ */ t(G, { className: "size-5" })
476
+ }
477
+ );
478
+ }, Ie = ({
479
+ className: o
480
+ }) => {
481
+ const { editor: e, isDisabled: r } = h(), { isBlockquote: l } = u({
482
+ editor: e,
483
+ selector: ({ editor: n }) => ({
484
+ isBlockquote: (n == null ? void 0 : n.isActive("blockquote")) ?? !1
485
+ })
486
+ });
487
+ return /* @__PURE__ */ t(
488
+ g,
489
+ {
490
+ "aria-label": "Block quote",
491
+ isDisabled: r,
492
+ isActive: l,
493
+ onClick: () => e.chain().focus().toggleBlockquote().run(),
494
+ className: o,
495
+ children: /* @__PURE__ */ t(H, { className: "size-5" })
496
+ }
497
+ );
498
+ }, Re = ({
499
+ className: o
500
+ }) => {
501
+ const { editor: e, isDisabled: r } = h(), { currentFontSize: l } = u({
502
+ editor: e,
503
+ selector: ({ editor: i }) => {
504
+ var a;
505
+ return {
506
+ currentFontSize: ((a = i == null ? void 0 : i.getAttributes("textStyle")) == null ? void 0 : a.fontSize) || y[2].id
507
+ };
508
+ }
509
+ }), n = f(
510
+ (i) => {
511
+ e.chain().focus().setFontSize(i).run();
512
+ },
513
+ [e]
514
+ );
515
+ return /* @__PURE__ */ t(
516
+ b,
517
+ {
518
+ "aria-label": "Font size",
519
+ size: "sm",
520
+ items: y,
521
+ isDisabled: r,
522
+ className: C("w-full md:w-22", o),
523
+ selectedKey: l,
524
+ onSelectionChange: n,
525
+ children: (i) => /* @__PURE__ */ t(
526
+ b.Item,
527
+ {
528
+ id: i.id,
529
+ className: "[&_svg:not([data-icon])]:hidden",
530
+ children: i.label
531
+ }
532
+ )
533
+ }
534
+ );
535
+ };
536
+ export {
537
+ Fe as RichTextEditorAlignCenter,
538
+ Ne as RichTextEditorAlignLeft,
539
+ Ie as RichTextEditorBlockquote,
540
+ Ce as RichTextEditorBold,
541
+ ve as RichTextEditorBulletList,
542
+ Ee as RichTextEditorColor,
543
+ ye as RichTextEditorFontFamily,
544
+ Re as RichTextEditorFontSize,
545
+ Le as RichTextEditorGenerate,
546
+ ze as RichTextEditorHeading,
547
+ De as RichTextEditorImage,
548
+ ke as RichTextEditorItalic,
549
+ Te as RichTextEditorLink,
550
+ Be as RichTextEditorOrderedList,
551
+ Se as RichTextEditorStrikethrough,
552
+ Ae as RichTextEditorUnderline
553
+ };
@@ -0,0 +1,21 @@
1
+ interface HeadingRefocusOptions {
2
+ /** Focus inside the open heading list: still picking, keep waiting. */
3
+ isInList: (target: EventTarget | null) => boolean;
4
+ /** The editor's own focus (tiptap focuses on the next frame); must not disarm the listener. */
5
+ isEditor: (target: EventTarget | null) => boolean;
6
+ /** The heading Select's trigger, where react-aria restores focus once the popover closes. */
7
+ isOwnTrigger: (target: EventTarget | null) => boolean;
8
+ refocusEditor: () => void;
9
+ timeoutMs?: number;
10
+ doc?: Document;
11
+ }
12
+ /**
13
+ * After a heading pick, react-aria restores focus to the Select trigger (its onFocus does not fire
14
+ * for that), so typing would hit the trigger's typeahead and Enter would reopen the menu. Hand focus
15
+ * back to the editor when it lands on the trigger. Focus that goes anywhere else (the user clicked or
16
+ * tabbed away) disarms without redirecting; a timeout covers focus never being restored.
17
+ * Returns a function that disarms the listener.
18
+ */
19
+ export declare function armHeadingRefocus({ isInList, isEditor, isOwnTrigger, refocusEditor, timeoutMs, doc, }: HeadingRefocusOptions): () => void;
20
+ export {};
21
+ //# sourceMappingURL=text-editor-heading-refocus.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text-editor-heading-refocus.d.ts","sourceRoot":"","sources":["../../src/rich-text/text-editor-heading-refocus.ts"],"names":[],"mappings":"AAAA,UAAU,qBAAqB;IAC7B,uEAAuE;IACvE,QAAQ,EAAE,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,KAAK,OAAO,CAAC;IAClD,+FAA+F;IAC/F,QAAQ,EAAE,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,KAAK,OAAO,CAAC;IAClD,6FAA6F;IAC7F,YAAY,EAAE,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,KAAK,OAAO,CAAC;IACtD,aAAa,EAAE,MAAM,IAAI,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,GAAG,CAAC,EAAE,QAAQ,CAAC;CAChB;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,QAAQ,EACR,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,SAAgB,EAChB,GAAc,GACf,EAAE,qBAAqB,GAAG,MAAM,IAAI,CAkBpC"}
@@ -0,0 +1,24 @@
1
+ function m({
2
+ isInList: c,
3
+ isEditor: s,
4
+ isOwnTrigger: i,
5
+ refocusEditor: u,
6
+ timeoutMs: a = 1500,
7
+ doc: e = document
8
+ }) {
9
+ const r = (t) => {
10
+ const o = t.target;
11
+ c(o) || s(o) || (n(), i(o) && u());
12
+ }, f = window.setTimeout(() => {
13
+ n();
14
+ const t = e.activeElement;
15
+ (!t || t === e.body || i(t)) && u();
16
+ }, a);
17
+ function n() {
18
+ e.removeEventListener("focusin", r, !0), window.clearTimeout(f);
19
+ }
20
+ return e.addEventListener("focusin", r, !0), n;
21
+ }
22
+ export {
23
+ m as armHeadingRefocus
24
+ };
@@ -0,0 +1,8 @@
1
+ import { Editor } from '@tiptap/react';
2
+ /**
3
+ * When a paragraph uses hard breaks for line breaks, TipTap's toggleBulletList wraps the whole
4
+ * paragraph. Split at the current line's boundaries so list toggles apply to one line only.
5
+ * Uses standard splitBlock — same as Enter outside lists.
6
+ */
7
+ export declare function isolateCurrentLineAtCursor(editor: Editor): void;
8
+ //# sourceMappingURL=text-editor-line-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text-editor-line-utils.d.ts","sourceRoot":"","sources":["../../src/rich-text/text-editor-line-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAgC5C;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAyC/D"}
@@ -0,0 +1,29 @@
1
+ function p(t, e) {
2
+ let n = 0, r = e.content.size;
3
+ return e.forEach((f, a) => {
4
+ if (f.type.name === "hardBreak") {
5
+ const s = a + f.nodeSize;
6
+ s <= t ? n = s : a >= t && (r = Math.min(r, a));
7
+ }
8
+ }), { lineStartOffset: n, lineEndOffset: r };
9
+ }
10
+ function u(t) {
11
+ const { $from: e } = t.state.selection, n = e.parent;
12
+ if (n.type.name !== "paragraph") return;
13
+ let r = !1;
14
+ if (n.forEach((l) => {
15
+ l.type.name === "hardBreak" && (r = !0);
16
+ }), !r) return;
17
+ const f = e.parentOffset, a = e.start(), { lineStartOffset: s } = p(f, n);
18
+ s > 0 && t.chain().focus().setTextSelection(a + s).splitBlock().run();
19
+ const { $from: i } = t.state.selection, c = i.parent;
20
+ if (c.type.name !== "paragraph") return;
21
+ const { lineEndOffset: o } = p(
22
+ i.parentOffset,
23
+ c
24
+ );
25
+ o < c.content.size && t.chain().focus().setTextSelection(i.start() + o).splitBlock().run();
26
+ }
27
+ export {
28
+ u as isolateCurrentLineAtCursor
29
+ };
@@ -0,0 +1,32 @@
1
+ export interface MentionUser {
2
+ id: string;
3
+ name: string;
4
+ avatar?: string | null;
5
+ }
6
+ interface MentionListProps {
7
+ items: MentionUser[];
8
+ command: (item: {
9
+ id: string;
10
+ label: string;
11
+ }) => void;
12
+ }
13
+ interface MentionListRef {
14
+ onKeyDown: (props: {
15
+ event: KeyboardEvent;
16
+ }) => boolean;
17
+ }
18
+ export declare const MentionList: import('react').ForwardRefExoticComponent<MentionListProps & import('react').RefAttributes<MentionListRef>>;
19
+ /** Getter lets the user list update without recreating the TipTap editor. */
20
+ export declare const createMentionSuggestion: (getUsers: () => MentionUser[]) => {
21
+ items: ({ query }: {
22
+ query: string;
23
+ }) => MentionUser[];
24
+ render: () => {
25
+ onStart: (props: any) => void;
26
+ onUpdate(props: any): void;
27
+ onKeyDown(props: any): boolean;
28
+ onExit(): void;
29
+ };
30
+ };
31
+ export {};
32
+ //# sourceMappingURL=text-editor-mention.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text-editor-mention.d.ts","sourceRoot":"","sources":["../../src/rich-text/text-editor-mention.tsx"],"names":[],"mappings":"AAMA,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB;AAED,UAAU,gBAAgB;IACxB,KAAK,EAAE,WAAW,EAAE,CAAC;IACrB,OAAO,EAAE,CAAC,IAAI,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;CACxD;AAED,UAAU,cAAc;IACtB,SAAS,EAAE,CAAC,KAAK,EAAE;QAAE,KAAK,EAAE,aAAa,CAAA;KAAE,KAAK,OAAO,CAAC;CACzD;AAED,eAAO,MAAM,WAAW,6GAmFvB,CAAC;AAIF,6EAA6E;AAC7E,eAAO,MAAM,uBAAuB,GAAI,UAAU,MAAM,WAAW,EAAE;uBAChD;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE;;yBAUf,GAAG;wBAsBJ,GAAG;yBAYF,GAAG;;;CAexB,CAAC"}