payload-canvas 0.4.0 → 0.5.1

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 +626 -154
  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 -1
  234. package/dist/blocks/index.js +2 -1
  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
@@ -6,6 +6,7 @@ import { memo, useCallback } from 'react';
6
6
  import { SECTION_REF_BLOCK, sectionRefId } from '../../../blocks/builtins/sectionRef.js';
7
7
  import { findBlock, findLocation } from '../../../core/index.js';
8
8
  import { copyBlock, copyStyles, detachSection, duplicateBlock, inRow, moveBy, parseClipboard, pasteStoredBlocks, pasteStyles, removeBlock, resetStyles, siblingCount, storedClipboard, storedStyles, storesBuilderData, toggleHidden, } from '../actions.js';
9
+ import { contentModeAllows } from '../contentMode.js';
9
10
  import { useRuntime } from '../runtime.js';
10
11
  import { requestSaveSection } from '../sections/SectionDialog.js';
11
12
  import { useEditor } from '../store.js';
@@ -39,26 +40,35 @@ export function blockMenuEntries(runtime, id, origin) {
39
40
  const row = inRow(layout, runtime.measurement.get(), id);
40
41
  // A Payload blocks field stores no styles (storesBuilderData), whatever the definition says.
41
42
  const styled = storesBuilderData(runtime) && hasStyles(runtime.config.blocks, block.type);
43
+ const selectParent = { icon: 'parent', label: 'Select parent', keys: keys('parent'), disabled: !parentId, run: () => parentId && runtime.store.select(parentId) };
44
+ const moveUp = {
45
+ icon: row ? 'left' : 'up',
46
+ label: row ? 'Move left' : 'Move up',
47
+ keys: keys('moveUp'),
48
+ disabled: !location || location.index === 0,
49
+ run: () => moveBy(runtime, id, -1),
50
+ };
51
+ const moveDown = {
52
+ icon: row ? 'right' : 'down',
53
+ label: row ? 'Move right' : 'Move down',
54
+ keys: keys('moveDown'),
55
+ disabled: !location || location.index >= siblings - 1,
56
+ run: () => moveBy(runtime, id, 1),
57
+ };
58
+ const duplicate = { icon: 'duplicate', label: 'Duplicate', keys: keys('duplicate'), run: () => duplicateBlock(runtime, id) };
59
+ const remove = { icon: 'delete', label: 'Delete', keys: keys('delete'), danger: true, run: () => removeBlock(runtime, id) };
60
+ // Content mode: items of a block that lets editors manage them move, copy and go; nothing else changes.
61
+ if (runtime.contentMode.get()) {
62
+ return contentModeAllows('duplicate', layout, id) ? [selectParent, 'separator', moveUp, moveDown, 'separator', duplicate, 'separator', remove] : [selectParent];
63
+ }
42
64
  return [
43
- { icon: 'parent', label: 'Select parent', keys: keys('parent'), disabled: !parentId, run: () => parentId && runtime.store.select(parentId) },
65
+ selectParent,
44
66
  { icon: 'rename', label: 'Rename', keys: keys('rename'), ownFocus: true, run: () => requestRename(runtime, id, origin === 'outline' ? 'outline' : 'inspector') },
45
67
  'separator',
46
- {
47
- icon: row ? 'left' : 'up',
48
- label: row ? 'Move left' : 'Move up',
49
- keys: keys('moveUp'),
50
- disabled: !location || location.index === 0,
51
- run: () => moveBy(runtime, id, -1),
52
- },
53
- {
54
- icon: row ? 'right' : 'down',
55
- label: row ? 'Move right' : 'Move down',
56
- keys: keys('moveDown'),
57
- disabled: !location || location.index >= siblings - 1,
58
- run: () => moveBy(runtime, id, 1),
59
- },
68
+ moveUp,
69
+ moveDown,
60
70
  'separator',
61
- { icon: 'duplicate', label: 'Duplicate', keys: keys('duplicate'), run: () => duplicateBlock(runtime, id) },
71
+ duplicate,
62
72
  { icon: 'copy', label: 'Copy', keys: keys('copy'), run: () => copyBlock(runtime, id) },
63
73
  {
64
74
  icon: 'paste',
@@ -96,7 +106,7 @@ export function blockMenuEntries(runtime, id, origin) {
96
106
  ? [{ icon: 'section', label: 'Detach section', run: () => void detachSection(runtime, id) }]
97
107
  : []),
98
108
  'separator',
99
- { icon: 'delete', label: 'Delete', keys: keys('delete'), danger: true, run: () => removeBlock(runtime, id) },
109
+ remove,
100
110
  ];
101
111
  }
102
112
  /**
@@ -1,10 +1,12 @@
1
1
  // Names for blocks in the outline, the breadcrumbs, the inspector and the publish problems.
2
2
  // Pure functions: the type label comes from the caller (the block definition's `label`).
3
+ import { iconLabel } from '../../blocks/builtins/icon.js';
4
+ import { readsComponent } from '../../core/components.js';
3
5
  import { FIELD_BLOCK, LIST_BLOCK } from './templates/binding.js';
4
6
  /** Longest preview text, in characters. The row cuts it with an ellipsis anyway. */
5
7
  const PREVIEW_MAX = 80;
6
8
  /** Block types whose text names a container only when nothing else inside has text. */
7
- const CHROME_TYPES = new Set(['menu', 'button']);
9
+ const CHROME_TYPES = new Set(['menu', 'button', 'icon']);
8
10
  /** HTML tags of a Stack that read better as a name than "Stack". */
9
11
  const TAG_NAMES = {
10
12
  section: 'Section',
@@ -60,9 +62,12 @@ function linkText(value) {
60
62
  const { url } = value;
61
63
  return typeof url === 'string' ? url : '';
62
64
  }
63
- /** Bound blocks show the field they read: `{title}`. */
65
+ /**
66
+ * Bound blocks show the field they read: `{title}`. A component's properties do not count: the
67
+ * block shows its own content, the default of every copy.
68
+ */
64
69
  function boundPreview(block) {
65
- const first = Object.values(block.bindings ?? {})[0];
70
+ const first = Object.values(block.bindings ?? {}).find((binding) => !readsComponent(binding));
66
71
  return first ? `{${first}}` : '';
67
72
  }
68
73
  const clip = (text) => (text.length > PREVIEW_MAX ? `${text.slice(0, PREVIEW_MAX - 1)}…` : text);
@@ -112,6 +117,9 @@ function ownPreview(block) {
112
117
  return innerTitle(block) || linkText(props.link);
113
118
  case 'video':
114
119
  return str('url');
120
+ case 'icon':
121
+ // The label for screen readers, else the icon's name ("arrowRight" -> "arrow right").
122
+ return clip(str('label') || iconLabel(str('name')));
115
123
  default:
116
124
  if (childrenOf(block).length > 0)
117
125
  return innerTitle(block);
@@ -9,6 +9,8 @@ type Props = {
9
9
  readonly onChange: (value: unknown) => void;
10
10
  /** The other values of the same object (block props, group or row), for fields that read a sibling. */
11
11
  readonly siblings?: Record<string, unknown>;
12
+ /** Sets several props of the same object in one change. `undefined` removes a prop. */
13
+ readonly onSiblingsChange?: (patch: Record<string, unknown>) => void;
12
14
  };
13
15
  export declare function fieldLabel(field: Field): string;
14
16
  /**
@@ -18,7 +20,7 @@ export declare function fieldLabel(field: Field): string;
18
20
  * `{ relationTo, value }`: we store IDs, or `{ relationTo, value: id }` for polymorphic fields.
19
21
  * SelectInput returns the option object. DatePicker returns a Date, stored as an ISO string.
20
22
  */
21
- export declare function RenderBlockField({ field, onChange, path, value, siblings }: Props): import("react").JSX.Element;
23
+ export declare function RenderBlockField({ field, onChange, path, value, siblings, onSiblingsChange }: Props): import("react").JSX.Element;
22
24
  type FieldsProps = {
23
25
  readonly fields: Field[];
24
26
  /** The object the fields read from: block props, a group value or an array row. */
@@ -8,10 +8,13 @@ import { isStructuralChange } from './fields/arrayState.js';
8
8
  import { CheckedTextField, NumberField } from './fields/CheckedInputs.js';
9
9
  import { FieldSection, GroupField } from './fields/GroupField.js';
10
10
  import { JsonField } from './fields/JsonField.js';
11
- import { WhereField } from './fields/WhereField.js';
11
+ import { QueryFiltersField } from './fields/QueryFiltersField.js';
12
+ import { ListWhereField } from './fields/ListWhereField.js';
12
13
  import { ManyValuesField } from './fields/ManyValuesField.js';
13
14
  import { PointField } from './fields/PointField.js';
15
+ import { RelatedField } from './fields/RelatedField.js';
14
16
  import { RichTextField } from './fields/RichTextField.js';
17
+ import { SortField } from './fields/SortField.js';
15
18
  import { fieldMergeKey } from './fields/undoPath.js';
16
19
  import { asId, formatProblem, fromRelationshipInput, isFieldVisible, isRecord, toRelationshipInput } from './fields/values.js';
17
20
  import { FieldAccessFrame, FieldAccessProvider, HiddenFieldsNote, useFieldAccessCheck } from './fields/access.js';
@@ -20,9 +23,16 @@ import { LocaleFieldFrame, LocaleFieldsProvider, useInspectorProps, useLocalePla
20
23
  import { GenerateImage } from './generate/GenerateImage.js';
21
24
  import { focusedField, propPathOf } from './live/field.js';
22
25
  import { PeerFieldNote } from './live/PresenceUI.js';
26
+ import { contentModeFields, useContentMode } from './contentMode.js';
23
27
  import { useRuntime } from './runtime.js';
24
28
  import { BindingScopeProvider, FieldSlot } from './templates/Bindable.js';
29
+ import { VisibilityField } from './templates/Visibility.js';
25
30
  import './fields/fields.scss';
31
+ /** The value of a sibling prop named in `admin.custom` (for example the list's `collection`), when it is text. */
32
+ const siblingText = (siblings, name) => {
33
+ const value = name ? siblings?.[name] : undefined;
34
+ return typeof value === 'string' ? value : undefined;
35
+ };
26
36
  function text(value) {
27
37
  if (typeof value === 'string')
28
38
  return value || undefined;
@@ -61,36 +71,50 @@ function Unsupported({ label, reason }) {
61
71
  * `{ relationTo, value }`: we store IDs, or `{ relationTo, value: id }` for polymorphic fields.
62
72
  * SelectInput returns the option object. DatePicker returns a Date, stored as an ISO string.
63
73
  */
64
- export function RenderBlockField({ field, onChange, path, value, siblings }) {
74
+ export function RenderBlockField({ field, onChange, path, value, siblings, onSiblingsChange }) {
65
75
  const { config } = useConfig();
66
76
  // In another locale, an untranslated text shows the fallback language's text as its placeholder.
67
- const placeholder = useLocalePlaceholder(path);
77
+ const localePlaceholder = useLocalePlaceholder(path);
68
78
  const label = fieldLabel(field);
69
79
  const description = fieldDescription(field);
70
80
  const required = 'required' in field ? Boolean(field.required) : false;
71
81
  // A missing value renders as the field's default; a cleared one (`null`, `''`) renders empty.
72
82
  const missing = value === undefined;
73
83
  const textDefault = missing && 'defaultValue' in field && typeof field.defaultValue === 'string' ? field.defaultValue : undefined;
84
+ // `admin.placeholder`: a hint inside the empty input ("100vw", the site's default label).
85
+ const ownPlaceholder = text(field.admin?.placeholder);
86
+ const placeholder = localePlaceholder ?? textDefault ?? ownPlaceholder;
74
87
  switch (field.type) {
75
88
  case 'text':
76
89
  case 'email': {
77
90
  if (field.type === 'text' && field.hasMany) {
78
91
  return _jsx(ManyValuesField, { description: description, kind: "text", label: label, onChange: onChange, path: path, required: required, value: value });
79
92
  }
93
+ // `admin.custom.builderSort`: a list's sort, as a field select and a direction.
94
+ const sort = field.admin?.custom?.builderSort;
95
+ if (sort) {
96
+ return _jsx(SortField, { collection: siblingText(siblings, sort.collectionField), label: label, onChange: onChange, value: missing ? field.defaultValue : value });
97
+ }
98
+ // `admin.custom.builderRelated`: a list's "Related to this page", which also sets the mode prop.
99
+ const related = field.admin?.custom?.builderRelated;
100
+ if (related?.modeField && onSiblingsChange) {
101
+ const modeField = related.modeField;
102
+ return (_jsx(RelatedField, { collection: siblingText(siblings, related.collectionField), field: value, label: label, mode: siblings?.[modeField], onChange: (next, mode) => onSiblingsChange({ [field.name]: next, [modeField]: mode }) }));
103
+ }
80
104
  if (field.admin?.custom?.builderFormat) {
81
- return (_jsx(CheckedTextField, { check: (input) => formatProblem(field, input), description: description, label: label, onChange: onChange, path: path, required: required, value: asString(value) }));
105
+ return (_jsx(CheckedTextField, { check: (input) => formatProblem(field, input), description: description, label: label, onChange: onChange, path: path, placeholder: placeholder, required: required, value: asString(value) }));
82
106
  }
83
- return (_jsx(TextInput, { description: description, label: label, onChange: (e) => onChange(e.target.value), path: path, placeholder: placeholder ?? textDefault, required: required, value: asString(value) }));
107
+ return (_jsx(TextInput, { description: description, label: label, onChange: (e) => onChange(e.target.value), path: path, placeholder: placeholder, required: required, value: asString(value) }));
84
108
  }
85
109
  case 'number': {
86
110
  if (field.hasMany) {
87
111
  return _jsx(ManyValuesField, { description: description, kind: "number", label: label, onChange: onChange, path: path, required: required, value: value });
88
112
  }
89
- return (_jsx(NumberField, { description: description, label: label, limits: { min: field.min, max: field.max, required }, onChange: onChange, path: path, placeholder: missing && typeof field.defaultValue === 'number' ? String(field.defaultValue) : undefined, required: required, value: value }));
113
+ return (_jsx(NumberField, { description: description, label: label, limits: { min: field.min, max: field.max, required }, onChange: onChange, path: path, placeholder: missing && typeof field.defaultValue === 'number' ? String(field.defaultValue) : ownPlaceholder, required: required, value: value }));
90
114
  }
91
115
  case 'textarea':
92
116
  case 'code':
93
- return (_jsx(TextareaInput, { description: description, label: label, onChange: (e) => onChange(e.target.value), path: path, placeholder: placeholder ?? textDefault, required: required, rows: field.type === 'code' ? 8 : 4, value: asString(value) }));
117
+ return (_jsx(TextareaInput, { description: description, label: label, onChange: (e) => onChange(e.target.value), path: path, placeholder: placeholder, required: required, rows: field.type === 'code' ? 8 : 4, value: asString(value) }));
94
118
  case 'select':
95
119
  case 'radio': {
96
120
  const hasMany = field.type === 'select' && Boolean(field.hasMany);
@@ -132,7 +156,13 @@ export function RenderBlockField({ field, onChange, path, value, siblings }) {
132
156
  const where = field.admin?.custom?.builderWhere;
133
157
  if (where) {
134
158
  const collection = where.collectionField ? siblings?.[where.collectionField] : undefined;
135
- return (_jsx(WhereField, { collection: typeof collection === 'string' ? collection : undefined, description: description, label: label, onChange: onChange, path: path, required: required, value: value }));
159
+ return (_jsx(ListWhereField, { collection: typeof collection === 'string' ? collection : undefined, description: description, label: label, onChange: onChange, path: path, required: required, value: value }));
160
+ }
161
+ // `admin.custom.builderQueryFilters`: a collection list's URL filters, edited as rows.
162
+ const queryFilters = field.admin?.custom?.builderQueryFilters;
163
+ if (queryFilters) {
164
+ const collection = queryFilters.collectionField ? siblings?.[queryFilters.collectionField] : undefined;
165
+ return (_jsx(QueryFiltersField, { collection: typeof collection === 'string' ? collection : undefined, description: description, label: label, onChange: onChange, path: path, required: required, value: value }));
136
166
  }
137
167
  return _jsx(JsonField, { description: description, label: label, onChange: onChange, path: path, required: required, value: value });
138
168
  }
@@ -175,6 +205,17 @@ export function RenderBlockFields({ fields, data, path, onChange, scope = fields
175
205
  delete next[name];
176
206
  onChange(Object.keys(next).length > 0 ? next : undefined);
177
207
  };
208
+ // Several props in one change (one undo step): `undefined` removes a prop.
209
+ const setFields = (patch) => {
210
+ const next = { ...record };
211
+ for (const [name, value] of Object.entries(patch)) {
212
+ if (value === undefined)
213
+ delete next[name];
214
+ else
215
+ next[name] = value;
216
+ }
217
+ onChange(Object.keys(next).length > 0 ? next : undefined);
218
+ };
178
219
  const out = [];
179
220
  fields.forEach((field, index) => {
180
221
  if (!isFieldVisible(field, record, scope))
@@ -219,7 +260,12 @@ export function RenderBlockFields({ fields, data, path, onChange, scope = fields
219
260
  if (!access.read)
220
261
  return;
221
262
  const onFieldChange = (value) => setField(name, value, field);
222
- out.push(_jsxs("div", { "data-builder-field": fieldPath, style: { display: 'contents' }, children: [_jsx(FieldAccessFrame, { locked: !access.update, children: _jsx(LocaleFieldFrame, { path: fieldPath, name: name, children: _jsx(FieldSlot, { field: field, path: fieldPath, value: record[name], onChange: onFieldChange, label: fieldLabel(field), children: _jsx(RenderBlockField, { field: field, path: fieldPath, value: record[name], onChange: onFieldChange, siblings: record }) }) }) }), _jsx(PeerFieldNote, { fieldPath: fieldPath }), _jsx(FieldProblem, { path: fieldPath })] }, name));
263
+ // `admin.custom.builderHeading`: a small heading above the field starts a group of fields.
264
+ const heading = text(field.admin?.custom?.builderHeading);
265
+ if (heading) {
266
+ out.push(_jsx("h4", { className: "builder-field-heading", children: heading }, `heading-${name}`));
267
+ }
268
+ out.push(_jsxs("div", { "data-builder-field": fieldPath, style: { display: 'contents' }, children: [_jsx(FieldAccessFrame, { locked: !access.update, children: _jsx(LocaleFieldFrame, { path: fieldPath, name: name, children: _jsx(FieldSlot, { field: field, path: fieldPath, value: record[name], onChange: onFieldChange, label: fieldLabel(field), children: _jsx(RenderBlockField, { field: field, path: fieldPath, value: record[name], onChange: onFieldChange, siblings: record, onSiblingsChange: setFields }) }) }) }), _jsx(PeerFieldNote, { fieldPath: fieldPath }), _jsx(FieldProblem, { path: fieldPath })] }, name));
223
269
  });
224
270
  return _jsx(_Fragment, { children: out });
225
271
  }
@@ -245,10 +291,14 @@ export function BlockContentFields({ block }) {
245
291
  const field = focusedField(runtime);
246
292
  useEffect(() => () => field.set(null), [field]);
247
293
  const def = getBlockDefinition(runtime.config.blocks, block.type);
294
+ // Content mode: only text, images and links, without bindings or visibility.
295
+ const contentMode = useContentMode(runtime);
248
296
  if (!def)
249
297
  return _jsxs("p", { className: "builder-editor__hint", children: ["Unknown block type \u201C", block.type, "\u201D."] });
250
- if (def.fields.length === 0)
251
- return _jsx("p", { className: "builder-editor__hint", children: "This block has no content fields." });
298
+ const fields = contentMode ? contentModeFields(def, block) : def.fields;
299
+ if (fields.length === 0) {
300
+ return _jsx("p", { className: "builder-editor__hint", children: contentMode ? 'Nothing to edit in this block. Pick a text, image or link inside it.' : 'This block has no content fields.' });
301
+ }
252
302
  const handleChange = (next) => {
253
303
  const after = next ?? {};
254
304
  const changed = Object.keys(after).filter((key) => after[key] !== props[key]);
@@ -292,5 +342,6 @@ export function BlockContentFields({ block }) {
292
342
  else
293
343
  runtime.store.redo();
294
344
  };
295
- return (_jsx("div", { className: "builder-editor__fields", onFocus: onFocus, onBlur: onBlur, onKeyDown: onUndoKeys, children: _jsx(BindingScopeProvider, { block: block, prefix: `builder.${block.id}.`, children: _jsx(FieldProblemsProvider, { block: block, children: _jsx(LocaleFieldsProvider, { block: block, children: _jsxs(FieldAccessProvider, { block: block, prefix: `builder.${block.id}.`, children: [_jsx(RenderBlockFields, { fields: def.fields, data: props, path: `builder.${block.id}`, onChange: handleChange }), _jsx(HiddenFieldsNote, { block: block })] }) }) }) }) }));
345
+ const fieldList = (_jsx(FieldProblemsProvider, { block: block, children: _jsx(LocaleFieldsProvider, { block: block, children: _jsxs(FieldAccessProvider, { block: block, prefix: `builder.${block.id}.`, children: [_jsx(RenderBlockFields, { fields: fields, scope: def.fields, data: props, path: `builder.${block.id}`, onChange: handleChange }), _jsx(HiddenFieldsNote, { block: block })] }) }) }));
346
+ return (_jsx("div", { className: "builder-editor__fields", onFocus: onFocus, onBlur: onBlur, onKeyDown: onUndoKeys, children: contentMode ? (fieldList) : (_jsxs(BindingScopeProvider, { block: block, prefix: `builder.${block.id}.`, children: [fieldList, _jsx(VisibilityField, { block: block })] })) }));
296
347
  }
@@ -14,6 +14,8 @@ import { type ThumbnailService } from './sections/thumbnails.js';
14
14
  import type { CollaboratorCursor, LiveState, Peer, PeerCursor } from './live/index.js';
15
15
  import { type TemplateState } from './templates/state.js';
16
16
  import { type RegionsController } from './regions/controller.js';
17
+ import { type ClassesController } from './classes/controller.js';
18
+ import { type CommentsController } from './comments/controller.js';
17
19
  export declare const OUTLINE_INDENT = 16;
18
20
  /** `data` attached to every dnd-kit draggable (canvas handle, outline row, library item, section card). */
19
21
  export type DragData = {
@@ -46,6 +48,13 @@ export type FrameSize = {
46
48
  export type InspectorTab = 'block' | 'assistant';
47
49
  export type Runtime = {
48
50
  config: BuilderClientConfig;
51
+ /** The user may change the design (`editor.canEditDesign` on the server). False: always content mode. */
52
+ canEditDesign: boolean;
53
+ /**
54
+ * Content mode (core/contentMode.ts): only text, images and links change. True for users without
55
+ * design rights, and while a designer uses "Preview as client".
56
+ */
57
+ contentMode: ValueStore<boolean>;
49
58
  /** Sent to the iframe on every `ready`. */
50
59
  canvasInit: CanvasInit;
51
60
  store: EditorStore;
@@ -104,6 +113,10 @@ export type Runtime = {
104
113
  insertSpot: ValueStore<InsertSpot | null>;
105
114
  /** Saved sections and the section dialog. */
106
115
  sections: SectionsController;
116
+ /** Editable classes: the list, usage, the class the Styles panel edits, writes. Null when turned off. */
117
+ classes: ClassesController | null;
118
+ /** Comments on the canvas: the list, comment mode, the pin being placed. Null when turned off. */
119
+ comments: CommentsController | null;
107
120
  /** Real thumbnails of sections for the library. */
108
121
  thumbnails: ThumbnailService;
109
122
  /** Payload's REST route, e.g. "/api". */
@@ -127,6 +140,7 @@ export type Runtime = {
127
140
  */
128
141
  export declare function createRuntime(config: BuilderClientConfig, api: string, document: BuilderDocMeta, options?: {
129
142
  locale?: string | null;
143
+ canEditDesign?: boolean;
130
144
  }): Runtime;
131
145
  export declare const RuntimeContext: import("react").Context<Runtime | null>;
132
146
  export declare function useRuntime(): Runtime;
@@ -1,7 +1,8 @@
1
1
  'use client';
2
2
  import { createContext, createRef, use } from 'react';
3
- import { canvasDropTarget, createId, EMPTY_LAYOUT, findBlock, getBlockDefinition, outlineDropTarget, starterSlots, withFieldDefaults, } from '../../core/index.js';
3
+ import { canvasDropTarget, createId, EMPTY_LAYOUT, findBlock, getBlockDefinition, outlineDropTarget, starterSlots, withDefaultClasses, withFieldDefaults, } from '../../core/index.js';
4
4
  import { post, rectContains } from '../../protocol/index.js';
5
+ import { contentModeProblem } from '../../core/contentMode.js';
5
6
  import { removeBlock } from './actions.js';
6
7
  import { storageProblemOf } from './storage.js';
7
8
  import { createAssistant } from './assistant/controller.js';
@@ -14,6 +15,8 @@ import { createSectionsController } from './sections/controller.js';
14
15
  import { createThumbnailService } from './sections/thumbnails.js';
15
16
  import { initialTemplateState } from './templates/state.js';
16
17
  import { createRegionsController } from './regions/controller.js';
18
+ import { createClassesController } from './classes/controller.js';
19
+ import { createCommentsController } from './comments/controller.js';
17
20
  export const OUTLINE_INDENT = 16;
18
21
  const COLLAPSED_KEY = 'payload-builder:collapsed';
19
22
  function loadCollapsed() {
@@ -30,6 +33,7 @@ function loadCollapsed() {
30
33
  * `document` is the open document as the server loaded it.
31
34
  */
32
35
  export function createRuntime(config, api, document, options = {}) {
36
+ const canEditDesign = options.canEditDesign !== false;
33
37
  const storageProblem = storageProblemOf(config);
34
38
  const store = createEditorStore(EMPTY_LAYOUT, {
35
39
  ...(storageProblem ? { storageProblem } : {}),
@@ -74,9 +78,13 @@ export function createRuntime(config, api, document, options = {}) {
74
78
  document: { collection: document.collection, id: document.id },
75
79
  ...(config.regions?.length ? { regions: config.regions } : {}),
76
80
  ...(config.relations && Object.keys(config.relations).length > 0 ? { relations: config.relations } : {}),
81
+ ...(config.classes ? { classesEndpoint: config.classes.endpoint } : {}),
82
+ ...(config.savedSections ? { savedSections: config.savedSections.collection } : {}),
77
83
  };
78
84
  const runtime = {
79
85
  config,
86
+ canEditDesign,
87
+ contentMode: createValueStore(!canEditDesign),
80
88
  canvasInit,
81
89
  store,
82
90
  measurement: createValueStore(null),
@@ -108,7 +116,11 @@ export function createRuntime(config, api, document, options = {}) {
108
116
  problemsRequest.set(Date.now());
109
117
  return problemSummary(list) || null;
110
118
  },
111
- onPublished: () => problems.set([]),
119
+ onPublished: () => {
120
+ problems.set([]);
121
+ // Publishing the page published its classes with unpublished changes.
122
+ void runtime.classes?.load();
123
+ },
112
124
  // The settings drawer, a region or a rename saved a field: its old problem is gone.
113
125
  onFieldsSaved: (fields) => problems.set(withoutSavedFields(problems.get(), fields)),
114
126
  }, document),
@@ -116,6 +128,8 @@ export function createRuntime(config, api, document, options = {}) {
116
128
  problemsRequest,
117
129
  assistant: null,
118
130
  regions: null,
131
+ classes: null,
132
+ comments: null,
119
133
  assistantFlash: createValueStore(new Map()),
120
134
  assistantFocus: createValueStore(0),
121
135
  toggleAssistant(open) {
@@ -152,6 +166,8 @@ export function createRuntime(config, api, document, options = {}) {
152
166
  runtime.help.set(false);
153
167
  else if (runtime.follow.get())
154
168
  runtime.follow.set(null);
169
+ else if (runtime.comments && closeComment(runtime.comments))
170
+ return;
155
171
  else if (runtime.regions?.selected.get())
156
172
  runtime.regions.selected.set(null);
157
173
  else
@@ -172,15 +188,13 @@ export function createRuntime(config, api, document, options = {}) {
172
188
  const def = getBlockDefinition(config.blocks, type);
173
189
  if (!def)
174
190
  return null;
175
- const block = { id: createId(), type };
191
+ // A Payload blocks field stores no classes: a new block there starts without them.
192
+ const block = config.storage === 'payload-blocks' ? { id: createId(), type } : withDefaultClasses({ id: createId(), type }, def);
176
193
  // Field defaults that are plain data, inside groups, rows and tabs too (function defaults
177
194
  // were stripped from the client config). From now on the block stores its own values.
178
195
  const props = withFieldDefaults({}, def.fields);
179
196
  if (Object.keys(props).length > 0)
180
197
  block.props = props;
181
- // A Payload blocks field stores no classes: a new block there starts without them.
182
- if (def.defaultClassName && config.storage !== 'payload-blocks')
183
- block.className = def.defaultClassName;
184
198
  // A new list starts with one list item (see `starterSlots`).
185
199
  const slots = starterSlots(config.blocks, type, createId);
186
200
  if (slots)
@@ -190,6 +204,15 @@ export function createRuntime(config, api, document, options = {}) {
190
204
  },
191
205
  };
192
206
  store.onWarning((text) => runtime.warn(text));
207
+ // Content mode refuses design edits in the editor already, with the server's own rule.
208
+ const guardContent = () => {
209
+ const on = runtime.contentMode.get();
210
+ store.setEditGuard(on ? (before, after) => contentModeProblem(before, after, config.blocks) : null);
211
+ if (on)
212
+ runtime.insertSpot.set(null);
213
+ };
214
+ guardContent();
215
+ runtime.contentMode.subscribe(guardContent);
193
216
  // The first edit of blocks, classes or shared props in another locale says that it changes every language.
194
217
  let sharedNoted = false;
195
218
  store.onSharedEdit(() => {
@@ -200,6 +223,20 @@ export function createRuntime(config, api, document, options = {}) {
200
223
  });
201
224
  if (config.ai)
202
225
  runtime.assistant = createAssistant(runtime, config.ai.endpoint);
226
+ if (config.classes) {
227
+ runtime.classes = createClassesController(config.classes, api, store);
228
+ if (typeof window !== 'undefined')
229
+ void runtime.classes.load();
230
+ }
231
+ if (config.comments) {
232
+ runtime.comments = createCommentsController({
233
+ api,
234
+ config: config.comments,
235
+ document: { collection: document.collection, id: document.id },
236
+ warn: (text) => runtime.warn(text),
237
+ notify: (text) => runtime.notify(text),
238
+ });
239
+ }
203
240
  if (config.regions?.length) {
204
241
  const regions = createRegionsController({
205
242
  regions: config.regions,
@@ -212,6 +249,18 @@ export function createRuntime(config, api, document, options = {}) {
212
249
  });
213
250
  runtime.regions = regions;
214
251
  store.setFieldWriter((changes, locale) => regions.writeEdits(changes, locale));
252
+ // Content mode does not edit the page's fixed regions.
253
+ const leaveRegions = () => {
254
+ if (!runtime.contentMode.get())
255
+ return;
256
+ if (regions.selected.get())
257
+ regions.selected.set(null);
258
+ if (regions.hovered.get())
259
+ regions.hovered.set(null);
260
+ };
261
+ regions.selected.subscribe(leaveRegions);
262
+ regions.hovered.subscribe(leaveRegions);
263
+ runtime.contentMode.subscribe(leaveRegions);
215
264
  // A selected block and a selected region exclude each other.
216
265
  store.subscribe(() => {
217
266
  if (store.getState().selectedId && regions.selected.get())
@@ -232,6 +281,18 @@ export function createRuntime(config, api, document, options = {}) {
232
281
  }
233
282
  return runtime;
234
283
  }
284
+ /** Escape in comment mode: closes the composer or the open thread, else leaves comment mode. False when it did nothing. */
285
+ function closeComment(comments) {
286
+ if (comments.draft.get() || comments.open.get()) {
287
+ comments.draft.set(null);
288
+ comments.open.set(null);
289
+ return true;
290
+ }
291
+ if (!comments.mode.get())
292
+ return false;
293
+ comments.toggle(false);
294
+ return true;
295
+ }
235
296
  export const RuntimeContext = createContext(null);
236
297
  export function useRuntime() {
237
298
  const runtime = use(RuntimeContext);
@@ -0,0 +1,8 @@
1
+ import type { Block } from '../../../core/types.js';
2
+ import './components.scss';
3
+ /** A copy of a component: its properties as fields, "Edit component" and the places that use it. */
4
+ export declare function ComponentValuesPanel({ block }: {
5
+ block: Block;
6
+ }): import("react").JSX.Element | null;
7
+ /** In a saved section with properties: it is a component, and how many places use it. */
8
+ export declare function ComponentBanner(): import("react").JSX.Element | null;
@@ -0,0 +1,116 @@
1
+ 'use client';
2
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ // Components in the inspector. On a copy (a `sectionRef` block): the component's properties as
4
+ // normal fields, "Edit component" and how many places use it. In a saved section with
5
+ // properties: a banner with the same count. The property buttons are in ./PropertyControls.tsx.
6
+ import { useConfig, useRouteTransition } from '@payloadcms/ui';
7
+ import { useRouter } from 'next/navigation';
8
+ import { useEffect, useMemo } from 'react';
9
+ import { SECTION_REF_VALUES, sectionRefId } from '../../../blocks/builtins/sectionRef.js';
10
+ import { componentProperties, componentValuesOf, fieldValue, storedValue, toPlainText, } from '../../../core/index.js';
11
+ import { useContentMode } from '../contentMode.js';
12
+ import { Icon } from '../icons.js';
13
+ import { editSectionPath } from '../Library.js';
14
+ import { RenderBlockFields } from '../renderField.js';
15
+ import { useRuntime } from '../runtime.js';
16
+ import { useValue } from '../valueStore.js';
17
+ import { editsSection, usedInText, useOwnProperties, useUsedIn } from './components.js';
18
+ import './components.scss';
19
+ /** The input of a property on a copy: the bound field, named after the property, never required. */
20
+ function propertyField(property) {
21
+ if (property.type === 'visible')
22
+ return { name: property.name, label: property.label, type: 'checkbox' };
23
+ const base = (property.field ?? { type: 'json' });
24
+ const { defaultValue: _default, required: _required, localized: _localized, validate: _validate, ...rest } = base;
25
+ const admin = { ...base.admin };
26
+ delete admin.condition;
27
+ delete admin.description;
28
+ if (admin.custom && typeof admin.custom === 'object') {
29
+ const { builderCondition: _condition, ...custom } = admin.custom;
30
+ admin.custom = custom;
31
+ }
32
+ if (property.type === 'text')
33
+ admin.placeholder = toPlainText(property.default) ?? '';
34
+ return { ...rest, name: property.name, label: property.label, admin };
35
+ }
36
+ /** What the property inputs show: the copy's values, and for "visible" the master's state. */
37
+ function inputData(properties, values) {
38
+ const data = {};
39
+ for (const property of properties) {
40
+ const value = property.type === 'visible' ? (values[property.name] ?? property.default) : fieldValue(property, values[property.name]);
41
+ if (value !== undefined)
42
+ data[property.name] = value;
43
+ }
44
+ return data;
45
+ }
46
+ /** The values a copy stores after an edit. A "visible" value equal to the master's is left out. */
47
+ function nextValues(properties, data) {
48
+ const values = {};
49
+ for (const property of properties) {
50
+ const value = storedValue(property, data?.[property.name]);
51
+ if (value === undefined || (property.type === 'visible' && value === property.default))
52
+ continue;
53
+ values[property.name] = value;
54
+ }
55
+ return values;
56
+ }
57
+ /** Opens a saved section in the full-screen builder. Back returns to this page. */
58
+ function useEditComponent(savedId) {
59
+ const runtime = useRuntime();
60
+ const router = useRouter();
61
+ const { startRouteTransition } = useRouteTransition();
62
+ const { config: { routes }, } = useConfig();
63
+ const collection = runtime.config.savedSections?.collection;
64
+ if (!collection || savedId === null)
65
+ return null;
66
+ return () => {
67
+ const href = editSectionPath(routes.admin, collection, savedId, `${window.location.pathname}${window.location.search}`);
68
+ startRouteTransition(() => router.push(href));
69
+ };
70
+ }
71
+ /** A copy of a component: its properties as fields, "Edit component" and the places that use it. */
72
+ export function ComponentValuesPanel({ block }) {
73
+ const runtime = useRuntime();
74
+ const saved = useValue(runtime.sections.saved);
75
+ useEffect(() => void runtime.sections.load(), [runtime.sections]);
76
+ const savedId = sectionRefId(block.props?.section);
77
+ const section = savedId === null ? undefined : saved?.find((s) => s.savedId !== undefined && String(s.savedId) === String(savedId));
78
+ const properties = useMemo(() => (section ? componentProperties(section.blocks, runtime.config.blocks) : []), [section, runtime.config.blocks]);
79
+ const usedIn = useUsedIn(runtime, section ? savedId : null);
80
+ // Content mode: a client fills in this copy's values; the component itself is design.
81
+ const contentMode = useContentMode(runtime);
82
+ const edit = useEditComponent(section && !contentMode ? savedId : null);
83
+ if (savedId === null)
84
+ return null;
85
+ if (saved === null)
86
+ return _jsx("p", { className: "builder-editor__hint", children: "Loading the component\u2026" });
87
+ if (!section) {
88
+ return (_jsxs("p", { className: "builder-comp__missing", children: [_jsx(Icon, { name: "warning", size: 14 }), " This component was deleted. Pick another one, or delete this block."] }));
89
+ }
90
+ const values = componentValuesOf(block.props);
91
+ const onChange = (data) => {
92
+ const next = nextValues(properties, data);
93
+ const changed = properties.filter((p) => JSON.stringify(next[p.name]) !== JSON.stringify(values[p.name]));
94
+ if (changed.length === 0)
95
+ return;
96
+ runtime.store.apply(Object.keys(next).length > 0
97
+ ? { type: 'update', id: block.id, props: { [SECTION_REF_VALUES]: next } }
98
+ : { type: 'update', id: block.id, unsetProps: [SECTION_REF_VALUES] },
99
+ // Typing in one field merges into one undo step.
100
+ changed.length === 1 ? { mergeKey: `component:${block.id}:${changed[0].name}` } : {});
101
+ };
102
+ const usedText = usedInText(usedIn);
103
+ return (_jsxs("section", { className: "builder-comp", "aria-label": `${section.label} properties`, children: [_jsxs("div", { className: "builder-comp__head", children: [_jsx(Icon, { name: "component", size: 14 }), _jsxs("div", { className: "builder-comp__title", children: [_jsx("span", { className: "builder-comp__name", children: section.label }), usedText && _jsx("span", { className: "builder-comp__meta", children: usedText })] }), edit && (_jsx("button", { type: "button", className: "builder-comp__edit", onClick: edit, children: "Edit component" }))] }), properties.length === 0 ? (_jsx("p", { className: "builder-editor__hint", children: "No properties yet. In the component, use the \u25C6 button next to a field to add one." })) : (_jsxs(_Fragment, { children: [_jsx(RenderBlockFields, { fields: properties.map(propertyField), data: inputData(properties, values), path: `builder.${block.id}.${SECTION_REF_VALUES}`, onChange: onChange }), _jsx("p", { className: "builder-editor__hint", children: "Empty fields show the content of the component." })] }))] }));
104
+ }
105
+ /** In a saved section with properties: it is a component, and how many places use it. */
106
+ export function ComponentBanner() {
107
+ const runtime = useRuntime();
108
+ const own = editsSection(runtime);
109
+ const properties = useOwnProperties(runtime);
110
+ const meta = useValue(runtime.doc.meta);
111
+ const usedIn = useUsedIn(runtime, own && properties.length > 0 ? meta.id : null);
112
+ if (!own || properties.length === 0)
113
+ return null;
114
+ const usedText = usedInText(usedIn);
115
+ return (_jsxs("div", { className: "builder-comp__banner", role: "note", children: [_jsx(Icon, { name: "component", size: 14 }), _jsxs("p", { children: [_jsx("strong", { children: "Component" }), " with ", properties.length, " ", properties.length === 1 ? 'property' : 'properties', usedText ? `. ${usedText}` : '', ". Changes show on every copy."] })] }));
116
+ }
@@ -0,0 +1,18 @@
1
+ import { type ReactNode } from 'react';
2
+ import type { Block } from '../../../core/types.js';
3
+ import './components.scss';
4
+ /**
5
+ * One content field of a block in a saved section: its input (the component's own value, the
6
+ * default every copy starts with) and the property button or chip. `bind`: the field's bind
7
+ * button, when it has one.
8
+ */
9
+ export declare function PropertySlot({ block, propPath, label, children }: {
10
+ block: Block;
11
+ propPath: string;
12
+ label: string;
13
+ children: ReactNode;
14
+ }): import("react").JSX.Element;
15
+ /** "Visible": a property that shows or hides the block in each copy. Saved sections only. */
16
+ export declare function VisibleProperty({ block }: {
17
+ block: Block;
18
+ }): import("react").JSX.Element | null;