@eeacms/volto-eea-website-policy 2.3.0 → 2.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,12 @@ 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
+ ### [2.3.1](https://github.com/eea/volto-eea-website-policy/compare/2.3.0...2.3.1) - 30 January 2025
8
+
9
+ #### :bug: Bug Fixes
10
+
11
+ - fix: error on edititing html block and make it readonly - refs #282438 [Teodor Voicu - [`302e393`](https://github.com/eea/volto-eea-website-policy/commit/302e393c8214465673d757b50b89d89574f0f4a8)]
12
+
7
13
  ### [2.3.0](https://github.com/eea/volto-eea-website-policy/compare/2.2.3...2.3.0) - 11 October 2024
8
14
 
9
15
  #### :rocket: New Features
@@ -45,6 +51,12 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
45
51
  - removed double rolesWhoCanChangeLayout setting [David Ichim - [`37dab9e`](https://github.com/eea/volto-eea-website-policy/commit/37dab9ef04dc1497655e49186f398b5dd53f39b1)]
46
52
  - use contextnavigation in policy [nileshgulia1 - [`eea2258`](https://github.com/eea/volto-eea-website-policy/commit/eea2258244c146ff682e055ffb88cf0b9020da93)]
47
53
  - move contextNav to volto-eea-website-theme [nileshgulia1 - [`07aa147`](https://github.com/eea/volto-eea-website-policy/commit/07aa14746a0253f75dc7c63610e1998eae6ffbf5)]
54
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`f620f72`](https://github.com/eea/volto-eea-website-policy/commit/f620f72b1bee27d9215b4cec5ddbe125ae0f7030)]
55
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`13b94c3`](https://github.com/eea/volto-eea-website-policy/commit/13b94c308e20970b4a30e1ec12734e8eaabfffb9)]
56
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`8ebc23d`](https://github.com/eea/volto-eea-website-policy/commit/8ebc23dac8134ffed5b8f89d117cec1a13790c2c)]
57
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`a57c3eb`](https://github.com/eea/volto-eea-website-policy/commit/a57c3eb88ad31cc50f5321c406ac5b5d918bf623)]
58
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`f26c537`](https://github.com/eea/volto-eea-website-policy/commit/f26c537fa75fcb6eedad808a933a8a0689eda9f8)]
59
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`b1491ca`](https://github.com/eea/volto-eea-website-policy/commit/b1491ca3c9f07a7b91b9e892b0e53e4cf82762ce)]
48
60
  - Added extra handleOutsideClick on Accordion mobile and tablet to close when clicking besides the smaller menu [David Ichim - [`6d36534`](https://github.com/eea/volto-eea-website-policy/commit/6d365349ba9f779b527344d6d109c77d77501acf)]
49
61
  - close nav on tablet or mobile resolution by default [David Ichim - [`9e119d2`](https://github.com/eea/volto-eea-website-policy/commit/9e119d23d50dd5a614279da6ec3ccc369a16ba19)]
50
62
  - dropped useless code [David Ichim - [`7f5c122`](https://github.com/eea/volto-eea-website-policy/commit/7f5c122c596eb4db7f0ea4c81708b3c88aca657b)]
@@ -69,6 +81,14 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
69
81
 
70
82
  #### :hammer_and_wrench: Others
71
83
 
84
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`74f7cb1`](https://github.com/eea/volto-eea-website-policy/commit/74f7cb1b4f7dd3232f9a6c0ad35e50bc86b64e60)]
85
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`c8978f0`](https://github.com/eea/volto-eea-website-policy/commit/c8978f02c53c38d88b654544051aa28ba5ccd05c)]
86
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`fb31e28`](https://github.com/eea/volto-eea-website-policy/commit/fb31e285959820147aa07e827cea25589d27be63)]
87
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`3b0c059`](https://github.com/eea/volto-eea-website-policy/commit/3b0c059772a0ca32f398c17b6ddb74be8e2f0060)]
88
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`25d16e4`](https://github.com/eea/volto-eea-website-policy/commit/25d16e401b4d2685a201a1b3a9830916ed4c5b80)]
89
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`d4fdfaf`](https://github.com/eea/volto-eea-website-policy/commit/d4fdfaf94d8fa962906cf713c865202bbff1ff60)]
90
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`742d72c`](https://github.com/eea/volto-eea-website-policy/commit/742d72c1f020fc7a2ed553dc739be54daeb2283d)]
91
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`e3dc5ef`](https://github.com/eea/volto-eea-website-policy/commit/e3dc5ef5da18aa64091388d8779dcc2819e5ad80)]
72
92
  ### [2.2.2](https://github.com/eea/volto-eea-website-policy/compare/2.2.1...2.2.2) - 28 August 2024
73
93
 
74
94
  #### :bug: Bug Fixes
@@ -77,6 +97,10 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
77
97
 
78
98
  #### :hammer_and_wrench: Others
79
99
 
100
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`2703b09`](https://github.com/eea/volto-eea-website-policy/commit/2703b09f3803fa058b45f3f55c5343ab548139a1)]
101
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`2506307`](https://github.com/eea/volto-eea-website-policy/commit/2506307c355c2de50a40b76a6c09ac1989d11be1)]
102
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`48999a4`](https://github.com/eea/volto-eea-website-policy/commit/48999a4a5a16593ca90981a72a4606abc4a02e89)]
103
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`de57cc0`](https://github.com/eea/volto-eea-website-policy/commit/de57cc0093cec55cf372fe4beb610f77588b4bb3)]
80
104
  ### [2.2.1](https://github.com/eea/volto-eea-website-policy/compare/2.2.0...2.2.1) - 27 August 2024
81
105
 
82
106
  #### :bug: Bug Fixes
@@ -85,6 +109,8 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
85
109
 
86
110
  #### :hammer_and_wrench: Others
87
111
 
112
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`e333afd`](https://github.com/eea/volto-eea-website-policy/commit/e333afd4354f5a78f7c2aec9026df928219c144a)]
113
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`9cb821a`](https://github.com/eea/volto-eea-website-policy/commit/9cb821a08010dfae144a5a4ae30e1c40da65d02a)]
88
114
  ### [2.2.0](https://github.com/eea/volto-eea-website-policy/compare/2.1.1...2.2.0) - 26 August 2024
89
115
 
90
116
  #### :rocket: New Features
@@ -93,6 +119,20 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
93
119
 
94
120
  #### :hammer_and_wrench: Others
95
121
 
122
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`9864108`](https://github.com/eea/volto-eea-website-policy/commit/9864108aea2be5def74d4d89542e0babf1fbc93b)]
123
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`d406101`](https://github.com/eea/volto-eea-website-policy/commit/d40610109bd581903a4a6212867197a352b3cc06)]
124
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`16936d4`](https://github.com/eea/volto-eea-website-policy/commit/16936d4b67baead7f2572eb19c47c9423da1af5a)]
125
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`1c1c92b`](https://github.com/eea/volto-eea-website-policy/commit/1c1c92bc8ea0a036cebf2b854197c52dd1f8681a)]
126
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`21accb1`](https://github.com/eea/volto-eea-website-policy/commit/21accb12e958b832f7463da93684f470420d1714)]
127
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`4898d16`](https://github.com/eea/volto-eea-website-policy/commit/4898d1673ba71098d18385d123f1fa403ff8089e)]
128
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`c4e596f`](https://github.com/eea/volto-eea-website-policy/commit/c4e596f4efbee0f835bf293f713da21669bc8c00)]
129
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`aa79040`](https://github.com/eea/volto-eea-website-policy/commit/aa7904074d9b90208218b4a801ea68491727de68)]
130
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`6c3aa38`](https://github.com/eea/volto-eea-website-policy/commit/6c3aa382200cd756f4bd7b40fee96bef71d5079e)]
131
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`9adc480`](https://github.com/eea/volto-eea-website-policy/commit/9adc480e0edf278386a065bf30b66c138592ee82)]
132
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`5554c13`](https://github.com/eea/volto-eea-website-policy/commit/5554c13183d7adda41dca07593fd51846b0d1375)]
133
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`e526958`](https://github.com/eea/volto-eea-website-policy/commit/e52695821dce6790ff89213f967569bce223680b)]
134
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`7e0381c`](https://github.com/eea/volto-eea-website-policy/commit/7e0381cd77ef067541585421a94536849dbdf4b5)]
135
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`3473b02`](https://github.com/eea/volto-eea-website-policy/commit/3473b02f98ea09fe4afa46389f14468c1897586d)]
96
136
  ### [2.1.1](https://github.com/eea/volto-eea-website-policy/compare/2.1.0...2.1.1) - 30 May 2024
97
137
 
98
138
  #### :house: Internal changes
@@ -101,6 +141,12 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
101
141
 
102
142
  #### :hammer_and_wrench: Others
103
143
 
144
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`c297b9e`](https://github.com/eea/volto-eea-website-policy/commit/c297b9efe743ad1f95ab662007a2186b5f042f4c)]
145
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`b11c055`](https://github.com/eea/volto-eea-website-policy/commit/b11c055d0a41c89a60f70875124994ba52772e48)]
146
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`a77d04e`](https://github.com/eea/volto-eea-website-policy/commit/a77d04e9f1e4d6b8657e09fd1a2bcde66499f77f)]
147
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`12c6e92`](https://github.com/eea/volto-eea-website-policy/commit/12c6e92e4157896bf812dbbd8996c754b491d3ea)]
148
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`0aa866d`](https://github.com/eea/volto-eea-website-policy/commit/0aa866dc6fb5f4226a99a3e192a958af60385185)]
149
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`7517f96`](https://github.com/eea/volto-eea-website-policy/commit/7517f96d82efd6a7ddaa746c81a51997583363f6)]
104
150
  ### [2.1.0](https://github.com/eea/volto-eea-website-policy/compare/2.0.0...2.1.0) - 9 May 2024
105
151
 
106
152
  #### :rocket: New Features
@@ -110,6 +156,10 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
110
156
  #### :hammer_and_wrench: Others
111
157
 
112
158
  - Release 2.1.0 [alin - [`da22af4`](https://github.com/eea/volto-eea-website-policy/commit/da22af436092236d7ef6e8568e3eca4813d517b5)]
159
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`9a5d706`](https://github.com/eea/volto-eea-website-policy/commit/9a5d7064e829622e2627c616c4ca1ce71511dfcb)]
160
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`f8b40e9`](https://github.com/eea/volto-eea-website-policy/commit/f8b40e961138efc4090d0ab45a5689905c672b15)]
161
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`4ab2144`](https://github.com/eea/volto-eea-website-policy/commit/4ab2144e02291d98064b001d9eb40417da4d1795)]
162
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`5af4642`](https://github.com/eea/volto-eea-website-policy/commit/5af464227c6695c7e2d3ccd9f240c2a5071bfefa)]
113
163
  ## [2.0.0](https://github.com/eea/volto-eea-website-policy/compare/1.15.0...2.0.0) - 22 April 2024
114
164
 
115
165
  #### :rocket: New Features
@@ -182,6 +232,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
182
232
 
183
233
  #### :hammer_and_wrench: Others
184
234
 
235
+ - test: [JENKINS] fail with logs on coverage [valentinab25 - [`5cf68f8`](https://github.com/eea/volto-eea-website-policy/commit/5cf68f8db34448d10fe993d16541ad9732434cc8)]
185
236
  ### [1.12.0-beta.1](https://github.com/eea/volto-eea-website-policy/compare/1.11.1...1.12.0-beta.1) - 12 January 2024
186
237
 
187
238
  #### :hammer_and_wrench: Others
@@ -202,6 +253,11 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
202
253
  #### :hammer_and_wrench: Others
203
254
 
204
255
  - Release 1.11.0 [Alin Voinea - [`3249160`](https://github.com/eea/volto-eea-website-policy/commit/3249160422c6c6e0cf14823b614f8885101a847a)]
256
+ - test: [JENKINS] Use java17 for sonarqube scanner [valentinab25 - [`8beb7e7`](https://github.com/eea/volto-eea-website-policy/commit/8beb7e7a12cbc314e56e4b1aceab5ef8d00ca6f3)]
257
+ - test: [JENKINS] Run cypress in started frontend container [valentinab25 - [`12d3da1`](https://github.com/eea/volto-eea-website-policy/commit/12d3da12e9a3b0882cf55efe2d40f3032724d41b)]
258
+ - test: [JENKINS] Add cpu limit on cypress docker [valentinab25 - [`0af0764`](https://github.com/eea/volto-eea-website-policy/commit/0af076467120ed9a80c697931e869837b92a0a4c)]
259
+ - test: [JENKINS] Increase shm-size to cypress docker [valentinab25 - [`8662e3e`](https://github.com/eea/volto-eea-website-policy/commit/8662e3e5fc3640d678ce320eb8856a37d419306c)]
260
+ - test: [JENKINS] Improve cypress time [valentinab25 - [`ef1074f`](https://github.com/eea/volto-eea-website-policy/commit/ef1074fdf968cafdf476d4ee4951eb18ebac048a)]
205
261
  ### [1.10.0](https://github.com/eea/volto-eea-website-policy/compare/1.9.2...1.10.0) - 2 November 2023
206
262
 
207
263
  #### :rocket: New Features
@@ -210,6 +266,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
210
266
 
211
267
  #### :house: Internal changes
212
268
 
269
+ - chore: [JENKINS] Refactor automated testing [valentinab25 - [`8b1b422`](https://github.com/eea/volto-eea-website-policy/commit/8b1b42297b46d9fb7325589b3bd043233c0d66e9)]
213
270
  - chore: husky, lint-staged use fixed versions [valentinab25 - [`44ac62e`](https://github.com/eea/volto-eea-website-policy/commit/44ac62e6f8b7e5b7d57edfbf82812c91dc5d6bba)]
214
271
  - chore:volto 16 in tests, update docs, fix stylelint overrides [valentinab25 - [`b9a46d8`](https://github.com/eea/volto-eea-website-policy/commit/b9a46d85a64739188a3df9e8cbe645418b5d8b0a)]
215
272
 
@@ -330,6 +387,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
330
387
 
331
388
  - Release 1.5.0 [Alin Voinea - [`a3dea8e`](https://github.com/eea/volto-eea-website-policy/commit/a3dea8ea15cb8d2a876dc10da926ece3a5707ea9)]
332
389
  - test(Jenkinsfile): Use latest stable volto for testing [Alin Voinea - [`a8f7123`](https://github.com/eea/volto-eea-website-policy/commit/a8f712364187f9638886667c249fa102cb49b5c0)]
390
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`124a8f8`](https://github.com/eea/volto-eea-website-policy/commit/124a8f8ad4ced507aeec27012d725f2e2b977e08)]
333
391
  ### [1.4.0](https://github.com/eea/volto-eea-website-policy/compare/1.3.4...1.4.0) - 21 February 2023
334
392
 
335
393
  #### :rocket: New Features
@@ -409,6 +467,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
409
467
  #### :hammer_and_wrench: Others
410
468
 
411
469
  - Release 1.1.0 [Alin Voinea - [`0291b3b`](https://github.com/eea/volto-eea-website-policy/commit/0291b3bb7b4c6ab09ca98728885cea4051eac8e3)]
470
+ - yarn 3 [Alin Voinea - [`593aa58`](https://github.com/eea/volto-eea-website-policy/commit/593aa58eaa4d28aced0603b7f7dd125c857a6f54)]
412
471
  ### [1.0.4](https://github.com/eea/volto-eea-website-policy/compare/1.0.3...1.0.4) - 22 November 2022
413
472
 
414
473
  #### :nail_care: Enhancements
@@ -454,6 +513,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
454
513
 
455
514
  #### :hammer_and_wrench: Others
456
515
 
516
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`d153f54`](https://github.com/eea/volto-eea-website-policy/commit/d153f54e55e918fa4746e05488c734624eaf14a9)]
457
517
  ### [0.4.0](https://github.com/eea/volto-eea-website-policy/compare/0.3.3...0.4.0) - 19 September 2022
458
518
 
459
519
  #### :hammer_and_wrench: Others
@@ -529,6 +589,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
529
589
  - format index.js [Andrei Grigore - [`db4481a`](https://github.com/eea/volto-eea-website-policy/commit/db4481aeeba59a769272659f33278c902fc69bec)]
530
590
  - Update index.js [Alexandru Ghica - [`dc09886`](https://github.com/eea/volto-eea-website-policy/commit/dc0988640a76a9914381b120f58bb61a9ab1eb39)]
531
591
  - Added externalRoutes [Alexandru Ghica - [`b68135b`](https://github.com/eea/volto-eea-website-policy/commit/b68135b013fafa93a41ea602ea2fad30879abe0f)]
592
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`575cca6`](https://github.com/eea/volto-eea-website-policy/commit/575cca674602ca2e1c2a41300c47ba594ff49aa0)]
532
593
  ### [0.1.1](https://github.com/eea/volto-eea-website-policy/compare/0.1.0...0.1.1) - 4 March 2022
533
594
 
534
595
  #### :hammer_and_wrench: Others
@@ -541,4 +602,5 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
541
602
 
542
603
  #### :hammer_and_wrench: Others
543
604
 
605
+ - yarn bootstrap [Alin Voinea - [`9b4d197`](https://github.com/eea/volto-eea-website-policy/commit/9b4d197cbc7992566cb36524d190078d5ad21a44)]
544
606
  - Initial commit [Alin Voinea - [`3800692`](https://github.com/eea/volto-eea-website-policy/commit/3800692f7a4de6460815bd6061facacb986cbef0)]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-eea-website-policy",
3
- "version": "2.3.0",
3
+ "version": "2.3.1",
4
4
  "description": "@eeacms/volto-eea-website-policy: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: IDM2 A-Team",
@@ -0,0 +1,371 @@
1
+ /**
2
+ * Edit html block.
3
+ * @module components/manage/Blocks/HTML/Edit
4
+ */
5
+
6
+ import { compose } from 'redux';
7
+ import React, { Component } from 'react';
8
+ import PropTypes from 'prop-types';
9
+ import { Button, Popup } from 'semantic-ui-react';
10
+ import { defineMessages, injectIntl } from 'react-intl';
11
+ import loadable from '@loadable/component';
12
+ import { isEqual } from 'lodash';
13
+
14
+ import { Icon } from '@plone/volto/components';
15
+ import { injectLazyLibs } from '@plone/volto/helpers/Loadable/Loadable';
16
+ import showSVG from '@plone/volto/icons/show.svg';
17
+ // import clearSVG from '@plone/volto/icons/clear.svg';
18
+ // import codeSVG from '@plone/volto/icons/code.svg';
19
+ // import indentSVG from '@plone/volto/icons/indent.svg';
20
+
21
+ const Editor = loadable(() => import('react-simple-code-editor'));
22
+
23
+ const messages = defineMessages({
24
+ source: {
25
+ id: 'Source',
26
+ defaultMessage: 'Source',
27
+ },
28
+ preview: {
29
+ id: 'Preview',
30
+ defaultMessage: 'Preview',
31
+ },
32
+ placeholder: {
33
+ id: '<p>Add some HTML here</p>',
34
+ defaultMessage: '<p>Add some HTML here</p>',
35
+ },
36
+ prettier: {
37
+ id: 'Prettify your code',
38
+ defaultMessage: 'Prettify your code',
39
+ },
40
+ clear: {
41
+ id: 'Clear',
42
+ defaultMessage: 'Clear',
43
+ },
44
+ code: {
45
+ id: 'Code',
46
+ defaultMessage: 'Code',
47
+ },
48
+ });
49
+
50
+ /**
51
+ * Edit html block class.
52
+ * @class Edit
53
+ * @extends Component
54
+ */
55
+ class Edit extends Component {
56
+ /**
57
+ * Property types.
58
+ * @property {Object} propTypes Property types.
59
+ * @static
60
+ */
61
+ static propTypes = {
62
+ selected: PropTypes.bool.isRequired,
63
+ block: PropTypes.string.isRequired,
64
+ index: PropTypes.number.isRequired,
65
+ data: PropTypes.objectOf(PropTypes.any).isRequired,
66
+ onChangeBlock: PropTypes.func.isRequired,
67
+ onSelectBlock: PropTypes.func.isRequired,
68
+ onDeleteBlock: PropTypes.func.isRequired,
69
+ handleKeyDown: PropTypes.func.isRequired,
70
+ editable: PropTypes.bool,
71
+ };
72
+
73
+ /**
74
+ * Default properties
75
+ * @property {Object} defaultProps Default properties.
76
+ * @static
77
+ */
78
+ static defaultProps = {
79
+ editable: true,
80
+ };
81
+ /**
82
+ * Constructor
83
+ * @method constructor
84
+ * @param {Object} props Component properties
85
+ */
86
+ constructor(props) {
87
+ super(props);
88
+ this.state = {
89
+ isPreview: false,
90
+ };
91
+ this.onChangeCode = this.onChangeCode.bind(this);
92
+ this.onPreview = this.onPreview.bind(this);
93
+ this.onCodeEditor = this.onCodeEditor.bind(this);
94
+ }
95
+
96
+ codeEditorRef = React.createRef();
97
+ savedSelection = {};
98
+
99
+ componentDidUpdate(prevProps, prevState, snapshot) {
100
+ if (this.codeEditorRef.current) {
101
+ this.savedSelection = snapshot;
102
+ this.restoreSelectionAndFocus(this.codeEditorRef.current);
103
+ }
104
+ }
105
+
106
+ /**
107
+ * @param {*} nextProps
108
+ * @param {*} nextState
109
+ * @returns {boolean}
110
+ * @memberof Edit
111
+ */
112
+ shouldComponentUpdate(nextProps) {
113
+ // Always rerender when the DOM node is not created for the Editor (the
114
+ // first call to shouldComponentUpdate).
115
+ if (!this._input) {
116
+ return true;
117
+ }
118
+
119
+ // Rerender the entire component when the Editor in it changes its selection
120
+ // because this way we get a call to getSnapshotBeforeUpdate where we can
121
+ // save the selection.
122
+ return (
123
+ this.props.selected ||
124
+ !isEqual(this.props.data, nextProps.data) ||
125
+ this._input.selectionStart !== this.savedSelection.selectionStart ||
126
+ this._input.selectionEnd !== this.savedSelection.selectionEnd
127
+ );
128
+ }
129
+
130
+ /**
131
+ * Change html handler
132
+ * @method onChangeCode
133
+ * @param {string} code New value html
134
+ * @returns {undefined}
135
+ */
136
+ onChangeCode(code) {
137
+ this.props.onChangeBlock(this.props.block, {
138
+ ...this.props.data,
139
+ html: code,
140
+ });
141
+ }
142
+
143
+ getValue() {
144
+ return this.props.data.html || '';
145
+ }
146
+
147
+ /**
148
+ * Preview mode handler
149
+ * @method onPreview
150
+ * @returns {undefined}
151
+ */
152
+ async onPreview() {
153
+ try {
154
+ const code = (
155
+ await this.props.prettierStandalone.format(this.getValue(), {
156
+ parser: 'html',
157
+ plugins: [this.props.prettierParserHtml],
158
+ })
159
+ ).trim();
160
+ this.setState(
161
+ {
162
+ isPreview: !this.state.isPreview,
163
+ },
164
+ () => this.onChangeCode(code),
165
+ );
166
+ } catch (ex) {
167
+ // error while parsing the user-typed HTML
168
+ // TODO: show a toast notification or something similar to the user
169
+ }
170
+ }
171
+
172
+ /**
173
+ * Prettify handler
174
+ * @method onPrettify
175
+ * @returns {undefined}
176
+ */
177
+ onPrettify = async () => {
178
+ try {
179
+ const code = (
180
+ await this.props.prettierStandalone.format(this.getValue(), {
181
+ parser: 'html',
182
+ plugins: [this.props.prettierParserHtml],
183
+ })
184
+ ).trim();
185
+ this.onChangeCode(code);
186
+ } catch (ex) {
187
+ // error while parsing the user-typed HTML
188
+ // TODO: show a toast notification or something similar to the user
189
+ }
190
+ };
191
+
192
+ /**
193
+ * Code Editor mode handler
194
+ * @method onPreview
195
+ * @returns {undefined}
196
+ */
197
+ onCodeEditor() {
198
+ this.setState({ isPreview: !this.state.isPreview });
199
+ }
200
+
201
+ getSelection = (editor) => {
202
+ if (!editor || !editor._input) {
203
+ return {};
204
+ }
205
+
206
+ return {
207
+ selectionStart: editor._input.selectionStart || 0,
208
+ selectionEnd: editor._input.selectionEnd || 0,
209
+ };
210
+ };
211
+
212
+ getSnapshotBeforeUpdate(prevProps, prevState) {
213
+ return this.codeEditorRef.current
214
+ ? this.getSelection(this.codeEditorRef.current)
215
+ : {};
216
+ }
217
+
218
+ restoreSelectionAndFocus = (editor) => {
219
+ if (!editor || !editor._input) {
220
+ return;
221
+ }
222
+ // Don't restore selection when the block is not selected.
223
+ if (
224
+ this.props.selected &&
225
+ editor._input &&
226
+ typeof this.savedSelection?.selectionStart === 'number' &&
227
+ typeof this.savedSelection?.selectionEnd === 'number'
228
+ ) {
229
+ editor._input.selectionStart = this.savedSelection?.selectionStart;
230
+ editor._input.selectionEnd = this.savedSelection?.selectionEnd;
231
+ editor._input.focus();
232
+ }
233
+ };
234
+
235
+ /**
236
+ * Render method.
237
+ * @method render
238
+ * @returns {string} Markup for the component.
239
+ */
240
+ render() {
241
+ const placeholder =
242
+ this.props.data.placeholder ||
243
+ this.props.intl.formatMessage(messages.placeholder);
244
+ const value = this.getValue();
245
+ return (
246
+ <>
247
+ {this.props.selected && value && (
248
+ <div className="toolbar">
249
+ {/* Hide temporary this feature in toolbar.*/}
250
+ {/* <Popup
251
+ trigger={
252
+ <Button
253
+ icon
254
+ basic
255
+ aria-label={this.props.intl.formatMessage(messages.source)}
256
+ active={!this.state.isPreview}
257
+ onClick={this.onCodeEditor}
258
+ >
259
+ <Icon name={codeSVG} size="24px" />
260
+ </Button>
261
+ }
262
+ position="top center"
263
+ content={this.props.intl.formatMessage(messages.code)}
264
+ size="mini"
265
+ /> */}
266
+ <Popup
267
+ trigger={
268
+ <Button
269
+ icon
270
+ basic
271
+ aria-label={this.props.intl.formatMessage(messages.preview)}
272
+ active={this.state.isPreview}
273
+ onClick={this.onPreview}
274
+ >
275
+ <Icon name={showSVG} size="24px" />
276
+ </Button>
277
+ }
278
+ position="top center"
279
+ content={this.props.intl.formatMessage(messages.preview)}
280
+ size="mini"
281
+ />
282
+ {/* Hide temporary this feature in toolbar. */}
283
+ {/* <Popup
284
+ trigger={
285
+ <Button
286
+ icon
287
+ basic
288
+ aria-label={this.props.intl.formatMessage(messages.prettier)}
289
+ onClick={this.onPrettify}
290
+ >
291
+ <Icon name={indentSVG} size="24px" />
292
+ </Button>
293
+ }
294
+ position="top center"
295
+ content={this.props.intl.formatMessage(messages.prettier)}
296
+ size="mini"
297
+ />
298
+ <div className="separator" />
299
+ <Popup
300
+ trigger={
301
+ <Button.Group>
302
+ <Button icon basic onClick={() => this.onChangeCode('')}>
303
+ <Icon name={clearSVG} size="24px" color="#e40166" />
304
+ </Button>
305
+ </Button.Group>
306
+ }
307
+ position="top center"
308
+ content={this.props.intl.formatMessage(messages.clear)}
309
+ size="mini"
310
+ /> */}
311
+ </div>
312
+ )}
313
+ {this.state.isPreview ? (
314
+ <div dangerouslySetInnerHTML={{ __html: value }} />
315
+ ) : (
316
+ <Editor
317
+ value={this.getValue()}
318
+ readOnly={true}
319
+ placeholder={placeholder}
320
+ onValueChange={(code) => this.onChangeCode(code)}
321
+ highlight={
322
+ this.props.prismCore?.highlight &&
323
+ this.props.prismCore?.languages?.html
324
+ ? (code) =>
325
+ this.props.prismCore.highlight(
326
+ code,
327
+ this.props.prismCore.languages.html,
328
+ 'html',
329
+ )
330
+ : () => {}
331
+ }
332
+ padding={8}
333
+ className="html-editor"
334
+ ref={(node) => {
335
+ if (node) {
336
+ this.codeEditorRef.current = node;
337
+ }
338
+ }}
339
+ ignoreTabKey={true}
340
+ />
341
+ )}
342
+ </>
343
+ );
344
+ }
345
+ }
346
+
347
+ const withPrismMarkup = (WrappedComponent) => (props) => {
348
+ const [loaded, setLoaded] = React.useState();
349
+ const promise = React.useRef(null);
350
+ const cancelled = React.useRef(false);
351
+
352
+ React.useEffect(() => {
353
+ promise.current = import('prismjs/components/prism-markup');
354
+ promise.current.then(() => {
355
+ if (!cancelled.current) {
356
+ setLoaded(true);
357
+ }
358
+ });
359
+ return () => {
360
+ cancelled.current = true;
361
+ };
362
+ }, []);
363
+
364
+ return loaded ? <WrappedComponent {...props} /> : null;
365
+ };
366
+
367
+ export default compose(
368
+ injectLazyLibs(['prettierStandalone', 'prettierParserHtml', 'prismCore']),
369
+ withPrismMarkup,
370
+ injectIntl,
371
+ )(Edit);
package/src/index.js CHANGED
@@ -12,6 +12,9 @@ const restrictedBlocks = [
12
12
  'dataqueryfilter',
13
13
  'dottedTableChart',
14
14
  'simpleDataConnectedTable',
15
+ 'video',
16
+ 'maps',
17
+ 'html',
15
18
  ];
16
19
 
17
20
  const overrideBlocks = {