md-editor-v3 4.6.2-beta.0 → 4.6.2-beta.2

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.
Files changed (58) hide show
  1. package/lib/cjs/MdCatalog.cjs +1 -1
  2. package/lib/cjs/MdEditor.cjs +15 -15
  3. package/lib/cjs/MdModal.cjs +1 -1
  4. package/lib/cjs/MdPreview.cjs +1 -1
  5. package/lib/cjs/ModalToolbar.cjs +1 -1
  6. package/lib/cjs/chunks/index.cjs +1 -8
  7. package/lib/cjs/chunks/index3.cjs +2 -1
  8. package/lib/cjs/chunks/index4.cjs +8 -2
  9. package/lib/cjs/index.cjs +1 -1
  10. package/lib/es/DropdownToolbar.mjs +2 -2
  11. package/lib/es/MdCatalog.mjs +9 -9
  12. package/lib/es/MdEditor.mjs +533 -521
  13. package/lib/es/MdModal.mjs +1 -1
  14. package/lib/es/MdPreview.mjs +2 -2
  15. package/lib/es/ModalToolbar.mjs +1 -1
  16. package/lib/es/chunks/config.mjs +11 -11
  17. package/lib/es/chunks/index.mjs +138 -1232
  18. package/lib/es/chunks/index2.mjs +2 -2
  19. package/lib/es/chunks/index3.mjs +79 -163
  20. package/lib/es/chunks/index4.mjs +1255 -77
  21. package/lib/es/config.mjs +1 -1
  22. package/lib/es/index.mjs +16 -17
  23. package/lib/preview.css +1 -1
  24. package/lib/style.css +1 -1
  25. package/lib/types/DropdownToolbar/DropdownToolbar.d.ts +1 -1
  26. package/lib/types/DropdownToolbar/index.d.ts +59 -33
  27. package/lib/types/MdCatalog/CatalogLink.d.ts +1 -1
  28. package/lib/types/MdCatalog/MdCatalog.d.ts +1 -1
  29. package/lib/types/MdCatalog/index.d.ts +59 -44
  30. package/lib/types/MdEditor/Editor.d.ts +1 -1
  31. package/lib/types/MdEditor/components/Checkbox/index.d.ts +1 -1
  32. package/lib/types/MdEditor/components/Divider/index.d.ts +1 -1
  33. package/lib/types/MdEditor/components/Dropdown/index.d.ts +1 -1
  34. package/lib/types/MdEditor/components/Icon/Icon.d.ts +1 -1
  35. package/lib/types/MdEditor/components/Icon/index.d.ts +1 -1
  36. package/lib/types/MdEditor/components/Modal/Modal.d.ts +1 -1
  37. package/lib/types/MdEditor/components/Modal/index.d.ts +60 -48
  38. package/lib/types/MdEditor/index.d.ts +101 -225
  39. package/lib/types/MdEditor/layouts/Content/ContentPreview.d.ts +1 -1
  40. package/lib/types/MdEditor/layouts/Content/index.d.ts +1 -1
  41. package/lib/types/MdEditor/layouts/Footer/MarkdownTotal.d.ts +1 -1
  42. package/lib/types/MdEditor/layouts/Footer/ScrollAuto.d.ts +1 -1
  43. package/lib/types/MdEditor/layouts/Footer/index.d.ts +1 -1
  44. package/lib/types/MdEditor/layouts/Modals/Clip.d.ts +1 -1
  45. package/lib/types/MdEditor/layouts/Modals/Link.d.ts +1 -1
  46. package/lib/types/MdEditor/layouts/Modals/index.d.ts +1 -1
  47. package/lib/types/MdEditor/layouts/Toolbar/TableShape.d.ts +1 -1
  48. package/lib/types/MdEditor/layouts/Toolbar/index.d.ts +1 -1
  49. package/lib/types/MdEditor/type.d.ts +1 -3
  50. package/lib/types/MdEditor/utils/vue-tsx.d.ts +1 -1
  51. package/lib/types/MdPreview/MdPreview.d.ts +1 -1
  52. package/lib/types/MdPreview/index.d.ts +72 -114
  53. package/lib/types/ModalToolbar/ModalToolbar.d.ts +1 -1
  54. package/lib/types/ModalToolbar/index.d.ts +64 -58
  55. package/lib/types/NormalToolbar/NormalToolbar.d.ts +1 -1
  56. package/lib/types/NormalToolbar/index.d.ts +56 -24
  57. package/lib/umd/index.js +69 -69
  58. package/package.json +1 -1
