componentDidMount() { const path = window.require('path'); const fs = window.require('fs'); var file = fs.readFileSync(this.props.path, { encoding: 'utf8' }); // initialize editor this.editor = monaco.editor.create(document.getElementById('editor-container'), { language: this._getLanguage(this.props.path), theme: 'ayu-dark', lineNumbers: 'on', wordWrap: 'on', scrollBeyondLastLine: false, automaticLayout: true, glyphMargin: true }, ); // Intialize the linter this._linterWorker = new ESLintWorker(); this._linterWorker.addEventListener('message', (message) => { this._updateMarkers(message); }); this._openFile(this.props.path); }
loadEditor() { this.editor = monaco.editor.create(this.divRef, { value: "function hello() {\n\talert('Hello world!');\n}", language: 'javascript', theme: 'vs-dark', }); }
render() { const options = { selectOnLineNumbers: true, model: monaco.editor.getModel(Uri.parse("file:///main.tsx")) || monaco.editor.createModel(code, "typescript", monaco.Uri.parse("file:///main.tsx")) } return ( <MonacoEditor width="800" height="800" language="typescript" theme="vs-dark" defaultValue='' value={this.state.code} onChange={this.onChange} editorWillMount={this.editorWillMount} editorDidMount={this.editorDidMount} options={options} /> ) }
componentDidMount() { this.editor = monaco.editor.create(this.container); }