@@ -3,9 +3,13 @@ import * as classes from './new-text.styles';
3
3
// Material UI ~ components
4
4
import Button from '@material-ui/core/Button' ;
5
5
import TextareaAutosize from '@material-ui/core/TextareaAutosize' ;
6
+ // Code Editor
7
+ import AceEditor from 'react-ace' ;
8
+ import 'ace-builds/src-noconflict/mode-typescript' ;
9
+ import 'ace-builds/src-noconflict/theme-monokai' ;
6
10
7
11
interface Props {
8
- handleAppendTrainerText : ( trainerText : string , ) => void ;
12
+ handleAppendTrainerText : ( trainerText : string ) => void ;
9
13
}
10
14
11
15
export const NewTextComponent : React . FC < Props > = props => {
@@ -27,9 +31,12 @@ export const NewTextComponent: React.FC<Props> = props => {
27
31
trainerTextRef . current = '' ;
28
32
} ;
29
33
30
- const handleOnChange = ( e : React . ChangeEvent < HTMLTextAreaElement > ) : void => {
31
- trainerTextRef . current = e . target . value ;
32
- setTrainerText ( e . target . value ) ;
34
+ const handleOnChange = (
35
+ value : string ,
36
+ e : React . ChangeEvent < HTMLTextAreaElement >
37
+ ) : void => {
38
+ trainerTextRef . current = value ;
39
+ setTrainerText ( value ) ;
33
40
} ;
34
41
35
42
React . useEffect ( ( ) => {
@@ -48,13 +55,29 @@ export const NewTextComponent: React.FC<Props> = props => {
48
55
< label className = { labelTextarea } htmlFor = "new-text" >
49
56
New text
50
57
</ label >
51
- < TextareaAutosize
52
- rowsMax = { 10 }
53
- rowsMin = { 10 }
54
- className = { editTextArea }
55
- onChange = { e => handleOnChange ( e ) }
58
+ < AceEditor
59
+ placeholder = ""
60
+ mode = "typescript"
61
+ theme = "monokai"
62
+ name = "blah2"
63
+ onChange = { ( value , e ) => handleOnChange ( value , e ) }
64
+ fontSize = { 14 }
65
+ showPrintMargin = { true }
66
+ showGutter = { true }
67
+ highlightActiveLine = { true }
56
68
value = { trainerText }
69
+ setOptions = { {
70
+ enableBasicAutocompletion : false ,
71
+ enableLiveAutocompletion : true ,
72
+ enableSnippets : false ,
73
+ showLineNumbers : true ,
74
+ tabSize : 2 ,
75
+ showPrintMargin : false ,
76
+ } }
77
+ className = { editTextArea }
78
+ width = "auto"
57
79
/>
80
+
58
81
< Button
59
82
variant = "contained"
60
83
color = "primary"
0 commit comments