@eeacms/volto-hero-block 5.4.6 → 6.0.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/.eslintrc.js +65 -0
- package/CHANGELOG.md +50 -25
- package/README.md +10 -0
- package/jest-addon.config.js +16 -3
- package/jest.setup.js +65 -0
- package/package.json +3 -1
- package/src/components/Blocks/Hero/Edit.jsx +124 -86
- package/src/components/Blocks/Hero/Edit.test.jsx +22 -36
- package/src/components/Blocks/Hero/Hero.jsx +3 -1
- package/src/components/Blocks/Hero/View.jsx +16 -2
- package/src/components/Blocks/Hero/View.test.jsx +24 -1
- package/src/components/Blocks/Hero/edit.css +5 -0
- package/src/components/Blocks/Hero/index.js +3 -1
- package/src/components/Blocks/Hero/schema.js +1 -5
- package/.project.eslintrc.js +0 -48
package/.eslintrc.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const projectRootPath = fs.realpathSync(__dirname + '/../../../');
|
|
4
|
+
|
|
5
|
+
let voltoPath = path.join(projectRootPath, 'node_modules/@plone/volto');
|
|
6
|
+
let configFile;
|
|
7
|
+
if (fs.existsSync(`${projectRootPath}/tsconfig.json`))
|
|
8
|
+
configFile = `${projectRootPath}/tsconfig.json`;
|
|
9
|
+
else if (fs.existsSync(`${projectRootPath}/jsconfig.json`))
|
|
10
|
+
configFile = `${projectRootPath}/jsconfig.json`;
|
|
11
|
+
|
|
12
|
+
if (configFile) {
|
|
13
|
+
const jsConfig = require(configFile).compilerOptions;
|
|
14
|
+
const pathsConfig = jsConfig.paths;
|
|
15
|
+
if (pathsConfig['@plone/volto'])
|
|
16
|
+
voltoPath = `./${jsConfig.baseUrl}/${pathsConfig['@plone/volto'][0]}`;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const AddonConfigurationRegistry = require(`${voltoPath}/addon-registry.js`);
|
|
20
|
+
const reg = new AddonConfigurationRegistry(projectRootPath);
|
|
21
|
+
|
|
22
|
+
// Extends ESlint configuration for adding the aliases to `src` directories in Volto addons
|
|
23
|
+
const addonAliases = Object.keys(reg.packages).map((o) => [
|
|
24
|
+
o,
|
|
25
|
+
reg.packages[o].modulePath,
|
|
26
|
+
]);
|
|
27
|
+
|
|
28
|
+
const addonExtenders = reg.getEslintExtenders().map((m) => require(m));
|
|
29
|
+
|
|
30
|
+
const defaultConfig = {
|
|
31
|
+
extends: `${voltoPath}/.eslintrc`,
|
|
32
|
+
settings: {
|
|
33
|
+
'import/resolver': {
|
|
34
|
+
alias: {
|
|
35
|
+
map: [
|
|
36
|
+
['@plone/volto', '@plone/volto/src'],
|
|
37
|
+
['@plone/volto-slate', '@plone/volto/packages/volto-slate/src'],
|
|
38
|
+
...addonAliases,
|
|
39
|
+
['@package', `${__dirname}/src`],
|
|
40
|
+
['@root', `${__dirname}/src`],
|
|
41
|
+
['~', `${__dirname}/src`],
|
|
42
|
+
],
|
|
43
|
+
extensions: ['.js', '.jsx', '.json'],
|
|
44
|
+
},
|
|
45
|
+
'babel-plugin-root-import': {
|
|
46
|
+
rootPathSuffix: 'src',
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
rules: {
|
|
51
|
+
'react/jsx-no-target-blank': [
|
|
52
|
+
'error',
|
|
53
|
+
{
|
|
54
|
+
allowReferrer: true,
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const config = addonExtenders.reduce(
|
|
61
|
+
(acc, extender) => extender.modify(acc),
|
|
62
|
+
defaultConfig,
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
module.exports = config;
|
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,56 @@ 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.0](https://github.com/eea/volto-hero-block/compare/5.5.0...6.0.0) - 4 April 2024
|
|
8
|
+
|
|
9
|
+
#### :boom: Breaking Change
|
|
10
|
+
|
|
11
|
+
- 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)]
|
|
12
|
+
- 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)]
|
|
13
|
+
|
|
14
|
+
#### :nail_care: Enhancements
|
|
15
|
+
|
|
16
|
+
- change(hero): Use EditBlockWrapper from Volto core [David Ichim - [`360d2d7`](https://github.com/eea/volto-hero-block/commit/360d2d7e0f0240dd089839cc2ec62a691bcf41e2)]
|
|
17
|
+
|
|
18
|
+
#### :hammer_and_wrench: Others
|
|
19
|
+
|
|
20
|
+
- 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)]
|
|
21
|
+
- Add ts-jest package to package.json [David Ichim - [`7c82b62`](https://github.com/eea/volto-hero-block/commit/7c82b626985bfdabcf10db6da159c13fa86b27e2)]
|
|
22
|
+
- 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)]
|
|
23
|
+
- 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)]
|
|
24
|
+
- fix intial value slate [dobri1408 - [`c70bb80`](https://github.com/eea/volto-hero-block/commit/c70bb80a8c60a710cba02d7afbe069ad1b2e4fa2)]
|
|
25
|
+
- 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)]
|
|
26
|
+
- switch to block sidebar when clicking on the hero block in edit [David Ichim - [`1797077`](https://github.com/eea/volto-hero-block/commit/1797077bcbe9001e24c382d4e534b150683acb9c)]
|
|
27
|
+
- fix eslint [dobri1408 - [`7b0a66c`](https://github.com/eea/volto-hero-block/commit/7b0a66cfb0157787b69ae9c80326b9d9e7a06227)]
|
|
28
|
+
- fix eslint [dobri1408 - [`163af98`](https://github.com/eea/volto-hero-block/commit/163af98415a702361c044531e8f13e8e034972ef)]
|
|
29
|
+
- fix eslint comments [dobri1408 - [`0fff8b0`](https://github.com/eea/volto-hero-block/commit/0fff8b07f4375cf8809fe3575ea6bf913aec0c0c)]
|
|
30
|
+
- fix eslint [dobri1408 - [`d560dcb`](https://github.com/eea/volto-hero-block/commit/d560dcb580755767d43d7848f182b420552c1894)]
|
|
31
|
+
- improve the quality [dobri1408 - [`d6bf215`](https://github.com/eea/volto-hero-block/commit/d6bf21563f6e1e423f1c730f5e5409cfc724c240)]
|
|
32
|
+
- Update Edit.jsx [dobri1408 - [`2c31ecd`](https://github.com/eea/volto-hero-block/commit/2c31ecd5fd896e5f0a43f4a689dbb60a36c39431)]
|
|
33
|
+
- fix cypress test [dobri1408 - [`c24f627`](https://github.com/eea/volto-hero-block/commit/c24f627de259623cf27cdcde703667d4e510ce8b)]
|
|
34
|
+
- fix unit tests [dobri1408 - [`ad6e98f`](https://github.com/eea/volto-hero-block/commit/ad6e98fe433f815a692139d5a06f669c485422ad)]
|
|
35
|
+
- fix unit tests [dobri1408 - [`7c007a6`](https://github.com/eea/volto-hero-block/commit/7c007a63c4a14a9230a4e59a3877e9494a241656)]
|
|
36
|
+
- trigger tests [dobri1408 - [`0f51440`](https://github.com/eea/volto-hero-block/commit/0f514401ccd93e90053009427735acc9d8ef4ef7)]
|
|
37
|
+
- mock react-router-dom [dobri1408 - [`f6a33ab`](https://github.com/eea/volto-hero-block/commit/f6a33ab4142fe25f890d186f09162d3c6ea8c68d)]
|
|
38
|
+
- fix eslint [dobri1408 - [`89483de`](https://github.com/eea/volto-hero-block/commit/89483dee93c172e14b8a89e71bd112a27d3d5a90)]
|
|
39
|
+
- fi problems with the bacward compatibility [dobri1408 - [`5915149`](https://github.com/eea/volto-hero-block/commit/59151498b7601f2e1de959916cee504b702c9cb1)]
|
|
40
|
+
- use blockform and renderblocks [dobri1408 - [`61994d0`](https://github.com/eea/volto-hero-block/commit/61994d0044e212e89dbec1ac25f13a56b42f8f82)]
|
|
41
|
+
- fix multiline hero bug [dobri1408 - [`25b26d5`](https://github.com/eea/volto-hero-block/commit/25b26d562121b59ff5120ea8caefaab014885889)]
|
|
42
|
+
### [5.5.0](https://github.com/eea/volto-hero-block/compare/5.4.6...5.5.0) - 19 February 2024
|
|
43
|
+
|
|
44
|
+
#### :house: Internal changes
|
|
45
|
+
|
|
46
|
+
- chore: package.json [Alin Voinea - [`3e83746`](https://github.com/eea/volto-hero-block/commit/3e8374664edaf5847c7290cf63b648c5b2d3e716)]
|
|
47
|
+
|
|
48
|
+
#### :hammer_and_wrench: Others
|
|
49
|
+
|
|
50
|
+
- Release 5.5.0 [alin - [`a81f788`](https://github.com/eea/volto-hero-block/commit/a81f788f54102a770b5e50cf5d7cfc6506278adf)]
|
|
51
|
+
- Don't need this as props, they're not passed to the editor, don't lie about this [Tiberiu Ichim - [`cc434c5`](https://github.com/eea/volto-hero-block/commit/cc434c5764a53a238e53f9be693af432af854ec5)]
|
|
52
|
+
- test: fix eslint errors [kreafox - [`5dd4d30`](https://github.com/eea/volto-hero-block/commit/5dd4d3071a68c0240f9f2c9defea0959621a275e)]
|
|
53
|
+
- Allow multiline editing of hero block [Tiberiu Ichim - [`373d1a0`](https://github.com/eea/volto-hero-block/commit/373d1a0d243b8e0b3df31f2a51a3c5df62f48214)]
|
|
54
|
+
- Allow multiline editing of hero block [Tiberiu Ichim - [`b674ca5`](https://github.com/eea/volto-hero-block/commit/b674ca589502a81aaf6abed75dbf8b83ac1731fb)]
|
|
55
|
+
- fix ESlint [Teodor - [`1439495`](https://github.com/eea/volto-hero-block/commit/14394952ef587f71be8b2c762c7e19698d8a55e4)]
|
|
56
|
+
- test: Update jest,Jenkinsfile,lint to volto-addons-template PR30 [valentinab25 - [`de6a206`](https://github.com/eea/volto-hero-block/commit/de6a206bed9afd53d97f5e6d70e2391ccc01f0f1)]
|
|
7
57
|
### [5.4.6](https://github.com/eea/volto-hero-block/compare/5.4.5...5.4.6) - 27 November 2023
|
|
8
58
|
|
|
9
59
|
#### :rocket: New Features
|
|
@@ -16,16 +66,9 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
16
66
|
|
|
17
67
|
#### :house: Internal changes
|
|
18
68
|
|
|
19
|
-
- chore: [JENKINS] Refactor automated testing [valentinab25 - [`df8242c`](https://github.com/eea/volto-hero-block/commit/df8242c62eb8c706c3854f6bb4a6984932463571)]
|
|
20
69
|
|
|
21
70
|
#### :hammer_and_wrench: Others
|
|
22
71
|
|
|
23
|
-
- test: [JENKINS] Use java17 for sonarqube scanner [valentinab25 - [`4ea90f6`](https://github.com/eea/volto-hero-block/commit/4ea90f6a23c92fe631ee6025dbe5ee27ec030665)]
|
|
24
|
-
- test: [JENKINS] Run cypress in started frontend container [valentinab25 - [`6e9d7f5`](https://github.com/eea/volto-hero-block/commit/6e9d7f593363e08f519ab8296aef229ed2682113)]
|
|
25
|
-
- test: [JENKINS] Add cpu limit on cypress docker [valentinab25 - [`067fa27`](https://github.com/eea/volto-hero-block/commit/067fa27ee26d1d348d5ce1b089ea9931d9f32589)]
|
|
26
|
-
- test: [JENKINS] Increase shm-size to cypress docker [valentinab25 - [`0f6a259`](https://github.com/eea/volto-hero-block/commit/0f6a259fc73db97a7a8af69a808421191b146629)]
|
|
27
|
-
- test: [JENKINS] Improve cypress time [valentinab25 - [`c1c72f4`](https://github.com/eea/volto-hero-block/commit/c1c72f4b54a84521f200682b230bba60e6920a70)]
|
|
28
|
-
- Add Sonarqube tag using clms-frontend addons list [EEA Jenkins - [`65744c9`](https://github.com/eea/volto-hero-block/commit/65744c9b2b0944d2aff90fc56485f10390810d1c)]
|
|
29
72
|
### [5.4.5](https://github.com/eea/volto-hero-block/compare/5.4.4...5.4.5) - 19 October 2023
|
|
30
73
|
|
|
31
74
|
### [5.4.4](https://github.com/eea/volto-hero-block/compare/5.4.3...5.4.4) - 19 October 2023
|
|
@@ -65,14 +108,12 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
65
108
|
- test: add unit tests for Hero, Edit, helpers, hooks - refs #254313 [ana-oprea - [`89b39af`](https://github.com/eea/volto-hero-block/commit/89b39afe7ad5ce94d341482be91ab55e2c1a31ed)]
|
|
66
109
|
- i18n: Add en [Alin Voinea - [`9cdb7f1`](https://github.com/eea/volto-hero-block/commit/9cdb7f1ff9d81dade3d91551b53cf7200f08937e)]
|
|
67
110
|
- test: Update Makefile and docker-compose to align it with Jenkinsfile [valentinab25 - [`0fe0d91`](https://github.com/eea/volto-hero-block/commit/0fe0d91fe9c43d10574990e9b163ffc49fe5bee7)]
|
|
68
|
-
- Add Sonarqube tag using freshwater-frontend addons list [EEA Jenkins - [`b1d1446`](https://github.com/eea/volto-hero-block/commit/b1d14467bcde28023b2831235928db1f328d6b0a)]
|
|
69
111
|
### [5.4.1](https://github.com/eea/volto-hero-block/compare/5.4.0...5.4.1) - 24 July 2023
|
|
70
112
|
|
|
71
113
|
### [5.4.0](https://github.com/eea/volto-hero-block/compare/5.3.1...5.4.0) - 12 June 2023
|
|
72
114
|
|
|
73
115
|
#### :house: Internal changes
|
|
74
116
|
|
|
75
|
-
- chore: [JENKINS] Deprecate circularity website [valentinab25 - [`395db48`](https://github.com/eea/volto-hero-block/commit/395db484f73c2dd2c56233c120a9620340f17d0b)]
|
|
76
117
|
|
|
77
118
|
#### :hammer_and_wrench: Others
|
|
78
119
|
|
|
@@ -93,7 +134,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
93
134
|
- put return statement [Dobricean Ioan Dorian - [`8eff5fd`](https://github.com/eea/volto-hero-block/commit/8eff5fdf977fcbb8cc952d3f45b577b02ca59cb9)]
|
|
94
135
|
- change name and refactor to be more efficent [Dobricean Ioan Dorian - [`ff24145`](https://github.com/eea/volto-hero-block/commit/ff2414542833998ef282376de3fbda8698287849)]
|
|
95
136
|
- stop-image-disappear over and over [Dobricean Ioan Dorian - [`c5b6f54`](https://github.com/eea/volto-hero-block/commit/c5b6f545ac422d95b8d802349aa4cf27af820829)]
|
|
96
|
-
- Add Sonarqube tag using industry-frontend addons list [EEA Jenkins - [`3d38dd0`](https://github.com/eea/volto-hero-block/commit/3d38dd09a36525bda448f67a6d218bc7690a4cc3)]
|
|
97
137
|
### [5.3.0](https://github.com/eea/volto-hero-block/compare/5.2.0...5.3.0) - 27 March 2023
|
|
98
138
|
|
|
99
139
|
#### :rocket: New Features
|
|
@@ -132,11 +172,9 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
132
172
|
- fix onScreen hook error #16 from eea/fix-onscreen-hook [ichim-david - [`9123541`](https://github.com/eea/volto-hero-block/commit/91235413f423d7e6c4788d70b687b3ed5d4884b4)]
|
|
133
173
|
- no need for comments [andreiggr - [`a14f9c3`](https://github.com/eea/volto-hero-block/commit/a14f9c3bdddfa22e6b4bbc8318f0ca5bdc9c2d38)]
|
|
134
174
|
- fix hook [andreiggr - [`f7fae73`](https://github.com/eea/volto-hero-block/commit/f7fae73007f79af2f06da1d9b72a53ad86fef4ac)]
|
|
135
|
-
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`6b78fc0`](https://github.com/eea/volto-hero-block/commit/6b78fc044a933ab9b4b4694901aa26628ef0a836)]
|
|
136
175
|
- eslint [andreiggr - [`68451b7`](https://github.com/eea/volto-hero-block/commit/68451b725420015fbd5b695e97b8742988d49913)]
|
|
137
176
|
- lazy load huge img on first 10px [andreiggr - [`67dc7d3`](https://github.com/eea/volto-hero-block/commit/67dc7d3475188d692e053032c2639dd1a585c029)]
|
|
138
177
|
- lazy load huge bgimage wip [andreiggr - [`86e45ec`](https://github.com/eea/volto-hero-block/commit/86e45ece842f1cd7452920dffa3a9b4aea945f56)]
|
|
139
|
-
- Add Sonarqube tag using ims-frontend addons list [EEA Jenkins - [`87cbb38`](https://github.com/eea/volto-hero-block/commit/87cbb383290a168f85703573670e17f4e1ed7747)]
|
|
140
178
|
## [4.0.0](https://github.com/eea/volto-hero-block/compare/3.0.1...4.0.0) - 7 February 2023
|
|
141
179
|
|
|
142
180
|
#### :nail_care: Enhancements
|
|
@@ -162,7 +200,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
162
200
|
|
|
163
201
|
#### :hammer_and_wrench: Others
|
|
164
202
|
|
|
165
|
-
- Add Sonarqube tag using advisory-board-frontend addons list [EEA Jenkins - [`ab85c7b`](https://github.com/eea/volto-hero-block/commit/ab85c7bd5bd1e3aec95e02f9b4d026b1203d5739)]
|
|
166
203
|
## [3.0.0](https://github.com/eea/volto-hero-block/compare/2.1.0...3.0.0) - 22 December 2022
|
|
167
204
|
|
|
168
205
|
#### :rocket: New Features
|
|
@@ -171,11 +208,8 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
171
208
|
|
|
172
209
|
#### :hammer_and_wrench: Others
|
|
173
210
|
|
|
174
|
-
- Add Sonarqube tag using advisory-board-frontend addons list [EEA Jenkins - [`f06f58c`](https://github.com/eea/volto-hero-block/commit/f06f58c7cd4cfc15a03208e9c7a4e31fe2eba2f6)]
|
|
175
|
-
- Add Sonarqube tag using climate-energy-frontend addons list [EEA Jenkins - [`20e5bcb`](https://github.com/eea/volto-hero-block/commit/20e5bcb3c4dd538595741928319c3204c5d18f8c)]
|
|
176
211
|
- Cosmetics [Alin Voinea - [`9dac70c`](https://github.com/eea/volto-hero-block/commit/9dac70c0a3bea8e188ede9123f4f99de8e0f6987)]
|
|
177
212
|
- test(Jenkins): Run tests and cypress with latest canary @plone/volto [Alin Voinea - [`2d4005f`](https://github.com/eea/volto-hero-block/commit/2d4005f0f31b121e1b7d2e94414f3dff92ec1a16)]
|
|
178
|
-
- Add Sonarqube tag using cca-frontend addons list [EEA Jenkins - [`2931fcc`](https://github.com/eea/volto-hero-block/commit/2931fccbee5f8e117e5ae9095ba57e63e465ddb3)]
|
|
179
213
|
### [2.1.0](https://github.com/eea/volto-hero-block/compare/2.0.0...2.1.0) - 12 December 2022
|
|
180
214
|
|
|
181
215
|
#### :bug: Bug Fixes
|
|
@@ -184,12 +218,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
184
218
|
|
|
185
219
|
#### :hammer_and_wrench: Others
|
|
186
220
|
|
|
187
|
-
- Add Sonarqube tag using bise-frontend addons list [EEA Jenkins - [`93be4f9`](https://github.com/eea/volto-hero-block/commit/93be4f96fb72cacfc25f9b058cb379d80060ee13)]
|
|
188
|
-
- yarn 3 [Alin Voinea - [`8e2dccd`](https://github.com/eea/volto-hero-block/commit/8e2dccd47cbef3c0871407baa376ce61c540c754)]
|
|
189
|
-
- Add Sonarqube tag using marine-frontend addons list [EEA Jenkins - [`6bc3af3`](https://github.com/eea/volto-hero-block/commit/6bc3af35b4edf07971d1b0ce1648965e8d6e3bc0)]
|
|
190
|
-
- Add Sonarqube tag using clms-frontend addons list [EEA Jenkins - [`d7dbbd2`](https://github.com/eea/volto-hero-block/commit/d7dbbd21277dd76bf59d91a4dc8e022b2a6ff99c)]
|
|
191
|
-
- Add Sonarqube tag using demo-kitkat-frontend addons list [EEA Jenkins - [`3c1f0d6`](https://github.com/eea/volto-hero-block/commit/3c1f0d6e7f8e5318aee3413ec3687d8492376f9d)]
|
|
192
|
-
- Add Sonarqube tag using forests-frontend addons list [EEA Jenkins - [`843017a`](https://github.com/eea/volto-hero-block/commit/843017aa7dbea71cc7888663496e352d287440b4)]
|
|
193
221
|
## [2.0.0](https://github.com/eea/volto-hero-block/compare/1.0.0...2.0.0) - 16 November 2022
|
|
194
222
|
|
|
195
223
|
#### :nail_care: Enhancements
|
|
@@ -199,7 +227,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
199
227
|
#### :hammer_and_wrench: Others
|
|
200
228
|
|
|
201
229
|
- test(estlint): Fix .project.eslintrc.js [Alin Voinea - [`b8f0971`](https://github.com/eea/volto-hero-block/commit/b8f0971b21a5334d40c1b8f5103cea61d9ffe6f1)]
|
|
202
|
-
- Add Sonarqube tag using circularity-frontend addons list [EEA Jenkins - [`581dedf`](https://github.com/eea/volto-hero-block/commit/581dedf07410ef2ca09e6ddaa05fbf176400adbb)]
|
|
203
230
|
## [1.0.0](https://github.com/eea/volto-hero-block/compare/0.2.0...1.0.0) - 28 October 2022
|
|
204
231
|
|
|
205
232
|
#### :nail_care: Enhancements
|
|
@@ -211,7 +238,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
211
238
|
- Remove cypress.json [Alin Voinea - [`593bdf2`](https://github.com/eea/volto-hero-block/commit/593bdf207ca4fd3f2393117b6f64a44727881ad0)]
|
|
212
239
|
- test(cypress): Upgrade to Cypress 10 / Razzle 4 [Alin Voinea - [`edd48a5`](https://github.com/eea/volto-hero-block/commit/edd48a5c13824bce5e03e46790f1890656b340d8)]
|
|
213
240
|
- Cleanup [Alin Voinea - [`9d72ee7`](https://github.com/eea/volto-hero-block/commit/9d72ee7a06d1c6fed46586d30bb85eae39e670bf)]
|
|
214
|
-
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`95986d0`](https://github.com/eea/volto-hero-block/commit/95986d0b8fd5c3cbb9e6da9059f71e066a8e171b)]
|
|
215
241
|
### [0.2.0](https://github.com/eea/volto-hero-block/compare/0.1.4...0.2.0) - 6 July 2022
|
|
216
242
|
|
|
217
243
|
#### :bug: Bug Fixes
|
|
@@ -250,7 +276,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
250
276
|
- Update slate footnote support [Miu Razvan - [`c1522b4`](https://github.com/eea/volto-hero-block/commit/c1522b4164dbe6de01771d211d7e0bf3009f44d4)]
|
|
251
277
|
- Use justify content for text and button as well [Miu Razvan - [`08599cc`](https://github.com/eea/volto-hero-block/commit/08599cc45546d9b349128c4f8ce9c01318385811)]
|
|
252
278
|
- Add dependencies [Miu Razvan - [`30e2881`](https://github.com/eea/volto-hero-block/commit/30e2881a2a97a899e7f4cc614a0405c300ac6fee)]
|
|
253
|
-
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`b415422`](https://github.com/eea/volto-hero-block/commit/b41542285edd29440a324b101a4dbae9334830bf)]
|
|
254
279
|
### 0.1.0 - 10 June 2022
|
|
255
280
|
|
|
256
281
|
#### :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
|
package/jest-addon.config.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
require('dotenv').config({ path: __dirname + '/.env' });
|
|
2
|
+
|
|
1
3
|
module.exports = {
|
|
2
4
|
testMatch: ['**/src/addons/**/?(*.)+(spec|test).[jt]s?(x)'],
|
|
3
5
|
collectCoverageFrom: [
|
|
@@ -9,18 +11,24 @@ module.exports = {
|
|
|
9
11
|
'@plone/volto/cypress': '<rootDir>/node_modules/@plone/volto/cypress',
|
|
10
12
|
'@plone/volto/babel': '<rootDir>/node_modules/@plone/volto/babel',
|
|
11
13
|
'@plone/volto/(.*)$': '<rootDir>/node_modules/@plone/volto/src/$1',
|
|
12
|
-
'@package/(.*)$': '<rootDir>/src/$1',
|
|
13
|
-
'@root/(.*)$': '<rootDir>/src/$1',
|
|
14
|
+
'@package/(.*)$': '<rootDir>/node_modules/@plone/volto/src/$1',
|
|
15
|
+
'@root/(.*)$': '<rootDir>/node_modules/@plone/volto/src/$1',
|
|
14
16
|
'@plone/volto-quanta/(.*)$': '<rootDir>/src/addons/volto-quanta/src/$1',
|
|
15
17
|
'@eeacms/(.*?)/(.*)$': '<rootDir>/node_modules/@eeacms/$1/src/$2',
|
|
16
|
-
'@plone/volto-slate':
|
|
18
|
+
'@plone/volto-slate$':
|
|
17
19
|
'<rootDir>/node_modules/@plone/volto/packages/volto-slate/src',
|
|
20
|
+
'@plone/volto-slate/(.*)$':
|
|
21
|
+
'<rootDir>/node_modules/@plone/volto/packages/volto-slate/src/$1',
|
|
18
22
|
'~/(.*)$': '<rootDir>/src/$1',
|
|
19
23
|
'load-volto-addons':
|
|
20
24
|
'<rootDir>/node_modules/@plone/volto/jest-addons-loader.js',
|
|
21
25
|
},
|
|
26
|
+
transformIgnorePatterns: [
|
|
27
|
+
'/node_modules/(?!(@plone|@root|@package|@eeacms)/).*/',
|
|
28
|
+
],
|
|
22
29
|
transform: {
|
|
23
30
|
'^.+\\.js(x)?$': 'babel-jest',
|
|
31
|
+
'^.+\\.ts(x)?$': 'ts-jest',
|
|
24
32
|
'^.+\\.(png)$': 'jest-file',
|
|
25
33
|
'^.+\\.(jpg)$': 'jest-file',
|
|
26
34
|
'^.+\\.(svg)$': './node_modules/@plone/volto/jest-svgsystem-transform.js',
|
|
@@ -33,4 +41,9 @@ module.exports = {
|
|
|
33
41
|
statements: 5,
|
|
34
42
|
},
|
|
35
43
|
},
|
|
44
|
+
...(process.env.JEST_USE_SETUP === 'ON' && {
|
|
45
|
+
setupFilesAfterEnv: [
|
|
46
|
+
'<rootDir>/node_modules/@eeacms/volto-hero-block/jest.setup.js',
|
|
47
|
+
],
|
|
48
|
+
}),
|
|
36
49
|
};
|
package/jest.setup.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { jest } from '@jest/globals';
|
|
2
|
+
import configureStore from 'redux-mock-store';
|
|
3
|
+
import thunk from 'redux-thunk';
|
|
4
|
+
import { blocksConfig } from '@plone/volto/config/Blocks';
|
|
5
|
+
import installSlate from '@plone/volto-slate/index';
|
|
6
|
+
|
|
7
|
+
var mockSemanticComponents = jest.requireActual('semantic-ui-react');
|
|
8
|
+
var mockComponents = jest.requireActual('@plone/volto/components');
|
|
9
|
+
var config = jest.requireActual('@plone/volto/registry').default;
|
|
10
|
+
|
|
11
|
+
config.blocks.blocksConfig = {
|
|
12
|
+
...blocksConfig,
|
|
13
|
+
...config.blocks.blocksConfig,
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
jest.doMock('semantic-ui-react', () => ({
|
|
17
|
+
__esModule: true,
|
|
18
|
+
...mockSemanticComponents,
|
|
19
|
+
Popup: ({ content, trigger }) => {
|
|
20
|
+
return (
|
|
21
|
+
<div className="popup">
|
|
22
|
+
<div className="trigger">{trigger}</div>
|
|
23
|
+
<div className="content">{content}</div>
|
|
24
|
+
</div>
|
|
25
|
+
);
|
|
26
|
+
},
|
|
27
|
+
}));
|
|
28
|
+
|
|
29
|
+
jest.doMock('@plone/volto/components', () => {
|
|
30
|
+
return {
|
|
31
|
+
__esModule: true,
|
|
32
|
+
...mockComponents,
|
|
33
|
+
SidebarPortal: ({ children }) => <div id="sidebar">{children}</div>,
|
|
34
|
+
};
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
jest.doMock('@plone/volto/registry', () =>
|
|
38
|
+
[installSlate].reduce((acc, apply) => apply(acc), config),
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
const mockStore = configureStore([thunk]);
|
|
42
|
+
|
|
43
|
+
global.fetch = jest.fn(() =>
|
|
44
|
+
Promise.resolve({
|
|
45
|
+
json: () => Promise.resolve({}),
|
|
46
|
+
}),
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
global.store = mockStore({
|
|
50
|
+
intl: {
|
|
51
|
+
locale: 'en',
|
|
52
|
+
messages: {},
|
|
53
|
+
formatMessage: jest.fn(),
|
|
54
|
+
},
|
|
55
|
+
content: {
|
|
56
|
+
create: {},
|
|
57
|
+
subrequests: [],
|
|
58
|
+
},
|
|
59
|
+
connected_data_parameters: {},
|
|
60
|
+
screen: {
|
|
61
|
+
page: {
|
|
62
|
+
width: 768,
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eeacms/volto-hero-block",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0",
|
|
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",
|
|
@@ -27,7 +27,9 @@
|
|
|
27
27
|
"@cypress/code-coverage": "^3.10.0",
|
|
28
28
|
"@plone/scripts": "*",
|
|
29
29
|
"babel-plugin-transform-class-properties": "^6.24.1",
|
|
30
|
+
"dotenv": "^16.3.2",
|
|
30
31
|
"husky": "^8.0.3",
|
|
32
|
+
"ts-jest": "^26.4.2",
|
|
31
33
|
"lint-staged": "^14.0.1",
|
|
32
34
|
"md5": "^2.3.0"
|
|
33
35
|
},
|
|
@@ -1,25 +1,22 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
2
|
import cx from 'classnames';
|
|
3
|
-
import { connect } from 'react-redux';
|
|
4
3
|
import isFunction from 'lodash/isFunction';
|
|
5
4
|
import { Icon } from 'semantic-ui-react';
|
|
6
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';
|
|
7
12
|
import {
|
|
8
13
|
BlockDataForm,
|
|
9
14
|
SidebarPortal,
|
|
10
15
|
UniversalLink,
|
|
11
16
|
} from '@plone/volto/components';
|
|
12
17
|
import { BodyClass } from '@plone/volto/helpers';
|
|
13
|
-
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
uploadContent,
|
|
17
|
-
saveSlateBlockSelection,
|
|
18
|
-
} from '@plone/volto-slate/actions';
|
|
19
|
-
import {
|
|
20
|
-
createSlateHeader,
|
|
21
|
-
getFieldURL,
|
|
22
|
-
} from '@eeacms/volto-hero-block/helpers';
|
|
18
|
+
|
|
19
|
+
import { getFieldURL } from '@eeacms/volto-hero-block/helpers';
|
|
23
20
|
import { HeroBlockSchema } from './schema';
|
|
24
21
|
import Copyright from './Copyright';
|
|
25
22
|
import Hero from './Hero';
|
|
@@ -40,18 +37,22 @@ const Metadata = ({ buttonLabel, inverted, styles, ...props }) => {
|
|
|
40
37
|
);
|
|
41
38
|
};
|
|
42
39
|
|
|
43
|
-
|
|
44
|
-
const
|
|
40
|
+
export default function Edit(props) {
|
|
41
|
+
const id = uuid();
|
|
42
|
+
const [selectedBlock, setSelectedBlock] = useState(id);
|
|
45
43
|
const {
|
|
46
44
|
data = {},
|
|
47
45
|
block = null,
|
|
48
|
-
selected
|
|
49
|
-
index,
|
|
46
|
+
selected,
|
|
50
47
|
properties,
|
|
51
48
|
onChangeBlock,
|
|
52
|
-
|
|
49
|
+
onChangeField,
|
|
50
|
+
pathname,
|
|
51
|
+
metadata = null,
|
|
52
|
+
setSidebarTab,
|
|
53
53
|
} = props;
|
|
54
|
-
const {
|
|
54
|
+
const { copyright, copyrightIcon, copyrightPosition } = data;
|
|
55
|
+
|
|
55
56
|
const copyrightPrefix = config.blocks.blocksConfig.hero.copyrightPrefix || '';
|
|
56
57
|
const schema = React.useMemo(() => {
|
|
57
58
|
if (isFunction(HeroBlockSchema)) {
|
|
@@ -60,66 +61,120 @@ const Edit = (props) => {
|
|
|
60
61
|
return HeroBlockSchema;
|
|
61
62
|
}, [props]);
|
|
62
63
|
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
editor.getBlockProps = () => props;
|
|
66
|
-
return editor;
|
|
67
|
-
},
|
|
68
|
-
[props],
|
|
69
|
-
);
|
|
64
|
+
const blockState = {};
|
|
65
|
+
const data_blocks = data?.data?.blocks;
|
|
70
66
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
67
|
+
if (data?.text || isEmpty(data_blocks)) {
|
|
68
|
+
let dataWithoutText = { ...data };
|
|
69
|
+
if (dataWithoutText) delete dataWithoutText.text;
|
|
70
|
+
|
|
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
|
+
}
|
|
76
96
|
|
|
77
97
|
return (
|
|
78
98
|
<>
|
|
79
99
|
<BodyClass className="with-hero-block" />
|
|
80
|
-
<
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
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>
|
|
118
172
|
<SidebarPortal selected={selected}>
|
|
119
173
|
<BlockDataForm
|
|
120
174
|
block={block}
|
|
121
175
|
schema={schema}
|
|
122
176
|
title={schema.title}
|
|
177
|
+
onChangeBlock={props.onChangeBlock}
|
|
123
178
|
onChangeField={(id, value) => {
|
|
124
179
|
onChangeBlock(block, {
|
|
125
180
|
...data,
|
|
@@ -131,21 +186,4 @@ const Edit = (props) => {
|
|
|
131
186
|
</SidebarPortal>
|
|
132
187
|
</>
|
|
133
188
|
);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
export default connect(
|
|
137
|
-
(state, props) => {
|
|
138
|
-
const blockId = props.block;
|
|
139
|
-
return {
|
|
140
|
-
defaultSelection: blockId
|
|
141
|
-
? state.slate_block_selections?.[blockId]
|
|
142
|
-
: null,
|
|
143
|
-
uploadRequest: state.upload_content?.[props.block]?.upload || {},
|
|
144
|
-
uploadedContent: state.upload_content?.[props.block]?.data || {},
|
|
145
|
-
};
|
|
146
|
-
},
|
|
147
|
-
{
|
|
148
|
-
uploadContent,
|
|
149
|
-
saveSlateBlockSelection, // needed as editor blockProps
|
|
150
|
-
},
|
|
151
|
-
)(Edit);
|
|
189
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { render
|
|
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.
|
|
10
|
+
const observe = jest.fn();
|
|
11
|
+
const unobserve = jest.fn();
|
|
12
|
+
jest.mock('@plone/volto/components', () => {
|
|
12
13
|
return {
|
|
13
14
|
__esModule: true,
|
|
14
|
-
|
|
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
|
-
|
|
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}>
|
|
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 = {
|
|
@@ -22,7 +22,7 @@ const intl = createIntl(
|
|
|
22
22
|
cache,
|
|
23
23
|
);
|
|
24
24
|
|
|
25
|
-
|
|
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;
|
|
@@ -89,11 +89,7 @@ export const HeroBlockSchema = () => {
|
|
|
89
89
|
description: (
|
|
90
90
|
<>
|
|
91
91
|
Ex. ri-copyright-line. See{' '}
|
|
92
|
-
<a
|
|
93
|
-
target="_blank"
|
|
94
|
-
rel="noopener noreferrer"
|
|
95
|
-
href="https://remixicon.com/"
|
|
96
|
-
>
|
|
92
|
+
<a target="_blank" rel="noopener" href="https://remixicon.com/">
|
|
97
93
|
Remix Icon set
|
|
98
94
|
</a>
|
|
99
95
|
</>
|
package/.project.eslintrc.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
|
|
4
|
-
const projectRootPath = fs.existsSync('./project')
|
|
5
|
-
? fs.realpathSync('./project')
|
|
6
|
-
: fs.realpathSync('./../../../');
|
|
7
|
-
const packageJson = require(path.join(projectRootPath, 'package.json'));
|
|
8
|
-
const jsConfig = require(path.join(projectRootPath, 'jsconfig.json')).compilerOptions;
|
|
9
|
-
|
|
10
|
-
const pathsConfig = jsConfig.paths;
|
|
11
|
-
|
|
12
|
-
let voltoPath = path.join(projectRootPath, 'node_modules/@plone/volto');
|
|
13
|
-
|
|
14
|
-
Object.keys(pathsConfig).forEach(pkg => {
|
|
15
|
-
if (pkg === '@plone/volto') {
|
|
16
|
-
voltoPath = `./${jsConfig.baseUrl}/${pathsConfig[pkg][0]}`;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
const AddonConfigurationRegistry = require(`${voltoPath}/addon-registry.js`);
|
|
20
|
-
const reg = new AddonConfigurationRegistry(projectRootPath);
|
|
21
|
-
|
|
22
|
-
// Extends ESlint configuration for adding the aliases to `src` directories in Volto addons
|
|
23
|
-
const addonAliases = Object.keys(reg.packages).map(o => [
|
|
24
|
-
o,
|
|
25
|
-
reg.packages[o].modulePath,
|
|
26
|
-
]);
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
module.exports = {
|
|
30
|
-
extends: `${projectRootPath}/node_modules/@plone/volto/.eslintrc`,
|
|
31
|
-
settings: {
|
|
32
|
-
'import/resolver': {
|
|
33
|
-
alias: {
|
|
34
|
-
map: [
|
|
35
|
-
['@plone/volto', '@plone/volto/src'],
|
|
36
|
-
...addonAliases,
|
|
37
|
-
['@package', `${__dirname}/src`],
|
|
38
|
-
['~', `${__dirname}/src`],
|
|
39
|
-
],
|
|
40
|
-
extensions: ['.js', '.jsx', '.json'],
|
|
41
|
-
},
|
|
42
|
-
'babel-plugin-root-import': {
|
|
43
|
-
rootPathSuffix: 'src',
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
};
|
|
48
|
-
|