@eeacms/volto-hero-block 5.4.5 → 5.5.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 +29 -21
- package/cypress.config.js +3 -3
- package/jest-addon.config.js +16 -4
- package/jest.setup.js +65 -0
- package/package.json +2 -1
- package/src/components/Blocks/Hero/Edit.jsx +29 -28
- package/src/components/Blocks/Hero/schema.js +10 -6
- 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,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
|
-
### [5.
|
|
7
|
+
### [5.5.0](https://github.com/eea/volto-hero-block/compare/5.4.6...5.5.0) - 19 February 2024
|
|
8
8
|
|
|
9
|
-
#### :
|
|
9
|
+
#### :house: Internal changes
|
|
10
|
+
|
|
11
|
+
- chore: package.json [Alin Voinea - [`3e83746`](https://github.com/eea/volto-hero-block/commit/3e8374664edaf5847c7290cf63b648c5b2d3e716)]
|
|
12
|
+
|
|
13
|
+
#### :hammer_and_wrench: Others
|
|
14
|
+
|
|
15
|
+
- Release 5.5.0 [alin - [`a81f788`](https://github.com/eea/volto-hero-block/commit/a81f788f54102a770b5e50cf5d7cfc6506278adf)]
|
|
16
|
+
- 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)]
|
|
17
|
+
- test: fix eslint errors [kreafox - [`5dd4d30`](https://github.com/eea/volto-hero-block/commit/5dd4d3071a68c0240f9f2c9defea0959621a275e)]
|
|
18
|
+
- Allow multiline editing of hero block [Tiberiu Ichim - [`373d1a0`](https://github.com/eea/volto-hero-block/commit/373d1a0d243b8e0b3df31f2a51a3c5df62f48214)]
|
|
19
|
+
- Allow multiline editing of hero block [Tiberiu Ichim - [`b674ca5`](https://github.com/eea/volto-hero-block/commit/b674ca589502a81aaf6abed75dbf8b83ac1731fb)]
|
|
20
|
+
- fix ESlint [Teodor - [`1439495`](https://github.com/eea/volto-hero-block/commit/14394952ef587f71be8b2c762c7e19698d8a55e4)]
|
|
21
|
+
- test: Update jest,Jenkinsfile,lint to volto-addons-template PR30 [valentinab25 - [`de6a206`](https://github.com/eea/volto-hero-block/commit/de6a206bed9afd53d97f5e6d70e2391ccc01f0f1)]
|
|
22
|
+
### [5.4.6](https://github.com/eea/volto-hero-block/compare/5.4.5...5.4.6) - 27 November 2023
|
|
23
|
+
|
|
24
|
+
#### :rocket: New Features
|
|
25
|
+
|
|
26
|
+
- feat(hero): add clear option for hero image position [David Ichim - [`80c35eb`](https://github.com/eea/volto-hero-block/commit/80c35eb76a27080968b111b8ef07a4b6563014b2)]
|
|
10
27
|
|
|
11
|
-
|
|
28
|
+
#### :nail_care: Enhancements
|
|
29
|
+
|
|
30
|
+
- change(image): renamed title for bg to Image position [David Ichim - [`81e1e63`](https://github.com/eea/volto-hero-block/commit/81e1e63d49f21d098382a3f02cf0aeb084a5a34d)]
|
|
31
|
+
|
|
32
|
+
#### :house: Internal changes
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
#### :hammer_and_wrench: Others
|
|
36
|
+
|
|
37
|
+
### [5.4.5](https://github.com/eea/volto-hero-block/compare/5.4.4...5.4.5) - 19 October 2023
|
|
12
38
|
|
|
13
39
|
### [5.4.4](https://github.com/eea/volto-hero-block/compare/5.4.3...5.4.4) - 19 October 2023
|
|
14
40
|
|
|
@@ -47,14 +73,12 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
47
73
|
- test: add unit tests for Hero, Edit, helpers, hooks - refs #254313 [ana-oprea - [`89b39af`](https://github.com/eea/volto-hero-block/commit/89b39afe7ad5ce94d341482be91ab55e2c1a31ed)]
|
|
48
74
|
- i18n: Add en [Alin Voinea - [`9cdb7f1`](https://github.com/eea/volto-hero-block/commit/9cdb7f1ff9d81dade3d91551b53cf7200f08937e)]
|
|
49
75
|
- test: Update Makefile and docker-compose to align it with Jenkinsfile [valentinab25 - [`0fe0d91`](https://github.com/eea/volto-hero-block/commit/0fe0d91fe9c43d10574990e9b163ffc49fe5bee7)]
|
|
50
|
-
- Add Sonarqube tag using freshwater-frontend addons list [EEA Jenkins - [`b1d1446`](https://github.com/eea/volto-hero-block/commit/b1d14467bcde28023b2831235928db1f328d6b0a)]
|
|
51
76
|
### [5.4.1](https://github.com/eea/volto-hero-block/compare/5.4.0...5.4.1) - 24 July 2023
|
|
52
77
|
|
|
53
78
|
### [5.4.0](https://github.com/eea/volto-hero-block/compare/5.3.1...5.4.0) - 12 June 2023
|
|
54
79
|
|
|
55
80
|
#### :house: Internal changes
|
|
56
81
|
|
|
57
|
-
- chore: [JENKINS] Deprecate circularity website [valentinab25 - [`395db48`](https://github.com/eea/volto-hero-block/commit/395db484f73c2dd2c56233c120a9620340f17d0b)]
|
|
58
82
|
|
|
59
83
|
#### :hammer_and_wrench: Others
|
|
60
84
|
|
|
@@ -75,7 +99,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
75
99
|
- put return statement [Dobricean Ioan Dorian - [`8eff5fd`](https://github.com/eea/volto-hero-block/commit/8eff5fdf977fcbb8cc952d3f45b577b02ca59cb9)]
|
|
76
100
|
- change name and refactor to be more efficent [Dobricean Ioan Dorian - [`ff24145`](https://github.com/eea/volto-hero-block/commit/ff2414542833998ef282376de3fbda8698287849)]
|
|
77
101
|
- stop-image-disappear over and over [Dobricean Ioan Dorian - [`c5b6f54`](https://github.com/eea/volto-hero-block/commit/c5b6f545ac422d95b8d802349aa4cf27af820829)]
|
|
78
|
-
- Add Sonarqube tag using industry-frontend addons list [EEA Jenkins - [`3d38dd0`](https://github.com/eea/volto-hero-block/commit/3d38dd09a36525bda448f67a6d218bc7690a4cc3)]
|
|
79
102
|
### [5.3.0](https://github.com/eea/volto-hero-block/compare/5.2.0...5.3.0) - 27 March 2023
|
|
80
103
|
|
|
81
104
|
#### :rocket: New Features
|
|
@@ -114,11 +137,9 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
114
137
|
- fix onScreen hook error #16 from eea/fix-onscreen-hook [ichim-david - [`9123541`](https://github.com/eea/volto-hero-block/commit/91235413f423d7e6c4788d70b687b3ed5d4884b4)]
|
|
115
138
|
- no need for comments [andreiggr - [`a14f9c3`](https://github.com/eea/volto-hero-block/commit/a14f9c3bdddfa22e6b4bbc8318f0ca5bdc9c2d38)]
|
|
116
139
|
- fix hook [andreiggr - [`f7fae73`](https://github.com/eea/volto-hero-block/commit/f7fae73007f79af2f06da1d9b72a53ad86fef4ac)]
|
|
117
|
-
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`6b78fc0`](https://github.com/eea/volto-hero-block/commit/6b78fc044a933ab9b4b4694901aa26628ef0a836)]
|
|
118
140
|
- eslint [andreiggr - [`68451b7`](https://github.com/eea/volto-hero-block/commit/68451b725420015fbd5b695e97b8742988d49913)]
|
|
119
141
|
- lazy load huge img on first 10px [andreiggr - [`67dc7d3`](https://github.com/eea/volto-hero-block/commit/67dc7d3475188d692e053032c2639dd1a585c029)]
|
|
120
142
|
- lazy load huge bgimage wip [andreiggr - [`86e45ec`](https://github.com/eea/volto-hero-block/commit/86e45ece842f1cd7452920dffa3a9b4aea945f56)]
|
|
121
|
-
- Add Sonarqube tag using ims-frontend addons list [EEA Jenkins - [`87cbb38`](https://github.com/eea/volto-hero-block/commit/87cbb383290a168f85703573670e17f4e1ed7747)]
|
|
122
143
|
## [4.0.0](https://github.com/eea/volto-hero-block/compare/3.0.1...4.0.0) - 7 February 2023
|
|
123
144
|
|
|
124
145
|
#### :nail_care: Enhancements
|
|
@@ -144,7 +165,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
144
165
|
|
|
145
166
|
#### :hammer_and_wrench: Others
|
|
146
167
|
|
|
147
|
-
- Add Sonarqube tag using advisory-board-frontend addons list [EEA Jenkins - [`ab85c7b`](https://github.com/eea/volto-hero-block/commit/ab85c7bd5bd1e3aec95e02f9b4d026b1203d5739)]
|
|
148
168
|
## [3.0.0](https://github.com/eea/volto-hero-block/compare/2.1.0...3.0.0) - 22 December 2022
|
|
149
169
|
|
|
150
170
|
#### :rocket: New Features
|
|
@@ -153,11 +173,8 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
153
173
|
|
|
154
174
|
#### :hammer_and_wrench: Others
|
|
155
175
|
|
|
156
|
-
- Add Sonarqube tag using advisory-board-frontend addons list [EEA Jenkins - [`f06f58c`](https://github.com/eea/volto-hero-block/commit/f06f58c7cd4cfc15a03208e9c7a4e31fe2eba2f6)]
|
|
157
|
-
- Add Sonarqube tag using climate-energy-frontend addons list [EEA Jenkins - [`20e5bcb`](https://github.com/eea/volto-hero-block/commit/20e5bcb3c4dd538595741928319c3204c5d18f8c)]
|
|
158
176
|
- Cosmetics [Alin Voinea - [`9dac70c`](https://github.com/eea/volto-hero-block/commit/9dac70c0a3bea8e188ede9123f4f99de8e0f6987)]
|
|
159
177
|
- test(Jenkins): Run tests and cypress with latest canary @plone/volto [Alin Voinea - [`2d4005f`](https://github.com/eea/volto-hero-block/commit/2d4005f0f31b121e1b7d2e94414f3dff92ec1a16)]
|
|
160
|
-
- Add Sonarqube tag using cca-frontend addons list [EEA Jenkins - [`2931fcc`](https://github.com/eea/volto-hero-block/commit/2931fccbee5f8e117e5ae9095ba57e63e465ddb3)]
|
|
161
178
|
### [2.1.0](https://github.com/eea/volto-hero-block/compare/2.0.0...2.1.0) - 12 December 2022
|
|
162
179
|
|
|
163
180
|
#### :bug: Bug Fixes
|
|
@@ -166,12 +183,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
166
183
|
|
|
167
184
|
#### :hammer_and_wrench: Others
|
|
168
185
|
|
|
169
|
-
- Add Sonarqube tag using bise-frontend addons list [EEA Jenkins - [`93be4f9`](https://github.com/eea/volto-hero-block/commit/93be4f96fb72cacfc25f9b058cb379d80060ee13)]
|
|
170
|
-
- yarn 3 [Alin Voinea - [`8e2dccd`](https://github.com/eea/volto-hero-block/commit/8e2dccd47cbef3c0871407baa376ce61c540c754)]
|
|
171
|
-
- Add Sonarqube tag using marine-frontend addons list [EEA Jenkins - [`6bc3af3`](https://github.com/eea/volto-hero-block/commit/6bc3af35b4edf07971d1b0ce1648965e8d6e3bc0)]
|
|
172
|
-
- Add Sonarqube tag using clms-frontend addons list [EEA Jenkins - [`d7dbbd2`](https://github.com/eea/volto-hero-block/commit/d7dbbd21277dd76bf59d91a4dc8e022b2a6ff99c)]
|
|
173
|
-
- Add Sonarqube tag using demo-kitkat-frontend addons list [EEA Jenkins - [`3c1f0d6`](https://github.com/eea/volto-hero-block/commit/3c1f0d6e7f8e5318aee3413ec3687d8492376f9d)]
|
|
174
|
-
- Add Sonarqube tag using forests-frontend addons list [EEA Jenkins - [`843017a`](https://github.com/eea/volto-hero-block/commit/843017aa7dbea71cc7888663496e352d287440b4)]
|
|
175
186
|
## [2.0.0](https://github.com/eea/volto-hero-block/compare/1.0.0...2.0.0) - 16 November 2022
|
|
176
187
|
|
|
177
188
|
#### :nail_care: Enhancements
|
|
@@ -181,7 +192,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
181
192
|
#### :hammer_and_wrench: Others
|
|
182
193
|
|
|
183
194
|
- test(estlint): Fix .project.eslintrc.js [Alin Voinea - [`b8f0971`](https://github.com/eea/volto-hero-block/commit/b8f0971b21a5334d40c1b8f5103cea61d9ffe6f1)]
|
|
184
|
-
- Add Sonarqube tag using circularity-frontend addons list [EEA Jenkins - [`581dedf`](https://github.com/eea/volto-hero-block/commit/581dedf07410ef2ca09e6ddaa05fbf176400adbb)]
|
|
185
195
|
## [1.0.0](https://github.com/eea/volto-hero-block/compare/0.2.0...1.0.0) - 28 October 2022
|
|
186
196
|
|
|
187
197
|
#### :nail_care: Enhancements
|
|
@@ -193,7 +203,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
193
203
|
- Remove cypress.json [Alin Voinea - [`593bdf2`](https://github.com/eea/volto-hero-block/commit/593bdf207ca4fd3f2393117b6f64a44727881ad0)]
|
|
194
204
|
- test(cypress): Upgrade to Cypress 10 / Razzle 4 [Alin Voinea - [`edd48a5`](https://github.com/eea/volto-hero-block/commit/edd48a5c13824bce5e03e46790f1890656b340d8)]
|
|
195
205
|
- Cleanup [Alin Voinea - [`9d72ee7`](https://github.com/eea/volto-hero-block/commit/9d72ee7a06d1c6fed46586d30bb85eae39e670bf)]
|
|
196
|
-
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`95986d0`](https://github.com/eea/volto-hero-block/commit/95986d0b8fd5c3cbb9e6da9059f71e066a8e171b)]
|
|
197
206
|
### [0.2.0](https://github.com/eea/volto-hero-block/compare/0.1.4...0.2.0) - 6 July 2022
|
|
198
207
|
|
|
199
208
|
#### :bug: Bug Fixes
|
|
@@ -232,7 +241,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
232
241
|
- Update slate footnote support [Miu Razvan - [`c1522b4`](https://github.com/eea/volto-hero-block/commit/c1522b4164dbe6de01771d211d7e0bf3009f44d4)]
|
|
233
242
|
- Use justify content for text and button as well [Miu Razvan - [`08599cc`](https://github.com/eea/volto-hero-block/commit/08599cc45546d9b349128c4f8ce9c01318385811)]
|
|
234
243
|
- Add dependencies [Miu Razvan - [`30e2881`](https://github.com/eea/volto-hero-block/commit/30e2881a2a97a899e7f4cc614a0405c300ac6fee)]
|
|
235
|
-
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`b415422`](https://github.com/eea/volto-hero-block/commit/b41542285edd29440a324b101a4dbae9334830bf)]
|
|
236
244
|
### 0.1.0 - 10 June 2022
|
|
237
245
|
|
|
238
246
|
#### :hammer_and_wrench: Others
|
package/cypress.config.js
CHANGED
|
@@ -2,12 +2,12 @@ const { defineConfig } = require('cypress');
|
|
|
2
2
|
|
|
3
3
|
module.exports = defineConfig({
|
|
4
4
|
viewportWidth: 1280,
|
|
5
|
-
defaultCommandTimeout:
|
|
5
|
+
defaultCommandTimeout: 8888,
|
|
6
6
|
chromeWebSecurity: false,
|
|
7
7
|
reporter: 'junit',
|
|
8
|
-
video:
|
|
8
|
+
video: false,
|
|
9
9
|
retries: {
|
|
10
|
-
runMode:
|
|
10
|
+
runMode: 2,
|
|
11
11
|
openMode: 0,
|
|
12
12
|
},
|
|
13
13
|
reporterOptions: {
|
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,16 +11,21 @@ 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',
|
|
24
31
|
'^.+\\.(png)$': 'jest-file',
|
|
@@ -33,4 +40,9 @@ module.exports = {
|
|
|
33
40
|
statements: 5,
|
|
34
41
|
},
|
|
35
42
|
},
|
|
36
|
-
|
|
43
|
+
...(process.env.JEST_USE_SETUP === 'ON' && {
|
|
44
|
+
setupFilesAfterEnv: [
|
|
45
|
+
'<rootDir>/node_modules/@eeacms/volto-hero-block/jest.setup.js',
|
|
46
|
+
],
|
|
47
|
+
}),
|
|
48
|
+
}
|
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": "5.
|
|
3
|
+
"version": "5.5.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,6 +27,7 @@
|
|
|
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",
|
|
31
32
|
"lint-staged": "^14.0.1",
|
|
32
33
|
"md5": "^2.3.0"
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React 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';
|
|
@@ -11,11 +10,10 @@ import {
|
|
|
11
10
|
} from '@plone/volto/components';
|
|
12
11
|
import { BodyClass } from '@plone/volto/helpers';
|
|
13
12
|
import SlateEditor from '@plone/volto-slate/editor/SlateEditor';
|
|
14
|
-
import { handleKey } from '@plone/volto-slate/blocks/Text/keyboard';
|
|
15
13
|
import {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
} from '@plone/volto-slate/
|
|
14
|
+
handleKey,
|
|
15
|
+
handleKeyDetached,
|
|
16
|
+
} from '@plone/volto-slate/blocks/Text/keyboard';
|
|
19
17
|
import {
|
|
20
18
|
createSlateHeader,
|
|
21
19
|
getFieldURL,
|
|
@@ -40,7 +38,7 @@ const Metadata = ({ buttonLabel, inverted, styles, ...props }) => {
|
|
|
40
38
|
);
|
|
41
39
|
};
|
|
42
40
|
|
|
43
|
-
|
|
41
|
+
export default function Edit(props) {
|
|
44
42
|
const { slate } = config.settings;
|
|
45
43
|
const {
|
|
46
44
|
data = {},
|
|
@@ -51,7 +49,13 @@ const Edit = (props) => {
|
|
|
51
49
|
onChangeBlock,
|
|
52
50
|
onSelectBlock,
|
|
53
51
|
} = props;
|
|
54
|
-
const {
|
|
52
|
+
const {
|
|
53
|
+
text,
|
|
54
|
+
copyright,
|
|
55
|
+
copyrightIcon,
|
|
56
|
+
copyrightPosition,
|
|
57
|
+
isMultiline,
|
|
58
|
+
} = data;
|
|
55
59
|
const copyrightPrefix = config.blocks.blocksConfig.hero.copyrightPrefix || '';
|
|
56
60
|
const schema = React.useMemo(() => {
|
|
57
61
|
if (isFunction(HeroBlockSchema)) {
|
|
@@ -74,17 +78,31 @@ const Edit = (props) => {
|
|
|
74
78
|
}
|
|
75
79
|
}, [onSelectBlock, selected, block]);
|
|
76
80
|
|
|
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);
|
|
92
|
+
|
|
77
93
|
return (
|
|
78
94
|
<>
|
|
79
95
|
<BodyClass className="with-hero-block" />
|
|
80
96
|
<Hero {...data}>
|
|
81
97
|
<Hero.Text {...data}>
|
|
82
98
|
<SlateEditor
|
|
99
|
+
key={isMultiline}
|
|
100
|
+
detached={!isMultiline}
|
|
83
101
|
index={index}
|
|
84
102
|
properties={properties}
|
|
85
|
-
extensions={
|
|
103
|
+
extensions={extensions}
|
|
86
104
|
renderExtensions={[withBlockProperties]}
|
|
87
|
-
value={
|
|
105
|
+
value={value}
|
|
88
106
|
onChange={(text) => {
|
|
89
107
|
onChangeBlock(block, {
|
|
90
108
|
...data,
|
|
@@ -93,7 +111,7 @@ const Edit = (props) => {
|
|
|
93
111
|
}}
|
|
94
112
|
block={block}
|
|
95
113
|
onFocus={handleFocus}
|
|
96
|
-
onKeyDown={handleKey}
|
|
114
|
+
onKeyDown={isMultiline ? handleKeyDetached : handleKey}
|
|
97
115
|
selected={selected}
|
|
98
116
|
placeholder="Add text..."
|
|
99
117
|
slateSettings={slate}
|
|
@@ -131,21 +149,4 @@ const Edit = (props) => {
|
|
|
131
149
|
</SidebarPortal>
|
|
132
150
|
</>
|
|
133
151
|
);
|
|
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);
|
|
152
|
+
}
|
|
@@ -4,11 +4,13 @@ import config from '@plone/volto/registry';
|
|
|
4
4
|
import alignTopSVG from '@plone/volto/icons/move-up.svg';
|
|
5
5
|
import alignCenterSVG from '@plone/volto/icons/row.svg';
|
|
6
6
|
import alignBottomSVG from '@plone/volto/icons/move-down.svg';
|
|
7
|
+
import clearSVG from '@plone/volto/icons/clear.svg';
|
|
7
8
|
|
|
8
9
|
const ALIGN_INFO_MAP = {
|
|
9
10
|
'has--bg--top': [alignTopSVG, 'Top'],
|
|
10
11
|
'has--bg--center': [alignCenterSVG, 'Center'],
|
|
11
12
|
'has--bg--bottom': [alignBottomSVG, 'Bottom'],
|
|
13
|
+
'': [clearSVG, 'None'],
|
|
12
14
|
};
|
|
13
15
|
|
|
14
16
|
export const HeroBlockSchema = () => {
|
|
@@ -24,6 +26,7 @@ export const HeroBlockSchema = () => {
|
|
|
24
26
|
'quoted',
|
|
25
27
|
'spaced',
|
|
26
28
|
'inverted',
|
|
29
|
+
'isMultiline',
|
|
27
30
|
'buttonLabel',
|
|
28
31
|
'buttonLink',
|
|
29
32
|
'overlay',
|
|
@@ -62,6 +65,11 @@ export const HeroBlockSchema = () => {
|
|
|
62
65
|
type: 'boolean',
|
|
63
66
|
defaultValue: true,
|
|
64
67
|
},
|
|
68
|
+
isMultiline: {
|
|
69
|
+
title: 'Multiline',
|
|
70
|
+
type: 'boolean',
|
|
71
|
+
defaultValue: false,
|
|
72
|
+
},
|
|
65
73
|
buttonLabel: {
|
|
66
74
|
title: 'Button label',
|
|
67
75
|
widget: 'textarea',
|
|
@@ -87,11 +95,7 @@ export const HeroBlockSchema = () => {
|
|
|
87
95
|
description: (
|
|
88
96
|
<>
|
|
89
97
|
Ex. ri-copyright-line. See{' '}
|
|
90
|
-
<a
|
|
91
|
-
target="_blank"
|
|
92
|
-
rel="noopener noreferrer"
|
|
93
|
-
href="https://remixicon.com/"
|
|
94
|
-
>
|
|
98
|
+
<a target="_blank" rel="noopener" href="https://remixicon.com/">
|
|
95
99
|
Remix Icon set
|
|
96
100
|
</a>
|
|
97
101
|
</>
|
|
@@ -131,7 +135,7 @@ export const stylingSchema = (props) => {
|
|
|
131
135
|
],
|
|
132
136
|
properties: {
|
|
133
137
|
bg: {
|
|
134
|
-
title: '
|
|
138
|
+
title: 'Image position',
|
|
135
139
|
widget: 'align',
|
|
136
140
|
actions: Object.keys(ALIGN_INFO_MAP),
|
|
137
141
|
actionsInfoMap: ALIGN_INFO_MAP,
|
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
|
-
|