diff --git a/webmaker/src/components/CodeMirrorBox.jsx b/webmaker/src/components/CodeMirrorBox.jsx new file mode 100644 index 0000000..a1132b9 --- /dev/null +++ b/webmaker/src/components/CodeMirrorBox.jsx @@ -0,0 +1,31 @@ +import { h, Component } from 'preact'; +import CodeMirror from '../CodeMirror'; + +import 'codemirror/mode/javascript/javascript.js'; + +export default class CodeMirrorBox extends Component { + componentDidMount() { + this.initEditor(); + } + shouldComponentUpdate() { + return false; + } + + initEditor() { + const options = this.props.options; + this.cm = CodeMirror.fromTextArea(this.textarea, this.props.options); + this.props.onCreation(this.cm); + } + + render() { + return ( +