@@ -1,87 +1,1265 @@
1
- var r = Object.defineProperty;
2
- var p = (o, s, t) => s in o ? r(o, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[s] = t;
3
- var i = (o, s, t) => (p(o, typeof s != "symbol" ? s + "" : s, t), t);
4
- class h {
5
- constructor() {
6
- // 事件池
7
- i(this, "pools", {});
1
+ import { inject as P, onMounted as S, watch as $, toRef as X, nextTick as L, shallowRef as R, ref as B, computed as F, defineComponent as Q, createVNode as A, Fragment as ue, reactive as Y, provide as H, onBeforeUnmount as de } from "vue";
2
+ import { c as C, p, m as me, k as O, a as U, h as fe, s as j, i as pe, b as he, d as G, e as D, f as ge, g as ye, j as ve } from "./config.mjs";
3
+ import { u as be, a as we, b as g, P as ke, C as V, B as M, O as ee, E as $e, U as Ce, c as te, d as z, F as K, e as q, H as Z, f as W, R as ne, h as Ie, T as Se } from "./index3.mjs";
4
+ import { a as _, u as Ee } from "./dom.mjs";
5
+ import Pe from "medium-zoom";
6
+ import { debounce as oe } from "@vavt/util";
7
+ import Te from "copy-to-clipboard";
8
+ import _e from "markdown-it";
9
+ import He from "markdown-it-image-figures";
10
+ import Fe from "markdown-it-task-lists";
11
+ import Ae from "lru-cache";
12
+ const Me = (e, a) => {
13
+ const l = P("editorId"), { noImgZoomIn: t } = e, n = oe(() => {
14
+ const r = document.querySelectorAll(`#${l}-preview img`);
15
+ r.length !== 0 && Pe(r, {
16
+ background: "#00000073"
17
+ });
18
+ });
19
+ S(() => {
20
+ !t && n();
21
+ }), $([a, X(e.setting, "preview")], () => {
22
+ !t && n();
23
+ });
24
+ }, Re = Me, xe = (e, a) => {
25
+ if (typeof a[e] == "string")
26
+ return a[e];
27
+ const l = `<i class="${p}-iconfont ${p}-icon-${e}"></i>`;
28
+ switch (C.iconfontType) {
29
+ case "svg":
30
+ return `<svg class="${p}-icon" aria-hidden="true"><use xlink:href="#${p}-icon-${e}"></use></svg>`;
31
+ default:
32
+ return l;
33
+ }
34
+ }, Le = (e, a) => {
35
+ const l = P("editorId"), t = P("usedLanguageText"), n = P("customIcon"), r = () => {
36
+ document.querySelectorAll(`#${l}-preview pre`).forEach((u) => {
37
+ var b, v;
38
+ let s = -1;
39
+ (b = u.querySelector(".copy-button")) == null || b.remove();
40
+ const o = ((v = t.value.copyCode) == null ? void 0 : v.text) || "复制代码", d = document.createElement("span");
41
+ d.setAttribute("class", "copy-button"), d.dataset.tips = o, d.innerHTML = xe("copy", n.value), d.addEventListener("click", () => {
42
+ var y, w;
43
+ clearTimeout(s);
44
+ const m = u.querySelector("code").innerText, h = Te(e.formatCopiedText(m)), f = ((y = t.value.copyCode) == null ? void 0 : y.successTips) || "已复制!", k = ((w = t.value.copyCode) == null ? void 0 : w.failTips) || "已复制!";
45
+ d.dataset.tips = h ? f : k, s = window.setTimeout(() => {
46
+ d.dataset.tips = o;
47
+ }, 1500);
48
+ }), u.appendChild(d);
49
+ });
50
+ }, i = () => {
51
+ L(r);
52
+ }, c = (u) => {
53
+ u && L(r);
54
+ };
55
+ $(() => a.value, i), $(() => e.setting.preview, c), $(() => e.setting.htmlPreview, c), $(() => t.value, r), S(r);
56
+ }, Be = Le, Ne = (e) => {
57
+ var r;
58
+ const a = (r = C.editorExtensions) == null ? void 0 : r.highlight, l = a == null ? void 0 : a.instance, t = P("highlight"), n = R(l);
59
+ return S(() => {
60
+ if (!e.noHighlight && !n.value) {
61
+ const i = document.createElement("script");
62
+ i.src = t.value.js, i.onload = () => {
63
+ n.value = window.hljs;
64
+ }, i.id = `${p}-hljs`, _(i, "hljs");
65
+ const c = document.createElement("link");
66
+ c.rel = "stylesheet", c.href = t.value.css, c.id = `${p}-hlCss`, _(c);
67
+ }
68
+ }), $(
69
+ () => t.value.css,
70
+ (i) => {
71
+ Ee(`${p}-hlCss`, "href", i);
72
+ }
73
+ ), n;
74
+ }, Oe = Ne, Ue = (e) => {
75
+ const a = P("theme"), { editorExtensions: l } = C, t = l == null ? void 0 : l.mermaid, n = R(t == null ? void 0 : t.instance), r = R(-1), i = new Ae({
76
+ max: 1e3,
77
+ // 缓存10分钟
78
+ ttl: 6e5
79
+ }), c = () => {
80
+ const s = n.value;
81
+ !e.noMermaid && s && (s.initialize({
82
+ startOnLoad: !1,
83
+ theme: a.value === "dark" ? "dark" : "default"
84
+ }), r.value = r.value + 1);
85
+ };
86
+ return $(
87
+ () => a.value,
88
+ () => {
89
+ i.clear(), c();
90
+ }
91
+ ), S(() => {
92
+ if (!e.noMermaid && !(t != null && t.instance)) {
93
+ const s = (t == null ? void 0 : t.js) || me;
94
+ if (/\.mjs/.test(s))
95
+ import(
96
+ /* @vite-ignore */
97
+ /* webpackIgnore: true */
98
+ s
99
+ ).then((o) => {
100
+ n.value = o.default, c();
101
+ });
102
+ else {
103
+ const o = document.createElement("script");
104
+ o.id = `${p}-mermaid`, o.src = s, o.onload = () => {
105
+ n.value = window.mermaid, c();
106
+ }, _(o, "mermaid");
107
+ }
108
+ }
109
+ }), { mermaidRef: n, reRenderRef: r, replaceMermaid: () => {
110
+ L(() => {
111
+ if (!e.noMermaid && n.value) {
112
+ const s = document.querySelectorAll(
113
+ `div.${p}-mermaid`
114
+ ), o = document.createElement("div");
115
+ o.style.width = document.body.offsetWidth + "px", o.style.height = document.body.offsetHeight + "px", o.style.position = "fixed", o.style.zIndex = "-10000", o.style.top = "-10000";
116
+ let d = s.length;
117
+ d > 0 && document.body.appendChild(o), s.forEach(async (b) => {
118
+ let v = i.get(b.innerText);
119
+ if (!v) {
120
+ const h = be(), f = n.value.renderAsync || n.value.render;
121
+ let k = "";
122
+ try {
123
+ k = await f(h, b.innerText, o);
124
+ } catch {
125
+ }
126
+ v = typeof k == "string" ? k : k.svg, i.set(b.innerText, v);
127
+ }
128
+ const m = document.createElement("p");
129
+ m.className = `${p}-mermaid`, m.setAttribute("data-processed", ""), m.innerHTML = v, b.dataset.line !== void 0 && (m.dataset.line = b.dataset.line), b.replaceWith(m), --d === 0 && o.remove();
130
+ });
131
+ }
132
+ });
133
+ } };
134
+ }, je = Ue, Ge = (e) => {
135
+ var n;
136
+ const a = (n = C.editorExtensions) == null ? void 0 : n.katex, l = a == null ? void 0 : a.instance, t = R(l);
137
+ return S(() => {
138
+ if (!e.noKatex && !t.value) {
139
+ const r = document.createElement("script");
140
+ r.src = (a == null ? void 0 : a.js) || O.js, r.onload = () => {
141
+ t.value = window.katex;
142
+ }, r.id = `${p}-katex`;
143
+ const i = document.createElement("link");
144
+ i.rel = "stylesheet", i.href = (a == null ? void 0 : a.css) || O.css, i.id = `${p}-katexCss`, _(r, "katex"), _(i);
145
+ }
146
+ }), t;
147
+ }, De = Ge, Ve = (e, a) => {
148
+ const l = e.renderer.rules.fence.bind(e.renderer.rules);
149
+ e.renderer.rules.fence = (t, n, r, i, c) => {
150
+ const u = t[n], s = u.content.trim();
151
+ if (u.info === "mermaid") {
152
+ let o;
153
+ return t[n].map && t[n].level === 0 && (o = t[n].map[0], t[n].attrSet("data-line", String(o))), `<div class="${p}-mermaid" ${o !== void 0 ? "data-line=" + o : ""} data-mermaid-theme=${a.themeRef.value}>${s}</div>`;
154
+ }
155
+ return l(t, n, r, i, c);
156
+ };
157
+ }, ze = Ve, J = (e, a) => {
158
+ let l = !0, t = !0;
159
+ const n = e.posMax, r = a > 0 ? e.src.charCodeAt(a - 1) : -1, i = a + 1 <= n ? e.src.charCodeAt(a + 1) : -1;
160
+ return (r === 32 || r === 9 || i >= 48 && i <= 57) && (t = !1), (i === 32 || i === 9) && (l = !1), {
161
+ can_open: l,
162
+ can_close: t
163
+ };
164
+ }, Ke = (e, a) => {
165
+ let l, t, n, r;
166
+ if (e.src[e.pos] !== "$")
167
+ return !1;
168
+ if (n = J(e, e.pos), !n.can_open)
169
+ return a || (e.pending += "$"), e.pos += 1, !0;
170
+ const i = e.pos + 1;
171
+ for (l = i; (l = e.src.indexOf("$", l)) !== -1; ) {
172
+ for (r = l - 1; e.src[r] === "\\"; )
173
+ r -= 1;
174
+ if ((l - r) % 2 == 1)
175
+ break;
176
+ l += 1;
177
+ }
178
+ return l === -1 ? (a || (e.pending += "$"), e.pos = i, !0) : l - i === 0 ? (a || (e.pending += "$$"), e.pos = i + 1, !0) : (n = J(e, l), n.can_close ? (a || (t = e.push("math_inline", "math", 0), t.markup = "$", t.content = e.src.slice(i, l)), e.pos = l + 1, !0) : (a || (e.pending += "$"), e.pos = i, !0));
179
+ }, qe = (e, a, l, t) => {
180
+ let n, r, i, c, u = !1, s = e.bMarks[a] + e.tShift[a], o = e.eMarks[a];
181
+ if (s + 2 > o || e.src.slice(s, s + 2) !== "$$")
182
+ return !1;
183
+ if (s += 2, n = e.src.slice(s, o), t)
184
+ return !0;
185
+ for (n.trim().slice(-2) === "$$" && (n = n.trim().slice(0, -2), u = !0), i = a; !u && (i++, !(i >= l || (s = e.bMarks[i] + e.tShift[i], o = e.eMarks[i], s < o && e.tShift[i] < e.blkIndent))); )
186
+ e.src.slice(s, o).trim().slice(-2) === "$$" && (c = e.src.slice(0, o).lastIndexOf("$$"), r = e.src.slice(s, c), u = !0);
187
+ e.line = i + 1;
188
+ const d = e.push("math_block", "math", 0);
189
+ return d.block = !0, d.content = (n && n.trim() ? n + `
190
+ ` : "") + e.getLines(a + 1, i, e.tShift[a], !0) + (r && r.trim() ? r : ""), d.map = [a, e.line], d.markup = "$$", !0;
191
+ }, Ze = (e, a) => {
192
+ const l = (n) => {
193
+ if (a.katexRef.value) {
194
+ const r = a.katexRef.value.renderToString(n, {
195
+ throwOnError: !1
196
+ });
197
+ return `<span class="${p}-katex-inline" data-processed>${r}</span>`;
198
+ } else
199
+ return `<span class="${p}-katex-inline">${n}</span>`;
200
+ }, t = (n, r) => {
201
+ if (a.katexRef.value) {
202
+ const i = a.katexRef.value.renderToString(n, {
203
+ throwOnError: !1,
204
+ displayMode: !0
205
+ });
206
+ return `<p class="${p}-katex-block" data-line=${r} data-processed>${i}</p>`;
207
+ } else
208
+ return `<p class="${p}-katex-block" data-line=${r}>${n}</p>`;
209
+ };
210
+ e.inline.ruler.after("escape", "math_inline", Ke), e.block.ruler.after("blockquote", "math_block", qe, {
211
+ alt: ["paragraph", "reference", "blockquote", "list"]
212
+ }), e.renderer.rules.math_inline = (n, r) => l(n[r].content), e.renderer.rules.math_block = (n, r) => t(n[r].content, n[r].map[0]) + `
213
+ `;
214
+ }, We = Ze, Je = (e, a) => {
215
+ a = a || {};
216
+ const l = 3, t = a.marker || "!", n = t.charCodeAt(0), r = t.length;
217
+ let i = "", c = "";
218
+ const u = (o, d, b, v, m) => {
219
+ const h = o[d];
220
+ return h.type === "admonition_open" ? (o[d].attrPush([
221
+ "class",
222
+ `${p}-admonition ${p}-admonition-${h.info}`
223
+ ]), o[d].attrSet("data-line", String(o[d].map[0]))) : h.type === "admonition_title_open" && o[d].attrPush(["class", `${p}-admonition-title`]), m.renderToken(o, d, b);
224
+ }, s = (o) => {
225
+ const d = o.trim().split(" ", 2);
226
+ c = "", i = d[0], d.length > 1 && (c = o.substring(i.length + 2)), (c === "" || !c) && (c = i);
227
+ };
228
+ e.block.ruler.before(
229
+ "code",
230
+ "admonition",
231
+ (o, d, b, v) => {
232
+ let m, h, f, k = !1, y = o.bMarks[d] + o.tShift[d], w = o.eMarks[d];
233
+ if (n !== o.src.charCodeAt(y))
234
+ return !1;
235
+ for (m = y + 1; m <= w && t[(m - y) % r] === o.src[m]; m++)
236
+ ;
237
+ const I = Math.floor((m - y) / r);
238
+ if (I !== l)
239
+ return !1;
240
+ m -= (m - y) % r;
241
+ const E = o.src.slice(y, m), T = o.src.slice(m, w);
242
+ if (s(T), v)
243
+ return !0;
244
+ for (h = d; h++, !(h >= b || (y = o.bMarks[h] + o.tShift[h], w = o.eMarks[h], y < w && o.sCount[h] < o.blkIndent)); )
245
+ if (n === o.src.charCodeAt(y) && !(o.sCount[h] - o.blkIndent >= 4)) {
246
+ for (m = y + 1; m <= w && t[(m - y) % r] === o.src[m]; m++)
247
+ ;
248
+ if (!(Math.floor((m - y) / r) < I) && (m -= (m - y) % r, m = o.skipSpaces(m), !(m < w))) {
249
+ k = !0;
250
+ break;
251
+ }
252
+ }
253
+ const N = o.parentType, se = o.lineMax;
254
+ return o.parentType = "root", o.lineMax = h, f = o.push("admonition_open", "div", 1), f.markup = E, f.block = !0, f.info = i, f.map = [d, h], f = o.push("admonition_title_open", "p", 1), f.markup = E + " " + i, f.map = [d, h], f = o.push("inline", "", 0), f.content = c, f.map = [d, o.line - 1], f.children = [], f = o.push("admonition_title_close", "p", -1), f.markup = E + " " + i, o.md.block.tokenize(o, d + 1, h), f = o.push("admonition_close", "div", -1), f.markup = o.src.slice(y, m), f.block = !0, o.parentType = N, o.lineMax = se, o.line = h + (k ? 1 : 0), !0;
255
+ },
256
+ {
257
+ alt: ["paragraph", "reference", "blockquote", "list"]
258
+ }
259
+ ), e.renderer.rules.admonition_open = u, e.renderer.rules.admonition_title_open = u, e.renderer.rules.admonition_title_close = u, e.renderer.rules.admonition_close = u;
260
+ }, Xe = Je, Qe = (e, a) => {
261
+ e.renderer.rules.heading_open = (l, t) => {
262
+ var c;
263
+ const n = l[t], r = ((c = l[t + 1].children) == null ? void 0 : c.reduce((u, s) => u + (s.content || ""), "")) || "", i = n.markup.length;
264
+ return a.headsRef.value.push({
265
+ text: r,
266
+ level: i
267
+ }), n.map && n.level === 0 && (n.attrSet("data-line", String(n.map[0])), n.attrSet(
268
+ "id",
269
+ a.mdHeadingId(r, i, a.headsRef.value.length)
270
+ )), e.renderer.renderToken(l, t, a);
271
+ }, e.renderer.rules.heading_close = (l, t, n, r, i) => i.renderToken(l, t, n);
272
+ }, Ye = Qe, et = (e, a) => {
273
+ const l = e.renderer.rules.fence, t = e.utils.unescapeAll, n = /\[(\w*)(?::([\w ]*))?\]/;
274
+ function r(s) {
275
+ return s.info ? t(s.info).trim() : "";
276
+ }
277
+ function i(s) {
278
+ const o = r(s), [d = null, b = ""] = (n.exec(o) || []).slice(1);
279
+ return [d, b];
8
280
  }
9
- // 移除事件监听
10
- remove(s, t, n) {
11
- const a = this.pools[s] && this.pools[s][t];
12
- a && (this.pools[s][t] = a.filter((e) => e !== n));
281
+ function c(s) {
282
+ const o = r(s);
283
+ return o ? o.split(/(\s+)/g)[0] : "";
284
+ }
285
+ const u = (s, o, d, b, v) => {
286
+ if (s[o].hidden)
287
+ return "";
288
+ const [m, h] = i(s[o]);
289
+ if (m === null)
290
+ return l(s, o, d, b, v);
291
+ let f, k, y, w, I = "", E = "";
292
+ for (let T = o; T < s.length && (f = s[T], [k, y] = i(f), k === m); T++)
293
+ f.info = f.info.replace(n, ""), f.hidden = !0, w = T - o > 0 ? "" : " checked", I += `<li><input type="radio" name="label-group-${a.editorId}-${o}"${w}><label for="group-${a.editorId}-${o}-tab-${T - o}" onclick="this.previousElementSibling.click()">${y || c(f)}</label></li>
294
+ `, E += `<input type="radio" id="group-${a.editorId}-${o}-tab-${T - o}" name="group-${a.editorId}-${o}"${w}>
295
+ ` + l(s, T, d, b, v);
296
+ return `<div class="code-tabs">
297
+ <ul>
298
+ ` + I + `</ul>
299
+ ` + E + "</div>";
300
+ };
301
+ e.renderer.rules.fence = u;
302
+ }, tt = et, nt = (e) => {
303
+ [
304
+ "paragraph_open",
305
+ "table_open",
306
+ "ordered_list_open",
307
+ "bullet_list_open",
308
+ "blockquote_open",
309
+ "hr",
310
+ "html_block",
311
+ "fence"
312
+ ].forEach((a) => {
313
+ const l = e.renderer.rules[a];
314
+ l ? e.renderer.rules[a] = (t, n, r, i, c) => {
315
+ let u;
316
+ const s = l(t, n, r, i, c);
317
+ return t[n].map && t[n].level === 0 ? (u = t[n].map[0], s.replace(/^(<[^>]*)/, `$1 data-line="${u}"`)) : s;
318
+ } : e.renderer.rules[a] = (t, n, r, i, c) => {
319
+ let u;
320
+ return t[n].map && t[n].level === 0 && (u = t[n].map[0], t[n].attrSet("data-line", String(u))), c.renderToken(t, n, r);
321
+ };
322
+ });
323
+ }, ot = (e, a) => {
324
+ const { editorConfig: l, markdownItConfig: t, markdownItPlugins: n } = C, r = P("editorId"), i = P("showCodeRowNumber"), c = P("theme"), u = B([]), s = Oe(e), o = De(e), { reRenderRef: d, replaceMermaid: b } = je(e), v = _e({
325
+ html: !0,
326
+ breaks: !0
327
+ });
328
+ t(v);
329
+ const m = [
330
+ {
331
+ type: "katex",
332
+ plugin: We,
333
+ options: { katexRef: o }
334
+ },
335
+ {
336
+ type: "image",
337
+ plugin: He,
338
+ options: { figcaption: !0, classes: "md-zoom" }
339
+ },
340
+ {
341
+ type: "admonition",
342
+ plugin: Xe,
343
+ options: {}
344
+ },
345
+ {
346
+ type: "taskList",
347
+ plugin: Fe,
348
+ options: {}
349
+ },
350
+ {
351
+ type: "heading",
352
+ plugin: Ye,
353
+ options: { mdHeadingId: e.mdHeadingId, headsRef: u }
354
+ },
355
+ {
356
+ type: "codeTabs",
357
+ plugin: tt,
358
+ options: { editorId: r }
359
+ }
360
+ ];
361
+ e.noMermaid || m.push({
362
+ type: "mermaid",
363
+ plugin: ze,
364
+ options: { themeRef: c }
365
+ }), n(m).forEach((w) => {
366
+ v.use(w.plugin, w.options);
367
+ }), v.set({
368
+ highlight: (w, I) => {
369
+ let E;
370
+ !e.noHighlight && s.value ? s.value.getLanguage(I) ? E = s.value.highlight(w, {
371
+ language: I,
372
+ ignoreIllegals: !0
373
+ }).value : E = s.value.highlightAuto(w).value : E = v.utils.escapeHtml(w);
374
+ const T = i ? we(E.trim()) : `<span class="code-block">${E.trim()}</span>`;
375
+ return `<pre><code class="language-${I}" language=${I}>${T}</code></pre>`;
376
+ }
377
+ }), nt(v);
378
+ const h = B(e.sanitize(v.render(e.modelValue))), f = () => {
379
+ g.emit(r, M, h.value), e.onHtmlChanged(h.value), e.onGetCatalog(u.value), g.emit(r, V, u.value), b();
380
+ };
381
+ S(f);
382
+ const k = oe(
383
+ async () => {
384
+ u.value = [], h.value = e.sanitize(v.render(e.modelValue)), f();
385
+ },
386
+ (l == null ? void 0 : l.renderDelay) !== void 0 ? l == null ? void 0 : l.renderDelay : a ? 0 : 500
387
+ ), y = F(() => (e.noKatex || o.value) && (e.noHighlight || s.value));
388
+ return $([X(e, "modelValue"), y, d], k), S(() => {
389
+ g.on(r, {
390
+ name: ke,
391
+ callback() {
392
+ g.emit(r, V, u.value);
393
+ }
394
+ });
395
+ }), { html: h };
396
+ }, rt = ot, re = {
397
+ modelValue: {
398
+ type: String,
399
+ default: ""
400
+ },
401
+ setting: {
402
+ type: Object,
403
+ default: () => ({})
404
+ },
405
+ onHtmlChanged: {
406
+ type: Function,
407
+ default: () => {
408
+ }
409
+ },
410
+ onGetCatalog: {
411
+ type: Function,
412
+ default: () => {
413
+ }
414
+ },
415
+ mdHeadingId: {
416
+ type: Function,
417
+ default: () => ""
418
+ },
419
+ noMermaid: {
420
+ type: Boolean,
421
+ default: !1
422
+ },
423
+ sanitize: {
424
+ type: Function,
425
+ default: (e) => e
426
+ },
427
+ // 不使用该函数功能
428
+ noKatex: {
429
+ type: Boolean,
430
+ default: !1
431
+ },
432
+ formatCopiedText: {
433
+ type: Function,
434
+ default: (e) => e
435
+ },
436
+ noHighlight: {
437
+ type: Boolean,
438
+ default: !1
439
+ },
440
+ previewOnly: {
441
+ type: Boolean,
442
+ default: !1
443
+ },
444
+ noImgZoomIn: {
445
+ type: Boolean
13
446
  }
14
- // 清空全部事件,由于单一实例,多次注册会被共享内容
15
- clear(s) {
16
- this.pools[s] = {};
447
+ }, bt = {
448
+ ...re,
449
+ onChange: {
450
+ type: Function,
451
+ default: () => {
452
+ }
453
+ },
454
+ placeholder: {
455
+ type: String,
456
+ default: ""
457
+ },
458
+ scrollAuto: {
459
+ type: Boolean
460
+ },
461
+ autofocus: {
462
+ type: Boolean
463
+ },
464
+ disabled: {
465
+ type: Boolean
466
+ },
467
+ readonly: {
468
+ type: Boolean
469
+ },
470
+ maxlength: {
471
+ type: Number
472
+ },
473
+ autoDetectCode: {
474
+ type: Boolean
475
+ },
476
+ /**
477
+ * 输入框失去焦点时触发事件
478
+ */
479
+ onBlur: {
480
+ type: Function,
481
+ default: () => {
482
+ }
483
+ },
484
+ /**
485
+ * 输入框获得焦点时触发事件
486
+ */
487
+ onFocus: {
488
+ type: Function,
489
+ default: () => {
490
+ }
491
+ },
492
+ noPrettier: {
493
+ type: Boolean
494
+ },
495
+ completions: {
496
+ type: Array
497
+ },
498
+ catalogVisible: {
499
+ type: Boolean
500
+ },
501
+ theme: {
502
+ type: String,
503
+ default: "light"
504
+ },
505
+ onInput: {
506
+ type: Function
507
+ },
508
+ onDrop: {
509
+ type: Function,
510
+ default: () => {
511
+ }
17
512
  }
18
- // 注册事件监听
19
- on(s, t) {
20
- return this.pools[s] || (this.pools[s] = {}), this.pools[s][t.name] || (this.pools[s][t.name] = []), this.pools[s][t.name].push(t.callback), this.pools[s][t.name].includes(t.callback);
513
+ }, at = /* @__PURE__ */ Q({
514
+ name: "ContentPreview",
515
+ props: re,
516
+ setup(e) {
517
+ const a = P("editorId"), l = P("previewTheme"), t = P("showCodeRowNumber"), {
518
+ html: n
519
+ } = rt(e, e.previewOnly);
520
+ return Be(e, n), Re(e, n), () => A(ue, null, [A("div", {
521
+ id: `${a}-preview-wrapper`,
522
+ class: `${p}-preview-wrapper`,
523
+ "data-show": e.setting.preview,
524
+ key: "content-preview-wrapper"
525
+ }, [A("article", {
526
+ id: `${a}-preview`,
527
+ class: [`${p}-preview`, `${l == null ? void 0 : l.value}-theme`, t && `${p}-scrn`],
528
+ innerHTML: n.value
529
+ }, null)]), !e.previewOnly && A("div", {
530
+ id: `${a}-html-wrapper`,
531
+ class: `${p}-preview-wrapper`,
532
+ "data-show": e.setting.htmlPreview,
533
+ key: "html-preview-wrapper"
534
+ }, [A("div", {
535
+ class: `${p}-html`
536
+ }, [n.value])])]);
21
537
  }
22
- // 触发事件
23
- emit(s, t, ...n) {
24
- this.pools[s] || (this.pools[s] = {});
25
- const a = this.pools[s][t];
26
- a && a.forEach((e) => {
27
- try {
28
- e(...n);
29
- } catch (c) {
30
- console.error(`${t} monitor event exception!`, c);
538
+ }), wt = (e, a) => {
539
+ const { editorId: l } = e, t = Y({
540
+ // 是否已编译成html
541
+ buildFinished: !1,
542
+ // 存储当前最新的html
543
+ html: ""
544
+ });
545
+ $(
546
+ () => e.modelValue,
547
+ () => {
548
+ t.buildFinished = !1;
549
+ }
550
+ ), S(() => {
551
+ g.on(l, {
552
+ name: M,
553
+ callback(n) {
554
+ t.buildFinished = !0, t.html = n;
555
+ }
556
+ }), g.on(l, {
557
+ name: ee,
558
+ callback() {
559
+ const n = new Promise((r) => {
560
+ if (t.buildFinished)
561
+ r(t.html);
562
+ else {
563
+ const i = (c) => {
564
+ r(c), g.remove(l, M, i);
565
+ };
566
+ g.on(l, {
567
+ name: M,
568
+ callback: i
569
+ });
570
+ }
571
+ });
572
+ e.onSave ? e.onSave(e.modelValue, n) : a.emit("onSave", e.modelValue, n);
573
+ }
574
+ });
575
+ });
576
+ }, ae = (e) => {
577
+ var n, r;
578
+ const { editorId: a } = e, l = (r = (n = C) == null ? void 0 : n.editorExtensions) == null ? void 0 : r.highlight;
579
+ H("editorId", a), H(
580
+ "theme",
581
+ F(() => e.theme)
582
+ ), H(
583
+ "highlight",
584
+ F(() => {
585
+ const i = {
586
+ ...U,
587
+ ...l == null ? void 0 : l.css
588
+ }, c = e.codeStyleReverse && e.codeStyleReverseList.includes(e.previewTheme) ? "dark" : e.theme;
589
+ return {
590
+ js: (l == null ? void 0 : l.js) || fe,
591
+ css: i[e.codeTheme] ? i[e.codeTheme][c] : U.atom[c]
592
+ };
593
+ })
594
+ ), H("showCodeRowNumber", e.showCodeRowNumber);
595
+ const t = F(() => {
596
+ var c, u;
597
+ const i = {
598
+ ...j,
599
+ ...(u = (c = C) == null ? void 0 : c.editorConfig) == null ? void 0 : u.languageUserDefined
600
+ };
601
+ return i[e.language] ? i[e.language] : j["zh-CN"];
602
+ });
603
+ H("usedLanguageText", t), H(
604
+ "previewTheme",
605
+ F(() => e.previewTheme)
606
+ ), H(
607
+ "customIcon",
608
+ F(() => e.customIcon)
609
+ );
610
+ }, kt = (e) => {
611
+ ae(e), H("tabWidth", e.tabWidth);
612
+ }, le = (e) => {
613
+ S(() => {
614
+ var a, l;
615
+ if (!e.noIconfont)
616
+ if (C.iconfontType === "svg") {
617
+ const t = document.createElement("script");
618
+ t.src = ((a = C.editorExtensions) == null ? void 0 : a.iconfont) || pe, t.id = `${p}-icon`, _(t);
619
+ } else {
620
+ const t = document.createElement("link");
621
+ t.rel = "stylesheet", t.href = ((l = C.editorExtensions) == null ? void 0 : l.iconfontClass) || he, t.id = `${p}-icon-class`, _(t);
622
+ }
623
+ });
624
+ }, $t = (e) => {
625
+ var c, u, s, o, d, b;
626
+ const { noPrettier: a, noUploadImg: l } = e, { editorExtensions: t } = C, n = a || !!((u = (c = C.editorExtensions) == null ? void 0 : c.prettier) != null && u.prettierInstance), r = a || !!((o = (s = C.editorExtensions) == null ? void 0 : s.prettier) != null && o.parserMarkdownInstance), i = l || !!((b = (d = C.editorExtensions) == null ? void 0 : d.cropper) != null && b.instance);
627
+ S(() => {
628
+ var k, y, w, I;
629
+ const v = document.createElement("script"), m = document.createElement("script");
630
+ v.src = ((k = t == null ? void 0 : t.prettier) == null ? void 0 : k.standaloneJs) || G.main, v.id = `${p}-prettier`, m.src = ((y = t == null ? void 0 : t.prettier) == null ? void 0 : y.parserMarkdownJs) || G.markdown, m.id = `${p}-prettierMD`;
631
+ const h = document.createElement("link");
632
+ h.rel = "stylesheet", h.href = ((w = t == null ? void 0 : t.cropper) == null ? void 0 : w.css) || D.css, h.id = `${p}-cropperCss`;
633
+ const f = document.createElement("script");
634
+ f.src = ((I = t == null ? void 0 : t.cropper) == null ? void 0 : I.js) || D.js, f.id = `${p}-cropper`, i || (_(h), _(f)), n || _(v), r || _(m);
635
+ }), le(e);
636
+ }, Ct = (e, a) => {
637
+ const { editorId: l } = e;
638
+ S(() => {
639
+ g.on(l, {
640
+ name: $e,
641
+ callback: (t) => {
642
+ e.onError instanceof Function ? e.onError(t) : a.emit("onError", t);
31
643
  }
32
644
  });
645
+ });
646
+ }, It = (e, a) => {
647
+ const { editorId: l } = e, t = Y({
648
+ pageFullscreen: e.pageFullscreen,
649
+ fullscreen: !1,
650
+ preview: e.preview,
651
+ htmlPreview: e.preview ? !1 : e.htmlPreview
652
+ }), n = (c, u) => {
653
+ t[c] = u === void 0 ? !t[c] : u, c === "preview" && t.preview ? t.htmlPreview = !1 : c === "htmlPreview" && t.htmlPreview && (t.preview = !1);
654
+ };
655
+ let r = "";
656
+ const i = () => {
657
+ t.pageFullscreen || t.fullscreen ? document.body.style.overflow = "hidden" : document.body.style.overflow = r;
658
+ };
659
+ return $(() => [t.pageFullscreen, t.fullscreen], i), S(() => {
660
+ g.on(l, {
661
+ name: Ce,
662
+ callback(c, u) {
663
+ const s = (o) => {
664
+ g.emit(l, ne, "image", {
665
+ desc: "",
666
+ urls: o
667
+ }), u && u();
668
+ };
669
+ e.onUploadImg ? e.onUploadImg(c, s) : a.emit("onUploadImg", c, s);
670
+ }
671
+ }), r = document.body.style.overflow, i();
672
+ }), [t, n];
673
+ }, St = (e) => {
674
+ const { editorId: a } = e, l = B(!1);
675
+ return S(() => {
676
+ g.on(a, {
677
+ name: te,
678
+ callback: (n) => {
679
+ n === void 0 ? l.value = !l.value : l.value = n;
680
+ }
681
+ });
682
+ }), F(() => !e.toolbarsExclude.includes("catalog") && e.toolbars.includes("catalog") && l.value);
683
+ }, Et = (e, a, l, t, n) => {
684
+ const { editorId: r } = e;
685
+ $(
686
+ () => t.pageFullscreen,
687
+ (c) => {
688
+ g.emit(r, z, c);
689
+ }
690
+ ), $(
691
+ () => t.fullscreen,
692
+ (c) => {
693
+ g.emit(r, K, c);
694
+ }
695
+ ), $(
696
+ () => t.preview,
697
+ (c) => {
698
+ g.emit(r, q, c);
699
+ }
700
+ ), $(
701
+ () => t.htmlPreview,
702
+ (c) => {
703
+ g.emit(r, Z, c);
704
+ }
705
+ ), $(l, (c) => {
706
+ g.emit(r, W, c);
707
+ });
708
+ const i = {
709
+ on(c, u) {
710
+ switch (c) {
711
+ case "pageFullscreen": {
712
+ g.on(r, {
713
+ name: z,
714
+ callback(s) {
715
+ u(s);
716
+ }
717
+ });
718
+ break;
719
+ }
720
+ case "fullscreen": {
721
+ g.on(r, {
722
+ name: K,
723
+ callback(s) {
724
+ u(s);
725
+ }
726
+ });
727
+ break;
728
+ }
729
+ case "preview": {
730
+ g.on(r, {
731
+ name: q,
732
+ callback(s) {
733
+ u(s);
734
+ }
735
+ });
736
+ break;
737
+ }
738
+ case "htmlPreview": {
739
+ g.on(r, {
740
+ name: Z,
741
+ callback(s) {
742
+ u(s);
743
+ }
744
+ });
745
+ break;
746
+ }
747
+ case "catalog": {
748
+ g.on(r, {
749
+ name: W,
750
+ callback(s) {
751
+ u(s);
752
+ }
753
+ });
754
+ break;
755
+ }
756
+ }
757
+ },
758
+ togglePageFullscreen(c) {
759
+ n("pageFullscreen", c);
760
+ },
761
+ toggleFullscreen(c) {
762
+ g.emit(r, Ie, c);
763
+ },
764
+ togglePreview(c) {
765
+ n("preview", c);
766
+ },
767
+ toggleHtmlPreview(c) {
768
+ n("htmlPreview", c);
769
+ },
770
+ toggleCatalog(c) {
771
+ g.emit(r, te, c);
772
+ },
773
+ triggerSave() {
774
+ g.emit(r, ee);
775
+ },
776
+ insert(c) {
777
+ g.emit(r, ne, "universal", { generate: c });
778
+ },
779
+ focus(c) {
780
+ g.emit(r, Se, c);
781
+ }
782
+ };
783
+ a.expose(i);
784
+ }, lt = (e) => e, ie = {
785
+ /**
786
+ * markdown content.
787
+ *
788
+ * @default ''
789
+ */
790
+ modelValue: {
791
+ type: String,
792
+ default: ""
793
+ },
794
+ /**
795
+ * 主题,支持light和dark
796
+ *
797
+ * @default 'light'
798
+ */
799
+ theme: {
800
+ type: String,
801
+ default: "light"
802
+ },
803
+ /**
804
+ * 外层类名
805
+ *
806
+ * @default ''
807
+ */
808
+ class: {
809
+ type: String,
810
+ default: ""
811
+ },
812
+ /**
813
+ * 预设语言名称
814
+ *
815
+ * @default 'zh-CN'
816
+ */
817
+ language: {
818
+ type: String,
819
+ default: "zh-CN"
820
+ },
821
+ /**
822
+ * html变化事件
823
+ */
824
+ onHtmlChanged: {
825
+ type: Function
826
+ },
827
+ /**
828
+ * 获取目录结构
829
+ */
830
+ onGetCatalog: {
831
+ type: Function
832
+ },
833
+ /**
834
+ * 编辑器唯一标识
835
+ *
836
+ * @default 'md-editor-v3'
837
+ */
838
+ editorId: {
839
+ type: String,
840
+ default: ge
841
+ },
842
+ /**
843
+ * 预览中代码是否显示行号
844
+ *
845
+ * @default false
846
+ */
847
+ showCodeRowNumber: {
848
+ type: Boolean,
849
+ default: !1
850
+ },
851
+ /**
852
+ * 预览内容样式
853
+ *
854
+ * @default 'default'
855
+ */
856
+ previewTheme: {
857
+ type: String,
858
+ default: "default"
859
+ },
860
+ /**
861
+ * 编辑器样式
862
+ */
863
+ style: {
864
+ type: Object,
865
+ default: () => ({})
866
+ },
867
+ /**
868
+ * 标题的id生成方式
869
+ *
870
+ * @default (text: string) => text
871
+ */
872
+ mdHeadingId: {
873
+ type: Function,
874
+ default: lt
875
+ },
876
+ /**
877
+ *
878
+ * 不能保证文本正确的情况,在marked编译md文本后通过该方法处理
879
+ * 推荐DOMPurify、sanitize-html
880
+ *
881
+ * @default (text: string) => text
882
+ */
883
+ sanitize: {
884
+ type: Function,
885
+ default: (e) => e
886
+ },
887
+ /**
888
+ * 不使用该mermaid
889
+ *
890
+ * @default false
891
+ */
892
+ noMermaid: {
893
+ type: Boolean,
894
+ default: !1
895
+ },
896
+ /**
897
+ * 不使用katex
898
+ *
899
+ * @default false
900
+ */
901
+ noKatex: {
902
+ type: Boolean,
903
+ default: !1
904
+ },
905
+ /**
906
+ * 代码主题
907
+ *
908
+ * @default 'atom'
909
+ */
910
+ codeTheme: {
911
+ type: String,
912
+ default: "atom"
913
+ },
914
+ /**
915
+ * 不插入iconfont链接
916
+ *
917
+ * @default false
918
+ */
919
+ noIconfont: {
920
+ type: Boolean
921
+ },
922
+ /**
923
+ * 复制代码格式化方法
924
+ *
925
+ * @default (text) => text
926
+ */
927
+ formatCopiedText: {
928
+ type: Function,
929
+ default: (e) => e
930
+ },
931
+ /**
932
+ * 某些预览主题的代码模块背景是暗色系
933
+ * 将这个属性设置为true,会自动在该主题下的light模式下使用暗色系的代码风格
934
+ *
935
+ * @default true
936
+ */
937
+ codeStyleReverse: {
938
+ type: Boolean,
939
+ default: !0
940
+ },
941
+ /**
942
+ * 需要自动调整的预览主题
943
+ *
944
+ * @default ['default', 'mk-cute']
945
+ */
946
+ codeStyleReverseList: {
947
+ type: Array,
948
+ default: ["default", "mk-cute"]
949
+ },
950
+ noHighlight: {
951
+ type: Boolean,
952
+ default: !1
953
+ },
954
+ /**
955
+ * 是否关闭编辑器默认的放大缩小功能
956
+ */
957
+ noImgZoomIn: {
958
+ type: Boolean,
959
+ default: !1
960
+ },
961
+ /**
962
+ * 自定义的图标
963
+ */
964
+ customIcon: {
965
+ type: Object,
966
+ default: {}
967
+ }
968
+ }, Pt = {
969
+ ...ie,
970
+ /**
971
+ * input回调事件
972
+ */
973
+ onChange: {
974
+ type: Function
975
+ },
976
+ /**
977
+ * input回调事件
978
+ */
979
+ onSave: {
980
+ type: Function
981
+ },
982
+ /**
983
+ * 上传图片事件
984
+ */
985
+ onUploadImg: {
986
+ type: Function
987
+ },
988
+ /**
989
+ * 是否页面内全屏
990
+ *
991
+ * @default false
992
+ */
993
+ pageFullscreen: {
994
+ type: Boolean,
995
+ default: !1
996
+ },
997
+ /**
998
+ * 是否展开预览
999
+ *
1000
+ * @default true
1001
+ */
1002
+ preview: {
1003
+ type: Boolean,
1004
+ default: !0
1005
+ },
1006
+ /**
1007
+ * 是否展开html预览
1008
+ *
1009
+ * @default false
1010
+ */
1011
+ htmlPreview: {
1012
+ type: Boolean,
1013
+ default: !1
1014
+ },
1015
+ /**
1016
+ * 仅预览模式,不显示toolbar和编辑框
1017
+ *
1018
+ * @4.0.0开始移除该设置,使用组件MdPreview替换
1019
+ *
1020
+ * @default false
1021
+ */
1022
+ // previewOnly: {
1023
+ // type: Boolean as PropType<boolean>,
1024
+ // default: false
1025
+ // },
1026
+ /**
1027
+ * 工具栏选择显示
1028
+ *
1029
+ * @default allToolbar
1030
+ */
1031
+ toolbars: {
1032
+ type: Array,
1033
+ default: ye
1034
+ },
1035
+ /**
1036
+ * 工具栏选择不显示
1037
+ *
1038
+ * @default []
1039
+ */
1040
+ toolbarsExclude: {
1041
+ type: Array,
1042
+ default: []
1043
+ },
1044
+ /**
1045
+ * 格式化md
1046
+ *
1047
+ * @default true
1048
+ */
1049
+ noPrettier: {
1050
+ type: Boolean,
1051
+ default: !1
1052
+ },
1053
+ /**
1054
+ * 一个tab等于空格数
1055
+ *
1056
+ * @default 2
1057
+ */
1058
+ tabWidth: {
1059
+ type: Number,
1060
+ default: 2
1061
+ },
1062
+ /**
1063
+ * 表格预设格子数
1064
+ *
1065
+ * @default [6, 4]
1066
+ */
1067
+ tableShape: {
1068
+ type: Array,
1069
+ default: () => [6, 4]
1070
+ },
1071
+ /**
1072
+ * 空提示
1073
+ *
1074
+ * @default ''
1075
+ */
1076
+ placeholder: {
1077
+ type: String,
1078
+ default: ""
1079
+ },
1080
+ /**
1081
+ * 自定义的工具栏列表
1082
+ */
1083
+ defToolbars: {
1084
+ type: [String, Object]
1085
+ },
1086
+ /**
1087
+ * 内部错误捕获
1088
+ */
1089
+ onError: {
1090
+ type: Function
1091
+ },
1092
+ /**
1093
+ * 页脚列表显示顺序
1094
+ */
1095
+ footers: {
1096
+ type: Array,
1097
+ default: ve
1098
+ },
1099
+ /**
1100
+ * 是否默认激活输入框和预览框同步滚动
1101
+ *
1102
+ * @default true
1103
+ */
1104
+ scrollAuto: {
1105
+ type: Boolean,
1106
+ default: !0
1107
+ },
1108
+ /**
1109
+ * 自定义的也叫工具组件列表
1110
+ */
1111
+ defFooters: {
1112
+ type: [String, Object]
1113
+ },
1114
+ /**
1115
+ * 是否禁用上传图片
1116
+ *
1117
+ * @default false
1118
+ */
1119
+ noUploadImg: {
1120
+ type: Boolean
1121
+ },
1122
+ /**
1123
+ * 文本区域自动获得焦点
1124
+ *
1125
+ * @default false
1126
+ */
1127
+ autoFocus: {
1128
+ type: Boolean
1129
+ },
1130
+ /**
1131
+ * 禁用文本区域
1132
+ *
1133
+ * @default false
1134
+ */
1135
+ disabled: {
1136
+ type: Boolean
1137
+ },
1138
+ /**
1139
+ * 文本区域为只读
1140
+ *
1141
+ * @default false
1142
+ */
1143
+ readOnly: {
1144
+ type: Boolean
1145
+ },
1146
+ /**
1147
+ * 文本区域允许的最大字符数
1148
+ */
1149
+ maxLength: {
1150
+ type: Number
1151
+ },
1152
+ /**
1153
+ * 是否启用自动识别粘贴代码类别
1154
+ * 目前支持 vscode 复制的代码识别
1155
+ *
1156
+ * @default false
1157
+ */
1158
+ autoDetectCode: {
1159
+ type: Boolean
1160
+ },
1161
+ /**
1162
+ * 输入框失去焦点时触发事件
1163
+ */
1164
+ onBlur: {
1165
+ type: Function
1166
+ },
1167
+ /**
1168
+ * 输入框获得焦点时触发事件
1169
+ */
1170
+ onFocus: {
1171
+ type: Function
1172
+ },
1173
+ /**
1174
+ * @codemirror/autocomplete匹配关键词的方法列表
1175
+ *
1176
+ * 它会被像下面这样嵌入编辑器
1177
+ *
1178
+ * import { autocompletion } from '@codemirror/autocomplete';
1179
+ * autocompletion({
1180
+ * override: [...completions]
1181
+ * })
1182
+ */
1183
+ completions: {
1184
+ type: Array
1185
+ },
1186
+ /**
1187
+ * 是否在工具栏下面显示对应的文字名称
1188
+ *
1189
+ * @default false
1190
+ */
1191
+ showToolbarName: {
1192
+ type: Boolean,
1193
+ default: !1
1194
+ },
1195
+ /**
1196
+ * 字符输入事件
1197
+ */
1198
+ onInput: {
1199
+ type: Function
1200
+ },
1201
+ onDrop: {
1202
+ type: Function
33
1203
  }
34
- }
35
- const C = new h(), E = "onSave", g = "changeCatalogVisible", A = "changeFullscreen", R = "pageFullscreenChanged", _ = "fullscreenChanged", d = "previewChanged", L = "htmlPreviewChanged", N = "catalogVisibleChanged", f = "textareaFocus", S = "buildFinished", b = "errorCatcher", G = "replace", H = "uploadImage", T = "openModals", F = "ctrlZ", m = "ctrlShiftZ", I = "catalogChanged", D = "pushCatalog", O = (o, s = "image.png") => {
36
- const t = o.split(","), n = t[0].match(/:(.*?);/);
37
- if (n) {
38
- const l = n[1], a = atob(t[1]);
39
- let e = a.length;
40
- const c = new Uint8Array(e);
41
- for (; e--; )
42
- c[e] = a.charCodeAt(e);
43
- return new File([c], s, { type: l });
1204
+ }, ce = ["onHtmlChanged", "onGetCatalog"], Tt = [
1205
+ ...ce,
1206
+ "onChange",
1207
+ "onSave",
1208
+ "onUploadImg",
1209
+ "onError",
1210
+ "update:modelValue",
1211
+ "onBlur",
1212
+ "onFocus",
1213
+ "onInput",
1214
+ "onDrop"
1215
+ ], it = /* @__PURE__ */ Q({
1216
+ name: "MdPreview",
1217
+ props: ie,
1218
+ emits: ce,
1219
+ setup(e, a) {
1220
+ const {
1221
+ editorId: l,
1222
+ noKatex: t,
1223
+ noMermaid: n,
1224
+ noHighlight: r
1225
+ } = e;
1226
+ return ae(e), le(e), de(() => {
1227
+ g.clear(l);
1228
+ }), () => A("div", {
1229
+ id: l,
1230
+ class: [p, e.class, e.theme === "dark" && `${p}-dark`, `${p}-previewOnly`],
1231
+ style: e.style
1232
+ }, [A(at, {
1233
+ modelValue: e.modelValue,
1234
+ onHtmlChanged: (i) => {
1235
+ e.onHtmlChanged ? e.onHtmlChanged(i) : a.emit("onHtmlChanged", i);
1236
+ },
1237
+ onGetCatalog: (i) => {
1238
+ e.onGetCatalog ? e.onGetCatalog(i) : a.emit("onGetCatalog", i);
1239
+ },
1240
+ mdHeadingId: e.mdHeadingId,
1241
+ noMermaid: n,
1242
+ sanitize: e.sanitize,
1243
+ noKatex: t,
1244
+ formatCopiedText: e.formatCopiedText,
1245
+ noHighlight: r,
1246
+ noImgZoomIn: e.noImgZoomIn,
1247
+ previewOnly: !0
1248
+ }, null)]);
44
1249
  }
45
- return null;
46
- }, w = (o) => {
47
- if (!o)
48
- return o;
49
- const s = o.split(`
50
- `), t = ['<span rn-wrapper aria-hidden="true">'];
51
- return s.forEach(() => {
52
- t.push("<span></span>");
53
- }), t.push("</span>"), `<span class="code-block">${o}</span>${t.join("")}`;
54
- }, P = (o, s) => {
55
- if (!o || !s)
56
- return 0;
57
- const t = o == null ? void 0 : o.getBoundingClientRect();
58
- if (s === document.documentElement)
59
- return t.top - s.clientTop;
60
- const n = s == null ? void 0 : s.getBoundingClientRect();
61
- return t.top - n.top;
62
- }, U = () => `${Date.now().toString(36)}${Math.random().toString(36).substring(2)}`;
1250
+ }), x = it;
1251
+ x.install = (e) => (e.component(x.name, x), e);
63
1252
  export {
64
- S as B,
65
- A as C,
66
- b as E,
67
- _ as F,
68
- L as H,
69
- T as O,
70
- D as P,
71
- G as R,
72
- f as T,
73
- H as U,
74
- O as a,
75
- C as b,
76
- g as c,
77
- E as d,
78
- m as e,
79
- F as f,
80
- w as g,
81
- I as h,
82
- R as i,
83
- d as j,
84
- N as k,
85
- P as l,
86
- U as u
1253
+ at as C,
1254
+ x as M,
1255
+ Tt as a,
1256
+ kt as b,
1257
+ bt as c,
1258
+ $t as d,
1259
+ Pt as e,
1260
+ Ct as f,
1261
+ It as g,
1262
+ St as h,
1263
+ Et as i,
1264
+ wt as u
87
1265
  };