@namroodinc/liquid-editorial 0.14.0 → 0.16.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 (271) hide show
  1. package/README.md +283 -12
  2. package/UPGRADING.md +106 -0
  3. package/dist/chunks/{Avatar-Dw7EWd_-.cjs → Avatar-BZGFSE6C.cjs} +2 -2
  4. package/dist/chunks/{Avatar-Dw7EWd_-.cjs.map → Avatar-BZGFSE6C.cjs.map} +1 -1
  5. package/dist/chunks/{Avatar-BToMaTdL.js → Avatar-C4W-g8nU.js} +2 -2
  6. package/dist/chunks/{Avatar-BToMaTdL.js.map → Avatar-C4W-g8nU.js.map} +1 -1
  7. package/dist/chunks/{Board-XeDG9nWP.js → Board-Cbi5FMW-.js} +2 -2
  8. package/dist/chunks/{Board-XeDG9nWP.js.map → Board-Cbi5FMW-.js.map} +1 -1
  9. package/dist/chunks/{Board-DeXtaWNO.cjs → Board-_agEjTy8.cjs} +2 -2
  10. package/dist/chunks/{Board-DeXtaWNO.cjs.map → Board-_agEjTy8.cjs.map} +1 -1
  11. package/dist/chunks/{CollectionView-Dbg4d_tA.cjs → CollectionView-BfX2Lxre.cjs} +2 -2
  12. package/dist/chunks/{CollectionView-Dbg4d_tA.cjs.map → CollectionView-BfX2Lxre.cjs.map} +1 -1
  13. package/dist/chunks/{CollectionView-C0_bTO2v.js → CollectionView-DPJGtSP5.js} +2 -2
  14. package/dist/chunks/{CollectionView-C0_bTO2v.js.map → CollectionView-DPJGtSP5.js.map} +1 -1
  15. package/dist/chunks/{ColourField-DAFzOIOq.cjs → ColourField-BVGnW8Wh.cjs} +2 -2
  16. package/dist/chunks/{ColourField-DAFzOIOq.cjs.map → ColourField-BVGnW8Wh.cjs.map} +1 -1
  17. package/dist/chunks/{ColourField-Bb8H87fg.js → ColourField-BcuARZY4.js} +6 -6
  18. package/dist/chunks/{ColourField-Bb8H87fg.js.map → ColourField-BcuARZY4.js.map} +1 -1
  19. package/dist/chunks/{DatePicker-COm1giw8.js → DatePicker-VQUsbYdo.js} +3 -3
  20. package/dist/chunks/{DatePicker-COm1giw8.js.map → DatePicker-VQUsbYdo.js.map} +1 -1
  21. package/dist/chunks/{DatePicker-DOg3iQYy.cjs → DatePicker-zA0bWVBp.cjs} +2 -2
  22. package/dist/chunks/{DatePicker-DOg3iQYy.cjs.map → DatePicker-zA0bWVBp.cjs.map} +1 -1
  23. package/dist/chunks/{Drawer-nUTJtwX_.js → Drawer-2cf0SaG4.js} +3 -3
  24. package/dist/chunks/{Drawer-nUTJtwX_.js.map → Drawer-2cf0SaG4.js.map} +1 -1
  25. package/dist/chunks/{Drawer-B2dcTh5l.cjs → Drawer-BzvSfkCL.cjs} +2 -2
  26. package/dist/chunks/{Drawer-B2dcTh5l.cjs.map → Drawer-BzvSfkCL.cjs.map} +1 -1
  27. package/dist/chunks/EntryPicker-C7EBfpaw.cjs +2 -0
  28. package/dist/chunks/EntryPicker-C7EBfpaw.cjs.map +1 -0
  29. package/dist/chunks/{EntryPicker-Ie9T47hA.js → EntryPicker-DBnDsgzi.js} +397 -397
  30. package/dist/chunks/EntryPicker-DBnDsgzi.js.map +1 -0
  31. package/dist/chunks/FormEditor-BG8bOXI8.js +35 -0
  32. package/dist/chunks/FormEditor-BG8bOXI8.js.map +1 -0
  33. package/dist/chunks/FormEditor-BJN0QuLI.cjs +2 -0
  34. package/dist/chunks/FormEditor-BJN0QuLI.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-VJTPhId7.js → Message-DM6pTq7N.js} +2 -2
  40. package/dist/chunks/{Message-VJTPhId7.js.map → Message-DM6pTq7N.js.map} +1 -1
  41. package/dist/chunks/{Message-B0A5bz8V.cjs → Message-yZJDVzb8.cjs} +2 -2
  42. package/dist/chunks/{Message-B0A5bz8V.cjs.map → Message-yZJDVzb8.cjs.map} +1 -1
  43. package/dist/chunks/{NumberField-C90eJGny.js → NumberField-CVsK4l9P.js} +13 -13
  44. package/dist/chunks/{NumberField-C90eJGny.js.map → NumberField-CVsK4l9P.js.map} +1 -1
  45. package/dist/chunks/{NumberField-BrWFmPkW.cjs → NumberField-Ccjpa_1d.cjs} +2 -2
  46. package/dist/chunks/{NumberField-BrWFmPkW.cjs.map → NumberField-Ccjpa_1d.cjs.map} +1 -1
  47. package/dist/chunks/RichTextEditor-D4rNww9d.cjs +2 -0
  48. package/dist/chunks/RichTextEditor-D4rNww9d.cjs.map +1 -0
  49. package/dist/chunks/RichTextEditor-DSxiMLVd.js +2832 -0
  50. package/dist/chunks/RichTextEditor-DSxiMLVd.js.map +1 -0
  51. package/dist/chunks/dialogLabel-Dx-WEEzI.cjs +2 -0
  52. package/dist/chunks/dialogLabel-Dx-WEEzI.cjs.map +1 -0
  53. package/dist/chunks/dialogLabel-nB1gwKz0.js +157 -0
  54. package/dist/chunks/dialogLabel-nB1gwKz0.js.map +1 -0
  55. package/dist/chunks/overlayLayer-CPd3zj_u.cjs +2 -0
  56. package/dist/chunks/overlayLayer-CPd3zj_u.cjs.map +1 -0
  57. package/dist/chunks/overlayLayer-Dv1vmfaI.js +199 -0
  58. package/dist/chunks/overlayLayer-Dv1vmfaI.js.map +1 -0
  59. package/dist/chunks/{useTooltip-Du8PutGX.js → useTooltip-COyAcujL.js} +2 -2
  60. package/dist/chunks/{useTooltip-Du8PutGX.js.map → useTooltip-COyAcujL.js.map} +1 -1
  61. package/dist/chunks/{useTooltip-ekdwMJFz.cjs → useTooltip-nEDN0ObI.cjs} +2 -2
  62. package/dist/chunks/{useTooltip-ekdwMJFz.cjs.map → useTooltip-nEDN0ObI.cjs.map} +1 -1
  63. package/dist/components/AppShell/index.cjs +1 -1
  64. package/dist/components/AppShell/index.js +1 -1
  65. package/dist/components/AssetCard/index.cjs +1 -1
  66. package/dist/components/AssetCard/index.js +1 -1
  67. package/dist/components/AssetGrid/index.cjs +1 -1
  68. package/dist/components/AssetGrid/index.js +1 -1
  69. package/dist/components/Avatar/index.cjs +1 -1
  70. package/dist/components/Avatar/index.js +1 -1
  71. package/dist/components/Banner/index.cjs +1 -1
  72. package/dist/components/Banner/index.js +1 -1
  73. package/dist/components/Board/index.cjs +1 -1
  74. package/dist/components/Board/index.js +1 -1
  75. package/dist/components/Button/index.cjs +1 -1
  76. package/dist/components/Button/index.js +1 -1
  77. package/dist/components/Choice/index.cjs +1 -1
  78. package/dist/components/Choice/index.cjs.map +1 -1
  79. package/dist/components/Choice/index.js +5 -5
  80. package/dist/components/CollectionView/index.cjs +1 -1
  81. package/dist/components/CollectionView/index.js +1 -1
  82. package/dist/components/ColourField/index.cjs +1 -1
  83. package/dist/components/ColourField/index.js +1 -1
  84. package/dist/components/DatePicker/index.cjs +1 -1
  85. package/dist/components/DatePicker/index.js +1 -1
  86. package/dist/components/Drawer/index.cjs +1 -1
  87. package/dist/components/Drawer/index.js +1 -1
  88. package/dist/components/EditLayout/index.cjs +1 -1
  89. package/dist/components/EditLayout/index.cjs.map +1 -1
  90. package/dist/components/EditLayout/index.js +6 -7
  91. package/dist/components/EditLayout/index.js.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/FormEditor/README.md +205 -178
  96. package/dist/components/FormEditor/control.d.cts +4 -4
  97. package/dist/components/FormEditor/control.d.cts.map +1 -1
  98. package/dist/components/FormEditor/control.d.ts +4 -4
  99. package/dist/components/FormEditor/control.d.ts.map +1 -1
  100. package/dist/components/FormEditor/form.d.cts +3 -3
  101. package/dist/components/FormEditor/form.d.cts.map +1 -1
  102. package/dist/components/FormEditor/form.d.ts +3 -3
  103. package/dist/components/FormEditor/form.d.ts.map +1 -1
  104. package/dist/components/FormEditor/index.cjs +1 -1
  105. package/dist/components/FormEditor/index.js +2 -2
  106. package/dist/components/FormEditor/model.d.cts +2 -0
  107. package/dist/components/FormEditor/model.d.cts.map +1 -1
  108. package/dist/components/FormEditor/model.d.ts +2 -0
  109. package/dist/components/FormEditor/model.d.ts.map +1 -1
  110. package/dist/components/FormEditor/rich-text-control.d.cts +1 -2
  111. package/dist/components/FormEditor/rich-text-control.d.cts.map +1 -1
  112. package/dist/components/FormEditor/rich-text-control.d.ts +1 -2
  113. package/dist/components/FormEditor/rich-text-control.d.ts.map +1 -1
  114. package/dist/components/Icon/icons.d.cts +5 -0
  115. package/dist/components/Icon/icons.d.cts.map +1 -1
  116. package/dist/components/Icon/icons.d.ts +5 -0
  117. package/dist/components/Icon/icons.d.ts.map +1 -1
  118. package/dist/components/Icon/index.cjs +1 -1
  119. package/dist/components/Icon/index.js +1 -1
  120. package/dist/components/ImageCropper/index.cjs +1 -1
  121. package/dist/components/ImageCropper/index.cjs.map +1 -1
  122. package/dist/components/ImageCropper/index.js +6 -6
  123. package/dist/components/Menu/index.cjs +1 -1
  124. package/dist/components/Menu/index.js +9 -9
  125. package/dist/components/Menu/index.js.map +1 -1
  126. package/dist/components/Modal/index.cjs +1 -1
  127. package/dist/components/Modal/index.js +2 -2
  128. package/dist/components/NumberField/index.cjs +1 -1
  129. package/dist/components/NumberField/index.js +1 -1
  130. package/dist/components/Popover/index.cjs +1 -1
  131. package/dist/components/Popover/index.cjs.map +1 -1
  132. package/dist/components/Popover/index.d.cts.map +1 -1
  133. package/dist/components/Popover/index.d.ts.map +1 -1
  134. package/dist/components/Popover/index.js +67 -64
  135. package/dist/components/Popover/index.js.map +1 -1
  136. package/dist/components/RichTextEditor/block-plugins.d.cts +62 -0
  137. package/dist/components/RichTextEditor/block-plugins.d.cts.map +1 -0
  138. package/dist/components/RichTextEditor/block-plugins.d.ts +62 -0
  139. package/dist/components/RichTextEditor/block-plugins.d.ts.map +1 -0
  140. package/dist/components/RichTextEditor/content-block-frame.d.cts +32 -0
  141. package/dist/components/RichTextEditor/content-block-frame.d.cts.map +1 -0
  142. package/dist/components/RichTextEditor/content-block-frame.d.ts +32 -0
  143. package/dist/components/RichTextEditor/content-block-frame.d.ts.map +1 -0
  144. package/dist/components/RichTextEditor/content-block-view.d.cts +3 -0
  145. package/dist/components/RichTextEditor/content-block-view.d.cts.map +1 -0
  146. package/dist/components/RichTextEditor/content-block-view.d.ts +3 -0
  147. package/dist/components/RichTextEditor/content-block-view.d.ts.map +1 -0
  148. package/dist/components/RichTextEditor/content-block.d.cts +10 -0
  149. package/dist/components/RichTextEditor/content-block.d.cts.map +1 -0
  150. package/dist/components/RichTextEditor/content-block.d.ts +10 -0
  151. package/dist/components/RichTextEditor/content-block.d.ts.map +1 -0
  152. package/dist/components/RichTextEditor/document.d.cts +24 -8
  153. package/dist/components/RichTextEditor/document.d.cts.map +1 -1
  154. package/dist/components/RichTextEditor/document.d.ts +24 -8
  155. package/dist/components/RichTextEditor/document.d.ts.map +1 -1
  156. package/dist/components/RichTextEditor/index.cjs +1 -1
  157. package/dist/components/RichTextEditor/index.d.cts +6 -4
  158. package/dist/components/RichTextEditor/index.d.cts.map +1 -1
  159. package/dist/components/RichTextEditor/index.d.ts +6 -4
  160. package/dist/components/RichTextEditor/index.d.ts.map +1 -1
  161. package/dist/components/RichTextEditor/index.js +1 -1
  162. package/dist/components/RichTextEditor/picker-block.d.cts +25 -0
  163. package/dist/components/RichTextEditor/picker-block.d.cts.map +1 -0
  164. package/dist/components/RichTextEditor/picker-block.d.ts +25 -0
  165. package/dist/components/RichTextEditor/picker-block.d.ts.map +1 -0
  166. package/dist/components/RichTextEditor/style.css +126 -49
  167. package/dist/components/RichTextEditor/table-actions.d.cts +11 -0
  168. package/dist/components/RichTextEditor/table-actions.d.cts.map +1 -0
  169. package/dist/components/RichTextEditor/table-actions.d.ts +11 -0
  170. package/dist/components/RichTextEditor/table-actions.d.ts.map +1 -0
  171. package/dist/components/RichTextEditor/table-bands.d.cts +19 -0
  172. package/dist/components/RichTextEditor/table-bands.d.cts.map +1 -0
  173. package/dist/components/RichTextEditor/table-bands.d.ts +19 -0
  174. package/dist/components/RichTextEditor/table-bands.d.ts.map +1 -0
  175. package/dist/components/RichTextEditor/table-view.d.cts +4 -0
  176. package/dist/components/RichTextEditor/table-view.d.cts.map +1 -0
  177. package/dist/components/RichTextEditor/table-view.d.ts +4 -0
  178. package/dist/components/RichTextEditor/table-view.d.ts.map +1 -0
  179. package/dist/components/RichTextEditor/tables.d.cts.map +1 -1
  180. package/dist/components/RichTextEditor/tables.d.ts.map +1 -1
  181. package/dist/components/RichTextEditor/use-blocks.d.cts +19 -0
  182. package/dist/components/RichTextEditor/use-blocks.d.cts.map +1 -0
  183. package/dist/components/RichTextEditor/use-blocks.d.ts +19 -0
  184. package/dist/components/RichTextEditor/use-blocks.d.ts.map +1 -0
  185. package/dist/components/SearchField/index.cjs +1 -1
  186. package/dist/components/SearchField/index.js +1 -1
  187. package/dist/components/Select/index.cjs +1 -1
  188. package/dist/components/Select/index.js +2 -2
  189. package/dist/components/SelectionCard/index.cjs +1 -1
  190. package/dist/components/SelectionCard/index.cjs.map +1 -1
  191. package/dist/components/SelectionCard/index.js +4 -4
  192. package/dist/components/SelectionCard/index.js.map +1 -1
  193. package/dist/components/SideNav/index.cjs +1 -1
  194. package/dist/components/SideNav/index.js +1 -1
  195. package/dist/components/SortableList/index.cjs +1 -1
  196. package/dist/components/SortableList/index.js +1 -1
  197. package/dist/components/Stepper/index.cjs +1 -1
  198. package/dist/components/Stepper/index.js +1 -1
  199. package/dist/components/SubNav/index.cjs +1 -1
  200. package/dist/components/SubNav/index.js +1 -1
  201. package/dist/components/Switch/style.css +2 -6
  202. package/dist/components/Table/index.cjs +1 -1
  203. package/dist/components/Table/index.js +1 -1
  204. package/dist/components/Time/index.cjs +1 -1
  205. package/dist/components/Time/index.js +1 -1
  206. package/dist/components/Toast/index.cjs +1 -1
  207. package/dist/components/Toast/index.js +1 -1
  208. package/dist/components/TopNav/index.cjs +1 -1
  209. package/dist/components/TopNav/index.js +1 -1
  210. package/dist/index.cjs +1 -1
  211. package/dist/index.d.cts +2 -2
  212. package/dist/index.d.cts.map +1 -1
  213. package/dist/index.d.ts +2 -2
  214. package/dist/index.d.ts.map +1 -1
  215. package/dist/index.js +49 -49
  216. package/dist/internal/useStableValue.d.cts +8 -0
  217. package/dist/internal/useStableValue.d.cts.map +1 -0
  218. package/dist/internal/useStableValue.d.ts +8 -0
  219. package/dist/internal/useStableValue.d.ts.map +1 -0
  220. package/dist/rich-text-blocks.cjs +2 -0
  221. package/dist/rich-text-blocks.cjs.map +1 -0
  222. package/dist/rich-text-blocks.d.cts +20 -0
  223. package/dist/rich-text-blocks.d.cts.map +1 -0
  224. package/dist/rich-text-blocks.d.ts +20 -0
  225. package/dist/rich-text-blocks.d.ts.map +1 -0
  226. package/dist/rich-text-blocks.js +36 -0
  227. package/dist/rich-text-blocks.js.map +1 -0
  228. package/package.json +14 -1
  229. package/dist/chunks/EntryPicker-BwEYRtQl.cjs +0 -2
  230. package/dist/chunks/EntryPicker-BwEYRtQl.cjs.map +0 -1
  231. package/dist/chunks/EntryPicker-Ie9T47hA.js.map +0 -1
  232. package/dist/chunks/FormEditor-D1HUnjMI.cjs +0 -2
  233. package/dist/chunks/FormEditor-D1HUnjMI.cjs.map +0 -1
  234. package/dist/chunks/FormEditor-DgDV5aeR.js +0 -30
  235. package/dist/chunks/FormEditor-DgDV5aeR.js.map +0 -1
  236. package/dist/chunks/Icon-Bxvp1-td.js +0 -102
  237. package/dist/chunks/Icon-Bxvp1-td.js.map +0 -1
  238. package/dist/chunks/Icon-CnnTrtNb.cjs +0 -2
  239. package/dist/chunks/Icon-CnnTrtNb.cjs.map +0 -1
  240. package/dist/chunks/RichTextEditor-DPhEkDxi.js +0 -2108
  241. package/dist/chunks/RichTextEditor-DPhEkDxi.js.map +0 -1
  242. package/dist/chunks/RichTextEditor-DV7NZp_k.cjs +0 -2
  243. package/dist/chunks/RichTextEditor-DV7NZp_k.cjs.map +0 -1
  244. package/dist/chunks/dialogLabel-C153NosD.js +0 -176
  245. package/dist/chunks/dialogLabel-C153NosD.js.map +0 -1
  246. package/dist/chunks/dialogLabel-CNNQbtob.cjs +0 -2
  247. package/dist/chunks/dialogLabel-CNNQbtob.cjs.map +0 -1
  248. package/dist/chunks/overlayLayer-CtOTt1xB.cjs +0 -2
  249. package/dist/chunks/overlayLayer-CtOTt1xB.cjs.map +0 -1
  250. package/dist/chunks/overlayLayer-Og07sIyl.js +0 -180
  251. package/dist/chunks/overlayLayer-Og07sIyl.js.map +0 -1
  252. package/dist/components/RichTextEditor/embed-context.d.cts +0 -41
  253. package/dist/components/RichTextEditor/embed-context.d.cts.map +0 -1
  254. package/dist/components/RichTextEditor/embed-context.d.ts +0 -41
  255. package/dist/components/RichTextEditor/embed-context.d.ts.map +0 -1
  256. package/dist/components/RichTextEditor/embed-types.d.cts +0 -29
  257. package/dist/components/RichTextEditor/embed-types.d.cts.map +0 -1
  258. package/dist/components/RichTextEditor/embed-types.d.ts +0 -29
  259. package/dist/components/RichTextEditor/embed-types.d.ts.map +0 -1
  260. package/dist/components/RichTextEditor/storyblock-view.d.cts +0 -3
  261. package/dist/components/RichTextEditor/storyblock-view.d.cts.map +0 -1
  262. package/dist/components/RichTextEditor/storyblock-view.d.ts +0 -3
  263. package/dist/components/RichTextEditor/storyblock-view.d.ts.map +0 -1
  264. package/dist/components/RichTextEditor/storyblock.d.cts +0 -19
  265. package/dist/components/RichTextEditor/storyblock.d.cts.map +0 -1
  266. package/dist/components/RichTextEditor/storyblock.d.ts +0 -19
  267. package/dist/components/RichTextEditor/storyblock.d.ts.map +0 -1
  268. package/dist/components/RichTextEditor/use-embeds.d.cts +0 -31
  269. package/dist/components/RichTextEditor/use-embeds.d.cts.map +0 -1
  270. package/dist/components/RichTextEditor/use-embeds.d.ts +0 -31
  271. package/dist/components/RichTextEditor/use-embeds.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_Fragment","Icon","Drawer","mergeRefs","cannotHoldFocus","createMovableHost","useIsomorphicLayoutEffect","observeElementWidth","Fragment$1","TIGHT_WIDTH","COMPACT_WIDTH","WIDE_WIDTH","layoutMode","width","statusLabels","statusIcons","relabelledStates","hasContent","node","SaveStatus","icon","saveState","custom","statusLabel","savedAgo","LeaveConfirmation","keepRef","useRef","origin","useEffect","frame","text","Button","onKeepEditing","bodyRef","EditActionBar","compact","backLabel","onBack","confirmLeave","confirmation","status","onLeave","actions","detailsToggle","DetailsRail","label","expanded","toggleRef","sheetOpen","detailsId","opensSheet","onToggle","contentRef","collapsed","EditLayout","forwardRef","rest","rootRef","mergedRef","useMemo","ref","railSlotRef","sheetSlotRef","lastFocus","railHost","useState","mode","setMode","localOpen","setLocalOpen","defaultRailOpen","sheet","setSheet","animate","setAnimate","useId","narrow","railOpen","current","next","moveHost","last","toggle","onRailToggle","railContent","rail","flushSync","className","event","onFocus","confirmText","railLabel","railCollapsed","createPortal"],"sources":["../../../src/components/EditLayout/index.tsx"],"sourcesContent":["import {\n forwardRef,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n type HTMLAttributes,\n type ReactNode,\n type RefObject,\n} from \"react\";\nimport { createPortal, flushSync } from \"react-dom\";\nimport { useIsomorphicLayoutEffect } from \"../../internal/useIsomorphicLayoutEffect\";\nimport { Button } from \"../Button\";\nimport { Drawer } from \"../Drawer\";\nimport { Icon } from \"../Icon\";\nimport type { IconName } from \"../Icon/icons\";\nimport { mergeRefs } from \"../../internal/mergeRefs\";\nimport { observeElementWidth } from \"../../internal/observeElementWidth\";\nimport { cannotHoldFocus } from \"../../internal/dialogFocus\";\nimport { createMovableHost, moveHost } from \"../../internal/movableHost\";\nimport \"./style.css\";\n\nexport type EditSaveState = \"clean\" | \"dirty\" | \"saving\" | \"saved\" | \"error\" | \"offline\";\n\nexport interface EditLayoutProps extends HTMLAttributes<HTMLDivElement> {\n backLabel: string;\n onBack: () => void;\n saveState?: EditSaveState;\n /**\n * Replaces the `clean` or `dirty` message, for example on a read-only record.\n * Saving, saved, error and offline keep their standard messages, and\n * `saveState` always controls the indicator and colour. Empty values are ignored.\n */\n statusLabel?: ReactNode;\n savedAgo?: ReactNode;\n actions?: ReactNode;\n /** A render slot can close the Details sheet before opening another dialog. */\n rail: ReactNode | ((closeDetails: () => void) => ReactNode);\n /** Custom collapsed controls receive the accessible expand action. */\n railCollapsed?: (expand: () => void) => ReactNode;\n railLabel?: string;\n railOpen?: boolean;\n defaultRailOpen?: boolean;\n onRailToggle?: (open: boolean) => void;\n confirmLeave?: boolean;\n confirmText?: string;\n onKeepEditing?: () => void;\n onLeave?: () => void;\n children?: ReactNode;\n}\n\n/** Below this width, the action bar's gaps and padding contract. */\nconst TIGHT_WIDTH = 360;\n/** Below this width, Details opens from the action bar. */\nconst COMPACT_WIDTH = 600;\n/** From this width, the rail follows the open/closed preference. */\nconst WIDE_WIDTH = 900;\n\ntype LayoutMode = \"tight\" | \"compact\" | \"narrow\" | \"wide\";\n\nfunction layoutMode(width: number): LayoutMode {\n if (width < TIGHT_WIDTH) {\n return \"tight\";\n }\n if (width < COMPACT_WIDTH) {\n return \"compact\";\n }\n if (width < WIDE_WIDTH) {\n return \"narrow\";\n }\n return \"wide\";\n}\n\nconst statusLabels: Record<EditSaveState, string> = {\n clean: \"No changes\",\n dirty: \"Unsaved changes\",\n saving: \"Saving…\",\n saved: \"Saved\",\n error: \"Couldn't save\",\n offline: \"Offline · kept in this tab\",\n};\n\nconst statusIcons: Record<EditSaveState, IconName | undefined> = {\n clean: undefined,\n dirty: undefined,\n saving: \"spinner\",\n saved: \"check\",\n error: \"alert-triangle\",\n offline: \"clock\",\n};\n\n/** Save progress, outcomes and connection loss always keep their standard messages. */\nconst relabelledStates: ReadonlySet<EditSaveState> = new Set([\"clean\", \"dirty\"]);\n\nfunction hasContent(node: ReactNode) {\n if (typeof node === \"string\") {\n return node.trim() !== \"\";\n }\n return node !== null && node !== undefined && typeof node !== \"boolean\";\n}\n\ninterface SaveStatusProps {\n saveState: EditSaveState;\n statusLabel?: ReactNode;\n savedAgo?: ReactNode;\n}\n\nfunction SaveStatus({ saveState, savedAgo, statusLabel }: SaveStatusProps) {\n const icon = statusIcons[saveState];\n const custom =\n relabelledStates.has(saveState) && hasContent(statusLabel) ? statusLabel : undefined;\n return (\n <div\n className=\"ds-edit-layout__status\"\n data-state={saveState}\n role=\"status\"\n aria-live=\"polite\"\n >\n {icon && (\n <Icon\n name={icon}\n className={saveState === \"saving\" ? \"ds-icon--spin\" : undefined}\n />\n )}\n {saveState === \"dirty\" && (\n <span\n className=\"ds-edit-layout__dirty\"\n aria-hidden=\"true\"\n />\n )}\n {/* The title recovers a custom string clipped beyond two lines. */}\n <span title={typeof custom === \"string\" ? custom : undefined}>\n {custom ?? statusLabels[saveState]}\n {saveState === \"saved\" && savedAgo ? <> {savedAgo}</> : null}\n </span>\n </div>\n );\n}\n\ninterface LeaveConfirmationProps {\n text: string;\n /** Keep editing falls back to the first control here when its origin is gone. */\n bodyRef: RefObject<HTMLDivElement | null>;\n onKeepEditing?: () => void;\n}\n\n/** Takes focus while shown; Keep editing returns it to where the user was. */\nfunction LeaveConfirmation({ text, bodyRef, onKeepEditing }: LeaveConfirmationProps) {\n const keepRef = useRef<HTMLButtonElement>(null);\n const origin = useRef<HTMLElement | null>(null);\n\n useEffect(() => {\n origin.current = document.activeElement as HTMLElement | null;\n const frame = requestAnimationFrame(() => keepRef.current?.focus({ preventScroll: true }));\n return () => cancelAnimationFrame(frame);\n }, []);\n\n const keepEditing = () => {\n onKeepEditing?.();\n requestAnimationFrame(() => {\n const destination = origin.current?.isConnected\n ? origin.current\n : bodyRef.current?.querySelector<HTMLElement>(\n \"input, textarea, button, [contenteditable='true']\",\n );\n destination?.focus({ preventScroll: true });\n });\n };\n\n return (\n <div className=\"ds-edit-layout__confirmation\">\n <strong>{text}</strong>\n <Button\n ref={keepRef}\n size=\"xs\"\n onClick={keepEditing}\n >\n Keep editing\n </Button>\n </div>\n );\n}\n\ninterface EditActionBarProps {\n backLabel: string;\n onBack: () => void;\n compact: boolean;\n status: ReactNode;\n actions?: ReactNode;\n /** Replaces the status and actions while set. */\n confirmLeave: boolean;\n confirmation: ReactNode;\n onLeave?: () => void;\n /** Shown only in compact layouts, where Details opens as a sheet. */\n detailsToggle: ReactNode;\n}\n\nfunction EditActionBar({\n backLabel,\n onBack,\n compact,\n status,\n actions,\n confirmLeave,\n confirmation,\n onLeave,\n detailsToggle,\n}: EditActionBarProps) {\n return (\n <header className=\"ds-edit-layout__bar\">\n <Button\n variant=\"simple\"\n size=\"sm\"\n iconStart=\"arrow-left\"\n isIconOnly={compact}\n aria-label={`Back to ${backLabel}`}\n onClick={onBack}\n >\n {backLabel}\n </Button>\n {confirmLeave ? confirmation : status}\n <div className=\"ds-edit-layout__actions\">\n {confirmLeave ? (\n <Button\n variant=\"danger\"\n size=\"sm\"\n onClick={onLeave}\n >\n Leave anyway\n </Button>\n ) : (\n actions\n )}\n {compact && detailsToggle}\n </div>\n </header>\n );\n}\n\ninterface DetailsRailProps {\n label: string;\n detailsId: string;\n expanded: boolean;\n /** Below the wide breakpoint, the toggle opens the Details sheet instead. */\n opensSheet: boolean;\n sheetOpen: boolean;\n toggleRef: RefObject<HTMLButtonElement | null>;\n /** Receives the rail content while the rail is expanded. */\n contentRef: RefObject<HTMLDivElement | null>;\n collapsed?: (expand: () => void) => ReactNode;\n onToggle: () => void;\n}\n\nfunction DetailsRail({\n label,\n detailsId,\n expanded,\n opensSheet,\n sheetOpen,\n toggleRef,\n contentRef,\n collapsed,\n onToggle,\n}: DetailsRailProps) {\n return (\n <aside\n className=\"ds-edit-layout__rail ds-field-surface\"\n aria-label={label}\n >\n <header className=\"ds-edit-layout__rail-head\">\n {expanded && <span>{label}</span>}\n <Button\n ref={toggleRef}\n variant=\"simple\"\n size=\"sm\"\n isIconOnly\n iconStart={expanded ? \"chevrons-right\" : \"chevrons-left\"}\n className=\"ds-edit-layout__toggle\"\n aria-label={`${expanded ? \"Collapse\" : \"Expand\"} ${label}`}\n aria-expanded={expanded || sheetOpen}\n aria-controls={detailsId}\n aria-haspopup={opensSheet ? \"dialog\" : undefined}\n onClick={onToggle}\n />\n </header>\n {expanded ? (\n <div\n id={detailsId}\n ref={contentRef}\n className=\"ds-edit-layout__rail-content\"\n />\n ) : (\n <div className=\"ds-edit-layout__rail-icons\">\n {collapsed ? (\n collapsed(onToggle)\n ) : (\n <Button\n variant=\"simple\"\n size=\"sm\"\n isIconOnly\n iconStart=\"info\"\n aria-label={`Show ${label}`}\n onClick={onToggle}\n />\n )}\n </div>\n )}\n </aside>\n );\n}\n\n/** Presentation only: the consumer owns saving, routing and persisted preferences. */\nexport const EditLayout = forwardRef<HTMLDivElement, EditLayoutProps>(function EditLayout(\n {\n backLabel,\n onBack,\n saveState = \"clean\",\n statusLabel,\n savedAgo,\n actions,\n rail,\n railCollapsed,\n railLabel = \"Details\",\n railOpen,\n defaultRailOpen = true,\n onRailToggle,\n confirmLeave = false,\n confirmText = \"Leave without saving?\",\n onKeepEditing,\n onLeave,\n children,\n className,\n onFocus,\n ...rest\n },\n ref,\n) {\n const rootRef = useRef<HTMLDivElement>(null);\n const mergedRef = useMemo(() => mergeRefs(rootRef, ref), [ref]);\n const bodyRef = useRef<HTMLDivElement>(null);\n const toggleRef = useRef<HTMLButtonElement>(null);\n const railSlotRef = useRef<HTMLDivElement>(null);\n const sheetSlotRef = useRef<HTMLDivElement>(null);\n const lastFocus = useRef<Element | null>(null);\n // Rail content renders once, into a node that moves between the rail and\n // the sheet, so uncontrolled fields keep their values across modes.\n const [railHost] = useState(() => createMovableHost(\"ds-edit-layout__rail-host\"));\n const [mode, setMode] = useState<LayoutMode>(\"wide\");\n const [localOpen, setLocalOpen] = useState(defaultRailOpen);\n const [sheet, setSheet] = useState(false);\n const [animate, setAnimate] = useState(false);\n const detailsId = useId();\n const compact = mode === \"tight\" || mode === \"compact\";\n const narrow = mode !== \"wide\";\n const expanded = !narrow && (railOpen ?? localOpen);\n\n // Leave confirmation and the wide rail both replace the Details sheet.\n if (sheet && (confirmLeave || !narrow)) {\n setSheet(false);\n }\n\n // Measure before the first paint, then re-render only when a breakpoint is crossed.\n useIsomorphicLayoutEffect(() => {\n let current: LayoutMode | undefined;\n return observeElementWidth(rootRef.current!, (width) => {\n const next = layoutMode(width);\n if (next === current) {\n return;\n }\n current = next;\n // Crossing a breakpoint is not a deliberate toggle, so it doesn't animate.\n setAnimate(false);\n setMode(next);\n });\n }, []);\n\n // Moving a node drops its focus; keep the user in the field they were in.\n useIsomorphicLayoutEffect(() => {\n if (railHost) {\n moveHost(railHost, railSlotRef.current ?? sheetSlotRef.current, lastFocus.current);\n }\n });\n\n // A breakpoint, a collapse or a closing sheet can remove the focused control.\n // Hand focus to the Details toggle that replaced it.\n useEffect(() => {\n const last = lastFocus.current;\n if (last && cannotHoldFocus(last) && cannotHoldFocus(document.activeElement)) {\n toggleRef.current?.focus({ preventScroll: true });\n }\n }, [mode, expanded, sheet]);\n\n const toggle = () => {\n if (narrow) {\n setSheet(true);\n return;\n }\n setAnimate(true);\n setLocalOpen(!expanded);\n onRailToggle?.(!expanded);\n };\n const closeDetails = () => flushSync(() => setSheet(false));\n const railContent = typeof rail === \"function\" ? rail(closeDetails) : rail;\n\n return (\n <div\n {...rest}\n ref={mergedRef}\n className={[\"ds-edit-layout\", className].filter(Boolean).join(\" \")}\n data-compact={compact || undefined}\n data-tight={mode === \"tight\" || undefined}\n data-expanded={expanded || undefined}\n data-animate={animate || undefined}\n onFocus={(event) => {\n lastFocus.current = event.target;\n onFocus?.(event);\n }}\n >\n <div className=\"ds-edit-layout__main\">\n <EditActionBar\n backLabel={backLabel}\n onBack={onBack}\n compact={compact}\n status={\n <SaveStatus\n saveState={saveState}\n statusLabel={statusLabel}\n savedAgo={savedAgo}\n />\n }\n actions={actions}\n confirmLeave={confirmLeave}\n confirmation={\n <LeaveConfirmation\n text={confirmText}\n bodyRef={bodyRef}\n onKeepEditing={onKeepEditing}\n />\n }\n onLeave={onLeave}\n detailsToggle={\n <Button\n ref={toggleRef}\n variant=\"simple\"\n size=\"sm\"\n isIconOnly\n iconStart=\"info\"\n aria-label={railLabel}\n aria-haspopup=\"dialog\"\n aria-expanded={sheet}\n aria-controls={detailsId}\n onClick={toggle}\n />\n }\n />\n <div\n ref={bodyRef}\n className=\"ds-edit-layout__body\"\n >\n <div className=\"ds-edit-layout__content\">{children}</div>\n </div>\n </div>\n {!compact && (\n <DetailsRail\n label={railLabel}\n detailsId={detailsId}\n expanded={expanded}\n opensSheet={narrow}\n sheetOpen={sheet}\n toggleRef={toggleRef}\n contentRef={railSlotRef}\n collapsed={railCollapsed}\n onToggle={toggle}\n />\n )}\n <Drawer\n id={narrow ? detailsId : undefined}\n dir={rest.dir}\n isOpen={sheet}\n onClose={() => setSheet(false)}\n side=\"end\"\n size=\"md\"\n title={railLabel}\n closeLabel={`Close ${railLabel}`}\n className=\"ds-edit-layout__sheet\"\n >\n {narrow && (\n <div\n ref={sheetSlotRef}\n className=\"ds-edit-layout__rail-content\"\n />\n )}\n </Drawer>\n {railHost && createPortal(railContent, railHost)}\n </div>\n );\n});\n"],"mappings":";;;;;;;;;;;;AAqDA,IAAMS,IAAc,KAEdC,IAAgB,KAEhBC,IAAa;AAInB,SAASC,EAAW,GAA2B;CAU7C,OATIC,IAAQJ,IACH,UAELI,IAAQH,IACH,YAELG,IAAQF,IACH,WAEF;AACT;AAEA,IAAMG,IAA8C;CAClD,OAAO;CACP,OAAO;CACP,QAAQ;CACR,OAAO;CACP,OAAO;CACP,SAAS;AACX,GAEMC,IAA2D;CAC/D,OAAO,KAAA;CACP,OAAO,KAAA;CACP,QAAQ;CACR,OAAO;CACP,OAAO;CACP,SAAS;AACX,GAGMC,oBAA+C,IAAI,IAAI,CAAC,SAAS,OAAO,CAAC;AAE/E,SAASC,EAAW,GAAiB;CAInC,OAHI,OAAOC,KAAS,WACXA,EAAK,KAAK,MAAM,KAElBA,KAAS,QAA8B,OAAOA,KAA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V;GACX,CAAA;GAEH,kBAACjF,GAAD;IACE,IAAI2E,IAAS3B,IAAY,KAAA;IACzB,KAAKO,EAAK;IACV,QAAQe;IACR,eAAeC,EAAS,EAAK;IAC7B,MAAK;IACL,MAAK;IACL,OAAOmB;IACP,YAAY,SAASA;IACrB,WAAU;IAET,UAAAf,KACC,kBAAC,OAAD;KACE,KAAKd;KACL,WAAU;IACX,CAAA;GAEG,CAAA;GACPE,KAAY6B,EAAaT,IAAapB,CAAQ;EAC5C;;AAET,CAAC"}
