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
@@ -1,7 +1,13 @@
1
- // The where builder's rows (field, operator, value) <-> a Payload `where` object. Pure, so it is
2
- // tested without React. Rows are AND-ed. A where the rows cannot show (`or`, nested groups,
3
- // object values, unknown operators) returns null from `whereRows`, and the field shows raw JSON.
4
- export const WHERE_OPERATORS = [
1
+ // The where builder's rows (field, operator, value) <-> a Payload `where` object, and the value
2
+ // parsing the condition rows share (ConditionRows.tsx). Pure, so it is tested without React.
3
+ // Rows in a group are AND-ed and groups are OR-ed: `{ or: [{ and: [...] }, ...] }`. The rows use
4
+ // the visibility operator names: Payload's `exists: true` / `exists: false` are "is set" and
5
+ // "is empty". A where the rows cannot show (nested groups, an `or` next to fields, object
6
+ // values, unknown operators) returns null from `whereGroups`, and the field shows raw JSON, so
7
+ // no part of a stored where is ever lost.
8
+ import { pageTokenPath, queryTokenParam } from '../../../core/whereValues.js';
9
+ /** Payload where operators the rows show (with `exists` as is_set / is_empty). */
10
+ const ROW_OPERATORS = new Set([
5
11
  'equals',
6
12
  'not_equals',
7
13
  'in',
@@ -12,17 +18,21 @@ export const WHERE_OPERATORS = [
12
18
  'less_than_equal',
13
19
  'like',
14
20
  'contains',
15
- 'exists',
16
- ];
21
+ ]);
17
22
  const isRecord = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
18
23
  const isScalar = (value) => typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean';
19
- const isOperator = (value) => WHERE_OPERATORS.includes(value);
20
- function fitsOperator(operator, value) {
24
+ /** A value read when the query runs (`$page.<path>`, `$query.<param>`): a list for in/not_in too. */
25
+ const isListToken = (value) => pageTokenPath(value) !== null || queryTokenParam(value) !== null;
26
+ /** The row of one `{ op: value }` entry, or null when the rows cannot show it. */
27
+ function rowOf(field, operator, value) {
21
28
  if (operator === 'exists')
22
- return typeof value === 'boolean';
23
- if (operator === 'in' || operator === 'not_in')
24
- return Array.isArray(value) && value.every(isScalar);
25
- return isScalar(value);
29
+ return typeof value === 'boolean' ? { field, operator: value ? 'is_set' : 'is_empty', value: undefined } : null;
30
+ if (!ROW_OPERATORS.has(operator))
31
+ return null;
32
+ if (operator === 'in' || operator === 'not_in') {
33
+ return (Array.isArray(value) && value.every(isScalar)) || isListToken(value) ? { field, operator, value } : null;
34
+ }
35
+ return isScalar(value) ? { field, operator, value } : null;
26
36
  }
27
37
  /** The rows of `{ field: { op: value } }` (several fields and operators allowed). Null when it does not fit. */
28
38
  function rowsOf(where) {
@@ -34,42 +44,73 @@ function rowsOf(where) {
34
44
  if (entries.length === 0)
35
45
  return null;
36
46
  for (const [operator, value] of entries) {
37
- if (!isOperator(operator) || !fitsOperator(operator, value))
47
+ const row = rowOf(field, operator, value);
48
+ if (!row)
38
49
  return null;
39
- rows.push({ field, operator, value });
50
+ rows.push(row);
40
51
  }
41
52
  }
42
53
  return rows;
43
54
  }
55
+ /** The rows of one AND group: `{ a: …, b: … }` or `{ and: [ { a: … }, … ] }`. Null when it does not fit. */
56
+ function groupRows(where) {
57
+ const keys = Object.keys(where);
58
+ if (keys.length !== 1 || keys[0] !== 'and')
59
+ return rowsOf(where);
60
+ if (!Array.isArray(where.and))
61
+ return null;
62
+ const rows = [];
63
+ for (const part of where.and) {
64
+ if (!isRecord(part))
65
+ return null;
66
+ const partRows = rowsOf(part);
67
+ if (!partRows)
68
+ return null;
69
+ rows.push(...partRows);
70
+ }
71
+ return rows;
72
+ }
44
73
  /**
45
- * The rows of a stored where: empty for no where, null when the builder cannot show it. Takes
46
- * `{ a: { equals: 1 }, b: { … } }` and `{ and: [ { a: { equals: 1 } }, … ] }`.
74
+ * The groups of a stored where: none for no where, null when the builder cannot show it. Takes
75
+ * one group (`{ a: { equals: 1 }, b: … }` or `{ and: [...] }`) or `{ or: [group, …] }`.
47
76
  */
48
- export function whereRows(where) {
77
+ export function whereGroups(where) {
49
78
  if (where === undefined || where === null)
50
79
  return [];
51
80
  if (!isRecord(where))
52
81
  return null;
53
82
  const keys = Object.keys(where);
54
- if (keys.length === 1 && keys[0] === 'and') {
55
- if (!Array.isArray(where.and))
83
+ if (keys.length === 1 && keys[0] === 'or') {
84
+ if (!Array.isArray(where.or) || where.or.length === 0)
56
85
  return null;
57
- const rows = [];
58
- for (const part of where.and) {
86
+ const groups = [];
87
+ for (const part of where.or) {
59
88
  if (!isRecord(part))
60
89
  return null;
61
- const partRows = rowsOf(part);
62
- if (!partRows)
90
+ const rows = groupRows(part);
91
+ // An empty part matches every document: the rows have no way to show that.
92
+ if (!rows || rows.length === 0)
63
93
  return null;
64
- rows.push(...partRows);
94
+ groups.push(rows);
65
95
  }
66
- return rows;
96
+ return groups;
67
97
  }
68
- return rowsOf(where);
98
+ const rows = groupRows(where);
99
+ if (!rows)
100
+ return null;
101
+ return rows.length > 0 ? [rows] : [];
102
+ }
103
+ /** The stored `{ op: value }` of a row: is_set and is_empty become `exists`. */
104
+ function entryOf(row) {
105
+ if (row.operator === 'is_set')
106
+ return ['exists', true];
107
+ if (row.operator === 'is_empty')
108
+ return ['exists', false];
109
+ return [row.operator, row.value];
69
110
  }
70
111
  /**
71
- * The where of the rows: one object `{ field: { op: value } }`, or `{ and: [...] }` when a field
72
- * has the same operator twice. Rows without a field are left out. `undefined` for no rows.
112
+ * The where of one group: one object `{ field: { op: value } }`, or `{ and: [...] }` when a
113
+ * field has the same operator twice. Rows without a field are left out. `undefined` for no rows.
73
114
  */
74
115
  export function rowsWhere(rows) {
75
116
  const complete = rows.filter((row) => row.field.trim());
@@ -79,21 +120,31 @@ export function rowsWhere(rows) {
79
120
  for (const row of complete) {
80
121
  const field = row.field.trim();
81
122
  const condition = (flat[field] ??= {});
82
- if (row.operator in condition) {
83
- return { and: complete.map((r) => ({ [r.field.trim()]: { [r.operator]: r.value } })) };
123
+ const [operator, value] = entryOf(row);
124
+ if (operator in condition) {
125
+ return { and: complete.map((r) => ({ [r.field.trim()]: Object.fromEntries([entryOf(r)]) })) };
84
126
  }
85
- condition[row.operator] = row.value;
127
+ condition[operator] = value;
86
128
  }
87
129
  return flat;
88
130
  }
131
+ /** The where of the groups: one group as `rowsWhere`, several as `{ or: [...] }`. Empty groups are left out. */
132
+ export function groupsWhere(groups) {
133
+ const wheres = groups.map(rowsWhere).filter((where) => where !== undefined);
134
+ if (wheres.length === 0)
135
+ return undefined;
136
+ return wheres.length === 1 ? wheres[0] : { or: wheres };
137
+ }
89
138
  /** The text a value shows in the value input: lists as "a, b". */
90
139
  export const whereValueText = (value) => Array.isArray(value) ? value.map(String).join(', ') : value === undefined || value === null ? '' : String(value);
91
140
  /**
92
141
  * The value to store for typed text. `fieldType` is the Payload field type when known: numbers
93
142
  * become numbers and checkboxes booleans; any other text stays text (so "0412" stays a string).
94
- * `in` and `not_in` split on commas. `exists` takes "true" or "false".
143
+ * `in` and `not_in` split on commas. `is_set` and `is_empty` take no value.
95
144
  */
96
145
  export function parseWhereValue(text, operator, fieldType) {
146
+ if (operator === 'is_set' || operator === 'is_empty')
147
+ return undefined;
97
148
  if (operator === 'exists')
98
149
  return text.trim() !== 'false';
99
150
  const one = (part) => {
@@ -114,5 +165,3 @@ export function parseWhereValue(text, operator, fieldType) {
114
165
  }
115
166
  return one(text);
116
167
  }
117
- /** The value a row keeps when its operator changes: re-read from its text for the new operator. */
118
- export const convertWhereValue = (row, operator, fieldType) => parseWhereValue(operator === 'exists' ? 'true' : whereValueText(row.value), operator, fieldType);
@@ -10,12 +10,25 @@ declare const PATHS: {
10
10
  list: import("react").JSX.Element;
11
11
  quote: import("react").JSX.Element;
12
12
  divider: import("react").JSX.Element;
13
- spacer: import("react").JSX.Element;
14
13
  video: import("react").JSX.Element;
15
14
  form: import("react").JSX.Element;
16
15
  block: import("react").JSX.Element;
17
16
  section: import("react").JSX.Element;
18
17
  layers: import("react").JSX.Element;
18
+ icon: import("react").JSX.Element;
19
+ carousel: import("react").JSX.Element;
20
+ embed: import("react").JSX.Element;
21
+ popup: import("react").JSX.Element;
22
+ tabs: import("react").JSX.Element;
23
+ tab: import("react").JSX.Element;
24
+ marquee: import("react").JSX.Element;
25
+ adjacentLinks: import("react").JSX.Element;
26
+ accordion: import("react").JSX.Element;
27
+ disclosure: import("react").JSX.Element;
28
+ tableOfContents: import("react").JSX.Element;
29
+ filter: import("react").JSX.Element;
30
+ sectionRef: import("react").JSX.Element;
31
+ component: import("react").JSX.Element;
19
32
  field: import("react").JSX.Element;
20
33
  collectionList: import("react").JSX.Element;
21
34
  repeat: import("react").JSX.Element;
@@ -43,6 +56,7 @@ declare const PATHS: {
43
56
  tablet: import("react").JSX.Element;
44
57
  mobile: import("react").JSX.Element;
45
58
  width: import("react").JSX.Element;
59
+ chevronLeft: import("react").JSX.Element;
46
60
  chevronRight: import("react").JSX.Element;
47
61
  chevronDown: import("react").JSX.Element;
48
62
  search: import("react").JSX.Element;
@@ -64,6 +78,7 @@ declare const PATHS: {
64
78
  sparkle: import("react").JSX.Element;
65
79
  arrowUp: import("react").JSX.Element;
66
80
  stop: import("react").JSX.Element;
81
+ comment: import("react").JSX.Element;
67
82
  compose: import("react").JSX.Element;
68
83
  key: import("react").JSX.Element;
69
84
  external: import("react").JSX.Element;
@@ -14,12 +14,39 @@ const PATHS = {
14
14
  list: (_jsxs(_Fragment, { children: [dot(3, 4), dot(3, 8), dot(3, 12), _jsx("path", { d: "M6 4h8M6 8h8M6 12h8" })] })),
15
15
  quote: (_jsx("path", { d: "M2.5 7.5h3.5V12H2.5V7.5Zm0 0c0-2 .9-3.4 2.75-4M9.5 7.5H13V12H9.5V7.5Zm0 0c0-2 .9-3.4 2.75-4" })),
16
16
  divider: (_jsxs(_Fragment, { children: [_jsx("path", { d: "M1.5 8h13" }), _jsx("path", { d: "M4 4.5h8M4 11.5h8", opacity: 0.4 })] })),
17
- spacer: _jsx("path", { d: "M2.5 2.5h11M2.5 13.5h11M8 5.25v5.5M6.25 7 8 5.25 9.75 7M6.25 9 8 10.75 9.75 9" }),
18
17
  video: (_jsxs(_Fragment, { children: [_jsx("rect", { x: "1.5", y: "3", width: "13", height: "10", rx: "1.5" }), _jsx("path", { d: "M6.75 5.75v4.5L10.5 8 6.75 5.75Z" })] })),
19
18
  form: (_jsxs(_Fragment, { children: [_jsx("rect", { x: "2", y: "2", width: "12", height: "3.5", rx: "1" }), _jsx("rect", { x: "2", y: "7", width: "12", height: "3.5", rx: "1" }), _jsx("path", { d: "M2.5 13.5h4" })] })),
20
19
  block: (_jsxs(_Fragment, { children: [_jsx("rect", { x: "2.5", y: "2.5", width: "11", height: "11", rx: "2" }), _jsx("path", { d: "M2.5 6.5h11" })] })),
21
20
  section: (_jsxs(_Fragment, { children: [_jsx("rect", { x: "2", y: "2", width: "12", height: "4.5", rx: "1" }), _jsx("rect", { x: "2", y: "8.5", width: "5", height: "5.5", rx: "1" }), _jsx("rect", { x: "9", y: "8.5", width: "5", height: "5.5", rx: "1" })] })),
22
21
  layers: _jsx("path", { d: "m8 2 6 3-6 3-6-3 6-3ZM2 8l6 3 6-3M2 11l6 3 6-3" }),
22
+ // Built-in blocks (`builtinBlocks()` and the plugin's sectionRef)
23
+ // A star: one glyph of the site's icon set.
24
+ icon: _jsx("path", { d: "m8 2 1.76 3.57 3.94.57-2.85 2.78.67 3.92L8 11l-3.52 1.84.67-3.92L2.3 6.14l3.94-.57L8 2Z" }),
25
+ // The current slide with the edges of its neighbours, and dots.
26
+ carousel: (_jsxs(_Fragment, { children: [_jsx("rect", { x: "4", y: "2.5", width: "8", height: "8", rx: "1" }), _jsx("path", { d: "M1.5 4v5M14.5 4v5" }), dot(6, 13.25, 0.75), dot(8, 13.25, 0.75), dot(10, 13.25, 0.75)] })),
27
+ // Angle brackets around a slash: custom code.
28
+ embed: _jsx("path", { d: "M5 4.5 1.75 8 5 11.5M11 4.5 14.25 8 11 11.5M9.25 3l-2.5 10" }),
29
+ // A panel with a close mark, over the page.
30
+ popup: (_jsxs(_Fragment, { children: [_jsx("rect", { x: "1.5", y: "2.5", width: "13", height: "11", rx: "1.5", opacity: 0.45 }), _jsx("rect", { x: "3.5", y: "4.5", width: "9", height: "7", rx: "1" }), _jsx("path", { d: "m9.25 6.25 1.5 1.5M10.75 6.25l-1.5 1.5M5.25 9.5h3" })] })),
31
+ // A row of tabs, the first one open, over its panel.
32
+ tabs: (_jsxs(_Fragment, { children: [_jsx("path", { d: "M1.5 13.5v-9a1 1 0 0 1 1-1h3.5a1 1 0 0 1 1 1V6h6.5a1 1 0 0 1 1 1v5.5a1 1 0 0 1-1 1h-11Z" }), _jsx("path", { d: "M7 6V4.5a1 1 0 0 1 1-1h2.5a1 1 0 0 1 1 1V6", opacity: 0.45 })] })),
33
+ // One tab and its panel.
34
+ tab: (_jsxs(_Fragment, { children: [_jsx("path", { d: "M2.5 6.5v-2a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2" }), _jsx("rect", { x: "1.5", y: "6.5", width: "13", height: "7", rx: "1" }), _jsx("path", { d: "M4 9.5h6", opacity: 0.45 })] })),
35
+ // Items in a row that move along.
36
+ marquee: (_jsxs(_Fragment, { children: [_jsx("rect", { x: "1.5", y: "4", width: "3.5", height: "4.5", rx: "0.75" }), _jsx("rect", { x: "6.25", y: "4", width: "3.5", height: "4.5", rx: "0.75" }), _jsx("rect", { x: "11", y: "4", width: "3.5", height: "4.5", rx: "0.75", opacity: 0.45 }), _jsx("path", { d: "M2 12.25h11M11.25 10.75l1.75 1.5-1.75 1.5" })] })),
37
+ // Back and forward between two documents.
38
+ adjacentLinks: (_jsxs(_Fragment, { children: [_jsx("path", { d: "M5 4.5 1.75 8 5 11.5M11 4.5 14.25 8 11 11.5" }), _jsx("path", { d: "M2 8h4M10 8h4", opacity: 0.45 })] })),
39
+ // Rows, each with an arrow; the first is open.
40
+ accordion: (_jsxs(_Fragment, { children: [_jsx("path", { d: "M2 3h12M2 9h12M2 13h12" }), _jsx("path", { d: "M4 5.75h6", opacity: 0.45 }), _jsx("path", { d: "m11.5 12 1 1 1-1" })] })),
41
+ // One row with an arrow, and its content below.
42
+ disclosure: (_jsxs(_Fragment, { children: [_jsx("rect", { x: "1.5", y: "2.5", width: "13", height: "4", rx: "1" }), _jsx("path", { d: "m10.5 4 1 1 1-1" }), _jsx("path", { d: "M3.5 9.5h9M3.5 12.5h6", opacity: 0.45 })] })),
43
+ // Lines, the second level indented.
44
+ tableOfContents: (_jsxs(_Fragment, { children: [dot(2.5, 4), dot(2.5, 12), _jsx("path", { d: "M5 4h9M7 8h7M5 12h9" })] })),
45
+ filter: _jsx("path", { d: "M2 3h12l-4.5 5.5V13l-3-1.5v-3L2 3Z" }),
46
+ // A section with a link mark: it shows the saved section live.
47
+ sectionRef: (_jsxs(_Fragment, { children: [_jsx("rect", { x: "2", y: "2", width: "12", height: "5", rx: "1" }), _jsx("path", { d: "M2 10h3M2 13h3", opacity: 0.45 }), _jsx("path", { d: "m9.5 11.5 2-2M10 9.25l.5-.5a1.25 1.25 0 0 1 1.75 1.75l-.5.5M11 13.75l-.5.5a1.25 1.25 0 0 1-1.75-1.75l.5-.5" })] })),
48
+ // Four diamonds: a component (a saved section with properties) and its properties.
49
+ component: _jsx("path", { d: "M8 1.75 10.25 4 8 6.25 5.75 4ZM12 5.75 14.25 8 12 10.25 9.75 8ZM8 9.75 10.25 12 8 14.25 5.75 12ZM4 5.75 6.25 8 4 10.25 1.75 8Z" }),
23
50
  // Dynamic blocks (templates and binding)
24
51
  field: (_jsxs(_Fragment, { children: [_jsx("path", { d: "M5.5 2.5H5A1.5 1.5 0 0 0 3.5 4v2.25L2.25 8 3.5 9.75V12A1.5 1.5 0 0 0 5 13.5h.5" }), _jsx("path", { d: "M10.5 2.5h.5A1.5 1.5 0 0 1 12.5 4v2.25L13.75 8 12.5 9.75V12a1.5 1.5 0 0 1-1.5 1.5h-.5" }), _jsx("path", { d: "M6.5 8h3" })] })),
25
52
  collectionList: (_jsxs(_Fragment, { children: [_jsx("rect", { x: "2", y: "2", width: "12", height: "5", rx: "1" }), _jsx("rect", { x: "2", y: "9", width: "12", height: "5", rx: "1", opacity: 0.45 }), _jsx("path", { d: "M4.5 4.5h4" }), _jsx("path", { d: "M4.5 11.5h4", opacity: 0.45 })] })),
@@ -51,6 +78,7 @@ const PATHS = {
51
78
  tablet: (_jsxs(_Fragment, { children: [_jsx("rect", { x: "3", y: "1.5", width: "10", height: "13", rx: "1.5" }), _jsx("path", { d: "M7 12h2" })] })),
52
79
  mobile: (_jsxs(_Fragment, { children: [_jsx("rect", { x: "4.5", y: "1.5", width: "7", height: "13", rx: "1.5" }), _jsx("path", { d: "M7.25 12h1.5" })] })),
53
80
  width: _jsx("path", { d: "M1.5 3v10M14.5 3v10M4 8h8M6 6 4 8l2 2M10 6l2 2-2 2" }),
81
+ chevronLeft: _jsx("path", { d: "m10 4-4 4 4 4" }),
54
82
  chevronRight: _jsx("path", { d: "m6 4 4 4-4 4" }),
55
83
  chevronDown: _jsx("path", { d: "m4 6 4 4 4-4" }),
56
84
  search: (_jsxs(_Fragment, { children: [_jsx("circle", { cx: "7", cy: "7", r: "4.5" }), _jsx("path", { d: "m10.5 10.5 3 3" })] })),
@@ -73,6 +101,7 @@ const PATHS = {
73
101
  // Assistant
74
102
  arrowUp: _jsx("path", { d: "M8 13V3.5M4 7.5l4-4 4 4" }),
75
103
  stop: _jsx("rect", { x: "4", y: "4", width: "8", height: "8", rx: "1.5", fill: "currentColor" }),
104
+ comment: _jsx("path", { d: "M5 11.5H4A1.5 1.5 0 0 1 2.5 10V4A1.5 1.5 0 0 1 4 2.5h8A1.5 1.5 0 0 1 13.5 4v6a1.5 1.5 0 0 1-1.5 1.5H8.5L5 14v-2.5Z" }),
76
105
  compose: _jsx("path", { d: "M13.5 9v3.5a1.5 1.5 0 0 1-1.5 1.5H3.5A1.5 1.5 0 0 1 2 12.5V4a1.5 1.5 0 0 1 1.5-1.5H7M11.25 2.25a1.4 1.4 0 0 1 2 2L8 9.5 5.5 10.5l1-2.5 4.75-5.75Z" }),
77
106
  key: (_jsxs(_Fragment, { children: [_jsx("circle", { cx: "5.5", cy: "10.5", r: "3" }), _jsx("path", { d: "m7.6 8.4 5.9-5.9M11.5 4.5l1.5 1.5M10 6l1.25 1.25" })] })),
78
107
  external: _jsx("path", { d: "M9.5 2.5h4v4M13.5 2.5 8 8M12 9.5V12a1.5 1.5 0 0 1-1.5 1.5H4A1.5 1.5 0 0 1 2.5 12V5.5A1.5 1.5 0 0 1 4 4h2.5" }),
@@ -116,8 +116,12 @@ export function startInlineEditing(runtime, id, offset) {
116
116
  runtime.iframeRef.current?.focus();
117
117
  runtime.postToCanvas({ type: 'inlineStart', id, ...(offset === undefined ? {} : { offset }) });
118
118
  }
119
+ /** True in content mode. Test runtimes may leave the store out: then false. */
120
+ const inContentMode = (runtime) => runtime.contentMode?.get() === true;
119
121
  /** Starts inline editing of a region's first text field (Enter on a selected region). */
120
122
  export function startRegionEditing(runtime, region) {
123
+ if (inContentMode(runtime))
124
+ return;
121
125
  runtime.iframeRef.current?.focus();
122
126
  runtime.postToCanvas({ type: 'inlineStart', id: '', region });
123
127
  }
@@ -128,6 +132,11 @@ export function endRegionInline(runtime, message) {
128
132
  drafts.delete(message.session);
129
133
  if (!draft?.changed || !runtime.regions)
130
134
  return;
135
+ // Content mode does not edit the page's fixed regions (the frame shows the saved value again).
136
+ if (inContentMode(runtime)) {
137
+ runtime.postToCanvas({ type: 'frameRefresh' });
138
+ return;
139
+ }
131
140
  void runtime.regions.write([{ path: draft.path, value: draft.value, base: draft.base }], { locale: draft.locale });
132
141
  }
133
142
  /**
@@ -13,6 +13,7 @@ import { createPortal } from 'react-dom';
13
13
  import { currentPosition, insertBlocks, insertNewBlockAt } from '../actions.js';
14
14
  import { BlockIcon, Icon } from '../icons.js';
15
15
  import { inlineEditing } from '../inline.js';
16
+ import { useContentMode } from '../contentMode.js';
16
17
  import { useRuntime } from '../runtime.js';
17
18
  import { Popover, usePopover } from '../styles/popover.js';
18
19
  import { useValue, useValueSelector } from '../valueStore.js';
@@ -33,7 +34,9 @@ export const InsertHandle = memo(function InsertHandle() {
33
34
  // The spot the open picker inserts at.
34
35
  const [target, setTarget] = useState(null);
35
36
  const shown = picker.open && target ? target : (held ?? spot);
36
- const visible = Boolean(shown) && (picker.open || (!dragging && !locked && !editing));
37
+ // Content mode adds no blocks.
38
+ const contentMode = useContentMode(runtime);
39
+ const visible = Boolean(shown) && !contentMode && (picker.open || (!dragging && !locked && !editing));
37
40
  const active = picker.open || held !== null;
38
41
  // The editor root, outside the zoomed frame and the overlay.
39
42
  const host = useSyncExternalStore(noSubscription, editorRoot, noRoot);
@@ -25,7 +25,9 @@ export declare function matchScore(query: string, label: string, ...texts: (stri
25
25
  * The picker's items for a position: blocks first, then sections. Within each, the best name
26
26
  * matches come first; then blocks go by category and sections saved-first. A section fits when
27
27
  * each of its top-level blocks, with everything inside, may go into the slot, and the slot has room
28
- * for all of them (`max`).
28
+ * for all of them (`max`). A section with variants is one item: it inserts the section's own
29
+ * version (its root block remembers the section, so the canvas offers the other versions), and
30
+ * its hint counts the versions.
29
31
  */
30
32
  export declare function pickerItems(args: {
31
33
  blocks: BlockDefinition[];
@@ -1,6 +1,7 @@
1
1
  // What the canvas insert picker offers at a spot: the block types and sections that fit there
2
2
  // (slot `allow` / `disallow` / `max` rules), filtered by the search text. Pure: no DOM, no React.
3
3
  import { slotAcceptsAt, slotRoom } from '../../../core/blocks.js';
4
+ import { sectionVersion, sectionVersions } from '../../../core/sections.js';
4
5
  /** Block categories in library order. Others follow A–Z. */
5
6
  export const BLOCK_ORDER = ['Layout', 'Content', 'Media', 'Interactive', 'Dynamic'];
6
7
  /**
@@ -26,7 +27,9 @@ const rank = (category) => {
26
27
  * The picker's items for a position: blocks first, then sections. Within each, the best name
27
28
  * matches come first; then blocks go by category and sections saved-first. A section fits when
28
29
  * each of its top-level blocks, with everything inside, may go into the slot, and the slot has room
29
- * for all of them (`max`).
30
+ * for all of them (`max`). A section with variants is one item: it inserts the section's own
31
+ * version (its root block remembers the section, so the canvas offers the other versions), and
32
+ * its hint counts the versions.
30
33
  */
31
34
  export function pickerItems(args) {
32
35
  const { blocks, layout, parentId, slot, query } = args;
@@ -37,17 +40,21 @@ export function pickerItems(args) {
37
40
  .toSorted((a, b) => (a.score ?? 0) - (b.score ?? 0) || rank(a.def.category) - rank(b.def.category) || a.order - b.order)
38
41
  .map(({ def }) => ({ kind: 'block', id: `block:${def.type}`, label: def.label, hint: def.category, icon: def.icon ?? def.type, type: def.type }));
39
42
  const sectionItems = args.sections
40
- .map((s, order) => ({ s, order, score: matchScore(query, s.label, s.description, s.category, s.savedId === undefined ? undefined : 'saved') }))
43
+ .map((s, order) => ({ s, order, score: matchScore(query, s.label, s.description, s.category, s.savedId === undefined ? undefined : 'saved', ...(s.variants ?? []).map((v) => v.label)) }))
41
44
  .filter(({ s, score }) => score !== null && s.blocks.length > 0)
42
45
  .filter(({ s }) => s.blocks.length <= room && s.blocks.every((block) => slotAcceptsAt(blocks, layout, parentId, slot, block)))
43
46
  .toSorted((a, b) => (a.score ?? 0) - (b.score ?? 0) || Number(a.s.savedId === undefined) - Number(b.s.savedId === undefined) || a.order - b.order)
44
- .map(({ s }) => ({
45
- kind: 'section',
46
- id: `section:${s.id}`,
47
- label: s.label,
48
- hint: s.savedId === undefined ? s.category : s.category ? `Saved · ${s.category}` : 'Saved',
49
- icon: 'section',
50
- section: s,
51
- }));
47
+ .map(({ s }) => {
48
+ const count = sectionVersions(s).length;
49
+ const versions = count > 1 ? `${count} versions` : undefined;
50
+ return {
51
+ kind: 'section',
52
+ id: `section:${s.id}`,
53
+ label: s.label,
54
+ hint: s.savedId === undefined ? [s.category, versions].filter(Boolean).join(' · ') || undefined : s.category ? `Saved · ${s.category}` : 'Saved',
55
+ icon: 'section',
56
+ section: sectionVersion(s) ?? s,
57
+ };
58
+ });
52
59
  return [...blockItems, ...sectionItems];
53
60
  }
@@ -15,6 +15,8 @@ export type InsertSpot = {
15
15
  };
16
16
  /** Default edge band of a container: near its edge the spot is before or after the container itself. */
17
17
  export declare const EDGE_BAND = 12;
18
+ /** Size of the "+" button, in iframe pixels at zoom 1. */
19
+ export declare const INSERT_BUTTON = 20;
18
20
  export type InsertSpotOptions = {
19
21
  /** Width of a container's edge band, in iframe pixels. Default EDGE_BAND. */
20
22
  band?: number;
@@ -27,7 +29,14 @@ export type InsertSpotOptions = {
27
29
  id: string;
28
30
  tolerance: number;
29
31
  };
32
+ /** Size of the "+" button in iframe pixels (its screen size divided by the zoom). Default INSERT_BUTTON. */
33
+ button?: number;
30
34
  };
35
+ /**
36
+ * True when a block is too small for the "+" to sit beside it on `axis` without covering much of
37
+ * it: short along the axis (an icon in a row, a badge) and not wide across it.
38
+ */
39
+ export declare function tooSmallForInsert(rect: Rect, axis: Axis, button?: number): boolean;
31
40
  export declare function spotPosition(spot: Pick<InsertSpot, 'parentId' | 'slot' | 'index'>): Position;
32
41
  /** True when two spots put the "+" at the same place for the same position. */
33
42
  export declare function sameSpot(a: InsertSpot | null, b: InsertSpot | null): boolean;
@@ -38,6 +47,8 @@ export declare function sameSpot(a: InsertSpot | null, b: InsertSpot | null): bo
38
47
  * 3. In an empty slot of the block under the pointer: inside it.
39
48
  * 4. In a filled slot, between children: before/after the nearest child.
40
49
  * 5. Otherwise: before/after the block under the pointer, by the pointer's side of its center.
41
- * A spot whose list accepts no block type moves up to the parent block, and so on.
50
+ * A spot whose list accepts no block type moves up to the parent block, and so on. So does a
51
+ * spot beside a block too small for the "+" (`tooSmallForInsert`: an icon, a badge) and a spot
52
+ * whose "+" would cover much of a block: the "+" never takes the clicks of a small block.
42
53
  */
43
54
  export declare function insertSpotAt(layout: Layout, blocks: BlockDefinition[], measurement: CanvasMeasurement, p: Point, options?: InsertSpotOptions): InsertSpot | null;
@@ -2,6 +2,7 @@
2
2
  // empty slot. Pure: no DOM, no React. Coordinates are iframe viewport coordinates, like the
3
3
  // measurement. Slot rules count: a spot is offered only where at least one block type fits.
4
4
  import { deepestBlockAt } from '../../../core/dropTarget.js';
5
+ import { reachableAt } from '../../../core/layers.js';
5
6
  import { getBlockDefinition, placementError, slotNames } from '../../../core/blocks.js';
6
7
  import { DEFAULT_SLOT, indexLayout } from '../../../core/tree.js';
7
8
  /** Default edge band of a container: near its edge the spot is before or after the container itself. */
@@ -9,6 +10,40 @@ export const EDGE_BAND = 12;
9
10
  const LINE = 2;
10
11
  /** Height of the empty page's spot area. */
11
12
  const EMPTY_PAGE_HEIGHT = 120;
13
+ /** Size of the "+" button, in iframe pixels at zoom 1. */
14
+ export const INSERT_BUTTON = 20;
15
+ /**
16
+ * A block is too small for the "+" beside it when it is under this many button sizes along the
17
+ * list's axis (48 px at zoom 1)…
18
+ */
19
+ const MIN_ALONG = 2.4;
20
+ /** …and under this many across it (160 px). A one-line text across the page still gets the "+". */
21
+ const MIN_ACROSS = 8;
22
+ const along = (rect, axis) => (axis === 'x' ? rect.width : rect.height);
23
+ const across = (rect, axis) => (axis === 'x' ? rect.height : rect.width);
24
+ /**
25
+ * True when a block is too small for the "+" to sit beside it on `axis` without covering much of
26
+ * it: short along the axis (an icon in a row, a badge) and not wide across it.
27
+ */
28
+ export function tooSmallForInsert(rect, axis, button = INSERT_BUTTON) {
29
+ return along(rect, axis) < button * MIN_ALONG && across(rect, axis) < button * MIN_ACROSS;
30
+ }
31
+ /** The "+" may cover at most this share of a block, so the block stays easy to click. */
32
+ const MAX_COVER = 0.2;
33
+ /** True when a "+" centered at `at` would cover more than MAX_COVER of a block (an icon beside it). */
34
+ function coversBlock(at, rects, button) {
35
+ const half = button / 2;
36
+ for (const r of rects) {
37
+ const area = r.width * r.height;
38
+ if (area <= 0)
39
+ continue;
40
+ const w = Math.min(at.x + half, r.x + r.width) - Math.max(at.x - half, r.x);
41
+ const h = Math.min(at.y + half, r.y + r.height) - Math.max(at.y - half, r.y);
42
+ if (w > 0 && h > 0 && (w * h) / area > MAX_COVER)
43
+ return true;
44
+ }
45
+ return false;
46
+ }
12
47
  export function spotPosition(spot) {
13
48
  return { parentId: spot.parentId, slot: spot.slot, index: spot.index };
14
49
  }
@@ -52,11 +87,16 @@ function indexOf(layout) {
52
87
  * 3. In an empty slot of the block under the pointer: inside it.
53
88
  * 4. In a filled slot, between children: before/after the nearest child.
54
89
  * 5. Otherwise: before/after the block under the pointer, by the pointer's side of its center.
55
- * A spot whose list accepts no block type moves up to the parent block, and so on.
90
+ * A spot whose list accepts no block type moves up to the parent block, and so on. So does a
91
+ * spot beside a block too small for the "+" (`tooSmallForInsert`: an icon, a badge) and a spot
92
+ * whose "+" would cover much of a block: the "+" never takes the clicks of a small block.
56
93
  */
57
94
  export function insertSpotAt(layout, blocks, measurement, p, options = {}) {
95
+ // Over an open popup only its blocks count (see `reachableAt`).
96
+ measurement = reachableAt(measurement, p);
58
97
  const band = options.band ?? EDGE_BAND;
59
98
  const selected = options.selected;
99
+ const button = options.button ?? INSERT_BUTTON;
60
100
  // Set when the spot under the pointer is on the selected block's edge: no "+" at all then, not
61
101
  // one further away (the parent's edge).
62
102
  let onSelectedEdge = false;
@@ -78,6 +118,9 @@ export function insertSpotAt(layout, blocks, measurement, p, options = {}) {
78
118
  const own = rects.get(list[i]?.id ?? '');
79
119
  if (!own)
80
120
  return null;
121
+ // Too small for the "+" beside it: none here. The search goes on with the parent.
122
+ if (tooSmallForInsert(own, axis, button))
123
+ return null;
81
124
  // On the list's axis: the middle of the gap, or the edge when there is no neighbor.
82
125
  let pos = side === 'before' ? start(own, axis) : end(own, axis);
83
126
  if (prev && next)
@@ -96,15 +139,11 @@ export function insertSpotAt(layout, blocks, measurement, p, options = {}) {
96
139
  const rect = axis === 'y'
97
140
  ? { x: lo, y: pos - LINE / 2, width: hi - lo, height: LINE }
98
141
  : { x: pos - LINE / 2, y: lo, width: LINE, height: hi - lo };
99
- return {
100
- parentId: ownerId,
101
- slot,
102
- index: at,
103
- kind: 'between',
104
- axis,
105
- at: axis === 'y' ? { x: (lo + hi) / 2, y: pos } : { x: pos, y: (lo + hi) / 2 },
106
- rect,
107
- };
142
+ const point = axis === 'y' ? { x: (lo + hi) / 2, y: pos } : { x: pos, y: (lo + hi) / 2 };
143
+ // The button would take the clicks of a block under it (an icon beside the gap).
144
+ if (coversBlock(point, rects.values(), button))
145
+ return null;
146
+ return { parentId: ownerId, slot, index: at, kind: 'between', axis, at: point, rect };
108
147
  };
109
148
  /** Before or after `entry`, by the pointer's side of its center. Climbs up while a list accepts nothing. */
110
149
  const around = (entry) => {
@@ -10,6 +10,7 @@ import { Icon } from '../icons.js';
10
10
  import { Library } from '../Library.js';
11
11
  import { isMac } from '../menu/keys.js';
12
12
  import { Outline } from '../Outline.js';
13
+ import { leftTabsFor, useContentMode } from '../contentMode.js';
13
14
  import { useRuntime } from '../runtime.js';
14
15
  import { useValue } from '../valueStore.js';
15
16
  import { LEFT_TABS, leftPanelId, selectLeftTab } from './leftTabs.js';
@@ -21,7 +22,11 @@ export function LeftPanel() {
21
22
  const stored = useValue(runtime.leftTab);
22
23
  // Without a stored choice, an empty page starts in Blocks and a page with blocks in Layers.
23
24
  const [fallback] = useState(() => (runtime.store.getState().layout.blocks.length === 0 ? 'blocks' : 'layers'));
24
- const tab = stored ?? fallback;
25
+ // Content mode adds no blocks or sections: Layers only.
26
+ const contentMode = useContentMode(runtime);
27
+ const tabs = leftTabsFor(contentMode, LEFT_TABS);
28
+ const wanted = stored ?? fallback;
29
+ const tab = tabs.some(({ id }) => id === wanted) ? wanted : 'layers';
25
30
  // Panels render the first time they open, then stay mounted.
26
31
  const [opened, setOpened] = useState(() => new Set(['layers', tab]));
27
32
  if (!opened.has(tab))
@@ -88,19 +93,19 @@ export function LeftPanel() {
88
93
  }, [runtime]);
89
94
  // Arrow keys, Home and End move between the tabs (WAI-ARIA tabs with automatic activation).
90
95
  const onKeyDown = (e) => {
91
- const index = LEFT_TABS.findIndex((t) => t.id === tab);
92
- const last = LEFT_TABS.length - 1;
93
- const next = e.key === 'ArrowRight' ? (index + 1) % LEFT_TABS.length : e.key === 'ArrowLeft' ? (index + last) % LEFT_TABS.length : e.key === 'Home' ? 0 : e.key === 'End' ? last : null;
96
+ const index = tabs.findIndex((t) => t.id === tab);
97
+ const last = tabs.length - 1;
98
+ const next = e.key === 'ArrowRight' ? (index + 1) % tabs.length : e.key === 'ArrowLeft' ? (index + last) % tabs.length : e.key === 'Home' ? 0 : e.key === 'End' ? last : null;
94
99
  if (next === null)
95
100
  return;
96
101
  e.preventDefault();
97
102
  e.stopPropagation();
98
- const id = LEFT_TABS[next]?.id;
103
+ const id = tabs[next]?.id;
99
104
  if (!id)
100
105
  return;
101
106
  selectLeftTab(runtime, id);
102
107
  document.getElementById(tabId(id))?.focus();
103
108
  };
104
109
  const alt = isMac() ? '⌥' : 'Alt+';
105
- return (_jsxs(_Fragment, { children: [_jsx("div", { className: "builder-left__head", children: _jsx("div", { ref: tablistRef, className: "builder-editor__segmented builder-editor__segmented--full", role: "tablist", "aria-label": "Left panel", children: LEFT_TABS.map(({ id, label, icon, digit }) => (_jsxs("button", { id: tabId(id), type: "button", role: "tab", "data-tab": id, "aria-selected": tab === id, "aria-controls": leftPanelId(id), "aria-keyshortcuts": `Alt+${digit}`, tabIndex: tab === id ? 0 : -1, className: "builder-editor__segment", "data-tooltip": `${label} (${alt}${digit})`, onClick: () => selectLeftTab(runtime, id), onKeyDown: onKeyDown, children: [_jsx(Icon, { name: icon, size: 13 }), label, id === 'sections' && sectionCount > 0 && _jsx("span", { className: "builder-editor__segment-count", children: sectionCount })] }, id))) }) }), LEFT_TABS.map(({ id }) => (_jsx("div", { id: leftPanelId(id), role: "tabpanel", "aria-labelledby": tabId(id), className: "builder-left__panel", hidden: tab !== id, children: opened.has(id) && (id === 'layers' ? _jsx(Outline, {}) : _jsx(Library, { kind: id })) }, id)))] }));
110
+ return (_jsxs(_Fragment, { children: [_jsx("div", { className: "builder-left__head", children: _jsx("div", { ref: tablistRef, className: "builder-editor__segmented builder-editor__segmented--full", role: "tablist", "aria-label": "Left panel", children: tabs.map(({ id, label, icon, digit }) => (_jsxs("button", { id: tabId(id), type: "button", role: "tab", "data-tab": id, "aria-selected": tab === id, "aria-controls": leftPanelId(id), "aria-keyshortcuts": `Alt+${digit}`, tabIndex: tab === id ? 0 : -1, className: "builder-editor__segment", "data-tooltip": `${label} (${alt}${digit})`, onClick: () => selectLeftTab(runtime, id), onKeyDown: onKeyDown, children: [_jsx(Icon, { name: icon, size: 13 }), label, id === 'sections' && sectionCount > 0 && _jsx("span", { className: "builder-editor__segment-count", children: sectionCount })] }, id))) }) }), tabs.map(({ id }) => (_jsx("div", { id: leftPanelId(id), role: "tabpanel", "aria-labelledby": tabId(id), className: "builder-left__panel", hidden: tab !== id, children: opened.has(id) && (id === 'layers' ? _jsx(Outline, {}) : _jsx(Library, { kind: id })) }, id)))] }));
106
111
  }
@@ -346,9 +346,17 @@ export function useMultiplayer(runtime, { docId, highlightMs = 2500 }) {
346
346
  sendAwareness();
347
347
  };
348
348
  es.addEventListener('session', (e) => {
349
+ const data = parse(e);
350
+ if (!data)
351
+ return;
352
+ onSession(data);
353
+ // Comment events are not replayed: (re)load the list with every session.
354
+ void runtime.comments?.load();
355
+ });
356
+ es.addEventListener('comments', (e) => {
349
357
  const data = parse(e);
350
358
  if (data)
351
- onSession(data);
359
+ runtime.comments?.handleEvent(data);
352
360
  });
353
361
  es.addEventListener('commit', (e) => {
354
362
  const data = parse(e);