md-editor-v3 4.2.1 → 4.3.0-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,6 +1,6 @@
1
1
  import { defineComponent as r, createVNode as l } from "vue";
2
- import { p as a } from "./chunks/config.mjs";
3
- import { g as c } from "./chunks/vue-tsx.mjs";
2
+ import { p as c } from "./chunks/config.mjs";
3
+ import { g as a } from "./chunks/vue-tsx.mjs";
4
4
  const m = {
5
5
  title: {
6
6
  type: String,
@@ -12,6 +12,12 @@ const m = {
12
12
  },
13
13
  onClick: {
14
14
  type: Function
15
+ },
16
+ /**
17
+ * 没有意义,仅用于规避克隆组件自动嵌入insert方法时,传入的是该组件而产生的waring
18
+ */
19
+ insert: {
20
+ type: Function
15
21
  }
16
22
  }, e = /* @__PURE__ */ r({
17
23
  name: "NormalToolbar",
@@ -19,17 +25,17 @@ const m = {
19
25
  emits: ["onClick"],
20
26
  setup(t, o) {
21
27
  return () => {
22
- const n = c({
28
+ const i = a({
23
29
  props: t,
24
30
  ctx: o
25
31
  }, "trigger");
26
32
  return l("div", {
27
- class: `${a}-toolbar-item`,
33
+ class: `${c}-toolbar-item`,
28
34
  title: t.title,
29
- onClick: (i) => {
30
- t.onClick instanceof Function ? t.onClick(i) : o.emit("onClick", i);
35
+ onClick: (n) => {
36
+ t.onClick instanceof Function ? t.onClick(n) : o.emit("onClick", n);
31
37
  }
32
- }, [n]);
38
+ }, [i]);
33
39
  };
34
40
  }
35
41
  });
@@ -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 H, defineComponent as Z, createVNode as F, Fragment as le, reactive as J, provide as M, onBeforeUnmount as ie } from "vue";
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
- }, Me = _e, Fe = (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({
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 = !l.value);
70
+ }), l.value = l.value + 1);
71
71
  };
72
72
  return $(
73
73
  () => o.value,
@@ -117,7 +117,7 @@ const Q = "onSave", Y = "changeCatalogVisible", Ce = "changeFullscreen", V = "pa
117
117
  }
118
118
  });
119
119
  } };
