md-editor-v3 4.18.0 → 4.19.0-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 +18 -1
- package/lib/cjs/MdEditor.cjs +20 -11
- package/lib/cjs/chunks/config.cjs +2 -1
- package/lib/cjs/chunks/index.cjs +107 -114
- package/lib/es/MdEditor.mjs +22 -13
- package/lib/es/chunks/config.mjs +2 -1
- package/lib/es/chunks/index.mjs +107 -114
- package/lib/preview.css +5 -5
- package/lib/style.css +10 -8
- package/lib/types/MdEditor/layouts/Content/markdownIt/mermaid/index.d.ts +1 -1
- package/lib/types/MdEditor/layouts/Toolbar/index.d.ts +6 -0
- package/lib/types/MdEditor/layouts/Toolbar/props.d.ts +3 -0
- package/lib/types/MdEditor/type.d.ts +7 -0
- package/lib/types/MdEditor/utils/cache.d.ts +2 -0
- package/lib/umd/index.js +52 -52
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -768,6 +768,23 @@ config({
|
|
|
768
768
|
});
|
|
769
769
|
```
|
|
770
770
|
|
|
771
|
+
### 🔧 katexConfig
|
|
772
|
+
|
|
773
|
+
Configure `katex`, [Details](https://katex.org/docs/options)
|
|
774
|
+
|
|
775
|
+
```js
|
|
776
|
+
import { config } from 'md-editor-v3';
|
|
777
|
+
|
|
778
|
+
config({
|
|
779
|
+
katexConfig(base: any) {
|
|
780
|
+
return {
|
|
781
|
+
...base,
|
|
782
|
+
strict: false
|
|
783
|
+
};
|
|
784
|
+
}
|
|
785
|
+
});
|
|
786
|
+
```
|
|
787
|
+
|
|
771
788
|
## 🪡 Shortcut Key
|
|
772
789
|
|
|
773
790
|
_Pay attention: shortcut keys are only available when the textarea has received focus!_
|
|
@@ -1008,7 +1025,7 @@ const onUploadImg = async (files, callback) => {
|
|
|
1008
1025
|
--md-color: if(@isDark, #999, #222);
|
|
1009
1026
|
--md-hover-color: if(@isDark, #bbb, #000);
|
|
1010
1027
|
--md-bk-color: if(@isDark, #000, #fff);
|
|
1011
|
-
--md-bk-color-outstand: if(@isDark, #
|
|
1028
|
+
--md-bk-color-outstand: if(@isDark, #333, #f2f2f2);
|
|
1012
1029
|
--md-bk-hover-color: if(@isDark, #1b1a1a, #f5f7fa);
|
|
1013
1030
|
--md-border-color: if(@isDark, #2d2d2d, #e6e6e6);
|
|
1014
1031
|
--md-border-hover-color: if(@isDark, #636262, #b9b9b9);
|
package/lib/cjs/MdEditor.cjs
CHANGED
|
@@ -83,6 +83,9 @@ const toolbarProps = {
|
|
|
83
83
|
*/
|
|
84
84
|
showToolbarName: {
|
|
85
85
|
type: Boolean
|
|
86
|
+
},
|
|
87
|
+
catalogVisible: {
|
|
88
|
+
type: Boolean
|
|
86
89
|
}
|
|
87
90
|
};
|
|
88
91
|
const useSreenfull = (props2) => {
|
|
@@ -167,8 +170,11 @@ const TableShape = /* @__PURE__ */ vue.defineComponent({
|
|
|
167
170
|
x: -1,
|
|
168
171
|
y: -1
|
|
169
172
|
});
|
|
173
|
+
const tableShapeStr = vue.computed(() => {
|
|
174
|
+
return JSON.stringify(props2.tableShape);
|
|
175
|
+
});
|
|
170
176
|
const initShape = () => {
|
|
171
|
-
const shape = [...
|
|
177
|
+
const shape = [...JSON.parse(tableShapeStr.value)];
|
|
172
178
|
if (!shape[2] || shape[2] < shape[0]) {
|
|
173
179
|
shape[2] = shape[0];
|
|
174
180
|
}
|
|
@@ -178,7 +184,7 @@ const TableShape = /* @__PURE__ */ vue.defineComponent({
|
|
|
178
184
|
return shape;
|
|
179
185
|
};
|
|
180
186
|
const tableShape = vue.ref(initShape());
|
|
181
|
-
vue.watch(
|
|
187
|
+
vue.watch([tableShapeStr], () => {
|
|
182
188
|
tableShape.value = initShape();
|
|
183
189
|
});
|
|
184
190
|
return () => vue.createVNode("div", {
|
|
@@ -948,7 +954,7 @@ const ToolBar = /* @__PURE__ */ vue.defineComponent({
|
|
|
948
954
|
}
|
|
949
955
|
case "pageFullscreen": {
|
|
950
956
|
return !props2.setting.fullscreen && vue.createVNode("div", {
|
|
951
|
-
"class": `${config.prefix}-toolbar-item`,
|
|
957
|
+
"class": [`${config.prefix}-toolbar-item`, props2.setting.pageFullscreen && `${config.prefix}-toolbar-active`],
|
|
952
958
|
"title": (_T = ult.value.toolbarTips) == null ? void 0 : _T.pageFullscreen,
|
|
953
959
|
"onClick": () => {
|
|
954
960
|
props2.updateSetting("pageFullscreen");
|
|
@@ -961,7 +967,7 @@ const ToolBar = /* @__PURE__ */ vue.defineComponent({
|
|
|
961
967
|
}
|
|
962
968
|
case "fullscreen": {
|
|
963
969
|
return vue.createVNode("div", {
|
|
964
|
-
"class": `${config.prefix}-toolbar-item`,
|
|
970
|
+
"class": [`${config.prefix}-toolbar-item`, props2.setting.fullscreen && `${config.prefix}-toolbar-active`],
|
|
965
971
|
"title": (_V = ult.value.toolbarTips) == null ? void 0 : _V.fullscreen,
|
|
966
972
|
"onClick": () => {
|
|
967
973
|
fullscreenHandler();
|
|
@@ -974,7 +980,7 @@ const ToolBar = /* @__PURE__ */ vue.defineComponent({
|
|
|
974
980
|
}
|
|
975
981
|
case "preview": {
|
|
976
982
|
return vue.createVNode("div", {
|
|
977
|
-
"class": `${config.prefix}-toolbar-item`,
|
|
983
|
+
"class": [`${config.prefix}-toolbar-item`, props2.setting.preview && `${config.prefix}-toolbar-active`],
|
|
978
984
|
"title": (_X = ult.value.toolbarTips) == null ? void 0 : _X.preview,
|
|
979
985
|
"onClick": () => {
|
|
980
986
|
props2.updateSetting("preview");
|
|
@@ -987,7 +993,7 @@ const ToolBar = /* @__PURE__ */ vue.defineComponent({
|
|
|
987
993
|
}
|
|
988
994
|
case "previewOnly": {
|
|
989
995
|
return vue.createVNode("div", {
|
|
990
|
-
"class": `${config.prefix}-toolbar-item`,
|
|
996
|
+
"class": [`${config.prefix}-toolbar-item`, props2.setting.previewOnly && `${config.prefix}-toolbar-active`],
|
|
991
997
|
"title": (_Z = ult.value.toolbarTips) == null ? void 0 : _Z.previewOnly,
|
|
992
998
|
"onClick": () => {
|
|
993
999
|
props2.updateSetting("previewOnly");
|
|
@@ -1000,7 +1006,7 @@ const ToolBar = /* @__PURE__ */ vue.defineComponent({
|
|
|
1000
1006
|
}
|
|
1001
1007
|
case "htmlPreview": {
|
|
1002
1008
|
return vue.createVNode("div", {
|
|
1003
|
-
"class": `${config.prefix}-toolbar-item`,
|
|
1009
|
+
"class": [`${config.prefix}-toolbar-item`, props2.setting.htmlPreview && `${config.prefix}-toolbar-active`],
|
|
1004
1010
|
"title": (_$ = ult.value.toolbarTips) == null ? void 0 : _$.htmlPreview,
|
|
1005
1011
|
"onClick": () => {
|
|
1006
1012
|
props2.updateSetting("htmlPreview");
|
|
@@ -1013,7 +1019,7 @@ const ToolBar = /* @__PURE__ */ vue.defineComponent({
|
|
|
1013
1019
|
}
|
|
1014
1020
|
case "catalog": {
|
|
1015
1021
|
return vue.createVNode("div", {
|
|
1016
|
-
"class": `${config.prefix}-toolbar-item`,
|
|
1022
|
+
"class": [`${config.prefix}-toolbar-item`, props2.catalogVisible && `${config.prefix}-toolbar-active`],
|
|
1017
1023
|
"title": (_ba = ult.value.toolbarTips) == null ? void 0 : _ba.catalog,
|
|
1018
1024
|
"onClick": () => {
|
|
1019
1025
|
eventName.bus.emit(editorId, eventName.CHANGE_CATALOG_VISIBLE);
|
|
@@ -2081,7 +2087,7 @@ const createAutocompletion = (completions) => {
|
|
|
2081
2087
|
from: word.from,
|
|
2082
2088
|
options: [
|
|
2083
2089
|
// 标题
|
|
2084
|
-
...["
|
|
2090
|
+
...["h2", "h3", "h4", "h5", "h6"].map((key, index2) => {
|
|
2085
2091
|
const label = new Array(index2 + 1).fill("#").join("");
|
|
2086
2092
|
return {
|
|
2087
2093
|
label,
|
|
@@ -2678,7 +2684,9 @@ const useCodeMirror = (props2) => {
|
|
|
2678
2684
|
}
|
|
2679
2685
|
}
|
|
2680
2686
|
}),
|
|
2681
|
-
eventComp.of(codemirror.EditorView.domEventHandlers(domEventHandlers))
|
|
2687
|
+
eventComp.of(codemirror.EditorView.domEventHandlers(domEventHandlers)),
|
|
2688
|
+
// 解决多行placeholder时,光标异常的情况
|
|
2689
|
+
view.drawSelection()
|
|
2682
2690
|
];
|
|
2683
2691
|
const getExtensions = () => {
|
|
2684
2692
|
const extensions = [
|
|
@@ -3207,7 +3215,8 @@ const Editor = /* @__PURE__ */ vue.defineComponent({
|
|
|
3207
3215
|
"tableShape": props2.tableShape,
|
|
3208
3216
|
"defToolbars": defToolbars,
|
|
3209
3217
|
"noUploadImg": noUploadImg,
|
|
3210
|
-
"showToolbarName": props2.showToolbarName
|
|
3218
|
+
"showToolbarName": props2.showToolbarName,
|
|
3219
|
+
"catalogVisible": catalogVisible.value
|
|
3211
3220
|
}, null), vue.createVNode(Content, {
|
|
3212
3221
|
"ref": codeRef,
|
|
3213
3222
|
"modelValue": props2.modelValue,
|
|
@@ -432,7 +432,8 @@ const configOption = {
|
|
|
432
432
|
},
|
|
433
433
|
markdownItPlugins: (s) => s,
|
|
434
434
|
iconfontType: "svg",
|
|
435
|
-
mermaidConfig: (c) => c
|
|
435
|
+
mermaidConfig: (c) => c,
|
|
436
|
+
katexConfig: (c) => c
|
|
436
437
|
};
|
|
437
438
|
const config = (option) => {
|
|
438
439
|
return util.deepMerge(configOption, option);
|
package/lib/cjs/chunks/index.cjs
CHANGED
|
@@ -140,16 +140,16 @@ const useHighlight = (props) => {
|
|
|
140
140
|
);
|
|
141
141
|
return hljsRef;
|
|
142
142
|
};
|
|
143
|
+
const mermaidCache = new lruCache.LRUCache({
|
|
144
|
+
max: 1e3,
|
|
145
|
+
// 缓存10分钟
|
|
146
|
+
ttl: 6e5
|
|
147
|
+
});
|
|
143
148
|
const useMermaid = (props) => {
|
|
144
149
|
const theme = vue.inject("theme");
|
|
145
150
|
const { editorExtensions, editorExtensionsAttrs, mermaidConfig } = config.configOption;
|
|
146
151
|
const mermaidRef = vue.shallowRef(editorExtensions.mermaid.instance);
|
|
147
152
|
const reRenderRef = vue.shallowRef(-1);
|
|
148
|
-
const mermaidCache = new lruCache.LRUCache({
|
|
149
|
-
max: 1e3,
|
|
150
|
-
// 缓存10分钟
|
|
151
|
-
ttl: 6e5
|
|
152
|
-
});
|
|
153
153
|
const configMermaid = () => {
|
|
154
154
|
const mermaid = mermaidRef.value;
|
|
155
155
|
if (!props.noMermaid && mermaid) {
|
|
@@ -291,6 +291,10 @@ const MermaidPlugin = (md, options) => {
|
|
|
291
291
|
line = tokens[idx].map[0];
|
|
292
292
|
tokens[idx].attrSet("data-line", String(line));
|
|
293
293
|
}
|
|
294
|
+
const mermaidHtml = mermaidCache.get(code);
|
|
295
|
+
if (mermaidHtml) {
|
|
296
|
+
return `<p class="${config.prefix}-mermaid" ${line !== void 0 ? "data-line=" + line : ""} data-processed>${mermaidHtml}</p>`;
|
|
297
|
+
}
|
|
294
298
|
return `<div class="${config.prefix}-mermaid" ${line !== void 0 ? "data-line=" + line : ""} data-mermaid-theme=${options.themeRef.value}>${code}</div>`;
|
|
295
299
|
}
|
|
296
300
|
return temp(tokens, idx, ops, env, slf);
|
|
@@ -310,117 +314,100 @@ const mergeAttrs = (token, addAttrs) => {
|
|
|
310
314
|
});
|
|
311
315
|
return tmpAttrs;
|
|
312
316
|
};
|
|
313
|
-
const isValidDelim = (state, pos) => {
|
|
314
|
-
let can_open = true, can_close = true;
|
|
315
|
-
const max = state.posMax;
|
|
316
|
-
const prevChar = pos > 0 ? state.src.charCodeAt(pos - 1) : -1;
|
|
317
|
-
const nextChar = pos + 1 <= max ? state.src.charCodeAt(pos + 1) : -1;
|
|
318
|
-
if (prevChar === 32 || prevChar === 9 || nextChar >= 48 && nextChar <= 57) {
|
|
319
|
-
can_close = false;
|
|
320
|
-
}
|
|
321
|
-
if (nextChar === 32 || nextChar === 9) {
|
|
322
|
-
can_open = false;
|
|
323
|
-
}
|
|
324
|
-
return {
|
|
325
|
-
can_open,
|
|
326
|
-
can_close
|
|
327
|
-
};
|
|
328
|
-
};
|
|
329
317
|
const math_inline = (state, silent) => {
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
if (
|
|
337
|
-
state.
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
if (!silent) {
|
|
371
|
-
state.pending += "$";
|
|
318
|
+
const delimiters = [
|
|
319
|
+
{ open: "$", close: "$" },
|
|
320
|
+
{ open: "\\(", close: "\\)" }
|
|
321
|
+
];
|
|
322
|
+
let match, token, pos;
|
|
323
|
+
for (const delim of delimiters) {
|
|
324
|
+
if (state.src.startsWith(delim.open, state.pos)) {
|
|
325
|
+
const start = state.pos + delim.open.length;
|
|
326
|
+
match = start;
|
|
327
|
+
while ((match = state.src.indexOf(delim.close, match)) !== -1) {
|
|
328
|
+
pos = match - 1;
|
|
329
|
+
while (state.src[pos] === "\\") {
|
|
330
|
+
pos -= 1;
|
|
331
|
+
}
|
|
332
|
+
if ((match - pos) % 2 == 1) {
|
|
333
|
+
break;
|
|
334
|
+
}
|
|
335
|
+
match += delim.close.length;
|
|
336
|
+
}
|
|
337
|
+
if (match === -1) {
|
|
338
|
+
if (!silent) {
|
|
339
|
+
state.pending += delim.open;
|
|
340
|
+
}
|
|
341
|
+
state.pos = start;
|
|
342
|
+
return true;
|
|
343
|
+
}
|
|
344
|
+
if (match - start === 0) {
|
|
345
|
+
if (!silent) {
|
|
346
|
+
state.pending += delim.open + delim.close;
|
|
347
|
+
}
|
|
348
|
+
state.pos = start + delim.close.length;
|
|
349
|
+
return true;
|
|
350
|
+
}
|
|
351
|
+
if (!silent) {
|
|
352
|
+
token = state.push("math_inline", "math", 0);
|
|
353
|
+
token.markup = delim.open;
|
|
354
|
+
token.content = state.src.slice(start, match);
|
|
355
|
+
}
|
|
356
|
+
state.pos = match + delim.close.length;
|
|
357
|
+
return true;
|
|
372
358
|
}
|
|
373
|
-
state.pos = start;
|
|
374
|
-
return true;
|
|
375
359
|
}
|
|
376
|
-
|
|
377
|
-
token = state.push("math_inline", "math", 0);
|
|
378
|
-
token.markup = "$";
|
|
379
|
-
token.content = state.src.slice(start, match);
|
|
380
|
-
}
|
|
381
|
-
state.pos = match + 1;
|
|
382
|
-
return true;
|
|
360
|
+
return false;
|
|
383
361
|
};
|
|
384
362
|
const math_block = (state, start, end, silent) => {
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
return true;
|
|
396
|
-
}
|
|
397
|
-
if (firstLine.trim().slice(-2) === "$$") {
|
|
398
|
-
firstLine = firstLine.trim().slice(0, -2);
|
|
399
|
-
found = true;
|
|
400
|
-
}
|
|
401
|
-
for (next = start; !found; ) {
|
|
402
|
-
next++;
|
|
403
|
-
if (next >= end) {
|
|
404
|
-
break;
|
|
363
|
+
const delimiters = [
|
|
364
|
+
{ open: "$$", close: "$$" },
|
|
365
|
+
{ open: "\\[", close: "\\]" }
|
|
366
|
+
];
|
|
367
|
+
let firstLine, lastLine, next, lastPos, found = false;
|
|
368
|
+
let pos = state.bMarks[start] + state.tShift[start];
|
|
369
|
+
let max = state.eMarks[start];
|
|
370
|
+
for (const delim of delimiters) {
|
|
371
|
+
if (pos + delim.open.length > max) {
|
|
372
|
+
continue;
|
|
405
373
|
}
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
374
|
+
if (state.src.slice(pos, pos + delim.open.length) !== delim.open) {
|
|
375
|
+
continue;
|
|
376
|
+
}
|
|
377
|
+
pos += delim.open.length;
|
|
378
|
+
firstLine = state.src.slice(pos, max);
|
|
379
|
+
if (silent) {
|
|
380
|
+
return true;
|
|
410
381
|
}
|
|
411
|
-
if (
|
|
412
|
-
|
|
413
|
-
lastLine = state.src.slice(pos, lastPos);
|
|
382
|
+
if (firstLine.trim().slice(-delim.close.length) === delim.close) {
|
|
383
|
+
firstLine = firstLine.trim().slice(0, -delim.close.length);
|
|
414
384
|
found = true;
|
|
415
385
|
}
|
|
386
|
+
for (next = start; !found; ) {
|
|
387
|
+
next++;
|
|
388
|
+
if (next >= end) {
|
|
389
|
+
break;
|
|
390
|
+
}
|
|
391
|
+
pos = state.bMarks[next] + state.tShift[next];
|
|
392
|
+
max = state.eMarks[next];
|
|
393
|
+
if (pos < max && state.tShift[next] < state.blkIndent) {
|
|
394
|
+
break;
|
|
395
|
+
}
|
|
396
|
+
if (state.src.slice(pos, max).trim().slice(-delim.close.length) === delim.close) {
|
|
397
|
+
lastPos = state.src.slice(0, max).lastIndexOf(delim.close);
|
|
398
|
+
lastLine = state.src.slice(pos, lastPos);
|
|
399
|
+
found = true;
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
state.line = next + 1;
|
|
403
|
+
const token = state.push("math_block", "math", 0);
|
|
404
|
+
token.block = true;
|
|
405
|
+
token.content = (firstLine && firstLine.trim() ? firstLine + "\n" : "") + state.getLines(start + 1, next, state.tShift[start], true) + (lastLine && lastLine.trim() ? lastLine : "");
|
|
406
|
+
token.map = [start, state.line];
|
|
407
|
+
token.markup = delim.open;
|
|
408
|
+
return true;
|
|
416
409
|
}
|
|
417
|
-
|
|
418
|
-
const token = state.push("math_block", "math", 0);
|
|
419
|
-
token.block = true;
|
|
420
|
-
token.content = (firstLine && firstLine.trim() ? firstLine + "\n" : "") + state.getLines(start + 1, next, state.tShift[start], true) + (lastLine && lastLine.trim() ? lastLine : "");
|
|
421
|
-
token.map = [start, state.line];
|
|
422
|
-
token.markup = "$$";
|
|
423
|
-
return true;
|
|
410
|
+
return false;
|
|
424
411
|
};
|
|
425
412
|
const KatexPlugin = (md, { katexRef }) => {
|
|
426
413
|
const katexInline = (tokens, idx, options, env, slf) => {
|
|
@@ -429,9 +416,12 @@ const KatexPlugin = (md, { katexRef }) => {
|
|
|
429
416
|
attrs: mergeAttrs(token, [["class", `${config.prefix}-katex-inline`]])
|
|
430
417
|
};
|
|
431
418
|
if (katexRef.value) {
|
|
432
|
-
const html = katexRef.value.renderToString(
|
|
433
|
-
|
|
434
|
-
|
|
419
|
+
const html = katexRef.value.renderToString(
|
|
420
|
+
token.content,
|
|
421
|
+
config.configOption.katexConfig({
|
|
422
|
+
throwOnError: false
|
|
423
|
+
})
|
|
424
|
+
);
|
|
435
425
|
return `<span ${slf.renderAttrs(tmpToken)} data-processed>${html}</span>`;
|
|
436
426
|
} else {
|
|
437
427
|
return `<span ${slf.renderAttrs(tmpToken)}>${token.content}</span>`;
|
|
@@ -443,16 +433,19 @@ const KatexPlugin = (md, { katexRef }) => {
|
|
|
443
433
|
attrs: mergeAttrs(token, [["class", `${config.prefix}-katex-block`]])
|
|
444
434
|
};
|
|
445
435
|
if (katexRef.value) {
|
|
446
|
-
const html = katexRef.value.renderToString(
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
436
|
+
const html = katexRef.value.renderToString(
|
|
437
|
+
token.content,
|
|
438
|
+
config.configOption.katexConfig({
|
|
439
|
+
throwOnError: false,
|
|
440
|
+
displayMode: true
|
|
441
|
+
})
|
|
442
|
+
);
|
|
450
443
|
return `<p ${slf.renderAttrs(tmpToken)} data-processed>${html}</p>`;
|
|
451
444
|
} else {
|
|
452
445
|
return `<p ${slf.renderAttrs(tmpToken)}>${token.content}</p>`;
|
|
453
446
|
}
|
|
454
447
|
};
|
|
455
|
-
md.inline.ruler.
|
|
448
|
+
md.inline.ruler.before("escape", "math_inline", math_inline);
|
|
456
449
|
md.block.ruler.after("blockquote", "math_block", math_block, {
|
|
457
450
|
alt: ["paragraph", "reference", "blockquote", "list"]
|
|
458
451
|
});
|
package/lib/es/MdEditor.mjs
CHANGED
|
@@ -4,7 +4,7 @@ var __publicField = (obj, key, value) => {
|
|
|
4
4
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
5
|
return value;
|
|
6
6
|
};
|
|
7
|
-
import { defineComponent, createVNode, inject, ref, onMounted, reactive,
|
|
7
|
+
import { defineComponent, createVNode, inject, ref, onMounted, reactive, computed, watch, nextTick, Fragment, cloneVNode, toRef, shallowRef, onBeforeUnmount } from "vue";
|
|
8
8
|
import { p as prefix, f as configOption, 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";
|
|
@@ -13,7 +13,7 @@ import { a as appendHandler } from "./chunks/dom.mjs";
|
|
|
13
13
|
import { M as MdModal, I as Icon } from "./chunks/index3.mjs";
|
|
14
14
|
import { b as base642File } from "./chunks/index4.mjs";
|
|
15
15
|
import { EditorView as EditorView$1 } from "codemirror";
|
|
16
|
-
import { EditorView, placeholder, keymap } from "@codemirror/view";
|
|
16
|
+
import { EditorView, placeholder, keymap, drawSelection } from "@codemirror/view";
|
|
17
17
|
import { languages } from "@codemirror/language-data";
|
|
18
18
|
import { markdown } from "@codemirror/lang-markdown";
|
|
19
19
|
import { EditorSelection, EditorState, Compartment, StateEffect } from "@codemirror/state";
|
|
@@ -82,6 +82,9 @@ const toolbarProps = {
|
|
|
82
82
|
*/
|
|
83
83
|
showToolbarName: {
|
|
84
84
|
type: Boolean
|
|
85
|
+
},
|
|
86
|
+
catalogVisible: {
|
|
87
|
+
type: Boolean
|
|
85
88
|
}
|
|
86
89
|
};
|
|
87
90
|
const useSreenfull = (props2) => {
|
|
@@ -166,8 +169,11 @@ const TableShape = /* @__PURE__ */ defineComponent({
|
|
|
166
169
|
x: -1,
|
|
167
170
|
y: -1
|
|
168
171
|
});
|
|
172
|
+
const tableShapeStr = computed(() => {
|
|
173
|
+
return JSON.stringify(props2.tableShape);
|
|
174
|
+
});
|
|
169
175
|
const initShape = () => {
|
|
170
|
-
const shape = [...
|
|
176
|
+
const shape = [...JSON.parse(tableShapeStr.value)];
|
|
171
177
|
if (!shape[2] || shape[2] < shape[0]) {
|
|
172
178
|
shape[2] = shape[0];
|
|
173
179
|
}
|
|
@@ -177,7 +183,7 @@ const TableShape = /* @__PURE__ */ defineComponent({
|
|
|
177
183
|
return shape;
|
|
178
184
|
};
|
|
179
185
|
const tableShape = ref(initShape());
|
|
180
|
-
watch(
|
|
186
|
+
watch([tableShapeStr], () => {
|
|
181
187
|
tableShape.value = initShape();
|
|
182
188
|
});
|
|
183
189
|
return () => createVNode("div", {
|
|
@@ -947,7 +953,7 @@ const ToolBar = /* @__PURE__ */ defineComponent({
|
|
|
947
953
|
}
|
|
948
954
|
case "pageFullscreen": {
|
|
949
955
|
return !props2.setting.fullscreen && createVNode("div", {
|
|
950
|
-
"class": `${prefix}-toolbar-item`,
|
|
956
|
+
"class": [`${prefix}-toolbar-item`, props2.setting.pageFullscreen && `${prefix}-toolbar-active`],
|
|
951
957
|
"title": (_T = ult.value.toolbarTips) == null ? void 0 : _T.pageFullscreen,
|
|
952
958
|
"onClick": () => {
|
|
953
959
|
props2.updateSetting("pageFullscreen");
|
|
@@ -960,7 +966,7 @@ const ToolBar = /* @__PURE__ */ defineComponent({
|
|
|
960
966
|
}
|
|
961
967
|
case "fullscreen": {
|
|
962
968
|
return createVNode("div", {
|
|
963
|
-
"class": `${prefix}-toolbar-item`,
|
|
969
|
+
"class": [`${prefix}-toolbar-item`, props2.setting.fullscreen && `${prefix}-toolbar-active`],
|
|
964
970
|
"title": (_V = ult.value.toolbarTips) == null ? void 0 : _V.fullscreen,
|
|
965
971
|
"onClick": () => {
|
|
966
972
|
fullscreenHandler();
|
|
@@ -973,7 +979,7 @@ const ToolBar = /* @__PURE__ */ defineComponent({
|
|
|
973
979
|
}
|
|
974
980
|
case "preview": {
|
|
975
981
|
return createVNode("div", {
|
|
976
|
-
"class": `${prefix}-toolbar-item`,
|
|
982
|
+
"class": [`${prefix}-toolbar-item`, props2.setting.preview && `${prefix}-toolbar-active`],
|
|
977
983
|
"title": (_X = ult.value.toolbarTips) == null ? void 0 : _X.preview,
|
|
978
984
|
"onClick": () => {
|
|
979
985
|
props2.updateSetting("preview");
|
|
@@ -986,7 +992,7 @@ const ToolBar = /* @__PURE__ */ defineComponent({
|
|
|
986
992
|
}
|
|
987
993
|
case "previewOnly": {
|
|
988
994
|
return createVNode("div", {
|
|
989
|
-
"class": `${prefix}-toolbar-item`,
|
|
995
|
+
"class": [`${prefix}-toolbar-item`, props2.setting.previewOnly && `${prefix}-toolbar-active`],
|
|
990
996
|
"title": (_Z = ult.value.toolbarTips) == null ? void 0 : _Z.previewOnly,
|
|
991
997
|
"onClick": () => {
|
|
992
998
|
props2.updateSetting("previewOnly");
|
|
@@ -999,7 +1005,7 @@ const ToolBar = /* @__PURE__ */ defineComponent({
|
|
|
999
1005
|
}
|
|
1000
1006
|
case "htmlPreview": {
|
|
1001
1007
|
return createVNode("div", {
|
|
1002
|
-
"class": `${prefix}-toolbar-item`,
|
|
1008
|
+
"class": [`${prefix}-toolbar-item`, props2.setting.htmlPreview && `${prefix}-toolbar-active`],
|
|
1003
1009
|
"title": (_$ = ult.value.toolbarTips) == null ? void 0 : _$.htmlPreview,
|
|
1004
1010
|
"onClick": () => {
|
|
1005
1011
|
props2.updateSetting("htmlPreview");
|
|
@@ -1012,7 +1018,7 @@ const ToolBar = /* @__PURE__ */ defineComponent({
|
|
|
1012
1018
|
}
|
|
1013
1019
|
case "catalog": {
|
|
1014
1020
|
return createVNode("div", {
|
|
1015
|
-
"class": `${prefix}-toolbar-item`,
|
|
1021
|
+
"class": [`${prefix}-toolbar-item`, props2.catalogVisible && `${prefix}-toolbar-active`],
|
|
1016
1022
|
"title": (_ba = ult.value.toolbarTips) == null ? void 0 : _ba.catalog,
|
|
1017
1023
|
"onClick": () => {
|
|
1018
1024
|
bus.emit(editorId, CHANGE_CATALOG_VISIBLE);
|
|
@@ -2080,7 +2086,7 @@ const createAutocompletion = (completions) => {
|
|
|
2080
2086
|
from: word.from,
|
|
2081
2087
|
options: [
|
|
2082
2088
|
// 标题
|
|
2083
|
-
...["
|
|
2089
|
+
...["h2", "h3", "h4", "h5", "h6"].map((key, index) => {
|
|
2084
2090
|
const label = new Array(index + 1).fill("#").join("");
|
|
2085
2091
|
return {
|
|
2086
2092
|
label,
|
|
@@ -2677,7 +2683,9 @@ const useCodeMirror = (props2) => {
|
|
|
2677
2683
|
}
|
|
2678
2684
|
}
|
|
2679
2685
|
}),
|
|
2680
|
-
eventComp.of(EditorView$1.domEventHandlers(domEventHandlers))
|
|
2686
|
+
eventComp.of(EditorView$1.domEventHandlers(domEventHandlers)),
|
|
2687
|
+
// 解决多行placeholder时,光标异常的情况
|
|
2688
|
+
drawSelection()
|
|
2681
2689
|
];
|
|
2682
2690
|
const getExtensions = () => {
|
|
2683
2691
|
const extensions = [
|
|
@@ -3206,7 +3214,8 @@ const Editor = /* @__PURE__ */ defineComponent({
|
|
|
3206
3214
|
"tableShape": props2.tableShape,
|
|
3207
3215
|
"defToolbars": defToolbars,
|
|
3208
3216
|
"noUploadImg": noUploadImg,
|
|
3209
|
-
"showToolbarName": props2.showToolbarName
|
|
3217
|
+
"showToolbarName": props2.showToolbarName,
|
|
3218
|
+
"catalogVisible": catalogVisible.value
|
|
3210
3219
|
}, null), createVNode(Content, {
|
|
3211
3220
|
"ref": codeRef,
|
|
3212
3221
|
"modelValue": props2.modelValue,
|
package/lib/es/chunks/config.mjs
CHANGED
|
@@ -431,7 +431,8 @@ const configOption = {
|
|
|
431
431
|
},
|
|
432
432
|
markdownItPlugins: (s) => s,
|
|
433
433
|
iconfontType: "svg",
|
|
434
|
-
mermaidConfig: (c) => c
|
|
434
|
+
mermaidConfig: (c) => c,
|
|
435
|
+
katexConfig: (c) => c
|
|
435
436
|
};
|
|
436
437
|
const config = (option) => {
|
|
437
438
|
return deepMerge(configOption, option);
|