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,360 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Add link form.
|
|
3
|
+
* @module components/manage/AnchorPlugin/components/LinkButton/AddLinkForm
|
|
4
|
+
* Customizzato
|
|
5
|
+
* - Aggiunta gestione data-element
|
|
6
|
+
* - Aggiunte opzioni per la select del data-element
|
|
7
|
+
* - Modificate icone ed elementi per stilizzare il tooltip del link
|
|
8
|
+
* - passato l'item selezionato, oltre alla sua url, nella onchange
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import React, { Component } from 'react';
|
|
12
|
+
import PropTypes from 'prop-types';
|
|
13
|
+
import { compose } from 'redux';
|
|
14
|
+
|
|
15
|
+
import cx from 'classnames';
|
|
16
|
+
import {
|
|
17
|
+
addAppURL,
|
|
18
|
+
isInternalURL,
|
|
19
|
+
flattenToAppURL,
|
|
20
|
+
URLUtils,
|
|
21
|
+
} from '@plone/volto/helpers';
|
|
22
|
+
|
|
23
|
+
import { doesNodeContainClick } from 'semantic-ui-react/dist/commonjs/lib';
|
|
24
|
+
import { Input, Form, Button } from 'semantic-ui-react';
|
|
25
|
+
import { defineMessages, injectIntl } from 'react-intl';
|
|
26
|
+
|
|
27
|
+
import clearSVG from '@plone/volto/icons/clear.svg';
|
|
28
|
+
import navTreeSVG from '@plone/volto/icons/nav.svg';
|
|
29
|
+
import aheadSVG from '@plone/volto/icons/ahead.svg';
|
|
30
|
+
|
|
31
|
+
import withObjectBrowser from '@plone/volto/components/manage/Sidebar/ObjectBrowser';
|
|
32
|
+
import { withRouter } from 'react-router';
|
|
33
|
+
|
|
34
|
+
import { Icon, SelectWidget } from '@plone/volto/components';
|
|
35
|
+
|
|
36
|
+
const messages = defineMessages({
|
|
37
|
+
placeholder: {
|
|
38
|
+
id: 'Enter URL or select an item',
|
|
39
|
+
defaultMessage: 'Enter URL or select an item',
|
|
40
|
+
},
|
|
41
|
+
placeholderLighthouse: {
|
|
42
|
+
id: 'Select a data-element ID',
|
|
43
|
+
defaultMessage: 'Seleziona un data-element ID', // TO DO: da sistemare quando si risolve il bug su i18n
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Add link form class.
|
|
49
|
+
* @class AddLinkForm
|
|
50
|
+
* @extends Component
|
|
51
|
+
*/
|
|
52
|
+
class AddLinkForm extends Component {
|
|
53
|
+
static propTypes = {
|
|
54
|
+
onChangeValue: PropTypes.func.isRequired,
|
|
55
|
+
onClear: PropTypes.func.isRequired,
|
|
56
|
+
onOverrideContent: PropTypes.func.isRequired,
|
|
57
|
+
theme: PropTypes.objectOf(PropTypes.any).isRequired,
|
|
58
|
+
openObjectBrowser: PropTypes.func.isRequired,
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Constructor
|
|
63
|
+
* @method constructor
|
|
64
|
+
* @param {Object} props Component properties
|
|
65
|
+
* @constructs AddLinkForm
|
|
66
|
+
*/
|
|
67
|
+
constructor(props) {
|
|
68
|
+
super(props);
|
|
69
|
+
|
|
70
|
+
this.state = {
|
|
71
|
+
dataElement: props.data.dataElement,
|
|
72
|
+
value: isInternalURL(props.data.url)
|
|
73
|
+
? flattenToAppURL(props.data.url)
|
|
74
|
+
: props.data.url || '',
|
|
75
|
+
item: null,
|
|
76
|
+
isInvalid: false,
|
|
77
|
+
};
|
|
78
|
+
this.onRef = this.onRef.bind(this);
|
|
79
|
+
this.onChange = this.onChange.bind(this);
|
|
80
|
+
this.onKeyDown = this.onKeyDown.bind(this);
|
|
81
|
+
this.onSubmit = this.onSubmit.bind(this);
|
|
82
|
+
|
|
83
|
+
// Options to data-element select
|
|
84
|
+
this.selectOptions = [
|
|
85
|
+
['appointment-booking', 'appointment-booking'],
|
|
86
|
+
['service-booking-access', 'service-booking-access'],
|
|
87
|
+
['faq', 'faq'],
|
|
88
|
+
['report-inefficiency', 'report-inefficiency'],
|
|
89
|
+
['accessibility-link', 'accessibility-link'],
|
|
90
|
+
['privacy-policy-link', 'privacy-policy-link'],
|
|
91
|
+
['legal-notes', 'legal-notes'],
|
|
92
|
+
];
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Component did mount
|
|
97
|
+
* @method componentDidMount
|
|
98
|
+
* @returns {undefined}
|
|
99
|
+
*/
|
|
100
|
+
componentDidMount() {
|
|
101
|
+
setTimeout(() => {
|
|
102
|
+
if (this.input) {
|
|
103
|
+
return this.input.focus();
|
|
104
|
+
}
|
|
105
|
+
return null;
|
|
106
|
+
}, 50);
|
|
107
|
+
document.addEventListener('mousedown', this.handleClickOutside, false);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
componentWillUnmount() {
|
|
111
|
+
document.removeEventListener('mousedown', this.handleClickOutside, false);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
handleClickOutside = (e) => {
|
|
115
|
+
if (
|
|
116
|
+
this.linkFormContainer.current &&
|
|
117
|
+
doesNodeContainClick(this.linkFormContainer.current, e)
|
|
118
|
+
)
|
|
119
|
+
return;
|
|
120
|
+
if (this.linkFormContainer.current && this.props.isObjectBrowserOpen)
|
|
121
|
+
return;
|
|
122
|
+
this.onClose();
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Ref handler
|
|
127
|
+
* @method onRef
|
|
128
|
+
* @param {Object} node Node
|
|
129
|
+
* @returns {undefined}
|
|
130
|
+
*/
|
|
131
|
+
onRef(node) {
|
|
132
|
+
this.input = node;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
linkFormContainer = React.createRef();
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Change handler
|
|
139
|
+
* @method onChange
|
|
140
|
+
* @param {Object} value Value
|
|
141
|
+
* @returns {undefined}
|
|
142
|
+
*/
|
|
143
|
+
onChange(value, clear, item) {
|
|
144
|
+
let nextState = { value, item };
|
|
145
|
+
if (!clear) {
|
|
146
|
+
if (
|
|
147
|
+
this.state.isInvalid &&
|
|
148
|
+
URLUtils.isUrl(URLUtils.normalizeUrl(value))
|
|
149
|
+
) {
|
|
150
|
+
nextState.isInvalid = false;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (isInternalURL(value)) {
|
|
154
|
+
nextState = { value: flattenToAppURL(value), item };
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
this.setState(nextState);
|
|
158
|
+
|
|
159
|
+
if (clear) this.clear();
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Clear handler
|
|
164
|
+
* @method clear
|
|
165
|
+
* @param {Object} value Value
|
|
166
|
+
* @returns {undefined}
|
|
167
|
+
*/
|
|
168
|
+
clear() {
|
|
169
|
+
const nextState = { value: '', item: null };
|
|
170
|
+
this.setState(nextState);
|
|
171
|
+
|
|
172
|
+
this.props.onClear();
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Close handler
|
|
177
|
+
* @method onClose
|
|
178
|
+
* @returns {undefined}
|
|
179
|
+
*/
|
|
180
|
+
onClose = () => this.props.onOverrideContent(undefined);
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Keydown handler
|
|
184
|
+
* @method onKeyDown
|
|
185
|
+
* @param {Object} e Event object
|
|
186
|
+
* @returns {undefined}
|
|
187
|
+
*/
|
|
188
|
+
onKeyDown(e) {
|
|
189
|
+
if (e.key === 'Enter') {
|
|
190
|
+
e.preventDefault();
|
|
191
|
+
e.stopPropagation();
|
|
192
|
+
this.onSubmit();
|
|
193
|
+
} else if (e.key === 'Escape') {
|
|
194
|
+
e.preventDefault();
|
|
195
|
+
this.onClose();
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Submit handler
|
|
201
|
+
* @method onSubmit
|
|
202
|
+
* @returns {undefined}
|
|
203
|
+
*/
|
|
204
|
+
onSubmit() {
|
|
205
|
+
let { value: url, dataElement, item } = this.state;
|
|
206
|
+
|
|
207
|
+
const checkedURL = URLUtils.checkAndNormalizeUrl(url);
|
|
208
|
+
url = checkedURL.url;
|
|
209
|
+
if (!checkedURL.isValid) {
|
|
210
|
+
this.setState({ isInvalid: true });
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
const editorStateUrl = isInternalURL(url) ? addAppURL(url) : url;
|
|
215
|
+
|
|
216
|
+
this.props.onChangeValue(editorStateUrl, dataElement, item);
|
|
217
|
+
this.onClose();
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Render method.
|
|
222
|
+
* @method render
|
|
223
|
+
* @returns {string} Markup for the component.
|
|
224
|
+
*/
|
|
225
|
+
render() {
|
|
226
|
+
const { value, isInvalid, dataElement } = this.state;
|
|
227
|
+
const className = isInvalid
|
|
228
|
+
? cx(
|
|
229
|
+
'ui input editor-link',
|
|
230
|
+
'input-anchorlink-theme',
|
|
231
|
+
'input-anchorlink-theme-Invalid',
|
|
232
|
+
)
|
|
233
|
+
: cx('ui input editor-link', 'input-anchorlink-theme');
|
|
234
|
+
|
|
235
|
+
return (
|
|
236
|
+
<div className="link-form-container" ref={this.linkFormContainer}>
|
|
237
|
+
<div
|
|
238
|
+
style={{ marginLeft: '5px', display: 'flex', alignItems: 'center' }}
|
|
239
|
+
>
|
|
240
|
+
<svg
|
|
241
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
242
|
+
width="24"
|
|
243
|
+
height="24"
|
|
244
|
+
viewBox="0 0 36 36"
|
|
245
|
+
fill="#B8B2C8"
|
|
246
|
+
>
|
|
247
|
+
<g fillRule="evenodd">
|
|
248
|
+
<path d="M27.1318,7.333 C24.4028,4.604 19.9618,4.604 17.2328,7.333 L12.9898,11.576 C11.8428,12.723 11.1288,14.248 10.9778,15.871 C10.8228,17.541 11.2708,19.211 12.2378,20.576 C12.4818,20.919 12.7278,21.213 12.9888,21.475 C13.7848,22.271 14.7778,22.868 15.8608,23.202 C16.5498,23.415 17.2548,23.519 17.9518,23.518 C19.7808,23.518 21.5598,22.804 22.8888,21.475 L23.9498,20.414 L22.5358,19 L21.4748,20.061 C20.1648,21.371 18.2388,21.842 16.4498,21.291 C15.6668,21.049 14.9778,20.635 14.4038,20.061 C14.2218,19.879 14.0478,19.668 13.8698,19.418 C13.1778,18.443 12.8588,17.249 12.9688,16.056 C13.0768,14.896 13.5868,13.808 14.4038,12.99 L18.6468,8.747 C20.5958,6.798 23.7688,6.798 25.7178,8.747 C26.6568,9.687 27.1748,10.942 27.1748,12.283 C27.1748,13.623 26.6568,14.878 25.7178,15.818 L27.1318,17.232 C28.4488,15.915 29.1748,14.157 29.1748,12.283 C29.1748,10.408 28.4488,8.65 27.1318,7.333" />
|
|
249
|
+
<path d="M25.0107,16.5254 C24.2147,15.7294 23.2217,15.1324 22.1387,14.7984 C19.6417,14.0284 16.9477,14.6894 15.1107,16.5254 L14.0507,17.5864 L15.4647,19.0004 L16.5247,17.9394 C17.8357,16.6294 19.7587,16.1554 21.5497,16.7094 C22.3337,16.9514 23.0217,17.3644 23.5957,17.9394 C23.7777,18.1214 23.9527,18.3314 24.1307,18.5824 C24.8217,19.5564 25.1417,20.7514 25.0317,21.9444 C24.9237,23.1034 24.4137,24.1924 23.5957,25.0104 L19.3537,29.2534 C17.4047,31.2024 14.2317,31.2024 12.2817,29.2534 C11.3427,28.3134 10.8247,27.0574 10.8247,25.7174 C10.8247,24.3774 11.3427,23.1214 12.2817,22.1824 L10.8677,20.7684 C9.5507,22.0854 8.8247,23.8424 8.8247,25.7174 C8.8247,27.5924 9.5507,29.3504 10.8677,30.6674 C12.2327,32.0314 14.0257,32.7134 15.8177,32.7134 C17.6107,32.7134 19.4027,32.0314 20.7677,30.6674 L25.0107,26.4244 C26.1567,25.2774 26.8717,23.7524 27.0227,22.1294 C27.1777,20.4594 26.7297,18.7894 25.7617,17.4244 C25.5177,17.0814 25.2717,16.7874 25.0107,16.5254" />
|
|
250
|
+
</g>
|
|
251
|
+
</svg>
|
|
252
|
+
<Form.Field>
|
|
253
|
+
<div className="wrapper-fields">
|
|
254
|
+
{/* INPUT LINK */}
|
|
255
|
+
<div className="wrap-field">
|
|
256
|
+
<Input
|
|
257
|
+
className={className}
|
|
258
|
+
id={`field-link`}
|
|
259
|
+
name="link"
|
|
260
|
+
value={value || ''}
|
|
261
|
+
onChange={({ target }) => this.onChange(target.value)}
|
|
262
|
+
placeholder={this.props.intl.formatMessage(
|
|
263
|
+
messages.placeholder,
|
|
264
|
+
)}
|
|
265
|
+
onKeyDown={this.onKeyDown}
|
|
266
|
+
ref={this.onRef}
|
|
267
|
+
/>
|
|
268
|
+
{value.length > 0 ? (
|
|
269
|
+
<Button.Group>
|
|
270
|
+
<Button
|
|
271
|
+
basic
|
|
272
|
+
className="cancel"
|
|
273
|
+
onClick={(e) => {
|
|
274
|
+
e.preventDefault();
|
|
275
|
+
e.stopPropagation();
|
|
276
|
+
this.clear();
|
|
277
|
+
}}
|
|
278
|
+
>
|
|
279
|
+
<Icon name={clearSVG} size="20px" />
|
|
280
|
+
</Button>
|
|
281
|
+
</Button.Group>
|
|
282
|
+
) : (
|
|
283
|
+
<Button.Group>
|
|
284
|
+
<Button
|
|
285
|
+
basic
|
|
286
|
+
icon
|
|
287
|
+
onClick={(e) => {
|
|
288
|
+
e.preventDefault();
|
|
289
|
+
e.stopPropagation();
|
|
290
|
+
|
|
291
|
+
this.props.openObjectBrowser({
|
|
292
|
+
mode: 'link',
|
|
293
|
+
overlay: true,
|
|
294
|
+
onSelectItem: (url, item) => {
|
|
295
|
+
this.onChange(url, null, item);
|
|
296
|
+
this.onSubmit();
|
|
297
|
+
},
|
|
298
|
+
});
|
|
299
|
+
}}
|
|
300
|
+
>
|
|
301
|
+
<Icon
|
|
302
|
+
name={navTreeSVG}
|
|
303
|
+
size="22px"
|
|
304
|
+
pointer-events="none"
|
|
305
|
+
/>
|
|
306
|
+
</Button>
|
|
307
|
+
</Button.Group>
|
|
308
|
+
)}
|
|
309
|
+
</div>
|
|
310
|
+
|
|
311
|
+
{/* DATA-ELEMENT SELECT */}
|
|
312
|
+
<div className="wrap-field">
|
|
313
|
+
<SelectWidget
|
|
314
|
+
id="data-element-select"
|
|
315
|
+
title="data-element"
|
|
316
|
+
placeholder={this.props.intl.formatMessage(
|
|
317
|
+
messages.placeholderLighthouse,
|
|
318
|
+
)}
|
|
319
|
+
isMulti={false}
|
|
320
|
+
value={dataElement}
|
|
321
|
+
onChange={(_, value) => {
|
|
322
|
+
this.setState({ dataElement: value });
|
|
323
|
+
}}
|
|
324
|
+
choices={this.selectOptions}
|
|
325
|
+
noValueOption={false}
|
|
326
|
+
wrapped={false}
|
|
327
|
+
/>
|
|
328
|
+
</div>
|
|
329
|
+
</div>
|
|
330
|
+
|
|
331
|
+
{/* BUTTON SUBMIT */}
|
|
332
|
+
<div className="wrapper-submit">
|
|
333
|
+
<Button.Group>
|
|
334
|
+
<Button
|
|
335
|
+
basic
|
|
336
|
+
primary
|
|
337
|
+
disabled={!value.length > 0}
|
|
338
|
+
onClick={(e) => {
|
|
339
|
+
e.preventDefault();
|
|
340
|
+
e.stopPropagation();
|
|
341
|
+
this.onSubmit();
|
|
342
|
+
}}
|
|
343
|
+
onKeyDown={(e) => {
|
|
344
|
+
e.preventDefault();
|
|
345
|
+
e.stopPropagation();
|
|
346
|
+
this.onSubmit();
|
|
347
|
+
}}
|
|
348
|
+
>
|
|
349
|
+
<Icon name={aheadSVG} size="28px" />
|
|
350
|
+
</Button>
|
|
351
|
+
</Button.Group>
|
|
352
|
+
</div>
|
|
353
|
+
</Form.Field>
|
|
354
|
+
</div>
|
|
355
|
+
</div>
|
|
356
|
+
);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
export default compose(injectIntl, withRouter, withObjectBrowser)(AddLinkForm);
|