design-comuni-plone-theme 11.29.2 → 12.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (227) hide show
  1. package/.github/workflows/main.yml +16 -16
  2. package/.github/workflows/npm.yml +1 -1
  3. package/.github/workflows/withnewsletter.yml +47 -0
  4. package/.release-it.json +1 -0
  5. package/.yarn/cache/@babel-helper-module-imports-npm-7.24.3-edb733448b-c23492189b.zip +0 -0
  6. package/.yarn/cache/@babel-types-npm-7.24.0-a0508cb308-4b574a37d4.zip +0 -0
  7. package/.yarn/cache/babel-plugin-lodash-npm-3.3.4-c7161075b6-044a4261e6.zip +0 -0
  8. package/.yarn/cache/braces-npm-3.0.3-582c14023c-b95aa0b3bd.zip +0 -0
  9. package/.yarn/cache/fill-range-npm-7.1.1-bf491486db-b4abfbca38.zip +0 -0
  10. package/.yarn/cache/micromatch-npm-4.0.8-c9570e4aca-79920eb634.zip +0 -0
  11. package/.yarn/cache/require-package-name-npm-2.0.1-ac9a206b63-00f4e9e467.zip +0 -0
  12. package/.yarn/install-state.gz +0 -0
  13. package/CHANGELOG.md +1728 -1659
  14. package/RELEASE.md +6 -0
  15. package/locales/de/LC_MESSAGES/volto.po +86 -19
  16. package/locales/en/LC_MESSAGES/volto.po +86 -19
  17. package/locales/es/LC_MESSAGES/volto.po +86 -19
  18. package/locales/fr/LC_MESSAGES/volto.po +86 -19
  19. package/locales/it/LC_MESSAGES/volto.po +87 -20
  20. package/locales/volto.pot +87 -20
  21. package/package.json +3 -1
  22. package/publiccode.yml +2 -2
  23. package/src/components/Collapse.jsx +1 -0
  24. package/src/components/ItaliaTheme/AppExtras/SiteSettingsExtras.jsx +0 -6
  25. package/src/components/ItaliaTheme/Blocks/Accordion/Block/EditBlock.jsx +29 -24
  26. package/src/components/ItaliaTheme/Blocks/Accordion/Block/ViewBlock.jsx +4 -12
  27. package/src/components/ItaliaTheme/Blocks/Accordion/Edit.jsx +118 -42
  28. package/src/components/ItaliaTheme/Blocks/Accordion/View.jsx +4 -18
  29. package/src/components/ItaliaTheme/Blocks/Alert/Edit.jsx +60 -113
  30. package/src/components/ItaliaTheme/Blocks/Alert/Sidebar.jsx +1 -0
  31. package/src/components/ItaliaTheme/Blocks/Alert/View.jsx +5 -14
  32. package/src/components/ItaliaTheme/Blocks/ArgumentsInEvidence/Block.jsx +16 -11
  33. package/src/components/ItaliaTheme/Blocks/ArgumentsInEvidence/Body.jsx +2 -1
  34. package/src/components/ItaliaTheme/Blocks/ArgumentsInEvidence/Edit.jsx +39 -1
  35. package/src/components/ItaliaTheme/Blocks/CTABlock/Block.jsx +35 -95
  36. package/src/components/ItaliaTheme/Blocks/Callout/Edit.jsx +108 -0
  37. package/src/components/ItaliaTheme/Blocks/Callout/Sidebar.jsx +173 -0
  38. package/src/components/ItaliaTheme/Blocks/Callout/View.jsx +45 -0
  39. package/src/components/ItaliaTheme/Blocks/ContactsBlock/Block/EditBlock.jsx +86 -63
  40. package/src/components/ItaliaTheme/Blocks/ContactsBlock/Block/ViewBlock.jsx +19 -39
  41. package/src/components/ItaliaTheme/Blocks/ContactsBlock/Edit.jsx +101 -22
  42. package/src/components/ItaliaTheme/Blocks/ContactsBlock/View.jsx +13 -21
  43. package/src/components/ItaliaTheme/Blocks/CountDown/Edit.jsx +21 -25
  44. package/src/components/ItaliaTheme/Blocks/CountDown/View.jsx +6 -15
  45. package/src/components/ItaliaTheme/Blocks/IconBlocks/Block/EditBlock.jsx +52 -22
  46. package/src/components/ItaliaTheme/Blocks/IconBlocks/Block/ViewBlock.jsx +9 -29
  47. package/src/components/ItaliaTheme/Blocks/IconBlocks/Edit.jsx +108 -21
  48. package/src/components/ItaliaTheme/Blocks/IconBlocks/Sidebar.jsx +1 -9
  49. package/src/components/ItaliaTheme/Blocks/IconBlocks/View.jsx +6 -14
  50. package/src/components/ItaliaTheme/Blocks/Listing/CardWithSlideUpTextTemplate.jsx +0 -1
  51. package/src/components/ItaliaTheme/Blocks/NumbersBlock/Block/EditBlock.jsx +45 -15
  52. package/src/components/ItaliaTheme/Blocks/NumbersBlock/Block/ViewBlock.jsx +2 -18
  53. package/src/components/ItaliaTheme/Blocks/NumbersBlock/Edit.jsx +98 -11
  54. package/src/components/ItaliaTheme/Blocks/NumbersBlock/View.jsx +2 -7
  55. package/src/components/ItaliaTheme/Blocks/TextCard/CardWithImage/Block.jsx +35 -67
  56. package/src/components/ItaliaTheme/Blocks/TextCard/CardWithImage/Edit.jsx +2 -8
  57. package/src/components/ItaliaTheme/Blocks/TextCard/SimpleCard/BodyWrapper.jsx +2 -1
  58. package/src/components/ItaliaTheme/Blocks/TextCard/SimpleCard/Edit.jsx +98 -84
  59. package/src/components/ItaliaTheme/Blocks/TextCard/SimpleCard/View.jsx +20 -3
  60. package/src/components/ItaliaTheme/Blocks/UOSearch/Sidebar.jsx +11 -11
  61. package/src/components/ItaliaTheme/Blocks/__tests__/Accordion.test.jsx +11 -28
  62. package/src/components/ItaliaTheme/Blocks/__tests__/Alert.test.jsx +10 -14
  63. package/src/components/ItaliaTheme/Blocks/__tests__/ArgumentsInEvidence.test.jsx +20 -28
  64. package/src/components/ItaliaTheme/Blocks/__tests__/CTABlock.test.jsx +14 -29
  65. package/src/components/ItaliaTheme/Blocks/__tests__/CardWithImage.test.jsx +11 -28
  66. package/src/components/ItaliaTheme/Blocks/__tests__/ContactsBlock.test.jsx +75 -140
  67. package/src/components/ItaliaTheme/Blocks/__tests__/Countdown.test.jsx +20 -28
  68. package/src/components/ItaliaTheme/Blocks/__tests__/IconBlocks.test.jsx +22 -56
  69. package/src/components/ItaliaTheme/Blocks/__tests__/NumbersBlock.test.jsx +14 -43
  70. package/src/components/ItaliaTheme/Blocks/__tests__/SimpleCard.test.jsx +14 -30
  71. package/src/components/ItaliaTheme/BrandText/BrandText.jsx +8 -14
  72. package/src/components/ItaliaTheme/BrandTextFooter/BrandTextFooter.jsx +31 -2
  73. package/src/components/ItaliaTheme/Footer/FooterInfos.jsx +21 -8
  74. package/src/components/ItaliaTheme/Footer/FooterNavigation.jsx +3 -3
  75. package/src/components/ItaliaTheme/Header/HeaderSlim/HeaderSlim.jsx +0 -7
  76. package/src/components/ItaliaTheme/Icons/Icon.jsx +0 -1
  77. package/src/components/ItaliaTheme/MegaMenu/MegaMenu.jsx +5 -1
  78. package/src/components/ItaliaTheme/View/BandoView/BandoApprofondimenti.jsx +1 -2
  79. package/src/components/ItaliaTheme/View/CartellaModulisticaView/DocRow.jsx +14 -5
  80. package/src/components/ItaliaTheme/View/Commons/Attachment.jsx +19 -3
  81. package/src/components/ItaliaTheme/View/Commons/Attachments.jsx +0 -1
  82. package/src/components/ItaliaTheme/View/Commons/DownloadFileFormat.jsx +11 -7
  83. package/src/components/ItaliaTheme/View/Commons/Gallery.jsx +1 -0
  84. package/src/components/ItaliaTheme/View/Commons/PageHeader/PageHeaderEventDates.jsx +0 -1
  85. package/src/components/ItaliaTheme/View/Commons/PageHeader/PageHeaderLinkServizio.jsx +6 -2
  86. package/src/components/ItaliaTheme/View/Commons/RichTextRender.jsx +8 -6
  87. package/src/components/ItaliaTheme/View/Commons/__tests__/RichText.test.jsx +14 -17
  88. package/src/components/ItaliaTheme/View/EventoView/EventoContattiOrganizzatoreEsterno.jsx +1 -1
  89. package/src/components/ItaliaTheme/View/EventoView/EventoUlterioriInformazioni.jsx +0 -4
  90. package/src/components/ItaliaTheme/View/ServizioView/ServizioAccedi.jsx +10 -7
  91. package/src/components/ItaliaTheme/View/ServizioView/ServizioMetatag.jsx +4 -3
  92. package/src/components/ItaliaTheme/View/__disabled_tests__/IncaricoView.test__disabled.jsx +24 -30
  93. package/src/components/ItaliaTheme/View/__tests__/CartellaModulisticaView.test.jsx +12 -1
  94. package/src/components/ItaliaTheme/View/__tests__/PageView.test.jsx +24 -2
  95. package/src/components/ItaliaTheme/View/__tests__/PersonaView.test.jsx +96 -92
  96. package/src/components/ItaliaTheme/View/__tests__/ServizioAChiSiRivolge.test.jsx +240 -286
  97. package/src/components/ItaliaTheme/View/__tests__/ServizioAccedi.test.jsx +240 -286
  98. package/src/components/ItaliaTheme/View/__tests__/ServizioCasiParticolari.test.jsx +240 -286
  99. package/src/components/ItaliaTheme/View/__tests__/ServizioComeFare.test.jsx +240 -286
  100. package/src/components/ItaliaTheme/View/__tests__/ServizioCondizioni.test.jsx +240 -286
  101. package/src/components/ItaliaTheme/View/__tests__/ServizioContatti.test.jsx +240 -286
  102. package/src/components/ItaliaTheme/View/__tests__/ServizioCosE.test.jsx +240 -286
  103. package/src/components/ItaliaTheme/View/__tests__/ServizioCosaServe.test.jsx +240 -286
  104. package/src/components/ItaliaTheme/View/__tests__/ServizioCosaSiOttiene.test.jsx +240 -286
  105. package/src/components/ItaliaTheme/View/__tests__/ServizioCostiVincoli.test.jsx +240 -286
  106. package/src/components/ItaliaTheme/View/__tests__/ServizioMetadati.test.jsx +240 -286
  107. package/src/components/ItaliaTheme/View/__tests__/ServizioModulistica.test.jsx +240 -286
  108. package/src/components/ItaliaTheme/View/__tests__/ServizioProcedure.test.jsx +240 -286
  109. package/src/components/ItaliaTheme/View/__tests__/ServizioSitiEsterni.test.jsx +240 -286
  110. package/src/components/ItaliaTheme/View/__tests__/ServizioTempiScadenze.test.jsx +240 -286
  111. package/src/components/ItaliaTheme/View/__tests__/ServizioUlterioriInformazioni.test.jsx +240 -286
  112. package/src/components/ItaliaTheme/View/__tests__/ServizioView.test.jsx +470 -560
  113. package/src/components/ItaliaTheme/View/__tests__/TrasparenzaView.test.jsx +12 -1
  114. package/src/components/ItaliaTheme/index.js +0 -1
  115. package/src/components/ItaliaTheme/manage/Widgets/ColorListWidget.jsx +11 -2
  116. package/src/components/ItaliaTheme/manage/Widgets/HtmlSlateWidget.jsx +156 -0
  117. package/src/components/ItaliaTheme/manage/Widgets/RichTextWidget.jsx +88 -0
  118. package/src/components/ItaliaTheme/manage/Widgets/SimpleTextEditorWidget.jsx +158 -0
  119. package/src/components/ItaliaTheme/manage/Widgets/TextEditorWidget.jsx +167 -270
  120. package/src/config/Blocks/ListingOptions/index.js +0 -1
  121. package/src/config/Blocks/ListingOptions/utils.js +0 -7
  122. package/src/config/Blocks/blocks.js +29 -8
  123. package/src/config/Blocks/listingVariations.js +1 -1
  124. package/src/config/Slate/Alignment/AlignMenu.jsx +169 -0
  125. package/src/config/Slate/Alignment/index.js +42 -0
  126. package/src/config/Slate/Blockquote/BlockquoteMenu.jsx +151 -0
  127. package/src/config/Slate/Blockquote/index.js +19 -0
  128. package/src/config/Slate/Headings/HeadingsMenu.jsx +139 -0
  129. package/src/config/Slate/Headings/headingsMenu.scss +44 -0
  130. package/src/config/Slate/Headings/index.js +62 -0
  131. package/src/config/Slate/Link/deserializer.js +25 -0
  132. package/src/config/Slate/Link/index.js +126 -0
  133. package/src/config/Slate/Link/renderer.jsx +99 -0
  134. package/src/config/Slate/LinkButton/index.js +47 -0
  135. package/src/config/Slate/TextLarger/index.js +51 -0
  136. package/src/config/Slate/Underline/index.js +10 -0
  137. package/src/config/Slate/config.js +43 -0
  138. package/src/config/Slate/deserializers.js +66 -0
  139. package/src/config/Slate/dropdownStyle.scss +14 -0
  140. package/src/config/Slate/dropdownUtils.js +422 -0
  141. package/src/config/Slate/extensions/breakList.js +91 -0
  142. package/src/config/Slate/handlers.js +243 -0
  143. package/src/config/Slate/utils.js +73 -0
  144. package/src/config/Widgets/widgets.js +1 -2
  145. package/src/config/italiaConfig.js +5 -53
  146. package/src/customizations/volto/components/manage/AnchorPlugin/components/LinkButton/AddLinkForm.jsx +361 -0
  147. package/src/customizations/volto/components/manage/Blocks/HeroImageLeft/Edit.jsx +75 -200
  148. package/src/customizations/volto/components/manage/Blocks/Video/Body.jsx +0 -1
  149. package/src/customizations/volto/components/manage/Blocks/Video/Edit.jsx +1 -1
  150. package/src/customizations/volto/components/manage/Form/BlocksToolbar.jsx +1 -1
  151. package/src/customizations/volto/components/manage/UniversalLink/UniversalLink.jsx +76 -18
  152. package/src/customizations/volto/components/manage/Widgets/RecurrenceWidget/RecurrenceWidget.jsx +4 -0
  153. package/src/customizations/volto-form-block/components/Field.jsx +45 -22
  154. package/src/helpers/EnhanceLink.js +44 -0
  155. package/src/helpers/FormValidation/FormValidationHelpers.js +3 -0
  156. package/src/helpers/blocks.js +80 -0
  157. package/src/helpers/files.js +13 -13
  158. package/src/helpers/index.js +4 -3
  159. package/src/helpers/richTextHelper.js +10 -0
  160. package/src/icons/Group.svg +1 -0
  161. package/src/icons/blocco-icone.svg +0 -3
  162. package/src/icons/blockquote-card-dark.svg +1 -0
  163. package/src/icons/blockquote-card.svg +1 -0
  164. package/src/icons/blockquote-simple.svg +1 -0
  165. package/src/icons/text-larger.svg +1 -0
  166. package/src/theme/ItaliaTheme/Blocks/_accordion.scss +2 -22
  167. package/src/theme/ItaliaTheme/Blocks/_alert.scss +51 -4
  168. package/src/theme/ItaliaTheme/Blocks/_bandiInEvidenceTemplate.scss +1 -0
  169. package/src/theme/ItaliaTheme/Blocks/_callout.scss +32 -0
  170. package/src/theme/ItaliaTheme/Blocks/_contacts.scss +17 -51
  171. package/src/theme/ItaliaTheme/Blocks/_countdown.scss +10 -1
  172. package/src/theme/ItaliaTheme/Blocks/_ctaBlock.scss +7 -23
  173. package/src/theme/ItaliaTheme/Blocks/_gridBlock.scss +1 -1
  174. package/src/theme/ItaliaTheme/Blocks/_hero.scss +1 -8
  175. package/src/theme/ItaliaTheme/Blocks/_iconBlocks.scss +6 -77
  176. package/src/theme/ItaliaTheme/Blocks/_imageCardTextBlock.scss +3 -2
  177. package/src/theme/ItaliaTheme/Blocks/_numbers.scss +6 -20
  178. package/src/theme/ItaliaTheme/Blocks/_simpleCardTextBlock.scss +8 -2
  179. package/src/theme/ItaliaTheme/Blocks/_subblocks-edit.scss +3 -1
  180. package/src/theme/ItaliaTheme/Blocks/_tableOfContents.scss +1 -0
  181. package/src/theme/ItaliaTheme/Components/_megamenu.scss +0 -4
  182. package/src/theme/ItaliaTheme/Components/_mobileMenu.scss +12 -16
  183. package/src/theme/ItaliaTheme/Print/_page.scss +1 -1
  184. package/src/theme/ItaliaTheme/Subsites/ItaliaTheme/Blocks/_contacts.scss +3 -0
  185. package/src/theme/ItaliaTheme/Subsites/ItaliaTheme/Blocks/_cta.scss +1 -0
  186. package/src/theme/ItaliaTheme/Subsites/ItaliaTheme/Blocks/_searchSections.scss +1 -0
  187. package/src/theme/ItaliaTheme/Subsites/bootstrap-italia/custom/_headercenter.scss +1 -0
  188. package/src/theme/ItaliaTheme/Views/_cartellaModulistica.scss +11 -2
  189. package/src/theme/ItaliaTheme/Views/_servizio.scss +2 -2
  190. package/src/theme/ItaliaTheme/Views/_slider.scss +3 -0
  191. package/src/theme/ItaliaTheme/Widgets/_iconWidget.scss +4 -0
  192. package/src/theme/ItaliaTheme/_common.scss +1 -0
  193. package/src/theme/ItaliaTheme/_home.scss +0 -4
  194. package/src/theme/ItaliaTheme/_main.scss +78 -84
  195. package/src/theme/_cms-ui.scss +63 -160
  196. package/src/theme/_mixins.scss +13 -0
  197. package/src/theme/bootstrap-override/_bootstrap-italia-site.scss +1 -0
  198. package/src/theme/bootstrap-override/bootstrap-italia/_footer.scss +1 -1
  199. package/src/theme/bootstrap-override/bootstrap-italia/_forms.scss +7 -0
  200. package/src/theme/bootstrap-override/bootstrap-italia/_headercenter.scss +8 -3
  201. package/src/theme/extras/_forms.scss +2 -14
  202. package/src/theme/site.scss +1 -1
  203. package/test-setup-config.js +58 -0
  204. package/.yarn/cache/braces-npm-3.0.2-782240b28a-e2a8e769a8.zip +0 -0
  205. package/.yarn/cache/fill-range-npm-7.0.1-b8b1817caa-cc283f4e65.zip +0 -0
  206. package/.yarn/cache/micromatch-npm-4.0.5-cfab5d7669-02a17b671c.zip +0 -0
  207. package/src/components/ItaliaTheme/Blocks/TextCard/SimpleCard/Block.jsx +0 -151
  208. package/src/components/ItaliaTheme/RemoveBodyClass/RemoveBodyClass.jsx +0 -84
  209. package/src/config/RichTextEditor/LinkEntity.jsx +0 -27
  210. package/src/config/RichTextEditor/Plugins/AnchorPlugin/components/Link/index.jsx +0 -44
  211. package/src/config/RichTextEditor/Plugins/AnchorPlugin/components/LinkButton/AddLinkForm.jsx +0 -349
  212. package/src/config/RichTextEditor/Plugins/AnchorPlugin/components/LinkButton/index.js +0 -150
  213. package/src/config/RichTextEditor/Plugins/AnchorPlugin/index.js +0 -88
  214. package/src/config/RichTextEditor/ToolbarButtons/AlignButton.jsx +0 -61
  215. package/src/config/RichTextEditor/ToolbarButtons/ButtonsButton.jsx +0 -14
  216. package/src/config/RichTextEditor/ToolbarButtons/CalloutsButton.jsx +0 -38
  217. package/src/config/RichTextEditor/ToolbarButtons/DraftJsDropdownButton.jsx +0 -106
  218. package/src/config/RichTextEditor/ToolbarButtons/HeadingsButton.jsx +0 -57
  219. package/src/config/RichTextEditor/ToolbarButtons/TextSizeButton.jsx +0 -65
  220. package/src/config/RichTextEditor/ToolbarButtons/UnderlineButton.jsx +0 -14
  221. package/src/config/RichTextEditor/config.js +0 -253
  222. package/src/config/volto-gdpr-privacy-defaultPanelConfig.js +0 -292
  223. package/src/customizations/volto/components/manage/Blocks/ToC/View.jsx +0 -134
  224. package/src/customizations/volto/components/manage/Blocks/ToC/variations/DefaultTocRenderer.jsx +0 -99
  225. package/src/customizations/volto/config/RichTextEditor/Plugins.jsx +0 -63
  226. package/src/helpers/redraftHelper.js +0 -9
  227. package/src/theme/ItaliaTheme/Components/_logo.scss +0 -10
