md-editor-v3 4.3.0 → 4.4.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 +4 -4
- package/lib/cjs/MdEditor.cjs +16 -16
- package/lib/cjs/chunks/index.cjs +6 -6
- package/lib/es/MdEditor.mjs +403 -504
- package/lib/es/chunks/index.mjs +359 -282
- package/lib/types/MdEditor/Editor.d.ts +9 -0
- package/lib/types/MdEditor/index.d.ts +20 -1
- package/lib/types/MdEditor/layouts/Content/ContentPreview.d.ts +33 -73
- package/lib/types/MdEditor/layouts/Content/index.d.ts +73 -58
- package/lib/types/MdEditor/layouts/Content/props.d.ts +73 -17
- package/lib/types/MdEditor/props.d.ts +14 -0
- package/lib/types/MdPreview/MdPreview.d.ts +9 -0
- package/lib/types/MdPreview/index.d.ts +20 -1
- package/lib/umd/index.js +31 -31
- package/package.json +1 -1
package/lib/es/chunks/index.mjs
CHANGED
|
@@ -1,64 +1,68 @@
|
|
|
1
|
-
import { inject as T, onMounted as
|
|
2
|
-
import { p as h, a as P, m as
|
|
3
|
-
import { u as
|
|
4
|
-
import { a as
|
|
5
|
-
import
|
|
1
|
+
import { inject as T, onMounted as I, watch as $, toRef as W, nextTick as A, shallowRef as x, ref as B, computed as M, defineComponent as J, createVNode as H, Fragment as ie, reactive as X, provide as _, onBeforeUnmount as ce } from "vue";
|
|
2
|
+
import { p as h, a as P, m as se, k as N, e as j, h as ue, f as O, i as de, g as V, j as U, l as me, b as fe, d as pe } from "./config.mjs";
|
|
3
|
+
import { u as he, g as ge, b as g } from "./index3.mjs";
|
|
4
|
+
import { a as F, u as ve } from "./dom.mjs";
|
|
5
|
+
import ye from "medium-zoom";
|
|
6
6
|
import { debounce as Q } from "@vavt/util";
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
const Y = "onSave", ee = "changeCatalogVisible",
|
|
13
|
-
const l = T("editorId"), t = Q(() => {
|
|
14
|
-
const
|
|
15
|
-
|
|
7
|
+
import be from "copy-to-clipboard";
|
|
8
|
+
import we from "markdown-it";
|
|
9
|
+
import ke from "markdown-it-image-figures";
|
|
10
|
+
import $e from "markdown-it-task-lists";
|
|
11
|
+
import Ce from "lru-cache";
|
|
12
|
+
const Y = "onSave", ee = "changeCatalogVisible", Ie = "changeFullscreen", G = "pageFullscreenChanged", D = "fullscreenChanged", z = "previewChanged", K = "htmlPreviewChanged", q = "catalogVisibleChanged", Se = "textareaFocus", Ee = (e, a) => {
|
|
13
|
+
const l = T("editorId"), { noImgZoomIn: t } = e, n = Q(() => {
|
|
14
|
+
const r = document.querySelectorAll(`#${l}-preview img`);
|
|
15
|
+
r.length !== 0 && ye(r, {
|
|
16
16
|
background: "#00000073"
|
|
17
17
|
});
|
|
18
18
|
});
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
I(() => {
|
|
20
|
+
!t && n();
|
|
21
|
+
}), $([a, W(e.setting, "preview")], () => {
|
|
22
|
+
!t && n();
|
|
23
|
+
});
|
|
24
|
+
}, Pe = Ee, Te = (e, a) => {
|
|
21
25
|
const l = T("editorId"), t = T("usedLanguageText"), n = () => {
|
|
22
26
|
document.querySelectorAll(`#${l}-preview pre`).forEach((c) => {
|
|
23
27
|
var m, b;
|
|
24
|
-
let
|
|
28
|
+
let u = -1;
|
|
25
29
|
(m = c.querySelector(".copy-button")) == null || m.remove();
|
|
26
|
-
const s = ((b = t.value.copyCode) == null ? void 0 : b.text) || "复制代码",
|
|
27
|
-
|
|
30
|
+
const s = ((b = t.value.copyCode) == null ? void 0 : b.text) || "复制代码", o = document.createElement("span");
|
|
31
|
+
o.setAttribute("class", "copy-button"), o.dataset.tips = s, o.innerHTML = `<svg class="${h}-icon" aria-hidden="true"><use xlink:href="#${h}-icon-copy"></use></svg>`, o.addEventListener("click", () => {
|
|
28
32
|
var k, v;
|
|
29
|
-
clearTimeout(
|
|
30
|
-
const y = c.querySelector("code").innerText,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
clearTimeout(u);
|
|
34
|
+
const y = c.querySelector("code").innerText, d = be(e.formatCopiedText(y)), p = ((k = t.value.copyCode) == null ? void 0 : k.successTips) || "已复制!", f = ((v = t.value.copyCode) == null ? void 0 : v.failTips) || "已复制!";
|
|
35
|
+
o.dataset.tips = d ? p : f, u = window.setTimeout(() => {
|
|
36
|
+
o.dataset.tips = s;
|
|
33
37
|
}, 1500);
|
|
34
|
-
}), c.appendChild(
|
|
38
|
+
}), c.appendChild(o);
|
|
35
39
|
});
|
|
36
|
-
},
|
|
40
|
+
}, r = () => {
|
|
37
41
|
A(n);
|
|
38
42
|
}, i = (c) => {
|
|
39
43
|
c && A(n);
|
|
40
44
|
};
|
|
41
|
-
$(() =>
|
|
42
|
-
},
|
|
43
|
-
var
|
|
44
|
-
const
|
|
45
|
-
return
|
|
45
|
+
$(() => a.value, r), $(() => e.setting.preview, i), $(() => e.setting.htmlPreview, i), $(() => t.value, n), I(n);
|
|
46
|
+
}, Fe = Te, _e = (e) => {
|
|
47
|
+
var r;
|
|
48
|
+
const a = (r = P.editorExtensions) == null ? void 0 : r.highlight, l = a == null ? void 0 : a.instance, t = T("highlight"), n = x(l);
|
|
49
|
+
return I(() => {
|
|
46
50
|
if (!e.noHighlight && !n.value) {
|
|
47
51
|
const i = document.createElement("script");
|
|
48
52
|
i.src = t.value.js, i.onload = () => {
|
|
49
53
|
n.value = window.hljs;
|
|
50
|
-
}, i.id = `${h}-hljs`,
|
|
54
|
+
}, i.id = `${h}-hljs`, F(i, "hljs");
|
|
51
55
|
const c = document.createElement("link");
|
|
52
|
-
c.rel = "stylesheet", c.href = t.value.css, c.id = `${h}-hlCss`,
|
|
56
|
+
c.rel = "stylesheet", c.href = t.value.css, c.id = `${h}-hlCss`, F(c);
|
|
53
57
|
}
|
|
54
58
|
}), $(
|
|
55
59
|
() => t.value.css,
|
|
56
60
|
(i) => {
|
|
57
|
-
|
|
61
|
+
ve(`${h}-hlCss`, "href", i);
|
|
58
62
|
}
|
|
59
63
|
), n;
|
|
60
|
-
},
|
|
61
|
-
const
|
|
64
|
+
}, He = _e, Me = (e) => {
|
|
65
|
+
const a = T("theme"), { editorExtensions: l } = P, t = l == null ? void 0 : l.mermaid, n = x(t == null ? void 0 : t.instance), r = x(-1), i = new Ce({
|
|
62
66
|
max: 1e3,
|
|
63
67
|
// 缓存10分钟
|
|
64
68
|
ttl: 6e5
|
|
@@ -66,225 +70,225 @@ const Y = "onSave", ee = "changeCatalogVisible", Ce = "changeFullscreen", G = "p
|
|
|
66
70
|
const s = n.value;
|
|
67
71
|
!e.noMermaid && s && (s.initialize({
|
|
68
72
|
startOnLoad: !1,
|
|
69
|
-
theme:
|
|
70
|
-
}),
|
|
73
|
+
theme: a.value === "dark" ? "dark" : "default"
|
|
74
|
+
}), r.value = r.value + 1);
|
|
71
75
|
};
|
|
72
76
|
return $(
|
|
73
|
-
() =>
|
|
77
|
+
() => a.value,
|
|
74
78
|
() => {
|
|
75
79
|
i.clear(), c();
|
|
76
80
|
}
|
|
77
|
-
),
|
|
81
|
+
), I(() => {
|
|
78
82
|
if (!e.noMermaid && !(t != null && t.instance)) {
|
|
79
|
-
const s = (t == null ? void 0 : t.js) ||
|
|
83
|
+
const s = (t == null ? void 0 : t.js) || se;
|
|
80
84
|
if (/\.mjs/.test(s))
|
|
81
85
|
import(
|
|
82
86
|
/* @vite-ignore */
|
|
83
87
|
/* webpackIgnore: true */
|
|
84
88
|
s
|
|
85
|
-
).then((
|
|
86
|
-
n.value =
|
|
89
|
+
).then((o) => {
|
|
90
|
+
n.value = o.default, c();
|
|
87
91
|
});
|
|
88
92
|
else {
|
|
89
|
-
const
|
|
90
|
-
|
|
93
|
+
const o = document.createElement("script");
|
|
94
|
+
o.id = `${h}-mermaid`, o.src = s, o.onload = () => {
|
|
91
95
|
n.value = window.mermaid, c();
|
|
92
|
-
},
|
|
96
|
+
}, F(o, "mermaid");
|
|
93
97
|
}
|
|
94
98
|
}
|
|
95
|
-
}), { mermaidRef: n, reRenderRef:
|
|
99
|
+
}), { mermaidRef: n, reRenderRef: r, replaceMermaid: () => {
|
|
96
100
|
A(() => {
|
|
97
101
|
if (!e.noMermaid && n.value) {
|
|
98
102
|
const s = document.querySelectorAll(
|
|
99
103
|
`div.${h}-mermaid`
|
|
100
|
-
),
|
|
101
|
-
|
|
104
|
+
), o = document.createElement("div");
|
|
105
|
+
o.style.width = document.body.offsetWidth + "px", o.style.height = document.body.offsetHeight + "px", o.style.position = "fixed", o.style.zIndex = "-10000", o.style.top = "-10000";
|
|
102
106
|
let m = s.length;
|
|
103
|
-
m > 0 && document.body.appendChild(
|
|
107
|
+
m > 0 && document.body.appendChild(o), s.forEach(async (b) => {
|
|
104
108
|
let y = i.get(b.innerText);
|
|
105
109
|
if (!y) {
|
|
106
|
-
const p =
|
|
110
|
+
const p = he(), f = n.value.renderAsync || n.value.render;
|
|
107
111
|
let k = "";
|
|
108
112
|
try {
|
|
109
|
-
k = await f(p, b.innerText,
|
|
113
|
+
k = await f(p, b.innerText, o);
|
|
110
114
|
} catch {
|
|
111
115
|
}
|
|
112
116
|
y = typeof k == "string" ? k : k.svg, i.set(b.innerText, y);
|
|
113
117
|
}
|
|
114
|
-
const
|
|
115
|
-
|
|
118
|
+
const d = document.createElement("p");
|
|
119
|
+
d.className = `${h}-mermaid`, d.setAttribute("data-processed", ""), d.innerHTML = y, b.dataset.line !== void 0 && (d.dataset.line = b.dataset.line), b.replaceWith(d), --m === 0 && o.remove();
|
|
116
120
|
});
|
|
117
121
|
}
|
|
118
122
|
});
|
|
119
123
|
} };
|
|
120
|
-
},
|
|
124
|
+
}, xe = Me, Re = (e) => {
|
|
121
125
|
var n;
|
|
122
|
-
const
|
|
123
|
-
return
|
|
126
|
+
const a = (n = P.editorExtensions) == null ? void 0 : n.katex, l = a == null ? void 0 : a.instance, t = x(l);
|
|
127
|
+
return I(() => {
|
|
124
128
|
if (!e.noKatex && !t.value) {
|
|
125
|
-
const
|
|
126
|
-
|
|
129
|
+
const r = document.createElement("script");
|
|
130
|
+
r.src = (a == null ? void 0 : a.js) || N.js, r.onload = () => {
|
|
127
131
|
t.value = window.katex;
|
|
128
|
-
},
|
|
132
|
+
}, r.id = `${h}-katex`;
|
|
129
133
|
const i = document.createElement("link");
|
|
130
|
-
i.rel = "stylesheet", i.href = (
|
|
134
|
+
i.rel = "stylesheet", i.href = (a == null ? void 0 : a.css) || N.css, i.id = `${h}-katexCss`, F(r, "katex"), F(i);
|
|
131
135
|
}
|
|
132
136
|
}), t;
|
|
133
|
-
},
|
|
137
|
+
}, Ae = Re, Be = (e, a) => {
|
|
134
138
|
const l = e.renderer.rules.fence.bind(e.renderer.rules);
|
|
135
|
-
e.renderer.rules.fence = (t, n,
|
|
136
|
-
const
|
|
137
|
-
if (
|
|
138
|
-
let
|
|
139
|
-
return t[n].map && t[n].level === 0 && (
|
|
139
|
+
e.renderer.rules.fence = (t, n, r, i, c) => {
|
|
140
|
+
const u = t[n], s = u.content.trim();
|
|
141
|
+
if (u.info === "mermaid") {
|
|
142
|
+
let o;
|
|
143
|
+
return t[n].map && t[n].level === 0 && (o = t[n].map[0], t[n].attrSet("data-line", String(o))), `<div class="${h}-mermaid" ${o !== void 0 ? "data-line=" + o : ""} data-mermaid-theme=${a.themeRef.value}>${s}</div>`;
|
|
140
144
|
}
|
|
141
|
-
return l(t, n,
|
|
145
|
+
return l(t, n, r, i, c);
|
|
142
146
|
};
|
|
143
|
-
}, Le =
|
|
147
|
+
}, Le = Be, Z = (e, a) => {
|
|
144
148
|
let l = !0, t = !0;
|
|
145
|
-
const n = e.posMax,
|
|
146
|
-
return (
|
|
149
|
+
const n = e.posMax, r = a > 0 ? e.src.charCodeAt(a - 1) : -1, i = a + 1 <= n ? e.src.charCodeAt(a + 1) : -1;
|
|
150
|
+
return (r === 32 || r === 9 || i >= 48 && i <= 57) && (t = !1), (i === 32 || i === 9) && (l = !1), {
|
|
147
151
|
can_open: l,
|
|
148
152
|
can_close: t
|
|
149
153
|
};
|
|
150
|
-
}, Ne = (e,
|
|
151
|
-
let l, t, n,
|
|
154
|
+
}, Ne = (e, a) => {
|
|
155
|
+
let l, t, n, r;
|
|
152
156
|
if (e.src[e.pos] !== "$")
|
|
153
157
|
return !1;
|
|
154
|
-
if (n =
|
|
155
|
-
return
|
|
158
|
+
if (n = Z(e, e.pos), !n.can_open)
|
|
159
|
+
return a || (e.pending += "$"), e.pos += 1, !0;
|
|
156
160
|
const i = e.pos + 1;
|
|
157
161
|
for (l = i; (l = e.src.indexOf("$", l)) !== -1; ) {
|
|
158
|
-
for (
|
|
159
|
-
|
|
160
|
-
if ((l -
|
|
162
|
+
for (r = l - 1; e.src[r] === "\\"; )
|
|
163
|
+
r -= 1;
|
|
164
|
+
if ((l - r) % 2 == 1)
|
|
161
165
|
break;
|
|
162
166
|
l += 1;
|
|
163
167
|
}
|
|
164
|
-
return l === -1 ? (
|
|
165
|
-
},
|
|
166
|
-
let n,
|
|
167
|
-
if (s + 2 >
|
|
168
|
+
return l === -1 ? (a || (e.pending += "$"), e.pos = i, !0) : l - i === 0 ? (a || (e.pending += "$$"), e.pos = i + 1, !0) : (n = Z(e, l), n.can_close ? (a || (t = e.push("math_inline", "math", 0), t.markup = "$", t.content = e.src.slice(i, l)), e.pos = l + 1, !0) : (a || (e.pending += "$"), e.pos = i, !0));
|
|
169
|
+
}, je = (e, a, l, t) => {
|
|
170
|
+
let n, r, i, c, u = !1, s = e.bMarks[a] + e.tShift[a], o = e.eMarks[a];
|
|
171
|
+
if (s + 2 > o || e.src.slice(s, s + 2) !== "$$")
|
|
168
172
|
return !1;
|
|
169
|
-
if (s += 2, n = e.src.slice(s,
|
|
173
|
+
if (s += 2, n = e.src.slice(s, o), t)
|
|
170
174
|
return !0;
|
|
171
|
-
for (n.trim().slice(-2) === "$$" && (n = n.trim().slice(0, -2),
|
|
172
|
-
e.src.slice(s,
|
|
175
|
+
for (n.trim().slice(-2) === "$$" && (n = n.trim().slice(0, -2), u = !0), i = a; !u && (i++, !(i >= l || (s = e.bMarks[i] + e.tShift[i], o = e.eMarks[i], s < o && e.tShift[i] < e.blkIndent))); )
|
|
176
|
+
e.src.slice(s, o).trim().slice(-2) === "$$" && (c = e.src.slice(0, o).lastIndexOf("$$"), r = e.src.slice(s, c), u = !0);
|
|
173
177
|
e.line = i + 1;
|
|
174
178
|
const m = e.push("math_block", "math", 0);
|
|
175
179
|
return m.block = !0, m.content = (n && n.trim() ? n + `
|
|
176
|
-
` : "") + e.getLines(
|
|
177
|
-
},
|
|
180
|
+
` : "") + e.getLines(a + 1, i, e.tShift[a], !0) + (r && r.trim() ? r : ""), m.map = [a, e.line], m.markup = "$$", !0;
|
|
181
|
+
}, Oe = (e, a) => {
|
|
178
182
|
const l = (n) => {
|
|
179
|
-
if (
|
|
180
|
-
const
|
|
183
|
+
if (a.katexRef.value) {
|
|
184
|
+
const r = a.katexRef.value.renderToString(n, {
|
|
181
185
|
throwOnError: !1
|
|
182
186
|
});
|
|
183
|
-
return `<span class="${h}-katex-inline" data-processed>${
|
|
187
|
+
return `<span class="${h}-katex-inline" data-processed>${r}</span>`;
|
|
184
188
|
} else
|
|
185
189
|
return `<span class="${h}-katex-inline">${n}</span>`;
|
|
186
|
-
}, t = (n,
|
|
187
|
-
if (
|
|
188
|
-
const i =
|
|
190
|
+
}, t = (n, r) => {
|
|
191
|
+
if (a.katexRef.value) {
|
|
192
|
+
const i = a.katexRef.value.renderToString(n, {
|
|
189
193
|
throwOnError: !1,
|
|
190
194
|
displayMode: !0
|
|
191
195
|
});
|
|
192
|
-
return `<p class="${h}-katex-block" data-line=${
|
|
196
|
+
return `<p class="${h}-katex-block" data-line=${r} data-processed>${i}</p>`;
|
|
193
197
|
} else
|
|
194
|
-
return `<p class="${h}-katex-block" data-line=${
|
|
198
|
+
return `<p class="${h}-katex-block" data-line=${r}>${n}</p>`;
|
|
195
199
|
};
|
|
196
|
-
e.inline.ruler.after("escape", "math_inline", Ne), e.block.ruler.after("blockquote", "math_block",
|
|
200
|
+
e.inline.ruler.after("escape", "math_inline", Ne), e.block.ruler.after("blockquote", "math_block", je, {
|
|
197
201
|
alt: ["paragraph", "reference", "blockquote", "list"]
|
|
198
|
-
}), e.renderer.rules.math_inline = (n,
|
|
202
|
+
}), e.renderer.rules.math_inline = (n, r) => l(n[r].content), e.renderer.rules.math_block = (n, r) => t(n[r].content, n[r].map[0]) + `
|
|
199
203
|
`;
|
|
200
|
-
},
|
|
201
|
-
|
|
202
|
-
const l = 3, t =
|
|
204
|
+
}, Ve = Oe, Ue = (e, a) => {
|
|
205
|
+
a = a || {};
|
|
206
|
+
const l = 3, t = a.marker || "!", n = t.charCodeAt(0), r = t.length;
|
|
203
207
|
let i = "", c = "";
|
|
204
|
-
const
|
|
205
|
-
const p =
|
|
206
|
-
return p.type === "admonition_open" ? (
|
|
208
|
+
const u = (o, m, b, y, d) => {
|
|
209
|
+
const p = o[m];
|
|
210
|
+
return p.type === "admonition_open" ? (o[m].attrPush([
|
|
207
211
|
"class",
|
|
208
212
|
`${h}-admonition ${h}-admonition-${p.info}`
|
|
209
|
-
]),
|
|
210
|
-
}, s = (
|
|
211
|
-
const m =
|
|
212
|
-
c = "", i = m[0], m.length > 1 && (c =
|
|
213
|
+
]), o[m].attrSet("data-line", String(o[m].map[0]))) : p.type === "admonition_title_open" && o[m].attrPush(["class", `${h}-admonition-title`]), d.renderToken(o, m, b);
|
|
214
|
+
}, s = (o) => {
|
|
215
|
+
const m = o.trim().split(" ", 2);
|
|
216
|
+
c = "", i = m[0], m.length > 1 && (c = o.substring(i.length + 2)), (c === "" || !c) && (c = i);
|
|
213
217
|
};
|
|
214
218
|
e.block.ruler.before(
|
|
215
219
|
"code",
|
|
216
220
|
"admonition",
|
|
217
|
-
(
|
|
218
|
-
let
|
|
219
|
-
if (n !==
|
|
221
|
+
(o, m, b, y) => {
|
|
222
|
+
let d, p, f, k = !1, v = o.bMarks[m] + o.tShift[m], w = o.eMarks[m];
|
|
223
|
+
if (n !== o.src.charCodeAt(v))
|
|
220
224
|
return !1;
|
|
221
|
-
for (
|
|
225
|
+
for (d = v + 1; d <= w && t[(d - v) % r] === o.src[d]; d++)
|
|
222
226
|
;
|
|
223
|
-
const C = Math.floor((
|
|
227
|
+
const C = Math.floor((d - v) / r);
|
|
224
228
|
if (C !== l)
|
|
225
229
|
return !1;
|
|
226
|
-
|
|
227
|
-
const
|
|
230
|
+
d -= (d - v) % r;
|
|
231
|
+
const S = o.src.slice(v, d), E = o.src.slice(d, w);
|
|
228
232
|
if (s(E), y)
|
|
229
233
|
return !0;
|
|
230
|
-
for (p = m; p++, !(p >= b || (v =
|
|
231
|
-
if (n ===
|
|
232
|
-
for (
|
|
234
|
+
for (p = m; p++, !(p >= b || (v = o.bMarks[p] + o.tShift[p], w = o.eMarks[p], v < w && o.sCount[p] < o.blkIndent)); )
|
|
235
|
+
if (n === o.src.charCodeAt(v) && !(o.sCount[p] - o.blkIndent >= 4)) {
|
|
236
|
+
for (d = v + 1; d <= w && t[(d - v) % r] === o.src[d]; d++)
|
|
233
237
|
;
|
|
234
|
-
if (!(Math.floor((
|
|
238
|
+
if (!(Math.floor((d - v) / r) < C) && (d -= (d - v) % r, d = o.skipSpaces(d), !(d < w))) {
|
|
235
239
|
k = !0;
|
|
236
240
|
break;
|
|
237
241
|
}
|
|
238
242
|
}
|
|
239
|
-
const
|
|
240
|
-
return
|
|
243
|
+
const L = o.parentType, le = o.lineMax;
|
|
244
|
+
return o.parentType = "root", o.lineMax = p, f = o.push("admonition_open", "div", 1), f.markup = S, f.block = !0, f.info = i, f.map = [m, p], f = o.push("admonition_title_open", "p", 1), f.markup = S + " " + i, f.map = [m, p], f = o.push("inline", "", 0), f.content = c, f.map = [m, o.line - 1], f.children = [], f = o.push("admonition_title_close", "p", -1), f.markup = S + " " + i, o.md.block.tokenize(o, m + 1, p), f = o.push("admonition_close", "div", -1), f.markup = o.src.slice(v, d), f.block = !0, o.parentType = L, o.lineMax = le, o.line = p + (k ? 1 : 0), !0;
|
|
241
245
|
},
|
|
242
246
|
{
|
|
243
247
|
alt: ["paragraph", "reference", "blockquote", "list"]
|
|
244
248
|
}
|
|
245
|
-
), e.renderer.rules.admonition_open =
|
|
246
|
-
},
|
|
249
|
+
), 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;
|
|
250
|
+
}, Ge = Ue, De = (e, a) => {
|
|
247
251
|
e.renderer.rules.heading_open = (l, t) => {
|
|
248
|
-
const n = l[t],
|
|
249
|
-
return
|
|
250
|
-
text:
|
|
252
|
+
const n = l[t], r = l[t + 1].content, i = n.markup.length;
|
|
253
|
+
return a.headsRef.value.push({
|
|
254
|
+
text: r,
|
|
251
255
|
level: i
|
|
252
256
|
}), n.map && n.level === 0 && (n.attrSet("data-line", String(n.map[0])), n.attrSet(
|
|
253
257
|
"id",
|
|
254
|
-
|
|
255
|
-
)), e.renderer.renderToken(l, t,
|
|
256
|
-
}, e.renderer.rules.heading_close = (l, t, n,
|
|
257
|
-
}, ze =
|
|
258
|
+
a.mdHeadingId(r, i, a.headsRef.value.length)
|
|
259
|
+
)), e.renderer.renderToken(l, t, a);
|
|
260
|
+
}, e.renderer.rules.heading_close = (l, t, n, r, i) => i.renderToken(l, t, n);
|
|
261
|
+
}, ze = De, Ke = (e, a) => {
|
|
258
262
|
const l = e.renderer.rules.fence, t = e.utils.unescapeAll, n = /\[(\w*)(?::([\w ]*))?\]/;
|
|
259
|
-
function
|
|
263
|
+
function r(s) {
|
|
260
264
|
return s.info ? t(s.info).trim() : "";
|
|
261
265
|
}
|
|
262
266
|
function i(s) {
|
|
263
|
-
const
|
|
267
|
+
const o = r(s), [m = null, b = ""] = (n.exec(o) || []).slice(1);
|
|
264
268
|
return [m, b];
|
|
265
269
|
}
|
|
266
270
|
function c(s) {
|
|
267
|
-
const
|
|
268
|
-
return
|
|
271
|
+
const o = r(s);
|
|
272
|
+
return o ? o.split(/(\s+)/g)[0] : "";
|
|
269
273
|
}
|
|
270
|
-
const
|
|
271
|
-
if (s[
|
|
274
|
+
const u = (s, o, m, b, y) => {
|
|
275
|
+
if (s[o].hidden)
|
|
272
276
|
return "";
|
|
273
|
-
const [
|
|
274
|
-
if (
|
|
275
|
-
return l(s,
|
|
276
|
-
let f, k, v, w, C = "",
|
|
277
|
-
for (let E =
|
|
278
|
-
f.info = f.info.replace(n, ""), f.hidden = !0, w = E -
|
|
279
|
-
`,
|
|
277
|
+
const [d, p] = i(s[o]);
|
|
278
|
+
if (d === null)
|
|
279
|
+
return l(s, o, m, b, y);
|
|
280
|
+
let f, k, v, w, C = "", S = "";
|
|
281
|
+
for (let E = o; E < s.length && (f = s[E], [k, v] = i(f), k === d); E++)
|
|
282
|
+
f.info = f.info.replace(n, ""), f.hidden = !0, w = E - o > 0 ? "" : " checked", C += `<li><input type="radio" name="label-group-${a.editorId}-${o}"${w}><label for="group-${a.editorId}-${o}-tab-${E - o}" onclick="this.previousElementSibling.click()">${v || c(f)}</label></li>
|
|
283
|
+
`, S += `<input type="radio" id="group-${a.editorId}-${o}-tab-${E - o}" name="group-${a.editorId}-${o}"${w}>
|
|
280
284
|
` + l(s, E, m, b, y);
|
|
281
285
|
return `<div class="code-tabs">
|
|
282
286
|
<ul>
|
|
283
287
|
` + C + `</ul>
|
|
284
|
-
` +
|
|
288
|
+
` + S + "</div>";
|
|
285
289
|
};
|
|
286
|
-
e.renderer.rules.fence =
|
|
287
|
-
},
|
|
290
|
+
e.renderer.rules.fence = u;
|
|
291
|
+
}, qe = Ke, Ze = (e) => {
|
|
288
292
|
[
|
|
289
293
|
"paragraph_open",
|
|
290
294
|
"table_open",
|
|
@@ -294,91 +298,91 @@ const Y = "onSave", ee = "changeCatalogVisible", Ce = "changeFullscreen", G = "p
|
|
|
294
298
|
"hr",
|
|
295
299
|
"html_block",
|
|
296
300
|
"fence"
|
|
297
|
-
].forEach((
|
|
298
|
-
const l = e.renderer.rules[
|
|
299
|
-
l ? e.renderer.rules[
|
|
300
|
-
let
|
|
301
|
-
const s = l(t, n,
|
|
302
|
-
return t[n].map && t[n].level === 0 ? (
|
|
303
|
-
} : e.renderer.rules[
|
|
304
|
-
let
|
|
305
|
-
return t[n].map && t[n].level === 0 && (
|
|
301
|
+
].forEach((a) => {
|
|
302
|
+
const l = e.renderer.rules[a];
|
|
303
|
+
l ? e.renderer.rules[a] = (t, n, r, i, c) => {
|
|
304
|
+
let u;
|
|
305
|
+
const s = l(t, n, r, i, c);
|
|
306
|
+
return t[n].map && t[n].level === 0 ? (u = t[n].map[0], s.replace(/^(<[^>]*)/, `$1 data-line="${u}"`)) : s;
|
|
307
|
+
} : e.renderer.rules[a] = (t, n, r, i, c) => {
|
|
308
|
+
let u;
|
|
309
|
+
return t[n].map && t[n].level === 0 && (u = t[n].map[0], t[n].attrSet("data-line", String(u))), c.renderToken(t, n, r);
|
|
306
310
|
};
|
|
307
311
|
});
|
|
308
|
-
}, We = (e,
|
|
309
|
-
const { editorConfig: l, markdownItConfig: t, markdownItPlugins: n } = P,
|
|
312
|
+
}, We = (e, a) => {
|
|
313
|
+
const { editorConfig: l, markdownItConfig: t, markdownItPlugins: n } = P, r = T("editorId"), i = T("showCodeRowNumber"), c = T("theme"), u = B([]), s = He(e), o = Ae(e), { reRenderRef: m, replaceMermaid: b } = xe(e), y = we({
|
|
310
314
|
html: !0,
|
|
311
315
|
breaks: !0
|
|
312
316
|
});
|
|
313
317
|
t(y);
|
|
314
|
-
const
|
|
318
|
+
const d = [
|
|
315
319
|
{
|
|
316
320
|
type: "katex",
|
|
317
|
-
plugin:
|
|
318
|
-
options: { katexRef:
|
|
321
|
+
plugin: Ve,
|
|
322
|
+
options: { katexRef: o }
|
|
319
323
|
},
|
|
320
324
|
{
|
|
321
325
|
type: "image",
|
|
322
|
-
plugin:
|
|
326
|
+
plugin: ke,
|
|
323
327
|
options: { figcaption: !0, classes: "md-zoom" }
|
|
324
328
|
},
|
|
325
329
|
{
|
|
326
330
|
type: "admonition",
|
|
327
|
-
plugin:
|
|
331
|
+
plugin: Ge,
|
|
328
332
|
options: {}
|
|
329
333
|
},
|
|
330
334
|
{
|
|
331
335
|
type: "taskList",
|
|
332
|
-
plugin:
|
|
336
|
+
plugin: $e,
|
|
333
337
|
options: {}
|
|
334
338
|
},
|
|
335
339
|
{
|
|
336
340
|
type: "heading",
|
|
337
341
|
plugin: ze,
|
|
338
|
-
options: { mdHeadingId: e.mdHeadingId, headsRef:
|
|
342
|
+
options: { mdHeadingId: e.mdHeadingId, headsRef: u }
|
|
339
343
|
},
|
|
340
344
|
{
|
|
341
345
|
type: "codeTabs",
|
|
342
|
-
plugin:
|
|
343
|
-
options: { editorId:
|
|
346
|
+
plugin: qe,
|
|
347
|
+
options: { editorId: r }
|
|
344
348
|
}
|
|
345
349
|
];
|
|
346
|
-
e.noMermaid ||
|
|
350
|
+
e.noMermaid || d.push({
|
|
347
351
|
type: "mermaid",
|
|
348
352
|
plugin: Le,
|
|
349
353
|
options: { themeRef: c }
|
|
350
|
-
}), n(
|
|
354
|
+
}), n(d).forEach((w) => {
|
|
351
355
|
y.use(w.plugin, w.options);
|
|
352
356
|
}), y.set({
|
|
353
357
|
highlight: (w, C) => {
|
|
354
|
-
let
|
|
355
|
-
!e.noHighlight && s.value ? s.value.getLanguage(C) ?
|
|
358
|
+
let S;
|
|
359
|
+
!e.noHighlight && s.value ? s.value.getLanguage(C) ? S = s.value.highlight(w, {
|
|
356
360
|
language: C,
|
|
357
361
|
ignoreIllegals: !0
|
|
358
|
-
}).value :
|
|
359
|
-
const E = i ?
|
|
362
|
+
}).value : S = s.value.highlightAuto(w).value : S = y.utils.escapeHtml(w);
|
|
363
|
+
const E = i ? ge(S.trim()) : `<span class="code-block">${S.trim()}</span>`;
|
|
360
364
|
return `<pre><code class="language-${C}" language=${C}>${E}</code></pre>`;
|
|
361
365
|
}
|
|
362
|
-
}),
|
|
363
|
-
const p =
|
|
364
|
-
g.emit(
|
|
366
|
+
}), Ze(y);
|
|
367
|
+
const p = B(e.sanitize(y.render(e.modelValue))), f = () => {
|
|
368
|
+
g.emit(r, "buildFinished", p.value), e.onHtmlChanged(p.value), e.onGetCatalog(u.value), g.emit(r, "catalogChanged", u.value), b();
|
|
365
369
|
};
|
|
366
|
-
|
|
370
|
+
I(f);
|
|
367
371
|
const k = Q(
|
|
368
372
|
async () => {
|
|
369
|
-
|
|
373
|
+
u.value = [], p.value = e.sanitize(y.render(e.modelValue)), f();
|
|
370
374
|
},
|
|
371
|
-
(l == null ? void 0 : l.renderDelay) !== void 0 ? l == null ? void 0 : l.renderDelay :
|
|
372
|
-
), v = M(() => (e.noKatex ||
|
|
373
|
-
return $([
|
|
374
|
-
g.on(
|
|
375
|
+
(l == null ? void 0 : l.renderDelay) !== void 0 ? l == null ? void 0 : l.renderDelay : a ? 0 : 500
|
|
376
|
+
), v = M(() => (e.noKatex || o.value) && (e.noHighlight || s.value));
|
|
377
|
+
return $([W(e, "modelValue"), v, m], k), I(() => {
|
|
378
|
+
g.on(r, {
|
|
375
379
|
name: "pushCatalog",
|
|
376
380
|
callback() {
|
|
377
|
-
g.emit(
|
|
381
|
+
g.emit(r, "catalogChanged", u.value);
|
|
378
382
|
}
|
|
379
383
|
});
|
|
380
384
|
}), { html: p };
|
|
381
|
-
},
|
|
385
|
+
}, Je = We, te = {
|
|
382
386
|
modelValue: {
|
|
383
387
|
type: String,
|
|
384
388
|
default: ""
|
|
@@ -425,25 +429,89 @@ const Y = "onSave", ee = "changeCatalogVisible", Ce = "changeFullscreen", G = "p
|
|
|
425
429
|
previewOnly: {
|
|
426
430
|
type: Boolean,
|
|
427
431
|
default: !1
|
|
432
|
+
},
|
|
433
|
+
noImgZoomIn: {
|
|
434
|
+
type: Boolean
|
|
435
|
+
}
|
|
436
|
+
}, dt = {
|
|
437
|
+
...te,
|
|
438
|
+
onChange: {
|
|
439
|
+
type: Function,
|
|
440
|
+
default: () => {
|
|
441
|
+
}
|
|
442
|
+
},
|
|
443
|
+
placeholder: {
|
|
444
|
+
type: String,
|
|
445
|
+
default: ""
|
|
446
|
+
},
|
|
447
|
+
scrollAuto: {
|
|
448
|
+
type: Boolean
|
|
449
|
+
},
|
|
450
|
+
autofocus: {
|
|
451
|
+
type: Boolean
|
|
452
|
+
},
|
|
453
|
+
disabled: {
|
|
454
|
+
type: Boolean
|
|
455
|
+
},
|
|
456
|
+
readonly: {
|
|
457
|
+
type: Boolean
|
|
458
|
+
},
|
|
459
|
+
maxlength: {
|
|
460
|
+
type: Number
|
|
461
|
+
},
|
|
462
|
+
autoDetectCode: {
|
|
463
|
+
type: Boolean
|
|
464
|
+
},
|
|
465
|
+
/**
|
|
466
|
+
* 输入框失去焦点时触发事件
|
|
467
|
+
*/
|
|
468
|
+
onBlur: {
|
|
469
|
+
type: Function,
|
|
470
|
+
default: () => {
|
|
471
|
+
}
|
|
472
|
+
},
|
|
473
|
+
/**
|
|
474
|
+
* 输入框获得焦点时触发事件
|
|
475
|
+
*/
|
|
476
|
+
onFocus: {
|
|
477
|
+
type: Function,
|
|
478
|
+
default: () => {
|
|
479
|
+
}
|
|
480
|
+
},
|
|
481
|
+
noPrettier: {
|
|
482
|
+
type: Boolean
|
|
483
|
+
},
|
|
484
|
+
completions: {
|
|
485
|
+
type: Array
|
|
486
|
+
},
|
|
487
|
+
catalogVisible: {
|
|
488
|
+
type: Boolean
|
|
489
|
+
},
|
|
490
|
+
theme: {
|
|
491
|
+
type: String,
|
|
492
|
+
default: "light"
|
|
493
|
+
},
|
|
494
|
+
onInput: {
|
|
495
|
+
type: Function
|
|
428
496
|
}
|
|
429
497
|
}, Xe = /* @__PURE__ */ J({
|
|
430
498
|
name: "ContentPreview",
|
|
431
|
-
props:
|
|
499
|
+
props: te,
|
|
432
500
|
setup(e) {
|
|
433
|
-
const
|
|
501
|
+
const a = T("editorId"), l = T("previewTheme"), t = T("showCodeRowNumber"), {
|
|
434
502
|
html: n
|
|
435
|
-
} =
|
|
436
|
-
return
|
|
437
|
-
id: `${
|
|
503
|
+
} = Je(e, e.previewOnly);
|
|
504
|
+
return Fe(e, n), Pe(e, n), () => H(ie, null, [H("div", {
|
|
505
|
+
id: `${a}-preview-wrapper`,
|
|
438
506
|
class: `${h}-preview-wrapper`,
|
|
439
507
|
"data-show": e.setting.preview,
|
|
440
508
|
key: "content-preview-wrapper"
|
|
441
509
|
}, [H("article", {
|
|
442
|
-
id: `${
|
|
510
|
+
id: `${a}-preview`,
|
|
443
511
|
class: [`${h}-preview`, `${l == null ? void 0 : l.value}-theme`, t && `${h}-scrn`],
|
|
444
512
|
innerHTML: n.value
|
|
445
513
|
}, null)]), !e.previewOnly && H("div", {
|
|
446
|
-
id: `${
|
|
514
|
+
id: `${a}-html-wrapper`,
|
|
447
515
|
class: `${h}-preview-wrapper`,
|
|
448
516
|
"data-show": e.setting.htmlPreview,
|
|
449
517
|
key: "html-preview-wrapper"
|
|
@@ -451,7 +519,7 @@ const Y = "onSave", ee = "changeCatalogVisible", Ce = "changeFullscreen", G = "p
|
|
|
451
519
|
class: `${h}-html`
|
|
452
520
|
}, [n.value])])]);
|
|
453
521
|
}
|
|
454
|
-
}),
|
|
522
|
+
}), mt = (e, a) => {
|
|
455
523
|
const { editorId: l } = e, t = X({
|
|
456
524
|
// 是否已编译成html
|
|
457
525
|
buildFinished: !1,
|
|
@@ -463,7 +531,7 @@ const Y = "onSave", ee = "changeCatalogVisible", Ce = "changeFullscreen", G = "p
|
|
|
463
531
|
() => {
|
|
464
532
|
t.buildFinished = !1;
|
|
465
533
|
}
|
|
466
|
-
),
|
|
534
|
+
), I(() => {
|
|
467
535
|
g.on(l, {
|
|
468
536
|
name: "buildFinished",
|
|
469
537
|
callback(n) {
|
|
@@ -472,12 +540,12 @@ const Y = "onSave", ee = "changeCatalogVisible", Ce = "changeFullscreen", G = "p
|
|
|
472
540
|
}), g.on(l, {
|
|
473
541
|
name: Y,
|
|
474
542
|
callback() {
|
|
475
|
-
const n = new Promise((
|
|
543
|
+
const n = new Promise((r) => {
|
|
476
544
|
if (t.buildFinished)
|
|
477
|
-
|
|
545
|
+
r(t.html);
|
|
478
546
|
else {
|
|
479
547
|
const i = (c) => {
|
|
480
|
-
|
|
548
|
+
r(c), g.remove(l, "buildFinished", i);
|
|
481
549
|
};
|
|
482
550
|
g.on(l, {
|
|
483
551
|
name: "buildFinished",
|
|
@@ -485,17 +553,17 @@ const Y = "onSave", ee = "changeCatalogVisible", Ce = "changeFullscreen", G = "p
|
|
|
485
553
|
});
|
|
486
554
|
}
|
|
487
555
|
});
|
|
488
|
-
e.onSave ? e.onSave(e.modelValue, n) :
|
|
556
|
+
e.onSave ? e.onSave(e.modelValue, n) : a.emit("onSave", e.modelValue, n);
|
|
489
557
|
}
|
|
490
558
|
});
|
|
491
559
|
});
|
|
492
|
-
},
|
|
493
|
-
var n,
|
|
494
|
-
const { editorId:
|
|
495
|
-
|
|
560
|
+
}, ne = (e) => {
|
|
561
|
+
var n, r;
|
|
562
|
+
const { editorId: a } = e, l = (r = (n = P) == null ? void 0 : n.editorExtensions) == null ? void 0 : r.highlight;
|
|
563
|
+
_("editorId", a), _(
|
|
496
564
|
"theme",
|
|
497
565
|
M(() => e.theme)
|
|
498
|
-
),
|
|
566
|
+
), _(
|
|
499
567
|
"highlight",
|
|
500
568
|
M(() => {
|
|
501
569
|
const i = {
|
|
@@ -503,159 +571,159 @@ const Y = "onSave", ee = "changeCatalogVisible", Ce = "changeFullscreen", G = "p
|
|
|
503
571
|
...l == null ? void 0 : l.css
|
|
504
572
|
}, c = e.codeStyleReverse && e.codeStyleReverseList.includes(e.previewTheme) ? "dark" : e.theme;
|
|
505
573
|
return {
|
|
506
|
-
js: (l == null ? void 0 : l.js) ||
|
|
574
|
+
js: (l == null ? void 0 : l.js) || ue,
|
|
507
575
|
css: i[e.codeTheme] ? i[e.codeTheme][c] : j.atom[c]
|
|
508
576
|
};
|
|
509
577
|
})
|
|
510
|
-
),
|
|
578
|
+
), _("showCodeRowNumber", e.showCodeRowNumber);
|
|
511
579
|
const t = M(() => {
|
|
512
|
-
var c,
|
|
580
|
+
var c, u;
|
|
513
581
|
const i = {
|
|
514
582
|
...O,
|
|
515
|
-
...(
|
|
583
|
+
...(u = (c = P) == null ? void 0 : c.editorConfig) == null ? void 0 : u.languageUserDefined
|
|
516
584
|
};
|
|
517
585
|
return i[e.language] ? i[e.language] : O["zh-CN"];
|
|
518
586
|
});
|
|
519
|
-
|
|
587
|
+
_("usedLanguageText", t), _(
|
|
520
588
|
"previewTheme",
|
|
521
589
|
M(() => e.previewTheme)
|
|
522
590
|
);
|
|
523
|
-
},
|
|
524
|
-
|
|
525
|
-
},
|
|
526
|
-
|
|
591
|
+
}, ft = (e) => {
|
|
592
|
+
ne(e), _("tabWidth", e.tabWidth);
|
|
593
|
+
}, oe = (e) => {
|
|
594
|
+
I(() => {
|
|
527
595
|
var l;
|
|
528
|
-
const
|
|
529
|
-
|
|
596
|
+
const a = document.createElement("script");
|
|
597
|
+
a.src = ((l = P.editorExtensions) == null ? void 0 : l.iconfont) || de, a.id = `${h}-icon`, e.noIconfont || F(a);
|
|
530
598
|
});
|
|
531
|
-
},
|
|
532
|
-
var c,
|
|
533
|
-
const { noPrettier:
|
|
534
|
-
|
|
599
|
+
}, pt = (e) => {
|
|
600
|
+
var c, u, s, o, m, b;
|
|
601
|
+
const { noPrettier: a, noUploadImg: l } = e, { editorExtensions: t } = P, n = a || !!((u = (c = P.editorExtensions) == null ? void 0 : c.prettier) != null && u.prettierInstance), r = a || !!((o = (s = P.editorExtensions) == null ? void 0 : s.prettier) != null && o.parserMarkdownInstance), i = l || !!((b = (m = P.editorExtensions) == null ? void 0 : m.cropper) != null && b.instance);
|
|
602
|
+
I(() => {
|
|
535
603
|
var k, v, w, C;
|
|
536
|
-
const y = document.createElement("script"),
|
|
537
|
-
y.src = ((k = t == null ? void 0 : t.prettier) == null ? void 0 : k.standaloneJs) ||
|
|
604
|
+
const y = document.createElement("script"), d = document.createElement("script");
|
|
605
|
+
y.src = ((k = t == null ? void 0 : t.prettier) == null ? void 0 : k.standaloneJs) || V.main, y.id = `${h}-prettier`, d.src = ((v = t == null ? void 0 : t.prettier) == null ? void 0 : v.parserMarkdownJs) || V.markdown, d.id = `${h}-prettierMD`;
|
|
538
606
|
const p = document.createElement("link");
|
|
539
|
-
p.rel = "stylesheet", p.href = ((w = t == null ? void 0 : t.cropper) == null ? void 0 : w.css) ||
|
|
607
|
+
p.rel = "stylesheet", p.href = ((w = t == null ? void 0 : t.cropper) == null ? void 0 : w.css) || U.css, p.id = `${h}-cropperCss`;
|
|
540
608
|
const f = document.createElement("script");
|
|
541
|
-
f.src = ((C = t == null ? void 0 : t.cropper) == null ? void 0 : C.js) ||
|
|
542
|
-
}),
|
|
543
|
-
},
|
|
609
|
+
f.src = ((C = t == null ? void 0 : t.cropper) == null ? void 0 : C.js) || U.js, f.id = `${h}-cropper`, i || (F(p), F(f)), n || F(y), r || F(d);
|
|
610
|
+
}), oe(e);
|
|
611
|
+
}, ht = (e, a) => {
|
|
544
612
|
const { editorId: l } = e;
|
|
545
|
-
|
|
613
|
+
I(() => {
|
|
546
614
|
g.on(l, {
|
|
547
615
|
name: "errorCatcher",
|
|
548
616
|
callback: (t) => {
|
|
549
|
-
e.onError instanceof Function ? e.onError(t) :
|
|
617
|
+
e.onError instanceof Function ? e.onError(t) : a.emit("onError", t);
|
|
550
618
|
}
|
|
551
619
|
});
|
|
552
620
|
});
|
|
553
|
-
},
|
|
621
|
+
}, gt = (e, a) => {
|
|
554
622
|
const { editorId: l } = e, t = X({
|
|
555
623
|
pageFullscreen: e.pageFullscreen,
|
|
556
624
|
fullscreen: !1,
|
|
557
625
|
preview: e.preview,
|
|
558
626
|
htmlPreview: e.preview ? !1 : e.htmlPreview
|
|
559
|
-
}), n = (c,
|
|
560
|
-
t[c] =
|
|
627
|
+
}), n = (c, u) => {
|
|
628
|
+
t[c] = u === void 0 ? !t[c] : u, c === "preview" && t.preview ? t.htmlPreview = !1 : c === "htmlPreview" && t.htmlPreview && (t.preview = !1);
|
|
561
629
|
};
|
|
562
|
-
let
|
|
630
|
+
let r = "";
|
|
563
631
|
const i = () => {
|
|
564
|
-
t.pageFullscreen || t.fullscreen ? document.body.style.overflow = "hidden" : document.body.style.overflow =
|
|
632
|
+
t.pageFullscreen || t.fullscreen ? document.body.style.overflow = "hidden" : document.body.style.overflow = r;
|
|
565
633
|
};
|
|
566
|
-
return $(() => [t.pageFullscreen, t.fullscreen], i),
|
|
634
|
+
return $(() => [t.pageFullscreen, t.fullscreen], i), I(() => {
|
|
567
635
|
g.on(l, {
|
|
568
636
|
name: "uploadImage",
|
|
569
|
-
callback(c,
|
|
570
|
-
const s = (
|
|
637
|
+
callback(c, u) {
|
|
638
|
+
const s = (o) => {
|
|
571
639
|
g.emit(l, "replace", "image", {
|
|
572
640
|
desc: "",
|
|
573
|
-
urls:
|
|
574
|
-
}),
|
|
641
|
+
urls: o
|
|
642
|
+
}), u && u();
|
|
575
643
|
};
|
|
576
|
-
e.onUploadImg ? e.onUploadImg(c, s) :
|
|
644
|
+
e.onUploadImg ? e.onUploadImg(c, s) : a.emit("onUploadImg", c, s);
|
|
577
645
|
}
|
|
578
|
-
}),
|
|
646
|
+
}), r = document.body.style.overflow, i();
|
|
579
647
|
}), [t, n];
|
|
580
|
-
},
|
|
581
|
-
const { editorId:
|
|
582
|
-
return
|
|
583
|
-
g.on(
|
|
648
|
+
}, vt = (e) => {
|
|
649
|
+
const { editorId: a } = e, l = B(!1);
|
|
650
|
+
return I(() => {
|
|
651
|
+
g.on(a, {
|
|
584
652
|
name: ee,
|
|
585
653
|
callback: (n) => {
|
|
586
654
|
n === void 0 ? l.value = !l.value : l.value = n;
|
|
587
655
|
}
|
|
588
656
|
});
|
|
589
657
|
}), M(() => !e.toolbarsExclude.includes("catalog") && e.toolbars.includes("catalog") && l.value);
|
|
590
|
-
},
|
|
591
|
-
const { editorId:
|
|
658
|
+
}, yt = (e, a, l, t, n) => {
|
|
659
|
+
const { editorId: r } = e;
|
|
592
660
|
$(
|
|
593
661
|
() => t.pageFullscreen,
|
|
594
662
|
(c) => {
|
|
595
|
-
g.emit(
|
|
663
|
+
g.emit(r, G, c);
|
|
596
664
|
}
|
|
597
665
|
), $(
|
|
598
666
|
() => t.fullscreen,
|
|
599
667
|
(c) => {
|
|
600
|
-
g.emit(
|
|
668
|
+
g.emit(r, D, c);
|
|
601
669
|
}
|
|
602
670
|
), $(
|
|
603
671
|
() => t.preview,
|
|
604
672
|
(c) => {
|
|
605
|
-
g.emit(
|
|
673
|
+
g.emit(r, z, c);
|
|
606
674
|
}
|
|
607
675
|
), $(
|
|
608
676
|
() => t.htmlPreview,
|
|
609
677
|
(c) => {
|
|
610
|
-
g.emit(
|
|
678
|
+
g.emit(r, K, c);
|
|
611
679
|
}
|
|
612
680
|
), $(l, (c) => {
|
|
613
|
-
g.emit(
|
|
681
|
+
g.emit(r, q, c);
|
|
614
682
|
});
|
|
615
683
|
const i = {
|
|
616
|
-
on(c,
|
|
684
|
+
on(c, u) {
|
|
617
685
|
switch (c) {
|
|
618
686
|
case "pageFullscreen": {
|
|
619
|
-
g.on(
|
|
687
|
+
g.on(r, {
|
|
620
688
|
name: G,
|
|
621
689
|
callback(s) {
|
|
622
|
-
|
|
690
|
+
u(s);
|
|
623
691
|
}
|
|
624
692
|
});
|
|
625
693
|
break;
|
|
626
694
|
}
|
|
627
695
|
case "fullscreen": {
|
|
628
|
-
g.on(
|
|
629
|
-
name:
|
|
696
|
+
g.on(r, {
|
|
697
|
+
name: D,
|
|
630
698
|
callback(s) {
|
|
631
|
-
|
|
699
|
+
u(s);
|
|
632
700
|
}
|
|
633
701
|
});
|
|
634
702
|
break;
|
|
635
703
|
}
|
|
636
704
|
case "preview": {
|
|
637
|
-
g.on(
|
|
638
|
-
name:
|
|
705
|
+
g.on(r, {
|
|
706
|
+
name: z,
|
|
639
707
|
callback(s) {
|
|
640
|
-
|
|
708
|
+
u(s);
|
|
641
709
|
}
|
|
642
710
|
});
|
|
643
711
|
break;
|
|
644
712
|
}
|
|
645
713
|
case "htmlPreview": {
|
|
646
|
-
g.on(
|
|
714
|
+
g.on(r, {
|
|
647
715
|
name: K,
|
|
648
716
|
callback(s) {
|
|
649
|
-
|
|
717
|
+
u(s);
|
|
650
718
|
}
|
|
651
719
|
});
|
|
652
720
|
break;
|
|
653
721
|
}
|
|
654
722
|
case "catalog": {
|
|
655
|
-
g.on(
|
|
723
|
+
g.on(r, {
|
|
656
724
|
name: q,
|
|
657
725
|
callback(s) {
|
|
658
|
-
|
|
726
|
+
u(s);
|
|
659
727
|
}
|
|
660
728
|
});
|
|
661
729
|
break;
|
|
@@ -666,7 +734,7 @@ const Y = "onSave", ee = "changeCatalogVisible", Ce = "changeFullscreen", G = "p
|
|
|
666
734
|
n("pageFullscreen", c);
|
|
667
735
|
},
|
|
668
736
|
toggleFullscreen(c) {
|
|
669
|
-
g.emit(
|
|
737
|
+
g.emit(r, Ie, c);
|
|
670
738
|
},
|
|
671
739
|
togglePreview(c) {
|
|
672
740
|
n("preview", c);
|
|
@@ -675,19 +743,19 @@ const Y = "onSave", ee = "changeCatalogVisible", Ce = "changeFullscreen", G = "p
|
|
|
675
743
|
n("htmlPreview", c);
|
|
676
744
|
},
|
|
677
745
|
toggleCatalog(c) {
|
|
678
|
-
g.emit(
|
|
746
|
+
g.emit(r, ee, c);
|
|
679
747
|
},
|
|
680
748
|
triggerSave() {
|
|
681
|
-
g.emit(
|
|
749
|
+
g.emit(r, Y);
|
|
682
750
|
},
|
|
683
751
|
insert(c) {
|
|
684
|
-
g.emit(
|
|
752
|
+
g.emit(r, "replace", "universal", { generate: c });
|
|
685
753
|
},
|
|
686
754
|
focus(c) {
|
|
687
|
-
g.emit(
|
|
755
|
+
g.emit(r, Se, c);
|
|
688
756
|
}
|
|
689
757
|
};
|
|
690
|
-
|
|
758
|
+
a.expose(i);
|
|
691
759
|
}, Qe = (e) => e, re = {
|
|
692
760
|
/**
|
|
693
761
|
* markdown content.
|
|
@@ -744,7 +812,7 @@ const Y = "onSave", ee = "changeCatalogVisible", Ce = "changeFullscreen", G = "p
|
|
|
744
812
|
*/
|
|
745
813
|
editorId: {
|
|
746
814
|
type: String,
|
|
747
|
-
default:
|
|
815
|
+
default: me
|
|
748
816
|
},
|
|
749
817
|
/**
|
|
750
818
|
* 预览中代码是否显示行号
|
|
@@ -857,8 +925,15 @@ const Y = "onSave", ee = "changeCatalogVisible", Ce = "changeFullscreen", G = "p
|
|
|
857
925
|
noHighlight: {
|
|
858
926
|
type: Boolean,
|
|
859
927
|
default: !1
|
|
928
|
+
},
|
|
929
|
+
/**
|
|
930
|
+
* 是否关闭编辑器默认的放大缩小功能
|
|
931
|
+
*/
|
|
932
|
+
noImgZoomIn: {
|
|
933
|
+
type: Boolean,
|
|
934
|
+
default: !1
|
|
860
935
|
}
|
|
861
|
-
},
|
|
936
|
+
}, bt = {
|
|
862
937
|
...re,
|
|
863
938
|
/**
|
|
864
939
|
* input回调事件
|
|
@@ -923,7 +998,7 @@ const Y = "onSave", ee = "changeCatalogVisible", Ce = "changeFullscreen", G = "p
|
|
|
923
998
|
*/
|
|
924
999
|
toolbars: {
|
|
925
1000
|
type: Array,
|
|
926
|
-
default:
|
|
1001
|
+
default: fe
|
|
927
1002
|
},
|
|
928
1003
|
/**
|
|
929
1004
|
* 工具栏选择不显示
|
|
@@ -987,7 +1062,7 @@ const Y = "onSave", ee = "changeCatalogVisible", Ce = "changeFullscreen", G = "p
|
|
|
987
1062
|
*/
|
|
988
1063
|
footers: {
|
|
989
1064
|
type: Array,
|
|
990
|
-
default:
|
|
1065
|
+
default: pe
|
|
991
1066
|
},
|
|
992
1067
|
/**
|
|
993
1068
|
* 是否默认激活输入框和预览框同步滚动
|
|
@@ -1091,8 +1166,8 @@ const Y = "onSave", ee = "changeCatalogVisible", Ce = "changeFullscreen", G = "p
|
|
|
1091
1166
|
onInput: {
|
|
1092
1167
|
type: Function
|
|
1093
1168
|
}
|
|
1094
|
-
},
|
|
1095
|
-
...
|
|
1169
|
+
}, ae = ["onHtmlChanged", "onGetCatalog"], wt = [
|
|
1170
|
+
...ae,
|
|
1096
1171
|
"onChange",
|
|
1097
1172
|
"onSave",
|
|
1098
1173
|
"onUploadImg",
|
|
@@ -1104,15 +1179,15 @@ const Y = "onSave", ee = "changeCatalogVisible", Ce = "changeFullscreen", G = "p
|
|
|
1104
1179
|
], Ye = /* @__PURE__ */ J({
|
|
1105
1180
|
name: "MdPreview",
|
|
1106
1181
|
props: re,
|
|
1107
|
-
emits:
|
|
1108
|
-
setup(e,
|
|
1182
|
+
emits: ae,
|
|
1183
|
+
setup(e, a) {
|
|
1109
1184
|
const {
|
|
1110
1185
|
editorId: l,
|
|
1111
1186
|
noKatex: t,
|
|
1112
1187
|
noMermaid: n,
|
|
1113
|
-
noHighlight:
|
|
1188
|
+
noHighlight: r
|
|
1114
1189
|
} = e;
|
|
1115
|
-
return
|
|
1190
|
+
return ne(e), oe(e), ce(() => {
|
|
1116
1191
|
g.clear(l);
|
|
1117
1192
|
}), () => H("div", {
|
|
1118
1193
|
id: l,
|
|
@@ -1121,36 +1196,38 @@ const Y = "onSave", ee = "changeCatalogVisible", Ce = "changeFullscreen", G = "p
|
|
|
1121
1196
|
}, [H(Xe, {
|
|
1122
1197
|
modelValue: e.modelValue,
|
|
1123
1198
|
onHtmlChanged: (i) => {
|
|
1124
|
-
e.onHtmlChanged ? e.onHtmlChanged(i) :
|
|
1199
|
+
e.onHtmlChanged ? e.onHtmlChanged(i) : a.emit("onHtmlChanged", i);
|
|
1125
1200
|
},
|
|
1126
1201
|
onGetCatalog: (i) => {
|
|
1127
|
-
e.onGetCatalog ? e.onGetCatalog(i) :
|
|
1202
|
+
e.onGetCatalog ? e.onGetCatalog(i) : a.emit("onGetCatalog", i);
|
|
1128
1203
|
},
|
|
1129
1204
|
mdHeadingId: e.mdHeadingId,
|
|
1130
1205
|
noMermaid: n,
|
|
1131
1206
|
sanitize: e.sanitize,
|
|
1132
1207
|
noKatex: t,
|
|
1133
1208
|
formatCopiedText: e.formatCopiedText,
|
|
1134
|
-
noHighlight:
|
|
1209
|
+
noHighlight: r,
|
|
1210
|
+
noImgZoomIn: e.noImgZoomIn,
|
|
1135
1211
|
previewOnly: !0
|
|
1136
1212
|
}, null)]);
|
|
1137
1213
|
}
|
|
1138
1214
|
}), R = Ye;
|
|
1139
1215
|
R.install = (e) => (e.component(R.name, R), e);
|
|
1140
1216
|
export {
|
|
1141
|
-
|
|
1217
|
+
Ie as C,
|
|
1142
1218
|
R as M,
|
|
1143
1219
|
Y as O,
|
|
1144
1220
|
Se as T,
|
|
1145
1221
|
ee as a,
|
|
1146
1222
|
Xe as b,
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1223
|
+
dt as c,
|
|
1224
|
+
wt as d,
|
|
1225
|
+
bt as e,
|
|
1150
1226
|
ft as f,
|
|
1151
1227
|
pt as g,
|
|
1152
1228
|
ht as h,
|
|
1153
1229
|
gt as i,
|
|
1154
1230
|
vt as j,
|
|
1155
|
-
|
|
1231
|
+
yt as k,
|
|
1232
|
+
mt as u
|
|
1156
1233
|
};
|