@eeacms/volto-tabs-block 9.1.0 → 10.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +7 -6
- package/CHANGELOG.md +54 -0
- package/DEVELOP.md +19 -17
- package/README.md +51 -19
- package/cypress.config.js +10 -1
- package/docker-compose.yml +1 -1
- package/jest-addon.config.js +10 -4
- package/package.json +1 -1
- package/src/components/Edit.jsx +9 -11
- package/src/components/Edit.test.jsx +239 -0
- package/src/components/View.test.jsx +2 -5
- package/src/components/layoutSchema.js +10 -2
- package/src/components/variations/accordion/View.jsx +3 -3
- package/src/components/variations/carousel/HorizontalView.jsx +2 -1
- package/src/components/variations/carousel/VerticalView.jsx +1 -1
- package/src/components/variations/default/Edit.jsx +5 -17
- package/src/components/variations/default/View.jsx +2 -2
- package/src/components/variations/horizontal-responsive/Edit.jsx +6 -18
- package/src/components/variations/horizontal-responsive/View.jsx +1 -1
- package/src/helpers.js +1 -1
- package/src/index.test.js +57 -0
- package/src/less/edit.less +0 -46
- package/src/utils/SimpleMarkdown.test.jsx +1 -1
- package/src/widgets/TabsWidget.jsx +5 -2
- package/src/components/EditBlockWrapper.jsx +0 -172
package/.eslintrc.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const path = require('path');
|
|
3
|
+
const { AddonRegistry } = require('@plone/registry/addon-registry');
|
|
3
4
|
const projectRootPath = fs.realpathSync(__dirname + '/../../../');
|
|
4
5
|
|
|
5
6
|
let voltoPath = path.join(projectRootPath, 'node_modules/@plone/volto');
|
|
@@ -16,16 +17,16 @@ if (configFile) {
|
|
|
16
17
|
voltoPath = `./${jsConfig.baseUrl}/${pathsConfig['@plone/volto'][0]}`;
|
|
17
18
|
}
|
|
18
19
|
|
|
19
|
-
const
|
|
20
|
-
const reg = new AddonConfigurationRegistry(projectRootPath);
|
|
20
|
+
const { registry } = AddonRegistry.init(projectRootPath);
|
|
21
21
|
|
|
22
22
|
// Extends ESlint configuration for adding the aliases to `src` directories in Volto addons
|
|
23
|
-
const addonAliases = Object.keys(
|
|
23
|
+
const addonAliases = Object.keys(registry.packages).map((o) => [
|
|
24
24
|
o,
|
|
25
|
-
|
|
25
|
+
registry.packages[o].modulePath,
|
|
26
26
|
]);
|
|
27
27
|
|
|
28
|
-
const addonExtenders =
|
|
28
|
+
const addonExtenders = registry.getEslintExtenders().map((m) => require(m));
|
|
29
|
+
const voltoSlatePath = '@plone/volto-slate/src';
|
|
29
30
|
|
|
30
31
|
const defaultConfig = {
|
|
31
32
|
extends: `${voltoPath}/.eslintrc`,
|
|
@@ -34,7 +35,7 @@ const defaultConfig = {
|
|
|
34
35
|
alias: {
|
|
35
36
|
map: [
|
|
36
37
|
['@plone/volto', '@plone/volto/src'],
|
|
37
|
-
['@plone/volto-slate',
|
|
38
|
+
['@plone/volto-slate', voltoSlatePath],
|
|
38
39
|
...addonAliases,
|
|
39
40
|
['@package', `${__dirname}/src`],
|
|
40
41
|
['@root', `${__dirname}/src`],
|
package/CHANGELOG.md
CHANGED
|
@@ -4,11 +4,33 @@ 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
|
+
### [10.0.1](https://github.com/eea/volto-tabs-block/compare/10.0.0...10.0.1) - 8 April 2026
|
|
8
|
+
|
|
9
|
+
## [10.0.0](https://github.com/eea/volto-tabs-block/compare/9.1.0...10.0.0) - 27 March 2026
|
|
10
|
+
|
|
11
|
+
#### :rocket: New Features
|
|
12
|
+
|
|
13
|
+
- feat: Volto 18 support - refs #287700 [Alin Voinea - [`f370bb2`](https://github.com/eea/volto-tabs-block/commit/f370bb24f0a741129c21896338baf19ed4bab030)]
|
|
14
|
+
|
|
15
|
+
#### :house: Internal changes
|
|
16
|
+
|
|
17
|
+
- chore: [JENKINSFILE] add package version in sonarqube [valentinab25 - [`1e18835`](https://github.com/eea/volto-tabs-block/commit/1e18835ff2d59579de5dc9bb8ec6056a90dd7f77)]
|
|
18
|
+
- chore: [JENKINSFILE] use sonarqube branches [EEA Jenkins - [`1b14a57`](https://github.com/eea/volto-tabs-block/commit/1b14a57d39aa4685294068fff78275a1f6248964)]
|
|
19
|
+
|
|
20
|
+
#### :hammer_and_wrench: Others
|
|
21
|
+
|
|
22
|
+
- Release 10.0.0: Volto 18 support [Alin Voinea - [`3f509ae`](https://github.com/eea/volto-tabs-block/commit/3f509aed7cff2e43d4d50f64bf24b6244602fd95)]
|
|
23
|
+
- test: Fix make test [Alin V. (Claudiu) - [`c29c5bc`](https://github.com/eea/volto-tabs-block/commit/c29c5bcc5f0e24ce636dc12c87a8579eb93bd56d)]
|
|
24
|
+
- tests: Fix Sonar Qube tags - refs #297339 [Alin Voinea - [`89ca2ae`](https://github.com/eea/volto-tabs-block/commit/89ca2ae4bc3821bed8012188e94930ae4457accf)]
|
|
7
25
|
### [9.1.0](https://github.com/eea/volto-tabs-block/compare/9.0.3...9.1.0) - 24 July 2025
|
|
8
26
|
|
|
9
27
|
#### :hammer_and_wrench: Others
|
|
10
28
|
|
|
11
29
|
- Release 9.1.0 [Alin Voinea - [`4396e37`](https://github.com/eea/volto-tabs-block/commit/4396e3740694d99cbb66414783c3fbbef7ed2022)]
|
|
30
|
+
- Add Sonarqube tag using clms-frontend addons list [EEA Jenkins - [`20aaf70`](https://github.com/eea/volto-tabs-block/commit/20aaf70fec13c977a805caeec043457867e62c36)]
|
|
31
|
+
- Add Sonarqube tag using clms-frontend addons list [EEA Jenkins - [`d516041`](https://github.com/eea/volto-tabs-block/commit/d516041244ee793504833b38033e75df20a8fa13)]
|
|
32
|
+
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`ae5b123`](https://github.com/eea/volto-tabs-block/commit/ae5b123036ab3ec9d225228206016d78ab6dcaa4)]
|
|
33
|
+
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`74fb410`](https://github.com/eea/volto-tabs-block/commit/74fb410ec9e3657e55fc5ea35c6717a737ddc375)]
|
|
12
34
|
### [9.0.3](https://github.com/eea/volto-tabs-block/compare/9.0.2...9.0.3) - 7 May 2025
|
|
13
35
|
|
|
14
36
|
#### :bug: Bug Fixes
|
|
@@ -17,6 +39,8 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
17
39
|
|
|
18
40
|
#### :hammer_and_wrench: Others
|
|
19
41
|
|
|
42
|
+
- Add Sonarqube tag using clms-frontend addons list [EEA Jenkins - [`01b5632`](https://github.com/eea/volto-tabs-block/commit/01b563271bd04f4329d9f876278324b970443413)]
|
|
43
|
+
- Add Sonarqube tag using ied-frontend addons list [EEA Jenkins - [`d457e25`](https://github.com/eea/volto-tabs-block/commit/d457e25d8a97b080eb8eb32ae4b85db530049e96)]
|
|
20
44
|
### [9.0.2](https://github.com/eea/volto-tabs-block/compare/9.0.1...9.0.2) - 27 January 2025
|
|
21
45
|
|
|
22
46
|
#### :house: Internal changes
|
|
@@ -67,6 +91,8 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
67
91
|
|
|
68
92
|
#### :hammer_and_wrench: Others
|
|
69
93
|
|
|
94
|
+
- Add Sonarqube tag using insitu-frontend addons list [EEA Jenkins - [`cb58ea7`](https://github.com/eea/volto-tabs-block/commit/cb58ea7417e8dd237b66908fd53f1f3ca8726566)]
|
|
95
|
+
- Add Sonarqube tag using freshwater-frontend addons list [EEA Jenkins - [`4377ffc`](https://github.com/eea/volto-tabs-block/commit/4377ffc350a92f62cbe77b17b67dd331c71cbcd7)]
|
|
70
96
|
### [7.5.1](https://github.com/eea/volto-tabs-block/compare/7.5.0...7.5.1) - 28 March 2024
|
|
71
97
|
|
|
72
98
|
#### :nail_care: Enhancements
|
|
@@ -109,6 +135,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
109
135
|
- Update react-slick version to 0.30.1 [David Ichim - [`3369176`](https://github.com/eea/volto-tabs-block/commit/33691768899e7f91d2cd15319dbe3ebe66cf1513)]
|
|
110
136
|
- update [Razvan - [`61b19e8`](https://github.com/eea/volto-tabs-block/commit/61b19e8584ff6023320b3671414392ea11449ff0)]
|
|
111
137
|
- use DefaultEdit variation for responsive accordion, refs #266327 [Razvan - [`11acf6c`](https://github.com/eea/volto-tabs-block/commit/11acf6ce5afe022ddd30bff42c9a3321d1284da6)]
|
|
138
|
+
- Add Sonarqube tag using insitu-frontend addons list [EEA Jenkins - [`5045757`](https://github.com/eea/volto-tabs-block/commit/5045757a275477ba382551b301998d835741b716)]
|
|
112
139
|
### [7.0.5](https://github.com/eea/volto-tabs-block/compare/7.0.4...7.0.5) - 10 December 2023
|
|
113
140
|
|
|
114
141
|
#### :rocket: New Features
|
|
@@ -140,6 +167,8 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
140
167
|
|
|
141
168
|
#### :hammer_and_wrench: Others
|
|
142
169
|
|
|
170
|
+
- test: [JENKINS] Use java17 for sonarqube scanner [valentinab25 - [`3b87d12`](https://github.com/eea/volto-tabs-block/commit/3b87d12df4d01031231b15eb4196f6ff6937706b)]
|
|
171
|
+
- test: [JENKINS] Run cypress in started frontend container [valentinab25 - [`f5f3430`](https://github.com/eea/volto-tabs-block/commit/f5f343024b45bb0206e0169cce6dd0e8472b6795)]
|
|
143
172
|
### [7.0.1](https://github.com/eea/volto-tabs-block/compare/7.0.0...7.0.1) - 9 November 2023
|
|
144
173
|
|
|
145
174
|
#### :bug: Bug Fixes
|
|
@@ -149,10 +178,14 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
149
178
|
|
|
150
179
|
#### :hammer_and_wrench: Others
|
|
151
180
|
|
|
181
|
+
- test: [JENKINS] Add cpu limit on cypress docker [valentinab25 - [`bd6ffd4`](https://github.com/eea/volto-tabs-block/commit/bd6ffd42a00a2d77ff59545d9adaab7a45361446)]
|
|
182
|
+
- test: [JENKINS] Increase shm-size to cypress docker [valentinab25 - [`d481e25`](https://github.com/eea/volto-tabs-block/commit/d481e25c4d61d7ff6ea11ff75c99fbdd730ecd82)]
|
|
183
|
+
- test: [JENKINS] Improve cypress time [valentinab25 - [`6c39efc`](https://github.com/eea/volto-tabs-block/commit/6c39efcc30bddfebb6c61f8a8cd714f61828ec69)]
|
|
152
184
|
## [7.0.0](https://github.com/eea/volto-tabs-block/compare/6.0.3...7.0.0) - 31 October 2023
|
|
153
185
|
|
|
154
186
|
#### :house: Internal changes
|
|
155
187
|
|
|
188
|
+
- chore: [JENKINS] Refactor automated testing [valentinab25 - [`f2e3d39`](https://github.com/eea/volto-tabs-block/commit/f2e3d3973c026f0331b82e0f691ec9bdc5899672)]
|
|
156
189
|
|
|
157
190
|
#### :hammer_and_wrench: Others
|
|
158
191
|
|
|
@@ -365,6 +398,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
365
398
|
|
|
366
399
|
#### :house: Internal changes
|
|
367
400
|
|
|
401
|
+
- chore: [JENKINS] Deprecate circularity website [valentinab25 - [`820aaa9`](https://github.com/eea/volto-tabs-block/commit/820aaa963e978a893a23b77f694bb011f3d768c1)]
|
|
368
402
|
|
|
369
403
|
#### :hammer_and_wrench: Others
|
|
370
404
|
|
|
@@ -455,6 +489,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
455
489
|
|
|
456
490
|
#### :hammer_and_wrench: Others
|
|
457
491
|
|
|
492
|
+
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`52bc1b0`](https://github.com/eea/volto-tabs-block/commit/52bc1b0fbd4611173b8ca9dc2cf4033b31474420)]
|
|
458
493
|
## [4.0.0](https://github.com/eea/volto-tabs-block/compare/3.0.1...4.0.0) - 10 March 2023
|
|
459
494
|
|
|
460
495
|
#### :house: Internal changes
|
|
@@ -465,7 +500,13 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
465
500
|
#### :hammer_and_wrench: Others
|
|
466
501
|
|
|
467
502
|
- Release 4.0.0 [Alin Voinea - [`8fc4cc9`](https://github.com/eea/volto-tabs-block/commit/8fc4cc9d8dc71e623e6586b95871cb3b98dc385f)]
|
|
503
|
+
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`22d5bdc`](https://github.com/eea/volto-tabs-block/commit/22d5bdc1b3579cc46c73ce855041ca09154eb502)]
|
|
504
|
+
- Add Sonarqube tag using advisory-board-frontend addons list [EEA Jenkins - [`fde4324`](https://github.com/eea/volto-tabs-block/commit/fde4324f962cde8e8de0d76a44bee4b67d216bf8)]
|
|
505
|
+
- Add Sonarqube tag using advisory-board-frontend addons list [EEA Jenkins - [`9175e47`](https://github.com/eea/volto-tabs-block/commit/9175e470d793edc63b62a99940aed25dd45f3713)]
|
|
468
506
|
- test(Jenkins): Run tests and cypress with latest canary @plone/volto [Alin Voinea - [`3348950`](https://github.com/eea/volto-tabs-block/commit/334895036f8e367281abb35a20879c32dfbfc292)]
|
|
507
|
+
- Add Sonarqube tag using cca-frontend addons list [EEA Jenkins - [`39bfb39`](https://github.com/eea/volto-tabs-block/commit/39bfb39fa6e8483e639491ff998293e758ac6384)]
|
|
508
|
+
- yarn 3 [Alin Voinea - [`7e98df5`](https://github.com/eea/volto-tabs-block/commit/7e98df59669d71945be461e86e282b913538b805)]
|
|
509
|
+
- Add Sonarqube tag using demo-kitkat-frontend addons list [EEA Jenkins - [`079d7a4`](https://github.com/eea/volto-tabs-block/commit/079d7a43480e92fe280a9372399ff2d4d28537ae)]
|
|
469
510
|
### [3.0.1](https://github.com/eea/volto-tabs-block/compare/3.0.0...3.0.1) - 16 November 2022
|
|
470
511
|
|
|
471
512
|
#### :hammer_and_wrench: Others
|
|
@@ -489,7 +530,9 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
489
530
|
|
|
490
531
|
#### :hammer_and_wrench: Others
|
|
491
532
|
|
|
533
|
+
- Add Sonarqube tag using marine-frontend addons list [EEA Jenkins - [`a00e419`](https://github.com/eea/volto-tabs-block/commit/a00e419aef4c82a25f277f5e25e3d512c7838264)]
|
|
492
534
|
- lint fix [David Ichim - [`c0a898c`](https://github.com/eea/volto-tabs-block/commit/c0a898c54461478baed2ac2f149ae580d4c89aeb)]
|
|
535
|
+
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`3b284e6`](https://github.com/eea/volto-tabs-block/commit/3b284e65e0eafa9b5ad8c92b4cb77628ffcc8103)]
|
|
493
536
|
### [2.2.0](https://github.com/eea/volto-tabs-block/compare/2.1.0...2.2.0) - 25 August 2022
|
|
494
537
|
|
|
495
538
|
#### :hammer_and_wrench: Others
|
|
@@ -505,6 +548,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
505
548
|
|
|
506
549
|
- Release 2.1.0 [Alin Voinea - [`3cdfa30`](https://github.com/eea/volto-tabs-block/commit/3cdfa30d4d03d864be8ad63f0648b4717298734a)]
|
|
507
550
|
- Squashed commit of the following: [Alin Voinea - [`ca241f5`](https://github.com/eea/volto-tabs-block/commit/ca241f56a96817679a1948154e2a8cc0e17b96fe)]
|
|
551
|
+
- Add Sonarqube tag using circularity-frontend addons list [EEA Jenkins - [`68ea5a6`](https://github.com/eea/volto-tabs-block/commit/68ea5a6b971fc36840cf5716a04f68316b229b2b)]
|
|
508
552
|
### [2.0.2](https://github.com/eea/volto-tabs-block/compare/2.0.1...2.0.2) - 16 June 2022
|
|
509
553
|
|
|
510
554
|
### [2.0.1](https://github.com/eea/volto-tabs-block/compare/2.0.0...2.0.1) - 10 June 2022
|
|
@@ -548,6 +592,8 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
548
592
|
- Let theme addon to set default values for default template schema [Miu Razvan - [`55f148d`](https://github.com/eea/volto-tabs-block/commit/55f148d1a95417f8a0b55681ce250acde8463c1c)]
|
|
549
593
|
- Render pane as container if tabs-block has full-width class [Miu Razvan - [`bbffb96`](https://github.com/eea/volto-tabs-block/commit/bbffb96b908476ddee447af3ce79bafb1a12f9a8)]
|
|
550
594
|
- Refactor default template [Miu Razvan - [`58eff52`](https://github.com/eea/volto-tabs-block/commit/58eff5281adb08a5f8fe6d21fd43330252012277)]
|
|
595
|
+
- Add Sonarqube tag using clms-frontend addons list [EEA Jenkins - [`72a6735`](https://github.com/eea/volto-tabs-block/commit/72a6735cbbc0e7d57b4bb7ea83fea9becc317018)]
|
|
596
|
+
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`e928da1`](https://github.com/eea/volto-tabs-block/commit/e928da1df7e4680bd4be9b5d46406800d721b8c5)]
|
|
551
597
|
### [1.2.12](https://github.com/eea/volto-tabs-block/compare/1.2.11...1.2.12) - 21 January 2022
|
|
552
598
|
|
|
553
599
|
### [1.2.11](https://github.com/eea/volto-tabs-block/compare/1.2.10...1.2.11) - 4 January 2022
|
|
@@ -562,11 +608,17 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
562
608
|
|
|
563
609
|
#### :hammer_and_wrench: Others
|
|
564
610
|
|
|
611
|
+
- Add Sonarqube tag using freshwater-frontend addons list [EEA Jenkins - [`cd2e2ac`](https://github.com/eea/volto-tabs-block/commit/cd2e2ac1d127bfc688ecf16e17734603ab727a34)]
|
|
565
612
|
### [1.2.8](https://github.com/eea/volto-tabs-block/compare/1.2.7...1.2.8) - 10 December 2021
|
|
566
613
|
|
|
567
614
|
#### :hammer_and_wrench: Others
|
|
568
615
|
|
|
569
616
|
- Refs #142010 - Optimize Volto-addons gitflow pipelines [valentinab25 - [`d10c0b3`](https://github.com/eea/volto-tabs-block/commit/d10c0b3d35d25c530d19eebde38dfe5da8fda01b)]
|
|
617
|
+
- Add Sonarqube tag using industry-frontend addons list [EEA Jenkins - [`1a7187f`](https://github.com/eea/volto-tabs-block/commit/1a7187f10b2bd9e1307dabf51823f63ccd766864)]
|
|
618
|
+
- Add Sonarqube tag using clms-frontend addons list [EEA Jenkins - [`72a7550`](https://github.com/eea/volto-tabs-block/commit/72a755025b38e1d8dd7fe206273a70585e4b9ac8)]
|
|
619
|
+
- Add Sonarqube tag using forests-frontend addons list [EEA Jenkins - [`022b277`](https://github.com/eea/volto-tabs-block/commit/022b2779a5d7fd7217c2d8a559eafab0bd86ce23)]
|
|
620
|
+
- Add Sonarqube tag using sustainability-frontend addons list [EEA Jenkins - [`84c9bea`](https://github.com/eea/volto-tabs-block/commit/84c9bea7a0aba2fe9ef9713e7131de6da6e0bcce)]
|
|
621
|
+
- Add Sonarqube tag using ims-frontend addons list [EEA Jenkins - [`020aa97`](https://github.com/eea/volto-tabs-block/commit/020aa97bc70a643ea3857566c5a1dc3a5200c2be)]
|
|
570
622
|
### [1.2.7](https://github.com/eea/volto-tabs-block/compare/1.2.6...1.2.7) - 27 August 2021
|
|
571
623
|
|
|
572
624
|
#### :hammer_and_wrench: Others
|
|
@@ -583,6 +635,8 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
583
635
|
|
|
584
636
|
- Move less import in View instead of Edit [Tiberiu Ichim - [`84aeff0`](https://github.com/eea/volto-tabs-block/commit/84aeff04a980076f54687c546691d37b6e790478)]
|
|
585
637
|
- gitignore tweaks [Tiberiu Ichim - [`f4c993d`](https://github.com/eea/volto-tabs-block/commit/f4c993d004b126f08f16651ab9460546fa9e9cad)]
|
|
638
|
+
- Add Sonarqube tag using frontend addons list [EEA Jenkins - [`865906a`](https://github.com/eea/volto-tabs-block/commit/865906a0deb261d44cc23e26bfd2d1dd0e319640)]
|
|
639
|
+
- Add Sonarqube tag using frontend addons list [EEA Jenkins - [`5383861`](https://github.com/eea/volto-tabs-block/commit/538386100adbc868e693c1c2a5ba13461307ffee)]
|
|
586
640
|
- Style update [razvanMiu - [`323aaaf`](https://github.com/eea/volto-tabs-block/commit/323aaafcad01d8fdf0e713a1fc254ae9fe319f43)]
|
|
587
641
|
- Fix 'scroll to' feature on carousel [razvanMiu - [`16c6a08`](https://github.com/eea/volto-tabs-block/commit/16c6a08f6db687542ea38e07a92b265e592f6173)]
|
|
588
642
|
- Better accesibility [razvanMiu - [`3511611`](https://github.com/eea/volto-tabs-block/commit/351161197270a4807f01d85a7055cbaadae72f8e)]
|
package/DEVELOP.md
CHANGED
|
@@ -26,21 +26,20 @@
|
|
|
26
26
|
|
|
27
27
|
### Or add @eeacms/volto-tabs-block to your Volto project
|
|
28
28
|
|
|
29
|
-
Before starting make sure your development environment is properly set. See [Volto
|
|
29
|
+
Before starting make sure your development environment is properly set. See the official Plone documentation for [creating a project with Cookieplone](https://6.docs.plone.org/install/create-project-cookieplone.html) and [installing an add-on in development mode in Volto 18 and 19](https://6.docs.plone.org/volto/development/add-ons/install-an-add-on-dev-18.html).
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
For new Volto 18+ projects, use Cookieplone. It includes `mrs-developer` by default.
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
1. Create a new Volto project with Cookieplone
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
yo @plone/volto my-volto-project --addon @eeacms/volto-tabs-block --skip-install
|
|
38
|
-
cd my-volto-project
|
|
35
|
+
uvx cookieplone project
|
|
36
|
+
cd project-title
|
|
39
37
|
|
|
40
38
|
1. Add the following to `mrs.developer.json`:
|
|
41
39
|
|
|
42
40
|
{
|
|
43
41
|
"volto-tabs-block": {
|
|
42
|
+
"output": "packages",
|
|
44
43
|
"url": "https://github.com/eea/volto-tabs-block.git",
|
|
45
44
|
"package": "@eeacms/volto-tabs-block",
|
|
46
45
|
"branch": "develop",
|
|
@@ -48,28 +47,31 @@ Before starting make sure your development environment is properly set. See [Vol
|
|
|
48
47
|
}
|
|
49
48
|
}
|
|
50
49
|
|
|
51
|
-
1.
|
|
50
|
+
1. Add `@eeacms/volto-tabs-block` to the `addons` key in your project `volto.config.js`
|
|
51
|
+
|
|
52
|
+
1. Install or refresh the project setup
|
|
52
53
|
|
|
53
|
-
make
|
|
54
|
-
yarn
|
|
54
|
+
make install
|
|
55
55
|
|
|
56
|
-
1. Start backend
|
|
56
|
+
1. Start backend in one terminal
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
make backend-start
|
|
59
59
|
|
|
60
|
-
...wait for backend to setup and start
|
|
60
|
+
...wait for backend to setup and start, ending with `Ready to handle requests`
|
|
61
61
|
|
|
62
62
|
...you can also check http://localhost:8080/Plone
|
|
63
63
|
|
|
64
|
-
1. Start frontend
|
|
64
|
+
1. Start frontend in a second terminal
|
|
65
65
|
|
|
66
|
-
|
|
66
|
+
make frontend-start
|
|
67
67
|
|
|
68
68
|
1. Go to http://localhost:3000
|
|
69
69
|
|
|
70
70
|
1. Happy hacking!
|
|
71
71
|
|
|
72
|
-
cd
|
|
72
|
+
cd packages/volto-tabs-block
|
|
73
|
+
|
|
74
|
+
For legacy Volto 17 projects, keep using the yarn-based workflow from the Volto 17 documentation.
|
|
73
75
|
|
|
74
76
|
## Cypress
|
|
75
77
|
|
|
@@ -81,7 +83,7 @@ project where you added `volto-tabs-block` to `mrs.developer.json`
|
|
|
81
83
|
Go to:
|
|
82
84
|
|
|
83
85
|
```BASH
|
|
84
|
-
cd
|
|
86
|
+
cd packages/volto-tabs-block/
|
|
85
87
|
```
|
|
86
88
|
|
|
87
89
|
Start:
|
package/README.md
CHANGED
|
@@ -3,16 +3,16 @@
|
|
|
3
3
|
[](https://github.com/eea/volto-tabs-block/releases)
|
|
4
4
|
|
|
5
5
|
[](https://ci.eionet.europa.eu/view/Github/job/volto-addons/job/volto-tabs-block/job/master/display/redirect)
|
|
6
|
-
[](https://sonarqube.eea.europa.eu/api/project_badges/measure?project=volto-tabs-block
|
|
6
|
+
[](https://sonarqube.eea.europa.eu/dashboard?id=volto-tabs-block)
|
|
7
|
+
[](https://sonarqube.eea.europa.eu/dashboard?id=volto-tabs-block)
|
|
8
|
+
[](https://sonarqube.eea.europa.eu/dashboard?id=volto-tabs-block)
|
|
9
|
+
[](https://sonarqube.eea.europa.eu/dashboard?id=volto-tabs-block)
|
|
10
10
|
|
|
11
11
|
[](https://ci.eionet.europa.eu/view/Github/job/volto-addons/job/volto-tabs-block/job/develop/display/redirect)
|
|
12
|
-
[](https://sonarqube.eea.europa.eu/api/project_badges/measure?project=volto-tabs-block
|
|
12
|
+
[](https://sonarqube.eea.europa.eu/dashboard?id=volto-tabs-block&branch=develop)
|
|
13
|
+
[](https://sonarqube.eea.europa.eu/dashboard?id=volto-tabs-block&branch=develop)
|
|
14
|
+
[](https://sonarqube.eea.europa.eu/dashboard?id=volto-tabs-block&branch=develop)
|
|
15
|
+
[](https://sonarqube.eea.europa.eu/dashboard?id=volto-tabs-block&branch=develop)
|
|
16
16
|
|
|
17
17
|
[Volto](https://github.com/plone/volto) add-on
|
|
18
18
|
|
|
@@ -35,6 +35,11 @@
|
|
|
35
35
|
|
|
36
36
|
Go to http://localhost:3000
|
|
37
37
|
|
|
38
|
+
`make start` now defaults to Volto 18. To run the same setup against Volto 17, use:
|
|
39
|
+
|
|
40
|
+
VOLTO_VERSION=17 make
|
|
41
|
+
VOLTO_VERSION=17 make start
|
|
42
|
+
|
|
38
43
|
### Add volto-tabs-block to your Volto project
|
|
39
44
|
|
|
40
45
|
1. Make sure you have a [Plone backend](https://plone.org/download) up-and-running at http://localhost:8080/Plone
|
|
@@ -48,35 +53,62 @@ Go to http://localhost:3000
|
|
|
48
53
|
* If you already have a volto project, just update `package.json`:
|
|
49
54
|
|
|
50
55
|
```JSON
|
|
51
|
-
"addons": [
|
|
52
|
-
"@eeacms/volto-tabs-block"
|
|
53
|
-
],
|
|
54
|
-
|
|
55
56
|
"dependencies": {
|
|
56
57
|
"@eeacms/volto-tabs-block": "*"
|
|
57
58
|
}
|
|
58
59
|
```
|
|
59
60
|
|
|
60
|
-
|
|
61
|
+
and `volto.config.js`:
|
|
62
|
+
|
|
63
|
+
```JavaScript
|
|
64
|
+
const addons = ['@eeacms/volto-tabs-block'];
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
* If not, create one with Cookieplone, as recommended by the official Plone documentation for Volto 18+:
|
|
61
68
|
|
|
62
69
|
```
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
cd my-volto-project
|
|
70
|
+
uvx cookieplone project
|
|
71
|
+
cd project-title
|
|
66
72
|
```
|
|
67
73
|
|
|
68
|
-
|
|
74
|
+
Then install the add-on in your frontend project. For Cookieplone-based Volto 18 and 19 projects, Plone documents `pnpm` usage:
|
|
75
|
+
|
|
76
|
+
```
|
|
77
|
+
pnpm --filter <name-of-your-policy-add-on> add @eeacms/volto-tabs-block
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Then add `@eeacms/volto-tabs-block` to the `addons` key in your project's `package.json` or declare it in `volto.config.js`.
|
|
81
|
+
|
|
82
|
+
1. Install or update dependencies, then start the project:
|
|
69
83
|
|
|
70
84
|
```
|
|
71
|
-
|
|
72
|
-
yarn start
|
|
85
|
+
make install
|
|
73
86
|
```
|
|
74
87
|
|
|
88
|
+
For a Cookieplone project, start the backend and frontend in separate terminals:
|
|
89
|
+
|
|
90
|
+
```
|
|
91
|
+
make backend-start
|
|
92
|
+
make frontend-start
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
For a legacy Volto 17 project, install the package with `yarn` and restart the frontend as usual.
|
|
96
|
+
|
|
75
97
|
1. Go to http://localhost:3000
|
|
76
98
|
|
|
77
99
|
1. Happy editing!
|
|
78
100
|
|
|
79
101
|
## Upgrade
|
|
102
|
+
|
|
103
|
+
### Upgrading to 10.x
|
|
104
|
+
|
|
105
|
+
> This version requires `Volto >= 17.18` or `Volto 18+`. It removes the custom `EditBlockWrapper` and uses Volto's built-in block chrome provided by `BlocksForm`.
|
|
106
|
+
|
|
107
|
+
#### Breaking changes
|
|
108
|
+
|
|
109
|
+
- **Removed `EditBlockWrapper.jsx`.** Any code importing `EditBlockWrapper` from `@eeacms/volto-tabs-block` will break. Use Volto's built-in `EditBlockWrapper` from `@plone/volto/components/manage/Blocks/Block/EditBlockWrapper` if you need a custom wrapper.
|
|
110
|
+
- **Removed custom edit toolbar styles.** The `edit.less` styles that powered the custom inner block toolbar have been removed. Inner blocks now use Volto's default block chrome.
|
|
111
|
+
|
|
80
112
|
### Upgrading to 7.0.0
|
|
81
113
|
Version 7 introduces the following breaking changes:
|
|
82
114
|
- The templates are now `variations` of the default template, so if you have custom templates,
|
package/cypress.config.js
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
const { defineConfig } = require('cypress');
|
|
2
2
|
|
|
3
|
+
const apiPath =
|
|
4
|
+
process.env.CYPRESS_API_PATH ||
|
|
5
|
+
process.env.RAZZLE_DEV_PROXY_API_PATH ||
|
|
6
|
+
process.env.RAZZLE_INTERNAL_API_PATH ||
|
|
7
|
+
'http://localhost:8080/Plone';
|
|
8
|
+
|
|
3
9
|
module.exports = defineConfig({
|
|
4
10
|
viewportWidth: 1280,
|
|
5
|
-
defaultCommandTimeout:
|
|
11
|
+
defaultCommandTimeout: 8888,
|
|
6
12
|
chromeWebSecurity: false,
|
|
13
|
+
env: {
|
|
14
|
+
API_PATH: apiPath,
|
|
15
|
+
},
|
|
7
16
|
reporter: 'junit',
|
|
8
17
|
video: false,
|
|
9
18
|
retries: {
|
package/docker-compose.yml
CHANGED
package/jest-addon.config.js
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
require('dotenv').config({ path: __dirname + '/.env' })
|
|
2
|
+
const fs = require('fs')
|
|
3
|
+
const path = require('path')
|
|
4
|
+
|
|
5
|
+
const voltoSlatePath = fs.existsSync(
|
|
6
|
+
path.join(__dirname, '../../../node_modules/@plone/volto-slate/src'),
|
|
7
|
+
)
|
|
8
|
+
? '<rootDir>/node_modules/@plone/volto-slate/src'
|
|
9
|
+
: '<rootDir>/node_modules/@plone/volto/packages/volto-slate/src'
|
|
2
10
|
|
|
3
11
|
module.exports = {
|
|
4
12
|
testMatch: ['**/src/addons/**/?(*.)+(spec|test).[jt]s?(x)'],
|
|
@@ -17,10 +25,8 @@ module.exports = {
|
|
|
17
25
|
'@eeacms/search/(.*)$': '<rootDir>/src/addons/volto-searchlib/searchlib/$1',
|
|
18
26
|
'@eeacms/search': '<rootDir>/src/addons/volto-searchlib/searchlib',
|
|
19
27
|
'@eeacms/(.*?)/(.*)$': '<rootDir>/node_modules/@eeacms/$1/src/$2',
|
|
20
|
-
'@plone/volto-slate$':
|
|
21
|
-
|
|
22
|
-
'@plone/volto-slate/(.*)$':
|
|
23
|
-
'<rootDir>/node_modules/@plone/volto/packages/volto-slate/src/$1',
|
|
28
|
+
'@plone/volto-slate$': voltoSlatePath,
|
|
29
|
+
'@plone/volto-slate/(.*)$': `${voltoSlatePath}/$1`,
|
|
24
30
|
'~/(.*)$': '<rootDir>/src/$1',
|
|
25
31
|
'load-volto-addons':
|
|
26
32
|
'<rootDir>/node_modules/@plone/volto/jest-addons-loader.js',
|
package/package.json
CHANGED
package/src/components/Edit.jsx
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
SidebarPortal,
|
|
7
|
-
BlocksToolbar,
|
|
8
|
-
BlockDataForm,
|
|
9
|
-
} from '@plone/volto/components';
|
|
10
|
-
import { getBlocksLayoutFieldname } from '@plone/volto/helpers';
|
|
1
|
+
import BlocksToolbar from '@plone/volto/components/manage/Form/BlocksToolbar';
|
|
2
|
+
import BlockDataForm from '@plone/volto/components/manage/Form/BlockDataForm';
|
|
3
|
+
import SidebarPortal from '@plone/volto/components/manage/Sidebar/SidebarPortal';
|
|
4
|
+
import { getBlocksLayoutFieldname } from '@plone/volto/helpers/Blocks/Blocks';
|
|
11
5
|
import { TABS_BLOCK } from '@eeacms/volto-tabs-block/constants';
|
|
12
6
|
import { empty, emptyTab } from '@eeacms/volto-tabs-block/helpers';
|
|
13
7
|
import { StyleWrapperView } from '@eeacms/volto-block-style/StyleWrapper';
|
|
14
8
|
import { BlockStyleWrapperEdit } from '@eeacms/volto-block-style/BlockStyleWrapper';
|
|
15
9
|
import { getVariation } from '@eeacms/volto-tabs-block/helpers';
|
|
16
10
|
import { DefaultEdit } from './variations/default';
|
|
11
|
+
import config from '@plone/volto/registry';
|
|
12
|
+
import cx from 'classnames';
|
|
13
|
+
import without from 'lodash/without';
|
|
14
|
+
import React from 'react';
|
|
17
15
|
import { useIntl } from 'react-intl';
|
|
18
16
|
|
|
19
17
|
import '@eeacms/volto-tabs-block/less/edit.less';
|
|
@@ -212,7 +210,7 @@ const Edit = (props) => {
|
|
|
212
210
|
{props.selected ? (
|
|
213
211
|
<BlocksToolbar
|
|
214
212
|
formData={tabData}
|
|
215
|
-
selectedBlock={
|
|
213
|
+
selectedBlock={activeBlock}
|
|
216
214
|
selectedBlocks={multiSelected}
|
|
217
215
|
onChangeBlocks={(newBlockData) => {
|
|
218
216
|
onChangeBlock(block, {
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { fireEvent, render, screen } from '@testing-library/react';
|
|
3
|
+
import '@testing-library/jest-dom';
|
|
4
|
+
import configureStore from 'redux-mock-store';
|
|
5
|
+
import { Provider } from 'react-intl-redux';
|
|
6
|
+
import { MemoryRouter } from 'react-router-dom';
|
|
7
|
+
import config from '@plone/volto/registry';
|
|
8
|
+
import Edit from './Edit';
|
|
9
|
+
import { TABS_BLOCK } from '@eeacms/volto-tabs-block/constants';
|
|
10
|
+
|
|
11
|
+
jest.mock('uuid', () => ({
|
|
12
|
+
v4: () => 'test-uuid-1234',
|
|
13
|
+
}));
|
|
14
|
+
|
|
15
|
+
jest.mock(
|
|
16
|
+
'@eeacms/volto-tabs-block/constants',
|
|
17
|
+
() => ({
|
|
18
|
+
TABS_BLOCK: 'tabs_block',
|
|
19
|
+
}),
|
|
20
|
+
{ virtual: true },
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
jest.mock(
|
|
24
|
+
'@eeacms/volto-tabs-block/helpers',
|
|
25
|
+
() => ({
|
|
26
|
+
empty: jest.fn(),
|
|
27
|
+
emptyTab: jest.fn(() => ({})),
|
|
28
|
+
getVariation: jest.fn(() => 'default'),
|
|
29
|
+
}),
|
|
30
|
+
{ virtual: true },
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
jest.mock(
|
|
34
|
+
'@eeacms/volto-tabs-block/components',
|
|
35
|
+
() => ({
|
|
36
|
+
AssetTab: ({ tabTitle }) => <span>{tabTitle}</span>,
|
|
37
|
+
}),
|
|
38
|
+
{ virtual: true },
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
jest.mock(
|
|
42
|
+
'@eeacms/volto-tabs-block/components/variations/default/schema',
|
|
43
|
+
() => ({
|
|
44
|
+
defaultSchemaEnhancer: jest.fn(({ schema }) => schema),
|
|
45
|
+
}),
|
|
46
|
+
{ virtual: true },
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
jest.mock(
|
|
50
|
+
'@eeacms/volto-tabs-block/utils',
|
|
51
|
+
() => ({
|
|
52
|
+
SimpleMarkdown: ({ md, className }) => (
|
|
53
|
+
<div className={className}>{md}</div>
|
|
54
|
+
),
|
|
55
|
+
getMenuPosition: () => ({}),
|
|
56
|
+
}),
|
|
57
|
+
{ virtual: true },
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
jest.mock('@eeacms/volto-tabs-block/less/edit.less', () => ({}), {
|
|
61
|
+
virtual: true,
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
jest.mock('@eeacms/volto-tabs-block/less/tabs.less', () => ({}), {
|
|
65
|
+
virtual: true,
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
jest.mock('@eeacms/volto-tabs-block/less/menu.less', () => ({}), {
|
|
69
|
+
virtual: true,
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
jest.mock('./variations/default', () => ({
|
|
73
|
+
DefaultEdit: jest.requireActual('./variations/default/Edit').default,
|
|
74
|
+
}));
|
|
75
|
+
|
|
76
|
+
jest.mock('@plone/volto/components/manage/Sidebar/SidebarPortal', () => ({
|
|
77
|
+
__esModule: true,
|
|
78
|
+
default: ({ children }) => <div>{children}</div>,
|
|
79
|
+
}));
|
|
80
|
+
|
|
81
|
+
jest.mock('@plone/volto/components/manage/Blocks/Block/BlocksForm', () => ({
|
|
82
|
+
__esModule: true,
|
|
83
|
+
default: jest.fn(
|
|
84
|
+
({ multiSelected, onSelectBlock, properties, selectedBlock }) => {
|
|
85
|
+
const blockList = properties.blocks
|
|
86
|
+
? Object.entries(properties.blocks)
|
|
87
|
+
: [];
|
|
88
|
+
|
|
89
|
+
return (
|
|
90
|
+
<div
|
|
91
|
+
data-testid={`blocks-form-${properties.title || 'untitled'}`}
|
|
92
|
+
data-multi-selected={(multiSelected || []).join(',')}
|
|
93
|
+
data-selected-block={selectedBlock || ''}
|
|
94
|
+
>
|
|
95
|
+
{blockList.map(([blockId]) => (
|
|
96
|
+
<button
|
|
97
|
+
key={blockId}
|
|
98
|
+
type="button"
|
|
99
|
+
aria-label={`Select ${blockId}`}
|
|
100
|
+
onClick={(event) => onSelectBlock?.(blockId, null, event)}
|
|
101
|
+
>
|
|
102
|
+
Select {blockId}
|
|
103
|
+
</button>
|
|
104
|
+
))}
|
|
105
|
+
</div>
|
|
106
|
+
);
|
|
107
|
+
},
|
|
108
|
+
),
|
|
109
|
+
}));
|
|
110
|
+
|
|
111
|
+
jest.mock('@plone/volto/components/manage/Form/BlocksToolbar', () => ({
|
|
112
|
+
__esModule: true,
|
|
113
|
+
default: ({ selectedBlock, selectedBlocks }) => (
|
|
114
|
+
<div
|
|
115
|
+
data-testid="blocks-toolbar"
|
|
116
|
+
data-selected-block={selectedBlock || ''}
|
|
117
|
+
data-selected-blocks={(selectedBlocks || []).join(',')}
|
|
118
|
+
/>
|
|
119
|
+
),
|
|
120
|
+
}));
|
|
121
|
+
|
|
122
|
+
jest.mock('@plone/volto/components/manage/Form/BlockDataForm', () => ({
|
|
123
|
+
__esModule: true,
|
|
124
|
+
default: () => <div>BlockDataForm</div>,
|
|
125
|
+
}));
|
|
126
|
+
|
|
127
|
+
jest.mock(
|
|
128
|
+
'@eeacms/volto-block-style/StyleWrapper',
|
|
129
|
+
() => ({
|
|
130
|
+
StyleWrapperView: ({ children }) => <>{children}</>,
|
|
131
|
+
}),
|
|
132
|
+
{ virtual: true },
|
|
133
|
+
);
|
|
134
|
+
|
|
135
|
+
jest.mock(
|
|
136
|
+
'@eeacms/volto-block-style/BlockStyleWrapper',
|
|
137
|
+
() => ({
|
|
138
|
+
BlockStyleWrapperEdit: ({ children }) => <>{children}</>,
|
|
139
|
+
}),
|
|
140
|
+
{ virtual: true },
|
|
141
|
+
);
|
|
142
|
+
|
|
143
|
+
const mockStore = configureStore();
|
|
144
|
+
const store = mockStore({
|
|
145
|
+
intl: {
|
|
146
|
+
locale: 'en',
|
|
147
|
+
messages: {},
|
|
148
|
+
},
|
|
149
|
+
screen: {
|
|
150
|
+
page: {
|
|
151
|
+
width: 768,
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
const mockData = {
|
|
157
|
+
title: 'Tabs',
|
|
158
|
+
data: {
|
|
159
|
+
blocks: {
|
|
160
|
+
tab1: {
|
|
161
|
+
'@type': 'tab',
|
|
162
|
+
title: 'Tab 1',
|
|
163
|
+
blocks: {
|
|
164
|
+
block1: {
|
|
165
|
+
'@type': 'text',
|
|
166
|
+
},
|
|
167
|
+
block2: {
|
|
168
|
+
'@type': 'text',
|
|
169
|
+
},
|
|
170
|
+
},
|
|
171
|
+
blocks_layout: {
|
|
172
|
+
items: ['block1', 'block2'],
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
blocks_layout: {
|
|
177
|
+
items: ['tab1'],
|
|
178
|
+
},
|
|
179
|
+
},
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
describe('Tabs Edit', () => {
|
|
183
|
+
beforeEach(() => {
|
|
184
|
+
config.blocks.blocksConfig[TABS_BLOCK] = {
|
|
185
|
+
...config.blocks.blocksConfig[TABS_BLOCK],
|
|
186
|
+
blockSchema: () => ({
|
|
187
|
+
title: 'Tabs',
|
|
188
|
+
properties: {
|
|
189
|
+
data: {
|
|
190
|
+
schema: {},
|
|
191
|
+
},
|
|
192
|
+
},
|
|
193
|
+
}),
|
|
194
|
+
variations: [{ id: 'default' }],
|
|
195
|
+
};
|
|
196
|
+
config.settings = {
|
|
197
|
+
...config.settings,
|
|
198
|
+
defaultBlockType: 'text',
|
|
199
|
+
};
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
it('forwards nested multi selection and tracks the active inner block in the toolbar', () => {
|
|
203
|
+
render(
|
|
204
|
+
<Provider store={store}>
|
|
205
|
+
<MemoryRouter>
|
|
206
|
+
<Edit
|
|
207
|
+
block="tabs-block"
|
|
208
|
+
data={mockData}
|
|
209
|
+
onChangeBlock={jest.fn()}
|
|
210
|
+
onChangeField={jest.fn()}
|
|
211
|
+
selected={true}
|
|
212
|
+
setSidebarTab={jest.fn()}
|
|
213
|
+
blockNode={{ current: document.createElement('div') }}
|
|
214
|
+
/>
|
|
215
|
+
</MemoryRouter>
|
|
216
|
+
</Provider>,
|
|
217
|
+
);
|
|
218
|
+
|
|
219
|
+
fireEvent.click(screen.getByRole('button', { name: 'Select block1' }));
|
|
220
|
+
|
|
221
|
+
expect(screen.getByTestId('blocks-toolbar')).toHaveAttribute(
|
|
222
|
+
'data-selected-block',
|
|
223
|
+
'block1',
|
|
224
|
+
);
|
|
225
|
+
|
|
226
|
+
fireEvent.click(screen.getByRole('button', { name: 'Select block2' }), {
|
|
227
|
+
shiftKey: true,
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
expect(screen.getByTestId('blocks-form-Tab 1')).toHaveAttribute(
|
|
231
|
+
'data-multi-selected',
|
|
232
|
+
'block1,block2',
|
|
233
|
+
);
|
|
234
|
+
expect(screen.getByTestId('blocks-toolbar')).toHaveAttribute(
|
|
235
|
+
'data-selected-blocks',
|
|
236
|
+
'block1,block2',
|
|
237
|
+
);
|
|
238
|
+
});
|
|
239
|
+
});
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { render, fireEvent } from '@testing-library/react';
|
|
3
|
-
import { BrowserRouter as Router } from 'react-router-dom';
|
|
4
3
|
import View from './View';
|
|
5
4
|
import config from '@plone/volto/registry';
|
|
6
5
|
import configureStore from 'redux-mock-store';
|
|
7
6
|
import { Provider } from 'react-intl-redux';
|
|
8
|
-
import '@testing-library/jest-dom
|
|
7
|
+
import '@testing-library/jest-dom';
|
|
9
8
|
|
|
10
9
|
config.blocks.blocksConfig = {
|
|
11
10
|
tabs_block: {
|
|
@@ -76,9 +75,7 @@ describe('View Component', () => {
|
|
|
76
75
|
|
|
77
76
|
const { container, getByText } = render(
|
|
78
77
|
<Provider store={store}>
|
|
79
|
-
<
|
|
80
|
-
<View data={{ variation: 'default', data: customTabsData }} />
|
|
81
|
-
</Router>
|
|
78
|
+
<View data={{ variation: 'default', data: customTabsData }} />
|
|
82
79
|
</Provider>,
|
|
83
80
|
);
|
|
84
81
|
const tabItemsMenu = container.querySelectorAll(
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { TABS_BLOCK } from '@eeacms/volto-tabs-block/constants';
|
|
2
|
+
|
|
1
3
|
const blocksArray = (config) => {
|
|
2
|
-
|
|
4
|
+
const choices = Object.keys(config.blocks.blocksConfig)
|
|
3
5
|
.map((key) => {
|
|
4
6
|
if (config.blocks.blocksConfig[key]?.restricted) {
|
|
5
7
|
return false;
|
|
@@ -9,6 +11,12 @@ const blocksArray = (config) => {
|
|
|
9
11
|
}
|
|
10
12
|
})
|
|
11
13
|
.filter((val) => !!val);
|
|
14
|
+
|
|
15
|
+
if (!choices.some(([id]) => id === TABS_BLOCK)) {
|
|
16
|
+
choices.push([TABS_BLOCK, 'Tabs']);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return choices;
|
|
12
20
|
};
|
|
13
21
|
|
|
14
22
|
const layoutSchema = (config) => ({
|
|
@@ -72,7 +80,7 @@ const layoutSchema = (config) => ({
|
|
|
72
80
|
},
|
|
73
81
|
readOnlySettings: {
|
|
74
82
|
title: 'Read-only settings',
|
|
75
|
-
description: 'Disable editing on
|
|
83
|
+
description: 'Disable editing on tabs block settings',
|
|
76
84
|
type: 'boolean',
|
|
77
85
|
},
|
|
78
86
|
},
|
|
@@ -6,8 +6,8 @@ import cx from 'classnames';
|
|
|
6
6
|
import noop from 'lodash/noop';
|
|
7
7
|
|
|
8
8
|
import { Icon } from 'semantic-ui-react';
|
|
9
|
-
import
|
|
10
|
-
import
|
|
9
|
+
import VoltoIcon from '@plone/volto/components/theme/Icon/Icon';
|
|
10
|
+
import RenderBlocks from '@plone/volto/components/theme/View/RenderBlocks';
|
|
11
11
|
import config from '@plone/volto/registry';
|
|
12
12
|
|
|
13
13
|
import Tabs from 'react-responsive-tabs';
|
|
@@ -17,7 +17,7 @@ import { getParentTabFromHash } from '@eeacms/volto-tabs-block/helpers';
|
|
|
17
17
|
import { withScrollToTarget } from '@eeacms/volto-tabs-block/hocs';
|
|
18
18
|
|
|
19
19
|
import '@eeacms/volto-tabs-block/less/menu.less';
|
|
20
|
-
import { getVariation } from '
|
|
20
|
+
import { getVariation } from '@eeacms/volto-tabs-block/helpers';
|
|
21
21
|
|
|
22
22
|
class Tab extends React.Component {
|
|
23
23
|
render() {
|
|
@@ -2,7 +2,8 @@ import React from 'react';
|
|
|
2
2
|
import { withRouter } from 'react-router';
|
|
3
3
|
import loadable from '@loadable/component';
|
|
4
4
|
import cx from 'classnames';
|
|
5
|
-
import
|
|
5
|
+
import Icon from '@plone/volto/components/theme/Icon/Icon';
|
|
6
|
+
import RenderBlocks from '@plone/volto/components/theme/View/RenderBlocks';
|
|
6
7
|
|
|
7
8
|
import rightArrowSVG from '@eeacms/volto-tabs-block/icons/right-key.svg';
|
|
8
9
|
import leftArrowSVG from '@eeacms/volto-tabs-block/icons/left-key.svg';
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { withRouter } from 'react-router';
|
|
3
3
|
import loadable from '@loadable/component';
|
|
4
4
|
import cx from 'classnames';
|
|
5
|
-
import
|
|
5
|
+
import RenderBlocks from '@plone/volto/components/theme/View/RenderBlocks';
|
|
6
6
|
import 'slick-carousel/slick/slick.css';
|
|
7
7
|
import 'slick-carousel/slick/slick-theme.css';
|
|
8
8
|
import '@eeacms/volto-tabs-block/less/carousel.less';
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { useIntl } from 'react-intl';
|
|
3
|
-
import
|
|
3
|
+
import isEmpty from 'lodash/isEmpty';
|
|
4
4
|
import { v4 as uuid } from 'uuid';
|
|
5
5
|
import cx from 'classnames';
|
|
6
6
|
import { Menu, Tab, Input, Container } from 'semantic-ui-react';
|
|
7
|
-
import
|
|
8
|
-
import { emptyBlocksForm } from '@plone/volto/helpers';
|
|
9
|
-
import EditBlockWrapper from '@eeacms/volto-tabs-block/components/EditBlockWrapper';
|
|
7
|
+
import BlocksForm from '@plone/volto/components/manage/Blocks/Block/BlocksForm';
|
|
8
|
+
import { emptyBlocksForm } from '@plone/volto/helpers/Blocks/Blocks';
|
|
10
9
|
import { defaultSchemaEnhancer } from '@eeacms/volto-tabs-block/components/variations/default/schema';
|
|
11
10
|
import { AssetTab } from '@eeacms/volto-tabs-block/components';
|
|
12
11
|
import {
|
|
@@ -252,6 +251,7 @@ const Edit = (props) => {
|
|
|
252
251
|
metadata={metadata}
|
|
253
252
|
pathname={props.pathname}
|
|
254
253
|
properties={isEmpty(tabs[tab]) ? emptyBlocksForm() : tabs[tab]}
|
|
254
|
+
multiSelected={selected && activeTab === tab ? multiSelected : []}
|
|
255
255
|
selected={selected && activeTab === tab && activeBlock}
|
|
256
256
|
selectedBlock={
|
|
257
257
|
selected && activeTab === tab && activeBlock
|
|
@@ -290,19 +290,7 @@ const Edit = (props) => {
|
|
|
290
290
|
);
|
|
291
291
|
setEditingTab(null);
|
|
292
292
|
}}
|
|
293
|
-
|
|
294
|
-
{({ draginfo }, editBlock, blockProps) => {
|
|
295
|
-
return (
|
|
296
|
-
<EditBlockWrapper
|
|
297
|
-
blockProps={blockProps}
|
|
298
|
-
draginfo={draginfo}
|
|
299
|
-
multiSelected={multiSelected.includes(blockProps.block)}
|
|
300
|
-
>
|
|
301
|
-
{editBlock}
|
|
302
|
-
</EditBlockWrapper>
|
|
303
|
-
);
|
|
304
|
-
}}
|
|
305
|
-
</BlocksForm>
|
|
293
|
+
/>
|
|
306
294
|
</Tab.Pane>
|
|
307
295
|
);
|
|
308
296
|
},
|
|
@@ -3,14 +3,14 @@ import { compose } from 'redux';
|
|
|
3
3
|
import { withRouter } from 'react-router';
|
|
4
4
|
import cx from 'classnames';
|
|
5
5
|
import { Menu, Tab, Container, Icon, Image } from 'semantic-ui-react';
|
|
6
|
-
import
|
|
6
|
+
import RenderBlocks from '@plone/volto/components/theme/View/RenderBlocks';
|
|
7
7
|
import { withScrollToTarget } from '@eeacms/volto-tabs-block/hocs';
|
|
8
8
|
import {
|
|
9
9
|
SimpleMarkdown,
|
|
10
10
|
getMenuPosition,
|
|
11
11
|
} from '@eeacms/volto-tabs-block/utils';
|
|
12
12
|
|
|
13
|
-
import { isInternalURL, flattenToAppURL } from '@plone/volto/helpers';
|
|
13
|
+
import { isInternalURL, flattenToAppURL } from '@plone/volto/helpers/Url/Url';
|
|
14
14
|
|
|
15
15
|
import '@eeacms/volto-tabs-block/less/menu.less';
|
|
16
16
|
|
|
@@ -4,12 +4,11 @@ import { compose } from 'redux';
|
|
|
4
4
|
import { useIntl } from 'react-intl';
|
|
5
5
|
import { withRouter } from 'react-router';
|
|
6
6
|
import { v4 as uuid } from 'uuid';
|
|
7
|
-
import
|
|
7
|
+
import isEmpty from 'lodash/isEmpty';
|
|
8
8
|
import cx from 'classnames';
|
|
9
9
|
import { Menu, Tab, Container, Dropdown, Input } from 'semantic-ui-react';
|
|
10
|
-
import { emptyBlocksForm } from '@plone/volto/helpers';
|
|
11
|
-
import
|
|
12
|
-
import EditBlockWrapper from '@eeacms/volto-tabs-block/components/EditBlockWrapper';
|
|
10
|
+
import { emptyBlocksForm } from '@plone/volto/helpers/Blocks/Blocks';
|
|
11
|
+
import BlocksForm from '@plone/volto/components/manage/Blocks/Block/BlocksForm';
|
|
13
12
|
import { defaultSchemaEnhancer } from '@eeacms/volto-tabs-block/components/variations/default/schema';
|
|
14
13
|
import {
|
|
15
14
|
SimpleMarkdown,
|
|
@@ -295,7 +294,6 @@ const Edit = (props) => {
|
|
|
295
294
|
activeTabIndex = 0,
|
|
296
295
|
block = null,
|
|
297
296
|
activeBlock = null,
|
|
298
|
-
multiSelected = [],
|
|
299
297
|
screen,
|
|
300
298
|
tabsData = {},
|
|
301
299
|
emptyTab = () => {},
|
|
@@ -304,6 +302,7 @@ const Edit = (props) => {
|
|
|
304
302
|
onSelectBlock = noop,
|
|
305
303
|
setEditingTab = noop,
|
|
306
304
|
schema,
|
|
305
|
+
multiSelected = [],
|
|
307
306
|
} = props;
|
|
308
307
|
const menuPosition = getMenuPosition(data);
|
|
309
308
|
|
|
@@ -355,6 +354,7 @@ const Edit = (props) => {
|
|
|
355
354
|
metadata={metadata}
|
|
356
355
|
pathname={props.pathname}
|
|
357
356
|
properties={isEmpty(tabs[tab]) ? emptyBlocksForm() : tabs[tab]}
|
|
357
|
+
multiSelected={selected && activeTab === tab ? multiSelected : []}
|
|
358
358
|
selected={selected && activeTab === tab && activeBlock}
|
|
359
359
|
selectedBlock={
|
|
360
360
|
selected && activeTab === tab && activeBlock
|
|
@@ -393,19 +393,7 @@ const Edit = (props) => {
|
|
|
393
393
|
);
|
|
394
394
|
setEditingTab(null);
|
|
395
395
|
}}
|
|
396
|
-
|
|
397
|
-
{({ draginfo }, editBlock, blockProps) => {
|
|
398
|
-
return (
|
|
399
|
-
<EditBlockWrapper
|
|
400
|
-
blockProps={blockProps}
|
|
401
|
-
draginfo={draginfo}
|
|
402
|
-
multiSelected={multiSelected.includes(blockProps.block)}
|
|
403
|
-
>
|
|
404
|
-
{editBlock}
|
|
405
|
-
</EditBlockWrapper>
|
|
406
|
-
);
|
|
407
|
-
}}
|
|
408
|
-
</BlocksForm>
|
|
396
|
+
/>
|
|
409
397
|
</div>
|
|
410
398
|
</Tab.Pane>
|
|
411
399
|
),
|
|
@@ -4,7 +4,7 @@ import { compose } from 'redux';
|
|
|
4
4
|
import { withRouter } from 'react-router';
|
|
5
5
|
import cx from 'classnames';
|
|
6
6
|
import { Menu, Tab, Container, Dropdown, Button } from 'semantic-ui-react';
|
|
7
|
-
import
|
|
7
|
+
import RenderBlocks from '@plone/volto/components/theme/View/RenderBlocks';
|
|
8
8
|
import {
|
|
9
9
|
SimpleMarkdown,
|
|
10
10
|
getMenuPosition,
|
package/src/helpers.js
CHANGED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
jest.mock(
|
|
2
|
+
'@eeacms/volto-tabs-block/components',
|
|
3
|
+
() => ({
|
|
4
|
+
DefaultEdit: () => null,
|
|
5
|
+
DefaultView: () => null,
|
|
6
|
+
AccordionEdit: () => null,
|
|
7
|
+
AccordionView: () => null,
|
|
8
|
+
HorizontalResponsiveEdit: () => null,
|
|
9
|
+
HorizontalResponsiveView: () => null,
|
|
10
|
+
HorizontalCarouselView: () => null,
|
|
11
|
+
VerticalCarouselView: () => null,
|
|
12
|
+
layoutSchema: require('./components/layoutSchema').default,
|
|
13
|
+
TabsEdit: () => null,
|
|
14
|
+
TabsView: () => null,
|
|
15
|
+
blockSchema: jest.fn(),
|
|
16
|
+
}),
|
|
17
|
+
{ virtual: true },
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
jest.mock('@eeacms/volto-tabs-block//icons/tabs.svg', () => 'tabs.svg', {
|
|
21
|
+
virtual: true,
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
jest.mock('./widgets', () => ({
|
|
25
|
+
TabsWidget: () => null,
|
|
26
|
+
}));
|
|
27
|
+
|
|
28
|
+
const applyConfig = require('./index').default;
|
|
29
|
+
const { TABS_BLOCK } = require('./constants');
|
|
30
|
+
|
|
31
|
+
describe('applyConfig', () => {
|
|
32
|
+
it('should include tabs in allowed blocks schema choices', () => {
|
|
33
|
+
const config = {
|
|
34
|
+
blocks: {
|
|
35
|
+
blocksConfig: {
|
|
36
|
+
text: { title: 'Text', restricted: false },
|
|
37
|
+
image: { restricted: false },
|
|
38
|
+
image_test: { title: 'Image', restricted: true },
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
widgets: {
|
|
42
|
+
type: {},
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const newConfig = applyConfig(config);
|
|
47
|
+
|
|
48
|
+
expect(
|
|
49
|
+
newConfig.blocks.blocksConfig[TABS_BLOCK].schema.properties.allowedBlocks
|
|
50
|
+
.items.choices,
|
|
51
|
+
).toEqual([
|
|
52
|
+
['text', 'Text'],
|
|
53
|
+
['image', 'image'],
|
|
54
|
+
[TABS_BLOCK, 'Tabs'],
|
|
55
|
+
]);
|
|
56
|
+
});
|
|
57
|
+
});
|
package/src/less/edit.less
CHANGED
|
@@ -46,18 +46,7 @@
|
|
|
46
46
|
// padding-bottom: 0.1rem;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
.block-wrapper {
|
|
50
|
-
&:not(:last-child) {
|
|
51
|
-
margin-bottom: 2rem;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
49
|
.block {
|
|
56
|
-
.block-add-button,
|
|
57
|
-
.delete-button {
|
|
58
|
-
display: none;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
50
|
.block.selected::before {
|
|
62
51
|
border-top-left-radius: 0;
|
|
63
52
|
}
|
|
@@ -68,44 +57,9 @@
|
|
|
68
57
|
pointer-events: none;
|
|
69
58
|
}
|
|
70
59
|
|
|
71
|
-
.block.wrapper.multiSelected {
|
|
72
|
-
.block .block::before {
|
|
73
|
-
z-index: 1;
|
|
74
|
-
background-color: rgba(120, 192, 215, 0.375);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
60
|
.blocks-form {
|
|
79
61
|
margin-top: 0.5rem;
|
|
80
62
|
}
|
|
81
|
-
|
|
82
|
-
.blocks-chooser {
|
|
83
|
-
right: 0;
|
|
84
|
-
left: auto;
|
|
85
|
-
margin-top: 3rem;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
.block-toolbar {
|
|
89
|
-
position: absolute;
|
|
90
|
-
z-index: 3;
|
|
91
|
-
right: -9px;
|
|
92
|
-
display: flex;
|
|
93
|
-
border: none;
|
|
94
|
-
border: 1px solid @borderColor;
|
|
95
|
-
border-bottom: 1px solid @pageBackground;
|
|
96
|
-
margin-top: -45px;
|
|
97
|
-
background-color: @pageBackground;
|
|
98
|
-
border-top-left-radius: 1rem;
|
|
99
|
-
border-top-right-radius: 1rem;
|
|
100
|
-
|
|
101
|
-
.ui.basic.button {
|
|
102
|
-
padding: 8px 5px;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
.ui.basic.button:hover {
|
|
106
|
-
background: transparent !important;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
63
|
}
|
|
110
64
|
|
|
111
65
|
.drag-drop-list-widget {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { render } from '@testing-library/react';
|
|
3
3
|
import SimpleMarkdown from './SimpleMarkdown';
|
|
4
|
-
import '@testing-library/jest-dom
|
|
4
|
+
import '@testing-library/jest-dom';
|
|
5
5
|
|
|
6
6
|
describe('SimpleMarkdown', () => {
|
|
7
7
|
it('renders empty when no markdown is provided', () => {
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { v4 as uuid } from 'uuid';
|
|
3
|
-
import
|
|
3
|
+
import omit from 'lodash/omit';
|
|
4
|
+
import without from 'lodash/without';
|
|
4
5
|
import move from 'lodash-move';
|
|
5
|
-
import
|
|
6
|
+
import Icon from '@plone/volto/components/theme/Icon/Icon';
|
|
7
|
+
import DragDropList from '@plone/volto/components/manage/DragDropList/DragDropList';
|
|
8
|
+
import FormFieldWrapper from '@plone/volto/components/manage/Widgets/FormFieldWrapper';
|
|
6
9
|
import { emptyTab } from '@eeacms/volto-tabs-block/helpers';
|
|
7
10
|
import { StyleWrapperEdit } from '@eeacms/volto-block-style/StyleWrapper';
|
|
8
11
|
import ObjectWidget from '@plone/volto/components/manage/Widgets/ObjectWidget';
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Icon, BlockChooser } from '@plone/volto/components';
|
|
3
|
-
import {
|
|
4
|
-
blockHasValue,
|
|
5
|
-
buildStyleClassNamesFromData,
|
|
6
|
-
} from '@plone/volto/helpers';
|
|
7
|
-
import config from '@plone/volto/registry';
|
|
8
|
-
import { Button } from 'semantic-ui-react';
|
|
9
|
-
import includes from 'lodash/includes';
|
|
10
|
-
import isBoolean from 'lodash/isBoolean';
|
|
11
|
-
import { defineMessages, injectIntl } from 'react-intl';
|
|
12
|
-
import { doesNodeContainClick } from 'semantic-ui-react/dist/commonjs/lib';
|
|
13
|
-
import cx from 'classnames';
|
|
14
|
-
|
|
15
|
-
import dragSVG from '@plone/volto/icons/drag.svg';
|
|
16
|
-
import addSVG from '@plone/volto/icons/circle-plus.svg';
|
|
17
|
-
import trashSVG from '@plone/volto/icons/delete.svg';
|
|
18
|
-
|
|
19
|
-
const messages = defineMessages({
|
|
20
|
-
unknownBlock: {
|
|
21
|
-
id: 'Unknown Block',
|
|
22
|
-
defaultMessage: 'Unknown Block {block}',
|
|
23
|
-
},
|
|
24
|
-
delete: {
|
|
25
|
-
id: 'delete',
|
|
26
|
-
defaultMessage: 'delete',
|
|
27
|
-
},
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
class EditBlockWrapper extends React.Component {
|
|
31
|
-
constructor(props) {
|
|
32
|
-
super(props);
|
|
33
|
-
this.state = {
|
|
34
|
-
addNewBlockOpened: false,
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
componentDidMount() {
|
|
39
|
-
document.addEventListener('mousedown', this.handleClickOutside, false);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
componentWillUnmount() {
|
|
43
|
-
document.removeEventListener('mousedown', this.handleClickOutside);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
handleClickOutside = (e) => {
|
|
47
|
-
if (
|
|
48
|
-
this.blockNode.current &&
|
|
49
|
-
doesNodeContainClick(this.blockNode.current, e)
|
|
50
|
-
) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if (this.state.addNewBlockOpened) {
|
|
55
|
-
this.setState({
|
|
56
|
-
addNewBlockOpened: false,
|
|
57
|
-
});
|
|
58
|
-
return true;
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
blockNode = React.createRef();
|
|
63
|
-
|
|
64
|
-
render() {
|
|
65
|
-
const { intl, blockProps, draginfo, extraControls, children } = this.props;
|
|
66
|
-
|
|
67
|
-
const {
|
|
68
|
-
allowedBlocks,
|
|
69
|
-
block,
|
|
70
|
-
data,
|
|
71
|
-
onDeleteBlock,
|
|
72
|
-
onMutateBlock,
|
|
73
|
-
selected,
|
|
74
|
-
} = blockProps;
|
|
75
|
-
const type = data['@type'];
|
|
76
|
-
const { disableNewBlocks } = data;
|
|
77
|
-
const visible = !data.fixed;
|
|
78
|
-
|
|
79
|
-
const required = isBoolean(data.required)
|
|
80
|
-
? data.required
|
|
81
|
-
: includes(config.blocks.requiredBlocks, type);
|
|
82
|
-
|
|
83
|
-
const styles = buildStyleClassNamesFromData(data.styles);
|
|
84
|
-
|
|
85
|
-
return (
|
|
86
|
-
<div ref={this.blockNode} className="block-wrapper">
|
|
87
|
-
<div
|
|
88
|
-
ref={draginfo?.innerRef}
|
|
89
|
-
{...(selected ? draginfo?.draggableProps : null)}
|
|
90
|
-
className={cx(`block-editor-${data['@type']}`, styles, {
|
|
91
|
-
[data.align]: data.align,
|
|
92
|
-
})}
|
|
93
|
-
>
|
|
94
|
-
{!selected && (
|
|
95
|
-
<div
|
|
96
|
-
style={{
|
|
97
|
-
display: 'none',
|
|
98
|
-
// keep react-beautiful-dnd happy
|
|
99
|
-
}}
|
|
100
|
-
{...draginfo.dragHandleProps}
|
|
101
|
-
></div>
|
|
102
|
-
)}
|
|
103
|
-
{selected && (
|
|
104
|
-
<div className="block-toolbar">
|
|
105
|
-
<div
|
|
106
|
-
style={{
|
|
107
|
-
display: visible ? 'inline-block' : 'none',
|
|
108
|
-
}}
|
|
109
|
-
{...draginfo.dragHandleProps}
|
|
110
|
-
className="drag handle wrapper-column-block"
|
|
111
|
-
>
|
|
112
|
-
<Button icon basic title="Drag and drop">
|
|
113
|
-
<Icon name={dragSVG} size="19px" />
|
|
114
|
-
</Button>
|
|
115
|
-
</div>
|
|
116
|
-
|
|
117
|
-
{extraControls}
|
|
118
|
-
|
|
119
|
-
{!disableNewBlocks && !blockHasValue(data) && (
|
|
120
|
-
<Button
|
|
121
|
-
icon
|
|
122
|
-
basic
|
|
123
|
-
title="Add block"
|
|
124
|
-
onClick={() => {
|
|
125
|
-
this.setState((prevState) => ({
|
|
126
|
-
addNewBlockOpened: !prevState.addNewBlockOpened,
|
|
127
|
-
}));
|
|
128
|
-
}}
|
|
129
|
-
className="column-block-add-button"
|
|
130
|
-
>
|
|
131
|
-
<Icon name={addSVG} className="" size="19px" />
|
|
132
|
-
</Button>
|
|
133
|
-
)}
|
|
134
|
-
{!required && (
|
|
135
|
-
<Button
|
|
136
|
-
icon
|
|
137
|
-
basic
|
|
138
|
-
title="Remove block"
|
|
139
|
-
onClick={() => onDeleteBlock(block)}
|
|
140
|
-
className="delete-button-column-block"
|
|
141
|
-
aria-label={intl.formatMessage(messages.delete)}
|
|
142
|
-
>
|
|
143
|
-
<Icon name={trashSVG} size="19px" />
|
|
144
|
-
</Button>
|
|
145
|
-
)}
|
|
146
|
-
{this.state.addNewBlockOpened && (
|
|
147
|
-
<BlockChooser
|
|
148
|
-
onMutateBlock={(id, value) => {
|
|
149
|
-
this.setState({ addNewBlockOpened: false });
|
|
150
|
-
onMutateBlock(id, value);
|
|
151
|
-
}}
|
|
152
|
-
currentBlock={block}
|
|
153
|
-
allowedBlocks={allowedBlocks}
|
|
154
|
-
/>
|
|
155
|
-
)}
|
|
156
|
-
</div>
|
|
157
|
-
)}
|
|
158
|
-
|
|
159
|
-
<div
|
|
160
|
-
className={cx('ui drag block wrapper inner', type, {
|
|
161
|
-
multiSelected: this.props.multiSelected,
|
|
162
|
-
})}
|
|
163
|
-
>
|
|
164
|
-
{children}
|
|
165
|
-
</div>
|
|
166
|
-
</div>
|
|
167
|
-
</div>
|
|
168
|
-
);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
export default injectIntl(EditBlockWrapper);
|