1
+ {"version":3,"file":"index.js","names":["_Fragment","Icon","Drawer","mergeRefs","createMovableHost","cannotHoldFocus","moveHost","useIsomorphicLayoutEffect","observeElementWidth","Fragment$1","TIGHT_WIDTH","COMPACT_WIDTH","WIDE_WIDTH","layoutMode","width","statusLabels","statusIcons","relabelledStates","hasContent","node","SaveStatus","icon","saveState","custom","statusLabel","savedAgo","LeaveConfirmation","keepRef","useRef","origin","useEffect","frame","text","Button","onKeepEditing","bodyRef","EditActionBar","compact","backLabel","onBack","confirmLeave","confirmation","status","onLeave","actions","detailsToggle","DetailsRail","label","expanded","toggleRef","sheetOpen","detailsId","opensSheet","onToggle","contentRef","collapsed","EditLayout","forwardRef","rest","rootRef","mergedRef","useMemo","ref","railSlotRef","sheetSlotRef","lastFocus","railHost","useState","mode","setMode","localOpen","setLocalOpen","defaultRailOpen","sheet","setSheet","animate","setAnimate","useId","narrow","railOpen","current","next","last","toggle","onRailToggle","railContent","rail","flushSync","className","event","onFocus","confirmText","railLabel","railCollapsed","createPortal"],"sources":["../../../src/components/EditLayout/index.tsx"],"sourcesContent":["import {\n forwardRef,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n type HTMLAttributes,\n type ReactNode,\n type RefObject,\n} from \"react\";\nimport { createPortal, flushSync } from \"react-dom\";\nimport { useIsomorphicLayoutEffect } from \"../../internal/useIsomorphicLayoutEffect\";\nimport { Button } from \"../Button\";\nimport { Drawer } from \"../Drawer\";\nimport { Icon } from \"../Icon\";\nimport type { IconName } from \"../Icon/icons\";\nimport { mergeRefs } from \"../../internal/mergeRefs\";\nimport { observeElementWidth } from \"../../internal/observeElementWidth\";\nimport { cannotHoldFocus } from \"../../internal/dialogFocus\";\nimport { createMovableHost, moveHost } from \"../../internal/movableHost\";\nimport \"./style.css\";\n\nexport type EditSaveState = \"clean\" | \"dirty\" | \"saving\" | \"saved\" | \"error\" | \"offline\";\n\nexport interface EditLayoutProps extends HTMLAttributes<HTMLDivElement> {\n backLabel: string;\n onBack: () => void;\n saveState?: EditSaveState;\n /**\n * Replaces the `clean` or `dirty` message, for example on a read-only record.\n * Saving, saved, error and offline keep their standard messages, and\n * `saveState` always controls the indicator and colour. Empty values are ignored.\n */\n statusLabel?: ReactNode;\n savedAgo?: ReactNode;\n actions?: ReactNode;\n /** A render slot can close the Details sheet before opening another dialog. */\n rail: ReactNode | ((closeDetails: () => void) => ReactNode);\n /** Custom collapsed controls receive the accessible expand action. */\n railCollapsed?: (expand: () => void) => ReactNode;\n railLabel?: string;\n railOpen?: boolean;\n defaultRailOpen?: boolean;\n onRailToggle?: (open: boolean) => void;\n confirmLeave?: boolean;\n confirmText?: string;\n onKeepEditing?: () => void;\n onLeave?: () => void;\n children?: ReactNode;\n}\n\n/** Below this width, the action bar's gaps and padding contract. */\nconst TIGHT_WIDTH = 360;\n/** Below this width, Details opens from the action bar. */\nconst COMPACT_WIDTH = 600;\n/** From this width, the rail follows the open/closed preference. */\nconst WIDE_WIDTH = 900;\n\ntype LayoutMode = \"tight\" | \"compact\" | \"narrow\" | \"wide\";\n\nfunction layoutMode(width: number): LayoutMode {\n if (width < TIGHT_WIDTH) {\n return \"tight\";\n }\n if (width < COMPACT_WIDTH) {\n return \"compact\";\n }\n if (width < WIDE_WIDTH) {\n return \"narrow\";\n }\n return \"wide\";\n}\n\nconst statusLabels: Record<EditSaveState, string> = {\n clean: \"No changes\",\n dirty: \"Unsaved changes\",\n saving: \"Saving…\",\n saved: \"Saved\",\n error: \"Couldn't save\",\n offline: \"Offline · kept in this tab\",\n};\n\nconst statusIcons: Record<EditSaveState, IconName | undefined> = {\n clean: undefined,\n dirty: undefined,\n saving: \"spinner\",\n saved: \"check\",\n error: \"alert-triangle\",\n offline: \"clock\",\n};\n\n/** Save progress, outcomes and connection loss always keep their standard messages. */\nconst relabelledStates: ReadonlySet<EditSaveState> = new Set([\"clean\", \"dirty\"]);\n\nfunction hasContent(node: ReactNode) {\n if (typeof node === \"string\") {\n return node.trim() !== \"\";\n }\n return node !== null && node !== undefined && typeof node !== \"boolean\";\n}\n\ninterface SaveStatusProps {\n saveState: EditSaveState;\n statusLabel?: ReactNode;\n savedAgo?: ReactNode;\n}\n\nfunction SaveStatus({ saveState, savedAgo, statusLabel }: SaveStatusProps) {\n const icon = statusIcons[saveState];\n const custom =\n relabelledStates.has(saveState) && hasContent(statusLabel) ? statusLabel : undefined;\n return (\n <div\n className=\"ds-edit-layout__status\"\n data-state={saveState}\n role=\"status\"\n aria-live=\"polite\"\n >\n {icon && (\n <Icon\n name={icon}\n className={saveState === \"saving\" ? \"ds-icon--spin\" : undefined}\n />\n )}\n {saveState === \"dirty\" && (\n <span\n className=\"ds-edit-layout__dirty\"\n aria-hidden=\"true\"\n />\n )}\n {/* The title recovers a custom string clipped beyond two lines. */}\n <span title={typeof custom === \"string\" ? custom : undefined}>\n {custom ?? statusLabels[saveState]}\n {saveState === \"saved\" && savedAgo ? <> {savedAgo}</> : null}\n </span>\n </div>\n );\n}\n\ninterface LeaveConfirmationProps {\n text: string;\n /** Keep editing falls back to the first control here when its origin is gone. */\n bodyRef: RefObject<HTMLDivElement | null>;\n onKeepEditing?: () => void;\n}\n\n/** Takes focus while shown; Keep editing returns it to where the user was. */\nfunction LeaveConfirmation({ text, bodyRef, onKeepEditing }: LeaveConfirmationProps) {\n const keepRef = useRef<HTMLButtonElement>(null);\n const origin = useRef<HTMLElement | null>(null);\n\n useEffect(() => {\n origin.current = document.activeElement as HTMLElement | null;\n const frame = requestAnimationFrame(() => keepRef.current?.focus({ preventScroll: true }));\n return () => cancelAnimationFrame(frame);\n }, []);\n\n const keepEditing = () => {\n onKeepEditing?.();\n requestAnimationFrame(() => {\n const destination = origin.current?.isConnected\n ? origin.current\n : bodyRef.current?.querySelector<HTMLElement>(\n \"input, textarea, button, [contenteditable='true']\",\n );\n destination?.focus({ preventScroll: true });\n });\n };\n\n return (\n <div className=\"ds-edit-layout__confirmation\">\n <strong>{text}</strong>\n <Button\n ref={keepRef}\n size=\"xs\"\n onClick={keepEditing}\n >\n Keep editing\n </Button>\n </div>\n );\n}\n\ninterface EditActionBarProps {\n backLabel: string;\n onBack: () => void;\n compact: boolean;\n status: ReactNode;\n actions?: ReactNode;\n /** Replaces the status and actions while set. */\n confirmLeave: boolean;\n confirmation: ReactNode;\n onLeave?: () => void;\n /** Shown only in compact layouts, where Details opens as a sheet. */\n detailsToggle: ReactNode;\n}\n\nfunction EditActionBar({\n backLabel,\n onBack,\n compact,\n status,\n actions,\n confirmLeave,\n confirmation,\n onLeave,\n detailsToggle,\n}: EditActionBarProps) {\n return (\n <header className=\"ds-edit-layout__bar\">\n <Button\n variant=\"simple\"\n size=\"sm\"\n iconStart=\"arrow-left\"\n isIconOnly={compact}\n aria-label={`Back to ${backLabel}`}\n onClick={onBack}\n >\n {backLabel}\n </Button>\n {confirmLeave ? confirmation : status}\n <div className=\"ds-edit-layout__actions\">\n {confirmLeave ? (\n <Button\n variant=\"danger\"\n size=\"sm\"\n onClick={onLeave}\n >\n Leave anyway\n </Button>\n ) : (\n actions\n )}\n {compact && detailsToggle}\n </div>\n </header>\n );\n}\n\ninterface DetailsRailProps {\n label: string;\n detailsId: string;\n expanded: boolean;\n /** Below the wide breakpoint, the toggle opens the Details sheet instead. */\n opensSheet: boolean;\n sheetOpen: boolean;\n toggleRef: RefObject<HTMLButtonElement | null>;\n /** Receives the rail content while the rail is expanded. */\n contentRef: RefObject<HTMLDivElement | null>;\n collapsed?: (expand: () => void) => ReactNode;\n onToggle: () => void;\n}\n\nfunction DetailsRail({\n label,\n detailsId,\n expanded,\n opensSheet,\n sheetOpen,\n toggleRef,\n contentRef,\n collapsed,\n onToggle,\n}: DetailsRailProps) {\n return (\n <aside\n className=\"ds-edit-layout__rail ds-field-surface\"\n aria-label={label}\n >\n <header className=\"ds-edit-layout__rail-head\">\n {expanded && <span>{label}</span>}\n <Button\n ref={toggleRef}\n variant=\"simple\"\n size=\"sm\"\n isIconOnly\n iconStart={expanded ? \"chevrons-right\" : \"chevrons-left\"}\n className=\"ds-edit-layout__toggle\"\n aria-label={`${expanded ? \"Collapse\" : \"Expand\"} ${label}`}\n aria-expanded={expanded || sheetOpen}\n aria-controls={detailsId}\n aria-haspopup={opensSheet ? \"dialog\" : undefined}\n onClick={onToggle}\n />\n </header>\n {expanded ? (\n <div\n id={detailsId}\n ref={contentRef}\n className=\"ds-edit-layout__rail-content\"\n />\n ) : (\n <div className=\"ds-edit-layout__rail-icons\">\n {collapsed ? (\n collapsed(onToggle)\n ) : (\n <Button\n variant=\"simple\"\n size=\"sm\"\n isIconOnly\n iconStart=\"info\"\n aria-label={`Show ${label}`}\n onClick={onToggle}\n />\n )}\n </div>\n )}\n </aside>\n );\n}\n\n/** Presentation only: the consumer owns saving, routing and persisted preferences. */\nexport const EditLayout = forwardRef<HTMLDivElement, EditLayoutProps>(function EditLayout(\n {\n backLabel,\n onBack,\n saveState = \"clean\",\n statusLabel,\n savedAgo,\n actions,\n rail,\n railCollapsed,\n railLabel = \"Details\",\n railOpen,\n defaultRailOpen = true,\n onRailToggle,\n confirmLeave = false,\n confirmText = \"Leave without saving?\",\n onKeepEditing,\n onLeave,\n children,\n className,\n onFocus,\n ...rest\n },\n ref,\n) {\n const rootRef = useRef<HTMLDivElement>(null);\n const mergedRef = useMemo(() => mergeRefs(rootRef, ref), [ref]);\n const bodyRef = useRef<HTMLDivElement>(null);\n const toggleRef = useRef<HTMLButtonElement>(null);\n const railSlotRef = useRef<HTMLDivElement>(null);\n const sheetSlotRef = useRef<HTMLDivElement>(null);\n const lastFocus = useRef<Element | null>(null);\n // Rail content renders once, into a node that moves between the rail and\n // the sheet, so uncontrolled fields keep their values across modes.\n const [railHost] = useState(() => createMovableHost(\"ds-edit-layout__rail-host\"));\n const [mode, setMode] = useState<LayoutMode>(\"wide\");\n const [localOpen, setLocalOpen] = useState(defaultRailOpen);\n const [sheet, setSheet] = useState(false);\n const [animate, setAnimate] = useState(false);\n const detailsId = useId();\n const compact = mode === \"tight\" || mode === \"compact\";\n const narrow = mode !== \"wide\";\n const expanded = !narrow && (railOpen ?? localOpen);\n\n // Leave confirmation and the wide rail both replace the Details sheet.\n if (sheet && (confirmLeave || !narrow)) {\n setSheet(false);\n }\n\n // Measure before the first paint, then re-render only when a breakpoint is crossed.\n useIsomorphicLayoutEffect(() => {\n let current: LayoutMode | undefined;\n return observeElementWidth(rootRef.current!, (width) => {\n const next = layoutMode(width);\n if (next === current) {\n return;\n }\n current = next;\n // Crossing a breakpoint is not a deliberate toggle, so it doesn't animate.\n setAnimate(false);\n setMode(next);\n });\n }, []);\n\n // Moving a node drops its focus; keep the user in the field they were in.\n useIsomorphicLayoutEffect(() => {\n if (railHost) {\n moveHost(railHost, railSlotRef.current ?? sheetSlotRef.current, lastFocus.current);\n }\n });\n\n // A breakpoint, a collapse or a closing sheet can remove the focused control.\n // Hand focus to the Details toggle that replaced it.\n useEffect(() => {\n const last = lastFocus.current;\n if (last && cannotHoldFocus(last) && cannotHoldFocus(document.activeElement)) {\n toggleRef.current?.focus({ preventScroll: true });\n }\n }, [mode, expanded, sheet]);\n\n const toggle = () => {\n if (narrow) {\n setSheet(true);\n return;\n }\n setAnimate(true);\n setLocalOpen(!expanded);\n onRailToggle?.(!expanded);\n };\n const closeDetails = () => flushSync(() => setSheet(false));\n const railContent = typeof rail === \"function\" ? rail(closeDetails) : rail;\n\n return (\n <div\n {...rest}\n ref={mergedRef}\n className={[\"ds-edit-layout\", className].filter(Boolean).join(\" \")}\n data-compact={compact || undefined}\n data-tight={mode === \"tight\" || undefined}\n data-expanded={expanded || undefined}\n data-animate={animate || undefined}\n onFocus={(event) => {\n lastFocus.current = event.target;\n onFocus?.(event);\n }}\n >\n <div className=\"ds-edit-layout__main\">\n <EditActionBar\n backLabel={backLabel}\n onBack={onBack}\n compact={compact}\n status={\n <SaveStatus\n saveState={saveState}\n statusLabel={statusLabel}\n savedAgo={savedAgo}\n />\n }\n actions={actions}\n confirmLeave={confirmLeave}\n confirmation={\n <LeaveConfirmation\n text={confirmText}\n bodyRef={bodyRef}\n onKeepEditing={onKeepEditing}\n />\n }\n onLeave={onLeave}\n detailsToggle={\n <Button\n ref={toggleRef}\n variant=\"simple\"\n size=\"sm\"\n isIconOnly\n iconStart=\"info\"\n aria-label={railLabel}\n aria-haspopup=\"dialog\"\n aria-expanded={sheet}\n aria-controls={detailsId}\n onClick={toggle}\n />\n }\n />\n <div\n ref={bodyRef}\n className=\"ds-edit-layout__body\"\n >\n <div className=\"ds-edit-layout__content\">{children}</div>\n </div>\n </div>\n {!compact && (\n <DetailsRail\n label={railLabel}\n detailsId={detailsId}\n expanded={expanded}\n opensSheet={narrow}\n sheetOpen={sheet}\n toggleRef={toggleRef}\n contentRef={railSlotRef}\n collapsed={railCollapsed}\n onToggle={toggle}\n />\n )}\n <Drawer\n id={narrow ? detailsId : undefined}\n dir={rest.dir}\n isOpen={sheet}\n onClose={() => setSheet(false)}\n side=\"end\"\n size=\"md\"\n title={railLabel}\n closeLabel={`Close ${railLabel}`}\n className=\"ds-edit-layout__sheet\"\n >\n {narrow && (\n <div\n ref={sheetSlotRef}\n className=\"ds-edit-layout__rail-content\"\n />\n )}\n </Drawer>\n {railHost && createPortal(railContent, railHost)}\n </div>\n );\n});\n"],"mappings":";;;;;;;;;;;AAqDA,IAAMU,IAAc,KAEdC,IAAgB,KAEhBC,IAAa;AAInB,SAASC,EAAW,GAA2B;CAU7C,OATIC,IAAQJ,IACH,UAELI,IAAQH,IACH,YAELG,IAAQF,IACH,WAEF;AACT;AAEA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;MACL,YAAA;MACA,WAAU;MACV,cAAY2C;MACZ,iBAAc;MACd,iBAAenB;MACf,iBAAetB;MACf,SAASgC;KACV,CAAA;IAEJ,CAAA,GACD,kBAAC,OAAD;KACE,KAAKhD;KACL,WAAU;KAEV,UAAA,kBAAC,OAAD;MAAK,WAAU;MAA2B;KAAc,CAAA;IACrD,CAAA,CACF;;GACJ,CAACE,KACA,kBAACS,IAAD;IACE,OAAO8C;IACI;IACD;IACV,YAAYd;IACZ,WAAWL;IACA;IACX,YAAYV;IACZ,WAAW8B;IACX,UAAUV;GACX,CAAA;GAEH,kBAACjF,GAAD;IACE,IAAI4E,IAAS3B,IAAY,KAAA;IACzB,KAAKO,EAAK;IACV,QAAQe;IACR,eAAeC,EAAS,EAAK;IAC7B,MAAK;IACL,MAAK;IACL,OAAOkB;IACP,YAAY,SAASA;IACrB,WAAU;IAET,UAAAd,KACC,kBAAC,OAAD;KACE,KAAKd;KACL,WAAU;IACX,CAAA;GAEG,CAAA;GACPE,KAAY4B,EAAaT,IAAanB,CAAQ;EAC5C;;AAET,CAAC"}
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../chunks/EntryPicker-BwEYRtQl.cjs");exports.EntryPicker=e.t;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../chunks/EntryPicker-C7EBfpaw.cjs");exports.EntryPicker=e.t;
@@ -1 +1 @@
1
- export { t as EntryPicker } from "../../chunks/EntryPicker-Ie9T47hA.js";
1
+ export { t as EntryPicker } from "../../chunks/EntryPicker-DBnDsgzi.js";
@@ -68,7 +68,7 @@
68
68
  border: 0;
