@eeacms/volto-flourish 0.1.4 → 0.1.6

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,11 +4,19 @@ 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.1.4](https://github.com/eea/volto-flourish/compare/0.1.3...0.1.4) - 18 February 2025
7
+ ### [0.1.6](https://github.com/eea/volto-flourish/compare/0.1.5...0.1.6) - 24 February 2025
8
8
 
9
9
  #### :hammer_and_wrench: Others
10
10
 
11
- - Fix re-display of flourish [Tiberiu Ichim - [`9c6a2c0`](https://github.com/eea/volto-flourish/commit/9c6a2c06c746bf4fb00aa1ed06ed4122152462ae)]
11
+ - Improve loading [Tiberiu Ichim - [`68ed505`](https://github.com/eea/volto-flourish/commit/68ed50596010f0a259eec3131ed7b620b1d10b0e)]
12
+ - test: update snapshot [kreafox - [`b5a149e`](https://github.com/eea/volto-flourish/commit/b5a149e49fd568e890dfb9ceb4e8d0309292e590)]
13
+ - Lower delay [Tiberiu Ichim - [`980d567`](https://github.com/eea/volto-flourish/commit/980d5673f2d34b1c20442e3354efb92148d6dd4c)]
14
+ - Code cleanup [Tiberiu Ichim - [`8c02bb7`](https://github.com/eea/volto-flourish/commit/8c02bb75096190698b31b2ae674e5ee4dd0e433b)]
15
+ - Try again [Tiberiu Ichim - [`c26d3e0`](https://github.com/eea/volto-flourish/commit/c26d3e02844932b7eac06698d21280c5ce094000)]
16
+ ### [0.1.5](https://github.com/eea/volto-flourish/compare/0.1.4...0.1.5) - 20 February 2025
17
+
18
+ ### [0.1.4](https://github.com/eea/volto-flourish/compare/0.1.3...0.1.4) - 18 February 2025
19
+
12
20
  ### [0.1.3](https://github.com/eea/volto-flourish/compare/0.1.2...0.1.3) - 17 February 2025
13
21
 
14
22
  #### :bug: Bug Fixes
@@ -24,9 +32,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
24
32
  - Embed [Tiberiu Ichim - [`65a99d6`](https://github.com/eea/volto-flourish/commit/65a99d6a3cbf69a33e0b3a485a92afc53a2835b8)]
25
33
  - Embed [Tiberiu Ichim - [`0bd365b`](https://github.com/eea/volto-flourish/commit/0bd365b91802227f921b3d7127a2722f56d33e97)]
26
34
  - Embed [Tiberiu Ichim - [`1bc7ee6`](https://github.com/eea/volto-flourish/commit/1bc7ee667a6168a15f50a51b2263e216ffbecc52)]
27
- - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`9c0d692`](https://github.com/eea/volto-flourish/commit/9c0d692ee158e264bc33fe7d05eafcee1ccb6066)]
28
- - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`aae3813`](https://github.com/eea/volto-flourish/commit/aae3813cf0f792b7cdaedb9f7b4ebc9d4bb6cd53)]
29
- - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`5ca27c2`](https://github.com/eea/volto-flourish/commit/5ca27c29e49291471d6cd2585922c39e87d46a84)]
30
35
  ### [0.1.2](https://github.com/eea/volto-flourish/compare/0.1.1...0.1.2) - 16 September 2024
31
36
 
32
37
  #### :house: Internal changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-flourish",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "@eeacms/volto-flourish: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: IDM2 A-Team",
@@ -1,8 +1,9 @@
1
- import { useEffect } from 'react';
1
+ import { useEffect, useMemo } from 'react';
2
2
  import { useSelector, useDispatch } from 'react-redux';
3
3
  import { getContent } from '@plone/volto/actions';
4
4
  import { flattenToAppURL } from '@plone/volto/helpers';
5
5
  import { default as Flourish } from '@eeacms/volto-flourish/components/Flourish';
6
+ import { v4 as uuid } from 'uuid';
6
7
  // import { Sources } from '@eeacms/volto-embed/Toolbar';
7
8
 
8
9
  import {
@@ -13,8 +14,24 @@ import {
13
14
  Enlarge,
14
15
  } from '@eeacms/volto-embed/Toolbar';
15
16
 
17
+ // const overlayStyles = {
18
+ // position: 'absolute',
19
+ // top: 0,
20
+ // left: 0,
21
+ // width: '100%',
22
+ // backgroundColor: 'rgba(255, 255, 255, 0)',
23
+ // zIndex: 20000,
24
+ // pointerEvents: 'none',
25
+ // height: '100%',
26
+ // };
27
+
16
28
  export default function View(props) {
17
- const { id, data } = props;
29
+ const {
30
+ id,
31
+ data,
32
+ // mode = 'view'
33
+ } = props;
34
+ const uid = useMemo(() => uuid(), []);
18
35
 
19
36
  const {
20
37
  with_sources,
@@ -41,11 +58,18 @@ export default function View(props) {
41
58
  }
42
59
  }, [dispatch, vis_url, id]);
43
60
 
61
+ // const editOverlay =
62
+ // mode === 'edit' ? (
63
+ // <div className="edit-overlay" style={overlayStyles} />
64
+ // ) : null;
65
+
44
66
  return (
45
67
  <div className="embed-flourish">
46
68
  {flourish_item_url ? (
47
- <div>
48
- <Flourish baseUrl={flourish_item_url} />
69
+ <>
70
+ <Flourish baseUrl={flourish_item_url} key={uid} id={uid} />
71
+ {/* {editOverlay} */}
72
+
49
73
  {flourishItemContent && (
50
74
  <div className="visualization-toolbar">
51
75
  <div className="left-col">
@@ -82,7 +106,7 @@ export default function View(props) {
82
106
  </div>
83
107
  </div>
84
108
  )}
85
- </div>
109
+ </>
86
110
  ) : props.mode ? (
87
111
  <div>Embed flourish</div>
88
112
  ) : null}
@@ -1,30 +1,45 @@
1
- import { useEffect } from 'react';
1
+ import { useEffect, useRef } from 'react';
2
2
 
3
- export default function Flourish({ baseUrl }) {
3
+ export default function Flourish({ baseUrl, id }) {
4
4
  const flourishUrl = `${baseUrl}/@@flourish/index.html`;
5
+ const nodeRef = useRef(null);
5
6
  const scriptUrl = `${baseUrl}/@@flourish/flourish.embed.js`;
6
7
 
7
8
  useEffect(() => {
8
9
  if (!baseUrl) return;
9
10
 
10
- if (!window.FlourishLoaded) {
11
- window.Flourish = { disable_autoload: true };
11
+ setTimeout(() => {
12
+ const container = nodeRef.current;
13
+ if (!container) {
14
+ return;
15
+ }
12
16
 
13
- const script = document.createElement('script');
14
- script.src = scriptUrl;
15
- script.async = true;
16
- script.onload = () => {};
17
+ container.setAttribute('data-src', flourishUrl);
17
18
 
18
- document.body.appendChild(script);
19
- } else {
20
- setTimeout(() => {
21
- const domNodes = document.querySelectorAll('.flourish-embed');
22
- domNodes.forEach((domNode) => window.Flourish.loadEmbed(domNode));
23
- }, 10);
24
- }
19
+ if (
20
+ document.querySelectorAll('script.flourish-embed-script').length === 0
21
+ ) {
22
+ const script = document.createElement('script');
23
+ script.src = scriptUrl;
24
+ script.className = 'flourish-embed-script';
25
+ script.id = id;
26
+ script.onload = () => {
27
+ //eslint-disable-next-line no-console
28
+ console.log('loaded script', id);
29
+ };
30
+ document.body.appendChild(script);
31
+ } else {
32
+ const node = document.getElementById(id);
33
+ if (node && window.Flourish?.loadEmbed) {
34
+ //eslint-disable-next-line no-console
35
+ console.log('Loading embed', node.id);
36
+ window.Flourish.loadEmbed(node);
37
+ }
38
+ }
39
+ }, 200);
25
40
 
26
41
  return () => {};
27
- }, [baseUrl, scriptUrl]);
42
+ }, [baseUrl, scriptUrl, id, flourishUrl]);
28
43
 
29
- return <div className="flourish-embed" data-src={flourishUrl}></div>;
44
+ return <div className="flourish-embed" id={id} ref={nodeRef}></div>;
30
45
  }