@ohhwells/bridge 0.1.68-next.200 → 0.1.68-next.205

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 CHANGED
@@ -12101,12 +12101,17 @@ function deleteFooterColumn(column) {
12101
12101
  }
12102
12102
 
12103
12103
  // src/lib/logo-identity.ts
12104
- var LOGO_TEXT_KEYS = ["nav-logo-text", "footer-logo-text", "logo-text"];
12105
- var LOGO_IMAGE_KEYS = ["nav-logo-image", "footer-logo", "footer-logo-image"];
12104
+ var LOGO_TEXT_KEYS = ["nav-logo-text", "footer-logo-text", "logo-text", "nav-logo", "logo"];
12105
+ var LOGO_IMAGE_KEYS = [
12106
+ "nav-logo-image",
12107
+ "footer-logo",
12108
+ "footer-logo-image",
12109
+ "logo-image",
12110
+ "footer-logo-img"
12111
+ ];
12106
12112
  var LOGO_HREF_KEYS = ["nav-logo-href", "footer-logo-href", "logo-href"];
12107
12113
  var LOGO_PLACEHOLDER_KEY = "logo-is-placeholder";
12108
12114
  var LOGO_ALT_KEY = "logo-alt";
12109
- var LOGO_IMAGE_URL_KEY = "nav-logo-image";
12110
12115
  var PLACEHOLDER_BUSINESS_NAME = "Business name";
