@@ -11,32 +11,35 @@ import { loadAceEditor, getAceModeFromExtension } from '../../helpers/AceEditorL
1111let AceEditor = loadAceEditor ( ) ;
1212
1313const SourceCodeField = (
14- { input, mode, meta : { error, warning } , label = null , children, tabIndex, onBlur, ...props } ,
14+ { input, mode, meta : { error, warning } , label = null , children, tabIndex, onBlur, readOnly = false , ...props } ,
1515 { userSettings : { vimMode = false , darkTheme = false } }
1616) => (
1717 < FormGroup controlId = { input . name } validationState = { error ? 'error' : warning ? 'warning' : undefined } >
1818 { Boolean ( label ) && < ControlLabel > { label } </ ControlLabel > }
1919 < ClientOnly >
20- < AceEditor
21- { ...props }
22- { ...input }
23- mode = { getAceModeFromExtension ( mode ) }
24- theme = { darkTheme ? 'monokai' : 'github' }
25- name = { input . name }
26- tabIndex = { tabIndex }
27- keyboardHandler = { vimMode ? 'vim' : undefined }
28- width = "100%"
29- height = "100%"
30- minLines = { 5 }
31- maxLines = { 20 }
32- onBlur = {
33- ( ) => input . onBlur ( ) // this is a hack that will ensure blur call witout distorting the contents
34- }
35- editorProps = { {
36- $blockScrolling : Infinity ,
37- $autoScrollEditorIntoView : true ,
38- } }
39- />
20+ < div className = { readOnly ? 'noselection' : '' } >
21+ < AceEditor
22+ { ...props }
23+ { ...input }
24+ mode = { getAceModeFromExtension ( mode ) }
25+ theme = { darkTheme ? 'monokai' : 'github' }
26+ name = { input . name }
27+ tabIndex = { tabIndex }
28+ keyboardHandler = { vimMode ? 'vim' : undefined }
29+ width = "100%"
30+ height = "100%"
31+ minLines = { 5 }
32+ maxLines = { 20 }
33+ readOnly = { readOnly }
34+ onBlur = {
35+ ( ) => input . onBlur ( ) // this is a hack that will ensure blur call witout distorting the contents
36+ }
37+ editorProps = { {
38+ $blockScrolling : Infinity ,
39+ $autoScrollEditorIntoView : true ,
40+ } }
41+ />
42+ </ div >
4043 </ ClientOnly >
4144 { error && < HelpBlock > { error } </ HelpBlock > }
4245 { ! error && warning && < HelpBlock > { warning } </ HelpBlock > }
@@ -61,6 +64,7 @@ SourceCodeField.propTypes = {
6164 PropTypes . element ,
6265 PropTypes . shape ( { type : PropTypes . oneOf ( [ FormattedMessage ] ) } ) ,
6366 ] ) ,
67+ readOnly : PropTypes . bool ,
6468 onBlur : PropTypes . func ,
6569} ;
6670
0 commit comments