@alfadocs/ui-kit 0.65.0 → 0.67.0

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 (159) hide show
  1. package/dist/_chunks/{agenda-card-Bl-SBiCh.js → agenda-card-BxSFkqgY.js} +2 -2
  2. package/dist/_chunks/{agenda-tray-Bh1KfEOG.js → agenda-tray-T-BumlGZ.js} +2 -2
  3. package/dist/_chunks/{ai-consent-banner-Btzmk8OH.js → ai-consent-banner-Dxtx_WAh.js} +2 -2
  4. package/dist/_chunks/{ai-tools-rail-JnlTqfS4.js → ai-tools-rail-DfmewPUN.js} +92 -76
  5. package/dist/_chunks/{alia-sidebar-CN8pA6c-.js → alia-sidebar-Ckv0yCKi.js} +2 -2
  6. package/dist/_chunks/{anamnesis-card-qeLYRG79.js → anamnesis-card-N8pIKWuS.js} +2 -2
  7. package/dist/_chunks/{antenatal-schedule-timeline-BfzFjEyb.js → antenatal-schedule-timeline-35ebkcZT.js} +2 -2
  8. package/dist/_chunks/{appointment-tray-BQnJEora.js → appointment-tray-CQJ3Nbi5.js} +4 -4
  9. package/dist/_chunks/{badge-zsf5i5bH.js → badge-CqGsX32l.js} +46 -42
  10. package/dist/_chunks/{bishop-score-x2fNqbuZ.js → bishop-score-CjsB9bM-.js} +3 -3
  11. package/dist/_chunks/{bmi-calculator-C3roxbqD.js → bmi-calculator-n-823_1V.js} +3 -3
  12. package/dist/_chunks/{care-plan-card-D42WD4-T.js → care-plan-card-CJei-nl9.js} +4 -4
  13. package/dist/_chunks/{care-plan-entry-card-BukNI7Uy.js → care-plan-entry-card-EmfrbHu8.js} +4 -4
  14. package/dist/_chunks/{clinical-note-card-BYo437dU.js → clinical-note-card-gtrxv6zn.js} +2 -2
  15. package/dist/_chunks/{color-picker-9tL7pz5y.js → color-picker-B7xsn6tX.js} +186 -167
  16. package/dist/_chunks/columns-2-BTOBZbep.js +15 -0
  17. package/dist/_chunks/{contact-profile-card-CCeJmjbd.js → contact-profile-card-7BMB85T6.js} +2 -2
  18. package/dist/_chunks/{cycle-calculator-DrVXbIB4.js → cycle-calculator-BF0ointe.js} +3 -3
  19. package/dist/_chunks/{dependent-selector-CRWgieHm.js → dependent-selector-DpzGtr_J.js} +2 -2
  20. package/dist/_chunks/{document-scanner-biBS_f6c.js → document-scanner-D2qehl3-.js} +53 -53
  21. package/dist/_chunks/{due-date-calculator-D4K1BnE2.js → due-date-calculator-DU9AEWNy.js} +4 -4
  22. package/dist/_chunks/{editable-currency-cell-renderer-CFqQc56y.js → editable-currency-cell-renderer-BVJ04DkB.js} +914 -865
  23. package/dist/_chunks/{fetal-weight-B_pBjlO7.js → fetal-weight-BVSzOhuR.js} +3 -3
  24. package/dist/_chunks/{gestational-age-calculator-BETQAVkA.js → gestational-age-calculator-DBlFdoiP.js} +4 -4
  25. package/dist/_chunks/{hcg-doubling-8zXCJgAQ.js → hcg-doubling-if4Q8aSX.js} +3 -3
  26. package/dist/_chunks/{type-DZ5OMRA2.js → image-C6RM5hfF.js} +4 -16
  27. package/dist/_chunks/{insert-result-DIAG3ltJ.js → insert-result-njqBthzT.js} +68 -57
  28. package/dist/_chunks/{marketplace-app-shell-BXfRMiRk.js → marketplace-app-shell-Bu-HD3fy.js} +3 -3
  29. package/dist/_chunks/{message-card-Bgcvfj6-.js → message-card-Bx4GmLvf.js} +9 -9
  30. package/dist/_chunks/{message-tray-saAVMeHP.js → message-tray-CVyJajVJ.js} +2 -2
  31. package/dist/_chunks/{operator-hero-CM8949Hd.js → operator-hero-f_KaRhw5.js} +2 -2
  32. package/dist/_chunks/{patient-search-Bw9ONucF.js → patient-search-DR9XUYRQ.js} +2 -2
  33. package/dist/_chunks/{patient-shell-CF_qon7C.js → patient-shell-DrV_iekt.js} +2 -2
  34. package/dist/_chunks/{patient-summary-card-Bgso0p_l.js → patient-summary-card-ByfIU8N0.js} +4 -4
  35. package/dist/_chunks/{payment-request-card-DBz3hVDz.js → payment-request-card-yTjzKQCU.js} +3 -3
  36. package/dist/_chunks/{periodontal-chart-card-AYyHtU9K.js → periodontal-chart-card-Dh3KgvYG.js} +2 -2
  37. package/dist/_chunks/{practice-results-CVAgY2RZ.js → practice-results-DND2SAt7.js} +2 -2
  38. package/dist/_chunks/{pregnancy-dating-BuzLTwjy.js → pregnancy-dating-QY-sqpvj.js} +4 -4
  39. package/dist/_chunks/{pregnancy-weight-gain-aicn7qs7.js → pregnancy-weight-gain-DOJXXNYP.js} +3 -3
  40. package/dist/_chunks/rich-text-editor-BOQr5lHx.js +1970 -0
  41. package/dist/_chunks/{scroll-area-BWqCkEGz.js → scroll-area-eccd_Uf-.js} +38 -28
  42. package/dist/_chunks/{sidebar-DPEHzxLZ.js → sidebar-CGjIk_FQ.js} +36 -22
  43. package/dist/_chunks/{suggestion-chip-C4kxWUIs.js → suggestion-chip-Bk4PmYTg.js} +30 -30
  44. package/dist/_chunks/{tab-bar-Xetknddo.js → tab-bar-B1ovILzh.js} +2 -2
  45. package/dist/_chunks/{tag-CdA0s_VV.js → tag-BQXwuJq1.js} +41 -38
  46. package/dist/_chunks/{transaction-chip-BZCa6XDn.js → transaction-chip-BrW8P50O.js} +19 -19
  47. package/dist/_chunks/trash-2-rPAKaRgB.js +18 -0
  48. package/dist/_chunks/{unit-converter-CHN2cZ4b.js → unit-converter-C1V3ACM9.js} +2 -2
  49. package/dist/_chunks/{workflow-map-BX3JY1Bu.js → workflow-map-JAZryZJr.js} +137 -149
  50. package/dist/agent-catalog.json +1 -1
  51. package/dist/components/agenda-card/index.js +1 -1
  52. package/dist/components/agenda-tray/index.js +1 -1
  53. package/dist/components/ai-consent-banner/index.js +1 -1
  54. package/dist/components/ai-tools-rail/index.js +1 -1
  55. package/dist/components/anamnesis-card/index.js +1 -1
  56. package/dist/components/appointment-card/index.js +1 -1
  57. package/dist/components/badge/index.js +1 -1
  58. package/dist/components/bishop-score/index.js +1 -1
  59. package/dist/components/bmi-calculator/index.js +1 -1
  60. package/dist/components/care-plan-card/index.js +1 -1
  61. package/dist/components/care-plan-entry-card/index.js +1 -1
  62. package/dist/components/clinical-note-card/index.js +1 -1
  63. package/dist/components/color-picker/index.js +1 -1
  64. package/dist/components/contact-profile-card/index.js +1 -1
  65. package/dist/components/cycle-calculator/index.js +1 -1
  66. package/dist/components/data-table/cell-renderers/actions-cell-renderer.d.ts +16 -0
  67. package/dist/components/data-table/cell-renderers/tooth-cell-renderer.d.ts +12 -0
  68. package/dist/components/data-table/data-table.d.ts +1 -1
  69. package/dist/components/data-table/index.d.ts +2 -0
  70. package/dist/components/data-table/index.js +13 -12
  71. package/dist/components/data-table/toolbar.d.ts +5 -1
  72. package/dist/components/dependent-selector/index.js +1 -1
  73. package/dist/components/document-scanner/index.js +1 -1
  74. package/dist/components/due-date-calculator/index.js +2 -2
  75. package/dist/components/fetal-weight/index.js +1 -1
  76. package/dist/components/gestational-age-calculator/index.js +1 -1
  77. package/dist/components/hcg-doubling/index.js +1 -1
  78. package/dist/components/message-card/index.js +1 -1
  79. package/dist/components/message-tray/index.js +1 -1
  80. package/dist/components/operator-hero/index.js +1 -1
  81. package/dist/components/patient-search/index.js +1 -1
  82. package/dist/components/patient-summary-card/index.js +1 -1
  83. package/dist/components/payment-card/index.js +1 -1
  84. package/dist/components/periodontal-chart-card/index.js +1 -1
  85. package/dist/components/practice-results/index.js +1 -1
  86. package/dist/components/pregnancy-dating/index.js +1 -1
  87. package/dist/components/pregnancy-weight-gain/index.js +1 -1
  88. package/dist/components/rich-text-editor/editor-toolbar.d.ts +36 -2
  89. package/dist/components/rich-text-editor/index.js +1 -1
  90. package/dist/components/rich-text-editor/rich-text-editor.d.ts +2 -0
  91. package/dist/components/scroll-area/index.js +1 -1
  92. package/dist/components/sidebar/index.js +1 -1
  93. package/dist/components/suggestion-chip/index.js +1 -1
  94. package/dist/components/tab-bar/index.js +1 -1
  95. package/dist/components/tag/index.js +1 -1
  96. package/dist/components/transaction-chip/index.js +1 -1
  97. package/dist/components/unit-converter/index.js +1 -1
  98. package/dist/components/workflow/index.js +1 -1
  99. package/dist/i18n/locales/ar.d.ts +26 -0
  100. package/dist/i18n/locales/ar.js +27 -1
  101. package/dist/i18n/locales/de.d.ts +26 -0
  102. package/dist/i18n/locales/de.js +27 -1
  103. package/dist/i18n/locales/el.d.ts +26 -0
  104. package/dist/i18n/locales/el.js +27 -1
  105. package/dist/i18n/locales/en.d.ts +26 -0
  106. package/dist/i18n/locales/en.js +27 -1
  107. package/dist/i18n/locales/es.d.ts +26 -0
  108. package/dist/i18n/locales/es.js +27 -1
  109. package/dist/i18n/locales/fr.d.ts +26 -0
  110. package/dist/i18n/locales/fr.js +27 -1
  111. package/dist/i18n/locales/hi.d.ts +26 -0
  112. package/dist/i18n/locales/hi.js +27 -1
  113. package/dist/i18n/locales/it.d.ts +26 -0
  114. package/dist/i18n/locales/it.js +27 -1
  115. package/dist/i18n/locales/ja.d.ts +26 -0
  116. package/dist/i18n/locales/ja.js +27 -1
  117. package/dist/i18n/locales/nl.d.ts +26 -0
  118. package/dist/i18n/locales/nl.js +25 -1
  119. package/dist/i18n/locales/pl.d.ts +26 -0
  120. package/dist/i18n/locales/pl.js +27 -1
  121. package/dist/i18n/locales/pt.d.ts +26 -0
  122. package/dist/i18n/locales/pt.js +27 -1
  123. package/dist/i18n/locales/ro.d.ts +26 -0
  124. package/dist/i18n/locales/ro.js +27 -1
  125. package/dist/i18n/locales/ru.d.ts +26 -0
  126. package/dist/i18n/locales/ru.js +27 -1
  127. package/dist/i18n/locales/sq.d.ts +26 -0
  128. package/dist/i18n/locales/sq.js +27 -1
  129. package/dist/i18n/locales/sv.d.ts +26 -0
  130. package/dist/i18n/locales/sv.js +25 -1
  131. package/dist/i18n/locales/tr.d.ts +26 -0
  132. package/dist/i18n/locales/tr.js +27 -1
  133. package/dist/i18n/locales/zh.d.ts +26 -0
  134. package/dist/i18n/locales/zh.js +25 -1
  135. package/dist/index.js +509 -508
  136. package/dist/locales/ar.json +27 -1
  137. package/dist/locales/de.json +27 -1
  138. package/dist/locales/el.json +27 -1
  139. package/dist/locales/en.json +27 -1
  140. package/dist/locales/es.json +27 -1
  141. package/dist/locales/fr.json +27 -1
  142. package/dist/locales/hi.json +27 -1
  143. package/dist/locales/it.json +27 -1
  144. package/dist/locales/ja.json +27 -1
  145. package/dist/locales/nl.json +27 -1
  146. package/dist/locales/pl.json +27 -1
  147. package/dist/locales/pt.json +27 -1
  148. package/dist/locales/ro.json +27 -1
  149. package/dist/locales/ru.json +27 -1
  150. package/dist/locales/sq.json +27 -1
  151. package/dist/locales/sv.json +27 -1
  152. package/dist/locales/tr.json +27 -1
  153. package/dist/locales/zh.json +27 -1
  154. package/dist/patterns/alia-assistant/index.js +1 -1
  155. package/dist/patterns/marketplace-app-shell/index.js +1 -1
  156. package/dist/patterns/patient-shell/index.js +1 -1
  157. package/dist/tokens.css +6 -3
  158. package/package.json +1 -1
  159. package/dist/_chunks/rich-text-editor-u36FqSWz.js +0 -1190
