@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,38 +0,0 @@
1
- import React from 'react';
2
-
3
- import { connect } from 'react-redux';
4
-
5
- import {
6
- uploadContent,
7
- saveSlateBlockSelection,
8
- } from '@plone/volto-slate/actions';
9
-
10
- import DefaultTextBlockEditor from './DefaultTextBlockEditor';
11
- import DetachedTextBlockEditor from './DetachedTextBlockEditor';
12
-
13
- import './css/editor.css';
14
-
15
- const TextBlockEdit = (props) => {
16
- return props.detached ? ( // || props.disableNewBlocks
17
- <DetachedTextBlockEditor {...props} />
18
- ) : (
19
- <DefaultTextBlockEditor {...props} />
20
- );
21
- };
22
-
23
- export default connect(
24
- (state, props) => {
25
- const blockId = props.block;
26
- return {
27
- defaultSelection: blockId
28
- ? state.slate_block_selections?.[blockId]
29
- : null,
30
- uploadRequest: state.upload_content?.[props.block]?.upload || {},
31
- uploadedContent: state.upload_content?.[props.block]?.data || {},
32
- };
33
- },
34
- {
35
- uploadContent,
36
- saveSlateBlockSelection, // needed as editor blockProps
37
- },
38
- )(TextBlockEdit);
@@ -1,107 +0,0 @@
1
- import React from 'react';
2
- import configureStore from 'redux-mock-store';
3
- import { Provider } from 'react-intl-redux';
4
- import { render } from '@testing-library/react';
5
- import config from '@plone/volto/registry';
6
- import TextBlockEdit from './TextBlockEdit';
7
- import { mockAllIsIntersecting } from 'react-intersection-observer/test-utils';
8
-
9
- const mockStore = configureStore();
10
-
11
- window.getSelection = () => null;
12
-
13
- global.__SERVER__ = true; // eslint-disable-line no-underscore-dangle
14
- global.__CLIENT__ = false; // eslint-disable-line no-underscore-dangle
15
-
16
- beforeAll(() => {
17
- config.widgets = {
18
- id: {
19
- default: () => <div />,
20
- },
21
- type: {
22
- boolean: () => <div />,
23
- },
24
- };
25
-
26
- config.settings = {
27
- supportedLanguages: [],
28
- slate: {
29
- elements: {
30
- default: ({ attributes, children }) => (
31
- <p {...attributes}>{children}</p>
32
- ),
33
- },
34
- leafs: {},
35
- persistentHelpers: [],
36
- contextToolbarButtons: [],
37
- textblockExtensions: [],
38
- extensions: [],
39
- elementToolbarButtons: {},
40
- },
41
- };
42
- config.blocks.blocksConfig.slate = {
43
- id: 'slate',
44
- title: 'Slate',
45
- group: 'text',
46
- edit: TextBlockEdit,
47
- restricted: false,
48
- mostUsed: false,
49
- blockHasOwnFocusManagement: true,
50
- sidebarTab: 1,
51
- security: {
52
- addPermission: [],
53
- view: [],
54
- },
55
- blockHasValue: (data) => {
56
- return !!data.plaintext;
57
- },
58
- };
59
- });
60
-
61
- describe('TextBlockEdit', () => {
62
- it('renders w/o errors', async () => {
63
- const store = mockStore({
64
- intl: {
65
- locale: 'en',
66
- messages: {},
67
- },
68
- });
69
-
70
- mockAllIsIntersecting(true);
71
-
72
- // TODO: also test for the initial contents: My first paragraph.
73
- const { asFragment } = render(
74
- <Provider store={store}>
75
- <TextBlockEdit
76
- block="478923"
77
- blockNode={{ current: {} }}
78
- detached={false}
79
- index={2}
80
- onAddBlock={() => {}}
81
- onChangeBlock={() => {}}
82
- onDeleteBlock={() => {}}
83
- onFocusNextBlock={() => {}}
84
- onFocusPreviousBlock={() => {}}
85
- onInsertBlock={() => {}}
86
- onMutateBlock={() => {}}
87
- onSelectBlock={() => {}}
88
- properties={{}}
89
- setSlateBlockSelection={() => {}}
90
- data={{
91
- '@type': 'slate',
92
- plaintext: '',
93
- value: [
94
- {
95
- type: 'p',
96
- children: [{ text: '' /* My first paragraph. */ }],
97
- },
98
- ],
99
- }}
100
- selected={true}
101
- />
102
- </Provider>,
103
- );
104
-
105
- expect(asFragment()).toMatchSnapshot();
106
- });
107
- });
@@ -1,54 +0,0 @@
1
- const Schema = {
2
- title: 'Text block settings',
3
- fieldsets: [
4
- {
5
- id: 'default',
6
- title: 'Default',
7
- fields: [
8
- 'placeholder',
9
- 'instructions',
10
- 'required',
11
- 'fixed',
12
- 'disableNewBlocks',
13
- 'readOnly',
14
- ],
15
- },
16
- ],
17
- properties: {
18
- placeholder: {
19
- title: 'Helper text',
20
- description:
21
- 'A short hint that describes the expected value within this block',
22
- type: 'string',
23
- },
24
- instructions: {
25
- title: 'Instructions',
26
- description: 'Detailed expected value within this block',
27
- type: 'string',
28
- widget: 'richtext',
29
- },
30
- required: {
31
- title: 'Required',
32
- description: "Don't allow deletion of this block",
33
- type: 'boolean',
34
- },
35
- fixed: {
36
- title: 'Fixed position',
37
- description: 'Disable drag & drop on this block',
38
- type: 'boolean',
39
- },
40
- disableNewBlocks: {
41
- title: 'Disable new blocks',
42
- description: 'Disable creation of new blocks after this block',
43
- type: 'boolean',
44
- },
45
- readOnly: {
46
- title: 'Read-only',
47
- description: 'Disable editing on this block',
48
- type: 'boolean',
49
- },
50
- },
51
- required: [],
52
- };
53
-
54
- export default Schema;
@@ -1,31 +0,0 @@
1
- import {
2
- serializeNodes,
3
- serializeNodesToText,
4
- } from '@plone/volto-slate/editor/render';
5
- import config from '@plone/volto/registry';
6
- import { isEqual } from 'lodash';
7
- import Slugger from 'github-slugger';
8
- import { normalizeString } from '@plone/volto/helpers';
9
-
10
- const TextBlockView = (props) => {
11
- const { id, data, styling = {} } = props;
12
- const { value, override_toc } = data;
13
- const metadata = props.metadata || props.properties;
14
- const { topLevelTargetElements } = config.settings.slate;
15
-
16
- const getAttributes = (node, path) => {
17
- const res = { ...styling };
18
- if (node.type && isEqual(path, [0])) {
19
- if (topLevelTargetElements.includes(node.type) || override_toc) {
20
- const text = serializeNodesToText(node?.children || []);
21
- const slug = Slugger.slug(normalizeString(text));
22
- res.id = slug || id;
23
- }
24
- }
25
- return res;
26
- };
27
-
28
- return serializeNodes(value, getAttributes, { metadata: metadata });
29
- };
30
-
31
- export default TextBlockView;
@@ -1,18 +0,0 @@
1
- .drop-indicator {
2
- width: 100%;
3
- min-height: 6rem;
4
- }
5
-
6
- .drop-indicator .ui.message {
7
- /* padding: 0px; */
8
- }
9
-
10
- .drop-indicator .ui.message center {
11
- height: 100%;
12
- /* margin: 0 auto; */
13
- }
14
-
15
- .drop-indicator .ui.message center img {
16
- width: 100%;
17
- height: 100%;
18
- }
@@ -1,49 +0,0 @@
1
- ```
2
- // Overrideable core actions.
3
- // See https://github.com/ianstormtaylor/slate/blob/master/packages/slate/src/interfaces/editor.ts
4
-
5
- apply: (operation: Operation) => void
6
-
7
- // Add a custom property to the leaf text nodes in the current selection.
8
- // If the selection is currently collapsed, the marks will be added to the
9
- // `editor.marks` property instead, and applied when text is inserted next.
10
- addMark: (key: string, value: any) => void
11
-
12
- removeMark: (key: string) => void
13
-
14
- // Delete content in the editor backward from the current selection.
15
- deleteBackward: (unit: 'character' | 'word' | 'line' | 'block') => void
16
- deleteForward: (unit: 'character' | 'word' | 'line' | 'block') => void
17
-
18
- // Insert a fragment at the current selection.
19
- insertFragment: (fragment: Node[]) => void
20
-
21
- // Delete the content in the current selection.
22
- deleteFragment: () => void
23
-
24
- getFragment: () => Descendant[]
25
-
26
- // Insert a block break at the current selection.
27
- // If the selection is currently expanded, it will be deleted first.
28
- insertBreak: () => void
29
-
30
- // Insert a node at the current selection.
31
- // If the selection is currently expanded, it will be deleted first.
32
- insertNode: (node: Node) => void
33
-
34
- // Insert text at the current selection.
35
- // If the selection is currently expanded, it will be deleted first.
36
- insertText: (text: string) => void
37
-
38
- transform:
39
- op types:
40
- insert_node
41
- insert_text
42
- merge_node
43
- move_node
44
- remove_node
45
- remove_text
46
- set_node
47
- set_selection
48
- split_node
49
- ```
@@ -1,100 +0,0 @@
1
- import { Editor, Range, Transforms } from 'slate';
2
- import config from '@plone/volto/registry';
3
- import {
4
- isCursorAtBlockEnd,
5
- splitEditorInTwoFragments,
6
- setEditorContent,
7
- createAndSelectNewBlockAfter,
8
- getCurrentListItem,
9
- createEmptyParagraph,
10
- } from '@plone/volto-slate/utils';
11
-
12
- /**
13
- * Handles `Enter` key on empty and non-empty list items.
14
- *
15
- * @param {Editor} editor The editor which should be modified by this extension
16
- * with a new version of the `insertBreak` method of the Slate editor.
17
- *
18
- * @description If the selection does not exist or is expanded, handle with the
19
- * default behavior. If the selection is inside a LI and it starts at a non-0
20
- * offset, split the LI. If the selection anchor is not in a LI or it is not at
21
- * offset 0, handle with the default behavior. Else delete the line before the
22
- * text cursor and then split the editor in two fragments, and convert them to
23
- * separate Slate Text blocks, based on the selection.
24
- */
25
- export const breakList = (editor) => {
26
- const { insertBreak } = editor;
27
-
28
- editor.insertBreak = () => {
29
- // If the selection does not exist or is expanded, handle with the default
30
- // behavior.
31
- if (!(editor.selection && Range.isCollapsed(editor.selection))) {
32
- insertBreak();
33
- return false;
34
- }
35
-
36
- const { slate } = config.settings;
37
- const { anchor } = editor.selection;
38
-
39
- const ref = Editor.rangeRef(editor, editor.selection, {
40
- affinity: 'inward',
41
- });
42
-
43
- // If the selection is inside a LI and it starts at a non-0 offset, split
44
- // the LI. (if one of the parents is a list item, break that list item)
45
- const [listItem, listItemPath] = getCurrentListItem(editor);
46
- if (listItem) {
47
- // if there is text in the selection
48
- if (Editor.string(editor, listItemPath)) {
49
- Transforms.splitNodes(editor, {
50
- at: editor.selection,
51
- match: (node) => node.type === slate.listItemType,
52
- always: true, // in case cursor is at end of line
53
- });
54
-
55
- return true;
56
- }
57
- }
58
-
59
- // If the selection anchor is not in a LI or it is not at offset 0, handle
60
- // with the default behavior.
61
- const [parent] = Editor.parent(editor, anchor.path); // , parentPath
62
-
63
- if (parent.type !== slate.listItemType || anchor.offset > 0) {
64
- insertBreak();
65
- return; // applies default behaviour, as defined in insertBreak.js extension
66
- }
67
-
68
- if (parent) {
69
- const blockProps = editor.getBlockProps();
70
- const { data } = blockProps;
71
- // Don't add new block if not allowed
72
- if (data?.disableNewBlocks) {
73
- return insertBreak();
74
- }
75
- }
76
-
77
- Editor.deleteBackward(editor, { unit: 'line' });
78
- // also account for empty nodes [{text: ''}]
79
- if (Editor.isEmpty(editor, parent)) {
80
- Transforms.removeNodes(editor, { at: ref.current });
81
- createAndSelectNewBlockAfter(editor, [createEmptyParagraph()]);
82
- return true;
83
- }
84
-
85
- Transforms.removeNodes(editor, { at: ref.current });
86
-
87
- if (isCursorAtBlockEnd(editor)) {
88
- createAndSelectNewBlockAfter(editor, [createEmptyParagraph()]);
89
- return true;
90
- }
91
-
92
- const [top, bottom] = splitEditorInTwoFragments(editor, ref.current);
93
- setEditorContent(editor, top);
94
- createAndSelectNewBlockAfter(editor, bottom);
95
-
96
- return true;
97
- };
98
-
99
- return editor;
100
- };
@@ -1,6 +0,0 @@
1
- export * from './insertBreak';
2
- export * from './withDeserializers';
3
- export * from './breakList';
4
- export * from './withLists';
5
- export * from './isSelected';
6
- export * from './normalizeExternalData';
@@ -1,57 +0,0 @@
1
- import ReactDOM from 'react-dom';
2
- import { Editor } from 'slate';
3
- // import { ReactEditor } from 'slate-react';
4
- import {
5
- splitEditorInTwoFragments,
6
- setEditorContent,
7
- createAndSelectNewBlockAfter,
8
- rangeIsInSplittableNode,
9
- // deconstructToVoltoBlocks,
10
- } from '@plone/volto-slate/utils';
11
-
12
- /**
13
- * @param {Editor} editor The Slate editor object to extend.
14
- * @description If the selection exists and touches with one of its edges a
15
- * closest-to-root `Text` node (`Path` with length `2`)
16
- *
17
- * - if the parent node of the selection exists, split editor into two
18
- * fragments put inside separate Volto Slate Text blocks;
19
- * - if the parent node of the selection does not exist, do nothing;
20
- *
21
- * and if the selection does not exist or does not touch with one of its edges a
22
- * closest-to-root `Text` node, call the default behavior.
23
- */
24
- export const withSplitBlocksOnBreak = (editor) => {
25
- const { insertBreak } = editor;
26
-
27
- editor.insertBreak = () => {
28
- // if selection is expanded, delete it
29
- if (rangeIsInSplittableNode(editor, editor.selection)) {
30
- const block = Editor.parent(editor, editor.selection);
31
-
32
- if (block) {
33
- const blockProps = editor.getBlockProps();
34
- const { data } = blockProps;
35
-
36
- // Don't add new block if not allowed
37
- if (data?.disableNewBlocks) {
38
- return insertBreak();
39
- }
40
-
41
- // TODO: another method would be to simply insert a break and call
42
- // deconstructToVoltoBlocks
43
- ReactDOM.unstable_batchedUpdates(() => {
44
- const [top, bottom] = splitEditorInTwoFragments(editor);
45
- setEditorContent(editor, top);
46
- // ReactEditor.blur(editor);
47
- createAndSelectNewBlockAfter(editor, bottom);
48
- });
49
- }
50
- return;
51
- }
52
-
53
- return insertBreak();
54
- };
55
-
56
- return editor;
57
- };
@@ -1,7 +0,0 @@
1
- export const withIsSelected = (editor) => {
2
- editor.isSelected = () => {
3
- const blockProps = editor.getBlockProps();
4
- return blockProps.selected;
5
- };
6
- return editor;
7
- };
@@ -1,7 +0,0 @@
1
- export function normalizeExternalData(editor) {
2
- editor.normalizeExternalData = (fragment) => {
3
- return fragment; // don't normalize in text block
4
- };
5
-
6
- return editor;
7
- }
@@ -1,87 +0,0 @@
1
- import isUrl from 'is-url';
2
- import imageExtensions from 'image-extensions';
3
- import { blockTagDeserializer } from '@plone/volto-slate/editor/deserialize';
4
- import { getBaseUrl, validateFileUploadSize } from '@plone/volto/helpers';
5
- import { v4 as uuid } from 'uuid';
6
- import { Transforms } from 'slate';
7
-
8
- import { IMAGE } from '@plone/volto-slate/constants';
9
-
10
- export const insertImage = (editor, url, { typeImg = IMAGE } = {}) => {
11
- const image = { type: typeImg, url, children: [{ text: '' }] };
12
- Transforms.insertNodes(editor, image);
13
- };
14
-
15
- export const isImageUrl = (url) => {
16
- if (!isUrl(url)) return false;
17
-
18
- const ext = new URL(url).pathname.split('.').pop();
19
-
20
- return imageExtensions.includes(ext);
21
- };
22
-
23
- export const onImageLoad = (editor, reader) => () => {
24
- const data = reader.result;
25
-
26
- // if (url) insertImage(editor, url);
27
- const fields = data.match(/^data:(.*);(.*),(.*)$/);
28
- const blockProps = editor.getBlockProps();
29
- const { block, uploadContent, pathname } = blockProps;
30
-
31
- // TODO: we need a way to get the uploaded image URL
32
- // This would be easier if we would have block transformers-based image
33
- // blocks
34
- const url = getBaseUrl(pathname);
35
- const uploadId = uuid();
36
- const uploadFileName = `clipboard-${uploadId}`;
37
- const uploadTitle = `Clipboard image`;
38
- const content = {
39
- '@type': 'Image',
40
- title: uploadTitle,
41
- image: {
42
- data: fields[3],
43
- encoding: fields[2],
44
- 'content-type': fields[1],
45
- filename: uploadFileName,
46
- },
47
- };
48
-
49
- uploadContent(url, content, block).then((data) => {
50
- const dlUrl = data.image.download;
51
- insertImage(editor, dlUrl);
52
- });
53
- };
54
-
55
- export const withDeserializers = (editor) => {
56
- editor.htmlTagsToSlate = {
57
- ...editor.htmlTagsToSlate,
58
-
59
- // We don't want H1 tags when pasting, we rewrite them as H2
60
- H1: blockTagDeserializer('h2'),
61
- };
62
-
63
- const handleFiles = editor.dataTransferHandlers?.files || (() => true);
64
-
65
- editor.dataTransferHandlers = {
66
- ...editor.dataTransferHandlers,
67
- files: (files) => {
68
- const unprocessed = [];
69
- const { intl } = editor.getBlockProps();
70
- for (const file of files) {
71
- if (!validateFileUploadSize(file, intl.formatMessage)) return;
72
- const reader = new FileReader();
73
- const [mime] = file.type.split('/');
74
- if (mime === 'image') {
75
- reader.addEventListener('load', onImageLoad(editor, reader));
76
- reader.readAsDataURL(file);
77
- } else {
78
- unprocessed.push(file);
79
- }
80
- }
81
-
82
- return handleFiles(unprocessed);
83
- },
84
- };
85
-
86
- return editor;
87
- };
@@ -1,5 +0,0 @@
1
- export const withLists = (editor) => {
2
- // The code that used to be here was moved to the basic SlateEditor normalizeNode
3
- // In the future, custom behavior for normalizeNode should be added here
4
- return editor;
5
- };