@eeacms/volto-hero-block 5.5.0 → 6.0.1

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,48 @@ 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.0.1](https://github.com/eea/volto-hero-block/compare/6.0.0...6.0.1) - 5 April 2024
8
+
9
+ #### :house: Internal changes
10
+
11
+ - chore: Fix package.json [alin - [`a6f6427`](https://github.com/eea/volto-hero-block/commit/a6f6427acc6789a0c4a9a9b07e73b8186638d872)]
12
+
13
+ ## [6.0.0](https://github.com/eea/volto-hero-block/compare/5.5.0...6.0.0) - 5 April 2024
14
+
15
+ #### :boom: Breaking Change
16
+
17
+ - breaking(hero): Use BlocksForm instead of SlateEditor to render more slates block #44 from eea/multiline-bug [ichim-david - [`57953c5`](https://github.com/eea/volto-hero-block/commit/57953c5f27a1831fbb3ff581900b1b8d1b20cb1e)]
18
+ - breaking(tests): Updated Hero.test.jsx.snap snapshots after removal of inner div wrapper [David Ichim - [`7cf73ef`](https://github.com/eea/volto-hero-block/commit/7cf73ef3c4cd0b01dc238a1f6a51a1866dd56aa0)]
19
+
20
+ #### :nail_care: Enhancements
21
+
22
+ - change(hero): Use EditBlockWrapper from Volto core [David Ichim - [`360d2d7`](https://github.com/eea/volto-hero-block/commit/360d2d7e0f0240dd089839cc2ec62a691bcf41e2)]
23
+
24
+ #### :hammer_and_wrench: Others
25
+
26
+ - Release 6.0.0 #45 from eea/develop [ichim-david - [`a0120da`](https://github.com/eea/volto-hero-block/commit/a0120da50fcf7d5962a9dd9a93abe88fcbee090d)]
27
+ - Fix onClick event in Hero block to select the block in Edit mode [David Ichim - [`1f38992`](https://github.com/eea/volto-hero-block/commit/1f389922d05a5a04cf11d023229aca156873f4b9)]
28
+ - Add ts-jest package to package.json [David Ichim - [`7c82b62`](https://github.com/eea/volto-hero-block/commit/7c82b626985bfdabcf10db6da159c13fa86b27e2)]
29
+ - bump package version to a major 6.0.0 to indicate breaking changes [David Ichim - [`472b675`](https://github.com/eea/volto-hero-block/commit/472b675fcc037c5ac31ceed52f60aa13998fa896)]
30
+ - fix crash of page after removal of a slate block and saving edit page [David Ichim - [`a917cdc`](https://github.com/eea/volto-hero-block/commit/a917cdccec827594b10ceced3c1588cac2308b43)]
31
+ - fix intial value slate [dobri1408 - [`c70bb80`](https://github.com/eea/volto-hero-block/commit/c70bb80a8c60a710cba02d7afbe069ad1b2e4fa2)]
32
+ - Update Jest configuration to avoid ts error and removed onClick from Hero block view component [David Ichim - [`448dbb4`](https://github.com/eea/volto-hero-block/commit/448dbb4882b0fa3d0a128a7a5241b3fa8148d955)]
33
+ - switch to block sidebar when clicking on the hero block in edit [David Ichim - [`1797077`](https://github.com/eea/volto-hero-block/commit/1797077bcbe9001e24c382d4e534b150683acb9c)]
34
+ - fix eslint [dobri1408 - [`7b0a66c`](https://github.com/eea/volto-hero-block/commit/7b0a66cfb0157787b69ae9c80326b9d9e7a06227)]
35
+ - fix eslint [dobri1408 - [`163af98`](https://github.com/eea/volto-hero-block/commit/163af98415a702361c044531e8f13e8e034972ef)]
36
+ - fix eslint comments [dobri1408 - [`0fff8b0`](https://github.com/eea/volto-hero-block/commit/0fff8b07f4375cf8809fe3575ea6bf913aec0c0c)]
37
+ - fix eslint [dobri1408 - [`d560dcb`](https://github.com/eea/volto-hero-block/commit/d560dcb580755767d43d7848f182b420552c1894)]
38
+ - improve the quality [dobri1408 - [`d6bf215`](https://github.com/eea/volto-hero-block/commit/d6bf21563f6e1e423f1c730f5e5409cfc724c240)]
39
+ - Update Edit.jsx [dobri1408 - [`2c31ecd`](https://github.com/eea/volto-hero-block/commit/2c31ecd5fd896e5f0a43f4a689dbb60a36c39431)]
40
+ - fix cypress test [dobri1408 - [`c24f627`](https://github.com/eea/volto-hero-block/commit/c24f627de259623cf27cdcde703667d4e510ce8b)]
41
+ - fix unit tests [dobri1408 - [`ad6e98f`](https://github.com/eea/volto-hero-block/commit/ad6e98fe433f815a692139d5a06f669c485422ad)]
42
+ - fix unit tests [dobri1408 - [`7c007a6`](https://github.com/eea/volto-hero-block/commit/7c007a63c4a14a9230a4e59a3877e9494a241656)]
43
+ - trigger tests [dobri1408 - [`0f51440`](https://github.com/eea/volto-hero-block/commit/0f514401ccd93e90053009427735acc9d8ef4ef7)]
44
+ - mock react-router-dom [dobri1408 - [`f6a33ab`](https://github.com/eea/volto-hero-block/commit/f6a33ab4142fe25f890d186f09162d3c6ea8c68d)]
45
+ - fix eslint [dobri1408 - [`89483de`](https://github.com/eea/volto-hero-block/commit/89483dee93c172e14b8a89e71bd112a27d3d5a90)]
46
+ - fi problems with the bacward compatibility [dobri1408 - [`5915149`](https://github.com/eea/volto-hero-block/commit/59151498b7601f2e1de959916cee504b702c9cb1)]
47
+ - use blockform and renderblocks [dobri1408 - [`61994d0`](https://github.com/eea/volto-hero-block/commit/61994d0044e212e89dbec1ac25f13a56b42f8f82)]
48
+ - fix multiline hero bug [dobri1408 - [`25b26d5`](https://github.com/eea/volto-hero-block/commit/25b26d562121b59ff5120ea8caefaab014885889)]
7
49
  ### [5.5.0](https://github.com/eea/volto-hero-block/compare/5.4.6...5.5.0) - 19 February 2024
8
50
 
9
51
  #### :house: Internal changes
@@ -18,6 +60,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
18
60
  - Allow multiline editing of hero block [Tiberiu Ichim - [`373d1a0`](https://github.com/eea/volto-hero-block/commit/373d1a0d243b8e0b3df31f2a51a3c5df62f48214)]
19
61
  - Allow multiline editing of hero block [Tiberiu Ichim - [`b674ca5`](https://github.com/eea/volto-hero-block/commit/b674ca589502a81aaf6abed75dbf8b83ac1731fb)]
20
62
  - fix ESlint [Teodor - [`1439495`](https://github.com/eea/volto-hero-block/commit/14394952ef587f71be8b2c762c7e19698d8a55e4)]
63
+ - Add Sonarqube tag using insitu-frontend addons list [EEA Jenkins - [`f133e20`](https://github.com/eea/volto-hero-block/commit/f133e2017ff9c3f13e6c44ce3e6b7757a25b129f)]
21
64
  - test: Update jest,Jenkinsfile,lint to volto-addons-template PR30 [valentinab25 - [`de6a206`](https://github.com/eea/volto-hero-block/commit/de6a206bed9afd53d97f5e6d70e2391ccc01f0f1)]
22
65
  ### [5.4.6](https://github.com/eea/volto-hero-block/compare/5.4.5...5.4.6) - 27 November 2023
23
66
 
@@ -31,9 +74,16 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
31
74
 
32
75
  #### :house: Internal changes
33
76
 
77
+ - chore: [JENKINS] Refactor automated testing [valentinab25 - [`df8242c`](https://github.com/eea/volto-hero-block/commit/df8242c62eb8c706c3854f6bb4a6984932463571)]
34
78
 
35
79
  #### :hammer_and_wrench: Others
36
80
 
81
+ - test: [JENKINS] Use java17 for sonarqube scanner [valentinab25 - [`4ea90f6`](https://github.com/eea/volto-hero-block/commit/4ea90f6a23c92fe631ee6025dbe5ee27ec030665)]
82
+ - test: [JENKINS] Run cypress in started frontend container [valentinab25 - [`6e9d7f5`](https://github.com/eea/volto-hero-block/commit/6e9d7f593363e08f519ab8296aef229ed2682113)]
83
+ - test: [JENKINS] Add cpu limit on cypress docker [valentinab25 - [`067fa27`](https://github.com/eea/volto-hero-block/commit/067fa27ee26d1d348d5ce1b089ea9931d9f32589)]
84
+ - test: [JENKINS] Increase shm-size to cypress docker [valentinab25 - [`0f6a259`](https://github.com/eea/volto-hero-block/commit/0f6a259fc73db97a7a8af69a808421191b146629)]
85
+ - test: [JENKINS] Improve cypress time [valentinab25 - [`c1c72f4`](https://github.com/eea/volto-hero-block/commit/c1c72f4b54a84521f200682b230bba60e6920a70)]
86
+ - Add Sonarqube tag using clms-frontend addons list [EEA Jenkins - [`65744c9`](https://github.com/eea/volto-hero-block/commit/65744c9b2b0944d2aff90fc56485f10390810d1c)]
37
87
  ### [5.4.5](https://github.com/eea/volto-hero-block/compare/5.4.4...5.4.5) - 19 October 2023
38
88
 
39
89
  ### [5.4.4](https://github.com/eea/volto-hero-block/compare/5.4.3...5.4.4) - 19 October 2023
@@ -73,12 +123,14 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
73
123
  - test: add unit tests for Hero, Edit, helpers, hooks - refs #254313 [ana-oprea - [`89b39af`](https://github.com/eea/volto-hero-block/commit/89b39afe7ad5ce94d341482be91ab55e2c1a31ed)]
74
124
  - i18n: Add en [Alin Voinea - [`9cdb7f1`](https://github.com/eea/volto-hero-block/commit/9cdb7f1ff9d81dade3d91551b53cf7200f08937e)]
75
125
  - test: Update Makefile and docker-compose to align it with Jenkinsfile [valentinab25 - [`0fe0d91`](https://github.com/eea/volto-hero-block/commit/0fe0d91fe9c43d10574990e9b163ffc49fe5bee7)]
126
+ - Add Sonarqube tag using freshwater-frontend addons list [EEA Jenkins - [`b1d1446`](https://github.com/eea/volto-hero-block/commit/b1d14467bcde28023b2831235928db1f328d6b0a)]
76
127
  ### [5.4.1](https://github.com/eea/volto-hero-block/compare/5.4.0...5.4.1) - 24 July 2023
77
128
 
78
129
  ### [5.4.0](https://github.com/eea/volto-hero-block/compare/5.3.1...5.4.0) - 12 June 2023
79
130
 
80
131
  #### :house: Internal changes
81
132
 
133
+ - chore: [JENKINS] Deprecate circularity website [valentinab25 - [`395db48`](https://github.com/eea/volto-hero-block/commit/395db484f73c2dd2c56233c120a9620340f17d0b)]
82
134
 
83
135
  #### :hammer_and_wrench: Others
84
136
 
@@ -99,6 +151,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
99
151
  - put return statement [Dobricean Ioan Dorian - [`8eff5fd`](https://github.com/eea/volto-hero-block/commit/8eff5fdf977fcbb8cc952d3f45b577b02ca59cb9)]
100
152
  - change name and refactor to be more efficent [Dobricean Ioan Dorian - [`ff24145`](https://github.com/eea/volto-hero-block/commit/ff2414542833998ef282376de3fbda8698287849)]
101
153
  - stop-image-disappear over and over [Dobricean Ioan Dorian - [`c5b6f54`](https://github.com/eea/volto-hero-block/commit/c5b6f545ac422d95b8d802349aa4cf27af820829)]
154
+ - Add Sonarqube tag using industry-frontend addons list [EEA Jenkins - [`3d38dd0`](https://github.com/eea/volto-hero-block/commit/3d38dd09a36525bda448f67a6d218bc7690a4cc3)]
102
155
  ### [5.3.0](https://github.com/eea/volto-hero-block/compare/5.2.0...5.3.0) - 27 March 2023
103
156
 
104
157
  #### :rocket: New Features
@@ -137,9 +190,11 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
137
190
  - fix onScreen hook error #16 from eea/fix-onscreen-hook [ichim-david - [`9123541`](https://github.com/eea/volto-hero-block/commit/91235413f423d7e6c4788d70b687b3ed5d4884b4)]
138
191
  - no need for comments [andreiggr - [`a14f9c3`](https://github.com/eea/volto-hero-block/commit/a14f9c3bdddfa22e6b4bbc8318f0ca5bdc9c2d38)]
139
192
  - fix hook [andreiggr - [`f7fae73`](https://github.com/eea/volto-hero-block/commit/f7fae73007f79af2f06da1d9b72a53ad86fef4ac)]
193
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`6b78fc0`](https://github.com/eea/volto-hero-block/commit/6b78fc044a933ab9b4b4694901aa26628ef0a836)]
140
194
  - eslint [andreiggr - [`68451b7`](https://github.com/eea/volto-hero-block/commit/68451b725420015fbd5b695e97b8742988d49913)]
141
195
  - lazy load huge img on first 10px [andreiggr - [`67dc7d3`](https://github.com/eea/volto-hero-block/commit/67dc7d3475188d692e053032c2639dd1a585c029)]
142
196
  - lazy load huge bgimage wip [andreiggr - [`86e45ec`](https://github.com/eea/volto-hero-block/commit/86e45ece842f1cd7452920dffa3a9b4aea945f56)]
197
+ - Add Sonarqube tag using ims-frontend addons list [EEA Jenkins - [`87cbb38`](https://github.com/eea/volto-hero-block/commit/87cbb383290a168f85703573670e17f4e1ed7747)]
143
198
  ## [4.0.0](https://github.com/eea/volto-hero-block/compare/3.0.1...4.0.0) - 7 February 2023
144
199
 
145
200
  #### :nail_care: Enhancements
@@ -165,6 +220,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
165
220
 
166
221
  #### :hammer_and_wrench: Others
167
222
 
223
+ - Add Sonarqube tag using advisory-board-frontend addons list [EEA Jenkins - [`ab85c7b`](https://github.com/eea/volto-hero-block/commit/ab85c7bd5bd1e3aec95e02f9b4d026b1203d5739)]
168
224
  ## [3.0.0](https://github.com/eea/volto-hero-block/compare/2.1.0...3.0.0) - 22 December 2022
169
225
 
170
226
  #### :rocket: New Features
@@ -173,8 +229,11 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
173
229
 
174
230
  #### :hammer_and_wrench: Others
175
231
 
232
+ - Add Sonarqube tag using advisory-board-frontend addons list [EEA Jenkins - [`f06f58c`](https://github.com/eea/volto-hero-block/commit/f06f58c7cd4cfc15a03208e9c7a4e31fe2eba2f6)]
233
+ - Add Sonarqube tag using climate-energy-frontend addons list [EEA Jenkins - [`20e5bcb`](https://github.com/eea/volto-hero-block/commit/20e5bcb3c4dd538595741928319c3204c5d18f8c)]
176
234
  - Cosmetics [Alin Voinea - [`9dac70c`](https://github.com/eea/volto-hero-block/commit/9dac70c0a3bea8e188ede9123f4f99de8e0f6987)]
177
235
  - test(Jenkins): Run tests and cypress with latest canary @plone/volto [Alin Voinea - [`2d4005f`](https://github.com/eea/volto-hero-block/commit/2d4005f0f31b121e1b7d2e94414f3dff92ec1a16)]
236
+ - Add Sonarqube tag using cca-frontend addons list [EEA Jenkins - [`2931fcc`](https://github.com/eea/volto-hero-block/commit/2931fccbee5f8e117e5ae9095ba57e63e465ddb3)]
178
237
  ### [2.1.0](https://github.com/eea/volto-hero-block/compare/2.0.0...2.1.0) - 12 December 2022
179
238
 
180
239
  #### :bug: Bug Fixes
@@ -183,6 +242,12 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
183
242
 
184
243
  #### :hammer_and_wrench: Others
185
244
 
245
+ - Add Sonarqube tag using bise-frontend addons list [EEA Jenkins - [`93be4f9`](https://github.com/eea/volto-hero-block/commit/93be4f96fb72cacfc25f9b058cb379d80060ee13)]
246
+ - yarn 3 [Alin Voinea - [`8e2dccd`](https://github.com/eea/volto-hero-block/commit/8e2dccd47cbef3c0871407baa376ce61c540c754)]
247
+ - Add Sonarqube tag using marine-frontend addons list [EEA Jenkins - [`6bc3af3`](https://github.com/eea/volto-hero-block/commit/6bc3af35b4edf07971d1b0ce1648965e8d6e3bc0)]
248
+ - Add Sonarqube tag using clms-frontend addons list [EEA Jenkins - [`d7dbbd2`](https://github.com/eea/volto-hero-block/commit/d7dbbd21277dd76bf59d91a4dc8e022b2a6ff99c)]
249
+ - Add Sonarqube tag using demo-kitkat-frontend addons list [EEA Jenkins - [`3c1f0d6`](https://github.com/eea/volto-hero-block/commit/3c1f0d6e7f8e5318aee3413ec3687d8492376f9d)]
250
+ - Add Sonarqube tag using forests-frontend addons list [EEA Jenkins - [`843017a`](https://github.com/eea/volto-hero-block/commit/843017aa7dbea71cc7888663496e352d287440b4)]
186
251
  ## [2.0.0](https://github.com/eea/volto-hero-block/compare/1.0.0...2.0.0) - 16 November 2022
187
252
 
188
253
  #### :nail_care: Enhancements
@@ -192,6 +257,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
192
257
  #### :hammer_and_wrench: Others
193
258
 
194
259
  - test(estlint): Fix .project.eslintrc.js [Alin Voinea - [`b8f0971`](https://github.com/eea/volto-hero-block/commit/b8f0971b21a5334d40c1b8f5103cea61d9ffe6f1)]
260
+ - Add Sonarqube tag using circularity-frontend addons list [EEA Jenkins - [`581dedf`](https://github.com/eea/volto-hero-block/commit/581dedf07410ef2ca09e6ddaa05fbf176400adbb)]
195
261
  ## [1.0.0](https://github.com/eea/volto-hero-block/compare/0.2.0...1.0.0) - 28 October 2022
196
262
 
197
263
  #### :nail_care: Enhancements
@@ -203,6 +269,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
203
269
  - Remove cypress.json [Alin Voinea - [`593bdf2`](https://github.com/eea/volto-hero-block/commit/593bdf207ca4fd3f2393117b6f64a44727881ad0)]
204
270
  - test(cypress): Upgrade to Cypress 10 / Razzle 4 [Alin Voinea - [`edd48a5`](https://github.com/eea/volto-hero-block/commit/edd48a5c13824bce5e03e46790f1890656b340d8)]
205
271
  - Cleanup [Alin Voinea - [`9d72ee7`](https://github.com/eea/volto-hero-block/commit/9d72ee7a06d1c6fed46586d30bb85eae39e670bf)]
272
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`95986d0`](https://github.com/eea/volto-hero-block/commit/95986d0b8fd5c3cbb9e6da9059f71e066a8e171b)]
206
273
  ### [0.2.0](https://github.com/eea/volto-hero-block/compare/0.1.4...0.2.0) - 6 July 2022
207
274
 
208
275
  #### :bug: Bug Fixes
@@ -241,6 +308,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
241
308
  - Update slate footnote support [Miu Razvan - [`c1522b4`](https://github.com/eea/volto-hero-block/commit/c1522b4164dbe6de01771d211d7e0bf3009f44d4)]
242
309
  - Use justify content for text and button as well [Miu Razvan - [`08599cc`](https://github.com/eea/volto-hero-block/commit/08599cc45546d9b349128c4f8ce9c01318385811)]
243
310
  - Add dependencies [Miu Razvan - [`30e2881`](https://github.com/eea/volto-hero-block/commit/30e2881a2a97a899e7f4cc614a0405c300ac6fee)]
311
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`b415422`](https://github.com/eea/volto-hero-block/commit/b41542285edd29440a324b101a4dbae9334830bf)]
244
312
  ### 0.1.0 - 10 June 2022
245
313
 
246
314
  #### :hammer_and_wrench: Others
package/README.md CHANGED
@@ -26,6 +26,16 @@ Enhanced Hero Block [Volto](https://github.com/plone/volto) add-on
26
26
 
27
27
  This version requires: `@plone/volto >= 16.0.0.alpha.46` (schemaEnhancer / addStyling).
28
28
 
29
+ ### Upgrading to 6.x
30
+
31
+ Starting with version `6.0.0` we have the following breaking changes from version `5.x.x`:
32
+
33
+ 1. Removed inner `div` that was used to add `quoted-wrapper` class.
34
+ This `class` is now added on the main `div` alongside the other `block` options.
35
+ 2. Block is using `BlocksForm` to add more than one `Slate` blocks.
36
+ This is useful in case you have to add some sub titles or extra paragraphs inside the `Hero block`. The default `Slate` tag is still `h2` but you can change it using the rich text options toolbar.
37
+
38
+
29
39
  ## Getting started
30
40
 
31
41
  ### Try volto-hero-block with Docker
@@ -1,4 +1,4 @@
1
- require('dotenv').config({ path: __dirname + '/.env' })
1
+ require('dotenv').config({ path: __dirname + '/.env' });
2
2
 
3
3
  module.exports = {
4
4
  testMatch: ['**/src/addons/**/?(*.)+(spec|test).[jt]s?(x)'],
@@ -28,6 +28,7 @@ module.exports = {
28
28
  ],
29
29
  transform: {
30
30
  '^.+\\.js(x)?$': 'babel-jest',
31
+ '^.+\\.ts(x)?$': 'ts-jest',
31
32
  '^.+\\.(png)$': 'jest-file',
32
33
  '^.+\\.(jpg)$': 'jest-file',
33
34
  '^.+\\.(svg)$': './node_modules/@plone/volto/jest-svgsystem-transform.js',
@@ -45,4 +46,4 @@ module.exports = {
45
46
  '<rootDir>/node_modules/@eeacms/volto-hero-block/jest.setup.js',
46
47
  ],
47
48
  }),
48
- }
49
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-hero-block",
3
- "version": "5.5.0",
3
+ "version": "6.0.1",
4
4
  "description": "@eeacms/volto-hero-block: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: IDM2 A-Team",
@@ -30,7 +30,8 @@
30
30
  "dotenv": "^16.3.2",
31
31
  "husky": "^8.0.3",
32
32
  "lint-staged": "^14.0.1",
33
- "md5": "^2.3.0"
33
+ "md5": "^2.3.0",
34
+ "ts-jest": "^26.4.2"
34
35
  },
35
36
  "lint-staged": {
36
37
  "src/**/*.{js,jsx,ts,tsx,json}": [
@@ -1,23 +1,22 @@
1
- import React from 'react';
1
+ import React, { useState } from 'react';
2
2
  import cx from 'classnames';
3
3
  import isFunction from 'lodash/isFunction';
4
4
  import { Icon } from 'semantic-ui-react';
5
5
  import config from '@plone/volto/registry';
6
+ import { BlocksForm } from '@plone/volto/components';
7
+ import EditBlockWrapper from '@plone/volto/components/manage/Blocks/Block/EditBlockWrapper';
8
+ import { v4 as uuid } from 'uuid';
9
+ import '@eeacms/volto-hero-block/components/Blocks/Hero/edit.css';
10
+
11
+ import { isEmpty } from 'lodash';
6
12
  import {
7
13
  BlockDataForm,
8
14
  SidebarPortal,
9
15
  UniversalLink,
10
16
  } from '@plone/volto/components';
11
17
  import { BodyClass } from '@plone/volto/helpers';
12
- import SlateEditor from '@plone/volto-slate/editor/SlateEditor';
13
- import {
14
- handleKey,
15
- handleKeyDetached,
16
- } from '@plone/volto-slate/blocks/Text/keyboard';
17
- import {
18
- createSlateHeader,
19
- getFieldURL,
20
- } from '@eeacms/volto-hero-block/helpers';
18
+
19
+ import { getFieldURL } from '@eeacms/volto-hero-block/helpers';
21
20
  import { HeroBlockSchema } from './schema';
22
21
  import Copyright from './Copyright';
23
22
  import Hero from './Hero';
@@ -39,23 +38,21 @@ const Metadata = ({ buttonLabel, inverted, styles, ...props }) => {
39
38
  };
40
39
 
41
40
  export default function Edit(props) {
42
- const { slate } = config.settings;
41
+ const id = uuid();
42
+ const [selectedBlock, setSelectedBlock] = useState(id);
43
43
  const {
44
44
  data = {},
45
45
  block = null,
46
- selected = false,
47
- index,
46
+ selected,
48
47
  properties,
49
48
  onChangeBlock,
50
- onSelectBlock,
49
+ onChangeField,
50
+ pathname,
51
+ metadata = null,
52
+ setSidebarTab,
51
53
  } = props;
52
- const {
53
- text,
54
- copyright,
55
- copyrightIcon,
56
- copyrightPosition,
57
- isMultiline,
58
- } = data;
54
+ const { copyright, copyrightIcon, copyrightPosition } = data;
55
+
59
56
  const copyrightPrefix = config.blocks.blocksConfig.hero.copyrightPrefix || '';
60
57
  const schema = React.useMemo(() => {
61
58
  if (isFunction(HeroBlockSchema)) {
@@ -64,80 +61,120 @@ export default function Edit(props) {
64
61
  return HeroBlockSchema;
65
62
  }, [props]);
66
63
 
67
- const withBlockProperties = React.useCallback(
68
- (editor) => {
69
- editor.getBlockProps = () => props;
70
- return editor;
71
- },
72
- [props],
73
- );
64
+ const blockState = {};
65
+ const data_blocks = data?.data?.blocks;
74
66
 
75
- const handleFocus = React.useCallback(() => {
76
- if (!selected) {
77
- onSelectBlock(block);
78
- }
79
- }, [onSelectBlock, selected, block]);
67
+ if (data?.text || isEmpty(data_blocks)) {
68
+ let dataWithoutText = { ...data };
69
+ if (dataWithoutText) delete dataWithoutText.text;
80
70
 
81
- const extensions = React.useMemo(() => {
82
- if (isMultiline) {
83
- return slate.textblockExtensions.filter(
84
- (f) => f.name !== 'withSplitBlocksOnBreak',
85
- );
86
- } else {
87
- return slate.textblockExtensions;
88
- }
89
- }, [slate.textblockExtensions, isMultiline]);
90
-
91
- const value = createSlateHeader(text);
71
+ onChangeBlock(block, {
72
+ ...dataWithoutText,
73
+ data: data?.text
74
+ ? {
75
+ blocks: {
76
+ [id]: {
77
+ '@type': 'slate',
78
+ value: data.text,
79
+ plaintext: data.text?.[0].children?.[0].text,
80
+ },
81
+ },
82
+ blocks_layout: { items: [id] },
83
+ }
84
+ : {
85
+ blocks: {
86
+ [id]: {
87
+ '@type': 'slate',
88
+ value: [{ type: 'h2', children: [{ text: '' }] }],
89
+ plaintext: '',
90
+ },
91
+ },
92
+ blocks_layout: { items: [id] },
93
+ },
94
+ });
95
+ }
92
96
 
93
97
  return (
94
98
  <>
95
99
  <BodyClass className="with-hero-block" />
96
- <Hero {...data}>
97
- <Hero.Text {...data}>
98
- <SlateEditor
99
- key={isMultiline}
100
- detached={!isMultiline}
101
- index={index}
102
- properties={properties}
103
- extensions={extensions}
104
- renderExtensions={[withBlockProperties]}
105
- value={value}
106
- onChange={(text) => {
107
- onChangeBlock(block, {
108
- ...data,
109
- text,
110
- });
111
- }}
112
- block={block}
113
- onFocus={handleFocus}
114
- onKeyDown={isMultiline ? handleKeyDetached : handleKey}
115
- selected={selected}
116
- placeholder="Add text..."
117
- slateSettings={slate}
118
- />
119
- </Hero.Text>
120
- <Hero.Meta {...data}>
121
- <Metadata {...data} />
122
- </Hero.Meta>
123
- {copyright ? (
124
- <Copyright copyrightPosition={copyrightPosition}>
125
- <Copyright.Prefix>{copyrightPrefix}</Copyright.Prefix>
126
- <Copyright.Icon>
127
- <Icon className={copyrightIcon} />
128
- </Copyright.Icon>
129
- <Copyright.Text>{copyright}</Copyright.Text>
130
- </Copyright>
131
- ) : (
132
- ''
133
- )}
134
- </Hero>
135
-
100
+ <div
101
+ className="hero-edit-wrapper"
102
+ role="presentation"
103
+ onClick={(e) => {
104
+ const className = e.target.getAttribute('class');
105
+ if (className && className.includes('hero')) {
106
+ setSelectedBlock(id);
107
+ setSidebarTab(1);
108
+ }
109
+ }}
110
+ >
111
+ <Hero {...data}>
112
+ <Hero.Text {...data}>
113
+ <BlocksForm
114
+ metadata={properties || metadata}
115
+ properties={data.data || {}}
116
+ manage={false}
117
+ allowedBlocks={'slate'}
118
+ selectedBlock={selectedBlock}
119
+ title={data.placeholder}
120
+ onSelectBlock={(s, e) => {
121
+ setSelectedBlock(s);
122
+ }}
123
+ onChangeFormData={(newFormData) => {
124
+ onChangeBlock(block, {
125
+ ...data,
126
+ data: newFormData,
127
+ });
128
+ }}
129
+ onChangeField={(id, value) => {
130
+ if (['blocks', 'blocks_layout'].indexOf(id) > -1) {
131
+ blockState[id] = value;
132
+ onChangeBlock(block, {
133
+ ...data,
134
+ data: {
135
+ ...data.data,
136
+ ...blockState,
137
+ },
138
+ });
139
+ } else {
140
+ onChangeField(id, value);
141
+ }
142
+ }}
143
+ pathname={pathname}
144
+ >
145
+ {({ draginfo }, editBlock, blockProps) => (
146
+ <EditBlockWrapper
147
+ draginfo={draginfo}
148
+ blockProps={blockProps}
149
+ disabled={data.disableInnerButtons}
150
+ >
151
+ {editBlock}
152
+ </EditBlockWrapper>
153
+ )}
154
+ </BlocksForm>
155
+ </Hero.Text>
156
+ <Hero.Meta {...data}>
157
+ <Metadata {...data} />
158
+ </Hero.Meta>
159
+ {copyright ? (
160
+ <Copyright copyrightPosition={copyrightPosition}>
161
+ <Copyright.Prefix>{copyrightPrefix}</Copyright.Prefix>
162
+ <Copyright.Icon>
163
+ <Icon className={copyrightIcon} />
164
+ </Copyright.Icon>
165
+ <Copyright.Text>{copyright}</Copyright.Text>
166
+ </Copyright>
167
+ ) : (
168
+ ''
169
+ )}
170
+ </Hero>
171
+ </div>
136
172
  <SidebarPortal selected={selected}>
137
173
  <BlockDataForm
138
174
  block={block}
139
175
  schema={schema}
140
176
  title={schema.title}
177
+ onChangeBlock={props.onChangeBlock}
141
178
  onChangeField={(id, value) => {
142
179
  onChangeBlock(block, {
143
180
  ...data,
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { render, fireEvent } from '@testing-library/react';
2
+ import { render } from '@testing-library/react';
3
3
  import { Provider } from 'react-redux';
4
4
  import configureStore from 'redux-mock-store';
5
5
  import Edit from './Edit';
@@ -7,25 +7,33 @@ import config from '@plone/volto/registry';
7
7
  import '@testing-library/jest-dom/extend-expect';
8
8
 
9
9
  const mockStore = configureStore([]);
10
-
11
- jest.mock('@plone/volto-slate/editor/SlateEditor', () => {
10
+ const observe = jest.fn();
11
+ const unobserve = jest.fn();
12
+ jest.mock('@plone/volto/components', () => {
12
13
  return {
13
14
  __esModule: true,
14
- default: ({ placeholder, children, onChange, onFocus }) => (
15
- <div
16
- onChange={(target) => onChange(target)}
17
- onFocus={() => onFocus()}
18
- id="test"
19
- >
15
+ BlocksForm: ({ placeholder, children, onChange, onFocus }) => (
16
+ <div id="test">
20
17
  <div>{placeholder}</div>
21
18
  {children}
22
19
  </div>
23
20
  ),
21
+ SidebarPortal: ({ children }) => <div>{children}</div>,
22
+ BlockDataForm: () => <div></div>,
23
+ UniversalLink: () => <div></div>,
24
+ RenderBlocks: () => <div></div>,
24
25
  };
25
26
  });
27
+ jest.mock('react-router-dom', () => ({
28
+ useLocation: jest.fn().mockReturnValue({
29
+ pathname: '/test-jest',
30
+ search: '',
31
+ hash: '',
32
+ state: null,
33
+ key: 'test-jest',
34
+ }),
35
+ }));
26
36
 
27
- const observe = jest.fn();
28
- const unobserve = jest.fn();
29
37
  window.IntersectionObserver = jest.fn((callback) => ({
30
38
  observe,
31
39
  unobserve,
@@ -60,7 +68,7 @@ describe('Edit component', () => {
60
68
  it('renders without crashing', () => {
61
69
  const { container } = render(
62
70
  <Provider store={store}>
63
- <Edit />
71
+ <Edit onChangeBlock={() => {}} onSelectBlock={() => {}} />
64
72
  </Provider>,
65
73
  );
66
74
  expect(container).toBeTruthy();
@@ -82,35 +90,13 @@ describe('Edit component', () => {
82
90
 
83
91
  const { container } = render(
84
92
  <Provider store={store}>
85
- <Edit data={data} />
93
+ <Edit data={data} onChangeBlock={() => {}} />
86
94
  </Provider>,
87
95
  );
88
96
 
89
97
  expect(container.querySelector('#test')).toBeInTheDocument();
90
98
  });
91
99
 
92
- it('calls onFocus when SlateEditor is focused', () => {
93
- config.blocks = {
94
- blocksConfig: {
95
- hero: {
96
- copyrightPrefix: 'Test Prefix',
97
- schema: () => ({
98
- title: 'Hero',
99
- }),
100
- },
101
- },
102
- };
103
- const onSelectBlock = jest.fn();
104
- const { getByText } = render(
105
- <Provider store={store}>
106
- <Edit onSelectBlock={onSelectBlock} />
107
- </Provider>,
108
- );
109
-
110
- fireEvent.focus(getByText('Add text...'));
111
- expect(onSelectBlock).toHaveBeenCalled();
112
- });
113
-
114
100
  it('renders without copyrightPrefix', () => {
115
101
  config.blocks = {
116
102
  blocksConfig: {
@@ -124,7 +110,7 @@ describe('Edit component', () => {
124
110
  const onSelectBlock = jest.fn();
125
111
  render(
126
112
  <Provider store={store}>
127
- <Edit onSelectBlock={onSelectBlock} />
113
+ <Edit onSelectBlock={onSelectBlock} onChangeBlock={() => {}} />
128
114
  </Provider>,
129
115
  );
130
116
  });
@@ -35,6 +35,7 @@ function Hero({
35
35
 
36
36
  const bgImgRef = React.useRef();
37
37
  const onScreen = useFirstVisited(bgImgRef);
38
+
38
39
  return (
39
40
  <div
40
41
  className={cx(
@@ -101,9 +102,10 @@ Hero.Text = ({ children, quoted, styles }) => {
101
102
  'hero-block-text',
102
103
  `color-fg-${textVariant}`,
103
104
  `text-${textAlign}`,
105
+ quoted ? 'quoted-wrapper' : '',
104
106
  )}
105
107
  >
106
- <div className={quoted ? 'quoted-wrapper' : ''}>{children}</div>
108
+ {children}
107
109
  </div>
108
110
  );
109
111
  };
@@ -1,8 +1,9 @@
1
1
  import React from 'react';
2
2
  import cx from 'classnames';
3
3
  import { Icon } from 'semantic-ui-react';
4
- import { UniversalLink } from '@plone/volto/components';
4
+ import { UniversalLink, RenderBlocks } from '@plone/volto/components';
5
5
  import { BodyClass } from '@plone/volto/helpers';
6
+ import { useLocation } from 'react-router-dom';
6
7
  import Hero from './Hero';
7
8
  import Copyright from './Copyright';
8
9
  import { serializeText, getFieldURL } from '@eeacms/volto-hero-block/helpers';
@@ -25,14 +26,27 @@ const Metadata = ({ buttonLabel, inverted, styles, ...props }) => {
25
26
  };
26
27
 
27
28
  const View = (props) => {
29
+ const location = useLocation();
28
30
  const { data = {} } = props;
29
31
  const { text, copyright, copyrightIcon, copyrightPosition } = data;
32
+
33
+ const metadata = props.metadata || props.properties;
30
34
  const copyrightPrefix = config.blocks.blocksConfig.hero.copyrightPrefix || '';
31
35
  return (
32
36
  <React.Fragment>
33
37
  <BodyClass className="with-hero-block" />
34
38
  <Hero {...data}>
35
- <Hero.Text {...data}>{serializeText(text)}</Hero.Text>
39
+ <Hero.Text {...data}>
40
+ {data?.data ? (
41
+ <RenderBlocks
42
+ location={location}
43
+ metadata={metadata}
44
+ content={data?.data || {}}
45
+ />
46
+ ) : (
47
+ serializeText(text)
48
+ )}
49
+ </Hero.Text>
36
50
  <Hero.Meta {...data}>
37
51
  <Metadata {...data} />
38
52
  </Hero.Meta>
@@ -9,7 +9,30 @@ window.IntersectionObserver = jest.fn((callback) => ({
9
9
  observe,
10
10
  unobserve,
11
11
  }));
12
-
12
+ jest.mock('@plone/volto/components', () => {
13
+ return {
14
+ __esModule: true,
15
+ BlocksForm: ({ placeholder, children, onChange, onFocus }) => (
16
+ <div id="test">
17
+ <div>{placeholder}</div>
18
+ {children}
19
+ </div>
20
+ ),
21
+ SidebarPortal: ({ children }) => <div>{children}</div>,
22
+ BlockDataForm: () => <div></div>,
23
+ UniversalLink: () => <div></div>,
24
+ RenderBlocks: () => <div></div>,
25
+ };
26
+ });
27
+ jest.mock('react-router-dom', () => ({
28
+ useLocation: jest.fn().mockReturnValue({
29
+ pathname: '/test-jest',
30
+ search: '',
31
+ hash: '',
32
+ state: null,
33
+ key: 'test-jest',
34
+ }),
35
+ }));
13
36
  describe('View Component', () => {
14
37
  it('renders view component', () => {
15
38
  config.blocks = {
@@ -0,0 +1,5 @@
1
+ .hero-block .block-add-button,
2
+ .hero-block .drag.handle.wrapper,
3
+ .hero-block .block-editor-slate:first-of-type .delete-button {
4
+ display: none !important;
5
+ }
@@ -22,7 +22,7 @@ const intl = createIntl(
22
22
  cache,
23
23
  );
24
24
 
25
- export default (config) => {
25
+ const applyConfig = (config) => {
26
26
  config.blocks.blocksConfig.hero = {
27
27
  id: 'hero',
28
28
  title: 'Hero',
@@ -50,3 +50,5 @@ export default (config) => {
50
50
 
51
51
  return config;
52
52
  };
53
+
54
+ export default applyConfig;
@@ -26,7 +26,6 @@ export const HeroBlockSchema = () => {
26
26
  'quoted',
27
27
  'spaced',
28
28
  'inverted',
29
- 'isMultiline',
30
29
  'buttonLabel',
31
30
  'buttonLink',
32
31
  'overlay',
@@ -65,11 +64,6 @@ export const HeroBlockSchema = () => {
65
64
  type: 'boolean',
66
65
  defaultValue: true,
67
66
  },
68
- isMultiline: {
69
- title: 'Multiline',
70
- type: 'boolean',
71
- defaultValue: false,
72
- },
73
67
  buttonLabel: {
74
68
  title: 'Button label',
75
69
  widget: 'textarea',