@@ -5,6 +5,7 @@ import { getDefaultExtensions } from './getDefaultExtensions';
55import { getStatistics } from './utils' ;
66import { type ReactCodeMirrorProps } from '.' ;
77import { TimeoutLatch , getScheduler } from './timeoutLatch' ;
8+ import { scrollerTheme , getDimensionTheme } from './theme/dimensionTheme' ;
89
910export const ExternalChange = Annotation . define < boolean > ( ) ;
1011const TYPING_TIMOUT = 200 ; // ms
@@ -45,19 +46,7 @@ export function useCodeMirror(props: UseCodeMirror) {
4546 const [ state , setState ] = useState < EditorState > ( ) ;
4647 const typingLatch = useState < { current : TimeoutLatch | null } > ( ( ) => ( { current : null } ) ) [ 0 ] ;
4748 const pendingUpdate = useState < { current : ( ( ) => void ) | null } > ( ( ) => ( { current : null } ) ) [ 0 ] ;
48- const defaultThemeOption = EditorView . theme ( {
49- '&' : {
50- height,
51- minHeight,
52- maxHeight,
53- width,
54- minWidth,
55- maxWidth,
56- } ,
57- '& .cm-scroller' : {
58- height : '100% !important' ,
59- } ,
60- } ) ;
49+ const defaultThemeOption = getDimensionTheme ( height , minHeight , maxHeight , width , minWidth , maxWidth ) ;
6150 const updateListener = EditorView . updateListener . of ( ( vu : ViewUpdate ) => {
6251 if (
6352 vu . docChanged &&
@@ -96,7 +85,12 @@ export function useCodeMirror(props: UseCodeMirror) {
9685 basicSetup : defaultBasicSetup ,
9786 } ) ;
9887
99- let getExtensions = [ updateListener , defaultThemeOption , ...defaultExtensions ] ;
88+ let getExtensions = [
89+ updateListener ,
90+ ...( defaultThemeOption ? [ defaultThemeOption ] : [ ] ) ,
91+ scrollerTheme ,
92+ ...defaultExtensions ,
93+ ] ;
10094
10195 if ( onUpdate && typeof onUpdate === 'function' ) {
10296 getExtensions . push ( EditorView . updateListener . of ( onUpdate ) ) ;
0 commit comments