md-editor-v3 4.6.1 → 4.6.2-beta.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.
Files changed (58) hide show
  1. package/lib/cjs/MdCatalog.cjs +1 -1
  2. package/lib/cjs/MdEditor.cjs +3 -3
  3. package/lib/cjs/MdModal.cjs +1 -1
  4. package/lib/cjs/MdPreview.cjs +1 -1
  5. package/lib/cjs/ModalToolbar.cjs +1 -1
  6. package/lib/cjs/chunks/index.cjs +1 -8
  7. package/lib/cjs/chunks/index3.cjs +2 -1
  8. package/lib/cjs/chunks/index4.cjs +8 -2
  9. package/lib/cjs/index.cjs +1 -1
  10. package/lib/es/DropdownToolbar.mjs +2 -2
  11. package/lib/es/MdCatalog.mjs +9 -9
  12. package/lib/es/MdEditor.mjs +137 -135
  13. package/lib/es/MdModal.mjs +1 -1
  14. package/lib/es/MdPreview.mjs +2 -2
  15. package/lib/es/ModalToolbar.mjs +1 -1
  16. package/lib/es/chunks/config.mjs +11 -11
  17. package/lib/es/chunks/index.mjs +138 -1231
  18. package/lib/es/chunks/index2.mjs +2 -2
  19. package/lib/es/chunks/index3.mjs +79 -163
  20. package/lib/es/chunks/index4.mjs +1255 -77
  21. package/lib/es/config.mjs +1 -1
  22. package/lib/es/index.mjs +18 -17
  23. package/lib/preview.css +1 -1
  24. package/lib/style.css +1 -1
  25. package/lib/types/DropdownToolbar/DropdownToolbar.d.ts +1 -1
  26. package/lib/types/DropdownToolbar/index.d.ts +59 -33
  27. package/lib/types/MdCatalog/CatalogLink.d.ts +1 -1
  28. package/lib/types/MdCatalog/MdCatalog.d.ts +1 -1
  29. package/lib/types/MdCatalog/index.d.ts +59 -44
  30. package/lib/types/MdEditor/Editor.d.ts +1 -1
  31. package/lib/types/MdEditor/components/Checkbox/index.d.ts +1 -1
  32. package/lib/types/MdEditor/components/Divider/index.d.ts +1 -1
  33. package/lib/types/MdEditor/components/Dropdown/index.d.ts +1 -1
  34. package/lib/types/MdEditor/components/Icon/Icon.d.ts +1 -1
  35. package/lib/types/MdEditor/components/Icon/index.d.ts +1 -1
  36. package/lib/types/MdEditor/components/Modal/Modal.d.ts +1 -1
  37. package/lib/types/MdEditor/components/Modal/index.d.ts +60 -48
  38. package/lib/types/MdEditor/index.d.ts +101 -225
  39. package/lib/types/MdEditor/layouts/Content/ContentPreview.d.ts +1 -1
  40. package/lib/types/MdEditor/layouts/Content/index.d.ts +1 -1
  41. package/lib/types/MdEditor/layouts/Footer/MarkdownTotal.d.ts +1 -1
  42. package/lib/types/MdEditor/layouts/Footer/ScrollAuto.d.ts +1 -1
  43. package/lib/types/MdEditor/layouts/Footer/index.d.ts +1 -1
  44. package/lib/types/MdEditor/layouts/Modals/Clip.d.ts +1 -1
  45. package/lib/types/MdEditor/layouts/Modals/Link.d.ts +1 -1
  46. package/lib/types/MdEditor/layouts/Modals/index.d.ts +1 -1
  47. package/lib/types/MdEditor/layouts/Toolbar/TableShape.d.ts +1 -1
  48. package/lib/types/MdEditor/layouts/Toolbar/index.d.ts +1 -1
  49. package/lib/types/MdEditor/type.d.ts +3 -1
  50. package/lib/types/MdEditor/utils/vue-tsx.d.ts +1 -1
  51. package/lib/types/MdPreview/MdPreview.d.ts +1 -1
  52. package/lib/types/MdPreview/index.d.ts +72 -114
  53. package/lib/types/ModalToolbar/ModalToolbar.d.ts +1 -1
  54. package/lib/types/ModalToolbar/index.d.ts +64 -58
  55. package/lib/types/NormalToolbar/NormalToolbar.d.ts +1 -1
  56. package/lib/types/NormalToolbar/index.d.ts +56 -24
  57. package/lib/umd/index.js +32 -32
  58. package/package.json +9 -8
@@ -137,6 +137,6 @@ const B = {
137
137
  });
138
138
  y.install = (e) => (e.component(y.name, y), e);
139
139
  export {
140
- y as D,
141
- F as a
140
+ F as D,
141
+ y as a
142
142
  };
