design-comuni-plone-theme 11.29.2 → 12.0.0

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 (227) hide show
  1. package/.github/workflows/main.yml +16 -16
  2. package/.github/workflows/npm.yml +1 -1
  3. package/.github/workflows/withnewsletter.yml +47 -0
  4. package/.release-it.json +1 -0
  5. package/.yarn/cache/@babel-helper-module-imports-npm-7.24.3-edb733448b-c23492189b.zip +0 -0
  6. package/.yarn/cache/@babel-types-npm-7.24.0-a0508cb308-4b574a37d4.zip +0 -0
  7. package/.yarn/cache/babel-plugin-lodash-npm-3.3.4-c7161075b6-044a4261e6.zip +0 -0
  8. package/.yarn/cache/braces-npm-3.0.3-582c14023c-b95aa0b3bd.zip +0 -0
  9. package/.yarn/cache/fill-range-npm-7.1.1-bf491486db-b4abfbca38.zip +0 -0
  10. package/.yarn/cache/micromatch-npm-4.0.8-c9570e4aca-79920eb634.zip +0 -0
  11. package/.yarn/cache/require-package-name-npm-2.0.1-ac9a206b63-00f4e9e467.zip +0 -0
  12. package/.yarn/install-state.gz +0 -0
  13. package/CHANGELOG.md +1728 -1659
  14. package/RELEASE.md +6 -0
  15. package/locales/de/LC_MESSAGES/volto.po +86 -19
  16. package/locales/en/LC_MESSAGES/volto.po +86 -19
  17. package/locales/es/LC_MESSAGES/volto.po +86 -19
  18. package/locales/fr/LC_MESSAGES/volto.po +86 -19
  19. package/locales/it/LC_MESSAGES/volto.po +87 -20
  20. package/locales/volto.pot +87 -20
  21. package/package.json +3 -1
  22. package/publiccode.yml +2 -2
  23. package/src/components/Collapse.jsx +1 -0
  24. package/src/components/ItaliaTheme/AppExtras/SiteSettingsExtras.jsx +0 -6
  25. package/src/components/ItaliaTheme/Blocks/Accordion/Block/EditBlock.jsx +29 -24
  26. package/src/components/ItaliaTheme/Blocks/Accordion/Block/ViewBlock.jsx +4 -12
  27. package/src/components/ItaliaTheme/Blocks/Accordion/Edit.jsx +118 -42
  28. package/src/components/ItaliaTheme/Blocks/Accordion/View.jsx +4 -18
  29. package/src/components/ItaliaTheme/Blocks/Alert/Edit.jsx +60 -113
  30. package/src/components/ItaliaTheme/Blocks/Alert/Sidebar.jsx +1 -0
  31. package/src/components/ItaliaTheme/Blocks/Alert/View.jsx +5 -14
  32. package/src/components/ItaliaTheme/Blocks/ArgumentsInEvidence/Block.jsx +16 -11
  33. package/src/components/ItaliaTheme/Blocks/ArgumentsInEvidence/Body.jsx +2 -1
  34. package/src/components/ItaliaTheme/Blocks/ArgumentsInEvidence/Edit.jsx +39 -1
  35. package/src/components/ItaliaTheme/Blocks/CTABlock/Block.jsx +35 -95
  36. package/src/components/ItaliaTheme/Blocks/Callout/Edit.jsx +108 -0
  37. package/src/components/ItaliaTheme/Blocks/Callout/Sidebar.jsx +173 -0
  38. package/src/components/ItaliaTheme/Blocks/Callout/View.jsx +45 -0
  39. package/src/components/ItaliaTheme/Blocks/ContactsBlock/Block/EditBlock.jsx +86 -63
  40. package/src/components/ItaliaTheme/Blocks/ContactsBlock/Block/ViewBlock.jsx +19 -39
  41. package/src/components/ItaliaTheme/Blocks/ContactsBlock/Edit.jsx +101 -22
  42. package/src/components/ItaliaTheme/Blocks/ContactsBlock/View.jsx +13 -21
  43. package/src/components/ItaliaTheme/Blocks/CountDown/Edit.jsx +21 -25
  44. package/src/components/ItaliaTheme/Blocks/CountDown/View.jsx +6 -15
  45. package/src/components/ItaliaTheme/Blocks/IconBlocks/Block/EditBlock.jsx +52 -22
  46. package/src/components/ItaliaTheme/Blocks/IconBlocks/Block/ViewBlock.jsx +9 -29
  47. package/src/components/ItaliaTheme/Blocks/IconBlocks/Edit.jsx +108 -21
  48. package/src/components/ItaliaTheme/Blocks/IconBlocks/Sidebar.jsx +1 -9
  49. package/src/components/ItaliaTheme/Blocks/IconBlocks/View.jsx +6 -14
  50. package/src/components/ItaliaTheme/Blocks/Listing/CardWithSlideUpTextTemplate.jsx +0 -1
  51. package/src/components/ItaliaTheme/Blocks/NumbersBlock/Block/EditBlock.jsx +45 -15
  52. package/src/components/ItaliaTheme/Blocks/NumbersBlock/Block/ViewBlock.jsx +2 -18
  53. package/src/components/ItaliaTheme/Blocks/NumbersBlock/Edit.jsx +98 -11
  54. package/src/components/ItaliaTheme/Blocks/NumbersBlock/View.jsx +2 -7
  55. package/src/components/ItaliaTheme/Blocks/TextCard/CardWithImage/Block.jsx +35 -67
  56. package/src/components/ItaliaTheme/Blocks/TextCard/CardWithImage/Edit.jsx +2 -8
  57. package/src/components/ItaliaTheme/Blocks/TextCard/SimpleCard/BodyWrapper.jsx +2 -1
  58. package/src/components/ItaliaTheme/Blocks/TextCard/SimpleCard/Edit.jsx +98 -84
  59. package/src/components/ItaliaTheme/Blocks/TextCard/SimpleCard/View.jsx +20 -3
  60. package/src/components/ItaliaTheme/Blocks/UOSearch/Sidebar.jsx +11 -11
  61. package/src/components/ItaliaTheme/Blocks/__tests__/Accordion.test.jsx +11 -28
  62. package/src/components/ItaliaTheme/Blocks/__tests__/Alert.test.jsx +10 -14
  63. package/src/components/ItaliaTheme/Blocks/__tests__/ArgumentsInEvidence.test.jsx +20 -28
  64. package/src/components/ItaliaTheme/Blocks/__tests__/CTABlock.test.jsx +14 -29
  65. package/src/components/ItaliaTheme/Blocks/__tests__/CardWithImage.test.jsx +11 -28
  66. package/src/components/ItaliaTheme/Blocks/__tests__/ContactsBlock.test.jsx +75 -140
  67. package/src/components/ItaliaTheme/Blocks/__tests__/Countdown.test.jsx +20 -28
  68. package/src/components/ItaliaTheme/Blocks/__tests__/IconBlocks.test.jsx +22 -56
  69. package/src/components/ItaliaTheme/Blocks/__tests__/NumbersBlock.test.jsx +14 -43
  70. package/src/components/ItaliaTheme/Blocks/__tests__/SimpleCard.test.jsx +14 -30
  71. package/src/components/ItaliaTheme/BrandText/BrandText.jsx +8 -14
  72. package/src/components/ItaliaTheme/BrandTextFooter/BrandTextFooter.jsx +31 -2
  73. package/src/components/ItaliaTheme/Footer/FooterInfos.jsx +21 -8
  74. package/src/components/ItaliaTheme/Footer/FooterNavigation.jsx +3 -3
  75. package/src/components/ItaliaTheme/Header/HeaderSlim/HeaderSlim.jsx +0 -7
  76. package/src/components/ItaliaTheme/Icons/Icon.jsx +0 -1
  77. package/src/components/ItaliaTheme/MegaMenu/MegaMenu.jsx +5 -1
  78. package/src/components/ItaliaTheme/View/BandoView/BandoApprofondimenti.jsx +1 -2
  79. package/src/components/ItaliaTheme/View/CartellaModulisticaView/DocRow.jsx +14 -5
  80. package/src/components/ItaliaTheme/View/Commons/Attachment.jsx +19 -3
  81. package/src/components/ItaliaTheme/View/Commons/Attachments.jsx +0 -1
  82. package/src/components/ItaliaTheme/View/Commons/DownloadFileFormat.jsx +11 -7
  83. package/src/components/ItaliaTheme/View/Commons/Gallery.jsx +1 -0
  84. package/src/components/ItaliaTheme/View/Commons/PageHeader/PageHeaderEventDates.jsx +0 -1
  85. package/src/components/ItaliaTheme/View/Commons/PageHeader/PageHeaderLinkServizio.jsx +6 -2
  86. package/src/components/ItaliaTheme/View/Commons/RichTextRender.jsx +8 -6
  87. package/src/components/ItaliaTheme/View/Commons/__tests__/RichText.test.jsx +14 -17
  88. package/src/components/ItaliaTheme/View/EventoView/EventoContattiOrganizzatoreEsterno.jsx +1 -1
  89. package/src/components/ItaliaTheme/View/EventoView/EventoUlterioriInformazioni.jsx +0 -4
  90. package/src/components/ItaliaTheme/View/ServizioView/ServizioAccedi.jsx +10 -7
  91. package/src/components/ItaliaTheme/View/ServizioView/ServizioMetatag.jsx +4 -3
  92. package/src/components/ItaliaTheme/View/__disabled_tests__/IncaricoView.test__disabled.jsx +24 -30
  93. package/src/components/ItaliaTheme/View/__tests__/CartellaModulisticaView.test.jsx +12 -1
  94. package/src/components/ItaliaTheme/View/__tests__/PageView.test.jsx +24 -2
  95. package/src/components/ItaliaTheme/View/__tests__/PersonaView.test.jsx +96 -92
  96. package/src/components/ItaliaTheme/View/__tests__/ServizioAChiSiRivolge.test.jsx +240 -286
  97. package/src/components/ItaliaTheme/View/__tests__/ServizioAccedi.test.jsx +240 -286
  98. package/src/components/ItaliaTheme/View/__tests__/ServizioCasiParticolari.test.jsx +240 -286
  99. package/src/components/ItaliaTheme/View/__tests__/ServizioComeFare.test.jsx +240 -286
  100. package/src/components/ItaliaTheme/View/__tests__/ServizioCondizioni.test.jsx +240 -286
  101. package/src/components/ItaliaTheme/View/__tests__/ServizioContatti.test.jsx +240 -286
  102. package/src/components/ItaliaTheme/View/__tests__/ServizioCosE.test.jsx +240 -286
  103. package/src/components/ItaliaTheme/View/__tests__/ServizioCosaServe.test.jsx +240 -286
  104. package/src/components/ItaliaTheme/View/__tests__/ServizioCosaSiOttiene.test.jsx +240 -286
  105. package/src/components/ItaliaTheme/View/__tests__/ServizioCostiVincoli.test.jsx +240 -286
  106. package/src/components/ItaliaTheme/View/__tests__/ServizioMetadati.test.jsx +240 -286
  107. package/src/components/ItaliaTheme/View/__tests__/ServizioModulistica.test.jsx +240 -286
  108. package/src/components/ItaliaTheme/View/__tests__/ServizioProcedure.test.jsx +240 -286
  109. package/src/components/ItaliaTheme/View/__tests__/ServizioSitiEsterni.test.jsx +240 -286
  110. package/src/components/ItaliaTheme/View/__tests__/ServizioTempiScadenze.test.jsx +240 -286
  111. package/src/components/ItaliaTheme/View/__tests__/ServizioUlterioriInformazioni.test.jsx +240 -286
  112. package/src/components/ItaliaTheme/View/__tests__/ServizioView.test.jsx +470 -560
  113. package/src/components/ItaliaTheme/View/__tests__/TrasparenzaView.test.jsx +12 -1
  114. package/src/components/ItaliaTheme/index.js +0 -1
  115. package/src/components/ItaliaTheme/manage/Widgets/ColorListWidget.jsx +11 -2
  116. package/src/components/ItaliaTheme/manage/Widgets/HtmlSlateWidget.jsx +156 -0
  117. package/src/components/ItaliaTheme/manage/Widgets/RichTextWidget.jsx +88 -0
  118. package/src/components/ItaliaTheme/manage/Widgets/SimpleTextEditorWidget.jsx +158 -0
  119. package/src/components/ItaliaTheme/manage/Widgets/TextEditorWidget.jsx +167 -270
  120. package/src/config/Blocks/ListingOptions/index.js +0 -1
  121. package/src/config/Blocks/ListingOptions/utils.js +0 -7
  122. package/src/config/Blocks/blocks.js +29 -8
  123. package/src/config/Blocks/listingVariations.js +1 -1
  124. package/src/config/Slate/Alignment/AlignMenu.jsx +169 -0
  125. package/src/config/Slate/Alignment/index.js +42 -0
  126. package/src/config/Slate/Blockquote/BlockquoteMenu.jsx +151 -0
  127. package/src/config/Slate/Blockquote/index.js +19 -0
  128. package/src/config/Slate/Headings/HeadingsMenu.jsx +139 -0
  129. package/src/config/Slate/Headings/headingsMenu.scss +44 -0
  130. package/src/config/Slate/Headings/index.js +62 -0
  131. package/src/config/Slate/Link/deserializer.js +25 -0
  132. package/src/config/Slate/Link/index.js +126 -0
  133. package/src/config/Slate/Link/renderer.jsx +99 -0
  134. package/src/config/Slate/LinkButton/index.js +47 -0
  135. package/src/config/Slate/TextLarger/index.js +51 -0
  136. package/src/config/Slate/Underline/index.js +10 -0
  137. package/src/config/Slate/config.js +43 -0
  138. package/src/config/Slate/deserializers.js +66 -0
  139. package/src/config/Slate/dropdownStyle.scss +14 -0
  140. package/src/config/Slate/dropdownUtils.js +422 -0
  141. package/src/config/Slate/extensions/breakList.js +91 -0
  142. package/src/config/Slate/handlers.js +243 -0
  143. package/src/config/Slate/utils.js +73 -0
  144. package/src/config/Widgets/widgets.js +1 -2
  145. package/src/config/italiaConfig.js +5 -53
  146. package/src/customizations/volto/components/manage/AnchorPlugin/components/LinkButton/AddLinkForm.jsx +361 -0
  147. package/src/customizations/volto/components/manage/Blocks/HeroImageLeft/Edit.jsx +75 -200
  148. package/src/customizations/volto/components/manage/Blocks/Video/Body.jsx +0 -1
  149. package/src/customizations/volto/components/manage/Blocks/Video/Edit.jsx +1 -1
  150. package/src/customizations/volto/components/manage/Form/BlocksToolbar.jsx +1 -1
  151. package/src/customizations/volto/components/manage/UniversalLink/UniversalLink.jsx +76 -18
  152. package/src/customizations/volto/components/manage/Widgets/RecurrenceWidget/RecurrenceWidget.jsx +4 -0
  153. package/src/customizations/volto-form-block/components/Field.jsx +45 -22
  154. package/src/helpers/EnhanceLink.js +44 -0
  155. package/src/helpers/FormValidation/FormValidationHelpers.js +3 -0
  156. package/src/helpers/blocks.js +80 -0
  157. package/src/helpers/files.js +13 -13
  158. package/src/helpers/index.js +4 -3
  159. package/src/helpers/richTextHelper.js +10 -0
  160. package/src/icons/Group.svg +1 -0
  161. package/src/icons/blocco-icone.svg +0 -3
  162. package/src/icons/blockquote-card-dark.svg +1 -0
  163. package/src/icons/blockquote-card.svg +1 -0
  164. package/src/icons/blockquote-simple.svg +1 -0
  165. package/src/icons/text-larger.svg +1 -0
  166. package/src/theme/ItaliaTheme/Blocks/_accordion.scss +2 -22
  167. package/src/theme/ItaliaTheme/Blocks/_alert.scss +51 -4
  168. package/src/theme/ItaliaTheme/Blocks/_bandiInEvidenceTemplate.scss +1 -0
  169. package/src/theme/ItaliaTheme/Blocks/_callout.scss +32 -0
  170. package/src/theme/ItaliaTheme/Blocks/_contacts.scss +17 -51
  171. package/src/theme/ItaliaTheme/Blocks/_countdown.scss +10 -1
  172. package/src/theme/ItaliaTheme/Blocks/_ctaBlock.scss +7 -23
  173. package/src/theme/ItaliaTheme/Blocks/_gridBlock.scss +1 -1
  174. package/src/theme/ItaliaTheme/Blocks/_hero.scss +1 -8
  175. package/src/theme/ItaliaTheme/Blocks/_iconBlocks.scss +6 -77
  176. package/src/theme/ItaliaTheme/Blocks/_imageCardTextBlock.scss +3 -2
  177. package/src/theme/ItaliaTheme/Blocks/_numbers.scss +6 -20
  178. package/src/theme/ItaliaTheme/Blocks/_simpleCardTextBlock.scss +8 -2
  179. package/src/theme/ItaliaTheme/Blocks/_subblocks-edit.scss +3 -1
  180. package/src/theme/ItaliaTheme/Blocks/_tableOfContents.scss +1 -0
  181. package/src/theme/ItaliaTheme/Components/_megamenu.scss +0 -4
  182. package/src/theme/ItaliaTheme/Components/_mobileMenu.scss +12 -16
  183. package/src/theme/ItaliaTheme/Print/_page.scss +1 -1
  184. package/src/theme/ItaliaTheme/Subsites/ItaliaTheme/Blocks/_contacts.scss +3 -0
  185. package/src/theme/ItaliaTheme/Subsites/ItaliaTheme/Blocks/_cta.scss +1 -0
  186. package/src/theme/ItaliaTheme/Subsites/ItaliaTheme/Blocks/_searchSections.scss +1 -0
  187. package/src/theme/ItaliaTheme/Subsites/bootstrap-italia/custom/_headercenter.scss +1 -0
  188. package/src/theme/ItaliaTheme/Views/_cartellaModulistica.scss +11 -2
  189. package/src/theme/ItaliaTheme/Views/_servizio.scss +2 -2
  190. package/src/theme/ItaliaTheme/Views/_slider.scss +3 -0
  191. package/src/theme/ItaliaTheme/Widgets/_iconWidget.scss +4 -0
  192. package/src/theme/ItaliaTheme/_common.scss +1 -0
  193. package/src/theme/ItaliaTheme/_home.scss +0 -4
  194. package/src/theme/ItaliaTheme/_main.scss +78 -84
  195. package/src/theme/_cms-ui.scss +63 -160
  196. package/src/theme/_mixins.scss +13 -0
  197. package/src/theme/bootstrap-override/_bootstrap-italia-site.scss +1 -0
  198. package/src/theme/bootstrap-override/bootstrap-italia/_footer.scss +1 -1
  199. package/src/theme/bootstrap-override/bootstrap-italia/_forms.scss +7 -0
  200. package/src/theme/bootstrap-override/bootstrap-italia/_headercenter.scss +8 -3
  201. package/src/theme/extras/_forms.scss +2 -14
  202. package/src/theme/site.scss +1 -1
  203. package/test-setup-config.js +58 -0
  204. package/.yarn/cache/braces-npm-3.0.2-782240b28a-e2a8e769a8.zip +0 -0
  205. package/.yarn/cache/fill-range-npm-7.0.1-b8b1817caa-cc283f4e65.zip +0 -0
  206. package/.yarn/cache/micromatch-npm-4.0.5-cfab5d7669-02a17b671c.zip +0 -0
  207. package/src/components/ItaliaTheme/Blocks/TextCard/SimpleCard/Block.jsx +0 -151
  208. package/src/components/ItaliaTheme/RemoveBodyClass/RemoveBodyClass.jsx +0 -84
  209. package/src/config/RichTextEditor/LinkEntity.jsx +0 -27
  210. package/src/config/RichTextEditor/Plugins/AnchorPlugin/components/Link/index.jsx +0 -44
  211. package/src/config/RichTextEditor/Plugins/AnchorPlugin/components/LinkButton/AddLinkForm.jsx +0 -349
  212. package/src/config/RichTextEditor/Plugins/AnchorPlugin/components/LinkButton/index.js +0 -150
  213. package/src/config/RichTextEditor/Plugins/AnchorPlugin/index.js +0 -88
  214. package/src/config/RichTextEditor/ToolbarButtons/AlignButton.jsx +0 -61
  215. package/src/config/RichTextEditor/ToolbarButtons/ButtonsButton.jsx +0 -14
  216. package/src/config/RichTextEditor/ToolbarButtons/CalloutsButton.jsx +0 -38
  217. package/src/config/RichTextEditor/ToolbarButtons/DraftJsDropdownButton.jsx +0 -106
  218. package/src/config/RichTextEditor/ToolbarButtons/HeadingsButton.jsx +0 -57
  219. package/src/config/RichTextEditor/ToolbarButtons/TextSizeButton.jsx +0 -65
  220. package/src/config/RichTextEditor/ToolbarButtons/UnderlineButton.jsx +0 -14
  221. package/src/config/RichTextEditor/config.js +0 -253
  222. package/src/config/volto-gdpr-privacy-defaultPanelConfig.js +0 -292
  223. package/src/customizations/volto/components/manage/Blocks/ToC/View.jsx +0 -134
  224. package/src/customizations/volto/components/manage/Blocks/ToC/variations/DefaultTocRenderer.jsx +0 -99
  225. package/src/customizations/volto/config/RichTextEditor/Plugins.jsx +0 -63
  226. package/src/helpers/redraftHelper.js +0 -9
  227. package/src/theme/ItaliaTheme/Components/_logo.scss +0 -10
