md-editor-v3 6.0.1 → 6.1.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,119 +1,159 @@
1
- import { p as w } from "./config.mjs";
2
- const B = {
3
- copy: `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-copy ${w}-icon"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>`,
4
- "collapse-tips": `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-circle-chevron-left ${w}-icon"><circle cx="12" cy="12" r="10"/><path d="m14 16-4-4 4-4"/></svg>`,
5
- pin: '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-pin"><path d="M12 17v5"/><path d="M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z"/></svg>',
6
- "pin-off": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-pin-off"><path d="M12 17v5"/><path d="M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89"/><path d="m2 2 20 20"/><path d="M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11"/></svg>'
7
- }, y = (i, s) => typeof s[i] == "string" ? s[i] : B[i], I = (i, s) => {
8
- const t = (l) => {
9
- const o = i.parentElement || document.body, n = o.offsetWidth, c = o.offsetHeight, { clientWidth: r, clientHeight: d } = document.documentElement, h = l.offsetX, g = l.offsetY, f = (E) => {
10
- let a = E.x + document.body.scrollLeft - document.body.clientLeft - h, u = E.y + document.body.scrollTop - document.body.clientTop - g;
11
- a = a < 1 ? 1 : a < r - n - 1 ? a : r - n - 1, u = u < 1 ? 1 : u < d - c - 1 ? u : d - c - 1, s ? s(a, u) : (o.style.left = `${a}px`, o.style.top = `${u}px`);
1
+ import I from "@vavt/copy2clipboard";
2
+ import { p as i } from "./config.mjs";
3
+ const j = {
4
+ copy: `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-copy ${i}-icon"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>`,
5
+ "collapse-tips": `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-circle-chevron-left ${i}-icon"><circle cx="12" cy="12" r="10"/><path d="m14 16-4-4 4-4"/></svg>`,
6
+ pin: `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-pin ${i}-icon"><path d="M12 17v5"/><path d="M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z"/></svg>`,
7
+ "pin-off": `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-pin-off ${i}-icon"><path d="M12 17v5"/><path d="M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89"/><path d="m2 2 20 20"/><path d="M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11"/></svg>`,
8
+ check: `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-check ${i}-icon"><path d="M20 6 9 17l-5-5"/></svg>`
9
+ }, p = (d, s) => typeof s[d] == "string" ? s[d] : j[d], z = (d, s) => {
10
+ const e = (c) => {
11
+ const t = d.parentElement || document.body, n = t.offsetWidth, r = t.offsetHeight, { clientWidth: l, clientHeight: u } = document.documentElement, a = c.offsetX, w = c.offsetY, g = (y) => {
12
+ let h = y.x + document.body.scrollLeft - document.body.clientLeft - a, m = y.y + document.body.scrollTop - document.body.clientTop - w;
13
+ h = h < 1 ? 1 : h < l - n - 1 ? h : l - n - 1, m = m < 1 ? 1 : m < u - r - 1 ? m : u - r - 1, s ? s(h, m) : (t.style.left = `${h}px`, t.style.top = `${m}px`);
12
14
  };
13
- document.addEventListener("mousemove", f);
15
+ document.addEventListener("mousemove", g);
14
16
  const v = () => {
15
- document.removeEventListener("mousemove", f), document.removeEventListener("mouseup", v);
17
+ document.removeEventListener("mousemove", g), document.removeEventListener("mouseup", v);
16
18
  };
17
19
  document.addEventListener("mouseup", v);
18
20
  };
19
- return i.addEventListener("mousedown", t), () => {
20
- i.removeEventListener("mousedown", t);
21
+ return d.addEventListener("mousedown", e), () => {
22
+ d.removeEventListener("mousedown", e);
21
23
  };
22
- }, S = (i, s, t = "") => {
23
- const l = document.getElementById(s.id);
24
- if (l)
25
- t !== "" && (Reflect.get(window, t) ? s.onload?.call(l, new Event("load")) : s.onload && l.addEventListener("load", s.onload));
24
+ }, A = (d, s, e = "") => {
25
+ const c = document.getElementById(s.id);
26
+ if (c)
27
+ e !== "" && (Reflect.get(window, e) ? s.onload?.call(c, new Event("load")) : s.onload && c.addEventListener("load", s.onload));
26
28
  else {
27
- const o = { ...s };
28
- o.onload = null;
29
- const n = A(i, o);
29
+ const t = { ...s };
30
+ t.onload = null;
31
+ const n = D(d, t);
30
32
  s.onload && n.addEventListener("load", s.onload), document.head.appendChild(n);
31
33
  }
32
- }, V = (i, s) => {
33
- document.getElementById(s.id)?.remove(), S(i, s);
34
- }, A = (i, s) => {
35
- const t = document.createElement(i);
36
- return Object.keys(s).forEach((l) => {
37
- s[l] !== void 0 && (t[l] = s[l]);
38
- }), t;
39
- }, z = /* @__PURE__ */ (() => {
40
- const i = (t) => {
41
- if (!t)
34
+ }, b = (d, s) => {
35
+ document.getElementById(s.id)?.remove(), A(d, s);
36
+ }, D = (d, s) => {
37
+ const e = document.createElement(d);
38
+ return Object.keys(s).forEach((c) => {
39
+ s[c] !== void 0 && (e[c] = s[c]);
40
+ }), e;
41
+ }, V = (d, s) => {
42
+ const e = /* @__PURE__ */ new Map();
43
+ return d?.forEach((c) => {
44
+ let t = c.querySelector(`.${i}-mermaid-action`);
45
+ t ? t.querySelector(`.${i}-mermaid-copy`) || t.insertAdjacentHTML(
46
+ "beforeend",
47
+ `<span class="${i}-mermaid-copy">${p("copy", s.customIcon)}</span>`
48
+ ) : (c.insertAdjacentHTML(
49
+ "beforeend",
50
+ `<div class="${i}-mermaid-action"><span class="${i}-mermaid-copy">${p("copy", s.customIcon)}</span></div>`
51
+ ), t = c.querySelector(`.${i}-mermaid-action`));
52
+ const n = t.querySelector(`.${i}-mermaid-copy`);
53
+ let r = -1;
54
+ const l = () => {
55
+ clearTimeout(r), I(c.dataset.content || "").then(() => {
56
+ n.innerHTML = p("check", s.customIcon);
57
+ }).catch(() => {
58
+ n.innerHTML = p("copy", s.customIcon);
59
+ }).finally(() => {
60
+ r = window.setTimeout(() => {
61
+ n.innerHTML = p("copy", s.customIcon);
62
+ }, 1500);
63
+ });
64
+ };
65
+ n.addEventListener("click", l), e.set(c, {
66
+ removeClick: () => {
67
+ n.removeEventListener("click", l);
68
+ }
69
+ });
70
+ }), () => {
71
+ e.forEach(({ removeClick: c }) => {
72
+ c?.();
73
+ }), e.clear();
74
+ };
75
+ }, R = /* @__PURE__ */ (() => {
76
+ const d = (e) => {
77
+ if (!e)
42
78
  return () => {
43
79
  };
44
- const l = t.firstChild;
45
- let o = 1, n = 0, c = 0, r = !1, d, h, g, f = 1;
80
+ const c = e.firstChild;
81
+ let t = 1, n = 0, r = 0, l = !1, u, a, w, g = 1;
46
82
  const v = () => {
47
- l.style.transform = `translate(${n}px, ${c}px) scale(${o})`;
48
- }, E = (e) => {
49
- e.touches.length === 1 ? (r = !0, d = e.touches[0].clientX - n, h = e.touches[0].clientY - c) : e.touches.length === 2 && (g = Math.hypot(
50
- e.touches[0].clientX - e.touches[1].clientX,
51
- e.touches[0].clientY - e.touches[1].clientY
52
- ), f = o);
53
- }, a = (e) => {
54
- if (e.preventDefault(), r && e.touches.length === 1)
55
- n = e.touches[0].clientX - d, c = e.touches[0].clientY - h, v();
56
- else if (e.touches.length === 2) {
57
- const p = Math.hypot(
58
- e.touches[0].clientX - e.touches[1].clientX,
59
- e.touches[0].clientY - e.touches[1].clientY
60
- ) / g, m = o;
61
- o = f * (1 + (p - 1));
62
- const M = (e.touches[0].clientX + e.touches[1].clientX) / 2, k = (e.touches[0].clientY + e.touches[1].clientY) / 2, $ = l.getBoundingClientRect(), T = (M - $.left) / m, D = (k - $.top) / m;
63
- n -= T * (o - m), c -= D * (o - m), v();
83
+ c.style.transform = `translate(${n}px, ${r}px) scale(${t})`;
84
+ }, y = (o) => {
85
+ o.touches.length === 1 ? (l = !0, u = o.touches[0].clientX - n, a = o.touches[0].clientY - r) : o.touches.length === 2 && (w = Math.hypot(
86
+ o.touches[0].clientX - o.touches[1].clientX,
87
+ o.touches[0].clientY - o.touches[1].clientY
88
+ ), g = t);
89
+ }, h = (o) => {
90
+ if (o.preventDefault(), l && o.touches.length === 1)
91
+ n = o.touches[0].clientX - u, r = o.touches[0].clientY - a, v();
92
+ else if (o.touches.length === 2) {
93
+ const E = Math.hypot(
94
+ o.touches[0].clientX - o.touches[1].clientX,
95
+ o.touches[0].clientY - o.touches[1].clientY
96
+ ) / w, f = t;
97
+ t = g * (1 + (E - 1));
98
+ const M = (o.touches[0].clientX + o.touches[1].clientX) / 2, k = (o.touches[0].clientY + o.touches[1].clientY) / 2, H = c.getBoundingClientRect(), X = (M - H.left) / f, S = (k - H.top) / f;
99
+ n -= X * (t - f), r -= S * (t - f), v();
64
100
  }
65
- }, u = () => {
66
- r = !1;
67
- }, x = (e) => {
68
- e.preventDefault();
69
- const L = 0.02, p = o;
70
- e.deltaY < 0 ? o += L : o = Math.max(0.1, o - L);
71
- const m = l.getBoundingClientRect(), M = e.clientX - m.left, k = e.clientY - m.top;
72
- n -= M / p * (o - p), c -= k / p * (o - p), v();
73
- }, Y = (e) => {
74
- r = !0, d = e.clientX - n, h = e.clientY - c;
75
- }, X = (e) => {
76
- r && (n = e.clientX - d, c = e.clientY - h, v());
77
- }, C = () => {
78
- r = !1;
79
- }, H = () => {
80
- r = !1;
101
+ }, m = () => {
102
+ l = !1;
103
+ }, $ = (o) => {
104
+ o.preventDefault();
105
+ const L = 0.02, E = t;
106
+ o.deltaY < 0 ? t += L : t = Math.max(0.1, t - L);
107
+ const f = c.getBoundingClientRect(), M = o.clientX - f.left, k = o.clientY - f.top;
108
+ n -= M / E * (t - E), r -= k / E * (t - E), v();
109
+ }, x = (o) => {
110
+ l = !0, u = o.clientX - n, a = o.clientY - r;
111
+ }, C = (o) => {
112
+ l && (n = o.clientX - u, r = o.clientY - a, v());
113
+ }, T = () => {
114
+ l = !1;
115
+ }, Y = () => {
116
+ l = !1;
81
117
  };
82
- return t.addEventListener("touchstart", E, { passive: !1 }), t.addEventListener("touchmove", a, { passive: !1 }), t.addEventListener("touchend", u), t.addEventListener("wheel", x, { passive: !1 }), t.addEventListener("mousedown", Y), t.addEventListener("mousemove", X), t.addEventListener("mouseup", C), t.addEventListener("mouseleave", H), () => {
83
- t.removeEventListener("touchstart", E), t.removeEventListener("touchmove", a), t.removeEventListener("touchend", u), t.removeEventListener("wheel", x), t.removeEventListener("mousedown", Y), t.removeEventListener("mousemove", X), t.removeEventListener("mouseup", C), t.removeEventListener("mouseleave", H);
118
+ return e.addEventListener("touchstart", y, { passive: !1 }), e.addEventListener("touchmove", h, { passive: !1 }), e.addEventListener("touchend", m), e.addEventListener("wheel", $, { passive: !1 }), e.addEventListener("mousedown", x), e.addEventListener("mousemove", C), e.addEventListener("mouseup", T), e.addEventListener("mouseleave", Y), () => {
119
+ e.removeEventListener("touchstart", y), e.removeEventListener("touchmove", h), e.removeEventListener("touchend", m), e.removeEventListener("wheel", $), e.removeEventListener("mousedown", x), e.removeEventListener("mousemove", C), e.removeEventListener("mouseup", T), e.removeEventListener("mouseleave", Y);
84
120
  };
85
121
  };
86
- return (t, l) => {
87
- const o = /* @__PURE__ */ new Map();
88
- return t?.forEach((n) => {
89
- let c = n.querySelector(`.${w}-mermaid-action`);
90
- c || (n.insertAdjacentHTML(
122
+ return (e, c) => {
123
+ const t = /* @__PURE__ */ new Map();
124
+ return e?.forEach((n) => {
125
+ let r = n.querySelector(`.${i}-mermaid-action`);
126
+ r ? r.querySelector(`.${i}-mermaid-zoom`) || r.insertAdjacentHTML(
127
+ "beforeend",
128
+ `<span class="${i}-mermaid-zoom">${p("pin-off", c.customIcon)}</span>`
129
+ ) : (n.insertAdjacentHTML(
91
130
  "beforeend",
92
- `<div class="${w}-mermaid-action">${y("pin-off", l.customIcon)}</div>`
93
- ), c = n.querySelector(`.${w}-mermaid-action`));
94
- const r = () => {
95
- const d = o.get(n);
96
- if (d?.removeEvent)
97
- d.removeEvent(), n.removeAttribute("data-grab"), o.set(n, { removeClick: d.removeClick }), c.innerHTML = y("pin-off", l.customIcon);
131
+ `<div class="${i}-mermaid-action"><span class="${i}-mermaid-zoom">${p("pin-off", c.customIcon)}</span></div>`
132
+ ), r = n.querySelector(`.${i}-mermaid-action`));
133
+ const l = r.querySelector(`.${i}-mermaid-zoom`), u = () => {
134
+ const a = t.get(n);
135
+ if (a?.removeEvent)
136
+ a.removeEvent(), n.removeAttribute("data-grab"), t.set(n, { removeClick: a.removeClick }), l.innerHTML = p("pin-off", c.customIcon);
98
137
  else {
99
- const h = i(n);
100
- n.setAttribute("data-grab", ""), o.set(n, { removeEvent: h, removeClick: d?.removeClick }), c.innerHTML = y("pin", l.customIcon);
138
+ const w = d(n);
139
+ n.setAttribute("data-grab", ""), t.set(n, { removeEvent: w, removeClick: a?.removeClick }), l.innerHTML = p("pin", c.customIcon);
101
140
  }
102
141
  };
103
- c.addEventListener("click", r), o.set(n, {
104
- removeClick: () => c.removeEventListener("click", r)
142
+ l.addEventListener("click", u), t.set(n, {
143
+ removeClick: () => l.removeEventListener("click", u)
105
144
  });
106
145
  }), () => {
107
- o.forEach(({ removeEvent: n, removeClick: c }) => {
108
- n?.(), c?.();
109
- }), o.clear();
146
+ t.forEach(({ removeEvent: n, removeClick: r }) => {
147
+ n?.(), r?.();
148
+ }), t.clear();
110
149
  };
111
150
  };
112
151
  })();
113
152
  export {
114
- y as S,
115
- S as a,
116
- I as k,
117
- V as u,
118
- z
153
+ p as S,
154
+ A as a,
155
+ V as c,
156
+ z as k,
157
+ b as u,
158
+ R as z
119
159
  };