@conloca/cms-spa 0.2.6 → 0.3.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 (483) hide show
  1. package/dist/spa/main.css +262 -21
  2. package/dist/ts/.build-inputs.json +99 -57
  3. package/dist/ts/CmsSpaApp.d.ts +4 -6
  4. package/dist/ts/CmsSpaApp.d.ts.map +1 -1
  5. package/dist/ts/CmsSpaApp.js +19 -8
  6. package/dist/ts/CmsSpaApp.js.map +1 -1
  7. package/dist/ts/components/conflicts/EditorNoticeStrip.d.ts +44 -0
  8. package/dist/ts/components/conflicts/EditorNoticeStrip.d.ts.map +1 -0
  9. package/dist/ts/components/conflicts/EditorNoticeStrip.js +55 -0
  10. package/dist/ts/components/conflicts/EditorNoticeStrip.js.map +1 -0
  11. package/dist/ts/components/conflicts/FieldConflictList.d.ts +20 -0
  12. package/dist/ts/components/conflicts/FieldConflictList.d.ts.map +1 -0
  13. package/dist/ts/components/conflicts/FieldConflictList.js +14 -0
  14. package/dist/ts/components/conflicts/FieldConflictList.js.map +1 -0
  15. package/dist/ts/components/conflicts/FieldConflictPicker.d.ts +28 -0
  16. package/dist/ts/components/conflicts/FieldConflictPicker.d.ts.map +1 -0
  17. package/dist/ts/components/conflicts/FieldConflictPicker.js +52 -0
  18. package/dist/ts/components/conflicts/FieldConflictPicker.js.map +1 -0
  19. package/dist/ts/components/conflicts/OverwriteNotice.d.ts +11 -0
  20. package/dist/ts/components/conflicts/OverwriteNotice.d.ts.map +1 -0
  21. package/dist/ts/components/conflicts/OverwriteNotice.js +8 -0
  22. package/dist/ts/components/conflicts/OverwriteNotice.js.map +1 -0
  23. package/dist/ts/components/conflicts/PageDraftMenu.d.ts +11 -0
  24. package/dist/ts/components/conflicts/PageDraftMenu.d.ts.map +1 -0
  25. package/dist/ts/components/conflicts/PageDraftMenu.js +20 -0
  26. package/dist/ts/components/conflicts/PageDraftMenu.js.map +1 -0
  27. package/dist/ts/components/conflicts/PeerAvatars.d.ts +9 -0
  28. package/dist/ts/components/conflicts/PeerAvatars.d.ts.map +1 -0
  29. package/dist/ts/components/conflicts/PeerAvatars.js +29 -0
  30. package/dist/ts/components/conflicts/PeerAvatars.js.map +1 -0
  31. package/dist/ts/components/conflicts/PuckConflicts.d.ts +13 -0
  32. package/dist/ts/components/conflicts/PuckConflicts.d.ts.map +1 -0
  33. package/dist/ts/components/conflicts/PuckConflicts.js +59 -0
  34. package/dist/ts/components/conflicts/PuckConflicts.js.map +1 -0
  35. package/dist/ts/components/conflicts/RecentVersionsDialog.d.ts +15 -0
  36. package/dist/ts/components/conflicts/RecentVersionsDialog.d.ts.map +1 -0
  37. package/dist/ts/components/conflicts/RecentVersionsDialog.js +94 -0
  38. package/dist/ts/components/conflicts/RecentVersionsDialog.js.map +1 -0
  39. package/dist/ts/components/conflicts/conflict-label.d.ts +12 -0
  40. package/dist/ts/components/conflicts/conflict-label.d.ts.map +1 -0
  41. package/dist/ts/components/conflicts/conflict-label.js +120 -0
  42. package/dist/ts/components/conflicts/conflict-label.js.map +1 -0
  43. package/dist/ts/components/conflicts/use-page-conflicts.d.ts +26 -0
  44. package/dist/ts/components/conflicts/use-page-conflicts.d.ts.map +1 -0
  45. package/dist/ts/components/conflicts/use-page-conflicts.js +93 -0
  46. package/dist/ts/components/conflicts/use-page-conflicts.js.map +1 -0
  47. package/dist/ts/components/conflicts/version-copy.d.ts +7 -0
  48. package/dist/ts/components/conflicts/version-copy.d.ts.map +1 -0
  49. package/dist/ts/components/conflicts/version-copy.js +31 -0
  50. package/dist/ts/components/conflicts/version-copy.js.map +1 -0
  51. package/dist/ts/components/dashboard/RecentActivity.d.ts.map +1 -1
  52. package/dist/ts/components/dashboard/RecentActivity.js +2 -1
  53. package/dist/ts/components/dashboard/RecentActivity.js.map +1 -1
  54. package/dist/ts/components/dialogs/CreatePageDialog.js +1 -1
  55. package/dist/ts/components/dialogs/CreatePageDialog.js.map +1 -1
  56. package/dist/ts/components/dialogs/DataPropertiesDialog.d.ts +2 -1
  57. package/dist/ts/components/dialogs/DataPropertiesDialog.d.ts.map +1 -1
  58. package/dist/ts/components/dialogs/DataPropertiesDialog.js +15 -3
  59. package/dist/ts/components/dialogs/DataPropertiesDialog.js.map +1 -1
  60. package/dist/ts/components/dialogs/FragmentPropertiesDialog.d.ts +2 -1
  61. package/dist/ts/components/dialogs/FragmentPropertiesDialog.d.ts.map +1 -1
  62. package/dist/ts/components/dialogs/FragmentPropertiesDialog.js +16 -3
  63. package/dist/ts/components/dialogs/FragmentPropertiesDialog.js.map +1 -1
  64. package/dist/ts/components/dialogs/PageMetadataDialog.d.ts +9 -2
  65. package/dist/ts/components/dialogs/PageMetadataDialog.d.ts.map +1 -1
  66. package/dist/ts/components/dialogs/PageMetadataDialog.js +63 -16
  67. package/dist/ts/components/dialogs/PageMetadataDialog.js.map +1 -1
  68. package/dist/ts/components/dialogs/UnsavedChangesDialog.d.ts +16 -1
  69. package/dist/ts/components/dialogs/UnsavedChangesDialog.d.ts.map +1 -1
  70. package/dist/ts/components/dialogs/UnsavedChangesDialog.js +90 -2
  71. package/dist/ts/components/dialogs/UnsavedChangesDialog.js.map +1 -1
  72. package/dist/ts/components/dialogs/unsaved-guard.d.ts +9 -0
  73. package/dist/ts/components/dialogs/unsaved-guard.d.ts.map +1 -0
  74. package/dist/ts/components/dialogs/unsaved-guard.js +14 -0
  75. package/dist/ts/components/dialogs/unsaved-guard.js.map +1 -0
  76. package/dist/ts/components/editor/CMSMDXEditor.d.ts +6 -1
  77. package/dist/ts/components/editor/CMSMDXEditor.d.ts.map +1 -1
  78. package/dist/ts/components/editor/CMSMDXEditor.js +32 -15
  79. package/dist/ts/components/editor/CMSMDXEditor.js.map +1 -1
  80. package/dist/ts/components/editor/EditorFrame.d.ts +22 -0
  81. package/dist/ts/components/editor/EditorFrame.d.ts.map +1 -0
  82. package/dist/ts/components/editor/EditorFrame.js +72 -0
  83. package/dist/ts/components/editor/EditorFrame.js.map +1 -0
  84. package/dist/ts/components/editor/FragmentBlockTypeSelect.d.ts +10 -0
  85. package/dist/ts/components/editor/FragmentBlockTypeSelect.d.ts.map +1 -0
  86. package/dist/ts/components/editor/FragmentBlockTypeSelect.js +187 -0
  87. package/dist/ts/components/editor/FragmentBlockTypeSelect.js.map +1 -0
  88. package/dist/ts/components/editor/FragmentComponentBlock.d.ts +7 -0
  89. package/dist/ts/components/editor/FragmentComponentBlock.d.ts.map +1 -0
  90. package/dist/ts/components/editor/FragmentComponentBlock.js +180 -0
  91. package/dist/ts/components/editor/FragmentComponentBlock.js.map +1 -0
  92. package/dist/ts/components/editor/FragmentEditor.d.ts +3 -1
  93. package/dist/ts/components/editor/FragmentEditor.d.ts.map +1 -1
  94. package/dist/ts/components/editor/FragmentEditor.js +545 -130
  95. package/dist/ts/components/editor/FragmentEditor.js.map +1 -1
  96. package/dist/ts/components/editor/FragmentEditorHeaderActions.d.ts +20 -0
  97. package/dist/ts/components/editor/FragmentEditorHeaderActions.d.ts.map +1 -0
  98. package/dist/ts/components/editor/FragmentEditorHeaderActions.js +49 -0
  99. package/dist/ts/components/editor/FragmentEditorHeaderActions.js.map +1 -0
  100. package/dist/ts/components/editor/GenericBlock.d.ts.map +1 -1
  101. package/dist/ts/components/editor/GenericBlock.js +109 -12
  102. package/dist/ts/components/editor/GenericBlock.js.map +1 -1
  103. package/dist/ts/components/editor/InlinePreviewFrame.d.ts +19 -0
  104. package/dist/ts/components/editor/InlinePreviewFrame.d.ts.map +1 -0
  105. package/dist/ts/components/editor/InlinePreviewFrame.js +65 -0
  106. package/dist/ts/components/editor/InlinePreviewFrame.js.map +1 -0
  107. package/dist/ts/components/editor/JsxPropsPanel.d.ts.map +1 -1
  108. package/dist/ts/components/editor/JsxPropsPanel.js +62 -2
  109. package/dist/ts/components/editor/JsxPropsPanel.js.map +1 -1
  110. package/dist/ts/components/editor/LocaleSelector.d.ts +2 -1
  111. package/dist/ts/components/editor/LocaleSelector.d.ts.map +1 -1
  112. package/dist/ts/components/editor/LocaleSelector.js +2 -2
  113. package/dist/ts/components/editor/LocaleSelector.js.map +1 -1
  114. package/dist/ts/components/editor/MDXLivePreview.d.ts +2 -0
  115. package/dist/ts/components/editor/MDXLivePreview.d.ts.map +1 -1
  116. package/dist/ts/components/editor/MDXLivePreview.js +30 -38
  117. package/dist/ts/components/editor/MDXLivePreview.js.map +1 -1
  118. package/dist/ts/components/editor/MdxPageEditor.d.ts +7 -2
  119. package/dist/ts/components/editor/MdxPageEditor.d.ts.map +1 -1
  120. package/dist/ts/components/editor/MdxPageEditor.js +136 -10
  121. package/dist/ts/components/editor/MdxPageEditor.js.map +1 -1
  122. package/dist/ts/components/editor/PageEditor.d.ts +4 -1
  123. package/dist/ts/components/editor/PageEditor.d.ts.map +1 -1
  124. package/dist/ts/components/editor/PageEditor.js +78 -100
  125. package/dist/ts/components/editor/PageEditor.js.map +1 -1
  126. package/dist/ts/components/editor/PageEditorHeaderActions.d.ts +15 -4
  127. package/dist/ts/components/editor/PageEditorHeaderActions.d.ts.map +1 -1
  128. package/dist/ts/components/editor/PageEditorHeaderActions.js +13 -7
  129. package/dist/ts/components/editor/PageEditorHeaderActions.js.map +1 -1
  130. package/dist/ts/components/editor/PageEditorWrapper.d.ts +8 -2
  131. package/dist/ts/components/editor/PageEditorWrapper.d.ts.map +1 -1
  132. package/dist/ts/components/editor/PageEditorWrapper.js +99 -41
  133. package/dist/ts/components/editor/PageEditorWrapper.js.map +1 -1
  134. package/dist/ts/components/editor/body-sync-plugin.d.ts +2 -0
  135. package/dist/ts/components/editor/body-sync-plugin.d.ts.map +1 -0
  136. package/dist/ts/components/editor/body-sync-plugin.js +32 -0
  137. package/dist/ts/components/editor/body-sync-plugin.js.map +1 -0
  138. package/dist/ts/components/editor/draft-media-config.d.ts +6 -0
  139. package/dist/ts/components/editor/draft-media-config.d.ts.map +1 -1
  140. package/dist/ts/components/editor/draft-media-config.js +21 -0
  141. package/dist/ts/components/editor/draft-media-config.js.map +1 -1
  142. package/dist/ts/components/editor/fragment-save-check.d.ts +7 -0
  143. package/dist/ts/components/editor/fragment-save-check.d.ts.map +1 -0
  144. package/dist/ts/components/editor/fragment-save-check.js +13 -0
  145. package/dist/ts/components/editor/fragment-save-check.js.map +1 -0
  146. package/dist/ts/components/editor/fragment-save-lifetime.d.ts +18 -0
  147. package/dist/ts/components/editor/fragment-save-lifetime.d.ts.map +1 -0
  148. package/dist/ts/components/editor/fragment-save-lifetime.js +115 -0
  149. package/dist/ts/components/editor/fragment-save-lifetime.js.map +1 -0
  150. package/dist/ts/components/editor/host-wrapper-plugin.d.ts.map +1 -1
  151. package/dist/ts/components/editor/host-wrapper-plugin.js +20 -7
  152. package/dist/ts/components/editor/host-wrapper-plugin.js.map +1 -1
  153. package/dist/ts/components/editor/index.d.ts +0 -1
  154. package/dist/ts/components/editor/index.d.ts.map +1 -1
  155. package/dist/ts/components/editor/index.js +0 -1
  156. package/dist/ts/components/editor/index.js.map +1 -1
  157. package/dist/ts/components/editor/insert-menu/InsertMdxComponentButton.d.ts.map +1 -1
  158. package/dist/ts/components/editor/insert-menu/InsertMdxComponentButton.js +6 -11
  159. package/dist/ts/components/editor/insert-menu/InsertMdxComponentButton.js.map +1 -1
  160. package/dist/ts/components/editor/insert-menu/SlashMenuPlugin.d.ts.map +1 -1
  161. package/dist/ts/components/editor/insert-menu/SlashMenuPlugin.js +66 -12
  162. package/dist/ts/components/editor/insert-menu/SlashMenuPlugin.js.map +1 -1
  163. package/dist/ts/components/editor/insert-menu/insert-payload.d.ts +16 -21
  164. package/dist/ts/components/editor/insert-menu/insert-payload.d.ts.map +1 -1
  165. package/dist/ts/components/editor/insert-menu/insert-payload.js +75 -22
  166. package/dist/ts/components/editor/insert-menu/insert-payload.js.map +1 -1
  167. package/dist/ts/components/editor/insert-menu/mdx-components-plugin.d.ts +3 -1
  168. package/dist/ts/components/editor/insert-menu/mdx-components-plugin.d.ts.map +1 -1
  169. package/dist/ts/components/editor/insert-menu/mdx-components-plugin.js +5 -3
  170. package/dist/ts/components/editor/insert-menu/mdx-components-plugin.js.map +1 -1
  171. package/dist/ts/components/editor/jsx-layout-plugin.d.ts +25 -0
  172. package/dist/ts/components/editor/jsx-layout-plugin.d.ts.map +1 -0
  173. package/dist/ts/components/editor/jsx-layout-plugin.js +77 -0
  174. package/dist/ts/components/editor/jsx-layout-plugin.js.map +1 -0
  175. package/dist/ts/components/editor/offered-mdx-components.d.ts +11 -0
  176. package/dist/ts/components/editor/offered-mdx-components.d.ts.map +1 -0
  177. package/dist/ts/components/editor/offered-mdx-components.js +27 -0
  178. package/dist/ts/components/editor/offered-mdx-components.js.map +1 -0
  179. package/dist/ts/components/editor/page-setting-targets.d.ts.map +1 -1
  180. package/dist/ts/components/editor/page-setting-targets.js +2 -1
  181. package/dist/ts/components/editor/page-setting-targets.js.map +1 -1
  182. package/dist/ts/components/editor/preview-availability.d.ts +16 -1
  183. package/dist/ts/components/editor/preview-availability.d.ts.map +1 -1
  184. package/dist/ts/components/editor/preview-availability.js +16 -1
  185. package/dist/ts/components/editor/preview-availability.js.map +1 -1
  186. package/dist/ts/components/editor/prop-field-hint.d.ts +13 -0
  187. package/dist/ts/components/editor/prop-field-hint.d.ts.map +1 -0
  188. package/dist/ts/components/editor/prop-field-hint.js +70 -0
  189. package/dist/ts/components/editor/prop-field-hint.js.map +1 -0
  190. package/dist/ts/components/editor/soft-break-plugin.d.ts +21 -0
  191. package/dist/ts/components/editor/soft-break-plugin.d.ts.map +1 -0
  192. package/dist/ts/components/editor/soft-break-plugin.js +52 -0
  193. package/dist/ts/components/editor/soft-break-plugin.js.map +1 -0
  194. package/dist/ts/components/editor/use-live-page-settings.d.ts +13 -0
  195. package/dist/ts/components/editor/use-live-page-settings.d.ts.map +1 -0
  196. package/dist/ts/components/editor/use-live-page-settings.js +76 -0
  197. package/dist/ts/components/editor/use-live-page-settings.js.map +1 -0
  198. package/dist/ts/components/editor/usePagePreview.d.ts +32 -0
  199. package/dist/ts/components/editor/usePagePreview.d.ts.map +1 -0
  200. package/dist/ts/components/editor/usePagePreview.js +252 -0
  201. package/dist/ts/components/editor/usePagePreview.js.map +1 -0
  202. package/dist/ts/components/editors/DataEditor.d.ts +6 -3
  203. package/dist/ts/components/editors/DataEditor.d.ts.map +1 -1
  204. package/dist/ts/components/editors/DataEditor.js +153 -19
  205. package/dist/ts/components/editors/DataEditor.js.map +1 -1
  206. package/dist/ts/components/fields/MDXEditField.d.ts +1 -1
  207. package/dist/ts/components/fields/MDXEditField.js +2 -2
  208. package/dist/ts/components/fields/MDXEditField.js.map +1 -1
  209. package/dist/ts/components/forms/SchemaForm.d.ts.map +1 -1
  210. package/dist/ts/components/forms/SchemaForm.js +1 -9
  211. package/dist/ts/components/forms/SchemaForm.js.map +1 -1
  212. package/dist/ts/components/media/AssetDetailSidebar.d.ts.map +1 -1
  213. package/dist/ts/components/media/AssetDetailSidebar.js +43 -5
  214. package/dist/ts/components/media/AssetDetailSidebar.js.map +1 -1
  215. package/dist/ts/components/pages/DataList.d.ts.map +1 -1
  216. package/dist/ts/components/pages/DataList.js +16 -4
  217. package/dist/ts/components/pages/DataList.js.map +1 -1
  218. package/dist/ts/components/pages/FragmentList.d.ts.map +1 -1
  219. package/dist/ts/components/pages/FragmentList.js +10 -0
  220. package/dist/ts/components/pages/FragmentList.js.map +1 -1
  221. package/dist/ts/components/pages/PageList.d.ts.map +1 -1
  222. package/dist/ts/components/pages/PageList.js +54 -118
  223. package/dist/ts/components/pages/PageList.js.map +1 -1
  224. package/dist/ts/components/pages/PageRow.d.ts +21 -0
  225. package/dist/ts/components/pages/PageRow.d.ts.map +1 -0
  226. package/dist/ts/components/pages/PageRow.js +70 -0
  227. package/dist/ts/components/pages/PageRow.js.map +1 -0
  228. package/dist/ts/components/pages/PageTable.d.ts +21 -0
  229. package/dist/ts/components/pages/PageTable.d.ts.map +1 -0
  230. package/dist/ts/components/pages/PageTable.js +12 -0
  231. package/dist/ts/components/pages/PageTable.js.map +1 -0
  232. package/dist/ts/components/pages/page-list-model.d.ts +20 -0
  233. package/dist/ts/components/pages/page-list-model.d.ts.map +1 -0
  234. package/dist/ts/components/pages/page-list-model.js +78 -0
  235. package/dist/ts/components/pages/page-list-model.js.map +1 -0
  236. package/dist/ts/components/puck/MDXContent.d.ts +3 -3
  237. package/dist/ts/components/puck/MDXContent.d.ts.map +1 -1
  238. package/dist/ts/components/puck/MDXContent.js +24 -72
  239. package/dist/ts/components/puck/MDXContent.js.map +1 -1
  240. package/dist/ts/components/puck/csp-frame-harness.d.ts +14 -0
  241. package/dist/ts/components/puck/csp-frame-harness.d.ts.map +1 -0
  242. package/dist/ts/components/puck/csp-frame-harness.js +85 -0
  243. package/dist/ts/components/puck/csp-frame-harness.js.map +1 -0
  244. package/dist/ts/components/puck/use-fragment-render.d.ts +9 -0
  245. package/dist/ts/components/puck/use-fragment-render.d.ts.map +1 -0
  246. package/dist/ts/components/puck/use-fragment-render.js +70 -0
  247. package/dist/ts/components/puck/use-fragment-render.js.map +1 -0
  248. package/dist/ts/components/sandbox/ContentSandbox.d.ts +3 -5
  249. package/dist/ts/components/sandbox/ContentSandbox.d.ts.map +1 -1
  250. package/dist/ts/components/sandbox/ContentSandbox.js +6 -8
  251. package/dist/ts/components/sandbox/ContentSandbox.js.map +1 -1
  252. package/dist/ts/components/sandbox/frame-runtime.d.ts +1 -1
  253. package/dist/ts/components/sandbox/frame-runtime.d.ts.map +1 -1
  254. package/dist/ts/components/sandbox/frame-runtime.js +1 -1
  255. package/dist/ts/components/sandbox/frame-runtime.js.map +1 -1
  256. package/dist/ts/components/toast.d.ts +8 -4
  257. package/dist/ts/components/toast.d.ts.map +1 -1
  258. package/dist/ts/components/toast.js +6 -1
  259. package/dist/ts/components/toast.js.map +1 -1
  260. package/dist/ts/components/ui/Card.d.ts +3 -5
  261. package/dist/ts/components/ui/Card.d.ts.map +1 -1
  262. package/dist/ts/components/ui/Card.js +3 -5
  263. package/dist/ts/components/ui/Card.js.map +1 -1
  264. package/dist/ts/components/ui/Select.d.ts.map +1 -1
  265. package/dist/ts/components/ui/Select.js +12 -3
  266. package/dist/ts/components/ui/Select.js.map +1 -1
  267. package/dist/ts/draft-tools.d.ts +76 -0
  268. package/dist/ts/draft-tools.d.ts.map +1 -0
  269. package/dist/ts/draft-tools.js +2 -0
  270. package/dist/ts/draft-tools.js.map +1 -0
  271. package/dist/ts/frame/channel.d.ts +1 -1
  272. package/dist/ts/frame/channel.d.ts.map +1 -1
  273. package/dist/ts/frame/channel.js +3 -0
  274. package/dist/ts/frame/channel.js.map +1 -1
  275. package/dist/ts/frame/editor-frame.d.ts.map +1 -1
  276. package/dist/ts/frame/editor-frame.js +188 -30
  277. package/dist/ts/frame/editor-frame.js.map +1 -1
  278. package/dist/ts/frame/protocol.d.ts +73 -4
  279. package/dist/ts/frame/protocol.d.ts.map +1 -1
  280. package/dist/ts/frame/protocol.js +54 -16
  281. package/dist/ts/frame/protocol.js.map +1 -1
  282. package/dist/ts/hooks/useUnsavedChangesGuard.d.ts +5 -3
  283. package/dist/ts/hooks/useUnsavedChangesGuard.d.ts.map +1 -1
  284. package/dist/ts/hooks/useUnsavedChangesGuard.js +17 -7
  285. package/dist/ts/hooks/useUnsavedChangesGuard.js.map +1 -1
  286. package/dist/ts/host-style-probe.d.ts.map +1 -1
  287. package/dist/ts/host-style-probe.js +160 -40
  288. package/dist/ts/host-style-probe.js.map +1 -1
  289. package/dist/ts/index.d.ts +13 -0
  290. package/dist/ts/index.d.ts.map +1 -1
  291. package/dist/ts/index.js +14 -0
  292. package/dist/ts/index.js.map +1 -1
  293. package/dist/ts/live/data-binding.d.ts +67 -0
  294. package/dist/ts/live/data-binding.d.ts.map +1 -0
  295. package/dist/ts/live/data-binding.js +215 -0
  296. package/dist/ts/live/data-binding.js.map +1 -0
  297. package/dist/ts/live/doc-channel.d.ts +74 -0
  298. package/dist/ts/live/doc-channel.d.ts.map +1 -0
  299. package/dist/ts/live/doc-channel.js +293 -0
  300. package/dist/ts/live/doc-channel.js.map +1 -0
  301. package/dist/ts/live/held-fragment-edits.d.ts +15 -0
  302. package/dist/ts/live/held-fragment-edits.d.ts.map +1 -0
  303. package/dist/ts/live/held-fragment-edits.js +47 -0
  304. package/dist/ts/live/held-fragment-edits.js.map +1 -0
  305. package/dist/ts/live/markdown-binding.d.ts +54 -0
  306. package/dist/ts/live/markdown-binding.d.ts.map +1 -0
  307. package/dist/ts/live/markdown-binding.js +618 -0
  308. package/dist/ts/live/markdown-binding.js.map +1 -0
  309. package/dist/ts/live/markdown-live-plugin.d.ts +42 -0
  310. package/dist/ts/live/markdown-live-plugin.d.ts.map +1 -0
  311. package/dist/ts/live/markdown-live-plugin.js +918 -0
  312. package/dist/ts/live/markdown-live-plugin.js.map +1 -0
  313. package/dist/ts/live/messages.d.ts +142 -0
  314. package/dist/ts/live/messages.d.ts.map +1 -0
  315. package/dist/ts/live/messages.js +266 -0
  316. package/dist/ts/live/messages.js.map +1 -0
  317. package/dist/ts/live/puck-binding.d.ts +88 -0
  318. package/dist/ts/live/puck-binding.d.ts.map +1 -0
  319. package/dist/ts/live/puck-binding.js +467 -0
  320. package/dist/ts/live/puck-binding.js.map +1 -0
  321. package/dist/ts/live/undo.d.ts +29 -0
  322. package/dist/ts/live/undo.d.ts.map +1 -0
  323. package/dist/ts/live/undo.js +104 -0
  324. package/dist/ts/live/undo.js.map +1 -0
  325. package/dist/ts/live/use-live.d.ts +77 -0
  326. package/dist/ts/live/use-live.d.ts.map +1 -0
  327. package/dist/ts/live/use-live.js +207 -0
  328. package/dist/ts/live/use-live.js.map +1 -0
  329. package/dist/ts/mdx-components-define.d.ts +52 -15
  330. package/dist/ts/mdx-components-define.d.ts.map +1 -1
  331. package/dist/ts/mdx-components-define.js +136 -0
  332. package/dist/ts/mdx-components-define.js.map +1 -1
  333. package/dist/ts/mdx-components.d.ts +11 -19
  334. package/dist/ts/mdx-components.d.ts.map +1 -1
  335. package/dist/ts/mdx-components.js +23 -32
  336. package/dist/ts/mdx-components.js.map +1 -1
  337. package/dist/ts/media/AssetScopePill.d.ts.map +1 -1
  338. package/dist/ts/media/AssetScopePill.js +2 -1
  339. package/dist/ts/media/AssetScopePill.js.map +1 -1
  340. package/dist/ts/merge-default-props.d.ts.map +1 -1
  341. package/dist/ts/merge-default-props.js +3 -0
  342. package/dist/ts/merge-default-props.js.map +1 -1
  343. package/dist/ts/selected-block.d.ts +27 -2
  344. package/dist/ts/selected-block.d.ts.map +1 -1
  345. package/dist/ts/selected-block.js +43 -1
  346. package/dist/ts/selected-block.js.map +1 -1
  347. package/dist/ts/site-render.d.ts +60 -0
  348. package/dist/ts/site-render.d.ts.map +1 -0
  349. package/dist/ts/site-render.js +87 -0
  350. package/dist/ts/site-render.js.map +1 -0
  351. package/dist/ts/types.d.ts +3 -0
  352. package/dist/ts/types.d.ts.map +1 -1
  353. package/dist/ts/ui-config.d.ts +29 -13
  354. package/dist/ts/ui-config.d.ts.map +1 -1
  355. package/dist/ts/ui-config.js +14 -3
  356. package/dist/ts/ui-config.js.map +1 -1
  357. package/dist/ts/utils/apply-clash.d.ts +44 -0
  358. package/dist/ts/utils/apply-clash.d.ts.map +1 -0
  359. package/dist/ts/utils/apply-clash.js +102 -0
  360. package/dist/ts/utils/apply-clash.js.map +1 -0
  361. package/dist/ts/utils/mdast-tree.d.ts +5 -7
  362. package/dist/ts/utils/mdast-tree.d.ts.map +1 -1
  363. package/dist/ts/utils/mdast-tree.js +8 -13
  364. package/dist/ts/utils/mdast-tree.js.map +1 -1
  365. package/dist/ts/utils/pageMetadata.d.ts +6 -2
  366. package/dist/ts/utils/pageMetadata.d.ts.map +1 -1
  367. package/dist/ts/utils/pageMetadata.js +25 -7
  368. package/dist/ts/utils/pageMetadata.js.map +1 -1
  369. package/dist/ts/utils/schema-fields.d.ts +2 -0
  370. package/dist/ts/utils/schema-fields.d.ts.map +1 -1
  371. package/dist/ts/utils/schema-fields.js +8 -0
  372. package/dist/ts/utils/schema-fields.js.map +1 -1
  373. package/dist/ts/write-access.d.ts +2 -0
  374. package/dist/ts/write-access.d.ts.map +1 -1
  375. package/dist/ts/write-access.js +9 -4
  376. package/dist/ts/write-access.js.map +1 -1
  377. package/package.json +18 -7
  378. package/src/CmsSpaApp.tsx +20 -11
  379. package/src/components/conflicts/EditorNoticeStrip.tsx +135 -0
  380. package/src/components/conflicts/FieldConflictList.tsx +59 -0
  381. package/src/components/conflicts/FieldConflictPicker.tsx +158 -0
  382. package/src/components/conflicts/OverwriteNotice.tsx +30 -0
  383. package/src/components/conflicts/PageDraftMenu.tsx +51 -0
  384. package/src/components/conflicts/PeerAvatars.tsx +51 -0
  385. package/src/components/conflicts/PuckConflicts.tsx +92 -0
  386. package/src/components/conflicts/RecentVersionsDialog.tsx +154 -0
  387. package/src/components/conflicts/conflict-label.ts +124 -0
  388. package/src/components/conflicts/use-page-conflicts.ts +112 -0
  389. package/src/components/conflicts/version-copy.ts +33 -0
  390. package/src/components/dashboard/RecentActivity.tsx +3 -2
  391. package/src/components/dialogs/CreatePageDialog.tsx +1 -1
  392. package/src/components/dialogs/DataPropertiesDialog.tsx +22 -4
  393. package/src/components/dialogs/FragmentPropertiesDialog.tsx +23 -4
  394. package/src/components/dialogs/PageMetadataDialog.tsx +157 -65
  395. package/src/components/dialogs/UnsavedChangesDialog.tsx +171 -21
  396. package/src/components/dialogs/unsaved-guard.ts +15 -0
  397. package/src/components/editor/CMSMDXEditor.tsx +238 -198
  398. package/src/components/editor/EditorFrame.tsx +116 -0
  399. package/src/components/editor/FragmentBlockTypeSelect.tsx +245 -0
  400. package/src/components/editor/FragmentComponentBlock.tsx +257 -0
  401. package/src/components/editor/FragmentEditor.tsx +899 -213
  402. package/src/components/editor/FragmentEditorHeaderActions.tsx +77 -0
  403. package/src/components/editor/GenericBlock.tsx +127 -16
  404. package/src/components/editor/InlinePreviewFrame.tsx +78 -0
  405. package/src/components/editor/JsxPropsPanel.tsx +90 -6
  406. package/src/components/editor/LocaleSelector.tsx +4 -2
  407. package/src/components/editor/MDXLivePreview.tsx +44 -46
  408. package/src/components/editor/MdxPageEditor.tsx +247 -7
  409. package/src/components/editor/PageEditor.tsx +154 -121
  410. package/src/components/editor/PageEditorHeaderActions.tsx +65 -27
  411. package/src/components/editor/PageEditorWrapper.tsx +122 -45
  412. package/src/components/editor/body-sync-plugin.ts +44 -0
  413. package/src/components/editor/draft-media-config.ts +22 -0
  414. package/src/components/editor/fragment-save-check.ts +26 -0
  415. package/src/components/editor/fragment-save-lifetime.ts +142 -0
  416. package/src/components/editor/host-wrapper-plugin.ts +28 -7
  417. package/src/components/editor/index.ts +0 -1
  418. package/src/components/editor/insert-menu/InsertMdxComponentButton.tsx +7 -11
  419. package/src/components/editor/insert-menu/SlashMenuPlugin.tsx +95 -18
  420. package/src/components/editor/insert-menu/insert-payload.ts +79 -30
  421. package/src/components/editor/insert-menu/mdx-components-plugin.ts +5 -3
  422. package/src/components/editor/jsx-layout-plugin.ts +103 -0
  423. package/src/components/editor/offered-mdx-components.ts +35 -0
  424. package/src/components/editor/page-setting-targets.tsx +2 -0
  425. package/src/components/editor/preview-availability.ts +21 -1
  426. package/src/components/editor/prop-field-hint.ts +75 -0
  427. package/src/components/editor/soft-break-plugin.ts +55 -0
  428. package/src/components/editor/use-live-page-settings.ts +80 -0
  429. package/src/components/editor/usePagePreview.ts +291 -0
  430. package/src/components/editors/DataEditor.tsx +257 -22
  431. package/src/components/fields/MDXEditField.tsx +2 -2
  432. package/src/components/forms/SchemaForm.tsx +1 -10
  433. package/src/components/media/AssetDetailSidebar.tsx +47 -6
  434. package/src/components/pages/DataList.tsx +14 -4
  435. package/src/components/pages/FragmentList.tsx +8 -0
  436. package/src/components/pages/PageList.tsx +90 -337
  437. package/src/components/pages/PageRow.tsx +290 -0
  438. package/src/components/pages/PageTable.tsx +71 -0
  439. package/src/components/pages/page-list-model.ts +98 -0
  440. package/src/components/puck/MDXContent.tsx +37 -113
  441. package/src/components/puck/csp-frame-harness.tsx +99 -0
  442. package/src/components/puck/use-fragment-render.ts +82 -0
  443. package/src/components/sandbox/ContentSandbox.tsx +6 -11
  444. package/src/components/sandbox/frame-runtime.ts +0 -2
  445. package/src/components/toast.tsx +23 -5
  446. package/src/components/ui/Card.tsx +3 -5
  447. package/src/components/ui/Select.tsx +14 -6
  448. package/src/draft-tools.ts +77 -0
  449. package/src/frame/channel.ts +3 -1
  450. package/src/frame/editor-frame.ts +210 -30
  451. package/src/frame/protocol.ts +98 -15
  452. package/src/hooks/useUnsavedChangesGuard.ts +17 -6
  453. package/src/host-style-probe.ts +157 -37
  454. package/src/index.ts +90 -0
  455. package/src/live/data-binding.ts +252 -0
  456. package/src/live/doc-channel.ts +343 -0
  457. package/src/live/held-fragment-edits.ts +47 -0
  458. package/src/live/markdown-binding.ts +630 -0
  459. package/src/live/markdown-live-plugin.tsx +1037 -0
  460. package/src/live/messages.ts +370 -0
  461. package/src/live/puck-binding.tsx +579 -0
  462. package/src/live/undo.ts +112 -0
  463. package/src/live/use-live.ts +264 -0
  464. package/src/main.css +184 -4
  465. package/src/mdx-components-define.ts +170 -24
  466. package/src/mdx-components.ts +29 -30
  467. package/src/media/AssetScopePill.tsx +2 -1
  468. package/src/merge-default-props.ts +4 -0
  469. package/src/selected-block.ts +55 -3
  470. package/src/site-render.ts +146 -0
  471. package/src/types.ts +3 -0
  472. package/src/ui-config.ts +51 -15
  473. package/src/utils/apply-clash.ts +113 -0
  474. package/src/utils/mdast-tree.ts +8 -12
  475. package/src/utils/pageMetadata.ts +25 -7
  476. package/src/utils/schema-fields.ts +9 -0
  477. package/src/write-access.ts +10 -4
  478. package/styles/tailwind-theme.css +11 -0
  479. package/dist/ts/components/editor/ContentDiff.d.ts +0 -10
  480. package/dist/ts/components/editor/ContentDiff.d.ts.map +0 -1
  481. package/dist/ts/components/editor/ContentDiff.js +0 -52
  482. package/dist/ts/components/editor/ContentDiff.js.map +0 -1
  483. package/src/components/editor/ContentDiff.tsx +0 -251
