markdown-flow-ui 0.1.89 → 0.1.90-beta.1

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 (61) hide show
  1. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.cjs.js +1 -1
  2. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.es.js +1 -1
  3. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/c4Diagram-YG6GDRKO.cjs.js +1 -1
  4. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/c4Diagram-YG6GDRKO.es.js +1 -1
  5. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/chunk-S3R3BYOJ.cjs.js +1 -1
  6. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/chunk-S3R3BYOJ.es.js +1 -1
  7. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/chunk-TZMSLE5B.cjs.js +1 -1
  8. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/chunk-TZMSLE5B.es.js +1 -1
  9. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/ganttDiagram-LVOFAZNH.cjs.js +1 -1
  10. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/ganttDiagram-LVOFAZNH.es.js +1 -1
  11. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/sequenceDiagram-WL72ISMW.cjs.js +1 -1
  12. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/sequenceDiagram-WL72ISMW.es.js +1 -1
  13. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-input@1.8.0_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-input/es/BaseInput.cjs.js +1 -1
  14. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-input@1.8.0_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-input/es/BaseInput.es.js +1 -1
  15. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/ResizableTextArea.cjs.js +1 -1
  16. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/ResizableTextArea.es.js +1 -1
  17. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/TextArea.cjs.js +1 -1
  18. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/TextArea.es.js +1 -1
  19. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/index.cjs.js +1 -1
  20. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/index.es.js +1 -1
  21. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/remark-flow@0.1.6/node_modules/remark-flow/dist/index.cjs.js +1 -1
  22. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/remark-flow@0.1.6/node_modules/remark-flow/dist/index.es.js +1 -1
  23. package/dist/_virtual/index.cjs2.js +1 -1
  24. package/dist/_virtual/index.cjs3.js +1 -1
  25. package/dist/_virtual/index.cjs7.js +1 -1
  26. package/dist/_virtual/index.cjs8.js +1 -1
  27. package/dist/_virtual/index.es2.js +5 -2
  28. package/dist/_virtual/index.es2.js.map +1 -1
  29. package/dist/_virtual/index.es3.js +2 -5
  30. package/dist/_virtual/index.es3.js.map +1 -1
  31. package/dist/_virtual/index.es7.js +2 -3
  32. package/dist/_virtual/index.es7.js.map +1 -1
  33. package/dist/_virtual/index.es8.js +3 -2
  34. package/dist/_virtual/index.es8.js.map +1 -1
  35. package/dist/components/ContentRender/ContentRender.cjs.js +4 -2
  36. package/dist/components/ContentRender/ContentRender.cjs.js.map +1 -1
  37. package/dist/components/ContentRender/ContentRender.es.js +187 -173
  38. package/dist/components/ContentRender/ContentRender.es.js.map +1 -1
  39. package/dist/components/ContentRender/IframeSandbox.cjs.js +1 -1
  40. package/dist/components/ContentRender/IframeSandbox.cjs.js.map +1 -1
  41. package/dist/components/ContentRender/IframeSandbox.es.js +1 -1
  42. package/dist/components/ContentRender/IframeSandbox.es.js.map +1 -1
  43. package/dist/components/ContentRender/SplitContent.stories.d.ts +16 -0
  44. package/dist/components/ContentRender/utils/mermaid-parse.cjs.js +5 -3
  45. package/dist/components/ContentRender/utils/mermaid-parse.cjs.js.map +1 -1
  46. package/dist/components/ContentRender/utils/mermaid-parse.es.js +83 -58
  47. package/dist/components/ContentRender/utils/mermaid-parse.es.js.map +1 -1
  48. package/dist/components/ContentRender/utils/mermaid-parse.test.d.ts +1 -0
  49. package/dist/components/ContentRender/utils/split-content.cjs.js +5 -3
  50. package/dist/components/ContentRender/utils/split-content.cjs.js.map +1 -1
  51. package/dist/components/ContentRender/utils/split-content.es.js +97 -63
  52. package/dist/components/ContentRender/utils/split-content.es.js.map +1 -1
  53. package/dist/components/ContentRender/utils/strip-svg-text-line-breaks.cjs.js +2 -0
  54. package/dist/components/ContentRender/utils/strip-svg-text-line-breaks.cjs.js.map +1 -0
  55. package/dist/components/ContentRender/utils/strip-svg-text-line-breaks.d.ts +1 -0
  56. package/dist/components/ContentRender/utils/strip-svg-text-line-breaks.es.js +10 -0
  57. package/dist/components/ContentRender/utils/strip-svg-text-line-breaks.es.js.map +1 -0
  58. package/dist/components/ui/inputGroup/textarea.cjs.js +1 -1
  59. package/dist/components/ui/inputGroup/textarea.es.js +1 -1
  60. package/dist/markdown-flow-ui-lib.css +1 -1
  61. package/package.json +1 -1
