@mujian/js-sdk 0.0.6-beta.13 → 0.0.6-beta.15
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/react.js +11 -13
- package/package.json +1 -1
package/dist/react.js
CHANGED
|
@@ -357,7 +357,7 @@ function useHeightObserver() {
|
|
|
357
357
|
const MdRendererBase = ({ content })=>{
|
|
358
358
|
const containerRef = useRef(null);
|
|
359
359
|
useRef([]);
|
|
360
|
-
const iframeIdList =
|
|
360
|
+
const [iframeIdList, setIframeIdList] = useState([]);
|
|
361
361
|
const { observe, unobserve } = useHeightObserver();
|
|
362
362
|
useEffect(()=>{
|
|
363
363
|
let mes = messageFormatting(content);
|
|
@@ -365,7 +365,10 @@ const MdRendererBase = ({ content })=>{
|
|
|
365
365
|
const code = match.replace("<code>", "").replace("</code>", "");
|
|
366
366
|
const srcdoc = createSrcContent(unescapeHTML(code));
|
|
367
367
|
const id = v4();
|
|
368
|
-
|
|
368
|
+
setIframeIdList([
|
|
369
|
+
...iframeIdList,
|
|
370
|
+
id
|
|
371
|
+
]);
|
|
369
372
|
const escapedSrcdoc = escapeHtmlAttribute(srcdoc);
|
|
370
373
|
return `
|
|
371
374
|
<div class="MJ-iframe-container" id="MJ-iframe-container-${id}" style="display:flex;width:100%;height:100%;position:relative;">
|
|
@@ -381,15 +384,8 @@ const MdRendererBase = ({ content })=>{
|
|
|
381
384
|
content
|
|
382
385
|
]);
|
|
383
386
|
useEffect(()=>{
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
console.log("event", event);
|
|
387
|
-
if (event.data?.type === "MJ_UPDATE_VIEWPORT_HEIGHT") document.documentElement.style.setProperty("--MJ-iframe-height", `${window.parent.innerHeight}px`);
|
|
388
|
-
});
|
|
389
|
-
}, []);
|
|
390
|
-
useEffect(()=>{
|
|
391
|
-
console.log("iframeIdList", iframeIdList.current);
|
|
392
|
-
iframeIdList.current.forEach((id)=>{
|
|
387
|
+
console.log("iframeIdList", iframeIdList);
|
|
388
|
+
iframeIdList.forEach((id)=>{
|
|
393
389
|
const iframe = document.getElementById("MJ-iframe-" + id);
|
|
394
390
|
if (!iframe) return;
|
|
395
391
|
iframe.addEventListener("load", ()=>{
|
|
@@ -399,7 +395,7 @@ const MdRendererBase = ({ content })=>{
|
|
|
399
395
|
});
|
|
400
396
|
});
|
|
401
397
|
return ()=>{
|
|
402
|
-
iframeIdList.
|
|
398
|
+
iframeIdList.forEach((id)=>{
|
|
403
399
|
const iframe = document.getElementById("MJ-iframe-" + id);
|
|
404
400
|
if (!iframe) return;
|
|
405
401
|
unobserve(iframe);
|
|
@@ -411,7 +407,9 @@ const MdRendererBase = ({ content })=>{
|
|
|
411
407
|
});
|
|
412
408
|
};
|
|
413
409
|
}, [
|
|
414
|
-
iframeIdList
|
|
410
|
+
iframeIdList,
|
|
411
|
+
observe,
|
|
412
|
+
unobserve
|
|
415
413
|
]);
|
|
416
414
|
return /*#__PURE__*/ jsx("div", {
|
|
417
415
|
className: "mes_text",
|