@matechat/core 1.5.2 → 1.6.0-alpha.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/Bubble/index.js +5 -5
- package/Input/index.css +1 -1
- package/Input/index.js +53 -53
- package/Introduction/index.css +1 -1
- package/Introduction/index.js +8 -8
- package/List/index.js +53 -51
- package/Locale/index.js +33 -21
- package/MarkdownCard/MermaidService-QktyNvVC.js +53 -0
- package/MarkdownCard/index.css +1 -1
- package/MarkdownCard/index.js +253 -163
- package/package.json +1 -1
package/MarkdownCard/index.js
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import "./index.css";
|
|
2
|
-
import { defineComponent as
|
|
3
|
-
import
|
|
2
|
+
import { defineComponent as P, ref as w, computed as T, watch as k, nextTick as G, onMounted as Z, createElementBlock as y, openBlock as M, normalizeClass as C, renderSlot as E, createVNode as K, createElementVNode as h, toDisplayString as U, createCommentVNode as W, unref as v, Transition as J, withCtx as V, useSlots as q, h as A, Fragment as ee, createBlock as te, resolveDynamicComponent as se } from "vue";
|
|
3
|
+
import D from "highlight.js";
|
|
4
4
|
import ie from "markdown-it";
|
|
5
5
|
import { debounce as ne } from "lodash-es";
|
|
6
|
-
import { getDefaultWhiteList as oe, getDefaultCSSWhiteList as
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
import { getDefaultWhiteList as oe, getDefaultCSSWhiteList as ae, filterXSS as le } from "xss";
|
|
7
|
+
import { useMcI18n as re } from "@matechat/core/Locale";
|
|
8
|
+
const ce = "data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'?%3e%3csvg%20width='16px'%20height='16px'%20viewBox='0%200%2016%2016'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3ctitle%3e全部收起%3c/title%3e%3cg%20id='全部收起'%20stroke='none'%20stroke-width='1'%20fill='none'%20fill-rule='evenodd'%3e%3cpath%20d='M4.715694,14.4114091%20C4.910563,14.5464051%205.179987,14.5271201%205.353553,14.3535531%20L5.353553,14.3535531%20L7.99999988,11.7070001%20L10.646447,14.3535531%20L10.715694,14.4114091%20C10.910563,14.5464051%2011.179987,14.5271201%2011.353553,14.3535531%20C11.548816,14.1582911%2011.548816,13.8417091%2011.353553,13.6464471%20L11.353553,13.6464471%20L8.353553,10.6464471%20L8.284306,10.5885911%20C8.089437,10.4535951%207.820013,10.4728801%207.646447,10.6464471%20L7.646447,10.6464471%20L4.646447,13.6464471%20L4.588591,13.7156941%20C4.453595,13.9105631%204.47288,14.1799871%204.646447,14.3535531%20L4.646447,14.3535531%20L4.715694,14.4114091%20Z%20M14.5,7.50000012%20C14.776142,7.50000012%2015,7.72385812%2015,8.00000012%20C15,8.27614212%2014.776142,8.50000012%2014.5,8.50000012%20L1.5,8.50000012%20C1.223858,8.50000012%201,8.27614212%201,8.00000012%20C1,7.72385812%201.223858,7.50000012%201.5,7.50000012%20L14.5,7.50000012%20Z%20M8.284306,5.41140912%20L8.353553,5.35355312%20L11.353553,2.35355312%20C11.548816,2.15829112%2011.548816,1.84170912%2011.353553,1.64644712%20C11.179987,1.47288012%2010.910563,1.45359512%2010.715694,1.58859112%20L10.646447,1.64644712%20L7.99999988,4.29300012%20L5.353553,1.64644712%20C5.179987,1.47288012%204.910563,1.45359512%204.715694,1.58859112%20L4.646447,1.64644712%20C4.47288,1.82001312%204.453595,2.08943712%204.588591,2.28430612%20L4.646447,2.35355312%20L7.646447,5.35355312%20C7.820013,5.52712012%208.089437,5.54640512%208.284306,5.41140912%20Z'%20id='形状结合'%20fill='%2371757F'%20fill-rule='nonzero'%3e%3c/path%3e%3c/g%3e%3c/svg%3e", de = "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB3aWR0aD0iMTZweCIgaGVpZ2h0PSIxNnB4IiB2aWV3Qm94PSIwIDAgMTYgMTYiIHZlcnNpb249IjEu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DNjA0Ljc0NTQ2LDIxNSA2MDQuOTQ5NjA4LDIxNC44MjMxMjUgNjA0Ljk5MTk0NCwyMTQuNTg5ODc2IEw2MDUsMjE0LjUgTDYwNSwyMDcuNSBDNjA1LDIwNy4yNTQ1NCA2MDQuODIzMTI1LDIwNy4wNTAzOTIgNjA0LjU4OTg3NiwyMDcuMDA4MDU2IEw2MDQuNSwyMDcgWiIgaWQ9IuW9oueKtue7k+WQiCIgZmlsbD0iIzcxNzU3RiIgZmlsbC1ydWxlPSJub256ZXJvIj48L3BhdGg+CiAgICAgICAgPC9nPgogICAgPC9nPgo8L3N2Zz4=", ge = "data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'?%3e%3csvg%20width='16px'%20height='16px'%20viewBox='0%200%2016%2016'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3ctitle%3estatus/whiteBG/correct%3c/title%3e%3cdesc%3eCreated%20with%20Sketch.%3c/desc%3e%3cdefs%3e%3cpolygon%20id='path-1'%20points='6.53553391%209.77817459%2012.1923882%204.12132034%2013.6066017%205.53553391%206.53553391%2012.6066017%203%209.07106781%204.41421356%207.65685425%206.53553391%209.77817459'%3e%3c/polygon%3e%3c/defs%3e%3cg%20id='status/whiteBG/correct'%20stroke='none'%20stroke-width='1'%20fill='none'%20fill-rule='evenodd'%3e%3cmask%20id='mask-2'%20fill='white'%3e%3cuse%20xlink:href='%23path-1'%3e%3c/use%3e%3c/mask%3e%3cuse%20id='Mask'%20fill='%233DCCA6'%20xlink:href='%23path-1'%3e%3c/use%3e%3c/g%3e%3c/svg%3e";
|
|
9
|
+
class X {
|
|
9
10
|
constructor() {
|
|
10
|
-
this.xssWhiteList = oe(), this.cssWhiteList =
|
|
11
|
+
this.xssWhiteList = oe(), this.cssWhiteList = ae(), this.setDefaultXss();
|
|
11
12
|
}
|
|
12
13
|
setDefaultXss() {
|
|
13
14
|
this.xssWhiteList.input = ["type", "checked", "disabled", "class"], this.xssWhiteList.label = ["for"], this.xssWhiteList.ul = ["class"], this.xssWhiteList.div = ["class"], this.xssWhiteList.a = ["href", "class", "target", "name"], this.xssWhiteList.ol = ["start"], this.xssWhiteList.p = ["class"], this.xssWhiteList.span = ["style", "class", "title", "id"], this.xssWhiteList.svg = ["style", "class", "width", "height", "viewbox", "preserveaspectratio", "id", "fill", "stroke"], this.xssWhiteList.path = ["style", "class", "d", "id", "fill", "stroke"], this.xssWhiteList.th = ["style"], this.xssWhiteList.td = ["style"];
|
|
14
15
|
}
|
|
15
|
-
onIgnoreTagAttr(s,
|
|
16
|
-
if (!i && (
|
|
17
|
-
return
|
|
16
|
+
onIgnoreTagAttr(s, a, g, i) {
|
|
17
|
+
if (!i && (a === "id" || s === "span" && a === "style"))
|
|
18
|
+
return a + "=" + g;
|
|
18
19
|
}
|
|
19
20
|
getXssWhiteList() {
|
|
20
21
|
return this.xssWhiteList;
|
|
@@ -23,18 +24,18 @@ class G {
|
|
|
23
24
|
this.xssWhiteList = s;
|
|
24
25
|
}
|
|
25
26
|
setCustomXssRules(s) {
|
|
26
|
-
s && s.forEach((
|
|
27
|
-
|
|
27
|
+
s && s.forEach((a) => {
|
|
28
|
+
a.value === null ? delete this.xssWhiteList[a.key] : this.xssWhiteList[a.key] = a.value;
|
|
28
29
|
});
|
|
29
30
|
}
|
|
30
|
-
setMdPlugins(s,
|
|
31
|
-
s && s.length && s.forEach((
|
|
32
|
-
const { plugin: i, opts:
|
|
33
|
-
|
|
31
|
+
setMdPlugins(s, a) {
|
|
32
|
+
s && s.length && s.forEach((g) => {
|
|
33
|
+
const { plugin: i, opts: u } = g;
|
|
34
|
+
a.use(i, u);
|
|
34
35
|
});
|
|
35
36
|
}
|
|
36
37
|
filterHtml(s) {
|
|
37
|
-
return
|
|
38
|
+
return le(s, {
|
|
38
39
|
whiteList: this.xssWhiteList,
|
|
39
40
|
onIgnoreTagAttr: this.onIgnoreTagAttr,
|
|
40
41
|
css: {
|
|
@@ -48,16 +49,19 @@ class G {
|
|
|
48
49
|
});
|
|
49
50
|
}
|
|
50
51
|
}
|
|
51
|
-
const
|
|
52
|
+
const ue = {
|
|
52
53
|
key: 0,
|
|
53
54
|
class: "mc-code-block-header"
|
|
54
|
-
},
|
|
55
|
+
}, me = { class: "mc-code-lang" }, he = { class: "mc-code-block-actions" }, Me = {
|
|
56
|
+
key: 0,
|
|
57
|
+
style: { "margin-right": "8px" }
|
|
58
|
+
}, ye = ["title"], Ie = ["title"], pe = {
|
|
55
59
|
key: 0,
|
|
56
|
-
src: re
|
|
57
|
-
}, Ie = {
|
|
58
|
-
key: 1,
|
|
59
60
|
src: de
|
|
60
|
-
},
|
|
61
|
+
}, De = {
|
|
62
|
+
key: 1,
|
|
63
|
+
src: ge
|
|
64
|
+
}, Le = { key: 0 }, we = ["innerHTML"], fe = { key: 1 }, Ne = ["innerHTML"], ve = /* @__PURE__ */ P({
|
|
61
65
|
__name: "CodeBlock",
|
|
62
66
|
props: {
|
|
63
67
|
code: {
|
|
@@ -75,100 +79,176 @@ const ge = {
|
|
|
75
79
|
theme: {
|
|
76
80
|
type: String,
|
|
77
81
|
default: "light"
|
|
82
|
+
},
|
|
83
|
+
enableMermaid: {
|
|
84
|
+
type: Boolean,
|
|
85
|
+
default: !1
|
|
86
|
+
},
|
|
87
|
+
mermaidConfig: {
|
|
88
|
+
type: Object,
|
|
89
|
+
default: () => ({})
|
|
78
90
|
}
|
|
79
91
|
},
|
|
80
|
-
setup(
|
|
81
|
-
const s =
|
|
92
|
+
setup(d) {
|
|
93
|
+
const s = d, { t: a } = re(), g = new X();
|
|
94
|
+
let i = null;
|
|
95
|
+
const u = w(!0), m = w(!1), f = w(""), c = w(!0), I = T(() => {
|
|
96
|
+
var e;
|
|
97
|
+
return s.enableMermaid && ((e = s.language) == null ? void 0 : e.toLowerCase()) === "mermaid";
|
|
98
|
+
}), L = T(() => {
|
|
82
99
|
try {
|
|
83
100
|
const e = s.code.indexOf('<span class="mc-typewriter');
|
|
84
|
-
let
|
|
85
|
-
return s.language &&
|
|
101
|
+
let n;
|
|
102
|
+
return s.language && D.getLanguage(s.language) ? e !== -1 ? n = D.highlight(s.code.slice(0, e), { language: s.language }).value + s.code.slice(e) : n = D.highlight(s.code, { language: s.language }).value : typeof D.highlightAuto !== void 0 ? e !== -1 ? n = D.highlightAuto(s.code.slice(0, e)).value + s.code.slice(e) : n = D.highlightAuto(s.code).value : n = g.filterHtml(s.code), n;
|
|
86
103
|
} catch {
|
|
87
104
|
}
|
|
88
|
-
}),
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
105
|
+
}), N = async () => {
|
|
106
|
+
if (!(!I.value || !s.code)) {
|
|
107
|
+
if (!i)
|
|
108
|
+
try {
|
|
109
|
+
const { MermaidService: e } = await import("./MermaidService-QktyNvVC.js"), n = {
|
|
110
|
+
theme: s.theme === "dark" ? "dark" : "default",
|
|
111
|
+
...s.mermaidConfig
|
|
112
|
+
};
|
|
113
|
+
i = new e(n);
|
|
114
|
+
} catch (e) {
|
|
115
|
+
console.error("Failed to load MermaidService:", e);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
try {
|
|
119
|
+
const e = await i.renderMermaid(s.code, s.theme);
|
|
120
|
+
f.value = e;
|
|
121
|
+
} catch {
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}, p = () => {
|
|
125
|
+
u.value = !u.value;
|
|
126
|
+
}, x = ne((e) => {
|
|
127
|
+
const n = e.target;
|
|
92
128
|
if (navigator.clipboard)
|
|
93
129
|
navigator.clipboard.writeText(s.code);
|
|
94
130
|
else {
|
|
95
131
|
const r = document.createElement("textarea");
|
|
96
132
|
r.style.position = "fixed", r.style.top = "-9999px", r.style.left = "-9999px", r.style.zIndex = "-1", r.value = s.code, document.body.appendChild(r), r.select(), document.execCommand("copy"), document.body.removeChild(r);
|
|
97
133
|
}
|
|
98
|
-
|
|
99
|
-
|
|
134
|
+
n.classList.remove("icon-copy-new"), m.value = !0, setTimeout(() => {
|
|
135
|
+
m.value = !1;
|
|
100
136
|
}, 1500);
|
|
101
|
-
}, 300),
|
|
137
|
+
}, 300), b = (e) => {
|
|
102
138
|
e.dataset || (e.dataset = {}), e.style.height && (e.dataset.height = e.style.height), e.style.maxHeight = 0;
|
|
103
|
-
},
|
|
139
|
+
}, O = (e) => {
|
|
104
140
|
requestAnimationFrame(() => {
|
|
105
141
|
e.dataset.oldOverflow = e.style.overflow, e.dataset.height ? e.style.maxHeight = e.dataset.height : e.scrollHeight !== 0 ? e.style.maxHeight = `${e.scrollHeight}px` : e.style.maxHeight = 0, e.style.overflow = "hidden";
|
|
106
142
|
});
|
|
107
|
-
},
|
|
143
|
+
}, S = (e) => {
|
|
108
144
|
e.style.maxHeight = "", e.style.overflow = e.dataset.oldOverflow;
|
|
109
|
-
},
|
|
145
|
+
}, B = (e) => {
|
|
110
146
|
e.dataset || (e.dataset = {}), e.dataset.oldOverflow = e.style.overflow, e.style.maxHeight = `${e.scrollHeight}px`, e.style.overflow = "hidden";
|
|
111
|
-
},
|
|
147
|
+
}, t = (e) => {
|
|
112
148
|
e.scrollHeight !== 0 && (e.style.maxHeight = 0);
|
|
113
|
-
},
|
|
149
|
+
}, o = (e) => {
|
|
114
150
|
e.style.maxHeight = "", e.style.overflow = e.dataset.oldOverflow;
|
|
115
|
-
},
|
|
116
|
-
return (
|
|
151
|
+
}, l = T(() => s.theme === "dark" ? "mc-code-block-dark" : "mc-code-block-light");
|
|
152
|
+
return k(() => [s.code, s.theme, s.enableMermaid], () => {
|
|
153
|
+
I.value && G(() => {
|
|
154
|
+
N();
|
|
155
|
+
});
|
|
156
|
+
}, { immediate: !0 }), Z(() => {
|
|
157
|
+
I.value && N();
|
|
158
|
+
}), (e, n) => (M(), y(
|
|
117
159
|
"div",
|
|
118
160
|
{
|
|
119
|
-
class:
|
|
161
|
+
class: C(["mc-code-block", l.value])
|
|
120
162
|
},
|
|
121
163
|
[
|
|
122
|
-
e.$slots.header ?
|
|
123
|
-
|
|
164
|
+
e.$slots.header ? E(e.$slots, "header", { key: 1 }, void 0, !0) : (M(), y("div", ue, [
|
|
165
|
+
h(
|
|
124
166
|
"span",
|
|
125
|
-
|
|
126
|
-
|
|
167
|
+
me,
|
|
168
|
+
U(d.language),
|
|
127
169
|
1
|
|
128
170
|
/* TEXT */
|
|
129
171
|
),
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
172
|
+
E(e.$slots, "actions", {}, () => [
|
|
173
|
+
h("div", he, [
|
|
174
|
+
I.value ? (M(), y("div", Me, [
|
|
175
|
+
h(
|
|
176
|
+
"ul",
|
|
177
|
+
{
|
|
178
|
+
class: C(["mc-diagram-switch", { "mc-show-code": !c.value }])
|
|
179
|
+
},
|
|
180
|
+
[
|
|
181
|
+
h(
|
|
182
|
+
"li",
|
|
183
|
+
{
|
|
184
|
+
onClick: n[0] || (n[0] = (r) => c.value = !0),
|
|
185
|
+
class: C({ "mc-diagram-switch-active": c.value })
|
|
186
|
+
},
|
|
187
|
+
U(v(a)("Md.diagram")),
|
|
188
|
+
3
|
|
189
|
+
/* TEXT, CLASS */
|
|
190
|
+
),
|
|
191
|
+
h(
|
|
192
|
+
"li",
|
|
193
|
+
{
|
|
194
|
+
onClick: n[1] || (n[1] = (r) => c.value = !1),
|
|
195
|
+
class: C({ "mc-diagram-switch-active": !c.value })
|
|
196
|
+
},
|
|
197
|
+
U(v(a)("Md.code")),
|
|
198
|
+
3
|
|
199
|
+
/* TEXT, CLASS */
|
|
200
|
+
)
|
|
201
|
+
],
|
|
202
|
+
2
|
|
203
|
+
/* CLASS */
|
|
204
|
+
)
|
|
205
|
+
])) : W("v-if", !0),
|
|
206
|
+
h("div", {
|
|
133
207
|
class: "mc-action-btn mc-toggle-btn",
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
208
|
+
title: v(a)("Md.toggle"),
|
|
209
|
+
onClick: p
|
|
210
|
+
}, n[3] || (n[3] = [
|
|
211
|
+
h(
|
|
137
212
|
"img",
|
|
138
213
|
{ src: ce },
|
|
139
214
|
null,
|
|
140
215
|
-1
|
|
141
|
-
/*
|
|
216
|
+
/* CACHED */
|
|
142
217
|
)
|
|
143
|
-
])),
|
|
144
|
-
|
|
218
|
+
]), 8, ye),
|
|
219
|
+
h("div", {
|
|
145
220
|
class: "mc-action-btn mc-copy-btn",
|
|
146
|
-
|
|
147
|
-
|
|
221
|
+
title: v(a)("Md.copy"),
|
|
222
|
+
onClick: n[2] || (n[2] = //@ts-ignore
|
|
223
|
+
(...r) => v(x) && v(x)(...r))
|
|
148
224
|
}, [
|
|
149
|
-
|
|
150
|
-
])
|
|
225
|
+
m.value ? (M(), y("img", De)) : (M(), y("img", pe))
|
|
226
|
+
], 8, Ie)
|
|
151
227
|
])
|
|
152
228
|
], !0)
|
|
153
229
|
])),
|
|
154
|
-
|
|
230
|
+
K(J, {
|
|
155
231
|
name: "collapse-transition",
|
|
156
|
-
onBeforeEnter:
|
|
157
|
-
onEnter:
|
|
158
|
-
onAfterEnter:
|
|
159
|
-
onBeforeLeave:
|
|
160
|
-
onLeave:
|
|
161
|
-
onAfterLeave:
|
|
232
|
+
onBeforeEnter: b,
|
|
233
|
+
onEnter: O,
|
|
234
|
+
onAfterEnter: S,
|
|
235
|
+
onBeforeLeave: B,
|
|
236
|
+
onLeave: t,
|
|
237
|
+
onAfterLeave: o
|
|
162
238
|
}, {
|
|
163
|
-
default:
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
239
|
+
default: V(() => [
|
|
240
|
+
u.value ? (M(), y("div", Le, [
|
|
241
|
+
I.value && c.value && !e.$slots.content ? (M(), y("div", {
|
|
242
|
+
key: 0,
|
|
243
|
+
class: "mc-mermaid-content",
|
|
244
|
+
innerHTML: f.value
|
|
245
|
+
}, null, 8, we)) : e.$slots.content ? E(e.$slots, "content", { key: 2 }, void 0, !0) : (M(), y("pre", fe, [
|
|
246
|
+
h("code", {
|
|
247
|
+
class: C(`hljs language-${d.language}`),
|
|
248
|
+
innerHTML: L.value
|
|
249
|
+
}, null, 10, Ne)
|
|
170
250
|
]))
|
|
171
|
-
])) :
|
|
251
|
+
])) : W("v-if", !0)
|
|
172
252
|
]),
|
|
173
253
|
_: 3
|
|
174
254
|
/* FORWARDED */
|
|
@@ -178,16 +258,16 @@ const ge = {
|
|
|
178
258
|
/* CLASS */
|
|
179
259
|
));
|
|
180
260
|
}
|
|
181
|
-
}),
|
|
182
|
-
const
|
|
183
|
-
for (const [
|
|
184
|
-
|
|
185
|
-
return
|
|
186
|
-
},
|
|
261
|
+
}), $ = (d, s) => {
|
|
262
|
+
const a = d.__vccOpts || d;
|
|
263
|
+
for (const [g, i] of s)
|
|
264
|
+
a[g] = i;
|
|
265
|
+
return a;
|
|
266
|
+
}, Ce = /* @__PURE__ */ $(ve, [["__scopeId", "data-v-a7f19fa4"]]), Q = {
|
|
187
267
|
step: 2,
|
|
188
268
|
interval: 50,
|
|
189
269
|
style: "normal"
|
|
190
|
-
},
|
|
270
|
+
}, Ae = {
|
|
191
271
|
content: {
|
|
192
272
|
type: String,
|
|
193
273
|
default: ""
|
|
@@ -235,167 +315,177 @@ const ge = {
|
|
|
235
315
|
theme: {
|
|
236
316
|
type: String,
|
|
237
317
|
default: "light"
|
|
318
|
+
},
|
|
319
|
+
enableMermaid: {
|
|
320
|
+
type: Boolean,
|
|
321
|
+
default: !1
|
|
322
|
+
},
|
|
323
|
+
mermaidConfig: {
|
|
324
|
+
type: Object,
|
|
325
|
+
default: () => ({})
|
|
238
326
|
}
|
|
239
|
-
},
|
|
327
|
+
}, ke = /* @__PURE__ */ P({
|
|
240
328
|
__name: "mdCard",
|
|
241
|
-
props:
|
|
329
|
+
props: Ae,
|
|
242
330
|
emits: ["afterMdtInit", "typingStart", "typing", "typingEnd"],
|
|
243
|
-
setup(
|
|
244
|
-
const
|
|
245
|
-
let
|
|
246
|
-
const
|
|
331
|
+
setup(d, { expose: s, emit: a }) {
|
|
332
|
+
const g = new X(), i = d, u = a, m = q();
|
|
333
|
+
let f = null;
|
|
334
|
+
const c = ie({
|
|
247
335
|
breaks: !0,
|
|
248
336
|
linkify: !0,
|
|
249
337
|
html: !0,
|
|
250
|
-
highlight: (t,
|
|
251
|
-
if (
|
|
338
|
+
highlight: (t, o) => {
|
|
339
|
+
if (o && D.getLanguage(o))
|
|
252
340
|
try {
|
|
253
|
-
return
|
|
341
|
+
return D.highlight(t, { language: o }).value;
|
|
254
342
|
} catch {
|
|
255
343
|
}
|
|
256
344
|
return "";
|
|
257
345
|
},
|
|
258
346
|
...i.mdOptions
|
|
259
347
|
});
|
|
260
|
-
|
|
261
|
-
const
|
|
348
|
+
c.renderer.rules.fence = (t, o) => `<!----MC_MARKDOWN_CODE_BLOCK_${o}---->`;
|
|
349
|
+
const I = w({
|
|
262
350
|
tokens: [],
|
|
263
351
|
html: ""
|
|
264
|
-
}),
|
|
265
|
-
var
|
|
352
|
+
}), L = w(0), N = w(!1), p = () => {
|
|
353
|
+
var e;
|
|
266
354
|
let t = i.content || "";
|
|
267
|
-
if (i.typing &&
|
|
268
|
-
t = i.content.slice(0,
|
|
269
|
-
const
|
|
270
|
-
|
|
355
|
+
if (i.typing && N.value) {
|
|
356
|
+
t = i.content.slice(0, L.value) || "";
|
|
357
|
+
const n = { ...Q, ...i == null ? void 0 : i.typingOptions };
|
|
358
|
+
n.style === "cursor" ? t += '<span class="mc-typewriter mc-typewriter-cursor">|</span>' : (n.style === "color" || n.style === "gradient") && (t = t.slice(0, -5) + `<span class="mc-typewriter mc-typewriter-${n.style}">${t.slice(-5)}</span>`);
|
|
271
359
|
}
|
|
272
360
|
if (i.enableThink) {
|
|
273
|
-
const
|
|
274
|
-
t = (t == null ? void 0 : t.replace("<think>", `<div class="${
|
|
361
|
+
const n = ((e = i.thinkOptions) == null ? void 0 : e.customClass) || "mc-think-block";
|
|
362
|
+
t = (t == null ? void 0 : t.replace("<think>", `<div class="${n}">`).replace("</think>", "</div>")) || "";
|
|
275
363
|
}
|
|
276
|
-
const
|
|
277
|
-
|
|
364
|
+
const o = c.parse(t, {}), l = c.render(t);
|
|
365
|
+
I.value = { tokens: o, html: l };
|
|
278
366
|
};
|
|
279
|
-
|
|
367
|
+
k(
|
|
280
368
|
() => {
|
|
281
369
|
var t;
|
|
282
370
|
return [i.enableThink, (t = i.thinkOptions) == null ? void 0 : t.customClass];
|
|
283
371
|
},
|
|
284
372
|
() => {
|
|
285
|
-
|
|
373
|
+
p();
|
|
286
374
|
}
|
|
287
375
|
);
|
|
288
|
-
const
|
|
289
|
-
const
|
|
290
|
-
actions:
|
|
291
|
-
header:
|
|
292
|
-
content:
|
|
376
|
+
const x = (t, o, l) => {
|
|
377
|
+
const e = {
|
|
378
|
+
actions: m.actions ? () => m.actions({ codeBlockData: { code: o, language: t } }) || null : void 0,
|
|
379
|
+
header: m.header ? () => m.header({ codeBlockData: { code: o, language: t } }) || null : void 0,
|
|
380
|
+
content: m.content ? () => m.content({ codeBlockData: { code: o, language: t } }) || null : void 0
|
|
293
381
|
};
|
|
294
|
-
return
|
|
295
|
-
|
|
382
|
+
return A(
|
|
383
|
+
Ce,
|
|
296
384
|
{
|
|
297
385
|
language: t,
|
|
298
|
-
code:
|
|
299
|
-
blockIndex:
|
|
386
|
+
code: o,
|
|
387
|
+
blockIndex: l,
|
|
300
388
|
theme: i.theme,
|
|
301
|
-
|
|
389
|
+
enableMermaid: i.enableMermaid,
|
|
390
|
+
mermaidConfig: i.mermaidConfig,
|
|
391
|
+
key: `code-block-${l}`
|
|
302
392
|
},
|
|
303
|
-
|
|
393
|
+
e
|
|
304
394
|
);
|
|
305
395
|
};
|
|
306
|
-
|
|
396
|
+
k(
|
|
307
397
|
() => i.content,
|
|
308
|
-
(t,
|
|
398
|
+
(t, o) => {
|
|
309
399
|
if (!i.typing) {
|
|
310
|
-
|
|
400
|
+
L.value = (t == null ? void 0 : t.length) || 0, p();
|
|
311
401
|
return;
|
|
312
402
|
}
|
|
313
|
-
t.indexOf(
|
|
403
|
+
t.indexOf(o) === -1 && (L.value = 0), G(() => O());
|
|
314
404
|
},
|
|
315
405
|
{ immediate: !0 }
|
|
316
406
|
);
|
|
317
|
-
const
|
|
318
|
-
|
|
319
|
-
},
|
|
320
|
-
clearTimeout(
|
|
321
|
-
const t = { ...
|
|
322
|
-
let
|
|
323
|
-
if (Array.isArray(t.step) && (
|
|
324
|
-
|
|
407
|
+
const b = () => {
|
|
408
|
+
N.value = !1, u("typingEnd");
|
|
409
|
+
}, O = () => {
|
|
410
|
+
clearTimeout(f), N.value = !0, u("typingStart");
|
|
411
|
+
const t = { ...Q, ...i == null ? void 0 : i.typingOptions }, o = () => {
|
|
412
|
+
let l = t.step;
|
|
413
|
+
if (Array.isArray(t.step) && (l = t.step[0] + Math.floor(Math.random() * (t.step[1] - t.step[0]))), L.value += l, p(), u("typing"), L.value >= i.content.length) {
|
|
414
|
+
b(), p();
|
|
325
415
|
return;
|
|
326
416
|
}
|
|
327
|
-
|
|
417
|
+
f = setTimeout(o, t.interval);
|
|
328
418
|
};
|
|
329
|
-
|
|
330
|
-
},
|
|
419
|
+
f = setTimeout(o);
|
|
420
|
+
}, S = T(() => ({
|
|
331
421
|
name: "MarkdownRenderer",
|
|
332
422
|
render() {
|
|
333
|
-
var
|
|
423
|
+
var Y;
|
|
334
424
|
if (typeof document > "u")
|
|
335
|
-
return
|
|
336
|
-
const { html: t, tokens:
|
|
337
|
-
let
|
|
338
|
-
const
|
|
339
|
-
let
|
|
340
|
-
for (;
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
innerHTML: t.slice(
|
|
344
|
-
key: `markdown-segment-${
|
|
425
|
+
return A("div");
|
|
426
|
+
const { html: t, tokens: o } = I.value, l = [];
|
|
427
|
+
let e = 0, n;
|
|
428
|
+
const r = /<!----MC_MARKDOWN_CODE_BLOCK_(\d+)---->/g;
|
|
429
|
+
let _ = 0, z = 0;
|
|
430
|
+
for (; n = r.exec(t), !!n; ) {
|
|
431
|
+
n.index > e && l.push(
|
|
432
|
+
A("div", {
|
|
433
|
+
innerHTML: t.slice(e, n.index),
|
|
434
|
+
key: `markdown-segment-${z++}`
|
|
345
435
|
})
|
|
346
436
|
);
|
|
347
|
-
const
|
|
348
|
-
|
|
437
|
+
const j = o[Number.parseInt(n[1])], F = ((Y = j == null ? void 0 : j.info) == null ? void 0 : Y.replace(/<span\b[^>]*>/i, "").replace("</span>", "")) || "", R = j.content;
|
|
438
|
+
l.push(x(F, R, _)), _++, e = r.lastIndex;
|
|
349
439
|
}
|
|
350
|
-
return
|
|
351
|
-
|
|
352
|
-
innerHTML: t.slice(
|
|
353
|
-
key: `markdown-segment-${
|
|
440
|
+
return e < t.length && l.push(
|
|
441
|
+
A("div", {
|
|
442
|
+
innerHTML: t.slice(e),
|
|
443
|
+
key: `markdown-segment-${z++}`
|
|
354
444
|
})
|
|
355
|
-
),
|
|
445
|
+
), A("div", l);
|
|
356
446
|
}
|
|
357
447
|
}));
|
|
358
|
-
|
|
448
|
+
k(
|
|
359
449
|
() => i.customXssRules,
|
|
360
450
|
(t) => {
|
|
361
|
-
|
|
451
|
+
g.setCustomXssRules(t), p();
|
|
362
452
|
},
|
|
363
453
|
{ deep: !1 }
|
|
364
|
-
),
|
|
454
|
+
), k(
|
|
365
455
|
() => i.mdPlugins,
|
|
366
456
|
(t) => {
|
|
367
|
-
|
|
457
|
+
g.setMdPlugins(t, c), p();
|
|
368
458
|
},
|
|
369
459
|
{ immediate: !0, deep: !1 }
|
|
370
460
|
);
|
|
371
|
-
const
|
|
372
|
-
return
|
|
373
|
-
|
|
374
|
-
}), s({ mdt:
|
|
461
|
+
const B = T(() => i.theme === "dark" ? "mc-markdown-render-dark" : "mc-markdown-render-light");
|
|
462
|
+
return Z(() => {
|
|
463
|
+
u("afterMdtInit", c);
|
|
464
|
+
}), s({ mdt: c }), (t, o) => (M(), y(
|
|
375
465
|
ee,
|
|
376
466
|
null,
|
|
377
467
|
[
|
|
378
|
-
|
|
468
|
+
h(
|
|
379
469
|
"div",
|
|
380
470
|
{
|
|
381
|
-
class:
|
|
471
|
+
class: C(["mc-markdown-render", B.value])
|
|
382
472
|
},
|
|
383
473
|
[
|
|
384
|
-
(
|
|
474
|
+
(M(), te(se(S.value)))
|
|
385
475
|
],
|
|
386
476
|
2
|
|
387
477
|
/* CLASS */
|
|
388
478
|
),
|
|
389
|
-
|
|
479
|
+
W("v-if", !0)
|
|
390
480
|
],
|
|
391
481
|
64
|
|
392
482
|
/* STABLE_FRAGMENT */
|
|
393
483
|
));
|
|
394
484
|
}
|
|
395
|
-
}),
|
|
396
|
-
|
|
397
|
-
|
|
485
|
+
}), H = /* @__PURE__ */ $(ke, [["__scopeId", "data-v-a40d857a"]]);
|
|
486
|
+
H.install = (d) => {
|
|
487
|
+
d.component("McMarkdownCard", H);
|
|
398
488
|
};
|
|
399
489
|
export {
|
|
400
|
-
|
|
490
|
+
H as McMarkdownCard
|
|
401
491
|
};
|