@ohhwells/bridge 0.1.99 → 0.1.100

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.js CHANGED
@@ -2547,6 +2547,10 @@ var REPLACED_ATTR = "data-ohw-ai-replaced-by";
2547
2547
  var REMOVED_ATTR2 = "data-ohw-ai-removed";
2548
2548
  var TEMPLATE_HIDDEN_ATTR = "data-ohw-ai-template-hidden";
2549
2549
  var CHROME_SECTION_IDS = /* @__PURE__ */ new Set(["navbar", "footer"]);
2550
+ function isChromeSection2(el) {
2551
+ if (CHROME_SECTION_IDS.has(el.getAttribute("data-ohw-section") ?? "")) return true;
2552
+ return el.tagName === "HEADER" || el.tagName === "FOOTER";
2553
+ }
2550
2554
  function readRootVar(name) {
2551
2555
  if (typeof document === "undefined") return "";
2552
2556
  return getComputedStyle(document.documentElement).getPropertyValue(name).trim();
@@ -2598,7 +2602,10 @@ function deriveTemplateButtonStyle() {
2598
2602
  ].map((v) => v || "0px");
2599
2603
  const radius = corners.every((v) => v === corners[0]) ? corners[0] : corners.join(" ");
2600
2604
  const px = (v) => parseFloat(v) || 0;
2601
- const padY = Math.max(px(cs.paddingTop), px(cs.paddingBottom));
2605
+ const lineHeight = px(cs.lineHeight) || px(cs.fontSize) * 1.2;
2606
+ const contentH = btn.getBoundingClientRect().height - px(cs.borderTopWidth) - px(cs.borderBottomWidth);
2607
+ const impliedY = Math.round(Math.max(0, (contentH - lineHeight) / 2));
2608
+ const padY = Math.max(px(cs.paddingTop), px(cs.paddingBottom), impliedY);
2602
2609
  const padX = Math.max(px(cs.paddingLeft), px(cs.paddingRight));
2603
2610
  return {
2604
2611
  radius: radius || "10px",
@@ -2624,6 +2631,19 @@ function findPlacementAnchor(id, exclude) {
2624
2631
  for (const el of document.querySelectorAll(`[data-ohw-section="${CSS.escape(id)}"]`)) {
2625
2632
  if (el === exclude) continue;
2626
2633
  if (el.parentElement?.closest("[data-ohw-section]")) continue;
2634
+ if (isChromeSection2(el)) return null;
2635
+ return el;
2636
+ }
2637
+ return null;
2638
+ }
2639
+ function findFooterSection() {
2640
+ const byId = findTemplateSection("footer");
2641
+ if (byId) return byId;
2642
+ for (const el of Array.from(
2643
+ document.querySelectorAll("footer[data-ohw-section]")
2644
+ ).reverse()) {
2645
+ if (el.hasAttribute(CONTAINER_ATTR)) continue;
2646
+ if (el.parentElement?.closest("[data-ohw-section]")) continue;
2627
2647
  return el;
2628
2648
  }
2629
2649
  return null;
@@ -2650,7 +2670,7 @@ function placeContainer(container, entry) {
2650
2670
  return;
2651
2671
  }
2652
2672
  }
2653
- const footer = findTemplateSection("footer");
2673
+ const footer = findFooterSection();
2654
2674
  if (footer) {
2655
2675
  footer.insertAdjacentElement("beforebegin", container);
2656
2676
  } else {
@@ -2685,7 +2705,7 @@ function syncTemplateHidden(state, pageHasSections) {
2685
2705
  if (!hide) return;
2686
2706
  for (const el of Array.from(document.querySelectorAll("[data-ohw-section]"))) {
2687
2707
  if (el.hasAttribute(CONTAINER_ATTR)) continue;
2688
- if (CHROME_SECTION_IDS.has(el.getAttribute("data-ohw-section") ?? "")) continue;
2708
+ if (isChromeSection2(el)) continue;
2689
2709
  if (el.parentElement?.closest("[data-ohw-section]")) continue;
2690
2710
  if (el.hasAttribute(REPLACED_ATTR) || el.hasAttribute(REMOVED_ATTR2)) continue;
2691
2711
  el.style.display = "none";
@@ -20787,6 +20807,9 @@ function OhhwellsBridge() {
20787
20807
  if (reapNodes.length > 0) postToParentRef.current({ type: "ow:change", nodes: reapNodes });
20788
20808
  const hydratedHeight = document.body.scrollHeight;
20789
20809
  if (hydratedHeight > 50) postToParentRef.current({ type: "ow:height", height: hydratedHeight });
20810
+ if (parseAiSectionsState(aiSectionsRef.current).sections.length > 0) {
20811
+ postAiSectionsChanged();
20812
+ }
20790
20813
  postToParentRef.current({ type: "ow:hydrate-done" });
20791
20814
  };
20792
20815
  const handleUpdateLogoIdentity = (e) => {
@@ -21995,7 +22018,7 @@ function OhhwellsBridge() {
21995
22018
  postToParent2({
21996
22019
  type: "ow:ready",
21997
22020
  version: "1",
21998
- bridgeVersion: "0.1.98",
22021
+ bridgeVersion: "0.1.99",
21999
22022
  path: pathname,
22000
22023
  nodes: collectEditableNodes(editContentRef.current),
22001
22024
  sections