@@ -1,171 +1,87 @@
1
- import { defineComponent as v, createVNode as t, inject as k, h as M, ref as f, reactive as b, computed as j, onMounted as F, onBeforeUnmount as w, watch as p, nextTick as S } from "vue";
2
- import { p as l, a as H } from "./config.mjs";
3
- import { g as y } from "./vue-tsx.mjs";
4
- import { k as g } from "./dom.mjs";
5
- const T = /* @__PURE__ */ v({
6
- props: {
7
- name: {
8
- type: String,
9
- default: ""
10
- }
11
- },
12
- setup(e) {
13
- return () => H.iconfontType === "svg" ? t("svg", {
14
- class: `${l}-icon`,
15
- "aria-hidden": "true"
16
- }, [t("use", {
17
- "xlink:href": `#${l}-icon-${e.name}`
18
- }, null)]) : t("i", {
19
- class: `${l}-iconfont ${l}-icon-${e.name}`
20
- }, null);
1
+ var r = Object.defineProperty;
2
+ var p = (o, s, t) => s in o ? r(o, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[s] = t;
3
+ var i = (o, s, t) => (p(o, typeof s != "symbol" ? s + "" : s, t), t);
4
+ class h {
5
+ constructor() {
6
+ // 事件池
7
+ i(this, "pools", {});
21
8
  }
22
- }), C = /* @__PURE__ */ v({
23
- props: {
24
- name: {
25
- type: String,
26
- default: ""
27
- }
28
- },
29
- setup(e) {
30
- const c = k("customIcon");
31
- return () => {
32
- const i = c.value[e.name];
33
- return typeof i == "object" ? typeof i.component == "object" ? M(i.component, i.props) : t("span", {
34
- innerHTML: i.component
35
- }, null) : t(T, {
36
- name: e.name
37
- }, null);
38
- };
9
+ // 移除事件监听
10
+ remove(s, t, n) {
11
+ const a = this.pools[s] && this.pools[s][t];
12
+ a && (this.pools[s][t] = a.filter((e) => e !== n));
39
13
  }
40
- }), z = {
41
- title: {
42
- type: String,
43
- default: ""
44
- },
45
- visible: {
46
- type: Boolean,
47
- default: !1
48
- },
49
- width: {
50
- type: String,
51
- default: "auto"
52
- },
53
- height: {
54
- type: String,
55
- default: "auto"
56
- },
57
- onClose: {
58
- type: Function
59
- },
60
- showAdjust: {
61
- type: Boolean,
62
- default: !1
63
- },
64
- isFullscreen: {
65
- type: Boolean,
66
- default: !1
67
- },
68
- onAdjust: {
69
- type: Function,
70
- default: () => {
71
- }
14
+ // 清空全部事件,由于单一实例,多次注册会被共享内容
15
+ clear(s) {
16
+ this.pools[s] = {};
72
17
  }
73
- }, h = /* @__PURE__ */ v({
74
- name: "MdModal",
75
- props: z,
76
- emits: ["onClose"],
77
- setup(e, c) {
78
- const i = f(e.visible), a = f([`${l}-modal`]), m = f(), r = f();
79
- let d = () => {
80
- };
81
- const o = b({
82
- initPos: {
83
- left: "0px",
84
- top: "0px"
85
- },
86
- historyPos: {
87
- left: "0px",
88
- top: "0px"
18
+ // 注册事件监听
19
+ on(s, t) {
20
+ return this.pools[s] || (this.pools[s] = {}), this.pools[s][t.name] || (this.pools[s][t.name] = []), this.pools[s][t.name].push(t.callback), this.pools[s][t.name].includes(t.callback);
21
+ }
22
+ // 触发事件
23
+ emit(s, t, ...n) {
24
+ this.pools[s] || (this.pools[s] = {});
25
+ const a = this.pools[s][t];
26
+ a && a.forEach((e) => {
27
+ try {
28
+ e(...n);
29
+ } catch (c) {
30
+ console.error(`${t} monitor event exception!`, c);
89
31
  }
90
- }), P = j(() => e.isFullscreen ? {
91
- width: "100%",
92
- height: "100%"
93
- } : {
94
- width: e.width,
95
- height: e.height
96
32
  });
97
- return F(() => {
98
- d = g(r.value, (s, n) => {
99
- o.initPos.left = s + "px", o.initPos.top = n + "px";
100
- });
101
- }), w(() => {
102
- d();
103
- }), p(() => e.isFullscreen, (s) => {
104
- s ? d() : d = g(r.value, (n, u) => {
105
- o.initPos.left = n + "px", o.initPos.top = u + "px";
106
- });
107
- }), p(() => e.visible, (s) => {
108
- s ? (a.value.push("zoom-in"), i.value = s, S(() => {
109
- const n = m.value.offsetWidth / 2, u = m.value.offsetHeight / 2, $ = document.documentElement.clientWidth / 2, x = document.documentElement.clientHeight / 2;
110
- o.initPos.left = $ - n + "px", o.initPos.top = x - u + "px";
111
- }), setTimeout(() => {
112
- a.value = a.value.filter((n) => n !== "zoom-in");
113
- }, 140)) : (a.value.push("zoom-out"), setTimeout(() => {
114
- a.value = a.value.filter((n) => n !== "zoom-out"), i.value = s;
115
- }, 130));
116
- }), () => {
117
- const s = y({
118
- ctx: c
119
- }), n = y({
120
- props: e,
121
- ctx: c
122
- }, "title");
123
- return t("div", {
124
- style: {
125
- display: i.value ? "block" : "none"
126
- }
127
- }, [t("div", {
128
- class: `${l}-modal-mask`,
129
- onClick: () => {
130
- e.onClose ? e.onClose() : c.emit("onClose");
131
- }
132
- }, null), t("div", {
133
- class: a.value,
134
- style: {
135
- ...o.initPos,
136
- ...P.value
137
- },
138
- ref: m
139
- }, [t("div", {
140
- class: `${l}-modal-header`,
141
- ref: r
142
- }, [n || ""]), t("div", {
143
- class: `${l}-modal-body`
144
- }, [s]), t("div", {
145
- class: `${l}-modal-func`
146
- }, [e.showAdjust && t("div", {
147
- class: `${l}-modal-adjust`,
148
- onClick: (u) => {
149
- u.stopPropagation(), e.isFullscreen ? o.initPos = o.historyPos : (o.historyPos = o.initPos, o.initPos = {
150
- left: "0",
151
- top: "0"
152
- }), e.onAdjust(!e.isFullscreen);
153
- }
154
- }, [t(C, {
155
- name: e.isFullscreen ? "suoxiao" : "fangda"
156
- }, null)]), t("div", {
157
- class: `${l}-modal-close`,
158
- onClick: (u) => {
159
- u.stopPropagation(), e.onClose ? e.onClose() : c.emit("onClose");
160
- }
161
- }, [t(C, {
162
- name: "close"
163
- }, null)])])])]);
164
- };
165
33
  }
166
- });
167
- h.install = (e) => (e.component(h.name, h), e);
34
+ }
35
+ const C = new h(), E = "onSave", g = "changeCatalogVisible", A = "changeFullscreen", R = "pageFullscreenChanged", _ = "fullscreenChanged", d = "previewChanged", L = "htmlPreviewChanged", N = "catalogVisibleChanged", f = "textareaFocus", S = "buildFinished", b = "errorCatcher", G = "replace", H = "uploadImage", T = "openModals", F = "ctrlZ", m = "ctrlShiftZ", I = "catalogChanged", D = "pushCatalog", O = (o, s = "image.png") => {
36
+ const t = o.split(","), n = t[0].match(/:(.*?);/);
37
+ if (n) {
38
+ const l = n[1], a = atob(t[1]);
39
+ let e = a.length;
40
+ const c = new Uint8Array(e);
41
+ for (; e--; )
42
+ c[e] = a.charCodeAt(e);
43
+ return new File([c], s, { type: l });
44
+ }
45
+ return null;
46
+ }, w = (o) => {
47
+ if (!o)
48
+ return o;
49
+ const s = o.split(`
50
+ `), t = ['<span rn-wrapper aria-hidden="true">'];
51
+ return s.forEach(() => {
52
+ t.push("<span></span>");
53
+ }), t.push("</span>"), `<span class="code-block">${o}</span>${t.join("")}`;
54
+ }, P = (o, s) => {
55
+ if (!o || !s)
56
+ return 0;
57
+ const t = o == null ? void 0 : o.getBoundingClientRect();
58
+ if (s === document.documentElement)
59
+ return t.top - s.clientTop;
60
+ const n = s == null ? void 0 : s.getBoundingClientRect();
61
+ return t.top - n.top;
62
+ }, U = () => `${Date.now().toString(36)}${Math.random().toString(36).substring(2)}`;
168
63
  export {
169
- C as I,
170
- h as M
64
+ S as B,
65
+ I as C,
66
+ b as E,
67
+ _ as F,
68
+ L as H,
69
+ E as O,
70
+ D as P,
71
+ G as R,
72
+ f as T,
73
+ H as U,
74
+ w as a,
75
+ C as b,
76
+ g as c,
77
+ R as d,
78
+ d as e,
79
+ N as f,
80
+ P as g,
81
+ A as h,
82
+ O as i,
83
+ T as j,
84
+ m as k,
85
+ F as l,
86
+ U as u
171
87
  };