md-editor-v3 4.11.1 → 4.11.3
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 +1 -1
- package/lib/cjs/MdEditor.cjs +1 -1
- package/lib/cjs/MdPreview.cjs +1 -1
- package/lib/cjs/chunks/config.cjs +1 -1
- package/lib/cjs/chunks/index.cjs +6 -6
- package/lib/cjs/index.cjs +1 -1
- package/lib/es/MdEditor.mjs +1 -0
- package/lib/es/MdPreview.mjs +3 -2
- package/lib/es/chunks/config.mjs +1 -1
- package/lib/es/chunks/index.mjs +159 -144
- package/lib/es/index.mjs +24 -23
- package/lib/preview.css +1 -1
- package/lib/style.css +1 -1
- package/lib/umd/index.js +65 -64
- package/package.json +3 -2
package/lib/es/chunks/index.mjs
CHANGED
|
@@ -1,27 +1,28 @@
|
|
|
1
|
-
import { inject as _, onMounted as P, watch as
|
|
1
|
+
import { inject as _, onMounted as P, watch as I, nextTick as j, shallowRef as B, ref as R, computed as H, toRef as fe, defineComponent as te, createVNode as M, Fragment as pe, reactive as ne, provide as x, onBeforeUnmount as he } from "vue";
|
|
2
2
|
import { e as S, p as h, m as ge, k as D, f as V, h as ye, s as z, a as ve, i as be, g as W, j as K, l as we, b as ke, d as $e } from "./config.mjs";
|
|
3
|
-
import { a as Ce, b as y, P as Ie, C as q, R as G, B as A, O as
|
|
3
|
+
import { a as Ce, b as y, P as Ie, C as q, R as G, B as A, O as oe, E as Se, U as Ee, c as re, d as Z, F as J, e as X, H as Q, f as Y, h as ae, i as Pe } from "./index4.mjs";
|
|
4
4
|
import { a as T, u as _e } from "./dom.mjs";
|
|
5
5
|
import Te from "medium-zoom";
|
|
6
|
-
import { debounce as
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
6
|
+
import { debounce as le, uuid as U } from "@vavt/util";
|
|
7
|
+
import xe from "copy-to-clipboard";
|
|
8
|
+
import He from "markdown-it";
|
|
9
|
+
import Fe from "markdown-it-image-figures";
|
|
10
10
|
import Me from "markdown-it-task-lists";
|
|
11
|
-
import Re from "
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
import Re from "markdown-it-xss";
|
|
12
|
+
import Ae from "lru-cache";
|
|
13
|
+
const Be = (e, a) => {
|
|
14
|
+
const l = _("editorId"), { noImgZoomIn: t } = e, n = le(() => {
|
|
14
15
|
const i = document.querySelectorAll(`#${l}-preview img`);
|
|
15
16
|
i.length !== 0 && Te(i, {
|
|
16
17
|
background: "#00000073"
|
|
17
18
|
});
|
|
18
19
|
});
|
|
19
20
|
P(() => {
|
|
20
|
-
!t && n();
|
|
21
|
-
}),
|
|
21
|
+
!t && e.setting.preview && n();
|
|
22
|
+
}), I([a], () => {
|
|
22
23
|
!t && n();
|
|
23
24
|
});
|
|
24
|
-
},
|
|
25
|
+
}, Le = Be, Ne = (e, a) => {
|
|
25
26
|
if (typeof a[e] == "string")
|
|
26
27
|
return a[e];
|
|
27
28
|
const l = `<i class="${h}-iconfont ${h}-icon-${e}"></i>`;
|
|
@@ -31,29 +32,29 @@ const Ae = (e, a) => {
|
|
|
31
32
|
default:
|
|
32
33
|
return l;
|
|
33
34
|
}
|
|
34
|
-
},
|
|
35
|
+
}, Oe = (e, a, l) => {
|
|
35
36
|
const t = _("editorId"), n = _("usedLanguageText"), i = _("customIcon"), r = () => {
|
|
36
37
|
document.querySelectorAll(`#${t}-preview pre`).forEach((s) => {
|
|
37
38
|
var v, m;
|
|
38
39
|
let o = -1;
|
|
39
40
|
(v = s.querySelector(".copy-button")) == null || v.remove();
|
|
40
41
|
const d = ((m = n.value.copyCode) == null ? void 0 : m.text) || "复制代码", b = document.createElement("span");
|
|
41
|
-
b.setAttribute("class", "copy-button"), b.dataset.tips = d, b.innerHTML =
|
|
42
|
+
b.setAttribute("class", "copy-button"), b.dataset.tips = d, b.innerHTML = Ne("copy", i.value), b.addEventListener("click", () => {
|
|
42
43
|
var w, E;
|
|
43
44
|
clearTimeout(o);
|
|
44
|
-
const p = s.querySelector("code").innerText, f =
|
|
45
|
+
const p = s.querySelector("code").innerText, f = xe(e.formatCopiedText(p)), k = ((w = n.value.copyCode) == null ? void 0 : w.successTips) || "已复制!", g = ((E = n.value.copyCode) == null ? void 0 : E.failTips) || "已复制!";
|
|
45
46
|
b.dataset.tips = f ? k : g, o = window.setTimeout(() => {
|
|
46
47
|
b.dataset.tips = d;
|
|
47
48
|
}, 1500);
|
|
48
49
|
}), s.appendChild(b);
|
|
49
50
|
});
|
|
50
51
|
}, u = () => {
|
|
51
|
-
|
|
52
|
+
j(r);
|
|
52
53
|
}, c = (s) => {
|
|
53
|
-
s &&
|
|
54
|
+
s && j(r);
|
|
54
55
|
};
|
|
55
|
-
|
|
56
|
-
},
|
|
56
|
+
I([a, l], u), I(() => e.setting.preview, c), I(() => e.setting.htmlPreview, c), I(() => n.value, r), P(r);
|
|
57
|
+
}, je = Oe, Ue = (e) => {
|
|
57
58
|
var i;
|
|
58
59
|
const a = (i = S.editorExtensions) == null ? void 0 : i.highlight, l = a == null ? void 0 : a.instance, t = _("highlight"), n = B(l);
|
|
59
60
|
return P(() => {
|
|
@@ -65,14 +66,14 @@ const Ae = (e, a) => {
|
|
|
65
66
|
const u = document.createElement("link");
|
|
66
67
|
u.rel = "stylesheet", u.href = t.value.css, u.id = `${h}-hlCss`, T(u);
|
|
67
68
|
}
|
|
68
|
-
}),
|
|
69
|
+
}), I(
|
|
69
70
|
() => t.value.css,
|
|
70
71
|
(r) => {
|
|
71
72
|
_e(`${h}-hlCss`, "href", r);
|
|
72
73
|
}
|
|
73
74
|
), n;
|
|
74
|
-
},
|
|
75
|
-
const a = _("theme"), { editorExtensions: l, mermaidConfig: t } = S, n = l == null ? void 0 : l.mermaid, i = B(n == null ? void 0 : n.instance), r = B(-1), u = new
|
|
75
|
+
}, Ge = Ue, De = (e) => {
|
|
76
|
+
const a = _("theme"), { editorExtensions: l, mermaidConfig: t } = S, n = l == null ? void 0 : l.mermaid, i = B(n == null ? void 0 : n.instance), r = B(-1), u = new Ae({
|
|
76
77
|
max: 1e3,
|
|
77
78
|
// 缓存10分钟
|
|
78
79
|
ttl: 6e5
|
|
@@ -85,7 +86,7 @@ const Ae = (e, a) => {
|
|
|
85
86
|
})
|
|
86
87
|
), r.value = r.value + 1);
|
|
87
88
|
};
|
|
88
|
-
return
|
|
89
|
+
return I(
|
|
89
90
|
() => a.value,
|
|
90
91
|
() => {
|
|
91
92
|
u.clear(), c();
|
|
@@ -109,7 +110,7 @@ const Ae = (e, a) => {
|
|
|
109
110
|
}
|
|
110
111
|
}
|
|
111
112
|
}), { mermaidRef: i, reRenderRef: r, replaceMermaid: () => {
|
|
112
|
-
|
|
113
|
+
j(() => {
|
|
113
114
|
if (!e.noMermaid && i.value) {
|
|
114
115
|
const o = document.querySelectorAll(
|
|
115
116
|
`div.${h}-mermaid`
|
|
@@ -119,7 +120,7 @@ const Ae = (e, a) => {
|
|
|
119
120
|
b > 0 && document.body.appendChild(d), o.forEach(async (v) => {
|
|
120
121
|
let m = u.get(v.innerText);
|
|
121
122
|
if (!m) {
|
|
122
|
-
const f =
|
|
123
|
+
const f = U(), k = i.value.renderAsync || i.value.render;
|
|
123
124
|
let g = "";
|
|
124
125
|
try {
|
|
125
126
|
g = await k(f, v.innerText, d);
|
|
@@ -135,7 +136,7 @@ const Ae = (e, a) => {
|
|
|
135
136
|
}
|
|
136
137
|
});
|
|
137
138
|
} };
|
|
138
|
-
},
|
|
139
|
+
}, Ve = De, ze = (e) => {
|
|
139
140
|
var n;
|
|
140
141
|
const a = (n = S.editorExtensions) == null ? void 0 : n.katex, l = a == null ? void 0 : a.instance, t = B(l);
|
|
141
142
|
return P(() => {
|
|
@@ -148,7 +149,7 @@ const Ae = (e, a) => {
|
|
|
148
149
|
r.rel = "stylesheet", r.href = (a == null ? void 0 : a.css) || D.css, r.id = `${h}-katexCss`, T(i, "katex"), T(r);
|
|
149
150
|
}
|
|
150
151
|
}), t;
|
|
151
|
-
},
|
|
152
|
+
}, We = ze, Ke = (e, a) => {
|
|
152
153
|
const l = e.renderer.rules.fence.bind(e.renderer.rules);
|
|
153
154
|
e.renderer.rules.fence = (t, n, i, r, u) => {
|
|
154
155
|
const c = t[n], s = c.content.trim();
|
|
@@ -158,14 +159,14 @@ const Ae = (e, a) => {
|
|
|
158
159
|
}
|
|
159
160
|
return l(t, n, i, r, u);
|
|
160
161
|
};
|
|
161
|
-
},
|
|
162
|
+
}, qe = Ke, ee = (e, a) => {
|
|
162
163
|
let l = !0, t = !0;
|
|
163
164
|
const n = e.posMax, i = a > 0 ? e.src.charCodeAt(a - 1) : -1, r = a + 1 <= n ? e.src.charCodeAt(a + 1) : -1;
|
|
164
165
|
return (i === 32 || i === 9 || r >= 48 && r <= 57) && (t = !1), (r === 32 || r === 9) && (l = !1), {
|
|
165
166
|
can_open: l,
|
|
166
167
|
can_close: t
|
|
167
168
|
};
|
|
168
|
-
},
|
|
169
|
+
}, Ze = (e, a) => {
|
|
169
170
|
let l, t, n, i;
|
|
170
171
|
if (e.src[e.pos] !== "$")
|
|
171
172
|
return !1;
|
|
@@ -180,7 +181,7 @@ const Ae = (e, a) => {
|
|
|
180
181
|
l += 1;
|
|
181
182
|
}
|
|
182
183
|
return l === -1 ? (a || (e.pending += "$"), e.pos = r, !0) : l - r === 0 ? (a || (e.pending += "$$"), e.pos = r + 1, !0) : (n = ee(e, l), n.can_close ? (a || (t = e.push("math_inline", "math", 0), t.markup = "$", t.content = e.src.slice(r, l)), e.pos = l + 1, !0) : (a || (e.pending += "$"), e.pos = r, !0));
|
|
183
|
-
},
|
|
184
|
+
}, Je = (e, a, l, t) => {
|
|
184
185
|
let n, i, r, u, c = !1, s = e.bMarks[a] + e.tShift[a], o = e.eMarks[a];
|
|
185
186
|
if (s + 2 > o || e.src.slice(s, s + 2) !== "$$")
|
|
186
187
|
return !1;
|
|
@@ -192,7 +193,7 @@ const Ae = (e, a) => {
|
|
|
192
193
|
const d = e.push("math_block", "math", 0);
|
|
193
194
|
return d.block = !0, d.content = (n && n.trim() ? n + `
|
|
194
195
|
` : "") + e.getLines(a + 1, r, e.tShift[a], !0) + (i && i.trim() ? i : ""), d.map = [a, e.line], d.markup = "$$", !0;
|
|
195
|
-
},
|
|
196
|
+
}, Xe = (e, a) => {
|
|
196
197
|
const l = (n) => {
|
|
197
198
|
if (a.katexRef.value) {
|
|
198
199
|
const i = a.katexRef.value.renderToString(n, {
|
|
@@ -211,11 +212,11 @@ const Ae = (e, a) => {
|
|
|
211
212
|
} else
|
|
212
213
|
return `<p class="${h}-katex-block" data-line=${i}>${n}</p>`;
|
|
213
214
|
};
|
|
214
|
-
e.inline.ruler.after("escape", "math_inline",
|
|
215
|
+
e.inline.ruler.after("escape", "math_inline", Ze), e.block.ruler.after("blockquote", "math_block", Je, {
|
|
215
216
|
alt: ["paragraph", "reference", "blockquote", "list"]
|
|
216
217
|
}), e.renderer.rules.math_inline = (n, i) => l(n[i].content), e.renderer.rules.math_block = (n, i) => t(n[i].content, n[i].map[0]) + `
|
|
217
218
|
`;
|
|
218
|
-
}, Qe =
|
|
219
|
+
}, Qe = Xe, Ye = (e, a) => {
|
|
219
220
|
a = a || {};
|
|
220
221
|
const l = 3, t = a.marker || "!", n = t.charCodeAt(0), i = t.length;
|
|
221
222
|
let r = "", u = "";
|
|
@@ -242,8 +243,8 @@ const Ae = (e, a) => {
|
|
|
242
243
|
if (E !== l)
|
|
243
244
|
return !1;
|
|
244
245
|
m -= (m - g) % i;
|
|
245
|
-
const
|
|
246
|
-
if (s(
|
|
246
|
+
const $ = o.src.slice(g, m), C = o.src.slice(m, w);
|
|
247
|
+
if (s(C), v)
|
|
247
248
|
return !0;
|
|
248
249
|
for (p = d; p++, !(p >= b || (g = o.bMarks[p] + o.tShift[p], w = o.eMarks[p], g < w && o.sCount[p] < o.blkIndent)); )
|
|
249
250
|
if (n === o.src.charCodeAt(g) && !(o.sCount[p] - o.blkIndent >= 4)) {
|
|
@@ -254,14 +255,14 @@ const Ae = (e, a) => {
|
|
|
254
255
|
break;
|
|
255
256
|
}
|
|
256
257
|
}
|
|
257
|
-
const L = o.parentType,
|
|
258
|
-
return o.parentType = "root", o.lineMax = p, f = o.push("admonition_open", "div", 1), f.markup =
|
|
258
|
+
const L = o.parentType, F = o.lineMax;
|
|
259
|
+
return o.parentType = "root", o.lineMax = p, f = o.push("admonition_open", "div", 1), f.markup = $, f.block = !0, f.info = r, f.map = [d, p], f = o.push("admonition_title_open", "p", 1), f.markup = $ + " " + r, f.map = [d, p], f = o.push("inline", "", 0), f.content = u, f.map = [d, o.line - 1], f.children = [], f = o.push("admonition_title_close", "p", -1), f.markup = $ + " " + r, o.md.block.tokenize(o, d + 1, p), f = o.push("admonition_close", "div", -1), f.markup = o.src.slice(g, m), f.block = !0, o.parentType = L, o.lineMax = F, o.line = p + (k ? 1 : 0), !0;
|
|
259
260
|
},
|
|
260
261
|
{
|
|
261
262
|
alt: ["paragraph", "reference", "blockquote", "list"]
|
|
262
263
|
}
|
|
263
264
|
), e.renderer.rules.admonition_open = c, e.renderer.rules.admonition_title_open = c, e.renderer.rules.admonition_title_close = c, e.renderer.rules.admonition_close = c;
|
|
264
|
-
},
|
|
265
|
+
}, et = Ye, tt = (e, a) => {
|
|
265
266
|
e.renderer.rules.heading_open = (l, t) => {
|
|
266
267
|
var u;
|
|
267
268
|
const n = l[t], i = ((u = l[t + 1].children) == null ? void 0 : u.reduce((c, s) => c + (s.content || ""), "")) || "", r = n.markup.length;
|
|
@@ -273,7 +274,7 @@ const Ae = (e, a) => {
|
|
|
273
274
|
a.mdHeadingId(i, r, a.headsRef.value.length)
|
|
274
275
|
)), e.renderer.renderToken(l, t, a);
|
|
275
276
|
}, e.renderer.rules.heading_close = (l, t, n, i, r) => r.renderToken(l, t, n);
|
|
276
|
-
},
|
|
277
|
+
}, nt = tt, ot = (e, a) => {
|
|
277
278
|
const l = e.renderer.rules.fence, t = e.utils.unescapeAll, n = /\[(\w*)(?::([\w ]*))?\]/;
|
|
278
279
|
function i(s) {
|
|
279
280
|
return s.info ? t(s.info).trim() : "";
|
|
@@ -292,18 +293,18 @@ const Ae = (e, a) => {
|
|
|
292
293
|
const [m, p] = r(s[o]);
|
|
293
294
|
if (m === null)
|
|
294
295
|
return l(s, o, d, b, v);
|
|
295
|
-
let f, k, g, w, E = "",
|
|
296
|
-
for (let
|
|
297
|
-
f.info = f.info.replace(n, ""), f.hidden = !0, w =
|
|
298
|
-
`,
|
|
299
|
-
` + l(s,
|
|
296
|
+
let f, k, g, w, E = "", $ = "";
|
|
297
|
+
for (let C = o; C < s.length && (f = s[C], [k, g] = r(f), k === m); C++)
|
|
298
|
+
f.info = f.info.replace(n, ""), f.hidden = !0, w = C - o > 0 ? "" : " checked", E += `<li><input type="radio" name="label-group-${a.editorId}-${o}"${w}><label for="group-${a.editorId}-${o}-tab-${C - o}" onclick="this.previousElementSibling.click()">${g || u(f)}</label></li>
|
|
299
|
+
`, $ += `<input type="radio" id="group-${a.editorId}-${o}-tab-${C - o}" name="group-${a.editorId}-${o}"${w}>
|
|
300
|
+
` + l(s, C, d, b, v);
|
|
300
301
|
return `<div class="code-tabs">
|
|
301
302
|
<ul>
|
|
302
303
|
` + E + `</ul>
|
|
303
|
-
` +
|
|
304
|
+
` + $ + "</div>";
|
|
304
305
|
};
|
|
305
306
|
e.renderer.rules.fence = c;
|
|
306
|
-
},
|
|
307
|
+
}, rt = ot, at = (e) => {
|
|
307
308
|
[
|
|
308
309
|
"paragraph_open",
|
|
309
310
|
"table_open",
|
|
@@ -324,8 +325,8 @@ const Ae = (e, a) => {
|
|
|
324
325
|
return t[n].map && t[n].level === 0 && (c = t[n].map[0], t[n].attrSet("data-line", String(c))), u.renderToken(t, n, i);
|
|
325
326
|
};
|
|
326
327
|
});
|
|
327
|
-
},
|
|
328
|
-
const { editorConfig: l, markdownItConfig: t, markdownItPlugins: n } = S, i = _("editorId"), r = _("showCodeRowNumber"), u = _("theme"), c = R([]), s =
|
|
328
|
+
}, lt = (e, a) => {
|
|
329
|
+
const { editorConfig: l, markdownItConfig: t, markdownItPlugins: n } = S, i = _("editorId"), r = _("showCodeRowNumber"), u = _("theme"), c = R([]), s = Ge(e), o = We(e), { reRenderRef: d, replaceMermaid: b } = Ve(e), v = He({
|
|
329
330
|
html: !0,
|
|
330
331
|
breaks: !0
|
|
331
332
|
});
|
|
@@ -340,12 +341,12 @@ const Ae = (e, a) => {
|
|
|
340
341
|
},
|
|
341
342
|
{
|
|
342
343
|
type: "image",
|
|
343
|
-
plugin:
|
|
344
|
+
plugin: Fe,
|
|
344
345
|
options: { figcaption: !0, classes: "md-zoom" }
|
|
345
346
|
},
|
|
346
347
|
{
|
|
347
348
|
type: "admonition",
|
|
348
|
-
plugin:
|
|
349
|
+
plugin: et,
|
|
349
350
|
options: {}
|
|
350
351
|
},
|
|
351
352
|
{
|
|
@@ -355,51 +356,65 @@ const Ae = (e, a) => {
|
|
|
355
356
|
},
|
|
356
357
|
{
|
|
357
358
|
type: "heading",
|
|
358
|
-
plugin:
|
|
359
|
+
plugin: nt,
|
|
359
360
|
options: { mdHeadingId: e.mdHeadingId, headsRef: c }
|
|
360
361
|
},
|
|
361
362
|
{
|
|
362
363
|
type: "codeTabs",
|
|
363
|
-
plugin:
|
|
364
|
+
plugin: rt,
|
|
364
365
|
options: { editorId: i }
|
|
366
|
+
},
|
|
367
|
+
{
|
|
368
|
+
type: "xss",
|
|
369
|
+
plugin: Re,
|
|
370
|
+
options: {
|
|
371
|
+
// https://github.com/leizongmin/js-xss/blob/master/README.zh.md
|
|
372
|
+
xss($) {
|
|
373
|
+
return {
|
|
374
|
+
whiteList: Object.assign({}, $.getDefaultWhiteList(), {
|
|
375
|
+
input: ["class", "disabled", "type", "checked"]
|
|
376
|
+
})
|
|
377
|
+
};
|
|
378
|
+
}
|
|
379
|
+
}
|
|
365
380
|
}
|
|
366
381
|
];
|
|
367
382
|
e.noMermaid || m.push({
|
|
368
383
|
type: "mermaid",
|
|
369
|
-
plugin:
|
|
384
|
+
plugin: qe,
|
|
370
385
|
options: { themeRef: u }
|
|
371
386
|
}), n(m, {
|
|
372
387
|
editorId: i
|
|
373
|
-
}).forEach((
|
|
374
|
-
v.use(
|
|
388
|
+
}).forEach(($) => {
|
|
389
|
+
v.use($.plugin, $.options);
|
|
375
390
|
});
|
|
376
391
|
const p = v.options.highlight;
|
|
377
392
|
v.set({
|
|
378
|
-
highlight: (
|
|
393
|
+
highlight: ($, C, L) => {
|
|
379
394
|
if (p) {
|
|
380
|
-
const N = p(
|
|
395
|
+
const N = p($, C, L);
|
|
381
396
|
if (N)
|
|
382
397
|
return N;
|
|
383
398
|
}
|
|
384
|
-
let
|
|
385
|
-
!e.noHighlight && s.value ? s.value.getLanguage(
|
|
386
|
-
language:
|
|
399
|
+
let F;
|
|
400
|
+
!e.noHighlight && s.value ? s.value.getLanguage(C) ? F = s.value.highlight($, {
|
|
401
|
+
language: C,
|
|
387
402
|
ignoreIllegals: !0
|
|
388
|
-
}).value :
|
|
389
|
-
const
|
|
390
|
-
return `<pre><code class="language-${
|
|
403
|
+
}).value : F = s.value.highlightAuto($).value : F = v.utils.escapeHtml($);
|
|
404
|
+
const me = r ? Ce(F.replace(/^\n+|\n+$/g, "")) : `<span class="code-block">${F.replace(/^\n+|\n+$/g, "")}</span>`;
|
|
405
|
+
return `<pre><code class="language-${C}" language=${C}>${me}</code></pre>`;
|
|
391
406
|
}
|
|
392
|
-
}),
|
|
393
|
-
const f = R(`_article-key_${
|
|
407
|
+
}), at(v);
|
|
408
|
+
const f = R(`_article-key_${U()}`), k = R(e.sanitize(v.render(e.modelValue))), g = () => {
|
|
394
409
|
y.emit(i, A, k.value), e.onHtmlChanged(k.value), e.onGetCatalog(c.value), y.emit(i, q, c.value), b();
|
|
395
410
|
};
|
|
396
411
|
P(g);
|
|
397
412
|
const w = () => {
|
|
398
413
|
c.value = [], k.value = e.sanitize(v.render(e.modelValue)), g();
|
|
399
|
-
}, E =
|
|
400
|
-
return
|
|
401
|
-
[
|
|
402
|
-
|
|
414
|
+
}, E = H(() => (e.noKatex || o.value) && (e.noHighlight || s.value));
|
|
415
|
+
return I(
|
|
416
|
+
[fe(e, "modelValue"), E, d],
|
|
417
|
+
le(
|
|
403
418
|
w,
|
|
404
419
|
(l == null ? void 0 : l.renderDelay) !== void 0 ? l == null ? void 0 : l.renderDelay : a ? 0 : 500
|
|
405
420
|
)
|
|
@@ -412,11 +427,11 @@ const Ae = (e, a) => {
|
|
|
412
427
|
}), y.on(i, {
|
|
413
428
|
name: G,
|
|
414
429
|
callback: () => {
|
|
415
|
-
w(), f.value = `_article-key_${
|
|
430
|
+
w(), f.value = `_article-key_${U()}`;
|
|
416
431
|
}
|
|
417
432
|
});
|
|
418
433
|
}), { html: k, key: f };
|
|
419
|
-
},
|
|
434
|
+
}, it = lt, ie = {
|
|
420
435
|
modelValue: {
|
|
421
436
|
type: String,
|
|
422
437
|
default: ""
|
|
@@ -470,8 +485,8 @@ const Ae = (e, a) => {
|
|
|
470
485
|
sanitizeMermaid: {
|
|
471
486
|
type: Function
|
|
472
487
|
}
|
|
473
|
-
},
|
|
474
|
-
...
|
|
488
|
+
}, It = {
|
|
489
|
+
...ie,
|
|
475
490
|
onChange: {
|
|
476
491
|
type: Function,
|
|
477
492
|
default: () => {
|
|
@@ -542,15 +557,15 @@ const Ae = (e, a) => {
|
|
|
542
557
|
onInputBoxWitdhChange: {
|
|
543
558
|
type: Function
|
|
544
559
|
}
|
|
545
|
-
},
|
|
560
|
+
}, ct = /* @__PURE__ */ te({
|
|
546
561
|
name: "ContentPreview",
|
|
547
|
-
props:
|
|
562
|
+
props: ie,
|
|
548
563
|
setup(e) {
|
|
549
564
|
const a = _("editorId"), l = _("previewTheme"), t = _("showCodeRowNumber"), {
|
|
550
565
|
html: n,
|
|
551
566
|
key: i
|
|
552
|
-
} =
|
|
553
|
-
return
|
|
567
|
+
} = it(e, e.previewOnly);
|
|
568
|
+
return je(e, n, i), Le(e, n), () => M(pe, null, [M("div", {
|
|
554
569
|
id: `${a}-preview-wrapper`,
|
|
555
570
|
class: `${h}-preview-wrapper`,
|
|
556
571
|
"data-show": e.setting.preview,
|
|
@@ -569,14 +584,14 @@ const Ae = (e, a) => {
|
|
|
569
584
|
class: `${h}-html`
|
|
570
585
|
}, [n.value])])]);
|
|
571
586
|
}
|
|
572
|
-
}),
|
|
573
|
-
const { editorId: l } = e, t =
|
|
587
|
+
}), St = (e, a) => {
|
|
588
|
+
const { editorId: l } = e, t = ne({
|
|
574
589
|
// 是否已编译成html
|
|
575
590
|
buildFinished: !1,
|
|
576
591
|
// 存储当前最新的html
|
|
577
592
|
html: ""
|
|
578
593
|
});
|
|
579
|
-
|
|
594
|
+
I(
|
|
580
595
|
() => e.modelValue,
|
|
581
596
|
() => {
|
|
582
597
|
t.buildFinished = !1;
|
|
@@ -588,7 +603,7 @@ const Ae = (e, a) => {
|
|
|
588
603
|
t.buildFinished = !0, t.html = n;
|
|
589
604
|
}
|
|
590
605
|
}), y.on(l, {
|
|
591
|
-
name:
|
|
606
|
+
name: oe,
|
|
592
607
|
callback() {
|
|
593
608
|
const n = new Promise((i) => {
|
|
594
609
|
if (t.buildFinished)
|
|
@@ -607,18 +622,18 @@ const Ae = (e, a) => {
|
|
|
607
622
|
}
|
|
608
623
|
});
|
|
609
624
|
});
|
|
610
|
-
},
|
|
625
|
+
}, ce = (e) => {
|
|
611
626
|
var n, i;
|
|
612
627
|
const { editorId: a } = e, l = (i = (n = S) == null ? void 0 : n.editorExtensions) == null ? void 0 : i.highlight;
|
|
613
|
-
|
|
628
|
+
x("editorId", a), x(
|
|
614
629
|
"theme",
|
|
615
|
-
|
|
616
|
-
),
|
|
630
|
+
H(() => e.theme)
|
|
631
|
+
), x(
|
|
617
632
|
"language",
|
|
618
|
-
|
|
619
|
-
),
|
|
633
|
+
H(() => e.language)
|
|
634
|
+
), x(
|
|
620
635
|
"highlight",
|
|
621
|
-
|
|
636
|
+
H(() => {
|
|
622
637
|
const r = {
|
|
623
638
|
...V,
|
|
624
639
|
...l == null ? void 0 : l.css
|
|
@@ -628,8 +643,8 @@ const Ae = (e, a) => {
|
|
|
628
643
|
css: r[e.codeTheme] ? r[e.codeTheme][u] : V.atom[u]
|
|
629
644
|
};
|
|
630
645
|
})
|
|
631
|
-
),
|
|
632
|
-
const t =
|
|
646
|
+
), x("showCodeRowNumber", e.showCodeRowNumber);
|
|
647
|
+
const t = H(() => {
|
|
633
648
|
var u, c;
|
|
634
649
|
const r = {
|
|
635
650
|
...z,
|
|
@@ -637,16 +652,16 @@ const Ae = (e, a) => {
|
|
|
637
652
|
};
|
|
638
653
|
return r[e.language] ? r[e.language] : z["zh-CN"];
|
|
639
654
|
});
|
|
640
|
-
|
|
655
|
+
x("usedLanguageText", t), x(
|
|
641
656
|
"previewTheme",
|
|
642
|
-
|
|
643
|
-
),
|
|
657
|
+
H(() => e.previewTheme)
|
|
658
|
+
), x(
|
|
644
659
|
"customIcon",
|
|
645
|
-
|
|
660
|
+
H(() => e.customIcon)
|
|
646
661
|
);
|
|
647
|
-
},
|
|
648
|
-
|
|
649
|
-
},
|
|
662
|
+
}, Et = (e) => {
|
|
663
|
+
ce(e), x("tabWidth", e.tabWidth);
|
|
664
|
+
}, se = (e) => {
|
|
650
665
|
P(() => {
|
|
651
666
|
var a, l;
|
|
652
667
|
if (!e.noIconfont)
|
|
@@ -658,7 +673,7 @@ const Ae = (e, a) => {
|
|
|
658
673
|
t.rel = "stylesheet", t.href = ((l = S.editorExtensions) == null ? void 0 : l.iconfontClass) || be, t.id = `${h}-icon-class`, T(t);
|
|
659
674
|
}
|
|
660
675
|
});
|
|
661
|
-
},
|
|
676
|
+
}, Pt = (e) => {
|
|
662
677
|
var u, c, s, o, d, b;
|
|
663
678
|
const { noPrettier: a, noUploadImg: l } = e, { editorExtensions: t } = S, n = a || !!((c = (u = S.editorExtensions) == null ? void 0 : u.prettier) != null && c.prettierInstance), i = a || !!((o = (s = S.editorExtensions) == null ? void 0 : s.prettier) != null && o.parserMarkdownInstance), r = l || !!((b = (d = S.editorExtensions) == null ? void 0 : d.cropper) != null && b.instance);
|
|
664
679
|
P(() => {
|
|
@@ -669,8 +684,8 @@ const Ae = (e, a) => {
|
|
|
669
684
|
p.rel = "stylesheet", p.href = ((w = t == null ? void 0 : t.cropper) == null ? void 0 : w.css) || K.css, p.id = `${h}-cropperCss`;
|
|
670
685
|
const f = document.createElement("script");
|
|
671
686
|
f.src = ((E = t == null ? void 0 : t.cropper) == null ? void 0 : E.js) || K.js, f.id = `${h}-cropper`, r || (T(p), T(f)), n || T(v), i || T(m);
|
|
672
|
-
}),
|
|
673
|
-
},
|
|
687
|
+
}), se(e);
|
|
688
|
+
}, _t = (e, a) => {
|
|
674
689
|
const { editorId: l } = e;
|
|
675
690
|
P(() => {
|
|
676
691
|
y.on(l, {
|
|
@@ -680,8 +695,8 @@ const Ae = (e, a) => {
|
|
|
680
695
|
}
|
|
681
696
|
});
|
|
682
697
|
});
|
|
683
|
-
},
|
|
684
|
-
const { editorId: l } = e, t =
|
|
698
|
+
}, Tt = (e, a) => {
|
|
699
|
+
const { editorId: l } = e, t = ne({
|
|
685
700
|
pageFullscreen: e.pageFullscreen,
|
|
686
701
|
fullscreen: !1,
|
|
687
702
|
preview: e.preview,
|
|
@@ -693,12 +708,12 @@ const Ae = (e, a) => {
|
|
|
693
708
|
const r = () => {
|
|
694
709
|
t.pageFullscreen || t.fullscreen ? document.body.style.overflow = "hidden" : document.body.style.overflow = i;
|
|
695
710
|
};
|
|
696
|
-
return
|
|
711
|
+
return I(() => [t.pageFullscreen, t.fullscreen], r), P(() => {
|
|
697
712
|
y.on(l, {
|
|
698
713
|
name: Ee,
|
|
699
714
|
callback(u, c) {
|
|
700
715
|
const s = (o) => {
|
|
701
|
-
y.emit(l,
|
|
716
|
+
y.emit(l, ae, "image", {
|
|
702
717
|
desc: "",
|
|
703
718
|
urls: o
|
|
704
719
|
}), c && c();
|
|
@@ -707,39 +722,39 @@ const Ae = (e, a) => {
|
|
|
707
722
|
}
|
|
708
723
|
}), i = document.body.style.overflow, r();
|
|
709
724
|
}), [t, n];
|
|
710
|
-
},
|
|
725
|
+
}, xt = (e) => {
|
|
711
726
|
const { editorId: a } = e, l = R(!1);
|
|
712
727
|
return P(() => {
|
|
713
728
|
y.on(a, {
|
|
714
|
-
name:
|
|
729
|
+
name: re,
|
|
715
730
|
callback: (n) => {
|
|
716
731
|
n === void 0 ? l.value = !l.value : l.value = n;
|
|
717
732
|
}
|
|
718
733
|
});
|
|
719
|
-
}),
|
|
720
|
-
},
|
|
734
|
+
}), H(() => !e.toolbarsExclude.includes("catalog") && e.toolbars.includes("catalog") && l.value);
|
|
735
|
+
}, Ht = (e, a, l, t, n, i) => {
|
|
721
736
|
const { editorId: r } = e;
|
|
722
|
-
|
|
737
|
+
I(
|
|
723
738
|
() => t.pageFullscreen,
|
|
724
739
|
(c) => {
|
|
725
740
|
y.emit(r, Z, c);
|
|
726
741
|
}
|
|
727
|
-
),
|
|
742
|
+
), I(
|
|
728
743
|
() => t.fullscreen,
|
|
729
744
|
(c) => {
|
|
730
745
|
y.emit(r, J, c);
|
|
731
746
|
}
|
|
732
|
-
),
|
|
747
|
+
), I(
|
|
733
748
|
() => t.preview,
|
|
734
749
|
(c) => {
|
|
735
|
-
y.emit(r,
|
|
750
|
+
y.emit(r, X, c);
|
|
736
751
|
}
|
|
737
|
-
),
|
|
752
|
+
), I(
|
|
738
753
|
() => t.htmlPreview,
|
|
739
754
|
(c) => {
|
|
740
|
-
y.emit(r,
|
|
755
|
+
y.emit(r, Q, c);
|
|
741
756
|
}
|
|
742
|
-
),
|
|
757
|
+
), I(l, (c) => {
|
|
743
758
|
y.emit(r, Y, c);
|
|
744
759
|
});
|
|
745
760
|
const u = {
|
|
@@ -765,7 +780,7 @@ const Ae = (e, a) => {
|
|
|
765
780
|
}
|
|
766
781
|
case "preview": {
|
|
767
782
|
y.on(r, {
|
|
768
|
-
name:
|
|
783
|
+
name: X,
|
|
769
784
|
callback(o) {
|
|
770
785
|
s(o);
|
|
771
786
|
}
|
|
@@ -774,7 +789,7 @@ const Ae = (e, a) => {
|
|
|
774
789
|
}
|
|
775
790
|
case "htmlPreview": {
|
|
776
791
|
y.on(r, {
|
|
777
|
-
name:
|
|
792
|
+
name: Q,
|
|
778
793
|
callback(o) {
|
|
779
794
|
s(o);
|
|
780
795
|
}
|
|
@@ -805,13 +820,13 @@ const Ae = (e, a) => {
|
|
|
805
820
|
n("htmlPreview", c);
|
|
806
821
|
},
|
|
807
822
|
toggleCatalog(c) {
|
|
808
|
-
y.emit(r,
|
|
823
|
+
y.emit(r, re, c);
|
|
809
824
|
},
|
|
810
825
|
triggerSave() {
|
|
811
|
-
y.emit(r,
|
|
826
|
+
y.emit(r, oe);
|
|
812
827
|
},
|
|
813
828
|
insert(c) {
|
|
814
|
-
y.emit(r,
|
|
829
|
+
y.emit(r, ae, "universal", { generate: c });
|
|
815
830
|
},
|
|
816
831
|
focus(c) {
|
|
817
832
|
var s;
|
|
@@ -830,7 +845,7 @@ const Ae = (e, a) => {
|
|
|
830
845
|
}
|
|
831
846
|
};
|
|
832
847
|
a.expose(u);
|
|
833
|
-
},
|
|
848
|
+
}, st = (e) => e, ue = {
|
|
834
849
|
/**
|
|
835
850
|
* markdown content.
|
|
836
851
|
*
|
|
@@ -920,7 +935,7 @@ const Ae = (e, a) => {
|
|
|
920
935
|
*/
|
|
921
936
|
mdHeadingId: {
|
|
922
937
|
type: Function,
|
|
923
|
-
default:
|
|
938
|
+
default: st
|
|
924
939
|
},
|
|
925
940
|
/**
|
|
926
941
|
*
|
|
@@ -1018,8 +1033,8 @@ const Ae = (e, a) => {
|
|
|
1018
1033
|
type: Function,
|
|
1019
1034
|
default: (e) => Promise.resolve(e)
|
|
1020
1035
|
}
|
|
1021
|
-
},
|
|
1022
|
-
...
|
|
1036
|
+
}, Ft = {
|
|
1037
|
+
...ue,
|
|
1023
1038
|
/**
|
|
1024
1039
|
* input回调事件
|
|
1025
1040
|
*/
|
|
@@ -1270,8 +1285,8 @@ const Ae = (e, a) => {
|
|
|
1270
1285
|
onInputBoxWitdhChange: {
|
|
1271
1286
|
type: Function
|
|
1272
1287
|
}
|
|
1273
|
-
},
|
|
1274
|
-
...
|
|
1288
|
+
}, de = ["onHtmlChanged", "onGetCatalog"], Mt = [
|
|
1289
|
+
...de,
|
|
1275
1290
|
"onChange",
|
|
1276
1291
|
"onSave",
|
|
1277
1292
|
"onUploadImg",
|
|
@@ -1282,17 +1297,17 @@ const Ae = (e, a) => {
|
|
|
1282
1297
|
"onInput",
|
|
1283
1298
|
"onDrop",
|
|
1284
1299
|
"onInputBoxWitdhChange"
|
|
1285
|
-
],
|
|
1300
|
+
], ut = (e, a) => {
|
|
1286
1301
|
const { editorId: l } = e, t = {
|
|
1287
1302
|
rerender() {
|
|
1288
1303
|
y.emit(l, G);
|
|
1289
1304
|
}
|
|
1290
1305
|
};
|
|
1291
1306
|
a.expose(t);
|
|
1292
|
-
},
|
|
1307
|
+
}, dt = /* @__PURE__ */ te({
|
|
1293
1308
|
name: "MdPreview",
|
|
1294
|
-
props:
|
|
1295
|
-
emits:
|
|
1309
|
+
props: ue,
|
|
1310
|
+
emits: de,
|
|
1296
1311
|
setup(e, a) {
|
|
1297
1312
|
const {
|
|
1298
1313
|
editorId: l,
|
|
@@ -1300,13 +1315,13 @@ const Ae = (e, a) => {
|
|
|
1300
1315
|
noMermaid: n,
|
|
1301
1316
|
noHighlight: i
|
|
1302
1317
|
} = e;
|
|
1303
|
-
return
|
|
1318
|
+
return ce(e), se(e), ut(e, a), he(() => {
|
|
1304
1319
|
y.clear(l);
|
|
1305
1320
|
}), () => M("div", {
|
|
1306
1321
|
id: l,
|
|
1307
1322
|
class: [h, e.class, e.theme === "dark" && `${h}-dark`, `${h}-previewOnly`],
|
|
1308
1323
|
style: e.style
|
|
1309
|
-
}, [M(
|
|
1324
|
+
}, [M(ct, {
|
|
1310
1325
|
modelValue: e.modelValue,
|
|
1311
1326
|
onHtmlChanged: (r) => {
|
|
1312
1327
|
e.onHtmlChanged ? e.onHtmlChanged(r) : a.emit("onHtmlChanged", r);
|
|
@@ -1325,19 +1340,19 @@ const Ae = (e, a) => {
|
|
|
1325
1340
|
sanitizeMermaid: e.sanitizeMermaid
|
|
1326
1341
|
}, null)]);
|
|
1327
1342
|
}
|
|
1328
|
-
}), O =
|
|
1343
|
+
}), O = dt;
|
|
1329
1344
|
O.install = (e) => (e.component(O.name, O), e);
|
|
1330
1345
|
export {
|
|
1331
|
-
|
|
1346
|
+
ct as C,
|
|
1332
1347
|
O as M,
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1348
|
+
Mt as a,
|
|
1349
|
+
Et as b,
|
|
1350
|
+
It as c,
|
|
1351
|
+
Pt as d,
|
|
1352
|
+
Ft as e,
|
|
1353
|
+
_t as f,
|
|
1354
|
+
Tt as g,
|
|
1355
|
+
xt as h,
|
|
1356
|
+
Ht as i,
|
|
1357
|
+
St as u
|
|
1343
1358
|
};
|