@@ -0,0 +1,126 @@
1
+ /*Customized LinkEditor to:
2
+ - handle data-element
3
+ - enhance link (enhanced_link_infos)
4
+ */
5
+ import React from 'react';
6
+ import { useSelector, useDispatch } from 'react-redux';
7
+ import { ReactEditor } from 'slate-react';
8
+ import { Transforms } from 'slate';
9
+ import {
10
+ _insertElement,
11
+ _unwrapElement,
12
+ _isActiveElement,
13
+ _getActiveElement,
14
+ } from '@plone/volto-slate/elementEditor/utils';
15
+ import { SIMPLELINK } from '@plone/volto-slate/constants';
16
+ import { useSelectionPosition } from '@plone/volto-slate/hooks';
17
+ import { setPluginOptions } from '@plone/volto-slate/actions';
18
+ import { PositionedToolbar } from '@plone/volto-slate/editor/ui';
19
+ import AddLinkForm from '@plone/volto/components/manage/AnchorPlugin/components/LinkButton/AddLinkForm';
20
+ import { simpleLinkDeserializer } from 'design-comuni-plone-theme/config/Slate/Link/deserializer';
21
+ const LinkEditor = (props) => {
22
+ const { editor, pluginId, getActiveElement, unwrapElement, insertElement } =
23
+ props;
24
+ const pid = `${editor.uid}-${pluginId}`;
25
+ const showEditor = useSelector((state) => {
26
+ return state['slate_plugins']?.[pid]?.show_sidebar_editor;
27
+ });
28
+ const savedPosition = React.useRef();
29
+ const rect = useSelectionPosition();
30
+
31
+ const dispatch = useDispatch();
32
+
33
+ const active = getActiveElement(editor);
34
+ const [node] = active || [];
35
+
36
+ if (showEditor && !savedPosition.current) {
37
+ savedPosition.current = getPositionStyle(rect);
38
+ }
39
+ const dataElement =
40
+ node?.data?.dataElement || node?.data?.['data-element'] || '';
41
+
42
+ return showEditor ? (
43
+ <PositionedToolbar className="add-link" position={savedPosition.current}>
44
+ <AddLinkForm
45
+ block="draft-js"
46
+ placeholder={'Aggiungi un link'}
47
+ data={{ url: node?.data?.url || '', dataElement }}
48
+ theme={{}}
49
+ onChangeValue={(url, dataElement, item) => {
50
+ let enhanced_link_infos = null;
51
+ if (item && item.enhanced_links_enabled) {
52
+ enhanced_link_infos = {};
53
+ enhanced_link_infos['content-type'] = item.mime_type;
54
+ enhanced_link_infos.getObjSize = item.getObjSize;
55
+ }
56
+ if (!active) {
57
+ if (!editor.selection) editor.selection = editor.savedSelection;
58
+ insertElement(editor, { url, dataElement, enhanced_link_infos });
59
+ } else {
60
+ const selection = unwrapElement(editor);
61
+ editor.selection = selection;
62
+ insertElement(editor, { url, dataElement, enhanced_link_infos });
63
+ }
64
+ // ReactEditor.focus(editor);
65
+
66
+ dispatch(setPluginOptions(pid, { show_sidebar_editor: false }));
67
+ savedPosition.current = null;
68
+
69
+ ReactEditor.deselect(editor);
70
+ Transforms.collapse(editor, { edge: 'end' });
71
+ Transforms.insertText(editor, ' ');
72
+ }}
73
+ onClear={() => {
74
+ // clear button was pressed in the link edit popup
75
+ try {
76
+ const newSelection = JSON.parse(
77
+ JSON.stringify(unwrapElement(editor)),
78
+ );
79
+ editor.selection = newSelection;
80
+ editor.savedSelection = newSelection;
81
+ } catch (e) {
82
+ //do nothing when no link was setted yet, and you clear the select item to link
83
+ }
84
+ }}
85
+ onOverrideContent={(c) => {
86
+ dispatch(setPluginOptions(pid, { show_sidebar_editor: false }));
87
+ savedPosition.current = null;
88
+ }}
89
+ />
90
+ </PositionedToolbar>
91
+ ) : null;
92
+ };
93
+ function getPositionStyle(rect) {
94
+ return {
95
+ style: {
96
+ opacity: 1,
97
+ top: rect.top + window.pageYOffset - 6,
98
+ left: rect.left + window.pageXOffset + rect.width / 2,
99
+ },
100
+ };
101
+ }
102
+
103
+ export default function install(config) {
104
+ const { slate } = config.settings;
105
+ const PLUGINID = SIMPLELINK;
106
+ const insertElement = _insertElement(PLUGINID);
107
+ const getActiveElement = _getActiveElement(PLUGINID);
108
+ const isActiveElement = _isActiveElement(PLUGINID);
109
+ const unwrapElement = _unwrapElement(PLUGINID);
110
+ const pluginOptions = {
111
+ insertElement,
112
+ getActiveElement,
113
+ isActiveElement,
114
+ unwrapElement,
115
+ };
116
+ //remove Volto helper link to add custom helper link
117
+ slate.persistentHelpers = slate.persistentHelpers.filter(
118
+ (h) => h().props.pluginId !== 'link',
119
+ );
120
+ slate.persistentHelpers.push((props) => (
121
+ <LinkEditor {...props} pluginId={PLUGINID} {...pluginOptions} />
122
+ ));
123
+ slate.htmlTagsToSlate.A = simpleLinkDeserializer;
124
+
125
+ return config;
126
+ }
@@ -0,0 +1,99 @@
1
+ import React from 'react';
2
+ import { UniversalLink } from '@plone/volto/components';
3
+ import config from '@plone/volto/registry';
4
+ import { isInternalURL, flattenToAppURL } from '@plone/volto/helpers';
5
+ import { EnhanceLink } from 'design-comuni-plone-theme/helpers';
6
+ import { Icon } from 'design-comuni-plone-theme/components/ItaliaTheme';
7
+
8
+ const ViewLink = ({
9
+ url,
10
+ target,
11
+ download,
12
+ children,
13
+ className,
14
+ dataElement,
15
+ }) => {
16
+ const { openExternalLinkInNewTab } = config.settings;
17
+ let dataElementAttr = {};
18
+ if (dataElement) {
19
+ dataElementAttr['data-element'] = dataElement;
20
+ }
21
+ return (
22
+ <UniversalLink
23
+ href={url}
24
+ openLinkInNewTab={
25
+ (openExternalLinkInNewTab && !isInternalURL(url)) || target === '_blank'
26
+ }
27
+ download={download}
28
+ className={className}
29
+ {...dataElementAttr}
30
+ >
31
+ {children}
32
+ </UniversalLink>
33
+ );
34
+ };
35
+
36
+ export const LinkElement = (props) => {
37
+ const { attributes, children, element, mode = 'edit' } = props;
38
+
39
+ let dataElementAttr = {};
40
+ if (element.data.dataElement) {
41
+ dataElementAttr['data-element'] = element.data.dataElement;
42
+ }
43
+
44
+ let enhanced_link = element.data.enhanced_link_infos
45
+ ? EnhanceLink({
46
+ enhanced_link_infos: {
47
+ ...element.data.enhanced_link_infos, //{mime_type: 'image/png', getObjSize: '1.3 MB'}
48
+ filename: element.data.url,
49
+ },
50
+ })
51
+ : null;
52
+
53
+ const extended_children = enhanced_link?.children ?? <></>;
54
+
55
+ return mode === 'view' ? (
56
+ <ViewLink {...(element.data || {})} {...attributes}>
57
+ {children}
58
+ {extended_children}
59
+ </ViewLink>
60
+ ) : (
61
+ <a
62
+ {...attributes}
63
+ {...dataElementAttr}
64
+ className={'slate-editor-link ' + (attributes.className ?? '')}
65
+ href={
66
+ isInternalURL(element.data?.url)
67
+ ? flattenToAppURL(element.data?.url)
68
+ : element.data?.url
69
+ }
70
+ onClick={(e) => e.preventDefault()}
71
+ >
72
+ {Array.isArray(children)
73
+ ? children.map((child, i) => {
74
+ if (child?.props?.decorations) {
75
+ const isSelection =
76
+ child.props.decorations.findIndex((deco) => deco.isSelection) >
77
+ -1;
78
+ if (isSelection)
79
+ return (
80
+ <span className="highlight-selection" key={`${i}-sel`}>
81
+ {child}
82
+ </span>
83
+ );
84
+ }
85
+ return child;
86
+ })
87
+ : children}
88
+ {extended_children}
89
+ {!isInternalURL(element.data?.url) &&
90
+ config.settings.siteProperties.markSpecialLinks && (
91
+ <Icon
92
+ icon="it-external-link"
93
+ size="xs"
94
+ className="ms-1 align-sub external-link"
95
+ />
96
+ )}
97
+ </a>
98
+ );
99
+ };
@@ -0,0 +1,47 @@
1
+ import React from 'react';
2
+ import { useSlate } from 'slate-react';
3
+
4
+ import { ToolbarButton } from '@plone/volto-slate/editor/ui';
5
+
6
+ import circleMenuSVG from '@plone/volto/icons/circle-menu.svg';
7
+
8
+ import {
9
+ toggleStyle,
10
+ isLinkStyleActive,
11
+ } from 'design-comuni-plone-theme/config/Slate/dropdownUtils';
12
+ import { insertToolbarButtons } from 'design-comuni-plone-theme/config/Slate/utils';
13
+ import { LinkElement as ItaliaLinkElement } from 'design-comuni-plone-theme/config/Slate/Link/renderer';
14
+
15
+ const LinkButtonButton = ({ icon, active, ...props }) => {
16
+ const CLASSNAME = 'btn btn-primary inline-link';
17
+ const editor = useSlate();
18
+ const isActive = isLinkStyleActive(editor, CLASSNAME);
19
+
20
+ return (
21
+ <ToolbarButton
22
+ {...props}
23
+ icon={icon}
24
+ active={isActive}
25
+ onMouseDown={(e) => {
26
+ e.stopPropagation();
27
+ e.preventDefault();
28
+ toggleStyle(editor, { cssClass: CLASSNAME, isBlock: false });
29
+ }}
30
+ />
31
+ );
32
+ };
33
+
34
+ export default function install(config) {
35
+ const { slate } = config.settings;
36
+
37
+ slate.buttons.linkButton = (props) => (
38
+ <LinkButtonButton title="Stile bottone" icon={circleMenuSVG} {...props} />
39
+ );
40
+ slate.elements.link = ItaliaLinkElement;
41
+
42
+ //aggiungo il bottone di headings alla toolbar, dopo strikethrough
43
+ insertToolbarButtons(['linkButton'], 'link', slate);
44
+
45
+ //htmlTagToSlate deserializer is defined in ./Link/deserializer.js
46
+ return config;
47
+ }
@@ -0,0 +1,51 @@
1
+ import React from 'react';
2
+ import { useSlate } from 'slate-react';
3
+
4
+ import { ToolbarButton } from '@plone/volto-slate/editor/ui';
5
+
6
+ import textLargerSVG from 'design-comuni-plone-theme/icons/text-larger.svg';
7
+
8
+ import {
9
+ toggleStyle,
10
+ isInlineStyleActive,
11
+ } from 'design-comuni-plone-theme/config/Slate/dropdownUtils';
12
+ import { insertToolbarButtons } from 'design-comuni-plone-theme/config/Slate/utils';
13
+
14
+ export const TextLargerElement = ({ attributes, children, element }) => {
15
+ return <span {...attributes}>{children}</span>;
16
+ };
17
+
18
+ const TextLargerButton = ({ icon, active, ...props }) => {
19
+ const CLASSNAME = 'text-larger';
20
+ const editor = useSlate();
21
+ const isActive = isInlineStyleActive(editor, CLASSNAME);
22
+
23
+ return (
24
+ <ToolbarButton
25
+ {...props}
26
+ icon={icon}
27
+ active={isActive}
28
+ onMouseDown={(event) => {
29
+ return toggleStyle(editor, { cssClass: CLASSNAME, isBlock: false });
30
+ }}
31
+ />
32
+ );
33
+ };
34
+
35
+ export default function install(config) {
36
+ const { slate } = config.settings;
37
+
38
+ slate.buttons.textLarger = (props) => (
39
+ <TextLargerButton
40
+ title="Testo più grande"
41
+ icon={textLargerSVG}
42
+ {...props}
43
+ />
44
+ );
45
+ slate.elements.textLarger = TextLargerElement;
46
+
47
+ //aggiungo il bottone di headings alla toolbar, dopo strikethrough
48
+ insertToolbarButtons(['textLarger'], 'strikethrough', slate);
49
+
50
+ return config;
51
+ }
@@ -0,0 +1,10 @@
1
+ import { insertToolbarButtons } from 'design-comuni-plone-theme/config/Slate/utils';
2
+
3
+ export default function install(config) {
4
+ const { slate } = config.settings;
5
+
6
+ //aggiungo il bottone di underline alla toolbar, dopo bold
7
+ insertToolbarButtons(['underline'], 'italic', slate);
8
+
9
+ return config;
10
+ }
@@ -0,0 +1,43 @@
1
+ //config.settings.slate.contextToolbarButtons
2
+ import RichTextWidget from 'design-comuni-plone-theme/components/ItaliaTheme/manage/Widgets/RichTextWidget';
3
+ import HtmlSlateWidget from 'design-comuni-plone-theme/components/ItaliaTheme/manage/Widgets/HtmlSlateWidget';
4
+ import installAlignment from 'design-comuni-plone-theme/config/Slate/Alignment';
5
+ import installHeadings from 'design-comuni-plone-theme/config/Slate/Headings';
6
+ import installUnderline from 'design-comuni-plone-theme/config/Slate/Underline';
7
+ import installBlockquote from 'design-comuni-plone-theme/config/Slate/Blockquote';
8
+ import installLinkButton from 'design-comuni-plone-theme/config/Slate/LinkButton';
9
+ import installTextLarger from 'design-comuni-plone-theme/config/Slate/TextLarger';
10
+ import installLink from 'design-comuni-plone-theme/config/Slate/Link';
11
+
12
+ import installHandlers from 'design-comuni-plone-theme/config/Slate/handlers';
13
+ import installDeserializers from 'design-comuni-plone-theme/config/Slate/deserializers';
14
+
15
+ export default function applyItaliaSlateConfig(config) {
16
+ installAlignment(config);
17
+ installHeadings(config);
18
+ installUnderline(config);
19
+ installTextLarger(config);
20
+ installLink(config);
21
+ installBlockquote(config);
22
+ installLinkButton(config);
23
+
24
+ installHandlers(config);
25
+ installDeserializers(config);
26
+
27
+ //remove callout because there's a Volto's block for it
28
+ delete config.settings.slate.elements.callout;
29
+ delete config.settings.slate.buttons.callout;
30
+ config.settings.slate.toolbarButtons = config.settings.slate.toolbarButtons.filter(
31
+ (b) => b !== 'callout',
32
+ );
33
+ config.settings.slate.expandedToolbarButtons = config.settings.slate.toolbarButtons.filter(
34
+ (b) => b !== 'callout',
35
+ );
36
+
37
+ //add wrapper public-ui to widgets
38
+ config.widgets.widget.slate = RichTextWidget;
39
+ config.widgets.widget.slate_richtext = RichTextWidget;
40
+ config.widgets.widget.slate_html = HtmlSlateWidget;
41
+ config.widgets.widget.richtext = HtmlSlateWidget;
42
+ return config;
43
+ }
@@ -0,0 +1,66 @@
1
+ import { jsx } from 'slate-hyperscript';
2
+ import { deserializeChildren } from '@plone/volto-slate/editor/deserialize';
3
+ import { TD, TH } from '@plone/volto-slate/constants';
4
+
5
+ /*rispetto a quello di volto-slate:
6
+ - aggiunge anche la classe (styleName) se era stata impostata
7
+ */
8
+ export const blockTagDeserializer = (tagname) => (editor, el, options) => {
9
+ // if (tagname === 'h2') debugger;
10
+ let children = deserializeChildren(el, editor, options).filter(
11
+ (n) => n !== null,
12
+ );
13
+
14
+ if (
15
+ [TD, TH].includes(tagname) &&
16
+ children.length > 0 &&
17
+ typeof children[0] === 'string'
18
+ ) {
19
+ // TODO: should here be handled the cases when there are more strings in
20
+ // `children` or when there are besides strings other types of nodes too?
21
+ const p = { type: 'div', children: [{ text: '' }] };
22
+ p.children[0].text = children[0];
23
+ children = [p];
24
+ }
25
+
26
+ // normalizes block elements so that they're never empty
27
+ // Avoids a hard crash from the Slate editor
28
+ const hasValidChildren = children.length && children.find((c) => !!c);
29
+ if (!hasValidChildren) {
30
+ children = [{ text: '' }];
31
+ }
32
+
33
+ return jsx(
34
+ 'element',
35
+ { type: tagname, styleName: el.getAttribute('class') },
36
+ children,
37
+ );
38
+ };
39
+
40
+ /*rispetto a quello di volto-slate:
41
+ - se il tag body contiene direttamente dei children <li> allora crea un <ul> wrapper
42
+ */
43
+ export const bodyTagDeserializer = () => (editor, el, options) => {
44
+ if (
45
+ el?.firstElementChild?.nodeName === 'LI' &&
46
+ el?.lastElementChild?.nodeName === 'LI'
47
+ ) {
48
+ return jsx(
49
+ 'element',
50
+ { type: 'ul' },
51
+ deserializeChildren(el, editor, options),
52
+ );
53
+ }
54
+ return jsx('fragment', {}, deserializeChildren(el, editor, options));
55
+ };
56
+
57
+ export default function install(config) {
58
+ config.settings.slate.htmlTagsToSlate.BODY = bodyTagDeserializer();
59
+ config.settings.slate.htmlTagsToSlate.P = blockTagDeserializer('p');
60
+ config.settings.slate.htmlTagsToSlate.OL = blockTagDeserializer('ol');
61
+ config.settings.slate.htmlTagsToSlate.UL = blockTagDeserializer('ul');
62
+ config.settings.slate.htmlTagsToSlate.BLOCKQUOTE =
63
+ blockTagDeserializer('blockquote');
64
+
65
+ //A (link) deserializer is defined in ./Link/deserializer.js
66
+ }
@@ -0,0 +1,14 @@
1
+ .cms-ui .slate-inline-toolbar {
2
+ .ui.buttons {
3
+ flex-wrap: wrap;
4
+ }
5
+ .ui.dropdown .menu > .item {
6
+ &.active {
7
+ color: #007eb1;
8
+ background-color: lighten(#007eb1, 60);
9
+ }
10
+ > .icon {
11
+ margin-right: 0;
12
+ }
13
+ }
14
+ }