@eeacms/volto-group-block 4.3.0 → 4.3.4

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,11 +4,37 @@ 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
+ #### [4.3.4](https://github.com/eea/volto-group-block/compare/4.3.3...4.3.4)
8
+
9
+ - add cy tests [`#16`](https://github.com/eea/volto-group-block/pull/16)
10
+
11
+ #### [4.3.3](https://github.com/eea/volto-group-block/compare/4.3.2...4.3.3)
12
+
13
+ > 18 December 2021
14
+
15
+ - Add SonarQube badges [`#15`](https://github.com/eea/volto-group-block/pull/15)
16
+
17
+ #### [4.3.2](https://github.com/eea/volto-group-block/compare/4.3.1...4.3.2)
18
+
19
+ > 10 December 2021
20
+
21
+ - Develop [`#14`](https://github.com/eea/volto-group-block/pull/14)
22
+ - Correct Cypress tests [`#13`](https://github.com/eea/volto-group-block/pull/13)
23
+ - Refs #142010 - Optimize Volto-addons gitflow pipelines [`bc36cf5`](https://github.com/eea/volto-group-block/commit/bc36cf58c39e2b43c2fbf5189df6ddefc1260857)
24
+
25
+ #### [4.3.1](https://github.com/eea/volto-group-block/compare/4.3.0...4.3.1)
26
+
27
+ > 11 October 2021
28
+
29
+ - Possibility to ignore spaces with maxChars [`#11`](https://github.com/eea/volto-group-block/pull/11)
30
+ - No space count [`#10`](https://github.com/eea/volto-group-block/pull/10)
31
+
7
32
  #### [4.3.0](https://github.com/eea/volto-group-block/compare/4.2.3...4.3.0)
8
33
 
34
+ > 24 June 2021
35
+
36
+ - Refactor counter to use CSS class instead of inline style [`#9`](https://github.com/eea/volto-group-block/pull/9)
9
37
  - Show help icon only if block instructions differ from section instructions [`a4ca4e5`](https://github.com/eea/volto-group-block/commit/a4ca4e58968dcfb947072a255c8f797df7977852)
10
- - [JENKINS] - Fix stylelint [`c897993`](https://github.com/eea/volto-group-block/commit/c8979933fda9366c8669aa2c494e7442e2ca4bae)
11
- - Refactor counter to use CSS class instead of inline style [`d676d7d`](https://github.com/eea/volto-group-block/commit/d676d7d2fa50eb4c16ab4d332a728ab9a8062c3a)
12
38
 
13
39
  #### [4.2.3](https://github.com/eea/volto-group-block/compare/4.2.2...4.2.3)
14
40
 
@@ -20,7 +46,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
20
46
 
21
47
  > 14 May 2021
22
48
 
23
- - [JENKINS] - Auto-release pipeline [`#7`](https://github.com/eea/volto-group-block/pull/7)
24
49
 
25
50
  #### [4.2.1](https://github.com/eea/volto-group-block/compare/4.2.0...4.2.1)
26
51
 
@@ -100,7 +125,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
100
125
 
101
126
  - Drop volto-blocks-form dependency [`#6`](https://github.com/eea/volto-group-block/pull/6)
102
127
  - Release 3.0.0 [`a83216e`](https://github.com/eea/volto-group-block/commit/a83216ed496b3a14ea49fd9697cd50ac64866092)
103
- - Cleanup Jenkinsfile DEPENDENCIES [`9d2a5d0`](https://github.com/eea/volto-group-block/commit/9d2a5d04308ecef93ca2682d928d0919b0f861ea)
104
128
  - Cosmetics [`03d6ed8`](https://github.com/eea/volto-group-block/commit/03d6ed8cbb796bacef3b3b78a1cee4114874033c)
105
129
  - Fix focus management [`35327d7`](https://github.com/eea/volto-group-block/commit/35327d7b457beeed15b7129541bb1665cab4586b)
106
130
  - Change imports from volto core [`d1dcc14`](https://github.com/eea/volto-group-block/commit/d1dcc14116fa408731d545d45d01669a06563b46)
@@ -143,19 +167,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
143
167
 
144
168
  - Release 1.0.0 [`b6ef873`](https://github.com/eea/volto-group-block/commit/b6ef873cb6f61e17db66fdd4de1d9d4902a66fc6)
145
169
  - Update package meta info [`143b7d4`](https://github.com/eea/volto-group-block/commit/143b7d44438d7afa5e346a9d21a85352df4e925f)
146
- - [JENKINS] - Fix SONAR tags [`512b56c`](https://github.com/eea/volto-group-block/commit/512b56ce931aa4c14f353e2a4c5bbbb614fe632f)
147
- - [JENKINS] - Update [`2204acd`](https://github.com/eea/volto-group-block/commit/2204acdefee84114bd403f9772a1e610348dc3dd)
148
- - [JENKINS] - Fix code-analysis [`88a5b3d`](https://github.com/eea/volto-group-block/commit/88a5b3d58b951ecfbc6e813accf065ca5e8be990)
149
- - [JENKINS] - Fix SonarQube report [`7fca879`](https://github.com/eea/volto-group-block/commit/7fca879b526be822cd63312ed51447d6e6a59cf2)
150
- - [JENKINS] - Fix unit tests pipeline [`5b9b28f`](https://github.com/eea/volto-group-block/commit/5b9b28f1de060635f1c665a80939bfa66918a918)
151
- - [JENKINS] - Add jest unit tests [`d8af5b7`](https://github.com/eea/volto-group-block/commit/d8af5b7932988b490a079d86079e359b5584fd7f)
152
- - [JENKINS] - Fix develop badge [`857b4ab`](https://github.com/eea/volto-group-block/commit/857b4ab5bc0aa9947c2ed76f35cec7d409c7fa66)
153
- - [JENKINS] - Add jenkins builds badges [`6cebd3e`](https://github.com/eea/volto-group-block/commit/6cebd3e970a840c4951c614a5d130dab05ae553f)
154
- - [JENKINS] - Cleanup console.log [`df38b6f`](https://github.com/eea/volto-group-block/commit/df38b6f7a630176e911ff89263c21e519ab44efa)
155
- - [JENKINS] - Fix eslint pipeline [`ca7c87a`](https://github.com/eea/volto-group-block/commit/ca7c87a4f74f2b0ea354ea5369f0700b8bee92af)
156
- - [JENKINS] - Fix style [`0e2c5a3`](https://github.com/eea/volto-group-block/commit/0e2c5a39b2f785ae1d942d39e7f8b2789dafc795)
157
170
  - Add Jenkinkins pipeline [`866a4e1`](https://github.com/eea/volto-group-block/commit/866a4e14ea1eb8f5adb01222e576e5ab6dc73a70)
158
- - yarn prettier [`e3fe0a3`](https://github.com/eea/volto-group-block/commit/e3fe0a36b89878769341b45198d6c9e2f2584d15)
159
171
 
160
172
  #### [0.1.3](https://github.com/eea/volto-group-block/compare/0.1.2...0.1.3)
161
173
 
@@ -200,5 +212,4 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
200
212
  - Render meta block [`0d44560`](https://github.com/eea/volto-group-block/commit/0d4456011ca56454068a54c610250b02df4ccb3b)
201
213
  - Implement meta block allowedBlocks settings [`f24feb1`](https://github.com/eea/volto-group-block/commit/f24feb1a1751f04841c21c7cd52a517fb02074ba)
202
214
  - Edit meta block [`236d291`](https://github.com/eea/volto-group-block/commit/236d29156fa835a7aa54eecdb4f120de0d64b271)
203
- - yarn bootstrap [`e009dfb`](https://github.com/eea/volto-group-block/commit/e009dfb6b9b74d101a6722f0982a5359fc522b6b)
204
215
  - Initial commit [`6a7b0de`](https://github.com/eea/volto-group-block/commit/6a7b0deb8f873d1462fd6a9c61edfc1562b3aace)
package/Jenkinsfile CHANGED
@@ -4,13 +4,37 @@ pipeline {
4
4
  environment {
5
5
  GIT_NAME = "volto-group-block"
6
6
  NAMESPACE = "@eeacms"
7
- SONARQUBE_TAGS = "volto.eea.europa.eu"
7
+ SONARQUBE_TAGS = "volto.eea.europa.eu,forest.eea.europa.eu,www.eea.europa.eu-ims,climate-energy.eea.europa.eu,sustainability.eionet.europa.eu,biodiversity.europa.eu,clms.land.copernicus.eu,industry.eea.europa.eu,water.europa.eu-freshwater"
8
8
  DEPENDENCIES = ""
9
9
  }
10
10
 
11
11
  stages {
12
12
 
13
+ stage('Release') {
14
+ when {
15
+ allOf {
16
+ environment name: 'CHANGE_ID', value: ''
17
+ branch 'master'
18
+ }
19
+ }
20
+ steps {
21
+ node(label: 'docker') {
22
+ withCredentials([string(credentialsId: 'eea-jenkins-token', variable: 'GITHUB_TOKEN'),string(credentialsId: 'eea-jenkins-npm-token', variable: 'NPM_TOKEN')]) {
23
+ sh '''docker pull eeacms/gitflow'''
24
+ sh '''docker run -i --rm --name="$BUILD_TAG-gitflow-master" -e GIT_BRANCH="$BRANCH_NAME" -e GIT_NAME="$GIT_NAME" -e GIT_TOKEN="$GITHUB_TOKEN" -e NPM_TOKEN="$NPM_TOKEN" -e LANGUAGE=javascript eeacms/gitflow'''
25
+ }
26
+ }
27
+ }
28
+ }
29
+
13
30
  stage('Code') {
31
+ when {
32
+ allOf {
33
+ environment name: 'CHANGE_ID', value: ''
34
+ not { changelog '.*^Automated release [0-9\\.]+$' }
35
+ not { branch 'master' }
36
+ }
37
+ }
14
38
  steps {
15
39
  parallel(
16
40
 
@@ -36,6 +60,15 @@ pipeline {
36
60
  }
37
61
 
38
62
  stage('Tests') {
63
+ when {
64
+ allOf {
65
+ environment name: 'CHANGE_ID', value: ''
66
+ anyOf {
67
+ not { changelog '.*^Automated release [0-9\\.]+$' }
68
+ branch 'master'
69
+ }
70
+ }
71
+ }
39
72
  steps {
40
73
  parallel(
41
74
 
@@ -75,6 +108,15 @@ pipeline {
75
108
  }
76
109
 
77
110
  stage('Integration tests') {
111
+ when {
112
+ allOf {
113
+ environment name: 'CHANGE_ID', value: ''
114
+ anyOf {
115
+ not { changelog '.*^Automated release [0-9\\.]+$' }
116
+ branch 'master'
117
+ }
118
+ }
119
+ }
78
120
  steps {
79
121
  parallel(
80
122
 
@@ -82,7 +124,7 @@ pipeline {
82
124
  node(label: 'docker') {
83
125
  script {
84
126
  try {
85
- sh '''docker pull plone; docker run -d --name="$BUILD_TAG-plone" -e SITE="Plone" -e PROFILES="profile-plone.restapi:blocks" plone fg'''
127
+ sh '''docker pull plone; docker run -d --rm --name="$BUILD_TAG-plone" -e SITE="Plone" -e PROFILES="profile-plone.restapi:blocks" plone fg'''
86
128
  sh '''docker pull plone/volto-addon-ci; docker run -i --name="$BUILD_TAG-cypress" --link $BUILD_TAG-plone:plone -e NAMESPACE="$NAMESPACE" -e GIT_NAME=$GIT_NAME -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" -e DEPENDENCIES="$DEPENDENCIES" plone/volto-addon-ci cypress'''
87
129
  } finally {
88
130
  try {
@@ -100,7 +142,8 @@ pipeline {
100
142
  reportName: 'CypressCoverage',
101
143
  reportTitles: 'Integration Tests Code Coverage'])
102
144
  }
103
- archiveArtifacts artifacts: 'cypress-reports/videos/*.mp4', fingerprint: true
145
+ sh '''touch empty_file; for ok_test in $(grep -E 'file=.*failures="0"' $(grep 'testsuites .*failures="0"' $(find cypress-results -name *.xml) empty_file | awk -F: '{print $1}') empty_file | sed 's/.* file="\\(.*\\)" time.*/\\1/' | sed 's#^cypress/integration/##g' | sed 's#^../../../node_modules/@eeacms/##g'); do rm -f cypress-reports/videos/$ok_test.mp4; rm -f cypress-reports/$ok_test.mp4; done'''
146
+ archiveArtifacts artifacts: 'cypress-reports/**/*.mp4', fingerprint: true, allowEmptyArchive: true
104
147
  stash name: "cypress-coverage", includes: "cypress-coverage/**", allowEmpty: true
105
148
  }
106
149
  finally {
@@ -122,10 +165,16 @@ pipeline {
122
165
  }
123
166
 
124
167
  stage('Report to SonarQube') {
125
- // Exclude Pull-Requests
126
168
  when {
127
169
  allOf {
128
170
  environment name: 'CHANGE_ID', value: ''
171
+ anyOf {
172
+ branch 'master'
173
+ allOf {
174
+ branch 'develop'
175
+ not { changelog '.*^Automated release [0-9\\.]+$' }
176
+ }
177
+ }
129
178
  }
130
179
  }
131
180
  steps {
@@ -156,8 +205,8 @@ pipeline {
156
205
  steps {
157
206
  node(label: 'docker') {
158
207
  script {
159
- if ( env.CHANGE_BRANCH != "develop" && !( env.CHANGE_BRANCH.startsWith("hotfix")) ) {
160
- error "Pipeline aborted due to PR not made from develop or hotfix branch"
208
+ if ( env.CHANGE_BRANCH != "develop" ) {
209
+ error "Pipeline aborted due to PR not made from develop branch"
161
210
  }
162
211
  withCredentials([string(credentialsId: 'eea-jenkins-token', variable: 'GITHUB_TOKEN')]) {
163
212
  sh '''docker pull eeacms/gitflow'''
@@ -168,23 +217,6 @@ pipeline {
168
217
  }
169
218
  }
170
219
 
171
- stage('Release') {
172
- when {
173
- allOf {
174
- environment name: 'CHANGE_ID', value: ''
175
- branch 'master'
176
- }
177
- }
178
- steps {
179
- node(label: 'docker') {
180
- withCredentials([string(credentialsId: 'eea-jenkins-token', variable: 'GITHUB_TOKEN'),string(credentialsId: 'eea-jenkins-npm-token', variable: 'NPM_TOKEN')]) {
181
- sh '''docker pull eeacms/gitflow'''
182
- sh '''docker run -i --rm --name="$BUILD_TAG-gitflow-master" -e GIT_BRANCH="$BRANCH_NAME" -e GIT_NAME="$GIT_NAME" -e GIT_TOKEN="$GITHUB_TOKEN" -e NPM_TOKEN="$NPM_TOKEN" -e LANGUAGE=javascript eeacms/gitflow'''
183
- }
184
- }
185
- }
186
- }
187
-
188
220
  }
189
221
 
190
222
  post {
package/README.md CHANGED
@@ -1,7 +1,19 @@
1
1
  # volto-group-block
2
+
2
3
  [![Releases](https://img.shields.io/github/v/release/eea/volto-group-block)](https://github.com/eea/volto-group-block/releases)
4
+
3
5
  [![Pipeline](https://ci.eionet.europa.eu/buildStatus/icon?job=volto-addons%2Fvolto-group-block%2Fmaster&subject=master)](https://ci.eionet.europa.eu/view/Github/job/volto-addons/job/volto-group-block/job/master/display/redirect)
6
+ [![Lines of Code](https://sonarqube.eea.europa.eu/api/project_badges/measure?project=volto-group-block-master&metric=ncloc)](https://sonarqube.eea.europa.eu/dashboard?id=volto-group-block-master)
7
+ [![Coverage](https://sonarqube.eea.europa.eu/api/project_badges/measure?project=volto-group-block-master&metric=coverage)](https://sonarqube.eea.europa.eu/dashboard?id=volto-group-block-master)
8
+ [![Bugs](https://sonarqube.eea.europa.eu/api/project_badges/measure?project=volto-group-block-master&metric=bugs)](https://sonarqube.eea.europa.eu/dashboard?id=volto-group-block-master)
9
+ [![Duplicated Lines (%)](https://sonarqube.eea.europa.eu/api/project_badges/measure?project=volto-group-block-master&metric=duplicated_lines_density)](https://sonarqube.eea.europa.eu/dashboard?id=volto-group-block-master)
10
+
4
11
  [![Pipeline](https://ci.eionet.europa.eu/buildStatus/icon?job=volto-addons%2Fvolto-group-block%2Fdevelop&subject=develop)](https://ci.eionet.europa.eu/view/Github/job/volto-addons/job/volto-group-block/job/develop/display/redirect)
12
+ [![Lines of Code](https://sonarqube.eea.europa.eu/api/project_badges/measure?project=volto-group-block-develop&metric=ncloc)](https://sonarqube.eea.europa.eu/dashboard?id=volto-group-block-develop)
13
+ [![Coverage](https://sonarqube.eea.europa.eu/api/project_badges/measure?project=volto-group-block-develop&metric=coverage)](https://sonarqube.eea.europa.eu/dashboard?id=volto-group-block-develop)
14
+ [![Bugs](https://sonarqube.eea.europa.eu/api/project_badges/measure?project=volto-group-block-develop&metric=bugs)](https://sonarqube.eea.europa.eu/dashboard?id=volto-group-block-develop)
15
+ [![Duplicated Lines (%)](https://sonarqube.eea.europa.eu/api/project_badges/measure?project=volto-group-block-develop&metric=duplicated_lines_density)](https://sonarqube.eea.europa.eu/dashboard?id=volto-group-block-develop)
16
+
5
17
 
6
18
  [Volto](https://github.com/plone/volto) add-on to group blocks in sections and filter available blocks per content-type per section
7
19
 
@@ -72,6 +84,81 @@
72
84
 
73
85
  1. Happy editing!
74
86
 
87
+ ## Release
88
+
89
+ ### Automatic release using Jenkins
90
+
91
+ * The automatic release is started by creating a [Pull Request](../../compare/master...develop) from `develop` to `master`. The pull request status checks correlated to the branch and PR Jenkins jobs need to be processed successfully. 1 review from a github user with rights is mandatory.
92
+ * It runs on every commit on `master` branch, which is protected from direct commits, only allowing pull request merge commits.
93
+ * The automatic release is done by [Jenkins](https://ci.eionet.europa.eu). The status of the release job can be seen both in the Readme.md badges and the green check/red cross/yellow circle near the last commit information. If you click on the icon, you will have the list of checks that were run. The `continuous-integration/jenkins/branch` link goes to the Jenkins job execution webpage.
94
+ * Automated release scripts are located in the `eeacms/gitflow` docker image, specifically [js-release.sh](https://github.com/eea/eea.docker.gitflow/blob/master/src/js-release.sh) script. It uses the `release-it` tool.
95
+ * As long as a PR request is open from develop to master, the PR Jenkins job will automatically re-create the CHANGELOG.md and package.json files to be production-ready.
96
+ * The version format must be MAJOR.MINOR.PATCH. By default, next release is set to next minor version (with patch 0).
97
+ * You can manually change the version in `package.json`. The new version must not be already present in the tags/releases of the repository, otherwise it will be automatically increased by the script. Any changes to the version will trigger a `CHANGELOG.md` re-generation.
98
+ * Automated commits and commits with [JENKINS] or [YARN] in the commit log are excluded from `CHANGELOG.md` file.
99
+
100
+ ### Manual release from the develop branch ( beta release )
101
+
102
+ #### Installation and configuration of release-it
103
+
104
+ You need to first install the [release-it](https://github.com/release-it/release-it) client.
105
+
106
+ ```
107
+ npm install -g release-it
108
+ ```
109
+
110
+ Release-it uses the configuration written in the [`.release-it.json`](./.release-it.json) file located in the root of the repository.
111
+
112
+ Release-it is a tool that automates 4 important steps in the release process:
113
+
114
+ 1. Version increase in `package.json` ( increased from the current version in `package.json`)
115
+ 2. `CHANGELOG.md` automatic generation from commit messages ( grouped by releases )
116
+ 3. GitHub release on the commit with the changelog and package.json modification on the develop branch
117
+ 4. NPM release ( by default it's disabled, but can be enabled in the configuration file )
118
+
119
+ To configure the authentification, you need to export GITHUB_TOKEN for [GitHub](https://github.com/settings/tokens)
120
+
121
+ ```
122
+ export GITHUB_TOKEN=XXX-XXXXXXXXXXXXXXXXXXXXXX
123
+ ```
124
+
125
+ To configure npm, you can use the `npm login` command or use a configuration file with a TOKEN :
126
+
127
+ ```
128
+ echo "//registry.npmjs.org/:_authToken=YYYYYYYYYYYYYYYYYYYYYYYYYYYYYY" > .npmrc
129
+ ```
130
+
131
+ #### Using release-it tool
132
+
133
+ There are 3 yarn scripts that can be run to do the release
134
+
135
+ ##### yarn release-beta
136
+
137
+ Automatically calculates and presents 3 beta versions - patch, minor and major for you to choose ( or Other for manual input).
138
+
139
+ ```
140
+ ? Select increment (next version):
141
+ ❯ prepatch (0.1.1-beta.0)
142
+ preminor (0.2.0-beta.0)
143
+ premajor (1.0.0-beta.0)
144
+ Other, please specify...
145
+ ```
146
+
147
+ ##### yarn release-major-beta
148
+
149
+ Same as `yarn release-beta`, but with premajor version pre-selected.
150
+
151
+ ##### yarn release
152
+
153
+ Generic command, does not automatically add the `beta` to version, but you can still manually write it if you choose Other.
154
+
155
+ #### Important notes
156
+
157
+ > Do not use release-it tool on master branch, the commit on CHANGELOG.md file and the version increase in the package.json file can't be done without a PULL REQUEST.
158
+
159
+ > Do not keep Pull Requests from develop to master branches open when you are doing beta releases from the develop branch. As long as a PR to master is open, an automatic script will run on every commit and will update both the version and the changelog to a production-ready state - ( MAJOR.MINOR.PATCH mandatory format for version).
160
+
161
+
75
162
  ## How to contribute
76
163
 
77
164
  See [DEVELOP.md](https://github.com/eea/volto-group-block/blob/master/DEVELOP.md).
@@ -5,21 +5,33 @@ describe('Blocks Tests', () => {
5
5
  afterEach(tearDownAfterEach);
6
6
 
7
7
  it('Add Block: Empty', () => {
8
+ // without this the clear command below does nothing sometimes
9
+ cy.wait(500);
10
+
8
11
  // Change page title
9
- cy.get('.documentFirstHeading > .public-DraftStyleDefault-block')
10
- .clear()
11
- .type('My Add-on Page')
12
- .get('.documentFirstHeading span[data-text]')
13
- .contains('My Add-on Page');
12
+ cy.get('[contenteditable=true]').first().clear();
13
+
14
+ cy.get('[contenteditable=true]').first().type('My Add-on Page');
14
15
 
15
- cy.get('.documentFirstHeading > .public-DraftStyleDefault-block').type(
16
- '{enter}',
17
- );
16
+ cy.get('.documentFirstHeading').contains('My Add-on Page');
17
+
18
+ cy.get('[contenteditable=true]').first().type('{enter}');
18
19
 
19
20
  // Add block
20
21
  cy.get('.ui.basic.icon.button.block-add-button').first().click();
21
- cy.get('.blocks-chooser .title').contains('Media').click();
22
- cy.get('.content.active.media .button.image').contains('Image').click();
22
+ cy.get('.blocks-chooser .title').contains('Common').click();
23
+ cy.get('.content.active.common .button.group').contains('Group').click();
24
+
25
+ cy.get('.block.text.selected').type("test");
26
+ cy.get('.block.text.selected').type("{enter}");
27
+ cy.get('.block.text.selected').type("test2");
28
+ cy.get('.block.text.selected').type("{enter}");
29
+ cy.get('.block.text.selected').type("test3");
30
+
31
+ cy.get('.block-toolbar svg').first()
32
+ .trigger('mousedown', { button: 0})
33
+ .trigger('mousemove', 10, -40, { force: true})
34
+ .trigger('mouseup', 10, -40, {force:true});
23
35
 
24
36
  // Save
25
37
  cy.get('#toolbar-save').click();
@@ -27,6 +39,6 @@ describe('Blocks Tests', () => {
27
39
 
28
40
  // then the page view should contain our changes
29
41
  cy.contains('My Add-on Page');
30
- cy.get('.block.image');
42
+ cy.contains('test2');
31
43
  });
32
44
  });
@@ -44,7 +44,7 @@ export const setupBeforeEach = () => {
44
44
  cy.waitForResourceToLoad('@types');
45
45
  cy.waitForResourceToLoad('my-page');
46
46
  cy.navigate('/cypress/my-page/edit');
47
- cy.get(`.block.title [data-contents]`);
47
+ cy.get(`.block.title h1`);
48
48
  };
49
49
 
50
50
  export const tearDownAfterEach = () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-group-block",
3
- "version": "4.3.0",
3
+ "version": "4.3.4",
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",
@@ -25,6 +25,8 @@
25
25
  },
26
26
  "scripts": {
27
27
  "release": "release-it",
28
+ "release-major-beta": "release-it major --preRelease=beta",
29
+ "release-beta": "release-it --preRelease=beta",
28
30
  "bootstrap": "npm install -g ejs; npm link ejs; node bootstrap",
29
31
  "stylelint": "../../../node_modules/stylelint/bin/stylelint.js --allow-empty-input 'src/**/*.{css,less}'",
30
32
  "stylelint:overrides": "../../../node_modules/.bin/stylelint --syntax less --allow-empty-input 'theme/**/*.overrides' 'src/**/*.overrides'",
@@ -30,9 +30,8 @@ const Edit = (props) => {
30
30
  } = props;
31
31
 
32
32
  const metadata = props.metadata || props.properties;
33
- const properties = isEmpty(data?.data?.blocks)
34
- ? emptyBlocksForm()
35
- : data.data;
33
+ const data_blocks = data?.data?.blocks;
34
+ const properties = isEmpty(data_blocks) ? emptyBlocksForm() : data.data;
36
35
 
37
36
  const [selectedBlock, setSelectedBlock] = useState(
38
37
  properties.blocks_layout.items[0],
@@ -40,7 +39,7 @@ const Edit = (props) => {
40
39
 
41
40
  React.useEffect(() => {
42
41
  if (
43
- isEmpty(data?.data?.blocks) &&
42
+ isEmpty(data_blocks) &&
44
43
  properties.blocks_layout.items[0] !== selectedBlock
45
44
  ) {
46
45
  setSelectedBlock(properties.blocks_layout.items[0]);
@@ -49,40 +48,65 @@ const Edit = (props) => {
49
48
  data: properties,
50
49
  });
51
50
  }
52
- }, [
53
- onChangeBlock,
54
- properties,
55
- selectedBlock,
56
- block,
57
- data,
58
- data?.data?.blocks,
59
- ]);
51
+ }, [onChangeBlock, properties, selectedBlock, block, data, data_blocks]);
60
52
 
61
53
  const blockState = {};
62
54
  let charCount = 0;
63
55
 
56
+ /**
57
+ * Count the number of characters that are anything except using Regex
58
+ * @param {string} paragraph
59
+ * @returns
60
+ */
61
+ const countCharsWithoutSpaces = (paragraph) => {
62
+ const regex = /[^\s\\]/g;
63
+
64
+ return (paragraph.match(regex) || []).length;
65
+ };
66
+
67
+ /**
68
+ * Count the number of characters
69
+ * @param {string} paragraph
70
+ * @returns
71
+ */
72
+ const countCharsWithSpaces = (paragraph) => {
73
+ return paragraph?.length || 0;
74
+ };
75
+
76
+ /**
77
+ * Recursively look for any block that contains text or plaintext
78
+ * @param {Object} blocksObject
79
+ * @returns
80
+ */
64
81
  const countTextInBlocks = (blocksObject) => {
65
82
  let groupCharCount = 0;
66
83
 
67
84
  Object.keys(blocksObject).forEach((blockId) => {
68
- const charCountTemp = blocksObject[blockId]?.plaintext
69
- ? blocksObject[blockId]?.plaintext.length
85
+ const foundText = blocksObject[blockId]?.plaintext
86
+ ? blocksObject[blockId]?.plaintext
70
87
  : blocksObject[blockId]?.text?.blocks[0]?.text
71
- ? blocksObject[blockId].text.blocks[0].text.length
88
+ ? blocksObject[blockId].text.blocks[0].text
72
89
  : blocksObject[blockId]?.data?.blocks
73
90
  ? countTextInBlocks(blocksObject[blockId]?.data?.blocks)
74
91
  : blocksObject[blockId]?.blocks
75
92
  ? countTextInBlocks(blocksObject[blockId]?.blocks)
76
- : 0;
77
- groupCharCount = groupCharCount + charCountTemp;
93
+ : '';
94
+ const resultText =
95
+ typeof foundText === 'string' || foundText instanceof String
96
+ ? foundText
97
+ : '';
98
+
99
+ groupCharCount += props.data.ignoreSpaces
100
+ ? countCharsWithoutSpaces(resultText)
101
+ : countCharsWithSpaces(resultText);
78
102
  });
79
103
 
80
104
  return groupCharCount;
81
105
  };
82
106
 
83
107
  const showCharCounter = () => {
84
- if (props.data?.data?.blocks) {
85
- charCount = countTextInBlocks(props.data?.data?.blocks);
108
+ if (data_blocks) {
109
+ charCount = countTextInBlocks(data_blocks);
86
110
  }
87
111
  };
88
112
  showCharCounter();
@@ -11,6 +11,7 @@ const Schema = {
11
11
  'allowedBlocks',
12
12
  'as',
13
13
  'maxChars',
14
+ 'ignoreSpaces',
14
15
  'readOnlySettings',
15
16
  'disableInnerButtons',
16
17
  'required',
@@ -67,6 +68,11 @@ const Schema = {
67
68
  type: 'integer',
68
69
  factory: 'Integer',
69
70
  },
71
+ ignoreSpaces: {
72
+ title: 'Ignore spaces',
73
+ description: 'Ignore spaces while calculating maximum characters',
74
+ type: 'boolean',
75
+ },
70
76
  required: {
71
77
  title: 'Required',
72
78
  description: "Don't allow deletion of this block",