md-editor-v3 4.0.1 → 4.0.3-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/lib/cjs/chunks/config.cjs +1 -1
- package/lib/cjs/chunks/index.cjs +4 -4
- package/lib/es/chunks/config.mjs +1 -1
- package/lib/es/chunks/index.mjs +197 -188
- package/lib/umd/index.js +2 -2
- package/package.json +1 -1
package/lib/es/chunks/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { inject as I, onMounted as C, watch as $, toRef as W, nextTick as A, shallowRef as R, ref as L, computed as M, defineComponent as Z, createVNode as H, Fragment as le, reactive as J, provide as F, onBeforeUnmount as ie } from "vue";
|
|
2
|
-
import { p, a as S, m as ce, k as
|
|
2
|
+
import { p as g, a as S, m as ce, k as N, e as B, h as se, f as j, i as ue, g as O, j as U, l as de, b as me, d as fe } from "./config.mjs";
|
|
3
3
|
import { b } from "./event-bus.mjs";
|
|
4
|
-
import { a as
|
|
4
|
+
import { a as P, u as he } from "./dom.mjs";
|
|
5
5
|
import pe from "medium-zoom";
|
|
6
6
|
import { d as X, u as ge, a as ve } from "./index4.mjs";
|
|
7
7
|
import be from "copy-to-clipboard";
|
|
@@ -17,53 +17,53 @@ const Q = "onSave", Y = "changeCatalogVisible", Ce = "changeFullscreen", V = "pa
|
|
|
17
17
|
});
|
|
18
18
|
});
|
|
19
19
|
C(t), $([a, W(e.setting, "preview")], t);
|
|
20
|
-
}, Te = Ie,
|
|
20
|
+
}, Te = Ie, Pe = (e, a) => {
|
|
21
21
|
const l = I("editorId"), t = I("usedLanguageText"), n = () => {
|
|
22
|
-
document.querySelectorAll(`#${l}-preview pre`).forEach((
|
|
23
|
-
var
|
|
24
|
-
let
|
|
25
|
-
(
|
|
22
|
+
document.querySelectorAll(`#${l}-preview pre`).forEach((i) => {
|
|
23
|
+
var d, f;
|
|
24
|
+
let u = -1;
|
|
25
|
+
(d = i.querySelector(".copy-button")) == null || d.remove();
|
|
26
26
|
const s = ((f = t.value.copyCode) == null ? void 0 : f.text) || "复制代码", r = document.createElement("span");
|
|
27
|
-
r.setAttribute("class", "copy-button"), r.dataset.tips = s, r.innerHTML = `<svg class="${
|
|
27
|
+
r.setAttribute("class", "copy-button"), r.dataset.tips = s, r.innerHTML = `<svg class="${g}-icon" aria-hidden="true"><use xlink:href="#${g}-icon-copy"></use></svg>`, r.addEventListener("click", () => {
|
|
28
28
|
var k, v;
|
|
29
|
-
clearTimeout(
|
|
30
|
-
const w =
|
|
31
|
-
r.dataset.tips = m ?
|
|
29
|
+
clearTimeout(u);
|
|
30
|
+
const w = i.querySelector("code").innerText, m = be(e.formatCopiedText(w)), p = ((k = t.value.copyCode) == null ? void 0 : k.successTips) || "已复制!", h = ((v = t.value.copyCode) == null ? void 0 : v.failTips) || "已复制!";
|
|
31
|
+
r.dataset.tips = m ? p : h, u = window.setTimeout(() => {
|
|
32
32
|
r.dataset.tips = s;
|
|
33
33
|
}, 1500);
|
|
34
|
-
}),
|
|
34
|
+
}), i.appendChild(r);
|
|
35
35
|
});
|
|
36
36
|
}, o = () => {
|
|
37
37
|
A(n);
|
|
38
|
-
},
|
|
39
|
-
|
|
38
|
+
}, c = (i) => {
|
|
39
|
+
i && A(n);
|
|
40
40
|
};
|
|
41
|
-
$(() => a.value, o), $(() => e.setting.preview,
|
|
42
|
-
},
|
|
41
|
+
$(() => a.value, o), $(() => e.setting.preview, c), $(() => e.setting.htmlPreview, c), $(() => t.value, n), C(n);
|
|
42
|
+
}, Ee = Pe, _e = (e) => {
|
|
43
43
|
var o;
|
|
44
44
|
const a = (o = S.editorExtensions) == null ? void 0 : o.highlight, l = a == null ? void 0 : a.instance, t = I("highlight"), n = R(l);
|
|
45
45
|
return C(() => {
|
|
46
46
|
if (!e.noHighlight && !n.value) {
|
|
47
|
-
const
|
|
48
|
-
|
|
47
|
+
const c = document.createElement("script");
|
|
48
|
+
c.src = t.value.js, c.onload = () => {
|
|
49
49
|
n.value = window.hljs;
|
|
50
|
-
},
|
|
51
|
-
const
|
|
52
|
-
|
|
50
|
+
}, c.id = `${g}-hljs`, P(c, "hljs");
|
|
51
|
+
const i = document.createElement("link");
|
|
52
|
+
i.rel = "stylesheet", i.href = t.value.css, i.id = `${g}-hlCss`, P(i);
|
|
53
53
|
}
|
|
54
54
|
}), $(
|
|
55
55
|
() => t.value.css,
|
|
56
|
-
(
|
|
57
|
-
he(`${
|
|
56
|
+
(c) => {
|
|
57
|
+
he(`${g}-hlCss`, "href", c);
|
|
58
58
|
}
|
|
59
59
|
), n;
|
|
60
60
|
}, Fe = _e, He = (e) => {
|
|
61
|
-
const a = I("theme"), { editorExtensions: l } = S, t = l == null ? void 0 : l.mermaid, n = R(t == null ? void 0 : t.instance), o = R(!1),
|
|
61
|
+
const a = I("theme"), { editorExtensions: l } = S, t = l == null ? void 0 : l.mermaid, n = R(t == null ? void 0 : t.instance), o = R(!1), c = new $e({
|
|
62
62
|
max: 1e3,
|
|
63
63
|
// 缓存10分钟
|
|
64
64
|
ttl: 6e5
|
|
65
|
-
}),
|
|
66
|
-
const s =
|
|
65
|
+
}), i = () => {
|
|
66
|
+
const s = n.value;
|
|
67
67
|
!e.noMermaid && s && (s.initialize({
|
|
68
68
|
startOnLoad: !1,
|
|
69
69
|
theme: a.value === "dark" ? "dark" : "default"
|
|
@@ -72,29 +72,38 @@ const Q = "onSave", Y = "changeCatalogVisible", Ce = "changeFullscreen", V = "pa
|
|
|
72
72
|
return $(
|
|
73
73
|
() => a.value,
|
|
74
74
|
() => {
|
|
75
|
-
|
|
75
|
+
c.clear(), i();
|
|
76
76
|
}
|
|
77
77
|
), C(() => {
|
|
78
78
|
if (!e.noMermaid && !(t != null && t.instance)) {
|
|
79
|
-
const s =
|
|
80
|
-
s
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
79
|
+
const s = (t == null ? void 0 : t.js) || ce;
|
|
80
|
+
if (/\.mjs/.test(s))
|
|
81
|
+
import(
|
|
82
|
+
/* @vite-ignore */
|
|
83
|
+
/* webpackIgnore: true */
|
|
84
|
+
s
|
|
85
|
+
).then((r) => {
|
|
86
|
+
n.value = r.default, i();
|
|
87
|
+
});
|
|
88
|
+
else {
|
|
89
|
+
const r = document.createElement("script");
|
|
90
|
+
r.id = `${g}-mermaid`, r.src = s, r.onload = () => {
|
|
91
|
+
n.value = window.mermaid, i();
|
|
92
|
+
}, P(r, "mermaid");
|
|
93
|
+
}
|
|
85
94
|
}
|
|
86
95
|
}), { mermaidRef: n, reRenderRef: o, replaceMermaid: () => {
|
|
87
96
|
A(() => {
|
|
88
97
|
!e.noMermaid && n.value && document.querySelectorAll(
|
|
89
|
-
`div.${
|
|
98
|
+
`div.${g}-mermaid`
|
|
90
99
|
).forEach(async (r) => {
|
|
91
|
-
let
|
|
92
|
-
if (!
|
|
93
|
-
const w = ge(),
|
|
94
|
-
|
|
100
|
+
let d = c.get(r.innerText);
|
|
101
|
+
if (!d) {
|
|
102
|
+
const w = ge(), p = await (n.value.renderAsync || n.value.render)(w, r.innerText);
|
|
103
|
+
d = typeof p == "string" ? p : p.svg, c.set(r.innerText, d);
|
|
95
104
|
}
|
|
96
105
|
const f = document.createElement("p");
|
|
97
|
-
f.className = `${
|
|
106
|
+
f.className = `${g}-mermaid`, f.setAttribute("data-processed", ""), f.innerHTML = d, r.dataset.line !== void 0 && (f.dataset.line = r.dataset.line), r.replaceWith(f);
|
|
98
107
|
});
|
|
99
108
|
});
|
|
100
109
|
} };
|
|
@@ -104,99 +113,99 @@ const Q = "onSave", Y = "changeCatalogVisible", Ce = "changeFullscreen", V = "pa
|
|
|
104
113
|
return C(() => {
|
|
105
114
|
if (!e.noKatex && !t.value) {
|
|
106
115
|
const o = document.createElement("script");
|
|
107
|
-
o.src = (a == null ? void 0 : a.js) ||
|
|
116
|
+
o.src = (a == null ? void 0 : a.js) || N.js, o.onload = () => {
|
|
108
117
|
t.value = window.katex;
|
|
109
|
-
}, o.id = `${
|
|
110
|
-
const
|
|
111
|
-
|
|
118
|
+
}, o.id = `${g}-katex`;
|
|
119
|
+
const c = document.createElement("link");
|
|
120
|
+
c.rel = "stylesheet", c.href = (a == null ? void 0 : a.css) || N.css, c.id = `${g}-katexCss`, P(o, "katex"), P(c);
|
|
112
121
|
}
|
|
113
122
|
}), t;
|
|
114
123
|
}, xe = Re, Ae = (e, a) => {
|
|
115
124
|
const l = e.renderer.rules.fence.bind(e.renderer.rules);
|
|
116
|
-
e.renderer.rules.fence = (t, n, o,
|
|
117
|
-
const
|
|
118
|
-
if (
|
|
125
|
+
e.renderer.rules.fence = (t, n, o, c, i) => {
|
|
126
|
+
const u = t[n], s = u.content.trim();
|
|
127
|
+
if (u.info === "mermaid") {
|
|
119
128
|
let r;
|
|
120
|
-
return t[n].map && t[n].level === 0 && (r = t[n].map[0], t[n].attrSet("data-line", String(r))), `<div class="${
|
|
129
|
+
return t[n].map && t[n].level === 0 && (r = t[n].map[0], t[n].attrSet("data-line", String(r))), `<div class="${g}-mermaid" ${r !== void 0 ? "data-line=" + r : ""} data-mermaid-theme=${a.themeRef.value}>${s}</div>`;
|
|
121
130
|
}
|
|
122
|
-
return l(t, n, o,
|
|
131
|
+
return l(t, n, o, c, i);
|
|
123
132
|
};
|
|
124
133
|
}, Le = Ae, q = (e, a) => {
|
|
125
134
|
let l = !0, t = !0;
|
|
126
|
-
const n = e.posMax, o = a > 0 ? e.src.charCodeAt(a - 1) : -1,
|
|
127
|
-
return (o === 32 || o === 9 ||
|
|
135
|
+
const n = e.posMax, o = a > 0 ? e.src.charCodeAt(a - 1) : -1, c = a + 1 <= n ? e.src.charCodeAt(a + 1) : -1;
|
|
136
|
+
return (o === 32 || o === 9 || c >= 48 && c <= 57) && (t = !1), (c === 32 || c === 9) && (l = !1), {
|
|
128
137
|
can_open: l,
|
|
129
138
|
can_close: t
|
|
130
139
|
};
|
|
131
|
-
},
|
|
140
|
+
}, Ne = (e, a) => {
|
|
132
141
|
let l, t, n, o;
|
|
133
142
|
if (e.src[e.pos] !== "$")
|
|
134
143
|
return !1;
|
|
135
144
|
if (n = q(e, e.pos), !n.can_open)
|
|
136
145
|
return a || (e.pending += "$"), e.pos += 1, !0;
|
|
137
|
-
const
|
|
138
|
-
for (l =
|
|
146
|
+
const c = e.pos + 1;
|
|
147
|
+
for (l = c; (l = e.src.indexOf("$", l)) !== -1; ) {
|
|
139
148
|
for (o = l - 1; e.src[o] === "\\"; )
|
|
140
149
|
o -= 1;
|
|
141
150
|
if ((l - o) % 2 == 1)
|
|
142
151
|
break;
|
|
143
152
|
l += 1;
|
|
144
153
|
}
|
|
145
|
-
return l === -1 ? (a || (e.pending += "$"), e.pos =
|
|
146
|
-
},
|
|
147
|
-
let n, o,
|
|
154
|
+
return l === -1 ? (a || (e.pending += "$"), e.pos = c, !0) : l - c === 0 ? (a || (e.pending += "$$"), e.pos = c + 1, !0) : (n = q(e, l), n.can_close ? (a || (t = e.push("math_inline", "math", 0), t.markup = "$", t.content = e.src.slice(c, l)), e.pos = l + 1, !0) : (a || (e.pending += "$"), e.pos = c, !0));
|
|
155
|
+
}, Be = (e, a, l, t) => {
|
|
156
|
+
let n, o, c, i, u = !1, s = e.bMarks[a] + e.tShift[a], r = e.eMarks[a];
|
|
148
157
|
if (s + 2 > r || e.src.slice(s, s + 2) !== "$$")
|
|
149
158
|
return !1;
|
|
150
159
|
if (s += 2, n = e.src.slice(s, r), t)
|
|
151
160
|
return !0;
|
|
152
|
-
for (n.trim().slice(-2) === "$$" && (n = n.trim().slice(0, -2),
|
|
153
|
-
e.src.slice(s, r).trim().slice(-2) === "$$" && (
|
|
154
|
-
e.line =
|
|
155
|
-
const
|
|
156
|
-
return
|
|
157
|
-
` : "") + e.getLines(a + 1,
|
|
161
|
+
for (n.trim().slice(-2) === "$$" && (n = n.trim().slice(0, -2), u = !0), c = a; !u && (c++, !(c >= l || (s = e.bMarks[c] + e.tShift[c], r = e.eMarks[c], s < r && e.tShift[c] < e.blkIndent))); )
|
|
162
|
+
e.src.slice(s, r).trim().slice(-2) === "$$" && (i = e.src.slice(0, r).lastIndexOf("$$"), o = e.src.slice(s, i), u = !0);
|
|
163
|
+
e.line = c + 1;
|
|
164
|
+
const d = e.push("math_block", "math", 0);
|
|
165
|
+
return d.block = !0, d.content = (n && n.trim() ? n + `
|
|
166
|
+
` : "") + e.getLines(a + 1, c, e.tShift[a], !0) + (o && o.trim() ? o : ""), d.map = [a, e.line], d.markup = "$$", !0;
|
|
158
167
|
}, je = (e, a) => {
|
|
159
168
|
const l = (n) => {
|
|
160
169
|
if (a.katexRef.value) {
|
|
161
170
|
const o = a.katexRef.value.renderToString(n, {
|
|
162
171
|
throwOnError: !1
|
|
163
172
|
});
|
|
164
|
-
return `<span class="${
|
|
173
|
+
return `<span class="${g}-katex-inline" data-processed>${o}</span>`;
|
|
165
174
|
} else
|
|
166
|
-
return `<span class="${
|
|
175
|
+
return `<span class="${g}-katex-inline">${n}</span>`;
|
|
167
176
|
}, t = (n, o) => {
|
|
168
177
|
if (a.katexRef.value) {
|
|
169
|
-
const
|
|
178
|
+
const c = a.katexRef.value.renderToString(n, {
|
|
170
179
|
throwOnError: !1,
|
|
171
180
|
displayMode: !0
|
|
172
181
|
});
|
|
173
|
-
return `<p class="${
|
|
182
|
+
return `<p class="${g}-katex-block" data-line=${o} data-processed>${c}</p>`;
|
|
174
183
|
} else
|
|
175
|
-
return `<p class="${
|
|
184
|
+
return `<p class="${g}-katex-block" data-line=${o}>${n}</p>`;
|
|
176
185
|
};
|
|
177
|
-
e.inline.ruler.after("escape", "math_inline",
|
|
186
|
+
e.inline.ruler.after("escape", "math_inline", Ne), e.block.ruler.after("blockquote", "math_block", Be, {
|
|
178
187
|
alt: ["paragraph", "reference", "blockquote", "list"]
|
|
179
188
|
}), e.renderer.rules.math_inline = (n, o) => l(n[o].content), e.renderer.rules.math_block = (n, o) => t(n[o].content, n[o].map[0]) + `
|
|
180
189
|
`;
|
|
181
190
|
}, Oe = je, Ue = (e, a) => {
|
|
182
191
|
a = a || {};
|
|
183
192
|
const l = 3, t = a.marker || "!", n = t.charCodeAt(0), o = t.length;
|
|
184
|
-
let
|
|
185
|
-
const
|
|
186
|
-
const
|
|
187
|
-
return
|
|
193
|
+
let c = "", i = "";
|
|
194
|
+
const u = (r, d, f, w, m) => {
|
|
195
|
+
const p = r[d];
|
|
196
|
+
return p.type === "admonition_open" ? (r[d].attrPush([
|
|
188
197
|
"class",
|
|
189
|
-
`${
|
|
190
|
-
]), r[
|
|
198
|
+
`${g}-admonition ${g}-admonition-${p.info}`
|
|
199
|
+
]), r[d].attrSet("data-line", String(r[d].map[0]))) : p.type === "admonition_title_open" && r[d].attrPush(["class", `${g}-admonition-title`]), m.renderToken(r, d, f);
|
|
191
200
|
}, s = (r) => {
|
|
192
|
-
const
|
|
193
|
-
|
|
201
|
+
const d = r.trim().split(" ", 2);
|
|
202
|
+
i = "", c = d[0], d.length > 1 && (i = r.substring(c.length + 2)), (i === "" || !i) && (i = c);
|
|
194
203
|
};
|
|
195
204
|
e.block.ruler.before(
|
|
196
205
|
"code",
|
|
197
206
|
"admonition",
|
|
198
|
-
(r,
|
|
199
|
-
let m,
|
|
207
|
+
(r, d, f, w) => {
|
|
208
|
+
let m, p, h, k = !1, v = r.bMarks[d] + r.tShift[d], y = r.eMarks[d];
|
|
200
209
|
if (n !== r.src.charCodeAt(v))
|
|
201
210
|
return !1;
|
|
202
211
|
for (m = v + 1; m <= y && t[(m - v) % o] === r.src[m]; m++)
|
|
@@ -205,11 +214,11 @@ const Q = "onSave", Y = "changeCatalogVisible", Ce = "changeFullscreen", V = "pa
|
|
|
205
214
|
if (T !== l)
|
|
206
215
|
return !1;
|
|
207
216
|
m -= (m - v) % o;
|
|
208
|
-
const _ = r.src.slice(v, m),
|
|
209
|
-
if (s(
|
|
217
|
+
const _ = r.src.slice(v, m), E = r.src.slice(m, y);
|
|
218
|
+
if (s(E), w)
|
|
210
219
|
return !0;
|
|
211
|
-
for (
|
|
212
|
-
if (n === r.src.charCodeAt(v) && !(r.sCount[
|
|
220
|
+
for (p = d; p++, !(p >= f || (v = r.bMarks[p] + r.tShift[p], y = r.eMarks[p], v < y && r.sCount[p] < r.blkIndent)); )
|
|
221
|
+
if (n === r.src.charCodeAt(v) && !(r.sCount[p] - r.blkIndent >= 4)) {
|
|
213
222
|
for (m = v + 1; m <= y && t[(m - v) % o] === r.src[m]; m++)
|
|
214
223
|
;
|
|
215
224
|
if (!(Math.floor((m - v) / o) < T) && (m -= (m - v) % o, m = r.skipSpaces(m), !(m < y))) {
|
|
@@ -218,56 +227,56 @@ const Q = "onSave", Y = "changeCatalogVisible", Ce = "changeFullscreen", V = "pa
|
|
|
218
227
|
}
|
|
219
228
|
}
|
|
220
229
|
const ae = r.parentType, oe = r.lineMax;
|
|
221
|
-
return r.parentType = "root", r.lineMax =
|
|
230
|
+
return r.parentType = "root", r.lineMax = p, h = r.push("admonition_open", "div", 1), h.markup = _, h.block = !0, h.info = c, h.map = [d, p], h = r.push("admonition_title_open", "p", 1), h.markup = _ + " " + c, h.map = [d, p], h = r.push("inline", "", 0), h.content = i, h.map = [d, r.line - 1], h.children = [], h = r.push("admonition_title_close", "p", -1), h.markup = _ + " " + c, r.md.block.tokenize(r, d + 1, p), h = r.push("admonition_close", "div", -1), h.markup = r.src.slice(v, m), h.block = !0, r.parentType = ae, r.lineMax = oe, r.line = p + (k ? 1 : 0), !0;
|
|
222
231
|
},
|
|
223
232
|
{
|
|
224
233
|
alt: ["paragraph", "reference", "blockquote", "list"]
|
|
225
234
|
}
|
|
226
|
-
), e.renderer.rules.admonition_open =
|
|
235
|
+
), e.renderer.rules.admonition_open = u, e.renderer.rules.admonition_title_open = u, e.renderer.rules.admonition_title_close = u, e.renderer.rules.admonition_close = u;
|
|
227
236
|
}, Ve = Ue, Ge = (e, a) => {
|
|
228
237
|
let l;
|
|
229
238
|
e.core.ruler.push("headingLinks", (t) => {
|
|
230
239
|
l || (l = t.Token);
|
|
231
240
|
}), e.renderer.rules.heading_open = (t, n) => {
|
|
232
|
-
const o = t[n],
|
|
241
|
+
const o = t[n], c = t[n + 1].content, i = o.markup.length;
|
|
233
242
|
return a.headsRef.value.push({
|
|
234
|
-
text:
|
|
235
|
-
level:
|
|
243
|
+
text: c,
|
|
244
|
+
level: i
|
|
236
245
|
}), o.map && o.level === 0 && (o.attrSet("data-line", String(o.map[0])), o.attrSet(
|
|
237
246
|
"id",
|
|
238
|
-
a.mdHeadingId(
|
|
247
|
+
a.mdHeadingId(c, i, a.headsRef.value.length)
|
|
239
248
|
)), e.renderer.renderToken(t, n, a);
|
|
240
|
-
}, e.renderer.rules.heading_close = (t, n, o,
|
|
249
|
+
}, e.renderer.rules.heading_close = (t, n, o, c, i) => i.renderToken(t, n, o);
|
|
241
250
|
}, De = Ge, ze = (e, a) => {
|
|
242
251
|
const l = e.renderer.rules.fence, t = e.utils.unescapeAll, n = /\[(\w*)(?::([\w ]*))?\]/;
|
|
243
252
|
function o(s) {
|
|
244
253
|
return s.info ? t(s.info).trim() : "";
|
|
245
254
|
}
|
|
246
|
-
function i(s) {
|
|
247
|
-
const r = o(s), [u = null, f = ""] = (n.exec(r) || []).slice(1);
|
|
248
|
-
return [u, f];
|
|
249
|
-
}
|
|
250
255
|
function c(s) {
|
|
256
|
+
const r = o(s), [d = null, f = ""] = (n.exec(r) || []).slice(1);
|
|
257
|
+
return [d, f];
|
|
258
|
+
}
|
|
259
|
+
function i(s) {
|
|
251
260
|
const r = o(s);
|
|
252
261
|
return r ? r.split(/(\s+)/g)[0] : "";
|
|
253
262
|
}
|
|
254
|
-
const
|
|
263
|
+
const u = (s, r, d, f, w) => {
|
|
255
264
|
if (s[r].hidden)
|
|
256
265
|
return "";
|
|
257
|
-
const [m,
|
|
266
|
+
const [m, p] = c(s[r]);
|
|
258
267
|
if (m === null)
|
|
259
|
-
return l(s, r,
|
|
268
|
+
return l(s, r, d, f, w);
|
|
260
269
|
let h, k, v, y, T = "", _ = "";
|
|
261
|
-
for (let
|
|
262
|
-
h.info = h.info.replace(n, ""), h.hidden = !0, y =
|
|
263
|
-
`, _ += `<input type="radio" id="group-${a.editorId}-${r}-tab-${
|
|
264
|
-
` + l(s,
|
|
270
|
+
for (let E = r; E < s.length && (h = s[E], [k, v] = c(h), k === m); E++)
|
|
271
|
+
h.info = h.info.replace(n, ""), h.hidden = !0, y = E - r > 0 ? "" : " checked", T += `<li><input type="radio" name="label-group-${a.editorId}-${r}"${y}><label for="group-${a.editorId}-${r}-tab-${E - r}" onclick="this.previousElementSibling.click()">${v || i(h)}</label></li>
|
|
272
|
+
`, _ += `<input type="radio" id="group-${a.editorId}-${r}-tab-${E - r}" name="group-${a.editorId}-${r}"${y}>
|
|
273
|
+
` + l(s, E, d, f, w);
|
|
265
274
|
return `<div class="code-tabs">
|
|
266
275
|
<ul>
|
|
267
276
|
` + T + `</ul>
|
|
268
277
|
` + _ + "</div>";
|
|
269
278
|
};
|
|
270
|
-
e.renderer.rules.fence =
|
|
279
|
+
e.renderer.rules.fence = u;
|
|
271
280
|
}, Ke = ze, qe = (e) => {
|
|
272
281
|
[
|
|
273
282
|
"paragraph_open",
|
|
@@ -277,49 +286,49 @@ const Q = "onSave", Y = "changeCatalogVisible", Ce = "changeFullscreen", V = "pa
|
|
|
277
286
|
"blockquote_open",
|
|
278
287
|
"hr"
|
|
279
288
|
].forEach((a) => {
|
|
280
|
-
e.renderer.rules[a] = (l, t, n, o,
|
|
281
|
-
let
|
|
282
|
-
return l[t].map && l[t].level === 0 && (
|
|
289
|
+
e.renderer.rules[a] = (l, t, n, o, c) => {
|
|
290
|
+
let i;
|
|
291
|
+
return l[t].map && l[t].level === 0 && (i = l[t].map[0], l[t].attrSet("data-line", String(i))), c.renderToken(l, t, n);
|
|
283
292
|
};
|
|
284
293
|
}), ["html_block", "fence"].forEach((a) => {
|
|
285
294
|
const l = e.renderer.rules[a];
|
|
286
|
-
e.renderer.rules[a] = (t, n, o,
|
|
287
|
-
let
|
|
288
|
-
const s = l(t, n, o,
|
|
289
|
-
return t[n].map && t[n].level === 0 ? (
|
|
295
|
+
e.renderer.rules[a] = (t, n, o, c, i) => {
|
|
296
|
+
let u;
|
|
297
|
+
const s = l(t, n, o, c, i);
|
|
298
|
+
return t[n].map && t[n].level === 0 ? (u = t[n].map[0], s.replace(/^(<[^>]*)/, `$1 data-line="${u}"`)) : s;
|
|
290
299
|
};
|
|
291
300
|
});
|
|
292
301
|
}, We = (e, a) => {
|
|
293
|
-
const { editorConfig: l, markdownItConfig: t } = S, n = I("editorId"), o = I("showCodeRowNumber"),
|
|
302
|
+
const { editorConfig: l, markdownItConfig: t } = S, n = I("editorId"), o = I("showCodeRowNumber"), c = I("theme"), i = L([]), u = Fe(e), s = xe(e), { reRenderRef: r, replaceMermaid: d } = Me(e), f = ye({
|
|
294
303
|
html: !0,
|
|
295
304
|
breaks: !0
|
|
296
305
|
});
|
|
297
|
-
f.use(Oe, { katexRef: s }), f.use(we, { figcaption: !0 }), f.use(Ve), f.use(ke), f.use(De, { mdHeadingId: e.mdHeadingId, headsRef:
|
|
306
|
+
f.use(Oe, { katexRef: s }), f.use(we, { figcaption: !0 }), f.use(Ve), f.use(ke), f.use(De, { mdHeadingId: e.mdHeadingId, headsRef: i }), f.use(Ke, { editorId: n }), e.noMermaid || f.use(Le, { themeRef: c }), f.set({
|
|
298
307
|
highlight: (k, v) => {
|
|
299
308
|
let y;
|
|
300
|
-
!e.noHighlight &&
|
|
309
|
+
!e.noHighlight && u.value ? u.value.getLanguage(v) ? y = u.value.highlight(k, {
|
|
301
310
|
language: v,
|
|
302
311
|
ignoreIllegals: !0
|
|
303
|
-
}).value : y =
|
|
312
|
+
}).value : y = u.value.highlightAuto(k).value : y = f.utils.escapeHtml(k);
|
|
304
313
|
const T = o ? ve(y.trim()) : `<span class="code-block">${y.trim()}</span>`;
|
|
305
314
|
return `<pre><code class="language-${v}" language=${v}>${T}</code></pre>`;
|
|
306
315
|
}
|
|
307
316
|
}), qe(f), t(f);
|
|
308
317
|
const w = L(e.sanitize(f.render(e.modelValue))), m = () => {
|
|
309
|
-
b.emit(n, "buildFinished", w.value), e.onHtmlChanged(w.value), e.onGetCatalog(
|
|
318
|
+
b.emit(n, "buildFinished", w.value), e.onHtmlChanged(w.value), e.onGetCatalog(i.value), b.emit(n, "catalogChanged", i.value), d();
|
|
310
319
|
};
|
|
311
320
|
C(m);
|
|
312
|
-
const
|
|
321
|
+
const p = X(
|
|
313
322
|
async () => {
|
|
314
|
-
|
|
323
|
+
i.value = [], w.value = e.sanitize(f.render(e.modelValue)), m();
|
|
315
324
|
},
|
|
316
325
|
(l == null ? void 0 : l.renderDelay) !== void 0 ? l == null ? void 0 : l.renderDelay : a ? 0 : 500
|
|
317
|
-
), h = M(() => (e.noKatex || s.value) && (e.noHighlight ||
|
|
318
|
-
return $([W(e, "modelValue"), h, r],
|
|
326
|
+
), h = M(() => (e.noKatex || s.value) && (e.noHighlight || u.value));
|
|
327
|
+
return $([W(e, "modelValue"), h, r], p), C(() => {
|
|
319
328
|
b.on(n, {
|
|
320
329
|
name: "pushCatalog",
|
|
321
330
|
callback() {
|
|
322
|
-
b.emit(n, "catalogChanged",
|
|
331
|
+
b.emit(n, "catalogChanged", i.value);
|
|
323
332
|
}
|
|
324
333
|
});
|
|
325
334
|
}), { html: w };
|
|
@@ -378,25 +387,25 @@ const Q = "onSave", Y = "changeCatalogVisible", Ce = "changeFullscreen", V = "pa
|
|
|
378
387
|
const a = I("editorId"), l = I("previewTheme"), t = I("showCodeRowNumber"), {
|
|
379
388
|
html: n
|
|
380
389
|
} = Ze(e, e.previewOnly);
|
|
381
|
-
return
|
|
390
|
+
return Ee(e, n), Te(e, n), () => H(le, null, [H("div", {
|
|
382
391
|
id: `${a}-preview-wrapper`,
|
|
383
|
-
class: `${
|
|
392
|
+
class: `${g}-preview-wrapper`,
|
|
384
393
|
"data-show": e.setting.preview,
|
|
385
394
|
key: "content-preview-wrapper"
|
|
386
395
|
}, [H("article", {
|
|
387
396
|
id: `${a}-preview`,
|
|
388
|
-
class: [`${
|
|
397
|
+
class: [`${g}-preview`, `${l == null ? void 0 : l.value}-theme`, t && `${g}-scrn`],
|
|
389
398
|
innerHTML: n.value
|
|
390
399
|
}, null)]), !e.previewOnly && H("div", {
|
|
391
400
|
id: `${a}-html-wrapper`,
|
|
392
|
-
class: `${
|
|
401
|
+
class: `${g}-preview-wrapper`,
|
|
393
402
|
"data-show": e.setting.htmlPreview,
|
|
394
403
|
key: "html-preview-wrapper"
|
|
395
404
|
}, [H("div", {
|
|
396
|
-
class: `${
|
|
405
|
+
class: `${g}-html`
|
|
397
406
|
}, [n.value])])]);
|
|
398
407
|
}
|
|
399
|
-
}),
|
|
408
|
+
}), dt = (e, a) => {
|
|
400
409
|
const { editorId: l } = e, t = J({
|
|
401
410
|
// 是否已编译成html
|
|
402
411
|
buildFinished: !1,
|
|
@@ -421,12 +430,12 @@ const Q = "onSave", Y = "changeCatalogVisible", Ce = "changeFullscreen", V = "pa
|
|
|
421
430
|
if (t.buildFinished)
|
|
422
431
|
o(t.html);
|
|
423
432
|
else {
|
|
424
|
-
const
|
|
425
|
-
o(
|
|
433
|
+
const c = (i) => {
|
|
434
|
+
o(i), b.remove(l, "buildFinished", c);
|
|
426
435
|
};
|
|
427
436
|
b.on(l, {
|
|
428
437
|
name: "buildFinished",
|
|
429
|
-
callback:
|
|
438
|
+
callback: c
|
|
430
439
|
});
|
|
431
440
|
}
|
|
432
441
|
});
|
|
@@ -443,23 +452,23 @@ const Q = "onSave", Y = "changeCatalogVisible", Ce = "changeFullscreen", V = "pa
|
|
|
443
452
|
), F(
|
|
444
453
|
"highlight",
|
|
445
454
|
M(() => {
|
|
446
|
-
const
|
|
447
|
-
...
|
|
455
|
+
const c = {
|
|
456
|
+
...B,
|
|
448
457
|
...l == null ? void 0 : l.css
|
|
449
|
-
},
|
|
458
|
+
}, i = e.codeStyleReverse && e.codeStyleReverseList.includes(e.previewTheme) ? "dark" : e.theme;
|
|
450
459
|
return {
|
|
451
460
|
js: (l == null ? void 0 : l.js) || se,
|
|
452
|
-
css:
|
|
461
|
+
css: c[e.codeTheme] ? c[e.codeTheme][i] : B.atom[i]
|
|
453
462
|
};
|
|
454
463
|
})
|
|
455
464
|
), F("showCodeRowNumber", e.showCodeRowNumber);
|
|
456
465
|
const t = M(() => {
|
|
457
|
-
var
|
|
458
|
-
const
|
|
466
|
+
var i, u;
|
|
467
|
+
const c = {
|
|
459
468
|
...j,
|
|
460
|
-
...(
|
|
469
|
+
...(u = (i = S) == null ? void 0 : i.editorConfig) == null ? void 0 : u.languageUserDefined
|
|
461
470
|
};
|
|
462
|
-
return
|
|
471
|
+
return c[e.language] ? c[e.language] : j["zh-CN"];
|
|
463
472
|
});
|
|
464
473
|
F("usedLanguageText", t), F(
|
|
465
474
|
"previewTheme",
|
|
@@ -471,19 +480,19 @@ const Q = "onSave", Y = "changeCatalogVisible", Ce = "changeFullscreen", V = "pa
|
|
|
471
480
|
C(() => {
|
|
472
481
|
var l;
|
|
473
482
|
const a = document.createElement("script");
|
|
474
|
-
a.src = ((l = S.editorExtensions) == null ? void 0 : l.iconfont) ||
|
|
483
|
+
a.src = ((l = S.editorExtensions) == null ? void 0 : l.iconfont) || ue, a.id = `${g}-icon`, e.noIconfont || P(a);
|
|
475
484
|
});
|
|
476
485
|
}, ft = (e) => {
|
|
477
|
-
var
|
|
478
|
-
const { noPrettier: a, noUploadImg: l } = e, { editorExtensions: t } = S, n = a || !!((
|
|
486
|
+
var i, u, s, r, d, f;
|
|
487
|
+
const { noPrettier: a, noUploadImg: l } = e, { editorExtensions: t } = S, n = a || !!((u = (i = S.editorExtensions) == null ? void 0 : i.prettier) != null && u.prettierInstance), o = a || !!((r = (s = S.editorExtensions) == null ? void 0 : s.prettier) != null && r.parserMarkdownInstance), c = l || !!((f = (d = S.editorExtensions) == null ? void 0 : d.cropper) != null && f.instance);
|
|
479
488
|
C(() => {
|
|
480
489
|
var k, v, y, T;
|
|
481
490
|
const w = document.createElement("script"), m = document.createElement("script");
|
|
482
|
-
w.src = ((k = t == null ? void 0 : t.prettier) == null ? void 0 : k.standaloneJs) || O.main, w.id = `${
|
|
483
|
-
const
|
|
484
|
-
|
|
491
|
+
w.src = ((k = t == null ? void 0 : t.prettier) == null ? void 0 : k.standaloneJs) || O.main, w.id = `${g}-prettier`, m.src = ((v = t == null ? void 0 : t.prettier) == null ? void 0 : v.parserMarkdownJs) || O.markdown, m.id = `${g}-prettierMD`;
|
|
492
|
+
const p = document.createElement("link");
|
|
493
|
+
p.rel = "stylesheet", p.href = ((y = t == null ? void 0 : t.cropper) == null ? void 0 : y.css) || U.css, p.id = `${g}-cropperCss`;
|
|
485
494
|
const h = document.createElement("script");
|
|
486
|
-
h.src = ((T = t == null ? void 0 : t.cropper) == null ? void 0 : T.js) || U.js, h.id = `${
|
|
495
|
+
h.src = ((T = t == null ? void 0 : t.cropper) == null ? void 0 : T.js) || U.js, h.id = `${g}-cropper`, c || (P(p), P(h)), n || P(w), o || P(m);
|
|
487
496
|
}), te(e);
|
|
488
497
|
}, ht = (e, a) => {
|
|
489
498
|
const { editorId: l } = e, t = J({
|
|
@@ -491,26 +500,26 @@ const Q = "onSave", Y = "changeCatalogVisible", Ce = "changeFullscreen", V = "pa
|
|
|
491
500
|
fullscreen: !1,
|
|
492
501
|
preview: e.preview,
|
|
493
502
|
htmlPreview: e.preview ? !1 : e.htmlPreview
|
|
494
|
-
}), n = (
|
|
495
|
-
t[
|
|
503
|
+
}), n = (i, u) => {
|
|
504
|
+
t[i] = u === void 0 ? !t[i] : u, i === "preview" && t.preview ? t.htmlPreview = !1 : i === "htmlPreview" && t.htmlPreview && (t.preview = !1);
|
|
496
505
|
};
|
|
497
506
|
let o = "";
|
|
498
|
-
const
|
|
507
|
+
const c = () => {
|
|
499
508
|
t.pageFullscreen || t.fullscreen ? document.body.style.overflow = "hidden" : document.body.style.overflow = o;
|
|
500
509
|
};
|
|
501
|
-
return $(() => [t.pageFullscreen, t.fullscreen],
|
|
510
|
+
return $(() => [t.pageFullscreen, t.fullscreen], c), C(() => {
|
|
502
511
|
b.on(l, {
|
|
503
512
|
name: "uploadImage",
|
|
504
|
-
callback(
|
|
513
|
+
callback(i, u) {
|
|
505
514
|
const s = (r) => {
|
|
506
515
|
b.emit(l, "replace", "image", {
|
|
507
516
|
desc: "",
|
|
508
517
|
urls: r
|
|
509
|
-
}),
|
|
518
|
+
}), u && u();
|
|
510
519
|
};
|
|
511
|
-
e.onUploadImg ? e.onUploadImg(
|
|
520
|
+
e.onUploadImg ? e.onUploadImg(i, s) : a.emit("onUploadImg", i, s);
|
|
512
521
|
}
|
|
513
|
-
}), o = document.body.style.overflow,
|
|
522
|
+
}), o = document.body.style.overflow, c();
|
|
514
523
|
}), [t, n];
|
|
515
524
|
}, pt = (e) => {
|
|
516
525
|
const { editorId: a } = e, l = L(!1);
|
|
@@ -526,35 +535,35 @@ const Q = "onSave", Y = "changeCatalogVisible", Ce = "changeFullscreen", V = "pa
|
|
|
526
535
|
const { editorId: o } = e;
|
|
527
536
|
$(
|
|
528
537
|
() => t.pageFullscreen,
|
|
529
|
-
(
|
|
530
|
-
b.emit(o, V,
|
|
538
|
+
(i) => {
|
|
539
|
+
b.emit(o, V, i);
|
|
531
540
|
}
|
|
532
541
|
), $(
|
|
533
542
|
() => t.fullscreen,
|
|
534
|
-
(
|
|
535
|
-
b.emit(o, G,
|
|
543
|
+
(i) => {
|
|
544
|
+
b.emit(o, G, i);
|
|
536
545
|
}
|
|
537
546
|
), $(
|
|
538
547
|
() => t.preview,
|
|
539
|
-
(
|
|
540
|
-
b.emit(o, D,
|
|
548
|
+
(i) => {
|
|
549
|
+
b.emit(o, D, i);
|
|
541
550
|
}
|
|
542
551
|
), $(
|
|
543
552
|
() => t.htmlPreview,
|
|
544
|
-
(
|
|
545
|
-
b.emit(o, z,
|
|
553
|
+
(i) => {
|
|
554
|
+
b.emit(o, z, i);
|
|
546
555
|
}
|
|
547
|
-
), $(l, (
|
|
548
|
-
b.emit(o, K,
|
|
556
|
+
), $(l, (i) => {
|
|
557
|
+
b.emit(o, K, i);
|
|
549
558
|
});
|
|
550
|
-
const
|
|
551
|
-
on(
|
|
552
|
-
switch (
|
|
559
|
+
const c = {
|
|
560
|
+
on(i, u) {
|
|
561
|
+
switch (i) {
|
|
553
562
|
case "pageFullscreen": {
|
|
554
563
|
b.on(o, {
|
|
555
564
|
name: V,
|
|
556
565
|
callback(s) {
|
|
557
|
-
|
|
566
|
+
u(s);
|
|
558
567
|
}
|
|
559
568
|
});
|
|
560
569
|
break;
|
|
@@ -563,7 +572,7 @@ const Q = "onSave", Y = "changeCatalogVisible", Ce = "changeFullscreen", V = "pa
|
|
|
563
572
|
b.on(o, {
|
|
564
573
|
name: G,
|
|
565
574
|
callback(s) {
|
|
566
|
-
|
|
575
|
+
u(s);
|
|
567
576
|
}
|
|
568
577
|
});
|
|
569
578
|
break;
|
|
@@ -572,7 +581,7 @@ const Q = "onSave", Y = "changeCatalogVisible", Ce = "changeFullscreen", V = "pa
|
|
|
572
581
|
b.on(o, {
|
|
573
582
|
name: D,
|
|
574
583
|
callback(s) {
|
|
575
|
-
|
|
584
|
+
u(s);
|
|
576
585
|
}
|
|
577
586
|
});
|
|
578
587
|
break;
|
|
@@ -581,7 +590,7 @@ const Q = "onSave", Y = "changeCatalogVisible", Ce = "changeFullscreen", V = "pa
|
|
|
581
590
|
b.on(o, {
|
|
582
591
|
name: z,
|
|
583
592
|
callback(s) {
|
|
584
|
-
|
|
593
|
+
u(s);
|
|
585
594
|
}
|
|
586
595
|
});
|
|
587
596
|
break;
|
|
@@ -590,39 +599,39 @@ const Q = "onSave", Y = "changeCatalogVisible", Ce = "changeFullscreen", V = "pa
|
|
|
590
599
|
b.on(o, {
|
|
591
600
|
name: K,
|
|
592
601
|
callback(s) {
|
|
593
|
-
|
|
602
|
+
u(s);
|
|
594
603
|
}
|
|
595
604
|
});
|
|
596
605
|
break;
|
|
597
606
|
}
|
|
598
607
|
}
|
|
599
608
|
},
|
|
600
|
-
togglePageFullscreen(
|
|
601
|
-
n("pageFullscreen",
|
|
609
|
+
togglePageFullscreen(i) {
|
|
610
|
+
n("pageFullscreen", i);
|
|
602
611
|
},
|
|
603
|
-
toggleFullscreen(
|
|
604
|
-
b.emit(o, Ce,
|
|
612
|
+
toggleFullscreen(i) {
|
|
613
|
+
b.emit(o, Ce, i);
|
|
605
614
|
},
|
|
606
|
-
togglePreview(
|
|
607
|
-
n("preview",
|
|
615
|
+
togglePreview(i) {
|
|
616
|
+
n("preview", i);
|
|
608
617
|
},
|
|
609
|
-
toggleHtmlPreview(
|
|
610
|
-
n("htmlPreview",
|
|
618
|
+
toggleHtmlPreview(i) {
|
|
619
|
+
n("htmlPreview", i);
|
|
611
620
|
},
|
|
612
|
-
toggleCatalog(
|
|
613
|
-
b.emit(o, Y,
|
|
621
|
+
toggleCatalog(i) {
|
|
622
|
+
b.emit(o, Y, i);
|
|
614
623
|
},
|
|
615
624
|
triggerSave() {
|
|
616
625
|
b.emit(o, Q);
|
|
617
626
|
},
|
|
618
|
-
insert(
|
|
619
|
-
b.emit(o, "replace", "universal", { generate:
|
|
627
|
+
insert(i) {
|
|
628
|
+
b.emit(o, "replace", "universal", { generate: i });
|
|
620
629
|
},
|
|
621
630
|
focus() {
|
|
622
631
|
b.emit(o, Se);
|
|
623
632
|
}
|
|
624
633
|
};
|
|
625
|
-
a.expose(
|
|
634
|
+
a.expose(c);
|
|
626
635
|
}, Qe = (e) => e, ne = {
|
|
627
636
|
/**
|
|
628
637
|
* markdown content.
|
|
@@ -679,7 +688,7 @@ const Q = "onSave", Y = "changeCatalogVisible", Ce = "changeFullscreen", V = "pa
|
|
|
679
688
|
*/
|
|
680
689
|
editorId: {
|
|
681
690
|
type: String,
|
|
682
|
-
default:
|
|
691
|
+
default: de
|
|
683
692
|
},
|
|
684
693
|
/**
|
|
685
694
|
* 预览中代码是否显示行号
|
|
@@ -1022,15 +1031,15 @@ const Q = "onSave", Y = "changeCatalogVisible", Ce = "changeFullscreen", V = "pa
|
|
|
1022
1031
|
b.clear(l);
|
|
1023
1032
|
}), () => H("div", {
|
|
1024
1033
|
id: l,
|
|
1025
|
-
class: [
|
|
1034
|
+
class: [g, e.class, e.theme === "dark" && `${g}-dark`, `${g}-previewOnly`],
|
|
1026
1035
|
style: e.style
|
|
1027
1036
|
}, [H(Xe, {
|
|
1028
1037
|
modelValue: e.modelValue,
|
|
1029
|
-
onHtmlChanged: (
|
|
1030
|
-
e.onHtmlChanged ? e.onHtmlChanged(
|
|
1038
|
+
onHtmlChanged: (c) => {
|
|
1039
|
+
e.onHtmlChanged ? e.onHtmlChanged(c) : a.emit("onHtmlChanged", c);
|
|
1031
1040
|
},
|
|
1032
|
-
onGetCatalog: (
|
|
1033
|
-
e.onGetCatalog ? e.onGetCatalog(
|
|
1041
|
+
onGetCatalog: (c) => {
|
|
1042
|
+
e.onGetCatalog ? e.onGetCatalog(c) : a.emit("onGetCatalog", c);
|
|
1034
1043
|
},
|
|
1035
1044
|
mdHeadingId: e.mdHeadingId,
|
|
1036
1045
|
noMermaid: n,
|
|
@@ -1057,5 +1066,5 @@ export {
|
|
|
1057
1066
|
ht as g,
|
|
1058
1067
|
pt as h,
|
|
1059
1068
|
gt as i,
|
|
1060
|
-
|
|
1069
|
+
dt as u
|
|
1061
1070
|
};
|