payload-canvas 0.4.0 → 0.5.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 (468) hide show
  1. package/README.md +625 -153
  2. package/dist/admin/AiKeyField.d.ts +8 -0
  3. package/dist/admin/AiKeyField.js +54 -0
  4. package/dist/admin/BuilderTab.js +4 -1
  5. package/dist/admin/DocumentEditView.d.ts +9 -0
  6. package/dist/admin/DocumentEditView.js +45 -0
  7. package/dist/admin/LayoutField.d.ts +2 -2
  8. package/dist/admin/LayoutField.js +10 -7
  9. package/dist/admin/TemplateConditionsField.d.ts +9 -0
  10. package/dist/admin/TemplateConditionsField.js +22 -0
  11. package/dist/admin/aiKeyField.scss +58 -0
  12. package/dist/admin/client.d.ts +3 -0
  13. package/dist/admin/client.js +6 -0
  14. package/dist/admin/diff/changes.js +5 -0
  15. package/dist/admin/editor/Canvas.js +20 -5
  16. package/dist/admin/editor/Editor.d.ts +3 -1
  17. package/dist/admin/editor/Editor.js +6 -3
  18. package/dist/admin/editor/Inspector.js +75 -28
  19. package/dist/admin/editor/Library.js +40 -15
  20. package/dist/admin/editor/Outline.js +21 -16
  21. package/dist/admin/editor/Overlay.js +8 -3
  22. package/dist/admin/editor/actions.d.ts +10 -2
  23. package/dist/admin/editor/actions.js +18 -3
  24. package/dist/admin/editor/assistant/AssistantPanel.js +3 -1
  25. package/dist/admin/editor/classes/ClassManager.d.ts +4 -0
  26. package/dist/admin/editor/classes/ClassManager.js +56 -0
  27. package/dist/admin/editor/classes/controller.d.ts +112 -0
  28. package/dist/admin/editor/classes/controller.js +326 -0
  29. package/dist/admin/editor/classes/manager.scss +262 -0
  30. package/dist/admin/editor/classes/managerModel.d.ts +5 -0
  31. package/dist/admin/editor/classes/managerModel.js +27 -0
  32. package/dist/admin/editor/comments/CommentLayer.d.ts +2 -0
  33. package/dist/admin/editor/comments/CommentLayer.js +143 -0
  34. package/dist/admin/editor/comments/CommentsPanel.d.ts +8 -0
  35. package/dist/admin/editor/comments/CommentsPanel.js +73 -0
  36. package/dist/admin/editor/comments/Thread.d.ts +26 -0
  37. package/dist/admin/editor/comments/Thread.js +84 -0
  38. package/dist/admin/editor/comments/comments.scss +539 -0
  39. package/dist/admin/editor/comments/controller.d.ts +48 -0
  40. package/dist/admin/editor/comments/controller.js +142 -0
  41. package/dist/admin/editor/contentMode.d.ts +17 -0
  42. package/dist/admin/editor/contentMode.js +37 -0
  43. package/dist/admin/editor/dnd/DropOutlines.d.ts +1 -0
  44. package/dist/admin/editor/dnd/DropOutlines.js +73 -0
  45. package/dist/admin/editor/dnd/dnd.scss +43 -0
  46. package/dist/admin/editor/dnd/mode.d.ts +4 -0
  47. package/dist/admin/editor/dnd/mode.js +39 -0
  48. package/dist/admin/editor/editor.scss +13 -58
  49. package/dist/admin/editor/empty/EmptyStart.js +18 -66
  50. package/dist/admin/editor/fields/AddButton.d.ts +15 -0
  51. package/dist/admin/editor/fields/AddButton.js +14 -0
  52. package/dist/admin/editor/fields/ArrayField.js +3 -2
  53. package/dist/admin/editor/fields/CheckedInputs.d.ts +1 -0
  54. package/dist/admin/editor/fields/ConditionRows.d.ts +19 -0
  55. package/dist/admin/editor/fields/ConditionRows.js +137 -0
  56. package/dist/admin/editor/fields/ListWhereField.d.ts +8 -0
  57. package/dist/admin/editor/fields/ListWhereField.js +20 -0
  58. package/dist/admin/editor/fields/QueryFiltersField.d.ts +18 -0
  59. package/dist/admin/editor/fields/QueryFiltersField.js +41 -0
  60. package/dist/admin/editor/fields/RelatedField.d.ts +19 -0
  61. package/dist/admin/editor/fields/RelatedField.js +44 -0
  62. package/dist/admin/editor/fields/SortField.d.ts +13 -0
  63. package/dist/admin/editor/fields/SortField.js +37 -0
  64. package/dist/admin/editor/fields/WhereField.d.ts +12 -4
  65. package/dist/admin/editor/fields/WhereField.js +33 -53
  66. package/dist/admin/editor/fields/collectionFields.d.ts +6 -0
  67. package/dist/admin/editor/fields/collectionFields.js +15 -0
  68. package/dist/admin/editor/fields/conditions.d.ts +99 -0
  69. package/dist/admin/editor/fields/conditions.js +339 -0
  70. package/dist/admin/editor/fields/fields.scss +232 -9
  71. package/dist/admin/editor/fields/listOptions.d.ts +44 -0
  72. package/dist/admin/editor/fields/listOptions.js +111 -0
  73. package/dist/admin/editor/fields/queryFilterRows.d.ts +8 -0
  74. package/dist/admin/editor/fields/queryFilterRows.js +29 -0
  75. package/dist/admin/editor/fields/whereRows.d.ts +11 -12
  76. package/dist/admin/editor/fields/whereRows.js +83 -34
  77. package/dist/admin/editor/icons.d.ts +16 -1
  78. package/dist/admin/editor/icons.js +30 -1
  79. package/dist/admin/editor/inline.js +9 -0
  80. package/dist/admin/editor/insert/InsertHandle.js +4 -1
  81. package/dist/admin/editor/insert/picker.d.ts +3 -1
  82. package/dist/admin/editor/insert/picker.js +17 -10
  83. package/dist/admin/editor/insert/spots.d.ts +12 -1
  84. package/dist/admin/editor/insert/spots.js +49 -10
  85. package/dist/admin/editor/layout/LeftPanel.js +11 -6
  86. package/dist/admin/editor/live/useMultiplayer.js +9 -1
  87. package/dist/admin/editor/menu/blockMenu.js +27 -17
  88. package/dist/admin/editor/names.js +11 -3
  89. package/dist/admin/editor/renderField.d.ts +3 -1
  90. package/dist/admin/editor/renderField.js +63 -12
  91. package/dist/admin/editor/runtime.d.ts +14 -0
  92. package/dist/admin/editor/runtime.js +67 -6
  93. package/dist/admin/editor/sections/ComponentFields.d.ts +8 -0
  94. package/dist/admin/editor/sections/ComponentFields.js +116 -0
  95. package/dist/admin/editor/sections/PropertyControls.d.ts +18 -0
  96. package/dist/admin/editor/sections/PropertyControls.js +65 -0
  97. package/dist/admin/editor/sections/components.d.ts +29 -0
  98. package/dist/admin/editor/sections/components.js +112 -0
  99. package/dist/admin/editor/sections/components.scss +238 -0
  100. package/dist/admin/editor/sections/variants.d.ts +32 -0
  101. package/dist/admin/editor/sections/variants.js +59 -0
  102. package/dist/admin/editor/sections/variants.scss +90 -0
  103. package/dist/admin/editor/shortcuts.d.ts +4 -1
  104. package/dist/admin/editor/shortcuts.js +19 -3
  105. package/dist/admin/editor/store.d.ts +18 -0
  106. package/dist/admin/editor/store.js +46 -0
  107. package/dist/admin/editor/styles/ClassBar.d.ts +14 -0
  108. package/dist/admin/editor/styles/ClassBar.js +90 -0
  109. package/dist/admin/editor/styles/ClassCss.d.ts +4 -0
  110. package/dist/admin/editor/styles/ClassCss.js +28 -0
  111. package/dist/admin/editor/styles/ClassDialog.d.ts +2 -0
  112. package/dist/admin/editor/styles/ClassDialog.js +151 -0
  113. package/dist/admin/editor/styles/ColorPicker.js +5 -2
  114. package/dist/admin/editor/styles/RawClasses.d.ts +26 -1
  115. package/dist/admin/editor/styles/RawClasses.js +184 -32
  116. package/dist/admin/editor/styles/StylesPanel.d.ts +3 -3
  117. package/dist/admin/editor/styles/StylesPanel.js +53 -14
  118. package/dist/admin/editor/styles/VariantBar.js +2 -2
  119. package/dist/admin/editor/styles/classEdit.d.ts +4 -0
  120. package/dist/admin/editor/styles/classEdit.js +20 -0
  121. package/dist/admin/editor/styles/classes.scss +381 -0
  122. package/dist/admin/editor/styles/context.d.ts +19 -6
  123. package/dist/admin/editor/styles/context.js +24 -6
  124. package/dist/admin/editor/styles/controls.d.ts +3 -1
  125. package/dist/admin/editor/styles/controls.js +30 -12
  126. package/dist/admin/editor/styles/popover.d.ts +6 -0
  127. package/dist/admin/editor/styles/popover.js +5 -5
  128. package/dist/admin/editor/styles/styles.scss +26 -104
  129. package/dist/admin/editor/styles/suggestions.d.ts +22 -0
  130. package/dist/admin/editor/styles/suggestions.js +77 -0
  131. package/dist/admin/editor/styles/tokens.js +14 -0
  132. package/dist/admin/editor/templates/Bindable.js +86 -57
  133. package/dist/admin/editor/templates/SamplePicker.js +1 -1
  134. package/dist/admin/editor/templates/Visibility.d.ts +9 -0
  135. package/dist/admin/editor/templates/Visibility.js +54 -0
  136. package/dist/admin/editor/templates/binding.d.ts +2 -2
  137. package/dist/admin/editor/templates/binding.js +2 -2
  138. package/dist/admin/editor/templates/templates.scss +27 -0
  139. package/dist/admin/editor/templates/visibilityRows.d.ts +22 -0
  140. package/dist/admin/editor/templates/visibilityRows.js +83 -0
  141. package/dist/admin/editor/topbar/ContentModeToggle.d.ts +5 -0
  142. package/dist/admin/editor/topbar/ContentModeToggle.js +26 -0
  143. package/dist/admin/editor/topbar/DocumentActions.d.ts +1 -1
  144. package/dist/admin/editor/topbar/DocumentActions.js +5 -4
  145. package/dist/admin/editor/topbar/DocumentTitle.js +7 -2
  146. package/dist/admin/editor/topbar/TopBar.js +15 -3
  147. package/dist/admin/editor/topbar/contentMode.scss +35 -0
  148. package/dist/admin/editor/topbar/topbar.scss +3 -1
  149. package/dist/admin/formChoice.d.ts +3 -0
  150. package/dist/admin/formChoice.js +10 -0
  151. package/dist/admin/layoutField.scss +69 -0
  152. package/dist/admin/screen/BuilderScreen.d.ts +6 -1
  153. package/dist/admin/screen/BuilderScreen.js +4 -3
  154. package/dist/admin/server/BuilderView.js +10 -3
  155. package/dist/admin/templateConditions.scss +24 -0
  156. package/dist/ai/adapters/anthropic.js +17 -4
  157. package/dist/ai/adapters/cloudflare-gateway.js +7 -1
  158. package/dist/ai/adapters/cloudflare-workers-ai.js +2 -0
  159. package/dist/ai/adapters/openai-compatible.js +1 -0
  160. package/dist/ai/adapters/openrouter.js +2 -0
  161. package/dist/ai/config.d.ts +24 -4
  162. package/dist/ai/config.js +27 -8
  163. package/dist/ai/endpoint.d.ts +5 -2
  164. package/dist/ai/endpoint.js +31 -26
  165. package/dist/ai/images/cloudflare-workers-ai.js +6 -2
  166. package/dist/ai/images/openai.js +8 -3
  167. package/dist/ai/images/openrouter.js +6 -2
  168. package/dist/ai/images/service.d.ts +10 -4
  169. package/dist/ai/images/service.js +23 -7
  170. package/dist/ai/openai-format.d.ts +7 -0
  171. package/dist/ai/openai-format.js +17 -5
  172. package/dist/ai/prompt.d.ts +8 -0
  173. package/dist/ai/prompt.js +25 -5
  174. package/dist/ai/settings/index.d.ts +62 -0
  175. package/dist/ai/settings/index.js +264 -0
  176. package/dist/ai/settings/secret.d.ts +11 -0
  177. package/dist/ai/settings/secret.js +46 -0
  178. package/dist/ai/settings/shared.d.ts +22 -0
  179. package/dist/ai/settings/shared.js +3 -0
  180. package/dist/ai/tools.d.ts +3 -0
  181. package/dist/ai/tools.js +79 -15
  182. package/dist/ai/types.d.ts +43 -0
  183. package/dist/blocks/builtins/adjacentLinks.d.ts +5 -0
  184. package/dist/blocks/builtins/adjacentLinks.js +76 -0
  185. package/dist/blocks/builtins/carousel.d.ts +2 -29
  186. package/dist/blocks/builtins/carousel.js +44 -51
  187. package/dist/blocks/builtins/disclosure.d.ts +2 -1
  188. package/dist/blocks/builtins/disclosure.js +22 -32
  189. package/dist/blocks/builtins/embed.d.ts +15 -0
  190. package/dist/blocks/builtins/embed.js +47 -0
  191. package/dist/blocks/builtins/faq.d.ts +1 -1
  192. package/dist/blocks/builtins/faq.js +2 -2
  193. package/dist/blocks/builtins/filterLink.d.ts +1 -19
  194. package/dist/blocks/builtins/filterLink.js +9 -50
  195. package/dist/blocks/builtins/icon.d.ts +2 -0
  196. package/dist/blocks/builtins/icon.js +8 -8
  197. package/dist/blocks/builtins/index.d.ts +18 -13
  198. package/dist/blocks/builtins/index.js +43 -22
  199. package/dist/blocks/builtins/marquee.d.ts +5 -0
  200. package/dist/blocks/builtins/marquee.js +68 -0
  201. package/dist/blocks/builtins/popup.d.ts +5 -0
  202. package/dist/blocks/builtins/popup.js +83 -0
  203. package/dist/blocks/builtins/sectionRef.d.ts +16 -2
  204. package/dist/blocks/builtins/sectionRef.js +34 -12
  205. package/dist/blocks/builtins/shared.d.ts +18 -23
  206. package/dist/blocks/builtins/shared.js +34 -42
  207. package/dist/blocks/builtins/tableOfContents.d.ts +4 -0
  208. package/dist/blocks/builtins/tableOfContents.js +12 -18
  209. package/dist/blocks/builtins/tabs.d.ts +6 -0
  210. package/dist/blocks/builtins/tabs.js +87 -0
  211. package/dist/blocks/client/adjacentLinks.d.ts +4 -0
  212. package/dist/blocks/client/adjacentLinks.js +4 -0
  213. package/dist/blocks/client/carousel.d.ts +45 -0
  214. package/dist/blocks/client/carousel.js +53 -0
  215. package/dist/blocks/client/embed.d.ts +21 -0
  216. package/dist/blocks/client/embed.js +23 -0
  217. package/dist/blocks/client/field.d.ts +7 -0
  218. package/dist/blocks/client/field.js +8 -0
  219. package/dist/blocks/client/filterLink.d.ts +19 -0
  220. package/dist/blocks/client/filterLink.js +30 -0
  221. package/dist/blocks/client/helpers.d.ts +21 -0
  222. package/dist/blocks/client/helpers.js +24 -0
  223. package/dist/blocks/client/marquee.d.ts +14 -0
  224. package/dist/blocks/client/marquee.js +25 -0
  225. package/dist/blocks/client/menu.d.ts +46 -0
  226. package/dist/blocks/client/menu.js +49 -0
  227. package/dist/blocks/client/popup.d.ts +15 -0
  228. package/dist/blocks/client/popup.js +16 -0
  229. package/dist/blocks/client/tabs.d.ts +10 -0
  230. package/dist/blocks/client/tabs.js +11 -0
  231. package/dist/blocks/defaults.d.ts +15 -52
  232. package/dist/blocks/defaults.js +203 -437
  233. package/dist/blocks/index.d.ts +1 -2
  234. package/dist/blocks/index.js +1 -2
  235. package/dist/classes/actions.d.ts +97 -0
  236. package/dist/classes/actions.js +296 -0
  237. package/dist/classes/collection.d.ts +5 -0
  238. package/dist/classes/collection.js +189 -0
  239. package/dist/classes/config.d.ts +34 -0
  240. package/dist/classes/config.js +8 -0
  241. package/dist/classes/endpoints.d.ts +2 -0
  242. package/dist/classes/endpoints.js +120 -0
  243. package/dist/classes/index.d.ts +36 -0
  244. package/dist/classes/index.js +42 -0
  245. package/dist/classes/mcp.d.ts +6 -0
  246. package/dist/classes/mcp.js +161 -0
  247. package/dist/classes/shared.d.ts +131 -0
  248. package/dist/classes/shared.js +300 -0
  249. package/dist/classes/sheet.d.ts +34 -0
  250. package/dist/classes/sheet.js +126 -0
  251. package/dist/classes/usage.d.ts +57 -0
  252. package/dist/classes/usage.js +208 -0
  253. package/dist/comments/collection.d.ts +38 -0
  254. package/dist/comments/collection.js +226 -0
  255. package/dist/comments/config.d.ts +15 -0
  256. package/dist/comments/config.js +2 -0
  257. package/dist/comments/index.d.ts +20 -0
  258. package/dist/comments/index.js +22 -0
  259. package/dist/comments/shared.d.ts +54 -0
  260. package/dist/comments/shared.js +104 -0
  261. package/dist/core/bindings.d.ts +77 -32
  262. package/dist/core/bindings.js +319 -134
  263. package/dist/core/blockNames.d.ts +9 -0
  264. package/dist/core/blockNames.js +11 -0
  265. package/dist/core/blocks.d.ts +21 -8
  266. package/dist/core/blocks.js +37 -16
  267. package/dist/core/classes.d.ts +16 -8
  268. package/dist/core/classes.js +31 -27
  269. package/dist/core/components.d.ts +72 -0
  270. package/dist/core/components.js +294 -0
  271. package/dist/core/contentMode.d.ts +27 -0
  272. package/dist/core/contentMode.js +0 -0
  273. package/dist/core/dropTarget.d.ts +11 -0
  274. package/dist/core/dropTarget.js +24 -1
  275. package/dist/core/fields.d.ts +5 -0
  276. package/dist/core/fields.js +11 -0
  277. package/dist/core/headings.d.ts +5 -2
  278. package/dist/core/headings.js +14 -6
  279. package/dist/core/index.d.ts +8 -3
  280. package/dist/core/index.js +8 -3
  281. package/dist/core/layers.d.ts +9 -0
  282. package/dist/core/layers.js +29 -0
  283. package/dist/core/operations.d.ts +6 -0
  284. package/dist/core/operations.js +85 -24
  285. package/dist/core/payloadBlocks.js +5 -1
  286. package/dist/core/references.js +28 -0
  287. package/dist/core/schema.js +20 -6
  288. package/dist/core/sectionOrigin.d.ts +6 -0
  289. package/dist/core/sectionOrigin.js +21 -0
  290. package/dist/core/sections.d.ts +72 -0
  291. package/dist/core/sections.js +331 -0
  292. package/dist/core/templateChoice.d.ts +24 -0
  293. package/dist/core/templateChoice.js +43 -0
  294. package/dist/core/tree.js +18 -6
  295. package/dist/core/types.d.ts +148 -18
  296. package/dist/core/validate.d.ts +4 -1
  297. package/dist/core/validate.js +28 -11
  298. package/dist/core/visibility.d.ts +63 -0
  299. package/dist/core/visibility.js +214 -0
  300. package/dist/core/whereValues.d.ts +22 -0
  301. package/dist/core/whereValues.js +43 -0
  302. package/dist/css/classes.d.ts +16 -0
  303. package/dist/css/classes.js +172 -0
  304. package/dist/css/index.d.ts +32 -1
  305. package/dist/css/index.js +64 -5
  306. package/dist/css/tokens.d.ts +10 -0
  307. package/dist/css/tokens.js +23 -10
  308. package/dist/index.d.ts +5 -2
  309. package/dist/index.js +6 -1
  310. package/dist/live/contentMode.d.ts +24 -0
  311. package/dist/live/contentMode.js +39 -0
  312. package/dist/live/endpoints.js +3 -0
  313. package/dist/live/session.d.ts +5 -0
  314. package/dist/live/session.js +8 -0
  315. package/dist/live/types.d.ts +16 -1
  316. package/dist/mcp/index.d.ts +10 -1
  317. package/dist/mcp/index.js +146 -54
  318. package/dist/mcp/shared.d.ts +93 -3
  319. package/dist/mcp/shared.js +211 -15
  320. package/dist/plugin/hook.d.ts +7 -1
  321. package/dist/plugin/hook.js +30 -4
  322. package/dist/plugin/index.d.ts +19 -8
  323. package/dist/plugin/index.js +89 -20
  324. package/dist/plugin/links.d.ts +24 -0
  325. package/dist/plugin/links.js +27 -0
  326. package/dist/plugin/listCollections.d.ts +9 -7
  327. package/dist/plugin/listCollections.js +30 -21
  328. package/dist/plugin/sections.d.ts +14 -7
  329. package/dist/plugin/sections.js +69 -23
  330. package/dist/plugin/sectionsUsedIn.d.ts +6 -0
  331. package/dist/plugin/sectionsUsedIn.js +24 -0
  332. package/dist/plugin/templateEndpoint.d.ts +9 -0
  333. package/dist/plugin/templateEndpoint.js +49 -0
  334. package/dist/plugin/templates.js +23 -8
  335. package/dist/protocol/index.d.ts +16 -1
  336. package/dist/react/canvas/BuilderCanvas.js +144 -21
  337. package/dist/react/canvas/classes.d.ts +17 -0
  338. package/dist/react/canvas/classes.js +102 -0
  339. package/dist/react/canvas/controls.d.ts +31 -0
  340. package/dist/react/canvas/controls.js +75 -0
  341. package/dist/react/canvas/fetchDocs.d.ts +2 -2
  342. package/dist/react/canvas/fetchDocs.js +16 -8
  343. package/dist/react/canvas/measure.d.ts +9 -0
  344. package/dist/react/canvas/measure.js +106 -7
  345. package/dist/react/canvas/resolveLayout.d.ts +1 -1
  346. package/dist/react/canvas/resolveLayout.js +4 -3
  347. package/dist/react/canvas/thumbnail/ThumbnailCanvas.js +17 -4
  348. package/dist/react/classes/ClassesStyle.d.ts +27 -0
  349. package/dist/react/classes/ClassesStyle.js +27 -0
  350. package/dist/react/components/Button.d.ts +2 -11
  351. package/dist/react/components/Button.js +8 -43
  352. package/dist/react/components/CollectionList.d.ts +4 -1
  353. package/dist/react/components/CollectionList.js +10 -3
  354. package/dist/react/components/Container.d.ts +5 -2
  355. package/dist/react/components/Container.js +7 -4
  356. package/dist/react/components/Field.js +3 -14
  357. package/dist/react/components/Link.d.ts +1 -1
  358. package/dist/react/components/Link.js +5 -3
  359. package/dist/react/components/List.d.ts +1 -1
  360. package/dist/react/components/List.js +2 -2
  361. package/dist/react/components/Menu.d.ts +10 -1
  362. package/dist/react/components/Menu.js +39 -12
  363. package/dist/react/components/RichText.d.ts +3 -4
  364. package/dist/react/components/RichText.js +5 -5
  365. package/dist/react/components/builtins/Accordion.d.ts +4 -3
  366. package/dist/react/components/builtins/Accordion.js +6 -5
  367. package/dist/react/components/builtins/AdjacentLinks.d.ts +11 -0
  368. package/dist/react/components/builtins/AdjacentLinks.js +20 -0
  369. package/dist/react/components/builtins/Carousel.d.ts +21 -10
  370. package/dist/react/components/builtins/Carousel.js +175 -100
  371. package/dist/react/components/builtins/Disclosure.d.ts +4 -3
  372. package/dist/react/components/builtins/Disclosure.js +6 -5
  373. package/dist/react/components/builtins/Embed.d.ts +11 -0
  374. package/dist/react/components/builtins/Embed.js +23 -0
  375. package/dist/react/components/builtins/EmbedHtml.d.ts +15 -0
  376. package/dist/react/components/builtins/EmbedHtml.js +51 -0
  377. package/dist/react/components/builtins/EmbedPreview.d.ts +34 -0
  378. package/dist/react/components/builtins/EmbedPreview.js +105 -0
  379. package/dist/react/components/builtins/FilterLink.d.ts +1 -1
  380. package/dist/react/components/builtins/FilterLink.js +4 -4
  381. package/dist/react/components/builtins/Marquee.d.ts +8 -0
  382. package/dist/react/components/builtins/Marquee.js +15 -0
  383. package/dist/react/components/builtins/Popup.d.ts +26 -0
  384. package/dist/react/components/builtins/Popup.js +146 -0
  385. package/dist/react/components/builtins/SectionRef.d.ts +4 -3
  386. package/dist/react/components/builtins/SectionRef.js +9 -5
  387. package/dist/react/components/builtins/Tab.d.ts +7 -0
  388. package/dist/react/components/builtins/Tab.js +21 -0
  389. package/dist/react/components/builtins/TableOfContents.d.ts +17 -3
  390. package/dist/react/components/builtins/TableOfContents.js +22 -7
  391. package/dist/react/components/builtins/Tabs.d.ts +17 -0
  392. package/dist/react/components/builtins/Tabs.js +71 -0
  393. package/dist/react/components/builtins/index.d.ts +37 -20
  394. package/dist/react/components/builtins/index.js +54 -20
  395. package/dist/react/components/builtins/tabsContext.d.ts +12 -0
  396. package/dist/react/components/builtins/tabsContext.js +6 -0
  397. package/dist/react/components/index.js +11 -8
  398. package/dist/react/components/lazy.d.ts +32 -0
  399. package/dist/react/components/lazy.js +20 -0
  400. package/dist/react/components/lazyBlock.d.ts +17 -0
  401. package/dist/react/components/lazyBlock.js +23 -0
  402. package/dist/react/index.d.ts +6 -3
  403. package/dist/react/index.js +5 -2
  404. package/dist/react/render/RenderLayout.d.ts +9 -7
  405. package/dist/react/render/RenderLayout.js +96 -45
  406. package/dist/react/render/canvasMode.d.ts +13 -0
  407. package/dist/react/render/canvasMode.js +13 -0
  408. package/dist/react/render/canvasServer.js +4 -3
  409. package/dist/react/render/canvasServerTypes.d.ts +5 -0
  410. package/dist/react/render/lists.d.ts +36 -4
  411. package/dist/react/render/lists.js +132 -15
  412. package/dist/react/render/marks.d.ts +15 -0
  413. package/dist/react/render/marks.js +23 -0
  414. package/dist/react/render/payload.d.ts +8 -1
  415. package/dist/react/render/payload.js +12 -3
  416. package/dist/react/render/preview.d.ts +11 -0
  417. package/dist/react/render/preview.js +13 -0
  418. package/dist/react/render/relations.d.ts +10 -0
  419. package/dist/react/render/relations.js +39 -0
  420. package/dist/react/render/resolve.d.ts +8 -4
  421. package/dist/react/render/resolve.js +11 -5
  422. package/dist/react/render/reveal.d.ts +17 -0
  423. package/dist/react/render/reveal.js +39 -0
  424. package/dist/react/render/sections.d.ts +11 -5
  425. package/dist/react/render/sections.js +52 -24
  426. package/dist/react/render/templates.d.ts +47 -0
  427. package/dist/react/render/templates.js +139 -0
  428. package/dist/react/render/types.d.ts +62 -5
  429. package/dist/react/server.d.ts +2 -37
  430. package/dist/react/server.js +8 -133
  431. package/dist/react/theme/ThemeLiveLoader.d.ts +4 -0
  432. package/dist/react/theme/ThemeLiveLoader.js +5 -0
  433. package/dist/react/theme/ThemeStyle.js +1 -1
  434. package/dist/theme/admin/Variables.d.ts +11 -0
  435. package/dist/theme/admin/Variables.js +115 -0
  436. package/dist/theme/admin/fields.scss +113 -0
  437. package/dist/theme/client.d.ts +1 -0
  438. package/dist/theme/client.js +2 -0
  439. package/dist/theme/css.d.ts +6 -1
  440. package/dist/theme/css.js +12 -4
  441. package/dist/theme/global.js +83 -0
  442. package/dist/theme/index.d.ts +1 -0
  443. package/dist/theme/index.js +1 -0
  444. package/dist/theme/server.d.ts +15 -0
  445. package/dist/theme/server.js +43 -0
  446. package/dist/theme/usage.d.ts +23 -0
  447. package/dist/theme/usage.js +68 -0
  448. package/dist/theme/variables.d.ts +72 -0
  449. package/dist/theme/variables.js +231 -0
  450. package/package.json +4 -2
  451. package/dist/admin/editor/styles/SiteClasses.d.ts +0 -9
  452. package/dist/admin/editor/styles/SiteClasses.js +0 -31
  453. package/dist/blocks/builtins/headingId.d.ts +0 -15
  454. package/dist/blocks/builtins/headingId.js +0 -36
  455. package/dist/blocks/builtins/lightbox.d.ts +0 -43
  456. package/dist/blocks/builtins/lightbox.js +0 -93
  457. package/dist/blocks/builtins/mediaBackdrop.d.ts +0 -11
  458. package/dist/blocks/builtins/mediaBackdrop.js +0 -79
  459. package/dist/react/components/Quote.d.ts +0 -3
  460. package/dist/react/components/Quote.js +0 -12
  461. package/dist/react/components/Spacer.d.ts +0 -3
  462. package/dist/react/components/Spacer.js +0 -6
  463. package/dist/react/components/builtins/BackdropVideo.d.ts +0 -13
  464. package/dist/react/components/builtins/BackdropVideo.js +0 -16
  465. package/dist/react/components/builtins/Lightbox.d.ts +0 -45
  466. package/dist/react/components/builtins/Lightbox.js +0 -252
  467. package/dist/react/components/builtins/MediaBackdrop.d.ts +0 -14
  468. package/dist/react/components/builtins/MediaBackdrop.js +0 -61
