|
| 1 | + |
| 2 | +/** |
| 3 | + * https://github.com/uiwjs/react-codemirror/issues/409 |
| 4 | + */ |
| 5 | +import { tags as t } from '@lezer/highlight'; |
| 6 | +import { createTheme, CreateThemeOptions } from '@uiw/codemirror-themes'; |
| 7 | + |
| 8 | +export const defaultSettingsVscodeDark: CreateThemeOptions['settings'] = { |
| 9 | + background: '#1e1e1e', |
| 10 | + foreground: '#9cdcfe', |
| 11 | + caret: '#c6c6c6', |
| 12 | + selection: '#6199ff2f', |
| 13 | + selectionMatch: '#72a1ff59', |
| 14 | + lineHighlight: '#ffffff0f', |
| 15 | + gutterBackground: '#1e1e1e', |
| 16 | + gutterForeground: '#838383', |
| 17 | + gutterActiveForeground: '#fff', |
| 18 | + fontFamily: 'Menlo, Monaco, Consolas, "Andale Mono", "Ubuntu Mono", "Courier New", monospace', |
| 19 | +}; |
| 20 | + |
| 21 | +export function vscodeDarkInit(options?: Partial<CreateThemeOptions>) { |
| 22 | + const { theme = 'dark', settings = {}, styles = [] } = options || {}; |
| 23 | + return createTheme({ |
| 24 | + theme: theme, |
| 25 | + settings: { |
| 26 | + ...defaultSettingsVscodeDark, |
| 27 | + ...settings, |
| 28 | + }, |
| 29 | + styles: [ |
| 30 | + { |
| 31 | + tag: [ |
| 32 | + t.keyword, |
| 33 | + t.operatorKeyword, |
| 34 | + t.modifier, |
| 35 | + t.color, |
| 36 | + t.constant(t.name), |
| 37 | + t.standard(t.name), |
| 38 | + t.standard(t.tagName), |
| 39 | + t.special(t.brace), |
| 40 | + t.atom, |
| 41 | + t.bool, |
| 42 | + t.special(t.variableName), |
| 43 | + ], |
| 44 | + color: '#569cd6', |
| 45 | + }, |
| 46 | + { |
| 47 | + tag: [t.controlKeyword, t.moduleKeyword], |
| 48 | + color: '#c586c0', |
| 49 | + }, |
| 50 | + { |
| 51 | + tag: [ |
| 52 | + t.name, |
| 53 | + t.deleted, |
| 54 | + t.character, |
| 55 | + t.macroName, |
| 56 | + t.propertyName, |
| 57 | + t.variableName, |
| 58 | + t.labelName, |
| 59 | + t.definition(t.name), |
| 60 | + ], |
| 61 | + color: '#9cdcfe', |
| 62 | + }, |
| 63 | + { tag: t.heading, fontWeight: 'bold', color: '#9cdcfe' }, |
| 64 | + { |
| 65 | + tag: [t.typeName, t.className, t.tagName, t.number, t.changed, t.annotation, t.self, t.namespace], |
| 66 | + color: '#4ec9b0', |
| 67 | + }, |
| 68 | + { |
| 69 | + tag: [t.function(t.variableName), t.function(t.propertyName)], |
| 70 | + color: '#dcdcaa', |
| 71 | + }, |
| 72 | + { tag: [t.number], color: '#b5cea8' }, |
| 73 | + { |
| 74 | + tag: [t.operator, t.punctuation, t.separator, t.url, t.escape, t.regexp], |
| 75 | + color: '#d4d4d4', |
| 76 | + }, |
| 77 | + { |
| 78 | + tag: [t.regexp], |
| 79 | + color: '#d16969', |
| 80 | + }, |
| 81 | + { |
| 82 | + tag: [t.special(t.string), t.processingInstruction, t.string, t.inserted], |
| 83 | + color: '#ce9178', |
| 84 | + }, |
| 85 | + { tag: [t.angleBracket], color: '#808080' }, |
| 86 | + { tag: t.strong, fontWeight: 'bold' }, |
| 87 | + { tag: t.emphasis, fontStyle: 'italic' }, |
| 88 | + { tag: t.strikethrough, textDecoration: 'line-through' }, |
| 89 | + { tag: [t.meta, t.comment], color: '#6a9955' }, |
| 90 | + { tag: t.link, color: '#6a9955', textDecoration: 'underline' }, |
| 91 | + { tag: t.invalid, color: '#ff0000' }, |
| 92 | + ...styles, |
| 93 | + ], |
| 94 | + }); |
| 95 | +} |
| 96 | + |
| 97 | +export const vscodeDark = vscodeDarkInit(); |
0 commit comments