@ohhwells/bridge 0.1.8 → 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 +48 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +48 -13
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3907,6 +3907,10 @@ function OhhwellsBridge() {
|
|
|
3907
3907
|
const activate = useCallback((el) => {
|
|
3908
3908
|
if (activeElRef.current === el) return;
|
|
3909
3909
|
deactivate();
|
|
3910
|
+
if (hoveredImageRef.current) {
|
|
3911
|
+
hoveredImageRef.current = null;
|
|
3912
|
+
postToParentRef.current({ type: "ow:image-unhover" });
|
|
3913
|
+
}
|
|
3910
3914
|
el.setAttribute("contenteditable", "true");
|
|
3911
3915
|
el.removeAttribute("data-ohw-hovered");
|
|
3912
3916
|
activeElRef.current = el;
|
|
@@ -4081,6 +4085,7 @@ function OhhwellsBridge() {
|
|
|
4081
4085
|
[data-ohw-editable][contenteditable] *::selection { background: ${PRIMARY}59 !important; }
|
|
4082
4086
|
[data-ohw-editable-state], [data-ohw-editable-state] * { pointer-events: none !important; }
|
|
4083
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; }
|
|
4084
4089
|
`;
|
|
4085
4090
|
const forceHover = document.createElement("style");
|
|
4086
4091
|
forceHover.setAttribute("data-ohw-active-state-style", "");
|
|
@@ -4175,10 +4180,13 @@ function OhhwellsBridge() {
|
|
|
4175
4180
|
};
|
|
4176
4181
|
const postImageHover = (imgEl, isDragOver = false) => {
|
|
4177
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 });
|
|
4178
4185
|
postToParentRef.current({
|
|
4179
4186
|
type: "ow:image-hover",
|
|
4180
4187
|
key: imgEl.dataset.ohwKey ?? "",
|
|
4181
4188
|
rect: { top: r2.top, left: r2.left, width: r2.width, height: r2.height },
|
|
4189
|
+
hasTextOverlap,
|
|
4182
4190
|
...isDragOver ? { isDragOver: true } : {}
|
|
4183
4191
|
});
|
|
4184
4192
|
const track = imgEl.closest("[data-ohw-hover-pause]");
|
|
@@ -4225,7 +4233,16 @@ function OhhwellsBridge() {
|
|
|
4225
4233
|
}
|
|
4226
4234
|
return smallest;
|
|
4227
4235
|
};
|
|
4228
|
-
const probeImageAt = (clientX, clientY, isDragOver = false, fromParentViewport = false
|
|
4236
|
+
const probeImageAt = (clientX, clientY, isDragOver = false, fromParentViewport = false) => {
|
|
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
|
+
}
|
|
4229
4246
|
const toggleEl = document.querySelector("[data-ohw-state-toggle]");
|
|
4230
4247
|
if (toggleEl) {
|
|
4231
4248
|
const { x, y } = toProbeCoords(clientX, clientY, fromParentViewport);
|
|
@@ -4251,16 +4268,20 @@ function OhhwellsBridge() {
|
|
|
4251
4268
|
}
|
|
4252
4269
|
return;
|
|
4253
4270
|
}
|
|
4254
|
-
const
|
|
4255
|
-
|
|
4256
|
-
|
|
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) {
|
|
4257
4278
|
if (hoveredImageRef.current) {
|
|
4258
4279
|
hoveredImageRef.current = null;
|
|
4259
4280
|
resumeAnimTracks();
|
|
4260
4281
|
postToParentRef.current({ type: "ow:image-unhover" });
|
|
4261
4282
|
}
|
|
4262
4283
|
document.querySelectorAll("[data-ohw-hovered]").forEach((el) => el.removeAttribute("data-ohw-hovered"));
|
|
4263
|
-
|
|
4284
|
+
if (!textEditable.hasAttribute("contenteditable")) textEditable.setAttribute("data-ohw-hovered", "");
|
|
4264
4285
|
return;
|
|
4265
4286
|
}
|
|
4266
4287
|
const activeHovered = document.querySelector("[data-ohw-hovered]");
|
|
@@ -4286,9 +4307,20 @@ function OhhwellsBridge() {
|
|
|
4286
4307
|
} else {
|
|
4287
4308
|
const inIframeView = clientX >= 0 && clientY >= 0 && clientX <= window.innerWidth && clientY <= window.innerHeight;
|
|
4288
4309
|
if (!inIframeView) return;
|
|
4289
|
-
hoveredImageRef.current
|
|
4290
|
-
|
|
4291
|
-
|
|
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", "");
|
|
4292
4324
|
}
|
|
4293
4325
|
};
|
|
4294
4326
|
const probeHoverCardsAt = (clientX, clientY, fromParentViewport = false) => {
|
|
@@ -4325,9 +4357,9 @@ function OhhwellsBridge() {
|
|
|
4325
4357
|
};
|
|
4326
4358
|
const handlePointerSync = (e) => {
|
|
4327
4359
|
if (e.data?.type !== "ow:pointer-sync") return;
|
|
4328
|
-
const { clientX, clientY
|
|
4360
|
+
const { clientX, clientY } = e.data;
|
|
4329
4361
|
if (typeof clientX !== "number" || typeof clientY !== "number") return;
|
|
4330
|
-
probeImageAt(clientX, clientY
|
|
4362
|
+
probeImageAt(clientX, clientY);
|
|
4331
4363
|
probeHoverCardsAt(clientX, clientY);
|
|
4332
4364
|
};
|
|
4333
4365
|
const handleDragOver = (e) => {
|
|
@@ -4526,11 +4558,14 @@ function OhhwellsBridge() {
|
|
|
4526
4558
|
setToggleState((prev) => prev ? { ...prev, rect } : null);
|
|
4527
4559
|
}
|
|
4528
4560
|
if (hoveredImageRef.current) {
|
|
4529
|
-
const
|
|
4561
|
+
const el = hoveredImageRef.current;
|
|
4562
|
+
const r2 = el.getBoundingClientRect();
|
|
4563
|
+
const hasTextOverlap = el.dataset.ohwEditable === "bg-image" || el.hasAttribute("data-ohw-editable-state");
|
|
4530
4564
|
postToParentRef.current({
|
|
4531
4565
|
type: "ow:image-hover",
|
|
4532
|
-
key:
|
|
4533
|
-
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
|
|
4534
4569
|
});
|
|
4535
4570
|
}
|
|
4536
4571
|
};
|