@ohhwells/bridge 0.1.62 → 0.1.63
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 +144 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +144 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -10880,6 +10880,43 @@ function addFooterColumnWithPersist({
|
|
|
10880
10880
|
return result;
|
|
10881
10881
|
}
|
|
10882
10882
|
|
|
10883
|
+
// src/lib/site-wide-scope.ts
|
|
10884
|
+
function getLogoElement(el) {
|
|
10885
|
+
const marked = el.closest('[data-ohw-role="logo"], [data-ohw-logo]');
|
|
10886
|
+
if (marked) return marked;
|
|
10887
|
+
const root = el.closest("nav, [data-ohw-nav-root], footer");
|
|
10888
|
+
if (!root) return null;
|
|
10889
|
+
const anchor = el.closest("a");
|
|
10890
|
+
if (anchor && root.contains(anchor) && !anchor.hasAttribute("data-ohw-href-key") && !anchor.closest("[data-ohw-nav-container]") && Boolean(anchor.querySelector("img") || anchor.matches("img"))) {
|
|
10891
|
+
return anchor;
|
|
10892
|
+
}
|
|
10893
|
+
const img = el.matches("img") ? el : null;
|
|
10894
|
+
if (img && !img.closest("[data-ohw-href-key]") && !img.closest("[data-ohw-nav-container]") && (img.closest("footer") || img.closest("nav, [data-ohw-nav-root]"))) {
|
|
10895
|
+
return img;
|
|
10896
|
+
}
|
|
10897
|
+
return null;
|
|
10898
|
+
}
|
|
10899
|
+
function isInFooter(el) {
|
|
10900
|
+
if (!el) return false;
|
|
10901
|
+
return Boolean(el.closest("footer") || el.closest('[data-ohw-section="footer"]'));
|
|
10902
|
+
}
|
|
10903
|
+
function isSiteWideElement(el) {
|
|
10904
|
+
if (!el) return false;
|
|
10905
|
+
if (getLogoElement(el)) return true;
|
|
10906
|
+
if (isInFooter(el)) return true;
|
|
10907
|
+
if (el.hasAttribute("data-ohw-nav-container") || el.hasAttribute("data-ohw-nav-root")) {
|
|
10908
|
+
return true;
|
|
10909
|
+
}
|
|
10910
|
+
if (el.hasAttribute("data-ohw-href-key") && el.closest("nav, [data-ohw-nav-root], [data-ohw-nav-drawer], aside")) {
|
|
10911
|
+
return true;
|
|
10912
|
+
}
|
|
10913
|
+
if (el.closest('[data-ohw-role="navbar-button"]')) return true;
|
|
10914
|
+
return false;
|
|
10915
|
+
}
|
|
10916
|
+
function isSiteWideScopeActive(args) {
|
|
10917
|
+
return isSiteWideElement(args.selected) || isSiteWideElement(args.hoveredItem) || isSiteWideElement(args.hoveredNavContainer) || isSiteWideElement(args.active);
|
|
10918
|
+
}
|
|
10919
|
+
|
|
10883
10920
|
// src/ui/FloatingPanel.tsx
|
|
10884
10921
|
import {
|
|
10885
10922
|
useCallback as useCallback5,
|
|
@@ -13882,6 +13919,8 @@ function OhhwellsBridge() {
|
|
|
13882
13919
|
setIsItemDragging(false);
|
|
13883
13920
|
hoveredNavContainerRef.current = null;
|
|
13884
13921
|
setHoveredNavContainerRect(null);
|
|
13922
|
+
hoveredItemElRef.current = null;
|
|
13923
|
+
setHoveredItemRect(null);
|
|
13885
13924
|
if (!activeElRef.current) {
|
|
13886
13925
|
setNavGroupForceOpen(null, false);
|
|
13887
13926
|
setToolbarRect(null);
|
|
@@ -14760,6 +14799,33 @@ function OhhwellsBridge() {
|
|
|
14760
14799
|
selectRef.current = select;
|
|
14761
14800
|
selectFrameRef.current = selectFrame;
|
|
14762
14801
|
deselectRef.current = deselect;
|
|
14802
|
+
const lastSiteWideScopeRef = useRef9(null);
|
|
14803
|
+
useEffect12(() => {
|
|
14804
|
+
if (!isEditMode) {
|
|
14805
|
+
if (lastSiteWideScopeRef.current !== false) {
|
|
14806
|
+
lastSiteWideScopeRef.current = false;
|
|
14807
|
+
postToParent2({ type: "ow:site-wide-scope", active: false });
|
|
14808
|
+
}
|
|
14809
|
+
return;
|
|
14810
|
+
}
|
|
14811
|
+
const active = isSiteWideScopeActive({
|
|
14812
|
+
selected: selectedElRef.current,
|
|
14813
|
+
hoveredItem: hoveredItemElRef.current,
|
|
14814
|
+
hoveredNavContainer: hoveredNavContainerRef.current,
|
|
14815
|
+
active: activeElRef.current
|
|
14816
|
+
});
|
|
14817
|
+
if (lastSiteWideScopeRef.current === active) return;
|
|
14818
|
+
lastSiteWideScopeRef.current = active;
|
|
14819
|
+
postToParent2({ type: "ow:site-wide-scope", active });
|
|
14820
|
+
}, [
|
|
14821
|
+
isEditMode,
|
|
14822
|
+
hoveredItemRect,
|
|
14823
|
+
hoveredNavContainerRect,
|
|
14824
|
+
toolbarVariant,
|
|
14825
|
+
toolbarRect,
|
|
14826
|
+
isFooterFrameSelection,
|
|
14827
|
+
postToParent2
|
|
14828
|
+
]);
|
|
14763
14829
|
useLayoutEffect4(() => {
|
|
14764
14830
|
if (!subdomain || isEditMode) {
|
|
14765
14831
|
setFetchState("done");
|
|
@@ -15217,6 +15283,15 @@ function OhhwellsBridge() {
|
|
|
15217
15283
|
return;
|
|
15218
15284
|
}
|
|
15219
15285
|
}
|
|
15286
|
+
const logoEl = getLogoElement(target);
|
|
15287
|
+
if (logoEl) {
|
|
15288
|
+
e.preventDefault();
|
|
15289
|
+
e.stopPropagation();
|
|
15290
|
+
deselectRef.current();
|
|
15291
|
+
deactivateRef.current();
|
|
15292
|
+
postToParentRef.current({ type: "ow:open-logo-settings" });
|
|
15293
|
+
return;
|
|
15294
|
+
}
|
|
15220
15295
|
const editable = target.closest("[data-ohw-editable]");
|
|
15221
15296
|
if (editable) {
|
|
15222
15297
|
if (editable.dataset.ohwEditable === "link") {
|
|
@@ -15414,7 +15489,7 @@ function OhhwellsBridge() {
|
|
|
15414
15489
|
const allowFooterLinksHover = toolbarVariantRef.current !== "select-frame" || selectedIsFooterColumn;
|
|
15415
15490
|
if (allowNavContainerHover) {
|
|
15416
15491
|
const navContainer = target.closest("[data-ohw-nav-container]");
|
|
15417
|
-
if (navContainer && !getNavigationItemAnchor(target)) {
|
|
15492
|
+
if (navContainer && !getNavigationItemAnchor(target) && !getLogoElement(target)) {
|
|
15418
15493
|
hoveredNavContainerRef.current = navContainer;
|
|
15419
15494
|
setHoveredNavContainerRect(navContainer.getBoundingClientRect());
|
|
15420
15495
|
hoveredItemElRef.current = null;
|
|
@@ -15443,6 +15518,15 @@ function OhhwellsBridge() {
|
|
|
15443
15518
|
setHoveredNavContainerRect(null);
|
|
15444
15519
|
}
|
|
15445
15520
|
}
|
|
15521
|
+
const logoEl = getLogoElement(target);
|
|
15522
|
+
if (logoEl) {
|
|
15523
|
+
hoveredNavContainerRef.current = null;
|
|
15524
|
+
setHoveredNavContainerRect(null);
|
|
15525
|
+
if (selectedElRef.current === logoEl) return;
|
|
15526
|
+
hoveredItemElRef.current = logoEl;
|
|
15527
|
+
setHoveredItemRect(logoEl.getBoundingClientRect());
|
|
15528
|
+
return;
|
|
15529
|
+
}
|
|
15446
15530
|
const navAnchor = getNavigationItemAnchor(target);
|
|
15447
15531
|
if (navAnchor) {
|
|
15448
15532
|
hoveredNavContainerRef.current = null;
|
|
@@ -15480,6 +15564,12 @@ function OhhwellsBridge() {
|
|
|
15480
15564
|
setHoveredItemRect(hoverTarget.getBoundingClientRect());
|
|
15481
15565
|
} else if (!isInsideNavigationItem(editable)) {
|
|
15482
15566
|
hoverTarget.setAttribute("data-ohw-hovered", "");
|
|
15567
|
+
if (editable.closest("footer") || editable.closest('[data-ohw-section="footer"]')) {
|
|
15568
|
+
hoveredNavContainerRef.current = null;
|
|
15569
|
+
setHoveredNavContainerRect(null);
|
|
15570
|
+
hoveredItemElRef.current = editable;
|
|
15571
|
+
setHoveredItemRect(editable.getBoundingClientRect());
|
|
15572
|
+
}
|
|
15483
15573
|
}
|
|
15484
15574
|
}
|
|
15485
15575
|
};
|
|
@@ -15515,6 +15605,18 @@ function OhhwellsBridge() {
|
|
|
15515
15605
|
}
|
|
15516
15606
|
return;
|
|
15517
15607
|
}
|
|
15608
|
+
const logoEl = getLogoElement(target);
|
|
15609
|
+
if (logoEl) {
|
|
15610
|
+
const related2 = e.relatedTarget instanceof Element ? e.relatedTarget : null;
|
|
15611
|
+
if (related2 && (logoEl === related2 || logoEl.contains(related2) || related2.closest?.('[data-ohw-role="logo"], [data-ohw-logo]'))) {
|
|
15612
|
+
return;
|
|
15613
|
+
}
|
|
15614
|
+
if (hoveredItemElRef.current === logoEl) {
|
|
15615
|
+
hoveredItemElRef.current = null;
|
|
15616
|
+
setHoveredItemRect(null);
|
|
15617
|
+
}
|
|
15618
|
+
return;
|
|
15619
|
+
}
|
|
15518
15620
|
const editable = target.closest("[data-ohw-editable]");
|
|
15519
15621
|
if (!editable) return;
|
|
15520
15622
|
const related = e.relatedTarget instanceof Element ? e.relatedTarget : null;
|
|
@@ -15535,6 +15637,13 @@ function OhhwellsBridge() {
|
|
|
15535
15637
|
}
|
|
15536
15638
|
} else {
|
|
15537
15639
|
hoverTarget.removeAttribute("data-ohw-hovered");
|
|
15640
|
+
if (hoveredItemElRef.current === editable) {
|
|
15641
|
+
const stillOnEditable = related instanceof Element && related.closest("[data-ohw-editable]") === editable;
|
|
15642
|
+
if (!stillOnEditable) {
|
|
15643
|
+
hoveredItemElRef.current = null;
|
|
15644
|
+
setHoveredItemRect(null);
|
|
15645
|
+
}
|
|
15646
|
+
}
|
|
15538
15647
|
}
|
|
15539
15648
|
}
|
|
15540
15649
|
};
|
|
@@ -15651,6 +15760,26 @@ function OhhwellsBridge() {
|
|
|
15651
15760
|
hoveredNavContainerRef.current = null;
|
|
15652
15761
|
setHoveredNavContainerRect(null);
|
|
15653
15762
|
}
|
|
15763
|
+
const logoCandidates = [
|
|
15764
|
+
...document.querySelectorAll('[data-ohw-role="logo"], [data-ohw-logo]'),
|
|
15765
|
+
...document.querySelectorAll("nav a:not([data-ohw-href-key]), [data-ohw-nav-root] a:not([data-ohw-href-key])"),
|
|
15766
|
+
...document.querySelectorAll("footer img")
|
|
15767
|
+
];
|
|
15768
|
+
const seenLogos = /* @__PURE__ */ new Set();
|
|
15769
|
+
for (const candidate of logoCandidates) {
|
|
15770
|
+
const logo = getLogoElement(candidate);
|
|
15771
|
+
if (!logo || seenLogos.has(logo)) continue;
|
|
15772
|
+
seenLogos.add(logo);
|
|
15773
|
+
const r2 = logo.getBoundingClientRect();
|
|
15774
|
+
if (x < r2.left || x > r2.right || y < r2.top || y > r2.bottom) continue;
|
|
15775
|
+
hoveredNavContainerRef.current = null;
|
|
15776
|
+
setHoveredNavContainerRect(null);
|
|
15777
|
+
if (selectedElRef.current !== logo) {
|
|
15778
|
+
hoveredItemElRef.current = logo;
|
|
15779
|
+
setHoveredItemRect(logo.getBoundingClientRect());
|
|
15780
|
+
}
|
|
15781
|
+
return;
|
|
15782
|
+
}
|
|
15654
15783
|
const navContainers = Array.from(
|
|
15655
15784
|
document.querySelectorAll("[data-ohw-nav-container]")
|
|
15656
15785
|
);
|
|
@@ -16887,6 +17016,19 @@ function OhhwellsBridge() {
|
|
|
16887
17016
|
postToParentRef.current({ type: "ow:image-pick", key: stateCardImage.dataset.ohwKey ?? "", elementType: stateCardImage.dataset.ohwEditable ?? "image" });
|
|
16888
17017
|
return;
|
|
16889
17018
|
}
|
|
17019
|
+
const logoAtPoint = Array.from(
|
|
17020
|
+
document.querySelectorAll('[data-ohw-role="logo"], [data-ohw-logo]')
|
|
17021
|
+
).map((el) => getLogoElement(el)).find((logo) => {
|
|
17022
|
+
if (!logo) return false;
|
|
17023
|
+
const r2 = logo.getBoundingClientRect();
|
|
17024
|
+
return clientX >= r2.left && clientX <= r2.right && clientY >= r2.top && clientY <= r2.bottom;
|
|
17025
|
+
});
|
|
17026
|
+
if (logoAtPoint) {
|
|
17027
|
+
deselectRef.current();
|
|
17028
|
+
deactivateRef.current();
|
|
17029
|
+
postToParentRef.current({ type: "ow:open-logo-settings" });
|
|
17030
|
+
return;
|
|
17031
|
+
}
|
|
16890
17032
|
const textEditable = Array.from(
|
|
16891
17033
|
document.querySelectorAll(NON_MEDIA_SELECTOR)
|
|
16892
17034
|
).find((el) => {
|
|
@@ -17220,7 +17362,7 @@ function OhhwellsBridge() {
|
|
|
17220
17362
|
postToParent2({
|
|
17221
17363
|
type: "ow:ready",
|
|
17222
17364
|
version: "1",
|
|
17223
|
-
bridgeVersion: "0.1.
|
|
17365
|
+
bridgeVersion: "0.1.62",
|
|
17224
17366
|
path: pathname,
|
|
17225
17367
|
nodes: collectEditableNodes(editContentRef.current),
|
|
17226
17368
|
sections
|