@eeacms/volto-eea-website-policy 0.2.6 → 0.3.2

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 CHANGED
@@ -4,8 +4,30 @@ 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
+ #### [0.3.2](https://github.com/eea/volto-eea-website-policy/compare/0.3.1...0.3.2)
8
+
9
+ - Safely get data - refs #153018 [`aefc689`](https://github.com/eea/volto-eea-website-policy/commit/aefc68979f6aad86ea02952f82e639dfe8c566f2)
10
+ - Customize Blocks helper - copy unchanged from @plone/volto 16.alpha.12 [`368ffa8`](https://github.com/eea/volto-eea-website-policy/commit/368ffa8c9ebfc54d364d7bf13b60f4016f1c90e8)
11
+
12
+ #### [0.3.1](https://github.com/eea/volto-eea-website-policy/compare/0.3.0...0.3.1)
13
+
14
+ > 1 August 2022
15
+
16
+ - feature(navigation): addde context navigation block [`#14`](https://github.com/eea/volto-eea-website-policy/pull/14)
17
+
18
+ #### [0.3.0](https://github.com/eea/volto-eea-website-policy/compare/0.2.6...0.3.0)
19
+
20
+ > 6 July 2022
21
+
22
+ - change(teaser): enabled theming for icon and text color [`#13`](https://github.com/eea/volto-eea-website-policy/pull/13)
23
+ - change(package): bump release version [`1b00439`](https://github.com/eea/volto-eea-website-policy/commit/1b0043933442bb73c1042dce644a2c09e5f210f4)
24
+ - change(item): enable theming for icon and text color and added tertiary option [`58c2d28`](https://github.com/eea/volto-eea-website-policy/commit/58c2d2864fe94c9e7808064b61d3b6c4e6fccbb1)
25
+ - change(item): commented sizes too small for item icons and enabled tertiary theme [`0f02d7d`](https://github.com/eea/volto-eea-website-policy/commit/0f02d7d6204b068b78c3f977a561782a19b6f79e)
26
+
7
27
  #### [0.2.6](https://github.com/eea/volto-eea-website-policy/compare/0.2.5...0.2.6)
8
28
 
29
+ > 1 July 2022
30
+
9
31
  - Fix Cannot read properties of undefined (reading 'translations') [`8e7b8b8`](https://github.com/eea/volto-eea-website-policy/commit/8e7b8b8533b14f173d77783fe2d0b517c29c5937)
10
32
  - Customize Toolbar.jsx - copied unchanged from @plone/volto 16.0.0.alpha.11 [`b7add4f`](https://github.com/eea/volto-eea-website-policy/commit/b7add4faa8ef2dde7d77489fc8bc431cbb023314)
11
33
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-eea-website-policy",
3
- "version": "0.2.6",
3
+ "version": "0.3.2",
4
4
  "description": "@eeacms/volto-eea-website-policy: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: IDM2 A-Team",
@@ -0,0 +1,31 @@
1
+ import React from 'react';
2
+ import { EditSchema } from './schema';
3
+ import { InlineForm, SidebarPortal } from '@plone/volto/components';
4
+ import ContextNavigationView from './ContextNavigationView';
5
+
6
+ const ContextNavigationFillView = (props) => {
7
+ const schema = EditSchema();
8
+ return (
9
+ <>
10
+ <h3>Context navigation</h3>
11
+ <ContextNavigationView {...props} />{' '}
12
+ <SidebarPortal selected={props.selected}>
13
+ {props.selected && (
14
+ <InlineForm
15
+ title={schema.title}
16
+ schema={schema}
17
+ formData={props.data}
18
+ onChangeField={(id, value) => {
19
+ props.onChangeBlock(props.block, {
20
+ ...props.data,
21
+ [id]: value,
22
+ });
23
+ }}
24
+ />
25
+ )}
26
+ </SidebarPortal>
27
+ </>
28
+ );
29
+ };
30
+
31
+ export default ContextNavigationFillView;
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ import ConnectedContextNavigation from '@plone/volto/components/theme/Navigation/ContextNavigation';
3
+ import { flattenToAppURL } from '@plone/volto/helpers';
4
+
5
+ const ContextNavigationView = ({ data = {} }) => {
6
+ const navProps = { ...data };
7
+ const root_path = data?.root_node?.[0]?.['@id'];
8
+ if (root_path) navProps['root_path'] = flattenToAppURL(root_path);
9
+
10
+ return (
11
+ <>
12
+ <ConnectedContextNavigation params={navProps} />
13
+ </>
14
+ );
15
+ };
16
+
17
+ export default ContextNavigationView;
@@ -0,0 +1,26 @@
1
+ import codeSVG from '@plone/volto/icons/code.svg';
2
+ import ContextNavigationEdit from './ContextNavigationEdit';
3
+ import ContextNavigationView from './ContextNavigationView';
4
+ import BlockSettingsSchema from '@plone/volto/components/manage/Blocks/Block/Schema';
5
+
6
+ export default (config) => {
7
+ config.blocks.blocksConfig.contextNavigation = {
8
+ id: 'contextNavigation',
9
+ title: 'Navigation',
10
+ icon: codeSVG,
11
+ group: 'site',
12
+ view: ContextNavigationView,
13
+ edit: ContextNavigationEdit,
14
+ schema: BlockSettingsSchema,
15
+ restricted: false,
16
+ mostUsed: true,
17
+ blockHasOwnFocusManagement: true,
18
+ sidebarTab: 1,
19
+ security: {
20
+ addPermission: [],
21
+ view: [],
22
+ },
23
+ };
24
+
25
+ return config;
26
+ };
@@ -0,0 +1,81 @@
1
+ export const EditSchema = () => {
2
+ return {
3
+ title: 'Navigation',
4
+ fieldsets: [
5
+ {
6
+ id: 'default',
7
+ title: 'Default',
8
+ fields: [
9
+ 'name',
10
+ 'root_node',
11
+ 'includeTop',
12
+ 'currentFolderOnly',
13
+ 'topLevel',
14
+ 'bottomLevel',
15
+ 'no_icons',
16
+ 'thumb_scale',
17
+ 'no_thumbs',
18
+ ],
19
+ },
20
+ ],
21
+ required: [],
22
+ properties: {
23
+ name: {
24
+ title: 'Title',
25
+ description: 'The title of the navigation tree',
26
+ },
27
+ root_node: {
28
+ title: 'Root node',
29
+ description:
30
+ 'You may search for and choose a folder to act as the root of the navigation tree. Leave blank to use the Plone site root.',
31
+ widget: 'object_browser',
32
+ // TODO: these don't work. Why?
33
+ mode: 'link',
34
+ selectedItemAttrs: ['Title', 'Description'],
35
+ },
36
+ includeTop: {
37
+ title: 'Include top node',
38
+ description:
39
+ "Whether or not to show the top, or 'root', node in the navigation tree. This is affected by the 'Start level' setting.",
40
+ type: 'boolean',
41
+ },
42
+ currentFolderOnly: {
43
+ title: 'Only show the contents of the current folder',
44
+ description:
45
+ 'If selected, the navigation tree will only show the current folder and its children at all times.',
46
+ type: 'boolean',
47
+ },
48
+
49
+ topLevel: {
50
+ title: 'Start level',
51
+ description:
52
+ 'An integer value that specifies the number of folder levels below the site root that must be exceeded before the navigation tree will display. 0 means that the navigation tree should be displayed everywhere including pages in the root of the site. 1 means the tree only shows up inside folders located in the root and downwards, never showing at the top level.',
53
+ type: 'number',
54
+ default: 1,
55
+ },
56
+ bottomLevel: {
57
+ title: 'Navigation tree depth',
58
+ description:
59
+ 'How many folders should be included before the navigation tree stops. 0 means no limit. 1 only includes the root folder.',
60
+ type: 'number',
61
+ default: 0,
62
+ },
63
+ no_icons: {
64
+ title: 'Supress icons',
65
+ description:
66
+ 'If enabled, the portlet will not show document type icons.',
67
+ type: 'boolean',
68
+ },
69
+ thumb_scale: {
70
+ title: 'Override thumb scale',
71
+ description:
72
+ "Enter a valid scale name (see 'Image Handling' control panel) to override (e.g. icon, tile, thumb, mini, preview, ... ). Leave empty to use default (see 'Site' control panel).",
73
+ },
74
+ no_thumbs: {
75
+ title: 'Supress thumbs',
76
+ type: 'boolean',
77
+ description: 'If enabled, the portlet will not show thumbs.',
78
+ },
79
+ },
80
+ };
81
+ };
@@ -12,7 +12,13 @@ export default ({ data }) => {
12
12
  ? [{ id: 'image', title: 'Image', fields: ['image', 'imageSize'] }]
13
13
  : []),
14
14
  ...(assetType === 'icon'
15
- ? [{ id: 'icon', title: 'Icon', fields: ['icon', 'iconSize'] }]
15
+ ? [
16
+ {
17
+ id: 'icon',
18
+ title: 'Icon',
19
+ fields: ['icon', 'iconSize', 'iconTheme'],
20
+ },
21
+ ]
16
22
  : []),
17
23
  ],
18
24
  properties: {
@@ -31,10 +37,11 @@ export default ({ data }) => {
31
37
  imageSize: {
32
38
  title: 'Image size',
33
39
  choices: [
34
- ['mini', 'Mini'],
35
- ['tile', 'Tile'],
36
- ['tiny', 'Tiny'],
37
- ['small', 'Small'],
40
+ // commented as they were too small to use as item icons
41
+ // ['mini', 'Mini'],
42
+ // ['tile', 'Tile'],
43
+ // ['tiny', 'Tiny'],
44
+ // ['small', 'Small'],
38
45
  ['large', 'Large'],
39
46
  ['big', 'Big'],
40
47
  ['huge', 'Huge'],
@@ -63,6 +70,7 @@ export default ({ data }) => {
63
70
  choices: [
64
71
  ['primary', 'Primary'],
65
72
  ['secondary', 'Secondary'],
73
+ ['tertiary', 'Tertiary'],
66
74
  ],
67
75
  },
68
76
  },
@@ -86,6 +94,7 @@ export const stylingSchema = ({ intl }) => ({
86
94
  choices: [
87
95
  ['primary', 'Primary'],
88
96
  ['secondary', 'Secondary'],
97
+ ['tertiary', 'Tertiary'],
89
98
  ],
90
99
  },
91
100
  verticalAlign: {
@@ -0,0 +1,440 @@
1
+ /**
2
+ * Blocks helper.
3
+ * @module helpers/Blocks
4
+ */
5
+
6
+ import { omit, without, endsWith, find, isObject, keys, toPairs } from 'lodash';
7
+ import move from 'lodash-move';
8
+ import { v4 as uuid } from 'uuid';
9
+ import config from '@plone/volto/registry';
10
+ import { applySchemaEnhancer } from '@plone/volto/helpers';
11
+
12
+ /**
13
+ * Get blocks field.
14
+ * @function getBlocksFieldname
15
+ * @param {Object} props Properties.
16
+ * @return {string} Field name of the blocks
17
+ */
18
+ export function getBlocksFieldname(props) {
19
+ return (
20
+ find(
21
+ keys(props),
22
+ (key) => key !== 'volto.blocks' && endsWith(key, 'blocks'),
23
+ ) || null
24
+ );
25
+ }
26
+
27
+ /**
28
+ * Get blocks layout field.
29
+ * @function getBlocksLayoutFieldname
30
+ * @param {Object} props Properties.
31
+ * @return {string} Field name of the blocks layout
32
+ */
33
+ export function getBlocksLayoutFieldname(props) {
34
+ return (
35
+ find(
36
+ keys(props),
37
+ (key) => key !== 'volto.blocks' && endsWith(key, 'blocks_layout'),
38
+ ) || null
39
+ );
40
+ }
41
+
42
+ /**
43
+ * Has blocks data.
44
+ * @function hasBlocksData
45
+ * @param {Object} props Properties.
46
+ * @return {boolean} True if it has blocks data.
47
+ */
48
+ export function hasBlocksData(props) {
49
+ return (
50
+ find(
51
+ keys(props),
52
+ (key) => key !== 'volto.blocks' && endsWith(key, 'blocks'),
53
+ ) !== undefined
54
+ );
55
+ }
56
+
57
+ /**
58
+ * Pluggable method to test if a block has a set value (any non-empty value)
59
+ * @function blockHasValue
60
+ * @param {Object} data Block data
61
+ * @return {boolean} True if block has a non-empty value
62
+ */
63
+ export function blockHasValue(data) {
64
+ const { blocks } = config;
65
+ const blockType = data['@type'];
66
+ const check = blocks.blocksConfig[blockType]?.blockHasValue;
67
+ if (!check) {
68
+ return true;
69
+ }
70
+ return check(data);
71
+ }
72
+
73
+ /**
74
+ * Get block pairs of [id, block] from content properties
75
+ * @function getBlocks
76
+ * @param {Object} properties
77
+ * @return {Array} a list of block [id, value] pairs, in order from layout
78
+ */
79
+ export const getBlocks = (properties) => {
80
+ const blocksFieldName = getBlocksFieldname(properties);
81
+ const blocksLayoutFieldname = getBlocksLayoutFieldname(properties);
82
+ return (
83
+ properties[blocksLayoutFieldname]?.items?.map((n) => [
84
+ n,
85
+ properties[blocksFieldName][n],
86
+ ]) || []
87
+ );
88
+ };
89
+
90
+ /**
91
+ * Move block to different location index within blocks_layout
92
+ * @function moveBlock
93
+ * @param {Object} formData Form data
94
+ * @param {number} source index within form blocks_layout items
95
+ * @param {number} destination index within form blocks_layout items
96
+ * @return {Object} New form data
97
+ */
98
+ export function moveBlock(formData, source, destination) {
99
+ const blocksLayoutFieldname = getBlocksLayoutFieldname(formData);
100
+ return {
101
+ ...formData,
102
+ [blocksLayoutFieldname]: {
103
+ items: move(formData[blocksLayoutFieldname].items, source, destination),
104
+ },
105
+ };
106
+ }
107
+
108
+ /**
109
+ * Delete block by id
110
+ * @function deleteBlock
111
+ * @param {Object} formData Form data
112
+ * @param {string} blockId Block uid
113
+ * @return {Object} New form data
114
+ */
115
+ export function deleteBlock(formData, blockId) {
116
+ const blocksFieldname = getBlocksFieldname(formData);
117
+ const blocksLayoutFieldname = getBlocksLayoutFieldname(formData);
118
+
119
+ let newFormData = {
120
+ ...formData,
121
+ [blocksLayoutFieldname]: {
122
+ items: without(formData[blocksLayoutFieldname].items, blockId),
123
+ },
124
+ [blocksFieldname]: omit(formData[blocksFieldname], [blockId]),
125
+ };
126
+
127
+ if (newFormData[blocksLayoutFieldname].items.length === 0) {
128
+ newFormData = addBlock(newFormData, config.settings.defaultBlockType, 0);
129
+ }
130
+
131
+ return newFormData;
132
+ }
133
+
134
+ /**
135
+ * Add block
136
+ * @function addBlock
137
+ * @param {Object} formData Form data
138
+ * @param {string} type Block type
139
+ * @param {number} index Destination index
140
+ * @return {Array} New block id, New form data
141
+ */
142
+ export function addBlock(formData, type, index) {
143
+ const { settings } = config;
144
+ const id = uuid();
145
+ const idTrailingBlock = uuid();
146
+ const blocksFieldname = getBlocksFieldname(formData);
147
+ const blocksLayoutFieldname = getBlocksLayoutFieldname(formData);
148
+ const totalItems = formData[blocksLayoutFieldname].items.length;
149
+ const insert = index === -1 ? totalItems : index;
150
+
151
+ return [
152
+ id,
153
+ {
154
+ ...formData,
155
+ [blocksLayoutFieldname]: {
156
+ items: [
157
+ ...formData[blocksLayoutFieldname].items.slice(0, insert),
158
+ id,
159
+ ...(type !== settings.defaultBlockType ? [idTrailingBlock] : []),
160
+ ...formData[blocksLayoutFieldname].items.slice(insert),
161
+ ],
162
+ },
163
+ [blocksFieldname]: {
164
+ ...formData[blocksFieldname],
165
+ [id]: {
166
+ '@type': type,
167
+ },
168
+ ...(type !== settings.defaultBlockType && {
169
+ [idTrailingBlock]: {
170
+ '@type': settings.defaultBlockType,
171
+ },
172
+ }),
173
+ },
174
+ selected: id,
175
+ },
176
+ ];
177
+ }
178
+
179
+ /**
180
+ * Mutate block
181
+ * @function mutateBlock
182
+ * @param {Object} formData Form data
183
+ * @param {string} id Block uid to mutate
184
+ * @param {number} value Block's new value
185
+ * @return {Object} New form data
186
+ */
187
+ export function mutateBlock(formData, id, value) {
188
+ const { settings } = config;
189
+ const blocksFieldname = getBlocksFieldname(formData);
190
+ const blocksLayoutFieldname = getBlocksLayoutFieldname(formData);
191
+ const index = formData[blocksLayoutFieldname].items.indexOf(id) + 1;
192
+
193
+ // Test if block at index is already a placeholder (trailing) block
194
+ const trailId = formData[blocksLayoutFieldname].items[index];
195
+ if (trailId) {
196
+ const block = formData[blocksFieldname][trailId];
197
+ if (!blockHasValue(block)) {
198
+ return {
199
+ ...formData,
200
+ [blocksFieldname]: {
201
+ ...formData[blocksFieldname],
202
+ [id]: value || null,
203
+ },
204
+ };
205
+ }
206
+ }
207
+
208
+ const idTrailingBlock = uuid();
209
+ return {
210
+ ...formData,
211
+ [blocksFieldname]: {
212
+ ...formData[blocksFieldname],
213
+ [id]: value || null,
214
+ [idTrailingBlock]: {
215
+ '@type': settings.defaultBlockType,
216
+ },
217
+ },
218
+ [blocksLayoutFieldname]: {
219
+ items: [
220
+ ...formData[blocksLayoutFieldname].items.slice(0, index),
221
+ idTrailingBlock,
222
+ ...formData[blocksLayoutFieldname].items.slice(index),
223
+ ],
224
+ },
225
+ };
226
+ }
227
+
228
+ /**
229
+ * Insert new block before another block
230
+ * @function insertBlock
231
+ * @param {Object} formData Form data
232
+ * @param {string} id Insert new block before the block with this id
233
+ * @param {number} value New block's value
234
+ * @return {Array} New block id, New form data
235
+ */
236
+ export function insertBlock(formData, id, value, current = {}) {
237
+ const blocksFieldname = getBlocksFieldname(formData);
238
+ const blocksLayoutFieldname = getBlocksLayoutFieldname(formData);
239
+ const index = formData[blocksLayoutFieldname].items.indexOf(id);
240
+
241
+ const newBlockId = uuid();
242
+ return [
243
+ newBlockId,
244
+ {
245
+ ...formData,
246
+ [blocksFieldname]: {
247
+ ...formData[blocksFieldname],
248
+ [newBlockId]: value || null,
249
+ [id]: {
250
+ ...formData[blocksFieldname][id],
251
+ ...current,
252
+ },
253
+ },
254
+ [blocksLayoutFieldname]: {
255
+ items: [
256
+ ...formData[blocksLayoutFieldname].items.slice(0, index),
257
+ newBlockId,
258
+ ...formData[blocksLayoutFieldname].items.slice(index),
259
+ ],
260
+ },
261
+ },
262
+ ];
263
+ }
264
+
265
+ /**
266
+ * Change block
267
+ * @function changeBlock
268
+ * @param {Object} formData Form data
269
+ * @param {string} id Block uid to change
270
+ * @param {number} value Block's new value
271
+ * @return {Object} New form data
272
+ */
273
+ export function changeBlock(formData, id, value) {
274
+ const blocksFieldname = getBlocksFieldname(formData);
275
+ return {
276
+ ...formData,
277
+ [blocksFieldname]: {
278
+ ...formData[blocksFieldname],
279
+ [id]: value || null,
280
+ },
281
+ };
282
+ }
283
+
284
+ /**
285
+ * Get the next block UID within form
286
+ * @function nextBlockId
287
+ * @param {Object} formData Form data
288
+ * @param {string} currentBlock Block uid
289
+ * @return {string} Next block uid
290
+ */
291
+ export function nextBlockId(formData, currentBlock) {
292
+ const blocksLayoutFieldname = getBlocksLayoutFieldname(formData);
293
+ const currentIndex = formData[blocksLayoutFieldname].items.indexOf(
294
+ currentBlock,
295
+ );
296
+
297
+ if (currentIndex === formData[blocksLayoutFieldname].items.length - 1) {
298
+ // We are already at the bottom block don't do anything
299
+ return null;
300
+ }
301
+
302
+ const newIndex = currentIndex + 1;
303
+ return formData[blocksLayoutFieldname].items[newIndex];
304
+ }
305
+
306
+ /**
307
+ * Get the previous block UID within form
308
+ * @function previousBlockId
309
+ * @param {Object} formData Form data
310
+ * @param {string} currentBlock Block uid
311
+ * @return {string} Previous block uid
312
+ */
313
+ export function previousBlockId(formData, currentBlock) {
314
+ const blocksLayoutFieldname = getBlocksLayoutFieldname(formData);
315
+ const currentIndex = formData[blocksLayoutFieldname].items.indexOf(
316
+ currentBlock,
317
+ );
318
+
319
+ if (currentIndex === 0) {
320
+ // We are already at the top block don't do anything
321
+ return null;
322
+ }
323
+ const newindex = currentIndex - 1;
324
+ return formData[blocksLayoutFieldname].items[newindex];
325
+ }
326
+
327
+ /**
328
+ * Generate empty block form
329
+ * @function emptyBlocksForm
330
+ * @param {Object} formData Form data
331
+ * @return {Object} Empty blocks form with one defaultBlockType block
332
+ */
333
+ export function emptyBlocksForm() {
334
+ const { settings } = config;
335
+ const id = uuid();
336
+ return {
337
+ blocks: {
338
+ [id]: {
339
+ '@type': settings.defaultBlockType,
340
+ },
341
+ },
342
+ blocks_layout: { items: [id] },
343
+ };
344
+ }
345
+
346
+ /**
347
+ * Recursively discover blocks in data and call the provided callback
348
+ * @function visitBlocks
349
+ * @param {Object} content A content data structure (an object with blocks and blocks_layout)
350
+ * @param {Function} callback A function to call on each discovered block
351
+ */
352
+ export function visitBlocks(content, callback) {
353
+ const queue = getBlocks(content);
354
+ while (queue.length > 0) {
355
+ const [id, blockdata] = queue.shift();
356
+ callback([id, blockdata]);
357
+
358
+ // assumes that a block value is like: {blocks, blocks_layout} or
359
+ // { data: {blocks, blocks_layout}}
360
+ if (Object.keys(blockdata || {}).indexOf('blocks') > -1) {
361
+ queue.push(...getBlocks(blockdata));
362
+ }
363
+ if (Object.keys(blockdata?.data || {}).indexOf('blocks') > -1) {
364
+ queue.push(...getBlocks(blockdata.data));
365
+ }
366
+ }
367
+ }
368
+
369
+ /**
370
+ * Initializes data with the default values coming from schema
371
+ */
372
+ export function applySchemaDefaults({ data = {}, schema }) {
373
+ const derivedData = {
374
+ ...Object.keys(schema.properties).reduce((accumulator, currentField) => {
375
+ return schema.properties[currentField].default
376
+ ? {
377
+ ...accumulator,
378
+ [currentField]: schema.properties[currentField].default,
379
+ }
380
+ : accumulator;
381
+ }, {}),
382
+ ...data,
383
+ };
384
+ return derivedData;
385
+ }
386
+
387
+ /**
388
+ * Apply the block's default (as defined in schema) to the block data.
389
+ *
390
+ * @function applyBlockDefaults
391
+ * @param {Object} params An object with data, intl and anything else
392
+ * @return {Object} Derived data, with the defaults extracted from the schema
393
+ */
394
+ export function applyBlockDefaults({ data = {}, intl, ...rest }, blocksConfig) {
395
+ const block_type = data['@type'];
396
+ const { blockSchema } =
397
+ (blocksConfig || config.blocks.blocksConfig)[block_type] || {};
398
+ if (!blockSchema) return data;
399
+
400
+ let schema =
401
+ typeof blockSchema === 'function'
402
+ ? blockSchema({ data, intl, ...rest })
403
+ : blockSchema;
404
+ schema = applySchemaEnhancer({ schema, formData: data, intl });
405
+
406
+ return applySchemaDefaults({ data, schema });
407
+ }
408
+
409
+ export const buildStyleClassNamesFromData = (styles) => {
410
+ // styles has the form
411
+ // const styles = {
412
+ // color: 'red',
413
+ // backgroundColor: '#AABBCC',
414
+ // }
415
+ // Returns: ['has--color--red', 'has--backgroundColor--AABBCC']
416
+ let styleArray = [];
417
+ const pairedStyles = toPairs(styles);
418
+ pairedStyles.forEach((item) => {
419
+ if (isObject(item[1])) {
420
+ const flattenedNestedStyles = toPairs(item[1]).map((nested) => [
421
+ item[0],
422
+ ...nested,
423
+ ]);
424
+ flattenedNestedStyles.forEach((sub) => styleArray.push(sub));
425
+ } else {
426
+ styleArray.push(item);
427
+ }
428
+ });
429
+ return styleArray.map((item) => {
430
+ const classname = item.map((item) => {
431
+ const str_item = item ? item.toString() : '';
432
+ return str_item && str_item.startsWith('#')
433
+ ? str_item.replace('#', '')
434
+ : str_item;
435
+ });
436
+ return `has--${classname[0]}--${classname[1]}${
437
+ classname[2] ? `--${classname[2]}` : ''
438
+ }`;
439
+ });
440
+ };
package/src/index.js CHANGED
@@ -2,6 +2,7 @@ import { runtimeConfig } from '@plone/volto/runtime_config';
2
2
  import installCallout from 'volto-slate/editor/plugins/Callout';
3
3
  import installItemBlock from '@eeacms/volto-eea-website-policy/components/Blocks/Item';
4
4
  import customizeTeaserBlock from '@eeacms/volto-eea-website-policy/components/Blocks/Teaser';
5
+ import installContextNavigationBlock from '@eeacms/volto-eea-website-policy/components/Blocks/ContextNavigation';
5
6
 
6
7
  const applyConfig = (config) => {
7
8
  // if (process.env.NODE_ENV === 'production') {
@@ -99,10 +100,11 @@ const applyConfig = (config) => {
99
100
  }
100
101
 
101
102
  // Custom blocks
102
- config = [installItemBlock, customizeTeaserBlock].reduce(
103
- (acc, apply) => apply(acc),
104
- config,
105
- );
103
+ config = [
104
+ installItemBlock,
105
+ installContextNavigationBlock,
106
+ customizeTeaserBlock,
107
+ ].reduce((acc, apply) => apply(acc), config);
106
108
  config.blocks.blocksConfig.item.mostUsed = true;
107
109
 
108
110
  // Disable some blocks