@@ -1,16 +1,27 @@
1
1
  /**
2
2
  * Edit text block.
3
3
  * @module components/Widgets/TextEditorWidget/TextEditorWidget
4
+ *
5
+ * E' come il componente DetatchedTextBlockEditor di @plone/volto-slate,
6
+ * ma in più ha il withBlockProperties,
7
+ * che serve per getire gli handler (le function di focusPrev e focusNext)
4
8
  */
5
9
 
6
- import React, { Component } from 'react';
10
+ import React from 'react';
11
+ import { connect } from 'react-redux';
7
12
  import PropTypes from 'prop-types';
8
- import { compose } from 'redux';
9
- import { defineMessages, injectIntl } from 'react-intl';
10
- import { includes, isEqual } from 'lodash';
11
- import loadable from '@loadable/component';
12
- import { injectLazyLibs } from '@plone/volto/helpers/Loadable/Loadable';
13
13
 
14
+ import { defineMessages, useIntl } from 'react-intl';
15
+ import { useInView } from 'react-intersection-observer';
16
+ import { SlateEditor } from '@plone/volto-slate/editor';
17
+ import { serializeNodesToText } from '@plone/volto-slate/editor/render';
18
+ import { handleKeyDetached } from '@plone/volto-slate/blocks/Text/keyboard';
19
+ import {
20
+ uploadContent,
21
+ saveSlateBlockSelection,
22
+ } from '@plone/volto-slate/actions';
23
+ import SimpleTextEditorWidget from './SimpleTextEditorWidget';
24
+ import { breakList as customBreakList } from 'design-comuni-plone-theme/config/Slate/extensions/breakList';
14
25
  import config from '@plone/volto/registry';
