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
@@ -6,27 +6,16 @@
6
6
  import React from 'react';
7
7
  import PropTypes from 'prop-types';
8
8
  import cx from 'classnames';
9
- import redraft from 'redraft';
10
9
  import { Container, Row, Col } from 'design-react-kit';
11
10
  //import { isCmsUi } from '@plone/volto/helpers';
12
- import config from '@plone/volto/registry';
11
+ import { TextBlockView } from '@plone/volto-slate/blocks/Text';
13
12
 
14
13
  /**
15
14
  * View Alert block class.
16
15
  * @class View
17
16
  * @extends Component
18
17
  */
19
- const View = ({ data, pathname }) => {
20
- //const isCmsUI = pathname ? isCmsUi(pathname) : false
21
-
22
- const content = data.text
23
- ? redraft(
24
- data.text,
25
- config.settings.richtextViewSettings.ToHTMLRenderers,
26
- config.settings.richtextViewSettings.ToHTMLOptions,
27
- )
28
- : '';
29
-
18
+ const View = ({ data, id }) => {
30
19
  const background_color = data.bg_color ?? data.color; // backwards compatibility with previous background-color variable name 'color'
31
20
 
32
21
  return (
@@ -47,7 +36,9 @@ const View = ({ data, pathname }) => {
47
36
  />
48
37
  </Col>
49
38
  )}
50
- <Col>{content}</Col>
39
+ <Col>
40
+ <TextBlockView id={id} data={{ value: data.text }} />
41
+ </Col>
51
42
  </Row>
52
43
  </Container>
53
44
  </div>
@@ -8,11 +8,11 @@ import {
8
8
  CardText,
9
9
  CardReadMore,
10
10
  } from 'design-react-kit';
11
- import redraft from 'redraft';
11
+
12
12
  import { UniversalLink } from '@plone/volto/components';
13
13
  import { flattenToAppURL } from '@plone/volto/helpers';
14
14
  import { ArgumentIcon } from 'design-comuni-plone-theme/components/ItaliaTheme/View';
15
- import config from '@plone/volto/registry';
15
+ import { TextBlockView } from '@plone/volto-slate/blocks/Text';
16
16
 
17
17
  const messages = defineMessages({
18
18
  text: {
@@ -33,10 +33,11 @@ const Block = ({
33
33
  data,
34
34
  inEditMode,
35
35
  selected,
36
- focusOn,
37
36
  block,
38
37
  onChange,
39
38
  intl,
39
+ index,
40
+ ...otherProps
40
41
  }) => {
41
42
  const argument = data?.argument ? data?.argument[0] : null;
42
43
 
@@ -49,21 +50,25 @@ const Block = ({
49
50
  <CardText tag="p">{argument?.description}</CardText>
50
51
  {inEditMode ? (
51
52
  <TextEditorWidget
53
+ {...otherProps}
52
54
  data={data}
55
+ block={block}
53
56
  fieldName="title"
54
57
  selected={selected}
55
- block={block}
56
- onChangeBlock={onChange}
57
58
  placeholder={intl.formatMessage(messages.text)}
58
- focusOn={focusOn}
59
+ onChangeBlock={(block, _data) => {
60
+ onChange(_data);
61
+ }}
62
+ setSelected={() => {
63
+ otherProps.onSubblockChangeFocus(index);
64
+ }}
59
65
  />
60
66
  ) : (
61
67
  <div>
62
- {redraft(
63
- data.title,
64
- config.settings.richtextViewSettings.ToHTMLRenderers,
65
- config.settings.richtextViewSettings.ToHTMLOptions,
66
- )}
68
+ <TextBlockView
69
+ id={otherProps.id + '-' + index}
70
+ data={{ value: data.title }}
71
+ />
67
72
  </div>
68
73
  )}
69
74
  {argument && (
@@ -23,13 +23,14 @@ class Body extends SubblockEdit {
23
23
  return (
24
24
  <Subblock subblock={this} className="subblock-edit">
25
25
  <Block
26
+ {...this.props}
26
27
  data={this.props.data}
27
28
  index={this.props.index}
28
29
  key={this.props.index}
29
30
  inEditMode={this.props.inEditMode}
30
31
  selected={this.props.selected || this.state.focusOn === 'title'}
31
32
  block={this.props.block}
32
- focusOn={this.props.focusOn}
33
+ focusOn={this.state.focusOn}
33
34
  intl={this.props.intl}
34
35
  onChange={this.onChange}
35
36
  />
@@ -11,20 +11,58 @@ import {
11
11
  import { SidebarPortal } from '@plone/volto/components';
12
12
  import Sidebar from 'design-comuni-plone-theme/components/ItaliaTheme/Blocks/ArgumentsInEvidence/Sidebar.jsx';
13
13
  import { ArgumentsInEvidenceBackground } from 'design-comuni-plone-theme/components/ItaliaTheme';
14
+ import { handleKeyDownOwnFocusManagement } from 'design-comuni-plone-theme/helpers/blocks';
14
15
 
15
16
  class Edit extends SubblocksEdit {
17
+ handleEnter = (e) => {
18
+ if (this.props.selected) {
19
+ handleKeyDownOwnFocusManagement(e, this.props);
20
+ }
21
+ };
22
+
23
+ componentDidMount() {
24
+ const blockNode = this.props.blockNode;
25
+
26
+ if (this.props.selected && this.node) {
27
+ this.node.focus();
28
+ }
29
+ if (this.state.subblocks.length === 0) {
30
+ this.addSubblock();
31
+ }
32
+
33
+ if (blockNode && blockNode.current) {
34
+ blockNode.current.addEventListener('keydown', this.handleEnter, false);
35
+ }
36
+ }
37
+
38
+ /**
39
+ * Component will receive props
40
+ * @method componentWillUnmount
41
+ * @returns {undefined}
42
+ */
43
+ componentWillUnmount() {
44
+ if (this.props.selected && this.node) {
45
+ this.node.focus();
46
+ }
47
+ const blockNode = this.props.blockNode;
48
+ if (blockNode && blockNode.current) {
49
+ blockNode.current.removeEventListener('keydown', this.handleEnter, false);
50
+ }
51
+ }
52
+
16
53
  render() {
17
54
  const hasArguments = this.props.data.subblocks?.some((subblock) => {
18
55
  return subblock.argument?.length > 0;
19
56
  });
20
57
 
21
58
  return (
22
- <div className="argumentInEvidence public-ui">
59
+ <div className="argumentInEvidence public-ui" tabIndex="-1">
23
60
  {hasArguments && <ArgumentsInEvidenceBackground inEditMode={true} />}
24
61
  <SubblocksWrapper node={this.node}>
25
62
  <BodyWrapper data={this.props.data} inEditMode={false}>
26
63
  {this.state.subblocks.map((subblock, subindex) => (
27
64
  <Body
65
+ {...this.props}
28
66
  data={subblock}
29
67
  index={subindex}
30
68
  key={subblock.id}
@@ -5,9 +5,10 @@ import { defineMessages, useIntl } from 'react-intl';
5
5
  import PropTypes from 'prop-types';
6
6
  import { TextEditorWidget } from 'design-comuni-plone-theme/components/ItaliaTheme';
7
7
  import { UniversalLink } from '@plone/volto/components';
8
+ import { TextBlockView } from '@plone/volto-slate/blocks/Text';
9
+ import { useHandleDetachedBlockFocus } from 'design-comuni-plone-theme/helpers/blocks';
8
10
  import config from '@plone/volto/registry';
9
11
  import cx from 'classnames';
10
- import redraft from 'redraft';
11
12
 
12
13
  const messages = defineMessages({
13
14
  cta_title: {
@@ -24,36 +25,19 @@ const messages = defineMessages({
24
25
  },
25
26
  });
26
27
 
27
-
28
- const Block = ({
29
- data,
30
- block,
31
- inEditMode,
32
- onChangeBlock,
33
- onSelectBlock,
34
- onAddBlock,
35
- index,
36
- onFocusNextBlock,
37
- onFocusPreviousBlock,
38
- selected,
39
- }) => {
28
+ const Block = (props) => {
29
+ const { data, block, inEditMode, selected, ...otherProps } = props;
40
30
  const intl = useIntl();
41
31
  const Image = config.getComponent({ name: 'Image' }).component;
42
- const title = data?.cta_title?.blocks[0]?.text;
32
+ const title = data?.cta_title;
43
33
  const hasImage = data?.showImage && data?.ctaImage?.length > 0;
44
34
  const content = data?.cta_content;
45
35
  const showFullwidth = data?.showFullWidth;
46
36
 
47
- const [selectedField, setSelectedField] = useState('title');
48
- const titleRef = useRef();
49
- const contentRef = useRef();
50
- useEffect(() => {
51
- if (selected) {
52
- setSelectedField('title');
53
- } else {
54
- setSelectedField(null);
55
- }
56
- }, [selected]);
37
+ const { selectedField, setSelectedField } = useHandleDetachedBlockFocus(
38
+ props,
39
+ 'cta_title',
40
+ );
57
41
 
58
42
  return (
59
43
  <div
@@ -61,20 +45,6 @@ const Block = ({
61
45
  'has-image': hasImage,
62
46
  'full-width': showFullwidth,
63
47
  })}
64
- onKeyDown={(e) => {
65
- if (e.key === 'Enter' && !e.shiftKey) {
66
- if (
67
- !titleRef.current.contains(e.target) &&
68
- !contentRef.current.contains(e.target)
69
- ) {
70
- this.props.onAddBlock('text', index + 1);
71
- }
72
-
73
- if (titleRef.current.contains(e.target)) {
74
- setSelectedField('content');
75
- }
76
- }
77
- }}
78
48
  >
79
49
  {hasImage && data?.ctaImage?.length > 0 && (
80
50
  <figure className="img-wrapper">
@@ -94,70 +64,40 @@ const Block = ({
94
64
  <div className="cta-tile-text">
95
65
  <h2 className="title mt-0" id={block + 'title'}>
96
66
  {inEditMode ? (
97
- <div
98
- ref={titleRef}
99
- onClick={() => {
100
- setSelectedField('title');
101
- }}
102
- onFocus={() => {
103
- setSelectedField('title');
67
+ <TextEditorWidget
68
+ {...otherProps}
69
+ showToolbar={false}
70
+ data={data}
71
+ fieldName="cta_title"
72
+ selected={selected && selectedField === 'cta_title'}
73
+ setSelected={setSelectedField}
74
+ block={block}
75
+ placeholder={intl.formatMessage(messages.cta_title)}
76
+ focusNextField={() => {
77
+ setSelectedField('cta_content');
104
78
  }}
105
- >
106
- <TextEditorWidget
107
- data={data}
108
- fieldName="cta_title"
109
- selected={selectedField === 'title'}
110
- block={block}
111
- onChangeBlock={(data) => onChangeBlock(block, data)}
112
- placeholder={intl.formatMessage(messages.cta_title)}
113
- showToolbar={false}
114
- onSelectBlock={() => {}}
115
- onAddBlock={() => {
116
- setSelectedField('content');
117
- }}
118
- onFocusNextBlock={() => {
119
- setSelectedField('content');
120
- }}
121
- onFocusPreviousBlock={onFocusPreviousBlock}
122
- />
123
- </div>
79
+ />
124
80
  ) : (
125
81
  title
126
82
  )}
127
83
  </h2>
84
+
128
85
  {inEditMode ? (
129
- <div
130
- ref={contentRef}
131
- onClick={() => {
132
- setSelectedField('content');
133
- }}
134
- onFocus={() => {
135
- setSelectedField('content');
86
+ <TextEditorWidget
87
+ {...otherProps}
88
+ showToolbar={true}
89
+ data={data}
90
+ fieldName="cta_content"
91
+ block={block}
92
+ selected={selected && selectedField === 'cta_content'}
93
+ placeholder={intl.formatMessage(messages.cta_content)}
94
+ setSelected={setSelectedField}
95
+ focusPrevField={() => {
96
+ setSelectedField('cta_title');
136
97
  }}
137
- >
138
- <TextEditorWidget
139
- data={data}
140
- fieldName="cta_content"
141
- selected={selectedField === 'content'}
142
- block={block}
143
- onChangeBlock={(data) => onChangeBlock(block, data)}
144
- placeholder={intl.formatMessage(messages.cta_content)}
145
- showToolbar={true}
146
- onSelectBlock={onSelectBlock}
147
- onAddBlock={onAddBlock}
148
- index={index}
149
- onFocusNextBlock={onFocusNextBlock}
150
- onFocusPreviousBlock={() => {
151
- setSelectedField('title');
152
- }}
153
- />
154
- </div>
98
+ />
155
99
  ) : (
156
- redraft(
157
- content,
158
- config.settings.richtextViewSettings.ToHTMLRenderers,
159
- config.settings.richtextViewSettings.ToHTMLOptions,
160
- )
100
+ <TextBlockView data={{ value: content }} />
161
101
  )}
162
102
  {data.ctaLink?.length > 0 && data.ctaLinkTitle?.length > 0 && (
163
103
  <div className="mt-5">
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Edit Callout block.
3
+ * @module components/ItaliaTheme/Blocks/Callout/Edit
4
+ */
5
+
6
+ import React from 'react';
7
+ import PropTypes from 'prop-types';
8
+ import { defineMessages, useIntl } from 'react-intl';
9
+ import { SidebarPortal } from '@plone/volto/components';
10
+
11
+ import { Callout, CalloutTitle, CalloutText } from 'design-react-kit';
12
+ import { Icon } from 'design-comuni-plone-theme/components/ItaliaTheme';
13
+ import Sidebar from './Sidebar.jsx';
14
+ import { TextEditorWidget } from 'design-comuni-plone-theme/components/ItaliaTheme';
15
+ import { useHandleDetachedBlockFocus } from 'design-comuni-plone-theme/helpers/blocks';
16
+
17
+ const messages = defineMessages({
18
+ title: {
19
+ id: 'Type the title…',
20
+ defaultMessage: 'Type the title…',
21
+ },
22
+ text: {
23
+ id: 'Type text…',
24
+ defaultMessage: 'Digita il testo…',
25
+ },
26
+ });
27
+ /**
28
+ * Edit Calloout block class.
29
+ * @class Edit
30
+ * @extends Component
31
+ */
32
+ const Edit = (props) => {
33
+ const { data, onChangeBlock, block, onSelectBlock, selected, ...otherProps } =
34
+ props;
35
+ const intl = useIntl();
36
+ const { selectedField, setSelectedField } = useHandleDetachedBlockFocus(
37
+ props,
38
+ 'title',
39
+ );
40
+
41
+ return __SERVER__ ? (
42
+ <div />
43
+ ) : (
44
+ <div className="public-ui" id={block} tabIndex="-1" role="textbox">
45
+ <Callout
46
+ highlight={data.style === 'highlight'}
47
+ color={data.color?.replace('callout_', '')}
48
+ >
49
+ <CalloutTitle tag="h4">
50
+ {data.icon && <Icon icon={data.icon} padding={false} aria-hidden />}
51
+
52
+ <div className="text">
53
+ <TextEditorWidget
54
+ {...otherProps}
55
+ showToolbar={false}
56
+ data={data}
57
+ block={block}
58
+ fieldName="title"
59
+ onChangeBlock={onChangeBlock}
60
+ selected={selected && selectedField === 'title'}
61
+ placeholder={intl.formatMessage(messages.title)}
62
+ setSelected={setSelectedField}
63
+ focusNextField={() => {
64
+ setSelectedField('text');
65
+ }}
66
+ onSelectBlock={onSelectBlock}
67
+ />
68
+ </div>
69
+ </CalloutTitle>
70
+ <CalloutText>
71
+ <TextEditorWidget
72
+ {...otherProps}
73
+ data={data}
74
+ fieldName="text"
75
+ block={block}
76
+ onSelectBlock={onSelectBlock}
77
+ selected={selected && selectedField === 'text'}
78
+ placeholder={intl.formatMessage(messages.text)}
79
+ onChangeBlock={onChangeBlock}
80
+ setSelected={setSelectedField}
81
+ focusPrevField={() => {
82
+ setSelectedField('title');
83
+ }}
84
+ />
85
+ </CalloutText>
86
+ </Callout>
87
+
88
+ <SidebarPortal selected={selected || false}>
89
+ <Sidebar data={data} block={block} onChangeBlock={onChangeBlock} />
90
+ </SidebarPortal>
91
+ </div>
92
+ );
93
+ };
94
+
95
+ Edit.propTypes = {
96
+ properties: PropTypes.objectOf(PropTypes.any).isRequired,
97
+ selected: PropTypes.bool.isRequired,
98
+ index: PropTypes.number.isRequired,
99
+ onChangeField: PropTypes.func.isRequired,
100
+ onSelectBlock: PropTypes.func.isRequired,
101
+ onDeleteBlock: PropTypes.func.isRequired,
102
+ onAddBlock: PropTypes.func.isRequired,
103
+ onFocusPreviousBlock: PropTypes.func.isRequired,
104
+ onFocusNextBlock: PropTypes.func.isRequired,
105
+ block: PropTypes.string.isRequired,
106
+ };
107
+
108
+ export default Edit;
@@ -0,0 +1,173 @@
1
+ import React, { useEffect } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { Segment } from 'semantic-ui-react';
4
+ import { FormattedMessage, injectIntl } from 'react-intl';
5
+ import { /*TextWidget,*/ SelectWidget } from '@plone/volto/components';
6
+ import { injectLazyLibs } from '@plone/volto/helpers/Loadable/Loadable';
7
+ import { defineMessages, useIntl } from 'react-intl';
8
+ import { ColorListWidget } from 'design-comuni-plone-theme/components/ItaliaTheme';
9
+ import { Icon } from 'design-comuni-plone-theme/components/ItaliaTheme';
10
+ import { FormFieldWrapper } from '@plone/volto/components';
11
+
12
+ const messages = defineMessages({
13
+ color: { id: 'color', defaultMessage: 'Colore' },
14
+ color_default: {
15
+ id: 'color_default',
16
+ defaultMessage: 'Default',
17
+ },
18
+ color_success: {
19
+ id: 'color_success',
20
+ defaultMessage: 'Success',
21
+ },
22
+ color_warning: {
23
+ id: 'color_warning',
24
+ defaultMessage: 'Warning',
25
+ },
26
+ color_danger: {
27
+ id: 'color_danger',
28
+ defaultMessage: 'Danger',
29
+ },
30
+ color_note: {
31
+ id: 'color_note',
32
+ defaultMessage: 'Note',
33
+ },
34
+ style: { id: 'callout_style', defaultMessage: 'Stile' },
35
+ style_basic: { id: 'callout_style_basic', defaultMessage: 'Base' },
36
+ style_highlight: {
37
+ id: 'callout_style_highlight',
38
+ defaultMessage: 'In evidenza',
39
+ },
40
+ icon: {
41
+ id: 'icon',
42
+ defaultMessage: 'Icona',
43
+ },
44
+ });
45
+
46
+ const Sidebar = ({ data, block, onChangeBlock, reactSelect }) => {
47
+ const intl = useIntl();
48
+ const { Option } = reactSelect.components;
49
+ const colors = [
50
+ {
51
+ name: 'callout_default',
52
+ label: intl.formatMessage(messages.color_default),
53
+ },
54
+ { name: 'success', label: intl.formatMessage(messages.color_success) },
55
+ { name: 'warning', label: intl.formatMessage(messages.color_warning) },
56
+ { name: 'danger', label: intl.formatMessage(messages.color_danger) },
57
+ { name: 'callout_note', label: intl.formatMessage(messages.color_note) },
58
+ ];
59
+
60
+ const styles = [
61
+ ['base', intl.formatMessage(messages.style_basic)],
62
+ ['highlight', intl.formatMessage(messages.style_highlight)],
63
+ ];
64
+
65
+ useEffect(() => {
66
+ if (!data.style) {
67
+ //default nuovo blocco
68
+ onChangeBlock(block, {
69
+ ...data,
70
+ style: styles[0][0],
71
+ icon: 'it-info-circle',
72
+ });
73
+ }
74
+ }, []);
75
+
76
+ return (
77
+ <Segment.Group raised>
78
+ <header className="header pulled">
79
+ <h2>
80
+ <FormattedMessage id="Callout" defaultMessage="Callout" />
81
+ </h2>
82
+ </header>
83
+ <div className="ui form">
84
+ <SelectWidget
85
+ id="style"
86
+ title={intl.formatMessage(messages.style)}
87
+ required={false}
88
+ value={data.style}
89
+ intl={intl}
90
+ onChange={(id, value) => {
91
+ onChangeBlock(block, { ...data, [id]: value });
92
+ }}
93
+ choices={styles}
94
+ noValueOption={false}
95
+ />
96
+ <ColorListWidget
97
+ id="color"
98
+ title={intl.formatMessage(messages.color)}
99
+ value={data.color}
100
+ onChange={(id, value) => {
101
+ onChangeBlock(block, {
102
+ ...data,
103
+ [id]: value,
104
+ });
105
+ }}
106
+ colors={colors}
107
+ />
108
+
109
+ <div className="select-icon-widget">
110
+ <SelectWidget
111
+ id="icon"
112
+ title={intl.formatMessage(messages.icon)}
113
+ required={false}
114
+ value={data.icon}
115
+ intl={intl}
116
+ onChange={(id, value) => {
117
+ onChangeBlock(block, { ...data, [id]: value });
118
+ }}
119
+ choices={[
120
+ ['it-info-circle', 'Info'],
121
+ ['it-check-circle', 'Check'],
122
+ ['it-help-circle', 'Help'],
123
+ ['it-close-circle', 'Close'],
124
+ ]}
125
+ customOptionStyling={(props) => {
126
+ return (
127
+ <Option {...props}>
128
+ {props.data.value !== 'no-value' && (
129
+ <span className="icon-container italia-icon">
130
+ <Icon icon={props.data.value} />
131
+ </span>
132
+ )}
133
+ <span className="label-container">{props.data.label}</span>
134
+ </Option>
135
+ );
136
+ }}
137
+ />
138
+
139
+ <FormFieldWrapper id="icon-preview-widget-id" title="">
140
+ <p className="help">
141
+ {data.icon ? (
142
+ <Icon icon={data.icon} className="show-icon-italia" />
143
+ ) : (
144
+ <></>
145
+ )}
146
+ </p>
147
+ </FormFieldWrapper>
148
+ </div>
149
+ {/* <TextWidget
150
+ id="title"
151
+ title={intl.formatMessage(messages.linkMoreTitle)}
152
+ value={data.linkMoreTitle}
153
+ onChange={(name, value) => {
154
+ onChangeBlock(block, {
155
+ ...data,
156
+ linkMoreTitle: value,
157
+ });
158
+ }}
159
+ /> */}
160
+ </div>
161
+ </Segment.Group>
162
+ );
163
+ };
164
+
165
+ Sidebar.propTypes = {
166
+ data: PropTypes.objectOf(PropTypes.any),
167
+ block: PropTypes.string,
168
+ onChangeBlock: PropTypes.func,
169
+ selected: PropTypes.any,
170
+ setSelected: PropTypes.func,
171
+ };
172
+
173
+ export default injectLazyLibs('reactSelect')(injectIntl(Sidebar));
@@ -0,0 +1,45 @@
1
+ /**
2
+ * View Callout block.
3
+ * @module components/ItaliaTheme/Blocks/Callout/View
4
+ */
5
+
6
+ import React from 'react';
7
+ import PropTypes from 'prop-types';
8
+
9
+ import { Callout, CalloutTitle, CalloutText } from 'design-react-kit';
10
+ import { Icon } from 'design-comuni-plone-theme/components/ItaliaTheme';
11
+ import { TextBlockView } from '@plone/volto-slate/blocks/Text';
12
+ /**
13
+ * View Callout block class.
14
+ * @class CalloutView
15
+ * @extends Component
16
+ */
17
+
18
+ const View = ({ data, id }) => {
19
+ return (
20
+ <div className="block callout_block" id={id}>
21
+ <Callout
22
+ highlight={data.style === 'highlight'}
23
+ color={data.color?.replace('callout_', '')}
24
+ >
25
+ <CalloutTitle>
26
+ {data.icon && <Icon icon={data.icon} padding={false} aria-hidden />}
27
+ <span className="text">{data.title}</span>
28
+ </CalloutTitle>
29
+ <CalloutText>
30
+ <TextBlockView id={id} data={{ value: data.text }} />
31
+ </CalloutText>
32
+ </Callout>
33
+ </div>
34
+ );
35
+ };
36
+ /**
37
+ * Property types.
38
+ * @property {Object} propTypes Property types.
39
+ * @static
40
+ */
41
+ View.propTypes = {
42
+ data: PropTypes.objectOf(PropTypes.any).isRequired,
43
+ };
44
+
45
+ export default View;