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
@@ -38,7 +38,7 @@ class EditBlock extends SubblockEdit {
38
38
  * Constructor
39
39
  * @method constructor
40
40
  * @param {Object} props Component properties
41
- * @constructs WysiwygEditor
41
+ * @constructs Accordion Edit
42
42
  */
43
43
  constructor(props) {
44
44
  super(props);
@@ -87,30 +87,33 @@ class EditBlock extends SubblockEdit {
87
87
  }}
88
88
  >
89
89
  <TextEditorWidget
90
+ {...this.props}
91
+ key="title"
92
+ showToolbar={false}
90
93
  data={this.props.data}
91
94
  fieldName="title"
92
- selected={this.props.selected && this.state.focusOn === 'title'}
93
- block={this.props.block}
94
- onChangeBlock={this.onChange}
95
+ onChangeBlock={(block, _data) => {
96
+ this.onChange(_data);
97
+ }}
95
98
  placeholder={this.props.intl.formatMessage(
96
99
  messages.titlePlaceholder,
97
100
  )}
98
- onSelectBlock={() => {}}
99
- onAddBlock={() => {
100
- this.setState({ focusOn: 'text' });
101
+ selected={this.props.selected && this.state.focusOn === 'title'}
102
+ setSelected={(f) => {
103
+ this.setState({
104
+ focusOn: f,
105
+ });
101
106
  }}
102
- onFocusNextBlock={() => {
107
+ focusNextField={() => {
103
108
  this.setState({ focusOn: 'text' });
104
109
  }}
105
- onFocusPreviousBlock={
110
+ focusPrevField={
106
111
  this.props.isFirst
107
112
  ? this.props.onFocusPreviousBlock
108
113
  : () => {
109
114
  this.props.onSubblockChangeFocus(this.props.index - 1);
110
115
  }
111
116
  }
112
- showToolbar={false}
113
- key="title"
114
117
  />
115
118
  </div>
116
119
  </h3>
@@ -123,31 +126,33 @@ class EditBlock extends SubblockEdit {
123
126
  >
124
127
  <div className="accordion-inner">
125
128
  <TextEditorWidget
129
+ {...this.props}
130
+ key="text"
126
131
  data={this.props.data}
127
132
  fieldName="text"
128
133
  selected={
129
134
  this.props.selected && this.state.focusOn === 'text'
130
135
  }
131
- block={this.props.block}
132
- onChangeBlock={this.onChange}
133
136
  placeholder={this.props.intl.formatMessage(
134
137
  messages.textPlaceholder,
135
138
  )}
136
- onAddBlock={this.props.onFocusNextBlock}
137
- onFocusNextBlock={
138
- this.props.isLast
139
- ? this.props.onFocusNextBlock
140
- : () => {
141
- this.setState({ focusOn: null });
142
- this.props.onSubblockChangeFocus(
143
- this.props.index + 1,
144
- );
139
+ onChangeBlock={(block, _data) => {
140
+ this.onChange(_data);
141
+ }}
142
+ setSelected={(f) => this.setState({ focusOn: f })}
143
+ focusNextField={
144
+ !this.props.isLast
145
+ ? () => {
146
+ this.setState({
147
+ focusOn: null,
148
+ subIndexSelected: this.props.index + 1,
149
+ });
145
150
  }
151
+ : null //default go to next block
146
152
  }
147
- onFocusPreviousBlock={() => {
153
+ focusPrevField={() => {
148
154
  this.setState({ focusOn: 'title' });
149
155
  }}
150
- key="text"
151
156
  />
152
157
  </div>
153
158
  {this.props.data.href && (
@@ -5,12 +5,11 @@
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 cx from 'classnames';
11
10
  import { Icon } from 'design-comuni-plone-theme/components/ItaliaTheme';
12
11
  import { UniversalLink } from '@plone/volto/components';
13
- import config from '@plone/volto/registry';
12
+ import { TextBlockView } from '@plone/volto-slate/blocks/Text';
14
13
 
15
14
  const messages = defineMessages({
16
15
  vedi: {
@@ -34,6 +33,7 @@ const messages = defineMessages({
34
33
  */
35
34
  const ViewBlock = ({ data, isOpen, toggle, id, index }) => {
36
35
  const intl = useIntl();
36
+
37
37
  return (
38
38
  <div className="accordion-item subblock-view">
39
39
  {data.title && (
@@ -55,11 +55,7 @@ const ViewBlock = ({ data, isOpen, toggle, id, index }) => {
55
55
  }
56
56
  />
57
57
 
58
- {redraft(
59
- data.title,
60
- config.settings.richtextViewSettings.ToHTMLRenderers,
61
- config.settings.richtextViewSettings.ToHTMLOptions,
62
- )}
58
+ {data.title}
63
59
  </button>
64
60
  </h3>
65
61
  )}
@@ -72,11 +68,7 @@ const ViewBlock = ({ data, isOpen, toggle, id, index }) => {
72
68
  aria-labelledby={`${id}-${index}`}
73
69
  >
74
70
  <div className="accordion-inner" onFocus={toggle()}>
75
- {redraft(
76
- data.text,
77
- config.settings.richtextViewSettings.ToHTMLRenderers,
78
- config.settings.richtextViewSettings.ToHTMLOptions,
79
- )}
71
+ <TextBlockView id={id} data={{ value: data.text }} />
80
72
  </div>
81
73
  {data.href && (
82
74
  <div className="link-more">
@@ -14,6 +14,7 @@ import {
14
14
  } from 'volto-subblocks';
15
15
 
16
16
  import { SidebarPortal } from '@plone/volto/components';
17
+ import { handleKeyDownOwnFocusManagement } from 'design-comuni-plone-theme/helpers/blocks';
17
18
  import Sidebar from './Sidebar.jsx';
18
19
 
19
20
  import { defineMessages } from 'react-intl';
@@ -30,6 +31,68 @@ const messages = defineMessages({
30
31
  * @extends Component
31
32
  */
32
33
  class Edit extends SubblocksEdit {
34
+ constructor(props) {
35
+ super(props);
36
+ this.nodeF = React.createRef();
37
+ }
38
+
39
+ UNSAFE_componentWillReceiveProps(newProps) {
40
+ if (newProps.selected) {
41
+ if (!this.props.selected) {
42
+ if (this.state.subIndexSelected < 0) {
43
+ this.onSubblockChangeFocus(0);
44
+ }
45
+ }
46
+ } else {
47
+ this.onSubblockChangeFocus(-1);
48
+ }
49
+ }
50
+
51
+ handleEnter = (e) => {
52
+ if (this.props.selected && this.state.subIndexSelected < 0) {
53
+ handleKeyDownOwnFocusManagement(e, this.props);
54
+ }
55
+ };
56
+
57
+ handleClick = (e) => {
58
+ const hasParent = (element, className) => {
59
+ if (!element.parentNode) {
60
+ return false;
61
+ }
62
+
63
+ if (element.classList.contains(className)) {
64
+ return true;
65
+ }
66
+
67
+ return hasParent(element.parentNode, className);
68
+ };
69
+ const clickOutsideSubblocks =
70
+ !e.target.classList.contains('volto-subblocks-wrapper') &&
71
+ !hasParent(e.target, 'volto-subblocks-wrapper');
72
+
73
+ if (clickOutsideSubblocks) {
74
+ this.setState({ subIndexSelected: -1 });
75
+ }
76
+ };
77
+
78
+ componentDidMount() {
79
+ if (this.props.selected && this.node) {
80
+ this.node.focus();
81
+ }
82
+ if (this.props.selected && this.nodeF.current) {
83
+ this.nodeF.current.focus();
84
+ }
85
+
86
+ if (this.state.subblocks.length === 0) {
87
+ this.addSubblock();
88
+ }
89
+
90
+ if (this.nodeF && this.nodeF.current) {
91
+ this.nodeF.current.addEventListener('keydown', this.handleEnter, false);
92
+ this.nodeF.current.addEventListener('click', this.handleClick, false);
93
+ }
94
+ }
95
+
33
96
  /**
34
97
  * Render method.
35
98
  * @method render
@@ -40,7 +103,7 @@ class Edit extends SubblocksEdit {
40
103
  return <div />;
41
104
  }
42
105
  return (
43
- <div className="public-ui">
106
+ <div className="public-ui" tabIndex="-1" ref={this.nodeF}>
44
107
  <div className="full-width section section-muted section-inset-shadow py-5 is-edit-mode">
45
108
  <Container className="px-md-4">
46
109
  <Card className="card-bg rounded" noWrapper={false} space tag="div">
@@ -49,17 +112,15 @@ class Edit extends SubblocksEdit {
49
112
  {this.state.subblocks.map((subblock, subindex) => (
50
113
  <div className="accordion-item" key={subblock.id}>
51
114
  <EditBlock
115
+ {...this.props}
116
+ {...this.subblockProps}
117
+ onChangeFocus={this.onSubblockChangeFocus}
52
118
  data={subblock}
53
119
  index={subindex}
54
120
  selected={
55
121
  this.props.selected &&
56
122
  this.isSubblockSelected(subindex)
57
123
  }
58
- {...this.subblockProps}
59
- openObjectBrowser={this.props.openObjectBrowser}
60
- onFocusPreviousBlock={this.props.onFocusPreviousBlock}
61
- onFocusNextBlock={this.props.onFocusNextBlock}
62
- onSubblockChangeFocus={this.onSubblockChangeFocus}
63
124
  isLast={this.state.subblocks.length - 1 === subindex}
64
125
  isFirst={subindex === 0}
65
126
  />
@@ -3,18 +3,14 @@
3
3
  * @module components/manage/Blocks/Image/Edit
4
4
  */
5
5
 
6
- import React, { Component } from 'react';
7
- import PropTypes from 'prop-types';
8
- import { connect } from 'react-redux';
9
- import { compose } from 'redux';
6
+ import React, { useEffect } from 'react';
10
7
 
11
8
  import cx from 'classnames';
12
9
  import { Container, Row, Col } from 'design-react-kit';
13
10
 
14
- import { createContent } from '@plone/volto/actions';
15
11
  import { SidebarPortal } from '@plone/volto/components';
16
- import { defineMessages, injectIntl } from 'react-intl';
17
-
12
+ import { defineMessages, useIntl } from 'react-intl';
13
+ import { useHandleDetachedBlockFocus } from 'design-comuni-plone-theme/helpers/blocks';
18
14
  import {
19
15
  AlertSidebar,
20
16
  TextEditorWidget,
@@ -26,116 +22,67 @@ const messages = defineMessages({
26
22
  defaultMessage: 'Digita il testo…',
27
23
  },
28
24
  });
29
- /**
30
- * Edit Alert block class.
31
- * @class Edit
32
- * @extends Component
33
- */
34
- class Edit extends Component {
35
- /**
36
- * Property types.
37
- * @property {Object} propTypes Property types.
38
- * @static
39
- */
40
- static propTypes = {
41
- selected: PropTypes.bool.isRequired,
42
- block: PropTypes.string.isRequired,
43
- index: PropTypes.number.isRequired,
44
- data: PropTypes.objectOf(PropTypes.any).isRequired,
45
- content: PropTypes.objectOf(PropTypes.any).isRequired,
46
- request: PropTypes.shape({
47
- loading: PropTypes.bool,
48
- loaded: PropTypes.bool,
49
- }).isRequired,
50
- pathname: PropTypes.string.isRequired,
51
- onChangeBlock: PropTypes.func.isRequired,
52
- onSelectBlock: PropTypes.func.isRequired,
53
- onDeleteBlock: PropTypes.func.isRequired,
54
- onFocusPreviousBlock: PropTypes.func.isRequired,
55
- onFocusNextBlock: PropTypes.func.isRequired,
56
- handleKeyDown: PropTypes.func.isRequired,
57
- createContent: PropTypes.func.isRequired,
58
- };
59
25
 
60
- constructor(props) {
61
- super(props);
62
- if (!this.props.data.bg_color) {
63
- this.props.data.bg_color = this.props.data.color ?? 'warning'; // backwards compatibility with previous background-color variable name 'color'
64
- }
65
- this.blockNode = React.createRef();
66
- }
26
+ const Edit = (props) => {
27
+ const { data, onChangeBlock, block, selected } = props;
28
+ const intl = useIntl();
29
+ const { selectedField, setSelectedField } = useHandleDetachedBlockFocus(
30
+ props,
31
+ 'text',
32
+ );
67
33
 
68
- render() {
69
- if (__SERVER__) {
70
- return <div />;
34
+ useEffect(() => {
35
+ if (!data.bg_color) {
36
+ onChangeBlock(block, {
37
+ ...data,
38
+ bg_color: data.color ?? 'warning',
39
+ });
71
40
  }
72
- return (
73
- <div className="public-ui">
74
- <div
75
- className={cx('alertblock', {
76
- selected: this.props.selected,
77
- })}
78
- >
79
- <Row
80
- className={cx(
81
- 'full-width p-5',
82
- 'bg-alert-' + this.props.data.bg_color,
83
- )}
84
- >
85
- <Container className="ui">
86
- <Row className="align-items-start">
87
- {this.props.data.image?.data && (
88
- <Col sm={2} className="pb-3 image-col">
89
- <img
90
- src={`data:${this.props.data.image['content-type']};${this.props.data.image.encoding},${this.props.data.image.data}`}
91
- alt=""
92
- className={cx('left-image', [
93
- this.props.data.sizeImage
94
- ? 'size-' + this.props.data.sizeImage
95
- : 'size-l',
96
- ])}
97
- />
98
- </Col>
99
- )}
100
- <Col>
101
- <TextEditorWidget
102
- data={this.props.data}
103
- fieldName="text"
104
- selected={this.props.selected}
105
- block={this.props.block}
106
- onChangeBlock={(data) =>
107
- this.props.onChangeBlock(this.props.block, data)
108
- }
109
- placeholder={this.props.intl.formatMessage(
110
- messages.content_placeholder,
111
- )}
112
- showToolbar={true}
113
- onSelectBlock={this.props.onSelectBlock}
114
- onAddBlock={this.props.onAddBlock}
115
- index={this.props.index}
116
- onFocusNextBlock={this.props.onFocusNextBlock}
117
- onFocusPreviousBlock={this.props.onFocusPreviousBlock}
41
+ }, [data, onChangeBlock, block]);
42
+
43
+ return __SERVER__ ? (
44
+ <div />
45
+ ) : (
46
+ <div className="public-ui" tabIndex="-1">
47
+ <div
48
+ className={cx('alertblock', {
49
+ selected: selected,
50
+ })}
51
+ >
52
+ <Row className={cx('full-width p-5', 'bg-alert-' + data.bg_color)}>
53
+ <Container className="ui">
54
+ <Row className="align-items-start">
55
+ {data.image?.data && (
56
+ <Col sm={2} className="pb-3 image-col">
57
+ <img
58
+ src={`data:${data.image['content-type']};${data.image.encoding},${data.image.data}`}
59
+ alt=""
60
+ className={cx('left-image', [
61
+ data.sizeImage ? 'size-' + data.sizeImage : 'size-l',
62
+ ])}
118
63
  />
119
64
  </Col>
120
- </Row>
121
- </Container>
122
- </Row>
123
- </div>
124
- <SidebarPortal selected={this.props.selected}>
125
- <AlertSidebar {...this.props} />
126
- </SidebarPortal>
65
+ )}
66
+ <Col>
67
+ <TextEditorWidget
68
+ {...props}
69
+ data={data}
70
+ fieldName="text"
71
+ selected={selectedField === 'text'}
72
+ setSelected={setSelectedField}
73
+ placeholder={intl.formatMessage(messages.content_placeholder)}
74
+ showToolbar={true}
75
+ />
76
+ </Col>
77
+ </Row>
78
+ </Container>
79
+ </Row>
127
80
  </div>
128
- );
129
- }
130
- }
81
+ <SidebarPortal selected={selected}>
82
+ <AlertSidebar {...props} />
83
+ </SidebarPortal>
84
+ </div>
85
+ );
86
+ };
131
87
 
132
- export default compose(
133
- injectIntl,
134
- connect(
135
- (state) => ({
136
- request: state.content.create,
137
- content: state.content.data,
138
- }),
139
- { createContent },
140
- ),
141
- )(Edit);
88
+ export default Edit;
@@ -68,6 +68,7 @@ class Sidebar extends Component {
68
68
  <Segment className="form">
69
69
  <ColorListWidget
70
70
  id="bg_color"
71
+ className="alert-colors-widget"
71
72
  title={this.props.intl.formatMessage(messages.Color)}
72
73
  value={this.props.data.bg_color}
73
74
  onChange={(id, value) => {
@@ -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}