design-comuni-plone-theme 11.10.1 → 12.0.0-alpha.1

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 (194) hide show
  1. package/.github/workflows/slate.yml +47 -0
  2. package/.yarn/cache/@babel-helper-module-imports-npm-7.24.3-edb733448b-c23492189b.zip +0 -0
  3. package/.yarn/cache/@babel-types-npm-7.24.0-a0508cb308-4b574a37d4.zip +0 -0
  4. package/.yarn/cache/babel-plugin-lodash-npm-3.3.4-c7161075b6-044a4261e6.zip +0 -0
  5. package/.yarn/cache/require-package-name-npm-2.0.1-ac9a206b63-00f4e9e467.zip +0 -0
  6. package/.yarn/cache/{volto-form-block-npm-3.7.2-f24953a510-7387a1b85a.zip → volto-form-block-npm-3.8.2-e49cbe07d5-5b72a06a5e.zip} +0 -0
  7. package/.yarn/install-state.gz +0 -0
  8. package/CHANGELOG.md +878 -904
  9. package/RELEASE.md +8 -0
  10. package/locales/de/LC_MESSAGES/volto.po +86 -18
  11. package/locales/en/LC_MESSAGES/volto.po +86 -18
  12. package/locales/es/LC_MESSAGES/volto.po +86 -18
  13. package/locales/fr/LC_MESSAGES/volto.po +86 -18
  14. package/locales/it/LC_MESSAGES/volto.po +86 -18
  15. package/locales/volto.pot +87 -19
  16. package/package.json +4 -2
  17. package/publiccode.yml +2 -2
  18. package/src/components/Collapse.jsx +1 -0
  19. package/src/components/ItaliaTheme/Blocks/Accordion/Block/EditBlock.jsx +29 -24
  20. package/src/components/ItaliaTheme/Blocks/Accordion/Block/ViewBlock.jsx +4 -12
  21. package/src/components/ItaliaTheme/Blocks/Accordion/Edit.jsx +67 -6
  22. package/src/components/ItaliaTheme/Blocks/Alert/Edit.jsx +60 -113
  23. package/src/components/ItaliaTheme/Blocks/Alert/Sidebar.jsx +1 -0
  24. package/src/components/ItaliaTheme/Blocks/Alert/View.jsx +5 -14
  25. package/src/components/ItaliaTheme/Blocks/ArgumentsInEvidence/Block.jsx +16 -11
  26. package/src/components/ItaliaTheme/Blocks/ArgumentsInEvidence/Body.jsx +2 -1
  27. package/src/components/ItaliaTheme/Blocks/ArgumentsInEvidence/Edit.jsx +39 -1
  28. package/src/components/ItaliaTheme/Blocks/CTABlock/Block.jsx +35 -95
  29. package/src/components/ItaliaTheme/Blocks/Callout/Edit.jsx +108 -0
  30. package/src/components/ItaliaTheme/Blocks/Callout/Sidebar.jsx +173 -0
  31. package/src/components/ItaliaTheme/Blocks/Callout/View.jsx +45 -0
  32. package/src/components/ItaliaTheme/Blocks/ContactsBlock/Block/EditBlock.jsx +84 -63
  33. package/src/components/ItaliaTheme/Blocks/ContactsBlock/Block/ViewBlock.jsx +19 -39
  34. package/src/components/ItaliaTheme/Blocks/ContactsBlock/Edit.jsx +92 -19
  35. package/src/components/ItaliaTheme/Blocks/ContactsBlock/View.jsx +13 -21
  36. package/src/components/ItaliaTheme/Blocks/CountDown/Edit.jsx +21 -25
  37. package/src/components/ItaliaTheme/Blocks/CountDown/View.jsx +6 -15
  38. package/src/components/ItaliaTheme/Blocks/IconBlocks/Block/EditBlock.jsx +40 -15
  39. package/src/components/ItaliaTheme/Blocks/IconBlocks/Block/ViewBlock.jsx +6 -21
  40. package/src/components/ItaliaTheme/Blocks/IconBlocks/Edit.jsx +93 -20
  41. package/src/components/ItaliaTheme/Blocks/IconBlocks/Sidebar.jsx +1 -9
  42. package/src/components/ItaliaTheme/Blocks/IconBlocks/View.jsx +4 -17
  43. package/src/components/ItaliaTheme/Blocks/NumbersBlock/Block/EditBlock.jsx +46 -15
  44. package/src/components/ItaliaTheme/Blocks/NumbersBlock/Block/ViewBlock.jsx +2 -18
  45. package/src/components/ItaliaTheme/Blocks/NumbersBlock/Edit.jsx +84 -11
  46. package/src/components/ItaliaTheme/Blocks/NumbersBlock/View.jsx +2 -11
  47. package/src/components/ItaliaTheme/Blocks/TextCard/CardWithImage/Block.jsx +33 -67
  48. package/src/components/ItaliaTheme/Blocks/TextCard/CardWithImage/Edit.jsx +2 -8
  49. package/src/components/ItaliaTheme/Blocks/TextCard/SimpleCard/BodyWrapper.jsx +2 -1
  50. package/src/components/ItaliaTheme/Blocks/TextCard/SimpleCard/Edit.jsx +98 -84
  51. package/src/components/ItaliaTheme/Blocks/TextCard/SimpleCard/View.jsx +20 -3
  52. package/src/components/ItaliaTheme/Blocks/__tests__/Accordion.test.jsx +11 -28
  53. package/src/components/ItaliaTheme/Blocks/__tests__/Alert.test.jsx +10 -14
  54. package/src/components/ItaliaTheme/Blocks/__tests__/ArgumentsInEvidence.test.jsx +20 -28
  55. package/src/components/ItaliaTheme/Blocks/__tests__/CTABlock.test.jsx +14 -29
  56. package/src/components/ItaliaTheme/Blocks/__tests__/CardWithImage.test.jsx +11 -28
  57. package/src/components/ItaliaTheme/Blocks/__tests__/ContactsBlock.test.jsx +75 -140
  58. package/src/components/ItaliaTheme/Blocks/__tests__/Countdown.test.jsx +20 -28
  59. package/src/components/ItaliaTheme/Blocks/__tests__/IconBlocks.test.jsx +22 -56
  60. package/src/components/ItaliaTheme/Blocks/__tests__/NumbersBlock.test.jsx +14 -43
  61. package/src/components/ItaliaTheme/Blocks/__tests__/SimpleCard.test.jsx +14 -30
  62. package/src/components/ItaliaTheme/Footer/FooterInfos.jsx +22 -8
  63. package/src/components/ItaliaTheme/Footer/FooterNavigation.jsx +3 -3
  64. package/src/components/ItaliaTheme/MegaMenu/MegaMenu.jsx +5 -1
  65. package/src/components/ItaliaTheme/Slider/SingleSlideWrapper.jsx +2 -3
  66. package/src/components/ItaliaTheme/View/BandoView/BandoApprofondimenti.jsx +1 -2
  67. package/src/components/ItaliaTheme/View/CartellaModulisticaView/DocRow.jsx +14 -5
  68. package/src/components/ItaliaTheme/View/Commons/Attachment.jsx +19 -3
  69. package/src/components/ItaliaTheme/View/Commons/Attachments.jsx +0 -1
  70. package/src/components/ItaliaTheme/View/Commons/DownloadFileFormat.jsx +11 -7
  71. package/src/components/ItaliaTheme/View/Commons/Module.jsx +7 -6
  72. package/src/components/ItaliaTheme/View/Commons/PageHeader/PageHeaderLinkServizio.jsx +6 -2
  73. package/src/components/ItaliaTheme/View/Commons/RichTextRender.jsx +8 -6
  74. package/src/components/ItaliaTheme/View/Commons/__tests__/RichText.test.jsx +14 -17
  75. package/src/components/ItaliaTheme/View/ServizioView/ServizioAccedi.jsx +5 -6
  76. package/src/components/ItaliaTheme/View/ServizioView/ServizioMetatag.jsx +4 -0
  77. package/src/components/ItaliaTheme/View/__tests__/CartellaModulisticaView.test.jsx +12 -1
  78. package/src/components/ItaliaTheme/View/__tests__/IncaricoView.test.jsx +24 -30
  79. package/src/components/ItaliaTheme/View/__tests__/PageView.test.jsx +24 -2
  80. package/src/components/ItaliaTheme/View/__tests__/PersonaView.test.jsx +96 -92
  81. package/src/components/ItaliaTheme/View/__tests__/ServizioAChiSiRivolge.test.jsx +240 -286
  82. package/src/components/ItaliaTheme/View/__tests__/ServizioAccedi.test.jsx +240 -286
  83. package/src/components/ItaliaTheme/View/__tests__/ServizioCasiParticolari.test.jsx +240 -286
  84. package/src/components/ItaliaTheme/View/__tests__/ServizioComeFare.test.jsx +240 -286
  85. package/src/components/ItaliaTheme/View/__tests__/ServizioCondizioni.test.jsx +240 -286
  86. package/src/components/ItaliaTheme/View/__tests__/ServizioContatti.test.jsx +240 -286
  87. package/src/components/ItaliaTheme/View/__tests__/ServizioCosE.test.jsx +240 -286
  88. package/src/components/ItaliaTheme/View/__tests__/ServizioCosaServe.test.jsx +240 -286
  89. package/src/components/ItaliaTheme/View/__tests__/ServizioCosaSiOttiene.test.jsx +240 -286
  90. package/src/components/ItaliaTheme/View/__tests__/ServizioCostiVincoli.test.jsx +240 -286
  91. package/src/components/ItaliaTheme/View/__tests__/ServizioMetadati.test.jsx +240 -286
  92. package/src/components/ItaliaTheme/View/__tests__/ServizioModulistica.test.jsx +240 -286
  93. package/src/components/ItaliaTheme/View/__tests__/ServizioProcedure.test.jsx +240 -286
  94. package/src/components/ItaliaTheme/View/__tests__/ServizioSitiEsterni.test.jsx +240 -286
  95. package/src/components/ItaliaTheme/View/__tests__/ServizioTempiScadenze.test.jsx +240 -286
  96. package/src/components/ItaliaTheme/View/__tests__/ServizioUlterioriInformazioni.test.jsx +240 -286
  97. package/src/components/ItaliaTheme/View/__tests__/ServizioView.test.jsx +470 -560
  98. package/src/components/ItaliaTheme/View/__tests__/TrasparenzaView.test.jsx +12 -1
  99. package/src/components/ItaliaTheme/manage/Widgets/ColorListWidget.jsx +11 -2
  100. package/src/components/ItaliaTheme/manage/Widgets/HtmlSlateWidget.jsx +154 -0
  101. package/src/components/ItaliaTheme/manage/Widgets/RichTextWidget.jsx +88 -0
  102. package/src/components/ItaliaTheme/manage/Widgets/SimpleTextEditorWidget.jsx +158 -0
  103. package/src/components/ItaliaTheme/manage/Widgets/TextEditorWidget.jsx +167 -270
  104. package/src/config/Blocks/ListingOptions/index.js +0 -1
  105. package/src/config/Blocks/ListingOptions/utils.js +0 -7
  106. package/src/config/Blocks/blocks.js +29 -8
  107. package/src/config/Blocks/listingVariations.js +1 -1
  108. package/src/config/Slate/Alignment/AlignMenu.jsx +169 -0
  109. package/src/config/Slate/Alignment/index.js +42 -0
  110. package/src/config/Slate/Blockquote/BlockquoteMenu.jsx +151 -0
  111. package/src/config/Slate/Blockquote/index.js +12 -0
  112. package/src/config/Slate/Headings/HeadingsMenu.jsx +139 -0
  113. package/src/config/Slate/Headings/headingsMenu.scss +44 -0
  114. package/src/config/Slate/Headings/index.js +62 -0
  115. package/src/config/Slate/Link/deserializer.js +25 -0
  116. package/src/config/Slate/Link/index.js +126 -0
  117. package/src/config/Slate/Link/renderer.jsx +99 -0
  118. package/src/config/Slate/LinkButton/index.js +47 -0
  119. package/src/config/Slate/TextLarger/index.js +51 -0
  120. package/src/config/Slate/Underline/index.js +10 -0
  121. package/src/config/Slate/config.js +43 -0
  122. package/src/config/Slate/deserializers.js +66 -0
  123. package/src/config/Slate/dropdownStyle.scss +14 -0
  124. package/src/config/Slate/dropdownUtils.js +422 -0
  125. package/src/config/Slate/extensions/breakList.js +91 -0
  126. package/src/config/Slate/handlers.js +243 -0
  127. package/src/config/Slate/utils.js +73 -0
  128. package/src/config/Widgets/widgets.js +1 -2
  129. package/src/config/italiaConfig.js +7 -54
  130. package/src/customizations/volto/components/manage/AnchorPlugin/components/LinkButton/AddLinkForm.jsx +360 -0
  131. package/src/customizations/volto/components/manage/Blocks/HeroImageLeft/Edit.jsx +75 -200
  132. package/src/customizations/volto/components/manage/Blocks/Video/Edit.jsx +1 -1
  133. package/src/customizations/volto/components/manage/Form/BlocksToolbar.jsx +1 -1
  134. package/src/customizations/volto/components/manage/UniversalLink/UniversalLink.jsx +59 -6
  135. package/src/customizations/volto-form-block/components/Field.jsx +45 -22
  136. package/src/customizations/volto-form-block/components/FormResult.jsx +74 -0
  137. package/src/customizations/volto-form-block/components/FormView.jsx +79 -66
  138. package/src/customizations/volto-form-block/components/Widget/Button.jsx +50 -0
  139. package/src/helpers/EnhanceLink.js +44 -0
  140. package/src/helpers/FormValidation/FormValidationHelpers.js +3 -0
  141. package/src/helpers/blocks.js +86 -0
  142. package/src/helpers/files.js +14 -14
  143. package/src/helpers/index.js +4 -3
  144. package/src/helpers/richTextHelper.js +10 -0
  145. package/src/icons/Group.svg +1 -0
  146. package/src/icons/blocco-icone.svg +0 -3
  147. package/src/icons/blockquote-card-dark.svg +1 -0
  148. package/src/icons/blockquote-card.svg +1 -0
  149. package/src/icons/blockquote-simple.svg +1 -0
  150. package/src/icons/text-larger.svg +1 -0
  151. package/src/theme/ItaliaTheme/Blocks/_accordion.scss +1 -10
  152. package/src/theme/ItaliaTheme/Blocks/_alert.scss +53 -1
  153. package/src/theme/ItaliaTheme/Blocks/_bandiInEvidenceTemplate.scss +1 -0
  154. package/src/theme/ItaliaTheme/Blocks/_callout.scss +32 -0
  155. package/src/theme/ItaliaTheme/Blocks/_contacts.scss +15 -32
  156. package/src/theme/ItaliaTheme/Blocks/_ctaBlock.scss +0 -14
  157. package/src/theme/ItaliaTheme/Blocks/_gridBlock.scss +1 -1
  158. package/src/theme/ItaliaTheme/Blocks/_hero.scss +1 -8
  159. package/src/theme/ItaliaTheme/Blocks/_iconBlocks.scss +0 -30
  160. package/src/theme/ItaliaTheme/Blocks/_imageCardTextBlock.scss +3 -2
  161. package/src/theme/ItaliaTheme/Blocks/_numbers.scss +1 -5
  162. package/src/theme/ItaliaTheme/Blocks/_simpleCardTextBlock.scss +8 -2
  163. package/src/theme/ItaliaTheme/Blocks/_tableOfContents.scss +1 -0
  164. package/src/theme/ItaliaTheme/Components/_megamenu.scss +0 -4
  165. package/src/theme/ItaliaTheme/Subsites/ItaliaTheme/Blocks/_cta.scss +1 -0
  166. package/src/theme/ItaliaTheme/Subsites/ItaliaTheme/Blocks/_searchSections.scss +1 -0
  167. package/src/theme/ItaliaTheme/Subsites/bootstrap-italia/custom/_headercenter.scss +1 -0
  168. package/src/theme/ItaliaTheme/Views/_cartellaModulistica.scss +11 -2
  169. package/src/theme/ItaliaTheme/Views/_slider.scss +3 -3
  170. package/src/theme/ItaliaTheme/Widgets/_iconWidget.scss +4 -0
  171. package/src/theme/ItaliaTheme/_main.scss +42 -54
  172. package/src/theme/_cms-ui.scss +59 -161
  173. package/src/theme/extras/_forms.scss +2 -14
  174. package/src/theme/site.scss +1 -0
  175. package/test-setup-config.js +58 -0
  176. package/src/components/ItaliaTheme/Blocks/TextCard/SimpleCard/Block.jsx +0 -151
  177. package/src/config/RichTextEditor/LinkEntity.jsx +0 -27
  178. package/src/config/RichTextEditor/Plugins/AnchorPlugin/components/Link/index.jsx +0 -44
  179. package/src/config/RichTextEditor/Plugins/AnchorPlugin/components/LinkButton/AddLinkForm.jsx +0 -349
  180. package/src/config/RichTextEditor/Plugins/AnchorPlugin/components/LinkButton/index.js +0 -150
  181. package/src/config/RichTextEditor/Plugins/AnchorPlugin/index.js +0 -88
  182. package/src/config/RichTextEditor/ToolbarButtons/AlignButton.jsx +0 -61
  183. package/src/config/RichTextEditor/ToolbarButtons/ButtonsButton.jsx +0 -14
  184. package/src/config/RichTextEditor/ToolbarButtons/CalloutsButton.jsx +0 -38
  185. package/src/config/RichTextEditor/ToolbarButtons/DraftJsDropdownButton.jsx +0 -106
  186. package/src/config/RichTextEditor/ToolbarButtons/HeadingsButton.jsx +0 -57
  187. package/src/config/RichTextEditor/ToolbarButtons/TextSizeButton.jsx +0 -65
  188. package/src/config/RichTextEditor/ToolbarButtons/UnderlineButton.jsx +0 -14
  189. package/src/config/RichTextEditor/config.js +0 -253
  190. package/src/config/volto-gdpr-privacy-defaultPanelConfig.js +0 -292
  191. package/src/customizations/volto/components/manage/Blocks/ToC/View.jsx +0 -134
  192. package/src/customizations/volto/components/manage/Blocks/ToC/variations/DefaultTocRenderer.jsx +0 -99
  193. package/src/customizations/volto/config/RichTextEditor/Plugins.jsx +0 -63
  194. package/src/helpers/redraftHelper.js +0 -9