@@ -1,1190 +0,0 @@
1
- import { jsx as e, jsxs as w, Fragment as Pe } from "react/jsx-runtime";
2
- import { useId as he, useState as _, useRef as x, useCallback as f, useEffect as P, forwardRef as De, useMemo as Se, useImperativeHandle as Be } from "react";
3
- import { c as ke } from "./index-D2ZczOXr.js";
4
- import { useTranslation as xe } from "react-i18next";
5
- import { SafeHtml as Ve, sanitiseHtml as Fe } from "../safe-html/index.js";
6
- import { u as We } from "./registry-nPAVE19X.js";
7
- import { I } from "./icon-button-LqoiKcUN.js";
8
- import { S as Ge } from "./spinner-hbwuKwMf.js";
9
- import { T as Qe } from "./text-area-BIx0tZ05.js";
10
- import { E as Ze } from "./editor-overlay-wYm22wZK.js";
11
- import { R as Je } from "./rotate-ccw-BWANpitO.js";
12
- import { C as Xe } from "./check-DPdL_Sm7.js";
13
- import { S as pe } from "./square-CZoGU14v.js";
14
- import { M as ve } from "./mic-B4Gog3Gi.js";
15
- import { S as Ye } from "./send-CySZIRPJ.js";
16
- import { S as ye } from "./sparkles-CuYXqQLg.js";
17
- import { P as me } from "./popover-DTbfAuR0.js";
18
- import { D as A } from "./dropdown-menu-DwwPovMZ.js";
19
- import { T as Ue, I as Ke } from "./type-DZ5OMRA2.js";
20
- import { c as C } from "./createLucideIcon-CrFbzy84.js";
21
- /**
22
- * @license lucide-react v1.8.0 - ISC
23
- *
24
- * This source code is licensed under the ISC license.
25
- * See the LICENSE file in the root directory of this source tree.
26
- */
27
- const et = [
28
- [
29
- "path",
30
- { d: "M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8", key: "mg9rjx" }
31
- ]
32
- ], tt = C("bold", et);
33
- /**
34
- * @license lucide-react v1.8.0 - ISC
35
- *
36
- * This source code is licensed under the ISC license.
37
- * See the LICENSE file in the root directory of this source tree.
38
- */
39
- const rt = [
40
- ["path", { d: "M4 12h8", key: "17cfdx" }],
41
- ["path", { d: "M4 18V6", key: "1rz3zl" }],
42
- ["path", { d: "M12 18V6", key: "zqpxq5" }],
43
- ["path", { d: "M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1", key: "9jr5yi" }]
44
- ], ot = C("heading-2", rt);
45
- /**
46
- * @license lucide-react v1.8.0 - ISC
47
- *
48
- * This source code is licensed under the ISC license.
49
- * See the LICENSE file in the root directory of this source tree.
50
- */
51
- const at = [
52
- ["path", { d: "M4 12h8", key: "17cfdx" }],
53
- ["path", { d: "M4 18V6", key: "1rz3zl" }],
54
- ["path", { d: "M12 18V6", key: "zqpxq5" }],
55
- ["path", { d: "M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2", key: "68ncm8" }],
56
- ["path", { d: "M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2", key: "1ejuhz" }]
57
- ], nt = C("heading-3", at);
58
- /**
59
- * @license lucide-react v1.8.0 - ISC
60
- *
61
- * This source code is licensed under the ISC license.
62
- * See the LICENSE file in the root directory of this source tree.
63
- */
64
- const it = [
65
- ["line", { x1: "19", x2: "10", y1: "4", y2: "4", key: "15jd3p" }],
66
- ["line", { x1: "14", x2: "5", y1: "20", y2: "20", key: "bu0au3" }],
67
- ["line", { x1: "15", x2: "9", y1: "4", y2: "20", key: "uljnxc" }]
68
- ], lt = C("italic", it);
69
- /**
70
- * @license lucide-react v1.8.0 - ISC
71
- *
72
- * This source code is licensed under the ISC license.
73
- * See the LICENSE file in the root directory of this source tree.
74
- */
75
- const st = [
76
- ["path", { d: "M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71", key: "1cjeqo" }],
77
- ["path", { d: "M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71", key: "19qd67" }]
78
- ], dt = C("link", st);
79
- /**
80
- * @license lucide-react v1.8.0 - ISC
81
- *
82
- * This source code is licensed under the ISC license.
83
- * See the LICENSE file in the root directory of this source tree.
84
- */
85
- const ct = [
86
- ["path", { d: "M11 5h10", key: "1cz7ny" }],
87
- ["path", { d: "M11 12h10", key: "1438ji" }],
88
- ["path", { d: "M11 19h10", key: "11t30w" }],
89
- ["path", { d: "M4 4h1v5", key: "10yrso" }],
90
- ["path", { d: "M4 9h2", key: "r1h2o0" }],
91
- ["path", { d: "M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02", key: "xtkcd5" }]
92
- ], ut = C("list-ordered", ct);
93
- /**
94
- * @license lucide-react v1.8.0 - ISC
95
- *
96
- * This source code is licensed under the ISC license.
97
- * See the LICENSE file in the root directory of this source tree.
98
- */
99
- const mt = [
100
- ["path", { d: "M3 5h.01", key: "18ugdj" }],
101
- ["path", { d: "M3 12h.01", key: "nlz23k" }],
102
- ["path", { d: "M3 19h.01", key: "noohij" }],
103
- ["path", { d: "M8 5h13", key: "1pao27" }],
104
- ["path", { d: "M8 12h13", key: "1za7za" }],
105
- ["path", { d: "M8 19h13", key: "m83p4d" }]
106
- ], ft = C("list", mt);
107
- /**
108
- * @license lucide-react v1.8.0 - ISC
109
- *
110
- * This source code is licensed under the ISC license.
111
- * See the LICENSE file in the root directory of this source tree.
112
- */
113
- const gt = [["path", { d: "M5 12h14", key: "1ays0h" }]], bt = C("minus", gt);
114
- /**
115
- * @license lucide-react v1.8.0 - ISC
116
- *
117
- * This source code is licensed under the ISC license.
118
- * See the LICENSE file in the root directory of this source tree.
119
- */
120
- const ht = [
121
- [
122
- "path",
123
- {
124
- d: "M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",
125
- key: "e79jfc"
126
- }
127
- ],
128
- ["circle", { cx: "13.5", cy: "6.5", r: ".5", fill: "currentColor", key: "1okk4w" }],
129
- ["circle", { cx: "17.5", cy: "10.5", r: ".5", fill: "currentColor", key: "f64h9f" }],
130
- ["circle", { cx: "6.5", cy: "12.5", r: ".5", fill: "currentColor", key: "qy21gx" }],
131
- ["circle", { cx: "8.5", cy: "7.5", r: ".5", fill: "currentColor", key: "fotxhn" }]
132
- ], pt = C("palette", ht);
133
- /**
134
- * @license lucide-react v1.8.0 - ISC
135
- *
136
- * This source code is licensed under the ISC license.
137
- * See the LICENSE file in the root directory of this source tree.
138
- */
139
- const vt = [
140
- ["path", { d: "M13 4v16", key: "8vvj80" }],
141
- ["path", { d: "M17 4v16", key: "7dpous" }],
142
- ["path", { d: "M19 4H9.5a4.5 4.5 0 0 0 0 9H13", key: "sh4n9v" }]
143
- ], yt = C("pilcrow", vt);
144
- /**
145
- * @license lucide-react v1.8.0 - ISC
146
- *
147
- * This source code is licensed under the ISC license.
148
- * See the LICENSE file in the root directory of this source tree.
149
- */
150
- const kt = [
151
- [
152
- "path",
153
- {
154
- d: "M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",
155
- key: "rib7q0"
156
- }
157
- ],
158
- [
159
- "path",
160
- {
161
- d: "M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",
162
- key: "1ymkrd"
163
- }
164
- ]
165
- ], xt = C("quote", kt);
166
- /**
167
- * @license lucide-react v1.8.0 - ISC
168
- *
169
- * This source code is licensed under the ISC license.
170
- * See the LICENSE file in the root directory of this source tree.
171
- */
172
- const wt = [
173
- ["path", { d: "M16 4H9a3 3 0 0 0-2.83 4", key: "43sutm" }],
174
- ["path", { d: "M14 12a4 4 0 0 1 0 8H6", key: "nlfj13" }],
175
- ["line", { x1: "4", x2: "20", y1: "12", y2: "12", key: "1e0a9i" }]
176
- ], Ct = C("strikethrough", wt);
177
- /**
178
- * @license lucide-react v1.8.0 - ISC
179
- *
180
- * This source code is licensed under the ISC license.
181
- * See the LICENSE file in the root directory of this source tree.
182
- */
183
- const Mt = [
184
- ["path", { d: "M12 3v18", key: "108xh3" }],
185
- ["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", key: "afitv7" }],
186
- ["path", { d: "M3 9h18", key: "1pudct" }],
187
- ["path", { d: "M3 15h18", key: "5xshup" }]
188
- ], zt = C("table", Mt), Nt = {
189
- id: "rich-text-editor",
190
- capabilities: ["edit_inline"],
191
- state: {
192
- html: {
193
- type: "string",
194
- description: "Sanitised HTML representation of the editor content.",
195
- read: (o) => o.getHTML()
196
- },
197
- text: {
198
- type: "string",
199
- description: "Plain-text content of the editor (tags stripped).",
200
- read: (o) => o.getText()
201
- },
202
- markdown: {
203
- type: "string",
204
- description: "Markdown representation of the editor content. The Redactor engine has no native Markdown serialiser, so this is always empty — read `html` instead.",
205
- read: (o) => o.getMarkdown()
206
- }
207
- },
208
- actions: {
209
- set_content: {
210
- safety: "destructive",
211
- argsType: "{ html: string }",
212
- description: "Replace the editor content. Loses unsaved input.",
213
- invoke: (o, n) => {
214
- o.setContent(n.html);
215
- }
216
- },
217
- insert_at_cursor: {
218
- safety: "destructive",
219
- argsType: "{ content: string; asHtml?: boolean }",
220
- description: "Insert content at the caret (replacing any selection). HTML is sanitised; pass asHtml:false for plain text. Seam for merge/template variables and AI-generated drafts.",
221
- invoke: (o, n) => {
222
- o.insertAtCursor(n.content, { asHtml: n.asHtml });
223
- }
224
- },
225
- apply_format: {
226
- safety: "destructive",
227
- argsType: "{ format: 'bold' | 'italic' | 'strikethrough' | 'bulletedList' | 'numberedList' | 'heading' | 'quote' | 'paragraph' }",
228
- description: "Toggle/apply a block or inline format on the current selection (bold, italic, strikethrough, bulleted/numbered list, heading, quote, paragraph).",
229
- invoke: (o, n) => {
230
- o.applyFormat(n.format);
231
- }
232
- },
233
- clear: {
234
- safety: "destructive",
235
- description: "Empty the editor. Loses unsaved input.",
236
- invoke: (o) => {
237
- o.clear();
238
- }
239
- },
240
- focus: {
241
- safety: "read",
242
- description: "Move keyboard focus to the editor surface.",
243
- invoke: (o) => {
244
- o.focus();
245
- }
246
- }
247
- },
248
- domHooks: {
249
- root: { attr: "data-component", value: "rich-text-editor" },
250
- instanceId: {
251
- attr: "data-component-id",
252
- sourceProp: "id",
253
- description: "Sourced from the id prop."
254
- }
255
- }
256
- }, Rt = "ds:aria-pressed:!bg-[var(--destructive)] ds:aria-pressed:!text-[var(--destructive-foreground)]", St = "ds:text-[length:var(--font-size-sm)] ds:text-[color:var(--muted-foreground)]", Tt = "ds:text-[length:var(--font-size-sm)] ds:text-[color:var(--destructive)]", Te = [
257
- "ds:rounded-[var(--radius-md)] ds:border ds:border-[color:var(--border)]",
258
- "ds:bg-[color-mix(in_srgb,var(--background)_70%,transparent)]",
259
- "ds:p-[var(--spacing-sm)] ds:[max-block-size:10rem] ds:overflow-y-auto",
260
- "ds:text-[length:var(--font-size-sm)] ds:text-[color:var(--foreground)]"
261
- ].join(" ");
262
- function _e(o, n) {
263
- return n ? o ? /\s$/.test(o) ? `${o}${n}` : `${o} ${n}` : n : o;
264
- }
265
- function _t({
266
- open: o,
267
- onClose: n,
268
- onRequestAiDraft: g,
269
- onInsert: L,
270
- previewAsHtml: Q = !0,
271
- privacyNotice: j,
272
- onDictate: l
273
- }) {
274
- const { t: b } = xe(), R = he(), s = he(), [h, p] = _(""), [k, Z] = _(!1), [D, B] = _(!1), [S, J] = _(null), V = x(null), [u, ne] = _(!1), [M, F] = _(""), E = x(null), W = f(() => {
275
- var i;
276
- (i = E.current) == null || i.abort();
277
- }, []), m = f(() => {
278
- if (!l) return;
279
- const i = new AbortController();
280
- E.current = i, ne(!0), F(""), l({
281
- signal: i.signal,
282
- onPartialTranscript: (d) => {
283
- i.signal.aborted || F(d);
284
- },
285
- onFinalTranscript: (d) => {
286
- if (i.signal.aborted) return;
287
- const G = d.trim();
288
- F(""), G && p((N) => _e(N, G));
289
- }
290
- }).catch(() => {
291
- }).finally(() => {
292
- F(""), E.current === i && (E.current = null, ne(!1));
293
- });
294
- }, [l]), z = f(() => {
295
- u ? W() : m();
296
- }, [u, m, W]);
297
- P(() => {
298
- var i, d;
299
- o ? (p(""), Z(!1), B(!1), J(null), F("")) : ((i = V.current) == null || i.abort(), V.current = null, (d = E.current) == null || d.abort());
300
- }, [o]), P(
301
- () => () => {
302
- var i, d;
303
- (i = V.current) == null || i.abort(), (d = E.current) == null || d.abort();
304
- },
305
- []
306
- );
307
- const $ = f(() => {
308
- var G;
309
- const i = h.trim();
310
- if (!i || k) return;
311
- W(), (G = V.current) == null || G.abort();
312
- const d = new AbortController();
313
- V.current = d, B(!1), Z(!0), g({ prompt: i, signal: d.signal }).then((N) => {
314
- d.signal.aborted || (J(N), Z(!1));
315
- }).catch((N) => {
316
- d.signal.aborted || N && typeof N == "object" && "name" in N && N.name === "AbortError" || (B(!0), Z(!1));
317
- });
318
- }, [h, k, g, W]), U = f(() => {
319
- S != null && (L(S), n());
320
- }, [S, L, n]), ie = S != null, K = u ? _e(h, M) : h;
321
- return /* @__PURE__ */ e(
322
- Ze,
323
- {
324
- open: o,
325
- onClose: n,
326
- title: /* @__PURE__ */ w("span", { className: "ds:inline-flex ds:items-center ds:gap-[var(--spacing-xs)]", children: [
327
- /* @__PURE__ */ e(ye, { "aria-hidden": "true", className: "ds:size-4" }),
328
- b("editor.ai.dialogTitle")
329
- ] }),
330
- ariaLabel: b("editor.ai.dialogTitle"),
331
- children: ie ? /* @__PURE__ */ w("div", { className: "ds:flex ds:items-end ds:gap-[var(--spacing-xs)]", children: [
332
- /* @__PURE__ */ e("div", { className: "ds:min-w-0 ds:flex-1", children: Q ? /* @__PURE__ */ e(
333
- Ve,
334
- {
335
- html: S,
336
- profile: "rich-text",
337
- className: Te,
338
- tabIndex: 0,
339
- "aria-label": b("editor.ai.dialogTitle")
340
- }
341
- ) : (
342
- // Focusable so a keyboard user can scroll a long draft preview
343
- // (mirrors the SafeHtml preview branch above). The lint rule's
344
- // tabIndex allowlist doesn't cover a scrollable, non-interactive
345
- // text region.
346
- // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
347
- /* @__PURE__ */ e("p", { className: Te, tabIndex: 0, children: S })
348
- ) }),
349
- /* @__PURE__ */ e(
350
- I,
351
- {
352
- size: "sm",
353
- intent: "ghost",
354
- className: "ds:rounded-full",
355
- icon: /* @__PURE__ */ e(Je, {}),
356
- "aria-label": b("editor.ai.retry"),
357
- onClick: () => J(null)
358
- }
359
- ),
360
- /* @__PURE__ */ e(
361
- I,
362
- {
363
- size: "sm",
364
- intent: "primary",
365
- className: "ds:rounded-full",
366
- icon: /* @__PURE__ */ e(Xe, {}),
367
- "aria-label": b("common.confirm"),
368
- onClick: U
369
- }
370
- )
371
- ] }) : /* @__PURE__ */ w(Pe, { children: [
372
- /* @__PURE__ */ w("div", { className: "ds:flex ds:items-end ds:gap-[var(--spacing-xs)]", children: [
373
- /* @__PURE__ */ e("div", { className: "ds:min-w-0 ds:flex-1", children: /* @__PURE__ */ e(
374
- Qe,
375
- {
376
- id: R,
377
- size: "md",
378
- value: K,
379
- onChange: (i) => p(i.target.value),
380
- placeholder: b("editor.ai.promptPlaceholder"),
381
- "aria-label": b("editor.ai.promptLabel"),
382
- autoResize: !0,
383
- minRows: 1,
384
- maxRows: 3,
385
- readOnly: u,
386
- tone: D ? "error" : "default",
387
- "aria-describedby": D ? s : void 0
388
- }
389
- ) }),
390
- l ? /* @__PURE__ */ e(
391
- I,
392
- {
393
- size: "sm",
394
- intent: "ghost",
395
- className: u ? Rt : void 0,
396
- icon: u ? /* @__PURE__ */ e(pe, { className: "ds:fill-current" }) : /* @__PURE__ */ e(ve, {}),
397
- "aria-pressed": u,
398
- "aria-label": b(u ? "editor.ai.dictateStop" : "editor.ai.dictateStart"),
399
- onClick: z
400
- }
401
- ) : null,
402
- /* @__PURE__ */ e(
403
- I,
404
- {
405
- size: "sm",
406
- intent: "primary",
407
- icon: k ? /* @__PURE__ */ e(Ge, { size: "sm", variant: "pulse" }) : /* @__PURE__ */ e(Ye, {}),
408
- className: "ds:rounded-full",
409
- disabled: k || !h.trim(),
410
- "aria-busy": k || void 0,
411
- "aria-label": b("editor.ai.generate"),
412
- onClick: $
413
- }
414
- )
415
- ] }),
416
- D ? /* @__PURE__ */ e("p", { id: s, role: "alert", className: Tt, children: b("editor.ai.error") }) : j ? /* @__PURE__ */ e("p", { className: St, children: j }) : null
417
- ] })
418
- }
419
- );
420
- }
421
- const It = {
422
- bold: {
423
- id: "bold",
424
- icon: /* @__PURE__ */ e(tt, {}),
425
- label: ["editor.bold", "Bold"],
426
- command: ["module.inline.format", { tag: "b" }],
427
- toggle: "bold"
428
- },
429
- italic: {
430
- id: "italic",
431
- icon: /* @__PURE__ */ e(lt, {}),
432
- label: ["editor.italic", "Italic"],
433
- command: ["module.inline.format", { tag: "i" }],
434
- toggle: "italic"
435
- },
436
- strike: {
437
- id: "strike",
438
- icon: /* @__PURE__ */ e(Ct, {}),
439
- label: ["editor.strike", "Strikethrough"],
440
- command: ["module.inline.format", { tag: "del" }],
441
- toggle: "strike"
442
- },
443
- ul: {
444
- id: "ul",
445
- icon: /* @__PURE__ */ e(ft, {}),
446
- label: ["editor.list.bullet", "Bulleted list"],
447
- command: ["module.list.toggle", "ul"],
448
- toggle: "ul"
449
- },
450
- ol: {
451
- id: "ol",
452
- icon: /* @__PURE__ */ e(ut, {}),
453
- label: ["editor.list.ordered", "Numbered list"],
454
- command: ["module.list.toggle", "ol"],
455
- toggle: "ol"
456
- },
457
- link: {
458
- id: "link",
459
- icon: /* @__PURE__ */ e(dt, {}),
460
- label: ["editor.link.insert", "Insert link"],
461
- command: ["module.link.open"]
462
- },
463
- rule: {
464
- id: "rule",
465
- icon: /* @__PURE__ */ e(bt, {}),
466
- label: ["editor.horizontalRule", "Horizontal rule"],
467
- command: ["module.line.insert"]
468
- }
469
- }, Ht = [
470
- {
471
- id: "paragraph",
472
- tag: "p",
473
- icon: /* @__PURE__ */ e(yt, {}),
474
- label: ["editor.paragraph", "Paragraph"]
475
- },
476
- {
477
- id: "h2",
478
- tag: "h2",
479
- icon: /* @__PURE__ */ e(ot, {}),
480
- label: ["editor.heading2", "Heading 2"]
481
- },
482
- {
483
- id: "h3",
484
- tag: "h3",
485
- icon: /* @__PURE__ */ e(nt, {}),
486
- label: ["editor.heading3", "Heading 3"]
487
- },
488
- {
489
- id: "quote",
490
- tag: "blockquote",
491
- icon: /* @__PURE__ */ e(xt, {}),
492
- label: ["editor.quote", "Quote"]
493
- }
494
- ], At = {
495
- minimal: ["bold", "italic", "link"],
496
- standard: ["format", "bold", "italic", "strike", "ul", "ol", "link"],
497
- full: ["format", "bold", "italic", "strike", "ul", "ol", "link", "rule"]
498
- }, Lt = [
499
- {
500
- token: "--foreground",
501
- bg: "ds:bg-[var(--foreground)]",
502
- label: ["editor.color.default", "Default"]
503
- },
504
- {
505
- token: "--color-violet-700",
506
- bg: "ds:bg-[var(--color-violet-700)]",
507
- label: ["editor.color.violet", "Violet"]
508
- },
509
- {
510
- token: "--color-magenta-700",
511
- bg: "ds:bg-[var(--color-magenta-700)]",
512
- label: ["editor.color.magenta", "Magenta"]
513
- },
514
- {
515
- token: "--color-blue-700",
516
- bg: "ds:bg-[var(--color-blue-700)]",
517
- label: ["editor.color.blue", "Blue"]
518
- },
519
- {
520
- token: "--color-green-700",
521
- bg: "ds:bg-[var(--color-green-700)]",
522
- label: ["editor.color.green", "Green"]
523
- },
524
- {
525
- token: "--color-orange-700",
526
- bg: "ds:bg-[var(--color-orange-700)]",
527
- label: ["editor.color.orange", "Orange"]
528
- },
529
- {
530
- token: "--color-red-700",
531
- bg: "ds:bg-[var(--color-red-700)]",
532
- label: ["editor.color.red", "Red"]
533
- }
534
- ], Et = [
535
- {
536
- id: "rowAbove",
537
- command: "plugin.table.addRowAbove",
538
- label: ["editor.table.rowAbove", "Add row above"]
539
- },
540
- {
541
- id: "rowBelow",
542
- command: "plugin.table.addRowBelow",
543
- label: ["editor.table.rowBelow", "Add row below"]
544
- },
545
- {
546
- id: "colLeft",
547
- command: "plugin.table.addColumnLeft",
548
- label: ["editor.table.columnLeft", "Add column left"]
549
- },
550
- {
551
- id: "colRight",
552
- command: "plugin.table.addColumnRight",
553
- label: ["editor.table.columnRight", "Add column right"]
554
- },
555
- {
556
- id: "deleteRow",
557
- command: "plugin.table.deleteRow",
558
- label: ["editor.table.deleteRow", "Delete row"]
559
- },
560
- {
561
- id: "deleteColumn",
562
- command: "plugin.table.deleteColumn",
563
- label: ["editor.table.deleteColumn", "Delete column"]
564
- },
565
- {
566
- id: "deleteTable",
567
- command: "plugin.table.deleteTable",
568
- label: ["editor.table.deleteTable", "Delete table"]
569
- }
570
- ], $t = ke(
571
- [
572
- "ds:flex ds:flex-wrap ds:items-center ds:gap-[var(--spacing-xs)]",
573
- "ds:rounded-[var(--radius-md)] ds:border ds:border-[color:var(--border)]",
574
- "ds:bg-[var(--background)] ds:p-[var(--spacing-xs)]",
575
- "ds:shadow-[var(--shadow-md)]"
576
- ].join(" ")
577
- ), qt = "ds:self-stretch ds:[inline-size:var(--border-width-sm)] ds:bg-[var(--border)] ds:[margin-inline:var(--spacing-2xs)]", jt = "ds:size-6 ds:rounded-[var(--radius-sm)] ds:border ds:border-[color-mix(in_srgb,var(--foreground)_15%,transparent)] ds:focus-visible:outline-[length:var(--focus-ring-width)] ds:focus-visible:outline-solid ds:focus-visible:outline-[var(--ring)] ds:focus-visible:[outline-offset:var(--focus-ring-offset)]";
578
- function Ot(o) {
579
- return typeof window > "u" ? "" : getComputedStyle(document.documentElement).getPropertyValue(o).trim();
580
- }
581
- function Pt({
582
- run: o,
583
- active: n,
584
- preset: g,
585
- enableColor: L = !1,
586
- enableImage: Q = !1,
587
- enableTable: j = !1
588
- }) {
589
- const { t: l } = xe(), b = L || Q || j, R = (s) => s.preventDefault();
590
- return /* @__PURE__ */ w(
591
- "div",
592
- {
593
- role: "toolbar",
594
- "aria-label": l("editor.toolbarLabel"),
595
- className: $t(),
596
- "data-component": "editor-toolbar",
597
- children: [
598
- At[g].map((s) => {
599
- if (s === "format")
600
- return /* @__PURE__ */ w(A.Root, { children: [
601
- /* @__PURE__ */ e(A.Trigger, { asChild: !0, children: /* @__PURE__ */ e(
602
- I,
603
- {
604
- size: "sm",
605
- intent: "ghost",
606
- icon: /* @__PURE__ */ e(Ue, {}),
607
- "aria-label": l("editor.format", "Paragraph style"),
608
- onMouseDown: R
609
- }
610
- ) }),
611
- /* @__PURE__ */ e(A.Content, { align: "start", children: Ht.map((p) => /* @__PURE__ */ e(
612
- A.Item,
613
- {
614
- startIcon: p.icon,
615
- onSelect: () => o("module.block.format", { tag: p.tag }),
616
- children: l(p.label[0], p.label[1])
617
- },
618
- p.id
619
- )) })
620
- ] }, "format");
621
- const h = It[s];
622
- return /* @__PURE__ */ e(
623
- I,
624
- {
625
- size: "sm",
626
- intent: "ghost",
627
- icon: h.icon,
628
- "aria-label": l(h.label[0], h.label[1]),
629
- "aria-pressed": h.toggle ? n.has(h.toggle) : void 0,
630
- onMouseDown: R,
631
- onClick: () => o(...h.command)
632
- },
633
- h.id
634
- );
635
- }),
636
- b ? /* @__PURE__ */ e("span", { "aria-hidden": "true", className: qt }) : null,
637
- L ? /* @__PURE__ */ w(me, { children: [
638
- /* @__PURE__ */ e(me.Trigger, { asChild: !0, children: /* @__PURE__ */ e(
639
- I,
640
- {
641
- size: "sm",
642
- intent: "ghost",
643
- icon: /* @__PURE__ */ e(pt, {}),
644
- "aria-label": l("editor.textColor", "Text colour"),
645
- onMouseDown: R
646
- }
647
- ) }),
648
- /* @__PURE__ */ w(me.Content, { side: "bottom", align: "start", children: [
649
- /* @__PURE__ */ e(me.Heading, { children: l("editor.textColor", "Text colour") }),
650
- /* @__PURE__ */ e("div", { className: "ds:flex ds:flex-wrap ds:gap-[var(--spacing-xs)] ds:pt-[var(--spacing-xs)]", children: Lt.map((s) => /* @__PURE__ */ e(
651
- "button",
652
- {
653
- type: "button",
654
- "aria-label": l(s.label[0], s.label[1]),
655
- className: `${jt} ${s.bg}`,
656
- onMouseDown: R,
657
- onClick: () => o("plugin.fontcolor.set", {
658
- rule: "color",
659
- value: Ot(s.token)
660
- })
661
- },
662
- s.token
663
- )) }),
664
- /* @__PURE__ */ e(
665
- "button",
666
- {
667
- type: "button",
668
- className: "ds:mt-[var(--spacing-sm)] ds:text-[length:var(--font-size-sm)] ds:text-[color:var(--muted-foreground)] ds:underline",
669
- onMouseDown: R,
670
- onClick: () => o("plugin.fontcolor.remove", { rule: "color" }),
671
- children: l("editor.color.remove", "Remove colour")
672
- }
673
- )
674
- ] })
675
- ] }) : null,
676
- Q ? /* @__PURE__ */ e(
677
- I,
678
- {
679
- size: "sm",
680
- intent: "ghost",
681
- icon: /* @__PURE__ */ e(Ke, {}),
682
- "aria-label": l("editor.image.insert", "Insert image"),
683
- onMouseDown: R,
684
- onClick: () => o("module.image.open")
685
- }
686
- ) : null,
687
- j ? /* @__PURE__ */ w(A.Root, { children: [
688
- /* @__PURE__ */ e(A.Trigger, { asChild: !0, children: /* @__PURE__ */ e(
689
- I,
690
- {
691
- size: "sm",
692
- intent: "ghost",
693
- icon: /* @__PURE__ */ e(zt, {}),
694
- "aria-label": l("editor.table.insert", "Insert table"),
695
- onMouseDown: R
696
- }
697
- ) }),
698
- /* @__PURE__ */ w(A.Content, { align: "start", children: [
699
- /* @__PURE__ */ e(A.Item, { onSelect: () => o("plugin.table.insert"), children: l("editor.table.insert", "Insert table") }),
700
- /* @__PURE__ */ e(A.Separator, {}),
701
- Et.map((s) => /* @__PURE__ */ e(A.Item, { onSelect: () => o(s.command), children: l(s.label[0], s.label[1]) }, s.id))
702
- ] })
703
- ] }) : null
704
- ]
705
- }
706
- );
707
- }
708
- function O(o) {
709
- return Fe(o, "rich-text");
710
- }
711
- function be(o = "") {
712
- const n = String(o).trim();
713
- if (n === "" || n === "<p><br></p>" || n === "<p>&nbsp;</p>")
714
- return "";
715
- const g = n.replace(/<br\s*\/?>/gi, "").replace(/&nbsp;/gi, "").replace(/<[^>]+>/g, "").trim();
716
- return g === "" && /<img\b[^>]*>/i.test(n) ? n : g === "" ? "" : n;
717
- }
718
- function Dt(o) {
719
- return o.replace(
720
- /<img(?![^>]*\sloading=)([^>]*)>/gi,
721
- '<img loading="lazy"$1>'
722
- );
723
- }
724
- function Bt(o) {
725
- if (o) return o;
726
- if (typeof window > "u") return null;
727
- const n = window;
728
- return n.$R ?? n.Redactor ?? null;
729
- }
730
- const Vt = {
731
- bold: ["module.inline.format", { tag: "b" }],
732
- italic: ["module.inline.format", { tag: "i" }],
733
- strikethrough: ["module.inline.format", { tag: "del" }],
734
- bulletedList: ["module.list.toggle", "ul"],
735
- numberedList: ["module.list.toggle", "ol"],
736
- heading: ["module.block.format", { tag: "h2" }],
737
- quote: ["module.block.format", { tag: "blockquote" }],
738
- paragraph: ["module.block.format", { tag: "p" }]
739
- }, Ft = {
740
- zh: "zh_cn",
741
- pt: "pt_br"
742
- };
743
- function Wt(o) {
744
- const n = o.split("-")[0];
745
- return Ft[n] ?? n ?? "en";
746
- }
747
- const Gt = ke(
748
- "redactor-theme-alfadocs ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]"
749
- ), Qt = ke(
750
- [
751
- "ds:block ds:[inline-size:100%]",
752
- "ds:rounded-[var(--radius-md)] ds:border ds:border-[color:var(--border)]",
753
- "ds:bg-[var(--background)] ds:text-[var(--foreground)]",
754
- "ds:shadow-[var(--shadow-md)]",
755
- "ds:font-[family-name:var(--font-sans)] ds:text-[length:var(--font-size-base)]",
756
- "ds:p-[var(--spacing-md)] ds:[min-block-size:var(--rich-text-editor-min-block-size)]",
757
- "ds:focus-visible:outline-[length:var(--focus-ring-width)]",
758
- "ds:focus-visible:outline-solid",
759
- "ds:focus-visible:outline-[var(--ring)]",
760
- "ds:focus-visible:outline-offset-[length:var(--focus-ring-offset)]",
761
- "ds:forced-colors:focus-visible:outline-[CanvasText]"
762
- ].join(" ")
763
- ), He = [
764
- "ds:inline-flex ds:items-center ds:justify-center",
765
- "ds:[min-block-size:var(--min-target-size)] ds:[min-inline-size:var(--min-target-size)]",
766
- "ds:text-[color:var(--primary-foreground)]",
767
- "ds:transition-colors",
768
- "ds:focus-visible:outline-[length:var(--focus-ring-width)]",
769
- "ds:focus-visible:outline-solid",
770
- "ds:focus-visible:outline-[var(--primary-foreground)]",
771
- "ds:focus-visible:[outline-offset:calc(var(--focus-ring-width)*-1)]"
772
- ].join(" "), Ie = `${He} ds:hover:bg-[color-mix(in_srgb,var(--primary-foreground)_15%,transparent)]`, Zt = `${He} ds:bg-[var(--destructive)] ds:hover:bg-[color-mix(in_srgb,var(--destructive)_88%,var(--primary-foreground))]`, Jt = "ds:aria-pressed:!bg-[var(--destructive)] ds:aria-pressed:!text-[var(--destructive-foreground)]", Xt = De(
773
- ({
774
- id: o,
775
- defaultValue: n,
776
- value: g,
777
- onChange: L,
778
- toolbar: Q = "standard",
779
- placeholder: j,
780
- readOnly: l = !1,
781
- ariaLabel: b,
782
- minHeight: R,
783
- className: s,
784
- redactor: h,
785
- options: p,
786
- plugins: k,
787
- lang: Z,
788
- imageUploadUrl: D,
789
- onKeyDown: B,
790
- onRequestAiDraft: S,
791
- aiDraftFormat: J = "html",
792
- aiPrivacyNotice: V,
793
- onDictate: u
794
- }, ne) => {
795
- const { t: M, i18n: F } = xe(), E = he(), W = Se(
796
- () => `rte-${E.replace(/[^a-zA-Z0-9-_]/g, "")}`,
797
- [E]
798
- ), m = `#${W}`, z = x(null), $ = x(null), U = x(!1), ie = x(l), K = x(null), [i, d] = _(!1), [G, N] = _(!1), [Ae, Le] = _(
799
- () => /* @__PURE__ */ new Set()
800
- ), ee = x(null), T = x(L), le = x(B);
801
- P(() => {
802
- T.current = L, le.current = B;
803
- }, [L, B]);
804
- const Ee = x(
805
- (() => {
806
- const t = g ?? n ?? "";
807
- return t ? O(t) : "";
808
- })()
809
- ), te = f(() => {
810
- var r;
811
- const t = $.current;
812
- if (t)
813
- try {
814
- const a = t(m, "source.getCode");
815
- if (typeof a == "string") return a;
816
- } catch {
817
- }
818
- return ((r = z.current) == null ? void 0 : r.value) ?? "";
819
- }, [m]), q = f(
820
- (t, ...r) => {
821
- const a = $.current;
822
- if (!a) return !1;
823
- const v = ie.current;
824
- if (v)
825
- try {
826
- a(m, "disableReadOnly");
827
- } catch {
828
- }
829
- try {
830
- return a(m, t, ...r), !0;
831
- } catch {
832
- return !1;
833
- } finally {
834
- if (v)
835
- try {
836
- a(m, "enableReadOnly");
837
- } catch {
838
- }
839
- }
840
- },
841
- [m]
842
- ), re = f(
843
- (t, r) => {
844
- var ae;
845
- const a = (r == null ? void 0 : r.asHtml) ?? !0, v = a ? O(t) : t;
846
- if (q(a ? "insertion.insertHtml" : "insertion.insertText", v)) return;
847
- const c = z.current;
848
- if (!c) return;
849
- const X = c.selectionStart ?? c.value.length, Y = c.selectionEnd ?? c.value.length;
850
- c.value = c.value.slice(0, X) + v + c.value.slice(Y);
851
- const ue = X + v.length;
852
- try {
853
- c.setSelectionRange(ue, ue);
854
- } catch {
855
- }
856
- (ae = T.current) == null || ae.call(T, { html: O(c.value), markdown: "" });
857
- },
858
- [q]
859
- ), se = f(() => {
860
- var v;
861
- const t = (v = K.current) == null ? void 0 : v.querySelector(".redactor-in"), r = typeof window < "u" ? window.getSelection() : null, a = /* @__PURE__ */ new Set();
862
- if (t && r && r.anchorNode && t.contains(r.anchorNode) && typeof document.queryCommandState == "function")
863
- try {
864
- document.queryCommandState("bold") && a.add("bold"), document.queryCommandState("italic") && a.add("italic"), document.queryCommandState("strikeThrough") && a.add("strike"), document.queryCommandState("insertUnorderedList") && a.add("ul"), document.queryCommandState("insertOrderedList") && a.add("ol");
865
- const y = String(
866
- document.queryCommandValue("formatBlock") || ""
867
- ).toLowerCase();
868
- /^h[1-6]$/.test(y) ? a.add("heading") : y === "blockquote" && a.add("quote");
869
- } catch {
870
- }
871
- Le(
872
- (y) => y.size === a.size && [...a].every((c) => y.has(c)) ? y : a
873
- );
874
- }, []), fe = f(
875
- (t, ...r) => {
876
- q(t, ...r), typeof window < "u" ? window.requestAnimationFrame(() => se()) : se();
877
- },
878
- [q, se]
879
- ), oe = x(null), de = x(null), [H, we] = _(!1), [$e, Ce] = _(!1), ce = f(() => {
880
- const t = de.current;
881
- t != null && t.parentNode && t.parentNode.removeChild(t), de.current = null;
882
- }, []), Me = f((t) => {
883
- var v;
884
- const r = (v = K.current) == null ? void 0 : v.querySelector(
885
- ".redactor-in"
886
- );
887
- if (!r) return;
888
- let a = de.current;
889
- if (!a || !r.contains(a)) {
890
- a = document.createElement("span"), a.setAttribute("data-rte-interim", ""), a.setAttribute("contenteditable", "false");
891
- const y = window.getSelection();
892
- if (y && y.rangeCount > 0 && r.contains(y.anchorNode)) {
893
- const c = y.getRangeAt(0);
894
- c.collapse(!1), c.insertNode(a);
895
- } else
896
- r.appendChild(a);
897
- de.current = a;
898
- }
899
- a.textContent = t;
900
- }, []), ze = f(() => {
901
- var t;
902
- (t = oe.current) == null || t.abort();
903
- }, []), Ne = f(() => {
904
- if (!u) return;
905
- const t = new AbortController();
906
- oe.current = t, Ce(!1), we(!0), ce(), u({
907
- signal: t.signal,
908
- // Interim text shows live in the editor (grey + caret); each final
909
- // replaces it with committed text at the caret.
910
- onPartialTranscript: (r) => {
911
- t.signal.aborted || Me(r);
912
- },
913
- onFinalTranscript: (r) => {
914
- if (t.signal.aborted) return;
915
- ce();
916
- const a = r.trim();
917
- a && re(`${a} `, { asHtml: !1 });
918
- }
919
- }).catch((r) => {
920
- t.signal.aborted || r && typeof r == "object" && "name" in r && r.name === "AbortError" || Ce(!0);
921
- }).finally(() => {
922
- ce(), oe.current === t && (oe.current = null, we(!1));
923
- });
924
- }, [u, re, ce, Me]), Re = f(() => {
925
- H ? ze() : Ne();
926
- }, [H, Ne, ze]);
927
- P(() => () => {
928
- var t;
929
- return (t = oe.current) == null ? void 0 : t.abort();
930
- }, []), P(() => {
931
- const t = z.current;
932
- if (!t) return;
933
- t.value = Ee.current;
934
- const r = Bt(h);
935
- if (!r) {
936
- d(!0);
937
- return;
938
- }
939
- $.current = r;
940
- const a = {
941
- lang: Z ?? Wt(F.language || "en"),
942
- // The kit renders its OWN toolbar (EditorToolbar) and drives Redactor
943
- // via the command API, so Redactor's native toolbar is suppressed.
944
- toolbar: !1,
945
- plugins: k ?? [],
946
- placeholder: j ?? M("editor.placeholder"),
947
- toolbarFixed: !1,
948
- // Platform parity (RedactorWysiwyg.js:84): no inline shortcode expansion.
949
- shortcodes: !1,
950
- imageEditable: !1,
951
- imageResizable: !0
952
- }, v = D ? { imageUpload: D } : {}, y = (p == null ? void 0 : p.callbacks) ?? {}, c = {
953
- ...a,
954
- ...v,
955
- ...p ?? {},
956
- // Re-pin safety-critical keys LAST so consumer `options` can't override
957
- // the sanitising change handler, re-enable image editing, or turn off
958
- // drag-resize (platform re-pins both image flags — RedactorWysiwyg.js:115-116).
959
- imageEditable: !1,
960
- imageResizable: !0,
961
- callbacks: {
962
- ...y,
963
- changed(X) {
964
- const Y = be(Dt(X)), ue = O(Y);
965
- U.current = !0, T.current && (ee.current && clearTimeout(ee.current), ee.current = setTimeout(() => {
966
- var ae;
967
- (ae = T.current) == null || ae.call(T, { html: ue, markdown: "" });
968
- }, 100));
969
- },
970
- keydown(X) {
971
- var Y;
972
- (Y = le.current) == null || Y.call(le, X);
973
- },
974
- observe() {
975
- se();
976
- }
977
- }
978
- };
979
- try {
980
- if (r(m, c), l)
981
- try {
982
- r(m, "enableReadOnly");
983
- } catch {
984
- }
985
- } catch {
986
- d(!0);
987
- }
988
- return () => {
989
- ee.current && clearTimeout(ee.current);
990
- try {
991
- r(m, "destroy");
992
- } catch {
993
- }
994
- $.current = null;
995
- };
996
- }, []), P(() => {
997
- if (!$.current || g === void 0) return;
998
- if (U.current) {
999
- U.current = !1;
1000
- return;
1001
- }
1002
- const t = O(be(g));
1003
- be(te()) !== t && q("source.setCode", t);
1004
- }, [g, te, q]), P(() => {
1005
- ie.current = l;
1006
- const t = $.current;
1007
- if (t)
1008
- try {
1009
- t(m, l ? "enableReadOnly" : "disableReadOnly");
1010
- } catch {
1011
- }
1012
- }, [l, m]), P(() => {
1013
- if (!i || g === void 0) return;
1014
- const t = z.current;
1015
- if (!t) return;
1016
- const r = O(g);
1017
- t.value !== r && document.activeElement !== t && (t.value = r);
1018
- }, [i, g]);
1019
- const ge = Se(
1020
- () => ({
1021
- getHTML() {
1022
- return te();
1023
- },
1024
- getText() {
1025
- return te().replace(/<[^>]*>/g, " ").replace(/&nbsp;/gi, " ").replace(/\s+/g, " ").trim();
1026
- },
1027
- getMarkdown() {
1028
- return "";
1029
- },
1030
- setContent(t) {
1031
- const r = O(t);
1032
- q("source.setCode", r) || z.current && (z.current.value = r);
1033
- },
1034
- insertAtCursor: re,
1035
- applyFormat(t) {
1036
- const r = Vt[t];
1037
- r && fe(...r);
1038
- },
1039
- focus() {
1040
- var r;
1041
- const t = $.current;
1042
- if (t)
1043
- try {
1044
- t(m, "editor.focus");
1045
- return;
1046
- } catch {
1047
- }
1048
- (r = z.current) == null || r.focus();
1049
- },
1050
- clear() {
1051
- q("source.setCode", "") || z.current && (z.current.value = "");
1052
- }
1053
- }),
1054
- [m, te, q, re, fe]
1055
- );
1056
- Be(ne, () => ge, [ge]), We(Nt, ge, o);
1057
- const qe = f(
1058
- (t) => {
1059
- var r;
1060
- (r = T.current) == null || r.call(T, {
1061
- html: O(t.target.value),
1062
- markdown: ""
1063
- });
1064
- },
1065
- []
1066
- ), je = b ?? M("editor.regionLabel"), Oe = j ?? M("editor.placeholder");
1067
- return /* @__PURE__ */ w(
1068
- "div",
1069
- {
1070
- ref: K,
1071
- className: [Gt(), s].filter(Boolean).join(" "),
1072
- "data-component": "rich-text-editor",
1073
- "data-component-id": o,
1074
- "data-min-height": R,
1075
- children: [
1076
- !i && !l ? /* @__PURE__ */ e(
1077
- Pt,
1078
- {
1079
- run: fe,
1080
- active: Ae,
1081
- preset: Q,
1082
- enableColor: (k == null ? void 0 : k.includes("fontcolor")) ?? !1,
1083
- enableImage: !!D,
1084
- enableTable: (k == null ? void 0 : k.includes("table")) ?? !1
1085
- }
1086
- ) : null,
1087
- /* @__PURE__ */ w("div", { className: "ds:relative", children: [
1088
- /* @__PURE__ */ e(
1089
- "textarea",
1090
- {
1091
- ref: z,
1092
- id: W,
1093
- "aria-label": je,
1094
- "aria-multiline": "true",
1095
- placeholder: Oe,
1096
- onChange: i ? qe : void 0,
1097
- readOnly: i ? l : void 0,
1098
- className: i ? Qt() : void 0
1099
- }
1100
- ),
1101
- S && u ? /* @__PURE__ */ w("div", { className: "ds:absolute ds:[inset-block-end:var(--spacing-md)] ds:[inset-inline-end:var(--spacing-md)] ds:z-10 ds:flex ds:items-center ds:overflow-hidden ds:rounded-full ds:bg-[var(--primary)] ds:shadow-[var(--shadow-lg)]", children: [
1102
- /* @__PURE__ */ e(
1103
- "button",
1104
- {
1105
- type: "button",
1106
- onClick: Re,
1107
- "aria-pressed": H,
1108
- "aria-label": M(H ? "editor.ai.dictateStop" : "editor.ai.dictateStart"),
1109
- className: H ? Zt : Ie,
1110
- children: H ? /* @__PURE__ */ e(
1111
- pe,
1112
- {
1113
- "aria-hidden": "true",
1114
- className: "ds:size-5 ds:fill-current"
1115
- }
1116
- ) : /* @__PURE__ */ e(ve, { "aria-hidden": "true", className: "ds:size-5" })
1117
- }
1118
- ),
1119
- /* @__PURE__ */ e(
1120
- "span",
1121
- {
1122
- "aria-hidden": "true",
1123
- className: "ds:self-stretch ds:[inline-size:var(--border-width-sm)] ds:bg-[color-mix(in_srgb,var(--primary-foreground)_35%,transparent)]"
1124
- }
1125
- ),
1126
- /* @__PURE__ */ e(
1127
- "button",
1128
- {
1129
- type: "button",
1130
- onClick: () => N(!0),
1131
- "aria-label": M("editor.ai.helpMeWrite"),
1132
- className: Ie,
1133
- children: /* @__PURE__ */ e(ye, { "aria-hidden": "true", className: "ds:size-5" })
1134
- }
1135
- )
1136
- ] }) : u ? /* @__PURE__ */ e("div", { className: "ds:absolute ds:[inset-block-end:var(--spacing-md)] ds:[inset-inline-end:var(--spacing-md)] ds:z-10", children: /* @__PURE__ */ e(
1137
- I,
1138
- {
1139
- size: "lg",
1140
- intent: "primary",
1141
- icon: H ? /* @__PURE__ */ e(pe, { className: "ds:fill-current" }) : /* @__PURE__ */ e(ve, {}),
1142
- "aria-pressed": H,
1143
- "aria-label": M(H ? "editor.ai.dictateStop" : "editor.ai.dictateStart"),
1144
- onClick: Re,
1145
- className: H ? `${Jt} ds:rounded-full ds:shadow-[var(--shadow-lg)]` : "ds:rounded-full ds:shadow-[var(--shadow-lg)]"
1146
- }
1147
- ) }) : S ? /* @__PURE__ */ e("div", { className: "ds:absolute ds:[inset-block-end:var(--spacing-md)] ds:[inset-inline-end:var(--spacing-md)] ds:z-10", children: /* @__PURE__ */ e(
1148
- I,
1149
- {
1150
- size: "lg",
1151
- intent: "primary",
1152
- icon: /* @__PURE__ */ e(ye, {}),
1153
- "aria-label": M("editor.ai.helpMeWrite"),
1154
- onClick: () => N(!0),
1155
- className: "ds:rounded-full ds:shadow-[var(--shadow-lg)]"
1156
- }
1157
- ) }) : null,
1158
- S ? /* @__PURE__ */ e(
1159
- _t,
1160
- {
1161
- open: G,
1162
- onClose: () => N(!1),
1163
- onRequestAiDraft: S,
1164
- onInsert: (t) => re(t, { asHtml: J !== "text" }),
1165
- previewAsHtml: J !== "text",
1166
- privacyNotice: V,
1167
- onDictate: u
1168
- }
1169
- ) : null
1170
- ] }),
1171
- u && $e ? /* @__PURE__ */ e(
1172
- "p",
1173
- {
1174
- role: "alert",
1175
- className: "ds:text-[length:var(--font-size-sm)] ds:text-[color:var(--destructive)]",
1176
- children: M("editor.ai.dictationError")
1177
- }
1178
- ) : null
1179
- ]
1180
- }
1181
- );
1182
- }
1183
- );
1184
- Xt.displayName = "RichTextEditor";
1185
- export {
1186
- Xt as R,
1187
- Nt as r,
1188
- Gt as w
1189
- };
1190
- //# sourceMappingURL=rich-text-editor-u36FqSWz.js.map