@ohhwells/bridge 0.1.39-next.72 → 0.1.39-next.76
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 +57 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +57 -22
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -8157,6 +8157,7 @@ function OhhwellsBridge() {
|
|
|
8157
8157
|
const [mediaHover, setMediaHover] = (0, import_react9.useState)(null);
|
|
8158
8158
|
const [carouselHover, setCarouselHover] = (0, import_react9.useState)(null);
|
|
8159
8159
|
const [uploadingRects, setUploadingRects] = (0, import_react9.useState)({});
|
|
8160
|
+
const pendingUploadRectRef = (0, import_react9.useRef)(null);
|
|
8160
8161
|
const hoveredGapRef = (0, import_react9.useRef)(null);
|
|
8161
8162
|
const imageUnhoverTimerRef = (0, import_react9.useRef)(null);
|
|
8162
8163
|
const imageShowTimerRef = (0, import_react9.useRef)(null);
|
|
@@ -9208,7 +9209,15 @@ function OhhwellsBridge() {
|
|
|
9208
9209
|
if (isMediaEditable(editable)) {
|
|
9209
9210
|
e.preventDefault();
|
|
9210
9211
|
e.stopPropagation();
|
|
9211
|
-
|
|
9212
|
+
const key = editable.dataset.ohwKey ?? "";
|
|
9213
|
+
const r2 = editable.getBoundingClientRect();
|
|
9214
|
+
if (key && r2.width > 1 && r2.height > 1) {
|
|
9215
|
+
pendingUploadRectRef.current = {
|
|
9216
|
+
key,
|
|
9217
|
+
rect: { top: r2.top, left: r2.left, width: r2.width, height: r2.height }
|
|
9218
|
+
};
|
|
9219
|
+
}
|
|
9220
|
+
postToParentRef.current({ type: "ow:image-pick", key, elementType: editable.dataset.ohwEditable ?? "image" });
|
|
9212
9221
|
return;
|
|
9213
9222
|
}
|
|
9214
9223
|
const hrefCtx = getHrefKeyFromElement(editable);
|
|
@@ -9878,6 +9887,7 @@ function OhhwellsBridge() {
|
|
|
9878
9887
|
if (!entry || entry.fadingOut) return prev;
|
|
9879
9888
|
return { ...prev, [key]: { ...entry, fadingOut: true } };
|
|
9880
9889
|
});
|
|
9890
|
+
if (pendingUploadRectRef.current?.key === key) pendingUploadRectRef.current = null;
|
|
9881
9891
|
};
|
|
9882
9892
|
let found = false;
|
|
9883
9893
|
document.querySelectorAll(`[data-ohw-key="${key}"]`).forEach((el) => {
|
|
@@ -10243,23 +10253,43 @@ function OhhwellsBridge() {
|
|
|
10243
10253
|
activeStateElRef.current = null;
|
|
10244
10254
|
setToggleState(null);
|
|
10245
10255
|
};
|
|
10256
|
+
const resolveUploadRects = (key) => {
|
|
10257
|
+
const matches = Array.from(document.querySelectorAll(`[data-ohw-key="${key}"]`));
|
|
10258
|
+
const rects = matches.map((el) => {
|
|
10259
|
+
const r2 = el.getBoundingClientRect();
|
|
10260
|
+
return { top: r2.top, left: r2.left, width: r2.width, height: r2.height };
|
|
10261
|
+
}).filter((r2) => r2.width > 1 && r2.height > 1);
|
|
10262
|
+
if (rects.length > 0) return rects;
|
|
10263
|
+
const pending = pendingUploadRectRef.current;
|
|
10264
|
+
if (pending?.key === key && pending.rect.width > 1 && pending.rect.height > 1) {
|
|
10265
|
+
return [pending.rect];
|
|
10266
|
+
}
|
|
10267
|
+
const hovered = hoveredImageRef.current;
|
|
10268
|
+
if (hovered?.dataset.ohwKey === key) {
|
|
10269
|
+
const r2 = hovered.getBoundingClientRect();
|
|
10270
|
+
if (r2.width > 1 && r2.height > 1) {
|
|
10271
|
+
return [{ top: r2.top, left: r2.left, width: r2.width, height: r2.height }];
|
|
10272
|
+
}
|
|
10273
|
+
}
|
|
10274
|
+
return [];
|
|
10275
|
+
};
|
|
10246
10276
|
const handleImageUploading = (e) => {
|
|
10247
|
-
|
|
10248
|
-
|
|
10277
|
+
const type = e.data?.type;
|
|
10278
|
+
if (type !== "ow:image-uploading" && type !== "ow:anim-lock") return;
|
|
10279
|
+
const key = e.data.key;
|
|
10280
|
+
if (!key) return;
|
|
10281
|
+
const uploading = type === "ow:anim-lock" ? true : !!e.data.uploading;
|
|
10249
10282
|
setUploadingRects((prev) => {
|
|
10250
10283
|
if (!uploading) {
|
|
10284
|
+
if (pendingUploadRectRef.current?.key === key) pendingUploadRectRef.current = null;
|
|
10251
10285
|
if (!(key in prev)) return prev;
|
|
10252
10286
|
const next = { ...prev };
|
|
10253
10287
|
delete next[key];
|
|
10254
10288
|
return next;
|
|
10255
10289
|
}
|
|
10256
|
-
const
|
|
10257
|
-
if (
|
|
10258
|
-
|
|
10259
|
-
return {
|
|
10260
|
-
...prev,
|
|
10261
|
-
[key]: { rect: { top: r2.top, left: r2.left, width: r2.width, height: r2.height } }
|
|
10262
|
-
};
|
|
10290
|
+
const rects = resolveUploadRects(key);
|
|
10291
|
+
if (rects.length === 0) return prev;
|
|
10292
|
+
return { ...prev, [key]: { rects } };
|
|
10263
10293
|
});
|
|
10264
10294
|
document.querySelectorAll(`[data-ohw-key="${key}"]`).forEach((el) => {
|
|
10265
10295
|
const track = el.closest("[data-ohw-hover-pause]");
|
|
@@ -10805,9 +10835,12 @@ function OhhwellsBridge() {
|
|
|
10805
10835
|
);
|
|
10806
10836
|
const handleMediaReplace = (0, import_react9.useCallback)(
|
|
10807
10837
|
(key) => {
|
|
10838
|
+
if (mediaHover?.key === key) {
|
|
10839
|
+
pendingUploadRectRef.current = { key, rect: mediaHover.rect };
|
|
10840
|
+
}
|
|
10808
10841
|
postToParent2({ type: "ow:image-pick", key, elementType: mediaHover?.elementType ?? "image" });
|
|
10809
10842
|
},
|
|
10810
|
-
[postToParent2, mediaHover
|
|
10843
|
+
[postToParent2, mediaHover]
|
|
10811
10844
|
);
|
|
10812
10845
|
const handleEditCarousel = (0, import_react9.useCallback)(
|
|
10813
10846
|
(key) => {
|
|
@@ -10851,17 +10884,19 @@ function OhhwellsBridge() {
|
|
|
10851
10884
|
return bridgeRoot ? (0, import_react_dom3.createPortal)(
|
|
10852
10885
|
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_jsx_runtime25.Fragment, { children: [
|
|
10853
10886
|
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { ref: attachVisibleViewport, "data-ohw-visible-viewport": "", "aria-hidden": true }),
|
|
10854
|
-
Object.entries(uploadingRects).
|
|
10855
|
-
|
|
10856
|
-
|
|
10857
|
-
|
|
10858
|
-
|
|
10859
|
-
|
|
10860
|
-
|
|
10861
|
-
|
|
10862
|
-
|
|
10863
|
-
|
|
10864
|
-
|
|
10887
|
+
Object.entries(uploadingRects).flatMap(
|
|
10888
|
+
([key, { rects, fadingOut }]) => rects.map((rect, i) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
10889
|
+
MediaOverlay,
|
|
10890
|
+
{
|
|
10891
|
+
hover: { key, rect, elementType: "image", isDragOver: false, hasTextOverlap: false },
|
|
10892
|
+
isUploading: true,
|
|
10893
|
+
fadingOut,
|
|
10894
|
+
onFadeOutComplete: handleMediaFadeOutComplete,
|
|
10895
|
+
onReplace: handleMediaReplace
|
|
10896
|
+
},
|
|
10897
|
+
`uploading-${key}-${i}`
|
|
10898
|
+
))
|
|
10899
|
+
),
|
|
10865
10900
|
mediaHover && !(mediaHover.key in uploadingRects) && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
10866
10901
|
MediaOverlay,
|
|
10867
10902
|
{
|