@@ -24,19 +24,19 @@ export interface Settings {
2424 /** Default text color. */
2525 foreground : string ;
2626 /** Caret color. */
27- caret : string ;
27+ caret ? : string ;
2828 /** Selection background. */
29- selection : string ;
29+ selection ? : string ;
3030 /** Selection match background. */
3131 selectionMatch ?: string ;
3232 /** Background of highlighted lines. */
33- lineHighlight : string ;
33+ lineHighlight ? : string ;
3434 /** Gutter background. */
35- gutterBackground : string ;
35+ gutterBackground ? : string ;
3636 /** Text color inside gutter. */
37- gutterForeground : string ;
37+ gutterForeground ? : string ;
3838 /** Gutter right border color. */
39- gutterBorder : string ;
39+ gutterBorder ? : string ;
4040}
4141
4242export const createTheme = ( { theme, settings, styles } : CreateThemeOptions ) : Extension => {
@@ -45,24 +45,37 @@ export const createTheme = ({ theme, settings, styles }: CreateThemeOptions): Ex
4545 backgroundColor : settings . background ,
4646 color : settings . foreground ,
4747 } ,
48- '.cm-content' : {
48+ '.cm-gutters' : { } ,
49+ } ;
50+
51+ if ( settings . gutterBackground ) {
52+ themeOptions [ '.cm-gutters' ] . backgroundColor = settings . gutterBackground ;
53+ }
54+ if ( settings . gutterForeground ) {
55+ themeOptions [ '.cm-gutters' ] . color = settings . gutterForeground ;
56+ }
57+ if ( settings . gutterBorder ) {
58+ themeOptions [ '.cm-gutters' ] . borderRightColor = settings . gutterBorder ;
59+ }
60+
61+ if ( settings . caret ) {
62+ themeOptions [ '.cm-content' ] = {
4963 caretColor : settings . caret ,
50- } ,
51- '.cm-cursor, .cm-dropCursor' : {
64+ } ;
65+ themeOptions [ '.cm-cursor, .cm-dropCursor' ] = {
5266 borderLeftColor : settings . caret ,
53- } ,
54- '.cm-activeLine' : {
67+ } ;
68+ }
69+
70+ if ( settings . lineHighlight ) {
71+ themeOptions [ '.cm-activeLine' ] = {
5572 backgroundColor : settings . lineHighlight ,
56- } ,
57- '.cm-gutters' : {
58- backgroundColor : settings . gutterBackground ,
59- color : settings . gutterForeground ,
60- borderRightColor : settings . gutterBorder ,
61- } ,
62- '.cm-activeLineGutter' : {
73+ } ;
74+ themeOptions [ '.cm-activeLineGutter' ] = {
6375 backgroundColor : settings . lineHighlight ,
64- } ,
65- } ;
76+ } ;
77+ }
78+
6679 if ( settings . selection ) {
6780 themeOptions [
6881 '&.cm-focused .cm-selectionBackground .cm-selectionBackground, & .cm-selectionLayer .cm-selectionBackground, ::selection'
0 commit comments