markdown-flow-ui 0.1.99 → 0.1.100-beta.0

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.
Files changed (83) hide show
  1. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/ellipsis-vertical.cjs.js +7 -0
  2. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/ellipsis-vertical.cjs.js.map +1 -0
  3. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/ellipsis-vertical.es.js +17 -0
  4. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/ellipsis-vertical.es.js.map +1 -0
  5. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/file-pen-line.cjs.js +7 -0
  6. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/file-pen-line.cjs.js.map +1 -0
  7. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/file-pen-line.es.js +29 -0
  8. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/file-pen-line.es.js.map +1 -0
  9. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/maximize.cjs.js +7 -0
  10. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/maximize.cjs.js.map +1 -0
  11. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/maximize.es.js +18 -0
  12. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/maximize.es.js.map +1 -0
  13. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/rotate-ccw.cjs.js +7 -0
  14. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/rotate-ccw.cjs.js.map +1 -0
  15. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/rotate-ccw.es.js +16 -0
  16. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/rotate-ccw.es.js.map +1 -0
  17. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/rotate-cw.cjs.js +7 -0
  18. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/rotate-cw.cjs.js.map +1 -0
  19. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/rotate-cw.es.js +16 -0
  20. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/rotate-cw.es.js.map +1 -0
  21. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/volume-2.cjs.js +7 -0
  22. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/volume-2.cjs.js.map +1 -0
  23. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/volume-2.es.js +23 -0
  24. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/volume-2.es.js.map +1 -0
  25. package/dist/_virtual/index.cjs.js +1 -1
  26. package/dist/_virtual/index.es.js +1 -0
  27. package/dist/assets/markdown-flow-ui.css +1 -1
  28. package/dist/components/ContentRender/IframeSandbox.cjs.js +3 -3
  29. package/dist/components/ContentRender/IframeSandbox.cjs.js.map +1 -1
  30. package/dist/components/ContentRender/IframeSandbox.es.js +212 -164
  31. package/dist/components/ContentRender/IframeSandbox.es.js.map +1 -1
  32. package/dist/components/ContentRender/SandboxApp.cjs.js +2 -2
  33. package/dist/components/ContentRender/SandboxApp.cjs.js.map +1 -1
  34. package/dist/components/ContentRender/SandboxApp.es.js +21 -21
  35. package/dist/components/ContentRender/SandboxApp.es.js.map +1 -1
  36. package/dist/components/ContentRender/index.cjs.js +1 -1
  37. package/dist/components/ContentRender/index.es.js +6 -5
  38. package/dist/components/MarkdownFlow/MarkdownFlow.cjs.js +1 -1
  39. package/dist/components/MarkdownFlow/MarkdownFlow.cjs.js.map +1 -1
  40. package/dist/components/MarkdownFlow/MarkdownFlow.es.js +2 -2
  41. package/dist/components/Slide/Player.cjs.js +2 -0
  42. package/dist/components/Slide/Player.cjs.js.map +1 -0
  43. package/dist/components/Slide/Player.d.ts +19 -0
  44. package/dist/components/Slide/Player.es.js +327 -0
  45. package/dist/components/Slide/Player.es.js.map +1 -0
  46. package/dist/components/Slide/Slide.cjs.js +2 -0
  47. package/dist/components/Slide/Slide.cjs.js.map +1 -0
  48. package/dist/components/Slide/Slide.d.ts +12 -0
  49. package/dist/components/Slide/Slide.es.js +394 -0
  50. package/dist/components/Slide/Slide.es.js.map +1 -0
  51. package/dist/components/Slide/Slide.stories.d.ts +47 -0
  52. package/dist/components/Slide/diff-utils.cjs.js +5 -0
  53. package/dist/components/Slide/diff-utils.cjs.js.map +1 -0
  54. package/dist/components/Slide/diff-utils.d.ts +18 -0
  55. package/dist/components/Slide/diff-utils.es.js +113 -0
  56. package/dist/components/Slide/diff-utils.es.js.map +1 -0
  57. package/dist/components/Slide/index.d.ts +12 -0
  58. package/dist/components/Slide/interaction-defaults.cjs.js +2 -0
  59. package/dist/components/Slide/interaction-defaults.cjs.js.map +1 -0
  60. package/dist/components/Slide/interaction-defaults.d.ts +23 -0
  61. package/dist/components/Slide/interaction-defaults.es.js +85 -0
  62. package/dist/components/Slide/interaction-defaults.es.js.map +1 -0
  63. package/dist/components/Slide/types.d.ts +24 -0
  64. package/dist/components/Slide/useSlide.cjs.js +2 -0
  65. package/dist/components/Slide/useSlide.cjs.js.map +1 -0
  66. package/dist/components/Slide/useSlide.d.ts +21 -0
  67. package/dist/components/Slide/useSlide.es.js +102 -0
  68. package/dist/components/Slide/useSlide.es.js.map +1 -0
  69. package/dist/components/index.d.ts +5 -0
  70. package/dist/index.cjs.js +1 -1
  71. package/dist/index.es.js +21 -9
  72. package/dist/index.es.js.map +1 -1
  73. package/dist/lib/browserUserActivation.cjs.js +2 -0
  74. package/dist/lib/browserUserActivation.cjs.js.map +1 -0
  75. package/dist/lib/browserUserActivation.d.ts +5 -0
  76. package/dist/lib/browserUserActivation.es.js +13 -0
  77. package/dist/lib/browserUserActivation.es.js.map +1 -0
  78. package/dist/markdown-flow-ui-lib.css +1 -1
  79. package/dist/renderer.cjs.js +1 -1
  80. package/dist/renderer.d.ts +3 -2
  81. package/dist/renderer.es.js +20 -8
  82. package/dist/renderer.es.js.map +1 -1
  83. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const C=require("../../_virtual/jsx-runtime.cjs.js"),n=require("react"),te=require("react-dom/client"),ne=require("./SandboxApp.cjs.js"),re=require("./utils/split-content.cjs.js"),se=require("./ContentRender.cjs.js"),oe=()=>Promise.resolve().then(()=>require("./blackboard-vendor.cjs.js")).then(l=>l.injectBlackboardLibraries),ie=/<img\b[^>]*>/i,le=180,U=l=>l.split(/\s+/).filter(Boolean).map(s=>s.split(":").pop()||s),G=l=>{const s=l.trim().toLowerCase();if(!s)return null;const f=s.match(/^([0-9.]+)(vh|dvh|svh|lvh)$/i);return f?`${f[1]}${f[2].toLowerCase()}`:null},W=l=>{if(!l.trim())return null;const s=U(l);if(s.includes("h-screen")||s.includes("h-dvh"))return"100dvh";if(s.includes("h-svh"))return"100svh";if(s.includes("h-lvh"))return"100lvh";const f=s.find(H=>/^h-\[[0-9.]+(vh|dvh|svh|lvh)\]$/i.test(H));if(!f)return null;const v=f.match(/^h-\[([0-9.]+)(vh|dvh|svh|lvh)\]$/i);return v?`${v[1]}${v[2].toLowerCase()}`:null},ce=({content:l,type:s,className:f,loadingText:v,styleLoadingText:H,scriptLoadingText:B,fullScreenButtonText:j,hideFullScreen:_=!1,mode:h="content"})=>{const D=n.useRef(null),w=n.useRef(null),A=n.useRef(null),I=n.useRef(null),S=n.useRef(()=>{}),[,Y]=n.useState(480),[O,Z]=n.useState(0),[J,K]=n.useState(!1),Q=h==="blackboard",q=n.useRef(""),r=n.useMemo(()=>{const t=re.splitContentSegments(l).filter(c=>c.type==="sandbox");return(h==="blackboard"?t[t.length-1]?.value||"":t.map(c=>c.value).join(`
2
- `))||""},[l,h]),[E,V]=n.useState(r),L=n.useRef(r),z=n.useRef(r),R=n.useRef(null),F=()=>{R.current!==null&&(window.clearTimeout(R.current),R.current=null)};n.useEffect(()=>()=>{F()},[]),n.useEffect(()=>{const e=L.current;L.current=r;const t=!!e&&r.length>e.length&&r.startsWith(e),o=ie.test(r);if(!(t&&o)){F(),z.current=r,V(r);return}z.current=r,F(),R.current=window.setTimeout(()=>{V(z.current),R.current=null},le)},[r]);const P=!!n.useMemo(()=>{const e=E.trim();if(!e)return null;const t=e.match(/^<([a-zA-Z][\w:-]*)(\s[^>]*?)?>/);if(!t)return null;const o=t[2]||"",c=o.match(/\bheight\s*=\s*["']([^"']+)["']/i);if(c){const m=G(c[1]);if(m)return m}const y=o.match(/\bstyle\s*=\s*["']([^"']+)["']/i)?.[1]?.match(/\bheight\s*:\s*([^;]+)/i)?.[1];if(y){const m=G(y);if(m)return m}const M=o.match(/\bclass\s*=\s*["']([^"']+)["']/i)?.[1];return M?W(M):null},[E]);n.useEffect(()=>{if(h!=="blackboard"){q.current=r;return}const e=q.current;!(e&&r.startsWith(e))&&e&&Z(o=>o+1),q.current=r},[r,h]),n.useEffect(()=>{const e=w.current;if(!e)return;const t=e.contentDocument;if(!t)return;t.open(),t.write(`<!DOCTYPE html>
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d=require("../../_virtual/jsx-runtime.cjs.js"),n=require("react"),pe=require("react-dom/client"),ge=require("./SandboxApp.cjs.js"),xe=require("./utils/split-content.cjs.js"),ve=require("./ContentRender.cjs.js"),we=require("../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/loader-circle.cjs.js");let V=null;const se=()=>(V||(V=Promise.resolve().then(()=>require("./blackboard-vendor.cjs.js")).then(i=>i.injectBlackboardLibraries)),V);typeof window<"u"&&se();const Re=/<img\b[^>]*>/i,Ee=180,ye="markdown-flow-ui:sandbox",Ce="interaction",Se=240,ie=i=>i.split(/\s+/).filter(Boolean).map(r=>r.split(":").pop()||r),re=i=>{const r=i.trim().toLowerCase();if(!r)return null;const f=r.match(/^([0-9.]+)(vh|dvh|svh|lvh)$/i);return f?`${f[1]}${f[2].toLowerCase()}`:null},oe=i=>{if(!i.trim())return null;const r=ie(i);if(r.includes("h-screen")||r.includes("h-dvh"))return"100dvh";if(r.includes("h-svh"))return"100svh";if(r.includes("h-lvh"))return"100lvh";const f=r.find(T=>/^h-\[[0-9.]+(vh|dvh|svh|lvh)\]$/i.test(T));if(!f)return null;const p=f.match(/^h-\[([0-9.]+)(vh|dvh|svh|lvh)\]$/i);return p?`${p[1]}${p[2].toLowerCase()}`:null},He=({content:i,type:r,className:f,loadingText:p,styleLoadingText:T,scriptLoadingText:P,fullScreenButtonText:k,hideFullScreen:G=!1,mode:h="content"})=>{const U=n.useRef(null),R=n.useRef(null),N=n.useRef(null),W=n.useRef(null),I=n.useRef(()=>{}),[le,ce]=n.useState(480),X=n.useRef(0),[Y,ue]=n.useState(0),[ae,de]=n.useState(!1),[_,D]=n.useState(r!=="sandbox"),O=h==="blackboard",q=n.useRef(""),o=n.useMemo(()=>{const e=xe.splitContentSegments(i).filter(c=>c.type==="sandbox");return(h==="blackboard"?e[e.length-1]?.value||"":e.map(c=>c.value).join(`
2
+ `))||""},[i,h]),[j,Z]=n.useState(o),J=n.useRef(o),B=n.useRef(o),y=n.useRef(null),E=n.useCallback(t=>{if(typeof window>"u")return;const e=Date.now();e-X.current<Se||(X.current=e,window.postMessage({source:ye,type:Ce,eventType:t},window.location.origin))},[]),F=()=>{y.current!==null&&(window.clearTimeout(y.current),y.current=null)};n.useEffect(()=>()=>{F()},[]),n.useEffect(()=>{const t=J.current;J.current=o;const e=!!t&&o.length>t.length&&o.startsWith(t),l=Re.test(o);if(!(e&&l)){F(),B.current=o,Z(o);return}B.current=o,F(),y.current=window.setTimeout(()=>{Z(B.current),y.current=null},Ee)},[o]);const K=n.useMemo(()=>{const t=j.trim();if(!t)return null;const e=t.match(/^<([a-zA-Z][\w:-]*)(\s[^>]*?)?>/);if(!e)return null;const l=e[2]||"",c=l.match(/\bheight\s*=\s*["']([^"']+)["']/i);if(c){const m=re(c[1]);if(m)return m}const S=l.match(/\bstyle\s*=\s*["']([^"']+)["']/i)?.[1]?.match(/\bheight\s*:\s*([^;]+)/i)?.[1];if(S){const m=re(S);if(m)return m}const g=l.match(/\bclass\s*=\s*["']([^"']+)["']/i)?.[1];return g?oe(g):null},[j]),Q=!!K,ee=r==="sandbox",C=O&&r==="sandbox"?K??`${le}px`:void 0;n.useEffect(()=>{if(h!=="blackboard"){q.current=o;return}const t=q.current;!(t&&o.startsWith(t))&&t&&ue(l=>l+1),q.current=o},[o,h]),n.useEffect(()=>{const t=R.current;if(!t)return;const e=t.contentDocument;if(!e)return;e.open(),e.write(`<!DOCTYPE html>
3
3
  <html${h==="blackboard"?' style="height: 100%;"':""}>
4
4
  <head>
5
5
  <meta charset="utf-8" />
@@ -13,5 +13,5 @@
13
13
  <body>
14
14
  <div id="root"></div>
15
15
  </body>
16
- </html>`),t.close(),I.current=t;const o=t.getElementById("root");if(!o)return;const c=te.createRoot(o);A.current=c;let x=!1;const y=(u,d)=>{const i=u.trim().toLowerCase();if(!i)return null;const a=Number.parseFloat(i);return Number.isNaN(a)?null:/(dvh|svh|lvh|vh)$/i.test(i)?a/100*d:i.endsWith("px")||/^[0-9.]+$/.test(i)?a:null},M=(u,d)=>{if(!u.trim())return null;const i=W(u);if(i)return y(i,d);const g=U(u).find(T=>/^h-\[[0-9.]+px\]$/i.test(T));if(!g)return null;const p=g.match(/^h-\[([0-9.]+)px\]$/i);if(!p)return null;const b=Number.parseFloat(p[1]);return Number.isNaN(b)?null:b},m=()=>{if(!w.current||!t.body)return null;const d=t.body.querySelector(".sandbox-wrapper")?.firstElementChild;if(!d)return null;const i=Array.from(d.children);if(i.length!==1)return null;const a=i[0],g=a.style.height||a.getAttribute("height"),p=w.current.ownerDocument?.documentElement?.clientHeight||window.innerHeight,b=g?y(g,p):null;if(b!==null)return Math.ceil(b);const T=M(a.getAttribute("class")||"",p);return T!==null?Math.ceil(T):null},$=()=>{if(!w.current||!t.body)return;const u=t.body.getBoundingClientRect(),d=t.documentElement?.getBoundingClientRect(),i=u.height,a=d?.height||0,g=Math.max(i,a),p=m(),b=Math.max(200,p??Math.ceil(g));Y(b)},k=()=>{requestAnimationFrame(()=>{x||$()})};S.current=k,$(),k(),oe().then(u=>{x||(u(t),k())}).catch(()=>{x||k()});const N=new ResizeObserver(()=>$());return N.observe(t.body),o&&N.observe(o),()=>{x=!0,N.disconnect(),setTimeout(()=>{c.unmount(),A.current=null,I.current=null,S.current=()=>{}},0)}},[]),n.useEffect(()=>{const e=()=>{K(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",e),()=>document.removeEventListener("fullscreenchange",e)},[]);const X=()=>{const e=D.current||w.current;if(e){if(document.fullscreenElement){document.exitFullscreen().catch(()=>{});return}e.requestFullscreen&&e.requestFullscreen().catch(()=>{})}};n.useEffect(()=>{const e=A.current;e&&(e.render(C.jsxRuntimeExports.jsx(ne.default,{html:E,loadingText:v,styleLoadingText:H,scriptLoadingText:B,fullScreenButtonText:j,hideFullScreen:_,resetToken:O,hasRootVhHeight:P,mode:h})),requestAnimationFrame(()=>S.current?.()))},[E,v,H,B,j,O,h]);const ee=["w-full relative content-render-iframe-sandbox",Q?"h-full overflow-auto flex flex-col":"aspect-[16/9] overflow-hidden flex items-center justify-center"].filter(Boolean).join(" ");return C.jsxRuntimeExports.jsxs("div",{ref:D,"data-root-vh":P?"true":"false",className:ee,children:[!_&&C.jsxRuntimeExports.jsx("button",{type:"button",onClick:X,className:"absolute top-2 right-2 z-50 p-1.5 bg-black/75 text-white rounded-md cursor-pointer",children:J?"退出全屏":j||"全屏浏览"}),h==="blackboard"&&s==="markdown"?C.jsxRuntimeExports.jsx(se.default,{content:l}):C.jsxRuntimeExports.jsx("iframe",{ref:w,sandbox:"allow-scripts allow-same-origin allow-popups allow-popups-to-escape-sandbox",allow:"fullscreen",allowFullScreen:!0,className:[f,"w-full h-full mx-auto my-auto block"].filter(Boolean).join(" "),style:{height:"100%",margin:"auto"}})]})};exports.default=ce;
16
+ </html>`),e.close(),W.current=e;const l=O&&r==="sandbox",c=()=>E("pointerdown"),L=()=>E("mousedown"),S=()=>E("touchstart");l&&(e.addEventListener("pointerdown",c,!0),e.addEventListener("mousedown",L,!0),e.addEventListener("touchstart",S,!0));const g=e.getElementById("root");if(!g)return;const m=pe.createRoot(g);N.current=m;let H=!1;const ne=(u,b)=>{const s=u.trim().toLowerCase();if(!s)return null;const a=Number.parseFloat(s);return Number.isNaN(a)?null:/(dvh|svh|lvh|vh)$/i.test(s)?a/100*b:s.endsWith("px")||/^[0-9.]+$/.test(s)?a:null},me=(u,b)=>{if(!u.trim())return null;const s=oe(u);if(s)return ne(s,b);const x=ie(u).find(A=>/^h-\[[0-9.]+px\]$/i.test(A));if(!x)return null;const v=x.match(/^h-\[([0-9.]+)px\]$/i);if(!v)return null;const w=Number.parseFloat(v[1]);return Number.isNaN(w)?null:w},be=()=>{if(!R.current||!e.body)return null;const b=e.body.querySelector(".sandbox-wrapper")?.firstElementChild;if(!b)return null;const s=Array.from(b.children);if(s.length!==1)return null;const a=s[0],x=a.style.height||a.getAttribute("height"),v=R.current.ownerDocument?.documentElement?.clientHeight||window.innerHeight,w=x?ne(x,v):null;if(w!==null)return Math.ceil(w);const A=me(a.getAttribute("class")||"",v);return A!==null?Math.ceil(A):null},z=()=>{if(!R.current||!e.body)return;const u=e.body.getBoundingClientRect(),b=e.documentElement?.getBoundingClientRect(),s=u.height,a=b?.height||0,x=Math.max(s,a),v=be(),w=Math.max(200,v??Math.ceil(x));ce(w)},M=()=>{requestAnimationFrame(()=>{H||z()})};I.current=M,z(),M(),ee?se().then(u=>{H||(u(e),requestAnimationFrame(()=>{H||(D(!0),M())}))}).catch(()=>{H||(D(!0),M())}):D(!0);const $=new ResizeObserver(()=>z());return $.observe(e.body),g&&$.observe(g),()=>{H=!0,$.disconnect(),l&&(e.removeEventListener("pointerdown",c,!0),e.removeEventListener("mousedown",L,!0),e.removeEventListener("touchstart",S,!0)),setTimeout(()=>{m.unmount(),N.current=null,W.current=null,I.current=()=>{}},0)}},[]),n.useEffect(()=>{const t=()=>{de(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",t),()=>document.removeEventListener("fullscreenchange",t)},[]);const he=()=>{const t=U.current||R.current;if(t){if(document.fullscreenElement){document.exitFullscreen().catch(()=>{});return}t.requestFullscreen&&t.requestFullscreen().catch(()=>{})}};n.useEffect(()=>{const t=N.current;!t||!_||(t.render(d.jsxRuntimeExports.jsx(ge.default,{html:j,loadingText:p,styleLoadingText:T,scriptLoadingText:P,fullScreenButtonText:k,hideFullScreen:G,resetToken:Y,hasRootVhHeight:Q,mode:h})),requestAnimationFrame(()=>I.current?.()))},[j,p,T,P,k,Y,h,_]);const fe=["w-full relative content-render-iframe-sandbox",O?"h-full overflow-auto flex flex-col":"aspect-[16/9] overflow-hidden flex items-center justify-center"].filter(Boolean).join(" "),te=ee&&!_;return d.jsxRuntimeExports.jsxs("div",{ref:U,"data-root-vh":Q?"true":"false",className:fe,style:C?{height:C,minHeight:C}:void 0,children:[!G&&d.jsxRuntimeExports.jsx("button",{type:"button",onClick:he,className:"absolute top-2 right-2 z-50 p-1.5 bg-black/75 text-white rounded-md cursor-pointer",children:ae?"退出全屏":k||"全屏浏览"}),h==="blackboard"&&r==="markdown"?d.jsxRuntimeExports.jsx("div",{onMouseDown:()=>E("mousedown"),onPointerDown:()=>E("pointerdown"),onTouchStart:()=>E("touchstart"),children:d.jsxRuntimeExports.jsx(ve.default,{content:i})}):d.jsxRuntimeExports.jsxs(d.jsxRuntimeExports.Fragment,{children:[d.jsxRuntimeExports.jsx("iframe",{ref:R,sandbox:"allow-scripts allow-same-origin allow-popups allow-popups-to-escape-sandbox",allow:"fullscreen",allowFullScreen:!0,className:[f,"w-full h-full mx-auto my-auto block"].filter(Boolean).join(" "),style:{height:C??"100%",minHeight:C,margin:"auto",visibility:te?"hidden":"visible"}}),te?d.jsxRuntimeExports.jsx("div",{className:"pointer-events-none absolute inset-0 z-20 flex items-center justify-center",children:d.jsxRuntimeExports.jsx(we.default,{"aria-label":p||"Preparing sandbox styles",className:"text-primary h-7 w-7 animate-spin"})}):null]})]})};exports.default=He;
17
17
  //# sourceMappingURL=IframeSandbox.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"IframeSandbox.cjs.js","sources":["../../../src/components/ContentRender/IframeSandbox.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from \"react\";\nimport { createRoot, Root } from \"react-dom/client\";\nimport SandboxApp from \"./SandboxApp\";\nimport { splitContentSegments } from \"./utils/split-content\";\nimport ContentRender from \"./ContentRender\";\n// Lazy-load iframe vendor libraries and inject them into the sandbox document.\nconst loadBlackboardVendor = () =>\n import(\"./blackboard-vendor\").then((m) => m.injectBlackboardLibraries);\n\nconst COMPLETE_IMAGE_TAG_PATTERN = /<img\\b[^>]*>/i;\nconst POST_IMAGE_STREAM_DEBOUNCE_MS = 180;\nexport interface IframeSandboxProps {\n content: string;\n className?: string;\n loadingText?: string;\n styleLoadingText?: string;\n scriptLoadingText?: string;\n fullScreenButtonText?: string;\n hideFullScreen?: boolean;\n mode?: \"content\" | \"blackboard\";\n type: \"sandbox\" | \"markdown\";\n}\n\nconst normalizeTailwindHeightTokens = (className: string) =>\n className\n .split(/\\s+/)\n .filter(Boolean)\n .map((token) => token.split(\":\").pop() || token);\n\nconst parseViewportHeightCss = (value: string) => {\n const normalized = value.trim().toLowerCase();\n if (!normalized) return null;\n const matched = normalized.match(/^([0-9.]+)(vh|dvh|svh|lvh)$/i);\n if (!matched) return null;\n return `${matched[1]}${matched[2].toLowerCase()}`;\n};\n\nconst extractViewportHeightFromTailwindClass = (className: string) => {\n if (!className.trim()) return null;\n const normalizedTokens = normalizeTailwindHeightTokens(className);\n if (\n normalizedTokens.includes(\"h-screen\") ||\n normalizedTokens.includes(\"h-dvh\")\n ) {\n return \"100dvh\";\n }\n if (normalizedTokens.includes(\"h-svh\")) {\n return \"100svh\";\n }\n if (normalizedTokens.includes(\"h-lvh\")) {\n return \"100lvh\";\n }\n const arbitraryToken = normalizedTokens.find((token) =>\n /^h-\\[[0-9.]+(vh|dvh|svh|lvh)\\]$/i.test(token)\n );\n if (!arbitraryToken) return null;\n const matched = arbitraryToken.match(/^h-\\[([0-9.]+)(vh|dvh|svh|lvh)\\]$/i);\n if (!matched) return null;\n return `${matched[1]}${matched[2].toLowerCase()}`;\n};\n\nconst IframeSandbox: React.FC<IframeSandboxProps> = ({\n content,\n type,\n className,\n loadingText,\n styleLoadingText,\n scriptLoadingText,\n fullScreenButtonText,\n hideFullScreen = false,\n mode = \"content\",\n}) => {\n const containerRef = useRef<HTMLDivElement>(null);\n const iframeRef = useRef<HTMLIFrameElement>(null);\n const rootRef = useRef<Root | null>(null);\n const docRef = useRef<Document | null>(null);\n const updateHeightRef = useRef<() => void>(() => {});\n const [, setHeight] = useState(480);\n const [resetToken, setResetToken] = useState(0);\n const [isFullscreen, setIsFullscreen] = useState(false);\n const isBlackboardMode = mode === \"blackboard\";\n const prevHtmlRef = useRef<string>(\"\");\n const htmlContent = React.useMemo(() => {\n const segments = splitContentSegments(content);\n // console.log('segments=====', segments);\n const sandboxSegments = segments.filter((seg) => seg.type === \"sandbox\");\n const sandboxContent =\n mode === \"blackboard\"\n ? sandboxSegments[sandboxSegments.length - 1]?.value || \"\"\n : sandboxSegments.map((seg) => seg.value).join(\"\\n\");\n return sandboxContent || \"\";\n }, [content, mode]);\n const [renderHtmlContent, setRenderHtmlContent] = useState(htmlContent);\n const prevIncomingHtmlRef = useRef(htmlContent);\n const pendingHtmlRef = useRef(htmlContent);\n const deferRenderTimerRef = useRef<number | null>(null);\n\n const clearDeferredRenderTimer = () => {\n if (deferRenderTimerRef.current === null) return;\n window.clearTimeout(deferRenderTimerRef.current);\n deferRenderTimerRef.current = null;\n };\n\n useEffect(\n () => () => {\n clearDeferredRenderTimer();\n },\n []\n );\n\n useEffect(() => {\n const prevIncomingHtml = prevIncomingHtmlRef.current;\n prevIncomingHtmlRef.current = htmlContent;\n\n const isAppendOnlyStream =\n !!prevIncomingHtml &&\n htmlContent.length > prevIncomingHtml.length &&\n htmlContent.startsWith(prevIncomingHtml);\n const containsCompleteImage = COMPLETE_IMAGE_TAG_PATTERN.test(htmlContent);\n const shouldDeferRender = isAppendOnlyStream && containsCompleteImage;\n\n if (!shouldDeferRender) {\n clearDeferredRenderTimer();\n pendingHtmlRef.current = htmlContent;\n setRenderHtmlContent(htmlContent);\n return;\n }\n\n pendingHtmlRef.current = htmlContent;\n clearDeferredRenderTimer();\n deferRenderTimerRef.current = window.setTimeout(() => {\n setRenderHtmlContent(pendingHtmlRef.current);\n deferRenderTimerRef.current = null;\n }, POST_IMAGE_STREAM_DEBOUNCE_MS);\n }, [htmlContent]);\n\n const rootViewportHeightCss = React.useMemo(() => {\n const normalized = renderHtmlContent.trim();\n if (!normalized) return null;\n const rootMatch = normalized.match(/^<([a-zA-Z][\\w:-]*)(\\s[^>]*?)?>/);\n if (!rootMatch) return null;\n const attrs = rootMatch[2] || \"\";\n const heightAttrMatch = attrs.match(/\\bheight\\s*=\\s*[\"']([^\"']+)[\"']/i);\n if (heightAttrMatch) {\n const explicitHeightCss = parseViewportHeightCss(heightAttrMatch[1]);\n if (explicitHeightCss) return explicitHeightCss;\n }\n const styleAttrMatch = attrs.match(/\\bstyle\\s*=\\s*[\"']([^\"']+)[\"']/i)?.[1];\n const styleHeightMatch = styleAttrMatch?.match(\n /\\bheight\\s*:\\s*([^;]+)/i\n )?.[1];\n if (styleHeightMatch) {\n const styleHeightCss = parseViewportHeightCss(styleHeightMatch);\n if (styleHeightCss) return styleHeightCss;\n }\n const classAttrMatch = attrs.match(/\\bclass\\s*=\\s*[\"']([^\"']+)[\"']/i)?.[1];\n if (!classAttrMatch) return null;\n return extractViewportHeightFromTailwindClass(classAttrMatch);\n }, [renderHtmlContent]);\n const hasRootVhHeight = Boolean(rootViewportHeightCss);\n useEffect(() => {\n if (mode !== \"blackboard\") {\n prevHtmlRef.current = htmlContent;\n return;\n }\n const prev = prevHtmlRef.current;\n const isContinuation = prev && htmlContent.startsWith(prev);\n if (!isContinuation && prev) {\n setResetToken((token) => token + 1);\n }\n prevHtmlRef.current = htmlContent;\n }, [htmlContent, mode]);\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 html, body, #root { width: 100%; height: 100%; }\n html, body { margin: 0; padding: 0; overflow: auto; }\n *, *::before, *::after { box-sizing: border-box; }\n </style>\n </head>\n <body>\n <div id=\"root\"></div>\n </body>\n</html>`);\n doc.close();\n\n docRef.current = doc;\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\n const parseExplicitHeight = (\n value: string,\n parentViewportHeight: number\n ) => {\n const normalized = value.trim().toLowerCase();\n if (!normalized) return null;\n const numeric = Number.parseFloat(normalized);\n if (Number.isNaN(numeric)) return null;\n if (/(dvh|svh|lvh|vh)$/i.test(normalized)) {\n return (numeric / 100) * parentViewportHeight;\n }\n if (normalized.endsWith(\"px\") || /^[0-9.]+$/.test(normalized)) {\n return numeric;\n }\n return null;\n };\n const parseTailwindHeightClass = (\n className: string,\n parentViewportHeight: number\n ) => {\n if (!className.trim()) return null;\n const viewportHeightCss =\n extractViewportHeightFromTailwindClass(className);\n if (viewportHeightCss) {\n return parseExplicitHeight(viewportHeightCss, parentViewportHeight);\n }\n const normalizedTokens = normalizeTailwindHeightTokens(className);\n const arbitraryToken = normalizedTokens.find((token) =>\n /^h-\\[[0-9.]+px\\]$/i.test(token)\n );\n if (!arbitraryToken) return null;\n const matched = arbitraryToken.match(/^h-\\[([0-9.]+)px\\]$/i);\n if (!matched) return null;\n const numeric = Number.parseFloat(matched[1]);\n if (Number.isNaN(numeric)) return null;\n return numeric;\n };\n\n const resolveExplicitHeight = () => {\n if (!iframeRef.current || !doc.body) return null;\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 elements = Array.from(container.children) as HTMLElement[];\n if (elements.length !== 1) return null;\n const target = elements[0];\n const heightValue = target.style.height || target.getAttribute(\"height\");\n const parentViewportHeight =\n iframeRef.current.ownerDocument?.documentElement?.clientHeight ||\n window.innerHeight;\n const parsed = heightValue\n ? parseExplicitHeight(heightValue, parentViewportHeight)\n : null;\n if (parsed !== null) {\n return Math.ceil(parsed);\n }\n const classHeight = parseTailwindHeightClass(\n target.getAttribute(\"class\") || \"\",\n parentViewportHeight\n );\n return classHeight !== null ? Math.ceil(classHeight) : null;\n };\n\n const updateHeight = () => {\n if (!iframeRef.current || !doc.body) return;\n const bodyRect = doc.body.getBoundingClientRect();\n const htmlRect = doc.documentElement?.getBoundingClientRect();\n const bodyHeight = bodyRect.height;\n const htmlHeight = htmlRect?.height || 0;\n const contentHeight = Math.max(bodyHeight, htmlHeight);\n const explicitHeight = resolveExplicitHeight();\n const nextHeight = Math.max(\n 200,\n explicitHeight ?? Math.ceil(contentHeight)\n );\n setHeight(nextHeight);\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 // Inject Tailwind/DaisyUI/GSAP into iframe for all sandbox modes.\n // Dynamic import keeps ~3.3 MB of vendor libs out of the main bundle.\n // Tailwind's MutationObserver ensures styles apply even if content renders first.\n loadBlackboardVendor()\n .then((inject) => {\n if (isDestroyed) return;\n inject(doc);\n scheduleHeightUpdate();\n })\n .catch(() => {\n if (isDestroyed) return;\n scheduleHeightUpdate();\n });\n\n const resizeObserver = new ResizeObserver(() => updateHeight());\n resizeObserver.observe(doc.body);\n if (rootEl) {\n resizeObserver.observe(rootEl);\n }\n\n return () => {\n isDestroyed = true;\n resizeObserver.disconnect();\n // Defer unmount to avoid React warning when parent is mid-render\n setTimeout(() => {\n root.unmount();\n rootRef.current = null;\n docRef.current = null;\n updateHeightRef.current = () => {};\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 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 loadingText={loadingText}\n styleLoadingText={styleLoadingText}\n scriptLoadingText={scriptLoadingText}\n fullScreenButtonText={fullScreenButtonText}\n hideFullScreen={hideFullScreen}\n resetToken={resetToken}\n hasRootVhHeight={hasRootVhHeight}\n mode={mode}\n />\n );\n requestAnimationFrame(() => updateHeightRef.current?.());\n }, [\n renderHtmlContent,\n loadingText,\n styleLoadingText,\n scriptLoadingText,\n fullScreenButtonText,\n resetToken,\n mode,\n ]);\n const containerClassName = [\n \"w-full relative content-render-iframe-sandbox\",\n isBlackboardMode\n ? \"h-full overflow-auto flex flex-col\"\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 data-root-vh={hasRootVhHeight ? \"true\" : \"false\"}\n className={containerClassName}\n >\n {!hideFullScreen && (\n <button\n type=\"button\"\n onClick={toggleFullscreen}\n className={\n \"absolute top-2 right-2 z-50 p-1.5 bg-black/75 text-white rounded-md cursor-pointer\"\n }\n >\n {isFullscreen ? \"退出全屏\" : fullScreenButtonText || \"全屏浏览\"}\n </button>\n )}\n {mode === \"blackboard\" && type === \"markdown\" ? (\n <ContentRender content={content} />\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: \"100%\",\n margin: \"auto\",\n }}\n />\n )}\n </div>\n );\n};\n\nexport default IframeSandbox;\n"],"names":["loadBlackboardVendor","m","COMPLETE_IMAGE_TAG_PATTERN","POST_IMAGE_STREAM_DEBOUNCE_MS","normalizeTailwindHeightTokens","className","token","parseViewportHeightCss","value","normalized","matched","extractViewportHeightFromTailwindClass","normalizedTokens","arbitraryToken","IframeSandbox","content","type","loadingText","styleLoadingText","scriptLoadingText","fullScreenButtonText","hideFullScreen","mode","containerRef","useRef","iframeRef","rootRef","docRef","updateHeightRef","setHeight","useState","resetToken","setResetToken","isFullscreen","setIsFullscreen","isBlackboardMode","prevHtmlRef","htmlContent","React","sandboxSegments","splitContentSegments","seg","renderHtmlContent","setRenderHtmlContent","prevIncomingHtmlRef","pendingHtmlRef","deferRenderTimerRef","clearDeferredRenderTimer","useEffect","prevIncomingHtml","isAppendOnlyStream","containsCompleteImage","hasRootVhHeight","rootMatch","attrs","heightAttrMatch","explicitHeightCss","styleHeightMatch","styleHeightCss","classAttrMatch","prev","iframe","doc","rootEl","root","createRoot","isDestroyed","parseExplicitHeight","parentViewportHeight","numeric","parseTailwindHeightClass","viewportHeightCss","resolveExplicitHeight","container","elements","target","heightValue","parsed","classHeight","updateHeight","bodyRect","htmlRect","bodyHeight","htmlHeight","contentHeight","explicitHeight","nextHeight","scheduleHeightUpdate","inject","resizeObserver","onFullscreenChange","toggleFullscreen","jsx","SandboxApp","containerClassName","jsxs","ContentRender"],"mappings":"qUAMMA,GAAuB,IAC3B,QAAA,QAAA,EAAA,KAAA,IAAA,QAAO,4BAAqB,CAAA,EAAE,KAAMC,GAAMA,EAAE,yBAAyB,EAEjEC,GAA6B,gBAC7BC,GAAgC,IAahCC,EAAiCC,GACrCA,EACG,MAAM,KAAK,EACX,OAAO,OAAO,EACd,IAAKC,GAAUA,EAAM,MAAM,GAAG,EAAE,IAAA,GAASA,CAAK,EAE7CC,EAA0BC,GAAkB,CAChD,MAAMC,EAAaD,EAAM,KAAA,EAAO,YAAA,EAChC,GAAI,CAACC,EAAY,OAAO,KACxB,MAAMC,EAAUD,EAAW,MAAM,8BAA8B,EAC/D,OAAKC,EACE,GAAGA,EAAQ,CAAC,CAAC,GAAGA,EAAQ,CAAC,EAAE,YAAA,CAAa,GAD1B,IAEvB,EAEMC,EAA0CN,GAAsB,CACpE,GAAI,CAACA,EAAU,KAAA,EAAQ,OAAO,KAC9B,MAAMO,EAAmBR,EAA8BC,CAAS,EAChE,GACEO,EAAiB,SAAS,UAAU,GACpCA,EAAiB,SAAS,OAAO,EAEjC,MAAO,SAET,GAAIA,EAAiB,SAAS,OAAO,EACnC,MAAO,SAET,GAAIA,EAAiB,SAAS,OAAO,EACnC,MAAO,SAET,MAAMC,EAAiBD,EAAiB,KAAMN,GAC5C,mCAAmC,KAAKA,CAAK,CAAA,EAE/C,GAAI,CAACO,EAAgB,OAAO,KAC5B,MAAMH,EAAUG,EAAe,MAAM,oCAAoC,EACzE,OAAKH,EACE,GAAGA,EAAQ,CAAC,CAAC,GAAGA,EAAQ,CAAC,EAAE,YAAA,CAAa,GAD1B,IAEvB,EAEMI,GAA8C,CAAC,CACnD,QAAAC,EACA,KAAAC,EACA,UAAAX,EACA,YAAAY,EACA,iBAAAC,EACA,kBAAAC,EACA,qBAAAC,EACA,eAAAC,EAAiB,GACjB,KAAAC,EAAO,SACT,I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d,KAAK,GAAG,EAEX,OACE4D,EAAAA,kBAAAA,KAAC,MAAA,CACC,IAAKxE,EACL,eAAc6B,EAAkB,OAAS,QACzC,UAAW0C,GAEV,SAAA,CAAA,CAACzE,GACAuE,EAAAA,kBAAAA,IAAC,SAAA,CACC,KAAK,SACL,QAASD,EACT,UACE,qFAGD,SAAA1D,EAAe,OAASb,GAAwB,MAAA,CAAA,EAGpDE,IAAS,cAAgBN,IAAS,WACjC4E,EAAAA,kBAAAA,IAACI,WAAA,CAAc,QAAAjF,EAAkB,EAEjC6E,EAAAA,kBAAAA,IAAC,SAAA,CACC,IAAKnE,EACL,QAAQ,8EACR,MAAM,aACN,gBAAe,GACf,UAAW,CAACpB,EAAW,qCAAqC,EACzD,OAAO,OAAO,EACd,KAAK,GAAG,EACX,MAAO,CACL,OAAQ,OACR,OAAQ,MAAA,CACV,CAAA,CACF,CAAA,CAAA,CAIR"}
1
+ {"version":3,"file":"IframeSandbox.cjs.js","sources":["../../../src/components/ContentRender/IframeSandbox.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useRef, useState } from \"react\";\nimport { createRoot, Root } from \"react-dom/client\";\nimport { Loader2 } from \"lucide-react\";\nimport SandboxApp from \"./SandboxApp\";\nimport { splitContentSegments } from \"./utils/split-content\";\nimport ContentRender from \"./ContentRender\";\n\ntype InjectBlackboardLibraries =\n typeof import(\"./blackboard-vendor\").injectBlackboardLibraries;\n\n// Cache the sandbox vendor loader so every iframe reuses the same preload request.\nlet blackboardVendorPromise: Promise<InjectBlackboardLibraries> | null = null;\n\nconst loadBlackboardVendor = () => {\n if (!blackboardVendorPromise) {\n blackboardVendorPromise = import(\"./blackboard-vendor\").then(\n (m) => m.injectBlackboardLibraries\n );\n }\n\n return blackboardVendorPromise;\n};\n\n// Warm the sandbox vendor chunk as early as possible in the browser.\nif (typeof window !== \"undefined\") {\n void loadBlackboardVendor();\n}\n\nconst COMPLETE_IMAGE_TAG_PATTERN = /<img\\b[^>]*>/i;\nconst POST_IMAGE_STREAM_DEBOUNCE_MS = 180;\nconst SANDBOX_INTERACTION_MESSAGE_SOURCE = \"markdown-flow-ui:sandbox\";\nconst SANDBOX_INTERACTION_MESSAGE_TYPE = \"interaction\";\nconst SANDBOX_INTERACTION_THROTTLE_MS = 240;\nexport interface IframeSandboxProps {\n content: string;\n className?: string;\n loadingText?: string;\n styleLoadingText?: string;\n scriptLoadingText?: string;\n fullScreenButtonText?: string;\n hideFullScreen?: boolean;\n mode?: \"content\" | \"blackboard\";\n type: \"sandbox\" | \"markdown\";\n}\n\nconst normalizeTailwindHeightTokens = (className: string) =>\n className\n .split(/\\s+/)\n .filter(Boolean)\n .map((token) => token.split(\":\").pop() || token);\n\nconst parseViewportHeightCss = (value: string) => {\n const normalized = value.trim().toLowerCase();\n if (!normalized) return null;\n const matched = normalized.match(/^([0-9.]+)(vh|dvh|svh|lvh)$/i);\n if (!matched) return null;\n return `${matched[1]}${matched[2].toLowerCase()}`;\n};\n\nconst extractViewportHeightFromTailwindClass = (className: string) => {\n if (!className.trim()) return null;\n const normalizedTokens = normalizeTailwindHeightTokens(className);\n if (\n normalizedTokens.includes(\"h-screen\") ||\n normalizedTokens.includes(\"h-dvh\")\n ) {\n return \"100dvh\";\n }\n if (normalizedTokens.includes(\"h-svh\")) {\n return \"100svh\";\n }\n if (normalizedTokens.includes(\"h-lvh\")) {\n return \"100lvh\";\n }\n const arbitraryToken = normalizedTokens.find((token) =>\n /^h-\\[[0-9.]+(vh|dvh|svh|lvh)\\]$/i.test(token)\n );\n if (!arbitraryToken) return null;\n const matched = arbitraryToken.match(/^h-\\[([0-9.]+)(vh|dvh|svh|lvh)\\]$/i);\n if (!matched) return null;\n return `${matched[1]}${matched[2].toLowerCase()}`;\n};\n\nconst IframeSandbox: React.FC<IframeSandboxProps> = ({\n content,\n type,\n className,\n loadingText,\n styleLoadingText,\n scriptLoadingText,\n fullScreenButtonText,\n hideFullScreen = false,\n mode = \"content\",\n}) => {\n const containerRef = useRef<HTMLDivElement>(null);\n const iframeRef = useRef<HTMLIFrameElement>(null);\n const rootRef = useRef<Root | null>(null);\n const docRef = useRef<Document | null>(null);\n const updateHeightRef = useRef<() => void>(() => {});\n const [height, setHeight] = useState(480);\n const lastSandboxInteractionTimeRef = useRef(0);\n const [resetToken, setResetToken] = useState(0);\n const [isFullscreen, setIsFullscreen] = useState(false);\n const [isSandboxVendorReady, setIsSandboxVendorReady] = useState(\n type !== \"sandbox\"\n );\n const isBlackboardMode = mode === \"blackboard\";\n const prevHtmlRef = useRef<string>(\"\");\n const htmlContent = React.useMemo(() => {\n const segments = splitContentSegments(content);\n // console.log('segments=====', segments);\n const sandboxSegments = segments.filter((seg) => seg.type === \"sandbox\");\n const sandboxContent =\n mode === \"blackboard\"\n ? sandboxSegments[sandboxSegments.length - 1]?.value || \"\"\n : sandboxSegments.map((seg) => seg.value).join(\"\\n\");\n return sandboxContent || \"\";\n }, [content, mode]);\n const [renderHtmlContent, setRenderHtmlContent] = useState(htmlContent);\n const prevIncomingHtmlRef = useRef(htmlContent);\n const pendingHtmlRef = useRef(htmlContent);\n const deferRenderTimerRef = useRef<number | 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 const clearDeferredRenderTimer = () => {\n if (deferRenderTimerRef.current === null) return;\n window.clearTimeout(deferRenderTimerRef.current);\n deferRenderTimerRef.current = null;\n };\n\n useEffect(\n () => () => {\n clearDeferredRenderTimer();\n },\n []\n );\n\n useEffect(() => {\n const prevIncomingHtml = prevIncomingHtmlRef.current;\n prevIncomingHtmlRef.current = htmlContent;\n\n const isAppendOnlyStream =\n !!prevIncomingHtml &&\n htmlContent.length > prevIncomingHtml.length &&\n htmlContent.startsWith(prevIncomingHtml);\n const containsCompleteImage = COMPLETE_IMAGE_TAG_PATTERN.test(htmlContent);\n const shouldDeferRender = isAppendOnlyStream && containsCompleteImage;\n\n if (!shouldDeferRender) {\n clearDeferredRenderTimer();\n pendingHtmlRef.current = htmlContent;\n setRenderHtmlContent(htmlContent);\n return;\n }\n\n pendingHtmlRef.current = htmlContent;\n clearDeferredRenderTimer();\n deferRenderTimerRef.current = window.setTimeout(() => {\n setRenderHtmlContent(pendingHtmlRef.current);\n deferRenderTimerRef.current = null;\n }, POST_IMAGE_STREAM_DEBOUNCE_MS);\n }, [htmlContent]);\n\n const rootViewportHeightCss = React.useMemo(() => {\n const normalized = renderHtmlContent.trim();\n if (!normalized) return null;\n const rootMatch = normalized.match(/^<([a-zA-Z][\\w:-]*)(\\s[^>]*?)?>/);\n if (!rootMatch) return null;\n const attrs = rootMatch[2] || \"\";\n const heightAttrMatch = attrs.match(/\\bheight\\s*=\\s*[\"']([^\"']+)[\"']/i);\n if (heightAttrMatch) {\n const explicitHeightCss = parseViewportHeightCss(heightAttrMatch[1]);\n if (explicitHeightCss) return explicitHeightCss;\n }\n const styleAttrMatch = attrs.match(/\\bstyle\\s*=\\s*[\"']([^\"']+)[\"']/i)?.[1];\n const styleHeightMatch = styleAttrMatch?.match(\n /\\bheight\\s*:\\s*([^;]+)/i\n )?.[1];\n if (styleHeightMatch) {\n const styleHeightCss = parseViewportHeightCss(styleHeightMatch);\n if (styleHeightCss) return styleHeightCss;\n }\n const classAttrMatch = attrs.match(/\\bclass\\s*=\\s*[\"']([^\"']+)[\"']/i)?.[1];\n if (!classAttrMatch) return null;\n return extractViewportHeightFromTailwindClass(classAttrMatch);\n }, [renderHtmlContent]);\n const hasRootVhHeight = Boolean(rootViewportHeightCss);\n const shouldInjectSandboxVendor = type === \"sandbox\";\n const sandboxViewportHeight =\n isBlackboardMode && type === \"sandbox\"\n ? (rootViewportHeightCss ?? `${height}px`)\n : undefined;\n useEffect(() => {\n if (mode !== \"blackboard\") {\n prevHtmlRef.current = htmlContent;\n return;\n }\n const prev = prevHtmlRef.current;\n const isContinuation = prev && htmlContent.startsWith(prev);\n if (!isContinuation && prev) {\n setResetToken((token) => token + 1);\n }\n prevHtmlRef.current = htmlContent;\n }, [htmlContent, mode]);\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 html, body, #root { width: 100%; height: 100%; }\n html, body { margin: 0; padding: 0; overflow: auto; }\n *, *::before, *::after { box-sizing: border-box; }\n </style>\n </head>\n <body>\n <div id=\"root\"></div>\n </body>\n</html>`);\n doc.close();\n\n docRef.current = doc;\n\n const shouldBridgeSandboxInteraction =\n isBlackboardMode && type === \"sandbox\";\n const handleSandboxPointerDown = () =>\n emitSandboxInteraction(\"pointerdown\");\n const handleSandboxMouseDown = () => emitSandboxInteraction(\"mousedown\");\n const handleSandboxTouchStart = () => emitSandboxInteraction(\"touchstart\");\n\n if (shouldBridgeSandboxInteraction) {\n doc.addEventListener(\"pointerdown\", handleSandboxPointerDown, true);\n doc.addEventListener(\"mousedown\", handleSandboxMouseDown, true);\n doc.addEventListener(\"touchstart\", handleSandboxTouchStart, 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\n const parseExplicitHeight = (\n value: string,\n parentViewportHeight: number\n ) => {\n const normalized = value.trim().toLowerCase();\n if (!normalized) return null;\n const numeric = Number.parseFloat(normalized);\n if (Number.isNaN(numeric)) return null;\n if (/(dvh|svh|lvh|vh)$/i.test(normalized)) {\n return (numeric / 100) * parentViewportHeight;\n }\n if (normalized.endsWith(\"px\") || /^[0-9.]+$/.test(normalized)) {\n return numeric;\n }\n return null;\n };\n const parseTailwindHeightClass = (\n className: string,\n parentViewportHeight: number\n ) => {\n if (!className.trim()) return null;\n const viewportHeightCss =\n extractViewportHeightFromTailwindClass(className);\n if (viewportHeightCss) {\n return parseExplicitHeight(viewportHeightCss, parentViewportHeight);\n }\n const normalizedTokens = normalizeTailwindHeightTokens(className);\n const arbitraryToken = normalizedTokens.find((token) =>\n /^h-\\[[0-9.]+px\\]$/i.test(token)\n );\n if (!arbitraryToken) return null;\n const matched = arbitraryToken.match(/^h-\\[([0-9.]+)px\\]$/i);\n if (!matched) return null;\n const numeric = Number.parseFloat(matched[1]);\n if (Number.isNaN(numeric)) return null;\n return numeric;\n };\n\n const resolveExplicitHeight = () => {\n if (!iframeRef.current || !doc.body) return null;\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 elements = Array.from(container.children) as HTMLElement[];\n if (elements.length !== 1) return null;\n const target = elements[0];\n const heightValue = target.style.height || target.getAttribute(\"height\");\n const parentViewportHeight =\n iframeRef.current.ownerDocument?.documentElement?.clientHeight ||\n window.innerHeight;\n const parsed = heightValue\n ? parseExplicitHeight(heightValue, parentViewportHeight)\n : null;\n if (parsed !== null) {\n return Math.ceil(parsed);\n }\n const classHeight = parseTailwindHeightClass(\n target.getAttribute(\"class\") || \"\",\n parentViewportHeight\n );\n return classHeight !== null ? Math.ceil(classHeight) : null;\n };\n\n const updateHeight = () => {\n if (!iframeRef.current || !doc.body) return;\n const bodyRect = doc.body.getBoundingClientRect();\n const htmlRect = doc.documentElement?.getBoundingClientRect();\n const bodyHeight = bodyRect.height;\n const htmlHeight = htmlRect?.height || 0;\n const contentHeight = Math.max(bodyHeight, htmlHeight);\n const explicitHeight = resolveExplicitHeight();\n const nextHeight = Math.max(\n 200,\n explicitHeight ?? Math.ceil(contentHeight)\n );\n setHeight(nextHeight);\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 setIsSandboxVendorReady(true);\n } else {\n // Inject Tailwind/DaisyUI/GSAP before rendering sandbox content to avoid FOUC.\n loadBlackboardVendor()\n .then((inject) => {\n if (isDestroyed) return;\n inject(doc);\n requestAnimationFrame(() => {\n if (isDestroyed) return;\n setIsSandboxVendorReady(true);\n scheduleHeightUpdate();\n });\n })\n .catch(() => {\n if (isDestroyed) return;\n setIsSandboxVendorReady(true);\n scheduleHeightUpdate();\n });\n }\n\n const resizeObserver = new ResizeObserver(() => updateHeight());\n resizeObserver.observe(doc.body);\n if (rootEl) {\n resizeObserver.observe(rootEl);\n }\n\n return () => {\n isDestroyed = true;\n resizeObserver.disconnect();\n if (shouldBridgeSandboxInteraction) {\n doc.removeEventListener(\"pointerdown\", handleSandboxPointerDown, true);\n doc.removeEventListener(\"mousedown\", handleSandboxMouseDown, true);\n doc.removeEventListener(\"touchstart\", handleSandboxTouchStart, true);\n }\n // Defer unmount to avoid React warning when parent is mid-render\n setTimeout(() => {\n root.unmount();\n rootRef.current = null;\n docRef.current = null;\n updateHeightRef.current = () => {};\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 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 || !isSandboxVendorReady) return;\n\n root.render(\n <SandboxApp\n html={renderHtmlContent}\n loadingText={loadingText}\n styleLoadingText={styleLoadingText}\n scriptLoadingText={scriptLoadingText}\n fullScreenButtonText={fullScreenButtonText}\n hideFullScreen={hideFullScreen}\n resetToken={resetToken}\n hasRootVhHeight={hasRootVhHeight}\n mode={mode}\n />\n );\n requestAnimationFrame(() => updateHeightRef.current?.());\n }, [\n renderHtmlContent,\n loadingText,\n styleLoadingText,\n scriptLoadingText,\n fullScreenButtonText,\n resetToken,\n mode,\n isSandboxVendorReady,\n ]);\n const containerClassName = [\n \"w-full relative content-render-iframe-sandbox\",\n isBlackboardMode\n ? \"h-full overflow-auto flex flex-col\"\n : \"aspect-[16/9] overflow-hidden flex items-center justify-center\",\n ]\n .filter(Boolean)\n .join(\" \");\n\n const shouldShowSandboxLoading =\n shouldInjectSandboxVendor && !isSandboxVendorReady;\n\n return (\n <div\n ref={containerRef}\n data-root-vh={hasRootVhHeight ? \"true\" : \"false\"}\n className={containerClassName}\n style={\n sandboxViewportHeight\n ? {\n height: sandboxViewportHeight,\n minHeight: sandboxViewportHeight,\n }\n : undefined\n }\n >\n {!hideFullScreen && (\n <button\n type=\"button\"\n onClick={toggleFullscreen}\n className={\n \"absolute top-2 right-2 z-50 p-1.5 bg-black/75 text-white rounded-md cursor-pointer\"\n }\n >\n {isFullscreen ? \"退出全屏\" : fullScreenButtonText || \"全屏浏览\"}\n </button>\n )}\n {mode === \"blackboard\" && type === \"markdown\" ? (\n <div\n onMouseDown={() => emitSandboxInteraction(\"mousedown\")}\n onPointerDown={() => emitSandboxInteraction(\"pointerdown\")}\n onTouchStart={() => emitSandboxInteraction(\"touchstart\")}\n >\n <ContentRender content={content} />\n </div>\n ) : (\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 visibility: shouldShowSandboxLoading ? \"hidden\" : \"visible\",\n }}\n />\n {shouldShowSandboxLoading ? (\n <div className=\"pointer-events-none absolute inset-0 z-20 flex items-center justify-center\">\n <Loader2\n aria-label={loadingText || \"Preparing sandbox styles\"}\n className=\"text-primary h-7 w-7 animate-spin\"\n />\n </div>\n ) : null}\n </>\n )}\n </div>\n );\n};\n\nexport default IframeSandbox;\n"],"names":["blackboardVendorPromise","loadBlackboardVendor","m","COMPLETE_IMAGE_TAG_PATTERN","POST_IMAGE_STREAM_DEBOUNCE_MS","SANDBOX_INTERACTION_MESSAGE_SOURCE","SANDBOX_INTERACTION_MESSAGE_TYPE","SANDBOX_INTERACTION_THROTTLE_MS","normalizeTailwindHeightTokens","className","token","parseViewportHeightCss","value","normalized","matched","extractViewportHeightFromTailwindClass","normalizedTokens","arbitraryToken","IframeSandbox","content","type","loadingText","styleLoadingText","scriptLoadingText","fullScreenButtonText","hideFullScreen","mode","containerRef","useRef","iframeRef","rootRef","docRef","updateHeightRef","height","setHeight","useState","lastSandboxInteractionTimeRef","resetToken","setResetToken","isFullscreen","setIsFullscreen","isSandboxVendorReady","setIsSandboxVendorReady","isBlackboardMode","prevHtmlRef","htmlContent","React","sandboxSegments","splitContentSegments","seg","renderHtmlContent","setRenderHtmlContent","prevIncomingHtmlRef","pendingHtmlRef","deferRenderTimerRef","emitSandboxInteraction","useCallback","eventType","now","clearDeferredRenderTimer","useEffect","prevIncomingHtml","isAppendOnlyStream","containsCompleteImage","rootViewportHeightCss","rootMatch","attrs","heightAttrMatch","explicitHeightCss","styleHeightMatch","styleHeightCss","classAttrMatch","hasRootVhHeight","shouldInjectSandboxVendor","sandboxViewportHeight","prev","iframe","doc","shouldBridgeSandboxInteraction","handleSandboxPointerDown","handleSandboxMouseDown","handleSandboxTouchStart","rootEl","root","createRoot","isDestroyed","parseExplicitHeight","parentViewportHeight","numeric","parseTailwindHeightClass","viewportHeightCss","resolveExplicitHeight","container","elements","target","heightValue","parsed","classHeight","updateHeight","bodyRect","htmlRect","bodyHeight","htmlHeight","contentHeight","explicitHeight","nextHeight","scheduleHeightUpdate","inject","resizeObserver","onFullscreenChange","toggleFullscreen","jsx","SandboxApp","containerClassName","shouldShowSandboxLoading","jsxs","ContentRender","Fragment","Loader2"],"mappings":"gfAWA,IAAIA,EAAqE,KAEzE,MAAMC,GAAuB,KACtBD,IACHA,EAA0B,QAAA,QAAA,EAAA,KAAA,IAAA,QAAO,4BAAqB,CAAA,EAAE,KACrDE,GAAMA,EAAE,yBAAA,GAINF,GAIL,OAAO,OAAW,KACfC,GAAA,EAGP,MAAME,GAA6B,gBAC7BC,GAAgC,IAChCC,GAAqC,2BACrCC,GAAmC,cACnCC,GAAkC,IAalCC,GAAiCC,GACrCA,EACG,MAAM,KAAK,EACX,OAAO,OAAO,EACd,IAAKC,GAAUA,EAAM,MAAM,GAAG,EAAE,IAAA,GAASA,CAAK,EAE7CC,GAA0BC,GAAkB,CAChD,MAAMC,EAAaD,EAAM,KAAA,EAAO,YAAA,EAChC,GAAI,CAACC,EAAY,OAAO,KACxB,MAAMC,EAAUD,EAAW,MAAM,8BAA8B,EAC/D,OAAKC,EACE,GAAGA,EAAQ,CAAC,CAAC,GAAGA,EAAQ,CAAC,EAAE,YAAA,CAAa,GAD1B,IAEvB,EAEMC,GAA0CN,GAAsB,CACpE,GAAI,CAACA,EAAU,KAAA,EAAQ,OAAO,KAC9B,MAAMO,EAAmBR,GAA8BC,CAAS,EAChE,GACEO,EAAiB,SAAS,UAAU,GACpCA,EAAiB,SAAS,OAAO,EAEjC,MAAO,SAET,GAAIA,EAAiB,SAAS,OAAO,EACnC,MAAO,SAET,GAAIA,EAAiB,SAAS,OAAO,EACnC,MAAO,SAET,MAAMC,EAAiBD,EAAiB,KAAMN,GAC5C,mCAAmC,KAAKA,CAAK,CAAA,EAE/C,GAAI,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