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
@@ -62,7 +62,18 @@ const mock_allfields = {
62
62
  '@type': 'title',
63
63
  },
64
64
  'fbd627d2-46a1-4d32-b610-6aed2a142b36': {
65
- '@type': 'text',
65
+ '@type': 'slate',
66
+ plaintext: '',
67
+ value: [
68
+ {
69
+ children: [
70
+ {
71
+ text: '',
72
+ },
73
+ ],
74
+ type: 'p',
75
+ },
76
+ ],
66
77
  },
67
78
  },
68
79
  blocks_layout: {
@@ -26,7 +26,6 @@ export SectionIcon from 'design-comuni-plone-theme/components/ItaliaTheme/Icons/
26
26
 
27
27
  /********* COMMONS ********* */
28
28
  export CardCategory from 'design-comuni-plone-theme/components/ItaliaTheme/Cards/CardCategory';
29
- export RemoveBodyClass from 'design-comuni-plone-theme/components/ItaliaTheme/RemoveBodyClass/RemoveBodyClass';
30
29
  export CardPersona from 'design-comuni-plone-theme/components/ItaliaTheme/Cards/CardPersona';
31
30
  export GalleryPreview from 'design-comuni-plone-theme/components/ItaliaTheme/GalleryPreview/GalleryPreview';
32
31
 
@@ -44,8 +44,16 @@ class ColorListWidget extends Component {
44
44
  * @returns {string} Markup for the component.
45
45
  */
46
46
  render() {
47
- const { id, title, required, value, onChange, intl, colors, className } =
48
- this.props;
47
+ const {
48
+ id,
49
+ title,
50
+ required,
51
+ value,
52
+ onChange,
53
+ intl,
54
+ colors,
55
+ className,
56
+ } = this.props;
49
57
  return colors.length > 0 ? (
50
58
  <Form.Field
51
59
  inline
@@ -78,6 +86,7 @@ class ColorListWidget extends Component {
78
86
  active={value === color.name}
79
87
  circular
80
88
  aria-label={color.label}
89
+ title={color.label}
81
90
  />
82
91
  );
83
92
  })}
@@ -0,0 +1,156 @@
1
+ /**
2
+ * HtmlSlateWidget, a slate widget variant that saves its data as HTML
3
+ * CUSTOMIZATIONS:
4
+ * - rimossi i bottoni di allinemento, textlarger e blockquote perchè non funzionano nel widget e non servono in questi campi
5
+ * - aggiunta la classe public-ui
6
+ * - aggiunta la proprietà "fieldSet" per passare il nome del fieldset dentro SlateEditor. Quaste modifica è stata introdotta su volto 18: https://github.com/plone/volto/pull/6803
7
+ */
8
+
9
+ import React from 'react';
10
+ import ReactDOMServer from 'react-dom/server';
11
+ import configureStore from 'redux-mock-store';
12
+ import { MemoryRouter } from 'react-router-dom';
13
+ import { Provider, useSelector } from 'react-redux';
14
+ import { defineMessages, injectIntl } from 'react-intl';
15
+
16
+ import { FormFieldWrapper } from '@plone/volto/components';
17
+ import SlateEditor from '@plone/volto-slate/editor/SlateEditor';
18
+ import { serializeNodes } from '@plone/volto-slate/editor/render';
19
+ import { makeEditor } from '@plone/volto-slate/utils';
20
+ import deserialize from '@plone/volto-slate/editor/deserialize';
21
+
22
+ import {
23
+ createEmptyParagraph,
24
+ normalizeExternalData,
25
+ } from '@plone/volto-slate/utils';
26
+ import { ErrorBoundary } from '@plone/volto-slate/widgets/ErrorBoundary';
27
+ import config from '@plone/volto/registry';
28
+
29
+ import { getRichTextWidgetToolbarButtons } from 'design-comuni-plone-theme/config/Slate/utils';
30
+
31
+ import '@plone/volto-slate/widgets/style.css';
32
+
33
+ const messages = defineMessages({
34
+ error: {
35
+ id: 'An error has occurred while editing "{name}" field. We have been notified and we are looking into it. Please save your work and retry. If the issue persists please contact the site administrator.',
36
+ defaultMessage:
37
+ 'An error has occurred while editing "{name}" field. We have been notified and we are looking into it. Please save your work and retry. If the issue persists please contact the site administrator.',
38
+ },
39
+ });
40
+
41
+ const HtmlSlateWidget = (props) => {
42
+ const {
43
+ id,
44
+ onChange,
45
+ value,
46
+ focus,
47
+ fieldSet,
48
+ className,
49
+ block,
50
+ placeholder,
51
+ properties,
52
+ intl,
53
+ } = props;
54
+
55
+ const [selected, setSelected] = React.useState(focus);
56
+
57
+ const editor = React.useMemo(() => makeEditor(), []);
58
+
59
+ const token = useSelector((state) => state.userSession.token);
60
+
61
+ const toHtml = React.useCallback(
62
+ (value) => {
63
+ const mockStore = configureStore();
64
+ const html = ReactDOMServer.renderToStaticMarkup(
65
+ <Provider store={mockStore({ userSession: { token } })}>
66
+ <MemoryRouter>{serializeNodes(value || [])}</MemoryRouter>
67
+ </Provider>,
68
+ );
69
+ //console.log('toHtml', value, ' ----> ', html);
70
+
71
+ return {
72
+ 'content-type': value ? value['content-type'] : 'text/html',
73
+ encoding: value ? value.encoding : 'utf8',
74
+ data: html,
75
+ };
76
+ },
77
+ [token],
78
+ );
79
+
80
+ const fromHtml = React.useCallback(
81
+ (value) => {
82
+ const html = value?.data || '';
83
+
84
+ const parsed = new DOMParser().parseFromString(html, 'text/html');
85
+ const body =
86
+ parsed.getElementsByTagName('google-sheets-html-origin').length > 0
87
+ ? parsed.querySelector('google-sheets-html-origin > table')
88
+ : parsed.body;
89
+
90
+ let data = deserialize(editor, body, { collapseWhitespace: false });
91
+ data = normalizeExternalData(editor, data);
92
+
93
+ // editor.children = data;
94
+ // Editor.normalize(editor);
95
+ // TODO: need to add {text: ""} placeholders between elements
96
+ const res = data.length ? data : [createEmptyParagraph()];
97
+ // console.log('from html', { html: value?.data, res });
98
+ return res;
99
+ },
100
+ [editor],
101
+ );
102
+
103
+ const valueFromHtml = React.useMemo(() => {
104
+ //console.log('fromhtml', value, '--->', fromHtml(value));
105
+ return fromHtml(value);
106
+ }, [value, fromHtml]);
107
+
108
+ const handleChange = React.useCallback(
109
+ (newValue) => {
110
+ onChange(id, toHtml(newValue));
111
+ },
112
+ [onChange, toHtml, id],
113
+ );
114
+
115
+ const handleClick = React.useCallback(() => {
116
+ setSelected(true);
117
+ }, []);
118
+
119
+ let toolbarButtons = getRichTextWidgetToolbarButtons(config);
120
+
121
+ const slateSettings = {
122
+ ...config.settings.slate,
123
+ toolbarButtons: toolbarButtons,
124
+ };
125
+
126
+ return (
127
+ <FormFieldWrapper {...props} draggable={false} className="slate_wysiwyg">
128
+ <div
129
+ className="slate_wysiwyg_box public-ui"
130
+ role="textbox"
131
+ tabIndex="-1"
132
+ style={{ boxSizing: 'initial' }}
133
+ onClick={handleClick}
134
+ onKeyDown={() => {}}
135
+ >
136
+ <ErrorBoundary name={intl.formatMessage(messages.error, { name: id })}>
137
+ <SlateEditor
138
+ className={className}
139
+ id={id}
140
+ name={id}
141
+ value={valueFromHtml}
142
+ fieldSet={fieldSet}
143
+ onChange={handleChange}
144
+ block={block}
145
+ selected={selected}
146
+ properties={properties}
147
+ placeholder={placeholder}
148
+ slateSettings={slateSettings}
149
+ />
150
+ </ErrorBoundary>
151
+ </div>
152
+ </FormFieldWrapper>
153
+ );
154
+ };
155
+
156
+ export default injectIntl(HtmlSlateWidget);
@@ -0,0 +1,88 @@
1
+ /**
2
+ * A Slate widget that uses internal JSON representation as its value
3
+ * CUSTOMIZATIONS:
4
+ * - rimossi i bottoni di allinemento, textlarger e blockquote perchè non funzionano nel widget e non servono in questi campi
5
+ * - aggiunta la classe public-ui
6
+ */
7
+
8
+ import React from 'react';
9
+ import isUndefined from 'lodash/isUndefined';
10
+ import isString from 'lodash/isString';
11
+ import { FormFieldWrapper } from '@plone/volto/components';
12
+ import SlateEditor from '@plone/volto-slate/editor/SlateEditor';
13
+
14
+ import {
15
+ createEmptyParagraph,
16
+ createParagraph,
17
+ } from '@plone/volto-slate/utils/blocks';
18
+
19
+ import '@plone/volto-slate/widgets/style.css';
20
+ import { getRichTextWidgetToolbarButtons } from 'design-comuni-plone-theme/config/Slate/utils';
21
+
22
+ import config from '@plone/volto/registry';
23
+
24
+ const getValue = (value) => {
25
+ if (isUndefined(value) || !isUndefined(value?.data)) {
26
+ return [createEmptyParagraph()];
27
+ }
28
+ // Previously this was a text field
29
+ if (isString(value)) {
30
+ return [createParagraph(value)];
31
+ }
32
+ return value;
33
+ };
34
+
35
+ const SlateRichTextWidget = (props) => {
36
+ const {
37
+ id,
38
+ onChange,
39
+ value,
40
+ focus,
41
+ className,
42
+ block,
43
+ placeholder,
44
+ properties,
45
+ readOnly = false,
46
+ } = props;
47
+ const [selected, setSelected] = React.useState(focus);
48
+
49
+ let toolbarButtons = getRichTextWidgetToolbarButtons(config);
50
+
51
+ const slateSettings = {
52
+ ...config.settings.slate,
53
+ toolbarButtons: toolbarButtons,
54
+ };
55
+
56
+ return (
57
+ <FormFieldWrapper {...props} draggable={false} className="slate_wysiwyg">
58
+ <div
59
+ className="slate_wysiwyg_box public-ui"
60
+ role="textbox"
61
+ tabIndex="-1"
62
+ style={{ boxSizing: 'initial' }}
63
+ onClick={() => {
64
+ setSelected(true);
65
+ }}
66
+ onKeyDown={() => {}}
67
+ >
68
+ <SlateEditor
69
+ className={className}
70
+ readOnly={readOnly}
71
+ id={id}
72
+ name={id}
73
+ value={getValue(value)}
74
+ onChange={(newValue) => {
75
+ onChange(id, newValue);
76
+ }}
77
+ block={block}
78
+ selected={selected}
79
+ properties={properties}
80
+ placeholder={placeholder}
81
+ slateSettings={slateSettings}
82
+ />
83
+ </div>
84
+ </FormFieldWrapper>
85
+ );
86
+ };
87
+
88
+ export default SlateRichTextWidget;
@@ -0,0 +1,158 @@
1
+ /**
2
+ * Edit simple text block.
3
+ * @module components/Widgets/SimpleTextEditorWidget/SimpleTextEditorWidget
4
+ *
5
+ * E' un editor di testo da mettere nei blocchi, senza formattazione.
6
+ */
7
+
8
+ import React, { useRef, useEffect } from 'react';
9
+
10
+ import PropTypes from 'prop-types';
11
+ import { defineMessages, useIntl } from 'react-intl';
12
+ import { useInView } from 'react-intersection-observer';
13
+
14
+ import config from '@plone/volto/registry';
15
+
16
+ const messages = defineMessages({
17
+ text: {
18
+ id: 'Type text…',
19
+ defaultMessage: 'Type text…',
20
+ },
21
+ });
22
+
23
+ const SimpleTextEditorWidget = (props) => {
24
+ const intl = useIntl();
25
+ const {
26
+ data,
27
+ setSelected,
28
+ onSelectBlock,
29
+ onChangeBlock,
30
+ fieldName,
31
+ block,
32
+ value,
33
+ selected,
34
+ placeholder,
35
+ } = props;
36
+ const { ref, inView } = useInView({
37
+ threshold: 0,
38
+ rootMargin: '0px 0px 200px 0px',
39
+ });
40
+
41
+ const fieldRef = useRef();
42
+
43
+ const handleKey = (event) => {
44
+ const { slate } = config.settings;
45
+
46
+ const handlers = slate.textblockDetachedKeyboardHandlers[event.key];
47
+
48
+ if (handlers) {
49
+ // a handler can return `true` to signify it has handled the event in this
50
+ // case, the execution flow is stopped
51
+ const handlerProps = {
52
+ getBlockProps: () => {
53
+ return { ...props };
54
+ },
55
+ getSavedSelection: () => null,
56
+ };
57
+ return handlers.find((handler) =>
58
+ handler({ editor: handlerProps, event }),
59
+ );
60
+ }
61
+ };
62
+
63
+ useEffect(() => {
64
+ if (selected) {
65
+ fieldRef.current.focus();
66
+ }
67
+ }, [selected]);
68
+
69
+ useEffect(() => {
70
+ //inizializzazione del valore nel campo
71
+ const _value = value ?? data[fieldName];
72
+ if (fieldRef.current && _value?.length > 0) {
73
+ fieldRef.current.innerText = _value;
74
+ }
75
+ }, []);
76
+
77
+ const selectThis = () => {
78
+ if (setSelected) {
79
+ setSelected(fieldName ?? true);
80
+ } else if (onSelectBlock) {
81
+ onSelectBlock(block);
82
+ }
83
+ };
84
+
85
+ const pasteAsTextPlain = (e) => {
86
+ e.preventDefault();
87
+ var text = '';
88
+ if (e.clipboardData || e.originalEvent.clipboardData) {
89
+ text = (e.originalEvent || e).clipboardData.getData('text/plain');
90
+ } else if (window.clipboardData) {
91
+ text = window.clipboardData.getData('Text');
92
+ }
93
+
94
+ text = text.replaceAll('\n', ' ');
95
+
96
+ if (document.queryCommandSupported('insertText')) {
97
+ document.execCommand('insertText', false, text);
98
+ } else {
99
+ document.execCommand('paste', false, text);
100
+ }
101
+ };
102
+
103
+ return (
104
+ <div className="simple-text-editor-widget" ref={ref}>
105
+ <span
106
+ className="simple-text-input"
107
+ contentEditable={inView} //se è in view è editabile, altrimenti è readOnly
108
+ dir="ltr"
109
+ suppressContentEditableWarning={true}
110
+ role="textbox"
111
+ tabIndex={0}
112
+ placeholder={placeholder || intl.formatMessage(messages.text)}
113
+ onInput={(e) => {
114
+ let retVal = {
115
+ value: e.target.textContent,
116
+ };
117
+ if (fieldName) {
118
+ retVal = { [fieldName]: e.target.textContent };
119
+ }
120
+
121
+ onChangeBlock(block, { ...data, ...retVal });
122
+ }}
123
+ onFocus={(e) => {
124
+ if (!selected) {
125
+ selectThis();
126
+ }
127
+ }}
128
+ onBlur={(e) => {
129
+ setSelected(fieldName ? null : false);
130
+ }}
131
+ onPaste={(e) => {
132
+ pasteAsTextPlain(e);
133
+ }}
134
+ onKeyDown={handleKey}
135
+ ref={fieldRef}
136
+ />
137
+ </div>
138
+ );
139
+ };
140
+
141
+ SimpleTextEditorWidget.propTypes = {
142
+ data: PropTypes.objectOf(PropTypes.any).isRequired,
143
+ setSelected: PropTypes.func.isRequired,
144
+ onSelectBlock: PropTypes.func.isRequired,
145
+ onChangeBlock: PropTypes.func.isRequired,
146
+ block: PropTypes.string.isRequired,
147
+ value: PropTypes.string,
148
+ selected: PropTypes.bool.isRequired,
149
+ placeholder: PropTypes.string.isRequired,
150
+ focusPrevField: PropTypes.func,
151
+ focusNextField: PropTypes.func,
152
+ //from block props:
153
+ properties: PropTypes.objectOf(PropTypes.any).isRequired,
154
+ onFocusPreviousBlock: PropTypes.func.isRequired,
155
+ onFocusNextBlock: PropTypes.func.isRequired,
156
+ };
157
+
158
+ export default SimpleTextEditorWidget;