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
@@ -1,6 +1,7 @@
1
1
  /*
2
2
  CUSTOMIZATIONS:
3
3
  - Added stores link
4
+ - Added slate
4
5
  */
5
6
 
6
7
  /**
@@ -17,8 +18,7 @@ import { Button, Dimmer, Loader, Message } from 'semantic-ui-react';
17
18
  import { isEqual } from 'lodash';
18
19
  import { defineMessages, injectIntl } from 'react-intl';
19
20
  import cx from 'classnames';
20
-
21
- import { injectLazyLibs } from '@plone/volto/helpers/Loadable/Loadable';
21
+ import { handleKeyDownOwnFocusManagement } from 'design-comuni-plone-theme/helpers/blocks';
22
22
  import {
23
23
  flattenToAppURL,
24
24
  getBaseUrl,
@@ -29,6 +29,7 @@ import { Icon, SidebarPortal } from '@plone/volto/components';
29
29
 
30
30
  import clearSVG from '@plone/volto/icons/clear.svg';
31
31
 
32
+ import { TextEditorWidget } from 'design-comuni-plone-theme/components/ItaliaTheme';
32
33
  import StoresButtons from 'design-comuni-plone-theme/components/ItaliaTheme/Blocks/HeroImageLeft/StoresButtons';
33
34
  import HeroSidebar from 'design-comuni-plone-theme/components/ItaliaTheme/Blocks/HeroImageLeft/HeroSidebar';
34
35
 
@@ -104,7 +105,7 @@ class EditComponent extends Component {
104
105
  * Constructor
105
106
  * @method constructor
106
107
  * @param {Object} props Component properties
107
- * @constructs WysiwygEditor
108
+ * @constructs Hero Image left edit
108
109
  */
109
110
  constructor(props) {
110
111
  super(props);
@@ -114,58 +115,20 @@ class EditComponent extends Component {
114
115
  uploading: false,
115
116
  };
116
117
 
117
- const { Map } = this.props.immutableLib;
118
-
119
118
  if (!__SERVER__) {
120
- const { DefaultDraftBlockRenderMap, EditorState } = props.draftJs;
121
- const { stateFromHTML } = props.draftJsImportHtml;
122
-
123
- const blockTitleRenderMap = Map({
124
- unstyled: {
125
- element: 'h1',
126
- },
127
- });
128
-
129
- const blockDescriptionRenderMap = Map({
130
- unstyled: {
131
- element: 'div',
132
- },
133
- });
134
-
135
- this.extendedBlockRenderMap =
136
- DefaultDraftBlockRenderMap.merge(blockTitleRenderMap);
137
-
138
- this.extendedDescripBlockRenderMap = DefaultDraftBlockRenderMap.merge(
139
- blockDescriptionRenderMap,
140
- );
141
-
142
- let titleEditorState;
143
- let descriptionEditorState;
144
- if (props.data && props.data.title) {
145
- titleEditorState = EditorState.createWithContent(
146
- stateFromHTML(props.data.title),
147
- );
148
- } else {
149
- titleEditorState = EditorState.createEmpty();
150
- }
151
- if (props.data && props.data.description) {
152
- descriptionEditorState = EditorState.createWithContent(
153
- stateFromHTML(props.data.description),
154
- );
155
- } else {
156
- descriptionEditorState = EditorState.createEmpty();
157
- }
158
119
  this.state = {
159
120
  uploading: false,
160
- titleEditorState,
161
- descriptionEditorState,
162
121
  currentFocused: 'title',
163
122
  };
164
123
  }
165
-
166
- this.onChangeTitle = this.onChangeTitle.bind(this);
167
- this.onChangeDescription = this.onChangeDescription.bind(this);
168
124
  }
125
+ blockRef = React.createRef();
126
+
127
+ handleEnter = (e) => {
128
+ if (this.props.selected) {
129
+ handleKeyDownOwnFocusManagement(e, this.props);
130
+ }
131
+ };
169
132
 
170
133
  /**
171
134
  * Component did mount
@@ -174,7 +137,22 @@ class EditComponent extends Component {
174
137
  */
