md-editor-v3 7.0.0 → 7.1.0-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,125 +1,125 @@
1
- import { useId as je, provide as I, computed as F, reactive as me, watch as x, onMounted as L, ref as U, inject as $, nextTick as W, shallowRef as se, onBeforeUnmount as le, toRef as De, defineComponent as pe, createVNode as j, Fragment as Ve, h as ze } from "vue";
2
- import { b, g as ge, R as Ge, U as Ue, C as Fe, B as ne, O as Re, E as re, h as ye, F as be, i as Ce, j as we, H as $e, k as Ee, e as We, d as qe, f as de, P as Ke, T as Ze } from "./event-bus.mjs";
3
- import { deepMerge as Je, deepClone as Xe, randomId as fe, debounce as Ye } from "@vavt/util";
4
- import { p as h, g as P, f as xe, s as Ie, a as Qe, b as et } from "./config.mjs";
5
- import { a as O, u as tt, S as nt, c as ot, z as at } from "./dom.mjs";
6
- import rt from "@vavt/copy2clipboard";
7
- import st from "markdown-it";
8
- import lt from "markdown-it-image-figures";
9
- import it from "markdown-it-sub";
10
- import ct from "markdown-it-sup";
11
- import { p as dt, a as ut } from "./index5.mjs";
12
- import mt from "medium-zoom";
13
- const ft = (e, t, a) => {
1
+ import { useId as ze, provide as I, computed as H, reactive as fe, watch as S, onMounted as _, ref as Q, inject as E, nextTick as Y, shallowRef as de, onBeforeUnmount as re, toRef as be, defineComponent as ge, createVNode as Z, Fragment as Ge, h as Ue } from "vue";
2
+ import { b as w, g as ve, R as We, U as qe, C as Oe, B as ie, O as _e, E as ce, h as Ce, F as we, i as $e, j as Ee, H as xe, k as Se, e as Ke, d as Ze, f as ue, P as Je, T as Xe } from "./event-bus.mjs";
3
+ import { deepMerge as Qe, deepClone as Ye, randomId as he, debounce as et } from "@vavt/util";
4
+ import { p as f, g as j, f as Te, s as Ie, m as ke, h as le, r as ae, a as tt, b as nt } from "./config.mjs";
5
+ import { a as z, u as ot, S as at, c as rt, z as st } from "./dom.mjs";
6
+ import it from "@vavt/copy2clipboard";
7
+ import lt from "markdown-it";
8
+ import ct from "markdown-it-image-figures";
9
+ import dt from "markdown-it-sub";
10
+ import ut from "markdown-it-sup";
11
+ import { p as mt, a as ft } from "./index5.mjs";
12
+ import ht from "medium-zoom";
13
+ const pt = (e, t, a) => {
14
14
  const { editorId: o } = a, n = {
15
15
  rerender() {
16
- b.emit(o, ge);
16
+ w.emit(o, ve);
17
17
  }
18
18
  };
19
19
  t.expose(n);
20
- }, M = {
21
- hljs: `${h}-hljs`,
22
- hlcss: `${h}-hlCss`,
23
- prettier: `${h}-prettier`,
24
- prettierMD: `${h}-prettierMD`,
25
- cropperjs: `${h}-cropper`,
26
- croppercss: `${h}-cropperCss`,
27
- screenfull: `${h}-screenfull`,
28
- mermaidM: `${h}-mermaid-m`,
29
- mermaid: `${h}-mermaid`,
30
- katexjs: `${h}-katex`,
31
- katexcss: `${h}-katexCss`,
32
- echarts: `${h}-echarts`
33
- }, he = (e, t) => {
34
- b.emit(e, Ge, t);
35
- }, mn = (e, t, a) => {
36
- const { editorId: o } = a, n = me({
20
+ }, B = {
21
+ hljs: `${f}-hljs`,
22
+ hlcss: `${f}-hlCss`,
23
+ prettier: `${f}-prettier`,
24
+ prettierMD: `${f}-prettierMD`,
25
+ cropperjs: `${f}-cropper`,
26
+ croppercss: `${f}-cropperCss`,
27
+ screenfull: `${f}-screenfull`,
28
+ mermaidM: `${f}-mermaid-m`,
29
+ mermaid: `${f}-mermaid`,
30
+ katexjs: `${f}-katex`,
31
+ katexcss: `${f}-katexCss`,
32
+ echarts: `${f}-echarts`
33
+ }, pe = (e, t) => {
34
+ w.emit(e, We, t);
35
+ }, dn = (e, t, a) => {
36
+ const { editorId: o } = a, n = fe({
37
37
  // 是否已编译成html
38
38
  buildFinished: !1,
39
39
  // 存储当前最新的html
40
40
  html: ""
41
41
  });
42
- x(
42
+ S(
43
43
  () => e.modelValue,
44
44
  () => {
45
45
  n.buildFinished = !1;
46
46
  }
47
- ), L(() => {
48
- b.on(o, {
49
- name: ne,
50
- callback(c) {
51
- n.buildFinished = !0, n.html = c;
47
+ ), _(() => {
48
+ w.on(o, {
49
+ name: ie,
50
+ callback(s) {
51
+ n.buildFinished = !0, n.html = s;
52
52
  }
53
- }), b.on(o, {
54
- name: Re,
53
+ }), w.on(o, {
54
+ name: _e,
55
55
  callback() {
56
- const c = new Promise((i) => {
56
+ const s = new Promise((c) => {
57
57
  if (n.buildFinished)
58
- i(n.html);
58
+ c(n.html);
59
59
  else {
60
- const d = (u) => {
61
- i(u), b.remove(o, ne, d);
60
+ const u = (d) => {
61
+ c(d), w.remove(o, ie, u);
62
62
  };
63
- b.on(o, {
64
- name: ne,
65
- callback: d
63
+ w.on(o, {
64
+ name: ie,
65
+ callback: u
66
66
  });
67
67
  }
68
68
  });
69
- e.onSave ? e.onSave(e.modelValue, c) : t.emit("onSave", e.modelValue, c);
69
+ e.onSave ? e.onSave(e.modelValue, s) : t.emit("onSave", e.modelValue, s);
70
70
  }
71
71
  });
72
72
  });
73
- }, Le = (e, {
73
+ }, Ne = (e, {
74
74
  editorId: t,
75
75
  rootRef: a,
76
76
  setting: o
77
77
  }) => {
78
- const n = P.editorExtensions.highlight, c = P.editorExtensionsAttrs.highlight;
78
+ const n = j.editorExtensions.highlight, s = j.editorExtensionsAttrs.highlight;
79
79
  I("editorId", t), I("rootRef", a), I(
80
80
  "theme",
81
- F(() => e.theme)
81
+ H(() => e.theme)
82
82
  ), I(
83
83
  "language",
84
- F(() => e.language)
84
+ H(() => e.language)
85
85
  ), I(
86
86
  "highlight",
87
- F(() => {
88
- const { js: d } = n, u = {
89
- ...xe,
87
+ H(() => {
88
+ const { js: u } = n, d = {
89
+ ...Te,
90
90
  ...n.css
91
- }, { js: r, css: l = {} } = c || {}, s = e.codeStyleReverse && e.codeStyleReverseList.includes(e.previewTheme) ? "dark" : e.theme, m = u[e.codeTheme] ? u[e.codeTheme][s] : xe.atom[s], f = u[e.codeTheme] && l[e.codeTheme] ? l[e.codeTheme][s] : l.atom ? l.atom[s] : {};
91
+ }, { js: r, css: i = {} } = s || {}, l = e.codeStyleReverse && e.codeStyleReverseList.includes(e.previewTheme) ? "dark" : e.theme, m = d[e.codeTheme] ? d[e.codeTheme][l] : Te.atom[l], h = d[e.codeTheme] && i[e.codeTheme] ? i[e.codeTheme][l] : i.atom ? i.atom[l] : {};
92
92
  return {
93
93
  js: {
94
- src: d,
94
+ src: u,
95
95
  ...r
96
96
  },
97
97
  css: {
98
98
  href: m,
99
- ...f
99
+ ...h
100
100
  }
101
101
  };
102
102
  })
103
103
  ), I("showCodeRowNumber", e.showCodeRowNumber);
104
- const i = F(() => {
105
- const d = {
104
+ const c = H(() => {
105
+ const u = {
106
106
  ...Ie,
107
- ...P.editorConfig.languageUserDefined
107
+ ...j.editorConfig.languageUserDefined
108
108
  };
109
- return Je(
110
- Xe(Ie["en-US"]),
111
- d[e.language] || {}
109
+ return Qe(
110
+ Ye(Ie["en-US"]),
111
+ u[e.language] || {}
112
112
  );
113
113
  });
114
- return I("usedLanguageText", i), I(
114
+ return I("usedLanguageText", c), I(
115
115
  "previewTheme",
116
- F(() => e.previewTheme)
116
+ H(() => e.previewTheme)
117
117
  ), I(
118
118
  "customIcon",
119
- F(() => e.customIcon)
119
+ H(() => e.customIcon)
120
120
  ), I(
121
121
  "setting",
122
- F(() => o ? {
122
+ H(() => o ? {
123
123
  // setting是reactive,不转化是可以直接赋值的
124
124
  ...o
125
125
  } : {
@@ -130,79 +130,79 @@ const ft = (e, t, a) => {
130
130
  fullscreen: !1
131
131
  })
132
132
  ), { editorId: t };
133
- }, fn = (e, t) => (I("tabWidth", e.tabWidth), I(
133
+ }, un = (e, t) => (I("tabWidth", e.tabWidth), I(
134
134
  "disabled",
135
- F(() => e.disabled)
135
+ H(() => e.disabled)
136
136
  ), I(
137
137
  "contentDisabled",
138
- F(() => e.disabled || e.readOnly)
138
+ H(() => e.disabled || e.readOnly)
139
139
  ), I(
140
140
  "showToolbarName",
141
- F(() => e.showToolbarName)
141
+ H(() => e.showToolbarName)
142
142
  ), I("noUploadImg", e.noUploadImg), I(
143
143
  "tableShape",
144
- F(() => e.tableShape)
144
+ H(() => e.tableShape)
145
145
  ), I("noPrettier", e.noPrettier), I(
146
146
  "codeTheme",
147
- F(() => e.codeTheme)
147
+ H(() => e.codeTheme)
148
148
  ), I("updateSetting", t.updateSetting), I(
149
149
  "catalogVisible",
150
- F(() => t.catalogVisible.value)
150
+ H(() => t.catalogVisible.value)
151
151
  ), I("defToolbars", t.defToolbars), I(
152
152
  "floatingToolbars",
153
- F(() => e.floatingToolbars)
154
- ), Le(e, t)), hn = (e) => {
155
- const { noPrettier: t, noUploadImg: a } = e, { editorExtensions: o, editorExtensionsAttrs: n } = P, c = t || o.prettier.prettierInstance, i = t || o.prettier.parserMarkdownInstance, d = a || o.cropper.instance;
156
- L(() => {
157
- if (!d) {
158
- const { js: u = {}, css: r = {} } = n.cropper || {};
159
- O("link", {
153
+ H(() => e.floatingToolbars)
154
+ ), Ne(e, t)), mn = (e) => {
155
+ const { noPrettier: t, noUploadImg: a } = e, { editorExtensions: o, editorExtensionsAttrs: n } = j, s = t || o.prettier.prettierInstance, c = t || o.prettier.parserMarkdownInstance, u = a || o.cropper.instance;
156
+ _(() => {
157
+ if (!u) {
158
+ const { js: d = {}, css: r = {} } = n.cropper || {};
159
+ z("link", {
160
160
  ...r,
161
161
  rel: "stylesheet",
162
162
  href: o.cropper.css,
163
- id: M.croppercss
164
- }), O("script", {
165
- ...u,
163
+ id: B.croppercss
164
+ }), z("script", {
165
+ ...d,
166
166
  src: o.cropper.js,
167
- id: M.cropperjs
167
+ id: B.cropperjs
168
168
  });
169
169
  }
170
- if (!c) {
171
- const { standaloneJs: u = {} } = n.prettier || {};
172
- O("script", {
173
- ...u,
170
+ if (!s) {
171
+ const { standaloneJs: d = {} } = n.prettier || {};
172
+ z("script", {
173
+ ...d,
174
174
  src: o.prettier.standaloneJs,
175
- id: M.prettier
175
+ id: B.prettier
176
176
  });
177
177
  }
178
- if (!i) {
179
- const { parserMarkdownJs: u = {} } = n.prettier || {};
180
- O("script", {
181
- ...u,
178
+ if (!c) {
179
+ const { parserMarkdownJs: d = {} } = n.prettier || {};
180
+ z("script", {
181
+ ...d,
182
182
  src: o.prettier.parserMarkdownJs,
183
- id: M.prettierMD
183
+ id: B.prettierMD
184
184
  });
185
185
  }
186
186
  });
187
- }, pn = (e, t, a) => {
187
+ }, fn = (e, t, a) => {
188
188
  const { editorId: o } = a;
189
- L(() => {
190
- b.on(o, {
191
- name: re,
189
+ _(() => {
190
+ w.on(o, {
191
+ name: ce,
192
192
  callback: (n) => {
193
193
  e.onError?.(n), t.emit("onError", n);
194
194
  }
195
195
  });
196
196
  });
197
- }, gn = (e, t, a) => {
198
- const { editorId: o } = a, n = me({
197
+ }, hn = (e, t, a) => {
198
+ const { editorId: o } = a, n = fe({
199
199
  pageFullscreen: e.pageFullscreen,
200
200
  fullscreen: !1,
201
201
  preview: e.preview,
202
202
  htmlPreview: e.preview ? !1 : e.htmlPreview,
203
203
  previewOnly: !1
204
- }), c = me({ ...n }), i = (r, l) => {
205
- const s = l === void 0 ? !n[r] : l;
204
+ }), s = fe({ ...n }), c = (r, i) => {
205
+ const l = i === void 0 ? !n[r] : i;
206
206
  switch (r) {
207
207
  case "preview": {
208
208
  n.htmlPreview = !1, n.previewOnly = !1;
@@ -213,126 +213,126 @@ const ft = (e, t, a) => {
213
213
  break;
214
214
  }
215
215
  case "previewOnly": {
216
- s ? !n.preview && !n.htmlPreview && (n.preview = !0) : (c.preview || (n.preview = !1), c.htmlPreview || (n.htmlPreview = !1));
216
+ l ? !n.preview && !n.htmlPreview && (n.preview = !0) : (s.preview || (n.preview = !1), s.htmlPreview || (n.htmlPreview = !1));
217
217
  break;
218
218
  }
219
219
  }
220
- c[r] = s, n[r] = s;
220
+ s[r] = l, n[r] = l;
221
221
  };
222
- let d = "";
223
- const u = () => {
224
- n.pageFullscreen || n.fullscreen ? document.body.style.overflow = "hidden" : document.body.style.overflow = d;
222
+ let u = "";
223
+ const d = () => {
224
+ n.pageFullscreen || n.fullscreen ? document.body.style.overflow = "hidden" : document.body.style.overflow = u;
225
225
  };
226
- return x(() => [n.pageFullscreen, n.fullscreen], u), L(() => {
227
- b.on(o, {
228
- name: Ue,
229
- callback(r, l) {
230
- const s = (m) => {
231
- he(o, {
226
+ return S(() => [n.pageFullscreen, n.fullscreen], d), _(() => {
227
+ w.on(o, {
228
+ name: qe,
229
+ callback(r, i) {
230
+ const l = (m) => {
231
+ pe(o, {
232
232
  direct: "image",
233
233
  params: {
234
234
  desc: "",
235
235
  urls: m
236
236
  }
237
- }), l?.();
237
+ }), i?.();
238
238
  };
239
- e.onUploadImg ? e.onUploadImg(r, s) : t.emit("onUploadImg", r, s);
239
+ e.onUploadImg ? e.onUploadImg(r, l) : t.emit("onUploadImg", r, l);
240
240
  }
241
- }), d = document.body.style.overflow, u();
242
- }), [n, i];
243
- }, vn = (e, t) => {
244
- const { editorId: a } = t, o = U(!1);
245
- return L(() => {
246
- b.on(a, {
247
- name: Fe,
241
+ }), u = document.body.style.overflow, d();
242
+ }), [n, c];
243
+ }, pn = (e, t) => {
244
+ const { editorId: a } = t, o = Q(!1);
245
+ return _(() => {
246
+ w.on(a, {
247
+ name: Oe,
248
248
  callback: (n) => {
249
249
  n === void 0 ? o.value = !o.value : o.value = n;
250
250
  }
251
251
  });
252
252
  }), o;
253
- }, yn = (e, t, a) => {
254
- const { editorId: o, catalogVisible: n, setting: c, updateSetting: i, codeRef: d } = a;
255
- x(
256
- () => c.pageFullscreen,
253
+ }, gn = (e, t, a) => {
254
+ const { editorId: o, catalogVisible: n, setting: s, updateSetting: c, codeRef: u } = a;
255
+ S(
256
+ () => s.pageFullscreen,
257
257
  (r) => {
258
- b.emit(o, ye, r);
258
+ w.emit(o, Ce, r);
259
259
  }
260
- ), x(
261
- () => c.fullscreen,
260
+ ), S(
261
+ () => s.fullscreen,
262
262
  (r) => {
263
- b.emit(o, be, r);
263
+ w.emit(o, we, r);
264
264
  }
265
- ), x(
266
- () => c.preview,
265
+ ), S(
266
+ () => s.preview,
267
267
  (r) => {
268
- b.emit(o, Ce, r);
268
+ w.emit(o, $e, r);
269
269
  }
270
- ), x(
271
- () => c.previewOnly,
270
+ ), S(
271
+ () => s.previewOnly,
272
272
  (r) => {
273
- b.emit(o, we, r);
273
+ w.emit(o, Ee, r);
274
274
  }
275
- ), x(
276
- () => c.htmlPreview,
275
+ ), S(
276
+ () => s.htmlPreview,
277
277
  (r) => {
278
- b.emit(o, $e, r);
278
+ w.emit(o, xe, r);
279
279
  }
280
- ), x(n, (r) => {
281
- b.emit(o, Ee, r);
280
+ ), S(n, (r) => {
281
+ w.emit(o, Se, r);
282
282
  });
283
- const u = {
284
- on(r, l) {
283
+ const d = {
284
+ on(r, i) {
285
285
  switch (r) {
286
286
  case "pageFullscreen": {
287
- b.on(o, {
288
- name: ye,
289
- callback(s) {
290
- l(s);
287
+ w.on(o, {
288
+ name: Ce,
289
+ callback(l) {
290
+ i(l);
291
291
  }
292
292
  });
293
293
  break;
294
294
  }
295
295
  case "fullscreen": {
296
- b.on(o, {
297
- name: be,
298
- callback(s) {
299
- l(s);
296
+ w.on(o, {
297
+ name: we,
298
+ callback(l) {
299
+ i(l);
300
300
  }
301
301
  });
302
302
  break;
303
303
  }
304
304
  case "preview": {
305
- b.on(o, {
306
- name: Ce,
307
- callback(s) {
308
- l(s);
305
+ w.on(o, {
306
+ name: $e,
307
+ callback(l) {
308
+ i(l);
309
309
  }
310
310
  });
311
311
  break;
312
312
  }
313
313
  case "previewOnly": {
314
- b.on(o, {
315
- name: we,
316
- callback(s) {
317
- l(s);
314
+ w.on(o, {
315
+ name: Ee,
316
+ callback(l) {
317
+ i(l);
318
318
  }
319
319
  });
320
320
  break;
321
321
  }
322
322
  case "htmlPreview": {
323
- b.on(o, {
324
- name: $e,
325
- callback(s) {
326
- l(s);
323
+ w.on(o, {
324
+ name: xe,
325
+ callback(l) {
326
+ i(l);
327
327
  }
328
328
  });
329
329
  break;
330
330
  }
331
331
  case "catalog": {
332
- b.on(o, {
333
- name: Ee,
334
- callback(s) {
335
- l(s);
332
+ w.on(o, {
333
+ name: Se,
334
+ callback(l) {
335
+ i(l);
336
336
  }
337
337
  });
338
338
  break;
@@ -340,220 +340,221 @@ const ft = (e, t, a) => {
340
340
  }
341
341
  },
342
342
  togglePageFullscreen(r) {
343
- i("pageFullscreen", r);
343
+ c("pageFullscreen", r);
344
344
  },
345
345
  toggleFullscreen(r) {
346
- b.emit(o, qe, r);
346
+ w.emit(o, Ze, r);
347
347
  },
348
348
  togglePreview(r) {
349
- i("preview", r);
349
+ c("preview", r);
350
350
  },
351
351
  togglePreviewOnly(r) {
352
- i("previewOnly", r);
352
+ c("previewOnly", r);
353
353
  },
354
354
  toggleHtmlPreview(r) {
355
- i("htmlPreview", r);
355
+ c("htmlPreview", r);
356
356
  },
357
357
  toggleCatalog(r) {
358
- b.emit(o, Fe, r);
358
+ w.emit(o, Oe, r);
359
359
  },
360
360
  triggerSave() {
361
- b.emit(o, Re);
361
+ w.emit(o, _e);
362
362
  },
363
363
  insert(r) {
364
- he(o, {
364
+ pe(o, {
365
365
  direct: "universal",
366
366
  params: { generate: r },
367
367
  source: "programmatic"
368
368
  });
369
369
  },
370
370
  focus(r) {
371
- d.value?.focus(r);
371
+ u.value?.focus(r);
372
372
  },
373
373
  rerender() {
374
- b.emit(o, ge);
374
+ w.emit(o, ve);
375
375
  },
376
376
  getSelectedText() {
377
- return d.value?.getSelectedText();
377
+ return u.value?.getSelectedText();
378
378
  },
379
379
  resetHistory() {
380
- d.value?.resetHistory();
380
+ u.value?.resetHistory();
381
381
  },
382
382
  domEventHandlers(r) {
383
- b.emit(o, We, r);
383
+ w.emit(o, Ke, r);
384
384
  },
385
385
  execCommand(r) {
386
- he(o, { direct: r, source: "programmatic" });
386
+ pe(o, { direct: r, source: "programmatic" });
387
387
  },
388
388
  getEditorView() {
389
- return d.value?.getEditorView();
389
+ return u.value?.getEditorView();
390
390
  }
391
391
  };
392
- t.expose(u);
393
- }, ht = (e) => {
394
- const t = je();
395
- return e.id || e.editorId || `${h}-${t}`;
396
- }, pt = (e, t, a) => {
397
- const o = $("editorId"), n = $("rootRef"), c = $("usedLanguageText"), i = $("setting"), d = () => {
398
- n.value.querySelectorAll(`#${o} .${h}-preview .${h}-code`).forEach((l) => {
399
- let s = -1;
400
- const m = l.querySelector(
401
- `.${h}-copy-button:not([data-processed])`
392
+ t.expose(d);
393
+ }, gt = (e) => {
394
+ const t = ze();
395
+ return e.id || e.editorId || `${f}-${t}`;
396
+ }, vt = (e, t, a) => {
397
+ const o = E("editorId"), n = E("rootRef"), s = E("usedLanguageText"), c = E("setting"), u = () => {
398
+ n.value.querySelectorAll(`#${o} .${f}-preview .${f}-code`).forEach((i) => {
399
+ let l = -1;
400
+ const m = i.querySelector(
401
+ `.${f}-copy-button:not([data-processed])`
402
402
  );
403
- m && (m.onclick = (f) => {
404
- f.preventDefault(), clearTimeout(s);
405
- const g = (l.querySelector("input:checked + pre code") || l.querySelector("pre code")).textContent, { text: v, successTips: E, failTips: y } = c.value.copyCode;
406
- let C = E;
407
- rt(e.formatCopiedText(g || "")).catch(() => {
408
- C = y;
403
+ m && (m.onclick = (h) => {
404
+ h.preventDefault(), clearTimeout(l);
405
+ const p = (i.querySelector("input:checked + pre code") || i.querySelector("pre code")).textContent, { text: v, successTips: $, failTips: y } = s.value.copyCode;
406
+ let b = $;
407
+ it(e.formatCopiedText(p || "")).catch(() => {
408
+ b = y;
409
409
  }).finally(() => {
410
- m.dataset.isIcon ? m.dataset.tips = C : m.textContent = C, s = window.setTimeout(() => {
410
+ m.dataset.isIcon ? m.dataset.tips = b : m.textContent = b, l = window.setTimeout(() => {
411
411
  m.dataset.isIcon ? m.dataset.tips = v : m.textContent = v;
412
412
  }, 1500);
413
413
  });
414
414
  }, m.setAttribute("data-processed", "true"));
415
415
  });
416
- }, u = () => {
417
- W(d);
418
- }, r = (l) => {
419
- l && W(d);
416
+ }, d = () => {
417
+ Y(u);
418
+ }, r = (i) => {
419
+ i && Y(u);
420
420
  };
421
- x([t, a], u), x(() => i.value.preview, r), x(() => i.value.htmlPreview, r), L(d);
422
- }, gt = (e) => {
423
- const t = $("editorId"), a = $("theme"), o = $("rootRef"), { editorExtensions: n, editorExtensionsAttrs: c, echartsConfig: i } = P;
424
- let d = n.echarts.instance;
425
- const u = se(-1), r = () => {
426
- !e.noEcharts && d && (u.value = u.value + 1);
421
+ S([t, a], d), S(() => c.value.preview, r), S(() => c.value.htmlPreview, r), _(u);
422
+ }, yt = (e) => {
423
+ const t = E("editorId"), a = E("theme"), o = E("rootRef"), { editorExtensions: n, editorExtensionsAttrs: s, echartsConfig: c } = j;
424
+ let u = n.echarts.instance;
425
+ const d = de(-1), r = () => {
426
+ !e.noEcharts && u && (d.value = d.value + 1);
427
427
  };
428
- x(
428
+ S(
429
429
  () => a.value,
430
430
  () => {
431
431
  r();
432
432
  }
433
- ), L(() => {
434
- if (e.noEcharts || d)
433
+ ), _(() => {
434
+ if (e.noEcharts || u)
435
435
  return;
436
- const g = n.echarts.js;
437
- O(
436
+ const p = n.echarts.js;
437
+ z(
438
438
  "script",
439
439
  {
440
- ...c.echarts?.js,
441
- src: g,
442
- id: M.echarts,
440
+ ...s.echarts?.js,
441
+ src: p,
442
+ id: B.echarts,
443
443
  onload() {
444
- d = window.echarts, r();
444
+ u = window.echarts, r();
445
445
  }
446
446
  },
447
447
  "echarts"
448
448
  );
449
449
  });
450
- let l = [], s = [], m = [];
451
- const f = (g = !1) => {
452
- if (!l.length) {
453
- g && (s.forEach((C) => {
454
- C.dispose?.();
455
- }), m.forEach((C) => {
456
- C.disconnect?.();
457
- }), s = [], m = []);
450
+ let i = [], l = [], m = [];
451
+ const h = (p = !1) => {
452
+ if (!i.length) {
453
+ p && (l.forEach((b) => {
454
+ b.dispose?.();
455
+ }), m.forEach((b) => {
456
+ b.disconnect?.();
457
+ }), l = [], m = []);
458
458
  return;
459
459
  }
460
- const v = [], E = [], y = [];
461
- l.forEach((C, T) => {
462
- const w = s[T], k = m[T];
463
- if (g || !C || !C.isConnected || (o?.value ? !o.value.contains(C) : !1)) {
464
- w?.dispose?.(), k?.disconnect?.();
460
+ const v = [], $ = [], y = [];
461
+ i.forEach((b, C) => {
462
+ const x = l[C], F = m[C];
463
+ if (p || !b || !b.isConnected || (o?.value ? !o.value.contains(b) : !1)) {
464
+ x?.dispose?.(), F?.disconnect?.();
465
465
  return;
466
466
  }
467
- v.push(C), w && E.push(w), k && y.push(k);
468
- }), l = v, s = E, m = y;
469
- }, p = () => {
470
- if (f(), !e.noEcharts && d) {
471
- const g = o.value;
472
- if (!g) return;
467
+ v.push(b), x && $.push(x), F && y.push(F);
468
+ }), i = v, l = $, m = y;
469
+ }, g = () => {
470
+ if (h(), !e.noEcharts && u) {
471
+ const p = o.value;
472
+ if (!p) return;
473
473
  Array.from(
474
- g.querySelectorAll(
475
- `#${t} div.${h}-echarts:not([data-processed])`
476
- )
477
- ).forEach((E) => {
478
- if (E.dataset.closed === "false")
474
+ p.querySelectorAll(`div.${f}-echarts:not([data-processed])`)
475
+ ).forEach(($) => {
476
+ if ($.dataset.closed === "false")
479
477
  return !1;
478
+ const y = $.textContent || "";
479
+ let b, C;
480
480
  try {
481
- const y = n.echarts.parseOption(E.innerText, {
481
+ const x = {
482
482
  editorId: t,
483
- element: E
484
- }), C = i(y), T = d.init(E, a.value);
485
- T.setOption(C), E.setAttribute("data-processed", ""), l.push(E), s.push(T);
486
- const w = new ResizeObserver(() => {
487
- T.resize();
488
- });
489
- w.observe(E), m.push(w);
490
- } catch (y) {
491
- b.emit(t, re, {
483
+ element: $
484
+ }, F = n.echarts.parseOption(y, x), T = n.echarts.sanitizeOption(
485
+ c(F),
486
+ x
487
+ );
488
+ b = u.init($, a.value), b.setOption(T), C = new ResizeObserver(() => {
489
+ b.resize();
490
+ }), C.observe($), $.setAttribute("data-processed", ""), i.push($), l.push(b), m.push(C);
491
+ } catch (x) {
492
+ b && (C?.disconnect(), b.dispose(), $.textContent = y), w.emit(t, ce, {
492
493
  name: "echarts",
493
- message: y?.message,
494
- error: y
494
+ message: x?.message,
495
+ error: x
495
496
  });
496
497
  }
497
498
  });
498
499
  }
499
500
  };
500
- return le(() => {
501
- f(!0);
502
- }), { reRenderEcharts: u, replaceEcharts: p };
503
- }, vt = (e) => {
504
- const t = $("highlight"), a = se(P.editorExtensions.highlight.instance);
505
- return L(() => {
506
- e.noHighlight || a.value || (O("link", {
501
+ return re(() => {
502
+ h(!0);
503
+ }), { reRenderEcharts: d, replaceEcharts: g };
504
+ }, bt = (e) => {
505
+ const t = E("highlight"), a = de(j.editorExtensions.highlight.instance);
506
+ return _(() => {
507
+ e.noHighlight || a.value || (z("link", {
507
508
  ...t.value.css,
508
509
  rel: "stylesheet",
509
- id: M.hlcss
510
- }), O(
510
+ id: B.hlcss
511
+ }), z(
511
512
  "script",
512
513
  {
513
514
  ...t.value.js,
514
- id: M.hljs,
515
+ id: B.hljs,
515
516
  onload() {
516
517
  a.value = window.hljs;
517
518
  }
518
519
  },
519
520
  "hljs"
520
521
  ));
521
- }), x(
522
+ }), S(
522
523
  () => t.value.css,
523
524
  () => {
524
- e.noHighlight || P.editorExtensions.highlight.instance || tt("link", {
525
+ e.noHighlight || j.editorExtensions.highlight.instance || ot("link", {
525
526
  ...t.value.css,
526
527
  rel: "stylesheet",
527
- id: M.hlcss
528
+ id: B.hlcss
528
529
  });
529
530
  }
530
531
  ), a;
531
- }, yt = (e) => {
532
- const t = se(P.editorExtensions.katex.instance);
533
- return L(() => {
532
+ }, Ct = (e) => {
533
+ const t = de(j.editorExtensions.katex.instance);
534
+ return _(() => {
534
535
  if (e.noKatex || t.value)
535
536
  return;
536
- const { editorExtensions: a, editorExtensionsAttrs: o } = P;
537
- O(
537
+ const { editorExtensions: a, editorExtensionsAttrs: o } = j;
538
+ z(
538
539
  "script",
539
540
  {
540
541
  ...o.katex?.js,
541
542
  src: a.katex.js,
542
- id: M.katexjs,
543
+ id: B.katexjs,
543
544
  onload() {
544
545
  t.value = window.katex;
545
546
  }
546
547
  },
547
548
  "katex"
548
- ), O("link", {
549
+ ), z("link", {
549
550
  ...o.katex?.css,
550
551
  rel: "stylesheet",
551
552
  href: a.katex.css,
552
- id: M.katexcss
553
+ id: B.katexcss
553
554
  });
554
555
  }), t;
555
556
  };
556
- class bt {
557
+ class wt {
557
558
  constructor(t) {
558
559
  this.options = t;
559
560
  }
@@ -592,351 +593,361 @@ class bt {
592
593
  this.cache.clear();
593
594
  }
594
595
  }
595
- const oe = new bt({
596
- max: 1e3,
597
- // 缓存10分钟
598
- ttl: 6e5
599
- }), Ct = (e) => {
600
- const t = $("editorId"), a = $("theme"), o = $("rootRef"), { editorExtensions: n, editorExtensionsAttrs: c, mermaidConfig: i } = P;
601
- let d = n.mermaid.instance;
602
- const u = se(-1), r = () => {
603
- if (!e.noMermaid && d) {
604
- const s = a.value === "dark" ? {
605
- startOnLoad: !1,
606
- theme: "dark"
607
- } : {
608
- startOnLoad: !1,
609
- theme: "base",
610
- themeVariables: {
611
- background: "#ffffff",
612
- primaryColor: "#ffffff",
613
- primaryTextColor: "#1f2329",
614
- primaryBorderColor: "#b7c0cc",
615
- secondaryColor: "#f7f8fa",
616
- tertiaryColor: "#f7f8fa",
617
- lineColor: "#596273",
618
- edgeLabelBackground: "#ffffff",
619
- clusterBkg: "#ffffff",
620
- clusterBorder: "#b7c0cc"
621
- }
622
- };
623
- d.initialize(i(s)), u.value = u.value + 1;
624
- }
596
+ const Ae = /* @__PURE__ */ new WeakMap(), $t = (e, t) => {
597
+ const a = (Ae.get(e) || Promise.resolve()).then(t);
598
+ return Ae.set(
599
+ e,
600
+ a.then(
601
+ () => {
602
+ },
603
+ () => {
604
+ }
605
+ )
606
+ ), a;
607
+ }, Et = (e) => {
608
+ const t = E("editorId"), a = E("theme"), o = E("rootRef"), { editorExtensions: n, editorExtensionsAttrs: s, mermaidConfig: c } = j;
609
+ let u = n.mermaid.instance;
610
+ const d = de(0), r = new wt({ max: 1e3, ttl: 6e5 }), i = /* @__PURE__ */ new WeakSet(), l = /* @__PURE__ */ new WeakMap();
611
+ let m = 0, h = !1;
612
+ const g = ($, y) => r.get(JSON.stringify([d.value, $, y])), p = () => {
613
+ m += 1, r.clear(), d.value += 1;
625
614
  };
626
- return x(
627
- () => a.value,
615
+ S([a, () => e.sanitizeMermaid], p, { flush: "sync" }), S(
616
+ () => e.modelValue,
628
617
  () => {
629
- oe.clear(), r();
630
- }
631
- ), L(() => {
632
- if (e.noMermaid || d)
618
+ m += 1;
619
+ },
620
+ { flush: "sync" }
621
+ ), _(() => {
622
+ if (e.noMermaid || u)
633
623
  return;
634
- const s = n.mermaid.js;
635
- /\.mjs/.test(s) ? (O("link", {
636
- ...c.mermaid?.js,
624
+ const $ = n.mermaid.js, y = (b) => {
625
+ h || (u = b, p());
626
+ };
627
+ /\.mjs/.test($) ? (z("link", {
628
+ ...s.mermaid?.js,
637
629
  rel: "modulepreload",
638
- href: s,
639
- id: M.mermaidM
630
+ href: $,
631
+ id: B.mermaidM
640
632
  }), import(
641
633
  /* @vite-ignore */
642
634
  /* webpackIgnore: true */
643
- s
644
- ).then((m) => {
645
- d = m.default, r();
646
- }).catch((m) => {
647
- b.emit(t, re, {
635
+ $
636
+ ).then((b) => y(b.default)).catch((b) => {
637
+ h || w.emit(t, ce, {
648
638
  name: "mermaid",
649
- message: `Failed to load mermaid module: ${m.message}`,
650
- error: m
639
+ message: `Failed to load mermaid module: ${b.message}`,
640
+ error: b
651
641
  });
652
- })) : O(
642
+ })) : z(
653
643
  "script",
654
644
  {
655
- ...c.mermaid?.js,
656
- src: s,
657
- id: M.mermaid,
645
+ ...s.mermaid?.js,
646
+ src: $,
647
+ id: B.mermaid,
658
648
  onload() {
659
- d = window.mermaid, r();
649
+ y(window.mermaid);
660
650
  }
661
651
  },
662
652
  "mermaid"
663
653
  );
664
- }), { reRenderRef: u, replaceMermaid: async () => {
665
- if (!e.noMermaid && d) {
666
- const s = o.value;
667
- if (!s) return;
668
- const m = s.querySelectorAll(
669
- `div.${h}-mermaid`
670
- );
671
- if (m.length === 0) return;
672
- const f = document.createElement("div"), p = document.body.offsetWidth > 1366 ? document.body.offsetWidth : 1366, g = document.body.offsetHeight > 768 ? document.body.offsetHeight : 768;
673
- f.style.width = p + "px", f.style.height = g + "px", f.style.position = "fixed", f.style.zIndex = "-10000", f.style.top = "-10000px", f.style.left = "-10000px", document.body.appendChild(f);
674
- try {
675
- await Promise.allSettled(
676
- Array.from(m).map((v) => (async (y) => {
677
- if (y.dataset.closed === "false")
678
- return !1;
679
- const C = y.innerText;
680
- let T = oe.get(C);
681
- if (!T) {
682
- const w = fe();
683
- let k = { svg: "" };
684
- try {
685
- k = await d.render(w, C, f), T = await e.sanitizeMermaid(k.svg);
686
- const S = document.createElement("p");
687
- S.className = `${h}-mermaid`, S.setAttribute("data-processed", ""), S.setAttribute("data-content", C), S.innerHTML = T, S.children[0]?.removeAttribute("height"), oe.set(C, S.innerHTML), y.dataset.line !== void 0 && (S.dataset.line = y.dataset.line), y.replaceWith(S);
688
- } catch (S) {
689
- b.emit(t, re, {
690
- name: "mermaid",
691
- message: S.message,
692
- error: S
654
+ });
655
+ const v = async () => {
656
+ const $ = o.value;
657
+ if (h || e.noMermaid || !u || !$) return;
658
+ const y = u, b = $.querySelectorAll(
659
+ `div.${f}-mermaid, p.${f}-mermaid[data-processed]`
660
+ );
661
+ await Promise.all(
662
+ Array.from(b).filter((C) => C.dataset.closed !== "false" && C.dataset.mermaidRevision === String(d.value) && !i.has(C)).map((C) => {
663
+ const x = l.get(C);
664
+ if (x?.generation === m) return x.promise;
665
+ const T = (async () => {
666
+ const R = m, J = d.value, D = C.dataset.content ?? C.textContent ?? "", N = C.dataset.mermaidBlock, U = JSON.stringify([J, N, D]), W = e.sanitizeMermaid, X = a.value, V = () => !h && m === R && C.isConnected && $.contains(C);
667
+ if (V())
668
+ try {
669
+ let L = r.get(U);
670
+ if (L && C.dataset.processed !== void 0) {
671
+ L.bindFunctions?.(C), i.add(C);
672
+ return;
673
+ }
674
+ if (!L) {
675
+ const O = await $t(y, async () => {
676
+ if (!V()) return;
677
+ const K = {
678
+ startOnLoad: !1,
679
+ securityLevel: "strict",
680
+ secure: Array.from(
681
+ /* @__PURE__ */ new Set([
682
+ ...y.mermaidAPI?.defaultConfig?.secure || [],
683
+ "secure",
684
+ "securityLevel",
685
+ "startOnLoad",
686
+ "maxTextSize",
687
+ "suppressErrorRendering",
688
+ "maxEdges",
689
+ "dompurifyConfig"
690
+ ])
691
+ )
692
+ }, ee = {
693
+ ...K,
694
+ ...X === "dark" ? { theme: "dark" } : {
695
+ theme: "base",
696
+ themeVariables: {
697
+ background: "#ffffff",
698
+ primaryColor: "#ffffff",
699
+ primaryTextColor: "#1f2329",
700
+ primaryBorderColor: "#b7c0cc",
701
+ secondaryColor: "#f7f8fa",
702
+ tertiaryColor: "#f7f8fa",
703
+ lineColor: "#596273",
704
+ edgeLabelBackground: "#ffffff",
705
+ clusterBkg: "#ffffff",
706
+ clusterBorder: "#b7c0cc"
707
+ }
708
+ }
709
+ }, k = c(ee);
710
+ y.initialize({
711
+ ...k,
712
+ // 返回部分主题配置时仍继承安全默认值,显式覆盖则尊重调用方选择。
713
+ startOnLoad: k?.startOnLoad ?? !1,
714
+ securityLevel: k?.securityLevel ?? "strict",
715
+ secure: k?.secure ?? K.secure
716
+ });
717
+ const A = document.createElement("div");
718
+ A.style.cssText = "position:fixed;z-index:-10000;top:-10000px;left:-10000px;", A.style.width = Math.max(document.body.offsetWidth, 1366) + "px", A.style.height = Math.max(document.body.offsetHeight, 768) + "px", document.body.appendChild(A);
719
+ try {
720
+ return await y.render(he(), D, A);
721
+ } finally {
722
+ A.remove();
723
+ }
693
724
  });
725
+ if (!O || !V()) return;
726
+ const q = W ? await W(O.svg) : O.svg;
727
+ if (!V()) return;
728
+ if (typeof q != "string")
729
+ throw new TypeError("Mermaid sanitizer must return a string.");
730
+ L = { svg: q, bindFunctions: O.bindFunctions };
694
731
  }
732
+ if (!V()) return;
733
+ const P = document.createElement("p");
734
+ for (const O of Array.from(C.attributes))
735
+ P.setAttribute(O.name, O.value);
736
+ P.setAttribute("data-processed", ""), P.setAttribute("data-content", D), P.innerHTML = L.svg, P.children[0]?.removeAttribute("height");
737
+ const M = { ...L, svg: P.innerHTML };
738
+ C.replaceWith(P);
739
+ try {
740
+ L.bindFunctions?.(P), i.add(P);
741
+ } catch (O) {
742
+ throw P.replaceWith(C), O;
743
+ }
744
+ r.set(U, M);
745
+ } catch (L) {
746
+ if (!V()) return;
747
+ C.dataset.processed !== void 0 && (C.textContent = D, C.removeAttribute("data-processed")), w.emit(t, ce, {
748
+ name: "mermaid",
749
+ message: L?.message,
750
+ error: L
751
+ });
695
752
  }
696
- })(v))
697
- );
698
- } finally {
699
- f.remove();
700
- }
701
- }
702
- } };
703
- }, wt = (e, t) => {
753
+ })().finally(() => {
754
+ l.get(C)?.promise === T && l.delete(C);
755
+ });
756
+ return l.set(C, { generation: m, promise: T }), T;
757
+ })
758
+ );
759
+ };
760
+ return re(() => {
761
+ h = !0, m += 1, r.clear();
762
+ }), { reRenderRef: d, replaceMermaid: v, invalidateMermaid: p, getCachedMermaid: g };
763
+ }, xt = (e, t) => {
704
764
  t = t || {};
705
- const a = 3, o = t.marker || "!", n = o.charCodeAt(0), c = o.length;
706
- let i = "", d = "";
707
- const u = (l, s, m, f, p) => {
708
- const g = l[s];
709
- return g.type === "admonition_open" ? l[s].attrPush([
765
+ const a = 3, o = t.marker || "!", n = o.charCodeAt(0), s = o.length;
766
+ let c = "", u = "";
767
+ const d = (i, l, m, h, g) => {
768
+ const p = i[l];
769
+ return p.type === "admonition_open" ? i[l].attrPush([
710
770
  "class",
711
- `${h}-admonition ${h}-admonition-${g.info}`
712
- ]) : g.type === "admonition_title_open" && l[s].attrPush(["class", `${h}-admonition-title`]), p.renderToken(l, s, m);
713
- }, r = (l) => {
714
- const s = l.trim().split(" ", 2);
715
- d = "", i = s[0], s.length > 1 && (d = l.substring(i.length + 2));
771
+ `${f}-admonition ${f}-admonition-${p.info}`
772
+ ]) : p.type === "admonition_title_open" && i[l].attrPush(["class", `${f}-admonition-title`]), g.renderToken(i, l, m);
773
+ }, r = (i) => {
774
+ const l = i.trim().split(" ", 2);
775
+ u = "", c = l[0], l.length > 1 && (u = i.substring(c.length + 2));
716
776
  };
717
777
  e.block.ruler.before(
718
778
  "code",
719
779
  "admonition",
720
- (l, s, m, f) => {
721
- let p, g, v, E = !1, y = l.bMarks[s] + l.tShift[s], C = l.eMarks[s];
722
- if (n !== l.src.charCodeAt(y))
780
+ (i, l, m, h) => {
781
+ let g, p, v, $ = !1, y = i.bMarks[l] + i.tShift[l], b = i.eMarks[l];
782
+ if (n !== i.src.charCodeAt(y))
723
783
  return !1;
724
- for (p = y + 1; p <= C && o[(p - y) % c] === l.src[p]; p++)
784
+ for (g = y + 1; g <= b && o[(g - y) % s] === i.src[g]; g++)
725
785
  ;
726
- const T = Math.floor((p - y) / c);
727
- if (T !== a)
786
+ const C = Math.floor((g - y) / s);
787
+ if (C !== a)
728
788
  return !1;
729
- p -= (p - y) % c;
730
- const w = l.src.slice(y, p), k = l.src.slice(p, C);
731
- if (r(k), f)
789
+ g -= (g - y) % s;
790
+ const x = i.src.slice(y, g), F = i.src.slice(g, b);
791
+ if (r(F), h)
732
792
  return !0;
733
- for (g = s; g++, !(g >= m || (y = l.bMarks[g] + l.tShift[g], C = l.eMarks[g], y < C && l.sCount[g] < l.blkIndent)); )
734
- if (n === l.src.charCodeAt(y) && !(l.sCount[g] - l.blkIndent >= 4)) {
735
- for (p = y + 1; p <= C && o[(p - y) % c] === l.src[p]; p++)
793
+ for (p = l; p++, !(p >= m || (y = i.bMarks[p] + i.tShift[p], b = i.eMarks[p], y < b && i.sCount[p] < i.blkIndent)); )
794
+ if (n === i.src.charCodeAt(y) && !(i.sCount[p] - i.blkIndent >= 4)) {
795
+ for (g = y + 1; g <= b && o[(g - y) % s] === i.src[g]; g++)
736
796
  ;
737
- if (!(Math.floor((p - y) / c) < T) && (p -= (p - y) % c, p = l.skipSpaces(p), !(p < C))) {
738
- E = !0;
797
+ if (!(Math.floor((g - y) / s) < C) && (g -= (g - y) % s, g = i.skipSpaces(g), !(g < b))) {
798
+ $ = !0;
739
799
  break;
740
800
  }
741
801
  }
742
- const S = l.parentType, R = l.lineMax;
743
- return l.parentType = "root", l.lineMax = g, v = l.push("admonition_open", "div", 1), v.markup = w, v.block = !0, v.info = i, v.map = [s, g], d && (v = l.push("admonition_title_open", "p", 1), v.markup = w + " " + i, v.map = [s, g], v = l.push("inline", "", 0), v.content = d, v.map = [s, l.line - 1], v.children = [], v = l.push("admonition_title_close", "p", -1), v.markup = w + " " + i), l.md.block.tokenize(l, s + 1, g), v = l.push("admonition_close", "div", -1), v.markup = l.src.slice(y, p), v.block = !0, l.parentType = S, l.lineMax = R, l.line = g + (E ? 1 : 0), !0;
802
+ const T = i.parentType, R = i.lineMax;
803
+ return i.parentType = "root", i.lineMax = p, v = i.push("admonition_open", "div", 1), v.markup = x, v.block = !0, v.info = c, v.map = [l, p], u && (v = i.push("admonition_title_open", "p", 1), v.markup = x + " " + c, v.map = [l, p], v = i.push("inline", "", 0), v.content = u, v.map = [l, i.line - 1], v.children = [], v = i.push("admonition_title_close", "p", -1), v.markup = x + " " + c), i.md.block.tokenize(i, l + 1, p), v = i.push("admonition_close", "div", -1), v.markup = i.src.slice(y, g), v.block = !0, i.parentType = T, i.lineMax = R, i.line = p + ($ ? 1 : 0), !0;
744
804
  },
745
805
  {
746
806
  alt: ["paragraph", "reference", "blockquote", "list"]
747
807
  }
748
- ), e.renderer.rules.admonition_open = u, e.renderer.rules.admonition_title_open = u, e.renderer.rules.admonition_title_close = u, e.renderer.rules.admonition_close = u;
749
- }, $t = /^\s*\d+(?:\s*-\s*\d+)?(?:\s*,\s*\d+(?:\s*-\s*\d+)?)*\s*$/, Et = (e) => {
750
- const t = e.search(/\s/);
751
- let a = "", o = !1;
752
- for (let n = 0; n < e.length; n += 1) {
753
- const c = e[n];
754
- if (a) {
755
- if (o) {
756
- o = !1;
757
- continue;
758
- }
759
- if (c === "\\") {
760
- o = !0;
761
- continue;
762
- }
763
- c === a && (a = "");
764
- continue;
765
- }
766
- if (c === '"' || c === "'" || c === "`") {
767
- a = c;
768
- continue;
769
- }
770
- if (c !== "{")
771
- continue;
772
- const i = e.indexOf("}", n + 1);
773
- if (i === -1)
774
- break;
775
- const d = e.slice(n + 1, i);
776
- if (!$t.test(d))
777
- continue;
778
- const u = e[n - 1] || "", r = e[i + 1] || "", l = !r || /\s/.test(r), s = (t === -1 || n < t) && (!u || !/[\s="'`]/.test(u)) && l, m = (!u || /\s/.test(u)) && l;
779
- if (s || m)
780
- return {
781
- endIndex: i + 1,
782
- startIndex: n,
783
- value: d
784
- };
785
- }
786
- return null;
787
- }, ae = (e, t = "") => {
788
- const a = `${e}${t ? ` ${t}` : ""}`.trim(), o = Et(a), n = o ? `${a.slice(0, o.startIndex)} ${a.slice(o.endIndex)}`.trim() : a, c = n.search(/\s/), i = c === -1 ? n : n.slice(0, c), d = c === -1 ? "" : n.slice(c).trim(), u = o ? o.value.split(",").reduce((r, l) => {
789
- const [s, m] = l.split("-").map((p) => Number.parseInt(p.trim(), 10)), f = m ?? s;
790
- return s > 0 && f >= s && r.push({ start: s, end: f }), r;
791
- }, []) : [];
792
- return {
793
- attrs: d,
794
- language: i,
795
- lineHighlightRanges: u
796
- };
797
- }, te = (e, t, a) => `<${e.tag}${a.renderAttrs(e)}>${t}</${e.tag}>`, Te = (e, t) => {
798
- const a = e.attrs ? e.attrs.slice() : [];
799
- return t.forEach((o) => {
800
- const n = e.attrIndex(o[0]);
801
- n < 0 ? a.push(o) : (a[n] = a[n].slice(), a[n][1] += ` ${o[1]}`);
802
- }), a;
803
- }, xt = (e) => Array.from(e).map(
808
+ ), e.renderer.rules.admonition_open = d, e.renderer.rules.admonition_title_open = d, e.renderer.rules.admonition_title_close = d, e.renderer.rules.admonition_close = d;
809
+ }, St = (e) => Array.from(e).map(
804
810
  (t) => /[A-Za-z0-9_-]/.test(t) ? t : `_${t.codePointAt(0).toString(16)}_`
805
- ).join(""), It = (e, t) => {
806
- const a = e.renderer.rules.fence, o = e.utils.unescapeAll, n = /\[(\w*)(?::([\w ]*))?\]/, c = /::(open|close)/, i = xt(t.editorId), d = (m) => m.info ? o(m.info).trim() : "", u = (m) => {
807
- const f = d(m), [p = null, g = ""] = (n.exec(f) || []).slice(1);
808
- return [p, g];
809
- }, r = (m) => ae(d(m)).language, l = (m) => {
810
- const f = m.info.match(c) || [], p = f[1] === "open" || f[1] !== "close" && t.codeFoldable && m.content.trim().split(`
811
- `).length < t.autoFoldThreshold, g = f[1] || t.codeFoldable ? "details" : "div", v = f[1] || t.codeFoldable ? "summary" : "div";
812
- return { open: p, tagContainer: g, tagHeader: v };
813
- }, s = (m, f, p, g, v) => {
814
- if (m[f].hidden)
811
+ ).join(""), Tt = (e, t) => {
812
+ const a = e.renderer.rules.fence, o = e.utils.unescapeAll, n = /\[(\w*)(?::([\w ]*))?\]/, s = /::(open|close)/, c = St(t.editorId), u = (m) => m.info ? o(m.info).trim() : "", d = (m) => {
813
+ const h = u(m), [g = null, p = ""] = (n.exec(h) || []).slice(1);
814
+ return [g, p];
815
+ }, r = (m) => le(u(m)).language, i = (m) => {
816
+ const h = m.info.match(s) || [], g = h[1] === "open" || h[1] !== "close" && t.codeFoldable && m.content.trim().split(`
817
+ `).length < t.autoFoldThreshold, p = h[1] || t.codeFoldable ? "details" : "div", v = h[1] || t.codeFoldable ? "summary" : "div";
818
+ return { open: g, tagContainer: p, tagHeader: v };
819
+ }, l = (m, h, g, p, v) => {
820
+ if (m[h].hidden)
815
821
  return "";
816
- const E = t.usedLanguageTextRef.value?.copyCode.text || "", y = t.customIconRef.value.copy, C = e.utils.escapeHtml(E), T = y || C, w = !!y, k = `<span class="${h}-collapse-tips">${nt("collapse-tips", t.customIconRef.value)}</span>`, [S] = u(m[f]);
817
- if (S === null) {
818
- const { open: A, tagContainer: _, tagHeader: Q } = l(m[f]), G = [["class", `${h}-code`]];
819
- A && G.push(["open", ""]);
820
- const ee = {
821
- attrs: Te(m[f], G)
822
+ const $ = t.usedLanguageTextRef.value?.copyCode.text || "", y = t.customIconRef.value.copy, b = e.utils.escapeHtml($), C = y || b, x = !!y, F = `<span class="${f}-collapse-tips">${at("collapse-tips", t.customIconRef.value)}</span>`, [T] = d(m[h]);
823
+ if (T === null) {
824
+ const { open: k, tagContainer: A, tagHeader: G } = i(m[h]), te = [["class", `${f}-code`]];
825
+ k && te.push(["open", ""]);
826
+ const se = {
827
+ attrs: ke(m[h], te)
822
828
  };
823
- m[f].info = m[f].info.replace(c, "");
824
- const { attrs: Oe, language: Ne } = ae(
825
- d(m[f])
826
- ), ve = [Ne, Oe].filter(Boolean).join(" "), Be = a(m, f, p, g, v);
829
+ m[h].info = m[h].info.replace(s, "");
830
+ const { attrs: ne, language: oe } = le(
831
+ u(m[h])
832
+ ), ye = [oe, ne].filter(Boolean).join(" "), Ve = a(m, h, g, p, v);
827
833
  return `
828
- <${_} ${v.renderAttrs(ee)}>
829
- <${Q} class="${h}-code-head">
830
- <div class="${h}-code-flag"><span></span><span></span><span></span></div>
831
- <div class="${h}-code-action">
832
- <span class="${h}-code-lang">${e.utils.escapeHtml(ve)}</span>
833
- <span class="${h}-copy-button" data-tips="${C}"${w ? " data-is-icon=true" : ""}>${T}</span>
834
- ${t.extraTools instanceof Function ? t.extraTools({ lang: ve }) : t.extraTools || ""}
835
- ${_ === "details" ? k : ""}
834
+ <${A} ${v.renderAttrs(se)}>
835
+ <${G} class="${f}-code-head">
836
+ <div class="${f}-code-flag"><span></span><span></span><span></span></div>
837
+ <div class="${f}-code-action">
838
+ <span class="${f}-code-lang">${e.utils.escapeHtml(ye)}</span>
839
+ <span class="${f}-copy-button" data-tips="${b}"${x ? " data-is-icon=true" : ""}>${C}</span>
840
+ ${t.extraTools instanceof Function ? t.extraTools({ lang: ye }) : t.extraTools || ""}
841
+ ${A === "details" ? F : ""}
836
842
  </div>
837
- </${Q}>
838
- ${Be}
839
- </${_}>
843
+ </${G}>
844
+ ${Ve}
845
+ </${A}>
840
846
  `;
841
847
  }
842
- let R, N, D, B, q = "", K = "", Z = "";
843
- const { open: ie, tagContainer: H, tagHeader: J } = l(m[f]), V = [["class", `${h}-code`]];
844
- ie && V.push(["open", ""]);
845
- const X = {
846
- attrs: Te(m[f], V)
848
+ let R, J, D, N, U = "", W = "", X = "";
849
+ const { open: V, tagContainer: L, tagHeader: P } = i(m[h]), M = [["class", `${f}-code`]];
850
+ V && M.push(["open", ""]);
851
+ const O = {
852
+ attrs: ke(m[h], M)
847
853
  };
848
- for (let A = f; A < m.length && (R = m[A], [N, D] = u(R), N === S); A++) {
849
- R.info = R.info.replace(n, "").replace(c, ""), R.hidden = !0;
850
- const _ = `${h}-codetab-${i}-${f}-${A - f}`;
851
- B = A - f > 0 ? "" : "checked", q += `
854
+ for (let k = h; k < m.length && (R = m[k], [J, D] = d(R), J === T); k++) {
855
+ R.info = R.info.replace(n, "").replace(s, ""), R.hidden = !0;
856
+ const A = `${f}-codetab-${c}-${h}-${k - h}`;
857
+ N = k - h > 0 ? "" : "checked", U += `
852
858
  <li>
853
859
  <input
854
860
  type="radio"
855
- id="label-${h}-codetab-label-1-${i}-${f}-${A - f}"
856
- name="${h}-codetab-label-${i}-${f}"
857
- class="${_}"
858
- ${B}
861
+ id="label-${f}-codetab-label-1-${c}-${h}-${k - h}"
862
+ name="${f}-codetab-label-${c}-${h}"
863
+ class="${A}"
864
+ ${N}
859
865
  >
860
866
  <label
861
- for="label-${h}-codetab-label-1-${i}-${f}-${A - f}"
862
- onclick="this.getRootNode().querySelectorAll('.${_}').forEach(e => e.click())"
867
+ for="label-${f}-codetab-label-1-${c}-${h}-${k - h}"
868
+ onclick="this.getRootNode().querySelectorAll('.${A}').forEach(e => e.click())"
863
869
  >
864
870
  ${e.utils.escapeHtml(D || r(R))}
865
871
  </label>
866
- </li>`, K += `
872
+ </li>`, W += `
867
873
  <div role="tabpanel">
868
874
  <input
869
875
  type="radio"
870
- name="${h}-codetab-pre-${i}-${f}"
871
- class="${_}"
872
- ${B}
876
+ name="${f}-codetab-pre-${c}-${h}"
877
+ class="${A}"
878
+ ${N}
873
879
  role="presentation">
874
- ${a(m, A, p, g, v)}
875
- </div>`, Z += `
880
+ ${a(m, k, g, p, v)}
881
+ </div>`, X += `
876
882
  <input
877
883
  type="radio"
878
- name="${h}-codetab-lang-${i}-${f}"
879
- class="${_}"
880
- ${B}
884
+ name="${f}-codetab-lang-${c}-${h}"
885
+ class="${A}"
886
+ ${N}
881
887
  role="presentation">
882
- <span class=${h}-code-lang role="note">${e.utils.escapeHtml(r(R))}</span>`;
888
+ <span class=${f}-code-lang role="note">${e.utils.escapeHtml(r(R))}</span>`;
883
889
  }
884
- const { attrs: ce, language: z } = ae(
885
- d(m[f])
886
- ), Y = [z, ce].filter(Boolean).join(" ");
890
+ const { attrs: q, language: K } = le(
891
+ u(m[h])
892
+ ), ee = [K, q].filter(Boolean).join(" ");
887
893
  return `
888
- <${H} ${v.renderAttrs(X)}>
889
- <${J} class="${h}-code-head">
890
- <div class="${h}-code-flag">
891
- <ul class="${h}-codetab-label" role="tablist">${q}</ul>
894
+ <${L} ${v.renderAttrs(O)}>
895
+ <${P} class="${f}-code-head">
896
+ <div class="${f}-code-flag">
897
+ <ul class="${f}-codetab-label" role="tablist">${U}</ul>
892
898
  </div>
893
- <div class="${h}-code-action">
894
- <span class="${h}-codetab-lang">${Z}</span>
895
- <span class="${h}-copy-button" data-tips="${C}"${w ? " data-is-icon=true" : ""}>${T}</span>
896
- ${t.extraTools instanceof Function ? t.extraTools({ lang: Y }) : t.extraTools || ""}
897
- ${H === "details" ? k : ""}
899
+ <div class="${f}-code-action">
900
+ <span class="${f}-codetab-lang">${X}</span>
901
+ <span class="${f}-copy-button" data-tips="${b}"${x ? " data-is-icon=true" : ""}>${C}</span>
902
+ ${t.extraTools instanceof Function ? t.extraTools({ lang: ee }) : t.extraTools || ""}
903
+ ${L === "details" ? F : ""}
898
904
  </div>
899
- </${J}>
900
- ${K}
901
- </${H}>
905
+ </${P}>
906
+ ${W}
907
+ </${L}>
902
908
  `;
903
909
  };
904
- e.renderer.rules.fence = s, e.renderer.rules.code_block = s;
905
- }, Tt = (e, t) => {
910
+ e.renderer.rules.fence = l, e.renderer.rules.code_block = l;
911
+ }, It = (e, t) => {
906
912
  e.core.ruler.after("block", "echarts-token-attrs", (o) => {
907
- o.tokens.forEach((n) => {
908
- if (!(n.type !== "fence" || n.info !== "echarts") && (n.tag = "div", n.attrJoin("class", `${h}-echarts`), n.attrSet("data-echarts-theme", t.themeRef.value), n.attrSet("style", "width: 100%; aspect-ratio: 4 / 3;"), n.map && n.level === 0)) {
909
- const c = n.map[1] - 1, d = !!o.env.srcLines?.[c]?.trim()?.startsWith("```");
910
- n.attrSet("data-closed", `${d}`), n.attrSet("data-line", String(n.map[0]));
913
+ let n;
914
+ o.tokens.forEach((s) => {
915
+ if (!(s.type !== "fence" || s.info.trim() !== "echarts") && (s.tag = "div", s.attrJoin("class", `${f}-echarts`), s.attrSet("data-echarts-theme", t.themeRef.value), s.attrSet("style", "width: 100%; aspect-ratio: 4 / 3;"), s.map)) {
916
+ n ??= o.src.split(`
917
+ `);
918
+ const c = s.content ? s.content.split(`
919
+ `).length - Number(s.content.endsWith(`
920
+ `)) : 0, u = n[s.map[1] - 1].trimEnd(), d = s.map[1] - s.map[0] === c + 2 && u.endsWith(s.markup);
921
+ s.attrSet("data-closed", `${d}`), s.level === 0 && s.attrSet("data-line", String(s.map[0]));
911
922
  }
912
923
  });
913
924
  });
914
925
  const a = e.renderer.rules.fence.bind(e.renderer.rules);
915
- e.renderer.rules.fence = (o, n, c, i, d) => {
916
- const u = o[n], r = u.content.trim();
917
- return u.info === "echarts" ? te(u, e.utils.escapeHtml(r), d) : a(o, n, c, i, d);
926
+ e.renderer.rules.fence = (o, n, s, c, u) => {
927
+ const d = o[n];
928
+ return d.info.trim() === "echarts" ? ae(d, e.utils.escapeHtml(d.content.trim()), u) : a(o, n, s, c, u);
918
929
  };
919
- }, St = (e, t) => {
930
+ }, kt = (e, t) => {
920
931
  e.renderer.rules.heading_open = (a, o) => {
921
- const n = a[o], c = a[o + 1].children?.reduce((d, u) => d + (["text", "code_inline", "math_inline"].includes(u.type) && u.content || ""), "") || "", i = n.markup.length;
932
+ const n = a[o], s = a[o + 1].children?.reduce((u, d) => u + (["text", "code_inline", "math_inline"].includes(d.type) && d.content || ""), "") || "", c = n.markup.length;
922
933
  return t.headsRef.value.push({
923
- text: c,
924
- level: i,
934
+ text: s,
935
+ level: c,
925
936
  line: n.map[0],
926
937
  currentToken: n,
927
938
  nextToken: a[o + 1]
928
939
  }), n.map && n.level === 0 && n.attrSet(
929
940
  "id",
930
941
  t.mdHeadingId({
931
- text: c,
932
- level: i,
942
+ text: s,
943
+ level: c,
933
944
  index: t.headsRef.value.length,
934
945
  currentToken: n,
935
946
  nextToken: a[o + 1]
936
947
  })
937
948
  ), e.renderer.renderToken(a, o, t);
938
- }, e.renderer.rules.heading_close = (a, o, n, c, i) => i.renderToken(a, o, n);
939
- }, Se = {
949
+ }, e.renderer.rules.heading_close = (a, o, n, s, c) => c.renderToken(a, o, n);
950
+ }, Fe = {
940
951
  block: [
941
952
  { open: "$$", close: "$$" },
942
953
  { open: "\\[", close: "\\]" }
@@ -947,350 +958,347 @@ const oe = new bt({
947
958
  { open: "\\[", close: "\\]" },
948
959
  { open: "\\(", close: "\\)" }
949
960
  ]
950
- }, kt = (e) => (t, a) => {
961
+ }, At = (e) => (t, a) => {
951
962
  const o = e.delimiters;
952
963
  for (const n of o) {
953
964
  if (!t.src.startsWith(n.open, t.pos))
954
965
  continue;
955
- const c = t.pos + n.open.length;
956
- let i = c;
957
- for (; (i = t.src.indexOf(n.close, i)) !== -1; ) {
958
- let d = 0, u = i - 1;
959
- for (; u >= 0 && t.src[u] === "\\"; )
960
- d++, u--;
961
- if (d % 2 === 0)
966
+ const s = t.pos + n.open.length;
967
+ let c = s;
968
+ for (; (c = t.src.indexOf(n.close, c)) !== -1; ) {
969
+ let u = 0, d = c - 1;
970
+ for (; d >= 0 && t.src[d] === "\\"; )
971
+ u++, d--;
972
+ if (u % 2 === 0)
962
973
  break;
963
- i += n.close.length;
974
+ c += n.close.length;
964
975
  }
965
- if (i !== -1) {
966
- if (i - c === 0)
967
- return a || (t.pending += n.open + n.close), t.pos = i + n.close.length, !0;
976
+ if (c !== -1) {
977
+ if (c - s === 0)
978
+ return a || (t.pending += n.open + n.close), t.pos = c + n.close.length, !0;
968
979
  if (!a) {
969
- const d = t.push("math_inline", e.tag, 0);
970
- d.attrSet("class", e.className), d.markup = n.open, d.content = t.src.slice(c, i);
980
+ const u = t.push("math_inline", e.tag, 0);
981
+ u.attrSet("class", e.className), u.markup = n.open, u.content = t.src.slice(s, c);
971
982
  }
972
- return t.pos = i + n.close.length, !0;
983
+ return t.pos = c + n.close.length, !0;
973
984
  }
974
985
  }
975
986
  return !1;
976
- }, At = (e) => (t, a, o, n) => {
977
- const c = e.delimiters, i = t.bMarks[a] + t.tShift[a], d = t.eMarks[a], u = (r, l, s) => {
978
- t.line = l;
987
+ }, Ft = (e) => (t, a, o, n) => {
988
+ const s = e.delimiters, c = t.bMarks[a] + t.tShift[a], u = t.eMarks[a], d = (r, i, l) => {
989
+ t.line = i;
979
990
  const m = t.push("math_block", e.tag, 0);
980
- return m.attrSet("class", e.className), m.block = !0, m.content = r, m.map = [a, t.line], m.markup = s, !0;
991
+ return m.attrSet("class", e.className), m.block = !0, m.content = r, m.map = [a, t.line], m.markup = l, !0;
981
992
  };
982
- for (const r of c) {
983
- const l = i;
984
- if (t.src.slice(l, l + r.open.length) !== r.open)
993
+ for (const r of s) {
994
+ const i = c;
995
+ if (t.src.slice(i, i + r.open.length) !== r.open)
985
996
  continue;
986
- const s = l + r.open.length, m = t.src.slice(s, d).trim(), f = m === "", p = m === r.close, g = m.endsWith(r.close);
987
- if (!f && !p && !g)
997
+ const l = i + r.open.length, m = t.src.slice(l, u).trim(), h = m === "", g = m === r.close, p = m.endsWith(r.close);
998
+ if (!h && !g && !p)
988
999
  continue;
989
1000
  if (n)
990
1001
  return !0;
991
- if (p)
992
- return u("", a + 1, r.open);
993
- if (!f && g) {
994
- const w = m.slice(0, -r.close.length);
995
- return u(w, a + 1, r.open);
1002
+ if (g)
1003
+ return d("", a + 1, r.open);
1004
+ if (!h && p) {
1005
+ const x = m.slice(0, -r.close.length);
1006
+ return d(x, a + 1, r.open);
996
1007
  }
997
- let v = a + 1, E = !1, y = "";
1008
+ let v = a + 1, $ = !1, y = "";
998
1009
  for (; v < o; v++) {
999
- const w = t.bMarks[v] + t.tShift[v], k = t.eMarks[v];
1000
- if (w < k && t.tShift[v] < t.blkIndent)
1010
+ const x = t.bMarks[v] + t.tShift[v], F = t.eMarks[v];
1011
+ if (x < F && t.tShift[v] < t.blkIndent)
1001
1012
  break;
1002
- if (t.src.slice(w, k).trim().endsWith(r.close)) {
1003
- const R = t.src.slice(0, k).lastIndexOf(r.close);
1004
- y = t.src.slice(w, R), E = !0;
1013
+ if (t.src.slice(x, F).trim().endsWith(r.close)) {
1014
+ const R = t.src.slice(0, F).lastIndexOf(r.close);
1015
+ y = t.src.slice(x, R), $ = !0;
1005
1016
  break;
1006
1017
  }
1007
1018
  }
1008
- if (!E)
1019
+ if (!$)
1009
1020
  continue;
1010
- const T = t.getLines(a + 1, v, t.tShift[a], !0) + (y.trim() ? y : "");
1011
- return u(T, v + 1, r.open);
1021
+ const C = t.getLines(a + 1, v, t.tShift[a], !0) + (y.trim() ? y : "");
1022
+ return d(C, v + 1, r.open);
1012
1023
  }
1013
1024
  return !1;
1014
- }, Ht = (e, { katexRef: t, inlineDelimiters: a, blockDelimiters: o }) => {
1015
- const n = (d, u, r = !1) => {
1025
+ }, Rt = (e, { katexRef: t, inlineDelimiters: a, blockDelimiters: o }) => {
1026
+ const n = (u, d, r = !1) => {
1016
1027
  if (!t.value)
1017
- return te(d, e.utils.escapeHtml(d.content), u);
1018
- const l = t.value.renderToString(
1019
- d.content,
1020
- P.katexConfig({
1021
- throwOnError: !1,
1022
- displayMode: r
1023
- })
1024
- );
1025
- return d.attrSet("data-processed", ""), te(d, String(l), u);
1026
- }, c = (d, u, r, l, s) => n(d[u], s), i = (d, u, r, l, s) => n(d[u], s, !0);
1028
+ return ae(u, e.utils.escapeHtml(u.content), d);
1029
+ const i = { throwOnError: !1, displayMode: r, trust: !1 }, l = j.katexConfig(i), m = t.value.renderToString(u.content, {
1030
+ ...i,
1031
+ ...l,
1032
+ // 配置其他选项不应隐式开放 HTML 命令;调用方仍可显式传 true 或判断函数。
1033
+ trust: l?.trust ?? !1
1034
+ });
1035
+ return u.attrSet("data-processed", ""), ae(u, String(m), d);
1036
+ }, s = (u, d, r, i, l) => n(u[d], l), c = (u, d, r, i, l) => n(u[d], l, !0);
1027
1037
  e.inline.ruler.before(
1028
1038
  "escape",
1029
1039
  "math_inline",
1030
- kt({
1031
- delimiters: a || Se.inline,
1032
- className: `${h}-katex-inline`,
1040
+ At({
1041
+ delimiters: a || Fe.inline,
1042
+ className: `${f}-katex-inline`,
1033
1043
  tag: "span"
1034
1044
  })
1035
1045
  ), e.block.ruler.after(
1036
1046
  "blockquote",
1037
1047
  "math_block",
1038
- At({
1039
- delimiters: o || Se.block,
1040
- className: `${h}-katex-block`,
1048
+ Ft({
1049
+ delimiters: o || Fe.block,
1050
+ className: `${f}-katex-block`,
1041
1051
  tag: "p"
1042
1052
  }),
1043
1053
  {
1044
1054
  alt: ["paragraph", "reference", "blockquote", "list"]
1045
1055
  }
1046
- ), e.renderer.rules.math_inline = c, e.renderer.rules.math_block = i;
1047
- }, Ft = (e, t) => {
1056
+ ), e.renderer.rules.math_inline = s, e.renderer.rules.math_block = c;
1057
+ }, Mt = (e, t) => {
1048
1058
  e.core.ruler.after("block", "mermaid-token-attrs", (o) => {
1049
- o.tokens.forEach((n) => {
1050
- if (!(n.type !== "fence" || n.info !== "mermaid") && (n.tag = "div", n.attrJoin("class", `${h}-mermaid`), n.attrSet("data-mermaid-theme", t.themeRef.value), n.map && n.level === 0)) {
1059
+ o.tokens.forEach((n, s) => {
1060
+ if (!(n.type !== "fence" || n.info !== "mermaid") && (n.tag = "div", n.attrJoin("class", `${f}-mermaid`), n.attrSet("data-mermaid-theme", t.themeRef.value), n.attrSet("data-mermaid-block", String(n.map?.[0] ?? s)), n.attrSet("data-mermaid-revision", String(t.revision?.value ?? 0)), n.map && n.level === 0)) {
1051
1061
  const c = n.map[1] - 1, d = !!o.env.srcLines?.[c]?.trim()?.startsWith("```");
1052
1062
  n.attrSet("data-closed", `${d}`), n.attrSet("data-line", String(n.map[0]));
1053
1063
  }
1054
1064
  });
1055
1065
  });
1056
1066
  const a = e.renderer.rules.fence.bind(e.renderer.rules);
1057
- e.renderer.rules.fence = (o, n, c, i, d) => {
1058
- const u = o[n], r = u.content.trim();
1059
- if (u.info === "mermaid") {
1060
- const l = oe.get(r);
1061
- return l ? (u.tag = "p", u.attrSet("data-processed", ""), u.attrSet("data-content", r), te(u, l, d)) : te(u, e.utils.escapeHtml(r), d);
1067
+ e.renderer.rules.fence = (o, n, s, c, u) => {
1068
+ const d = o[n], r = d.content.trim();
1069
+ if (d.info === "mermaid") {
1070
+ const i = d.attrGet("data-closed") !== "false" ? t.getCached?.(d.attrGet("data-mermaid-block") ?? void 0, r) : void 0;
1071
+ return i ? (d.tag = "p", d.attrSet("data-processed", ""), d.attrSet("data-content", r), ae(d, i.svg, u)) : ae(d, e.utils.escapeHtml(r), u);
1062
1072
  }
1063
- return a(o, n, c, i, d);
1073
+ return a(o, n, s, c, u);
1064
1074
  };
1065
- }, ke = (e, t, a) => {
1075
+ }, Re = (e, t, a) => {
1066
1076
  const o = e.attrIndex(t), n = [t, a];
1067
1077
  o < 0 ? e.attrPush(n) : (e.attrs = e.attrs || [], e.attrs[o] = n);
1068
- }, Rt = (e) => e.type === "inline", Lt = (e) => e.type === "paragraph_open", Mt = (e) => e.type === "list_item_open", Pt = (e) => e.content.indexOf("[ ] ") === 0 || e.content.indexOf("[x] ") === 0 || e.content.indexOf("[X] ") === 0, _t = (e, t) => Rt(e[t]) && Lt(e[t - 1]) && Mt(e[t - 2]) && Pt(e[t]), Ot = (e, t) => {
1078
+ }, Lt = (e) => e.type === "inline", Ht = (e) => e.type === "paragraph_open", Pt = (e) => e.type === "list_item_open", Ot = (e) => e.content.indexOf("[ ] ") === 0 || e.content.indexOf("[x] ") === 0 || e.content.indexOf("[X] ") === 0, _t = (e, t) => Lt(e[t]) && Ht(e[t - 1]) && Pt(e[t - 2]) && Ot(e[t]), Nt = (e, t) => {
1069
1079
  const a = e[t].level - 1;
1070
1080
  for (let o = t - 1; o >= 0; o--)
1071
1081
  if (e[o].level === a)
1072
1082
  return o;
1073
1083
  return -1;
1074
- }, Nt = (e) => {
1075
- const t = new e("html_inline", "", 0);
1076
- return t.content = "<label>", t;
1077
- }, Bt = (e) => {
1078
- const t = new e("html_inline", "", 0);
1079
- return t.content = "</label>", t;
1080
- }, jt = (e, t, a) => {
1081
- const o = new a("html_inline", "", 0);
1082
- return o.content = '<label class="task-list-item-label" for="' + t + '">' + e + "</label>", o.attrs = [["for", t]], o;
1083
- }, Dt = (e, t, a) => {
1084
+ }, Me = (e) => new e("label_open", "label", 1), Le = (e) => new e("label_close", "label", -1), Bt = (e, t, a) => {
1084
1085
  const o = new t("html_inline", "", 0), n = a.enabled ? " " : ' disabled="" ';
1085
1086
  return e.content.indexOf("[ ] ") === 0 ? o.content = '<input class="task-list-item-checkbox"' + n + 'type="checkbox">' : (e.content.indexOf("[x] ") === 0 || e.content.indexOf("[X] ") === 0) && (o.content = '<input class="task-list-item-checkbox" checked=""' + n + 'type="checkbox">'), o;
1086
- }, Vt = (e, t, a) => {
1087
- if (e.children = e.children || [], e.children.unshift(Dt(e, t, a)), e.children[1].content = e.children[1].content.slice(3), e.content = e.content.slice(3), a.label)
1087
+ }, jt = (e, t, a) => {
1088
+ if (e.children = e.children || [], e.children.unshift(Bt(e, t, a)), e.children[1].content = e.children[1].content.slice(3), e.content = e.content.slice(3), a.label)
1088
1089
  if (a.labelAfter) {
1089
- e.children.pop();
1090
- const o = "task-item-" + Math.ceil(Math.random() * (1e4 * 1e3) - 1e3);
1091
- e.children[0].content = e.children[0].content.slice(0, -1) + ' id="' + o + '">', e.children.push(jt(e.content, o, t));
1090
+ const o = "task-item-" + Math.ceil(Math.random() * 1e7 - 1e3);
1091
+ e.children[0].content = e.children[0].content.slice(0, -1) + ' id="' + o + '">';
1092
+ const n = Me(t);
1093
+ n.attrSet("class", "task-list-item-label"), n.attrSet("for", o), e.children.splice(1, 0, n), e.children.push(Le(t));
1092
1094
  } else
1093
- e.children.unshift(Nt(t)), e.children.push(Bt(t));
1094
- }, zt = (e, t = {}) => {
1095
+ e.children.unshift(Me(t)), e.children.push(Le(t));
1096
+ }, Dt = (e, t = {}) => {
1095
1097
  e.core.ruler.after("inline", "github-task-lists", (a) => {
1096
1098
  const o = a.tokens;
1097
1099
  for (let n = 2; n < o.length; n++)
1098
- _t(o, n) && (Vt(o[n], a.Token, t), ke(
1100
+ _t(o, n) && (jt(o[n], a.Token, t), Re(
1099
1101
  o[n - 2],
1100
1102
  "class",
1101
1103
  "task-list-item" + (t.enabled ? " enabled" : " ")
1102
- ), ke(o[Ot(o, n - 2)], "class", "contains-task-list"));
1104
+ ), Re(o[Nt(o, n - 2)], "class", "contains-task-list"));
1103
1105
  });
1104
- }, Gt = (e) => {
1106
+ }, Vt = (e) => {
1105
1107
  e.core.ruler.push("init-line-number", (t) => (t.tokens.forEach((a) => {
1106
1108
  a.map && a.attrSet("data-line", a.map[0].toString());
1107
1109
  }), !0));
1108
- }, Ut = (e, t) => {
1109
- const { editorConfig: a, markdownItConfig: o, markdownItPlugins: n, editorExtensions: c } = P, i = $("editorId"), d = $("language"), u = $(
1110
+ }, zt = (e, t) => {
1111
+ const { editorConfig: a, markdownItConfig: o, markdownItPlugins: n, editorExtensions: s } = j, c = E("editorId"), u = E("language"), d = E(
1110
1112
  "usedLanguageText"
1111
- ), r = $("showCodeRowNumber"), l = $("theme"), s = $("customIcon"), m = $("rootRef"), f = $("setting"), p = U([]), g = vt(e), v = yt(e), { reRenderRef: E, replaceMermaid: y } = Ct(e), { reRenderEcharts: C, replaceEcharts: T } = gt(e), w = st({
1113
+ ), r = E("showCodeRowNumber"), i = E("theme"), l = E("customIcon"), m = E("rootRef"), h = E("setting"), g = Q([]), p = bt(e), v = Ct(e), { reRenderRef: $, replaceMermaid: y, invalidateMermaid: b, getCachedMermaid: C } = Et(e), { reRenderEcharts: x, replaceEcharts: F } = yt(e), T = lt({
1112
1114
  // 关闭源文本中的原生 HTML 解析,插件生成的 HTML 不受影响。
1113
1115
  html: !1,
1114
1116
  breaks: !0,
1115
1117
  linkify: !0
1116
1118
  });
1117
- o(w, {
1118
- editorId: i
1119
+ o(T, {
1120
+ editorId: c
1119
1121
  });
1120
- const k = [
1122
+ const R = [
1121
1123
  {
1122
1124
  type: "image",
1123
- plugin: lt,
1125
+ plugin: ct,
1124
1126
  options: { figcaption: !0, classes: "md-zoom" }
1125
1127
  },
1126
1128
  {
1127
1129
  type: "admonition",
1128
- plugin: wt,
1130
+ plugin: xt,
1129
1131
  options: {}
1130
1132
  },
1131
1133
  {
1132
1134
  type: "taskList",
1133
- plugin: zt,
1135
+ plugin: Dt,
1134
1136
  options: {}
1135
1137
  },
1136
1138
  {
1137
1139
  type: "heading",
1138
- plugin: St,
1139
- options: { mdHeadingId: e.mdHeadingId, headsRef: p }
1140
+ plugin: kt,
1141
+ options: { mdHeadingId: e.mdHeadingId, headsRef: g }
1140
1142
  },
1141
1143
  {
1142
1144
  type: "code",
1143
- plugin: It,
1145
+ plugin: Tt,
1144
1146
  options: {
1145
- editorId: i,
1146
- usedLanguageTextRef: u,
1147
+ editorId: c,
1148
+ usedLanguageTextRef: d,
1147
1149
  // showCodeRowNumber,
1148
1150
  codeFoldable: e.codeFoldable,
1149
1151
  autoFoldThreshold: e.autoFoldThreshold,
1150
- customIconRef: s
1152
+ customIconRef: l
1151
1153
  }
1152
1154
  },
1153
1155
  {
1154
1156
  type: "sub",
1155
- plugin: it,
1157
+ plugin: dt,
1156
1158
  options: {}
1157
1159
  },
1158
1160
  {
1159
1161
  type: "sup",
1160
- plugin: ct,
1162
+ plugin: ut,
1161
1163
  options: {}
1162
1164
  }
1163
1165
  ];
1164
- e.noKatex || k.push({
1166
+ e.noKatex || R.push({
1165
1167
  type: "katex",
1166
- plugin: Ht,
1168
+ plugin: Rt,
1167
1169
  options: { katexRef: v }
1168
- }), e.noMermaid || k.push({
1170
+ }), e.noMermaid || R.push({
1169
1171
  type: "mermaid",
1170
- plugin: Ft,
1171
- options: { themeRef: l }
1172
- }), e.noEcharts || k.push({
1172
+ plugin: Mt,
1173
+ options: { themeRef: i, revision: $, getCached: C }
1174
+ }), e.noEcharts || R.push({
1173
1175
  type: "echarts",
1174
- plugin: Tt,
1175
- options: { themeRef: l }
1176
- }), n(k, {
1177
- editorId: i
1178
- }).forEach((H) => {
1179
- w.use(H.plugin, H.options);
1176
+ plugin: It,
1177
+ options: { themeRef: i }
1178
+ }), n(R, {
1179
+ editorId: c
1180
+ }).forEach((M) => {
1181
+ T.use(M.plugin, M.options);
1180
1182
  });
1181
- const S = w.options.highlight;
1182
- w.set({
1183
- highlight: (H, J, V) => {
1184
- const X = ae(J, V), { attrs: ce, language: z, lineHighlightRanges: Y } = X;
1185
- let A = "";
1186
- if (S) {
1187
- const G = S(H, z, ce);
1188
- if (G) {
1189
- const ee = dt(G, H, {
1190
- lineHighlightRanges: Y,
1183
+ const J = T.options.highlight;
1184
+ T.set({
1185
+ highlight: (M, O, q) => {
1186
+ const K = le(O, q), { attrs: ee, language: k, lineHighlightRanges: A } = K;
1187
+ let G = "";
1188
+ if (J) {
1189
+ const ne = J(M, k, ee);
1190
+ if (ne) {
1191
+ const oe = mt(ne, M, {
1192
+ lineHighlightRanges: A,
1191
1193
  showLineNumber: r
1192
1194
  });
1193
- if (ee.shouldReturnDirectly)
1194
- return ee.html;
1195
- A = ee.html;
1195
+ if (oe.shouldReturnDirectly)
1196
+ return oe.html;
1197
+ G = oe.html;
1196
1198
  }
1197
1199
  }
1198
- A || (!e.noHighlight && g.value ? g.value.getLanguage(z) ? A = g.value.highlight(H, {
1199
- language: z,
1200
+ G || (!e.noHighlight && p.value ? p.value.getLanguage(k) ? G = p.value.highlight(M, {
1201
+ language: k,
1200
1202
  ignoreIllegals: !0
1201
- }).value : A = g.value.highlightAuto(H).value : A = w.utils.escapeHtml(H));
1202
- const _ = w.utils.escapeHtml(z);
1203
- let Q = `<span class="${h}-code-block">${A.replace(/^\n+|\n+$/g, "")}</span>`;
1204
- return (r || Y.length) && (Q = ut(A, H, {
1205
- lineHighlightRanges: Y,
1203
+ }).value : G = p.value.highlightAuto(M).value : G = T.utils.escapeHtml(M));
1204
+ const te = T.utils.escapeHtml(k);
1205
+ let se = `<span class="${f}-code-block">${G.replace(/^\n+|\n+$/g, "")}</span>`;
1206
+ return (r || A.length) && (se = ft(G, M, {
1207
+ lineHighlightRanges: A,
1206
1208
  showLineNumber: r
1207
- })), `<pre><code class="language-${_}" language="${_}">${Q}</code></pre>`;
1209
+ })), `<pre><code class="language-${te}" language="${te}">${se}</code></pre>`;
1208
1210
  }
1209
- }), Gt(w);
1210
- const R = U(`_article-key_${fe()}`), N = U(
1211
+ }), Vt(T);
1212
+ const D = Q(`_article-key_${he()}`), N = Q(
1211
1213
  e.sanitize(
1212
- w.render(e.modelValue, {
1214
+ T.render(e.modelValue, {
1213
1215
  srcLines: e.modelValue.split(`
1214
1216
  `)
1215
1217
  })
1216
1218
  )
1217
1219
  );
1218
- let D = () => {
1219
- }, B = () => {
1220
+ let U = () => {
1221
+ }, W = () => {
1220
1222
  };
1221
- const q = () => {
1222
- const H = m.value?.querySelectorAll(
1223
- `#${i} p.${h}-mermaid:not([data-closed=false])`
1223
+ const X = () => {
1224
+ const M = m.value?.querySelectorAll(
1225
+ `#${c} p.${f}-mermaid:not([data-closed=false])`
1224
1226
  );
1225
- B(), B = ot(H, {
1226
- customIcon: s.value
1227
- }), c.mermaid?.enableZoom && (D(), D = at(H, {
1228
- customIcon: s.value
1227
+ W(), W = rt(M, {
1228
+ customIcon: l.value
1229
+ }), s.mermaid?.enableZoom && (U(), U = st(M, {
1230
+ customIcon: l.value
1229
1231
  }));
1230
- }, K = () => {
1231
- b.emit(i, ne, N.value), e.onHtmlChanged(N.value), e.onGetCatalog(p.value), b.emit(i, de, p.value), W(() => {
1232
- y().then(q), T();
1232
+ }, V = () => {
1233
+ w.emit(c, ie, N.value), e.onHtmlChanged(N.value), e.onGetCatalog(g.value), w.emit(c, ue, g.value), Y(() => {
1234
+ y().then(X), F();
1233
1235
  });
1234
- }, Z = () => {
1235
- p.value = [], N.value = e.sanitize(
1236
- w.render(e.modelValue, {
1236
+ }, L = () => {
1237
+ g.value = [], N.value = e.sanitize(
1238
+ T.render(e.modelValue, {
1237
1239
  srcLines: e.modelValue.split(`
1238
1240
  `)
1239
1241
  })
1240
1242
  );
1241
- }, ie = F(() => (e.noKatex || !!v.value) && (e.noHighlight || !!g.value));
1242
- return x(
1243
- [De(e, "modelValue"), ie, E, d],
1244
- (H, J, V) => {
1245
- const X = window.setTimeout(
1243
+ }, P = H(() => (e.noKatex || !!v.value) && (e.noHighlight || !!p.value));
1244
+ return S(
1245
+ [
1246
+ be(e, "modelValue"),
1247
+ be(e, "sanitize"),
1248
+ P,
1249
+ $,
1250
+ u
1251
+ ],
1252
+ (M, O, q) => {
1253
+ const K = window.setTimeout(
1246
1254
  () => {
1247
- Z();
1255
+ L();
1248
1256
  },
1249
1257
  t ? 0 : a.renderDelay
1250
1258
  );
1251
- V(() => {
1252
- clearTimeout(X);
1259
+ q(() => {
1260
+ clearTimeout(K);
1253
1261
  });
1254
1262
  }
1255
- ), x(
1256
- () => f.value.preview,
1263
+ ), S(
1264
+ () => h.value.preview,
1257
1265
  () => {
1258
- f.value.preview && W(() => {
1259
- y().then(q), T(), b.emit(i, de, p.value);
1266
+ h.value.preview && Y(() => {
1267
+ y().then(X), F(), w.emit(c, ue, g.value);
1260
1268
  });
1261
1269
  }
1262
- ), x([N, C], () => {
1263
- K();
1264
- }), L(K), L(() => {
1265
- b.on(i, {
1266
- name: Ke,
1270
+ ), S([N, x, D], () => {
1271
+ V();
1272
+ }), _(V), _(() => {
1273
+ w.on(c, {
1274
+ name: Je,
1267
1275
  callback() {
1268
- b.emit(i, de, p.value);
1276
+ w.emit(c, ue, g.value);
1269
1277
  }
1270
- }), b.on(i, {
1271
- name: ge,
1278
+ }), w.on(c, {
1279
+ name: ve,
1272
1280
  callback: () => {
1273
- R.value = `_article-key_${fe()}`, Z();
1281
+ b(), D.value = `_article-key_${he()}`, L();
1274
1282
  }
1275
1283
  });
1276
- }), le(() => {
1277
- D(), B();
1278
- }), { html: N, key: R };
1279
- }, Wt = (e, t) => {
1280
- const a = $("editorId"), o = $("setting"), { noImgZoomIn: n } = e, c = Ye(() => {
1281
- const i = document.querySelectorAll(
1284
+ }), re(() => {
1285
+ U(), W();
1286
+ }), { html: N, key: D };
1287
+ }, Gt = (e, t) => {
1288
+ const a = E("editorId"), o = E("setting"), { noImgZoomIn: n } = e, s = et(() => {
1289
+ const c = document.querySelectorAll(
1282
1290
  `#${a}-preview img:not(.not-zoom):not(.medium-zoom-image)`
1283
1291
  );
1284
- i.length !== 0 && mt(i, {
1292
+ c.length !== 0 && ht(c, {
1285
1293
  background: "#00000073"
1286
1294
  });
1287
1295
  });
1288
- L(async () => {
1289
- !n && o.value.preview && await c();
1290
- }), x([t, () => o.value.preview], async () => {
1291
- !n && o.value.preview && await c();
1296
+ _(async () => {
1297
+ !n && o.value.preview && await s();
1298
+ }), S([t, () => o.value.preview], async () => {
1299
+ !n && o.value.preview && await s();
1292
1300
  });
1293
- }, Ae = {
1301
+ }, He = {
1294
1302
  checked: {
1295
1303
  regexp: /- \[x\]/,
1296
1304
  value: "- [ ]"
@@ -1299,55 +1307,55 @@ const oe = new bt({
1299
1307
  regexp: /- \[\s\]/,
1300
1308
  value: "- [x]"
1301
1309
  }
1302
- }, qt = (e, t) => {
1303
- const a = $("editorId"), o = $("rootRef");
1310
+ }, Ut = (e, t) => {
1311
+ const a = E("editorId"), o = E("rootRef");
1304
1312
  let n = () => {
1305
1313
  };
1306
- const c = () => {
1314
+ const s = () => {
1307
1315
  if (!o.value)
1308
1316
  return !1;
1309
- const i = o.value.querySelectorAll(".task-list-item.enabled"), d = (u) => {
1310
- u.preventDefault();
1311
- const r = u.target.checked ? "unChecked" : "checked", l = u.target.parentElement?.dataset.line;
1312
- if (!l)
1317
+ const c = o.value.querySelectorAll(".task-list-item.enabled"), u = (d) => {
1318
+ d.preventDefault();
1319
+ const r = d.target.checked ? "unChecked" : "checked", i = d.target.parentElement?.dataset.line;
1320
+ if (!i)
1313
1321
  return;
1314
- const s = Number(l), m = e.modelValue.split(`
1315
- `), f = m[Number(s)].replace(
1316
- Ae[r].regexp,
1317
- Ae[r].value
1322
+ const l = Number(i), m = e.modelValue.split(`
1323
+ `), h = m[Number(l)].replace(
1324
+ He[r].regexp,
1325
+ He[r].value
1318
1326
  );
1319
- e.previewOnly ? (m[Number(s)] = f, e.onChange(m.join(`
1320
- `))) : b.emit(a, Ze, s + 1, f);
1327
+ e.previewOnly ? (m[Number(l)] = h, e.onChange(m.join(`
1328
+ `))) : w.emit(a, Xe, l + 1, h);
1321
1329
  };
1322
- i.forEach((u) => {
1323
- u.addEventListener("click", d);
1330
+ c.forEach((d) => {
1331
+ d.addEventListener("click", u);
1324
1332
  }), n = () => {
1325
- i.forEach((u) => {
1326
- u.removeEventListener("click", d);
1333
+ c.forEach((d) => {
1334
+ d.removeEventListener("click", u);
1327
1335
  });
1328
1336
  };
1329
1337
  };
1330
- le(() => {
1338
+ re(() => {
1331
1339
  n();
1332
- }), x(
1340
+ }), S(
1333
1341
  [t],
1334
1342
  () => {
1335
- n(), W(c);
1343
+ n(), Y(s);
1336
1344
  },
1337
1345
  {
1338
1346
  immediate: !0
1339
1347
  }
1340
1348
  );
1341
- }, Kt = (e, t, a) => {
1342
- const o = $("setting"), n = () => {
1343
- W(() => {
1349
+ }, Wt = (e, t, a) => {
1350
+ const o = E("setting"), n = () => {
1351
+ Y(() => {
1344
1352
  e.onRemount?.();
1345
1353
  });
1346
- }, c = (i) => {
1347
- i && n();
1354
+ }, s = (c) => {
1355
+ c && n();
1348
1356
  };
1349
- x([t, a], n), x(() => o.value.preview, c), x(() => o.value.htmlPreview, c), L(n);
1350
- }, Me = {
1357
+ S([t, a], n), S(() => o.value.preview, s), S(() => o.value.htmlPreview, s), _(n);
1358
+ }, Be = {
1351
1359
  modelValue: {
1352
1360
  type: String,
1353
1361
  default: ""
@@ -1418,8 +1426,8 @@ const oe = new bt({
1418
1426
  type: [Object, Function],
1419
1427
  default: void 0
1420
1428
  }
1421
- }, bn = {
1422
- ...Me,
1429
+ }, vn = {
1430
+ ...Be,
1423
1431
  updateModelValue: {
1424
1432
  type: Function,
1425
1433
  default: () => {
@@ -1487,10 +1495,10 @@ const oe = new bt({
1487
1495
  catalogMaxDepth: {
1488
1496
  type: Number
1489
1497
  }
1490
- }, He = (e) => {
1498
+ }, Pe = (e) => {
1491
1499
  const a = new DOMParser().parseFromString(e, "text/html");
1492
1500
  return Array.from(a.body.childNodes);
1493
- }, Zt = (e, t) => e.nodeType !== t.nodeType ? !1 : e.nodeType === Node.TEXT_NODE || e.nodeType === Node.COMMENT_NODE ? e.textContent === t.textContent : e.nodeType === Node.ELEMENT_NODE ? e.outerHTML === t.outerHTML : e.isEqualNode ? e.isEqualNode(t) : !1, Jt = /* @__PURE__ */ pe({
1501
+ }, qt = (e, t) => e.nodeType !== t.nodeType ? !1 : e.nodeType === Node.TEXT_NODE || e.nodeType === Node.COMMENT_NODE ? e.textContent === t.textContent : e.nodeType === Node.ELEMENT_NODE ? e.outerHTML === t.outerHTML : e.isEqualNode ? e.isEqualNode(t) : !1, Kt = /* @__PURE__ */ ge({
1494
1502
  name: "UpdateOnDemand",
1495
1503
  props: {
1496
1504
  id: {
@@ -1507,74 +1515,74 @@ const oe = new bt({
1507
1515
  }
1508
1516
  },
1509
1517
  setup(e) {
1510
- const t = U(), a = e.html, o = (n, c) => {
1518
+ const t = Q(), a = e.html, o = (n, s) => {
1511
1519
  if (!t.value) return;
1512
- const i = t.value, d = Array.from(i.childNodes), u = Math.min(n.length, c.length);
1520
+ const c = t.value, u = Array.from(c.childNodes), d = Math.min(n.length, s.length);
1513
1521
  let r = -1;
1514
- for (let s = 0; s < u; s++)
1515
- if (!Zt(n[s], c[s])) {
1516
- r = s;
1522
+ for (let l = 0; l < d; l++)
1523
+ if (!qt(n[l], s[l])) {
1524
+ r = l;
1517
1525
  break;
1518
1526
  }
1519
1527
  if (r === -1)
1520
- if (c.length > n.length)
1528
+ if (s.length > n.length)
1521
1529
  r = n.length;
1522
- else if (n.length > c.length)
1523
- r = c.length;
1530
+ else if (n.length > s.length)
1531
+ r = s.length;
1524
1532
  else
1525
1533
  return;
1526
- const l = Math.min(r, d.length);
1527
- for (let s = d.length - 1; s >= l; s--)
1528
- d[s].remove();
1529
- for (let s = r; s < n.length; s++)
1530
- i.appendChild(n[s].cloneNode(!0));
1534
+ const i = Math.min(r, u.length);
1535
+ for (let l = u.length - 1; l >= i; l--)
1536
+ u[l].remove();
1537
+ for (let l = r; l < n.length; l++)
1538
+ c.appendChild(n[l].cloneNode(!0));
1531
1539
  };
1532
- return x(() => e.html, (n, c) => {
1533
- const i = He(n), d = He(c || "");
1534
- o(i, d);
1535
- }), () => j("div", {
1540
+ return S(() => e.html, (n, s) => {
1541
+ const c = Pe(n), u = Pe(s || "");
1542
+ o(c, u);
1543
+ }), () => Z("div", {
1536
1544
  id: e.id,
1537
1545
  class: e.class,
1538
1546
  innerHTML: a,
1539
1547
  ref: t
1540
1548
  }, null);
1541
1549
  }
1542
- }), Xt = /* @__PURE__ */ pe({
1550
+ }), Zt = /* @__PURE__ */ ge({
1543
1551
  name: "ContentPreview",
1544
- props: Me,
1552
+ props: Be,
1545
1553
  setup(e) {
1546
- const t = $("editorId"), a = $("setting"), o = $("previewTheme"), n = $("showCodeRowNumber"), {
1547
- html: c,
1548
- key: i
1549
- } = Ut(e, e.previewOnly);
1550
- pt(e, c, i), Wt(e, c), qt(e, c), Kt(e, c, i);
1551
- const d = F(() => [`${h}-preview`, `${o?.value}-theme`, n && `${h}-scrn`].filter(Boolean)), u = () => {
1554
+ const t = E("editorId"), a = E("setting"), o = E("previewTheme"), n = E("showCodeRowNumber"), {
1555
+ html: s,
1556
+ key: c
1557
+ } = zt(e, e.previewOnly);
1558
+ vt(e, s, c), Gt(e, s), Ut(e, s), Wt(e, s, c);
1559
+ const u = H(() => [`${f}-preview`, `${o?.value}-theme`, n && `${f}-scrn`].filter(Boolean)), d = () => {
1552
1560
  const r = `${t}-preview`;
1553
- return e.previewComponent ? ze(e.previewComponent, {
1554
- key: i.value,
1555
- html: c.value,
1561
+ return e.previewComponent ? Ue(e.previewComponent, {
1562
+ key: c.value,
1563
+ html: s.value,
1556
1564
  id: r,
1557
- class: d.value
1558
- }) : j(Jt, {
1559
- key: i.value,
1560
- html: c.value,
1565
+ class: u.value
1566
+ }) : Z(Kt, {
1567
+ key: c.value,
1568
+ html: s.value,
1561
1569
  id: r,
1562
- class: d.value
1570
+ class: u.value
1563
1571
  }, null);
1564
1572
  };
1565
- return () => j(Ve, null, [a.value.preview && (e.previewOnly ? u() : j("div", {
1573
+ return () => Z(Ge, null, [a.value.preview && (e.previewOnly ? d() : Z("div", {
1566
1574
  id: `${t}-preview-wrapper`,
1567
- class: `${h}-preview-wrapper`,
1575
+ class: `${f}-preview-wrapper`,
1568
1576
  key: "content-preview-wrapper"
1569
- }, [u()])), a.value.htmlPreview && j("div", {
1577
+ }, [d()])), a.value.htmlPreview && Z("div", {
1570
1578
  id: `${t}-html-wrapper`,
1571
- class: `${h}-preview-wrapper`,
1579
+ class: `${f}-preview-wrapper`,
1572
1580
  key: "html-preview-wrapper"
1573
- }, [j("div", {
1574
- class: `${h}-html`
1575
- }, [c.value])])]);
1581
+ }, [Z("div", {
1582
+ class: `${f}-html`
1583
+ }, [s.value])])]);
1576
1584
  }
1577
- }), Yt = ({ text: e }) => e, Pe = {
1585
+ }), Jt = ({ text: e }) => e, je = {
1578
1586
  /**
1579
1587
  * markdown content.
1580
1588
  *
@@ -1683,12 +1691,12 @@ const oe = new bt({
1683
1691
  */
1684
1692
  mdHeadingId: {
1685
1693
  type: Function,
1686
- default: Yt
1694
+ default: Jt
1687
1695
  },
1688
1696
  /**
1689
1697
  *
1690
- * 不能保证文本正确的情况,在marked编译md文本后通过该方法处理
1691
- * 推荐DOMPurify、sanitize-html
1698
+ * Markdown 编译后的 HTML 后处理入口。原生 HTML 默认关闭;显式开启或使用
1699
+ * 自定义 renderer 时,可在这里接入 DOMPurify、sanitize-html 等业务清洗策略。
1692
1700
  *
1693
1701
  * @default (text: string) => text
1694
1702
  */
@@ -1769,6 +1777,7 @@ const oe = new bt({
1769
1777
  type: Object,
1770
1778
  default: {}
1771
1779
  },
1780
+ /** Mermaid 在默认 strict 渲染之后的异步 SVG 后处理入口。 */
1772
1781
  sanitizeMermaid: {
1773
1782
  type: Function,
1774
1783
  default: (e) => Promise.resolve(e)
@@ -1812,8 +1821,8 @@ const oe = new bt({
1812
1821
  type: [Object, Function],
1813
1822
  default: void 0
1814
1823
  }
1815
- }, Cn = {
1816
- ...Pe,
1824
+ }, yn = {
1825
+ ...je,
1817
1826
  /**
1818
1827
  * input回调事件
1819
1828
  */
@@ -1873,7 +1882,7 @@ const oe = new bt({
1873
1882
  */
1874
1883
  toolbars: {
1875
1884
  type: Array,
1876
- default: et
1885
+ default: nt
1877
1886
  },
1878
1887
  /**
1879
1888
  * 浮动工具栏
@@ -1951,7 +1960,7 @@ const oe = new bt({
1951
1960
  */
1952
1961
  footers: {
1953
1962
  type: Array,
1954
- default: Qe
1963
+ default: tt
1955
1964
  },
1956
1965
  /**
1957
1966
  * 是否默认激活输入框和预览框同步滚动
@@ -2118,14 +2127,14 @@ const oe = new bt({
2118
2127
  type: Number,
2119
2128
  default: void 0
2120
2129
  }
2121
- }, _e = [
2130
+ }, De = [
2122
2131
  "onHtmlChanged",
2123
2132
  "onGetCatalog",
2124
2133
  "onChange",
2125
2134
  "onRemount",
2126
2135
  "update:modelValue"
2127
- ], wn = [
2128
- ..._e,
2136
+ ], bn = [
2137
+ ...De,
2129
2138
  "onSave",
2130
2139
  "onUploadImg",
2131
2140
  "onError",
@@ -2134,43 +2143,43 @@ const oe = new bt({
2134
2143
  "onInput",
2135
2144
  "onDrop",
2136
2145
  "onInputBoxWidthChange"
2137
- ], ue = /* @__PURE__ */ pe({
2146
+ ], me = /* @__PURE__ */ ge({
2138
2147
  name: "MdPreview",
2139
- props: Pe,
2140
- emits: _e,
2148
+ props: je,
2149
+ emits: De,
2141
2150
  setup(e, t) {
2142
2151
  const {
2143
2152
  noKatex: a,
2144
2153
  noMermaid: o,
2145
2154
  noHighlight: n
2146
- } = e, c = U(), i = ht(e);
2147
- Le(e, {
2148
- rootRef: c,
2149
- editorId: i
2150
- }), ft(e, t, {
2151
- editorId: i
2152
- }), le(() => {
2153
- b.clear(i);
2155
+ } = e, s = Q(), c = gt(e);
2156
+ Ne(e, {
2157
+ rootRef: s,
2158
+ editorId: c
2159
+ }), pt(e, t, {
2160
+ editorId: c
2161
+ }), re(() => {
2162
+ w.clear(c);
2154
2163
  });
2155
- const d = (s) => {
2156
- e.onChange?.(s), t.emit("onChange", s), t.emit("update:modelValue", s);
2157
- }, u = (s) => {
2158
- e.onHtmlChanged?.(s), t.emit("onHtmlChanged", s);
2159
- }, r = (s) => {
2160
- e.onGetCatalog?.(s), t.emit("onGetCatalog", s);
2161
- }, l = () => {
2164
+ const u = (l) => {
2165
+ e.onChange?.(l), t.emit("onChange", l), t.emit("update:modelValue", l);
2166
+ }, d = (l) => {
2167
+ e.onHtmlChanged?.(l), t.emit("onHtmlChanged", l);
2168
+ }, r = (l) => {
2169
+ e.onGetCatalog?.(l), t.emit("onGetCatalog", l);
2170
+ }, i = () => {
2162
2171
  e.onRemount?.(), t.emit("onRemount");
2163
2172
  };
2164
- return () => j("div", {
2165
- id: i,
2166
- class: [h, e.class, `${h}-previewOnly`],
2173
+ return () => Z("div", {
2174
+ id: c,
2175
+ class: [f, e.class, `${f}-previewOnly`],
2167
2176
  "data-theme": e.theme,
2168
2177
  style: e.style,
2169
- ref: c
2170
- }, [j(Xt, {
2178
+ ref: s
2179
+ }, [Z(Zt, {
2171
2180
  modelValue: e.modelValue,
2172
- onChange: d,
2173
- onHtmlChanged: u,
2181
+ onChange: u,
2182
+ onHtmlChanged: d,
2174
2183
  onGetCatalog: r,
2175
2184
  mdHeadingId: e.mdHeadingId,
2176
2185
  noMermaid: o,
@@ -2183,27 +2192,27 @@ const oe = new bt({
2183
2192
  sanitizeMermaid: e.sanitizeMermaid,
2184
2193
  codeFoldable: e.codeFoldable,
2185
2194
  autoFoldThreshold: e.autoFoldThreshold,
2186
- onRemount: l,
2195
+ onRemount: i,
2187
2196
  noEcharts: e.noEcharts,
2188
2197
  previewComponent: e.previewComponent
2189
2198
  }, null)]);
2190
2199
  }
2191
2200
  });
2192
- ue.install = (e) => (e.component(ue.name, ue), e);
2201
+ me.install = (e) => (e.component(me.name, me), e);
2193
2202
  export {
2194
- M as C,
2195
- ue as M,
2196
- Xt as a,
2197
- wn as b,
2198
- bn as c,
2199
- Cn as d,
2200
- he as e,
2201
- gn as f,
2202
- vn as g,
2203
- mn as h,
2204
- hn as i,
2205
- pn as j,
2206
- yn as k,
2207
- fn as l,
2208
- ht as u
2203
+ B as C,
2204
+ me as M,
2205
+ Zt as a,
2206
+ bn as b,
2207
+ vn as c,
2208
+ yn as d,
2209
+ pe as e,
2210
+ hn as f,
2211
+ pn as g,
2212
+ dn as h,
2213
+ mn as i,
2214
+ fn as j,
2215
+ gn as k,
2216
+ un as l,
2217
+ gt as u
2209
2218
  };