markdown-flow-ui 0.1.81-beta.13 → 0.1.81-beta.14
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/classnames@2.5.1/node_modules/classnames/index.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.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.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/unified@11.0.5/node_modules/unified/lib/index.js +1 -1
- package/dist/_virtual/index10.js +2 -2
- package/dist/_virtual/index6.js +4 -4
- package/dist/_virtual/index7.js +4 -4
- package/dist/_virtual/index9.js +2 -2
- package/dist/assets/markdown-flow-ui.css +1 -1
- package/dist/components/ContentRender/ContentRender.js +89 -107
- package/dist/components/ContentRender/ContentRender.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,47 +1,47 @@
|
|
|
1
1
|
import { j as t } from "../../_virtual/jsx-runtime.js";
|
|
2
2
|
/* empty css */
|
|
3
3
|
/* empty css */
|
|
4
|
-
import
|
|
5
|
-
import
|
|
4
|
+
import T, { useMemo as C, useRef as $, useEffect as R } from "react";
|
|
5
|
+
import V from "../../_virtual/index.js";
|
|
6
6
|
/* empty css */
|
|
7
7
|
/* empty css */
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import { preserveCustomVariableProperties as
|
|
13
|
-
import {
|
|
14
|
-
import { parseMarkdownSegments as
|
|
15
|
-
import { normalizeInlineHtml as
|
|
16
|
-
import
|
|
17
|
-
import { Markdown as
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
import
|
|
22
|
-
import
|
|
23
|
-
import
|
|
24
|
-
const
|
|
25
|
-
const
|
|
8
|
+
import _ from "./CodeBlock.js";
|
|
9
|
+
import E from "./plugins/CustomVariable.js";
|
|
10
|
+
import I from "./plugins/MermaidChart.js";
|
|
11
|
+
import U from "./useTypewriterStateMachine.js";
|
|
12
|
+
import { preserveCustomVariableProperties as W, restoreCustomVariableProperties as q } from "./utils/custom-variable-props.js";
|
|
13
|
+
import { subsetLanguages as G, highlightLanguages as K } from "./utils/highlight-languages.js";
|
|
14
|
+
import { parseMarkdownSegments as D, mermaidBlockIsComplete as F } from "./utils/mermaid-parse.js";
|
|
15
|
+
import { normalizeInlineHtml as M } from "./utils/normalize-inline-html.js";
|
|
16
|
+
import J from "./IframeSandbox.js";
|
|
17
|
+
import { Markdown as O } 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.js";
|
|
18
|
+
import Q from "../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rehype-raw@7.0.0/node_modules/rehype-raw/lib/index.js";
|
|
19
|
+
import X from "../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rehype-highlight@7.0.2/node_modules/rehype-highlight/lib/index.js";
|
|
20
|
+
import Y from "../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rehype-katex@7.0.1/node_modules/rehype-katex/lib/index.js";
|
|
21
|
+
import Z from "../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/remark-gfm@4.0.1/node_modules/remark-gfm/lib/index.js";
|
|
22
|
+
import ee from "../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/remark-math@6.0.0/node_modules/remark-math/lib/index.js";
|
|
23
|
+
import te from "../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/remark-breaks@4.0.0/node_modules/remark-breaks/lib/index.js";
|
|
24
|
+
const H = (r) => {
|
|
25
|
+
const c = /<(script|style|link|iframe|html|head|body|meta|title|base|template|div|section|article|main)[\s>]/i, a = r.search(c);
|
|
26
26
|
if (a === -1)
|
|
27
27
|
return [{ type: "markdown", value: r }];
|
|
28
28
|
const i = /<\/[a-z][^>]*>\s*\n(?=[^\s<])/gi;
|
|
29
|
-
let
|
|
29
|
+
let l = r.length, o;
|
|
30
30
|
for (; o = i.exec(r); )
|
|
31
31
|
if (!(o.index <= a)) {
|
|
32
|
-
|
|
32
|
+
l = o.index + o[0].length - 1;
|
|
33
33
|
break;
|
|
34
34
|
}
|
|
35
|
-
const d = [], u = r.slice(0, a), n = r.slice(a,
|
|
36
|
-
return u.trim() && d.push({ type: "markdown", value: u }), d.push({ type: "sandbox", value: n }),
|
|
37
|
-
},
|
|
38
|
-
const
|
|
35
|
+
const d = [], u = r.slice(0, a), n = r.slice(a, l), m = r.slice(l);
|
|
36
|
+
return u.trim() && d.push({ type: "markdown", value: u }), d.push({ type: "sandbox", value: n }), m.trim() && d.push(...H(m)), d;
|
|
37
|
+
}, re = ({ svg: r }) => {
|
|
38
|
+
const c = $(null);
|
|
39
39
|
return R(() => {
|
|
40
|
-
const a =
|
|
40
|
+
const a = c.current;
|
|
41
41
|
if (!a) return;
|
|
42
|
-
const i = a.shadowRoot ?? a.attachShadow({ mode: "open" }),
|
|
43
|
-
let o = i.getElementById(
|
|
44
|
-
o || (o = document.createElement("style"), o.id =
|
|
42
|
+
const i = a.shadowRoot ?? a.attachShadow({ mode: "open" }), l = "content-render-svg-style";
|
|
43
|
+
let o = i.getElementById(l);
|
|
44
|
+
o || (o = document.createElement("style"), o.id = l, o.textContent = `
|
|
45
45
|
:host { display: block; width: 100%; max-width: 100%; text-align: center; }
|
|
46
46
|
svg { max-width: 100%; height: auto; display: inline-block; }
|
|
47
47
|
`, i.appendChild(o)), Array.from(i.childNodes).filter(
|
|
@@ -49,38 +49,52 @@ const q = (r) => {
|
|
|
49
49
|
).forEach((n) => i.removeChild(n));
|
|
50
50
|
const u = document.createElement("template");
|
|
51
51
|
u.innerHTML = r, i.append(u.content.cloneNode(!0)), i.querySelectorAll("svg").forEach((n) => {
|
|
52
|
-
const
|
|
53
|
-
if (!
|
|
54
|
-
const f =
|
|
52
|
+
const m = n.getAttribute("viewBox");
|
|
53
|
+
if (!m) return;
|
|
54
|
+
const f = m.trim().split(/[\s,]+/).map((v) => Number(v));
|
|
55
55
|
if (f.length !== 4 || f.some(Number.isNaN)) return;
|
|
56
|
-
const [, , x, p] = f,
|
|
56
|
+
const [, , x, p] = f, g = n.getAttribute("width"), j = n.getAttribute("height"), k = !!g && g !== "0", b = !!j && j !== "0";
|
|
57
57
|
if (!k && !b) {
|
|
58
58
|
n.style.width = "100%", n.style.height = "auto", !n.style.aspectRatio && p > 0 && (n.style.aspectRatio = `${x} / ${p}`);
|
|
59
59
|
return;
|
|
60
60
|
}
|
|
61
61
|
!k && x > 0 && n.setAttribute("width", `${x}`), !b && p > 0 && n.setAttribute("height", `${p}`);
|
|
62
62
|
});
|
|
63
|
-
}, [r]), /* @__PURE__ */ t.jsx("div", { className: "content-render-svg-scroll", children: /* @__PURE__ */ t.jsx("div", { className: "content-render-svg", ref:
|
|
64
|
-
},
|
|
63
|
+
}, [r]), /* @__PURE__ */ t.jsx("div", { className: "content-render-svg-scroll", children: /* @__PURE__ */ t.jsx("div", { className: "content-render-svg", ref: c }) });
|
|
64
|
+
}, ne = [Z, ee, V, te], se = [
|
|
65
|
+
W,
|
|
66
|
+
Q,
|
|
67
|
+
q,
|
|
68
|
+
[X, { languages: K, subset: G }],
|
|
69
|
+
Y
|
|
70
|
+
], z = ({ content: r, components: c }) => /* @__PURE__ */ t.jsx("div", { className: "markdown-body", children: /* @__PURE__ */ t.jsx(
|
|
71
|
+
O,
|
|
72
|
+
{
|
|
73
|
+
remarkPlugins: ne,
|
|
74
|
+
rehypePlugins: se,
|
|
75
|
+
components: c,
|
|
76
|
+
children: r
|
|
77
|
+
}
|
|
78
|
+
) }), Ie = ({
|
|
65
79
|
content: r,
|
|
66
|
-
customRenderBar:
|
|
80
|
+
customRenderBar: c,
|
|
67
81
|
onSend: a,
|
|
68
82
|
typingSpeed: i = 30,
|
|
69
|
-
enableTypewriter:
|
|
83
|
+
enableTypewriter: l = !1,
|
|
70
84
|
defaultButtonText: o,
|
|
71
85
|
defaultInputText: d,
|
|
72
86
|
defaultSelectedValues: u,
|
|
73
87
|
readonly: n = !1,
|
|
74
|
-
onTypeFinished:
|
|
88
|
+
onTypeFinished: m,
|
|
75
89
|
confirmButtonText: f,
|
|
76
90
|
copyButtonText: x,
|
|
77
91
|
copiedButtonText: p,
|
|
78
|
-
onClickCustomButtonAfterContent:
|
|
92
|
+
onClickCustomButtonAfterContent: g,
|
|
79
93
|
beforeSend: j
|
|
80
94
|
// tooltipMinLength,
|
|
81
95
|
}) => {
|
|
82
96
|
const k = C(
|
|
83
|
-
() =>
|
|
97
|
+
() => M(r),
|
|
84
98
|
[r]
|
|
85
99
|
), b = {
|
|
86
100
|
"custom-button-after-content": ({
|
|
@@ -89,12 +103,12 @@ const q = (r) => {
|
|
|
89
103
|
"button",
|
|
90
104
|
{
|
|
91
105
|
className: "content-render-custom-button-after-content",
|
|
92
|
-
onClick:
|
|
106
|
+
onClick: g,
|
|
93
107
|
children: /* @__PURE__ */ t.jsx("span", { className: "content-render-custom-button-after-content-inner", children: e })
|
|
94
108
|
}
|
|
95
109
|
),
|
|
96
110
|
"custom-variable": (e) => /* @__PURE__ */ t.jsx(
|
|
97
|
-
|
|
111
|
+
E,
|
|
98
112
|
{
|
|
99
113
|
...e,
|
|
100
114
|
readonly: n,
|
|
@@ -109,8 +123,8 @@ const q = (r) => {
|
|
|
109
123
|
code: (e) => {
|
|
110
124
|
const { className: s, children: h, ...A } = e;
|
|
111
125
|
if (/language-(\w+)/.exec(s || "")?.[1] === "mermaid") {
|
|
112
|
-
const B = h?.toString().replace(/\n$/, "") || "",
|
|
113
|
-
return /* @__PURE__ */ t.jsx(
|
|
126
|
+
const B = h?.toString().replace(/\n$/, "") || "", P = F(r, B);
|
|
127
|
+
return /* @__PURE__ */ t.jsx(I, { chart: B, frozen: P });
|
|
114
128
|
}
|
|
115
129
|
return /* @__PURE__ */ t.jsx("code", { className: s, ...A, children: h });
|
|
116
130
|
},
|
|
@@ -135,94 +149,62 @@ const q = (r) => {
|
|
|
135
149
|
) : /* @__PURE__ */ t.jsx("input", { ...e }),
|
|
136
150
|
a: ({ children: e, ...s }) => /* @__PURE__ */ t.jsx("a", { target: "_blank", rel: "noopener noreferrer", ...s, children: e }),
|
|
137
151
|
pre: (e) => /* @__PURE__ */ t.jsx(
|
|
138
|
-
|
|
152
|
+
_,
|
|
139
153
|
{
|
|
140
154
|
...e,
|
|
141
155
|
copyButtonText: x,
|
|
142
156
|
copiedButtonText: p
|
|
143
157
|
}
|
|
144
158
|
)
|
|
145
|
-
}, { displayContent: N, isComplete: v } =
|
|
159
|
+
}, { displayContent: N, isComplete: v } = U({
|
|
146
160
|
// processMarkdownText will let code block printf("You win!\n") become printf("You win!<br/>");
|
|
147
161
|
// content: processMarkdownText(content),
|
|
148
162
|
content: k,
|
|
149
163
|
typingSpeed: i,
|
|
150
|
-
disabled: !
|
|
164
|
+
disabled: !l
|
|
151
165
|
}), S = C(
|
|
152
|
-
() =>
|
|
166
|
+
() => H(r),
|
|
153
167
|
[r]
|
|
154
|
-
),
|
|
168
|
+
), y = S.some(
|
|
155
169
|
(e) => e.type === "sandbox"
|
|
156
|
-
),
|
|
157
|
-
() =>
|
|
170
|
+
), L = C(
|
|
171
|
+
() => D(N),
|
|
158
172
|
[N]
|
|
159
|
-
), w =
|
|
173
|
+
), w = $(!1);
|
|
160
174
|
return R(() => {
|
|
161
|
-
|
|
162
|
-
}, [
|
|
163
|
-
|
|
164
|
-
}, [
|
|
175
|
+
y || v && !w.current && (w.current = !0, m?.());
|
|
176
|
+
}, [y, v, m]), R(() => {
|
|
177
|
+
y || (w.current = !1);
|
|
178
|
+
}, [y, r]), y ? /* @__PURE__ */ t.jsx("div", { className: "content-render", children: S.map(
|
|
165
179
|
(e, s) => e.type === "sandbox" ? /* @__PURE__ */ t.jsx(
|
|
166
|
-
|
|
180
|
+
J,
|
|
167
181
|
{
|
|
168
182
|
content: e.value,
|
|
169
183
|
className: "content-render-iframe"
|
|
170
184
|
},
|
|
171
185
|
`sandbox-${s}`
|
|
172
|
-
) : /* @__PURE__ */ t.jsx(
|
|
173
|
-
|
|
186
|
+
) : /* @__PURE__ */ t.jsx(
|
|
187
|
+
z,
|
|
174
188
|
{
|
|
175
|
-
remarkPlugins: [
|
|
176
|
-
_,
|
|
177
|
-
E,
|
|
178
|
-
I,
|
|
179
|
-
[U, { omit: ["table", "code", "listItem"] }]
|
|
180
|
-
],
|
|
181
|
-
rehypePlugins: [
|
|
182
|
-
L,
|
|
183
|
-
T,
|
|
184
|
-
[
|
|
185
|
-
V,
|
|
186
|
-
{
|
|
187
|
-
detect: !0,
|
|
188
|
-
subset: P,
|
|
189
|
-
languages: M
|
|
190
|
-
}
|
|
191
|
-
]
|
|
192
|
-
],
|
|
193
189
|
components: b,
|
|
194
|
-
|
|
195
|
-
}
|
|
196
|
-
|
|
190
|
+
content: M(e.value)
|
|
191
|
+
},
|
|
192
|
+
`md-${s}`
|
|
193
|
+
)
|
|
197
194
|
) }) : /* @__PURE__ */ t.jsxs("div", { className: "content-render", children: [
|
|
198
|
-
|
|
195
|
+
L.map((e, s) => {
|
|
199
196
|
if (e.type === "text")
|
|
200
|
-
return /* @__PURE__ */ t.jsx(
|
|
201
|
-
|
|
197
|
+
return /* @__PURE__ */ t.jsx(
|
|
198
|
+
z,
|
|
202
199
|
{
|
|
203
|
-
remarkPlugins: [
|
|
204
|
-
_,
|
|
205
|
-
E,
|
|
206
|
-
I,
|
|
207
|
-
U
|
|
208
|
-
],
|
|
209
|
-
rehypePlugins: [
|
|
210
|
-
Q,
|
|
211
|
-
L,
|
|
212
|
-
X,
|
|
213
|
-
[
|
|
214
|
-
V,
|
|
215
|
-
{ languages: M, subset: P }
|
|
216
|
-
],
|
|
217
|
-
T
|
|
218
|
-
],
|
|
219
200
|
components: b,
|
|
220
|
-
|
|
221
|
-
}
|
|
222
|
-
|
|
201
|
+
content: e.value
|
|
202
|
+
},
|
|
203
|
+
s
|
|
204
|
+
);
|
|
223
205
|
if (e.type === "mermaid")
|
|
224
206
|
return /* @__PURE__ */ t.jsx(
|
|
225
|
-
|
|
207
|
+
I,
|
|
226
208
|
{
|
|
227
209
|
chart: e.value,
|
|
228
210
|
frozen: !e.complete
|
|
@@ -230,9 +212,9 @@ const q = (r) => {
|
|
|
230
212
|
s
|
|
231
213
|
);
|
|
232
214
|
if (e.type === "svg")
|
|
233
|
-
return /* @__PURE__ */ t.jsx(
|
|
215
|
+
return /* @__PURE__ */ t.jsx(re, { svg: e.value }, s);
|
|
234
216
|
}),
|
|
235
|
-
|
|
217
|
+
c && /* @__PURE__ */ t.jsx("div", { className: "content-render-custom-bar", children: T.createElement(c, {
|
|
236
218
|
content: r,
|
|
237
219
|
displayContent: N,
|
|
238
220
|
onSend: a
|
|
@@ -240,6 +222,6 @@ const q = (r) => {
|
|
|
240
222
|
] });
|
|
241
223
|
};
|
|
242
224
|
export {
|
|
243
|
-
|
|
225
|
+
Ie as default
|
|
244
226
|
};
|
|
245
227
|
//# sourceMappingURL=ContentRender.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentRender.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\";\n\ntype RenderSegment =\n | { type: \"markdown\"; value: string }\n | { type: \"sandbox\"; value: string };\n\nconst splitContentSegments = (raw: string): RenderSegment[] => {\n const startPattern =\n /<(script|style|link|iframe|html|head|body|meta|title|base|template|div|section|article|main)[\\s>]/i;\n\n const startIndex = raw.search(startPattern);\n if (startIndex === -1) {\n return [{ type: \"markdown\", value: raw }];\n }\n\n // Find the end of the HTML block: stop at the first closing tag whose\n // following line does not start with another HTML tag.\n const closingBoundary = /<\\/[a-z][^>]*>\\s*\\n(?=[^\\s<])/gi;\n let blockEnd = raw.length;\n let match: RegExpExecArray | null;\n\n while ((match = closingBoundary.exec(raw))) {\n if (match.index <= startIndex) continue;\n blockEnd = match.index + match[0].length - 1; // end before the newline\n break;\n }\n\n const segments: RenderSegment[] = [];\n const before = raw.slice(0, startIndex);\n const htmlBlock = raw.slice(startIndex, blockEnd);\n const after = raw.slice(blockEnd);\n\n if (before.trim()) {\n segments.push({ type: \"markdown\", value: before });\n }\n\n segments.push({ type: \"sandbox\", value: htmlBlock });\n\n if (after.trim()) {\n segments.push(...splitContentSegments(after));\n }\n\n return segments;\n};\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 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 styleEl.textContent = `\n :host { display: block; width: 100%; max-width: 100%; text-align: center; }\n svg { max-width: 100%; height: auto; display: inline-block; }\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 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 hasWidth = !!widthAttr && widthAttr !== \"0\";\n const hasHeight = !!heightAttr && heightAttr !== \"0\";\n const shouldUseResponsiveSize = !hasWidth && !hasHeight;\n\n if (shouldUseResponsiveSize) {\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 if (!hasWidth && viewBoxWidth > 0) {\n svgEl.setAttribute(\"width\", `${viewBoxWidth}`);\n }\n if (!hasHeight && viewBoxHeight > 0) {\n svgEl.setAttribute(\"height\", `${viewBoxHeight}`);\n }\n });\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 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 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),\n [content]\n );\n const hasSandbox = renderSegments.some(\n (segment) => segment.type === \"sandbox\"\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\">\n {renderSegments.map((segment, idx) =>\n segment.type === \"sandbox\" ? (\n <IframeSandbox\n key={`sandbox-${idx}`}\n content={segment.value}\n className=\"content-render-iframe\"\n />\n ) : (\n <div key={`md-${idx}`} className=\"markdown-body\">\n <ReactMarkdown\n remarkPlugins={[\n remarkGfm,\n remarkMath,\n remarkFlow,\n [remarkBreaks, { omit: [\"table\", \"code\", \"listItem\"] }],\n ]}\n rehypePlugins={[\n rehypeRaw,\n rehypeKatex,\n [\n rehypeHighlight,\n {\n detect: true,\n subset: subsetLanguages,\n languages: highlightLanguages,\n },\n ],\n ]}\n components={components}\n >\n {normalizeInlineHtml(segment.value)}\n </ReactMarkdown>\n </div>\n )\n )}\n </div>\n );\n }\n\n return (\n <div className=\"content-render\">\n {segments.map((seg, index) => {\n if (seg.type === \"text\") {\n return (\n <div key={index} className=\"markdown-body\">\n <ReactMarkdown\n remarkPlugins={[\n remarkGfm,\n remarkMath,\n remarkFlow,\n remarkBreaks,\n ]}\n rehypePlugins={[\n preserveCustomVariableProperties,\n rehypeRaw,\n restoreCustomVariableProperties,\n [\n rehypeHighlight,\n { languages: highlightLanguages, subset: subsetLanguages },\n ],\n rehypeKatex,\n ]}\n components={components}\n >\n {seg.value}\n </ReactMarkdown>\n </div>\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":["splitContentSegments","raw","startPattern","startIndex","closingBoundary","blockEnd","match","segments","before","htmlBlock","after","SvgBlockInShadow","svg","hostRef","useRef","useEffect","host","shadowRoot","styleId","styleEl","node","template","svgEl","viewBox","dimensions","value","viewBoxWidth","viewBoxHeight","widthAttr","heightAttr","hasWidth","hasHeight","jsx","ContentRender","content","customRenderBar","onSend","typingSpeed","enableTypewriter","defaultButtonText","defaultInputText","defaultSelectedValues","readonly","onTypeFinished","confirmButtonText","copyButtonText","copiedButtonText","onClickCustomButtonAfterContent","beforeSend","normalizedContent","useMemo","normalizeInlineHtml","components","children","props","CustomButtonInputVariable","className","rest","chartContent","frozen","mermaidBlockIsComplete","MermaidChart","CodeBlock","displayContent","isComplete","useTypewriterStateMachine","renderSegments","hasSandbox","segment","parseMarkdownSegments","hasCompleted","idx","IframeSandbox","ReactMarkdown","remarkGfm","remarkMath","remarkFlow","remarkBreaks","rehypeRaw","rehypeKatex","rehypeHighlight","subsetLanguages","highlightLanguages","jsxs","seg","index","preserveCustomVariableProperties","restoreCustomVariableProperties","React"],"mappings":";;;;;;;;;;;;;;;;;;;;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E3DF;AAAA,YAAA;AAAA,YAEF,YAAA3B;AAAA,YAEC,UAAAgC,EAAI;AAAA,UAAA;AAAA,QAAA,KApBCC,CAsBV;AAIJ,UAAID,EAAI,SAAS;AACf,eACEpD,gBAAAA,EAAAA;AAAAA,UAAC6B;AAAA,UAAA;AAAA,YAEC,OAAOuB,EAAI;AAAA,YACX,QAAQ,CAACA,EAAI;AAAA,UAAA;AAAA,UAFRC;AAAA,QAAA;AAOX,UAAID,EAAI,SAAS;AACf,eAAOpD,gBAAAA,EAAAA,IAACrB,IAAA,EAA6B,KAAKyE,EAAI,SAAhBC,CAAuB;AAAA,IAEzD,CAAC;AAAA,IAEAlD,KACCH,gBAAAA,EAAAA,IAAC,OAAA,EAAI,WAAU,6BACZ,UAAAwD,EAAM,cAAcrD,GAAiB;AAAA,MACpC,SAAAD;AAAA,MACA,gBAAA6B;AAAA,MACA,QAAA3B;AAAA,IAAA,CACD,EAAA,CACH;AAAA,EAAA,GAEJ;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"ContentRender.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\";\n\ntype RenderSegment =\n | { type: \"markdown\"; value: string }\n | { type: \"sandbox\"; value: string };\n\nconst splitContentSegments = (raw: string): RenderSegment[] => {\n const startPattern =\n /<(script|style|link|iframe|html|head|body|meta|title|base|template|div|section|article|main)[\\s>]/i;\n\n const startIndex = raw.search(startPattern);\n if (startIndex === -1) {\n return [{ type: \"markdown\", value: raw }];\n }\n\n // Find the end of the HTML block: stop at the first closing tag whose\n // following line does not start with another HTML tag.\n const closingBoundary = /<\\/[a-z][^>]*>\\s*\\n(?=[^\\s<])/gi;\n let blockEnd = raw.length;\n let match: RegExpExecArray | null;\n\n while ((match = closingBoundary.exec(raw))) {\n if (match.index <= startIndex) continue;\n blockEnd = match.index + match[0].length - 1; // end before the newline\n break;\n }\n\n const segments: RenderSegment[] = [];\n const before = raw.slice(0, startIndex);\n const htmlBlock = raw.slice(startIndex, blockEnd);\n const after = raw.slice(blockEnd);\n\n if (before.trim()) {\n segments.push({ type: \"markdown\", value: before });\n }\n\n segments.push({ type: \"sandbox\", value: htmlBlock });\n\n if (after.trim()) {\n segments.push(...splitContentSegments(after));\n }\n\n return segments;\n};\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 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 styleEl.textContent = `\n :host { display: block; width: 100%; max-width: 100%; text-align: center; }\n svg { max-width: 100%; height: auto; display: inline-block; }\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 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 hasWidth = !!widthAttr && widthAttr !== \"0\";\n const hasHeight = !!heightAttr && heightAttr !== \"0\";\n const shouldUseResponsiveSize = !hasWidth && !hasHeight;\n\n if (shouldUseResponsiveSize) {\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 if (!hasWidth && viewBoxWidth > 0) {\n svgEl.setAttribute(\"width\", `${viewBoxWidth}`);\n }\n if (!hasHeight && viewBoxHeight > 0) {\n svgEl.setAttribute(\"height\", `${viewBoxHeight}`);\n }\n });\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\nconst MarkdownRenderer: React.FC<{\n content: string;\n components: CustomComponents;\n}> = ({ content: markdownContent, components }) => (\n <div className=\"markdown-body\">\n <ReactMarkdown\n remarkPlugins={remarkPlugins}\n rehypePlugins={rehypePlugins}\n components={components}\n >\n {markdownContent}\n </ReactMarkdown>\n </div>\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 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),\n [content]\n );\n const hasSandbox = renderSegments.some(\n (segment) => segment.type === \"sandbox\"\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\">\n {renderSegments.map((segment, idx) =>\n segment.type === \"sandbox\" ? (\n <IframeSandbox\n key={`sandbox-${idx}`}\n content={segment.value}\n className=\"content-render-iframe\"\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\">\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":["splitContentSegments","raw","startPattern","startIndex","closingBoundary","blockEnd","match","segments","before","htmlBlock","after","SvgBlockInShadow","svg","hostRef","useRef","useEffect","host","shadowRoot","styleId","styleEl","node","template","svgEl","viewBox","dimensions","value","viewBoxWidth","viewBoxHeight","widthAttr","heightAttr","hasWidth","hasHeight","jsx","remarkPlugins","remarkGfm","remarkMath","remarkFlow","remarkBreaks","rehypePlugins","preserveCustomVariableProperties","rehypeRaw","restoreCustomVariableProperties","rehypeHighlight","highlightLanguages","subsetLanguages","rehypeKatex","MarkdownRenderer","markdownContent","components","ReactMarkdown","ContentRender","content","customRenderBar","onSend","typingSpeed","enableTypewriter","defaultButtonText","defaultInputText","defaultSelectedValues","readonly","onTypeFinished","confirmButtonText","copyButtonText","copiedButtonText","onClickCustomButtonAfterContent","beforeSend","normalizedContent","useMemo","normalizeInlineHtml","children","props","CustomButtonInputVariable","className","rest","chartContent","frozen","mermaidBlockIsComplete","MermaidChart","CodeBlock","displayContent","isComplete","useTypewriterStateMachine","renderSegments","hasSandbox","segment","parseMarkdownSegments","hasCompleted","idx","IframeSandbox","jsxs","seg","index","React"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAwCA,MAAMA,IAAuB,CAACC,MAAiC;AAC7D,QAAMC,IACJ,sGAEIC,IAAaF,EAAI,OAAOC,CAAY;AAC1C,MAAIC,MAAe;AACjB,WAAO,CAAC,EAAE,MAAM,YAAY,OAAOF,GAAK;AAK1C,QAAMG,IAAkB;AACxB,MAAIC,IAAWJ,EAAI,QACfK;AAEJ,SAAQA,IAAQF,EAAgB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