69
69
  border-radius: var(--field-radius);
70
70
 
71
- /* Steps from the row, result or storyblock it sits in, hovered or not. */
71
+ /* Steps from the row, result or content block it sits in, hovered or not. */
72
72
  background: var(--fill-control);
73
73
  color: var(--color-text-muted);
74
74
  }
@@ -86,7 +86,7 @@ exports. Import the aggregate stylesheet with either entry point. The optional
86
86
  | `value` | `FormValues` | Omit for uncontrolled state; controlled callers must echo changes. |
87
87
  | `defaultValue` | `FormValues` | `{}`; initial uncontrolled values only. |
88
88
  | `onValueChange` | `(values, { fieldId }) => void` | Reports the complete next values and the edited field ID. |
89
- | `embedSources` | `Record<string, RichTextEmbedSources>` | Rich-text embed sources keyed by field ID; absent means no embed buttons. |
89
+ | `blockPlugins` | `Record<string, readonly ContentBlockPlugin[]>` | Rich-text plug-ins keyed by field ID. Register the same definitions on the field schema. |
90
90
  | `pickerItems` | `Record<string, EntryItem[]>` | `{}`; available assets/entries keyed by field ID. |
91
91
  | `errors` | `FormErrors` | `{}`; app messages override built-in errors. Clear stale app errors explicitly. |
