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
@@ -0,0 +1,243 @@
1
+ import { Node, Editor } from 'slate';
2
+ import {
3
+ goDown,
4
+ goUp,
5
+ softBreak,
6
+ unwrapEmptyString,
7
+ } from '@plone/volto-slate/blocks/Text/keyboard';
8
+
9
+ import {
10
+ isCursorAtBlockStart,
11
+ isCursorAtBlockEnd,
12
+ getNextVoltoBlock,
13
+ getPreviousVoltoBlock,
14
+ createDefaultBlock,
15
+ getCurrentListItem,
16
+ } from '@plone/volto-slate/utils';
17
+ import config from '@plone/volto/registry';
18
+
19
+ const focusPrev = (props) => {
20
+ const getBlockProps = props.editor.getBlockProps;
21
+ const {
22
+ focusPrevField,
23
+ showToolbar,
24
+ onFocusPreviousBlock,
25
+ block,
26
+ blockNode,
27
+ properties,
28
+ index,
29
+ saveSlateBlockSelection,
30
+ } = getBlockProps
31
+ ? getBlockProps()
32
+ : {
33
+ focusPrevField: null,
34
+ showToolbar: true,
35
+ onFocusPreviousBlock: null,
36
+ block: null,
37
+ blockNode: null,
38
+ properties: null,
39
+ index: null,
40
+ saveSlateBlockSelection: null,
41
+ };
42
+
43
+ let isAtStart = false;
44
+
45
+ if (showToolbar) {
46
+ isAtStart = isCursorAtBlockStart(props.editor);
47
+ } else {
48
+ let _range = document.getSelection().getRangeAt(0);
49
+ let range = _range.cloneRange();
50
+ range.selectNodeContents(props.event.target);
51
+ range.setEnd(_range.endContainer, _range.endOffset);
52
+ isAtStart = range.toString().length === 0;
53
+ //isAtStart = props.event.target.selectionStart === 0;
54
+ }
55
+
56
+ if (isAtStart) {
57
+ //move to prev field
58
+ if (focusPrevField) {
59
+ props.event.stopPropagation();
60
+ return focusPrevField();
61
+ }
62
+
63
+ //handle SimpleTextEditorWidget -> move to prev block
64
+ if (!showToolbar && onFocusPreviousBlock) {
65
+ const prev = getPreviousVoltoBlock(index, properties);
66
+ if (!prev || prev[0]?.['@type'] !== 'slate')
67
+ return onFocusPreviousBlock(block, blockNode.current);
68
+ const [slateBlock, id] = prev;
69
+ const pseudoEditor = {
70
+ children: slateBlock.value || [createDefaultBlock()],
71
+ };
72
+ const match = Node.last(pseudoEditor, []);
73
+ if (!match) return onFocusPreviousBlock(block, blockNode.current);
74
+
75
+ const [node, path] = match;
76
+ const point = { path, offset: (node?.text || '').length };
77
+ const selection = { anchor: point, focus: point };
78
+ saveSlateBlockSelection(id, selection);
79
+ return onFocusPreviousBlock(block, blockNode.current);
80
+ }
81
+ }
82
+
83
+ //handle SlateEditor arrow-up key
84
+ return goUp(props);
85
+ };
86
+
87
+ const goToNextVoltoBlock = (props) => {
88
+ const {
89
+ onFocusNextBlock,
90
+ block,
91
+ blockNode,
92
+ properties,
93
+ index,
94
+ saveSlateBlockSelection,
95
+ } = props.editor.getBlockProps();
96
+
97
+ const next = getNextVoltoBlock(index, properties);
98
+ if (!next || next[0]?.['@type'] !== 'slate')
99
+ return onFocusNextBlock(block, blockNode.current);
100
+
101
+ const [slateBlock, id] = next;
102
+ const pseudoEditor = {
103
+ children: slateBlock.value || [createDefaultBlock()],
104
+ };
105
+ const match = Node.last(pseudoEditor, []);
106
+ if (!match) return onFocusNextBlock(block, blockNode.current);
107
+
108
+ const path = match[1];
109
+ const point = { path, offset: 0 };
110
+ const selection = { anchor: point, focus: point };
111
+ saveSlateBlockSelection(id, selection);
112
+ return onFocusNextBlock(block, blockNode.current);
113
+ };
114
+ const focusNext = (props) => {
115
+ const getBlockProps = props.editor.getBlockProps;
116
+ const {
117
+ focusNextField,
118
+ showToolbar,
119
+ onFocusNextBlock,
120
+ onSelectBlock,
121
+ onAddBlock,
122
+ index,
123
+ } = getBlockProps
124
+ ? getBlockProps()
125
+ : {
126
+ showToolbar: true,
127
+ focusNextField: null,
128
+ onFocusNextBlock: null,
129
+ onSelectBlock: null,
130
+ onAddBlock: null,
131
+ };
132
+
133
+ if (showToolbar) {
134
+ const [listItem] = getCurrentListItem(props.editor);
135
+ if (listItem) {
136
+ //managed by breaklist extension
137
+ return true;
138
+ }
139
+ }
140
+
141
+ props.event.preventDefault();
142
+ props.event.stopPropagation();
143
+ let isAtEnd = false;
144
+
145
+ if (showToolbar) {
146
+ isAtEnd = isCursorAtBlockEnd(props.editor);
147
+ } else {
148
+ let selection = document.getSelection();
149
+
150
+ if (selection && selection.rangeCount > 0) {
151
+ const _range = selection.getRangeAt(0);
152
+ let range = _range.cloneRange();
153
+ range.selectNodeContents(props.event.target);
154
+ range.setEnd(_range.endContainer, _range.endOffset);
155
+ isAtEnd =
156
+ range.toString().length === props.event.target.innerText?.length;
157
+ // isAtEnd =
158
+ // props.event.target.selectionEnd === props.event.target.value?.length;
159
+ }
160
+ }
161
+
162
+ //move to next field
163
+ if (focusNextField) {
164
+ focusNextField();
165
+ return false;
166
+ }
167
+
168
+ if (isAtEnd) {
169
+ if (props.event.key === 'Enter' || props.event.keyCode === 13) {
170
+ onSelectBlock(onAddBlock(config.settings.defaultBlockType, index + 1));
171
+ return false;
172
+ } else {
173
+ //arrow-down key
174
+ //handle SimpleTextEditorWidget -> move to next block
175
+ if (!showToolbar && onFocusNextBlock) {
176
+ return goToNextVoltoBlock(props);
177
+ }
178
+ }
179
+ }
180
+
181
+ //handle SlateEditor arrow-down key
182
+ return goDown(props);
183
+ };
184
+
185
+ const breakInSimpleTextEditor = (props) => {
186
+ //disable break and softBreak (props.event.shiftKey) in SimpleTextEditorWidget
187
+ const getBlockProps = props.editor.getBlockProps;
188
+ const { showToolbar, focusNextField } = getBlockProps
189
+ ? getBlockProps()
190
+ : { showToolbar: true };
191
+ if (props.event.key === 'Enter' && !showToolbar) {
192
+ props.event.preventDefault();
193
+ if (focusNextField) {
194
+ focusNextField();
195
+ return false;
196
+ }
197
+ goToNextVoltoBlock(props);
198
+ return false;
199
+ }
200
+
201
+ return true;
202
+ };
203
+
204
+ const handleBreak = (props) => {
205
+ const getBlockProps = props.editor.getBlockProps;
206
+ const { showToolbar } = getBlockProps
207
+ ? getBlockProps()
208
+ : { showToolbar: true };
209
+
210
+ if (!showToolbar) {
211
+ return breakInSimpleTextEditor(props);
212
+ } else {
213
+ let ret = softBreak(props);
214
+ if (!ret) {
215
+ const [listItem] = props.editor.selection
216
+ ? getCurrentListItem(props.editor)
217
+ : [];
218
+ if (listItem) {
219
+ //managed by breaklist extension
220
+ } else {
221
+ props.event.preventDefault();
222
+ props.event.stopPropagation();
223
+ Editor.insertNode(props.editor, {
224
+ type: 'paragraph',
225
+ children: [{ text: '' }],
226
+ });
227
+ ret = true;
228
+ }
229
+ }
230
+ return ret;
231
+ }
232
+ };
233
+
234
+ export default function install(config) {
235
+ config.settings.slate.textblockDetachedKeyboardHandlers = {
236
+ ...config.settings.slate.textblockDetachedKeyboardHandlers,
237
+ Enter: [unwrapEmptyString, handleBreak, focusNext],
238
+ ArrowUp: [focusPrev],
239
+ ArrowDown: [focusNext],
240
+ };
241
+
242
+ return config;
243
+ }
@@ -0,0 +1,73 @@
1
+ import { makeEditor } from '@plone/volto-slate/utils';
2
+ import deserialize from '@plone/volto-slate/editor/deserialize';
3
+ import {
4
+ createEmptyParagraph,
5
+ normalizeExternalData,
6
+ } from '@plone/volto-slate/utils';
7
+
8
+ export const insertToolbarButtons = (buttons = [], insertAfter = '', slate) => {
9
+ const insertAtToolbarButtons = slate.toolbarButtons.indexOf(insertAfter) + 1;
10
+ slate.toolbarButtons = [
11
+ ...slate.toolbarButtons.slice(0, insertAtToolbarButtons),
12
+ ...buttons,
13
+ ...slate.toolbarButtons.slice(insertAtToolbarButtons),
14
+ ].filter((el, index, array) => {
15
+ if (index > 0) {
16
+ //rimuovo i separatori consecutivi nel caso se ne siano creati
17
+ if (el === 'separator' && array[index - 1] === 'separator') return false;
18
+ }
19
+ return true;
20
+ });
21
+
22
+ const insertAtExpandedToolbarButtons =
23
+ slate.toolbarButtons.indexOf(insertAfter) + 1;
24
+ slate.expandedToolbarButtons = [
25
+ ...slate.expandedToolbarButtons.slice(0, insertAtExpandedToolbarButtons),
26
+ ...buttons,
27
+ ...slate.expandedToolbarButtons.slice(insertAtExpandedToolbarButtons),
28
+ ].filter((el, index, array) => {
29
+ if (index > 0) {
30
+ //rimuovo i separatori consecutivi nel caso se ne siano creati
31
+ if (el === 'separator' && array[index - 1] === 'separator') return false;
32
+ }
33
+ return true;
34
+ });
35
+
36
+ //rimuovo doppi separator
37
+ };
38
+
39
+ export const getRichTextWidgetToolbarButtons = (config) => {
40
+ const EXCLUDE_TOOLBAR_BUTTONS = ['textLarger', 'headings'];
41
+
42
+ let toolbarButtons = (config.settings.slate?.toolbarButtons ?? [])
43
+ .filter((b) => EXCLUDE_TOOLBAR_BUTTONS.indexOf(b) < 0)
44
+ .filter(
45
+ (e, index, array) =>
46
+ !(
47
+ e === 'separator' &&
48
+ (index === 0 || array[index - 1] === 'separator')
49
+ ), //rimuovi i separatori consecutivi e il primo elemento se è un separatore
50
+ );
51
+
52
+ return toolbarButtons;
53
+ };
54
+
55
+ export const fromHtml = (value) => {
56
+ const editor = makeEditor();
57
+ const html = value?.data || '';
58
+
59
+ const parsed = new DOMParser().parseFromString(html, 'text/html');
60
+ const body =
61
+ parsed.getElementsByTagName('google-sheets-html-origin').length > 0
62
+ ? parsed.querySelector('google-sheets-html-origin > table')
63
+ : parsed.body;
64
+ let data = deserialize(editor, body, { collapseWhitespace: false });
65
+ data = normalizeExternalData(editor, data);
66
+
67
+ // editor.children = data;
68
+ // Editor.normalize(editor);
69
+ // TODO: need to add {text: ""} placeholders between elements
70
+ const res = data.length ? data : [createEmptyParagraph()];
71
+ // console.log('from html', { html: value?.data, res });
72
+ return res;
73
+ };
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import CharCounterTextareaWidget from 'design-comuni-plone-theme/components/ItaliaTheme/manage/Widgets/CharCounterTextareaWidget';
3
3
  import CharCounterTextWidget from 'design-comuni-plone-theme/components/ItaliaTheme/manage/Widgets/CharCounterTextWidget';
