@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.cjs
CHANGED
|
@@ -10953,6 +10953,43 @@ function addFooterColumnWithPersist({
|
|
|
10953
10953
|
return result;
|
|
10954
10954
|
}
|
|
10955
10955
|
|
|
10956
|
+
// src/lib/site-wide-scope.ts
|
|
10957
|
+
function getLogoElement(el) {
|
|
10958
|
+
const marked = el.closest('[data-ohw-role="logo"], [data-ohw-logo]');
|
|
10959
|
+
if (marked) return marked;
|
|
10960
|
+
const root = el.closest("nav, [data-ohw-nav-root], footer");
|
|
10961
|
+
if (!root) return null;
|
|
10962
|
+
const anchor = el.closest("a");
|
|
10963
|
+
if (anchor && root.contains(anchor) && !anchor.hasAttribute("data-ohw-href-key") && !anchor.closest("[data-ohw-nav-container]") && Boolean(anchor.querySelector("img") || anchor.matches("img"))) {
|
|
10964
|
+
return anchor;
|
|
10965
|
+
}
|
|
10966
|
+
const img = el.matches("img") ? el : null;
|
|
10967
|
+
if (img && !img.closest("[data-ohw-href-key]") && !img.closest("[data-ohw-nav-container]") && (img.closest("footer") || img.closest("nav, [data-ohw-nav-root]"))) {
|
|
10968
|
+
return img;
|
|
10969
|
+
}
|
|
10970
|
+
return null;
|
|
10971
|
+
}
|
|
10972
|
+
function isInFooter(el) {
|
|
10973
|
+
if (!el) return false;
|
|
10974
|
+
return Boolean(el.closest("footer") || el.closest('[data-ohw-section="footer"]'));
|
|
10975
|
+
}
|
|
10976
|
+
function isSiteWideElement(el) {
|
|
10977
|
+
if (!el) return false;
|
|
10978
|
+
if (getLogoElement(el)) return true;
|
|
10979
|
+
if (isInFooter(el)) return true;
|
|
10980
|
+
if (el.hasAttribute("data-ohw-nav-container") || el.hasAttribute("data-ohw-nav-root")) {
|
|
10981
|
+
return true;
|
|
10982
|
+
}
|
|
10983
|
+
if (el.hasAttribute("data-ohw-href-key") && el.closest("nav, [data-ohw-nav-root], [data-ohw-nav-drawer], aside")) {
|
|
10984
|
+
return true;
|
|
10985
|
+
}
|
|
10986
|
+
if (el.closest('[data-ohw-role="navbar-button"]')) return true;
|
|
10987
|
+
return false;
|
|
10988
|
+
}
|
|
10989
|
+
function isSiteWideScopeActive(args) {
|
|
10990
|
+
return isSiteWideElement(args.selected) || isSiteWideElement(args.hoveredItem) || isSiteWideElement(args.hoveredNavContainer) || isSiteWideElement(args.active);
|
|
10991
|
+
}
|
|
10992
|
+
|
|
10956
10993
|
// src/ui/FloatingPanel.tsx
|
|
10957
10994
|
var import_react13 = require("react");
|
|
10958
10995
|
var import_lucide_react13 = require("lucide-react");
|
|
@@ -13949,6 +13986,8 @@ function OhhwellsBridge() {
|
|
|
13949
13986
|
setIsItemDragging(false);
|
|
13950
13987
|
hoveredNavContainerRef.current = null;
|
|
13951
13988
|
setHoveredNavContainerRect(null);
|
|
13989
|
+
hoveredItemElRef.current = null;
|
|
13990
|
+
setHoveredItemRect(null);
|
|
13952
13991
|
if (!activeElRef.current) {
|
|
13953
13992
|
setNavGroupForceOpen(null, false);
|
|
13954
13993
|
setToolbarRect(null);
|
|
@@ -14827,6 +14866,33 @@ function OhhwellsBridge() {
|
|
|
14827
14866
|
selectRef.current = select;
|
|
14828
14867
|
selectFrameRef.current = selectFrame;
|
|
14829
14868
|
deselectRef.current = deselect;
|
|
14869
|
+
const lastSiteWideScopeRef = (0, import_react16.useRef)(null);
|
|
14870
|
+
(0, import_react16.useEffect)(() => {
|
|
14871
|
+
if (!isEditMode) {
|
|
14872
|
+
if (lastSiteWideScopeRef.current !== false) {
|
|
14873
|
+
lastSiteWideScopeRef.current = false;
|
|
14874
|
+
postToParent2({ type: "ow:site-wide-scope", active: false });
|
|
14875
|
+
}
|
|
14876
|
+
return;
|
|
14877
|
+
}
|
|
14878
|
+
const active = isSiteWideScopeActive({
|
|
14879
|
+
selected: selectedElRef.current,
|
|
14880
|
+
hoveredItem: hoveredItemElRef.current,
|
|
14881
|
+
hoveredNavContainer: hoveredNavContainerRef.current,
|
|
14882
|
+
active: activeElRef.current
|
|
14883
|
+
});
|
|
14884
|
+
if (lastSiteWideScopeRef.current === active) return;
|
|
14885
|
+
lastSiteWideScopeRef.current = active;
|
|
14886
|
+
postToParent2({ type: "ow:site-wide-scope", active });
|
|
14887
|
+
}, [
|
|
14888
|
+
isEditMode,
|
|
14889
|
+
hoveredItemRect,
|
|
14890
|
+
hoveredNavContainerRect,
|
|
14891
|
+
toolbarVariant,
|
|
14892
|
+
toolbarRect,
|
|
14893
|
+
isFooterFrameSelection,
|
|
14894
|
+
postToParent2
|
|
14895
|
+
]);
|
|
14830
14896
|
(0, import_react16.useLayoutEffect)(() => {
|
|
14831
14897
|
if (!subdomain || isEditMode) {
|
|
14832
14898
|
setFetchState("done");
|
|
@@ -15284,6 +15350,15 @@ function OhhwellsBridge() {
|
|
|
15284
15350
|
return;
|
|
15285
15351
|
}
|
|
15286
15352
|
}
|
|
15353
|
+
const logoEl = getLogoElement(target);
|
|
15354
|
+
if (logoEl) {
|
|
15355
|
+
e.preventDefault();
|
|
15356
|
+
e.stopPropagation();
|
|
15357
|
+
deselectRef.current();
|
|
15358
|
+
deactivateRef.current();
|
|
15359
|
+
postToParentRef.current({ type: "ow:open-logo-settings" });
|
|
15360
|
+
return;
|
|
15361
|
+
}
|
|
15287
15362
|
const editable = target.closest("[data-ohw-editable]");
|
|
15288
15363
|
if (editable) {
|
|
15289
15364
|
if (editable.dataset.ohwEditable === "link") {
|
|
@@ -15481,7 +15556,7 @@ function OhhwellsBridge() {
|
|
|
15481
15556
|
const allowFooterLinksHover = toolbarVariantRef.current !== "select-frame" || selectedIsFooterColumn;
|
|
15482
15557
|
if (allowNavContainerHover) {
|
|
15483
15558
|
const navContainer = target.closest("[data-ohw-nav-container]");
|
|
15484
|
-
if (navContainer && !getNavigationItemAnchor(target)) {
|
|
15559
|
+
if (navContainer && !getNavigationItemAnchor(target) && !getLogoElement(target)) {
|
|
15485
15560
|
hoveredNavContainerRef.current = navContainer;
|
|
15486
15561
|
setHoveredNavContainerRect(navContainer.getBoundingClientRect());
|
|
15487
15562
|
hoveredItemElRef.current = null;
|
|
@@ -15510,6 +15585,15 @@ function OhhwellsBridge() {
|
|
|
15510
15585
|
setHoveredNavContainerRect(null);
|
|
15511
15586
|
}
|
|
15512
15587
|
}
|
|
15588
|
+
const logoEl = getLogoElement(target);
|
|
15589
|
+
if (logoEl) {
|
|
15590
|
+
hoveredNavContainerRef.current = null;
|
|
15591
|
+
setHoveredNavContainerRect(null);
|
|
15592
|
+
if (selectedElRef.current === logoEl) return;
|
|
15593
|
+
hoveredItemElRef.current = logoEl;
|
|
15594
|
+
setHoveredItemRect(logoEl.getBoundingClientRect());
|
|
15595
|
+
return;
|
|
15596
|
+
}
|
|
15513
15597
|
const navAnchor = getNavigationItemAnchor(target);
|
|
15514
15598
|
if (navAnchor) {
|
|
15515
15599
|
hoveredNavContainerRef.current = null;
|
|
@@ -15547,6 +15631,12 @@ function OhhwellsBridge() {
|
|
|
15547
15631
|
setHoveredItemRect(hoverTarget.getBoundingClientRect());
|
|
15548
15632
|
} else if (!isInsideNavigationItem(editable)) {
|
|
15549
15633
|
hoverTarget.setAttribute("data-ohw-hovered", "");
|
|
15634
|
+
if (editable.closest("footer") || editable.closest('[data-ohw-section="footer"]')) {
|
|
15635
|
+
hoveredNavContainerRef.current = null;
|
|
15636
|
+
setHoveredNavContainerRect(null);
|
|
15637
|
+
hoveredItemElRef.current = editable;
|
|
15638
|
+
setHoveredItemRect(editable.getBoundingClientRect());
|
|
15639
|
+
}
|
|
15550
15640
|
}
|
|
15551
15641
|
}
|
|
15552
15642
|
};
|
|
@@ -15582,6 +15672,18 @@ function OhhwellsBridge() {
|
|
|
15582
15672
|
}
|
|
15583
15673
|
return;
|
|
15584
15674
|
}
|
|
15675
|
+
const logoEl = getLogoElement(target);
|
|
15676
|
+
if (logoEl) {
|
|
15677
|
+
const related2 = e.relatedTarget instanceof Element ? e.relatedTarget : null;
|
|
15678
|
+
if (related2 && (logoEl === related2 || logoEl.contains(related2) || related2.closest?.('[data-ohw-role="logo"], [data-ohw-logo]'))) {
|
|
15679
|
+
return;
|
|
15680
|
+
}
|
|
15681
|
+
if (hoveredItemElRef.current === logoEl) {
|
|
15682
|
+
hoveredItemElRef.current = null;
|
|
15683
|
+
setHoveredItemRect(null);
|
|
15684
|
+
}
|
|
15685
|
+
return;
|
|
15686
|
+
}
|
|
15585
15687
|
const editable = target.closest("[data-ohw-editable]");
|
|
15586
15688
|
if (!editable) return;
|
|
15587
15689
|
const related = e.relatedTarget instanceof Element ? e.relatedTarget : null;
|
|
@@ -15602,6 +15704,13 @@ function OhhwellsBridge() {
|
|
|
15602
15704
|
}
|
|
15603
15705
|
} else {
|
|
15604
15706
|
hoverTarget.removeAttribute("data-ohw-hovered");
|
|
15707
|
+
if (hoveredItemElRef.current === editable) {
|
|
15708
|
+
const stillOnEditable = related instanceof Element && related.closest("[data-ohw-editable]") === editable;
|
|
15709
|
+
if (!stillOnEditable) {
|
|
15710
|
+
hoveredItemElRef.current = null;
|
|
15711
|
+
setHoveredItemRect(null);
|
|
15712
|
+
}
|
|
15713
|
+
}
|
|
15605
15714
|
}
|
|
15606
15715
|
}
|
|
15607
15716
|
};
|
|
@@ -15718,6 +15827,26 @@ function OhhwellsBridge() {
|
|
|
15718
15827
|
hoveredNavContainerRef.current = null;
|
|
15719
15828
|
setHoveredNavContainerRect(null);
|
|
15720
15829
|
}
|
|
15830
|
+
const logoCandidates = [
|
|
15831
|
+
...document.querySelectorAll('[data-ohw-role="logo"], [data-ohw-logo]'),
|
|
15832
|
+
...document.querySelectorAll("nav a:not([data-ohw-href-key]), [data-ohw-nav-root] a:not([data-ohw-href-key])"),
|
|
15833
|
+
...document.querySelectorAll("footer img")
|
|
15834
|
+
];
|
|
15835
|
+
const seenLogos = /* @__PURE__ */ new Set();
|
|
15836
|
+
for (const candidate of logoCandidates) {
|
|
15837
|
+
const logo = getLogoElement(candidate);
|
|
15838
|
+
if (!logo || seenLogos.has(logo)) continue;
|
|
15839
|
+
seenLogos.add(logo);
|
|
15840
|
+
const r2 = logo.getBoundingClientRect();
|
|
15841
|
+
if (x < r2.left || x > r2.right || y < r2.top || y > r2.bottom) continue;
|
|
15842
|
+
hoveredNavContainerRef.current = null;
|
|
15843
|
+
setHoveredNavContainerRect(null);
|
|
15844
|
+
if (selectedElRef.current !== logo) {
|
|
15845
|
+
hoveredItemElRef.current = logo;
|
|
15846
|
+
setHoveredItemRect(logo.getBoundingClientRect());
|
|
15847
|
+
}
|
|
15848
|
+
return;
|
|
15849
|
+
}
|
|
15721
15850
|
const navContainers = Array.from(
|
|
15722
15851
|
document.querySelectorAll("[data-ohw-nav-container]")
|
|
15723
15852
|
);
|
|
@@ -16954,6 +17083,19 @@ function OhhwellsBridge() {
|
|
|
16954
17083
|
postToParentRef.current({ type: "ow:image-pick", key: stateCardImage.dataset.ohwKey ?? "", elementType: stateCardImage.dataset.ohwEditable ?? "image" });
|
|
16955
17084
|
return;
|
|
16956
17085
|
}
|
|
17086
|
+
const logoAtPoint = Array.from(
|
|
17087
|
+
document.querySelectorAll('[data-ohw-role="logo"], [data-ohw-logo]')
|
|
17088
|
+
).map((el) => getLogoElement(el)).find((logo) => {
|
|
17089
|
+
if (!logo) return false;
|
|
17090
|
+
const r2 = logo.getBoundingClientRect();
|
|
17091
|
+
return clientX >= r2.left && clientX <= r2.right && clientY >= r2.top && clientY <= r2.bottom;
|
|
17092
|
+
});
|
|
17093
|
+
if (logoAtPoint) {
|
|
17094
|
+
deselectRef.current();
|
|
17095
|
+
deactivateRef.current();
|
|
17096
|
+
postToParentRef.current({ type: "ow:open-logo-settings" });
|
|
17097
|
+
return;
|
|
17098
|
+
}
|
|
16957
17099
|
const textEditable = Array.from(
|
|
16958
17100
|
document.querySelectorAll(NON_MEDIA_SELECTOR)
|
|
16959
17101
|
).find((el) => {
|
|
@@ -17287,7 +17429,7 @@ function OhhwellsBridge() {
|
|
|
17287
17429
|
postToParent2({
|
|
17288
17430
|
type: "ow:ready",
|
|
17289
17431
|
version: "1",
|
|
17290
|
-
bridgeVersion: "0.1.
|
|
17432
|
+
bridgeVersion: "0.1.62",
|
|
17291
17433
|
path: pathname,
|
|
17292
17434
|
nodes: collectEditableNodes(editContentRef.current),
|
|
17293
17435
|
sections
|