@ohhwells/bridge 0.1.113-next.297 → 0.1.113-next.300
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 +24 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +24 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -9552,6 +9552,7 @@ function AiSectionOverlay({
|
|
|
9552
9552
|
const sectionEl = inner ? movableUnit(inner) : null;
|
|
9553
9553
|
const id = sectionEl ? instanceIdOf(sectionEl) || null : null;
|
|
9554
9554
|
if (id === selectedIdRef.current) return;
|
|
9555
|
+
selectedIdRef.current = id;
|
|
9555
9556
|
setSelectedId(id);
|
|
9556
9557
|
if (options?.report !== false) report(sectionEl);
|
|
9557
9558
|
},
|
|
@@ -9572,9 +9573,11 @@ function AiSectionOverlay({
|
|
|
9572
9573
|
return sectionEl != null;
|
|
9573
9574
|
},
|
|
9574
9575
|
clear: () => {
|
|
9576
|
+
selectedIdRef.current = null;
|
|
9575
9577
|
setSelectedId(null);
|
|
9576
9578
|
report(null);
|
|
9577
|
-
}
|
|
9579
|
+
},
|
|
9580
|
+
getSelectedId: () => selectedIdRef.current
|
|
9578
9581
|
};
|
|
9579
9582
|
return () => {
|
|
9580
9583
|
apiRef.current = null;
|
|
@@ -9583,6 +9586,7 @@ function AiSectionOverlay({
|
|
|
9583
9586
|
(0, import_react8.useEffect)(() => {
|
|
9584
9587
|
const onMessage = (e) => {
|
|
9585
9588
|
if (e.data?.type === "ow:ai-select" && e.data.sectionId === null) {
|
|
9589
|
+
selectedIdRef.current = null;
|
|
9586
9590
|
setSelectedId(null);
|
|
9587
9591
|
return;
|
|
9588
9592
|
}
|
|
@@ -9633,6 +9637,7 @@ function AiSectionOverlay({
|
|
|
9633
9637
|
if (reviewIdRef.current) return;
|
|
9634
9638
|
if (document.querySelector("[data-ohw-editing]")) return;
|
|
9635
9639
|
if (selectedIdRef.current) {
|
|
9640
|
+
selectedIdRef.current = null;
|
|
9636
9641
|
setSelectedId(null);
|
|
9637
9642
|
report(null);
|
|
9638
9643
|
}
|
|
@@ -17871,18 +17876,30 @@ function OhhwellsBridge() {
|
|
|
17871
17876
|
}, []);
|
|
17872
17877
|
const [selectedMedia, setSelectedMedia] = (0, import_react17.useState)(null);
|
|
17873
17878
|
const selectedMediaElRef = (0, import_react17.useRef)(null);
|
|
17879
|
+
const mediaKeyDropTokenRef = (0, import_react17.useRef)(0);
|
|
17874
17880
|
const clearMediaSelection = (0, import_react17.useCallback)(() => {
|
|
17875
17881
|
const prev = selectedMediaElRef.current;
|
|
17876
17882
|
selectedMediaElRef.current = null;
|
|
17877
17883
|
setSelectedMedia(null);
|
|
17878
17884
|
const sectionEl = prev?.closest("[data-ohw-section]") ?? null;
|
|
17879
17885
|
if (sectionEl) {
|
|
17880
|
-
|
|
17881
|
-
|
|
17882
|
-
|
|
17883
|
-
|
|
17884
|
-
key
|
|
17885
|
-
|
|
17886
|
+
const sectionInstanceId = instanceIdOf(movableUnit(sectionEl)) || null;
|
|
17887
|
+
if (!sectionInstanceId) return;
|
|
17888
|
+
const token = ++mediaKeyDropTokenRef.current;
|
|
17889
|
+
const onQueueDrained = (e) => {
|
|
17890
|
+
if (e.source !== window || e.data?.type !== "ow:media-key-drop" || e.data.token !== token) return;
|
|
17891
|
+
window.removeEventListener("message", onQueueDrained);
|
|
17892
|
+
if (aiSectionApiRef.current?.getSelectedId() !== sectionInstanceId) return;
|
|
17893
|
+
if (selectedMediaElRef.current) return;
|
|
17894
|
+
postToParentRef.current({
|
|
17895
|
+
type: "ow:section-selected",
|
|
17896
|
+
sectionId: sectionEl.dataset.ohwSection ?? null,
|
|
17897
|
+
sectionLabel: sectionEl.dataset.ohwSectionLabel ?? titleCaseSectionId(sectionEl.dataset.ohwSection ?? ""),
|
|
17898
|
+
key: null
|
|
17899
|
+
});
|
|
17900
|
+
};
|
|
17901
|
+
window.addEventListener("message", onQueueDrained);
|
|
17902
|
+
window.postMessage({ type: "ow:media-key-drop", token }, "*");
|
|
17886
17903
|
}
|
|
17887
17904
|
}, []);
|
|
17888
17905
|
const clearMediaSelectionRef = (0, import_react17.useRef)(clearMediaSelection);
|