4
4
  import { DatetimeWidget } from '@plone/volto/config/Widgets';
5
- import { ArrayWidget, WysiwygWidget } from '@plone/volto/components';
5
+ import { ArrayWidget } from '@plone/volto/components';
6
6
  import { MultilingualWidget } from 'volto-multilingual-widget';
7
7
  import IconWidget from 'design-comuni-plone-theme/components/ItaliaTheme/manage/Widgets/IconWidget';
8
8
  import SubsiteSocialLinksWidget from 'design-comuni-plone-theme/components/ItaliaTheme/manage/Widgets/SubsiteSocialLinksWidget';
@@ -83,7 +83,6 @@ const getItaliaWidgets = (config) => {
83
83
  },
84
84
  widget: {
85
85
  ...config.widgets.widget,
86
- richtext: WysiwygWidget,
87
86
  color_list: ColorListWidget,
88
87
  path_filters: PathFiltersWidget,
89
88
  location_filter: LocationFiltersWidget,
@@ -34,7 +34,6 @@ import HandleAnchor from 'design-comuni-plone-theme/components/ItaliaTheme/AppEx
34
34
  import GenericAppExtras from 'design-comuni-plone-theme/components/ItaliaTheme/AppExtras/GenericAppExtras';
35
35
  import PageLoader from 'design-comuni-plone-theme/components/ItaliaTheme/AppExtras/PageLoader';
36
36
  import TrackFocus from 'design-comuni-plone-theme/components/ItaliaTheme/AppExtras/TrackFocus';
37
- import redraft from 'redraft';
38
37
  import { loadables as ItaliaLoadables } from 'design-comuni-plone-theme/config/loadables';
39
38
 
40
39
  // CTs icons
@@ -58,16 +57,14 @@ import faQuestionSVG from 'design-comuni-plone-theme/icons/question-solid.svg';
58
57
  import bandoSVG from 'design-comuni-plone-theme/icons/bando.svg';
59
58
  import logSVG from 'design-comuni-plone-theme/icons/log.svg';
60
59
 
61
- import applyRichTextConfig from 'design-comuni-plone-theme/config/RichTextEditor/config';
62
-
63
- import gdprPrivacyPanelConfig from 'design-comuni-plone-theme/config/volto-gdpr-privacy-defaultPanelConfig.js';
60
+ import applyItaliaSlateConfig from 'design-comuni-plone-theme/config/Slate/config';
64
61
 
65
62
  import { schemaListing } from 'design-comuni-plone-theme/components/ItaliaTheme/Blocks/Listing/schema.js';
66
63
 
67
64
  import reducers from 'design-comuni-plone-theme/reducers';
68
65
 
69
- const ReleaseLog = loadable(() =>
70
- import('design-comuni-plone-theme/components/ReleaseLog/ReleaseLog'),
66
+ const ReleaseLog = loadable(
67
+ () => import('design-comuni-plone-theme/components/ReleaseLog/ReleaseLog'),
71
68
  );
72
69
 
73
70
  const messages = defineMessages({
@@ -78,7 +75,7 @@ const messages = defineMessages({
78
75
  });
79
76
 
80
77
  export default function applyConfig(voltoConfig) {
81
- let config = applyRichTextConfig(voltoConfig);
78
+ let config = applyItaliaSlateConfig(voltoConfig);
82
79
 
83
80
  /******************************************************************************
84
81
  * SETTINGS
@@ -191,7 +188,7 @@ export default function applyConfig(voltoConfig) {
191
188
  'social-settings': shareSVG,
192
189
  'release-log': logSVG,
193
190
  },
194
- defaultBlockType: 'text',
191
+ //defaultBlockType: 'text',
195
192
  defaultExcludedFromSearch: {
196
193
  portalTypes: ['Image', 'File'],
197
194
  },
@@ -308,6 +305,7 @@ export default function applyConfig(voltoConfig) {
308
305
  'break',
309
306
  'testo_riquadro_semplice',
310
307
  'testo_riquadro_immagine',
308
+ 'callout_block',
311
309
  'rssBlock',
312
310
  //se si aggiunge un nuovo blocco, verificare che in edit non ci siano bottoni che provocano il submit della form. Se succede, gestirli con e.prevenDefault() e.stopPropagation().
313
311
  ],
@@ -315,11 +313,6 @@ export default function applyConfig(voltoConfig) {
315
313
  showRestricted: false,
316
314
  },
317
315
 
318
- 'volto-gdpr-privacy': {
319
- ...config.settings['volto-gdpr-privacy'],
320
- defaultPanelConfig: gdprPrivacyPanelConfig,
321
- },
322
-
323
316
  'volto-editablefooter': {
324
317
  ...config.settings['volto-editablefooter'],
325
318
  options: { socials: true, newsletterSubscribe: true },
@@ -410,6 +403,7 @@ export default function applyConfig(voltoConfig) {
410
403
  },
411
404
  hero: {
412
405
  ...config.blocks.blocksConfig.hero,
406
+ hasOwnFocusManagement: true,
413
407
  sidebarTab: 1,
414
408
  },
415
409
  html: {
@@ -417,22 +411,6 @@ export default function applyConfig(voltoConfig) {
417
411
  sidebarTab: 1,
418
412
  },
419
413
  rssBlock,
420
- text: {
421
- ...config.blocks.blocksConfig.text,
422
- restricted: false,
423
- },
424
- slate: {
425
- ...config.blocks.blocksConfig.slate,
426
- restricted: true,
427
- },
428
- table: {
429
- ...config.blocks.blocksConfig.table,
430
- restricted: false,
431
- },
432
- slateTable: {
433
- ...config.blocks.blocksConfig.slateTable,
434
- restricted: true,
435
- },
436
414
  maps: {
437
415
  ...config.blocks.blocksConfig.maps,
438
416
  restricted: true,
@@ -480,31 +458,6 @@ export default function applyConfig(voltoConfig) {
480
458
  // comment out the following line and add the leadimage behavior in Document.xml file
481
459
  delete config.blocks.blocksConfig['leadimage'];
482
460
 
483
- // TOC block anchors not working, customizing tocEntry
484
- // to also return draftJS block id
485
- config.settings.slate = {
486
- ...(config.settings.slate ?? {}),
487
- topLevelTargetElements: ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'],
488
- };
489
- config.blocks.blocksConfig.text = {
490
- ...config.blocks.blocksConfig.text,
491
- tocEntry: (block = {}) => {
492
- const draft = redraft(
493
- block.text,
494
- config.settings.richtextViewSettings.ToHTMLRenderers,
495
- config.settings.richtextViewSettings.ToHTMLOptions,
496
- );
497
- const type = draft?.[0]?.[0]?.type;
498
-
499
- return config.settings.slate.topLevelTargetElements.includes(type)
500
- ? [
501
- parseInt(type.slice(1)),
502
- block.text.blocks[0].text,
503
- block.text.blocks[0].key,
504
- ]
505
- : null;
506
- },
507
- };
508
461
  // Remove Horizontal Menu variation of TOC Block
509
462
  config.blocks.blocksConfig.toc.variations =
510
463
  config.blocks.blocksConfig.toc.variations.filter(