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.
- package/.github/workflows/main.yml +16 -16
- package/.github/workflows/npm.yml +1 -1
- package/.github/workflows/withnewsletter.yml +47 -0
- package/.release-it.json +1 -0
- package/.yarn/cache/@babel-helper-module-imports-npm-7.24.3-edb733448b-c23492189b.zip +0 -0
- package/.yarn/cache/@babel-types-npm-7.24.0-a0508cb308-4b574a37d4.zip +0 -0
- package/.yarn/cache/babel-plugin-lodash-npm-3.3.4-c7161075b6-044a4261e6.zip +0 -0
- package/.yarn/cache/braces-npm-3.0.3-582c14023c-b95aa0b3bd.zip +0 -0
- package/.yarn/cache/fill-range-npm-7.1.1-bf491486db-b4abfbca38.zip +0 -0
- package/.yarn/cache/micromatch-npm-4.0.8-c9570e4aca-79920eb634.zip +0 -0
- package/.yarn/cache/require-package-name-npm-2.0.1-ac9a206b63-00f4e9e467.zip +0 -0
- package/.yarn/install-state.gz +0 -0
- package/CHANGELOG.md +1728 -1659
- package/RELEASE.md +6 -0
- package/locales/de/LC_MESSAGES/volto.po +86 -19
- package/locales/en/LC_MESSAGES/volto.po +86 -19
- package/locales/es/LC_MESSAGES/volto.po +86 -19
- package/locales/fr/LC_MESSAGES/volto.po +86 -19
- package/locales/it/LC_MESSAGES/volto.po +87 -20
- package/locales/volto.pot +87 -20
- package/package.json +3 -1
- package/publiccode.yml +2 -2
- package/src/components/Collapse.jsx +1 -0
- package/src/components/ItaliaTheme/AppExtras/SiteSettingsExtras.jsx +0 -6
- package/src/components/ItaliaTheme/Blocks/Accordion/Block/EditBlock.jsx +29 -24
- package/src/components/ItaliaTheme/Blocks/Accordion/Block/ViewBlock.jsx +4 -12
- package/src/components/ItaliaTheme/Blocks/Accordion/Edit.jsx +118 -42
- package/src/components/ItaliaTheme/Blocks/Accordion/View.jsx +4 -18
- package/src/components/ItaliaTheme/Blocks/Alert/Edit.jsx +60 -113
- package/src/components/ItaliaTheme/Blocks/Alert/Sidebar.jsx +1 -0
- package/src/components/ItaliaTheme/Blocks/Alert/View.jsx +5 -14
- package/src/components/ItaliaTheme/Blocks/ArgumentsInEvidence/Block.jsx +16 -11
- package/src/components/ItaliaTheme/Blocks/ArgumentsInEvidence/Body.jsx +2 -1
- package/src/components/ItaliaTheme/Blocks/ArgumentsInEvidence/Edit.jsx +39 -1
- package/src/components/ItaliaTheme/Blocks/CTABlock/Block.jsx +35 -95
- package/src/components/ItaliaTheme/Blocks/Callout/Edit.jsx +108 -0
- package/src/components/ItaliaTheme/Blocks/Callout/Sidebar.jsx +173 -0
- package/src/components/ItaliaTheme/Blocks/Callout/View.jsx +45 -0
- package/src/components/ItaliaTheme/Blocks/ContactsBlock/Block/EditBlock.jsx +86 -63
- package/src/components/ItaliaTheme/Blocks/ContactsBlock/Block/ViewBlock.jsx +19 -39
- package/src/components/ItaliaTheme/Blocks/ContactsBlock/Edit.jsx +101 -22
- package/src/components/ItaliaTheme/Blocks/ContactsBlock/View.jsx +13 -21
- package/src/components/ItaliaTheme/Blocks/CountDown/Edit.jsx +21 -25
- package/src/components/ItaliaTheme/Blocks/CountDown/View.jsx +6 -15
- package/src/components/ItaliaTheme/Blocks/IconBlocks/Block/EditBlock.jsx +52 -22
- package/src/components/ItaliaTheme/Blocks/IconBlocks/Block/ViewBlock.jsx +9 -29
- package/src/components/ItaliaTheme/Blocks/IconBlocks/Edit.jsx +108 -21
- package/src/components/ItaliaTheme/Blocks/IconBlocks/Sidebar.jsx +1 -9
- package/src/components/ItaliaTheme/Blocks/IconBlocks/View.jsx +6 -14
- package/src/components/ItaliaTheme/Blocks/Listing/CardWithSlideUpTextTemplate.jsx +0 -1
- package/src/components/ItaliaTheme/Blocks/NumbersBlock/Block/EditBlock.jsx +45 -15
- package/src/components/ItaliaTheme/Blocks/NumbersBlock/Block/ViewBlock.jsx +2 -18
- package/src/components/ItaliaTheme/Blocks/NumbersBlock/Edit.jsx +98 -11
- package/src/components/ItaliaTheme/Blocks/NumbersBlock/View.jsx +2 -7
- package/src/components/ItaliaTheme/Blocks/TextCard/CardWithImage/Block.jsx +35 -67
- package/src/components/ItaliaTheme/Blocks/TextCard/CardWithImage/Edit.jsx +2 -8
- package/src/components/ItaliaTheme/Blocks/TextCard/SimpleCard/BodyWrapper.jsx +2 -1
- package/src/components/ItaliaTheme/Blocks/TextCard/SimpleCard/Edit.jsx +98 -84
- package/src/components/ItaliaTheme/Blocks/TextCard/SimpleCard/View.jsx +20 -3
- package/src/components/ItaliaTheme/Blocks/UOSearch/Sidebar.jsx +11 -11
- package/src/components/ItaliaTheme/Blocks/__tests__/Accordion.test.jsx +11 -28
- package/src/components/ItaliaTheme/Blocks/__tests__/Alert.test.jsx +10 -14
- package/src/components/ItaliaTheme/Blocks/__tests__/ArgumentsInEvidence.test.jsx +20 -28
- package/src/components/ItaliaTheme/Blocks/__tests__/CTABlock.test.jsx +14 -29
- package/src/components/ItaliaTheme/Blocks/__tests__/CardWithImage.test.jsx +11 -28
- package/src/components/ItaliaTheme/Blocks/__tests__/ContactsBlock.test.jsx +75 -140
- package/src/components/ItaliaTheme/Blocks/__tests__/Countdown.test.jsx +20 -28
- package/src/components/ItaliaTheme/Blocks/__tests__/IconBlocks.test.jsx +22 -56
- package/src/components/ItaliaTheme/Blocks/__tests__/NumbersBlock.test.jsx +14 -43
- package/src/components/ItaliaTheme/Blocks/__tests__/SimpleCard.test.jsx +14 -30
- package/src/components/ItaliaTheme/BrandText/BrandText.jsx +8 -14
- package/src/components/ItaliaTheme/BrandTextFooter/BrandTextFooter.jsx +31 -2
- package/src/components/ItaliaTheme/Footer/FooterInfos.jsx +21 -8
- package/src/components/ItaliaTheme/Footer/FooterNavigation.jsx +3 -3
- package/src/components/ItaliaTheme/Header/HeaderSlim/HeaderSlim.jsx +0 -7
- package/src/components/ItaliaTheme/Icons/Icon.jsx +0 -1
- package/src/components/ItaliaTheme/MegaMenu/MegaMenu.jsx +5 -1
- package/src/components/ItaliaTheme/View/BandoView/BandoApprofondimenti.jsx +1 -2
- package/src/components/ItaliaTheme/View/CartellaModulisticaView/DocRow.jsx +14 -5
- package/src/components/ItaliaTheme/View/Commons/Attachment.jsx +19 -3
- package/src/components/ItaliaTheme/View/Commons/Attachments.jsx +0 -1
- package/src/components/ItaliaTheme/View/Commons/DownloadFileFormat.jsx +11 -7
- package/src/components/ItaliaTheme/View/Commons/Gallery.jsx +1 -0
- package/src/components/ItaliaTheme/View/Commons/PageHeader/PageHeaderEventDates.jsx +0 -1
- package/src/components/ItaliaTheme/View/Commons/PageHeader/PageHeaderLinkServizio.jsx +6 -2
- package/src/components/ItaliaTheme/View/Commons/RichTextRender.jsx +8 -6
- package/src/components/ItaliaTheme/View/Commons/__tests__/RichText.test.jsx +14 -17
- package/src/components/ItaliaTheme/View/EventoView/EventoContattiOrganizzatoreEsterno.jsx +1 -1
- package/src/components/ItaliaTheme/View/EventoView/EventoUlterioriInformazioni.jsx +0 -4
- package/src/components/ItaliaTheme/View/ServizioView/ServizioAccedi.jsx +10 -7
- package/src/components/ItaliaTheme/View/ServizioView/ServizioMetatag.jsx +4 -3
- package/src/components/ItaliaTheme/View/__disabled_tests__/IncaricoView.test__disabled.jsx +24 -30
- package/src/components/ItaliaTheme/View/__tests__/CartellaModulisticaView.test.jsx +12 -1
- package/src/components/ItaliaTheme/View/__tests__/PageView.test.jsx +24 -2
- package/src/components/ItaliaTheme/View/__tests__/PersonaView.test.jsx +96 -92
- package/src/components/ItaliaTheme/View/__tests__/ServizioAChiSiRivolge.test.jsx +240 -286
- package/src/components/ItaliaTheme/View/__tests__/ServizioAccedi.test.jsx +240 -286
- package/src/components/ItaliaTheme/View/__tests__/ServizioCasiParticolari.test.jsx +240 -286
- package/src/components/ItaliaTheme/View/__tests__/ServizioComeFare.test.jsx +240 -286
- package/src/components/ItaliaTheme/View/__tests__/ServizioCondizioni.test.jsx +240 -286
- package/src/components/ItaliaTheme/View/__tests__/ServizioContatti.test.jsx +240 -286
- package/src/components/ItaliaTheme/View/__tests__/ServizioCosE.test.jsx +240 -286
- package/src/components/ItaliaTheme/View/__tests__/ServizioCosaServe.test.jsx +240 -286
- package/src/components/ItaliaTheme/View/__tests__/ServizioCosaSiOttiene.test.jsx +240 -286
- package/src/components/ItaliaTheme/View/__tests__/ServizioCostiVincoli.test.jsx +240 -286
- package/src/components/ItaliaTheme/View/__tests__/ServizioMetadati.test.jsx +240 -286
- package/src/components/ItaliaTheme/View/__tests__/ServizioModulistica.test.jsx +240 -286
- package/src/components/ItaliaTheme/View/__tests__/ServizioProcedure.test.jsx +240 -286
- package/src/components/ItaliaTheme/View/__tests__/ServizioSitiEsterni.test.jsx +240 -286
- package/src/components/ItaliaTheme/View/__tests__/ServizioTempiScadenze.test.jsx +240 -286
- package/src/components/ItaliaTheme/View/__tests__/ServizioUlterioriInformazioni.test.jsx +240 -286
- package/src/components/ItaliaTheme/View/__tests__/ServizioView.test.jsx +470 -560
- package/src/components/ItaliaTheme/View/__tests__/TrasparenzaView.test.jsx +12 -1
- package/src/components/ItaliaTheme/index.js +0 -1
- package/src/components/ItaliaTheme/manage/Widgets/ColorListWidget.jsx +11 -2
- package/src/components/ItaliaTheme/manage/Widgets/HtmlSlateWidget.jsx +156 -0
- package/src/components/ItaliaTheme/manage/Widgets/RichTextWidget.jsx +88 -0
- package/src/components/ItaliaTheme/manage/Widgets/SimpleTextEditorWidget.jsx +158 -0
- package/src/components/ItaliaTheme/manage/Widgets/TextEditorWidget.jsx +167 -270
- package/src/config/Blocks/ListingOptions/index.js +0 -1
- package/src/config/Blocks/ListingOptions/utils.js +0 -7
- package/src/config/Blocks/blocks.js +29 -8
- package/src/config/Blocks/listingVariations.js +1 -1
- package/src/config/Slate/Alignment/AlignMenu.jsx +169 -0
- package/src/config/Slate/Alignment/index.js +42 -0
- package/src/config/Slate/Blockquote/BlockquoteMenu.jsx +151 -0
- package/src/config/Slate/Blockquote/index.js +19 -0
- package/src/config/Slate/Headings/HeadingsMenu.jsx +139 -0
- package/src/config/Slate/Headings/headingsMenu.scss +44 -0
- package/src/config/Slate/Headings/index.js +62 -0
- package/src/config/Slate/Link/deserializer.js +25 -0
- package/src/config/Slate/Link/index.js +126 -0
- package/src/config/Slate/Link/renderer.jsx +99 -0
- package/src/config/Slate/LinkButton/index.js +47 -0
- package/src/config/Slate/TextLarger/index.js +51 -0
- package/src/config/Slate/Underline/index.js +10 -0
- package/src/config/Slate/config.js +43 -0
- package/src/config/Slate/deserializers.js +66 -0
- package/src/config/Slate/dropdownStyle.scss +14 -0
- package/src/config/Slate/dropdownUtils.js +422 -0
- package/src/config/Slate/extensions/breakList.js +91 -0
- package/src/config/Slate/handlers.js +243 -0
- package/src/config/Slate/utils.js +73 -0
- package/src/config/Widgets/widgets.js +1 -2
- package/src/config/italiaConfig.js +5 -53
- package/src/customizations/volto/components/manage/AnchorPlugin/components/LinkButton/AddLinkForm.jsx +361 -0
- package/src/customizations/volto/components/manage/Blocks/HeroImageLeft/Edit.jsx +75 -200
- package/src/customizations/volto/components/manage/Blocks/Video/Body.jsx +0 -1
- package/src/customizations/volto/components/manage/Blocks/Video/Edit.jsx +1 -1
- package/src/customizations/volto/components/manage/Form/BlocksToolbar.jsx +1 -1
- package/src/customizations/volto/components/manage/UniversalLink/UniversalLink.jsx +76 -18
- package/src/customizations/volto/components/manage/Widgets/RecurrenceWidget/RecurrenceWidget.jsx +4 -0
- package/src/customizations/volto-form-block/components/Field.jsx +45 -22
- package/src/helpers/EnhanceLink.js +44 -0
- package/src/helpers/FormValidation/FormValidationHelpers.js +3 -0
- package/src/helpers/blocks.js +80 -0
- package/src/helpers/files.js +13 -13
- package/src/helpers/index.js +4 -3
- package/src/helpers/richTextHelper.js +10 -0
- package/src/icons/Group.svg +1 -0
- package/src/icons/blocco-icone.svg +0 -3
- package/src/icons/blockquote-card-dark.svg +1 -0
- package/src/icons/blockquote-card.svg +1 -0
- package/src/icons/blockquote-simple.svg +1 -0
- package/src/icons/text-larger.svg +1 -0
- package/src/theme/ItaliaTheme/Blocks/_accordion.scss +2 -22
- package/src/theme/ItaliaTheme/Blocks/_alert.scss +51 -4
- package/src/theme/ItaliaTheme/Blocks/_bandiInEvidenceTemplate.scss +1 -0
- package/src/theme/ItaliaTheme/Blocks/_callout.scss +32 -0
- package/src/theme/ItaliaTheme/Blocks/_contacts.scss +17 -51
- package/src/theme/ItaliaTheme/Blocks/_countdown.scss +10 -1
- package/src/theme/ItaliaTheme/Blocks/_ctaBlock.scss +7 -23
- package/src/theme/ItaliaTheme/Blocks/_gridBlock.scss +1 -1
- package/src/theme/ItaliaTheme/Blocks/_hero.scss +1 -8
- package/src/theme/ItaliaTheme/Blocks/_iconBlocks.scss +6 -77
- package/src/theme/ItaliaTheme/Blocks/_imageCardTextBlock.scss +3 -2
- package/src/theme/ItaliaTheme/Blocks/_numbers.scss +6 -20
- package/src/theme/ItaliaTheme/Blocks/_simpleCardTextBlock.scss +8 -2
- package/src/theme/ItaliaTheme/Blocks/_subblocks-edit.scss +3 -1
- package/src/theme/ItaliaTheme/Blocks/_tableOfContents.scss +1 -0
- package/src/theme/ItaliaTheme/Components/_megamenu.scss +0 -4
- package/src/theme/ItaliaTheme/Components/_mobileMenu.scss +12 -16
- package/src/theme/ItaliaTheme/Print/_page.scss +1 -1
- package/src/theme/ItaliaTheme/Subsites/ItaliaTheme/Blocks/_contacts.scss +3 -0
- package/src/theme/ItaliaTheme/Subsites/ItaliaTheme/Blocks/_cta.scss +1 -0
- package/src/theme/ItaliaTheme/Subsites/ItaliaTheme/Blocks/_searchSections.scss +1 -0
- package/src/theme/ItaliaTheme/Subsites/bootstrap-italia/custom/_headercenter.scss +1 -0
- package/src/theme/ItaliaTheme/Views/_cartellaModulistica.scss +11 -2
- package/src/theme/ItaliaTheme/Views/_servizio.scss +2 -2
- package/src/theme/ItaliaTheme/Views/_slider.scss +3 -0
- package/src/theme/ItaliaTheme/Widgets/_iconWidget.scss +4 -0
- package/src/theme/ItaliaTheme/_common.scss +1 -0
- package/src/theme/ItaliaTheme/_home.scss +0 -4
- package/src/theme/ItaliaTheme/_main.scss +78 -84
- package/src/theme/_cms-ui.scss +63 -160
- package/src/theme/_mixins.scss +13 -0
- package/src/theme/bootstrap-override/_bootstrap-italia-site.scss +1 -0
- package/src/theme/bootstrap-override/bootstrap-italia/_footer.scss +1 -1
- package/src/theme/bootstrap-override/bootstrap-italia/_forms.scss +7 -0
- package/src/theme/bootstrap-override/bootstrap-italia/_headercenter.scss +8 -3
- package/src/theme/extras/_forms.scss +2 -14
- package/src/theme/site.scss +1 -1
- package/test-setup-config.js +58 -0
- package/.yarn/cache/braces-npm-3.0.2-782240b28a-e2a8e769a8.zip +0 -0
- package/.yarn/cache/fill-range-npm-7.0.1-b8b1817caa-cc283f4e65.zip +0 -0
- package/.yarn/cache/micromatch-npm-4.0.5-cfab5d7669-02a17b671c.zip +0 -0
- package/src/components/ItaliaTheme/Blocks/TextCard/SimpleCard/Block.jsx +0 -151
- package/src/components/ItaliaTheme/RemoveBodyClass/RemoveBodyClass.jsx +0 -84
- package/src/config/RichTextEditor/LinkEntity.jsx +0 -27
- package/src/config/RichTextEditor/Plugins/AnchorPlugin/components/Link/index.jsx +0 -44
- package/src/config/RichTextEditor/Plugins/AnchorPlugin/components/LinkButton/AddLinkForm.jsx +0 -349
- package/src/config/RichTextEditor/Plugins/AnchorPlugin/components/LinkButton/index.js +0 -150
- package/src/config/RichTextEditor/Plugins/AnchorPlugin/index.js +0 -88
- package/src/config/RichTextEditor/ToolbarButtons/AlignButton.jsx +0 -61
- package/src/config/RichTextEditor/ToolbarButtons/ButtonsButton.jsx +0 -14
- package/src/config/RichTextEditor/ToolbarButtons/CalloutsButton.jsx +0 -38
- package/src/config/RichTextEditor/ToolbarButtons/DraftJsDropdownButton.jsx +0 -106
- package/src/config/RichTextEditor/ToolbarButtons/HeadingsButton.jsx +0 -57
- package/src/config/RichTextEditor/ToolbarButtons/TextSizeButton.jsx +0 -65
- package/src/config/RichTextEditor/ToolbarButtons/UnderlineButton.jsx +0 -14
- package/src/config/RichTextEditor/config.js +0 -253
- package/src/config/volto-gdpr-privacy-defaultPanelConfig.js +0 -292
- package/src/customizations/volto/components/manage/Blocks/ToC/View.jsx +0 -134
- package/src/customizations/volto/components/manage/Blocks/ToC/variations/DefaultTocRenderer.jsx +0 -99
- package/src/customizations/volto/config/RichTextEditor/Plugins.jsx +0 -63
- package/src/helpers/redraftHelper.js +0 -9
- package/src/theme/ItaliaTheme/Components/_logo.scss +0 -10
|
@@ -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
|
|
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,9 +34,8 @@ 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
|
-
|
|
39
37
|
import SiteSettingsExtras from 'design-comuni-plone-theme/components/ItaliaTheme/AppExtras/SiteSettingsExtras';
|
|
38
|
+
|
|
40
39
|
import { loadables as ItaliaLoadables } from 'design-comuni-plone-theme/config/loadables';
|
|
41
40
|
|
|
42
41
|
// CTs icons
|
|
@@ -60,9 +59,7 @@ import faQuestionSVG from 'design-comuni-plone-theme/icons/question-solid.svg';
|
|
|
60
59
|
import bandoSVG from 'design-comuni-plone-theme/icons/bando.svg';
|
|
61
60
|
import logSVG from 'design-comuni-plone-theme/icons/log.svg';
|
|
62
61
|
|
|
63
|
-
import
|
|
64
|
-
|
|
65
|
-
import gdprPrivacyPanelConfig from 'design-comuni-plone-theme/config/volto-gdpr-privacy-defaultPanelConfig.js';
|
|
62
|
+
import applyItaliaSlateConfig from 'design-comuni-plone-theme/config/Slate/config';
|
|
66
63
|
|
|
67
64
|
import { schemaListing } from 'design-comuni-plone-theme/components/ItaliaTheme/Blocks/Listing/schema.js';
|
|
68
65
|
|
|
@@ -92,7 +89,7 @@ const messages = defineMessages({
|
|
|
92
89
|
});
|
|
93
90
|
|
|
94
91
|
export default function applyConfig(voltoConfig) {
|
|
95
|
-
let config =
|
|
92
|
+
let config = applyItaliaSlateConfig(voltoConfig);
|
|
96
93
|
|
|
97
94
|
/******************************************************************************
|
|
98
95
|
* SETTINGS
|
|
@@ -216,7 +213,7 @@ export default function applyConfig(voltoConfig) {
|
|
|
216
213
|
'social-settings': shareSVG,
|
|
217
214
|
'release-log': logSVG,
|
|
218
215
|
},
|
|
219
|
-
defaultBlockType: 'text',
|
|
216
|
+
//defaultBlockType: 'text',
|
|
220
217
|
defaultExcludedFromSearch: {
|
|
221
218
|
portalTypes: ['Image', 'File'],
|
|
222
219
|
},
|
|
@@ -334,11 +331,6 @@ export default function applyConfig(voltoConfig) {
|
|
|
334
331
|
},
|
|
335
332
|
],
|
|
336
333
|
|
|
337
|
-
'volto-gdpr-privacy': {
|
|
338
|
-
...config.settings['volto-gdpr-privacy'],
|
|
339
|
-
defaultPanelConfig: gdprPrivacyPanelConfig,
|
|
340
|
-
},
|
|
341
|
-
|
|
342
334
|
'volto-editablefooter': {
|
|
343
335
|
...config.settings['volto-editablefooter'],
|
|
344
336
|
options: { socials: true, newsletterSubscribe: true },
|
|
@@ -461,6 +453,7 @@ export default function applyConfig(voltoConfig) {
|
|
|
461
453
|
},
|
|
462
454
|
hero: {
|
|
463
455
|
...config.blocks.blocksConfig.hero,
|
|
456
|
+
hasOwnFocusManagement: true,
|
|
464
457
|
sidebarTab: 1,
|
|
465
458
|
},
|
|
466
459
|
html: {
|
|
@@ -468,22 +461,6 @@ export default function applyConfig(voltoConfig) {
|
|
|
468
461
|
sidebarTab: 1,
|
|
469
462
|
},
|
|
470
463
|
rssBlock,
|
|
471
|
-
text: {
|
|
472
|
-
...config.blocks.blocksConfig.text,
|
|
473
|
-
restricted: false,
|
|
474
|
-
},
|
|
475
|
-
slate: {
|
|
476
|
-
...config.blocks.blocksConfig.slate,
|
|
477
|
-
restricted: true,
|
|
478
|
-
},
|
|
479
|
-
table: {
|
|
480
|
-
...config.blocks.blocksConfig.table,
|
|
481
|
-
restricted: false,
|
|
482
|
-
},
|
|
483
|
-
slateTable: {
|
|
484
|
-
...config.blocks.blocksConfig.slateTable,
|
|
485
|
-
restricted: true,
|
|
486
|
-
},
|
|
487
464
|
maps: {
|
|
488
465
|
...config.blocks.blocksConfig.maps,
|
|
489
466
|
restricted: true,
|
|
@@ -531,31 +508,6 @@ export default function applyConfig(voltoConfig) {
|
|
|
531
508
|
// comment out the following line and add the leadimage behavior in Document.xml file
|
|
532
509
|
delete config.blocks.blocksConfig['leadimage'];
|
|
533
510
|
|
|
534
|
-
// TOC block anchors not working, customizing tocEntry
|
|
535
|
-
// to also return draftJS block id
|
|
536
|
-
config.settings.slate = {
|
|
537
|
-
...(config.settings.slate ?? {}),
|
|
538
|
-
topLevelTargetElements: ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'],
|
|
539
|
-
};
|
|
540
|
-
config.blocks.blocksConfig.text = {
|
|
541
|
-
...config.blocks.blocksConfig.text,
|
|
542
|
-
tocEntry: (block = {}) => {
|
|
543
|
-
const draft = redraft(
|
|
544
|
-
block.text,
|
|
545
|
-
config.settings.richtextViewSettings.ToHTMLRenderers,
|
|
546
|
-
config.settings.richtextViewSettings.ToHTMLOptions,
|
|
547
|
-
);
|
|
548
|
-
const type = draft?.[0]?.[0]?.type;
|
|
549
|
-
|
|
550
|
-
return config.settings.slate.topLevelTargetElements.includes(type)
|
|
551
|
-
? [
|
|
552
|
-
parseInt(type.slice(1)),
|
|
553
|
-
block.text.blocks[0].text,
|
|
554
|
-
block.text.blocks[0].key,
|
|
555
|
-
]
|
|
556
|
-
: null;
|
|
557
|
-
},
|
|
558
|
-
};
|
|
559
511
|
// Remove Horizontal Menu variation of TOC Block
|
|
560
512
|
config.blocks.blocksConfig.toc.variations =
|
|
561
513
|
config.blocks.blocksConfig.toc.variations.filter(
|