ublo-lib 1.44.16 → 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,
|
|
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
|
|
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
|
-
|
|
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
|
-
},
|
|
23
|
-
}, []);
|
|
27
|
+
}, 200);
|
|
28
|
+
}, [lang, path, cmsMode]);
|
|
24
29
|
React.useEffect(() => {
|
|
25
|
-
|
|
26
|
-
|
|
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",
|
|
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-
|
|
43
|
+
zone.removeEventListener("ublo-section-pasted", refreshCalendars);
|
|
44
|
+
zone.removeEventListener("ublo-section-created", refreshCalendars);
|
|
37
45
|
});
|
|
38
46
|
};
|
|
39
|
-
}, [
|
|
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));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-injected-cms-markup.d.ts","sourceRoot":"","sources":["../../../src/common/hooks/use-injected-cms-markup.js"],"names":[],"mappings":";AAaA,
|
|
1
|
+
{"version":3,"file":"use-injected-cms-markup.d.ts","sourceRoot":"","sources":["../../../src/common/hooks/use-injected-cms-markup.js"],"names":[],"mappings":";AAaA,wEA+BC"}
|
|
@@ -12,32 +12,28 @@ const findAllByKey = (obj, keyToFind) => {
|
|
|
12
12
|
const useInjectedCmsMarkup = (entries, isReady) => {
|
|
13
13
|
const { cmsMode } = useUbloContext();
|
|
14
14
|
const injectCmsMarkup = React.useCallback(async () => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
else {
|
|
35
|
-
target.markup = value;
|
|
36
|
-
}
|
|
37
|
-
});
|
|
15
|
+
await window.Cms.register();
|
|
16
|
+
const formats = window.Cms.sectionClasses;
|
|
17
|
+
entries.forEach((entry) => {
|
|
18
|
+
const { key, value } = entry;
|
|
19
|
+
const isArray = Array.isArray(value);
|
|
20
|
+
const targets = findAllByKey(formats, key);
|
|
21
|
+
targets.forEach((target) => {
|
|
22
|
+
if (!target?.markup)
|
|
23
|
+
return;
|
|
24
|
+
if (isArray) {
|
|
25
|
+
const formattedRows = value.map((v) => {
|
|
26
|
+
return { name: v, markup: `<tr><td>${v}</td></tr>` };
|
|
27
|
+
});
|
|
28
|
+
const [anchor] = target.markup;
|
|
29
|
+
target.markup = anchor ? [anchor, ...formattedRows] : formattedRows;
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
target.markup = value;
|
|
33
|
+
}
|
|
38
34
|
});
|
|
39
|
-
|
|
40
|
-
|
|
35
|
+
});
|
|
36
|
+
await window.Cms.analyse();
|
|
41
37
|
}, [entries]);
|
|
42
38
|
React.useEffect(() => {
|
|
43
39
|
if (isReady && cmsMode === "connected") {
|