@@ -0,0 +1,77 @@
1
+ /** React hooks over the editor's doc channel, and the one-edit write the notices and pickers use. */
2
+ import type { ContentData } from '@conloca/content-api';
3
+ import { type EditorFlushResult } from '../editor-flush.js';
4
+ import { type DocChannel, type FrameLiveDoc } from './doc-channel.js';
5
+ import { type DocOpenRequest, type JsonValue, type LiveMessage, type LiveStatus, type PresencePeer } from './messages.js';
6
+ export type LiveDocState = {
7
+ state: 'loading';
8
+ } | {
9
+ state: 'ready';
10
+ live: FrameLiveDoc;
11
+ } | {
12
+ state: 'failed';
13
+ message: string;
14
+ };
15
+ /** Where a doc binding stands: `bound` follows every handover at once, `shown` is what the editor has rendered. */
16
+ export interface LiveBinding {
17
+ readonly bound: FrameLiveDoc | null;
18
+ readonly shown: FrameLiveDoc | null;
19
+ /** The open answered. */
20
+ bind(live: FrameLiveDoc): void;
21
+ /** The editor rendered `shown`: a replica it moved off is destroyed, then its key closed. */
22
+ commit(shown: FrameLiveDoc | null): void;
23
+ /** The editor unmounts: every replica it held closes (a held one stays for the next mount). */
24
+ stop(): void;
25
+ }
26
+ /**
27
+ * `useLiveDoc`'s handover: on `doc.replaced` the binding moves to the new replica, and the old one is closed only after
28
+ * the editor rendered the new one, so its edits until then still go out under the old key. A replica replaced again
29
+ * before it was ever rendered is closed at once.
30
+ */
31
+ export declare function followHandovers(channel: DocChannel, onMove: (live: FrameLiveDoc) => void): LiveBinding;
32
+ /** Opens `req` through the doc channel and follows its handovers (see `followHandovers`). */
33
+ export declare function useLiveDoc(req: DocOpenRequest | null): LiveDocState;
34
+ /** Calls `handler` with each live message of `type` while mounted. */
35
+ export declare function useLiveMessage<T extends LiveMessage['type']>(type: T, handler: (m: Extract<LiveMessage, {
36
+ type: T;
37
+ }>) => void): void;
38
+ export declare function useLiveStatus(): LiveStatus | null;
39
+ export declare function usePresencePeers(docKey: string): PresencePeer[];
40
+ /**
41
+ * Pushes pending work: held work answers not ok with its notice, otherwise the parent answers; without a channel the
42
+ * open editor's own save runs.
43
+ */
44
+ export declare function flushLive(): Promise<EditorFlushResult>;
45
+ /** Some replica or value in this frame is held; a leave guard counts it as unsaved. */
46
+ export declare function anyHeld(): boolean;
47
+ /** The serialized held replica of `docKey`, for its copy-out button; null when it is not held. */
48
+ export declare function heldContent(docKey: string): ContentData | null;
49
+ export type DocEditResult = {
50
+ ok: true;
51
+ } | {
52
+ ok: false;
53
+ reason: 'not-found' | 'not-open' | 'error' | 'changed';
54
+ message: string;
55
+ };
56
+ export type DocEditValue = JsonValue | null | undefined;
57
+ /** `expected`, when given, is the value the anchor must still hold; anything else refuses the write as `changed`. */
58
+ export type DocEdit = {
59
+ anchor: string;
60
+ value: DocEditValue;
61
+ expected?: DocEditValue;
62
+ };
63
+ export type DocEdits = (edits: DocEdit[]) => DocEditResult;
64
+ /**
65
+ * Writes each edit at its content anchor over the serialized doc, then applies the result in one transaction: all or
66
+ * nothing. Never throws.
67
+ */
68
+ export declare function applyDocEdits(live: FrameLiveDoc | undefined, edits: DocEdit[]): DocEditResult;
69
+ /** One value at an anchor (Restore yours, picker choices); `undefined` removes the key. */
70
+ export declare function useDocEdit(docKey: string): (anchor: string, value: DocEditValue, expected?: {
71
+ value: DocEditValue;
72
+ }) => DocEditResult;
73
+ /** Reads the value at an anchor in the open doc now; `undefined` when it is absent or the doc is not open. */
74
+ export declare function useDocRead(docKey: string): (anchor: string) => DocEditValue;
75
+ /** Several values in one transaction (MDX page settings): all keys or none. */
76
+ export declare function useDocEdits(docKey: string): DocEdits;
77
+ //# sourceMappingURL=use-live.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-live.d.ts","sourceRoot":"","sources":["../../../src/live/use-live.ts"],"names":[],"mappings":"AAAA,qGAAqG;AAErG,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAIxD,OAAO,EAAE,KAAK,iBAAiB,EAAmB,MAAM,oBAAoB,CAAC;AAE7E,OAAO,EAAE,KAAK,UAAU,EAAe,KAAK,YAAY,EAAqC,MAAM,kBAAkB,CAAC;AACtH,OAAO,EACL,KAAK,cAAc,EAEnB,KAAK,SAAS,EACd,KAAK,W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1
+ /** React hooks over the editor's doc channel, and the one-edit write the notices and pickers use. */
2
+ import { applyAnchorValue, deepEqual, valueAtAnchor } from '@conloca/content-api/merge';
3
+ import { applyContentDiff, serializeDoc } from '@conloca/content-api/ydoc';
4
+ import { useCallback, useEffect, useRef, useState, useSyncExternalStore } from 'react';
5
+ import { flushOpenEditor } from '../editor-flush.js';
6
+ import { getUIConfig } from '../ui-config.js';
7
+ import { EDIT_ORIGIN, openFailureMessage, useDocChannel } from './doc-channel.js';
8
+ import { isJsonValue, } from './messages.js';
9
+ /**
10
+ * `useLiveDoc`'s handover: on `doc.replaced` the binding moves to the new replica, and the old one is closed only after
11
+ * the editor rendered the new one, so its edits until then still go out under the old key. A replica replaced again
12
+ * before it was ever rendered is closed at once.
13
+ */
14
+ export function followHandovers(channel, onMove) {
15
+ let bound = null;
16
+ let shown = null;
17
+ const stopReplaced = channel.on('replaced', (event) => {
18
+ if (bound === null || event.docKey !== bound.docKey)
19
+ return;
20
+ if (bound !== shown)
21
+ bound.close();
22
+ bound = event.live;
23
+ onMove(event.live);
24
+ });
25
+ return {
26
+ get bound() {
27
+ return bound;
28
+ },
29
+ get shown() {
30
+ return shown;
31
+ },
32
+ bind(live) {
33
+ bound = live;
34
+ onMove(live);
35
+ },
36
+ commit(next) {
37
+ const before = shown;
38
+ shown = next;
39
+ if (before !== null && next !== null && before !== next)
40
+ before.close();
41
+ },
42
+ stop() {
43
+ stopReplaced();
44
+ bound?.close();
45
+ if (shown !== bound)
46
+ shown?.close();
47
+ },
48
+ };
49
+ }
50
+ /** Opens `req` through the doc channel and follows its handovers (see `followHandovers`). */
51
+ export function useLiveDoc(req) {
52
+ const channel = useDocChannel();
53
+ const [state, setState] = useState({ state: 'loading' });
54
+ const binding = useRef(null);
55
+ const kind = req?.kind;
56
+ const id = req?.id;
57
+ const locale = req?.locale;
58
+ useEffect(() => {
59
+ if (!channel || kind === undefined || id === undefined || locale === undefined)
60
+ return undefined;
61
+ const abort = new AbortController();
62
+ const handover = followHandovers(channel, (live) => setState({ state: 'ready', live }));
63
+ binding.current = handover;
64
+ setState({ state: 'loading' });
65
+ channel.open({ kind, id, locale }, abort.signal).then((live) => handover.bind(live), (error) => {
66
+ if (!abort.signal.aborted)
67
+ setState({ state: 'failed', message: openFailureMessage(error) });
68
+ });
69
+ return () => {
70
+ abort.abort();
71
+ handover.stop();
72
+ };
73
+ }, [channel, kind, id, locale]);
74
+ const shown = state.state === 'ready' ? state.live : null;
75
+ useEffect(() => {
76
+ binding.current?.commit(shown);
77
+ }, [shown]);
78
+ return state;
79
+ }
80
+ /** Calls `handler` with each live message of `type` while mounted. */
81
+ export function useLiveMessage(type, handler) {
82
+ const channel = useDocChannel();
83
+ const latest = useRef(handler);
84
+ latest.current = handler;
85
+ useEffect(() => {
86
+ if (!channel)
87
+ return undefined;
88
+ return channel.on('message', (message) => {
89
+ if (isOfType(message, type))
90
+ latest.current(message);
91
+ });
92
+ }, [channel, type]);
93
+ }
94
+ function isOfType(message, type) {
95
+ return message.type === type;
96
+ }
97
+ const noSubscribe = () => () => { };
98
+ export function useLiveStatus() {
99
+ const channel = useDocChannel();
100
+ return useSyncExternalStore(channel ? (notify) => channel.on('status', notify) : noSubscribe, () => channel?.status() ?? null);
101
+ }
102
+ const NO_PEERS = [];
103
+ export function usePresencePeers(docKey) {
104
+ const channel = useDocChannel();
105
+ return useSyncExternalStore(channel ? (notify) => channel.on('peers', notify) : noSubscribe, () => channel?.peers(docKey) ?? NO_PEERS);
106
+ }
107
+ /**
108
+ * Pushes pending work: held work answers not ok with its notice, otherwise the parent answers; without a channel the
109
+ * open editor's own save runs.
110
+ */
111
+ export async function flushLive() {
112
+ const channel = getUIConfig().docChannel;
113
+ return channel ? channel.flush() : flushOpenEditor();
114
+ }
115
+ /** Some replica or value in this frame is held; a leave guard counts it as unsaved. */
116
+ export function anyHeld() {
117
+ return (getUIConfig().docChannel?.held() ?? null) !== null;
118
+ }
119
+ /** The serialized held replica of `docKey`, for its copy-out button; null when it is not held. */
120
+ export function heldContent(docKey) {
121
+ return getUIConfig().docChannel?.heldContent(docKey) ?? null;
122
+ }
123
+ const NOT_FOUND = 'This block was deleted, so the value could not be restored.';
124
+ const CHANGED = 'Changed again since. Check the field.';
125
+ /** The parsed file the anchor helpers read, from a serialized doc. */
126
+ function wrap(content) {
127
+ if (typeof content.mdx === 'string')
128
+ return { kind: 'mdx', doc: content.mdx };
129
+ if (content.puckData !== undefined)
130
+ return { kind: 'vxjson', doc: { type: 'puck', content: { puckData: content.puckData } } };
131
+ if (content.data !== undefined) {
132
+ return isJsonValue(content.data) ? { kind: 'vxjson', doc: { type: 'json', data: content.data } } : null;
133
+ }
134
+ return null;
135
+ }
136
+ function unwrap(kind, doc) {
137
+ if (kind === 'mdx')
138
+ return typeof doc === 'string' ? { mdx: doc } : null;
139
+ if (typeof doc !== 'object' || doc === null || Array.isArray(doc))
140
+ return null;
141
+ const { content, data } = doc;
142
+ if (typeof content === 'object' && content !== null && !Array.isArray(content))
143
+ return { puckData: content.puckData };
144
+ return typeof data === 'object' && data !== null && !Array.isArray(data) ? { data } : null;
145
+ }
146
+ /**
147
+ * Writes each edit at its content anchor over the serialized doc, then applies the result in one transaction: all or
148
+ * nothing. Never throws.
149
+ */
150
+ export function applyDocEdits(live, edits) {
151
+ if (!live)
152
+ return { ok: false, reason: 'not-open', message: 'This page is not open for editing.' };
153
+ if (live.held)
154
+ return { ok: false, reason: 'error', message: getUIConfig().docChannel?.held() ?? 'This page is held.' };
155
+ try {
156
+ const base = wrap(serializeDoc(live.doc));
157
+ if (!base)
158
+ return { ok: false, reason: 'error', message: 'This page could not be read.' };
159
+ let current = base.doc;
160
+ for (const edit of edits) {
161
+ const { anchor, value } = edit;
162
+ const input = { kind: base.kind, doc: current, anchor, base: base.doc };
163
+ const found = valueAtAnchor(input);
164
+ const now = found.found ? found.value : undefined;
165
+ if ('expected' in edit && !deepEqual(now, edit.expected))
166
+ return { ok: false, reason: 'changed', message: CHANGED };
167
+ const written = applyAnchorValue({ ...input, expected: now, value });
168
+ if (!written.ok)
169
+ return { ok: false, reason: 'not-found', message: NOT_FOUND };
170
+ current = written.doc;
171
+ }
172
+ const next = unwrap(base.kind, current);
173
+ if (!next)
174
+ return { ok: false, reason: 'error', message: 'This page could not be written.' };
175
+ applyContentDiff(live.doc, next, EDIT_ORIGIN);
176
+ return { ok: true };
177
+ }
178
+ catch (error) {
179
+ console.error('[live] could not write an edit', error);
180
+ return { ok: false, reason: 'error', message: error instanceof Error ? error.message : String(error) };
181
+ }
182
+ }
183
+ /** One value at an anchor (Restore yours, picker choices); `undefined` removes the key. */
184
+ export function useDocEdit(docKey) {
185
+ const channel = useDocChannel();
186
+ return useCallback((anchor, value, expected) => applyDocEdits(channel?.live(docKey), [
187
+ expected ? { anchor, value, expected: expected.value } : { anchor, value },
188
+ ]), [channel, docKey]);
189
+ }
190
+ /** Reads the value at an anchor in the open doc now; `undefined` when it is absent or the doc is not open. */
191
+ export function useDocRead(docKey) {
192
+ const channel = useDocChannel();
193
+ return useCallback((anchor) => {
194
+ const live = channel?.live(docKey);
195
+ const base = live ? wrap(serializeDoc(live.doc)) : null;
196
+ if (!base)
197
+ return undefined;
198
+ const found = valueAtAnchor({ kind: base.kind, doc: base.doc, anchor, base: base.doc });
199
+ return found.found ? found.value : undefined;
200
+ }, [channel, docKey]);
201
+ }
202
+ /** Several values in one transaction (MDX page settings): all keys or none. */
203
+ export function useDocEdits(docKey) {
204
+ const channel = useDocChannel();
205
+ return useCallback((edits) => applyDocEdits(channel?.live(docKey), edits), [channel, docKey]);
206
+ }
207
+ //# sourceMappingURL=use-live.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-live.js","sourceRoot":"","sources":["../../../src/live/use-live.ts"],"names":[],"mappings":"AAAA,qGAAqG;AAGrG,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AACxF,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,2BAA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KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;IAC/C,CAAC,EACD,CAAC,OAAO,EAAE,MAAM,CAAC,CAClB,CAAC;AACJ,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,WAAW,CAAC,MAAc;IACxC,MAAM,OAAO,GAAG,aAAa,EAAE,CAAC;IAChC,OAAO,WAAW,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;AAChG,CAAC"}
@@ -6,6 +6,7 @@
6
6
  * `mdx-components.ts`, which re-exports everything here for compatibility.
