md-editor-v3 4.2.1-beta.1 → 4.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/MdEditor.cjs +16 -16
- package/lib/cjs/chunks/index.cjs +4 -4
- package/lib/cjs/chunks/index2.cjs +1 -1
- package/lib/cjs/chunks/index4.cjs +2 -2
- package/lib/cjs/index.cjs +1 -1
- package/lib/es/MdEditor.mjs +296 -289
- package/lib/es/chunks/index.mjs +27 -27
- package/lib/es/chunks/index2.mjs +4 -1
- package/lib/es/chunks/index4.mjs +21 -19
- package/lib/es/index.mjs +14 -15
- package/lib/preview.css +1 -1
- package/lib/style.css +1 -1
- package/lib/types/MdEditor/layouts/Content/composition/useMermaid.d.ts +1 -1
- package/lib/types/MdEditor/layouts/Content/index.d.ts +15 -0
- package/lib/types/MdEditor/layouts/Content/markdownIt/mermaid/index.d.ts +0 -1
- package/lib/types/MdEditor/layouts/Content/props.d.ts +8 -1
- package/lib/types/MdEditor/type.d.ts +1 -3
- package/lib/umd/index.js +28 -28
- package/package.json +2 -2
package/lib/es/chunks/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { inject as I, onMounted as C, watch as $, toRef as W, nextTick as A, shallowRef as x, ref as L, computed as
|
|
1
|
+
import { inject as I, onMounted as C, watch as $, toRef as W, nextTick as A, shallowRef as x, 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
2
|
import { p, a as S, m as ce, k as N, e as B, h as se, f as j, i as de, g as O, j as U, l as ue, b as me, d as fe } from "./config.mjs";
|
|
3
3
|
import { u as he, g as pe, b as y } from "./index4.mjs";
|
|
4
4
|
import { a as T, u as ge } from "./dom.mjs";
|
|
@@ -57,8 +57,8 @@ const Q = "onSave", Y = "changeCatalogVisible", Ce = "changeFullscreen", V = "pa
|
|
|
57
57
|
ge(`${p}-hlCss`, "href", i);
|
|
58
58
|
}
|
|
59
59
|
), t;
|
|
60
|
-
},
|
|
61
|
-
const o = I("theme"), { editorExtensions: a } = S, n = a == null ? void 0 : a.mermaid, t = x(n == null ? void 0 : n.instance), l = x(
|
|
60
|
+
}, Fe = _e, He = (e) => {
|
|
61
|
+
const o = I("theme"), { editorExtensions: a } = S, n = a == null ? void 0 : a.mermaid, t = x(n == null ? void 0 : n.instance), l = x(-1), i = new $e({
|
|
62
62
|
max: 1e3,
|
|
63
63
|
// 缓存10分钟
|
|
64
64
|
ttl: 6e5
|
|
@@ -67,7 +67,7 @@ const Q = "onSave", Y = "changeCatalogVisible", Ce = "changeFullscreen", V = "pa
|
|
|
67
67
|
!e.noMermaid && s && (s.initialize({
|
|
68
68
|
startOnLoad: !1,
|
|
69
69
|
theme: o.value === "dark" ? "dark" : "default"
|
|
70
|
-
}), l.value =
|
|
70
|
+
}), l.value = l.value + 1);
|
|
71
71
|
};
|
|
72
72
|
return $(
|
|
73
73
|
() => o.value,
|
|
@@ -98,9 +98,9 @@ const Q = "onSave", Y = "changeCatalogVisible", Ce = "changeFullscreen", V = "pa
|
|
|
98
98
|
const s = document.querySelectorAll(
|
|
99
99
|
`div.${p}-mermaid`
|
|
100
100
|
), r = document.createElement("div");
|
|
101
|
-
r.style.width = document.body.offsetWidth + "px", r.style.height = document.body.offsetHeight + "px", r.style.position = "fixed", r.style.zIndex = "-10000", r.style.top = "-10000"
|
|
101
|
+
r.style.width = document.body.offsetWidth + "px", r.style.height = document.body.offsetHeight + "px", r.style.position = "fixed", r.style.zIndex = "-10000", r.style.top = "-10000";
|
|
102
102
|
let m = s.length;
|
|
103
|
-
s.forEach(async (f) => {
|
|
103
|
+
m > 0 && document.body.appendChild(r), s.forEach(async (f) => {
|
|
104
104
|
let b = i.get(f.innerText);
|
|
105
105
|
if (!b) {
|
|
106
106
|
const g = he(), h = t.value.renderAsync || t.value.render;
|
|
@@ -117,7 +117,7 @@ const Q = "onSave", Y = "changeCatalogVisible", Ce = "changeFullscreen", V = "pa
|
|
|
117
117
|
}
|
|
118
118
|
});
|
|
119
119
|
} };
|
|
120
|
-
},
|
|
120
|
+
}, Me = He, xe = (e) => {
|
|
121
121
|
var t;
|
|
122
122
|
const o = (t = S.editorExtensions) == null ? void 0 : t.katex, a = o == null ? void 0 : o.instance, n = x(a);
|
|
123
123
|
return C(() => {
|
|
@@ -134,7 +134,7 @@ const Q = "onSave", Y = "changeCatalogVisible", Ce = "changeFullscreen", V = "pa
|
|
|
134
134
|
const a = e.renderer.rules.fence.bind(e.renderer.rules);
|
|
135
135
|
e.renderer.rules.fence = (n, t, l, i, c) => {
|
|
136
136
|
const d = n[t], s = d.content.trim();
|
|
137
|
-
if (d.info === "mermaid"
|
|
137
|
+
if (d.info === "mermaid") {
|
|
138
138
|
let r;
|
|
139
139
|
return n[t].map && n[t].level === 0 && (r = n[t].map[0], n[t].attrSet("data-line", String(r))), `<div class="${p}-mermaid" ${r !== void 0 ? "data-line=" + r : ""} data-mermaid-theme=${o.themeRef.value}>${s}</div>`;
|
|
140
140
|
}
|
|
@@ -306,11 +306,11 @@ const Q = "onSave", Y = "changeCatalogVisible", Ce = "changeFullscreen", V = "pa
|
|
|
306
306
|
};
|
|
307
307
|
});
|
|
308
308
|
}, We = (e, o) => {
|
|
309
|
-
const { editorConfig: a, markdownItConfig: n } = S, t = I("editorId"), l = I("showCodeRowNumber"), i = I("theme"), c = L([]), d =
|
|
309
|
+
const { editorConfig: a, markdownItConfig: n } = S, t = I("editorId"), l = I("showCodeRowNumber"), i = I("theme"), c = L([]), d = Fe(e), s = Re(e), { reRenderRef: r, replaceMermaid: m } = Me(e), f = be({
|
|
310
310
|
html: !0,
|
|
311
311
|
breaks: !0
|
|
312
312
|
});
|
|
313
|
-
n(f), f.use(Oe, { katexRef: s }), f.use(we, { figcaption: !0 }), f.use(Ve), f.use(ke), f.use(De, { mdHeadingId: e.mdHeadingId, headsRef: c }), f.use(Ke, { editorId: t }), e.noMermaid || f.use(Le, { themeRef: i
|
|
313
|
+
n(f), f.use(Oe, { katexRef: s }), f.use(we, { figcaption: !0 }), f.use(Ve), f.use(ke), f.use(De, { mdHeadingId: e.mdHeadingId, headsRef: c }), f.use(Ke, { editorId: t }), e.noMermaid || f.use(Le, { themeRef: i }), f.set({
|
|
314
314
|
highlight: (w, v) => {
|
|
315
315
|
let k;
|
|
316
316
|
!e.noHighlight && d.value ? d.value.getLanguage(v) ? k = d.value.highlight(w, {
|
|
@@ -330,7 +330,7 @@ const Q = "onSave", Y = "changeCatalogVisible", Ce = "changeFullscreen", V = "pa
|
|
|
330
330
|
c.value = [], b.value = e.sanitize(f.render(e.modelValue)), u();
|
|
331
331
|
},
|
|
332
332
|
(a == null ? void 0 : a.renderDelay) !== void 0 ? a == null ? void 0 : a.renderDelay : o ? 0 : 500
|
|
333
|
-
), h =
|
|
333
|
+
), h = M(() => (e.noKatex || s.value) && (e.noHighlight || d.value));
|
|
334
334
|
return $([W(e, "modelValue"), h, r], g), C(() => {
|
|
335
335
|
y.on(t, {
|
|
336
336
|
name: "pushCatalog",
|
|
@@ -394,21 +394,21 @@ const Q = "onSave", Y = "changeCatalogVisible", Ce = "changeFullscreen", V = "pa
|
|
|
394
394
|
const o = I("editorId"), a = I("previewTheme"), n = I("showCodeRowNumber"), {
|
|
395
395
|
html: t
|
|
396
396
|
} = Ze(e, e.previewOnly);
|
|
397
|
-
return Ee(e, t), Pe(e, t), () =>
|
|
397
|
+
return Ee(e, t), Pe(e, t), () => H(le, null, [H("div", {
|
|
398
398
|
id: `${o}-preview-wrapper`,
|
|
399
399
|
class: `${p}-preview-wrapper`,
|
|
400
400
|
"data-show": e.setting.preview,
|
|
401
401
|
key: "content-preview-wrapper"
|
|
402
|
-
}, [
|
|
402
|
+
}, [H("article", {
|
|
403
403
|
id: `${o}-preview`,
|
|
404
404
|
class: [`${p}-preview`, `${a == null ? void 0 : a.value}-theme`, n && `${p}-scrn`],
|
|
405
405
|
innerHTML: t.value
|
|
406
|
-
}, null)]), !e.previewOnly &&
|
|
406
|
+
}, null)]), !e.previewOnly && H("div", {
|
|
407
407
|
id: `${o}-html-wrapper`,
|
|
408
408
|
class: `${p}-preview-wrapper`,
|
|
409
409
|
"data-show": e.setting.htmlPreview,
|
|
410
410
|
key: "html-preview-wrapper"
|
|
411
|
-
}, [
|
|
411
|
+
}, [H("div", {
|
|
412
412
|
class: `${p}-html`
|
|
413
413
|
}, [t.value])])]);
|
|
414
414
|
}
|
|
@@ -453,12 +453,12 @@ const Q = "onSave", Y = "changeCatalogVisible", Ce = "changeFullscreen", V = "pa
|
|
|
453
453
|
}, ee = (e) => {
|
|
454
454
|
var t, l;
|
|
455
455
|
const { editorId: o } = e, a = (l = (t = S) == null ? void 0 : t.editorExtensions) == null ? void 0 : l.highlight;
|
|
456
|
-
|
|
456
|
+
F("editorId", o), F(
|
|
457
457
|
"theme",
|
|
458
|
-
|
|
459
|
-
),
|
|
458
|
+
M(() => e.theme)
|
|
459
|
+
), F(
|
|
460
460
|
"highlight",
|
|
461
|
-
|
|
461
|
+
M(() => {
|
|
462
462
|
const i = {
|
|
463
463
|
...B,
|
|
464
464
|
...a == null ? void 0 : a.css
|
|
@@ -468,8 +468,8 @@ const Q = "onSave", Y = "changeCatalogVisible", Ce = "changeFullscreen", V = "pa
|
|
|
468
468
|
css: i[e.codeTheme] ? i[e.codeTheme][c] : B.atom[c]
|
|
469
469
|
};
|
|
470
470
|
})
|
|
471
|
-
),
|
|
472
|
-
const n =
|
|
471
|
+
), F("showCodeRowNumber", e.showCodeRowNumber);
|
|
472
|
+
const n = M(() => {
|
|
473
473
|
var c, d;
|
|
474
474
|
const i = {
|
|
475
475
|
...j,
|
|
@@ -477,12 +477,12 @@ const Q = "onSave", Y = "changeCatalogVisible", Ce = "changeFullscreen", V = "pa
|
|
|
477
477
|
};
|
|
478
478
|
return i[e.language] ? i[e.language] : j["zh-CN"];
|
|
479
479
|
});
|
|
480
|
-
|
|
480
|
+
F("usedLanguageText", n), F(
|
|
481
481
|
"previewTheme",
|
|
482
|
-
|
|
482
|
+
M(() => e.previewTheme)
|
|
483
483
|
);
|
|
484
484
|
}, mt = (e) => {
|
|
485
|
-
ee(e),
|
|
485
|
+
ee(e), F("tabWidth", e.tabWidth);
|
|
486
486
|
}, te = (e) => {
|
|
487
487
|
C(() => {
|
|
488
488
|
var a;
|
|
@@ -537,7 +537,7 @@ const Q = "onSave", Y = "changeCatalogVisible", Ce = "changeFullscreen", V = "pa
|
|
|
537
537
|
t === void 0 ? a.value = !a.value : a.value = t;
|
|
538
538
|
}
|
|
539
539
|
});
|
|
540
|
-
}),
|
|
540
|
+
}), M(() => !e.toolbarsExclude.includes("catalog") && e.toolbars.includes("catalog") && a.value);
|
|
541
541
|
}, gt = (e, o, a, n, t) => {
|
|
542
542
|
const { editorId: l } = e;
|
|
543
543
|
$(
|
|
@@ -1049,11 +1049,11 @@ const Q = "onSave", Y = "changeCatalogVisible", Ce = "changeFullscreen", V = "pa
|
|
|
1049
1049
|
} = e;
|
|
1050
1050
|
return ee(e), te(e), ie(() => {
|
|
1051
1051
|
y.clear(a);
|
|
1052
|
-
}), () =>
|
|
1052
|
+
}), () => H("div", {
|
|
1053
1053
|
id: a,
|
|
1054
1054
|
class: [p, e.class, e.theme === "dark" && `${p}-dark`, `${p}-previewOnly`],
|
|
1055
1055
|
style: e.style
|
|
1056
|
-
}, [
|
|
1056
|
+
}, [H(Xe, {
|
|
1057
1057
|
modelValue: e.modelValue,
|
|
1058
1058
|
onHtmlChanged: (i) => {
|
|
1059
1059
|
e.onHtmlChanged ? e.onHtmlChanged(i) : o.emit("onHtmlChanged", i);
|
package/lib/es/chunks/index2.mjs
CHANGED
|
@@ -31,7 +31,10 @@ const B = {
|
|
|
31
31
|
}), r = C(), n = C(), y = () => {
|
|
32
32
|
var p;
|
|
33
33
|
t.triggerHover = !0;
|
|
34
|
-
const o = r.value, l = n.value
|
|
34
|
+
const o = r.value, l = n.value;
|
|
35
|
+
if (!o || !l)
|
|
36
|
+
return;
|
|
37
|
+
const v = o.getBoundingClientRect(), u = o.offsetTop, L = o.offsetLeft, S = v.height, b = v.width, w = ((p = document.querySelector(e.relative)) == null ? void 0 : p.scrollLeft) || 0;
|
|
35
38
|
t.overlayStyle = {
|
|
36
39
|
...t.overlayStyle,
|
|
37
40
|
top: u + S + "px",
|
package/lib/es/chunks/index4.mjs
CHANGED
|
@@ -9,7 +9,7 @@ class u {
|
|
|
9
9
|
// 移除事件监听
|
|
10
10
|
remove(t, s, n) {
|
|
11
11
|
const i = this.pools[t] && this.pools[t][s];
|
|
12
|
-
i && (this.pools[t][s] = i.filter((
|
|
12
|
+
i && (this.pools[t][s] = i.filter((r) => r !== n));
|
|
13
13
|
}
|
|
14
14
|
// 清空全部事件,由于单一实例,多次注册会被共享内容
|
|
15
15
|
clear(t) {
|
|
@@ -23,27 +23,27 @@ class u {
|
|
|
23
23
|
emit(t, s, ...n) {
|
|
24
24
|
this.pools[t] || (this.pools[t] = {});
|
|
25
25
|
const i = this.pools[t][s];
|
|
26
|
-
i && i.forEach((
|
|
26
|
+
i && i.forEach((r) => {
|
|
27
27
|
try {
|
|
28
|
-
|
|
29
|
-
} catch (
|
|
30
|
-
console.error(`${s} monitor event exception!`,
|
|
28
|
+
r(...n);
|
|
29
|
+
} catch (l) {
|
|
30
|
+
console.error(`${s} monitor event exception!`, l);
|
|
31
31
|
}
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
-
const g = new u(),
|
|
35
|
+
const g = new u(), f = (o, t = "image.png") => {
|
|
36
36
|
const s = o.split(","), n = s[0].match(/:(.*?);/);
|
|
37
37
|
if (n) {
|
|
38
|
-
const
|
|
39
|
-
let
|
|
40
|
-
const
|
|
41
|
-
for (;
|
|
42
|
-
r
|
|
43
|
-
return new File([
|
|
38
|
+
const e = n[1], i = atob(s[1]);
|
|
39
|
+
let r = i.length;
|
|
40
|
+
const l = new Uint8Array(r);
|
|
41
|
+
for (; r--; )
|
|
42
|
+
l[r] = i.charCodeAt(r);
|
|
43
|
+
return new File([l], t, { type: e });
|
|
44
44
|
}
|
|
45
45
|
return null;
|
|
46
|
-
},
|
|
46
|
+
}, b = (o) => {
|
|
47
47
|
if (!o)
|
|
48
48
|
return o;
|
|
49
49
|
const t = o.split(`
|
|
@@ -51,17 +51,19 @@ const g = new u(), b = (o, t = "image.png") => {
|
|
|
51
51
|
return t.forEach(() => {
|
|
52
52
|
s.push("<span></span>");
|
|
53
53
|
}), s.push("</span>"), `<span class="code-block">${o}</span>${s.join("")}`;
|
|
54
|
-
},
|
|
54
|
+
}, R = (o, t) => {
|
|
55
|
+
if (!o || !t)
|
|
56
|
+
return 0;
|
|
55
57
|
const s = o == null ? void 0 : o.getBoundingClientRect();
|
|
56
58
|
if (t === document.documentElement)
|
|
57
59
|
return s.top - t.clientTop;
|
|
58
60
|
const n = t == null ? void 0 : t.getBoundingClientRect();
|
|
59
61
|
return s.top - n.top;
|
|
60
|
-
},
|
|
62
|
+
}, m = () => `${Date.now().toString(36)}${Math.random().toString(36).substring(2)}`;
|
|
61
63
|
export {
|
|
62
|
-
|
|
64
|
+
f as a,
|
|
63
65
|
g as b,
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
66
|
+
R as c,
|
|
67
|
+
b as g,
|
|
68
|
+
m as u
|
|
67
69
|
};
|
package/lib/es/index.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { default as
|
|
2
|
-
import { M as
|
|
3
|
-
import { default as
|
|
4
|
-
import { D as
|
|
5
|
-
import { M as
|
|
6
|
-
import { default as
|
|
7
|
-
import { c as
|
|
1
|
+
import { default as v } from "./MdEditor.mjs";
|
|
2
|
+
import { M as E } from "./chunks/index.mjs";
|
|
3
|
+
import { default as P } from "./NormalToolbar.mjs";
|
|
4
|
+
import { D as j } from "./chunks/index2.mjs";
|
|
5
|
+
import { M as q } from "./chunks/index3.mjs";
|
|
6
|
+
import { default as z } from "./MdCatalog.mjs";
|
|
7
|
+
import { c as B } from "./chunks/config.mjs";
|
|
8
8
|
import "vue";
|
|
9
9
|
import "./chunks/index4.mjs";
|
|
10
10
|
import "@vavt/util";
|
|
@@ -13,7 +13,6 @@ import "codemirror";
|
|
|
13
13
|
import "@codemirror/view";
|
|
14
14
|
import "@codemirror/language-data";
|
|
15
15
|
import "@codemirror/lang-markdown";
|
|
16
|
-
import "@codemirror/lang-html";
|
|
17
16
|
import "@codemirror/commands";
|
|
18
17
|
import "@codemirror/language";
|
|
19
18
|
import "@lezer/highlight";
|
|
@@ -27,11 +26,11 @@ import "markdown-it-image-figures";
|
|
|
27
26
|
import "markdown-it-task-lists";
|
|
28
27
|
import "lru-cache";
|
|
29
28
|
export {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
29
|
+
j as DropdownToolbar,
|
|
30
|
+
z as MdCatalog,
|
|
31
|
+
v as MdEditor,
|
|
32
|
+
E as MdPreview,
|
|
33
|
+
q as ModalToolbar,
|
|
34
|
+
P as NormalToolbar,
|
|
35
|
+
B as config
|
|
37
36
|
};
|