@namroodinc/liquid-editorial 0.13.5 → 0.15.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 (275) hide show
  1. package/README.md +2 -2
  2. package/UPGRADING.md +94 -0
  3. package/dist/chunks/{Avatar-BY0dAItT.cjs → Avatar-BZGFSE6C.cjs} +2 -2
  4. package/dist/chunks/{Avatar-BY0dAItT.cjs.map → Avatar-BZGFSE6C.cjs.map} +1 -1
  5. package/dist/chunks/{Avatar-UjhjcHh5.js → Avatar-C4W-g8nU.js} +2 -2
  6. package/dist/chunks/{Avatar-UjhjcHh5.js.map → Avatar-C4W-g8nU.js.map} +1 -1
  7. package/dist/chunks/{Board-DUX76d2R.js → Board-Cbi5FMW-.js} +2 -2
  8. package/dist/chunks/{Board-DUX76d2R.js.map → Board-Cbi5FMW-.js.map} +1 -1
  9. package/dist/chunks/{Board-CQ1GTuRB.cjs → Board-_agEjTy8.cjs} +2 -2
  10. package/dist/chunks/{Board-CQ1GTuRB.cjs.map → Board-_agEjTy8.cjs.map} +1 -1
  11. package/dist/chunks/{CollectionView-CIJdNwcq.cjs → CollectionView-BfX2Lxre.cjs} +2 -2
  12. package/dist/chunks/{CollectionView-CIJdNwcq.cjs.map → CollectionView-BfX2Lxre.cjs.map} +1 -1
  13. package/dist/chunks/{CollectionView-JRNdXHti.js → CollectionView-DPJGtSP5.js} +2 -2
  14. package/dist/chunks/{CollectionView-JRNdXHti.js.map → CollectionView-DPJGtSP5.js.map} +1 -1
  15. package/dist/chunks/{ColourField-DFvRASVe.cjs → ColourField-BVGnW8Wh.cjs} +2 -2
  16. package/dist/chunks/{ColourField-DFvRASVe.cjs.map → ColourField-BVGnW8Wh.cjs.map} +1 -1
  17. package/dist/chunks/{ColourField-BG5oGj9f.js → ColourField-BcuARZY4.js} +6 -6
  18. package/dist/chunks/{ColourField-BG5oGj9f.js.map → ColourField-BcuARZY4.js.map} +1 -1
  19. package/dist/chunks/{DatePicker-LqaePc57.js → DatePicker-VQUsbYdo.js} +3 -3
  20. package/dist/chunks/{DatePicker-LqaePc57.js.map → DatePicker-VQUsbYdo.js.map} +1 -1
  21. package/dist/chunks/{DatePicker-ClOqS6oH.cjs → DatePicker-zA0bWVBp.cjs} +2 -2
  22. package/dist/chunks/{DatePicker-ClOqS6oH.cjs.map → DatePicker-zA0bWVBp.cjs.map} +1 -1
  23. package/dist/chunks/{Drawer-Ck5XKT_V.js → Drawer-2cf0SaG4.js} +3 -3
  24. package/dist/chunks/{Drawer-Ck5XKT_V.js.map → Drawer-2cf0SaG4.js.map} +1 -1
  25. package/dist/chunks/{Drawer-DdIH9jpe.cjs → Drawer-BzvSfkCL.cjs} +2 -2
  26. package/dist/chunks/{Drawer-DdIH9jpe.cjs.map → Drawer-BzvSfkCL.cjs.map} +1 -1
  27. package/dist/chunks/EntryPicker-BGWxiLJ_.js +877 -0
  28. package/dist/chunks/EntryPicker-BGWxiLJ_.js.map +1 -0
  29. package/dist/chunks/EntryPicker-wVjzdlAO.cjs +2 -0
  30. package/dist/chunks/EntryPicker-wVjzdlAO.cjs.map +1 -0
  31. package/dist/chunks/FormEditor-BHVJG23r.js +30 -0
  32. package/dist/chunks/FormEditor-BHVJG23r.js.map +1 -0
  33. package/dist/chunks/FormEditor-DjUz7qQo.cjs +2 -0
  34. package/dist/chunks/FormEditor-DjUz7qQo.cjs.map +1 -0
  35. package/dist/chunks/Icon-QLZH31JA.cjs +2 -0
  36. package/dist/chunks/Icon-QLZH31JA.cjs.map +1 -0
  37. package/dist/chunks/Icon-kLLQC54Z.js +107 -0
  38. package/dist/chunks/Icon-kLLQC54Z.js.map +1 -0
  39. package/dist/chunks/{Message-d6lqiMQ6.js → Message-DM6pTq7N.js} +2 -2
  40. package/dist/chunks/{Message-d6lqiMQ6.js.map → Message-DM6pTq7N.js.map} +1 -1
  41. package/dist/chunks/{Message-yhdaBpaz.cjs → Message-yZJDVzb8.cjs} +2 -2
  42. package/dist/chunks/{Message-yhdaBpaz.cjs.map → Message-yZJDVzb8.cjs.map} +1 -1
  43. package/dist/chunks/RichTextEditor-BgfeOrEe.cjs +2 -0
  44. package/dist/chunks/RichTextEditor-BgfeOrEe.cjs.map +1 -0
  45. package/dist/chunks/RichTextEditor-CS2ED0HP.js +2702 -0
  46. package/dist/chunks/RichTextEditor-CS2ED0HP.js.map +1 -0
  47. package/dist/chunks/dialogLabel-Dx-WEEzI.cjs +2 -0
  48. package/dist/chunks/dialogLabel-Dx-WEEzI.cjs.map +1 -0
  49. package/dist/chunks/dialogLabel-nB1gwKz0.js +157 -0
  50. package/dist/chunks/dialogLabel-nB1gwKz0.js.map +1 -0
  51. package/dist/chunks/overlayLayer-CPd3zj_u.cjs +2 -0
  52. package/dist/chunks/overlayLayer-CPd3zj_u.cjs.map +1 -0
  53. package/dist/chunks/overlayLayer-Dv1vmfaI.js +199 -0
  54. package/dist/chunks/overlayLayer-Dv1vmfaI.js.map +1 -0
  55. package/dist/chunks/{useTooltip-DnJEFBLg.js → useTooltip-COyAcujL.js} +2 -2
  56. package/dist/chunks/{useTooltip-DnJEFBLg.js.map → useTooltip-COyAcujL.js.map} +1 -1
  57. package/dist/chunks/{useTooltip-C7ON4nkV.cjs → useTooltip-nEDN0ObI.cjs} +2 -2
  58. package/dist/chunks/{useTooltip-C7ON4nkV.cjs.map → useTooltip-nEDN0ObI.cjs.map} +1 -1
  59. package/dist/components/AppShell/index.cjs +1 -1
  60. package/dist/components/AppShell/index.js +1 -1
  61. package/dist/components/AssetCard/index.cjs +1 -1
  62. package/dist/components/AssetCard/index.js +1 -1
  63. package/dist/components/AssetGrid/index.cjs +1 -1
  64. package/dist/components/AssetGrid/index.js +1 -1
  65. package/dist/components/Avatar/index.cjs +1 -1
  66. package/dist/components/Avatar/index.js +1 -1
  67. package/dist/components/Banner/index.cjs +1 -1
  68. package/dist/components/Banner/index.js +1 -1
  69. package/dist/components/Board/index.cjs +1 -1
  70. package/dist/components/Board/index.js +1 -1
  71. package/dist/components/Button/index.cjs +1 -1
  72. package/dist/components/Button/index.js +1 -1
  73. package/dist/components/Choice/index.cjs +1 -1
  74. package/dist/components/Choice/index.cjs.map +1 -1
  75. package/dist/components/Choice/index.js +5 -5
  76. package/dist/components/CollectionView/index.cjs +1 -1
  77. package/dist/components/CollectionView/index.js +1 -1
  78. package/dist/components/ColourField/index.cjs +1 -1
  79. package/dist/components/ColourField/index.js +1 -1
  80. package/dist/components/DatePicker/index.cjs +1 -1
  81. package/dist/components/DatePicker/index.js +1 -1
  82. package/dist/components/Drawer/index.cjs +1 -1
  83. package/dist/components/Drawer/index.js +1 -1
  84. package/dist/components/EditLayout/index.cjs +1 -1
  85. package/dist/components/EditLayout/index.cjs.map +1 -1
  86. package/dist/components/EditLayout/index.js +6 -7
  87. package/dist/components/EditLayout/index.js.map +1 -1
  88. package/dist/components/EntryPicker/dialog.d.cts +11 -1
  89. package/dist/components/EntryPicker/dialog.d.cts.map +1 -1
  90. package/dist/components/EntryPicker/dialog.d.ts +11 -1
  91. package/dist/components/EntryPicker/dialog.d.ts.map +1 -1
  92. package/dist/components/EntryPicker/index.cjs +1 -1
  93. package/dist/components/EntryPicker/index.js +1 -1
  94. package/dist/components/EntryPicker/style.css +1 -1
  95. package/dist/components/EntryPicker/use-picker-data.d.cts +1 -1
  96. package/dist/components/EntryPicker/use-picker-data.d.cts.map +1 -1
  97. package/dist/components/EntryPicker/use-picker-data.d.ts +1 -1
  98. package/dist/components/EntryPicker/use-picker-data.d.ts.map +1 -1
  99. package/dist/components/EntryPicker/use-picker-session.d.cts +4 -1
  100. package/dist/components/EntryPicker/use-picker-session.d.cts.map +1 -1
  101. package/dist/components/EntryPicker/use-picker-session.d.ts +4 -1
  102. package/dist/components/EntryPicker/use-picker-session.d.ts.map +1 -1
  103. package/dist/components/EntryPicker/use-selected-items.d.cts +2 -0
  104. package/dist/components/EntryPicker/use-selected-items.d.cts.map +1 -1
  105. package/dist/components/EntryPicker/use-selected-items.d.ts +2 -0
  106. package/dist/components/EntryPicker/use-selected-items.d.ts.map +1 -1
  107. package/dist/components/FormEditor/README.md +197 -28
  108. package/dist/components/FormEditor/control.d.cts +11 -2
  109. package/dist/components/FormEditor/control.d.cts.map +1 -1
  110. package/dist/components/FormEditor/control.d.ts +11 -2
  111. package/dist/components/FormEditor/control.d.ts.map +1 -1
  112. package/dist/components/FormEditor/form.d.cts +33 -0
  113. package/dist/components/FormEditor/form.d.cts.map +1 -0
  114. package/dist/components/FormEditor/form.d.ts +33 -0
  115. package/dist/components/FormEditor/form.d.ts.map +1 -0
  116. package/dist/components/FormEditor/index.cjs +1 -1
  117. package/dist/components/FormEditor/index.d.cts +3 -27
  118. package/dist/components/FormEditor/index.d.cts.map +1 -1
  119. package/dist/components/FormEditor/index.d.ts +3 -27
  120. package/dist/components/FormEditor/index.d.ts.map +1 -1
  121. package/dist/components/FormEditor/index.js +3 -3
  122. package/dist/components/FormEditor/model.d.cts +2 -0
  123. package/dist/components/FormEditor/model.d.cts.map +1 -1
  124. package/dist/components/FormEditor/model.d.ts +2 -0
  125. package/dist/components/FormEditor/model.d.ts.map +1 -1
  126. package/dist/components/FormEditor/rich-text-control.d.cts +4 -0
  127. package/dist/components/FormEditor/rich-text-control.d.cts.map +1 -0
  128. package/dist/components/FormEditor/rich-text-control.d.ts +4 -0
  129. package/dist/components/FormEditor/rich-text-control.d.ts.map +1 -0
  130. package/dist/components/Icon/icons.d.cts +16 -0
  131. package/dist/components/Icon/icons.d.cts.map +1 -1
  132. package/dist/components/Icon/icons.d.ts +16 -0
  133. package/dist/components/Icon/icons.d.ts.map +1 -1
  134. package/dist/components/Icon/index.cjs +1 -1
  135. package/dist/components/Icon/index.js +1 -1
  136. package/dist/components/ImageCropper/index.cjs +1 -1
  137. package/dist/components/ImageCropper/index.cjs.map +1 -1
  138. package/dist/components/ImageCropper/index.js +6 -6
  139. package/dist/components/Menu/index.cjs +1 -1
  140. package/dist/components/Menu/index.cjs.map +1 -1
  141. package/dist/components/Menu/index.d.cts +3 -2
  142. package/dist/components/Menu/index.d.cts.map +1 -1
  143. package/dist/components/Menu/index.d.ts +3 -2
  144. package/dist/components/Menu/index.d.ts.map +1 -1
  145. package/dist/components/Menu/index.js +65 -52
  146. package/dist/components/Menu/index.js.map +1 -1
  147. package/dist/components/Modal/index.cjs +1 -1
  148. package/dist/components/Modal/index.js +2 -2
  149. package/dist/components/Popover/index.cjs +1 -1
  150. package/dist/components/Popover/index.cjs.map +1 -1
  151. package/dist/components/Popover/index.d.cts.map +1 -1
  152. package/dist/components/Popover/index.d.ts.map +1 -1
  153. package/dist/components/Popover/index.js +67 -64
  154. package/dist/components/Popover/index.js.map +1 -1
  155. package/dist/components/RichTextEditor/content-block-frame.d.cts +32 -0
  156. package/dist/components/RichTextEditor/content-block-frame.d.cts.map +1 -0
  157. package/dist/components/RichTextEditor/content-block-frame.d.ts +32 -0
  158. package/dist/components/RichTextEditor/content-block-frame.d.ts.map +1 -0
  159. package/dist/components/RichTextEditor/content-block-view.d.cts +3 -0
  160. package/dist/components/RichTextEditor/content-block-view.d.cts.map +1 -0
  161. package/dist/components/RichTextEditor/content-block-view.d.ts +3 -0
  162. package/dist/components/RichTextEditor/content-block-view.d.ts.map +1 -0
  163. package/dist/components/RichTextEditor/content-block.d.cts +24 -0
  164. package/dist/components/RichTextEditor/content-block.d.cts.map +1 -0
  165. package/dist/components/RichTextEditor/content-block.d.ts +24 -0
  166. package/dist/components/RichTextEditor/content-block.d.ts.map +1 -0
  167. package/dist/components/RichTextEditor/document.d.cts +15 -8
  168. package/dist/components/RichTextEditor/document.d.cts.map +1 -1
  169. package/dist/components/RichTextEditor/document.d.ts +15 -8
  170. package/dist/components/RichTextEditor/document.d.ts.map +1 -1
  171. package/dist/components/RichTextEditor/embed-context.d.cts +5 -0
  172. package/dist/components/RichTextEditor/embed-context.d.cts.map +1 -1
  173. package/dist/components/RichTextEditor/embed-context.d.ts +5 -0
  174. package/dist/components/RichTextEditor/embed-context.d.ts.map +1 -1
  175. package/dist/components/RichTextEditor/embed-types.d.cts +6 -4
  176. package/dist/components/RichTextEditor/embed-types.d.cts.map +1 -1
  177. package/dist/components/RichTextEditor/embed-types.d.ts +6 -4
  178. package/dist/components/RichTextEditor/embed-types.d.ts.map +1 -1
  179. package/dist/components/RichTextEditor/index.cjs +1 -1
  180. package/dist/components/RichTextEditor/index.d.cts +9 -1
  181. package/dist/components/RichTextEditor/index.d.cts.map +1 -1
  182. package/dist/components/RichTextEditor/index.d.ts +9 -1
  183. package/dist/components/RichTextEditor/index.d.ts.map +1 -1
  184. package/dist/components/RichTextEditor/index.js +1 -2
  185. package/dist/components/RichTextEditor/style.css +161 -86
  186. package/dist/components/RichTextEditor/table-actions.d.cts +11 -0
  187. package/dist/components/RichTextEditor/table-actions.d.cts.map +1 -0
  188. package/dist/components/RichTextEditor/table-actions.d.ts +11 -0
  189. package/dist/components/RichTextEditor/table-actions.d.ts.map +1 -0
  190. package/dist/components/RichTextEditor/table-bands.d.cts +19 -0
  191. package/dist/components/RichTextEditor/table-bands.d.cts.map +1 -0
  192. package/dist/components/RichTextEditor/table-bands.d.ts +19 -0
  193. package/dist/components/RichTextEditor/table-bands.d.ts.map +1 -0
  194. package/dist/components/RichTextEditor/table-view.d.cts +4 -0
  195. package/dist/components/RichTextEditor/table-view.d.cts.map +1 -0
  196. package/dist/components/RichTextEditor/table-view.d.ts +4 -0
  197. package/dist/components/RichTextEditor/table-view.d.ts.map +1 -0
  198. package/dist/components/RichTextEditor/tables.d.cts +7 -0
  199. package/dist/components/RichTextEditor/tables.d.cts.map +1 -0
  200. package/dist/components/RichTextEditor/tables.d.ts +7 -0
  201. package/dist/components/RichTextEditor/tables.d.ts.map +1 -0
  202. package/dist/components/RichTextEditor/use-embeds.d.cts.map +1 -1
  203. package/dist/components/RichTextEditor/use-embeds.d.ts.map +1 -1
  204. package/dist/components/SearchField/index.cjs +1 -1
  205. package/dist/components/SearchField/index.js +1 -1
  206. package/dist/components/Select/index.cjs +1 -1
  207. package/dist/components/Select/index.js +2 -2
  208. package/dist/components/SelectionCard/index.cjs +1 -1
  209. package/dist/components/SelectionCard/index.cjs.map +1 -1
  210. package/dist/components/SelectionCard/index.js +4 -4
  211. package/dist/components/SelectionCard/index.js.map +1 -1
  212. package/dist/components/SideNav/index.cjs +1 -1
  213. package/dist/components/SideNav/index.js +1 -1
  214. package/dist/components/SortableList/index.cjs +1 -1
  215. package/dist/components/SortableList/index.js +1 -1
  216. package/dist/components/Stepper/index.cjs +1 -1
  217. package/dist/components/Stepper/index.js +1 -1
  218. package/dist/components/SubNav/index.cjs +1 -1
  219. package/dist/components/SubNav/index.js +1 -1
  220. package/dist/components/Switch/style.css +2 -6
  221. package/dist/components/Table/index.cjs +1 -1
  222. package/dist/components/Table/index.js +1 -1
  223. package/dist/components/Time/index.cjs +1 -1
  224. package/dist/components/Time/index.js +1 -1
  225. package/dist/components/Toast/index.cjs +1 -1
  226. package/dist/components/Toast/index.js +1 -1
  227. package/dist/components/TopNav/index.cjs +1 -1
  228. package/dist/components/TopNav/index.js +1 -1
  229. package/dist/index.cjs +1 -1
  230. package/dist/index.d.cts +1 -1
  231. package/dist/index.d.cts.map +1 -1
  232. package/dist/index.d.ts +1 -1
  233. package/dist/index.d.ts.map +1 -1
  234. package/dist/index.js +28 -28
  235. package/dist/internal/dialogFocus.d.cts +6 -1
  236. package/dist/internal/dialogFocus.d.cts.map +1 -1
  237. package/dist/internal/dialogFocus.d.ts +6 -1
  238. package/dist/internal/dialogFocus.d.ts.map +1 -1
  239. package/package.json +8 -6
  240. package/dist/chunks/EntryPicker-B4dAsObz.cjs +0 -2
  241. package/dist/chunks/EntryPicker-B4dAsObz.cjs.map +0 -1
  242. package/dist/chunks/EntryPicker-DDXHytMN.js +0 -160
  243. package/dist/chunks/EntryPicker-DDXHytMN.js.map +0 -1
  244. package/dist/chunks/FormEditor-BGzE-rqk.cjs +0 -2
  245. package/dist/chunks/FormEditor-BGzE-rqk.cjs.map +0 -1
  246. package/dist/chunks/FormEditor-ChH4e5sB.js +0 -693
  247. package/dist/chunks/FormEditor-ChH4e5sB.js.map +0 -1
  248. package/dist/chunks/Icon-3ucBRgrd.cjs +0 -2
  249. package/dist/chunks/Icon-3ucBRgrd.cjs.map +0 -1
  250. package/dist/chunks/Icon-dPXyBYe5.js +0 -91
  251. package/dist/chunks/Icon-dPXyBYe5.js.map +0 -1
  252. package/dist/chunks/RichTextEditor-BFblqw8m.js +0 -1144
  253. package/dist/chunks/RichTextEditor-BFblqw8m.js.map +0 -1
  254. package/dist/chunks/RichTextEditor-DU9CVeRD.cjs +0 -2
  255. package/dist/chunks/RichTextEditor-DU9CVeRD.cjs.map +0 -1
  256. package/dist/chunks/dialogLabel-DT7rCr3_.js +0 -176
  257. package/dist/chunks/dialogLabel-DT7rCr3_.js.map +0 -1
  258. package/dist/chunks/dialogLabel-_-MTckE_.cjs +0 -2
  259. package/dist/chunks/dialogLabel-_-MTckE_.cjs.map +0 -1
  260. package/dist/chunks/overlayLayer-iGhuAByk.cjs +0 -2
  261. package/dist/chunks/overlayLayer-iGhuAByk.cjs.map +0 -1
  262. package/dist/chunks/overlayLayer-lU4iWSjO.js +0 -162
  263. package/dist/chunks/overlayLayer-lU4iWSjO.js.map +0 -1
  264. package/dist/chunks/use-picker-session-BSpOwnQ-.js +0 -712
  265. package/dist/chunks/use-picker-session-BSpOwnQ-.js.map +0 -1
  266. package/dist/chunks/use-picker-session-ouqHBmVA.cjs +0 -2
  267. package/dist/chunks/use-picker-session-ouqHBmVA.cjs.map +0 -1
  268. package/dist/components/RichTextEditor/storyblock-view.d.cts +0 -3
  269. package/dist/components/RichTextEditor/storyblock-view.d.cts.map +0 -1
  270. package/dist/components/RichTextEditor/storyblock-view.d.ts +0 -3
  271. package/dist/components/RichTextEditor/storyblock-view.d.ts.map +0 -1
  272. package/dist/components/RichTextEditor/storyblock.d.cts +0 -19
  273. package/dist/components/RichTextEditor/storyblock.d.cts.map +0 -1
  274. package/dist/components/RichTextEditor/storyblock.d.ts +0 -19
  275. package/dist/components/RichTextEditor/storyblock.d.ts.map +0 -1
