/** * @jsx React.DOM */ var IS_MOBILE = ( navigator.userAgent.match(/Android/i) || navigator.userAgent.match(/webOS/i) || navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPad/i) || navigator.userAgent.match(/iPod/i) || navigator.userAgent.match(/BlackBerry/i) || navigator.userAgent.match(/Windows Phone/i) ); var CodeMirrorEditor = React.createClass({ componentDidMount: function(root) { if (IS_MOBILE) { return; } this.editor = CodeMirror.fromTextArea(this.refs.editor.getDOMNode(), { mode: 'javascript', lineNumbers: false, matchBrackets: true, theme: 'solarized-light' }); this.editor.on('change', this.onChange); this.onChange(); }, onChange: function() { if (this.props.onChange) { var content = this.editor.getValue(); this.props.onChange(content); } }, render: function() { // wrap in a div to fully contain CodeMirror var editor; if (IS_MOBILE) { editor =
{this.props.codeText}; } else { editor = ; } return (
{this.getDesugaredCode()}, mountNode ); } else { eval(this.getDesugaredCode()); } } catch (e) { React.renderComponent( , mountNode ); } } });