markdown-flow-ui 0.1.128 → 0.2.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 (152) hide show
  1. package/dist/components/ContentRender/ContentRender.cjs.js +2 -2
  2. package/dist/components/ContentRender/ContentRender.cjs.js.map +1 -1
  3. package/dist/components/ContentRender/ContentRender.d.ts +4 -0
  4. package/dist/components/ContentRender/ContentRender.es.js +217 -211
  5. package/dist/components/ContentRender/ContentRender.es.js.map +1 -1
  6. package/dist/components/ContentRender/IframeSandbox.cjs.js +3 -3
  7. package/dist/components/ContentRender/IframeSandbox.cjs.js.map +1 -1
  8. package/dist/components/ContentRender/IframeSandbox.d.ts +3 -0
  9. package/dist/components/ContentRender/IframeSandbox.es.js +199 -186
  10. package/dist/components/ContentRender/IframeSandbox.es.js.map +1 -1
  11. package/dist/components/ContentRender/MarkdownFlowInput.cjs.js +1 -1
  12. package/dist/components/ContentRender/MarkdownFlowInput.cjs.js.map +1 -1
  13. package/dist/components/ContentRender/MarkdownFlowInput.d.ts +3 -0
  14. package/dist/components/ContentRender/MarkdownFlowInput.es.js +35 -32
  15. package/dist/components/ContentRender/MarkdownFlowInput.es.js.map +1 -1
  16. package/dist/components/ContentRender/MarkdownFlowInput.stories.d.ts +6 -0
  17. package/dist/components/ContentRender/SandboxApp.cjs.js +2 -2
  18. package/dist/components/ContentRender/SandboxApp.cjs.js.map +1 -1
  19. package/dist/components/ContentRender/SandboxApp.d.ts +3 -0
  20. package/dist/components/ContentRender/SandboxApp.es.js +117 -104
  21. package/dist/components/ContentRender/SandboxApp.es.js.map +1 -1
  22. package/dist/components/ContentRender/contentRenderI18n.cjs.js +2 -0
  23. package/dist/components/ContentRender/contentRenderI18n.cjs.js.map +1 -0
  24. package/dist/components/ContentRender/contentRenderI18n.d.ts +15 -0
  25. package/dist/components/ContentRender/contentRenderI18n.es.js +59 -0
  26. package/dist/components/ContentRender/contentRenderI18n.es.js.map +1 -0
  27. package/dist/components/ContentRender/index.cjs.js +1 -1
  28. package/dist/components/ContentRender/index.d.ts +1 -0
  29. package/dist/components/ContentRender/index.es.js +1 -0
  30. package/dist/components/ContentRender/index.es.js.map +1 -1
  31. package/dist/components/ContentRender/plugins/CustomVariable.cjs.js +1 -1
  32. package/dist/components/ContentRender/plugins/CustomVariable.cjs.js.map +1 -1
  33. package/dist/components/ContentRender/plugins/CustomVariable.d.ts +3 -1
  34. package/dist/components/ContentRender/plugins/CustomVariable.es.js +131 -124
  35. package/dist/components/ContentRender/plugins/CustomVariable.es.js.map +1 -1
  36. package/dist/components/MarkdownFlow/MarkdownFlow.cjs.js +1 -1
  37. package/dist/components/MarkdownFlow/MarkdownFlow.cjs.js.map +1 -1
  38. package/dist/components/MarkdownFlow/MarkdownFlow.d.ts +3 -0
  39. package/dist/components/MarkdownFlow/MarkdownFlow.es.js +18 -15
  40. package/dist/components/MarkdownFlow/MarkdownFlow.es.js.map +1 -1
  41. package/dist/components/MarkdownFlow/MarkdownFlow.stories.d.ts +6 -0
  42. package/dist/components/MarkdownFlow/ScrollableMarkdownFlow.d.ts +1 -0
  43. package/dist/components/MarkdownFlow/index.cjs.js +1 -1
  44. package/dist/components/MarkdownFlow/index.es.js +1 -0
  45. package/dist/components/MarkdownFlow/index.es.js.map +1 -1
  46. package/dist/components/MarkdownFlowEditor/MarkdownFlowEditor.cjs.js +1 -1
  47. package/dist/components/MarkdownFlowEditor/MarkdownFlowEditor.cjs.js.map +1 -1
  48. package/dist/components/MarkdownFlowEditor/MarkdownFlowEditor.d.ts +2 -2
  49. package/dist/components/MarkdownFlowEditor/MarkdownFlowEditor.es.js +23 -22
  50. package/dist/components/MarkdownFlowEditor/MarkdownFlowEditor.es.js.map +1 -1
  51. package/dist/components/MarkdownFlowEditor/MarkdownFlowEditor.stories.d.ts +1 -1
  52. package/dist/components/MarkdownFlowEditor/components/EditorToolbar.cjs.js.map +1 -1
  53. package/dist/components/MarkdownFlowEditor/components/EditorToolbar.es.js.map +1 -1
  54. package/dist/components/MarkdownFlowEditor/editorI18n.cjs.js +1 -1
  55. package/dist/components/MarkdownFlowEditor/editorI18n.cjs.js.map +1 -1
  56. package/dist/components/MarkdownFlowEditor/editorI18n.d.ts +0 -2
  57. package/dist/components/MarkdownFlowEditor/editorI18n.es.js +12 -24
  58. package/dist/components/MarkdownFlowEditor/editorI18n.es.js.map +1 -1
  59. package/dist/components/MarkdownFlowEditor/index.d.ts +1 -1
  60. package/dist/components/Slide/Player.cjs.js +1 -1
  61. package/dist/components/Slide/Player.cjs.js.map +1 -1
  62. package/dist/components/Slide/Player.d.ts +30 -30
  63. package/dist/components/Slide/Player.es.js +721 -638
  64. package/dist/components/Slide/Player.es.js.map +1 -1
  65. package/dist/components/Slide/Slide.cjs.js +1 -1
  66. package/dist/components/Slide/Slide.cjs.js.map +1 -1
  67. package/dist/components/Slide/Slide.d.ts +22 -4
  68. package/dist/components/Slide/Slide.es.js +758 -638
  69. package/dist/components/Slide/Slide.es.js.map +1 -1
  70. package/dist/components/Slide/Slide.stories.d.ts +19 -20
  71. package/dist/components/Slide/constants.d.ts +0 -24
  72. package/dist/components/Slide/index.d.ts +2 -1
  73. package/dist/components/Slide/slideI18n.cjs.js +2 -0
  74. package/dist/components/Slide/slideI18n.cjs.js.map +1 -0
  75. package/dist/components/Slide/slideI18n.d.ts +44 -0
  76. package/dist/components/Slide/slideI18n.es.js +162 -0
  77. package/dist/components/Slide/slideI18n.es.js.map +1 -0
  78. package/dist/components/Slide/useSlide.cjs.js +1 -1
  79. package/dist/components/Slide/useSlide.cjs.js.map +1 -1
  80. package/dist/components/Slide/useSlide.d.ts +2 -0
  81. package/dist/components/Slide/useSlide.es.js +124 -105
  82. package/dist/components/Slide/useSlide.es.js.map +1 -1
  83. package/dist/components/Slide/utils/audioSegments.cjs.js +2 -0
  84. package/dist/components/Slide/utils/audioSegments.cjs.js.map +1 -0
  85. package/dist/components/Slide/utils/audioSegments.d.ts +2 -0
  86. package/dist/components/Slide/utils/audioSegments.es.js +21 -0
  87. package/dist/components/Slide/utils/audioSegments.es.js.map +1 -0
  88. package/dist/components/Slide/utils/audioSegments.test.d.ts +1 -0
  89. package/dist/components/Slide/utils/playbackSequence.cjs.js +1 -1
  90. package/dist/components/Slide/utils/playbackSequence.cjs.js.map +1 -1
  91. package/dist/components/Slide/utils/playbackSequence.d.ts +10 -0
  92. package/dist/components/Slide/utils/playbackSequence.es.js +15 -6
  93. package/dist/components/Slide/utils/playbackSequence.es.js.map +1 -1
  94. package/dist/components/Slide/utils/playerVisibility.cjs.js +2 -0
  95. package/dist/components/Slide/utils/playerVisibility.cjs.js.map +1 -0
  96. package/dist/components/Slide/utils/playerVisibility.d.ts +10 -0
  97. package/dist/components/Slide/utils/playerVisibility.es.js +11 -0
  98. package/dist/components/Slide/utils/playerVisibility.es.js.map +1 -0
  99. package/dist/components/Slide/utils/playerVisibility.test.d.ts +1 -0
  100. package/dist/components/Slide/utils/subtitleCue.cjs.js +2 -2
  101. package/dist/components/Slide/utils/subtitleCue.cjs.js.map +1 -1
  102. package/dist/components/Slide/utils/subtitleCue.d.ts +21 -0
  103. package/dist/components/Slide/utils/subtitleCue.es.js +146 -49
  104. package/dist/components/Slide/utils/subtitleCue.es.js.map +1 -1
  105. package/dist/components/Slide/utils/subtitleJumpNavigation.cjs.js +2 -0
  106. package/dist/components/Slide/utils/subtitleJumpNavigation.cjs.js.map +1 -0
  107. package/dist/components/Slide/utils/subtitleJumpNavigation.d.ts +10 -0
  108. package/dist/components/Slide/utils/subtitleJumpNavigation.es.js +22 -0
  109. package/dist/components/Slide/utils/subtitleJumpNavigation.es.js.map +1 -0
  110. package/dist/components/Slide/utils/subtitleJumpNavigation.test.d.ts +1 -0
  111. package/dist/components/index.d.ts +2 -1
  112. package/dist/editor.d.ts +3 -2
  113. package/dist/index.cjs.js +1 -1
  114. package/dist/index.es.js +14 -13
  115. package/dist/index.es.js.map +1 -1
  116. package/dist/lib/locale.cjs.js +2 -0
  117. package/dist/lib/locale.cjs.js.map +1 -0
  118. package/dist/lib/locale.d.ts +4 -0
  119. package/dist/lib/locale.es.js +19 -0
  120. package/dist/lib/locale.es.js.map +1 -0
  121. package/dist/lib/localeTextMap.cjs.js +2 -0
  122. package/dist/lib/localeTextMap.cjs.js.map +1 -0
  123. package/dist/lib/localeTextMap.d.ts +4 -0
  124. package/dist/lib/localeTextMap.es.js +5 -0
  125. package/dist/lib/localeTextMap.es.js.map +1 -0
  126. package/dist/markdown-flow-ui-lib.css +1 -1
  127. package/dist/node_modules/lucide-react/dist/esm/icons/fast-forward.cjs.js +7 -0
  128. package/dist/node_modules/lucide-react/dist/esm/icons/fast-forward.cjs.js.map +1 -0
  129. package/dist/node_modules/lucide-react/dist/esm/icons/fast-forward.es.js +16 -0
  130. package/dist/node_modules/lucide-react/dist/esm/icons/fast-forward.es.js.map +1 -0
  131. package/dist/node_modules/lucide-react/dist/esm/icons/rewind.cjs.js +7 -0
  132. package/dist/node_modules/lucide-react/dist/esm/icons/rewind.cjs.js.map +1 -0
  133. package/dist/node_modules/lucide-react/dist/esm/icons/rewind.es.js +16 -0
  134. package/dist/node_modules/lucide-react/dist/esm/icons/rewind.es.js.map +1 -0
  135. package/dist/renderer.cjs.js +1 -1
  136. package/dist/renderer.d.ts +1 -0
  137. package/dist/renderer.es.js +15 -14
  138. package/dist/renderer.es.js.map +1 -1
  139. package/dist/slide.d.ts +1 -0
  140. package/package.json +1 -1
  141. package/dist/components/Slide/constants.cjs.js +0 -2
  142. package/dist/components/Slide/constants.cjs.js.map +0 -1
  143. package/dist/components/Slide/constants.es.js +0 -28
  144. package/dist/components/Slide/constants.es.js.map +0 -1
  145. package/dist/node_modules/lucide-react/dist/esm/icons/rotate-ccw.cjs.js +0 -7
  146. package/dist/node_modules/lucide-react/dist/esm/icons/rotate-ccw.cjs.js.map +0 -1
  147. package/dist/node_modules/lucide-react/dist/esm/icons/rotate-ccw.es.js +0 -16
  148. package/dist/node_modules/lucide-react/dist/esm/icons/rotate-ccw.es.js.map +0 -1
  149. package/dist/node_modules/lucide-react/dist/esm/icons/rotate-cw.cjs.js +0 -7
  150. package/dist/node_modules/lucide-react/dist/esm/icons/rotate-cw.cjs.js.map +0 -1
  151. package/dist/node_modules/lucide-react/dist/esm/icons/rotate-cw.es.js +0 -16
  152. package/dist/node_modules/lucide-react/dist/esm/icons/rotate-cw.es.js.map +0 -1
