vditor 4.0.0 → 4.0.1
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 +1 -0
- package/dist/css/content-theme/ant-design.css +7 -22
- package/dist/css/content-theme/dark.css +7 -16
- package/dist/css/content-theme/light.css +7 -15
- package/dist/css/content-theme/wechat.css +7 -19
- package/dist/index.css +102 -58
- package/dist/index.js +31 -31
- package/dist/index.min.js +1 -1
- package/dist/js/mermaid/mermaid.min.js +516 -467
- package/dist/method.js +29 -30
- package/dist/method.min.js +1 -1
- package/dist/ts/constants.d.ts +1 -0
- package/dist/types/index.d.ts +3 -0
- package/package.json +1 -1
- package/src/assets/less/_reset.less +80 -28
- package/src/assets/less/index.less +14 -20
- package/src/index.ts +1 -0
- package/src/ts/constants.ts +1 -0
- package/src/ts/export/index.ts +1 -0
- package/src/ts/markdown/mediaRender.ts +23 -38
- package/src/ts/markdown/mermaidRender.ts +1 -1
- package/src/ts/markdown/previewRender.ts +1 -0
- package/src/ts/markdown/setLute.ts +1 -0
|
@@ -152,12 +152,27 @@
|
|
|
152
152
|
margin-bottom: 16px;
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
-
blockquote {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
155
|
+
blockquote:not(.callout) {
|
|
156
|
+
position: relative;
|
|
157
|
+
display: flex;
|
|
158
|
+
flex-direction: column;
|
|
159
|
+
padding: 0 0 0 calc(0.25em + 6px);
|
|
160
|
+
color: var(--blockquote-text-color, #5f6368);
|
|
161
|
+
background-color: transparent;
|
|
162
|
+
border: 0;
|
|
159
163
|
margin: 0 0 16px 0;
|
|
160
164
|
|
|
165
|
+
&::before {
|
|
166
|
+
position: absolute;
|
|
167
|
+
top: 6px;
|
|
168
|
+
bottom: 6px;
|
|
169
|
+
left: 2px;
|
|
170
|
+
width: 0.25em;
|
|
171
|
+
content: "";
|
|
172
|
+
background-color: var(--blockquote-border-color, #e0e0e0);
|
|
173
|
+
border-radius: 6px;
|
|
174
|
+
}
|
|
175
|
+
|
|
161
176
|
& > :first-child {
|
|
162
177
|
margin-top: 0;
|
|
163
178
|
}
|
|
@@ -165,6 +180,13 @@
|
|
|
165
180
|
& > :last-child {
|
|
166
181
|
margin-bottom: 0;
|
|
167
182
|
}
|
|
183
|
+
|
|
184
|
+
& > p {
|
|
185
|
+
padding: 4px;
|
|
186
|
+
margin: 2px 0;
|
|
187
|
+
line-height: 1.625;
|
|
188
|
+
border-radius: 6px;
|
|
189
|
+
}
|
|
168
190
|
}
|
|
169
191
|
|
|
170
192
|
ins > iframe {
|
|
@@ -652,69 +674,99 @@
|
|
|
652
674
|
.vditor-reset .callout,
|
|
653
675
|
.vditor-wysiwyg blockquote.callout,
|
|
654
676
|
.vditor-ir blockquote.callout {
|
|
655
|
-
--callout-color: var(--callout-note-color, #
|
|
656
|
-
--callout-background-color: var(--callout-note-background-color, rgba(9, 105, 218, 0.08));
|
|
677
|
+
--callout-color: var(--callout-note-color, #3575f0);
|
|
657
678
|
position: relative;
|
|
679
|
+
display: flex;
|
|
680
|
+
flex-direction: column;
|
|
658
681
|
margin: 0 0 16px;
|
|
659
|
-
padding: 0.
|
|
660
|
-
color:
|
|
661
|
-
background-color: var(--callout-background-color);
|
|
682
|
+
padding: 0 0 0 calc(0.25em + 6px);
|
|
683
|
+
color: var(--blockquote-text-color, #5f6368);
|
|
662
684
|
border: 0;
|
|
663
|
-
|
|
685
|
+
|
|
686
|
+
&::before {
|
|
687
|
+
position: absolute;
|
|
688
|
+
top: 6px;
|
|
689
|
+
bottom: 6px;
|
|
690
|
+
left: 2px;
|
|
691
|
+
width: 0.25em;
|
|
692
|
+
content: "";
|
|
693
|
+
background-color: var(--callout-color);
|
|
694
|
+
border-radius: 6px;
|
|
695
|
+
}
|
|
664
696
|
|
|
665
697
|
&[data-subtype="TIP"] {
|
|
666
|
-
--callout-color: var(--callout-tip-color, #
|
|
667
|
-
--callout-background-color: var(--callout-tip-background-color, rgba(26, 127, 55, 0.08));
|
|
698
|
+
--callout-color: var(--callout-tip-color, #65b84d);
|
|
668
699
|
}
|
|
669
700
|
|
|
670
701
|
&[data-subtype="IMPORTANT"] {
|
|
671
|
-
--callout-color: var(--callout-important-color, #
|
|
672
|
-
--callout-background-color: var(--callout-important-background-color, rgba(130, 80, 223, 0.08));
|
|
702
|
+
--callout-color: var(--callout-important-color, #8957e5);
|
|
673
703
|
}
|
|
674
704
|
|
|
675
705
|
&[data-subtype="WARNING"] {
|
|
676
|
-
--callout-color: var(--callout-warning-color, #
|
|
677
|
-
--callout-background-color: var(--callout-warning-background-color, rgba(154, 103, 0, 0.08));
|
|
706
|
+
--callout-color: var(--callout-warning-color, #ff9632);
|
|
678
707
|
}
|
|
679
708
|
|
|
680
709
|
&[data-subtype="CAUTION"] {
|
|
681
|
-
--callout-color: var(--callout-caution-color, #
|
|
682
|
-
--callout-background-color: var(--callout-caution-background-color, rgba(207, 34, 46, 0.08));
|
|
710
|
+
--callout-color: var(--callout-caution-color, #d23f31);
|
|
683
711
|
}
|
|
684
712
|
|
|
685
713
|
> .callout-info {
|
|
686
714
|
display: flex;
|
|
687
715
|
align-items: center;
|
|
688
716
|
min-height: 1.5em;
|
|
689
|
-
margin:
|
|
717
|
+
margin: 2px 0;
|
|
718
|
+
padding: 4px;
|
|
690
719
|
color: var(--callout-color);
|
|
691
|
-
font-weight: 600;
|
|
692
720
|
|
|
693
721
|
.callout-icon {
|
|
694
|
-
display:
|
|
722
|
+
display: flex;
|
|
695
723
|
align-items: center;
|
|
696
|
-
|
|
724
|
+
justify-content: center;
|
|
725
|
+
width: 1.2em;
|
|
726
|
+
height: 1.2em;
|
|
727
|
+
padding: 4px;
|
|
728
|
+
line-height: 1.2em;
|
|
729
|
+
text-align: center;
|
|
730
|
+
font-variant-emoji: emoji;
|
|
731
|
+
border-radius: 6px;
|
|
732
|
+
|
|
733
|
+
&:empty {
|
|
734
|
+
display: none;
|
|
735
|
+
}
|
|
697
736
|
}
|
|
698
737
|
|
|
699
738
|
.callout-title {
|
|
739
|
+
flex: 1;
|
|
700
740
|
min-width: 1px;
|
|
741
|
+
margin-left: 4px;
|
|
742
|
+
font-size: 114%;
|
|
743
|
+
font-weight: 500;
|
|
744
|
+
opacity: 0.86;
|
|
701
745
|
}
|
|
702
746
|
|
|
703
747
|
.callout-img,
|
|
704
748
|
> .callout-img {
|
|
705
|
-
width: 1.2em;
|
|
706
749
|
height: 1.2em;
|
|
707
|
-
|
|
708
|
-
object-fit: contain;
|
|
750
|
+
width: 100%;
|
|
709
751
|
}
|
|
710
752
|
}
|
|
711
753
|
|
|
712
|
-
> .callout-
|
|
713
|
-
>
|
|
714
|
-
|
|
754
|
+
> p:not(.callout-info),
|
|
755
|
+
> .callout-content > p {
|
|
756
|
+
padding: 4px;
|
|
757
|
+
margin: 2px 0;
|
|
758
|
+
line-height: 1.625;
|
|
759
|
+
border-radius: 6px;
|
|
715
760
|
}
|
|
716
761
|
}
|
|
717
762
|
|
|
763
|
+
.vditor-wysiwyg blockquote.callout > .callout-info,
|
|
764
|
+
.vditor-ir blockquote.callout > .callout-info {
|
|
765
|
+
font-size: 114%;
|
|
766
|
+
font-weight: 500;
|
|
767
|
+
opacity: 0.86;
|
|
768
|
+
}
|
|
769
|
+
|
|
718
770
|
.vditor-wysiwyg__callout-marker {
|
|
719
771
|
display: none;
|
|
720
772
|
}
|
|
@@ -37,16 +37,13 @@
|
|
|
37
37
|
--count-background-color: rgba(27, 31, 35, 0.05);
|
|
38
38
|
--heading-border-color: #eaecef;
|
|
39
39
|
--blockquote-color: #6a737d;
|
|
40
|
-
--
|
|
41
|
-
--
|
|
42
|
-
--callout-
|
|
43
|
-
--callout-tip-
|
|
44
|
-
--callout-important-color: #
|
|
45
|
-
--callout-
|
|
46
|
-
--callout-
|
|
47
|
-
--callout-warning-background-color: rgba(154, 103, 0, 0.08);
|
|
48
|
-
--callout-caution-color: #cf222e;
|
|
49
|
-
--callout-caution-background-color: rgba(207, 34, 46, 0.08);
|
|
40
|
+
--blockquote-border-color: #e0e0e0;
|
|
41
|
+
--blockquote-text-color: #5f6368;
|
|
42
|
+
--callout-note-color: #3575f0;
|
|
43
|
+
--callout-tip-color: #65b84d;
|
|
44
|
+
--callout-important-color: #8957e5;
|
|
45
|
+
--callout-warning-color: #ff9632;
|
|
46
|
+
--callout-caution-color: #d23f31;
|
|
50
47
|
|
|
51
48
|
--ir-heading-color: #660e7a;
|
|
52
49
|
--ir-title-color: #808080;
|
|
@@ -77,16 +74,13 @@
|
|
|
77
74
|
--count-background-color: rgba(@blurColor, 0.36);
|
|
78
75
|
--heading-border-color: var(--textarea-text-color);
|
|
79
76
|
--blockquote-color: var(--toolbar-icon-color);
|
|
80
|
-
--
|
|
81
|
-
--
|
|
82
|
-
--callout-
|
|
83
|
-
--callout-tip-
|
|
84
|
-
--callout-important-color: #
|
|
85
|
-
--callout-
|
|
86
|
-
--callout-
|
|
87
|
-
--callout-warning-background-color: rgba(187, 128, 9, 0.15);
|
|
88
|
-
--callout-caution-color: #f85149;
|
|
89
|
-
--callout-caution-background-color: rgba(248, 81, 73, 0.15);
|
|
77
|
+
--blockquote-border-color: rgba(230, 230, 230, 0.1);
|
|
78
|
+
--blockquote-text-color: #9aa0a6;
|
|
79
|
+
--callout-note-color: #3575f0;
|
|
80
|
+
--callout-tip-color: #65b84d;
|
|
81
|
+
--callout-important-color: #b388ff;
|
|
82
|
+
--callout-warning-color: #ff9632;
|
|
83
|
+
--callout-caution-color: #d23f31;
|
|
90
84
|
|
|
91
85
|
--ir-heading-color: #9876aa;
|
|
92
86
|
--ir-title-color: #808080;
|
package/src/index.ts
CHANGED
|
@@ -557,6 +557,7 @@ class Vditor extends VditorMethod {
|
|
|
557
557
|
this.vditor.lute = setLute({
|
|
558
558
|
autoSpace: this.vditor.options.preview.markdown.autoSpace,
|
|
559
559
|
callout: this.vditor.options.preview.markdown.callout,
|
|
560
|
+
inlineMath: this.vditor.options.preview.markdown.inlineMath,
|
|
560
561
|
gfmAutoLink: this.vditor.options.preview.markdown.gfmAutoLink,
|
|
561
562
|
codeBlockPreview: this.vditor.options.preview.markdown
|
|
562
563
|
.codeBlockPreview,
|
package/src/ts/constants.ts
CHANGED
package/src/ts/export/index.ts
CHANGED
|
@@ -37,6 +37,7 @@ window.addEventListener("message", (e) => {
|
|
|
37
37
|
cdn: "${vditor.options.cdn}",
|
|
38
38
|
markdown: {
|
|
39
39
|
callout: ${JSON.stringify(vditor.options.preview.markdown.callout)},
|
|
40
|
+
inlineMath: ${JSON.stringify(vditor.options.preview.markdown.inlineMath)},
|
|
40
41
|
theme: ${JSON.stringify(vditor.options.preview.theme)}
|
|
41
42
|
},
|
|
42
43
|
hljs: {
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import {getSearch} from "../util/function";
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
const replaceMedia = (element: HTMLElement, tag: "video" | "audio" | "iframe", url: string) => {
|
|
4
|
+
const media = element.ownerDocument.createElement(tag);
|
|
5
|
+
if (tag === "iframe") {
|
|
6
|
+
media.className = "iframe__video";
|
|
7
|
+
} else {
|
|
8
|
+
media.setAttribute("controls", "controls");
|
|
9
|
+
}
|
|
10
|
+
// 链接属性经 DOM 解码后可能包含引号,直接设置属性以保留 URL 的数据语义。
|
|
11
|
+
media.setAttribute("src", url);
|
|
12
|
+
element.replaceWith(media);
|
|
11
13
|
};
|
|
12
14
|
|
|
13
15
|
const iframeRender = (element: HTMLElement, url: string) => {
|
|
@@ -21,33 +23,20 @@ const iframeRender = (element: HTMLElement, url: string) => {
|
|
|
21
23
|
const tedMatch = url.match(/(?:www\.|\/\/)ted\.com\/talks\/(\w+)/);
|
|
22
24
|
|
|
23
25
|
if (youtubeMatch && youtubeMatch[1].length === 11) {
|
|
24
|
-
element
|
|
25
|
-
|
|
26
|
-
(youtubeMatch[2] ? "?start=" + youtubeMatch[2] : "")}"></iframe>`);
|
|
27
|
-
element.remove();
|
|
26
|
+
replaceMedia(element, "iframe", `//www.youtube.com/embed/${youtubeMatch[1] +
|
|
27
|
+
(youtubeMatch[2] ? "?start=" + youtubeMatch[2] : "")}`);
|
|
28
28
|
} else if (youkuMatch && youkuMatch[1]) {
|
|
29
|
-
element
|
|
30
|
-
`<iframe class="iframe__video" src="//player.youku.com/embed/${youkuMatch[1]}"></iframe>`);
|
|
31
|
-
element.remove();
|
|
29
|
+
replaceMedia(element, "iframe", `//player.youku.com/embed/${youkuMatch[1]}`);
|
|
32
30
|
} else if (qqMatch && qqMatch[1]) {
|
|
33
|
-
element
|
|
34
|
-
`<iframe class="iframe__video" src="https://v.qq.com/txp/iframe/player.html?vid=${qqMatch[1]}"></iframe>`);
|
|
35
|
-
element.remove();
|
|
31
|
+
replaceMedia(element, "iframe", `https://v.qq.com/txp/iframe/player.html?vid=${qqMatch[1]}`);
|
|
36
32
|
} else if (coubMatch && coubMatch[1]) {
|
|
37
|
-
element
|
|
38
|
-
|
|
39
|
-
src="//coub.com/embed/${coubMatch[1]}?muted=false&autostart=false&originalSize=true&startWithHD=true"></iframe>`);
|
|
40
|
-
element.remove();
|
|
33
|
+
replaceMedia(element, "iframe",
|
|
34
|
+
`//coub.com/embed/${coubMatch[1]}?muted=false&autostart=false&originalSize=true&startWithHD=true`);
|
|
41
35
|
} else if (facebookMatch && facebookMatch[0]) {
|
|
42
|
-
element
|
|
43
|
-
|
|
44
|
-
src="https://www.facebook.com/plugins/video.php?href=${encodeURIComponent(facebookMatch[0])}"></iframe>`);
|
|
45
|
-
element.remove();
|
|
36
|
+
replaceMedia(element, "iframe",
|
|
37
|
+
`https://www.facebook.com/plugins/video.php?href=${encodeURIComponent(facebookMatch[0])}`);
|
|
46
38
|
} else if (dailymotionMatch && dailymotionMatch[2]) {
|
|
47
|
-
element
|
|
48
|
-
`<iframe class="iframe__video"
|
|
49
|
-
src="https://www.dailymotion.com/embed/video/${dailymotionMatch[2]}"></iframe>`);
|
|
50
|
-
element.remove();
|
|
39
|
+
replaceMedia(element, "iframe", `https://www.dailymotion.com/embed/video/${dailymotionMatch[2]}`);
|
|
51
40
|
} else if (url.indexOf("bilibili.com") > -1 && (url.indexOf("bvid=") > -1 || (bilibiliMatch && bilibiliMatch[1]))) {
|
|
52
41
|
const params: IObject = {
|
|
53
42
|
bvid: getSearch("bvid", url) || (bilibiliMatch && bilibiliMatch[1]),
|
|
@@ -75,13 +64,9 @@ const iframeRender = (element: HTMLElement, url: string) => {
|
|
|
75
64
|
src += "&";
|
|
76
65
|
}
|
|
77
66
|
});
|
|
78
|
-
element
|
|
79
|
-
`<iframe class="iframe__video" src="${src}"></iframe>`);
|
|
80
|
-
element.remove();
|
|
67
|
+
replaceMedia(element, "iframe", src);
|
|
81
68
|
} else if (tedMatch && tedMatch[1]) {
|
|
82
|
-
element
|
|
83
|
-
`<iframe class="iframe__video" src="//embed.ted.com/talks/${tedMatch[1]}"></iframe>`);
|
|
84
|
-
element.remove();
|
|
69
|
+
replaceMedia(element, "iframe", `//embed.ted.com/talks/${tedMatch[1]}`);
|
|
85
70
|
}
|
|
86
71
|
};
|
|
87
72
|
|
|
@@ -95,9 +80,9 @@ export const mediaRender = (element: HTMLElement) => {
|
|
|
95
80
|
return;
|
|
96
81
|
}
|
|
97
82
|
if (url.match(/^.+.(mp4|m4v|ogg|ogv|webm)$/)) {
|
|
98
|
-
|
|
83
|
+
replaceMedia(aElement, "video", url);
|
|
99
84
|
} else if (url.match(/^.+.(mp3|wav|flac)$/)) {
|
|
100
|
-
|
|
85
|
+
replaceMedia(aElement, "audio", url);
|
|
101
86
|
} else {
|
|
102
87
|
iframeRender(aElement, url);
|
|
103
88
|
}
|
|
@@ -13,7 +13,7 @@ export const mermaidRender = (element: (HTMLElement | Document) = document, cdn
|
|
|
13
13
|
if (mermaidElements.length === 0) {
|
|
14
14
|
return;
|
|
15
15
|
}
|
|
16
|
-
addScript(`${cdn}/dist/js/mermaid/mermaid.min.js?v=11.
|
|
16
|
+
addScript(`${cdn}/dist/js/mermaid/mermaid.min.js?v=11.17.2`, "vditorMermaidScript").then(() => {
|
|
17
17
|
const config: any = {
|
|
18
18
|
securityLevel: "loose", // 升级后无 https://github.com/siyuan-note/siyuan/issues/3587,可使用该选项
|
|
19
19
|
altFontFamily: "sans-serif",
|
|
@@ -62,6 +62,7 @@ export const md2html = (mdText: string, options?: IPreviewOptions) => {
|
|
|
62
62
|
const lute = setLute({
|
|
63
63
|
autoSpace: mergedOptions.markdown.autoSpace,
|
|
64
64
|
callout: mergedOptions.markdown.callout,
|
|
65
|
+
inlineMath: mergedOptions.markdown.inlineMath,
|
|
65
66
|
gfmAutoLink: mergedOptions.markdown.gfmAutoLink,
|
|
66
67
|
codeBlockPreview: mergedOptions.markdown.codeBlockPreview,
|
|
67
68
|
emojiSite: mergedOptions.emojiPath,
|
|
@@ -6,6 +6,7 @@ export const setLute = (options: ILuteOptions) => {
|
|
|
6
6
|
lute.SetInlineMathAllowDigitAfterOpenMarker(options.inlineMathDigit);
|
|
7
7
|
lute.SetAutoSpace(options.autoSpace);
|
|
8
8
|
lute.SetCallout(options.callout);
|
|
9
|
+
lute.SetInlineMath(options.inlineMath);
|
|
9
10
|
lute.SetToC(options.toc);
|
|
10
11
|
lute.SetFootnotes(options.footnotes);
|
|
11
12
|
lute.SetFixTermTypo(options.fixTermTypo);
|