<commit_before>/** @jsx React.DOM */

var React = require('react');
var Section = require('./Section');

var Selection = require('../modules/Selection');
var KeyIntent = require('../modules/KeyIntent');

var ContentState = require('../state/ContentState');
var SelectionState = require('../state/SelectionState');
var KeyActions = require('../actions/KeyActions');

require('../stylesheets/Content.css');

var Content = React.createClass({
  propTypes: {
    onChange: React.PropTypes.func
  },

  getDefaultProps: function() {
    return {
      onChange: function() {}
    }
  },
  getInitialState: function() {
    return {
      content: {sections: []},
      selection: new Selection
    }
  },

  // update when store changes
  componentDidMount: function() {
    ContentState.register(this.setState.bind(this));
    SelectionState.register(this.setState.bind(this));

    this.actions = new KeyActions;
  },

  checkSelection: function() {
    setTimeout(function() {
      SelectionState.set({selection: new Selection})
    }.bind(this), 1);
  },

  // handle changes
  onChange: function(e) {
    this.checkSelection();
    this.props.onChange(this.state.content);
  },
  onMouseUp: function(e) {
    this.checkSelection();
  },
  onBlur: function(e) {
    this.checkSelection();
    this.onChange();
  },

  onKeyUp: function(e) {
    this.checkSelection();
    if (e.keyCode == 91) { this.metaKey = false; }
  },
  onKeyDown: function(e) {
    if (e.keyCode == 91) { this.metaKey = true; }
    e.metaKey = this.metaKey;

    var keyIntent = new KeyIntent(e);
    var intent = keyIntent.getIntent();

    var prevent = this.actions[intent]();
    if (prevent) { e.preventDefault(); }<commit_msg>only execute key intent if one is found<commit_after>/** @jsx React.DOM */

var React = require('react');
var Section = require('./Section');

var Selection = require('../modules/Selection');
var KeyIntent = require('../modules/KeyIntent');

var ContentState = require('../state/ContentState');
var SelectionState = require('../state/SelectionState');
var KeyActions = require('../actions/KeyActions');

require('../stylesheets/Content.css');

var Content = React.createClass({
  propTypes: {
    onChange: React.PropTypes.func
  },

  getDefaultProps: function() {
    return {
      onChange: function() {}
    }
  },
  getInitialState: function() {
    return {
      content: {sections: []},
      selection: new Selection
    }
  },

  // update when store changes
  componentDidMount: function() {
    ContentState.register(this.setState.bind(this));
    SelectionState.register(this.setState.bind(this));

    this.actions = new KeyActions;
  },

  checkSelection: function() {
    setTimeout(function() {
      SelectionState.set({selection: new Selection})
    }.bind(this), 1);
  },

  // handle changes
  onChange: function(e) {
    this.checkSelection();
    this.props.onChange(this.state.content);
  },
  onMouseUp: function(e) {
    this.checkSelection();
  },
  onBlur: function(e) {
    this.checkSelection();
    this.onChange();
  },

  onKeyUp: function(e) {
    this.checkSelection();
    if (e.keyCode == 91) { this.metaKey = false; }
  },
  onKeyDown: function(e) {
    if (e.keyCode == 91) { this.metaKey = true; }
    e.metaKey = this.metaKey;

    var keyIntent = new KeyIntent(e);
    var intent = keyIntent.getIntent();
    if (intent) {
      var prevent = this.actions[intent]();
      if (prevent) { e.preventDefault(); }
    }
{'fraction_non_alphanumeric': 0.16228703436326883, 'fraction_numerical': 0.0028876696505919725, 'mean_word_length': 3.292441140024783, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '3068242', 'n_tokens_mistral': 1079, 'n_tokens_neox': 1063, 'n_words': 221}