@eeacms/volto-group-block 6.0.0 → 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,7 +4,15 @@ 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.
|
|
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
|
|
8
16
|
|
|
9
17
|
#### :hammer_and_wrench: Others
|
|
10
18
|
|
package/package.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
2
|
import { isEmpty, without } from 'lodash';
|
|
3
|
+
import config from '@plone/volto/registry';
|
|
3
4
|
import {
|
|
4
5
|
BlocksForm,
|
|
5
6
|
SidebarPortal,
|
|
@@ -32,6 +33,44 @@ const Edit = (props) => {
|
|
|
32
33
|
manage,
|
|
33
34
|
formDescription,
|
|
34
35
|
} = props;
|
|
36
|
+
const metadata = props.metadata || props.properties;
|
|
37
|
+
const [multiSelected, setMultiSelected] = useState([]);
|
|
38
|
+
const data_blocks = data?.data?.blocks;
|
|
39
|
+
const properties = isEmpty(data_blocks) ? emptyBlocksForm() : data.data;
|
|
40
|
+
|
|
41
|
+
const [selectedBlock, setSelectedBlock] = useState(
|
|
42
|
+
properties.blocks_layout.items[0],
|
|
43
|
+
);
|
|
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
|
+
|
|
35
74
|
const onSelectBlock = (id, isMultipleSelection, event, activeBlock) => {
|
|
36
75
|
let newMultiSelected = [];
|
|
37
76
|
let selected = id;
|
|
@@ -67,14 +106,7 @@ const Edit = (props) => {
|
|
|
67
106
|
setSelectedBlock(selected);
|
|
68
107
|
setMultiSelected(newMultiSelected);
|
|
69
108
|
};
|
|
70
|
-
const metadata = props.metadata || props.properties;
|
|
71
|
-
const [multiSelected, setMultiSelected] = useState([]);
|
|
72
|
-
const data_blocks = data?.data?.blocks;
|
|
73
|
-
const properties = isEmpty(data_blocks) ? emptyBlocksForm() : data.data;
|
|
74
109
|
|
|
75
|
-
const [selectedBlock, setSelectedBlock] = useState(
|
|
76
|
-
properties.blocks_layout.items[0],
|
|
77
|
-
);
|
|
78
110
|
const changeBlockData = (newBlockData) => {
|
|
79
111
|
let pastedBlocks = newBlockData.blocks_layout.items.filter((blockID) => {
|
|
80
112
|
if (data?.data?.blocks_layout.items.find((x) => x === blockID))
|
|
@@ -98,6 +130,7 @@ const Edit = (props) => {
|
|
|
98
130
|
},
|
|
99
131
|
});
|
|
100
132
|
};
|
|
133
|
+
|
|
101
134
|
React.useEffect(() => {
|
|
102
135
|
if (
|
|
103
136
|
isEmpty(data_blocks) &&
|
|
@@ -111,9 +144,6 @@ const Edit = (props) => {
|
|
|
111
144
|
}
|
|
112
145
|
}, [onChangeBlock, properties, selectedBlock, block, data, data_blocks]);
|
|
113
146
|
|
|
114
|
-
const blockState = {};
|
|
115
|
-
let charCount = 0;
|
|
116
|
-
|
|
117
147
|
/**
|
|
118
148
|
* Count the number of characters that are anything except using Regex
|
|
119
149
|
* @param {string} paragraph
|
|
@@ -216,7 +246,16 @@ const Edit = (props) => {
|
|
|
216
246
|
}
|
|
217
247
|
|
|
218
248
|
return (
|
|
219
|
-
<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
|
+
>
|
|
220
259
|
<legend
|
|
221
260
|
onClick={() => {
|
|
222
261
|
setSelectedBlock();
|
|
@@ -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
|