md-editor-v3 4.2.1-beta.0 → 4.2.1

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.
@@ -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", document.body.appendChild(r);
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;
@@ -1,11 +1,7 @@
1
- import { defineComponent as H, reactive as T, ref as L, watch as k, onMounted as D, onBeforeUnmount as $, cloneVNode as O, createVNode as d, inject as j } from "vue";
1
+ import { defineComponent as H, reactive as E, ref as C, watch as T, onMounted as D, onBeforeUnmount as $, cloneVNode as O, createVNode as c, inject as j } from "vue";
2
2
  import { p as g } from "./config.mjs";
3
- import { g as u } from "./vue-tsx.mjs";
3
+ import { g as d } from "./vue-tsx.mjs";
4
4
  const B = {
5
- trigger: {
6
- type: String,
7
- default: "hover"
8
- },
9
5
  overlay: {
10
6
  type: [String, Object],
11
7
  default: ""
@@ -27,56 +23,55 @@ const B = {
27
23
  }, I = /* @__PURE__ */ H({
28
24
  props: B,
29
25
  setup(e, a) {
30
- const s = `${g}-dropdown-hidden`, t = T({
31
- overlayClass: [s],
26
+ const i = `${g}-dropdown-hidden`, t = E({
27
+ overlayClass: [i],
32
28
  overlayStyle: {},
33
29
  triggerHover: !1,
34
30
  overlayHover: !1
35
- }), o = L(), n = L(), v = () => {
36
- var E;
37
- e.trigger === "hover" && (t.triggerHover = !0);
38
- const r = o.value, l = n.value, i = r.getBoundingClientRect(), f = r.offsetTop, S = r.offsetLeft, b = i.height, p = i.width, w = ((E = document.querySelector(e.relative)) == null ? void 0 : E.scrollLeft) || 0;
31
+ }), r = C(), n = C(), y = () => {
32
+ var p;
33
+ t.triggerHover = !0;
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;
39
38
  t.overlayStyle = {
40
39
  ...t.overlayStyle,
41
- top: f + b + "px",
42
- left: S - l.offsetWidth / 2 + p / 2 - w + "px"
40
+ top: u + S + "px",
41
+ left: L - l.offsetWidth / 2 + b / 2 - w + "px"
43
42
  }, e.onChange(!0);
44
43
  }, m = () => {
45
44
  t.overlayHover = !0;
46
45
  };
47
- k(() => e.visible, (r) => {
48
- r ? t.overlayClass = t.overlayClass.filter((l) => l !== s) : t.overlayClass.push(s);
46
+ T(() => e.visible, (o) => {
47
+ o ? t.overlayClass = t.overlayClass.filter((l) => l !== i) : t.overlayClass.push(i);
49
48
  });
50
- const h = (r) => {
51
- const l = o.value, i = n.value;
52
- !l.contains(r.target) && !i.contains(r.target) && e.onChange(!1);
53
- };
54
- let C = -1;
55
- const c = (r) => {
56
- o.value === r.target ? t.triggerHover = !1 : t.overlayHover = !1, clearTimeout(C), C = window.setTimeout(() => {
49
+ let h = -1;
50
+ const s = (o) => {
51
+ r.value === o.target ? t.triggerHover = !1 : t.overlayHover = !1, clearTimeout(h), h = window.setTimeout(() => {
57
52
  !t.overlayHover && !t.triggerHover && e.onChange(!1);
58
53
  }, 10);
59
54
  };
60
55
  return D(() => {
61
- e.trigger === "click" ? (o.value.addEventListener("click", v), document.addEventListener("click", h)) : (o.value.addEventListener("mouseenter", v), o.value.addEventListener("mouseleave", c), n.value.addEventListener("mouseenter", m), n.value.addEventListener("mouseleave", c));
56
+ r.value.addEventListener("mouseenter", y), r.value.addEventListener("mouseleave", s), n.value.addEventListener("mouseenter", m), n.value.addEventListener("mouseleave", s);
62
57
  }), $(() => {
63
- e.trigger === "click" ? (o.value.removeEventListener("click", v), document.removeEventListener("click", h)) : (o.value.removeEventListener("mouseenter", v), o.value.removeEventListener("mouseleave", c), n.value.removeEventListener("mouseenter", m), n.value.removeEventListener("mouseleave", c));
58
+ r.value.removeEventListener("mouseenter", y), r.value.removeEventListener("mouseleave", s), n.value.removeEventListener("mouseenter", m), n.value.removeEventListener("mouseleave", s);
64
59
  }), () => {
65
- const r = u({
60
+ const o = d({
66
61
  ctx: a
67
- }), l = u({
62
+ }), l = d({
68
63
  props: e,
69
64
  ctx: a
70
- }, "overlay"), i = O(r instanceof Array ? r[0] : r, {
71
- ref: o
72
- }), f = d("div", {
65
+ }, "overlay"), v = O(o instanceof Array ? o[0] : o, {
66
+ ref: r
67
+ }), u = c("div", {
73
68
  class: [`${g}-dropdown`, t.overlayClass],
74
69
  style: t.overlayStyle,
75
70
  ref: n
76
- }, [d("div", {
71
+ }, [c("div", {
77
72
  class: `${g}-dropdown-overlay`
78
73
  }, [l instanceof Array ? l[0] : l])]);
79
- return [i, f];
74
+ return [v, u];
80
75
  };
81
76
  }
82
77
  }), A = {
@@ -98,29 +93,29 @@ const B = {
98
93
  overlay: {
99
94
  type: [String, Object]
100
95
  }
101
- }, y = /* @__PURE__ */ H({
96
+ }, f = /* @__PURE__ */ H({
102
97
  name: "DropdownToolbar",
103
98
  props: A,
104
99
  emits: ["onChange"],
105
100
  setup(e, a) {
106
- const s = j("editorId");
101
+ const i = j("editorId");
107
102
  return () => {
108
- const t = u({
103
+ const t = d({
109
104
  props: e,
110
105
  ctx: a
111
- }, "trigger"), o = u({
106
+ }, "trigger"), r = d({
112
107
  props: e,
113
108
  ctx: a
114
109
  }, "overlay");
115
- return d(I, {
116
- relative: `#${s}-toolbar-wrapper`,
110
+ return c(I, {
111
+ relative: `#${i}-toolbar-wrapper`,
117
112
  visible: e.visible,
118
113
  onChange: (n) => {
119
114
  e.onChange instanceof Function ? e.onChange(n) : a.emit("onChange", n);
120
115
  },
121
- overlay: o
116
+ overlay: r
122
117
  }, {
123
- default: () => [d("div", {
118
+ default: () => [c("div", {
124
119
  class: `${g}-toolbar-item`,
125
120
  title: e.title || ""
126
121
  }, [t])]
@@ -128,8 +123,8 @@ const B = {
128
123
  };
129
124
  }
130
125
  });
131
- y.install = (e) => (e.component(y.name, y), e);
126
+ f.install = (e) => (e.component(f.name, f), e);
132
127
  export {
133
- y as D,
128
+ f as D,
134
129
  I as a
135
130
  };
@@ -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((e) => e !== n));
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((e) => {
26
+ i && i.forEach((r) => {
27
27
  try {
28
- e(...n);
29
- } catch (r) {
30
- console.error(`${s} monitor event exception!`, r);
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(), b = (o, t = "image.png") => {
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 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 });
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
- }, f = (o) => {
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
- }, m = (o, t) => {
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
- }, R = () => `${Date.now().toString(36)}${Math.random().toString(36).substring(2)}`;
62
+ }, m = () => `${Date.now().toString(36)}${Math.random().toString(36).substring(2)}`;
61
63
  export {
62
- b as a,
64
+ f as a,
63
65
  g as b,
64
- m as c,
65
- f as g,
66
- R as u
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 C } from "./MdEditor.mjs";
2
- import { M as N } from "./chunks/index.mjs";
3
- import { default as h } from "./NormalToolbar.mjs";
4
- import { D as k } from "./chunks/index2.mjs";
5
- import { M as y } from "./chunks/index3.mjs";
6
- import { default as A } from "./MdCatalog.mjs";
7
- import { c as F } from "./chunks/config.mjs";
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
- k as DropdownToolbar,
31
- A as MdCatalog,
32
- C as MdEditor,
33
- N as MdPreview,
34
- y as ModalToolbar,
35
- h as NormalToolbar,
36
- F as config
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
  };