markdown-flow-ui 0.2.33 → 0.2.34

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/README.md CHANGED
@@ -66,6 +66,15 @@ Detection and presentation are separate: `pre`, `details`, `summary`,
66
66
  styles and language/direction attributes while bypassing typing. Widget roots
67
67
  retain the sandbox; native presentation blocks with embedded script, style, or
68
68
  other document resources also use the sandbox (native video frames are exempt).
69
+ In content mode, sandbox blocks reserve their measured content height instead
70
+ of a minimum 16:9 slide. The iframe retains a separate layout viewport of at
71
+ least 16:9 so authored `vh` and `vmin` sizes stay stable; unused viewport space
72
+ is clipped by the top-aligned content container. Content growth, collapse,
73
+ image loads and width changes trigger remeasurement. When shown, the fullscreen
74
+ control reserves its actual height so it remains accessible on very short blocks.
75
+ Authored margins, explicit heights and viewport-filling layouts are preserved
76
+ rather than trimmed.
77
+ Blackboard sizing and sandbox permissions are unchanged.
69
78
  Detection scans absolute source offsets without reparsing every remaining
70
79
  suffix. Native videos use the complete received Markdown structure; typing only
71
80
  changes text visibility, preserving video frames across earlier headings, lists,
@@ -1,5 +1,6 @@
1
- var r = {};
1
+ import { __require as r } from "../node_modules/rc-util/node_modules/react-is/index.es.js";
2
+ var a = r();
2
3
  export {
3
- r as __exports
4
+ a as r
4
5
  };
5
6
  //# sourceMappingURL=index.es10.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.es10.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
