md-editor-v3 5.0.0-2 → 5.0.0-3

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.
@@ -8,6 +8,7 @@ const util = require("@vavt/util");
8
8
  const DropdownToolbar = require("./chunks/index2.cjs");
9
9
  const eventName = require("./chunks/event-name.cjs");
10
10
  const dom = require("./chunks/dom.cjs");
11
+ const MdPreview = require("./chunks/index.cjs");
11
12
  const MdModal = require("./chunks/index4.cjs");
12
13
  const index = require("./chunks/index5.cjs");
13
14
  const MdCatalog = require("./chunks/index3.cjs");
@@ -21,7 +22,6 @@ const language = require("@codemirror/language");
21
22
  const highlight = require("@lezer/highlight");
22
23
  const autocomplete = require("@codemirror/autocomplete");
23
24
  const search = require("@codemirror/search");
24
- const MdPreview = require("./chunks/index.cjs");
25
25
  const vueTsx = require("./chunks/vue-tsx.cjs");
26
26
  const NormalToolbar = require("./NormalToolbar.cjs");
27
27
  const ModalToolbar = require("./ModalToolbar.cjs");
@@ -137,7 +137,7 @@ const useSreenfull = (props2) => {
137
137
  {
138
138
  ...(_a = editorExtensionsAttrs.screenfull) == null ? void 0 : _a.js,
139
139
  src: editorExtensions.screenfull.js,
140
- id: `${config.prefix}-screenfull`,
140
+ id: MdPreview.CDN_IDS.screenfull,
141
141
  onload: screenfullLoad
142
142
  },
143
143
  "screenfull"
@@ -2,8 +2,8 @@
2
2
  const vue = require("vue");
3
3
  const config = require("./config.cjs");
4
4
  const eventName = require("./event-name.cjs");
5
- const dom = require("./dom.cjs");
6
5
  const util = require("@vavt/util");
6
+ const dom = require("./dom.cjs");
7
7
  const mediumZoom = require("medium-zoom");
8
8
  const copy = require("copy-to-clipboard");
9
9
  const mdit = require("markdown-it");
@@ -12,6 +12,19 @@ const SubPlugin = require("markdown-it-sub");
12
12
  const SupPlugin = require("markdown-it-sup");
13
13
  const index = require("./index5.cjs");
14
14
  const lruCache = require("lru-cache");
15
+ const CDN_IDS = {
16
+ hljs: `${config.prefix}-hljs`,
17
+ hlcss: `${config.prefix}-hlCss`,
18
+ prettier: `${config.prefix}-prettier`,
19
+ prettierMD: `${config.prefix}-prettierMD`,
20
+ cropperjs: `${config.prefix}-cropper`,
21
+ croppercss: `${config.prefix}-cropperCss`,
22
+ screenfull: `${config.prefix}-screenfull`,
23
+ mermaidM: `${config.prefix}-mermaid-m`,
24
+ mermaid: `${config.prefix}-mermaid`,
25
+ katexjs: `${config.prefix}-katex`,
26
+ katexcss: `${config.prefix}-katexCss`
27
+ };
15
28
  const userZoom = (props, html) => {
16
29
  const editorId = vue.inject("editorId");
17
30
  const { noImgZoomIn } = props;
@@ -95,13 +108,13 @@ const useHighlight = (props) => {
95
108
  dom.appendHandler("link", {
96
109
  ...highlight.value.css,
97
110
  rel: "stylesheet",
98
- id: `${config.prefix}-hlCss`
111
+ id: CDN_IDS.hlcss
99
112
  });
100
113
  dom.appendHandler(
101
114
  "script",
102
115
  {
103
116
  ...highlight.value.js,
104
- id: `${config.prefix}-hljs`,
117
+ id: CDN_IDS.hljs,
105
118
  onload() {
106
119
  hljsRef.value = window.hljs;
107
120
  }
@@ -118,7 +131,7 @@ const useHighlight = (props) => {
118
131
  dom.updateHandler("link", {
119
132
  ...highlight.value.css,
120
133
  rel: "stylesheet",
121
- id: `${config.prefix}-hlCss`
134
+ id: CDN_IDS.hlcss
122
135
  });
123
136
  }
124
137
  );
@@ -165,7 +178,7 @@ const useMermaid = (props) => {
165
178
  ...(_a = editorExtensionsAttrs.mermaid) == null ? void 0 : _a.js,
166
179
  rel: "modulepreload",
167
180
  href: jsSrc,
168
- id: `${config.prefix}-mermaid-m`
181
+ id: CDN_IDS.mermaidM
169
182
  });
170
183
  import(
171
184
  /* @vite-ignore */
@@ -181,7 +194,7 @@ const useMermaid = (props) => {
181
194
  {
182
195
  ...(_b = editorExtensionsAttrs.mermaid) == null ? void 0 : _b.js,
183
196
  src: jsSrc,
184
- id: `${config.prefix}-mermaid`,
197
+ id: CDN_IDS.mermaid,
185
198
  onload() {
186
199
  mermaidRef.value = window.mermaid;
187
200
  configMermaid();
@@ -258,7 +271,7 @@ const useKatex = (props) => {
258
271
  "script",
259
272
  {
260
273
  src: editorExtensions.katex.js,
261
- id: `${config.prefix}-katex`,
274
+ id: CDN_IDS.katexjs,
262
275
  onload() {
263
276
  katex.value = window.katex;
264
277
  }
@@ -268,7 +281,7 @@ const useKatex = (props) => {
268
281
  dom.appendHandler("link", {
269
282
  rel: "stylesheet",
270
283
  href: editorExtensions.katex.css,
271
- id: `${config.prefix}-katexCss`
284
+ id: CDN_IDS.katexcss
272
285
  });
273
286
  });
274
287
  return katex;
@@ -1368,12 +1381,12 @@ const useExpansion = (props) => {
1368
1381
  ...css,
1369
1382
  rel: "stylesheet",
1370
1383
  href: editorExtensions.cropper.css,
1371
- id: `${config.prefix}-cropperCss`
1384
+ id: CDN_IDS.croppercss
1372
1385
  });
1373
1386
  dom.appendHandler("script", {
1374
1387
  ...js,
1375
1388
  src: editorExtensions.cropper.js,
1376
- id: `${config.prefix}-cropper`
1389
+ id: CDN_IDS.cropperjs
1377
1390
  });
1378
1391
  }
1379
1392
  if (!noPrettierScript) {
@@ -1381,7 +1394,7 @@ const useExpansion = (props) => {
1381
1394
  dom.appendHandler("script", {
1382
1395
  ...standaloneJs,
1383
1396
  src: editorExtensions.prettier.standaloneJs,
1384
- id: `${config.prefix}-prettier`
1397
+ id: CDN_IDS.prettier
1385
1398
  });
1386
1399
  }
1387
1400
  if (!noParserMarkdownScript) {
@@ -1389,7 +1402,7 @@ const useExpansion = (props) => {
1389
1402
  dom.appendHandler("script", {
1390
1403
  ...parserMarkdownJs,
1391
1404
  src: editorExtensions.prettier.parserMarkdownJs,
1392
- id: `${config.prefix}-prettierMD`
1405
+ id: CDN_IDS.prettierMD
1393
1406
  });
1394
1407
  }
1395
1408
  });
@@ -2243,6 +2256,7 @@ MdPreview.install = (app) => {
2243
2256
  app.component(MdPreview.name, MdPreview);
2244
2257
  return app;
2245
2258
  };
2259
+ exports.CDN_IDS = CDN_IDS;
2246
2260
  exports.ContentPreview = ContentPreview;
2247
2261
  exports.MdPreview = MdPreview;
2248
2262
  exports.StrIcon = StrIcon$1;
package/lib/cjs/index.cjs CHANGED
@@ -1352,6 +1352,14 @@ const XSSPlugin = (md, options) => {
1352
1352
  }
1353
1353
  });
1354
1354
  };
1355
+ const clearSideEffects = () => {
1356
+ Object.keys(MdPreview.CDN_IDS).forEach((key) => {
1357
+ const ele = document.getElementById(MdPreview.CDN_IDS[key]);
1358
+ if (ele) {
1359
+ ele.remove();
1360
+ }
1361
+ });
1362
+ };
1355
1363
  exports.MdEditor = MdEditor;
1356
1364
  exports.MdPreview = MdPreview.MdPreview;
1357
1365
  exports.StrIcon = MdPreview.StrIcon;
@@ -1368,3 +1376,4 @@ exports.en_US = config.en_US;
1368
1376
  exports.zh_CN = config.zh_CN;
1369
1377
  exports.NormalFooterToolbar = NormalFooterToolbar;
1370
1378
  exports.XSSPlugin = XSSPlugin;
1379
+ exports.clearSideEffects = clearSideEffects;
@@ -7,6 +7,7 @@ import { draggingScroll, linkTo, throttle } from "@vavt/util";
7
7
  import { a as Dropdown, D as DropdownToolbar } from "./chunks/index2.mjs";
8
8
  import { b as bus, C as CHANGE_FULL_SCREEN, E as ERROR_CATCHER, U as UPLOAD_IMAGE, O as OPEN_MODALS, R as REPLACE, a as CHANGE_CATALOG_VISIBLE, c as ON_SAVE, d as CTRL_SHIFT_Z, e as CTRL_Z, f as EVENT_LISTENER, T as TASK_STATE_CHANGED } from "./chunks/event-name.mjs";
9
9
  import { a as appendHandler } from "./chunks/dom.mjs";
10
+ import { C as CDN_IDS, c as contentProps, a as ContentPreview, e as editorProps, b as editorEmits, u as useProvide, d as useConfig, f as useCatalog, g as useOnSave, h as useExpansion, i as useErrorCatcher, j as useExpose, M as MdPreview } from "./chunks/index.mjs";
10
11
  import { M as MdModal, I as Icon } from "./chunks/index4.mjs";
11
12
  import { b as base642File } from "./chunks/index5.mjs";
12
13
  import { s as scrollAuto, a as scrollAutoWithScale, M as MdCatalog } from "./chunks/index3.mjs";
@@ -20,7 +21,6 @@ import { HighlightStyle, syntaxHighlighting, indentUnit } from "@codemirror/lang
20
21
  import { tags } from "@lezer/highlight";
21
22
  import { autocompletion } from "@codemirror/autocomplete";
22
23
  import { searchKeymap } from "@codemirror/search";
23
- import { c as contentProps, C as ContentPreview, e as editorProps, a as editorEmits, u as useProvide, b as useConfig, d as useCatalog, f as useOnSave, g as useExpansion, h as useErrorCatcher, i as useExpose, M as MdPreview } from "./chunks/index.mjs";
24
24
  import { g as getSlot } from "./chunks/vue-tsx.mjs";
25
25
  import NormalToolbar from "./NormalToolbar.mjs";
26
26
  import ModalToolbar from "./ModalToolbar.mjs";
@@ -136,7 +136,7 @@ const useSreenfull = (props2) => {
136
136
  {
137
137
  ...(_a = editorExtensionsAttrs.screenfull) == null ? void 0 : _a.js,
138
138
  src: editorExtensions.screenfull.js,
139
- id: `${prefix}-screenfull`,
139
+ id: CDN_IDS.screenfull,
140
140
  onload: screenfullLoad
141
141
  },
142
142
  "screenfull"
@@ -1,8 +1,8 @@
1
1
  import { inject, onMounted, watch, toRef, nextTick, shallowRef, ref, computed, onBeforeUnmount, defineComponent, createVNode, Fragment, reactive, provide, useId } from "vue";
2
2
  import { p as prefix, d as configOption, f as codeCss, s as staticTextDefault, a as allToolbar, b as allFooter } from "./config.mjs";
3
3
  import { b as bus, g as CATALOG_CHANGED, P as PUSH_CATALOG, h as RERENDER, B as BUILD_FINISHED, T as TASK_STATE_CHANGED, c as ON_SAVE, E as ERROR_CATCHER, U as UPLOAD_IMAGE, a as CHANGE_CATALOG_VISIBLE, i as PAGE_FULL_SCREEN_CHANGED, F as FULL_SCREEN_CHANGED, j as PREVIEW_CHANGED, k as PREVIEW_ONLY_CHANGED, H as HTML_PREVIEW_CHANGED, l as CATALOG_VISIBLE_CHANGED, R as REPLACE, C as CHANGE_FULL_SCREEN, f as EVENT_LISTENER } from "./event-name.mjs";
4
- import { a as appendHandler, u as updateHandler, z as zoomMermaid } from "./dom.mjs";
5
4
  import { debounce, randomId, deepMerge, deepClone } from "@vavt/util";
5
+ import { a as appendHandler, u as updateHandler, z as zoomMermaid } from "./dom.mjs";
6
6
  import mediumZoom from "medium-zoom";
7
7
  import copy from "copy-to-clipboard";
8
8
  import mdit from "markdown-it";
@@ -11,6 +11,19 @@ import SubPlugin from "markdown-it-sub";
11
11
  import SupPlugin from "markdown-it-sup";
12
12
  import { g as generateCodeRowNumber } from "./index5.mjs";
13
13
  import { LRUCache } from "lru-cache";
14
+ const CDN_IDS = {
15
+ hljs: `${prefix}-hljs`,
16
+ hlcss: `${prefix}-hlCss`,
17
+ prettier: `${prefix}-prettier`,
18
+ prettierMD: `${prefix}-prettierMD`,
19
+ cropperjs: `${prefix}-cropper`,
20
+ croppercss: `${prefix}-cropperCss`,
21
+ screenfull: `${prefix}-screenfull`,
22
+ mermaidM: `${prefix}-mermaid-m`,
23
+ mermaid: `${prefix}-mermaid`,
24
+ katexjs: `${prefix}-katex`,
25
+ katexcss: `${prefix}-katexCss`
26
+ };
14
27
  const userZoom = (props, html) => {
15
28
  const editorId = inject("editorId");
16
29
  const { noImgZoomIn } = props;
@@ -94,13 +107,13 @@ const useHighlight = (props) => {
94
107
  appendHandler("link", {
95
108
  ...highlight.value.css,
96
109
  rel: "stylesheet",
97
- id: `${prefix}-hlCss`
110
+ id: CDN_IDS.hlcss
98
111
  });
99
112
  appendHandler(
100
113
  "script",
101
114
  {
102
115
  ...highlight.value.js,
103
- id: `${prefix}-hljs`,
116
+ id: CDN_IDS.hljs,
104
117
  onload() {
105
118
  hljsRef.value = window.hljs;
106
119
  }
@@ -117,7 +130,7 @@ const useHighlight = (props) => {
117
130
  updateHandler("link", {
118
131
  ...highlight.value.css,
119
132
  rel: "stylesheet",
120
- id: `${prefix}-hlCss`
133
+ id: CDN_IDS.hlcss
121
134
  });
122
135
  }
123
136
  );
@@ -164,7 +177,7 @@ const useMermaid = (props) => {
164
177
  ...(_a = editorExtensionsAttrs.mermaid) == null ? void 0 : _a.js,
165
178
  rel: "modulepreload",
166
179
  href: jsSrc,
167
- id: `${prefix}-mermaid-m`
180
+ id: CDN_IDS.mermaidM
168
181
  });
169
182
  import(
170
183
  /* @vite-ignore */
@@ -180,7 +193,7 @@ const useMermaid = (props) => {
180
193
  {
181
194
  ...(_b = editorExtensionsAttrs.mermaid) == null ? void 0 : _b.js,
182
195
  src: jsSrc,
183
- id: `${prefix}-mermaid`,
196
+ id: CDN_IDS.mermaid,
184
197
  onload() {
185
198
  mermaidRef.value = window.mermaid;
186
199
  configMermaid();
@@ -257,7 +270,7 @@ const useKatex = (props) => {
257
270
  "script",
258
271
  {
259
272
  src: editorExtensions.katex.js,
260
- id: `${prefix}-katex`,
273
+ id: CDN_IDS.katexjs,
261
274
  onload() {
262
275
  katex.value = window.katex;
263
276
  }
@@ -267,7 +280,7 @@ const useKatex = (props) => {
267
280
  appendHandler("link", {
268
281
  rel: "stylesheet",
269
282
  href: editorExtensions.katex.css,
270
- id: `${prefix}-katexCss`
283
+ id: CDN_IDS.katexcss
271
284
  });
272
285
  });
273
286
  return katex;
@@ -1367,12 +1380,12 @@ const useExpansion = (props) => {
1367
1380
  ...css,
1368
1381
  rel: "stylesheet",
1369
1382
  href: editorExtensions.cropper.css,
1370
- id: `${prefix}-cropperCss`
1383
+ id: CDN_IDS.croppercss
1371
1384
  });
1372
1385
  appendHandler("script", {
1373
1386
  ...js,
1374
1387
  src: editorExtensions.cropper.js,
1375
- id: `${prefix}-cropper`
1388
+ id: CDN_IDS.cropperjs
1376
1389
  });
1377
1390
  }
1378
1391
  if (!noPrettierScript) {
@@ -1380,7 +1393,7 @@ const useExpansion = (props) => {
1380
1393
  appendHandler("script", {
1381
1394
  ...standaloneJs,
1382
1395
  src: editorExtensions.prettier.standaloneJs,
1383
- id: `${prefix}-prettier`
1396
+ id: CDN_IDS.prettier
1384
1397
  });
1385
1398
  }
1386
1399
  if (!noParserMarkdownScript) {
@@ -1388,7 +1401,7 @@ const useExpansion = (props) => {
1388
1401
  appendHandler("script", {
1389
1402
  ...parserMarkdownJs,
1390
1403
  src: editorExtensions.prettier.parserMarkdownJs,
1391
- id: `${prefix}-prettierMD`
1404
+ id: CDN_IDS.prettierMD
1392
1405
  });
1393
1406
  }
1394
1407
  });
@@ -2243,17 +2256,18 @@ MdPreview.install = (app) => {
2243
2256
  return app;
2244
2257
  };
2245
2258
  export {
2246
- ContentPreview as C,
2259
+ CDN_IDS as C,
2247
2260
  MdPreview as M,
2248
2261
  StrIcon$1 as S,
2249
- editorEmits as a,
2250
- useConfig as b,
2262
+ ContentPreview as a,
2263
+ editorEmits as b,
2251
2264
  contentProps as c,
2252
- useCatalog as d,
2265
+ useConfig as d,
2253
2266
  editorProps as e,
2254
- useOnSave as f,
2255
- useExpansion as g,
2256
- useErrorCatcher as h,
2257
- useExpose$1 as i,
2267
+ useCatalog as f,
2268
+ useOnSave as g,
2269
+ useExpansion as h,
2270
+ useErrorCatcher as i,
2271
+ useExpose$1 as j,
2258
2272
  useProvide as u
2259
2273
  };
package/lib/es/index.mjs CHANGED
@@ -1,4 +1,5 @@
1
1
  import { default as default2 } from "./MdEditor.mjs";
2
+ import { C as CDN_IDS } from "./chunks/index.mjs";
2
3
  import { M, S } from "./chunks/index.mjs";
3
4
  import { default as default3 } from "./NormalToolbar.mjs";
4
5
  import { D } from "./chunks/index2.mjs";
@@ -1351,6 +1352,14 @@ const XSSPlugin = (md, options) => {
1351
1352
  }
1352
1353
  });
1353
1354
  };
1355
+ const clearSideEffects = () => {
1356
+ Object.keys(CDN_IDS).forEach((key) => {
1357
+ const ele = document.getElementById(CDN_IDS[key]);
1358
+ if (ele) {
1359
+ ele.remove();
1360
+ }
1361
+ });
1362
+ };
1354
1363
  export {
1355
1364
  D as DropdownToolbar,
1356
1365
  M2 as MdCatalog,
@@ -1364,6 +1373,7 @@ export {
1364
1373
  XSSPlugin,
1365
1374
  b as allFooter,
1366
1375
  a as allToolbar,
1376
+ clearSideEffects,
1367
1377
  c as config,
1368
1378
  e as editorExtensionsAttrs,
1369
1379
  en_US,
@@ -0,0 +1,13 @@
1
+ export declare const CDN_IDS: {
2
+ hljs: string;
3
+ hlcss: string;
4
+ prettier: string;
5
+ prettierMD: string;
6
+ cropperjs: string;
7
+ croppercss: string;
8
+ screenfull: string;
9
+ mermaidM: string;
10
+ mermaid: string;
11
+ katexjs: string;
12
+ katexcss: string;
13
+ };
@@ -9,4 +9,5 @@ export { default as StrIcon } from './MdEditor/components/Icon/Str';
9
9
  export { default as NormalFooterToolbar } from './NormalFooterToolbar';
10
10
  export * from './MdEditor/layouts/Content/markdownIt/xss';
11
11
  export * from './config';
12
+ export * from './util';
12
13
  export * from './MdEditor/type';
@@ -0,0 +1,5 @@
1
+ /**
2
+ * 清空组件带来的副作用,例如
3
+ * 1. 使用CDN嵌入的链接,为了保证多个组件能够正常使用,组件在卸载时不会主动移除
4
+ */
5
+ export declare const clearSideEffects: () => void;