@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
@@ -6,10 +6,18 @@ import {
6
6
  } from '@conloca/content-api-client';
7
7
  import { AlertCircle, Code2, Loader2, Save } from 'lucide-react';
8
8
  import { useEffect, useRef, useState } from 'react';
9
+ import { notifyEditorDirtyChanged, registerEditorFlushHandler } from '../../editor-flush.js';
9
10
  import { type HostSchema, isHostSchema } from '../../host-schema.js';
11
+ import { dropHeldDataValues, heldDataKeys, type LiveDataValues, useLiveDataValues } from '../../live/data-binding.js';
12
+ import { type FrameLiveDoc, useDocChannel } from '../../live/doc-channel.js';
13
+ import { useLiveDoc } from '../../live/use-live.js';
10
14
  import { contentFailureMessage } from '../../utils/content-failure.js';
11
15
  import { validateEntryData } from '../../utils/data-entry-validation.js';
12
- import { UnsavedChangesDialog } from '../dialogs/UnsavedChangesDialog.js';
16
+ import { DraftNoticeStrip } from '../conflicts/EditorNoticeStrip.js';
17
+ import { PageDraftMenu } from '../conflicts/PageDraftMenu.js';
18
+ import { PeerAvatars } from '../conflicts/PeerAvatars.js';
19
+ import { draftToolsPage } from '../conflicts/use-page-conflicts.js';
20
+ import { LiveLeaveGuard, UnsavedChangesDialog } from '../dialogs/UnsavedChangesDialog.js';
13
21
  import { LocaleSelector } from '../editor/LocaleSelector.js';
14
22
  import { SchemaForm } from '../forms/SchemaForm.js';
15
23
 
@@ -20,8 +28,8 @@ interface DataEditorProps {
20
28
  initialLocale: string;
21
29
  existingLocales: string[];
22
30
  schema: HostSchema | null;
23
- /** Writes a new entry holding `data`; resolves true once it is created. */
24
- create?: (data: DataCollectionEntry['data']) => Promise<boolean>;
31
+ /** Writes a new entry holding `data`; resolves its id and etag once created, null when refused. */
32
+ create?: (data: DataCollectionEntry['data']) => Promise<{ id?: string; etag?: string } | null>;
25
33
  onSave?: () => void;
26
34
  onCancel?: () => void;
27
35
  }
