@ohhwells/bridge 0.1.113-next.299 → 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 +9 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +9 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -17876,6 +17876,7 @@ function OhhwellsBridge() {
|
|
|
17876
17876
|
}, []);
|
|
17877
17877
|
const [selectedMedia, setSelectedMedia] = (0, import_react17.useState)(null);
|
|
17878
17878
|
const selectedMediaElRef = (0, import_react17.useRef)(null);
|
|
17879
|
+
const mediaKeyDropTokenRef = (0, import_react17.useRef)(0);
|
|
17879
17880
|
const clearMediaSelection = (0, import_react17.useCallback)(() => {
|
|
17880
17881
|
const prev = selectedMediaElRef.current;
|
|
17881
17882
|
selectedMediaElRef.current = null;
|
|
@@ -17883,8 +17884,11 @@ function OhhwellsBridge() {
|
|
|
17883
17884
|
const sectionEl = prev?.closest("[data-ohw-section]") ?? null;
|
|
17884
17885
|
if (sectionEl) {
|
|
17885
17886
|
const sectionInstanceId = instanceIdOf(movableUnit(sectionEl)) || null;
|
|
17886
|
-
|
|
17887
|
-
|
|
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);
|
|
17888
17892
|
if (aiSectionApiRef.current?.getSelectedId() !== sectionInstanceId) return;
|
|
17889
17893
|
if (selectedMediaElRef.current) return;
|
|
17890
17894
|
postToParentRef.current({
|
|
@@ -17893,7 +17897,9 @@ function OhhwellsBridge() {
|
|
|
17893
17897
|
sectionLabel: sectionEl.dataset.ohwSectionLabel ?? titleCaseSectionId(sectionEl.dataset.ohwSection ?? ""),
|
|
17894
17898
|
key: null
|
|
17895
17899
|
});
|
|
17896
|
-
}
|
|
17900
|
+
};
|
|
17901
|
+
window.addEventListener("message", onQueueDrained);
|
|
17902
|
+
window.postMessage({ type: "ow:media-key-drop", token }, "*");
|
|
17897
17903
|
}
|
|
17898
17904
|
}, []);
|
|
17899
17905
|
const clearMediaSelectionRef = (0, import_react17.useRef)(clearMediaSelection);
|