@@ -1,11 +1,15 @@
1
1
  // Texts and helpers shared by the MCP tools (src/mcp) and the editor's AI assistant (src/ai).
2
2
  // No zod and no Payload runtime here, so the assistant does not need the MCP dependencies.
3
- import { COLLECTION_LIST_BLOCK, FIELD_BLOCK, INDEX_PATH, ITEM_PATH, PAGE_PATH, PARENT_PATH, REPEAT_BLOCK, URL_PATH, VISIBLE_BINDING } from '../core/bindings.js';
4
- import { classFields } from '../core/classes.js';
3
+ import { SECTION_REF_BLOCK, SECTION_REF_VALUES } from '../blocks/builtins/sectionRef.js';
4
+ import { applyComponentValues, checkComponentValues, componentProperties, fieldValue } from '../core/components.js';
5
+ import { COLLECTION_LIST_BLOCK, FIELD_BLOCK, INDEX_PATH, isRichText, richTextToPlain, isRepeatSlot, ITEM_PATH, PAGE_PATH, PARENT_PATH, REPEAT_BLOCK, URL_PATH } from '../core/bindings.js';
6
+ import { blockParts } from '../core/classes.js';
7
+ import { conditionMet, readCondition } from '../core/conditions.js';
5
8
  import { dataFields, optionValues } from '../core/fields.js';
