@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.cjs
CHANGED
|
@@ -3435,7 +3435,9 @@ function ToggleGroupItem({
|
|
|
3435
3435
|
Toggle,
|
|
3436
3436
|
{
|
|
3437
3437
|
pressed: groupValue === value,
|
|
3438
|
-
onPressedChange: () =>
|
|
3438
|
+
onPressedChange: (pressed) => {
|
|
3439
|
+
if (pressed) onValueChange(value);
|
|
3440
|
+
},
|
|
3439
3441
|
className: cn(
|
|
3440
3442
|
"text-foreground cursor-pointer hover:bg-transparent hover:text-foreground",
|
|
3441
3443
|
"data-[state=on]:bg-background data-[state=on]:shadow-sm",
|
|
@@ -4127,8 +4129,6 @@ function OhhwellsBridge() {
|
|
|
4127
4129
|
[data-ohw-editable-state], [data-ohw-editable-state] * { pointer-events: none !important; }
|
|
4128
4130
|
[data-ohw-editable-state][data-ohw-active-state] [data-ohw-editable] { pointer-events: auto !important; }
|
|
4129
4131
|
[data-ohw-editable-state][data-ohw-active-state][data-ohw-editable] { pointer-events: auto !important; }
|
|
4130
|
-
[data-ohw-editable-state] [data-ohw-editable="image"],
|
|
4131
|
-
[data-ohw-editable-state][data-ohw-editable="image"] { pointer-events: auto !important; }
|
|
4132
4132
|
`;
|
|
4133
4133
|
const forceHover = document.createElement("style");
|
|
4134
4134
|
forceHover.setAttribute("data-ohw-active-state-style", "");
|
|
@@ -4155,10 +4155,12 @@ function OhhwellsBridge() {
|
|
|
4155
4155
|
if (editable) {
|
|
4156
4156
|
if (editable.dataset.ohwEditable === "image" || editable.dataset.ohwEditable === "bg-image") {
|
|
4157
4157
|
e.preventDefault();
|
|
4158
|
+
e.stopPropagation();
|
|
4158
4159
|
postToParentRef.current({ type: "ow:image-pick", key: editable.dataset.ohwKey ?? "" });
|
|
4159
4160
|
return;
|
|
4160
4161
|
}
|
|
4161
4162
|
e.preventDefault();
|
|
4163
|
+
e.stopPropagation();
|
|
4162
4164
|
activateRef.current(editable);
|
|
4163
4165
|
return;
|
|
4164
4166
|
}
|
|
@@ -4223,7 +4225,7 @@ function OhhwellsBridge() {
|
|
|
4223
4225
|
};
|
|
4224
4226
|
const postImageHover = (imgEl, isDragOver = false, forceTextOverlap) => {
|
|
4225
4227
|
const r2 = getVisibleRect(imgEl);
|
|
4226
|
-
const hasTextOverlap = forceTextOverlap ??
|
|
4228
|
+
const hasTextOverlap = forceTextOverlap ?? false;
|
|
4227
4229
|
hoveredImageHasTextOverlapRef.current = hasTextOverlap;
|
|
4228
4230
|
postToParentRef.current({
|
|
4229
4231
|
type: "ow:image-hover",
|
|
@@ -4622,12 +4624,11 @@ function OhhwellsBridge() {
|
|
|
4622
4624
|
if (hoveredImageRef.current) {
|
|
4623
4625
|
const el = hoveredImageRef.current;
|
|
4624
4626
|
const r2 = el.getBoundingClientRect();
|
|
4625
|
-
const hasTextOverlap = el.dataset.ohwEditable === "bg-image" || el.hasAttribute("data-ohw-editable-state");
|
|
4626
4627
|
postToParentRef.current({
|
|
4627
4628
|
type: "ow:image-hover",
|
|
4628
4629
|
key: el.dataset.ohwKey ?? "",
|
|
4629
4630
|
rect: { top: r2.top, left: r2.left, width: r2.width, height: r2.height },
|
|
4630
|
-
hasTextOverlap
|
|
4631
|
+
hasTextOverlap: hoveredImageHasTextOverlapRef.current
|
|
4631
4632
|
});
|
|
4632
4633
|
}
|
|
4633
4634
|
};
|
|
@@ -4701,12 +4702,49 @@ function OhhwellsBridge() {
|
|
|
4701
4702
|
parentScrollRef.current = { iframeOffsetTop, headerH, canvasH };
|
|
4702
4703
|
if (activeElRef.current) applyToolbarPos(activeElRef.current.getBoundingClientRect());
|
|
4703
4704
|
};
|
|
4705
|
+
const handleClickAt = (e) => {
|
|
4706
|
+
if (e.data?.type !== "ow:click-at") return;
|
|
4707
|
+
const { clientX, clientY } = e.data;
|
|
4708
|
+
const allImages = Array.from(
|
|
4709
|
+
document.querySelectorAll('[data-ohw-editable="image"], [data-ohw-editable="bg-image"]')
|
|
4710
|
+
).filter((el) => !!el.closest("[data-ohw-editable-state]"));
|
|
4711
|
+
const stateCardImage = allImages.find((el) => {
|
|
4712
|
+
const ownerCard = el.closest("[data-ohw-editable-state]");
|
|
4713
|
+
if (ownerCard) {
|
|
4714
|
+
const inHoverState = ownerCard.getAttribute("data-ohw-active-state") === "hover";
|
|
4715
|
+
const elState = el.dataset.ohwState;
|
|
4716
|
+
if (el === ownerCard && inHoverState) return false;
|
|
4717
|
+
if (elState === "default" && inHoverState) return false;
|
|
4718
|
+
if (elState === "hover" && !inHoverState) return false;
|
|
4719
|
+
}
|
|
4720
|
+
const r2 = el.getBoundingClientRect();
|
|
4721
|
+
return clientX >= r2.left && clientX <= r2.right && clientY >= r2.top && clientY <= r2.bottom;
|
|
4722
|
+
});
|
|
4723
|
+
if (stateCardImage) {
|
|
4724
|
+
postToParentRef.current({ type: "ow:image-pick", key: stateCardImage.dataset.ohwKey ?? "" });
|
|
4725
|
+
return;
|
|
4726
|
+
}
|
|
4727
|
+
const textEditable = Array.from(
|
|
4728
|
+
document.querySelectorAll(
|
|
4729
|
+
'[data-ohw-editable]:not([data-ohw-editable="image"]):not([data-ohw-editable="bg-image"])'
|
|
4730
|
+
)
|
|
4731
|
+
).find((el) => {
|
|
4732
|
+
const r2 = el.getBoundingClientRect();
|
|
4733
|
+
return clientX >= r2.left && clientX <= r2.right && clientY >= r2.top && clientY <= r2.bottom;
|
|
4734
|
+
});
|
|
4735
|
+
if (textEditable) {
|
|
4736
|
+
activateRef.current(textEditable);
|
|
4737
|
+
return;
|
|
4738
|
+
}
|
|
4739
|
+
deactivateRef.current();
|
|
4740
|
+
};
|
|
4704
4741
|
window.addEventListener("message", handleSave);
|
|
4705
4742
|
window.addEventListener("message", handleImageUrl);
|
|
4706
4743
|
window.addEventListener("message", handleAnimLock);
|
|
4707
4744
|
window.addEventListener("message", handleCanvasHeight);
|
|
4708
4745
|
window.addEventListener("message", handleParentScroll);
|
|
4709
4746
|
window.addEventListener("message", handlePointerSync);
|
|
4747
|
+
window.addEventListener("message", handleClickAt);
|
|
4710
4748
|
document.addEventListener("click", handleClick, true);
|
|
4711
4749
|
document.addEventListener("paste", handlePaste, true);
|
|
4712
4750
|
document.addEventListener("input", handleInput, true);
|
|
@@ -4740,6 +4778,7 @@ function OhhwellsBridge() {
|
|
|
4740
4778
|
window.removeEventListener("message", handleCanvasHeight);
|
|
4741
4779
|
window.removeEventListener("message", handleParentScroll);
|
|
4742
4780
|
window.removeEventListener("message", handlePointerSync);
|
|
4781
|
+
window.removeEventListener("message", handleClickAt);
|
|
4743
4782
|
window.removeEventListener("message", handleHydrate);
|
|
4744
4783
|
window.removeEventListener("message", handleDeactivate);
|
|
4745
4784
|
autoSaveTimers.current.forEach(clearTimeout);
|