md-editor-v3 4.12.4 → 4.13.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.
package/README.md CHANGED
@@ -151,6 +151,7 @@ Except for the same as `MdPreview`:
151
151
  | completions | `Array<CompletionSource>` | [] | `@codemirror/autocomplete` List of function to match keywords |
152
152
  | showToolbarName | `boolean` | false | Show toolbar name or not |
153
153
  | inputBoxWitdh | `string` | '50%' | Default width of input box |
154
+ | transformImgUrl | `(imgUrl: string) => string` | t => t | Transform image links |
154
155
 
155
156
  <details>
156
157
  <summary>『toolbars』</summary>
@@ -185,6 +186,7 @@ Except for the same as `MdPreview`:
185
186
  'pageFullscreen',
186
187
  'fullscreen',
187
188
  'preview',
189
+ 'previewOnly',
188
190
  'htmlPreview',
189
191
  'catalog',
190
192
  'github'
@@ -230,6 +232,7 @@ export interface ToolbarTips {
230
232
  fullscreen?: string;
231
233
  catalog?: string;
232
234
  preview?: string;
235
+ previewOnly?: string;
233
236
  htmlPreview?: string;
234
237
  github?: string;
235
238
  '-'?: string;
@@ -403,6 +406,12 @@ Get the internal state of the editor, including pageFullscreen, fullscreen, prev
403
406
  editorRef.value?.on('preview', (status) => console.log(status));
404
407
  ```
405
408
 
409
+ - previewOnly
410
+
411
+ ```js
412
+ editorRef.value?.on('previewOnly', (status) => console.log(status));
413
+ ```
414
+
406
415
  - htmlPreview
407
416
 
408
417
  ```js
@@ -439,6 +448,14 @@ Toggle status of preview.
439
448
  editorRef.value?.togglePreview(true);
440
449
  ```
441
450
 
451
+ ### 📖 togglePreviewOnly
452
+
453
+ Toggle into Preview Only Mode.
454
+
455
+ ```js
456
+ editorRef.value?.togglePreviewOnly(true);
457
+ ```
458
+
442
459
  ### 📼 toggleHtmlPreview
443
460
 
444
461
  Toggle status of htmlPreview.
@@ -532,6 +549,14 @@ editorRef.value?.domEventHandlers({
532
549
  });
533
550
  ```
534
551
 
552
+ ### 🎛 execCommand
553
+
554
+ Insert content into the editor via trigger.
555
+
556
+ ```js
557
+ editorRef.value?.execCommand('bold');
558
+ ```
559
+
535
560
  ## 💴 Config Editor
536
561
 
537
562
  Use `config(option: ConfigOption)` to reconfigure `markdown-it` and so on.
@@ -21,6 +21,7 @@ const commands = require("@codemirror/commands");
21
21
  const language = require("@codemirror/language");
22
22
  const highlight = require("@lezer/highlight");
23
23
  const autocomplete = require("@codemirror/autocomplete");
24
+ const search = require("@codemirror/search");
24
25
  const MdPreview = require("./chunks/index.cjs");
25
26
  const MdCatalog = require("./MdCatalog.cjs");
26
27
  const vueTsx = require("./chunks/vue-tsx.cjs");
@@ -545,7 +546,7 @@ const ToolBar = /* @__PURE__ */ vue.defineComponent({
545
546
  uploadRef.value.addEventListener("change", uploadHandler);
546
547
  });
547
548
  const barRender = (barItem) => {
548
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca, _da, _ea, _fa, _ga, _ha, _ia, _ja, _ka, _la, _ma;
549
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca, _da, _ea, _fa, _ga, _ha, _ia, _ja, _ka, _la, _ma, _na, _oa;
549
550
  if (config.allToolbar.includes(barItem)) {
550
551
  switch (barItem) {
551
552
  case "-": {
@@ -953,10 +954,23 @@ const ToolBar = /* @__PURE__ */ vue.defineComponent({
953
954
  "class": `${config.prefix}-toolbar-item-name`
954
955
  }, [(_Y = ult.value.toolbarTips) == null ? void 0 : _Y.preview])]);
955
956
  }
957
+ case "previewOnly": {
958
+ return vue.createVNode("div", {
959
+ "class": `${config.prefix}-toolbar-item`,
960
+ "title": (_Z = ult.value.toolbarTips) == null ? void 0 : _Z.previewOnly,
961
+ "onClick": () => {
962
+ props2.updateSetting("previewOnly");
963
+ }
964
+ }, [vue.createVNode(MdModal.Icon, {
965
+ "name": "preview-only"
966
+ }, null), props2.showToolbarName && vue.createVNode("div", {
967
+ "class": `${config.prefix}-toolbar-item-name`
968
+ }, [(__ = ult.value.toolbarTips) == null ? void 0 : __.previewOnly])]);
969
+ }
956
970
  case "htmlPreview": {
957
971
  return vue.createVNode("div", {
958
972
  "class": `${config.prefix}-toolbar-item`,
959
- "title": (_Z = ult.value.toolbarTips) == null ? void 0 : _Z.htmlPreview,
973
+ "title": (_$ = ult.value.toolbarTips) == null ? void 0 : _$.htmlPreview,
960
974
  "onClick": () => {
961
975
  props2.updateSetting("htmlPreview");
962
976
  }
@@ -964,12 +978,12 @@ const ToolBar = /* @__PURE__ */ vue.defineComponent({
964
978
  "name": "coding"
965
979
  }, null), props2.showToolbarName && vue.createVNode("div", {
966
980
  "class": `${config.prefix}-toolbar-item-name`
967
- }, [(__ = ult.value.toolbarTips) == null ? void 0 : __.htmlPreview])]);
981
+ }, [(_aa = ult.value.toolbarTips) == null ? void 0 : _aa.htmlPreview])]);
968
982
  }
