md-editor-v3 2.4.2 → 2.5.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -19,18 +19,18 @@ var __spreadValues = (a, b) => {
19
19
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
20
  import { reactive, watch, onMounted, onBeforeUnmount, provide, computed, ref, defineComponent, createVNode, cloneVNode, nextTick, inject, Fragment, toRef, isVNode } from "vue";
21
21
  const prefix = "md-editor";
22
- const iconfontUrl = "https://at.alicdn.com/t/c/font_2605852_4cjr7o5jo0f.js";
22
+ const iconfontUrl = "https://at.alicdn.com/t/c/font_2605852_gymddm8qwtd.js";
23
23
  const cdnBase = "https://cdnjs.cloudflare.com/ajax/libs";
24
- const highlightUrl = `${cdnBase}/highlight.js/11.5.1/highlight.min.js`;
24
+ const highlightUrl = `${cdnBase}/highlight.js/11.7.0/highlight.min.js`;
25
25
  const prettierUrl = {
26
- main: `${cdnBase}/prettier/2.4.0/standalone.js`,
27
- markdown: `${cdnBase}/prettier/2.4.0/parser-markdown.js`
26
+ main: `${cdnBase}/prettier/2.8.0/standalone.js`,
27
+ markdown: `${cdnBase}/prettier/2.8.0/parser-markdown.js`
28
28
  };
29
29
  const cropperUrl = {
30
- css: `${cdnBase}/cropperjs/1.5.12/cropper.min.css`,
31
- js: `${cdnBase}/cropperjs/1.5.12/cropper.min.js`
30
+ css: `${cdnBase}/cropperjs/1.5.13/cropper.min.css`,
31
+ js: `${cdnBase}/cropperjs/1.5.13/cropper.min.js`
32
32
  };
33
- const screenfullUrl = `${cdnBase}/screenfull.js/5.1.0/screenfull.min.js`;
33
+ const screenfullUrl = `${cdnBase}/screenfull.js/6.0.2/screenfull.min.js`;
34
34
  const allToolbar = [
35
35
  "bold",
36
36
  "underline",
@@ -112,11 +112,12 @@ const staticTextDefault = {
112
112
  clip2upload: "\u88C1\u526A\u4E0A\u4F20"
113
113
  },
114
114
  linkModalTips: {
115
- title: "\u6DFB\u52A0",
116
- descLable: "\u94FE\u63A5\u63CF\u8FF0\uFF1A",
117
- descLablePlaceHolder: "\u8BF7\u8F93\u5165\u63CF\u8FF0...",
118
- urlLable: "\u94FE\u63A5\u5730\u5740\uFF1A",
119
- urlLablePlaceHolder: "\u8BF7\u8F93\u5165\u94FE\u63A5...",
115
+ linkTitle: "\u6DFB\u52A0\u94FE\u63A5",
116
+ imageTitle: "\u6DFB\u52A0\u56FE\u7247",
117
+ descLabel: "\u94FE\u63A5\u63CF\u8FF0\uFF1A",
118
+ descLabelPlaceHolder: "\u8BF7\u8F93\u5165\u63CF\u8FF0...",
119
+ urlLabel: "\u94FE\u63A5\u5730\u5740\uFF1A",
120
+ urlLabelPlaceHolder: "\u8BF7\u8F93\u5165\u94FE\u63A5...",
120
121
  buttonOK: "\u786E\u5B9A"
121
122
  },
122
123
  clipModalTips: {
@@ -192,11 +193,12 @@ const staticTextDefault = {
192
193
  clip2upload: "Clip Upload"
193
194
  },
194
195
  linkModalTips: {
195
- title: "Add ",
196
- descLable: "Desc:",
197
- descLablePlaceHolder: "Enter a description...",
198
- urlLable: "Link:",
199
- urlLablePlaceHolder: "Enter a link...",
196
+ linkTitle: "Add Link",
197
+ imageTitle: "Add Image",
198
+ descLabel: "Desc:",
199
+ descLabelPlaceHolder: "Enter a description...",
200
+ urlLabel: "Link:",
201
+ urlLabelPlaceHolder: "Enter a link...",
200
202
  buttonOK: "OK"
201
203
  },
202
204
  clipModalTips: {
@@ -228,43 +230,43 @@ const staticTextDefault = {
228
230
  }
229
231
  }
230
232
  };
231
- const mermaidUrl = `${cdnBase}/mermaid/8.13.5/mermaid.min.js`;
233
+ const mermaidUrl = `${cdnBase}/mermaid/9.2.2/mermaid.min.js`;
232
234
  const katexUrl = {
233
- js: `${cdnBase}/KaTeX/0.15.1/katex.min.js`,
234
- css: `${cdnBase}/KaTeX/0.15.1/katex.min.css`
235
+ js: `${cdnBase}/KaTeX/0.16.3/katex.min.js`,
236
+ css: `${cdnBase}/KaTeX/0.16.3/katex.min.css`
235
237
  };
236
238
  const codeCss = {
237
239
  a11y: {
238
- light: `${cdnBase}/highlight.js/11.5.1/styles/a11y-light.min.css`,
239
- dark: `${cdnBase}/highlight.js/11.5.1/styles/a11y-dark.min.css`
240
+ light: `${cdnBase}/highlight.js/11.7.0/styles/a11y-light.min.css`,
241
+ dark: `${cdnBase}/highlight.js/11.7.0/styles/a11y-dark.min.css`
240
242
  },
241
243
  atom: {
242
- light: `${cdnBase}/highlight.js/11.5.1/styles/atom-one-light.min.css`,
243
- dark: `${cdnBase}/highlight.js/11.5.1/styles/atom-one-dark.min.css`
244
+ light: `${cdnBase}/highlight.js/11.7.0/styles/atom-one-light.min.css`,
245
+ dark: `${cdnBase}/highlight.js/11.7.0/styles/atom-one-dark.min.css`
244
246
  },
245
247
  github: {
246
- light: `${cdnBase}/highlight.js/11.5.1/styles/github.min.css`,
247
- dark: `${cdnBase}/highlight.js/11.5.1/styles/github-dark.min.css`
248
+ light: `${cdnBase}/highlight.js/11.7.0/styles/github.min.css`,
249
+ dark: `${cdnBase}/highlight.js/11.7.0/styles/github-dark.min.css`
248
250
  },
249
251
  gradient: {
250
- light: `${cdnBase}/highlight.js/11.5.1/styles/gradient-light.min.css`,
251
- dark: `${cdnBase}/highlight.js/11.5.1/styles/gradient-dark.min.css`
252
+ light: `${cdnBase}/highlight.js/11.7.0/styles/gradient-light.min.css`,
253
+ dark: `${cdnBase}/highlight.js/11.7.0/styles/gradient-dark.min.css`
252
254
  },
253
255
  kimbie: {
254
- light: `${cdnBase}/highlight.js/11.5.1/styles/kimbie-light.min.css`,
255
- dark: `${cdnBase}/highlight.js/11.5.1/styles/kimbie-dark.min.css`
256
+ light: `${cdnBase}/highlight.js/11.7.0/styles/kimbie-light.min.css`,
257
+ dark: `${cdnBase}/highlight.js/11.7.0/styles/kimbie-dark.min.css`
256
258
  },
257
259
  paraiso: {
258
- light: `${cdnBase}/highlight.js/11.5.1/styles/paraiso-light.min.css`,
259
- dark: `${cdnBase}/highlight.js/11.5.1/styles/paraiso-dark.min.css`
260
+ light: `${cdnBase}/highlight.js/11.7.0/styles/paraiso-light.min.css`,
261
+ dark: `${cdnBase}/highlight.js/11.7.0/styles/paraiso-dark.min.css`
260
262
  },
261
263
  qtcreator: {
262
- light: `${cdnBase}/highlight.js/11.5.1/styles/qtcreator-light.min.css`,
263
- dark: `${cdnBase}/highlight.js/11.5.1/styles/qtcreator-dark.min.css`
264
+ light: `${cdnBase}/highlight.js/11.7.0/styles/qtcreator-light.min.css`,
265
+ dark: `${cdnBase}/highlight.js/11.7.0/styles/qtcreator-dark.min.css`
264
266
  },
265
267
  stackoverflow: {
266
- light: `${cdnBase}/highlight.js/11.5.1/styles/stackoverflow-light.min.css`,
267
- dark: `${cdnBase}/highlight.js/11.5.1/styles/stackoverflow-dark.min.css`
268
+ light: `${cdnBase}/highlight.js/11.7.0/styles/stackoverflow-light.min.css`,
269
+ dark: `${cdnBase}/highlight.js/11.7.0/styles/stackoverflow-dark.min.css`
268
270
  }
269
271
  };
270
272
  const configOption = {
@@ -560,6 +562,14 @@ const updateHandler = debounce((id, attr, value) => {
560
562
  ele.setAttribute(attr, value);
561
563
  }
562
564
  }, 10);
565
+ const ON_SAVE = "onSave";
566
+ const CHANGE_CATALOG_VISIBLE = "changeCatalogVisible";
567
+ const CHANGE_FULL_SCREEN = "changeFullscreen";
568
+ const PAGE_FULL_SCREEN_CHANGED = "pageFullscreenChanged";
569
+ const FULL_SCREEN_CHANGED = "fullscreenChanged";
570
+ const PREVIEW_CHANGED = "previewChanged";
571
+ const HTML_PREVIEW_CHANGED = "htmlPreviewChanged";
572
+ const CATALOG_VISIBLE_CHANGED = "catalogVisibleChanged";
563
573
  const useKeyBoard = (props, context) => {
564
574
  const { editorId, noPrettier, previewOnly } = props;
565
575
  const state = reactive({
@@ -568,7 +578,7 @@ const useKeyBoard = (props, context) => {
568
578
  });
569
579
  const initFunc = (name) => {
570
580
  var _a, _b;
571
- return ((_a = props.toolbars) == null ? void 0 : _a.includes(name)) && !((_b = props.toolbarsExclude) == null ? void 0 : _b.includes(name)) && !noPrettier;
581
+ return ((_a = props.toolbars) == null ? void 0 : _a.includes(name)) && !((_b = props.toolbarsExclude) == null ? void 0 : _b.includes(name));
572
582
  };
573
583
  const keyDownHandler = (event) => {
574
584
  if (event.target !== document.querySelector(`#${props.editorId}-textarea`)) {
@@ -584,7 +594,7 @@ const useKeyBoard = (props, context) => {
584
594
  }
585
595
  } else {
586
596
  if (initFunc("save")) {
587
- bus.emit(editorId, "onSave", props.modelValue);
597
+ bus.emit(editorId, ON_SAVE, props.modelValue);
588
598
  event.preventDefault();
589
599
  }
590
600
  }
@@ -768,7 +778,7 @@ const useKeyBoard = (props, context) => {
768
778
  }
769
779
  case "KeyF": {
770
780
  if (event.shiftKey) {
771
- if (initFunc("prettier")) {
781
+ if (initFunc("prettier") && !noPrettier) {
772
782
  bus.emit(editorId, "replace", "prettier");
773
783
  event.preventDefault();
774
784
  }
@@ -818,7 +828,7 @@ const useKeyBoard = (props, context) => {
818
828
  }
819
829
  });
820
830
  bus.on(editorId, {
821
- name: "onSave",
831
+ name: ON_SAVE,
822
832
  callback() {
823
833
  const htmlPromise = new Promise((rev) => {
824
834
  if (state.buildFinished) {
@@ -858,9 +868,10 @@ const useProvide = (props) => {
858
868
  provide("theme", computed(() => props.theme));
859
869
  provide("highlight", computed(() => {
860
870
  const cssList = __spreadValues(__spreadValues({}, codeCss), highlightConfig == null ? void 0 : highlightConfig.css);
871
+ const theme = props.codeStyleReverse && props.codeStyleReverseList.includes(props.previewTheme) ? "dark" : props.theme;
861
872
  return {
862
873
  js: (highlightConfig == null ? void 0 : highlightConfig.js) || highlightUrl,
863
- css: cssList[props.codeTheme] ? cssList[props.codeTheme][props.theme] : codeCss.atom[props.theme]
874
+ css: cssList[props.codeTheme] ? cssList[props.codeTheme][theme] : codeCss.atom[theme]
864
875
  };
865
876
  }));
866
877
  provide("historyLength", props.historyLength);
@@ -880,11 +891,11 @@ const useProvide = (props) => {
880
891
  };
881
892
  const useExpansion = (props) => {
882
893
  var _a, _b, _c, _d, _e, _f;
883
- const { noPrettier, previewOnly, noIconfont } = props;
894
+ const { noPrettier, previewOnly, noIconfont, noUploadImg } = props;
884
895
  const { editorExtensions } = configOption;
885
896
  const noPrettierScript = noPrettier || !!((_b = (_a = configOption.editorExtensions) == null ? void 0 : _a.prettier) == null ? void 0 : _b.prettierInstance);
886
897
  const noParserMarkdownScript = noPrettier || !!((_d = (_c = configOption.editorExtensions) == null ? void 0 : _c.prettier) == null ? void 0 : _d.parserMarkdownInstance);
887
- const noCropperScript = !!((_f = (_e = configOption.editorExtensions) == null ? void 0 : _e.cropper) == null ? void 0 : _f.instance);
898
+ const noCropperScript = noUploadImg || !!((_f = (_e = configOption.editorExtensions) == null ? void 0 : _e.cropper) == null ? void 0 : _f.instance);
888
899
  onMounted(() => {
889
900
  var _a2, _b2, _c2, _d2;
890
901
  const iconfontScript = document.createElement("script");
@@ -923,13 +934,13 @@ const useExpansion = (props) => {
923
934
  const useConfig = (props, context) => {
924
935
  const { editorId, previewOnly } = props;
925
936
  const setting = reactive({
926
- pageFullScreen: props.pageFullScreen,
937
+ pageFullscreen: props.pageFullscreen,
927
938
  fullscreen: false,
928
939
  preview: props.preview,
929
940
  htmlPreview: props.preview ? false : props.htmlPreview
930
941
  });
931
- const updateSetting = (v, k) => {
932
- setting[k] = v;
942
+ const updateSetting = (k, v) => {
943
+ setting[k] = v === void 0 ? !setting[k] : v;
933
944
  if (k === "preview" && setting.preview) {
934
945
  setting.htmlPreview = false;
935
946
  } else if (k === "htmlPreview" && setting.htmlPreview) {
@@ -938,13 +949,13 @@ const useConfig = (props, context) => {
938
949
  };
939
950
  let bodyOverflowHistory = "";
940
951
  const adjustBody = () => {
941
- if (setting.pageFullScreen || setting.fullscreen) {
952
+ if (setting.pageFullscreen || setting.fullscreen) {
942
953
  document.body.style.overflow = "hidden";
943
954
  } else {
944
955
  document.body.style.overflow = bodyOverflowHistory;
945
956
  }
946
957
  };
947
- watch(() => [setting.pageFullScreen, setting.fullscreen], adjustBody);
958
+ watch(() => [setting.pageFullscreen, setting.fullscreen], adjustBody);
948
959
  onMounted(() => {
949
960
  if (!previewOnly) {
950
961
  bus.on(editorId, {
@@ -975,9 +986,13 @@ const useCatalog = (props) => {
975
986
  const catalogVisible = ref(false);
976
987
  onMounted(() => {
977
988
  bus.on(editorId, {
978
- name: "catalogShow",
979
- callback: () => {
980
- catalogVisible.value = !catalogVisible.value;
989
+ name: CHANGE_CATALOG_VISIBLE,
990
+ callback: (v) => {
991
+ if (v === void 0) {
992
+ catalogVisible.value = !catalogVisible.value;
993
+ } else {
994
+ catalogVisible.value = v;
995
+ }
981
996
  }
982
997
  });
983
998
  });
@@ -986,6 +1001,97 @@ const useCatalog = (props) => {
986
1001
  });
987
1002
  return [catalogVisible, catalogShow];
988
1003
  };
1004
+ const useExpose = (props, ctx, catalogVisible, setting, updateSetting) => {
1005
+ const { editorId } = props;
1006
+ watch(() => setting.pageFullscreen, (newVal) => {
1007
+ bus.emit(editorId, PAGE_FULL_SCREEN_CHANGED, newVal);
1008
+ });
1009
+ watch(() => setting.fullscreen, (newVal) => {
1010
+ bus.emit(editorId, FULL_SCREEN_CHANGED, newVal);
1011
+ });
1012
+ watch(() => setting.preview, (newVal) => {
1013
+ bus.emit(editorId, PREVIEW_CHANGED, newVal);
1014
+ });
1015
+ watch(() => setting.htmlPreview, (newVal) => {
1016
+ bus.emit(editorId, HTML_PREVIEW_CHANGED, newVal);
1017
+ });
1018
+ watch(catalogVisible, (newVal) => {
1019
+ bus.emit(editorId, CATALOG_VISIBLE_CHANGED, newVal);
1020
+ });
1021
+ const exposeParam = {
1022
+ on(eventName, callBack) {
1023
+ switch (eventName) {
1024
+ case "pageFullscreen": {
1025
+ bus.on(editorId, {
1026
+ name: PAGE_FULL_SCREEN_CHANGED,
1027
+ callback(status) {
1028
+ callBack(status);
1029
+ }
1030
+ });
1031
+ break;
1032
+ }
1033
+ case "fullscreen": {
1034
+ bus.on(editorId, {
1035
+ name: FULL_SCREEN_CHANGED,
1036
+ callback(status) {
1037
+ callBack(status);
1038
+ }
1039
+ });
1040
+ break;
1041
+ }
1042
+ case "preview": {
1043
+ bus.on(editorId, {
1044
+ name: PREVIEW_CHANGED,
1045
+ callback(status) {
1046
+ callBack(status);
1047
+ }
1048
+ });
1049
+ break;
1050
+ }
1051
+ case "htmlPreview": {
1052
+ bus.on(editorId, {
1053
+ name: HTML_PREVIEW_CHANGED,
1054
+ callback(status) {
1055
+ callBack(status);
1056
+ }
1057
+ });
1058
+ break;
1059
+ }
1060
+ case "catalog": {
1061
+ bus.on(editorId, {
1062
+ name: CATALOG_VISIBLE_CHANGED,
1063
+ callback(status) {
1064
+ callBack(status);
1065
+ }
1066
+ });
1067
+ break;
1068
+ }
1069
+ }
1070
+ },
1071
+ togglePageFullscreen(status) {
1072
+ updateSetting("pageFullscreen", status);
1073
+ },
1074
+ toggleFullscreen(status) {
1075
+ bus.emit(editorId, CHANGE_FULL_SCREEN, status);
1076
+ },
1077
+ togglePreview(status) {
1078
+ updateSetting("preview", status);
1079
+ },
1080
+ toggleHtmlPreview(status) {
1081
+ updateSetting("htmlPreview", status);
1082
+ },
1083
+ toggleCatalog(status) {
1084
+ bus.emit(editorId, CHANGE_CATALOG_VISIBLE, status);
1085
+ },
1086
+ triggerSave() {
1087
+ bus.emit(editorId, ON_SAVE);
1088
+ },
1089
+ insert(generate) {
1090
+ bus.emit(editorId, "replace", "universal", { generate });
1091
+ }
1092
+ };
1093
+ ctx.expose(exposeParam);
1094
+ };
989
1095
  var index$1 = "";
990
1096
  var Divider = defineComponent({
991
1097
  setup() {
@@ -1334,13 +1440,13 @@ var LinkModal = defineComponent({
1334
1440
  const ult = inject("usedLanguageText");
1335
1441
  const editorId = inject("editorId");
1336
1442
  const title = computed(() => {
1337
- var _a, _b, _c, _d;
1443
+ var _a, _b;
1338
1444
  switch (props.type) {
1339
1445
  case "link": {
1340
- return `${(_a = ult.value.linkModalTips) == null ? void 0 : _a.title}${(_b = ult.value.toolbarTips) == null ? void 0 : _b.link}`;
1446
+ return (_a = ult.value.linkModalTips) == null ? void 0 : _a.linkTitle;
1341
1447
  }
1342
1448
  case "image": {
1343
- return `${(_c = ult.value.linkModalTips) == null ? void 0 : _c.title}${(_d = ult.value.toolbarTips) == null ? void 0 : _d.image}`;
1449
+ return (_b = ult.value.linkModalTips) == null ? void 0 : _b.imageTitle;
1344
1450
  }
1345
1451
  default: {
1346
1452
  return "";
@@ -1369,10 +1475,10 @@ var LinkModal = defineComponent({
1369
1475
  return [createVNode("div", {
1370
1476
  "class": `${prefix}-form-item`
1371
1477
  }, [createVNode("label", {
1372
- "class": `${prefix}-lable`,
1478
+ "class": `${prefix}-label`,
1373
1479
  "for": `link-desc-${editorId}`
1374
- }, [(_a = ult.value.linkModalTips) == null ? void 0 : _a.descLable]), createVNode("input", {
1375
- "placeholder": (_b = ult.value.linkModalTips) == null ? void 0 : _b.descLablePlaceHolder,
1480
+ }, [(_a = ult.value.linkModalTips) == null ? void 0 : _a.descLabel]), createVNode("input", {
1481
+ "placeholder": (_b = ult.value.linkModalTips) == null ? void 0 : _b.descLabelPlaceHolder,
1376
1482
  "class": `${prefix}-input`,
1377
1483
  "id": `link-desc-${editorId}`,
1378
1484
  "type": "text",
@@ -1384,10 +1490,10 @@ var LinkModal = defineComponent({
1384
1490
  }, null)]), createVNode("div", {
1385
1491
  "class": `${prefix}-form-item`
1386
1492
  }, [createVNode("label", {
1387
- "class": `${prefix}-lable`,
1493
+ "class": `${prefix}-label`,
1388
1494
  "for": `link-url-${editorId}`
1389
- }, [(_c = ult.value.linkModalTips) == null ? void 0 : _c.urlLable]), createVNode("input", {
1390
- "placeholder": (_d = ult.value.linkModalTips) == null ? void 0 : _d.urlLablePlaceHolder,
1495
+ }, [(_c = ult.value.linkModalTips) == null ? void 0 : _c.urlLabel]), createVNode("input", {
1496
+ "placeholder": (_d = ult.value.linkModalTips) == null ? void 0 : _d.urlLabelPlaceHolder,
1391
1497
  "class": `${prefix}-input`,
1392
1498
  "id": `link-url-${editorId}`,
1393
1499
  "type": "text",
@@ -1620,20 +1726,21 @@ const useSreenfull = (props) => {
1620
1726
  let screenfull = (_b = (_a = configOption.editorExtensions) == null ? void 0 : _a.screenfull) == null ? void 0 : _b.instance;
1621
1727
  const screenfullJs = (_d = (_c = configOption.editorExtensions) == null ? void 0 : _c.screenfull) == null ? void 0 : _d.js;
1622
1728
  const screenfullMe = ref(false);
1623
- const fullScreenHandler = () => {
1729
+ const fullscreenHandler = (status) => {
1624
1730
  if (!screenfull) {
1625
1731
  bus.emit(editorId, "errorCatcher", {
1626
- name: "fullScreen",
1627
- message: "fullScreen is undefined"
1732
+ name: "fullscreen",
1733
+ message: "fullscreen is undefined"
1628
1734
  });
1629
1735
  return;
1630
1736
  }
1631
1737
  if (screenfull.isEnabled) {
1632
1738
  screenfullMe.value = true;
1633
- if (screenfull.isFullscreen) {
1634
- screenfull.exit();
1635
- } else {
1739
+ const targetStatus = status === void 0 ? !screenfull.isFullscreen : !!status;
1740
+ if (targetStatus) {
1636
1741
  screenfull.request();
1742
+ } else {
1743
+ screenfull.exit();
1637
1744
  }
1638
1745
  } else {
1639
1746
  console.error("browser does not support screenfull!");
@@ -1644,7 +1751,7 @@ const useSreenfull = (props) => {
1644
1751
  screenfull.on("change", () => {
1645
1752
  if (screenfullMe.value || props.setting.fullscreen) {
1646
1753
  screenfullMe.value = false;
1647
- props.updateSetting(!props.setting.fullscreen, "fullscreen");
1754
+ props.updateSetting("fullscreen");
1648
1755
  }
1649
1756
  });
1650
1757
  }
@@ -1663,7 +1770,15 @@ const useSreenfull = (props) => {
1663
1770
  appendHandler(screenScript, "screenfull");
1664
1771
  }
1665
1772
  });
1666
- return { fullScreenHandler };
1773
+ onMounted(() => {
1774
+ if (!previewOnly) {
1775
+ bus.on(editorId, {
1776
+ name: CHANGE_FULL_SCREEN,
1777
+ callback: fullscreenHandler
1778
+ });
1779
+ }
1780
+ });
1781
+ return { fullscreenHandler };
1667
1782
  };
1668
1783
  const tableShapeProps = () => ({
1669
1784
  tableShape: {
@@ -1755,7 +1870,7 @@ var ToolBar = defineComponent({
1755
1870
  const editorId = inject("editorId");
1756
1871
  const ult = inject("usedLanguageText");
1757
1872
  const {
1758
- fullScreenHandler
1873
+ fullscreenHandler
1759
1874
  } = useSreenfull(props);
1760
1875
  const wrapperId = `${editorId}-toolbar-wrapper`;
1761
1876
  const visible = reactive({
@@ -2167,7 +2282,7 @@ var ToolBar = defineComponent({
2167
2282
  "class": `${prefix}-toolbar-item`,
2168
2283
  "title": (_z = ult.value.toolbarTips) == null ? void 0 : _z.save,
2169
2284
  "onClick": () => {
2170
- bus.emit(editorId, "onSave");
2285
+ bus.emit(editorId, ON_SAVE);
2171
2286
  }
2172
2287
  }, [createVNode("svg", {
2173
2288
  "class": `${prefix}-icon`,
@@ -2195,25 +2310,27 @@ var ToolBar = defineComponent({
2195
2310
  "class": `${prefix}-toolbar-item`,
2196
2311
  "title": (_B = ult.value.toolbarTips) == null ? void 0 : _B.pageFullscreen,
2197
2312
  "onClick": () => {
2198
- props.updateSetting(!props.setting.pageFullScreen, "pageFullScreen");
2313
+ props.updateSetting("pageFullscreen");
2199
2314
  }
2200
2315
  }, [createVNode("svg", {
2201
2316
  "class": `${prefix}-icon`,
2202
2317
  "aria-hidden": "true"
2203
2318
  }, [createVNode("use", {
2204
- "xlink:href": `#md-editor-icon-${props.setting.pageFullScreen ? "suoxiao" : "fangda"}`
2319
+ "xlink:href": `#md-editor-icon-${props.setting.pageFullscreen ? "suoxiao" : "fangda"}`
2205
2320
  }, null)])]);
2206
2321
  }
2207
2322
  case "fullscreen": {
2208
2323
  return createVNode("div", {
2209
2324
  "class": `${prefix}-toolbar-item`,
2210
2325
  "title": (_C = ult.value.toolbarTips) == null ? void 0 : _C.fullscreen,
2211
- "onClick": fullScreenHandler
2326
+ "onClick": () => {
2327
+ fullscreenHandler();
2328
+ }
2212
2329
  }, [createVNode("svg", {
2213
2330
  "class": `${prefix}-icon`,
2214
2331
  "aria-hidden": "true"
2215
2332
  }, [createVNode("use", {
2216
- "xlink:href": `#md-editor-icon-${props.setting.fullscreen ? "fullScreen-exit" : "fullScreen"}`
2333
+ "xlink:href": `#md-editor-icon-${props.setting.fullscreen ? "fullscreen-exit" : "fullscreen"}`
2217
2334
  }, null)])]);
2218
2335
  }
2219
2336
  case "preview": {
@@ -2221,7 +2338,7 @@ var ToolBar = defineComponent({
2221
2338
  "class": `${prefix}-toolbar-item`,
2222
2339
  "title": (_D = ult.value.toolbarTips) == null ? void 0 : _D.preview,
2223
2340
  "onClick": () => {
2224
- props.updateSetting(!props.setting.preview, "preview");
2341
+ props.updateSetting("preview");
2225
2342
  }
2226
2343
  }, [createVNode("svg", {
2227
2344
  "class": `${prefix}-icon`,
@@ -2235,7 +2352,7 @@ var ToolBar = defineComponent({
2235
2352
  "class": `${prefix}-toolbar-item`,
2236
2353
  "title": (_E = ult.value.toolbarTips) == null ? void 0 : _E.htmlPreview,
2237
2354
  "onClick": () => {
2238
- props.updateSetting(!props.setting.htmlPreview, "htmlPreview");
2355
+ props.updateSetting("htmlPreview");
2239
2356
  }
2240
2357
  }, [createVNode("svg", {
2241
2358
  "class": `${prefix}-icon`,
@@ -2249,7 +2366,7 @@ var ToolBar = defineComponent({
2249
2366
  "class": `${prefix}-toolbar-item`,
2250
2367
  "title": (_F = ult.value.toolbarTips) == null ? void 0 : _F.catalog,
2251
2368
  "onClick": () => {
2252
- bus.emit(editorId, "catalogShow");
2369
+ bus.emit(editorId, CHANGE_CATALOG_VISIBLE);
2253
2370
  },
2254
2371
  "key": "bar-catalog"
2255
2372
  }, [createVNode("svg", {
@@ -2397,10 +2514,7 @@ var ToolBar = defineComponent({
2397
2514
  "class": `${prefix}-toolbar-wrapper`,
2398
2515
  "id": wrapperId
2399
2516
  }, [createVNode("div", {
2400
- "class": `${prefix}-toolbar`,
2401
- "onMouseenter": () => {
2402
- bus.emit(editorId, "selectTextChange");
2403
- }
2517
+ "class": `${prefix}-toolbar`
2404
2518
  }, [createVNode("div", {
2405
2519
  "class": `${prefix}-toolbar-left`,
2406
2520
  "ref": toolbarLeftRef
@@ -2438,6 +2552,7 @@ var ToolBar = defineComponent({
2438
2552
  });
2439
2553
  function getDefaults() {
2440
2554
  return {
2555
+ async: false,
2441
2556
  baseUrl: null,
2442
2557
  breaks: false,
2443
2558
  extensions: null,
@@ -2452,7 +2567,6 @@ function getDefaults() {
2452
2567
  sanitize: false,
2453
2568
  sanitizer: null,
2454
2569
  silent: false,
2455
- smartLists: false,
2456
2570
  smartypants: false,
2457
2571
  tokenizer: null,
2458
2572
  walkTokens: null,
@@ -2464,9 +2578,9 @@ function changeDefaults(newDefaults) {
2464
2578
  defaults = newDefaults;
2465
2579
  }
2466
2580
  const escapeTest = /[&<>"']/;
2467
- const escapeReplace = /[&<>"']/g;
2468
- const escapeTestNoEncode = /[<>"']|&(?!#?\w+;)/;
2469
- const escapeReplaceNoEncode = /[<>"']|&(?!#?\w+;)/g;
2581
+ const escapeReplace = new RegExp(escapeTest.source, "g");
2582
+ const escapeTestNoEncode = /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/;
2583
+ const escapeReplaceNoEncode = new RegExp(escapeTestNoEncode.source, "g");
2470
2584
  const escapeReplacements = {
2471
2585
  "&": "&amp;",
2472
2586
  "<": "&lt;",
@@ -2680,7 +2794,7 @@ function outputLink(cap, link, raw, lexer) {
2680
2794
  href,
2681
2795
  title,
2682
2796
  text,
2683
- tokens: lexer.inlineTokens(text, [])
2797
+ tokens: lexer.inlineTokens(text)
2684
2798
  };
2685
2799
  lexer.state.inLink = false;
2686
2800
  return token;
@@ -2744,7 +2858,7 @@ class Tokenizer {
2744
2858
  return {
2745
2859
  type: "code",
2746
2860
  raw,
2747
- lang: cap[2] ? cap[2].trim() : cap[2],
2861
+ lang: cap[2] ? cap[2].trim().replace(this.rules.inline._escapes, "$1") : cap[2],
2748
2862
  text
2749
2863
  };
2750
2864
  }
@@ -2761,15 +2875,13 @@ class Tokenizer {
2761
2875
  text = trimmed.trim();
2762
2876
  }
2763
2877
  }
2764
- const token = {
2878
+ return {
2765
2879
  type: "heading",
2766
2880
  raw: cap[0],
2767
2881
  depth: cap[1].length,
2768
2882
  text,
2769
- tokens: []
2883
+ tokens: this.lexer.inline(text)
2770
2884
  };
2771
- this.lexer.inline(token.text, token.tokens);
2772
- return token;
2773
2885
  }
2774
2886
  }
2775
2887
  hr(src) {
@@ -2842,12 +2954,20 @@ class Tokenizer {
2842
2954
  if (!endEarly) {
2843
2955
  const nextBulletRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:[*+-]|\\d{1,9}[.)])((?: [^\\n]*)?(?:\\n|$))`);
2844
2956
  const hrRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`);
2957
+ const fencesBeginRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:\`\`\`|~~~)`);
2958
+ const headingBeginRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}#`);
2845
2959
  while (src) {
2846
2960
  rawLine = src.split("\n", 1)[0];
2847
2961
  line = rawLine;
2848
2962
  if (this.options.pedantic) {
2849
2963
  line = line.replace(/^ {1,4}(?=( {4})*[^ ])/g, " ");
2850
2964
  }
2965
+ if (fencesBeginRegex.test(line)) {
2966
+ break;
2967
+ }
2968
+ if (headingBeginRegex.test(line)) {
2969
+ break;
2970
+ }
2851
2971
  if (nextBulletRegex.test(line)) {
2852
2972
  break;
2853
2973
  }
@@ -2931,10 +3051,10 @@ class Tokenizer {
2931
3051
  text: cap[0]
2932
3052
  };
2933
3053
  if (this.options.sanitize) {
3054
+ const text = this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape(cap[0]);
2934
3055
  token.type = "paragraph";
2935
- token.text = this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape(cap[0]);
2936
- token.tokens = [];
2937
- this.lexer.inline(token.text, token.tokens);
3056
+ token.text = text;
3057
+ token.tokens = this.lexer.inline(text);
2938
3058
  }
2939
3059
  return token;
2940
3060
  }
@@ -2942,15 +3062,15 @@ class Tokenizer {
2942
3062
  def(src) {
2943
3063
  const cap = this.rules.block.def.exec(src);
2944
3064
  if (cap) {
2945
- if (cap[3])
2946
- cap[3] = cap[3].substring(1, cap[3].length - 1);
2947
3065
  const tag = cap[1].toLowerCase().replace(/\s+/g, " ");
3066
+ const href = cap[2] ? cap[2].replace(/^<(.*)>$/, "$1").replace(this.rules.inline._escapes, "$1") : "";
3067
+ const title = cap[3] ? cap[3].substring(1, cap[3].length - 1).replace(this.rules.inline._escapes, "$1") : cap[3];
2948
3068
  return {
2949
3069
  type: "def",
2950
3070
  tag,
2951
3071
  raw: cap[0],
2952
- href: cap[2],
2953
- title: cap[3]
3072
+ href,
3073
+ title
2954
3074
  };
2955
3075
  }
2956
3076
  }
@@ -2988,15 +3108,13 @@ class Tokenizer {
2988
3108
  }
2989
3109
  l = item.header.length;
2990
3110
  for (j = 0; j < l; j++) {
2991
- item.header[j].tokens = [];
2992
- this.lexer.inlineTokens(item.header[j].text, item.header[j].tokens);
3111
+ item.header[j].tokens = this.lexer.inline(item.header[j].text);
2993
3112
  }
2994
3113
  l = item.rows.length;
2995
3114
  for (j = 0; j < l; j++) {
2996
3115
  row = item.rows[j];
2997
3116
  for (k = 0; k < row.length; k++) {
2998
- row[k].tokens = [];
2999
- this.lexer.inlineTokens(row[k].text, row[k].tokens);
3117
+ row[k].tokens = this.lexer.inline(row[k].text);
3000
3118
  }
3001
3119
  }
3002
3120
  return item;
@@ -3006,41 +3124,36 @@ class Tokenizer {
3006
3124
  lheading(src) {
3007
3125
  const cap = this.rules.block.lheading.exec(src);
3008
3126
  if (cap) {
3009
- const token = {
3127
+ return {
3010
3128
  type: "heading",
3011
3129
  raw: cap[0],
3012
3130
  depth: cap[2].charAt(0) === "=" ? 1 : 2,
3013
3131
  text: cap[1],
3014
- tokens: []
3132
+ tokens: this.lexer.inline(cap[1])
3015
3133
  };
3016
- this.lexer.inline(token.text, token.tokens);
3017
- return token;
3018
3134
  }
3019
3135
  }
3020
3136
  paragraph(src) {
3021
3137
  const cap = this.rules.block.paragraph.exec(src);
3022
3138
  if (cap) {
3023
- const token = {
3139
+ const text = cap[1].charAt(cap[1].length - 1) === "\n" ? cap[1].slice(0, -1) : cap[1];
3140
+ return {
3024
3141
  type: "paragraph",
3025
3142
  raw: cap[0],
3026
- text: cap[1].charAt(cap[1].length - 1) === "\n" ? cap[1].slice(0, -1) : cap[1],
3027
- tokens: []
3143
+ text,
3144
+ tokens: this.lexer.inline(text)
3028
3145
  };
3029
- this.lexer.inline(token.text, token.tokens);
3030
- return token;
3031
3146
  }
3032
3147
  }
3033
3148
  text(src) {
3034
3149
  const cap = this.rules.block.text.exec(src);
3035
3150
  if (cap) {
3036
- const token = {
3151
+ return {
3037
3152
  type: "text",
3038
3153
  raw: cap[0],
3039
3154
  text: cap[0],
3040
- tokens: []
3155
+ tokens: this.lexer.inline(cap[0])
3041
3156
  };
3042
- this.lexer.inline(token.text, token.tokens);
3043
- return token;
3044
3157
  }
3045
3158
  }
3046
3159
  escape(src) {
@@ -3127,7 +3240,7 @@ class Tokenizer {
3127
3240
  if ((cap = this.rules.inline.reflink.exec(src)) || (cap = this.rules.inline.nolink.exec(src))) {
3128
3241
  let link = (cap[2] || cap[1]).replace(/\s+/g, " ");
3129
3242
  link = links[link.toLowerCase()];
3130
- if (!link || !link.href) {
3243
+ if (!link) {
3131
3244
  const text = cap[0].charAt(0);
3132
3245
  return {
3133
3246
  type: "text",
@@ -3169,21 +3282,22 @@ class Tokenizer {
3169
3282
  if (delimTotal > 0)
3170
3283
  continue;
3171
3284
  rLength = Math.min(rLength, rLength + delimTotal + midDelimTotal);
3285
+ const raw = src.slice(0, lLength + match.index + (match[0].length - rDelim.length) + rLength);
3172
3286
  if (Math.min(lLength, rLength) % 2) {
3173
- const text2 = src.slice(1, lLength + match.index + rLength);
3287
+ const text2 = raw.slice(1, -1);
3174
3288
  return {
3175
3289
  type: "em",
3176
- raw: src.slice(0, lLength + match.index + rLength + 1),
3290
+ raw,
3177
3291
  text: text2,
3178
- tokens: this.lexer.inlineTokens(text2, [])
3292
+ tokens: this.lexer.inlineTokens(text2)
3179
3293
  };
3180
3294
  }
3181
- const text = src.slice(2, lLength + match.index + rLength - 1);
3295
+ const text = raw.slice(2, -2);
3182
3296
  return {
3183
3297
  type: "strong",
3184
- raw: src.slice(0, lLength + match.index + rLength + 1),
3298
+ raw,
3185
3299
  text,
3186
- tokens: this.lexer.inlineTokens(text, [])
3300
+ tokens: this.lexer.inlineTokens(text)
3187
3301
  };
3188
3302
  }
3189
3303
  }
@@ -3221,7 +3335,7 @@ class Tokenizer {
3221
3335
  type: "del",
3222
3336
  raw: cap[0],
3223
3337
  text: cap[2],
3224
- tokens: this.lexer.inlineTokens(cap[2], [])
3338
+ tokens: this.lexer.inlineTokens(cap[2])
3225
3339
  };
3226
3340
  }
3227
3341
  }
@@ -3312,9 +3426,9 @@ const block = {
3312
3426
  blockquote: /^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,
3313
3427
  list: /^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/,
3314
3428
  html: "^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))",
3315
- def: /^ {0,3}\[(label)\]: *(?:\n *)?<?([^\s>]+)>?(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/,
3429
+ def: /^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/,
3316
3430
  table: noopTest,
3317
- lheading: /^([^\n]+)\n {0,3}(=+|-+) *(?:\n+|$)/,
3431
+ lheading: /^((?:.|\n(?!\n))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
3318
3432
  _paragraph: /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,
3319
3433
  text: /^[^\n]+/
3320
3434
  };
@@ -3340,6 +3454,7 @@ block.pedantic = merge({}, block.normal, {
3340
3454
  def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
3341
3455
  heading: /^(#{1,6})(.*)(?:\n+|$)/,
3342
3456
  fences: noopTest,
3457
+ lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
3343
3458
  paragraph: edit(block.normal._paragraph).replace("hr", block.hr).replace("heading", " *#{1,6} *[^\n]").replace("lheading", block.lheading).replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").getRegex()
3344
3459
  });
3345
3460
  const inline = {
@@ -3353,8 +3468,8 @@ const inline = {
3353
3468
  reflinkSearch: "reflink|nolink(?!\\()",
3354
3469
  emStrong: {
3355
3470
  lDelim: /^(?:\*+(?:([punct_])|[^\s*]))|^_+(?:([punct*])|([^\s_]))/,
3356
- rDelimAst: /^[^_*]*?\_\_[^_*]*?\*[^_*]*?(?=\_\_)|[^*]+(?=[^*])|[punct_](\*+)(?=[\s]|$)|[^punct*_\s](\*+)(?=[punct_\s]|$)|[punct_\s](\*+)(?=[^punct*_\s])|[\s](\*+)(?=[punct_])|[punct_](\*+)(?=[punct_])|[^punct*_\s](\*+)(?=[^punct*_\s])/,
3357
- rDelimUnd: /^[^_*]*?\*\*[^_*]*?\_[^_*]*?(?=\*\*)|[^_]+(?=[^_])|[punct*](\_+)(?=[\s]|$)|[^punct*_\s](\_+)(?=[punct*\s]|$)|[punct*\s](\_+)(?=[^punct*_\s])|[\s](\_+)(?=[punct*])|[punct*](\_+)(?=[punct*])/
3471
+ rDelimAst: /^(?:[^_*\\]|\\.)*?\_\_(?:[^_*\\]|\\.)*?\*(?:[^_*\\]|\\.)*?(?=\_\_)|(?:[^*\\]|\\.)+(?=[^*])|[punct_](\*+)(?=[\s]|$)|(?:[^punct*_\s\\]|\\.)(\*+)(?=[punct_\s]|$)|[punct_\s](\*+)(?=[^punct*_\s])|[\s](\*+)(?=[punct_])|[punct_](\*+)(?=[punct_])|(?:[^punct*_\s\\]|\\.)(\*+)(?=[^punct*_\s])/,
3472
+ rDelimUnd: /^(?:[^_*\\]|\\.)*?\*\*(?:[^_*\\]|\\.)*?\_(?:[^_*\\]|\\.)*?(?=\*\*)|(?:[^_\\]|\\.)+(?=[^_])|[punct*](\_+)(?=[\s]|$)|(?:[^punct*_\s\\]|\\.)(\_+)(?=[punct*\s]|$)|[punct*\s](\_+)(?=[^punct*_\s])|[\s](\_+)(?=[punct*])|[punct*](\_+)(?=[punct*])/
3358
3473
  },
3359
3474
  code: /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,
3360
3475
  br: /^( {2,}|\\)\n(?!\s*$)/,
@@ -3365,7 +3480,7 @@ const inline = {
3365
3480
  inline._punctuation = "!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~";
3366
3481
  inline.punctuation = edit(inline.punctuation).replace(/punctuation/g, inline._punctuation).getRegex();
3367
3482
  inline.blockSkip = /\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g;
3368
- inline.escapedEmSt = /\\\*|\\_/g;
3483
+ inline.escapedEmSt = /(?:^|[^\\])(?:\\\\)*\\[*_]/g;
3369
3484
  inline._comment = edit(block._comment).replace("(?:-->|$)", "-->").getRegex();
3370
3485
  inline.emStrong.lDelim = edit(inline.emStrong.lDelim).replace(/punct/g, inline._punctuation).getRegex();
3371
3486
  inline.emStrong.rDelimAst = edit(inline.emStrong.rDelimAst, "g").replace(/punct/g, inline._punctuation).getRegex();
@@ -3634,8 +3749,9 @@ class Lexer {
3634
3749
  this.state.top = true;
3635
3750
  return tokens;
3636
3751
  }
3637
- inline(src, tokens) {
3752
+ inline(src, tokens = []) {
3638
3753
  this.inlineQueue.push({ src, tokens });
3754
+ return tokens;
3639
3755
  }
3640
3756
  inlineTokens(src, tokens = []) {
3641
3757
  let token, lastToken, cutSrc;
@@ -3656,7 +3772,8 @@ class Lexer {
3656
3772
  maskedSrc = maskedSrc.slice(0, match.index) + "[" + repeatString("a", match[0].length - 2) + "]" + maskedSrc.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
3657
3773
  }
3658
3774
  while ((match = this.tokenizer.rules.inline.escapedEmSt.exec(maskedSrc)) != null) {
3659
- maskedSrc = maskedSrc.slice(0, match.index) + "++" + maskedSrc.slice(this.tokenizer.rules.inline.escapedEmSt.lastIndex);
3775
+ maskedSrc = maskedSrc.slice(0, match.index + match[0].length - 2) + "++" + maskedSrc.slice(this.tokenizer.rules.inline.escapedEmSt.lastIndex);
3776
+ this.tokenizer.rules.inline.escapedEmSt.lastIndex--;
3660
3777
  }
3661
3778
  while (src) {
3662
3779
  if (!keepPrevChar) {
@@ -3795,7 +3912,7 @@ class Renderer {
3795
3912
  if (!lang) {
3796
3913
  return "<pre><code>" + (escaped ? code : escape(code, true)) + "</code></pre>\n";
3797
3914
  }
3798
- return '<pre><code class="' + this.options.langPrefix + escape(lang, true) + '">' + (escaped ? code : escape(code, true)) + "</code></pre>\n";
3915
+ return '<pre><code class="' + this.options.langPrefix + escape(lang) + '">' + (escaped ? code : escape(code, true)) + "</code></pre>\n";
3799
3916
  }
3800
3917
  blockquote(quote) {
3801
3918
  return `<blockquote>
@@ -3868,7 +3985,7 @@ ${content}</tr>
3868
3985
  if (href === null) {
3869
3986
  return text;
3870
3987
  }
3871
- let out = '<a href="' + escape(href) + '"';
3988
+ let out = '<a href="' + href + '"';
3872
3989
  if (title) {
3873
3990
  out += ' title="' + title + '"';
3874
3991
  }
@@ -4221,18 +4338,26 @@ function marked(src, opt, callback) {
4221
4338
  }
4222
4339
  return;
4223
4340
  }
4341
+ function onError(e) {
4342
+ e.message += "\nPlease report this to https://github.com/markedjs/marked.";
4343
+ if (opt.silent) {
4344
+ return "<p>An error occurred:</p><pre>" + escape(e.message + "", true) + "</pre>";
4345
+ }
4346
+ throw e;
4347
+ }
4224
4348
  try {
4225
4349
  const tokens = Lexer.lex(src, opt);
4226
4350
  if (opt.walkTokens) {
4351
+ if (opt.async) {
4352
+ return Promise.all(marked.walkTokens(tokens, opt.walkTokens)).then(() => {
4353
+ return Parser.parse(tokens, opt);
4354
+ }).catch(onError);
4355
+ }
4227
4356
  marked.walkTokens(tokens, opt.walkTokens);
4228
4357
  }
4229
4358
  return Parser.parse(tokens, opt);
4230
4359
  } catch (e) {
4231
- e.message += "\nPlease report this to https://github.com/markedjs/marked.";
4232
- if (opt.silent) {
4233
- return "<p>An error occurred:</p><pre>" + escape(e.message + "", true) + "</pre>";
4234
- }
4235
- throw e;
4360
+ onError(e);
4236
4361
  }
4237
4362
  }
4238
4363
  marked.options = marked.setOptions = function(opt) {
@@ -4243,18 +4368,17 @@ marked.options = marked.setOptions = function(opt) {
4243
4368
  marked.getDefaults = getDefaults;
4244
4369
  marked.defaults = defaults;
4245
4370
  marked.use = function(...args) {
4246
- const opts = merge({}, ...args);
4247
4371
  const extensions = marked.defaults.extensions || { renderers: {}, childTokens: {} };
4248
- let hasExtensions;
4249
4372
  args.forEach((pack) => {
4373
+ const opts = merge({}, pack);
4374
+ opts.async = marked.defaults.async || opts.async;
4250
4375
  if (pack.extensions) {
4251
- hasExtensions = true;
4252
4376
  pack.extensions.forEach((ext) => {
4253
4377
  if (!ext.name) {
4254
4378
  throw new Error("extension name required");
4255
4379
  }
4256
4380
  if (ext.renderer) {
4257
- const prevRenderer = extensions.renderers ? extensions.renderers[ext.name] : null;
4381
+ const prevRenderer = extensions.renderers[ext.name];
4258
4382
  if (prevRenderer) {
4259
4383
  extensions.renderers[ext.name] = function(...args2) {
4260
4384
  let ret = ext.renderer.apply(this, args2);
@@ -4296,6 +4420,7 @@ marked.use = function(...args) {
4296
4420
  extensions.childTokens[ext.name] = ext.childTokens;
4297
4421
  }
4298
4422
  });
4423
+ opts.extensions = extensions;
4299
4424
  }
4300
4425
  if (pack.renderer) {
4301
4426
  const renderer = marked.defaults.renderer || new Renderer();
@@ -4328,48 +4453,49 @@ marked.use = function(...args) {
4328
4453
  if (pack.walkTokens) {
4329
4454
  const walkTokens = marked.defaults.walkTokens;
4330
4455
  opts.walkTokens = function(token) {
4331
- pack.walkTokens.call(this, token);
4456
+ let values = [];
4457
+ values.push(pack.walkTokens.call(this, token));
4332
4458
  if (walkTokens) {
4333
- walkTokens.call(this, token);
4459
+ values = values.concat(walkTokens.call(this, token));
4334
4460
  }
4461
+ return values;
4335
4462
  };
4336
4463
  }
4337
- if (hasExtensions) {
4338
- opts.extensions = extensions;
4339
- }
4340
4464
  marked.setOptions(opts);
4341
4465
  });
4342
4466
  };
4343
4467
  marked.walkTokens = function(tokens, callback) {
4468
+ let values = [];
4344
4469
  for (const token of tokens) {
4345
- callback.call(marked, token);
4470
+ values = values.concat(callback.call(marked, token));
4346
4471
  switch (token.type) {
4347
4472
  case "table": {
4348
4473
  for (const cell of token.header) {
4349
- marked.walkTokens(cell.tokens, callback);
4474
+ values = values.concat(marked.walkTokens(cell.tokens, callback));
4350
4475
  }
4351
4476
  for (const row of token.rows) {
4352
4477
  for (const cell of row) {
4353
- marked.walkTokens(cell.tokens, callback);
4478
+ values = values.concat(marked.walkTokens(cell.tokens, callback));
4354
4479
  }
4355
4480
  }
4356
4481
  break;
4357
4482
  }
4358
4483
  case "list": {
4359
- marked.walkTokens(token.items, callback);
4484
+ values = values.concat(marked.walkTokens(token.items, callback));
4360
4485
  break;
4361
4486
  }
4362
4487
  default: {
4363
4488
  if (marked.defaults.extensions && marked.defaults.extensions.childTokens && marked.defaults.extensions.childTokens[token.type]) {
4364
4489
  marked.defaults.extensions.childTokens[token.type].forEach(function(childTokens) {
4365
- marked.walkTokens(token[childTokens], callback);
4490
+ values = values.concat(marked.walkTokens(token[childTokens], callback));
4366
4491
  });
4367
4492
  } else if (token.tokens) {
4368
- marked.walkTokens(token.tokens, callback);
4493
+ values = values.concat(marked.walkTokens(token.tokens, callback));
4369
4494
  }
4370
4495
  }
4371
4496
  }
4372
4497
  }
4498
+ return values;
4373
4499
  };
4374
4500
  marked.parseInline = function(src, opt) {
4375
4501
  if (typeof src === "undefined" || src === null) {
@@ -4525,7 +4651,7 @@ function copy(text, options) {
4525
4651
  return success;
4526
4652
  }
4527
4653
  var copyToClipboard = copy;
4528
- /*! medium-zoom 1.0.6 | MIT License | https://github.com/francoischalifour/medium-zoom */
4654
+ /*! medium-zoom 1.0.8 | MIT License | https://github.com/francoischalifour/medium-zoom */
4529
4655
  var _extends = Object.assign || function(target) {
4530
4656
  for (var i = 1; i < arguments.length; i++) {
4531
4657
  var source = arguments[i];
@@ -4755,8 +4881,8 @@ var mediumZoom = function mediumZoom2(selector) {
4755
4881
  var naturalWidth = isSvg(zoomTarget) ? viewportWidth : zoomTarget.naturalWidth || viewportWidth;
4756
4882
  var naturalHeight = isSvg(zoomTarget) ? viewportHeight : zoomTarget.naturalHeight || viewportHeight;
4757
4883
  var _zoomTarget$getBoundi = zoomTarget.getBoundingClientRect(), top = _zoomTarget$getBoundi.top, left = _zoomTarget$getBoundi.left, width = _zoomTarget$getBoundi.width, height = _zoomTarget$getBoundi.height;
4758
- var scaleX = Math.min(naturalWidth, viewportWidth) / width;
4759
- var scaleY = Math.min(naturalHeight, viewportHeight) / height;
4884
+ var scaleX = Math.min(Math.max(width, naturalWidth), viewportWidth) / width;
4885
+ var scaleY = Math.min(Math.max(height, naturalHeight), viewportHeight) / height;
4760
4886
  var scale = Math.min(scaleX, scaleY);
4761
4887
  var translateX = (-left + (viewportWidth - width) / 2 + zoomOptions.margin + container.left) / scale;
4762
4888
  var translateY = (-top + (viewportHeight - height) / 2 + zoomOptions.margin + container.top) / scale;
@@ -4805,6 +4931,9 @@ var mediumZoom = function mediumZoom2(selector) {
4805
4931
  active.template.appendChild(template.content.cloneNode(true));
4806
4932
  document.body.appendChild(active.template);
4807
4933
  }
4934
+ if (active.original.parentElement && active.original.parentElement.tagName === "PICTURE" && active.original.currentSrc) {
4935
+ active.zoomed.src = active.original.currentSrc;
4936
+ }
4808
4937
  document.body.appendChild(active.zoomed);
4809
4938
  window.requestAnimationFrame(function() {
4810
4939
  document.body.classList.add("medium-zoom--opened");
@@ -4817,6 +4946,7 @@ var mediumZoom = function mediumZoom2(selector) {
4817
4946
  active.zoomedHd = active.zoomed.cloneNode();
4818
4947
  active.zoomedHd.removeAttribute("srcset");
4819
4948
  active.zoomedHd.removeAttribute("sizes");
4949
+ active.zoomedHd.removeAttribute("loading");
4820
4950
  active.zoomedHd.src = active.zoomed.getAttribute("data-zoom-src");
4821
4951
  active.zoomedHd.onerror = function() {
4822
4952
  clearInterval(getZoomTargetSize);
@@ -5342,6 +5472,14 @@ ${(mermaidTemplate == null ? void 0 : mermaidTemplate.journey) || "journey\n ti
5342
5472
  deviationEnd = -4;
5343
5473
  break;
5344
5474
  }
5475
+ case "universal": {
5476
+ const { generate } = params;
5477
+ const insertOptions = generate(selectedText);
5478
+ targetValue = insertOptions.targetValue;
5479
+ select = insertOptions.select;
5480
+ deviationStart = insertOptions.deviationStart;
5481
+ deviationEnd = insertOptions.deviationEnd;
5482
+ }
5345
5483
  }
5346
5484
  }
5347
5485
  return insert(inputArea, targetValue, {
@@ -5380,9 +5518,9 @@ var kaTexExtensions = {
5380
5518
  throwOnError: false,
5381
5519
  displayMode: true
5382
5520
  });
5383
- return `<span class="${prefix2}-katex-block" data-processed>${html}</span>`;
5521
+ return `<p class="${prefix2}-katex-block" data-processed>${html}</p>`;
5384
5522
  } else {
5385
- return `<span class="${prefix2}-katex-block">${token.text}</span>`;
5523
+ return `<p class="${prefix2}-katex-block">${token.text}</p>`;
5386
5524
  }
5387
5525
  }
5388
5526
  };
@@ -5548,7 +5686,6 @@ const useMarked = (props, mermaidData) => {
5548
5686
  let renderer = new marked.Renderer();
5549
5687
  const markedCode = renderer.code;
5550
5688
  renderer.code = (code, language, isEscaped) => {
5551
- var _a2;
5552
5689
  if (!props.noMermaid && language === "mermaid") {
5553
5690
  const idRand = `${prefix}-mermaid-${Date.now().toString(36)}`;
5554
5691
  try {
@@ -5558,19 +5695,11 @@ const useMarked = (props, mermaidData) => {
5558
5695
  } else if (typeof window !== "undefined" && window.mermaid) {
5559
5696
  svgCode = window.mermaid.mermaidAPI.render(idRand, code);
5560
5697
  } else {
5561
- svgCode = `<div class="mermaid">${code}</div>`;
5698
+ svgCode = `<p class="mermaid">${code}</p>`;
5562
5699
  }
5563
- return `<div class="${prefix}-mermaid">${svgCode}</div>`;
5700
+ return `<p class="${prefix}-mermaid">${svgCode}</p>`;
5564
5701
  } catch (error) {
5565
- if (typeof document !== "undefined") {
5566
- const errorDom = document.querySelector(`#${idRand}`);
5567
- if (errorDom) {
5568
- const errorSvg = errorDom.outerHTML;
5569
- (_a2 = errorDom.parentElement) == null ? void 0 : _a2.remove();
5570
- return errorSvg;
5571
- }
5572
- }
5573
- return "";
5702
+ return `<p class="${prefix}-mermaid-error">Error: ${(error == null ? void 0 : error.message) || ""}</p>`;
5574
5703
  }
5575
5704
  }
5576
5705
  return markedCode.call(renderer, code, language, isEscaped);
@@ -6003,6 +6132,9 @@ var Content = defineComponent({
6003
6132
  "id": `${editorId}-textarea`,
6004
6133
  "ref": textAreaRef,
6005
6134
  "value": props.value,
6135
+ "onBlur": () => {
6136
+ bus.emit(editorId, "selectTextChange");
6137
+ },
6006
6138
  "onKeydown": () => {
6007
6139
  bus.emit(editorId, "saveHistoryPos", true);
6008
6140
  },
@@ -6022,7 +6154,7 @@ var Content = defineComponent({
6022
6154
  "class": `${prefix}-preview-wrapper`,
6023
6155
  "ref": previewRef,
6024
6156
  "key": "content-preview-wrapper"
6025
- }, [createVNode("div", {
6157
+ }, [createVNode("article", {
6026
6158
  "id": `${editorId}-preview`,
6027
6159
  "class": [`${prefix}-preview`, `${previewTheme == null ? void 0 : previewTheme.value}-theme`, showCodeRowNumber && `${prefix}-scrn`],
6028
6160
  "innerHTML": html.value
@@ -6415,7 +6547,7 @@ const editorProps = () => ({
6415
6547
  onUploadImg: {
6416
6548
  type: Function
6417
6549
  },
6418
- pageFullScreen: {
6550
+ pageFullscreen: {
6419
6551
  type: Boolean,
6420
6552
  default: false
6421
6553
  },
@@ -6527,6 +6659,14 @@ const editorProps = () => ({
6527
6659
  },
6528
6660
  noUploadImg: {
6529
6661
  type: Boolean
6662
+ },
6663
+ codeStyleReverse: {
6664
+ type: Boolean,
6665
+ default: true
6666
+ },
6667
+ codeStyleReverseList: {
6668
+ type: Array,
6669
+ default: ["default", "mk-cute"]
6530
6670
  }
6531
6671
  });
6532
6672
  const markedHeadingId = (text) => text;
@@ -6537,7 +6677,11 @@ const Editor = defineComponent({
6537
6677
  setup(props, context) {
6538
6678
  const {
6539
6679
  editorId,
6540
- previewOnly
6680
+ previewOnly,
6681
+ noKatex,
6682
+ noMermaid,
6683
+ noPrettier,
6684
+ noUploadImg
6541
6685
  } = props;
6542
6686
  const state = reactive({
6543
6687
  scrollAuto: props.scrollAuto
@@ -6550,6 +6694,7 @@ const Editor = defineComponent({
6550
6694
  onBeforeUnmount(() => {
6551
6695
  bus.clear(editorId);
6552
6696
  });
6697
+ useExpose(props, context, catalogVisible, setting, updateSetting);
6553
6698
  return () => {
6554
6699
  var _a;
6555
6700
  const defToolbars = getSlot({
@@ -6562,17 +6707,17 @@ const Editor = defineComponent({
6562
6707
  }, "defFooters");
6563
6708
  return createVNode("div", {
6564
6709
  "id": editorId,
6565
- "class": [prefix, props.class, props.theme === "dark" && `${prefix}-dark`, setting.fullscreen || setting.pageFullScreen ? `${prefix}-fullscreen` : "", previewOnly && `${prefix}-previewOnly`],
6710
+ "class": [prefix, props.class, props.theme === "dark" && `${prefix}-dark`, setting.fullscreen || setting.pageFullscreen ? `${prefix}-fullscreen` : "", previewOnly && `${prefix}-previewOnly`],
6566
6711
  "style": props.style
6567
6712
  }, [!previewOnly && createVNode(ToolBar, {
6568
- "noPrettier": props.noPrettier,
6713
+ "noPrettier": noPrettier,
6569
6714
  "toolbars": props.toolbars,
6570
6715
  "toolbarsExclude": props.toolbarsExclude,
6571
6716
  "setting": setting,
6572
6717
  "updateSetting": updateSetting,
6573
6718
  "tableShape": props.tableShape,
6574
6719
  "defToolbars": defToolbars,
6575
- "noUploadImg": props.noUploadImg
6720
+ "noUploadImg": noUploadImg
6576
6721
  }, null), createVNode(Content, {
6577
6722
  "value": props.modelValue,
6578
6723
  "onChange": (value) => {
@@ -6600,10 +6745,10 @@ const Editor = defineComponent({
6600
6745
  }
6601
6746
  },
6602
6747
  "markedHeadingId": props.markedHeadingId,
6603
- "noMermaid": props.noMermaid,
6748
+ "noMermaid": noMermaid,
6604
6749
  "sanitize": props.sanitize,
6605
6750
  "placeholder": props.placeholder,
6606
- "noKatex": props.noKatex,
6751
+ "noKatex": noKatex,
6607
6752
  "scrollAuto": state.scrollAuto,
6608
6753
  "formatCopiedText": props.formatCopiedText
6609
6754
  }, null), !previewOnly && ((_a = props.footers) == null ? void 0 : _a.length) > 0 && createVNode(Footer, {