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
@@ -5,9 +5,10 @@ import { defineMessages, useIntl } from 'react-intl';
5
5
  import PropTypes from 'prop-types';
6
6
  import { TextEditorWidget } from 'design-comuni-plone-theme/components/ItaliaTheme';
7
7
  import { UniversalLink } from '@plone/volto/components';
8
+ import { TextBlockView } from '@plone/volto-slate/blocks/Text';
9
+ import { useHandleDetachedBlockFocus } from 'design-comuni-plone-theme/helpers/blocks';
8
10
  import config from '@plone/volto/registry';
9
11
  import cx from 'classnames';
10
- import redraft from 'redraft';
11
12
 
12
13
  const messages = defineMessages({
13
14
  cta_title: {
@@ -24,36 +25,19 @@ const messages = defineMessages({
24
25
  },
25
26
  });
26
27
 
27
-
28
- const Block = ({
29
- data,
30
- block,
31
- inEditMode,
32
- onChangeBlock,
33
- onSelectBlock,
34
- onAddBlock,
35
- index,
36
- onFocusNextBlock,
37
- onFocusPreviousBlock,
38
- selected,
39
- }) => {
28
+ const Block = (props) => {
29
+ const { data, block, inEditMode, selected, ...otherProps } = props;
40
30
  const intl = useIntl();
41
31
  const Image = config.getComponent({ name: 'Image' }).component;
42
- const title = data?.cta_title?.blocks[0]?.text;
32
+ const title = data?.cta_title;
43
33
  const hasImage = data?.showImage && data?.ctaImage?.length > 0;
44
34
  const content = data?.cta_content;
45
35
  const showFullwidth = data?.showFullWidth;
46
36
 
47
- const [selectedField, setSelectedField] = useState('title');
48
- const titleRef = useRef();
49
- const contentRef = useRef();
50
- useEffect(() => {
51
- if (selected) {
52
- setSelectedField('title');
53
- } else {
54
- setSelectedField(null);
55
- }
56
- }, [selected]);
37
+ const { selectedField, setSelectedField } = useHandleDetachedBlockFocus(
38
+ props,
39
+ 'cta_title',
40
+ );
57
41
 
58
42
  return (
59
43
  <div
@@ -61,20 +45,6 @@ const Block = ({
61
45
  'has-image': hasImage,
62
46
  'full-width': showFullwidth,
63
47
  })}
64
- onKeyDown={(e) => {
65
- if (e.key === 'Enter' && !e.shiftKey) {
66
- if (
67
- !titleRef.current.contains(e.target) &&
68
- !contentRef.current.contains(e.target)
69
- ) {
70
- this.props.onAddBlock('text', index + 1);
71
- }
72
-
73
- if (titleRef.current.contains(e.target)) {
74
- setSelectedField('content');
75
- }
76
- }
77
- }}
78
48
  >
79
49
  {hasImage && data?.ctaImage?.length > 0 && (
80
50
  <figure className="img-wrapper">
@@ -94,70 +64,40 @@ const Block = ({
94
64
  <div className="cta-tile-text">
95
65
  <h2 className="title mt-0" id={block + 'title'}>
96
66
  {inEditMode ? (
97
- <div
98
- ref={titleRef}
99
- onClick={() => {
100
- setSelectedField('title');
101
- }}
102
- onFocus={() => {
103
- setSelectedField('title');
67
+ <TextEditorWidget
68
+ {...otherProps}
69
+ showToolbar={false}
70
+ data={data}
71
+ fieldName="cta_title"
72
+ selected={selectedField === 'cta_title'}
73
+ setSelected={setSelectedField}
74
+ block={block}
75
+ placeholder={intl.formatMessage(messages.cta_title)}
76
+ focusNextField={() => {
77
+ setSelectedField('cta_content');
104
78
  }}
105
- >
106
- <TextEditorWidget
107
- data={data}
108
- fieldName="cta_title"
109
- selected={selectedField === 'title'}
110
- block={block}
111
- onChangeBlock={(data) => onChangeBlock(block, data)}
112
- placeholder={intl.formatMessage(messages.cta_title)}
113
- showToolbar={false}
114
- onSelectBlock={() => {}}
115
- onAddBlock={() => {
116
- setSelectedField('content');
117
- }}
118
- onFocusNextBlock={() => {
119
- setSelectedField('content');
120
- }}
121
- onFocusPreviousBlock={onFocusPreviousBlock}
122
- />
123
- </div>
79
+ />
124
80
  ) : (
125
81
  title
126
82
  )}
127
83
  </h2>
84
+
128
85
  {inEditMode ? (
129
- <div
130
- ref={contentRef}
131
- onClick={() => {
132
- setSelectedField('content');
133
- }}
134
- onFocus={() => {
135
- setSelectedField('content');
86
+ <TextEditorWidget
87
+ {...otherProps}
88
+ showToolbar={true}
89
+ data={data}
90
+ fieldName="cta_content"
91
+ block={block}
92
+ selected={selectedField === 'cta_content'}
93
+ placeholder={intl.formatMessage(messages.cta_content)}
94
+ setSelected={setSelectedField}
95
+ focusPrevField={() => {
96
+ setSelectedField('cta_title');
136
97
  }}
137
- >
138
- <TextEditorWidget
139
- data={data}
140
- fieldName="cta_content"
141
- selected={selectedField === 'content'}
142
- block={block}
143
- onChangeBlock={(data) => onChangeBlock(block, data)}
144
- placeholder={intl.formatMessage(messages.cta_content)}
145
- showToolbar={true}
146
- onSelectBlock={onSelectBlock}
147
- onAddBlock={onAddBlock}
148
- index={index}
149
- onFocusNextBlock={onFocusNextBlock}
150
- onFocusPreviousBlock={() => {
151
- setSelectedField('title');
152
- }}
153
- />
154
- </div>
98
+ />
155
99
  ) : (
156
- redraft(
157
- content,
158
- config.settings.richtextViewSettings.ToHTMLRenderers,
159
- config.settings.richtextViewSettings.ToHTMLOptions,
160
- )
100
+ <TextBlockView data={{ value: content }} />
161
101
  )}
162
102
  {data.ctaLink?.length > 0 && data.ctaLinkTitle?.length > 0 && (
163
103
  <div className="mt-5">
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Edit Callout block.
3
+ * @module components/ItaliaTheme/Blocks/Callout/Edit
4
+ */
5
+
6
+ import React from 'react';
7
+ import PropTypes from 'prop-types';
8
+ import { defineMessages, useIntl } from 'react-intl';
9
+ import { SidebarPortal } from '@plone/volto/components';
10
+
11
+ import { Callout, CalloutTitle, CalloutText } from 'design-react-kit';
12
+ import { Icon } from 'design-comuni-plone-theme/components/ItaliaTheme';
13
+ import Sidebar from './Sidebar.jsx';
14
+ import { TextEditorWidget } from 'design-comuni-plone-theme/components/ItaliaTheme';
15
+ import { useHandleDetachedBlockFocus } from 'design-comuni-plone-theme/helpers/blocks';
16
+
17
+ const messages = defineMessages({
18
+ title: {
19
+ id: 'Type the title…',
20
+ defaultMessage: 'Type the title…',
21
+ },
22
+ text: {
23
+ id: 'Type text…',
24
+ defaultMessage: 'Digita il testo…',
25
+ },
26
+ });
27
+ /**
28
+ * Edit Calloout block class.
29
+ * @class Edit
30
+ * @extends Component
31
+ */
32
+ const Edit = (props) => {
33
+ const { data, onChangeBlock, block, onSelectBlock, selected, ...otherProps } =
34
+ props;
35
+ const intl = useIntl();
36
+ const { selectedField, setSelectedField } = useHandleDetachedBlockFocus(
37
+ props,
38
+ 'title',
39
+ );
40
+
41
+ return __SERVER__ ? (
42
+ <div />
43
+ ) : (
44
+ <div className="public-ui" id={block} tabIndex="-1" role="textbox">
45
+ <Callout
46
+ highlight={data.style === 'highlight'}
47
+ color={data.color?.replace('callout_', '')}
48
+ >
49
+ <CalloutTitle tag="h4">
50
+ {data.icon && <Icon icon={data.icon} padding={false} aria-hidden />}
51
+
52
+ <div className="text">
53
+ <TextEditorWidget
54
+ {...otherProps}
55
+ showToolbar={false}
56
+ data={data}
57
+ block={block}
58
+ fieldName="title"
59
+ onChangeBlock={onChangeBlock}
60
+ selected={selectedField === 'title'}
61
+ placeholder={intl.formatMessage(messages.title)}
62
+ setSelected={setSelectedField}
63
+ focusNextField={() => {
64
+ setSelectedField('text');
65
+ }}
66
+ onSelectBlock={onSelectBlock}
67
+ />
68
+ </div>
69
+ </CalloutTitle>
70
+ <CalloutText>
71
+ <TextEditorWidget
72
+ {...otherProps}
73
+ data={data}
74
+ fieldName="text"
75
+ block={block}
76
+ onSelectBlock={onSelectBlock}
77
+ selected={selectedField === 'text'}
78
+ placeholder={intl.formatMessage(messages.text)}
79
+ onChangeBlock={onChangeBlock}
80
+ setSelected={setSelectedField}
81
+ focusPrevField={() => {
82
+ setSelectedField('title');
83
+ }}
84
+ />
85
+ </CalloutText>
86
+ </Callout>
87
+
88
+ <SidebarPortal selected={selected || false}>
89
+ <Sidebar data={data} block={block} onChangeBlock={onChangeBlock} />
90
+ </SidebarPortal>
91
+ </div>
92
+ );
93
+ };
94
+
95
+ Edit.propTypes = {
96
+ properties: PropTypes.objectOf(PropTypes.any).isRequired,
97
+ selected: PropTypes.bool.isRequired,
98
+ index: PropTypes.number.isRequired,
99
+ onChangeField: PropTypes.func.isRequired,
100
+ onSelectBlock: PropTypes.func.isRequired,
101
+ onDeleteBlock: PropTypes.func.isRequired,
102
+ onAddBlock: PropTypes.func.isRequired,
103
+ onFocusPreviousBlock: PropTypes.func.isRequired,
104
+ onFocusNextBlock: PropTypes.func.isRequired,
105
+ block: PropTypes.string.isRequired,
106
+ };
107
+
108
+ export default Edit;
@@ -0,0 +1,173 @@
1
+ import React, { useEffect } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { Segment } from 'semantic-ui-react';
4
+ import { FormattedMessage, injectIntl } from 'react-intl';
5
+ import { /*TextWidget,*/ SelectWidget } from '@plone/volto/components';
6
+ import { injectLazyLibs } from '@plone/volto/helpers/Loadable/Loadable';
7
+ import { defineMessages, useIntl } from 'react-intl';
8
+ import { ColorListWidget } from 'design-comuni-plone-theme/components/ItaliaTheme';
9
+ import { Icon } from 'design-comuni-plone-theme/components/ItaliaTheme';
10
+ import { FormFieldWrapper } from '@plone/volto/components';
11
+
12
+ const messages = defineMessages({
13
+ color: { id: 'color', defaultMessage: 'Colore' },
14
+ color_default: {
15
+ id: 'color_default',
16
+ defaultMessage: 'Default',
17
+ },
18
+ color_success: {
19
+ id: 'color_success',
20
+ defaultMessage: 'Success',
21
+ },
22
+ color_warning: {
23
+ id: 'color_warning',
24
+ defaultMessage: 'Warning',
25
+ },
26
+ color_danger: {
27
+ id: 'color_danger',
28
+ defaultMessage: 'Danger',
29
+ },
30
+ color_note: {
31
+ id: 'color_note',
32
+ defaultMessage: 'Note',
33
+ },
34
+ style: { id: 'callout_style', defaultMessage: 'Stile' },
35
+ style_basic: { id: 'callout_style_basic', defaultMessage: 'Base' },
36
+ style_highlight: {
37
+ id: 'callout_style_highlight',
38
+ defaultMessage: 'In evidenza',
39
+ },
40
+ icon: {
41
+ id: 'icon',
42
+ defaultMessage: 'Icona',
43
+ },
44
+ });
45
+
46
+ const Sidebar = ({ data, block, onChangeBlock, reactSelect }) => {
47
+ const intl = useIntl();
48
+ const { Option } = reactSelect.components;
49
+ const colors = [
50
+ {
51
+ name: 'callout_default',
52
+ label: intl.formatMessage(messages.color_default),
53
+ },
54
+ { name: 'success', label: intl.formatMessage(messages.color_success) },
55
+ { name: 'warning', label: intl.formatMessage(messages.color_warning) },
56
+ { name: 'danger', label: intl.formatMessage(messages.color_danger) },
57
+ { name: 'callout_note', label: intl.formatMessage(messages.color_note) },
58
+ ];
59
+
60
+ const styles = [
61
+ ['base', intl.formatMessage(messages.style_basic)],
62
+ ['highlight', intl.formatMessage(messages.style_highlight)],
63
+ ];
64
+
65
+ useEffect(() => {
66
+ if (!data.style) {
67
+ //default nuovo blocco
68
+ onChangeBlock(block, {
69
+ ...data,
70
+ style: styles[0][0],
71
+ icon: 'it-info-circle',
72
+ });
73
+ }
74
+ }, []);
75
+
76
+ return (
77
+ <Segment.Group raised>
78
+ <header className="header pulled">
79
+ <h2>
80
+ <FormattedMessage id="Callout" defaultMessage="Callout" />
81
+ </h2>
82
+ </header>
83
+ <div className="ui form">
84
+ <SelectWidget
85
+ id="style"
86
+ title={intl.formatMessage(messages.style)}
87
+ required={false}
88
+ value={data.style}
89
+ intl={intl}
90
+ onChange={(id, value) => {
91
+ onChangeBlock(block, { ...data, [id]: value });
92
+ }}
93
+ choices={styles}
94
+ noValueOption={false}
95
+ />
96
+ <ColorListWidget
97
+ id="color"
98
+ title={intl.formatMessage(messages.color)}
99
+ value={data.color}
100
+ onChange={(id, value) => {
101
+ onChangeBlock(block, {
102
+ ...data,
103
+ [id]: value,
104
+ });
105
+ }}
106
+ colors={colors}
107
+ />
108
+
109
+ <div className="select-icon-widget">
110
+ <SelectWidget
111
+ id="icon"
112
+ title={intl.formatMessage(messages.icon)}
113
+ required={false}
114
+ value={data.icon}
115
+ intl={intl}
116
+ onChange={(id, value) => {
117
+ onChangeBlock(block, { ...data, [id]: value });
118
+ }}
119
+ choices={[
120
+ ['it-info-circle', 'Info'],
121
+ ['it-check-circle', 'Check'],
122
+ ['it-help-circle', 'Help'],
123
+ ['it-close-circle', 'Close'],
124
+ ]}
125
+ customOptionStyling={(props) => {
126
+ return (
127
+ <Option {...props}>
128
+ {props.data.value !== 'no-value' && (
129
+ <span className="icon-container italia-icon">
130
+ <Icon icon={props.data.value} />
131
+ </span>
132
+ )}
133
+ <span className="label-container">{props.data.label}</span>
134
+ </Option>
135
+ );
136
+ }}
137
+ />
138
+
139
+ <FormFieldWrapper id="icon-preview-widget-id" title="">
140
+ <p className="help">
141
+ {data.icon ? (
142
+ <Icon icon={data.icon} className="show-icon-italia" />
143
+ ) : (
144
+ <></>
145
+ )}
146
+ </p>
147
+ </FormFieldWrapper>
148
+ </div>
149
+ {/* <TextWidget
150
+ id="title"
151
+ title={intl.formatMessage(messages.linkMoreTitle)}
152
+ value={data.linkMoreTitle}
153
+ onChange={(name, value) => {
154
+ onChangeBlock(block, {
155
+ ...data,
156
+ linkMoreTitle: value,
157
+ });
158
+ }}
159
+ /> */}
160
+ </div>
161
+ </Segment.Group>
162
+ );
163
+ };
164
+
165
+ Sidebar.propTypes = {
166
+ data: PropTypes.objectOf(PropTypes.any),
167
+ block: PropTypes.string,
168
+ onChangeBlock: PropTypes.func,
169
+ selected: PropTypes.any,
170
+ setSelected: PropTypes.func,
171
+ };
172
+
173
+ export default injectLazyLibs('reactSelect')(injectIntl(Sidebar));
@@ -0,0 +1,45 @@
1
+ /**
2
+ * View Callout block.
3
+ * @module components/ItaliaTheme/Blocks/Callout/View
4
+ */
5
+
6
+ import React from 'react';
7
+ import PropTypes from 'prop-types';
8
+
9
+ import { Callout, CalloutTitle, CalloutText } from 'design-react-kit';
10
+ import { Icon } from 'design-comuni-plone-theme/components/ItaliaTheme';
11
+ import { TextBlockView } from '@plone/volto-slate/blocks/Text';
12
+ /**
13
+ * View Callout block class.
14
+ * @class CalloutView
15
+ * @extends Component
16
+ */
17
+
18
+ const View = ({ data, id }) => {
19
+ return (
20
+ <div className="block callout_block" id={id}>
21
+ <Callout
22
+ highlight={data.style === 'highlight'}
23
+ color={data.color?.replace('callout_', '')}
24
+ >
25
+ <CalloutTitle>
26
+ {data.icon && <Icon icon={data.icon} padding={false} aria-hidden />}
27
+ <span className="text">{data.title}</span>
28
+ </CalloutTitle>
29
+ <CalloutText>
30
+ <TextBlockView id={id} data={{ value: data.text }} />
31
+ </CalloutText>
32
+ </Callout>
33
+ </div>
34
+ );
35
+ };
36
+ /**
37
+ * Property types.
38
+ * @property {Object} propTypes Property types.
39
+ * @static
40
+ */
41
+ View.propTypes = {
42
+ data: PropTypes.objectOf(PropTypes.any).isRequired,
43
+ };
44
+
45
+ export default View;