markdown-flow-ui 0.1.82 → 0.1.83-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/@braintree_sanitize-url@7.1.1/node_modules/@braintree/sanitize-url/dist/index.js +1 -1
- 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/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/c4Diagram-YG6GDRKO.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.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.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.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.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.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.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.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.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.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/remark-flow@0.1.6/node_modules/remark-flow/dist/remark-custom-variable.js +1 -1
- package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/remark-flow@0.1.6/node_modules/remark-flow/dist/remark-interaction.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/_virtual/index10.js +2 -2
- package/dist/_virtual/index2.js +5 -2
- package/dist/_virtual/index2.js.map +1 -1
- package/dist/_virtual/index3.js +2 -4
- package/dist/_virtual/index3.js.map +1 -1
- package/dist/_virtual/index4.js +4 -5
- package/dist/_virtual/index4.js.map +1 -1
- package/dist/_virtual/index7.js +2 -3
- package/dist/_virtual/index7.js.map +1 -1
- package/dist/_virtual/index8.js +3 -2
- package/dist/_virtual/index8.js.map +1 -1
- package/dist/assets/markdown-flow-ui.css +1 -1
- package/dist/components/ContentRender/ContentRender.d.ts +15 -0
- package/dist/components/ContentRender/ContentRender.js +147 -109
- package/dist/components/ContentRender/ContentRender.js.map +1 -1
- package/dist/components/ContentRender/ContentRender.stories.d.ts +2 -0
- package/dist/components/ContentRender/IframeSandbox.d.ts +13 -0
- package/dist/components/ContentRender/IframeSandbox.js +157 -0
- package/dist/components/ContentRender/IframeSandbox.js.map +1 -0
- package/dist/components/ContentRender/SandboxApp.d.ts +11 -0
- package/dist/components/ContentRender/SandboxApp.js +199 -0
- package/dist/components/ContentRender/SandboxApp.js.map +1 -0
- package/dist/components/ContentRender/index.d.ts +5 -0
- package/dist/components/ContentRender/index.js +2 -1
- package/dist/components/ContentRender/index.js.map +1 -1
- package/dist/components/ContentRender/utils/split-content.d.ts +8 -0
- package/dist/components/ContentRender/utils/split-content.js +35 -0
- package/dist/components/ContentRender/utils/split-content.js.map +1 -0
- package/dist/components/ContentRender/utils/split-content.test.d.ts +1 -0
- package/dist/components/MarkdownFlow/MarkdownFlow.js +4 -3
- package/dist/components/MarkdownFlow/MarkdownFlow.js.map +1 -1
- package/dist/components/ui/inputGroup/textarea.js +1 -1
- package/dist/index.js +12 -8
- package/dist/index.js.map +1 -1
- package/dist/markdown-flow-ui-lib.css +1 -1
- package/dist/renderer.d.ts +6 -2
- package/dist/renderer.js +11 -6
- package/dist/renderer.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { CustomRenderBarProps, OnSendContentParams } from '../types';
|
|
3
|
+
import { ComponentsWithCustomVariable } from './plugins/CustomVariable';
|
|
3
4
|
export interface ContentRenderProps {
|
|
4
5
|
content: string;
|
|
5
6
|
/**
|
|
@@ -27,7 +28,21 @@ export interface ContentRenderProps {
|
|
|
27
28
|
copyButtonText?: string;
|
|
28
29
|
copiedButtonText?: string;
|
|
29
30
|
dynamicInteractionFormat?: string;
|
|
31
|
+
sandboxLoadingText?: string;
|
|
32
|
+
sandboxStyleLoadingText?: string;
|
|
33
|
+
sandboxScriptLoadingText?: string;
|
|
34
|
+
sandboxFullscreenButtonText?: string;
|
|
35
|
+
sandboxMode?: "content" | "blackboard";
|
|
30
36
|
beforeSend?: (param: OnSendContentParams) => boolean;
|
|
31
37
|
}
|
|
38
|
+
type CustomComponents = ComponentsWithCustomVariable & {
|
|
39
|
+
"custom-button-after-content"?: React.ComponentType<{
|
|
40
|
+
children: React.ReactNode;
|
|
41
|
+
}>;
|
|
42
|
+
};
|
|
43
|
+
export declare const MarkdownRenderer: React.FC<{
|
|
44
|
+
content: string;
|
|
45
|
+
components: CustomComponents;
|
|
46
|
+
}>;
|
|
32
47
|
declare const ContentRender: React.FC<ContentRenderProps>;
|
|
33
48
|
export default ContentRender;
|
|
@@ -1,123 +1,138 @@
|
|
|
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 W, { useMemo as S, useRef as V, useEffect as L } from "react";
|
|
5
|
+
import q 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 { subsetLanguages as
|
|
14
|
-
import { parseMarkdownSegments as
|
|
15
|
-
import { normalizeInlineHtml as
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
import
|
|
22
|
-
import
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
8
|
+
import F from "./CodeBlock.js";
|
|
9
|
+
import G from "./plugins/CustomVariable.js";
|
|
10
|
+
import z from "./plugins/MermaidChart.js";
|
|
11
|
+
import K from "./useTypewriterStateMachine.js";
|
|
12
|
+
import { preserveCustomVariableProperties as D, restoreCustomVariableProperties as J } from "./utils/custom-variable-props.js";
|
|
13
|
+
import { subsetLanguages as O, highlightLanguages as Q } from "./utils/highlight-languages.js";
|
|
14
|
+
import { parseMarkdownSegments as X, mermaidBlockIsComplete as Y } from "./utils/mermaid-parse.js";
|
|
15
|
+
import { normalizeInlineHtml as H } from "./utils/normalize-inline-html.js";
|
|
16
|
+
import Z from "./IframeSandbox.js";
|
|
17
|
+
import { splitContentSegments as E } from "./utils/split-content.js";
|
|
18
|
+
import { Markdown as ee } 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";
|
|
19
|
+
import te from "../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rehype-raw@7.0.0/node_modules/rehype-raw/lib/index.js";
|
|
20
|
+
import re from "../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rehype-highlight@7.0.2/node_modules/rehype-highlight/lib/index.js";
|
|
21
|
+
import ne from "../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rehype-katex@7.0.1/node_modules/rehype-katex/lib/index.js";
|
|
22
|
+
import se from "../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/remark-gfm@4.0.1/node_modules/remark-gfm/lib/index.js";
|
|
23
|
+
import oe from "../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/remark-math@6.0.0/node_modules/remark-math/lib/index.js";
|
|
24
|
+
import ae from "../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/remark-breaks@4.0.0/node_modules/remark-breaks/lib/index.js";
|
|
25
|
+
const ie = ({ svg: s }) => {
|
|
26
|
+
const c = V(null);
|
|
27
|
+
return L(() => {
|
|
28
|
+
const o = c.current;
|
|
27
29
|
if (!o) return;
|
|
28
|
-
const a = o.shadowRoot ?? o.attachShadow({ mode: "open" }),
|
|
29
|
-
let i = a.getElementById(
|
|
30
|
-
i || (i = document.createElement("style"), i.id =
|
|
30
|
+
const a = o.shadowRoot ?? o.attachShadow({ mode: "open" }), f = "content-render-svg-style";
|
|
31
|
+
let i = a.getElementById(f);
|
|
32
|
+
i || (i = document.createElement("style"), i.id = f, i.textContent = `
|
|
31
33
|
svg { height: auto; display: inline-block; }
|
|
32
34
|
svg.content-render-svg-el--responsive { width: 100%; max-width: 100%; }
|
|
33
35
|
svg.content-render-svg-el--fixed { max-width: none; }
|
|
34
36
|
`, a.appendChild(i)), Array.from(a.childNodes).filter(
|
|
35
37
|
(r) => r !== i
|
|
36
38
|
).forEach((r) => a.removeChild(r));
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
let
|
|
39
|
+
const x = document.createElement("template");
|
|
40
|
+
x.innerHTML = s, a.append(x.content.cloneNode(!0));
|
|
41
|
+
let g = !1, d = !1;
|
|
40
42
|
a.querySelectorAll("svg").forEach((r) => {
|
|
41
|
-
const
|
|
42
|
-
if (!
|
|
43
|
-
const
|
|
44
|
-
if (
|
|
45
|
-
const [, ,
|
|
46
|
-
if (!N && !
|
|
47
|
-
|
|
43
|
+
const b = r.getAttribute("viewBox");
|
|
44
|
+
if (!b) return;
|
|
45
|
+
const u = b.trim().split(/[\s,]+/).map((w) => Number(w));
|
|
46
|
+
if (u.length !== 4 || u.some(Number.isNaN)) return;
|
|
47
|
+
const [, , h, l] = u, j = r.getAttribute("width"), y = r.getAttribute("height"), N = !!j && j !== "0", k = !!y && y !== "0";
|
|
48
|
+
if (!N && !k) {
|
|
49
|
+
g = !0, r.classList.add("content-render-svg-el--responsive"), r.classList.remove("content-render-svg-el--fixed"), r.style.width = "100%", r.style.height = "auto", !r.style.aspectRatio && l > 0 && (r.style.aspectRatio = `${h} / ${l}`);
|
|
48
50
|
return;
|
|
49
51
|
}
|
|
50
|
-
|
|
52
|
+
d = !0, r.classList.add("content-render-svg-el--fixed"), r.classList.remove("content-render-svg-el--responsive"), !N && h > 0 && r.setAttribute("width", `${h}`), !k && l > 0 && r.setAttribute("height", `${l}`);
|
|
51
53
|
});
|
|
52
|
-
const
|
|
53
|
-
o.classList.toggle("content-render-svg--responsive",
|
|
54
|
-
}, [
|
|
55
|
-
},
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
const v = g && !d;
|
|
55
|
+
o.classList.toggle("content-render-svg--responsive", v), o.classList.toggle("content-render-svg--fixed", !v);
|
|
56
|
+
}, [s]), /* @__PURE__ */ t.jsx("div", { className: "content-render-svg-scroll", children: /* @__PURE__ */ t.jsx("div", { className: "content-render-svg", ref: c }) });
|
|
57
|
+
}, ce = [se, oe, q, ae], me = [
|
|
58
|
+
D,
|
|
59
|
+
te,
|
|
60
|
+
J,
|
|
61
|
+
[re, { languages: Q, subset: O }],
|
|
62
|
+
ne
|
|
63
|
+
], P = ({ content: s, components: c }) => /* @__PURE__ */ t.jsx("div", { className: "markdown-renderer", children: /* @__PURE__ */ t.jsx(
|
|
64
|
+
ee,
|
|
65
|
+
{
|
|
66
|
+
remarkPlugins: ce,
|
|
67
|
+
rehypePlugins: me,
|
|
68
|
+
components: c,
|
|
69
|
+
children: s
|
|
70
|
+
}
|
|
71
|
+
) }), He = ({
|
|
72
|
+
content: s,
|
|
73
|
+
customRenderBar: c,
|
|
58
74
|
onSend: o,
|
|
59
75
|
typingSpeed: a = 30,
|
|
60
|
-
enableTypewriter:
|
|
76
|
+
enableTypewriter: f = !1,
|
|
61
77
|
defaultButtonText: i,
|
|
62
|
-
defaultInputText:
|
|
63
|
-
defaultSelectedValues:
|
|
64
|
-
readonly:
|
|
65
|
-
onTypeFinished:
|
|
66
|
-
confirmButtonText:
|
|
78
|
+
defaultInputText: A,
|
|
79
|
+
defaultSelectedValues: x,
|
|
80
|
+
readonly: g = !1,
|
|
81
|
+
onTypeFinished: d,
|
|
82
|
+
confirmButtonText: v,
|
|
67
83
|
copyButtonText: r,
|
|
68
|
-
copiedButtonText:
|
|
69
|
-
|
|
70
|
-
|
|
84
|
+
copiedButtonText: b,
|
|
85
|
+
sandboxLoadingText: u,
|
|
86
|
+
sandboxStyleLoadingText: h,
|
|
87
|
+
sandboxScriptLoadingText: l,
|
|
88
|
+
sandboxFullscreenButtonText: j,
|
|
89
|
+
sandboxMode: y = "content",
|
|
90
|
+
onClickCustomButtonAfterContent: N,
|
|
91
|
+
beforeSend: k
|
|
71
92
|
// tooltipMinLength,
|
|
72
93
|
}) => {
|
|
73
|
-
const
|
|
74
|
-
() =>
|
|
75
|
-
[
|
|
76
|
-
),
|
|
77
|
-
// processMarkdownText will let code block printf("You win!\n") become printf("You win!<br/>");
|
|
78
|
-
// content: processMarkdownText(content),
|
|
79
|
-
content: l,
|
|
80
|
-
typingSpeed: a,
|
|
81
|
-
disabled: !g
|
|
82
|
-
}), N = {
|
|
94
|
+
const B = S(
|
|
95
|
+
() => H(s),
|
|
96
|
+
[s]
|
|
97
|
+
), w = {
|
|
83
98
|
"custom-button-after-content": ({
|
|
84
99
|
children: e
|
|
85
100
|
}) => /* @__PURE__ */ t.jsx(
|
|
86
101
|
"button",
|
|
87
102
|
{
|
|
88
103
|
className: "content-render-custom-button-after-content",
|
|
89
|
-
onClick:
|
|
104
|
+
onClick: N,
|
|
90
105
|
children: /* @__PURE__ */ t.jsx("span", { className: "content-render-custom-button-after-content-inner", children: e })
|
|
91
106
|
}
|
|
92
107
|
),
|
|
93
108
|
"custom-variable": (e) => /* @__PURE__ */ t.jsx(
|
|
94
|
-
|
|
109
|
+
G,
|
|
95
110
|
{
|
|
96
111
|
...e,
|
|
97
|
-
readonly:
|
|
112
|
+
readonly: g,
|
|
98
113
|
defaultButtonText: i,
|
|
99
|
-
defaultInputText:
|
|
100
|
-
defaultSelectedValues:
|
|
114
|
+
defaultInputText: A,
|
|
115
|
+
defaultSelectedValues: x,
|
|
101
116
|
onSend: o,
|
|
102
|
-
beforeSend:
|
|
103
|
-
confirmButtonText:
|
|
117
|
+
beforeSend: k,
|
|
118
|
+
confirmButtonText: v
|
|
104
119
|
}
|
|
105
120
|
),
|
|
106
121
|
code: (e) => {
|
|
107
|
-
const { className:
|
|
108
|
-
if (/language-(\w+)/.exec(
|
|
109
|
-
const
|
|
110
|
-
return /* @__PURE__ */ t.jsx(
|
|
122
|
+
const { className: n, children: m, ...M } = e;
|
|
123
|
+
if (/language-(\w+)/.exec(n || "")?.[1] === "mermaid") {
|
|
124
|
+
const $ = m?.toString().replace(/\n$/, "") || "", U = Y(s, $);
|
|
125
|
+
return /* @__PURE__ */ t.jsx(z, { chart: $, frozen: U });
|
|
111
126
|
}
|
|
112
|
-
return /* @__PURE__ */ t.jsx("code", { className:
|
|
127
|
+
return /* @__PURE__ */ t.jsx("code", { className: n, ...M, children: m });
|
|
113
128
|
},
|
|
114
129
|
table: ({ ...e }) => /* @__PURE__ */ t.jsx("div", { className: "content-render-table-container", children: /* @__PURE__ */ t.jsx("table", { className: "content-render-table", ...e }) }),
|
|
115
130
|
th: ({ ...e }) => /* @__PURE__ */ t.jsx("th", { className: "content-render-th", ...e }),
|
|
116
131
|
td: ({ ...e }) => /* @__PURE__ */ t.jsx("td", { className: "content-render-td", ...e }),
|
|
117
132
|
tr: ({ ...e }) => /* @__PURE__ */ t.jsx("tr", { className: "content-render-tr", ...e }),
|
|
118
|
-
li: ({ node: e, ...
|
|
119
|
-
const
|
|
120
|
-
return typeof
|
|
133
|
+
li: ({ node: e, ...n }) => {
|
|
134
|
+
const m = e?.properties?.className;
|
|
135
|
+
return typeof m == "string" && m.includes("task-list-item") || Array.isArray(m) && m.includes("task-list-item") ? /* @__PURE__ */ t.jsx("li", { className: "content-render-task-list-item", ...n }) : /* @__PURE__ */ t.jsx("li", { ...n });
|
|
121
136
|
},
|
|
122
137
|
ol: ({ ...e }) => /* @__PURE__ */ t.jsx("ol", { className: "content-render-ol", ...e }),
|
|
123
138
|
ul: ({ ...e }) => /* @__PURE__ */ t.jsx("ul", { className: "content-render-ul", ...e }),
|
|
@@ -130,64 +145,87 @@ const Y = ({ svg: n }) => {
|
|
|
130
145
|
...e
|
|
131
146
|
}
|
|
132
147
|
) : /* @__PURE__ */ t.jsx("input", { ...e }),
|
|
133
|
-
a: ({ children: e, ...
|
|
148
|
+
a: ({ children: e, ...n }) => /* @__PURE__ */ t.jsx("a", { target: "_blank", rel: "noopener noreferrer", ...n, children: e }),
|
|
134
149
|
pre: (e) => /* @__PURE__ */ t.jsx(
|
|
135
|
-
|
|
150
|
+
F,
|
|
136
151
|
{
|
|
137
152
|
...e,
|
|
138
153
|
copyButtonText: r,
|
|
139
|
-
copiedButtonText:
|
|
154
|
+
copiedButtonText: b
|
|
140
155
|
}
|
|
141
156
|
)
|
|
142
|
-
},
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
157
|
+
}, { displayContent: C, isComplete: I } = K({
|
|
158
|
+
// processMarkdownText will let code block printf("You win!\n") become printf("You win!<br/>");
|
|
159
|
+
// content: processMarkdownText(content),
|
|
160
|
+
content: B,
|
|
161
|
+
typingSpeed: a,
|
|
162
|
+
disabled: !f
|
|
163
|
+
}), T = S(
|
|
164
|
+
() => E(s),
|
|
165
|
+
[s]
|
|
166
|
+
), p = T.some(
|
|
167
|
+
(e) => e.type === "sandbox"
|
|
168
|
+
), _ = S(
|
|
169
|
+
() => X(C),
|
|
170
|
+
[C]
|
|
171
|
+
), R = V(!1);
|
|
172
|
+
return L(() => {
|
|
173
|
+
p || I && !R.current && (R.current = !0, d?.());
|
|
174
|
+
}, [p, I, d]), L(() => {
|
|
175
|
+
p || (R.current = !1);
|
|
176
|
+
}, [p, s]), p ? /* @__PURE__ */ t.jsx("div", { className: "content-render markdown-body", children: T.map(
|
|
177
|
+
(e, n) => e.type === "sandbox" ? /* @__PURE__ */ t.jsx(
|
|
178
|
+
Z,
|
|
179
|
+
{
|
|
180
|
+
content: e.value,
|
|
181
|
+
className: "content-render-iframe",
|
|
182
|
+
loadingText: u,
|
|
183
|
+
styleLoadingText: h,
|
|
184
|
+
scriptLoadingText: l,
|
|
185
|
+
fullScreenButtonText: j,
|
|
186
|
+
mode: y
|
|
187
|
+
},
|
|
188
|
+
`sandbox-${n}`
|
|
189
|
+
) : /* @__PURE__ */ t.jsx(
|
|
190
|
+
P,
|
|
191
|
+
{
|
|
192
|
+
components: w,
|
|
193
|
+
content: H(e.value)
|
|
194
|
+
},
|
|
195
|
+
`md-${n}`
|
|
196
|
+
)
|
|
197
|
+
) }) : /* @__PURE__ */ t.jsxs("div", { className: "content-render markdown-body", children: [
|
|
198
|
+
_.map((e, n) => {
|
|
151
199
|
if (e.type === "text")
|
|
152
200
|
return /* @__PURE__ */ t.jsx(
|
|
153
|
-
|
|
201
|
+
P,
|
|
154
202
|
{
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
P,
|
|
158
|
-
K,
|
|
159
|
-
V,
|
|
160
|
-
[
|
|
161
|
-
D,
|
|
162
|
-
{ languages: U, subset: _ }
|
|
163
|
-
],
|
|
164
|
-
J
|
|
165
|
-
],
|
|
166
|
-
components: N,
|
|
167
|
-
children: e.value
|
|
203
|
+
components: w,
|
|
204
|
+
content: e.value
|
|
168
205
|
},
|
|
169
|
-
|
|
206
|
+
n
|
|
170
207
|
);
|
|
171
208
|
if (e.type === "mermaid")
|
|
172
209
|
return /* @__PURE__ */ t.jsx(
|
|
173
|
-
|
|
210
|
+
z,
|
|
174
211
|
{
|
|
175
212
|
chart: e.value,
|
|
176
213
|
frozen: !e.complete
|
|
177
214
|
},
|
|
178
|
-
|
|
215
|
+
n
|
|
179
216
|
);
|
|
180
217
|
if (e.type === "svg")
|
|
181
|
-
return /* @__PURE__ */ t.jsx(
|
|
218
|
+
return /* @__PURE__ */ t.jsx(ie, { svg: e.value }, n);
|
|
182
219
|
}),
|
|
183
|
-
|
|
184
|
-
content:
|
|
185
|
-
displayContent:
|
|
220
|
+
c && /* @__PURE__ */ t.jsx("div", { className: "content-render-custom-bar", children: W.createElement(c, {
|
|
221
|
+
content: s,
|
|
222
|
+
displayContent: C,
|
|
186
223
|
onSend: o
|
|
187
224
|
}) })
|
|
188
225
|
] });
|
|
189
226
|
};
|
|
190
227
|
export {
|
|
191
|
-
|
|
228
|
+
P as MarkdownRenderer,
|
|
229
|
+
He as default
|
|
192
230
|
};
|
|
193
231
|
//# 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\";\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 // 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 hasWidth = !!widthAttr && widthAttr !== \"0\";\n const hasHeight = !!heightAttr && heightAttr !== \"0\";\n const shouldUseResponsiveSize = !hasWidth && !hasHeight;\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 (!hasWidth && viewBoxWidth > 0) {\n svgEl.setAttribute(\"width\", `${viewBoxWidth}`);\n }\n if (!hasHeight && 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 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 { 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 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 hasCompleted = useRef(false);\n\n useEffect(() => {\n if (isComplete && !hasCompleted.current) {\n hasCompleted.current = true; // Mark as completed\n onTypeFinished?.(); // Call the passed callback\n }\n }, [isComplete, onTypeFinished]);\n useEffect(() => {\n hasCompleted.current = false; // Reset completion status when content changes\n }, [content]);\n\n const segments = parseMarkdownSegments(displayContent);\n\n return (\n <div className={`content-render markdown-body`}>\n {segments.map((seg, index) => {\n if (seg.type === \"text\") {\n return (\n <ReactMarkdown\n key={index}\n remarkPlugins={[remarkGfm, remarkMath, remarkFlow, remarkBreaks]}\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 );\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","hasWidth","hasHeight","hostResponsive","jsx","ContentRender","content","customRenderBar","onSend","typingSpeed","enableTypewriter","defaultButtonText","defaultInputText","defaultSelectedValues","readonly","onTypeFinished","confirmButtonText","copyButtonText","copiedButtonText","onClickCustomButtonAfterContent","beforeSend","normalizedContent","useMemo","normalizeInlineHtml","displayContent","isComplete","useTypewriterStateMachine","components","children","props","CustomButtonInputVariable","className","rest","chartContent","frozen","mermaidBlockIsComplete","MermaidChart","CodeBlock","hasCompleted","segments","parseMarkdownSegments","jsxs","seg","index","ReactMarkdown","remarkGfm","remarkMath","remarkFlow","remarkBreaks","preserveCustomVariableProperties","rehypeRaw","restoreCustomVariableProperties","rehypeHighlight","highlightLanguages","subsetLanguages","rehypeKatex","React"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAuEA,MAAMA,IAA8C,CAAC,EAAE,KAAAC,QAAU;AAC/D,QAAMC,IAAUC,EAAuB,IAAI;AAE3C,SAAAC,EAAU,MAAM;AACd,UAAMC,IAAOH,EAAQ;AACrB,QAAI,CAACG,EAAM;AACX,UAAMC,IAAaD,EAAK,cAAcA,EAAK,aAAa,EAAE,MAAM,QAAQ,GAClEE,IAAU;AAChB,QAAIC,IAAUF,EAAW,eAAeC,CAAO;AAE/C,IAAKC,MACHA,IAAU,SAAS,cAAc,OAAO,GACxCA,EAAQ,KAAKD,GAEbC,EAAQ,cAAc;AAAA;AAAA;AAAA;AAAA,SAKtBF,EAAW,YAAYE,CAAO,IAGV,MAAM,KAAKF,EAAW,UAAU,EAAE;AAAA,MACtD,CAACG,MAASA,MAASD;AAAA,IAAA,EAEP,QAAQ,CAACC,MAASH,EAAW,YAAYG,CAAI,CAAC;AAE5D,UAAMC,IAAW,SAAS,cAAc,UAAU;AAClD,IAAAA,EAAS,YAAYT,GACrBK,EAAW,OAAOI,EAAS,QAAQ,UAAU,EAAI,CAAC;AAElD,QAAIC,IAAmB,IACnBC,IAAc;AAElB,IAAAN,EAAW,iBAAiB,KAAK,EAAE,QAAQ,CAACO,MAAU;AAEpD,YAAMC,IAAUD,EAAM,aAAa,SAAS;AAC5C,UAAI,CAACC,EAAS;AAEd,YAAMC,IAAaD,EAChB,KAAA,EACA,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bC;AAAA,cACAC;AAAA,cACAC;AAAA,cACA;AAAA,gBACEC;AAAA,gBACA,EAAE,WAAWC,GAAoB,QAAQC,EAAA;AAAA,cAAgB;AAAA,cAE3DC;AAAA,YAAA;AAAA,YAEF,YAAA5B;AAAA,YAEC,UAAAe,EAAI;AAAA,UAAA;AAAA,UAdAC;AAAA,QAAA;AAmBX,UAAID,EAAI,SAAS;AACf,eACEtC,gBAAAA,EAAAA;AAAAA,UAACgC;AAAA,UAAA;AAAA,YAEC,OAAOM,EAAI;AAAA,YACX,QAAQ,CAACA,EAAI;AAAA,UAAA;AAAA,UAFRC;AAAA,QAAA;AAOX,UAAID,EAAI,SAAS;AACf,eAAOtC,gBAAAA,EAAAA,IAACxB,GAAA,EAA6B,KAAK8D,EAAI,SAAhBC,CAAuB;AAAA,IAEzD,CAAC;AAAA,IAEApC,KACCH,gBAAAA,EAAAA,IAAC,OAAA,EAAI,WAAU,6BACZ,UAAAoD,EAAM,cAAcjD,GAAiB;AAAA,MACpC,SAAAD;AAAA,MACA,gBAAAkB;AAAA,MACA,QAAAhB;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\";\nimport { splitContentSegments } 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 hasWidth = !!widthAttr && widthAttr !== \"0\";\n const hasHeight = !!heightAttr && heightAttr !== \"0\";\n const shouldUseResponsiveSize = !hasWidth && !hasHeight;\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 (!hasWidth && viewBoxWidth > 0) {\n svgEl.setAttribute(\"width\", `${viewBoxWidth}`);\n }\n if (!hasHeight && viewBoxHeight > 0) {\n svgEl.setAttribute(\"height\", `${viewBoxHeight}`);\n }\n });\n\n const hostResponsive = hasResponsiveSvg && !hasFixedSvg;\n host.classList.toggle(\"content-render-svg--responsive\", hostResponsive);\n host.classList.toggle(\"content-render-svg--fixed\", !hostResponsive);\n }, [svg]);\n\n return (\n <div className=\"content-render-svg-scroll\">\n <div className=\"content-render-svg\" ref={hostRef} />\n </div>\n );\n};\n\n// Extended component interface\ntype CustomComponents = ComponentsWithCustomVariable & {\n \"custom-button-after-content\"?: React.ComponentType<{\n children: React.ReactNode;\n }>;\n};\n\nconst remarkPlugins = [remarkGfm, remarkMath, remarkFlow, remarkBreaks];\n\nconst rehypePlugins = [\n preserveCustomVariableProperties,\n rehypeRaw,\n restoreCustomVariableProperties,\n [rehypeHighlight, { languages: highlightLanguages, subset: subsetLanguages }],\n rehypeKatex,\n];\n\nexport const MarkdownRenderer: React.FC<{\n content: string;\n components: CustomComponents;\n}> = ({ content: markdownContent, components }) => (\n <div className=\"markdown-renderer\">\n <ReactMarkdown\n remarkPlugins={remarkPlugins}\n rehypePlugins={rehypePlugins}\n components={components}\n >\n {markdownContent}\n </ReactMarkdown>\n </div>\n);\n\nconst 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),\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 markdown-body\">\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 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","hasWidth","hasHeight","hostResponsive","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","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","segment","segments","parseMarkdownSegments","hasCompleted","idx","IframeSandbox","jsxs","seg","index","React"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAmFA,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,UAAMC,IAAaD,EAAK,cAAcA,EAAK,aAAa,EAAE,MAAM,QAAQ,GAClEE,IAAU;AAChB,QAAIC,IAAUF,EAAW,eAAeC,CAAO;AAE/C,IAAKC,MACHA,IAAU,SAAS,cAAc,OAAO,GACxCA,EAAQ,KAAKD,GAEbC,EAAQ,cAAc;AAAA;AAAA;AAAA;AAAA,SAKtBF,EAAW,YAAYE,CAAO,IAGV,MAAM,KAAKF,EAAW,UAAU,EAAE;AAAA,MACtD,CAACG,MAASA,MAASD;AAAA,IAAA,EAEP,QAAQ,CAACC,MAASH,EAAW,YAAYG,CAAI,CAAC;AAE5D,UAAMC,IAAW,SAAS,cAAc,UAAU;AAClD,IAAAA,EAAS,YAAYT,GACrBK,EAAW,OAAOI,EAAS,QAAQ,UAAU,EAAI,CAAC;AAElD,QAAIC,IAAmB,IACnBC,IAAc;AAElB,IAAAN,EAAW,iBAAiB,KAAK,EAAE,QAAQ,CAACO,MAAU;AAEpD,YAAMC,IAAUD,EAAM,aAAa,SAAS;AAC5C,UAAI,CAACC,EAAS;AAEd,YAAMC,IAAaD,EAChB,KAAA,EACA,MAAM,QAAQ,EACd,IAAI,CAACE,MAAU,OAAOA,CAAK,CAAC;AAE/B,UAAID,EAAW,WAAW,KAAKA,EAAW,KAAK,OAAO,KAAK,EAAG;AAE9D,YAAM,CAAA,EAAA,EAAKE,GAAcC,CAAa,IAAIH,GACpCI,IAAYN,EAAM,aAAa,OAAO,GACtCO,IAAaP,EAAM,aAAa,QAAQ,GACxCQ,IAAW,CAAC,CAACF,KAAaA,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AI,SAAS;AACf,eAAOjE,gBAAAA,EAAAA,IAACxB,IAAA,EAA6B,KAAKyF,EAAI,SAAhBC,CAAuB;AAAA,IAEzD,CAAC;AAAA,IAEA9C,KACCpB,gBAAAA,EAAAA,IAAC,OAAA,EAAI,WAAU,6BACZ,UAAAmE,EAAM,cAAc/C,GAAiB;AAAA,MACpC,SAAAD;AAAA,MACA,gBAAAiC;AAAA,MACA,QAAA/B;AAAA,IAAA,CACD,EAAA,CACH;AAAA,EAAA,GAEJ;AAEJ;"}
|
|
@@ -33,3 +33,5 @@ export declare const NativeHtmlElements: Story;
|
|
|
33
33
|
export declare const CodeBlockShowcase: Story;
|
|
34
34
|
export declare const EnglishChineseTypographyPreview: Story;
|
|
35
35
|
export declare const SVGDemo: Story;
|
|
36
|
+
export declare const HTMLDemo: Story;
|
|
37
|
+
export declare const HTMLDemoIframeOnly: Story;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
export interface IframeSandboxProps {
|
|
3
|
+
content: string;
|
|
4
|
+
className?: string;
|
|
5
|
+
loadingText?: string;
|
|
6
|
+
styleLoadingText?: string;
|
|
7
|
+
scriptLoadingText?: string;
|
|
8
|
+
fullScreenButtonText?: string;
|
|
9
|
+
mode?: "content" | "blackboard";
|
|
10
|
+
type: "sandbox" | "markdown";
|
|
11
|
+
}
|
|
12
|
+
declare const IframeSandbox: React.FC<IframeSandboxProps>;
|
|
13
|
+
export default IframeSandbox;
|