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 +25 -0
- package/lib/cjs/MdEditor.cjs +96 -30
- package/lib/cjs/chunks/config.cjs +5 -2
- package/lib/cjs/chunks/index.cjs +48 -9
- package/lib/cjs/chunks/index4.cjs +2 -0
- package/lib/es/MdEditor.mjs +97 -31
- package/lib/es/chunks/config.mjs +5 -2
- package/lib/es/chunks/index.mjs +49 -10
- package/lib/es/chunks/index4.mjs +11 -9
- package/lib/style.css +58 -0
- package/lib/types/MdEditor/Editor.d.ts +10 -1
- package/lib/types/MdEditor/components/Icon/Icon.d.ts +1 -1
- package/lib/types/MdEditor/composition.d.ts +1 -1
- package/lib/types/MdEditor/config.d.ts +2 -2
- package/lib/types/MdEditor/index.d.ts +23 -4
- package/lib/types/MdEditor/layouts/Content/ContentPreview.d.ts +1 -1
- package/lib/types/MdEditor/layouts/Content/composition/usePasteUpload.d.ts +3 -1
- package/lib/types/MdEditor/layouts/Content/index.d.ts +10 -1
- package/lib/types/MdEditor/layouts/Content/props.d.ts +4 -0
- package/lib/types/MdEditor/props.d.ts +10 -0
- package/lib/types/MdEditor/static/event-name.d.ts +1 -0
- package/lib/types/MdEditor/type.d.ts +11 -0
- package/lib/types/MdPreview/MdPreview.d.ts +1 -1
- package/lib/types/MdPreview/index.d.ts +4 -4
- package/lib/umd/index.js +40 -39
- package/package.json +1 -1
package/lib/es/MdEditor.mjs
CHANGED
|
@@ -8,7 +8,7 @@ import { defineComponent, createVNode, inject, ref, onMounted, reactive, compute
|
|
|
8
8
|
import { p as prefix, e as configOption, l as screenfullUrl, b as allToolbar, M as MinInputBoxWidth, d as allFooter } from "./chunks/config.mjs";
|
|
9
9
|
import { draggingScroll, linkTo, debounce, createSmoothScroll, throttle } from "@vavt/util";
|
|
10
10
|
import { a as Dropdown, D as DropdownToolbar } from "./chunks/index2.mjs";
|
|
11
|
-
import { b as bus,
|
|
11
|
+
import { b as bus, j as CHANGE_FULL_SCREEN, E as ERROR_CATCHER, U as UPLOAD_IMAGE, m as base642File, n as OPEN_MODALS, i as REPLACE, c as CHANGE_CATALOG_VISIBLE, O as ON_SAVE, o as CTRL_SHIFT_Z, p as CTRL_Z, k as EVENT_LISTENER } from "./chunks/index4.mjs";
|
|
12
12
|
import { a as appendHandler } from "./chunks/dom.mjs";
|
|
13
13
|
import { M as MdModal, I as Icon } from "./chunks/index3.mjs";
|
|
14
14
|
import { EditorView as EditorView$1 } from "codemirror";
|
|
@@ -20,6 +20,7 @@ import { deleteLine, defaultKeymap, historyKeymap, indentWithTab, history, undo,
|
|
|
20
20
|
import { HighlightStyle, syntaxHighlighting, indentUnit } from "@codemirror/language";
|
|
21
21
|
import { tags } from "@lezer/highlight";
|
|
22
22
|
import { autocompletion } from "@codemirror/autocomplete";
|
|
23
|
+
import { searchKeymap } from "@codemirror/search";
|
|
23
24
|
import { c as contentProps, C as ContentPreview, e as editorProps, a as editorEmits, u as useOnSave, b as useProvide, d as useExpansion, f as useErrorCatcher, g as useConfig, h as useCatalog, i as useExpose, M as MdPreview } from "./chunks/index.mjs";
|
|
24
25
|
import MdCatalog from "./MdCatalog.mjs";
|
|
25
26
|
import { g as getSlot } from "./chunks/vue-tsx.mjs";
|
|
@@ -544,7 +545,7 @@ const ToolBar = /* @__PURE__ */ defineComponent({
|
|
|
544
545
|
uploadRef.value.addEventListener("change", uploadHandler);
|
|
545
546
|
});
|
|
546
547
|
const barRender = (barItem) => {
|
|
547
|
-
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;
|
|
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, _na, _oa;
|
|
548
549
|
if (allToolbar.includes(barItem)) {
|
|
549
550
|
switch (barItem) {
|
|
550
551
|
case "-": {
|
|
@@ -952,10 +953,23 @@ const ToolBar = /* @__PURE__ */ defineComponent({
|
|
|
952
953
|
"class": `${prefix}-toolbar-item-name`
|
|
953
954
|
}, [(_Y = ult.value.toolbarTips) == null ? void 0 : _Y.preview])]);
|
|
954
955
|
}
|
|
956
|
+
case "previewOnly": {
|
|
957
|
+
return createVNode("div", {
|
|
958
|
+
"class": `${prefix}-toolbar-item`,
|
|
959
|
+
"title": (_Z = ult.value.toolbarTips) == null ? void 0 : _Z.previewOnly,
|
|
960
|
+
"onClick": () => {
|
|
961
|
+
props2.updateSetting("previewOnly");
|
|
962
|
+
}
|
|
963
|
+
}, [createVNode(Icon, {
|
|
964
|
+
"name": "preview-only"
|
|
965
|
+
}, null), props2.showToolbarName && createVNode("div", {
|
|
966
|
+
"class": `${prefix}-toolbar-item-name`
|
|
967
|
+
}, [(__ = ult.value.toolbarTips) == null ? void 0 : __.previewOnly])]);
|
|
968
|
+
}
|
|
955
969
|
case "htmlPreview": {
|
|
956
970
|
return createVNode("div", {
|
|
957
971
|
"class": `${prefix}-toolbar-item`,
|
|
958
|
-
"title": (
|
|
972
|
+
"title": (_$ = ult.value.toolbarTips) == null ? void 0 : _$.htmlPreview,
|
|
959
973
|
"onClick": () => {
|
|
960
974
|
props2.updateSetting("htmlPreview");
|
|
961
975
|
}
|
|
@@ -963,12 +977,12 @@ const ToolBar = /* @__PURE__ */ defineComponent({
|
|
|
963
977
|
"name": "coding"
|
|
964
978
|
}, null), props2.showToolbarName && createVNode("div", {
|
|
965
979
|
"class": `${prefix}-toolbar-item-name`
|
|
966
|
-
}, [(
|
|
980
|
+
}, [(_aa = ult.value.toolbarTips) == null ? void 0 : _aa.htmlPreview])]);
|
|
967
981
|
}
|
|
968
982
|
case "catalog": {
|
|
969
983
|
return createVNode("div", {
|
|
970
984
|
"class": `${prefix}-toolbar-item`,
|
|
971
|
-
"title": (
|
|
985
|
+
"title": (_ba = ult.value.toolbarTips) == null ? void 0 : _ba.catalog,
|
|
972
986
|
"onClick": () => {
|
|
973
987
|
bus.emit(editorId, CHANGE_CATALOG_VISIBLE);
|
|
974
988
|
},
|
|
@@ -977,18 +991,18 @@ const ToolBar = /* @__PURE__ */ defineComponent({
|
|
|
977
991
|
"name": "catalog"
|
|
978
992
|
}, null), props2.showToolbarName && createVNode("div", {
|
|
979
993
|
"class": `${prefix}-toolbar-item-name`
|
|
980
|
-
}, [(
|
|
994
|
+
}, [(_ca = ult.value.toolbarTips) == null ? void 0 : _ca.catalog])]);
|
|
981
995
|
}
|
|
982
996
|
case "github": {
|
|
983
997
|
return createVNode("div", {
|
|
984
998
|
"class": `${prefix}-toolbar-item`,
|
|
985
|
-
"title": (
|
|
999
|
+
"title": (_da = ult.value.toolbarTips) == null ? void 0 : _da.github,
|
|
986
1000
|
"onClick": () => linkTo("https://github.com/imzbf/md-editor-v3")
|
|
987
1001
|
}, [createVNode(Icon, {
|
|
988
1002
|
"name": "github"
|
|
989
1003
|
}, null), props2.showToolbarName && createVNode("div", {
|
|
990
1004
|
"class": `${prefix}-toolbar-item-name`
|
|
991
|
-
}, [(
|
|
1005
|
+
}, [(_ea = ult.value.toolbarTips) == null ? void 0 : _ea.github])]);
|
|
992
1006
|
}
|
|
993
1007
|
case "mermaid": {
|
|
994
1008
|
return createVNode(Dropdown, {
|
|
@@ -1007,42 +1021,42 @@ const ToolBar = /* @__PURE__ */ defineComponent({
|
|
|
1007
1021
|
"onClick": () => {
|
|
1008
1022
|
emitHandler("flow");
|
|
1009
1023
|
}
|
|
1010
|
-
}, [(
|
|
1024
|
+
}, [(_fa = ult.value.mermaid) == null ? void 0 : _fa.flow]), createVNode("li", {
|
|
1011
1025
|
"class": `${prefix}-menu-item ${prefix}-menu-item-mermaid`,
|
|
1012
1026
|
"onClick": () => {
|
|
1013
1027
|
emitHandler("sequence");
|
|
1014
1028
|
}
|
|
1015
|
-
}, [(
|
|
1029
|
+
}, [(_ga = ult.value.mermaid) == null ? void 0 : _ga.sequence]), createVNode("li", {
|
|
1016
1030
|
"class": `${prefix}-menu-item ${prefix}-menu-item-mermaid`,
|
|
1017
1031
|
"onClick": () => {
|
|
1018
1032
|
emitHandler("gantt");
|
|
1019
1033
|
}
|
|
1020
|
-
}, [(
|
|
1034
|
+
}, [(_ha = ult.value.mermaid) == null ? void 0 : _ha.gantt]), createVNode("li", {
|
|
1021
1035
|
"class": `${prefix}-menu-item ${prefix}-menu-item-mermaid`,
|
|
1022
1036
|
"onClick": () => {
|
|
1023
1037
|
emitHandler("class");
|
|
1024
1038
|
}
|
|
1025
|
-
}, [(
|
|
1039
|
+
}, [(_ia = ult.value.mermaid) == null ? void 0 : _ia.class]), createVNode("li", {
|
|
1026
1040
|
"class": `${prefix}-menu-item ${prefix}-menu-item-mermaid`,
|
|
1027
1041
|
"onClick": () => {
|
|
1028
1042
|
emitHandler("state");
|
|
1029
1043
|
}
|
|
1030
|
-
}, [(
|
|
1044
|
+
}, [(_ja = ult.value.mermaid) == null ? void 0 : _ja.state]), createVNode("li", {
|
|
1031
1045
|
"class": `${prefix}-menu-item ${prefix}-menu-item-mermaid`,
|
|
1032
1046
|
"onClick": () => {
|
|
1033
1047
|
emitHandler("pie");
|
|
1034
1048
|
}
|
|
1035
|
-
}, [(
|
|
1049
|
+
}, [(_ka = ult.value.mermaid) == null ? void 0 : _ka.pie]), createVNode("li", {
|
|
1036
1050
|
"class": `${prefix}-menu-item ${prefix}-menu-item-mermaid`,
|
|
1037
1051
|
"onClick": () => {
|
|
1038
1052
|
emitHandler("relationship");
|
|
1039
1053
|
}
|
|
1040
|
-
}, [(
|
|
1054
|
+
}, [(_la = ult.value.mermaid) == null ? void 0 : _la.relationship]), createVNode("li", {
|
|
1041
1055
|
"class": `${prefix}-menu-item ${prefix}-menu-item-mermaid`,
|
|
1042
1056
|
"onClick": () => {
|
|
1043
1057
|
emitHandler("journey");
|
|
1044
1058
|
}
|
|
1045
|
-
}, [(
|
|
1059
|
+
}, [(_ma = ult.value.mermaid) == null ? void 0 : _ma.journey])]),
|
|
1046
1060
|
"key": "bar-mermaid"
|
|
1047
1061
|
}, {
|
|
1048
1062
|
default: () => {
|
|
@@ -1075,12 +1089,12 @@ const ToolBar = /* @__PURE__ */ defineComponent({
|
|
|
1075
1089
|
"onClick": () => {
|
|
1076
1090
|
emitHandler("katexInline");
|
|
1077
1091
|
}
|
|
1078
|
-
}, [(
|
|
1092
|
+
}, [(_na = ult.value.katex) == null ? void 0 : _na.inline]), createVNode("li", {
|
|
1079
1093
|
"class": `${prefix}-menu-item ${prefix}-menu-item-katex`,
|
|
1080
1094
|
"onClick": () => {
|
|
1081
1095
|
emitHandler("katexBlock");
|
|
1082
1096
|
}
|
|
1083
|
-
}, [(
|
|
1097
|
+
}, [(_oa = ult.value.katex) == null ? void 0 : _oa.block])]),
|
|
1084
1098
|
"key": "bar-katex"
|
|
1085
1099
|
}, {
|
|
1086
1100
|
default: () => {
|
|
@@ -1450,9 +1464,9 @@ const useAutoScroll = (props2, html, codeMirrorUt) => {
|
|
|
1450
1464
|
cEle,
|
|
1451
1465
|
codeMirrorUt.value
|
|
1452
1466
|
);
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1467
|
+
if (props2.scrollAuto) {
|
|
1468
|
+
initScrollAuto();
|
|
1469
|
+
}
|
|
1456
1470
|
}
|
|
1457
1471
|
};
|
|
1458
1472
|
watch(
|
|
@@ -1477,6 +1491,16 @@ const useAutoScroll = (props2, html, codeMirrorUt) => {
|
|
|
1477
1491
|
}
|
|
1478
1492
|
}
|
|
1479
1493
|
);
|
|
1494
|
+
watch(
|
|
1495
|
+
() => props2.setting.previewOnly,
|
|
1496
|
+
(po) => {
|
|
1497
|
+
if (po) {
|
|
1498
|
+
clearScrollAuto();
|
|
1499
|
+
} else {
|
|
1500
|
+
initScrollAuto();
|
|
1501
|
+
}
|
|
1502
|
+
}
|
|
1503
|
+
);
|
|
1480
1504
|
onMounted(rebindEvent);
|
|
1481
1505
|
};
|
|
1482
1506
|
const directive2flag = (direct, codeMirrorUt, params) => {
|
|
@@ -1755,8 +1779,8 @@ const oneDarkTheme = EditorView.theme(
|
|
|
1755
1779
|
".cm-cursor, .cm-dropCursor": { borderLeftColor: cursor$1 },
|
|
1756
1780
|
"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection": { backgroundColor: selection$1 },
|
|
1757
1781
|
".cm-panels": { backgroundColor: darkBackground$1, color: ivory$1 },
|
|
1758
|
-
".cm-panels.cm-panels-top": { borderBottom: "
|
|
1759
|
-
".cm-panels.cm-panels-bottom": { borderTop: "
|
|
1782
|
+
".cm-panels.cm-panels-top": { borderBottom: "1px solid var(--md-border-color)" },
|
|
1783
|
+
".cm-panels.cm-panels-bottom": { borderTop: "1px solid var(--md-border-color)" },
|
|
1760
1784
|
".cm-searchMatch": {
|
|
1761
1785
|
backgroundColor: "#72a1ff59",
|
|
1762
1786
|
outline: "1px solid #457dff"
|
|
@@ -1848,7 +1872,7 @@ const oneDark = [
|
|
|
1848
1872
|
oneDarkTheme,
|
|
1849
1873
|
syntaxHighlighting(oneDarkHighlightStyle)
|
|
1850
1874
|
];
|
|
1851
|
-
const chalky = "#e5c07b", coral = "#3f4a54", cyan = "#56b6c2", invalid = "#fff", ivory = "#3f4a54", stone = "#2d8cf0", malibu = "#2d8cf0", sage = "#3f4a54", whiskey = "#d19a66", violet = "#c678dd", darkBackground = "#
|
|
1875
|
+
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";
|
|
1852
1876
|
const oneLightTheme = EditorView.theme(
|
|
1853
1877
|
{
|
|
1854
1878
|
"&": {
|
|
@@ -1861,8 +1885,8 @@ const oneLightTheme = EditorView.theme(
|
|
|
1861
1885
|
".cm-cursor, .cm-dropCursor": { borderLeftColor: cursor },
|
|
1862
1886
|
"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection": { backgroundColor: selection },
|
|
1863
1887
|
".cm-panels": { backgroundColor: darkBackground, color: ivory },
|
|
1864
|
-
".cm-panels.cm-panels-top": { borderBottom: "
|
|
1865
|
-
".cm-panels.cm-panels-bottom": { borderTop: "
|
|
1888
|
+
".cm-panels.cm-panels-top": { borderBottom: "1px solid var(--md-border-color)" },
|
|
1889
|
+
".cm-panels.cm-panels-bottom": { borderTop: "1px solid var(--md-border-color)" },
|
|
1866
1890
|
".cm-searchMatch": {
|
|
1867
1891
|
backgroundColor: "#72a1ff59",
|
|
1868
1892
|
outline: "1px solid #457dff"
|
|
@@ -2258,9 +2282,10 @@ class CodeMirrorUt {
|
|
|
2258
2282
|
]);
|
|
2259
2283
|
}
|
|
2260
2284
|
}
|
|
2261
|
-
const usePasteUpload = (props2) => {
|
|
2285
|
+
const usePasteUpload = (props2, codeMirrorUt) => {
|
|
2262
2286
|
const editorId = inject("editorId");
|
|
2263
2287
|
const pasteHandler = (e) => {
|
|
2288
|
+
var _a, _b, _c;
|
|
2264
2289
|
if (!e.clipboardData) {
|
|
2265
2290
|
return;
|
|
2266
2291
|
}
|
|
@@ -2276,6 +2301,34 @@ const usePasteUpload = (props2) => {
|
|
|
2276
2301
|
e.preventDefault();
|
|
2277
2302
|
return;
|
|
2278
2303
|
}
|
|
2304
|
+
const targetValue = e.clipboardData.getData("text/plain");
|
|
2305
|
+
const to = ((_a = codeMirrorUt.value) == null ? void 0 : _a.view.state.selection.main.to) || 0;
|
|
2306
|
+
const from = ((_b = codeMirrorUt.value) == null ? void 0 : _b.view.state.doc.lineAt(to).from) || 0;
|
|
2307
|
+
const lineStart = ((_c = codeMirrorUt.value) == null ? void 0 : _c.view.state.doc.sliceString(from, to)) || "";
|
|
2308
|
+
const templateStart = /!\[.*\]\(\s*$/.test(lineStart);
|
|
2309
|
+
const templateIn = /!\[.*\]\((.*)\s?.*\)/.test(targetValue);
|
|
2310
|
+
if (templateStart) {
|
|
2311
|
+
bus.emit(editorId, REPLACE, "universal", {
|
|
2312
|
+
generate() {
|
|
2313
|
+
return {
|
|
2314
|
+
targetValue: props2.transformImgUrl(targetValue)
|
|
2315
|
+
};
|
|
2316
|
+
}
|
|
2317
|
+
});
|
|
2318
|
+
e.preventDefault();
|
|
2319
|
+
return;
|
|
2320
|
+
} else if (templateIn) {
|
|
2321
|
+
const matchArr = targetValue.match(new RegExp(`(?<=!\\[.*\\]\\()\\S+(?=\\s?["']?.*["']?\\))`));
|
|
2322
|
+
bus.emit(editorId, REPLACE, "universal", {
|
|
2323
|
+
generate() {
|
|
2324
|
+
return {
|
|
2325
|
+
targetValue: matchArr ? targetValue.replace(matchArr[0], props2.transformImgUrl(matchArr[0])) : targetValue
|
|
2326
|
+
};
|
|
2327
|
+
}
|
|
2328
|
+
});
|
|
2329
|
+
e.preventDefault();
|
|
2330
|
+
return;
|
|
2331
|
+
}
|
|
2279
2332
|
if (props2.autoDetectCode && e.clipboardData.types.includes("vscode-editor-data")) {
|
|
2280
2333
|
const vscCoodInfo = JSON.parse(e.clipboardData.getData("vscode-editor-data"));
|
|
2281
2334
|
bus.emit(editorId, REPLACE, "code", {
|
|
@@ -2285,7 +2338,6 @@ const usePasteUpload = (props2) => {
|
|
|
2285
2338
|
e.preventDefault();
|
|
2286
2339
|
return;
|
|
2287
2340
|
}
|
|
2288
|
-
const targetValue = e.clipboardData.getData("text/plain");
|
|
2289
2341
|
if (props2.maxlength && targetValue.length + props2.modelValue.length > props2.maxlength) {
|
|
2290
2342
|
bus.emit(editorId, ERROR_CATCHER, {
|
|
2291
2343
|
name: "overlength",
|
|
@@ -2480,7 +2532,8 @@ const createCommands = (id, contentProps2) => {
|
|
|
2480
2532
|
CtrlC,
|
|
2481
2533
|
CtrlL,
|
|
2482
2534
|
CtrlF,
|
|
2483
|
-
CtrlT
|
|
2535
|
+
CtrlT,
|
|
2536
|
+
...searchKeymap
|
|
2484
2537
|
];
|
|
2485
2538
|
};
|
|
2486
2539
|
const useCodeMirror = (props2) => {
|
|
@@ -2492,7 +2545,7 @@ const useCodeMirror = (props2) => {
|
|
|
2492
2545
|
const languageComp = new Compartment(), themeComp = new Compartment(), autocompletionComp = new Compartment(), historyComp = new Compartment(), eventComp = new Compartment();
|
|
2493
2546
|
const mdEditorCommands = createCommands(editorId, props2);
|
|
2494
2547
|
const spelling = ref(false);
|
|
2495
|
-
const pasteHandler = usePasteUpload(props2);
|
|
2548
|
+
const pasteHandler = usePasteUpload(props2, codeMirrorUt);
|
|
2496
2549
|
const domEventHandlers = {
|
|
2497
2550
|
paste: pasteHandler,
|
|
2498
2551
|
blur: props2.onBlur,
|
|
@@ -2754,6 +2807,18 @@ const useResize = (props2, contentRef, resizeRef) => {
|
|
|
2754
2807
|
immediate: true
|
|
2755
2808
|
}
|
|
2756
2809
|
);
|
|
2810
|
+
watch(
|
|
2811
|
+
() => props2.setting.previewOnly,
|
|
2812
|
+
(po) => {
|
|
2813
|
+
if (po) {
|
|
2814
|
+
inputWrapperStyle.width = "0%";
|
|
2815
|
+
resizeOperateStyle.display = "none";
|
|
2816
|
+
} else {
|
|
2817
|
+
inputWrapperStyle.width = state.resizedWidth;
|
|
2818
|
+
resizeOperateStyle.display = "initial";
|
|
2819
|
+
}
|
|
2820
|
+
}
|
|
2821
|
+
);
|
|
2757
2822
|
return { inputWrapperStyle, resizeOperateStyle };
|
|
2758
2823
|
};
|
|
2759
2824
|
const Content = /* @__PURE__ */ defineComponent({
|
|
@@ -3088,7 +3153,8 @@ const Editor = /* @__PURE__ */ defineComponent({
|
|
|
3088
3153
|
}
|
|
3089
3154
|
ctx.emit("onInputBoxWitdhChange", width);
|
|
3090
3155
|
},
|
|
3091
|
-
"sanitizeMermaid": props2.sanitizeMermaid
|
|
3156
|
+
"sanitizeMermaid": props2.sanitizeMermaid,
|
|
3157
|
+
"transformImgUrl": props2.transformImgUrl
|
|
3092
3158
|
}, null), ((_a = props2.footers) == null ? void 0 : _a.length) > 0 && createVNode(Footer, {
|
|
3093
3159
|
"modelValue": props2.modelValue,
|
|
3094
3160
|
"footers": props2.footers,
|
package/lib/es/chunks/config.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const prefix = "md-editor";
|
|
2
|
-
const iconfontSvgUrl = "https://at.alicdn.com/t/c/
|
|
3
|
-
const iconfontClassUrl = "https://at.alicdn.com/t/c/
|
|
2
|
+
const iconfontSvgUrl = "https://at.alicdn.com/t/c/font_2605852_rfu1p40qggh.js";
|
|
3
|
+
const iconfontClassUrl = "https://at.alicdn.com/t/c/font_2605852_rfu1p40qggh.css";
|
|
4
4
|
const cdnBase = "https://cdnjs.cloudflare.com/ajax/libs";
|
|
5
5
|
const highlightUrl = `${cdnBase}/highlight.js/11.8.0/highlight.min.js`;
|
|
6
6
|
const prettierUrl = {
|
|
@@ -42,6 +42,7 @@ const allToolbar = [
|
|
|
42
42
|
"pageFullscreen",
|
|
43
43
|
"fullscreen",
|
|
44
44
|
"preview",
|
|
45
|
+
"previewOnly",
|
|
45
46
|
"htmlPreview",
|
|
46
47
|
"catalog",
|
|
47
48
|
"github"
|
|
@@ -75,6 +76,7 @@ const staticTextDefault = {
|
|
|
75
76
|
pageFullscreen: "浏览器全屏",
|
|
76
77
|
fullscreen: "屏幕全屏",
|
|
77
78
|
preview: "预览",
|
|
79
|
+
previewOnly: "仅预览",
|
|
78
80
|
htmlPreview: "html代码预览",
|
|
79
81
|
catalog: "目录",
|
|
80
82
|
github: "源码地址"
|
|
@@ -156,6 +158,7 @@ const staticTextDefault = {
|
|
|
156
158
|
pageFullscreen: "fullscreen in page",
|
|
157
159
|
fullscreen: "fullscreen",
|
|
158
160
|
preview: "preview",
|
|
161
|
+
previewOnly: "preview only",
|
|
159
162
|
htmlPreview: "html preview",
|
|
160
163
|
catalog: "catalog",
|
|
161
164
|
github: "source code"
|
package/lib/es/chunks/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { inject, watch, toRef, onMounted, nextTick, shallowRef, ref, computed, defineComponent, createVNode, Fragment, reactive, provide, onBeforeUnmount } from "vue";
|
|
2
2
|
import { e as configOption, p as prefix, m as mermaidUrl, k as katexUrl, f as codeCss, h as highlightUrl, s as staticTextDefault, a as iconfontSvgUrl, i as iconfontClassUrl, g as prettierUrl, j as cropperUrl, b as allToolbar, d as allFooter } from "./config.mjs";
|
|
3
|
-
import { a as generateCodeRowNumber, b as bus, P as PUSH_CATALOG, C as CATALOG_CHANGED, R as RERENDER, B as BUILD_FINISHED, O as ON_SAVE, E as ERROR_CATCHER, U as UPLOAD_IMAGE, c as CHANGE_CATALOG_VISIBLE, d as PAGE_FULL_SCREEN_CHANGED, F as FULL_SCREEN_CHANGED, e as PREVIEW_CHANGED, H as HTML_PREVIEW_CHANGED,
|
|
3
|
+
import { a as generateCodeRowNumber, b as bus, P as PUSH_CATALOG, C as CATALOG_CHANGED, R as RERENDER, B as BUILD_FINISHED, O as ON_SAVE, E as ERROR_CATCHER, U as UPLOAD_IMAGE, c as CHANGE_CATALOG_VISIBLE, d as PAGE_FULL_SCREEN_CHANGED, F as FULL_SCREEN_CHANGED, e as PREVIEW_CHANGED, f as PREVIEW_ONLY_CHANGED, H as HTML_PREVIEW_CHANGED, h as CATALOG_VISIBLE_CHANGED, i as REPLACE, j as CHANGE_FULL_SCREEN, k as EVENT_LISTENER, l as getNextId } from "./index4.mjs";
|
|
4
4
|
import { a as appendHandler, u as updateHandler } from "./dom.mjs";
|
|
5
|
+
import { debounce, uuid, deepMerge, deepClone } from "@vavt/util";
|
|
5
6
|
import mediumZoom from "medium-zoom";
|
|
6
|
-
import { debounce, uuid } from "@vavt/util";
|
|
7
7
|
import copy from "copy-to-clipboard";
|
|
8
8
|
import mdit from "markdown-it";
|
|
9
9
|
import ImageFiguresPlugin from "markdown-it-image-figures";
|
|
@@ -932,6 +932,10 @@ const contentProps = {
|
|
|
932
932
|
},
|
|
933
933
|
onInputBoxWitdhChange: {
|
|
934
934
|
type: Function
|
|
935
|
+
},
|
|
936
|
+
transformImgUrl: {
|
|
937
|
+
type: Function,
|
|
938
|
+
default: (t) => t
|
|
935
939
|
}
|
|
936
940
|
};
|
|
937
941
|
const ContentPreview = /* @__PURE__ */ defineComponent({
|
|
@@ -1049,11 +1053,10 @@ const useProvidePreview = (props) => {
|
|
|
1049
1053
|
...staticTextDefault,
|
|
1050
1054
|
...(_b2 = (_a2 = configOption) == null ? void 0 : _a2.editorConfig) == null ? void 0 : _b2.languageUserDefined
|
|
1051
1055
|
};
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
}
|
|
1056
|
+
return deepMerge(
|
|
1057
|
+
deepClone(staticTextDefault["en-US"]),
|
|
1058
|
+
allText[props.language] || {}
|
|
1059
|
+
);
|
|
1057
1060
|
});
|
|
1058
1061
|
provide("usedLanguageText", usedLanguageText);
|
|
1059
1062
|
provide(
|
|
@@ -1144,14 +1147,19 @@ const useConfig = (props, context) => {
|
|
|
1144
1147
|
pageFullscreen: props.pageFullscreen,
|
|
1145
1148
|
fullscreen: false,
|
|
1146
1149
|
preview: props.preview,
|
|
1147
|
-
htmlPreview: props.preview ? false : props.htmlPreview
|
|
1150
|
+
htmlPreview: props.preview ? false : props.htmlPreview,
|
|
1151
|
+
previewOnly: false
|
|
1148
1152
|
});
|
|
1149
1153
|
const updateSetting = (k, v) => {
|
|
1150
1154
|
setting[k] = v === void 0 ? !setting[k] : v;
|
|
1151
|
-
if (k === "preview"
|
|
1155
|
+
if (k === "preview") {
|
|
1152
1156
|
setting.htmlPreview = false;
|
|
1153
|
-
|
|
1157
|
+
setting.previewOnly = false;
|
|
1158
|
+
} else if (k === "htmlPreview") {
|
|
1154
1159
|
setting.preview = false;
|
|
1160
|
+
setting.previewOnly = false;
|
|
1161
|
+
} else if (k === "previewOnly" && !setting.preview && !setting.htmlPreview) {
|
|
1162
|
+
setting.preview = true;
|
|
1155
1163
|
}
|
|
1156
1164
|
};
|
|
1157
1165
|
let bodyOverflowHistory = "";
|
|
@@ -1226,6 +1234,12 @@ const useExpose$1 = (props, ctx, catalogVisible, setting, updateSetting, codeRef
|
|
|
1226
1234
|
bus.emit(editorId, PREVIEW_CHANGED, newVal);
|
|
1227
1235
|
}
|
|
1228
1236
|
);
|
|
1237
|
+
watch(
|
|
1238
|
+
() => setting.previewOnly,
|
|
1239
|
+
(newVal) => {
|
|
1240
|
+
bus.emit(editorId, PREVIEW_ONLY_CHANGED, newVal);
|
|
1241
|
+
}
|
|
1242
|
+
);
|
|
1229
1243
|
watch(
|
|
1230
1244
|
() => setting.htmlPreview,
|
|
1231
1245
|
(newVal) => {
|
|
@@ -1265,6 +1279,15 @@ const useExpose$1 = (props, ctx, catalogVisible, setting, updateSetting, codeRef
|
|
|
1265
1279
|
});
|
|
1266
1280
|
break;
|
|
1267
1281
|
}
|
|
1282
|
+
case "previewOnly": {
|
|
1283
|
+
bus.on(editorId, {
|
|
1284
|
+
name: PREVIEW_ONLY_CHANGED,
|
|
1285
|
+
callback(status) {
|
|
1286
|
+
callBack(status);
|
|
1287
|
+
}
|
|
1288
|
+
});
|
|
1289
|
+
break;
|
|
1290
|
+
}
|
|
1268
1291
|
case "htmlPreview": {
|
|
1269
1292
|
bus.on(editorId, {
|
|
1270
1293
|
name: HTML_PREVIEW_CHANGED,
|
|
@@ -1294,6 +1317,9 @@ const useExpose$1 = (props, ctx, catalogVisible, setting, updateSetting, codeRef
|
|
|
1294
1317
|
togglePreview(status) {
|
|
1295
1318
|
updateSetting("preview", status);
|
|
1296
1319
|
},
|
|
1320
|
+
togglePreviewOnly(status) {
|
|
1321
|
+
updateSetting("previewOnly", status);
|
|
1322
|
+
},
|
|
1297
1323
|
toggleHtmlPreview(status) {
|
|
1298
1324
|
updateSetting("htmlPreview", status);
|
|
1299
1325
|
},
|
|
@@ -1323,6 +1349,9 @@ const useExpose$1 = (props, ctx, catalogVisible, setting, updateSetting, codeRef
|
|
|
1323
1349
|
},
|
|
1324
1350
|
domEventHandlers(handlers) {
|
|
1325
1351
|
bus.emit(editorId, EVENT_LISTENER, handlers);
|
|
1352
|
+
},
|
|
1353
|
+
execCommand(direct) {
|
|
1354
|
+
bus.emit(editorId, REPLACE, direct);
|
|
1326
1355
|
}
|
|
1327
1356
|
};
|
|
1328
1357
|
ctx.expose(exposeParam);
|
|
@@ -1768,6 +1797,16 @@ const editorProps = {
|
|
|
1768
1797
|
*/
|
|
1769
1798
|
onInputBoxWitdhChange: {
|
|
1770
1799
|
type: Function
|
|
1800
|
+
},
|
|
1801
|
+
/**
|
|
1802
|
+
* 替换粘贴的图片链接
|
|
1803
|
+
*
|
|
1804
|
+
* @param t 图片链接
|
|
1805
|
+
* @returns
|
|
1806
|
+
*/
|
|
1807
|
+
transformImgUrl: {
|
|
1808
|
+
type: Function,
|
|
1809
|
+
default: (t) => t
|
|
1771
1810
|
}
|
|
1772
1811
|
};
|
|
1773
1812
|
const mdPreviewEmits = ["onHtmlChanged", "onGetCatalog"];
|
package/lib/es/chunks/index4.mjs
CHANGED
|
@@ -57,6 +57,7 @@ const CHANGE_FULL_SCREEN = "changeFullscreen";
|
|
|
57
57
|
const PAGE_FULL_SCREEN_CHANGED = "pageFullscreenChanged";
|
|
58
58
|
const FULL_SCREEN_CHANGED = "fullscreenChanged";
|
|
59
59
|
const PREVIEW_CHANGED = "previewChanged";
|
|
60
|
+
const PREVIEW_ONLY_CHANGED = "previewOnlyChanged";
|
|
60
61
|
const HTML_PREVIEW_CHANGED = "htmlPreviewChanged";
|
|
61
62
|
const CATALOG_VISIBLE_CHANGED = "catalogVisibleChanged";
|
|
62
63
|
const BUILD_FINISHED = "buildFinished";
|
|
@@ -129,14 +130,15 @@ export {
|
|
|
129
130
|
CHANGE_CATALOG_VISIBLE as c,
|
|
130
131
|
PAGE_FULL_SCREEN_CHANGED as d,
|
|
131
132
|
PREVIEW_CHANGED as e,
|
|
132
|
-
|
|
133
|
+
PREVIEW_ONLY_CHANGED as f,
|
|
133
134
|
getRelativeTop as g,
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
135
|
+
CATALOG_VISIBLE_CHANGED as h,
|
|
136
|
+
REPLACE as i,
|
|
137
|
+
CHANGE_FULL_SCREEN as j,
|
|
138
|
+
EVENT_LISTENER as k,
|
|
139
|
+
getNextId as l,
|
|
140
|
+
base642File as m,
|
|
141
|
+
OPEN_MODALS as n,
|
|
142
|
+
CTRL_SHIFT_Z as o,
|
|
143
|
+
CTRL_Z as p
|
|
142
144
|
};
|
package/lib/style.css
CHANGED
|
@@ -381,6 +381,64 @@
|
|
|
381
381
|
}.ͼ1 .cm-scroller {
|
|
382
382
|
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace;
|
|
383
383
|
line-height: 20px;
|
|
384
|
+
}.cm-search .cm-textfield {
|
|
385
|
+
border-radius: 4px;
|
|
386
|
+
padding: 4px 11px;
|
|
387
|
+
color: var(--md-color);
|
|
388
|
+
font-size: 10px;
|
|
389
|
+
background-image: none;
|
|
390
|
+
border: 1px solid var(--md-border-color);
|
|
391
|
+
transition: all 0.2s;
|
|
392
|
+
}.cm-search .cm-textfield:focus,
|
|
393
|
+
.cm-search .cm-textfield:hover {
|
|
394
|
+
border-color: var(--md-border-hover-color);
|
|
395
|
+
outline: 0;
|
|
396
|
+
}.cm-search .cm-textfield:focus {
|
|
397
|
+
border-color: var(--md-border-active-color);
|
|
398
|
+
}.cm-search .cm-button {
|
|
399
|
+
font-weight: 400;
|
|
400
|
+
text-align: center;
|
|
401
|
+
vertical-align: middle;
|
|
402
|
+
cursor: pointer;
|
|
403
|
+
border: 1px solid var(--md-border-color);
|
|
404
|
+
white-space: nowrap;
|
|
405
|
+
user-select: none;
|
|
406
|
+
height: 20px;
|
|
407
|
+
padding: 0 15px;
|
|
408
|
+
font-size: 10px;
|
|
409
|
+
border-radius: 4px;
|
|
410
|
+
transition: all 0.2s linear;
|
|
411
|
+
color: var(--md-color);
|
|
412
|
+
background-color: inherit;
|
|
413
|
+
background-image: none;
|
|
414
|
+
border-color: var(--md-border-color);
|
|
415
|
+
}.cm-search .cm-button:first-of-type {
|
|
416
|
+
margin-left: 0;
|
|
417
|
+
}.cm-search .cm-button:hover {
|
|
418
|
+
color: var(--md-hover-color);
|
|
419
|
+
background-color: inherit;
|
|
420
|
+
border-color: var(--md-border-hover-color);
|
|
421
|
+
}.cm-search input[type='checkbox'] {
|
|
422
|
+
vertical-align: sub;
|
|
423
|
+
}.cm-search input[type='checkbox']::after {
|
|
424
|
+
display: block;
|
|
425
|
+
content: '';
|
|
426
|
+
font-weight: bold;
|
|
427
|
+
cursor: pointer;
|
|
428
|
+
width: 12px;
|
|
429
|
+
height: 12px;
|
|
430
|
+
border: 1px solid var(--md-border-color);
|
|
431
|
+
background-color: var(--md-bk-color-outstand);
|
|
432
|
+
border-radius: 2px;
|
|
433
|
+
line-height: 1;
|
|
434
|
+
text-align: center;
|
|
435
|
+
}.cm-search input[type='checkbox']:checked::after {
|
|
436
|
+
content: '✓';
|
|
437
|
+
color: var(--md-color);
|
|
438
|
+
}.cm-search button[name='close'] {
|
|
439
|
+
color: inherit;
|
|
440
|
+
cursor: pointer;
|
|
441
|
+
right: 6px;
|
|
384
442
|
}.md-editor-catalog-editor {
|
|
385
443
|
--md-color: #3f4a54;
|
|
386
444
|
--md-hover-color: #000;
|
|
@@ -105,6 +105,10 @@ declare const Editor: import('vue').DefineComponent<{
|
|
|
105
105
|
onInputBoxWitdhChange: {
|
|
106
106
|
type: import("vue").PropType<(width: string) => void>;
|
|
107
107
|
};
|
|
108
|
+
transformImgUrl: {
|
|
109
|
+
type: import("vue").PropType<(t: string) => string>;
|
|
110
|
+
default: (t: string) => string;
|
|
111
|
+
};
|
|
108
112
|
modelValue: {
|
|
109
113
|
type: import("vue").PropType<string>;
|
|
110
114
|
default: string;
|
|
@@ -301,6 +305,10 @@ declare const Editor: import('vue').DefineComponent<{
|
|
|
301
305
|
onInputBoxWitdhChange: {
|
|
302
306
|
type: import("vue").PropType<(width: string) => void>;
|
|
303
307
|
};
|
|
308
|
+
transformImgUrl: {
|
|
309
|
+
type: import("vue").PropType<(t: string) => string>;
|
|
310
|
+
default: (t: string) => string;
|
|
311
|
+
};
|
|
304
312
|
modelValue: {
|
|
305
313
|
type: import("vue").PropType<string>;
|
|
306
314
|
default: string;
|
|
@@ -409,6 +417,7 @@ declare const Editor: import('vue').DefineComponent<{
|
|
|
409
417
|
htmlPreview: boolean;
|
|
410
418
|
class: string;
|
|
411
419
|
style: string | import("vue").CSSProperties;
|
|
420
|
+
language: string;
|
|
412
421
|
toolbars: import("~/type").ToolbarNames[];
|
|
413
422
|
toolbarsExclude: import("~/type").ToolbarNames[];
|
|
414
423
|
noPrettier: boolean;
|
|
@@ -419,9 +428,9 @@ declare const Editor: import('vue').DefineComponent<{
|
|
|
419
428
|
scrollAuto: boolean;
|
|
420
429
|
showToolbarName: boolean;
|
|
421
430
|
inputBoxWitdh: string;
|
|
431
|
+
transformImgUrl: (t: string) => string;
|
|
422
432
|
modelValue: string;
|
|
423
433
|
theme: import("~/type").Themes;
|
|
424
|
-
language: string;
|
|
425
434
|
editorId: string;
|
|
426
435
|
showCodeRowNumber: boolean;
|
|
427
436
|
previewTheme: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PropType } from 'vue';
|
|
2
2
|
|
|
3
|
-
export type IconName = 'bold' | 'underline' | 'italic' | 'strike-through' | 'title' | 'sub' | 'sup' | 'quote' | 'unordered-list' | 'ordered-list' | 'task' | 'code-row' | 'code' | 'link' | 'image' | 'table' | 'revoke' | 'next' | 'baocun' | 'prettier' | 'suoxiao' | 'fangda' | 'fullscreen-exit' | 'fullscreen' | 'preview' | 'coding' | 'catalog' | 'github' | 'mermaid' | 'formula' | 'close' | 'delete' | 'upload';
|
|
3
|
+
export type IconName = 'bold' | 'underline' | 'italic' | 'strike-through' | 'title' | 'sub' | 'sup' | 'quote' | 'unordered-list' | 'ordered-list' | 'task' | 'code-row' | 'code' | 'link' | 'image' | 'table' | 'revoke' | 'next' | 'baocun' | 'prettier' | 'suoxiao' | 'fangda' | 'fullscreen-exit' | 'fullscreen' | 'preview-only' | 'preview' | 'coding' | 'catalog' | 'github' | 'mermaid' | 'formula' | 'close' | 'delete' | 'upload';
|
|
4
4
|
declare const _default: import('vue').DefineComponent<{
|
|
5
5
|
name: {
|
|
6
6
|
type: PropType<IconName>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ContentExposeParam } from './layouts/Content/type';
|
|
2
|
-
import { SettingType, UpdateSetting, MdPreviewProps,
|
|
2
|
+
import { SettingType, UpdateSetting, MdPreviewProps, EditorProps, EditorContext } from './type';
|
|
3
3
|
import { Ref } from 'vue';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -2,8 +2,8 @@ import { CodeCss, Config, ConfigOption, Footers, StaticTextDefault } from './typ
|
|
|
2
2
|
|
|
3
3
|
export declare const prefix = "md-editor";
|
|
4
4
|
export declare const defaultEditorId = "md-editor-v3";
|
|
5
|
-
export declare const iconfontSvgUrl = "https://at.alicdn.com/t/c/
|
|
6
|
-
export declare const iconfontClassUrl = "https://at.alicdn.com/t/c/
|
|
5
|
+
export declare const iconfontSvgUrl = "https://at.alicdn.com/t/c/font_2605852_rfu1p40qggh.js";
|
|
6
|
+
export declare const iconfontClassUrl = "https://at.alicdn.com/t/c/font_2605852_rfu1p40qggh.css";
|
|
7
7
|
export declare const cdnBase = "https://cdnjs.cloudflare.com/ajax/libs";
|
|
8
8
|
export declare const highlightUrl = "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/highlight.min.js";
|
|
9
9
|
export declare const prettierUrl: {
|