@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,61 +0,0 @@
1
- import * as slateReducers from './reducers';
2
-
3
- import installSlate from './editor';
4
- import installTextBlock from './blocks/Text';
5
- import installTableBlock from './blocks/Table';
6
- import RichTextWidget from './widgets/RichTextWidget';
7
- import RichTextWidgetView from './widgets/RichTextWidgetView';
8
- import HtmlSlateWidget from './widgets/HtmlSlateWidget';
9
- import ObjectByTypeWidget from './widgets/ObjectByTypeWidget';
10
-
11
- export default function applyConfig(config) {
12
- config = [installSlate, installTextBlock, installTableBlock].reduce(
13
- (acc, apply) => apply(acc),
14
- config,
15
- );
16
-
17
- config.settings.defaultBlockType = 'slate';
18
-
19
- config.settings.slate.toolbarButtons = [
20
- 'bold',
21
- 'italic',
22
- 'strikethrough',
23
- 'link',
24
- 'separator',
25
- 'heading-two',
26
- 'heading-three',
27
- 'separator',
28
- 'sub',
29
- 'sup',
30
- 'separator',
31
- 'numbered-list',
32
- 'bulleted-list',
33
- 'blockquote',
34
- 'styleMenu',
35
- ];
36
-
37
- config.settings.slate.scrollIntoView = false;
38
-
39
- config.addonReducers = {
40
- ...config.addonReducers,
41
- ...slateReducers,
42
- };
43
-
44
- config.views = {
45
- ...config.views,
46
- };
47
-
48
- config.widgets.widget.slate = RichTextWidget;
49
- config.widgets.widget.slate_richtext = RichTextWidget;
50
- config.widgets.widget.slate_html = HtmlSlateWidget;
51
- config.widgets.widget.richtext = HtmlSlateWidget;
52
- config.widgets.widget.object_by_type = ObjectByTypeWidget;
53
-
54
- // volto-widgets-view
55
- if (config.widgets.views?.widget) {
56
- config.widgets.views.widget.slate = RichTextWidgetView;
57
- config.widgets.views.widget.slate_richtext = RichTextWidgetView;
58
- }
59
-
60
- return config;
61
- }
@@ -1,74 +0,0 @@
1
- /**
2
- * Upload reducer.
3
- * @module reducers/content
4
- *
5
- * Customized copy of Volto's content reducer
6
- */
7
-
8
- import config from '@plone/volto/registry';
9
-
10
- import { UPLOAD_CONTENT } from '@plone/volto-slate/constants';
11
-
12
- const initialState = {};
13
-
14
- /**
15
- * Content reducer.
16
- * @function content
17
- * @param {Object} state Current state.
18
- * @param {Object} action Action to be handled.
19
- * @returns {Object} New state.
20
- */
21
- export default function upload_content(state = initialState, action = {}) {
22
- let { result, origin } = action;
23
- switch (action.type) {
24
- case `${UPLOAD_CONTENT}_PENDING`:
25
- return {
26
- ...state,
27
- [origin]: {
28
- ...state[origin],
29
- upload: {
30
- loading: true,
31
- loaded: false,
32
- error: null,
33
- },
34
- },
35
- };
36
- case `${UPLOAD_CONTENT}_SUCCESS`:
37
- return {
38
- ...state,
39
- [origin]: {
40
- ...state[origin],
41
- data: {
42
- ...result,
43
- items:
44
- action.result &&
45
- action.result.items &&
46
- action.result.items.map((item) => ({
47
- ...item,
48
- url: item['@id'].replace(config.settings.apiPath, ''),
49
- })),
50
- },
51
- upload: {
52
- loading: false,
53
- loaded: true,
54
- error: null,
55
- },
56
- },
57
- };
58
- case `${UPLOAD_CONTENT}_FAIL`:
59
- return {
60
- ...state,
61
- [origin]: {
62
- ...state[origin],
63
- data: null,
64
- upload: {
65
- loading: false,
66
- loaded: false,
67
- error: action.error,
68
- },
69
- },
70
- };
71
- default:
72
- return state;
73
- }
74
- }
@@ -1,3 +0,0 @@
1
- export { default as slate_block_selections } from './selection';
2
- export { default as upload_content } from './content';
3
- export { default as slate_plugins } from './plugins';
@@ -1,17 +0,0 @@
1
- const initialState = {};
2
-
3
- export default function slate_plugins(state = initialState, action = {}) {
4
- const { type, pluginId, ...rest } = action;
5
- switch (type) {
6
- case 'SLATE_PLUGINS':
7
- return {
8
- ...state,
9
- [pluginId]: {
10
- ...state[pluginId],
11
- ...rest,
12
- },
13
- };
14
- default:
15
- return state;
16
- }
17
- }
@@ -1,16 +0,0 @@
1
- const initialState = {};
2
-
3
- export default function slate_block_selections(
4
- state = initialState,
5
- action = {},
6
- ) {
7
- switch (action.type) {
8
- case 'SAVE_SLATE_BLOCK_SELECTION':
9
- return {
10
- ...state,
11
- [action.blockid]: action.selection,
12
- };
13
- default:
14
- return state;
15
- }
16
- }
@@ -1,375 +0,0 @@
1
- /* eslint no-console: ["error", { allow: ["error", "warn"] }] */
2
- import { Editor, Transforms, Text } from 'slate'; // Range, RangeRef
3
- import config from '@plone/volto/registry';
4
- import {
5
- getBlocksFieldname,
6
- getBlocksLayoutFieldname,
7
- } from '@plone/volto/helpers';
8
- import _ from 'lodash';
9
- import { makeEditor } from './editor';
10
-
11
- // case sensitive; first in an inner array is the default and preffered format
12
- // in that array of formats
13
- const formatAliases = [
14
- ['strong', 'b'],
15
- ['em', 'i'],
16
- ['del', 's'],
17
- ];
18
-
19
- /**
20
- * Excerpt from Slate documentation, kept here for posterity:
21
- * See https://docs.slatejs.org/concepts/11-normalizing#built-in-constraints
22
-
23
- ## Built-in Constraints
24
-
25
- Slate editors come with a few built-in constraints out of the box. These
26
- constraints are there to make working with content much more predictable than
27
- standard contenteditable. All of the built-in logic in Slate depends on these
28
- constraints, so unfortunately you cannot omit them. They are...
29
-
30
- - All Element nodes must contain at least one Text descendant. If an element node
31
- does not contain any children, an empty text node will be added as its only
32
- child. This constraint exists to ensure that the selection's anchor and focus
33
- points (which rely on referencing text nodes) can always be placed inside any
34
- node. With this, empty elements (or void elements) wouldn't be selectable.
35
-
36
- - Two adjacent texts with the same custom properties will be merged. If two
37
- adjacent text nodes have the same formatting, they're merged into a single text
38
- node with a combined text string of the two. This exists to prevent the text
39
- nodes from only ever expanding in count in the document, since both adding and
40
- removing formatting results in splitting text nodes.
41
-
42
- - Block nodes can only contain other blocks, or inline and text nodes. For
43
- example, a paragraph block cannot have another paragraph block element and
44
- a link inline element as children at the same time. The type of children
45
- allowed is determined by the first child, and any other non-conforming children
46
- are removed. This ensures that common richtext behaviors like "splitting
47
- a block in two" function consistently.
48
-
49
- - Inline nodes cannot be the first or last child of a parent block, nor can it
50
- be next to another inline node in the children array. If this is the case, an
51
- empty text node will be added to correct this to be in compliance with the
52
- constraint.
53
-
54
- - The top-level editor node can only contain block nodes. If any of the
55
- top-level children are inline or text nodes they will be removed. This ensures
56
- that there are always block nodes in the editor so that behaviors like
57
- "splitting a block in two" work as expected.
58
-
59
- - These default constraints are all mandated because they make working with
60
- Slate documents much more predictable.
61
-
62
- Although these constraints are the best we've come up with now, we're always
63
- looking for ways to have Slate's built-in constraints be less constraining if
64
- possible—as long as it keeps standard behaviors easy to reason about. If you
65
- come up with a way to reduce or remove a built-in constraint with a different
66
- approach, we're all ears!
67
- *
68
- */
69
-
70
- export const normalizeExternalData = (editor, nodes) => {
71
- let fakeEditor = makeEditor({ extensions: editor._installedPlugins });
72
- fakeEditor.children = nodes;
73
- // put all the non-blocks (e.g. images which are inline Elements) inside p-s
74
- Editor.withoutNormalizing(fakeEditor, () => {
75
- //for htmlSlateWidget compatibility
76
- if (nodes && !Editor.isBlock(fakeEditor, nodes[0]))
77
- Transforms.wrapNodes(
78
- fakeEditor,
79
- { type: 'p' },
80
- {
81
- at: [],
82
- match: (node, path) =>
83
- (!Editor.isEditor(node) && !Editor.isBlock(fakeEditor, node)) ||
84
- fakeEditor.isInline(node),
85
- mode: 'highest',
86
- },
87
- );
88
- });
89
-
90
- Editor.normalize(fakeEditor, { force: true });
91
-
92
- return fakeEditor.children;
93
- };
94
-
95
- /**
96
- * Is it text? Is it whitespace (space, newlines, tabs) ?
97
- *
98
- */
99
- export const isWhitespace = (c) => {
100
- return (
101
- typeof c === 'string' &&
102
- c.replace(/\s/g, '').replace(/\t/g, '').replace(/\n/g, '').length === 0
103
- );
104
- };
105
-
106
- export function createDefaultBlock(children) {
107
- return {
108
- type: config.settings.slate.defaultBlockType,
109
- children: children || [{ text: '' }],
110
- };
111
- }
112
-
113
- export function createBlock(type, children) {
114
- return {
115
- type,
116
- children: children || [{ text: '' }],
117
- };
118
- }
119
-
120
- export function createEmptyParagraph() {
121
- // TODO: rename to createEmptyBlock
122
- return {
123
- type: config.settings.slate.defaultBlockType,
124
- children: [{ text: '' }],
125
- };
126
- }
127
-
128
- export function createParagraph(text) {
129
- return {
130
- type: config.settings.slate.defaultBlockType,
131
- children: [{ text }],
132
- };
133
- }
134
-
135
- export const isSingleBlockTypeActive = (editor, format) => {
136
- const [match] = Editor.nodes(editor, {
137
- match: (n) => n.type === format,
138
- });
139
-
140
- return !!match;
141
- };
142
-
143
- export const isBlockActive = (editor, format) => {
144
- const aliasList = _.find(formatAliases, (x) => _.includes(x, format));
145
-
146
- if (aliasList) {
147
- const aliasFound = _.some(aliasList, (y) => {
148
- return isSingleBlockTypeActive(editor, y);
149
- });
150
-
151
- if (aliasFound) {
152
- return true;
153
- }
154
- }
155
-
156
- return isSingleBlockTypeActive(editor, format);
157
- };
158
-
159
- export const getBlockTypeContextData = (editor, format) => {
160
- let isActive, defaultFormat, matcher;
161
-
162
- const aliasList = _.find(formatAliases, (x) => _.includes(x, format));
163
-
164
- if (aliasList) {
165
- const aliasFound = _.some(aliasList, (y) => {
166
- return isSingleBlockTypeActive(editor, y);
167
- });
168
-
169
- if (aliasFound) {
170
- isActive = true;
171
- defaultFormat = _.first(aliasList);
172
- matcher = (n) => _.includes(aliasList, n.type);
173
-
174
- return { isActive, defaultFormat, matcher };
175
- }
176
- }
177
-
178
- isActive = isBlockActive(editor, format);
179
- defaultFormat = format;
180
- matcher = (n) => n.type === format;
181
-
182
- return { isActive, defaultFormat, matcher };
183
- };
184
-
185
- export const toggleInlineFormat = (editor, format) => {
186
- const { isActive, defaultFormat, matcher } = getBlockTypeContextData(
187
- editor,
188
- format,
189
- );
190
-
191
- if (isActive) {
192
- const rangeRef = Editor.rangeRef(editor, editor.selection);
193
-
194
- Transforms.unwrapNodes(editor, {
195
- match: matcher,
196
- split: false,
197
- });
198
-
199
- const newSel = JSON.parse(JSON.stringify(rangeRef.current));
200
-
201
- Transforms.select(editor, newSel);
202
- editor.setSavedSelection(newSel);
203
- // editor.savedSelection = newSel;
204
- return;
205
- }
206
-
207
- const exclusiveElements = config.settings.slate.exclusiveElements;
208
- const matchedElements = exclusiveTags(exclusiveElements, format);
209
- let alreadyOneIsActive =
210
- !!matchedElements &&
211
- (matchedElements.indexOf(format) === 0
212
- ? isBlockActive(editor, matchedElements[1])
213
- : isBlockActive(editor, matchedElements[0]));
214
-
215
- if (alreadyOneIsActive) {
216
- Transforms.unwrapNodes(editor, {
217
- match: (n) => matchedElements.includes(n.type),
218
- split: false,
219
- });
220
-
221
- const block = { type: format, children: [] };
222
- Transforms.wrapNodes(editor, block, { split: true });
223
- return;
224
- }
225
-
226
- // `children` property is added automatically as an empty array then
227
- // normalized
228
- const block = { type: defaultFormat };
229
- Transforms.wrapNodes(editor, block, { split: true });
230
- };
231
-
232
- const exclusiveTags = (exclusiveElements, format) => {
233
- let elements = null;
234
- for (const item of exclusiveElements) {
235
- if (item.includes(format)) {
236
- elements = item;
237
- break;
238
- }
239
- }
240
-
241
- return elements;
242
- };
243
-
244
- export const toggleBlock = (editor, format, allowedChildren) => {
245
- // We have 6 boolean variables which need to be accounted for.
246
- // See https://docs.google.com/spreadsheets/d/1mVeMuqSTMABV2BhoHPrPAFjn7zUksbNgZ9AQK_dcd3U/edit?usp=sharing
247
- const { slate } = config.settings;
248
- const { listTypes } = slate;
249
-
250
- const isListItem = isBlockActive(editor, slate.listItemType);
251
- const isActive = isBlockActive(editor, format);
252
- const wantsList = listTypes.includes(format);
253
-
254
- if (isListItem && !wantsList) {
255
- toggleFormatAsListItem(editor, format);
256
- } else if (isListItem && wantsList && !isActive) {
257
- switchListType(editor, format);
258
- } else if (!isListItem && wantsList) {
259
- changeBlockToList(editor, format);
260
- } else if (!isListItem && !wantsList) {
261
- toggleFormat(editor, format, allowedChildren);
262
- } else if (isListItem && wantsList && isActive) {
263
- clearFormatting(editor);
264
- } else {
265
- console.warn('toggleBlock case not covered, please examine:', {
266
- wantsList,
267
- isActive,
268
- isListItem,
269
- });
270
- }
271
- };
272
-
273
- /*
274
- * Applies a block format to a list item. Will split the list
275
- */
276
- export const toggleFormatAsListItem = (editor, format) => {
277
- Transforms.setNodes(editor, {
278
- type: format,
279
- });
280
-
281
- Editor.normalize(editor);
282
- };
283
-
284
- /*
285
- * Toggles between list types by exploding the block
286
- */
287
- export const switchListType = (editor, format) => {
288
- const { slate } = config.settings;
289
- Transforms.unwrapNodes(editor, {
290
- match: (n) => slate.listTypes.includes(n.type),
291
- split: true,
292
- });
293
- const block = { type: format, children: [] };
294
- Transforms.wrapNodes(editor, block);
295
- };
296
-
297
- export const changeBlockToList = (editor, format) => {
298
- const { slate } = config.settings;
299
- const [match] = Editor.nodes(editor, {
300
- match: (n) => n.type === slate.listItemType,
301
- });
302
-
303
- if (!match) {
304
- Transforms.setNodes(editor, {
305
- type: slate.listItemType,
306
- // id: nanoid(8),
307
- });
308
- }
309
-
310
- // `children` property is added automatically as an empty array then
311
- // normalized
312
- const block = { type: format };
313
- Transforms.wrapNodes(editor, block);
314
- };
315
-
316
- export const toggleFormat = (editor, format, allowedChildren) => {
317
- const { slate } = config.settings;
318
- const isActive = isBlockActive(editor, format);
319
- const type = isActive ? slate.defaultBlockType : format;
320
- Transforms.setNodes(editor, {
321
- type,
322
- });
323
- allowedChildren?.length &&
324
- Transforms.unwrapNodes(editor, {
325
- mode: 'all',
326
- at: [0],
327
- match: (n, path) => {
328
- const isMatch =
329
- path.length > 1 && // we don't deal with the parent nodes
330
- !(Text.isText(n) || allowedChildren.includes(n?.type));
331
- return isMatch;
332
- },
333
- });
334
- };
335
-
336
- /**
337
- * @param {object} properties A prop received by the View component
338
- * which is read by the `getBlocksFieldname` and
339
- * `getBlocksLayoutFieldname` Volto helpers to produce the return value.
340
- * @returns {Array} All the blocks data taken from the Volto form.
341
- */
342
- export const getAllBlocks = (properties, blocks) => {
343
- const blocksFieldName = getBlocksFieldname(properties);
344
- const blocksLayoutFieldname = getBlocksLayoutFieldname(properties);
345
-
346
- for (const n of properties?.[blocksLayoutFieldname]?.items || []) {
347
- const block = properties[blocksFieldName][n];
348
- // TODO Make this configurable via block config getBlocks
349
- if (
350
- block?.data?.[blocksLayoutFieldname] &&
351
- block?.data?.[blocksFieldName]
352
- ) {
353
- getAllBlocks(block.data, blocks);
354
- } else if (block?.[blocksLayoutFieldname] && block?.[blocksFieldName]) {
355
- getAllBlocks(block, blocks);
356
- }
357
- blocks.push({
358
- id: n,
359
- ...block,
360
- });
361
- }
362
- return blocks;
363
- };
364
-
365
- export const clearFormatting = (editor) => {
366
- const { slate } = config.settings;
367
- Transforms.setNodes(editor, {
368
- type: slate.defaultBlockType,
369
- });
370
- Transforms.unwrapNodes(editor, {
371
- match: (n) => n.type && n.type !== slate.defaultBlockType,
372
- mode: 'all',
373
- split: false,
374
- });
375
- };
@@ -1,138 +0,0 @@
1
- import { getAllBlocks } from './blocks';
2
-
3
- describe('Blocks utils', () => {
4
- describe('Get all blocks', () => {
5
- it('Basic empty test', () => {
6
- const metadata = {};
7
- const blocks = getAllBlocks(metadata, []);
8
- expect(blocks).toEqual([]);
9
- });
10
-
11
- it('Empty blocks', () => {
12
- const metadata = {
13
- blocks: {},
14
- blocks_layout: {},
15
- };
16
- const blocks = getAllBlocks(metadata, []);
17
- expect(blocks).toEqual([]);
18
- });
19
-
20
- it('Empty blocks with items', () => {
21
- const metadata = {
22
- blocks: {},
23
- blocks_layout: { items: [] },
24
- };
25
- const blocks = getAllBlocks(metadata, []);
26
- expect(blocks).toEqual([]);
27
- });
28
-
29
- it('One level of blocks', () => {
30
- const metadata = {
31
- blocks: { a: {} },
32
- blocks_layout: { items: ['a'] },
33
- };
34
- const blocks = getAllBlocks(metadata, []);
35
- expect(blocks).toEqual([{ id: 'a' }]);
36
- });
37
-
38
- it('Two level of blocks w/o data', () => {
39
- const metadata = {
40
- blocks: {
41
- a: {
42
- blocks: {
43
- b: { type: 'text' },
44
- },
45
- blocks_layout: {
46
- items: ['b'],
47
- },
48
- },
49
- },
50
- blocks_layout: {
51
- items: ['a'],
52
- },
53
- };
54
- const blocks = getAllBlocks(metadata, []);
55
- expect(blocks).toEqual([
56
- { id: 'b', ...metadata.blocks.a.blocks.b },
57
- { id: 'a', ...metadata.blocks.a },
58
- ]);
59
- });
60
-
61
- it('Two level of blocks w/ data', () => {
62
- const metadata = {
63
- blocks: {
64
- a: {
65
- data: {
66
- blocks: {
67
- b: { type: 'text' },
68
- },
69
- blocks_layout: {
70
- items: ['b'],
71
- },
72
- },
73
- },
74
- },
75
- blocks_layout: {
76
- items: ['a'],
77
- },
78
- };
79
- const blocks = getAllBlocks(metadata, []);
80
- expect(blocks).toEqual([
81
- { id: 'b', ...metadata.blocks.a.data.blocks.b },
82
- { id: 'a', ...metadata.blocks.a },
83
- ]);
84
- });
85
-
86
- it('Three level of blocks', () => {
87
- const metadata = {
88
- blocks: {
89
- a: {
90
- data: {
91
- blocks: {
92
- a1: { type: 'text' },
93
- a2: {
94
- type: 'text',
95
- blocks: {
96
- a21: { type: 'image' },
97
- a22: { type: 'image' },
98
- },
99
- blocks_layout: {
100
- items: ['a21', 'a22'],
101
- },
102
- },
103
- },
104
- blocks_layout: {
105
- items: ['a1', 'a2'],
106
- },
107
- },
108
- },
109
- b: {
110
- data: {
111
- blocks: {
112
- b1: { type: 'text' },
113
- b2: { type: 'text' },
114
- },
115
- blocks_layout: {
116
- items: ['b1', 'b2'],
117
- },
118
- },
119
- },
120
- },
121
- blocks_layout: {
122
- items: ['a', 'b'],
123
- },
124
- };
125
- const blocks = getAllBlocks(metadata, []);
126
- expect(blocks).toEqual([
127
- { id: 'a1', ...metadata.blocks.a.data.blocks.a1 },
128
- { id: 'a21', ...metadata.blocks.a.data.blocks.a2.blocks.a21 },
129
- { id: 'a22', ...metadata.blocks.a.data.blocks.a2.blocks.a22 },
130
- { id: 'a2', ...metadata.blocks.a.data.blocks.a2 },
131
- { id: 'a', ...metadata.blocks.a },
132
- { id: 'b1', ...metadata.blocks.b.data.blocks.b1 },
133
- { id: 'b2', ...metadata.blocks.b.data.blocks.b2 },
134
- { id: 'b', ...metadata.blocks.b },
135
- ]);
136
- });
137
- });
138
- });