@ohhwells/bridge 0.1.12 → 0.1.13
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 +45 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +45 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3396,7 +3396,9 @@ function ToggleGroupItem({
|
|
|
3396
3396
|
Toggle,
|
|
3397
3397
|
{
|
|
3398
3398
|
pressed: groupValue === value,
|
|
3399
|
-
onPressedChange: () =>
|
|
3399
|
+
onPressedChange: (pressed) => {
|
|
3400
|
+
if (pressed) onValueChange(value);
|
|
3401
|
+
},
|
|
3400
3402
|
className: cn(
|
|
3401
3403
|
"text-foreground cursor-pointer hover:bg-transparent hover:text-foreground",
|
|
3402
3404
|
"data-[state=on]:bg-background data-[state=on]:shadow-sm",
|
|
@@ -4088,8 +4090,6 @@ function OhhwellsBridge() {
|
|
|
4088
4090
|
[data-ohw-editable-state], [data-ohw-editable-state] * { pointer-events: none !important; }
|
|
4089
4091
|
[data-ohw-editable-state][data-ohw-active-state] [data-ohw-editable] { pointer-events: auto !important; }
|
|
4090
4092
|
[data-ohw-editable-state][data-ohw-active-state][data-ohw-editable] { pointer-events: auto !important; }
|
|
4091
|
-
[data-ohw-editable-state] [data-ohw-editable="image"],
|
|
4092
|
-
[data-ohw-editable-state][data-ohw-editable="image"] { pointer-events: auto !important; }
|
|
4093
4093
|
`;
|
|
4094
4094
|
const forceHover = document.createElement("style");
|
|
4095
4095
|
forceHover.setAttribute("data-ohw-active-state-style", "");
|
|
@@ -4116,10 +4116,12 @@ function OhhwellsBridge() {
|
|
|
4116
4116
|
if (editable) {
|
|
4117
4117
|
if (editable.dataset.ohwEditable === "image" || editable.dataset.ohwEditable === "bg-image") {
|
|
4118
4118
|
e.preventDefault();
|
|
4119
|
+
e.stopPropagation();
|
|
4119
4120
|
postToParentRef.current({ type: "ow:image-pick", key: editable.dataset.ohwKey ?? "" });
|
|
4120
4121
|
return;
|
|
4121
4122
|
}
|
|
4122
4123
|
e.preventDefault();
|
|
4124
|
+
e.stopPropagation();
|
|
4123
4125
|
activateRef.current(editable);
|
|
4124
4126
|
return;
|
|
4125
4127
|
}
|
|
@@ -4184,7 +4186,7 @@ function OhhwellsBridge() {
|
|
|
4184
4186
|
};
|
|
4185
4187
|
const postImageHover = (imgEl, isDragOver = false, forceTextOverlap) => {
|
|
4186
4188
|
const r2 = getVisibleRect(imgEl);
|
|
4187
|
-
const hasTextOverlap = forceTextOverlap ??
|
|
4189
|
+
const hasTextOverlap = forceTextOverlap ?? false;
|
|
4188
4190
|
hoveredImageHasTextOverlapRef.current = hasTextOverlap;
|
|
4189
4191
|
postToParentRef.current({
|
|
4190
4192
|
type: "ow:image-hover",
|
|
@@ -4583,12 +4585,11 @@ function OhhwellsBridge() {
|
|
|
4583
4585
|
if (hoveredImageRef.current) {
|
|
4584
4586
|
const el = hoveredImageRef.current;
|
|
4585
4587
|
const r2 = el.getBoundingClientRect();
|
|
4586
|
-
const hasTextOverlap = el.dataset.ohwEditable === "bg-image" || el.hasAttribute("data-ohw-editable-state");
|
|
4587
4588
|
postToParentRef.current({
|
|
4588
4589
|
type: "ow:image-hover",
|
|
4589
4590
|
key: el.dataset.ohwKey ?? "",
|
|
4590
4591
|
rect: { top: r2.top, left: r2.left, width: r2.width, height: r2.height },
|
|
4591
|
-
hasTextOverlap
|
|
4592
|
+
hasTextOverlap: hoveredImageHasTextOverlapRef.current
|
|
4592
4593
|
});
|
|
4593
4594
|
}
|
|
4594
4595
|
};
|
|
@@ -4662,12 +4663,49 @@ function OhhwellsBridge() {
|
|
|
4662
4663
|
parentScrollRef.current = { iframeOffsetTop, headerH, canvasH };
|
|
4663
4664
|
if (activeElRef.current) applyToolbarPos(activeElRef.current.getBoundingClientRect());
|
|
4664
4665
|
};
|
|
4666
|
+
const handleClickAt = (e) => {
|
|
4667
|
+
if (e.data?.type !== "ow:click-at") return;
|
|
4668
|
+
const { clientX, clientY } = e.data;
|
|
4669
|
+
const allImages = Array.from(
|
|
4670
|
+
document.querySelectorAll('[data-ohw-editable="image"], [data-ohw-editable="bg-image"]')
|
|
4671
|
+
).filter((el) => !!el.closest("[data-ohw-editable-state]"));
|
|
4672
|
+
const stateCardImage = allImages.find((el) => {
|
|
4673
|
+
const ownerCard = el.closest("[data-ohw-editable-state]");
|
|
4674
|
+
if (ownerCard) {
|
|
4675
|
+
const inHoverState = ownerCard.getAttribute("data-ohw-active-state") === "hover";
|
|
4676
|
+
const elState = el.dataset.ohwState;
|
|
4677
|
+
if (el === ownerCard && inHoverState) return false;
|
|
4678
|
+
if (elState === "default" && inHoverState) return false;
|
|
4679
|
+
if (elState === "hover" && !inHoverState) return false;
|
|
4680
|
+
}
|
|
4681
|
+
const r2 = el.getBoundingClientRect();
|
|
4682
|
+
return clientX >= r2.left && clientX <= r2.right && clientY >= r2.top && clientY <= r2.bottom;
|
|
4683
|
+
});
|
|
4684
|
+
if (stateCardImage) {
|
|
4685
|
+
postToParentRef.current({ type: "ow:image-pick", key: stateCardImage.dataset.ohwKey ?? "" });
|
|
4686
|
+
return;
|
|
4687
|
+
}
|
|
4688
|
+
const textEditable = Array.from(
|
|
4689
|
+
document.querySelectorAll(
|
|
4690
|
+
'[data-ohw-editable]:not([data-ohw-editable="image"]):not([data-ohw-editable="bg-image"])'
|
|
4691
|
+
)
|
|
4692
|
+
).find((el) => {
|
|
4693
|
+
const r2 = el.getBoundingClientRect();
|
|
4694
|
+
return clientX >= r2.left && clientX <= r2.right && clientY >= r2.top && clientY <= r2.bottom;
|
|
4695
|
+
});
|
|
4696
|
+
if (textEditable) {
|
|
4697
|
+
activateRef.current(textEditable);
|
|
4698
|
+
return;
|
|
4699
|
+
}
|
|
4700
|
+
deactivateRef.current();
|
|
4701
|
+
};
|
|
4665
4702
|
window.addEventListener("message", handleSave);
|
|
4666
4703
|
window.addEventListener("message", handleImageUrl);
|
|
4667
4704
|
window.addEventListener("message", handleAnimLock);
|
|
4668
4705
|
window.addEventListener("message", handleCanvasHeight);
|
|
4669
4706
|
window.addEventListener("message", handleParentScroll);
|
|
4670
4707
|
window.addEventListener("message", handlePointerSync);
|
|
4708
|
+
window.addEventListener("message", handleClickAt);
|
|
4671
4709
|
document.addEventListener("click", handleClick, true);
|
|
4672
4710
|
document.addEventListener("paste", handlePaste, true);
|
|
4673
4711
|
document.addEventListener("input", handleInput, true);
|
|
@@ -4701,6 +4739,7 @@ function OhhwellsBridge() {
|
|
|
4701
4739
|
window.removeEventListener("message", handleCanvasHeight);
|
|
4702
4740
|
window.removeEventListener("message", handleParentScroll);
|
|
4703
4741
|
window.removeEventListener("message", handlePointerSync);
|
|
4742
|
+
window.removeEventListener("message", handleClickAt);
|
|
4704
4743
|
window.removeEventListener("message", handleHydrate);
|
|
4705
4744
|
window.removeEventListener("message", handleDeactivate);
|
|
4706
4745
|
autoSaveTimers.current.forEach(clearTimeout);
|