@plone/volto 18.0.0-alpha.2 → 18.0.0-alpha.4

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 (293) hide show
  1. package/.eslintrc +3 -3
  2. package/.prettierignore +8 -0
  3. package/.prettierrc +12 -0
  4. package/{packages/registry/.release-it.json → .release-it.json} +11 -6
  5. package/CHANGELOG.md +44 -4
  6. package/locales/ca/LC_MESSAGES/volto.po +1 -0
  7. package/locales/de/LC_MESSAGES/volto.po +1 -0
  8. package/locales/en/LC_MESSAGES/volto.po +1 -0
  9. package/locales/es/LC_MESSAGES/volto.po +1 -0
  10. package/locales/eu/LC_MESSAGES/volto.po +1 -0
  11. package/locales/fi/LC_MESSAGES/volto.po +1 -0
  12. package/locales/fr/LC_MESSAGES/volto.po +1 -0
  13. package/locales/it/LC_MESSAGES/volto.po +1 -0
  14. package/locales/ja/LC_MESSAGES/volto.po +1 -0
  15. package/locales/nl/LC_MESSAGES/volto.po +1 -0
  16. package/locales/pt/LC_MESSAGES/volto.po +1 -0
  17. package/locales/pt_BR/LC_MESSAGES/volto.po +1 -0
  18. package/locales/ro/LC_MESSAGES/volto.po +1 -0
  19. package/locales/volto.pot +2 -1
  20. package/locales/zh_CN/LC_MESSAGES/volto.po +1 -0
  21. package/package.json +57 -127
  22. package/razzle.config.js +4 -7
  23. package/src/components/manage/Blocks/Video/Body.jsx +52 -22
  24. package/src/components/manage/Blocks/Video/Body.test.jsx +167 -0
  25. package/src/components/manage/Controlpanels/Users/UserGroupMembershipControlPanel.jsx +2 -2
  26. package/src/components/manage/Form/Form.jsx +5 -2
  27. package/src/components/theme/Breadcrumbs/Breadcrumbs.jsx +19 -2
  28. package/src/components/theme/ContentMetadataTags/ContentMetadataTags.jsx +46 -39
  29. package/src/config/index.js +0 -4
  30. package/src/icons/divide-horizontal.svg +0 -0
  31. package/src/icons/divide-vertical.svg +0 -0
  32. package/src/icons/hero.svg +0 -0
  33. package/src/icons/slider.svg +0 -0
  34. package/src/icons/summary.svg +0 -0
  35. package/src/middleware/api.js +1 -1
  36. package/theme/themes/default/elements/icon.overrides +0 -0
  37. package/theme/themes/default/globals/reset.overrides +0 -0
  38. package/theme/themes/default/globals/site.variables +0 -0
  39. package/theme/themes/default/modules/dropdown.overrides +0 -0
  40. package/theme/themes/default/modules/dropdown.variables +0 -0
  41. package/theme/themes/default/modules/modal.variables +0 -0
  42. package/theme/themes/default/modules/video.overrides +0 -0
  43. package/theme/themes/default/modules/video.variables +0 -0
  44. package/theme/themes/pastanaga/assets/fonts/icons.eot +0 -0
  45. package/theme/themes/pastanaga/assets/fonts/icons.svg +0 -0
  46. package/theme/themes/pastanaga/assets/fonts/icons.ttf +0 -0
  47. package/theme/themes/pastanaga/assets/fonts/icons.woff +0 -0
  48. package/theme/themes/pastanaga/globals/reset.overrides +0 -0
  49. package/theme/themes/pastanaga/globals/site.variables +0 -0
  50. package/theme/themes/pastanaga/modules/dropdown.variables +0 -0
  51. package/theme/themes/pastanaga/modules/modal.variables +0 -0
  52. package/theme/themes/pastanaga/modules/video.overrides +0 -0
  53. package/theme/themes/pastanaga/modules/video.variables +0 -0
  54. package/tsconfig.json +1 -4
  55. package/types/components/manage/Blocks/Video/Body.d.ts +5 -0
  56. package/types/config/RichTextEditor/index.d.ts +5 -8
  57. package/types/helpers/AsyncConnect/index.d.ts +2 -2
  58. package/types/helpers/Url/Url.d.ts +3 -3
  59. package/types/icons/load-icons.d.ts +1 -1
  60. package/webpack-plugins/webpack-less-plugin.js +1 -0
  61. package/CODE_OF_CONDUCT.md +0 -13
  62. package/CONTRIBUTING.md +0 -7
  63. package/README.md +0 -154
  64. package/RELEASING.md +0 -73
  65. package/ROADMAP.md +0 -30
  66. package/SECURITY.md +0 -14
  67. package/logos/Logo.png +0 -0
  68. package/logos/VoltoLogoEra2-dark-mode.png +0 -0
  69. package/logos/VoltoLogoEra2.png +0 -0
  70. package/logos/volto-colorful.png +0 -0
  71. package/logos/volto-colorful.svg +0 -35
  72. package/logos/volto-guide.png +0 -0
  73. package/logos/volto-h-transparent.svg +0 -6
  74. package/logos/volto-transparent.png +0 -0
  75. package/logos/volto-transparent.svg +0 -19
  76. package/logos/volto-transparent2.svg +0 -5
  77. package/logos/volto-yellow.svg +0 -29
  78. package/logos/volto.sketch +0 -0
  79. package/packages/README.md +0 -7
  80. package/packages/registry/.towncrier/towncrier_template.jinja +0 -10
  81. package/packages/registry/CHANGELOG.md +0 -16
  82. package/packages/registry/README.md +0 -207
  83. package/packages/registry/addon-registry.js +0 -603
  84. package/packages/registry/create-addons-loader.js +0 -116
  85. package/packages/registry/create-theme-addons-loader.js +0 -78
  86. package/packages/registry/news/.gitkeep +0 -0
  87. package/packages/registry/package.json +0 -76
  88. package/packages/registry/src/index.ts +0 -174
  89. package/packages/registry/src/registry.test.js +0 -111
  90. package/packages/registry/tsconfig.json +0 -32
  91. package/packages/scripts/CHANGELOG.md +0 -173
  92. package/packages/scripts/README.md +0 -128
  93. package/packages/scripts/addon/consolidate.js +0 -28
  94. package/packages/scripts/addon/generators.js +0 -213
  95. package/packages/scripts/addon/getAddonInfo.js +0 -65
  96. package/packages/scripts/addon/index.js +0 -88
  97. package/packages/scripts/addon/utils.js +0 -44
  98. package/packages/scripts/backportpr.js +0 -75
  99. package/packages/scripts/changelogupdater.cjs +0 -94
  100. package/packages/scripts/corepackagebump.js +0 -20
  101. package/packages/scripts/i18n.cjs +0 -310
  102. package/packages/scripts/package.json +0 -76
  103. package/packages/scripts/templates/towncrier_template.jinja +0 -10
  104. package/packages/types/Blocks/View.ts +0 -11
  105. package/packages/types/actions.ts +0 -15
  106. package/packages/types/breadcrumbs.ts +0 -10
  107. package/packages/types/config/Blocks.ts +0 -153
  108. package/packages/types/config/Content.ts +0 -62
  109. package/packages/types/config/Settings.ts +0 -86
  110. package/packages/types/config/Views.ts +0 -15
  111. package/packages/types/config/Widgets.ts +0 -7
  112. package/packages/types/config/index.ts +0 -21
  113. package/packages/types/content/common.ts +0 -60
  114. package/packages/types/content/get.ts +0 -66
  115. package/packages/types/index.ts +0 -0
  116. package/packages/types/navigation.ts +0 -12
  117. package/packages/types/package.json +0 -64
  118. package/packages/types/types.ts +0 -61
  119. package/packages/volto-slate/.i18n.babel.config.js +0 -1
  120. package/packages/volto-slate/README.md +0 -4
  121. package/packages/volto-slate/build/messages/src/blocks/Table/TableBlockEdit.json +0 -90
  122. package/packages/volto-slate/build/messages/src/blocks/Text/DefaultTextBlockEditor.json +0 -6
  123. package/packages/volto-slate/build/messages/src/blocks/Text/DetachedTextBlockEditor.json +0 -6
  124. package/packages/volto-slate/build/messages/src/blocks/Text/SlashMenu.json +0 -6
  125. package/packages/volto-slate/build/messages/src/editor/plugins/AdvancedLink/index.json +0 -10
  126. package/packages/volto-slate/build/messages/src/editor/plugins/Link/index.json +0 -10
  127. package/packages/volto-slate/build/messages/src/editor/plugins/Table/index.json +0 -30
  128. package/packages/volto-slate/build/messages/src/elementEditor/messages.json +0 -10
  129. package/packages/volto-slate/build/messages/src/widgets/HtmlSlateWidget.json +0 -6
  130. package/packages/volto-slate/build/messages/src/widgets/RichTextWidgetView.json +0 -6
  131. package/packages/volto-slate/locales/de/LC_MESSAGES/volto.po +0 -148
  132. package/packages/volto-slate/locales/en/LC_MESSAGES/volto.po +0 -148
  133. package/packages/volto-slate/locales/volto.pot +0 -182
  134. package/packages/volto-slate/package.json +0 -43
  135. package/packages/volto-slate/src/actions/content.js +0 -30
  136. package/packages/volto-slate/src/actions/index.js +0 -3
  137. package/packages/volto-slate/src/actions/plugins.js +0 -9
  138. package/packages/volto-slate/src/actions/selection.js +0 -22
  139. package/packages/volto-slate/src/blocks/Table/Cell.jsx +0 -87
  140. package/packages/volto-slate/src/blocks/Table/Cell.test.js +0 -54
  141. package/packages/volto-slate/src/blocks/Table/TableBlockEdit.jsx +0 -694
  142. package/packages/volto-slate/src/blocks/Table/TableBlockEdit.test.js +0 -40
  143. package/packages/volto-slate/src/blocks/Table/TableBlockView.jsx +0 -150
  144. package/packages/volto-slate/src/blocks/Table/TableBlockView.test.js +0 -49
  145. package/packages/volto-slate/src/blocks/Table/deconstruct.js +0 -113
  146. package/packages/volto-slate/src/blocks/Table/extensions/normalizeTable.js +0 -5
  147. package/packages/volto-slate/src/blocks/Table/index.js +0 -60
  148. package/packages/volto-slate/src/blocks/Table/schema.js +0 -122
  149. package/packages/volto-slate/src/blocks/Text/DefaultTextBlockEditor.jsx +0 -304
  150. package/packages/volto-slate/src/blocks/Text/DetachedTextBlockEditor.jsx +0 -77
  151. package/packages/volto-slate/src/blocks/Text/MarkdownIntroduction.jsx +0 -59
  152. package/packages/volto-slate/src/blocks/Text/PluginSidebar.jsx +0 -18
  153. package/packages/volto-slate/src/blocks/Text/ShortcutListing.jsx +0 -28
  154. package/packages/volto-slate/src/blocks/Text/SlashMenu.jsx +0 -203
  155. package/packages/volto-slate/src/blocks/Text/TextBlockEdit.jsx +0 -38
  156. package/packages/volto-slate/src/blocks/Text/TextBlockEdit.test.js +0 -107
  157. package/packages/volto-slate/src/blocks/Text/TextBlockSchema.js +0 -54
  158. package/packages/volto-slate/src/blocks/Text/TextBlockView.jsx +0 -31
  159. package/packages/volto-slate/src/blocks/Text/css/editor.css +0 -18
  160. package/packages/volto-slate/src/blocks/Text/extensions/Readme.md +0 -49
  161. package/packages/volto-slate/src/blocks/Text/extensions/breakList.js +0 -100
  162. package/packages/volto-slate/src/blocks/Text/extensions/index.js +0 -6
  163. package/packages/volto-slate/src/blocks/Text/extensions/insertBreak.js +0 -57
  164. package/packages/volto-slate/src/blocks/Text/extensions/isSelected.js +0 -7
  165. package/packages/volto-slate/src/blocks/Text/extensions/normalizeExternalData.js +0 -7
  166. package/packages/volto-slate/src/blocks/Text/extensions/withDeserializers.js +0 -87
  167. package/packages/volto-slate/src/blocks/Text/extensions/withLists.js +0 -5
  168. package/packages/volto-slate/src/blocks/Text/index.js +0 -171
  169. package/packages/volto-slate/src/blocks/Text/keyboard/backspaceInList.js +0 -58
  170. package/packages/volto-slate/src/blocks/Text/keyboard/breakBlocks.js +0 -3
  171. package/packages/volto-slate/src/blocks/Text/keyboard/cancelEsc.js +0 -7
  172. package/packages/volto-slate/src/blocks/Text/keyboard/indentListItems.js +0 -240
  173. package/packages/volto-slate/src/blocks/Text/keyboard/index.js +0 -52
  174. package/packages/volto-slate/src/blocks/Text/keyboard/joinBlocks.js +0 -180
  175. package/packages/volto-slate/src/blocks/Text/keyboard/moveListItems.js +0 -124
  176. package/packages/volto-slate/src/blocks/Text/keyboard/slashMenu.js +0 -19
  177. package/packages/volto-slate/src/blocks/Text/keyboard/softBreak.js +0 -7
  178. package/packages/volto-slate/src/blocks/Text/keyboard/traverseBlocks.js +0 -81
  179. package/packages/volto-slate/src/blocks/Text/keyboard/unwrapEmptyString.js +0 -26
  180. package/packages/volto-slate/src/blocks/Text/schema.js +0 -39
  181. package/packages/volto-slate/src/constants.js +0 -123
  182. package/packages/volto-slate/src/editor/EditorContext.jsx +0 -5
  183. package/packages/volto-slate/src/editor/EditorReference.jsx +0 -22
  184. package/packages/volto-slate/src/editor/SlateEditor.jsx +0 -375
  185. package/packages/volto-slate/src/editor/config.jsx +0 -344
  186. package/packages/volto-slate/src/editor/decorate.js +0 -68
  187. package/packages/volto-slate/src/editor/deserialize.js +0 -185
  188. package/packages/volto-slate/src/editor/extensions/index.js +0 -6
  189. package/packages/volto-slate/src/editor/extensions/insertBreak.js +0 -15
  190. package/packages/volto-slate/src/editor/extensions/insertData.js +0 -159
  191. package/packages/volto-slate/src/editor/extensions/isInline.js +0 -14
  192. package/packages/volto-slate/src/editor/extensions/normalizeExternalData.js +0 -8
  193. package/packages/volto-slate/src/editor/extensions/normalizeNode.js +0 -48
  194. package/packages/volto-slate/src/editor/extensions/withDeserializers.js +0 -15
  195. package/packages/volto-slate/src/editor/extensions/withTestingFeatures.jsx +0 -84
  196. package/packages/volto-slate/src/editor/index.js +0 -14
  197. package/packages/volto-slate/src/editor/less/editor.less +0 -173
  198. package/packages/volto-slate/src/editor/less/globals.less +0 -18
  199. package/packages/volto-slate/src/editor/less/slate.less +0 -28
  200. package/packages/volto-slate/src/editor/plugins/AdvancedLink/deserialize.js +0 -90
  201. package/packages/volto-slate/src/editor/plugins/AdvancedLink/extensions.js +0 -32
  202. package/packages/volto-slate/src/editor/plugins/AdvancedLink/index.js +0 -50
  203. package/packages/volto-slate/src/editor/plugins/AdvancedLink/render.jsx +0 -37
  204. package/packages/volto-slate/src/editor/plugins/AdvancedLink/schema.js +0 -114
  205. package/packages/volto-slate/src/editor/plugins/AdvancedLink/styles.less +0 -8
  206. package/packages/volto-slate/src/editor/plugins/Blockquote/index.js +0 -30
  207. package/packages/volto-slate/src/editor/plugins/Callout/index.js +0 -34
  208. package/packages/volto-slate/src/editor/plugins/Image/deconstruct.js +0 -30
  209. package/packages/volto-slate/src/editor/plugins/Image/extensions.js +0 -51
  210. package/packages/volto-slate/src/editor/plugins/Image/index.js +0 -11
  211. package/packages/volto-slate/src/editor/plugins/Image/render.jsx +0 -22
  212. package/packages/volto-slate/src/editor/plugins/Link/extensions.js +0 -58
  213. package/packages/volto-slate/src/editor/plugins/Link/index.js +0 -164
  214. package/packages/volto-slate/src/editor/plugins/Link/render.jsx +0 -54
  215. package/packages/volto-slate/src/editor/plugins/Markdown/constants.js +0 -81
  216. package/packages/volto-slate/src/editor/plugins/Markdown/extensions.js +0 -334
  217. package/packages/volto-slate/src/editor/plugins/Markdown/index.js +0 -28
  218. package/packages/volto-slate/src/editor/plugins/Markdown/utils.js +0 -198
  219. package/packages/volto-slate/src/editor/plugins/StyleMenu/StyleMenu.jsx +0 -153
  220. package/packages/volto-slate/src/editor/plugins/StyleMenu/index.js +0 -19
  221. package/packages/volto-slate/src/editor/plugins/StyleMenu/style.less +0 -29
  222. package/packages/volto-slate/src/editor/plugins/StyleMenu/utils.js +0 -168
  223. package/packages/volto-slate/src/editor/plugins/Table/TableButton.jsx +0 -142
  224. package/packages/volto-slate/src/editor/plugins/Table/TableCell.jsx +0 -44
  225. package/packages/volto-slate/src/editor/plugins/Table/TableContainer.jsx +0 -37
  226. package/packages/volto-slate/src/editor/plugins/Table/TableSizePicker.jsx +0 -83
  227. package/packages/volto-slate/src/editor/plugins/Table/extensions.js +0 -87
  228. package/packages/volto-slate/src/editor/plugins/Table/index.js +0 -390
  229. package/packages/volto-slate/src/editor/plugins/Table/less/public.less +0 -29
  230. package/packages/volto-slate/src/editor/plugins/Table/less/table.less +0 -28
  231. package/packages/volto-slate/src/editor/plugins/Table/render.jsx +0 -30
  232. package/packages/volto-slate/src/editor/plugins/index.js +0 -19
  233. package/packages/volto-slate/src/editor/render.jsx +0 -224
  234. package/packages/volto-slate/src/editor/ui/BasicToolbar.jsx +0 -11
  235. package/packages/volto-slate/src/editor/ui/BlockButton.jsx +0 -31
  236. package/packages/volto-slate/src/editor/ui/ClearFormattingButton.jsx +0 -21
  237. package/packages/volto-slate/src/editor/ui/ExpandedToolbar.jsx +0 -18
  238. package/packages/volto-slate/src/editor/ui/Expando.jsx +0 -5
  239. package/packages/volto-slate/src/editor/ui/InlineToolbar.jsx +0 -73
  240. package/packages/volto-slate/src/editor/ui/MarkButton.jsx +0 -23
  241. package/packages/volto-slate/src/editor/ui/MarkElementButton.jsx +0 -30
  242. package/packages/volto-slate/src/editor/ui/Menu.jsx +0 -13
  243. package/packages/volto-slate/src/editor/ui/PositionedToolbar.jsx +0 -32
  244. package/packages/volto-slate/src/editor/ui/Separator.jsx +0 -7
  245. package/packages/volto-slate/src/editor/ui/SlateContextToolbar.jsx +0 -13
  246. package/packages/volto-slate/src/editor/ui/SlateToolbar.jsx +0 -96
  247. package/packages/volto-slate/src/editor/ui/Toolbar.jsx +0 -103
  248. package/packages/volto-slate/src/editor/ui/ToolbarButton.jsx +0 -33
  249. package/packages/volto-slate/src/editor/ui/ToolbarButton.test.js +0 -25
  250. package/packages/volto-slate/src/editor/ui/index.js +0 -15
  251. package/packages/volto-slate/src/editor/utils.js +0 -248
  252. package/packages/volto-slate/src/elementEditor/ContextButtons.jsx +0 -56
  253. package/packages/volto-slate/src/elementEditor/PluginEditor.jsx +0 -124
  254. package/packages/volto-slate/src/elementEditor/Readme.md +0 -6
  255. package/packages/volto-slate/src/elementEditor/SchemaProvider.jsx +0 -3
  256. package/packages/volto-slate/src/elementEditor/SidebarEditor.jsx +0 -46
  257. package/packages/volto-slate/src/elementEditor/ToolbarButton.jsx +0 -44
  258. package/packages/volto-slate/src/elementEditor/index.js +0 -5
  259. package/packages/volto-slate/src/elementEditor/makeInlineElementPlugin.js +0 -100
  260. package/packages/volto-slate/src/elementEditor/messages.js +0 -14
  261. package/packages/volto-slate/src/elementEditor/utils.js +0 -226
  262. package/packages/volto-slate/src/hooks/index.js +0 -3
  263. package/packages/volto-slate/src/hooks/useEditorContext.js +0 -6
  264. package/packages/volto-slate/src/hooks/useIsomorphicLayoutEffect.js +0 -7
  265. package/packages/volto-slate/src/hooks/useSelectionPosition.js +0 -25
  266. package/packages/volto-slate/src/i18n.js +0 -180
  267. package/packages/volto-slate/src/icons/hashlink.svg +0 -57
  268. package/packages/volto-slate/src/index.js +0 -61
  269. package/packages/volto-slate/src/reducers/content.js +0 -74
  270. package/packages/volto-slate/src/reducers/index.js +0 -3
  271. package/packages/volto-slate/src/reducers/plugins.js +0 -17
  272. package/packages/volto-slate/src/reducers/selection.js +0 -16
  273. package/packages/volto-slate/src/utils/blocks.js +0 -375
  274. package/packages/volto-slate/src/utils/blocks.test.js +0 -138
  275. package/packages/volto-slate/src/utils/editor.js +0 -31
  276. package/packages/volto-slate/src/utils/image.js +0 -25
  277. package/packages/volto-slate/src/utils/index.js +0 -11
  278. package/packages/volto-slate/src/utils/internals.js +0 -46
  279. package/packages/volto-slate/src/utils/lists.js +0 -92
  280. package/packages/volto-slate/src/utils/marks.js +0 -104
  281. package/packages/volto-slate/src/utils/mime-types.js +0 -24
  282. package/packages/volto-slate/src/utils/nodes.js +0 -4
  283. package/packages/volto-slate/src/utils/ops.js +0 -20
  284. package/packages/volto-slate/src/utils/random.js +0 -17
  285. package/packages/volto-slate/src/utils/selection.js +0 -236
  286. package/packages/volto-slate/src/utils/slate-string-utils.js +0 -408
  287. package/packages/volto-slate/src/utils/volto-blocks.js +0 -314
  288. package/packages/volto-slate/src/widgets/ErrorBoundary.jsx +0 -27
  289. package/packages/volto-slate/src/widgets/HtmlSlateWidget.jsx +0 -139
  290. package/packages/volto-slate/src/widgets/ObjectByTypeWidget.jsx +0 -49
  291. package/packages/volto-slate/src/widgets/RichTextWidget.jsx +0 -72
  292. package/packages/volto-slate/src/widgets/RichTextWidgetView.jsx +0 -37
  293. package/packages/volto-slate/src/widgets/style.css +0 -21
