md-editor-v3 4.7.0 → 4.8.0-beta.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/README.md +17 -1
- package/lib/cjs/MdCatalog.cjs +1 -1
- package/lib/cjs/MdEditor.cjs +27 -27
- package/lib/cjs/MdModal.cjs +1 -1
- package/lib/cjs/MdPreview.cjs +1 -1
- package/lib/cjs/ModalToolbar.cjs +1 -1
- package/lib/cjs/chunks/config.cjs +1 -1
- package/lib/cjs/chunks/index.cjs +8 -1
- package/lib/cjs/chunks/index3.cjs +1 -2
- package/lib/cjs/chunks/index4.cjs +2 -8
- package/lib/cjs/config.cjs +1 -1
- package/lib/cjs/index.cjs +1 -1
- package/lib/es/DropdownToolbar.mjs +2 -2
- package/lib/es/MdCatalog.mjs +1 -1
- package/lib/es/MdEditor.mjs +717 -674
- package/lib/es/MdModal.mjs +1 -1
- package/lib/es/MdPreview.mjs +2 -2
- package/lib/es/ModalToolbar.mjs +1 -1
- package/lib/es/chunks/config.mjs +19 -19
- package/lib/es/chunks/index.mjs +1248 -138
- package/lib/es/chunks/index2.mjs +2 -2
- package/lib/es/chunks/index3.mjs +163 -79
- package/lib/es/chunks/index4.mjs +77 -1258
- package/lib/es/config.mjs +10 -2
- package/lib/es/index.mjs +24 -17
- package/lib/style.css +1 -1
- package/lib/types/MdEditor/Editor.d.ts +9 -0
- package/lib/types/MdEditor/config.d.ts +2 -2
- package/lib/types/MdEditor/index.d.ts +15 -0
- package/lib/types/MdEditor/layouts/Content/composition/index.d.ts +2 -1
- package/lib/types/MdEditor/layouts/Content/composition/useResize.d.ts +12 -0
- package/lib/types/MdEditor/layouts/Content/index.d.ts +6 -0
- package/lib/types/MdEditor/layouts/Content/props.d.ts +3 -0
- package/lib/types/MdEditor/props.d.ts +10 -0
- package/lib/types/config.d.ts +3 -1
- package/lib/types/index.d.ts +1 -1
- package/lib/umd/index.js +31 -31
- package/package.json +1 -1
package/lib/es/chunks/index.mjs
CHANGED
|
@@ -1,171 +1,1281 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { p as l,
|
|
3
|
-
import { g as
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { inject as P, onMounted as S, watch as $, toRef as X, nextTick as B, shallowRef as R, ref as L, 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 { e as C, p, m as me, k as O, f as U, h as fe, s as j, a as pe, i as he, g as G, j as D, l as ge, b as ye, d 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 W, f as Z, R as ne, h as Ie, T as Se } from "./index4.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
|
+
}, Be = (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
|
+
B(r);
|
|
52
|
+
}, c = (u) => {
|
|
53
|
+
u && B(r);
|
|
54
|
+
};
|
|
55
|
+
$(() => a.value, i), $(() => e.setting.preview, c), $(() => e.setting.htmlPreview, c), $(() => t.value, r), S(r);
|
|
56
|
+
}, Le = Be, 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);
|
|
10
67
|
}
|
|
11
|
-
},
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
+
B(() => {
|
|
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;
|
|
21
177
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
+
}, We = (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
|
+
}, Ze = We, 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"]
|
|
27
258
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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() : "";
|
|
39
276
|
}
|
|
40
|
-
|
|
41
|
-
|
|
277
|
+
function i(s) {
|
|
278
|
+
const o = r(s), [d = null, b = ""] = (n.exec(o) || []).slice(1);
|
|
279
|
+
return [d, b];
|
|
280
|
+
}
|
|
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 = L([]), 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: Ze,
|
|
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 = L(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: {
|
|
42
398
|
type: String,
|
|
43
399
|
default: ""
|
|
44
400
|
},
|
|
45
|
-
|
|
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: {
|
|
46
420
|
type: Boolean,
|
|
47
421
|
default: !1
|
|
48
422
|
},
|
|
49
|
-
|
|
50
|
-
type:
|
|
51
|
-
default:
|
|
423
|
+
sanitize: {
|
|
424
|
+
type: Function,
|
|
425
|
+
default: (e) => e
|
|
52
426
|
},
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
427
|
+
// 不使用该函数功能
|
|
428
|
+
noKatex: {
|
|
429
|
+
type: Boolean,
|
|
430
|
+
default: !1
|
|
56
431
|
},
|
|
57
|
-
|
|
58
|
-
type: Function
|
|
432
|
+
formatCopiedText: {
|
|
433
|
+
type: Function,
|
|
434
|
+
default: (e) => e
|
|
59
435
|
},
|
|
60
|
-
|
|
436
|
+
noHighlight: {
|
|
61
437
|
type: Boolean,
|
|
62
438
|
default: !1
|
|
63
439
|
},
|
|
64
|
-
|
|
440
|
+
previewOnly: {
|
|
65
441
|
type: Boolean,
|
|
66
442
|
default: !1
|
|
67
443
|
},
|
|
68
|
-
|
|
444
|
+
noImgZoomIn: {
|
|
445
|
+
type: Boolean
|
|
446
|
+
}
|
|
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: {
|
|
69
488
|
type: Function,
|
|
70
489
|
default: () => {
|
|
71
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
|
+
}
|
|
512
|
+
},
|
|
513
|
+
inputBoxWitdh: {
|
|
514
|
+
type: String
|
|
72
515
|
}
|
|
73
|
-
},
|
|
74
|
-
name: "
|
|
75
|
-
props:
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
516
|
+
}, at = /* @__PURE__ */ Q({
|
|
517
|
+
name: "ContentPreview",
|
|
518
|
+
props: re,
|
|
519
|
+
setup(e) {
|
|
520
|
+
const a = P("editorId"), l = P("previewTheme"), t = P("showCodeRowNumber"), {
|
|
521
|
+
html: n
|
|
522
|
+
} = rt(e, e.previewOnly);
|
|
523
|
+
return Le(e, n), Re(e, n), () => A(ue, null, [A("div", {
|
|
524
|
+
id: `${a}-preview-wrapper`,
|
|
525
|
+
class: `${p}-preview-wrapper`,
|
|
526
|
+
"data-show": e.setting.preview,
|
|
527
|
+
key: "content-preview-wrapper"
|
|
528
|
+
}, [A("article", {
|
|
529
|
+
id: `${a}-preview`,
|
|
530
|
+
class: [`${p}-preview`, `${l == null ? void 0 : l.value}-theme`, t && `${p}-scrn`],
|
|
531
|
+
innerHTML: n.value
|
|
532
|
+
}, null)]), !e.previewOnly && A("div", {
|
|
533
|
+
id: `${a}-html-wrapper`,
|
|
534
|
+
class: `${p}-preview-wrapper`,
|
|
535
|
+
"data-show": e.setting.htmlPreview,
|
|
536
|
+
key: "html-preview-wrapper"
|
|
537
|
+
}, [A("div", {
|
|
538
|
+
class: `${p}-html`
|
|
539
|
+
}, [n.value])])]);
|
|
540
|
+
}
|
|
541
|
+
}), wt = (e, a) => {
|
|
542
|
+
const { editorId: l } = e, t = Y({
|
|
543
|
+
// 是否已编译成html
|
|
544
|
+
buildFinished: !1,
|
|
545
|
+
// 存储当前最新的html
|
|
546
|
+
html: ""
|
|
547
|
+
});
|
|
548
|
+
$(
|
|
549
|
+
() => e.modelValue,
|
|
550
|
+
() => {
|
|
551
|
+
t.buildFinished = !1;
|
|
552
|
+
}
|
|
553
|
+
), S(() => {
|
|
554
|
+
g.on(l, {
|
|
555
|
+
name: M,
|
|
556
|
+
callback(n) {
|
|
557
|
+
t.buildFinished = !0, t.html = n;
|
|
558
|
+
}
|
|
559
|
+
}), g.on(l, {
|
|
560
|
+
name: ee,
|
|
561
|
+
callback() {
|
|
562
|
+
const n = new Promise((r) => {
|
|
563
|
+
if (t.buildFinished)
|
|
564
|
+
r(t.html);
|
|
565
|
+
else {
|
|
566
|
+
const i = (c) => {
|
|
567
|
+
r(c), g.remove(l, M, i);
|
|
568
|
+
};
|
|
569
|
+
g.on(l, {
|
|
570
|
+
name: M,
|
|
571
|
+
callback: i
|
|
572
|
+
});
|
|
573
|
+
}
|
|
574
|
+
});
|
|
575
|
+
e.onSave ? e.onSave(e.modelValue, n) : a.emit("onSave", e.modelValue, n);
|
|
576
|
+
}
|
|
577
|
+
});
|
|
578
|
+
});
|
|
579
|
+
}, ae = (e) => {
|
|
580
|
+
var n, r;
|
|
581
|
+
const { editorId: a } = e, l = (r = (n = C) == null ? void 0 : n.editorExtensions) == null ? void 0 : r.highlight;
|
|
582
|
+
H("editorId", a), H(
|
|
583
|
+
"theme",
|
|
584
|
+
F(() => e.theme)
|
|
585
|
+
), H(
|
|
586
|
+
"language",
|
|
587
|
+
F(() => e.language)
|
|
588
|
+
), H(
|
|
589
|
+
"highlight",
|
|
590
|
+
F(() => {
|
|
591
|
+
const i = {
|
|
592
|
+
...U,
|
|
593
|
+
...l == null ? void 0 : l.css
|
|
594
|
+
}, c = e.codeStyleReverse && e.codeStyleReverseList.includes(e.previewTheme) ? "dark" : e.theme;
|
|
595
|
+
return {
|
|
596
|
+
js: (l == null ? void 0 : l.js) || fe,
|
|
597
|
+
css: i[e.codeTheme] ? i[e.codeTheme][c] : U.atom[c]
|
|
598
|
+
};
|
|
599
|
+
})
|
|
600
|
+
), H("showCodeRowNumber", e.showCodeRowNumber);
|
|
601
|
+
const t = F(() => {
|
|
602
|
+
var c, u;
|
|
603
|
+
const i = {
|
|
604
|
+
...j,
|
|
605
|
+
...(u = (c = C) == null ? void 0 : c.editorConfig) == null ? void 0 : u.languageUserDefined
|
|
80
606
|
};
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
607
|
+
return i[e.language] ? i[e.language] : j["zh-CN"];
|
|
608
|
+
});
|
|
609
|
+
H("usedLanguageText", t), H(
|
|
610
|
+
"previewTheme",
|
|
611
|
+
F(() => e.previewTheme)
|
|
612
|
+
), H(
|
|
613
|
+
"customIcon",
|
|
614
|
+
F(() => e.customIcon)
|
|
615
|
+
);
|
|
616
|
+
}, kt = (e) => {
|
|
617
|
+
ae(e), H("tabWidth", e.tabWidth);
|
|
618
|
+
}, le = (e) => {
|
|
619
|
+
S(() => {
|
|
620
|
+
var a, l;
|
|
621
|
+
if (!e.noIconfont)
|
|
622
|
+
if (C.iconfontType === "svg") {
|
|
623
|
+
const t = document.createElement("script");
|
|
624
|
+
t.src = ((a = C.editorExtensions) == null ? void 0 : a.iconfont) || pe, t.id = `${p}-icon`, _(t);
|
|
625
|
+
} else {
|
|
626
|
+
const t = document.createElement("link");
|
|
627
|
+
t.rel = "stylesheet", t.href = ((l = C.editorExtensions) == null ? void 0 : l.iconfontClass) || he, t.id = `${p}-icon-class`, _(t);
|
|
628
|
+
}
|
|
629
|
+
});
|
|
630
|
+
}, $t = (e) => {
|
|
631
|
+
var c, u, s, o, d, b;
|
|
632
|
+
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);
|
|
633
|
+
S(() => {
|
|
634
|
+
var k, y, w, I;
|
|
635
|
+
const v = document.createElement("script"), m = document.createElement("script");
|
|
636
|
+
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`;
|
|
637
|
+
const h = document.createElement("link");
|
|
638
|
+
h.rel = "stylesheet", h.href = ((w = t == null ? void 0 : t.cropper) == null ? void 0 : w.css) || D.css, h.id = `${p}-cropperCss`;
|
|
639
|
+
const f = document.createElement("script");
|
|
640
|
+
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);
|
|
641
|
+
}), le(e);
|
|
642
|
+
}, Ct = (e, a) => {
|
|
643
|
+
const { editorId: l } = e;
|
|
644
|
+
S(() => {
|
|
645
|
+
g.on(l, {
|
|
646
|
+
name: $e,
|
|
647
|
+
callback: (t) => {
|
|
648
|
+
e.onError instanceof Function ? e.onError(t) : a.emit("onError", t);
|
|
89
649
|
}
|
|
90
|
-
}), P = j(() => e.isFullscreen ? {
|
|
91
|
-
width: "100%",
|
|
92
|
-
height: "100%"
|
|
93
|
-
} : {
|
|
94
|
-
width: e.width,
|
|
95
|
-
height: e.height
|
|
96
650
|
});
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
651
|
+
});
|
|
652
|
+
}, It = (e, a) => {
|
|
653
|
+
const { editorId: l } = e, t = Y({
|
|
654
|
+
pageFullscreen: e.pageFullscreen,
|
|
655
|
+
fullscreen: !1,
|
|
656
|
+
preview: e.preview,
|
|
657
|
+
htmlPreview: e.preview ? !1 : e.htmlPreview
|
|
658
|
+
}), n = (c, u) => {
|
|
659
|
+
t[c] = u === void 0 ? !t[c] : u, c === "preview" && t.preview ? t.htmlPreview = !1 : c === "htmlPreview" && t.htmlPreview && (t.preview = !1);
|
|
660
|
+
};
|
|
661
|
+
let r = "";
|
|
662
|
+
const i = () => {
|
|
663
|
+
t.pageFullscreen || t.fullscreen ? document.body.style.overflow = "hidden" : document.body.style.overflow = r;
|
|
664
|
+
};
|
|
665
|
+
return $(() => [t.pageFullscreen, t.fullscreen], i), S(() => {
|
|
666
|
+
g.on(l, {
|
|
667
|
+
name: Ce,
|
|
668
|
+
callback(c, u) {
|
|
669
|
+
const s = (o) => {
|
|
670
|
+
g.emit(l, ne, "image", {
|
|
671
|
+
desc: "",
|
|
672
|
+
urls: o
|
|
673
|
+
}), u && u();
|
|
674
|
+
};
|
|
675
|
+
e.onUploadImg ? e.onUploadImg(c, s) : a.emit("onUploadImg", c, s);
|
|
676
|
+
}
|
|
677
|
+
}), r = document.body.style.overflow, i();
|
|
678
|
+
}), [t, n];
|
|
679
|
+
}, St = (e) => {
|
|
680
|
+
const { editorId: a } = e, l = L(!1);
|
|
681
|
+
return S(() => {
|
|
682
|
+
g.on(a, {
|
|
683
|
+
name: te,
|
|
684
|
+
callback: (n) => {
|
|
685
|
+
n === void 0 ? l.value = !l.value : l.value = n;
|
|
686
|
+
}
|
|
687
|
+
});
|
|
688
|
+
}), F(() => !e.toolbarsExclude.includes("catalog") && e.toolbars.includes("catalog") && l.value);
|
|
689
|
+
}, Et = (e, a, l, t, n) => {
|
|
690
|
+
const { editorId: r } = e;
|
|
691
|
+
$(
|
|
692
|
+
() => t.pageFullscreen,
|
|
693
|
+
(c) => {
|
|
694
|
+
g.emit(r, z, c);
|
|
695
|
+
}
|
|
696
|
+
), $(
|
|
697
|
+
() => t.fullscreen,
|
|
698
|
+
(c) => {
|
|
699
|
+
g.emit(r, K, c);
|
|
700
|
+
}
|
|
701
|
+
), $(
|
|
702
|
+
() => t.preview,
|
|
703
|
+
(c) => {
|
|
704
|
+
g.emit(r, q, c);
|
|
705
|
+
}
|
|
706
|
+
), $(
|
|
707
|
+
() => t.htmlPreview,
|
|
708
|
+
(c) => {
|
|
709
|
+
g.emit(r, W, c);
|
|
710
|
+
}
|
|
711
|
+
), $(l, (c) => {
|
|
712
|
+
g.emit(r, Z, c);
|
|
713
|
+
});
|
|
714
|
+
const i = {
|
|
715
|
+
on(c, u) {
|
|
716
|
+
switch (c) {
|
|
717
|
+
case "pageFullscreen": {
|
|
718
|
+
g.on(r, {
|
|
719
|
+
name: z,
|
|
720
|
+
callback(s) {
|
|
721
|
+
u(s);
|
|
722
|
+
}
|
|
723
|
+
});
|
|
724
|
+
break;
|
|
126
725
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
726
|
+
case "fullscreen": {
|
|
727
|
+
g.on(r, {
|
|
728
|
+
name: K,
|
|
729
|
+
callback(s) {
|
|
730
|
+
u(s);
|
|
731
|
+
}
|
|
732
|
+
});
|
|
733
|
+
break;
|
|
131
734
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
class: `${l}-modal-header`,
|
|
141
|
-
ref: r
|
|
142
|
-
}, [n || ""]), t("div", {
|
|
143
|
-
class: `${l}-modal-body`
|
|
144
|
-
}, [s]), t("div", {
|
|
145
|
-
class: `${l}-modal-func`
|
|
146
|
-
}, [e.showAdjust && t("div", {
|
|
147
|
-
class: `${l}-modal-adjust`,
|
|
148
|
-
onClick: (u) => {
|
|
149
|
-
u.stopPropagation(), e.isFullscreen ? o.initPos = o.historyPos : (o.historyPos = o.initPos, o.initPos = {
|
|
150
|
-
left: "0",
|
|
151
|
-
top: "0"
|
|
152
|
-
}), e.onAdjust(!e.isFullscreen);
|
|
735
|
+
case "preview": {
|
|
736
|
+
g.on(r, {
|
|
737
|
+
name: q,
|
|
738
|
+
callback(s) {
|
|
739
|
+
u(s);
|
|
740
|
+
}
|
|
741
|
+
});
|
|
742
|
+
break;
|
|
153
743
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
744
|
+
case "htmlPreview": {
|
|
745
|
+
g.on(r, {
|
|
746
|
+
name: W,
|
|
747
|
+
callback(s) {
|
|
748
|
+
u(s);
|
|
749
|
+
}
|
|
750
|
+
});
|
|
751
|
+
break;
|
|
160
752
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
753
|
+
case "catalog": {
|
|
754
|
+
g.on(r, {
|
|
755
|
+
name: Z,
|
|
756
|
+
callback(s) {
|
|
757
|
+
u(s);
|
|
758
|
+
}
|
|
759
|
+
});
|
|
760
|
+
break;
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
},
|
|
764
|
+
togglePageFullscreen(c) {
|
|
765
|
+
n("pageFullscreen", c);
|
|
766
|
+
},
|
|
767
|
+
toggleFullscreen(c) {
|
|
768
|
+
g.emit(r, Ie, c);
|
|
769
|
+
},
|
|
770
|
+
togglePreview(c) {
|
|
771
|
+
n("preview", c);
|
|
772
|
+
},
|
|
773
|
+
toggleHtmlPreview(c) {
|
|
774
|
+
n("htmlPreview", c);
|
|
775
|
+
},
|
|
776
|
+
toggleCatalog(c) {
|
|
777
|
+
g.emit(r, te, c);
|
|
778
|
+
},
|
|
779
|
+
triggerSave() {
|
|
780
|
+
g.emit(r, ee);
|
|
781
|
+
},
|
|
782
|
+
insert(c) {
|
|
783
|
+
g.emit(r, ne, "universal", { generate: c });
|
|
784
|
+
},
|
|
785
|
+
focus(c) {
|
|
786
|
+
g.emit(r, Se, c);
|
|
787
|
+
}
|
|
788
|
+
};
|
|
789
|
+
a.expose(i);
|
|
790
|
+
}, lt = (e) => e, ie = {
|
|
791
|
+
/**
|
|
792
|
+
* markdown content.
|
|
793
|
+
*
|
|
794
|
+
* @default ''
|
|
795
|
+
*/
|
|
796
|
+
modelValue: {
|
|
797
|
+
type: String,
|
|
798
|
+
default: ""
|
|
799
|
+
},
|
|
800
|
+
/**
|
|
801
|
+
* 主题,支持light和dark
|
|
802
|
+
*
|
|
803
|
+
* @default 'light'
|
|
804
|
+
*/
|
|
805
|
+
theme: {
|
|
806
|
+
type: String,
|
|
807
|
+
default: "light"
|
|
808
|
+
},
|
|
809
|
+
/**
|
|
810
|
+
* 外层类名
|
|
811
|
+
*
|
|
812
|
+
* @default ''
|
|
813
|
+
*/
|
|
814
|
+
class: {
|
|
815
|
+
type: String,
|
|
816
|
+
default: ""
|
|
817
|
+
},
|
|
818
|
+
/**
|
|
819
|
+
* 预设语言名称
|
|
820
|
+
*
|
|
821
|
+
* @default 'zh-CN'
|
|
822
|
+
*/
|
|
823
|
+
language: {
|
|
824
|
+
type: String,
|
|
825
|
+
default: "zh-CN"
|
|
826
|
+
},
|
|
827
|
+
/**
|
|
828
|
+
* html变化事件
|
|
829
|
+
*/
|
|
830
|
+
onHtmlChanged: {
|
|
831
|
+
type: Function
|
|
832
|
+
},
|
|
833
|
+
/**
|
|
834
|
+
* 获取目录结构
|
|
835
|
+
*/
|
|
836
|
+
onGetCatalog: {
|
|
837
|
+
type: Function
|
|
838
|
+
},
|
|
839
|
+
/**
|
|
840
|
+
* 编辑器唯一标识
|
|
841
|
+
*
|
|
842
|
+
* @default 'md-editor-v3'
|
|
843
|
+
*/
|
|
844
|
+
editorId: {
|
|
845
|
+
type: String,
|
|
846
|
+
default: ge
|
|
847
|
+
},
|
|
848
|
+
/**
|
|
849
|
+
* 预览中代码是否显示行号
|
|
850
|
+
*
|
|
851
|
+
* @default false
|
|
852
|
+
*/
|
|
853
|
+
showCodeRowNumber: {
|
|
854
|
+
type: Boolean,
|
|
855
|
+
default: !1
|
|
856
|
+
},
|
|
857
|
+
/**
|
|
858
|
+
* 预览内容样式
|
|
859
|
+
*
|
|
860
|
+
* @default 'default'
|
|
861
|
+
*/
|
|
862
|
+
previewTheme: {
|
|
863
|
+
type: String,
|
|
864
|
+
default: "default"
|
|
865
|
+
},
|
|
866
|
+
/**
|
|
867
|
+
* 编辑器样式
|
|
868
|
+
*/
|
|
869
|
+
style: {
|
|
870
|
+
type: Object,
|
|
871
|
+
default: () => ({})
|
|
872
|
+
},
|
|
873
|
+
/**
|
|
874
|
+
* 标题的id生成方式
|
|
875
|
+
*
|
|
876
|
+
* @default (text: string) => text
|
|
877
|
+
*/
|
|
878
|
+
mdHeadingId: {
|
|
879
|
+
type: Function,
|
|
880
|
+
default: lt
|
|
881
|
+
},
|
|
882
|
+
/**
|
|
883
|
+
*
|
|
884
|
+
* 不能保证文本正确的情况,在marked编译md文本后通过该方法处理
|
|
885
|
+
* 推荐DOMPurify、sanitize-html
|
|
886
|
+
*
|
|
887
|
+
* @default (text: string) => text
|
|
888
|
+
*/
|
|
889
|
+
sanitize: {
|
|
890
|
+
type: Function,
|
|
891
|
+
default: (e) => e
|
|
892
|
+
},
|
|
893
|
+
/**
|
|
894
|
+
* 不使用该mermaid
|
|
895
|
+
*
|
|
896
|
+
* @default false
|
|
897
|
+
*/
|
|
898
|
+
noMermaid: {
|
|
899
|
+
type: Boolean,
|
|
900
|
+
default: !1
|
|
901
|
+
},
|
|
902
|
+
/**
|
|
903
|
+
* 不使用katex
|
|
904
|
+
*
|
|
905
|
+
* @default false
|
|
906
|
+
*/
|
|
907
|
+
noKatex: {
|
|
908
|
+
type: Boolean,
|
|
909
|
+
default: !1
|
|
910
|
+
},
|
|
911
|
+
/**
|
|
912
|
+
* 代码主题
|
|
913
|
+
*
|
|
914
|
+
* @default 'atom'
|
|
915
|
+
*/
|
|
916
|
+
codeTheme: {
|
|
917
|
+
type: String,
|
|
918
|
+
default: "atom"
|
|
919
|
+
},
|
|
920
|
+
/**
|
|
921
|
+
* 不插入iconfont链接
|
|
922
|
+
*
|
|
923
|
+
* @default false
|
|
924
|
+
*/
|
|
925
|
+
noIconfont: {
|
|
926
|
+
type: Boolean
|
|
927
|
+
},
|
|
928
|
+
/**
|
|
929
|
+
* 复制代码格式化方法
|
|
930
|
+
*
|
|
931
|
+
* @default (text) => text
|
|
932
|
+
*/
|
|
933
|
+
formatCopiedText: {
|
|
934
|
+
type: Function,
|
|
935
|
+
default: (e) => e
|
|
936
|
+
},
|
|
937
|
+
/**
|
|
938
|
+
* 某些预览主题的代码模块背景是暗色系
|
|
939
|
+
* 将这个属性设置为true,会自动在该主题下的light模式下使用暗色系的代码风格
|
|
940
|
+
*
|
|
941
|
+
* @default true
|
|
942
|
+
*/
|
|
943
|
+
codeStyleReverse: {
|
|
944
|
+
type: Boolean,
|
|
945
|
+
default: !0
|
|
946
|
+
},
|
|
947
|
+
/**
|
|
948
|
+
* 需要自动调整的预览主题
|
|
949
|
+
*
|
|
950
|
+
* @default ['default', 'mk-cute']
|
|
951
|
+
*/
|
|
952
|
+
codeStyleReverseList: {
|
|
953
|
+
type: Array,
|
|
954
|
+
default: ["default", "mk-cute"]
|
|
955
|
+
},
|
|
956
|
+
noHighlight: {
|
|
957
|
+
type: Boolean,
|
|
958
|
+
default: !1
|
|
959
|
+
},
|
|
960
|
+
/**
|
|
961
|
+
* 是否关闭编辑器默认的放大缩小功能
|
|
962
|
+
*/
|
|
963
|
+
noImgZoomIn: {
|
|
964
|
+
type: Boolean,
|
|
965
|
+
default: !1
|
|
966
|
+
},
|
|
967
|
+
/**
|
|
968
|
+
* 自定义的图标
|
|
969
|
+
*/
|
|
970
|
+
customIcon: {
|
|
971
|
+
type: Object,
|
|
972
|
+
default: {}
|
|
973
|
+
}
|
|
974
|
+
}, Pt = {
|
|
975
|
+
...ie,
|
|
976
|
+
/**
|
|
977
|
+
* input回调事件
|
|
978
|
+
*/
|
|
979
|
+
onChange: {
|
|
980
|
+
type: Function
|
|
981
|
+
},
|
|
982
|
+
/**
|
|
983
|
+
* input回调事件
|
|
984
|
+
*/
|
|
985
|
+
onSave: {
|
|
986
|
+
type: Function
|
|
987
|
+
},
|
|
988
|
+
/**
|
|
989
|
+
* 上传图片事件
|
|
990
|
+
*/
|
|
991
|
+
onUploadImg: {
|
|
992
|
+
type: Function
|
|
993
|
+
},
|
|
994
|
+
/**
|
|
995
|
+
* 是否页面内全屏
|
|
996
|
+
*
|
|
997
|
+
* @default false
|
|
998
|
+
*/
|
|
999
|
+
pageFullscreen: {
|
|
1000
|
+
type: Boolean,
|
|
1001
|
+
default: !1
|
|
1002
|
+
},
|
|
1003
|
+
/**
|
|
1004
|
+
* 是否展开预览
|
|
1005
|
+
*
|
|
1006
|
+
* @default true
|
|
1007
|
+
*/
|
|
1008
|
+
preview: {
|
|
1009
|
+
type: Boolean,
|
|
1010
|
+
default: !0
|
|
1011
|
+
},
|
|
1012
|
+
/**
|
|
1013
|
+
* 是否展开html预览
|
|
1014
|
+
*
|
|
1015
|
+
* @default false
|
|
1016
|
+
*/
|
|
1017
|
+
htmlPreview: {
|
|
1018
|
+
type: Boolean,
|
|
1019
|
+
default: !1
|
|
1020
|
+
},
|
|
1021
|
+
/**
|
|
1022
|
+
* 仅预览模式,不显示toolbar和编辑框
|
|
1023
|
+
*
|
|
1024
|
+
* @4.0.0开始移除该设置,使用组件MdPreview替换
|
|
1025
|
+
*
|
|
1026
|
+
* @default false
|
|
1027
|
+
*/
|
|
1028
|
+
// previewOnly: {
|
|
1029
|
+
// type: Boolean as PropType<boolean>,
|
|
1030
|
+
// default: false
|
|
1031
|
+
// },
|
|
1032
|
+
/**
|
|
1033
|
+
* 工具栏选择显示
|
|
1034
|
+
*
|
|
1035
|
+
* @default allToolbar
|
|
1036
|
+
*/
|
|
1037
|
+
toolbars: {
|
|
1038
|
+
type: Array,
|
|
1039
|
+
default: ye
|
|
1040
|
+
},
|
|
1041
|
+
/**
|
|
1042
|
+
* 工具栏选择不显示
|
|
1043
|
+
*
|
|
1044
|
+
* @default []
|
|
1045
|
+
*/
|
|
1046
|
+
toolbarsExclude: {
|
|
1047
|
+
type: Array,
|
|
1048
|
+
default: []
|
|
1049
|
+
},
|
|
1050
|
+
/**
|
|
1051
|
+
* 格式化md
|
|
1052
|
+
*
|
|
1053
|
+
* @default true
|
|
1054
|
+
*/
|
|
1055
|
+
noPrettier: {
|
|
1056
|
+
type: Boolean,
|
|
1057
|
+
default: !1
|
|
1058
|
+
},
|
|
1059
|
+
/**
|
|
1060
|
+
* 一个tab等于空格数
|
|
1061
|
+
*
|
|
1062
|
+
* @default 2
|
|
1063
|
+
*/
|
|
1064
|
+
tabWidth: {
|
|
1065
|
+
type: Number,
|
|
1066
|
+
default: 2
|
|
1067
|
+
},
|
|
1068
|
+
/**
|
|
1069
|
+
* 表格预设格子数
|
|
1070
|
+
*
|
|
1071
|
+
* @default [6, 4]
|
|
1072
|
+
*/
|
|
1073
|
+
tableShape: {
|
|
1074
|
+
type: Array,
|
|
1075
|
+
default: () => [6, 4]
|
|
1076
|
+
},
|
|
1077
|
+
/**
|
|
1078
|
+
* 空提示
|
|
1079
|
+
*
|
|
1080
|
+
* @default ''
|
|
1081
|
+
*/
|
|
1082
|
+
placeholder: {
|
|
1083
|
+
type: String,
|
|
1084
|
+
default: ""
|
|
1085
|
+
},
|
|
1086
|
+
/**
|
|
1087
|
+
* 自定义的工具栏列表
|
|
1088
|
+
*/
|
|
1089
|
+
defToolbars: {
|
|
1090
|
+
type: [String, Object]
|
|
1091
|
+
},
|
|
1092
|
+
/**
|
|
1093
|
+
* 内部错误捕获
|
|
1094
|
+
*/
|
|
1095
|
+
onError: {
|
|
1096
|
+
type: Function
|
|
1097
|
+
},
|
|
1098
|
+
/**
|
|
1099
|
+
* 页脚列表显示顺序
|
|
1100
|
+
*/
|
|
1101
|
+
footers: {
|
|
1102
|
+
type: Array,
|
|
1103
|
+
default: ve
|
|
1104
|
+
},
|
|
1105
|
+
/**
|
|
1106
|
+
* 是否默认激活输入框和预览框同步滚动
|
|
1107
|
+
*
|
|
1108
|
+
* @default true
|
|
1109
|
+
*/
|
|
1110
|
+
scrollAuto: {
|
|
1111
|
+
type: Boolean,
|
|
1112
|
+
default: !0
|
|
1113
|
+
},
|
|
1114
|
+
/**
|
|
1115
|
+
* 自定义的也叫工具组件列表
|
|
1116
|
+
*/
|
|
1117
|
+
defFooters: {
|
|
1118
|
+
type: [String, Object]
|
|
1119
|
+
},
|
|
1120
|
+
/**
|
|
1121
|
+
* 是否禁用上传图片
|
|
1122
|
+
*
|
|
1123
|
+
* @default false
|
|
1124
|
+
*/
|
|
1125
|
+
noUploadImg: {
|
|
1126
|
+
type: Boolean
|
|
1127
|
+
},
|
|
1128
|
+
/**
|
|
1129
|
+
* 文本区域自动获得焦点
|
|
1130
|
+
*
|
|
1131
|
+
* @default false
|
|
1132
|
+
*/
|
|
1133
|
+
autoFocus: {
|
|
1134
|
+
type: Boolean
|
|
1135
|
+
},
|
|
1136
|
+
/**
|
|
1137
|
+
* 禁用文本区域
|
|
1138
|
+
*
|
|
1139
|
+
* @default false
|
|
1140
|
+
*/
|
|
1141
|
+
disabled: {
|
|
1142
|
+
type: Boolean
|
|
1143
|
+
},
|
|
1144
|
+
/**
|
|
1145
|
+
* 文本区域为只读
|
|
1146
|
+
*
|
|
1147
|
+
* @default false
|
|
1148
|
+
*/
|
|
1149
|
+
readOnly: {
|
|
1150
|
+
type: Boolean
|
|
1151
|
+
},
|
|
1152
|
+
/**
|
|
1153
|
+
* 文本区域允许的最大字符数
|
|
1154
|
+
*/
|
|
1155
|
+
maxLength: {
|
|
1156
|
+
type: Number
|
|
1157
|
+
},
|
|
1158
|
+
/**
|
|
1159
|
+
* 是否启用自动识别粘贴代码类别
|
|
1160
|
+
* 目前支持 vscode 复制的代码识别
|
|
1161
|
+
*
|
|
1162
|
+
* @default false
|
|
1163
|
+
*/
|
|
1164
|
+
autoDetectCode: {
|
|
1165
|
+
type: Boolean
|
|
1166
|
+
},
|
|
1167
|
+
/**
|
|
1168
|
+
* 输入框失去焦点时触发事件
|
|
1169
|
+
*/
|
|
1170
|
+
onBlur: {
|
|
1171
|
+
type: Function
|
|
1172
|
+
},
|
|
1173
|
+
/**
|
|
1174
|
+
* 输入框获得焦点时触发事件
|
|
1175
|
+
*/
|
|
1176
|
+
onFocus: {
|
|
1177
|
+
type: Function
|
|
1178
|
+
},
|
|
1179
|
+
/**
|
|
1180
|
+
* @codemirror/autocomplete匹配关键词的方法列表
|
|
1181
|
+
*
|
|
1182
|
+
* 它会被像下面这样嵌入编辑器
|
|
1183
|
+
*
|
|
1184
|
+
* import { autocompletion } from '@codemirror/autocomplete';
|
|
1185
|
+
* autocompletion({
|
|
1186
|
+
* override: [...completions]
|
|
1187
|
+
* })
|
|
1188
|
+
*/
|
|
1189
|
+
completions: {
|
|
1190
|
+
type: Array
|
|
1191
|
+
},
|
|
1192
|
+
/**
|
|
1193
|
+
* 是否在工具栏下面显示对应的文字名称
|
|
1194
|
+
*
|
|
1195
|
+
* @default false
|
|
1196
|
+
*/
|
|
1197
|
+
showToolbarName: {
|
|
1198
|
+
type: Boolean,
|
|
1199
|
+
default: !1
|
|
1200
|
+
},
|
|
1201
|
+
/**
|
|
1202
|
+
* 字符输入事件
|
|
1203
|
+
*/
|
|
1204
|
+
onInput: {
|
|
1205
|
+
type: Function
|
|
1206
|
+
},
|
|
1207
|
+
onDrop: {
|
|
1208
|
+
type: Function
|
|
1209
|
+
},
|
|
1210
|
+
/**
|
|
1211
|
+
* 输入框的默认宽度
|
|
1212
|
+
*
|
|
1213
|
+
* @example '100px'/'50%'
|
|
1214
|
+
* @default '50%
|
|
1215
|
+
*/
|
|
1216
|
+
inputBoxWitdh: {
|
|
1217
|
+
type: String,
|
|
1218
|
+
default: "50%"
|
|
1219
|
+
}
|
|
1220
|
+
}, ce = ["onHtmlChanged", "onGetCatalog"], Tt = [
|
|
1221
|
+
...ce,
|
|
1222
|
+
"onChange",
|
|
1223
|
+
"onSave",
|
|
1224
|
+
"onUploadImg",
|
|
1225
|
+
"onError",
|
|
1226
|
+
"update:modelValue",
|
|
1227
|
+
"onBlur",
|
|
1228
|
+
"onFocus",
|
|
1229
|
+
"onInput",
|
|
1230
|
+
"onDrop"
|
|
1231
|
+
], it = /* @__PURE__ */ Q({
|
|
1232
|
+
name: "MdPreview",
|
|
1233
|
+
props: ie,
|
|
1234
|
+
emits: ce,
|
|
1235
|
+
setup(e, a) {
|
|
1236
|
+
const {
|
|
1237
|
+
editorId: l,
|
|
1238
|
+
noKatex: t,
|
|
1239
|
+
noMermaid: n,
|
|
1240
|
+
noHighlight: r
|
|
1241
|
+
} = e;
|
|
1242
|
+
return ae(e), le(e), de(() => {
|
|
1243
|
+
g.clear(l);
|
|
1244
|
+
}), () => A("div", {
|
|
1245
|
+
id: l,
|
|
1246
|
+
class: [p, e.class, e.theme === "dark" && `${p}-dark`, `${p}-previewOnly`],
|
|
1247
|
+
style: e.style
|
|
1248
|
+
}, [A(at, {
|
|
1249
|
+
modelValue: e.modelValue,
|
|
1250
|
+
onHtmlChanged: (i) => {
|
|
1251
|
+
e.onHtmlChanged ? e.onHtmlChanged(i) : a.emit("onHtmlChanged", i);
|
|
1252
|
+
},
|
|
1253
|
+
onGetCatalog: (i) => {
|
|
1254
|
+
e.onGetCatalog ? e.onGetCatalog(i) : a.emit("onGetCatalog", i);
|
|
1255
|
+
},
|
|
1256
|
+
mdHeadingId: e.mdHeadingId,
|
|
1257
|
+
noMermaid: n,
|
|
1258
|
+
sanitize: e.sanitize,
|
|
1259
|
+
noKatex: t,
|
|
1260
|
+
formatCopiedText: e.formatCopiedText,
|
|
1261
|
+
noHighlight: r,
|
|
1262
|
+
noImgZoomIn: e.noImgZoomIn,
|
|
1263
|
+
previewOnly: !0
|
|
1264
|
+
}, null)]);
|
|
165
1265
|
}
|
|
166
|
-
});
|
|
167
|
-
|
|
1266
|
+
}), x = it;
|
|
1267
|
+
x.install = (e) => (e.component(x.name, x), e);
|
|
168
1268
|
export {
|
|
169
|
-
|
|
170
|
-
|
|
1269
|
+
at as C,
|
|
1270
|
+
x as M,
|
|
1271
|
+
Tt as a,
|
|
1272
|
+
kt as b,
|
|
1273
|
+
bt as c,
|
|
1274
|
+
$t as d,
|
|
1275
|
+
Pt as e,
|
|
1276
|
+
Ct as f,
|
|
1277
|
+
It as g,
|
|
1278
|
+
St as h,
|
|
1279
|
+
Et as i,
|
|
1280
|
+
wt as u
|
|
171
1281
|
};
|