"use strict";

var ace = require('brace');
require('brace/theme/tomorrow');
require('brace/mode/javascript');

var React = require('react/addons');

var IdeComponent = React.createClass({
  editor: null,
  componentDidMount: function () {
    this.editor = ace.edit(this.refs.ide.getDOMNode());
    this.editor.setTheme('ace/theme/tomorrow');

    var session = this.editor.getSession();
    session.setMode('ace/mode/javascript');
    session.setTabSize(2);
    session.setUseSoftTabs(true);
    session.on('change', this.onChange);
  },
  componentDidUpdate: function () {
    this.editor.setValue(this.props.code);
  },
  render: function () {
    return (
      <div ref='ide' className='ide'>
      </div>
    );
  },
  onChange: function () {
    this.props.onChange(this.editor.getValue());
  }
});

module.exports = IdeComponent;

"use strict";

var ace = require('brace');
require('brace/theme/tomorrow');
require('brace/mode/javascript');

var React = require('react/addons');

var IdeComponent = React.createClass({
  editor: null,
  componentDidMount: function () {
    this.editor = ace.edit(this.refs.ide.getDOMNode());
    this.editor.setTheme('ace/theme/tomorrow');

    var session = this.editor.getSession();
    session.setMode('ace/mode/javascript');
    session.setTabSize(2);
    session.setUseSoftTabs(true);
    session.on('change', this.onChange);
  },
  render: function () {
    return <div ref='ide' className='ide'>{this.props.code}</div>;
  },
  onChange: function () {
    this.props.onChange(this.editor.getValue());
  }
});

module.exports = IdeComponent;

Fix bug in prefilling IDE.
Fix bug in prefilling IDE.