@@ -31,7 +39,31 @@ interface DataEditorProps {
31
39
  * Uses collection-specific schema for form generation if available.
32
40
  * Supports locale switching similar to FragmentEditor.
33
41
  */
34
- export function DataEditor({
42
+ export function DataEditor(props: DataEditorProps) {
43
+ // The entry's id: a new entry gets one once created, and from then on is bound like any other.
44
+ const [id, setId] = useState(props.id);
45
+ // Typed during the create of an entry made here and stored by nothing yet; see `EntryEditor`'s `takeCarried`.
46
+ const [carrying, setCarrying] = useState(false);
47
+ // Above the loading and error screens too: a locale switch reloads, and the old doc may still owe work.
48
+ const bound = useDocChannel() !== null && id !== '';
49
+ return (
50
+ <>
51
+ {bound && <LiveLeaveGuard unsaved={carrying} />}
52
+ <EntryEditor
53
+ {...props}
54
+ id={id}
55
+ carrying={carrying}
56
+ onCreated={(created) => {
57
+ setId(created);
58
+ setCarrying(true);
59
+ }}
60
+ onCarried={() => setCarrying(false)}
61
+ />
62
+ </>
63
+ );
64
+ }
65
+
66
+ function EntryEditor({
35
67
  id,
36
68
  collection,
37
69
  initialLocale,
@@ -40,41 +72,66 @@ export function DataEditor({
40
72
  create,
41
73
  onSave,
42
74
  onCancel,
43
- }: DataEditorProps) {
75
+ carrying,
76
+ onCreated,
77
+ onCarried,
78
+ }: DataEditorProps & { carrying: boolean; onCreated: (id: string) => void; onCarried: () => void }) {
44
79
  // Locale state
45
80
  const [currentLocale, setCurrentLocale] = useState(initialLocale);
46
- const [currentEtag, setCurrentEtag] = useState<string>('');
81
+ // null: the version is not known (nothing loaded, or a create that returned no tag); '' is a real, loaded tag.
82
+ const [currentEtag, setCurrentEtag] = useState<string | null>(null);
47
83
  const [pendingLocaleSwitch, setPendingLocaleSwitch] = useState<string | null>(null);
48
84
  const [showUnsavedDialog, setShowUnsavedDialog] = useState(false);
49
85
 
50
86
  // Track saved values to detect changes
51
87
  const savedValuesRef = useRef<Record<string, unknown>>({});
88
+ // The values as typed, current even inside a save's await (state is only current after the next render).
89
+ const latestValuesRef = useRef(savedValuesRef.current);
90
+ // Typed during the create of an entry made here, not stored yet: the form keeps it, with Save, until the entry's
91
+ // doc opens and takes it, once; a doc that fails to open leaves it to Save.
92
+ const carryingRef = useRef(false);
93
+ const takeCarried = () => {
94
+ if (!carryingRef.current) return null;
95
+ carryingRef.current = false;
96
+ onCarried();
97
+ return latestValuesRef.current === savedValuesRef.current ? null : latestValuesRef.current;
98
+ };
52
99
 
53
100
  const { data: entry, isLoading, error } = useLocalizedContent(id, currentLocale);
54
101
  const updateLocalized = useUpdateLocalized();
55
102
 
56
103
  // Local state for form values
57
- const [values, setValues] = useState<Record<string, unknown>>({});
104
+ // The same object the refs hold, so a save of untouched values is not taken for typing during it.
105
+ const [values, setValues] = useState(savedValuesRef.current);
58
106
  const [hasChanges, setHasChanges] = useState(false);
59
107
  const [saveError, setSaveError] = useState<string | null>(null);
60
108
  const [saving, setSaving] = useState(false);
61
109
  const isNew = id === '';
110
+ // Bound to the entry's shared doc, each valid change is written as it is typed; a new entry has no doc until created.
111
+ const channel = useDocChannel();
112
+ const docWanted = channel !== null && id !== '';
113
+ const liveDoc = useLiveDoc(docWanted ? { kind: 'data', id, locale: currentLocale } : null);
114
+ const bound = docWanted && (!carrying || liveDoc.state === 'ready');
115
+ const [dropSwitch, setDropSwitch] = useState<{ locale: string; keys: string[] } | null>(null);
62
116
 
63
- // Initialize form values and etag when entry loads
117
+ // Initialize form values and etag when entry loads. A save's cache update or a refetch also emits a
118
+ // new entry; an edit not yet stored is kept, and so is the etag it was based on, so its save conflicts
119
+ // with a newer server version instead of overwriting it.
64
120
  useEffect(() => {
65
- if (entry?.localized?.content?.data) {
66
- const data = entry.localized.content.data as Record<string, unknown>;
121
+ if (entry?.localized && latestValuesRef.current === savedValuesRef.current) {
122
+ // An entry stored with no data still loads, so its etag is taken and its first save is checked.
123
+ const data = entry.localized.content?.data ?? {};
67
124
  setValues(data);
68
125
  savedValuesRef.current = data;
126
+ latestValuesRef.current = data;
69
127
  setHasChanges(false);
70
- }
71
- if (entry?.localized?.etag) {
72
- setCurrentEtag(entry.localized.etag);
128
+ setCurrentEtag(entry.localized.etag ?? null);
73
129
  }
74
130
  }, [entry]);
75
131
 
76
132
  // Track changes
77
133
  const handleChange = (newValues: Record<string, unknown>) => {
134
+ latestValuesRef.current = newValues;
78
135
  setValues(newValues);
79
136
  setHasChanges(true);
80
137
  };
@@ -92,11 +149,26 @@ export function DataEditor({
92
149
  setSaving(true);
93
150
  try {
94
151
  if (isNew) {
95
- const created = (await create?.(values)) ?? false;
96
- if (created) onSave?.();
97
- return created;
152
+ const created = (await create?.(values)) ?? null;
153
+ if (!created) return false;
154
+ savedValuesRef.current = values;
155
+ // Typing during the create is not stored yet: keep it open; bound, the doc takes it, else the next save does.
156
+ if (latestValuesRef.current !== values && created.id) {
157
+ setCurrentEtag(created.etag ?? null);
158
+ carryingRef.current = true;
159
+ onCreated(created.id);
160
+ } else {
161
+ setHasChanges(false);
162
+ onSave?.();
163
+ }
164
+ return true;
98
165
  }
99
166
 
167
+ // Never write unchecked: a tag fetched now would match a teammate's later save and overwrite it.
168
+ if (currentEtag === null) {
169
+ setSaveError("Could not confirm this entry's version. Close it, reopen it and enter your changes again.");
170
+ return false;
171
+ }
100
172
  const result = await updateLocalized.mutateAsync({
101
173
  id,
102
174
  locale: currentLocale,
@@ -110,18 +182,63 @@ export function DataEditor({
110
182
  setSaveError(contentFailureMessage(result, 'Failed to save data'));
111
183
  return false;
112
184
  }
113
- setHasChanges(false);
114
185
  savedValuesRef.current = values;
115
186
  if (result.etag) {
116
187
  setCurrentEtag(result.etag);
117
188
  }
118
- onSave?.();
189
+ // Typing during the write is not stored yet: the edit stays unsaved and the editor stays open.
190
+ if (latestValuesRef.current === values) {
191
+ setHasChanges(false);
192
+ // The carried typing is stored now: nothing is left for the doc to take or for leaving to lose.
193
+ if (carryingRef.current) {
194
+ carryingRef.current = false;
195
+ onCarried();
196
+ }
197
+ onSave?.();
198
+ }
119
199
  return true;
120
200
  } finally {
121
201
  setSaving(false);
122
202
  }
123
203
  };
124
204
 
205
+ // The host's Save, Cmd+S and status pill read and flush this edit; bound, the shared doc is already synced.
206
+ const hasChangesRef = useRef(hasChanges);
207
+ hasChangesRef.current = hasChanges;
208
+ // One save at a time: the button, the locale dialog and the host's flush all join the save already running.
209
+ const activeSaveRef = useRef<Promise<boolean> | null>(null);
210
+ const save = (): Promise<boolean> => {
211
+ if (activeSaveRef.current) return activeSaveRef.current;
212
+ const running = handleSave().finally(() => {
213
+ activeSaveRef.current = null;
214
+ });
215
+ activeSaveRef.current = running;
216
+ return running;
217
+ };
218
+ // save is recreated each render; the flush runs the latest.
219
+ const saveRef = useRef(save);
220
+ saveRef.current = save;
221
+ useEffect(() => {
222
+ if (bound) return undefined;
223
+ return registerEditorFlushHandler(
224
+ async () => {
225
+ const active = activeSaveRef.current;
226
+ if (!active && !hasChangesRef.current) return { ok: true };
227
+ const saved = await (active ?? saveRef.current()).catch(() => false);
228
+ // A joined save wrote older values; the edit typed since is not stored, so this flush did not save it.
229
+ if (saved && latestValuesRef.current !== savedValuesRef.current) {
230
+ return { ok: false, message: 'The editor changed while saving; save again.' };
231
+ }
232
+ return saved ? { ok: true } : { ok: false, message: 'Could not save editor changes.' };
233
+ },
234
+ { isDirty: () => hasChangesRef.current },
235
+ );
236
+ }, [bound]);
237
+ // biome-ignore lint/correctness/useExhaustiveDependencies: The dependency change is the event; handlers read current state through refs.
238
+ useEffect(() => {
239
+ notifyEditorDirtyChanged();
240
+ }, [hasChanges]);
241
+
125
242
  // Locale switching handlers
126
243
  const handleLocaleChange = async (newLocale: string) => {
127
244
  if (newLocale === currentLocale) return;
@@ -147,6 +264,7 @@ export function DataEditor({
147
264
  const newData = (newLocaleContent.localized.content?.data as Record<string, unknown>) || {};
148
265
  setValues(newData);
149
266
  savedValuesRef.current = newData;
267
+ latestValuesRef.current = newData;
150
268
  setCurrentEtag(newLocaleContent.localized.etag);
151
269
  setHasChanges(false);
152
270
  setCurrentLocale(newLocale);
@@ -163,7 +281,7 @@ export function DataEditor({
163
281
 
164
282
  // Save current content first; a refused save keeps the locale and the edits, with the reason shown.
165
283
  try {
166
- const saved = await handleSave();
284
+ const saved = await save();
167
285
  setShowUnsavedDialog(false);
168
286
  if (saved) await switchLocale(pendingLocaleSwitch);
169
287
  else setPendingLocaleSwitch(null);
@@ -186,8 +304,8 @@ export function DataEditor({
186
304
  setPendingLocaleSwitch(null);
187
305
  };
188
306
 
189
- // Loading state
190
- if (isLoading) {
307
+ // Loading state; an entry just created here keeps its unsaved form while it loads.
308
+ if (isLoading && !hasChanges) {
191
309
  return (
192
310
  <div className="flex items-center justify-center py-12">
193
311
  <Loader2 className="h-6 w-6 animate-spin text-azure-04 dark:text-azure-08" />
@@ -223,10 +341,91 @@ export function DataEditor({
223
341
  );
224
342
  }
225
343
 
344
+ if (bound) {
345
+ // The doc is already synced, so a locale switch saves nothing first; it only asks before dropping held values.
346
+ const switchLiveLocale = (locale: string) => {
347
+ if (locale === currentLocale) return;
348
+ const keys = heldDataKeys(`${id}:${currentLocale}`);
349
+ if (keys.length > 0) setDropSwitch({ locale, keys });
350
+ else setCurrentLocale(locale);
351
+ };
352
+ const draftPage = draftToolsPage(id, currentLocale);
353
+ return (
354
+ <div className="space-y-6">
355
+ <DraftNoticeStrip
356
+ id={id}
357
+ locale={currentLocale}
358
+ docKey={liveDoc.state === 'ready' ? liveDoc.live.docKey : undefined}
359
+ />
360
+ <div className="flex items-center gap-3 pb-4 border-b border-grey-09 dark:border-grey-03">
361
+ <span className="text-sm text-grey-04 dark:text-grey-07">Locale:</span>
362
+ <LocaleSelector
363
+ currentLocale={currentLocale}
364
+ availableLocales={existingLocales}
365
+ onChange={switchLiveLocale}
366
+ />
367
+ <div className="ml-auto flex items-center gap-2">
368
+ {liveDoc.state === 'ready' && <PeerAvatars live={liveDoc.live} />}
369
+ {draftPage && <PageDraftMenu page={draftPage} label={entry?.localized?.meta?.title || id} />}
370
+ </div>
371
+ </div>
372
+ {liveDoc.state === 'ready' ? (
373
+ <LiveDataForm
374
+ key={liveDoc.live.docKey}
375
+ live={liveDoc.live}
376
+ schema={schema}
377
+ entry={`${id}:${currentLocale}`}
378
+ takeCarried={takeCarried}
379
+ />
380
+ ) : liveDoc.state === 'failed' ? (
381
+ <p className="text-red-04 dark:text-red-08">{liveDoc.message}</p>
382
+ ) : (
383
+ <Loader2 className="h-6 w-6 animate-spin text-azure-04 dark:text-azure-08" />
384
+ )}
385
+ {onCancel && (
386
+ <div className="flex justify-end pt-4 border-t border-grey-09 dark:border-grey-03">
387
+ <button
388
+ type="button"
389
+ onClick={onCancel}
390
+ className="px-4 py-2 border border-grey-09 dark:border-grey-03 rounded-md hover:bg-grey-11 dark:hover:bg-grey-03 transition-colors"
391
+ >
392
+ Close
393
+ </button>
394
+ </div>
395
+ )}
396
+ {dropSwitch && (
397
+ <div role="alertdialog" aria-label="Values not saved" className="p-3 border border-yellow-08 rounded-md">
398
+ <p className="text-sm">
399
+ These values are not valid, so they were never saved, and switching locale drops them:{' '}
400
+ {dropSwitch.keys.join(', ')}
401
+ </p>
402
+ <div className="flex justify-end gap-2 pt-2">
403
+ <button type="button" onClick={() => setDropSwitch(null)} className="px-3 py-1 border rounded-md">
404
+ Cancel
405
+ </button>
406
+ <button
407
+ type="button"
408
+ onClick={() => {
409
+ dropHeldDataValues(`${id}:${currentLocale}`);
410
+ setDropSwitch(null);
411
+ setCurrentLocale(dropSwitch.locale);
412
+ }}
413
+ className="px-3 py-1 bg-red-04 text-white rounded-md"
414
+ >
415
+ Drop them and switch
416
+ </button>
417
+ </div>
418
+ </div>
419
+ )}
420
+ </div>
421
+ );
422
+ }
423
+
226
424
  // Schema exists - render form
227
425
  return (
228
426
  <>
229
427
  <div className="space-y-6">
428
+ {!isNew && <DraftNoticeStrip id={id} locale={currentLocale} />}
230
429
  {/* Locale selector header - only show existing locales; a new entry has one, the one it is created in */}
231
430
  {!isNew && (
232
431
  <div className="flex items-center gap-3 pb-4 border-b border-grey-09 dark:border-grey-03">
@@ -270,7 +469,7 @@ export function DataEditor({
270
469
  )}
271
470
  <button
272
471
  type="button"
273
- onClick={handleSave}
472
+ onClick={save}
274
473
  disabled={(!hasChanges && !isNew) || saving || !isHostSchema(schema)}
275
474
  className="px-4 py-2 bg-azure-04 text-white rounded-md hover:bg-azure-03 transition-colors disabled:opacity-50 disabled:cursor-not-allowed inline-flex items-center gap-2"
276
475
  >
@@ -301,3 +500,39 @@ export function DataEditor({
301
500
  </>
302
501
  );
303
502
  }
503
+
504
+ /** The form over the entry's replica: what it shows is the doc's data, with the values the schema rejected held. */
505
+ function LiveDataForm({
506
+ live,
507
+ schema,
508
+ entry,
509
+ takeCarried,
510
+ }: {
511
+ live: FrameLiveDoc;
512
+ schema: HostSchema;
513
+ entry: string;
514
+ takeCarried: () => LiveDataValues['values'] | null;
515
+ }) {
516
+ const { values, change, errors } = useLiveDataValues(
517
+ live,
518
+ (next) => (isHostSchema(schema) ? validateEntryData(schema, next) : null),
519
+ entry,
520
+ );
521
+ // biome-ignore lint/correctness/useExhaustiveDependencies: written once, into the doc of the entry just created.
522
+ useEffect(() => {
523
+ const carried = takeCarried();
524
+ if (carried) change(carried);
525
+ }, []);
526
+ const messages = [...new Set(Object.values(errors))];
527
+ return (
528
+ <>
529
+ <SchemaForm schema={schema} values={values} onChange={change} />
530
+ {messages.length > 0 && (
531
+ <div className="flex items-center gap-2 p-3 bg-red-11 dark:bg-red-02 border border-red-08 dark:border-red-03 rounded-md text-red-04 dark:text-red-08 text-sm">
532
+ <AlertCircle className="h-4 w-4 flex-shrink-0" />
533
+ <span>Not saved until fixed. {messages.join(' ')}</span>
534
+ </div>
535
+ )}
536
+ </>
537
+ );
538
+ }
@@ -14,14 +14,14 @@ interface MDXEditFieldProps {
14
14
  * than opening a modal. The page-route editor brings unsaved-changes guarding,
15
15
  * conflict recovery, locale switching, and Cmd+S — none of which the modal
16
16
  * had. The `?from=page` flag asks FragmentEditor to surface a shared-content
17
- * warning banner and offer a "Done" button that returns to this page.
17
+ * warning banner and offer a back arrow that returns to this page.
18
18
  */
19
19
  export function MDXEditField({ entry }: MDXEditFieldProps) {
20
20
  const navigate = useNavigate();
21
21
  // `:id` exists because MDXEditField is only rendered inside the Puck page
22
22
  // editor, which mounts at `/pages/:id`. If we ever surface this field
23
23
  // elsewhere the navigation will silently lose the return path, so the
24
- // button still works (lands on /fragments/:id with no Done shortcut).
24
+ // button still works (lands on /fragments/:id with Back returning to the fragments list).
25
25
  const { id: pageId } = useParams<{ id: string }>();
26
26
 
27
27
  const handleOpenEditor = () => {
@@ -2,7 +2,7 @@ import { Loader2 } from 'lucide-react';
2
2
  import { useId } from 'react';
3
3
  import { type HostSchema, isHostSchema } from '../../host-schema.js';
4
4
  import { fromDatetimeLocalValue, toDatetimeLocalValue } from '../../utils/pageMetadata.js';
5
- import { type FieldInfo, type FormFields, fieldsOfHostSchema } from '../../utils/schema-fields.js';
5
+ import { type FieldInfo, type FormFields, fieldsOfHostSchema, formatFieldLabel } from '../../utils/schema-fields.js';
6
6
  import { ImageFieldRender } from '../fields/ImageField.js';
7
7
  import { Input, Select, Textarea } from '../ui/index.js';
8
8
  import { ChipArrayField } from './ChipArrayField.js';
@@ -302,15 +302,6 @@ function SchemaField({ name, fieldInfo, value, onChange }: SchemaFieldProps) {
302
302
  }
303
303
  }
304
304
 
305
- function formatFieldLabel(name: string): string {
306
- // Convert camelCase/snake_case to Title Case
307
- return name
308
- .replace(/([A-Z])/g, ' $1')
309
- .replace(/_/g, ' ')
310
- .replace(/^\w/, (c) => c.toUpperCase())
311
- .trim();
312
- }
313
-
314
305
  function formatEnumLabel(value: string): string {
315
306
  // Convert enum values like "PENDING", "in_progress", "camelCase" to readable labels
316
307
  return value
@@ -1,4 +1,4 @@
1
- import { formatFileSize } from '@conloca/content-api-client';
1
+ import { APIClientError, ErrorCodes, formatFileSize } from '@conloca/content-api-client';
2
2
  import { FolderInput, Loader2, Trash2, X } from 'lucide-react';
3
3
  import { useMemo, useState } from 'react';
4
4
  import type { AssetEntry } from '../../hooks/index.js';
@@ -22,6 +22,19 @@ function formatDate(dateString: string): string {
22
22
  });
23
23
  }
24
24
 
25
+ /** The asset as it stands when a save was refused because someone else changed the field meanwhile, else null. */
26
+ function changedMeanwhile(error: Error): AssetEntry | null {
27
+ if (!(error instanceof APIClientError) || error.code !== ErrorCodes.WRITE_ERROR) return null;
28
+ // The refusal names the clashing `fields` and carries `current`, the asset entry it refused the save against; any
29
+ // other write error is a failed save.
30
+ const details: { fields?: string[]; current?: AssetEntry } | undefined = error.details;
31
+ const current = details?.current;
32
+ if (!Array.isArray(details?.fields) || typeof current !== 'object' || current === null) return null;
33
+ return current;
34
+ }
35
+
36
+ const CHANGED_MEANWHILE = 'Changed by someone else while you were editing. Check the new value and save again.';
37
+
25
38
  interface AssetDetailSidebarProps {
26
39
  /**
27
40
  * The asset's record as the folder listing currently holds it. The caller
@@ -48,6 +61,8 @@ export function AssetDetailSidebar({
48
61
  const [storedAlt, setStoredAlt] = useState(asset.alt || '');
49
62
  const [storedTags, setStoredTags] = useState<string[]>(asset.tags ?? []);
50
63
  const [confirmDelete, setConfirmDelete] = useState(false);
64
+ // Whether a save was refused because someone else changed the field meanwhile.
65
+ const [changedNotice, setChangedNotice] = useState(false);
51
66
  const [showMoveDialog, setShowMoveDialog] = useState(false);
52
67
  // Whether the pages using this image are known, so a move or delete cannot be confirmed before they are shown.
53
68
  const [usageSettled, setUsageSettled] = useState(false);
@@ -105,16 +120,28 @@ export function AssetDetailSidebar({
105
120
  // reloads `asset` a moment after each save, so an edit put back within that
106
121
  // moment would look unchanged, and a reload can carry someone else's save, so
107
122
  // an untouched field would look changed and be written over it. A save that
108
- // fails changed nothing, so the next blur sends it again.
123
+ // fails changed nothing, so the next blur sends it again. Each save sends
124
+ // what the panel believes is stored, so a server can refuse it when someone
125
+ // else changed that field meanwhile; the panel then shows their value.
126
+ const base = { alt: storedAlt || null, tags: storedTags.length > 0 ? storedTags : null };
109
127
  const handleAltBlur = () => {
110
128
  if (altText === storedAlt) return;
111
129
  const previous = storedAlt;
112
130
  setStoredAlt(altText);
131
+ setChangedNotice(false);
113
132
  saveAlt.mutate(
114
133
  // null clears: undefined is dropped from the JSON body and the stored
115
134
  // record would keep the old alt text.
116
- { path, updates: { alt: altText || null } },
117
- { onError: () => setStoredAlt(previous) },
135
+ { path, updates: { alt: altText || null }, base },
136
+ {
137
+ onError: (error) => {
138
+ const current = changedMeanwhile(error);
139
+ if (current === null) return setStoredAlt(previous);
140
+ setStoredAlt(current.alt || '');
141
+ setAltText(current.alt || '');
142
+ setChangedNotice(true);
143
+ },
144
+ },
118
145
  );
119
146
  };
120
147
 
@@ -127,9 +154,18 @@ export function AssetDetailSidebar({
127
154
  if (JSON.stringify(newTags) === JSON.stringify(storedTags)) return;
128
155
  const previous = storedTags;
129
156
  setStoredTags(newTags);
157
+ setChangedNotice(false);
130
158
  saveTags.mutate(
131
- { path, updates: { tags: newTags.length > 0 ? newTags : null } },
132
- { onError: () => setStoredTags(previous) },
159
+ { path, updates: { tags: newTags.length > 0 ? newTags : null }, base },
160
+ {
161
+ onError: (error) => {
162
+ const current = changedMeanwhile(error);
163
+ if (current === null) return setStoredTags(previous);
164
+ setStoredTags(current.tags ?? []);
165
+ setTagsInput(current.tags?.join(', ') || '');
166
+ setChangedNotice(true);
167
+ },
168
+ },
133
169
  );
134
170
  };
135
171
 
@@ -260,6 +296,11 @@ export function AssetDetailSidebar({
260
296
  />
261
297
  <p className="mt-1 text-xs text-grey-04 dark:text-grey-07">Separate tags with commas</p>
262
298
  </div>
299
+ {changedNotice && (
300
+ <p role="alert" className="text-xs text-red-04 dark:text-red-08">
301
+ {CHANGED_MEANWHILE}
302
+ </p>
303
+ )}
263
304
  </div>
264
305
 
265
306
  {/* Usage section */}
@@ -17,6 +17,7 @@ import type { DataSchemas } from '../../data-schemas.js';
17
17
  import { useDialogState, useErrorModal } from '../../hooks/index.js';
18
18
  import type { DataEntry } from '../../types.js';
19
19
  import { getUIConfig } from '../../ui-config.js';
20
+ import { ApplyClashError } from '../../utils/apply-clash.js';
20
21
  import { contentFailureMessage, isStaleWrite } from '../../utils/content-failure.js';
21
22
  import { editableEntryMeta, entryMetaPatch } from '../../utils/entry-meta.js';
22
23
  import { untitledName, untitledNameNote } from '../../utils/entry-name.js';
@@ -208,7 +209,7 @@ export function DataList({ dataSchemas }: DataListProps) {
208
209
  });
209
210
  };
210
211
 
211
- /** Writes the new entry the editor is open on, holding `entryData`; resolves true once it is created. */
212
+ /** Writes the new entry the editor is open on, holding `entryData`; resolves its id and etag once created. */
212
213
  const createEntry = async (entryData: DataCollectionEntry['data']) => {
213
214
  const { collection, entryTitle: title, locale, name } = editDataDialog;
214
215
  const description = editDataDialog.description || undefined;
@@ -251,14 +252,14 @@ export function DataList({ dataSchemas }: DataListProps) {
251
252
  ),
252
253
  error,
253
254
  );
254
- return false;
255
+ return null;
255
256
  }
256
257
 
257
258
  if (!result.success) {
258
259
  const nameTaken = result.reason === 'name_taken' || result.reason === 'already_exists';
259
260
  showError(withNameNote(contentFailureMessage(result, 'Failed to create data entry'), nameTaken), result.error);
260
261
  }
261
- return result.success;
262
+ return result.success ? { id: result.id, etag: result.etag } : null;
262
263
  };
263
264
 
264
265
  const handleDeleteEntry = (entryId: string) => {
@@ -321,6 +322,12 @@ export function DataList({ dataSchemas }: DataListProps) {
321
322
  etag: propertiesDialog.etag,
322
323
  });
323
324
 
325
+ const clash = result.success ? undefined : result.conflictDetails?.conflicts;
326
+ if (clash && clash.length > 0) {
327
+ // The dialog stays open with the other values loaded; the next Save sends against the page as it is now.
328
+ if (result.currentEtag) openPropertiesDialog({ ...propertiesDialog, etag: result.currentEtag });
329
+ throw new ApplyClashError(clash, result.conflictDetails?.changedBy);
330
+ }
324
331
  closePropertiesDialog();
325
332
 
326
333
  if (!result.success) {
@@ -331,6 +338,7 @@ export function DataList({ dataSchemas }: DataListProps) {
331
338
  }
332
339
  }
333
340
  } catch (err) {
341
+ if (err instanceof ApplyClashError) throw err;
334
342
  closePropertiesDialog();
335
343
  showError('Failed to save properties. Please try again.', err);
336
344
  }
@@ -468,7 +476,9 @@ export function DataList({ dataSchemas }: DataListProps) {
468
476
  className="fixed inset-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-50"
469
477
  role="dialog"
470
478
  onKeyDown={(e) => {
471
- if (e.key === 'Escape') closeEditDataDialog();
479
+ // A menu or dialog opened from the editor closes itself on Escape; React still bubbles the key here.
480
+ const layer = e.target instanceof Element ? e.target.closest('[role="dialog"], [role="menu"]') : null;
481
+ if (e.key === 'Escape' && layer === e.currentTarget) closeEditDataDialog();
472
482
  }}
473
483
  >
474
484
  <div
@@ -13,6 +13,7 @@ import { useCallback, useMemo, useRef, useState } from 'react';
13
13
  import { useNavigate } from 'react-router-dom';
14
14
  import { useClickOutside, useDialogState, useErrorModal } from '../../hooks/index.js';
15
15
  import type { Fragment } from '../../types.js';
16
+ import { ApplyClashError } from '../../utils/apply-clash.js';
16
17
  import { cn } from '../../utils/cn.js';
17
18
  import { contentFailureMessage, isStaleWrite } from '../../utils/content-failure.js';
18
19
  import { editableEntryMeta, entryMetaPatch } from '../../utils/entry-meta.js';
@@ -303,6 +304,12 @@ export function FragmentList() {
303
304
  etag: propertiesDialog.etag,
304
305
  });
305
306
 
307
+ const clash = result.success ? undefined : result.conflictDetails?.conflicts;
308
+ if (clash && clash.length > 0) {
309
+ // The dialog stays open with the other values loaded; the next Save sends against the page as it is now.
310
+ if (result.currentEtag) openPropertiesDialog({ ...propertiesDialog, etag: result.currentEtag });
311
+ throw new ApplyClashError(clash, result.conflictDetails?.changedBy);
312
+ }
306
313
  closePropertiesDialog();
307
314
 
308
315
  if (!result.success) {
@@ -313,6 +320,7 @@ export function FragmentList() {
313
320
  }
314
321
  }
315
322
  } catch (error) {
323
+ if (error instanceof ApplyClashError) throw error;
316
324
  closePropertiesDialog();
317
325
  showError('Failed to save properties. Please try again.', error);
318
326
  }