@@ -2,11 +2,14 @@ import React, { Component } from 'react'
22import { Redirect } from 'react-router-dom' ;
33import axios from 'axios' ;
44import AceEditor from 'react-ace' ;
5- import { Grid , Button , CircularProgress } from '@material-ui/core' ;
5+ import { Grid , Button , CircularProgress , Select , MenuItem } from '@material-ui/core' ;
66
77import 'ace-builds/src-noconflict/mode-java' ;
88import 'ace-builds/src-noconflict/mode-python' ;
99import 'ace-builds/src-noconflict/mode-c_cpp' ;
10+ import 'ace-builds/src-noconflict/mode-javascript' ;
11+ import 'ace-builds/src-noconflict/mode-sql' ;
12+ import 'ace-builds/src-noconflict/mode-json' ;
1013import 'ace-builds/src-noconflict/mode-plain_text' ;
1114import 'ace-builds/src-noconflict/theme-monokai' ;
1215
@@ -34,13 +37,20 @@ class Editor extends Component {
3437 } )
3538 }
3639
37- onChange = ( value ) => {
40+ onChangeText = ( value ) => {
3841 this . setState ( {
3942 ...this . state ,
4043 text : value
4144 } )
4245 }
4346
47+ onChangeType = ( event ) => {
48+ this . setState ( {
49+ ...this . state ,
50+ type : event . target . value
51+ } )
52+ }
53+
4454 setInProgress = ( ) => {
4555 this . setState ( {
4656 ...this . state ,
@@ -111,12 +121,12 @@ class Editor extends Component {
111121 < Grid item xs = { 12 } >
112122 < AceEditor
113123 name = 'editor'
114- mode = { this . props . language }
124+ mode = { this . state . type }
115125 theme = { theme }
116126 height = { this . state . editorHeight }
117127 width = { this . state . editorWidth }
118128 value = { this . state . text }
119- onChange = { this . onChange }
129+ onChange = { this . onChangeText }
120130 showPrintMargin = { false }
121131 editorProps = { { $blockScrolling : true } }
122132 setOptions = { {
@@ -127,6 +137,21 @@ class Editor extends Component {
127137 />
128138 </ Grid >
129139 < Grid item xs = { 12 } style = { { textAlign : 'right' , marginTop : '0.75%' } } >
140+ < Select
141+ labelId = 'select-language-label'
142+ id = 'select-language'
143+ value = { this . state . type }
144+ onChange = { this . onChangeType }
145+ style = { { color : '#ffffff' , marginRight : '0.75%' } }
146+ >
147+ < MenuItem value = 'plaintext' > None</ MenuItem >
148+ < MenuItem value = 'python' > Python</ MenuItem >
149+ < MenuItem value = 'java' > Java</ MenuItem >
150+ < MenuItem value = 'c_cpp' > C++</ MenuItem >
151+ < MenuItem value = 'javascript' > Javascript</ MenuItem >
152+ < MenuItem value = 'sql' > SQL</ MenuItem >
153+ < MenuItem value = 'json' > JSON</ MenuItem >
154+ </ Select >
130155 { this . renderSubmit ( ) }
131156 </ Grid >
132157 </ Grid >
0 commit comments