md-editor-v3 4.11.3 → 4.12.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 +11 -1
- package/lib/cjs/DropdownToolbar.cjs +1 -1
- package/lib/cjs/MdCatalog.cjs +1 -1
- package/lib/cjs/MdEditor.cjs +7 -7
- 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 +7 -7
- package/lib/cjs/chunks/index4.cjs +2 -2
- package/lib/cjs/index.cjs +1 -1
- package/lib/es/DropdownToolbar.mjs +2 -5
- package/lib/es/MdCatalog.mjs +18 -18
- package/lib/es/MdEditor.mjs +173 -173
- package/lib/es/MdModal.mjs +2 -7
- package/lib/es/MdPreview.mjs +2 -14
- package/lib/es/ModalToolbar.mjs +8 -10
- package/lib/es/chunks/config.mjs +22 -23
- package/lib/es/chunks/index.mjs +153 -137
- package/lib/es/chunks/index4.mjs +22 -18
- package/lib/es/index.mjs +23 -44
- package/lib/preview.css +1 -1
- package/lib/style.css +1 -1
- package/lib/types/DropdownToolbar/index.d.ts +8 -8
- package/lib/types/MdCatalog/CatalogLink.d.ts +1 -1
- package/lib/types/MdCatalog/MdCatalog.d.ts +1 -1
- package/lib/types/MdCatalog/index.d.ts +5 -5
- package/lib/types/MdEditor/Editor.d.ts +15 -15
- package/lib/types/MdEditor/components/Dropdown/index.d.ts +1 -1
- package/lib/types/MdEditor/components/Modal/Modal.d.ts +2 -2
- package/lib/types/MdEditor/components/Modal/index.d.ts +8 -8
- package/lib/types/MdEditor/components/Popper/index.d.ts +15 -0
- package/lib/types/MdEditor/config.d.ts +3 -3
- package/lib/types/MdEditor/index.d.ts +68 -68
- package/lib/types/MdEditor/layouts/Content/ContentPreview.d.ts +8 -4
- package/lib/types/MdEditor/layouts/Content/composition/useAttach.d.ts +9 -0
- package/lib/types/MdEditor/layouts/Content/index.d.ts +12 -8
- package/lib/types/MdEditor/layouts/Content/props.d.ts +6 -2
- package/lib/types/MdEditor/layouts/Modals/Link.d.ts +1 -1
- package/lib/types/MdEditor/layouts/Toolbar/index.d.ts +1 -1
- package/lib/types/MdEditor/props.d.ts +2 -2
- package/lib/types/MdEditor/static/env.d.ts +1 -0
- package/lib/types/MdEditor/type.d.ts +7 -1
- package/lib/types/MdEditor/utils/index.d.ts +4 -0
- package/lib/types/MdPreview/MdPreview.d.ts +13 -13
- package/lib/types/MdPreview/index.d.ts +45 -45
- package/lib/types/ModalToolbar/ModalToolbar.d.ts +3 -3
- package/lib/types/ModalToolbar/index.d.ts +16 -16
- package/lib/types/NormalToolbar/index.d.ts +5 -5
- package/lib/umd/index.js +67 -68
- package/package.json +31 -31
package/lib/es/chunks/index.mjs
CHANGED
|
@@ -1,28 +1,32 @@
|
|
|
1
|
-
import { inject as
|
|
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
|
|
3
|
-
import { a as
|
|
1
|
+
import { inject as P, watch as I, toRef as te, onMounted as _, nextTick as j, shallowRef as B, ref as R, computed as F, defineComponent as ne, createVNode as M, Fragment as pe, reactive as oe, provide as x, onBeforeUnmount as he } from "vue";
|
|
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 q, b as we, d as ke } from "./config.mjs";
|
|
3
|
+
import { a as $e, b as y, P as Ce, C as K, R as G, B as A, O as re, E as Ie, U as Se, c as ae, d as Z, F as J, e as X, H as Q, f as Y, h as le, i as Ee, j 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
|
|
6
|
+
import { debounce as ie, uuid as U } from "@vavt/util";
|
|
7
7
|
import xe from "copy-to-clipboard";
|
|
8
|
-
import
|
|
9
|
-
import
|
|
8
|
+
import Fe from "markdown-it";
|
|
9
|
+
import He from "markdown-it-image-figures";
|
|
10
10
|
import Me from "markdown-it-task-lists";
|
|
11
11
|
import Re from "markdown-it-xss";
|
|
12
|
-
import Ae from "lru-cache";
|
|
12
|
+
import { LRUCache as Ae } from "lru-cache";
|
|
13
13
|
const Be = (e, a) => {
|
|
14
|
-
const l =
|
|
14
|
+
const l = P("editorId"), { noImgZoomIn: t } = e, n = ie(() => {
|
|
15
15
|
const i = document.querySelectorAll(`#${l}-preview img`);
|
|
16
16
|
i.length !== 0 && Te(i, {
|
|
17
17
|
background: "#00000073"
|
|
18
18
|
});
|
|
19
19
|
});
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
I(
|
|
21
|
+
[a, te(e.setting, "preview")],
|
|
22
|
+
() => {
|
|
23
|
+
!t && e.setting.preview && n();
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
immediate: !0
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
}, Le = (e, a) => {
|
|
26
30
|
if (typeof a[e] == "string")
|
|
27
31
|
return a[e];
|
|
28
32
|
const l = `<i class="${h}-iconfont ${h}-icon-${e}"></i>`;
|
|
@@ -32,14 +36,14 @@ const Be = (e, a) => {
|
|
|
32
36
|
default:
|
|
33
37
|
return l;
|
|
34
38
|
}
|
|
35
|
-
},
|
|
36
|
-
const t =
|
|
39
|
+
}, Ne = (e, a, l) => {
|
|
40
|
+
const t = P("editorId"), n = P("usedLanguageText"), i = P("customIcon"), r = () => {
|
|
37
41
|
document.querySelectorAll(`#${t}-preview pre`).forEach((s) => {
|
|
38
42
|
var v, m;
|
|
39
43
|
let o = -1;
|
|
40
44
|
(v = s.querySelector(".copy-button")) == null || v.remove();
|
|
41
45
|
const d = ((m = n.value.copyCode) == null ? void 0 : m.text) || "复制代码", b = document.createElement("span");
|
|
42
|
-
b.setAttribute("class", "copy-button"), b.dataset.tips = d, b.innerHTML =
|
|
46
|
+
b.setAttribute("class", "copy-button"), b.dataset.tips = d, b.innerHTML = Le("copy", i.value), b.addEventListener("click", () => {
|
|
43
47
|
var w, E;
|
|
44
48
|
clearTimeout(o);
|
|
45
49
|
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) || "已复制!";
|
|
@@ -53,11 +57,11 @@ const Be = (e, a) => {
|
|
|
53
57
|
}, c = (s) => {
|
|
54
58
|
s && j(r);
|
|
55
59
|
};
|
|
56
|
-
I([a, l], u), I(() => e.setting.preview, c), I(() => e.setting.htmlPreview, c), I(() => n.value, r),
|
|
57
|
-
},
|
|
60
|
+
I([a, l], u), I(() => e.setting.preview, c), I(() => e.setting.htmlPreview, c), I(() => n.value, r), _(r);
|
|
61
|
+
}, Oe = (e) => {
|
|
58
62
|
var i;
|
|
59
|
-
const a = (i = S.editorExtensions) == null ? void 0 : i.highlight, l = a == null ? void 0 : a.instance, t =
|
|
60
|
-
return
|
|
63
|
+
const a = (i = S.editorExtensions) == null ? void 0 : i.highlight, l = a == null ? void 0 : a.instance, t = P("highlight"), n = B(l);
|
|
64
|
+
return _(() => {
|
|
61
65
|
if (!e.noHighlight && !n.value) {
|
|
62
66
|
const r = document.createElement("script");
|
|
63
67
|
r.src = t.value.js, r.onload = () => {
|
|
@@ -72,8 +76,8 @@ const Be = (e, a) => {
|
|
|
72
76
|
_e(`${h}-hlCss`, "href", r);
|
|
73
77
|
}
|
|
74
78
|
), n;
|
|
75
|
-
},
|
|
76
|
-
const a =
|
|
79
|
+
}, je = (e) => {
|
|
80
|
+
const a = P("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({
|
|
77
81
|
max: 1e3,
|
|
78
82
|
// 缓存10分钟
|
|
79
83
|
ttl: 6e5
|
|
@@ -91,7 +95,7 @@ const Be = (e, a) => {
|
|
|
91
95
|
() => {
|
|
92
96
|
u.clear(), c();
|
|
93
97
|
}
|
|
94
|
-
),
|
|
98
|
+
), _(() => {
|
|
95
99
|
if (!e.noMermaid && !(n != null && n.instance)) {
|
|
96
100
|
const o = (n == null ? void 0 : n.js) || ge;
|
|
97
101
|
if (/\.mjs/.test(o))
|
|
@@ -136,10 +140,10 @@ const Be = (e, a) => {
|
|
|
136
140
|
}
|
|
137
141
|
});
|
|
138
142
|
} };
|
|
139
|
-
},
|
|
143
|
+
}, Ue = (e) => {
|
|
140
144
|
var n;
|
|
141
145
|
const a = (n = S.editorExtensions) == null ? void 0 : n.katex, l = a == null ? void 0 : a.instance, t = B(l);
|
|
142
|
-
return
|
|
146
|
+
return _(() => {
|
|
143
147
|
if (!e.noKatex && !t.value) {
|
|
144
148
|
const i = document.createElement("script");
|
|
145
149
|
i.src = (a == null ? void 0 : a.js) || D.js, i.onload = () => {
|
|
@@ -149,7 +153,7 @@ const Be = (e, a) => {
|
|
|
149
153
|
r.rel = "stylesheet", r.href = (a == null ? void 0 : a.css) || D.css, r.id = `${h}-katexCss`, T(i, "katex"), T(r);
|
|
150
154
|
}
|
|
151
155
|
}), t;
|
|
152
|
-
},
|
|
156
|
+
}, Ge = (e, a) => {
|
|
153
157
|
const l = e.renderer.rules.fence.bind(e.renderer.rules);
|
|
154
158
|
e.renderer.rules.fence = (t, n, i, r, u) => {
|
|
155
159
|
const c = t[n], s = c.content.trim();
|
|
@@ -159,14 +163,14 @@ const Be = (e, a) => {
|
|
|
159
163
|
}
|
|
160
164
|
return l(t, n, i, r, u);
|
|
161
165
|
};
|
|
162
|
-
},
|
|
166
|
+
}, De = Ge, ee = (e, a) => {
|
|
163
167
|
let l = !0, t = !0;
|
|
164
168
|
const n = e.posMax, i = a > 0 ? e.src.charCodeAt(a - 1) : -1, r = a + 1 <= n ? e.src.charCodeAt(a + 1) : -1;
|
|
165
169
|
return (i === 32 || i === 9 || r >= 48 && r <= 57) && (t = !1), (r === 32 || r === 9) && (l = !1), {
|
|
166
170
|
can_open: l,
|
|
167
171
|
can_close: t
|
|
168
172
|
};
|
|
169
|
-
},
|
|
173
|
+
}, Ve = (e, a) => {
|
|
170
174
|
let l, t, n, i;
|
|
171
175
|
if (e.src[e.pos] !== "$")
|
|
172
176
|
return !1;
|
|
@@ -181,7 +185,7 @@ const Be = (e, a) => {
|
|
|
181
185
|
l += 1;
|
|
182
186
|
}
|
|
183
187
|
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));
|
|
184
|
-
},
|
|
188
|
+
}, ze = (e, a, l, t) => {
|
|
185
189
|
let n, i, r, u, c = !1, s = e.bMarks[a] + e.tShift[a], o = e.eMarks[a];
|
|
186
190
|
if (s + 2 > o || e.src.slice(s, s + 2) !== "$$")
|
|
187
191
|
return !1;
|
|
@@ -193,7 +197,7 @@ const Be = (e, a) => {
|
|
|
193
197
|
const d = e.push("math_block", "math", 0);
|
|
194
198
|
return d.block = !0, d.content = (n && n.trim() ? n + `
|
|
195
199
|
` : "") + e.getLines(a + 1, r, e.tShift[a], !0) + (i && i.trim() ? i : ""), d.map = [a, e.line], d.markup = "$$", !0;
|
|
196
|
-
},
|
|
200
|
+
}, We = (e, a) => {
|
|
197
201
|
const l = (n) => {
|
|
198
202
|
if (a.katexRef.value) {
|
|
199
203
|
const i = a.katexRef.value.renderToString(n, {
|
|
@@ -212,11 +216,11 @@ const Be = (e, a) => {
|
|
|
212
216
|
} else
|
|
213
217
|
return `<p class="${h}-katex-block" data-line=${i}>${n}</p>`;
|
|
214
218
|
};
|
|
215
|
-
e.inline.ruler.after("escape", "math_inline",
|
|
219
|
+
e.inline.ruler.after("escape", "math_inline", Ve), e.block.ruler.after("blockquote", "math_block", ze, {
|
|
216
220
|
alt: ["paragraph", "reference", "blockquote", "list"]
|
|
217
221
|
}), 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]) + `
|
|
218
222
|
`;
|
|
219
|
-
},
|
|
223
|
+
}, qe = We, Ke = (e, a) => {
|
|
220
224
|
a = a || {};
|
|
221
225
|
const l = 3, t = a.marker || "!", n = t.charCodeAt(0), i = t.length;
|
|
222
226
|
let r = "", u = "";
|
|
@@ -255,14 +259,14 @@ const Be = (e, a) => {
|
|
|
255
259
|
break;
|
|
256
260
|
}
|
|
257
261
|
}
|
|
258
|
-
const L = o.parentType,
|
|
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 =
|
|
262
|
+
const L = o.parentType, H = o.lineMax;
|
|
263
|
+
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 = H, o.line = p + (k ? 1 : 0), !0;
|
|
260
264
|
},
|
|
261
265
|
{
|
|
262
266
|
alt: ["paragraph", "reference", "blockquote", "list"]
|
|
263
267
|
}
|
|
264
268
|
), 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;
|
|
265
|
-
},
|
|
269
|
+
}, Ze = Ke, Je = (e, a) => {
|
|
266
270
|
e.renderer.rules.heading_open = (l, t) => {
|
|
267
271
|
var u;
|
|
268
272
|
const n = l[t], i = ((u = l[t + 1].children) == null ? void 0 : u.reduce((c, s) => c + (s.content || ""), "")) || "", r = n.markup.length;
|
|
@@ -274,7 +278,7 @@ const Be = (e, a) => {
|
|
|
274
278
|
a.mdHeadingId(i, r, a.headsRef.value.length)
|
|
275
279
|
)), e.renderer.renderToken(l, t, a);
|
|
276
280
|
}, e.renderer.rules.heading_close = (l, t, n, i, r) => r.renderToken(l, t, n);
|
|
277
|
-
},
|
|
281
|
+
}, Xe = Je, Qe = (e, a) => {
|
|
278
282
|
const l = e.renderer.rules.fence, t = e.utils.unescapeAll, n = /\[(\w*)(?::([\w ]*))?\]/;
|
|
279
283
|
function i(s) {
|
|
280
284
|
return s.info ? t(s.info).trim() : "";
|
|
@@ -304,7 +308,7 @@ const Be = (e, a) => {
|
|
|
304
308
|
` + $ + "</div>";
|
|
305
309
|
};
|
|
306
310
|
e.renderer.rules.fence = c;
|
|
307
|
-
},
|
|
311
|
+
}, Ye = Qe, et = (e) => {
|
|
308
312
|
[
|
|
309
313
|
"paragraph_open",
|
|
310
314
|
"table_open",
|
|
@@ -325,8 +329,8 @@ const Be = (e, a) => {
|
|
|
325
329
|
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);
|
|
326
330
|
};
|
|
327
331
|
});
|
|
328
|
-
},
|
|
329
|
-
const { editorConfig: l, markdownItConfig: t, markdownItPlugins: n } = S, i =
|
|
332
|
+
}, tt = (e, a) => {
|
|
333
|
+
const { editorConfig: l, markdownItConfig: t, markdownItPlugins: n } = S, i = P("editorId"), r = P("showCodeRowNumber"), u = P("theme"), c = R([]), s = Oe(e), o = Ue(e), { reRenderRef: d, replaceMermaid: b } = je(e), v = Fe({
|
|
330
334
|
html: !0,
|
|
331
335
|
breaks: !0
|
|
332
336
|
});
|
|
@@ -336,17 +340,17 @@ const Be = (e, a) => {
|
|
|
336
340
|
const m = [
|
|
337
341
|
{
|
|
338
342
|
type: "katex",
|
|
339
|
-
plugin:
|
|
343
|
+
plugin: qe,
|
|
340
344
|
options: { katexRef: o }
|
|
341
345
|
},
|
|
342
346
|
{
|
|
343
347
|
type: "image",
|
|
344
|
-
plugin:
|
|
348
|
+
plugin: He,
|
|
345
349
|
options: { figcaption: !0, classes: "md-zoom" }
|
|
346
350
|
},
|
|
347
351
|
{
|
|
348
352
|
type: "admonition",
|
|
349
|
-
plugin:
|
|
353
|
+
plugin: Ze,
|
|
350
354
|
options: {}
|
|
351
355
|
},
|
|
352
356
|
{
|
|
@@ -356,12 +360,12 @@ const Be = (e, a) => {
|
|
|
356
360
|
},
|
|
357
361
|
{
|
|
358
362
|
type: "heading",
|
|
359
|
-
plugin:
|
|
363
|
+
plugin: Xe,
|
|
360
364
|
options: { mdHeadingId: e.mdHeadingId, headsRef: c }
|
|
361
365
|
},
|
|
362
366
|
{
|
|
363
367
|
type: "codeTabs",
|
|
364
|
-
plugin:
|
|
368
|
+
plugin: Ye,
|
|
365
369
|
options: { editorId: i }
|
|
366
370
|
},
|
|
367
371
|
{
|
|
@@ -372,7 +376,21 @@ const Be = (e, a) => {
|
|
|
372
376
|
xss($) {
|
|
373
377
|
return {
|
|
374
378
|
whiteList: Object.assign({}, $.getDefaultWhiteList(), {
|
|
375
|
-
|
|
379
|
+
// 支持任务列表
|
|
380
|
+
input: ["class", "disabled", "type", "checked"],
|
|
381
|
+
// 主要支持youtobe、腾讯视频、哔哩哔哩等内嵌视频代码
|
|
382
|
+
iframe: [
|
|
383
|
+
"class",
|
|
384
|
+
"width",
|
|
385
|
+
"height",
|
|
386
|
+
"src",
|
|
387
|
+
"title",
|
|
388
|
+
"border",
|
|
389
|
+
"frameborder",
|
|
390
|
+
"framespacing",
|
|
391
|
+
"allow",
|
|
392
|
+
"allowfullscreen"
|
|
393
|
+
]
|
|
376
394
|
})
|
|
377
395
|
};
|
|
378
396
|
}
|
|
@@ -381,7 +399,7 @@ const Be = (e, a) => {
|
|
|
381
399
|
];
|
|
382
400
|
e.noMermaid || m.push({
|
|
383
401
|
type: "mermaid",
|
|
384
|
-
plugin:
|
|
402
|
+
plugin: De,
|
|
385
403
|
options: { themeRef: u }
|
|
386
404
|
}), n(m, {
|
|
387
405
|
editorId: i
|
|
@@ -396,33 +414,33 @@ const Be = (e, a) => {
|
|
|
396
414
|
if (N)
|
|
397
415
|
return N;
|
|
398
416
|
}
|
|
399
|
-
let
|
|
400
|
-
!e.noHighlight && s.value ? s.value.getLanguage(C) ?
|
|
417
|
+
let H;
|
|
418
|
+
!e.noHighlight && s.value ? s.value.getLanguage(C) ? H = s.value.highlight($, {
|
|
401
419
|
language: C,
|
|
402
420
|
ignoreIllegals: !0
|
|
403
|
-
}).value :
|
|
404
|
-
const
|
|
405
|
-
return `<pre><code class="language-${C}" language=${C}>${
|
|
421
|
+
}).value : H = s.value.highlightAuto($).value : H = v.utils.escapeHtml($);
|
|
422
|
+
const fe = r ? $e(H.replace(/^\n+|\n+$/g, "")) : `<span class="code-block">${H.replace(/^\n+|\n+$/g, "")}</span>`;
|
|
423
|
+
return `<pre><code class="language-${C}" language=${C}>${fe}</code></pre>`;
|
|
406
424
|
}
|
|
407
|
-
}),
|
|
425
|
+
}), et(v);
|
|
408
426
|
const f = R(`_article-key_${U()}`), k = R(e.sanitize(v.render(e.modelValue))), g = () => {
|
|
409
|
-
y.emit(i, A, k.value), e.onHtmlChanged(k.value), e.onGetCatalog(c.value), y.emit(i,
|
|
427
|
+
y.emit(i, A, k.value), e.onHtmlChanged(k.value), e.onGetCatalog(c.value), y.emit(i, K, c.value), b();
|
|
410
428
|
};
|
|
411
|
-
|
|
429
|
+
_(g);
|
|
412
430
|
const w = () => {
|
|
413
431
|
c.value = [], k.value = e.sanitize(v.render(e.modelValue)), g();
|
|
414
|
-
}, E =
|
|
432
|
+
}, E = F(() => (e.noKatex || o.value) && (e.noHighlight || s.value));
|
|
415
433
|
return I(
|
|
416
|
-
[
|
|
417
|
-
|
|
434
|
+
[te(e, "modelValue"), E, d],
|
|
435
|
+
ie(
|
|
418
436
|
w,
|
|
419
437
|
(l == null ? void 0 : l.renderDelay) !== void 0 ? l == null ? void 0 : l.renderDelay : a ? 0 : 500
|
|
420
438
|
)
|
|
421
|
-
),
|
|
439
|
+
), _(() => {
|
|
422
440
|
y.on(i, {
|
|
423
|
-
name:
|
|
441
|
+
name: Ce,
|
|
424
442
|
callback() {
|
|
425
|
-
y.emit(i,
|
|
443
|
+
y.emit(i, K, c.value);
|
|
426
444
|
}
|
|
427
445
|
}), y.on(i, {
|
|
428
446
|
name: G,
|
|
@@ -431,14 +449,14 @@ const Be = (e, a) => {
|
|
|
431
449
|
}
|
|
432
450
|
});
|
|
433
451
|
}), { html: k, key: f };
|
|
434
|
-
},
|
|
452
|
+
}, nt = tt, ce = {
|
|
435
453
|
modelValue: {
|
|
436
454
|
type: String,
|
|
437
455
|
default: ""
|
|
438
456
|
},
|
|
439
457
|
setting: {
|
|
440
458
|
type: Object,
|
|
441
|
-
default: () => ({})
|
|
459
|
+
default: () => ({ preview: !0 })
|
|
442
460
|
},
|
|
443
461
|
onHtmlChanged: {
|
|
444
462
|
type: Function,
|
|
@@ -485,8 +503,8 @@ const Be = (e, a) => {
|
|
|
485
503
|
sanitizeMermaid: {
|
|
486
504
|
type: Function
|
|
487
505
|
}
|
|
488
|
-
},
|
|
489
|
-
...
|
|
506
|
+
}, vt = {
|
|
507
|
+
...ce,
|
|
490
508
|
onChange: {
|
|
491
509
|
type: Function,
|
|
492
510
|
default: () => {
|
|
@@ -557,35 +575,33 @@ const Be = (e, a) => {
|
|
|
557
575
|
onInputBoxWitdhChange: {
|
|
558
576
|
type: Function
|
|
559
577
|
}
|
|
560
|
-
},
|
|
578
|
+
}, ot = /* @__PURE__ */ ne({
|
|
561
579
|
name: "ContentPreview",
|
|
562
|
-
props:
|
|
580
|
+
props: ce,
|
|
563
581
|
setup(e) {
|
|
564
|
-
const a =
|
|
582
|
+
const a = P("editorId"), l = P("previewTheme"), t = P("showCodeRowNumber"), {
|
|
565
583
|
html: n,
|
|
566
584
|
key: i
|
|
567
|
-
} =
|
|
568
|
-
return
|
|
585
|
+
} = nt(e, e.previewOnly);
|
|
586
|
+
return Ne(e, n, i), Be(e, n), () => M(pe, null, [e.setting.preview && M("div", {
|
|
569
587
|
id: `${a}-preview-wrapper`,
|
|
570
588
|
class: `${h}-preview-wrapper`,
|
|
571
|
-
"data-show": e.setting.preview,
|
|
572
589
|
key: "content-preview-wrapper"
|
|
573
590
|
}, [M("div", {
|
|
574
591
|
key: i.value,
|
|
575
592
|
id: `${a}-preview`,
|
|
576
593
|
class: [`${h}-preview`, `${l == null ? void 0 : l.value}-theme`, t && `${h}-scrn`],
|
|
577
594
|
innerHTML: n.value
|
|
578
|
-
}, null)]), !e.previewOnly && M("div", {
|
|
595
|
+
}, null)]), !e.previewOnly && e.setting.htmlPreview && M("div", {
|
|
579
596
|
id: `${a}-html-wrapper`,
|
|
580
597
|
class: `${h}-preview-wrapper`,
|
|
581
|
-
"data-show": e.setting.htmlPreview,
|
|
582
598
|
key: "html-preview-wrapper"
|
|
583
599
|
}, [M("div", {
|
|
584
600
|
class: `${h}-html`
|
|
585
601
|
}, [n.value])])]);
|
|
586
602
|
}
|
|
587
|
-
}),
|
|
588
|
-
const { editorId: l } = e, t =
|
|
603
|
+
}), bt = (e, a) => {
|
|
604
|
+
const { editorId: l } = e, t = oe({
|
|
589
605
|
// 是否已编译成html
|
|
590
606
|
buildFinished: !1,
|
|
591
607
|
// 存储当前最新的html
|
|
@@ -596,14 +612,14 @@ const Be = (e, a) => {
|
|
|
596
612
|
() => {
|
|
597
613
|
t.buildFinished = !1;
|
|
598
614
|
}
|
|
599
|
-
),
|
|
615
|
+
), _(() => {
|
|
600
616
|
y.on(l, {
|
|
601
617
|
name: A,
|
|
602
618
|
callback(n) {
|
|
603
619
|
t.buildFinished = !0, t.html = n;
|
|
604
620
|
}
|
|
605
621
|
}), y.on(l, {
|
|
606
|
-
name:
|
|
622
|
+
name: re,
|
|
607
623
|
callback() {
|
|
608
624
|
const n = new Promise((i) => {
|
|
609
625
|
if (t.buildFinished)
|
|
@@ -622,18 +638,18 @@ const Be = (e, a) => {
|
|
|
622
638
|
}
|
|
623
639
|
});
|
|
624
640
|
});
|
|
625
|
-
},
|
|
641
|
+
}, se = (e) => {
|
|
626
642
|
var n, i;
|
|
627
643
|
const { editorId: a } = e, l = (i = (n = S) == null ? void 0 : n.editorExtensions) == null ? void 0 : i.highlight;
|
|
628
644
|
x("editorId", a), x(
|
|
629
645
|
"theme",
|
|
630
|
-
|
|
646
|
+
F(() => e.theme)
|
|
631
647
|
), x(
|
|
632
648
|
"language",
|
|
633
|
-
|
|
649
|
+
F(() => e.language)
|
|
634
650
|
), x(
|
|
635
651
|
"highlight",
|
|
636
|
-
|
|
652
|
+
F(() => {
|
|
637
653
|
const r = {
|
|
638
654
|
...V,
|
|
639
655
|
...l == null ? void 0 : l.css
|
|
@@ -644,7 +660,7 @@ const Be = (e, a) => {
|
|
|
644
660
|
};
|
|
645
661
|
})
|
|
646
662
|
), x("showCodeRowNumber", e.showCodeRowNumber);
|
|
647
|
-
const t =
|
|
663
|
+
const t = F(() => {
|
|
648
664
|
var u, c;
|
|
649
665
|
const r = {
|
|
650
666
|
...z,
|
|
@@ -654,15 +670,15 @@ const Be = (e, a) => {
|
|
|
654
670
|
});
|
|
655
671
|
x("usedLanguageText", t), x(
|
|
656
672
|
"previewTheme",
|
|
657
|
-
|
|
673
|
+
F(() => e.previewTheme)
|
|
658
674
|
), x(
|
|
659
675
|
"customIcon",
|
|
660
|
-
|
|
676
|
+
F(() => e.customIcon)
|
|
661
677
|
);
|
|
662
|
-
},
|
|
663
|
-
|
|
664
|
-
},
|
|
665
|
-
|
|
678
|
+
}, wt = (e) => {
|
|
679
|
+
se(e), x("tabWidth", e.tabWidth);
|
|
680
|
+
}, ue = (e) => {
|
|
681
|
+
_(() => {
|
|
666
682
|
var a, l;
|
|
667
683
|
if (!e.noIconfont)
|
|
668
684
|
if (S.iconfontType === "svg") {
|
|
@@ -673,30 +689,30 @@ const Be = (e, a) => {
|
|
|
673
689
|
t.rel = "stylesheet", t.href = ((l = S.editorExtensions) == null ? void 0 : l.iconfontClass) || be, t.id = `${h}-icon-class`, T(t);
|
|
674
690
|
}
|
|
675
691
|
});
|
|
676
|
-
},
|
|
692
|
+
}, kt = (e) => {
|
|
677
693
|
var u, c, s, o, d, b;
|
|
678
694
|
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);
|
|
679
|
-
|
|
695
|
+
_(() => {
|
|
680
696
|
var k, g, w, E;
|
|
681
697
|
const v = document.createElement("script"), m = document.createElement("script");
|
|
682
698
|
v.src = ((k = t == null ? void 0 : t.prettier) == null ? void 0 : k.standaloneJs) || W.main, v.id = `${h}-prettier`, m.src = ((g = t == null ? void 0 : t.prettier) == null ? void 0 : g.parserMarkdownJs) || W.markdown, m.id = `${h}-prettierMD`;
|
|
683
699
|
const p = document.createElement("link");
|
|
684
|
-
p.rel = "stylesheet", p.href = ((w = t == null ? void 0 : t.cropper) == null ? void 0 : w.css) ||
|
|
700
|
+
p.rel = "stylesheet", p.href = ((w = t == null ? void 0 : t.cropper) == null ? void 0 : w.css) || q.css, p.id = `${h}-cropperCss`;
|
|
685
701
|
const f = document.createElement("script");
|
|
686
|
-
f.src = ((E = t == null ? void 0 : t.cropper) == null ? void 0 : E.js) ||
|
|
687
|
-
}),
|
|
688
|
-
},
|
|
702
|
+
f.src = ((E = t == null ? void 0 : t.cropper) == null ? void 0 : E.js) || q.js, f.id = `${h}-cropper`, r || (T(p), T(f)), n || T(v), i || T(m);
|
|
703
|
+
}), ue(e);
|
|
704
|
+
}, $t = (e, a) => {
|
|
689
705
|
const { editorId: l } = e;
|
|
690
|
-
|
|
706
|
+
_(() => {
|
|
691
707
|
y.on(l, {
|
|
692
|
-
name:
|
|
708
|
+
name: Ie,
|
|
693
709
|
callback: (t) => {
|
|
694
710
|
e.onError instanceof Function ? e.onError(t) : a.emit("onError", t);
|
|
695
711
|
}
|
|
696
712
|
});
|
|
697
713
|
});
|
|
698
|
-
},
|
|
699
|
-
const { editorId: l } = e, t =
|
|
714
|
+
}, Ct = (e, a) => {
|
|
715
|
+
const { editorId: l } = e, t = oe({
|
|
700
716
|
pageFullscreen: e.pageFullscreen,
|
|
701
717
|
fullscreen: !1,
|
|
702
718
|
preview: e.preview,
|
|
@@ -708,12 +724,12 @@ const Be = (e, a) => {
|
|
|
708
724
|
const r = () => {
|
|
709
725
|
t.pageFullscreen || t.fullscreen ? document.body.style.overflow = "hidden" : document.body.style.overflow = i;
|
|
710
726
|
};
|
|
711
|
-
return I(() => [t.pageFullscreen, t.fullscreen], r),
|
|
727
|
+
return I(() => [t.pageFullscreen, t.fullscreen], r), _(() => {
|
|
712
728
|
y.on(l, {
|
|
713
|
-
name:
|
|
729
|
+
name: Se,
|
|
714
730
|
callback(u, c) {
|
|
715
731
|
const s = (o) => {
|
|
716
|
-
y.emit(l,
|
|
732
|
+
y.emit(l, le, "image", {
|
|
717
733
|
desc: "",
|
|
718
734
|
urls: o
|
|
719
735
|
}), c && c();
|
|
@@ -722,17 +738,17 @@ const Be = (e, a) => {
|
|
|
722
738
|
}
|
|
723
739
|
}), i = document.body.style.overflow, r();
|
|
724
740
|
}), [t, n];
|
|
725
|
-
},
|
|
741
|
+
}, It = (e) => {
|
|
726
742
|
const { editorId: a } = e, l = R(!1);
|
|
727
|
-
return
|
|
743
|
+
return _(() => {
|
|
728
744
|
y.on(a, {
|
|
729
|
-
name:
|
|
745
|
+
name: ae,
|
|
730
746
|
callback: (n) => {
|
|
731
747
|
n === void 0 ? l.value = !l.value : l.value = n;
|
|
732
748
|
}
|
|
733
749
|
});
|
|
734
|
-
}),
|
|
735
|
-
},
|
|
750
|
+
}), F(() => !e.toolbarsExclude.includes("catalog") && e.toolbars.includes("catalog") && l.value);
|
|
751
|
+
}, St = (e, a, l, t, n, i) => {
|
|
736
752
|
const { editorId: r } = e;
|
|
737
753
|
I(
|
|
738
754
|
() => t.pageFullscreen,
|
|
@@ -811,7 +827,7 @@ const Be = (e, a) => {
|
|
|
811
827
|
n("pageFullscreen", c);
|
|
812
828
|
},
|
|
813
829
|
toggleFullscreen(c) {
|
|
814
|
-
y.emit(r,
|
|
830
|
+
y.emit(r, Ee, c);
|
|
815
831
|
},
|
|
816
832
|
togglePreview(c) {
|
|
817
833
|
n("preview", c);
|
|
@@ -820,13 +836,13 @@ const Be = (e, a) => {
|
|
|
820
836
|
n("htmlPreview", c);
|
|
821
837
|
},
|
|
822
838
|
toggleCatalog(c) {
|
|
823
|
-
y.emit(r,
|
|
839
|
+
y.emit(r, ae, c);
|
|
824
840
|
},
|
|
825
841
|
triggerSave() {
|
|
826
|
-
y.emit(r,
|
|
842
|
+
y.emit(r, re);
|
|
827
843
|
},
|
|
828
844
|
insert(c) {
|
|
829
|
-
y.emit(r,
|
|
845
|
+
y.emit(r, le, "universal", { generate: c });
|
|
830
846
|
},
|
|
831
847
|
focus(c) {
|
|
832
848
|
var s;
|
|
@@ -845,7 +861,7 @@ const Be = (e, a) => {
|
|
|
845
861
|
}
|
|
846
862
|
};
|
|
847
863
|
a.expose(u);
|
|
848
|
-
},
|
|
864
|
+
}, rt = (e) => e, de = {
|
|
849
865
|
/**
|
|
850
866
|
* markdown content.
|
|
851
867
|
*
|
|
@@ -901,7 +917,7 @@ const Be = (e, a) => {
|
|
|
901
917
|
*/
|
|
902
918
|
editorId: {
|
|
903
919
|
type: String,
|
|
904
|
-
default:
|
|
920
|
+
default: () => Pe("md-editor-v3_")
|
|
905
921
|
},
|
|
906
922
|
/**
|
|
907
923
|
* 预览中代码是否显示行号
|
|
@@ -935,7 +951,7 @@ const Be = (e, a) => {
|
|
|
935
951
|
*/
|
|
936
952
|
mdHeadingId: {
|
|
937
953
|
type: Function,
|
|
938
|
-
default:
|
|
954
|
+
default: rt
|
|
939
955
|
},
|
|
940
956
|
/**
|
|
941
957
|
*
|
|
@@ -1033,8 +1049,8 @@ const Be = (e, a) => {
|
|
|
1033
1049
|
type: Function,
|
|
1034
1050
|
default: (e) => Promise.resolve(e)
|
|
1035
1051
|
}
|
|
1036
|
-
},
|
|
1037
|
-
...
|
|
1052
|
+
}, Et = {
|
|
1053
|
+
...de,
|
|
1038
1054
|
/**
|
|
1039
1055
|
* input回调事件
|
|
1040
1056
|
*/
|
|
@@ -1098,7 +1114,7 @@ const Be = (e, a) => {
|
|
|
1098
1114
|
*/
|
|
1099
1115
|
toolbars: {
|
|
1100
1116
|
type: Array,
|
|
1101
|
-
default:
|
|
1117
|
+
default: we
|
|
1102
1118
|
},
|
|
1103
1119
|
/**
|
|
1104
1120
|
* 工具栏选择不显示
|
|
@@ -1162,7 +1178,7 @@ const Be = (e, a) => {
|
|
|
1162
1178
|
*/
|
|
1163
1179
|
footers: {
|
|
1164
1180
|
type: Array,
|
|
1165
|
-
default:
|
|
1181
|
+
default: ke
|
|
1166
1182
|
},
|
|
1167
1183
|
/**
|
|
1168
1184
|
* 是否默认激活输入框和预览框同步滚动
|
|
@@ -1285,8 +1301,8 @@ const Be = (e, a) => {
|
|
|
1285
1301
|
onInputBoxWitdhChange: {
|
|
1286
1302
|
type: Function
|
|
1287
1303
|
}
|
|
1288
|
-
},
|
|
1289
|
-
...
|
|
1304
|
+
}, me = ["onHtmlChanged", "onGetCatalog"], Pt = [
|
|
1305
|
+
...me,
|
|
1290
1306
|
"onChange",
|
|
1291
1307
|
"onSave",
|
|
1292
1308
|
"onUploadImg",
|
|
@@ -1297,17 +1313,17 @@ const Be = (e, a) => {
|
|
|
1297
1313
|
"onInput",
|
|
1298
1314
|
"onDrop",
|
|
1299
1315
|
"onInputBoxWitdhChange"
|
|
1300
|
-
],
|
|
1316
|
+
], at = (e, a) => {
|
|
1301
1317
|
const { editorId: l } = e, t = {
|
|
1302
1318
|
rerender() {
|
|
1303
1319
|
y.emit(l, G);
|
|
1304
1320
|
}
|
|
1305
1321
|
};
|
|
1306
1322
|
a.expose(t);
|
|
1307
|
-
},
|
|
1323
|
+
}, O = /* @__PURE__ */ ne({
|
|
1308
1324
|
name: "MdPreview",
|
|
1309
|
-
props:
|
|
1310
|
-
emits:
|
|
1325
|
+
props: de,
|
|
1326
|
+
emits: me,
|
|
1311
1327
|
setup(e, a) {
|
|
1312
1328
|
const {
|
|
1313
1329
|
editorId: l,
|
|
@@ -1315,13 +1331,13 @@ const Be = (e, a) => {
|
|
|
1315
1331
|
noMermaid: n,
|
|
1316
1332
|
noHighlight: i
|
|
1317
1333
|
} = e;
|
|
1318
|
-
return
|
|
1334
|
+
return se(e), ue(e), at(e, a), he(() => {
|
|
1319
1335
|
y.clear(l);
|
|
1320
1336
|
}), () => M("div", {
|
|
1321
1337
|
id: l,
|
|
1322
1338
|
class: [h, e.class, e.theme === "dark" && `${h}-dark`, `${h}-previewOnly`],
|
|
1323
1339
|
style: e.style
|
|
1324
|
-
}, [M(
|
|
1340
|
+
}, [M(ot, {
|
|
1325
1341
|
modelValue: e.modelValue,
|
|
1326
1342
|
onHtmlChanged: (r) => {
|
|
1327
1343
|
e.onHtmlChanged ? e.onHtmlChanged(r) : a.emit("onHtmlChanged", r);
|
|
@@ -1340,19 +1356,19 @@ const Be = (e, a) => {
|
|
|
1340
1356
|
sanitizeMermaid: e.sanitizeMermaid
|
|
1341
1357
|
}, null)]);
|
|
1342
1358
|
}
|
|
1343
|
-
})
|
|
1359
|
+
});
|
|
1344
1360
|
O.install = (e) => (e.component(O.name, O), e);
|
|
1345
1361
|
export {
|
|
1346
|
-
|
|
1362
|
+
ot as C,
|
|
1347
1363
|
O as M,
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1364
|
+
Pt as a,
|
|
1365
|
+
wt as b,
|
|
1366
|
+
vt as c,
|
|
1367
|
+
kt as d,
|
|
1368
|
+
Et as e,
|
|
1369
|
+
$t as f,
|
|
1370
|
+
Ct as g,
|
|
1371
|
+
It as h,
|
|
1372
|
+
St as i,
|
|
1373
|
+
bt as u
|
|
1358
1374
|
};
|