@@ -2,7 +2,7 @@ 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' ;
@@ -34,13 +34,20 @@ class Editor extends Component {
3434 } )
3535 }
3636
37- onChange = ( value ) => {
37+ onChangeText = ( value ) => {
3838 this . setState ( {
3939 ...this . state ,
4040 text : value
4141 } )
4242 }
4343
44+ onChangeType = ( event ) => {
45+ this . setState ( {
46+ ...this . state ,
47+ type : event . target . value
48+ } )
49+ }
50+
4451 setInProgress = ( ) => {
4552 this . setState ( {
4653 ...this . state ,
@@ -111,12 +118,12 @@ class Editor extends Component {
111118 < Grid item xs = { 12 } >
112119 < AceEditor
113120 name = 'editor'
114- mode = { this . props . language }
121+ mode = { this . state . type }
115122 theme = { theme }
116123 height = { this . state . editorHeight }
117124 width = { this . state . editorWidth }
118125 value = { this . state . text }
119- onChange = { this . onChange }
126+ onChange = { this . onChangeText }
120127 showPrintMargin = { false }
121128 editorProps = { { $blockScrolling : true } }
122129 setOptions = { {
@@ -127,6 +134,18 @@ class Editor extends Component {
127134 />
128135 </ Grid >
129136 < Grid item xs = { 12 } style = { { textAlign : 'right' , marginTop : '0.75%' } } >
137+ < Select
138+ labelId = 'select-language-label'
139+ id = 'select-language'
140+ value = { this . state . type }
141+ onChange = { this . onChangeType }
142+ style = { { color : '#ffffff' , marginRight : '0.75%' } }
143+ >
144+ < MenuItem value = 'plaintext' > None</ MenuItem >
145+ < MenuItem value = 'python' > Python</ MenuItem >
146+ < MenuItem value = 'java' > Java</ MenuItem >
147+ < MenuItem value = 'c_cpp' > C++</ MenuItem >
148+ </ Select >
130149 { this . renderSubmit ( ) }
131150 </ Grid >
132151 </ Grid >
0 commit comments