ublo-lib 1.44.15 → 1.44.17

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/common/components/editable-calendar/index.js"],"names":[],"mappings":"AAOA,gEAiDC;uBAxDsB,OAAO"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/common/components/editable-calendar/index.js"],"names":[],"mappings":"AAOA,gEA4DC;uBAnEsB,OAAO"}
@@ -7,9 +7,14 @@ const Calendar = dynamic(() => import("./calendar"), { ssr: false });
7
7
  export default function EditableCalendar() {
8
8
  const { lang, path, cmsMode } = useUbloContext();
9
9
  const [formats, setFormats] = React.useState([]);
10
- const refreshFormats = React.useCallback(() => {
10
+ const [refreshKey, setRefreshKey] = React.useState(0);
11
+ const refreshCalendars = () => {
12
+ setRefreshKey((key) => key + 1);
13
+ };
14
+ React.useEffect(() => {
15
+ window.refreshCalendars = refreshCalendars;
11
16
  setFormats([]);
12
- window.requestAnimationFrame(() => setTimeout(() => {
17
+ setTimeout(() => {
13
18
  const elements = document.querySelectorAll("section.editable-calendar");
14
19
  if (elements.length) {
15
20
  const formats = Array.from(elements).map((element) => {
@@ -19,24 +24,27 @@ export default function EditableCalendar() {
19
24
  });
20
25
  setFormats(formats);
21
26
  }
22
- }, 1000));
23
- }, []);
27
+ }, 200);
28
+ }, [lang, path, cmsMode]);
24
29
  React.useEffect(() => {
25
- refreshFormats();
26
- }, [lang, path, cmsMode, refreshFormats]);
30
+ window.addEventListener("ublo-content-saved", refreshCalendars);
31
+ return () => {
32
+ window.addEventListener("ublo-content-saved", refreshCalendars);
33
+ };
34
+ }, []);
27
35
  React.useEffect(() => {
28
36
  const zones = Array.from(document.querySelectorAll(".cms"));
29
37
  zones.forEach((zone) => {
30
- zone.addEventListener("ublo-section-created", refreshFormats);
38
+ zone.addEventListener("ublo-section-created", refreshCalendars);
39
+ zone.addEventListener("ublo-section-pasted", refreshCalendars);
31
40
  });
32
- window.addEventListener("ublo-content-saved", reloadWindow);
33
41
  return () => {
34
- window.addEventListener("ublo-content-saved", reloadWindow);
35
42
  zones.forEach((zone) => {
36
- zone.removeEventListener("ublo-section-created", refreshFormats);
43
+ zone.removeEventListener("ublo-section-pasted", refreshCalendars);
44
+ zone.removeEventListener("ublo-section-created", refreshCalendars);
37
45
  });
38
46
  };
39
- }, [refreshFormats]);
47
+ }, []);
40
48
  if (!formats.length)
41
49
  return null;
42
50
  return formats.map((format) => ReactDOM.createPortal(_jsx(Calendar, { lang: lang, format: format }), format.element));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ublo-lib",
3
- "version": "1.44.15",
3
+ "version": "1.44.17",
4
4
  "peerDependencies": {
5
5
  "classnames": "^2.5.1",
6
6
  "dt-design-system": "^3.12.0",