@superlc/md-vue 0.1.1 → 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/index.js CHANGED
@@ -1,63 +1,63 @@
1
- import { defineComponent as A, ref as h, h as f, watch as w, computed as B, onUnmounted as U } from "vue";
2
- import { parseToHast as P, createStreamingParser as F, OutputRateController as O } from "@superlc/md-core";
3
- let T = !1, x = null;
4
- async function D() {
5
- if (!T)
6
- return x || (x = (async () => {
7
- await import("katex/dist/katex.min.css"), T = !0;
8
- })(), x);
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 ne() {
11
- return T;
10
+ function Se() {
11
+ return O;
12
12
  }
13
- function R() {
14
- return D();
13
+ function Y() {
14
+ return oe();
15
15
  }
16
- async function G(e) {
16
+ async function re(t) {
17
17
  try {
18
- return await navigator.clipboard.writeText(e), !0;
18
+ return await navigator.clipboard.writeText(t), !0;
19
19
  } catch {
20
- return J(e);
20
+ return se(t);
21
21
  }
22
22
  }
23
- function J(e) {
24
- const t = document.createElement("textarea");
25
- t.value = e, t.style.position = "fixed", t.style.left = "-9999px", document.body.appendChild(t), t.select();
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
26
  try {
27
27
  return document.execCommand("copy"), !0;
28
28
  } catch {
29
29
  return !1;
30
30
  } finally {
31
- document.body.removeChild(t);
31
+ document.body.removeChild(n);
32
32
  }
33
33
  }
34
- const Q = () => f(
34
+ const ue = () => e(
35
35
  "svg",
36
36
  {
37
37
  viewBox: "0 0 24 24",
38
38
  fill: "currentColor"
39
39
  },
40
40
  [
41
- f("path", {
41
+ e("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
- ), X = () => f(
45
+ ), ce = () => e(
46
46
  "svg",
47
47
  {
48
48
  viewBox: "0 0 24 24",
49
49
  fill: "currentColor"
50
50
  },
51
51
  [
52
- f("path", {
52
+ e("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 I(e) {
58
- return typeof e == "string" ? e : Array.isArray(e) ? e.map((t) => typeof t == "string" ? t : t && typeof t == "object" && "children" in t ? I(t.children) : "").join("") : "";
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
59
  }
60
- const L = A({
60
+ const q = C({
61
61
  name: "CodeBlock",
62
62
  props: {
63
63
  showCopyButton: {
@@ -66,34 +66,690 @@ const L = A({
66
66
  }
67
67
  },
68
68
  emits: ["copy"],
69
- setup(e, { slots: t, emit: l }) {
70
- const a = h(!1), u = async () => {
71
- var o;
72
- const r = (o = t.default) == null ? void 0 : o.call(t), n = r ? I(r) : "";
73
- await G(n) && (a.value = !0, l("copy", n), setTimeout(() => {
74
- a.value = !1;
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
75
  }, 2e3));
76
76
  };
77
77
  return () => {
78
- var n;
79
- const r = (n = t.default) == null ? void 0 : n.call(t);
80
- return f("div", { class: "md-code-block-wrapper" }, [
81
- f("pre", {}, r),
82
- e.showCopyButton && f(
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
83
  "button",
84
84
  {
85
85
  type: "button",
86
- class: `md-copy-button${a.value ? " md-copy-button--copied" : ""}`,
87
- onClick: u,
88
- title: a.value ? "已复制" : "复制代码",
89
- "aria-label": a.value ? "已复制" : "复制代码"
86
+ class: `md-copy-button${s.value ? " md-copy-button--copied" : ""}`,
87
+ onClick: o,
88
+ title: s.value ? "已复制" : "复制代码",
89
+ "aria-label": s.value ? "已复制" : "复制代码"
90
90
  },
91
- [a.value ? f(X) : f(Q)]
91
+ [s.value ? e(ce) : e(ue)]
92
92
  )
93
93
  ]);
94
94
  };
95
95
  }
96
- }), z = A({
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({
97
753
  name: "Markdown",
98
754
  props: {
99
755
  content: {
@@ -131,177 +787,190 @@ const L = A({
131
787
  copyButton: {
132
788
  type: Boolean,
133
789
  default: !0
790
+ },
791
+ mermaid: {
792
+ type: [Boolean, Object],
793
+ default: !1
134
794
  }
135
795
  },
136
796
  emits: ["codeCopy"],
137
- setup(e, { emit: t }) {
138
- w(
139
- () => e.math,
140
- (u) => {
141
- u && R();
797
+ setup(t, { emit: n }) {
798
+ H(
799
+ () => t.math,
800
+ (o) => {
801
+ o && Y();
142
802
  },
143
803
  { immediate: !0 }
144
804
  );
145
- function l(u, r = {}) {
146
- if (u.type === "text")
147
- return u.value;
148
- if (u.type === "comment")
805
+ function l(o, a = {}, r = null) {
806
+ if (o.type === "text")
807
+ return o.value;
808
+ if (o.type === "comment")
149
809
  return null;
150
- if (u.type === "root") {
151
- const n = u.children.map((s) => l(s, r)).filter((s) => s !== null);
152
- return f("div", { class: e.class }, n);
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);
153
813
  }
154
- if (u.type === "element") {
155
- const { tagName: n, properties: s, children: o } = u, m = r[n] || n, d = {};
156
- if (s)
157
- for (const [i, c] of Object.entries(s))
158
- i === "className" ? d.class = Array.isArray(c) ? c.join(" ") : c : d[i] = c;
159
- const v = o.map((i) => l(i, r)).filter((i) => i !== null);
160
- return typeof m == "string" ? f(m, d, v) : f(m, d, () => v);
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);
161
830
  }
162
831
  return null;
163
832
  }
164
- const a = B(() => {
165
- if (!e.content) return null;
166
- const u = P(e.content, {
167
- gfm: e.gfm,
168
- highlight: e.highlight,
169
- math: e.math,
170
- remarkPlugins: e.remarkPlugins,
171
- rehypePlugins: e.rehypePlugins
172
- }), r = {
173
- ...e.copyButton ? {
174
- pre: A({
175
- setup(n, { slots: s }) {
176
- return () => f(
177
- L,
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,
178
847
  {
179
- showCopyButton: e.copyButton,
180
- onCopy: (o) => t("codeCopy", o)
848
+ showCopyButton: t.copyButton,
849
+ onCopy: (d) => n("codeCopy", d)
181
850
  },
182
- s.default
851
+ u.default
183
852
  );
184
853
  }
185
854
  })
186
855
  } : {},
187
- ...e.components
856
+ ...t.components
188
857
  };
189
- return l(u, r);
858
+ return l(o, r, a);
190
859
  });
191
- return () => a.value ? a.value : null;
860
+ return () => s.value ? s.value : null;
192
861
  }
193
862
  });
194
- function j(e, t) {
195
- if (e.type === "text")
196
- return e.value;
197
- if (e.type === "root") {
198
- const l = e.children.map((a) => j(a, t)).filter((a) => a !== null);
199
- return f("div", {}, l);
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);
200
869
  }
201
- if (e.type === "element") {
202
- const l = e, a = l.tagName, u = t == null ? void 0 : t[a], r = { ...l.properties };
203
- r.className && (r.class = Array.isArray(r.className) ? r.className.join(" ") : r.className, delete r.className);
204
- const n = l.children.map((s) => j(s, t)).filter((s) => s !== null);
205
- return u ? f(u, r, () => n) : f(a, r, n);
870
+ if (t.type === "element") {
871
+ const l = t, s = l.tagName, o = n == null ? void 0 : n[s], a = { ...l.properties };
872
+ a.className && (a.class = Array.isArray(a.className) ? a.className.join(" ") : a.className, delete a.className);
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);
206
875
  }
207
876
  return null;
208
877
  }
209
- function ae(e = {}) {
878
+ function Ne(t = {}) {
210
879
  const {
211
- components: t,
880
+ components: n,
212
881
  minUpdateInterval: l = 16,
213
- immediate: a = !1,
214
- outputRate: u = "medium",
215
- ...r
216
- } = e, n = F(r), s = new O(u), o = h(0), m = h(!1), d = h(0), v = h("idle");
217
- let i = 0, c = null;
218
- const y = () => {
219
- const g = performance.now(), N = g - i;
220
- a || N >= l ? (i = g, o.value++) : c === null && (c = requestAnimationFrame(() => {
221
- c = null, i = performance.now(), o.value++;
882
+ immediate: s = !1,
883
+ outputRate: o = "medium",
884
+ ...a
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++;
222
891
  }));
223
- }, k = (g) => {
224
- n.append(g), y();
225
- }, p = (g) => {
226
- n.reset(), m.value = !1, d.value = 0, v.value = "running", s.start(
227
- g,
228
- (N) => {
229
- N && n.append(N), d.value = s.progress, y();
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();
230
899
  },
231
900
  () => {
232
- n.finish(), m.value = !0, d.value = 1, v.value = "complete", y();
901
+ r.finish(), d.value = !0, v.value = 1, y.value = "complete", p();
233
902
  }
234
903
  );
235
- }, S = () => {
236
- s.pause(), v.value = s.status;
904
+ }, I = () => {
905
+ c.pause(), y.value = c.status;
906
+ }, x = () => {
907
+ c.resume(), y.value = c.status;
237
908
  }, b = () => {
238
- s.resume(), v.value = s.status;
239
- }, H = () => {
240
- s.skipToEnd(), v.value = s.status, d.value = 1;
241
- }, q = () => {
242
- s.stop(), n.finish(), m.value = !0, v.value = "complete", c !== null && (cancelAnimationFrame(c), c = null), o.value++;
243
- }, K = () => {
244
- s.stop(), n.reset(), m.value = !1, d.value = 0, v.value = "idle", c !== null && (cancelAnimationFrame(c), c = null), o.value++;
909
+ c.skipToEnd(), y.value = c.status, v.value = 1;
910
+ }, w = () => {
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++;
245
914
  };
246
- U(() => {
247
- s.stop(), c !== null && cancelAnimationFrame(c);
915
+ F(() => {
916
+ c.stop(), i !== null && cancelAnimationFrame(i);
248
917
  });
249
- const $ = B(() => (o.value, n.getState().blocks)), W = B(() => (o.value, n.getStats())), _ = B(() => (o.value, n.getContent()));
918
+ const N = B(() => (u.value, r.getState().blocks)), g = B(() => (u.value, r.getStats())), z = B(() => (u.value, r.getContent()));
250
919
  return {
251
920
  vnode: B(() => {
252
- o.value;
253
- const g = n.getState();
254
- if (g.blocks.length === 0)
921
+ u.value;
922
+ const M = r.getState();
923
+ if (M.blocks.length === 0)
255
924
  return null;
256
- const N = g.blocks.map((C) => C.hast ? f(
925
+ const V = M.blocks.map((L) => L.hast ? e(
257
926
  "div",
258
927
  {
259
- key: C.key,
260
- "data-block-key": C.key,
261
- "data-pending": !C.stable || void 0
928
+ key: L.key,
929
+ "data-block-key": L.key,
930
+ "data-pending": !L.stable || void 0
262
931
  },
263
- [j(C.hast, t)]
264
- ) : null).filter((C) => C !== null);
265
- return f("div", { "data-streaming": !m.value }, N);
932
+ [D(L.hast, n)]
933
+ ) : null).filter((L) => L !== null);
934
+ return e("div", { "data-streaming": !d.value }, V);
266
935
  }),
267
936
  append: k,
268
- start: p,
269
- pause: S,
270
- resume: b,
271
- skipToEnd: H,
272
- reset: K,
273
- finish: q,
274
- blocks: $,
275
- stats: W,
276
- isComplete: m,
277
- content: _,
278
- progress: d,
279
- outputStatus: v
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
280
949
  };
281
950
  }
282
- function V(e, t, l, a, u) {
283
- if (e.type === "text")
284
- return e.value;
285
- if (e.type === "root") {
286
- const r = e.children.map((n) => V(n, t, l, a, u)).filter((n) => n !== null);
287
- return f("div", {}, r);
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);
288
957
  }
289
- if (e.type === "element") {
290
- const r = e, n = r.tagName, s = t == null ? void 0 : t[n], o = { ...r.properties };
291
- o.className && (o.class = Array.isArray(o.className) ? o.className.join(" ") : o.className, delete o.className);
292
- const m = r.children.map((d) => V(d, t, l, a, u)).filter((d) => d !== null);
293
- return n === "pre" && l && !s ? f(
294
- L,
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,
295
964
  {
296
- showCopyButton: u && l,
297
- onCopy: a
965
+ showCopyButton: o && l,
966
+ onCopy: s
298
967
  },
299
- () => m
300
- ) : s ? f(s, o, () => m) : f(n, o, m);
968
+ () => d
969
+ ) : c ? e(c, u, () => d) : e(r, u, d);
301
970
  }
302
971
  return null;
303
972
  }
304
- const E = A({
973
+ const ee = C({
305
974
  name: "StreamingMarkdown",
306
975
  props: {
307
976
  content: {
@@ -354,139 +1023,142 @@ const E = A({
354
1023
  }
355
1024
  },
356
1025
  emits: ["complete", "blockStable", "progress", "codeCopy"],
357
- setup(e, { emit: t }) {
358
- w(
359
- () => e.math,
360
- (i) => {
361
- i && R();
1026
+ setup(t, { emit: n }) {
1027
+ H(
1028
+ () => t.math,
1029
+ (m) => {
1030
+ m && Y();
362
1031
  },
363
1032
  { immediate: !0 }
364
1033
  );
365
- const l = F({
366
- gfm: e.gfm,
367
- highlight: e.highlight,
368
- math: e.math
369
- }), a = new O(e.outputRate), u = h(0), r = h(""), n = h(void 0), s = h([]), o = h(!1);
370
- let m = 0, d = null;
371
- const v = () => {
372
- const i = performance.now();
373
- i - m >= e.minUpdateInterval ? (m = i, u.value++) : d === null && (d = requestAnimationFrame(() => {
374
- d = null, m = performance.now(), u.value++;
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++;
375
1044
  }));
376
1045
  };
377
- return w(
378
- () => e.source,
379
- (i) => {
380
- i !== void 0 && i !== n.value && (n.value = i, e.autoStart && i && (l.reset(), r.value = "", o.value = !1, a.start(
381
- i,
382
- (c) => {
383
- c && (l.append(c), r.value += c), t("progress", a.progress), v();
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();
384
1053
  },
385
1054
  () => {
386
- l.finish(), o.value = !0, t("complete"), v();
1055
+ l.finish(), u.value = !0, n("complete"), y();
387
1056
  }
388
1057
  )));
389
1058
  },
390
1059
  { immediate: !0 }
391
- ), w(
392
- () => e.content,
393
- (i) => {
394
- if (e.source !== void 0)
1060
+ ), H(
1061
+ () => t.content,
1062
+ (m) => {
1063
+ if (t.source !== void 0)
395
1064
  return;
396
- const c = r.value, y = i || "";
397
- if (y !== c) {
398
- if (y.startsWith(c)) {
399
- const p = y.slice(c.length);
400
- p && l.append(p);
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);
401
1070
  } else
402
- l.reset(), y && l.append(y);
403
- r.value = y, v();
1071
+ l.reset(), p && l.append(p);
1072
+ a.value = p, y();
404
1073
  const k = l.getState().blocks;
405
- k.forEach((p, S) => {
406
- const b = s.value[S];
407
- p.stable && (!b || !b.stable) && t("blockStable", p);
408
- }), s.value = k;
1074
+ k.forEach((f, I) => {
1075
+ const x = c.value[I];
1076
+ f.stable && (!x || !x.stable) && n("blockStable", f);
1077
+ }), c.value = k;
409
1078
  }
410
1079
  },
411
1080
  { immediate: !0 }
412
- ), w(
413
- () => e.isComplete,
414
- (i) => {
415
- e.source === void 0 && i && (l.finish(), d !== null && (cancelAnimationFrame(d), d = null), u.value++, t("complete"));
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"));
416
1085
  }
417
- ), w(
418
- () => e.outputRate,
419
- (i) => {
420
- a.setRate(i);
1086
+ ), H(
1087
+ () => t.outputRate,
1088
+ (m) => {
1089
+ s.setRate(m);
421
1090
  }
422
- ), U(() => {
423
- a.stop(), d !== null && cancelAnimationFrame(d);
1091
+ ), F(() => {
1092
+ s.stop(), v !== null && cancelAnimationFrame(v);
424
1093
  }), () => {
425
- u.value;
426
- const i = l.getState(), c = e.source !== void 0 ? o.value : e.isComplete, y = (p) => t("codeCopy", p), k = i.blocks.map((p) => p.hast ? f(
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(
427
1096
  "div",
428
1097
  {
429
- key: p.key,
430
- "data-block-key": p.key,
431
- "data-pending": !p.stable || void 0
1098
+ key: f.key,
1099
+ "data-block-key": f.key,
1100
+ "data-pending": !f.stable || void 0
432
1101
  },
433
- [V(p.hast, e.components, e.copyButton, y, p.stable)]
434
- ) : null).filter((p) => p !== null);
435
- return f(
1102
+ [R(f.hast, t.components, t.copyButton, p, f.stable)]
1103
+ ) : null).filter((f) => f !== null);
1104
+ return e(
436
1105
  "div",
437
1106
  {
438
- class: e.class,
439
- "data-streaming": !c
1107
+ class: t.class,
1108
+ "data-streaming": !i
440
1109
  },
441
1110
  k
442
1111
  );
443
1112
  };
444
1113
  }
445
1114
  });
446
- function M(e, t = {}) {
447
- if (e.type === "text")
448
- return e.value;
449
- if (e.type === "comment")
1115
+ function Z(t, n = {}) {
1116
+ if (t.type === "text")
1117
+ return t.value;
1118
+ if (t.type === "comment")
450
1119
  return null;
451
- if (e.type === "root") {
452
- const l = e.children.map((a) => M(a, t)).filter((a) => a !== null);
453
- return f("div", {}, l);
1120
+ if (t.type === "root") {
1121
+ const l = t.children.map((s) => Z(s, n)).filter((s) => s !== null);
1122
+ return e("div", {}, l);
454
1123
  }
455
- if (e.type === "element") {
456
- const { tagName: l, properties: a, children: u } = e, r = t[l] || l, n = {};
457
- if (a)
458
- for (const [o, m] of Object.entries(a))
459
- o === "className" ? n.class = Array.isArray(m) ? m.join(" ") : m : n[o] = m;
460
- const s = u.map((o) => M(o, t)).filter((o) => o !== null);
461
- return f(r, n, () => s);
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);
462
1131
  }
463
1132
  return null;
464
1133
  }
465
- function re(e, t = {}) {
466
- const { components: l = {}, ...a } = t;
1134
+ function Ve(t, n = {}) {
1135
+ const { components: l = {}, ...s } = n;
467
1136
  return B(() => {
468
- const u = e();
469
- if (!u) return null;
470
- const r = P(u, a);
471
- return M(r, l);
1137
+ const o = t();
1138
+ if (!o) return null;
1139
+ const a = j(o, s);
1140
+ return Z(a, l);
472
1141
  });
473
1142
  }
474
- function Y(e) {
475
- e.component("Markdown", z), e.component("StreamingMarkdown", E);
1143
+ function ze(t) {
1144
+ t.component("Markdown", Q), t.component("StreamingMarkdown", ee);
476
1145
  }
477
- const le = {
478
- install: Y,
479
- Markdown: z,
480
- StreamingMarkdown: E
1146
+ const He = {
1147
+ install: ze,
1148
+ Markdown: Q,
1149
+ StreamingMarkdown: ee
481
1150
  };
482
1151
  export {
483
- L as CodeBlock,
484
- z as Markdown,
485
- E as StreamingMarkdown,
486
- le as default,
487
- Y as install,
488
- ne as isKatexCssLoaded,
489
- R as preloadKatexCss,
490
- re as useMarkdown,
491
- ae as useStreamingMarkdown
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
492
1164
  };