Skip to content

Commit 6e0c7f2

Browse files
authored
feat: Modernize JavaScript console with tabs and server-side storage of scripts (#2962)
1 parent 00eb2d1 commit 6e0c7f2

File tree

5 files changed

+2191
-141
lines changed

5 files changed

+2191
-141
lines changed

src/components/BrowserMenu/MenuItem.react.js

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import React from 'react';
99
import styles from 'components/BrowserMenu/BrowserMenu.scss';
1010

11-
const MenuItem = ({ text, disabled, active, greenActive, onClick }) => {
11+
const MenuItem = ({ text, shortcut, disabled, active, greenActive, onClick, disableMouseDown = false }) => {
1212
const classes = [styles.item];
1313
if (disabled) {
1414
classes.push(styles.disabled);
@@ -30,14 +30,29 @@ const MenuItem = ({ text, disabled, active, greenActive, onClick }) => {
3030
<div
3131
className={classes.join(' ')}
3232
onClick={handleClick}
33-
onMouseDown={handleClick} // This is needed - onClick alone doesn't work in this context
33+
onMouseDown={disableMouseDown ? undefined : handleClick} // This is needed - onClick alone doesn't work in this context
3434
style={{
3535
position: 'relative',
3636
zIndex: 9999,
37-
cursor: 'pointer'
37+
cursor: 'pointer',
38+
display: 'flex',
39+
justifyContent: 'space-between',
40+
alignItems: 'center'
3841
}}
3942
>
40-
{text}
43+
<span>{text}</span>
44+
{shortcut && (
45+
<span
46+
style={{
47+
opacity: 0.5,
48+
fontSize: '0.85em',
49+
marginLeft: '12px',
50+
color: 'inherit'
51+
}}
52+
>
53+
{shortcut}
54+
</span>
55+
)}
4156
</div>
4257
);
4358
};

src/components/CodeEditor/CodeEditor.react.js

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,23 @@ import Editor from 'react-ace';
1010
import PropTypes from '../../lib/PropTypes';
1111

1212
import 'ace-builds/src-noconflict/mode-javascript';
13-
import 'ace-builds/src-noconflict/theme-solarized_dark';
13+
import 'ace-builds/src-noconflict/theme-monokai';
1414
import 'ace-builds/src-noconflict/snippets/javascript';
1515
import 'ace-builds/src-noconflict/ext-language_tools';
1616

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+
1730
export default class CodeEditor extends React.Component {
1831
constructor(props) {
1932
super(props);
@@ -32,13 +45,13 @@ export default class CodeEditor extends React.Component {
3245
}
3346

3447
render() {
35-
const { fontSize = 18 } = this.props;
48+
const { fontSize = 18, theme = 'monokai' } = this.props;
3649
const { code } = this.state;
3750

3851
return (
3952
<Editor
4053
mode="javascript"
41-
theme="solarized_dark"
54+
theme={theme}
4255
onChange={value => this.setState({ code: value })}
4356
fontSize={fontSize}
4457
showPrintMargin={true}
@@ -49,8 +62,25 @@ export default class CodeEditor extends React.Component {
4962
enableBasicAutocompletion={true}
5063
enableLiveAutocompletion={true}
5164
enableSnippets={false}
52-
showLineNumbers={true}
5365
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
5484
/>
5585
);
5686
}
@@ -59,4 +89,5 @@ export default class CodeEditor extends React.Component {
5989
CodeEditor.propTypes = {
6090
fontSize: PropTypes.number.describe('Font size of the editor'),
6191
defaultValue: PropTypes.string.describe('Default Code'),
92+
theme: PropTypes.string.describe('Theme for the editor'),
6293
};

0 commit comments

Comments
 (0)