md-editor-v3 2.4.1 → 2.5.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,9 +17,9 @@ var __spreadValues = (a, b) => {
17
17
  return a;
18
18
  };
19
19
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
- import { onMounted, onBeforeUnmount, provide, computed, reactive, watch, ref, defineComponent, createVNode, cloneVNode, nextTick, inject, Fragment, toRef, isVNode } from "vue";
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
24
  const highlightUrl = `${cdnBase}/highlight.js/11.5.1/highlight.min.js`;
25
25
  const prettierUrl = {
@@ -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: {
@@ -292,7 +294,7 @@ class Bus {
292
294
  const targetRace = this.pools[race];
293
295
  const events = targetRace && this.pools[race][name];
294
296
  if (events) {
295
- this.pools[race][name] = events.filter((item) => item === func);
297
+ this.pools[race][name] = events.filter((item) => item !== func);
296
298
  }
297
299
  }
298
300
  clear(race) {
@@ -560,11 +562,23 @@ 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
- const { editorId, noPrettier } = props;
574
+ const { editorId, noPrettier, previewOnly } = props;
575
+ const state = reactive({
576
+ buildFinished: false,
577
+ html: ""
578
+ });
565
579
  const initFunc = (name) => {
566
580
  var _a, _b;
567
- 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));
568
582
  };
569
583
  const keyDownHandler = (event) => {
570
584
  if (event.target !== document.querySelector(`#${props.editorId}-textarea`)) {
@@ -580,7 +594,7 @@ const useKeyBoard = (props, context) => {
580
594
  }
581
595
  } else {
582
596
  if (initFunc("save")) {
583
- bus.emit(editorId, "onSave", props.modelValue);
597
+ bus.emit(editorId, ON_SAVE, props.modelValue);
584
598
  event.preventDefault();
585
599
  }
586
600
  }
@@ -764,7 +778,7 @@ const useKeyBoard = (props, context) => {
764
778
  }
765
779
  case "KeyF": {
766
780
  if (event.shiftKey) {
767
- if (initFunc("prettier")) {
781
+ if (initFunc("prettier") && !noPrettier) {
768
782
  bus.emit(editorId, "replace", "prettier");
769
783
  event.preventDefault();
770
784
  }
@@ -800,43 +814,68 @@ const useKeyBoard = (props, context) => {
800
814
  }
801
815
  }
802
816
  };
817
+ watch(() => props.modelValue, () => {
818
+ state.buildFinished = false;
819
+ });
803
820
  onMounted(() => {
804
- if (!props.previewOnly) {
821
+ if (!previewOnly) {
805
822
  window.addEventListener("keydown", keyDownHandler);
806
823
  bus.on(editorId, {
807
- name: "onSave",
824
+ name: "buildFinished",
825
+ callback(html) {
826
+ state.buildFinished = true;
827
+ state.html = html;
828
+ }
829
+ });
830
+ bus.on(editorId, {
831
+ name: ON_SAVE,
808
832
  callback() {
833
+ const htmlPromise = new Promise((rev) => {
834
+ if (state.buildFinished) {
835
+ rev(state.html);
836
+ } else {
837
+ const buildFinishedCallback = (html) => {
838
+ rev(html);
839
+ bus.remove(editorId, "buildFinished", buildFinishedCallback);
840
+ };
841
+ bus.on(editorId, {
842
+ name: "buildFinished",
843
+ callback: buildFinishedCallback
844
+ });
845
+ }
846
+ });
809
847
  if (props.onSave) {
810
- props.onSave(props.modelValue);
848
+ props.onSave(props.modelValue, htmlPromise);
811
849
  } else {
812
- context.emit("onSave", props.modelValue);
850
+ context.emit("onSave", props.modelValue, htmlPromise);
813
851
  }
814
852
  }
815
853
  });
816
854
  }
817
855
  });
818
856
  onBeforeUnmount(() => {
819
- if (!props.previewOnly) {
857
+ if (!previewOnly) {
820
858
  window.removeEventListener("keydown", keyDownHandler);
821
859
  }
822
860
  });
823
861
  };
824
862
  const useProvide = (props) => {
825
863
  var _a;
826
- const { editorId } = props;
864
+ const { editorId, previewOnly } = props;
827
865
  const highlightConfig = (_a = configOption == null ? void 0 : configOption.editorExtensions) == null ? void 0 : _a.highlight;
828
866
  provide("editorId", editorId);
829
867
  provide("tabWidth", props.tabWidth);
830
868
  provide("theme", computed(() => props.theme));
831
869
  provide("highlight", computed(() => {
832
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;
833
872
  return {
834
873
  js: (highlightConfig == null ? void 0 : highlightConfig.js) || highlightUrl,
835
- 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]
836
875
  };
837
876
  }));
838
877
  provide("historyLength", props.historyLength);
839
- provide("previewOnly", props.previewOnly);
878
+ provide("previewOnly", previewOnly);
840
879
  provide("showCodeRowNumber", props.showCodeRowNumber);
841
880
  const usedLanguageText = computed(() => {
842
881
  var _a2;
@@ -852,11 +891,11 @@ const useProvide = (props) => {
852
891
  };
853
892
  const useExpansion = (props) => {
854
893
  var _a, _b, _c, _d, _e, _f;
855
- const { noPrettier, previewOnly, noIconfont } = props;
894
+ const { noPrettier, previewOnly, noIconfont, noUploadImg } = props;
856
895
  const { editorExtensions } = configOption;
857
896
  const noPrettierScript = noPrettier || !!((_b = (_a = configOption.editorExtensions) == null ? void 0 : _a.prettier) == null ? void 0 : _b.prettierInstance);
858
897
  const noParserMarkdownScript = noPrettier || !!((_d = (_c = configOption.editorExtensions) == null ? void 0 : _c.prettier) == null ? void 0 : _d.parserMarkdownInstance);
859
- 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);
860
899
  onMounted(() => {
861
900
  var _a2, _b2, _c2, _d2;
862
901
  const iconfontScript = document.createElement("script");
@@ -893,15 +932,15 @@ const useExpansion = (props) => {
893
932
  });
894
933
  };
895
934
  const useConfig = (props, context) => {
896
- const { editorId } = props;
935
+ const { editorId, previewOnly } = props;
897
936
  const setting = reactive({
898
- pageFullScreen: props.pageFullScreen,
937
+ pageFullscreen: props.pageFullscreen,
899
938
  fullscreen: false,
900
939
  preview: props.preview,
901
940
  htmlPreview: props.preview ? false : props.htmlPreview
902
941
  });
903
942
  const updateSetting = (v, k) => {
904
- setting[k] = v;
943
+ setting[k] = v === void 0 ? !setting[k] : v;
905
944
  if (k === "preview" && setting.preview) {
906
945
  setting.htmlPreview = false;
907
946
  } else if (k === "htmlPreview" && setting.htmlPreview) {
@@ -910,15 +949,15 @@ const useConfig = (props, context) => {
910
949
  };
911
950
  let bodyOverflowHistory = "";
912
951
  const adjustBody = () => {
913
- if (setting.pageFullScreen || setting.fullscreen) {
952
+ if (setting.pageFullscreen || setting.fullscreen) {
914
953
  document.body.style.overflow = "hidden";
915
954
  } else {
916
955
  document.body.style.overflow = bodyOverflowHistory;
917
956
  }
918
957
  };
919
- watch(() => [setting.pageFullScreen, setting.fullscreen], adjustBody);
958
+ watch(() => [setting.pageFullscreen, setting.fullscreen], adjustBody);
920
959
  onMounted(() => {
921
- if (!props.previewOnly) {
960
+ if (!previewOnly) {
922
961
  bus.on(editorId, {
923
962
  name: "uploadImage",
924
963
  callback(files, cb) {
@@ -947,9 +986,13 @@ const useCatalog = (props) => {
947
986
  const catalogVisible = ref(false);
948
987
  onMounted(() => {
949
988
  bus.on(editorId, {
950
- name: "catalogShow",
951
- callback: () => {
952
- 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
+ }
953
996
  }
954
997
  });
955
998
  });
@@ -958,6 +1001,97 @@ const useCatalog = (props) => {
958
1001
  });
959
1002
  return [catalogVisible, catalogShow];
960
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(status, "pageFullscreen");
1073
+ },
1074
+ toggleFullscreen(status) {
1075
+ bus.emit(editorId, CHANGE_FULL_SCREEN, status);
1076
+ },
1077
+ togglePreview(status) {
1078
+ updateSetting(status, "preview");
1079
+ },
1080
+ toggleHtmlPreview(status) {
1081
+ updateSetting(status, "htmlPreview");
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
+ };
961
1095
  var index$1 = "";
962
1096
  var Divider = defineComponent({
963
1097
  setup() {
@@ -1139,6 +1273,9 @@ const modalProps = () => ({
1139
1273
  type: Function,
1140
1274
  default: () => () => {
1141
1275
  }
1276
+ },
1277
+ class: {
1278
+ type: String
1142
1279
  }
1143
1280
  });
1144
1281
  var Modal = defineComponent({
@@ -1224,6 +1361,7 @@ var Modal = defineComponent({
1224
1361
  ctx
1225
1362
  }, "title");
1226
1363
  return createVNode("div", {
1364
+ "class": [props.class],
1227
1365
  "style": {
1228
1366
  display: modalVisible.value ? "block" : "none"
1229
1367
  }
@@ -1302,13 +1440,13 @@ var LinkModal = defineComponent({
1302
1440
  const ult = inject("usedLanguageText");
1303
1441
  const editorId = inject("editorId");
1304
1442
  const title = computed(() => {
1305
- var _a, _b, _c, _d;
1443
+ var _a, _b;
1306
1444
  switch (props.type) {
1307
1445
  case "link": {
1308
- 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;
1309
1447
  }
1310
1448
  case "image": {
1311
- 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;
1312
1450
  }
1313
1451
  default: {
1314
1452
  return "";
@@ -1337,10 +1475,10 @@ var LinkModal = defineComponent({
1337
1475
  return [createVNode("div", {
1338
1476
  "class": `${prefix}-form-item`
1339
1477
  }, [createVNode("label", {
1340
- "class": `${prefix}-lable`,
1478
+ "class": `${prefix}-label`,
1341
1479
  "for": `link-desc-${editorId}`
1342
- }, [(_a = ult.value.linkModalTips) == null ? void 0 : _a.descLable]), createVNode("input", {
1343
- "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,
1344
1482
  "class": `${prefix}-input`,
1345
1483
  "id": `link-desc-${editorId}`,
1346
1484
  "type": "text",
@@ -1352,10 +1490,10 @@ var LinkModal = defineComponent({
1352
1490
  }, null)]), createVNode("div", {
1353
1491
  "class": `${prefix}-form-item`
1354
1492
  }, [createVNode("label", {
1355
- "class": `${prefix}-lable`,
1493
+ "class": `${prefix}-label`,
1356
1494
  "for": `link-url-${editorId}`
1357
- }, [(_c = ult.value.linkModalTips) == null ? void 0 : _c.urlLable]), createVNode("input", {
1358
- "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,
1359
1497
  "class": `${prefix}-input`,
1360
1498
  "id": `link-url-${editorId}`,
1361
1499
  "type": "text",
@@ -1467,6 +1605,7 @@ var ClipModal = defineComponent({
1467
1605
  return () => {
1468
1606
  var _a2;
1469
1607
  return createVNode(Modal, {
1608
+ "class": `${prefix}-modal-clip`,
1470
1609
  "title": (_a2 = ult.value.clipModalTips) == null ? void 0 : _a2.title,
1471
1610
  "visible": props.visible,
1472
1611
  "onClose": props.onCancel,
@@ -1479,7 +1618,7 @@ var ClipModal = defineComponent({
1479
1618
  "height": "421px"
1480
1619
  }, {
1481
1620
  default: () => {
1482
- var _a3;
1621
+ var _a3, _b2;
1483
1622
  return [createVNode("div", {
1484
1623
  "class": `${prefix}-form-item ${prefix}-clip`
1485
1624
  }, [createVNode("div", {
@@ -1527,7 +1666,7 @@ var ClipModal = defineComponent({
1527
1666
  reset();
1528
1667
  }
1529
1668
  }
1530
- }, [(_a3 = ult.value.linkModalTips) == null ? void 0 : _a3.buttonOK])]), createVNode("input", {
1669
+ }, [((_a3 = ult.value.clipModalTips) == null ? void 0 : _a3.buttonUpload) || ((_b2 = ult.value.linkModalTips) == null ? void 0 : _b2.buttonOK)])]), createVNode("input", {
1531
1670
  "ref": uploadRef,
1532
1671
  "accept": "image/*",
1533
1672
  "type": "file",
@@ -1587,20 +1726,21 @@ const useSreenfull = (props) => {
1587
1726
  let screenfull = (_b = (_a = configOption.editorExtensions) == null ? void 0 : _a.screenfull) == null ? void 0 : _b.instance;
1588
1727
  const screenfullJs = (_d = (_c = configOption.editorExtensions) == null ? void 0 : _c.screenfull) == null ? void 0 : _d.js;
1589
1728
  const screenfullMe = ref(false);
1590
- const fullScreenHandler = () => {
1729
+ const fullscreenHandler = (status) => {
1591
1730
  if (!screenfull) {
1592
1731
  bus.emit(editorId, "errorCatcher", {
1593
- name: "fullScreen",
1594
- message: "fullScreen is undefined"
1732
+ name: "fullscreen",
1733
+ message: "fullscreen is undefined"
1595
1734
  });
1596
1735
  return;
1597
1736
  }
1598
1737
  if (screenfull.isEnabled) {
1599
1738
  screenfullMe.value = true;
1600
- if (screenfull.isFullscreen) {
1601
- screenfull.exit();
1602
- } else {
1739
+ const targetStatus = status === void 0 ? !screenfull.isFullscreen : !!status;
1740
+ if (targetStatus) {
1603
1741
  screenfull.request();
1742
+ } else {
1743
+ screenfull.exit();
1604
1744
  }
1605
1745
  } else {
1606
1746
  console.error("browser does not support screenfull!");
@@ -1630,7 +1770,15 @@ const useSreenfull = (props) => {
1630
1770
  appendHandler(screenScript, "screenfull");
1631
1771
  }
1632
1772
  });
1633
- 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 };
1634
1782
  };
1635
1783
  const tableShapeProps = () => ({
1636
1784
  tableShape: {
@@ -1722,7 +1870,7 @@ var ToolBar = defineComponent({
1722
1870
  const editorId = inject("editorId");
1723
1871
  const ult = inject("usedLanguageText");
1724
1872
  const {
1725
- fullScreenHandler
1873
+ fullscreenHandler
1726
1874
  } = useSreenfull(props);
1727
1875
  const wrapperId = `${editorId}-toolbar-wrapper`;
1728
1876
  const visible = reactive({
@@ -2134,7 +2282,7 @@ var ToolBar = defineComponent({
2134
2282
  "class": `${prefix}-toolbar-item`,
2135
2283
  "title": (_z = ult.value.toolbarTips) == null ? void 0 : _z.save,
2136
2284
  "onClick": () => {
2137
- bus.emit(editorId, "onSave");
2285
+ bus.emit(editorId, ON_SAVE);
2138
2286
  }
2139
2287
  }, [createVNode("svg", {
2140
2288
  "class": `${prefix}-icon`,
@@ -2162,25 +2310,27 @@ var ToolBar = defineComponent({
2162
2310
  "class": `${prefix}-toolbar-item`,
2163
2311
  "title": (_B = ult.value.toolbarTips) == null ? void 0 : _B.pageFullscreen,
2164
2312
  "onClick": () => {
2165
- props.updateSetting(!props.setting.pageFullScreen, "pageFullScreen");
2313
+ props.updateSetting(!props.setting.pageFullscreen, "pageFullscreen");
2166
2314
  }
2167
2315
  }, [createVNode("svg", {
2168
2316
  "class": `${prefix}-icon`,
2169
2317
  "aria-hidden": "true"
2170
2318
  }, [createVNode("use", {
2171
- "xlink:href": `#md-editor-icon-${props.setting.pageFullScreen ? "suoxiao" : "fangda"}`
2319
+ "xlink:href": `#md-editor-icon-${props.setting.pageFullscreen ? "suoxiao" : "fangda"}`
2172
2320
  }, null)])]);
2173
2321
  }
2174
2322
  case "fullscreen": {
2175
2323
  return createVNode("div", {
2176
2324
  "class": `${prefix}-toolbar-item`,
2177
2325
  "title": (_C = ult.value.toolbarTips) == null ? void 0 : _C.fullscreen,
2178
- "onClick": fullScreenHandler
2326
+ "onClick": () => {
2327
+ fullscreenHandler();
2328
+ }
2179
2329
  }, [createVNode("svg", {
2180
2330
  "class": `${prefix}-icon`,
2181
2331
  "aria-hidden": "true"
2182
2332
  }, [createVNode("use", {
2183
- "xlink:href": `#md-editor-icon-${props.setting.fullscreen ? "fullScreen-exit" : "fullScreen"}`
2333
+ "xlink:href": `#md-editor-icon-${props.setting.fullscreen ? "fullscreen-exit" : "fullscreen"}`
2184
2334
  }, null)])]);
2185
2335
  }
2186
2336
  case "preview": {
@@ -2216,7 +2366,7 @@ var ToolBar = defineComponent({
2216
2366
  "class": `${prefix}-toolbar-item`,
2217
2367
  "title": (_F = ult.value.toolbarTips) == null ? void 0 : _F.catalog,
2218
2368
  "onClick": () => {
2219
- bus.emit(editorId, "catalogShow");
2369
+ bus.emit(editorId, CHANGE_CATALOG_VISIBLE);
2220
2370
  },
2221
2371
  "key": "bar-catalog"
2222
2372
  }, [createVNode("svg", {
@@ -2364,10 +2514,7 @@ var ToolBar = defineComponent({
2364
2514
  "class": `${prefix}-toolbar-wrapper`,
2365
2515
  "id": wrapperId
2366
2516
  }, [createVNode("div", {
2367
- "class": `${prefix}-toolbar`,
2368
- "onMouseenter": () => {
2369
- bus.emit(editorId, "selectTextChange");
2370
- }
2517
+ "class": `${prefix}-toolbar`
2371
2518
  }, [createVNode("div", {
2372
2519
  "class": `${prefix}-toolbar-left`,
2373
2520
  "ref": toolbarLeftRef
@@ -5309,6 +5456,14 @@ ${(mermaidTemplate == null ? void 0 : mermaidTemplate.journey) || "journey\n ti
5309
5456
  deviationEnd = -4;
5310
5457
  break;
5311
5458
  }
5459
+ case "universal": {
5460
+ const { generate } = params;
5461
+ const insertOptions = generate(selectedText);
5462
+ targetValue = insertOptions.targetValue;
5463
+ select = insertOptions.select;
5464
+ deviationStart = insertOptions.deviationStart;
5465
+ deviationEnd = insertOptions.deviationEnd;
5466
+ }
5312
5467
  }
5313
5468
  }
5314
5469
  return insert(inputArea, targetValue, {
@@ -5607,6 +5762,7 @@ const useMarked = (props, mermaidData) => {
5607
5762
  heads.value = [];
5608
5763
  const _html = props.sanitize(marked(props.value || "", { renderer }));
5609
5764
  html.value = _html;
5765
+ bus.emit(editorId, "buildFinished", _html);
5610
5766
  props.onHtmlChanged(_html);
5611
5767
  }, (editorConfig == null ? void 0 : editorConfig.renderDelay) !== void 0 ? editorConfig == null ? void 0 : editorConfig.renderDelay : previewOnly ? 0 : 500);
5612
5768
  watch([
@@ -5873,7 +6029,7 @@ const usePasteUpload = (textAreaRef) => {
5873
6029
  }
5874
6030
  });
5875
6031
  };
5876
- const userZoom = (html) => {
6032
+ const userZoom = (props, html) => {
5877
6033
  const editorId = inject("editorId");
5878
6034
  const zoomHander = debounce(() => {
5879
6035
  const imgs = document.querySelectorAll(`#${editorId}-preview img[zoom]`);
@@ -5885,7 +6041,7 @@ const userZoom = (html) => {
5885
6041
  });
5886
6042
  });
5887
6043
  onMounted(zoomHander);
5888
- watch([html], zoomHander);
6044
+ watch([html, toRef(props.setting, "preview")], zoomHander);
5889
6045
  };
5890
6046
  const contentProps = () => ({
5891
6047
  value: {
@@ -5959,7 +6115,7 @@ var Content = defineComponent({
5959
6115
  useAutoGenrator(props, textAreaRef);
5960
6116
  useHistory(props, textAreaRef, completeStatus);
5961
6117
  usePasteUpload(textAreaRef);
5962
- userZoom(html);
6118
+ userZoom(props, html);
5963
6119
  return () => {
5964
6120
  return createVNode(Fragment, null, [createVNode("div", {
5965
6121
  "class": `${prefix}-content`
@@ -5969,6 +6125,9 @@ var Content = defineComponent({
5969
6125
  "id": `${editorId}-textarea`,
5970
6126
  "ref": textAreaRef,
5971
6127
  "value": props.value,
6128
+ "onBlur": () => {
6129
+ bus.emit(editorId, "selectTextChange");
6130
+ },
5972
6131
  "onKeydown": () => {
5973
6132
  bus.emit(editorId, "saveHistoryPos", true);
5974
6133
  },
@@ -6381,7 +6540,7 @@ const editorProps = () => ({
6381
6540
  onUploadImg: {
6382
6541
  type: Function
6383
6542
  },
6384
- pageFullScreen: {
6543
+ pageFullscreen: {
6385
6544
  type: Boolean,
6386
6545
  default: false
6387
6546
  },
@@ -6493,6 +6652,14 @@ const editorProps = () => ({
6493
6652
  },
6494
6653
  noUploadImg: {
6495
6654
  type: Boolean
6655
+ },
6656
+ codeStyleReverse: {
6657
+ type: Boolean,
6658
+ default: true
6659
+ },
6660
+ codeStyleReverseList: {
6661
+ type: Array,
6662
+ default: ["default", "mk-cute"]
6496
6663
  }
6497
6664
  });
6498
6665
  const markedHeadingId = (text) => text;
@@ -6502,7 +6669,12 @@ const Editor = defineComponent({
6502
6669
  emits: ["onChange", "onSave", "onUploadImg", "onHtmlChanged", "onGetCatalog", "onError", "update:modelValue"],
6503
6670
  setup(props, context) {
6504
6671
  const {
6505
- editorId
6672
+ editorId,
6673
+ previewOnly,
6674
+ noKatex,
6675
+ noMermaid,
6676
+ noPrettier,
6677
+ noUploadImg
6506
6678
  } = props;
6507
6679
  const state = reactive({
6508
6680
  scrollAuto: props.scrollAuto
@@ -6515,6 +6687,7 @@ const Editor = defineComponent({
6515
6687
  onBeforeUnmount(() => {
6516
6688
  bus.clear(editorId);
6517
6689
  });
6690
+ useExpose(props, context, catalogVisible, setting, updateSetting);
6518
6691
  return () => {
6519
6692
  var _a;
6520
6693
  const defToolbars = getSlot({
@@ -6527,17 +6700,17 @@ const Editor = defineComponent({
6527
6700
  }, "defFooters");
6528
6701
  return createVNode("div", {
6529
6702
  "id": editorId,
6530
- "class": [prefix, props.class, props.theme === "dark" && `${prefix}-dark`, setting.fullscreen || setting.pageFullScreen ? `${prefix}-fullscreen` : "", props.previewOnly && `${prefix}-previewOnly`],
6703
+ "class": [prefix, props.class, props.theme === "dark" && `${prefix}-dark`, setting.fullscreen || setting.pageFullscreen ? `${prefix}-fullscreen` : "", previewOnly && `${prefix}-previewOnly`],
6531
6704
  "style": props.style
6532
- }, [!props.previewOnly && createVNode(ToolBar, {
6533
- "noPrettier": props.noPrettier,
6705
+ }, [!previewOnly && createVNode(ToolBar, {
6706
+ "noPrettier": noPrettier,
6534
6707
  "toolbars": props.toolbars,
6535
6708
  "toolbarsExclude": props.toolbarsExclude,
6536
6709
  "setting": setting,
6537
6710
  "updateSetting": updateSetting,
6538
6711
  "tableShape": props.tableShape,
6539
6712
  "defToolbars": defToolbars,
6540
- "noUploadImg": props.noUploadImg
6713
+ "noUploadImg": noUploadImg
6541
6714
  }, null), createVNode(Content, {
6542
6715
  "value": props.modelValue,
6543
6716
  "onChange": (value) => {
@@ -6565,19 +6738,19 @@ const Editor = defineComponent({
6565
6738
  }
6566
6739
  },
6567
6740
  "markedHeadingId": props.markedHeadingId,
6568
- "noMermaid": props.noMermaid,
6741
+ "noMermaid": noMermaid,
6569
6742
  "sanitize": props.sanitize,
6570
6743
  "placeholder": props.placeholder,
6571
- "noKatex": props.noKatex,
6744
+ "noKatex": noKatex,
6572
6745
  "scrollAuto": state.scrollAuto,
6573
6746
  "formatCopiedText": props.formatCopiedText
6574
- }, null), !props.previewOnly && ((_a = props.footers) == null ? void 0 : _a.length) > 0 && createVNode(Footer, {
6747
+ }, null), !previewOnly && ((_a = props.footers) == null ? void 0 : _a.length) > 0 && createVNode(Footer, {
6575
6748
  "modelValue": props.modelValue,
6576
6749
  "footers": props.footers,
6577
6750
  "defFooters": defFooters,
6578
6751
  "scrollAuto": state.scrollAuto,
6579
6752
  "onScrollAutoChange": (v) => state.scrollAuto = v
6580
- }, null), catalogShow.value && !props.previewOnly && createVNode(MdCatalog, {
6753
+ }, null), catalogShow.value && !previewOnly && createVNode(MdCatalog, {
6581
6754
  "theme": props.theme,
6582
6755
  "style": {
6583
6756
  display: catalogVisible.value ? "block" : "none"