7
7
  * Mirrors the `page-schemas` / `page-schema-define` split.
8
8
  */
9
+ import { type FragmentOutlineProps, type JsonValue } from '@conloca/mdx/render';
9
10
  import type { JsxEditorProps } from '@mdxeditor/editor';
10
11
  import type { MdxJsxFlowElement, MdxJsxTextElement } from 'mdast-util-mdx-jsx';
11
12
  import type { ComponentType } from 'react';
@@ -33,32 +34,36 @@ import type { ComponentType } from 'react';
33
34
  * referenced in the document. Unrelated author imports (types, side
34
35
  * effects) are dropped. See the astro-cms README for the full constraint.
35
36
  */
36
- export type MdxComponentProp = {
37
+ /** Fields every prop shares. `hidden` keeps a top-level prop out of the settings panel; its value is still kept. */
38
+ interface MdxComponentPropBase {
37
39
  name: string;
38
- type: 'string';
39
40
  required?: boolean;
40
41
  label?: string;
41
42
  help?: string;
43
+ hidden?: boolean;
44
+ }
45
+ export type MdxComponentProp = (MdxComponentPropBase & {
46
+ type: 'string';
42
47
  defaultValue?: string;
43
48
  options?: ReadonlyArray<{
44
49
  value: string;
45
50
  label: string;
46
51
  }>;
47
- } | {
48
- name: string;
52
+ }) | (MdxComponentPropBase & {
49
53
  type: 'number';
50
- required?: boolean;
51
- label?: string;
52
- help?: string;
53
54
  defaultValue?: number;
54
- } | {
55
- name: string;
55
+ }) | (MdxComponentPropBase & {
56
56
  type: 'boolean';
57
- required?: boolean;
58
- label?: string;
59
- help?: string;
60
57
  defaultValue?: boolean;
61
- };
58
+ }) | (MdxComponentPropBase & {
59
+ type: 'list';
60
+ of: MdxComponentField;
61
+ }) | (MdxComponentPropBase & {
62
+ type: 'object';
63
+ fields: Record<string, MdxComponentField>;
64
+ });
65
+ /** A list item or object field: an `MdxComponentProp` without `name`. */
66
+ export type MdxComponentField = MdxComponentProp extends infer P ? P extends MdxComponentProp ? Omit<P, 'name'> : never : never;
62
67
  export interface MdxComponentInsertHint {
63
68
  /** Human-readable label shown in the slash menu and the toolbar dropdown. */
64
69
  label: string;
@@ -91,9 +96,15 @@ export interface MdxJsxComponentDescriptor {
91
96
  props?: ReadonlyArray<MdxComponentProp>;
92
97
  /** Whether the component accepts children (nested rich-text editor). */
93
98
  hasChildren?: boolean;
99
+ /**
100
+ * Offer the component in the fragment editor's Block type dropdown, next to Paragraph and the headings: its body is
101
+ * one line of text, such as an eyebrow or a quiet title. Choosing it turns the line into the component; choosing
102
+ * Paragraph turns it back. Needs `kind: 'flow'` and `hasChildren: true`.
103
+ */
104
+ blockType?: boolean;
94
105
  /** Default attributes used at insert time. */
95
106
  defaults?: {
96
- attributes?: Record<string, string | number | boolean>;
107
+ attributes?: Record<string, JsonValue>;
97
108
  /** Raw MDX snippet parsed to mdast children at insert time. */
98
109
  children?: string;
99
110
  };
@@ -140,6 +151,25 @@ export type MdxComponents = ReadonlyArray<MdxComponentDescriptor>;
140
151
  export declare function isJsxDescriptor(d: MdxComponentDescriptor): d is MdxJsxComponentDescriptor;
141
152
  /** Type guard: descriptor is the snippet variant. */
142
153
  export declare function isSnippetDescriptor(d: MdxComponentDescriptor): d is MdxSnippetDescriptor;
154
+ /**
155
+ * Merge auto-discovered descriptors over host-authored ones.
156
+ *
157
+ * Discovered entries win on a name collision: they are derived from the
158
+ * source of truth (the MDX files and component folders themselves), while a
159
+ * hand-written list can lag. Discovery cannot see the host's editor settings,
160
+ * though: the host's `insert` (labels, descriptions), `props` (labels, help,
161
+ * `hidden`) and `blockType` stay on the merged entry. The exception is a name
162
+ * in `hostWins`, the site's fragment vocabulary components: there the host's
163
+ * declared types are the contract, so the host entry is kept and the
164
+ * discovered one dropped. ONE rule for every caller: the editors and the
165
+ * component manifest.
166
+ *
167
+ * Host survivors keep their relative order and discovered entries append
168
+ * after them, so a colliding entry surfaces at its discovered position, not
169
+ * its host slot. Inputs are assumed unique-by-name — that validation lives
170
+ * in `defineMdxComponents` and the discovery merge, not here.
171
+ */
172
+ export declare function mergeDiscoveredMdxComponents(hostAuthored: MdxComponents, discovered: MdxComponents, hostWins?: ReadonlySet<string>): MdxComponents;
143
173
  /**
144
174
  * Identity helper that validates registration-time invariants.
145
175
  *
@@ -164,6 +194,12 @@ export declare function readStringAttribute(node: MdxJsxFlowElement | MdxJsxText
164
194
  * back to the file.
165
195
  */
166
196
  export declare function writeStringAttribute<T extends MdxJsxFlowElement | MdxJsxTextElement>(attributes: T['attributes'], name: string, value: string): T['attributes'];
197
+ /**
198
+ * `attributes` with the outline anchor (the `outline.id` prop) made from the contents text (`outline.text`) when the
199
+ * element has no anchor and has text. An existing anchor is never changed, so links to it keep working after the text
200
+ * is edited. `taken` holds the anchors already in the document.
201
+ */
202
+ export declare function withOutlineId<T extends MdxJsxFlowElement | MdxJsxTextElement>(attributes: T['attributes'], outline: FragmentOutlineProps, taken: Iterable<string>): T['attributes'];
167
203
  /**
168
204
  * Type-aware attribute writer. Encodes the value into the right
169
205
  * mdast shape so the saved MDX matches what an author would write
@@ -181,5 +217,6 @@ export declare function writeStringAttribute<T extends MdxJsxFlowElement | MdxJs
181
217
  * encoding so a `stagger?: boolean` round-trips as `<CardGrid stagger>`
182
218
  * and not the truthy-but-incorrect `<CardGrid stagger="true">`.
183
219
  */
184
- export declare function writeAttribute<T extends MdxJsxFlowElement | MdxJsxTextElement>(attributes: T['attributes'], name: string, value: string | boolean | number | null | undefined): T['attributes'];
220
+ export declare function writeAttribute<T extends MdxJsxFlowElement | MdxJsxTextElement>(attributes: T['attributes'], name: string, value: JsonValue | null | undefined): T['attributes'];
221
+ export {};
185
222
  //# sourceMappingURL=mdx-components-define.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mdx-components-define.d.ts","sourceRoot":"","sources":["../../src/mdx-components-define.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,KAAK,EAAmB,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAChG,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE3C;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,MAAM,MAAM,gBAAgB,GACxB;IACE,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,QAAQ,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,aAAa,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC3D,GACD;IACE,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,QAAQ,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GACD;IACE,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,SAAS,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,CA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ACtB,CAAC,CAAC,YAAY,CAAC,CAOjB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,iBAAiB,GAAG,iBAAiB,EAC5E,UAAU,EAAE,CAAC,CAAC,YAAY,CAAC,EAC3B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,SAAS,GAAG,IAAI,GAAG,SAAS,GAClC,CAAC,CAAC,YAAY,CAAC,CA6BjB"}
@@ -1,3 +1,12 @@
1
+ /**
2
+ * DECLARATION side of the MDX-components plugin API — the half a host's
3
+ * schemas module needs. Deliberately free of editor runtime imports so it
4
+ * evaluates anywhere a content config or test runner does (no DOM, no vite
5
+ * transform): the editor runtime (GenericBlock, the shared registry) lives in
6
+ * `mdx-components.ts`, which re-exports everything here for compatibility.
7
+ * Mirrors the `page-schemas` / `page-schema-define` split.
8
+ */
9
+ import { outlineIdFor } from '@conloca/mdx/render';
1
10
  /** Type guard: descriptor is the JSX variant (vs. a snippet). */
2
11
  export function isJsxDescriptor(d) {
3
12
  return d.kind === 'flow' || d.kind === 'text';
@@ -6,6 +15,47 @@ export function isJsxDescriptor(d) {
6
15
  export function isSnippetDescriptor(d) {
7
16
  return d.kind === 'snippet';
8
17
  }
18
+ /**
19
+ * Merge auto-discovered descriptors over host-authored ones.
20
+ *
21
+ * Discovered entries win on a name collision: they are derived from the
22
+ * source of truth (the MDX files and component folders themselves), while a
23
+ * hand-written list can lag. Discovery cannot see the host's editor settings,
24
+ * though: the host's `insert` (labels, descriptions), `props` (labels, help,
25
+ * `hidden`) and `blockType` stay on the merged entry. The exception is a name
26
+ * in `hostWins`, the site's fragment vocabulary components: there the host's
27
+ * declared types are the contract, so the host entry is kept and the
28
+ * discovered one dropped. ONE rule for every caller: the editors and the
29
+ * component manifest.
30
+ *
31
+ * Host survivors keep their relative order and discovered entries append
32
+ * after them, so a colliding entry surfaces at its discovered position, not
33
+ * its host slot. Inputs are assumed unique-by-name — that validation lives
34
+ * in `defineMdxComponents` and the discovery merge, not here.
35
+ */
36
+ export function mergeDiscoveredMdxComponents(hostAuthored, discovered, hostWins = new Set()) {
37
+ if (discovered.length === 0)
38
+ return hostAuthored;
39
+ const host = new Map(hostAuthored.map((descriptor) => [descriptor.name, descriptor]));
40
+ const kept = discovered.filter((descriptor) => !(hostWins.has(descriptor.name) && host.has(descriptor.name)));
41
+ const keptNames = new Set(kept.map((descriptor) => descriptor.name));
42
+ const merged = hostAuthored.filter((descriptor) => !keptNames.has(descriptor.name));
43
+ for (const descriptor of kept) {
44
+ const authored = host.get(descriptor.name);
45
+ if (!authored || !isJsxDescriptor(authored) || !isJsxDescriptor(descriptor)) {
46
+ merged.push(descriptor);
47
+ continue;
48
+ }
49
+ const { insert, props, blockType } = authored;
50
+ merged.push({
51
+ ...descriptor,
52
+ ...(insert && { insert }),
53
+ ...(props && { props }),
54
+ ...(blockType !== undefined && { blockType }),
55
+ });
56
+ }
57
+ return merged;
58
+ }
9
59
  /**
10
60
  * Identity helper that validates registration-time invariants.
11
61
  *
@@ -36,10 +86,18 @@ export function defineMdxComponents(components) {
36
86
  }
37
87
  throw new Error(`defineMdxComponents: duplicate descriptor for '${descriptor.name}'.`);
38
88
  }
89
+ if (isJsxDescriptor(descriptor))
90
+ checkJsxProps(descriptor);
39
91
  if (isJsxDescriptor(descriptor) && descriptor.kind === 'text' && descriptor.hasChildren) {
40
92
  throw new Error(`defineMdxComponents: descriptor '${descriptor.name}' has kind: 'text' with hasChildren: true — ` +
41
93
  "text-kind JSX is treated as an inline atom; use kind: 'flow' for components with children.");
42
94
  }
95
+ if (isJsxDescriptor(descriptor) &&
96
+ descriptor.blockType &&
97
+ (descriptor.kind !== 'flow' || !descriptor.hasChildren)) {
98
+ throw new Error(`defineMdxComponents: descriptor '${descriptor.name}' has blockType: true — a block type holds a line of text, ` +
99
+ "so it needs kind: 'flow' and hasChildren: true.");
100
+ }
43
101
  if (isSnippetDescriptor(descriptor) && descriptor.content.length === 0) {
44
102
  throw new Error(`defineMdxComponents: snippet descriptor '${descriptor.name}' has empty content — ` +
45
103
  'a snippet with no content would silently insert nothing.');
@@ -48,6 +106,63 @@ export function defineMdxComponents(components) {
48
106
  }
49
107
  return components;
50
108
  }
109
+ function isPlainObject(v) {
110
+ return typeof v === 'object' && v !== null && !Array.isArray(v);
111
+ }
112
+ /** Throws when a field has an unusable shape or `value` (when given) contradicts it. `path` is `Card.cta.href`. */
113
+ function checkField(field, path, value) {
114
+ const fail = (why) => {
115
+ throw new Error(`defineMdxComponents: ${path} ${why}.`);
116
+ };
117
+ const typeName = field.type;
118
+ const has = value !== undefined && value !== null;
119
+ switch (field.type) {
120
+ case 'string':
121
+ case 'number':
122
+ case 'boolean':
123
+ if (has && typeof value !== field.type)
124
+ fail(`default must be a ${field.type}`);
125
+ return;
126
+ case 'list':
127
+ if (!field.of)
128
+ fail("is a list without 'of'");
129
+ if (has && !Array.isArray(value))
130
+ fail('default must be an array');
131
+ checkField(field.of, `${path}[]`);
132
+ if (Array.isArray(value)) {
133
+ for (const [i, item] of value.entries())
134
+ checkField(field.of, `${path}[${i}]`, item);
135
+ }
136
+ return;
137
+ case 'object':
138
+ if (!field.fields || Object.keys(field.fields).length === 0)
139
+ fail("is an object without 'fields'");
140
+ if (has && !isPlainObject(value))
141
+ fail('default must be an object');
142
+ for (const [key, sub] of Object.entries(field.fields)) {
143
+ checkField(sub, `${path}.${key}`, isPlainObject(value) ? value[key] : undefined);
144
+ }
145
+ return;
146
+ default:
147
+ fail(`has unknown type '${String(typeName)}'`);
148
+ }
149
+ }
150
+ function checkJsxProps(d) {
151
+ const defaults = d.defaults?.attributes ?? {};
152
+ for (const prop of d.props ?? []) {
153
+ if (/^on/i.test(prop.name)) {
154
+ console.warn(`defineMdxComponents: ${d.name}.${prop.name} starts with "on" and is never passed to the component; rename it.`);
155
+ }
156
+ const value = defaults[prop.name];
157
+ const scalar = prop.type === 'string' || prop.type === 'number' || prop.type === 'boolean';
158
+ // Scalar props predate this check; a throw here would crash existing sites at boot, so warn instead.
159
+ if (scalar && value !== undefined && value !== null && typeof value !== prop.type) {
160
+ console.warn(`defineMdxComponents: ${d.name}.${prop.name} default should be a ${prop.type}, got ${JSON.stringify(value)}.`);
161
+ continue;
162
+ }
163
+ checkField(prop, `${d.name}.${prop.name}`, value);
164
+ }
165
+ }
51
166
  /**
52
167
  * Read a string-valued JSX attribute from an mdast flow element. Returns
53
168
  * an empty string when the attribute is missing or holds an expression
@@ -92,6 +207,19 @@ export function writeStringAttribute(attributes, name, value) {
92
207
  }
93
208
  return next;
94
209
  }
210
+ /**
211
+ * `attributes` with the outline anchor (the `outline.id` prop) made from the contents text (`outline.text`) when the
212
+ * element has no anchor and has text. An existing anchor is never changed, so links to it keep working after the text
213
+ * is edited. `taken` holds the anchors already in the document.
214
+ */
215
+ export function withOutlineId(attributes, outline, taken) {
216
+ const named = (name) => attributes.find((a) => a.type === 'mdxJsxAttribute' && a.name === name);
217
+ const id = named(outline.id);
218
+ const text = named(outline.text)?.value;
219
+ if ((id && id.value !== '') || typeof text !== 'string' || text.trim() === '')
220
+ return attributes;
221
+ return writeAttribute(attributes, outline.id, outlineIdFor(text, taken));
222
+ }
95
223
  /**
96
224
  * Type-aware attribute writer. Encodes the value into the right
97
225
  * mdast shape so the saved MDX matches what an author would write
@@ -135,6 +263,14 @@ export function writeAttribute(attributes, name, value) {
135
263
  value: { type: 'mdxJsxAttributeValueExpression', value: String(value) },
136
264
  });
137
265
  }
266
+ else if (typeof value === 'object') {
267
+ // Lists and objects: a JSON literal expression, which readAttrs parses back.
268
+ next.push({
269
+ type: 'mdxJsxAttribute',
270
+ name,
271
+ value: { type: 'mdxJsxAttributeValueExpression', value: JSON.stringify(value) },
272
+ });
273
+ }
138
274
  return next;
139
275
  }
140
276
  //# sourceMappingURL=mdx-components-define.js.map