@ohhwells/bridge 0.1.9 → 0.1.10

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
@@ -4124,6 +4124,7 @@ function OhhwellsBridge() {
4124
4124
  [data-ohw-editable][contenteditable] *::selection { background: ${PRIMARY}59 !important; }
4125
4125
  [data-ohw-editable-state], [data-ohw-editable-state] * { pointer-events: none !important; }
4126
4126
  [data-ohw-editable-state][data-ohw-active-state] [data-ohw-editable] { pointer-events: auto !important; }
4127
+ [data-ohw-editable]:not([data-ohw-editable="image"]):not([data-ohw-editable="bg-image"]) { pointer-events: auto !important; }
4127
4128
  `;
4128
4129
  const forceHover = document.createElement("style");
4129
4130
  forceHover.setAttribute("data-ohw-active-state-style", "");
@@ -4218,10 +4219,13 @@ function OhhwellsBridge() {
4218
4219
  };
4219
4220
  const postImageHover = (imgEl, isDragOver = false) => {
4220
4221
  const r2 = getVisibleRect(imgEl);
4222
+ const hasTextOverlap = imgEl.dataset.ohwEditable === "bg-image" || imgEl.hasAttribute("data-ohw-editable-state");
4223
+ console.log("[OHW] postImageHover", { key: imgEl.dataset.ohwKey, editable: imgEl.dataset.ohwEditable, hasState: imgEl.hasAttribute("data-ohw-editable-state"), hasTextOverlap });
4221
4224
  postToParentRef.current({
4222
4225
  type: "ow:image-hover",
4223
4226
  key: imgEl.dataset.ohwKey ?? "",
4224
4227
  rect: { top: r2.top, left: r2.left, width: r2.width, height: r2.height },
4228
+ hasTextOverlap,
4225
4229
  ...isDragOver ? { isDragOver: true } : {}
4226
4230
  });
4227
4231
  const track = imgEl.closest("[data-ohw-hover-pause]");
@@ -4269,7 +4273,15 @@ function OhhwellsBridge() {
4269
4273
  return smallest;
4270
4274
  };
4271
4275
  const probeImageAt = (clientX, clientY, isDragOver = false, fromParentViewport = false) => {
4272
- if (activeElRef.current) return;
4276
+ if (activeElRef.current) {
4277
+ console.log("[OHW] probeImageAt: text active, suppressing image hover");
4278
+ if (hoveredImageRef.current) {
4279
+ hoveredImageRef.current = null;
4280
+ resumeAnimTracks();
4281
+ postToParentRef.current({ type: "ow:image-unhover" });
4282
+ }
4283
+ return;
4284
+ }
4273
4285
  const toggleEl = document.querySelector("[data-ohw-state-toggle]");
4274
4286
  if (toggleEl) {
4275
4287
  const { x, y } = toProbeCoords(clientX, clientY, fromParentViewport);
@@ -4295,15 +4307,20 @@ function OhhwellsBridge() {
4295
4307
  }
4296
4308
  return;
4297
4309
  }
4298
- const topEditable = topEl?.closest("[data-ohw-editable]");
4299
- if (topEditable && topEditable.dataset.ohwEditable !== "image" && topEditable.dataset.ohwEditable !== "bg-image") {
4310
+ const textEditable = Array.from(
4311
+ document.querySelectorAll('[data-ohw-editable]:not([data-ohw-editable="image"]):not([data-ohw-editable="bg-image"])')
4312
+ ).find((el) => {
4313
+ const er = el.getBoundingClientRect();
4314
+ return x >= er.left && x <= er.right && y >= er.top && y <= er.bottom;
4315
+ });
4316
+ if (textEditable) {
4300
4317
  if (hoveredImageRef.current) {
4301
4318
  hoveredImageRef.current = null;
4302
4319
  resumeAnimTracks();
4303
4320
  postToParentRef.current({ type: "ow:image-unhover" });
4304
4321
  }
4305
4322
  document.querySelectorAll("[data-ohw-hovered]").forEach((el) => el.removeAttribute("data-ohw-hovered"));
4306
- topEditable.setAttribute("data-ohw-hovered", "");
4323
+ if (!textEditable.hasAttribute("contenteditable")) textEditable.setAttribute("data-ohw-hovered", "");
4307
4324
  return;
4308
4325
  }
4309
4326
  const activeHovered = document.querySelector("[data-ohw-hovered]");
@@ -4329,9 +4346,20 @@ function OhhwellsBridge() {
4329
4346
  } else {
4330
4347
  const inIframeView = clientX >= 0 && clientY >= 0 && clientX <= window.innerWidth && clientY <= window.innerHeight;
4331
4348
  if (!inIframeView) return;
4332
- hoveredImageRef.current = null;
4333
- resumeAnimTracks();
4334
- postToParentRef.current({ type: "ow:image-unhover" });
4349
+ if (hoveredImageRef.current) {
4350
+ hoveredImageRef.current = null;
4351
+ resumeAnimTracks();
4352
+ postToParentRef.current({ type: "ow:image-unhover" });
4353
+ }
4354
+ const { x, y } = toProbeCoords(clientX, clientY, fromParentViewport);
4355
+ const textEl = Array.from(
4356
+ document.querySelectorAll('[data-ohw-editable]:not([data-ohw-editable="image"]):not([data-ohw-editable="bg-image"])')
4357
+ ).find((el) => {
4358
+ const er = el.getBoundingClientRect();
4359
+ return x >= er.left && x <= er.right && y >= er.top && y <= er.bottom;
4360
+ });
4361
+ document.querySelectorAll("[data-ohw-hovered]").forEach((el) => el.removeAttribute("data-ohw-hovered"));
4362
+ if (textEl && !textEl.hasAttribute("contenteditable")) textEl.setAttribute("data-ohw-hovered", "");
4335
4363
  }
4336
4364
  };
4337
4365
  const probeHoverCardsAt = (clientX, clientY, fromParentViewport = false) => {
@@ -4569,11 +4597,14 @@ function OhhwellsBridge() {
4569
4597
  setToggleState((prev) => prev ? { ...prev, rect } : null);
4570
4598
  }
4571
4599
  if (hoveredImageRef.current) {
4572
- const r2 = hoveredImageRef.current.getBoundingClientRect();
4600
+ const el = hoveredImageRef.current;
4601
+ const r2 = el.getBoundingClientRect();
4602
+ const hasTextOverlap = el.dataset.ohwEditable === "bg-image" || el.hasAttribute("data-ohw-editable-state");
4573
4603
  postToParentRef.current({
4574
4604
  type: "ow:image-hover",
4575
- key: hoveredImageRef.current.dataset.ohwKey ?? "",
4576
- rect: { top: r2.top, left: r2.left, width: r2.width, height: r2.height }
4605
+ key: el.dataset.ohwKey ?? "",
4606
+ rect: { top: r2.top, left: r2.left, width: r2.width, height: r2.height },
4607
+ hasTextOverlap
4577
4608
  });
4578
4609
  }
4579
4610
  };