markdown-flow-ui 0.2.15 → 0.2.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/index.es3.js +4 -5
- package/dist/_virtual/index.es3.js.map +1 -1
- package/dist/_virtual/index.es4.js +5 -4
- package/dist/_virtual/index.es4.js.map +1 -1
- package/dist/_virtual/index3.cjs +1 -1
- package/dist/_virtual/index4.cjs +1 -1
- package/dist/components/ContentRender/ContentRender.cjs +2 -2
- package/dist/components/ContentRender/ContentRender.cjs.map +1 -1
- package/dist/components/ContentRender/ContentRender.d.ts +3 -0
- package/dist/components/ContentRender/ContentRender.es.js +301 -262
- package/dist/components/ContentRender/ContentRender.es.js.map +1 -1
- package/dist/components/ContentRender/index.d.ts +1 -1
- package/dist/components/ContentRender/typewriterPacing.fixtures.d.ts +14 -0
- package/dist/components/ContentRender/utils/typewriter-pacing.cjs +3 -0
- package/dist/components/ContentRender/utils/typewriter-pacing.cjs.map +1 -0
- package/dist/components/ContentRender/utils/typewriter-pacing.d.ts +27 -0
- package/dist/components/ContentRender/utils/typewriter-pacing.es.js +98 -0
- package/dist/components/ContentRender/utils/typewriter-pacing.es.js.map +1 -0
- package/dist/components/ContentRender/utils/typewriter-pacing.test.d.ts +1 -0
- package/dist/components/index.d.ts +1 -1
- package/dist/components/ui/inputGroup/textarea.cjs +1 -1
- package/dist/components/ui/inputGroup/textarea.es.js +1 -1
- package/dist/markdown-flow-ui-lib.css +1 -1
- package/dist/node_modules/rc-input/es/BaseInput.cjs +1 -1
- package/dist/node_modules/rc-input/es/BaseInput.es.js +1 -1
- package/dist/node_modules/rc-textarea/es/ResizableTextArea.cjs +1 -1
- package/dist/node_modules/rc-textarea/es/ResizableTextArea.es.js +1 -1
- package/dist/node_modules/rc-textarea/es/TextArea.cjs +1 -1
- package/dist/node_modules/rc-textarea/es/TextArea.es.js +1 -1
- package/dist/node_modules/rc-textarea/es/index.cjs +1 -1
- package/dist/node_modules/rc-textarea/es/index.es.js +1 -1
- package/dist/node_modules/remark-flow/dist/interaction-plugin-core.cjs +1 -1
- package/dist/node_modules/remark-flow/dist/interaction-plugin-core.es.js +1 -1
- package/dist/renderer.d.ts +2 -2
- package/package.json +1 -1
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
const t = /* @__PURE__ */ r(e);
|
|
1
|
+
import { getAugmentedNamespace as e } from "./_commonjsHelpers.es.js";
|
|
2
|
+
import * as r from "../node_modules/unist-util-visit/index.es.js";
|
|
3
|
+
const m = /* @__PURE__ */ e(r);
|
|
5
4
|
export {
|
|
6
|
-
|
|
5
|
+
m as default
|
|
7
6
|
};
|
|
8
7
|
//# 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,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import { getDefaultExportFromCjs as r } from "./_commonjsHelpers.es.js";
|
|
2
|
+
import { __require as s } from "../node_modules/classnames/index.es.js";
|
|
3
|
+
var e = s();
|
|
4
|
+
const t = /* @__PURE__ */ r(e);
|
|
4
5
|
export {
|
|
5
|
-
|
|
6
|
+
t as default
|
|
6
7
|
};
|
|
7
8
|
//# sourceMappingURL=index.es4.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es4.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.es4.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
package/dist/_virtual/index3.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./_commonjsHelpers.cjs"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./_commonjsHelpers.cjs"),t=require("../node_modules/unist-util-visit/index.cjs"),r=e.getAugmentedNamespace(t);exports.default=r;
|
|
2
2
|
//# sourceMappingURL=index3.cjs.map
|
package/dist/_virtual/index4.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./_commonjsHelpers.cjs"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./_commonjsHelpers.cjs"),r=require("../node_modules/classnames/index.cjs");var s=r.__require();const t=e.getDefaultExportFromCjs(s);exports.default=t;
|
|
2
2
|
//# sourceMappingURL=index4.cjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("react/jsx-runtime"),r=require("react"),_e=require("../../_virtual/index.cjs"),Fe=require("./utils/sanitize-invalid-tag-name.cjs"),We=require("./utils/strip-svg-text-line-breaks.cjs");;/* empty css */;/* empty css */;/* empty css */;/* empty css */const Be=require("./CodeBlock.cjs"),$e=require("./plugins/CustomVariable.cjs"),re=require("./plugins/MermaidChart.cjs"),Ce=require("./utils/custom-variable-props.cjs"),be=require("./utils/highlight-languages.cjs"),se=require("./utils/mermaid-parse.cjs"),ke=require("./utils/normalize-inline-html.cjs"),He=require("./IframeSandbox.cjs"),F=require("./utils/typewriter-pacing.cjs"),Qe=require("./utils/split-content.cjs"),Oe=require("../../lib/interaction-defaults.cjs"),Re=require("../../lib/locale.cjs"),Ne=require("./contentRenderI18n.cjs"),Ue=require("../../node_modules/react-markdown/lib/index.cjs"),Ge=require("../../node_modules/rehype-raw/lib/index.cjs"),Ke=require("../../node_modules/rehype-highlight/lib/index.cjs"),Xe=require("../../node_modules/rehype-katex/lib/index.cjs"),Ye=require("../../node_modules/remark-gfm/lib/index.cjs"),Ze=require("../../node_modules/remark-math/lib/index.cjs"),Je=require("../../node_modules/remark-breaks/lib/index.cjs"),et=/<(script|style|link|iframe|html|head|body|meta|title|base|template|div|section|article|main)\b/i,tt=2,Se=({svg:t})=>{const s=r.useRef(null);return r.useEffect(()=>{const o=s.current;if(!o)return;const a=o.shadowRoot??o.attachShadow({mode:"open"}),T="content-render-svg-style";let d=a.getElementById(T);d||(d=document.createElement("style"),d.id=T,d.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(d)),Array.from(a.childNodes).filter(i=>i!==d).forEach(i=>a.removeChild(i));const M=document.createElement("template"),B=qe.stripSvgTextLineBreaks(t);M.innerHTML=B,a.append(M.content.cloneNode(!0));let C=!1,q=!1;a.querySelectorAll("svg").forEach(i=>{const $=i.getAttribute("viewBox");if(!$)return;const L=$.trim().split(/[\s,]+/).map(l=>Number(l));if(L.length!==4||L.some(Number.isNaN))return;const[,,k,y]=L,R=i.getAttribute("width"),j=i.getAttribute("height"),z=l=>{if(!l)return!1;const x=l.trim().toLowerCase();return x==="auto"||x.endsWith("%")},V=l=>{if(!l)return null;const x=l.trim().toLowerCase();if(x==="auto"||x.endsWith("%"))return null;const b=Number.parseFloat(x);return Number.isNaN(b)?null:b},E=z(R),F=z(j),D=!R||R==="0",I=!j||j==="0",P=V(R),H=V(j);if(E||F||D&&I||P===k&&H===y){C=!0,i.classList.add("content-render-svg-el--responsive"),i.classList.remove("content-render-svg-el--fixed"),i.style.width="100%",i.style.height="auto",!i.style.aspectRatio&&y>0&&(i.style.aspectRatio=`${k} / ${y}`);return}q=!0,i.classList.add("content-render-svg-el--fixed"),i.classList.remove("content-render-svg-el--responsive"),D&&k>0&&i.setAttribute("width",`${k}`),I&&y>0&&i.setAttribute("height",`${y}`)});const v=C&&!q;s.classList.toggle("content-render-svg--responsive",v),s.classList.toggle("content-render-svg--fixed",!v)},[t]),n.jsx("div",{className:"content-render-svg-scroll",children:n.jsx("div",{className:"content-render-svg",ref:r})})},Z=o.createContext(null),_e=t=>{const r=o.useContext(Z),s=o.useContext(ve.CodeBlockContext);if(!r)throw new Error("Markdown code renderer requires ContentRender context.");const{className:a,children:g,...d}=t;if(/language-(\w+)/.exec(a||"")?.[1]==="mermaid"){const B=g?.toString().replace(/\n$/,"")||"",C=Y.mermaidBlockIsComplete(r.current.renderContent,B);return n.jsx(Q.default,{chart:B,frozen:C,messages:r.current.mermaidMessages})}return n.jsx("code",{className:a,...d,dir:d.dir??(s?void 0:"ltr"),children:g})},Oe=[Fe.default,Pe.default,Ne.default,He.default],Ue=[fe.preserveCustomVariableProperties,De.default,Me.sanitizeInvalidTagName,fe.restoreCustomVariableProperties,[Ie.default,{languages:xe.highlightLanguages,subset:xe.subsetLanguages}],Ee.default],ee=({content:t,components:r,locale:s})=>{const a=ye.getContentRenderLocaleTexts(s);return n.jsx("div",{className:"markdown-renderer",children:n.jsx(Ve.Markdown,{remarkPlugins:Oe,rehypePlugins:Ue,remarkRehypeOptions:{footnoteLabel:a.footnoteLabel,footnoteBackLabel:(g,d)=>{const w=String(g+1)+(d>1?`-${d}`:"");return a.footnoteBackLabel.replace("{reference}",w)}},components:r,children:t})})},Ge=t=>{if(t.length<=1)return t;const r=[];return t.forEach(s=>{if(s.type==="sandbox"){r.push(s);return}const a=r[r.length-1];if(a&&a.type!=="sandbox"){r[r.length-1]={type:"markdown",value:`${a.value}${s.value}`};return}r.push({type:"markdown",value:s.value})}),r},Xe=(t,r)=>{const s=Math.max(1,r),a=Array.from(t);return{chunk:a.slice(0,s).join(""),rest:a.slice(s).join("")}},Je=(t,r)=>t===r?!0:!t||!r||t.length!==r.length?!1:t.every((s,a)=>s===r[a]),Ke=t=>{const r=o.useRef(t);return Je(r.current,t)||(r.current=t),r.current},Qe=({content:t,contentType:r,locale:s,lang:a,dir:g,customRenderBar:d,onSend:w,typingSpeed:M=40,enableTypewriter:B=!1,onTypeFinished:C,onTypewriterStateChange:q,userInput:v,interactionDefaultValueOptions:i,defaultButtonText:$,defaultInputText:L,defaultSelectedValues:k,readonly:y=!1,confirmButtonText:R,copyButtonText:j,copiedButtonText:z,sandboxLoadingText:V,sandboxStyleLoadingText:E,sandboxScriptLoadingText:F,disableSandboxLoadingOverlay:D=!1,sandboxFullscreenButtonText:I,sandboxExitFullscreenButtonText:P,sandboxMode:H="content",onClickCustomButtonAfterContent:W,beforeSend:_})=>{const l=ye.getContentRenderLocaleTexts(s),x=o.useMemo(()=>({loading:l.mermaidLoadingText,emptyChart:l.mermaidEmptyChartText,error:l.mermaidErrorText}),[l]),b=g??pe.getMarkdownFlowDirection(s),A=a??pe.getMarkdownFlowLanguage(s),te=R||l.confirmButtonText,ne=j||l.copyButtonText,re=z||l.copiedButtonText,be=I||l.sandboxFullscreenButtonText,Te=P||l.sandboxExitFullscreenButtonText,m=!!B&&(!r||r==="text"),se=2,oe=Math.max(0,M),[T,O]=o.useState(()=>m?"":t),S=o.useRef(""),ae=o.useRef(m),U=o.useRef(!1);o.useEffect(()=>{const e=ae.current;if(ae.current=m,U.current=!1,!m){S.current="",O(t);return}O(c=>{const f=!e,N=t.startsWith(c);if(!f&&!N)return S.current="",t;const h=f||!N?"":c;return S.current=t.slice(h.length),h})},[t,m]),o.useEffect(()=>{m&&(U.current||S.current||T!==t||(U.current=!0,C?.()))},[t,T,m,C]),o.useEffect(()=>{if(!m||!S.current)return;const e=window.setTimeout(()=>{O(c=>{const{chunk:f,rest:N}=Xe(S.current,se);return f?(S.current=N,`${c}${f}`):c})},oe);return()=>window.clearTimeout(e)},[t,T,m,se,oe]);const ie=o.useMemo(()=>({isTypewriterEnabled:m,isTyping:m&&T!==t,isComplete:T===t,renderedLength:T.length,totalLength:t.length}),[t,T,m]);o.useEffect(()=>{q?.(ie)},[q,ie]);const p=m?T:t,G=o.useMemo(()=>he.normalizeInlineHtml(p),[p]),X=o.useMemo(()=>ze.getInteractionDefaultValues(p,v,i),[i,p,v]),ce=$?.trim()||X.buttonText,le=L?.trim()||X.inputText,we=o.useMemo(()=>v?v.split(",").map(e=>e.trim()).filter(Boolean):void 0,[v]),Ce=k?.length?k:X.selectedValues||we,ue=Ke(Ce),u=o.useRef({direction:b,language:A,mermaidMessages:x,beforeSend:_,locale:s,onClickCustomButtonAfterContent:W,onSend:w,readonly:y,renderContent:p,resolvedConfirmButtonText:te,resolvedCopiedButtonText:re,resolvedCopyButtonText:ne,resolvedDefaultButtonText:ce,resolvedDefaultInputText:le,resolvedDefaultSelectedValues:ue});u.current={direction:b,language:A,mermaidMessages:x,beforeSend:_,locale:s,onClickCustomButtonAfterContent:W,onSend:w,readonly:y,renderContent:p,resolvedConfirmButtonText:te,resolvedCopiedButtonText:re,resolvedCopyButtonText:ne,resolvedDefaultButtonText:ce,resolvedDefaultInputText:le,resolvedDefaultSelectedValues:ue};const de=o.useMemo(()=>({"custom-button-after-content":({children:e})=>n.jsx("button",{className:"content-render-custom-button-after-content",onClick:u.current.onClickCustomButtonAfterContent,children:n.jsx("span",{className:"content-render-custom-button-after-content-inner",children:e})}),"custom-variable":e=>n.jsx(Le.default,{...e,readonly:u.current.readonly,defaultButtonText:u.current.resolvedDefaultButtonText,defaultInputText:u.current.resolvedDefaultInputText,defaultSelectedValues:u.current.resolvedDefaultSelectedValues,onSend:u.current.onSend,beforeSend:u.current.beforeSend,locale:u.current.locale,dir:u.current.direction,lang:u.current.language,confirmButtonText:u.current.resolvedConfirmButtonText}),code:_e,table:({...e})=>n.jsx("div",{className:"content-render-table-container",children:n.jsx("table",{className:"content-render-table",...e})}),th:({...e})=>n.jsx("th",{className:"content-render-th",...e}),td:({...e})=>n.jsx("td",{className:"content-render-td",...e}),tr:({...e})=>n.jsx("tr",{className:"content-render-tr",...e}),li:({node:e,...c})=>{const f=e?.properties?.className;return typeof f=="string"&&f.includes("task-list-item")||Array.isArray(f)&&f.includes("task-list-item")?n.jsx("li",{className:"content-render-task-list-item",...c}):n.jsx("li",{...c})},ol:({...e})=>n.jsx("ol",{className:"content-render-ol",...e}),ul:({...e})=>n.jsx("ul",{className:"content-render-ul",...e}),input:({...e})=>e.type==="checkbox"?n.jsx("input",{type:"checkbox",className:"content-render-checkbox",disabled:!0,...e}):n.jsx("input",{...e}),a:({children:e,...c})=>n.jsx("a",{target:"_blank",rel:"noopener noreferrer",...c,children:e}),pre:e=>n.jsx(ve.default,{...e,copyButtonText:u.current.resolvedCopyButtonText,copiedButtonText:u.current.resolvedCopiedButtonText})}),[]),me=o.useMemo(()=>We.test(p),[p]),J=o.useMemo(()=>me?$e.splitContentSegments(p,!0):[],[p,me]),ke=J.some(e=>e.type==="sandbox"),Se=o.useMemo(()=>Ge(J),[J]),Be=o.useMemo(()=>Y.parseMarkdownSegments(G),[G]),Re=(e,c)=>{const f=he.normalizeInlineHtml(e);return Y.parseMarkdownSegments(f).map((h,je)=>{const K=`${c}-${h.type}-${je}`;return h.type==="text"?n.jsx(Z.Provider,{value:u,children:n.jsx(ee,{locale:s,components:de,content:h.value})},K):h.type==="mermaid"?n.jsx(Q.default,{chart:h.value,frozen:!h.complete,messages:x},K):h.type==="svg"?n.jsx(ge,{svg:h.value},K):null})};return ke?n.jsx("div",{className:"content-render markdown-body",dir:b,lang:A,children:Se.map((e,c)=>e.type==="sandbox"?n.jsx(Ae.default,{hideFullScreen:!0,type:"sandbox",content:e.value,className:"content-render-iframe",locale:s,dir:b,lang:A,loadingText:V,styleLoadingText:E,scriptLoadingText:F,disableLoadingOverlay:D,fullScreenButtonText:be,exitFullScreenButtonText:Te,mode:H},`sandbox-${c}`):n.jsx(o.Fragment,{children:Re(e.value,`md-${c}`)},`md-${c}`))}):n.jsxs("div",{className:"content-render markdown-body",dir:b,lang:A,children:[Be.map((e,c)=>{if(e.type==="text")return n.jsx(Z.Provider,{value:u,children:n.jsx(ee,{locale:s,components:de,content:e.value})},c);if(e.type==="mermaid")return n.jsx(Q.default,{chart:e.value,frozen:!e.complete,messages:x},c);if(e.type==="svg")return n.jsx(ge,{svg:e.value},c)}),d&&n.jsx("div",{className:"content-render-custom-bar",children:o.createElement(d,{content:t,displayContent:G,onSend:w})})]})};exports.MarkdownRenderer=ee;exports.default=Qe;
|
|
5
|
+
`,a.appendChild(d)),Array.from(a.childNodes).filter(c=>c!==d).forEach(c=>a.removeChild(c));const A=document.createElement("template"),j=We.stripSvgTextLineBreaks(t);A.innerHTML=j,a.append(A.content.cloneNode(!0));let h=!1,E=!1;a.querySelectorAll("svg").forEach(c=>{const D=c.getAttribute("viewBox");if(!D)return;const V=D.trim().split(/[\s,]+/).map(g=>Number(g));if(V.length!==4||V.some(Number.isNaN))return;const[,,q,C]=V,R=c.getAttribute("width"),M=c.getAttribute("height"),W=g=>{if(!g)return!1;const u=g.trim().toLowerCase();return u==="auto"||u.endsWith("%")},$=g=>{if(!g)return null;const u=g.trim().toLowerCase();if(u==="auto"||u.endsWith("%"))return null;const S=Number.parseFloat(u);return Number.isNaN(S)?null:S},U=W(R),G=W(M),H=!R||R==="0",Q=!M||M==="0",K=$(R),X=$(M);if(U||G||H&&Q||K===q&&X===C){h=!0,c.classList.add("content-render-svg-el--responsive"),c.classList.remove("content-render-svg-el--fixed"),c.style.width="100%",c.style.height="auto",!c.style.aspectRatio&&C>0&&(c.style.aspectRatio=`${q} / ${C}`);return}E=!0,c.classList.add("content-render-svg-el--fixed"),c.classList.remove("content-render-svg-el--responsive"),H&&q>0&&c.setAttribute("width",`${q}`),Q&&C>0&&c.setAttribute("height",`${C}`)});const I=h&&!E;o.classList.toggle("content-render-svg--responsive",I),o.classList.toggle("content-render-svg--fixed",!I)},[t]),n.jsx("div",{className:"content-render-svg-scroll",children:n.jsx("div",{className:"content-render-svg",ref:s})})},oe=r.createContext(null),nt=t=>{const s=r.useContext(oe),o=r.useContext(Be.CodeBlockContext);if(!s)throw new Error("Markdown code renderer requires ContentRender context.");const{className:a,children:T,...d}=t;if(/language-(\w+)/.exec(a||"")?.[1]==="mermaid"){const j=T?.toString().replace(/\n$/,"")||"",h=se.mermaidBlockIsComplete(s.current.renderContent,j);return n.jsx(re.default,{chart:j,frozen:h,messages:s.current.mermaidMessages})}return n.jsx("code",{className:a,...d,dir:d.dir??(o?void 0:"ltr"),children:T})},rt=[Ye.default,Ze.default,_e.default,Je.default],st=[Ce.preserveCustomVariableProperties,Ge.default,Fe.sanitizeInvalidTagName,Ce.restoreCustomVariableProperties,[Ke.default,{languages:be.highlightLanguages,subset:be.subsetLanguages}],Xe.default],ae=({content:t,components:s,locale:o})=>{const a=Ne.getContentRenderLocaleTexts(o);return n.jsx("div",{className:"markdown-renderer",children:n.jsx(Ue.Markdown,{remarkPlugins:rt,rehypePlugins:st,remarkRehypeOptions:{footnoteLabel:a.footnoteLabel,footnoteBackLabel:(T,d)=>{const k=String(T+1)+(d>1?`-${d}`:"");return a.footnoteBackLabel.replace("{reference}",k)}},components:s,children:t})})},ot=t=>{if(t.length<=1)return t;const s=[];return t.forEach(o=>{if(o.type==="sandbox"){s.push(o);return}const a=s[s.length-1];if(a&&a.type!=="sandbox"){s[s.length-1]={type:"markdown",value:`${a.value}${o.value}`};return}s.push({type:"markdown",value:o.value})}),s},at=(t,s)=>{const o=Math.max(1,s),a=Array.from(t);return{chunk:a.slice(0,o).join(""),rest:a.slice(o).join("")}},ct=(t,s)=>t===s?!0:!t||!s||t.length!==s.length?!1:t.every((o,a)=>o===s[a]),it=t=>{const s=r.useRef(t);return ct(s.current,t)||(s.current=t),s.current},ut=({content:t,contentType:s,locale:o,lang:a,dir:T,customRenderBar:d,onSend:k,typingSpeed:A=40,enableTypewriter:j=!1,typewriterPacing:h="fixed",onTypeFinished:E,onTypewriterStateChange:I,userInput:c,interactionDefaultValueOptions:D,defaultButtonText:V,defaultInputText:q,defaultSelectedValues:C,readonly:R=!1,confirmButtonText:M,copyButtonText:W,copiedButtonText:$,sandboxLoadingText:U,sandboxStyleLoadingText:G,sandboxScriptLoadingText:H,disableSandboxLoadingOverlay:Q=!1,sandboxFullscreenButtonText:K,sandboxExitFullscreenButtonText:X,sandboxMode:ce="content",onClickCustomButtonAfterContent:Y,beforeSend:g})=>{const u=Ne.getContentRenderLocaleTexts(o),S=r.useMemo(()=>({loading:u.mermaidLoadingText,emptyChart:u.mermaidEmptyChartText,error:u.mermaidErrorText}),[u]),z=T??Re.getMarkdownFlowDirection(o),P=a??Re.getMarkdownFlowLanguage(o),ie=M||u.confirmButtonText,ue=W||u.copyButtonText,le=$||u.copiedButtonText,je=K||u.sandboxFullscreenButtonText,qe=X||u.sandboxExitFullscreenButtonText,m=!!j&&(!s||s==="text"),de=Math.max(0,A),Me=h==="fixed"?t:void 0,[y,me]=r.useState(()=>m?"":t),O=r.useRef(y),p=r.useRef(""),b=r.useRef({tokens:[],head:0}),B=r.useRef(0),fe=r.useRef(m),xe=r.useRef(h),he=r.useRef(t),Z=r.useRef(!1),[Le,Ae]=r.useState(0);r.useEffect(()=>{const e=fe.current,i=xe.current,f=he.current,w=!!p.current;fe.current=m,xe.current=h,he.current=t,(t!==f||m!==e)&&(Z.current=!1);const x=()=>{p.current="",b.current={tokens:[],head:0},B.current=0},_=L=>{O.current=L,me(L)};if(!m){x(),_(t);return}e||(x(),_(""));const N=e?O.current:"";if(!t.startsWith(N)){x(),_(t);return}const ne=t.slice(N.length);if(!ne){x();return}if(h==="content-aware"){const L=f.slice(N.length);e&&i==="content-aware"&&t.startsWith(f)&&p.current===L?b.current=F.appendContentAwareTypewriterQueue(b.current,t.slice(f.length)):(b.current=F.createContentAwareTypewriterQueue(ne),B.current=0)}else b.current={tokens:[],head:0},B.current=0;p.current=ne,w||Ae(L=>L+1)},[t,m,h]),r.useEffect(()=>{m&&(Z.current||p.current||y!==t||(Z.current=!0,E?.()))},[t,y,m,E]),r.useEffect(()=>{if(!m||!p.current)return;const e=window.setTimeout(()=>{if(!p.current)return;let i="";if(h==="content-aware"){const w=F.consumeContentAwareTypewriterQueue(b.current,B.current+F.CONTENT_AWARE_TYPEWRITER_TICK_BUDGET);i=w.chunk,b.current=w.queue,F.isContentAwareTypewriterQueueEmpty(w.queue)?B.current=0:B.current=w.remainingBudget}else i=at(p.current,tt).chunk;if(!i)return;p.current=p.current.slice(i.length),p.current||(b.current={tokens:[],head:0},B.current=0);const f=`${O.current}${i}`;O.current=f,me(f)},de);return()=>window.clearTimeout(e)},[y,Me,m,h,de,Le]);const pe=r.useMemo(()=>({isTypewriterEnabled:m,isTyping:m&&y!==t,isComplete:y===t,renderedLength:y.length,totalLength:t.length}),[t,y,m]);r.useEffect(()=>{I?.(pe)},[I,pe]);const v=m?y:t,J=r.useMemo(()=>ke.normalizeInlineHtml(v),[v]),ee=r.useMemo(()=>Oe.getInteractionDefaultValues(v,c,D),[D,v,c]),ge=V?.trim()||ee.buttonText,ve=q?.trim()||ee.inputText,Ee=r.useMemo(()=>c?c.split(",").map(e=>e.trim()).filter(Boolean):void 0,[c]),Ie=C?.length?C:ee.selectedValues||Ee,Te=it(Ie),l=r.useRef({direction:z,language:P,mermaidMessages:S,beforeSend:g,locale:o,onClickCustomButtonAfterContent:Y,onSend:k,readonly:R,renderContent:v,resolvedConfirmButtonText:ie,resolvedCopiedButtonText:le,resolvedCopyButtonText:ue,resolvedDefaultButtonText:ge,resolvedDefaultInputText:ve,resolvedDefaultSelectedValues:Te});l.current={direction:z,language:P,mermaidMessages:S,beforeSend:g,locale:o,onClickCustomButtonAfterContent:Y,onSend:k,readonly:R,renderContent:v,resolvedConfirmButtonText:ie,resolvedCopiedButtonText:le,resolvedCopyButtonText:ue,resolvedDefaultButtonText:ge,resolvedDefaultInputText:ve,resolvedDefaultSelectedValues:Te};const ye=r.useMemo(()=>({"custom-button-after-content":({children:e})=>n.jsx("button",{className:"content-render-custom-button-after-content",onClick:l.current.onClickCustomButtonAfterContent,children:n.jsx("span",{className:"content-render-custom-button-after-content-inner",children:e})}),"custom-variable":e=>n.jsx($e.default,{...e,readonly:l.current.readonly,defaultButtonText:l.current.resolvedDefaultButtonText,defaultInputText:l.current.resolvedDefaultInputText,defaultSelectedValues:l.current.resolvedDefaultSelectedValues,onSend:l.current.onSend,beforeSend:l.current.beforeSend,locale:l.current.locale,dir:l.current.direction,lang:l.current.language,confirmButtonText:l.current.resolvedConfirmButtonText}),code:nt,table:({...e})=>n.jsx("div",{className:"content-render-table-container",children:n.jsx("table",{className:"content-render-table",...e})}),th:({...e})=>n.jsx("th",{className:"content-render-th",...e}),td:({...e})=>n.jsx("td",{className:"content-render-td",...e}),tr:({...e})=>n.jsx("tr",{className:"content-render-tr",...e}),li:({node:e,...i})=>{const f=e?.properties?.className;return typeof f=="string"&&f.includes("task-list-item")||Array.isArray(f)&&f.includes("task-list-item")?n.jsx("li",{className:"content-render-task-list-item",...i}):n.jsx("li",{...i})},ol:({...e})=>n.jsx("ol",{className:"content-render-ol",...e}),ul:({...e})=>n.jsx("ul",{className:"content-render-ul",...e}),input:({...e})=>e.type==="checkbox"?n.jsx("input",{type:"checkbox",className:"content-render-checkbox",disabled:!0,...e}):n.jsx("input",{...e}),a:({children:e,...i})=>n.jsx("a",{target:"_blank",rel:"noopener noreferrer",...i,children:e}),pre:e=>n.jsx(Be.default,{...e,copyButtonText:l.current.resolvedCopyButtonText,copiedButtonText:l.current.resolvedCopiedButtonText})}),[]),we=r.useMemo(()=>et.test(v),[v]),te=r.useMemo(()=>we?Qe.splitContentSegments(v,!0):[],[v,we]),De=te.some(e=>e.type==="sandbox"),Ve=r.useMemo(()=>ot(te),[te]),ze=r.useMemo(()=>se.parseMarkdownSegments(J),[J]),Pe=(e,i)=>{const f=ke.normalizeInlineHtml(e);return se.parseMarkdownSegments(f).map((x,_)=>{const N=`${i}-${x.type}-${_}`;return x.type==="text"?n.jsx(oe.Provider,{value:l,children:n.jsx(ae,{locale:o,components:ye,content:x.value})},N):x.type==="mermaid"?n.jsx(re.default,{chart:x.value,frozen:!x.complete,messages:S},N):x.type==="svg"?n.jsx(Se,{svg:x.value},N):null})};return De?n.jsx("div",{className:"content-render markdown-body",dir:z,lang:P,children:Ve.map((e,i)=>e.type==="sandbox"?n.jsx(He.default,{hideFullScreen:!0,type:"sandbox",content:e.value,className:"content-render-iframe",locale:o,dir:z,lang:P,loadingText:U,styleLoadingText:G,scriptLoadingText:H,disableLoadingOverlay:Q,fullScreenButtonText:je,exitFullScreenButtonText:qe,mode:ce},`sandbox-${i}`):n.jsx(r.Fragment,{children:Pe(e.value,`md-${i}`)},`md-${i}`))}):n.jsxs("div",{className:"content-render markdown-body",dir:z,lang:P,children:[ze.map((e,i)=>{if(e.type==="text")return n.jsx(oe.Provider,{value:l,children:n.jsx(ae,{locale:o,components:ye,content:e.value})},i);if(e.type==="mermaid")return n.jsx(re.default,{chart:e.value,frozen:!e.complete,messages:S},i);if(e.type==="svg")return n.jsx(Se,{svg:e.value},i)}),d&&n.jsx("div",{className:"content-render-custom-bar",children:r.createElement(d,{content:t,displayContent:J,onSend:k})})]})};exports.MarkdownRenderer=ae;exports.default=ut;
|
|
6
6
|
//# sourceMappingURL=ContentRender.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentRender.cjs","sources":["../../../src/components/ContentRender/ContentRender.tsx"],"sourcesContent":["import 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 type { PluggableList } from \"unified\";\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 \"highlight.js/styles/github.css\";\nimport \"katex/dist/katex.min.css\";\nimport CodeBlock, { CodeBlockContext } from \"./CodeBlock\";\nimport CustomButtonInputVariable, {\n ComponentsWithCustomVariable,\n} from \"./plugins/CustomVariable\";\nimport MermaidChart, { type MermaidChartProps } 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 {\n getMarkdownFlowDirection,\n getMarkdownFlowLanguage,\n type MarkdownFlowLocale,\n} 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 /** Overrides the locale-derived language; omitted values inherit from the host. */\n lang?: string;\n /** Overrides locale-derived direction; omitted values inherit when no locale is set. */\n dir?: React.HTMLAttributes<HTMLDivElement>[\"dir\"];\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\ntype MarkdownComponentRuntimeValues = {\n direction?: ContentRenderProps[\"dir\"];\n language?: string;\n mermaidMessages: MermaidChartProps[\"messages\"];\n beforeSend?: (param: OnSendContentParams) => boolean;\n locale?: MarkdownFlowLocale;\n onClickCustomButtonAfterContent?: () => void;\n onSend?: (content: OnSendContentParams) => void;\n readonly: boolean;\n renderContent: string;\n resolvedConfirmButtonText: string;\n resolvedCopiedButtonText: string;\n resolvedCopyButtonText: string;\n resolvedDefaultButtonText?: string;\n resolvedDefaultInputText?: string;\n resolvedDefaultSelectedValues?: string[];\n};\n\nconst MarkdownComponentRuntimeContext =\n React.createContext<React.RefObject<MarkdownComponentRuntimeValues> | null>(\n null\n );\n\nconst MarkdownCode = (props: React.ComponentProps<\"code\">) => {\n const runtimeValuesRef = React.useContext(MarkdownComponentRuntimeContext);\n const isInCodeBlock = React.useContext(CodeBlockContext);\n if (!runtimeValuesRef) {\n throw new Error(\"Markdown code renderer requires ContentRender context.\");\n }\n const { className, children, ...rest } = props as {\n className?: string;\n children?: React.ReactNode;\n dir?: string;\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(\n runtimeValuesRef.current.renderContent,\n chartContent\n );\n return (\n <MermaidChart\n chart={chartContent}\n frozen={frozen}\n messages={runtimeValuesRef.current.mermaidMessages}\n />\n );\n }\n\n return (\n <code\n className={className}\n {...rest}\n dir={rest.dir ?? (isInCodeBlock ? undefined : \"ltr\")}\n >\n {children}\n </code>\n );\n};\n\nconst remarkPlugins: PluggableList = [\n remarkGfm,\n remarkMath,\n remarkFlow,\n remarkBreaks,\n];\n\nconst rehypePlugins: PluggableList = [\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 locale?: MarkdownFlowLocale;\n}> = ({ content: markdownContent, components, locale }) => {\n const texts = getContentRenderLocaleTexts(locale);\n return (\n <div className=\"markdown-renderer\">\n <ReactMarkdown\n remarkPlugins={remarkPlugins}\n rehypePlugins={rehypePlugins}\n remarkRehypeOptions={{\n footnoteLabel: texts.footnoteLabel,\n footnoteBackLabel: (referenceIndex, rereferenceIndex) => {\n const reference =\n String(referenceIndex + 1) +\n (rereferenceIndex > 1 ? `-${rereferenceIndex}` : \"\");\n return texts.footnoteBackLabel.replace(\"{reference}\", reference);\n },\n }}\n components={components}\n >\n {markdownContent}\n </ReactMarkdown>\n </div>\n );\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 areStringArraysEqual = (left?: string[], right?: string[]) => {\n if (left === right) {\n return true;\n }\n if (!left || !right || left.length !== right.length) {\n return false;\n }\n return left.every((value, index) => value === right[index]);\n};\n\nconst useStableStringArray = (values?: string[]) => {\n const valuesRef = useRef<string[] | undefined>(values);\n\n if (!areStringArraysEqual(valuesRef.current, values)) {\n valuesRef.current = values;\n }\n\n return valuesRef.current;\n};\n\nconst ContentRender: React.FC<ContentRenderProps> = ({\n content,\n contentType,\n locale,\n lang,\n dir,\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 mermaidMessages = useMemo(\n () => ({\n loading: localeTexts.mermaidLoadingText,\n emptyChart: localeTexts.mermaidEmptyChartText,\n error: localeTexts.mermaidErrorText,\n }),\n [localeTexts]\n );\n const direction = dir ?? getMarkdownFlowDirection(locale);\n const language = lang ?? getMarkdownFlowLanguage(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 const stableDefaultSelectedValues = useStableStringArray(\n resolvedDefaultSelectedValues\n );\n const componentRuntimeValuesRef = useRef<MarkdownComponentRuntimeValues>({\n direction,\n language,\n mermaidMessages,\n beforeSend,\n locale,\n onClickCustomButtonAfterContent,\n onSend,\n readonly,\n renderContent,\n resolvedConfirmButtonText,\n resolvedCopiedButtonText,\n resolvedCopyButtonText,\n resolvedDefaultButtonText,\n resolvedDefaultInputText,\n resolvedDefaultSelectedValues: stableDefaultSelectedValues,\n });\n\n componentRuntimeValuesRef.current = {\n direction,\n language,\n mermaidMessages,\n beforeSend,\n locale,\n onClickCustomButtonAfterContent,\n onSend,\n readonly,\n renderContent,\n resolvedConfirmButtonText,\n resolvedCopiedButtonText,\n resolvedCopyButtonText,\n resolvedDefaultButtonText,\n resolvedDefaultInputText,\n resolvedDefaultSelectedValues: stableDefaultSelectedValues,\n };\n\n const components = useMemo<CustomComponents>(\n () => ({\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={\n componentRuntimeValuesRef.current.onClickCustomButtonAfterContent\n }\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={componentRuntimeValuesRef.current.readonly}\n defaultButtonText={\n componentRuntimeValuesRef.current.resolvedDefaultButtonText\n }\n defaultInputText={\n componentRuntimeValuesRef.current.resolvedDefaultInputText\n }\n defaultSelectedValues={\n componentRuntimeValuesRef.current.resolvedDefaultSelectedValues\n }\n onSend={componentRuntimeValuesRef.current.onSend}\n beforeSend={componentRuntimeValuesRef.current.beforeSend}\n locale={componentRuntimeValuesRef.current.locale}\n dir={componentRuntimeValuesRef.current.direction}\n lang={componentRuntimeValuesRef.current.language}\n confirmButtonText={\n componentRuntimeValuesRef.current.resolvedConfirmButtonText\n }\n // tooltipMinLength={tooltipMinLength}\n />\n ),\n code: MarkdownCode,\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={\n componentRuntimeValuesRef.current.resolvedCopyButtonText\n }\n copiedButtonText={\n componentRuntimeValuesRef.current.resolvedCopiedButtonText\n }\n />\n ),\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 <MarkdownComponentRuntimeContext.Provider\n key={key}\n value={componentRuntimeValuesRef}\n >\n <MarkdownRenderer\n locale={locale}\n components={components}\n content={seg.value}\n />\n </MarkdownComponentRuntimeContext.Provider>\n );\n }\n\n if (seg.type === \"mermaid\") {\n return (\n <MermaidChart\n key={key}\n chart={seg.value}\n frozen={!seg.complete}\n messages={mermaidMessages}\n />\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\n className=\"content-render markdown-body\"\n dir={direction}\n lang={language}\n >\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 dir={direction}\n lang={language}\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\n className=\"content-render markdown-body\"\n dir={direction}\n lang={language}\n >\n {segments.map((seg, index) => {\n if (seg.type === \"text\") {\n return (\n <MarkdownComponentRuntimeContext.Provider\n key={index}\n value={componentRuntimeValuesRef}\n >\n <MarkdownRenderer\n locale={locale}\n components={components}\n content={seg.value}\n />\n </MarkdownComponentRuntimeContext.Provider>\n );\n }\n\n if (seg.type === \"mermaid\") {\n return (\n <MermaidChart\n key={index}\n chart={seg.value}\n frozen={!seg.complete}\n messages={mermaidMessages}\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","MarkdownComponentRuntimeContext","React","MarkdownCode","props","runtimeValuesRef","isInCodeBlock","CodeBlockContext","className","children","rest","chartContent","frozen","mermaidBlockIsComplete","MermaidChart","remarkPlugins","remarkGfm","remarkMath","remarkFlow","remarkBreaks","rehypePlugins","preserveCustomVariableProperties","rehypeRaw","sanitizeInvalidTagName","restoreCustomVariableProperties","rehypeHighlight","highlightLanguages","subsetLanguages","rehypeKatex","MarkdownRenderer","markdownContent","components","locale","texts","getContentRenderLocaleTexts","ReactMarkdown","referenceIndex","rereferenceIndex","reference","mergeNonSandboxSegments","segments","merged","segment","last","splitTextByCharacterChunk","chunkSize","safeChunkSize","characters","areStringArraysEqual","left","right","index","useStableStringArray","values","valuesRef","ContentRender","content","contentType","lang","dir","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","mermaidMessages","useMemo","direction","getMarkdownFlowDirection","language","getMarkdownFlowLanguage","resolvedConfirmButtonText","resolvedCopyButtonText","resolvedCopiedButtonText","resolvedSandboxFullscreenButtonText","resolvedSandboxExitFullscreenButtonText","isTypewriterEnabled","typewriterChunkSize","typewriterTickMs","displayContent","setDisplayContent","useState","pendingContentRef","previousTypewriterEnabledRef","hasReportedTypeFinishedRef","wasTypewriterEnabled","current","shouldRestartTyping","canContinueTyping","nextVisibleContent","typewriterTimer","chunk","typewriterState","renderContent","normalizedContent","normalizeInlineHtml","interactionDefaults","getInteractionDefaultValues","resolvedDefaultButtonText","resolvedDefaultInputText","fallbackSelectedValues","resolvedDefaultSelectedValues","stableDefaultSelectedValues","componentRuntimeValuesRef","CustomButtonInputVariable","CodeBlock","hasPotentialSandboxTags","renderSegments","splitContentSegments","hasSandbox","mergedRenderSegments","parseMarkdownSegments","renderMarkdownSegments","raw","keyPrefix","seg","key","idx","IframeSandbox","jsxs"],"mappings":"o5CAoDMA,GACJ,kGAuEIC,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,EAA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AAA,CAEC,MAAOyH,EAAI,MACX,OAAQ,CAACA,EAAI,SACb,SAAUlD,CAAA,EAHLlC,CAAA,EAQX,GAAIoF,EAAI,OAAS,MACf,OAAOvI,EAAAA,IAAClC,GAAA,CAA6B,IAAKyK,EAAI,OAAhBpF,CAAuB,CAEzD,CAAC,EAEAS,GACC5D,EAAAA,IAAC,MAAA,CAAI,UAAU,4BACZ,SAAAE,EAAM,cAAc0D,EAAiB,CACpC,QAAAJ,EACA,eAAgB0D,EAChB,OAAArD,CAAA,CACD,CAAA,CACH,CAAA,CAAA,CAAA,CAIR"}
|
|
1
|
+
{"version":3,"file":"ContentRender.cjs","sources":["../../../src/components/ContentRender/ContentRender.tsx"],"sourcesContent":["import 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 type { PluggableList } from \"unified\";\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 \"highlight.js/styles/github.css\";\nimport \"katex/dist/katex.min.css\";\nimport CodeBlock, { CodeBlockContext } from \"./CodeBlock\";\nimport CustomButtonInputVariable, {\n ComponentsWithCustomVariable,\n} from \"./plugins/CustomVariable\";\nimport MermaidChart, { type MermaidChartProps } 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 appendContentAwareTypewriterQueue,\n CONTENT_AWARE_TYPEWRITER_TICK_BUDGET,\n consumeContentAwareTypewriterQueue,\n createContentAwareTypewriterQueue,\n isContentAwareTypewriterQueueEmpty,\n type ContentAwareTypewriterQueue,\n} from \"./utils/typewriter-pacing\";\nimport {\n splitContentSegments,\n type RenderSegment,\n} from \"./utils/split-content\";\nimport {\n getInteractionDefaultValues,\n type InteractionDefaultValueOptions,\n} from \"../../lib/interaction-defaults\";\nimport {\n getMarkdownFlowDirection,\n getMarkdownFlowLanguage,\n type MarkdownFlowLocale,\n} 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;\nconst FIXED_TYPEWRITER_CHUNK_SIZE = 2;\n\nexport type ContentRenderTypewriterPacing = \"fixed\" | \"content-aware\";\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 /** Overrides the locale-derived language; omitted values inherit from the host. */\n lang?: string;\n /** Overrides locale-derived direction; omitted values inherit when no locale is set. */\n dir?: React.HTMLAttributes<HTMLDivElement>[\"dir\"];\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 /** Controls how much text is revealed per tick. Defaults to the legacy fixed pacing. */\n typewriterPacing?: ContentRenderTypewriterPacing;\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\ntype MarkdownComponentRuntimeValues = {\n direction?: ContentRenderProps[\"dir\"];\n language?: string;\n mermaidMessages: MermaidChartProps[\"messages\"];\n beforeSend?: (param: OnSendContentParams) => boolean;\n locale?: MarkdownFlowLocale;\n onClickCustomButtonAfterContent?: () => void;\n onSend?: (content: OnSendContentParams) => void;\n readonly: boolean;\n renderContent: string;\n resolvedConfirmButtonText: string;\n resolvedCopiedButtonText: string;\n resolvedCopyButtonText: string;\n resolvedDefaultButtonText?: string;\n resolvedDefaultInputText?: string;\n resolvedDefaultSelectedValues?: string[];\n};\n\nconst MarkdownComponentRuntimeContext =\n React.createContext<React.RefObject<MarkdownComponentRuntimeValues> | null>(\n null\n );\n\nconst MarkdownCode = (props: React.ComponentProps<\"code\">) => {\n const runtimeValuesRef = React.useContext(MarkdownComponentRuntimeContext);\n const isInCodeBlock = React.useContext(CodeBlockContext);\n if (!runtimeValuesRef) {\n throw new Error(\"Markdown code renderer requires ContentRender context.\");\n }\n const { className, children, ...rest } = props as {\n className?: string;\n children?: React.ReactNode;\n dir?: string;\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(\n runtimeValuesRef.current.renderContent,\n chartContent\n );\n return (\n <MermaidChart\n chart={chartContent}\n frozen={frozen}\n messages={runtimeValuesRef.current.mermaidMessages}\n />\n );\n }\n\n return (\n <code\n className={className}\n {...rest}\n dir={rest.dir ?? (isInCodeBlock ? undefined : \"ltr\")}\n >\n {children}\n </code>\n );\n};\n\nconst remarkPlugins: PluggableList = [\n remarkGfm,\n remarkMath,\n remarkFlow,\n remarkBreaks,\n];\n\nconst rehypePlugins: PluggableList = [\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 locale?: MarkdownFlowLocale;\n}> = ({ content: markdownContent, components, locale }) => {\n const texts = getContentRenderLocaleTexts(locale);\n return (\n <div className=\"markdown-renderer\">\n <ReactMarkdown\n remarkPlugins={remarkPlugins}\n rehypePlugins={rehypePlugins}\n remarkRehypeOptions={{\n footnoteLabel: texts.footnoteLabel,\n footnoteBackLabel: (referenceIndex, rereferenceIndex) => {\n const reference =\n String(referenceIndex + 1) +\n (rereferenceIndex > 1 ? `-${rereferenceIndex}` : \"\");\n return texts.footnoteBackLabel.replace(\"{reference}\", reference);\n },\n }}\n components={components}\n >\n {markdownContent}\n </ReactMarkdown>\n </div>\n );\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 areStringArraysEqual = (left?: string[], right?: string[]) => {\n if (left === right) {\n return true;\n }\n if (!left || !right || left.length !== right.length) {\n return false;\n }\n return left.every((value, index) => value === right[index]);\n};\n\nconst useStableStringArray = (values?: string[]) => {\n const valuesRef = useRef<string[] | undefined>(values);\n\n if (!areStringArraysEqual(valuesRef.current, values)) {\n valuesRef.current = values;\n }\n\n return valuesRef.current;\n};\n\nconst ContentRender: React.FC<ContentRenderProps> = ({\n content,\n contentType,\n locale,\n lang,\n dir,\n customRenderBar,\n onSend,\n typingSpeed = 40,\n enableTypewriter = false,\n typewriterPacing = \"fixed\",\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 mermaidMessages = useMemo(\n () => ({\n loading: localeTexts.mermaidLoadingText,\n emptyChart: localeTexts.mermaidEmptyChartText,\n error: localeTexts.mermaidErrorText,\n }),\n [localeTexts]\n );\n const direction = dir ?? getMarkdownFlowDirection(locale);\n const language = lang ?? getMarkdownFlowLanguage(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 typewriterTickMs = Math.max(0, typingSpeed);\n const fixedTypewriterContentVersion =\n typewriterPacing === \"fixed\" ? content : undefined;\n const [displayContent, setDisplayContent] = useState(() =>\n isTypewriterEnabled ? \"\" : content\n );\n const displayContentRef = useRef(displayContent);\n const pendingContentRef = useRef(\"\");\n const contentAwareQueueRef = useRef<ContentAwareTypewriterQueue>({\n tokens: [],\n head: 0,\n });\n const contentAwareBudgetRef = useRef(0);\n const previousTypewriterEnabledRef = useRef(isTypewriterEnabled);\n const previousTypewriterPacingRef = useRef(typewriterPacing);\n const previousSourceContentRef = useRef(content);\n const hasReportedTypeFinishedRef = useRef(false);\n const [typewriterWakeVersion, setTypewriterWakeVersion] = useState(0);\n\n useEffect(() => {\n const wasTypewriterEnabled = previousTypewriterEnabledRef.current;\n const previousTypewriterPacing = previousTypewriterPacingRef.current;\n const previousSourceContent = previousSourceContentRef.current;\n const wasPending = Boolean(pendingContentRef.current);\n\n previousTypewriterEnabledRef.current = isTypewriterEnabled;\n previousTypewriterPacingRef.current = typewriterPacing;\n previousSourceContentRef.current = content;\n\n if (\n content !== previousSourceContent ||\n isTypewriterEnabled !== wasTypewriterEnabled\n ) {\n hasReportedTypeFinishedRef.current = false;\n }\n\n const clearPendingContent = () => {\n pendingContentRef.current = \"\";\n contentAwareQueueRef.current = { tokens: [], head: 0 };\n contentAwareBudgetRef.current = 0;\n };\n\n const updateDisplayContent = (nextContent: string) => {\n displayContentRef.current = nextContent;\n setDisplayContent(nextContent);\n };\n\n if (!isTypewriterEnabled) {\n clearPendingContent();\n updateDisplayContent(content);\n return;\n }\n\n if (!wasTypewriterEnabled) {\n clearPendingContent();\n updateDisplayContent(\"\");\n }\n\n const visibleContent = !wasTypewriterEnabled\n ? \"\"\n : displayContentRef.current;\n\n if (!content.startsWith(visibleContent)) {\n clearPendingContent();\n updateDisplayContent(content);\n return;\n }\n\n const nextPendingContent = content.slice(visibleContent.length);\n if (!nextPendingContent) {\n clearPendingContent();\n return;\n }\n\n if (typewriterPacing === \"content-aware\") {\n const previousPendingContent = previousSourceContent.slice(\n visibleContent.length\n );\n const canAppendToCachedQueue =\n wasTypewriterEnabled &&\n previousTypewriterPacing === \"content-aware\" &&\n content.startsWith(previousSourceContent) &&\n pendingContentRef.current === previousPendingContent;\n\n if (canAppendToCachedQueue) {\n contentAwareQueueRef.current = appendContentAwareTypewriterQueue(\n contentAwareQueueRef.current,\n content.slice(previousSourceContent.length)\n );\n } else {\n contentAwareQueueRef.current =\n createContentAwareTypewriterQueue(nextPendingContent);\n contentAwareBudgetRef.current = 0;\n }\n } else {\n contentAwareQueueRef.current = { tokens: [], head: 0 };\n contentAwareBudgetRef.current = 0;\n }\n\n pendingContentRef.current = nextPendingContent;\n\n if (!wasPending) {\n setTypewriterWakeVersion((version) => version + 1);\n }\n }, [content, isTypewriterEnabled, typewriterPacing]);\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 if (!pendingContentRef.current) {\n return;\n }\n\n let chunk = \"\";\n\n if (typewriterPacing === \"content-aware\") {\n const result = consumeContentAwareTypewriterQueue(\n contentAwareQueueRef.current,\n contentAwareBudgetRef.current + CONTENT_AWARE_TYPEWRITER_TICK_BUDGET\n );\n\n chunk = result.chunk;\n contentAwareQueueRef.current = result.queue;\n\n if (isContentAwareTypewriterQueueEmpty(result.queue)) {\n contentAwareBudgetRef.current = 0;\n } else {\n contentAwareBudgetRef.current = result.remainingBudget;\n }\n } else {\n const fixedChunk = splitTextByCharacterChunk(\n pendingContentRef.current,\n FIXED_TYPEWRITER_CHUNK_SIZE\n );\n chunk = fixedChunk.chunk;\n }\n\n if (!chunk) {\n return;\n }\n\n pendingContentRef.current = pendingContentRef.current.slice(chunk.length);\n if (!pendingContentRef.current) {\n contentAwareQueueRef.current = { tokens: [], head: 0 };\n contentAwareBudgetRef.current = 0;\n }\n\n const nextDisplayContent = `${displayContentRef.current}${chunk}`;\n displayContentRef.current = nextDisplayContent;\n setDisplayContent(nextDisplayContent);\n }, typewriterTickMs);\n\n return () => window.clearTimeout(typewriterTimer);\n }, [\n displayContent,\n fixedTypewriterContentVersion,\n isTypewriterEnabled,\n typewriterPacing,\n typewriterTickMs,\n typewriterWakeVersion,\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 const stableDefaultSelectedValues = useStableStringArray(\n resolvedDefaultSelectedValues\n );\n const componentRuntimeValuesRef = useRef<MarkdownComponentRuntimeValues>({\n direction,\n language,\n mermaidMessages,\n beforeSend,\n locale,\n onClickCustomButtonAfterContent,\n onSend,\n readonly,\n renderContent,\n resolvedConfirmButtonText,\n resolvedCopiedButtonText,\n resolvedCopyButtonText,\n resolvedDefaultButtonText,\n resolvedDefaultInputText,\n resolvedDefaultSelectedValues: stableDefaultSelectedValues,\n });\n\n componentRuntimeValuesRef.current = {\n direction,\n language,\n mermaidMessages,\n beforeSend,\n locale,\n onClickCustomButtonAfterContent,\n onSend,\n readonly,\n renderContent,\n resolvedConfirmButtonText,\n resolvedCopiedButtonText,\n resolvedCopyButtonText,\n resolvedDefaultButtonText,\n resolvedDefaultInputText,\n resolvedDefaultSelectedValues: stableDefaultSelectedValues,\n };\n\n const components = useMemo<CustomComponents>(\n () => ({\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={\n componentRuntimeValuesRef.current.onClickCustomButtonAfterContent\n }\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={componentRuntimeValuesRef.current.readonly}\n defaultButtonText={\n componentRuntimeValuesRef.current.resolvedDefaultButtonText\n }\n defaultInputText={\n componentRuntimeValuesRef.current.resolvedDefaultInputText\n }\n defaultSelectedValues={\n componentRuntimeValuesRef.current.resolvedDefaultSelectedValues\n }\n onSend={componentRuntimeValuesRef.current.onSend}\n beforeSend={componentRuntimeValuesRef.current.beforeSend}\n locale={componentRuntimeValuesRef.current.locale}\n dir={componentRuntimeValuesRef.current.direction}\n lang={componentRuntimeValuesRef.current.language}\n confirmButtonText={\n componentRuntimeValuesRef.current.resolvedConfirmButtonText\n }\n // tooltipMinLength={tooltipMinLength}\n />\n ),\n code: MarkdownCode,\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={\n componentRuntimeValuesRef.current.resolvedCopyButtonText\n }\n copiedButtonText={\n componentRuntimeValuesRef.current.resolvedCopiedButtonText\n }\n />\n ),\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 <MarkdownComponentRuntimeContext.Provider\n key={key}\n value={componentRuntimeValuesRef}\n >\n <MarkdownRenderer\n locale={locale}\n components={components}\n content={seg.value}\n />\n </MarkdownComponentRuntimeContext.Provider>\n );\n }\n\n if (seg.type === \"mermaid\") {\n return (\n <MermaidChart\n key={key}\n chart={seg.value}\n frozen={!seg.complete}\n messages={mermaidMessages}\n />\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\n className=\"content-render markdown-body\"\n dir={direction}\n lang={language}\n >\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 dir={direction}\n lang={language}\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\n className=\"content-render markdown-body\"\n dir={direction}\n lang={language}\n >\n {segments.map((seg, index) => {\n if (seg.type === \"text\") {\n return (\n <MarkdownComponentRuntimeContext.Provider\n key={index}\n value={componentRuntimeValuesRef}\n >\n <MarkdownRenderer\n locale={locale}\n components={components}\n content={seg.value}\n />\n </MarkdownComponentRuntimeContext.Provider>\n );\n }\n\n if (seg.type === \"mermaid\") {\n return (\n <MermaidChart\n key={index}\n chart={seg.value}\n frozen={!seg.complete}\n messages={mermaidMessages}\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","FIXED_TYPEWRITER_CHUNK_SIZE","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","MarkdownComponentRuntimeContext","React","MarkdownCode","props","runtimeValuesRef","isInCodeBlock","CodeBlockContext","className","children","rest","chartContent","frozen","mermaidBlockIsComplete","MermaidChart","remarkPlugins","remarkGfm","remarkMath","remarkFlow","remarkBreaks","rehypePlugins","preserveCustomVariableProperties","rehypeRaw","sanitizeInvalidTagName","restoreCustomVariableProperties","rehypeHighlight","highlightLanguages","subsetLanguages","rehypeKatex","MarkdownRenderer","markdownContent","components","locale","texts","getContentRenderLocaleTexts","ReactMarkdown","referenceIndex","rereferenceIndex","reference","mergeNonSandboxSegments","segments","merged","segment","last","splitTextByCharacterChunk","chunkSize","safeChunkSize","characters","areStringArraysEqual","left","right","index","useStableStringArray","values","valuesRef","ContentRender","content","contentType","lang","dir","customRenderBar","onSend","typingSpeed","enableTypewriter","typewriterPacing","onTypeFinished","onTypewriterStateChange","userInput","interactionDefaultValueOptions","defaultButtonText","defaultInputText","defaultSelectedValues","readonly","confirmButtonText","copyButtonText","copiedButtonText","sandboxLoadingText","sandboxStyleLoadingText","sandboxScriptLoadingText","disableSandboxLoadingOverlay","sandboxFullscreenButtonText","sandboxExitFullscreenButtonText","sandboxMode","onClickCustomButtonAfterContent","beforeSend","localeTexts","mermaidMessages","useMemo","direction","getMarkdownFlowDirection","language","getMarkdownFlowLanguage","resolvedConfirmButtonText","resolvedCopyButtonText","resolvedCopiedButtonText","resolvedSandboxFullscreenButtonText","resolvedSandboxExitFullscreenButtonText","isTypewriterEnabled","typewriterTickMs","fixedTypewriterContentVersion","displayContent","setDisplayContent","useState","displayContentRef","pendingContentRef","contentAwareQueueRef","contentAwareBudgetRef","previousTypewriterEnabledRef","previousTypewriterPacingRef","previousSourceContentRef","hasReportedTypeFinishedRef","typewriterWakeVersion","setTypewriterWakeVersion","wasTypewriterEnabled","previousTypewriterPacing","previousSourceContent","wasPending","clearPendingContent","updateDisplayContent","nextContent","visibleContent","nextPendingContent","previousPendingContent","appendContentAwareTypewriterQueue","createContentAwareTypewriterQueue","version","typewriterTimer","chunk","result","consumeContentAwareTypewriterQueue","CONTENT_AWARE_TYPEWRITER_TICK_BUDGET","isContentAwareTypewriterQueueEmpty","nextDisplayContent","typewriterState","renderContent","normalizedContent","normalizeInlineHtml","interactionDefaults","getInteractionDefaultValues","resolvedDefaultButtonText","resolvedDefaultInputText","fallbackSelectedValues","resolvedDefaultSelectedValues","stableDefaultSelectedValues","componentRuntimeValuesRef","CustomButtonInputVariable","CodeBlock","hasPotentialSandboxTags","renderSegments","splitContentSegments","hasSandbox","mergedRenderSegments","parseMarkdownSegments","renderMarkdownSegments","raw","keyPrefix","seg","key","idx","IframeSandbox","jsxs"],"mappings":"i8CA4DMA,GACJ,kGACIC,GAA8B,EA2E9BC,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,EAAS,OAEd,MAAMC,EAAaD,EAChB,KAAA,EACA,MAAM,QAAQ,EACd,IAAKE,GAAU,OAA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D,EAAAA,IAAC,MAAA,CAAI,UAAU,4BACZ,SAAAE,EAAM,cAAc0D,EAAiB,CACpC,QAAAJ,EACA,eAAgB+E,EAChB,OAAA1E,CAAA,CACD,CAAA,CACH,CAAA,CAAA,CAAA,CAIR"}
|
|
@@ -3,6 +3,7 @@ import { CustomRenderBarProps, OnSendContentParams } from '../types.js';
|
|
|
3
3
|
import { ComponentsWithCustomVariable } from './plugins/CustomVariable.js';
|
|
4
4
|
import { InteractionDefaultValueOptions } from '../../lib/interaction-defaults.js';
|
|
5
5
|
import { MarkdownFlowLocale } from '../../lib/locale.js';
|
|
6
|
+
export type ContentRenderTypewriterPacing = "fixed" | "content-aware";
|
|
6
7
|
export interface ContentRenderProps {
|
|
7
8
|
content: string;
|
|
8
9
|
contentType?: string;
|
|
@@ -28,6 +29,8 @@ export interface ContentRenderProps {
|
|
|
28
29
|
onSend?: (content: OnSendContentParams) => void;
|
|
29
30
|
typingSpeed?: number;
|
|
30
31
|
enableTypewriter?: boolean;
|
|
32
|
+
/** Controls how much text is revealed per tick. Defaults to the legacy fixed pacing. */
|
|
33
|
+
typewriterPacing?: ContentRenderTypewriterPacing;
|
|
31
34
|
onTypeFinished?: () => void;
|
|
32
35
|
onTypewriterStateChange?: (state: ContentRenderTypewriterState) => void;
|
|
33
36
|
userInput?: string;
|