@ohhwells/bridge 0.1.31-next.33 → 0.1.32-next.35
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/dist/index.cjs +24 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +24 -18
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -6535,26 +6535,32 @@ function OhhwellsBridge() {
|
|
|
6535
6535
|
(0, import_react6.useEffect)(() => {
|
|
6536
6536
|
if (!subdomain || isEditMode) return;
|
|
6537
6537
|
let debounceTimer = null;
|
|
6538
|
+
let observer = null;
|
|
6538
6539
|
const applyFromCache = () => {
|
|
6539
6540
|
const content = contentCache.get(subdomain);
|
|
6540
6541
|
if (!content) return;
|
|
6541
6542
|
retryMissingSchedulingMounts(getPageSchedulingEntries(content["__ohw_sections"]), false);
|
|
6542
|
-
|
|
6543
|
-
|
|
6544
|
-
|
|
6545
|
-
if (
|
|
6546
|
-
|
|
6547
|
-
if (
|
|
6548
|
-
|
|
6549
|
-
|
|
6550
|
-
if (el.
|
|
6551
|
-
|
|
6552
|
-
|
|
6553
|
-
|
|
6554
|
-
|
|
6555
|
-
|
|
6556
|
-
|
|
6557
|
-
|
|
6543
|
+
observer?.disconnect();
|
|
6544
|
+
try {
|
|
6545
|
+
for (const [key, val] of Object.entries(content)) {
|
|
6546
|
+
if (key === "__ohw_sections") continue;
|
|
6547
|
+
document.querySelectorAll(`[data-ohw-key="${key}"]`).forEach((el) => {
|
|
6548
|
+
if (el.dataset.ohwEditable === "image") {
|
|
6549
|
+
const img = el instanceof HTMLImageElement ? el : el.querySelector("img");
|
|
6550
|
+
if (img && img.src !== val) img.src = val;
|
|
6551
|
+
} else if (el.dataset.ohwEditable === "bg-image") {
|
|
6552
|
+
const next = `url('${val}')`;
|
|
6553
|
+
if (el.style.backgroundImage !== next) el.style.backgroundImage = next;
|
|
6554
|
+
} else if (el.dataset.ohwEditable === "link") {
|
|
6555
|
+
applyLinkHref(el, val);
|
|
6556
|
+
} else if (el.innerHTML !== val) {
|
|
6557
|
+
el.innerHTML = val;
|
|
6558
|
+
}
|
|
6559
|
+
});
|
|
6560
|
+
applyLinkByKey(key, val);
|
|
6561
|
+
}
|
|
6562
|
+
} finally {
|
|
6563
|
+
observer?.observe(document.body, { childList: true, subtree: true });
|
|
6558
6564
|
}
|
|
6559
6565
|
enforceLinkHrefs();
|
|
6560
6566
|
};
|
|
@@ -6563,10 +6569,10 @@ function OhhwellsBridge() {
|
|
|
6563
6569
|
debounceTimer = setTimeout(applyFromCache, 150);
|
|
6564
6570
|
};
|
|
6565
6571
|
scheduleApply();
|
|
6566
|
-
|
|
6572
|
+
observer = new MutationObserver(scheduleApply);
|
|
6567
6573
|
observer.observe(document.body, { childList: true, subtree: true });
|
|
6568
6574
|
return () => {
|
|
6569
|
-
observer
|
|
6575
|
+
observer?.disconnect();
|
|
6570
6576
|
if (debounceTimer) clearTimeout(debounceTimer);
|
|
6571
6577
|
};
|
|
6572
6578
|
}, [subdomain, isEditMode, pathname]);
|