@@ -1,1144 +0,0 @@
1
- import { t as e } from "./Icon-dPXyBYe5.js";
2
- import { Button as t } from "../components/Button/index.js";
3
- import { t as n } from "./mergeRefs-C6_5pADN.js";
4
- import { d as r, f as i, g as a, o, p as s, s as c, u as l } from "./overlayLayer-lU4iWSjO.js";
5
- import { a as u, o as d } from "./dialogLabel-DT7rCr3_.js";
6
- import { t as f } from "./useIsomorphicLayoutEffect-Bc9hxFMc.js";
7
- import { ButtonGroup as p } from "../components/ButtonGroup/index.js";
8
- import { Badge as m } from "../components/Badge/index.js";
9
- /* empty css */
10
- import { Field as h } from "../components/Field/index.js";
11
- import { Modal as g } from "../components/Modal/index.js";
12
- import { TextField as _ } from "../components/TextField/index.js";
13
- import { Popover as v } from "../components/Popover/index.js";
14
- import { MenuSeparator as y } from "../components/Menu/index.js";
15
- import { a as b, i as x, l as S, o as C, s as w, t as T } from "./use-picker-session-BSpOwnQ-.js";
16
- import { createContext as E, forwardRef as D, useCallback as O, useContext as k, useEffect as A, useId as j, useMemo as M, useRef as N, useState as P } from "react";
17
- import { createPortal as F } from "react-dom";
18
- import { Fragment as ee, jsx as I, jsxs as L } from "react/jsx-runtime";
19
- import { EditorContent as te, Node as R, NodeViewWrapper as z, ReactNodeViewRenderer as B, createDocument as ne, getMarkRange as re, getSchema as V, mergeAttributes as H, useEditor as ie, useEditorState as ae } from "@tiptap/react";
20
- import { Placeholder as oe } from "@tiptap/extension-placeholder";
21
- import { StarterKit as se } from "@tiptap/starter-kit";
22
- import { Link as U } from "@tiptap/extension-link";
23
- //#region src/components/RichTextEditor/expansion.tsx
24
- function ce(e, t) {
25
- let n = t.querySelector(".ds-rte__content");
26
- if (!n) return;
27
- let r = e.view.coordsAtPos(e.state.selection.head), i = n.getBoundingClientRect();
28
- (r.top < i.top || r.bottom > i.bottom) && (n.scrollTop += r.top - i.top - i.height / 2);
29
- }
30
- function le({ editor: e, disabled: n, isHeld: i = !1, invalid: a, label: o, labelledBy: c, expandedWidth: l, frameRef: p }) {
31
- let m = d("ds-rte__host"), [h, _] = P(!1), [v, y] = P(0), b = N(null), x = N(null), S = N(null), C = N(!1), w = N(!1), T = j();
32
- h && n && !i && _(!1);
33
- let E = O(() => {
34
- C.current = document.activeElement === S.current, _(!1);
35
- }, []);
36
- f(() => {
37
- m && (u(m, h ? x.current : b.current), w.current !== h && (w.current = h, n || !e ? r(document.activeElement) && s(p.current, { preventScroll: !0 }) : (ce(e, m), !h && C.current ? S.current?.focus() : (e.view.focus(), e.commands.scrollIntoView()), C.current = !1)));
38
- }, [
39
- m,
40
- h,
41
- e,
42
- n,
43
- p
44
- ]);
45
- let D = h ? "Collapse editor" : "Expand editor";
46
- return {
47
- expanded: h,
48
- toggle: /* @__PURE__ */ I(t, {
49
- ref: S,
50
- size: "sm",
51
- isIconOnly: !0,
52
- iconStart: h ? "minimize-2" : "maximize-2",
53
- className: "ds-rte__expand",
54
- "aria-label": D,
55
- title: D,
56
- "aria-expanded": h,
57
- "aria-controls": h ? T : void 0,
58
- isDisabled: n || !e || !m,
59
- onMouseDown: (e) => e.preventDefault(),
60
- onClick: () => {
61
- h ? E() : (y(p.current.getBoundingClientRect().height), _(!0));
62
- }
63
- }),
64
- surfaceSlot: (e) => /* @__PURE__ */ I("div", {
65
- ref: b,
66
- className: "ds-rte__slot",
67
- children: m ? F(e, m) : e
68
- }),
69
- dialog: /* @__PURE__ */ I(g, {
70
- id: T,
71
- isOpen: h,
72
- onClose: E,
73
- title: o,
74
- hasHeader: !1,
75
- size: l === "full" ? "full" : "wide",
76
- className: "ds-rte__modal",
77
- "data-invalid": a || void 0,
78
- "aria-labelledby": c,
79
- children: /* @__PURE__ */ I("div", {
80
- ref: x,
81
- className: "ds-rte__expanded-slot"
82
- })
83
- }),
84
- frameStyle: h ? { minBlockSize: v } : void 0
85
- };
86
- }
87
- //#endregion
88
- //#region src/components/RichTextEditor/storyblock.ts
89
- function W(e) {
90
- let t = (e) => typeof e == "string" && e.trim().length > 0;
91
- return [
92
- "left",
93
- "full",
94
- "right"
95
- ].includes(e.align == null ? "full" : e.align) && (e.type === "entry" ? t(e.id) && t(e.entryId) && e.assetId == null : e.type === "asset" && t(e.assetId) && e.id == null && e.entryId == null);
96
- }
97
- function G(e) {
98
- return {
99
- ...e,
100
- ...e.type === "storyblock" && e.attrs ? { attrs: {
101
- type: e.attrs.type,
102
- ...e.attrs.type === "entry" ? {
103
- id: e.attrs.id,
104
- entryId: e.attrs.entryId
105
- } : { assetId: e.attrs.assetId },
106
- align: e.attrs.align ?? "full"
107
- } } : {},
108
- ...e.content ? { content: e.content.map(G) } : {}
109
- };
110
- }
111
- var K = R.create({
112
- name: "storyblock",
113
- group: "block",
114
- atom: !0,
115
- draggable: !0,
116
- selectable: !0,
117
- marks: "",
118
- addAttributes() {
119
- return Object.fromEntries([
120
- "type",
121
- "id",
122
- "entryId",
123
- "assetId",
124
- "align"
125
- ].map((e) => [e, {
126
- default: e === "align" ? "full" : null,
127
- parseHTML: (t) => t.getAttribute(`data-storyblock-${e.toLowerCase()}`),
128
- renderHTML: () => ({})
129
- }]));
130
- },
131
- parseHTML() {
132
- return [{
133
- tag: "div[data-storyblock]",
134
- getAttrs: (e) => W(Object.fromEntries([
135
- "type",
136
- "id",
137
- "entryId",
138
- "assetId",
139
- "align"
140
- ].map((t) => [t, e.getAttribute(`data-storyblock-${t.toLowerCase()}`)]))) ? null : !1
141
- }];
142
- },
143
- renderHTML({ node: e, HTMLAttributes: t }) {
144
- let n = G({
145
- type: "storyblock",
146
- attrs: e.attrs
147
- }).attrs;
148
- return ["div", H(t, {
149
- "data-storyblock": "",
150
- ...Object.fromEntries(Object.entries(n).map(([e, t]) => [`data-storyblock-${e.toLowerCase()}`, t]))
151
- })];
152
- }
153
- }), q = {
154
- type: "doc",
155
- content: [{ type: "paragraph" }]
156
- }, ue = [se.configure({
157
- link: !1,
158
- trailingNode: { notAfter: ["paragraph", "storyblock"] }
159
- }), U.configure({
160
- openOnClick: !1,
161
- autolink: !0
162
- })];
163
- function de(e = K) {
164
- return [e, ...ue];
165
- }
166
- var J = V(de());
167
- function Y(e) {
168
- return e.content?.length ? e : {
169
- ...e,
170
- content: q.content
171
- };
172
- }
173
- function fe(e) {
174
- try {
175
- if (!e || typeof e != "object" || !("type" in e) || e.type !== "doc") throw Error();
176
- let t = (e) => {
177
- let n = J.nodes[e.type ?? ""];
178
- if (!n || Object.keys(e).some((e) => ![
179
- "type",
180
- "attrs",
181
- "content",
182
- "marks",
183
- "text"
184
- ].includes(e)) || e.text !== void 0 && e.type !== "text" || e.attrs && Object.keys(e.attrs).some((e) => !Object.hasOwn(n.spec.attrs ?? {}, e)) || e.type === "storyblock" && (!W(e.attrs ?? {}) || e.marks?.length)) throw Error();
185
- for (let t of e.marks ?? []) {
186
- let e = J.marks[t.type];
187
- if (!e || Object.keys(t).some((e) => !["type", "attrs"].includes(e)) || Object.keys(t.attrs ?? {}).some((t) => !Object.hasOwn(e.spec.attrs ?? {}, t))) throw Error();
188
- }
189
- e.content?.forEach(t);
190
- }, n = e;
191
- t(n), J.nodeFromJSON(Y(n)).check();
192
- } catch {
193
- return "Unsupported or invalid rich-text document.";
194
- }
195
- }
196
- //#endregion
197
- //#region src/components/RichTextEditor/embed-context.ts
198
- function X(e) {
199
- return !!(e && (e.loadPage || e.items?.length || e.onCreate));
200
- }
201
- var Z = E({
202
- views: {},
203
- disabled: !1,
204
- busy: !1,
205
- pickCount: 0,
206
- replace: () => {},
207
- seed: () => void 0,
208
- forgetSeed: () => {}
209
- }), pe = [], me = [
210
- {
211
- align: "left",
212
- icon: "align-left",
213
- label: "Left"
214
- },
215
- {
216
- align: "full",
217
- icon: "align-justify",
218
- label: "Full"
219
- },
220
- {
221
- align: "right",
222
- icon: "align-right",
223
- label: "Right"
224
- }
225
- ];
226
- function he(e, t) {
227
- let { views: n, seed: r, forgetSeed: i } = k(Z), a = n[e], o = a?.items ?? pe, s = M(() => [t], [t]), c = O((t) => r(e, t), [r, e]), l = C(s, o, a?.resolveItem, a?.refreshKey, c), u = r(e, t);
228
- A(() => {
229
- u && i(e, t, u);
230
- }, [
231
- i,
232
- e,
233
- t,
234
- u
235
- ]);
236
- let { known: d, failures: f } = l, p = !!a?.resolveItem, m = M(() => w({
237
- selected: s,
238
- items: o,
239
- pageItems: pe,
240
- known: d,
241
- failures: f,
242
- hasResolver: p,
243
- itemLabel: e
244
- })[0], [
245
- s,
246
- o,
247
- d,
248
- f,
249
- p,
250
- e
251
- ]), h = b(`Couldn't load ${e}`, l.status, l.error, l.retry), g = o.some((e) => e.id === t);
252
- return {
253
- view: a,
254
- item: m,
255
- missing: m.tone === "removed" || !g && d.has(t) && !d.get(t),
256
- failure: h
257
- };
258
- }
259
- function ge({ kind: t, isMovable: n, onSelect: r }) {
260
- return /* @__PURE__ */ L("span", {
261
- className: "ds-storyblock__kind",
262
- "data-drag-handle": n ? "" : void 0,
263
- draggable: n || void 0,
264
- title: n ? "Drag to move" : void 0,
265
- onClick: n ? r : void 0,
266
- children: [n && /* @__PURE__ */ I("span", {
267
- className: "ds-storyblock__grip",
268
- "aria-hidden": "true",
269
- children: /* @__PURE__ */ I(e, {
270
- name: "grip-vertical",
271
- size: 16
272
- })
273
- }), /* @__PURE__ */ I(m, {
274
- className: "ds-storyblock__kind-label",
275
- shape: "tag",
276
- size: "sm",
277
- children: t
278
- })]
279
- });
280
- }
281
- function _e({ kind: e, name: n, align: r, isSelected: s, isLocked: c, missing: l, canReplace: u, onEdit: d, onSelect: f, onAlign: m, onReplace: h, onRemove: g }) {
282
- let [_, b] = P(!1), [x, S] = P(!1), C = N(null), w = N(null), T = j(), E = o(_) && !c, D = `Block actions for ${n}`;
283
- _ && c && b(!1), A(() => {
284
- if (!E) return;
285
- w.current?.querySelector("[aria-pressed=\"true\"]")?.focus({ preventScroll: !0 });
286
- let e = (e) => {
287
- let t = e.target;
288
- t instanceof Node && !C.current?.contains(t) && !w.current?.contains(t) && b(!1);
289
- };
290
- return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
291
- }, [E]);
292
- let O = () => {
293
- b(!1), C.current?.focus({ preventScroll: !0 });
294
- };
295
- return /* @__PURE__ */ L("div", {
296
- className: "ds-storyblock__bar ds-field-surface",
297
- onKeyDown: (e) => {
298
- let t = w.current;
299
- if (!E || !t) return;
300
- if (e.key === "Escape" && !e.nativeEvent.isComposing) {
301
- e.preventDefault(), e.stopPropagation(), O();
302
- return;
303
- }
304
- if (e.key !== "Tab" || !(e.target instanceof Node) || !t.contains(e.target)) return;
305
- let n = a(t), r = e.shiftKey ? n[0] : n.at(-1);
306
- e.target === t && !e.shiftKey ? (e.preventDefault(), n[0]?.focus({ preventScroll: !0 })) : (e.target === r || e.target === t) && (e.preventDefault(), e.shiftKey ? O() : (b(!1), i(e.currentTarget)));
307
- },
308
- onBlur: ({ relatedTarget: e }) => {
309
- E && e && e !== C.current && !w.current?.contains(e) && b(!1);
310
- },
311
- children: [
312
- /* @__PURE__ */ I(ge, {
313
- kind: e,
314
- isMovable: !c,
315
- onSelect: f
316
- }),
317
- /* @__PURE__ */ I(t, {
318
- ref: C,
319
- variant: E ? "active" : "simple",
320
- size: "sm",
321
- isIconOnly: !0,
322
- iconStart: "more-horizontal",
323
- isDisabled: c,
324
- tabIndex: !c && (s || x || E) ? 0 : -1,
325
- "aria-label": D,
326
- "aria-haspopup": "dialog",
327
- "aria-expanded": E,
328
- "aria-controls": E ? T : void 0,
329
- onFocus: () => S(!0),
330
- onBlur: () => S(!1),
331
- onClick: () => E ? O() : b(!0)
332
- }),
333
- /* @__PURE__ */ I(v, {
334
- anchorRef: C,
335
- panelRef: w,
336
- isOpen: E,
337
- align: "end",
338
- role: "dialog",
339
- tabIndex: -1,
340
- "aria-label": D,
341
- id: T,
342
- className: "ds-storyblock__popover ds-surface-raised ds-field-surface",
343
- children: /* @__PURE__ */ L("div", {
344
- className: "ds-storyblock__popover-content",
345
- children: [
346
- /* @__PURE__ */ L("div", {
347
- className: "ds-storyblock__popover-section",
348
- children: [/* @__PURE__ */ I("div", {
349
- className: "ds-storyblock__popover-label",
350
- children: "Alignment"
351
- }), /* @__PURE__ */ I(p, {
352
- className: "ds-storyblock__alignment",
353
- "aria-label": "Alignment",
354
- children: me.map((e) => /* @__PURE__ */ I(t, {
355
- size: "sm",
356
- iconStart: e.icon,
357
- "aria-pressed": r === e.align,
358
- variant: r === e.align ? "primary" : "neutral",
359
- onClick: () => m(e.align),
360
- children: e.label
361
- }, e.align))
362
- })]
363
- }),
364
- (d || u.isShown) && /* @__PURE__ */ L("div", {
365
- className: "ds-storyblock__popover-section",
366
- children: [d && /* @__PURE__ */ L(t, {
367
- className: "ds-storyblock__action",
368
- variant: "simple",
369
- size: "md",
370
- iconStart: "pencil",
371
- onClick: () => {
372
- O(), d();
373
- },
374
- children: ["Edit ", e]
375
- }), u.isShown && /* @__PURE__ */ I(t, {
376
- className: "ds-storyblock__action",
377
- variant: "simple",
378
- size: "md",
379
- iconStart: "rotate-cw",
380
- isDisabled: !u.isEnabled,
381
- onClick: () => {
382
- O(), h();
383
- },
384
- children: l ? `Choose another ${e}…` : "Replace…"
385
- })]
386
- }),
387
- /* @__PURE__ */ I(y, {}),
388
- /* @__PURE__ */ I(t, {
389
- className: "ds-storyblock__action",
390
- variant: "danger",
391
- size: "md",
392
- iconStart: "trash",
393
- onClick: () => {
394
- b(!1), g();
395
- },
396
- children: "Remove from field"
397
- })
398
- ]
399
- })
400
- })
401
- ]
402
- });
403
- }
404
- function ve({ kind: e, id: t, item: n, missing: r }) {
405
- return /* @__PURE__ */ I("div", {
406
- className: "ds-entry ds-storyblock__body",
407
- children: r ? /* @__PURE__ */ L("span", {
408
- className: "ds-entry__body",
409
- children: [/* @__PURE__ */ I("em", {
410
- className: "ds-entry__title",
411
- children: `Unavailable ${e}`
412
- }), /* @__PURE__ */ L("span", {
413
- className: "ds-entry__meta",
414
- children: [/* @__PURE__ */ I("span", { children: `This ${e} was deleted. Replace or remove it.` }), /* @__PURE__ */ I("code", { children: t })]
415
- })]
416
- }) : /* @__PURE__ */ I(S, { item: n })
417
- });
418
- }
419
- function ye({ node: e, selected: t, editor: n, getPos: r, updateAttributes: i }) {
420
- let { disabled: a, busy: o, replace: s } = k(Z), c = e.attrs.type, l = String(c === "entry" ? e.attrs.entryId : e.attrs.assetId), { view: u, item: d, missing: f, failure: p } = he(c, l), m = e.attrs.align ?? "full", h = !f && !d.isUnavailable && !d.isDisabled && u?.onEditItem, g = t && !a, _ = () => {
421
- let e = r();
422
- e !== void 0 && n.chain().focus().setNodeSelection(e).run();
423
- };
424
- return /* @__PURE__ */ L(z, {
425
- className: "ds-storyblock ds-field-surface",
426
- "data-align": m,
427
- "data-selected": g || void 0,
428
- "data-missing": f || void 0,
429
- "data-tone": f ? "removed" : d.tone,
430
- contentEditable: !1,
431
- onMouseDown: (e) => {
432
- let t = e.target;
433
- t instanceof Element && e.currentTarget.contains(t) && (t.closest("button") ? e.preventDefault() : !a && !t.closest("[data-drag-handle]") && (e.preventDefault(), _()));
434
- },
435
- children: [
436
- a ? /* @__PURE__ */ I("div", {
437
- className: "ds-storyblock__bar ds-field-surface",
438
- children: /* @__PURE__ */ I(ge, {
439
- kind: c,
440
- isMovable: !1
441
- })
442
- }) : /* @__PURE__ */ I(_e, {
443
- kind: c,
444
- name: f ? `Unavailable ${c}` : d.title,
445
- align: m,
446
- missing: f,
447
- isSelected: g,
448
- isLocked: !!u?.isDialogHidden,
449
- canReplace: {
450
- isShown: !!u?.canEmbed,
451
- isEnabled: !!u?.canEmbed && !o
452
- },
453
- onEdit: h ? () => h(d) : void 0,
454
- onSelect: _,
455
- onAlign: (e) => i({ align: e }),
456
- onReplace: () => {
457
- let e = r();
458
- e !== void 0 && s(c, e);
459
- },
460
- onRemove: () => {
461
- let t = r();
462
- t !== void 0 && n.chain().focus().setNodeSelection(t).deleteRange({
463
- from: t,
464
- to: t + e.nodeSize
465
- }).run();
466
- }
467
- }),
468
- /* @__PURE__ */ I(ve, {
469
- kind: c,
470
- id: l,
471
- item: d,
472
- missing: f
473
- }),
474
- p && /* @__PURE__ */ I("div", {
475
- className: "ds-storyblock__failure",
476
- children: p
477
- })
478
- ]
479
- });
480
- }
481
- //#endregion
482
- //#region src/components/RichTextEditor/use-embeds.tsx
483
- var be = "ds-rte-embed-commit", xe = ["entry", "asset"], Se = {
484
- entry: {
485
- itemLabel: "entry",
486
- itemsLabel: "entries"
487
- },
488
- asset: {
489
- itemLabel: "asset",
490
- itemsLabel: "assets"
491
- }
492
- }, Ce = {}, we = [];
493
- function Q(e, t, n) {
494
- return {
495
- type: e,
496
- align: t,
497
- ...e === "entry" ? {
498
- id: n.modelId,
499
- entryId: n.id
500
- } : { assetId: n.id }
501
- };
502
- }
503
- function Te(e, t) {
504
- if (t.tone === "removed") return {
505
- label: t.removedLabel ?? "Removed",
506
- description: `This ${e} was removed.`
507
- };
508
- if (!W(Q(e, "full", t))) return {
509
- label: "Can't embed",
510
- description: `This ${e} has no ${e === "entry" && !t.modelId?.trim() ? "model API ID" : "ID"}.`
511
- };
512
- }
513
- var Ee = {
514
- entry: (e) => Te("entry", e),
515
- asset: (e) => Te("asset", e)
516
- };
517
- function De(e, t) {
518
- return e?.type.name === "storyblock" && e.attrs.type === t.kind && String(t.kind === "entry" ? e.attrs.entryId : e.attrs.assetId) === t.replaceId;
519
- }
520
- function Oe(e) {
521
- return e.flatMap((e) => e.mapping.maps);
522
- }
523
- function ke(e, t) {
524
- let n = t;
525
- for (let t of Oe(e)) {
526
- let e = n, r;
527
- if (t.forEach((t, n, i, a) => {
528
- r === void 0 && t <= e && e < n && n - t === a - i && (r = i + (e - t));
529
- }), r !== void 0) {
530
- n = r;
531
- continue;
532
- }
533
- let i = t.mapResult(e, 1);
534
- if (i.deletedAfter) return null;
535
- n = i.pos;
536
- }
537
- return n;
538
- }
539
- function Ae(e, t, n) {
540
- let r = t, i = n;
541
- for (let t of Oe(e)) {
542
- if (r === i) {
543
- r = i = t.map(i, -1);
544
- continue;
545
- }
546
- let e = !1;
547
- if (t.forEach((t, n, a, o) => {
548
- let s = i - r === 1 && t === r && n === i && o - a === 1;
549
- e ||= t <= r && i <= n && !s;
550
- }), r = t.map(r, 1), i = t.map(i, -1), e || i <= r) return null;
551
- }
552
- return {
553
- from: r,
554
- to: i
555
- };
556
- }
557
- function je(e, t) {
558
- let n = e.resolve(Math.min(t, e.content.size));
559
- return n.depth ? n.after(1) : n.pos;
560
- }
561
- function Me(e, t, n) {
562
- let r = e !== void 0, i = !!e?.resolveItem, a = !!e?.onEditItem, o = e?.refreshKey, s = e?.items, c = !!e?.isDialogHidden, l = X(e);
563
- return M(() => r ? {
564
- resolveItem: i ? t : void 0,
565
- refreshKey: o,
566
- items: s,
567
- isDialogHidden: c,
568
- canEmbed: l,
569
- onEditItem: a ? n : void 0
570
- } : void 0, [
571
- r,
572
- i,
573
- a,
574
- o,
575
- s,
576
- c,
577
- l,
578
- t,
579
- n
580
- ]);
581
- }
582
- function Ne({ session: e, source: t, disabled: n, label: r, close: i, target: a, pick: o }) {
583
- let { itemLabel: s, itemsLabel: c } = Se[e.kind], l = M(() => e.replaceId ? [e.replaceId] : [], [e]), u = T(l, t.items ?? we, {
584
- ...t,
585
- resolveItem: void 0,
586
- mode: "single"
587
- }, {
588
- isOpen: !0,
589
- isDisabled: n,
590
- itemLabel: s,
591
- itemsLabel: c,
592
- close: i,
593
- restrict: Ee[e.kind]
594
- }), d = e.replaceId ? "Replace" : "Embed";
595
- return /* @__PURE__ */ I(x, {
596
- ...u.dialog,
597
- isOpen: !0,
598
- onClose: i,
599
- onToggle: (e) => {
600
- let t = u.choice(e);
601
- t && o(t, u.revision);
602
- },
603
- addLabel: `${d} ${s}`,
604
- onCreate: t.onCreate ? () => t.onCreate?.(a) : void 0,
605
- isCreating: t.isCreating,
606
- dialogTitle: t.dialogTitle,
607
- dialogDescription: `Choose one ${s} to embed in ${r}. ${t.dialogDescription ?? ""}`.trim(),
608
- isDialogHidden: t.isDialogHidden
609
- });
610
- }
611
- function Pe(e, n = Ce, r, i) {
612
- let [a, o] = P(null), s = N(0), c = N({
613
- session: null,
614
- from: 0,
615
- to: 0,
616
- alive: !1
617
- }), u = N(/* @__PURE__ */ new Map()), [d, f] = P(0), m = O(() => {
618
- c.current.alive = !1, o(null);
619
- }, []), h = a ? n[a.kind] : void 0, g = a && X(h) && (!r || h?.isCreating) ? a : null;
620
- a && !g && o(null);
621
- let _ = !!(g && (h?.isDialogHidden || h?.isCreating)), v = l({
622
- editor: e,
623
- sources: n,
624
- disabled: r,
625
- busy: _
626
- });
627
- A(() => {
628
- if (!e || !a) return;
629
- c.current.alive = !0;
630
- let t = ({ editor: e, transaction: t, appendedTransactions: n }) => {
631
- let r = [t, ...n];
632
- if (!c.current.alive || !r.some((e) => e.docChanged)) return;
633
- let { from: i, to: o } = c.current;
634
- if (a.replaceId === void 0) {
635
- let e = Ae(r, i, o);
636
- e ? Object.assign(c.current, e) : m();
637
- return;
638
- }
639
- let s = ke(r, i);
640
- s === null || !De(e.state.doc.nodeAt(s), a) ? m() : Object.assign(c.current, {
641
- from: s,
642
- to: s + 1
643
- });
644
- };
645
- return e.on("transaction", t), () => {
646
- e.off("transaction", t), c.current.session === a && (c.current.alive = !1);
647
- };
648
- }, [
649
- e,
650
- a,
651
- m
652
- ]);
653
- let y = (e) => {
654
- let { editor: t, sources: n, disabled: r } = v.current, i = n[e.kind];
655
- return !(!t || t.isDestroyed || c.current.session !== e || !c.current.alive || !X(i) || r && !i?.isCreating);
656
- }, b = (e, t, n) => {
657
- let r = v.current.editor;
658
- if (!r || !y(e) || t.isDisabled || t.tone === "removed") return !1;
659
- let { doc: i } = r.state, a = e.replaceId !== void 0, o = a ? i.nodeAt(c.current.from) : null;
660
- if (a && !De(o, e)) return !1;
661
- let s = Q(e.kind, o?.attrs.align ?? "full", t);
662
- if (!W(s)) return !1;
663
- let l = a ? c.current.from : je(i, c.current.to), d = `${e.kind}:${t.id}`;
664
- c.current.alive = !1, u.current = /* @__PURE__ */ new Map([[d, {
665
- item: t,
666
- revision: n
667
- }]]);
668
- let p = !1;
669
- try {
670
- let e = r.chain().focus().setMeta(be, !0);
671
- p = a ? e.setNodeSelection(l).updateAttributes("storyblock", s).run() : e.insertContentAt(l, {
672
- type: "storyblock",
673
- attrs: s
674
- }).setNodeSelection(l).run();
675
- } catch {
676
- p = !1;
677
- } finally {
678
- m();
679
- }
680
- return p ? f((e) => e + 1) : u.current.delete(d), p;
681
- }, x = (e, t) => {
682
- let { editor: n, sources: r, disabled: i, busy: a } = v.current;
683
- if (!n || i || a || !X(r[e])) return;
684
- let l = t === void 0 ? null : n.state.doc.nodeAt(t);
685
- if (t !== void 0 && (l?.type.name !== "storyblock" || l.attrs.type !== e)) return;
686
- let { $from: u, from: d, to: f } = n.state.selection, p = {
687
- id: s.current += 1,
688
- kind: e,
689
- replaceId: l ? String(e === "entry" ? l.attrs.entryId : l.attrs.assetId) : void 0
690
- }, m = t === void 0 ? u.depth ? {
691
- from: u.before(1),
692
- to: u.after(1)
693
- } : {
694
- from: d,
695
- to: f
696
- } : {
697
- from: t,
698
- to: t + 1
699
- };
700
- c.current = {
701
- session: p,
702
- ...m,
703
- alive: !0
704
- }, o(p);
705
- }, S = l({ open: x }), [C] = P(() => ({
706
- replace: (e, t) => S.current.open(e, t),
707
- seed: (e, t) => u.current.get(`${e}:${t}`),
708
- forgetSeed: (e, t, n) => {
709
- u.current.get(`${e}:${t}`) === n && u.current.delete(`${e}:${t}`);
710
- },
711
- resolve: {
712
- entry: (e) => v.current.sources.entry?.resolveItem?.(e) ?? null,
713
- asset: (e) => v.current.sources.asset?.resolveItem?.(e) ?? null
714
- },
715
- edit: {
716
- entry: (e) => {
717
- v.current.sources.entry?.onEditItem?.(e);
718
- },
719
- asset: (e) => {
720
- v.current.sources.asset?.onEditItem?.(e);
721
- }
722
- }
723
- })), w = Me(n.entry, C.resolve.entry, C.edit.entry), T = Me(n.asset, C.resolve.asset, C.edit.asset), E = M(() => ({
724
- views: {
725
- entry: w,
726
- asset: T
727
- },
728
- disabled: r,
729
- busy: _,
730
- pickCount: d,
731
- replace: C.replace,
732
- seed: C.seed,
733
- forgetSeed: C.forgetSeed
734
- }), [
735
- w,
736
- T,
737
- r,
738
- _,
739
- d,
740
- C
741
- ]), D = xe.filter((e) => X(n[e]));
742
- return {
743
- context: E,
744
- isCreating: xe.some((e) => n[e]?.isCreating),
745
- toolbar: D.length > 0 && /* @__PURE__ */ I(p, {
746
- "aria-label": "Embed",
747
- children: D.map((n) => /* @__PURE__ */ I(t, {
748
- size: "sm",
749
- isIconOnly: !0,
750
- iconStart: n === "entry" ? "file-text" : "image",
751
- "aria-label": `Embed ${n}`,
752
- title: `Embed ${n}`,
753
- "aria-pressed": g?.kind === n,
754
- variant: g?.kind === n ? "primary" : "neutral",
755
- isDisabled: r || _ || !e,
756
- onClick: () => x(n)
757
- }, n))
758
- }),
759
- dialog: e && g && h && /* @__PURE__ */ I(Ne, {
760
- session: g,
761
- source: h,
762
- disabled: r,
763
- label: i,
764
- close: m,
765
- target: {
766
- available: () => y(g),
767
- commit: (e) => b(g, e, v.current.sources[g.kind]?.refreshKey)
768
- },
769
- pick: (e, t) => b(g, e, t)
770
- }, g.id)
771
- };
772
- }
773
- //#endregion
774
- //#region src/components/RichTextEditor/index.tsx
775
- function Fe({ editor: e, selection: n, onClose: r }) {
776
- let [i, a] = P(n.href), [o, s] = P(), c = j();
777
- A(() => {
778
- let t = () => {
779
- e.state.doc.eq(n.document) || r();
780
- };
781
- return e.on("transaction", t), () => {
782
- e.off("transaction", t);
783
- };
784
- }, [
785
- e,
786
- n,
787
- r
788
- ]);
789
- let l = () => !e.isDestroyed && e.isEditable && e.state.doc.eq(n.document), u = () => {
790
- if (!l()) {
791
- r();
792
- return;
793
- }
794
- let t = i.trim();
795
- if (!t || !e.can().setLink({ href: t })) {
796
- s(t ? "Enter a valid link URL." : "Enter a link URL.");
797
- return;
798
- }
799
- let a = e.chain().focus().setTextSelection({
800
- from: n.from,
801
- to: n.to
802
- });
803
- n.from === n.to && !n.isEditing ? a.setLink({ href: t }).insertContent({
804
- type: "text",
805
- text: t,
806
- marks: [{
807
- type: "link",
808
- attrs: { href: t }
809
- }]
810
- }).run() : a.setLink({ href: t }).run(), r();
811
- };
812
- return /* @__PURE__ */ I(g, {
813
- isOpen: !0,
814
- title: n.isEditing ? "Edit link" : "Add link",
815
- size: "dialog",
816
- onClose: r,
817
- footer: /* @__PURE__ */ L(ee, { children: [
818
- n.isEditing && /* @__PURE__ */ I(t, {
819
- variant: "danger",
820
- onClick: () => {
821
- l() && e.chain().focus().setTextSelection({
822
- from: n.from,
823
- to: n.to
824
- }).unsetLink().run(), r();
825
- },
826
- children: "Remove link"
827
- }),
828
- /* @__PURE__ */ I(t, {
829
- onClick: r,
830
- children: "Cancel"
831
- }),
832
- /* @__PURE__ */ I(t, {
833
- variant: "primary",
834
- type: "submit",
835
- form: c,
836
- children: "Save"
837
- })
838
- ] }),
839
- children: /* @__PURE__ */ I("form", {
840
- id: c,
841
- noValidate: !0,
842
- onSubmit: (e) => {
843
- e.preventDefault(), e.stopPropagation(), u();
844
- },
845
- children: /* @__PURE__ */ I(h, {
846
- label: "URL",
847
- isRequired: !0,
848
- error: o,
849
- children: (e) => /* @__PURE__ */ I(_, {
850
- ...e,
851
- value: i,
852
- inputMode: "url",
853
- autoComplete: "url",
854
- placeholder: "https://example.com",
855
- onChange: (e) => {
856
- a(e.target.value), s(void 0);
857
- }
858
- })
859
- })
860
- })
861
- });
862
- }
863
- var $ = [
864
- [
865
- {
866
- id: "bold",
867
- icon: "bold",
868
- label: "Bold",
869
- run: (e) => e.chain().focus().toggleBold().run(),
870
- active: (e) => e.isActive("bold")
871
- },
872
- {
873
- id: "italic",
874
- icon: "italic",
875
- label: "Italic",
876
- run: (e) => e.chain().focus().toggleItalic().run(),
877
- active: (e) => e.isActive("italic")
878
- },
879
- {
880
- id: "strike",
881
- icon: "strikethrough",
882
- label: "Strikethrough",
883
- run: (e) => e.chain().focus().toggleStrike().run(),
884
- active: (e) => e.isActive("strike")
885
- },
886
- {
887
- id: "code",
888
- icon: "code",
889
- label: "Inline code",
890
- run: (e) => e.chain().focus().toggleCode().run(),
891
- active: (e) => e.isActive("code")
892
- }
893
- ],
894
- [
895
- {
896
- id: "h2",
897
- icon: "heading-2",
898
- label: "Heading",
899
- run: (e) => e.chain().focus().toggleHeading({ level: 2 }).run(),
900
- active: (e) => e.isActive("heading", { level: 2 })
901
- },
902
- {
903
- id: "h3",
904
- icon: "heading-3",
905
- label: "Subheading",
906
- run: (e) => e.chain().focus().toggleHeading({ level: 3 }).run(),
907
- active: (e) => e.isActive("heading", { level: 3 })
908
- },
909
- {
910
- id: "quote",
911
- icon: "quote",
912
- label: "Quote",
913
- run: (e) => e.chain().focus().toggleBlockquote().run(),
914
- active: (e) => e.isActive("blockquote")
915
- }
916
- ],
917
- [{
918
- id: "ul",
919
- icon: "list",
920
- label: "Bulleted list",
921
- run: (e) => e.chain().focus().toggleBulletList().run(),
922
- active: (e) => e.isActive("bulletList")
923
- }, {
924
- id: "ol",
925
- icon: "list-ordered",
926
- label: "Numbered list",
927
- run: (e) => e.chain().focus().toggleOrderedList().run(),
928
- active: (e) => e.isActive("orderedList")
929
- }],
930
- [{
931
- id: "undo",
932
- icon: "undo",
933
- label: "Undo",
934
- run: (e) => e.chain().focus().undo().run()
935
- }, {
936
- id: "redo",
937
- icon: "redo",
938
- label: "Redo",
939
- run: (e) => e.chain().focus().redo().run()
940
- }]
941
- ];
942
- function Ie({ editor: e, state: n, disabled: r, label: i, toolbarExtra: a, openLink: o, expandControl: s, embedControl: c }) {
943
- return /* @__PURE__ */ L("div", {
944
- className: "ds-rte__toolbar ds-field-surface",
945
- role: "toolbar",
946
- "aria-label": `${i} formatting`,
947
- children: [
948
- $.map((i, a) => /* @__PURE__ */ I(p, {
949
- "aria-label": `Formatting ${a + 1}`,
950
- children: i.map((i) => /* @__PURE__ */ I(t, {
951
- size: "sm",
952
- isIconOnly: !0,
953
- iconStart: i.icon,
954
- "aria-label": i.label,
955
- title: i.label,
956
- "aria-pressed": i.active ? n?.active[i.id] : void 0,
957
- variant: n?.active[i.id] ? "primary" : "neutral",
958
- isDisabled: r || !e,
959
- onClick: () => e && i.run(e)
960
- }, i.id))
961
- }, a)),
962
- /* @__PURE__ */ I(p, {
963
- "aria-label": "Link",
964
- children: /* @__PURE__ */ I(t, {
965
- size: "sm",
966
- isIconOnly: !0,
967
- iconStart: "link",
968
- "aria-label": n?.linkActive ? "Edit link" : "Add link",
969
- title: n?.linkActive ? "Edit link" : "Add link",
970
- variant: n?.linkActive ? "primary" : "neutral",
971
- isDisabled: r || !e,
972
- onClick: () => e && o(e.state, e.isActive("link") ? e.state.selection.from : void 0)
973
- })
974
- }),
975
- c,
976
- a,
977
- s
978
- ]
979
- });
980
- }
981
- var Le = D(function({ scopeRef: e, className: t, expansion: n, isFocused: r, disabled: i, invalid: a, contentError: o, errorId: s, surface: l, children: u }, d) {
982
- return /* @__PURE__ */ I(c.Provider, {
983
- value: e,
984
- children: /* @__PURE__ */ L("div", {
985
- ref: d,
986
- className: ["ds-rte", t].filter(Boolean).join(" "),
987
- style: n.frameStyle,
988
- "data-expanded": n.expanded || void 0,
989
- "data-focused": r && !n.expanded || void 0,
990
- "data-disabled": i || void 0,
991
- "data-invalid": a || void 0,
992
- "aria-invalid": a || void 0,
993
- children: [
994
- o && /* @__PURE__ */ I("p", {
995
- id: s,
996
- role: "alert",
997
- className: "ds-field__error",
998
- children: o
999
- }),
1000
- n.expanded && /* @__PURE__ */ I("p", {
1001
- className: "ds-rte__placeholder",
1002
- children: "Editing in expanded view. Press Esc to return."
1003
- }),
1004
- n.surfaceSlot(/* @__PURE__ */ I("div", {
1005
- className: "ds-rte__surface",
1006
- hidden: !!o,
1007
- "data-expanded": n.expanded || void 0,
1008
- "data-focused": r || void 0,
1009
- "data-disabled": i || void 0,
1010
- "data-invalid": a || void 0,
1011
- children: l
1012
- })),
1013
- n.dialog,
1014
- u
1015
- ]
1016
- })
1017
- });
1018
- }), Re = K.extend({ addNodeView() {
1019
- return B(ye, { update: ({ oldNode: e, newNode: t, updateProps: n }) => e.attrs.type === t.attrs.type && (e !== t && n(), !0) });
1020
- } });
1021
- function ze(e, t) {
1022
- return t.key !== "Escape" || t.isComposing ? !1 : (e.someProp("handleKeyDown", (n) => n(e, t)) && t.preventDefault(), !0);
1023
- }
1024
- var Be = D(function(e, t) {
1025
- let { placeholder: r = "Write something…", size: i = "md", expandedWidth: a = "wide", isDisabled: o = !1, isInvalid: s = !1, label: c = "Rich text editor", className: l, toolbarExtra: u, id: d, isRequired: f, required: p, "aria-label": m, "aria-labelledby": h, "aria-describedby": g, "aria-invalid": _ } = e, v = N(null), y = M(() => n(v, t), [t]), [b, x] = P(!1), [S, C] = P(null), w = O(() => C(null), []), [T] = P(() => e.defaultValue ?? (e.format === "json" ? q : "")), E = e.value === void 0 ? T : e.value, D = M(() => e.format === "json" ? fe(E) : void 0, [e.format, E]), k = j(), F = s || !!D || _, R = o || !!D;
1026
- R && S && C(null);
1027
- let z = O((e, t) => {
1028
- if (R) return;
1029
- let n = t === void 0 ? void 0 : re(e.doc.resolve(t), e.schema.marks.link), r = n && e.doc.nodeAt(n.from)?.marks.find((t) => t.type === e.schema.marks.link);
1030
- C({
1031
- from: n?.from ?? e.selection.from,
1032
- to: n?.to ?? e.selection.to,
1033
- href: r?.attrs.href ?? "",
1034
- isEditing: !!r,
1035
- document: e.doc
1036
- });
1037
- }, [R]), B = M(() => ({
1038
- role: "textbox",
1039
- ...h ? {} : { "aria-label": m ?? c },
1040
- "aria-multiline": "true",
1041
- ...d ? { id: d } : {},
1042
- ...h ? { "aria-labelledby": h } : {},
1043
- ...g ? { "aria-describedby": g } : {},
1044
- ...F ? { "aria-invalid": String(F) } : {},
1045
- ...f || p ? { "aria-required": "true" } : {}
1046
- }), [
1047
- c,
1048
- m,
1049
- d,
1050
- h,
1051
- g,
1052
- F,
1053
- f,
1054
- p
1055
- ]), V = M(() => ({
1056
- attributes: B,
1057
- handleDOMEvents: {
1058
- keydown: ze,
1059
- click: (e, t) => {
1060
- let n = t.target instanceof Element ? t.target.closest("a") : null;
1061
- return !n || !e.dom.contains(n) ? !1 : (t.preventDefault(), e.editable && z(e.state, e.posAtDOM(n, 0)), !0);
1062
- }
1063
- }
1064
- }), [B, z]), H = M(() => [...de(Re), oe.configure({ placeholder: r })], [r]), se = M(() => D ? q : typeof E == "string" ? E : Y(E), [E, D]), U = ie({
1065
- immediatelyRender: !1,
1066
- editable: !R,
1067
- content: se,
1068
- extensions: H,
1069
- editorProps: V,
1070
- onFocus: () => x(!0),
1071
- onBlur: () => x(!1),
1072
- onUpdate: ({ editor: t, transaction: n }) => {
1073
- (!R || n.getMeta("ds-rte-embed-commit")) && (e.format === "json" ? e.onChange?.(G(t.getJSON())) : e.onChange?.(t.getHTML()));
1074
- }
1075
- });
1076
- A(() => {
1077
- U && (U.setEditable(!R, !1), U.setOptions({ editorProps: V }));
1078
- }, [
1079
- U,
1080
- R,
1081
- V
1082
- ]), A(() => {
1083
- if (!U || e.value === void 0 || D) return;
1084
- let t = typeof e.value == "string" ? ne(e.value, U.schema) : U.schema.nodeFromJSON(Y(e.value));
1085
- t.eq(U.state.doc) || U.commands.setContent(t, { emitUpdate: !1 });
1086
- }, [
1087
- U,
1088
- e.value,
1089
- D
1090
- ]);
1091
- let ce = ae({
1092
- editor: U,
1093
- selector: ({ editor: e }) => e ? {
1094
- active: Object.fromEntries($.flat().map((t) => [t.id, t.active?.(e) ?? !1])),
1095
- linkActive: e.isActive("link")
1096
- } : null
1097
- }), W = Pe(U, D ? void 0 : e.embeds, R, c), K = le({
1098
- editor: U,
1099
- disabled: R,
1100
- isHeld: W.isCreating,
1101
- invalid: !!F,
1102
- label: m ?? c,
1103
- labelledBy: h,
1104
- expandedWidth: a,
1105
- frameRef: v
1106
- });
1107
- return /* @__PURE__ */ I(Z.Provider, {
1108
- value: W.context,
1109
- children: /* @__PURE__ */ L(Le, {
1110
- ref: y,
1111
- scopeRef: v,
1112
- className: l,
1113
- expansion: K,
1114
- isFocused: b,
1115
- disabled: R,
1116
- invalid: !!F,
1117
- contentError: D,
1118
- errorId: k,
1119
- surface: /* @__PURE__ */ L(ee, { children: [/* @__PURE__ */ I(Ie, {
1120
- editor: U,
1121
- state: ce,
1122
- disabled: R,
1123
- label: c,
1124
- toolbarExtra: u,
1125
- openLink: z,
1126
- expandControl: K.toggle,
1127
- embedControl: W.toolbar
1128
- }), /* @__PURE__ */ I("div", {
1129
- className: "ds-rte__content ds-field-surface",
1130
- "data-size": i,
1131
- children: /* @__PURE__ */ I(te, { editor: U })
1132
- })] }),
1133
- children: [W.dialog, U && S && !R && /* @__PURE__ */ I(Fe, {
1134
- editor: U,
1135
- selection: S,
1136
- onClose: w
1137
- })]
1138
- })
1139
- });
1140
- });
1141
- //#endregion
1142
- export { fe as n, q as r, Be as t };
1143
-
1144
- //# sourceMappingURL=RichTextEditor-BFblqw8m.js.map