design-comuni-plone-theme 11.10.2 → 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 (195) 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/cache/{volto-gdpr-privacy-npm-2.2.1-bc93b3e168-bce76108c3.zip → volto-gdpr-privacy-npm-2.2.0-6be0f74d53-8a93254251.zip} +0 -0
  8. package/.yarn/install-state.gz +0 -0
  9. package/CHANGELOG.md +878 -916
  10. package/RELEASE.md +8 -0
  11. package/locales/de/LC_MESSAGES/volto.po +86 -18
  12. package/locales/en/LC_MESSAGES/volto.po +86 -18
  13. package/locales/es/LC_MESSAGES/volto.po +86 -18
  14. package/locales/fr/LC_MESSAGES/volto.po +86 -18
  15. package/locales/it/LC_MESSAGES/volto.po +86 -18
  16. package/locales/volto.pot +87 -19
  17. package/package.json +5 -3
  18. package/publiccode.yml +2 -2
  19. package/src/components/Collapse.jsx +1 -0
  20. package/src/components/ItaliaTheme/Blocks/Accordion/Block/EditBlock.jsx +29 -24
  21. package/src/components/ItaliaTheme/Blocks/Accordion/Block/ViewBlock.jsx +4 -12
  22. package/src/components/ItaliaTheme/Blocks/Accordion/Edit.jsx +67 -6
  23. package/src/components/ItaliaTheme/Blocks/Alert/Edit.jsx +60 -113
  24. package/src/components/ItaliaTheme/Blocks/Alert/Sidebar.jsx +1 -0
  25. package/src/components/ItaliaTheme/Blocks/Alert/View.jsx +5 -14
  26. package/src/components/ItaliaTheme/Blocks/ArgumentsInEvidence/Block.jsx +16 -11
  27. package/src/components/ItaliaTheme/Blocks/ArgumentsInEvidence/Body.jsx +2 -1
  28. package/src/components/ItaliaTheme/Blocks/ArgumentsInEvidence/Edit.jsx +39 -1
  29. package/src/components/ItaliaTheme/Blocks/CTABlock/Block.jsx +35 -95
  30. package/src/components/ItaliaTheme/Blocks/Callout/Edit.jsx +108 -0
  31. package/src/components/ItaliaTheme/Blocks/Callout/Sidebar.jsx +173 -0
  32. package/src/components/ItaliaTheme/Blocks/Callout/View.jsx +45 -0
  33. package/src/components/ItaliaTheme/Blocks/ContactsBlock/Block/EditBlock.jsx +84 -63
  34. package/src/components/ItaliaTheme/Blocks/ContactsBlock/Block/ViewBlock.jsx +19 -39
  35. package/src/components/ItaliaTheme/Blocks/ContactsBlock/Edit.jsx +92 -19
  36. package/src/components/ItaliaTheme/Blocks/ContactsBlock/View.jsx +13 -21
  37. package/src/components/ItaliaTheme/Blocks/CountDown/Edit.jsx +21 -25
  38. package/src/components/ItaliaTheme/Blocks/CountDown/View.jsx +6 -15
  39. package/src/components/ItaliaTheme/Blocks/IconBlocks/Block/EditBlock.jsx +40 -15
  40. package/src/components/ItaliaTheme/Blocks/IconBlocks/Block/ViewBlock.jsx +6 -21
  41. package/src/components/ItaliaTheme/Blocks/IconBlocks/Edit.jsx +93 -20
  42. package/src/components/ItaliaTheme/Blocks/IconBlocks/Sidebar.jsx +1 -9
  43. package/src/components/ItaliaTheme/Blocks/IconBlocks/View.jsx +4 -17
  44. package/src/components/ItaliaTheme/Blocks/NumbersBlock/Block/EditBlock.jsx +46 -15
  45. package/src/components/ItaliaTheme/Blocks/NumbersBlock/Block/ViewBlock.jsx +2 -18
  46. package/src/components/ItaliaTheme/Blocks/NumbersBlock/Edit.jsx +84 -11
  47. package/src/components/ItaliaTheme/Blocks/NumbersBlock/View.jsx +2 -11
  48. package/src/components/ItaliaTheme/Blocks/TextCard/CardWithImage/Block.jsx +33 -67
  49. package/src/components/ItaliaTheme/Blocks/TextCard/CardWithImage/Edit.jsx +2 -8
  50. package/src/components/ItaliaTheme/Blocks/TextCard/SimpleCard/BodyWrapper.jsx +2 -1
  51. package/src/components/ItaliaTheme/Blocks/TextCard/SimpleCard/Edit.jsx +98 -84
  52. package/src/components/ItaliaTheme/Blocks/TextCard/SimpleCard/View.jsx +20 -3
  53. package/src/components/ItaliaTheme/Blocks/__tests__/Accordion.test.jsx +11 -28
  54. package/src/components/ItaliaTheme/Blocks/__tests__/Alert.test.jsx +10 -14
  55. package/src/components/ItaliaTheme/Blocks/__tests__/ArgumentsInEvidence.test.jsx +20 -28
  56. package/src/components/ItaliaTheme/Blocks/__tests__/CTABlock.test.jsx +14 -29
  57. package/src/components/ItaliaTheme/Blocks/__tests__/CardWithImage.test.jsx +11 -28
  58. package/src/components/ItaliaTheme/Blocks/__tests__/ContactsBlock.test.jsx +75 -140
  59. package/src/components/ItaliaTheme/Blocks/__tests__/Countdown.test.jsx +20 -28
  60. package/src/components/ItaliaTheme/Blocks/__tests__/IconBlocks.test.jsx +22 -56
  61. package/src/components/ItaliaTheme/Blocks/__tests__/NumbersBlock.test.jsx +14 -43
  62. package/src/components/ItaliaTheme/Blocks/__tests__/SimpleCard.test.jsx +14 -30
  63. package/src/components/ItaliaTheme/Footer/FooterInfos.jsx +22 -8
  64. package/src/components/ItaliaTheme/Footer/FooterNavigation.jsx +3 -3
  65. package/src/components/ItaliaTheme/MegaMenu/MegaMenu.jsx +5 -1
  66. package/src/components/ItaliaTheme/Slider/SingleSlideWrapper.jsx +2 -3
  67. package/src/components/ItaliaTheme/View/BandoView/BandoApprofondimenti.jsx +1 -2
  68. package/src/components/ItaliaTheme/View/CartellaModulisticaView/DocRow.jsx +14 -5
  69. package/src/components/ItaliaTheme/View/Commons/Attachment.jsx +19 -3
  70. package/src/components/ItaliaTheme/View/Commons/Attachments.jsx +0 -1
  71. package/src/components/ItaliaTheme/View/Commons/DownloadFileFormat.jsx +11 -7
  72. package/src/components/ItaliaTheme/View/Commons/Module.jsx +7 -6
  73. package/src/components/ItaliaTheme/View/Commons/PageHeader/PageHeaderLinkServizio.jsx +6 -2
  74. package/src/components/ItaliaTheme/View/Commons/RichTextRender.jsx +8 -6
  75. package/src/components/ItaliaTheme/View/Commons/__tests__/RichText.test.jsx +14 -17
  76. package/src/components/ItaliaTheme/View/ServizioView/ServizioAccedi.jsx +5 -6
  77. package/src/components/ItaliaTheme/View/ServizioView/ServizioMetatag.jsx +4 -0
  78. package/src/components/ItaliaTheme/View/__tests__/CartellaModulisticaView.test.jsx +12 -1
  79. package/src/components/ItaliaTheme/View/__tests__/IncaricoView.test.jsx +24 -30
  80. package/src/components/ItaliaTheme/View/__tests__/PageView.test.jsx +24 -2
  81. package/src/components/ItaliaTheme/View/__tests__/PersonaView.test.jsx +96 -92
  82. package/src/components/ItaliaTheme/View/__tests__/ServizioAChiSiRivolge.test.jsx +240 -286
  83. package/src/components/ItaliaTheme/View/__tests__/ServizioAccedi.test.jsx +240 -286
  84. package/src/components/ItaliaTheme/View/__tests__/ServizioCasiParticolari.test.jsx +240 -286
  85. package/src/components/ItaliaTheme/View/__tests__/ServizioComeFare.test.jsx +240 -286
  86. package/src/components/ItaliaTheme/View/__tests__/ServizioCondizioni.test.jsx +240 -286
  87. package/src/components/ItaliaTheme/View/__tests__/ServizioContatti.test.jsx +240 -286
  88. package/src/components/ItaliaTheme/View/__tests__/ServizioCosE.test.jsx +240 -286
  89. package/src/components/ItaliaTheme/View/__tests__/ServizioCosaServe.test.jsx +240 -286
  90. package/src/components/ItaliaTheme/View/__tests__/ServizioCosaSiOttiene.test.jsx +240 -286
  91. package/src/components/ItaliaTheme/View/__tests__/ServizioCostiVincoli.test.jsx +240 -286
  92. package/src/components/ItaliaTheme/View/__tests__/ServizioMetadati.test.jsx +240 -286
  93. package/src/components/ItaliaTheme/View/__tests__/ServizioModulistica.test.jsx +240 -286
  94. package/src/components/ItaliaTheme/View/__tests__/ServizioProcedure.test.jsx +240 -286
  95. package/src/components/ItaliaTheme/View/__tests__/ServizioSitiEsterni.test.jsx +240 -286
  96. package/src/components/ItaliaTheme/View/__tests__/ServizioTempiScadenze.test.jsx +240 -286
  97. package/src/components/ItaliaTheme/View/__tests__/ServizioUlterioriInformazioni.test.jsx +240 -286
  98. package/src/components/ItaliaTheme/View/__tests__/ServizioView.test.jsx +470 -560
  99. package/src/components/ItaliaTheme/View/__tests__/TrasparenzaView.test.jsx +12 -1
  100. package/src/components/ItaliaTheme/manage/Widgets/ColorListWidget.jsx +11 -2
  101. package/src/components/ItaliaTheme/manage/Widgets/HtmlSlateWidget.jsx +154 -0
  102. package/src/components/ItaliaTheme/manage/Widgets/RichTextWidget.jsx +88 -0
  103. package/src/components/ItaliaTheme/manage/Widgets/SimpleTextEditorWidget.jsx +158 -0
  104. package/src/components/ItaliaTheme/manage/Widgets/TextEditorWidget.jsx +167 -270
  105. package/src/config/Blocks/ListingOptions/index.js +0 -1
  106. package/src/config/Blocks/ListingOptions/utils.js +0 -7
  107. package/src/config/Blocks/blocks.js +29 -8
  108. package/src/config/Blocks/listingVariations.js +1 -1
  109. package/src/config/Slate/Alignment/AlignMenu.jsx +169 -0
  110. package/src/config/Slate/Alignment/index.js +42 -0
  111. package/src/config/Slate/Blockquote/BlockquoteMenu.jsx +151 -0
  112. package/src/config/Slate/Blockquote/index.js +12 -0
  113. package/src/config/Slate/Headings/HeadingsMenu.jsx +139 -0
  114. package/src/config/Slate/Headings/headingsMenu.scss +44 -0
  115. package/src/config/Slate/Headings/index.js +62 -0
  116. package/src/config/Slate/Link/deserializer.js +25 -0
  117. package/src/config/Slate/Link/index.js +126 -0
  118. package/src/config/Slate/Link/renderer.jsx +99 -0
  119. package/src/config/Slate/LinkButton/index.js +47 -0
  120. package/src/config/Slate/TextLarger/index.js +51 -0
  121. package/src/config/Slate/Underline/index.js +10 -0
  122. package/src/config/Slate/config.js +43 -0
  123. package/src/config/Slate/deserializers.js +66 -0
  124. package/src/config/Slate/dropdownStyle.scss +14 -0
  125. package/src/config/Slate/dropdownUtils.js +422 -0
  126. package/src/config/Slate/extensions/breakList.js +91 -0
  127. package/src/config/Slate/handlers.js +243 -0
  128. package/src/config/Slate/utils.js +73 -0
  129. package/src/config/Widgets/widgets.js +1 -2
  130. package/src/config/italiaConfig.js +7 -54
  131. package/src/customizations/volto/components/manage/AnchorPlugin/components/LinkButton/AddLinkForm.jsx +360 -0
  132. package/src/customizations/volto/components/manage/Blocks/HeroImageLeft/Edit.jsx +75 -200
  133. package/src/customizations/volto/components/manage/Blocks/Video/Edit.jsx +1 -1
  134. package/src/customizations/volto/components/manage/Form/BlocksToolbar.jsx +1 -1
  135. package/src/customizations/volto/components/manage/UniversalLink/UniversalLink.jsx +59 -6
  136. package/src/customizations/volto-form-block/components/Field.jsx +45 -22
  137. package/src/customizations/volto-form-block/components/FormResult.jsx +74 -0
  138. package/src/customizations/volto-form-block/components/FormView.jsx +79 -66
  139. package/src/customizations/volto-form-block/components/Widget/Button.jsx +50 -0
  140. package/src/helpers/EnhanceLink.js +44 -0
  141. package/src/helpers/FormValidation/FormValidationHelpers.js +3 -0
  142. package/src/helpers/blocks.js +86 -0
  143. package/src/helpers/files.js +14 -14
  144. package/src/helpers/index.js +4 -3
  145. package/src/helpers/richTextHelper.js +10 -0
  146. package/src/icons/Group.svg +1 -0
  147. package/src/icons/blocco-icone.svg +0 -3
  148. package/src/icons/blockquote-card-dark.svg +1 -0
  149. package/src/icons/blockquote-card.svg +1 -0
  150. package/src/icons/blockquote-simple.svg +1 -0
  151. package/src/icons/text-larger.svg +1 -0
  152. package/src/theme/ItaliaTheme/Blocks/_accordion.scss +1 -10
  153. package/src/theme/ItaliaTheme/Blocks/_alert.scss +53 -1
  154. package/src/theme/ItaliaTheme/Blocks/_bandiInEvidenceTemplate.scss +1 -0
  155. package/src/theme/ItaliaTheme/Blocks/_callout.scss +32 -0
  156. package/src/theme/ItaliaTheme/Blocks/_contacts.scss +15 -32
  157. package/src/theme/ItaliaTheme/Blocks/_ctaBlock.scss +0 -14
  158. package/src/theme/ItaliaTheme/Blocks/_gridBlock.scss +1 -1
  159. package/src/theme/ItaliaTheme/Blocks/_hero.scss +1 -8
  160. package/src/theme/ItaliaTheme/Blocks/_iconBlocks.scss +0 -30
  161. package/src/theme/ItaliaTheme/Blocks/_imageCardTextBlock.scss +3 -2
  162. package/src/theme/ItaliaTheme/Blocks/_numbers.scss +1 -5
  163. package/src/theme/ItaliaTheme/Blocks/_simpleCardTextBlock.scss +8 -2
  164. package/src/theme/ItaliaTheme/Blocks/_tableOfContents.scss +1 -0
  165. package/src/theme/ItaliaTheme/Components/_megamenu.scss +0 -4
  166. package/src/theme/ItaliaTheme/Subsites/ItaliaTheme/Blocks/_cta.scss +1 -0
  167. package/src/theme/ItaliaTheme/Subsites/ItaliaTheme/Blocks/_searchSections.scss +1 -0
  168. package/src/theme/ItaliaTheme/Subsites/bootstrap-italia/custom/_headercenter.scss +1 -0
  169. package/src/theme/ItaliaTheme/Views/_cartellaModulistica.scss +11 -2
  170. package/src/theme/ItaliaTheme/Views/_slider.scss +3 -3
  171. package/src/theme/ItaliaTheme/Widgets/_iconWidget.scss +4 -0
  172. package/src/theme/ItaliaTheme/_main.scss +42 -54
  173. package/src/theme/_cms-ui.scss +59 -161
  174. package/src/theme/extras/_forms.scss +2 -14
  175. package/src/theme/site.scss +1 -0
  176. package/test-setup-config.js +58 -0
  177. package/src/components/ItaliaTheme/Blocks/TextCard/SimpleCard/Block.jsx +0 -151
  178. package/src/config/RichTextEditor/LinkEntity.jsx +0 -27
  179. package/src/config/RichTextEditor/Plugins/AnchorPlugin/components/Link/index.jsx +0 -44
  180. package/src/config/RichTextEditor/Plugins/AnchorPlugin/components/LinkButton/AddLinkForm.jsx +0 -349
  181. package/src/config/RichTextEditor/Plugins/AnchorPlugin/components/LinkButton/index.js +0 -150
  182. package/src/config/RichTextEditor/Plugins/AnchorPlugin/index.js +0 -88
  183. package/src/config/RichTextEditor/ToolbarButtons/AlignButton.jsx +0 -61
  184. package/src/config/RichTextEditor/ToolbarButtons/ButtonsButton.jsx +0 -14
  185. package/src/config/RichTextEditor/ToolbarButtons/CalloutsButton.jsx +0 -38
  186. package/src/config/RichTextEditor/ToolbarButtons/DraftJsDropdownButton.jsx +0 -106
  187. package/src/config/RichTextEditor/ToolbarButtons/HeadingsButton.jsx +0 -57
  188. package/src/config/RichTextEditor/ToolbarButtons/TextSizeButton.jsx +0 -65
  189. package/src/config/RichTextEditor/ToolbarButtons/UnderlineButton.jsx +0 -14
  190. package/src/config/RichTextEditor/config.js +0 -253
  191. package/src/config/volto-gdpr-privacy-defaultPanelConfig.js +0 -292
  192. package/src/customizations/volto/components/manage/Blocks/ToC/View.jsx +0 -134
  193. package/src/customizations/volto/components/manage/Blocks/ToC/variations/DefaultTocRenderer.jsx +0 -99
  194. package/src/customizations/volto/config/RichTextEditor/Plugins.jsx +0 -63
  195. package/src/helpers/redraftHelper.js +0 -9