175
138
  componentDidMount() {
176
139
  if (this.props.selected) {
177
- this.titleEditor.focus();
140
+ this.setState(() => ({ currentFocused: 'title' }));
141
+ }
142
+
143
+ const blockNode = this.props.blockNode;
144
+
145
+ if (this.props.selected && this.node) {
146
+ this.node.focus();
147
+ }
148
+ if (blockNode && blockNode.current) {
149
+ blockNode.current.addEventListener('keydown', this.handleEnter, false);
150
+ } else if (this.blockRef && this.blockRef.current) {
151
+ this.blockRef.current.addEventListener(
152
+ 'keydown',
153
+ this.handleEnter,
154
+ false,
155
+ );
178
156
  }
179
157
  }
180
158
 
@@ -199,44 +177,14 @@ class EditComponent extends Component {
199
177
  });
200
178
  }
201
179
 
202
- const { EditorState } = this.props.draftJs;
203
- const { stateFromHTML } = this.props.draftJsImportHtml;
204
-
205
- if (
206
- nextProps.data.title &&
207
- this.props.data.title !== nextProps.data.title &&
208
- !this.props.selected
209
- ) {
210
- const contentState = stateFromHTML(nextProps.data.title);
211
- this.setState({
212
- titleEditorState: nextProps.data.title
213
- ? EditorState.createWithContent(contentState)
214
- : EditorState.createEmpty(),
215
- });
216
- }
217
-
218
- if (
219
- nextProps.data.description &&
220
- this.props.data.description !== nextProps.data.description &&
221
- !this.props.selected
222
- ) {
223
- const contentState = stateFromHTML(nextProps.data.description);
224
- this.setState({
225
- descriptionEditorState: nextProps.data.description
226
- ? EditorState.createWithContent(contentState)
227
- : EditorState.createEmpty(),
228
- });
229
- }
230
-
231
- if (nextProps.selected !== this.props.selected) {
232
- if (this.state.currentFocused === 'title') {
233
- this.titleEditor.focus();
234
- } else {
235
- this.descriptionEditor.focus();
180
+ if (nextProps.selected) {
181
+ if (!this.props.selected) {
182
+ this.setState({ currentFocused: 'title' });
236
183
  }
184
+ } else {
185
+ this.setState({ currentFocused: null });
237
186
  }
238
187
  }
239
-
240
188
  /**
241
189
  * @param {*} nextProps
242
190
  * @param {*} nextState
@@ -247,36 +195,6 @@ class EditComponent extends Component {
247
195
  return this.props.selected || !isEqual(this.props.data, nextProps.data);
248
196
  }
249
197
 
250
- /**
251
- * Change Title handler
252
- * @method onChangeTitle
253
- * @param {object} titleEditorState Editor state.
254
- * @returns {undefined}
255
- */
256
- onChangeTitle(titleEditorState) {
257
- this.setState({ titleEditorState }, () => {
258
- this.props.onChangeBlock(this.props.block, {
259
- ...this.props.data,
260
- title: titleEditorState.getCurrentContent().getPlainText(),
261
- });
262
- });
263
- }
264
-
265
- /**
266
- * Change Description handler
267
- * @method onChangeDescription
268
- * @param {object} descriptionEditorState Editor state.
269
- * @returns {undefined}
270
- */
271
- onChangeDescription(descriptionEditorState) {
272
- this.setState({ descriptionEditorState }, () => {
273
- this.props.onChangeBlock(this.props.block, {
274
- ...this.props.data,
275
- description: descriptionEditorState.getCurrentContent().getPlainText(),
276
- });
277
- });
278
- }
279
-
280
198
  /**
281
199
  * Upload image handler
282
200
  * @method onUploadImage
@@ -315,13 +233,21 @@ class EditComponent extends Component {
315
233
  if (__SERVER__) {
316
234
  return <div />;
317
235
  }
318
- const { Editor } = this.props.draftJs;
236
+
319
237
  const placeholder =
320
238
  this.props.data.placeholder ||
321
239
  this.props.intl.formatMessage(messages.placeholder);
322
240
 
323
241
  return (
324
- <div className="public-ui">
242
+ <div
243
+ className="public-ui"
244
+ tabIndex="-1"
245
+ ref={(node) => {
246
+ if (node) {
247
+ this.blockRef.current = node;
248
+ }
249
+ }}
250
+ >
325
251
  <div
326
252
  className={cx('block hero', {
327
253
  selected: this.props.selected,
@@ -392,92 +318,43 @@ class EditComponent extends Component {
392
318
  })}
393
319
  >
394
320
  <div className="edit-title">
395
- <Editor
396
- ref={(node) => {
397
- this.titleEditor = node;
398
- }}
399
- readOnly={!this.props.editable}
400
- onChange={this.onChangeTitle}
401
- editorState={this.state.titleEditorState}
402
- blockRenderMap={this.extendedBlockRenderMap}
403
- handleReturn={() => true}
404
- placeholder={this.props.intl.formatMessage(messages.title)}
405
- blockStyleFn={() => 'title-editor'}
406
- onUpArrow={() => {
407
- const selectionState =
408
- this.state.titleEditorState.getSelection();
409
- const { titleEditorState } = this.state;
410
- if (
411
- titleEditorState
412
- .getCurrentContent()
413
- .getBlockMap()
414
- .first()
415
- .getKey() === selectionState.getFocusKey()
416
- ) {
417
- this.props.onFocusPreviousBlock(
418
- this.props.block,
419
- this.props.blockNode.current,
420
- );
421
- }
422
- }}
423
- onDownArrow={() => {
424
- const selectionState =
425
- this.state.titleEditorState.getSelection();
426
- const { titleEditorState } = this.state;
427
- if (
428
- titleEditorState
429
- .getCurrentContent()
430
- .getBlockMap()
431
- .last()
432
- .getKey() === selectionState.getFocusKey()
433
- ) {
321
+ <h1>
322
+ <TextEditorWidget
323
+ {...this.props}
324
+ showToolbar={false}
325
+ data={this.props.data}
326
+ fieldName="title"
327
+ selected={this.state.currentFocused === 'title'}
328
+ placeholder={this.props.intl.formatMessage(messages.title)}
329
+ setSelected={(f) => {
330
+ this.setState(() => ({ currentFocused: f }));
331
+ }}
332
+ focusNextField={() => {
434
333
  this.setState(() => ({ currentFocused: 'description' }));
435
- this.descriptionEditor.focus();
436
- }
437
- }}
438
- />
334
+ }}
335
+ />
336
+ </h1>
439
337
  </div>
440
- <Editor
441
- ref={(node) => {
442
- this.descriptionEditor = node;
443
- }}
444
- readOnly={!this.props.editable}
445
- onChange={this.onChangeDescription}
446
- editorState={this.state.descriptionEditorState}
447
- blockRenderMap={this.extendedDescripBlockRenderMap}
448
- handleReturn={() => true}
449
- placeholder={this.props.intl.formatMessage(
450
- messages.description,
451
- )}
452
- blockStyleFn={() => 'description-editor'}
453
- onUpArrow={() => {
454
- const selectionState =
455
- this.state.descriptionEditorState.getSelection();
456
- const currentCursorPosition = selectionState.getStartOffset();
457
338
 
458
- if (currentCursorPosition === 0) {
339
+ <p>
340
+ <TextEditorWidget
341
+ {...this.props}
342
+ showToolbar={false}
343
+ data={this.props.data}
344
+ fieldName="description"
345
+ selected={this.state.currentFocused === 'description'}
346
+ placeholder={this.props.intl.formatMessage(
347
+ messages.description,
348
+ )}
349
+ setSelected={(f) => {
350
+ this.setState(() => ({ currentFocused: f }));
351
+ }}
352
+ focusPrevField={() => {
459
353
  this.setState(() => ({ currentFocused: 'title' }));
460
- this.titleEditor.focus();
461
- }
462
- }}
463
- onDownArrow={() => {
464
- const selectionState =
465
- this.state.descriptionEditorState.getSelection();
466
- const { descriptionEditorState } = this.state;
467
- const currentCursorPosition = selectionState.getStartOffset();
468
- const blockLength = descriptionEditorState
469
- .getCurrentContent()
470
- .getFirstBlock()
471
- .getLength();
354
+ }}
355
+ />
356
+ </p>
472
357
 
473
- if (currentCursorPosition === blockLength) {
474
- this.props.onFocusNextBlock(
475
- this.props.block,
476
- this.props.blockNode.current,
477
- );
478
- }
479
- }}
480
- />
481
358
  <StoresButtons data={this.props.data} />
482
359
  </div>
483
360
  </div>
@@ -490,9 +367,7 @@ class EditComponent extends Component {
490
367
  }
491
368
  }
492
369
 
493
- const Edit = injectLazyLibs(['draftJs', 'immutableLib', 'draftJsImportHtml'])(
494
- EditComponent,
495
- );
370
+ const Edit = EditComponent;
496
371
 
497
372
  export default compose(
498
373
  injectIntl,
@@ -74,7 +74,7 @@ class Edit extends Component {
74
74
  * Constructor
75
75
  * @method constructor
76
76
  * @param {Object} props Component properties
77
- * @constructs WysiwygEditor
77
+ * @constructs Video block edit
78
78
  */
79
79
  constructor(props) {
80
80
  super(props);
@@ -17,7 +17,7 @@ import { Icon } from '@plone/volto/components';
17
17
  import { Plug } from '@plone/volto/components/manage/Pluggable';
18
18
  import { load } from 'redux-localstorage-simple';
19
19
  import { isEqual, omit, without } from 'lodash';
20
- import { cloneBlock } from 'design-comuni-plone-theme/config/Blocks/ListingOptions';
20
+ import { cloneBlock } from 'design-comuni-plone-theme/helpers/blocks';
21
21
  import { setBlocksClipboard, resetBlocksClipboard } from '@plone/volto/actions';
22
22
  import config from '@plone/volto/registry';
23
23
 
@@ -5,11 +5,13 @@
5
5
  * CUSTOMIZATIONS:
6
6
  * - aggiunto icona per link esterni
7
7
  * - aggiunto title informativo per link esterni
8
+ * - aggiunta la dimensione del file se il link punta a un file (enhanced_link_infos)
9
+ * - aggiunto il parametro hideFileFormat per nascondere il formato del file dall'enhance link
8
10
  */
9
11
 
10
12
  import React from 'react';
11
13
  import PropTypes from 'prop-types';
12
- import { useIntl } from 'react-intl';
14
+ import { useIntl, defineMessages } from 'react-intl';
13
15
  import { HashLink as Link } from 'react-router-hash-link';
14
16
  import { useSelector } from 'react-redux';
15
17
  import {
@@ -19,9 +21,15 @@ import {
19
21
  } from '@plone/volto/helpers/Url/Url';
20
22
  import { matchPath } from 'react-router';
21
23
  import { Icon } from 'design-comuni-plone-theme/components/ItaliaTheme';
22
-
24
+ import { EnhanceLink } from 'design-comuni-plone-theme/helpers';
23
25
  import config from '@plone/volto/registry';
24
26
 
27
+ const messages = defineMessages({
28
+ opensInNewTab: {
29
+ id: 'opensInNewTab',
30
+ defaultMessage: 'Apre in un nuovo tab',
31
+ },
32
+ });
25
33
  const UniversalLink = ({
26
34
  href,
27
35
  item = null,
@@ -31,13 +39,30 @@ const UniversalLink = ({
31
39
  className = null,
32
40
  title = null,
33
41
  overrideMarkSpecialLinks = false,
42
+ hideFileFormat = false,
34
43
  ...props
35
44
  }) => {
36
- const intl = useIntl();
45
+ let translations = {
46
+ opensInNewTab: {
47
+ defaultMessage: messages.opensInNewTab.defaultMessage,
48
+ },
49
+ };
50
+ //questo perchè il provider di intl non è sempre definito, ad esempio in slate_wysiwyg_box (Slate RichTextWidget)
51
+ try {
52
+ const intl = useIntl();
53
+ Object.keys(translations).forEach(
54
+ (k) => (translations[k].message = intl.formatMessage(messages[k])),
55
+ );
56
+ } catch (e) {
57
+ // eslint-disable-next-line no-console
58
+ console.log('Cannot use intl here. View default messages.', e);
59
+ }
37
60
  const token = useSelector((state) => state.userSession?.token);
38
61
  const { openExternalLinkInNewTab } = config.settings;
39
62
 
40
63
  let url = href;
64
+ let enhanced_link_infos = null;
65
+
41
66
  if (!href && item) {
42
67
  if (!item['@id']) {
43
68
  // eslint-disable-next-line no-console
@@ -75,6 +100,16 @@ const UniversalLink = ({
75
100
  }
76
101
  }
77
102
 
103
+ if (item && item['@id']) {
104
+ /*enhance link*/
105
+ if (item && item.enhanced_links_enabled) {
106
+ enhanced_link_infos = { ...item };
107
+ if (!enhanced_link_infos.filename) {
108
+ enhanced_link_infos.filename = item['@id'];
109
+ }
110
+ }
111
+ }
112
+
78
113
  const isBlacklisted =
79
114
  (config.settings.externalRoutes ?? []).find((route) =>
80
115
  matchPath(flattenToAppURL(url), route.match),
@@ -87,6 +122,16 @@ const UniversalLink = ({
87
122
  const checkedURL = URLUtils.checkAndNormalizeUrl(url);
88
123
  url = checkedURL.url;
89
124
 
125
+ let aria_label = props['aria-label'] ?? item?.title ?? null;
126
+ let enhanced_link = null;
127
+ let extended_children = <></>;
128
+
129
+ if (enhanced_link_infos) {
130
+ enhanced_link = EnhanceLink({ enhanced_link_infos, aria_label });
131
+ extended_children = enhanced_link.children;
132
+ aria_label = enhanced_link.aria_label;
133
+ }
134
+
90
135
  let tag = (
91
136
  <Link
92
137
  to={flattenToAppURL(url)}
@@ -95,8 +140,10 @@ const UniversalLink = ({
95
140
  className={className}
96
141
  smooth={config.settings.hashLinkSmoothScroll}
97
142
  {...props}
143
+ aria-label={aria_label}
98
144
  >
99
145
  {children}
146
+ {extended_children}
100
147
  </Link>
101
148
  );
102
149
 
@@ -109,9 +156,10 @@ const UniversalLink = ({
109
156
  tag = (
110
157
  <a
111
158
  href={url}
112
- title={`${title ? title + ' - ' : ''}${intl.formatMessage({
113
- id: 'opensInNewTab',
114
- })}`}
159
+ title={`${title ? title + ' - ' : ''}${
160
+ translations.opensInNewTab.message ??
161
+ translations.opensInNewTab.defaultMessage
162
+ }`}
115
163
  target={
116
164
  !checkedURL.isMail && !checkedURL.isTelephone && openInNewTab
117
165
  ? '_blank'
@@ -120,6 +168,7 @@ const UniversalLink = ({
120
168
  rel="noopener noreferrer"
121
169
  className={className}
122
170
  {...props}
171
+ aria-label={aria_label}
123
172
  >
124
173
  {children}
125
174
  {!overrideMarkSpecialLinks &&
@@ -141,8 +190,10 @@ const UniversalLink = ({
141
190
  title={title}
142
191
  className={className}
143
192
  {...props}
193
+ aria-label={aria_label}
144
194
  >
145
195
  {children}
196
+ {extended_children}
146
197
  </a>
147
198
  );
148
199
  } else if (isDisplayFile) {
@@ -154,8 +205,10 @@ const UniversalLink = ({
154
205
  rel="noopener noreferrer"
155
206
  className={className}
156
207
  {...props}
208
+ aria-label={aria_label}
157
209
  >
158
210
  {children}
211
+ {extended_children}
159
212
  </a>
160
213
  );
161
214
  }
@@ -6,7 +6,7 @@
6
6
  * - customized to use design-react-kit elements instead semantic-ui elements
7
7
  */
8
8
 
9
- import React from 'react';
9
+ import React, { useState } from 'react';
10
10
  import PropTypes from 'prop-types';
11
11
  import { useIntl, defineMessages } from 'react-intl';
12
12
  import { Input, FormGroup, Label } from 'design-react-kit';
@@ -14,15 +14,21 @@ import { Icon } from 'design-comuni-plone-theme/components/ItaliaTheme';
14
14
 
15
15
  import FileWidget from 'design-comuni-plone-theme/components/ItaliaTheme/manage/Widgets/FileWidget';
16
16
  import { injectLazyLibs } from '@plone/volto/helpers/Loadable/Loadable';
17
- import WysiwygWidget from '@plone/volto/components/manage/Widgets/WysiwygWidget';
18
-
17
+ import { TextBlockView } from '@plone/volto-slate/blocks/Text';
18
+ import { TextEditorWidget } from 'design-comuni-plone-theme/components/ItaliaTheme';
19
19
  import config from '@plone/volto/registry';
20
20
 
21
+ import { fromHtml } from 'design-comuni-plone-theme/config/Slate/utils';
22
+
21
23
  const messages = defineMessages({
22
24
  select_a_value: {
23
25
  id: 'form_select_a_value',
24
26
  defaultMessage: 'Seleziona un valore',
25
27
  },
28
+ static_field_placeholder: {
29
+ id: 'form_static_field_placeholder',
30
+ defaultMessage: 'Inserisci qui il testo statico da mostrare.',
31
+ },
26
32
  open_menu: {
27
33
  id: 'open_menu',
28
34
  defaultMessage: 'Apri il menu',
@@ -68,6 +74,8 @@ const Field = ({
68
74
  const intl = useIntl();
69
75
  const Select = reactSelect.default;
70
76
 
77
+ const [selected, setSelected] = useState(false);
78
+
71
79
  const getLabel = () => {
72
80
  return required ? label + ' *' : label;
73
81
  };
@@ -85,6 +93,13 @@ const Field = ({
85
93
  description
86
94
  );
87
95
 
96
+ let static_text_value = value;
97
+ if (field_type === 'static_text') {
98
+ if (value?.data) {
99
+ static_text_value = fromHtml(value);
100
+ } //per retrocompatibilità con il vecchio widget che usava draftjs
101
+ }
102
+
88
103
  return (
89
104
  <div className="field">
90
105
  {field_type === 'text' && (
@@ -322,25 +337,33 @@ const Field = ({
322
337
  value={value ?? ''}
323
338
  />
324
339
  )}
325
- {field_type === 'static_text' &&
326
- (isOnEdit ? (
327
- <WysiwygWidget
328
- wrapped={false}
329
- id={name}
330
- name={name}
331
- title={label}
332
- description={description}
333
- onChange={onChange}
334
- value={value}
335
- />
336
- ) : value?.data ? (
337
- <div
338
- className="static-text"
339
- dangerouslySetInnerHTML={{ __html: value.data }}
340
- />
341
- ) : (
342
- <br />
343
- ))}
340
+
341
+ {field_type === 'static_text' && (
342
+ <>
343
+ {isOnEdit ? (
344
+ <div className="mb-2">
345
+ <TextEditorWidget
346
+ value={static_text_value}
347
+ selected={selected}
348
+ setSelected={setSelected}
349
+ placeholder={intl.formatMessage(
350
+ messages.static_field_placeholder,
351
+ )}
352
+ showToolbar={true}
353
+ onChangeBlock={(block, data) => {
354
+ onChange(name, data.value);
355
+ }}
356
+ />
357
+ </div>
358
+ ) : value ? (
359
+ <div className="static-text">
360
+ <TextBlockView id={name} data={{ value: static_text_value }} />
361
+ </div>
362
+ ) : (
363
+ <br />
364
+ )}
365
+ </>
366
+ )}
344
367
  {config.blocks.blocksConfig.form.additionalFields?.reduce((acc, val) => {
345
368
  if (val.id === field_type)
346
369
  return [