File tree Expand file tree Collapse file tree 1 file changed +13
-7
lines changed
Expand file tree Collapse file tree 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';
2020
2121export interface Settings {
2222 /** Editor background. */
23- background : string ;
23+ background ? : string ;
2424 /** Default text color. */
25- foreground : string ;
25+ foreground ? : string ;
2626 /** Caret color. */
2727 caret ?: string ;
2828 /** Selection background. */
@@ -43,14 +43,20 @@ export interface Settings {
4343 fontFamily ?: string ;
4444}
4545
46- export const createTheme = ( { theme, settings, styles } : CreateThemeOptions ) : Extension => {
46+ export const createTheme = ( { theme, settings = { } , styles = [ ] } : CreateThemeOptions ) : Extension => {
4747 const themeOptions : Record < string , StyleSpec > = {
48- '&' : {
49- backgroundColor : settings . background ,
50- color : settings . foreground ,
51- } ,
5248 '.cm-gutters' : { } ,
5349 } ;
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+ }
5460
5561 if ( settings . fontFamily ) {
5662 themeOptions [ '&.cm-editor .cm-scroller' ] = {
You can’t perform that action at this time.
0 commit comments