md-editor-v3 7.1.0 → 7.1.2

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,10 +1,10 @@
1
- import { createVNode as t, defineComponent as k, h as j, inject as p, ref as c, shallowRef as O, reactive as E, computed as g, watch as x, nextTick as b, onMounted as W, Teleport as q } from "vue";
2
- import { p as l, g as C } from "./config.mjs";
3
- import { c as w } from "./index5.mjs";
4
- import { k as I } from "./dom.mjs";
5
- import { g as z } from "./vue-tsx.mjs";
6
- import { Upload as N, Trash2 as D, X as U, SquareSigma as X, ChartArea as G, ListTree as Q, CodeXml as V, Eye as Z, View as J, Expand as K, Shrink as Y, Maximize2 as _, Minimize2 as ee, SquareCode as M, Save as te, Forward as ne, Reply as oe, Table as ie, Image as le, Link as se, Code as ae, ListTodo as re, ListOrdered as ue, List as ce, Quote as de, Superscript as me, Subscript as fe, Heading as he, Strikethrough as ve, Italic as ye, Underline as ge, Bold as Se } from "@lucide/vue";
7
- const pe = () => t("svg", {
1
+ import { createVNode as n, defineComponent as p, h as A, inject as w, computed as y, ref as m, shallowRef as q, useId as D, reactive as K, onBeforeMount as O, onMounted as V, watch as U, watchPostEffect as R, Teleport as W } from "vue";
2
+ import { Upload as X, Trash2 as G, X as Q, SquareSigma as Z, ChartArea as _, ListTree as J, CodeXml as Y, Eye as ee, View as te, Expand as oe, Shrink as ne, Maximize2 as ie, Minimize2 as le, SquareCode as $, Save as ae, Forward as se, Reply as ce, Table as re, Image as de, Link as ue, Code as me, ListTodo as fe, ListOrdered as ye, List as he, Quote as ve, Superscript as ge, Subscript as be, Heading as Se, Strikethrough as ke, Italic as we, Underline as pe, Bold as xe } from "@lucide/vue";
3
+ import { p as a, g as B } from "./config.mjs";
4
+ import { c as E } from "./index5.mjs";
5
+ import { k as Ie, g as S } from "./dom.mjs";
6
+ import { g as j } from "./vue-tsx.mjs";
7
+ const Ce = () => n("svg", {
8
8
  xmlns: "http://www.w3.org/2000/svg",
9
9
  viewBox: "0 0 24 24",
10
10
  fill: "none",
@@ -13,47 +13,47 @@ const pe = () => t("svg", {
13
13
  "stroke-linecap": "round",
14
14
  "stroke-linejoin": "round",
15
15
  class: "lucide lucide-github-icon"
16
- }, [t("path", {
16
+ }, [n("path", {
17
17
  d: "M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4"
18
- }, null), t("path", {
18
+ }, null), n("path", {
19
19
  d: "M9 18c-4.51 2-5-2-7-2"
20
- }, null)]), ke = {
21
- bold: Se,
22
- underline: ge,
23
- italic: ye,
24
- "strike-through": ve,
25
- title: he,
26
- sub: fe,
27
- sup: me,
28
- quote: de,
29
- "unordered-list": ce,
30
- "ordered-list": ue,
31
- task: re,
32
- "code-row": ae,
33
- code: M,
34
- link: se,
35
- image: le,
36
- table: ie,
37
- revoke: oe,
38
- next: ne,
39
- save: te,
40
- prettier: M,
41
- minimize: ee,
42
- maximize: _,
43
- "fullscreen-exit": Y,
44
- fullscreen: K,
45
- "preview-only": J,
46
- preview: Z,
47
- "preview-html": V,
48
- catalog: Q,
49
- github: pe,
50
- mermaid: G,
51
- formula: X,
52
- close: U,
53
- delete: D,
54
- upload: N
55
- }, xe = /* @__PURE__ */ k({
56
- name: `${l}-icon-set`,
20
+ }, null)]), Me = {
21
+ bold: xe,
22
+ underline: pe,
23
+ italic: we,
24
+ "strike-through": ke,
25
+ title: Se,
26
+ sub: be,
27
+ sup: ge,
28
+ quote: ve,
29
+ "unordered-list": he,
30
+ "ordered-list": ye,
31
+ task: fe,
32
+ "code-row": me,
33
+ code: $,
34
+ link: ue,
35
+ image: de,
36
+ table: re,
37
+ revoke: ce,
38
+ next: se,
39
+ save: ae,
40
+ prettier: $,
41
+ minimize: le,
42
+ maximize: ie,
43
+ "fullscreen-exit": ne,
44
+ fullscreen: oe,
45
+ "preview-only": te,
46
+ preview: ee,
47
+ "preview-html": Y,
48
+ catalog: J,
49
+ github: Ce,
50
+ mermaid: _,
51
+ formula: Z,
52
+ close: Q,
53
+ delete: G,
54
+ upload: X
55
+ }, Fe = /* @__PURE__ */ p({
56
+ name: `${a}-icon-set`,
57
57
  props: {
58
58
  name: {
59
59
  type: String,
@@ -61,12 +61,12 @@ const pe = () => t("svg", {
61
61
  }
62
62
  },
63
63
  setup(e) {
64
- return () => j(ke[e.name], {
65
- class: `${l}-icon`
64
+ return () => A(Me[e.name], {
65
+ class: `${a}-icon`
66
66
  });
67
67
  }
68
- }), P = /* @__PURE__ */ k({
69
- name: `${l}-icon`,
68
+ }), T = /* @__PURE__ */ p({
69
+ name: `${a}-icon`,
70
70
  props: {
71
71
  name: {
72
72
  type: String,
@@ -74,17 +74,17 @@ const pe = () => t("svg", {
74
74
  }
75
75
  },
76
76
  setup(e) {
77
- const u = p("customIcon");
77
+ const d = w("customIcon", y(() => ({})));
78
78
  return () => {
79
- const a = u.value[e.name];
80
- return typeof a == "object" ? typeof a.component == "object" ? j(a.component, a.props) : t("span", {
81
- innerHTML: a.component
82
- }, null) : t(xe, {
79
+ const c = d.value[e.name];
80
+ return typeof c == "object" ? typeof c.component == "object" ? A(c.component, c.props) : n("span", {
81
+ innerHTML: c.component
82
+ }, null) : n(Fe, {
83
83
  name: e.name
84
84
  }, null);
85
85
  };
86
86
  }
87
- }), be = {
87
+ }), ze = {
88
88
  title: {
89
89
  type: [String, Object],
90
90
  default: ""
@@ -129,15 +129,14 @@ const pe = () => t("svg", {
129
129
  type: Boolean,
130
130
  default: !0
131
131
  }
132
- }, S = /* @__PURE__ */ k({
132
+ }, k = /* @__PURE__ */ p({
133
133
  name: "MdModal",
134
- props: be,
134
+ props: ze,
135
135
  emits: ["onClose"],
136
- setup(e, u) {
137
- const a = p("theme"), $ = p("rootRef"), m = c(e.visible), r = c([`${l}-modal`]), f = c(), h = c(), v = c(), B = O();
138
- let d = () => {
139
- };
140
- const n = E({
136
+ setup(e, d) {
137
+ const c = w("theme", y(() => "light")), x = w("rootRef", m()), f = m(e.visible), I = m(), C = m(), h = q(), v = m(), M = D();
138
+ let F = null;
139
+ const l = K({
141
140
  maskStyle: {
142
141
  zIndex: -1
143
142
  },
@@ -152,107 +151,145 @@ const pe = () => t("svg", {
152
151
  insetInlineStart: "0px",
153
152
  insetBlockStart: "0px"
154
153
  }
155
- }), F = g(() => e.isFullscreen ? {
156
- width: "100%",
157
- height: "100%"
158
- } : {
159
- width: e.width,
160
- height: e.height
161
- });
162
- x(() => e.isFullscreen, (o) => {
163
- o ? d() : b(() => {
164
- d = I(h.value, (i, s) => {
165
- n.initPos.insetInlineStart = i + "px", n.initPos.insetBlockStart = s + "px";
154
+ }), z = () => {
155
+ F = (x.value?.getRootNode() || document).activeElement;
156
+ };
157
+ O(() => {
158
+ e.visible && z();
159
+ }), V(() => {
160
+ const i = x.value?.getRootNode();
161
+ h.value = i instanceof ShadowRoot ? i : document.body;
162
+ }), U(() => e.visible, (i, o, t) => {
163
+ if (i)
164
+ z(), f.value = !0;
165
+ else {
166
+ const s = window.setTimeout(() => {
167
+ f.value = !1;
168
+ }, 150);
169
+ t(() => clearTimeout(s));
170
+ }
171
+ }), R((i) => {
172
+ const o = C.value;
173
+ !o || e.isFullscreen || !e.visible || i(Ie(o, (t, s) => {
174
+ l.initPos.insetInlineStart = t + "px", l.initPos.insetBlockStart = s + "px";
175
+ }));
176
+ }), R((i) => {
177
+ const o = I.value;
178
+ if (v.value && (v.value.inert = !e.visible), !e.visible || !f.value || !o) return;
179
+ l.maskStyle = {
180
+ zIndex: B.editorConfig.zIndex + E()
181
+ }, l.modalStyle = {
182
+ zIndex: B.editorConfig.zIndex + E()
183
+ }, l.initPos = {
184
+ insetInlineStart: (document.documentElement.clientWidth - o.offsetWidth) / 2 + "px",
185
+ insetBlockStart: (document.documentElement.clientHeight - o.offsetHeight) / 2 + "px"
186
+ };
187
+ const t = o.getRootNode(), s = F, u = o.querySelector(`.${a}-modal-body`);
188
+ o.contains(t.activeElement) || (S(u)[0] || S(o)[0] || o).focus({
189
+ preventScroll: !0
190
+ }), i(() => {
191
+ const r = t.activeElement;
192
+ s?.isConnected && (!r || r === document.body || o.contains(r)) && s.focus({
193
+ preventScroll: !0
166
194
  });
167
195
  });
168
- }), x(() => e.visible, (o) => {
169
- o ? (n.maskStyle.zIndex = C.editorConfig.zIndex + w(), n.modalStyle.zIndex = C.editorConfig.zIndex + w(), r.value.push("zoom-in"), m.value = o, b(() => {
170
- const i = f.value.offsetWidth / 2, s = f.value.offsetHeight / 2, T = document.documentElement.clientWidth / 2, H = document.documentElement.clientHeight / 2;
171
- n.initPos.insetInlineStart = T - i + "px", n.initPos.insetBlockStart = H - s + "px", e.isFullscreen || (d = I(h.value, (A, L) => {
172
- n.initPos.insetInlineStart = A + "px", n.initPos.insetBlockStart = L + "px";
173
- }));
174
- }), setTimeout(() => {
175
- r.value = r.value.filter((i) => i !== "zoom-in");
176
- }, 140)) : (r.value.push("zoom-out"), d(), setTimeout(() => {
177
- r.value = r.value.filter((i) => i !== "zoom-out"), m.value = o;
178
- }, 130));
179
- });
180
- const y = g(() => ({
181
- display: m.value ? "block" : "none"
182
- })), R = g(() => {
183
- if (typeof e.style == "string") {
184
- const o = Object.entries(y.value).map(([i, s]) => `${i}: ${s}`).join("; ");
185
- return [e.style, o].join("; ");
186
- } else return e.style instanceof Object ? {
187
- ...y.value,
188
- ...e.style
189
- } : y.value;
190
196
  });
191
- return W(() => {
192
- const o = $.value?.getRootNode();
193
- v.value = o instanceof Document ? document.body : o;
194
- }), () => {
195
- const o = z({
196
- ctx: u
197
- }), i = z({
197
+ const L = y(() => ({
198
+ width: e.isFullscreen ? "100%" : e.width,
199
+ height: e.isFullscreen ? "100%" : e.height
200
+ })), N = y(() => {
201
+ const i = f.value ? "block" : "none";
202
+ return typeof e.style == "string" ? `${e.style}; display: ${i};` : {
203
+ ...e.style,
204
+ display: i
205
+ };
206
+ }), g = () => {
207
+ e.onClose?.(), d.emit("onClose");
208
+ };
209
+ return () => {
210
+ const i = j({
211
+ ctx: d
212
+ }), o = j({
198
213
  props: e,
199
- ctx: u
214
+ ctx: d
200
215
  }, "title");
201
- return v.value ? t(q, {
202
- to: v.value
216
+ return h.value ? n(W, {
217
+ to: h.value
203
218
  }, {
204
- default: () => [t("div", {
205
- ref: B,
206
- class: `${l}-modal-container`,
207
- "data-theme": a.value
208
- }, [t("div", {
219
+ default: () => [n("div", {
220
+ ref: v,
221
+ class: `${a}-modal-container`,
222
+ "data-theme": c.value
223
+ }, [n("div", {
209
224
  class: e.class,
210
- style: R.value
211
- }, [e.showMask && t("div", {
212
- class: `${l}-modal-mask`,
213
- style: n.maskStyle,
214
- onClick: () => {
215
- e.onClose?.(), u.emit("onClose");
216
- }
217
- }, null), t("div", {
218
- class: r.value,
225
+ style: N.value,
226
+ "aria-hidden": !e.visible || void 0
227
+ }, [e.showMask && n("div", {
228
+ class: `${a}-modal-mask`,
229
+ style: l.maskStyle,
230
+ onClick: g
231
+ }, null), n("div", {
232
+ class: [`${a}-modal`, e.visible ? "zoom-in" : "zoom-out"],
219
233
  style: {
220
- ...n.modalStyle,
221
- ...n.initPos,
222
- ...F.value
234
+ ...l.modalStyle,
235
+ ...l.initPos,
236
+ ...L.value
223
237
  },
224
- ref: f
225
- }, [t("div", {
226
- class: `${l}-modal-header`,
227
- ref: h
228
- }, [i || ""]), t("div", {
229
- class: `${l}-modal-body`
230
- }, [o]), t("div", {
231
- class: `${l}-modal-func`
232
- }, [e.showAdjust && t("div", {
233
- class: `${l}-modal-adjust`,
234
- onClick: (s) => {
235
- s.stopPropagation(), e.isFullscreen ? n.initPos = n.historyPos : (n.historyPos = n.initPos, n.initPos = {
238
+ ref: I,
239
+ role: "dialog",
240
+ "aria-modal": e.showMask || void 0,
241
+ "aria-labelledby": o ? M : void 0,
242
+ "aria-label": o ? void 0 : "Dialog",
243
+ tabindex: -1,
244
+ onKeydown: (t) => {
245
+ if (!e.visible || t.defaultPrevented || t.isComposing)
246
+ return;
247
+ if (t.key === "Escape") {
248
+ t.preventDefault(), t.stopPropagation(), g();
249
+ return;
250
+ }
251
+ if (t.key !== "Tab" || !e.showMask) return;
252
+ const s = t.currentTarget, u = s.getRootNode(), r = S(s), b = r[0], P = r.at(-1), H = t.shiftKey ? u.activeElement === b || u.activeElement === s : u.activeElement === P;
253
+ (!b || H) && (t.preventDefault(), ((t.shiftKey ? P : b) || s).focus({
254
+ preventScroll: !0
255
+ }));
256
+ }
257
+ }, [n("div", {
258
+ id: M,
259
+ class: `${a}-modal-header`,
260
+ ref: C
261
+ }, [o || ""]), n("div", {
262
+ class: `${a}-modal-func`
263
+ }, [e.showAdjust && n("button", {
264
+ class: `${a}-modal-adjust`,
265
+ type: "button",
266
+ "aria-label": e.isFullscreen ? "Restore" : "Maximize",
267
+ onClick: (t) => {
268
+ t.stopPropagation(), e.isFullscreen ? l.initPos = l.historyPos : (l.historyPos = l.initPos, l.initPos = {
236
269
  insetInlineStart: "0",
237
270
  insetBlockStart: "0"
238
271
  }), e.onAdjust(!e.isFullscreen);
239
272
  }
240
- }, [t(P, {
273
+ }, [n(T, {
241
274
  name: e.isFullscreen ? "minimize" : "maximize"
242
- }, null)]), t("div", {
243
- class: `${l}-modal-close`,
244
- onClick: (s) => {
245
- s.stopPropagation(), e.onClose?.(), u.emit("onClose");
275
+ }, null)]), n("button", {
276
+ class: `${a}-modal-close`,
277
+ type: "button",
278
+ "aria-label": "Close",
279
+ onClick: (t) => {
280
+ t.stopPropagation(), g();
246
281
  }
247
- }, [t(P, {
282
+ }, [n(T, {
248
283
  name: "close"
249
- }, null)])])])])])]
284
+ }, null)])]), n("div", {
285
+ class: `${a}-modal-body`
286
+ }, [i])])])])]
250
287
  }) : "";
251
288
  };
252
289
  }
253
290
  });
254
- S.install = (e) => (e.component(S.name, S), e);
291
+ k.install = (e) => (e.component(k.name, k), e);
255
292
  export {
256
- P as I,
257
- S as M
293
+ T as I,
294
+ k as M
258
295
  };