969
983
  case "catalog": {
970
984
  return vue.createVNode("div", {
971
985
  "class": `${config.prefix}-toolbar-item`,
972
- "title": (_$ = ult.value.toolbarTips) == null ? void 0 : _$.catalog,
986
+ "title": (_ba = ult.value.toolbarTips) == null ? void 0 : _ba.catalog,
973
987
  "onClick": () => {
974
988
  index.bus.emit(editorId, index.CHANGE_CATALOG_VISIBLE);
975
989
  },
@@ -978,18 +992,18 @@ const ToolBar = /* @__PURE__ */ vue.defineComponent({
978
992
  "name": "catalog"
979
993
  }, null), props2.showToolbarName && vue.createVNode("div", {
980
994
  "class": `${config.prefix}-toolbar-item-name`
981
- }, [(_aa = ult.value.toolbarTips) == null ? void 0 : _aa.catalog])]);
995
+ }, [(_ca = ult.value.toolbarTips) == null ? void 0 : _ca.catalog])]);
982
996
  }
983
997
  case "github": {
984
998
  return vue.createVNode("div", {
985
999
  "class": `${config.prefix}-toolbar-item`,
986
- "title": (_ba = ult.value.toolbarTips) == null ? void 0 : _ba.github,
1000
+ "title": (_da = ult.value.toolbarTips) == null ? void 0 : _da.github,
987
1001
  "onClick": () => util.linkTo("https://github.com/imzbf/md-editor-v3")
988
1002
  }, [vue.createVNode(MdModal.Icon, {
989
1003
  "name": "github"
990
1004
  }, null), props2.showToolbarName && vue.createVNode("div", {
991
1005
  "class": `${config.prefix}-toolbar-item-name`
992
- }, [(_ca = ult.value.toolbarTips) == null ? void 0 : _ca.github])]);
1006
+ }, [(_ea = ult.value.toolbarTips) == null ? void 0 : _ea.github])]);
993
1007
  }