@@ -1,7 +0,0 @@
1
- # Packages
2
-
3
- This directory is intended to contain packages related to Volto ecosystem.
4
-
5
- It was never intended to convert this repo in a monorepo.
6
-
7
- Main Volto package is still located in the root, and it's intended to continue doing so.
@@ -1,10 +0,0 @@
1
- {% if sections[""] %}
2
- {% for category, val in definitions.items() if category in sections[""] %}
3
- ### {{ definitions[category]['name'] }}
4
-
5
- {% for text, values in sections[""][category].items() %}
6
- - {{ text }} {{ values|join(', ') }}
7
- {% endfor %}
8
-
9
- {% endfor %}
10
- {% endif %}
@@ -1,16 +0,0 @@
1
- # @plone/registry Release Notes
2
-
3
- <!-- Do *NOT* add new change log entries to this file.
4
- You should create a file in the news directory instead.
5
- For helpful instructions, please see:
6
- https://6.docs.plone.org/contributing/index.html#contributing-change-log-label
7
- -->
8
-
9
- <!-- towncrier release notes start -->
10
-
11
- ## 1.0.0 (2023-11-05)
12
-
13
- ### Feature
14
-
15
- - Moved add-on registry to its own package. @sneridagh
16
- Initial Release @sneridagh [#4949](https://github.com/plone/volto/issues/4949)
@@ -1,207 +0,0 @@
1
- # Add-on and configuration registry
2
-
3
- This package provides support for building an add-on registry and infrastructure for JavaScript and TypeScript-based apps.
4
-
5
- ## Extensibility and pluggability
6
-
7
- As a developer when you build an app, regardless of the framework and technologies used, it's a one-off app.
8
- That means you have to build something that has very specific requirements, behavior, and look and feel.
9
-
10
- Sometimes you need to build something generic that is pluggable and extensible.
11
- In the JavaScript and TypeScript ecosystem, this is often quite complex, and the existing frameworks do not provide the means to do this.
12
-
13
- ## Add-on registry
14
-
15
- An add-on registry is a facility that allows an app, which was built on an existing framework, to itself be extensible and pluggable.
16
-
17
- The add-on registry is a store where you can register a number of add-ons that your app consumes.
18
-
19
- Add-on packages are just CommonJS packages.
20
- The only requirement is that they point the `main` key of their `package.json` to a module that exports as a default function, which acts as a configuration loader.
21
-
22
- An add-on can be published in an npm registry, just as any other package.
23
- However, add-ons are meant to not be transpiled.
24
- They should be released as source packages.
25
-
26
- ## Register an add-on
27
-
28
- You should declare your add-on in your project.
29
- This is done in your app's `package.json`'s `addons` key:
30
-
31
- ```json
32
- {
33
- "name": "my-app-project",
34
- "addons": [
35
- "acme-volto-foo-addon",
36
- "@plone/some-addon",
37
- "collective-another-volto-addon"
38
- ]
39
- }
40
- ```
41
-
42
- The `addons` key ensures the add-on's main default export function is executed, being passed the configuration registry.
43
- In that function, the add-on can customize the registry.
44
- The function needs to return the `config` object (the configuration registry), so that it's passed further along to the other add-ons.
45
-
46
- The add-ons are registered in the order they are found in the `addons` key.
47
- The last add-on takes precedence over the others.
48
- This means that if you configure something in `acme-volto-foo-addon`, then the same thing later in `collective-another-volto-addon`, the latter configured thing will win and its configuration will be applied.
49
-
50
- The default export of any add-on main `index.js` file should be a function with the signature `config => config`.
51
- That is, it should take the configuration registry object and return it, possibly mutated or changed.
52
-
53
- ## Configuration registry
54
-
55
- The configuration registry supplements the add-on registry.
56
-
57
- It is a facility that stores app configuration to be shared in the app.
58
-
59
- Let's say that your app is the user interface of a content management system (CMS).
60
- This CMS uses blocks as its main fundamental unit of content.
61
- The pages that the CMS builds are made up of these blocks.
62
- The CMS has some basic available blocks, but it's a requirement that integrators are able to register more blocks in a pluggable way.
63
-
64
- This app will use the add-on registry to extend the basic CMS capabilities, so an external add-on can supplement their own add-ons to the basic CMS ones.
65
-
66
- Let's assume we've defined a key in the registry `config.blocks.blocksConfig`, and defined a way to register the available blocks in the CMS as the keys in that object in the configuration registry:
67
-
68
- ```js
69
- config.blocks.blocksConfig.faq_viewer = {
70
- id: 'faq_viewer',
71
- title: 'FAQ Viewer',
72
- edit: FAQBlockEdit,
73
- view: FAQBlockView,
74
- icon: chartIcon,
75
- group: 'common',
76
- restricted: false,
77
- mostUsed: true,
78
- sidebarTab: 1,
79
- };
80
- ```
81
-
82
- The configuration registry will have other keys already set by default, which will compose the initial set of basic blocks used by the CMS.
83
- Then the CMS will properly populate the available blocks in the user interface.
84
-
85
- The add-on is meant to extend the initial configuration.
86
- From the default export function of our add-on, we should provide the configuration of the new block:
87
-
88
- ```ts
89
- export default function applyConfig(config: ConfigData) {
90
- config.blocks.blocksConfig.faq_viewer = {
91
- id: 'faq_viewer',
92
- title: 'FAQ Viewer',
93
- edit: FAQBlockEdit,
94
- view: FAQBlockView,
95
- icon: chartIcon,
96
- group: 'common',
97
- restricted: false,
98
- mostUsed: true,
99
- sidebarTab: 1,
100
- };
101
-
102
- return config;
103
- }
104
- ```
105
-
106
- Once the app starts, the add-on registry will execute, in order, all the registered add-ons' default export functions, configuring the new block.
107
- The add-on will then become available to the CMS when it asks the configuration registry for it.
108
-
109
- ## Accessing the configuration registry
110
-
111
- The configuration registry can be accessed by:
112
-
113
- ```ts
114
- import config from '@plone/registry'
115
-
116
- const blocksConfig = config.blocks.blocksConfig
117
- ```
118
-
119
- ## Component registry
120
-
121
- The configuration registry also stores a components registry in itself.
122
- The components registry is a mapping of name to component.
123
- You can look up a name, and receive a component that you can reference in your code.
124
- This provides an alternative, and more convenient, way to customize components.
125
- You can override programatically such registrations from your add-on or projects because it's stored in the configuration registry.
126
- You can customize a component without using shadowing at all, if the code that uses the component retrieves from the component registry, rather then import it directly.
127
- You can even have modifiers to the component registrations through dependencies.
128
- Thus you can adapt the call, given an array of such dependencies.
129
-
130
- ## Register components by name using `config.registerComponent`
131
-
132
- You can register components by name, typically from an add-on or project configuration:
133
-
134
- ```js
135
- import MyToolbarComponent from './MyToolbarComponent'
136
-
137
- config.registerComponent({
138
- name: 'Toolbar',
139
- component: MyToolbarComponent,
140
- });
141
- ```
142
-
143
- ## Retrieve a component from the component registry
144
-
145
- You can programatically retrieve a component from the registry using `config.getComponent`:
146
-
147
- ```js
148
- const Toolbar = config.getComponent('Toolbar').component
149
- ```
150
-
151
- Or you can retrieve a component by using the convenience component `Component`, if you want to use it in JSX code directly.
152
-
153
- ```jsx
154
- import Component from '@plone/volto/components/theme/Component/Component';
155
-
156
- <Component componentName="Toolbar" {...props} />
157
- ```
158
-
159
- Note that you can pass `props` down to the retrieved component.
160
-
161
- ## Adapt the component using the `dependencies` array
162
-
163
- You can register components, then retrieve them, given a list of modifiers using `dependencies`.
164
-
165
- ```js
166
- import MyTeaserNewsItemComponent from './MyTeaserNewsItemComponent'
167
-
168
- config.registerComponent({
169
- name: 'Teaser',
170
- component: MyTeaserNewsItemComponent,
171
- dependencies: 'News Item',
172
- });
173
- ```
174
-
175
- And then retrieve the component:
176
-
177
- ```js
178
- config.getComponent({
179
- name: 'Teaser',
180
- dependencies: ['News Item'],
181
- }).component
182
- ```
183
-
184
- You can have both, either with or without dependencies:
185
-
186
- ```js
187
- import MyTeaserDefaultComponent from './MyTeaserDefaultComponent'
188
- import MyTeaserNewsItemComponent from './MyTeaserNewsItemComponent'
189
-
190
- config.registerComponent({
191
- name: 'Teaser',
192
- component: MyTeaserDefaultComponent,
193
- });
194
-
195
- config.registerComponent({
196
- name: 'Teaser',
197
- component: MyTeaserNewsItemComponent,
198
- dependencies: 'News Item',
199
- });
200
- ```
201
-
202
- Then retrieve them both, depending on the use case.
203
- In the example, given a content type value coming from the `content` prop, you would retrieve them as shown:
204
-
205
- ```jsx
206
- <Component componentName="Toolbar" dependencies={[props.content['@type']]} {...props} />
207
- ```