md-editor-v3 4.0.3 → 4.0.4-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.
@@ -1,57 +1,67 @@
1
- const a = (t, n = {
2
- newWindow: !0,
3
- nofollow: !0
4
- }) => {
5
- t || console.error("error link!");
6
- const e = document.createElement("a");
7
- e.href = t, e.style.display = "none", n.newWindow && (e.target = "_blank"), n.nofollow && (e.rel = "noopener noreferrer"), document.body.appendChild(e), e.click(), document.body.removeChild(e);
8
- }, u = (t, n = "image.png") => {
9
- const e = t.split(","), o = e[0].match(/:(.*?);/);
10
- if (o) {
11
- const s = o[1], i = atob(e[1]);
12
- let r = i.length;
13
- const l = new Uint8Array(r);
14
- for (; r--; )
15
- l[r] = i.charCodeAt(r);
16
- return new File([l], n, { type: s });
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
- }, c = (t) => {
20
- if (!t)
21
- return t;
22
- const n = t.split(`
23
- `), e = ['<span rn-wrapper aria-hidden="true">'];
24
- return n.forEach(() => {
25
- e.push("<span></span>");
26
- }), e.push("</span>"), `<span class="code-block">${t}</span>${e.join("")}`;
27
- }, d = (t, n = 200) => {
28
- let e = 0;
29
- return (...o) => new Promise((s) => {
30
- e && (clearTimeout(e), s("cancel")), e = window.setTimeout(() => {
31
- t.apply(void 0, o), e = 0, s("done");
32
- }, n);
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
- c as a,
51
- u as b,
52
- w as c,
53
- d,
54
- a as g,
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
  * 不再采用正确匹配,会导致性能问题