@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,50 +0,0 @@
1
- import { defineMessages } from 'react-intl'; // , defineMessages
2
- import linkSVG from '@plone/volto/icons/link.svg';
3
- import { makeInlineElementPlugin } from '@plone/volto-slate/elementEditor';
4
-
5
- import { LINK } from '@plone/volto-slate/constants';
6
- import { LinkElement } from './render';
7
- import { withLink } from './extensions';
8
- import { linkDeserializer } from './deserialize';
9
- import LinkEditSchema from './schema';
10
-
11
- const messages = defineMessages({
12
- edit: {
13
- id: 'Edit link',
14
- defaultMessage: 'Edit link',
15
- },
16
- delete: {
17
- id: 'Remove link',
18
- defaultMessage: 'Remove link',
19
- },
20
- });
21
-
22
- export default (config) => {
23
- const { slate } = config.settings;
24
-
25
- slate.toolbarButtons = [...(slate.toolbarButtons || []), LINK];
26
- slate.expandedToolbarButtons = [
27
- ...(slate.expandedToolbarButtons || []),
28
- LINK,
29
- ];
30
-
31
- slate.htmlTagsToSlate.A = linkDeserializer;
32
-
33
- const opts = {
34
- title: 'Link',
35
- pluginId: LINK,
36
- elementType: LINK,
37
- element: LinkElement,
38
- isInlineElement: true,
39
- editSchema: LinkEditSchema,
40
- extensions: [withLink],
41
- hasValue: (formData) => !!formData.link,
42
- toolbarButtonIcon: linkSVG,
43
- messages,
44
- };
45
-
46
- const [installLinkEditor] = makeInlineElementPlugin(opts);
47
- config = installLinkEditor(config);
48
-
49
- return config;
50
- };
@@ -1,37 +0,0 @@
1
- import React from 'react';
2
- import { UniversalLink } from '@plone/volto/components';
3
- import './styles.less';
4
-
5
- export const LinkElement = ({ attributes, children, element, mode }) => {
6
- // TODO: handle title on internal links
7
- let url = element.url;
8
- const { link } = element.data || {};
9
-
10
- const internal_link = link?.internal?.internal_link?.[0]?.['@id'];
11
- const external_link = link?.external?.external_link;
12
- const email = link?.email;
13
-
14
- const href = email
15
- ? `mailto:${email.email_address}${
16
- email.email_subject ? `?subject=${email.email_subject}` : ''
17
- }`
18
- : external_link || internal_link || url;
19
-
20
- const { title } = element?.data || {};
21
-
22
- return mode === 'view' ? (
23
- <>
24
- <UniversalLink
25
- href={href || '#'}
26
- openLinkInNewTab={link?.external?.target === '_blank'}
27
- title={title}
28
- >
29
- {children}
30
- </UniversalLink>
31
- </>
32
- ) : (
33
- <span {...attributes} className="slate-editor-link">
34
- {children}
35
- </span>
36
- );
37
- };
@@ -1,114 +0,0 @@
1
- import externalSVG from '@plone/volto/icons/link.svg';
2
- import internalSVG from '@plone/volto/icons/nav.svg';
3
- import emailSVG from '@plone/volto/icons/email.svg';
4
- // import pageLinkSVG from '@plone/volto/icons/show-blocks.svg';
5
-
6
- export const EmailLinkSchema = {
7
- title: 'Email address',
8
- fieldsets: [
9
- {
10
- id: 'email',
11
- title: 'Email',
12
- fields: ['email_address', 'email_subject'],
13
- },
14
- ],
15
- properties: {
16
- email_address: {
17
- title: 'Email address',
18
- },
19
- email_subject: {
20
- title: 'Email subject',
21
- description: 'Optional',
22
- },
23
- },
24
- required: [],
25
- };
26
-
27
- export const InternalLinkSchema = {
28
- title: 'Internal link',
29
- fieldsets: [
30
- {
31
- id: 'internal',
32
- title: 'Internal',
33
- fields: ['internal_link'],
34
- },
35
- ],
36
- properties: {
37
- internal_link: {
38
- widget: 'object_browser',
39
- title: 'Internal link',
40
- multiple: false,
41
- mode: 'link',
42
- selectedItemAttrs: [],
43
- },
44
- },
45
- required: [],
46
- };
47
-
48
- export const ExternalLinkSchema = {
49
- title: 'External link',
50
- fieldsets: [
51
- {
52
- id: 'external',
53
- title: 'External',
54
- fields: ['external_link', 'target'],
55
- },
56
- ],
57
- properties: {
58
- external_link: {
59
- title: 'External URL',
60
- description:
61
- 'URL can be relative within this site or absolute if it starts with http:// or https://',
62
- },
63
- target: {
64
- title: 'Target',
65
- choices: [
66
- ['_self', 'Open in this window / frame'],
67
- ['_blank', 'Open in new window'],
68
- ['_parent', 'Open in parent window / frame'],
69
- ['_top', 'Open in top frame (replaces all frames)'],
70
- ],
71
- },
72
- },
73
- required: [],
74
- };
75
-
76
- const LinkEditSchema = {
77
- title: 'Insert link',
78
- fieldsets: [
79
- {
80
- id: 'default',
81
- title: 'Internal link',
82
- fields: ['link', 'title'],
83
- },
84
- ],
85
- properties: {
86
- title: {
87
- title: 'Link Title',
88
- },
89
- link: {
90
- title: 'Link',
91
- widget: 'object_by_type',
92
- schemas: [
93
- {
94
- id: 'internal',
95
- icon: internalSVG,
96
- schema: InternalLinkSchema,
97
- },
98
- {
99
- id: 'external',
100
- icon: externalSVG,
101
- schema: ExternalLinkSchema,
102
- },
103
- {
104
- id: 'email',
105
- icon: emailSVG,
106
- schema: EmailLinkSchema,
107
- },
108
- ],
109
- },
110
- },
111
- required: [],
112
- };
113
-
114
- export default LinkEditSchema;
@@ -1,8 +0,0 @@
1
- @type: 'extra';
2
- @element: 'custom';
3
-
4
- @import (multiple, reference, optional) '../../theme.config';
5
-
6
- .slate-editor-link {
7
- color: @linkColor;
8
- }
@@ -1,30 +0,0 @@
1
- import React from 'react';
2
- import { BlockButton } from '@plone/volto-slate/editor/ui';
3
- import quoteIcon from '@plone/volto/icons/quote.svg';
4
-
5
- // TODO: this needs to use constants for el type
6
-
7
- export const BlockquoteElement = ({ attributes, children }) => {
8
- // the 'callout' class is defined in file 'blocks.less'
9
- // TODO: move the style out of it into a `blockquote` tag name selector
10
- return <blockquote {...attributes}>{children}</blockquote>;
11
- };
12
-
13
- export default function install(config) {
14
- const { slate } = config.settings;
15
-
16
- slate.buttons['blockquote'] = (props) => (
17
- <BlockButton
18
- format="blockquote"
19
- icon={quoteIcon}
20
- title="Blockquote"
21
- {...props}
22
- />
23
- );
24
- slate.elements['blockquote'] = BlockquoteElement;
25
-
26
- slate.toolbarButtons.push('blockquote');
27
- slate.expandedToolbarButtons.push('blockquote');
28
-
29
- return config;
30
- }
@@ -1,34 +0,0 @@
1
- import React from 'react';
2
- import { BlockButton } from '@plone/volto-slate/editor/ui';
3
- import calloutSVG from '@plone/volto/icons/megaphone.svg';
4
-
5
- // TODO: this needs to use constants for el type
6
-
7
- export const CalloutElement = ({ attributes, children, element }) => {
8
- // the 'callout' class is defined in file 'blocks.less'
9
- // TODO: move the style out of it into a `blockquote` tag name selector
10
- return (
11
- <p {...attributes} className="callout">
12
- {children}
13
- </p>
14
- );
15
- };
16
-
17
- export default function install(config) {
18
- const { slate } = config.settings;
19
-
20
- slate.buttons['callout'] = (props) => (
21
- <BlockButton
22
- format="callout"
23
- icon={calloutSVG}
24
- title="Callout"
25
- {...props}
26
- />
27
- );
28
- slate.elements['callout'] = CalloutElement;
29
-
30
- slate.toolbarButtons.push('callout');
31
- slate.expandedToolbarButtons.push('callout');
32
-
33
- return config;
34
- }
@@ -1,30 +0,0 @@
1
- import { v4 as uuid } from 'uuid';
2
- import { Editor, Transforms } from 'slate';
3
- import { IMAGE } from '@plone/volto-slate/constants';
4
-
5
- export function syncCreateImageBlock(url) {
6
- const id = uuid();
7
- const block = {
8
- '@type': 'image',
9
- url,
10
- };
11
- return [id, block];
12
- }
13
-
14
- // This function is used by deconstructToVoltoBlocks, so not directly by the
15
- // <SlateEditor>. File exists here because there's no "blocks/Image" folder
16
- export const extractImages = (editor, pathRef) => {
17
- const imageNodes = Array.from(
18
- Editor.nodes(editor, {
19
- at: pathRef.current,
20
- match: (node) => node.type === IMAGE,
21
- }),
22
- );
23
- const images = imageNodes.map(([el, path]) => el);
24
- Transforms.removeNodes(editor, {
25
- at: pathRef.current,
26
- match: (node) => node.type === IMAGE,
27
- });
28
-
29
- return images.map((el) => syncCreateImageBlock(el.url));
30
- };
@@ -1,51 +0,0 @@
1
- // The default behavior is to allow images to be copy/pasted inside the editor
2
- // The TextBlockEdit extensions will come and then split the images into
3
- // separate dedicated Volto image blocks.
4
-
5
- import { IMAGE } from '@plone/volto-slate/constants';
6
- import { jsx } from 'slate-hyperscript';
7
-
8
- export const deserializeImageTag = (editor, el) => {
9
- const attrs = { type: IMAGE };
10
-
11
- // TODO: not all of these attributes should be stored in the DB
12
- for (const name of el.getAttributeNames()) {
13
- attrs[name] = el.getAttribute(name);
14
- }
15
-
16
- // TODO: recognize more unsupported protocols
17
- if (typeof attrs.src === 'undefined' || attrs.src.startsWith('file:///')) {
18
- return null;
19
- }
20
-
21
- attrs.url = attrs.src;
22
- delete attrs.src;
23
-
24
- return [jsx('element', attrs, [{ text: '' }])];
25
- };
26
-
27
- /**
28
- * Allows for pasting images from clipboard.
29
- * Not yet: dragging and dropping images, selecting them through a file system dialog.
30
- * @param typeImg
31
- */
32
- export const withImage = (editor) => {
33
- const { isVoid, isInline } = editor;
34
-
35
- editor.isVoid = (element) => {
36
- return element.type === IMAGE ? true : isVoid(element);
37
- };
38
-
39
- // If it's not marked as inline, Slate will strip the {type:'img"} nodes when
40
- // it finds them next to {text: ''} nodes
41
- editor.isInline = (element) => {
42
- return element && element.type === IMAGE ? true : isInline(element);
43
- };
44
-
45
- editor.htmlTagsToSlate = {
46
- ...editor.htmlTagsToSlate,
47
- IMG: deserializeImageTag,
48
- };
49
-
50
- return editor;
51
- };
@@ -1,11 +0,0 @@
1
- import { withImage } from './extensions';
2
- import { ImageElement } from './render';
3
-
4
- export default function install(config) {
5
- const { slate } = config.settings;
6
-
7
- slate.extensions = [...(slate.extensions || []), withImage];
8
- slate.elements.img = ImageElement;
9
-
10
- return config;
11
- }
@@ -1,22 +0,0 @@
1
- import React from 'react';
2
- import { useSelected, useFocused } from 'slate-react';
3
-
4
- export const ImageElement = (props) => {
5
- const { attributes, children, element } = props;
6
- const selected = useSelected();
7
- const focused = useFocused();
8
-
9
- const style = {
10
- display: 'block',
11
- maxWidth: '100%',
12
- maxHeight: '20em',
13
- boxShadow: selected && focused ? '0 0 0 2px blue' : 'none',
14
- };
15
-
16
- return (
17
- <span {...attributes} style={{ display: 'inline-block' }}>
18
- {children}
19
- <img alt="" src={element.url} style={style} />
20
- </span>
21
- );
22
- };
@@ -1,58 +0,0 @@
1
- import { Text, Transforms, Element } from 'slate'; // Editor,
2
- import { SIMPLELINK } from '@plone/volto-slate/constants';
3
- import { jsx } from 'slate-hyperscript';
4
- import { deserialize } from '@plone/volto-slate/editor/deserialize';
5
-
6
- const nodeToText = (node) => {
7
- if (Text.isText(node)) {
8
- return node.text.trim();
9
- } else {
10
- return node.children.map(nodeToText).join('');
11
- }
12
- };
13
-
14
- export const withSimpleLink = (editor) => {
15
- const { isInline, normalizeNode } = editor;
16
-
17
- editor.isInline = (element) => {
18
- return element && element.type === SIMPLELINK ? true : isInline(element);
19
- };
20
-
21
- editor.normalizeNode = (entry) => {
22
- const [node, path] = entry;
23
- const isTextNode = Text.isText(node);
24
- const isElementNode = Element.isElement(node);
25
- const isLinkTypeNode = node.type === SIMPLELINK;
26
-
27
- // delete childless link nodes
28
- if (!isTextNode && isElementNode && isLinkTypeNode && !nodeToText(node)) {
29
- Transforms.removeNodes(editor, { at: path });
30
- return;
31
- }
32
-
33
- return normalizeNode(entry);
34
- };
35
-
36
- return editor;
37
- };
38
-
39
- export const simpleLinkDeserializer = (editor, el) => {
40
- let parent = el;
41
-
42
- let children = Array.from(parent.childNodes)
43
- .map((el) => deserialize(editor, el))
44
- .flat();
45
-
46
- if (!children.length) children = [{ text: '' }];
47
-
48
- const attrs = {
49
- type: SIMPLELINK,
50
- data: {
51
- url: el.getAttribute('href'),
52
- },
53
- };
54
-
55
- return jsx('element', attrs, children);
56
- };
57
-
58
- simpleLinkDeserializer.id = 'simpleLinkDeserializer';
@@ -1,164 +0,0 @@
1
- import React from 'react';
2
- import { defineMessages } from 'react-intl'; // , defineMessages
3
- import { ReactEditor, useSlate } from 'slate-react';
4
- import { useSelector, useDispatch } from 'react-redux';
5
- import AddLinkForm from '@plone/volto/components/manage/AnchorPlugin/components/LinkButton/AddLinkForm';
6
- import {
7
- _insertElement,
8
- _unwrapElement,
9
- _isActiveElement,
10
- _getActiveElement,
11
- } from '@plone/volto-slate/elementEditor/utils';
12
- import { SIMPLELINK, LINK } from '@plone/volto-slate/constants';
13
- import { LinkElement } from './render';
14
- import { simpleLinkDeserializer, withSimpleLink } from './extensions';
15
- import { setPluginOptions } from '@plone/volto-slate/actions';
16
- import {
17
- ToolbarButton as UIToolbarButton,
18
- PositionedToolbar,
19
- } from '@plone/volto-slate/editor/ui';
20
- import { useSelectionPosition } from '@plone/volto-slate/hooks';
21
-
22
- import linkSVG from '@plone/volto/icons/link.svg';
23
- import unlinkSVG from '@plone/volto/icons/unlink.svg';
24
-
25
- const messages = defineMessages({
26
- add: {
27
- id: 'Add link',
28
- defaultMessage: 'Add link',
29
- },
30
- edit: {
31
- id: 'Edit link',
32
- defaultMessage: 'Edit link',
33
- },
34
- });
35
-
36
- function getPositionStyle(rect) {
37
- return {
38
- style: {
39
- opacity: 1,
40
- top: rect.top + window.pageYOffset - 6,
41
- left: rect.left + window.pageXOffset + rect.width / 2,
42
- },
43
- };
44
- }
45
-
46
- const LinkEditor = (props) => {
47
- const {
48
- editor,
49
- pluginId,
50
- getActiveElement,
51
- unwrapElement,
52
- insertElement,
53
- } = props;
54
- const pid = `${editor.uid}-${pluginId}`;
55
- const showEditor = useSelector((state) => {
56
- return state['slate_plugins']?.[pid]?.show_sidebar_editor;
57
- });
58
- const savedPosition = React.useRef();
59
- const rect = useSelectionPosition();
60
-
61
- const dispatch = useDispatch();
62
-
63
- const active = getActiveElement(editor);
64
- // console.log('active', active);
65
- const [node] = active || [];
66
-
67
- if (showEditor && !savedPosition.current) {
68
- savedPosition.current = getPositionStyle(rect);
69
- }
70
-
71
- return showEditor ? (
72
- <PositionedToolbar className="add-link" position={savedPosition.current}>
73
- <AddLinkForm
74
- block="draft-js"
75
- placeholder={'Add link'}
76
- data={{ url: node?.data?.url || '' }}
77
- theme={{}}
78
- onChangeValue={(url) => {
79
- if (!active) {
80
- if (!editor.selection) editor.selection = editor.savedSelection;
81
- insertElement(editor, { url });
82
- } else {
83
- const selection = unwrapElement(editor);
84
- editor.selection = selection;
85
- insertElement(editor, { url });
86
- }
87
- ReactEditor.focus(editor);
88
- dispatch(setPluginOptions(pid, { show_sidebar_editor: false }));
89
- savedPosition.current = null;
90
- }}
91
- onClear={() => {
92
- // clear button was pressed in the link edit popup
93
- const newSelection = JSON.parse(
94
- JSON.stringify(unwrapElement(editor)),
95
- );
96
- editor.selection = newSelection;
97
- editor.savedSelection = newSelection;
98
- }}
99
- onOverrideContent={(c) => {
100
- dispatch(setPluginOptions(pid, { show_sidebar_editor: false }));
101
- savedPosition.current = null;
102
- }}
103
- />
104
- </PositionedToolbar>
105
- ) : null;
106
- };
107
-
108
- const applyConfig = (config) => {
109
- const { slate } = config.settings;
110
-
111
- const PLUGINID = SIMPLELINK;
112
-
113
- const linkBtnIndex = slate.toolbarButtons.findIndex((b) => b === LINK);
114
- slate.expandedToolbarButtons = slate.expandedToolbarButtons.filter(
115
- (b) => b !== LINK,
116
- );
117
-
118
- const insertElement = _insertElement(PLUGINID);
119
- const getActiveElement = _getActiveElement(PLUGINID);
120
- const isActiveElement = _isActiveElement(PLUGINID);
121
- const unwrapElement = _unwrapElement(PLUGINID);
122
-
123
- const ToolbarButton = (props) => {
124
- const dispatch = useDispatch();
125
- const editor = useSlate();
126
- const isElement = isActiveElement(editor);
127
-
128
- return (
129
- <UIToolbarButton
130
- title={isElement ? messages.edit : messages.add}
131
- icon={isElement ? unlinkSVG : linkSVG}
132
- active={isElement}
133
- onMouseDown={(e) => {
134
- e.stopPropagation();
135
- e.preventDefault();
136
- const pid = `${editor.uid}-${PLUGINID}`;
137
- editor.savedSelection = JSON.parse(JSON.stringify(editor.selection));
138
- dispatch(setPluginOptions(pid, { show_sidebar_editor: true }));
139
- }}
140
- />
141
- );
142
- };
143
-
144
- const pluginOptions = {
145
- insertElement,
146
- getActiveElement,
147
- isActiveElement,
148
- unwrapElement,
149
- };
150
-
151
- slate.buttons[PLUGINID] = ToolbarButton;
152
- slate.toolbarButtons[linkBtnIndex] = PLUGINID;
153
- slate.htmlTagsToSlate.A = simpleLinkDeserializer;
154
- slate.extensions.push(withSimpleLink);
155
- slate.elements[PLUGINID] = LinkElement;
156
- slate.nodeTypesToHighlight.push(PLUGINID);
157
- slate.persistentHelpers.push((props) => (
158
- <LinkEditor {...props} pluginId={PLUGINID} {...pluginOptions} />
159
- ));
160
-
161
- return config;
162
- };
163
-
164
- export default applyConfig;
@@ -1,54 +0,0 @@
1
- import React from 'react';
2
- import cx from 'classnames';
3
- import { UniversalLink } from '@plone/volto/components';
4
- import config from '@plone/volto/registry';
5
- import { isInternalURL, flattenToAppURL } from '@plone/volto/helpers';
6
-
7
- const ViewLink = ({ url, target, download, children }) => {
8
- const { openExternalLinkInNewTab } = config.settings;
9
- return (
10
- <UniversalLink
11
- href={url}
12
- openLinkInNewTab={
13
- (openExternalLinkInNewTab && !isInternalURL(url)) || target === '_blank'
14
- }
15
- download={download}
16
- >
17
- {children}
18
- </UniversalLink>
19
- );
20
- };
21
-
22
- export const LinkElement = (props) => {
23
- const { attributes, children, element, mode = 'edit' } = props;
24
- const isInternalUrl = isInternalURL(element.data?.url);
25
- const linkUrl = element.data?.url;
26
-
27
- return mode === 'view' ? (
28
- <ViewLink {...(element.data || {})}>{children}</ViewLink>
29
- ) : (
30
- <a
31
- {...attributes}
32
- className={cx('slate-editor-link', { external: !isInternalUrl })}
33
- href={isInternalUrl ? flattenToAppURL(linkUrl) : linkUrl}
34
- onClick={(e) => e.preventDefault()}
35
- >
36
- {Array.isArray(children)
37
- ? children.map((child, i) => {
38
- if (child?.props?.decorations) {
39
- const isSelection =
40
- child.props.decorations.findIndex((deco) => deco.isSelection) >
41
- -1;
42
- if (isSelection)
43
- return (
44
- <span className="highlight-selection" key={`${i}-sel`}>
45
- {child}
46
- </span>
47
- );
48
- }
49
- return child;
50
- })
51
- : children}
52
- </a>
53
- );
54
- };