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.
- package/.github/workflows/slate.yml +47 -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/require-package-name-npm-2.0.1-ac9a206b63-00f4e9e467.zip +0 -0
- 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
- 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
- package/.yarn/install-state.gz +0 -0
- package/CHANGELOG.md +878 -916
- package/RELEASE.md +8 -0
- package/locales/de/LC_MESSAGES/volto.po +86 -18
- package/locales/en/LC_MESSAGES/volto.po +86 -18
- package/locales/es/LC_MESSAGES/volto.po +86 -18
- package/locales/fr/LC_MESSAGES/volto.po +86 -18
- package/locales/it/LC_MESSAGES/volto.po +86 -18
- package/locales/volto.pot +87 -19
- package/package.json +5 -3
- package/publiccode.yml +2 -2
- package/src/components/Collapse.jsx +1 -0
- 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 +67 -6
- 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 +84 -63
- package/src/components/ItaliaTheme/Blocks/ContactsBlock/Block/ViewBlock.jsx +19 -39
- package/src/components/ItaliaTheme/Blocks/ContactsBlock/Edit.jsx +92 -19
- 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 +40 -15
- package/src/components/ItaliaTheme/Blocks/IconBlocks/Block/ViewBlock.jsx +6 -21
- package/src/components/ItaliaTheme/Blocks/IconBlocks/Edit.jsx +93 -20
- package/src/components/ItaliaTheme/Blocks/IconBlocks/Sidebar.jsx +1 -9
- package/src/components/ItaliaTheme/Blocks/IconBlocks/View.jsx +4 -17
- package/src/components/ItaliaTheme/Blocks/NumbersBlock/Block/EditBlock.jsx +46 -15
- package/src/components/ItaliaTheme/Blocks/NumbersBlock/Block/ViewBlock.jsx +2 -18
- package/src/components/ItaliaTheme/Blocks/NumbersBlock/Edit.jsx +84 -11
- package/src/components/ItaliaTheme/Blocks/NumbersBlock/View.jsx +2 -11
- package/src/components/ItaliaTheme/Blocks/TextCard/CardWithImage/Block.jsx +33 -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/__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/Footer/FooterInfos.jsx +22 -8
- package/src/components/ItaliaTheme/Footer/FooterNavigation.jsx +3 -3
- package/src/components/ItaliaTheme/MegaMenu/MegaMenu.jsx +5 -1
- package/src/components/ItaliaTheme/Slider/SingleSlideWrapper.jsx +2 -3
- 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/Module.jsx +7 -6
- 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/ServizioView/ServizioAccedi.jsx +5 -6
- package/src/components/ItaliaTheme/View/ServizioView/ServizioMetatag.jsx +4 -0
- package/src/components/ItaliaTheme/View/__tests__/CartellaModulisticaView.test.jsx +12 -1
- package/src/components/ItaliaTheme/View/__tests__/IncaricoView.test.jsx +24 -30
- 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/manage/Widgets/ColorListWidget.jsx +11 -2
- package/src/components/ItaliaTheme/manage/Widgets/HtmlSlateWidget.jsx +154 -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 +12 -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 +7 -54
- package/src/customizations/volto/components/manage/AnchorPlugin/components/LinkButton/AddLinkForm.jsx +360 -0
- package/src/customizations/volto/components/manage/Blocks/HeroImageLeft/Edit.jsx +75 -200
- 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 +59 -6
- package/src/customizations/volto-form-block/components/Field.jsx +45 -22
- package/src/customizations/volto-form-block/components/FormResult.jsx +74 -0
- package/src/customizations/volto-form-block/components/FormView.jsx +79 -66
- package/src/customizations/volto-form-block/components/Widget/Button.jsx +50 -0
- package/src/helpers/EnhanceLink.js +44 -0
- package/src/helpers/FormValidation/FormValidationHelpers.js +3 -0
- package/src/helpers/blocks.js +86 -0
- package/src/helpers/files.js +14 -14
- 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 +1 -10
- package/src/theme/ItaliaTheme/Blocks/_alert.scss +53 -1
- 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 +15 -32
- package/src/theme/ItaliaTheme/Blocks/_ctaBlock.scss +0 -14
- 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 +0 -30
- package/src/theme/ItaliaTheme/Blocks/_imageCardTextBlock.scss +3 -2
- package/src/theme/ItaliaTheme/Blocks/_numbers.scss +1 -5
- package/src/theme/ItaliaTheme/Blocks/_simpleCardTextBlock.scss +8 -2
- package/src/theme/ItaliaTheme/Blocks/_tableOfContents.scss +1 -0
- package/src/theme/ItaliaTheme/Components/_megamenu.scss +0 -4
- 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/_slider.scss +3 -3
- package/src/theme/ItaliaTheme/Widgets/_iconWidget.scss +4 -0
- package/src/theme/ItaliaTheme/_main.scss +42 -54
- package/src/theme/_cms-ui.scss +59 -161
- package/src/theme/extras/_forms.scss +2 -14
- package/src/theme/site.scss +1 -0
- package/test-setup-config.js +58 -0
- package/src/components/ItaliaTheme/Blocks/TextCard/SimpleCard/Block.jsx +0 -151
- 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
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/*Customized LinkEditor to:
|
|
2
|
+
- handle data-element
|
|
3
|
+
- enhance link (enhanced_link_infos)
|
|
4
|
+
*/
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { useSelector, useDispatch } from 'react-redux';
|
|
7
|
+
import { ReactEditor } from 'slate-react';
|
|
8
|
+
import { Transforms } from 'slate';
|
|
9
|
+
import {
|
|
10
|
+
_insertElement,
|
|
11
|
+
_unwrapElement,
|
|
12
|
+
_isActiveElement,
|
|
13
|
+
_getActiveElement,
|
|
14
|
+
} from '@plone/volto-slate/elementEditor/utils';
|
|
15
|
+
import { SIMPLELINK } from '@plone/volto-slate/constants';
|
|
16
|
+
import { useSelectionPosition } from '@plone/volto-slate/hooks';
|
|
17
|
+
import { setPluginOptions } from '@plone/volto-slate/actions';
|
|
18
|
+
import { PositionedToolbar } from '@plone/volto-slate/editor/ui';
|
|
19
|
+
import AddLinkForm from '@plone/volto/components/manage/AnchorPlugin/components/LinkButton/AddLinkForm';
|
|
20
|
+
import { simpleLinkDeserializer } from 'design-comuni-plone-theme/config/Slate/Link/deserializer';
|
|
21
|
+
const LinkEditor = (props) => {
|
|
22
|
+
const { editor, pluginId, getActiveElement, unwrapElement, insertElement } =
|
|
23
|
+
props;
|
|
24
|
+
const pid = `${editor.uid}-${pluginId}`;
|
|
25
|
+
const showEditor = useSelector((state) => {
|
|
26
|
+
return state['slate_plugins']?.[pid]?.show_sidebar_editor;
|
|
27
|
+
});
|
|
28
|
+
const savedPosition = React.useRef();
|
|
29
|
+
const rect = useSelectionPosition();
|
|
30
|
+
|
|
31
|
+
const dispatch = useDispatch();
|
|
32
|
+
|
|
33
|
+
const active = getActiveElement(editor);
|
|
34
|
+
const [node] = active || [];
|
|
35
|
+
|
|
36
|
+
if (showEditor && !savedPosition.current) {
|
|
37
|
+
savedPosition.current = getPositionStyle(rect);
|
|
38
|
+
}
|
|
39
|
+
const dataElement =
|
|
40
|
+
node?.data?.dataElement || node?.data?.['data-element'] || '';
|
|
41
|
+
|
|
42
|
+
return showEditor ? (
|
|
43
|
+
<PositionedToolbar className="add-link" position={savedPosition.current}>
|
|
44
|
+
<AddLinkForm
|
|
45
|
+
block="draft-js"
|
|
46
|
+
placeholder={'Aggiungi un link'}
|
|
47
|
+
data={{ url: node?.data?.url || '', dataElement }}
|
|
48
|
+
theme={{}}
|
|
49
|
+
onChangeValue={(url, dataElement, item) => {
|
|
50
|
+
let enhanced_link_infos = null;
|
|
51
|
+
if (item && item.enhanced_links_enabled) {
|
|
52
|
+
enhanced_link_infos = {};
|
|
53
|
+
enhanced_link_infos['content-type'] = item.mime_type;
|
|
54
|
+
enhanced_link_infos.getObjSize = item.getObjSize;
|
|
55
|
+
}
|
|
56
|
+
if (!active) {
|
|
57
|
+
if (!editor.selection) editor.selection = editor.savedSelection;
|
|
58
|
+
insertElement(editor, { url, dataElement, enhanced_link_infos });
|
|
59
|
+
} else {
|
|
60
|
+
const selection = unwrapElement(editor);
|
|
61
|
+
editor.selection = selection;
|
|
62
|
+
insertElement(editor, { url, dataElement, enhanced_link_infos });
|
|
63
|
+
}
|
|
64
|
+
// ReactEditor.focus(editor);
|
|
65
|
+
|
|
66
|
+
dispatch(setPluginOptions(pid, { show_sidebar_editor: false }));
|
|
67
|
+
savedPosition.current = null;
|
|
68
|
+
|
|
69
|
+
ReactEditor.deselect(editor);
|
|
70
|
+
Transforms.collapse(editor, { edge: 'end' });
|
|
71
|
+
Transforms.insertText(editor, ' ');
|
|
72
|
+
}}
|
|
73
|
+
onClear={() => {
|
|
74
|
+
// clear button was pressed in the link edit popup
|
|
75
|
+
try {
|
|
76
|
+
const newSelection = JSON.parse(
|
|
77
|
+
JSON.stringify(unwrapElement(editor)),
|
|
78
|
+
);
|
|
79
|
+
editor.selection = newSelection;
|
|
80
|
+
editor.savedSelection = newSelection;
|
|
81
|
+
} catch (e) {
|
|
82
|
+
//do nothing when no link was setted yet, and you clear the select item to link
|
|
83
|
+
}
|
|
84
|
+
}}
|
|
85
|
+
onOverrideContent={(c) => {
|
|
86
|
+
dispatch(setPluginOptions(pid, { show_sidebar_editor: false }));
|
|
87
|
+
savedPosition.current = null;
|
|
88
|
+
}}
|
|
89
|
+
/>
|
|
90
|
+
</PositionedToolbar>
|
|
91
|
+
) : null;
|
|
92
|
+
};
|
|
93
|
+
function getPositionStyle(rect) {
|
|
94
|
+
return {
|
|
95
|
+
style: {
|
|
96
|
+
opacity: 1,
|
|
97
|
+
top: rect.top + window.pageYOffset - 6,
|
|
98
|
+
left: rect.left + window.pageXOffset + rect.width / 2,
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export default function install(config) {
|
|
104
|
+
const { slate } = config.settings;
|
|
105
|
+
const PLUGINID = SIMPLELINK;
|
|
106
|
+
const insertElement = _insertElement(PLUGINID);
|
|
107
|
+
const getActiveElement = _getActiveElement(PLUGINID);
|
|
108
|
+
const isActiveElement = _isActiveElement(PLUGINID);
|
|
109
|
+
const unwrapElement = _unwrapElement(PLUGINID);
|
|
110
|
+
const pluginOptions = {
|
|
111
|
+
insertElement,
|
|
112
|
+
getActiveElement,
|
|
113
|
+
isActiveElement,
|
|
114
|
+
unwrapElement,
|
|
115
|
+
};
|
|
116
|
+
//remove Volto helper link to add custom helper link
|
|
117
|
+
slate.persistentHelpers = slate.persistentHelpers.filter(
|
|
118
|
+
(h) => h().props.pluginId !== 'link',
|
|
119
|
+
);
|
|
120
|
+
slate.persistentHelpers.push((props) => (
|
|
121
|
+
<LinkEditor {...props} pluginId={PLUGINID} {...pluginOptions} />
|
|
122
|
+
));
|
|
123
|
+
slate.htmlTagsToSlate.A = simpleLinkDeserializer;
|
|
124
|
+
|
|
125
|
+
return config;
|
|
126
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { UniversalLink } from '@plone/volto/components';
|
|
3
|
+
import config from '@plone/volto/registry';
|
|
4
|
+
import { isInternalURL, flattenToAppURL } from '@plone/volto/helpers';
|
|
5
|
+
import { EnhanceLink } from 'design-comuni-plone-theme/helpers';
|
|
6
|
+
import { Icon } from 'design-comuni-plone-theme/components/ItaliaTheme';
|
|
7
|
+
|
|
8
|
+
const ViewLink = ({
|
|
9
|
+
url,
|
|
10
|
+
target,
|
|
11
|
+
download,
|
|
12
|
+
children,
|
|
13
|
+
className,
|
|
14
|
+
dataElement,
|
|
15
|
+
}) => {
|
|
16
|
+
const { openExternalLinkInNewTab } = config.settings;
|
|
17
|
+
let dataElementAttr = {};
|
|
18
|
+
if (dataElement) {
|
|
19
|
+
dataElementAttr['data-element'] = dataElement;
|
|
20
|
+
}
|
|
21
|
+
return (
|
|
22
|
+
<UniversalLink
|
|
23
|
+
href={url}
|
|
24
|
+
openLinkInNewTab={
|
|
25
|
+
(openExternalLinkInNewTab && !isInternalURL(url)) || target === '_blank'
|
|
26
|
+
}
|
|
27
|
+
download={download}
|
|
28
|
+
className={className}
|
|
29
|
+
{...dataElementAttr}
|
|
30
|
+
>
|
|
31
|
+
{children}
|
|
32
|
+
</UniversalLink>
|
|
33
|
+
);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export const LinkElement = (props) => {
|
|
37
|
+
const { attributes, children, element, mode = 'edit' } = props;
|
|
38
|
+
|
|
39
|
+
let dataElementAttr = {};
|
|
40
|
+
if (element.data.dataElement) {
|
|
41
|
+
dataElementAttr['data-element'] = element.data.dataElement;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
let enhanced_link = element.data.enhanced_link_infos
|
|
45
|
+
? EnhanceLink({
|
|
46
|
+
enhanced_link_infos: {
|
|
47
|
+
...element.data.enhanced_link_infos, //{mime_type: 'image/png', getObjSize: '1.3 MB'}
|
|
48
|
+
filename: element.data.url,
|
|
49
|
+
},
|
|
50
|
+
})
|
|
51
|
+
: null;
|
|
52
|
+
|
|
53
|
+
const extended_children = enhanced_link?.children ?? <></>;
|
|
54
|
+
|
|
55
|
+
return mode === 'view' ? (
|
|
56
|
+
<ViewLink {...(element.data || {})} {...attributes}>
|
|
57
|
+
{children}
|
|
58
|
+
{extended_children}
|
|
59
|
+
</ViewLink>
|
|
60
|
+
) : (
|
|
61
|
+
<a
|
|
62
|
+
{...attributes}
|
|
63
|
+
{...dataElementAttr}
|
|
64
|
+
className={'slate-editor-link ' + (attributes.className ?? '')}
|
|
65
|
+
href={
|
|
66
|
+
isInternalURL(element.data?.url)
|
|
67
|
+
? flattenToAppURL(element.data?.url)
|
|
68
|
+
: element.data?.url
|
|
69
|
+
}
|
|
70
|
+
onClick={(e) => e.preventDefault()}
|
|
71
|
+
>
|
|
72
|
+
{Array.isArray(children)
|
|
73
|
+
? children.map((child, i) => {
|
|
74
|
+
if (child?.props?.decorations) {
|
|
75
|
+
const isSelection =
|
|
76
|
+
child.props.decorations.findIndex((deco) => deco.isSelection) >
|
|
77
|
+
-1;
|
|
78
|
+
if (isSelection)
|
|
79
|
+
return (
|
|
80
|
+
<span className="highlight-selection" key={`${i}-sel`}>
|
|
81
|
+
{child}
|
|
82
|
+
</span>
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
return child;
|
|
86
|
+
})
|
|
87
|
+
: children}
|
|
88
|
+
{extended_children}
|
|
89
|
+
{!isInternalURL(element.data?.url) &&
|
|
90
|
+
config.settings.siteProperties.markSpecialLinks && (
|
|
91
|
+
<Icon
|
|
92
|
+
icon="it-external-link"
|
|
93
|
+
size="xs"
|
|
94
|
+
className="ms-1 align-sub external-link"
|
|
95
|
+
/>
|
|
96
|
+
)}
|
|
97
|
+
</a>
|
|
98
|
+
);
|
|
99
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useSlate } from 'slate-react';
|
|
3
|
+
|
|
4
|
+
import { ToolbarButton } from '@plone/volto-slate/editor/ui';
|
|
5
|
+
|
|
6
|
+
import circleMenuSVG from '@plone/volto/icons/circle-menu.svg';
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
toggleStyle,
|
|
10
|
+
isLinkStyleActive,
|
|
11
|
+
} from 'design-comuni-plone-theme/config/Slate/dropdownUtils';
|
|
12
|
+
import { insertToolbarButtons } from 'design-comuni-plone-theme/config/Slate/utils';
|
|
13
|
+
import { LinkElement as ItaliaLinkElement } from 'design-comuni-plone-theme/config/Slate/Link/renderer';
|
|
14
|
+
|
|
15
|
+
const LinkButtonButton = ({ icon, active, ...props }) => {
|
|
16
|
+
const CLASSNAME = 'btn btn-primary inline-link';
|
|
17
|
+
const editor = useSlate();
|
|
18
|
+
const isActive = isLinkStyleActive(editor, CLASSNAME);
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<ToolbarButton
|
|
22
|
+
{...props}
|
|
23
|
+
icon={icon}
|
|
24
|
+
active={isActive}
|
|
25
|
+
onMouseDown={(e) => {
|
|
26
|
+
e.stopPropagation();
|
|
27
|
+
e.preventDefault();
|
|
28
|
+
toggleStyle(editor, { cssClass: CLASSNAME, isBlock: false });
|
|
29
|
+
}}
|
|
30
|
+
/>
|
|
31
|
+
);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export default function install(config) {
|
|
35
|
+
const { slate } = config.settings;
|
|
36
|
+
|
|
37
|
+
slate.buttons.linkButton = (props) => (
|
|
38
|
+
<LinkButtonButton title="Stile bottone" icon={circleMenuSVG} {...props} />
|
|
39
|
+
);
|
|
40
|
+
slate.elements.link = ItaliaLinkElement;
|
|
41
|
+
|
|
42
|
+
//aggiungo il bottone di headings alla toolbar, dopo strikethrough
|
|
43
|
+
insertToolbarButtons(['linkButton'], 'link', slate);
|
|
44
|
+
|
|
45
|
+
//htmlTagToSlate deserializer is defined in ./Link/deserializer.js
|
|
46
|
+
return config;
|
|
47
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useSlate } from 'slate-react';
|
|
3
|
+
|
|
4
|
+
import { ToolbarButton } from '@plone/volto-slate/editor/ui';
|
|
5
|
+
|
|
6
|
+
import textLargerSVG from 'design-comuni-plone-theme/icons/text-larger.svg';
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
toggleStyle,
|
|
10
|
+
isInlineStyleActive,
|
|
11
|
+
} from 'design-comuni-plone-theme/config/Slate/dropdownUtils';
|
|
12
|
+
import { insertToolbarButtons } from 'design-comuni-plone-theme/config/Slate/utils';
|
|
13
|
+
|
|
14
|
+
export const TextLargerElement = ({ attributes, children, element }) => {
|
|
15
|
+
return <span {...attributes}>{children}</span>;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const TextLargerButton = ({ icon, active, ...props }) => {
|
|
19
|
+
const CLASSNAME = 'text-larger';
|
|
20
|
+
const editor = useSlate();
|
|
21
|
+
const isActive = isInlineStyleActive(editor, CLASSNAME);
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<ToolbarButton
|
|
25
|
+
{...props}
|
|
26
|
+
icon={icon}
|
|
27
|
+
active={isActive}
|
|
28
|
+
onMouseDown={(event) => {
|
|
29
|
+
return toggleStyle(editor, { cssClass: CLASSNAME, isBlock: false });
|
|
30
|
+
}}
|
|
31
|
+
/>
|
|
32
|
+
);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export default function install(config) {
|
|
36
|
+
const { slate } = config.settings;
|
|
37
|
+
|
|
38
|
+
slate.buttons.textLarger = (props) => (
|
|
39
|
+
<TextLargerButton
|
|
40
|
+
title="Testo più grande"
|
|
41
|
+
icon={textLargerSVG}
|
|
42
|
+
{...props}
|
|
43
|
+
/>
|
|
44
|
+
);
|
|
45
|
+
slate.elements.textLarger = TextLargerElement;
|
|
46
|
+
|
|
47
|
+
//aggiungo il bottone di headings alla toolbar, dopo strikethrough
|
|
48
|
+
insertToolbarButtons(['textLarger'], 'strikethrough', slate);
|
|
49
|
+
|
|
50
|
+
return config;
|
|
51
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { insertToolbarButtons } from 'design-comuni-plone-theme/config/Slate/utils';
|
|
2
|
+
|
|
3
|
+
export default function install(config) {
|
|
4
|
+
const { slate } = config.settings;
|
|
5
|
+
|
|
6
|
+
//aggiungo il bottone di underline alla toolbar, dopo bold
|
|
7
|
+
insertToolbarButtons(['underline'], 'italic', slate);
|
|
8
|
+
|
|
9
|
+
return config;
|
|
10
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
//config.settings.slate.contextToolbarButtons
|
|
2
|
+
import RichTextWidget from 'design-comuni-plone-theme/components/ItaliaTheme/manage/Widgets/RichTextWidget';
|
|
3
|
+
import HtmlSlateWidget from 'design-comuni-plone-theme/components/ItaliaTheme/manage/Widgets/HtmlSlateWidget';
|
|
4
|
+
import installAlignment from 'design-comuni-plone-theme/config/Slate/Alignment';
|
|
5
|
+
import installHeadings from 'design-comuni-plone-theme/config/Slate/Headings';
|
|
6
|
+
import installUnderline from 'design-comuni-plone-theme/config/Slate/Underline';
|
|
7
|
+
import installBlockquote from 'design-comuni-plone-theme/config/Slate/Blockquote';
|
|
8
|
+
import installLinkButton from 'design-comuni-plone-theme/config/Slate/LinkButton';
|
|
9
|
+
import installTextLarger from 'design-comuni-plone-theme/config/Slate/TextLarger';
|
|
10
|
+
import installLink from 'design-comuni-plone-theme/config/Slate/Link';
|
|
11
|
+
|
|
12
|
+
import installHandlers from 'design-comuni-plone-theme/config/Slate/handlers';
|
|
13
|
+
import installDeserializers from 'design-comuni-plone-theme/config/Slate/deserializers';
|
|
14
|
+
|
|
15
|
+
export default function applyItaliaSlateConfig(config) {
|
|
16
|
+
installAlignment(config);
|
|
17
|
+
installHeadings(config);
|
|
18
|
+
installUnderline(config);
|
|
19
|
+
installTextLarger(config);
|
|
20
|
+
installLink(config);
|
|
21
|
+
installBlockquote(config);
|
|
22
|
+
installLinkButton(config);
|
|
23
|
+
|
|
24
|
+
installHandlers(config);
|
|
25
|
+
installDeserializers(config);
|
|
26
|
+
|
|
27
|
+
//remove callout because there's a Volto's block for it
|
|
28
|
+
delete config.settings.slate.elements.callout;
|
|
29
|
+
delete config.settings.slate.buttons.callout;
|
|
30
|
+
config.settings.slate.toolbarButtons = config.settings.slate.toolbarButtons.filter(
|
|
31
|
+
(b) => b !== 'callout',
|
|
32
|
+
);
|
|
33
|
+
config.settings.slate.expandedToolbarButtons = config.settings.slate.toolbarButtons.filter(
|
|
34
|
+
(b) => b !== 'callout',
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
//add wrapper public-ui to widgets
|
|
38
|
+
config.widgets.widget.slate = RichTextWidget;
|
|
39
|
+
config.widgets.widget.slate_richtext = RichTextWidget;
|
|
40
|
+
config.widgets.widget.slate_html = HtmlSlateWidget;
|
|
41
|
+
config.widgets.widget.richtext = HtmlSlateWidget;
|
|
42
|
+
return config;
|
|
43
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { jsx } from 'slate-hyperscript';
|
|
2
|
+
import { deserializeChildren } from '@plone/volto-slate/editor/deserialize';
|
|
3
|
+
import { TD, TH } from '@plone/volto-slate/constants';
|
|
4
|
+
|
|
5
|
+
/*rispetto a quello di volto-slate:
|
|
6
|
+
- aggiunge anche la classe (styleName) se era stata impostata
|
|
7
|
+
*/
|
|
8
|
+
export const blockTagDeserializer = (tagname) => (editor, el, options) => {
|
|
9
|
+
// if (tagname === 'h2') debugger;
|
|
10
|
+
let children = deserializeChildren(el, editor, options).filter(
|
|
11
|
+
(n) => n !== null,
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
if (
|
|
15
|
+
[TD, TH].includes(tagname) &&
|
|
16
|
+
children.length > 0 &&
|
|
17
|
+
typeof children[0] === 'string'
|
|
18
|
+
) {
|
|
19
|
+
// TODO: should here be handled the cases when there are more strings in
|
|
20
|
+
// `children` or when there are besides strings other types of nodes too?
|
|
21
|
+
const p = { type: 'div', children: [{ text: '' }] };
|
|
22
|
+
p.children[0].text = children[0];
|
|
23
|
+
children = [p];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// normalizes block elements so that they're never empty
|
|
27
|
+
// Avoids a hard crash from the Slate editor
|
|
28
|
+
const hasValidChildren = children.length && children.find((c) => !!c);
|
|
29
|
+
if (!hasValidChildren) {
|
|
30
|
+
children = [{ text: '' }];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return jsx(
|
|
34
|
+
'element',
|
|
35
|
+
{ type: tagname, styleName: el.getAttribute('class') },
|
|
36
|
+
children,
|
|
37
|
+
);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/*rispetto a quello di volto-slate:
|
|
41
|
+
- se il tag body contiene direttamente dei children <li> allora crea un <ul> wrapper
|
|
42
|
+
*/
|
|
43
|
+
export const bodyTagDeserializer = () => (editor, el, options) => {
|
|
44
|
+
if (
|
|
45
|
+
el?.firstElementChild?.nodeName === 'LI' &&
|
|
46
|
+
el?.lastElementChild?.nodeName === 'LI'
|
|
47
|
+
) {
|
|
48
|
+
return jsx(
|
|
49
|
+
'element',
|
|
50
|
+
{ type: 'ul' },
|
|
51
|
+
deserializeChildren(el, editor, options),
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
return jsx('fragment', {}, deserializeChildren(el, editor, options));
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export default function install(config) {
|
|
58
|
+
config.settings.slate.htmlTagsToSlate.BODY = bodyTagDeserializer();
|
|
59
|
+
config.settings.slate.htmlTagsToSlate.P = blockTagDeserializer('p');
|
|
60
|
+
config.settings.slate.htmlTagsToSlate.OL = blockTagDeserializer('ol');
|
|
61
|
+
config.settings.slate.htmlTagsToSlate.UL = blockTagDeserializer('ul');
|
|
62
|
+
config.settings.slate.htmlTagsToSlate.BLOCKQUOTE =
|
|
63
|
+
blockTagDeserializer('blockquote');
|
|
64
|
+
|
|
65
|
+
//A (link) deserializer is defined in ./Link/deserializer.js
|
|
66
|
+
}
|