forked from mxx1111/mdlook
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththemes.ts
More file actions
50 lines (44 loc) · 1.32 KB
/
Copy paththemes.ts
File metadata and controls
50 lines (44 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { EditorView } from '@codemirror/view'
import { vsCodeDark } from '@fsegurai/codemirror-theme-vscode-dark'
import { vsCodeLight } from '@fsegurai/codemirror-theme-vscode-light'
const customStyles = EditorView.theme({
// 装订线:垂直居中、无背景无边框无内边距
'.cm-gutterElement': {
display: `flex`,
justifyContent: `right`,
alignItems: `center`,
},
'&.cm-editor .cm-gutters': {
backgroundColor: `transparent !important`,
borderRight: `none !important`,
padding: `0 !important`,
},
// 折叠装订线:固定宽度,无内边距
'.cm-foldGutter': {
width: `10px !important`,
overflow: `hidden`,
},
'.cm-foldGutter .cm-gutterElement': {
padding: `0 !important`,
width: `10px !important`,
minWidth: `unset !important`,
},
// 折叠图标:默认隐藏,hover 装订线时显示
'.cm-foldGutter .cm-gutterElement span': {
opacity: `0`,
transition: `opacity 0.15s ease`,
},
'&.cm-editor .cm-gutters:hover .cm-foldGutter .cm-gutterElement span': {
opacity: `1`,
},
})
export function lightTheme() {
return [vsCodeLight, customStyles]
}
export function darkTheme() {
return [vsCodeDark, customStyles]
}
// 根据主题模式获取主题扩展
export function theme(isDark: boolean) {
return isDark ? darkTheme() : lightTheme()
}