1
+ {"version":3,"file":"index.es10.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
@@ -1,6 +1,5 @@
1
- import { __require as r } from "../node_modules/rc-util/node_modules/react-is/index.es.js";
2
- var a = r();
1
+ var r = {};
3
2
  export {
4
- a as r
3
+ r as __exports
5
4
  };
6
5
  //# sourceMappingURL=index.es11.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.es11.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
1
+ {"version":3,"file":"index.es11.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -1,8 +1,5 @@
1
- import { getDefaultExportFromCjs as r } from "./_commonjsHelpers.es.js";
2
- import { __require as o } from "../node_modules/style-to-js/cjs/index.es.js";
3
- var t = o();
4
- const a = /* @__PURE__ */ r(t);
1
+ var s = { exports: {} };
5
2
  export {
6
- a as default
3
+ s as __module
7
4
  };
8
5
  //# sourceMappingURL=index.es7.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.es7.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
1
+ {"version":3,"file":"index.es7.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -1,5 +1,8 @@
1
- var s = { exports: {} };
1
+ import { getDefaultExportFromCjs as r } from "./_commonjsHelpers.es.js";
2
+ import { __require as o } from "../node_modules/style-to-js/cjs/index.es.js";
3
+ var t = o();
4
+ const a = /* @__PURE__ */ r(t);
2
5
  export {
3
- s as __module
6
+ a as default
4
7
  };
5
8
  //# sourceMappingURL=index.es8.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.es8.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
1
+ {"version":3,"file":"index.es8.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var e={};exports.__exports=e;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../node_modules/rc-util/node_modules/react-is/index.cjs");var r=e.__require();exports.reactIsExports=r;
2
2
  //# sourceMappingURL=index10.cjs.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../node_modules/rc-util/node_modules/react-is/index.cjs");var r=e.__require();exports.reactIsExports=r;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var e={};exports.__exports=e;
2
2
  //# sourceMappingURL=index11.cjs.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./_commonjsHelpers.cjs"),r=require("../node_modules/style-to-js/cjs/index.cjs");var t=r.__require();const o=e.getDefaultExportFromCjs(t);exports.default=o;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var e={exports:{}};exports.__module=e;
2
2
  //# sourceMappingURL=index7.cjs.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var e={exports:{}};exports.__module=e;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./_commonjsHelpers.cjs"),r=require("../node_modules/style-to-js/cjs/index.cjs");var t=r.__require();const o=e.getDefaultExportFromCjs(t);exports.default=o;
2
2
  //# sourceMappingURL=index8.cjs.map
@@ -1,13 +1,13 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const _=require("react/jsx-runtime"),t=require("react"),Ht=require("react-dom/client"),xt=require("./SandboxApp.cjs"),Rt=require("./ContentRender.cjs"),A=require("./utils/iframe-viewport-height.cjs"),Ye=require("../../lib/sandboxInteraction.cjs"),pt=require("./utils/iframe-scaling.cjs"),Ue=require("../../lib/locale.cjs"),St=require("../../lib/useDetachedLanguage.cjs"),Xe=require("../../lib/useResolvedDirection.cjs"),vt=require("./contentRenderI18n.cjs"),Et=require("./cjkFontFamily.cjs");let Se=null;const Ke=()=>(Se||(Se=Promise.resolve().then(()=>require("./blackboard-vendor.cjs"))),Se),Ct=/<img\b[^>]*>/i,yt=180,Mt=240,Tt=i=>i.split(/\s+/).filter(Boolean).map(o=>{const l=o.split(":");return l[l.length-1]!=="h-screen"&&l[l.length-1]!=="min-h-screen"?o:(l[l.length-1]="h-full",l.join(":"))}).join(" "),kt=(i,o)=>!o||!i.trim()?i:i.replace(/^(\s*<[a-zA-Z][\w:-]*)(\s[^>]*?)?>/,(l,h,P="")=>{const w=P.match(/\bclass\s*=\s*(["'])([^"']*)\1/i);if(!w)return l;const I=Tt(w[2]);return I===w[2]?l:`${h}${P.replace(w[0],`class=${w[1]}${I}${w[1]}`)}>`}),Ft=({content:i,type:o,className:l,locale:h,lang:P,dir:w,loadingText:I,styleLoadingText:ve,scriptLoadingText:Ee,fullScreenButtonText:Je,exitFullScreenButtonText:Qe,hideFullScreen:Ze=!1,mode:u="content",replaceRootScreenHeightWithFull:et=!1,enableScaling:tt=!1,disableLoadingOverlay:ee=!1})=>{const Ce=vt.getContentRenderLocaleTexts(h),H=w??Ue.getMarkdownFlowDirection(h),te=P??Ue.getMarkdownFlowLanguage(h),nt=Je||Ce.sandboxFullscreenButtonText,rt=Qe||Ce.sandboxExitFullscreenButtonText,C=t.useRef(null),ye=St.useDetachedLanguage(C,te),{resolvedDirection:ne}=Xe.useResolvedDirection(C,H),Me=t.useRef(null),Te=t.useRef(null),ot=t.useCallback(n=>{Me.current=n,Te.current=n?.querySelector(".content-render")??null},[]),{resolvedDirection:it}=Xe.useResolvedDirection(Te,H),ke=H??ne,Fe=t.useRef(H);Fe.current=H;const[st,ct]=t.useState();let z;H==="auto"&&(z=ne,o==="sandbox"?z=st??ne:u==="blackboard"&&(z=it));const x=t.useRef(null),L=t.useRef(null),q=t.useRef(()=>{}),[lt,ut]=t.useState(480),[Ae,at]=t.useState(0),[re,oe]=t.useState(0),ie=t.useRef(!1),se=t.useRef(!1),_e=t.useRef(0),[De,dt]=t.useState(0),[ce,ht]=t.useState(!1),le=o==="sandbox",R=u==="blackboard",p=tt&&R&&o==="sandbox",O=R&&o==="sandbox",D=O&&et,ue=t.useRef(""),$=t.useMemo(()=>o==="sandbox"?i:"",[i,o]),s=t.useMemo(()=>kt($,D),[$,D]),Ie=t.useMemo(()=>D?A.inspectViewportHeightFromHtmlRootString($):A.EMPTY_ROOT_HEIGHT_META,[$,D]),ae=t.useMemo(()=>D&&Ie.hasFullViewportHeight,[Ie.hasFullViewportHeight,D]),[G,qe]=t.useState(s),Oe=t.useRef(s),de=t.useRef(s),V=t.useRef(null),S=t.useRef(null),Ve=t.useRef(null),he=t.useCallback(n=>{if(typeof window>"u")return;const e=Date.now();e-_e.current<Mt||(_e.current=e,window.postMessage({source:Ye.SANDBOX_INTERACTION_MESSAGE_SOURCE,type:Ye.SANDBOX_INTERACTION_MESSAGE_TYPE,eventType:n},window.location.origin))},[]);t.useEffect(()=>{if(o!=="markdown"||u!=="blackboard")return;const n=Me.current;if(!n)return;const e=()=>he("click");return n.addEventListener("click",e),()=>n.removeEventListener("click",e)},[he,u,o]);const fe=()=>{V.current!==null&&(window.clearTimeout(V.current),V.current=null)},ft=()=>{S.current!==null&&(window.cancelAnimationFrame(S.current),S.current=null)};t.useEffect(()=>()=>{fe(),ft()},[]),t.useEffect(()=>{const n=Oe.current;Oe.current=s;const e=!!n&&s.length>n.length&&s.startsWith(n),f=Ct.test(s);if(!(e&&f)){fe(),de.current=s,qe(s);return}de.current=s,fe(),V.current=window.setTimeout(()=>{qe(de.current),V.current=null},yt)},[s]);const Y=t.useMemo(()=>O?A.inspectViewportHeightFromHtmlRootString(G).viewportHeightCss:null,[G,O]);t.useEffect(()=>{Ve.current=Y},[Y]);const me=!!Y,N=R&&o==="sandbox"?p||ae?"100%":Y??`${lt}px`:void 0;t.useEffect(()=>{if(u!=="blackboard"){ue.current=s;return}const n=ue.current;!(n&&s.startsWith(n))&&n&&dt(f=>f+1),ue.current=s},[u,s]),t.useEffect(()=>{const n=x.current;if(!n)return;const e=n.contentDocument;if(!e)return;e.open(),e.write(`<!DOCTYPE html>
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const I=require("react/jsx-runtime"),t=require("react"),vt=require("react-dom/client"),Ct=require("./SandboxApp.cjs"),Et=require("./ContentRender.cjs"),D=require("./utils/iframe-viewport-height.cjs"),Je=require("../../lib/sandboxInteraction.cjs"),Mt=require("./utils/iframe-scaling.cjs"),Qe=require("../../lib/locale.cjs"),yt=require("../../lib/useDetachedLanguage.cjs"),Ze=require("../../lib/useResolvedDirection.cjs"),Tt=require("./contentRenderI18n.cjs"),kt=require("./cjkFontFamily.cjs");let Ce=null;const et=()=>(Ce||(Ce=Promise.resolve().then(()=>require("./blackboard-vendor.cjs"))),Ce),Ft=/<img\b[^>]*>/i,At=180,_t=240,Dt=i=>i.split(/\s+/).filter(Boolean).map(o=>{const l=o.split(":");return l[l.length-1]!=="h-screen"&&l[l.length-1]!=="min-h-screen"?o:(l[l.length-1]="h-full",l.join(":"))}).join(" "),It=(i,o)=>!o||!i.trim()?i:i.replace(/^(\s*<[a-zA-Z][\w:-]*)(\s[^>]*?)?>/,(l,f,L="")=>{const R=L.match(/\bclass\s*=\s*(["'])([^"']*)\1/i);if(!R)return l;const V=Dt(R[2]);return V===R[2]?l:`${f}${L.replace(R[0],`class=${R[1]}${V}${R[1]}`)}>`}),qt=({content:i,type:o,className:l,locale:f,lang:L,dir:R,loadingText:V,styleLoadingText:Ee,scriptLoadingText:Me,fullScreenButtonText:tt,exitFullScreenButtonText:nt,hideFullScreen:ye=!1,mode:u="content",replaceRootScreenHeightWithFull:rt=!1,enableScaling:ot=!1,disableLoadingOverlay:ne=!1})=>{const Te=Tt.getContentRenderLocaleTexts(f),x=R??Qe.getMarkdownFlowDirection(f),re=L??Qe.getMarkdownFlowLanguage(f),it=tt||Te.sandboxFullscreenButtonText,st=nt||Te.sandboxExitFullscreenButtonText,T=t.useRef(null),ke=t.useRef(null),Fe=yt.useDetachedLanguage(T,re),{resolvedDirection:oe}=Ze.useResolvedDirection(T,x),Ae=t.useRef(null),_e=t.useRef(null),ct=t.useCallback(n=>{Ae.current=n,_e.current=n?.querySelector(".content-render")??null},[]),{resolvedDirection:lt}=Ze.useResolvedDirection(_e,x),De=x??oe,Ie=t.useRef(x);Ie.current=x;const[ut,at]=t.useState();let $;x==="auto"&&($=oe,o==="sandbox"?$=ut??oe:u==="blackboard"&&($=lt));const p=t.useRef(null),G=t.useRef(null),N=t.useRef(()=>{}),[dt,ht]=t.useState(480),[ie,ft]=t.useState(null),[Y,se]=t.useState(0),[qe,mt]=t.useState(0),ce=t.useRef(!1),le=t.useRef(!1),Oe=t.useRef(0),[Ve,gt]=t.useState(0),[ue,bt]=t.useState(!1),ae=o==="sandbox",S=u==="blackboard",v=ot&&S&&o==="sandbox",B=S&&o==="sandbox",q=B&&rt,de=t.useRef(""),U=t.useMemo(()=>o==="sandbox"?i:"",[i,o]),s=t.useMemo(()=>It(U,q),[U,q]),Ne=t.useMemo(()=>q?D.inspectViewportHeightFromHtmlRootString(U):D.EMPTY_ROOT_HEIGHT_META,[U,q]),he=t.useMemo(()=>q&&Ne.hasFullViewportHeight,[Ne.hasFullViewportHeight,q]),[X,Be]=t.useState(s),We=t.useRef(s),fe=t.useRef(s),W=t.useRef(null),C=t.useRef(null),je=t.useRef(null),me=t.useCallback(n=>{if(typeof window>"u")return;const e=Date.now();e-Oe.current<_t||(Oe.current=e,window.postMessage({source:Je.SANDBOX_INTERACTION_MESSAGE_SOURCE,type:Je.SANDBOX_INTERACTION_MESSAGE_TYPE,eventType:n},window.location.origin))},[]);t.useEffect(()=>{if(o!=="markdown"||u!=="blackboard")return;const n=Ae.current;if(!n)return;const e=()=>me("click");return n.addEventListener("click",e),()=>n.removeEventListener("click",e)},[me,u,o]);const ge=()=>{W.current!==null&&(window.clearTimeout(W.current),W.current=null)},wt=()=>{C.current!==null&&(window.cancelAnimationFrame(C.current),C.current=null)};t.useEffect(()=>()=>{ge(),wt()},[]),t.useEffect(()=>{const n=We.current;We.current=s;const e=!!n&&s.length>n.length&&s.startsWith(n),a=Ft.test(s);if(!(e&&a)){ge(),fe.current=s,Be(s);return}fe.current=s,ge(),W.current=window.setTimeout(()=>{Be(fe.current),W.current=null},At)},[s]);const K=t.useMemo(()=>B?D.inspectViewportHeightFromHtmlRootString(X).viewportHeightCss:null,[X,B]);t.useEffect(()=>{je.current=K},[K]);const be=!!K,j=S&&o==="sandbox"?v||he?"100%":K??`${dt}px`:void 0;t.useEffect(()=>{if(u!=="blackboard"){de.current=s;return}const n=de.current;!(n&&s.startsWith(n))&&n&&gt(a=>a+1),de.current=s},[u,s]),t.useEffect(()=>{const n=p.current;if(!n)return;const e=n.contentDocument;if(!e)return;e.open(),e.write(`<!DOCTYPE html>
2
2
  <html${u==="blackboard"?' style="height: 100%;"':""}>
3
3
  <head>
4
4
  <meta charset="utf-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <style>
7
7
  :root { color-scheme: light; }
8
- html, body, #root { width: 100%; font-family: ${Et.CJK_SAFE_SANS_FONT_FAMILY}; }
8
+ html, body, #root { width: 100%; font-family: ${kt.CJK_SAFE_SANS_FONT_FAMILY}; }
9
9
  ${u==="blackboard"?"html, body, #root { height: 100%; }":""}
10
- html, body { margin: 0; padding: 0; overflow: ${p?"hidden auto":u==="blackboard"?"auto":"hidden"}; }
10
+ html, body { margin: 0; padding: 0; overflow: ${v?"hidden auto":u==="blackboard"?"auto":"hidden"}; }
11
11
  *, *::before, *::after { box-sizing: border-box; }
12
12
  ${u!=="blackboard"?`
13
13
  .h-screen { height: auto !important; }
@@ -20,5 +20,5 @@
20
20
  <body>
21
21
  <div id="root"></div>
22
22
  </body>
23
- </html>`),e.close(),e.documentElement.setAttribute("data-theme","light"),e.documentElement.style.colorScheme="light",e.body?.style.setProperty("color-scheme","light");const f=R&&o==="sandbox",U=()=>he("click");f&&e.addEventListener("click",U,!0);const W=e.getElementById("root");if(!W)return;const ge=Ht.createRoot(W);L.current=ge;let v=!1;const We=r=>({heightAttrValue:r.getAttribute("height"),styleAttrValue:r.getAttribute("style"),classAttrValue:r.getAttribute("class")}),Be=r=>{const c=Array.from(r.children);return c.length===1?c[0]:null},bt=()=>{if(!O||!x.current||!e.body)return null;const r=x.current.ownerDocument?.documentElement?.clientHeight||window.innerHeight,c=Ve.current,g=c?A.parseExplicitHeight(c,r):null;if(g!==null)return Math.ceil(g);const m=e.body.querySelector(".sandbox-wrapper")?.firstElementChild;if(!m)return null;const b=Array.from(m.children),T=b.length===1?b[0]:null,Q=A.inspectViewportHeightFromNodeChain(T,{getNode:We,getSingleChild:Be}).viewportHeightCss;if(Q){const B=A.parseExplicitHeight(Q,r);if(B!==null)return Math.ceil(B)}const d=A.resolveExplicitHeightFromNodeChain(T,r,{getNode:We,getSingleChild:Be});return d!==null?Math.ceil(d):null},be=()=>{if(!x.current||!e.body)return;if(!R){if(ie.current){se.current=!0;return}ie.current=!0;const m=x.current,b=C.current?.clientWidth||0,T=m.style.height;if(b>0){const pe=Math.round(b*9/16),Q=Math.max(8192,b*20);m.style.height=pe+"px",e.body.offsetHeight;let d=e.body.scrollHeight;const B=e.defaultView;if(B){const j=E=>{let k=0;const $e=F=>{if(F!==E&&F.scrollHeight>F.clientHeight+1){const Z=B.getComputedStyle(F).overflowY;if(Z==="auto"||Z==="scroll"){const Ge=F.getBoundingClientRect();Ge.top>=0&&(k=Math.max(k,Math.ceil(Ge.top+F.scrollHeight)))}}for(const Z of F.children)$e(Z)};return $e(E),k};d=Math.max(d,j(e.body));for(let E=0;E<8&&d>pe;E++){m.style.height=d+"px",e.body.offsetHeight;const k=Math.max(e.body.scrollHeight,j(e.body));if(k<=d+1||k>=d*1.5)break;d=k}}m.style.height=T,at(j=>{const E=Math.min(Q,Math.max(200,Math.ceil(d)));return j===E?j:E})}setTimeout(()=>{ie.current=!1,se.current&&(se.current=!1,y())},50);return}if(p)return;const r=e.body.scrollHeight,c=e.documentElement?.scrollHeight||0,g=W?.scrollHeight||0,M=Math.max(r,c,g);if(O){const m=bt(),b=Math.max(200,m??Math.ceil(M));ut(T=>T===b?T:b)}},y=()=>{requestAnimationFrame(()=>{v||be()})};q.current=y,be(),y(),le&&Ke().then(({injectBlackboardLibraries:r})=>{v||(r(e),p&&pt.injectScalingSystem(e),requestAnimationFrame(()=>{v||y()}))}).catch(()=>{v||y()});const a=C.current;let we=!!(a&&(a.clientWidth<=0||a.clientHeight<=0)),X=!1,K=null,J=null;const je=()=>{if(v)return;y(),n.contentWindow?.__mdf_triggerFitContent?.()},He=()=>!!(a&&a.clientWidth>0&&a.clientHeight>0),Pe=()=>{!le||!a||!we||X||!He()||(X=!0,Ke().then(({refreshTailwindRuntime:r})=>{v||(K=window.requestAnimationFrame(()=>{K=null,X=!1;const c=e.querySelector(".sandbox-container");v||!He()||!c?.childNodes.length||!r(e)||(we=!1,je(),J=window.setTimeout(()=>{J=null,je()},100))}))}).catch(()=>{X=!1}))},ze=typeof ResizeObserver<"u",xe=le&&a&&ze?new ResizeObserver(r=>{const c=r[0]?.contentRect,g=c?.width??a.clientWidth,M=c?.height??a.clientHeight;g>0&&M>0&&Pe()}):null;xe&&a&&xe.observe(a);const Re=ze?new ResizeObserver(()=>be()):null;Re?.observe(e.body),W&&Re?.observe(W);const wt=()=>{if(o!=="sandbox"||Fe.current!=="auto")return;const r=e.querySelector(".sandbox-wrapper"),c=e.defaultView;if(!r||!c)return;const g=c.getComputedStyle(r).direction==="rtl"?"rtl":"ltr";ct(M=>M===g?M:g)},Le=new MutationObserver(()=>{if(wt(),y(),!He()){we=!0;return}Pe()});return Le.observe(e.body,{childList:!0,characterData:!0,subtree:!0,attributes:!0,attributeFilter:["style","class","dir"]}),()=>{v=!0,xe?.disconnect(),Re?.disconnect(),Le.disconnect(),K!==null&&window.cancelAnimationFrame(K),J!==null&&window.clearTimeout(J),p&&n.contentWindow?.__mdf_cleanupScaling?.(),f&&e.removeEventListener("click",U,!0),L.current===ge&&(L.current=null,q.current=()=>{}),setTimeout(()=>{ge.unmount()},0)}},[]),t.useEffect(()=>{const n=()=>{ht(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",n),()=>document.removeEventListener("fullscreenchange",n)},[]),t.useEffect(()=>{const n=C.current;if(!n)return;if(typeof ResizeObserver>"u"){oe(n.clientWidth);return}const e=new ResizeObserver(f=>{oe(f[0]?.contentRect.width??n.clientWidth)});return e.observe(n),oe(n.clientWidth),()=>e.disconnect()},[]);const Ne=t.useMemo(()=>{if(R||re===0||ce)return;const n=Math.round(re*9/16);return{height:Math.max(n,Ae)}},[R,re,Ae,ce]),mt=()=>{const n=C.current||x.current;if(n){if(document.fullscreenElement){document.exitFullscreen().catch(()=>{});return}n.requestFullscreen&&n.requestFullscreen().catch(()=>{})}};t.useEffect(()=>{const n=L.current;if(!n)return;n.render(_.jsx(xt.default,{html:G,locale:h,dir:ke,lang:ye,loadingText:I,styleLoadingText:ve,scriptLoadingText:Ee,disableLoadingOverlay:ee,resetToken:De,hasRootVhHeight:me,mode:u,stretchRootHeight:ae,enableScaling:p})),S.current=window.requestAnimationFrame(()=>{q.current?.(),p&&x.current?.contentWindow?.__mdf_triggerFitContent?.(),S.current=null});const e=setTimeout(()=>q.current?.(),100),f=setTimeout(()=>q.current?.(),500);return()=>{S.current!==null&&(window.cancelAnimationFrame(S.current),S.current=null),clearTimeout(e),clearTimeout(f)}},[G,h,ke,ye,I,ve,Ee,De,ee,me,u,ae,p]);const gt=[`w-full relative content-render-iframe-sandbox content-render-iframe-sandbox--${o}`,R?"h-full overflow-auto flex flex-col":Ne?"overflow-hidden flex items-center justify-center":"aspect-[16/9] overflow-hidden flex items-center justify-center"].filter(Boolean).join(" ");return _.jsxs("div",{ref:C,dir:H,lang:te,"data-root-vh":me?"true":"false",className:gt,style:N?{height:N,minHeight:N}:Ne,children:[!Ze&&_.jsx("button",{type:"button",dir:z,onClick:mt,className:"absolute top-2 end-2 z-50 p-1.5 bg-black/75 text-white rounded-md cursor-pointer",children:ce?rt:nt}),u==="blackboard"&&o==="markdown"?_.jsx("div",{ref:ot,children:_.jsx(Rt.default,{content:i,locale:h,dir:H,lang:te,disableSandboxLoadingOverlay:ee})}):_.jsx("iframe",{ref:x,sandbox:"allow-scripts allow-same-origin allow-popups allow-popups-to-escape-sandbox",allow:"fullscreen",allowFullScreen:!0,className:[l,"w-full h-full mx-auto my-auto block"].filter(Boolean).join(" "),style:{height:N??"100%",minHeight:N,margin:"auto"}})]})},At=i=>{const o=i.mode??"content",l=!!(i.enableScaling&&o==="blackboard"&&i.type==="sandbox"),h=`${i.type}:${o}:${l?"scaled":"unscaled"}`;return _.jsx(Ft,{...i},h)};exports.default=At;
23
+ </html>`),e.close(),e.documentElement.setAttribute("data-theme","light"),e.documentElement.style.colorScheme="light",e.body?.style.setProperty("color-scheme","light");const a=S&&o==="sandbox",E=()=>me("click");a&&e.addEventListener("click",E,!0);const k=e.getElementById("root");if(!k)return;const O=vt.createRoot(k);G.current=O;let m=!1;const Pe=r=>({heightAttrValue:r.getAttribute("height"),styleAttrValue:r.getAttribute("style"),classAttrValue:r.getAttribute("class")}),ze=r=>{const c=Array.from(r.children);return c.length===1?c[0]:null},pt=()=>{if(!B||!p.current||!e.body)return null;const r=p.current.ownerDocument?.documentElement?.clientHeight||window.innerHeight,c=je.current,b=c?D.parseExplicitHeight(c,r):null;if(b!==null)return Math.ceil(b);const g=e.body.querySelector(".sandbox-wrapper")?.firstElementChild;if(!g)return null;const w=Array.from(g.children),_=w.length===1?w[0]:null,ee=D.inspectViewportHeightFromNodeChain(_,{getNode:Pe,getSingleChild:ze}).viewportHeightCss;if(ee){const P=D.parseExplicitHeight(ee,r);if(P!==null)return Math.ceil(P)}const h=D.resolveExplicitHeightFromNodeChain(_,r,{getNode:Pe,getSingleChild:ze});return h!==null?Math.ceil(h):null},He=()=>{if(!p.current||!e.body)return;if(!S){if(ce.current){le.current=!0;return}ce.current=!0;const g=p.current,w=T.current?.clientWidth||0,_=g.style.height;if(w>0){const ve=Math.round(w*9/16),ee=Math.max(8192,w*20);g.style.height=ve+"px",e.body.offsetHeight;let h=e.body.scrollHeight;const P=e.defaultView;if(P){const z=M=>{let H=0;const Ue=y=>{const Xe=P.getComputedStyle(y);if(Xe.position==="fixed"&&(H=Math.max(H,Math.ceil(y.getBoundingClientRect().bottom))),y!==M&&y.scrollHeight>y.clientHeight+1){const te=Xe.overflowY;if(te==="auto"||te==="scroll"){const Ke=y.getBoundingClientRect();Ke.top>=0&&(H=Math.max(H,Math.ceil(Ke.top+y.scrollHeight)))}}for(const te of y.children)Ue(te)};return Ue(M),H};h=Math.max(h,z(e.body));for(let M=0;M<8&&h>ve;M++){g.style.height=h+"px",e.body.offsetHeight;const H=Math.max(e.body.scrollHeight,z(e.body));if(H<=h+1||H>=h*1.5)break;h=H}}g.style.height=_,ft(z=>{const M=Math.min(ee,Math.max(1,Math.ceil(h)));return z===M?z:M})}setTimeout(()=>{ce.current=!1,le.current&&(le.current=!1,F())},50);return}if(v)return;const r=e.body.scrollHeight,c=e.documentElement?.scrollHeight||0,b=k?.scrollHeight||0,A=Math.max(r,c,b);if(B){const g=pt(),w=Math.max(200,g??Math.ceil(A));ht(_=>_===w?_:w)}},F=()=>{requestAnimationFrame(()=>{m||He()})};N.current=F,He(),F(),ae&&et().then(({injectBlackboardLibraries:r})=>{m||(r(e),v&&Mt.injectScalingSystem(e),requestAnimationFrame(()=>{m||F()}))}).catch(()=>{m||F()});const d=T.current;let Re=!!(d&&(d.clientWidth<=0||d.clientHeight<=0)),J=!1,Q=null,Z=null;const Le=()=>{if(m)return;F(),n.contentWindow?.__mdf_triggerFitContent?.()},xe=()=>!!(d&&d.clientWidth>0&&d.clientHeight>0),$e=()=>{!ae||!d||!Re||J||!xe()||(J=!0,et().then(({refreshTailwindRuntime:r})=>{m||(Q=window.requestAnimationFrame(()=>{Q=null,J=!1;const c=e.querySelector(".sandbox-container");m||!xe()||!c?.childNodes.length||!r(e)||(Re=!1,Le(),Z=window.setTimeout(()=>{Z=null,Le()},100))}))}).catch(()=>{J=!1}))},Ge=typeof ResizeObserver<"u",pe=ae&&d&&Ge?new ResizeObserver(r=>{const c=r[0]?.contentRect,b=c?.width??d.clientWidth,A=c?.height??d.clientHeight;b>0&&A>0&&$e()}):null;pe&&d&&pe.observe(d);const Se=Ge?new ResizeObserver(()=>He()):null;Se?.observe(e.body),k&&Se?.observe(k);const St=()=>{if(o!=="sandbox"||Ie.current!=="auto")return;const r=e.querySelector(".sandbox-wrapper"),c=e.defaultView;if(!r||!c)return;const b=c.getComputedStyle(r).direction==="rtl"?"rtl":"ltr";at(A=>A===b?A:b)},Ye=new MutationObserver(()=>{if(St(),F(),!xe()){Re=!0;return}$e()});return Ye.observe(e.body,{childList:!0,characterData:!0,subtree:!0,attributes:!0,attributeFilter:["style","class","dir"]}),()=>{m=!0,pe?.disconnect(),Se?.disconnect(),Ye.disconnect(),Q!==null&&window.cancelAnimationFrame(Q),Z!==null&&window.clearTimeout(Z),v&&n.contentWindow?.__mdf_cleanupScaling?.(),a&&e.removeEventListener("click",E,!0),G.current===O&&(G.current=null,N.current=()=>{}),setTimeout(()=>{O.unmount()},0)}},[]),t.useEffect(()=>{const n=()=>{bt(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",n),()=>document.removeEventListener("fullscreenchange",n)},[]),t.useEffect(()=>{const n=T.current;if(!n)return;const e=ke.current,a=()=>{mt(e?Math.ceil(e.offsetTop+e.offsetHeight):0)};if(typeof ResizeObserver>"u"){se(n.clientWidth),a();return}const E=new ResizeObserver(k=>{const O=k.find(m=>m.target===n);O&&se(O.contentRect.width),a()});return E.observe(n),e&&E.observe(e),se(n.clientWidth),a(),()=>E.disconnect()},[ye]);const we=t.useMemo(()=>{if(S||Y===0||ue)return;const n=Math.round(Y*9/16);return{height:Math.max(ie??n,qe)}},[S,Y,ie,ue,qe]),Ht=we?Math.max(Math.round(Y*9/16),ie??0):void 0,Rt=()=>{const n=T.current||p.current;if(n){if(document.fullscreenElement){document.exitFullscreen().catch(()=>{});return}n.requestFullscreen&&n.requestFullscreen().catch(()=>{})}};t.useEffect(()=>{const n=G.current;if(!n)return;n.render(I.jsx(Ct.default,{html:X,locale:f,dir:De,lang:Fe,loadingText:V,styleLoadingText:Ee,scriptLoadingText:Me,disableLoadingOverlay:ne,resetToken:Ve,hasRootVhHeight:be,mode:u,stretchRootHeight:he,enableScaling:v})),C.current=window.requestAnimationFrame(()=>{N.current?.(),v&&p.current?.contentWindow?.__mdf_triggerFitContent?.(),C.current=null});const e=setTimeout(()=>N.current?.(),100),a=setTimeout(()=>N.current?.(),500);return()=>{C.current!==null&&(window.cancelAnimationFrame(C.current),C.current=null),clearTimeout(e),clearTimeout(a)}},[X,f,De,Fe,V,Ee,Me,Ve,ne,be,u,he,v]);const xt=[`w-full relative content-render-iframe-sandbox content-render-iframe-sandbox--${o}`,S?"h-full overflow-auto flex flex-col":we?"overflow-hidden":"aspect-[16/9] overflow-hidden flex items-center justify-center"].filter(Boolean).join(" ");return I.jsxs("div",{ref:T,dir:x,lang:re,"data-root-vh":be?"true":"false",className:xt,style:j?{height:j,minHeight:j}:we,children:[!ye&&I.jsx("button",{ref:ke,type:"button",dir:$,onClick:Rt,className:"absolute top-2 end-2 z-50 p-1.5 bg-black/75 text-white rounded-md cursor-pointer",children:ue?st:it}),u==="blackboard"&&o==="markdown"?I.jsx("div",{ref:ct,children:I.jsx(Et.default,{content:i,locale:f,dir:x,lang:re,disableSandboxLoadingOverlay:ne})}):I.jsx("iframe",{ref:p,sandbox:"allow-scripts allow-same-origin allow-popups allow-popups-to-escape-sandbox",allow:"fullscreen",allowFullScreen:!0,className:[l,"w-full h-full mx-auto my-auto block"].filter(Boolean).join(" "),style:{height:j??Ht??"100%",minHeight:j,margin:"auto"}})]})},Ot=i=>{const o=i.mode??"content",l=!!(i.enableScaling&&o==="blackboard"&&i.type==="sandbox"),f=`${i.type}:${o}:${l?"scaled":"unscaled"}`;return I.jsx(qt,{...i},f)};exports.default=Ot;
24
24
  //# sourceMappingURL=IframeSandbox.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"IframeSandbox.cjs","sources":["../../../src/components/ContentRender/IframeSandbox.tsx"],"sourcesContent":["import React, {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { createRoot, Root } from \"react-dom/client\";\nimport SandboxApp from \"./SandboxApp\";\nimport ContentRender from \"./ContentRender\";\nimport {\n EMPTY_ROOT_HEIGHT_META,\n inspectViewportHeightFromHtmlRootString,\n inspectViewportHeightFromNodeChain,\n parseExplicitHeight,\n resolveExplicitHeightFromNodeChain,\n} from \"./utils/iframe-viewport-height\";\nimport {\n SANDBOX_INTERACTION_MESSAGE_SOURCE,\n SANDBOX_INTERACTION_MESSAGE_TYPE,\n} from \"../../lib/sandboxInteraction\";\nimport {\n injectScalingSystem,\n type ScalingWindow,\n} from \"./utils/iframe-scaling\";\nimport {\n getMarkdownFlowDirection,\n getMarkdownFlowLanguage,\n type MarkdownFlowLocale,\n} from \"../../lib/locale\";\nimport { useDetachedLanguage } from \"../../lib/useDetachedLanguage\";\nimport { useResolvedDirection } from \"../../lib/useResolvedDirection\";\nimport { getContentRenderLocaleTexts } from \"./contentRenderI18n\";\nimport { CJK_SAFE_SANS_FONT_FAMILY } from \"./cjkFontFamily\";\n\ntype BlackboardVendorModule = typeof import(\"./blackboard-vendor\");\n\n// Cache the sandbox vendor loader so every iframe reuses the same preload request.\nlet blackboardVendorPromise: Promise<BlackboardVendorModule> | null = null;\n\nconst loadBlackboardVendor = () => {\n if (!blackboardVendorPromise) {\n blackboardVendorPromise = import(\"./blackboard-vendor\");\n }\n\n return blackboardVendorPromise;\n};\n\nconst COMPLETE_IMAGE_TAG_PATTERN = /<img\\b[^>]*>/i;\nconst POST_IMAGE_STREAM_DEBOUNCE_MS = 180;\nconst SANDBOX_INTERACTION_THROTTLE_MS = 240;\n\nexport interface IframeSandboxProps {\n content: string;\n className?: string;\n locale?: MarkdownFlowLocale;\n /** Overrides the locale-derived language without changing authored HTML language. */\n lang?: string;\n /** Overrides locale-derived direction without replacing authored HTML direction. */\n dir?: React.HTMLAttributes<HTMLDivElement>[\"dir\"];\n loadingText?: string;\n styleLoadingText?: string;\n scriptLoadingText?: string;\n fullScreenButtonText?: string;\n exitFullScreenButtonText?: string;\n hideFullScreen?: boolean;\n mode?: \"content\" | \"blackboard\";\n type: \"sandbox\" | \"markdown\";\n replaceRootScreenHeightWithFull?: boolean;\n enableScaling?: boolean;\n disableLoadingOverlay?: boolean;\n}\n\nconst replaceRootScreenHeightToken = (className: string) =>\n className\n .split(/\\s+/)\n .filter(Boolean)\n .map((token) => {\n const segments = token.split(\":\");\n if (\n segments[segments.length - 1] !== \"h-screen\" &&\n segments[segments.length - 1] !== \"min-h-screen\"\n ) {\n return token;\n }\n segments[segments.length - 1] = \"h-full\";\n return segments.join(\":\");\n })\n .join(\" \");\n\nconst replaceRootScreenHeightWithFullClass = (\n html: string,\n enabled: boolean\n) => {\n if (!enabled || !html.trim()) {\n return html;\n }\n\n return html.replace(\n /^(\\s*<[a-zA-Z][\\w:-]*)(\\s[^>]*?)?>/,\n (match, tagStart: string, attrs = \"\") => {\n const classMatch = attrs.match(/\\bclass\\s*=\\s*([\"'])([^\"']*)\\1/i);\n\n if (!classMatch) {\n return match;\n }\n\n const nextClassName = replaceRootScreenHeightToken(classMatch[2]);\n\n if (nextClassName === classMatch[2]) {\n return match;\n }\n\n return `${tagStart}${attrs.replace(\n classMatch[0],\n `class=${classMatch[1]}${nextClassName}${classMatch[1]}`\n )}>`;\n }\n );\n};\n\nconst IframeSandboxInstance: React.FC<IframeSandboxProps> = ({\n content,\n type,\n className,\n locale,\n lang,\n dir,\n loadingText,\n styleLoadingText,\n scriptLoadingText,\n fullScreenButtonText,\n exitFullScreenButtonText,\n hideFullScreen = false,\n mode = \"content\",\n replaceRootScreenHeightWithFull = false,\n enableScaling = false,\n disableLoadingOverlay = false,\n}) => {\n const localeTexts = getContentRenderLocaleTexts(locale);\n const direction = dir ?? getMarkdownFlowDirection(locale);\n const language = lang ?? getMarkdownFlowLanguage(locale);\n const resolvedFullScreenButtonText =\n fullScreenButtonText || localeTexts.sandboxFullscreenButtonText;\n const resolvedExitFullScreenButtonText =\n exitFullScreenButtonText || localeTexts.sandboxExitFullscreenButtonText;\n const containerRef = useRef<HTMLDivElement>(null);\n const sandboxLanguage = useDetachedLanguage(containerRef, language);\n const { resolvedDirection } = useResolvedDirection(containerRef, direction);\n const markdownContainerRef = useRef<HTMLDivElement>(null);\n const markdownContentRef = useRef<HTMLElement>(null);\n const setMarkdownContentContainerRef = useCallback(\n (node: HTMLDivElement | null) => {\n markdownContainerRef.current = node;\n markdownContentRef.current =\n node?.querySelector<HTMLElement>(\".content-render\") ?? null;\n },\n []\n );\n const { resolvedDirection: markdownContentDirection } = useResolvedDirection(\n markdownContentRef,\n direction\n );\n const sandboxDirection = direction ?? resolvedDirection;\n const requestedDirectionRef = useRef(direction);\n requestedDirectionRef.current = direction;\n // Auto direction cannot inspect text across the iframe document boundary.\n // Mirror the rendered sandbox direction to host controls instead.\n const [sandboxContentDirection, setSandboxContentDirection] = useState<\n \"ltr\" | \"rtl\"\n >();\n let fullscreenControlDirection: \"ltr\" | \"rtl\" | undefined;\n if (direction === \"auto\") {\n fullscreenControlDirection = resolvedDirection;\n if (type === \"sandbox\") {\n fullscreenControlDirection = sandboxContentDirection ?? resolvedDirection;\n } else if (mode === \"blackboard\") {\n fullscreenControlDirection = markdownContentDirection;\n }\n }\n const iframeRef = useRef<HTMLIFrameElement>(null);\n const rootRef = useRef<Root | null>(null);\n const updateHeightRef = useRef<() => void>(() => {});\n const [height, setHeight] = useState(480);\n const [contentHeight, setContentHeight] = useState(0);\n const [containerWidth, setContainerWidth] = useState(0);\n const isMeasuringContentRef = useRef(false);\n const pendingHeightUpdateRef = useRef(false);\n const lastSandboxInteractionTimeRef = useRef(0);\n const [resetToken, setResetToken] = useState(0);\n const [isFullscreen, setIsFullscreen] = useState(false);\n const shouldInjectSandboxVendor = type === \"sandbox\";\n\n const isBlackboardMode = mode === \"blackboard\";\n const shouldEnableScaling =\n enableScaling && isBlackboardMode && type === \"sandbox\";\n const shouldMeasureDynamicHeight = isBlackboardMode && type === \"sandbox\";\n const shouldProcessRootScreenHeight =\n shouldMeasureDynamicHeight && replaceRootScreenHeightWithFull;\n const prevHtmlRef = useRef<string>(\"\");\n const htmlContent = React.useMemo(\n () => (type === \"sandbox\" ? content : \"\"),\n [content, type]\n );\n const normalizedHtmlContent = React.useMemo(\n () =>\n replaceRootScreenHeightWithFullClass(\n htmlContent,\n shouldProcessRootScreenHeight\n ),\n [htmlContent, shouldProcessRootScreenHeight]\n );\n const originalRootHeightMeta = React.useMemo(\n () =>\n shouldProcessRootScreenHeight\n ? inspectViewportHeightFromHtmlRootString(htmlContent)\n : EMPTY_ROOT_HEIGHT_META,\n [htmlContent, shouldProcessRootScreenHeight]\n );\n const shouldStretchRootHeight = React.useMemo(\n () =>\n shouldProcessRootScreenHeight &&\n originalRootHeightMeta.hasFullViewportHeight,\n [\n originalRootHeightMeta.hasFullViewportHeight,\n shouldProcessRootScreenHeight,\n ]\n );\n const [renderHtmlContent, setRenderHtmlContent] = useState(\n normalizedHtmlContent\n );\n const prevIncomingHtmlRef = useRef(normalizedHtmlContent);\n const pendingHtmlRef = useRef(normalizedHtmlContent);\n const deferRenderTimerRef = useRef<number | null>(null);\n const initialPaintFrameRef = useRef<number | null>(null);\n const renderViewportHeightCssRef = useRef<string | null>(null);\n\n const emitSandboxInteraction = useCallback((eventType: string) => {\n if (typeof window === \"undefined\") {\n return;\n }\n const now = Date.now();\n if (\n now - lastSandboxInteractionTimeRef.current <\n SANDBOX_INTERACTION_THROTTLE_MS\n ) {\n return;\n }\n lastSandboxInteractionTimeRef.current = now;\n window.postMessage(\n {\n source: SANDBOX_INTERACTION_MESSAGE_SOURCE,\n type: SANDBOX_INTERACTION_MESSAGE_TYPE,\n eventType,\n },\n window.location.origin\n );\n }, []);\n\n useEffect(() => {\n if (type !== \"markdown\" || mode !== \"blackboard\") return;\n const container = markdownContainerRef.current;\n if (!container) return;\n const handleClick = () => emitSandboxInteraction(\"click\");\n container.addEventListener(\"click\", handleClick);\n return () => container.removeEventListener(\"click\", handleClick);\n }, [emitSandboxInteraction, mode, type]);\n\n const clearDeferredRenderTimer = () => {\n if (deferRenderTimerRef.current === null) return;\n window.clearTimeout(deferRenderTimerRef.current);\n deferRenderTimerRef.current = null;\n };\n\n const clearInitialPaintFrames = () => {\n if (initialPaintFrameRef.current !== null) {\n window.cancelAnimationFrame(initialPaintFrameRef.current);\n initialPaintFrameRef.current = null;\n }\n };\n\n useEffect(\n () => () => {\n clearDeferredRenderTimer();\n clearInitialPaintFrames();\n },\n []\n );\n\n useEffect(() => {\n const prevIncomingHtml = prevIncomingHtmlRef.current;\n prevIncomingHtmlRef.current = normalizedHtmlContent;\n\n const isAppendOnlyStream =\n !!prevIncomingHtml &&\n normalizedHtmlContent.length > prevIncomingHtml.length &&\n normalizedHtmlContent.startsWith(prevIncomingHtml);\n const containsCompleteImage = COMPLETE_IMAGE_TAG_PATTERN.test(\n normalizedHtmlContent\n );\n const shouldDeferRender = isAppendOnlyStream && containsCompleteImage;\n\n if (!shouldDeferRender) {\n clearDeferredRenderTimer();\n pendingHtmlRef.current = normalizedHtmlContent;\n setRenderHtmlContent(normalizedHtmlContent);\n return;\n }\n\n pendingHtmlRef.current = normalizedHtmlContent;\n clearDeferredRenderTimer();\n deferRenderTimerRef.current = window.setTimeout(() => {\n setRenderHtmlContent(pendingHtmlRef.current);\n deferRenderTimerRef.current = null;\n }, POST_IMAGE_STREAM_DEBOUNCE_MS);\n }, [normalizedHtmlContent]);\n\n const rootViewportHeightCss = React.useMemo(() => {\n if (!shouldMeasureDynamicHeight) {\n return null;\n }\n\n return inspectViewportHeightFromHtmlRootString(renderHtmlContent)\n .viewportHeightCss;\n }, [renderHtmlContent, shouldMeasureDynamicHeight]);\n\n useEffect(() => {\n renderViewportHeightCssRef.current = rootViewportHeightCss;\n }, [rootViewportHeightCss]);\n\n const hasRootVhHeight = Boolean(rootViewportHeightCss);\n const sandboxViewportHeight =\n isBlackboardMode && type === \"sandbox\"\n ? shouldEnableScaling\n ? \"100%\"\n : shouldStretchRootHeight\n ? \"100%\"\n : (rootViewportHeightCss ?? `${height}px`)\n : undefined;\n useEffect(() => {\n if (mode !== \"blackboard\") {\n prevHtmlRef.current = normalizedHtmlContent;\n return;\n }\n const prev = prevHtmlRef.current;\n const isContinuation = prev && normalizedHtmlContent.startsWith(prev);\n if (!isContinuation && prev) {\n setResetToken((token) => token + 1);\n }\n prevHtmlRef.current = normalizedHtmlContent;\n }, [mode, normalizedHtmlContent]);\n\n useEffect(() => {\n const iframe = iframeRef.current;\n if (!iframe) return undefined;\n\n const doc = iframe.contentDocument;\n if (!doc) return undefined;\n\n doc.open();\n doc.write(`<!DOCTYPE html>\n<html${mode === \"blackboard\" ? ' style=\"height: 100%;\"' : \"\"}>\n <head>\n <meta charset=\"utf-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <style>\n :root { color-scheme: light; }\n html, body, #root { width: 100%; font-family: ${CJK_SAFE_SANS_FONT_FAMILY}; }\n ${mode === \"blackboard\" ? \"html, body, #root { height: 100%; }\" : \"\"}\n html, body { margin: 0; padding: 0; overflow: ${shouldEnableScaling ? \"hidden auto\" : mode === \"blackboard\" ? \"auto\" : \"hidden\"}; }\n *, *::before, *::after { box-sizing: border-box; }\n ${\n mode !== \"blackboard\"\n ? `\n .h-screen { height: auto !important; }\n .min-h-screen { min-height: auto !important; }\n .h-dvh, .h-svh, .h-lvh { height: auto !important; }\n .min-h-dvh, .min-h-svh, .min-h-lvh { min-height: auto !important; }\n `\n : \"\"\n }\n </style>\n </head>\n <body>\n <div id=\"root\"></div>\n </body>\n</html>`);\n doc.close();\n\n // Force iframe theme to stay in light mode regardless of host OS preference.\n doc.documentElement.setAttribute(\"data-theme\", \"light\");\n doc.documentElement.style.colorScheme = \"light\";\n doc.body?.style.setProperty(\"color-scheme\", \"light\");\n\n const shouldBridgeSandboxInteraction =\n isBlackboardMode && type === \"sandbox\";\n const handleSandboxClick = () => emitSandboxInteraction(\"click\");\n\n if (shouldBridgeSandboxInteraction) {\n doc.addEventListener(\"click\", handleSandboxClick, true);\n }\n\n const rootEl = doc.getElementById(\"root\");\n if (!rootEl) return undefined;\n\n const root = createRoot(rootEl);\n rootRef.current = root;\n let isDestroyed = false;\n const getHeightInspectionNode = (node: HTMLElement) => ({\n heightAttrValue: node.getAttribute(\"height\"),\n styleAttrValue: node.getAttribute(\"style\"),\n classAttrValue: node.getAttribute(\"class\"),\n });\n const getSingleChildElement = (node: HTMLElement) => {\n const childElements = Array.from(node.children) as HTMLElement[];\n\n return childElements.length === 1 ? childElements[0] : null;\n };\n\n const resolveExplicitHeight = () => {\n if (!shouldMeasureDynamicHeight) return null;\n if (!iframeRef.current || !doc.body) return null;\n const parentViewportHeight =\n iframeRef.current.ownerDocument?.documentElement?.clientHeight ||\n window.innerHeight;\n // Reuse parsed height metadata from the current html snapshot first to\n // avoid re-inspecting the same DOM chain on every height tick.\n const precomputedViewportHeightCss = renderViewportHeightCssRef.current;\n const parsed = precomputedViewportHeightCss\n ? parseExplicitHeight(\n precomputedViewportHeightCss,\n parentViewportHeight\n )\n : null;\n\n if (parsed !== null) {\n return Math.ceil(parsed);\n }\n\n const wrapper = doc.body.querySelector(\n \".sandbox-wrapper\"\n ) as HTMLElement | null;\n const container = wrapper?.firstElementChild as HTMLElement | null;\n if (!container) return null;\n const containerChildren = Array.from(container.children) as HTMLElement[];\n const rootContentElement =\n containerChildren.length === 1 ? containerChildren[0] : null;\n const runtimeHeightMeta = inspectViewportHeightFromNodeChain(\n rootContentElement,\n {\n getNode: getHeightInspectionNode,\n getSingleChild: getSingleChildElement,\n }\n );\n const runtimeViewportHeightCss = runtimeHeightMeta.viewportHeightCss;\n\n if (runtimeViewportHeightCss) {\n const runtimeViewportHeight = parseExplicitHeight(\n runtimeViewportHeightCss,\n parentViewportHeight\n );\n\n if (runtimeViewportHeight !== null) {\n return Math.ceil(runtimeViewportHeight);\n }\n }\n\n const explicitPixelHeight = resolveExplicitHeightFromNodeChain(\n rootContentElement,\n parentViewportHeight,\n {\n getNode: getHeightInspectionNode,\n getSingleChild: getSingleChildElement,\n }\n );\n\n return explicitPixelHeight !== null\n ? Math.ceil(explicitPixelHeight)\n : null;\n };\n\n const updateHeight = () => {\n if (!iframeRef.current || !doc.body) return;\n\n if (!isBlackboardMode) {\n // Guard: prevent re-entrant measurement from ResizeObserver /\n // MutationObserver callbacks triggered by our own height changes.\n if (isMeasuringContentRef.current) {\n // Mark that an update was requested while the guard was active.\n // We will retry once the guard releases (see setTimeout below).\n pendingHeightUpdateRef.current = true;\n return;\n }\n isMeasuringContentRef.current = true;\n\n // Content mode height measurement strategy:\n // Temporarily set iframe height to the 16:9 minimum so that:\n // 1. vmin units are stable: vmin = min(cw, minH)/100 = minH/100,\n // consistent with the final rendered 16:9 iframe.\n // 2. Viewport-filling content (e.g. inline style=\"height:100vh\")\n // fills the 16:9 space → scrollHeight = minH, which is then\n // correctly bounded by the 16:9 minimum in contentModeStyle.\n // (Previously using cw caused such content to report 1:1 height,\n // overriding the 16:9 minimum.)\n const iframe = iframeRef.current;\n const cw = containerRef.current?.clientWidth || 0;\n const prevH = iframe.style.height;\n\n if (cw > 0) {\n const minH = Math.round((cw * 9) / 16);\n // Absolute height cap. Diverging vh-feedback (multiple `height:100vh`\n // siblings, or compound vh-relative children whose sum exceeds the\n // viewport) can otherwise grow the iframe geometrically across\n // repeated ResizeObserver/MutationObserver passes. 1:20 aspect is\n // a generous upper bound for any single sandbox slide.\n const maxH = Math.max(8192, cw * 20);\n iframe.style.height = minH + \"px\";\n // eslint-disable-next-line @typescript-eslint/no-unused-expressions\n doc.body.offsetHeight; // force layout\n\n let measuredH = doc.body.scrollHeight;\n\n // Detect inner elements that clip overflowing content behind a\n // scrollbar (e.g. <div style=\"height:100vh; overflow-y:auto\"> whose\n // content is taller than the iframe). body.scrollHeight won't see\n // that overflow, so we walk the tree and factor in each scrollable\n // element's full scroll height based on its position in the iframe.\n const iframeWin = doc.defaultView;\n if (iframeWin) {\n // Returns the max natural bottom of inner elements that clip\n // content via overflow:auto/scroll (i.e. internal scrollbars).\n const getInnerScrollableHeight = (root: Element): number => {\n let maxH = 0;\n const walk = (el: Element) => {\n if (el !== root && el.scrollHeight > el.clientHeight + 1) {\n const oy = iframeWin.getComputedStyle(el).overflowY;\n if (oy === \"auto\" || oy === \"scroll\") {\n const rect = el.getBoundingClientRect();\n if (rect.top >= 0) {\n maxH = Math.max(\n maxH,\n Math.ceil(rect.top + el.scrollHeight)\n );\n }\n }\n }\n for (const child of el.children) walk(child);\n };\n walk(root);\n return maxH;\n };\n\n measuredH = Math.max(measuredH, getInnerScrollableHeight(doc.body));\n\n // Content that uses vh-relative sizing grows as the viewport\n // expands. Measure up to 8 more times at the expanded height so\n // we capture the full content height in a single updateHeight()\n // call rather than waiting for external re-triggers.\n for (let i = 0; i < 8 && measuredH > minH; i++) {\n iframe.style.height = measuredH + \"px\";\n // eslint-disable-next-line @typescript-eslint/no-unused-expressions\n doc.body.offsetHeight; // force layout at expanded size\n const nextH = Math.max(\n doc.body.scrollHeight,\n getInnerScrollableHeight(doc.body)\n );\n if (nextH <= measuredH + 1) break; // stable — stop iterating\n // Geometric vh-feedback detection: vh-relative children scale\n // with the iframe viewport, so growing the iframe makes them\n // larger which grows scrollHeight — runaway divergence. Two\n // `height:100vh` siblings produce a 2× per-iteration multiplier.\n // Stop iterating; keep the prior (stable) measuredH.\n if (nextH >= measuredH * 1.5) break;\n measuredH = nextH;\n }\n }\n\n // Restore iframe to let React control it via contentModeStyle\n iframe.style.height = prevH;\n\n setContentHeight((prev) => {\n const next = Math.min(maxH, Math.max(200, Math.ceil(measuredH)));\n return prev === next ? prev : next;\n });\n }\n\n setTimeout(() => {\n isMeasuringContentRef.current = false;\n // Retry any update that was blocked while the guard was active\n // (e.g. dynamic content injected by scripts or images loading).\n if (pendingHeightUpdateRef.current) {\n pendingHeightUpdateRef.current = false;\n scheduleHeightUpdate();\n }\n }, 50);\n return;\n }\n\n // Scaling mode: viewport is fixed, content scales via font-size.\n if (shouldEnableScaling) return;\n\n // Blackboard mode: use existing measurement logic\n const bodyScrollH = doc.body.scrollHeight;\n const htmlScrollH = doc.documentElement?.scrollHeight || 0;\n const rootScrollH = rootEl?.scrollHeight || 0;\n const measuredHeight = Math.max(bodyScrollH, htmlScrollH, rootScrollH);\n\n if (shouldMeasureDynamicHeight) {\n const explicitHeight = resolveExplicitHeight();\n const nextHeight = Math.max(\n 200,\n explicitHeight ?? Math.ceil(measuredHeight)\n );\n setHeight((prevHeight) =>\n prevHeight === nextHeight ? prevHeight : nextHeight\n );\n }\n };\n const scheduleHeightUpdate = () => {\n requestAnimationFrame(() => {\n if (isDestroyed) return;\n updateHeight();\n });\n };\n updateHeightRef.current = scheduleHeightUpdate;\n\n updateHeight();\n scheduleHeightUpdate();\n\n if (shouldInjectSandboxVendor) {\n // Inject Tailwind/DaisyUI/GSAP before rendering sandbox content to avoid FOUC.\n loadBlackboardVendor()\n .then(({ injectBlackboardLibraries }) => {\n if (isDestroyed) return;\n injectBlackboardLibraries(doc);\n if (shouldEnableScaling) {\n injectScalingSystem(doc);\n }\n requestAnimationFrame(() => {\n if (isDestroyed) return;\n scheduleHeightUpdate();\n });\n })\n .catch(() => {\n if (isDestroyed) return;\n scheduleHeightUpdate();\n });\n }\n\n const hostElement = containerRef.current;\n let needsTailwindRefreshAfterHidden = Boolean(\n hostElement &&\n (hostElement.clientWidth <= 0 || hostElement.clientHeight <= 0)\n );\n let isTailwindRefreshQueued = false;\n let tailwindRefreshFrame: number | null = null;\n let tailwindRefreshTimer: number | null = null;\n const runPostTailwindRefreshLayout = () => {\n if (isDestroyed) return;\n scheduleHeightUpdate();\n const iframeWin = iframe.contentWindow as ScalingWindow | null;\n iframeWin?.__mdf_triggerFitContent?.();\n };\n const isHostVisible = () =>\n Boolean(\n hostElement &&\n hostElement.clientWidth > 0 &&\n hostElement.clientHeight > 0\n );\n const queueTailwindRefreshAfterHidden = () => {\n if (\n !shouldInjectSandboxVendor ||\n !hostElement ||\n !needsTailwindRefreshAfterHidden ||\n isTailwindRefreshQueued ||\n !isHostVisible()\n ) {\n return;\n }\n\n isTailwindRefreshQueued = true;\n loadBlackboardVendor()\n .then(({ refreshTailwindRuntime }) => {\n if (isDestroyed) return;\n\n tailwindRefreshFrame = window.requestAnimationFrame(() => {\n tailwindRefreshFrame = null;\n isTailwindRefreshQueued = false;\n\n const sandboxContainer = doc.querySelector(\".sandbox-container\");\n if (\n isDestroyed ||\n !isHostVisible() ||\n !sandboxContainer?.childNodes.length ||\n !refreshTailwindRuntime(doc)\n ) {\n return;\n }\n\n needsTailwindRefreshAfterHidden = false;\n runPostTailwindRefreshLayout();\n tailwindRefreshTimer = window.setTimeout(() => {\n tailwindRefreshTimer = null;\n runPostTailwindRefreshLayout();\n }, 100);\n });\n })\n .catch(() => {\n isTailwindRefreshQueued = false;\n });\n };\n const canObserveResize = typeof ResizeObserver !== \"undefined\";\n const hostResizeObserver =\n shouldInjectSandboxVendor && hostElement && canObserveResize\n ? new ResizeObserver((entries) => {\n const contentRect = entries[0]?.contentRect;\n const hostWidth = contentRect?.width ?? hostElement.clientWidth;\n const hostHeight = contentRect?.height ?? hostElement.clientHeight;\n const isHostSizeVisible = hostWidth > 0 && hostHeight > 0;\n\n if (!isHostSizeVisible) {\n return;\n }\n\n queueTailwindRefreshAfterHidden();\n })\n : null;\n if (hostResizeObserver && hostElement) {\n hostResizeObserver.observe(hostElement);\n }\n\n const resizeObserver = canObserveResize\n ? new ResizeObserver(() => updateHeight())\n : null;\n resizeObserver?.observe(doc.body);\n if (rootEl) {\n resizeObserver?.observe(rootEl);\n }\n\n const syncSandboxContentDirection = () => {\n if (type !== \"sandbox\" || requestedDirectionRef.current !== \"auto\") {\n return;\n }\n const wrapper = doc.querySelector<HTMLElement>(\".sandbox-wrapper\");\n const view = doc.defaultView;\n if (!wrapper || !view) return;\n const nextDirection =\n view.getComputedStyle(wrapper).direction === \"rtl\" ? \"rtl\" : \"ltr\";\n setSandboxContentDirection((currentDirection) =>\n currentDirection === nextDirection ? currentDirection : nextDirection\n );\n };\n\n // MutationObserver: detect DOM changes that ResizeObserver might miss\n // (e.g. content injected by scripts, images loading, dynamic rendering)\n const mutationObserver = new MutationObserver(() => {\n syncSandboxContentDirection();\n scheduleHeightUpdate();\n if (!isHostVisible()) {\n needsTailwindRefreshAfterHidden = true;\n return;\n }\n queueTailwindRefreshAfterHidden();\n });\n mutationObserver.observe(doc.body, {\n childList: true,\n characterData: true,\n subtree: true,\n attributes: true,\n attributeFilter: [\"style\", \"class\", \"dir\"],\n });\n\n return () => {\n isDestroyed = true;\n hostResizeObserver?.disconnect();\n resizeObserver?.disconnect();\n mutationObserver.disconnect();\n if (tailwindRefreshFrame !== null) {\n window.cancelAnimationFrame(tailwindRefreshFrame);\n }\n if (tailwindRefreshTimer !== null) {\n window.clearTimeout(tailwindRefreshTimer);\n }\n if (shouldEnableScaling) {\n const iframeWin = iframe.contentWindow as ScalingWindow | null;\n iframeWin?.__mdf_cleanupScaling?.();\n }\n if (shouldBridgeSandboxInteraction) {\n doc.removeEventListener(\"click\", handleSandboxClick, true);\n }\n if (rootRef.current === root) {\n rootRef.current = null;\n updateHeightRef.current = () => {};\n }\n // Defer unmount to avoid React warning when parent is mid-render\n setTimeout(() => {\n root.unmount();\n }, 0);\n };\n }, []);\n\n useEffect(() => {\n const onFullscreenChange = () => {\n setIsFullscreen(Boolean(document.fullscreenElement));\n };\n document.addEventListener(\"fullscreenchange\", onFullscreenChange);\n return () =>\n document.removeEventListener(\"fullscreenchange\", onFullscreenChange);\n }, []);\n\n // Track container width for computing min-height in content mode\n useEffect(() => {\n const el = containerRef.current;\n if (!el) return;\n if (typeof ResizeObserver === \"undefined\") {\n setContainerWidth(el.clientWidth);\n return;\n }\n const ro = new ResizeObserver((entries) => {\n setContainerWidth(entries[0]?.contentRect.width ?? el.clientWidth);\n });\n ro.observe(el);\n setContainerWidth(el.clientWidth);\n return () => ro.disconnect();\n }, []);\n\n // Content mode: min 16:9 aspect ratio, grow to fit content (no scrollbar)\n const contentModeStyle = useMemo<React.CSSProperties | undefined>(() => {\n if (isBlackboardMode || containerWidth === 0 || isFullscreen)\n return undefined;\n const minH = Math.round((containerWidth * 9) / 16);\n const h = Math.max(minH, contentHeight);\n return { height: h };\n }, [isBlackboardMode, containerWidth, contentHeight, isFullscreen]);\n\n const toggleFullscreen = () => {\n const target = containerRef.current || iframeRef.current;\n if (!target) return;\n if (document.fullscreenElement) {\n document.exitFullscreen().catch(() => {});\n return;\n }\n if (target.requestFullscreen) {\n target.requestFullscreen().catch(() => {});\n }\n };\n\n useEffect(() => {\n const root = rootRef.current;\n if (!root) return;\n\n root.render(\n <SandboxApp\n html={renderHtmlContent}\n locale={locale}\n dir={sandboxDirection}\n lang={sandboxLanguage}\n loadingText={loadingText}\n styleLoadingText={styleLoadingText}\n scriptLoadingText={scriptLoadingText}\n disableLoadingOverlay={disableLoadingOverlay}\n resetToken={resetToken}\n hasRootVhHeight={hasRootVhHeight}\n mode={mode}\n stretchRootHeight={shouldStretchRootHeight}\n enableScaling={shouldEnableScaling}\n />\n );\n\n // Schedule multiple measurements to catch async content (scripts, images, styles).\n initialPaintFrameRef.current = window.requestAnimationFrame(() => {\n updateHeightRef.current?.();\n if (shouldEnableScaling) {\n const iframeWin = iframeRef.current\n ?.contentWindow as ScalingWindow | null;\n iframeWin?.__mdf_triggerFitContent?.();\n }\n initialPaintFrameRef.current = null;\n });\n const t1 = setTimeout(() => updateHeightRef.current?.(), 100);\n const t2 = setTimeout(() => updateHeightRef.current?.(), 500);\n return () => {\n if (initialPaintFrameRef.current !== null) {\n window.cancelAnimationFrame(initialPaintFrameRef.current);\n initialPaintFrameRef.current = null;\n }\n clearTimeout(t1);\n clearTimeout(t2);\n };\n }, [\n renderHtmlContent,\n locale,\n sandboxDirection,\n sandboxLanguage,\n loadingText,\n styleLoadingText,\n scriptLoadingText,\n resetToken,\n disableLoadingOverlay,\n hasRootVhHeight,\n mode,\n shouldStretchRootHeight,\n shouldEnableScaling,\n ]);\n const containerClassName = [\n `w-full relative content-render-iframe-sandbox content-render-iframe-sandbox--${type}`,\n isBlackboardMode\n ? \"h-full overflow-auto flex flex-col\"\n : contentModeStyle\n ? \"overflow-hidden flex items-center justify-center\"\n : \"aspect-[16/9] overflow-hidden flex items-center justify-center\",\n ]\n .filter(Boolean)\n .join(\" \");\n\n return (\n <div\n ref={containerRef}\n dir={direction}\n lang={language}\n data-root-vh={hasRootVhHeight ? \"true\" : \"false\"}\n className={containerClassName}\n style={\n sandboxViewportHeight\n ? {\n height: sandboxViewportHeight,\n minHeight: sandboxViewportHeight,\n }\n : contentModeStyle\n }\n >\n {!hideFullScreen && (\n <button\n type=\"button\"\n dir={fullscreenControlDirection}\n onClick={toggleFullscreen}\n className={\n \"absolute top-2 end-2 z-50 p-1.5 bg-black/75 text-white rounded-md cursor-pointer\"\n }\n >\n {isFullscreen\n ? resolvedExitFullScreenButtonText\n : resolvedFullScreenButtonText}\n </button>\n )}\n {mode === \"blackboard\" && type === \"markdown\" ? (\n <div ref={setMarkdownContentContainerRef}>\n <ContentRender\n content={content}\n locale={locale}\n dir={direction}\n lang={language}\n disableSandboxLoadingOverlay={disableLoadingOverlay}\n />\n </div>\n ) : (\n <iframe\n ref={iframeRef}\n sandbox=\"allow-scripts allow-same-origin allow-popups allow-popups-to-escape-sandbox\"\n allow=\"fullscreen\"\n allowFullScreen\n className={[className, \"w-full h-full mx-auto my-auto block\"]\n .filter(Boolean)\n .join(\" \")}\n style={{\n height: sandboxViewportHeight ?? \"100%\",\n minHeight: sandboxViewportHeight,\n margin: \"auto\",\n }}\n />\n )}\n </div>\n );\n};\n\nconst IframeSandbox: React.FC<IframeSandboxProps> = (props) => {\n const mode = props.mode ?? \"content\";\n const shouldEnableScaling = Boolean(\n props.enableScaling && mode === \"blackboard\" && props.type === \"sandbox\"\n );\n // The iframe shell captures these initialization-only values. Remounting the\n // inner instance keeps old and new React roots from sharing cleanup refs.\n const lifecycleKey = `${props.type}:${mode}:${shouldEnableScaling ? \"scaled\" : \"unscaled\"}`;\n\n return <IframeSandboxInstance key={lifecycleKey} {...props} />;\n};\n\nexport default IframeSandbox;\n"],"names":["blackboardVendorPromise","loadBlackboardVendor","COMPLETE_IMAGE_TAG_PATTERN","POST_IMAGE_STREAM_DEBOUNCE_MS","SANDBOX_INTERACTION_THROTTLE_MS","replaceRootScreenHeightToken","className","token","segments","replaceRootScreenHeightWithFullClass","html","enabled","match","tagStart","attrs","classMatch","nextClassName","IframeSandboxInstance","content","type","locale","lang","dir","loadingText","styleLoadingText","scriptLoadingText","fullScreenButtonText","exitFullScreenButtonText","hideFullScreen","mode","replaceRootScreenHeightWithFull","enableScaling","disableLoadingOverlay","localeTexts","getContentRenderLocaleTexts","direction","getMarkdownFlowDirection","language","getMarkdownFlowLanguage","resolvedFullScreenButtonText","resolvedExitFullScreenButtonText","containerRef","useRef","sandboxLanguage","useDetachedLanguage","resolvedDirection","useResolvedDirection","markdownContainerRef","markdownContentRef","setMarkdownContentContainerRef","useCallback","node","markdownContentDirection","sandboxDirection","requestedDirectionRef","sandboxContentDirection","setSandboxContentDirection","useState","fullscreenControlDirection","iframeRef","rootRef","updateHeightRef","height","setHeight","contentHeight","setContentHeight","containerWidth","setContainerWidth","isMeasuringContentRef","pendingHeightUpdateRef","lastSandboxInteractionTimeRef","resetToken","setResetToken","isFullscreen","setIsFullscreen","shouldInjectSandboxVendor","isBlackboardMode","shouldEnableScaling","shouldMeasureDynamicHeight","shouldProcessRootScreenHeight","prevHtmlRef","htmlContent","React","normalizedHtmlContent","originalRootHeightMeta","inspectViewportHeightFromHtmlRootString","EMPTY_ROOT_HEIGHT_META","shouldStretchRootHeight","renderHtmlContent","setRenderHtmlContent","prevIncomingHtmlRef","pendingHtmlRef","deferRenderTimerRef","initialPaintFrameRef","renderViewportHeightCssRef","emitSandboxInteraction","eventType","now","SANDBOX_INTERACTION_MESSAGE_SOURCE","SANDBOX_INTERACTION_MESSAGE_TYPE","useEffect","container","handleClick","clearDeferredRenderTimer","clearInitialPaintFrames","prevIncomingHtml","isAppendOnlyStream","containsCompleteImage","rootViewportHeightCss","hasRootVhHeight","sandboxViewportHeight","prev","iframe","doc","CJK_SAFE_SANS_FONT_FAMILY","shouldBridgeSandboxInteraction","handleSandboxClick","rootEl","root","createRoot","isDestroyed","getHeightInspectionNode","getSingleChildElement","childElements","resolveExplicitHeight","parentViewportHeight","precomputedViewportHeightCss","parsed","parseExplicitHeight","containerChildren","rootContentElement","runtimeViewportHeightCss","inspectViewportHeightFromNodeChain","runtimeViewportHeight","explicitPixelHeight","resolveExplicitHeightFromNodeChain","updateHeight","cw","prevH","minH","maxH","measuredH","iframeWin","getInnerScrollableHeight","walk","el","oy","rect","child","i","nextH","next","scheduleHeightUpdate","bodyScrollH","htmlScrollH","rootScrollH","measuredHeight","explicitHeight","nextHeight","prevHeight","injectBlackboardLibraries","injectScalingSystem","hostElement","needsTailwindRefreshAfterHidden","isTailwindRefreshQueued","tailwindRefreshFrame","tailwindRefreshTimer","runPostTailwindRefreshLayout","isHostVisible","queueTailwindRefreshAfterHidden","refreshTailwindRuntime","sandboxContainer","canObserveResize","hostResizeObserver","entries","contentRect","hostWidth","hostHeight","resizeObserver","syncSandboxContentDirection","wrapper","view","nextDirection","currentDirection","mutationObserver","onFullscreenChange","ro","contentModeStyle","useMemo","toggleFullscreen","target","jsx","SandboxApp","t1","t2","containerClassName","jsxs","ContentRender","IframeSandbox","props","lifecycleKey"],"mappings":"wlBAsCA,IAAIA,GAAkE,KAEtE,MAAMC,GAAuB,KACtBD,KACHA,GAA0B,QAAA,QAAA,EAAA,KAAA,IAAA,QAAO,yBAAqB,CAAA,GAGjDA,IAGHE,GAA6B,gBAC7BC,GAAgC,IAChCC,GAAkC,IAuBlCC,GAAgCC,GACpCA,EACG,MAAM,KAAK,EACX,OAAO,OAAO,EACd,IAAKC,GAAU,CACd,MAAMC,EAAWD,EAAM,MAAM,GAAG,EAChC,OACEC,EAASA,EAAS,OAAS,CAAC,IAAM,YAClCA,EAASA,EAAS,OAAS,CAAC,IAAM,eAE3BD,GAETC,EAASA,EAAS,OAAS,CAAC,EAAI,SACzBA,EAAS,KAAK,GAAG,EAC1B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ME,GACN,eAAcwE,GAAkB,OAAS,QACzC,UAAWsF,GACX,MACErF,EACI,CACE,OAAQA,EACR,UAAWA,CAAA,EAEb6E,GAGL,SAAA,CAAA,CAAC/J,IACAmK,EAAAA,IAAC,SAAA,CACC,KAAK,SACL,IAAKrI,EACL,QAASmI,GACT,UACE,mFAGD,YACGrJ,GACAD,EAAA,CAAA,EAGPV,IAAS,cAAgBV,IAAS,WACjC4K,EAAAA,IAAC,MAAA,CAAI,IAAK9I,GACR,SAAA8I,EAAAA,IAACM,GAAAA,QAAA,CACC,QAAAnL,EAAA,OACAE,EACA,IAAKe,EACL,KAAME,GACN,6BAA8BL,EAAA,CAAA,EAElC,EAEA+J,EAAAA,IAAC,SAAA,CACC,IAAKpI,EACL,QAAQ,8EACR,MAAM,aACN,gBAAe,GACf,UAAW,CAACrD,EAAW,qCAAqC,EACzD,OAAO,OAAO,EACd,KAAK,GAAG,EACX,MAAO,CACL,OAAQwG,GAAyB,OACjC,UAAWA,EACX,OAAQ,MAAA,CACV,CAAA,CACF,CAAA,CAAA,CAIR,EAEMwF,GAA+CC,GAAU,CAC7D,MAAM1K,EAAO0K,EAAM,MAAQ,UACrB1H,EAAsB,GAC1B0H,EAAM,eAAiB1K,IAAS,cAAgB0K,EAAM,OAAS,WAI3DC,EAAe,GAAGD,EAAM,IAAI,IAAI1K,CAAI,IAAIgD,EAAsB,SAAW,UAAU,GAEzF,OAAOkH,EAAAA,IAAC9K,GAAA,CAA0C,GAAGsL,CAAA,EAAlBC,CAAyB,CAC9D"}
1
+ {"version":3,"file":"IframeSandbox.cjs","sources":["../../../src/components/ContentRender/IframeSandbox.tsx"],"sourcesContent":["import React, {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { createRoot, Root } from \"react-dom/client\";\nimport SandboxApp from \"./SandboxApp\";\nimport ContentRender from \"./ContentRender\";\nimport {\n EMPTY_ROOT_HEIGHT_META,\n inspectViewportHeightFromHtmlRootString,\n inspectViewportHeightFromNodeChain,\n parseExplicitHeight,\n resolveExplicitHeightFromNodeChain,\n} from \"./utils/iframe-viewport-height\";\nimport {\n SANDBOX_INTERACTION_MESSAGE_SOURCE,\n SANDBOX_INTERACTION_MESSAGE_TYPE,\n} from \"../../lib/sandboxInteraction\";\nimport {\n injectScalingSystem,\n type ScalingWindow,\n} from \"./utils/iframe-scaling\";\nimport {\n getMarkdownFlowDirection,\n getMarkdownFlowLanguage,\n type MarkdownFlowLocale,\n} from \"../../lib/locale\";\nimport { useDetachedLanguage } from \"../../lib/useDetachedLanguage\";\nimport { useResolvedDirection } from \"../../lib/useResolvedDirection\";\nimport { getContentRenderLocaleTexts } from \"./contentRenderI18n\";\nimport { CJK_SAFE_SANS_FONT_FAMILY } from \"./cjkFontFamily\";\n\ntype BlackboardVendorModule = typeof import(\"./blackboard-vendor\");\n\n// Cache the sandbox vendor loader so every iframe reuses the same preload request.\nlet blackboardVendorPromise: Promise<BlackboardVendorModule> | null = null;\n\nconst loadBlackboardVendor = () => {\n if (!blackboardVendorPromise) {\n blackboardVendorPromise = import(\"./blackboard-vendor\");\n }\n\n return blackboardVendorPromise;\n};\n\nconst COMPLETE_IMAGE_TAG_PATTERN = /<img\\b[^>]*>/i;\nconst POST_IMAGE_STREAM_DEBOUNCE_MS = 180;\nconst SANDBOX_INTERACTION_THROTTLE_MS = 240;\n\nexport interface IframeSandboxProps {\n content: string;\n className?: string;\n locale?: MarkdownFlowLocale;\n /** Overrides the locale-derived language without changing authored HTML language. */\n lang?: string;\n /** Overrides locale-derived direction without replacing authored HTML direction. */\n dir?: React.HTMLAttributes<HTMLDivElement>[\"dir\"];\n loadingText?: string;\n styleLoadingText?: string;\n scriptLoadingText?: string;\n fullScreenButtonText?: string;\n exitFullScreenButtonText?: string;\n hideFullScreen?: boolean;\n mode?: \"content\" | \"blackboard\";\n type: \"sandbox\" | \"markdown\";\n replaceRootScreenHeightWithFull?: boolean;\n enableScaling?: boolean;\n disableLoadingOverlay?: boolean;\n}\n\nconst replaceRootScreenHeightToken = (className: string) =>\n className\n .split(/\\s+/)\n .filter(Boolean)\n .map((token) => {\n const segments = token.split(\":\");\n if (\n segments[segments.length - 1] !== \"h-screen\" &&\n segments[segments.length - 1] !== \"min-h-screen\"\n ) {\n return token;\n }\n segments[segments.length - 1] = \"h-full\";\n return segments.join(\":\");\n })\n .join(\" \");\n\nconst replaceRootScreenHeightWithFullClass = (\n html: string,\n enabled: boolean\n) => {\n if (!enabled || !html.trim()) {\n return html;\n }\n\n return html.replace(\n /^(\\s*<[a-zA-Z][\\w:-]*)(\\s[^>]*?)?>/,\n (match, tagStart: string, attrs = \"\") => {\n const classMatch = attrs.match(/\\bclass\\s*=\\s*([\"'])([^\"']*)\\1/i);\n\n if (!classMatch) {\n return match;\n }\n\n const nextClassName = replaceRootScreenHeightToken(classMatch[2]);\n\n if (nextClassName === classMatch[2]) {\n return match;\n }\n\n return `${tagStart}${attrs.replace(\n classMatch[0],\n `class=${classMatch[1]}${nextClassName}${classMatch[1]}`\n )}>`;\n }\n );\n};\n\nconst IframeSandboxInstance: React.FC<IframeSandboxProps> = ({\n content,\n type,\n className,\n locale,\n lang,\n dir,\n loadingText,\n styleLoadingText,\n scriptLoadingText,\n fullScreenButtonText,\n exitFullScreenButtonText,\n hideFullScreen = false,\n mode = \"content\",\n replaceRootScreenHeightWithFull = false,\n enableScaling = false,\n disableLoadingOverlay = false,\n}) => {\n const localeTexts = getContentRenderLocaleTexts(locale);\n const direction = dir ?? getMarkdownFlowDirection(locale);\n const language = lang ?? getMarkdownFlowLanguage(locale);\n const resolvedFullScreenButtonText =\n fullScreenButtonText || localeTexts.sandboxFullscreenButtonText;\n const resolvedExitFullScreenButtonText =\n exitFullScreenButtonText || localeTexts.sandboxExitFullscreenButtonText;\n const containerRef = useRef<HTMLDivElement>(null);\n const fullscreenButtonRef = useRef<HTMLButtonElement>(null);\n const sandboxLanguage = useDetachedLanguage(containerRef, language);\n const { resolvedDirection } = useResolvedDirection(containerRef, direction);\n const markdownContainerRef = useRef<HTMLDivElement>(null);\n const markdownContentRef = useRef<HTMLElement>(null);\n const setMarkdownContentContainerRef = useCallback(\n (node: HTMLDivElement | null) => {\n markdownContainerRef.current = node;\n markdownContentRef.current =\n node?.querySelector<HTMLElement>(\".content-render\") ?? null;\n },\n []\n );\n const { resolvedDirection: markdownContentDirection } = useResolvedDirection(\n markdownContentRef,\n direction\n );\n const sandboxDirection = direction ?? resolvedDirection;\n const requestedDirectionRef = useRef(direction);\n requestedDirectionRef.current = direction;\n // Auto direction cannot inspect text across the iframe document boundary.\n // Mirror the rendered sandbox direction to host controls instead.\n const [sandboxContentDirection, setSandboxContentDirection] = useState<\n \"ltr\" | \"rtl\"\n >();\n let fullscreenControlDirection: \"ltr\" | \"rtl\" | undefined;\n if (direction === \"auto\") {\n fullscreenControlDirection = resolvedDirection;\n if (type === \"sandbox\") {\n fullscreenControlDirection = sandboxContentDirection ?? resolvedDirection;\n } else if (mode === \"blackboard\") {\n fullscreenControlDirection = markdownContentDirection;\n }\n }\n const iframeRef = useRef<HTMLIFrameElement>(null);\n const rootRef = useRef<Root | null>(null);\n const updateHeightRef = useRef<() => void>(() => {});\n const [height, setHeight] = useState(480);\n const [contentHeight, setContentHeight] = useState<number | null>(null);\n const [containerWidth, setContainerWidth] = useState(0);\n const [fullscreenControlHeight, setFullscreenControlHeight] = useState(0);\n const isMeasuringContentRef = useRef(false);\n const pendingHeightUpdateRef = useRef(false);\n const lastSandboxInteractionTimeRef = useRef(0);\n const [resetToken, setResetToken] = useState(0);\n const [isFullscreen, setIsFullscreen] = useState(false);\n const shouldInjectSandboxVendor = type === \"sandbox\";\n\n const isBlackboardMode = mode === \"blackboard\";\n const shouldEnableScaling =\n enableScaling && isBlackboardMode && type === \"sandbox\";\n const shouldMeasureDynamicHeight = isBlackboardMode && type === \"sandbox\";\n const shouldProcessRootScreenHeight =\n shouldMeasureDynamicHeight && replaceRootScreenHeightWithFull;\n const prevHtmlRef = useRef<string>(\"\");\n const htmlContent = React.useMemo(\n () => (type === \"sandbox\" ? content : \"\"),\n [content, type]\n );\n const normalizedHtmlContent = React.useMemo(\n () =>\n replaceRootScreenHeightWithFullClass(\n htmlContent,\n shouldProcessRootScreenHeight\n ),\n [htmlContent, shouldProcessRootScreenHeight]\n );\n const originalRootHeightMeta = React.useMemo(\n () =>\n shouldProcessRootScreenHeight\n ? inspectViewportHeightFromHtmlRootString(htmlContent)\n : EMPTY_ROOT_HEIGHT_META,\n [htmlContent, shouldProcessRootScreenHeight]\n );\n const shouldStretchRootHeight = React.useMemo(\n () =>\n shouldProcessRootScreenHeight &&\n originalRootHeightMeta.hasFullViewportHeight,\n [\n originalRootHeightMeta.hasFullViewportHeight,\n shouldProcessRootScreenHeight,\n ]\n );\n const [renderHtmlContent, setRenderHtmlContent] = useState(\n normalizedHtmlContent\n );\n const prevIncomingHtmlRef = useRef(normalizedHtmlContent);\n const pendingHtmlRef = useRef(normalizedHtmlContent);\n const deferRenderTimerRef = useRef<number | null>(null);\n const initialPaintFrameRef = useRef<number | null>(null);\n const renderViewportHeightCssRef = useRef<string | null>(null);\n\n const emitSandboxInteraction = useCallback((eventType: string) => {\n if (typeof window === \"undefined\") {\n return;\n }\n const now = Date.now();\n if (\n now - lastSandboxInteractionTimeRef.current <\n SANDBOX_INTERACTION_THROTTLE_MS\n ) {\n return;\n }\n lastSandboxInteractionTimeRef.current = now;\n window.postMessage(\n {\n source: SANDBOX_INTERACTION_MESSAGE_SOURCE,\n type: SANDBOX_INTERACTION_MESSAGE_TYPE,\n eventType,\n },\n window.location.origin\n );\n }, []);\n\n useEffect(() => {\n if (type !== \"markdown\" || mode !== \"blackboard\") return;\n const container = markdownContainerRef.current;\n if (!container) return;\n const handleClick = () => emitSandboxInteraction(\"click\");\n container.addEventListener(\"click\", handleClick);\n return () => container.removeEventListener(\"click\", handleClick);\n }, [emitSandboxInteraction, mode, type]);\n\n const clearDeferredRenderTimer = () => {\n if (deferRenderTimerRef.current === null) return;\n window.clearTimeout(deferRenderTimerRef.current);\n deferRenderTimerRef.current = null;\n };\n\n const clearInitialPaintFrames = () => {\n if (initialPaintFrameRef.current !== null) {\n window.cancelAnimationFrame(initialPaintFrameRef.current);\n initialPaintFrameRef.current = null;\n }\n };\n\n useEffect(\n () => () => {\n clearDeferredRenderTimer();\n clearInitialPaintFrames();\n },\n []\n );\n\n useEffect(() => {\n const prevIncomingHtml = prevIncomingHtmlRef.current;\n prevIncomingHtmlRef.current = normalizedHtmlContent;\n\n const isAppendOnlyStream =\n !!prevIncomingHtml &&\n normalizedHtmlContent.length > prevIncomingHtml.length &&\n normalizedHtmlContent.startsWith(prevIncomingHtml);\n const containsCompleteImage = COMPLETE_IMAGE_TAG_PATTERN.test(\n normalizedHtmlContent\n );\n const shouldDeferRender = isAppendOnlyStream && containsCompleteImage;\n\n if (!shouldDeferRender) {\n clearDeferredRenderTimer();\n pendingHtmlRef.current = normalizedHtmlContent;\n setRenderHtmlContent(normalizedHtmlContent);\n return;\n }\n\n pendingHtmlRef.current = normalizedHtmlContent;\n clearDeferredRenderTimer();\n deferRenderTimerRef.current = window.setTimeout(() => {\n setRenderHtmlContent(pendingHtmlRef.current);\n deferRenderTimerRef.current = null;\n }, POST_IMAGE_STREAM_DEBOUNCE_MS);\n }, [normalizedHtmlContent]);\n\n const rootViewportHeightCss = React.useMemo(() => {\n if (!shouldMeasureDynamicHeight) {\n return null;\n }\n\n return inspectViewportHeightFromHtmlRootString(renderHtmlContent)\n .viewportHeightCss;\n }, [renderHtmlContent, shouldMeasureDynamicHeight]);\n\n useEffect(() => {\n renderViewportHeightCssRef.current = rootViewportHeightCss;\n }, [rootViewportHeightCss]);\n\n const hasRootVhHeight = Boolean(rootViewportHeightCss);\n const sandboxViewportHeight =\n isBlackboardMode && type === \"sandbox\"\n ? shouldEnableScaling\n ? \"100%\"\n : shouldStretchRootHeight\n ? \"100%\"\n : (rootViewportHeightCss ?? `${height}px`)\n : undefined;\n useEffect(() => {\n if (mode !== \"blackboard\") {\n prevHtmlRef.current = normalizedHtmlContent;\n return;\n }\n const prev = prevHtmlRef.current;\n const isContinuation = prev && normalizedHtmlContent.startsWith(prev);\n if (!isContinuation && prev) {\n setResetToken((token) => token + 1);\n }\n prevHtmlRef.current = normalizedHtmlContent;\n }, [mode, normalizedHtmlContent]);\n\n useEffect(() => {\n const iframe = iframeRef.current;\n if (!iframe) return undefined;\n\n const doc = iframe.contentDocument;\n if (!doc) return undefined;\n\n doc.open();\n doc.write(`<!DOCTYPE html>\n<html${mode === \"blackboard\" ? ' style=\"height: 100%;\"' : \"\"}>\n <head>\n <meta charset=\"utf-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <style>\n :root { color-scheme: light; }\n html, body, #root { width: 100%; font-family: ${CJK_SAFE_SANS_FONT_FAMILY}; }\n ${mode === \"blackboard\" ? \"html, body, #root { height: 100%; }\" : \"\"}\n html, body { margin: 0; padding: 0; overflow: ${shouldEnableScaling ? \"hidden auto\" : mode === \"blackboard\" ? \"auto\" : \"hidden\"}; }\n *, *::before, *::after { box-sizing: border-box; }\n ${\n mode !== \"blackboard\"\n ? `\n .h-screen { height: auto !important; }\n .min-h-screen { min-height: auto !important; }\n .h-dvh, .h-svh, .h-lvh { height: auto !important; }\n .min-h-dvh, .min-h-svh, .min-h-lvh { min-height: auto !important; }\n `\n : \"\"\n }\n </style>\n </head>\n <body>\n <div id=\"root\"></div>\n </body>\n</html>`);\n doc.close();\n\n // Force iframe theme to stay in light mode regardless of host OS preference.\n doc.documentElement.setAttribute(\"data-theme\", \"light\");\n doc.documentElement.style.colorScheme = \"light\";\n doc.body?.style.setProperty(\"color-scheme\", \"light\");\n\n const shouldBridgeSandboxInteraction =\n isBlackboardMode && type === \"sandbox\";\n const handleSandboxClick = () => emitSandboxInteraction(\"click\");\n\n if (shouldBridgeSandboxInteraction) {\n doc.addEventListener(\"click\", handleSandboxClick, true);\n }\n\n const rootEl = doc.getElementById(\"root\");\n if (!rootEl) return undefined;\n\n const root = createRoot(rootEl);\n rootRef.current = root;\n let isDestroyed = false;\n const getHeightInspectionNode = (node: HTMLElement) => ({\n heightAttrValue: node.getAttribute(\"height\"),\n styleAttrValue: node.getAttribute(\"style\"),\n classAttrValue: node.getAttribute(\"class\"),\n });\n const getSingleChildElement = (node: HTMLElement) => {\n const childElements = Array.from(node.children) as HTMLElement[];\n\n return childElements.length === 1 ? childElements[0] : null;\n };\n\n const resolveExplicitHeight = () => {\n if (!shouldMeasureDynamicHeight) return null;\n if (!iframeRef.current || !doc.body) return null;\n const parentViewportHeight =\n iframeRef.current.ownerDocument?.documentElement?.clientHeight ||\n window.innerHeight;\n // Reuse parsed height metadata from the current html snapshot first to\n // avoid re-inspecting the same DOM chain on every height tick.\n const precomputedViewportHeightCss = renderViewportHeightCssRef.current;\n const parsed = precomputedViewportHeightCss\n ? parseExplicitHeight(\n precomputedViewportHeightCss,\n parentViewportHeight\n )\n : null;\n\n if (parsed !== null) {\n return Math.ceil(parsed);\n }\n\n const wrapper = doc.body.querySelector(\n \".sandbox-wrapper\"\n ) as HTMLElement | null;\n const container = wrapper?.firstElementChild as HTMLElement | null;\n if (!container) return null;\n const containerChildren = Array.from(container.children) as HTMLElement[];\n const rootContentElement =\n containerChildren.length === 1 ? containerChildren[0] : null;\n const runtimeHeightMeta = inspectViewportHeightFromNodeChain(\n rootContentElement,\n {\n getNode: getHeightInspectionNode,\n getSingleChild: getSingleChildElement,\n }\n );\n const runtimeViewportHeightCss = runtimeHeightMeta.viewportHeightCss;\n\n if (runtimeViewportHeightCss) {\n const runtimeViewportHeight = parseExplicitHeight(\n runtimeViewportHeightCss,\n parentViewportHeight\n );\n\n if (runtimeViewportHeight !== null) {\n return Math.ceil(runtimeViewportHeight);\n }\n }\n\n const explicitPixelHeight = resolveExplicitHeightFromNodeChain(\n rootContentElement,\n parentViewportHeight,\n {\n getNode: getHeightInspectionNode,\n getSingleChild: getSingleChildElement,\n }\n );\n\n return explicitPixelHeight !== null\n ? Math.ceil(explicitPixelHeight)\n : null;\n };\n\n const updateHeight = () => {\n if (!iframeRef.current || !doc.body) return;\n\n if (!isBlackboardMode) {\n // Guard: prevent re-entrant measurement from ResizeObserver /\n // MutationObserver callbacks triggered by our own height changes.\n if (isMeasuringContentRef.current) {\n // Mark that an update was requested while the guard was active.\n // We will retry once the guard releases (see setTimeout below).\n pendingHeightUpdateRef.current = true;\n return;\n }\n isMeasuringContentRef.current = true;\n\n // Content mode height measurement strategy:\n // Temporarily set iframe height to the 16:9 layout viewport so that:\n // 1. vmin units are stable: vmin = min(cw, minH)/100 = minH/100,\n // consistent with the final rendered 16:9 iframe.\n // 2. Viewport-filling content (e.g. inline style=\"height:100vh\")\n // retains its 16:9 viewport. Naturally sized content reserves only\n // its measured body height in the host page.\n // (Previously using cw caused such content to report 1:1 height,\n // overriding the 16:9 minimum.)\n const iframe = iframeRef.current;\n const cw = containerRef.current?.clientWidth || 0;\n const prevH = iframe.style.height;\n\n if (cw > 0) {\n const minH = Math.round((cw * 9) / 16);\n // Absolute height cap. Diverging vh-feedback (multiple `height:100vh`\n // siblings, or compound vh-relative children whose sum exceeds the\n // viewport) can otherwise grow the iframe geometrically across\n // repeated ResizeObserver/MutationObserver passes. 1:20 aspect is\n // a generous upper bound for any single sandbox slide.\n const maxH = Math.max(8192, cw * 20);\n iframe.style.height = minH + \"px\";\n // eslint-disable-next-line @typescript-eslint/no-unused-expressions\n doc.body.offsetHeight; // force layout\n\n let measuredH = doc.body.scrollHeight;\n\n // Detect inner elements that clip overflowing content behind a\n // scrollbar (e.g. <div style=\"height:100vh; overflow-y:auto\"> whose\n // content is taller than the iframe). body.scrollHeight won't see\n // that overflow, so we walk the tree and factor in each scrollable\n // element's full scroll height based on its position in the iframe.\n const iframeWin = doc.defaultView;\n if (iframeWin) {\n // Include fixed-position widgets, which do not contribute to body\n // scrollHeight, as well as content behind internal scrollbars.\n const getInnerScrollableHeight = (root: Element): number => {\n let maxH = 0;\n const walk = (el: Element) => {\n const style = iframeWin.getComputedStyle(el);\n if (style.position === \"fixed\") {\n maxH = Math.max(\n maxH,\n Math.ceil(el.getBoundingClientRect().bottom)\n );\n }\n if (el !== root && el.scrollHeight > el.clientHeight + 1) {\n const oy = style.overflowY;\n if (oy === \"auto\" || oy === \"scroll\") {\n const rect = el.getBoundingClientRect();\n if (rect.top >= 0) {\n maxH = Math.max(\n maxH,\n Math.ceil(rect.top + el.scrollHeight)\n );\n }\n }\n }\n for (const child of el.children) walk(child);\n };\n walk(root);\n return maxH;\n };\n\n measuredH = Math.max(measuredH, getInnerScrollableHeight(doc.body));\n\n // Content that uses vh-relative sizing grows as the viewport\n // expands. Measure up to 8 more times at the expanded height so\n // we capture the full content height in a single updateHeight()\n // call rather than waiting for external re-triggers.\n for (let i = 0; i < 8 && measuredH > minH; i++) {\n iframe.style.height = measuredH + \"px\";\n // eslint-disable-next-line @typescript-eslint/no-unused-expressions\n doc.body.offsetHeight; // force layout at expanded size\n const nextH = Math.max(\n doc.body.scrollHeight,\n getInnerScrollableHeight(doc.body)\n );\n if (nextH <= measuredH + 1) break; // stable — stop iterating\n // Geometric vh-feedback detection: vh-relative children scale\n // with the iframe viewport, so growing the iframe makes them\n // larger which grows scrollHeight — runaway divergence. Two\n // `height:100vh` siblings produce a 2× per-iteration multiplier.\n // Stop iterating; keep the prior (stable) measuredH.\n if (nextH >= measuredH * 1.5) break;\n measuredH = nextH;\n }\n }\n\n // Restore iframe to let React control it via contentModeStyle\n iframe.style.height = prevH;\n\n setContentHeight((prev) => {\n const next = Math.min(maxH, Math.max(1, Math.ceil(measuredH)));\n return prev === next ? prev : next;\n });\n }\n\n setTimeout(() => {\n isMeasuringContentRef.current = false;\n // Retry any update that was blocked while the guard was active\n // (e.g. dynamic content injected by scripts or images loading).\n if (pendingHeightUpdateRef.current) {\n pendingHeightUpdateRef.current = false;\n scheduleHeightUpdate();\n }\n }, 50);\n return;\n }\n\n // Scaling mode: viewport is fixed, content scales via font-size.\n if (shouldEnableScaling) return;\n\n // Blackboard mode: use existing measurement logic\n const bodyScrollH = doc.body.scrollHeight;\n const htmlScrollH = doc.documentElement?.scrollHeight || 0;\n const rootScrollH = rootEl?.scrollHeight || 0;\n const measuredHeight = Math.max(bodyScrollH, htmlScrollH, rootScrollH);\n\n if (shouldMeasureDynamicHeight) {\n const explicitHeight = resolveExplicitHeight();\n const nextHeight = Math.max(\n 200,\n explicitHeight ?? Math.ceil(measuredHeight)\n );\n setHeight((prevHeight) =>\n prevHeight === nextHeight ? prevHeight : nextHeight\n );\n }\n };\n const scheduleHeightUpdate = () => {\n requestAnimationFrame(() => {\n if (isDestroyed) return;\n updateHeight();\n });\n };\n updateHeightRef.current = scheduleHeightUpdate;\n\n updateHeight();\n scheduleHeightUpdate();\n\n if (shouldInjectSandboxVendor) {\n // Inject Tailwind/DaisyUI/GSAP before rendering sandbox content to avoid FOUC.\n loadBlackboardVendor()\n .then(({ injectBlackboardLibraries }) => {\n if (isDestroyed) return;\n injectBlackboardLibraries(doc);\n if (shouldEnableScaling) {\n injectScalingSystem(doc);\n }\n requestAnimationFrame(() => {\n if (isDestroyed) return;\n scheduleHeightUpdate();\n });\n })\n .catch(() => {\n if (isDestroyed) return;\n scheduleHeightUpdate();\n });\n }\n\n const hostElement = containerRef.current;\n let needsTailwindRefreshAfterHidden = Boolean(\n hostElement &&\n (hostElement.clientWidth <= 0 || hostElement.clientHeight <= 0)\n );\n let isTailwindRefreshQueued = false;\n let tailwindRefreshFrame: number | null = null;\n let tailwindRefreshTimer: number | null = null;\n const runPostTailwindRefreshLayout = () => {\n if (isDestroyed) return;\n scheduleHeightUpdate();\n const iframeWin = iframe.contentWindow as ScalingWindow | null;\n iframeWin?.__mdf_triggerFitContent?.();\n };\n const isHostVisible = () =>\n Boolean(\n hostElement &&\n hostElement.clientWidth > 0 &&\n hostElement.clientHeight > 0\n );\n const queueTailwindRefreshAfterHidden = () => {\n if (\n !shouldInjectSandboxVendor ||\n !hostElement ||\n !needsTailwindRefreshAfterHidden ||\n isTailwindRefreshQueued ||\n !isHostVisible()\n ) {\n return;\n }\n\n isTailwindRefreshQueued = true;\n loadBlackboardVendor()\n .then(({ refreshTailwindRuntime }) => {\n if (isDestroyed) return;\n\n tailwindRefreshFrame = window.requestAnimationFrame(() => {\n tailwindRefreshFrame = null;\n isTailwindRefreshQueued = false;\n\n const sandboxContainer = doc.querySelector(\".sandbox-container\");\n if (\n isDestroyed ||\n !isHostVisible() ||\n !sandboxContainer?.childNodes.length ||\n !refreshTailwindRuntime(doc)\n ) {\n return;\n }\n\n needsTailwindRefreshAfterHidden = false;\n runPostTailwindRefreshLayout();\n tailwindRefreshTimer = window.setTimeout(() => {\n tailwindRefreshTimer = null;\n runPostTailwindRefreshLayout();\n }, 100);\n });\n })\n .catch(() => {\n isTailwindRefreshQueued = false;\n });\n };\n const canObserveResize = typeof ResizeObserver !== \"undefined\";\n const hostResizeObserver =\n shouldInjectSandboxVendor && hostElement && canObserveResize\n ? new ResizeObserver((entries) => {\n const contentRect = entries[0]?.contentRect;\n const hostWidth = contentRect?.width ?? hostElement.clientWidth;\n const hostHeight = contentRect?.height ?? hostElement.clientHeight;\n const isHostSizeVisible = hostWidth > 0 && hostHeight > 0;\n\n if (!isHostSizeVisible) {\n return;\n }\n\n queueTailwindRefreshAfterHidden();\n })\n : null;\n if (hostResizeObserver && hostElement) {\n hostResizeObserver.observe(hostElement);\n }\n\n const resizeObserver = canObserveResize\n ? new ResizeObserver(() => updateHeight())\n : null;\n resizeObserver?.observe(doc.body);\n if (rootEl) {\n resizeObserver?.observe(rootEl);\n }\n\n const syncSandboxContentDirection = () => {\n if (type !== \"sandbox\" || requestedDirectionRef.current !== \"auto\") {\n return;\n }\n const wrapper = doc.querySelector<HTMLElement>(\".sandbox-wrapper\");\n const view = doc.defaultView;\n if (!wrapper || !view) return;\n const nextDirection =\n view.getComputedStyle(wrapper).direction === \"rtl\" ? \"rtl\" : \"ltr\";\n setSandboxContentDirection((currentDirection) =>\n currentDirection === nextDirection ? currentDirection : nextDirection\n );\n };\n\n // MutationObserver: detect DOM changes that ResizeObserver might miss\n // (e.g. content injected by scripts, images loading, dynamic rendering)\n const mutationObserver = new MutationObserver(() => {\n syncSandboxContentDirection();\n scheduleHeightUpdate();\n if (!isHostVisible()) {\n needsTailwindRefreshAfterHidden = true;\n return;\n }\n queueTailwindRefreshAfterHidden();\n });\n mutationObserver.observe(doc.body, {\n childList: true,\n characterData: true,\n subtree: true,\n attributes: true,\n attributeFilter: [\"style\", \"class\", \"dir\"],\n });\n\n return () => {\n isDestroyed = true;\n hostResizeObserver?.disconnect();\n resizeObserver?.disconnect();\n mutationObserver.disconnect();\n if (tailwindRefreshFrame !== null) {\n window.cancelAnimationFrame(tailwindRefreshFrame);\n }\n if (tailwindRefreshTimer !== null) {\n window.clearTimeout(tailwindRefreshTimer);\n }\n if (shouldEnableScaling) {\n const iframeWin = iframe.contentWindow as ScalingWindow | null;\n iframeWin?.__mdf_cleanupScaling?.();\n }\n if (shouldBridgeSandboxInteraction) {\n doc.removeEventListener(\"click\", handleSandboxClick, true);\n }\n if (rootRef.current === root) {\n rootRef.current = null;\n updateHeightRef.current = () => {};\n }\n // Defer unmount to avoid React warning when parent is mid-render\n setTimeout(() => {\n root.unmount();\n }, 0);\n };\n }, []);\n\n useEffect(() => {\n const onFullscreenChange = () => {\n setIsFullscreen(Boolean(document.fullscreenElement));\n };\n document.addEventListener(\"fullscreenchange\", onFullscreenChange);\n return () =>\n document.removeEventListener(\"fullscreenchange\", onFullscreenChange);\n }, []);\n\n // Track the layout viewport width and enough host space for its own control.\n useEffect(() => {\n const el = containerRef.current;\n if (!el) return;\n const button = fullscreenButtonRef.current;\n const updateControlHeight = () => {\n setFullscreenControlHeight(\n button ? Math.ceil(button.offsetTop + button.offsetHeight) : 0\n );\n };\n if (typeof ResizeObserver === \"undefined\") {\n setContainerWidth(el.clientWidth);\n updateControlHeight();\n return;\n }\n const ro = new ResizeObserver((entries) => {\n const hostEntry = entries.find((entry) => entry.target === el);\n if (hostEntry) setContainerWidth(hostEntry.contentRect.width);\n updateControlHeight();\n });\n ro.observe(el);\n if (button) ro.observe(button);\n setContainerWidth(el.clientWidth);\n updateControlHeight();\n return () => ro.disconnect();\n }, [hideFullScreen]);\n\n // Keep a stable layout viewport for authored vh/vmin sizing, while the host\n // reserves only the measured content height. The iframe is top-aligned inside\n // the clipped host so a short card does not leave a slide-sized blank area.\n const contentModeStyle = useMemo<React.CSSProperties | undefined>(() => {\n if (isBlackboardMode || containerWidth === 0 || isFullscreen)\n return undefined;\n const minH = Math.round((containerWidth * 9) / 16);\n return { height: Math.max(contentHeight ?? minH, fullscreenControlHeight) };\n }, [\n isBlackboardMode,\n containerWidth,\n contentHeight,\n isFullscreen,\n fullscreenControlHeight,\n ]);\n\n const contentIframeHeight = contentModeStyle\n ? Math.max(Math.round((containerWidth * 9) / 16), contentHeight ?? 0)\n : undefined;\n\n const toggleFullscreen = () => {\n const target = containerRef.current || iframeRef.current;\n if (!target) return;\n if (document.fullscreenElement) {\n document.exitFullscreen().catch(() => {});\n return;\n }\n if (target.requestFullscreen) {\n target.requestFullscreen().catch(() => {});\n }\n };\n\n useEffect(() => {\n const root = rootRef.current;\n if (!root) return;\n\n root.render(\n <SandboxApp\n html={renderHtmlContent}\n locale={locale}\n dir={sandboxDirection}\n lang={sandboxLanguage}\n loadingText={loadingText}\n styleLoadingText={styleLoadingText}\n scriptLoadingText={scriptLoadingText}\n disableLoadingOverlay={disableLoadingOverlay}\n resetToken={resetToken}\n hasRootVhHeight={hasRootVhHeight}\n mode={mode}\n stretchRootHeight={shouldStretchRootHeight}\n enableScaling={shouldEnableScaling}\n />\n );\n\n // Schedule multiple measurements to catch async content (scripts, images, styles).\n initialPaintFrameRef.current = window.requestAnimationFrame(() => {\n updateHeightRef.current?.();\n if (shouldEnableScaling) {\n const iframeWin = iframeRef.current\n ?.contentWindow as ScalingWindow | null;\n iframeWin?.__mdf_triggerFitContent?.();\n }\n initialPaintFrameRef.current = null;\n });\n const t1 = setTimeout(() => updateHeightRef.current?.(), 100);\n const t2 = setTimeout(() => updateHeightRef.current?.(), 500);\n return () => {\n if (initialPaintFrameRef.current !== null) {\n window.cancelAnimationFrame(initialPaintFrameRef.current);\n initialPaintFrameRef.current = null;\n }\n clearTimeout(t1);\n clearTimeout(t2);\n };\n }, [\n renderHtmlContent,\n locale,\n sandboxDirection,\n sandboxLanguage,\n loadingText,\n styleLoadingText,\n scriptLoadingText,\n resetToken,\n disableLoadingOverlay,\n hasRootVhHeight,\n mode,\n shouldStretchRootHeight,\n shouldEnableScaling,\n ]);\n const containerClassName = [\n `w-full relative content-render-iframe-sandbox content-render-iframe-sandbox--${type}`,\n isBlackboardMode\n ? \"h-full overflow-auto flex flex-col\"\n : contentModeStyle\n ? \"overflow-hidden\"\n : \"aspect-[16/9] overflow-hidden flex items-center justify-center\",\n ]\n .filter(Boolean)\n .join(\" \");\n\n return (\n <div\n ref={containerRef}\n dir={direction}\n lang={language}\n data-root-vh={hasRootVhHeight ? \"true\" : \"false\"}\n className={containerClassName}\n style={\n sandboxViewportHeight\n ? {\n height: sandboxViewportHeight,\n minHeight: sandboxViewportHeight,\n }\n : contentModeStyle\n }\n >\n {!hideFullScreen && (\n <button\n ref={fullscreenButtonRef}\n type=\"button\"\n dir={fullscreenControlDirection}\n onClick={toggleFullscreen}\n className={\n \"absolute top-2 end-2 z-50 p-1.5 bg-black/75 text-white rounded-md cursor-pointer\"\n }\n >\n {isFullscreen\n ? resolvedExitFullScreenButtonText\n : resolvedFullScreenButtonText}\n </button>\n )}\n {mode === \"blackboard\" && type === \"markdown\" ? (\n <div ref={setMarkdownContentContainerRef}>\n <ContentRender\n content={content}\n locale={locale}\n dir={direction}\n lang={language}\n disableSandboxLoadingOverlay={disableLoadingOverlay}\n />\n </div>\n ) : (\n <iframe\n ref={iframeRef}\n sandbox=\"allow-scripts allow-same-origin allow-popups allow-popups-to-escape-sandbox\"\n allow=\"fullscreen\"\n allowFullScreen\n className={[className, \"w-full h-full mx-auto my-auto block\"]\n .filter(Boolean)\n .join(\" \")}\n style={{\n height: sandboxViewportHeight ?? contentIframeHeight ?? \"100%\",\n minHeight: sandboxViewportHeight,\n margin: \"auto\",\n }}\n />\n )}\n </div>\n );\n};\n\nconst IframeSandbox: React.FC<IframeSandboxProps> = (props) => {\n const mode = props.mode ?? \"content\";\n const shouldEnableScaling = Boolean(\n props.enableScaling && mode === \"blackboard\" && props.type === \"sandbox\"\n );\n // The iframe shell captures these initialization-only values. Remounting the\n // inner instance keeps old and new React roots from sharing cleanup refs.\n const lifecycleKey = `${props.type}:${mode}:${shouldEnableScaling ? \"scaled\" : \"unscaled\"}`;\n\n return <IframeSandboxInstance key={lifecycleKey} {...props} />;\n};\n\nexport default IframeSandbox;\n"],"names":["blackboardVendorPromise","loadBlackboardVendor","COMPLETE_IMAGE_TAG_PATTERN","POST_IMAGE_STREAM_DEBOUNCE_MS","SANDBOX_INTERACTION_THROTTLE_MS","replaceRootScreenHeightToken","className","token","segments","replaceRootScreenHeightWithFullClass","html","enabled","match","tagStart","attrs","classMatch","nextClassName","IframeSandboxInstance","content","type","locale","lang","dir","loadingText","styleLoadingText","scriptLoadingText","fullScreenButtonText","exitFullScreenButtonText","hideFullScreen","mode","replaceRootScreenHeightWithFull","enableScaling","disableLoadingOverlay","localeTexts","getContentRenderLocaleTexts","direction","getMarkdownFlowDirection","language","getMarkdownFlowLanguage","resolvedFullScreenButtonText","resolvedExitFullScreenButtonText","containerRef","useRef","fullscreenButtonRef","sandboxLanguage","useDetachedLanguage","resolvedDirection","useResolvedDirection","markdownContainerRef","markdownContentRef","setMarkdownContentContainerRef","useCallback","node","markdownContentDirection","sandboxDirection","requestedDirectionRef","sandboxContentDirection","setSandboxContentDirection","useState","fullscreenControlDirection","iframeRef","rootRef","updateHeightRef","height","setHeight","contentHeight","setContentHeight","containerWidth","setContainerWidth","fullscreenControlHeight","setFullscreenControlHeight","isMeasuringContentRef","pendingHeightUpdateRef","lastSandboxInteractionTimeRef","resetToken","setResetToken","isFullscreen","setIsFullscreen","shouldInjectSandboxVendor","isBlackboardMode","shouldEnableScaling","shouldMeasureDynamicHeight","shouldProcessRootScreenHeight","prevHtmlRef","htmlContent","React","normalizedHtmlContent","originalRootHeightMeta","inspectViewportHeightFromHtmlRootString","EMPTY_ROOT_HEIGHT_META","shouldStretchRootHeight","renderHtmlContent","setRenderHtmlContent","prevIncomingHtmlRef","pendingHtmlRef","deferRenderTimerRef","initialPaintFrameRef","renderViewportHeightCssRef","emitSandboxInteraction","eventType","now","SANDBOX_INTERACTION_MESSAGE_SOURCE","SANDBOX_INTERACTION_MESSAGE_TYPE","useEffect","container","handleClick","clearDeferredRenderTimer","clearInitialPaintFrames","prevIncomingHtml","isAppendOnlyStream","containsCompleteImage","rootViewportHeightCss","hasRootVhHeight","sandboxViewportHeight","prev","iframe","doc","CJK_SAFE_SANS_FONT_FAMILY","shouldBridgeSandboxInteraction","handleSandboxClick","rootEl","root","createRoot","isDestroyed","getHeightInspectionNode","getSingleChildElement","childElements","resolveExplicitHeight","parentViewportHeight","precomputedViewportHeightCss","parsed","parseExplicitHeight","containerChildren","rootContentElement","runtimeViewportHeightCss","inspectViewportHeightFromNodeChain","runtimeViewportHeight","explicitPixelHeight","resolveExplicitHeightFromNodeChain","updateHeight","cw","prevH","minH","maxH","measuredH","iframeWin","getInnerScrollableHeight","walk","el","style","oy","rect","child","i","nextH","next","scheduleHeightUpdate","bodyScrollH","htmlScrollH","rootScrollH","measuredHeight","explicitHeight","nextHeight","prevHeight","injectBlackboardLibraries","injectScalingSystem","hostElement","needsTailwindRefreshAfterHidden","isTailwindRefreshQueued","tailwindRefreshFrame","tailwindRefreshTimer","runPostTailwindRefreshLayout","isHostVisible","queueTailwindRefreshAfterHidden","refreshTailwindRuntime","sandboxContainer","canObserveResize","hostResizeObserver","entries","contentRect","hostWidth","hostHeight","resizeObserver","syncSandboxContentDirection","wrapper","view","nextDirection","currentDirection","mutationObserver","onFullscreenChange","button","updateControlHeight","ro","hostEntry","entry","contentModeStyle","useMemo","contentIframeHeight","toggleFullscreen","target","jsx","SandboxApp","t1","t2","containerClassName","jsxs","ContentRender","IframeSandbox","props","lifecycleKey"],"mappings":"wlBAsCA,IAAIA,GAAkE,KAEtE,MAAMC,GAAuB,KACtBD,KACHA,GAA0B,QAAA,QAAA,EAAA,KAAA,IAAA,QAAO,yBAAqB,CAAA,GAGjDA,IAGHE,GAA6B,gBAC7BC,GAAgC,IAChCC,GAAkC,IAuBlCC,GAAgCC,GACpCA,EACG,MAAM,KAAK,EACX,OAAO,OAAO,EACd,IAAKC,GAAU,CACd,MAAMC,EAAWD,EAAM,MAAM,GAAG,EAChC,OACEC,EAASA,EAAS,OAAS,CAAC,IAAM,YAClCA,EAASA,EAAS,OAAS,CAAC,IAAM,eAE3BD,GAETC,EAASA,EAAS,OAAS,CAAC,EAAI,SACzBA,EAAS,KAAK,GAAG,EAC1B,CAAC,EACA,KAAK,GAAG,EAEPC,GAAuC,CAC3CC,EACAC,IAEI,CAACA,GAAW,CAACD,EAAK,OACbA,EAGFA,EAAK,QACV,qCACA,CAACE,EAAOC,EAAkBC,EAAQ,KAAO,CACvC,MAAMC,EAAaD,EAAM,MAAM,iCAAiC,EAEhE,GAAI,CAACC,EACH,OAAOH,EAGT,MAAMI,EAAgBX,GAA6BU,EAAW,CAAC,CAAC,EAEhE,OAAIC,IAAkBD,EAAW,CAAC,EACzBH,EAGF,GAAGC,CAAQ,GAAGC,EAAM,QACzBC,EAAW,CAAC,EACZ,SAASA,EAAW,CAAC,CAAC,GAAGC,CAAa,GAAGD,EAAW,CAAC,CAAC,EAAA,CACvD,GACH,CAAA,EAIEE,GAAsD,CAAC,CAC3D,QAAAC,EACA,KAAAC,EACA,UAAAb,EAAA,OACAc,EACA,KAAAC,EACA,IAAAC,EACA,YAAAC,EACA,iBAAAC,GACA,kBAAAC,GACA,qBAAAC,GACA,yBAAAC,GACA,eAAAC,GAAiB,GACjB,KAAAC,EAAO,UACP,gCAAAC,GAAkC,GAClC,cAAAC,G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