6
9
  import { htmlIdsOf, withoutTakenHtmlIds } from '../core/attrs.js';
7
10
  import { createId } from '../core/ids.js';
8
11
  import { MOTION_EASING_INFO, MOTION_KINDS, MOTION_PRESET_INFO, MOTION_SPECS } from '../core/motion.js';
12
+ import { listedVariants } from '../core/sections.js';
9
13
  import { DEFAULT_SLOT, indexLayout } from '../core/tree.js';
10
14
  /** The keys of a motion kind with their limits, e.g. "duration 50-5000, easing: ease-out | ..., repeat". */
11
15
  function motionKeys(kind) {
@@ -39,33 +43,36 @@ export function motionGuide() {
39
43
  */
40
44
  export function layoutGuide(blocksFrom) {
41
45
  return `
42
- LAYOUT MODEL. A layout is JSON: { "version": 1, "blocks": Block[] }. A Block is { id, type, props?, className?, slots?, bindings?, hidden?, motion?, attrs?, slotClassName? }.
46
+ LAYOUT MODEL. A layout is JSON: { "version": 1, "blocks": Block[] }. A Block is { id, type, props?, className?, slots?, bindings?, visibility?, hidden?, motion?, attrs?, partClassName? }.
43
47
  - id: a string, unique in the whole layout. Operations target blocks by id, never by array index. New blocks need new ids: use "b_" plus 6 lowercase letters or digits (e.g. "b_k3x9qa").
44
48
  - type: a block type from ${blocksFrom}.
45
49
  - props: the block's own values. Get the exact shape with getBlockSchema. Upload and relationship props hold document IDs.
46
- - className: Tailwind CSS v4 utility classes, with variants such as md:, lg:, hover:, dark:. Theme classes work (bg-primary, text-primary-foreground, text-muted-foreground, font-heading). CSS is generated on save, so any valid class works.
50
+ - className: Tailwind CSS v4 utility classes, with variants such as md:, lg:, hover:, dark:. Theme classes work (bg-primary, text-primary-foreground, text-muted-foreground, font-heading). CSS is generated on save, so any valid class works. In "update", className replaces the whole list; addClassName and removeClassName (space-separated) change single classes and keep the rest.
47
51
  - slots: child blocks by slot name, e.g. { "children": [ ...blocks ] }. Only block types with slots take children. ${blocksFrom} shows which types each slot accepts. A type with "onlyInside" goes only directly inside those types (e.g. "listItem" only in a "list"). A slot with "maxBlocks" holds at most that many direct children: inserting into a full slot fails, so replace (update or remove) the block there instead. A slot with "minBlocks" needs that many before the page can be published.
48
- - bindings: (templates and collection list items only) prop path -> document field path, e.g. { "text": "title" }, { "image": "featuredImage" }, { "link": "$url" }. At render time the prop takes the document's value; when the document has no value the literal prop stays. Get field paths from getBindingSources.
52
+ - bindings: (templates, and blocks inside the "item" slot of a collection list or repeat, only) prop path -> document field path, e.g. { "text": "title" }, { "image": "featuredImage" }, { "link": "$url" }. At render time the prop takes the document's value; when the document has no value the literal prop stays. Get field paths from getBindingSources.
53
+ - visibility: (templates, and blocks inside the "item" slot of a collection list or repeat, only) conditions that show the block only when they match the document (see VISIBILITY in the bindings guide). Leave it out when the block always shows.
54
+ - On a normal page, outside list and repeat items, there is no current document: bindings and visibility do nothing (the block always shows), and the tools return a "no-effect" warning. Use "hidden": true to hide a block there.
49
55
  - motion: animations of the block (see MOTION below). Leave it out when the block has none.
50
- - slotClassName: Tailwind classes of a slot's own element, by slot name, e.g. { "empty": "col-span-full text-center" }. Only slots marked with "classes" in ${blocksFrom} take them. In "update" it merges per slot; null removes a slot's classes.
56
+ - partClassName: Tailwind classes of a block's inner elements, by part name, e.g. { "empty": "col-span-full text-center" } on a collection list or { "arrow": "size-12 rounded-full bg-white" } on a carousel. Only the "parts" listed in ${blocksFrom} take them. In "update" it merges per part; null removes a part's classes.
51
57
  - attrs: HTML attributes of the block element: { id?, ariaLabel?, ariaHidden? }. "id" is an anchor for "#id" links (e.g. "contact"), unique in the layout, letters, digits, - and _, starting with a letter; never the block id. "ariaLabel" names the element for screen readers (e.g. a nav or an icon-only link). "ariaHidden": true hides decorative blocks from screen readers. Copies of a section or a block leave out an id the page already uses.
52
- - Canonical form: leave out empty props, slots, bindings and motion objects and empty slot lists. Set hidden only when true.
58
+ - section: { id, variant? } on the root block of a ready-made section, set by insertSection. Editors use it to switch the section to another variant. Keep it as it is; never write it yourself.
59
+ - Canonical form: leave out empty props, slots, bindings, visibility and motion objects and empty slot lists. Set hidden only when true.
53
60
  POSITION = { parentId, slot?, index }. parentId null means the page root, whose only slot is "children". slot defaults to "children". index is the block's FINAL index in the target list (0 = first; the list length = append). For a move inside the same list, count positions after the block is taken out.
54
61
  ${motionGuide()}`.trim();
55
62
  }
56
63
  export const BINDINGS_GUIDE = [
57
64
  'BINDINGS. A block in a template (or in a collection list item) binds props to document fields: "bindings": { "<prop path>": "<field path>" }.',
58
65
  'Examples: heading { "text": "title" }, text { "text": "excerpt" }, image { "image": "featuredImage" }, button or link { "link": "$url" }.',
59
- `"${URL_PATH}" is the document's page URL. Nested props use dots: { "link.url": "$url" }. "<relationship path>.${URL_PATH}" is the page URL of a related document, e.g. { "link": "categories.0.${URL_PATH}" } (the first category of a listed model).`,
66
+ `"${URL_PATH}" is the document's page URL. Nested props use dots: { "link.url": "$url" }. "<relationship path>.${URL_PATH}" is the page URL of a related document, e.g. { "link": "categories.0.${URL_PATH}" } (the first category of a listed post).`,
60
67
  'Values are converted to the prop type: rich text and dates become plain text in text props. When the document has no value, the literal prop stays, so bound props may stay empty.',
61
68
  `The "${FIELD_BLOCK}" block shows any field by its type (rich text, image, date, text): props { "path": "content" }.`,
62
69
  `In a "${COLLECTION_LIST_BLOCK}" block, blocks in the "item" slot bind to each LISTED document, not to the page.`,
63
70
  `In a "${REPEAT_BLOCK}" block (props { "path": "faqs" }), blocks in the "item" slot bind to each ROW of that list field: the row's fields ("question"), "${ITEM_PATH}" (the row value, e.g. an upload for an image) and "${INDEX_PATH}" (the row number from 1).`,
64
71
  `Inside any list or repeat item: "${PARENT_PATH}.<field>" reads the enclosing document (e.g. "${PARENT_PATH}.name"), "${PAGE_PATH}.<field>" the page's own document, "${INDEX_PATH}" the item number.`,
65
- 'Fallbacks: "heading|name" uses the first path with a value.',
66
- 'Formatters after the paths: "publishedAt|date:en-AU:Australia/Brisbane", "price|currency:AUD" ($1,200), "price|number", "bio|firstSentence".',
67
- 'Template strings: a binding with {{…}} is text with expressions, e.g. { "text": "Enquire about {{name}}" } or "From {{price|currency:AUD}}". A missing expression becomes empty; when all are missing the literal prop stays.',
68
- `Conditional blocks: "${VISIBLE_BINDING}" in bindings shows the block only when the condition holds: "availableToday" (filled; false counts as empty), "!availableToday" (empty), "district=north" (equals; for lists, any item or document id), "district!=north", and for numbers "price>100", "price>=100", "age<30", "age<=30". "field#" is the number of items of a list: "galleryImages#>=3" (at least 3 photos), "services#=0". A hidden block renders nothing on the site.`,
72
+ 'Fallbacks: "subtitle|title" uses the first path with a value.',
73
+ 'Formatters after the paths, arguments after ":": "publishedAt|date:en-GB:Europe/London" (language, time zone), "price|currency:EUR" (€1,200; code, language), "price|number", "name|uppercase", "name|lowercase", "summary|truncate:160" (characters) or "summary|truncate:25:words", "body|readingTime" ("5 min read"; arguments: words per minute, the text after the number). After the first part, a formatter name is always a formatter: a field called "date" can only be the first path.',
74
+ 'Template strings: a binding with {{…}} is text with expressions, e.g. { "text": "Read about {{title}}" } or "From {{price|currency:EUR}}". A missing expression becomes empty; when all are missing the literal prop stays. There is no other syntax.',
75
+ 'VISIBILITY. "visibility": { "match"?: "all" | "any", "conditions": [{ "field", "operator", "value"?, "valueField"?, "count"? }] } shows the block only when all (or any) conditions match the document. "valueField" (a field path) compares with another field instead of "value". With "match": "any", an entry may be a group { "all": [conditions] }, so { "match": "any", "conditions": [{ "all": [a, b] }, c] } means (a and b) or c. field: a field path, or "$index", "$item", "$parent.<field>", "$page.<field>". Operators: is_set, is_empty (no value; false counts as empty), equals, not_equals (for lists: any item or document id), in, not_in (value is a list), greater_than, greater_than_equal, less_than, less_than_equal (numbers or dates), like (all words, any case), contains (any case). "count": true compares the number of items of an array or hasMany field. Examples: { "conditions": [{ "field": "price", "operator": "greater_than", "value": 100 }] }; { "conditions": [{ "field": "gallery", "operator": "greater_than_equal", "value": 3, "count": true }] }. A block that fails renders nothing on the site. On a normal page, outside list and repeat items, there is no current document: the conditions are not checked and the block always shows.',
69
76
  ].join('\n');
70
77
  /** Copies a block tree with new ids that are not in `used`. */
71
78
  export function withNewIds(block, used) {
@@ -155,7 +162,8 @@ export function sectionInsertOps(layout, section, at) {
155
162
  }
156
163
  /** A block type as plain data for AI models: props, slots, where it may go, description and example. */
157
164
  export function describeBlock(def) {
158
- const classProps = new Set(classFields(def).map((f) => f.name));
165
+ // Inner elements that take classes in `partClassName`, with the classes a new block starts with.
166
+ const parts = blockParts(def).map(({ name, label, defaultClassName }) => ({ name, label, ...(defaultClassName ? { defaultClassName } : {}) }));
159
167
  const props = dataFields(def.fields).map((f) => {
160
168
  const options = f.type === 'select' || f.type === 'radio' ? optionValues(f) : undefined;
161
169
  return {
@@ -165,7 +173,6 @@ export function describeBlock(def) {
165
173
  ...(f.hasMany ? { hasMany: true } : {}),
166
174
  ...(options?.length ? { options } : {}),
167
175
  ...(f.relationTo ? { relationTo: f.relationTo } : {}),
168
- ...(classProps.has(f.name) ? { holds: 'Tailwind classes (compiled like className)' } : {}),
169
176
  };
170
177
  });
171
178
  const slots = def.slots
@@ -176,7 +183,6 @@ export function describeBlock(def) {
176
183
  accepts: slot.allow && !slot.allow.includes('*') ? slot.allow : 'any block',
177
184
  ...(typeof slot.min === 'number' ? { minBlocks: slot.min } : {}),
178
185
  ...(typeof slot.max === 'number' ? { maxBlocks: slot.max } : {}),
179
- ...(slot.styles ? { classes: 'takes its own classes in "slotClassName"' } : {}),
180
186
  },
181
187
  ]))
182
188
  : undefined;
@@ -190,9 +196,18 @@ export function describeBlock(def) {
190
196
  ...(def.parents ? { onlyInside: def.parents } : {}),
191
197
  ...(def.styles === false ? { className: 'not supported' } : {}),
192
198
  ...(def.defaultClassName ? { defaultClassName: def.defaultClassName } : {}),
199
+ ...(parts.length > 0 ? { parts } : {}),
193
200
  ...(def.ai?.example ? { example: def.ai.example } : {}),
194
201
  };
195
202
  }
203
+ /**
204
+ * `variants` of a `listSections` entry (MCP and the assistant): each variant's id, label,
205
+ * description and outline (`full`: its block JSON). Empty when the section has none.
206
+ */
207
+ export function variantsListing(section, full) {
208
+ const variants = listedVariants(section, (blocks) => (full ? { blocks } : { outline: outline(blocks).join('\n') }));
209
+ return variants ? { variants } : {};
210
+ }
196
211
  /** One line per block (indented by depth), with the start of its text, for a short section summary. */
197
212
  export function outline(blocks, depth = 0) {
198
213
  return blocks.flatMap((block) => {
@@ -202,3 +217,184 @@ export function outline(blocks, depth = 0) {
202
217
  return [own, ...children];
203
218
  });
204
219
  }
220
+ const UPDATE_META = new Set(['type', 'id', 'locale']);
221
+ const CLASS_KEYS = new Set(['className', 'addClassName', 'removeClassName']);
222
+ /**
223
+ * A short list of what an operation batch did, one entry per operation: ids, block types, and for
224
+ * updates the keys they changed. `before` and `after` are the layouts around the batch, `ops` the
225
+ * applied operations (duplicates as inserts).
226
+ */
227
+ export function changeSummary(before, after, ops) {
228
+ const old = indexLayout(before);
229
+ const now = indexLayout(after);
230
+ const typeOf = (id) => now.get(id)?.block.type ?? old.get(id)?.block.type ?? 'unknown';
231
+ return ops.map((op) => {
232
+ switch (op.type) {
233
+ case 'insert': {
234
+ const count = touchedIds([op]).size;
235
+ return { op: op.type, id: op.block.id, type: op.block.type, to: op.to, ...(count > 1 ? { blocks: count } : {}) };
236
+ }
237
+ case 'move':
238
+ return { op: op.type, id: op.id, type: typeOf(op.id), to: op.to };
239
+ case 'remove':
240
+ case 'duplicate':
241
+ return { op: op.type, id: op.id, type: typeOf(op.id) };
242
+ case 'update': {
243
+ const changed = [];
244
+ for (const [key, value] of Object.entries(op)) {
245
+ if (UPDATE_META.has(key) || value === undefined)
246
+ continue;
247
+ if (key === 'props' && value && typeof value === 'object')
248
+ changed.push(...Object.keys(value).map((name) => `props.${name}`));
249
+ else if (key === 'unsetProps' && Array.isArray(value))
250
+ changed.push(...value.map((name) => `props.${String(name)}`));
251
+ else if (CLASS_KEYS.has(key))
252
+ changed.push('className');
253
+ else
254
+ changed.push(key);
255
+ }
256
+ const classes = Object.keys(op).some((key) => CLASS_KEYS.has(key));
257
+ return {
258
+ op: op.type,
259
+ id: op.id,
260
+ type: typeOf(op.id),
261
+ changed: [...new Set(changed)],
262
+ ...(classes ? { className: now.get(op.id)?.block.className ?? '' } : {}),
263
+ };
264
+ }
265
+ }
266
+ });
267
+ }
268
+ /** The block ids an operation batch touched: inserted blocks with their children, moved and updated blocks. */
269
+ export function touchedIds(ops) {
270
+ const ids = new Set();
271
+ const collect = (block) => {
272
+ ids.add(block.id);
273
+ for (const children of Object.values(block.slots ?? {}))
274
+ children.forEach(collect);
275
+ };
276
+ for (const op of ops) {
277
+ if (op.type === 'insert')
278
+ collect(op.block);
279
+ else if (op.type === 'move' || op.type === 'update')
280
+ ids.add(op.id);
281
+ }
282
+ return ids;
283
+ }
284
+ /**
285
+ * Blocks in `list` (children included) whose main upload or relationship prop is empty: an image
286
+ * block without an image, a form block without a form. Per block type that is the first upload or
287
+ * relationship field and every required one. Props hidden by their field's condition, bound props
288
+ * and hasMany fields are left out.
289
+ */
290
+ export function missingContent(list, definitions) {
291
+ const byType = new Map(definitions.map((def) => [def.type, def]));
292
+ const out = [];
293
+ const visit = (block) => {
294
+ const def = byType.get(block.type);
295
+ if (def) {
296
+ const fields = dataFields(def.fields);
297
+ const props = block.props ?? {};
298
+ const refs = fields.filter((f) => (f.type === 'upload' || f.type === 'relationship') && !f.hasMany && f.relationTo);
299
+ refs.forEach((field, i) => {
300
+ if (i > 0 && !field.required)
301
+ return;
302
+ const value = props[field.name];
303
+ if ((value !== undefined && value !== null && value !== '') || block.bindings?.[field.name])
304
+ return;
305
+ const condition = readCondition(field);
306
+ if (condition && !conditionMet(condition, props, fields))
307
+ return;
308
+ out.push({ id: block.id, type: block.type, prop: field.name, field: field.type, relationTo: field.relationTo });
309
+ });
310
+ }
311
+ for (const children of Object.values(block.slots ?? {}))
312
+ children.forEach(visit);
313
+ };
314
+ list.forEach(visit);
315
+ return out;
316
+ }
317
+ /** What to do about `missingContent`, for tool results. `generateImage`: the tool that makes images is there. */
318
+ export function missingContentHint(missing, options) {
319
+ const parts = [];
320
+ if (missing.some((m) => m.field === 'upload')) {
321
+ parts.push(`Empty images render nothing on the site. ${options.generateImage ? 'Make one with generateImage, or use' : 'Use'} an existing upload (findDocument or searchContent on the upload collection) or upload one (uploadMedia), then set its id: applyOperations {"type":"update","id":"<block id>","props":{"<prop>":<media id>}}.`);
322
+ }
323
+ if (missing.some((m) => m.field === 'relationship')) {
324
+ parts.push('Empty relationships (for example a form): find a document of `relationTo` with findDocument, then set its id the same way.');
325
+ }
326
+ return parts.join(' ');
327
+ }
328
+ /**
329
+ * Warnings for `visibility` and `bindings` that do nothing: on a normal page nothing checks them
330
+ * (there is no current document), so the block always shows and bound props keep their own value.
331
+ * They work in templates and inside the "item" slot of a collection list or repeat. `only`: report
332
+ * these block ids only.
333
+ */
334
+ export function contextOnlyWarnings(layout, only) {
335
+ const out = [];
336
+ const visit = (list, path, inItem) => {
337
+ list.forEach((block, i) => {
338
+ const at = `${path}[${i}]`;
339
+ if (!inItem && (!only || only.has(block.id))) {
340
+ if (block.visibility)
341
+ out.push({ blockId: block.id, path: `${at}.visibility`, code: 'no-effect', message: CONTEXT_ONLY_VISIBILITY });
342
+ if (block.bindings && Object.keys(block.bindings).length > 0) {
343
+ out.push({ blockId: block.id, path: `${at}.bindings`, code: 'no-effect', message: CONTEXT_ONLY_BINDINGS });
344
+ }
345
+ }
346
+ for (const [slot, children] of Object.entries(block.slots ?? {}))
347
+ visit(children, `${at}.slots.${slot}`, inItem || isRepeatSlot(block.type, slot));
348
+ });
349
+ };
350
+ visit(layout.blocks, 'blocks', false);
351
+ return out;
352
+ }
353
+ export const CONTEXT_ONLY_VISIBILITY = 'visibility does nothing here: it only applies in templates and in collection list or repeat items. On a normal page the block always shows. Remove it, or set "hidden": true to hide the block.';
354
+ export const CONTEXT_ONLY_BINDINGS = 'bindings do nothing here: they only apply in templates and in collection list or repeat items. On a normal page the props keep their own values. Write the values into props instead.';
355
+ /** A property's default as AI models read it: rich text as plain text, an image as its upload id. */
356
+ function defaultForModels(property) {
357
+ if (property.type === 'richText')
358
+ return isRichText(property.default) ? richTextToPlain(property.default) : property.default;
359
+ if (property.type === 'image')
360
+ return fieldValue(property, property.default);
361
+ return property.default;
362
+ }
363
+ /**
364
+ * `listSections` fields of a component (a saved section with properties): `component: true` and
365
+ * its properties with their type and default. Nothing for other sections.
366
+ */
367
+ export function componentListing(section, blocks) {
368
+ if (section.savedId === undefined)
369
+ return {};
370
+ const properties = componentProperties(section.blocks, blocks);
371
+ if (properties.length === 0)
372
+ return {};
373
+ return {
374
+ component: true,
375
+ properties: properties.map((p) => {
376
+ const value = defaultForModels(p);
377
+ return { name: p.name, type: p.type, ...(value !== undefined ? { default: value } : {}) };
378
+ }),
379
+ };
380
+ }
381
+ /**
382
+ * The section `insertSection` puts in. A component (or `linked: true`) goes in as one copy that
383
+ * stays in sync (a `sectionRef` block) with `values`; else the section's blocks go in as plain
384
+ * blocks, with `values` put into them. Returns the problem as text.
385
+ */
386
+ export function sectionToInsert(section, blocks, options) {
387
+ const properties = section.savedId !== undefined ? componentProperties(section.blocks, blocks) : [];
388
+ const linked = options.linked ?? properties.length > 0;
389
+ const { values, problems } = checkComponentValues(properties, options.values);
390
+ if (problems.length > 0)
391
+ return problems.join(' ');
392
+ if (!linked)
393
+ return { ...section, blocks: applyComponentValues(section.blocks, values, blocks) };
394
+ if (section.savedId === undefined)
395
+ return 'Only saved sections can be inserted as linked copies (linked: true).';
396
+ if (!blocks.some((def) => def.type === SECTION_REF_BLOCK))
397
+ return 'Linked copies of saved sections are turned off on this site.';
398
+ const props = { section: section.savedId, ...(Object.keys(values).length > 0 ? { [SECTION_REF_VALUES]: values } : {}) };
399
+ return { ...section, blocks: [{ id: 'component', type: SECTION_REF_BLOCK, props }] };
400
+ }
@@ -1,7 +1,7 @@
1
1
  import { type CollectionAfterChangeHook, type CollectionBeforeChangeHook, type CollectionBeforeOperationHook, type FieldHook, type PayloadRequest, type SanitizedCollectionConfig } from 'payload';
2
2
  import { type FieldRunContext } from '../core/fieldHooks.js';
3
3
  import { type FieldRegistry } from '../core/fieldSemantics.js';
4
- import type { BindingField, BlockDefinition, Layout, LocaleSettings } from '../core/types.js';
4
+ import { type BindingField, type BlockDefinition, type Layout, type LocaleSettings } from '../core/types.js';
5
5
  import { type LayoutError } from '../core/validate.js';
6
6
  import { type CssOptions } from '../css/index.js';
7
7
  import { type FieldClock, type FieldHistory, type SettingsLocks } from '../live/fieldsGuard.js';
@@ -93,6 +93,12 @@ export type HookChanges = {
93
93
  };
94
94
  /** The prop hook changes a save of `collection`/`id` recorded in its `context`, or null. */
95
95
  export declare function hookChangesOf(context: Record<string, unknown> | undefined, collection: string, id: unknown): HookChanges | null;
96
+ /**
97
+ * A save by the plugin itself: the session's draft, publish / unpublish / revert, or the template
98
+ * "Default" flag. It keeps Payload's document lock and skips the stale-save check.
99
+ */
100
+ /** The start of the error when content mode refuses a Restore that would change the design. */
101
+ export declare const RESTORE_DESIGN_MESSAGE = "This version has a different design, so only a designer can restore it.";
96
102
  /**
97
103
  * Before a plugin save, remembers Payload's lock on the document, so `layoutAfterChange` can put
98
104
  * it back (Payload deletes the lock on every update). Also before a save by someone who has the
@@ -4,6 +4,7 @@ import { APIError, getLatestCollectionVersion, ValidationError, } from 'payload'
4
4
  import { validateBindings, withoutBoundRequired } from '../core/bindings.js';
5
5
  import { richTextFieldName } from '../core/blocks.js';
6
6
  import { collectClasses } from '../core/classes.js';
7
+ import { contentModeProblem } from '../core/contentMode.js';
7
8
  import { enforcePropAccess, filterUnreadableProps, hasPropAccess } from '../core/fieldAccess.js';
8
9
  import { hasPropHooks, runPropHooks } from '../core/fieldHooks.js';
9
10
  import { sameJson } from '../core/fieldSemantics.js';
@@ -11,9 +12,14 @@ import { runPropValidators } from '../core/fieldValidate.js';
11
12
  import { describeLayoutErrors } from '../core/issues.js';
12
13
  import { hasLocaleValues, knownLocale, mergeLocaleView, resolveLayoutLocale } from '../core/locale.js';
13
14
  import { isPlainObject, normalizeLayout } from '../core/tree.js';
15
+ import { EMPTY_LAYOUT } from '../core/types.js';
14
16
  import { isBlockingError, isLayoutWarning, validateLayout } from '../core/validate.js';
15
17
  import { compileClasses } from '../css/index.js';
18
+ import { withoutClassNames } from '../classes/shared.js';
19
+ import { classNamesFor } from '../classes/sheet.js';
20
+ import { withThemeVariables } from '../theme/server.js';
16
21
  import { changedFieldsOf, checkStaleSave, defaultFieldClock, defaultFieldHistory, defaultSettingsLocks, KEEP_LOCK_CONTEXT, keepNewerField, recordFieldChanges, rememberLocks, restoreLocks, staleSaveErrors, staleSaveMessage, topFieldLabel, } from '../live/fieldsGuard.js';
22
+ import { canEditDesign } from '../live/contentMode.js';
17
23
  import { defaultWriteGate, writeKey } from '../live/writeGate.js';
18
24
  /** `context` flag of the session's own draft saves. */
19
25
  export const SESSION_SAVE_CONTEXT = 'builderSession';
@@ -124,6 +130,8 @@ export function hookChangesOf(context, collection, id) {
124
130
  * A save by the plugin itself: the session's draft, publish / unpublish / revert, or the template
125
131
  * "Default" flag. It keeps Payload's document lock and skips the stale-save check.
126
132
  */
133
+ /** The start of the error when content mode refuses a Restore that would change the design. */
134
+ export const RESTORE_DESIGN_MESSAGE = 'This version has a different design, so only a designer can restore it.';
127
135
  /** Payload's Restore of a version (its operation sets this flag): the version's values are the truth. */
128
136
  function isRestore(context) {
129
137
  return Boolean(context?.isRestoringVersion);
@@ -166,7 +174,7 @@ function isGeneratedCss(value) {
166
174
  return typeof v.hash === 'string' && typeof v.css === 'string';
167
175
  }
168
176
  /** The hash covers the class list and the entry CSS, so a theme change also recompiles. */
169
- async function hashInput(classes, entry) {
177
+ async function hashInput(classes, entry, themeCss = '') {
170
178
  const hash = createHash('sha256');
171
179
  hash.update(classes.join(' '));
172
180
  hash.update('\0');
@@ -176,6 +184,9 @@ async function hashInput(classes, entry) {
176
184
  catch {
177
185
  // The compile reports a missing entry file. The hash stays usable.
178
186
  }
187
+ // The theme's variable names (`bg-brand` compiles only while `brand` exists). Empty: the old hash.
188
+ if (themeCss)
189
+ hash.update(themeCss);
179
190
  return hash.digest('hex').slice(0, 16);
180
191
  }
181
192
  function formatErrors(errors) {
@@ -325,6 +336,19 @@ export function layoutBeforeChange(options) {
325
336
  if (at)
326
337
  layout = mergeLocaleView(savedLayout, layout, at.locale, blocks, localization);
327
338
  }
339
+ // Content mode (editor.canEditDesign): a user's own save (REST, GraphQL, the Edit view) and
340
+ // Payload's Restore of a version may change only content. The live session checks each edit
341
+ // when it arrives, so its saves, the guarded saves and the plugin's own saves are not checked
342
+ // again. A restore is compared with the session's layout when one is open (it holds edits
343
+ // that are not saved yet), else with the stored layout.
344
+ const restoring = isRestore(context);
345
+ const userSave = !own && !guarded && !isPluginSave(context) && context?.[OVERRIDE_ACCESS_CONTEXT] === false;
346
+ if (userSave && req.user && !(await canEditDesign(req))) {
347
+ const current = (restoring && docId !== undefined ? sessions?.peek(slug, docId)?.layout : undefined) ?? savedLayout ?? EMPTY_LAYOUT;
348
+ const problem = contentModeProblem(current, layout, blocks);
349
+ if (problem)
350
+ throw new APIError(restoring ? `${RESTORE_DESIGN_MESSAGE} ${problem}` : problem, 403, undefined, true);
351
+ }
328
352
  if (registry) {
329
353
  // Field access. The live session checks every edit when it arrives (session.ts), so its
330
354
  // saves and the layouts the guard put in are not checked again. Other saves (REST, the
@@ -356,8 +380,10 @@ export function layoutBeforeChange(options) {
356
380
  }
357
381
  data[field] = layout;
358
382
  // Block definitions add the classes their components use, so those reach the CSS too.
359
- const classes = collectClasses(layout, blocks);
360
- const hash = await hashInput(classes, css.entry);
383
+ // Editable classes come from their own stylesheet: the layout's CSS leaves them out.
384
+ const classes = withoutClassNames(collectClasses(layout, blocks), new Set(await classNamesFor(req.payload).catch(() => [])));
385
+ const siteCss = await withThemeVariables(req.payload, css);
386
+ const hash = await hashInput(classes, css.entry, siteCss.themeCss);
361
387
  if (isGeneratedCss(previous) && previous.hash === hash) {
362
388
  data[cssField] = previous;
363
389
  return data;
@@ -367,7 +393,7 @@ export function layoutBeforeChange(options) {
367
393
  return data;
368
394
  }
369
395
  try {
370
- const output = await compileClasses(classes, css);
396
+ const output = await compileClasses(classes, siteCss);
371
397
  data[cssField] = { hash, css: output };
372
398
  }
373
399
  catch (error) {
@@ -6,6 +6,8 @@ import { type CssOptions, type FontFamilies, type TailwindPlugins } from '../css
6
6
  import { type ThemeOptions } from '../theme/config.js';
7
7
  import { type SavedSectionsOptions } from './sections.js';
8
8
  import { type ReferencesOptions } from './references.js';
9
+ import { type ClassesOptions } from '../classes/index.js';
10
+ import { type CommentsOptions } from '../comments/index.js';
9
11
  export type { GeneratedCss } from './hook.js';
10
12
  export type { SavedSectionsOptions } from './sections.js';
11
13
  export type { ReferencesOptions } from './references.js';
@@ -143,7 +145,10 @@ export type WebsiteBuilderOptions = {
143
145
  * `payload-canvas/react/server`. See the README's "Theme" section.
144
146
  */
145
147
  theme?: ThemeOptions | false;
146
- /** Editor behaviour, e.g. `{ dragMode: 'smooth' }`. See the README's "Drag and drop" section. */
148
+ /**
149
+ * Editor behaviour, e.g. `{ dragMode: 'smooth', dropOutlines: false }` (see the README's "Drag and
150
+ * drop" section), or `{ openInBuilder: true }`: opening a saved document goes straight to the builder.
151
+ */
147
152
  editor?: EditorOptions;
148
153
  /**
149
154
  * References: a hidden `builderRefs` field on every builder collection lists the media and
@@ -152,6 +157,19 @@ export type WebsiteBuilderOptions = {
152
157
  * the README's "References and Used in" section.
153
158
  */
154
159
  references?: ReferencesOptions | false;
160
+ /**
161
+ * Editable classes: a collection of named classes (`card`, `btn-primary`) with Tailwind classes
162
+ * and custom CSS, edited in the Styles panel. A change restyles every block that uses the class,
163
+ * without a deploy. On by default; `false` turns it off. Render the stylesheet on the site with
164
+ * `ClassesStyle` from `payload-canvas/react/server`. See the README's "Editable classes" section.
165
+ */
166
+ classes?: ClassesOptions | boolean;
167
+ /**
168
+ * Comments on the canvas: people who may change a page leave comments on its blocks, reply and
169
+ * resolve them in the builder, live for everyone. Stored in a `builder-comments` collection, never
170
+ * in the layout. On by default; `false` turns it off. See the README's "Comments" section.
171
+ */
172
+ comments?: CommentsOptions | boolean;
155
173
  };
156
174
  /** Key of the full-screen builder view in `admin.components.views`. */
157
175
  export declare const BUILDER_VIEW_KEY = "websiteBuilder";
@@ -159,13 +177,6 @@ export declare const BUILDER_VIEW_KEY = "websiteBuilder";
159
177
  export declare const BUILDER_VIEW_PATH = "/builder/:collection/:id";
160
178
  /** Name of the hidden field that stores the generated CSS (`{ hash, css }`) for a layout field. */
161
179
  export declare function cssFieldName(field: string): string;
162
- /**
163
- * The website builder plugin. Put it LAST in `plugins`: plugins such as SEO with `tabbedUI`
164
- * move all fields into tabs, and the layout field must stay a top-level field.
165
- *
166
- * Editors open the builder full screen at `{admin}/builder/:collection/:id` (a root admin view
167
- * without Payload's nav and header). The document's "Builder" tab and the layout field link there.
168
- */
169
180
  export declare function websiteBuilder(options: WebsiteBuilderOptions): Plugin;
170
181
  /** Name of the hidden virtual field that carries the builder's config for a Payload blocks field. */
171
182
  export declare function builderConfigFieldName(field: string): string;