994
1008
  case "mermaid": {
995
1009
  return vue.createVNode(DropdownToolbar.Dropdown, {
@@ -1008,42 +1022,42 @@ const ToolBar = /* @__PURE__ */ vue.defineComponent({
1008
1022
  "onClick": () => {
1009
1023
  emitHandler("flow");
1010
1024
  }
1011
- }, [(_da = ult.value.mermaid) == null ? void 0 : _da.flow]), vue.createVNode("li", {
1025
+ }, [(_fa = ult.value.mermaid) == null ? void 0 : _fa.flow]), vue.createVNode("li", {
1012
1026
  "class": `${config.prefix}-menu-item ${config.prefix}-menu-item-mermaid`,
1013
1027
  "onClick": () => {
1014
1028
  emitHandler("sequence");
1015
1029
  }
1016
- }, [(_ea = ult.value.mermaid) == null ? void 0 : _ea.sequence]), vue.createVNode("li", {
1030
+ }, [(_ga = ult.value.mermaid) == null ? void 0 : _ga.sequence]), vue.createVNode("li", {
1017
1031
  "class": `${config.prefix}-menu-item ${config.prefix}-menu-item-mermaid`,
1018
1032
  "onClick": () => {
1019
1033
  emitHandler("gantt");
1020
1034
  }
1021
- }, [(_fa = ult.value.mermaid) == null ? void 0 : _fa.gantt]), vue.createVNode("li", {
1035
+ }, [(_ha = ult.value.mermaid) == null ? void 0 : _ha.gantt]), vue.createVNode("li", {
1022
1036
  "class": `${config.prefix}-menu-item ${config.prefix}-menu-item-mermaid`,
1023
1037
  "onClick": () => {
1024
1038
  emitHandler("class");
1025
1039
  }
1026
- }, [(_ga = ult.value.mermaid) == null ? void 0 : _ga.class]), vue.createVNode("li", {
1040
+ }, [(_ia = ult.value.mermaid) == null ? void 0 : _ia.class]), vue.createVNode("li", {
1027
1041
  "class": `${config.prefix}-menu-item ${config.prefix}-menu-item-mermaid`,
1028
1042
  "onClick": () => {
1029
1043
  emitHandler("state");
1030
1044
  }
1031
- }, [(_ha = ult.value.mermaid) == null ? void 0 : _ha.state]), vue.createVNode("li", {
1045
+ }, [(_ja = ult.value.mermaid) == null ? void 0 : _ja.state]), vue.createVNode("li", {
1032
1046
  "class": `${config.prefix}-menu-item ${config.prefix}-menu-item-mermaid`,
1033
1047
  "onClick": () => {
1034
1048
  emitHandler("pie");
1035
1049
  }
1036
- }, [(_ia = ult.value.mermaid) == null ? void 0 : _ia.pie]), vue.createVNode("li", {
1050
+ }, [(_ka = ult.value.mermaid) == null ? void 0 : _ka.pie]), vue.createVNode("li", {
1037
1051
  "class": `${config.prefix}-menu-item ${config.prefix}-menu-item-mermaid`,
1038
1052
  "onClick": () => {
1039
1053
  emitHandler("relationship");
1040
1054
  }
1041
- }, [(_ja = ult.value.mermaid) == null ? void 0 : _ja.relationship]), vue.createVNode("li", {
1055
+ }, [(_la = ult.value.mermaid) == null ? void 0 : _la.relationship]), vue.createVNode("li", {
1042
1056
  "class": `${config.prefix}-menu-item ${config.prefix}-menu-item-mermaid`,
1043
1057
  "onClick": () => {
1044
1058
  emitHandler("journey");
1045
1059
  }
1046
- }, [(_ka = ult.value.mermaid) == null ? void 0 : _ka.journey])]),
1060
+ }, [(_ma = ult.value.mermaid) == null ? void 0 : _ma.journey])]),
1047
1061
  "key": "bar-mermaid"