15
26
 
16
27
  const messages = defineMessages({
@@ -20,284 +31,170 @@ const messages = defineMessages({
20
31
  },
21
32
  });
22
33
 
23
- const Editor = loadable(() => import('draft-js-plugins-editor'));
24
-
25
- /**
26
- * TextEditorWidget class.
27
- * @class Edit
28
- * @extends Component
29
- */
30
- class TextEditorWidgetComponent extends Component {
31
- /**
32
- * Property types.
33
- * @property {Object} propTypes Property types.
34
- * @static
35
- */
36
- static propTypes = {
37
- data: PropTypes.objectOf(PropTypes.any).isRequired,
38
- fieldName: PropTypes.string.isRequired,
39
- selected: PropTypes.bool.isRequired,
40
- block: PropTypes.string.isRequired,
41
- onChangeBlock: PropTypes.func.isRequired,
42
- placeholder: PropTypes.string,
43
- focusOn: PropTypes.func,
44
- nextFocus: PropTypes.any,
45
- prevFocus: PropTypes.any,
46
- onFocusNextBlock: PropTypes.any,
47
- onFocusPreviousBlock: PropTypes.any,
48
- showToolbar: PropTypes.bool,
49
- onSelectBlock: PropTypes.func,
50
- onAddBlock: PropTypes.func,
51
- disableMoveToNearest: PropTypes.bool,
52
- };
53
-
54
- /**
55
- * Default properties
56
- * @property {Object} defaultProps Default properties.
57
- * @static
58
- */
59
- static defaultProps = {
60
- showToolbar: true,
61
- };
62
-
63
- /**
64
- * Constructor
65
- * @method constructor
66
- * @param {Object} props Component properties
67
- * @constructs WysiwygEditor
68
- */
69
- constructor(props) {
70
- super(props);
71
- const { settings } = config;
72
-
73
- this.draftConfig = settings.richtextEditorSettings(props);
74
-
75
- const { EditorState, convertFromRaw } = props.draftJs;
76
- const createInlineToolbarPlugin = props.draftJsInlineToolbarPlugin.default;
77
-
78
- if (!__SERVER__) {
79
- let editorState;
80
- if (props.data && props.data[props.fieldName]) {
81
- editorState = EditorState.createWithContent(
82
- convertFromRaw(props.data[props.fieldName]),
83
- );
84
- } else {
85
- editorState = EditorState.createEmpty();
86
- }
87
-
88
- const inlineToolbarPlugin = createInlineToolbarPlugin({
89
- structure: this.draftConfig.richTextEditorInlineToolbarButtons,
90
- });
91
-
92
- this.state = {
93
- editorState,
94
- inlineToolbarPlugin,
95
- addNewBlockOpened: false,
34
+ const TextEditorWidget = (props) => {
35
+ const {
36
+ showToolbar = true,
37
+ setSelected,
38
+ wrapClass,
39
+ index,
40
+ properties,
41
+ value,
42
+ fieldName,
43
+ block,
44
+ selected,
45
+ onSelectBlock,
46
+ onChangeBlock,
47
+ data = {},
48
+ ...otherProps
49
+ } = props;
50
+
51
+ const { slate } = config.settings;
52
+ const { textblockExtensions } = slate;
53
+ const withBlockProperties = React.useCallback(
54
+ (editor) => {
55
+ const p = {
56
+ ...props,
57
+ showToolbar: showToolbar,
58
+ data: { ...props.data, disableNewBlocks: true },
96
59
  };
60
+ editor.getBlockProps = () => p;
61
+ return editor;
62
+ },
63
+ [props, showToolbar],
64
+ );
65
+ //const [uid, setUid] = useState();
66
+ // const getEditor = React.useCallback((editor) => {
67
+ // setUid(editor.uid);
68
+ // return editor;
69
+ // });
70
+
71
+ //const link_pid = `${uid}-link`;
72
+ // const show_sidebar_editor = useSelector((state) => {
73
+ // return state['slate_plugins']?.[link_pid]?.show_sidebar_editor;
74
+ // });
75
+
76
+ const intl = useIntl();
77
+ const placeholder =
78
+ otherProps.placeholder || intl.formatMessage(messages.text);
79
+
80
+ const { ref, inView } = useInView({
81
+ threshold: 0,
82
+ rootMargin: '0px 0px 200px 0px',
83
+ });
84
+
85
+ const _value = fieldName ? data[fieldName] : value;
86
+
87
+ const selectThis = () => {
88
+ if (setSelected) {
89
+ setSelected(fieldName ?? true);
90
+ } else if (onSelectBlock) {
91
+ onSelectBlock(block);
97
92
  }
98
- }
99
-
100
- /**
101
- * Component will receive props
102
- * @method componentDidMount
103
- * @returns {undefined}
104
- */
105
- componentDidMount() {
106
- if (this.props.selected && this.node) {
107
- setTimeout(this.node.focus, 0);
108
- }
109
- }
110
-
111
- /**
112
- * Component will receive props
113
- * @method componentWillReceiveProps
114
- * @param {Object} nextProps Next properties
115
- * @returns {undefined}
116
- */
117
- UNSAFE_componentWillReceiveProps(nextProps) {
118
- if (!this.props.selected && nextProps.selected) {
119
- // See https://github.com/draft-js-plugins/draft-js-plugins/issues/800
120
- setTimeout(this.node.focus, 0);
121
- const { EditorState } = this.props.draftJs;
122
-
123
- this.setState({
124
- editorState: EditorState.moveFocusToEnd(this.state.editorState),
125
- });
126
- }
127
- }
128
-
129
- /**
130
- * Change handler
131
- * @method onChange
132
- * @param {object} editorState Editor state.
133
- * @returns {undefined}
134
- */
135
- onChange = (editorState) => {
136
- const { convertToRaw } = this.props.draftJs;
137
- if (
138
- !isEqual(
139
- convertToRaw(editorState.getCurrentContent()),
140
- convertToRaw(this.state.editorState.getCurrentContent()),
141
- )
142
- ) {
143
- this.props.onChangeBlock({
144
- ...this.props.data,
145
- [this.props.fieldName]: convertToRaw(editorState.getCurrentContent()),
146
- });
147
- }
148
- this.setState({ editorState });
149
93
  };
150
94
 
151
- /**
152
- * Render method.
153
- * @method render
154
- * @returns {string} Markup for the component.
155
- */
156
- render() {
157
- if (__SERVER__) {
158
- return <div />;
95
+ const extensions = [...textblockExtensions].map((f) => {
96
+ if (f.name === 'breakList') {
97
+ return customBreakList;
159
98
  }
160
-
161
- const { InlineToolbar } = this.state.inlineToolbarPlugin;
162
- let placeholder = this.props.placeholder
163
- ? this.props.placeholder
164
- : this.props.intl.formatMessage(messages.text);
165
- let disableMoveToNearest = this.props.disableMoveToNearest;
166
- const isSoftNewlineEvent = this.props.draftJsLibIsSoftNewlineEvent.default;
167
- const { RichUtils } = this.props.draftJs;
168
-
169
- return (
170
- <>
171
- <div className={[this.props.fieldName]}>
172
- <Editor
173
- onChange={this.onChange}
174
- editorState={this.state.editorState}
175
- plugins={[
176
- this.state.inlineToolbarPlugin,
177
- ...this.draftConfig.richTextEditorPlugins,
178
- ]}
179
- blockRenderMap={this.draftConfig.extendedBlockRenderMap}
180
- blockStyleFn={this.draftConfig.blockStyleFn}
181
- customStyleMap={this.draftConfig.customStyleMap}
182
- placeholder={placeholder}
183
- handleReturn={(e) => {
184
- // if (disableMoveToNearest) {
185
- // e.stopPropagation();
186
- // }
187
- if (isSoftNewlineEvent(e)) {
188
- this.onChange(
189
- RichUtils.insertSoftNewline(this.state.editorState),
190
- );
191
- return 'handled';
99
+ return f;
100
+ });
101
+ return (
102
+ <div
103
+ className={wrapClass}
104
+ onClick={() => selectThis()}
105
+ onFocus={() => selectThis()}
106
+ onKeyDown={() => selectThis()}
107
+ role={'textbox'}
108
+ tabIndex="-1"
109
+ >
110
+ {showToolbar ? (
111
+ <div
112
+ className="text-slate-editor-inner detached-slate-editor"
113
+ ref={ref}
114
+ >
115
+ <SlateEditor
116
+ index={index}
117
+ readOnly={!inView}
118
+ properties={properties}
119
+ extensions={extensions}
120
+ renderExtensions={[withBlockProperties /*, getEditor*/]}
121
+ value={_value}
122
+ block={block /* is this needed? */}
123
+ slateSettings={otherProps.slateSettings}
124
+ onFocus={() => {
125
+ if (!selected) {
126
+ selectThis();
192
127
  }
193
-
194
- if (
195
- !disableMoveToNearest &&
196
- this.props.onSelectBlock &&
197
- this.props.onAddBlock
198
- ) {
199
- const selectionState = this.state.editorState.getSelection();
200
- const anchorKey = selectionState.getAnchorKey();
201
- const currentContent =
202
- this.state.editorState.getCurrentContent();
203
- const currentContentBlock =
204
- currentContent.getBlockForKey(anchorKey);
205
- const blockType = currentContentBlock.getType();
206
- if (!includes(this.draftConfig.listBlockTypes, blockType)) {
207
- this.props.onSelectBlock(
208
- this.props.onAddBlock('text', this.props.index + 1),
209
- );
210
- return 'handled';
211
- }
212
- return 'un-handled';
213
- }
214
-
215
- return {};
216
128
  }}
217
- onUpArrow={(e) => {
218
- if (this.props.prevFocus) {
219
- this.props.setFocus(this.props.prevFocus);
220
- e.stopPropagation();
221
- } else {
222
- if (this.props.disableMoveToNearest) {
223
- e.stopPropagation();
224
- } else {
225
- if (this.props.onFocusPreviousBlock) {
226
- const selectionState =
227
- this.state.editorState.getSelection();
228
- const currentCursorPosition =
229
- selectionState.getStartOffset();
129
+ onChange={(value, selection, editor) => {
130
+ let v = value;
230
131
 
231
- if (currentCursorPosition === 0) {
232
- this.props.onFocusPreviousBlock(
233
- this.props.block,
234
- this.node,
235
- );
236
- }
237
- }
238
- }
239
- }
240
- }}
241
- onDownArrow={(e) => {
242
- if (this.props.nextFocus) {
243
- this.props.setFocus(this.props.nextFocus);
244
- e.stopPropagation();
245
- } else {
246
- if (this.props.disableMoveToNearest) {
247
- e.stopPropagation();
248
- } else {
249
- if (this.props.onFocusNextBlock) {
250
- const selectionState =
251
- this.state.editorState.getSelection();
252
- const { editorState } = this.state;
253
- const currentCursorPosition =
254
- selectionState.getStartOffset();
255
- const blockLength = editorState
256
- .getCurrentContent()
257
- .getFirstBlock()
258
- .getLength();
132
+ let retVal = {
133
+ value: v,
134
+ plaintext: serializeNodesToText(value || []),
135
+ };
259
136
 
260
- if (currentCursorPosition === blockLength) {
261
- this.props.onFocusNextBlock(this.props.block, this.node);
262
- }
263
- }
264
- }
137
+ if (fieldName) {
138
+ retVal = { [fieldName]: v };
265
139
  }
140
+ onChangeBlock(block, {
141
+ ...data,
142
+ ...retVal,
143
+ });
266
144
  }}
267
- ref={(node) => {
268
- this.node = node;
145
+ selected={selected}
146
+ placeholder={placeholder}
147
+ onKeyDown={handleKeyDetached}
148
+ editableProps={{
149
+ 'aria-multiline': 'true',
150
+ }}
151
+ onBlur={() => {
152
+ // //fix: click on toolbar dropdown items. But you cannot reselect h2 text for example if you go out of the block
153
+ // if (!show_sidebar_editor) {
154
+ // setSelected(fieldName ? null : false);
155
+ // }
269
156
  }}
270
157
  />
271
- {this.props.showToolbar && this.node && <InlineToolbar />}
272
158
  </div>
273
- </>
274
- );
275
- }
276
- }
277
-
278
- export const TextEditorWidget = React.memo(
279
- compose(
280
- injectIntl,
281
- injectLazyLibs([
282
- 'draftJs',
283
- 'draftJsLibIsSoftNewlineEvent',
284
- 'draftJsFilters',
285
- 'draftJsInlineToolbarPlugin',
286
- 'draftJsBlockBreakoutPlugin',
287
- 'draftJsCreateInlineStyleButton',
288
- 'draftJsCreateBlockStyleButton',
289
- 'immutableLib',
290
- // TODO: add all plugin dependencies, also in Wysiwyg and Cell
291
- ]),
292
- )(TextEditorWidgetComponent),
293
- );
159
+ ) : (
160
+ <div className="text-editor-inner simple-text">
161
+ <SimpleTextEditorWidget {...props} index={index} value={_value} />
162
+ </div>
163
+ )}
164
+ </div>
165
+ );
166
+ };
294
167
 
295
- const Preloader = (props) => {
296
- const [loaded, setLoaded] = React.useState(false);
297
- React.useEffect(() => {
298
- Editor.load().then(() => setLoaded(true));
299
- }, []);
300
- return loaded ? <TextEditorWidget {...props} /> : null;
168
+ TextEditorWidget.propTypes = {
169
+ data: PropTypes.objectOf(PropTypes.any).isRequired,
170
+ setSelected: PropTypes.func,
171
+ onChangeBlock: PropTypes.func.isRequired,
172
+ block: PropTypes.string.isRequired,
173
+ selected: PropTypes.bool.isRequired,
174
+ showToolbar: PropTypes.bool,
175
+ wrapClass: PropTypes.string,
176
+ focusPrevField: PropTypes.func,
177
+ focusNextField: PropTypes.func,
178
+ //from block props:
179
+ properties: PropTypes.objectOf(PropTypes.any).isRequired,
180
+ onFocusPreviousBlock: PropTypes.func.isRequired,
181
+ onFocusNextBlock: PropTypes.func.isRequired,
182
+ onSelectBlock: PropTypes.func.isRequired,
301
183
  };
302
184
 
303
- export default Preloader;
185
+ export default connect(
186
+ (state, props) => {
187
+ const blockId = props.block;
188
+ return {
189
+ defaultSelection: blockId
190
+ ? state.slate_block_selections?.[blockId]
191
+ : null,
192
+ uploadRequest: state.upload_content?.[props.block]?.upload || {},
193
+ uploadedContent: state.upload_content?.[props.block]?.data || {},
194
+ };
195
+ },
196
+ {
197
+ uploadContent,
198
+ saveSlateBlockSelection, // needed as editor blockProps
199
+ },
200
+ )(TextEditorWidget);
@@ -1,7 +1,6 @@
1
1
  export {
2
2
  addSchemaField,
3
3
  templatesOptions,
4
- cloneBlock,
5
4
  } from 'design-comuni-plone-theme/config/Blocks/ListingOptions/utils';
6
5
  export addDefaultOptions from 'design-comuni-plone-theme/config/Blocks/ListingOptions/defaultOptions';
7
6
  export addDefaultAdditionalOptions from 'design-comuni-plone-theme/config/Blocks/ListingOptions/defaultAdditionalOptions';
@@ -1,5 +1,4 @@
1
1
  import { defineMessages } from 'react-intl';
2
- import { v4 as uuid } from 'uuid';
3
2
 
4
3
  const messages = defineMessages({
5
4
  show_icon: {
@@ -179,9 +178,3 @@ export const addLighthouseField = (schema, intl, position = 1) => {
179
178
 
180
179
  return pos;
181
180
  };
182
-
183
- export const cloneBlock = (blockData) => {
184
- const blockID = uuid();
185
- const clonedData = { ...blockData, block: blockID };
186
- return [blockID, clonedData];
187
- };
@@ -65,7 +65,11 @@ import countDownSVG from 'design-comuni-plone-theme/icons/count-down.svg';
65
65
  import CountDownBlockView from 'design-comuni-plone-theme/components/ItaliaTheme/Blocks/CountDown/View';
66
66
  import CountDownBlockEdit from 'design-comuni-plone-theme/components/ItaliaTheme/Blocks/CountDown/Edit';
67
67
 
68
- import { cloneBlock } from 'design-comuni-plone-theme/config/Blocks/ListingOptions';
68
+ import calloutSVG from '@plone/volto/icons/megaphone.svg';
69
+ import CalloutView from 'design-comuni-plone-theme/components/ItaliaTheme/Blocks/Callout/View';
70
+ import CalloutEdit from 'design-comuni-plone-theme/components/ItaliaTheme/Blocks/Callout/Edit';
71
+
72
+ import { cloneBlock } from 'design-comuni-plone-theme/helpers/blocks';
69
73
 
70
74
  const italiaBlocks = {
71
75
  highlitedContent: {
@@ -204,7 +208,6 @@ const italiaBlocks = {
204
208
  restricted: false,
205
209
  mostUsed: false,
206
210
  cloneData: cloneBlock,
207
- blockHasOwnFocusManagement: true,
208
211
  security: {
209
212
  addPermission: [],
210
213
  view: [],
@@ -222,7 +225,6 @@ const italiaBlocks = {
222
225
  restricted: false,
223
226
  mostUsed: false,
224
227
  cloneData: cloneBlock,
225
- blockHasOwnFocusManagement: true,
226
228
  security: {
227
229
  addPermission: [],
228
230
  view: [],
@@ -238,7 +240,6 @@ const italiaBlocks = {
238
240
  restricted: false,
239
241
  mostUsed: false,
240
242
  cloneData: cloneBlock,
241
- blockHasOwnFocusManagement: true,
242
243
  security: {
243
244
  addPermission: [],
244
245
  view: [],
@@ -277,6 +278,7 @@ const italiaBlocks = {
277
278
  view: [],
278
279
  },
279
280
  sidebarTab: 1,
281
+ blockHasOwnFocusManagement: true,
280
282
  },
281
283
  iconBlocks: {
282
284
  id: 'iconBlocks',
@@ -293,6 +295,7 @@ const italiaBlocks = {
293
295
  view: [],
294
296
  },
295
297
  sidebarTab: 1,
298
+ blockHasOwnFocusManagement: true,
296
299
  },
297
300
  contacts: {
298
301
  id: 'contacts',
@@ -309,6 +312,7 @@ const italiaBlocks = {
309
312
  view: [],
310
313
  },
311
314
  sidebarTab: 1,
315
+ blockHasOwnFocusManagement: true,
312
316
  },
313
317
 
314
318
  video_gallery: {
@@ -337,7 +341,6 @@ const italiaBlocks = {
337
341
  restricted: false,
338
342
  mostUsed: false,
339
343
  cloneData: cloneBlock,
340
- blockHasOwnFocusManagement: true,
341
344
  security: {
342
345
  addPermission: [],
343
346
  view: [],
@@ -359,15 +362,33 @@ const italiaBlocks = {
359
362
  view: [],
360
363
  },
361
364
  sidebarTab: 1,
365
+ blockHasOwnFocusManagement: true,
366
+ },
367
+ callout_block: {
368
+ id: 'callout_block',
369
+ title: 'Callout',
370
+ icon: calloutSVG,
371
+ group: 'text',
372
+ view: CalloutView,
373
+ edit: CalloutEdit,
374
+ restricted: false,
375
+ mostUsed: false,
376
+ cloneData: cloneBlock,
377
+ security: {
378
+ addPermission: [],
379
+ view: [],
380
+ },
381
+ sidebarTab: 1,
382
+ blockHasOwnFocusManagement: true,
362
383
  },
363
384
  };
364
385
 
365
386
  const getItaliaBlocks = (config) => {
366
387
  delete config.blocks.blocksConfig.teaser;
367
388
  config.blocks.blocksConfig.gridBlock.allowedBlocks =
368
- config.blocks.blocksConfig.gridBlock.allowedBlocks
369
- .filter((item) => !['slate', 'teaser'].includes(item))
370
- .concat(['text']);
389
+ config.blocks.blocksConfig.gridBlock.allowedBlocks.filter(
390
+ (item) => !['teaser'].includes(item),
391
+ );
371
392
  return italiaBlocks;
372
393
  };
373
394
  export default getItaliaBlocks;
@@ -66,8 +66,8 @@ import {
66
66
  addLinkMoreOptions,
67
67
  addSmallBlockLinksTemplateOptions,
68
68
  addAttachmentCardTemplateOptions,
69
- cloneBlock,
70
69
  } from 'design-comuni-plone-theme/config/Blocks/ListingOptions';
70
+ import { cloneBlock } from 'design-comuni-plone-theme/helpers/blocks';
71
71
 
72
72
  import { addLighthouseField } from 'design-comuni-plone-theme/config/Blocks/ListingOptions/utils';
73
73