@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,304 +0,0 @@
1
- import ReactDOM from 'react-dom';
2
- import React from 'react';
3
- import { readAsDataURL } from 'promise-file-reader';
4
- import Dropzone from 'react-dropzone';
5
- import { defineMessages, useIntl } from 'react-intl';
6
- import { useInView } from 'react-intersection-observer';
7
- import { Dimmer, Loader, Message, Segment } from 'semantic-ui-react';
8
-
9
- import {
10
- flattenToAppURL,
11
- getBaseUrl,
12
- validateFileUploadSize,
13
- } from '@plone/volto/helpers';
14
- import config from '@plone/volto/registry';
15
- import {
16
- BlockDataForm,
17
- SidebarPortal,
18
- BlockChooserButton,
19
- } from '@plone/volto/components';
20
-
21
- import { SlateEditor } from '@plone/volto-slate/editor';
22
- import { serializeNodesToText } from '@plone/volto-slate/editor/render';
23
- import {
24
- createImageBlock,
25
- parseDefaultSelection,
26
- deconstructToVoltoBlocks,
27
- } from '@plone/volto-slate/utils';
28
- import { Transforms } from 'slate';
29
-
30
- import PersistentSlashMenu from './SlashMenu';
31
- import ShortcutListing from './ShortcutListing';
32
- import MarkdownIntroduction from './MarkdownIntroduction';
33
- import { handleKey } from './keyboard';
34
- import TextBlockSchema from './schema';
35
-
36
- import imageBlockSVG from '@plone/volto/components/manage/Blocks/Image/block-image.svg';
37
-
38
- import './css/editor.css';
39
-
40
- // TODO: refactor dropzone to separate component wrapper
41
-
42
- const messages = defineMessages({
43
- text: {
44
- id: 'Type text…',
45
- defaultMessage: 'Type text…',
46
- },
47
- });
48
-
49
- const DEBUG = false;
50
-
51
- export const DefaultTextBlockEditor = (props) => {
52
- const {
53
- block,
54
- blocksConfig,
55
- data,
56
- detached = false,
57
- index,
58
- onChangeBlock,
59
- onInsertBlock,
60
- onMutateBlock,
61
- onSelectBlock,
62
- pathname,
63
- properties,
64
- selected,
65
- uploadRequest,
66
- uploadContent,
67
- uploadedContent,
68
- defaultSelection,
69
- saveSlateBlockSelection,
70
- allowedBlocks,
71
- formTitle,
72
- formDescription,
73
- } = props;
74
-
75
- const { slate } = config.settings;
76
- const { textblockExtensions } = slate;
77
- const { value } = data;
78
- const intl = useIntl();
79
-
80
- // const [addNewBlockOpened, setAddNewBlockOpened] = React.useState();
81
- const [showDropzone, setShowDropzone] = React.useState(false);
82
- const [uploading, setUploading] = React.useState(false);
83
- const [newImageId, setNewImageId] = React.useState(null);
84
-
85
- const prevReq = React.useRef(null);
86
-
87
- const withBlockProperties = React.useCallback(
88
- (editor) => {
89
- editor.getBlockProps = () => props;
90
- return editor;
91
- },
92
- [props],
93
- );
94
-
95
- const slateSettings = React.useMemo(
96
- () => ({
97
- ...config.settings.slate,
98
- persistentHelpers: [
99
- ...config.settings.slate.persistentHelpers,
100
- PersistentSlashMenu,
101
- ],
102
- }),
103
- [],
104
- );
105
-
106
- const onDrop = React.useCallback(
107
- (files) => {
108
- // TODO: need to fix setUploading, treat uploading indicator
109
- // inteligently, show progress report on uploading files
110
- setUploading(true);
111
- files.forEach((file) => {
112
- const [mime] = file.type.split('/');
113
- if (mime !== 'image') return;
114
- if (!validateFileUploadSize(file, intl.formatMessage)) return;
115
-
116
- readAsDataURL(file).then((data) => {
117
- const fields = data.match(/^data:(.*);(.*),(.*)$/);
118
- uploadContent(
119
- getBaseUrl(pathname),
120
- {
121
- '@type': 'Image',
122
- title: file.name,
123
- image: {
124
- data: fields[3],
125
- encoding: fields[2],
126
- 'content-type': fields[1],
127
- filename: file.name,
128
- },
129
- },
130
- block,
131
- );
132
- });
133
- });
134
- setShowDropzone(false);
135
- },
136
- [pathname, uploadContent, block, intl.formatMessage],
137
- );
138
-
139
- const { loaded, loading } = uploadRequest;
140
- const imageId = uploadedContent['@id'];
141
- const prevLoaded = prevReq.current;
142
-
143
- React.useEffect(() => {
144
- if (loaded && !loading && !prevLoaded && newImageId !== imageId) {
145
- const url = flattenToAppURL(imageId);
146
- setNewImageId(imageId);
147
-
148
- createImageBlock(url, index, props);
149
- }
150
- prevReq.current = loaded;
151
- }, [props, loaded, loading, prevLoaded, imageId, newImageId, index]);
152
-
153
- const handleUpdate = React.useCallback(
154
- (editor) => {
155
- // defaultSelection is used for things such as "restoring" the selection
156
- // when joining blocks or moving the selection to block start on block
157
- // split
158
- if (defaultSelection) {
159
- const selection = parseDefaultSelection(editor, defaultSelection);
160
- if (selection) {
161
- Transforms.select(editor, selection);
162
- saveSlateBlockSelection(block, null);
163
- }
164
- }
165
- },
166
- [defaultSelection, block, saveSlateBlockSelection],
167
- );
168
-
169
- const onEditorChange = (value, editor) => {
170
- ReactDOM.unstable_batchedUpdates(() => {
171
- onChangeBlock(block, {
172
- ...data,
173
- value,
174
- plaintext: serializeNodesToText(value || []),
175
- // TODO: also add html serialized value
176
- });
177
- deconstructToVoltoBlocks(editor);
178
- });
179
- };
180
-
181
- // Get editing instructions from block settings or props
182
- let instructions = data?.instructions?.data || data?.instructions;
183
- if (!instructions || instructions === '<p><br/></p>') {
184
- instructions = formDescription;
185
- }
186
-
187
- const placeholder =
188
- data.placeholder || formTitle || intl.formatMessage(messages.text);
189
- const schema = TextBlockSchema(data);
190
-
191
- const disableNewBlocks = data?.disableNewBlocks || detached;
192
- const { ref, inView } = useInView({
193
- threshold: 0,
194
- rootMargin: '0px 0px 200px 0px',
195
- });
196
-
197
- const handleFocus = React.useCallback(() => {
198
- if (!selected) {
199
- onSelectBlock(block);
200
- }
201
- }, [onSelectBlock, selected, block]);
202
-
203
- return (
204
- <div className="text-slate-editor-inner" ref={ref}>
205
- <>
206
- <Dropzone
207
- disableClick
208
- onDrop={onDrop}
209
- className="dropzone"
210
- onDragOver={() => setShowDropzone(true)}
211
- onDragLeave={() => setShowDropzone(false)}
212
- >
213
- {({ getRootProps, getInputProps }) => {
214
- return showDropzone ? (
215
- <div className="drop-indicator">
216
- {uploading ? (
217
- <Dimmer active>
218
- <Loader indeterminate>Uploading image</Loader>
219
- </Dimmer>
220
- ) : (
221
- <Message>
222
- <center>
223
- <img src={imageBlockSVG} alt="" />
224
- </center>
225
- </Message>
226
- )}
227
- </div>
228
- ) : (
229
- <>
230
- <SlateEditor
231
- index={index}
232
- readOnly={!inView}
233
- properties={properties}
234
- extensions={textblockExtensions}
235
- renderExtensions={[withBlockProperties]}
236
- value={value}
237
- block={block /* is this needed? */}
238
- defaultSelection={defaultSelection}
239
- onUpdate={handleUpdate}
240
- debug={DEBUG}
241
- onFocus={handleFocus}
242
- onChange={(value, editor) => onEditorChange(value, editor)}
243
- onKeyDown={handleKey}
244
- selected={selected}
245
- placeholder={placeholder}
246
- slateSettings={slateSettings}
247
- editableProps={{ 'aria-multiline': 'false' }}
248
- />
249
- {DEBUG ? <div>{block}</div> : ''}
250
- </>
251
- );
252
- }}
253
- </Dropzone>
254
-
255
- {!config.experimental.addBlockButton.enabled &&
256
- selected &&
257
- !data.plaintext?.trim() &&
258
- !disableNewBlocks && (
259
- <BlockChooserButton
260
- data={data}
261
- block={block}
262
- onInsertBlock={(id, value) => {
263
- onSelectBlock(onInsertBlock(id, value));
264
- }}
265
- onMutateBlock={onMutateBlock}
266
- allowedBlocks={allowedBlocks}
267
- blocksConfig={blocksConfig}
268
- size="24px"
269
- properties={properties}
270
- />
271
- )}
272
-
273
- <SidebarPortal selected={selected}>
274
- <div id="slate-plugin-sidebar"></div>
275
- {instructions ? (
276
- <Segment attached>
277
- <div dangerouslySetInnerHTML={{ __html: instructions }} />
278
- </Segment>
279
- ) : (
280
- <>
281
- <ShortcutListing />
282
- <MarkdownIntroduction />
283
- <BlockDataForm
284
- block={block}
285
- schema={schema}
286
- title={schema.title}
287
- onChangeBlock={onChangeBlock}
288
- onChangeField={(id, value) => {
289
- onChangeBlock(block, {
290
- ...data,
291
- [id]: value,
292
- });
293
- }}
294
- formData={data}
295
- />
296
- </>
297
- )}
298
- </SidebarPortal>
299
- </>
300
- </div>
301
- );
302
- };
303
-
304
- export default DefaultTextBlockEditor;
@@ -1,77 +0,0 @@
1
- import React from 'react';
2
- import { defineMessages, useIntl } from 'react-intl';
3
- import { useInView } from 'react-intersection-observer';
4
- import { SlateEditor } from '@plone/volto-slate/editor';
5
- import { serializeNodesToText } from '@plone/volto-slate/editor/render';
6
- import { handleKeyDetached } from './keyboard';
7
-
8
- const DEBUG = false;
9
-
10
- const messages = defineMessages({
11
- text: {
12
- id: 'Type text…',
13
- defaultMessage: 'Type text…',
14
- },
15
- });
16
-
17
- export const DetachedTextBlockEditor = (props) => {
18
- const {
19
- data,
20
- index,
21
- properties,
22
- onSelectBlock,
23
- onChangeBlock,
24
- block,
25
- selected,
26
- formTitle,
27
- formDescription,
28
- } = props;
29
- const { value } = data;
30
-
31
- const intl = useIntl();
32
- const placeholder =
33
- data.placeholder || formTitle || intl.formatMessage(messages.text);
34
- let instructions = data?.instructions?.data || data?.instructions;
35
- if (!instructions || instructions === '<p><br/></p>') {
36
- instructions = formDescription;
37
- }
38
-
39
- const { ref, inView } = useInView({
40
- threshold: 0,
41
- rootMargin: '0px 0px 200px 0px',
42
- });
43
-
44
- return (
45
- <div className="text-slate-editor-inner detached-slate-editor" ref={ref}>
46
- <SlateEditor
47
- index={index}
48
- readOnly={!inView}
49
- properties={properties}
50
- renderExtensions={[]}
51
- value={value}
52
- block={block /* is this needed? */}
53
- debug={DEBUG}
54
- slateSettings={props.slateSettings}
55
- onFocus={() => {
56
- if (!selected) {
57
- onSelectBlock(block);
58
- }
59
- }}
60
- onChange={(value, selection, editor) => {
61
- onChangeBlock(block, {
62
- ...data,
63
- value,
64
- plaintext: serializeNodesToText(value || []),
65
- // TODO: also add html serialized value
66
- });
67
- }}
68
- selected={selected}
69
- placeholder={placeholder}
70
- onKeyDown={handleKeyDetached}
71
- editableProps={{ 'aria-multiline': 'true' }}
72
- />
73
- </div>
74
- );
75
- };
76
-
77
- export default DetachedTextBlockEditor;
@@ -1,59 +0,0 @@
1
- import { Segment, List } from 'semantic-ui-react';
2
- import React from 'react';
3
-
4
- /**
5
- * A component to be shown in the sidebar as a introduction to the Markdown support in the Slate-based Text block. It renders a header and a list and has no state.
6
- * @param {object} props Can be an empty object (no props are used in this component).
7
- */
8
- const MarkdownIntroduction = (props) => {
9
- return (
10
- <div>
11
- <header className="header">
12
- <h2>Markdown shortcuts</h2>
13
- </header>
14
-
15
- <Segment secondary attached style={{ fontFamily: 'monospace' }}>
16
- <List>
17
- <List.Item key={1} style={{ fontSize: 'xx-large' }}>
18
- # Title
19
- </List.Item>
20
- <List.Item key={2} style={{ fontSize: 'x-large' }}>
21
- ## Subtitle
22
- </List.Item>
23
-
24
- <List.Item key={3} style={{ paddingTop: '1rem' }}>
25
- * unordered list item
26
- </List.Item>
27
- <List.Item key={4}>+ unordered list item</List.Item>
28
- <List.Item key={5}>- unordered list item</List.Item>
29
-
30
- <List.Item key={6} style={{ paddingTop: '1rem' }}>
31
- 1. ordered list item
32
- </List.Item>
33
- <List.Item key={7}>1) ordered list item</List.Item>
34
-
35
- <List.Item key={8} className="callout">
36
- &gt; block quote
37
- </List.Item>
38
- <List.Item key={9} style={{ fontWeight: 'bold' }}>
39
- **bold text**
40
- </List.Item>
41
- <List.Item key={10} style={{ fontWeight: 'bold' }}>
42
- __bold text__
43
- </List.Item>
44
- <List.Item key={11} style={{ fontStyle: 'italic' }}>
45
- *italic text*
46
- </List.Item>
47
- <List.Item key={12} style={{ fontStyle: 'italic' }}>
48
- _italic text_
49
- </List.Item>
50
- <List.Item key={13} style={{ textDecoration: 'line-through' }}>
51
- ~~strikethrough text~~
52
- </List.Item>
53
- </List>
54
- </Segment>
55
- </div>
56
- );
57
- };
58
-
59
- export default MarkdownIntroduction;
@@ -1,18 +0,0 @@
1
- import React from 'react';
2
- import { Portal } from 'react-portal';
3
-
4
- const PluginSidebar = ({ children, selected }) => {
5
- return (
6
- <>
7
- {selected && (
8
- <Portal
9
- node={__CLIENT__ && document.getElementById('slate-plugin-sidebar')}
10
- >
11
- {children}
12
- </Portal>
13
- )}
14
- </>
15
- );
16
- };
17
-
18
- export default PluginSidebar;
@@ -1,28 +0,0 @@
1
- import { Segment, List } from 'semantic-ui-react';
2
- import config from '@plone/volto/registry';
3
- import React from 'react';
4
-
5
- const ShortcutListing = (props) => {
6
- const hotkeys = config.settings?.slate?.hotkeys;
7
- return (
8
- <div>
9
- <header className="header">
10
- <h2>Editor shortcuts</h2>
11
- </header>
12
-
13
- <Segment secondary attached>
14
- <List>
15
- <List.Item>
16
- Type a slash (<em>/</em>) to change block type
17
- </List.Item>
18
- {Object.entries(hotkeys || {}).map(([shortcut, { format, type }]) => (
19
- <List.Item key={shortcut}>{`${shortcut}: ${format}`}</List.Item>
20
- ))}
21
- </List>
22
- <div>On Windows, the MOD key is Ctrl, on Mac OS X it's Cmd.</div>
23
- </Segment>
24
- </div>
25
- );
26
- };
27
-
28
- export default ShortcutListing;
@@ -1,203 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import { filter, isEmpty } from 'lodash';
4
- import { Menu } from 'semantic-ui-react';
5
- import { useIntl, FormattedMessage } from 'react-intl';
6
- import { Icon } from '@plone/volto/components';
7
-
8
- const emptySlateBlock = () => ({
9
- value: [
10
- {
11
- children: [
12
- {
13
- text: '',
14
- },
15
- ],
16
- type: 'p',
17
- },
18
- ],
19
- plaintext: '',
20
- });
21
-
22
- const useIsMounted = () => {
23
- const ref = React.useRef();
24
- React.useEffect(() => {
25
- ref.current = true;
26
- return () => (ref.current = false);
27
- }, []);
28
- return ref.current;
29
- };
30
-
31
- const SlashMenu = ({
32
- currentBlock,
33
- onMutateBlock,
34
- selected,
35
- availableBlocks,
36
- }) => {
37
- const intl = useIntl();
38
-
39
- return (
40
- <div className="power-user-menu">
41
- <Menu vertical fluid borderless>
42
- {availableBlocks.map((block, index) => (
43
- <Menu.Item
44
- key={block.id}
45
- className={block.id}
46
- active={index === selected}
47
- onClick={(e) => {
48
- // onInsertBlock(currentBlock, { '@type': block.id });
49
- onMutateBlock(currentBlock, { '@type': block.id });
50
- e.stopPropagation();
51
- }}
52
- >
53
- <Icon name={block.icon} size="24px" />
54
- {intl.formatMessage({
55
- id: block.title,
56
- defaultMessage: block.title,
57
- })}
58
- </Menu.Item>
59
- ))}
60
- {availableBlocks.length === 0 && (
61
- <Menu.Item>
62
- <FormattedMessage
63
- id="No matching blocks"
64
- defaultMessage="No matching blocks"
65
- />
66
- </Menu.Item>
67
- )}
68
- </Menu>
69
- </div>
70
- );
71
- };
72
-
73
- SlashMenu.propTypes = {
74
- currentBlock: PropTypes.string.isRequired,
75
- onInsertBlock: PropTypes.func,
76
- selected: PropTypes.number,
77
- blocksConfig: PropTypes.arrayOf(PropTypes.any),
78
- };
79
-
80
- const translateBlockTitle = (block, intl) =>
81
- intl.formatMessage({
82
- id: block.title,
83
- defaultMessage: block.title,
84
- });
85
- const scoreBlock = (block, slashCommand, intl) => {
86
- if (!slashCommand) return 0;
87
- const title = translateBlockTitle(block, intl).toLowerCase();
88
- // prefer initial title matches, then title substring matches
89
- if (title.indexOf(slashCommand[1]) === 0) return 2;
90
- if (title.indexOf(slashCommand[1]) !== -1) return 1;
91
- };
92
-
93
- /**
94
- * A SlashMenu wrapper implemented as a volto-slate PersistentHelper.
95
- */
96
- const PersistentSlashMenu = ({ editor }) => {
97
- const props = editor.getBlockProps();
98
- const intl = useIntl();
99
- const {
100
- block,
101
- blocksConfig,
102
- data,
103
- onMutateBlock,
104
- properties,
105
- selected,
106
- allowedBlocks,
107
- detached,
108
- } = props;
109
- const disableNewBlocks = data?.disableNewBlocks || detached;
110
-
111
- const [slashMenuSelected, setSlashMenuSelected] = React.useState(0);
112
-
113
- const hasAllowedBlocks = !isEmpty(allowedBlocks);
114
- const slashCommand = data.plaintext
115
- ?.toLowerCase()
116
- .trim()
117
- .match(/^\/([a-z]*)$/);
118
-
119
- const availableBlocks = React.useMemo(
120
- () =>
121
- filter(blocksConfig, (item) =>
122
- hasAllowedBlocks
123
- ? allowedBlocks.includes(item.id)
124
- : typeof item.restricted === 'function'
125
- ? !item.restricted({ properties, block: item })
126
- : !item.restricted,
127
- )
128
- .filter((block) => Boolean(block.title && block.id))
129
- .filter((block) => {
130
- // typed text is a substring of the title or id
131
- const title = translateBlockTitle(block, intl).toLowerCase();
132
- return (
133
- block.id !== 'slate' &&
134
- slashCommand &&
135
- title.indexOf(slashCommand[1]) !== -1
136
- );
137
- })
138
- .sort((a, b) => {
139
- const scoreDiff =
140
- scoreBlock(b, slashCommand, intl) -
141
- scoreBlock(a, slashCommand, intl);
142
- if (scoreDiff) return scoreDiff;
143
- // sort equally scored blocks by title
144
- return translateBlockTitle(a, intl).localeCompare(
145
- translateBlockTitle(b, intl),
146
- );
147
- }),
148
- [
149
- allowedBlocks,
150
- blocksConfig,
151
- intl,
152
- properties,
153
- slashCommand,
154
- hasAllowedBlocks,
155
- ],
156
- );
157
-
158
- const slashMenuSize = availableBlocks.length;
159
- const show = selected && slashCommand && !disableNewBlocks;
160
-
161
- const isMounted = useIsMounted();
162
-
163
- React.useEffect(() => {
164
- if (isMounted && show && slashMenuSelected > slashMenuSize - 1) {
165
- setSlashMenuSelected(slashMenuSize - 1);
166
- }
167
- }, [show, slashMenuSelected, isMounted, slashMenuSize]);
168
-
169
- editor.showSlashMenu = show;
170
-
171
- editor.slashEnter = () =>
172
- slashMenuSize > 0 &&
173
- onMutateBlock(
174
- block,
175
- {
176
- '@type': availableBlocks[slashMenuSelected].id,
177
- },
178
- emptySlateBlock(),
179
- );
180
-
181
- editor.slashArrowUp = () =>
182
- setSlashMenuSelected(
183
- slashMenuSelected === 0 ? slashMenuSize - 1 : slashMenuSelected - 1,
184
- );
185
-
186
- editor.slashArrowDown = () =>
187
- setSlashMenuSelected(
188
- slashMenuSelected >= slashMenuSize - 1 ? 0 : slashMenuSelected + 1,
189
- );
190
-
191
- return show ? (
192
- <SlashMenu
193
- currentBlock={block}
194
- onMutateBlock={onMutateBlock}
195
- availableBlocks={availableBlocks}
196
- selected={slashMenuSelected}
197
- />
198
- ) : (
199
- ''
200
- );
201
- };
202
-
203
- export default PersistentSlashMenu;