92
92
  | `showAllErrors` | Boolean | `false`; reveal built-in required/format errors, usually after submission. |
@@ -161,7 +161,7 @@ are not automatically schema options.
161
161
  | --- | --- | --- |
162
162
  | `shortText` | `inputType: "text" \| "email"` (`text`), `maxLength`, `readOnly: false`, `autoFocus: false` | String; empty text remains `""`. |
163
163
  | `longText` | `rows: 3`, `maxLength`, `readOnly: false`, `autoFocus: false` | String. |
164
- | `richText` | `placeholder: "Write something…"`, `expandedWidth: "wide" \| "full"` (`wide`; any other runtime value throws), `tables: true` (false removes table insertion and rejects table nodes; a non-boolean runtime value throws); no autofocus | TipTap JSON document rooted at `doc`. |
164
+ | `richText` | `placeholder: "Write something…"`, `expandedWidth: "wide" \| "full"` (`wide`; any other runtime value throws), `tables: true` (false removes table insertion and rejects table nodes; a non-boolean runtime value throws), `blockDefinitions: ContentBlockDefinition[]` (none; the block types the field accepts, see [content block plug-ins](#rich-text-content-block-plug-ins); a non-array, duplicate or malformed runtime value throws with the field ID); no autofocus | TipTap JSON document rooted at `doc`. |
165
165
  | `number` | `min`, `max`, `step: number \| "any"` (`"any"`), `hasSteppers: true`, `decreaseLabel` / `increaseLabel` (`"Decrease {label}"` / `"Increase {label}"`), `prefix`, `suffix` (strings), `autoFocus: false` | Finite number. |
166
166
  | `boolean` | `autoFocus: false`; always a Switch | Boolean; `false` satisfies required. |
167
167
  | `dateTime` | Native browser date-and-time input; `autoFocus: false`; label gets `(UTC)` | UTC ISO string ending in `Z`, including milliseconds. |
@@ -317,29 +317,46 @@ stored document. Expansion is local UI state, so applications do not persist it.
317
317
 
318
318
  ### Rich-text tables
319
319
 
320
- Rich-text editors have one table control in the toolbar by default. Outside a
321
- table it is Insert table (`table` icon); while the caret is in a table it
322
- becomes Table actions (`grid-2x2-plus` icon), which opens the actions menu.
323
- Insert table opens a FormEditor form: Rows and Columns number fields (1–50 of each at
324
- insertion, with steppers) and an Include header row switch. The defaults are
325
- 3 × 3 with a header. FormEditor reports requiredness and bounds; the dialog adds
326
- "Enter a whole number." for a fractional count. A table inserted while a block such as a
327
- storyblock or rule is selected follows that block instead of replacing it, and
328
- the caret lands in the first cell. Insertion is one undo step, separate from
329
- typing that follows. Use Table actions from a cell to add or delete rows or
330
- columns, merge cells, toggle the header row, or delete the table. Row, column,
331
- cell and delete actions are separated, each with a lucide glyph: Add row above
332
- and below `rows-2-plus-top` and `rows-2-plus-bottom`, Add column before and
333
- after `columns-2-plus-left` and `columns-2-plus-right` (mirrored with
334
- right-to-left text), Delete row and column `table-rows-split` and
335
- `table-columns-split`, Merge cells `table-cells-merge`, Toggle header row
336
- `panel-top` and Delete table `grid-2x2-x`. Merge cells joins a selection of
337
- two or more cells, made by dragging or Shift-clicking across them, into one
338
- spanning cell. Actions that can't run, such as merging without a cell selection
339
- or deleting a table's only row or column, are disabled. Tab and Shift+Tab move
340
- between cells. Wide tables scroll inside the editor. Cells rest on the canvas,
341
- as storyblocks do, so a table stands apart from the editor's fill: lighter in
342
- the light theme, deeper in the dark one. The header row takes a stronger step.
320
+ The toolbar's Insert table button uses the `table` icon and is disabled when
321
+ the caret or selection is in a table or the whole table is selected. Outside
322
+ a table it opens a grid for up to 6 rows and 8 columns, initially focused at
323
+ 3 × 3. Hover or use the arrow keys to preview a size. While the grid has
324
+ focus, hovering a size also focuses it, so Enter inserts the size shown;
325
+ leaving the grid shows the focused size again. Pick a size by clicking or
326
+ pressing Enter or Space. Include header row is on by default.
327
+
328
+ Custom size opens a FormEditor form with Rows and Columns number fields
329
+ (1–50 each, with steppers) and carries over Include header row. FormEditor
330
+ reports requiredness and bounds. The dialog adds "Enter a whole number." for
331
+ a fractional count. With a content block or another standalone block selected,
332
+ Insert table places the table after it. The caret lands in the first cell.
333
+ Typing there starts a separate undo step.
334
+
335
+ Each table is a Content Block. Select a cell and open **⋯ Table actions**
336
+ in the block's title bar to add, delete, or move its row or column. Column
337
+ moves follow the visible left and right directions in LTR and RTL. Cells
338
+ joined by a span move together, header formatting stays at the edge, and
339
+ Undo reverts one move. Delete row and Delete column remove every row or
340
+ column the selected cells cover, and are disabled when that would remove all
341
+ of them.
342
+ Add row above is disabled when it would insert before a complete first-row
343
+ header. Rows can still be inserted below the header and columns on either side.
344
+
345
+ The same menu toggles the first-row and first-column headers, merges the
346
+ selected cells, splits a merged cell, and deletes the table. Moves and inserts
347
+ for a cell range use the cell where the selection ends. **Cell alignment**
348
+ applies left, centre, or right to the active cell or all cells in the selected
349
+ range in one undo step. Left is the default in both LTR and RTL. Choosing an
350
+ alignment returns focus to the editor. When the whole table is selected
351
+ without a cell, for example by clicking its title bar first, row, column,
352
+ merge and split commands are disabled with "Select a cell first", and Cell
353
+ alignment applies to every cell.
354
+
355
+ Tab and Shift+Tab move between cells while editing. Press Shift+F10 or
356
+ the Menu key from a cell to open **Table actions**; the browser's own context
357
+ menu for that key stays closed. Escape selects the whole
358
+ table and remembers the cell selection, and Tab then reaches the menu.
359
+ Click or drag the title-bar grip to select or move the whole table.
343
360
 
344
361
  A table is part of the existing TipTap JSON document, using `table`, `tableRow`,
345
362
  `tableHeader` and `tableCell` nodes. Cells can contain formatted content.
@@ -352,6 +369,16 @@ formatting without carrying over column widths. Content cut, copied or dragged
352
369
  within the same editor keeps its stored widths, and cells pasted into a table
353
370
  take that table's column widths.
354
371
 
372
+ Regular and header cells store alignment in `attrs.align` as `left`, `center`,
373
+ or `right`. An omitted or null value displays as left. HTML reads inline
374
+ `text-align` and the legacy `align` attribute. Saved alignment uses inline
375
+ `text-align` on `<td>` and `<th>`, so keep that property in HTML sanitizers.
376
+ Set the same left default in the delivery renderer.
377
+
378
+ Pasting or dropping a selection that contains a Content Block of any
379
+ registered type into a cell rejects the entire operation, including mixed
380
+ selections with text. Previously saved blocks inside a cell still load.
381
+
355
382
  Tables without stored widths save as a `<table>` with a `<tbody>` and no inline
356
383
  sizing. A table with any stored column width saves with its sizing:
357
384
 
@@ -711,17 +738,21 @@ See the packaged UPGRADING.md for removed styling APIs.
711
738
  each selected ID's copy from before a refresh until a fresh one arrives.
712
739
  Translate clear events and Field bindings here. Rich text is the one adapter
713
740
  `control.tsx` does not import: `rich-text-control.tsx` renders RichTextEditor,
714
- forwarding `expandedWidth` and `tables`, and `index.tsx` supplies it through
715
- `RichTextControlContext`. RichTextEditor's `tables.tsx` renders its Insert
716
- table form with `FormEditorCore` from `form.tsx`, so the two components
741
+ forwarding `expandedWidth`, `tables` and registered content block plug-ins, and `index.tsx` supplies it through
742
+ `RichTextControlContext`. RichTextEditor's `tables.tsx` handles the quick
743
+ grid and renders the custom size form with `FormEditorCore` from `form.tsx`,
744
+ so the two components
717
745
  never import each other in a cycle. RichTextEditor's `expansion.tsx` moves one
718
746
  rendering host into a headerless Modal; Modal and the shared `src/internal`
719
747
  helpers own the dialog behaviour and portal scope. RichTextEditor's
720
748
  `document.ts` builds the schema with or without tables for both the editor
721
749
  and `validateFormValues`. It also strips widths from cells pasted or dropped
722
750
  from outside the editor, and renders tables without stored widths as
723
- semantic HTML. `tables.tsx` owns the table
724
- dialog and actions.
751
+ semantic HTML. `table-view.tsx` extends TableView to mount the shared
752
+ `content-block-frame.tsx` and its grouped table actions. Its clipboard guard
753
+ rejects embeds before TableKit can paste content into selected cells.
754
+ `table-actions.ts` supplies the menus and uses `table-bands.ts` to move
755
+ spans and widths together.
725
756
  Do not copy control styling.
726
757
  3. **State/frame:** `form.tsx` (`FormEditorCore`) asserts the schema, owns controlled/uncontrolled
727
758
  wiring and changed-field tracking, and wraps each Field in Container with
@@ -784,156 +815,152 @@ Refused results keep a focusable `aria-disabled` checkbox, described by the
784
815
  reason or, at the cap, by a full-selection note. Applications confirm
785
816
  missing records and remove links when saving; FormEditor never drops selections.
786
817
 
787
- ## Rich-text embedded entries and assets
788
-
789
- `RichTextEditor.embeds` accepts optional `entry` and `asset` sources.
790
- `FormEditor.embedSources[fieldId]` passes the same configuration to a rich-text
791
- field, independently of ordinary `pickerSources`. Sources reuse EntryPicker paging
792
- (`loadPage`), static `items` (searched by title and keywords when there is no
793
- `loadPage`), `resolveItem`, refresh keys, `dialogTitle`/`dialogDescription`,
794
- editing and dialog suspension. They do not fetch or save content themselves.
795
-
796
- A source adds its toolbar button and its blocks' Replace action only when it can
797
- offer something to embed: `loadPage`, non-empty `items` or `onCreate`. A source with only
798
- `resolveItem` displays existing blocks without offering insertion. Embedding from
799
- a source that lists choices (`loadPage` or non-empty `items`) always stages
800
- existing items across queries and pages; its toolbar button reads "Embed
801
- entries" or "Embed assets". A source that can only create (`onCreate` alone)
802
- reads "Embed entry" or "Embed asset" and inserts the one item it creates, with
803
- Done to close. Use the results checkboxes to select or deselect items. The
804
- footer shows the count as text, since an insertion has no limit to draw a
805
- usage ring against. Insert selected commits the selected items as
806
- consecutive storyblocks in selection order, with one undo step. Closing the
807
- dialog discards the pending selection. Replace still chooses one item, and New
808
- creates and inserts one item when the selection is empty. While a creation is
809
- pending (`isCreating`), rows can't be selected, so staging and creation never
810
- compete for the same insertion. Embed sources ignore EntryPicker's `mode` and
811
- `max`, including on a source spread from a field's picker source.
812
-
813
- Give a source with `loadPage` a `resolveItem`. After a `refreshKey` change,
814
- Insert selected waits for `resolveItem` to check each staged item, even when
815
- refreshed search results already list it. The inserted storyblock uses the
816
- confirmed copy from the current refresh immediately. The picker deselects items
817
- that `resolveItem` returns as null, removed, unavailable or disabled, and any
818
- that a results page at the current refresh shows as removed, unavailable,
819
- disabled or otherwise restricted, since a page can refuse an item but only
820
- `resolveItem` confirms one. It reports
821
- the change in the footer and re-enables Insert selected for the rest.
822
- If `resolveItem` rejects, the dialog shows
823
- "Couldn't load selected entries" (or assets) with Try again, and Insert selected
824
- stays disabled until a retry succeeds. Without `resolveItem`, a
825
- staged item is checked again only if a refreshed page shows it; one that no
826
- longer appears keeps its earlier copy and is inserted. Static `items` sources
827
- deselect an item as soon as it leaves `items`.
828
-
829
- Entry rows use the existing `EntryItem` contract with an additional `modelId`
830
- containing a readable model API ID; `item.id` identifies the selected entry.
831
- Asset rows need only the existing item contract. A row that can't become a block
832
- is restricted in the dialog, as an application's own `isDisabled` row would be,
833
- rather than ignoring the pick or producing an invalid block. The reasons are:
834
-
835
- - a removed item (`tone: "removed"`): its `removedLabel`, or "Removed";
836
- - an item with `isUnavailable`: "Unavailable", in insertion, replacement and
837
- for an item committed after creation;
838
- - an entry without `modelId`, or a blank ID: "Can't embed".
818
+ ## Rich-text content block plug-ins
819
+
820
+ A rich-text field accepts `blockDefinitions`, an optional list of pure
821
+ `ContentBlockDefinition` values. Supply those same definition objects in
822
+ `blockPlugins[fieldId]` to give each type an editor preview and actions.
823
+ `validateFormValues` uses the field's definitions. A valid block satisfies a
824
+ required field. An unsupported or malformed block protects the field value and
825
+ displays an error. Register every block type that can appear in the field, even
826
+ when an author has no insert permission. Standalone `RichTextEditor.blockPlugins`
827
+ supplies both the definitions and runtime behavior. The package README's
828
+ [Rich-text content blocks](../../../README.md#rich-text-content-blocks) guide
829
+ builds a complete plug-in, with its dialog, preview and server validation.
830
+
831
+ Define plug-ins and their definitions once, outside render, or memoize them.
832
+ Blocks render again when their plug-in object changes, and checks run again
833
+ when a definition changes. `createPickerBlockPlugin` is the exception: call it
834
+ on every render with the current source, and blocks render again only when the
835
+ source's items, refresh key, resolver or item editor change.
839
836
 
840
837
  ```tsx
841
- import type { RichTextEmbedItem, RichTextEmbedSource, RichTextEmbedSources } from "@namroodinc/liquid-editorial";
842
-
843
- export function embeddedResources(
844
- entries: Omit<RichTextEmbedSource, "onCreate">,
845
- assets: RichTextEmbedSource,
846
- createEntry: (onCreated: (item: RichTextEmbedItem) => void) => void,
847
- ): RichTextEmbedSources {
848
- return {
849
- entry: {
850
- ...entries, // returned entry items carry modelId; give entries a resolveItem
851
- onCreate: (target) => createEntry((item) => {
852
- if (target.available()) { target.commit(item); }
853
- }),
854
- },
855
- asset: assets,
856
- };
838
+ import { useMemo } from "react";
839
+ import {
840
+ FormEditor as BlockFormEditor,
841
+ type ContentBlockPlugin,
842
+ } from "@namroodinc/liquid-editorial";
843
+ import type { ContentBlockDefinition } from "@namroodinc/liquid-editorial/rich-text-blocks";
844
+
845
+ const mapDefinition: ContentBlockDefinition = {
846
+ type: "map",
847
+ validate: ({ latitude, longitude }) =>
848
+ typeof latitude === "number" &&
849
+ Math.abs(latitude) <= 90 &&
850
+ typeof longitude === "number" &&
851
+ Math.abs(longitude) <= 180,
852
+ };
853
+
854
+ export function StoryForm({
855
+ renderMapForm,
856
+ }: {
857
+ renderMapForm: ContentBlockPlugin["renderEditor"];
858
+ }) {
859
+ const map = useMemo(
860
+ () =>
861
+ ({
862
+ definition: mapDefinition,
863
+ label: "Map",
864
+ icon: "globe",
865
+ insertLabel: "Insert map",
866
+ editLabel: "Edit map",
867
+ renderPreview: ({ latitude, longitude }, frame) =>
868
+ frame({ body: <p>{String(latitude)}, {String(longitude)}</p> }),
869
+ renderEditor: renderMapForm,
870
+ }) satisfies ContentBlockPlugin,
871
+ [renderMapForm],
872
+ );
873
+
874
+ return (
875
+ <BlockFormEditor
876
+ schema={{
877
+ fields: [
878
+ { id: "body", type: "richText", label: "Body", blockDefinitions: [mapDefinition] },
879
+ ],
880
+ }}
881
+ blockPlugins={{ body: [map] }}
882
+ />
883
+ );
857
884
  }
858
- // <FormEditor schema={schema} embedSources={{ body: embeddedResources(...) }} ... />
859
885
  ```
860
886
 
861
- `onCreate` receives a `RichTextEmbedTarget`: `available()` checks the living editor,
862
- source and bookmarked position; `commit(item)` returns whether insertion or
863
- replacement succeeded. The application rechecks permissions, field eligibility
864
- and resource availability before committing a delayed creation. A pending creation
865
- may complete while its source's `isCreating` disables the parent form; ordinary
866
- read-only controls still reject commits, and a disabled editor reports only that
867
- commit, never selection or plugin changes. An expanded editor stays expanded while
868
- a source `isCreating`, so the block lands where the writer is working; clear
869
- `isCreating` and re-enable together after committing. `isDialogHidden` suspends the
870
- picker without resetting its query or pages. While a picker is suspended or its
871
- source `isCreating`, Embed and Replace are disabled so another session cannot
872
- replace the pending target. Blocks of a kind whose picker is suspended also
873
- disable their Block actions trigger, closing an open menu, and can't be dragged,
874
- so the pending replacement keeps its target.
875
-
876
- The bookmark follows document edits, including transactions plugins append.
877
- Insertion is anchored to the top-level block the cursor was in and lands at the
878
- top-level boundary after it, even when that block is wrapped, lifted, joined or
879
- edited meanwhile; a change that replaces the whole block ends the session.
880
- Replacement follows its block and survives in-place changes such as alignment,
881
- keeping the block's alignment as it is at commit. Deleting the bookmarked block
882
- ends the session. Removing the source or disabling the editor for any other
883
- reason also ends it for good: the picker never reopens on its own and its target
884
- refuses later commits. `commit` always returns a boolean. Each Embed or Replace
885
- starts a fresh picker.
886
-
887
- Entry nodes store `{ type: "storyblock", attrs: { type: "entry", id: "article",
888
- entryId: "<resource ID>", align: "full" } }`; asset nodes store
889
- `{ type: "storyblock", attrs: { type: "asset", assetId: "<resource ID>", align:
890
- "full" } }`. Model IDs and resource IDs have separate meanings. Identifiers are
891
- opaque strings in the library; applications validate UUIDs/model formats and own
892
- model restrictions. Entry model IDs can be refreshed by the application's delivery
893
- serializer without changing the saved parent document.
894
-
895
- Blocks are atomic, draggable and selectable. Insert follows the cursor's top-level
896
- block, including when the caret is in a table cell. Replacement stays within
897
- the same kind and retains alignment. Left and
898
- right blocks occupy 62% of the writing width and let text wrap around them. Below
899
- 32rem they use the full writing width. Drag the grip and kind label to move a
900
- block. Select a block with the arrow keys in the editor and press Tab to reach its
901
- `Block actions for {item title}` button. It opens the shared Menu, named the
902
- same: an Alignment group of icon-only radio items (Align left, Full width, Align
903
- right), then Edit, Replace and Remove from field. Opening it focuses the current
904
- alignment and the arrow keys walk the items. Tab closes it and continues after the
905
- editor; Shift+Tab and Escape return focus to the trigger. Alignment changes keep
906
- the menu open. Edit, Replace and Remove close it. Remove deletes the block from
907
- the document and returns the caret to that position.
908
-
909
- Standard blocks have a primary-tinted title bar. Pass `tone: "draft"` and
910
- publication guidance in the picker item’s `metadata` to show a warning bar and
911
- note. Missing blocks have a danger bar and a solid danger kind label. Selection
912
- deepens each bar in its own tone and adds a focus outline. A missing block offers
913
- “Choose another entry” or “Choose another asset” when replacement is available.
914
- A read-only block shows its kind and body, and its bar does not change on
915
- hover. Enter and gap-cursor editing let
916
- writers continue after a final block. Selecting a block leaves the document intact.
917
-
918
- A block alone satisfies required rich text. Syntax errors are rejected by both
919
- RichTextEditor and FormEditor validation. Resolved row data is never serialized;
920
- HTML uses reference-only data-storyblock attributes and round-trips through the
921
- same schema. Node views share the selected-item cache's loading, stale-refresh and
922
- retry behavior; null or removed-tone items, static ones included, show a missing
923
- state. A static item takes precedence over a cached lookup, so supplying one
924
- repairs a block whose lookup found nothing. A block just inserted or replaced shows the row the writer picked at once,
925
- without a Loading placeholder or another `resolveItem` call, including a Replace
926
- that picks the block's own item again (repairing a missing block or refreshing
927
- renamed metadata); any later block for
928
- that item, after an undo, paste or reset, is described afresh, as is a block whose
929
- kind changes between entry and asset under an equal resource ID. Node views read
930
- sources through stable wrappers, so sources built on every render don't re-render
931
- every block; keep static `items` arrays stable. Resolution,
932
- selection, expansion and linked-item edits emit no document change on their own.
933
-
934
- The architecture remains `FormEditor → RichTextEditor → storyblock node views`,
935
- with both ordinary pickers and editor dialogs using `usePickerSession` (search,
936
- paging, selection rules, edit dismissal and the shared PickerDialog props),
937
- PickerDialog, EntryRow and the selected-item reader. Remote embed batches that
938
- have a resolver use search pages for the results and the selected-item reader
939
- for rechecks. Applications supply data and resource editors.
887
+ `renderEditor` receives a `ContentBlockSession`. Render a dialog component
888
+ with its `data` as the initial value in edit or replace mode. After validating
889
+ the inputs, call `target.commit({ latitude, longitude })`, and call
890
+ `target.close()` on cancellation. `commit` returns a boolean and insertion can
891
+ also commit an array in one undo step. For previews that need hooks, return a
892
+ component from `renderPreview` and let that component call `frame` with the
893
+ title, body and optional status or resource edit action. The frame provides
894
+ selection, dragging, alignment and removal. Wrap the body in
895
+ `.ds-content-block__body` for the frame's padding and type size.
896
+
897
+ Plug-in blocks are atomic: writers edit their data only through the plug-in's
898
+ dialog. Tables aren't plug-ins, because writers edit their cells in place.
899
+ They are TableKit schema nodes that reuse the frame, title bar and actions
900
+ menu, and their type name, `table`, is reserved.
901
+
902
+ Block type names are unique lowercase identifiers beginning with a letter.
903
+ Use letters, digits and hyphens. The editor reserves `table`.
904
+ JSON stores `{ type: "contentBlock", attrs: { type: "map", align: "full",
905
+ data: { latitude: 51.5, longitude: -0.12 } } }`. Alignment is `left`, `full` or
906
+ `right`; an omitted `align` reads as `full`, and the editor always writes it.
907
+ The HTML node is a `div` with `data-content-block`,
908
+ `data-content-block-type`, `data-content-block-align` and the JSON string in
909
+ `data-content-block-data`. Only those attributes are read, so a block element's
910
+ own `type`, `align` or `data` attributes never change the stored block. Import `contentBlockRegistry` and `validContentBlock`
911
+ from the browser-independent `rich-text-blocks` entry point to validate the
912
+ same payload on the server. Applications define what to publish and how to
913
+ render it in delivery.
914
+
915
+ ### Blocks that use a picker
916
+
917
+ Use `createPickerBlockPlugin` for blocks chosen from an EntryPicker. Supply
918
+ the definition, singular and plural labels, icon, picker source, `toData(item)`
919
+ and `itemId(data)`. The source can provide static `items`, remote `loadPage`,
920
+ `resolveItem`, `onEditItem` and `onCreate`. Resolve-only sources show existing
921
+ blocks. Applications define which items are eligible and which attributes to
922
+ store. Resolved previews stay in editor state.
923
+
924
+ Insertion from listed choices stages selections across queries and pages, then
925
+ commits them in order. Replacement chooses one item and keeps alignment.
926
+ Restricted, removed or unavailable items cannot be committed. Give remote
927
+ sources a resolver so a refresh can recheck staged items. A failed recheck
928
+ blocks insertion until retry succeeds. `onCreate` gets a picker target that
929
+ commits the created item after the application rechecks permissions and
930
+ availability. While creating, the picker suspends other selections. Use
931
+ `isCreating` and `isDialogHidden` to coordinate asynchronous drawers and
932
+ temporarily disable the parent form.
933
+
934
+ A target checks the live editor, registration and document position.
935
+ Insertion is anchored after the current top-level block and replacement follows
936
+ its original block through alignment changes. Deletion, a change to the
937
+ target's data or editor disposal invalidates the session. An ordinary
938
+ read-only transition closes the session. A plug-in can finish its own pending
939
+ creation while the application temporarily disables the form.
940
+
941
+ The editor refuses any change that would leave an unregistered or invalid
942
+ block in the document, whether it comes from a paste, a drop, a toolbar command
943
+ or an attribute update. The editor's own documents therefore always pass
944
+ validation. A document from elsewhere is checked when it arrives, and the whole
945
+ document is checked again when the definitions change. A document that no longer
946
+ passes protects the field until its plug-ins return.
947
+
948
+ The editor and FormEditor validate one generic node with the pure definition
949
+ registry. `index.tsx` owns validation and the change guard, `use-blocks.tsx`
950
+ owns the transaction and dialog target, `block-plugins.ts` owns the node views'
951
+ registration snapshot, `content-block-view.tsx` renders a plug-in block in the
952
+ shared frame, and `picker-block.tsx` adapts the optional picker workflow.
953
+ Applications register type-specific previews, data and editors.
954
+
955
+ Tables join the frame without the plug-in registry. `document.ts` adds
956
+ TableKit's `table`, `tableRow`, `tableHeader` and `tableCell` nodes to the
957
+ schema when `tables` is on, so validation reads them as schema content, not
958
+ payloads. `table-view.tsx` gives the table node a ProseMirror node view that
959
+ wraps it in `contentBlockFrameClass` and mounts `ContentBlockBar` from
960
+ `content-block-frame.tsx`, with the table's actions from `table-actions.ts`.
961
+ It reads the read-only state from the same `BlockContext`. The toolbar's
962
+ `TableControl` in `tables.tsx` inserts tables, separately from the plug-in
963
+ insert buttons. A new block with editable content follows that route: a schema
964
+ node and node view in the library, not a plug-in. `src/test/mapBlock.tsx` is
965
+ the plug-in route's reference: the README guide shows it, and a test keeps the
966
+ two in step.