@eeacms/volto-cca-policy 0.3.63 → 0.3.64

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,20 @@ 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
+ ### [0.3.64](https://github.com/eea/volto-cca-policy/compare/0.3.63...0.3.64) - 11 July 2025
8
+
9
+ #### :rocket: New Features
10
+
11
+ - feat: add flourish embed block - refs #289220 [kreafox - [`6a97c0a`](https://github.com/eea/volto-cca-policy/commit/6a97c0a1b71ff9ad12201a79c951e189931f440d)]
12
+
13
+ #### :nail_care: Enhancements
14
+
15
+ - change: improve edit mode message for missing Flourish embed code [kreafox - [`6eb9b2a`](https://github.com/eea/volto-cca-policy/commit/6eb9b2af688ad8a4552382378c8046203ee3e456)]
16
+
17
+ #### :house: Internal changes
18
+
19
+ - style: Automated code fix [eea-jenkins - [`c1813ef`](https://github.com/eea/volto-cca-policy/commit/c1813ef923c3a6e8a37a0a48b7f88772b260fb15)]
20
+
7
21
  ### [0.3.63](https://github.com/eea/volto-cca-policy/compare/0.3.62...0.3.63) - 9 July 2025
8
22
 
9
23
  #### :hammer_and_wrench: Others
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-cca-policy",
3
- "version": "0.3.63",
3
+ "version": "0.3.64",
4
4
  "description": "@eeacms/volto-cca-policy: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: IDM2 A-Team",
@@ -0,0 +1,33 @@
1
+ import { SidebarPortal } from '@plone/volto/components';
2
+ import BlockDataForm from '@plone/volto/components/manage/Form/BlockDataForm';
3
+ import FlourishEmbedBlockView from './FlourishEmbedBlockView';
4
+ import schema from './schema';
5
+
6
+ const FlourishEmbedBlockEdit = (props) => {
7
+ const { block, data, onChangeBlock, selected, id } = props;
8
+
9
+ return (
10
+ <>
11
+ <div className="flourish-edit-view">
12
+ <FlourishEmbedBlockView data={data} id={id} mode="edit" />
13
+ </div>
14
+
15
+ <SidebarPortal selected={selected}>
16
+ <BlockDataForm
17
+ block={block}
18
+ title={schema.title}
19
+ schema={schema}
20
+ onChangeField={(id, value) => {
21
+ onChangeBlock(block, {
22
+ ...data,
23
+ [id]: value,
24
+ });
25
+ }}
26
+ onChangeBlock={onChangeBlock}
27
+ formData={data}
28
+ />
29
+ </SidebarPortal>
30
+ </>
31
+ );
32
+ };
33
+ export default FlourishEmbedBlockEdit;
@@ -0,0 +1,40 @@
1
+ import { PrivacyProtection } from '@eeacms/volto-embed';
2
+ import {
3
+ buildFlourishUrl,
4
+ flourishDataprotection,
5
+ getDataSrcFromEmbedCode,
6
+ } from '@eeacms/volto-cca-policy/helpers/flourishUtils';
7
+
8
+ import './style.less';
9
+
10
+ const FlourishEmbedBlockView = ({ data, mode }) => {
11
+ const isEditMode = mode === 'edit';
12
+ const embed_code = data?.embed_code || '';
13
+ const flourishPath = getDataSrcFromEmbedCode(embed_code);
14
+ const flourishUrl = buildFlourishUrl(flourishPath);
15
+
16
+ if (!flourishUrl)
17
+ return isEditMode ? (
18
+ <div>Add a valid Flourish embed code to display the visualization.</div>
19
+ ) : null;
20
+
21
+ return (
22
+ <PrivacyProtection
23
+ data={{
24
+ url: flourishUrl,
25
+ dataprotection: flourishDataprotection,
26
+ }}
27
+ >
28
+ <iframe
29
+ height="980"
30
+ width="100%"
31
+ src={flourishUrl}
32
+ title="Flourish visualization"
33
+ className="flourish-embed-iframe"
34
+ sandbox="allow-same-origin allow-forms allow-scripts allow-downloads allow-popups allow-popups-to-escape-sandbox allow-top-navigation-by-user-activation"
35
+ ></iframe>
36
+ </PrivacyProtection>
37
+ );
38
+ };
39
+
40
+ export default FlourishEmbedBlockView;
@@ -0,0 +1,22 @@
1
+ import FlourishEmbedBlockEdit from './FlourishEmbedBlockEdit';
2
+ import FlourishEmbedBlockView from './FlourishEmbedBlockView';
3
+ import sliderSVG from '@plone/volto/icons/slider.svg';
4
+
5
+ export default function installBlock(config) {
6
+ config.blocks.blocksConfig.FlourishEmbedBlock = {
7
+ id: 'FlourishEmbedBlock',
8
+ title: 'Flourish visualization',
9
+ icon: sliderSVG,
10
+ group: 'site',
11
+ edit: FlourishEmbedBlockEdit,
12
+ view: FlourishEmbedBlockView,
13
+ mostUsed: false,
14
+ sidebarTab: 1,
15
+ security: {
16
+ addPermission: [],
17
+ view: [],
18
+ },
19
+ };
20
+
21
+ return config;
22
+ }
@@ -0,0 +1,17 @@
1
+ export default {
2
+ title: 'Flourish visualization block',
3
+ fieldsets: [
4
+ {
5
+ id: 'default',
6
+ title: 'Default',
7
+ fields: ['embed_code'],
8
+ },
9
+ ],
10
+ properties: {
11
+ embed_code: {
12
+ title: 'Flourish embed code',
13
+ widget: 'textarea',
14
+ },
15
+ },
16
+ required: [],
17
+ };
@@ -0,0 +1,13 @@
1
+ .flourish-edit-view {
2
+ position: relative;
3
+
4
+ &:after {
5
+ position: absolute;
6
+ top: 0;
7
+ left: 0;
8
+ width: 100%;
9
+ height: 100%;
10
+ background-color: rgba(255, 255, 255, 0.5);
11
+ content: '';
12
+ }
13
+ }
@@ -19,6 +19,7 @@ import installTabsBlock from './TabsBlock';
19
19
  import installRedirectBlock from './RedirectBlock';
20
20
  import installContentLinks from './ContentLinks';
21
21
  import installASTNavigation from './ASTNavigation';
22
+ import installFlourishEmbedBlock from './FlourishEmbedBlock';
22
23
 
23
24
  // import installMKHMap from './MKHMap';
24
25
  // import installCountryMapHeatIndex from './CountryMapHeatIndex';
@@ -52,6 +53,7 @@ export default function installBlocks(config) {
52
53
  installContentLinks,
53
54
  installASTNavigation,
54
55
  installCountryMapProfile,
56
+ installFlourishEmbedBlock,
55
57
  // installMKHMap,
56
58
  // installCountryMapHeatIndex,
57
59
  )(config);
@@ -7,6 +7,11 @@ import {
7
7
  PortalMessage,
8
8
  } from '@eeacms/volto-cca-policy/components';
9
9
  import { fixEmbedURL } from '@eeacms/volto-cca-policy/helpers';
10
+ import {
11
+ buildFlourishUrl,
12
+ flourishDataprotection,
13
+ getDataSrcFromEmbedCode,
14
+ } from '@eeacms/volto-cca-policy/helpers/flourishUtils';
10
15
  import {
11
16
  TOOL,
12
17
  GUIDANCE,
@@ -30,51 +35,18 @@ import {
30
35
 
31
36
  const share_eea = ['https://cmshare.eea.eu', 'shareit.eea.europa.eu'];
32
37
 
33
- const dataprotection = {
34
- enabled: true,
35
- privacy_cookie_key: 'flourish',
36
- privacy_statement: [
37
- {
38
- children: [
39
- {
40
- text:
41
- 'This map is hosted by a third party [Flourish]. ' +
42
- 'By showing the external content you accept the terms ' +
43
- 'and conditions of www.flourish.studio. This includes ' +
44
- 'their cookie policies, which we have no control over.',
45
- },
46
- ],
47
- type: 'p',
48
- },
49
- ],
50
- };
51
-
52
38
  const MaybeFlourishVisualization = ({ content }) => {
53
39
  const { map_graphs } = content;
54
40
 
55
41
  // https://helpcenter.flourish.studio/hc/en-us/articles/8761537208463-How-to-embed-Flourish-charts-in-your-CMS
56
- const data_src = (map_graphs) => {
57
- if (typeof map_graphs === 'string') {
58
- const regex = /data-src="([^"]*)"/;
59
- const match = regex.exec(map_graphs);
60
-
61
- if (match && match.length > 1) {
62
- const dataSrcValue = match[1];
63
- return dataSrcValue;
64
- }
65
- }
66
- return null;
67
- };
68
- const flourishPath = data_src(map_graphs);
69
- const flourishUrl = map_graphs
70
- ? `https://flo.uri.sh/${flourishPath}/embed`
71
- : null;
42
+ const flourishPath = getDataSrcFromEmbedCode(map_graphs);
43
+ const flourishUrl = buildFlourishUrl(flourishPath);
72
44
 
73
45
  return !!flourishPath ? (
74
46
  <PrivacyProtection
75
47
  data={{
76
48
  url: flourishUrl,
77
- dataprotection: dataprotection,
49
+ dataprotection: flourishDataprotection,
78
50
  }}
79
51
  >
80
52
  <iframe
@@ -121,7 +93,7 @@ const MaybeIframeVisualization = ({ content }) => {
121
93
  <PrivacyProtection
122
94
  data={{
123
95
  url: url,
124
- dataprotection: dataprotection,
96
+ dataprotection: flourishDataprotection,
125
97
  }}
126
98
  >
127
99
  <iframe
@@ -0,0 +1,32 @@
1
+ export const getDataSrcFromEmbedCode = (htmlString) => {
2
+ if (typeof htmlString !== 'string') return null;
3
+ const regex = /data-src="([^"]*)"/;
4
+ const match = regex.exec(htmlString);
5
+ return match && match[1] ? match[1] : null;
6
+ };
7
+
8
+ export const buildFlourishUrl = (path) => {
9
+ if (!path) return null;
10
+ const [base, query] = path.split('?');
11
+ return query
12
+ ? `https://flo.uri.sh/${base}/embed?${query}`
13
+ : `https://flo.uri.sh/${base}/embed`;
14
+ };
15
+
16
+ export const flourishDataprotection = {
17
+ enabled: true,
18
+ privacy_cookie_key: 'flourish',
19
+ privacy_statement: [
20
+ {
21
+ children: [
22
+ {
23
+ text:
24
+ 'This map is hosted by a third party [Flourish]. ' +
25
+ 'By showing the external content you accept the terms ' +
26
+ 'and conditions of www.flourish.studio, including their cookie policy.',
27
+ },
28
+ ],
29
+ type: 'p',
30
+ },
31
+ ],
32
+ };