markdown-flow-ui 0.1.89 → 0.1.90-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/classnames@2.5.1/node_modules/classnames/index.cjs.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/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/rc-input@1.8.0_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-input/es/BaseInput.cjs.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-input@1.8.0_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-input/es/BaseInput.es.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/ResizableTextArea.cjs.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/ResizableTextArea.es.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/TextArea.cjs.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/TextArea.es.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/index.cjs.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/index.es.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/remark-flow@0.1.6/node_modules/remark-flow/dist/index.cjs.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/remark-flow@0.1.6/node_modules/remark-flow/dist/index.es.js +1 -1
- package/dist/_virtual/index.cjs2.js +1 -1
- package/dist/_virtual/index.cjs3.js +1 -1
- package/dist/_virtual/index.cjs7.js +1 -1
- package/dist/_virtual/index.cjs8.js +1 -1
- package/dist/_virtual/index.es2.js +5 -2
- package/dist/_virtual/index.es2.js.map +1 -1
- package/dist/_virtual/index.es3.js +2 -5
- package/dist/_virtual/index.es3.js.map +1 -1
- package/dist/_virtual/index.es7.js +2 -3
- package/dist/_virtual/index.es7.js.map +1 -1
- package/dist/_virtual/index.es8.js +3 -2
- package/dist/_virtual/index.es8.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 +149 -140
- package/dist/components/ContentRender/ContentRender.es.js.map +1 -1
- package/dist/components/ContentRender/IframeSandbox.cjs.js +1 -1
- package/dist/components/ContentRender/IframeSandbox.cjs.js.map +1 -1
- package/dist/components/ContentRender/IframeSandbox.es.js +1 -1
- package/dist/components/ContentRender/IframeSandbox.es.js.map +1 -1
- package/dist/components/ContentRender/SplitContent.stories.d.ts +16 -0
- package/dist/components/ContentRender/utils/split-content.cjs.js +5 -3
- package/dist/components/ContentRender/utils/split-content.cjs.js.map +1 -1
- package/dist/components/ContentRender/utils/split-content.es.js +93 -62
- package/dist/components/ContentRender/utils/split-content.es.js.map +1 -1
- 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 +10 -0
- package/dist/components/ContentRender/utils/strip-svg-text-line-breaks.es.js.map +1 -0
- package/dist/components/ui/inputGroup/textarea.cjs.js +1 -1
- package/dist/components/ui/inputGroup/textarea.es.js +1 -1
- package/dist/markdown-flow-ui-lib.css +1 -1
- package/package.json +1 -1
|
@@ -1,87 +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
|
|
6
|
-
import { sanitizeInvalidTagName as
|
|
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";
|
|
7
8
|
/* empty css */
|
|
8
9
|
/* empty css */
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import { preserveCustomVariableProperties as
|
|
14
|
-
import { subsetLanguages as
|
|
15
|
-
import { parseMarkdownSegments as
|
|
16
|
-
import { normalizeInlineHtml as
|
|
17
|
-
import
|
|
18
|
-
import { splitContentSegments as
|
|
19
|
-
import { Markdown as
|
|
20
|
-
import
|
|
21
|
-
import
|
|
22
|
-
import
|
|
23
|
-
import
|
|
24
|
-
import
|
|
25
|
-
import
|
|
26
|
-
const
|
|
27
|
-
const o =
|
|
28
|
-
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(() => {
|
|
29
30
|
const a = o.current;
|
|
30
31
|
if (!a) return;
|
|
31
|
-
const i = a.shadowRoot ?? a.attachShadow({ mode: "open" }),
|
|
32
|
-
let
|
|
33
|
-
|
|
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 = `
|
|
34
35
|
svg { height: auto; display: inline-block; }
|
|
35
36
|
svg.content-render-svg-el--responsive { width: 100%; max-width: 100%; }
|
|
36
37
|
svg.content-render-svg-el--fixed { max-width: none; }
|
|
37
|
-
`, i.appendChild(
|
|
38
|
-
(
|
|
39
|
-
).forEach((
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
let
|
|
43
|
-
i.querySelectorAll("svg").forEach((
|
|
44
|
-
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");
|
|
45
46
|
if (!R) return;
|
|
46
|
-
const
|
|
47
|
-
if (
|
|
48
|
-
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) => {
|
|
49
50
|
if (!c) return !1;
|
|
50
51
|
const e = c.trim().toLowerCase();
|
|
51
52
|
return e === "auto" || e.endsWith("%");
|
|
52
|
-
},
|
|
53
|
+
}, B = (c) => {
|
|
53
54
|
if (!c) return null;
|
|
54
55
|
const e = c.trim().toLowerCase();
|
|
55
56
|
if (e === "auto" || e.endsWith("%"))
|
|
56
57
|
return null;
|
|
57
|
-
const
|
|
58
|
-
return Number.isNaN(
|
|
59
|
-
},
|
|
60
|
-
if (
|
|
61
|
-
|
|
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}`);
|
|
62
63
|
return;
|
|
63
64
|
}
|
|
64
|
-
|
|
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}`);
|
|
65
66
|
});
|
|
66
|
-
const
|
|
67
|
-
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);
|
|
68
69
|
}, [s]), /* @__PURE__ */ t.jsx("div", { className: "content-render-svg-scroll", children: /* @__PURE__ */ t.jsx("div", { className: "content-render-svg", ref: o }) });
|
|
69
|
-
},
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
G,
|
|
70
|
+
}, he = [de, ue, O, pe], fe = [
|
|
71
|
+
ee,
|
|
72
|
+
ce,
|
|
73
73
|
Q,
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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,
|
|
78
79
|
{
|
|
79
|
-
remarkPlugins:
|
|
80
|
-
rehypePlugins:
|
|
80
|
+
remarkPlugins: he,
|
|
81
|
+
rehypePlugins: fe,
|
|
81
82
|
components: o,
|
|
82
83
|
children: s
|
|
83
84
|
}
|
|
84
|
-
) }),
|
|
85
|
+
) }), xe = (s) => {
|
|
85
86
|
if (s.length <= 1) return s;
|
|
86
87
|
const o = [];
|
|
87
88
|
return s.forEach((a) => {
|
|
@@ -99,71 +100,71 @@ const le = ({ svg: s }) => {
|
|
|
99
100
|
}
|
|
100
101
|
o.push({ type: "markdown", value: a.value });
|
|
101
102
|
}), o;
|
|
102
|
-
},
|
|
103
|
+
}, qe = ({
|
|
103
104
|
content: s,
|
|
104
105
|
customRenderBar: o,
|
|
105
106
|
onSend: a,
|
|
106
107
|
typingSpeed: i = 30,
|
|
107
|
-
enableTypewriter:
|
|
108
|
-
defaultButtonText:
|
|
109
|
-
defaultInputText:
|
|
110
|
-
defaultSelectedValues:
|
|
111
|
-
readonly:
|
|
112
|
-
onTypeFinished:
|
|
113
|
-
confirmButtonText:
|
|
114
|
-
copyButtonText:
|
|
115
|
-
copiedButtonText:
|
|
116
|
-
sandboxLoadingText:
|
|
117
|
-
sandboxStyleLoadingText:
|
|
118
|
-
sandboxScriptLoadingText:
|
|
119
|
-
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,
|
|
120
121
|
sandboxMode: f = "content",
|
|
121
|
-
onClickCustomButtonAfterContent:
|
|
122
|
-
beforeSend:
|
|
122
|
+
onClickCustomButtonAfterContent: x,
|
|
123
|
+
beforeSend: C
|
|
123
124
|
// tooltipMinLength,
|
|
124
125
|
}) => {
|
|
125
|
-
const
|
|
126
|
-
() =>
|
|
126
|
+
const B = $(
|
|
127
|
+
() => q(s),
|
|
127
128
|
[s]
|
|
128
|
-
),
|
|
129
|
+
), M = {
|
|
129
130
|
"custom-button-after-content": ({
|
|
130
131
|
children: e
|
|
131
132
|
}) => /* @__PURE__ */ t.jsx(
|
|
132
133
|
"button",
|
|
133
134
|
{
|
|
134
135
|
className: "content-render-custom-button-after-content",
|
|
135
|
-
onClick:
|
|
136
|
+
onClick: x,
|
|
136
137
|
children: /* @__PURE__ */ t.jsx("span", { className: "content-render-custom-button-after-content-inner", children: e })
|
|
137
138
|
}
|
|
138
139
|
),
|
|
139
140
|
"custom-variable": (e) => /* @__PURE__ */ t.jsx(
|
|
140
|
-
|
|
141
|
+
Z,
|
|
141
142
|
{
|
|
142
143
|
...e,
|
|
143
|
-
readonly:
|
|
144
|
-
defaultButtonText:
|
|
145
|
-
defaultInputText:
|
|
146
|
-
defaultSelectedValues:
|
|
144
|
+
readonly: z,
|
|
145
|
+
defaultButtonText: d,
|
|
146
|
+
defaultInputText: W,
|
|
147
|
+
defaultSelectedValues: b,
|
|
147
148
|
onSend: a,
|
|
148
|
-
beforeSend:
|
|
149
|
-
confirmButtonText:
|
|
149
|
+
beforeSend: C,
|
|
150
|
+
confirmButtonText: S
|
|
150
151
|
}
|
|
151
152
|
),
|
|
152
153
|
code: (e) => {
|
|
153
|
-
const { className:
|
|
154
|
-
if (/language-(\w+)/.exec(
|
|
155
|
-
const
|
|
156
|
-
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 });
|
|
157
158
|
}
|
|
158
|
-
return /* @__PURE__ */ t.jsx("code", { className:
|
|
159
|
+
return /* @__PURE__ */ t.jsx("code", { className: r, ...I, children: l });
|
|
159
160
|
},
|
|
160
161
|
table: ({ ...e }) => /* @__PURE__ */ t.jsx("div", { className: "content-render-table-container", children: /* @__PURE__ */ t.jsx("table", { className: "content-render-table", ...e }) }),
|
|
161
162
|
th: ({ ...e }) => /* @__PURE__ */ t.jsx("th", { className: "content-render-th", ...e }),
|
|
162
163
|
td: ({ ...e }) => /* @__PURE__ */ t.jsx("td", { className: "content-render-td", ...e }),
|
|
163
164
|
tr: ({ ...e }) => /* @__PURE__ */ t.jsx("tr", { className: "content-render-tr", ...e }),
|
|
164
|
-
li: ({ node: e, ...
|
|
165
|
-
const
|
|
166
|
-
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 });
|
|
167
168
|
},
|
|
168
169
|
ol: ({ ...e }) => /* @__PURE__ */ t.jsx("ol", { className: "content-render-ol", ...e }),
|
|
169
170
|
ul: ({ ...e }) => /* @__PURE__ */ t.jsx("ul", { className: "content-render-ul", ...e }),
|
|
@@ -176,91 +177,99 @@ const le = ({ svg: s }) => {
|
|
|
176
177
|
...e
|
|
177
178
|
}
|
|
178
179
|
) : /* @__PURE__ */ t.jsx("input", { ...e }),
|
|
179
|
-
a: ({ children: e, ...
|
|
180
|
+
a: ({ children: e, ...r }) => /* @__PURE__ */ t.jsx("a", { target: "_blank", rel: "noopener noreferrer", ...r, children: e }),
|
|
180
181
|
pre: (e) => /* @__PURE__ */ t.jsx(
|
|
181
|
-
|
|
182
|
+
Y,
|
|
182
183
|
{
|
|
183
184
|
...e,
|
|
184
|
-
copyButtonText:
|
|
185
|
-
copiedButtonText:
|
|
185
|
+
copyButtonText: L,
|
|
186
|
+
copiedButtonText: n
|
|
186
187
|
}
|
|
187
188
|
)
|
|
188
|
-
}, { displayContent:
|
|
189
|
+
}, { displayContent: N, isComplete: w } = E({
|
|
189
190
|
// processMarkdownText will let code block printf("You win!\n") become printf("You win!<br/>");
|
|
190
191
|
// content: processMarkdownText(content),
|
|
191
|
-
content:
|
|
192
|
+
content: B,
|
|
192
193
|
typingSpeed: i,
|
|
193
|
-
disabled: !
|
|
194
|
-
}),
|
|
195
|
-
() =>
|
|
194
|
+
disabled: !k
|
|
195
|
+
}), g = $(
|
|
196
|
+
() => ae(s, !0),
|
|
196
197
|
[s]
|
|
197
|
-
),
|
|
198
|
+
), p = g.some(
|
|
198
199
|
(e) => e.type === "sandbox"
|
|
199
|
-
),
|
|
200
|
-
() =>
|
|
201
|
-
[
|
|
202
|
-
),
|
|
203
|
-
() =>
|
|
204
|
-
[
|
|
205
|
-
),
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
}, [
|
|
209
|
-
|
|
210
|
-
}, [
|
|
211
|
-
|
|
212
|
-
|
|
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(H, { chart: m.value, frozen: !m.complete }, v) : m.type === "svg" ? /* @__PURE__ */ t.jsx(G, { svg: m.value }, v) : null;
|
|
224
|
+
});
|
|
225
|
+
};
|
|
226
|
+
return p ? /* @__PURE__ */ t.jsx("div", { className: "content-render markdown-body", children: A.map(
|
|
227
|
+
(e, r) => e.type === "sandbox" ? /* @__PURE__ */ t.jsx(
|
|
228
|
+
oe,
|
|
213
229
|
{
|
|
214
230
|
hideFullScreen: !0,
|
|
215
231
|
content: e.value,
|
|
216
232
|
className: "content-render-iframe",
|
|
217
|
-
loadingText:
|
|
218
|
-
styleLoadingText:
|
|
219
|
-
scriptLoadingText:
|
|
220
|
-
fullScreenButtonText:
|
|
233
|
+
loadingText: R,
|
|
234
|
+
styleLoadingText: j,
|
|
235
|
+
scriptLoadingText: h,
|
|
236
|
+
fullScreenButtonText: u,
|
|
221
237
|
mode: f
|
|
222
238
|
},
|
|
223
|
-
`sandbox-${
|
|
224
|
-
) : /* @__PURE__ */ t.jsx(
|
|
225
|
-
P,
|
|
226
|
-
{
|
|
227
|
-
components: L,
|
|
228
|
-
content: W(e.value)
|
|
229
|
-
},
|
|
230
|
-
`md-${n}`
|
|
231
|
-
)
|
|
239
|
+
`sandbox-${r}`
|
|
240
|
+
) : /* @__PURE__ */ t.jsx(_.Fragment, { children: c(e.value, `md-${r}`) }, `md-${r}`)
|
|
232
241
|
) }) : /* @__PURE__ */ t.jsxs("div", { className: "content-render markdown-body", children: [
|
|
233
|
-
|
|
242
|
+
F.map((e, r) => {
|
|
234
243
|
if (e.type === "text")
|
|
235
244
|
return /* @__PURE__ */ t.jsx(
|
|
236
|
-
|
|
245
|
+
K,
|
|
237
246
|
{
|
|
238
|
-
components:
|
|
247
|
+
components: M,
|
|
239
248
|
content: e.value
|
|
240
249
|
},
|
|
241
|
-
|
|
250
|
+
r
|
|
242
251
|
);
|
|
243
252
|
if (e.type === "mermaid")
|
|
244
253
|
return /* @__PURE__ */ t.jsx(
|
|
245
|
-
|
|
254
|
+
H,
|
|
246
255
|
{
|
|
247
256
|
chart: e.value,
|
|
248
257
|
frozen: !e.complete
|
|
249
258
|
},
|
|
250
|
-
|
|
259
|
+
r
|
|
251
260
|
);
|
|
252
261
|
if (e.type === "svg")
|
|
253
|
-
return /* @__PURE__ */ t.jsx(
|
|
262
|
+
return /* @__PURE__ */ t.jsx(G, { svg: e.value }, r);
|
|
254
263
|
}),
|
|
255
|
-
o && /* @__PURE__ */ t.jsx("div", { className: "content-render-custom-bar", children:
|
|
264
|
+
o && /* @__PURE__ */ t.jsx("div", { className: "content-render-custom-bar", children: _.createElement(o, {
|
|
256
265
|
content: s,
|
|
257
|
-
displayContent:
|
|
266
|
+
displayContent: N,
|
|
258
267
|
onSend: a
|
|
259
268
|
}) })
|
|
260
269
|
] });
|
|
261
270
|
};
|
|
262
271
|
export {
|
|
263
|
-
|
|
264
|
-
|
|
272
|
+
K as MarkdownRenderer,
|
|
273
|
+
qe as default
|
|
265
274
|
};
|
|
266
275
|
//# sourceMappingURL=ContentRender.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentRender.es.js","sources":["../../../src/components/ContentRender/ContentRender.tsx"],"sourcesContent":["import \"highlight.js/styles/github.css\";\nimport \"katex/dist/katex.min.css\";\nimport React, { useEffect, useMemo, useRef } from \"react\";\nimport ReactMarkdown from \"react-markdown\";\nimport rehypeHighlight from \"rehype-highlight\";\nimport rehypeKatex from \"rehype-katex\";\nimport rehypeRaw from \"rehype-raw\";\nimport remarkBreaks from \"remark-breaks\";\nimport remarkFlow from \"remark-flow\";\nimport remarkGfm from \"remark-gfm\";\nimport remarkMath from \"remark-math\";\nimport { CustomRenderBarProps, OnSendContentParams } from \"../types\";\nimport { sanitizeInvalidTagName } from \"./utils/sanitize-invalid-tag-name\";\nimport \"./contentRender.css\";\nimport \"./github-markdown-light.css\";\nimport CodeBlock from \"./CodeBlock\";\nimport CustomButtonInputVariable, {\n ComponentsWithCustomVariable,\n} from \"./plugins/CustomVariable\";\nimport MermaidChart from \"./plugins/MermaidChart\";\nimport useTypewriterStateMachine from \"./useTypewriterStateMachine\";\nimport {\n preserveCustomVariableProperties,\n restoreCustomVariableProperties,\n} from \"./utils/custom-variable-props\";\nimport {\n highlightLanguages,\n subsetLanguages,\n} from \"./utils/highlight-languages\";\n// import { processMarkdownText } from \"./utils/process-markdown\";\nimport {\n parseMarkdownSegments,\n mermaidBlockIsComplete,\n} from \"./utils/mermaid-parse\";\nimport { normalizeInlineHtml } from \"./utils/normalize-inline-html\";\nimport IframeSandbox from \"./IframeSandbox\";\nimport {\n splitContentSegments,\n type RenderSegment,\n} from \"./utils/split-content\";\n// Define component Props type\nexport interface ContentRenderProps {\n content: string;\n /**\n+ * Callback invoked when the custom button after content is clicked.\n+ * This button is rendered via the `<custom-button-after-content>` tag in markdown content.\n+ * @example\n+ * ```tsx\n+ * <ContentRender\n+ * content=\"Hello <custom-button-after-content>Ask</custom-button-after-content>\"\n+ * onClickCustomButtonAfterContent={() => console.log('Button clicked')}\n+ * />\n+ * ```\n+ */\n customRenderBar?: CustomRenderBarProps;\n onClickCustomButtonAfterContent?: () => void;\n onSend?: (content: OnSendContentParams) => void;\n typingSpeed?: number;\n enableTypewriter?: boolean;\n defaultButtonText?: string;\n defaultInputText?: string; // Text input by user\n defaultSelectedValues?: string[]; // Default selected values for multi-select\n readonly?: boolean;\n onTypeFinished?: () => void;\n // Multi-select confirm button text (i18n support)\n confirmButtonText?: string;\n // Copy button text (i18n support)\n copyButtonText?: string;\n // Copied state text (i18n support)\n copiedButtonText?: string;\n // Dynamic interaction format for multi-select support\n dynamicInteractionFormat?: string;\n // Loading text before first HTML block renders inside iframe (i18n support)\n sandboxLoadingText?: string;\n // Loading text while styles are being generated inside iframe\n sandboxStyleLoadingText?: string;\n // Loading text while scripts are being cached/executed inside iframe\n sandboxScriptLoadingText?: string;\n // Fullscreen button text for iframe sandbox\n sandboxFullscreenButtonText?: string;\n // Sandbox render mode\n sandboxMode?: \"content\" | \"blackboard\";\n beforeSend?: (param: OnSendContentParams) => boolean;\n // tooltipMinLength?: number; // Control minimum character length for tooltip display, default 10\n}\n\n// Render svg string via Shadow DOM to avoid markdown wrapping\nconst SvgBlockInShadow: React.FC<{ svg: string }> = ({ svg }) => {\n const hostRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n const host = hostRef.current;\n if (!host) return;\n const shadowRoot = host.shadowRoot ?? host.attachShadow({ mode: \"open\" });\n const styleId = \"content-render-svg-style\";\n let styleEl = shadowRoot.getElementById(styleId) as HTMLStyleElement | null;\n\n if (!styleEl) {\n styleEl = document.createElement(\"style\");\n styleEl.id = styleId;\n // Keep intrinsic SVG width so the wrapper can scroll horizontally when needed\n styleEl.textContent = `\n svg { height: auto; display: inline-block; }\n svg.content-render-svg-el--responsive { width: 100%; max-width: 100%; }\n svg.content-render-svg-el--fixed { max-width: none; }\n `;\n shadowRoot.appendChild(styleEl);\n }\n\n const nodesToRemove = Array.from(shadowRoot.childNodes).filter(\n (node) => node !== styleEl\n );\n nodesToRemove.forEach((node) => shadowRoot.removeChild(node));\n\n const template = document.createElement(\"template\");\n template.innerHTML = svg;\n shadowRoot.append(template.content.cloneNode(true));\n\n let hasResponsiveSvg = false;\n let hasFixedSvg = false;\n\n shadowRoot.querySelectorAll(\"svg\").forEach((svgEl) => {\n // Derive responsive sizing from viewBox so pure viewBox SVGs stay visible and fluid\n const viewBox = svgEl.getAttribute(\"viewBox\");\n if (!viewBox) return;\n\n const dimensions = viewBox\n .trim()\n .split(/[\\s,]+/)\n .map((value) => Number(value));\n\n if (dimensions.length !== 4 || dimensions.some(Number.isNaN)) return;\n\n const [, , viewBoxWidth, viewBoxHeight] = dimensions;\n const widthAttr = svgEl.getAttribute(\"width\");\n const heightAttr = svgEl.getAttribute(\"height\");\n const isRelativeLength = (value?: string | null) => {\n if (!value) return false;\n const normalized = value.trim().toLowerCase();\n return normalized === \"auto\" || normalized.endsWith(\"%\");\n };\n const toNumericLength = (value?: string | null) => {\n if (!value) return null;\n const normalized = value.trim().toLowerCase();\n if (normalized === \"auto\" || normalized.endsWith(\"%\")) {\n return null;\n }\n const parsed = Number.parseFloat(normalized);\n return Number.isNaN(parsed) ? null : parsed;\n };\n // Treat percentage/auto sizing as responsive so viewBox drives the layout\n const isWidthRelative = isRelativeLength(widthAttr);\n const isHeightRelative = isRelativeLength(heightAttr);\n const widthMissing = !widthAttr || widthAttr === \"0\";\n const heightMissing = !heightAttr || heightAttr === \"0\";\n const numericWidth = toNumericLength(widthAttr);\n const numericHeight = toNumericLength(heightAttr);\n const matchesViewBox =\n numericWidth === viewBoxWidth && numericHeight === viewBoxHeight;\n\n // Prefer responsive layout when sizing is relative or matches the viewBox\n const shouldUseResponsiveSize =\n isWidthRelative ||\n isHeightRelative ||\n (widthMissing && heightMissing) ||\n matchesViewBox;\n\n if (shouldUseResponsiveSize) {\n hasResponsiveSvg = true;\n svgEl.classList.add(\"content-render-svg-el--responsive\");\n svgEl.classList.remove(\"content-render-svg-el--fixed\");\n svgEl.style.width = \"100%\";\n svgEl.style.height = \"auto\";\n if (!svgEl.style.aspectRatio && viewBoxHeight > 0) {\n svgEl.style.aspectRatio = `${viewBoxWidth} / ${viewBoxHeight}`;\n }\n return;\n }\n\n hasFixedSvg = true;\n svgEl.classList.add(\"content-render-svg-el--fixed\");\n svgEl.classList.remove(\"content-render-svg-el--responsive\");\n if (widthMissing && viewBoxWidth > 0) {\n svgEl.setAttribute(\"width\", `${viewBoxWidth}`);\n }\n if (heightMissing && viewBoxHeight > 0) {\n svgEl.setAttribute(\"height\", `${viewBoxHeight}`);\n }\n });\n\n const hostResponsive = hasResponsiveSvg && !hasFixedSvg;\n host.classList.toggle(\"content-render-svg--responsive\", hostResponsive);\n host.classList.toggle(\"content-render-svg--fixed\", !hostResponsive);\n }, [svg]);\n\n return (\n <div className=\"content-render-svg-scroll\">\n <div className=\"content-render-svg\" ref={hostRef} />\n </div>\n );\n};\n\n// Extended component interface\ntype CustomComponents = ComponentsWithCustomVariable & {\n \"custom-button-after-content\"?: React.ComponentType<{\n children: React.ReactNode;\n }>;\n};\n\nconst remarkPlugins = [remarkGfm, remarkMath, remarkFlow, remarkBreaks];\n\nconst rehypePlugins = [\n preserveCustomVariableProperties,\n rehypeRaw,\n sanitizeInvalidTagName,\n restoreCustomVariableProperties,\n [rehypeHighlight, { languages: highlightLanguages, subset: subsetLanguages }],\n rehypeKatex,\n];\n\nexport const MarkdownRenderer: React.FC<{\n content: string;\n components: CustomComponents;\n}> = ({ content: markdownContent, components }) => (\n <div className=\"markdown-renderer\">\n <ReactMarkdown\n remarkPlugins={remarkPlugins}\n rehypePlugins={rehypePlugins}\n components={components}\n >\n {markdownContent}\n </ReactMarkdown>\n </div>\n);\n\nconst mergeNonSandboxSegments = (segments: RenderSegment[]) => {\n if (segments.length <= 1) return segments;\n const merged: RenderSegment[] = [];\n\n segments.forEach((segment) => {\n if (segment.type === \"sandbox\") {\n merged.push(segment);\n return;\n }\n\n const last = merged[merged.length - 1];\n if (last && last.type !== \"sandbox\") {\n merged[merged.length - 1] = {\n type: \"markdown\",\n value: `${last.value}${segment.value}`,\n };\n return;\n }\n\n merged.push({ type: \"markdown\", value: segment.value });\n });\n\n return merged;\n};\n\nconst ContentRender: React.FC<ContentRenderProps> = ({\n content,\n customRenderBar,\n onSend,\n typingSpeed = 30,\n enableTypewriter = false,\n defaultButtonText,\n defaultInputText,\n defaultSelectedValues,\n readonly = false,\n onTypeFinished,\n confirmButtonText,\n copyButtonText,\n copiedButtonText,\n sandboxLoadingText,\n sandboxStyleLoadingText,\n sandboxScriptLoadingText,\n sandboxFullscreenButtonText,\n sandboxMode = \"content\",\n onClickCustomButtonAfterContent,\n beforeSend,\n // tooltipMinLength,\n}) => {\n const normalizedContent = useMemo(\n () => normalizeInlineHtml(content),\n [content]\n );\n\n // Use custom Hook to handle typewriter effect\n const components: CustomComponents = {\n \"custom-button-after-content\": ({\n children,\n }: {\n children: React.ReactNode;\n }) => {\n return (\n <button\n className=\"content-render-custom-button-after-content\"\n onClick={onClickCustomButtonAfterContent}\n >\n <span className=\"content-render-custom-button-after-content-inner\">\n {children}\n </span>\n </button>\n );\n },\n \"custom-variable\": (props) => (\n <CustomButtonInputVariable\n {...props}\n readonly={readonly}\n defaultButtonText={defaultButtonText}\n defaultInputText={defaultInputText}\n defaultSelectedValues={defaultSelectedValues}\n onSend={onSend}\n beforeSend={beforeSend}\n confirmButtonText={confirmButtonText}\n // tooltipMinLength={tooltipMinLength}\n />\n ),\n code: (props) => {\n const { className, children, ...rest } = props as {\n className?: string;\n children?: React.ReactNode;\n };\n const match = /language-(\\w+)/.exec(className || \"\");\n const language = match?.[1];\n if (language === \"mermaid\") {\n const chartContent = children?.toString().replace(/\\n$/, \"\") || \"\";\n const frozen = mermaidBlockIsComplete(content, chartContent);\n return <MermaidChart chart={chartContent} frozen={frozen} />;\n }\n\n return (\n <code className={className} {...rest}>\n {children}\n </code>\n );\n },\n table: ({ ...props }) => (\n <div className=\"content-render-table-container\">\n <table className=\"content-render-table\" {...props} />\n </div>\n ),\n th: ({ ...props }) => <th className=\"content-render-th\" {...props} />,\n td: ({ ...props }) => <td className=\"content-render-td\" {...props} />,\n tr: ({ ...props }) => <tr className=\"content-render-tr\" {...props} />,\n li: ({ node, ...props }) => {\n const className = node?.properties?.className;\n const hasTaskListItem =\n (typeof className === \"string\" &&\n className.includes(\"task-list-item\")) ||\n (Array.isArray(className) && className.includes(\"task-list-item\"));\n if (hasTaskListItem) {\n return <li className=\"content-render-task-list-item\" {...props} />;\n }\n return <li {...props} />;\n },\n ol: ({ ...props }) => <ol className=\"content-render-ol\" {...props} />,\n ul: ({ ...props }) => <ul className=\"content-render-ul\" {...props} />,\n input: ({ ...props }) => {\n if (props.type === \"checkbox\") {\n return (\n <input\n type=\"checkbox\"\n className=\"content-render-checkbox\"\n disabled\n {...props}\n />\n );\n }\n return <input {...props} />;\n },\n a: ({ children, ...props }) => (\n <a target=\"_blank\" rel=\"noopener noreferrer\" {...props}>\n {children}\n </a>\n ),\n pre: (props) => (\n <CodeBlock\n {...props}\n copyButtonText={copyButtonText}\n copiedButtonText={copiedButtonText}\n />\n ),\n };\n\n const { displayContent, isComplete } = useTypewriterStateMachine({\n // processMarkdownText will let code block printf(\"You win!\\n\") become printf(\"You win!<br/>\");\n // content: processMarkdownText(content),\n content: normalizedContent,\n typingSpeed,\n disabled: !enableTypewriter,\n });\n\n const renderSegments = useMemo(\n () => splitContentSegments(content, true),\n [content]\n );\n\n const hasSandbox = renderSegments.some(\n (segment) => segment.type === \"sandbox\"\n );\n const mergedRenderSegments = useMemo(\n () => mergeNonSandboxSegments(renderSegments),\n [renderSegments]\n );\n\n const segments = useMemo(\n () => parseMarkdownSegments(displayContent),\n [displayContent]\n );\n\n const hasCompleted = useRef(false);\n\n useEffect(() => {\n if (hasSandbox) return;\n if (isComplete && !hasCompleted.current) {\n hasCompleted.current = true; // Mark as completed\n onTypeFinished?.(); // Call the passed callback\n }\n }, [hasSandbox, isComplete, onTypeFinished]);\n\n useEffect(() => {\n if (hasSandbox) return;\n hasCompleted.current = false; // Reset completion status when content changes\n }, [hasSandbox, content]);\n\n if (hasSandbox) {\n return (\n <div className=\"content-render markdown-body\">\n {mergedRenderSegments.map((segment, idx) =>\n segment.type === \"sandbox\" ? (\n <IframeSandbox\n key={`sandbox-${idx}`}\n hideFullScreen\n content={segment.value}\n className=\"content-render-iframe\"\n loadingText={sandboxLoadingText}\n styleLoadingText={sandboxStyleLoadingText}\n scriptLoadingText={sandboxScriptLoadingText}\n fullScreenButtonText={sandboxFullscreenButtonText}\n mode={sandboxMode}\n />\n ) : (\n <MarkdownRenderer\n key={`md-${idx}`}\n components={components}\n content={normalizeInlineHtml(segment.value)}\n />\n )\n )}\n </div>\n );\n }\n\n return (\n <div className=\"content-render markdown-body\">\n {segments.map((seg, index) => {\n if (seg.type === \"text\") {\n return (\n <MarkdownRenderer\n key={index}\n components={components}\n content={seg.value}\n />\n );\n }\n\n if (seg.type === \"mermaid\") {\n return (\n <MermaidChart\n key={index}\n chart={seg.value}\n frozen={!seg.complete}\n />\n );\n }\n\n if (seg.type === \"svg\") {\n return <SvgBlockInShadow key={index} svg={seg.value} />;\n }\n })}\n\n {customRenderBar && (\n <div className=\"content-render-custom-bar\">\n {React.createElement(customRenderBar, {\n content,\n displayContent,\n onSend,\n })}\n </div>\n )}\n </div>\n );\n};\n\nexport default ContentRender;\n"],"names":["SvgBlockInShadow","svg","hostRef","useRef","useEffect","host","shadowRoot","styleId","styleEl","node","template","hasResponsiveSvg","hasFixedSvg","svgEl","viewBox","dimensions","value","viewBoxWidth","viewBoxHeight","widthAttr","heightAttr","isRelativeLength","normalized","toNumericLength","parsed","isWidthRelative","isHeightRelative","widthMissing","heightMissing","numericWidth","numericHeight","hostResponsive","jsx","remarkPlugins","remarkGfm","remarkMath","remarkFlow","remarkBreaks","rehypePlugins","preserveCustomVariableProperties","rehypeRaw","sanitizeInvalidTagName","restoreCustomVariableProperties","rehypeHighlight","highlightLanguages","subsetLanguages","rehypeKatex","MarkdownRenderer","markdownContent","components","ReactMarkdown","mergeNonSandboxSegments","segments","merged","segment","last","ContentRender","content","customRenderBar","onSend","typingSpeed","enableTypewriter","defaultButtonText","defaultInputText","defaultSelectedValues","readonly","onTypeFinished","confirmButtonText","copyButtonText","copiedButtonText","sandboxLoadingText","sandboxStyleLoadingText","sandboxScriptLoadingText","sandboxFullscreenButtonText","sandboxMode","onClickCustomButtonAfterContent","beforeSend","normalizedContent","useMemo","normalizeInlineHtml","children","props","CustomButtonInputVariable","className","rest","chartContent","frozen","mermaidBlockIsComplete","MermaidChart","CodeBlock","displayContent","isComplete","useTypewriterStateMachine","renderSegments","splitContentSegments","hasSandbox","mergedRenderSegments","parseMarkdownSegments","hasCompleted","idx","IframeSandbox","jsxs","seg","index","React"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAuFA,MAAMA,KAA8C,CAAC,EAAE,KAAAC,QAAU;AAC/D,QAAMC,IAAUC,EAAuB,IAAI;AAE3C,SAAAC,EAAU,MAAM;AACd,UAAMC,IAAOH,EAAQ;AACrB,QAAI,CAACG,EAAM;AACX,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B;AAAA,IAAA,CACD,EAAA,CACH;AAAA,EAAA,GAEJ;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"ContentRender.es.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 key={key} chart={seg.value} frozen={!seg.complete} />\n );\n }\n\n if (seg.type === \"svg\") {\n return <SvgBlockInShadow key={key} svg={seg.value} />;\n }\n\n return null;\n });\n };\n\n if (hasSandbox) {\n return (\n <div className=\"content-render markdown-body\">\n {mergedRenderSegments.map((segment, idx) =>\n segment.type === \"sandbox\" ? (\n <IframeSandbox\n key={`sandbox-${idx}`}\n hideFullScreen\n content={segment.value}\n className=\"content-render-iframe\"\n loadingText={sandboxLoadingText}\n styleLoadingText={sandboxStyleLoadingText}\n scriptLoadingText={sandboxScriptLoadingText}\n fullScreenButtonText={sandboxFullscreenButtonText}\n mode={sandboxMode}\n />\n ) : (\n <React.Fragment key={`md-${idx}`}>\n {renderMarkdownSegments(segment.value, `md-${idx}`)}\n </React.Fragment>\n )\n )}\n </div>\n );\n }\n\n return (\n <div className=\"content-render markdown-body\">\n {segments.map((seg, index) => {\n if (seg.type === \"text\") {\n return (\n <MarkdownRenderer\n key={index}\n components={components}\n content={seg.value}\n />\n );\n }\n\n if (seg.type === \"mermaid\") {\n return (\n <MermaidChart\n key={index}\n chart={seg.value}\n frozen={!seg.complete}\n />\n );\n }\n\n if (seg.type === \"svg\") {\n return <SvgBlockInShadow key={index} svg={seg.value} />;\n }\n })}\n\n {customRenderBar && (\n <div className=\"content-render-custom-bar\">\n {React.createElement(customRenderBar, {\n content,\n displayContent,\n onSend,\n })}\n </div>\n )}\n </div>\n );\n};\n\nexport default ContentRender;\n"],"names":["SvgBlockInShadow","svg","hostRef","useRef","useEffect","host","shadowRoot","styleId","styleEl","node","template","cleanedSvg","stripSvgTextLineBreaks","hasResponsiveSvg","hasFixedSvg","svgEl","viewBox","dimensions","value","viewBoxWidth","viewBoxHeight","widthAttr","heightAttr","isRelativeLength","normalized","toNumericLength","parsed","isWidthRelative","isHeightRelative","widthMissing","heightMissing","numericWidth","numericHeight","hostResponsive","jsx","remarkPlugins","remarkGfm","remarkMath","remarkFlow","remarkBreaks","rehypePlugins","preserveCustomVariableProperties","rehypeRaw","sanitizeInvalidTagName","restoreCustomVariableProperties","rehypeHighlight","highlightLanguages","subsetLanguages","rehypeKatex","MarkdownRenderer","markdownContent","components","ReactMarkdown","mergeNonSandboxSegments","segments","merged","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":";;;;;;;;;;;;;;;;;;;;;;;;;;AAwFA,MAAMA,IAA8C,CAAC,EAAE,KAAAC,QAAU;AAC/D,QAAMC,IAAUC,EAAuB,IAAI;AAE3C,SAAAC,EAAU,MAAM;AACd,UAAMC,IAAOH,E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EAAI,WAAU,gCACZ,UAAA;AAAA,IAAAxD,EAAS,IAAI,CAACkD,GAAKC,MAAU;AAC5B,UAAID,EAAI,SAAS;AACf,eACEtE,gBAAAA,EAAAA;AAAAA,UAACe;AAAA,UAAA;AAAA,YAEC,YAAAE;AAAA,YACA,SAASqD,EAAI;AAAA,UAAA;AAAA,UAFRC;AAAA,QAAA;AAOX,UAAID,EAAI,SAAS;AACf,eACEtE,gBAAAA,EAAAA;AAAAA,UAACwD;AAAA,UAAA;AAAA,YAEC,OAAOc,EAAI;AAAA,YACX,QAAQ,CAACA,EAAI;AAAA,UAAA;AAAA,UAFRC;AAAA,QAAA;AAOX,UAAID,EAAI,SAAS;AACf,eAAOtE,gBAAAA,EAAAA,IAAClC,GAAA,EAA6B,KAAKwG,EAAI,SAAhBC,CAAuB;AAAA,IAEzD,CAAC;AAAA,IAEA7C,KACC1B,gBAAAA,EAAAA,IAAC,OAAA,EAAI,WAAU,6BACZ,UAAA2E,EAAM,cAAcjD,GAAiB;AAAA,MACpC,SAAAD;AAAA,MACA,gBAAAiC;AAAA,MACA,QAAA/B;AAAA,IAAA,CACD,EAAA,CACH;AAAA,EAAA,GAEJ;AAEJ;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const h=require("../../_virtual/jsx-runtime.cjs.js"),n=require("react"),$=require("react-dom/client"),B=require("./SandboxApp.cjs.js"),P=require("./utils/split-content.cjs.js"),_=require("./ContentRender.cjs.js"),L=({content:f,type:S,className:Y,loadingText:C,styleLoadingText:H,scriptLoadingText:j,fullScreenButtonText:p,hideFullScreen:M=!1,mode:c="content"})=>{const q=n.useRef(null),l=n.useRef(null),x=n.useRef(null),k=n.useRef(null),R=n.useRef(()=>{}),[z,A]=n.useState(480),[F,O]=n.useState(0),[D,I]=n.useState(!1),v=n.useRef(""),u=n.useMemo(()=>{const t=P.splitContentSegments(f).filter(o=>o.type==="sandbox");return(c==="blackboard"?t[t.length-1]?.value||"":t.map(o=>o.value).join(`
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const h=require("../../_virtual/jsx-runtime.cjs.js"),n=require("react"),$=require("react-dom/client"),B=require("./SandboxApp.cjs.js"),P=require("./utils/split-content.cjs.js"),_=require("./ContentRender.cjs.js"),L=({content:f,type:S,className:Y,loadingText:C,styleLoadingText:H,scriptLoadingText:j,fullScreenButtonText:p,hideFullScreen:M=!1,mode:c="content"})=>{const q=n.useRef(null),l=n.useRef(null),x=n.useRef(null),k=n.useRef(null),R=n.useRef(()=>{}),[z,A]=n.useState(480),[F,O]=n.useState(0),[D,I]=n.useState(!1),v=n.useRef(""),u=n.useMemo(()=>{const t=P.splitContentSegments(f,!0).filter(o=>o.type==="sandbox");return(c==="blackboard"?t[t.length-1]?.value||"":t.map(o=>o.value).join(`
|
|
2
2
|
`))||""},[f,c]),N=n.useMemo(()=>{const e=u.trim();if(!e)return!1;const t=e.match(/^<([a-zA-Z][\w:-]*)(\s[^>]*?)?>/);if(!t)return!1;const r=t[2]||"",o=r.match(/\bheight\s*=\s*["']([^"']+)["']/i);if(o&&/vh$/i.test(o[1].trim()))return!0;const d=r.match(/\bstyle\s*=\s*["']([^"']+)["']/i);return d?/height\s*:\s*[^;]*vh\b/i.test(d[1]):!1},[u]);n.useEffect(()=>{if(c!=="blackboard"){v.current=u;return}const e=v.current;!(e&&u.startsWith(e))&&e&&O(r=>r+1),v.current=u},[u,c]),n.useEffect(()=>{const e=l.current;if(!e)return;const t=e.contentDocument;if(!t)return;t.open(),t.write(`<!DOCTYPE html>
|
|
3
3
|
<html>
|
|
4
4
|
<head>
|