@ohhwells/bridge 0.1.51-next.124 → 0.1.51-next.126
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 +143 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +143 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -8976,6 +8976,43 @@ function deleteFooterColumn(column) {
|
|
|
8976
8976
|
};
|
|
8977
8977
|
}
|
|
8978
8978
|
|
|
8979
|
+
// src/lib/site-wide-scope.ts
|
|
8980
|
+
function getLogoElement(el) {
|
|
8981
|
+
const marked = el.closest('[data-ohw-role="logo"], [data-ohw-logo]');
|
|
8982
|
+
if (marked) return marked;
|
|
8983
|
+
const root = el.closest("nav, [data-ohw-nav-root], footer");
|
|
8984
|
+
if (!root) return null;
|
|
8985
|
+
const anchor = el.closest("a");
|
|
8986
|
+
if (anchor && root.contains(anchor) && !anchor.hasAttribute("data-ohw-href-key") && !anchor.closest("[data-ohw-nav-container]") && Boolean(anchor.querySelector("img") || anchor.matches("img"))) {
|
|
8987
|
+
return anchor;
|
|
8988
|
+
}
|
|
8989
|
+
const img = el.matches("img") ? el : null;
|
|
8990
|
+
if (img && !img.closest("[data-ohw-href-key]") && !img.closest("[data-ohw-nav-container]") && (img.closest("footer") || img.closest("nav, [data-ohw-nav-root]"))) {
|
|
8991
|
+
return img;
|
|
8992
|
+
}
|
|
8993
|
+
return null;
|
|
8994
|
+
}
|
|
8995
|
+
function isInFooter(el) {
|
|
8996
|
+
if (!el) return false;
|
|
8997
|
+
return Boolean(el.closest("footer") || el.closest('[data-ohw-section="footer"]'));
|
|
8998
|
+
}
|
|
8999
|
+
function isSiteWideElement(el) {
|
|
9000
|
+
if (!el) return false;
|
|
9001
|
+
if (getLogoElement(el)) return true;
|
|
9002
|
+
if (isInFooter(el)) return true;
|
|
9003
|
+
if (el.hasAttribute("data-ohw-nav-container") || el.hasAttribute("data-ohw-nav-root")) {
|
|
9004
|
+
return true;
|
|
9005
|
+
}
|
|
9006
|
+
if (el.hasAttribute("data-ohw-href-key") && el.closest("nav, [data-ohw-nav-root], [data-ohw-nav-drawer], aside")) {
|
|
9007
|
+
return true;
|
|
9008
|
+
}
|
|
9009
|
+
if (el.closest('[data-ohw-role="navbar-button"]')) return true;
|
|
9010
|
+
return false;
|
|
9011
|
+
}
|
|
9012
|
+
function isSiteWideScopeActive(args) {
|
|
9013
|
+
return isSiteWideElement(args.selected) || isSiteWideElement(args.hoveredItem) || isSiteWideElement(args.hoveredNavContainer) || isSiteWideElement(args.active);
|
|
9014
|
+
}
|
|
9015
|
+
|
|
8979
9016
|
// src/lib/add-footer-column.ts
|
|
8980
9017
|
function buildFooterColumnEditContentPatch(result) {
|
|
8981
9018
|
return {
|
|
@@ -11646,6 +11683,8 @@ function OhhwellsBridge() {
|
|
|
11646
11683
|
setIsItemDragging(false);
|
|
11647
11684
|
hoveredNavContainerRef.current = null;
|
|
11648
11685
|
setHoveredNavContainerRect(null);
|
|
11686
|
+
hoveredItemElRef.current = null;
|
|
11687
|
+
setHoveredItemRect(null);
|
|
11649
11688
|
if (!activeElRef.current) {
|
|
11650
11689
|
setNavGroupForceOpen(null, false);
|
|
11651
11690
|
setToolbarRect(null);
|
|
@@ -12390,6 +12429,33 @@ function OhhwellsBridge() {
|
|
|
12390
12429
|
selectRef.current = select;
|
|
12391
12430
|
selectFrameRef.current = selectFrame;
|
|
12392
12431
|
deselectRef.current = deselect;
|
|
12432
|
+
const lastSiteWideScopeRef = (0, import_react13.useRef)(null);
|
|
12433
|
+
(0, import_react13.useEffect)(() => {
|
|
12434
|
+
if (!isEditMode) {
|
|
12435
|
+
if (lastSiteWideScopeRef.current !== false) {
|
|
12436
|
+
lastSiteWideScopeRef.current = false;
|
|
12437
|
+
postToParent2({ type: "ow:site-wide-scope", active: false });
|
|
12438
|
+
}
|
|
12439
|
+
return;
|
|
12440
|
+
}
|
|
12441
|
+
const active = isSiteWideScopeActive({
|
|
12442
|
+
selected: selectedElRef.current,
|
|
12443
|
+
hoveredItem: hoveredItemElRef.current,
|
|
12444
|
+
hoveredNavContainer: hoveredNavContainerRef.current,
|
|
12445
|
+
active: activeElRef.current
|
|
12446
|
+
});
|
|
12447
|
+
if (lastSiteWideScopeRef.current === active) return;
|
|
12448
|
+
lastSiteWideScopeRef.current = active;
|
|
12449
|
+
postToParent2({ type: "ow:site-wide-scope", active });
|
|
12450
|
+
}, [
|
|
12451
|
+
isEditMode,
|
|
12452
|
+
hoveredItemRect,
|
|
12453
|
+
hoveredNavContainerRect,
|
|
12454
|
+
toolbarVariant,
|
|
12455
|
+
toolbarRect,
|
|
12456
|
+
isFooterFrameSelection,
|
|
12457
|
+
postToParent2
|
|
12458
|
+
]);
|
|
12393
12459
|
(0, import_react13.useLayoutEffect)(() => {
|
|
12394
12460
|
if (!subdomain || isEditMode) {
|
|
12395
12461
|
setFetchState("done");
|
|
@@ -12826,6 +12892,15 @@ function OhhwellsBridge() {
|
|
|
12826
12892
|
return;
|
|
12827
12893
|
}
|
|
12828
12894
|
}
|
|
12895
|
+
const logoEl = getLogoElement(target);
|
|
12896
|
+
if (logoEl) {
|
|
12897
|
+
e.preventDefault();
|
|
12898
|
+
e.stopPropagation();
|
|
12899
|
+
deselectRef.current();
|
|
12900
|
+
deactivateRef.current();
|
|
12901
|
+
postToParentRef.current({ type: "ow:open-logo-settings" });
|
|
12902
|
+
return;
|
|
12903
|
+
}
|
|
12829
12904
|
const editable = target.closest("[data-ohw-editable]");
|
|
12830
12905
|
if (editable) {
|
|
12831
12906
|
if (editable.dataset.ohwEditable === "link") {
|
|
@@ -12991,7 +13066,7 @@ function OhhwellsBridge() {
|
|
|
12991
13066
|
const allowFooterLinksHover = toolbarVariantRef.current !== "select-frame" || selectedIsFooterColumn;
|
|
12992
13067
|
if (allowNavContainerHover) {
|
|
12993
13068
|
const navContainer = target.closest("[data-ohw-nav-container]");
|
|
12994
|
-
if (navContainer && !getNavigationItemAnchor(target)) {
|
|
13069
|
+
if (navContainer && !getNavigationItemAnchor(target) && !getLogoElement(target)) {
|
|
12995
13070
|
hoveredNavContainerRef.current = navContainer;
|
|
12996
13071
|
setHoveredNavContainerRect(navContainer.getBoundingClientRect());
|
|
12997
13072
|
hoveredItemElRef.current = null;
|
|
@@ -13020,6 +13095,15 @@ function OhhwellsBridge() {
|
|
|
13020
13095
|
setHoveredNavContainerRect(null);
|
|
13021
13096
|
}
|
|
13022
13097
|
}
|
|
13098
|
+
const logoEl = getLogoElement(target);
|
|
13099
|
+
if (logoEl) {
|
|
13100
|
+
hoveredNavContainerRef.current = null;
|
|
13101
|
+
setHoveredNavContainerRect(null);
|
|
13102
|
+
if (selectedElRef.current === logoEl) return;
|
|
13103
|
+
hoveredItemElRef.current = logoEl;
|
|
13104
|
+
setHoveredItemRect(logoEl.getBoundingClientRect());
|
|
13105
|
+
return;
|
|
13106
|
+
}
|
|
13023
13107
|
const navAnchor = getNavigationItemAnchor(target);
|
|
13024
13108
|
if (navAnchor) {
|
|
13025
13109
|
hoveredNavContainerRef.current = null;
|
|
@@ -13052,6 +13136,12 @@ function OhhwellsBridge() {
|
|
|
13052
13136
|
setHoveredItemRect(hoverTarget.getBoundingClientRect());
|
|
13053
13137
|
} else if (!isInsideNavigationItem(editable)) {
|
|
13054
13138
|
hoverTarget.setAttribute("data-ohw-hovered", "");
|
|
13139
|
+
if (editable.closest("footer") || editable.closest('[data-ohw-section="footer"]')) {
|
|
13140
|
+
hoveredNavContainerRef.current = null;
|
|
13141
|
+
setHoveredNavContainerRect(null);
|
|
13142
|
+
hoveredItemElRef.current = editable;
|
|
13143
|
+
setHoveredItemRect(editable.getBoundingClientRect());
|
|
13144
|
+
}
|
|
13055
13145
|
}
|
|
13056
13146
|
}
|
|
13057
13147
|
};
|
|
@@ -13087,6 +13177,18 @@ function OhhwellsBridge() {
|
|
|
13087
13177
|
}
|
|
13088
13178
|
return;
|
|
13089
13179
|
}
|
|
13180
|
+
const logoEl = getLogoElement(target);
|
|
13181
|
+
if (logoEl) {
|
|
13182
|
+
const related2 = e.relatedTarget instanceof Element ? e.relatedTarget : null;
|
|
13183
|
+
if (related2 && (logoEl === related2 || logoEl.contains(related2) || related2.closest?.('[data-ohw-role="logo"], [data-ohw-logo]'))) {
|
|
13184
|
+
return;
|
|
13185
|
+
}
|
|
13186
|
+
if (hoveredItemElRef.current === logoEl) {
|
|
13187
|
+
hoveredItemElRef.current = null;
|
|
13188
|
+
setHoveredItemRect(null);
|
|
13189
|
+
}
|
|
13190
|
+
return;
|
|
13191
|
+
}
|
|
13090
13192
|
const editable = target.closest("[data-ohw-editable]");
|
|
13091
13193
|
if (!editable) return;
|
|
13092
13194
|
const related = e.relatedTarget instanceof Element ? e.relatedTarget : null;
|
|
@@ -13100,6 +13202,13 @@ function OhhwellsBridge() {
|
|
|
13100
13202
|
}
|
|
13101
13203
|
} else {
|
|
13102
13204
|
hoverTarget.removeAttribute("data-ohw-hovered");
|
|
13205
|
+
if (hoveredItemElRef.current === editable) {
|
|
13206
|
+
const stillOnEditable = related instanceof Element && related.closest("[data-ohw-editable]") === editable;
|
|
13207
|
+
if (!stillOnEditable) {
|
|
13208
|
+
hoveredItemElRef.current = null;
|
|
13209
|
+
setHoveredItemRect(null);
|
|
13210
|
+
}
|
|
13211
|
+
}
|
|
13103
13212
|
}
|
|
13104
13213
|
}
|
|
13105
13214
|
};
|
|
@@ -13216,6 +13325,26 @@ function OhhwellsBridge() {
|
|
|
13216
13325
|
hoveredNavContainerRef.current = null;
|
|
13217
13326
|
setHoveredNavContainerRect(null);
|
|
13218
13327
|
}
|
|
13328
|
+
const logoCandidates = [
|
|
13329
|
+
...document.querySelectorAll('[data-ohw-role="logo"], [data-ohw-logo]'),
|
|
13330
|
+
...document.querySelectorAll("nav a:not([data-ohw-href-key]), [data-ohw-nav-root] a:not([data-ohw-href-key])"),
|
|
13331
|
+
...document.querySelectorAll("footer img")
|
|
13332
|
+
];
|
|
13333
|
+
const seenLogos = /* @__PURE__ */ new Set();
|
|
13334
|
+
for (const candidate of logoCandidates) {
|
|
13335
|
+
const logo = getLogoElement(candidate);
|
|
13336
|
+
if (!logo || seenLogos.has(logo)) continue;
|
|
13337
|
+
seenLogos.add(logo);
|
|
13338
|
+
const r2 = logo.getBoundingClientRect();
|
|
13339
|
+
if (x < r2.left || x > r2.right || y < r2.top || y > r2.bottom) continue;
|
|
13340
|
+
hoveredNavContainerRef.current = null;
|
|
13341
|
+
setHoveredNavContainerRect(null);
|
|
13342
|
+
if (selectedElRef.current !== logo) {
|
|
13343
|
+
hoveredItemElRef.current = logo;
|
|
13344
|
+
setHoveredItemRect(logo.getBoundingClientRect());
|
|
13345
|
+
}
|
|
13346
|
+
return;
|
|
13347
|
+
}
|
|
13219
13348
|
const navContainers = Array.from(
|
|
13220
13349
|
document.querySelectorAll("[data-ohw-nav-container]")
|
|
13221
13350
|
);
|
|
@@ -14296,6 +14425,19 @@ function OhhwellsBridge() {
|
|
|
14296
14425
|
postToParentRef.current({ type: "ow:image-pick", key: stateCardImage.dataset.ohwKey ?? "", elementType: stateCardImage.dataset.ohwEditable ?? "image" });
|
|
14297
14426
|
return;
|
|
14298
14427
|
}
|
|
14428
|
+
const logoAtPoint = Array.from(
|
|
14429
|
+
document.querySelectorAll('[data-ohw-role="logo"], [data-ohw-logo]')
|
|
14430
|
+
).map((el) => getLogoElement(el)).find((logo) => {
|
|
14431
|
+
if (!logo) return false;
|
|
14432
|
+
const r2 = logo.getBoundingClientRect();
|
|
14433
|
+
return clientX >= r2.left && clientX <= r2.right && clientY >= r2.top && clientY <= r2.bottom;
|
|
14434
|
+
});
|
|
14435
|
+
if (logoAtPoint) {
|
|
14436
|
+
deselectRef.current();
|
|
14437
|
+
deactivateRef.current();
|
|
14438
|
+
postToParentRef.current({ type: "ow:open-logo-settings" });
|
|
14439
|
+
return;
|
|
14440
|
+
}
|
|
14299
14441
|
const textEditable = Array.from(
|
|
14300
14442
|
document.querySelectorAll(NON_MEDIA_SELECTOR)
|
|
14301
14443
|
).find((el) => {
|