@eeacms/volto-eea-website-theme 1.17.2 → 1.18.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,12 +4,43 @@ 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.18.1](https://github.com/eea/volto-eea-website-theme/compare/1.18.0...1.18.1) - 26 June 2023
8
+
9
+ #### :bug: Bug Fixes
10
+
11
+ - fix: don't break slate [Miu Razvan - [`e71afc4`](https://github.com/eea/volto-eea-website-theme/commit/e71afc4e336a12069ae196370de82bc96fc7e35c)]
12
+
13
+ ### [1.18.0](https://github.com/eea/volto-eea-website-theme/compare/1.17.2...1.18.0) - 20 June 2023
14
+
15
+ #### :rocket: New Features
16
+
17
+ - feat: ThemesWidget update advanced-search link - refs #145772 [Alin Voinea - [`036f471`](https://github.com/eea/volto-eea-website-theme/commit/036f4711ace0985e2b542c64a1cbe28fd97911bd)]
18
+ - feat: Add ThemeasWidget for taxonomy_themes and fix tags link - refs #145772 [Alin Voinea - [`903de63`](https://github.com/eea/volto-eea-website-theme/commit/903de638be2e2b2a9c550200706271fc72f09e36)]
19
+
20
+ #### :bug: Bug Fixes
21
+
22
+ - fix: clearformat only selection [nileshgulia1 - [`e8aab36`](https://github.com/eea/volto-eea-website-theme/commit/e8aab36c0c86e2a2a01ca53673a89c596949a4b1)]
23
+ - fix(slate): backport feature from volto-slate that sets classes on style options [David Ichim - [`5ed97f3`](https://github.com/eea/volto-eea-website-theme/commit/5ed97f34a4714dcbaa11296ca64d043a24464d3e)]
24
+
25
+ #### :nail_care: Enhancements
26
+
27
+ - change(footer): removed fallback to empty array for footer actions #153 from eea/footer_actions [ichim-david - [`8fb9c08`](https://github.com/eea/volto-eea-website-theme/commit/8fb9c082a7fac14e31c7e568cc85cb7095b0524d)]
28
+
29
+ #### :hammer_and_wrench: Others
30
+
31
+ - Release 1.18.0 #154 from eea/develop [ichim-david - [`9e47abb`](https://github.com/eea/volto-eea-website-theme/commit/9e47abb88ec371b142caf177d114ccff49a53082)]
32
+ - Refs #254132 - Bump to 1.18.0. [GhitaB - [`51f483b`](https://github.com/eea/volto-eea-website-theme/commit/51f483b3dba6cff13471fc512d372b577991f6f4)]
33
+ - Refs #254132 - Do not initialize actions with []. Make sure actions in footerOpts are used if set. [GhitaB - [`8c0afb5`](https://github.com/eea/volto-eea-website-theme/commit/8c0afb539b0c96928545bc9a6974a189c9e886b8)]
34
+ - test: Fix sonarqube - Convert the conditional to a boolean to avoid leaked value [Alin Voinea - [`195eb19`](https://github.com/eea/volto-eea-website-theme/commit/195eb19b8aa40a95bca6aafc7720bdc6b8e02340)]
7
35
  ### [1.17.2](https://github.com/eea/volto-eea-website-theme/compare/1.17.1...1.17.2) - 14 June 2023
8
36
 
9
37
  #### :rocket: New Features
10
38
 
11
39
  - feat: config nextcloud subtitles languages - refs #253430 [dobri1408 - [`1fc72df`](https://github.com/eea/volto-eea-website-theme/commit/1fc72df37adbb9f9c03f4adb6ad800d7e603ed90)]
12
40
 
41
+ #### :hammer_and_wrench: Others
42
+
43
+ - Release #150 from eea/develop [ichim-david - [`52f1f78`](https://github.com/eea/volto-eea-website-theme/commit/52f1f782a1d815c6df5be1aabe34f67715637d0f)]
13
44
  ### [1.17.1](https://github.com/eea/volto-eea-website-theme/compare/1.17.0...1.17.1) - 12 June 2023
14
45
 
15
46
  #### :nail_care: Enhancements
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-eea-website-theme",
3
- "version": "1.17.2",
3
+ "version": "1.18.1",
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",
@@ -0,0 +1,20 @@
1
+ import React from 'react';
2
+ import cx from 'classnames';
3
+ import Tag from '@eeacms/volto-eea-design-system/ui/Tag/Tag';
4
+
5
+ export const ThemesWidget = ({ value, children, className }) => {
6
+ return value ? (
7
+ <span className={cx(className, 'token', 'widget')}>
8
+ {value.map((tag) => (
9
+ <Tag
10
+ href={`https://www.eea.europa.eu/en/advanced-search?filters[0][field]=topic&filters[0][values][0]=${tag.title}&filters[0][type]=any&filters[1][field]=language&filters[1][type]=any&filters[1][values][0]=en&sort-field=issued.date&sort-direction=desc`}
11
+ key={tag.token}
12
+ >
13
+ {children ? children(tag.title) : tag.title}
14
+ </Tag>
15
+ ))}
16
+ </span>
17
+ ) : (
18
+ ''
19
+ );
20
+ };
@@ -6,7 +6,10 @@ export const TokenWidget = ({ value, children, className }) =>
6
6
  value ? (
7
7
  <span className={cx(className, 'token', 'widget')}>
8
8
  {value.map((tag) => (
9
- <Tag href={`http://search.apps.eea.europa.eu/?q=${tag}`} key={tag}>
9
+ <Tag
10
+ href={`https://www.eea.europa.eu/en/advanced-search?q=${tag}`}
11
+ key={tag}
12
+ >
10
13
  {children ? children(tag) : tag}
11
14
  </Tag>
12
15
  ))}
@@ -0,0 +1 @@
1
+ This customization fixes bugs with styleMenu not highlighting selected styles in some scenarios. This should be removed after https://github.com/plone/volto/pull/4852
@@ -0,0 +1,157 @@
1
+ import React from 'react';
2
+ import { useSlate } from 'slate-react';
3
+ import { Dropdown } from 'semantic-ui-react';
4
+ import { useIntl, defineMessages } from 'react-intl';
5
+ import cx from 'classnames';
6
+ import { omit } from 'lodash';
7
+ import { isBlockStyleActive, isInlineStyleActive, toggleStyle } from './utils';
8
+ import config from '@plone/volto/registry';
9
+ import { ToolbarButton } from '@plone/volto-slate/editor/ui';
10
+ import paintSVG from '@plone/volto/icons/paint.svg';
11
+
12
+ const messages = defineMessages({
13
+ inlineStyle: {
14
+ id: 'Inline Style',
15
+ defaultMessage: 'Inline Style',
16
+ },
17
+ paragraphStyle: {
18
+ id: 'Paragraph Style',
19
+ defaultMessage: 'Paragraph Style',
20
+ },
21
+ additionalStyles: {
22
+ id: 'Additional Styles',
23
+ defaultMessage: 'Additional Styles',
24
+ },
25
+ });
26
+
27
+ const StyleMenuButton = ({ icon, active, ...props }) => (
28
+ <ToolbarButton {...props} icon={icon} active={active} />
29
+ );
30
+
31
+ const MenuOpts = ({ editor, toSelect, option, type }) => {
32
+ const isActive = toSelect.includes(option);
33
+ return (
34
+ <Dropdown.Item
35
+ as="span"
36
+ active={isActive}
37
+ className={cx(`${type}-${option.value}`, { active: isActive })}
38
+ {...omit(option, ['isBlock'])}
39
+ data-isblock={option.isBlock}
40
+ onClick={(event, selItem) => {
41
+ toggleStyle(editor, {
42
+ cssClass: selItem.value,
43
+ isBlock: selItem.isBlock,
44
+ });
45
+ }}
46
+ />
47
+ );
48
+ };
49
+
50
+ const StylingsButton = (props) => {
51
+ const editor = useSlate();
52
+ const intl = useIntl();
53
+
54
+ // Converting the settings to a format that is required by dropdowns.
55
+ const inlineOpts = [
56
+ ...config.settings.slate.styleMenu.inlineStyles.map((def) => {
57
+ return {
58
+ value: def.cssClass,
59
+ text: def.label,
60
+ icon: def.icon,
61
+ isBlock: false,
62
+ };
63
+ }),
64
+ ];
65
+ const blockOpts = [
66
+ ...config.settings.slate.styleMenu.blockStyles.map((def) => {
67
+ return {
68
+ value: def.cssClass,
69
+ text: def.label,
70
+ icon: def.icon,
71
+ isBlock: true,
72
+ };
73
+ }),
74
+ ];
75
+
76
+ // Calculating the initial selection.
77
+ const toSelect = [];
78
+ // block styles
79
+ for (const val of blockOpts) {
80
+ const ia = isBlockStyleActive(editor, val.value);
81
+ if (ia) {
82
+ toSelect.push(val);
83
+ }
84
+ }
85
+ // inline styles
86
+ for (const val of inlineOpts) {
87
+ const ia = isInlineStyleActive(editor, val.value);
88
+ if (ia) {
89
+ toSelect.push(val);
90
+ }
91
+ }
92
+
93
+ const menuItemProps = {
94
+ toSelect,
95
+ editor,
96
+ };
97
+ const showMenu = inlineOpts.length || blockOpts.length;
98
+ return showMenu ? (
99
+ <Dropdown
100
+ id="style-menu"
101
+ pointing="top left"
102
+ multiple
103
+ value={toSelect}
104
+ disabled={config.settings.slate.styleMenu.disabled ?? false}
105
+ additionLabel={intl.formatMessage(messages.additionalStyles)}
106
+ trigger={
107
+ <StyleMenuButton
108
+ title={intl.formatMessage(messages.additionalStyles)}
109
+ icon={paintSVG}
110
+ active={toSelect.length > 0}
111
+ />
112
+ }
113
+ >
114
+ <Dropdown.Menu>
115
+ {inlineOpts.length ? (
116
+ <>
117
+ <Dropdown.Header
118
+ content={intl.formatMessage(messages.inlineStyle)}
119
+ />
120
+ {inlineOpts.map((option, index) => (
121
+ <MenuOpts
122
+ {...menuItemProps}
123
+ type="inline-style"
124
+ option={option}
125
+ key={index}
126
+ />
127
+ ))}
128
+ </>
129
+ ) : (
130
+ ''
131
+ )}
132
+
133
+ {blockOpts.length ? (
134
+ <>
135
+ <Dropdown.Header
136
+ content={intl.formatMessage(messages.paragraphStyle)}
137
+ />
138
+ {blockOpts.map((option, index) => (
139
+ <MenuOpts
140
+ {...menuItemProps}
141
+ type="block-style"
142
+ option={option}
143
+ key={index}
144
+ />
145
+ ))}
146
+ </>
147
+ ) : (
148
+ ''
149
+ )}
150
+ </Dropdown.Menu>
151
+ </Dropdown>
152
+ ) : (
153
+ ''
154
+ );
155
+ };
156
+
157
+ export default StylingsButton;
@@ -0,0 +1,168 @@
1
+ /* eslint no-console: ["error", { allow: ["warn", "error"] }] */
2
+ import { Editor, Transforms } from 'slate';
3
+ import { isBlockActive } from '@plone/volto-slate/utils';
4
+ import config from '@plone/volto/registry';
5
+
6
+ /**
7
+ * Toggles a style (e.g. in the StyleMenu plugin).
8
+ * @param {Editor} editor
9
+ * @param {object} options
10
+ * @param {boolean} options.isRequested Whether the given style is requested by
11
+ * the user. The style is only applied if it is requested and only removed if it
12
+ * is not requested.
13
+ */
14
+ export const toggleStyle = (editor, { cssClass, isBlock, isRequested }) => {
15
+ if (isBlock) {
16
+ toggleBlockStyle(editor, cssClass);
17
+ } else {
18
+ toggleInlineStyle(editor, cssClass);
19
+ }
20
+ };
21
+
22
+ export const toggleBlockStyle = (editor, style) => {
23
+ // We have 6 boolean variables which need to be accounted for.
24
+ // See https://docs.google.com/spreadsheets/d/1mVeMuqSTMABV2BhoHPrPAFjn7zUksbNgZ9AQK_dcd3U/edit?usp=sharing
25
+ const { slate } = config.settings;
26
+
27
+ const isListItem = isBlockActive(editor, slate.listItemType);
28
+ const isActive = isBlockStyleActive(editor, style);
29
+ const wantsList = false;
30
+
31
+ if (isListItem && !wantsList) {
32
+ toggleBlockStyleAsListItem(editor, style);
33
+ } else if (isListItem && wantsList && !isActive) {
34
+ // switchListType(editor, format); // this will deconstruct to Volto blocks
35
+ } else if (!isListItem && wantsList) {
36
+ // changeBlockToList(editor, format);
37
+ } else if (!isListItem && !wantsList) {
38
+ internalToggleBlockStyle(editor, style);
39
+ } else {
40
+ console.warn('toggleBlockStyle case not covered, please examine:', {
41
+ wantsList,
42
+ isActive,
43
+ isListItem,
44
+ });
45
+ }
46
+ };
47
+
48
+ export const toggleInlineStyle = (editor, style) => {
49
+ // We have 6 boolean variables which need to be accounted for.
50
+ // See https://docs.google.com/spreadsheets/d/1mVeMuqSTMABV2BhoHPrPAFjn7zUksbNgZ9AQK_dcd3U/edit?usp=sharing
51
+ const { slate } = config.settings;
52
+
53
+ const isListItem = isBlockActive(editor, slate.listItemType);
54
+ const isActive = isInlineStyleActive(editor, style);
55
+ const wantsList = false;
56
+
57
+ if (isListItem && !wantsList) {
58
+ toggleInlineStyleAsListItem(editor, style);
59
+ } else if (isListItem && wantsList && !isActive) {
60
+ // switchListType(editor, format); // this will deconstruct to Volto blocks
61
+ } else if (!isListItem && wantsList) {
62
+ // changeBlockToList(editor, format);
63
+ } else if (!isListItem && !wantsList) {
64
+ internalToggleInlineStyle(editor, style);
65
+ } else {
66
+ console.warn('toggleInlineStyle case not covered, please examine:', {
67
+ wantsList,
68
+ isActive,
69
+ isListItem,
70
+ });
71
+ }
72
+ };
73
+
74
+ export const isBlockStyleActive = (editor, style) => {
75
+ const keyName = `style-${style}`;
76
+ const sn = Array.from(
77
+ Editor.nodes(editor, {
78
+ match: (n) => {
79
+ const isStyle = typeof n.styleName === 'string' || n[keyName];
80
+ return !Editor.isEditor(n) && isStyle;
81
+ },
82
+ mode: 'all',
83
+ }),
84
+ );
85
+
86
+ for (const [n] of sn) {
87
+ if (typeof n.styleName === 'string') {
88
+ if (n.styleName.split(' ').filter((x) => x === style).length > 0) {
89
+ return true;
90
+ }
91
+ } else if (
92
+ n[keyName] &&
93
+ keyName.split('-').filter((x) => x === style).length > 0
94
+ )
95
+ return true;
96
+ }
97
+ return false;
98
+ };
99
+
100
+ export const isInlineStyleActive = (editor, style) => {
101
+ const m = Editor.marks(editor);
102
+ const keyName = `style-${style}`;
103
+ if (m && m[keyName]) {
104
+ return true;
105
+ }
106
+ return false;
107
+ };
108
+
109
+ export const internalToggleBlockStyle = (editor, style) => {
110
+ toggleBlockStyleInSelection(editor, style);
111
+ };
112
+
113
+ export const internalToggleInlineStyle = (editor, style) => {
114
+ toggleInlineStyleInSelection(editor, style);
115
+ };
116
+
117
+ /*
118
+ * Applies a block format unto a list item. Will split the list and deconstruct the
119
+ * block
120
+ */
121
+ export const toggleBlockStyleAsListItem = (editor, style) => {
122
+ toggleBlockStyleInSelection(editor, style);
123
+ };
124
+
125
+ /*
126
+ * Applies an inline style unto a list item.
127
+ */
128
+ export const toggleInlineStyleAsListItem = (editor, style) => {
129
+ toggleInlineStyleInSelection(editor, style);
130
+ };
131
+
132
+ function toggleInlineStyleInSelection(editor, style) {
133
+ const m = Editor.marks(editor);
134
+ const keyName = 'style-' + style;
135
+
136
+ if (m && m[keyName]) {
137
+ Editor.removeMark(editor, keyName);
138
+ } else {
139
+ Editor.addMark(editor, keyName, true);
140
+ }
141
+ }
142
+
143
+ function toggleBlockStyleInSelection(editor, style) {
144
+ const sn = Array.from(
145
+ Editor.nodes(editor, {
146
+ mode: 'highest',
147
+ match: (n) => {
148
+ return !Editor.isEditor(n);
149
+ },
150
+ }),
151
+ );
152
+
153
+ for (const [n, p] of sn) {
154
+ let cn = n.styleName;
155
+ if (typeof n.styleName !== 'string') {
156
+ cn = style;
157
+ } else if (n.styleName.split(' ').filter((x) => x === style).length > 0) {
158
+ cn = cn
159
+ .split(' ')
160
+ .filter((x) => x !== style)
161
+ .join(' ');
162
+ } else {
163
+ // the style is not set but other styles are set
164
+ cn = cn.split(' ').concat(style).join(' ');
165
+ }
166
+ Transforms.setNodes(editor, { styleName: cn }, { at: p });
167
+ }
168
+ }
@@ -13,11 +13,11 @@ import isArray from 'lodash/isArray';
13
13
  const Footer = () => {
14
14
  const { eea } = config.settings;
15
15
  const {
16
- footerActions = [],
17
- copyrightActions = [],
18
- socialActions = [],
19
- contactActions = [],
20
- contactExtraActions = [],
16
+ footerActions,
17
+ copyrightActions,
18
+ socialActions,
19
+ contactActions,
20
+ contactExtraActions,
21
21
  } = useSelector(
22
22
  (state) => ({
23
23
  footerActions: state.actions?.actions?.footer_actions,
package/src/index.js CHANGED
@@ -7,6 +7,7 @@ import CustomCSS from '@eeacms/volto-eea-website-theme/components/theme/CustomCS
7
7
  import NotFound from '@eeacms/volto-eea-website-theme/components/theme/NotFound/NotFound';
8
8
  import DraftBackground from '@eeacms/volto-eea-website-theme/components/theme/DraftBackground/DraftBackground';
9
9
  import { TokenWidget } from '@eeacms/volto-eea-website-theme/components/theme/Widgets/TokenWidget';
10
+ import { ThemesWidget } from '@eeacms/volto-eea-website-theme/components/theme/Widgets/ThemesWidget';
10
11
  import SubsiteClass from './components/theme/SubsiteClass';
11
12
  import HomePageView from '@eeacms/volto-eea-website-theme/components/theme/Homepage/HomePageView';
12
13
  import HomePageInverseView from '@eeacms/volto-eea-website-theme/components/theme/Homepage/HomePageInverseView';
@@ -111,11 +112,10 @@ const applyConfig = (config) => {
111
112
  config.blocks.blocksConfig.hero.copyrightPrefix = 'Image';
112
113
  }
113
114
 
114
- // Custom TokenWidget
115
- if (config.widgets.views) {
116
- config.widgets.views.id.subjects = TokenWidget;
117
- config.widgets.views.widget.tags = TokenWidget;
118
- }
115
+ // Custom Widgets
116
+ config.widgets.views.id.taxonomy_themes = ThemesWidget;
117
+ config.widgets.views.id.subjects = TokenWidget;
118
+ config.widgets.views.widget.tags = TokenWidget;
119
119
 
120
120
  // /voltoCustom.css express-middleware
121
121
  // /ok express-middleware - see also: https://github.com/plone/volto/pull/4432
package/src/slate.js CHANGED
@@ -17,6 +17,8 @@ import clearIcon from './icons/eraser.svg';
17
17
 
18
18
  const toggleBlockClassFormat = (editor, format) => {
19
19
  const levels = Array.from(Editor.levels(editor, editor.selection));
20
+ // TODO: someone fix this
21
+ if (levels.length < 2) return false;
20
22
  const [, [, path]] = levels;
21
23
  Transforms.setNodes(
22
24
  editor,
@@ -30,7 +32,9 @@ const toggleBlockClassFormat = (editor, format) => {
30
32
 
31
33
  const isBlockClassActive = (editor, format) => {
32
34
  if (!editor.selection) return false;
35
+ // TODO: someone fix this
33
36
  const levels = Array.from(Editor.levels(editor, editor.selection));
37
+ if (levels.length < 2) return false;
34
38
  const [, [node]] = levels;
35
39
  return node.styleName === format;
36
40
  };
@@ -66,7 +70,7 @@ const clearFormatting = (editor) => {
66
70
  // console.log('node', n, p);
67
71
  return Text.isText(n);
68
72
  },
69
- at: [0], // uncomment if you want everything to be cleared
73
+ //at: [0], // uncomment if you want everything to be cleared
70
74
  }),
71
75
  );
72
76
 
@@ -215,6 +219,8 @@ export default function installSlate(config) {
215
219
  </List.Item>
216
220
  );
217
221
 
222
+ config.settings.slate.allowedHeadlineElements.push('zotero');
223
+
218
224
  // Slate StyleMenu configuration
219
225
  config.settings.slate.styleMenu = {
220
226
  ...(config.settings.slate.styleMenu || {}),