markdown-flow-ui 0.2.29 → 0.2.30
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/README.md +5 -0
- package/dist/components/ContentRender/ContentRender.cjs +2 -2
- package/dist/components/ContentRender/ContentRender.cjs.map +1 -1
- package/dist/components/ContentRender/ContentRender.d.ts +2 -0
- package/dist/components/ContentRender/ContentRender.es.js +368 -358
- package/dist/components/ContentRender/ContentRender.es.js.map +1 -1
- package/dist/components/ContentRender/utils/html-block-end.cjs +2 -0
- package/dist/components/ContentRender/utils/html-block-end.cjs.map +1 -0
- package/dist/components/ContentRender/utils/html-block-end.d.ts +6 -0
- package/dist/components/ContentRender/utils/html-block-end.es.js +104 -0
- package/dist/components/ContentRender/utils/html-block-end.es.js.map +1 -0
- package/dist/components/ContentRender/utils/html-block-end.test.d.ts +1 -0
- package/dist/components/ContentRender/utils/split-content.cjs +3 -3
- package/dist/components/ContentRender/utils/split-content.cjs.map +1 -1
- package/dist/components/ContentRender/utils/split-content.d.ts +1 -1
- package/dist/components/ContentRender/utils/split-content.es.js +220 -129
- package/dist/components/ContentRender/utils/split-content.es.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,417 +1,438 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import { jsx as n, jsxs as je } from "react/jsx-runtime";
|
|
2
|
+
import U, { useMemo as B, useState as Ne, useRef as g, useEffect as P } from "react";
|
|
3
|
+
import Qe from "../../_virtual/index.es.js";
|
|
4
4
|
import { sanitizeInvalidTagName as Pe } from "./utils/sanitize-invalid-tag-name.es.js";
|
|
5
|
-
import { stripSvgTextLineBreaks as
|
|
5
|
+
import { stripSvgTextLineBreaks as Ue } from "./utils/strip-svg-text-line-breaks.es.js";
|
|
6
6
|
/* empty css */
|
|
7
7
|
/* empty css */
|
|
8
8
|
/* empty css */
|
|
9
9
|
/* empty css */
|
|
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 { getTrailingTypewriterGrapheme as
|
|
19
|
-
import { splitContentSegments as
|
|
20
|
-
import { getInteractionDefaultValues as
|
|
21
|
-
import { getMarkdownFlowDirection as
|
|
22
|
-
import { getContentRenderLocaleTexts as
|
|
23
|
-
import { Markdown as
|
|
24
|
-
import
|
|
25
|
-
import
|
|
26
|
-
import
|
|
27
|
-
import
|
|
28
|
-
import
|
|
29
|
-
import
|
|
30
|
-
const
|
|
31
|
-
const
|
|
10
|
+
import Ke, { CodeBlockContext as Oe } from "./CodeBlock.es.js";
|
|
11
|
+
import Ye from "./plugins/CustomVariable.es.js";
|
|
12
|
+
import le from "./plugins/MermaidChart.es.js";
|
|
13
|
+
import { preserveCustomVariableProperties as Xe, restoreCustomVariableProperties as Ze } from "./utils/custom-variable-props.es.js";
|
|
14
|
+
import { subsetLanguages as Je, highlightLanguages as et } from "./utils/highlight-languages.es.js";
|
|
15
|
+
import { parseMarkdownSegments as Le, mermaidBlockIsComplete as tt } from "./utils/mermaid-parse.es.js";
|
|
16
|
+
import { normalizeInlineHtml as Ae } from "./utils/normalize-inline-html.es.js";
|
|
17
|
+
import nt from "./IframeSandbox.es.js";
|
|
18
|
+
import { getTrailingTypewriterGrapheme as ue, appendContentAwareTypewriterQueue as Me, consumeContentAwareTypewriterQueue as rt, CONTENT_AWARE_TYPEWRITER_TICK_BUDGET as ot, isContentAwareTypewriterQueueEmpty as st } from "./utils/typewriter-pacing.es.js";
|
|
19
|
+
import { splitContentSegments as at } from "./utils/split-content.es.js";
|
|
20
|
+
import { getInteractionDefaultValues as it } from "../../lib/interaction-defaults.es.js";
|
|
21
|
+
import { getMarkdownFlowDirection as ct, getMarkdownFlowLanguage as ut } from "../../lib/locale.es.js";
|
|
22
|
+
import { getContentRenderLocaleTexts as De } from "./contentRenderI18n.es.js";
|
|
23
|
+
import { Markdown as lt } from "../../node_modules/react-markdown/lib/index.es.js";
|
|
24
|
+
import dt from "../../node_modules/rehype-raw/lib/index.es.js";
|
|
25
|
+
import mt from "../../node_modules/rehype-highlight/lib/index.es.js";
|
|
26
|
+
import pt from "../../node_modules/rehype-katex/lib/index.es.js";
|
|
27
|
+
import ht from "../../node_modules/remark-gfm/lib/index.es.js";
|
|
28
|
+
import ft from "../../node_modules/remark-math/lib/index.es.js";
|
|
29
|
+
import gt from "../../node_modules/remark-breaks/lib/index.es.js";
|
|
30
|
+
const vt = 2, $e = ({ svg: t }) => {
|
|
31
|
+
const r = g(null);
|
|
32
32
|
return P(() => {
|
|
33
|
-
const o =
|
|
33
|
+
const o = r.current;
|
|
34
34
|
if (!o) return;
|
|
35
|
-
const
|
|
36
|
-
let
|
|
37
|
-
|
|
35
|
+
const a = o.shadowRoot ?? o.attachShadow({ mode: "open" }), T = "content-render-svg-style";
|
|
36
|
+
let m = a.getElementById(T);
|
|
37
|
+
m || (m = document.createElement("style"), m.id = T, m.textContent = `
|
|
38
38
|
svg { height: auto; display: inline-block; }
|
|
39
39
|
svg.content-render-svg-el--responsive { width: 100%; max-width: 100%; }
|
|
40
40
|
svg.content-render-svg-el--fixed { max-width: none; }
|
|
41
|
-
`,
|
|
42
|
-
(
|
|
43
|
-
).forEach((
|
|
44
|
-
const G = document.createElement("template"),
|
|
45
|
-
G.innerHTML =
|
|
46
|
-
let
|
|
47
|
-
|
|
48
|
-
const
|
|
49
|
-
if (!
|
|
50
|
-
const
|
|
51
|
-
if (
|
|
52
|
-
const [, ,
|
|
53
|
-
if (!
|
|
54
|
-
const
|
|
55
|
-
return
|
|
56
|
-
},
|
|
57
|
-
if (!
|
|
58
|
-
const
|
|
59
|
-
if (
|
|
41
|
+
`, a.appendChild(m)), Array.from(a.childNodes).filter(
|
|
42
|
+
(i) => i !== m
|
|
43
|
+
).forEach((i) => a.removeChild(i));
|
|
44
|
+
const G = document.createElement("template"), V = Ue(t);
|
|
45
|
+
G.innerHTML = V, a.append(G.content.cloneNode(!0));
|
|
46
|
+
let p = !1, z = !1;
|
|
47
|
+
a.querySelectorAll("svg").forEach((i) => {
|
|
48
|
+
const _ = i.getAttribute("viewBox");
|
|
49
|
+
if (!_) return;
|
|
50
|
+
const q = _.trim().split(/[\s,]+/).map((y) => Number(y));
|
|
51
|
+
if (q.length !== 4 || q.some(Number.isNaN)) return;
|
|
52
|
+
const [, , D, R] = q, A = i.getAttribute("width"), E = i.getAttribute("height"), K = (y) => {
|
|
53
|
+
if (!y) return !1;
|
|
54
|
+
const u = y.trim().toLowerCase();
|
|
55
|
+
return u === "auto" || u.endsWith("%");
|
|
56
|
+
}, O = (y) => {
|
|
57
|
+
if (!y) return null;
|
|
58
|
+
const u = y.trim().toLowerCase();
|
|
59
|
+
if (u === "auto" || u.endsWith("%"))
|
|
60
60
|
return null;
|
|
61
|
-
const M = Number.parseFloat(
|
|
61
|
+
const M = Number.parseFloat(u);
|
|
62
62
|
return Number.isNaN(M) ? null : M;
|
|
63
|
-
},
|
|
64
|
-
if (
|
|
65
|
-
|
|
63
|
+
}, ee = K(A), te = K(E), Y = !A || A === "0", X = !E || E === "0", ne = O(A), re = O(E);
|
|
64
|
+
if (ee || te || Y && X || ne === D && re === R) {
|
|
65
|
+
p = !0, i.classList.add("content-render-svg-el--responsive"), i.classList.remove("content-render-svg-el--fixed"), i.style.width = "100%", i.style.height = "auto", !i.style.aspectRatio && R > 0 && (i.style.aspectRatio = `${D} / ${R}`);
|
|
66
66
|
return;
|
|
67
67
|
}
|
|
68
|
-
|
|
68
|
+
z = !0, i.classList.add("content-render-svg-el--fixed"), i.classList.remove("content-render-svg-el--responsive"), Y && D > 0 && i.setAttribute("width", `${D}`), X && R > 0 && i.setAttribute("height", `${R}`);
|
|
69
69
|
});
|
|
70
|
-
const
|
|
71
|
-
o.classList.toggle("content-render-svg--responsive",
|
|
72
|
-
}, [t]), /* @__PURE__ */
|
|
73
|
-
},
|
|
70
|
+
const W = p && !z;
|
|
71
|
+
o.classList.toggle("content-render-svg--responsive", W), o.classList.toggle("content-render-svg--fixed", !W);
|
|
72
|
+
}, [t]), /* @__PURE__ */ n("div", { className: "content-render-svg-scroll", children: /* @__PURE__ */ n("div", { className: "content-render-svg", ref: r }) });
|
|
73
|
+
}, de = U.createContext(
|
|
74
74
|
null
|
|
75
75
|
), xt = (t) => {
|
|
76
|
-
const
|
|
77
|
-
if (!
|
|
76
|
+
const r = U.useContext(de), o = U.useContext(Oe);
|
|
77
|
+
if (!r)
|
|
78
78
|
throw new Error("Markdown code renderer requires ContentRender context.");
|
|
79
|
-
const { className:
|
|
80
|
-
if (/language-(\w+)/.exec(
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
|
|
79
|
+
const { className: a, children: T, ...m } = t;
|
|
80
|
+
if (/language-(\w+)/.exec(a || "")?.[1] === "mermaid") {
|
|
81
|
+
const V = T?.toString().replace(/\n$/, "") || "", p = tt(
|
|
82
|
+
r.current.renderContent,
|
|
83
|
+
V
|
|
84
84
|
);
|
|
85
|
-
return /* @__PURE__ */
|
|
86
|
-
|
|
85
|
+
return /* @__PURE__ */ n(
|
|
86
|
+
le,
|
|
87
87
|
{
|
|
88
|
-
chart:
|
|
89
|
-
frozen:
|
|
90
|
-
messages:
|
|
88
|
+
chart: V,
|
|
89
|
+
frozen: p,
|
|
90
|
+
messages: r.current.mermaidMessages
|
|
91
91
|
}
|
|
92
92
|
);
|
|
93
93
|
}
|
|
94
|
-
return /* @__PURE__ */
|
|
94
|
+
return /* @__PURE__ */ n(
|
|
95
95
|
"code",
|
|
96
96
|
{
|
|
97
|
-
className:
|
|
98
|
-
...
|
|
99
|
-
dir:
|
|
100
|
-
children:
|
|
97
|
+
className: a,
|
|
98
|
+
...m,
|
|
99
|
+
dir: m.dir ?? (o ? void 0 : "ltr"),
|
|
100
|
+
children: T
|
|
101
101
|
}
|
|
102
102
|
);
|
|
103
|
-
},
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
],
|
|
109
|
-
Oe,
|
|
110
|
-
lt,
|
|
111
|
-
Pe,
|
|
103
|
+
}, yt = [
|
|
104
|
+
ht,
|
|
105
|
+
ft,
|
|
106
|
+
Qe,
|
|
107
|
+
gt
|
|
108
|
+
], Ct = [
|
|
112
109
|
Xe,
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
110
|
+
dt,
|
|
111
|
+
Pe,
|
|
112
|
+
Ze,
|
|
113
|
+
[mt, { languages: et, subset: Je }],
|
|
114
|
+
pt
|
|
115
|
+
], Ve = ({ content: t, components: r, locale: o }) => {
|
|
116
|
+
const a = De(o);
|
|
117
|
+
return /* @__PURE__ */ n("div", { className: "markdown-renderer", children: /* @__PURE__ */ n(
|
|
118
|
+
lt,
|
|
119
119
|
{
|
|
120
|
-
remarkPlugins:
|
|
121
|
-
rehypePlugins:
|
|
120
|
+
remarkPlugins: yt,
|
|
121
|
+
rehypePlugins: Ct,
|
|
122
122
|
remarkRehypeOptions: {
|
|
123
|
-
footnoteLabel:
|
|
124
|
-
footnoteBackLabel: (
|
|
125
|
-
const
|
|
126
|
-
return
|
|
123
|
+
footnoteLabel: a.footnoteLabel,
|
|
124
|
+
footnoteBackLabel: (T, m) => {
|
|
125
|
+
const L = String(T + 1) + (m > 1 ? `-${m}` : "");
|
|
126
|
+
return a.footnoteBackLabel.replace("{reference}", L);
|
|
127
127
|
}
|
|
128
128
|
},
|
|
129
|
-
components:
|
|
129
|
+
components: r,
|
|
130
130
|
children: t
|
|
131
131
|
}
|
|
132
132
|
) });
|
|
133
|
-
},
|
|
133
|
+
}, Tt = (t) => {
|
|
134
134
|
if (t.length <= 1) return t;
|
|
135
|
-
const
|
|
135
|
+
const r = [];
|
|
136
136
|
return t.forEach((o) => {
|
|
137
137
|
if (o.type === "sandbox") {
|
|
138
|
-
|
|
138
|
+
r.push(o);
|
|
139
139
|
return;
|
|
140
140
|
}
|
|
141
|
-
const
|
|
142
|
-
if (
|
|
143
|
-
|
|
141
|
+
const a = r[r.length - 1];
|
|
142
|
+
if (a && a.type !== "sandbox") {
|
|
143
|
+
r[r.length - 1] = {
|
|
144
144
|
type: "markdown",
|
|
145
|
-
value: `${
|
|
145
|
+
value: `${a.value}${o.value}`
|
|
146
146
|
};
|
|
147
147
|
return;
|
|
148
148
|
}
|
|
149
|
-
|
|
150
|
-
}),
|
|
151
|
-
},
|
|
152
|
-
const o = Math.max(1,
|
|
149
|
+
r.push({ type: "markdown", value: o.value });
|
|
150
|
+
}), r;
|
|
151
|
+
}, kt = (t, r) => {
|
|
152
|
+
const o = Math.max(1, r), a = Array.from(t);
|
|
153
153
|
return {
|
|
154
|
-
chunk:
|
|
155
|
-
rest:
|
|
154
|
+
chunk: a.slice(0, o).join(""),
|
|
155
|
+
rest: a.slice(o).join("")
|
|
156
156
|
};
|
|
157
|
-
},
|
|
158
|
-
const
|
|
159
|
-
return
|
|
160
|
-
},
|
|
157
|
+
}, wt = (t, r) => t === r ? !0 : !t || !r || t.length !== r.length ? !1 : t.every((o, a) => o === r[a]), bt = (t) => {
|
|
158
|
+
const r = g(t);
|
|
159
|
+
return wt(r.current, t) || (r.current = t), r.current;
|
|
160
|
+
}, nn = ({
|
|
161
161
|
content: t,
|
|
162
|
-
contentType:
|
|
162
|
+
contentType: r,
|
|
163
163
|
locale: o,
|
|
164
|
-
lang:
|
|
165
|
-
dir:
|
|
166
|
-
customRenderBar:
|
|
167
|
-
onSend:
|
|
164
|
+
lang: a,
|
|
165
|
+
dir: T,
|
|
166
|
+
customRenderBar: m,
|
|
167
|
+
onSend: L,
|
|
168
168
|
typingSpeed: G = 30,
|
|
169
|
-
enableTypewriter:
|
|
170
|
-
typewriterPacing:
|
|
171
|
-
onTypeFinished:
|
|
172
|
-
onTypewriterStateChange:
|
|
173
|
-
userInput:
|
|
174
|
-
interactionDefaultValueOptions:
|
|
175
|
-
defaultButtonText:
|
|
176
|
-
defaultInputText:
|
|
177
|
-
defaultSelectedValues:
|
|
178
|
-
readonly:
|
|
179
|
-
confirmButtonText:
|
|
180
|
-
copyButtonText:
|
|
181
|
-
copiedButtonText:
|
|
182
|
-
sandboxLoadingText:
|
|
183
|
-
sandboxStyleLoadingText:
|
|
184
|
-
sandboxScriptLoadingText:
|
|
185
|
-
disableSandboxLoadingOverlay:
|
|
186
|
-
sandboxFullscreenButtonText:
|
|
187
|
-
sandboxExitFullscreenButtonText:
|
|
188
|
-
sandboxMode:
|
|
189
|
-
onClickCustomButtonAfterContent:
|
|
190
|
-
beforeSend:
|
|
169
|
+
enableTypewriter: V = !1,
|
|
170
|
+
typewriterPacing: p = "fixed",
|
|
171
|
+
onTypeFinished: z,
|
|
172
|
+
onTypewriterStateChange: W,
|
|
173
|
+
userInput: i,
|
|
174
|
+
interactionDefaultValueOptions: _,
|
|
175
|
+
defaultButtonText: q,
|
|
176
|
+
defaultInputText: D,
|
|
177
|
+
defaultSelectedValues: R,
|
|
178
|
+
readonly: A = !1,
|
|
179
|
+
confirmButtonText: E,
|
|
180
|
+
copyButtonText: K,
|
|
181
|
+
copiedButtonText: O,
|
|
182
|
+
sandboxLoadingText: ee,
|
|
183
|
+
sandboxStyleLoadingText: te,
|
|
184
|
+
sandboxScriptLoadingText: Y,
|
|
185
|
+
disableSandboxLoadingOverlay: X = !1,
|
|
186
|
+
sandboxFullscreenButtonText: ne,
|
|
187
|
+
sandboxExitFullscreenButtonText: re,
|
|
188
|
+
sandboxMode: me = "content",
|
|
189
|
+
onClickCustomButtonAfterContent: oe,
|
|
190
|
+
beforeSend: y
|
|
191
191
|
// tooltipMinLength,
|
|
192
192
|
}) => {
|
|
193
|
-
const
|
|
193
|
+
const u = De(o), M = B(
|
|
194
194
|
() => ({
|
|
195
|
-
loading:
|
|
196
|
-
emptyChart:
|
|
197
|
-
error:
|
|
195
|
+
loading: u.mermaidLoadingText,
|
|
196
|
+
emptyChart: u.mermaidEmptyChartText,
|
|
197
|
+
error: u.mermaidErrorText
|
|
198
198
|
}),
|
|
199
|
-
[
|
|
200
|
-
), H =
|
|
201
|
-
() =>
|
|
202
|
-
|
|
199
|
+
[u]
|
|
200
|
+
), H = T ?? ct(o), j = a ?? ut(o), pe = E || u.confirmButtonText, he = K || u.copyButtonText, fe = O || u.copiedButtonText, Ee = ne || u.sandboxFullscreenButtonText, Ie = re || u.sandboxExitFullscreenButtonText, l = !!V && (!r || r === "text"), Z = B(
|
|
201
|
+
() => Tt(at(t, !0, !0)),
|
|
202
|
+
[t]
|
|
203
|
+
), se = Z.some(
|
|
204
|
+
(e) => e.type === "sandbox"
|
|
205
|
+
), c = se ? Z.filter((e) => e.type !== "sandbox").map((e) => e.value).join("") : t, ge = Math.max(0, G), Fe = p === "fixed" ? c : void 0, [v, ve] = Ne(
|
|
206
|
+
() => l ? "" : c
|
|
207
|
+
), J = g(v), f = g(""), x = g({
|
|
203
208
|
tokens: [],
|
|
204
209
|
head: 0,
|
|
205
210
|
trailingGrapheme: ""
|
|
206
|
-
}),
|
|
211
|
+
}), S = g(0), xe = g(l), ye = g(p), Ce = g(c), Te = g(t), ae = g(!1), [Ge, ze] = Ne(0);
|
|
207
212
|
P(() => {
|
|
208
|
-
const e =
|
|
209
|
-
|
|
210
|
-
const
|
|
211
|
-
|
|
213
|
+
const e = xe.current, s = ye.current, h = Ce.current, k = !!f.current, C = Te.current !== t;
|
|
214
|
+
Te.current = t, xe.current = l, ye.current = p, Ce.current = c, (C || l !== e) && (ae.current = !1);
|
|
215
|
+
const Q = () => {
|
|
216
|
+
f.current = "", x.current = {
|
|
212
217
|
tokens: [],
|
|
213
218
|
head: 0,
|
|
214
219
|
trailingGrapheme: ""
|
|
215
|
-
},
|
|
216
|
-
},
|
|
217
|
-
|
|
220
|
+
}, S.current = 0;
|
|
221
|
+
}, w = (F) => {
|
|
222
|
+
J.current = F, ve(F);
|
|
218
223
|
};
|
|
219
|
-
if (!
|
|
220
|
-
|
|
224
|
+
if (!l) {
|
|
225
|
+
Q(), w(c);
|
|
221
226
|
return;
|
|
222
227
|
}
|
|
223
|
-
e || (
|
|
224
|
-
const
|
|
225
|
-
if (!
|
|
226
|
-
|
|
228
|
+
e || (Q(), w(""));
|
|
229
|
+
const $ = e ? J.current : "";
|
|
230
|
+
if (!c.startsWith($)) {
|
|
231
|
+
Q(), w(c), p === "content-aware" && (x.current = {
|
|
227
232
|
tokens: [],
|
|
228
233
|
head: 0,
|
|
229
|
-
trailingGrapheme:
|
|
234
|
+
trailingGrapheme: ue(c)
|
|
230
235
|
});
|
|
231
236
|
return;
|
|
232
237
|
}
|
|
233
|
-
let N =
|
|
238
|
+
let N = c.slice($.length);
|
|
234
239
|
if (!N) {
|
|
235
|
-
|
|
240
|
+
f.current = "", S.current = 0, x.current = p === "content-aware" ? {
|
|
236
241
|
tokens: [],
|
|
237
242
|
head: 0,
|
|
238
|
-
trailingGrapheme:
|
|
243
|
+
trailingGrapheme: ue($)
|
|
239
244
|
} : { tokens: [], head: 0, trailingGrapheme: "" };
|
|
240
245
|
return;
|
|
241
246
|
}
|
|
242
|
-
if (
|
|
243
|
-
const
|
|
244
|
-
|
|
247
|
+
if (p === "content-aware") {
|
|
248
|
+
const F = h.slice(
|
|
249
|
+
$.length
|
|
245
250
|
);
|
|
246
|
-
if (e &&
|
|
247
|
-
const
|
|
248
|
-
|
|
249
|
-
|
|
251
|
+
if (e && s === "content-aware" && c.startsWith(h) && f.current === F) {
|
|
252
|
+
const b = Me(
|
|
253
|
+
x.current,
|
|
254
|
+
c.slice(h.length)
|
|
250
255
|
);
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
),
|
|
256
|
+
x.current = b.queue, b.immediateChunk && (N = N.slice(
|
|
257
|
+
b.immediateChunk.length
|
|
258
|
+
), w(`${$}${b.immediateChunk}`));
|
|
254
259
|
} else {
|
|
255
|
-
const
|
|
260
|
+
const b = Me(
|
|
256
261
|
{
|
|
257
262
|
tokens: [],
|
|
258
263
|
head: 0,
|
|
259
|
-
trailingGrapheme:
|
|
264
|
+
trailingGrapheme: ue($)
|
|
260
265
|
},
|
|
261
266
|
N
|
|
262
267
|
);
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
),
|
|
268
|
+
x.current = b.queue, b.immediateChunk && (N = N.slice(
|
|
269
|
+
b.immediateChunk.length
|
|
270
|
+
), w(`${$}${b.immediateChunk}`)), S.current = 0;
|
|
266
271
|
}
|
|
267
272
|
} else
|
|
268
|
-
|
|
273
|
+
x.current = {
|
|
269
274
|
tokens: [],
|
|
270
275
|
head: 0,
|
|
271
276
|
trailingGrapheme: ""
|
|
272
|
-
},
|
|
273
|
-
|
|
274
|
-
}, [t,
|
|
275
|
-
|
|
276
|
-
}, [
|
|
277
|
-
|
|
277
|
+
}, S.current = 0;
|
|
278
|
+
f.current = N, !k && N && ze((F) => F + 1);
|
|
279
|
+
}, [t, c, l, p]), P(() => {
|
|
280
|
+
l && (ae.current || f.current || v !== c || (ae.current = !0, z?.()));
|
|
281
|
+
}, [
|
|
282
|
+
t,
|
|
283
|
+
c,
|
|
284
|
+
v,
|
|
285
|
+
l,
|
|
286
|
+
z
|
|
287
|
+
]), P(() => {
|
|
288
|
+
if (!l || !f.current)
|
|
278
289
|
return;
|
|
279
290
|
const e = window.setTimeout(() => {
|
|
280
|
-
if (!
|
|
291
|
+
if (!f.current)
|
|
281
292
|
return;
|
|
282
|
-
let
|
|
283
|
-
if (
|
|
284
|
-
const
|
|
285
|
-
|
|
286
|
-
|
|
293
|
+
let s = "";
|
|
294
|
+
if (p === "content-aware") {
|
|
295
|
+
const k = rt(
|
|
296
|
+
x.current,
|
|
297
|
+
S.current + ot
|
|
287
298
|
);
|
|
288
|
-
|
|
299
|
+
s = k.chunk, x.current = k.queue, st(k.queue) ? S.current = 0 : S.current = k.remainingBudget;
|
|
289
300
|
} else
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
301
|
+
s = kt(
|
|
302
|
+
f.current,
|
|
303
|
+
vt
|
|
293
304
|
).chunk;
|
|
294
|
-
if (!
|
|
305
|
+
if (!s)
|
|
295
306
|
return;
|
|
296
|
-
|
|
307
|
+
f.current = f.current.slice(s.length), f.current || (x.current = p === "content-aware" ? {
|
|
297
308
|
tokens: [],
|
|
298
309
|
head: 0,
|
|
299
|
-
trailingGrapheme:
|
|
300
|
-
} : { tokens: [], head: 0, trailingGrapheme: "" },
|
|
301
|
-
const
|
|
302
|
-
|
|
303
|
-
},
|
|
310
|
+
trailingGrapheme: x.current.trailingGrapheme
|
|
311
|
+
} : { tokens: [], head: 0, trailingGrapheme: "" }, S.current = 0);
|
|
312
|
+
const h = `${J.current}${s}`;
|
|
313
|
+
J.current = h, ve(h);
|
|
314
|
+
}, ge);
|
|
304
315
|
return () => window.clearTimeout(e);
|
|
305
316
|
}, [
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
317
|
+
v,
|
|
318
|
+
Fe,
|
|
319
|
+
l,
|
|
320
|
+
p,
|
|
321
|
+
ge,
|
|
322
|
+
Ge
|
|
312
323
|
]);
|
|
313
|
-
const
|
|
324
|
+
const ke = B(
|
|
314
325
|
() => ({
|
|
315
|
-
isTypewriterEnabled:
|
|
316
|
-
isTyping:
|
|
317
|
-
isComplete:
|
|
318
|
-
renderedLength:
|
|
326
|
+
isTypewriterEnabled: l,
|
|
327
|
+
isTyping: l && v !== c,
|
|
328
|
+
isComplete: v === c,
|
|
329
|
+
renderedLength: t.length - Math.max(0, c.length - v.length),
|
|
319
330
|
totalLength: t.length
|
|
320
331
|
}),
|
|
321
|
-
[t,
|
|
332
|
+
[t, c, v, l]
|
|
322
333
|
);
|
|
323
334
|
P(() => {
|
|
324
|
-
|
|
325
|
-
}, [
|
|
326
|
-
const
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
335
|
+
W?.(ke);
|
|
336
|
+
}, [W, ke]);
|
|
337
|
+
const we = B(() => {
|
|
338
|
+
let e = 0;
|
|
339
|
+
return Z.map((s) => {
|
|
340
|
+
if (s.type === "sandbox" || !l) return s;
|
|
341
|
+
const h = v.slice(
|
|
342
|
+
e,
|
|
343
|
+
e + s.value.length
|
|
344
|
+
);
|
|
345
|
+
return e += s.value.length, { ...s, value: h };
|
|
346
|
+
});
|
|
347
|
+
}, [Z, v, l]), I = se ? we.map((e) => e.value).join("") : l ? v : t, ie = B(
|
|
348
|
+
() => Ae(I),
|
|
349
|
+
[I]
|
|
350
|
+
), ce = B(
|
|
351
|
+
() => it(
|
|
352
|
+
I,
|
|
353
|
+
i,
|
|
354
|
+
_
|
|
334
355
|
),
|
|
335
|
-
[
|
|
336
|
-
),
|
|
337
|
-
() =>
|
|
338
|
-
[
|
|
339
|
-
),
|
|
340
|
-
|
|
341
|
-
),
|
|
356
|
+
[_, I, i]
|
|
357
|
+
), be = q?.trim() || ce.buttonText, Be = D?.trim() || ce.inputText, We = B(
|
|
358
|
+
() => i ? i.split(",").map((e) => e.trim()).filter(Boolean) : void 0,
|
|
359
|
+
[i]
|
|
360
|
+
), _e = R?.length ? R : ce.selectedValues || We, Re = bt(
|
|
361
|
+
_e
|
|
362
|
+
), d = g({
|
|
342
363
|
direction: H,
|
|
343
|
-
language:
|
|
364
|
+
language: j,
|
|
344
365
|
mermaidMessages: M,
|
|
345
|
-
beforeSend:
|
|
366
|
+
beforeSend: y,
|
|
346
367
|
locale: o,
|
|
347
|
-
onClickCustomButtonAfterContent:
|
|
348
|
-
onSend:
|
|
349
|
-
readonly:
|
|
350
|
-
renderContent:
|
|
351
|
-
resolvedConfirmButtonText:
|
|
352
|
-
resolvedCopiedButtonText:
|
|
353
|
-
resolvedCopyButtonText:
|
|
354
|
-
resolvedDefaultButtonText:
|
|
355
|
-
resolvedDefaultInputText:
|
|
356
|
-
resolvedDefaultSelectedValues:
|
|
368
|
+
onClickCustomButtonAfterContent: oe,
|
|
369
|
+
onSend: L,
|
|
370
|
+
readonly: A,
|
|
371
|
+
renderContent: I,
|
|
372
|
+
resolvedConfirmButtonText: pe,
|
|
373
|
+
resolvedCopiedButtonText: fe,
|
|
374
|
+
resolvedCopyButtonText: he,
|
|
375
|
+
resolvedDefaultButtonText: be,
|
|
376
|
+
resolvedDefaultInputText: Be,
|
|
377
|
+
resolvedDefaultSelectedValues: Re
|
|
357
378
|
});
|
|
358
|
-
|
|
379
|
+
d.current = {
|
|
359
380
|
direction: H,
|
|
360
|
-
language:
|
|
381
|
+
language: j,
|
|
361
382
|
mermaidMessages: M,
|
|
362
|
-
beforeSend:
|
|
383
|
+
beforeSend: y,
|
|
363
384
|
locale: o,
|
|
364
|
-
onClickCustomButtonAfterContent:
|
|
365
|
-
onSend:
|
|
366
|
-
readonly:
|
|
367
|
-
renderContent:
|
|
368
|
-
resolvedConfirmButtonText:
|
|
369
|
-
resolvedCopiedButtonText:
|
|
370
|
-
resolvedCopyButtonText:
|
|
371
|
-
resolvedDefaultButtonText:
|
|
372
|
-
resolvedDefaultInputText:
|
|
373
|
-
resolvedDefaultSelectedValues:
|
|
385
|
+
onClickCustomButtonAfterContent: oe,
|
|
386
|
+
onSend: L,
|
|
387
|
+
readonly: A,
|
|
388
|
+
renderContent: I,
|
|
389
|
+
resolvedConfirmButtonText: pe,
|
|
390
|
+
resolvedCopiedButtonText: fe,
|
|
391
|
+
resolvedCopyButtonText: he,
|
|
392
|
+
resolvedDefaultButtonText: be,
|
|
393
|
+
resolvedDefaultInputText: Be,
|
|
394
|
+
resolvedDefaultSelectedValues: Re
|
|
374
395
|
};
|
|
375
|
-
const
|
|
396
|
+
const Se = B(
|
|
376
397
|
() => ({
|
|
377
398
|
"custom-button-after-content": ({
|
|
378
399
|
children: e
|
|
379
|
-
}) => /* @__PURE__ */
|
|
400
|
+
}) => /* @__PURE__ */ n(
|
|
380
401
|
"button",
|
|
381
402
|
{
|
|
382
403
|
className: "content-render-custom-button-after-content",
|
|
383
|
-
onClick:
|
|
384
|
-
children: /* @__PURE__ */
|
|
404
|
+
onClick: d.current.onClickCustomButtonAfterContent,
|
|
405
|
+
children: /* @__PURE__ */ n("span", { className: "content-render-custom-button-after-content-inner", children: e })
|
|
385
406
|
}
|
|
386
407
|
),
|
|
387
|
-
"custom-variable": (e) => /* @__PURE__ */
|
|
388
|
-
|
|
408
|
+
"custom-variable": (e) => /* @__PURE__ */ n(
|
|
409
|
+
Ye,
|
|
389
410
|
{
|
|
390
411
|
...e,
|
|
391
|
-
readonly:
|
|
392
|
-
defaultButtonText:
|
|
393
|
-
defaultInputText:
|
|
394
|
-
defaultSelectedValues:
|
|
395
|
-
onSend:
|
|
396
|
-
beforeSend:
|
|
397
|
-
locale:
|
|
398
|
-
dir:
|
|
399
|
-
lang:
|
|
400
|
-
confirmButtonText:
|
|
412
|
+
readonly: d.current.readonly,
|
|
413
|
+
defaultButtonText: d.current.resolvedDefaultButtonText,
|
|
414
|
+
defaultInputText: d.current.resolvedDefaultInputText,
|
|
415
|
+
defaultSelectedValues: d.current.resolvedDefaultSelectedValues,
|
|
416
|
+
onSend: d.current.onSend,
|
|
417
|
+
beforeSend: d.current.beforeSend,
|
|
418
|
+
locale: d.current.locale,
|
|
419
|
+
dir: d.current.direction,
|
|
420
|
+
lang: d.current.language,
|
|
421
|
+
confirmButtonText: d.current.resolvedConfirmButtonText
|
|
401
422
|
}
|
|
402
423
|
),
|
|
403
424
|
code: xt,
|
|
404
|
-
table: ({ ...e }) => /* @__PURE__ */
|
|
405
|
-
th: ({ ...e }) => /* @__PURE__ */
|
|
406
|
-
td: ({ ...e }) => /* @__PURE__ */
|
|
407
|
-
tr: ({ ...e }) => /* @__PURE__ */
|
|
408
|
-
li: ({ node: e, ...
|
|
409
|
-
const
|
|
410
|
-
return typeof
|
|
425
|
+
table: ({ ...e }) => /* @__PURE__ */ n("div", { className: "content-render-table-container", children: /* @__PURE__ */ n("table", { className: "content-render-table", ...e }) }),
|
|
426
|
+
th: ({ ...e }) => /* @__PURE__ */ n("th", { className: "content-render-th", ...e }),
|
|
427
|
+
td: ({ ...e }) => /* @__PURE__ */ n("td", { className: "content-render-td", ...e }),
|
|
428
|
+
tr: ({ ...e }) => /* @__PURE__ */ n("tr", { className: "content-render-tr", ...e }),
|
|
429
|
+
li: ({ node: e, ...s }) => {
|
|
430
|
+
const h = e?.properties?.className;
|
|
431
|
+
return typeof h == "string" && h.includes("task-list-item") || Array.isArray(h) && h.includes("task-list-item") ? /* @__PURE__ */ n("li", { className: "content-render-task-list-item", ...s }) : /* @__PURE__ */ n("li", { ...s });
|
|
411
432
|
},
|
|
412
|
-
ol: ({ ...e }) => /* @__PURE__ */
|
|
413
|
-
ul: ({ ...e }) => /* @__PURE__ */
|
|
414
|
-
input: ({ ...e }) => e.type === "checkbox" ? /* @__PURE__ */
|
|
433
|
+
ol: ({ ...e }) => /* @__PURE__ */ n("ol", { className: "content-render-ol", ...e }),
|
|
434
|
+
ul: ({ ...e }) => /* @__PURE__ */ n("ul", { className: "content-render-ul", ...e }),
|
|
435
|
+
input: ({ ...e }) => e.type === "checkbox" ? /* @__PURE__ */ n(
|
|
415
436
|
"input",
|
|
416
437
|
{
|
|
417
438
|
type: "checkbox",
|
|
@@ -419,70 +440,59 @@ const ft = /<(script|style|link|iframe|html|head|body|meta|title|base|template|d
|
|
|
419
440
|
disabled: !0,
|
|
420
441
|
...e
|
|
421
442
|
}
|
|
422
|
-
) : /* @__PURE__ */
|
|
423
|
-
a: ({ children: e, ...
|
|
424
|
-
pre: (e) => /* @__PURE__ */
|
|
425
|
-
|
|
443
|
+
) : /* @__PURE__ */ n("input", { ...e }),
|
|
444
|
+
a: ({ children: e, ...s }) => /* @__PURE__ */ n("a", { target: "_blank", rel: "noopener noreferrer", ...s, children: e }),
|
|
445
|
+
pre: (e) => /* @__PURE__ */ n(
|
|
446
|
+
Ke,
|
|
426
447
|
{
|
|
427
448
|
...e,
|
|
428
|
-
copyButtonText:
|
|
429
|
-
copiedButtonText:
|
|
449
|
+
copyButtonText: d.current.resolvedCopyButtonText,
|
|
450
|
+
copiedButtonText: d.current.resolvedCopiedButtonText
|
|
430
451
|
}
|
|
431
452
|
)
|
|
432
453
|
}),
|
|
433
454
|
[]
|
|
434
|
-
),
|
|
435
|
-
() =>
|
|
436
|
-
[
|
|
437
|
-
),
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
() => yt(se),
|
|
444
|
-
[se]
|
|
445
|
-
), ze = C(
|
|
446
|
-
() => Be(ne),
|
|
447
|
-
[ne]
|
|
448
|
-
), We = (e, i) => {
|
|
449
|
-
const p = Se(e);
|
|
450
|
-
return Be(p).map((f, $) => {
|
|
451
|
-
const x = `${i}-${f.type}-${$}`;
|
|
452
|
-
return f.type === "text" ? /* @__PURE__ */ r(
|
|
453
|
-
ce.Provider,
|
|
455
|
+
), qe = B(
|
|
456
|
+
() => Le(ie),
|
|
457
|
+
[ie]
|
|
458
|
+
), He = (e, s) => {
|
|
459
|
+
const h = Ae(e);
|
|
460
|
+
return Le(h).map((C, Q) => {
|
|
461
|
+
const w = `${s}-${C.type}-${Q}`;
|
|
462
|
+
return C.type === "text" ? /* @__PURE__ */ n(
|
|
463
|
+
de.Provider,
|
|
454
464
|
{
|
|
455
|
-
value:
|
|
456
|
-
children: /* @__PURE__ */
|
|
457
|
-
|
|
465
|
+
value: d,
|
|
466
|
+
children: /* @__PURE__ */ n(
|
|
467
|
+
Ve,
|
|
458
468
|
{
|
|
459
469
|
locale: o,
|
|
460
|
-
components:
|
|
461
|
-
content:
|
|
470
|
+
components: Se,
|
|
471
|
+
content: C.value
|
|
462
472
|
}
|
|
463
473
|
)
|
|
464
474
|
},
|
|
465
|
-
|
|
466
|
-
) :
|
|
467
|
-
|
|
475
|
+
w
|
|
476
|
+
) : C.type === "mermaid" ? /* @__PURE__ */ n(
|
|
477
|
+
le,
|
|
468
478
|
{
|
|
469
|
-
chart:
|
|
470
|
-
frozen: !
|
|
479
|
+
chart: C.value,
|
|
480
|
+
frozen: !C.complete,
|
|
471
481
|
messages: M
|
|
472
482
|
},
|
|
473
|
-
|
|
474
|
-
) :
|
|
483
|
+
w
|
|
484
|
+
) : C.type === "svg" ? /* @__PURE__ */ n($e, { svg: C.value }, w) : null;
|
|
475
485
|
});
|
|
476
486
|
};
|
|
477
|
-
return
|
|
487
|
+
return se ? /* @__PURE__ */ n(
|
|
478
488
|
"div",
|
|
479
489
|
{
|
|
480
490
|
className: "content-render markdown-body",
|
|
481
491
|
dir: H,
|
|
482
|
-
lang:
|
|
483
|
-
children:
|
|
484
|
-
(e,
|
|
485
|
-
|
|
492
|
+
lang: j,
|
|
493
|
+
children: we.map(
|
|
494
|
+
(e, s) => e.type === "sandbox" ? /* @__PURE__ */ n(
|
|
495
|
+
nt,
|
|
486
496
|
{
|
|
487
497
|
hideFullScreen: !0,
|
|
488
498
|
type: "sandbox",
|
|
@@ -490,67 +500,67 @@ const ft = /<(script|style|link|iframe|html|head|body|meta|title|base|template|d
|
|
|
490
500
|
className: "content-render-iframe",
|
|
491
501
|
locale: o,
|
|
492
502
|
dir: H,
|
|
493
|
-
lang:
|
|
494
|
-
loadingText:
|
|
495
|
-
styleLoadingText:
|
|
496
|
-
scriptLoadingText:
|
|
497
|
-
disableLoadingOverlay:
|
|
498
|
-
fullScreenButtonText:
|
|
499
|
-
exitFullScreenButtonText:
|
|
500
|
-
mode:
|
|
503
|
+
lang: j,
|
|
504
|
+
loadingText: ee,
|
|
505
|
+
styleLoadingText: te,
|
|
506
|
+
scriptLoadingText: Y,
|
|
507
|
+
disableLoadingOverlay: X,
|
|
508
|
+
fullScreenButtonText: Ee,
|
|
509
|
+
exitFullScreenButtonText: Ie,
|
|
510
|
+
mode: me
|
|
501
511
|
},
|
|
502
|
-
`sandbox-${
|
|
503
|
-
) : /* @__PURE__ */
|
|
512
|
+
`sandbox-${s}`
|
|
513
|
+
) : /* @__PURE__ */ n(U.Fragment, { children: He(e.value, `md-${s}`) }, `md-${s}`)
|
|
504
514
|
)
|
|
505
515
|
}
|
|
506
|
-
) : /* @__PURE__ */
|
|
516
|
+
) : /* @__PURE__ */ je(
|
|
507
517
|
"div",
|
|
508
518
|
{
|
|
509
519
|
className: "content-render markdown-body",
|
|
510
520
|
dir: H,
|
|
511
|
-
lang:
|
|
521
|
+
lang: j,
|
|
512
522
|
children: [
|
|
513
|
-
|
|
523
|
+
qe.map((e, s) => {
|
|
514
524
|
if (e.type === "text")
|
|
515
|
-
return /* @__PURE__ */
|
|
516
|
-
|
|
525
|
+
return /* @__PURE__ */ n(
|
|
526
|
+
de.Provider,
|
|
517
527
|
{
|
|
518
|
-
value:
|
|
519
|
-
children: /* @__PURE__ */
|
|
520
|
-
|
|
528
|
+
value: d,
|
|
529
|
+
children: /* @__PURE__ */ n(
|
|
530
|
+
Ve,
|
|
521
531
|
{
|
|
522
532
|
locale: o,
|
|
523
|
-
components:
|
|
533
|
+
components: Se,
|
|
524
534
|
content: e.value
|
|
525
535
|
}
|
|
526
536
|
)
|
|
527
537
|
},
|
|
528
|
-
|
|
538
|
+
s
|
|
529
539
|
);
|
|
530
540
|
if (e.type === "mermaid")
|
|
531
|
-
return /* @__PURE__ */
|
|
532
|
-
|
|
541
|
+
return /* @__PURE__ */ n(
|
|
542
|
+
le,
|
|
533
543
|
{
|
|
534
544
|
chart: e.value,
|
|
535
545
|
frozen: !e.complete,
|
|
536
546
|
messages: M
|
|
537
547
|
},
|
|
538
|
-
|
|
548
|
+
s
|
|
539
549
|
);
|
|
540
550
|
if (e.type === "svg")
|
|
541
|
-
return /* @__PURE__ */
|
|
551
|
+
return /* @__PURE__ */ n($e, { svg: e.value }, s);
|
|
542
552
|
}),
|
|
543
|
-
|
|
553
|
+
m && /* @__PURE__ */ n("div", { className: "content-render-custom-bar", children: U.createElement(m, {
|
|
544
554
|
content: t,
|
|
545
|
-
displayContent:
|
|
546
|
-
onSend:
|
|
555
|
+
displayContent: ie,
|
|
556
|
+
onSend: L
|
|
547
557
|
}) })
|
|
548
558
|
]
|
|
549
559
|
}
|
|
550
560
|
);
|
|
551
561
|
};
|
|
552
562
|
export {
|
|
553
|
-
|
|
554
|
-
|
|
563
|
+
Ve as MarkdownRenderer,
|
|
564
|
+
nn as default
|
|
555
565
|
};
|
|
556
566
|
//# sourceMappingURL=ContentRender.es.js.map
|