<commit_before>var React = require('react');
var assign = require('react/lib/Object.assign');
var Spec = require('../../../lib/spec');

var spec = new Spec('text', assign({
  innerHTML: {
    category: 'attributes',
    validation: React.PropTypes.string,
    default: 'Hello world'
  },
  fontFamily: {
    category: 'styles',
    validation: React.PropTypes.string,
    default: 'sans-serif'
  },
  color: {
    category: 'styles',
    validation: React.PropTypes.string,
    default: '#333'
  },
  fontStyle: {
    category: 'styles',
    validation: React.PropTypes.string,
    default: 'normal'
  },
  fontWeight: {
    category: 'styles',
    validation: React.PropTypes.string,
    default: 'normal'
  },
  textDecoration: {
    category: 'styles',
    validation: React.PropTypes.string,
    default: 'none'
  },
  textAlign: {
    category: 'styles',
    validation: React.PropTypes.string,
    default: 'center'
  }
}, Spec.getPositionProps()));

module.exports = React.createClass({
  mixins: [
    require('./textedit')
  ],

  statics: {spec},

  propTypes: spec.getPropTypes(),

  getDefaultProps: function () {
    return spec.getDefaultProps();
  },

  render: function() {
    var props = this.props;
    var style = {
      whiteSpace: 'nowrap',
      overflow: "hidden",
      textOverflow: "ellipsis"
    };

    [
      'fontFamily',
      'color',
      'fontWeight',
      'fontStyle',
      'textDecoration',
      'textAlign'
    ].forEach(function (prop) {
      style[prop] = props[prop];
    });

    var content = this.makeEditable(props.innerHTML, style);
    var onPClick = this.activate;
    if (this.state.editing) {
      onPClick = false;
    }
    return <p ref="dims" style={style} onClick={onPClick}>{content}</p>;
  }
});<commit_msg>[Fix #1862] Text defaults<commit_after>var React = require('react');
var assign = require('react/lib/Object.assign');
var Spec = require('../../../lib/spec');
var HELLO_STRINGS = ['Hello', 'Bonjour', 'Halló', 'Hej', 'Olá', '¡Hola!', 'Ciao', 'Halo'];

var spec = new Spec('text', assign({
  innerHTML: {
    category: 'attributes',
    validation: React.PropTypes.string,
    default: function () {
      var randomIndex = Math.floor(Math.random() * HELLO_STRINGS.length);
      return HELLO_STRINGS[randomIndex];
    }
  },
  fontFamily: {
    category: 'styles',
    validation: React.PropTypes.string,
    default: 'sans-serif'
  },
  color: {
    category: 'styles',
    validation: React.PropTypes.string,
    default: '#E06A2C'
  },
  fontSize: {
    category: 'styles',
    validation: React.PropTypes.number,
    default: 20
  },
  fontStyle: {
    category: 'styles',
    validation: React.PropTypes.string,
    default: 'normal'
  },
  fontWeight: {
    category: 'styles',
    validation: React.PropTypes.string,
    default: 'normal'
  },
  textDecoration: {
    category: 'styles',
    validation: React.PropTypes.string,
    default: 'none'
  },
  textAlign: {
    category: 'styles',
    validation: React.PropTypes.string,
    default: 'center'
  }
}, Spec.getPositionProps()));

module.exports = React.createClass({
  mixins: [
    require('./textedit')
  ],

  statics: {spec},

  propTypes: spec.getPropTypes(),

  getDefaultProps: function () {
    return spec.getDefaultProps();
  },

  render: function() {
    var props = this.props;
    var style = {
      whiteSpace: 'nowrap',
      overflow: "hidden",
      textOverflow: "ellipsis"
    };

    [
      'fontFamily',
      'color',
      'fontWeight',
      'fontSize',
      'fontStyle',
      'textDecoration',
      'textAlign'
    ].forEach(function (prop) {
      style[prop] = props[prop];
    });

    var content = this.makeEditable(props.innerHTML, style);
    var onPClick = this.activate;
    if (this.state.editing) {
      onPClick = false;
    }
    return <p ref="dims" style={style} onClick={onPClick}>{content}</p>;
  }
});
{'fraction_non_alphanumeric': 0.1617798353909465, 'fraction_numerical': 0.0030864197530864196, 'mean_word_length': 2.9522357723577235, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '4024839', 'n_tokens_mistral': 1280, 'n_tokens_neox': 1257, 'n_words': 258}