@@ -10,7 +10,7 @@ import { Container, Row, Col } from 'design-react-kit';
10
10
  import { SidebarPortal } from '@plone/volto/components';
11
11
  import { addAppURL, flattenToAppURL } from '@plone/volto/helpers';
12
12
  import { Icon } from 'design-comuni-plone-theme/components/ItaliaTheme';
13
-
13
+ import { handleKeyDownOwnFocusManagement } from 'design-comuni-plone-theme/helpers/blocks';
14
14
  import {
15
15
  withDNDContext,
16
16
  SubblocksEdit,
@@ -48,6 +48,66 @@ class Edit extends SubblocksEdit {
48
48
  constructor(props) {
49
49
  super(props);
50
50
  this.state.selectedField = 'title';
51
+ this.nodeF = React.createRef();
52
+ }
53
+
54
+ UNSAFE_componentWillReceiveProps(newProps) {
55
+ if (newProps.selected) {
56
+ if (!this.props.selected) {
57
+ this.setState({ selectedField: 'title' });
58
+ }
59
+ } else {
60
+ this.setState({ selectedField: null });
61
+ }
62
+ }
63
+
64
+ handleEnter = (e) => {
65
+ if (
66
+ this.props.selected &&
67
+ this.state.subIndexSelected < 0 &&
68
+ !this.state.selectedField
69
+ ) {
70
+ handleKeyDownOwnFocusManagement(e, this.props);
71
+ }
72
+ };
73
+
74
+ handleClick = (e) => {
75
+ const hasParent = (element, className) => {
76
+ if (!element.parentNode) {
77
+ return false;
78
+ }
79
+
80
+ if (element.classList.contains(className)) {
81
+ return true;
82
+ }
83
+
84
+ return hasParent(element.parentNode, className);
85
+ };
86
+ const clickOutsideSubblocks =
87
+ !e.target.classList.contains('volto-subblocks-wrapper') &&
88
+ !hasParent(e.target, 'volto-subblocks-wrapper');
89
+
90
+ if (clickOutsideSubblocks) {
91
+ this.setState({ subIndexSelected: -1 });
92
+ }
93
+ };
94
+
95
+ componentDidMount() {
96
+ if (this.props.selected && this.node) {
97
+ this.node.focus();
98
+ }
99
+ if (this.props.selected && this.nodeF.current) {
100
+ this.nodeF.current.focus();
101
+ }
102
+
103
+ if (this.state.subblocks.length === 0) {
104
+ this.addSubblock();
105
+ }
106
+
107
+ if (this.nodeF && this.nodeF.current) {
108
+ this.nodeF.current.addEventListener('keydown', this.handleEnter, false);
109
+ this.nodeF.current.addEventListener('click', this.handleClick, false);
110
+ }
51
111
  }
52
112
 
53
113
  /**
@@ -61,7 +121,7 @@ class Edit extends SubblocksEdit {
61
121
  }
62
122
 
63
123
  return (
64
- <div className="public-ui">
124
+ <div className="public-ui" tabIndex="-1" ref={this.nodeF}>
65
125
  <div className="full-width section py-5">
66
126
  {this.props.data?.background?.[0] ? (
67
127
  <div
@@ -119,22 +179,24 @@ class Edit extends SubblocksEdit {
119
179
 
120
180
  <div className="title">
121
181
  <TextEditorWidget
182
+ {...this.props}
183
+ showToolbar={false}
122
184
  data={this.props.data}
185
+ key={'title'}
123
186
  fieldName="title"
124
187
  selected={this.state.selectedField === 'title'}
125
- block={this.props.block}
126
- onChangeBlock={(data) => {
127
- this.props.onChangeBlock(this.props.block, {
128
- ...data,
129
- });
188
+ setSelected={(f) => {
189
+ this.setState({ selectedField: f });
130
190
  }}
191
+ onChangeBlock={this.props.onChangeBlock}
131
192
  placeholder={this.props.intl.formatMessage(
132
193
  messages.title,
133
194
  )}
134
- showToolbar={false}
135
- onSelectBlock={() => {}}
136
- onAddBlock={() => {
137
- this.setState({ selectedField: 'description' });
195
+ focusNextField={() => {
196
+ this.setState({
197
+ selectedField: null,
198
+ subIndexSelected: 0,
199
+ });
138
200
  }}
139
201
  />
140
202
  </div>
@@ -144,11 +206,22 @@ class Edit extends SubblocksEdit {
144
206
  {this.state.subblocks.map((subblock, subindex) => (
145
207
  <Col sm="6" lg="4" key={subblock.id}>
146
208
  <EditBlock
209
+ {...this.props}
147
210
  data={subblock}
148
211
  index={subindex}
212
+ blockIndex={this.props.index}
149
213
  selected={this.isSubblockSelected(subindex)}
150
214
  {...this.subblockProps}
215
+ onChangeFocus={this.onSubblockChangeFocus}
216
+ isFirst={subindex === 0}
217
+ isLast={subindex === this.state.subblocks?.length - 1}
151
218
  openObjectBrowser={this.props.openObjectBrowser}
219
+ onFocusPreviousBlock={() => {
220
+ this.setState({
221
+ selectedField: 'title',
222
+ subIndexSelected: -1,
223
+ });
224
+ }}
152
225
  />
153
226
  </Col>
154
227
  ))}
@@ -5,12 +5,11 @@
5
5
 
6
6
  import React from 'react';
7
7
  import PropTypes from 'prop-types';
8
- import redraft from 'redraft';
8
+
9
9
  import ViewBlock from './Block/ViewBlock';
10
10
  import { Container, Row, Col } from 'design-react-kit';
11
11
  import { Icon } from 'design-comuni-plone-theme/components/ItaliaTheme';
12
12
  import { addAppURL, flattenToAppURL } from '@plone/volto/helpers';
13
- import config from '@plone/volto/registry';
14
13
 
15
14
  /**
16
15
  * View block class.
@@ -62,15 +61,7 @@ const NumbersView = ({ data, block }) => {
62
61
  </div>
63
62
  )}
64
63
 
65
- {data.title && (
66
- <div className="title">
67
- {redraft(
68
- data.title,
69
- config.settings.richtextViewSettings.ToHTMLRenderers,
70
- config.settings.richtextViewSettings.ToHTMLOptions,
71
- )}
72
- </div>
73
- )}
64
+ {data.title && <div className="title">{data.title}</div>}
74
65
  </div>
75
66
  </Col>
76
67
 
@@ -1,12 +1,12 @@
1
1
  /* eslint-disable jsx-a11y/no-static-element-interactions */
2
2
  /* eslint-disable jsx-a11y/click-events-have-key-events */
3
- import React, { useState, useEffect } from 'react';
3
+ import React from 'react';
4
4
  import { Card, CardBody, Container, Row, Col } from 'design-react-kit';
5
5
  import { defineMessages, useIntl } from 'react-intl';
6
6
  import PropTypes from 'prop-types';
7
- import redraft from 'redraft';
8
7
  import { TextEditorWidget } from 'design-comuni-plone-theme/components/ItaliaTheme';
9
- import config from '@plone/volto/registry';
8
+ import { useHandleDetachedBlockFocus } from 'design-comuni-plone-theme/helpers/blocks';
9
+ import { TextBlockView } from '@plone/volto-slate/blocks/Text';
10
10
  import cx from 'classnames';
11
11
 
12
12
  const messages = defineMessages({
@@ -44,63 +44,35 @@ const renderImage = (image, showImage, sizeNatural, altText = '') =>
44
44
  </div>
45
45
  ) : null;
46
46
 
47
- const Block = ({
48
- data,
49
- block,
50
- inEditMode,
51
- onChange,
52
- onSelectBlock,
53
- onAddBlock,
54
- onFocusPreviousBlock,
55
- onFocusNextBlock,
56
- index,
57
- selected,
58
- }) => {
47
+ const Block = (props) => {
48
+ const { data, block, inEditMode, onChange, selected, ...otherProps } = props;
59
49
  const intl = useIntl();
60
- const title = data?.image_card_title?.blocks[0]?.text;
50
+ const title = data?.image_card_title;
61
51
  const hasImage = data?.showImage;
62
52
  const content = data?.image_card_content;
63
53
 
64
- const [selectedField, setSelectedField] = useState('title');
65
-
66
- useEffect(() => {
67
- if (selected) {
68
- setSelectedField('title');
69
- } else {
70
- setSelectedField(null);
71
- }
72
- }, [selected]);
73
-
54
+ const { selectedField, setSelectedField } = useHandleDetachedBlockFocus(
55
+ props,
56
+ 'image_card_title',
57
+ );
74
58
  return (
75
59
  <div className="image-text-card-wrapper">
76
60
  <h2 className="mb-4 mt-5" id={block.id + 'title'}>
77
61
  {inEditMode ? (
78
- <div
79
- onClick={() => {
80
- setSelectedField('title');
81
- }}
82
- onFocus={() => {
83
- setSelectedField('title');
62
+ <TextEditorWidget
63
+ {...otherProps}
64
+ showToolbar={false}
65
+ data={data}
66
+ block={block}
67
+ fieldName="image_card_title"
68
+ selected={selectedField === 'image_card_title'}
69
+ onChangeBlock={(block, data) => onChange(data)}
70
+ placeholder={intl.formatMessage(messages.image_card_title)}
71
+ setSelected={setSelectedField}
72
+ focusNextField={() => {
73
+ setSelectedField('image_card_content');
84
74
  }}
85
- >
86
- <TextEditorWidget
87
- data={data}
88
- fieldName="image_card_title"
89
- selected={selectedField === 'title'}
90
- block={block}
91
- onChangeBlock={(data) => onChange(data)}
92
- placeholder={intl.formatMessage(messages.image_card_title)}
93
- showToolbar={false}
94
- onSelectBlock={() => {}}
95
- onAddBlock={() => {
96
- setSelectedField('content');
97
- }}
98
- onFocusNextBlock={() => {
99
- setSelectedField('content');
100
- }}
101
- onFocusPreviousBlock={onFocusPreviousBlock}
102
- />
103
- </div>
75
+ />
104
76
  ) : (
105
77
  title
106
78
  )}
@@ -139,28 +111,26 @@ const Block = ({
139
111
  >
140
112
  <div
141
113
  onClick={() => {
142
- setSelectedField('content');
114
+ setSelectedField('image_card_content');
143
115
  }}
144
116
  onFocus={() => {
145
- setSelectedField('content');
117
+ setSelectedField('image_card_content');
146
118
  }}
147
119
  >
148
120
  <TextEditorWidget
121
+ {...otherProps}
122
+ showToolbar={true}
149
123
  data={data}
150
124
  fieldName="image_card_content"
151
- selected={selectedField === 'content'}
152
125
  block={block}
153
- onChangeBlock={(data) => onChange(data)}
126
+ selected={selectedField === 'image_card_content'}
127
+ onChangeBlock={(block, data) => onChange(data)}
154
128
  placeholder={intl.formatMessage(
155
129
  messages.image_card_content,
156
130
  )}
157
- showToolbar={true}
158
- onSelectBlock={onSelectBlock}
159
- onAddBlock={onAddBlock}
160
- index={index}
161
- onFocusNextBlock={onFocusNextBlock}
162
- onFocusPreviousBlock={() => {
163
- setSelectedField('title');
131
+ setSelected={setSelectedField}
132
+ focusPrevField={() => {
133
+ setSelectedField('image_card_title');
164
134
  }}
165
135
  />
166
136
  </div>
@@ -195,11 +165,7 @@ const Block = ({
195
165
  'ps-0': data?.rightImage,
196
166
  })}
197
167
  >
198
- {redraft(
199
- content,
200
- config.settings.richtextViewSettings.ToHTMLRenderers,
201
- config.settings.richtextViewSettings.ToHTMLOptions,
202
- )}
168
+ <TextBlockView data={{ value: content }} />
203
169
  </div>
204
170
  </Row>
205
171
  </Container>
@@ -89,19 +89,13 @@ class Edit extends Component {
89
89
  return <div />;
90
90
  }
91
91
  return (
92
- <div>
92
+ <div tabIndex="-1">
93
93
  <BodyWrapper data={this.state.currentBlockData} inEditMode={true}>
94
94
  <Block
95
+ {...this.props}
95
96
  data={this.state.currentBlockData}
96
- block={this.props.block}
97
97
  onChange={(obj) => this.onChange(obj)}
98
98
  inEditMode={true}
99
- onSelectBlock={this.props.onSelectBlock}
100
- onAddBlock={this.props.onAddBlock}
101
- index={this.props.index}
102
- selected={this.props.selected}
103
- onFocusPreviousBlock={this.props.onFocusPreviousBlock}
104
- onFocusNextBlock={this.props.onFocusNextBlock}
105
99
  />
106
100
  </BodyWrapper>
107
101
  <SidebarPortal selected={this.props.selected || false}>
@@ -7,8 +7,9 @@ const BodyWrapper = ({ inEditMode, children }) => {
7
7
  className={cx('block simple-text-block', {
8
8
  'public-ui': inEditMode,
9
9
  })}
10
+ {...(inEditMode ? { tabIndex: '-1' } : {})}
10
11
  >
11
- <div>{children}</div>
12
+ {children}
12
13
  </div>
13
14
  );
14
15
  };
@@ -3,98 +3,112 @@
3
3
  * @module components/Blocks/TitleVM/Edit
4
4
  */
5
5
 
6
- import React, { Component } from 'react';
6
+ import React from 'react';
7
7
  import PropTypes from 'prop-types';
8
- import Block from './Block';
9
- import { injectIntl } from 'react-intl';
10
- import { isEqual } from 'lodash';
8
+ import { defineMessages, useIntl } from 'react-intl';
9
+ import { Card, CardBody, CardTitle } from 'design-react-kit';
10
+ import { TextEditorWidget } from 'design-comuni-plone-theme/components/ItaliaTheme';
11
11
  import BodyWrapper from './BodyWrapper';
12
+ import { useHandleDetachedBlockFocus } from 'design-comuni-plone-theme/helpers/blocks';
13
+ import { Divider } from 'semantic-ui-react';
12
14
 
15
+ const messages = defineMessages({
16
+ simple_card_title: {
17
+ id: 'Type the title…',
18
+ defaultMessage: 'Type the title…',
19
+ },
20
+ simple_card_content: {
21
+ id: 'Type description…',
22
+ defaultMessage: 'Digita la descrizione…',
23
+ },
24
+ simple_card_click: {
25
+ id: 'Type text…',
26
+ defaultMessage: 'Digita il testo…',
27
+ },
28
+ });
13
29
  /**
14
- * Edit title block class.
30
+ * Edit Calloout block class.
15
31
  * @class Edit
16
32
  * @extends Component
17
33
  */
18
- class Edit extends Component {
19
- /**
20
- * Property types.
21
- * @property {Object} propTypes Property types.
22
- * @static
23
- */
24
- static propTypes = {
25
- properties: PropTypes.objectOf(PropTypes.any).isRequired,
26
- selected: PropTypes.bool.isRequired,
27
- index: PropTypes.number.isRequired,
28
- onChangeField: PropTypes.func.isRequired,
29
- onSelectBlock: PropTypes.func.isRequired,
30
- onDeleteBlock: PropTypes.func.isRequired,
31
- onAddBlock: PropTypes.func.isRequired,
32
- onFocusPreviousBlock: PropTypes.func.isRequired,
33
- onFocusNextBlock: PropTypes.func.isRequired,
34
- block: PropTypes.string.isRequired,
35
- };
34
+ const Edit = (props) => {
35
+ const { data, onChangeBlock, block, onSelectBlock, selected, ...otherProps } =
36
+ props;
37
+ const intl = useIntl();
36
38
 
37
- /**
38
- * Constructor
39
- * @method constructor
40
- * @param {Object} props Component properties
41
- * @constructs SimpleCard Edit block
42
- */
43
- constructor(props) {
44
- super(props);
39
+ const { selectedField, setSelectedField } = useHandleDetachedBlockFocus(
40
+ props,
41
+ 'simple_card_title',
42
+ );
45
43
 
46
- if (!__SERVER__) {
47
- }
48
- }
44
+ return __SERVER__ ? (
45
+ <div />
46
+ ) : (
47
+ <BodyWrapper data={data} inEditMode={true}>
48
+ <div className="simple-text-card-wrapper">
49
+ <Card
50
+ color="white"
51
+ className="card-bg rounded"
52
+ noWrapper={false}
53
+ space
54
+ tag="div"
55
+ >
56
+ <CardBody>
57
+ <div className="simple-text-card cms-ui">
58
+ <CardTitle tag="h3" className="h4">
59
+ <TextEditorWidget
60
+ {...otherProps}
61
+ showToolbar={false}
62
+ data={data}
63
+ block={block}
64
+ fieldName="simple_card_title"
65
+ selected={selectedField === 'simple_card_title'}
66
+ onChangeBlock={onChangeBlock}
67
+ onSelectBlock={onSelectBlock}
68
+ placeholder={intl.formatMessage(messages.simple_card_title)}
69
+ setSelected={setSelectedField}
70
+ focusNextField={() => {
71
+ setSelectedField('simple_card_content');
72
+ }}
73
+ />
74
+ </CardTitle>
75
+ <Divider />
76
+ <div>
77
+ <TextEditorWidget
78
+ {...otherProps}
79
+ showToolbar={true}
80
+ data={data}
81
+ fieldName="simple_card_content"
82
+ selected={selectedField === 'simple_card_content'}
83
+ setSelected={setSelectedField}
84
+ block={block}
85
+ onChangeBlock={onChangeBlock}
86
+ onSelectBlock={onSelectBlock}
87
+ placeholder={intl.formatMessage(messages.simple_card_content)}
88
+ focusPrevField={() => {
89
+ setSelectedField('simple_card_title');
90
+ }}
91
+ />
92
+ </div>
93
+ </div>
94
+ </CardBody>
95
+ </Card>
96
+ </div>
97
+ </BodyWrapper>
98
+ );
99
+ };
49
100
 
50
- /**
51
- * Component did mount lifecycle method
52
- * @method componentDidMount
53
- * @returns {undefined}
54
- */
55
- componentDidMount() {}
101
+ Edit.propTypes = {
102
+ properties: PropTypes.objectOf(PropTypes.any).isRequired,
103
+ selected: PropTypes.bool.isRequired,
104
+ index: PropTypes.number.isRequired,
105
+ onChangeField: PropTypes.func.isRequired,
106
+ onSelectBlock: PropTypes.func.isRequired,
107
+ onDeleteBlock: PropTypes.func.isRequired,
108
+ onAddBlock: PropTypes.func.isRequired,
109
+ onFocusPreviousBlock: PropTypes.func.isRequired,
110
+ onFocusNextBlock: PropTypes.func.isRequired,
111
+ block: PropTypes.string.isRequired,
112
+ };
56
113
 
57
- /**
58
- * Change handler
59
- * @method onChange
60
- * @param {object} editorState Editor state.
61
- * @returns {undefined}
62
- */
63
- onChange(obj, fieldname) {
64
- if (!isEqual(obj[fieldname], this.props.data[fieldname])) {
65
- this.props.onChangeBlock(this.props.block, {
66
- ...this.props.data,
67
- [fieldname]: obj[fieldname],
68
- });
69
- }
70
- }
71
-
72
- /**
73
- * Render method.
74
- * @method render
75
- * @returns {string} Markup for the component.
76
- */
77
- render() {
78
- if (__SERVER__) {
79
- return <div />;
80
- }
81
- return (
82
- <BodyWrapper data={this.props.data} inEditMode={true}>
83
- <Block
84
- data={this.props.data}
85
- block={this.props.block}
86
- onChange={(obj, fieldname) => this.onChange(obj, fieldname)}
87
- inEditMode={true}
88
- onSelectBlock={this.props.onSelectBlock}
89
- onAddBlock={this.props.onAddBlock}
90
- index={this.props.index}
91
- selected={this.props.selected}
92
- onFocusPreviousBlock={this.props.onFocusPreviousBlock}
93
- onFocusNextBlock={this.props.onFocusNextBlock}
94
- />
95
- </BodyWrapper>
96
- );
97
- }
98
- }
99
-
100
- export default injectIntl(Edit);
114
+ export default Edit;
@@ -5,8 +5,9 @@
5
5
 
6
6
  import React from 'react';
7
7
  import PropTypes from 'prop-types';
8
- import Block from './Block';
8
+ import { Card, CardBody, CardTitle } from 'design-react-kit';
9
9
  import BodyWrapper from './BodyWrapper';
10
+ import { TextBlockView } from '@plone/volto-slate/blocks/Text';
10
11
 
11
12
  /**
12
13
  * View title block class.
@@ -14,10 +15,26 @@ import BodyWrapper from './BodyWrapper';
14
15
  * @extends Component
15
16
  */
16
17
 
17
- const TextCardView = ({ data, id }) => {
18
+ const TextCardView = ({ data, id, block }) => {
18
19
  return (
19
20
  <BodyWrapper data={data} inEditMode={false}>
20
- <Block data={data} inEditMode={false} block={{ id: id }} />
21
+ <div className="simple-text-card-wrapper">
22
+ <Card
23
+ color="white"
24
+ className="card-bg rounded"
25
+ noWrapper={false}
26
+ space
27
+ tag="div"
28
+ >
29
+ <CardBody>
30
+ <CardTitle tag="h3" className="h4" id={id + '-title'}>
31
+ {data.simple_card_title}
32
+ </CardTitle>
33
+ <hr />
34
+ <TextBlockView data={{ value: data.simple_card_content }} />
35
+ </CardBody>
36
+ </Card>
37
+ </div>
21
38
  </BodyWrapper>
22
39
  );
23
40
  };
@@ -18,34 +18,17 @@ const mock_fields = {
18
18
  href: '/',
19
19
  id: '1675245121000',
20
20
  linkMoreTitle: 'Caught in a landside',
21
- text: {
22
- blocks: [
23
- {
24
- data: {},
25
- depth: 0,
26
- entityRanges: [],
27
- inlineStyleRanges: [],
28
- key: 'b6vem',
29
- text: 'Is this just fantasy',
30
- type: 'unstyled',
31
- },
32
- ],
33
- entityMap: {},
34
- },
35
- title: {
36
- blocks: [
37
- {
38
- data: {},
39
- depth: 0,
40
- entityRanges: [],
41
- inlineStyleRanges: [],
42
- key: '2ikdv',
43
- text: 'Accordion 1',
44
- type: 'unstyled',
45
- },
46
- ],
47
- entityMap: {},
48
- },
21
+ text: [
22
+ {
23
+ children: [
24
+ {
25
+ text: 'Is this just fantasy?',
26
+ },
27
+ ],
28
+ type: 'p',
29
+ },
30
+ ],
31
+ title: 'Accordion 1',
49
32
  },
50
33
  ],
51
34
  };
@@ -18,20 +18,16 @@ const mock_fields = {
18
18
  encoding: 'base64',
19
19
  filename: 'insalata-1280x720.jpeg',
20
20
  },
21
- text: {
22
- blocks: [
23
- {
24
- data: {},
25
- depth: 0,
26
- entityRanges: [],
27
- inlineStyleRanges: [],
28
- key: 'ctqrv',
29
- text: 'Ciao',
30
- type: 'unstyled',
31
- },
32
- ],
33
- entityMap: {},
34
- },
21
+ text: [
22
+ {
23
+ children: [
24
+ {
25
+ text: 'Ciao',
26
+ },
27
+ ],
28
+ type: 'p',
29
+ },
30
+ ],
35
31
  };
36
32
 
37
33
  const store = mockStore({