md-editor-v3 4.15.1-1 → 4.15.1-2
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/lib/cjs/chunks/index.cjs
CHANGED
|
@@ -12,6 +12,7 @@ const TaskListPlugin = require("markdown-it-task-lists");
|
|
|
12
12
|
const XSSPlugin = require("markdown-it-xss");
|
|
13
13
|
const index = require("./index4.cjs");
|
|
14
14
|
const lruCache = require("lru-cache");
|
|
15
|
+
const markdownIt = require("~/utils/markdown-it");
|
|
15
16
|
const userZoom = (props, html) => {
|
|
16
17
|
const editorId = vue.inject("editorId");
|
|
17
18
|
const { noImgZoomIn } = props;
|
|
@@ -376,38 +377,42 @@ const math_block = (state, start, end, silent) => {
|
|
|
376
377
|
token.markup = "$$";
|
|
377
378
|
return true;
|
|
378
379
|
};
|
|
379
|
-
const KatexPlugin = (md,
|
|
380
|
-
const katexInline = (
|
|
381
|
-
|
|
382
|
-
|
|
380
|
+
const KatexPlugin = (md, { katexRef }) => {
|
|
381
|
+
const katexInline = (tokens, idx, options, env, slf) => {
|
|
382
|
+
const token = tokens[idx];
|
|
383
|
+
const tmpToken = {
|
|
384
|
+
attrs: markdownIt.mergeAttrs(token, [["class", `${config.prefix}-katex-inline`]])
|
|
385
|
+
};
|
|
386
|
+
if (katexRef.value) {
|
|
387
|
+
const html = katexRef.value.renderToString(token.content, {
|
|
383
388
|
throwOnError: false
|
|
384
389
|
});
|
|
385
|
-
return `<span
|
|
390
|
+
return `<span ${slf.renderAttrs(tmpToken)} data-processed>${html}</span>`;
|
|
386
391
|
} else {
|
|
387
|
-
return `<span
|
|
392
|
+
return `<span ${slf.renderAttrs(tmpToken)}>${token.content}</span>`;
|
|
388
393
|
}
|
|
389
394
|
};
|
|
390
|
-
const katexBlock = (
|
|
391
|
-
|
|
392
|
-
|
|
395
|
+
const katexBlock = (tokens, idx, options, env, slf) => {
|
|
396
|
+
const token = tokens[idx];
|
|
397
|
+
const tmpToken = {
|
|
398
|
+
attrs: markdownIt.mergeAttrs(token, [["class", `${config.prefix}-katex-block`]])
|
|
399
|
+
};
|
|
400
|
+
if (katexRef.value) {
|
|
401
|
+
const html = katexRef.value.renderToString(token.content, {
|
|
393
402
|
throwOnError: false,
|
|
394
403
|
displayMode: true
|
|
395
404
|
});
|
|
396
|
-
return `<p
|
|
405
|
+
return `<p ${slf.renderAttrs(tmpToken)} data-processed>${html}</p>`;
|
|
397
406
|
} else {
|
|
398
|
-
return `<p
|
|
407
|
+
return `<p ${slf.renderAttrs(tmpToken)}>${token.content}</p>`;
|
|
399
408
|
}
|
|
400
409
|
};
|
|
401
410
|
md.inline.ruler.after("escape", "math_inline", math_inline);
|
|
402
411
|
md.block.ruler.after("blockquote", "math_block", math_block, {
|
|
403
412
|
alt: ["paragraph", "reference", "blockquote", "list"]
|
|
404
413
|
});
|
|
405
|
-
md.renderer.rules.math_inline =
|
|
406
|
-
|
|
407
|
-
};
|
|
408
|
-
md.renderer.rules.math_block = (tokens, idx) => {
|
|
409
|
-
return katexBlock(tokens[idx].content, tokens[idx].map[0]) + "\n";
|
|
410
|
-
};
|
|
414
|
+
md.renderer.rules.math_inline = katexInline;
|
|
415
|
+
md.renderer.rules.math_block = katexBlock;
|
|
411
416
|
};
|
|
412
417
|
const KatexPlugin$1 = KatexPlugin;
|
|
413
418
|
const AdmonitionPlugin = (md, options) => {
|
|
@@ -421,7 +426,6 @@ const AdmonitionPlugin = (md, options) => {
|
|
|
421
426
|
"class",
|
|
422
427
|
`${config.prefix}-admonition ${config.prefix}-admonition-${token.info}`
|
|
423
428
|
]);
|
|
424
|
-
tokens[idx].attrSet("data-line", String(tokens[idx].map[0]));
|
|
425
429
|
} else if (token.type === "admonition_title_open") {
|
|
426
430
|
tokens[idx].attrPush(["class", `${config.prefix}-admonition-title`]);
|
|
427
431
|
}
|
|
@@ -545,7 +549,6 @@ const HeadingPlugin = (md, options) => {
|
|
|
545
549
|
level
|
|
546
550
|
});
|
|
547
551
|
if (token.map && token.level === 0) {
|
|
548
|
-
token.attrSet("data-line", String(token.map[0]));
|
|
549
552
|
token.attrSet(
|
|
550
553
|
"id",
|
|
551
554
|
options.mdHeadingId(text, level, options.headsRef.value.length)
|
|
@@ -558,18 +561,6 @@ const HeadingPlugin = (md, options) => {
|
|
|
558
561
|
};
|
|
559
562
|
};
|
|
560
563
|
const HeadingPlugin$1 = HeadingPlugin;
|
|
561
|
-
const mergeAttrs = (token, open) => {
|
|
562
|
-
const i = token.attrIndex("class");
|
|
563
|
-
const tmpAttrs = token.attrs ? token.attrs.slice() : [];
|
|
564
|
-
if (i < 0) {
|
|
565
|
-
tmpAttrs.push(["class", `${config.prefix}-code`]);
|
|
566
|
-
} else {
|
|
567
|
-
tmpAttrs[i] = tmpAttrs[i].slice();
|
|
568
|
-
tmpAttrs[i][1] += ` ${config.prefix}-code"`;
|
|
569
|
-
}
|
|
570
|
-
open && tmpAttrs.push(["open", ""]);
|
|
571
|
-
return tmpAttrs;
|
|
572
|
-
};
|
|
573
564
|
const codetabs = (md, _opts) => {
|
|
574
565
|
const defaultRender = md.renderer.rules.fence, unescapeAll = md.utils.unescapeAll, re = /\[(\w*)(?::([\w ]*))?\]/;
|
|
575
566
|
const getInfo = (token) => {
|
|
@@ -596,8 +587,10 @@ const codetabs = (md, _opts) => {
|
|
|
596
587
|
const [GROUP] = getGroupAndTab(tokens[idx]);
|
|
597
588
|
if (GROUP === null) {
|
|
598
589
|
const { open: open2, tagContainer: tagContainer2, tagHeader: tagHeader2 } = getTagType(tokens[idx]);
|
|
590
|
+
const addAttrs2 = [["class", `${config.prefix}-code`]];
|
|
591
|
+
open2 && addAttrs2.push(["open", ""]);
|
|
599
592
|
const tmpToken2 = {
|
|
600
|
-
attrs: mergeAttrs(tokens[idx],
|
|
593
|
+
attrs: markdownIt.mergeAttrs(tokens[idx], addAttrs2)
|
|
601
594
|
};
|
|
602
595
|
const codeRendered = defaultRender(tokens, idx, options, env, slf);
|
|
603
596
|
return `<${tagContainer2} ${slf.renderAttrs(tmpToken2)}>
|
|
@@ -615,8 +608,10 @@ const codetabs = (md, _opts) => {
|
|
|
615
608
|
}
|
|
616
609
|
let token, group, tab, checked, labels = "", pres = "", langs = "";
|
|
617
610
|
const { open, tagContainer, tagHeader } = getTagType(tokens[idx]);
|
|
611
|
+
const addAttrs = [["class", `${config.prefix}-code`]];
|
|
612
|
+
open && addAttrs.push(["open", ""]);
|
|
618
613
|
const tmpToken = {
|
|
619
|
-
attrs: mergeAttrs(tokens[idx],
|
|
614
|
+
attrs: markdownIt.mergeAttrs(tokens[idx], addAttrs)
|
|
620
615
|
};
|
|
621
616
|
for (let i = idx; i < tokens.length; i++) {
|
|
622
617
|
token = tokens[i];
|
package/lib/es/chunks/index.mjs
CHANGED
|
@@ -11,6 +11,7 @@ import TaskListPlugin from "markdown-it-task-lists";
|
|
|
11
11
|
import XSSPlugin from "markdown-it-xss";
|
|
12
12
|
import { b as generateCodeRowNumber, c as getNextId } from "./index4.mjs";
|
|
13
13
|
import { LRUCache } from "lru-cache";
|
|
14
|
+
import { mergeAttrs } from "~/utils/markdown-it";
|
|
14
15
|
const userZoom = (props, html) => {
|
|
15
16
|
const editorId = inject("editorId");
|
|
16
17
|
const { noImgZoomIn } = props;
|
|
@@ -375,38 +376,42 @@ const math_block = (state, start, end, silent) => {
|
|
|
375
376
|
token.markup = "$$";
|
|
376
377
|
return true;
|
|
377
378
|
};
|
|
378
|
-
const KatexPlugin = (md,
|
|
379
|
-
const katexInline = (
|
|
380
|
-
|
|
381
|
-
|
|
379
|
+
const KatexPlugin = (md, { katexRef }) => {
|
|
380
|
+
const katexInline = (tokens, idx, options, env, slf) => {
|
|
381
|
+
const token = tokens[idx];
|
|
382
|
+
const tmpToken = {
|
|
383
|
+
attrs: mergeAttrs(token, [["class", `${prefix}-katex-inline`]])
|
|
384
|
+
};
|
|
385
|
+
if (katexRef.value) {
|
|
386
|
+
const html = katexRef.value.renderToString(token.content, {
|
|
382
387
|
throwOnError: false
|
|
383
388
|
});
|
|
384
|
-
return `<span
|
|
389
|
+
return `<span ${slf.renderAttrs(tmpToken)} data-processed>${html}</span>`;
|
|
385
390
|
} else {
|
|
386
|
-
return `<span
|
|
391
|
+
return `<span ${slf.renderAttrs(tmpToken)}>${token.content}</span>`;
|
|
387
392
|
}
|
|
388
393
|
};
|
|
389
|
-
const katexBlock = (
|
|
390
|
-
|
|
391
|
-
|
|
394
|
+
const katexBlock = (tokens, idx, options, env, slf) => {
|
|
395
|
+
const token = tokens[idx];
|
|
396
|
+
const tmpToken = {
|
|
397
|
+
attrs: mergeAttrs(token, [["class", `${prefix}-katex-block`]])
|
|
398
|
+
};
|
|
399
|
+
if (katexRef.value) {
|
|
400
|
+
const html = katexRef.value.renderToString(token.content, {
|
|
392
401
|
throwOnError: false,
|
|
393
402
|
displayMode: true
|
|
394
403
|
});
|
|
395
|
-
return `<p
|
|
404
|
+
return `<p ${slf.renderAttrs(tmpToken)} data-processed>${html}</p>`;
|
|
396
405
|
} else {
|
|
397
|
-
return `<p
|
|
406
|
+
return `<p ${slf.renderAttrs(tmpToken)}>${token.content}</p>`;
|
|
398
407
|
}
|
|
399
408
|
};
|
|
400
409
|
md.inline.ruler.after("escape", "math_inline", math_inline);
|
|
401
410
|
md.block.ruler.after("blockquote", "math_block", math_block, {
|
|
402
411
|
alt: ["paragraph", "reference", "blockquote", "list"]
|
|
403
412
|
});
|
|
404
|
-
md.renderer.rules.math_inline =
|
|
405
|
-
|
|
406
|
-
};
|
|
407
|
-
md.renderer.rules.math_block = (tokens, idx) => {
|
|
408
|
-
return katexBlock(tokens[idx].content, tokens[idx].map[0]) + "\n";
|
|
409
|
-
};
|
|
413
|
+
md.renderer.rules.math_inline = katexInline;
|
|
414
|
+
md.renderer.rules.math_block = katexBlock;
|
|
410
415
|
};
|
|
411
416
|
const KatexPlugin$1 = KatexPlugin;
|
|
412
417
|
const AdmonitionPlugin = (md, options) => {
|
|
@@ -420,7 +425,6 @@ const AdmonitionPlugin = (md, options) => {
|
|
|
420
425
|
"class",
|
|
421
426
|
`${prefix}-admonition ${prefix}-admonition-${token.info}`
|
|
422
427
|
]);
|
|
423
|
-
tokens[idx].attrSet("data-line", String(tokens[idx].map[0]));
|
|
424
428
|
} else if (token.type === "admonition_title_open") {
|
|
425
429
|
tokens[idx].attrPush(["class", `${prefix}-admonition-title`]);
|
|
426
430
|
}
|
|
@@ -544,7 +548,6 @@ const HeadingPlugin = (md, options) => {
|
|
|
544
548
|
level
|
|
545
549
|
});
|
|
546
550
|
if (token.map && token.level === 0) {
|
|
547
|
-
token.attrSet("data-line", String(token.map[0]));
|
|
548
551
|
token.attrSet(
|
|
549
552
|
"id",
|
|
550
553
|
options.mdHeadingId(text, level, options.headsRef.value.length)
|
|
@@ -557,18 +560,6 @@ const HeadingPlugin = (md, options) => {
|
|
|
557
560
|
};
|
|
558
561
|
};
|
|
559
562
|
const HeadingPlugin$1 = HeadingPlugin;
|
|
560
|
-
const mergeAttrs = (token, open) => {
|
|
561
|
-
const i = token.attrIndex("class");
|
|
562
|
-
const tmpAttrs = token.attrs ? token.attrs.slice() : [];
|
|
563
|
-
if (i < 0) {
|
|
564
|
-
tmpAttrs.push(["class", `${prefix}-code`]);
|
|
565
|
-
} else {
|
|
566
|
-
tmpAttrs[i] = tmpAttrs[i].slice();
|
|
567
|
-
tmpAttrs[i][1] += ` ${prefix}-code"`;
|
|
568
|
-
}
|
|
569
|
-
open && tmpAttrs.push(["open", ""]);
|
|
570
|
-
return tmpAttrs;
|
|
571
|
-
};
|
|
572
563
|
const codetabs = (md, _opts) => {
|
|
573
564
|
const defaultRender = md.renderer.rules.fence, unescapeAll = md.utils.unescapeAll, re = /\[(\w*)(?::([\w ]*))?\]/;
|
|
574
565
|
const getInfo = (token) => {
|
|
@@ -595,8 +586,10 @@ const codetabs = (md, _opts) => {
|
|
|
595
586
|
const [GROUP] = getGroupAndTab(tokens[idx]);
|
|
596
587
|
if (GROUP === null) {
|
|
597
588
|
const { open: open2, tagContainer: tagContainer2, tagHeader: tagHeader2 } = getTagType(tokens[idx]);
|
|
589
|
+
const addAttrs2 = [["class", `${prefix}-code`]];
|
|
590
|
+
open2 && addAttrs2.push(["open", ""]);
|
|
598
591
|
const tmpToken2 = {
|
|
599
|
-
attrs: mergeAttrs(tokens[idx],
|
|
592
|
+
attrs: mergeAttrs(tokens[idx], addAttrs2)
|
|
600
593
|
};
|
|
601
594
|
const codeRendered = defaultRender(tokens, idx, options, env, slf);
|
|
602
595
|
return `<${tagContainer2} ${slf.renderAttrs(tmpToken2)}>
|
|
@@ -614,8 +607,10 @@ const codetabs = (md, _opts) => {
|
|
|
614
607
|
}
|
|
615
608
|
let token, group, tab, checked, labels = "", pres = "", langs = "";
|
|
616
609
|
const { open, tagContainer, tagHeader } = getTagType(tokens[idx]);
|
|
610
|
+
const addAttrs = [["class", `${prefix}-code`]];
|
|
611
|
+
open && addAttrs.push(["open", ""]);
|
|
617
612
|
const tmpToken = {
|
|
618
|
-
attrs: mergeAttrs(tokens[idx],
|
|
613
|
+
attrs: mergeAttrs(tokens[idx], addAttrs)
|
|
619
614
|
};
|
|
620
615
|
for (let i = idx; i < tokens.length; i++) {
|
|
621
616
|
token = tokens[i];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { default as markdownit } from 'markdown-it';
|
|
2
2
|
import { ShallowRef } from 'vue';
|
|
3
3
|
|
|
4
|
-
declare const KatexPlugin: (md: markdownit,
|
|
4
|
+
declare const KatexPlugin: (md: markdownit, { katexRef }: {
|
|
5
5
|
katexRef: ShallowRef;
|
|
6
6
|
}) => void;
|
|
7
7
|
export default KatexPlugin;
|