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