@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.
@@ -1,20 +1,21 @@
1
1
  import "./index.css";
2
- import { defineComponent as Q, ref as A, computed as x, createElementBlock as L, openBlock as y, normalizeClass as S, renderSlot as b, createVNode as R, createElementVNode as N, toDisplayString as F, unref as z, Transition as $, withCtx as K, createCommentVNode as P, useSlots as J, watch as T, nextTick as V, h as f, onMounted as q, Fragment as ee, createBlock as te, resolveDynamicComponent as se } from "vue";
3
- import p from "highlight.js";
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 le, filterXSS as ae } from "xss";
7
- 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", re = "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB3aWR0aD0iMTZweCIgaGVpZ2h0PSIxNnB4IiB2aWV3Qm94PSIwIDAgMTYgMTYiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayI+CiAgICA8dGl0bGU+ZnVuY3Rpb24gaWNvbi9jb3B5PC90aXRsZT4KICAgIDxnIGlkPSLpobXpnaItMSIgc3Ryb2tlPSJub25lIiBzdHJva2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yMDcgWiIgaWQ9IuW9oueKtue7k+WQiCIgZmlsbD0iIzcxNzU3RiIgZmlsbC1ydWxlPSJub256ZXJvIj48L3BhdGg+CiAgICAgICAgPC9nPgogICAgPC9nPgo8L3N2Zz4=", de = "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";
8
- class G {
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,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB3aWR0aD0iMTZweCIgaGVpZ2h0PSIxNnB4IiB2aWV3Qm94PSIwIDAgMTYgMTYiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp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ljk5MTk0NCwyMTQuNTg5ODc2IEw2MDUsMjE0LjUgTDYwNSwyMDcuNSBDNjA1LDIwNy4yNTQ1NCA2MDQuODIzMTI1LDIwNy4wNTAzOTIgNjA0LjU4OTg3NiwyMDcuMDA4MDU2IEw2MDQuNSwyMDcgWiIgaWQ9IuW9oueKtue7k+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 = le(), this.setDefaultXss();
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, o, c, i) {
16
- if (!i && (o === "id" || s === "span" && o === "style"))
17
- return o + "=" + c;
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((o) => {
27
- o.value === null ? delete this.xssWhiteList[o.key] : this.xssWhiteList[o.key] = o.value;
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, o) {
31
- s && s.length && s.forEach((c) => {
32
- const { plugin: i, opts: h } = c;
33
- o.use(i, h);
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 ae(s, {
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 ge = {
52
+ const ue = {
52
53
  key: 0,
53
54
  class: "mc-code-block-header"
54
- }, ue = { class: "mc-code-lang" }, he = { class: "mc-code-block-actions" }, Me = {
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
- }, me = { key: 0 }, ye = { key: 0 }, pe = ["innerHTML"], De = /* @__PURE__ */ Q({
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(g) {
81
- const s = g, o = new G(), c = A(!0), i = A(!1), h = x(() => {
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 l;
85
- return s.language && p.getLanguage(s.language) ? e !== -1 ? l = p.highlight(s.code.slice(0, e), { language: s.language }).value + s.code.slice(e) : l = p.highlight(s.code, { language: s.language }).value : typeof p.highlightAuto !== void 0 ? e !== -1 ? l = p.highlightAuto(s.code.slice(0, e)).value + s.code.slice(e) : l = p.highlightAuto(s.code).value : l = o.filterHtml(s.code), l;
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
- }), M = () => {
89
- c.value = !c.value;
90
- }, w = ne((e) => {
91
- const l = e.target;
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
- l.classList.remove("icon-copy-new"), i.value = !0, setTimeout(() => {
99
- i.value = !1;
134
+ n.classList.remove("icon-copy-new"), m.value = !0, setTimeout(() => {
135
+ m.value = !1;
100
136
  }, 1500);
101
- }, 300), I = (e) => {
137
+ }, 300), b = (e) => {
102
138
  e.dataset || (e.dataset = {}), e.style.height && (e.dataset.height = e.style.height), e.style.maxHeight = 0;
103
- }, k = (e) => {
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
- }, D = (e) => {
143
+ }, S = (e) => {
108
144
  e.style.maxHeight = "", e.style.overflow = e.dataset.oldOverflow;
109
- }, C = (e) => {
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
- }, m = (e) => {
147
+ }, t = (e) => {
112
148
  e.scrollHeight !== 0 && (e.style.maxHeight = 0);
113
- }, j = (e) => {
149
+ }, o = (e) => {
114
150
  e.style.maxHeight = "", e.style.overflow = e.dataset.oldOverflow;
115
- }, O = x(() => s.theme === "dark" ? "mc-code-block-dark" : "mc-code-block-light");
116
- return (e, l) => (y(), L(
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: S(["mc-code-block", O.value])
161
+ class: C(["mc-code-block", l.value])
120
162
  },
121
163
  [
122
- e.$slots.header ? b(e.$slots, "header", { key: 1 }, void 0, !0) : (y(), L("div", ge, [
123
- N(
164
+ e.$slots.header ? E(e.$slots, "header", { key: 1 }, void 0, !0) : (M(), y("div", ue, [
165
+ h(
124
166
  "span",
125
- ue,
126
- F(g.language),
167
+ me,
168
+ U(d.language),
127
169
  1
128
170
  /* TEXT */
129
171
  ),
130
- b(e.$slots, "actions", {}, () => [
131
- N("div", he, [
132
- N("div", {
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
- onClick: M
135
- }, l[1] || (l[1] = [
136
- N(
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
- /* HOISTED */
216
+ /* CACHED */
142
217
  )
143
- ])),
144
- N("div", {
218
+ ]), 8, ye),
219
+ h("div", {
145
220
  class: "mc-action-btn mc-copy-btn",
146
- onClick: l[0] || (l[0] = //@ts-ignore
147
- (...r) => z(w) && z(w)(...r))
221
+ title: v(a)("Md.copy"),
222
+ onClick: n[2] || (n[2] = //@ts-ignore
223
+ (...r) => v(x) && v(x)(...r))
148
224
  }, [
149
- i.value ? (y(), L("img", Ie)) : (y(), L("img", Me))
150
- ])
225
+ m.value ? (M(), y("img", De)) : (M(), y("img", pe))
226
+ ], 8, Ie)
151
227
  ])
152
228
  ], !0)
153
229
  ])),
154
- R($, {
230
+ K(J, {
155
231
  name: "collapse-transition",
156
- onBeforeEnter: I,
157
- onEnter: k,
158
- onAfterEnter: D,
159
- onBeforeLeave: C,
160
- onLeave: m,
161
- onAfterLeave: j
232
+ onBeforeEnter: b,
233
+ onEnter: O,
234
+ onAfterEnter: S,
235
+ onBeforeLeave: B,
236
+ onLeave: t,
237
+ onAfterLeave: o
162
238
  }, {
163
- default: K(() => [
164
- c.value ? (y(), L("div", me, [
165
- e.$slots.content ? b(e.$slots, "content", { key: 1 }, void 0, !0) : (y(), L("pre", ye, [
166
- N("code", {
167
- class: S(`hljs language-${g.language}`),
168
- innerHTML: h.value
169
- }, null, 10, pe)
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
- ])) : P("v-if", !0)
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
- }), Z = (g, s) => {
182
- const o = g.__vccOpts || g;
183
- for (const [c, i] of s)
184
- o[c] = i;
185
- return o;
186
- }, Le = /* @__PURE__ */ Z(De, [["__scopeId", "data-v-e924c33d"]]), _ = {
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
- }, Ne = {
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
- }, we = /* @__PURE__ */ Q({
327
+ }, ke = /* @__PURE__ */ P({
240
328
  __name: "mdCard",
241
- props: Ne,
329
+ props: Ae,
242
330
  emits: ["afterMdtInit", "typingStart", "typing", "typingEnd"],
243
- setup(g, { expose: s, emit: o }) {
244
- const c = new G(), i = g, h = o, M = J();
245
- let w = null;
246
- const I = ie({
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, n) => {
251
- if (n && p.getLanguage(n))
338
+ highlight: (t, o) => {
339
+ if (o && D.getLanguage(o))
252
340
  try {
253
- return p.highlight(t, { language: n }).value;
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
- I.renderer.rules.fence = (t, n) => `<!----MC_MARKDOWN_CODE_BLOCK_${n}---->`;
261
- const k = A({
348
+ c.renderer.rules.fence = (t, o) => `<!----MC_MARKDOWN_CODE_BLOCK_${o}---->`;
349
+ const I = w({
262
350
  tokens: [],
263
351
  html: ""
264
- }), D = A(0), C = A(!1), m = () => {
265
- var u;
352
+ }), L = w(0), N = w(!1), p = () => {
353
+ var e;
266
354
  let t = i.content || "";
267
- if (i.typing && C.value) {
268
- t = i.content.slice(0, D.value) || "";
269
- const d = { ..._, ...i == null ? void 0 : i.typingOptions };
270
- d.style === "cursor" ? t += '<span class="mc-typewriter mc-typewriter-cursor">|</span>' : (d.style === "color" || d.style === "gradient") && (t = t.slice(0, -5) + `<span class="mc-typewriter mc-typewriter-${d.style}">${t.slice(-5)}</span>`);
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 d = ((u = i.thinkOptions) == null ? void 0 : u.customClass) || "mc-think-block";
274
- t = (t == null ? void 0 : t.replace("<think>", `<div class="${d}">`).replace("</think>", "</div>")) || "";
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 n = I.parse(t, {}), a = I.render(t);
277
- k.value = { tokens: n, html: a };
364
+ const o = c.parse(t, {}), l = c.render(t);
365
+ I.value = { tokens: o, html: l };
278
366
  };
279
- T(
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
- m();
373
+ p();
286
374
  }
287
375
  );
288
- const j = (t, n, a) => {
289
- const u = {
290
- actions: M.actions ? () => M.actions({ codeBlockData: { code: n, language: t } }) || null : void 0,
291
- header: M.header ? () => M.header({ codeBlockData: { code: n, language: t } }) || null : void 0,
292
- content: M.content ? () => M.content({ codeBlockData: { code: n, language: t } }) || null : void 0
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 f(
295
- Le,
382
+ return A(
383
+ Ce,
296
384
  {
297
385
  language: t,
298
- code: n,
299
- blockIndex: a,
386
+ code: o,
387
+ blockIndex: l,
300
388
  theme: i.theme,
301
- key: `code-block-${a}`
389
+ enableMermaid: i.enableMermaid,
390
+ mermaidConfig: i.mermaidConfig,
391
+ key: `code-block-${l}`
302
392
  },
303
- u
393
+ e
304
394
  );
305
395
  };
306
- T(
396
+ k(
307
397
  () => i.content,
308
- (t, n) => {
398
+ (t, o) => {
309
399
  if (!i.typing) {
310
- D.value = (t == null ? void 0 : t.length) || 0, m();
400
+ L.value = (t == null ? void 0 : t.length) || 0, p();
311
401
  return;
312
402
  }
313
- t.indexOf(n) === -1 && (D.value = 0), V(() => e());
403
+ t.indexOf(o) === -1 && (L.value = 0), G(() => O());
314
404
  },
315
405
  { immediate: !0 }
316
406
  );
317
- const O = () => {
318
- C.value = !1, h("typingEnd");
319
- }, e = () => {
320
- clearTimeout(w), C.value = !0, h("typingStart");
321
- const t = { ..._, ...i == null ? void 0 : i.typingOptions }, n = () => {
322
- let a = t.step;
323
- if (Array.isArray(t.step) && (a = t.step[0] + Math.floor(Math.random() * (t.step[1] - t.step[0]))), D.value += a, m(), h("typing"), D.value >= i.content.length) {
324
- O(), m();
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
- w = setTimeout(n, t.interval);
417
+ f = setTimeout(o, t.interval);
328
418
  };
329
- w = setTimeout(n);
330
- }, l = x(() => ({
419
+ f = setTimeout(o);
420
+ }, S = T(() => ({
331
421
  name: "MarkdownRenderer",
332
422
  render() {
333
- var W;
423
+ var Y;
334
424
  if (typeof document > "u")
335
- return f("div");
336
- const { html: t, tokens: n } = k.value, a = [];
337
- let u = 0, d;
338
- const B = /<!----MC_MARKDOWN_CODE_BLOCK_(\d+)---->/g;
339
- let E = 0, U = 0;
340
- for (; d = B.exec(t), !!d; ) {
341
- d.index > u && a.push(
342
- f("div", {
343
- innerHTML: t.slice(u, d.index),
344
- key: `markdown-segment-${U++}`
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 v = n[Number.parseInt(d[1])], H = ((W = v == null ? void 0 : v.info) == null ? void 0 : W.replace(/<span\b[^>]*>/i, "").replace("</span>", "")) || "", X = v.content;
348
- a.push(j(H, X, E)), E++, u = B.lastIndex;
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 u < t.length && a.push(
351
- f("div", {
352
- innerHTML: t.slice(u),
353
- key: `markdown-segment-${U++}`
440
+ return e < t.length && l.push(
441
+ A("div", {
442
+ innerHTML: t.slice(e),
443
+ key: `markdown-segment-${z++}`
354
444
  })
355
- ), f("div", a);
445
+ ), A("div", l);
356
446
  }
357
447
  }));
358
- T(
448
+ k(
359
449
  () => i.customXssRules,
360
450
  (t) => {
361
- c.setCustomXssRules(t), m();
451
+ g.setCustomXssRules(t), p();
362
452
  },
363
453
  { deep: !1 }
364
- ), T(
454
+ ), k(
365
455
  () => i.mdPlugins,
366
456
  (t) => {
367
- c.setMdPlugins(t, I), m();
457
+ g.setMdPlugins(t, c), p();
368
458
  },
369
459
  { immediate: !0, deep: !1 }
370
460
  );
371
- const r = x(() => i.theme === "dark" ? "mc-markdown-render-dark" : "mc-markdown-render-light");
372
- return q(() => {
373
- h("afterMdtInit", I);
374
- }), s({ mdt: I }), (t, n) => (y(), L(
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
- N(
468
+ h(
379
469
  "div",
380
470
  {
381
- class: S(["mc-markdown-render", r.value])
471
+ class: C(["mc-markdown-render", B.value])
382
472
  },
383
473
  [
384
- (y(), te(se(l.value)))
474
+ (M(), te(se(S.value)))
385
475
  ],
386
476
  2
387
477
  /* CLASS */
388
478
  ),
389
- P("v-if", !0)
479
+ W("v-if", !0)
390
480
  ],
391
481
  64
392
482
  /* STABLE_FRAGMENT */
393
483
  ));
394
484
  }
395
- }), Y = /* @__PURE__ */ Z(we, [["__scopeId", "data-v-6987322b"]]);
396
- Y.install = (g) => {
397
- g.component("McMarkdownCard", Y);
485
+ }), H = /* @__PURE__ */ $(ke, [["__scopeId", "data-v-a40d857a"]]);
486
+ H.install = (d) => {
487
+ d.component("McMarkdownCard", H);
398
488
  };
399
489
  export {
400
- Y as McMarkdownCard
490
+ H as McMarkdownCard
401
491
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@matechat/core",
3
- "version": "1.5.2",
3
+ "version": "1.6.0-alpha.0",
4
4
  "license": "MIT",
5
5
  "description": "前端智能化场景解决方案UI库,轻松构建你的AI应用。",
6
6
  "keywords": [