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.
- 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/install-state.gz +0 -0
- package/CHANGELOG.md +878 -904
- 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 +4 -2
- 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,169 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useSlate } from 'slate-react';
|
|
3
|
+
import { Dropdown } from 'semantic-ui-react';
|
|
4
|
+
import { useIntl, defineMessages } from 'react-intl';
|
|
5
|
+
import cx from 'classnames';
|
|
6
|
+
import { omit } from 'lodash';
|
|
7
|
+
import {
|
|
8
|
+
isBlockStyleActive,
|
|
9
|
+
toggleStyle,
|
|
10
|
+
} from 'design-comuni-plone-theme/config/Slate/dropdownUtils';
|
|
11
|
+
|
|
12
|
+
import { Icon } from '@plone/volto/components';
|
|
13
|
+
import { ToolbarButton } from '@plone/volto-slate/editor/ui';
|
|
14
|
+
|
|
15
|
+
import alignCenterSVG from '@plone/volto/icons/align-center.svg';
|
|
16
|
+
import alignLeftSVG from '@plone/volto/icons/align-left.svg';
|
|
17
|
+
import alignRightSVG from '@plone/volto/icons/align-right.svg';
|
|
18
|
+
import alignJustifySVG from '@plone/volto/icons/align-justify.svg';
|
|
19
|
+
|
|
20
|
+
import 'design-comuni-plone-theme/config/Slate/dropdownStyle.scss';
|
|
21
|
+
|
|
22
|
+
const messages = defineMessages({
|
|
23
|
+
align: {
|
|
24
|
+
id: 'Allineamento',
|
|
25
|
+
defaultMessage: 'Allineamento',
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
align_left: {
|
|
29
|
+
id: 'Allinea a sinistra',
|
|
30
|
+
defaultMessage: 'Allinea a sinistra',
|
|
31
|
+
},
|
|
32
|
+
align_center: {
|
|
33
|
+
id: 'Allinea al centro',
|
|
34
|
+
defaultMessage: 'Allinea al centro',
|
|
35
|
+
},
|
|
36
|
+
align_right: {
|
|
37
|
+
id: 'Allinea a destra',
|
|
38
|
+
defaultMessage: 'Allinea a destra',
|
|
39
|
+
},
|
|
40
|
+
align_justify: {
|
|
41
|
+
id: 'Allinea il testo giustificato',
|
|
42
|
+
defaultMessage: 'Allinea il testo giustificato',
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const ALIGN_OPTIONS = [
|
|
47
|
+
{
|
|
48
|
+
cssClass: 'text-left',
|
|
49
|
+
title: messages.align_left,
|
|
50
|
+
icon: alignLeftSVG,
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
cssClass: 'text-center',
|
|
54
|
+
title: messages.align_center,
|
|
55
|
+
icon: alignCenterSVG,
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
cssClass: 'text-end',
|
|
59
|
+
title: messages.align_right,
|
|
60
|
+
icon: alignRightSVG,
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
cssClass: 'text-justify',
|
|
64
|
+
title: messages.align_justify,
|
|
65
|
+
icon: alignJustifySVG,
|
|
66
|
+
},
|
|
67
|
+
];
|
|
68
|
+
|
|
69
|
+
const AlignMenuButton = ({ icon, active, ...props }) => {
|
|
70
|
+
return (
|
|
71
|
+
<ToolbarButton
|
|
72
|
+
{...props}
|
|
73
|
+
icon={icon}
|
|
74
|
+
active={active}
|
|
75
|
+
onMouseDown={() => {}}
|
|
76
|
+
/>
|
|
77
|
+
);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const MenuOpts = ({ editor, toSelect, option, type }) => {
|
|
81
|
+
const isActive = toSelect.includes(option);
|
|
82
|
+
|
|
83
|
+
return (
|
|
84
|
+
<Dropdown.Item
|
|
85
|
+
as="span"
|
|
86
|
+
active={isActive}
|
|
87
|
+
className={cx(`${type}-${option.value}`, { active: isActive })}
|
|
88
|
+
{...omit(option, ['isBlock', 'originalIcon'])}
|
|
89
|
+
data-isblock={option.isBlock}
|
|
90
|
+
onClick={(event, selItem) => {
|
|
91
|
+
toggleStyle(editor, {
|
|
92
|
+
cssClass: selItem.value,
|
|
93
|
+
isBlock: true,
|
|
94
|
+
oneOf: ALIGN_OPTIONS.reduce((acc, o) => [...acc, o.cssClass], []),
|
|
95
|
+
});
|
|
96
|
+
}}
|
|
97
|
+
/>
|
|
98
|
+
);
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const AlignButton = (props) => {
|
|
102
|
+
const editor = useSlate();
|
|
103
|
+
const intl = useIntl();
|
|
104
|
+
|
|
105
|
+
const blockOpts = ALIGN_OPTIONS.map((def) => {
|
|
106
|
+
return {
|
|
107
|
+
value: def.cssClass,
|
|
108
|
+
text: def.text,
|
|
109
|
+
title: intl.formatMessage(def.title),
|
|
110
|
+
icon: (props) => <Icon name={def.icon} size="24px" />,
|
|
111
|
+
isBlock: true,
|
|
112
|
+
originalIcon: def.icon,
|
|
113
|
+
};
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
// Calculating the initial selection.
|
|
117
|
+
const toSelect = [];
|
|
118
|
+
let selectedIcon = ALIGN_OPTIONS[0].icon;
|
|
119
|
+
|
|
120
|
+
// block styles
|
|
121
|
+
for (const val of blockOpts) {
|
|
122
|
+
const ia = isBlockStyleActive(editor, val.value);
|
|
123
|
+
|
|
124
|
+
if (ia) {
|
|
125
|
+
toSelect.push(val);
|
|
126
|
+
selectedIcon = val.originalIcon;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const menuItemProps = {
|
|
131
|
+
toSelect,
|
|
132
|
+
editor,
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
return (
|
|
136
|
+
<Dropdown
|
|
137
|
+
id="align-menu"
|
|
138
|
+
pointing="top left"
|
|
139
|
+
multiple
|
|
140
|
+
value={toSelect}
|
|
141
|
+
additionLabel={intl.formatMessage(messages.align)}
|
|
142
|
+
trigger={
|
|
143
|
+
<AlignMenuButton
|
|
144
|
+
title={intl.formatMessage(messages.align)}
|
|
145
|
+
icon={selectedIcon}
|
|
146
|
+
active={toSelect.length > 0}
|
|
147
|
+
/>
|
|
148
|
+
}
|
|
149
|
+
onMouseDown={(e) => {
|
|
150
|
+
e.preventDefault();
|
|
151
|
+
e.stopPropagation();
|
|
152
|
+
}}
|
|
153
|
+
>
|
|
154
|
+
<Dropdown.Menu>
|
|
155
|
+
{blockOpts.length &&
|
|
156
|
+
blockOpts.map((option, index) => (
|
|
157
|
+
<MenuOpts
|
|
158
|
+
{...menuItemProps}
|
|
159
|
+
type="block-align"
|
|
160
|
+
option={option}
|
|
161
|
+
key={index}
|
|
162
|
+
/>
|
|
163
|
+
))}
|
|
164
|
+
</Dropdown.Menu>
|
|
165
|
+
</Dropdown>
|
|
166
|
+
);
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
export default AlignButton;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useIntl, defineMessages } from 'react-intl';
|
|
3
|
+
import AlignMenu from './AlignMenu';
|
|
4
|
+
|
|
5
|
+
const messages = defineMessages({
|
|
6
|
+
align: {
|
|
7
|
+
id: 'Allineamento',
|
|
8
|
+
defaultMessage: 'Allineamento',
|
|
9
|
+
},
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
export const AlignElement = ({ attributes, children, element }) => {
|
|
13
|
+
return (
|
|
14
|
+
<p {...attributes} align="test">
|
|
15
|
+
{children}
|
|
16
|
+
</p>
|
|
17
|
+
);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const AlignButton = (props) => {
|
|
21
|
+
const intl = useIntl();
|
|
22
|
+
return <AlignMenu {...props} title={intl.formatMessage(messages.align)} />;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export default function install(config) {
|
|
26
|
+
const { slate } = config.settings;
|
|
27
|
+
|
|
28
|
+
slate.buttons.align = AlignButton;
|
|
29
|
+
|
|
30
|
+
slate.elements['align'] = AlignElement;
|
|
31
|
+
|
|
32
|
+
//lo metto come primo elemento della toolbar
|
|
33
|
+
slate.toolbarButtons = ['align', 'separator', ...slate.toolbarButtons];
|
|
34
|
+
slate.expandedToolbarButtons = [
|
|
35
|
+
'align',
|
|
36
|
+
'separator',
|
|
37
|
+
...slate.expandedToolbarButtons,
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
//il deserializer html per aggiungere le classi è definito in deserializers.js
|
|
41
|
+
return config;
|
|
42
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useSlate } from 'slate-react';
|
|
3
|
+
import { Dropdown } from 'semantic-ui-react';
|
|
4
|
+
import { useIntl, defineMessages } from 'react-intl';
|
|
5
|
+
import cx from 'classnames';
|
|
6
|
+
import { omit } from 'lodash';
|
|
7
|
+
import {
|
|
8
|
+
isBlockStyleActive,
|
|
9
|
+
toggleStyle,
|
|
10
|
+
} from 'design-comuni-plone-theme/config/Slate/dropdownUtils';
|
|
11
|
+
|
|
12
|
+
import { Icon } from '@plone/volto/components';
|
|
13
|
+
import { ToolbarButton } from '@plone/volto-slate/editor/ui';
|
|
14
|
+
|
|
15
|
+
import blockquoteSimpleIcon from 'design-comuni-plone-theme/icons/blockquote-simple.svg';
|
|
16
|
+
import blockquoteCardIcon from 'design-comuni-plone-theme/icons/blockquote-card.svg';
|
|
17
|
+
import blockquoteCardDarkIcon from 'design-comuni-plone-theme/icons/blockquote-card-dark.svg';
|
|
18
|
+
|
|
19
|
+
import 'design-comuni-plone-theme/config/Slate/dropdownStyle.scss';
|
|
20
|
+
|
|
21
|
+
const OPTIONS = [
|
|
22
|
+
{
|
|
23
|
+
title: 'Blockquote semplice',
|
|
24
|
+
format: 'blockquote',
|
|
25
|
+
icon: blockquoteSimpleIcon,
|
|
26
|
+
cssClass: 'blockquote',
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
title: 'Blockquote card',
|
|
30
|
+
format: 'blockquote',
|
|
31
|
+
icon: blockquoteCardIcon,
|
|
32
|
+
cssClass: 'blockquote-card',
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
title: 'Blockquote card scuro',
|
|
36
|
+
format: 'blockquote',
|
|
37
|
+
icon: blockquoteCardDarkIcon,
|
|
38
|
+
cssClass: 'blockquote-card dark',
|
|
39
|
+
},
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
const messages = defineMessages({
|
|
43
|
+
blockquote: {
|
|
44
|
+
id: 'Blockquote',
|
|
45
|
+
defaultMessage: 'Blockquote',
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
const BlockquoteMenuButton = ({ icon, active, ...props }) => (
|
|
50
|
+
<ToolbarButton {...props} icon={icon} active={active} />
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
const MenuOpts = ({ editor, toSelect, option, type, ...props }) => {
|
|
54
|
+
const isActive = toSelect.includes(option);
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<Dropdown.Item
|
|
58
|
+
as="span"
|
|
59
|
+
active={isActive}
|
|
60
|
+
className={cx(`${type}-${option.value}`, { active: isActive })}
|
|
61
|
+
{...omit(option, ['isBlock', 'originalIcon'])}
|
|
62
|
+
data-isblock={option.isBlock}
|
|
63
|
+
onClick={(event, selItem) => {
|
|
64
|
+
toggleStyle(editor, {
|
|
65
|
+
cssClass: selItem.value,
|
|
66
|
+
isBlock: true,
|
|
67
|
+
format: selItem.format,
|
|
68
|
+
allowedChildren: props.allowedChildren,
|
|
69
|
+
oneOf: OPTIONS.reduce((acc, o) => [...acc, o.cssClass], []),
|
|
70
|
+
});
|
|
71
|
+
}}
|
|
72
|
+
/>
|
|
73
|
+
);
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const BlockquoteButton = (props) => {
|
|
77
|
+
const editor = useSlate();
|
|
78
|
+
const intl = useIntl();
|
|
79
|
+
|
|
80
|
+
const blockOpts = OPTIONS.map((def) => {
|
|
81
|
+
return {
|
|
82
|
+
value: def.cssClass,
|
|
83
|
+
text: def.text,
|
|
84
|
+
title: def.title,
|
|
85
|
+
format: def.format,
|
|
86
|
+
icon: (props) => <Icon name={def.icon} size="24px" />,
|
|
87
|
+
isBlock: true,
|
|
88
|
+
originalIcon: def.icon,
|
|
89
|
+
};
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
// Calculating the initial selection.
|
|
93
|
+
const toSelect = [];
|
|
94
|
+
let selectedIcon = blockquoteCardIcon;
|
|
95
|
+
|
|
96
|
+
const oneOf = OPTIONS.reduce((acc, o) => [...acc, o.cssClass], []);
|
|
97
|
+
// block styles
|
|
98
|
+
for (const val of blockOpts) {
|
|
99
|
+
const ia = isBlockStyleActive(editor, val.value, oneOf);
|
|
100
|
+
|
|
101
|
+
if (ia) {
|
|
102
|
+
toSelect.push(val);
|
|
103
|
+
selectedIcon = val.originalIcon;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const menuItemProps = {
|
|
108
|
+
toSelect,
|
|
109
|
+
editor,
|
|
110
|
+
...props,
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
const showMenu = blockOpts.length;
|
|
114
|
+
|
|
115
|
+
return showMenu ? (
|
|
116
|
+
<Dropdown
|
|
117
|
+
id="blockquote-menu"
|
|
118
|
+
pointing="top left"
|
|
119
|
+
multiple
|
|
120
|
+
value={toSelect}
|
|
121
|
+
additionLabel={intl.formatMessage(messages.blockquote)}
|
|
122
|
+
trigger={
|
|
123
|
+
<BlockquoteMenuButton
|
|
124
|
+
title={intl.formatMessage(messages.blockquote)}
|
|
125
|
+
icon={selectedIcon}
|
|
126
|
+
active={toSelect.length > 0}
|
|
127
|
+
/>
|
|
128
|
+
}
|
|
129
|
+
onMouseDown={(e) => {
|
|
130
|
+
e.preventDefault();
|
|
131
|
+
e.stopPropagation();
|
|
132
|
+
}}
|
|
133
|
+
>
|
|
134
|
+
<Dropdown.Menu>
|
|
135
|
+
{blockOpts.length &&
|
|
136
|
+
blockOpts.map((option, index) => (
|
|
137
|
+
<MenuOpts
|
|
138
|
+
{...menuItemProps}
|
|
139
|
+
type="block-blockquote"
|
|
140
|
+
option={option}
|
|
141
|
+
key={index}
|
|
142
|
+
/>
|
|
143
|
+
))}
|
|
144
|
+
</Dropdown.Menu>
|
|
145
|
+
</Dropdown>
|
|
146
|
+
) : (
|
|
147
|
+
''
|
|
148
|
+
);
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
export default BlockquoteButton;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import BlockquoteMenu from './BlockquoteMenu';
|
|
3
|
+
|
|
4
|
+
export default function install(config) {
|
|
5
|
+
const { slate } = config.settings;
|
|
6
|
+
|
|
7
|
+
slate.buttons.blockquote = (props) => (
|
|
8
|
+
<BlockquoteMenu {...props} title="Blockquote" />
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
return config;
|
|
12
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useSlate } from 'slate-react';
|
|
3
|
+
import { Dropdown } from 'semantic-ui-react';
|
|
4
|
+
import { useIntl, defineMessages } from 'react-intl';
|
|
5
|
+
import cx from 'classnames';
|
|
6
|
+
import { omit } from 'lodash';
|
|
7
|
+
import config from '@plone/volto/registry';
|
|
8
|
+
import { isBlockActive } from '@plone/volto-slate/utils';
|
|
9
|
+
|
|
10
|
+
import { ToolbarButton, BlockButton } from '@plone/volto-slate/editor/ui';
|
|
11
|
+
|
|
12
|
+
import headingIcon from '@plone/volto/icons/heading.svg';
|
|
13
|
+
|
|
14
|
+
import 'design-comuni-plone-theme/config/Slate/dropdownStyle.scss';
|
|
15
|
+
import 'design-comuni-plone-theme/config/Slate/Headings/headingsMenu.scss';
|
|
16
|
+
|
|
17
|
+
const OPTIONS = [
|
|
18
|
+
{
|
|
19
|
+
title: 'h2',
|
|
20
|
+
format: 'h2',
|
|
21
|
+
content: 'h2',
|
|
22
|
+
className: 'headings-h2',
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
title: 'h3',
|
|
26
|
+
format: 'h3',
|
|
27
|
+
content: 'h3',
|
|
28
|
+
className: 'headings-h3',
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
title: 'h4',
|
|
32
|
+
format: 'h4',
|
|
33
|
+
content: 'h4',
|
|
34
|
+
className: 'headings-h4',
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
title: 'h5',
|
|
38
|
+
format: 'h5',
|
|
39
|
+
content: 'h5',
|
|
40
|
+
className: 'headings-h5',
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
title: 'h6',
|
|
44
|
+
format: 'h6',
|
|
45
|
+
content: 'h6',
|
|
46
|
+
className: 'headings-h6',
|
|
47
|
+
},
|
|
48
|
+
];
|
|
49
|
+
|
|
50
|
+
const messages = defineMessages({
|
|
51
|
+
title: {
|
|
52
|
+
id: 'Titolo',
|
|
53
|
+
defaultMessage: 'Titolo',
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
const HeadingsMenuButton = ({ icon, active, ...props }) => (
|
|
58
|
+
<ToolbarButton {...props} icon={icon} active={active} />
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
const MenuOpts = ({ editor, toSelect, option, type }) => {
|
|
62
|
+
const isActive = toSelect.includes(option);
|
|
63
|
+
return (
|
|
64
|
+
<Dropdown.Item
|
|
65
|
+
as="span"
|
|
66
|
+
active={isActive}
|
|
67
|
+
className={cx(`${type}-${option.format}`, {
|
|
68
|
+
active: isActive,
|
|
69
|
+
})}
|
|
70
|
+
>
|
|
71
|
+
<BlockButton
|
|
72
|
+
{...omit(option, ['isBlock'])}
|
|
73
|
+
data-isblock={option.isBlock}
|
|
74
|
+
allowedChildren={config.settings.slate.allowedHeadlineElements}
|
|
75
|
+
/>
|
|
76
|
+
</Dropdown.Item>
|
|
77
|
+
);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const HeadingsButton = (props) => {
|
|
81
|
+
const editor = useSlate();
|
|
82
|
+
const intl = useIntl();
|
|
83
|
+
|
|
84
|
+
// Calculating the initial selection.
|
|
85
|
+
const toSelect = [];
|
|
86
|
+
|
|
87
|
+
// block styles
|
|
88
|
+
for (const opt of OPTIONS) {
|
|
89
|
+
const ia = isBlockActive(editor, opt.format);
|
|
90
|
+
|
|
91
|
+
if (ia) {
|
|
92
|
+
toSelect.push(opt);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const menuItemProps = {
|
|
97
|
+
toSelect,
|
|
98
|
+
editor,
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const showMenu = OPTIONS.length;
|
|
102
|
+
|
|
103
|
+
return showMenu ? (
|
|
104
|
+
<Dropdown
|
|
105
|
+
id="headings-menu"
|
|
106
|
+
pointing="top left"
|
|
107
|
+
multiple
|
|
108
|
+
value={toSelect}
|
|
109
|
+
additionLabel={intl.formatMessage(messages.title)}
|
|
110
|
+
trigger={
|
|
111
|
+
<HeadingsMenuButton
|
|
112
|
+
title={intl.formatMessage(messages.title)}
|
|
113
|
+
icon={headingIcon}
|
|
114
|
+
active={toSelect.length > 0}
|
|
115
|
+
/>
|
|
116
|
+
}
|
|
117
|
+
onMouseDown={(e) => {
|
|
118
|
+
e.preventDefault();
|
|
119
|
+
e.stopPropagation();
|
|
120
|
+
}}
|
|
121
|
+
>
|
|
122
|
+
<Dropdown.Menu>
|
|
123
|
+
{OPTIONS.length > 0 &&
|
|
124
|
+
OPTIONS.map((option, index) => (
|
|
125
|
+
<MenuOpts
|
|
126
|
+
{...menuItemProps}
|
|
127
|
+
type="headings"
|
|
128
|
+
option={option}
|
|
129
|
+
key={index}
|
|
130
|
+
/>
|
|
131
|
+
))}
|
|
132
|
+
</Dropdown.Menu>
|
|
133
|
+
</Dropdown>
|
|
134
|
+
) : (
|
|
135
|
+
''
|
|
136
|
+
);
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
export default HeadingsButton;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
.slate-toolbar .ui.dropdown#headings-menu .menu {
|
|
2
|
+
.item {
|
|
3
|
+
padding: 0 !important;
|
|
4
|
+
text-align: center;
|
|
5
|
+
.button-wrapper {
|
|
6
|
+
margin: 0;
|
|
7
|
+
.ui.button {
|
|
8
|
+
border: none;
|
|
9
|
+
border-radius: 0;
|
|
10
|
+
padding: 0.78571429rem 1.14285714rem !important;
|
|
11
|
+
|
|
12
|
+
&,
|
|
13
|
+
&.active {
|
|
14
|
+
background-color: transparent !important;
|
|
15
|
+
color: rgba(0, 0, 0, 0.6) !important;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
&.headings-h2 {
|
|
19
|
+
font-size: 2.222rem;
|
|
20
|
+
font-family: 'Titillium Web', Geneva, Tahoma, sans-serif;
|
|
21
|
+
}
|
|
22
|
+
&.headings-h3 {
|
|
23
|
+
font-size: 1.777rem;
|
|
24
|
+
font-family: 'Titillium Web', Geneva, Tahoma, sans-serif;
|
|
25
|
+
}
|
|
26
|
+
&.headings-h4 {
|
|
27
|
+
font-size: 1.555rem;
|
|
28
|
+
font-weight: 600;
|
|
29
|
+
font-family: 'Titillium Web', Geneva, Tahoma, sans-serif;
|
|
30
|
+
}
|
|
31
|
+
&.headings-h5 {
|
|
32
|
+
font-size: 1.333rem;
|
|
33
|
+
font-weight: 400;
|
|
34
|
+
font-family: 'Titillium Web', Geneva, Tahoma, sans-serif;
|
|
35
|
+
}
|
|
36
|
+
&.headings-h6 {
|
|
37
|
+
font-size: 1rem;
|
|
38
|
+
font-weight: 600;
|
|
39
|
+
font-family: 'Titillium Web', Geneva, Tahoma, sans-serif;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import HeadingsMenu from './HeadingsMenu';
|
|
3
|
+
import { insertToolbarButtons } from 'design-comuni-plone-theme/config/Slate/utils';
|
|
4
|
+
import { renderLinkElement } from '@plone/volto-slate/editor/render';
|
|
5
|
+
|
|
6
|
+
export default function install(config) {
|
|
7
|
+
const { slate } = config.settings;
|
|
8
|
+
|
|
9
|
+
slate.buttons.headings = (props) => (
|
|
10
|
+
<HeadingsMenu {...props} title="Titolo" />
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
//sovrascivo gli elements h2,h3,h4 per fare in modo che usino anche le classi di blocco (es allineamento)
|
|
14
|
+
slate.elements['h2'] = ({ attributes, children }) =>
|
|
15
|
+
renderLinkElement('h2')({
|
|
16
|
+
attributes,
|
|
17
|
+
children,
|
|
18
|
+
className: attributes.className,
|
|
19
|
+
});
|
|
20
|
+
slate.elements['h3'] = ({ attributes, children }) =>
|
|
21
|
+
renderLinkElement('h3')({
|
|
22
|
+
attributes,
|
|
23
|
+
children,
|
|
24
|
+
className: attributes.className,
|
|
25
|
+
});
|
|
26
|
+
slate.elements['h4'] = ({ attributes, children }) =>
|
|
27
|
+
renderLinkElement('h4')({
|
|
28
|
+
attributes,
|
|
29
|
+
children,
|
|
30
|
+
className: attributes.className,
|
|
31
|
+
});
|
|
32
|
+
//aggiungo gli elements h5, h6 perchè non previsti da volto
|
|
33
|
+
slate.elements['h5'] = ({ attributes, children }) =>
|
|
34
|
+
renderLinkElement('h5')({
|
|
35
|
+
attributes,
|
|
36
|
+
children,
|
|
37
|
+
className: attributes.className,
|
|
38
|
+
});
|
|
39
|
+
slate.elements['h6'] = ({ attributes, children }) =>
|
|
40
|
+
renderLinkElement('h6')({
|
|
41
|
+
attributes,
|
|
42
|
+
children,
|
|
43
|
+
className: attributes.className,
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// rimuovo i bottoni di heading di volto
|
|
47
|
+
slate.toolbarButtons = slate.toolbarButtons.filter(
|
|
48
|
+
(b) => b !== 'heading-two' && b !== 'heading-three',
|
|
49
|
+
);
|
|
50
|
+
slate.expandedToolbarButtons = slate.expandedToolbarButtons.filter(
|
|
51
|
+
(b) => b !== 'heading-two' && b !== 'heading-three',
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
//aggiungo il bottone di headings alla toolbar, dopo strikethrough
|
|
55
|
+
insertToolbarButtons(
|
|
56
|
+
['separator', 'headings', 'separator'],
|
|
57
|
+
'strikethrough',
|
|
58
|
+
slate,
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
return config;
|
|
62
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsx } from 'slate-hyperscript';
|
|
2
|
+
import { deserialize } from '@plone/volto-slate/editor/deserialize';
|
|
3
|
+
import { SIMPLELINK } from '@plone/volto-slate/constants';
|
|
4
|
+
|
|
5
|
+
export const simpleLinkDeserializer = (editor, el) => {
|
|
6
|
+
let parent = el;
|
|
7
|
+
|
|
8
|
+
let children = Array.from(parent.childNodes)
|
|
9
|
+
.map((el) => deserialize(editor, el))
|
|
10
|
+
.flat();
|
|
11
|
+
|
|
12
|
+
if (!children.length) children = [{ text: '' }];
|
|
13
|
+
const attrs = {
|
|
14
|
+
type: SIMPLELINK,
|
|
15
|
+
data: {
|
|
16
|
+
url: el.getAttribute('href'),
|
|
17
|
+
dataElement: el.getAttribute('data-element'),
|
|
18
|
+
},
|
|
19
|
+
styleName: el.getAttribute('class'),
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
return jsx('element', attrs, children);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
simpleLinkDeserializer.id = 'simpleLinkDeserializer';
|