@eeacms/volto-group-block 8.0.0 → 8.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,16 @@ 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
- ### [8.0.0](https://github.com/eea/volto-group-block/compare/7.1.1...8.0.0) - 3 December 2025
7
+ ### [8.1.0](https://github.com/eea/volto-group-block/compare/8.0.0...8.1.0) - 3 December 2025
8
+
9
+ #### :rocket: New Features
10
+
11
+ - feat: Add possibility to skip blocks from character counting - refs #293783 [Teodor Voicu - [`c35d76b`](https://github.com/eea/volto-group-block/commit/c35d76bd03476bbcf8324b247ecf909c093d4117)]
12
+
13
+ #### :hammer_and_wrench: Others
14
+
15
+ - Release 8.1.0 [Alin Voinea - [`d711911`](https://github.com/eea/volto-group-block/commit/d71191102f8ef97375905049c7cbbe71ea9e357c)]
16
+ ## [8.0.0](https://github.com/eea/volto-group-block/compare/7.1.1...8.0.0) - 3 December 2025
8
17
 
9
18
  #### :boom: Breaking Change
10
19
 
@@ -15,7 +24,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
15
24
 
16
25
  #### :hammer_and_wrench: Others
17
26
 
18
- - Release 8.0.0 [Alin Voinea - [`75e44d3`](https://github.com/eea/volto-group-block/commit/75e44d345c84e45cb8f520b02a37d92de280de9e)]
19
27
  ### [7.1.1](https://github.com/eea/volto-group-block/compare/7.1.0...7.1.1) - 30 January 2025
20
28
 
21
29
  #### :house: Internal changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-group-block",
3
- "version": "8.0.0",
3
+ "version": "8.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",
@@ -10,8 +10,38 @@ import dissatisfiedSVG from '@plone/volto/icons/dissatisfied.svg';
10
10
  import { countCharsWithoutSpaces, countCharsWithSpaces } from './utils';
11
11
 
12
12
  const countTextInEachBlock =
13
- (countTextIn, ignoreSpaces, groupCharCount) =>
13
+ (
14
+ countTextIn,
15
+ ignoreSpaces,
16
+ groupCharCount,
17
+ skipBlockIds = new Set(),
18
+ skipBlocksInGroups = [],
19
+ ) =>
14
20
  ([id, blockData]) => {
21
+ // Track group blocks matching skip criteria and their children
22
+ if (blockData?.['@type'] === 'group') {
23
+ const shouldSkip = skipBlocksInGroups.some((criteria) => {
24
+ // Check if all criteria match
25
+ return Object.keys(criteria).every((key) => {
26
+ return blockData?.[key] === criteria[key];
27
+ });
28
+ });
29
+
30
+ if (shouldSkip) {
31
+ // Get all child block IDs from this group and mark them to be skipped
32
+ if (blockData?.data?.blocks) {
33
+ Object.keys(blockData.data.blocks).forEach((childId) => {
34
+ skipBlockIds.add(childId);
35
+ });
36
+ }
37
+ }
38
+ }
39
+
40
+ // Skip counting if this block is inside a skipped group
41
+ if (skipBlockIds.has(id)) {
42
+ return;
43
+ }
44
+
15
45
  const foundText =
16
46
  blockData && countTextIn?.includes(blockData?.['@type'])
17
47
  ? isString(blockData?.plaintext)
@@ -27,9 +57,11 @@ const countTextInEachBlock =
27
57
  };
28
58
 
29
59
  const countTextInBlocks = (blocksObject, ignoreSpaces, maxChars) => {
30
- const { countTextIn } = config.blocks?.blocksConfig?.group || [];
60
+ const { countTextIn, skipBlocksInGroups = [] } =
61
+ config.blocks?.blocksConfig?.group || {};
31
62
  // use obj ref to update value - if you send number it will not be updated
32
63
  const groupCharCount = { value: 0 };
64
+ const skipBlockIds = new Set();
33
65
 
34
66
  if (!maxChars || !blocksObject) {
35
67
  return groupCharCount.value;
@@ -37,7 +69,13 @@ const countTextInBlocks = (blocksObject, ignoreSpaces, maxChars) => {
37
69
 
38
70
  visitBlocks(
39
71
  blocksObject,
40
- countTextInEachBlock(countTextIn, ignoreSpaces, groupCharCount),
72
+ countTextInEachBlock(
73
+ countTextIn,
74
+ ignoreSpaces,
75
+ groupCharCount,
76
+ skipBlockIds,
77
+ skipBlocksInGroups,
78
+ ),
41
79
  );
42
80
 
43
81
  return groupCharCount.value;
package/src/index.js CHANGED
@@ -93,6 +93,7 @@ const applyConfig = (config) => {
93
93
  return entries;
94
94
  },
95
95
  countTextIn: ['slate', 'description'], //id of the block whose text should be counted
96
+ skipBlocksInGroups: [], // Array of group criteria to skip when counting chars. Each item can have: { className: 'group-class-name' }
96
97
  };
97
98
 
98
99
  return config;