@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.js CHANGED
@@ -4085,6 +4085,7 @@ function OhhwellsBridge() {
4085
4085
  [data-ohw-editable][contenteditable] *::selection { background: ${PRIMARY}59 !important; }
4086
4086
  [data-ohw-editable-state], [data-ohw-editable-state] * { pointer-events: none !important; }
4087
4087
  [data-ohw-editable-state][data-ohw-active-state] [data-ohw-editable] { pointer-events: auto !important; }
4088
+ [data-ohw-editable]:not([data-ohw-editable="image"]):not([data-ohw-editable="bg-image"]) { pointer-events: auto !important; }
4088
4089
  `;
4089
4090
  const forceHover = document.createElement("style");
4090
4091
  forceHover.setAttribute("data-ohw-active-state-style", "");
@@ -4179,10 +4180,13 @@ function OhhwellsBridge() {
4179
4180
  };
4180
4181
  const postImageHover = (imgEl, isDragOver = false) => {
4181
4182
  const r2 = getVisibleRect(imgEl);
4183
+ const hasTextOverlap = imgEl.dataset.ohwEditable === "bg-image" || imgEl.hasAttribute("data-ohw-editable-state");
4184
+ console.log("[OHW] postImageHover", { key: imgEl.dataset.ohwKey, editable: imgEl.dataset.ohwEditable, hasState: imgEl.hasAttribute("data-ohw-editable-state"), hasTextOverlap });
4182
4185
  postToParentRef.current({
4183
4186
  type: "ow:image-hover",
4184
4187
  key: imgEl.dataset.ohwKey ?? "",
4185
4188
  rect: { top: r2.top, left: r2.left, width: r2.width, height: r2.height },
4189
+ hasTextOverlap,
4186
4190
  ...isDragOver ? { isDragOver: true } : {}
4187
4191
  });
4188
4192
  const track = imgEl.closest("[data-ohw-hover-pause]");
@@ -4230,7 +4234,15 @@ function OhhwellsBridge() {
4230
4234
  return smallest;
4231
4235
  };
4232
4236
  const probeImageAt = (clientX, clientY, isDragOver = false, fromParentViewport = false) => {
4233
- if (activeElRef.current) return;
4237
+ if (activeElRef.current) {
4238
+ console.log("[OHW] probeImageAt: text active, suppressing image hover");
4239
+ if (hoveredImageRef.current) {
4240
+ hoveredImageRef.current = null;
4241
+ resumeAnimTracks();
4242
+ postToParentRef.current({ type: "ow:image-unhover" });
4243
+ }
4244
+ return;
4245
+ }
4234
4246
  const toggleEl = document.querySelector("[data-ohw-state-toggle]");
4235
4247
  if (toggleEl) {
4236
4248
  const { x, y } = toProbeCoords(clientX, clientY, fromParentViewport);
@@ -4256,15 +4268,20 @@ function OhhwellsBridge() {
4256
4268
  }
4257
4269
  return;
4258
4270
  }
4259
- const topEditable = topEl?.closest("[data-ohw-editable]");
4260
- if (topEditable && topEditable.dataset.ohwEditable !== "image" && topEditable.dataset.ohwEditable !== "bg-image") {
4271
+ const textEditable = Array.from(
4272
+ document.querySelectorAll('[data-ohw-editable]:not([data-ohw-editable="image"]):not([data-ohw-editable="bg-image"])')
4273
+ ).find((el) => {
4274
+ const er = el.getBoundingClientRect();
4275
+ return x >= er.left && x <= er.right && y >= er.top && y <= er.bottom;
4276
+ });
4277
+ if (textEditable) {
4261
4278
  if (hoveredImageRef.current) {
4262
4279
  hoveredImageRef.current = null;
4263
4280
  resumeAnimTracks();
4264
4281
  postToParentRef.current({ type: "ow:image-unhover" });
4265
4282
  }
4266
4283
  document.querySelectorAll("[data-ohw-hovered]").forEach((el) => el.removeAttribute("data-ohw-hovered"));
4267
- topEditable.setAttribute("data-ohw-hovered", "");
4284
+ if (!textEditable.hasAttribute("contenteditable")) textEditable.setAttribute("data-ohw-hovered", "");
4268
4285
  return;
4269
4286
  }
4270
4287
  const activeHovered = document.querySelector("[data-ohw-hovered]");
@@ -4290,9 +4307,20 @@ function OhhwellsBridge() {
4290
4307
  } else {
4291
4308
  const inIframeView = clientX >= 0 && clientY >= 0 && clientX <= window.innerWidth && clientY <= window.innerHeight;
4292
4309
  if (!inIframeView) return;
4293
- hoveredImageRef.current = null;
4294
- resumeAnimTracks();
4295
- postToParentRef.current({ type: "ow:image-unhover" });
4310
+ if (hoveredImageRef.current) {
4311
+ hoveredImageRef.current = null;
4312
+ resumeAnimTracks();
4313
+ postToParentRef.current({ type: "ow:image-unhover" });
4314
+ }
4315
+ const { x, y } = toProbeCoords(clientX, clientY, fromParentViewport);
4316
+ const textEl = Array.from(
4317
+ document.querySelectorAll('[data-ohw-editable]:not([data-ohw-editable="image"]):not([data-ohw-editable="bg-image"])')
4318
+ ).find((el) => {
4319
+ const er = el.getBoundingClientRect();
4320
+ return x >= er.left && x <= er.right && y >= er.top && y <= er.bottom;
4321
+ });
4322
+ document.querySelectorAll("[data-ohw-hovered]").forEach((el) => el.removeAttribute("data-ohw-hovered"));
4323
+ if (textEl && !textEl.hasAttribute("contenteditable")) textEl.setAttribute("data-ohw-hovered", "");
4296
4324
  }
4297
4325
  };
4298
4326
  const probeHoverCardsAt = (clientX, clientY, fromParentViewport = false) => {
@@ -4530,11 +4558,14 @@ function OhhwellsBridge() {
4530
4558
  setToggleState((prev) => prev ? { ...prev, rect } : null);
4531
4559
  }
4532
4560
  if (hoveredImageRef.current) {
4533
- const r2 = hoveredImageRef.current.getBoundingClientRect();
4561
+ const el = hoveredImageRef.current;
4562
+ const r2 = el.getBoundingClientRect();
4563
+ const hasTextOverlap = el.dataset.ohwEditable === "bg-image" || el.hasAttribute("data-ohw-editable-state");
4534
4564
  postToParentRef.current({
4535
4565
  type: "ow:image-hover",
4536
- key: hoveredImageRef.current.dataset.ohwKey ?? "",
4537
- rect: { top: r2.top, left: r2.left, width: r2.width, height: r2.height }
4566
+ key: el.dataset.ohwKey ?? "",
4567
+ rect: { top: r2.top, left: r2.left, width: r2.width, height: r2.height },
4568
+ hasTextOverlap
4538
4569
  });
4539
4570
  }
4540
4571
  };