1048
1062
  }, {
1049
1063
  default: () => {
@@ -1076,12 +1090,12 @@ const ToolBar = /* @__PURE__ */ vue.defineComponent({
1076
1090
  "onClick": () => {
1077
1091
  emitHandler("katexInline");
1078
1092
  }
1079
- }, [(_la = ult.value.katex) == null ? void 0 : _la.inline]), vue.createVNode("li", {
1093
+ }, [(_na = ult.value.katex) == null ? void 0 : _na.inline]), vue.createVNode("li", {
1080
1094
  "class": `${config.prefix}-menu-item ${config.prefix}-menu-item-katex`,
1081
1095
  "onClick": () => {
1082
1096
  emitHandler("katexBlock");
1083
1097
  }
1084
- }, [(_ma = ult.value.katex) == null ? void 0 : _ma.block])]),
1098
+ }, [(_oa = ult.value.katex) == null ? void 0 : _oa.block])]),
1085
1099
  "key": "bar-katex"
1086
1100
  }, {
1087
1101
  default: () => {
@@ -1451,9 +1465,9 @@ const useAutoScroll = (props2, html, codeMirrorUt) => {
1451
1465
  cEle,
1452
1466
  codeMirrorUt.value
1453
1467
  );
1454
- }
1455
- if (props2.scrollAuto) {
1456
- initScrollAuto();
1468
+ if (props2.scrollAuto) {
1469
+ initScrollAuto();
1470
+ }
1457
1471
  }
1458
1472
  };
1459
1473
  vue.watch(
@@ -1478,6 +1492,16 @@ const useAutoScroll = (props2, html, codeMirrorUt) => {
1478
1492
  }
1479
1493
  }
1480
1494
  );
1495
+ vue.watch(
1496
+ () => props2.setting.previewOnly,
1497
+ (po) => {
1498
+ if (po) {
1499
+ clearScrollAuto();
1500
+ } else {
1501
+ initScrollAuto();
1502
+ }
1503
+ }
1504
+ );
1481
1505
  vue.onMounted(rebindEvent);
1482
1506
  };
