@eeacms/volto-eea-website-theme 1.6.4 → 1.8.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 +36 -10
- package/package.json +2 -2
- package/src/config.js +3 -0
- package/src/customizations/@eeacms/volto-block-style/StyleWrapper/schema.js +0 -20
- package/src/customizations/@eeacms/volto-eea-design-system/ui/Header/HeaderSearchPopUp.js +1 -1
- package/src/customizations/@plone/volto-slate/editor/README.txt +2 -0
- package/src/customizations/@plone/volto-slate/editor/render.jsx +165 -0
- package/src/customizations/volto/components/manage/Sidebar/ObjectBrowserNav.jsx +13 -2
- package/src/customizations/volto/components/theme/View/EventView.jsx +10 -13
- package/src/customizations/volto/components/theme/View/style.less +17 -0
- package/src/icons/content-box-src.svg +36 -0
- package/src/icons/content-box.svg +12 -3
- package/src/icons/light-src.svg +22 -0
- package/src/icons/light.svg +5 -0
- package/src/icons/small-src.svg +22 -0
- package/src/icons/small.svg +5 -0
- package/src/index.js +24 -53
- package/src/slate.js +323 -0
package/CHANGELOG.md
CHANGED
@@ -4,6 +4,42 @@ 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.8.0](https://github.com/eea/volto-eea-website-theme/compare/1.7.0...1.8.0) - 8 February 2023
|
8
|
+
|
9
|
+
#### :rocket: New Features
|
10
|
+
|
11
|
+
- feat(align): Move text align to slate buttons - refs 160747 [Alin Voinea - [`24d8fe5`](https://github.com/eea/volto-eea-website-theme/commit/24d8fe5a74afc2b61dc622b368d3fe5b8b422390)]
|
12
|
+
|
13
|
+
#### :nail_care: Enhancements
|
14
|
+
|
15
|
+
- change(object-browser): Popup is hoverable in object browser nav #99 from eea/object_browser_nav_popup_hoverable [ichim-david - [`205c2c4`](https://github.com/eea/volto-eea-website-theme/commit/205c2c48803ce5814f71aea932038bf72272459e)]
|
16
|
+
|
17
|
+
#### :hammer_and_wrench: Others
|
18
|
+
|
19
|
+
- Release 1.8.0 [Alin Voinea - [`f15437f`](https://github.com/eea/volto-eea-website-theme/commit/f15437f9c9fd978431d3af48410d3ab9746be9fb)]
|
20
|
+
- Popup is hoverable in object browser nav [andreiggr - [`a944bff`](https://github.com/eea/volto-eea-website-theme/commit/a944bff8026b40c481bec474f2b509dc5c8b044a)]
|
21
|
+
### [1.7.0](https://github.com/eea/volto-eea-website-theme/compare/1.6.4...1.7.0) - 8 February 2023
|
22
|
+
|
23
|
+
#### :rocket: New Features
|
24
|
+
|
25
|
+
- feat(slate): Remove blockquote, italic, strikethrough slate button from expandedToolbarButtons - refs #160747 [Alin Voinea - [`c5a2684`](https://github.com/eea/volto-eea-website-theme/commit/c5a268428737374802a02c69fd6d24ddc5a8d3d3)]
|
26
|
+
- feat(slate): Remove 'underline' and 'italic' hotkeys - refs #160747 [Alin Voinea - [`82b6404`](https://github.com/eea/volto-eea-website-theme/commit/82b6404b044cc15f3612cee36c0ddef5973dfeeb)]
|
27
|
+
- feat(slate-buttons): Remove Italic, Strikethrough; Add Light, small - refs #160747 [Alin Voinea - [`7a78b42`](https://github.com/eea/volto-eea-website-theme/commit/7a78b42cf2158daa4a7d7ecc3f64611d4321147d)]
|
28
|
+
|
29
|
+
#### :nail_care: Enhancements
|
30
|
+
|
31
|
+
- change(object-browser): Use scale for img in obj browser and preview in popup #95 from eea/image_preview_object_browser [ichim-david - [`ac8f233`](https://github.com/eea/volto-eea-website-theme/commit/ac8f2333f46de737ccad5e10531f4deedc24c57f)]
|
32
|
+
- change(header): Add link in search popup to the search landing page #94 from eea/search-popup [ichim-david - [`fe7aab9`](https://github.com/eea/volto-eea-website-theme/commit/fe7aab90fc51dbb3aa4fb961470fe9bd73938314)]
|
33
|
+
- refactor(styleMenu): remove bordered styles #93 from eea/remove-bordered-styles [ichim-david - [`24bab89`](https://github.com/eea/volto-eea-website-theme/commit/24bab8912831e0b0ee30d8508400359c2f26893f)]
|
34
|
+
- change(header): Add link in search popup to the landing page [kreafox - [`d1e97df`](https://github.com/eea/volto-eea-website-theme/commit/d1e97df9766ef43d34c09c7c993123edf4dc0e0a)]
|
35
|
+
- change(header): Add link in search popup to the landing page [kreafox - [`9a8ec3a`](https://github.com/eea/volto-eea-website-theme/commit/9a8ec3aff4f37c562d6e377b9d4c2a48fc5c451a)]
|
36
|
+
- refactor(styleMenu): remove bordered styles [nileshgulia1 - [`97a7079`](https://github.com/eea/volto-eea-website-theme/commit/97a707934343cde875a59f33751d2c61267ddf7d)]
|
37
|
+
- refactor(config): Move some common settings from volto-eea-website-policy - refs #160747 [Alin Voinea - [`a40b6a3`](https://github.com/eea/volto-eea-website-theme/commit/a40b6a3719140a9be343e7d1aeca3d7098f3b1be)]
|
38
|
+
- change(theme widget): the first value is no value [ichim-david - [`12b8a5a`](https://github.com/eea/volto-eea-website-theme/commit/12b8a5ada013d7f28c89b596e2675e8cb0bfbb5e)]
|
39
|
+
|
40
|
+
#### :hammer_and_wrench: Others
|
41
|
+
|
42
|
+
- Use scale for img in obj browser and preview in popup [andreiggr - [`e78e21d`](https://github.com/eea/volto-eea-website-theme/commit/e78e21d0b35d69242833914ff41455f24d31927b)]
|
7
43
|
### [1.6.4](https://github.com/eea/volto-eea-website-theme/compare/1.6.3...1.6.4) - 31 January 2023
|
8
44
|
|
9
45
|
#### :bug: Bug Fixes
|
@@ -50,7 +86,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
50
86
|
|
51
87
|
- For some reasons types is a string [Alin Voinea - [`3769a09`](https://github.com/eea/volto-eea-website-theme/commit/3769a0981181d5b633f3498daebbe96be8b4b833)]
|
52
88
|
- Fix(redirect): o.filter - refs #157627 [Alin Voinea - [`deb23da`](https://github.com/eea/volto-eea-website-theme/commit/deb23da846444cc96539697fd798429ae0abe89e)]
|
53
|
-
- Add Sonarqube tag using advisory-board-frontend addons list [EEA Jenkins - [`f1fffc5`](https://github.com/eea/volto-eea-website-theme/commit/f1fffc5db96725440863d545580b4e76cce4b796)]
|
54
89
|
### [1.5.0](https://github.com/eea/volto-eea-website-theme/compare/1.4.2...1.5.0) - 9 January 2023
|
55
90
|
|
56
91
|
#### :hammer_and_wrench: Others
|
@@ -84,7 +119,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
84
119
|
|
85
120
|
- Release 1.4.0 [Alin Voinea - [`bd42a0d`](https://github.com/eea/volto-eea-website-theme/commit/bd42a0d26e928cac5d99933194755da3db06b341)]
|
86
121
|
- bump version to use as volto-eea-design-system [David Ichim - [`f4be047`](https://github.com/eea/volto-eea-website-theme/commit/f4be047328b46399b03b612d378b18aaf82e7dc1)]
|
87
|
-
- Add Sonarqube tag using advisory-board-frontend addons list [EEA Jenkins - [`9b7cfef`](https://github.com/eea/volto-eea-website-theme/commit/9b7cfefb4d34fc1c948015e491feb370f9795bd8)]
|
88
122
|
- test(Jenkins): Run tests and cypress with latest canary @plone/volto [Alin Voinea - [`df252a9`](https://github.com/eea/volto-eea-website-theme/commit/df252a9bfed0bb86cadf53c59dd1603b1e2cd822)]
|
89
123
|
### [1.3.2](https://github.com/eea/volto-eea-website-theme/compare/1.3.1...1.3.2) - 16 December 2022
|
90
124
|
|
@@ -94,7 +128,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
94
128
|
|
95
129
|
#### :hammer_and_wrench: Others
|
96
130
|
|
97
|
-
- Add Sonarqube tag using cca-frontend addons list [EEA Jenkins - [`a43c658`](https://github.com/eea/volto-eea-website-theme/commit/a43c658a7920c8df95e763b9a637f38ce77eba2c)]
|
98
131
|
- Better razzle.config [Tiberiu Ichim - [`81dbf48`](https://github.com/eea/volto-eea-website-theme/commit/81dbf48815fb27facb4f82c9b764540fdf188b2e)]
|
99
132
|
- Better razzle.config [Tiberiu Ichim - [`7bc9da2`](https://github.com/eea/volto-eea-website-theme/commit/7bc9da2cd837ab62a95cd29979cdd9b0055b7d67)]
|
100
133
|
### [1.3.1](https://github.com/eea/volto-eea-website-theme/compare/1.3.0...1.3.1) - 28 November 2022
|
@@ -103,9 +136,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
103
136
|
|
104
137
|
- feat(Footer): Bring back footer contacts extra actions - refs #151856 [Alin Voinea - [`6c19413`](https://github.com/eea/volto-eea-website-theme/commit/6c194139420c9fd847692d180db1c1593e2483de)]
|
105
138
|
|
106
|
-
#### :hammer_and_wrench: Others
|
107
|
-
|
108
|
-
- yarn 3 [Alin Voinea - [`ea7a709`](https://github.com/eea/volto-eea-website-theme/commit/ea7a7094945312776e9b6f44e371178603e92139)]
|
109
139
|
### [1.3.0](https://github.com/eea/volto-eea-website-theme/compare/1.2.0...1.3.0) - 22 November 2022
|
110
140
|
|
111
141
|
#### :rocket: New Features
|
@@ -146,7 +176,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
146
176
|
- Add subsite class to body [Tiberiu Ichim - [`74d700f`](https://github.com/eea/volto-eea-website-theme/commit/74d700fbfd6249a8604762a7e4e49cce857db0f3)]
|
147
177
|
- Add subsite info to header [Tiberiu Ichim - [`47daf8b`](https://github.com/eea/volto-eea-website-theme/commit/47daf8bb6374a1222040626b19d4154df7ba1b83)]
|
148
178
|
- fix eslint [Miu Razvan - [`eb8d0a7`](https://github.com/eea/volto-eea-website-theme/commit/eb8d0a790bc70c0aae256c6ff35f63c4885f338e)]
|
149
|
-
- Add Sonarqube tag using circularity-frontend addons list [EEA Jenkins - [`cc578a4`](https://github.com/eea/volto-eea-website-theme/commit/cc578a413b205a8e61e091fab3a88f94cedefc89)]
|
150
179
|
### [1.1.0](https://github.com/eea/volto-eea-website-theme/compare/1.0.0...1.1.0) - 28 October 2022
|
151
180
|
|
152
181
|
#### :nail_care: Enhancements
|
@@ -194,7 +223,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
194
223
|
|
195
224
|
#### :hammer_and_wrench: Others
|
196
225
|
|
197
|
-
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`33b56ac`](https://github.com/eea/volto-eea-website-theme/commit/33b56acb13fbaf0c5b79e8fc6e13c4b699c79c90)]
|
198
226
|
### [0.7.3](https://github.com/eea/volto-eea-website-theme/compare/0.7.2...0.7.3) - 22 September 2022
|
199
227
|
|
200
228
|
#### :hammer_and_wrench: Others
|
@@ -462,7 +490,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
462
490
|
- Header refactor, add custom logo #5 [ichim-david - [`4950235`](https://github.com/eea/volto-eea-website-theme/commit/49502358105437cfeac3b144e6d301cb59aa2346)]
|
463
491
|
- Update footer.config with new publication card component [ichim-david - [`2e38e9a`](https://github.com/eea/volto-eea-website-theme/commit/2e38e9a417f835009d60c80d4eb4b30229f55e45)]
|
464
492
|
- 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)]
|
465
|
-
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`da8ceb6`](https://github.com/eea/volto-eea-website-theme/commit/da8ceb68ea68bfbc9504e48ccd4d68277f11ab9a)]
|
466
493
|
- use breadcrumbs from eea-design-system [nileshgulia1 - [`db2f9e9`](https://github.com/eea/volto-eea-website-theme/commit/db2f9e9a4327420a3cce9a9903cd88549b129eab)]
|
467
494
|
- Update theme.config [ichim-david - [`8eca4f4`](https://github.com/eea/volto-eea-website-theme/commit/8eca4f40397a4aeca6d39029c92db78968d37064)]
|
468
495
|
- Added keyContent component to theme.config [ichim-david - [`d86f202`](https://github.com/eea/volto-eea-website-theme/commit/d86f202d0274d839487a88b51cae9a0e899beb23)]
|
@@ -504,5 +531,4 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
504
531
|
|
505
532
|
#### :hammer_and_wrench: Others
|
506
533
|
|
507
|
-
- yarn bootstrap [Alin Voinea - [`6995e9e`](https://github.com/eea/volto-eea-website-theme/commit/6995e9e091f21fdbbdffa8a44fc0e2c626f6d46a)]
|
508
534
|
- Initial commit [Alin Voinea - [`6a9c03a`](https://github.com/eea/volto-eea-website-theme/commit/6a9c03a7cebe71ca87e82cf58c42904063e9d8d3)]
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@eeacms/volto-eea-website-theme",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.8.0",
|
4
4
|
"description": "@eeacms/volto-eea-website-theme: Volto add-on",
|
5
5
|
"main": "src/index.js",
|
6
6
|
"author": "European Environment Agency: IDM2 A-Team",
|
@@ -22,7 +22,7 @@
|
|
22
22
|
"url": "git@github.com:eea/volto-eea-website-theme.git"
|
23
23
|
},
|
24
24
|
"dependencies": {
|
25
|
-
"@eeacms/volto-eea-design-system": "^1.0.0-alpha.
|
25
|
+
"@eeacms/volto-eea-design-system": "^1.0.0-alpha.15",
|
26
26
|
"volto-subsites": "*"
|
27
27
|
},
|
28
28
|
"devDependencies": {
|
package/src/config.js
CHANGED
@@ -259,6 +259,9 @@ export const headerSearchBox = [
|
|
259
259
|
isDefault: true,
|
260
260
|
path: '/en/advanced-search',
|
261
261
|
placeholder: 'Search...',
|
262
|
+
description:
|
263
|
+
'Looking for more information? Try searching the full EEA website content',
|
264
|
+
buttonTitle: 'Go to full site search',
|
262
265
|
},
|
263
266
|
{
|
264
267
|
path: '/en/datahub',
|
@@ -12,32 +12,12 @@ export const StyleSchema = () => {
|
|
12
12
|
title: 'Preset styles',
|
13
13
|
fields: ['style_name'],
|
14
14
|
},
|
15
|
-
{
|
16
|
-
id: 'text',
|
17
|
-
title: 'Text',
|
18
|
-
fields: ['textAlign', 'fontWeight'],
|
19
|
-
},
|
20
15
|
],
|
21
16
|
properties: {
|
22
17
|
style_name: {
|
23
18
|
title: 'Style',
|
24
19
|
widget: 'style_select',
|
25
20
|
},
|
26
|
-
textAlign: {
|
27
|
-
title: 'Text align',
|
28
|
-
widget: 'style_text_align',
|
29
|
-
},
|
30
|
-
fontWeight: {
|
31
|
-
title: 'Font weight',
|
32
|
-
description: 'The weight (or boldness) of the font',
|
33
|
-
choices: [
|
34
|
-
['300', 'Light'],
|
35
|
-
['400', 'Regular'],
|
36
|
-
['500', 'Medium'],
|
37
|
-
['600', 'SemiBold'],
|
38
|
-
['700', 'Bold'],
|
39
|
-
],
|
40
|
-
},
|
41
21
|
},
|
42
22
|
required: [],
|
43
23
|
};
|
@@ -0,0 +1,165 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { renderToStaticMarkup } from 'react-dom/server';
|
3
|
+
import { Node, Text } from 'slate';
|
4
|
+
import cx from 'classnames';
|
5
|
+
import { isEmpty, isEqual, omit } from 'lodash';
|
6
|
+
import config from '@plone/volto/registry';
|
7
|
+
|
8
|
+
const OMITTED = ['editor', 'path'];
|
9
|
+
|
10
|
+
// TODO: read, see if relevant
|
11
|
+
// https://reactjs.org/docs/higher-order-components.html#dont-use-hocs-inside-the-render-method
|
12
|
+
export const Element = ({ element, attributes = {}, extras, ...rest }) => {
|
13
|
+
const { slate } = config.settings;
|
14
|
+
const { elements } = slate;
|
15
|
+
const El = elements[element.type] || elements['default'];
|
16
|
+
|
17
|
+
// CUSTOMIZATION Code fix
|
18
|
+
const attrs = Object.keys(attributes || {}).reduce(
|
19
|
+
(acc, k) => {
|
20
|
+
if (!isEmpty(attributes[k])) {
|
21
|
+
if (k === 'className') {
|
22
|
+
acc.className = cx(attributes.className, acc.className);
|
23
|
+
} else {
|
24
|
+
acc[k] = attributes[k];
|
25
|
+
}
|
26
|
+
}
|
27
|
+
return acc;
|
28
|
+
},
|
29
|
+
element.styleName ? { className: element.styleName } : {},
|
30
|
+
);
|
31
|
+
// END CUSTOMIZATION
|
32
|
+
|
33
|
+
attrs.ref = attributes?.ref; // never remove the ref
|
34
|
+
|
35
|
+
return (
|
36
|
+
<El
|
37
|
+
element={element}
|
38
|
+
{...omit(rest, OMITTED)}
|
39
|
+
attributes={attrs}
|
40
|
+
extras={extras}
|
41
|
+
/>
|
42
|
+
);
|
43
|
+
};
|
44
|
+
|
45
|
+
export const Leaf = ({ children, ...rest }) => {
|
46
|
+
const { attributes, leaf, mode } = rest;
|
47
|
+
let { leafs } = config.settings.slate;
|
48
|
+
|
49
|
+
children = Object.keys(leafs).reduce((acc, name) => {
|
50
|
+
return Object.keys(leaf).includes(name)
|
51
|
+
? leafs[name]({ children: acc })
|
52
|
+
: acc;
|
53
|
+
}, children);
|
54
|
+
|
55
|
+
const classNames = {
|
56
|
+
[`highlight-${leaf.highlightType}`]: mode !== 'view' && leaf.highlightType,
|
57
|
+
'highlight-selection': mode !== 'view' && leaf.isSelection,
|
58
|
+
};
|
59
|
+
|
60
|
+
// stylemenu support
|
61
|
+
for (const prop in leaf) {
|
62
|
+
if (prop.startsWith('style-')) {
|
63
|
+
classNames[prop.substring(6)] = true;
|
64
|
+
}
|
65
|
+
}
|
66
|
+
|
67
|
+
const klass = cx(classNames);
|
68
|
+
|
69
|
+
return mode === 'view' ? (
|
70
|
+
typeof children === 'string' ? (
|
71
|
+
children.split('\n').map((t, i) => {
|
72
|
+
// Softbreak support. Should do a plugin?
|
73
|
+
return (
|
74
|
+
<React.Fragment key={`${i}`}>
|
75
|
+
{children.indexOf('\n') > -1 &&
|
76
|
+
children.split('\n').length - 1 > i ? (
|
77
|
+
<>
|
78
|
+
{klass ? <span className={klass}>{t}</span> : t}
|
79
|
+
<br />
|
80
|
+
</>
|
81
|
+
) : klass ? (
|
82
|
+
<span className={klass}>{t}</span>
|
83
|
+
) : (
|
84
|
+
t
|
85
|
+
)}
|
86
|
+
</React.Fragment>
|
87
|
+
);
|
88
|
+
})
|
89
|
+
) : (
|
90
|
+
<span className={klass}>{children}</span>
|
91
|
+
)
|
92
|
+
) : (
|
93
|
+
<span {...attributes} className={klass}>
|
94
|
+
{children}
|
95
|
+
</span>
|
96
|
+
);
|
97
|
+
};
|
98
|
+
|
99
|
+
const serializeData = (node) => {
|
100
|
+
return JSON.stringify({ type: node.type, data: node.data });
|
101
|
+
};
|
102
|
+
|
103
|
+
export const serializeNodes = (nodes, getAttributes, extras = {}) => {
|
104
|
+
const editor = { children: nodes || [] };
|
105
|
+
|
106
|
+
const _serializeNodes = (nodes) => {
|
107
|
+
return (nodes || []).map(([node, path], i) => {
|
108
|
+
return Text.isText(node) ? (
|
109
|
+
<Leaf path={path} leaf={node} text={node} mode="view" key={path}>
|
110
|
+
{node.text}
|
111
|
+
</Leaf>
|
112
|
+
) : (
|
113
|
+
<Element
|
114
|
+
path={path}
|
115
|
+
element={node}
|
116
|
+
mode="view"
|
117
|
+
key={path}
|
118
|
+
data-slate-data={node.data ? serializeData(node) : null}
|
119
|
+
attributes={
|
120
|
+
isEqual(path, [0])
|
121
|
+
? getAttributes
|
122
|
+
? getAttributes(node, path)
|
123
|
+
: null
|
124
|
+
: null
|
125
|
+
}
|
126
|
+
extras={extras}
|
127
|
+
>
|
128
|
+
{_serializeNodes(Array.from(Node.children(editor, path)))}
|
129
|
+
</Element>
|
130
|
+
);
|
131
|
+
});
|
132
|
+
};
|
133
|
+
|
134
|
+
return _serializeNodes(Array.from(Node.children(editor, [])));
|
135
|
+
};
|
136
|
+
|
137
|
+
/**
|
138
|
+
* Get the concatenated text string of a node's content.
|
139
|
+
*
|
140
|
+
* Note that this WILL include spaces between block node leafs in contrary to
|
141
|
+
* the original slate method. This function joins text of nodes with
|
142
|
+
* separating spaces to produce a string for indexing purposes.
|
143
|
+
*
|
144
|
+
*/
|
145
|
+
const ConcatenatedString = (node) => {
|
146
|
+
if (Text.isText(node)) {
|
147
|
+
return node.text.trim();
|
148
|
+
} else {
|
149
|
+
return node.children.map(ConcatenatedString).join(' ');
|
150
|
+
}
|
151
|
+
};
|
152
|
+
|
153
|
+
/**
|
154
|
+
* @function serializeNodesToText
|
155
|
+
*
|
156
|
+
* @param {Array[Node]} nodes
|
157
|
+
*
|
158
|
+
* @returns {string}
|
159
|
+
*/
|
160
|
+
export const serializeNodesToText = (nodes) => {
|
161
|
+
return nodes.map(ConcatenatedString).join('\n');
|
162
|
+
};
|
163
|
+
|
164
|
+
export const serializeNodesToHtml = (nodes) =>
|
165
|
+
renderToStaticMarkup(serializeNodes(nodes));
|
@@ -71,10 +71,21 @@ const ObjectBrowserNav = ({
|
|
71
71
|
>
|
72
72
|
<span title={`${item['@id']} (${item['@type']})`}>
|
73
73
|
<Popup
|
74
|
+
hoverable
|
74
75
|
key={item['@id']}
|
75
76
|
content={
|
76
77
|
<>
|
77
|
-
|
78
|
+
{item['@type'] === 'Image' && (
|
79
|
+
<Image
|
80
|
+
style={{
|
81
|
+
marginLeft: 'auto',
|
82
|
+
marginRight: 'auto',
|
83
|
+
marginBottom: '5px',
|
84
|
+
}}
|
85
|
+
src={`${item?.getURL}/@@images/image/mini`}
|
86
|
+
/>
|
87
|
+
)}
|
88
|
+
<Icon name={homeSVG} size="18px" />
|
78
89
|
{flattenToAppURL(item['@id'])} ( {item['@type']})
|
79
90
|
</>
|
80
91
|
}
|
@@ -82,7 +93,7 @@ const ObjectBrowserNav = ({
|
|
82
93
|
<span>
|
83
94
|
{item['@type'] === 'Image' ? (
|
84
95
|
<Image
|
85
|
-
src={`${item?.getURL}/@@images/image`}
|
96
|
+
src={`${item?.getURL}/@@images/image/icon`}
|
86
97
|
style={{
|
87
98
|
marginRight: '10px',
|
88
99
|
maxHeight: '24px',
|
@@ -6,9 +6,10 @@
|
|
6
6
|
import React from 'react';
|
7
7
|
import PropTypes from 'prop-types';
|
8
8
|
import { hasBlocksData, flattenHTMLToAppURL } from '@plone/volto/helpers';
|
9
|
-
import { Image
|
9
|
+
import { Image } from 'semantic-ui-react';
|
10
10
|
import RenderBlocks from '@plone/volto/components/theme/View/RenderBlocks';
|
11
11
|
import { EventDetails } from '@plone/volto/components';
|
12
|
+
import './style.less';
|
12
13
|
|
13
14
|
const EventTextfieldView = ({ content }) => (
|
14
15
|
<React.Fragment>
|
@@ -44,18 +45,14 @@ const EventView = (props) => {
|
|
44
45
|
|
45
46
|
return (
|
46
47
|
<div id="page-document" className="ui container viewwrapper event-view">
|
47
|
-
<
|
48
|
-
<
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
<Grid.Column mobile={12} tablet={5} computer={5}>
|
56
|
-
<EventDetails content={content} />
|
57
|
-
</Grid.Column>
|
58
|
-
</Grid>
|
48
|
+
<div className="event-view-box">
|
49
|
+
<EventDetails content={content} />
|
50
|
+
</div>
|
51
|
+
{hasBlocksData(content) ? (
|
52
|
+
<RenderBlocks {...props} />
|
53
|
+
) : (
|
54
|
+
<EventTextfieldView {...props} />
|
55
|
+
)}
|
59
56
|
</div>
|
60
57
|
);
|
61
58
|
};
|
@@ -0,0 +1,17 @@
|
|
1
|
+
@type: 'extra';
|
2
|
+
@element: 'custom';
|
3
|
+
|
4
|
+
@import (multiple, reference, optional) '../../theme.config';
|
5
|
+
|
6
|
+
.event-view-box {
|
7
|
+
position: relative;
|
8
|
+
top: -5vh;
|
9
|
+
right: 0vw;
|
10
|
+
}
|
11
|
+
|
12
|
+
@media only screen and (max-width: @largestMobileScreen) {
|
13
|
+
.event-view-box aside {
|
14
|
+
margin-left: 0 !important;
|
15
|
+
float: none !important;
|
16
|
+
}
|
17
|
+
}
|
@@ -0,0 +1,36 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
2
|
+
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
3
|
+
|
4
|
+
<svg
|
5
|
+
width="90mm"
|
6
|
+
height="90mm"
|
7
|
+
version="1.1"
|
8
|
+
viewBox="0 0 90 90"
|
9
|
+
id="svg8"
|
10
|
+
xmlns="http://www.w3.org/2000/svg"
|
11
|
+
xmlns:svg="http://www.w3.org/2000/svg">
|
12
|
+
<defs
|
13
|
+
id="defs12" />
|
14
|
+
<text
|
15
|
+
x="44.72715"
|
16
|
+
y="38.463978"
|
17
|
+
fill="#000000"
|
18
|
+
font-family="sans-serif"
|
19
|
+
font-size="16.933px"
|
20
|
+
letter-spacing="0px"
|
21
|
+
stroke-width=".26458"
|
22
|
+
text-align="center"
|
23
|
+
text-anchor="middle"
|
24
|
+
word-spacing="0px"
|
25
|
+
style="line-height:1.5"
|
26
|
+
xml:space="preserve"
|
27
|
+
id="text6"><tspan
|
28
|
+
x="44.72715"
|
29
|
+
y="38.463978"
|
30
|
+
text-align="center"
|
31
|
+
id="tspan2">Content</tspan><tspan
|
32
|
+
x="44.72715"
|
33
|
+
y="63.863926"
|
34
|
+
text-align="center"
|
35
|
+
id="tspan4">Box</tspan></text>
|
36
|
+
</svg>
|
@@ -1,5 +1,14 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
3
1
|
<svg width="90mm" height="90mm" version="1.1" viewBox="0 0 90 90" xmlns="http://www.w3.org/2000/svg">
|
4
|
-
<
|
2
|
+
<g stroke-width=".26458" aria-label="ContentBox">
|
3
|
+
<path d="m21.961 27.071v1.7611q-0.84334-0.78547-1.8024-1.1741-0.95083-0.3886-2.0257-0.3886-2.1166 0-3.2411 1.2981-1.1245 1.2898-1.1245 3.7372 0 2.4391 1.1245 3.7372 1.1245 1.2898 3.2411 1.2898 1.0748 0 2.0257-0.3886 0.9591-0.3886 1.8024-1.1741v1.7446q-0.87642 0.5953-1.8603 0.89295-0.97563 0.29765-2.067 0.29765-2.8029 0-4.4151-1.7115-1.6123-1.7198-1.6123-4.688 0-2.9765 1.6123-4.688 1.6123-1.7198 4.4151-1.7198 1.1079 0 2.0836 0.29765 0.9839 0.28938 1.8438 0.87642z"/>
|
4
|
+
<path d="m28.063 30.27q-1.2237 0-1.9347 0.9591-0.71105 0.95083-0.71105 2.6127 0 1.6619 0.70278 2.621 0.71105 0.95083 1.943 0.95083 1.2154 0 1.9265-0.9591 0.71105-0.9591 0.71105-2.6127 0-1.6453-0.71105-2.6044-0.71105-0.96736-1.9265-0.96736zm0-1.2898q1.9843 0 3.1171 1.2898 1.1327 1.2898 1.1327 3.5718 0 2.2737-1.1327 3.5718-1.1327 1.2898-3.1171 1.2898-1.9926 0-3.1253-1.2898-1.1245-1.2981-1.1245-3.5718 0-2.282 1.1245-3.5718 1.1327-1.2898 3.1253-1.2898z"/>
|
5
|
+
<path d="m42.532 32.875v5.5892h-1.5213v-5.5396q0-1.3146-0.51262-1.9678-0.51262-0.65318-1.5379-0.65318-1.2319 0-1.943 0.78547-0.71105 0.78547-0.71105 2.1414v5.2337h-1.5296v-9.2602h1.5296v1.4386q0.54569-0.83508 1.2816-1.2485 0.74413-0.4134 1.7115-0.4134 1.5957 0 2.4143 0.99217 0.81854 0.9839 0.81854 2.9021z"/>
|
6
|
+
<path d="m47.071 26.574v2.6292h3.1336v1.1823h-3.1336v5.027q0 1.1327 0.30592 1.4552 0.31419 0.32246 1.265 0.32246h1.5627v1.2733h-1.5627q-1.7611 0-2.4308-0.65318-0.66971-0.66145-0.66971-2.3977v-5.027h-1.1162v-1.1823h1.1162v-2.6292z"/>
|
7
|
+
<path d="m60.126 33.454v0.74413h-6.9948q0.09922 1.5709 0.94256 2.3977 0.85161 0.81854 2.3647 0.81854 0.87642 0 1.695-0.21497 0.82681-0.21497 1.6371-0.64491v1.4386q-0.81854 0.34726-1.6784 0.52916-0.85988 0.1819-1.7446 0.1819-2.2158 0-3.5139-1.2898-1.2898-1.2898-1.2898-3.4891 0-2.2737 1.2237-3.6049 1.2319-1.3394 3.3155-1.3394 1.8686 0 2.9517 1.2071 1.0914 1.1989 1.0914 3.2659zm-1.5213-0.44648q-0.01654-1.2485-0.70279-1.9926-0.67798-0.74413-1.8024-0.74413-1.2733 0-2.0422 0.71932-0.76066 0.71932-0.87642 2.0257z"/>
|
8
|
+
<path d="m70.321 32.875v5.5892h-1.5213v-5.5396q0-1.3146-0.51262-1.9678-0.51262-0.65318-1.5379-0.65318-1.2319 0-1.943 0.78547-0.71105 0.78547-0.71105 2.1414v5.2337h-1.5296v-9.2602h1.5296v1.4386q0.54569-0.83508 1.2816-1.2485 0.74413-0.4134 1.7115-0.4134 1.5957 0 2.4143 0.99217 0.81854 0.9839 0.81854 2.9021z"/>
|
9
|
+
<path d="m74.86 26.574v2.6292h3.1336v1.1823h-3.1336v5.027q0 1.1327 0.30592 1.4552 0.31419 0.32246 1.265 0.32246h1.5627v1.2733h-1.5627q-1.7611 0-2.4308-0.65318-0.66971-0.66145-0.66971-2.3977v-5.027h-1.1162v-1.1823h1.1162v-2.6292z"/>
|
10
|
+
<path d="m32.321 57.969v4.5226h2.6789q1.3477 0 1.9926-0.55396 0.65318-0.56223 0.65318-1.7115 0-1.1575-0.65318-1.7032-0.64491-0.55396-1.9926-0.55396zm0-5.0766v3.7206h2.4722q1.2237 0 1.819-0.45474 0.60357-0.46301 0.60357-1.4056 0-0.93429-0.60357-1.3973-0.5953-0.46301-1.819-0.46301zm-1.6702-1.3725h4.2663q1.9099 0 2.9434 0.79374 1.0335 0.79373 1.0335 2.2572 0 1.1327-0.52916 1.8024-0.52916 0.66971-1.5544 0.83507 1.2319 0.26458 1.9099 1.1079 0.68625 0.83508 0.68625 2.0918 0 1.6536-1.1245 2.5548-1.1245 0.90122-3.1997 0.90122h-4.4317z"/>
|
11
|
+
<path d="m45.79 55.67q-1.2237 0-1.9347 0.9591-0.71105 0.95083-0.71105 2.6127 0 1.6619 0.70279 2.621 0.71105 0.95083 1.943 0.95083 1.2154 0 1.9265-0.9591 0.71105-0.9591 0.71105-2.6127 0-1.6453-0.71105-2.6044-0.71105-0.96736-1.9265-0.96736zm0-1.2898q1.9843 0 3.1171 1.2898 1.1327 1.2898 1.1327 3.5718 0 2.2737-1.1327 3.5718-1.1327 1.2898-3.1171 1.2898-1.9926 0-3.1253-1.2898-1.1245-1.2981-1.1245-3.5718 0-2.282 1.1245-3.5718 1.1327-1.2898 3.1253-1.2898z"/>
|
12
|
+
<path d="m59.738 54.604-3.3486 4.5061 3.5222 4.7541h-1.7942l-2.6954-3.6379-2.6954 3.6379h-1.7942l3.5966-4.8451-3.2907-4.4151h1.7942l2.4556 3.299 2.4556-3.299z"/>
|
13
|
+
</g>
|
5
14
|
</svg>
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
2
|
+
<svg
|
3
|
+
width="36"
|
4
|
+
height="36"
|
5
|
+
viewBox="0 0 36 36"
|
6
|
+
version="1.1"
|
7
|
+
id="svg4"
|
8
|
+
xmlns="http://www.w3.org/2000/svg"
|
9
|
+
xmlns:svg="http://www.w3.org/2000/svg">
|
10
|
+
<defs
|
11
|
+
id="defs8" />
|
12
|
+
<text
|
13
|
+
xml:space="preserve"
|
14
|
+
style="font-size:42.6667px;line-height:1.25;font-family:'Serto Urhoy';-inkscape-font-specification:'Serto Urhoy';letter-spacing:0px;word-spacing:0px"
|
15
|
+
x="5.9687409"
|
16
|
+
y="30.979166"
|
17
|
+
id="text349"><tspan
|
18
|
+
id="tspan347"
|
19
|
+
x="5.9687409"
|
20
|
+
y="30.979166"
|
21
|
+
style="font-size:42.6667px">L</tspan></text>
|
22
|
+
</svg>
|
@@ -0,0 +1,5 @@
|
|
1
|
+
<svg width="36" height="36" version="1.1" viewBox="0 0 36 36" xmlns="http://www.w3.org/2000/svg">
|
2
|
+
<g aria-label="L">
|
3
|
+
<path d="m26.906 30.979-16.646 0.02083q-1.1667 0-1.1667-0.875 0-0.89583 1.1667-0.89583h1.4792l0.02083-20.875h-1.4792q-1.1667 0-1.1667-0.89583 0-0.875 1.1042-0.875h4.8333q1.1042 0 1.1042 0.875 0 0.89583-1.1667 0.89583h-1.4792v20.875h11.646l-0.02083-1.4792q0-1.1667 0.89583-1.1667 0.875 0 0.875 1.1042z"/>
|
4
|
+
</g>
|
5
|
+
</svg>
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
2
|
+
<svg
|
3
|
+
width="36"
|
4
|
+
height="36"
|
5
|
+
viewBox="0 0 36 36"
|
6
|
+
version="1.1"
|
7
|
+
id="svg4"
|
8
|
+
xmlns="http://www.w3.org/2000/svg"
|
9
|
+
xmlns:svg="http://www.w3.org/2000/svg">
|
10
|
+
<defs
|
11
|
+
id="defs8" />
|
12
|
+
<text
|
13
|
+
xml:space="preserve"
|
14
|
+
style="font-size:42.6667px;line-height:1.25;font-family:'Serto Urhoy';-inkscape-font-specification:'Serto Urhoy';letter-spacing:0px;word-spacing:0px"
|
15
|
+
x="5.9687409"
|
16
|
+
y="30.979166"
|
17
|
+
id="text349"><tspan
|
18
|
+
id="tspan347"
|
19
|
+
x="5.9687409"
|
20
|
+
y="30.979166"
|
21
|
+
style="font-size:42.6667px">s</tspan></text>
|
22
|
+
</svg>
|
@@ -0,0 +1,5 @@
|
|
1
|
+
<svg width="36" height="36" version="1.1" viewBox="0 0 36 36" xmlns="http://www.w3.org/2000/svg">
|
2
|
+
<g aria-label="s">
|
3
|
+
<path d="m24.427 26.5q0 2.625-2.625 4.0208-2.125 1.125-5 1.125-3.75 0-6.125-1.8958 0.0625 1.2917-0.79167 1.2917-0.79167 0-0.79167-1.0625v-3.25q0-1.0625 0.79167-1.0625 0.58333 0 0.83333 0.91667 0.35417 1.3125 0.39583 1.3958 1.375 2.1042 5.625 2.1042 2.1667 0 3.875-0.75 2.2292-0.95833 2.2292-2.8333 0-2.2708-3.3542-3.0417-3.125-0.5625-6.2292-1.125-3.3542-0.95833-3.3542-3.7292 0-2.25 2.375-3.4583 1.8958-0.95833 4.375-0.95833 3.2708 0 5.3125 1.6042-0.0625-1.0417 0.79167-1.0417 0.8125 0 0.8125 1.0625v2.7083q0 1.0625-0.8125 1.0625-0.52083 0-0.8125-0.95833-0.35417-1.2083-1.1458-1.7917-1.4167-1.0417-4.0833-1.0417-1.7708 0-3.25 0.58333-1.9583 0.79167-1.9583 2.2917 0 1.6667 2.4375 2.2708l5.125 0.83333q3.2083 0.625 4.4583 2.2083 0.89583 1.1458 0.89583 2.5208z"/>
|
4
|
+
</g>
|
5
|
+
</svg>
|
package/src/index.js
CHANGED
@@ -8,10 +8,9 @@ import SubsiteClass from './components/theme/SubsiteClass';
|
|
8
8
|
import HomePageView from '@eeacms/volto-eea-website-theme/components/theme/Homepage/HomePageView';
|
9
9
|
import HomePageInverseView from '@eeacms/volto-eea-website-theme/components/theme/Homepage/HomePageInverseView';
|
10
10
|
import { Icon } from '@plone/volto/components';
|
11
|
-
import paintSVG from '@plone/volto/icons/paint.svg';
|
12
11
|
import contentBoxSVG from './icons/content-box.svg';
|
13
12
|
import voltoCustomMiddleware from './middleware/voltoCustom';
|
14
|
-
import
|
13
|
+
import installSlate from './slate';
|
15
14
|
|
16
15
|
const applyConfig = (config) => {
|
17
16
|
// EEA specific settings
|
@@ -20,6 +19,24 @@ const applyConfig = (config) => {
|
|
20
19
|
...(config.settings.eea || {}),
|
21
20
|
};
|
22
21
|
|
22
|
+
// Insert scripts on Error pages
|
23
|
+
if (config.settings?.serverConfig?.extractScripts) {
|
24
|
+
config.settings.serverConfig.extractScripts.errorPages = true;
|
25
|
+
}
|
26
|
+
|
27
|
+
// Disable tags on View
|
28
|
+
config.settings.showTags = false;
|
29
|
+
|
30
|
+
// Enable Title block
|
31
|
+
config.blocks.blocksConfig.title.restricted = false;
|
32
|
+
|
33
|
+
// Enable description block (also for cypress)
|
34
|
+
config.blocks.blocksConfig.description.restricted = false;
|
35
|
+
config.blocks.requiredBlocks = [];
|
36
|
+
|
37
|
+
// Date format for EU
|
38
|
+
config.settings.dateLocale = 'en-gb';
|
39
|
+
|
23
40
|
// Custom Homepage layouts
|
24
41
|
config.views.layoutViews = {
|
25
42
|
...(config.views.layoutViews || {}),
|
@@ -31,6 +48,7 @@ const applyConfig = (config) => {
|
|
31
48
|
homepage_view: 'Homepage view',
|
32
49
|
homepage_inverse_view: 'Homepage white view',
|
33
50
|
};
|
51
|
+
|
34
52
|
// Apply accordion block customization
|
35
53
|
if (config.blocks.blocksConfig.accordion) {
|
36
54
|
config.blocks.blocksConfig.accordion.semanticIcon = 'ri-arrow-down-s-line';
|
@@ -88,67 +106,20 @@ const applyConfig = (config) => {
|
|
88
106
|
},
|
89
107
|
];
|
90
108
|
|
91
|
-
|
92
|
-
// Align Slate Lists to EEA Design System
|
93
|
-
config.settings.slate.elements.ul = ({ attributes, children }) => (
|
94
|
-
<List bulleted as="ul" {...attributes}>
|
95
|
-
{children}
|
96
|
-
</List>
|
97
|
-
);
|
98
|
-
|
99
|
-
config.settings.slate.elements.ol = ({ attributes, children }) => (
|
100
|
-
<List ordered as="ol" {...attributes}>
|
101
|
-
{children}
|
102
|
-
</List>
|
103
|
-
);
|
104
|
-
|
105
|
-
config.settings.slate.elements.li = ({ attributes, children }) => (
|
106
|
-
<List.Item as="li" {...attributes}>
|
107
|
-
{children}
|
108
|
-
</List.Item>
|
109
|
-
);
|
110
|
-
|
111
|
-
// Slate StyleMenu configuration
|
112
|
-
config.settings.slate.styleMenu = {
|
113
|
-
...(config.settings.slate.styleMenu || {}),
|
114
|
-
blockStyles: [
|
115
|
-
{
|
116
|
-
cssClass: 'primary',
|
117
|
-
label: 'Primary',
|
118
|
-
icon: () => <Icon name={paintSVG} size="18px" />,
|
119
|
-
},
|
120
|
-
{
|
121
|
-
cssClass: 'secondary',
|
122
|
-
label: 'Secondary',
|
123
|
-
icon: () => <Icon name={paintSVG} size="18px" />,
|
124
|
-
},
|
125
|
-
{
|
126
|
-
cssClass: 'tertiary',
|
127
|
-
label: 'Tertiary',
|
128
|
-
icon: () => <Icon name={paintSVG} size="18px" />,
|
129
|
-
},
|
130
|
-
{
|
131
|
-
cssClass: 'bordered',
|
132
|
-
label: 'Bordered',
|
133
|
-
icon: () => <Icon name={paintSVG} size="18px" />,
|
134
|
-
},
|
135
|
-
],
|
136
|
-
};
|
137
|
-
}
|
109
|
+
config = installSlate(config);
|
138
110
|
|
139
111
|
// Custom block-style colors
|
140
112
|
config.settings.available_colors = eea.colors;
|
141
113
|
|
142
114
|
// Site theme colors
|
143
|
-
|
144
115
|
config.settings.themeColors = [
|
145
|
-
{ value:
|
116
|
+
{ value: undefined, title: 'No theme' },
|
146
117
|
{ value: 'primary', title: 'Primary' },
|
147
118
|
{ value: 'secondary', title: 'Secondary' },
|
148
119
|
{ value: 'tertiary', title: 'Tertiary' },
|
149
120
|
];
|
150
121
|
|
151
|
-
// Custom
|
122
|
+
// Custom preset styles - content-box
|
152
123
|
config.settings.previewText = '';
|
153
124
|
config.settings.pluggableStyles = [
|
154
125
|
...(config.settings.pluggableStyles || []),
|
@@ -210,7 +181,7 @@ const applyConfig = (config) => {
|
|
210
181
|
},
|
211
182
|
];
|
212
183
|
|
213
|
-
// Custom blocks
|
184
|
+
// Custom blocks: Title
|
214
185
|
return [installCustomTitle].reduce((acc, apply) => apply(acc), config);
|
215
186
|
};
|
216
187
|
|
package/src/slate.js
ADDED
@@ -0,0 +1,323 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { List } from 'semantic-ui-react';
|
3
|
+
import { MarkElementButton, ToolbarButton } from '@plone/volto-slate/editor/ui';
|
4
|
+
import installCallout from '@plone/volto-slate/editor/plugins/Callout';
|
5
|
+
import { Icon } from '@plone/volto/components';
|
6
|
+
import { Editor, Transforms } from 'slate';
|
7
|
+
import { useSlate } from 'slate-react';
|
8
|
+
|
9
|
+
import formatClearIcon from '@plone/volto/icons/format-clear.svg';
|
10
|
+
import paintSVG from '@plone/volto/icons/paint.svg';
|
11
|
+
import alignLeftIcon from '@plone/volto/icons/align-left.svg';
|
12
|
+
import alignRightIcon from '@plone/volto/icons/align-right.svg';
|
13
|
+
import alignCenterIcon from '@plone/volto/icons/align-center.svg';
|
14
|
+
import alignJustifyIcon from '@plone/volto/icons/align-justify.svg';
|
15
|
+
import lightIcon from './icons/light.svg';
|
16
|
+
import smallIcon from './icons/small.svg';
|
17
|
+
|
18
|
+
const toggleBlockClassFormat = (editor, format) => {
|
19
|
+
const levels = Array.from(Editor.levels(editor, editor.selection));
|
20
|
+
const [, [, path]] = levels;
|
21
|
+
Transforms.setNodes(
|
22
|
+
editor,
|
23
|
+
{ styleName: format },
|
24
|
+
{
|
25
|
+
at: path,
|
26
|
+
},
|
27
|
+
);
|
28
|
+
return;
|
29
|
+
};
|
30
|
+
|
31
|
+
const isBlockClassActive = (editor, format) => {
|
32
|
+
if (!editor.selection) return false;
|
33
|
+
const levels = Array.from(Editor.levels(editor, editor.selection));
|
34
|
+
const [, [node]] = levels;
|
35
|
+
return node.styleName === format;
|
36
|
+
};
|
37
|
+
|
38
|
+
function BlockClassButton({ format, icon, ...props }) {
|
39
|
+
const editor = useSlate();
|
40
|
+
|
41
|
+
const isActive = isBlockClassActive(editor, format);
|
42
|
+
|
43
|
+
const handleMouseDown = React.useCallback(
|
44
|
+
(event) => {
|
45
|
+
event.preventDefault();
|
46
|
+
toggleBlockClassFormat(editor, format);
|
47
|
+
},
|
48
|
+
[editor, format], // , isActive
|
49
|
+
);
|
50
|
+
|
51
|
+
return (
|
52
|
+
<ToolbarButton
|
53
|
+
{...props}
|
54
|
+
active={isActive}
|
55
|
+
onMouseDown={handleMouseDown}
|
56
|
+
icon={icon}
|
57
|
+
/>
|
58
|
+
);
|
59
|
+
}
|
60
|
+
|
61
|
+
const clearFormatting = (editor) => {
|
62
|
+
Transforms.setNodes(editor, {
|
63
|
+
type: 'p',
|
64
|
+
styleName: null,
|
65
|
+
});
|
66
|
+
Transforms.unwrapNodes(editor, {
|
67
|
+
match: (n) => n.type && n.type !== 'p',
|
68
|
+
mode: 'all',
|
69
|
+
split: false,
|
70
|
+
});
|
71
|
+
};
|
72
|
+
|
73
|
+
const ClearFormattingButton = ({ icon, ...props }) => {
|
74
|
+
const editor = useSlate();
|
75
|
+
|
76
|
+
const handleMouseDown = React.useCallback(
|
77
|
+
(event) => {
|
78
|
+
event.preventDefault();
|
79
|
+
clearFormatting(editor);
|
80
|
+
},
|
81
|
+
[editor],
|
82
|
+
);
|
83
|
+
|
84
|
+
return <ToolbarButton {...props} onMouseDown={handleMouseDown} icon={icon} />;
|
85
|
+
};
|
86
|
+
|
87
|
+
export default function installSlate(config) {
|
88
|
+
if (config.settings.slate) {
|
89
|
+
// Callout slate button
|
90
|
+
config = installCallout(config);
|
91
|
+
|
92
|
+
config.settings.slate.buttons.clearformatting = (props) => (
|
93
|
+
<ClearFormattingButton title="Clear formatting" icon={formatClearIcon} />
|
94
|
+
);
|
95
|
+
|
96
|
+
// Remove blockquote, italic, strikethrough slate button from toolbarButtons
|
97
|
+
config.settings.slate.toolbarButtons = config.settings.slate.toolbarButtons.filter(
|
98
|
+
(item) => !['blockquote', 'italic', 'strikethrough'].includes(item),
|
99
|
+
);
|
100
|
+
|
101
|
+
// Remove blockquote, italic, strikethrough slate button from expandedToolbarButtons
|
102
|
+
config.settings.slate.expandedToolbarButtons = config.settings.slate.expandedToolbarButtons.filter(
|
103
|
+
(item) => !['blockquote', 'italic', 'strikethrough'].includes(item),
|
104
|
+
);
|
105
|
+
|
106
|
+
// Remove 'underline' and 'italic' hotkeys
|
107
|
+
config.settings.slate.hotkeys = Object.keys(config.settings.slate.hotkeys)
|
108
|
+
.filter((item) => !['mod+u', 'mod+i'].includes(item))
|
109
|
+
.reduce((out, key) => {
|
110
|
+
out[key] = config.settings.slate.hotkeys[key];
|
111
|
+
return out;
|
112
|
+
}, {});
|
113
|
+
|
114
|
+
// Small button
|
115
|
+
if (!config.settings.slate.toolbarButtons.includes('small')) {
|
116
|
+
config.settings.slate.elements.small = ({ children }) => (
|
117
|
+
<small>{children}</small>
|
118
|
+
);
|
119
|
+
|
120
|
+
config.settings.slate.buttons.small = (props) => (
|
121
|
+
<MarkElementButton
|
122
|
+
title="Small"
|
123
|
+
format="small"
|
124
|
+
icon={smallIcon}
|
125
|
+
{...props}
|
126
|
+
/>
|
127
|
+
);
|
128
|
+
|
129
|
+
config.settings.slate.inlineElements = [
|
130
|
+
...config.settings.slate.inlineElements,
|
131
|
+
'small',
|
132
|
+
];
|
133
|
+
|
134
|
+
config.settings.slate.toolbarButtons = [
|
135
|
+
...config.settings.slate.toolbarButtons.slice(0, 1),
|
136
|
+
'small',
|
137
|
+
...config.settings.slate.toolbarButtons.slice(1),
|
138
|
+
];
|
139
|
+
|
140
|
+
config.settings.slate.hotkeys['mod+s'] = {
|
141
|
+
format: 'small',
|
142
|
+
type: 'inline',
|
143
|
+
};
|
144
|
+
}
|
145
|
+
|
146
|
+
// Light button
|
147
|
+
if (!config.settings.slate.toolbarButtons.includes('light')) {
|
148
|
+
config.settings.slate.elements.light = ({ children }) => (
|
149
|
+
<span className="fw-light">{children}</span>
|
150
|
+
);
|
151
|
+
|
152
|
+
config.settings.slate.buttons.light = (props) => (
|
153
|
+
<MarkElementButton
|
154
|
+
title="Light"
|
155
|
+
format="light"
|
156
|
+
icon={lightIcon}
|
157
|
+
{...props}
|
158
|
+
/>
|
159
|
+
);
|
160
|
+
|
161
|
+
config.settings.slate.inlineElements = [
|
162
|
+
...config.settings.slate.inlineElements,
|
163
|
+
'light',
|
164
|
+
];
|
165
|
+
|
166
|
+
config.settings.slate.toolbarButtons = [
|
167
|
+
...config.settings.slate.toolbarButtons.slice(0, 1),
|
168
|
+
'light',
|
169
|
+
...config.settings.slate.toolbarButtons.slice(1),
|
170
|
+
];
|
171
|
+
|
172
|
+
config.settings.slate.hotkeys['mod+l'] = {
|
173
|
+
format: 'light',
|
174
|
+
type: 'inline',
|
175
|
+
};
|
176
|
+
}
|
177
|
+
|
178
|
+
// Align Slate Lists to EEA Design System
|
179
|
+
config.settings.slate.elements.ul = ({ attributes, children }) => (
|
180
|
+
<List bulleted as="ul" {...attributes}>
|
181
|
+
{children}
|
182
|
+
</List>
|
183
|
+
);
|
184
|
+
|
185
|
+
config.settings.slate.elements.ol = ({ attributes, children }) => (
|
186
|
+
<List ordered as="ol" {...attributes}>
|
187
|
+
{children}
|
188
|
+
</List>
|
189
|
+
);
|
190
|
+
|
191
|
+
config.settings.slate.elements.li = ({ attributes, children }) => (
|
192
|
+
<List.Item as="li" {...attributes}>
|
193
|
+
{children}
|
194
|
+
</List.Item>
|
195
|
+
);
|
196
|
+
|
197
|
+
// Slate StyleMenu configuration
|
198
|
+
config.settings.slate.styleMenu = {
|
199
|
+
...(config.settings.slate.styleMenu || {}),
|
200
|
+
blockStyles: [
|
201
|
+
{
|
202
|
+
cssClass: 'primary',
|
203
|
+
label: 'Primary',
|
204
|
+
icon: () => <Icon name={paintSVG} size="18px" />,
|
205
|
+
},
|
206
|
+
{
|
207
|
+
cssClass: 'secondary',
|
208
|
+
label: 'Secondary',
|
209
|
+
icon: () => <Icon name={paintSVG} size="18px" />,
|
210
|
+
},
|
211
|
+
{
|
212
|
+
cssClass: 'tertiary',
|
213
|
+
label: 'Tertiary',
|
214
|
+
icon: () => <Icon name={paintSVG} size="18px" />,
|
215
|
+
},
|
216
|
+
],
|
217
|
+
};
|
218
|
+
|
219
|
+
// Text Align buttons
|
220
|
+
|
221
|
+
// Align left
|
222
|
+
if (!config.settings.slate.toolbarButtons.includes('text-left')) {
|
223
|
+
config.settings.slate.buttons['text-left'] = (props) => (
|
224
|
+
<BlockClassButton
|
225
|
+
format="text-left"
|
226
|
+
icon={alignLeftIcon}
|
227
|
+
title="Align left"
|
228
|
+
{...props}
|
229
|
+
/>
|
230
|
+
);
|
231
|
+
|
232
|
+
config.settings.slate.toolbarButtons = [
|
233
|
+
...config.settings.slate.toolbarButtons,
|
234
|
+
'separator',
|
235
|
+
'text-left',
|
236
|
+
];
|
237
|
+
|
238
|
+
config.settings.slate.expandedToolbarButtons = [
|
239
|
+
...config.settings.slate.expandedToolbarButtons,
|
240
|
+
'separator',
|
241
|
+
'text-left',
|
242
|
+
];
|
243
|
+
}
|
244
|
+
|
245
|
+
// Align center
|
246
|
+
if (!config.settings.slate.toolbarButtons.includes('text-center')) {
|
247
|
+
config.settings.slate.buttons['text-center'] = (props) => (
|
248
|
+
<BlockClassButton
|
249
|
+
format="text-center"
|
250
|
+
icon={alignCenterIcon}
|
251
|
+
title="Align center"
|
252
|
+
{...props}
|
253
|
+
/>
|
254
|
+
);
|
255
|
+
|
256
|
+
config.settings.slate.toolbarButtons = [
|
257
|
+
...config.settings.slate.toolbarButtons,
|
258
|
+
'text-center',
|
259
|
+
];
|
260
|
+
|
261
|
+
config.settings.slate.expandedToolbarButtons = [
|
262
|
+
...config.settings.slate.expandedToolbarButtons,
|
263
|
+
'text-center',
|
264
|
+
];
|
265
|
+
}
|
266
|
+
|
267
|
+
// Align right
|
268
|
+
if (!config.settings.slate.toolbarButtons.includes('text-right')) {
|
269
|
+
config.settings.slate.buttons['text-right'] = (props) => (
|
270
|
+
<BlockClassButton
|
271
|
+
format="text-right"
|
272
|
+
icon={alignRightIcon}
|
273
|
+
title="Align right"
|
274
|
+
{...props}
|
275
|
+
/>
|
276
|
+
);
|
277
|
+
|
278
|
+
config.settings.slate.toolbarButtons = [
|
279
|
+
...config.settings.slate.toolbarButtons,
|
280
|
+
'text-right',
|
281
|
+
];
|
282
|
+
|
283
|
+
config.settings.slate.expandedToolbarButtons = [
|
284
|
+
...config.settings.slate.expandedToolbarButtons,
|
285
|
+
'text-right',
|
286
|
+
];
|
287
|
+
}
|
288
|
+
|
289
|
+
// Align justify
|
290
|
+
if (!config.settings.slate.toolbarButtons.includes('text-justify')) {
|
291
|
+
config.settings.slate.buttons['text-justify'] = (props) => (
|
292
|
+
<BlockClassButton
|
293
|
+
format="text-justify"
|
294
|
+
icon={alignJustifyIcon}
|
295
|
+
title="Align justify"
|
296
|
+
{...props}
|
297
|
+
/>
|
298
|
+
);
|
299
|
+
|
300
|
+
config.settings.slate.toolbarButtons = [
|
301
|
+
...config.settings.slate.toolbarButtons,
|
302
|
+
'text-justify',
|
303
|
+
'separator',
|
304
|
+
];
|
305
|
+
|
306
|
+
config.settings.slate.expandedToolbarButtons = [
|
307
|
+
...config.settings.slate.expandedToolbarButtons,
|
308
|
+
'text-justify',
|
309
|
+
'separator',
|
310
|
+
];
|
311
|
+
}
|
312
|
+
|
313
|
+
// Clear formatting
|
314
|
+
if (!config.settings.slate.toolbarButtons.includes('clearformatting')) {
|
315
|
+
config.settings.slate.toolbarButtons = [
|
316
|
+
...config.settings.slate.toolbarButtons,
|
317
|
+
'clearformatting',
|
318
|
+
];
|
319
|
+
}
|
320
|
+
}
|
321
|
+
|
322
|
+
return config;
|
323
|
+
}
|