@eeacms/volto-eea-website-theme 1.8.1 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +39 -10
- package/package.json +1 -1
- package/src/components/theme/DraftBackground/DraftBackground.jsx +45 -9
- package/src/customizations/@eeacms/volto-eea-design-system/ui/Header/HeaderSearchPopUp.js +14 -7
- package/src/customizations/volto/components/theme/ContactForm/ContactForm.jsx +27 -0
- package/src/customizations/volto/components/theme/Header/Header.jsx +7 -5
- package/src/icons/eraser.svg +3 -0
- package/src/index.js +6 -0
- package/src/slate.js +24 -3
package/CHANGELOG.md
CHANGED
@@ -4,6 +4,45 @@ All notable changes to this project will be documented in this file. Dates are d
|
|
4
4
|
|
5
5
|
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
6
6
|
|
7
|
+
### [1.9.0](https://github.com/eea/volto-eea-website-theme/compare/1.8.2...1.9.0) - 21 February 2023
|
8
|
+
|
9
|
+
#### :rocket: New Features
|
10
|
+
|
11
|
+
- feat(contact-form): Redirect to config.settings.contactForm - refs #160689 [Alin Voinea - [`8d93c76`](https://github.com/eea/volto-eea-website-theme/commit/8d93c76f022d0036a43ff1564189dc49530ca4e1)]
|
12
|
+
|
13
|
+
#### :bug: Bug Fixes
|
14
|
+
|
15
|
+
- fix(dropdown): navigation of links when using the keyboard only [David Ichim - [`1d97367`](https://github.com/eea/volto-eea-website-theme/commit/1d973671a2941ebb1463ba65ae6bbee5447edf1a)]
|
16
|
+
|
17
|
+
#### :nail_care: Enhancements
|
18
|
+
|
19
|
+
- change(language): hide language dropdown by default on eea-website-theme [David Ichim - [`23ba000`](https://github.com/eea/volto-eea-website-theme/commit/23ba000e7c8998c5f1a6f706f706027e95abeb84)]
|
20
|
+
|
21
|
+
#### :hammer_and_wrench: Others
|
22
|
+
|
23
|
+
- Release 1.9.0 [Alin Voinea - [`895e0ae`](https://github.com/eea/volto-eea-website-theme/commit/895e0ae0f6174976a5ad4965274bfebb2c65433f)]
|
24
|
+
### [1.8.2](https://github.com/eea/volto-eea-website-theme/compare/1.8.1...1.8.2) - 14 February 2023
|
25
|
+
|
26
|
+
#### :rocket: New Features
|
27
|
+
|
28
|
+
- feat: use removeTrailingSlash [Mimi - [`2fa8e23`](https://github.com/eea/volto-eea-website-theme/commit/2fa8e23525af589efb13f5b04e52026a97245556)]
|
29
|
+
- feat: compare pathname to contentId to show draft watermark [Mimi - [`de870d8`](https://github.com/eea/volto-eea-website-theme/commit/de870d8be85b7aa64e26697e1e19709c1c4721cb)]
|
30
|
+
- feat: show or remove the draft watermark based on the value from the ENV file [Mimi - [`e5d2ce0`](https://github.com/eea/volto-eea-website-theme/commit/e5d2ce00f865cbe5ddb95030cb8ccd8a609ebf02)]
|
31
|
+
- feat: remove draft image from control panel and login [Mimi - [`274891a`](https://github.com/eea/volto-eea-website-theme/commit/274891a0810102e445813bb59735c56403125895)]
|
32
|
+
|
33
|
+
#### :bug: Bug Fixes
|
34
|
+
|
35
|
+
- fix(search): Fix some issues in the search popup #107 from eea/fix-search-popup [ichim-david - [`07b03df`](https://github.com/eea/volto-eea-website-theme/commit/07b03df36022da21d4c80b220cf529840e00c707)]
|
36
|
+
- fix(search): Fix undefined [kreafox - [`613d358`](https://github.com/eea/volto-eea-website-theme/commit/613d35860222ede3d40fc61acc0202b95e53108b)]
|
37
|
+
- fix(search): Fix some issues in the search popup [kreafox - [`13b5e64`](https://github.com/eea/volto-eea-website-theme/commit/13b5e64b69eacffacf2e65b9c5336cbcb5a9dfa7)]
|
38
|
+
|
39
|
+
#### :house: Internal changes
|
40
|
+
|
41
|
+
- chore: clean up [Mimi - [`b80f1dc`](https://github.com/eea/volto-eea-website-theme/commit/b80f1dcc5e5cd1d369bdcea574dd8158785af6be)]
|
42
|
+
- chore: use runtimeConfig for the RAZZLE_DISABLE_DRAFT_WATERMARK variable [Mimi - [`6b6cc83`](https://github.com/eea/volto-eea-website-theme/commit/6b6cc83dd0e6a4820d75acfdc8d41e092831261d)]
|
43
|
+
- chore: clean up [Mimi - [`807ca82`](https://github.com/eea/volto-eea-website-theme/commit/807ca82820319c0d45096dcbe228eee4262b602c)]
|
44
|
+
- chore: add missing code [Mimi - [`3a93e94`](https://github.com/eea/volto-eea-website-theme/commit/3a93e944613af0ee3ca1ed25c2439d9c504d4591)]
|
45
|
+
|
7
46
|
### [1.8.1](https://github.com/eea/volto-eea-website-theme/compare/1.8.0...1.8.1) - 9 February 2023
|
8
47
|
|
9
48
|
#### :rocket: New Features
|
@@ -104,7 +143,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
104
143
|
|
105
144
|
- For some reasons types is a string [Alin Voinea - [`3769a09`](https://github.com/eea/volto-eea-website-theme/commit/3769a0981181d5b633f3498daebbe96be8b4b833)]
|
106
145
|
- Fix(redirect): o.filter - refs #157627 [Alin Voinea - [`deb23da`](https://github.com/eea/volto-eea-website-theme/commit/deb23da846444cc96539697fd798429ae0abe89e)]
|
107
|
-
- Add Sonarqube tag using advisory-board-frontend addons list [EEA Jenkins - [`f1fffc5`](https://github.com/eea/volto-eea-website-theme/commit/f1fffc5db96725440863d545580b4e76cce4b796)]
|
108
146
|
### [1.5.0](https://github.com/eea/volto-eea-website-theme/compare/1.4.2...1.5.0) - 9 January 2023
|
109
147
|
|
110
148
|
#### :hammer_and_wrench: Others
|
@@ -138,7 +176,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
138
176
|
|
139
177
|
- Release 1.4.0 [Alin Voinea - [`bd42a0d`](https://github.com/eea/volto-eea-website-theme/commit/bd42a0d26e928cac5d99933194755da3db06b341)]
|
140
178
|
- bump version to use as volto-eea-design-system [David Ichim - [`f4be047`](https://github.com/eea/volto-eea-website-theme/commit/f4be047328b46399b03b612d378b18aaf82e7dc1)]
|
141
|
-
- Add Sonarqube tag using advisory-board-frontend addons list [EEA Jenkins - [`9b7cfef`](https://github.com/eea/volto-eea-website-theme/commit/9b7cfefb4d34fc1c948015e491feb370f9795bd8)]
|
142
179
|
- test(Jenkins): Run tests and cypress with latest canary @plone/volto [Alin Voinea - [`df252a9`](https://github.com/eea/volto-eea-website-theme/commit/df252a9bfed0bb86cadf53c59dd1603b1e2cd822)]
|
143
180
|
### [1.3.2](https://github.com/eea/volto-eea-website-theme/compare/1.3.1...1.3.2) - 16 December 2022
|
144
181
|
|
@@ -148,7 +185,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
148
185
|
|
149
186
|
#### :hammer_and_wrench: Others
|
150
187
|
|
151
|
-
- Add Sonarqube tag using cca-frontend addons list [EEA Jenkins - [`a43c658`](https://github.com/eea/volto-eea-website-theme/commit/a43c658a7920c8df95e763b9a637f38ce77eba2c)]
|
152
188
|
- Better razzle.config [Tiberiu Ichim - [`81dbf48`](https://github.com/eea/volto-eea-website-theme/commit/81dbf48815fb27facb4f82c9b764540fdf188b2e)]
|
153
189
|
- Better razzle.config [Tiberiu Ichim - [`7bc9da2`](https://github.com/eea/volto-eea-website-theme/commit/7bc9da2cd837ab62a95cd29979cdd9b0055b7d67)]
|
154
190
|
### [1.3.1](https://github.com/eea/volto-eea-website-theme/compare/1.3.0...1.3.1) - 28 November 2022
|
@@ -157,9 +193,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
157
193
|
|
158
194
|
- feat(Footer): Bring back footer contacts extra actions - refs #151856 [Alin Voinea - [`6c19413`](https://github.com/eea/volto-eea-website-theme/commit/6c194139420c9fd847692d180db1c1593e2483de)]
|
159
195
|
|
160
|
-
#### :hammer_and_wrench: Others
|
161
|
-
|
162
|
-
- yarn 3 [Alin Voinea - [`ea7a709`](https://github.com/eea/volto-eea-website-theme/commit/ea7a7094945312776e9b6f44e371178603e92139)]
|
163
196
|
### [1.3.0](https://github.com/eea/volto-eea-website-theme/compare/1.2.0...1.3.0) - 22 November 2022
|
164
197
|
|
165
198
|
#### :rocket: New Features
|
@@ -200,7 +233,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
200
233
|
- Add subsite class to body [Tiberiu Ichim - [`74d700f`](https://github.com/eea/volto-eea-website-theme/commit/74d700fbfd6249a8604762a7e4e49cce857db0f3)]
|
201
234
|
- Add subsite info to header [Tiberiu Ichim - [`47daf8b`](https://github.com/eea/volto-eea-website-theme/commit/47daf8bb6374a1222040626b19d4154df7ba1b83)]
|
202
235
|
- fix eslint [Miu Razvan - [`eb8d0a7`](https://github.com/eea/volto-eea-website-theme/commit/eb8d0a790bc70c0aae256c6ff35f63c4885f338e)]
|
203
|
-
- Add Sonarqube tag using circularity-frontend addons list [EEA Jenkins - [`cc578a4`](https://github.com/eea/volto-eea-website-theme/commit/cc578a413b205a8e61e091fab3a88f94cedefc89)]
|
204
236
|
### [1.1.0](https://github.com/eea/volto-eea-website-theme/compare/1.0.0...1.1.0) - 28 October 2022
|
205
237
|
|
206
238
|
#### :nail_care: Enhancements
|
@@ -248,7 +280,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
248
280
|
|
249
281
|
#### :hammer_and_wrench: Others
|
250
282
|
|
251
|
-
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`33b56ac`](https://github.com/eea/volto-eea-website-theme/commit/33b56acb13fbaf0c5b79e8fc6e13c4b699c79c90)]
|
252
283
|
### [0.7.3](https://github.com/eea/volto-eea-website-theme/compare/0.7.2...0.7.3) - 22 September 2022
|
253
284
|
|
254
285
|
#### :hammer_and_wrench: Others
|
@@ -516,7 +547,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
516
547
|
- Header refactor, add custom logo #5 [ichim-david - [`4950235`](https://github.com/eea/volto-eea-website-theme/commit/49502358105437cfeac3b144e6d301cb59aa2346)]
|
517
548
|
- Update footer.config with new publication card component [ichim-david - [`2e38e9a`](https://github.com/eea/volto-eea-website-theme/commit/2e38e9a417f835009d60c80d4eb4b30229f55e45)]
|
518
549
|
- feature(breadcrumbs): implement eea-design-system breadcrumb as Volto component #32 #7 [ichim-david - [`181af41`](https://github.com/eea/volto-eea-website-theme/commit/181af4125ce2b9ddac56dab4723cb11c26633221)]
|
519
|
-
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`da8ceb6`](https://github.com/eea/volto-eea-website-theme/commit/da8ceb68ea68bfbc9504e48ccd4d68277f11ab9a)]
|
520
550
|
- use breadcrumbs from eea-design-system [nileshgulia1 - [`db2f9e9`](https://github.com/eea/volto-eea-website-theme/commit/db2f9e9a4327420a3cce9a9903cd88549b129eab)]
|
521
551
|
- Update theme.config [ichim-david - [`8eca4f4`](https://github.com/eea/volto-eea-website-theme/commit/8eca4f40397a4aeca6d39029c92db78968d37064)]
|
522
552
|
- Added keyContent component to theme.config [ichim-david - [`d86f202`](https://github.com/eea/volto-eea-website-theme/commit/d86f202d0274d839487a88b51cae9a0e899beb23)]
|
@@ -558,5 +588,4 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
558
588
|
|
559
589
|
#### :hammer_and_wrench: Others
|
560
590
|
|
561
|
-
- yarn bootstrap [Alin Voinea - [`6995e9e`](https://github.com/eea/volto-eea-website-theme/commit/6995e9e091f21fdbbdffa8a44fc0e2c626f6d46a)]
|
562
591
|
- Initial commit [Alin Voinea - [`6a9c03a`](https://github.com/eea/volto-eea-website-theme/commit/6a9c03a7cebe71ca87e82cf58c42904063e9d8d3)]
|
package/package.json
CHANGED
@@ -2,15 +2,51 @@ import React from 'react';
|
|
2
2
|
import { connect } from 'react-redux';
|
3
3
|
import './draft.css';
|
4
4
|
import { BodyClass } from '@plone/volto/helpers';
|
5
|
+
import { withRouter } from 'react-router-dom';
|
6
|
+
import { compose } from 'redux';
|
7
|
+
import { runtimeConfig } from '@plone/volto/runtime_config';
|
8
|
+
import { flattenToAppURL } from '@plone/volto/helpers';
|
5
9
|
|
6
|
-
const
|
7
|
-
|
8
|
-
return <BodyClass className={draftClass} />;
|
10
|
+
const removeTrailingSlash = (str) => {
|
11
|
+
return str.replace(/\/+$/, '');
|
9
12
|
};
|
10
|
-
function propsAreEqual(prevProps, nextProps) {
|
11
|
-
return prevProps.review_state === nextProps.review_state;
|
12
|
-
}
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
/**
|
15
|
+
* The review_state and id don't change everytime the page is changed and because of that the draft background
|
16
|
+
* will apear on pages that shouldn't have it. The RAZZLE_DISABLE_DRAFT_WATERMARK varible from ENV file should have two possible values:
|
17
|
+
* "Hide-No-Workflow" and "Hide-All". If the variable is not present, it should follow the current logic(show the draft image everywhere),
|
18
|
+
* if the value is "Hide-No-Workflow", then the draft image is not shown on pages like login or controlpanel and if the value is "Hide-All", then
|
19
|
+
* the draft image is not visible at all.
|
20
|
+
* For example, if the current page is /datatable (that has the draft background) and then we go to Content Types page,
|
21
|
+
* the review_state and id will be the same as the ones from /datatable, so the draft background will still be present. By checking
|
22
|
+
* if the pathname from (from withRouter) is different than the one from state.content.data and based on the varible from ENV,
|
23
|
+
* we decide if the draft backgound can be present or not.
|
24
|
+
* @param {Object} props
|
25
|
+
* @returns
|
26
|
+
*/
|
27
|
+
const DraftBackground = (props) => {
|
28
|
+
const draftClass = `wf-state-${props.review_state}`;
|
29
|
+
const razzleDraft =
|
30
|
+
runtimeConfig['RAZZLE_DISABLE_DRAFT_WATERMARK'] || 'default';
|
31
|
+
const isReviewableStateComponent =
|
32
|
+
props.review_state &&
|
33
|
+
props.contentId === removeTrailingSlash(props.pathname);
|
34
|
+
|
35
|
+
const draftOptions = {
|
36
|
+
'Hide-All': 'wf-state-published',
|
37
|
+
'Hide-No-Workflow': isReviewableStateComponent
|
38
|
+
? draftClass
|
39
|
+
: 'wf-state-published',
|
40
|
+
default: draftClass,
|
41
|
+
};
|
42
|
+
|
43
|
+
return <BodyClass className={draftOptions[razzleDraft]} />;
|
44
|
+
};
|
45
|
+
|
46
|
+
export default compose(
|
47
|
+
withRouter,
|
48
|
+
connect((state, props) => ({
|
49
|
+
review_state: state.content.data?.review_state,
|
50
|
+
contentId: flattenToAppURL(state.content.data?.['@id']),
|
51
|
+
})),
|
52
|
+
)(DraftBackground);
|
@@ -1,13 +1,15 @@
|
|
1
|
-
import React from 'react';
|
1
|
+
import React, { useEffect } from 'react';
|
2
2
|
import { Container, Input, List } from 'semantic-ui-react';
|
3
3
|
import { withRouter } from 'react-router-dom';
|
4
4
|
import { useClickOutside } from '@eeacms/volto-eea-design-system/helpers';
|
5
5
|
import config from '@plone/volto/registry';
|
6
6
|
|
7
7
|
const getRandomItems = (arr, max) => {
|
8
|
-
return
|
9
|
-
|
10
|
-
|
8
|
+
return (
|
9
|
+
arr?.slice(0, max).map(function () {
|
10
|
+
return this.splice(Math.floor(Math.random() * this.length), 1)[0];
|
11
|
+
}, arr.slice()) || []
|
12
|
+
);
|
11
13
|
};
|
12
14
|
|
13
15
|
function HeaderSearchPopUp({
|
@@ -32,10 +34,15 @@ function HeaderSearchPopUp({
|
|
32
34
|
searchSuggestions,
|
33
35
|
} = activeView;
|
34
36
|
const { suggestionsTitle, suggestions, maxToShow } = searchSuggestions || {};
|
37
|
+
|
35
38
|
const [text, setText] = React.useState('');
|
36
|
-
const visibleSuggestions =
|
37
|
-
|
38
|
-
|
39
|
+
const [visibleSuggestions, setVisibileSuggestions] = React.useState(
|
40
|
+
getRandomItems(suggestions, maxToShow),
|
41
|
+
);
|
42
|
+
|
43
|
+
useEffect(() => {
|
44
|
+
setVisibileSuggestions(getRandomItems(suggestions, maxToShow));
|
45
|
+
}, [maxToShow, suggestions]);
|
39
46
|
|
40
47
|
useClickOutside({ targetRefs: [nodeRef, ...triggerRefs], callback: onClose });
|
41
48
|
|
@@ -0,0 +1,27 @@
|
|
1
|
+
import React, { Component } from 'react';
|
2
|
+
import { UniversalLink } from '@plone/volto/components';
|
3
|
+
import { FormattedMessage } from 'react-intl';
|
4
|
+
import { Container } from 'semantic-ui-react';
|
5
|
+
import config from '@plone/volto/registry';
|
6
|
+
|
7
|
+
export class ContactFormComponent extends Component {
|
8
|
+
componentDidMount() {
|
9
|
+
if (config.settings.contactForm) {
|
10
|
+
this.props.history.replace(config.settings.contactForm);
|
11
|
+
}
|
12
|
+
}
|
13
|
+
|
14
|
+
render() {
|
15
|
+
const remoteUrl = config.settings.contactForm;
|
16
|
+
return (
|
17
|
+
<Container id="page-document">
|
18
|
+
<p>
|
19
|
+
<FormattedMessage id="Contact us:" defaultMessage="Contact us:" />{' '}
|
20
|
+
<UniversalLink href={remoteUrl}>{remoteUrl}</UniversalLink>
|
21
|
+
</p>
|
22
|
+
</Container>
|
23
|
+
);
|
24
|
+
}
|
25
|
+
}
|
26
|
+
|
27
|
+
export default ContactFormComponent;
|
@@ -101,10 +101,9 @@ const EEAHeader = ({ pathname, token, items, history, subsite }) => {
|
|
101
101
|
className=""
|
102
102
|
viewportWidth={width}
|
103
103
|
>
|
104
|
+
{/* eslint-disable-next-line jsx-a11y/no-static-element-interactions */}
|
104
105
|
<div
|
105
106
|
className="content"
|
106
|
-
role="menu"
|
107
|
-
tabIndex="0"
|
108
107
|
onClick={(evt) => evt.stopPropagation()}
|
109
108
|
onKeyDown={(evt) => evt.stopPropagation()}
|
110
109
|
>
|
@@ -116,8 +115,7 @@ const EEAHeader = ({ pathname, token, items, history, subsite }) => {
|
|
116
115
|
href="https://europa.eu/european-union/contact/institutions-bodies_en"
|
117
116
|
target="_blank"
|
118
117
|
rel="noreferrer"
|
119
|
-
|
120
|
-
aria-selected="false"
|
118
|
+
onKeyDown={(evt) => evt.stopPropagation()}
|
121
119
|
>
|
122
120
|
See all EU institutions and bodies
|
123
121
|
</a>
|
@@ -140,6 +138,7 @@ const EEAHeader = ({ pathname, token, items, history, subsite }) => {
|
|
140
138
|
className="site"
|
141
139
|
target="_blank"
|
142
140
|
rel="noreferrer"
|
141
|
+
onKeyDown={(evt) => evt.stopPropagation()}
|
143
142
|
>
|
144
143
|
{item.title}
|
145
144
|
</a>
|
@@ -154,7 +153,10 @@ const EEAHeader = ({ pathname, token, items, history, subsite }) => {
|
|
154
153
|
<Header.TopDropdownMenu
|
155
154
|
id="language-switcher"
|
156
155
|
className="item"
|
157
|
-
hasLanguageDropdown={
|
156
|
+
hasLanguageDropdown={
|
157
|
+
config.settings.supportedLanguages.length > 1 &&
|
158
|
+
config.settings.hasLanguageDropdown
|
159
|
+
}
|
158
160
|
text={`${language.toUpperCase()}`}
|
159
161
|
mobileText={`${language.toUpperCase()}`}
|
160
162
|
icon={
|
@@ -0,0 +1,3 @@
|
|
1
|
+
<svg width="36" height="36" version="1.1" viewBox="0 0 36 36" xmlns="http://www.w3.org/2000/svg">
|
2
|
+
<path d="m14.378 14.247-6.8402 6.8402 7.1774 7.1774h1.6168v-0.0028h1.6195l5.2207-5.2207zm1.954-1.9539 8.7942 8.7942 3.9079-3.9093-8.7942-8.7942zm5.5274 15.969h9.673v2.7637h-12.437l-5.5247 0.002764-8.9641-8.9641a1.3819 1.3819 0 0 1 0-1.954l14.655-14.657a1.3819 1.3819 0 0 1 1.9553 0l10.748 10.748a1.3819 1.3819 0 0 1 0 1.9539z" stroke-width="1.3819"/>
|
3
|
+
</svg>
|
package/src/index.js
CHANGED
@@ -20,6 +20,9 @@ const applyConfig = (config) => {
|
|
20
20
|
...(config.settings.eea || {}),
|
21
21
|
};
|
22
22
|
|
23
|
+
// #160689 Redirect contact-form to contact-us
|
24
|
+
config.settings.contactForm = '/contact';
|
25
|
+
|
23
26
|
// Insert scripts on Error pages
|
24
27
|
if (config.settings?.serverConfig?.extractScripts) {
|
25
28
|
config.settings.serverConfig.extractScripts.errorPages = true;
|
@@ -115,6 +118,9 @@ const applyConfig = (config) => {
|
|
115
118
|
// Custom block-style colors
|
116
119
|
config.settings.available_colors = eea.colors;
|
117
120
|
|
121
|
+
// hide language dropdown by default
|
122
|
+
config.settings.hasLanguageDropdown = false;
|
123
|
+
|
118
124
|
// Site theme colors
|
119
125
|
config.settings.themeColors = [
|
120
126
|
{ value: undefined, title: 'No theme' },
|
package/src/slate.js
CHANGED
@@ -3,10 +3,9 @@ import { List } from 'semantic-ui-react';
|
|
3
3
|
import { MarkElementButton, ToolbarButton } from '@plone/volto-slate/editor/ui';
|
4
4
|
import installCallout from '@plone/volto-slate/editor/plugins/Callout';
|
5
5
|
import { Icon } from '@plone/volto/components';
|
6
|
-
import { Editor, Transforms } from 'slate';
|
6
|
+
import { Editor, Transforms, Text } from 'slate';
|
7
7
|
import { useSlate } from 'slate-react';
|
8
8
|
|
9
|
-
import formatClearIcon from '@plone/volto/icons/format-clear.svg';
|
10
9
|
import paintSVG from '@plone/volto/icons/paint.svg';
|
11
10
|
import alignLeftIcon from '@plone/volto/icons/align-left.svg';
|
12
11
|
import alignRightIcon from '@plone/volto/icons/align-right.svg';
|
@@ -14,6 +13,7 @@ import alignCenterIcon from '@plone/volto/icons/align-center.svg';
|
|
14
13
|
import alignJustifyIcon from '@plone/volto/icons/align-justify.svg';
|
15
14
|
import lightIcon from './icons/light.svg';
|
16
15
|
import smallIcon from './icons/small.svg';
|
16
|
+
import clearIcon from './icons/eraser.svg';
|
17
17
|
|
18
18
|
const toggleBlockClassFormat = (editor, format) => {
|
19
19
|
const levels = Array.from(Editor.levels(editor, editor.selection));
|
@@ -59,6 +59,27 @@ function BlockClassButton({ format, icon, ...props }) {
|
|
59
59
|
}
|
60
60
|
|
61
61
|
const clearFormatting = (editor) => {
|
62
|
+
const sn = Array.from(
|
63
|
+
Editor.nodes(editor, {
|
64
|
+
mode: 'lowest',
|
65
|
+
match: (n, p) => {
|
66
|
+
// console.log('node', n, p);
|
67
|
+
return Text.isText(n);
|
68
|
+
},
|
69
|
+
at: [0], // uncomment if you want everything to be cleared
|
70
|
+
}),
|
71
|
+
);
|
72
|
+
|
73
|
+
// console.log('sn', sn);
|
74
|
+
|
75
|
+
sn.forEach(([n, at]) => {
|
76
|
+
const toRemove = Object.keys(n).filter((k) => k.startsWith('style-'));
|
77
|
+
if (toRemove.length) {
|
78
|
+
Transforms.unsetNodes(editor, toRemove, { at });
|
79
|
+
// console.log('unset', n, at, toRemove);
|
80
|
+
}
|
81
|
+
});
|
82
|
+
|
62
83
|
Transforms.setNodes(editor, {
|
63
84
|
type: 'p',
|
64
85
|
styleName: null,
|
@@ -90,7 +111,7 @@ export default function installSlate(config) {
|
|
90
111
|
config = installCallout(config);
|
91
112
|
|
92
113
|
config.settings.slate.buttons.clearformatting = (props) => (
|
93
|
-
<ClearFormattingButton title="Clear formatting" icon={
|
114
|
+
<ClearFormattingButton title="Clear formatting" icon={clearIcon} />
|
94
115
|
);
|
95
116
|
|
96
117
|
// Remove blockquote, italic, strikethrough slate button from toolbarButtons
|