1483
1507
  const directive2flag = (direct, codeMirrorUt, params) => {
@@ -1756,8 +1780,8 @@ const oneDarkTheme = view.EditorView.theme(
1756
1780
  ".cm-cursor, .cm-dropCursor": { borderLeftColor: cursor$1 },
1757
1781
  "&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection": { backgroundColor: selection$1 },
1758
1782
  ".cm-panels": { backgroundColor: darkBackground$1, color: ivory$1 },
1759
- ".cm-panels.cm-panels-top": { borderBottom: "2px solid black" },
1760
- ".cm-panels.cm-panels-bottom": { borderTop: "2px solid black" },
1783
+ ".cm-panels.cm-panels-top": { borderBottom: "1px solid var(--md-border-color)" },
1784
+ ".cm-panels.cm-panels-bottom": { borderTop: "1px solid var(--md-border-color)" },
1761
1785
  ".cm-searchMatch": {
1762
1786
  backgroundColor: "#72a1ff59",
1763
1787
  outline: "1px solid #457dff"
@@ -1849,7 +1873,7 @@ const oneDark = [
1849
1873
  oneDarkTheme,
1850
1874
  language.syntaxHighlighting(oneDarkHighlightStyle)
1851
1875
  ];
1852
- const chalky = "#e5c07b", coral = "#3f4a54", cyan = "#56b6c2", invalid = "#fff", ivory = "#3f4a54", stone = "#2d8cf0", malibu = "#2d8cf0", sage = "#3f4a54", whiskey = "#d19a66", violet = "#c678dd", darkBackground = "#21252b", highlightBackground = "#ceedfa33", background = "var(--md-bk-color)", tooltipBackground = "var(--md-bk-color)", selection = "#bad5fa", cursor = "#3f4a54";
1876
+ const chalky = "#e5c07b", coral = "#3f4a54", cyan = "#56b6c2", invalid = "#fff", ivory = "#3f4a54", stone = "#2d8cf0", malibu = "#2d8cf0", sage = "#3f4a54", whiskey = "#d19a66", violet = "#c678dd", darkBackground = "#f6f6f6", highlightBackground = "#ceedfa33", background = "var(--md-bk-color)", tooltipBackground = "var(--md-bk-color)", selection = "#bad5fa", cursor = "#3f4a54";
1853
1877
  const oneLightTheme = view.EditorView.theme(
1854
1878
  {
1855
1879
  "&": {
@@ -1862,8 +1886,8 @@ const oneLightTheme = view.EditorView.theme(
1862
1886
  ".cm-cursor, .cm-dropCursor": { borderLeftColor: cursor },
1863
1887
  "&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection": { backgroundColor: selection },
1864
1888
  ".cm-panels": { backgroundColor: darkBackground, color: ivory },
1865
- ".cm-panels.cm-panels-top": { borderBottom: "2px solid black" },
1866
- ".cm-panels.cm-panels-bottom": { borderTop: "2px solid black" },
1889
+ ".cm-panels.cm-panels-top": { borderBottom: "1px solid var(--md-border-color)" },
1890
+ ".cm-panels.cm-panels-bottom": { borderTop: "1px solid var(--md-border-color)" },
1867
1891
  ".cm-searchMatch": {
1868
1892
  backgroundColor: "#72a1ff59",
1869
1893
  outline: "1px solid #457dff"
@@ -2259,9 +2283,10 @@ class CodeMirrorUt {
2259
2283
  ]);
2260
2284
  }
2261
2285
  }
2262
- const usePasteUpload = (props2) => {
2286
+ const usePasteUpload = (props2, codeMirrorUt) => {
2263
2287
  const editorId = vue.inject("editorId");
2264
2288
  const pasteHandler = (e) => {
2289
+ var _a, _b, _c;
2265
2290
  if (!e.clipboardData) {
2266
2291
  return;
2267
2292
  }
@@ -2277,6 +2302,34 @@ const usePasteUpload = (props2) => {
2277
2302
  e.preventDefault();
2278
2303
  return;
2279
2304
  }
2305
+ const targetValue = e.clipboardData.getData("text/plain");
2306
+ const to = ((_a = codeMirrorUt.value) == null ? void 0 : _a.view.state.selection.main.to) || 0;
2307
+ const from = ((_b = codeMirrorUt.value) == null ? void 0 : _b.view.state.doc.lineAt(to).from) || 0;
2308
+ const lineStart = ((_c = codeMirrorUt.value) == null ? void 0 : _c.view.state.doc.sliceString(from, to)) || "";
2309
+ const templateStart = /!\[.*\]\(\s*$/.test(lineStart);
2310
+ const templateIn = /!\[.*\]\((.*)\s?.*\)/.test(targetValue);
2311
+ if (templateStart) {
2312
+ index.bus.emit(editorId, index.REPLACE, "universal", {
2313
+ generate() {
2314
+ return {
2315
+ targetValue: props2.transformImgUrl(targetValue)
2316
+ };
2317
+ }
2318
+ });
2319
+ e.preventDefault();
2320
+ return;
2321
+ } else if (templateIn) {
2322
+ const matchArr = targetValue.match(new RegExp(`(?<=!\\[.*\\]\\()\\S+(?=\\s?["']?.*["']?\\))`));
2323
+ index.bus.emit(editorId, index.REPLACE, "universal", {
2324
+ generate() {
2325
+ return {
2326
+ targetValue: matchArr ? targetValue.replace(matchArr[0], props2.transformImgUrl(matchArr[0])) : targetValue
2327
+ };
2328
+ }
2329
+ });
2330
+ e.preventDefault();
2331
+ return;
2332
+ }
2280
2333
  if (props2.autoDetectCode && e.clipboardData.types.includes("vscode-editor-data")) {
2281
2334
  const vscCoodInfo = JSON.parse(e.clipboardData.getData("vscode-editor-data"));
2282
2335
  index.bus.emit(editorId, index.REPLACE, "code", {
@@ -2286,7 +2339,6 @@ const usePasteUpload = (props2) => {
2286
2339
  e.preventDefault();
2287
2340
  return;
2288
2341
  }
2289
- const targetValue = e.clipboardData.getData("text/plain");
2290
2342
  if (props2.maxlength && targetValue.length + props2.modelValue.length > props2.maxlength) {
2291
2343
  index.bus.emit(editorId, index.ERROR_CATCHER, {
2292
2344
  name: "overlength",
@@ -2481,7 +2533,8 @@ const createCommands = (id, contentProps) => {
2481
2533
  CtrlC,
2482
2534
  CtrlL,
2483
2535
  CtrlF,
2484
- CtrlT
2536
+ CtrlT,
2537
+ ...search.searchKeymap
2485
2538
  ];
2486
2539
  };
2487
2540
  const useCodeMirror = (props2) => {
@@ -2493,7 +2546,7 @@ const useCodeMirror = (props2) => {
2493
2546
  const languageComp = new state.Compartment(), themeComp = new state.Compartment(), autocompletionComp = new state.Compartment(), historyComp = new state.Compartment(), eventComp = new state.Compartment();
2494
2547
  const mdEditorCommands = createCommands(editorId, props2);
2495
2548
  const spelling = vue.ref(false);
2496
- const pasteHandler = usePasteUpload(props2);
2549
+ const pasteHandler = usePasteUpload(props2, codeMirrorUt);
2497
2550
  const domEventHandlers = {
2498
2551
  paste: pasteHandler,
2499
2552
  blur: props2.onBlur,
@@ -2755,6 +2808,18 @@ const useResize = (props2, contentRef, resizeRef) => {
2755
2808
  immediate: true
2756
2809
  }
2757
2810
  );
2811
+ vue.watch(
2812
+ () => props2.setting.previewOnly,
2813
+ (po) => {
2814
+ if (po) {
2815
+ inputWrapperStyle.width = "0%";
2816
+ resizeOperateStyle.display = "none";
2817
+ } else {
2818
+ inputWrapperStyle.width = state2.resizedWidth;
2819
+ resizeOperateStyle.display = "initial";
2820
+ }
2821
+ }
2822
+ );
2758
2823
  return { inputWrapperStyle, resizeOperateStyle };
2759
2824
  };
2760
2825
  const Content = /* @__PURE__ */ vue.defineComponent({
@@ -3089,7 +3154,8 @@ const Editor = /* @__PURE__ */ vue.defineComponent({
3089
3154
  }
3090
3155
  ctx.emit("onInputBoxWitdhChange", width);
3091
3156
  },
3092
- "sanitizeMermaid": props2.sanitizeMermaid
3157
+ "sanitizeMermaid": props2.sanitizeMermaid,
3158
+ "transformImgUrl": props2.transformImgUrl
3093
3159
  }, null), ((_a = props2.footers) == null ? void 0 : _a.length) > 0 && vue.createVNode(Footer, {
3094
3160
  "modelValue": props2.modelValue,
3095
3161
  "footers": props2.footers,
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  const prefix = "md-editor";
3
- const iconfontSvgUrl = "https://at.alicdn.com/t/c/font_2605852_prouiefeic.js";
4
- const iconfontClassUrl = "https://at.alicdn.com/t/c/font_2605852_prouiefeic.css";
3
+ const iconfontSvgUrl = "https://at.alicdn.com/t/c/font_2605852_rfu1p40qggh.js";
4
+ const iconfontClassUrl = "https://at.alicdn.com/t/c/font_2605852_rfu1p40qggh.css";
5
5
  const cdnBase = "https://cdnjs.cloudflare.com/ajax/libs";
6
6
  const highlightUrl = `${cdnBase}/highlight.js/11.8.0/highlight.min.js`;
7
7
  const prettierUrl = {
@@ -43,6 +43,7 @@ const allToolbar = [
43
43
  "pageFullscreen",
44
44
  "fullscreen",
45
45
  "preview",
46
+ "previewOnly",
46
47
  "htmlPreview",
47
48
  "catalog",
48
49
  "github"
@@ -76,6 +77,7 @@ const staticTextDefault = {
76
77
  pageFullscreen: "浏览器全屏",
77
78
  fullscreen: "屏幕全屏",
78
79
  preview: "预览",
80
+ previewOnly: "仅预览",
79
81
  htmlPreview: "html代码预览",
80
82
  catalog: "目录",
81
83
  github: "源码地址"
@@ -157,6 +159,7 @@ const staticTextDefault = {
157
159
  pageFullscreen: "fullscreen in page",
158
160
  fullscreen: "fullscreen",
159
161
  preview: "preview",
162
+ previewOnly: "preview only",
160
163
  htmlPreview: "html preview",
161
164
  catalog: "catalog",
162
165
  github: "source code"
@@ -3,8 +3,8 @@ const vue = require("vue");
3
3
  const config = require("./config.cjs");
4
4
  const index = require("./index4.cjs");
5
5
  const dom = require("./dom.cjs");
6
- const mediumZoom = require("medium-zoom");
7
6
  const util = require("@vavt/util");
7
+ const mediumZoom = require("medium-zoom");
8
8
  const copy = require("copy-to-clipboard");
9
9
  const mdit = require("markdown-it");
10
10
  const ImageFiguresPlugin = require("markdown-it-image-figures");
@@ -933,6 +933,10 @@ const contentProps = {
933
933
  },
934
934
  onInputBoxWitdhChange: {
935
935
  type: Function
936
+ },
937
+ transformImgUrl: {
938
+ type: Function,
939
+ default: (t) => t
936
940
  }
937
941
  };
938
942
  const ContentPreview = /* @__PURE__ */ vue.defineComponent({
@@ -1050,11 +1054,10 @@ const useProvidePreview = (props) => {
1050
1054
  ...config.staticTextDefault,
1051
1055
  ...(_b2 = (_a2 = config.configOption) == null ? void 0 : _a2.editorConfig) == null ? void 0 : _b2.languageUserDefined
1052
1056
  };
1053
- if (allText[props.language]) {
1054
- return allText[props.language];
1055
- } else {
1056
- return config.staticTextDefault["zh-CN"];
1057
- }
1057
+ return util.deepMerge(
1058
+ util.deepClone(config.staticTextDefault["en-US"]),
1059
+ allText[props.language] || {}
1060
+ );
1058
1061
  });
1059
1062
  vue.provide("usedLanguageText", usedLanguageText);
1060
1063
  vue.provide(
@@ -1145,14 +1148,19 @@ const useConfig = (props, context) => {
1145
1148
  pageFullscreen: props.pageFullscreen,
1146
1149
  fullscreen: false,
1147
1150
  preview: props.preview,
1148
- htmlPreview: props.preview ? false : props.htmlPreview
1151
+ htmlPreview: props.preview ? false : props.htmlPreview,
1152
+ previewOnly: false
1149
1153
  });
1150
1154
  const updateSetting = (k, v) => {
1151
1155
  setting[k] = v === void 0 ? !setting[k] : v;
1152
- if (k === "preview" && setting.preview) {
1156
+ if (k === "preview") {
1153
1157
  setting.htmlPreview = false;
1154
- } else if (k === "htmlPreview" && setting.htmlPreview) {
1158
+ setting.previewOnly = false;
1159
+ } else if (k === "htmlPreview") {
1155
1160
  setting.preview = false;
1161
+ setting.previewOnly = false;
1162
+ } else if (k === "previewOnly" && !setting.preview && !setting.htmlPreview) {
1163
+ setting.preview = true;
1156
1164
  }
1157
1165
  };
1158
1166
  let bodyOverflowHistory = "";
@@ -1227,6 +1235,12 @@ const useExpose$1 = (props, ctx, catalogVisible, setting, updateSetting, codeRef
1227
1235
  index.bus.emit(editorId, index.PREVIEW_CHANGED, newVal);
1228
1236
  }
1229
1237
  );
1238
+ vue.watch(
1239
+ () => setting.previewOnly,
1240
+ (newVal) => {
1241
+ index.bus.emit(editorId, index.PREVIEW_ONLY_CHANGED, newVal);
1242
+ }
1243
+ );
1230
1244
  vue.watch(
1231
1245
  () => setting.htmlPreview,
1232
1246
  (newVal) => {
@@ -1266,6 +1280,15 @@ const useExpose$1 = (props, ctx, catalogVisible, setting, updateSetting, codeRef
1266
1280
  });
1267
1281
  break;
1268
1282
  }
1283
+ case "previewOnly": {
1284
+ index.bus.on(editorId, {
1285
+ name: index.PREVIEW_ONLY_CHANGED,
1286
+ callback(status) {
1287
+ callBack(status);
1288
+ }
1289
+ });
1290
+ break;
1291
+ }
1269
1292
  case "htmlPreview": {
1270
1293
  index.bus.on(editorId, {
1271
1294
  name: index.HTML_PREVIEW_CHANGED,
@@ -1295,6 +1318,9 @@ const useExpose$1 = (props, ctx, catalogVisible, setting, updateSetting, codeRef
1295
1318
  togglePreview(status) {
1296
1319
  updateSetting("preview", status);
1297
1320
  },
1321
+ togglePreviewOnly(status) {
1322
+ updateSetting("previewOnly", status);
1323
+ },
1298
1324
  toggleHtmlPreview(status) {
1299
1325
  updateSetting("htmlPreview", status);
1300
1326
  },
@@ -1324,6 +1350,9 @@ const useExpose$1 = (props, ctx, catalogVisible, setting, updateSetting, codeRef
1324
1350
  },
1325
1351
  domEventHandlers(handlers) {
1326
1352
  index.bus.emit(editorId, index.EVENT_LISTENER, handlers);
1353
+ },
1354
+ execCommand(direct) {
1355
+ index.bus.emit(editorId, index.REPLACE, direct);
1327
1356
  }
1328
1357
  };
1329
1358
  ctx.expose(exposeParam);
@@ -1769,6 +1798,16 @@ const editorProps = {
1769
1798
  */
1770
1799
  onInputBoxWitdhChange: {
1771
1800
  type: Function
1801
+ },
1802
+ /**
1803
+ * 替换粘贴的图片链接
1804
+ *
1805
+ * @param t 图片链接
1806
+ * @returns
1807
+ */
1808
+ transformImgUrl: {
1809
+ type: Function,
1810
+ default: (t) => t
1772
1811
  }
1773
1812
  };
1774
1813
  const mdPreviewEmits = ["onHtmlChanged", "onGetCatalog"];
@@ -58,6 +58,7 @@ const CHANGE_FULL_SCREEN = "changeFullscreen";
58
58
  const PAGE_FULL_SCREEN_CHANGED = "pageFullscreenChanged";
59
59
  const FULL_SCREEN_CHANGED = "fullscreenChanged";
60
60
  const PREVIEW_CHANGED = "previewChanged";
61
+ const PREVIEW_ONLY_CHANGED = "previewOnlyChanged";
61
62
  const HTML_PREVIEW_CHANGED = "htmlPreviewChanged";
62
63
  const CATALOG_VISIBLE_CHANGED = "catalogVisibleChanged";
63
64
  const BUILD_FINISHED = "buildFinished";
@@ -130,6 +131,7 @@ exports.ON_SAVE = ON_SAVE;
130
131
  exports.OPEN_MODALS = OPEN_MODALS;
131
132
  exports.PAGE_FULL_SCREEN_CHANGED = PAGE_FULL_SCREEN_CHANGED;
132
133
  exports.PREVIEW_CHANGED = PREVIEW_CHANGED;
134
+ exports.PREVIEW_ONLY_CHANGED = PREVIEW_ONLY_CHANGED;
133
135
  exports.PUSH_CATALOG = PUSH_CATALOG;
134
136
  exports.REPLACE = REPLACE;
135
137
  exports.RERENDER = RERENDER;