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