md-editor-v3 4.18.1 → 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 +17 -10
- package/lib/cjs/chunks/config.cjs +2 -1
- package/lib/cjs/chunks/index.cjs +98 -109
- package/lib/es/MdEditor.mjs +18 -11
- package/lib/es/chunks/config.mjs +2 -1
- package/lib/es/chunks/index.mjs +98 -109
- package/lib/preview.css +5 -5
- package/lib/style.css +10 -8
- 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/umd/index.js +32 -32
- package/package.json +1 -1
package/lib/es/chunks/index.mjs
CHANGED
|
@@ -313,117 +313,100 @@ const mergeAttrs = (token, addAttrs) => {
|
|
|
313
313
|
});
|
|
314
314
|
return tmpAttrs;
|
|
315
315
|
};
|
|
316
|
-
const isValidDelim = (state, pos) => {
|
|
317
|
-
let can_open = true, can_close = true;
|
|
318
|
-
const max = state.posMax;
|
|
319
|
-
const prevChar = pos > 0 ? state.src.charCodeAt(pos - 1) : -1;
|
|
320
|
-
const nextChar = pos + 1 <= max ? state.src.charCodeAt(pos + 1) : -1;
|
|
321
|
-
if (prevChar === 32 || prevChar === 9 || nextChar >= 48 && nextChar <= 57) {
|
|
322
|
-
can_close = false;
|
|
323
|
-
}
|
|
324
|
-
if (nextChar === 32 || nextChar === 9) {
|
|
325
|
-
can_open = false;
|
|
326
|
-
}
|
|
327
|
-
return {
|
|
328
|
-
can_open,
|
|
329
|
-
can_close
|
|
330
|
-
};
|
|
331
|
-
};
|
|
332
316
|
const math_inline = (state, silent) => {
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
if (
|
|
340
|
-
state.
|
|
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
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
if (!silent) {
|
|
374
|
-
state.pending += "$";
|
|
317
|
+
const delimiters = [
|
|
318
|
+
{ open: "$", close: "$" },
|
|
319
|
+
{ open: "\\(", close: "\\)" }
|
|
320
|
+
];
|
|
321
|
+
let match, token, pos;
|
|
322
|
+
for (const delim of delimiters) {
|
|
323
|
+
if (state.src.startsWith(delim.open, state.pos)) {
|
|
324
|
+
const start = state.pos + delim.open.length;
|
|
325
|
+
match = start;
|
|
326
|
+
while ((match = state.src.indexOf(delim.close, match)) !== -1) {
|
|
327
|
+
pos = match - 1;
|
|
328
|
+
while (state.src[pos] === "\\") {
|
|
329
|
+
pos -= 1;
|
|
330
|
+
}
|
|
331
|
+
if ((match - pos) % 2 == 1) {
|
|
332
|
+
break;
|
|
333
|
+
}
|
|
334
|
+
match += delim.close.length;
|
|
335
|
+
}
|
|
336
|
+
if (match === -1) {
|
|
337
|
+
if (!silent) {
|
|
338
|
+
state.pending += delim.open;
|
|
339
|
+
}
|
|
340
|
+
state.pos = start;
|
|
341
|
+
return true;
|
|
342
|
+
}
|
|
343
|
+
if (match - start === 0) {
|
|
344
|
+
if (!silent) {
|
|
345
|
+
state.pending += delim.open + delim.close;
|
|
346
|
+
}
|
|
347
|
+
state.pos = start + delim.close.length;
|
|
348
|
+
return true;
|
|
349
|
+
}
|
|
350
|
+
if (!silent) {
|
|
351
|
+
token = state.push("math_inline", "math", 0);
|
|
352
|
+
token.markup = delim.open;
|
|
353
|
+
token.content = state.src.slice(start, match);
|
|
354
|
+
}
|
|
355
|
+
state.pos = match + delim.close.length;
|
|
356
|
+
return true;
|
|
375
357
|
}
|
|
376
|
-
state.pos = start;
|
|
377
|
-
return true;
|
|
378
358
|
}
|
|
379
|
-
|
|
380
|
-
token = state.push("math_inline", "math", 0);
|
|
381
|
-
token.markup = "$";
|
|
382
|
-
token.content = state.src.slice(start, match);
|
|
383
|
-
}
|
|
384
|
-
state.pos = match + 1;
|
|
385
|
-
return true;
|
|
359
|
+
return false;
|
|
386
360
|
};
|
|
387
361
|
const math_block = (state, start, end, silent) => {
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
return true;
|
|
399
|
-
}
|
|
400
|
-
if (firstLine.trim().slice(-2) === "$$") {
|
|
401
|
-
firstLine = firstLine.trim().slice(0, -2);
|
|
402
|
-
found = true;
|
|
403
|
-
}
|
|
404
|
-
for (next = start; !found; ) {
|
|
405
|
-
next++;
|
|
406
|
-
if (next >= end) {
|
|
407
|
-
break;
|
|
362
|
+
const delimiters = [
|
|
363
|
+
{ open: "$$", close: "$$" },
|
|
364
|
+
{ open: "\\[", close: "\\]" }
|
|
365
|
+
];
|
|
366
|
+
let firstLine, lastLine, next, lastPos, found = false;
|
|
367
|
+
let pos = state.bMarks[start] + state.tShift[start];
|
|
368
|
+
let max = state.eMarks[start];
|
|
369
|
+
for (const delim of delimiters) {
|
|
370
|
+
if (pos + delim.open.length > max) {
|
|
371
|
+
continue;
|
|
408
372
|
}
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
if (pos < max && state.tShift[next] < state.blkIndent) {
|
|
412
|
-
break;
|
|
373
|
+
if (state.src.slice(pos, pos + delim.open.length) !== delim.open) {
|
|
374
|
+
continue;
|
|
413
375
|
}
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
376
|
+
pos += delim.open.length;
|
|
377
|
+
firstLine = state.src.slice(pos, max);
|
|
378
|
+
if (silent) {
|
|
379
|
+
return true;
|
|
380
|
+
}
|
|
381
|
+
if (firstLine.trim().slice(-delim.close.length) === delim.close) {
|
|
382
|
+
firstLine = firstLine.trim().slice(0, -delim.close.length);
|
|
417
383
|
found = true;
|
|
418
384
|
}
|
|
385
|
+
for (next = start; !found; ) {
|
|
386
|
+
next++;
|
|
387
|
+
if (next >= end) {
|
|
388
|
+
break;
|
|
389
|
+
}
|
|
390
|
+
pos = state.bMarks[next] + state.tShift[next];
|
|
391
|
+
max = state.eMarks[next];
|
|
392
|
+
if (pos < max && state.tShift[next] < state.blkIndent) {
|
|
393
|
+
break;
|
|
394
|
+
}
|
|
395
|
+
if (state.src.slice(pos, max).trim().slice(-delim.close.length) === delim.close) {
|
|
396
|
+
lastPos = state.src.slice(0, max).lastIndexOf(delim.close);
|
|
397
|
+
lastLine = state.src.slice(pos, lastPos);
|
|
398
|
+
found = true;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
state.line = next + 1;
|
|
402
|
+
const token = state.push("math_block", "math", 0);
|
|
403
|
+
token.block = true;
|
|
404
|
+
token.content = (firstLine && firstLine.trim() ? firstLine + "\n" : "") + state.getLines(start + 1, next, state.tShift[start], true) + (lastLine && lastLine.trim() ? lastLine : "");
|
|
405
|
+
token.map = [start, state.line];
|
|
406
|
+
token.markup = delim.open;
|
|
407
|
+
return true;
|
|
419
408
|
}
|
|
420
|
-
|
|
421
|
-
const token = state.push("math_block", "math", 0);
|
|
422
|
-
token.block = true;
|
|
423
|
-
token.content = (firstLine && firstLine.trim() ? firstLine + "\n" : "") + state.getLines(start + 1, next, state.tShift[start], true) + (lastLine && lastLine.trim() ? lastLine : "");
|
|
424
|
-
token.map = [start, state.line];
|
|
425
|
-
token.markup = "$$";
|
|
426
|
-
return true;
|
|
409
|
+
return false;
|
|
427
410
|
};
|
|
428
411
|
const KatexPlugin = (md, { katexRef }) => {
|
|
429
412
|
const katexInline = (tokens, idx, options, env, slf) => {
|
|
@@ -432,9 +415,12 @@ const KatexPlugin = (md, { katexRef }) => {
|
|
|
432
415
|
attrs: mergeAttrs(token, [["class", `${prefix}-katex-inline`]])
|
|
433
416
|
};
|
|
434
417
|
if (katexRef.value) {
|
|
435
|
-
const html = katexRef.value.renderToString(
|
|
436
|
-
|
|
437
|
-
|
|
418
|
+
const html = katexRef.value.renderToString(
|
|
419
|
+
token.content,
|
|
420
|
+
configOption.katexConfig({
|
|
421
|
+
throwOnError: false
|
|
422
|
+
})
|
|
423
|
+
);
|
|
438
424
|
return `<span ${slf.renderAttrs(tmpToken)} data-processed>${html}</span>`;
|
|
439
425
|
} else {
|
|
440
426
|
return `<span ${slf.renderAttrs(tmpToken)}>${token.content}</span>`;
|
|
@@ -446,16 +432,19 @@ const KatexPlugin = (md, { katexRef }) => {
|
|
|
446
432
|
attrs: mergeAttrs(token, [["class", `${prefix}-katex-block`]])
|
|
447
433
|
};
|
|
448
434
|
if (katexRef.value) {
|
|
449
|
-
const html = katexRef.value.renderToString(
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
435
|
+
const html = katexRef.value.renderToString(
|
|
436
|
+
token.content,
|
|
437
|
+
configOption.katexConfig({
|
|
438
|
+
throwOnError: false,
|
|
439
|
+
displayMode: true
|
|
440
|
+
})
|
|
441
|
+
);
|
|
453
442
|
return `<p ${slf.renderAttrs(tmpToken)} data-processed>${html}</p>`;
|
|
454
443
|
} else {
|
|
455
444
|
return `<p ${slf.renderAttrs(tmpToken)}>${token.content}</p>`;
|
|
456
445
|
}
|
|
457
446
|
};
|
|
458
|
-
md.inline.ruler.
|
|
447
|
+
md.inline.ruler.before("escape", "math_inline", math_inline);
|
|
459
448
|
md.block.ruler.after("blockquote", "math_block", math_block, {
|
|
460
449
|
alt: ["paragraph", "reference", "blockquote", "list"]
|
|
461
450
|
});
|
package/lib/preview.css
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
--md-color: #3f4a54;
|
|
3
3
|
--md-hover-color: #000;
|
|
4
4
|
--md-bk-color: #fff;
|
|
5
|
-
--md-bk-color-outstand: #
|
|
5
|
+
--md-bk-color-outstand: #f2f2f2;
|
|
6
6
|
--md-bk-hover-color: #f5f7fa;
|
|
7
7
|
--md-border-color: #e6e6e6;
|
|
8
8
|
--md-border-hover-color: #b9b9b9;
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
--md-color: #999;
|
|
61
61
|
--md-hover-color: #bbb;
|
|
62
62
|
--md-bk-color: #000;
|
|
63
|
-
--md-bk-color-outstand: #
|
|
63
|
+
--md-bk-color-outstand: #333;
|
|
64
64
|
--md-bk-hover-color: #1b1a1a;
|
|
65
65
|
--md-border-color: #2d2d2d;
|
|
66
66
|
--md-border-hover-color: #636262;
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
--md-color: #3f4a54;
|
|
76
76
|
--md-hover-color: #000;
|
|
77
77
|
--md-bk-color: #fff;
|
|
78
|
-
--md-bk-color-outstand: #
|
|
78
|
+
--md-bk-color-outstand: #f2f2f2;
|
|
79
79
|
--md-bk-hover-color: #f5f7fa;
|
|
80
80
|
--md-border-color: #e6e6e6;
|
|
81
81
|
--md-border-hover-color: #b9b9b9;
|
|
@@ -147,7 +147,7 @@
|
|
|
147
147
|
--md-color: #3f4a54;
|
|
148
148
|
--md-hover-color: #000;
|
|
149
149
|
--md-bk-color: #fff;
|
|
150
|
-
--md-bk-color-outstand: #
|
|
150
|
+
--md-bk-color-outstand: #f2f2f2;
|
|
151
151
|
--md-bk-hover-color: #f5f7fa;
|
|
152
152
|
--md-border-color: #e6e6e6;
|
|
153
153
|
--md-border-hover-color: #b9b9b9;
|
|
@@ -188,7 +188,7 @@
|
|
|
188
188
|
--md-color: #999;
|
|
189
189
|
--md-hover-color: #bbb;
|
|
190
190
|
--md-bk-color: #000;
|
|
191
|
-
--md-bk-color-outstand: #
|
|
191
|
+
--md-bk-color-outstand: #333;
|
|
192
192
|
--md-bk-hover-color: #1b1a1a;
|
|
193
193
|
--md-border-color: #2d2d2d;
|
|
194
194
|
--md-border-hover-color: #636262;
|
package/lib/style.css
CHANGED
|
@@ -313,9 +313,10 @@
|
|
|
313
313
|
box-sizing: content-box;
|
|
314
314
|
}.md-editor-toolbar-wrapper .md-editor-toolbar-item {
|
|
315
315
|
display: inline-block;
|
|
316
|
-
|
|
316
|
+
margin: 0 2px;
|
|
317
|
+
padding: 0 2px;
|
|
317
318
|
transition: all 0.3s;
|
|
318
|
-
border-radius:
|
|
319
|
+
border-radius: 3px;
|
|
319
320
|
cursor: pointer;
|
|
320
321
|
list-style: none;
|
|
321
322
|
user-select: none;
|
|
@@ -325,7 +326,8 @@
|
|
|
325
326
|
word-break: keep-all;
|
|
326
327
|
white-space: nowrap;
|
|
327
328
|
}.md-editor-toolbar-wrapper .md-editor-toolbar-item:hover {
|
|
328
|
-
|
|
329
|
+
background-color: var(--md-bk-color-outstand);
|
|
330
|
+
}.md-editor-toolbar-wrapper .md-editor-toolbar-active {
|
|
329
331
|
background-color: var(--md-bk-color-outstand);
|
|
330
332
|
}.md-editor-toolbar-wrapper .md-editor-toolbar-left,
|
|
331
333
|
.md-editor-toolbar-wrapper .md-editor-toolbar-right {
|
|
@@ -441,7 +443,7 @@
|
|
|
441
443
|
--md-color: #3f4a54;
|
|
442
444
|
--md-hover-color: #000;
|
|
443
445
|
--md-bk-color: #fff;
|
|
444
|
-
--md-bk-color-outstand: #
|
|
446
|
+
--md-bk-color-outstand: #f2f2f2;
|
|
445
447
|
--md-bk-hover-color: #f5f7fa;
|
|
446
448
|
--md-border-color: #e6e6e6;
|
|
447
449
|
--md-border-hover-color: #b9b9b9;
|
|
@@ -499,7 +501,7 @@
|
|
|
499
501
|
--md-color: #999;
|
|
500
502
|
--md-hover-color: #bbb;
|
|
501
503
|
--md-bk-color: #000;
|
|
502
|
-
--md-bk-color-outstand: #
|
|
504
|
+
--md-bk-color-outstand: #333;
|
|
503
505
|
--md-bk-hover-color: #1b1a1a;
|
|
504
506
|
--md-border-color: #2d2d2d;
|
|
505
507
|
--md-border-hover-color: #636262;
|
|
@@ -514,7 +516,7 @@
|
|
|
514
516
|
--md-color: #3f4a54;
|
|
515
517
|
--md-hover-color: #000;
|
|
516
518
|
--md-bk-color: #fff;
|
|
517
|
-
--md-bk-color-outstand: #
|
|
519
|
+
--md-bk-color-outstand: #f2f2f2;
|
|
518
520
|
--md-bk-hover-color: #f5f7fa;
|
|
519
521
|
--md-border-color: #e6e6e6;
|
|
520
522
|
--md-border-hover-color: #b9b9b9;
|
|
@@ -586,7 +588,7 @@
|
|
|
586
588
|
--md-color: #3f4a54;
|
|
587
589
|
--md-hover-color: #000;
|
|
588
590
|
--md-bk-color: #fff;
|
|
589
|
-
--md-bk-color-outstand: #
|
|
591
|
+
--md-bk-color-outstand: #f2f2f2;
|
|
590
592
|
--md-bk-hover-color: #f5f7fa;
|
|
591
593
|
--md-border-color: #e6e6e6;
|
|
592
594
|
--md-border-hover-color: #b9b9b9;
|
|
@@ -627,7 +629,7 @@
|
|
|
627
629
|
--md-color: #999;
|
|
628
630
|
--md-hover-color: #bbb;
|
|
629
631
|
--md-bk-color: #000;
|
|
630
|
-
--md-bk-color-outstand: #
|
|
632
|
+
--md-bk-color-outstand: #333;
|
|
631
633
|
--md-bk-hover-color: #1b1a1a;
|
|
632
634
|
--md-border-color: #2d2d2d;
|
|
633
635
|
--md-border-hover-color: #636262;
|
|
@@ -43,6 +43,9 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
43
43
|
showToolbarName: {
|
|
44
44
|
type: import("vue").PropType<boolean>;
|
|
45
45
|
};
|
|
46
|
+
catalogVisible: {
|
|
47
|
+
type: import("vue").PropType<boolean>;
|
|
48
|
+
};
|
|
46
49
|
}, () => import("vue/jsx-runtime").JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
47
50
|
noPrettier: {
|
|
48
51
|
type: import("vue").PropType<boolean>;
|
|
@@ -86,6 +89,9 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
86
89
|
showToolbarName: {
|
|
87
90
|
type: import("vue").PropType<boolean>;
|
|
88
91
|
};
|
|
92
|
+
catalogVisible: {
|
|
93
|
+
type: import("vue").PropType<boolean>;
|
|
94
|
+
};
|
|
89
95
|
}>>, {
|
|
90
96
|
toolbars: ToolbarNames[];
|
|
91
97
|
toolbarsExclude: ToolbarNames[];
|
|
@@ -306,6 +306,13 @@ export interface ConfigOption {
|
|
|
306
306
|
* @returns
|
|
307
307
|
*/
|
|
308
308
|
mermaidConfig: (base: any) => any;
|
|
309
|
+
/**
|
|
310
|
+
* katex配置
|
|
311
|
+
*
|
|
312
|
+
* @param baseConfig
|
|
313
|
+
* @returns
|
|
314
|
+
*/
|
|
315
|
+
katexConfig: (baseConfig: any) => any;
|
|
309
316
|
}
|
|
310
317
|
/**
|
|
311
318
|
* 扩展编辑器内部功能,包括marked和一些内部依赖实例,如highlight、cropper等
|