@eeacms/volto-group-block 5.0.1 → 6.1.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
CHANGED
|
@@ -4,6 +4,20 @@ 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
|
+
### [6.1.0](https://github.com/eea/volto-group-block/compare/6.0.0...6.1.0) - 4 April 2023
|
|
8
|
+
|
|
9
|
+
#### :house: Internal changes
|
|
10
|
+
|
|
11
|
+
- chore(package.json): update package version to 6.1.0 [Miu Razvan - [`b4251fc`](https://github.com/eea/volto-group-block/commit/b4251fcfa4c713d1777e4c389b36d3501a8a8d92)]
|
|
12
|
+
|
|
13
|
+
#### :hammer_and_wrench: Others
|
|
14
|
+
|
|
15
|
+
## [6.0.0](https://github.com/eea/volto-group-block/compare/5.0.1...6.0.0) - 24 March 2023
|
|
16
|
+
|
|
17
|
+
#### :hammer_and_wrench: Others
|
|
18
|
+
|
|
19
|
+
- (feat): Possibility to copy/cut/paste blocks within section group block - refs #157469 [dobri1408 - [`e9fc098`](https://github.com/eea/volto-group-block/commit/e9fc09825ba2ae258feb77864491d97d94c585b4)]
|
|
20
|
+
- test(Jenkins): Run tests and cypress with latest canary @plone/volto [Alin Voinea - [`2f42e7c`](https://github.com/eea/volto-group-block/commit/2f42e7c19a1da5a9c6a883cb4f101e8fa224ff94)]
|
|
7
21
|
### [5.0.1](https://github.com/eea/volto-group-block/compare/5.0.0...5.0.1) - 16 November 2022
|
|
8
22
|
|
|
9
23
|
#### :nail_care: Enhancements
|
|
@@ -20,8 +34,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
20
34
|
|
|
21
35
|
- Prepare 5.0.0 release [Miu Razvan - [`88c0ddd`](https://github.com/eea/volto-group-block/commit/88c0ddd569aeda7ee34d1eadea6a087f4e7dc257)]
|
|
22
36
|
- Update dependencies [Alin Voinea - [`c8405af`](https://github.com/eea/volto-group-block/commit/c8405afb830cdf62e7877bf30b619933519e1d71)]
|
|
23
|
-
- Add Sonarqube tag using marine-frontend addons list [EEA Jenkins - [`18e26c6`](https://github.com/eea/volto-group-block/commit/18e26c6939706d572ab8574e9b1826b9abc76314)]
|
|
24
|
-
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`8ed6d21`](https://github.com/eea/volto-group-block/commit/8ed6d21d8489911cc4cb471e3f8823c35f4adc50)]
|
|
25
37
|
### [4.3.8](https://github.com/eea/volto-group-block/compare/4.3.7...4.3.8) - 26 August 2022
|
|
26
38
|
|
|
27
39
|
### [4.3.7](https://github.com/eea/volto-group-block/compare/4.3.6...4.3.7) - 22 August 2022
|
|
@@ -34,9 +46,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
34
46
|
|
|
35
47
|
#### :hammer_and_wrench: Others
|
|
36
48
|
|
|
37
|
-
- Add Sonarqube tag using circularity-frontend addons list [EEA Jenkins - [`4e73f8b`](https://github.com/eea/volto-group-block/commit/4e73f8be3c73559557efadc410cb56abc055d82d)]
|
|
38
|
-
- Add Sonarqube tag using clms-frontend addons list [EEA Jenkins - [`3040335`](https://github.com/eea/volto-group-block/commit/3040335002c63b50208c95918413bc958150e7a9)]
|
|
39
|
-
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`386f730`](https://github.com/eea/volto-group-block/commit/386f730ed65f73fe1468b9b77351c97fb70edcc5)]
|
|
40
49
|
### [4.3.5](https://github.com/eea/volto-group-block/compare/4.3.4...4.3.5) - 4 January 2022
|
|
41
50
|
|
|
42
51
|
### [4.3.4](https://github.com/eea/volto-group-block/compare/4.3.3...4.3.4) - 3 January 2022
|
|
@@ -45,23 +54,15 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
45
54
|
|
|
46
55
|
#### :hammer_and_wrench: Others
|
|
47
56
|
|
|
48
|
-
- Add Sonarqube tag using freshwater-frontend addons list [EEA Jenkins - [`3e62d79`](https://github.com/eea/volto-group-block/commit/3e62d79a7ed37d10d623bc845d43e1144f8080f7)]
|
|
49
57
|
### [4.3.2](https://github.com/eea/volto-group-block/compare/4.3.1...4.3.2) - 10 December 2021
|
|
50
58
|
|
|
51
59
|
#### :hammer_and_wrench: Others
|
|
52
60
|
|
|
53
61
|
- Refs #142010 - Optimize Volto-addons gitflow pipelines [valentinab25 - [`bc36cf5`](https://github.com/eea/volto-group-block/commit/bc36cf58c39e2b43c2fbf5189df6ddefc1260857)]
|
|
54
|
-
- Add Sonarqube tag using industry-frontend addons list [EEA Jenkins - [`8038e78`](https://github.com/eea/volto-group-block/commit/8038e783c1e8ddd71e21f72070fdfa8e7e098993)]
|
|
55
|
-
- Add Sonarqube tag using clms-frontend addons list [EEA Jenkins - [`daccdbc`](https://github.com/eea/volto-group-block/commit/daccdbc733e47be7d6536eb67f8f2eea038dc94b)]
|
|
56
62
|
### [4.3.1](https://github.com/eea/volto-group-block/compare/4.3.0...4.3.1) - 11 October 2021
|
|
57
63
|
|
|
58
64
|
#### :hammer_and_wrench: Others
|
|
59
65
|
|
|
60
|
-
- Add Sonarqube tag using bise-frontend addons list [EEA Jenkins - [`b0092e4`](https://github.com/eea/volto-group-block/commit/b0092e4f78a1a0184e22e32bb9806cd57417dfb2)]
|
|
61
|
-
- Add Sonarqube tag using sustainability-frontend addons list [EEA Jenkins - [`ff8889c`](https://github.com/eea/volto-group-block/commit/ff8889cb7b0761b1df43b201984ce40b14e1561b)]
|
|
62
|
-
- Add Sonarqube tag using climate-energy-frontend addons list [EEA Jenkins - [`0375c28`](https://github.com/eea/volto-group-block/commit/0375c28ed1ffe9186a4790b454795c0ca8039f72)]
|
|
63
|
-
- Add Sonarqube tag using ims-frontend addons list [EEA Jenkins - [`c392190`](https://github.com/eea/volto-group-block/commit/c392190f044f5d9397bd2fb8c3d6a357f84960d0)]
|
|
64
|
-
- Add Sonarqube tag using frontend addons list [EEA Jenkins - [`9694501`](https://github.com/eea/volto-group-block/commit/9694501141e6780eba89464d36406e3c93629fd8)]
|
|
65
66
|
### [4.3.0](https://github.com/eea/volto-group-block/compare/4.2.3...4.3.0) - 24 June 2021
|
|
66
67
|
|
|
67
68
|
#### :hammer_and_wrench: Others
|
|
@@ -177,7 +178,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
177
178
|
- Release 1.0.0 [Alin Voinea - [`b6ef873`](https://github.com/eea/volto-group-block/commit/b6ef873cb6f61e17db66fdd4de1d9d4902a66fc6)]
|
|
178
179
|
- Update package meta info [Alin Voinea - [`143b7d4`](https://github.com/eea/volto-group-block/commit/143b7d44438d7afa5e346a9d21a85352df4e925f)]
|
|
179
180
|
- Add Jenkinkins pipeline [Alin Voinea - [`866a4e1`](https://github.com/eea/volto-group-block/commit/866a4e14ea1eb8f5adb01222e576e5ab6dc73a70)]
|
|
180
|
-
- yarn prettier [Alin Voinea - [`e3fe0a3`](https://github.com/eea/volto-group-block/commit/e3fe0a36b89878769341b45198d6c9e2f2584d15)]
|
|
181
181
|
### [0.1.3](https://github.com/eea/volto-group-block/compare/0.1.2...0.1.3) - 9 November 2020
|
|
182
182
|
|
|
183
183
|
#### :hammer_and_wrench: Others
|
|
@@ -217,5 +217,4 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
217
217
|
- Render meta block [Alin Voinea - [`0d44560`](https://github.com/eea/volto-group-block/commit/0d4456011ca56454068a54c610250b02df4ccb3b)]
|
|
218
218
|
- Implement meta block allowedBlocks settings [Alin Voinea - [`f24feb1`](https://github.com/eea/volto-group-block/commit/f24feb1a1751f04841c21c7cd52a517fb02074ba)]
|
|
219
219
|
- Edit meta block [Alin Voinea - [`236d291`](https://github.com/eea/volto-group-block/commit/236d29156fa835a7aa54eecdb4f120de0d64b271)]
|
|
220
|
-
- yarn bootstrap [Alin Voinea - [`e009dfb`](https://github.com/eea/volto-group-block/commit/e009dfb6b9b74d101a6722f0982a5359fc522b6b)]
|
|
221
220
|
- Initial commit [Alin Voinea - [`6a7b0de`](https://github.com/eea/volto-group-block/commit/6a7b0deb8f873d1462fd6a9c61edfc1562b3aace)]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eeacms/volto-group-block",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.1.0",
|
|
4
4
|
"description": "volto-group-block: Volto block to be used to group other blocks",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"author": "European Environment Agency: IDM2 A-Team",
|
|
@@ -18,10 +18,9 @@
|
|
|
18
18
|
"type": "git",
|
|
19
19
|
"url": "git@github.com:eea/volto-group-block.git"
|
|
20
20
|
},
|
|
21
|
-
"dependencies": {},
|
|
22
21
|
"devDependencies": {
|
|
23
|
-
"@plone/scripts": "*",
|
|
24
22
|
"@cypress/code-coverage": "^3.10.0",
|
|
23
|
+
"@plone/scripts": "*",
|
|
25
24
|
"babel-plugin-transform-class-properties": "^6.24.1",
|
|
26
25
|
"md5": "^2.3.0"
|
|
27
26
|
},
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
|
-
import { isEmpty } from 'lodash';
|
|
2
|
+
import { isEmpty, without } from 'lodash';
|
|
3
|
+
import config from '@plone/volto/registry';
|
|
3
4
|
import {
|
|
4
5
|
BlocksForm,
|
|
5
6
|
SidebarPortal,
|
|
6
7
|
Icon,
|
|
7
8
|
BlockDataForm,
|
|
9
|
+
BlocksToolbar,
|
|
8
10
|
} from '@plone/volto/components';
|
|
9
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
emptyBlocksForm,
|
|
13
|
+
getBlocksLayoutFieldname,
|
|
14
|
+
} from '@plone/volto/helpers';
|
|
10
15
|
import delightedSVG from '@plone/volto/icons/delighted.svg';
|
|
11
16
|
import dissatisfiedSVG from '@plone/volto/icons/dissatisfied.svg';
|
|
12
17
|
import PropTypes from 'prop-types';
|
|
@@ -28,8 +33,8 @@ const Edit = (props) => {
|
|
|
28
33
|
manage,
|
|
29
34
|
formDescription,
|
|
30
35
|
} = props;
|
|
31
|
-
|
|
32
36
|
const metadata = props.metadata || props.properties;
|
|
37
|
+
const [multiSelected, setMultiSelected] = useState([]);
|
|
33
38
|
const data_blocks = data?.data?.blocks;
|
|
34
39
|
const properties = isEmpty(data_blocks) ? emptyBlocksForm() : data.data;
|
|
35
40
|
|
|
@@ -37,6 +42,95 @@ const Edit = (props) => {
|
|
|
37
42
|
properties.blocks_layout.items[0],
|
|
38
43
|
);
|
|
39
44
|
|
|
45
|
+
const blockState = {};
|
|
46
|
+
let charCount = 0;
|
|
47
|
+
|
|
48
|
+
const handleKeyDown = (
|
|
49
|
+
e,
|
|
50
|
+
index,
|
|
51
|
+
block,
|
|
52
|
+
node,
|
|
53
|
+
{
|
|
54
|
+
disableEnter = false,
|
|
55
|
+
disableArrowUp = false,
|
|
56
|
+
disableArrowDown = false,
|
|
57
|
+
} = {},
|
|
58
|
+
) => {
|
|
59
|
+
const hasblockActive = !!selectedBlock;
|
|
60
|
+
if (e.key === 'ArrowUp' && !disableArrowUp && !hasblockActive) {
|
|
61
|
+
props.onFocusPreviousBlock(block, node);
|
|
62
|
+
e.preventDefault();
|
|
63
|
+
}
|
|
64
|
+
if (e.key === 'ArrowDown' && !disableArrowDown && !hasblockActive) {
|
|
65
|
+
props.onFocusNextBlock(block, node);
|
|
66
|
+
e.preventDefault();
|
|
67
|
+
}
|
|
68
|
+
if (e.key === 'Enter' && !disableEnter && !hasblockActive) {
|
|
69
|
+
props.onAddBlock(config.settings.defaultBlockType, index + 1);
|
|
70
|
+
e.preventDefault();
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const onSelectBlock = (id, isMultipleSelection, event, activeBlock) => {
|
|
75
|
+
let newMultiSelected = [];
|
|
76
|
+
let selected = id;
|
|
77
|
+
|
|
78
|
+
if (isMultipleSelection) {
|
|
79
|
+
selected = null;
|
|
80
|
+
const blocksLayoutFieldname = getBlocksLayoutFieldname(data?.data);
|
|
81
|
+
const blocks_layout = data?.data[blocksLayoutFieldname].items;
|
|
82
|
+
if (event.shiftKey) {
|
|
83
|
+
const anchor =
|
|
84
|
+
multiSelected.length > 0
|
|
85
|
+
? blocks_layout.indexOf(multiSelected[0])
|
|
86
|
+
: blocks_layout.indexOf(activeBlock);
|
|
87
|
+
const focus = blocks_layout.indexOf(id);
|
|
88
|
+
if (anchor === focus) {
|
|
89
|
+
newMultiSelected = [id];
|
|
90
|
+
} else if (focus > anchor) {
|
|
91
|
+
newMultiSelected = [...blocks_layout.slice(anchor, focus + 1)];
|
|
92
|
+
} else {
|
|
93
|
+
newMultiSelected = [...blocks_layout.slice(focus, anchor + 1)];
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if ((event.ctrlKey || event.metaKey) && !event.shiftKey) {
|
|
97
|
+
if (multiSelected.includes(id)) {
|
|
98
|
+
selected = null;
|
|
99
|
+
newMultiSelected = without(multiSelected, id);
|
|
100
|
+
} else {
|
|
101
|
+
newMultiSelected = [...(multiSelected || []), id];
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
setSelectedBlock(selected);
|
|
107
|
+
setMultiSelected(newMultiSelected);
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
const changeBlockData = (newBlockData) => {
|
|
111
|
+
let pastedBlocks = newBlockData.blocks_layout.items.filter((blockID) => {
|
|
112
|
+
if (data?.data?.blocks_layout.items.find((x) => x === blockID))
|
|
113
|
+
return false;
|
|
114
|
+
return true;
|
|
115
|
+
});
|
|
116
|
+
const selectedIndex =
|
|
117
|
+
data.data.blocks_layout.items.indexOf(selectedBlock) + 1;
|
|
118
|
+
onChangeBlock(block, {
|
|
119
|
+
...data,
|
|
120
|
+
data: {
|
|
121
|
+
...data?.data,
|
|
122
|
+
...newBlockData,
|
|
123
|
+
blocks_layout: {
|
|
124
|
+
items: [
|
|
125
|
+
...data.data.blocks_layout.items.slice(0, selectedIndex),
|
|
126
|
+
...pastedBlocks,
|
|
127
|
+
...data.data.blocks_layout.items.slice(selectedIndex),
|
|
128
|
+
],
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
});
|
|
132
|
+
};
|
|
133
|
+
|
|
40
134
|
React.useEffect(() => {
|
|
41
135
|
if (
|
|
42
136
|
isEmpty(data_blocks) &&
|
|
@@ -50,9 +144,6 @@ const Edit = (props) => {
|
|
|
50
144
|
}
|
|
51
145
|
}, [onChangeBlock, properties, selectedBlock, block, data, data_blocks]);
|
|
52
146
|
|
|
53
|
-
const blockState = {};
|
|
54
|
-
let charCount = 0;
|
|
55
|
-
|
|
56
147
|
/**
|
|
57
148
|
* Count the number of characters that are anything except using Regex
|
|
58
149
|
* @param {string} paragraph
|
|
@@ -155,7 +246,16 @@ const Edit = (props) => {
|
|
|
155
246
|
}
|
|
156
247
|
|
|
157
248
|
return (
|
|
158
|
-
<fieldset
|
|
249
|
+
<fieldset
|
|
250
|
+
role="presentation"
|
|
251
|
+
className="section-block"
|
|
252
|
+
onKeyDown={(e) => {
|
|
253
|
+
handleKeyDown(e, props.index, props.block, props.blockNode.current);
|
|
254
|
+
}}
|
|
255
|
+
// The tabIndex is required for the keyboard navigation
|
|
256
|
+
/* eslint-disable jsx-a11y/no-noninteractive-tabindex */
|
|
257
|
+
tabIndex={-1}
|
|
258
|
+
>
|
|
159
259
|
<legend
|
|
160
260
|
onClick={() => {
|
|
161
261
|
setSelectedBlock();
|
|
@@ -165,6 +265,28 @@ const Edit = (props) => {
|
|
|
165
265
|
>
|
|
166
266
|
{data.title || 'Section'}
|
|
167
267
|
</legend>
|
|
268
|
+
{selected ? (
|
|
269
|
+
<BlocksToolbar
|
|
270
|
+
selectedBlock={Object.keys(selectedBlock || {})[0]}
|
|
271
|
+
selectedBlocks={multiSelected}
|
|
272
|
+
onSetSelectedBlocks={(blockIds) => {
|
|
273
|
+
setMultiSelected(blockIds);
|
|
274
|
+
}}
|
|
275
|
+
formData={data.data}
|
|
276
|
+
onSelectBlock={(id, l, e) => {
|
|
277
|
+
const isMultipleSelection = e
|
|
278
|
+
? e.shiftKey || e.ctrlKey || e.metaKey
|
|
279
|
+
: false;
|
|
280
|
+
|
|
281
|
+
onSelectBlock(id, isMultipleSelection, e, selectedBlock);
|
|
282
|
+
}}
|
|
283
|
+
onChangeBlocks={(newBlockData) => {
|
|
284
|
+
changeBlockData(newBlockData);
|
|
285
|
+
}}
|
|
286
|
+
/>
|
|
287
|
+
) : (
|
|
288
|
+
''
|
|
289
|
+
)}
|
|
168
290
|
<BlocksForm
|
|
169
291
|
metadata={metadata}
|
|
170
292
|
properties={properties}
|
|
@@ -173,8 +295,11 @@ const Edit = (props) => {
|
|
|
173
295
|
allowedBlocks={data.allowedBlocks}
|
|
174
296
|
title={data.placeholder}
|
|
175
297
|
description={instructions}
|
|
176
|
-
onSelectBlock={(id) => {
|
|
177
|
-
|
|
298
|
+
onSelectBlock={(id, l, e) => {
|
|
299
|
+
const isMultipleSelection = e
|
|
300
|
+
? e.shiftKey || e.ctrlKey || e.metaKey
|
|
301
|
+
: false;
|
|
302
|
+
onSelectBlock(id, isMultipleSelection, e, selectedBlock);
|
|
178
303
|
}}
|
|
179
304
|
onChangeFormData={(newFormData) => {
|
|
180
305
|
onChangeBlock(block, {
|
|
@@ -223,6 +348,7 @@ const Edit = (props) => {
|
|
|
223
348
|
)}
|
|
224
349
|
</>
|
|
225
350
|
}
|
|
351
|
+
multiSelected={multiSelected.includes(blockProps.block)}
|
|
226
352
|
>
|
|
227
353
|
{editBlock}
|
|
228
354
|
</EditBlockWrapper>
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Icon, BlockChooser } from '@plone/volto/components';
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import {
|
|
4
|
+
blockHasValue,
|
|
5
|
+
buildStyleClassNamesFromData,
|
|
6
|
+
} from '@plone/volto/helpers';
|
|
5
7
|
import { Button } from 'semantic-ui-react';
|
|
6
8
|
import includes from 'lodash/includes';
|
|
7
9
|
import isBoolean from 'lodash/isBoolean';
|
|
8
10
|
import { defineMessages, injectIntl } from 'react-intl';
|
|
9
|
-
import { doesNodeContainClick } from 'semantic-ui-react/dist/commonjs/lib';
|
|
10
11
|
import cx from 'classnames';
|
|
12
|
+
import config from '@plone/volto/registry';
|
|
13
|
+
import { doesNodeContainClick } from 'semantic-ui-react/dist/commonjs/lib';
|
|
11
14
|
|
|
12
15
|
import dragSVG from '@plone/volto/icons/drag.svg';
|
|
13
16
|
import addSVG from '@plone/volto/icons/circle-plus.svg';
|
|
@@ -86,6 +89,8 @@ class EditBlockWrapper extends React.Component {
|
|
|
86
89
|
? data.required
|
|
87
90
|
: includes(config.blocks.requiredBlocks, type);
|
|
88
91
|
|
|
92
|
+
const styles = buildStyleClassNamesFromData(data.styles);
|
|
93
|
+
|
|
89
94
|
// Get editing instructions from block settings or props
|
|
90
95
|
let instructions = data?.instructions?.data || data?.instructions;
|
|
91
96
|
if (!instructions || instructions === '<p><br/></p>') {
|
|
@@ -97,7 +102,9 @@ class EditBlockWrapper extends React.Component {
|
|
|
97
102
|
<div
|
|
98
103
|
ref={draginfo?.innerRef}
|
|
99
104
|
{...(selected ? draginfo?.draggableProps : null)}
|
|
100
|
-
className={`block-editor-${data['@type']}
|
|
105
|
+
className={cx(`block-editor-${data['@type']}`, styles, {
|
|
106
|
+
[data.align]: data.align,
|
|
107
|
+
})}
|
|
101
108
|
>
|
|
102
109
|
{(!selected || !visible || disabled) && (
|
|
103
110
|
<div
|