md-editor-v3 4.0.3 → 4.0.4
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/LICENSE +4 -16
- package/lib/cjs/MdCatalog.cjs +1 -1
- package/lib/cjs/MdEditor.cjs +15 -15
- package/lib/cjs/MdPreview.cjs +1 -1
- package/lib/cjs/ModalToolbar.cjs +1 -1
- package/lib/cjs/chunks/dom.cjs +1 -1
- package/lib/cjs/chunks/index.cjs +3 -3
- package/lib/cjs/chunks/index4.cjs +2 -2
- package/lib/cjs/index.cjs +1 -1
- package/lib/es/MdCatalog.mjs +2 -2
- package/lib/es/MdEditor.mjs +135 -137
- package/lib/es/MdPreview.mjs +2 -2
- package/lib/es/ModalToolbar.mjs +1 -1
- package/lib/es/chunks/dom.mjs +1 -1
- package/lib/es/chunks/index.mjs +8 -8
- package/lib/es/chunks/index4.mjs +63 -53
- package/lib/es/index.mjs +1 -1
- package/lib/types/MdEditor/utils/index.d.ts +0 -26
- package/lib/umd/index.js +24 -24
- package/package.json +2 -1
- package/lib/cjs/chunks/event-bus.cjs +0 -1
- package/lib/es/chunks/event-bus.mjs +0 -38
- package/lib/types/MdEditor/utils/smooth-scroll.d.ts +0 -8
package/lib/es/MdPreview.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { M as x } from "./chunks/index.mjs";
|
|
2
2
|
import "vue";
|
|
3
3
|
import "./chunks/config.mjs";
|
|
4
|
-
import "./chunks/event-bus.mjs";
|
|
5
|
-
import "./chunks/dom.mjs";
|
|
6
4
|
import "./chunks/index4.mjs";
|
|
5
|
+
import "./chunks/dom.mjs";
|
|
6
|
+
import "@vavt/util";
|
|
7
7
|
import "medium-zoom";
|
|
8
8
|
import "copy-to-clipboard";
|
|
9
9
|
import "markdown-it";
|
package/lib/es/ModalToolbar.mjs
CHANGED
package/lib/es/chunks/dom.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { debounce as E } from "@vavt/util";
|
|
2
2
|
const L = (e, d) => {
|
|
3
3
|
const t = (n) => {
|
|
4
4
|
const o = e.parentElement || document.body, i = o.offsetWidth, m = o.offsetHeight, { clientWidth: u } = document.documentElement, { clientHeight: l } = document.documentElement, p = n.offsetX, v = n.offsetY, a = (f) => {
|
package/lib/es/chunks/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { inject as I, onMounted as C, watch as $, toRef as W, nextTick as A, shallowRef as R, ref as L, computed as M, defineComponent as Z, createVNode as H, Fragment as le, reactive as J, provide as F, onBeforeUnmount as ie } from "vue";
|
|
2
2
|
import { p as g, a as S, m as ce, k as N, e as B, h as se, f as j, i as ue, g as O, j as U, l as de, b as me, d as fe } from "./config.mjs";
|
|
3
|
-
import { b } from "./
|
|
4
|
-
import { a as P, u as
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
3
|
+
import { u as he, g as pe, b } from "./index4.mjs";
|
|
4
|
+
import { a as P, u as ge } from "./dom.mjs";
|
|
5
|
+
import ve from "medium-zoom";
|
|
6
|
+
import { debounce as X } from "@vavt/util";
|
|
7
7
|
import be from "copy-to-clipboard";
|
|
8
8
|
import ye from "markdown-it";
|
|
9
9
|
import we from "markdown-it-image-figures";
|
|
@@ -12,7 +12,7 @@ import $e from "lru-cache";
|
|
|
12
12
|
const Q = "onSave", Y = "changeCatalogVisible", Ce = "changeFullscreen", V = "pageFullscreenChanged", G = "fullscreenChanged", D = "previewChanged", z = "htmlPreviewChanged", K = "catalogVisibleChanged", Se = "textareaFocus", Ie = (e, a) => {
|
|
13
13
|
const l = I("editorId"), t = X(() => {
|
|
14
14
|
const n = document.querySelectorAll(`#${l}-preview img`);
|
|
15
|
-
n.length !== 0 &&
|
|
15
|
+
n.length !== 0 && ve(n, {
|
|
16
16
|
background: "#00000073"
|
|
17
17
|
});
|
|
18
18
|
});
|
|
@@ -54,7 +54,7 @@ const Q = "onSave", Y = "changeCatalogVisible", Ce = "changeFullscreen", V = "pa
|
|
|
54
54
|
}), $(
|
|
55
55
|
() => t.value.css,
|
|
56
56
|
(c) => {
|
|
57
|
-
|
|
57
|
+
ge(`${g}-hlCss`, "href", c);
|
|
58
58
|
}
|
|
59
59
|
), n;
|
|
60
60
|
}, Fe = _e, He = (e) => {
|
|
@@ -99,7 +99,7 @@ const Q = "onSave", Y = "changeCatalogVisible", Ce = "changeFullscreen", V = "pa
|
|
|
99
99
|
).forEach(async (r) => {
|
|
100
100
|
let d = c.get(r.innerText);
|
|
101
101
|
if (!d) {
|
|
102
|
-
const w =
|
|
102
|
+
const w = he(), p = await (n.value.renderAsync || n.value.render)(w, r.innerText);
|
|
103
103
|
d = typeof p == "string" ? p : p.svg, c.set(r.innerText, d);
|
|
104
104
|
}
|
|
105
105
|
const f = document.createElement("p");
|
|
@@ -310,7 +310,7 @@ const Q = "onSave", Y = "changeCatalogVisible", Ce = "changeFullscreen", V = "pa
|
|
|
310
310
|
language: v,
|
|
311
311
|
ignoreIllegals: !0
|
|
312
312
|
}).value : y = u.value.highlightAuto(k).value : y = f.utils.escapeHtml(k);
|
|
313
|
-
const T = o ?
|
|
313
|
+
const T = o ? pe(y.trim()) : `<span class="code-block">${y.trim()}</span>`;
|
|
314
314
|
return `<pre><code class="language-${v}" language=${v}>${T}</code></pre>`;
|
|
315
315
|
}
|
|
316
316
|
}), qe(f);
|
package/lib/es/chunks/index4.mjs
CHANGED
|
@@ -1,57 +1,67 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
var a = Object.defineProperty;
|
|
2
|
+
var c = (o, t, s) => t in o ? a(o, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : o[t] = s;
|
|
3
|
+
var p = (o, t, s) => (c(o, typeof t != "symbol" ? t + "" : t, s), s);
|
|
4
|
+
class u {
|
|
5
|
+
constructor() {
|
|
6
|
+
// 事件池
|
|
7
|
+
p(this, "pools", {});
|
|
8
|
+
}
|
|
9
|
+
// 移除事件监听
|
|
10
|
+
remove(t, s, n) {
|
|
11
|
+
const i = this.pools[t] && this.pools[t][s];
|
|
12
|
+
i && (this.pools[t][s] = i.filter((e) => e !== n));
|
|
13
|
+
}
|
|
14
|
+
// 清空全部事件,由于单一实例,多次注册会被共享内容
|
|
15
|
+
clear(t) {
|
|
16
|
+
this.pools[t] = {};
|
|
17
|
+
}
|
|
18
|
+
// 注册事件监听
|
|
19
|
+
on(t, s) {
|
|
20
|
+
return this.pools[t] || (this.pools[t] = {}), this.pools[t][s.name] || (this.pools[t][s.name] = []), this.pools[t][s.name].push(s.callback), this.pools[t][s.name].includes(s.callback);
|
|
21
|
+
}
|
|
22
|
+
// 触发事件
|
|
23
|
+
emit(t, s, ...n) {
|
|
24
|
+
this.pools[t] || (this.pools[t] = {});
|
|
25
|
+
const i = this.pools[t][s];
|
|
26
|
+
i && i.forEach((e) => {
|
|
27
|
+
try {
|
|
28
|
+
e(...n);
|
|
29
|
+
} catch (r) {
|
|
30
|
+
console.error(`${s} monitor event exception!`, r);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const g = new u(), b = (o, t = "image.png") => {
|
|
36
|
+
const s = o.split(","), n = s[0].match(/:(.*?);/);
|
|
37
|
+
if (n) {
|
|
38
|
+
const l = n[1], i = atob(s[1]);
|
|
39
|
+
let e = i.length;
|
|
40
|
+
const r = new Uint8Array(e);
|
|
41
|
+
for (; e--; )
|
|
42
|
+
r[e] = i.charCodeAt(e);
|
|
43
|
+
return new File([r], t, { type: l });
|
|
17
44
|
}
|
|
18
45
|
return null;
|
|
19
|
-
},
|
|
20
|
-
if (!
|
|
21
|
-
return
|
|
22
|
-
const
|
|
23
|
-
`),
|
|
24
|
-
return
|
|
25
|
-
|
|
26
|
-
}),
|
|
27
|
-
},
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}, p = (t, n = 200) => {
|
|
35
|
-
let e = 0, o = null;
|
|
36
|
-
return (...s) => {
|
|
37
|
-
const i = (r) => {
|
|
38
|
-
e === 0 && (e = r), r - e >= n ? (t.apply(void 0, o), o = null, e = 0) : window.requestAnimationFrame(i);
|
|
39
|
-
};
|
|
40
|
-
o === null && window.requestAnimationFrame(i), o = s;
|
|
41
|
-
};
|
|
42
|
-
}, w = (t, n) => {
|
|
43
|
-
const e = t == null ? void 0 : t.getBoundingClientRect();
|
|
44
|
-
if (n === document.documentElement)
|
|
45
|
-
return e.top - n.clientTop;
|
|
46
|
-
const o = n == null ? void 0 : n.getBoundingClientRect();
|
|
47
|
-
return e.top - o.top;
|
|
48
|
-
}, m = () => `${Date.now().toString(36)}${Math.random().toString(36).substring(2)}`;
|
|
46
|
+
}, f = (o) => {
|
|
47
|
+
if (!o)
|
|
48
|
+
return o;
|
|
49
|
+
const t = o.split(`
|
|
50
|
+
`), s = ['<span rn-wrapper aria-hidden="true">'];
|
|
51
|
+
return t.forEach(() => {
|
|
52
|
+
s.push("<span></span>");
|
|
53
|
+
}), s.push("</span>"), `<span class="code-block">${o}</span>${s.join("")}`;
|
|
54
|
+
}, m = (o, t) => {
|
|
55
|
+
const s = o == null ? void 0 : o.getBoundingClientRect();
|
|
56
|
+
if (t === document.documentElement)
|
|
57
|
+
return s.top - t.clientTop;
|
|
58
|
+
const n = t == null ? void 0 : t.getBoundingClientRect();
|
|
59
|
+
return s.top - n.top;
|
|
60
|
+
}, R = () => `${Date.now().toString(36)}${Math.random().toString(36).substring(2)}`;
|
|
49
61
|
export {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
p as t,
|
|
56
|
-
m as u
|
|
62
|
+
b as a,
|
|
63
|
+
g as b,
|
|
64
|
+
m as c,
|
|
65
|
+
f as g,
|
|
66
|
+
R as u
|
|
57
67
|
};
|
package/lib/es/index.mjs
CHANGED
|
@@ -6,8 +6,8 @@ import { M as k } from "./chunks/index3.mjs";
|
|
|
6
6
|
import { default as y } from "./MdCatalog.mjs";
|
|
7
7
|
import { c as A } from "./chunks/config.mjs";
|
|
8
8
|
import "vue";
|
|
9
|
-
import "./chunks/event-bus.mjs";
|
|
10
9
|
import "./chunks/index4.mjs";
|
|
10
|
+
import "@vavt/util";
|
|
11
11
|
import "./chunks/dom.mjs";
|
|
12
12
|
import "codemirror";
|
|
13
13
|
import "@codemirror/view";
|
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* js模拟a链接点击
|
|
3
|
-
*
|
|
4
|
-
* @param {string} url 目标地址
|
|
5
|
-
* @param {*} option 是否新窗口、是否要求不跟踪
|
|
6
|
-
*/
|
|
7
|
-
export declare const goto: (url: string, option?: {
|
|
8
|
-
newWindow: boolean;
|
|
9
|
-
nofollow: boolean;
|
|
10
|
-
}) => void;
|
|
11
1
|
/**
|
|
12
2
|
* 转换base64为file对象
|
|
13
3
|
* 方法来自网络
|
|
@@ -24,22 +14,6 @@ export declare const base642File: (base64: string, fileName?: string) => File |
|
|
|
24
14
|
* @returns string
|
|
25
15
|
*/
|
|
26
16
|
export declare const generateCodeRowNumber: (code: string) => string;
|
|
27
|
-
/**
|
|
28
|
-
* 防抖方法封装
|
|
29
|
-
*
|
|
30
|
-
* @param fn 目标方法
|
|
31
|
-
* @param ms 防抖延迟
|
|
32
|
-
* @returns
|
|
33
|
-
*/
|
|
34
|
-
export declare const debounce: (fn: (...params: Array<any>) => any, ms?: number) => (...params: Array<any>) => Promise<unknown>;
|
|
35
|
-
/**
|
|
36
|
-
* 节流函数
|
|
37
|
-
*
|
|
38
|
-
* @param fn 目标方法
|
|
39
|
-
* @param ms 节流延迟
|
|
40
|
-
* @returns
|
|
41
|
-
*/
|
|
42
|
-
export declare const throttle: (fn: (...params: Array<any>) => any, ms?: number) => (...params: Array<any>) => void;
|
|
43
17
|
/**
|
|
44
18
|
* 逻辑分离katex相关文本
|
|
45
19
|
* 不再采用正确匹配,会导致性能问题
|