@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,153 +0,0 @@
1
- import React from 'react';
2
- import { useSlate } from 'slate-react';
3
- import { Dropdown } from 'semantic-ui-react';
4
- import { useIntl, defineMessages } from 'react-intl';
5
- import cx from 'classnames';
6
- import { omit } from 'lodash';
7
- import { isBlockStyleActive, isInlineStyleActive, toggleStyle } from './utils';
8
- import config from '@plone/volto/registry';
9
- import { ToolbarButton } from '@plone/volto-slate/editor/ui';
10
- import paintSVG from '@plone/volto/icons/paint.svg';
11
-
12
- const messages = defineMessages({
13
- inlineStyle: {
14
- id: 'Inline Style',
15
- defaultMessage: 'Inline Style',
16
- },
17
- paragraphStyle: {
18
- id: 'Paragraph Style',
19
- defaultMessage: 'Paragraph Style',
20
- },
21
- additionalStyles: {
22
- id: 'Additional Styles',
23
- defaultMessage: 'Additional Styles',
24
- },
25
- });
26
-
27
- const StyleMenuButton = ({ icon, active, ...props }) => (
28
- <ToolbarButton {...props} icon={icon} active={active} />
29
- );
30
-
31
- const MenuOpts = ({ editor, toSelect, option, type }) => {
32
- const isActive = toSelect.includes(option);
33
- return (
34
- <Dropdown.Item
35
- as="span"
36
- active={isActive}
37
- className={cx(`${type}-${option.value}`, { active: isActive })}
38
- {...omit(option, ['isBlock'])}
39
- data-isblock={option.isBlock}
40
- onClick={(event, selItem) => {
41
- toggleStyle(editor, {
42
- cssClass: selItem.value,
43
- isBlock: selItem.isBlock,
44
- });
45
- }}
46
- />
47
- );
48
- };
49
-
50
- const StylingsButton = (props) => {
51
- const editor = useSlate();
52
- const intl = useIntl();
53
-
54
- // Converting the settings to a format that is required by dropdowns.
55
- const inlineOpts = [
56
- ...config.settings.slate.styleMenu.inlineStyles.map((def) => {
57
- return {
58
- value: def.cssClass,
59
- text: def.label,
60
- icon: def.icon,
61
- isBlock: false,
62
- };
63
- }),
64
- ];
65
- const blockOpts = [
66
- ...config.settings.slate.styleMenu.blockStyles.map((def) => {
67
- return {
68
- value: def.cssClass,
69
- text: def.label,
70
- icon: def.icon,
71
- isBlock: true,
72
- };
73
- }),
74
- ];
75
-
76
- // Calculating the initial selection.
77
- const toSelect = [];
78
- // block styles
79
- for (const val of blockOpts) {
80
- const ia = isBlockStyleActive(editor, val.value);
81
- if (ia) {
82
- toSelect.push(val);
83
- }
84
- }
85
- // inline styles
86
- for (const val of inlineOpts) {
87
- const ia = isInlineStyleActive(editor, val.value);
88
- if (ia) {
89
- toSelect.push(val);
90
- }
91
- }
92
-
93
- const menuItemProps = {
94
- toSelect,
95
- editor,
96
- };
97
- const showMenu = inlineOpts.length || blockOpts.length;
98
- return showMenu ? (
99
- <Dropdown
100
- id="style-menu"
101
- pointing="top left"
102
- multiple
103
- value={toSelect}
104
- disabled={config.settings.slate.styleMenu.disabled ?? false}
105
- additionLabel={intl.formatMessage(messages.additionalStyles)}
106
- trigger={
107
- <StyleMenuButton
108
- title={intl.formatMessage(messages.additionalStyles)}
109
- icon={paintSVG}
110
- active={toSelect.length > 0}
111
- />
112
- }
113
- >
114
- <Dropdown.Menu>
115
- {inlineOpts.length && (
116
- <>
117
- <Dropdown.Header
118
- content={intl.formatMessage(messages.inlineStyle)}
119
- />
120
- {inlineOpts.map((option, index) => (
121
- <MenuOpts
122
- {...menuItemProps}
123
- type="inline-style"
124
- option={option}
125
- key={index}
126
- />
127
- ))}
128
- </>
129
- )}
130
-
131
- {blockOpts.length && (
132
- <>
133
- <Dropdown.Header
134
- content={intl.formatMessage(messages.paragraphStyle)}
135
- />
136
- {blockOpts.map((option, index) => (
137
- <MenuOpts
138
- {...menuItemProps}
139
- type="block-style"
140
- option={option}
141
- key={index}
142
- />
143
- ))}
144
- </>
145
- )}
146
- </Dropdown.Menu>
147
- </Dropdown>
148
- ) : (
149
- ''
150
- );
151
- };
152
-
153
- export default StylingsButton;
@@ -1,19 +0,0 @@
1
- import React from 'react';
2
- import StyleMenu from './StyleMenu';
3
- import './style.less';
4
-
5
- export default function install(config) {
6
- const { slate } = config.settings;
7
-
8
- slate.buttons.styleMenu = (props) => <StyleMenu {...props} title="Styles" />;
9
-
10
- slate.toolbarButtons.push('styleMenu');
11
- slate.expandedToolbarButtons.push('styleMenu');
12
-
13
- slate.styleMenu = {
14
- inlineStyles: [],
15
- blockStyles: [],
16
- };
17
-
18
- return config;
19
- }
@@ -1,29 +0,0 @@
1
- #style-menu.ui.dropdown .menu {
2
- .item {
3
- display: flex;
4
- user-select: none;
5
-
6
- span.text {
7
- margin-top: auto;
8
- line-height: normal;
9
- vertical-align: middle;
10
- }
11
- }
12
-
13
- .header {
14
- color: rgb(153, 153, 153);
15
- font-size: 1rem;
16
- font-weight: normal;
17
- }
18
-
19
- .active {
20
- z-index: 1;
21
- background: #68778d;
22
- box-shadow: none;
23
- color: #ffffff;
24
- font-weight: 300;
25
- }
26
-
27
- overflow: auto;
28
- max-height: 50vh;
29
- }
@@ -1,168 +0,0 @@
1
- /* eslint no-console: ["error", { allow: ["warn", "error"] }] */
2
- import { Editor, Transforms } from 'slate';
3
- import { isBlockActive } from '@plone/volto-slate/utils';
4
- import config from '@plone/volto/registry';
5
-
6
- /**
7
- * Toggles a style (e.g. in the StyleMenu plugin).
8
- * @param {Editor} editor
9
- * @param {object} options
10
- * @param {boolean} options.isRequested Whether the given style is requested by
11
- * the user. The style is only applied if it is requested and only removed if it
12
- * is not requested.
13
- */
14
- export const toggleStyle = (editor, { cssClass, isBlock, isRequested }) => {
15
- if (isBlock) {
16
- toggleBlockStyle(editor, cssClass);
17
- } else {
18
- toggleInlineStyle(editor, cssClass);
19
- }
20
- };
21
-
22
- export const toggleBlockStyle = (editor, style) => {
23
- // We have 6 boolean variables which need to be accounted for.
24
- // See https://docs.google.com/spreadsheets/d/1mVeMuqSTMABV2BhoHPrPAFjn7zUksbNgZ9AQK_dcd3U/edit?usp=sharing
25
- const { slate } = config.settings;
26
-
27
- const isListItem = isBlockActive(editor, slate.listItemType);
28
- const isActive = isBlockStyleActive(editor, style);
29
- const wantsList = false;
30
-
31
- if (isListItem && !wantsList) {
32
- toggleBlockStyleAsListItem(editor, style);
33
- } else if (isListItem && wantsList && !isActive) {
34
- // switchListType(editor, format); // this will deconstruct to Volto blocks
35
- } else if (!isListItem && wantsList) {
36
- // changeBlockToList(editor, format);
37
- } else if (!isListItem && !wantsList) {
38
- internalToggleBlockStyle(editor, style);
39
- } else {
40
- console.warn('toggleBlockStyle case not covered, please examine:', {
41
- wantsList,
42
- isActive,
43
- isListItem,
44
- });
45
- }
46
- };
47
-
48
- export const toggleInlineStyle = (editor, style) => {
49
- // We have 6 boolean variables which need to be accounted for.
50
- // See https://docs.google.com/spreadsheets/d/1mVeMuqSTMABV2BhoHPrPAFjn7zUksbNgZ9AQK_dcd3U/edit?usp=sharing
51
- const { slate } = config.settings;
52
-
53
- const isListItem = isBlockActive(editor, slate.listItemType);
54
- const isActive = isInlineStyleActive(editor, style);
55
- const wantsList = false;
56
-
57
- if (isListItem && !wantsList) {
58
- toggleInlineStyleAsListItem(editor, style);
59
- } else if (isListItem && wantsList && !isActive) {
60
- // switchListType(editor, format); // this will deconstruct to Volto blocks
61
- } else if (!isListItem && wantsList) {
62
- // changeBlockToList(editor, format);
63
- } else if (!isListItem && !wantsList) {
64
- internalToggleInlineStyle(editor, style);
65
- } else {
66
- console.warn('toggleInlineStyle case not covered, please examine:', {
67
- wantsList,
68
- isActive,
69
- isListItem,
70
- });
71
- }
72
- };
73
-
74
- export const isBlockStyleActive = (editor, style) => {
75
- const keyName = `style-${style}`;
76
- const sn = Array.from(
77
- Editor.nodes(editor, {
78
- match: (n) => {
79
- const isStyle = typeof n.styleName === 'string' || n[keyName];
80
- return !Editor.isEditor(n) && isStyle;
81
- },
82
- mode: 'all',
83
- }),
84
- );
85
-
86
- for (const [n] of sn) {
87
- if (typeof n.styleName === 'string') {
88
- if (n.styleName.split(' ').filter((x) => x === style).length > 0) {
89
- return true;
90
- }
91
- } else if (
92
- n[keyName] &&
93
- keyName.split('-').filter((x) => x === style).length > 0
94
- )
95
- return true;
96
- }
97
- return false;
98
- };
99
-
100
- export const isInlineStyleActive = (editor, style) => {
101
- const m = Editor.marks(editor);
102
- const keyName = `style-${style}`;
103
- if (m && m[keyName]) {
104
- return true;
105
- }
106
- return false;
107
- };
108
-
109
- export const internalToggleBlockStyle = (editor, style) => {
110
- toggleBlockStyleInSelection(editor, style);
111
- };
112
-
113
- export const internalToggleInlineStyle = (editor, style) => {
114
- toggleInlineStyleInSelection(editor, style);
115
- };
116
-
117
- /*
118
- * Applies a block format unto a list item. Will split the list and deconstruct the
119
- * block
120
- */
121
- export const toggleBlockStyleAsListItem = (editor, style) => {
122
- toggleBlockStyleInSelection(editor, style);
123
- };
124
-
125
- /*
126
- * Applies an inline style unto a list item.
127
- */
128
- export const toggleInlineStyleAsListItem = (editor, style) => {
129
- toggleInlineStyleInSelection(editor, style);
130
- };
131
-
132
- function toggleInlineStyleInSelection(editor, style) {
133
- const m = Editor.marks(editor);
134
- const keyName = 'style-' + style;
135
-
136
- if (m && m[keyName]) {
137
- Editor.removeMark(editor, keyName);
138
- } else {
139
- Editor.addMark(editor, keyName, true);
140
- }
141
- }
142
-
143
- function toggleBlockStyleInSelection(editor, style) {
144
- const sn = Array.from(
145
- Editor.nodes(editor, {
146
- mode: 'highest',
147
- match: (n) => {
148
- return !Editor.isEditor(n);
149
- },
150
- }),
151
- );
152
-
153
- for (const [n, p] of sn) {
154
- let cn = n.styleName;
155
- if (typeof n.styleName !== 'string') {
156
- cn = style;
157
- } else if (n.styleName.split(' ').filter((x) => x === style).length > 0) {
158
- cn = cn
159
- .split(' ')
160
- .filter((x) => x !== style)
161
- .join(' ');
162
- } else {
163
- // the style is not set but other styles are set
164
- cn = cn.split(' ').concat(style).join(' ');
165
- }
166
- Transforms.setNodes(editor, { styleName: cn }, { at: p });
167
- }
168
- }
@@ -1,142 +0,0 @@
1
- import React from 'react';
2
- import { useSlate } from 'slate-react';
3
- import { Dropdown } from 'semantic-ui-react';
4
- import { ToolbarButton } from '@plone/volto-slate/editor/ui';
5
-
6
- import tableSVG from '@plone/volto/icons/table.svg';
7
- import TableContainer from './TableContainer';
8
- import './less/table.less';
9
- import { Editor, Transforms } from 'slate';
10
-
11
- const TableButton = ({ ...props }) => {
12
- const editor = useSlate();
13
-
14
- const [dropdownOpen, setDropdownOpen] = React.useState(false);
15
-
16
- const [activeRow, setActiveRow] = React.useState(1);
17
- const [activeColumn, setActiveColumn] = React.useState(1);
18
-
19
- const defaultRowCount = 5;
20
- const defaultColumnCount = 5;
21
-
22
- const [rowCount, setRowCount] = React.useState(defaultRowCount);
23
- const [columnCount, setColumnCount] = React.useState(defaultColumnCount);
24
-
25
- const resetState = React.useCallback(() => {
26
- setRowCount(defaultRowCount);
27
- setColumnCount(defaultColumnCount);
28
- setActiveRow(1);
29
- setActiveColumn(1);
30
- }, []);
31
-
32
- const createEmptyCell = React.useCallback((formatAsColumnHeaders = false) => {
33
- return {
34
- type: formatAsColumnHeaders ? 'th' : 'td',
35
- children: [{ type: 'p', children: [{ text: '' }] }],
36
- };
37
- }, []);
38
-
39
- const createEmptyRow = React.useCallback(
40
- (cellCount, formatAsColumnHeaders = false) => {
41
- // should contain at least one <td> or it is not valid that children is empty
42
- const row = { type: 'tr', children: [] };
43
-
44
- for (let i = 0; i < cellCount; ++i) {
45
- row.children.push(createEmptyCell(formatAsColumnHeaders));
46
- }
47
-
48
- return row;
49
- },
50
- [createEmptyCell],
51
- );
52
-
53
- /**
54
- * @param {number} row Number of rows for the new empty table.
55
- * @param {number} column Number of columns for the new empty table.
56
- */
57
- const insertEmptyTable = React.useCallback(
58
- ({ row, column }) => {
59
- const rows = [createEmptyRow(column, true)];
60
- for (let i = 0; i < row - 1; ++i) {
61
- rows.push(createEmptyRow(column));
62
- }
63
-
64
- const table = {
65
- type: 'table',
66
- children: [
67
- {
68
- type: 'tbody',
69
- children: rows,
70
- },
71
- ],
72
- };
73
-
74
- Transforms.insertNodes(editor, [table], {
75
- at: Editor.end(editor, []),
76
- });
77
- },
78
- [createEmptyRow, editor],
79
- );
80
-
81
- return (
82
- <>
83
- <Dropdown
84
- open={dropdownOpen}
85
- onClose={() => {
86
- resetState();
87
- setDropdownOpen(false);
88
- }}
89
- trigger={
90
- <ToolbarButton
91
- {...props}
92
- className="slate-table-dropdown-button"
93
- onClick={() => {
94
- if (dropdownOpen) {
95
- resetState();
96
- }
97
-
98
- setDropdownOpen(!dropdownOpen);
99
- }}
100
- icon={tableSVG}
101
- ></ToolbarButton>
102
- }
103
- >
104
- <Dropdown.Menu className="slate-table-dropdown-menu">
105
- <TableContainer
106
- rowCount={rowCount}
107
- columnCount={columnCount}
108
- activeColumn={activeColumn}
109
- activeRow={activeRow}
110
- onCellMouseEnter={({ row, column }) => {
111
- if (row > rowCount - 1) {
112
- setRowCount(row + 1);
113
- } else if (row < rowCount - 1) {
114
- setRowCount(defaultRowCount);
115
- }
116
-
117
- if (column > columnCount - 1) {
118
- setColumnCount(column + 1);
119
- } else if (column < columnCount - 1) {
120
- setColumnCount(defaultColumnCount);
121
- }
122
-
123
- if (row !== activeRow) {
124
- setActiveRow(row);
125
- }
126
- if (column !== activeColumn) {
127
- setActiveColumn(column);
128
- }
129
- }}
130
- onCellMouseLeave={({ row, column }) => {}}
131
- // `row` and `column` below are 1-based indices
132
- onCellClick={({ row, column }) => {
133
- insertEmptyTable({ row, column });
134
- }}
135
- />
136
- </Dropdown.Menu>
137
- </Dropdown>
138
- </>
139
- );
140
- };
141
-
142
- export default TableButton;
@@ -1,44 +0,0 @@
1
- import React from 'react';
2
- import cx from 'classnames';
3
-
4
- export const TableCell = ({
5
- active,
6
- row,
7
- column,
8
- onClick,
9
- onMouseEnter,
10
- onMouseLeave,
11
- }) => {
12
- const handleClick = React.useCallback(
13
- (ev) => {
14
- onClick({ row, column });
15
- },
16
- [column, onClick, row],
17
- );
18
-
19
- const handleMouseEnter = React.useCallback(
20
- (ev) => {
21
- onMouseEnter({ row, column });
22
- },
23
- [column, onMouseEnter, row],
24
- );
25
-
26
- const handleMouseLeave = React.useCallback(
27
- (ev) => {
28
- onMouseLeave({ row, column });
29
- },
30
- [column, onMouseLeave, row],
31
- );
32
-
33
- return (
34
- <td
35
- onMouseEnter={handleMouseEnter}
36
- onMouseLeave={handleMouseLeave}
37
- className={cx({ active })}
38
- >
39
- <button onClick={handleClick}></button>
40
- </td>
41
- );
42
- };
43
-
44
- export default TableCell;
@@ -1,37 +0,0 @@
1
- import React from 'react';
2
- import TableSizePicker from './TableSizePicker';
3
-
4
- export const TableContainer = ({
5
- rowCount,
6
- columnCount,
7
- activeRow,
8
- activeColumn,
9
- onCellClick,
10
- onCellMouseEnter,
11
- onCellMouseLeave,
12
- }) => {
13
- return (
14
- <div style={{ padding: '1rem' }}>
15
- <TableSizePicker
16
- activeRow={activeRow}
17
- activeColumn={activeColumn}
18
- rowCount={rowCount}
19
- columnCount={columnCount}
20
- onCellClick={onCellClick}
21
- onCellMouseEnter={({ row, column }) => {
22
- onCellMouseEnter({ row, column });
23
- }}
24
- onCellMouseLeave={onCellMouseLeave}
25
- />
26
- <p
27
- style={{
28
- textAlign: 'center',
29
- }}
30
- >
31
- {activeColumn || 1} &times; {activeRow || 1}
32
- </p>
33
- </div>
34
- );
35
- };
36
-
37
- export default TableContainer;
@@ -1,83 +0,0 @@
1
- import React from 'react';
2
- import TableCell from './TableCell';
3
-
4
- export const TableSizePicker = ({
5
- rowCount,
6
- columnCount,
7
- activeRow,
8
- activeColumn,
9
- onCellClick,
10
- onCellMouseEnter,
11
- onCellMouseLeave,
12
- }) => {
13
- const handleClick = React.useCallback(
14
- (...rest) => {
15
- onCellClick(...rest);
16
- },
17
- [onCellClick],
18
- );
19
-
20
- const handleMouseEnter = React.useCallback(
21
- (...rest) => {
22
- onCellMouseEnter(...rest);
23
- },
24
- [onCellMouseEnter],
25
- );
26
-
27
- const handleMouseLeave = React.useCallback(
28
- (...rest) => {
29
- onCellMouseLeave(...rest);
30
- },
31
- [onCellMouseLeave],
32
- );
33
-
34
- const createRow = React.useCallback(
35
- (rowIndex) => {
36
- const arr = [];
37
- for (let i = 0; i < columnCount; ++i) {
38
- const columnIndex = i + 1;
39
-
40
- arr.push(
41
- <TableCell
42
- key={columnIndex}
43
- row={rowIndex + 1}
44
- column={columnIndex}
45
- active={rowIndex + 1 <= activeRow && i + 1 <= activeColumn}
46
- onClick={handleClick}
47
- onMouseEnter={handleMouseEnter}
48
- onMouseLeave={handleMouseLeave}
49
- ></TableCell>,
50
- );
51
- }
52
- return <tr key={rowIndex}>{arr}</tr>;
53
- },
54
- [
55
- activeColumn,
56
- activeRow,
57
- columnCount,
58
- handleClick,
59
- handleMouseEnter,
60
- handleMouseLeave,
61
- ],
62
- );
63
-
64
- const rows = [];
65
- for (let i = 0; i < rowCount; ++i) {
66
- rows.push(createRow(i));
67
- }
68
-
69
- const zoomFactor = 1;
70
-
71
- return (
72
- <table
73
- style={{
74
- width: `${columnCount * zoomFactor}rem`,
75
- height: `${rowCount * zoomFactor}rem`,
76
- }}
77
- >
78
- <tbody>{rows}</tbody>
79
- </table>
80
- );
81
- };
82
-
83
- export default TableSizePicker;