@eeacms/volto-hero-block 5.4.6 → 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 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,21 @@ 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.5.0](https://github.com/eea/volto-hero-block/compare/5.4.6...5.5.0) - 19 February 2024
8
+
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)]
7
22
  ### [5.4.6](https://github.com/eea/volto-hero-block/compare/5.4.5...5.4.6) - 27 November 2023
8
23
 
9
24
  #### :rocket: New Features
@@ -16,16 +31,9 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
16
31
 
17
32
  #### :house: Internal changes
18
33
 
19
- - chore: [JENKINS] Refactor automated testing [valentinab25 - [`df8242c`](https://github.com/eea/volto-hero-block/commit/df8242c62eb8c706c3854f6bb4a6984932463571)]
20
34
 
21
35
  #### :hammer_and_wrench: Others
22
36
 
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
37
  ### [5.4.5](https://github.com/eea/volto-hero-block/compare/5.4.4...5.4.5) - 19 October 2023
30
38
 
31
39
  ### [5.4.4](https://github.com/eea/volto-hero-block/compare/5.4.3...5.4.4) - 19 October 2023
@@ -65,14 +73,12 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
65
73
  - test: add unit tests for Hero, Edit, helpers, hooks - refs #254313 [ana-oprea - [`89b39af`](https://github.com/eea/volto-hero-block/commit/89b39afe7ad5ce94d341482be91ab55e2c1a31ed)]
66
74
  - i18n: Add en [Alin Voinea - [`9cdb7f1`](https://github.com/eea/volto-hero-block/commit/9cdb7f1ff9d81dade3d91551b53cf7200f08937e)]
67
75
  - 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
76
  ### [5.4.1](https://github.com/eea/volto-hero-block/compare/5.4.0...5.4.1) - 24 July 2023
70
77
 
71
78
  ### [5.4.0](https://github.com/eea/volto-hero-block/compare/5.3.1...5.4.0) - 12 June 2023
72
79
 
73
80
  #### :house: Internal changes
74
81
 
75
- - chore: [JENKINS] Deprecate circularity website [valentinab25 - [`395db48`](https://github.com/eea/volto-hero-block/commit/395db484f73c2dd2c56233c120a9620340f17d0b)]
76
82
 
77
83
  #### :hammer_and_wrench: Others
78
84
 
@@ -93,7 +99,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
93
99
  - put return statement [Dobricean Ioan Dorian - [`8eff5fd`](https://github.com/eea/volto-hero-block/commit/8eff5fdf977fcbb8cc952d3f45b577b02ca59cb9)]
94
100
  - change name and refactor to be more efficent [Dobricean Ioan Dorian - [`ff24145`](https://github.com/eea/volto-hero-block/commit/ff2414542833998ef282376de3fbda8698287849)]
95
101
  - 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
102
  ### [5.3.0](https://github.com/eea/volto-hero-block/compare/5.2.0...5.3.0) - 27 March 2023
98
103
 
99
104
  #### :rocket: New Features
@@ -132,11 +137,9 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
132
137
  - fix onScreen hook error #16 from eea/fix-onscreen-hook [ichim-david - [`9123541`](https://github.com/eea/volto-hero-block/commit/91235413f423d7e6c4788d70b687b3ed5d4884b4)]
133
138
  - no need for comments [andreiggr - [`a14f9c3`](https://github.com/eea/volto-hero-block/commit/a14f9c3bdddfa22e6b4bbc8318f0ca5bdc9c2d38)]
134
139
  - 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
140
  - eslint [andreiggr - [`68451b7`](https://github.com/eea/volto-hero-block/commit/68451b725420015fbd5b695e97b8742988d49913)]
137
141
  - lazy load huge img on first 10px [andreiggr - [`67dc7d3`](https://github.com/eea/volto-hero-block/commit/67dc7d3475188d692e053032c2639dd1a585c029)]
138
142
  - 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
143
  ## [4.0.0](https://github.com/eea/volto-hero-block/compare/3.0.1...4.0.0) - 7 February 2023
141
144
 
142
145
  #### :nail_care: Enhancements
@@ -162,7 +165,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
162
165
 
163
166
  #### :hammer_and_wrench: Others
164
167
 
165
- - Add Sonarqube tag using advisory-board-frontend addons list [EEA Jenkins - [`ab85c7b`](https://github.com/eea/volto-hero-block/commit/ab85c7bd5bd1e3aec95e02f9b4d026b1203d5739)]
166
168
  ## [3.0.0](https://github.com/eea/volto-hero-block/compare/2.1.0...3.0.0) - 22 December 2022
167
169
 
168
170
  #### :rocket: New Features
@@ -171,11 +173,8 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
171
173
 
172
174
  #### :hammer_and_wrench: Others
173
175
 
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
176
  - Cosmetics [Alin Voinea - [`9dac70c`](https://github.com/eea/volto-hero-block/commit/9dac70c0a3bea8e188ede9123f4f99de8e0f6987)]
177
177
  - 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
178
  ### [2.1.0](https://github.com/eea/volto-hero-block/compare/2.0.0...2.1.0) - 12 December 2022
180
179
 
181
180
  #### :bug: Bug Fixes
@@ -184,12 +183,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
184
183
 
185
184
  #### :hammer_and_wrench: Others
186
185
 
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
186
  ## [2.0.0](https://github.com/eea/volto-hero-block/compare/1.0.0...2.0.0) - 16 November 2022
194
187
 
195
188
  #### :nail_care: Enhancements
@@ -199,7 +192,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
199
192
  #### :hammer_and_wrench: Others
200
193
 
201
194
  - 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
195
  ## [1.0.0](https://github.com/eea/volto-hero-block/compare/0.2.0...1.0.0) - 28 October 2022
204
196
 
205
197
  #### :nail_care: Enhancements
@@ -211,7 +203,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
211
203
  - Remove cypress.json [Alin Voinea - [`593bdf2`](https://github.com/eea/volto-hero-block/commit/593bdf207ca4fd3f2393117b6f64a44727881ad0)]
212
204
  - test(cypress): Upgrade to Cypress 10 / Razzle 4 [Alin Voinea - [`edd48a5`](https://github.com/eea/volto-hero-block/commit/edd48a5c13824bce5e03e46790f1890656b340d8)]
213
205
  - 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
206
  ### [0.2.0](https://github.com/eea/volto-hero-block/compare/0.1.4...0.2.0) - 6 July 2022
216
207
 
217
208
  #### :bug: Bug Fixes
@@ -250,7 +241,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
250
241
  - Update slate footnote support [Miu Razvan - [`c1522b4`](https://github.com/eea/volto-hero-block/commit/c1522b4164dbe6de01771d211d7e0bf3009f44d4)]
251
242
  - Use justify content for text and button as well [Miu Razvan - [`08599cc`](https://github.com/eea/volto-hero-block/commit/08599cc45546d9b349128c4f8ce9c01318385811)]
252
243
  - 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
244
  ### 0.1.0 - 10 June 2022
255
245
 
256
246
  #### :hammer_and_wrench: Others
@@ -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.4.6",
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
- uploadContent,
17
- saveSlateBlockSelection,
18
- } from '@plone/volto-slate/actions';
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
- const Edit = (props) => {
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 { text, copyright, copyrightIcon, copyrightPosition } = data;
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={slate.textblockExtensions}
103
+ extensions={extensions}
86
104
  renderExtensions={[withBlockProperties]}
87
- value={createSlateHeader(text)}
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
+ }
@@ -26,6 +26,7 @@ export const HeroBlockSchema = () => {
26
26
  'quoted',
27
27
  'spaced',
28
28
  'inverted',
29
+ 'isMultiline',
29
30
  'buttonLabel',
30
31
  'buttonLink',
31
32
  'overlay',
@@ -64,6 +65,11 @@ export const HeroBlockSchema = () => {
64
65
  type: 'boolean',
65
66
  defaultValue: true,
66
67
  },
68
+ isMultiline: {
69
+ title: 'Multiline',
70
+ type: 'boolean',
71
+ defaultValue: false,
72
+ },
67
73
  buttonLabel: {
68
74
  title: 'Button label',
69
75
  widget: 'textarea',
@@ -89,11 +95,7 @@ export const HeroBlockSchema = () => {
89
95
  description: (
90
96
  <>
91
97
  Ex. ri-copyright-line. See{' '}
92
- <a
93
- target="_blank"
94
- rel="noopener noreferrer"
95
- href="https://remixicon.com/"
96
- >
98
+ <a target="_blank" rel="noopener" href="https://remixicon.com/">
97
99
  Remix Icon set
98
100
  </a>
99
101
  </>
@@ -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
-