@@ -1,6 +1,6 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("../../_virtual/jsx-runtime.cjs.js");;/* empty css */;/* empty css */const o=require("react"),me=require("../../_virtual/index.cjs.js"),xe=require("./utils/sanitize-invalid-tag-name.cjs.js"),pe=require("./utils/strip-svg-text-line-breaks.cjs.js");;/* empty css */;/* empty css */const he=require("./CodeBlock.cjs.js"),fe=require("./plugins/CustomVariable.cjs.js"),F=require("./plugins/MermaidChart.cjs.js"),Z=require("./utils/custom-variable-props.cjs.js"),ee=require("./utils/highlight-languages.cjs.js"),O=require("./utils/mermaid-parse.cjs.js"),te=require("./utils/normalize-inline-html.cjs.js"),ge=require("./IframeSandbox.cjs.js"),je=require("./utils/split-content.cjs.js"),ve=require("../../lib/interaction-defaults.cjs.js"),Re=require("../../node_modules/react-markdown/lib/index.cjs.js"),ye=require("../../node_modules/rehype-raw/lib/index.cjs.js"),be=require("../../node_modules/rehype-highlight/lib/index.cjs.js"),we=require("../../node_modules/rehype-katex/lib/index.cjs.js"),Ee=require("../../node_modules/remark-gfm/lib/index.cjs.js"),Ne=require("../../node_modules/remark-math/lib/index.cjs.js"),Te=require("../../node_modules/remark-breaks/lib/index.cjs.js"),ke=/<(script|style|link|iframe|html|head|body|meta|title|base|template|div|section|article|main)\b/i,ne=({svg:n})=>{const i=o.useRef(null);return o.useEffect(()=>{const a=i.current;if(!a)return;const c=a.shadowRoot??a.attachShadow({mode:"open"}),k="content-render-svg-style";let f=c.getElementById(k);f||(f=document.createElement("style"),f.id=k,f.textContent=`
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("../../_virtual/jsx-runtime.cjs.js");;/* empty css */;/* empty css */const r=require("react"),ve=require("../../_virtual/index.cjs.js"),ye=require("./utils/sanitize-invalid-tag-name.cjs.js"),Re=require("./utils/strip-svg-text-line-breaks.cjs.js");;/* empty css */;/* empty css */const be=require("./CodeBlock.cjs.js"),Te=require("./plugins/CustomVariable.cjs.js"),G=require("./plugins/MermaidChart.cjs.js"),oe=require("./utils/custom-variable-props.cjs.js"),ie=require("./utils/highlight-languages.cjs.js"),X=require("./utils/mermaid-parse.cjs.js"),ae=require("./utils/normalize-inline-html.cjs.js"),we=require("./IframeSandbox.cjs.js"),Ee=require("./utils/split-content.cjs.js"),Ne=require("../../lib/interaction-defaults.cjs.js"),ke=require("./contentRenderI18n.cjs.js"),Se=require("../../node_modules/react-markdown/lib/index.cjs.js"),Be=require("../../node_modules/rehype-raw/lib/index.cjs.js"),Ce=require("../../node_modules/rehype-highlight/lib/index.cjs.js"),qe=require("../../node_modules/rehype-katex/lib/index.cjs.js"),Le=require("../../node_modules/remark-gfm/lib/index.cjs.js"),Me=require("../../node_modules/remark-math/lib/index.cjs.js"),$e=require("../../node_modules/remark-breaks/lib/index.cjs.js"),Ae=/<(script|style|link|iframe|html|head|body|meta|title|base|template|div|section|article|main)\b/i,ce=({svg:n})=>{const i=r.useRef(null);return r.useEffect(()=>{const a=i.current;if(!a)return;const c=a.shadowRoot??a.attachShadow({mode:"open"}),N="content-render-svg-style";let p=c.getElementById(N);p||(p=document.createElement("style"),p.id=N,p.textContent=`
2
2
  svg { height: auto; display: inline-block; }
3
3
  svg.content-render-svg-el--responsive { width: 100%; max-width: 100%; }
4
4
  svg.content-render-svg-el--fixed { max-width: none; }
5
- `,c.appendChild(f)),Array.from(c.childNodes).filter(r=>r!==f).forEach(r=>c.removeChild(r));const E=document.createElement("template"),j=pe.stripSvgTextLineBreaks(n);E.innerHTML=j,c.append(E.content.cloneNode(!0));let N=!1,S=!1;c.querySelectorAll("svg").forEach(r=>{const q=r.getAttribute("viewBox");if(!q)return;const T=q.trim().split(/[\s,]+/).map(u=>Number(u));if(T.length!==4||T.some(Number.isNaN))return;const[,,R,v]=T,y=r.getAttribute("width"),b=r.getAttribute("height"),L=u=>{if(!u)return!1;const x=u.trim().toLowerCase();return x==="auto"||x.endsWith("%")},M=u=>{if(!u)return null;const x=u.trim().toLowerCase();if(x==="auto"||x.endsWith("%"))return null;const p=Number.parseFloat(x);return Number.isNaN(p)?null:p},z=L(y),I=L(b),$=!y||y==="0",B=!b||b==="0",G=M(y),l=M(b);if(z||I||$&&B||G===R&&l===v){N=!0,r.classList.add("content-render-svg-el--responsive"),r.classList.remove("content-render-svg-el--fixed"),r.style.width="100%",r.style.height="auto",!r.style.aspectRatio&&v>0&&(r.style.aspectRatio=`${R} / ${v}`);return}S=!0,r.classList.add("content-render-svg-el--fixed"),r.classList.remove("content-render-svg-el--responsive"),$&&R>0&&r.setAttribute("width",`${R}`),B&&v>0&&r.setAttribute("height",`${v}`)});const C=N&&!S;a.classList.toggle("content-render-svg--responsive",C),a.classList.toggle("content-render-svg--fixed",!C)},[n]),t.jsxRuntimeExports.jsx("div",{className:"content-render-svg-scroll",children:t.jsxRuntimeExports.jsx("div",{className:"content-render-svg",ref:i})})},Se=[Ee.default,Ne.default,me.default,Te.default],Ce=[Z.preserveCustomVariableProperties,ye.default,xe.sanitizeInvalidTagName,Z.restoreCustomVariableProperties,[be.default,{languages:ee.highlightLanguages,subset:ee.subsetLanguages}],we.default],U=({content:n,components:i})=>t.jsxRuntimeExports.jsx("div",{className:"markdown-renderer",children:t.jsxRuntimeExports.jsx(Re.Markdown,{remarkPlugins:Se,rehypePlugins:Ce,components:i,children:n})}),qe=n=>{if(n.length<=1)return n;const i=[];return n.forEach(a=>{if(a.type==="sandbox"){i.push(a);return}const c=i[i.length-1];if(c&&c.type!=="sandbox"){i[i.length-1]={type:"markdown",value:`${c.value}${a.value}`};return}i.push({type:"markdown",value:a.value})}),i},Le=(n,i)=>{const a=Math.max(1,i),c=Array.from(n);return{chunk:c.slice(0,a).join(""),rest:c.slice(a).join("")}},Me=({content:n,contentType:i,customRenderBar:a,onSend:c,typingSpeed:k=40,enableTypewriter:f=!1,onTypeFinished:A,onTypewriterStateChange:E,userInput:j,interactionDefaultValueOptions:N,defaultButtonText:S,defaultInputText:C,defaultSelectedValues:r,readonly:q=!1,confirmButtonText:T,copyButtonText:R,copiedButtonText:v,sandboxLoadingText:y,sandboxStyleLoadingText:b,sandboxScriptLoadingText:L,disableSandboxLoadingOverlay:M=!1,sandboxFullscreenButtonText:z,sandboxMode:I="content",onClickCustomButtonAfterContent:$,beforeSend:B})=>{const l=!!f&&(!i||i==="text"),V=2,P=Math.max(0,k),[u,x]=o.useState(()=>l?"":n),p=o.useRef(""),X=o.useRef(l),H=o.useRef(!1);o.useEffect(()=>{const e=X.current;if(X.current=l,H.current=!1,!l){p.current="",x(n);return}x(s=>{const d=!e,g=n.startsWith(s);if(!d&&!g)return p.current="",n;const m=d||!g?"":s;return p.current=n.slice(m.length),m})},[n,l]),o.useEffect(()=>{l&&(H.current||p.current||u!==n||(H.current=!0,A?.()))},[n,u,l,A]),o.useEffect(()=>{if(!l||!p.current)return;const e=window.setTimeout(()=>{x(s=>{const{chunk:d,rest:g}=Le(p.current,V);return d?(p.current=g,`${s}${d}`):s})},P);return()=>window.clearTimeout(e)},[n,u,l,V,P]);const J=o.useMemo(()=>({isTypewriterEnabled:l,isTyping:l&&u!==n,isComplete:u===n,renderedLength:u.length,totalLength:n.length}),[n,u,l]);o.useEffect(()=>{E?.(J)},[E,J]);const h=l?u:n,D=o.useMemo(()=>te.normalizeInlineHtml(h),[h]),W=o.useMemo(()=>ve.getInteractionDefaultValues(h,j,N),[N,h,j]),se=S?.trim()||W.buttonText,re=C?.trim()||W.inputText,oe=o.useMemo(()=>j?j.split(",").map(e=>e.trim()).filter(Boolean):void 0,[j]),ie=r?.length?r:W.selectedValues||oe,K={"custom-button-after-content":({children:e})=>t.jsxRuntimeExports.jsx("button",{className:"content-render-custom-button-after-content",onClick:$,children:t.jsxRuntimeExports.jsx("span",{className:"content-render-custom-button-after-content-inner",children:e})}),"custom-variable":e=>t.jsxRuntimeExports.jsx(fe.default,{...e,readonly:q,defaultButtonText:se,defaultInputText:re,defaultSelectedValues:ie,onSend:c,beforeSend:B,confirmButtonText:T}),code:e=>{const{className:s,children:d,...g}=e;if(/language-(\w+)/.exec(s||"")?.[1]==="mermaid"){const w=d?.toString().replace(/\n$/,"")||"",de=O.mermaidBlockIsComplete(h,w);return t.jsxRuntimeExports.jsx(F.default,{chart:w,frozen:de})}return t.jsxRuntimeExports.jsx("code",{className:s,...g,children:d})},table:({...e})=>t.jsxRuntimeExports.jsx("div",{className:"content-render-table-container",children:t.jsxRuntimeExports.jsx("table",{className:"content-render-table",...e})}),th:({...e})=>t.jsxRuntimeExports.jsx("th",{className:"content-render-th",...e}),td:({...e})=>t.jsxRuntimeExports.jsx("td",{className:"content-render-td",...e}),tr:({...e})=>t.jsxRuntimeExports.jsx("tr",{className:"content-render-tr",...e}),li:({node:e,...s})=>{const d=e?.properties?.className;return typeof d=="string"&&d.includes("task-list-item")||Array.isArray(d)&&d.includes("task-list-item")?t.jsxRuntimeExports.jsx("li",{className:"content-render-task-list-item",...s}):t.jsxRuntimeExports.jsx("li",{...s})},ol:({...e})=>t.jsxRuntimeExports.jsx("ol",{className:"content-render-ol",...e}),ul:({...e})=>t.jsxRuntimeExports.jsx("ul",{className:"content-render-ul",...e}),input:({...e})=>e.type==="checkbox"?t.jsxRuntimeExports.jsx("input",{type:"checkbox",className:"content-render-checkbox",disabled:!0,...e}):t.jsxRuntimeExports.jsx("input",{...e}),a:({children:e,...s})=>t.jsxRuntimeExports.jsx("a",{target:"_blank",rel:"noopener noreferrer",...s,children:e}),pre:e=>t.jsxRuntimeExports.jsx(he.default,{...e,copyButtonText:R,copiedButtonText:v})},Q=o.useMemo(()=>ke.test(h),[h]),_=o.useMemo(()=>Q?je.splitContentSegments(h,!0):[],[h,Q]),ae=_.some(e=>e.type==="sandbox"),ce=o.useMemo(()=>qe(_),[_]),ue=o.useMemo(()=>O.parseMarkdownSegments(D),[D]),le=(e,s)=>{const d=te.normalizeInlineHtml(e);return O.parseMarkdownSegments(d).map((m,Y)=>{const w=`${s}-${m.type}-${Y}`;return m.type==="text"?t.jsxRuntimeExports.jsx(U,{components:K,content:m.value},w):m.type==="mermaid"?t.jsxRuntimeExports.jsx(F.default,{chart:m.value,frozen:!m.complete},w):m.type==="svg"?t.jsxRuntimeExports.jsx(ne,{svg:m.value},w):null})};return ae?t.jsxRuntimeExports.jsx("div",{className:"content-render markdown-body",children:ce.map((e,s)=>e.type==="sandbox"?t.jsxRuntimeExports.jsx(ge.default,{hideFullScreen:!0,type:"sandbox",content:e.value,className:"content-render-iframe",loadingText:y,styleLoadingText:b,scriptLoadingText:L,disableLoadingOverlay:M,fullScreenButtonText:z,mode:I},`sandbox-${s}`):t.jsxRuntimeExports.jsx(o.Fragment,{children:le(e.value,`md-${s}`)},`md-${s}`))}):t.jsxRuntimeExports.jsxs("div",{className:"content-render markdown-body",children:[ue.map((e,s)=>{if(e.type==="text")return t.jsxRuntimeExports.jsx(U,{components:K,content:e.value},s);if(e.type==="mermaid")return t.jsxRuntimeExports.jsx(F.default,{chart:e.value,frozen:!e.complete},s);if(e.type==="svg")return t.jsxRuntimeExports.jsx(ne,{svg:e.value},s)}),a&&t.jsxRuntimeExports.jsx("div",{className:"content-render-custom-bar",children:o.createElement(a,{content:n,displayContent:D,onSend:c})})]})};exports.MarkdownRenderer=U;exports.default=Me;
5
+ `,c.appendChild(p)),Array.from(c.childNodes).filter(o=>o!==p).forEach(o=>c.removeChild(o));const k=document.createElement("template"),q=Re.stripSvgTextLineBreaks(n);k.innerHTML=q,c.append(k.content.cloneNode(!0));let h=!1,S=!1;c.querySelectorAll("svg").forEach(o=>{const B=o.getAttribute("viewBox");if(!B)return;const C=B.trim().split(/[\s,]+/).map(m=>Number(m));if(C.length!==4||C.some(Number.isNaN))return;const[,,R,v]=C,b=o.getAttribute("width"),T=o.getAttribute("height"),M=m=>{if(!m)return!1;const f=m.trim().toLowerCase();return f==="auto"||f.endsWith("%")},$=m=>{if(!m)return null;const f=m.trim().toLowerCase();if(f==="auto"||f.endsWith("%"))return null;const I=Number.parseFloat(f);return Number.isNaN(I)?null:I},V=M(b),F=M(T),A=!b||b==="0",z=!T||T==="0",P=$(b),H=$(T);if(V||F||A&&z||P===R&&H===v){h=!0,o.classList.add("content-render-svg-el--responsive"),o.classList.remove("content-render-svg-el--fixed"),o.style.width="100%",o.style.height="auto",!o.style.aspectRatio&&v>0&&(o.style.aspectRatio=`${R} / ${v}`);return}S=!0,o.classList.add("content-render-svg-el--fixed"),o.classList.remove("content-render-svg-el--responsive"),A&&R>0&&o.setAttribute("width",`${R}`),z&&v>0&&o.setAttribute("height",`${v}`)});const L=h&&!S;a.classList.toggle("content-render-svg--responsive",L),a.classList.toggle("content-render-svg--fixed",!L)},[n]),t.jsxRuntimeExports.jsx("div",{className:"content-render-svg-scroll",children:t.jsxRuntimeExports.jsx("div",{className:"content-render-svg",ref:i})})},ze=[Le.default,Me.default,ve.default,$e.default],Ie=[oe.preserveCustomVariableProperties,Be.default,ye.sanitizeInvalidTagName,oe.restoreCustomVariableProperties,[Ce.default,{languages:ie.highlightLanguages,subset:ie.subsetLanguages}],qe.default],J=({content:n,components:i})=>t.jsxRuntimeExports.jsx("div",{className:"markdown-renderer",children:t.jsxRuntimeExports.jsx(Se.Markdown,{remarkPlugins:ze,rehypePlugins:Ie,components:i,children:n})}),Ve=n=>{if(n.length<=1)return n;const i=[];return n.forEach(a=>{if(a.type==="sandbox"){i.push(a);return}const c=i[i.length-1];if(c&&c.type!=="sandbox"){i[i.length-1]={type:"markdown",value:`${c.value}${a.value}`};return}i.push({type:"markdown",value:a.value})}),i},Fe=(n,i)=>{const a=Math.max(1,i),c=Array.from(n);return{chunk:c.slice(0,a).join(""),rest:c.slice(a).join("")}},Pe=({content:n,contentType:i,locale:a,customRenderBar:c,onSend:N,typingSpeed:p=40,enableTypewriter:K=!1,onTypeFinished:k,onTypewriterStateChange:q,userInput:h,interactionDefaultValueOptions:S,defaultButtonText:L,defaultInputText:o,defaultSelectedValues:B,readonly:C=!1,confirmButtonText:R,copyButtonText:v,copiedButtonText:b,sandboxLoadingText:T,sandboxStyleLoadingText:M,sandboxScriptLoadingText:$,disableSandboxLoadingOverlay:V=!1,sandboxFullscreenButtonText:F,sandboxExitFullscreenButtonText:A,sandboxMode:z="content",onClickCustomButtonAfterContent:P,beforeSend:H})=>{const w=ke.getContentRenderLocaleTexts(a),Q=R||w.confirmButtonText,m=v||w.copyButtonText,f=b||w.copiedButtonText,I=F||w.sandboxFullscreenButtonText,ue=A||w.sandboxExitFullscreenButtonText,l=!!K&&(!i||i==="text"),Y=2,Z=Math.max(0,p),[g,D]=r.useState(()=>l?"":n),y=r.useRef(""),ee=r.useRef(l),W=r.useRef(!1);r.useEffect(()=>{const e=ee.current;if(ee.current=l,W.current=!1,!l){y.current="",D(n);return}D(s=>{const u=!e,j=n.startsWith(s);if(!u&&!j)return y.current="",n;const d=u||!j?"":s;return y.current=n.slice(d.length),d})},[n,l]),r.useEffect(()=>{l&&(W.current||y.current||g!==n||(W.current=!0,k?.()))},[n,g,l,k]),r.useEffect(()=>{if(!l||!y.current)return;const e=window.setTimeout(()=>{D(s=>{const{chunk:u,rest:j}=Fe(y.current,Y);return u?(y.current=j,`${s}${u}`):s})},Z);return()=>window.clearTimeout(e)},[n,g,l,Y,Z]);const te=r.useMemo(()=>({isTypewriterEnabled:l,isTyping:l&&g!==n,isComplete:g===n,renderedLength:g.length,totalLength:n.length}),[n,g,l]);r.useEffect(()=>{q?.(te)},[q,te]);const x=l?g:n,_=r.useMemo(()=>ae.normalizeInlineHtml(x),[x]),O=r.useMemo(()=>Ne.getInteractionDefaultValues(x,h,S),[S,x,h]),le=L?.trim()||O.buttonText,de=o?.trim()||O.inputText,me=r.useMemo(()=>h?h.split(",").map(e=>e.trim()).filter(Boolean):void 0,[h]),xe=B?.length?B:O.selectedValues||me,ne={"custom-button-after-content":({children:e})=>t.jsxRuntimeExports.jsx("button",{className:"content-render-custom-button-after-content",onClick:P,children:t.jsxRuntimeExports.jsx("span",{className:"content-render-custom-button-after-content-inner",children:e})}),"custom-variable":e=>t.jsxRuntimeExports.jsx(Te.default,{...e,readonly:C,defaultButtonText:le,defaultInputText:de,defaultSelectedValues:xe,onSend:N,beforeSend:H,locale:a,confirmButtonText:Q}),code:e=>{const{className:s,children:u,...j}=e;if(/language-(\w+)/.exec(s||"")?.[1]==="mermaid"){const E=u?.toString().replace(/\n$/,"")||"",je=X.mermaidBlockIsComplete(x,E);return t.jsxRuntimeExports.jsx(G.default,{chart:E,frozen:je})}return t.jsxRuntimeExports.jsx("code",{className:s,...j,children:u})},table:({...e})=>t.jsxRuntimeExports.jsx("div",{className:"content-render-table-container",children:t.jsxRuntimeExports.jsx("table",{className:"content-render-table",...e})}),th:({...e})=>t.jsxRuntimeExports.jsx("th",{className:"content-render-th",...e}),td:({...e})=>t.jsxRuntimeExports.jsx("td",{className:"content-render-td",...e}),tr:({...e})=>t.jsxRuntimeExports.jsx("tr",{className:"content-render-tr",...e}),li:({node:e,...s})=>{const u=e?.properties?.className;return typeof u=="string"&&u.includes("task-list-item")||Array.isArray(u)&&u.includes("task-list-item")?t.jsxRuntimeExports.jsx("li",{className:"content-render-task-list-item",...s}):t.jsxRuntimeExports.jsx("li",{...s})},ol:({...e})=>t.jsxRuntimeExports.jsx("ol",{className:"content-render-ol",...e}),ul:({...e})=>t.jsxRuntimeExports.jsx("ul",{className:"content-render-ul",...e}),input:({...e})=>e.type==="checkbox"?t.jsxRuntimeExports.jsx("input",{type:"checkbox",className:"content-render-checkbox",disabled:!0,...e}):t.jsxRuntimeExports.jsx("input",{...e}),a:({children:e,...s})=>t.jsxRuntimeExports.jsx("a",{target:"_blank",rel:"noopener noreferrer",...s,children:e}),pre:e=>t.jsxRuntimeExports.jsx(be.default,{...e,copyButtonText:m,copiedButtonText:f})},se=r.useMemo(()=>Ae.test(x),[x]),U=r.useMemo(()=>se?Ee.splitContentSegments(x,!0):[],[x,se]),pe=U.some(e=>e.type==="sandbox"),he=r.useMemo(()=>Ve(U),[U]),fe=r.useMemo(()=>X.parseMarkdownSegments(_),[_]),ge=(e,s)=>{const u=ae.normalizeInlineHtml(e);return X.parseMarkdownSegments(u).map((d,re)=>{const E=`${s}-${d.type}-${re}`;return d.type==="text"?t.jsxRuntimeExports.jsx(J,{components:ne,content:d.value},E):d.type==="mermaid"?t.jsxRuntimeExports.jsx(G.default,{chart:d.value,frozen:!d.complete},E):d.type==="svg"?t.jsxRuntimeExports.jsx(ce,{svg:d.value},E):null})};return pe?t.jsxRuntimeExports.jsx("div",{className:"content-render markdown-body",children:he.map((e,s)=>e.type==="sandbox"?t.jsxRuntimeExports.jsx(we.default,{hideFullScreen:!0,type:"sandbox",content:e.value,className:"content-render-iframe",locale:a,loadingText:T,styleLoadingText:M,scriptLoadingText:$,disableLoadingOverlay:V,fullScreenButtonText:I,exitFullScreenButtonText:ue,mode:z},`sandbox-${s}`):t.jsxRuntimeExports.jsx(r.Fragment,{children:ge(e.value,`md-${s}`)},`md-${s}`))}):t.jsxRuntimeExports.jsxs("div",{className:"content-render markdown-body",children:[fe.map((e,s)=>{if(e.type==="text")return t.jsxRuntimeExports.jsx(J,{components:ne,content:e.value},s);if(e.type==="mermaid")return t.jsxRuntimeExports.jsx(G.default,{chart:e.value,frozen:!e.complete},s);if(e.type==="svg")return t.jsxRuntimeExports.jsx(ce,{svg:e.value},s)}),c&&t.jsxRuntimeExports.jsx("div",{className:"content-render-custom-bar",children:r.createElement(c,{content:n,displayContent:_,onSend:N})})]})};exports.MarkdownRenderer=J;exports.default=Pe;
6
6
  //# sourceMappingURL=ContentRender.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ContentRender.cjs.js","sources":["../../../src/components/ContentRender/ContentRender.tsx"],"sourcesContent":["import \"highlight.js/styles/github.css\";\nimport \"katex/dist/katex.min.css\";\nimport React, { useEffect, useMemo, useRef, useState } from \"react\";\nimport ReactMarkdown from \"react-markdown\";\nimport rehypeHighlight from \"rehype-highlight\";\nimport rehypeKatex from \"rehype-katex\";\nimport rehypeRaw from \"rehype-raw\";\nimport remarkBreaks from \"remark-breaks\";\nimport remarkFlow from \"remark-flow\";\nimport remarkGfm from \"remark-gfm\";\nimport remarkMath from \"remark-math\";\nimport { CustomRenderBarProps, OnSendContentParams } from \"../types\";\nimport { sanitizeInvalidTagName } from \"./utils/sanitize-invalid-tag-name\";\nimport { stripSvgTextLineBreaks } from \"./utils/strip-svg-text-line-breaks\";\nimport \"./contentRender.css\";\nimport \"./github-markdown-light.css\";\nimport CodeBlock from \"./CodeBlock\";\nimport CustomButtonInputVariable, {\n ComponentsWithCustomVariable,\n} from \"./plugins/CustomVariable\";\nimport MermaidChart from \"./plugins/MermaidChart\";\nimport {\n preserveCustomVariableProperties,\n restoreCustomVariableProperties,\n} from \"./utils/custom-variable-props\";\nimport {\n highlightLanguages,\n subsetLanguages,\n} from \"./utils/highlight-languages\";\n// import { processMarkdownText } from \"./utils/process-markdown\";\nimport {\n parseMarkdownSegments,\n mermaidBlockIsComplete,\n} from \"./utils/mermaid-parse\";\nimport { normalizeInlineHtml } from \"./utils/normalize-inline-html\";\nimport IframeSandbox from \"./IframeSandbox\";\nimport {\n splitContentSegments,\n type RenderSegment,\n} from \"./utils/split-content\";\nimport {\n getInteractionDefaultValues,\n type InteractionDefaultValueOptions,\n} from \"../../lib/interaction-defaults\";\n\nconst SANDBOX_TAG_HINT_PATTERN =\n /<(script|style|link|iframe|html|head|body|meta|title|base|template|div|section|article|main)\\b/i;\n\n// Define component Props type\nexport interface ContentRenderProps {\n content: string;\n contentType?: string;\n /**\n * Callback invoked when the custom button after content is clicked.\n * This button is rendered via the `<custom-button-after-content>` tag in markdown content.\n * @example\n * ```tsx\n * <ContentRender\n * content=\"Hello <custom-button-after-content>Ask</custom-button-after-content>\"\n * onClickCustomButtonAfterContent={() => console.log('Button clicked')}\n * />\n * ```\n */\n customRenderBar?: CustomRenderBarProps;\n onClickCustomButtonAfterContent?: () => void;\n onSend?: (content: OnSendContentParams) => void;\n typingSpeed?: number;\n enableTypewriter?: boolean;\n onTypeFinished?: () => void;\n onTypewriterStateChange?: (state: ContentRenderTypewriterState) => void;\n userInput?: string;\n interactionDefaultValueOptions?: InteractionDefaultValueOptions;\n defaultButtonText?: string;\n defaultInputText?: string; // Text input by user\n defaultSelectedValues?: string[]; // Default selected values for multi-select\n readonly?: boolean;\n // Multi-select confirm button text (i18n support)\n confirmButtonText?: string;\n // Copy button text (i18n support)\n copyButtonText?: string;\n // Copied state text (i18n support)\n copiedButtonText?: string;\n // Dynamic interaction format for multi-select support\n dynamicInteractionFormat?: string;\n // Loading text before first HTML block renders inside iframe (i18n support)\n sandboxLoadingText?: string;\n // Loading text while styles are being generated inside iframe\n sandboxStyleLoadingText?: string;\n // Loading text while scripts are being cached/executed inside iframe\n sandboxScriptLoadingText?: string;\n // Disable sandbox loading overlays when upper layers have already entered an error state\n disableSandboxLoadingOverlay?: boolean;\n // Fullscreen button text for iframe sandbox\n sandboxFullscreenButtonText?: string;\n // Sandbox render mode\n sandboxMode?: \"content\" | \"blackboard\";\n beforeSend?: (param: OnSendContentParams) => boolean;\n // tooltipMinLength?: number; // Control minimum character length for tooltip display, default 10\n}\n\nexport interface ContentRenderTypewriterState {\n isTypewriterEnabled: boolean;\n isTyping: boolean;\n isComplete: boolean;\n renderedLength: number;\n totalLength: number;\n}\n\n// Render svg string via Shadow DOM to avoid markdown wrapping\nconst SvgBlockInShadow: React.FC<{ svg: string }> = ({ svg }) => {\n const hostRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n const host = hostRef.current;\n if (!host) return;\n const shadowRoot = host.shadowRoot ?? host.attachShadow({ mode: \"open\" });\n const styleId = \"content-render-svg-style\";\n let styleEl = shadowRoot.getElementById(styleId) as HTMLStyleElement | null;\n\n if (!styleEl) {\n styleEl = document.createElement(\"style\");\n styleEl.id = styleId;\n // Keep intrinsic SVG width so the wrapper can scroll horizontally when needed\n styleEl.textContent = `\n svg { height: auto; display: inline-block; }\n svg.content-render-svg-el--responsive { width: 100%; max-width: 100%; }\n svg.content-render-svg-el--fixed { max-width: none; }\n `;\n shadowRoot.appendChild(styleEl);\n }\n\n const nodesToRemove = Array.from(shadowRoot.childNodes).filter(\n (node) => node !== styleEl\n );\n nodesToRemove.forEach((node) => shadowRoot.removeChild(node));\n\n const template = document.createElement(\"template\");\n const cleanedSvg = stripSvgTextLineBreaks(svg);\n template.innerHTML = cleanedSvg;\n shadowRoot.append(template.content.cloneNode(true));\n\n let hasResponsiveSvg = false;\n let hasFixedSvg = false;\n\n shadowRoot.querySelectorAll(\"svg\").forEach((svgEl) => {\n // Derive responsive sizing from viewBox so pure viewBox SVGs stay visible and fluid\n const viewBox = svgEl.getAttribute(\"viewBox\");\n if (!viewBox) return;\n\n const dimensions = viewBox\n .trim()\n .split(/[\\s,]+/)\n .map((value) => Number(value));\n\n if (dimensions.length !== 4 || dimensions.some(Number.isNaN)) return;\n\n const [, , viewBoxWidth, viewBoxHeight] = dimensions;\n const widthAttr = svgEl.getAttribute(\"width\");\n const heightAttr = svgEl.getAttribute(\"height\");\n const isRelativeLength = (value?: string | null) => {\n if (!value) return false;\n const normalized = value.trim().toLowerCase();\n return normalized === \"auto\" || normalized.endsWith(\"%\");\n };\n const toNumericLength = (value?: string | null) => {\n if (!value) return null;\n const normalized = value.trim().toLowerCase();\n if (normalized === \"auto\" || normalized.endsWith(\"%\")) {\n return null;\n }\n const parsed = Number.parseFloat(normalized);\n return Number.isNaN(parsed) ? null : parsed;\n };\n // Treat percentage/auto sizing as responsive so viewBox drives the layout\n const isWidthRelative = isRelativeLength(widthAttr);\n const isHeightRelative = isRelativeLength(heightAttr);\n const widthMissing = !widthAttr || widthAttr === \"0\";\n const heightMissing = !heightAttr || heightAttr === \"0\";\n const numericWidth = toNumericLength(widthAttr);\n const numericHeight = toNumericLength(heightAttr);\n const matchesViewBox =\n numericWidth === viewBoxWidth && numericHeight === viewBoxHeight;\n\n // Prefer responsive layout when sizing is relative or matches the viewBox\n const shouldUseResponsiveSize =\n isWidthRelative ||\n isHeightRelative ||\n (widthMissing && heightMissing) ||\n matchesViewBox;\n\n if (shouldUseResponsiveSize) {\n hasResponsiveSvg = true;\n svgEl.classList.add(\"content-render-svg-el--responsive\");\n svgEl.classList.remove(\"content-render-svg-el--fixed\");\n svgEl.style.width = \"100%\";\n svgEl.style.height = \"auto\";\n if (!svgEl.style.aspectRatio && viewBoxHeight > 0) {\n svgEl.style.aspectRatio = `${viewBoxWidth} / ${viewBoxHeight}`;\n }\n return;\n }\n\n hasFixedSvg = true;\n svgEl.classList.add(\"content-render-svg-el--fixed\");\n svgEl.classList.remove(\"content-render-svg-el--responsive\");\n if (widthMissing && viewBoxWidth > 0) {\n svgEl.setAttribute(\"width\", `${viewBoxWidth}`);\n }\n if (heightMissing && viewBoxHeight > 0) {\n svgEl.setAttribute(\"height\", `${viewBoxHeight}`);\n }\n });\n\n const hostResponsive = hasResponsiveSvg && !hasFixedSvg;\n host.classList.toggle(\"content-render-svg--responsive\", hostResponsive);\n host.classList.toggle(\"content-render-svg--fixed\", !hostResponsive);\n }, [svg]);\n\n return (\n <div className=\"content-render-svg-scroll\">\n <div className=\"content-render-svg\" ref={hostRef} />\n </div>\n );\n};\n\n// Extended component interface\ntype CustomComponents = ComponentsWithCustomVariable & {\n \"custom-button-after-content\"?: React.ComponentType<{\n children: React.ReactNode;\n }>;\n};\n\nconst remarkPlugins = [remarkGfm, remarkMath, remarkFlow, remarkBreaks];\n\nconst rehypePlugins = [\n preserveCustomVariableProperties,\n rehypeRaw,\n sanitizeInvalidTagName,\n restoreCustomVariableProperties,\n [rehypeHighlight, { languages: highlightLanguages, subset: subsetLanguages }],\n rehypeKatex,\n];\n\nexport const MarkdownRenderer: React.FC<{\n content: string;\n components: CustomComponents;\n}> = ({ content: markdownContent, components }) => (\n <div className=\"markdown-renderer\">\n <ReactMarkdown\n remarkPlugins={remarkPlugins}\n rehypePlugins={rehypePlugins}\n components={components}\n >\n {markdownContent}\n </ReactMarkdown>\n </div>\n);\n\nconst mergeNonSandboxSegments = (segments: RenderSegment[]) => {\n if (segments.length <= 1) return segments;\n const merged: RenderSegment[] = [];\n\n segments.forEach((segment) => {\n if (segment.type === \"sandbox\") {\n merged.push(segment);\n return;\n }\n\n const last = merged[merged.length - 1];\n if (last && last.type !== \"sandbox\") {\n merged[merged.length - 1] = {\n type: \"markdown\",\n value: `${last.value}${segment.value}`,\n };\n return;\n }\n\n merged.push({ type: \"markdown\", value: segment.value });\n });\n\n return merged;\n};\n\nconst splitTextByCharacterChunk = (value: string, chunkSize: number) => {\n const safeChunkSize = Math.max(1, chunkSize);\n const characters = Array.from(value);\n\n return {\n chunk: characters.slice(0, safeChunkSize).join(\"\"),\n rest: characters.slice(safeChunkSize).join(\"\"),\n };\n};\n\nconst ContentRender: React.FC<ContentRenderProps> = ({\n content,\n contentType,\n customRenderBar,\n onSend,\n typingSpeed = 40,\n enableTypewriter = false,\n onTypeFinished,\n onTypewriterStateChange,\n userInput,\n interactionDefaultValueOptions,\n defaultButtonText,\n defaultInputText,\n defaultSelectedValues,\n readonly = false,\n confirmButtonText,\n copyButtonText,\n copiedButtonText,\n sandboxLoadingText,\n sandboxStyleLoadingText,\n sandboxScriptLoadingText,\n disableSandboxLoadingOverlay = false,\n sandboxFullscreenButtonText,\n sandboxMode = \"content\",\n onClickCustomButtonAfterContent,\n beforeSend,\n // tooltipMinLength,\n}) => {\n const shouldApplyTypewriterByContentType =\n !contentType || contentType === \"text\";\n const isTypewriterEnabled =\n Boolean(enableTypewriter) && shouldApplyTypewriterByContentType;\n const typewriterChunkSize = 2;\n const typewriterTickMs = Math.max(0, typingSpeed);\n const [displayContent, setDisplayContent] = useState(() =>\n isTypewriterEnabled ? \"\" : content\n );\n const pendingContentRef = useRef(\"\");\n const previousTypewriterEnabledRef = useRef(isTypewriterEnabled);\n const hasReportedTypeFinishedRef = useRef(false);\n\n useEffect(() => {\n const wasTypewriterEnabled = previousTypewriterEnabledRef.current;\n previousTypewriterEnabledRef.current = isTypewriterEnabled;\n hasReportedTypeFinishedRef.current = false;\n\n if (!isTypewriterEnabled) {\n pendingContentRef.current = \"\";\n setDisplayContent(content);\n return;\n }\n\n setDisplayContent((current) => {\n const shouldRestartTyping = !wasTypewriterEnabled;\n const canContinueTyping = content.startsWith(current);\n\n if (!shouldRestartTyping && !canContinueTyping) {\n pendingContentRef.current = \"\";\n return content;\n }\n\n const nextVisibleContent =\n shouldRestartTyping || !canContinueTyping ? \"\" : current;\n\n pendingContentRef.current = content.slice(nextVisibleContent.length);\n return nextVisibleContent;\n });\n }, [content, isTypewriterEnabled]);\n\n useEffect(() => {\n if (!isTypewriterEnabled) {\n return;\n }\n\n if (\n hasReportedTypeFinishedRef.current ||\n pendingContentRef.current ||\n displayContent !== content\n ) {\n return;\n }\n\n hasReportedTypeFinishedRef.current = true;\n onTypeFinished?.();\n }, [content, displayContent, isTypewriterEnabled, onTypeFinished]);\n\n useEffect(() => {\n if (!isTypewriterEnabled || !pendingContentRef.current) {\n return undefined;\n }\n\n const typewriterTimer = window.setTimeout(() => {\n setDisplayContent((current) => {\n const { chunk, rest } = splitTextByCharacterChunk(\n pendingContentRef.current,\n typewriterChunkSize\n );\n\n if (!chunk) {\n return current;\n }\n\n pendingContentRef.current = rest;\n return `${current}${chunk}`;\n });\n }, typewriterTickMs);\n\n return () => window.clearTimeout(typewriterTimer);\n }, [\n content,\n displayContent,\n isTypewriterEnabled,\n typewriterChunkSize,\n typewriterTickMs,\n ]);\n\n const typewriterState = useMemo<ContentRenderTypewriterState>(\n () => ({\n isTypewriterEnabled,\n isTyping: isTypewriterEnabled && displayContent !== content,\n isComplete: displayContent === content,\n renderedLength: displayContent.length,\n totalLength: content.length,\n }),\n [content, displayContent, isTypewriterEnabled]\n );\n\n useEffect(() => {\n onTypewriterStateChange?.(typewriterState);\n }, [onTypewriterStateChange, typewriterState]);\n\n const renderContent = isTypewriterEnabled ? displayContent : content;\n const normalizedContent = useMemo(\n () => normalizeInlineHtml(renderContent),\n [renderContent]\n );\n\n const interactionDefaults = useMemo(\n () =>\n getInteractionDefaultValues(\n renderContent,\n userInput,\n interactionDefaultValueOptions\n ),\n [interactionDefaultValueOptions, renderContent, userInput]\n );\n\n const resolvedDefaultButtonText =\n defaultButtonText?.trim() || interactionDefaults.buttonText;\n const resolvedDefaultInputText =\n defaultInputText?.trim() || interactionDefaults.inputText;\n const fallbackSelectedValues = useMemo(\n () =>\n userInput\n ? userInput\n .split(\",\")\n .map((value) => value.trim())\n .filter(Boolean)\n : undefined,\n [userInput]\n );\n const resolvedDefaultSelectedValues = defaultSelectedValues?.length\n ? defaultSelectedValues\n : interactionDefaults.selectedValues || fallbackSelectedValues;\n\n const components: CustomComponents = {\n \"custom-button-after-content\": ({\n children,\n }: {\n children: React.ReactNode;\n }) => {\n return (\n <button\n className=\"content-render-custom-button-after-content\"\n onClick={onClickCustomButtonAfterContent}\n >\n <span className=\"content-render-custom-button-after-content-inner\">\n {children}\n </span>\n </button>\n );\n },\n \"custom-variable\": (props) => (\n <CustomButtonInputVariable\n {...props}\n readonly={readonly}\n defaultButtonText={resolvedDefaultButtonText}\n defaultInputText={resolvedDefaultInputText}\n defaultSelectedValues={resolvedDefaultSelectedValues}\n onSend={onSend}\n beforeSend={beforeSend}\n confirmButtonText={confirmButtonText}\n // tooltipMinLength={tooltipMinLength}\n />\n ),\n code: (props) => {\n const { className, children, ...rest } = props as {\n className?: string;\n children?: React.ReactNode;\n };\n const match = /language-(\\w+)/.exec(className || \"\");\n const language = match?.[1];\n if (language === \"mermaid\") {\n const chartContent = children?.toString().replace(/\\n$/, \"\") || \"\";\n const frozen = mermaidBlockIsComplete(renderContent, chartContent);\n return <MermaidChart chart={chartContent} frozen={frozen} />;\n }\n\n return (\n <code className={className} {...rest}>\n {children}\n </code>\n );\n },\n table: ({ ...props }) => (\n <div className=\"content-render-table-container\">\n <table className=\"content-render-table\" {...props} />\n </div>\n ),\n th: ({ ...props }) => <th className=\"content-render-th\" {...props} />,\n td: ({ ...props }) => <td className=\"content-render-td\" {...props} />,\n tr: ({ ...props }) => <tr className=\"content-render-tr\" {...props} />,\n li: ({ node, ...props }) => {\n const className = node?.properties?.className;\n const hasTaskListItem =\n (typeof className === \"string\" &&\n className.includes(\"task-list-item\")) ||\n (Array.isArray(className) && className.includes(\"task-list-item\"));\n if (hasTaskListItem) {\n return <li className=\"content-render-task-list-item\" {...props} />;\n }\n return <li {...props} />;\n },\n ol: ({ ...props }) => <ol className=\"content-render-ol\" {...props} />,\n ul: ({ ...props }) => <ul className=\"content-render-ul\" {...props} />,\n input: ({ ...props }) => {\n if (props.type === \"checkbox\") {\n return (\n <input\n type=\"checkbox\"\n className=\"content-render-checkbox\"\n disabled\n {...props}\n />\n );\n }\n return <input {...props} />;\n },\n a: ({ children, ...props }) => (\n <a target=\"_blank\" rel=\"noopener noreferrer\" {...props}>\n {children}\n </a>\n ),\n pre: (props) => (\n <CodeBlock\n {...props}\n copyButtonText={copyButtonText}\n copiedButtonText={copiedButtonText}\n />\n ),\n };\n\n const hasPotentialSandboxTags = useMemo(\n () => SANDBOX_TAG_HINT_PATTERN.test(renderContent),\n [renderContent]\n );\n\n const renderSegments = useMemo(\n () =>\n hasPotentialSandboxTags ? splitContentSegments(renderContent, true) : [],\n [renderContent, hasPotentialSandboxTags]\n );\n\n const hasSandbox = renderSegments.some(\n (segment) => segment.type === \"sandbox\"\n );\n const mergedRenderSegments = useMemo(\n () => mergeNonSandboxSegments(renderSegments),\n [renderSegments]\n );\n\n const segments = useMemo(\n () => parseMarkdownSegments(normalizedContent),\n [normalizedContent]\n );\n\n const renderMarkdownSegments = (raw: string, keyPrefix: string) => {\n const normalized = normalizeInlineHtml(raw);\n const parsed = parseMarkdownSegments(normalized);\n\n return parsed.map((seg, index) => {\n const key = `${keyPrefix}-${seg.type}-${index}`;\n\n if (seg.type === \"text\") {\n return (\n <MarkdownRenderer\n key={key}\n components={components}\n content={seg.value}\n />\n );\n }\n\n if (seg.type === \"mermaid\") {\n return (\n <MermaidChart key={key} chart={seg.value} frozen={!seg.complete} />\n );\n }\n\n if (seg.type === \"svg\") {\n return <SvgBlockInShadow key={key} svg={seg.value} />;\n }\n\n return null;\n });\n };\n\n if (hasSandbox) {\n return (\n <div className=\"content-render markdown-body\">\n {mergedRenderSegments.map((segment, idx) =>\n segment.type === \"sandbox\" ? (\n <IframeSandbox\n key={`sandbox-${idx}`}\n hideFullScreen\n type=\"sandbox\"\n content={segment.value}\n className=\"content-render-iframe\"\n loadingText={sandboxLoadingText}\n styleLoadingText={sandboxStyleLoadingText}\n scriptLoadingText={sandboxScriptLoadingText}\n disableLoadingOverlay={disableSandboxLoadingOverlay}\n fullScreenButtonText={sandboxFullscreenButtonText}\n mode={sandboxMode}\n />\n ) : (\n <React.Fragment key={`md-${idx}`}>\n {renderMarkdownSegments(segment.value, `md-${idx}`)}\n </React.Fragment>\n )\n )}\n </div>\n );\n }\n\n return (\n <div className=\"content-render markdown-body\">\n {segments.map((seg, index) => {\n if (seg.type === \"text\") {\n return (\n <MarkdownRenderer\n key={index}\n components={components}\n content={seg.value}\n />\n );\n }\n\n if (seg.type === \"mermaid\") {\n return (\n <MermaidChart\n key={index}\n chart={seg.value}\n frozen={!seg.complete}\n />\n );\n }\n\n if (seg.type === \"svg\") {\n return <SvgBlockInShadow key={index} svg={seg.value} />;\n }\n })}\n\n {customRenderBar && (\n <div className=\"content-render-custom-bar\">\n {React.createElement(customRenderBar, {\n content,\n displayContent: normalizedContent,\n onSend,\n })}\n </div>\n )}\n </div>\n );\n};\n\nexport default ContentRender;\n"],"names":["SANDBOX_TAG_HINT_PATTERN","SvgBlockInShadow","svg","hostRef","useRef","useEffect","host","shadowRoot","styleId","styleEl","node","template","cleanedSvg","stripSvgTextLineBreaks","hasResponsiveSvg","hasFixedSvg","svgEl","viewBox","dimensions","value","viewBoxWidth","viewBoxHeight","widthAttr","heightAttr","isRelativeLength","normalized","toNumericLength","parsed","isWidthRelative","isHeightRelative","widthMissing","heightMissing","numericWidth","numericHeight","hostResponsive","jsx","remarkPlugins","remarkGfm","remarkMath","remarkFlow","remarkBreaks","rehypePlugins","preserveCustomVariableProperties","rehypeRaw","sanitizeInvalidTagName","restoreCustomVariableProperties","rehypeHighlight","highlightLanguages","subsetLanguages","rehypeKatex","MarkdownRenderer","markdownContent","components","ReactMarkdown","mergeNonSandboxSegments","segments","merged","segment","last","splitTextByCharacterChunk","chunkSize","safeChunkSize","characters","ContentRender","content","contentType","customRenderBar","onSend","typingSpeed","enableTypewriter","onTypeFinished","onTypewriterStateChange","userInput","interactionDefaultValueOptions","defaultButtonText","defaultInputText","defaultSelectedValues","readonly","confirmButtonText","copyButtonText","copiedButtonText","sandboxLoadingText","sandboxStyleLoadingText","sandboxScriptLoadingText","disableSandboxLoadingOverlay","sandboxFullscreenButtonText","sandboxMode","onClickCustomButtonAfterContent","beforeSend","isTypewriterEnabled","typewriterChunkSize","typewriterTickMs","displayContent","setDisplayContent","useState","pendingContentRef","previousTypewriterEnabledRef","hasReportedTypeFinishedRef","wasTypewriterEnabled","current","shouldRestartTyping","canContinueTyping","nextVisibleContent","typewriterTimer","chunk","rest","typewriterState","useMemo","renderContent","normalizedContent","normalizeInlineHtml","interactionDefaults","getInteractionDefaultValues","resolvedDefaultButtonText","resolvedDefaultInputText","fallbackSelectedValues","resolvedDefaultSelectedValues","children","props","CustomButtonInputVariable","className","chartContent","frozen","mermaidBlockIsComplete","MermaidChart","CodeBlock","hasPotentialSandboxTags","renderSegments","splitContentSegments","hasSandbox","mergedRenderSegments","parseMarkdownSegments","renderMarkdownSegments","raw","keyPrefix","seg","index","key","idx","IframeSandbox","React","jsxs"],"mappings":"w6CA6CMA,GACJ,kGA+DIC,GAA8C,CA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B,kBAAmBC,EACnB,sBAAuBC,EACvB,qBAAsBC,EACtB,KAAMC,CAAA,EAVD,WAAWoD,CAAG,EAAA,EAarBvG,EAAAA,kBAAAA,IAACyG,EAAM,SAAN,CACE,SAAAR,GAAuB3E,EAAQ,MAAO,MAAMiF,CAAG,EAAE,CAAA,EAD/B,MAAMA,CAAG,EAE9B,CAAA,EAGN,EAKFG,EAAAA,kBAAAA,KAAC,MAAA,CAAI,UAAU,+BACZ,SAAA,CAAAtF,GAAS,IAAI,CAACgF,EAAKC,IAAU,CAC5B,GAAID,EAAI,OAAS,OACf,OACEpG,EAAAA,kBAAAA,IAACe,EAAA,CAEC,WAAAE,EACA,QAASmF,EAAI,KAAA,EAFRC,CAAA,EAOX,GAAID,EAAI,OAAS,UACf,OACEpG,EAAAA,kBAAAA,IAACyF,EAAAA,QAAA,CAEC,MAAOW,EAAI,MACX,OAAQ,CAACA,EAAI,QAAA,EAFRC,CAAA,EAOX,GAAID,EAAI,OAAS,MACf,OAAOpG,EAAAA,kBAAAA,IAAClC,GAAA,CAA6B,IAAKsI,EAAI,OAAhBC,CAAuB,CAEzD,CAAC,EAEAtE,GACC/B,EAAAA,kBAAAA,IAAC,MAAA,CAAI,UAAU,4BACZ,SAAAyG,EAAM,cAAc1E,EAAiB,CACpC,QAAAF,EACA,eAAgB6C,EAChB,OAAA1C,CAAA,CACD,CAAA,CACH,CAAA,EAEJ,CAEJ"}
