File tree 1 file changed +13
-7
lines changed
1 file changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -20,9 +20,9 @@ type Theme = 'light' | 'dark';
20
20
21
21
export interface Settings {
22
22
/** Editor background. */
23
- background : string ;
23
+ background ? : string ;
24
24
/** Default text color. */
25
- foreground : string ;
25
+ foreground ? : string ;
26
26
/** Caret color. */
27
27
caret ?: string ;
28
28
/** Selection background. */
@@ -43,14 +43,20 @@ export interface Settings {
43
43
fontFamily ?: string ;
44
44
}
45
45
46
- export const createTheme = ( { theme, settings, styles } : CreateThemeOptions ) : Extension => {
46
+ export const createTheme = ( { theme, settings = { } , styles = [ ] } : CreateThemeOptions ) : Extension => {
47
47
const themeOptions : Record < string , StyleSpec > = {
48
- '&' : {
49
- backgroundColor : settings . background ,
50
- color : settings . foreground ,
51
- } ,
52
48
'.cm-gutters' : { } ,
53
49
} ;
50
+ const baseStyle : StyleSpec = { } ;
51
+ if ( settings . background ) {
52
+ baseStyle . backgroundColor = settings . background ;
53
+ }
54
+ if ( settings . foreground ) {
55
+ baseStyle . color = settings . foreground ;
56
+ }
57
+ if ( settings . background || settings . foreground ) {
58
+ themeOptions [ '&' ] = baseStyle ;
59
+ }
54
60
55
61
if ( settings . fontFamily ) {
56
62
themeOptions [ '&.cm-editor .cm-scroller' ] = {
You can’t perform that action at this time.
0 commit comments