@@ -42,7 +42,7 @@ class EditBlock extends SubblockEdit {
42
42
  * Constructor
43
43
  * @method constructor
44
44
  * @param {Object} props Component properties
45
- * @constructs WysiwygEditor
45
+ * @constructs Icons Blocks edit
46
46
  */
47
47
  constructor(props) {
48
48
  super(props);
@@ -101,23 +101,36 @@ class EditBlock extends SubblockEdit {
101
101
  }}
102
102
  >
103
103
  <TextEditorWidget
104
+ {...this.props}
105
+ showToolbar={false}
104
106
  data={this.props.data}
105
107
  fieldName="title"
106
108
  selected={
107
109
  this.props.selected && this.state.focusOn === 'title'
108
110
  }
111
+ setSelected={(f) => {
112
+ this.setState({ focusOn: f });
113
+ }}
109
114
  block={this.props.block}
110
- onChangeBlock={this.onChange}
115
+ index={this.props.blockIndex}
116
+ onChangeBlock={(block, _data) => {
117
+ this.props.onChangeBlock(this.props.index, _data);
118
+ }}
111
119
  placeholder={this.props.intl.formatMessage(
112
120
  messages.titlePlaceholder,
113
121
  )}
114
- prevFocus="text"
115
- nextFocus="text"
116
- disableMoveToNearest={true}
117
- setFocus={(f) => {
118
- this.setState({ focusOn: f });
122
+ focusPrevField={
123
+ this.props.isFirst
124
+ ? this.props.onFocusPreviousBlock
125
+ : () => {
126
+ this.props.onSubblockChangeFocus(
127
+ this.props.index - 1,
128
+ );
129
+ }
130
+ }
131
+ focusNextField={() => {
132
+ this.setState({ focusOn: 'text' });
119
133
  }}
120
- showToolbar={false}
121
134
  key="title"
122
135
  />
123
136
  </div>
@@ -130,21 +143,33 @@ class EditBlock extends SubblockEdit {
130
143
  }}
131
144
  >
132
145
  <TextEditorWidget
146
+ {...this.props}
133
147
  data={this.props.data}
148
+ key="text"
134
149
  fieldName="text"
135
150
  selected={this.props.selected && this.state.focusOn === 'text'}
151
+ setSelected={(f) => {
152
+ this.setState({ focusOn: f });
153
+ }}
154
+ onChangeBlock={(block, _data) => {
155
+ this.props.onChangeBlock(this.props.index, _data);
156
+ }}
136
157
  block={this.props.block}
137
- onChangeBlock={this.onChange}
158
+ index={this.props.blockIndex}
138
159
  placeholder={this.props.intl.formatMessage(
139
160
  messages.textPlaceholder,
140
161
  )}
141
- disableMoveToNearest={true}
142
- prevFocus="title"
143
- nextFocus="title"
144
- setFocus={(f) => {
145
- this.setState({ focusOn: f });
162
+ focusNextField={
163
+ !this.props.isLast
164
+ ? () => {
165
+ this.setState({ focusOn: null });
166
+ this.props.onSubblockChangeFocus(this.props.index + 1);
167
+ }
168
+ : null //default go to next block
169
+ }
170
+ focusPrevField={() => {
171
+ this.setState({ focusOn: 'title' });
146
172
  }}
147
- key="text"
148
173
  />
149
174
  </div>
150
175
 
@@ -5,14 +5,14 @@
5
5
 
6
6
  import React from 'react';
7
7
  import PropTypes from 'prop-types';
8
- import redraft from 'redraft';
9
8
  import { useIntl, defineMessages } from 'react-intl';
10
9
  import { UniversalLink } from '@plone/volto/components';
11
10
 
12
11
  import { Icon } from 'design-comuni-plone-theme/components/ItaliaTheme';
13
12
  import { RichTextRender } from 'design-comuni-plone-theme/components/ItaliaTheme/View';
14
13
  import { Card, CardBody, CardReadMore } from 'design-react-kit';
15
- import config from '@plone/volto/registry';
14
+
15
+ import { TextBlockView } from '@plone/volto-slate/blocks/Text';
16
16
 
17
17
  const messages = defineMessages({
18
18
  vedi: {
@@ -36,11 +36,8 @@ const ViewBlock = ({ data, isOpen, toggle, id, index }) => {
36
36
  },
37
37
  };
38
38
 
39
- const cardTitle = redraft(data.title, rawStringRenderer, {
40
- cleanup: false,
41
- });
42
-
43
39
  const intl = useIntl();
40
+
44
41
  return (
45
42
  <Card
46
43
  className="card-bg rounded subblock-view"
@@ -55,22 +52,10 @@ const ViewBlock = ({ data, isOpen, toggle, id, index }) => {
55
52
  </div>
56
53
  )}
57
54
 
58
- {data.title && (
59
- <div className="iconblock-title">
60
- {redraft(
61
- data.title,
62
- config.settings.richtextViewSettings.ToHTMLRenderers,
63
- config.settings.richtextViewSettings.ToHTMLOptions,
64
- )}
65
- </div>
66
- )}
55
+ {data.title && <div className="iconblock-title">{data.title}</div>}
67
56
  {data.text && (
68
57
  <div className="iconblock-text">
69
- {redraft(
70
- data.text,
71
- config.settings.richtextViewSettings.ToHTMLRenderers,
72
- config.settings.richtextViewSettings.ToHTMLOptions,
73
- )}
58
+ <TextBlockView data={{ value: data.text }} />
74
59
  </div>
75
60
  )}
76
61
  {data.href && (
@@ -81,7 +66,7 @@ const ViewBlock = ({ data, isOpen, toggle, id, index }) => {
81
66
  text={data.linkMoreTitle || intl.formatMessage(messages.vedi)}
82
67
  aria-label={`${
83
68
  data.linkMoreTitle || intl.formatMessage(messages.vedi)
84
- } ${data.title ? cardTitle[0] : ''}`}
69
+ } ${data.title ?? ''}`}
85
70
  />
86
71
  )}
87
72
  </CardBody>
@@ -10,7 +10,7 @@ import { Container, Row, Col } from 'design-react-kit';
10
10
  import { SidebarPortal } from '@plone/volto/components';
11
11
  import { flattenToAppURL } from '@plone/volto/helpers';
12
12
  import { UniversalLink } from '@plone/volto/components';
13
-
13
+ import { handleKeyDownOwnFocusManagement } from 'design-comuni-plone-theme/helpers/blocks';
14
14
  import {
15
15
  withDNDContext,
16
16
  SubblocksEdit,
@@ -46,7 +46,68 @@ class Edit extends SubblocksEdit {
46
46
  constructor(props) {
47
47
  super(props);
48
48
  this.state.selectedField = 'title';
49
+ this.nodeF = React.createRef();
50
+ }
51
+
52
+ UNSAFE_componentWillReceiveProps(newProps) {
53
+ if (newProps.selected) {
54
+ if (!this.props.selected) {
55
+ this.setState({ selectedField: 'title' });
56
+ }
57
+ } else {
58
+ this.setState({ selectedField: null });
59
+ }
60
+ }
61
+
62
+ handleEnter = (e) => {
63
+ if (
64
+ this.props.selected &&
65
+ this.state.subIndexSelected < 0 &&
66
+ !this.state.selectedField
67
+ ) {
68
+ handleKeyDownOwnFocusManagement(e, this.props);
69
+ }
70
+ };
71
+
72
+ handleClick = (e) => {
73
+ const hasParent = (element, className) => {
74
+ if (!element.parentNode) {
75
+ return false;
76
+ }
77
+
78
+ if (element.classList.contains(className)) {
79
+ return true;
80
+ }
81
+
82
+ return hasParent(element.parentNode, className);
83
+ };
84
+ const clickOutsideSubblocks =
85
+ !e.target.classList.contains('volto-subblocks-wrapper') &&
86
+ !hasParent(e.target, 'volto-subblocks-wrapper');
87
+
88
+ if (clickOutsideSubblocks) {
89
+ this.setState({ subIndexSelected: -1 });
90
+ }
91
+ };
92
+
93
+ componentDidMount() {
94
+ if (this.props.selected && this.node) {
95
+ this.node.focus();
96
+ }
97
+ if (this.props.selected && this.nodeF.current) {
98
+ this.nodeF.current.focus();
99
+ }
100
+
101
+ if (this.state.subblocks.length === 0) {
102
+ this.addSubblock();
103
+ }
104
+
105
+ if (this.nodeF && this.nodeF.current) {
106
+ this.nodeF.current.addEventListener('keydown', this.handleEnter, false);
107
+ this.nodeF.current.addEventListener('click', this.handleClick, false);
108
+ }
49
109
  }
110
+
50
111
  /**
51
112
  * Render method.
52
113
  * @method render
@@ -59,7 +120,7 @@ class Edit extends SubblocksEdit {
59
120
  const Image = config.getComponent({ name: 'Image' }).component;
60
121
 
61
122
  return (
62
- <div className="public-ui">
123
+ <div className="public-ui" tabIndex="-1" ref={this.nodeF}>
63
124
  <div className="full-width section py-5">
64
125
  {this.props.data.background?.[0] ? (
65
126
  <div className="background-image">
@@ -79,19 +140,20 @@ class Edit extends SubblocksEdit {
79
140
  <div className="block-header">
80
141
  <div className="title">
81
142
  <TextEditorWidget
143
+ {...this.props}
144
+ showToolbar={false}
82
145
  data={this.props.data}
146
+ key={'title'}
83
147
  fieldName="title"
84
148
  selected={this.state.selectedField === 'title'}
85
- block={this.props.block}
86
- onChangeBlock={(data) => {
87
- this.props.onChangeBlock(this.props.block, {
88
- ...data,
149
+ setSelected={(f) => {
150
+ this.setState({
151
+ selectedField: f,
152
+ subIndexSelected: -1,
89
153
  });
90
154
  }}
91
155
  placeholder={this.props.intl.formatMessage(messages.title)}
92
- showToolbar={false}
93
- onSelectBlock={() => {}}
94
- onAddBlock={() => {
156
+ focusNextField={() => {
95
157
  this.setState({ selectedField: 'description' });
96
158
  }}
97
159
  />
@@ -99,35 +161,47 @@ class Edit extends SubblocksEdit {
99
161
 
100
162
  <div className="description">
101
163
  <TextEditorWidget
164
+ {...this.props}
165
+ showToolbar={true}
102
166
  data={this.props.data}
103
167
  fieldName="description"
104
168
  selected={this.state.selectedField === 'description'}
105
- block={this.props.block}
106
- onChangeBlock={(data) =>
107
- this.props.onChangeBlock(this.props.block, {
108
- ...data,
109
- })
110
- }
169
+ setSelected={(f) => {
170
+ this.setState({
171
+ selectedField: f,
172
+ subIndexSelected: -1,
173
+ });
174
+ }}
111
175
  placeholder={this.props.intl.formatMessage(
112
176
  messages.description,
113
177
  )}
114
- showToolbar={true}
115
- onSelectBlock={() => {}}
116
- onAddBlock={() => {}}
178
+ focusPrevField={() => {
179
+ this.setState({ selectedField: 'title' });
180
+ }}
181
+ focusNextField={() => {
182
+ this.setState({ selectedField: null, subIndexSelected: 0 });
183
+ }}
117
184
  />
118
185
  </div>
119
186
  </div>
120
-
121
187
  <SubblocksWrapper node={this.node}>
122
188
  <Row>
123
189
  {this.state.subblocks.map((subblock, subindex) => (
124
190
  <Col lg="4" xl="3" key={subblock.id}>
125
191
  <EditBlock
192
+ {...this.props}
126
193
  data={subblock}
127
194
  index={subindex}
195
+ blockIndex={this.props.index}
128
196
  selected={this.isSubblockSelected(subindex)}
129
197
  {...this.subblockProps}
198
+ onChangeFocus={this.onSubblockChangeFocus}
199
+ isFirst={subindex === 0}
200
+ isLast={subindex === this.state.subblocks?.length - 1}
130
201
  openObjectBrowser={this.props.openObjectBrowser}
202
+ onFocusPreviousBlock={() => {
203
+ this.setState({ selectedField: 'description' });
204
+ }}
131
205
  />
132
206
  </Col>
133
207
  ))}
@@ -141,7 +215,6 @@ class Edit extends SubblocksEdit {
141
215
  )}
142
216
  </Row>
143
217
  </SubblocksWrapper>
144
-
145
218
  {this.props.data.href && this.props.data.linkMoreTitle && (
146
219
  <div className="link-button text-center my-4">
147
220
  <UniversalLink
@@ -3,8 +3,6 @@ import PropTypes from 'prop-types';
3
3
  import { defineMessages, useIntl } from 'react-intl';
4
4
  import { Segment, Accordion } from 'semantic-ui-react';
5
5
  import { FormattedMessage, injectIntl } from 'react-intl';
6
- import redraft from 'redraft';
7
-
8
6
  import { TextWidget, Icon, ObjectBrowserWidget } from '@plone/volto/components';
9
7
  import upSVG from '@plone/volto/icons/up-key.svg';
10
8
  import downSVG from '@plone/volto/icons/down-key.svg';
@@ -104,13 +102,7 @@ const Sidebar = ({
104
102
  index={index}
105
103
  onClick={() => setSelected(selected === index ? null : index)}
106
104
  >
107
- {subblock.title
108
- ? redraft(
109
- subblock.title,
110
- config.settings.richtextViewSettings.ToHTMLRenderers,
111
- config.settings.richtextViewSettings.ToHTMLOptions,
112
- )
113
- : `Blocco ${index + 1}`}
105
+ {subblock.title ?? `Blocco ${index + 1}`}
114
106
  {selected === index ? (
115
107
  <Icon name={upSVG} size="20px" />
116
108
  ) : (
@@ -5,13 +5,12 @@
5
5
 
6
6
  import React from 'react';
7
7
  import PropTypes from 'prop-types';
8
- import redraft from 'redraft';
9
8
  import ViewBlock from './Block/ViewBlock';
10
9
  import { Container, Row, Col } from 'design-react-kit';
11
10
  import { flattenToAppURL } from '@plone/volto/helpers';
12
11
  import { UniversalLink } from '@plone/volto/components';
12
+ import { TextBlockView } from '@plone/volto-slate/blocks/Text';
13
13
  import config from '@plone/volto/registry';
14
- import { checkRedraftHasContent } from 'design-comuni-plone-theme/helpers';
15
14
 
16
15
  /**
17
16
  * View IconsBlock block class.
@@ -41,22 +40,10 @@ const IconsBlockView = ({ data, block }) => {
41
40
  )}
42
41
  <Container className="px-md-4">
43
42
  <div className="block-header">
44
- {checkRedraftHasContent(data.title) && (
45
- <div className="title">
46
- {redraft(
47
- data.title,
48
- config.settings.richtextViewSettings.ToHTMLRenderers,
49
- config.settings.richtextViewSettings.ToHTMLOptions,
50
- )}
51
- </div>
52
- )}
53
- {checkRedraftHasContent(data.description) && (
43
+ {data.title && <div className="title">{data.title}</div>}
44
+ {data.description && (
54
45
  <div className="description">
55
- {redraft(
56
- data.description,
57
- config.settings.richtextViewSettings.ToHTMLRenderers,
58
- config.settings.richtextViewSettings.ToHTMLOptions,
59
- )}
46
+ <TextBlockView data={{ value: data.description }} />
60
47
  </div>
61
48
  )}
62
49
  </div>
@@ -31,7 +31,7 @@ class EditBlock extends SubblockEdit {
31
31
  * Constructor
32
32
  * @method constructor
33
33
  * @param {Object} props Component properties
34
- * @constructs WysiwygEditor
34
+ * @constructs Numbers Block edit
35
35
  */
36
36
  constructor(props) {
37
37
  super(props);
@@ -51,6 +51,7 @@ class EditBlock extends SubblockEdit {
51
51
  // }
52
52
  // });
53
53
  }
54
+
54
55
  /**
55
56
  * Render method.
56
57
  * @method render
@@ -72,25 +73,39 @@ class EditBlock extends SubblockEdit {
72
73
  }}
73
74
  >
74
75
  <TextEditorWidget
76
+ {...this.props}
77
+ showToolbar={false}
75
78
  data={this.props.data}
76
79
  fieldName="title"
77
80
  selected={this.props.selected && this.state.focusOn === 'title'}
81
+ setSelected={(f) => {
82
+ this.setState({ focusOn: f });
83
+ if (!f) {
84
+ this.props.onSubblockChangeFocus(-1);
85
+ }
86
+ }}
78
87
  block={this.props.block}
79
- onChangeBlock={this.onChange}
88
+ index={this.props.blockIndex}
89
+ onChangeBlock={(block, _data) => {
90
+ this.props.onChangeBlock(this.props.index, _data);
91
+ }}
80
92
  placeholder={this.props.intl.formatMessage(
81
93
  messages.numberPlaceholder,
82
94
  )}
83
- prevFocus="text"
84
- nextFocus="text"
85
- setFocus={(f) => {
86
- this.setState({ focusOn: f });
95
+ focusPrevField={
96
+ this.props.isFirst
97
+ ? this.props.onFocusPreviousBlock
98
+ : () => {
99
+ this.props.onSubblockChangeFocus(this.props.index - 1);
100
+ }
101
+ }
102
+ focusNextField={() => {
103
+ this.setState({ focusOn: 'text' });
87
104
  }}
88
- showToolbar={false}
89
105
  key="title"
90
106
  />
91
107
  </div>
92
108
  </div>
93
-
94
109
  <div
95
110
  className="subblock-text"
96
111
  onClick={() => {
@@ -98,21 +113,37 @@ class EditBlock extends SubblockEdit {
98
113
  }}
99
114
  >
100
115
  <TextEditorWidget
116
+ {...this.props}
117
+ showToolbar={false}
101
118
  data={this.props.data}
119
+ key="text"
102
120
  fieldName="text"
103
121
  selected={this.props.selected && this.state.focusOn === 'text'}
122
+ setSelected={(f) => {
123
+ this.setState({ focusOn: f });
124
+ if (!f) {
125
+ this.props.onSubblockChangeFocus(-1);
126
+ }
127
+ }}
104
128
  block={this.props.block}
105
- onChangeBlock={this.onChange}
129
+ index={this.props.blockIndex}
130
+ onChangeBlock={(block, _data) => {
131
+ this.props.onChangeBlock(this.props.index, _data);
132
+ }}
106
133
  placeholder={this.props.intl.formatMessage(
107
134
  messages.descriptionPlaceholder,
108
135
  )}
109
- prevFocus="title"
110
- nextFocus="title"
111
- setFocus={(f) => {
112
- this.setState({ focusOn: f });
136
+ focusNextField={
137
+ !this.props.isLast
138
+ ? () => {
139
+ this.setState({ focusOn: null });
140
+ this.props.onSubblockChangeFocus(this.props.index + 1);
141
+ }
142
+ : null //default go to next block
143
+ }
144
+ focusPrevField={() => {
145
+ this.setState({ focusOn: 'title' });
113
146
  }}
114
- showToolbar={false}
115
- key="text"
116
147
  />
117
148
  </div>
118
149
  </div>
@@ -5,8 +5,6 @@
5
5
 
6
6
  import React from 'react';
7
7
  import PropTypes from 'prop-types';
8
- import redraft from 'redraft';
9
- import config from '@plone/volto/registry';
10
8
 
11
9
  /**
12
10
  * ViewBlock class.
@@ -17,23 +15,9 @@ const ViewBlock = ({ data, isOpen, toggle, id, index }) => {
17
15
  return (
18
16
  <div className="block-number">
19
17
  {data.title && (
20
- <div className="subblock-title font-monospace">
21
- {redraft(
22
- data.title,
23
- config.settings.richtextViewSettings.ToHTMLRenderers,
24
- config.settings.richtextViewSettings.ToHTMLOptions,
25
- )}
26
- </div>
27
- )}
28
- {data.text && (
29
- <div className="subblock-text">
30
- {redraft(
31
- data.text,
32
- config.settings.richtextViewSettings.ToHTMLRenderers,
33
- config.settings.richtextViewSettings.ToHTMLOptions,
34
- )}
35
- </div>
18
+ <div className="subblock-title font-monospace">{data.title}</div>
36
19
  )}
20
+ {data.text && <div className="subblock-text">{data.text}</div>}
37
21
  </div>
38
22
  );
39
23
  };