12111
12116
  function resolveLogoDisplayText(text) {
12112
12117
  const trimmed = (text ?? "").trim();
@@ -12126,6 +12131,21 @@ function ensureLogoHrefKey(root) {
12126
12131
  if (root.hasAttribute("data-ohw-href-key")) return;
12127
12132
  root.setAttribute("data-ohw-href-key", isFooterLogoRoot(root) ? "footer-logo-href" : "nav-logo-href");
12128
12133
  }
12134
+ function logoTextElement(root) {
12135
+ const SELECTOR = '[data-ohw-editable="plain"], [data-ohw-editable="text"]';
12136
+ if (root.matches(SELECTOR)) return root;
12137
+ const marked = root.querySelector(SELECTOR);
12138
+ if (marked) return marked;
12139
+ const hasOwnText = Array.from(root.childNodes).some(
12140
+ (node) => node.nodeType === Node.TEXT_NODE && node.textContent?.trim()
12141
+ );
12142
+ return hasOwnText ? root : null;
12143
+ }
12144
+ function logoRootImage(root) {
12145
+ const img = root.querySelector("img");
12146
+ const src = img?.getAttribute("src")?.trim() ?? "";
12147
+ return img && src && img.style.display !== "none" ? img : null;
12148
+ }
12129
12149
  function applyLogoIdentity(text, isPlaceholder) {
12130
12150
  const display = resolveLogoDisplayText(text);
12131
12151
  const placeholder = isPlaceholder || !text.trim() || display === PLACEHOLDER_BUSINESS_NAME;
@@ -12143,6 +12163,9 @@ function applyLogoIdentity(text, isPlaceholder) {
12143
12163
  document.querySelectorAll('[data-ohw-role="logo"], [data-ohw-logo]').forEach((el) => {
12144
12164
  if (placeholder) el.setAttribute("data-ohw-placeholder", "");
12145
12165
  else el.removeAttribute("data-ohw-placeholder");
12166
+ if (logoRootImage(el)) return;
12167
+ const textEl = logoTextElement(el);
12168
+ if (textEl && textEl.textContent !== display) textEl.textContent = display;
12146
12169
  });
12147
12170
  return display;
12148
12171
  }
@@ -12153,7 +12176,7 @@ function applyLogoImage(url, alt) {
12153
12176
  const imageKey = imageKeyForRoot(root);
12154
12177
  const textKey = textKeyForRoot(root);
12155
12178
  let img = root.querySelector(`img[data-ohw-key="${imageKey}"]`) ?? (root.querySelector(`[data-ohw-key="${imageKey}"]`) instanceof HTMLImageElement ? root.querySelector(`[data-ohw-key="${imageKey}"]`) : null) ?? root.querySelector("img");
12156
- let textEl = root.querySelector(`[data-ohw-key="${textKey}"]`) ?? root.querySelector('[data-ohw-key="logo-text"]');
12179
+ let textEl = root.querySelector(`[data-ohw-key="${textKey}"]`) ?? root.querySelector('[data-ohw-key="logo-text"]') ?? logoTextElement(root);
12157
12180
  if (url) {
12158
12181
  if (!img) {
12159
12182
  img = document.createElement("img");
@@ -12175,7 +12198,11 @@ function applyLogoImage(url, alt) {
12175
12198
  img.src = url;
12176
12199
  img.alt = displayAlt;
12177
12200
  img.style.display = "block";
12178
- if (textEl) textEl.style.display = "none";
12201
+ if (textEl === root) {
12202
+ Array.from(root.childNodes).filter((node) => node.nodeType === Node.TEXT_NODE).forEach((node) => node.remove());
12203
+ } else if (textEl) {
12204
+ textEl.style.display = "none";
12205
+ }
12179
12206
  root.removeAttribute("data-ohw-placeholder");
12180
12207
  return;
12181
12208
  }
@@ -12224,6 +12251,13 @@ function readLogoIdentityFromDom() {
12224
12251
  }
12225
12252
  let text = PLACEHOLDER_BUSINESS_NAME;
12226
12253
  let isPlaceholder = true;
12254
+ const rootWithText = Array.from(
12255
+ document.querySelectorAll('[data-ohw-role="logo"], [data-ohw-logo]')
12256
+ ).find((root) => logoTextElement(root)?.textContent?.trim());
12257
+ if (rootWithText) {
12258
+ text = logoTextElement(rootWithText).textContent.trim();
12259
+ isPlaceholder = rootWithText.hasAttribute("data-ohw-placeholder") || text === PLACEHOLDER_BUSINESS_NAME;
12260
+ }
12227
12261
  for (const key of LOGO_TEXT_KEYS) {
12228
12262
  const el = document.querySelector(`[data-ohw-key="${key}"]`);
12229
12263
  if (el?.textContent?.trim()) {
@@ -12254,7 +12288,7 @@ function applyLogoFromContent(content) {
12254
12288
  if (!hasLogoIdentity) return false;
12255
12289
  const logoText = content[LOGO_TEXT_KEYS[0]] ?? content[LOGO_TEXT_KEYS[1]] ?? readLogoIdentityFromDom().text;
12256
12290
  const logoAlt = content[LOGO_ALT_KEY] ?? logoText;
12257
- const rawLogoImage = content[LOGO_IMAGE_URL_KEY] ?? content["footer-logo"] ?? content["footer-logo-image"] ?? null;
12291
+ const rawLogoImage = LOGO_IMAGE_KEYS.map((key) => content[key]).find((value) => typeof value === "string" && value.trim()) ?? null;
12258
12292
  const logoImageUrl = typeof rawLogoImage === "string" && rawLogoImage.trim() ? rawLogoImage.trim() : null;
12259
12293
  const imageExplicitlyCleared = LOGO_IMAGE_KEYS.some((key) => key in content) && !logoImageUrl;
12260
12294
  const logoIsPlaceholder = LOGO_PLACEHOLDER_KEY in content ? content[LOGO_PLACEHOLDER_KEY] !== "false" : !logoImageUrl && (!logoText.trim() || logoText === PLACEHOLDER_BUSINESS_NAME);
@@ -14236,6 +14270,7 @@ function fadeInImageElement(img, onReady) {
14236
14270
  function applyEditableImageSrc(img, url) {
14237
14271
  img.removeAttribute("srcset");
14238
14272
  img.removeAttribute("sizes");
14273
+ if (img.loading === "lazy") img.loading = "eager";
14239
14274
  img.src = url;
14240
14275
  }
14241
14276
  function fadeInBgImage(el, url, onReady) {
@@ -14722,6 +14757,13 @@ function resolveFooterColumnSelectionTarget(target, clientX, clientY) {
14722
14757
  if (isPointOverNavItem(column, clientX, clientY)) return null;
14723
14758
  return column;
14724
14759
  }
14760
+ function isPointOverLogo(x, y) {
14761
+ for (const root of document.querySelectorAll('[data-ohw-role="logo"], [data-ohw-logo]')) {
14762
+ const r2 = root.getBoundingClientRect();
14763
+ if (r2.width > 0 && r2.height > 0 && x >= r2.left && x <= r2.right && y >= r2.top && y <= r2.bottom) return true;
14764
+ }
14765
+ return false;
14766
+ }
14725
14767
  function isPointOverNavigation(x, y) {
14726
14768
  const roots = /* @__PURE__ */ new Set();
14727
14769
  const navRoot = document.querySelector("[data-ohw-nav-root]") ?? document.querySelector("nav");
@@ -18495,6 +18537,11 @@ function OhhwellsBridge() {
18495
18537
  probeNavigationHoverAt(x, y);
18496
18538
  return;
18497
18539
  }
18540
+ if (isPointOverLogo(x, y)) {
18541
+ dismissImageHover();
18542
+ probeNavigationHoverAt(x, y);
18543
+ return;
18544
+ }
18498
18545
  const overMoreMenu = document.elementFromPoint(x, y)?.closest?.(
18499
18546
  '[data-ohw-more-menu], [data-slot="dropdown-menu-content"], [data-slot="dropdown-menu-item"]'
18500
18547
  );