@@ -10,10 +10,23 @@ import Editor from 'react-ace';
10
10
import PropTypes from '../../lib/PropTypes' ;
11
11
12
12
import 'ace-builds/src-noconflict/mode-javascript' ;
13
- import 'ace-builds/src-noconflict/theme-solarized_dark ' ;
13
+ import 'ace-builds/src-noconflict/theme-monokai ' ;
14
14
import 'ace-builds/src-noconflict/snippets/javascript' ;
15
15
import 'ace-builds/src-noconflict/ext-language_tools' ;
16
16
17
+ // Disable web workers to prevent MIME type errors
18
+ import ace from 'ace-builds/src-noconflict/ace' ;
19
+
20
+ // Configure ACE to disable workers globally
21
+ ace . config . set ( 'useWorker' , false ) ;
22
+ ace . config . set ( 'loadWorkerFromBlob' , false ) ;
23
+ ace . config . set ( 'workerPath' , false ) ;
24
+
25
+ // Also set the base path to prevent worker loading attempts
26
+ ace . config . set ( 'basePath' , '/bundles' ) ;
27
+ ace . config . set ( 'modePath' , '/bundles' ) ;
28
+ ace . config . set ( 'themePath' , '/bundles' ) ;
29
+
17
30
export default class CodeEditor extends React . Component {
18
31
constructor ( props ) {
19
32
super ( props ) ;
@@ -32,13 +45,13 @@ export default class CodeEditor extends React.Component {
32
45
}
33
46
34
47
render ( ) {
35
- const { fontSize = 18 } = this . props ;
48
+ const { fontSize = 18 , theme = 'monokai' } = this . props ;
36
49
const { code } = this . state ;
37
50
38
51
return (
39
52
< Editor
40
53
mode = "javascript"
41
- theme = "solarized_dark"
54
+ theme = { theme }
42
55
onChange = { value => this . setState ( { code : value } ) }
43
56
fontSize = { fontSize }
44
57
showPrintMargin = { true }
@@ -49,8 +62,25 @@ export default class CodeEditor extends React.Component {
49
62
enableBasicAutocompletion = { true }
50
63
enableLiveAutocompletion = { true }
51
64
enableSnippets = { false }
52
- showLineNumbers = { true }
53
65
tabSize = { 2 }
66
+ style = { {
67
+ backgroundColor : '#202020'
68
+ } }
69
+ setOptions = { {
70
+ useWorker : false , // Disable web workers to prevent MIME type errors
71
+ wrap : true ,
72
+ foldStyle : 'markbegin' ,
73
+ enableMultiselect : true ,
74
+ // Additional worker-related options
75
+ enableBasicAutocompletion : true ,
76
+ enableLiveAutocompletion : true ,
77
+ enableSnippets : false ,
78
+ } }
79
+ editorProps = { {
80
+ $blockScrolling : Infinity , // Disable annoying warning
81
+ $useWorker : false , // Additional worker disable
82
+ } }
83
+ commands = { [ ] } // Disable any commands that might trigger worker loading
54
84
/>
55
85
) ;
56
86
}
@@ -59,4 +89,5 @@ export default class CodeEditor extends React.Component {
59
89
CodeEditor . propTypes = {
60
90
fontSize : PropTypes . number . describe ( 'Font size of the editor' ) ,
61
91
defaultValue : PropTypes . string . describe ( 'Default Code' ) ,
92
+ theme : PropTypes . string . describe ( 'Theme for the editor' ) ,
62
93
} ;
0 commit comments