@ohhwells/bridge 0.1.97 → 0.1.99
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 +28 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +28 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -526,9 +526,9 @@ function applyStylesToDom(store) {
|
|
|
526
526
|
);
|
|
527
527
|
if (!store) return;
|
|
528
528
|
for (const [sectionId, override] of Object.entries(store.sections)) {
|
|
529
|
-
const
|
|
530
|
-
|
|
531
|
-
);
|
|
529
|
+
const escaped = CSS.escape(sectionId);
|
|
530
|
+
const byInstance = document.querySelectorAll(`[data-ohw-instance="${escaped}"]`);
|
|
531
|
+
const sections = byInstance.length ? byInstance : document.querySelectorAll(`[data-ohw-section="${escaped}"]`);
|
|
532
532
|
for (const marker of Array.from(sections)) {
|
|
533
533
|
const section = marker.querySelector(":scope > [data-ai-section]") ?? marker;
|
|
534
534
|
for (const [prop, attr] of Object.entries(SECTION_ATTRS)) {
|
|
@@ -606,8 +606,9 @@ function parseSectionsFromRoot(root) {
|
|
|
606
606
|
const seen = /* @__PURE__ */ new Set();
|
|
607
607
|
const sections = [];
|
|
608
608
|
for (const el of root.querySelectorAll("[data-ohw-section]")) {
|
|
609
|
-
const id = el.getAttribute("data-ohw-section")
|
|
610
|
-
|
|
609
|
+
const id = el.getAttribute("data-ohw-instance") || el.getAttribute("data-ohw-section") || "";
|
|
610
|
+
const type = el.getAttribute("data-ohw-section") ?? "";
|
|
611
|
+
if (!id || seen.has(id) || LINK_PICKER_EXCLUDED_IDS.has(type)) continue;
|
|
611
612
|
if (el.parentElement?.closest("[data-ohw-section]")) continue;
|
|
612
613
|
if (el.hasAttribute("data-ohw-ai-template-hidden") || el.hasAttribute("data-ohw-ai-removed") || el.hasAttribute("data-ohw-ai-replaced-by"))
|
|
613
614
|
continue;
|
|
@@ -17150,7 +17151,26 @@ function OhhwellsBridge() {
|
|
|
17150
17151
|
return;
|
|
17151
17152
|
}
|
|
17152
17153
|
const r2 = target.getBoundingClientRect();
|
|
17153
|
-
|
|
17154
|
+
let top = r2.top, left = r2.x - TEXT_HOVER_SIDE_PAD, bottom = r2.bottom, right = r2.x + r2.width + TEXT_HOVER_SIDE_PAD;
|
|
17155
|
+
let clipParent = target.parentElement;
|
|
17156
|
+
while (clipParent) {
|
|
17157
|
+
const style = getComputedStyle(clipParent);
|
|
17158
|
+
if (style.overflowY === "hidden" || style.overflowY === "clip" || style.overflowX === "hidden" || style.overflowX === "clip") {
|
|
17159
|
+
const pr = clipParent.getBoundingClientRect();
|
|
17160
|
+
top = Math.max(top, pr.top);
|
|
17161
|
+
bottom = Math.min(bottom, pr.bottom);
|
|
17162
|
+
left = Math.max(left, pr.left);
|
|
17163
|
+
right = Math.min(right, pr.right);
|
|
17164
|
+
}
|
|
17165
|
+
if (clipParent === document.documentElement) break;
|
|
17166
|
+
clipParent = clipParent.parentElement;
|
|
17167
|
+
}
|
|
17168
|
+
const width = right - left, height = bottom - top;
|
|
17169
|
+
if (width <= 0 || height <= 0) {
|
|
17170
|
+
setHoveredTextRect(null);
|
|
17171
|
+
return;
|
|
17172
|
+
}
|
|
17173
|
+
setHoveredTextRect(new DOMRect(left, top, width, height));
|
|
17154
17174
|
};
|
|
17155
17175
|
const observer = new MutationObserver(sync);
|
|
17156
17176
|
observer.observe(document.documentElement, {
|
|
@@ -20324,12 +20344,11 @@ function OhhwellsBridge() {
|
|
|
20324
20344
|
}
|
|
20325
20345
|
const { y } = toProbeCoords(clientX, clientY, fromParentViewport);
|
|
20326
20346
|
const sections = Array.from(document.querySelectorAll("[data-ohw-section]")).filter(
|
|
20327
|
-
(el) => !el.hasAttribute("data-ohw-ai-template-hidden") && !el.hasAttribute("data-ohw-ai-removed") && !el.hasAttribute("data-ohw-ai-replaced-by") && el.getBoundingClientRect().height > 0
|
|
20347
|
+
(el) => !el.hasAttribute("data-ohw-ai-template-hidden") && !el.hasAttribute("data-ohw-ai-removed") && !el.hasAttribute("data-ohw-ai-replaced-by") && !isPageFrameSection(el) && el.getBoundingClientRect().height > 0
|
|
20328
20348
|
).sort((a, b) => a.getBoundingClientRect().top - b.getBoundingClientRect().top);
|
|
20329
20349
|
const ZONE = 20;
|
|
20330
20350
|
for (let i = 0; i < sections.length; i++) {
|
|
20331
20351
|
const a = sections[i];
|
|
20332
|
-
if (isPageFrameSection(a)) continue;
|
|
20333
20352
|
const b = sections[i + 1] ?? null;
|
|
20334
20353
|
const boundaryY = a.getBoundingClientRect().bottom;
|
|
20335
20354
|
if (Math.abs(y - boundaryY) <= ZONE) {
|
|
@@ -21976,7 +21995,7 @@ function OhhwellsBridge() {
|
|
|
21976
21995
|
postToParent2({
|
|
21977
21996
|
type: "ow:ready",
|
|
21978
21997
|
version: "1",
|
|
21979
|
-
bridgeVersion: "0.1.
|
|
21998
|
+
bridgeVersion: "0.1.98",
|
|
21980
21999
|
path: pathname,
|
|
21981
22000
|
nodes: collectEditableNodes(editContentRef.current),
|
|
21982
22001
|
sections
|