1
+ {"version":3,"file":"ContentRender.cjs.js","sources":["../../../src/components/ContentRender/ContentRender.tsx"],"sourcesContent":["import \"highlight.js/styles/github.css\";\nimport \"katex/dist/katex.min.css\";\nimport React, { useEffect, useMemo, useRef, useState } from \"react\";\nimport ReactMarkdown from \"react-markdown\";\nimport rehypeHighlight from \"rehype-highlight\";\nimport rehypeKatex from \"rehype-katex\";\nimport rehypeRaw from \"rehype-raw\";\nimport remarkBreaks from \"remark-breaks\";\nimport remarkFlow from \"remark-flow\";\nimport remarkGfm from \"remark-gfm\";\nimport remarkMath from \"remark-math\";\nimport { CustomRenderBarProps, OnSendContentParams } from \"../types\";\nimport { sanitizeInvalidTagName } from \"./utils/sanitize-invalid-tag-name\";\nimport { stripSvgTextLineBreaks } from \"./utils/strip-svg-text-line-breaks\";\nimport \"./contentRender.css\";\nimport \"./github-markdown-light.css\";\nimport CodeBlock from \"./CodeBlock\";\nimport CustomButtonInputVariable, {\n ComponentsWithCustomVariable,\n} from \"./plugins/CustomVariable\";\nimport MermaidChart from \"./plugins/MermaidChart\";\nimport {\n preserveCustomVariableProperties,\n restoreCustomVariableProperties,\n} from \"./utils/custom-variable-props\";\nimport {\n highlightLanguages,\n subsetLanguages,\n} from \"./utils/highlight-languages\";\n// import { processMarkdownText } from \"./utils/process-markdown\";\nimport {\n parseMarkdownSegments,\n mermaidBlockIsComplete,\n} from \"./utils/mermaid-parse\";\nimport { normalizeInlineHtml } from \"./utils/normalize-inline-html\";\nimport IframeSandbox from \"./IframeSandbox\";\nimport {\n splitContentSegments,\n type RenderSegment,\n} from \"./utils/split-content\";\nimport {\n getInteractionDefaultValues,\n type InteractionDefaultValueOptions,\n} from \"../../lib/interaction-defaults\";\nimport type { MarkdownFlowLocale } from \"../../lib/locale\";\nimport { getContentRenderLocaleTexts } from \"./contentRenderI18n\";\n\nconst SANDBOX_TAG_HINT_PATTERN =\n /<(script|style|link|iframe|html|head|body|meta|title|base|template|div|section|article|main)\\b/i;\n\n// Define component Props type\nexport interface ContentRenderProps {\n content: string;\n contentType?: string;\n /** Locale used for built-in UI text when a more specific text prop is not provided. */\n locale?: MarkdownFlowLocale;\n /**\n * Callback invoked when the custom button after content is clicked.\n * This button is rendered via the `<custom-button-after-content>` tag in markdown content.\n * @example\n * ```tsx\n * <ContentRender\n * content=\"Hello <custom-button-after-content>Ask</custom-button-after-content>\"\n * onClickCustomButtonAfterContent={() => console.log('Button clicked')}\n * />\n * ```\n */\n customRenderBar?: CustomRenderBarProps;\n onClickCustomButtonAfterContent?: () => void;\n onSend?: (content: OnSendContentParams) => void;\n typingSpeed?: number;\n enableTypewriter?: boolean;\n onTypeFinished?: () => void;\n onTypewriterStateChange?: (state: ContentRenderTypewriterState) => void;\n userInput?: string;\n interactionDefaultValueOptions?: InteractionDefaultValueOptions;\n defaultButtonText?: string;\n defaultInputText?: string; // Text input by user\n defaultSelectedValues?: string[]; // Default selected values for multi-select\n readonly?: boolean;\n // Multi-select confirm button text (i18n support)\n confirmButtonText?: string;\n // Copy button text (i18n support)\n copyButtonText?: string;\n // Copied state text (i18n support)\n copiedButtonText?: string;\n // Dynamic interaction format for multi-select support\n dynamicInteractionFormat?: string;\n // Loading text before first HTML block renders inside iframe (i18n support)\n sandboxLoadingText?: string;\n // Loading text while styles are being generated inside iframe\n sandboxStyleLoadingText?: string;\n // Loading text while scripts are being cached/executed inside iframe\n sandboxScriptLoadingText?: string;\n // Disable sandbox loading overlays when upper layers have already entered an error state\n disableSandboxLoadingOverlay?: boolean;\n // Fullscreen button text for iframe sandbox\n sandboxFullscreenButtonText?: string;\n // Exit fullscreen button text for iframe sandbox\n sandboxExitFullscreenButtonText?: string;\n // Sandbox render mode\n sandboxMode?: \"content\" | \"blackboard\";\n beforeSend?: (param: OnSendContentParams) => boolean;\n // tooltipMinLength?: number; // Control minimum character length for tooltip display, default 10\n}\n\nexport interface ContentRenderTypewriterState {\n isTypewriterEnabled: boolean;\n isTyping: boolean;\n isComplete: boolean;\n renderedLength: number;\n totalLength: number;\n}\n\n// Render svg string via Shadow DOM to avoid markdown wrapping\nconst SvgBlockInShadow: React.FC<{ svg: string }> = ({ svg }) => {\n const hostRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n const host = hostRef.current;\n if (!host) return;\n const shadowRoot = host.shadowRoot ?? host.attachShadow({ mode: \"open\" });\n const styleId = \"content-render-svg-style\";\n let styleEl = shadowRoot.getElementById(styleId) as HTMLStyleElement | null;\n\n if (!styleEl) {\n styleEl = document.createElement(\"style\");\n styleEl.id = styleId;\n // Keep intrinsic SVG width so the wrapper can scroll horizontally when needed\n styleEl.textContent = `\n svg { height: auto; display: inline-block; }\n svg.content-render-svg-el--responsive { width: 100%; max-width: 100%; }\n svg.content-render-svg-el--fixed { max-width: none; }\n `;\n shadowRoot.appendChild(styleEl);\n }\n\n const nodesToRemove = Array.from(shadowRoot.childNodes).filter(\n (node) => node !== styleEl\n );\n nodesToRemove.forEach((node) => shadowRoot.removeChild(node));\n\n const template = document.createElement(\"template\");\n const cleanedSvg = stripSvgTextLineBreaks(svg);\n template.innerHTML = cleanedSvg;\n shadowRoot.append(template.content.cloneNode(true));\n\n let hasResponsiveSvg = false;\n let hasFixedSvg = false;\n\n shadowRoot.querySelectorAll(\"svg\").forEach((svgEl) => {\n // Derive responsive sizing from viewBox so pure viewBox SVGs stay visible and fluid\n const viewBox = svgEl.getAttribute(\"viewBox\");\n if (!viewBox) return;\n\n const dimensions = viewBox\n .trim()\n .split(/[\\s,]+/)\n .map((value) => Number(value));\n\n if (dimensions.length !== 4 || dimensions.some(Number.isNaN)) return;\n\n const [, , viewBoxWidth, viewBoxHeight] = dimensions;\n const widthAttr = svgEl.getAttribute(\"width\");\n const heightAttr = svgEl.getAttribute(\"height\");\n const isRelativeLength = (value?: string | null) => {\n if (!value) return false;\n const normalized = value.trim().toLowerCase();\n return normalized === \"auto\" || normalized.endsWith(\"%\");\n };\n const toNumericLength = (value?: string | null) => {\n if (!value) return null;\n const normalized = value.trim().toLowerCase();\n if (normalized === \"auto\" || normalized.endsWith(\"%\")) {\n return null;\n }\n const parsed = Number.parseFloat(normalized);\n return Number.isNaN(parsed) ? null : parsed;\n };\n // Treat percentage/auto sizing as responsive so viewBox drives the layout\n const isWidthRelative = isRelativeLength(widthAttr);\n const isHeightRelative = isRelativeLength(heightAttr);\n const widthMissing = !widthAttr || widthAttr === \"0\";\n const heightMissing = !heightAttr || heightAttr === \"0\";\n const numericWidth = toNumericLength(widthAttr);\n const numericHeight = toNumericLength(heightAttr);\n const matchesViewBox =\n numericWidth === viewBoxWidth && numericHeight === viewBoxHeight;\n\n // Prefer responsive layout when sizing is relative or matches the viewBox\n const shouldUseResponsiveSize =\n isWidthRelative ||\n isHeightRelative ||\n (widthMissing && heightMissing) ||\n matchesViewBox;\n\n if (shouldUseResponsiveSize) {\n hasResponsiveSvg = true;\n svgEl.classList.add(\"content-render-svg-el--responsive\");\n svgEl.classList.remove(\"content-render-svg-el--fixed\");\n svgEl.style.width = \"100%\";\n svgEl.style.height = \"auto\";\n if (!svgEl.style.aspectRatio && viewBoxHeight > 0) {\n svgEl.style.aspectRatio = `${viewBoxWidth} / ${viewBoxHeight}`;\n }\n return;\n }\n\n hasFixedSvg = true;\n svgEl.classList.add(\"content-render-svg-el--fixed\");\n svgEl.classList.remove(\"content-render-svg-el--responsive\");\n if (widthMissing && viewBoxWidth > 0) {\n svgEl.setAttribute(\"width\", `${viewBoxWidth}`);\n }\n if (heightMissing && viewBoxHeight > 0) {\n svgEl.setAttribute(\"height\", `${viewBoxHeight}`);\n }\n });\n\n const hostResponsive = hasResponsiveSvg && !hasFixedSvg;\n host.classList.toggle(\"content-render-svg--responsive\", hostResponsive);\n host.classList.toggle(\"content-render-svg--fixed\", !hostResponsive);\n }, [svg]);\n\n return (\n <div className=\"content-render-svg-scroll\">\n <div className=\"content-render-svg\" ref={hostRef} />\n </div>\n );\n};\n\n// Extended component interface\ntype CustomComponents = ComponentsWithCustomVariable & {\n \"custom-button-after-content\"?: React.ComponentType<{\n children: React.ReactNode;\n }>;\n};\n\nconst remarkPlugins = [remarkGfm, remarkMath, remarkFlow, remarkBreaks];\n\nconst rehypePlugins = [\n preserveCustomVariableProperties,\n rehypeRaw,\n sanitizeInvalidTagName,\n restoreCustomVariableProperties,\n [rehypeHighlight, { languages: highlightLanguages, subset: subsetLanguages }],\n rehypeKatex,\n];\n\nexport const MarkdownRenderer: React.FC<{\n content: string;\n components: CustomComponents;\n}> = ({ content: markdownContent, components }) => (\n <div className=\"markdown-renderer\">\n <ReactMarkdown\n remarkPlugins={remarkPlugins}\n rehypePlugins={rehypePlugins}\n components={components}\n >\n {markdownContent}\n </ReactMarkdown>\n </div>\n);\n\nconst mergeNonSandboxSegments = (segments: RenderSegment[]) => {\n if (segments.length <= 1) return segments;\n const merged: RenderSegment[] = [];\n\n segments.forEach((segment) => {\n if (segment.type === \"sandbox\") {\n merged.push(segment);\n return;\n }\n\n const last = merged[merged.length - 1];\n if (last && last.type !== \"sandbox\") {\n merged[merged.length - 1] = {\n type: \"markdown\",\n value: `${last.value}${segment.value}`,\n };\n return;\n }\n\n merged.push({ type: \"markdown\", value: segment.value });\n });\n\n return merged;\n};\n\nconst splitTextByCharacterChunk = (value: string, chunkSize: number) => {\n const safeChunkSize = Math.max(1, chunkSize);\n const characters = Array.from(value);\n\n return {\n chunk: characters.slice(0, safeChunkSize).join(\"\"),\n rest: characters.slice(safeChunkSize).join(\"\"),\n };\n};\n\nconst ContentRender: React.FC<ContentRenderProps> = ({\n content,\n contentType,\n locale,\n customRenderBar,\n onSend,\n typingSpeed = 40,\n enableTypewriter = false,\n onTypeFinished,\n onTypewriterStateChange,\n userInput,\n interactionDefaultValueOptions,\n defaultButtonText,\n defaultInputText,\n defaultSelectedValues,\n readonly = false,\n confirmButtonText,\n copyButtonText,\n copiedButtonText,\n sandboxLoadingText,\n sandboxStyleLoadingText,\n sandboxScriptLoadingText,\n disableSandboxLoadingOverlay = false,\n sandboxFullscreenButtonText,\n sandboxExitFullscreenButtonText,\n sandboxMode = \"content\",\n onClickCustomButtonAfterContent,\n beforeSend,\n // tooltipMinLength,\n}) => {\n const localeTexts = getContentRenderLocaleTexts(locale);\n const resolvedConfirmButtonText =\n confirmButtonText || localeTexts.confirmButtonText;\n const resolvedCopyButtonText = copyButtonText || localeTexts.copyButtonText;\n const resolvedCopiedButtonText =\n copiedButtonText || localeTexts.copiedButtonText;\n const resolvedSandboxFullscreenButtonText =\n sandboxFullscreenButtonText || localeTexts.sandboxFullscreenButtonText;\n const resolvedSandboxExitFullscreenButtonText =\n sandboxExitFullscreenButtonText ||\n localeTexts.sandboxExitFullscreenButtonText;\n const shouldApplyTypewriterByContentType =\n !contentType || contentType === \"text\";\n const isTypewriterEnabled =\n Boolean(enableTypewriter) && shouldApplyTypewriterByContentType;\n const typewriterChunkSize = 2;\n const typewriterTickMs = Math.max(0, typingSpeed);\n const [displayContent, setDisplayContent] = useState(() =>\n isTypewriterEnabled ? \"\" : content\n );\n const pendingContentRef = useRef(\"\");\n const previousTypewriterEnabledRef = useRef(isTypewriterEnabled);\n const hasReportedTypeFinishedRef = useRef(false);\n\n useEffect(() => {\n const wasTypewriterEnabled = previousTypewriterEnabledRef.current;\n previousTypewriterEnabledRef.current = isTypewriterEnabled;\n hasReportedTypeFinishedRef.current = false;\n\n if (!isTypewriterEnabled) {\n pendingContentRef.current = \"\";\n setDisplayContent(content);\n return;\n }\n\n setDisplayContent((current) => {\n const shouldRestartTyping = !wasTypewriterEnabled;\n const canContinueTyping = content.startsWith(current);\n\n if (!shouldRestartTyping && !canContinueTyping) {\n pendingContentRef.current = \"\";\n return content;\n }\n\n const nextVisibleContent =\n shouldRestartTyping || !canContinueTyping ? \"\" : current;\n\n pendingContentRef.current = content.slice(nextVisibleContent.length);\n return nextVisibleContent;\n });\n }, [content, isTypewriterEnabled]);\n\n useEffect(() => {\n if (!isTypewriterEnabled) {\n return;\n }\n\n if (\n hasReportedTypeFinishedRef.current ||\n pendingContentRef.current ||\n displayContent !== content\n ) {\n return;\n }\n\n hasReportedTypeFinishedRef.current = true;\n onTypeFinished?.();\n }, [content, displayContent, isTypewriterEnabled, onTypeFinished]);\n\n useEffect(() => {\n if (!isTypewriterEnabled || !pendingContentRef.current) {\n return undefined;\n }\n\n const typewriterTimer = window.setTimeout(() => {\n setDisplayContent((current) => {\n const { chunk, rest } = splitTextByCharacterChunk(\n pendingContentRef.current,\n typewriterChunkSize\n );\n\n if (!chunk) {\n return current;\n }\n\n pendingContentRef.current = rest;\n return `${current}${chunk}`;\n });\n }, typewriterTickMs);\n\n return () => window.clearTimeout(typewriterTimer);\n }, [\n content,\n displayContent,\n isTypewriterEnabled,\n typewriterChunkSize,\n typewriterTickMs,\n ]);\n\n const typewriterState = useMemo<ContentRenderTypewriterState>(\n () => ({\n isTypewriterEnabled,\n isTyping: isTypewriterEnabled && displayContent !== content,\n isComplete: displayContent === content,\n renderedLength: displayContent.length,\n totalLength: content.length,\n }),\n [content, displayContent, isTypewriterEnabled]\n );\n\n useEffect(() => {\n onTypewriterStateChange?.(typewriterState);\n }, [onTypewriterStateChange, typewriterState]);\n\n const renderContent = isTypewriterEnabled ? displayContent : content;\n const normalizedContent = useMemo(\n () => normalizeInlineHtml(renderContent),\n [renderContent]\n );\n\n const interactionDefaults = useMemo(\n () =>\n getInteractionDefaultValues(\n renderContent,\n userInput,\n interactionDefaultValueOptions\n ),\n [interactionDefaultValueOptions, renderContent, userInput]\n );\n\n const resolvedDefaultButtonText =\n defaultButtonText?.trim() || interactionDefaults.buttonText;\n const resolvedDefaultInputText =\n defaultInputText?.trim() || interactionDefaults.inputText;\n const fallbackSelectedValues = useMemo(\n () =>\n userInput\n ? userInput\n .split(\",\")\n .map((value) => value.trim())\n .filter(Boolean)\n : undefined,\n [userInput]\n );\n const resolvedDefaultSelectedValues = defaultSelectedValues?.length\n ? defaultSelectedValues\n : interactionDefaults.selectedValues || fallbackSelectedValues;\n\n const components: CustomComponents = {\n \"custom-button-after-content\": ({\n children,\n }: {\n children: React.ReactNode;\n }) => {\n return (\n <button\n className=\"content-render-custom-button-after-content\"\n onClick={onClickCustomButtonAfterContent}\n >\n <span className=\"content-render-custom-button-after-content-inner\">\n {children}\n </span>\n </button>\n );\n },\n \"custom-variable\": (props) => (\n <CustomButtonInputVariable\n {...props}\n readonly={readonly}\n defaultButtonText={resolvedDefaultButtonText}\n defaultInputText={resolvedDefaultInputText}\n defaultSelectedValues={resolvedDefaultSelectedValues}\n onSend={onSend}\n beforeSend={beforeSend}\n locale={locale}\n confirmButtonText={resolvedConfirmButtonText}\n // tooltipMinLength={tooltipMinLength}\n />\n ),\n code: (props) => {\n const { className, children, ...rest } = props as {\n className?: string;\n children?: React.ReactNode;\n };\n const match = /language-(\\w+)/.exec(className || \"\");\n const language = match?.[1];\n if (language === \"mermaid\") {\n const chartContent = children?.toString().replace(/\\n$/, \"\") || \"\";\n const frozen = mermaidBlockIsComplete(renderContent, chartContent);\n return <MermaidChart chart={chartContent} frozen={frozen} />;\n }\n\n return (\n <code className={className} {...rest}>\n {children}\n </code>\n );\n },\n table: ({ ...props }) => (\n <div className=\"content-render-table-container\">\n <table className=\"content-render-table\" {...props} />\n </div>\n ),\n th: ({ ...props }) => <th className=\"content-render-th\" {...props} />,\n td: ({ ...props }) => <td className=\"content-render-td\" {...props} />,\n tr: ({ ...props }) => <tr className=\"content-render-tr\" {...props} />,\n li: ({ node, ...props }) => {\n const className = node?.properties?.className;\n const hasTaskListItem =\n (typeof className === \"string\" &&\n className.includes(\"task-list-item\")) ||\n (Array.isArray(className) && className.includes(\"task-list-item\"));\n if (hasTaskListItem) {\n return <li className=\"content-render-task-list-item\" {...props} />;\n }\n return <li {...props} />;\n },\n ol: ({ ...props }) => <ol className=\"content-render-ol\" {...props} />,\n ul: ({ ...props }) => <ul className=\"content-render-ul\" {...props} />,\n input: ({ ...props }) => {\n if (props.type === \"checkbox\") {\n return (\n <input\n type=\"checkbox\"\n className=\"content-render-checkbox\"\n disabled\n {...props}\n />\n );\n }\n return <input {...props} />;\n },\n a: ({ children, ...props }) => (\n <a target=\"_blank\" rel=\"noopener noreferrer\" {...props}>\n {children}\n </a>\n ),\n pre: (props) => (\n <CodeBlock\n {...props}\n copyButtonText={resolvedCopyButtonText}\n copiedButtonText={resolvedCopiedButtonText}\n />\n ),\n };\n\n const hasPotentialSandboxTags = useMemo(\n () => SANDBOX_TAG_HINT_PATTERN.test(renderContent),\n [renderContent]\n );\n\n const renderSegments = useMemo(\n () =>\n hasPotentialSandboxTags ? splitContentSegments(renderContent, true) : [],\n [renderContent, hasPotentialSandboxTags]\n );\n\n const hasSandbox = renderSegments.some(\n (segment) => segment.type === \"sandbox\"\n );\n const mergedRenderSegments = useMemo(\n () => mergeNonSandboxSegments(renderSegments),\n [renderSegments]\n );\n\n const segments = useMemo(\n () => parseMarkdownSegments(normalizedContent),\n [normalizedContent]\n );\n\n const renderMarkdownSegments = (raw: string, keyPrefix: string) => {\n const normalized = normalizeInlineHtml(raw);\n const parsed = parseMarkdownSegments(normalized);\n\n return parsed.map((seg, index) => {\n const key = `${keyPrefix}-${seg.type}-${index}`;\n\n if (seg.type === \"text\") {\n return (\n <MarkdownRenderer\n key={key}\n components={components}\n content={seg.value}\n />\n );\n }\n\n if (seg.type === \"mermaid\") {\n return (\n <MermaidChart key={key} chart={seg.value} frozen={!seg.complete} />\n );\n }\n\n if (seg.type === \"svg\") {\n return <SvgBlockInShadow key={key} svg={seg.value} />;\n }\n\n return null;\n });\n };\n\n if (hasSandbox) {\n return (\n <div className=\"content-render markdown-body\">\n {mergedRenderSegments.map((segment, idx) =>\n segment.type === \"sandbox\" ? (\n <IframeSandbox\n key={`sandbox-${idx}`}\n hideFullScreen\n type=\"sandbox\"\n content={segment.value}\n className=\"content-render-iframe\"\n locale={locale}\n loadingText={sandboxLoadingText}\n styleLoadingText={sandboxStyleLoadingText}\n scriptLoadingText={sandboxScriptLoadingText}\n disableLoadingOverlay={disableSandboxLoadingOverlay}\n fullScreenButtonText={resolvedSandboxFullscreenButtonText}\n exitFullScreenButtonText={resolvedSandboxExitFullscreenButtonText}\n mode={sandboxMode}\n />\n ) : (\n <React.Fragment key={`md-${idx}`}>\n {renderMarkdownSegments(segment.value, `md-${idx}`)}\n </React.Fragment>\n )\n )}\n </div>\n );\n }\n\n return (\n <div className=\"content-render markdown-body\">\n {segments.map((seg, index) => {\n if (seg.type === \"text\") {\n return (\n <MarkdownRenderer\n key={index}\n components={components}\n content={seg.value}\n />\n );\n }\n\n if (seg.type === \"mermaid\") {\n return (\n <MermaidChart\n key={index}\n chart={seg.value}\n frozen={!seg.complete}\n />\n );\n }\n\n if (seg.type === \"svg\") {\n return <SvgBlockInShadow key={index} svg={seg.value} />;\n }\n })}\n\n {customRenderBar && (\n <div className=\"content-render-custom-bar\">\n {React.createElement(customRenderBar, {\n content,\n displayContent: normalizedContent,\n onSend,\n })}\n </div>\n )}\n </div>\n );\n};\n\nexport default ContentRender;\n"],"names":["SANDBOX_TAG_HINT_PATTERN","SvgBlockInShadow","svg","hostRef","useRef","useEffect","host","shadowRoot","styleId","styleEl","node","template","cleanedSvg","stripSvgTextLineBreaks","hasResponsiveSvg","hasFixedSvg","svgEl","viewBox","dimensions","value","viewBoxWidth","viewBoxHeight","widthAttr","heightAttr","isRelativeLength","normalized","toNumericLength","parsed","isWidthRelative","isHeightRelative","widthMissing","heightMissing","numericWidth","numericHeight","hostResponsive","jsx","remarkPlugins","remarkGfm","remarkMath","remarkFlow","remarkBreaks","rehypePlugins","preserveCustomVariableProperties","rehypeRaw","sanitizeInvalidTagName","restoreCustomVariableProperties","rehypeHighlight","highlightLanguages","subsetLanguages","rehypeKatex","MarkdownRenderer","markdownContent","components","ReactMarkdown","mergeNonSandboxSegments","segments","merged","segment","last","splitTextByCharacterChunk","chunkSize","safeChunkSize","characters","ContentRender","content","contentType","locale","customRenderBar","onSend","typingSpeed","enableTypewriter","onTypeFinished","onTypewriterStateChange","userInput","interactionDefaultValueOptions","defaultButtonText","defaultInputText","defaultSelectedValues","readonly","confirmButtonText","copyButtonText","copiedButtonText","sandboxLoadingText","sandboxStyleLoadingText","sandboxScriptLoadingText","disableSandboxLoadingOverlay","sandboxFullscreenButtonText","sandboxExitFullscreenButtonText","sandboxMode","onClickCustomButtonAfterContent","beforeSend","localeTexts","getContentRenderLocaleTexts","resolvedConfirmButtonText","resolvedCopyButtonText","resolvedCopiedButtonText","resolvedSandboxFullscreenButtonText","resolvedSandboxExitFullscreenButtonText","isTypewriterEnabled","typewriterChunkSize","typewriterTickMs","displayContent","setDisplayContent","useState","pendingContentRef","previousTypewriterEnabledRef","hasReportedTypeFinishedRef","wasTypewriterEnabled","current","shouldRestartTyping","canContinueTyping","nextVisibleContent","typewriterTimer","chunk","rest","typewriterState","useMemo","renderContent","normalizedContent","normalizeInlineHtml","interactionDefaults","getInteractionDefaultValues","resolvedDefaultButtonText","resolvedDefaultInputText","fallbackSelectedValues","resolvedDefaultSelectedValues","children","props","CustomButtonInputVariable","className","chartContent","frozen","mermaidBlockIsComplete","MermaidChart","CodeBlock","hasPotentialSandboxTags","renderSegments","splitContentSegments","hasSandbox","mergedRenderSegments","parseMarkdownSegments","renderMarkdownSegments","raw","keyPrefix","seg","index","key","idx","IframeSandbox","React","jsxs"],"mappings":"k9CA+CMA,GACJ,kGAmEIC,GAA8C,CAAC,CAAE,IAAAC,KAAU,CAC/D,MAAMC,EAAUC,EAAAA,OAAuB,IAAI,EAE3CC,OAAAA,EAAAA,UAAU,IAAM,CACd,MAAMC,EAAOH,EAAQ,QACrB,GAAI,CAACG,EAAM,OACX,MAAMC,EAAaD,EAAK,YAAcA,EAAK,aAAa,CAAE,KAAM,OAAQ,EAClEE,EAAU,2BAChB,IAAIC,EAAUF,EAAW,eAAeC,CAAO,EAE1CC,IACHA,EAAU,SAAS,cAAc,OAAO,EACxCA,EAAQ,GAAKD,EAEbC,EAAQ,YAAc;AAAA;AAAA;AAAA;AAAA,QAKtBF,EAAW,YAAYE,CAAO,GAGV,MAAM,KAAKF,EAAW,UAAU,EAAE,OACrDG,GAASA,IAASD,CAAA,EAEP,QAASC,GAASH,EAAW,YAAYG,CAAI,CAAC,EAE5D,MAAMC,EAAW,SAAS,cAAc,UAAU,EAC5CC,EAAaC,GAAAA,uBAAuBX,CAAG,EAC7CS,EAAS,UAAYC,EACrBL,EAAW,OAAOI,EAAS,QAAQ,UAAU,EAAI,CAAC,EAElD,IAAIG,EAAmB,GACnBC,EAAc,GAElBR,EAAW,iBAAiB,KAAK,EAAE,QAASS,GAAU,CAEpD,MAAMC,EAAUD,EAAM,aAAa,SAAS,EAC5C,GAAI,CAACC,EA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AOW,EAAI,MACX,OAAQ,CAACA,EAAI,QAAA,EAFRC,CAAA,EAOX,GAAID,EAAI,OAAS,MACf,OAAO7G,EAAAA,kBAAAA,IAAClC,GAAA,CAA6B,IAAK+I,EAAI,OAAhBC,CAAuB,CAEzD,CAAC,EAEA9E,GACChC,EAAAA,kBAAAA,IAAC,MAAA,CAAI,UAAU,4BACZ,SAAAkH,EAAM,cAAclF,EAAiB,CACpC,QAAAH,EACA,eAAgBsD,EAChB,OAAAlD,CAAA,CACD,CAAA,CACH,CAAA,EAEJ,CAEJ"}
@@ -2,9 +2,12 @@ import { default as React } from 'react';
2
2
  import { CustomRenderBarProps, OnSendContentParams } from '../types';
3
3
  import { ComponentsWithCustomVariable } from './plugins/CustomVariable';
4
4
  import { InteractionDefaultValueOptions } from '../../lib/interaction-defaults';
5
+ import { MarkdownFlowLocale } from '../../lib/locale';
5
6
  export interface ContentRenderProps {
6
7
  content: string;
7
8
  contentType?: string;
9
+ /** Locale used for built-in UI text when a more specific text prop is not provided. */
10
+ locale?: MarkdownFlowLocale;
8
11
  /**
9
12
  * Callback invoked when the custom button after content is clicked.
10
13
  * This button is rendered via the `<custom-button-after-content>` tag in markdown content.
@@ -38,6 +41,7 @@ export interface ContentRenderProps {
38
41
  sandboxScriptLoadingText?: string;
39
42
  disableSandboxLoadingOverlay?: boolean;
40
43
  sandboxFullscreenButtonText?: string;
44
+ sandboxExitFullscreenButtonText?: string;
41
45
  sandboxMode?: "content" | "blackboard";
42
46
  beforeSend?: (param: OnSendContentParams) => boolean;
43
47
  }