md-editor-v3 4.7.0 → 4.8.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.
Files changed (38) hide show
  1. package/README.md +17 -1
  2. package/lib/cjs/MdCatalog.cjs +1 -1
  3. package/lib/cjs/MdEditor.cjs +27 -27
  4. package/lib/cjs/MdModal.cjs +1 -1
  5. package/lib/cjs/MdPreview.cjs +1 -1
  6. package/lib/cjs/ModalToolbar.cjs +1 -1
  7. package/lib/cjs/chunks/config.cjs +1 -1
  8. package/lib/cjs/chunks/index.cjs +8 -1
  9. package/lib/cjs/chunks/index3.cjs +1 -2
  10. package/lib/cjs/chunks/index4.cjs +2 -8
  11. package/lib/cjs/config.cjs +1 -1
  12. package/lib/cjs/index.cjs +1 -1
  13. package/lib/es/DropdownToolbar.mjs +2 -2
  14. package/lib/es/MdCatalog.mjs +1 -1
  15. package/lib/es/MdEditor.mjs +717 -674
  16. package/lib/es/MdModal.mjs +1 -1
  17. package/lib/es/MdPreview.mjs +2 -2
  18. package/lib/es/ModalToolbar.mjs +1 -1
  19. package/lib/es/chunks/config.mjs +19 -19
  20. package/lib/es/chunks/index.mjs +1248 -138
  21. package/lib/es/chunks/index2.mjs +2 -2
  22. package/lib/es/chunks/index3.mjs +163 -79
  23. package/lib/es/chunks/index4.mjs +77 -1258
  24. package/lib/es/config.mjs +10 -2
  25. package/lib/es/index.mjs +24 -17
  26. package/lib/style.css +1 -1
  27. package/lib/types/MdEditor/Editor.d.ts +9 -0
  28. package/lib/types/MdEditor/config.d.ts +2 -2
  29. package/lib/types/MdEditor/index.d.ts +15 -0
  30. package/lib/types/MdEditor/layouts/Content/composition/index.d.ts +2 -1
  31. package/lib/types/MdEditor/layouts/Content/composition/useResize.d.ts +12 -0
  32. package/lib/types/MdEditor/layouts/Content/index.d.ts +6 -0
  33. package/lib/types/MdEditor/layouts/Content/props.d.ts +3 -0
  34. package/lib/types/MdEditor/props.d.ts +10 -0
  35. package/lib/types/config.d.ts +3 -1
  36. package/lib/types/index.d.ts +1 -1
  37. package/lib/umd/index.js +31 -31
  38. package/package.json +1 -1
@@ -146,6 +146,6 @@ const B = {
146
146
  });
147
147
  y.install = (e) => (e.component(y.name, y), e);
148
148
  export {
149
- F as D,
150
- y as a
149
+ y as D,
150
+ F as a
151
151
  };
@@ -1,87 +1,171 @@
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", {});
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, e 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);
8
21
  }
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));
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
+ };
13
39
  }
14
- // 清空全部事件,由于单一实例,多次注册会被共享内容
15
- clear(s) {
16
- this.pools[s] = {};
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
+ }
17
72
  }
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);
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"
31
89
  }
90
+ }), P = j(() => e.isFullscreen ? {
91
+ width: "100%",
92
+ height: "100%"
93
+ } : {
94
+ width: e.width,
95
+ height: e.height
32
96
  });
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
+ };
33
165
  }
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)}`;
166
+ });
167
+ h.install = (e) => (e.component(h.name, h), e);
63
168
  export {
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
169
+ C as I,
170
+ h as M
87
171
  };