@superlc/md-vue 0.1.0 → 0.2.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/Markdown.d.ts +23 -3
- package/dist/Markdown.d.ts.map +1 -1
- package/dist/components/CodeBlock.d.ts +26 -0
- package/dist/components/CodeBlock.d.ts.map +1 -0
- package/dist/components/index.d.ts +4 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/mermaid/MermaidBlock.d.ts +38 -0
- package/dist/components/mermaid/MermaidBlock.d.ts.map +1 -0
- package/dist/components/mermaid/MermaidFullscreenViewer.d.ts +29 -0
- package/dist/components/mermaid/MermaidFullscreenViewer.d.ts.map +1 -0
- package/dist/components/mermaid/icons.d.ts +52 -0
- package/dist/components/mermaid/icons.d.ts.map +1 -0
- package/dist/components/mermaid/index.d.ts +8 -0
- package/dist/components/mermaid/index.d.ts.map +1 -0
- package/dist/components/mermaid/types.d.ts +34 -0
- package/dist/components/mermaid/types.d.ts.map +1 -0
- package/dist/components/mermaid/useZoom.d.ts +24 -0
- package/dist/components/mermaid/useZoom.d.ts.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +37 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +999 -214
- package/dist/streaming/StreamingMarkdown.d.ts +12 -2
- package/dist/streaming/StreamingMarkdown.d.ts.map +1 -1
- package/dist/streaming/types.d.ts +4 -0
- package/dist/streaming/types.d.ts.map +1 -1
- package/dist/types.d.ts +23 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +18 -12
package/dist/index.js
CHANGED
|
@@ -1,19 +1,755 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { parseToHast as
|
|
3
|
-
let
|
|
4
|
-
async function
|
|
5
|
-
if (!
|
|
6
|
-
return
|
|
7
|
-
await import("katex/dist/katex.min.css"),
|
|
8
|
-
})(),
|
|
1
|
+
import { defineComponent as C, ref as h, h as e, computed as B, onMounted as $, onUnmounted as F, watch as H } from "vue";
|
|
2
|
+
import { detectColorScheme as te, observeColorScheme as ae, MermaidRenderer as ne, downloadAsPng as le, parseToHast as j, createStreamingParser as P, OutputRateController as U } from "@superlc/md-core";
|
|
3
|
+
let O = !1, A = null;
|
|
4
|
+
async function oe() {
|
|
5
|
+
if (!O)
|
|
6
|
+
return A || (A = (async () => {
|
|
7
|
+
await import("katex/dist/katex.min.css"), O = !0;
|
|
8
|
+
})(), A);
|
|
9
9
|
}
|
|
10
|
-
function
|
|
11
|
-
return
|
|
10
|
+
function Se() {
|
|
11
|
+
return O;
|
|
12
12
|
}
|
|
13
|
-
function
|
|
14
|
-
return
|
|
13
|
+
function Y() {
|
|
14
|
+
return oe();
|
|
15
15
|
}
|
|
16
|
-
|
|
16
|
+
async function re(t) {
|
|
17
|
+
try {
|
|
18
|
+
return await navigator.clipboard.writeText(t), !0;
|
|
19
|
+
} catch {
|
|
20
|
+
return se(t);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function se(t) {
|
|
24
|
+
const n = document.createElement("textarea");
|
|
25
|
+
n.value = t, n.style.position = "fixed", n.style.left = "-9999px", document.body.appendChild(n), n.select();
|
|
26
|
+
try {
|
|
27
|
+
return document.execCommand("copy"), !0;
|
|
28
|
+
} catch {
|
|
29
|
+
return !1;
|
|
30
|
+
} finally {
|
|
31
|
+
document.body.removeChild(n);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const ue = () => e(
|
|
35
|
+
"svg",
|
|
36
|
+
{
|
|
37
|
+
viewBox: "0 0 24 24",
|
|
38
|
+
fill: "currentColor"
|
|
39
|
+
},
|
|
40
|
+
[
|
|
41
|
+
e("path", {
|
|
42
|
+
d: "M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"
|
|
43
|
+
})
|
|
44
|
+
]
|
|
45
|
+
), ce = () => e(
|
|
46
|
+
"svg",
|
|
47
|
+
{
|
|
48
|
+
viewBox: "0 0 24 24",
|
|
49
|
+
fill: "currentColor"
|
|
50
|
+
},
|
|
51
|
+
[
|
|
52
|
+
e("path", {
|
|
53
|
+
d: "M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"
|
|
54
|
+
})
|
|
55
|
+
]
|
|
56
|
+
);
|
|
57
|
+
function X(t) {
|
|
58
|
+
return typeof t == "string" ? t : Array.isArray(t) ? t.map((n) => typeof n == "string" ? n : n && typeof n == "object" && "children" in n ? X(n.children) : "").join("") : "";
|
|
59
|
+
}
|
|
60
|
+
const q = C({
|
|
61
|
+
name: "CodeBlock",
|
|
62
|
+
props: {
|
|
63
|
+
showCopyButton: {
|
|
64
|
+
type: Boolean,
|
|
65
|
+
default: !0
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
emits: ["copy"],
|
|
69
|
+
setup(t, { slots: n, emit: l }) {
|
|
70
|
+
const s = h(!1), o = async () => {
|
|
71
|
+
var u;
|
|
72
|
+
const a = (u = n.default) == null ? void 0 : u.call(n), r = a ? X(a) : "";
|
|
73
|
+
await re(r) && (s.value = !0, l("copy", r), setTimeout(() => {
|
|
74
|
+
s.value = !1;
|
|
75
|
+
}, 2e3));
|
|
76
|
+
};
|
|
77
|
+
return () => {
|
|
78
|
+
var r;
|
|
79
|
+
const a = (r = n.default) == null ? void 0 : r.call(n);
|
|
80
|
+
return e("div", { class: "md-code-block-wrapper" }, [
|
|
81
|
+
e("pre", {}, a),
|
|
82
|
+
t.showCopyButton && e(
|
|
83
|
+
"button",
|
|
84
|
+
{
|
|
85
|
+
type: "button",
|
|
86
|
+
class: `md-copy-button${s.value ? " md-copy-button--copied" : ""}`,
|
|
87
|
+
onClick: o,
|
|
88
|
+
title: s.value ? "已复制" : "复制代码",
|
|
89
|
+
"aria-label": s.value ? "已复制" : "复制代码"
|
|
90
|
+
},
|
|
91
|
+
[s.value ? e(ce) : e(ue)]
|
|
92
|
+
)
|
|
93
|
+
]);
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
}), ie = {
|
|
97
|
+
min: 0.25,
|
|
98
|
+
max: 4,
|
|
99
|
+
step: 0.25,
|
|
100
|
+
default: 1
|
|
101
|
+
};
|
|
102
|
+
function W(t = {}) {
|
|
103
|
+
const {
|
|
104
|
+
config: n,
|
|
105
|
+
enableDrag: l = !1,
|
|
106
|
+
enableWheelZoom: s = !1
|
|
107
|
+
} = t, o = { ...ie, ...n }, a = h({
|
|
108
|
+
scale: o.default,
|
|
109
|
+
translateX: 0,
|
|
110
|
+
translateY: 0
|
|
111
|
+
}), r = h(!1), c = h({ x: 0, y: 0 }), u = h({ x: 0, y: 0 }), d = (g) => Math.max(o.min, Math.min(o.max, g)), v = B(() => a.value.scale < o.max), y = B(() => a.value.scale > o.min), m = () => {
|
|
112
|
+
a.value = {
|
|
113
|
+
...a.value,
|
|
114
|
+
scale: d(a.value.scale + o.step)
|
|
115
|
+
};
|
|
116
|
+
}, i = () => {
|
|
117
|
+
a.value = {
|
|
118
|
+
...a.value,
|
|
119
|
+
scale: d(a.value.scale - o.step)
|
|
120
|
+
};
|
|
121
|
+
}, p = () => {
|
|
122
|
+
a.value = {
|
|
123
|
+
scale: o.default,
|
|
124
|
+
translateX: 0,
|
|
125
|
+
translateY: 0
|
|
126
|
+
};
|
|
127
|
+
}, k = (g) => {
|
|
128
|
+
a.value = {
|
|
129
|
+
...a.value,
|
|
130
|
+
scale: d(g)
|
|
131
|
+
};
|
|
132
|
+
}, f = (g, z) => {
|
|
133
|
+
const T = g.width / z.width, M = g.height / z.height, V = Math.min(T, M) * 0.95;
|
|
134
|
+
a.value = {
|
|
135
|
+
scale: d(V),
|
|
136
|
+
translateX: 0,
|
|
137
|
+
translateY: 0
|
|
138
|
+
};
|
|
139
|
+
}, I = (g) => {
|
|
140
|
+
l && (g.preventDefault(), r.value = !0, c.value = { x: g.clientX, y: g.clientY }, u.value = { x: a.value.translateX, y: a.value.translateY });
|
|
141
|
+
}, x = (g) => {
|
|
142
|
+
if (!r.value) return;
|
|
143
|
+
const z = g.clientX - c.value.x, T = g.clientY - c.value.y;
|
|
144
|
+
a.value = {
|
|
145
|
+
...a.value,
|
|
146
|
+
translateX: u.value.x + z,
|
|
147
|
+
translateY: u.value.y + T
|
|
148
|
+
};
|
|
149
|
+
}, b = () => {
|
|
150
|
+
r.value = !1;
|
|
151
|
+
}, w = (g) => {
|
|
152
|
+
if (!s) return;
|
|
153
|
+
g.preventDefault();
|
|
154
|
+
const z = g.deltaY > 0 ? -o.step : o.step;
|
|
155
|
+
a.value = {
|
|
156
|
+
...a.value,
|
|
157
|
+
scale: d(a.value.scale + z)
|
|
158
|
+
};
|
|
159
|
+
}, S = () => {
|
|
160
|
+
p();
|
|
161
|
+
}, N = B(() => ({
|
|
162
|
+
transform: `translate(${a.value.translateX}px, ${a.value.translateY}px) scale(${a.value.scale})`,
|
|
163
|
+
transformOrigin: "center center",
|
|
164
|
+
transition: r.value ? "none" : "transform 0.2s ease-out",
|
|
165
|
+
cursor: l ? r.value ? "grabbing" : "grab" : "default"
|
|
166
|
+
}));
|
|
167
|
+
return $(() => {
|
|
168
|
+
l && (document.addEventListener("mousemove", x), document.addEventListener("mouseup", b));
|
|
169
|
+
}), F(() => {
|
|
170
|
+
l && (document.removeEventListener("mousemove", x), document.removeEventListener("mouseup", b));
|
|
171
|
+
}), {
|
|
172
|
+
state: a,
|
|
173
|
+
zoomIn: m,
|
|
174
|
+
zoomOut: i,
|
|
175
|
+
reset: p,
|
|
176
|
+
fitToContainer: f,
|
|
177
|
+
setScale: k,
|
|
178
|
+
canZoomIn: v,
|
|
179
|
+
canZoomOut: y,
|
|
180
|
+
contentStyle: N,
|
|
181
|
+
onMouseDown: I,
|
|
182
|
+
onWheel: w,
|
|
183
|
+
onDoubleClick: S
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
const de = C({
|
|
187
|
+
name: "ImageIcon",
|
|
188
|
+
setup() {
|
|
189
|
+
return () => e(
|
|
190
|
+
"svg",
|
|
191
|
+
{ viewBox: "0 0 24 24", fill: "currentColor" },
|
|
192
|
+
e("path", {
|
|
193
|
+
d: "M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z"
|
|
194
|
+
})
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
}), me = C({
|
|
198
|
+
name: "CodeIcon",
|
|
199
|
+
setup() {
|
|
200
|
+
return () => e(
|
|
201
|
+
"svg",
|
|
202
|
+
{ viewBox: "0 0 24 24", fill: "currentColor" },
|
|
203
|
+
e("path", {
|
|
204
|
+
d: "M9.4 16.6L4.8 12l4.6-4.6L8 6l-6 6 6 6 1.4-1.4zm5.2 0l4.6-4.6-4.6-4.6L16 6l6 6-6 6-1.4-1.4z"
|
|
205
|
+
})
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
}), K = C({
|
|
209
|
+
name: "ZoomInIcon",
|
|
210
|
+
setup() {
|
|
211
|
+
return () => e(
|
|
212
|
+
"svg",
|
|
213
|
+
{ viewBox: "0 0 24 24", fill: "currentColor" },
|
|
214
|
+
e("path", {
|
|
215
|
+
d: "M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14zm.5-7H9v2H7v1h2v2h1v-2h2V9h-2V7z"
|
|
216
|
+
})
|
|
217
|
+
);
|
|
218
|
+
}
|
|
219
|
+
}), G = C({
|
|
220
|
+
name: "ZoomOutIcon",
|
|
221
|
+
setup() {
|
|
222
|
+
return () => e(
|
|
223
|
+
"svg",
|
|
224
|
+
{ viewBox: "0 0 24 24", fill: "currentColor" },
|
|
225
|
+
e("path", {
|
|
226
|
+
d: "M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14zM7 9h5v1H7V9z"
|
|
227
|
+
})
|
|
228
|
+
);
|
|
229
|
+
}
|
|
230
|
+
}), _ = C({
|
|
231
|
+
name: "ResetIcon",
|
|
232
|
+
setup() {
|
|
233
|
+
return () => e(
|
|
234
|
+
"svg",
|
|
235
|
+
{ viewBox: "0 0 24 24", fill: "currentColor" },
|
|
236
|
+
e("path", {
|
|
237
|
+
d: "M12 5V1L7 6l5 5V7c3.31 0 6 2.69 6 6s-2.69 6-6 6-6-2.69-6-6H4c0 4.42 3.58 8 8 8s8-3.58 8-8-3.58-8-8-8z"
|
|
238
|
+
})
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
}), ve = C({
|
|
242
|
+
name: "FullscreenIcon",
|
|
243
|
+
setup() {
|
|
244
|
+
return () => e(
|
|
245
|
+
"svg",
|
|
246
|
+
{ viewBox: "0 0 24 24", fill: "currentColor" },
|
|
247
|
+
e("path", {
|
|
248
|
+
d: "M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z"
|
|
249
|
+
})
|
|
250
|
+
);
|
|
251
|
+
}
|
|
252
|
+
}), fe = C({
|
|
253
|
+
name: "FullscreenExitIcon",
|
|
254
|
+
setup() {
|
|
255
|
+
return () => e(
|
|
256
|
+
"svg",
|
|
257
|
+
{ viewBox: "0 0 24 24", fill: "currentColor" },
|
|
258
|
+
e("path", {
|
|
259
|
+
d: "M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z"
|
|
260
|
+
})
|
|
261
|
+
);
|
|
262
|
+
}
|
|
263
|
+
}), J = C({
|
|
264
|
+
name: "DownloadIcon",
|
|
265
|
+
setup() {
|
|
266
|
+
return () => e(
|
|
267
|
+
"svg",
|
|
268
|
+
{ viewBox: "0 0 24 24", fill: "currentColor" },
|
|
269
|
+
e("path", {
|
|
270
|
+
d: "M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z"
|
|
271
|
+
})
|
|
272
|
+
);
|
|
273
|
+
}
|
|
274
|
+
}), pe = C({
|
|
275
|
+
name: "CloseIcon",
|
|
276
|
+
setup() {
|
|
277
|
+
return () => e(
|
|
278
|
+
"svg",
|
|
279
|
+
{ viewBox: "0 0 24 24", fill: "currentColor" },
|
|
280
|
+
e("path", {
|
|
281
|
+
d: "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"
|
|
282
|
+
})
|
|
283
|
+
);
|
|
284
|
+
}
|
|
285
|
+
}), he = C({
|
|
286
|
+
name: "CopyIcon",
|
|
287
|
+
setup() {
|
|
288
|
+
return () => e(
|
|
289
|
+
"svg",
|
|
290
|
+
{ viewBox: "0 0 24 24", fill: "currentColor" },
|
|
291
|
+
e("path", {
|
|
292
|
+
d: "M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"
|
|
293
|
+
})
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
}), ye = C({
|
|
297
|
+
name: "CheckIcon",
|
|
298
|
+
setup() {
|
|
299
|
+
return () => e(
|
|
300
|
+
"svg",
|
|
301
|
+
{ viewBox: "0 0 24 24", fill: "currentColor" },
|
|
302
|
+
e("path", {
|
|
303
|
+
d: "M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"
|
|
304
|
+
})
|
|
305
|
+
);
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
C({
|
|
309
|
+
name: "FitIcon",
|
|
310
|
+
setup() {
|
|
311
|
+
return () => e(
|
|
312
|
+
"svg",
|
|
313
|
+
{ viewBox: "0 0 24 24", fill: "currentColor" },
|
|
314
|
+
e("path", {
|
|
315
|
+
d: "M3 5v4h2V5h4V3H5c-1.1 0-2 .9-2 2zm2 10H3v4c0 1.1.9 2 2 2h4v-2H5v-4zm14 4h-4v2h4c1.1 0 2-.9 2-2v-4h-2v4zm0-16h-4v2h4v4h2V5c0-1.1-.9-2-2-2z"
|
|
316
|
+
})
|
|
317
|
+
);
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
const ge = C({
|
|
321
|
+
name: "MermaidFullscreenViewer",
|
|
322
|
+
props: {
|
|
323
|
+
svg: {
|
|
324
|
+
type: String,
|
|
325
|
+
required: !0
|
|
326
|
+
},
|
|
327
|
+
open: {
|
|
328
|
+
type: Boolean,
|
|
329
|
+
required: !0
|
|
330
|
+
}
|
|
331
|
+
},
|
|
332
|
+
emits: ["close", "download"],
|
|
333
|
+
setup(t, { emit: n }) {
|
|
334
|
+
const l = h(null), s = h(null), o = h(null), a = h(!1), {
|
|
335
|
+
state: r,
|
|
336
|
+
zoomIn: c,
|
|
337
|
+
zoomOut: u,
|
|
338
|
+
reset: d,
|
|
339
|
+
fitToContainer: v,
|
|
340
|
+
canZoomIn: y,
|
|
341
|
+
canZoomOut: m,
|
|
342
|
+
contentStyle: i,
|
|
343
|
+
onMouseDown: p,
|
|
344
|
+
onWheel: k,
|
|
345
|
+
onDoubleClick: f
|
|
346
|
+
} = W({
|
|
347
|
+
enableDrag: !0,
|
|
348
|
+
enableWheelZoom: !0
|
|
349
|
+
}), I = async () => {
|
|
350
|
+
if (l.value)
|
|
351
|
+
try {
|
|
352
|
+
await l.value.requestFullscreen(), a.value = !0;
|
|
353
|
+
} catch {
|
|
354
|
+
a.value = !0;
|
|
355
|
+
}
|
|
356
|
+
}, x = () => {
|
|
357
|
+
document.fullscreenElement && document.exitFullscreen().catch(() => {
|
|
358
|
+
}), a.value = !1, n("close");
|
|
359
|
+
};
|
|
360
|
+
H(
|
|
361
|
+
() => t.open,
|
|
362
|
+
(N) => {
|
|
363
|
+
N ? I() : a.value && x();
|
|
364
|
+
}
|
|
365
|
+
);
|
|
366
|
+
const b = () => {
|
|
367
|
+
!document.fullscreenElement && a.value && (a.value = !1, n("close"));
|
|
368
|
+
}, w = (N) => {
|
|
369
|
+
if (a.value)
|
|
370
|
+
switch (N.key) {
|
|
371
|
+
case "+":
|
|
372
|
+
case "=":
|
|
373
|
+
c();
|
|
374
|
+
break;
|
|
375
|
+
case "-":
|
|
376
|
+
u();
|
|
377
|
+
break;
|
|
378
|
+
case "0":
|
|
379
|
+
d();
|
|
380
|
+
break;
|
|
381
|
+
}
|
|
382
|
+
};
|
|
383
|
+
$(() => {
|
|
384
|
+
document.addEventListener("fullscreenchange", b), document.addEventListener("keydown", w);
|
|
385
|
+
}), F(() => {
|
|
386
|
+
document.removeEventListener("fullscreenchange", b), document.removeEventListener("keydown", w);
|
|
387
|
+
});
|
|
388
|
+
const S = () => {
|
|
389
|
+
if (!s.value || !o.value) return;
|
|
390
|
+
const N = s.value.getBoundingClientRect(), g = o.value.querySelector("svg");
|
|
391
|
+
if (g) {
|
|
392
|
+
const z = g.getBoundingClientRect();
|
|
393
|
+
v(N, z);
|
|
394
|
+
}
|
|
395
|
+
};
|
|
396
|
+
return () => e(
|
|
397
|
+
"div",
|
|
398
|
+
{
|
|
399
|
+
ref: l,
|
|
400
|
+
class: [
|
|
401
|
+
"md-mermaid-fullscreen-wrapper",
|
|
402
|
+
a.value && "md-mermaid-fullscreen-wrapper--active"
|
|
403
|
+
],
|
|
404
|
+
role: "dialog",
|
|
405
|
+
"aria-modal": "true",
|
|
406
|
+
"aria-label": "Mermaid 图表全屏预览",
|
|
407
|
+
"aria-hidden": !a.value
|
|
408
|
+
},
|
|
409
|
+
a.value ? [
|
|
410
|
+
// 工具栏
|
|
411
|
+
e("div", { class: "md-mermaid-fullscreen-toolbar" }, [
|
|
412
|
+
e("div", { class: "md-mermaid-toolbar-group" }, [
|
|
413
|
+
e(
|
|
414
|
+
"button",
|
|
415
|
+
{
|
|
416
|
+
type: "button",
|
|
417
|
+
class: "md-mermaid-toolbar-btn",
|
|
418
|
+
onClick: u,
|
|
419
|
+
disabled: !m.value,
|
|
420
|
+
title: "缩小 (-)",
|
|
421
|
+
"aria-label": "缩小"
|
|
422
|
+
},
|
|
423
|
+
e(G)
|
|
424
|
+
),
|
|
425
|
+
e(
|
|
426
|
+
"span",
|
|
427
|
+
{ class: "md-mermaid-zoom-label" },
|
|
428
|
+
`${Math.round(r.value.scale * 100)}%`
|
|
429
|
+
),
|
|
430
|
+
e(
|
|
431
|
+
"button",
|
|
432
|
+
{
|
|
433
|
+
type: "button",
|
|
434
|
+
class: "md-mermaid-toolbar-btn",
|
|
435
|
+
onClick: c,
|
|
436
|
+
disabled: !y.value,
|
|
437
|
+
title: "放大 (+)",
|
|
438
|
+
"aria-label": "放大"
|
|
439
|
+
},
|
|
440
|
+
e(K)
|
|
441
|
+
),
|
|
442
|
+
e(
|
|
443
|
+
"button",
|
|
444
|
+
{
|
|
445
|
+
type: "button",
|
|
446
|
+
class: "md-mermaid-toolbar-btn",
|
|
447
|
+
onClick: d,
|
|
448
|
+
title: "重置 (0)",
|
|
449
|
+
"aria-label": "重置"
|
|
450
|
+
},
|
|
451
|
+
e(_)
|
|
452
|
+
),
|
|
453
|
+
e(
|
|
454
|
+
"button",
|
|
455
|
+
{
|
|
456
|
+
type: "button",
|
|
457
|
+
class: "md-mermaid-toolbar-btn",
|
|
458
|
+
onClick: S,
|
|
459
|
+
title: "适应窗口",
|
|
460
|
+
"aria-label": "适应窗口"
|
|
461
|
+
},
|
|
462
|
+
e(fe)
|
|
463
|
+
)
|
|
464
|
+
]),
|
|
465
|
+
e("div", { class: "md-mermaid-toolbar-group" }, [
|
|
466
|
+
e(
|
|
467
|
+
"button",
|
|
468
|
+
{
|
|
469
|
+
type: "button",
|
|
470
|
+
class: "md-mermaid-toolbar-btn",
|
|
471
|
+
onClick: () => n("download"),
|
|
472
|
+
title: "下载 PNG",
|
|
473
|
+
"aria-label": "下载"
|
|
474
|
+
},
|
|
475
|
+
e(J)
|
|
476
|
+
),
|
|
477
|
+
e(
|
|
478
|
+
"button",
|
|
479
|
+
{
|
|
480
|
+
type: "button",
|
|
481
|
+
class: "md-mermaid-toolbar-btn",
|
|
482
|
+
onClick: x,
|
|
483
|
+
title: "退出全屏 (Esc)",
|
|
484
|
+
"aria-label": "退出全屏"
|
|
485
|
+
},
|
|
486
|
+
e(pe)
|
|
487
|
+
)
|
|
488
|
+
])
|
|
489
|
+
]),
|
|
490
|
+
// 内容区域
|
|
491
|
+
e(
|
|
492
|
+
"div",
|
|
493
|
+
{
|
|
494
|
+
ref: s,
|
|
495
|
+
class: "md-mermaid-fullscreen-content",
|
|
496
|
+
onWheel: k
|
|
497
|
+
},
|
|
498
|
+
e("div", {
|
|
499
|
+
ref: o,
|
|
500
|
+
class: "md-mermaid-fullscreen-svg",
|
|
501
|
+
style: i.value,
|
|
502
|
+
onMousedown: p,
|
|
503
|
+
onDblclick: f,
|
|
504
|
+
innerHTML: t.svg
|
|
505
|
+
})
|
|
506
|
+
)
|
|
507
|
+
] : void 0
|
|
508
|
+
);
|
|
509
|
+
}
|
|
510
|
+
});
|
|
511
|
+
let E = null;
|
|
512
|
+
function be(t = "auto") {
|
|
513
|
+
return E ? E.setTheme(t ?? "auto") : E = new ne({ theme: t }), E;
|
|
514
|
+
}
|
|
515
|
+
async function Ce(t) {
|
|
516
|
+
try {
|
|
517
|
+
return await navigator.clipboard.writeText(t), !0;
|
|
518
|
+
} catch {
|
|
519
|
+
const n = document.createElement("textarea");
|
|
520
|
+
n.value = t, n.style.position = "fixed", n.style.left = "-9999px", document.body.appendChild(n), n.select();
|
|
521
|
+
try {
|
|
522
|
+
return document.execCommand("copy"), !0;
|
|
523
|
+
} catch {
|
|
524
|
+
return !1;
|
|
525
|
+
} finally {
|
|
526
|
+
document.body.removeChild(n);
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
const we = C({
|
|
531
|
+
name: "MermaidBlock",
|
|
532
|
+
props: {
|
|
533
|
+
code: {
|
|
534
|
+
type: String,
|
|
535
|
+
required: !0
|
|
536
|
+
},
|
|
537
|
+
theme: {
|
|
538
|
+
type: String,
|
|
539
|
+
default: "auto"
|
|
540
|
+
},
|
|
541
|
+
showToolbar: {
|
|
542
|
+
type: Boolean,
|
|
543
|
+
default: !0
|
|
544
|
+
}
|
|
545
|
+
},
|
|
546
|
+
emits: ["copy"],
|
|
547
|
+
setup(t, { emit: n }) {
|
|
548
|
+
const l = h("preview"), s = h(null), o = h(!0), a = h(!1), r = h(!1), c = h(te()), {
|
|
549
|
+
state: u,
|
|
550
|
+
zoomIn: d,
|
|
551
|
+
zoomOut: v,
|
|
552
|
+
reset: y,
|
|
553
|
+
canZoomIn: m,
|
|
554
|
+
canZoomOut: i,
|
|
555
|
+
contentStyle: p
|
|
556
|
+
} = W(), k = B(
|
|
557
|
+
() => {
|
|
558
|
+
var b;
|
|
559
|
+
return ((b = s.value) == null ? void 0 : b.success) && s.value.svg;
|
|
560
|
+
}
|
|
561
|
+
);
|
|
562
|
+
let f = null;
|
|
563
|
+
$(() => {
|
|
564
|
+
t.theme === "auto" && (f = ae((b) => {
|
|
565
|
+
c.value = b;
|
|
566
|
+
}));
|
|
567
|
+
}), F(() => {
|
|
568
|
+
f == null || f();
|
|
569
|
+
}), H(
|
|
570
|
+
() => [t.code, t.theme, c.value],
|
|
571
|
+
async () => {
|
|
572
|
+
o.value = !0;
|
|
573
|
+
const w = await be(t.theme).render(t.code);
|
|
574
|
+
s.value = w, o.value = !1, w.success || (l.value = "code");
|
|
575
|
+
},
|
|
576
|
+
{ immediate: !0 }
|
|
577
|
+
);
|
|
578
|
+
const I = async () => {
|
|
579
|
+
await Ce(t.code) && (r.value = !0, n("copy", t.code), setTimeout(() => r.value = !1, 2e3));
|
|
580
|
+
}, x = async () => {
|
|
581
|
+
var b, w;
|
|
582
|
+
if ((b = s.value) != null && b.svg)
|
|
583
|
+
try {
|
|
584
|
+
const S = ((w = window.matchMedia) == null ? void 0 : w.call(window, "(prefers-color-scheme: dark)").matches) ?? !1;
|
|
585
|
+
await le(s.value.svg, {
|
|
586
|
+
backgroundColor: S ? "#1a1a2e" : "#ffffff",
|
|
587
|
+
padding: 20,
|
|
588
|
+
scale: 2
|
|
589
|
+
});
|
|
590
|
+
} catch (S) {
|
|
591
|
+
console.error("Download failed:", S);
|
|
592
|
+
}
|
|
593
|
+
};
|
|
594
|
+
return () => {
|
|
595
|
+
const b = t.showToolbar ? e("div", { class: "md-mermaid-toolbar" }, [
|
|
596
|
+
// 模式切换
|
|
597
|
+
e("div", { class: "md-mermaid-toolbar-group md-mermaid-mode-switch" }, [
|
|
598
|
+
e(
|
|
599
|
+
"button",
|
|
600
|
+
{
|
|
601
|
+
type: "button",
|
|
602
|
+
class: `md-mermaid-toolbar-btn${l.value === "preview" ? " md-mermaid-toolbar-btn--active" : ""}`,
|
|
603
|
+
onClick: () => l.value = "preview",
|
|
604
|
+
disabled: !k.value,
|
|
605
|
+
title: "图片模式",
|
|
606
|
+
"aria-label": "图片模式"
|
|
607
|
+
},
|
|
608
|
+
e(de)
|
|
609
|
+
),
|
|
610
|
+
e(
|
|
611
|
+
"button",
|
|
612
|
+
{
|
|
613
|
+
type: "button",
|
|
614
|
+
class: `md-mermaid-toolbar-btn${l.value === "code" ? " md-mermaid-toolbar-btn--active" : ""}`,
|
|
615
|
+
onClick: () => l.value = "code",
|
|
616
|
+
title: "代码模式",
|
|
617
|
+
"aria-label": "代码模式"
|
|
618
|
+
},
|
|
619
|
+
e(me)
|
|
620
|
+
)
|
|
621
|
+
]),
|
|
622
|
+
// 缩放控制 - 仅图片模式显示
|
|
623
|
+
l.value === "preview" && k.value ? e("div", { class: "md-mermaid-toolbar-group" }, [
|
|
624
|
+
e(
|
|
625
|
+
"button",
|
|
626
|
+
{
|
|
627
|
+
type: "button",
|
|
628
|
+
class: "md-mermaid-toolbar-btn",
|
|
629
|
+
onClick: v,
|
|
630
|
+
disabled: !i.value,
|
|
631
|
+
title: "缩小",
|
|
632
|
+
"aria-label": "缩小"
|
|
633
|
+
},
|
|
634
|
+
e(G)
|
|
635
|
+
),
|
|
636
|
+
e(
|
|
637
|
+
"span",
|
|
638
|
+
{ class: "md-mermaid-zoom-label" },
|
|
639
|
+
`${Math.round(u.value.scale * 100)}%`
|
|
640
|
+
),
|
|
641
|
+
e(
|
|
642
|
+
"button",
|
|
643
|
+
{
|
|
644
|
+
type: "button",
|
|
645
|
+
class: "md-mermaid-toolbar-btn",
|
|
646
|
+
onClick: d,
|
|
647
|
+
disabled: !m.value,
|
|
648
|
+
title: "放大",
|
|
649
|
+
"aria-label": "放大"
|
|
650
|
+
},
|
|
651
|
+
e(K)
|
|
652
|
+
),
|
|
653
|
+
e(
|
|
654
|
+
"button",
|
|
655
|
+
{
|
|
656
|
+
type: "button",
|
|
657
|
+
class: "md-mermaid-toolbar-btn",
|
|
658
|
+
onClick: y,
|
|
659
|
+
title: "重置",
|
|
660
|
+
"aria-label": "重置缩放"
|
|
661
|
+
},
|
|
662
|
+
e(_)
|
|
663
|
+
)
|
|
664
|
+
]) : null,
|
|
665
|
+
// 操作按钮
|
|
666
|
+
e("div", { class: "md-mermaid-toolbar-group" }, [
|
|
667
|
+
l.value === "preview" && k.value ? [
|
|
668
|
+
e(
|
|
669
|
+
"button",
|
|
670
|
+
{
|
|
671
|
+
type: "button",
|
|
672
|
+
class: "md-mermaid-toolbar-btn",
|
|
673
|
+
onClick: () => a.value = !0,
|
|
674
|
+
title: "全屏",
|
|
675
|
+
"aria-label": "全屏查看"
|
|
676
|
+
},
|
|
677
|
+
e(ve)
|
|
678
|
+
),
|
|
679
|
+
e(
|
|
680
|
+
"button",
|
|
681
|
+
{
|
|
682
|
+
type: "button",
|
|
683
|
+
class: "md-mermaid-toolbar-btn",
|
|
684
|
+
onClick: x,
|
|
685
|
+
title: "下载 PNG",
|
|
686
|
+
"aria-label": "下载"
|
|
687
|
+
},
|
|
688
|
+
e(J)
|
|
689
|
+
)
|
|
690
|
+
] : null,
|
|
691
|
+
l.value === "code" ? e(
|
|
692
|
+
"button",
|
|
693
|
+
{
|
|
694
|
+
type: "button",
|
|
695
|
+
class: `md-mermaid-toolbar-btn${r.value ? " md-mermaid-toolbar-btn--success" : ""}`,
|
|
696
|
+
onClick: I,
|
|
697
|
+
title: r.value ? "已复制" : "复制代码",
|
|
698
|
+
"aria-label": r.value ? "已复制" : "复制代码"
|
|
699
|
+
},
|
|
700
|
+
r.value ? e(ye) : e(he)
|
|
701
|
+
) : null
|
|
702
|
+
])
|
|
703
|
+
]) : null;
|
|
704
|
+
let w;
|
|
705
|
+
return o.value ? w = e("div", { class: "md-mermaid-skeleton" }, [
|
|
706
|
+
e("div", { class: "md-mermaid-skeleton-box" })
|
|
707
|
+
]) : l.value === "preview" && k.value ? w = e("div", { class: "md-mermaid-preview", style: { overflow: "hidden" } }, [
|
|
708
|
+
e("div", {
|
|
709
|
+
class: "md-mermaid-svg-container",
|
|
710
|
+
style: p.value,
|
|
711
|
+
innerHTML: s.value.svg
|
|
712
|
+
})
|
|
713
|
+
]) : w = e("div", { class: "md-mermaid-code" }, [
|
|
714
|
+
e("pre", [e("code", { class: "language-mermaid" }, t.code)]),
|
|
715
|
+
s.value && !s.value.success ? e("div", { class: "md-mermaid-error" }, [
|
|
716
|
+
e("span", "渲染失败: "),
|
|
717
|
+
e("span", s.value.error)
|
|
718
|
+
]) : null
|
|
719
|
+
]), e("div", { class: "md-mermaid-block" }, [
|
|
720
|
+
b,
|
|
721
|
+
e("div", { class: "md-mermaid-content" }, [w]),
|
|
722
|
+
// 全屏查看器
|
|
723
|
+
k.value ? e(ge, {
|
|
724
|
+
svg: s.value.svg,
|
|
725
|
+
open: a.value,
|
|
726
|
+
onClose: () => a.value = !1,
|
|
727
|
+
onDownload: x
|
|
728
|
+
}) : null
|
|
729
|
+
]);
|
|
730
|
+
};
|
|
731
|
+
}
|
|
732
|
+
});
|
|
733
|
+
function ke(t) {
|
|
734
|
+
var s;
|
|
735
|
+
if (t.tagName !== "pre") return !1;
|
|
736
|
+
const n = t.children.find(
|
|
737
|
+
(o) => o.type === "element" && o.tagName === "code"
|
|
738
|
+
);
|
|
739
|
+
if (!n) return !1;
|
|
740
|
+
const l = (s = n.properties) == null ? void 0 : s.className;
|
|
741
|
+
return Array.isArray(l) ? l.some((o) => typeof o == "string" && o.includes("language-mermaid")) : typeof l == "string" && l.includes("language-mermaid");
|
|
742
|
+
}
|
|
743
|
+
function xe(t) {
|
|
744
|
+
const n = t.children.find(
|
|
745
|
+
(l) => l.type === "element" && l.tagName === "code"
|
|
746
|
+
);
|
|
747
|
+
return n ? n.children.map((l) => l.type === "text" ? l.value : "").join("") : "";
|
|
748
|
+
}
|
|
749
|
+
function Me(t) {
|
|
750
|
+
return t ? t === !0 ? { enabled: !0 } : t.enabled !== !1 ? t : null : null;
|
|
751
|
+
}
|
|
752
|
+
const Q = C({
|
|
17
753
|
name: "Markdown",
|
|
18
754
|
props: {
|
|
19
755
|
content: {
|
|
@@ -47,153 +783,194 @@ const q = M({
|
|
|
47
783
|
rehypePlugins: {
|
|
48
784
|
type: Array,
|
|
49
785
|
default: () => []
|
|
786
|
+
},
|
|
787
|
+
copyButton: {
|
|
788
|
+
type: Boolean,
|
|
789
|
+
default: !0
|
|
790
|
+
},
|
|
791
|
+
mermaid: {
|
|
792
|
+
type: [Boolean, Object],
|
|
793
|
+
default: !1
|
|
50
794
|
}
|
|
51
795
|
},
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
(
|
|
56
|
-
|
|
796
|
+
emits: ["codeCopy"],
|
|
797
|
+
setup(t, { emit: n }) {
|
|
798
|
+
H(
|
|
799
|
+
() => t.math,
|
|
800
|
+
(o) => {
|
|
801
|
+
o && Y();
|
|
57
802
|
},
|
|
58
803
|
{ immediate: !0 }
|
|
59
804
|
);
|
|
60
|
-
function
|
|
61
|
-
if (
|
|
62
|
-
return
|
|
63
|
-
if (
|
|
805
|
+
function l(o, a = {}, r = null) {
|
|
806
|
+
if (o.type === "text")
|
|
807
|
+
return o.value;
|
|
808
|
+
if (o.type === "comment")
|
|
64
809
|
return null;
|
|
65
|
-
if (
|
|
66
|
-
const
|
|
67
|
-
return
|
|
810
|
+
if (o.type === "root") {
|
|
811
|
+
const c = o.children.map((u) => l(u, a, r)).filter((u) => u !== null);
|
|
812
|
+
return e("div", { class: t.class }, c);
|
|
68
813
|
}
|
|
69
|
-
if (
|
|
70
|
-
const { tagName:
|
|
71
|
-
if (
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
814
|
+
if (o.type === "element") {
|
|
815
|
+
const { tagName: c, properties: u, children: d } = o;
|
|
816
|
+
if (r && ke(o)) {
|
|
817
|
+
const i = xe(o);
|
|
818
|
+
return e(we, {
|
|
819
|
+
code: i,
|
|
820
|
+
theme: r.theme,
|
|
821
|
+
onCopy: (p) => n("codeCopy", p)
|
|
822
|
+
});
|
|
823
|
+
}
|
|
824
|
+
const v = a[c] || c, y = {};
|
|
825
|
+
if (u)
|
|
826
|
+
for (const [i, p] of Object.entries(u))
|
|
827
|
+
i === "className" ? y.class = Array.isArray(p) ? p.join(" ") : p : y[i] = p;
|
|
828
|
+
const m = d.map((i) => l(i, a, r)).filter((i) => i !== null);
|
|
829
|
+
return typeof v == "string" ? e(v, y, m) : e(v, y, () => m);
|
|
76
830
|
}
|
|
77
831
|
return null;
|
|
78
832
|
}
|
|
79
|
-
const
|
|
80
|
-
if (!
|
|
81
|
-
const
|
|
82
|
-
gfm:
|
|
83
|
-
highlight:
|
|
84
|
-
math:
|
|
85
|
-
remarkPlugins:
|
|
86
|
-
rehypePlugins:
|
|
87
|
-
})
|
|
88
|
-
|
|
833
|
+
const s = B(() => {
|
|
834
|
+
if (!t.content) return null;
|
|
835
|
+
const o = j(t.content, {
|
|
836
|
+
gfm: t.gfm,
|
|
837
|
+
highlight: t.highlight,
|
|
838
|
+
math: t.math,
|
|
839
|
+
remarkPlugins: t.remarkPlugins,
|
|
840
|
+
rehypePlugins: t.rehypePlugins
|
|
841
|
+
}), a = Me(t.mermaid), r = {
|
|
842
|
+
...t.copyButton ? {
|
|
843
|
+
pre: C({
|
|
844
|
+
setup(c, { slots: u }) {
|
|
845
|
+
return () => e(
|
|
846
|
+
q,
|
|
847
|
+
{
|
|
848
|
+
showCopyButton: t.copyButton,
|
|
849
|
+
onCopy: (d) => n("codeCopy", d)
|
|
850
|
+
},
|
|
851
|
+
u.default
|
|
852
|
+
);
|
|
853
|
+
}
|
|
854
|
+
})
|
|
855
|
+
} : {},
|
|
856
|
+
...t.components
|
|
857
|
+
};
|
|
858
|
+
return l(o, r, a);
|
|
89
859
|
});
|
|
90
|
-
return () =>
|
|
860
|
+
return () => s.value ? s.value : null;
|
|
91
861
|
}
|
|
92
862
|
});
|
|
93
|
-
function
|
|
94
|
-
if (
|
|
95
|
-
return
|
|
96
|
-
if (
|
|
97
|
-
const
|
|
98
|
-
return
|
|
863
|
+
function D(t, n) {
|
|
864
|
+
if (t.type === "text")
|
|
865
|
+
return t.value;
|
|
866
|
+
if (t.type === "root") {
|
|
867
|
+
const l = t.children.map((s) => D(s, n)).filter((s) => s !== null);
|
|
868
|
+
return e("div", {}, l);
|
|
99
869
|
}
|
|
100
|
-
if (
|
|
101
|
-
const
|
|
870
|
+
if (t.type === "element") {
|
|
871
|
+
const l = t, s = l.tagName, o = n == null ? void 0 : n[s], a = { ...l.properties };
|
|
102
872
|
a.className && (a.class = Array.isArray(a.className) ? a.className.join(" ") : a.className, delete a.className);
|
|
103
|
-
const
|
|
104
|
-
return
|
|
873
|
+
const r = l.children.map((c) => D(c, n)).filter((c) => c !== null);
|
|
874
|
+
return o ? e(o, a, () => r) : e(s, a, r);
|
|
105
875
|
}
|
|
106
876
|
return null;
|
|
107
877
|
}
|
|
108
|
-
function
|
|
878
|
+
function Ne(t = {}) {
|
|
109
879
|
const {
|
|
110
|
-
components:
|
|
111
|
-
minUpdateInterval:
|
|
112
|
-
immediate:
|
|
113
|
-
outputRate:
|
|
880
|
+
components: n,
|
|
881
|
+
minUpdateInterval: l = 16,
|
|
882
|
+
immediate: s = !1,
|
|
883
|
+
outputRate: o = "medium",
|
|
114
884
|
...a
|
|
115
|
-
} =
|
|
116
|
-
let
|
|
117
|
-
const
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
|
|
885
|
+
} = t, r = P(a), c = new U(o), u = h(0), d = h(!1), v = h(0), y = h("idle");
|
|
886
|
+
let m = 0, i = null;
|
|
887
|
+
const p = () => {
|
|
888
|
+
const M = performance.now(), V = M - m;
|
|
889
|
+
s || V >= l ? (m = M, u.value++) : i === null && (i = requestAnimationFrame(() => {
|
|
890
|
+
i = null, m = performance.now(), u.value++;
|
|
121
891
|
}));
|
|
122
|
-
},
|
|
123
|
-
|
|
124
|
-
},
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
(
|
|
128
|
-
|
|
892
|
+
}, k = (M) => {
|
|
893
|
+
r.append(M), p();
|
|
894
|
+
}, f = (M) => {
|
|
895
|
+
r.reset(), d.value = !1, v.value = 0, y.value = "running", c.start(
|
|
896
|
+
M,
|
|
897
|
+
(V) => {
|
|
898
|
+
V && r.append(V), v.value = c.progress, p();
|
|
129
899
|
},
|
|
130
900
|
() => {
|
|
131
|
-
|
|
901
|
+
r.finish(), d.value = !0, v.value = 1, y.value = "complete", p();
|
|
132
902
|
}
|
|
133
903
|
);
|
|
904
|
+
}, I = () => {
|
|
905
|
+
c.pause(), y.value = c.status;
|
|
134
906
|
}, x = () => {
|
|
135
|
-
|
|
907
|
+
c.resume(), y.value = c.status;
|
|
908
|
+
}, b = () => {
|
|
909
|
+
c.skipToEnd(), y.value = c.status, v.value = 1;
|
|
136
910
|
}, w = () => {
|
|
137
|
-
|
|
138
|
-
},
|
|
139
|
-
|
|
140
|
-
}, K = () => {
|
|
141
|
-
i.stop(), l.finish(), f.value = !0, m.value = "complete", o !== null && (cancelAnimationFrame(o), o = null), u.value++;
|
|
142
|
-
}, L = () => {
|
|
143
|
-
i.stop(), l.reset(), f.value = !1, d.value = 0, m.value = "idle", o !== null && (cancelAnimationFrame(o), o = null), u.value++;
|
|
911
|
+
c.stop(), r.finish(), d.value = !0, y.value = "complete", i !== null && (cancelAnimationFrame(i), i = null), u.value++;
|
|
912
|
+
}, S = () => {
|
|
913
|
+
c.stop(), r.reset(), d.value = !1, v.value = 0, y.value = "idle", i !== null && (cancelAnimationFrame(i), i = null), u.value++;
|
|
144
914
|
};
|
|
145
|
-
|
|
146
|
-
|
|
915
|
+
F(() => {
|
|
916
|
+
c.stop(), i !== null && cancelAnimationFrame(i);
|
|
147
917
|
});
|
|
148
|
-
const
|
|
918
|
+
const N = B(() => (u.value, r.getState().blocks)), g = B(() => (u.value, r.getStats())), z = B(() => (u.value, r.getContent()));
|
|
149
919
|
return {
|
|
150
|
-
vnode:
|
|
920
|
+
vnode: B(() => {
|
|
151
921
|
u.value;
|
|
152
|
-
const
|
|
153
|
-
if (
|
|
922
|
+
const M = r.getState();
|
|
923
|
+
if (M.blocks.length === 0)
|
|
154
924
|
return null;
|
|
155
|
-
const
|
|
925
|
+
const V = M.blocks.map((L) => L.hast ? e(
|
|
156
926
|
"div",
|
|
157
927
|
{
|
|
158
|
-
key:
|
|
159
|
-
"data-block-key":
|
|
160
|
-
"data-pending": !
|
|
928
|
+
key: L.key,
|
|
929
|
+
"data-block-key": L.key,
|
|
930
|
+
"data-pending": !L.stable || void 0
|
|
161
931
|
},
|
|
162
|
-
[
|
|
163
|
-
) : null).filter((
|
|
164
|
-
return
|
|
932
|
+
[D(L.hast, n)]
|
|
933
|
+
) : null).filter((L) => L !== null);
|
|
934
|
+
return e("div", { "data-streaming": !d.value }, V);
|
|
165
935
|
}),
|
|
166
|
-
append:
|
|
167
|
-
start:
|
|
168
|
-
pause:
|
|
169
|
-
resume:
|
|
170
|
-
skipToEnd:
|
|
171
|
-
reset:
|
|
172
|
-
finish:
|
|
173
|
-
blocks:
|
|
174
|
-
stats:
|
|
175
|
-
isComplete:
|
|
176
|
-
content:
|
|
177
|
-
progress:
|
|
178
|
-
outputStatus:
|
|
936
|
+
append: k,
|
|
937
|
+
start: f,
|
|
938
|
+
pause: I,
|
|
939
|
+
resume: x,
|
|
940
|
+
skipToEnd: b,
|
|
941
|
+
reset: S,
|
|
942
|
+
finish: w,
|
|
943
|
+
blocks: N,
|
|
944
|
+
stats: g,
|
|
945
|
+
isComplete: d,
|
|
946
|
+
content: z,
|
|
947
|
+
progress: v,
|
|
948
|
+
outputStatus: y
|
|
179
949
|
};
|
|
180
950
|
}
|
|
181
|
-
function
|
|
182
|
-
if (
|
|
183
|
-
return
|
|
184
|
-
if (
|
|
185
|
-
const
|
|
186
|
-
return
|
|
951
|
+
function R(t, n, l, s, o) {
|
|
952
|
+
if (t.type === "text")
|
|
953
|
+
return t.value;
|
|
954
|
+
if (t.type === "root") {
|
|
955
|
+
const a = t.children.map((r) => R(r, n, l, s, o)).filter((r) => r !== null);
|
|
956
|
+
return e("div", {}, a);
|
|
187
957
|
}
|
|
188
|
-
if (
|
|
189
|
-
const
|
|
190
|
-
|
|
191
|
-
const
|
|
192
|
-
return
|
|
958
|
+
if (t.type === "element") {
|
|
959
|
+
const a = t, r = a.tagName, c = n == null ? void 0 : n[r], u = { ...a.properties };
|
|
960
|
+
u.className && (u.class = Array.isArray(u.className) ? u.className.join(" ") : u.className, delete u.className);
|
|
961
|
+
const d = a.children.map((v) => R(v, n, l, s, o)).filter((v) => v !== null);
|
|
962
|
+
return r === "pre" && l && !c ? e(
|
|
963
|
+
q,
|
|
964
|
+
{
|
|
965
|
+
showCopyButton: o && l,
|
|
966
|
+
onCopy: s
|
|
967
|
+
},
|
|
968
|
+
() => d
|
|
969
|
+
) : c ? e(c, u, () => d) : e(r, u, d);
|
|
193
970
|
}
|
|
194
971
|
return null;
|
|
195
972
|
}
|
|
196
|
-
const
|
|
973
|
+
const ee = C({
|
|
197
974
|
name: "StreamingMarkdown",
|
|
198
975
|
props: {
|
|
199
976
|
content: {
|
|
@@ -239,141 +1016,149 @@ const E = M({
|
|
|
239
1016
|
math: {
|
|
240
1017
|
type: Boolean,
|
|
241
1018
|
default: !1
|
|
1019
|
+
},
|
|
1020
|
+
copyButton: {
|
|
1021
|
+
type: Boolean,
|
|
1022
|
+
default: !0
|
|
242
1023
|
}
|
|
243
1024
|
},
|
|
244
|
-
emits: ["complete", "blockStable", "progress"],
|
|
245
|
-
setup(
|
|
246
|
-
|
|
247
|
-
() =>
|
|
248
|
-
(
|
|
249
|
-
|
|
1025
|
+
emits: ["complete", "blockStable", "progress", "codeCopy"],
|
|
1026
|
+
setup(t, { emit: n }) {
|
|
1027
|
+
H(
|
|
1028
|
+
() => t.math,
|
|
1029
|
+
(m) => {
|
|
1030
|
+
m && Y();
|
|
250
1031
|
},
|
|
251
1032
|
{ immediate: !0 }
|
|
252
1033
|
);
|
|
253
|
-
const
|
|
254
|
-
gfm:
|
|
255
|
-
highlight:
|
|
256
|
-
math:
|
|
257
|
-
}),
|
|
258
|
-
let
|
|
259
|
-
const
|
|
260
|
-
const
|
|
261
|
-
|
|
262
|
-
|
|
1034
|
+
const l = P({
|
|
1035
|
+
gfm: t.gfm,
|
|
1036
|
+
highlight: t.highlight,
|
|
1037
|
+
math: t.math
|
|
1038
|
+
}), s = new U(t.outputRate), o = h(0), a = h(""), r = h(void 0), c = h([]), u = h(!1);
|
|
1039
|
+
let d = 0, v = null;
|
|
1040
|
+
const y = () => {
|
|
1041
|
+
const m = performance.now();
|
|
1042
|
+
m - d >= t.minUpdateInterval ? (d = m, o.value++) : v === null && (v = requestAnimationFrame(() => {
|
|
1043
|
+
v = null, d = performance.now(), o.value++;
|
|
263
1044
|
}));
|
|
264
1045
|
};
|
|
265
|
-
return
|
|
266
|
-
() =>
|
|
267
|
-
(
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
(
|
|
271
|
-
|
|
1046
|
+
return H(
|
|
1047
|
+
() => t.source,
|
|
1048
|
+
(m) => {
|
|
1049
|
+
m !== void 0 && m !== r.value && (r.value = m, t.autoStart && m && (l.reset(), a.value = "", u.value = !1, s.start(
|
|
1050
|
+
m,
|
|
1051
|
+
(i) => {
|
|
1052
|
+
i && (l.append(i), a.value += i), n("progress", s.progress), y();
|
|
272
1053
|
},
|
|
273
1054
|
() => {
|
|
274
|
-
|
|
1055
|
+
l.finish(), u.value = !0, n("complete"), y();
|
|
275
1056
|
}
|
|
276
1057
|
)));
|
|
277
1058
|
},
|
|
278
1059
|
{ immediate: !0 }
|
|
279
|
-
),
|
|
280
|
-
() =>
|
|
281
|
-
(
|
|
282
|
-
if (
|
|
1060
|
+
), H(
|
|
1061
|
+
() => t.content,
|
|
1062
|
+
(m) => {
|
|
1063
|
+
if (t.source !== void 0)
|
|
283
1064
|
return;
|
|
284
|
-
const
|
|
285
|
-
if (
|
|
286
|
-
if (
|
|
287
|
-
const
|
|
288
|
-
|
|
1065
|
+
const i = a.value, p = m || "";
|
|
1066
|
+
if (p !== i) {
|
|
1067
|
+
if (p.startsWith(i)) {
|
|
1068
|
+
const f = p.slice(i.length);
|
|
1069
|
+
f && l.append(f);
|
|
289
1070
|
} else
|
|
290
|
-
|
|
291
|
-
a.value =
|
|
292
|
-
const
|
|
293
|
-
|
|
294
|
-
const
|
|
295
|
-
|
|
296
|
-
}),
|
|
1071
|
+
l.reset(), p && l.append(p);
|
|
1072
|
+
a.value = p, y();
|
|
1073
|
+
const k = l.getState().blocks;
|
|
1074
|
+
k.forEach((f, I) => {
|
|
1075
|
+
const x = c.value[I];
|
|
1076
|
+
f.stable && (!x || !x.stable) && n("blockStable", f);
|
|
1077
|
+
}), c.value = k;
|
|
297
1078
|
}
|
|
298
1079
|
},
|
|
299
1080
|
{ immediate: !0 }
|
|
300
|
-
),
|
|
301
|
-
() =>
|
|
302
|
-
(
|
|
303
|
-
|
|
1081
|
+
), H(
|
|
1082
|
+
() => t.isComplete,
|
|
1083
|
+
(m) => {
|
|
1084
|
+
t.source === void 0 && m && (l.finish(), v !== null && (cancelAnimationFrame(v), v = null), o.value++, n("complete"));
|
|
304
1085
|
}
|
|
305
|
-
),
|
|
306
|
-
() =>
|
|
307
|
-
(
|
|
308
|
-
|
|
1086
|
+
), H(
|
|
1087
|
+
() => t.outputRate,
|
|
1088
|
+
(m) => {
|
|
1089
|
+
s.setRate(m);
|
|
309
1090
|
}
|
|
310
|
-
),
|
|
311
|
-
|
|
1091
|
+
), F(() => {
|
|
1092
|
+
s.stop(), v !== null && cancelAnimationFrame(v);
|
|
312
1093
|
}), () => {
|
|
313
|
-
|
|
314
|
-
const
|
|
1094
|
+
o.value;
|
|
1095
|
+
const m = l.getState(), i = t.source !== void 0 ? u.value : t.isComplete, p = (f) => n("codeCopy", f), k = m.blocks.map((f) => f.hast ? e(
|
|
315
1096
|
"div",
|
|
316
1097
|
{
|
|
317
|
-
key:
|
|
318
|
-
"data-block-key":
|
|
319
|
-
"data-pending": !
|
|
1098
|
+
key: f.key,
|
|
1099
|
+
"data-block-key": f.key,
|
|
1100
|
+
"data-pending": !f.stable || void 0
|
|
320
1101
|
},
|
|
321
|
-
[
|
|
322
|
-
) : null).filter((
|
|
323
|
-
return
|
|
1102
|
+
[R(f.hast, t.components, t.copyButton, p, f.stable)]
|
|
1103
|
+
) : null).filter((f) => f !== null);
|
|
1104
|
+
return e(
|
|
324
1105
|
"div",
|
|
325
1106
|
{
|
|
326
|
-
class:
|
|
327
|
-
"data-streaming": !
|
|
1107
|
+
class: t.class,
|
|
1108
|
+
"data-streaming": !i
|
|
328
1109
|
},
|
|
329
|
-
|
|
1110
|
+
k
|
|
330
1111
|
);
|
|
331
1112
|
};
|
|
332
1113
|
}
|
|
333
1114
|
});
|
|
334
|
-
function
|
|
335
|
-
if (
|
|
336
|
-
return
|
|
337
|
-
if (
|
|
1115
|
+
function Z(t, n = {}) {
|
|
1116
|
+
if (t.type === "text")
|
|
1117
|
+
return t.value;
|
|
1118
|
+
if (t.type === "comment")
|
|
338
1119
|
return null;
|
|
339
|
-
if (
|
|
340
|
-
const
|
|
341
|
-
return
|
|
1120
|
+
if (t.type === "root") {
|
|
1121
|
+
const l = t.children.map((s) => Z(s, n)).filter((s) => s !== null);
|
|
1122
|
+
return e("div", {}, l);
|
|
342
1123
|
}
|
|
343
|
-
if (
|
|
344
|
-
const { tagName:
|
|
345
|
-
if (
|
|
346
|
-
for (const [u,
|
|
347
|
-
u === "className" ?
|
|
348
|
-
const
|
|
349
|
-
return
|
|
1124
|
+
if (t.type === "element") {
|
|
1125
|
+
const { tagName: l, properties: s, children: o } = t, a = n[l] || l, r = {};
|
|
1126
|
+
if (s)
|
|
1127
|
+
for (const [u, d] of Object.entries(s))
|
|
1128
|
+
u === "className" ? r.class = Array.isArray(d) ? d.join(" ") : d : r[u] = d;
|
|
1129
|
+
const c = o.map((u) => Z(u, n)).filter((u) => u !== null);
|
|
1130
|
+
return e(a, r, () => c);
|
|
350
1131
|
}
|
|
351
1132
|
return null;
|
|
352
1133
|
}
|
|
353
|
-
function
|
|
354
|
-
const { components:
|
|
355
|
-
return
|
|
356
|
-
const
|
|
357
|
-
if (!
|
|
358
|
-
const a =
|
|
359
|
-
return
|
|
1134
|
+
function Ve(t, n = {}) {
|
|
1135
|
+
const { components: l = {}, ...s } = n;
|
|
1136
|
+
return B(() => {
|
|
1137
|
+
const o = t();
|
|
1138
|
+
if (!o) return null;
|
|
1139
|
+
const a = j(o, s);
|
|
1140
|
+
return Z(a, l);
|
|
360
1141
|
});
|
|
361
1142
|
}
|
|
362
|
-
function
|
|
363
|
-
|
|
1143
|
+
function ze(t) {
|
|
1144
|
+
t.component("Markdown", Q), t.component("StreamingMarkdown", ee);
|
|
364
1145
|
}
|
|
365
|
-
const
|
|
366
|
-
install:
|
|
367
|
-
Markdown:
|
|
368
|
-
StreamingMarkdown:
|
|
1146
|
+
const He = {
|
|
1147
|
+
install: ze,
|
|
1148
|
+
Markdown: Q,
|
|
1149
|
+
StreamingMarkdown: ee
|
|
369
1150
|
};
|
|
370
1151
|
export {
|
|
371
|
-
q as
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
1152
|
+
q as CodeBlock,
|
|
1153
|
+
Q as Markdown,
|
|
1154
|
+
we as MermaidBlock,
|
|
1155
|
+
ge as MermaidFullscreenViewer,
|
|
1156
|
+
ee as StreamingMarkdown,
|
|
1157
|
+
He as default,
|
|
1158
|
+
ze as install,
|
|
1159
|
+
Se as isKatexCssLoaded,
|
|
1160
|
+
Y as preloadKatexCss,
|
|
1161
|
+
Ve as useMarkdown,
|
|
1162
|
+
Ne as useStreamingMarkdown,
|
|
1163
|
+
W as useZoom
|
|
379
1164
|
};
|