@eeacms/volto-cca-policy 0.3.62 → 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 +18 -2
- package/package.json +1 -1
- package/src/components/manage/Blocks/FlourishEmbedBlock/FlourishEmbedBlockEdit.jsx +33 -0
- package/src/components/manage/Blocks/FlourishEmbedBlock/FlourishEmbedBlockView.jsx +40 -0
- package/src/components/manage/Blocks/FlourishEmbedBlock/index.js +22 -0
- package/src/components/manage/Blocks/FlourishEmbedBlock/schema.js +17 -0
- package/src/components/manage/Blocks/FlourishEmbedBlock/style.less +13 -0
- package/src/components/manage/Blocks/index.js +2 -0
- package/src/components/theme/Views/DatabaseItemView.jsx +9 -37
- package/src/components/theme/Widgets/GeolocationWidgetMapContainer.jsx +9 -6
- package/src/helpers/flourishUtils.js +32 -0
- package/src/index.js +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -4,11 +4,27 @@ 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.
|
|
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
|
+
|
|
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
|
|
10
24
|
|
|
11
|
-
-
|
|
25
|
+
- Bring back geolocation widget [Tiberiu Ichim - [`7d388ac`](https://github.com/eea/volto-cca-policy/commit/7d388ac905688d67fd64a382d853afb562e593e2)]
|
|
26
|
+
### [0.3.62](https://github.com/eea/volto-cca-policy/compare/0.3.61...0.3.62) - 4 July 2025
|
|
27
|
+
|
|
12
28
|
### [0.3.61](https://github.com/eea/volto-cca-policy/compare/0.3.60...0.3.61) - 4 July 2025
|
|
13
29
|
|
|
14
30
|
#### :hammer_and_wrench: Others
|
package/package.json
CHANGED
|
@@ -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
|
+
};
|
|
@@ -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
|
|
57
|
-
|
|
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:
|
|
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:
|
|
96
|
+
dataprotection: flourishDataprotection,
|
|
125
97
|
}}
|
|
126
98
|
>
|
|
127
99
|
<iframe
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { withOpenLayers } from '@eeacms/volto-openlayers-map';
|
|
2
|
+
// import { openlayers as ol } from '@eeacms/volto-openlayers-map';
|
|
2
3
|
import {
|
|
3
4
|
Controls,
|
|
4
5
|
Interactions,
|
|
@@ -9,7 +10,7 @@ import {
|
|
|
9
10
|
import React, { useState } from 'react';
|
|
10
11
|
import { useMapContext } from '@eeacms/volto-openlayers-map/hocs';
|
|
11
12
|
|
|
12
|
-
function PinInteraction({ longitude, latitude, onChange }) {
|
|
13
|
+
function PinInteraction({ longitude, latitude, onChange, ol }) {
|
|
13
14
|
const mapContext = useMapContext();
|
|
14
15
|
const { addLayer, addInteraction, map } = mapContext;
|
|
15
16
|
|
|
@@ -63,13 +64,14 @@ function PinInteraction({ longitude, latitude, onChange }) {
|
|
|
63
64
|
const [longitude, latitude] = lonLat;
|
|
64
65
|
onChange({ latitude, longitude });
|
|
65
66
|
});
|
|
66
|
-
}, [addInteraction, addLayer, map, onChange, latitude, longitude]);
|
|
67
|
+
}, [addInteraction, addLayer, map, onChange, latitude, longitude, ol]);
|
|
67
68
|
|
|
68
69
|
return null;
|
|
69
70
|
}
|
|
70
71
|
|
|
71
72
|
const TileSetLoader = (props) => {
|
|
72
73
|
const [tileWMSSources, setTileWMSSources] = useState([]);
|
|
74
|
+
const { ol } = props;
|
|
73
75
|
|
|
74
76
|
React.useEffect(() => {
|
|
75
77
|
setTileWMSSources([
|
|
@@ -83,7 +85,7 @@ const TileSetLoader = (props) => {
|
|
|
83
85
|
transition: 0,
|
|
84
86
|
}),
|
|
85
87
|
]);
|
|
86
|
-
}, []);
|
|
88
|
+
}, [ol]);
|
|
87
89
|
|
|
88
90
|
return tileWMSSources ? (
|
|
89
91
|
<MapContainer {...props} source={tileWMSSources[0]} />
|
|
@@ -91,7 +93,7 @@ const TileSetLoader = (props) => {
|
|
|
91
93
|
};
|
|
92
94
|
|
|
93
95
|
const MapContainer = (props) => {
|
|
94
|
-
const { longitude, latitude, source, onChange } = props;
|
|
96
|
+
const { longitude, latitude, source, onChange, ol } = props;
|
|
95
97
|
return (
|
|
96
98
|
<Map
|
|
97
99
|
view={{
|
|
@@ -105,6 +107,7 @@ const MapContainer = (props) => {
|
|
|
105
107
|
<Layers>
|
|
106
108
|
<Controls attribution={false} zoom={false} />
|
|
107
109
|
<PinInteraction
|
|
110
|
+
ol={ol}
|
|
108
111
|
latitude={latitude}
|
|
109
112
|
longitude={longitude}
|
|
110
113
|
onChange={onChange}
|
|
@@ -125,4 +128,4 @@ const MapContainer = (props) => {
|
|
|
125
128
|
);
|
|
126
129
|
};
|
|
127
130
|
|
|
128
|
-
export default TileSetLoader;
|
|
131
|
+
export default withOpenLayers(TileSetLoader);
|
|
@@ -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
|
+
};
|
package/src/index.js
CHANGED
|
@@ -43,7 +43,7 @@ import BrokenLinks from './components/theme/Views/BrokenLinks';
|
|
|
43
43
|
|
|
44
44
|
import { eea_languages, non_eu_langs } from './constants';
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
import GeolocationWidget from './components/theme/Widgets/GeolocationWidget';
|
|
47
47
|
// import MigrationButtons from './components/MigrationButtons';
|
|
48
48
|
|
|
49
49
|
const getEnv = () => (typeof window !== 'undefined' ? window.env : process.env);
|
|
@@ -430,7 +430,7 @@ const applyConfig = (config) => {
|
|
|
430
430
|
};
|
|
431
431
|
// Custom widgets
|
|
432
432
|
config.widgets.id.geochars = GeocharsWidget;
|
|
433
|
-
|
|
433
|
+
config.widgets.id.geolocation = GeolocationWidget;
|
|
434
434
|
config.widgets.id.promotional_image = PromotionalImageWidget;
|
|
435
435
|
|
|
436
436
|
if (config.widgets.views?.widget) {
|