<commit_before>var React = require('react');

// Usage:
// var LensWriter = require('lens-writer/adapters/react');
// 
// React.createElement(LensWriter, {
//   content: LENS_ARTICLE_XML,
//   onSave: function(xml, cb) {
//     
//   }
// });

// Lens + Substance
var LensWriter = require('./src/lens_writer');
var Article = require('./lib/article');
var Component = require('substance/ui/component');
var $$ = Component.$$;

var ReactLensWriter = React.createClass({

  getWriter: function() {
    return this;
  },

  onSave: function(doc, changes, cb) {
    var xml = doc.toXml();
    this.props.onSave(xml, cb);
  },

  getContent: function() {
    return this.writer.getDocument().toXml();
  },

  // New props arrived, update the editor
  componentDidUpdate: function() {
    var doc = this.createDoc(this.props.content);
    this.writer.extendProps({
      doc: doc
    });
  },

  createDoc: function(content) {
    return Article.fromXml(content || Article.XML_TEMPLATE);
  },

  componentDidMount: function() {
    var el = React.findDOMNode(this);
    var doc = this.createDoc(this.props.content);
    this.writer = Component.mount($$(LensWriter, {
      doc: doc,
      onSave: this.onSave.bind(this)
    }), el);
  },

  render: function() {
    return React.DOM.div({
      className: 'lens-writer-wrapper'
    });
  }
});

ReactLensWriter.propTypes = {
  content: React.PropTypes.string // XML source of the document
};

module.exports = ReactLensWriter;<commit_msg>Fix it.<commit_after>var React = require('react');

// Usage:
// var LensWriter = require('lens-writer/adapters/react');
// 
// React.createElement(LensWriter, {
//   content: LENS_ARTICLE_XML,
//   onSave: function(xml, cb) {
//     
//   }
// });

// Lens + Substance
var LensWriter = require('./src/lens_writer');
var Article = require('./lib/article');
var Component = require('substance/ui/component');
var $$ = Component.$$;

var ReactLensWriter = React.createClass({

  getWriter: function() {
    return this;
  },

  onSave: function(doc, changes, cb) {
    var xml = doc.toXml();
    this.props.onSave(xml, cb);
  },

  getContent: function() {
    return this.writer.getDocument().toXml();
  },

  // New props arrived, update the editor
  componentDidUpdate: function() {
    var doc = this.createDoc(this.props.content);
    this.writer.extendProps({
      doc: doc
    });
  },

  createDoc: function(content) {
    return Article.fromXml(content || Article.XML_TEMPLATE);
  },

  componentDidMount: function() {
    var el = React.findDOMNode(this);
    var doc = this.createDoc(this.props.content);
    this.writer = Component.mount($$(LensWriter, {
      doc: doc,
      onSave: this.onSave
    }), el);
  },

  render: function() {
    return React.DOM.div({
      className: 'lens-writer-wrapper'
    });
  }
});

ReactLensWriter.propTypes = {
  content: React.PropTypes.string // XML source of the document
};

module.exports = ReactLensWriter;
{'fraction_non_alphanumeric': 0.16298811544991512, 'fraction_numerical': 0.0, 'mean_word_length': 3.1728045325779037, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1281406', 'n_tokens_mistral': 975, 'n_tokens_neox': 953, 'n_words': 192}