@@ -1,8 +1,5 @@
1
- import { getDefaultExportFromCjs as r } from "./_commonjsHelpers.es.js";
2
- import { __require as s } from "../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.es.js";
3
- var e = s();
4
- const t = /* @__PURE__ */ r(e);
1
+ var r = {};
5
2
  export {
6
- t as default
3
+ r as __exports
7
4
  };
8
5
  //# sourceMappingURL=index.es3.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.es3.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
1
+ {"version":3,"file":"index.es3.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -1,6 +1,5 @@
1
- import { __require as r } from "../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/@braintree_sanitize-url@7.1.1/node_modules/@braintree/sanitize-url/dist/index.es.js";
2
- var i = r();
1
+ var s = { exports: {} };
3
2
  export {
4
- i as d
3
+ s as __module
5
4
  };
6
5
  //# sourceMappingURL=index.es7.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.es7.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
1
+ {"version":3,"file":"index.es7.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -1,5 +1,6 @@
1
- var s = { exports: {} };
1
+ import { __require as r } from "../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/@braintree_sanitize-url@7.1.1/node_modules/@braintree/sanitize-url/dist/index.es.js";
2
+ var i = r();
2
3
  export {
3
- s as __module
4
+ i as d
4
5
  };
5
6
  //# sourceMappingURL=index.es8.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.es8.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
1
+ {"version":3,"file":"index.es8.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
@@ -1,6 +1,8 @@
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 u=require("react"),F=require("../../_virtual/index.cjs.js"),U=require("./utils/sanitize-invalid-tag-name.cjs.js");;/* empty css */;/* empty css */const O=require("./CodeBlock.cjs.js"),D=require("./plugins/CustomVariable.cjs.js"),B=require("./plugins/MermaidChart.cjs.js"),G=require("./useTypewriterStateMachine.cjs.js"),H=require("./utils/custom-variable-props.cjs.js"),P=require("./utils/highlight-languages.cjs.js"),V=require("./utils/mermaid-parse.cjs.js"),W=require("./utils/normalize-inline-html.cjs.js"),J=require("./IframeSandbox.cjs.js"),K=require("./utils/split-content.cjs.js"),Q=require("../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/react-markdown@10.1.0_@types_react@19.2.2_react@19.0.1/node_modules/react-markdown/lib/index.cjs.js"),X=require("../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rehype-raw@7.0.0/node_modules/rehype-raw/lib/index.cjs.js"),Y=require("../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rehype-highlight@7.0.2/node_modules/rehype-highlight/lib/index.cjs.js"),Z=require("../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rehype-katex@7.0.1/node_modules/rehype-katex/lib/index.cjs.js"),ee=require("../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/remark-gfm@4.0.1/node_modules/remark-gfm/lib/index.cjs.js"),te=require("../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/remark-math@6.0.0/node_modules/remark-math/lib/index.cjs.js"),ne=require("../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/remark-breaks@4.0.0/node_modules/remark-breaks/lib/index.cjs.js"),se=({svg:r})=>{const o=u.useRef(null);return u.useEffect(()=>{const i=o.current;if(!i)return;const a=i.shadowRoot??i.attachShadow({mode:"open"}),N="content-render-svg-style";let l=a.getElementById(N);l||(l=document.createElement("style"),l.id=N,l.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 u=require("react"),G=require("../../_virtual/index.cjs.js"),J=require("./utils/sanitize-invalid-tag-name.cjs.js"),K=require("./utils/strip-svg-text-line-breaks.cjs.js");;/* empty css */;/* empty css */const Q=require("./CodeBlock.cjs.js"),X=require("./plugins/CustomVariable.cjs.js"),A=require("./plugins/MermaidChart.cjs.js"),Y=require("./useTypewriterStateMachine.cjs.js"),V=require("./utils/custom-variable-props.cjs.js"),_=require("./utils/highlight-languages.cjs.js"),H=require("./utils/mermaid-parse.cjs.js"),U=require("./utils/normalize-inline-html.cjs.js"),Z=require("./IframeSandbox.cjs.js"),ee=require("./utils/split-content.cjs.js"),te=require("../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/react-markdown@10.1.0_@types_react@19.2.2_react@19.0.1/node_modules/react-markdown/lib/index.cjs.js"),ne=require("../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rehype-raw@7.0.0/node_modules/rehype-raw/lib/index.cjs.js"),se=require("../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rehype-highlight@7.0.2/node_modules/rehype-highlight/lib/index.cjs.js"),re=require("../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rehype-katex@7.0.1/node_modules/rehype-katex/lib/index.cjs.js"),oe=require("../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/remark-gfm@4.0.1/node_modules/remark-gfm/lib/index.cjs.js"),ie=require("../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/remark-math@6.0.0/node_modules/remark-math/lib/index.cjs.js"),ae=require("../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/remark-breaks@4.0.0/node_modules/remark-breaks/lib/index.cjs.js"),O=({svg:o})=>{const i=u.useRef(null);return u.useEffect(()=>{const l=i.current;if(!l)return;const r=l.shadowRoot??l.attachShadow({mode:"open"}),c="content-render-svg-style";let a=r.getElementById(c);a||(a=document.createElement("style"),a.id=c,a.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
- `,a.appendChild(l)),Array.from(a.childNodes).filter(n=>n!==l).forEach(n=>a.removeChild(n));const y=document.createElement("template");y.innerHTML=r,a.append(y.content.cloneNode(!0));let w=!1,g=!1;a.querySelectorAll("svg").forEach(n=>{const q=n.getAttribute("viewBox");if(!q)return;const R=q.trim().split(/[\s,]+/).map(c=>Number(c));if(R.length!==4||R.some(Number.isNaN))return;const[,,h,d]=R,p=n.getAttribute("width"),f=n.getAttribute("height"),k=c=>{if(!c)return!1;const e=c.trim().toLowerCase();return e==="auto"||e.endsWith("%")},S=c=>{if(!c)return null;const e=c.trim().toLowerCase();if(e==="auto"||e.endsWith("%"))return null;const s=Number.parseFloat(e);return Number.isNaN(s)?null:s},L=k(p),C=k(f),j=!p||p==="0",v=!f||f==="0",b=S(p),m=S(f);if(L||C||j&&v||b===h&&m===d){w=!0,n.classList.add("content-render-svg-el--responsive"),n.classList.remove("content-render-svg-el--fixed"),n.style.width="100%",n.style.height="auto",!n.style.aspectRatio&&d>0&&(n.style.aspectRatio=`${h} / ${d}`);return}g=!0,n.classList.add("content-render-svg-el--fixed"),n.classList.remove("content-render-svg-el--responsive"),j&&h>0&&n.setAttribute("width",`${h}`),v&&d>0&&n.setAttribute("height",`${d}`)});const E=w&&!g;i.classList.toggle("content-render-svg--responsive",E),i.classList.toggle("content-render-svg--fixed",!E)},[r]),t.jsxRuntimeExports.jsx("div",{className:"content-render-svg-scroll",children:t.jsxRuntimeExports.jsx("div",{className:"content-render-svg",ref:o})})},re=[ee.default,te.default,F.default,ne.default],oe=[H.preserveCustomVariableProperties,X.default,U.sanitizeInvalidTagName,H.restoreCustomVariableProperties,[Y.default,{languages:P.highlightLanguages,subset:P.subsetLanguages}],Z.default],$=({content:r,components:o})=>t.jsxRuntimeExports.jsx("div",{className:"markdown-renderer",children:t.jsxRuntimeExports.jsx(Q.Markdown,{remarkPlugins:re,rehypePlugins:oe,components:o,children:r})}),ie=r=>{if(r.length<=1)return r;const o=[];return r.forEach(i=>{if(i.type==="sandbox"){o.push(i);return}const a=o[o.length-1];if(a&&a.type!=="sandbox"){o[o.length-1]={type:"markdown",value:`${a.value}${i.value}`};return}o.push({type:"markdown",value:i.value})}),o},ae=({content:r,customRenderBar:o,onSend:i,typingSpeed:a=30,enableTypewriter:N=!1,defaultButtonText:l,defaultInputText:M,defaultSelectedValues:y,readonly:w=!1,onTypeFinished:g,confirmButtonText:E,copyButtonText:n,copiedButtonText:q,sandboxLoadingText:R,sandboxStyleLoadingText:h,sandboxScriptLoadingText:d,sandboxFullscreenButtonText:p,sandboxMode:f="content",onClickCustomButtonAfterContent:k,beforeSend:S})=>{const L=u.useMemo(()=>W.normalizeInlineHtml(r),[r]),C={"custom-button-after-content":({children:e})=>t.jsxRuntimeExports.jsx("button",{className:"content-render-custom-button-after-content",onClick:k,children:t.jsxRuntimeExports.jsx("span",{className:"content-render-custom-button-after-content-inner",children:e})}),"custom-variable":e=>t.jsxRuntimeExports.jsx(D.default,{...e,readonly:w,defaultButtonText:l,defaultInputText:M,defaultSelectedValues:y,onSend:i,beforeSend:S,confirmButtonText:E}),code:e=>{const{className:s,children:x,...T}=e;if(/language-(\w+)/.exec(s||"")?.[1]==="mermaid"){const A=x?.toString().replace(/\n$/,"")||"",_=V.mermaidBlockIsComplete(r,A);return t.jsxRuntimeExports.jsx(B.default,{chart:A,frozen:_})}return t.jsxRuntimeExports.jsx("code",{className:s,...T,children:x})},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 x=e?.properties?.className;return typeof x=="string"&&x.includes("task-list-item")||Array.isArray(x)&&x.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(O.default,{...e,copyButtonText:n,copiedButtonText:q})},{displayContent:j,isComplete:v}=G.default({content:L,typingSpeed:a,disabled:!N}),b=u.useMemo(()=>K.splitContentSegments(r,!0),[r]),m=b.some(e=>e.type==="sandbox"),z=u.useMemo(()=>ie(b),[b]),I=u.useMemo(()=>V.parseMarkdownSegments(j),[j]),c=u.useRef(!1);return u.useEffect(()=>{m||v&&!c.current&&(c.current=!0,g?.())},[m,v,g]),u.useEffect(()=>{m||(c.current=!1)},[m,r]),m?t.jsxRuntimeExports.jsx("div",{className:"content-render markdown-body",children:z.map((e,s)=>e.type==="sandbox"?t.jsxRuntimeExports.jsx(J.default,{hideFullScreen:!0,content:e.value,className:"content-render-iframe",loadingText:R,styleLoadingText:h,scriptLoadingText:d,fullScreenButtonText:p,mode:f},`sandbox-${s}`):t.jsxRuntimeExports.jsx($,{components:C,content:W.normalizeInlineHtml(e.value)},`md-${s}`))}):t.jsxRuntimeExports.jsxs("div",{className:"content-render markdown-body",children:[I.map((e,s)=>{if(e.type==="text")return t.jsxRuntimeExports.jsx($,{components:C,content:e.value},s);if(e.type==="mermaid")return t.jsxRuntimeExports.jsx(B.default,{chart:e.value,frozen:!e.complete},s);if(e.type==="svg")return t.jsxRuntimeExports.jsx(se,{svg:e.value},s)}),o&&t.jsxRuntimeExports.jsx("div",{className:"content-render-custom-bar",children:u.createElement(o,{content:r,displayContent:j,onSend:i})})]})};exports.MarkdownRenderer=$;exports.default=ae;
5
+ `,r.appendChild(a)),Array.from(r.childNodes).filter(s=>s!==a).forEach(s=>r.removeChild(s));const f=document.createElement("template"),B=K.stripSvgTextLineBreaks(o);f.innerHTML=B,console.log("template.innerHTML",f.innerHTML),r.append(f.content.cloneNode(!0));let y=!1,q=!1;r.querySelectorAll("svg").forEach(s=>{const L=s.getAttribute("viewBox");if(!L)return;const N=L.trim().split(/[\s,]+/).map(d=>Number(d));if(N.length!==4||N.some(Number.isNaN))return;const[,,j,p]=N,g=s.getAttribute("width"),v=s.getAttribute("height"),$=d=>{if(!d)return!1;const e=d.trim().toLowerCase();return e==="auto"||e.endsWith("%")},M=d=>{if(!d)return null;const e=d.trim().toLowerCase();if(e==="auto"||e.endsWith("%"))return null;const n=Number.parseFloat(e);return Number.isNaN(n)?null:n},C=$(g),k=$(v),w=!g||g==="0",R=!v||v==="0",h=M(g),z=M(v);if(C||k||w&&R||h===j&&z===p){y=!0,s.classList.add("content-render-svg-el--responsive"),s.classList.remove("content-render-svg-el--fixed"),s.style.width="100%",s.style.height="auto",!s.style.aspectRatio&&p>0&&(s.style.aspectRatio=`${j} / ${p}`);return}q=!0,s.classList.add("content-render-svg-el--fixed"),s.classList.remove("content-render-svg-el--responsive"),w&&j>0&&s.setAttribute("width",`${j}`),R&&p>0&&s.setAttribute("height",`${p}`)});const S=y&&!q;l.classList.toggle("content-render-svg--responsive",S),l.classList.toggle("content-render-svg--fixed",!S)},[o]),t.jsxRuntimeExports.jsx("div",{className:"content-render-svg-scroll",children:t.jsxRuntimeExports.jsx("div",{className:"content-render-svg",ref:i})})},ce=[oe.default,ie.default,G.default,ae.default],ue=[V.preserveCustomVariableProperties,ne.default,J.sanitizeInvalidTagName,V.restoreCustomVariableProperties,[se.default,{languages:_.highlightLanguages,subset:_.subsetLanguages}],re.default],W=({content:o,components:i})=>t.jsxRuntimeExports.jsx("div",{className:"markdown-renderer",children:t.jsxRuntimeExports.jsx(te.Markdown,{remarkPlugins:ce,rehypePlugins:ue,components:i,children:o})}),le=o=>{if(o.length<=1)return o;const i=[],l=(r,c)=>{const a=c.trimStart(),E=a.startsWith("|")||/^#{1,6}[ \t]/.test(a)||/^>[ \t]?/.test(a)||/^[-*+][ \t]/.test(a)||/^\d+\.[ \t]/.test(a);return!r.endsWith(`
6
+ `)&&E?`${r}
7
+ ${c}`:`${r}${c}`};return o.forEach(r=>{if(r.type==="sandbox"){i.push(r);return}const c=i[i.length-1];if(c&&c.type!=="sandbox"){i[i.length-1]={type:"markdown",value:l(c.value,r.value)};return}i.push({type:"markdown",value:r.value})}),i},de=({content:o,customRenderBar:i,onSend:l,typingSpeed:r=30,enableTypewriter:c=!1,defaultButtonText:a,defaultInputText:E,defaultSelectedValues:f,readonly:B=!1,onTypeFinished:y,confirmButtonText:q,copyButtonText:S,copiedButtonText:s,sandboxLoadingText:L,sandboxStyleLoadingText:N,sandboxScriptLoadingText:j,sandboxFullscreenButtonText:p,sandboxMode:g="content",onClickCustomButtonAfterContent:v,beforeSend:$})=>{const M=u.useMemo(()=>U.normalizeInlineHtml(o),[o]),C={"custom-button-after-content":({children:e})=>t.jsxRuntimeExports.jsx("button",{className:"content-render-custom-button-after-content",onClick:v,children:t.jsxRuntimeExports.jsx("span",{className:"content-render-custom-button-after-content-inner",children:e})}),"custom-variable":e=>t.jsxRuntimeExports.jsx(X.default,{...e,readonly:B,defaultButtonText:a,defaultInputText:E,defaultSelectedValues:f,onSend:l,beforeSend:$,confirmButtonText:q}),code:e=>{const{className:n,children:m,...I}=e;if(/language-(\w+)/.exec(n||"")?.[1]==="mermaid"){const b=m?.toString().replace(/\n$/,"")||"",D=H.mermaidBlockIsComplete(o,b);return t.jsxRuntimeExports.jsx(A.default,{chart:b,frozen:D})}return t.jsxRuntimeExports.jsx("code",{className:n,...I,children:m})},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,...n})=>{const m=e?.properties?.className;return typeof m=="string"&&m.includes("task-list-item")||Array.isArray(m)&&m.includes("task-list-item")?t.jsxRuntimeExports.jsx("li",{className:"content-render-task-list-item",...n}):t.jsxRuntimeExports.jsx("li",{...n})},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,...n})=>t.jsxRuntimeExports.jsx("a",{target:"_blank",rel:"noopener noreferrer",...n,children:e}),pre:e=>t.jsxRuntimeExports.jsx(Q.default,{...e,copyButtonText:S,copiedButtonText:s})},{displayContent:k,isComplete:w}=Y.default({content:M,typingSpeed:r,disabled:!c}),R=u.useMemo(()=>ee.splitContentSegments(o,!0),[o]),h=R.some(e=>e.type==="sandbox"),z=u.useMemo(()=>le(R),[R]),P=u.useMemo(()=>H.parseMarkdownSegments(k),[k]),T=u.useRef(!1);u.useEffect(()=>{h||w&&!T.current&&(T.current=!0,y?.())},[h,w,y]),u.useEffect(()=>{h||(T.current=!1)},[h,o]);const d=(e,n)=>{const m=U.normalizeInlineHtml(e);return H.parseMarkdownSegments(m).map((x,F)=>{const b=`${n}-${x.type}-${F}`;return x.type==="text"?t.jsxRuntimeExports.jsx(W,{components:C,content:x.value},b):x.type==="mermaid"?t.jsxRuntimeExports.jsx(A.default,{chart:x.value,frozen:!x.complete},b):x.type==="svg"?t.jsxRuntimeExports.jsx(O,{svg:x.value},b):null})};return h?t.jsxRuntimeExports.jsx("div",{className:"content-render markdown-body",children:z.map((e,n)=>e.type==="sandbox"?t.jsxRuntimeExports.jsx(Z.default,{hideFullScreen:!0,content:e.value,className:"content-render-iframe",loadingText:L,styleLoadingText:N,scriptLoadingText:j,fullScreenButtonText:p,mode:g},`sandbox-${n}`):t.jsxRuntimeExports.jsx(u.Fragment,{children:d(e.value,`md-${n}`)},`md-${n}`))}):t.jsxRuntimeExports.jsxs("div",{className:"content-render markdown-body",children:[P.map((e,n)=>{if(e.type==="text")return t.jsxRuntimeExports.jsx(W,{components:C,content:e.value},n);if(e.type==="mermaid")return t.jsxRuntimeExports.jsx(A.default,{chart:e.value,frozen:!e.complete},n);if(e.type==="svg")return t.jsxRuntimeExports.jsx(O,{svg:e.value},n)}),i&&t.jsxRuntimeExports.jsx("div",{className:"content-render-custom-bar",children:u.createElement(i,{content:o,displayContent:k,onSend:l})})]})};exports.MarkdownRenderer=W;exports.default=de;
6
8
  //# 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 } 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 \"./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 useTypewriterStateMachine from \"./useTypewriterStateMachine\";\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\";\n// Define component Props type\nexport interface ContentRenderProps {\n content: 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 defaultButtonText?: string;\n defaultInputText?: string; // Text input by user\n defaultSelectedValues?: string[]; // Default selected values for multi-select\n readonly?: boolean;\n onTypeFinished?: () => void;\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 // 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\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 template.innerHTML = svg;\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 ContentRender: React.FC<ContentRenderProps> = ({\n content,\n customRenderBar,\n onSend,\n typingSpeed = 30,\n enableTypewriter = false,\n defaultButtonText,\n defaultInputText,\n defaultSelectedValues,\n readonly = false,\n onTypeFinished,\n confirmButtonText,\n copyButtonText,\n copiedButtonText,\n sandboxLoadingText,\n sandboxStyleLoadingText,\n sandboxScriptLoadingText,\n sandboxFullscreenButtonText,\n sandboxMode = \"content\",\n onClickCustomButtonAfterContent,\n beforeSend,\n // tooltipMinLength,\n}) => {\n const normalizedContent = useMemo(\n () => normalizeInlineHtml(content),\n [content]\n );\n\n // Use custom Hook to handle typewriter effect\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={defaultButtonText}\n defaultInputText={defaultInputText}\n defaultSelectedValues={defaultSelectedValues}\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(content, 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 { displayContent, isComplete } = useTypewriterStateMachine({\n // processMarkdownText will let code block printf(\"You win!\\n\") become printf(\"You win!<br/>\");\n // content: processMarkdownText(content),\n content: normalizedContent,\n typingSpeed,\n disabled: !enableTypewriter,\n });\n\n const renderSegments = useMemo(\n () => splitContentSegments(content, true),\n [content]\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(displayContent),\n [displayContent]\n );\n\n const hasCompleted = useRef(false);\n\n useEffect(() => {\n if (hasSandbox) return;\n if (isComplete && !hasCompleted.current) {\n hasCompleted.current = true; // Mark as completed\n onTypeFinished?.(); // Call the passed callback\n }\n }, [hasSandbox, isComplete, onTypeFinished]);\n\n useEffect(() => {\n if (hasSandbox) return;\n hasCompleted.current = false; // Reset completion status when content changes\n }, [hasSandbox, content]);\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 content={segment.value}\n className=\"content-render-iframe\"\n loadingText={sandboxLoadingText}\n styleLoadingText={sandboxStyleLoadingText}\n scriptLoadingText={sandboxScriptLoadingText}\n fullScreenButtonText={sandboxFullscreenButtonText}\n mode={sandboxMode}\n />\n ) : (\n <MarkdownRenderer\n key={`md-${idx}`}\n components={components}\n content={normalizeInlineHtml(segment.value)}\n />\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,\n onSend,\n })}\n </div>\n )}\n </div>\n );\n};\n\nexport default ContentRender;\n"],"names":["SvgBlockInShadow","svg","hostRef","useRef","useEffect","host","shadowRoot","styleId","styleEl","node","template","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","ContentRender","content","customRenderBar","onSend","typingSpeed","enableTypewriter","defaultButtonText","defaultInputText","defaultSelectedValues","readonly","onTypeFinished","confirmButtonText","copyButtonText","copiedButtonText","sandboxLoadingText","sandboxStyleLoadingText","sandboxScriptLoadingText","sandboxFullscreenButtonText","sandboxMode","onClickCustomButtonAfterContent","beforeSend","normalizedContent","useMemo","normalizeInlineHtml","children","props","CustomButtonInputVariable","className","rest","chartContent","frozen","mermaidBlockIsComplete","MermaidChart","CodeBlock","displayContent","isComplete","useTypewriterStateMachine","renderSegments","splitContentSegments","hasSandbox","mergedRenderSegments","parseMarkdownSegments","hasCompleted","idx","IframeSandbox","jsxs","seg","index","React"],"mappings":"2hEAuFMA,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,EAClDA,EAAS,UAAYT,EACrBK,EAAW,OAAOI,EAAS,QAAQ,UAAU,EAAI,CAAC,EAElD,IAAIC,EAAmB,GACnBC,EAAc,GAElBN,EAAW,iBAAiB,KAAK,EAAE,QAASO,G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ACZ,SAAAgE,EAAqB,IAAI,CAAC1C,EAAS6C,IAClC7C,EAAQ,OAAS,UACftB,EAAAA,kBAAAA,IAACoE,EAAAA,QAAA,CAEC,eAAc,GACd,QAAS9C,EAAQ,MACjB,UAAU,wBACV,YAAagB,EACb,iBAAkBC,EAClB,kBAAmBC,EACnB,qBAAsBC,EACtB,KAAMC,CAAA,EARD,WAAWyB,CAAG,EAAA,EAWrBnE,EAAAA,kBAAAA,IAACe,EAAA,CAEC,WAAAE,EACA,QAAS8B,EAAAA,oBAAoBzB,EAAQ,KAAK,CAAA,EAFrC,MAAM6C,CAAG,EAAA,CAGhB,EAGN,EAKFE,EAAAA,kBAAAA,KAAC,MAAA,CAAI,UAAU,+BACZ,SAAA,CAAAjD,EAAS,IAAI,CAACkD,EAAKC,IAAU,CAC5B,GAAID,EAAI,OAAS,OACf,OACEtE,EAAAA,kBAAAA,IAACe,EAAA,CAEC,WAAAE,EACA,QAASqD,EAAI,KAAA,EAFRC,CAAA,EAOX,GAAID,EAAI,OAAS,UACf,OACEtE,EAAAA,kBAAAA,IAACwD,EAAAA,QAAA,CAEC,MAAOc,EAAI,MACX,OAAQ,CAACA,EAAI,QAAA,EAFRC,CAAA,EAOX,GAAID,EAAI,OAAS,MACf,OAAOtE,EAAAA,kBAAAA,IAAChC,GAAA,CAA6B,IAAKsG,EAAI,OAAhBC,CAAuB,CAEzD,CAAC,EAEA7C,GACC1B,EAAAA,kBAAAA,IAAC,MAAA,CAAI,UAAU,4BACZ,SAAAwE,EAAM,cAAc9C,EAAiB,CACpC,QAAAD,EACA,eAAAiC,EACA,OAAA/B,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 } 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 useTypewriterStateMachine from \"./useTypewriterStateMachine\";\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\";\n// Define component Props type\nexport interface ContentRenderProps {\n content: 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 defaultButtonText?: string;\n defaultInputText?: string; // Text input by user\n defaultSelectedValues?: string[]; // Default selected values for multi-select\n readonly?: boolean;\n onTypeFinished?: () => void;\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 // 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\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 console.log(\"template.innerHTML\", template.innerHTML);\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 const appendMarkdownValue = (prevValue: string, nextValue: string) => {\n // Keep block-level markdown segments on a new line when split-content emits\n // them as adjacent segments without boundary whitespace.\n const trimmedNext = nextValue.trimStart();\n const startsWithBlockMarker =\n trimmedNext.startsWith(\"|\") ||\n /^#{1,6}[ \\t]/.test(trimmedNext) ||\n /^>[ \\t]?/.test(trimmedNext) ||\n /^[-*+][ \\t]/.test(trimmedNext) ||\n /^\\d+\\.[ \\t]/.test(trimmedNext);\n const shouldInsertLineBreak =\n !prevValue.endsWith(\"\\n\") && startsWithBlockMarker;\n return shouldInsertLineBreak\n ? `${prevValue}\\n${nextValue}`\n : `${prevValue}${nextValue}`;\n };\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: appendMarkdownValue(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 ContentRender: React.FC<ContentRenderProps> = ({\n content,\n customRenderBar,\n onSend,\n typingSpeed = 30,\n enableTypewriter = false,\n defaultButtonText,\n defaultInputText,\n defaultSelectedValues,\n readonly = false,\n onTypeFinished,\n confirmButtonText,\n copyButtonText,\n copiedButtonText,\n sandboxLoadingText,\n sandboxStyleLoadingText,\n sandboxScriptLoadingText,\n sandboxFullscreenButtonText,\n sandboxMode = \"content\",\n onClickCustomButtonAfterContent,\n beforeSend,\n // tooltipMinLength,\n}) => {\n const normalizedContent = useMemo(\n () => normalizeInlineHtml(content),\n [content]\n );\n\n // Use custom Hook to handle typewriter effect\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={defaultButtonText}\n defaultInputText={defaultInputText}\n defaultSelectedValues={defaultSelectedValues}\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(content, 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 { displayContent, isComplete } = useTypewriterStateMachine({\n // processMarkdownText will let code block printf(\"You win!\\n\") become printf(\"You win!<br/>\");\n // content: processMarkdownText(content),\n content: normalizedContent,\n typingSpeed,\n disabled: !enableTypewriter,\n });\n\n const renderSegments = useMemo(\n () => splitContentSegments(content, true),\n [content]\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(displayContent),\n [displayContent]\n );\n\n const hasCompleted = useRef(false);\n\n useEffect(() => {\n if (hasSandbox) return;\n if (isComplete && !hasCompleted.current) {\n hasCompleted.current = true; // Mark as completed\n onTypeFinished?.(); // Call the passed callback\n }\n }, [hasSandbox, isComplete, onTypeFinished]);\n\n useEffect(() => {\n if (hasSandbox) return;\n hasCompleted.current = false; // Reset completion status when content changes\n }, [hasSandbox, content]);\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 content={segment.value}\n className=\"content-render-iframe\"\n loadingText={sandboxLoadingText}\n styleLoadingText={sandboxStyleLoadingText}\n scriptLoadingText={sandboxScriptLoadingText}\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,\n onSend,\n })}\n </div>\n )}\n </div>\n );\n};\n\nexport default ContentRender;\n"],"names":["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","appendMarkdownValue","prevValue","nextValue","trimmedNext","startsWithBlockMarker","segment","last","ContentRender","content","customRenderBar","onSend","typingSpeed","enableTypewriter","defaultButtonText","defaultInputText","defaultSelectedValues","readonly","onTypeFinished","confirmButtonText","copyButtonText","copiedButtonText","sandboxLoadingText","sandboxStyleLoadingText","sandboxScriptLoadingText","sandboxFullscreenButtonText","sandboxMode","onClickCustomButtonAfterContent","beforeSend","normalizedContent","useMemo","normalizeInlineHtml","children","props","CustomButtonInputVariable","className","rest","chartContent","frozen","mermaidBlockIsComplete","MermaidChart","CodeBlock","displayContent","isComplete","useTypewriterStateMachine","renderSegments","splitContentSegments","hasSandbox","mergedRenderSegments","parseMarkdownSegments","hasCompleted","renderMarkdownSegments","raw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