@eeacms/volto-eea-website-theme 1.28.1 → 1.28.3

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,22 @@ 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
+ ### [1.28.3](https://github.com/eea/volto-eea-website-theme/compare/1.28.2...1.28.3) - 5 March 2024
8
+
9
+ #### :bug: Bug Fixes
10
+
11
+ - fix(slate): fix copy/paste in slate from Microsoft Word Desktop App - refs #265782 [Miu Razvan - [`f7a128c`](https://github.com/eea/volto-eea-website-theme/commit/f7a128c4ef02207bf6dfd7adf38cb8df8f073d14)]
12
+ - fix(event): add permalink in customization to the original volto component [kreafox - [`c662aae`](https://github.com/eea/volto-eea-website-theme/commit/c662aae7c271fa1170dd2dbd8cc9a374fed59a2f)]
13
+
14
+ #### :nail_care: Enhancements
15
+
16
+ - refactor: Remove volto-slate patch normalizeExternalData.js - requires Volto 16.28.1+ [alin - [`6ea61da`](https://github.com/eea/volto-eea-website-theme/commit/6ea61dabfae9a755f09dbd588a378c4a2b5338f5)]
17
+
18
+ #### :hammer_and_wrench: Others
19
+
20
+ - Allow hit Enter in the LayoutSettings block to create a new block [Tiberiu Ichim - [`ecde522`](https://github.com/eea/volto-eea-website-theme/commit/ecde52263ce6f989936962bda7bc1213b2750d7d)]
21
+ ### [1.28.2](https://github.com/eea/volto-eea-website-theme/compare/1.28.1...1.28.2) - 29 February 2024
22
+
7
23
  ### [1.28.1](https://github.com/eea/volto-eea-website-theme/compare/1.28.0...1.28.1) - 19 February 2024
8
24
 
9
25
  #### :bug: Bug Fixes
@@ -29,8 +45,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
29
45
 
30
46
  - bump version [Razvan - [`721e939`](https://github.com/eea/volto-eea-website-theme/commit/721e939d12e324b459ebfa78a2e656ee7142a3d6)]
31
47
  - merge master into this branch [Razvan - [`586c8f9`](https://github.com/eea/volto-eea-website-theme/commit/586c8f910bac55a043bd8dda60e9444bd2ae1663)]
32
- - Add Sonarqube tag using freshwater-frontend addons list [EEA Jenkins - [`fd90044`](https://github.com/eea/volto-eea-website-theme/commit/fd9004442a9d1d465f7601ecdefe3e23c61e6a9c)]
33
- - Add Sonarqube tag using insitu-frontend addons list [EEA Jenkins - [`4bc3dd3`](https://github.com/eea/volto-eea-website-theme/commit/4bc3dd3ae412a66befd04b5b80fab3716c929240)]
34
48
  - test: Update jest,Jenkinsfile,lint to volto-addons-template PR30 [valentinab25 - [`c4dbd28`](https://github.com/eea/volto-eea-website-theme/commit/c4dbd289358205bc2d849aab7edb11ccf3b89cee)]
35
49
  - fix tests [Razvan - [`042330b`](https://github.com/eea/volto-eea-website-theme/commit/042330bc97d32ffe7ba769b4f2453f71cffed706)]
36
50
  - remove RemoveSchema logic [Razvan - [`08d10f8`](https://github.com/eea/volto-eea-website-theme/commit/08d10f8bf6f75478260e4e4c66d7316ba87b907a)]
@@ -125,11 +139,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
125
139
  - test: Add real image to cypress test [Alin Voinea - [`4ff591a`](https://github.com/eea/volto-eea-website-theme/commit/4ff591ae3318c9588b4e2114582c0fa6cfdf31ae)]
126
140
  - test: Add cypress tests for Image block styling position and align [Alin Voinea - [`7341ef7`](https://github.com/eea/volto-eea-website-theme/commit/7341ef7b92714fc0cc3ab0c31c39033e7b3e19e7)]
127
141
  - Revert "change(tests): commented out rss test since title block config is missing" [Alin Voinea - [`fb61191`](https://github.com/eea/volto-eea-website-theme/commit/fb611918d6ca380b89b594f283dcf9f685a4b294)]
128
- - test: [JENKINS] Use java17 for sonarqube scanner [valentinab25 - [`6a3be30`](https://github.com/eea/volto-eea-website-theme/commit/6a3be3092589411af7808a235f76de5222fd3868)]
129
- - test: [JENKINS] Run cypress in started frontend container [valentinab25 - [`c3978f2`](https://github.com/eea/volto-eea-website-theme/commit/c3978f23375ef066e9fd6f6c2e34ba6c1c058f69)]
130
- - test: [JENKINS] Add cpu limit on cypress docker [valentinab25 - [`f672779`](https://github.com/eea/volto-eea-website-theme/commit/f672779e845bec9240ccc901e9f53ec80c5a1819)]
131
- - test: [JENKINS] Increase shm-size to cypress docker [valentinab25 - [`ae5d8e3`](https://github.com/eea/volto-eea-website-theme/commit/ae5d8e3f4e04dc2808d47ce2ee886e1b23b528da)]
132
- - test: [JENKINS] Improve cypress time [valentinab25 - [`170ff0c`](https://github.com/eea/volto-eea-website-theme/commit/170ff0c8e3b30e69479bdf1117e811fea94f1027)]
133
142
  ### [1.23.0](https://github.com/eea/volto-eea-website-theme/compare/1.22.1...1.23.0) - 2 November 2023
134
143
 
135
144
  #### :rocket: New Features
@@ -142,7 +151,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
142
151
 
143
152
  #### :house: Internal changes
144
153
 
145
- - chore: [JENKINS] Refactor automated testing [valentinab25 - [`f28fce3`](https://github.com/eea/volto-eea-website-theme/commit/f28fce3d1eb815f95fb9aa40de42b10b7e8e30c5)]
146
154
  - chore: husky, lint-staged use fixed versions [valentinab25 - [`6d15088`](https://github.com/eea/volto-eea-website-theme/commit/6d150886c5aeb2ca0b569270486e60f7cc274e2c)]
147
155
  - chore:volto 16 in tests, update docs, fix stylelint overrides [valentinab25 - [`20c0323`](https://github.com/eea/volto-eea-website-theme/commit/20c032380b33c0077c869a05136f93e2fb68e5d4)]
148
156
 
@@ -328,7 +336,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
328
336
 
329
337
  #### :house: Internal changes
330
338
 
331
- - chore: [JENKINS] Deprecate circularity website [valentinab25 - [`370dcbf`](https://github.com/eea/volto-eea-website-theme/commit/370dcbfbf1a8135ce7b1b3b271b004552a631837)]
332
339
 
333
340
  #### :hammer_and_wrench: Others
334
341
 
@@ -484,7 +491,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
484
491
 
485
492
  #### :hammer_and_wrench: Others
486
493
 
487
- - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`6c5e2f8`](https://github.com/eea/volto-eea-website-theme/commit/6c5e2f80456e2061d9e9c15fd0a0b91b9ac70568)]
488
494
  ### [1.9.1](https://github.com/eea/volto-eea-website-theme/compare/1.9.0...1.9.1) - 28 February 2023
489
495
 
490
496
  #### :bug: Bug Fixes
@@ -631,7 +637,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
631
637
 
632
638
  - For some reasons types is a string [Alin Voinea - [`3769a09`](https://github.com/eea/volto-eea-website-theme/commit/3769a0981181d5b633f3498daebbe96be8b4b833)]
633
639
  - Fix(redirect): o.filter - refs #157627 [Alin Voinea - [`deb23da`](https://github.com/eea/volto-eea-website-theme/commit/deb23da846444cc96539697fd798429ae0abe89e)]
634
- - Add Sonarqube tag using advisory-board-frontend addons list [EEA Jenkins - [`f1fffc5`](https://github.com/eea/volto-eea-website-theme/commit/f1fffc5db96725440863d545580b4e76cce4b796)]
635
640
  ### [1.5.0](https://github.com/eea/volto-eea-website-theme/compare/1.4.2...1.5.0) - 9 January 2023
636
641
 
637
642
  #### :hammer_and_wrench: Others
@@ -665,7 +670,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
665
670
 
666
671
  - Release 1.4.0 [Alin Voinea - [`bd42a0d`](https://github.com/eea/volto-eea-website-theme/commit/bd42a0d26e928cac5d99933194755da3db06b341)]
667
672
  - bump version to use as volto-eea-design-system [David Ichim - [`f4be047`](https://github.com/eea/volto-eea-website-theme/commit/f4be047328b46399b03b612d378b18aaf82e7dc1)]
668
- - Add Sonarqube tag using advisory-board-frontend addons list [EEA Jenkins - [`9b7cfef`](https://github.com/eea/volto-eea-website-theme/commit/9b7cfefb4d34fc1c948015e491feb370f9795bd8)]
669
673
  - test(Jenkins): Run tests and cypress with latest canary @plone/volto [Alin Voinea - [`df252a9`](https://github.com/eea/volto-eea-website-theme/commit/df252a9bfed0bb86cadf53c59dd1603b1e2cd822)]
670
674
  ### [1.3.2](https://github.com/eea/volto-eea-website-theme/compare/1.3.1...1.3.2) - 16 December 2022
671
675
 
@@ -675,7 +679,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
675
679
 
676
680
  #### :hammer_and_wrench: Others
677
681
 
678
- - Add Sonarqube tag using cca-frontend addons list [EEA Jenkins - [`a43c658`](https://github.com/eea/volto-eea-website-theme/commit/a43c658a7920c8df95e763b9a637f38ce77eba2c)]
679
682
  - Better razzle.config [Tiberiu Ichim - [`81dbf48`](https://github.com/eea/volto-eea-website-theme/commit/81dbf48815fb27facb4f82c9b764540fdf188b2e)]
680
683
  - Better razzle.config [Tiberiu Ichim - [`7bc9da2`](https://github.com/eea/volto-eea-website-theme/commit/7bc9da2cd837ab62a95cd29979cdd9b0055b7d67)]
681
684
  ### [1.3.1](https://github.com/eea/volto-eea-website-theme/compare/1.3.0...1.3.1) - 28 November 2022
@@ -686,7 +689,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
686
689
 
687
690
  #### :hammer_and_wrench: Others
688
691
 
689
- - yarn 3 [Alin Voinea - [`ea7a709`](https://github.com/eea/volto-eea-website-theme/commit/ea7a7094945312776e9b6f44e371178603e92139)]
690
692
  ### [1.3.0](https://github.com/eea/volto-eea-website-theme/compare/1.2.0...1.3.0) - 22 November 2022
691
693
 
692
694
  #### :rocket: New Features
@@ -727,7 +729,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
727
729
  - Add subsite class to body [Tiberiu Ichim - [`74d700f`](https://github.com/eea/volto-eea-website-theme/commit/74d700fbfd6249a8604762a7e4e49cce857db0f3)]
728
730
  - Add subsite info to header [Tiberiu Ichim - [`47daf8b`](https://github.com/eea/volto-eea-website-theme/commit/47daf8bb6374a1222040626b19d4154df7ba1b83)]
729
731
  - fix eslint [Miu Razvan - [`eb8d0a7`](https://github.com/eea/volto-eea-website-theme/commit/eb8d0a790bc70c0aae256c6ff35f63c4885f338e)]
730
- - Add Sonarqube tag using circularity-frontend addons list [EEA Jenkins - [`cc578a4`](https://github.com/eea/volto-eea-website-theme/commit/cc578a413b205a8e61e091fab3a88f94cedefc89)]
731
732
  ### [1.1.0](https://github.com/eea/volto-eea-website-theme/compare/1.0.0...1.1.0) - 28 October 2022
732
733
 
733
734
  #### :nail_care: Enhancements
@@ -775,7 +776,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
775
776
 
776
777
  #### :hammer_and_wrench: Others
777
778
 
778
- - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`33b56ac`](https://github.com/eea/volto-eea-website-theme/commit/33b56acb13fbaf0c5b79e8fc6e13c4b699c79c90)]
779
779
  ### [0.7.3](https://github.com/eea/volto-eea-website-theme/compare/0.7.2...0.7.3) - 22 September 2022
780
780
 
781
781
  #### :hammer_and_wrench: Others
@@ -1043,7 +1043,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
1043
1043
  - Header refactor, add custom logo #5 [ichim-david - [`4950235`](https://github.com/eea/volto-eea-website-theme/commit/49502358105437cfeac3b144e6d301cb59aa2346)]
1044
1044
  - Update footer.config with new publication card component [ichim-david - [`2e38e9a`](https://github.com/eea/volto-eea-website-theme/commit/2e38e9a417f835009d60c80d4eb4b30229f55e45)]
1045
1045
  - feature(breadcrumbs): implement eea-design-system breadcrumb as Volto component #32 #7 [ichim-david - [`181af41`](https://github.com/eea/volto-eea-website-theme/commit/181af4125ce2b9ddac56dab4723cb11c26633221)]
1046
- - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`da8ceb6`](https://github.com/eea/volto-eea-website-theme/commit/da8ceb68ea68bfbc9504e48ccd4d68277f11ab9a)]
1047
1046
  - use breadcrumbs from eea-design-system [nileshgulia1 - [`db2f9e9`](https://github.com/eea/volto-eea-website-theme/commit/db2f9e9a4327420a3cce9a9903cd88549b129eab)]
1048
1047
  - Update theme.config [ichim-david - [`8eca4f4`](https://github.com/eea/volto-eea-website-theme/commit/8eca4f40397a4aeca6d39029c92db78968d37064)]
1049
1048
  - Added keyContent component to theme.config [ichim-david - [`d86f202`](https://github.com/eea/volto-eea-website-theme/commit/d86f202d0274d839487a88b51cae9a0e899beb23)]
@@ -1085,5 +1084,4 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
1085
1084
 
1086
1085
  #### :hammer_and_wrench: Others
1087
1086
 
1088
- - yarn bootstrap [Alin Voinea - [`6995e9e`](https://github.com/eea/volto-eea-website-theme/commit/6995e9e091f21fdbbdffa8a44fc0e2c626f6d46a)]
1089
1087
  - Initial commit [Alin Voinea - [`6a9c03a`](https://github.com/eea/volto-eea-website-theme/commit/6a9c03a7cebe71ca87e82cf58c42904063e9d8d3)]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-eea-website-theme",
3
- "version": "1.28.1",
3
+ "version": "1.28.3",
4
4
  "description": "@eeacms/volto-eea-website-theme: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: IDM2 A-Team",
@@ -14,7 +14,6 @@ export default (config) => {
14
14
  schema: BlockSettingsSchema,
15
15
  restricted: false,
16
16
  mostUsed: false,
17
- blockHasOwnFocusManagement: true,
18
17
  sidebarTab: 1,
19
18
  };
20
19
 
@@ -0,0 +1,372 @@
1
+ /* eslint no-console: ["error", { allow: ["error", "warn"] }] */
2
+ import { Editor, Transforms, Text } from 'slate'; // Range, RangeRef
3
+ import config from '@plone/volto/registry';
4
+ import {
5
+ getBlocksFieldname,
6
+ getBlocksLayoutFieldname,
7
+ } from '@plone/volto/helpers';
8
+ import _ from 'lodash';
9
+ import { makeEditor } from '@plone/volto-slate/utils/editor';
10
+
11
+ // case sensitive; first in an inner array is the default and preffered format
12
+ // in that array of formats
13
+ const formatAliases = [
14
+ ['strong', 'b'],
15
+ ['em', 'i'],
16
+ ['del', 's'],
17
+ ];
18
+
19
+ /**
20
+ * Excerpt from Slate documentation, kept here for posterity:
21
+ * See https://docs.slatejs.org/concepts/11-normalizing#built-in-constraints
22
+
23
+ ## Built-in Constraints
24
+
25
+ Slate editors come with a few built-in constraints out of the box. These
26
+ constraints are there to make working with content much more predictable than
27
+ standard contenteditable. All of the built-in logic in Slate depends on these
28
+ constraints, so unfortunately you cannot omit them. They are...
29
+
30
+ - All Element nodes must contain at least one Text descendant. If an element node
31
+ does not contain any children, an empty text node will be added as its only
32
+ child. This constraint exists to ensure that the selection's anchor and focus
33
+ points (which rely on referencing text nodes) can always be placed inside any
34
+ node. With this, empty elements (or void elements) wouldn't be selectable.
35
+
36
+ - Two adjacent texts with the same custom properties will be merged. If two
37
+ adjacent text nodes have the same formatting, they're merged into a single text
38
+ node with a combined text string of the two. This exists to prevent the text
39
+ nodes from only ever expanding in count in the document, since both adding and
40
+ removing formatting results in splitting text nodes.
41
+
42
+ - Block nodes can only contain other blocks, or inline and text nodes. For
43
+ example, a paragraph block cannot have another paragraph block element and
44
+ a link inline element as children at the same time. The type of children
45
+ allowed is determined by the first child, and any other non-conforming children
46
+ are removed. This ensures that common richtext behaviors like "splitting
47
+ a block in two" function consistently.
48
+
49
+ - Inline nodes cannot be the first or last child of a parent block, nor can it
50
+ be next to another inline node in the children array. If this is the case, an
51
+ empty text node will be added to correct this to be in compliance with the
52
+ constraint.
53
+
54
+ - The top-level editor node can only contain block nodes. If any of the
55
+ top-level children are inline or text nodes they will be removed. This ensures
56
+ that there are always block nodes in the editor so that behaviors like
57
+ "splitting a block in two" work as expected.
58
+
59
+ - These default constraints are all mandated because they make working with
60
+ Slate documents much more predictable.
61
+
62
+ Although these constraints are the best we've come up with now, we're always
63
+ looking for ways to have Slate's built-in constraints be less constraining if
64
+ possible—as long as it keeps standard behaviors easy to reason about. If you
65
+ come up with a way to reduce or remove a built-in constraint with a different
66
+ approach, we're all ears!
67
+ *
68
+ */
69
+
70
+ export const normalizeExternalData = (editor, nodes) => {
71
+ let fakeEditor = makeEditor({ extensions: editor._installedPlugins });
72
+ // set the nodes to the fakeEditor
73
+ let currentIndex = 0;
74
+ fakeEditor.children = nodes.reduce((nodes, node) => {
75
+ if (Editor.isBlock(fakeEditor, node) && !!node.type) {
76
+ nodes.push(node);
77
+ currentIndex++;
78
+ return nodes;
79
+ }
80
+ if (!nodes[currentIndex]) {
81
+ nodes[currentIndex] = { type: 'p', children: [] };
82
+ }
83
+ nodes[currentIndex].children.push(node);
84
+ return nodes;
85
+ }, []);
86
+
87
+ Editor.normalize(fakeEditor, { force: true });
88
+
89
+ return fakeEditor.children;
90
+ };
91
+
92
+ /**
93
+ * Is it text? Is it whitespace (space, newlines, tabs) ?
94
+ *
95
+ */
96
+ export const isWhitespace = (c) => {
97
+ return (
98
+ typeof c === 'string' &&
99
+ c.replace(/\s/g, '').replace(/\t/g, '').replace(/\n/g, '').length === 0
100
+ );
101
+ };
102
+
103
+ export function createDefaultBlock(children) {
104
+ return {
105
+ type: config.settings.slate.defaultBlockType,
106
+ children: children || [{ text: '' }],
107
+ };
108
+ }
109
+
110
+ export function createBlock(type, children) {
111
+ return {
112
+ type,
113
+ children: children || [{ text: '' }],
114
+ };
115
+ }
116
+
117
+ export function createEmptyParagraph() {
118
+ // TODO: rename to createEmptyBlock
119
+ return {
120
+ type: config.settings.slate.defaultBlockType,
121
+ children: [{ text: '' }],
122
+ };
123
+ }
124
+
125
+ export function createParagraph(text) {
126
+ return {
127
+ type: config.settings.slate.defaultBlockType,
128
+ children: [{ text }],
129
+ };
130
+ }
131
+
132
+ export const isSingleBlockTypeActive = (editor, format) => {
133
+ const [match] = Editor.nodes(editor, {
134
+ match: (n) => n.type === format,
135
+ });
136
+
137
+ return !!match;
138
+ };
139
+
140
+ export const isBlockActive = (editor, format) => {
141
+ const aliasList = _.find(formatAliases, (x) => _.includes(x, format));
142
+
143
+ if (aliasList) {
144
+ const aliasFound = _.some(aliasList, (y) => {
145
+ return isSingleBlockTypeActive(editor, y);
146
+ });
147
+
148
+ if (aliasFound) {
149
+ return true;
150
+ }
151
+ }
152
+
153
+ return isSingleBlockTypeActive(editor, format);
154
+ };
155
+
156
+ export const getBlockTypeContextData = (editor, format) => {
157
+ let isActive, defaultFormat, matcher;
158
+
159
+ const aliasList = _.find(formatAliases, (x) => _.includes(x, format));
160
+
161
+ if (aliasList) {
162
+ const aliasFound = _.some(aliasList, (y) => {
163
+ return isSingleBlockTypeActive(editor, y);
164
+ });
165
+
166
+ if (aliasFound) {
167
+ isActive = true;
168
+ defaultFormat = _.first(aliasList);
169
+ matcher = (n) => _.includes(aliasList, n.type);
170
+
171
+ return { isActive, defaultFormat, matcher };
172
+ }
173
+ }
174
+
175
+ isActive = isBlockActive(editor, format);
176
+ defaultFormat = format;
177
+ matcher = (n) => n.type === format;
178
+
179
+ return { isActive, defaultFormat, matcher };
180
+ };
181
+
182
+ export const toggleInlineFormat = (editor, format) => {
183
+ const { isActive, defaultFormat, matcher } = getBlockTypeContextData(
184
+ editor,
185
+ format,
186
+ );
187
+
188
+ if (isActive) {
189
+ const rangeRef = Editor.rangeRef(editor, editor.selection);
190
+
191
+ Transforms.unwrapNodes(editor, {
192
+ match: matcher,
193
+ split: false,
194
+ });
195
+
196
+ const newSel = JSON.parse(JSON.stringify(rangeRef.current));
197
+
198
+ Transforms.select(editor, newSel);
199
+ editor.setSavedSelection(newSel);
200
+ // editor.savedSelection = newSel;
201
+ return;
202
+ }
203
+
204
+ const exclusiveElements = config.settings.slate.exclusiveElements;
205
+ const matchedElements = exclusiveTags(exclusiveElements, format);
206
+ let alreadyOneIsActive =
207
+ !!matchedElements &&
208
+ (matchedElements.indexOf(format) === 0
209
+ ? isBlockActive(editor, matchedElements[1])
210
+ : isBlockActive(editor, matchedElements[0]));
211
+
212
+ if (alreadyOneIsActive) {
213
+ Transforms.unwrapNodes(editor, {
214
+ match: (n) => matchedElements.includes(n.type),
215
+ split: false,
216
+ });
217
+
218
+ const block = { type: format, children: [] };
219
+ Transforms.wrapNodes(editor, block, { split: true });
220
+ return;
221
+ }
222
+
223
+ // `children` property is added automatically as an empty array then
224
+ // normalized
225
+ const block = { type: defaultFormat };
226
+ Transforms.wrapNodes(editor, block, { split: true });
227
+ };
228
+
229
+ const exclusiveTags = (exclusiveElements, format) => {
230
+ let elements = null;
231
+ for (const item of exclusiveElements) {
232
+ if (item.includes(format)) {
233
+ elements = item;
234
+ break;
235
+ }
236
+ }
237
+
238
+ return elements;
239
+ };
240
+
241
+ export const toggleBlock = (editor, format, allowedChildren) => {
242
+ // We have 6 boolean variables which need to be accounted for.
243
+ // See https://docs.google.com/spreadsheets/d/1mVeMuqSTMABV2BhoHPrPAFjn7zUksbNgZ9AQK_dcd3U/edit?usp=sharing
244
+ const { slate } = config.settings;
245
+ const { listTypes } = slate;
246
+
247
+ const isListItem = isBlockActive(editor, slate.listItemType);
248
+ const isActive = isBlockActive(editor, format);
249
+ const wantsList = listTypes.includes(format);
250
+
251
+ if (isListItem && !wantsList) {
252
+ toggleFormatAsListItem(editor, format);
253
+ } else if (isListItem && wantsList && !isActive) {
254
+ switchListType(editor, format);
255
+ } else if (!isListItem && wantsList) {
256
+ changeBlockToList(editor, format);
257
+ } else if (!isListItem && !wantsList) {
258
+ toggleFormat(editor, format, allowedChildren);
259
+ } else if (isListItem && wantsList && isActive) {
260
+ clearFormatting(editor);
261
+ } else {
262
+ console.warn('toggleBlock case not covered, please examine:', {
263
+ wantsList,
264
+ isActive,
265
+ isListItem,
266
+ });
267
+ }
268
+ };
269
+
270
+ /*
271
+ * Applies a block format to a list item. Will split the list
272
+ */
273
+ export const toggleFormatAsListItem = (editor, format) => {
274
+ Transforms.setNodes(editor, {
275
+ type: format,
276
+ });
277
+
278
+ Editor.normalize(editor);
279
+ };
280
+
281
+ /*
282
+ * Toggles between list types by exploding the block
283
+ */
284
+ export const switchListType = (editor, format) => {
285
+ const { slate } = config.settings;
286
+ Transforms.unwrapNodes(editor, {
287
+ match: (n) => slate.listTypes.includes(n.type),
288
+ split: true,
289
+ });
290
+ const block = { type: format, children: [] };
291
+ Transforms.wrapNodes(editor, block);
292
+ };
293
+
294
+ export const changeBlockToList = (editor, format) => {
295
+ const { slate } = config.settings;
296
+ const [match] = Editor.nodes(editor, {
297
+ match: (n) => n.type === slate.listItemType,
298
+ });
299
+
300
+ if (!match) {
301
+ Transforms.setNodes(editor, {
302
+ type: slate.listItemType,
303
+ // id: nanoid(8),
304
+ });
305
+ }
306
+
307
+ // `children` property is added automatically as an empty array then
308
+ // normalized
309
+ const block = { type: format };
310
+ Transforms.wrapNodes(editor, block);
311
+ };
312
+
313
+ export const toggleFormat = (editor, format, allowedChildren) => {
314
+ const { slate } = config.settings;
315
+ const isActive = isBlockActive(editor, format);
316
+ const type = isActive ? slate.defaultBlockType : format;
317
+ Transforms.setNodes(editor, {
318
+ type,
319
+ });
320
+ allowedChildren?.length &&
321
+ Transforms.unwrapNodes(editor, {
322
+ mode: 'all',
323
+ at: [0],
324
+ match: (n, path) => {
325
+ const isMatch =
326
+ path.length > 1 && // we don't deal with the parent nodes
327
+ !(Text.isText(n) || allowedChildren.includes(n?.type));
328
+ return isMatch;
329
+ },
330
+ });
331
+ };
332
+
333
+ /**
334
+ * @param {object} properties A prop received by the View component
335
+ * which is read by the `getBlocksFieldname` and
336
+ * `getBlocksLayoutFieldname` Volto helpers to produce the return value.
337
+ * @returns {Array} All the blocks data taken from the Volto form.
338
+ */
339
+ export const getAllBlocks = (properties, blocks) => {
340
+ const blocksFieldName = getBlocksFieldname(properties);
341
+ const blocksLayoutFieldname = getBlocksLayoutFieldname(properties);
342
+
343
+ for (const n of properties?.[blocksLayoutFieldname]?.items || []) {
344
+ const block = properties[blocksFieldName][n];
345
+ // TODO Make this configurable via block config getBlocks
346
+ if (
347
+ block?.data?.[blocksLayoutFieldname] &&
348
+ block?.data?.[blocksFieldName]
349
+ ) {
350
+ getAllBlocks(block.data, blocks);
351
+ } else if (block?.[blocksLayoutFieldname] && block?.[blocksFieldName]) {
352
+ getAllBlocks(block, blocks);
353
+ }
354
+ blocks.push({
355
+ id: n,
356
+ ...block,
357
+ });
358
+ }
359
+ return blocks;
360
+ };
361
+
362
+ export const clearFormatting = (editor) => {
363
+ const { slate } = config.settings;
364
+ Transforms.setNodes(editor, {
365
+ type: slate.defaultBlockType,
366
+ });
367
+ Transforms.unwrapNodes(editor, {
368
+ match: (n) => n.type && n.type !== slate.defaultBlockType,
369
+ mode: 'all',
370
+ split: false,
371
+ });
372
+ };
@@ -138,6 +138,10 @@ class Form extends Component {
138
138
  text: uuid(),
139
139
  };
140
140
  let { formData } = props;
141
+ // TODO Tiberiu: customized here
142
+ formData = formData || {}; // when coming from login screen, formData is null
143
+ // this fixes a bug where, if you go to an /edit page, it will show login (you need to wait the 5 seconds timeout), after login you get redirected back to the edit, then it crashes
144
+ // end customized
141
145
  const blocksFieldname = getBlocksFieldname(formData);
142
146
  const blocksLayoutFieldname = getBlocksLayoutFieldname(formData);
143
147
 
@@ -62,7 +62,7 @@ const Footer = () => {
62
62
  url: flattenToAppURL(action.url),
63
63
  children:
64
64
  idx === 0
65
- ? contactExtraActions.map((child) => ({
65
+ ? (contactExtraActions || []).map((child) => ({
66
66
  text: child.title,
67
67
  icon: child.icon,
68
68
  url: flattenToAppURL(child.url),
@@ -0,0 +1,149 @@
1
+ /* Original: https://github.com/plone/volto/blob/16.x.x/src/components/theme/View/EventDatesInfo.jsx */
2
+
3
+ import React from 'react';
4
+ import PropTypes from 'prop-types';
5
+ import { List } from 'semantic-ui-react';
6
+ import cx from 'classnames';
7
+ import { injectLazyLibs } from '@plone/volto/helpers/Loadable/Loadable';
8
+ import config from '@plone/volto/registry';
9
+ // import { toBackendLang } from '@plone/volto/helpers';
10
+ // import { useSelector } from 'react-redux';
11
+
12
+ export const datesForDisplay = (start, end, moment) => {
13
+ const mStart = moment(start);
14
+ const mEnd = moment(end);
15
+ if (!mStart.isValid() || !mEnd.isValid()) {
16
+ return null;
17
+ }
18
+ const sameDay = mStart.isSame(mEnd, 'day');
19
+ const sameTime = mStart.isSame(mEnd, 'minute');
20
+ return {
21
+ sameDay,
22
+ sameTime,
23
+ startDate: mStart.format('ll'),
24
+ startTime: mStart.format('LT'),
25
+ endDate: mEnd.format('ll'),
26
+ endTime: mEnd.format('LT'),
27
+ };
28
+ };
29
+
30
+ const When_ = ({ start, end, whole_day, open_end, moment: momentlib }) => {
31
+ // Customization:
32
+ // Fix date format by using dateLocale instead of language from Redux
33
+ // const lang = useSelector((state) => state.intl.locale);
34
+ const dateLocale = config.settings.dateLocale || 'en-gb';
35
+
36
+ const moment = momentlib.default;
37
+ moment.locale(dateLocale);
38
+ // end customization
39
+
40
+ const datesInfo = datesForDisplay(start, end, moment);
41
+ if (!datesInfo) {
42
+ return;
43
+ }
44
+ // TODO I18N INTL
45
+
46
+ return (
47
+ <p
48
+ className={cx('event-when', {
49
+ 'same-day': datesInfo.sameDay,
50
+ 'same-time': datesInfo.sameTime,
51
+ 'whole-day': whole_day,
52
+ 'open-end': open_end,
53
+ })}
54
+ >
55
+ {!datesInfo.sameDay ? (
56
+ <>
57
+ <span className="start">
58
+ <span className="start-date">{datesInfo.startDate}</span>
59
+ {!whole_day && (
60
+ <>
61
+ {/* Plone has an optional word based on locale here */}
62
+ <span> </span>
63
+ <span className="start-time">{datesInfo.startTime}</span>
64
+ </>
65
+ )}
66
+ </span>
67
+ {!open_end && (
68
+ <>
69
+ &nbsp;to&nbsp;
70
+ <span className="end">
71
+ <span className="end-date">{datesInfo.endDate}</span>
72
+ {!whole_day && (
73
+ <>
74
+ {/* Plone has an optional word based on locale here */}
75
+ <span> </span>
76
+ <span className="end-time">{datesInfo.endTime}</span>
77
+ </>
78
+ )}
79
+ </span>
80
+ </>
81
+ )}
82
+ </>
83
+ ) : (
84
+ <>
85
+ {whole_day && (
86
+ <span className="start-date">{datesInfo.startDate}</span>
87
+ )}
88
+ {open_end && !whole_day && (
89
+ <>
90
+ <span className="start-date">{datesInfo.startDate}</span>
91
+ &nbsp;from&nbsp;
92
+ <span className="start-time">{datesInfo.startTime}</span>
93
+ </>
94
+ )}
95
+ {!(whole_day || open_end) && (
96
+ <>
97
+ <span className="start-date">{datesInfo.startDate}</span>
98
+ &nbsp;from&nbsp;
99
+ <span className="start-time">{datesInfo.startTime}</span>
100
+ &nbsp;to&nbsp;
101
+ <span className="end-time">{datesInfo.endTime}</span>
102
+ </>
103
+ )}
104
+ </>
105
+ )}
106
+ </p>
107
+ );
108
+ };
109
+
110
+ export const When = injectLazyLibs(['moment'])(When_);
111
+
112
+ When.propTypes = {
113
+ start: PropTypes.string.isRequired,
114
+ end: PropTypes.string,
115
+ whole_day: PropTypes.bool,
116
+ open_end: PropTypes.bool,
117
+ };
118
+
119
+ export const Recurrence_ = ({
120
+ recurrence,
121
+ start,
122
+ moment: momentlib,
123
+ rrule,
124
+ }) => {
125
+ const moment = momentlib.default;
126
+ const { RRule, rrulestr } = rrule;
127
+ if (recurrence.indexOf('DTSTART') < 0) {
128
+ var dtstart = RRule.optionsToString({
129
+ dtstart: new Date(start),
130
+ });
131
+ recurrence = dtstart + '\n' + recurrence;
132
+ }
133
+ const rule = rrulestr(recurrence, { unfold: true, forceset: true });
134
+
135
+ return (
136
+ <List
137
+ items={rule
138
+ .all()
139
+ .map((date) => datesForDisplay(date, undefined, moment))
140
+ .map((date) => date.startDate)}
141
+ />
142
+ );
143
+ };
144
+ export const Recurrence = injectLazyLibs(['moment', 'rrule'])(Recurrence_);
145
+
146
+ Recurrence.propTypes = {
147
+ recurrence: PropTypes.string.isRequired,
148
+ start: PropTypes.string.isRequired,
149
+ };
@@ -1,9 +0,0 @@
1
- // To be removed when https://github.com/plone/volto/pull/5347 is merged and released in Volto 16.x
2
- import { normalizeExternalData as normalize } from '@plone/volto-slate/utils';
3
-
4
- export function normalizeExternalData(editor) {
5
- editor.normalizeExternalData = (fragment) => {
6
- return normalize(editor, fragment);
7
- };
8
- return editor;
9
- }