markdown-flow-ui 0.1.88 → 0.1.89-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/@braintree_sanitize-url@7.1.1/node_modules/@braintree/sanitize-url/dist/index.cjs.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/@braintree_sanitize-url@7.1.1/node_modules/@braintree/sanitize-url/dist/index.es.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/hast-util-to-jsx-runtime@2.3.6/node_modules/hast-util-to-jsx-runtime/lib/index.cjs.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/hast-util-to-jsx-runtime@2.3.6/node_modules/hast-util-to-jsx-runtime/lib/index.es.js +1 -1
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/style-to-object@1.0.11/node_modules/style-to-object/cjs/index.cjs.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/style-to-object@1.0.11/node_modules/style-to-object/cjs/index.es.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/unified@11.0.5/node_modules/unified/lib/index.cjs.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/unified@11.0.5/node_modules/unified/lib/index.es.js +1 -1
- package/dist/_virtual/index.cjs5.js +1 -1
- package/dist/_virtual/index.cjs6.js +1 -1
- package/dist/_virtual/index.cjs7.js +1 -1
- package/dist/_virtual/index.es5.js +3 -5
- package/dist/_virtual/index.es5.js.map +1 -1
- package/dist/_virtual/index.es6.js +4 -4
- package/dist/_virtual/index.es7.js +5 -3
- package/dist/_virtual/index.es7.js.map +1 -1
- package/dist/components/ContentRender/ContentRender.cjs.js +2 -2
- package/dist/components/ContentRender/ContentRender.cjs.js.map +1 -1
- package/dist/components/ContentRender/ContentRender.es.js +156 -138
- package/dist/components/ContentRender/ContentRender.es.js.map +1 -1
- package/dist/components/ContentRender/utils/sanitize-invalid-tag-name.cjs.js +2 -0
- package/dist/components/ContentRender/utils/sanitize-invalid-tag-name.cjs.js.map +1 -0
- package/dist/components/ContentRender/utils/sanitize-invalid-tag-name.d.ts +2 -0
- package/dist/components/ContentRender/utils/sanitize-invalid-tag-name.es.js +17 -0
- package/dist/components/ContentRender/utils/sanitize-invalid-tag-name.es.js.map +1 -0
- package/dist/components/ContentRender/utils/strip-svg-text-line-breaks.cjs.js +2 -0
- package/dist/components/ContentRender/utils/strip-svg-text-line-breaks.cjs.js.map +1 -0
- package/dist/components/ContentRender/utils/strip-svg-text-line-breaks.d.ts +1 -0
- package/dist/components/ContentRender/utils/strip-svg-text-line-breaks.es.js +13 -0
- package/dist/components/ContentRender/utils/strip-svg-text-line-breaks.es.js.map +1 -0
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("../../_virtual/jsx-runtime.cjs.js");;/* empty css */;/* empty css */const
|
|
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 c=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"),I=require("./plugins/MermaidChart.cjs.js"),Y=require("./useTypewriterStateMachine.cjs.js"),F=require("./utils/custom-variable-props.cjs.js"),_=require("./utils/highlight-languages.cjs.js"),A=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:r})=>{const o=c.useRef(null);return c.useEffect(()=>{const i=o.current;if(!i)return;const a=i.shadowRoot??i.attachShadow({mode:"open"}),E="content-render-svg-style";let m=a.getElementById(E);m||(m=document.createElement("style"),m.id=E,m.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(
|
|
5
|
+
`,a.appendChild(m)),Array.from(a.childNodes).filter(s=>s!==m).forEach(s=>a.removeChild(s));const R=document.createElement("template"),T=K.stripSvgTextLineBreaks(r);R.innerHTML=T,console.log("template.innerHTML",R.innerHTML),a.append(R.content.cloneNode(!0));let b=!1,k=!1;a.querySelectorAll("svg").forEach(s=>{const S=s.getAttribute("viewBox");if(!S)return;const y=S.trim().split(/[\s,]+/).map(u=>Number(u));if(y.length!==4||y.some(Number.isNaN))return;const[,,h,x]=y,f=s.getAttribute("width"),j=s.getAttribute("height"),L=u=>{if(!u)return!1;const e=u.trim().toLowerCase();return e==="auto"||e.endsWith("%")},C=u=>{if(!u)return null;const e=u.trim().toLowerCase();if(e==="auto"||e.endsWith("%"))return null;const n=Number.parseFloat(e);return Number.isNaN(n)?null:n},$=L(f),N=L(j),w=!f||f==="0",g=!j||j==="0",p=C(f),z=C(j);if($||N||w&&g||p===h&&z===x){b=!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&&x>0&&(s.style.aspectRatio=`${h} / ${x}`);return}k=!0,s.classList.add("content-render-svg-el--fixed"),s.classList.remove("content-render-svg-el--responsive"),w&&h>0&&s.setAttribute("width",`${h}`),g&&x>0&&s.setAttribute("height",`${x}`)});const q=b&&!k;i.classList.toggle("content-render-svg--responsive",q),i.classList.toggle("content-render-svg--fixed",!q)},[r]),t.jsxRuntimeExports.jsx("div",{className:"content-render-svg-scroll",children:t.jsxRuntimeExports.jsx("div",{className:"content-render-svg",ref:o})})},ce=[oe.default,ie.default,G.default,ae.default],ue=[F.preserveCustomVariableProperties,ne.default,J.sanitizeInvalidTagName,F.restoreCustomVariableProperties,[se.default,{languages:_.highlightLanguages,subset:_.subsetLanguages}],re.default],H=({content:r,components:o})=>t.jsxRuntimeExports.jsx("div",{className:"markdown-renderer",children:t.jsxRuntimeExports.jsx(te.Markdown,{remarkPlugins:ce,rehypePlugins:ue,components:o,children:r})}),le=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},de=({content:r,customRenderBar:o,onSend:i,typingSpeed:a=30,enableTypewriter:E=!1,defaultButtonText:m,defaultInputText:P,defaultSelectedValues:R,readonly:T=!1,onTypeFinished:b,confirmButtonText:k,copyButtonText:q,copiedButtonText:s,sandboxLoadingText:S,sandboxStyleLoadingText:y,sandboxScriptLoadingText:h,sandboxFullscreenButtonText:x,sandboxMode:f="content",onClickCustomButtonAfterContent:j,beforeSend:L})=>{const C=c.useMemo(()=>U.normalizeInlineHtml(r),[r]),$={"custom-button-after-content":({children:e})=>t.jsxRuntimeExports.jsx("button",{className:"content-render-custom-button-after-content",onClick:j,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:T,defaultButtonText:m,defaultInputText:P,defaultSelectedValues:R,onSend:i,beforeSend:L,confirmButtonText:k}),code:e=>{const{className:n,children:l,...B}=e;if(/language-(\w+)/.exec(n||"")?.[1]==="mermaid"){const v=l?.toString().replace(/\n$/,"")||"",D=A.mermaidBlockIsComplete(r,v);return t.jsxRuntimeExports.jsx(I.default,{chart:v,frozen:D})}return t.jsxRuntimeExports.jsx("code",{className:n,...B,children:l})},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 l=e?.properties?.className;return typeof l=="string"&&l.includes("task-list-item")||Array.isArray(l)&&l.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:q,copiedButtonText:s})},{displayContent:N,isComplete:w}=Y.default({content:C,typingSpeed:a,disabled:!E}),g=c.useMemo(()=>ee.splitContentSegments(r,!0),[r]),p=g.some(e=>e.type==="sandbox"),z=c.useMemo(()=>le(g),[g]),V=c.useMemo(()=>A.parseMarkdownSegments(N),[N]),M=c.useRef(!1);c.useEffect(()=>{p||w&&!M.current&&(M.current=!0,b?.())},[p,w,b]),c.useEffect(()=>{p||(M.current=!1)},[p,r]);const u=(e,n)=>{const l=U.normalizeInlineHtml(e);return A.parseMarkdownSegments(l).map((d,W)=>{const v=`${n}-${d.type}-${W}`;return d.type==="text"?t.jsxRuntimeExports.jsx(H,{components:$,content:d.value},v):d.type==="mermaid"?t.jsxRuntimeExports.jsx(I.default,{chart:d.value,frozen:!d.complete},v):d.type==="svg"?t.jsxRuntimeExports.jsx(O,{svg:d.value},v):null})};return p?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:S,styleLoadingText:y,scriptLoadingText:h,fullScreenButtonText:x,mode:f},`sandbox-${n}`):t.jsxRuntimeExports.jsx(c.Fragment,{children:u(e.value,`md-${n}`)},`md-${n}`))}):t.jsxRuntimeExports.jsxs("div",{className:"content-render markdown-body",children:[V.map((e,n)=>{if(e.type==="text")return t.jsxRuntimeExports.jsx(H,{components:$,content:e.value},n);if(e.type==="mermaid")return t.jsxRuntimeExports.jsx(I.default,{chart:e.value,frozen:!e.complete},n);if(e.type==="svg")return t.jsxRuntimeExports.jsx(O,{svg:e.value},n)}),o&&t.jsxRuntimeExports.jsx("div",{className:"content-render-custom-bar",children:c.createElement(o,{content:r,displayContent:N,onSend:i})})]})};exports.MarkdownRenderer=H;exports.default=de;
|
|
6
6
|
//# sourceMappingURL=ContentRender.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentRender.cjs.js","sources":["../../../src/components/ContentRender/ContentRender.tsx"],"sourcesContent":["import \"highlight.js/styles/github.css\";\nimport \"katex/dist/katex.min.css\";\nimport React, { useEffect, useMemo, useRef } 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 \"./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 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","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":"o+DAsFMA,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,GAAU,CAEpD,MAAMC,EAAUD,EAAM,aAAa,SAAS,EAC5C,GAAI,CAACC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kBAAAA,IAACmE,EAAAA,QAAA,CAEC,eAAc,GACd,QAAS9C,EAAQ,MACjB,UAAU,wBACV,YAAagB,EACb,iBAAkBC,EAClB,kBAAmBC,EACnB,qBAAsBC,EACtB,KAAMC,CAAA,EARD,WAAWyB,CAAG,EAAA,EAWrBlE,EAAAA,kBAAAA,IAACc,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,OACErE,EAAAA,kBAAAA,IAACc,EAAA,CAEC,WAAAE,EACA,QAASqD,EAAI,KAAA,EAFRC,CAAA,EAOX,GAAID,EAAI,OAAS,UACf,OACErE,EAAAA,kBAAAA,IAACuD,EAAAA,QAAA,CAEC,MAAOc,EAAI,MACX,OAAQ,CAACA,EAAI,QAAA,EAFRC,CAAA,EAOX,GAAID,EAAI,OAAS,MACf,OAAOrE,EAAAA,kBAAAA,IAAChC,GAAA,CAA6B,IAAKqG,EAAI,OAAhBC,CAAuB,CAEzD,CAAC,EAEA7C,GACCzB,EAAAA,kBAAAA,IAAC,MAAA,CAAI,UAAU,4BACZ,SAAAuE,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\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 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\n key={key}\n chart={seg.value}\n frozen={!seg.complete}\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 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","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","keyPrefix","seg","index","key","idx","IframeSandbox","React","jsxs"],"mappings":"ulEAwFMA,EAA8C,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,CAA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AG,EAAE,CAAA,EAD/B,MAAMA,CAAG,EAE9B,CAAA,EAGN,EAKFG,EAAAA,kBAAAA,KAAC,MAAA,CAAI,UAAU,+BACZ,SAAA,CAAAxD,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,IAAClC,EAAA,CAA6B,IAAKwG,EAAI,OAAhBC,CAAuB,CAEzD,CAAC,EAEA7C,GACC1B,EAAAA,kBAAAA,IAAC,MAAA,CAAI,UAAU,4BACZ,SAAA2E,EAAM,cAAcjD,EAAiB,CACpC,QAAAD,EACA,eAAAiC,EACA,OAAA/B,CAAA,CACD,CAAA,CACH,CAAA,EAEJ,CAEJ"}
|
|
@@ -1,85 +1,88 @@
|
|
|
1
1
|
import { j as t } from "../../_virtual/jsx-runtime.es.js";
|
|
2
2
|
/* empty css */
|
|
3
3
|
/* empty css */
|
|
4
|
-
import
|
|
5
|
-
import
|
|
4
|
+
import _, { useMemo as $, useRef as D, useEffect as V } from "react";
|
|
5
|
+
import O from "../../_virtual/index.es.js";
|
|
6
|
+
import { sanitizeInvalidTagName as Q } from "./utils/sanitize-invalid-tag-name.es.js";
|
|
7
|
+
import { stripSvgTextLineBreaks as X } from "./utils/strip-svg-text-line-breaks.es.js";
|
|
6
8
|
/* empty css */
|
|
7
9
|
/* empty css */
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import { preserveCustomVariableProperties as
|
|
13
|
-
import { subsetLanguages as
|
|
14
|
-
import { parseMarkdownSegments as
|
|
15
|
-
import { normalizeInlineHtml as
|
|
16
|
-
import
|
|
17
|
-
import { splitContentSegments as
|
|
18
|
-
import { Markdown as
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
import
|
|
22
|
-
import
|
|
23
|
-
import
|
|
24
|
-
import
|
|
25
|
-
const
|
|
26
|
-
const o =
|
|
27
|
-
return
|
|
10
|
+
import Y from "./CodeBlock.es.js";
|
|
11
|
+
import Z from "./plugins/CustomVariable.es.js";
|
|
12
|
+
import H from "./plugins/MermaidChart.es.js";
|
|
13
|
+
import E from "./useTypewriterStateMachine.es.js";
|
|
14
|
+
import { preserveCustomVariableProperties as ee, restoreCustomVariableProperties as te } from "./utils/custom-variable-props.es.js";
|
|
15
|
+
import { subsetLanguages as re, highlightLanguages as ne } from "./utils/highlight-languages.es.js";
|
|
16
|
+
import { parseMarkdownSegments as U, mermaidBlockIsComplete as se } from "./utils/mermaid-parse.es.js";
|
|
17
|
+
import { normalizeInlineHtml as q } from "./utils/normalize-inline-html.es.js";
|
|
18
|
+
import oe from "./IframeSandbox.es.js";
|
|
19
|
+
import { splitContentSegments as ae } from "./utils/split-content.es.js";
|
|
20
|
+
import { Markdown as ie } from "../../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.es.js";
|
|
21
|
+
import ce from "../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rehype-raw@7.0.0/node_modules/rehype-raw/lib/index.es.js";
|
|
22
|
+
import le from "../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rehype-highlight@7.0.2/node_modules/rehype-highlight/lib/index.es.js";
|
|
23
|
+
import me from "../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rehype-katex@7.0.1/node_modules/rehype-katex/lib/index.es.js";
|
|
24
|
+
import de from "../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/remark-gfm@4.0.1/node_modules/remark-gfm/lib/index.es.js";
|
|
25
|
+
import ue from "../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/remark-math@6.0.0/node_modules/remark-math/lib/index.es.js";
|
|
26
|
+
import pe from "../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/remark-breaks@4.0.0/node_modules/remark-breaks/lib/index.es.js";
|
|
27
|
+
const G = ({ svg: s }) => {
|
|
28
|
+
const o = D(null);
|
|
29
|
+
return V(() => {
|
|
28
30
|
const a = o.current;
|
|
29
31
|
if (!a) return;
|
|
30
|
-
const i = a.shadowRoot ?? a.attachShadow({ mode: "open" }),
|
|
31
|
-
let
|
|
32
|
-
|
|
32
|
+
const i = a.shadowRoot ?? a.attachShadow({ mode: "open" }), k = "content-render-svg-style";
|
|
33
|
+
let d = i.getElementById(k);
|
|
34
|
+
d || (d = document.createElement("style"), d.id = k, d.textContent = `
|
|
33
35
|
svg { height: auto; display: inline-block; }
|
|
34
36
|
svg.content-render-svg-el--responsive { width: 100%; max-width: 100%; }
|
|
35
37
|
svg.content-render-svg-el--fixed { max-width: none; }
|
|
36
|
-
`, i.appendChild(
|
|
37
|
-
(
|
|
38
|
-
).forEach((
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
let
|
|
42
|
-
i.querySelectorAll("svg").forEach((
|
|
43
|
-
const R =
|
|
38
|
+
`, i.appendChild(d)), Array.from(i.childNodes).filter(
|
|
39
|
+
(n) => n !== d
|
|
40
|
+
).forEach((n) => i.removeChild(n));
|
|
41
|
+
const b = document.createElement("template"), z = X(s);
|
|
42
|
+
b.innerHTML = z, console.log("template.innerHTML", b.innerHTML), i.append(b.content.cloneNode(!0));
|
|
43
|
+
let y = !1, S = !1;
|
|
44
|
+
i.querySelectorAll("svg").forEach((n) => {
|
|
45
|
+
const R = n.getAttribute("viewBox");
|
|
44
46
|
if (!R) return;
|
|
45
|
-
const
|
|
46
|
-
if (
|
|
47
|
-
const [, , h,
|
|
47
|
+
const j = R.trim().split(/[\s,]+/).map((c) => Number(c));
|
|
48
|
+
if (j.length !== 4 || j.some(Number.isNaN)) return;
|
|
49
|
+
const [, , h, u] = j, f = n.getAttribute("width"), x = n.getAttribute("height"), C = (c) => {
|
|
48
50
|
if (!c) return !1;
|
|
49
51
|
const e = c.trim().toLowerCase();
|
|
50
52
|
return e === "auto" || e.endsWith("%");
|
|
51
|
-
},
|
|
53
|
+
}, B = (c) => {
|
|
52
54
|
if (!c) return null;
|
|
53
55
|
const e = c.trim().toLowerCase();
|
|
54
56
|
if (e === "auto" || e.endsWith("%"))
|
|
55
57
|
return null;
|
|
56
|
-
const
|
|
57
|
-
return Number.isNaN(
|
|
58
|
-
},
|
|
59
|
-
if (
|
|
60
|
-
|
|
58
|
+
const r = Number.parseFloat(e);
|
|
59
|
+
return Number.isNaN(r) ? null : r;
|
|
60
|
+
}, M = C(f), N = C(x), w = !f || f === "0", g = !x || x === "0", p = B(f), A = B(x);
|
|
61
|
+
if (M || N || w && g || p === h && A === u) {
|
|
62
|
+
y = !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 && u > 0 && (n.style.aspectRatio = `${h} / ${u}`);
|
|
61
63
|
return;
|
|
62
64
|
}
|
|
63
|
-
|
|
65
|
+
S = !0, n.classList.add("content-render-svg-el--fixed"), n.classList.remove("content-render-svg-el--responsive"), w && h > 0 && n.setAttribute("width", `${h}`), g && u > 0 && n.setAttribute("height", `${u}`);
|
|
64
66
|
});
|
|
65
|
-
const
|
|
66
|
-
a.classList.toggle("content-render-svg--responsive",
|
|
67
|
+
const L = y && !S;
|
|
68
|
+
a.classList.toggle("content-render-svg--responsive", L), a.classList.toggle("content-render-svg--fixed", !L);
|
|
67
69
|
}, [s]), /* @__PURE__ */ t.jsx("div", { className: "content-render-svg-scroll", children: /* @__PURE__ */ t.jsx("div", { className: "content-render-svg", ref: o }) });
|
|
68
|
-
},
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
[ne, { languages: X, subset: Q }],
|
|
73
|
-
se
|
|
74
|
-
], P = ({ content: s, components: o }) => /* @__PURE__ */ t.jsx("div", { className: "markdown-renderer", children: /* @__PURE__ */ t.jsx(
|
|
70
|
+
}, he = [de, ue, O, pe], fe = [
|
|
71
|
+
ee,
|
|
72
|
+
ce,
|
|
73
|
+
Q,
|
|
75
74
|
te,
|
|
75
|
+
[le, { languages: ne, subset: re }],
|
|
76
|
+
me
|
|
77
|
+
], K = ({ content: s, components: o }) => /* @__PURE__ */ t.jsx("div", { className: "markdown-renderer", children: /* @__PURE__ */ t.jsx(
|
|
78
|
+
ie,
|
|
76
79
|
{
|
|
77
|
-
remarkPlugins:
|
|
78
|
-
rehypePlugins:
|
|
80
|
+
remarkPlugins: he,
|
|
81
|
+
rehypePlugins: fe,
|
|
79
82
|
components: o,
|
|
80
83
|
children: s
|
|
81
84
|
}
|
|
82
|
-
) }),
|
|
85
|
+
) }), xe = (s) => {
|
|
83
86
|
if (s.length <= 1) return s;
|
|
84
87
|
const o = [];
|
|
85
88
|
return s.forEach((a) => {
|
|
@@ -97,71 +100,71 @@ const ce = ({ svg: s }) => {
|
|
|
97
100
|
}
|
|
98
101
|
o.push({ type: "markdown", value: a.value });
|
|
99
102
|
}), o;
|
|
100
|
-
},
|
|
103
|
+
}, qe = ({
|
|
101
104
|
content: s,
|
|
102
105
|
customRenderBar: o,
|
|
103
106
|
onSend: a,
|
|
104
107
|
typingSpeed: i = 30,
|
|
105
|
-
enableTypewriter:
|
|
106
|
-
defaultButtonText:
|
|
107
|
-
defaultInputText:
|
|
108
|
-
defaultSelectedValues:
|
|
109
|
-
readonly:
|
|
110
|
-
onTypeFinished:
|
|
111
|
-
confirmButtonText:
|
|
112
|
-
copyButtonText:
|
|
113
|
-
copiedButtonText:
|
|
114
|
-
sandboxLoadingText:
|
|
115
|
-
sandboxStyleLoadingText:
|
|
116
|
-
sandboxScriptLoadingText:
|
|
117
|
-
sandboxFullscreenButtonText:
|
|
108
|
+
enableTypewriter: k = !1,
|
|
109
|
+
defaultButtonText: d,
|
|
110
|
+
defaultInputText: W,
|
|
111
|
+
defaultSelectedValues: b,
|
|
112
|
+
readonly: z = !1,
|
|
113
|
+
onTypeFinished: y,
|
|
114
|
+
confirmButtonText: S,
|
|
115
|
+
copyButtonText: L,
|
|
116
|
+
copiedButtonText: n,
|
|
117
|
+
sandboxLoadingText: R,
|
|
118
|
+
sandboxStyleLoadingText: j,
|
|
119
|
+
sandboxScriptLoadingText: h,
|
|
120
|
+
sandboxFullscreenButtonText: u,
|
|
118
121
|
sandboxMode: f = "content",
|
|
119
|
-
onClickCustomButtonAfterContent:
|
|
120
|
-
beforeSend:
|
|
122
|
+
onClickCustomButtonAfterContent: x,
|
|
123
|
+
beforeSend: C
|
|
121
124
|
// tooltipMinLength,
|
|
122
125
|
}) => {
|
|
123
|
-
const
|
|
124
|
-
() =>
|
|
126
|
+
const B = $(
|
|
127
|
+
() => q(s),
|
|
125
128
|
[s]
|
|
126
|
-
),
|
|
129
|
+
), M = {
|
|
127
130
|
"custom-button-after-content": ({
|
|
128
131
|
children: e
|
|
129
132
|
}) => /* @__PURE__ */ t.jsx(
|
|
130
133
|
"button",
|
|
131
134
|
{
|
|
132
135
|
className: "content-render-custom-button-after-content",
|
|
133
|
-
onClick:
|
|
136
|
+
onClick: x,
|
|
134
137
|
children: /* @__PURE__ */ t.jsx("span", { className: "content-render-custom-button-after-content-inner", children: e })
|
|
135
138
|
}
|
|
136
139
|
),
|
|
137
140
|
"custom-variable": (e) => /* @__PURE__ */ t.jsx(
|
|
138
|
-
|
|
141
|
+
Z,
|
|
139
142
|
{
|
|
140
143
|
...e,
|
|
141
|
-
readonly:
|
|
142
|
-
defaultButtonText:
|
|
143
|
-
defaultInputText:
|
|
144
|
-
defaultSelectedValues:
|
|
144
|
+
readonly: z,
|
|
145
|
+
defaultButtonText: d,
|
|
146
|
+
defaultInputText: W,
|
|
147
|
+
defaultSelectedValues: b,
|
|
145
148
|
onSend: a,
|
|
146
|
-
beforeSend:
|
|
147
|
-
confirmButtonText:
|
|
149
|
+
beforeSend: C,
|
|
150
|
+
confirmButtonText: S
|
|
148
151
|
}
|
|
149
152
|
),
|
|
150
153
|
code: (e) => {
|
|
151
|
-
const { className:
|
|
152
|
-
if (/language-(\w+)/.exec(
|
|
153
|
-
const
|
|
154
|
-
return /* @__PURE__ */ t.jsx(
|
|
154
|
+
const { className: r, children: l, ...I } = e;
|
|
155
|
+
if (/language-(\w+)/.exec(r || "")?.[1] === "mermaid") {
|
|
156
|
+
const v = l?.toString().replace(/\n$/, "") || "", J = se(s, v);
|
|
157
|
+
return /* @__PURE__ */ t.jsx(H, { chart: v, frozen: J });
|
|
155
158
|
}
|
|
156
|
-
return /* @__PURE__ */ t.jsx("code", { className:
|
|
159
|
+
return /* @__PURE__ */ t.jsx("code", { className: r, ...I, children: l });
|
|
157
160
|
},
|
|
158
161
|
table: ({ ...e }) => /* @__PURE__ */ t.jsx("div", { className: "content-render-table-container", children: /* @__PURE__ */ t.jsx("table", { className: "content-render-table", ...e }) }),
|
|
159
162
|
th: ({ ...e }) => /* @__PURE__ */ t.jsx("th", { className: "content-render-th", ...e }),
|
|
160
163
|
td: ({ ...e }) => /* @__PURE__ */ t.jsx("td", { className: "content-render-td", ...e }),
|
|
161
164
|
tr: ({ ...e }) => /* @__PURE__ */ t.jsx("tr", { className: "content-render-tr", ...e }),
|
|
162
|
-
li: ({ node: e, ...
|
|
163
|
-
const
|
|
164
|
-
return typeof
|
|
165
|
+
li: ({ node: e, ...r }) => {
|
|
166
|
+
const l = e?.properties?.className;
|
|
167
|
+
return typeof l == "string" && l.includes("task-list-item") || Array.isArray(l) && l.includes("task-list-item") ? /* @__PURE__ */ t.jsx("li", { className: "content-render-task-list-item", ...r }) : /* @__PURE__ */ t.jsx("li", { ...r });
|
|
165
168
|
},
|
|
166
169
|
ol: ({ ...e }) => /* @__PURE__ */ t.jsx("ol", { className: "content-render-ol", ...e }),
|
|
167
170
|
ul: ({ ...e }) => /* @__PURE__ */ t.jsx("ul", { className: "content-render-ul", ...e }),
|
|
@@ -174,91 +177,106 @@ const ce = ({ svg: s }) => {
|
|
|
174
177
|
...e
|
|
175
178
|
}
|
|
176
179
|
) : /* @__PURE__ */ t.jsx("input", { ...e }),
|
|
177
|
-
a: ({ children: e, ...
|
|
180
|
+
a: ({ children: e, ...r }) => /* @__PURE__ */ t.jsx("a", { target: "_blank", rel: "noopener noreferrer", ...r, children: e }),
|
|
178
181
|
pre: (e) => /* @__PURE__ */ t.jsx(
|
|
179
|
-
|
|
182
|
+
Y,
|
|
180
183
|
{
|
|
181
184
|
...e,
|
|
182
|
-
copyButtonText:
|
|
183
|
-
copiedButtonText:
|
|
185
|
+
copyButtonText: L,
|
|
186
|
+
copiedButtonText: n
|
|
184
187
|
}
|
|
185
188
|
)
|
|
186
|
-
}, { displayContent:
|
|
189
|
+
}, { displayContent: N, isComplete: w } = E({
|
|
187
190
|
// processMarkdownText will let code block printf("You win!\n") become printf("You win!<br/>");
|
|
188
191
|
// content: processMarkdownText(content),
|
|
189
|
-
content:
|
|
192
|
+
content: B,
|
|
190
193
|
typingSpeed: i,
|
|
191
|
-
disabled: !
|
|
192
|
-
}),
|
|
193
|
-
() =>
|
|
194
|
+
disabled: !k
|
|
195
|
+
}), g = $(
|
|
196
|
+
() => ae(s, !0),
|
|
194
197
|
[s]
|
|
195
|
-
),
|
|
198
|
+
), p = g.some(
|
|
196
199
|
(e) => e.type === "sandbox"
|
|
197
|
-
),
|
|
198
|
-
() =>
|
|
199
|
-
[
|
|
200
|
-
),
|
|
201
|
-
() =>
|
|
202
|
-
[
|
|
203
|
-
),
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
}, [
|
|
207
|
-
|
|
208
|
-
}, [
|
|
209
|
-
|
|
210
|
-
|
|
200
|
+
), A = $(
|
|
201
|
+
() => xe(g),
|
|
202
|
+
[g]
|
|
203
|
+
), F = $(
|
|
204
|
+
() => U(N),
|
|
205
|
+
[N]
|
|
206
|
+
), T = D(!1);
|
|
207
|
+
V(() => {
|
|
208
|
+
p || w && !T.current && (T.current = !0, y?.());
|
|
209
|
+
}, [p, w, y]), V(() => {
|
|
210
|
+
p || (T.current = !1);
|
|
211
|
+
}, [p, s]);
|
|
212
|
+
const c = (e, r) => {
|
|
213
|
+
const l = q(e);
|
|
214
|
+
return U(l).map((m, P) => {
|
|
215
|
+
const v = `${r}-${m.type}-${P}`;
|
|
216
|
+
return m.type === "text" ? /* @__PURE__ */ t.jsx(
|
|
217
|
+
K,
|
|
218
|
+
{
|
|
219
|
+
components: M,
|
|
220
|
+
content: m.value
|
|
221
|
+
},
|
|
222
|
+
v
|
|
223
|
+
) : m.type === "mermaid" ? /* @__PURE__ */ t.jsx(
|
|
224
|
+
H,
|
|
225
|
+
{
|
|
226
|
+
chart: m.value,
|
|
227
|
+
frozen: !m.complete
|
|
228
|
+
},
|
|
229
|
+
v
|
|
230
|
+
) : m.type === "svg" ? /* @__PURE__ */ t.jsx(G, { svg: m.value }, v) : null;
|
|
231
|
+
});
|
|
232
|
+
};
|
|
233
|
+
return p ? /* @__PURE__ */ t.jsx("div", { className: "content-render markdown-body", children: A.map(
|
|
234
|
+
(e, r) => e.type === "sandbox" ? /* @__PURE__ */ t.jsx(
|
|
235
|
+
oe,
|
|
211
236
|
{
|
|
212
237
|
hideFullScreen: !0,
|
|
213
238
|
content: e.value,
|
|
214
239
|
className: "content-render-iframe",
|
|
215
|
-
loadingText:
|
|
216
|
-
styleLoadingText:
|
|
217
|
-
scriptLoadingText:
|
|
218
|
-
fullScreenButtonText:
|
|
240
|
+
loadingText: R,
|
|
241
|
+
styleLoadingText: j,
|
|
242
|
+
scriptLoadingText: h,
|
|
243
|
+
fullScreenButtonText: u,
|
|
219
244
|
mode: f
|
|
220
245
|
},
|
|
221
|
-
`sandbox-${
|
|
222
|
-
) : /* @__PURE__ */ t.jsx(
|
|
223
|
-
P,
|
|
224
|
-
{
|
|
225
|
-
components: L,
|
|
226
|
-
content: W(e.value)
|
|
227
|
-
},
|
|
228
|
-
`md-${n}`
|
|
229
|
-
)
|
|
246
|
+
`sandbox-${r}`
|
|
247
|
+
) : /* @__PURE__ */ t.jsx(_.Fragment, { children: c(e.value, `md-${r}`) }, `md-${r}`)
|
|
230
248
|
) }) : /* @__PURE__ */ t.jsxs("div", { className: "content-render markdown-body", children: [
|
|
231
|
-
|
|
249
|
+
F.map((e, r) => {
|
|
232
250
|
if (e.type === "text")
|
|
233
251
|
return /* @__PURE__ */ t.jsx(
|
|
234
|
-
|
|
252
|
+
K,
|
|
235
253
|
{
|
|
236
|
-
components:
|
|
254
|
+
components: M,
|
|
237
255
|
content: e.value
|
|
238
256
|
},
|
|
239
|
-
|
|
257
|
+
r
|
|
240
258
|
);
|
|
241
259
|
if (e.type === "mermaid")
|
|
242
260
|
return /* @__PURE__ */ t.jsx(
|
|
243
|
-
|
|
261
|
+
H,
|
|
244
262
|
{
|
|
245
263
|
chart: e.value,
|
|
246
264
|
frozen: !e.complete
|
|
247
265
|
},
|
|
248
|
-
|
|
266
|
+
r
|
|
249
267
|
);
|
|
250
268
|
if (e.type === "svg")
|
|
251
|
-
return /* @__PURE__ */ t.jsx(
|
|
269
|
+
return /* @__PURE__ */ t.jsx(G, { svg: e.value }, r);
|
|
252
270
|
}),
|
|
253
|
-
o && /* @__PURE__ */ t.jsx("div", { className: "content-render-custom-bar", children:
|
|
271
|
+
o && /* @__PURE__ */ t.jsx("div", { className: "content-render-custom-bar", children: _.createElement(o, {
|
|
254
272
|
content: s,
|
|
255
|
-
displayContent:
|
|
273
|
+
displayContent: N,
|
|
256
274
|
onSend: a
|
|
257
275
|
}) })
|
|
258
276
|
] });
|
|
259
277
|
};
|
|
260
278
|
export {
|
|
261
|
-
|
|
262
|
-
|
|
279
|
+
K as MarkdownRenderer,
|
|
280
|
+
qe as default
|
|
263
281
|
};
|
|
264
282
|
//# sourceMappingURL=ContentRender.es.js.map
|