120
- }, He = Fe, xe = (e) => {
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" && !o.noMermaid) {
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 = Me(e), s = Re(e), { reRenderRef: r, replaceMermaid: m } = He(e), f = be({
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, noMermaid: e.noMermaid }), f.set({
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 = H(() => (e.noKatex || s.value) && (e.noHighlight || d.value));
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), () => F(le, null, [F("div", {
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
- }, [F("article", {
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 && F("div", {
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
- }, [F("div", {
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
- M("editorId", o), M(
456
+ F("editorId", o), F(
457
457
  "theme",
458
- H(() => e.theme)
459
- ), M(
458
+ M(() => e.theme)
459
+ ), F(
460
460
  "highlight",
461
- H(() => {
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
- ), M("showCodeRowNumber", e.showCodeRowNumber);
472
- const n = H(() => {
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
- M("usedLanguageText", n), M(
480
+ F("usedLanguageText", n), F(
481
481
  "previewTheme",
482
- H(() => e.previewTheme)
482
+ M(() => e.previewTheme)
483
483
  );
484
484
  }, mt = (e) => {
485
- ee(e), M("tabWidth", e.tabWidth);
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
- }), H(() => !e.toolbarsExclude.includes("catalog") && e.toolbars.includes("catalog") && a.value);
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
- }), () => F("div", {
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
- }, [F(Xe, {
1056
+ }, [H(Xe, {
1057
1057
  modelValue: e.modelValue,
1058
1058
  onHtmlChanged: (i) => {
1059
1059
  e.onHtmlChanged ? e.onHtmlChanged(i) : o.emit("onHtmlChanged", i);
@@ -1,6 +1,6 @@
1
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 d } from "./vue-tsx.mjs";
3
+ import { g as u } from "./vue-tsx.mjs";
4
4
  const B = {
5
5
  overlay: {
6
6
  type: [String, Object],
@@ -20,7 +20,7 @@ const B = {
20
20
  type: String,
21
21
  default: "html"
22
22
  }
23
- }, I = /* @__PURE__ */ H({
23
+ }, F = /* @__PURE__ */ H({
24
24
  props: B,
25
25
  setup(e, a) {
26
26
  const i = `${g}-dropdown-hidden`, t = E({
@@ -34,10 +34,10 @@ const B = {
34
34
  const o = r.value, l = n.value;
35
35
  if (!o || !l)
36
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;
37
+ const v = o.getBoundingClientRect(), d = o.offsetTop, L = o.offsetLeft, S = v.height, b = v.width, w = ((p = document.querySelector(e.relative)) == null ? void 0 : p.scrollLeft) || 0;
38
38
  t.overlayStyle = {
39
39
  ...t.overlayStyle,
40
- top: u + S + "px",
40
+ top: d + S + "px",
41
41
  left: L - l.offsetWidth / 2 + b / 2 - w + "px"
42
42
  }, e.onChange(!0);
43
43
  }, m = () => {
@@ -57,24 +57,24 @@ const B = {
57
57
  }), $(() => {
58
58
  r.value.removeEventListener("mouseenter", y), r.value.removeEventListener("mouseleave", s), n.value.removeEventListener("mouseenter", m), n.value.removeEventListener("mouseleave", s);
59
59
  }), () => {
60
- const o = d({
60
+ const o = u({
61
61
  ctx: a
62
- }), l = d({
62
+ }), l = u({
63
63
  props: e,
64
64
  ctx: a
65
65
  }, "overlay"), v = O(o instanceof Array ? o[0] : o, {
66
66
  ref: r
67
- }), u = c("div", {
67
+ }), d = c("div", {
68
68
  class: [`${g}-dropdown`, t.overlayClass],
69
69
  style: t.overlayStyle,
70
70
  ref: n
71
71
  }, [c("div", {
72
72
  class: `${g}-dropdown-overlay`
73
73
  }, [l instanceof Array ? l[0] : l])]);
74
- return [v, u];
74
+ return [v, d];
75
75
  };
76
76
  }
77
- }), A = {
77
+ }), I = {
78
78
  title: {
79
79
  type: String,
80
80
  default: ""
@@ -92,22 +92,28 @@ const B = {
92
92
  // 下拉框中的内容
93
93
  overlay: {
94
94
  type: [String, Object]
95
+ },
96
+ /**
97
+ * 没有意义,仅用于规避克隆组件自动嵌入insert方法时,传入的是该组件而产生的waring
98
+ */
99
+ insert: {
100
+ type: Function
95
101
  }
96
102
  }, f = /* @__PURE__ */ H({
97
103
  name: "DropdownToolbar",
98
- props: A,
104
+ props: I,
99
105
  emits: ["onChange"],
100
106
  setup(e, a) {
101
107
  const i = j("editorId");
102
108
  return () => {
103
- const t = d({
109
+ const t = u({
104
110
  props: e,
105
111
  ctx: a
106
- }, "trigger"), r = d({
112
+ }, "trigger"), r = u({
107
113
  props: e,
108
114
  ctx: a
109
115
  }, "overlay");
110
- return c(I, {
116
+ return c(F, {
111
117
  relative: `#${i}-toolbar-wrapper`,
112
118
  visible: e.visible,
113
119
  onChange: (n) => {
@@ -126,5 +132,5 @@ const B = {
126
132
  f.install = (e) => (e.component(f.name, f), e);
127
133
  export {
128
134
  f as D,
129
- I as a
135
+ F as a
130
136
  };
@@ -55,7 +55,7 @@ const T = {
55
55
  left: "0px",
56
56
  top: "0px"
57
57
  }
58
- }), j = P(() => e.isFullscreen ? {
58
+ }), F = P(() => e.isFullscreen ? {
59
59
  width: "100%",
60
60
  height: "100%"
61
61
  } : {
@@ -74,8 +74,8 @@ const T = {
74
74
  });
75
75
  }), v(() => e.visible, (s) => {
76
76
  s ? (o.value.push("zoom-in"), c.value = s, S(() => {
77
- const i = d.value.offsetWidth / 2, u = d.value.offsetHeight / 2, F = document.documentElement.clientWidth / 2, k = document.documentElement.clientHeight / 2;
78
- l.initPos.left = F - i + "px", l.initPos.top = k - u + "px";
77
+ const i = d.value.offsetWidth / 2, u = d.value.offsetHeight / 2, j = document.documentElement.clientWidth / 2, k = document.documentElement.clientHeight / 2;
78
+ l.initPos.left = j - i + "px", l.initPos.top = k - u + "px";
79
79
  }), setTimeout(() => {
80
80
  o.value = o.value.filter((i) => i !== "zoom-in");
81
81
  }, 140)) : (o.value.push("zoom-out"), setTimeout(() => {
@@ -100,7 +100,7 @@ const T = {
100
100
  class: o.value,
101
101
  style: {
102
102
  ...l.initPos,
103
- ...j.value
103
+ ...F.value
104
104
  },
105
105
  ref: d
106
106
  }, [t("div", {
@@ -140,7 +140,7 @@ const T = {
140
140
  function M(e) {
141
141
  return typeof e == "function" || Object.prototype.toString.call(e) === "[object Object]" && !x(e);
142
142
  }
143
- const z = {
143
+ const p = {
144
144
  title: {
145
145
  type: String,
146
146
  default: ""
@@ -183,10 +183,16 @@ const z = {
183
183
  },
184
184
  onAdjust: {
185
185
  type: Function
186
+ },
187
+ /**
188
+ * 没有意义,仅用于规避克隆组件自动嵌入insert方法时,传入的是该组件而产生的waring
189
+ */
190
+ insert: {
191
+ type: Function
186
192
  }
187
193
  }, g = /* @__PURE__ */ C({
188
194
  name: "ModalToolbar",
189
- props: z,
195
+ props: p,
190
196
  emits: ["onClick", "onClose", "onAdjust"],
191
197
  setup(e, a) {
192
198
  return () => {
package/lib/es/index.mjs CHANGED
@@ -1,10 +1,10 @@
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";
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";
8
8
  import "vue";
9
9
  import "./chunks/index4.mjs";
10
10
  import "@vavt/util";
@@ -13,6 +13,7 @@ import "codemirror";
13
13
  import "@codemirror/view";
14
14
  import "@codemirror/language-data";
15
15
  import "@codemirror/lang-markdown";
16
+ import "@codemirror/lang-html";
16
17
  import "@codemirror/commands";
17
18
  import "@codemirror/language";
18
19
  import "@lezer/highlight";
@@ -26,11 +27,11 @@ import "markdown-it-image-figures";
26
27
  import "markdown-it-task-lists";
27
28
  import "lru-cache";
28
29
  export {
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
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
36
37
  };