@@ -75,6 +75,7 @@ const CodeEditor: React.FC<CodeEditorInterface> & CodeEditorComposition = React.
75
75
tabSize = 2 ,
76
76
lineDecorationsWidth = 0 ,
77
77
height = 450 ,
78
+ width = '100%' ,
78
79
inline = false ,
79
80
shebang = '' ,
80
81
onChange,
@@ -98,7 +99,7 @@ const CodeEditor: React.FC<CodeEditorInterface> & CodeEditorComposition = React.
98
99
99
100
const editorRef = useRef ( null )
100
101
const monacoRef = useRef ( null )
101
- const { width, height : windowHeight } = useWindowSize ( )
102
+ const { width : windowWidth , height : windowHeight } = useWindowSize ( )
102
103
const memoisedReducer = React . useCallback ( CodeEditorReducer , [ ] )
103
104
const [ state , dispatch ] = useReducer ( memoisedReducer , initialState ( { mode, theme, value, diffView, noParsing} ) )
104
105
const [ , json , yamlCode , error ] = useJsonYaml ( state . code , tabSize , state . mode , ! state . noParsing )
@@ -191,7 +192,7 @@ const CodeEditor: React.FC<CodeEditorInterface> & CodeEditorComposition = React.
191
192
return
192
193
}
193
194
editorRef . current . layout ( )
194
- } , [ width , windowHeight ] )
195
+ } , [ windowWidth , windowHeight ] )
195
196
196
197
useEffect ( ( ) => {
197
198
if ( onChange ) {
@@ -267,7 +268,7 @@ const CodeEditor: React.FC<CodeEditorInterface> & CodeEditorComposition = React.
267
268
}
268
269
269
270
return (
270
- < CodeEditorContext . Provider value = { { dispatch, state, handleLanguageChange, error, defaultValue, height } } >
271
+ < CodeEditorContext . Provider value = { { dispatch, state, handleLanguageChange, error, defaultValue, height, width } } >
271
272
{ children }
272
273
{ loading ? (
273
274
< CodeEditorPlaceholder customLoader = { customLoader } />
@@ -286,7 +287,7 @@ const CodeEditor: React.FC<CodeEditorInterface> & CodeEditorComposition = React.
286
287
theme = { state . theme . toLowerCase ( ) . split ( ' ' ) . join ( '-' ) }
287
288
editorDidMount = { editorDidMount }
288
289
height = { height }
289
- width = "100%"
290
+ width = { width }
290
291
/>
291
292
) : (
292
293
< MonacoEditor
@@ -297,7 +298,7 @@ const CodeEditor: React.FC<CodeEditorInterface> & CodeEditorComposition = React.
297
298
onChange = { handleOnChange }
298
299
editorDidMount = { editorDidMount }
299
300
height = { height }
300
- width = "100%"
301
+ width = { width }
301
302
/>
302
303
) }
303
304
</ >
0 commit comments