md-editor-v3 4.3.0-beta.4 → 4.3.0-beta.5
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/lib/cjs/MdEditor.cjs +24 -24
- package/lib/cjs/chunks/index.cjs +7 -7
- package/lib/es/MdEditor.mjs +457 -429
- package/lib/es/chunks/index.mjs +171 -160
- package/lib/types/MdEditor/layouts/Content/codemirror/index.d.ts +3 -3
- package/lib/types/MdEditor/type.d.ts +2 -1
- package/lib/umd/index.js +6 -6
- package/package.json +1 -1
package/lib/es/chunks/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { inject as
|
|
2
|
-
import { p as h, a as
|
|
1
|
+
import { inject as T, onMounted as S, watch as $, toRef as Z, nextTick as A, shallowRef as x, ref as L, computed as M, defineComponent as J, createVNode as H, Fragment as le, reactive as X, provide as F, onBeforeUnmount as ie } from "vue";
|
|
2
|
+
import { p as h, a as P, m as ce, k as B, e as j, h as se, f as O, i as de, g as U, j as V, l as ue, b as me, d as fe } from "./config.mjs";
|
|
3
3
|
import { u as pe, g as he, b as g } from "./index3.mjs";
|
|
4
4
|
import { a as _, u as ge } from "./dom.mjs";
|
|
5
5
|
import ve from "medium-zoom";
|
|
@@ -9,16 +9,16 @@ import be from "markdown-it";
|
|
|
9
9
|
import we from "markdown-it-image-figures";
|
|
10
10
|
import ke from "markdown-it-task-lists";
|
|
11
11
|
import $e from "lru-cache";
|
|
12
|
-
const Y = "onSave", ee = "changeCatalogVisible", Ce = "changeFullscreen", G = "pageFullscreenChanged", z = "fullscreenChanged", D = "previewChanged", K = "htmlPreviewChanged", q = "catalogVisibleChanged", Se = "textareaFocus", Ie = (e,
|
|
13
|
-
const l =
|
|
12
|
+
const Y = "onSave", ee = "changeCatalogVisible", Ce = "changeFullscreen", G = "pageFullscreenChanged", z = "fullscreenChanged", D = "previewChanged", K = "htmlPreviewChanged", q = "catalogVisibleChanged", Se = "textareaFocus", Ie = (e, o) => {
|
|
13
|
+
const l = T("editorId"), t = Q(() => {
|
|
14
14
|
const n = document.querySelectorAll(`#${l}-preview img.md-zoom`);
|
|
15
15
|
n.length !== 0 && ve(n, {
|
|
16
16
|
background: "#00000073"
|
|
17
17
|
});
|
|
18
18
|
});
|
|
19
|
-
|
|
20
|
-
},
|
|
21
|
-
const l =
|
|
19
|
+
S(t), $([o, Z(e.setting, "preview")], t);
|
|
20
|
+
}, Ee = Ie, Pe = (e, o) => {
|
|
21
|
+
const l = T("editorId"), t = T("usedLanguageText"), n = () => {
|
|
22
22
|
document.querySelectorAll(`#${l}-preview pre`).forEach((c) => {
|
|
23
23
|
var m, b;
|
|
24
24
|
let d = -1;
|
|
@@ -33,16 +33,16 @@ const Y = "onSave", ee = "changeCatalogVisible", Ce = "changeFullscreen", G = "p
|
|
|
33
33
|
}, 1500);
|
|
34
34
|
}), c.appendChild(r);
|
|
35
35
|
});
|
|
36
|
-
},
|
|
36
|
+
}, a = () => {
|
|
37
37
|
A(n);
|
|
38
38
|
}, i = (c) => {
|
|
39
39
|
c && A(n);
|
|
40
40
|
};
|
|
41
|
-
$(() =>
|
|
42
|
-
},
|
|
43
|
-
var
|
|
44
|
-
const
|
|
45
|
-
return
|
|
41
|
+
$(() => o.value, a), $(() => e.setting.preview, i), $(() => e.setting.htmlPreview, i), $(() => t.value, n), S(n);
|
|
42
|
+
}, Te = Pe, _e = (e) => {
|
|
43
|
+
var a;
|
|
44
|
+
const o = (a = P.editorExtensions) == null ? void 0 : a.highlight, l = o == null ? void 0 : o.instance, t = T("highlight"), n = x(l);
|
|
45
|
+
return S(() => {
|
|
46
46
|
if (!e.noHighlight && !n.value) {
|
|
47
47
|
const i = document.createElement("script");
|
|
48
48
|
i.src = t.value.js, i.onload = () => {
|
|
@@ -58,7 +58,7 @@ const Y = "onSave", ee = "changeCatalogVisible", Ce = "changeFullscreen", G = "p
|
|
|
58
58
|
}
|
|
59
59
|
), n;
|
|
60
60
|
}, Fe = _e, He = (e) => {
|
|
61
|
-
const
|
|
61
|
+
const o = T("theme"), { editorExtensions: l } = P, t = l == null ? void 0 : l.mermaid, n = x(t == null ? void 0 : t.instance), a = x(-1), i = new $e({
|
|
62
62
|
max: 1e3,
|
|
63
63
|
// 缓存10分钟
|
|
64
64
|
ttl: 6e5
|
|
@@ -66,15 +66,15 @@ const Y = "onSave", ee = "changeCatalogVisible", Ce = "changeFullscreen", G = "p
|
|
|
66
66
|
const s = n.value;
|
|
67
67
|
!e.noMermaid && s && (s.initialize({
|
|
68
68
|
startOnLoad: !1,
|
|
69
|
-
theme:
|
|
70
|
-
}),
|
|
69
|
+
theme: o.value === "dark" ? "dark" : "default"
|
|
70
|
+
}), a.value = a.value + 1);
|
|
71
71
|
};
|
|
72
72
|
return $(
|
|
73
|
-
() =>
|
|
73
|
+
() => o.value,
|
|
74
74
|
() => {
|
|
75
75
|
i.clear(), c();
|
|
76
76
|
}
|
|
77
|
-
),
|
|
77
|
+
), S(() => {
|
|
78
78
|
if (!e.noMermaid && !(t != null && t.instance)) {
|
|
79
79
|
const s = (t == null ? void 0 : t.js) || ce;
|
|
80
80
|
if (/\.mjs/.test(s))
|
|
@@ -92,7 +92,7 @@ const Y = "onSave", ee = "changeCatalogVisible", Ce = "changeFullscreen", G = "p
|
|
|
92
92
|
}, _(r, "mermaid");
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
|
-
}), { mermaidRef: n, reRenderRef:
|
|
95
|
+
}), { mermaidRef: n, reRenderRef: a, replaceMermaid: () => {
|
|
96
96
|
A(() => {
|
|
97
97
|
if (!e.noMermaid && n.value) {
|
|
98
98
|
const s = document.querySelectorAll(
|
|
@@ -119,87 +119,87 @@ const Y = "onSave", ee = "changeCatalogVisible", Ce = "changeFullscreen", G = "p
|
|
|
119
119
|
} };
|
|
120
120
|
}, Me = He, xe = (e) => {
|
|
121
121
|
var n;
|
|
122
|
-
const
|
|
123
|
-
return
|
|
122
|
+
const o = (n = P.editorExtensions) == null ? void 0 : n.katex, l = o == null ? void 0 : o.instance, t = x(l);
|
|
123
|
+
return S(() => {
|
|
124
124
|
if (!e.noKatex && !t.value) {
|
|
125
|
-
const
|
|
126
|
-
|
|
125
|
+
const a = document.createElement("script");
|
|
126
|
+
a.src = (o == null ? void 0 : o.js) || B.js, a.onload = () => {
|
|
127
127
|
t.value = window.katex;
|
|
128
|
-
},
|
|
128
|
+
}, a.id = `${h}-katex`;
|
|
129
129
|
const i = document.createElement("link");
|
|
130
|
-
i.rel = "stylesheet", i.href = (
|
|
130
|
+
i.rel = "stylesheet", i.href = (o == null ? void 0 : o.css) || B.css, i.id = `${h}-katexCss`, _(a, "katex"), _(i);
|
|
131
131
|
}
|
|
132
132
|
}), t;
|
|
133
|
-
}, Re = xe, Ae = (e,
|
|
133
|
+
}, Re = xe, Ae = (e, o) => {
|
|
134
134
|
const l = e.renderer.rules.fence.bind(e.renderer.rules);
|
|
135
|
-
e.renderer.rules.fence = (t, n,
|
|
135
|
+
e.renderer.rules.fence = (t, n, a, i, c) => {
|
|
136
136
|
const d = t[n], s = d.content.trim();
|
|
137
137
|
if (d.info === "mermaid") {
|
|
138
138
|
let r;
|
|
139
|
-
return t[n].map && t[n].level === 0 && (r = t[n].map[0], t[n].attrSet("data-line", String(r))), `<div class="${h}-mermaid" ${r !== void 0 ? "data-line=" + r : ""} data-mermaid-theme=${
|
|
139
|
+
return t[n].map && t[n].level === 0 && (r = t[n].map[0], t[n].attrSet("data-line", String(r))), `<div class="${h}-mermaid" ${r !== void 0 ? "data-line=" + r : ""} data-mermaid-theme=${o.themeRef.value}>${s}</div>`;
|
|
140
140
|
}
|
|
141
|
-
return l(t, n,
|
|
141
|
+
return l(t, n, a, i, c);
|
|
142
142
|
};
|
|
143
|
-
}, Le = Ae, W = (e,
|
|
143
|
+
}, Le = Ae, W = (e, o) => {
|
|
144
144
|
let l = !0, t = !0;
|
|
145
|
-
const n = e.posMax,
|
|
146
|
-
return (
|
|
145
|
+
const n = e.posMax, a = o > 0 ? e.src.charCodeAt(o - 1) : -1, i = o + 1 <= n ? e.src.charCodeAt(o + 1) : -1;
|
|
146
|
+
return (a === 32 || a === 9 || i >= 48 && i <= 57) && (t = !1), (i === 32 || i === 9) && (l = !1), {
|
|
147
147
|
can_open: l,
|
|
148
148
|
can_close: t
|
|
149
149
|
};
|
|
150
|
-
}, Ne = (e,
|
|
151
|
-
let l, t, n,
|
|
150
|
+
}, Ne = (e, o) => {
|
|
151
|
+
let l, t, n, a;
|
|
152
152
|
if (e.src[e.pos] !== "$")
|
|
153
153
|
return !1;
|
|
154
154
|
if (n = W(e, e.pos), !n.can_open)
|
|
155
|
-
return
|
|
155
|
+
return o || (e.pending += "$"), e.pos += 1, !0;
|
|
156
156
|
const i = e.pos + 1;
|
|
157
157
|
for (l = i; (l = e.src.indexOf("$", l)) !== -1; ) {
|
|
158
|
-
for (
|
|
159
|
-
|
|
160
|
-
if ((l -
|
|
158
|
+
for (a = l - 1; e.src[a] === "\\"; )
|
|
159
|
+
a -= 1;
|
|
160
|
+
if ((l - a) % 2 == 1)
|
|
161
161
|
break;
|
|
162
162
|
l += 1;
|
|
163
163
|
}
|
|
164
|
-
return l === -1 ? (
|
|
165
|
-
}, Be = (e,
|
|
166
|
-
let n,
|
|
164
|
+
return l === -1 ? (o || (e.pending += "$"), e.pos = i, !0) : l - i === 0 ? (o || (e.pending += "$$"), e.pos = i + 1, !0) : (n = W(e, l), n.can_close ? (o || (t = e.push("math_inline", "math", 0), t.markup = "$", t.content = e.src.slice(i, l)), e.pos = l + 1, !0) : (o || (e.pending += "$"), e.pos = i, !0));
|
|
165
|
+
}, Be = (e, o, l, t) => {
|
|
166
|
+
let n, a, i, c, d = !1, s = e.bMarks[o] + e.tShift[o], r = e.eMarks[o];
|
|
167
167
|
if (s + 2 > r || e.src.slice(s, s + 2) !== "$$")
|
|
168
168
|
return !1;
|
|
169
169
|
if (s += 2, n = e.src.slice(s, r), t)
|
|
170
170
|
return !0;
|
|
171
|
-
for (n.trim().slice(-2) === "$$" && (n = n.trim().slice(0, -2), d = !0), i =
|
|
172
|
-
e.src.slice(s, r).trim().slice(-2) === "$$" && (c = e.src.slice(0, r).lastIndexOf("$$"),
|
|
171
|
+
for (n.trim().slice(-2) === "$$" && (n = n.trim().slice(0, -2), d = !0), i = o; !d && (i++, !(i >= l || (s = e.bMarks[i] + e.tShift[i], r = e.eMarks[i], s < r && e.tShift[i] < e.blkIndent))); )
|
|
172
|
+
e.src.slice(s, r).trim().slice(-2) === "$$" && (c = e.src.slice(0, r).lastIndexOf("$$"), a = e.src.slice(s, c), d = !0);
|
|
173
173
|
e.line = i + 1;
|
|
174
174
|
const m = e.push("math_block", "math", 0);
|
|
175
175
|
return m.block = !0, m.content = (n && n.trim() ? n + `
|
|
176
|
-
` : "") + e.getLines(
|
|
177
|
-
}, je = (e,
|
|
176
|
+
` : "") + e.getLines(o + 1, i, e.tShift[o], !0) + (a && a.trim() ? a : ""), m.map = [o, e.line], m.markup = "$$", !0;
|
|
177
|
+
}, je = (e, o) => {
|
|
178
178
|
const l = (n) => {
|
|
179
|
-
if (
|
|
180
|
-
const
|
|
179
|
+
if (o.katexRef.value) {
|
|
180
|
+
const a = o.katexRef.value.renderToString(n, {
|
|
181
181
|
throwOnError: !1
|
|
182
182
|
});
|
|
183
|
-
return `<span class="${h}-katex-inline" data-processed>${
|
|
183
|
+
return `<span class="${h}-katex-inline" data-processed>${a}</span>`;
|
|
184
184
|
} else
|
|
185
185
|
return `<span class="${h}-katex-inline">${n}</span>`;
|
|
186
|
-
}, t = (n,
|
|
187
|
-
if (
|
|
188
|
-
const i =
|
|
186
|
+
}, t = (n, a) => {
|
|
187
|
+
if (o.katexRef.value) {
|
|
188
|
+
const i = o.katexRef.value.renderToString(n, {
|
|
189
189
|
throwOnError: !1,
|
|
190
190
|
displayMode: !0
|
|
191
191
|
});
|
|
192
|
-
return `<p class="${h}-katex-block" data-line=${
|
|
192
|
+
return `<p class="${h}-katex-block" data-line=${a} data-processed>${i}</p>`;
|
|
193
193
|
} else
|
|
194
|
-
return `<p class="${h}-katex-block" data-line=${
|
|
194
|
+
return `<p class="${h}-katex-block" data-line=${a}>${n}</p>`;
|
|
195
195
|
};
|
|
196
196
|
e.inline.ruler.after("escape", "math_inline", Ne), e.block.ruler.after("blockquote", "math_block", Be, {
|
|
197
197
|
alt: ["paragraph", "reference", "blockquote", "list"]
|
|
198
|
-
}), e.renderer.rules.math_inline = (n,
|
|
198
|
+
}), e.renderer.rules.math_inline = (n, a) => l(n[a].content), e.renderer.rules.math_block = (n, a) => t(n[a].content, n[a].map[0]) + `
|
|
199
199
|
`;
|
|
200
|
-
}, Oe = je, Ue = (e,
|
|
201
|
-
|
|
202
|
-
const l = 3, t =
|
|
200
|
+
}, Oe = je, Ue = (e, o) => {
|
|
201
|
+
o = o || {};
|
|
202
|
+
const l = 3, t = o.marker || "!", n = t.charCodeAt(0), a = t.length;
|
|
203
203
|
let i = "", c = "";
|
|
204
204
|
const d = (r, m, b, y, u) => {
|
|
205
205
|
const p = r[m];
|
|
@@ -218,53 +218,53 @@ const Y = "onSave", ee = "changeCatalogVisible", Ce = "changeFullscreen", G = "p
|
|
|
218
218
|
let u, p, f, k = !1, v = r.bMarks[m] + r.tShift[m], w = r.eMarks[m];
|
|
219
219
|
if (n !== r.src.charCodeAt(v))
|
|
220
220
|
return !1;
|
|
221
|
-
for (u = v + 1; u <= w && t[(u - v) %
|
|
221
|
+
for (u = v + 1; u <= w && t[(u - v) % a] === r.src[u]; u++)
|
|
222
222
|
;
|
|
223
|
-
const C = Math.floor((u - v) /
|
|
223
|
+
const C = Math.floor((u - v) / a);
|
|
224
224
|
if (C !== l)
|
|
225
225
|
return !1;
|
|
226
|
-
u -= (u - v) %
|
|
227
|
-
const
|
|
228
|
-
if (s(
|
|
226
|
+
u -= (u - v) % a;
|
|
227
|
+
const I = r.src.slice(v, u), E = r.src.slice(u, w);
|
|
228
|
+
if (s(E), y)
|
|
229
229
|
return !0;
|
|
230
230
|
for (p = m; p++, !(p >= b || (v = r.bMarks[p] + r.tShift[p], w = r.eMarks[p], v < w && r.sCount[p] < r.blkIndent)); )
|
|
231
231
|
if (n === r.src.charCodeAt(v) && !(r.sCount[p] - r.blkIndent >= 4)) {
|
|
232
|
-
for (u = v + 1; u <= w && t[(u - v) %
|
|
232
|
+
for (u = v + 1; u <= w && t[(u - v) % a] === r.src[u]; u++)
|
|
233
233
|
;
|
|
234
|
-
if (!(Math.floor((u - v) /
|
|
234
|
+
if (!(Math.floor((u - v) / a) < C) && (u -= (u - v) % a, u = r.skipSpaces(u), !(u < w))) {
|
|
235
235
|
k = !0;
|
|
236
236
|
break;
|
|
237
237
|
}
|
|
238
238
|
}
|
|
239
239
|
const N = r.parentType, ae = r.lineMax;
|
|
240
|
-
return r.parentType = "root", r.lineMax = p, f = r.push("admonition_open", "div", 1), f.markup =
|
|
240
|
+
return r.parentType = "root", r.lineMax = p, f = r.push("admonition_open", "div", 1), f.markup = I, f.block = !0, f.info = i, f.map = [m, p], f = r.push("admonition_title_open", "p", 1), f.markup = I + " " + i, f.map = [m, p], f = r.push("inline", "", 0), f.content = c, f.map = [m, r.line - 1], f.children = [], f = r.push("admonition_title_close", "p", -1), f.markup = I + " " + i, r.md.block.tokenize(r, m + 1, p), f = r.push("admonition_close", "div", -1), f.markup = r.src.slice(v, u), f.block = !0, r.parentType = N, r.lineMax = ae, r.line = p + (k ? 1 : 0), !0;
|
|
241
241
|
},
|
|
242
242
|
{
|
|
243
243
|
alt: ["paragraph", "reference", "blockquote", "list"]
|
|
244
244
|
}
|
|
245
245
|
), e.renderer.rules.admonition_open = d, e.renderer.rules.admonition_title_open = d, e.renderer.rules.admonition_title_close = d, e.renderer.rules.admonition_close = d;
|
|
246
|
-
}, Ve = Ue, Ge = (e,
|
|
246
|
+
}, Ve = Ue, Ge = (e, o) => {
|
|
247
247
|
e.renderer.rules.heading_open = (l, t) => {
|
|
248
|
-
const n = l[t],
|
|
249
|
-
return
|
|
250
|
-
text:
|
|
248
|
+
const n = l[t], a = l[t + 1].content, i = n.markup.length;
|
|
249
|
+
return o.headsRef.value.push({
|
|
250
|
+
text: a,
|
|
251
251
|
level: i
|
|
252
252
|
}), n.map && n.level === 0 && (n.attrSet("data-line", String(n.map[0])), n.attrSet(
|
|
253
253
|
"id",
|
|
254
|
-
|
|
255
|
-
)), e.renderer.renderToken(l, t,
|
|
256
|
-
}, e.renderer.rules.heading_close = (l, t, n,
|
|
257
|
-
}, ze = Ge, De = (e,
|
|
254
|
+
o.mdHeadingId(a, i, o.headsRef.value.length)
|
|
255
|
+
)), e.renderer.renderToken(l, t, o);
|
|
256
|
+
}, e.renderer.rules.heading_close = (l, t, n, a, i) => i.renderToken(l, t, n);
|
|
257
|
+
}, ze = Ge, De = (e, o) => {
|
|
258
258
|
const l = e.renderer.rules.fence, t = e.utils.unescapeAll, n = /\[(\w*)(?::([\w ]*))?\]/;
|
|
259
|
-
function
|
|
259
|
+
function a(s) {
|
|
260
260
|
return s.info ? t(s.info).trim() : "";
|
|
261
261
|
}
|
|
262
262
|
function i(s) {
|
|
263
|
-
const r =
|
|
263
|
+
const r = a(s), [m = null, b = ""] = (n.exec(r) || []).slice(1);
|
|
264
264
|
return [m, b];
|
|
265
265
|
}
|
|
266
266
|
function c(s) {
|
|
267
|
-
const r =
|
|
267
|
+
const r = a(s);
|
|
268
268
|
return r ? r.split(/(\s+)/g)[0] : "";
|
|
269
269
|
}
|
|
270
270
|
const d = (s, r, m, b, y) => {
|
|
@@ -273,15 +273,15 @@ const Y = "onSave", ee = "changeCatalogVisible", Ce = "changeFullscreen", G = "p
|
|
|
273
273
|
const [u, p] = i(s[r]);
|
|
274
274
|
if (u === null)
|
|
275
275
|
return l(s, r, m, b, y);
|
|
276
|
-
let f, k, v, w, C = "",
|
|
277
|
-
for (let
|
|
278
|
-
f.info = f.info.replace(n, ""), f.hidden = !0, w =
|
|
279
|
-
`,
|
|
280
|
-
` + l(s,
|
|
276
|
+
let f, k, v, w, C = "", I = "";
|
|
277
|
+
for (let E = r; E < s.length && (f = s[E], [k, v] = i(f), k === u); E++)
|
|
278
|
+
f.info = f.info.replace(n, ""), f.hidden = !0, w = E - r > 0 ? "" : " checked", C += `<li><input type="radio" name="label-group-${o.editorId}-${r}"${w}><label for="group-${o.editorId}-${r}-tab-${E - r}" onclick="this.previousElementSibling.click()">${v || c(f)}</label></li>
|
|
279
|
+
`, I += `<input type="radio" id="group-${o.editorId}-${r}-tab-${E - r}" name="group-${o.editorId}-${r}"${w}>
|
|
280
|
+
` + l(s, E, m, b, y);
|
|
281
281
|
return `<div class="code-tabs">
|
|
282
282
|
<ul>
|
|
283
283
|
` + C + `</ul>
|
|
284
|
-
` +
|
|
284
|
+
` + I + "</div>";
|
|
285
285
|
};
|
|
286
286
|
e.renderer.rules.fence = d;
|
|
287
287
|
}, Ke = De, qe = (e) => {
|
|
@@ -294,19 +294,19 @@ const Y = "onSave", ee = "changeCatalogVisible", Ce = "changeFullscreen", G = "p
|
|
|
294
294
|
"hr",
|
|
295
295
|
"html_block",
|
|
296
296
|
"fence"
|
|
297
|
-
].forEach((
|
|
298
|
-
const l = e.renderer.rules[
|
|
299
|
-
l ? e.renderer.rules[
|
|
297
|
+
].forEach((o) => {
|
|
298
|
+
const l = e.renderer.rules[o];
|
|
299
|
+
l ? e.renderer.rules[o] = (t, n, a, i, c) => {
|
|
300
300
|
let d;
|
|
301
|
-
const s = l(t, n,
|
|
301
|
+
const s = l(t, n, a, i, c);
|
|
302
302
|
return t[n].map && t[n].level === 0 ? (d = t[n].map[0], s.replace(/^(<[^>]*)/, `$1 data-line="${d}"`)) : s;
|
|
303
|
-
} : e.renderer.rules[
|
|
303
|
+
} : e.renderer.rules[o] = (t, n, a, i, c) => {
|
|
304
304
|
let d;
|
|
305
|
-
return t[n].map && t[n].level === 0 && (d = t[n].map[0], t[n].attrSet("data-line", String(d))), c.renderToken(t, n,
|
|
305
|
+
return t[n].map && t[n].level === 0 && (d = t[n].map[0], t[n].attrSet("data-line", String(d))), c.renderToken(t, n, a);
|
|
306
306
|
};
|
|
307
307
|
});
|
|
308
|
-
}, We = (e,
|
|
309
|
-
const { editorConfig: l, markdownItConfig: t, markdownItPlugins: n } =
|
|
308
|
+
}, We = (e, o) => {
|
|
309
|
+
const { editorConfig: l, markdownItConfig: t, markdownItPlugins: n } = P, a = T("editorId"), i = T("showCodeRowNumber"), c = T("theme"), d = L([]), s = Fe(e), r = Re(e), { reRenderRef: m, replaceMermaid: b } = Me(e), y = be({
|
|
310
310
|
html: !0,
|
|
311
311
|
breaks: !0
|
|
312
312
|
});
|
|
@@ -340,7 +340,7 @@ const Y = "onSave", ee = "changeCatalogVisible", Ce = "changeFullscreen", G = "p
|
|
|
340
340
|
{
|
|
341
341
|
type: "codeTabs",
|
|
342
342
|
plugin: Ke,
|
|
343
|
-
options: { editorId:
|
|
343
|
+
options: { editorId: a }
|
|
344
344
|
}
|
|
345
345
|
];
|
|
346
346
|
e.noMermaid || u.push({
|
|
@@ -351,30 +351,30 @@ const Y = "onSave", ee = "changeCatalogVisible", Ce = "changeFullscreen", G = "p
|
|
|
351
351
|
y.use(w.plugin, w.options);
|
|
352
352
|
}), y.set({
|
|
353
353
|
highlight: (w, C) => {
|
|
354
|
-
let
|
|
355
|
-
!e.noHighlight && s.value ? s.value.getLanguage(C) ?
|
|
354
|
+
let I;
|
|
355
|
+
!e.noHighlight && s.value ? s.value.getLanguage(C) ? I = s.value.highlight(w, {
|
|
356
356
|
language: C,
|
|
357
357
|
ignoreIllegals: !0
|
|
358
|
-
}).value :
|
|
359
|
-
const
|
|
360
|
-
return `<pre><code class="language-${C}" language=${C}>${
|
|
358
|
+
}).value : I = s.value.highlightAuto(w).value : I = y.utils.escapeHtml(w);
|
|
359
|
+
const E = i ? he(I.trim()) : `<span class="code-block">${I.trim()}</span>`;
|
|
360
|
+
return `<pre><code class="language-${C}" language=${C}>${E}</code></pre>`;
|
|
361
361
|
}
|
|
362
362
|
}), qe(y);
|
|
363
363
|
const p = L(e.sanitize(y.render(e.modelValue))), f = () => {
|
|
364
|
-
g.emit(
|
|
364
|
+
g.emit(a, "buildFinished", p.value), e.onHtmlChanged(p.value), e.onGetCatalog(d.value), g.emit(a, "catalogChanged", d.value), b();
|
|
365
365
|
};
|
|
366
|
-
|
|
366
|
+
S(f);
|
|
367
367
|
const k = Q(
|
|
368
368
|
async () => {
|
|
369
369
|
d.value = [], p.value = e.sanitize(y.render(e.modelValue)), f();
|
|
370
370
|
},
|
|
371
|
-
(l == null ? void 0 : l.renderDelay) !== void 0 ? l == null ? void 0 : l.renderDelay :
|
|
371
|
+
(l == null ? void 0 : l.renderDelay) !== void 0 ? l == null ? void 0 : l.renderDelay : o ? 0 : 500
|
|
372
372
|
), v = M(() => (e.noKatex || r.value) && (e.noHighlight || s.value));
|
|
373
|
-
return $([Z(e, "modelValue"), v, m], k),
|
|
374
|
-
g.on(
|
|
373
|
+
return $([Z(e, "modelValue"), v, m], k), S(() => {
|
|
374
|
+
g.on(a, {
|
|
375
375
|
name: "pushCatalog",
|
|
376
376
|
callback() {
|
|
377
|
-
g.emit(
|
|
377
|
+
g.emit(a, "catalogChanged", d.value);
|
|
378
378
|
}
|
|
379
379
|
});
|
|
380
380
|
}), { html: p };
|
|
@@ -430,20 +430,20 @@ const Y = "onSave", ee = "changeCatalogVisible", Ce = "changeFullscreen", G = "p
|
|
|
430
430
|
name: "ContentPreview",
|
|
431
431
|
props: Je,
|
|
432
432
|
setup(e) {
|
|
433
|
-
const
|
|
433
|
+
const o = T("editorId"), l = T("previewTheme"), t = T("showCodeRowNumber"), {
|
|
434
434
|
html: n
|
|
435
435
|
} = Ze(e, e.previewOnly);
|
|
436
|
-
return
|
|
437
|
-
id: `${
|
|
436
|
+
return Te(e, n), Ee(e, n), () => H(le, null, [H("div", {
|
|
437
|
+
id: `${o}-preview-wrapper`,
|
|
438
438
|
class: `${h}-preview-wrapper`,
|
|
439
439
|
"data-show": e.setting.preview,
|
|
440
440
|
key: "content-preview-wrapper"
|
|
441
441
|
}, [H("article", {
|
|
442
|
-
id: `${
|
|
442
|
+
id: `${o}-preview`,
|
|
443
443
|
class: [`${h}-preview`, `${l == null ? void 0 : l.value}-theme`, t && `${h}-scrn`],
|
|
444
444
|
innerHTML: n.value
|
|
445
445
|
}, null)]), !e.previewOnly && H("div", {
|
|
446
|
-
id: `${
|
|
446
|
+
id: `${o}-html-wrapper`,
|
|
447
447
|
class: `${h}-preview-wrapper`,
|
|
448
448
|
"data-show": e.setting.htmlPreview,
|
|
449
449
|
key: "html-preview-wrapper"
|
|
@@ -451,7 +451,7 @@ const Y = "onSave", ee = "changeCatalogVisible", Ce = "changeFullscreen", G = "p
|
|
|
451
451
|
class: `${h}-html`
|
|
452
452
|
}, [n.value])])]);
|
|
453
453
|
}
|
|
454
|
-
}), ut = (e,
|
|
454
|
+
}), ut = (e, o) => {
|
|
455
455
|
const { editorId: l } = e, t = X({
|
|
456
456
|
// 是否已编译成html
|
|
457
457
|
buildFinished: !1,
|
|
@@ -463,7 +463,7 @@ const Y = "onSave", ee = "changeCatalogVisible", Ce = "changeFullscreen", G = "p
|
|
|
463
463
|
() => {
|
|
464
464
|
t.buildFinished = !1;
|
|
465
465
|
}
|
|
466
|
-
),
|
|
466
|
+
), S(() => {
|
|
467
467
|
g.on(l, {
|
|
468
468
|
name: "buildFinished",
|
|
469
469
|
callback(n) {
|
|
@@ -472,12 +472,12 @@ const Y = "onSave", ee = "changeCatalogVisible", Ce = "changeFullscreen", G = "p
|
|
|
472
472
|
}), g.on(l, {
|
|
473
473
|
name: Y,
|
|
474
474
|
callback() {
|
|
475
|
-
const n = new Promise((
|
|
475
|
+
const n = new Promise((a) => {
|
|
476
476
|
if (t.buildFinished)
|
|
477
|
-
|
|
477
|
+
a(t.html);
|
|
478
478
|
else {
|
|
479
479
|
const i = (c) => {
|
|
480
|
-
|
|
480
|
+
a(c), g.remove(l, "buildFinished", i);
|
|
481
481
|
};
|
|
482
482
|
g.on(l, {
|
|
483
483
|
name: "buildFinished",
|
|
@@ -485,14 +485,14 @@ const Y = "onSave", ee = "changeCatalogVisible", Ce = "changeFullscreen", G = "p
|
|
|
485
485
|
});
|
|
486
486
|
}
|
|
487
487
|
});
|
|
488
|
-
e.onSave ? e.onSave(e.modelValue, n) :
|
|
488
|
+
e.onSave ? e.onSave(e.modelValue, n) : o.emit("onSave", e.modelValue, n);
|
|
489
489
|
}
|
|
490
490
|
});
|
|
491
491
|
});
|
|
492
492
|
}, te = (e) => {
|
|
493
|
-
var n,
|
|
494
|
-
const { editorId:
|
|
495
|
-
F("editorId",
|
|
493
|
+
var n, a;
|
|
494
|
+
const { editorId: o } = e, l = (a = (n = P) == null ? void 0 : n.editorExtensions) == null ? void 0 : a.highlight;
|
|
495
|
+
F("editorId", o), F(
|
|
496
496
|
"theme",
|
|
497
497
|
M(() => e.theme)
|
|
498
498
|
), F(
|
|
@@ -512,7 +512,7 @@ const Y = "onSave", ee = "changeCatalogVisible", Ce = "changeFullscreen", G = "p
|
|
|
512
512
|
var c, d;
|
|
513
513
|
const i = {
|
|
514
514
|
...O,
|
|
515
|
-
...(d = (c =
|
|
515
|
+
...(d = (c = P) == null ? void 0 : c.editorConfig) == null ? void 0 : d.languageUserDefined
|
|
516
516
|
};
|
|
517
517
|
return i[e.language] ? i[e.language] : O["zh-CN"];
|
|
518
518
|
});
|
|
@@ -523,24 +523,34 @@ const Y = "onSave", ee = "changeCatalogVisible", Ce = "changeFullscreen", G = "p
|
|
|
523
523
|
}, mt = (e) => {
|
|
524
524
|
te(e), F("tabWidth", e.tabWidth);
|
|
525
525
|
}, ne = (e) => {
|
|
526
|
-
|
|
526
|
+
S(() => {
|
|
527
527
|
var l;
|
|
528
|
-
const
|
|
529
|
-
|
|
528
|
+
const o = document.createElement("script");
|
|
529
|
+
o.src = ((l = P.editorExtensions) == null ? void 0 : l.iconfont) || de, o.id = `${h}-icon`, e.noIconfont || _(o);
|
|
530
530
|
});
|
|
531
531
|
}, ft = (e) => {
|
|
532
532
|
var c, d, s, r, m, b;
|
|
533
|
-
const { noPrettier:
|
|
534
|
-
|
|
533
|
+
const { noPrettier: o, noUploadImg: l } = e, { editorExtensions: t } = P, n = o || !!((d = (c = P.editorExtensions) == null ? void 0 : c.prettier) != null && d.prettierInstance), a = o || !!((r = (s = P.editorExtensions) == null ? void 0 : s.prettier) != null && r.parserMarkdownInstance), i = l || !!((b = (m = P.editorExtensions) == null ? void 0 : m.cropper) != null && b.instance);
|
|
534
|
+
S(() => {
|
|
535
535
|
var k, v, w, C;
|
|
536
536
|
const y = document.createElement("script"), u = document.createElement("script");
|
|
537
537
|
y.src = ((k = t == null ? void 0 : t.prettier) == null ? void 0 : k.standaloneJs) || U.main, y.id = `${h}-prettier`, u.src = ((v = t == null ? void 0 : t.prettier) == null ? void 0 : v.parserMarkdownJs) || U.markdown, u.id = `${h}-prettierMD`;
|
|
538
538
|
const p = document.createElement("link");
|
|
539
539
|
p.rel = "stylesheet", p.href = ((w = t == null ? void 0 : t.cropper) == null ? void 0 : w.css) || V.css, p.id = `${h}-cropperCss`;
|
|
540
540
|
const f = document.createElement("script");
|
|
541
|
-
f.src = ((C = t == null ? void 0 : t.cropper) == null ? void 0 : C.js) || V.js, f.id = `${h}-cropper`, i || (_(p), _(f)), n || _(y),
|
|
541
|
+
f.src = ((C = t == null ? void 0 : t.cropper) == null ? void 0 : C.js) || V.js, f.id = `${h}-cropper`, i || (_(p), _(f)), n || _(y), a || _(u);
|
|
542
542
|
}), ne(e);
|
|
543
|
-
}, pt = (e,
|
|
543
|
+
}, pt = (e, o) => {
|
|
544
|
+
const { editorId: l } = e;
|
|
545
|
+
S(() => {
|
|
546
|
+
g.on(l, {
|
|
547
|
+
name: "errorCatcher",
|
|
548
|
+
callback: (t) => {
|
|
549
|
+
e.onError instanceof Function ? e.onError(t) : o.emit("onError", t);
|
|
550
|
+
}
|
|
551
|
+
});
|
|
552
|
+
});
|
|
553
|
+
}, ht = (e, o) => {
|
|
544
554
|
const { editorId: l } = e, t = X({
|
|
545
555
|
pageFullscreen: e.pageFullscreen,
|
|
546
556
|
fullscreen: !1,
|
|
@@ -549,11 +559,11 @@ const Y = "onSave", ee = "changeCatalogVisible", Ce = "changeFullscreen", G = "p
|
|
|
549
559
|
}), n = (c, d) => {
|
|
550
560
|
t[c] = d === void 0 ? !t[c] : d, c === "preview" && t.preview ? t.htmlPreview = !1 : c === "htmlPreview" && t.htmlPreview && (t.preview = !1);
|
|
551
561
|
};
|
|
552
|
-
let
|
|
562
|
+
let a = "";
|
|
553
563
|
const i = () => {
|
|
554
|
-
t.pageFullscreen || t.fullscreen ? document.body.style.overflow = "hidden" : document.body.style.overflow =
|
|
564
|
+
t.pageFullscreen || t.fullscreen ? document.body.style.overflow = "hidden" : document.body.style.overflow = a;
|
|
555
565
|
};
|
|
556
|
-
return $(() => [t.pageFullscreen, t.fullscreen], i),
|
|
566
|
+
return $(() => [t.pageFullscreen, t.fullscreen], i), S(() => {
|
|
557
567
|
g.on(l, {
|
|
558
568
|
name: "uploadImage",
|
|
559
569
|
callback(c, d) {
|
|
@@ -563,50 +573,50 @@ const Y = "onSave", ee = "changeCatalogVisible", Ce = "changeFullscreen", G = "p
|
|
|
563
573
|
urls: r
|
|
564
574
|
}), d && d();
|
|
565
575
|
};
|
|
566
|
-
e.onUploadImg ? e.onUploadImg(c, s) :
|
|
576
|
+
e.onUploadImg ? e.onUploadImg(c, s) : o.emit("onUploadImg", c, s);
|
|
567
577
|
}
|
|
568
|
-
}),
|
|
578
|
+
}), a = document.body.style.overflow, i();
|
|
569
579
|
}), [t, n];
|
|
570
|
-
},
|
|
571
|
-
const { editorId:
|
|
572
|
-
return
|
|
573
|
-
g.on(
|
|
580
|
+
}, gt = (e) => {
|
|
581
|
+
const { editorId: o } = e, l = L(!1);
|
|
582
|
+
return S(() => {
|
|
583
|
+
g.on(o, {
|
|
574
584
|
name: ee,
|
|
575
585
|
callback: (n) => {
|
|
576
586
|
n === void 0 ? l.value = !l.value : l.value = n;
|
|
577
587
|
}
|
|
578
588
|
});
|
|
579
589
|
}), M(() => !e.toolbarsExclude.includes("catalog") && e.toolbars.includes("catalog") && l.value);
|
|
580
|
-
},
|
|
581
|
-
const { editorId:
|
|
590
|
+
}, vt = (e, o, l, t, n) => {
|
|
591
|
+
const { editorId: a } = e;
|
|
582
592
|
$(
|
|
583
593
|
() => t.pageFullscreen,
|
|
584
594
|
(c) => {
|
|
585
|
-
g.emit(
|
|
595
|
+
g.emit(a, G, c);
|
|
586
596
|
}
|
|
587
597
|
), $(
|
|
588
598
|
() => t.fullscreen,
|
|
589
599
|
(c) => {
|
|
590
|
-
g.emit(
|
|
600
|
+
g.emit(a, z, c);
|
|
591
601
|
}
|
|
592
602
|
), $(
|
|
593
603
|
() => t.preview,
|
|
594
604
|
(c) => {
|
|
595
|
-
g.emit(
|
|
605
|
+
g.emit(a, D, c);
|
|
596
606
|
}
|
|
597
607
|
), $(
|
|
598
608
|
() => t.htmlPreview,
|
|
599
609
|
(c) => {
|
|
600
|
-
g.emit(
|
|
610
|
+
g.emit(a, K, c);
|
|
601
611
|
}
|
|
602
612
|
), $(l, (c) => {
|
|
603
|
-
g.emit(
|
|
613
|
+
g.emit(a, q, c);
|
|
604
614
|
});
|
|
605
615
|
const i = {
|
|
606
616
|
on(c, d) {
|
|
607
617
|
switch (c) {
|
|
608
618
|
case "pageFullscreen": {
|
|
609
|
-
g.on(
|
|
619
|
+
g.on(a, {
|
|
610
620
|
name: G,
|
|
611
621
|
callback(s) {
|
|
612
622
|
d(s);
|
|
@@ -615,7 +625,7 @@ const Y = "onSave", ee = "changeCatalogVisible", Ce = "changeFullscreen", G = "p
|
|
|
615
625
|
break;
|
|
616
626
|
}
|
|
617
627
|
case "fullscreen": {
|
|
618
|
-
g.on(
|
|
628
|
+
g.on(a, {
|
|
619
629
|
name: z,
|
|
620
630
|
callback(s) {
|
|
621
631
|
d(s);
|
|
@@ -624,7 +634,7 @@ const Y = "onSave", ee = "changeCatalogVisible", Ce = "changeFullscreen", G = "p
|
|
|
624
634
|
break;
|
|
625
635
|
}
|
|
626
636
|
case "preview": {
|
|
627
|
-
g.on(
|
|
637
|
+
g.on(a, {
|
|
628
638
|
name: D,
|
|
629
639
|
callback(s) {
|
|
630
640
|
d(s);
|
|
@@ -633,7 +643,7 @@ const Y = "onSave", ee = "changeCatalogVisible", Ce = "changeFullscreen", G = "p
|
|
|
633
643
|
break;
|
|
634
644
|
}
|
|
635
645
|
case "htmlPreview": {
|
|
636
|
-
g.on(
|
|
646
|
+
g.on(a, {
|
|
637
647
|
name: K,
|
|
638
648
|
callback(s) {
|
|
639
649
|
d(s);
|
|
@@ -642,7 +652,7 @@ const Y = "onSave", ee = "changeCatalogVisible", Ce = "changeFullscreen", G = "p
|
|
|
642
652
|
break;
|
|
643
653
|
}
|
|
644
654
|
case "catalog": {
|
|
645
|
-
g.on(
|
|
655
|
+
g.on(a, {
|
|
646
656
|
name: q,
|
|
647
657
|
callback(s) {
|
|
648
658
|
d(s);
|
|
@@ -656,7 +666,7 @@ const Y = "onSave", ee = "changeCatalogVisible", Ce = "changeFullscreen", G = "p
|
|
|
656
666
|
n("pageFullscreen", c);
|
|
657
667
|
},
|
|
658
668
|
toggleFullscreen(c) {
|
|
659
|
-
g.emit(
|
|
669
|
+
g.emit(a, Ce, c);
|
|
660
670
|
},
|
|
661
671
|
togglePreview(c) {
|
|
662
672
|
n("preview", c);
|
|
@@ -665,19 +675,19 @@ const Y = "onSave", ee = "changeCatalogVisible", Ce = "changeFullscreen", G = "p
|
|
|
665
675
|
n("htmlPreview", c);
|
|
666
676
|
},
|
|
667
677
|
toggleCatalog(c) {
|
|
668
|
-
g.emit(
|
|
678
|
+
g.emit(a, ee, c);
|
|
669
679
|
},
|
|
670
680
|
triggerSave() {
|
|
671
|
-
g.emit(
|
|
681
|
+
g.emit(a, Y);
|
|
672
682
|
},
|
|
673
683
|
insert(c) {
|
|
674
|
-
g.emit(
|
|
684
|
+
g.emit(a, "replace", "universal", { generate: c });
|
|
675
685
|
},
|
|
676
686
|
focus(c) {
|
|
677
|
-
g.emit(
|
|
687
|
+
g.emit(a, Se, c);
|
|
678
688
|
}
|
|
679
689
|
};
|
|
680
|
-
|
|
690
|
+
o.expose(i);
|
|
681
691
|
}, Qe = (e) => e, re = {
|
|
682
692
|
/**
|
|
683
693
|
* markdown content.
|
|
@@ -848,7 +858,7 @@ const Y = "onSave", ee = "changeCatalogVisible", Ce = "changeFullscreen", G = "p
|
|
|
848
858
|
type: Boolean,
|
|
849
859
|
default: !1
|
|
850
860
|
}
|
|
851
|
-
},
|
|
861
|
+
}, yt = {
|
|
852
862
|
...re,
|
|
853
863
|
/**
|
|
854
864
|
* input回调事件
|
|
@@ -1081,7 +1091,7 @@ const Y = "onSave", ee = "changeCatalogVisible", Ce = "changeFullscreen", G = "p
|
|
|
1081
1091
|
onInput: {
|
|
1082
1092
|
type: Function
|
|
1083
1093
|
}
|
|
1084
|
-
}, oe = ["onHtmlChanged", "onGetCatalog"],
|
|
1094
|
+
}, oe = ["onHtmlChanged", "onGetCatalog"], bt = [
|
|
1085
1095
|
...oe,
|
|
1086
1096
|
"onChange",
|
|
1087
1097
|
"onSave",
|
|
@@ -1095,12 +1105,12 @@ const Y = "onSave", ee = "changeCatalogVisible", Ce = "changeFullscreen", G = "p
|
|
|
1095
1105
|
name: "MdPreview",
|
|
1096
1106
|
props: re,
|
|
1097
1107
|
emits: oe,
|
|
1098
|
-
setup(e,
|
|
1108
|
+
setup(e, o) {
|
|
1099
1109
|
const {
|
|
1100
1110
|
editorId: l,
|
|
1101
1111
|
noKatex: t,
|
|
1102
1112
|
noMermaid: n,
|
|
1103
|
-
noHighlight:
|
|
1113
|
+
noHighlight: a
|
|
1104
1114
|
} = e;
|
|
1105
1115
|
return te(e), ne(e), ie(() => {
|
|
1106
1116
|
g.clear(l);
|
|
@@ -1111,17 +1121,17 @@ const Y = "onSave", ee = "changeCatalogVisible", Ce = "changeFullscreen", G = "p
|
|
|
1111
1121
|
}, [H(Xe, {
|
|
1112
1122
|
modelValue: e.modelValue,
|
|
1113
1123
|
onHtmlChanged: (i) => {
|
|
1114
|
-
e.onHtmlChanged ? e.onHtmlChanged(i) :
|
|
1124
|
+
e.onHtmlChanged ? e.onHtmlChanged(i) : o.emit("onHtmlChanged", i);
|
|
1115
1125
|
},
|
|
1116
1126
|
onGetCatalog: (i) => {
|
|
1117
|
-
e.onGetCatalog ? e.onGetCatalog(i) :
|
|
1127
|
+
e.onGetCatalog ? e.onGetCatalog(i) : o.emit("onGetCatalog", i);
|
|
1118
1128
|
},
|
|
1119
1129
|
mdHeadingId: e.mdHeadingId,
|
|
1120
1130
|
noMermaid: n,
|
|
1121
1131
|
sanitize: e.sanitize,
|
|
1122
1132
|
noKatex: t,
|
|
1123
1133
|
formatCopiedText: e.formatCopiedText,
|
|
1124
|
-
noHighlight:
|
|
1134
|
+
noHighlight: a,
|
|
1125
1135
|
previewOnly: !0
|
|
1126
1136
|
}, null)]);
|
|
1127
1137
|
}
|
|
@@ -1134,12 +1144,13 @@ export {
|
|
|
1134
1144
|
Se as T,
|
|
1135
1145
|
ee as a,
|
|
1136
1146
|
Xe as b,
|
|
1137
|
-
|
|
1147
|
+
bt as c,
|
|
1138
1148
|
mt as d,
|
|
1139
|
-
|
|
1149
|
+
yt as e,
|
|
1140
1150
|
ft as f,
|
|
1141
1151
|
pt as g,
|
|
1142
1152
|
ht as h,
|
|
1143
1153
|
gt as i,
|
|
1154
|
+
vt as j,
|
|
1144
1155
|
ut as u
|
|
1145
1156
|
};
|