@@ -14,8 +14,9 @@ import {
14
14
scrollPastEnd ,
15
15
} from '@codemirror/view' ;
16
16
import { useEffect , useRef , useState , type MutableRefObject } from 'react' ;
17
+ import { classNames } from '../../utils/classnames.js' ;
18
+ import { debounce } from '../../utils/debounce.js' ;
17
19
import type { Theme } from '../types.js' ;
18
- import { debounce } from '../utils/debounce.js' ;
19
20
import { BinaryContent } from './BinaryContent.js' ;
20
21
import { getTheme , reconfigureTheme } from './cm-theme.js' ;
21
22
import { indentKeyBinding } from './indent.js' ;
@@ -46,14 +47,15 @@ export type OnChangeCallback = (update: EditorUpdate) => void;
46
47
export type OnScrollCallback = ( position : ScrollPosition ) => void ;
47
48
48
49
interface Props {
50
+ theme : Theme ;
49
51
id ?: unknown ;
50
52
doc ?: EditorDocument ;
51
53
debounceChange ?: number ;
52
54
debounceScroll ?: number ;
53
55
autoFocusOnDocumentChange ?: boolean ;
54
56
onChange ?: OnChangeCallback ;
55
57
onScroll ?: OnScrollCallback ;
56
- theme : Theme ;
58
+ className ?: string ;
57
59
}
58
60
59
61
type EditorStates = Map < string , EditorState > ;
@@ -67,6 +69,7 @@ export function CodeMirrorEditor({
67
69
onScroll,
68
70
onChange,
69
71
theme,
72
+ className = '' ,
70
73
} : Props ) {
71
74
const [ language ] = useState ( new Compartment ( ) ) ;
72
75
const [ readOnly ] = useState ( new Compartment ( ) ) ;
@@ -176,13 +179,15 @@ export function CodeMirrorEditor({
176
179
} , [ doc ?. value , doc ?. filePath , doc ?. loading ] ) ;
177
180
178
181
return (
179
- < div className = "h-full relative" >
182
+ < div className = { classNames ( ' relative' , className ) } >
180
183
{ isBinaryFile && < BinaryContent /> }
181
184
< div className = "h-full overflow-hidden" ref = { containerRef } />
182
185
</ div >
183
186
) ;
184
187
}
185
188
189
+ export default CodeMirrorEditor ;
190
+
186
191
CodeMirrorEditor . displayName = 'CodeMirrorEditor' ;
187
192
188
193
function newEditorState (
0 commit comments