<commit_before>
//==================================================================================================
//FIELD
//==================================================================================================

Form.Field = Backbone.View.extend({

  template: _.template('\
    <div>\
      <label for="<%= editorId %>"><%= title %></label>\
      <div>\
        <span data-editor></span>\
        <div data-error></div>\
        <div><%= help %></div>\
      </div>\
    </div>\
  '),

  /**
   * CSS class name added to the field when there is a validation error
   */
  errorClassName: 'error',

  initialize: function(options) {
    options = options || {};

    //Store important data
    _.extend(this, _.pick(options, 'form', 'key', 'value', 'model', 'idPrefix'));

    //Override defaults
    _.extend(this, _.pick(options, 'template', 'errorClassName'));

    //Create the full field schema, merging defaults etc.
    this.schema = this.createSchema(options.schema);

    //Create editor
    this.editor = this.createEditor();
  },

  /**
   * Creates the full field schema, merging defaults etc.
   *
   * @param {Object|String} schema
   *
   * @return {Object}
   */
  createSchema: function(schema) {
    if (_.isString(schema)) schema = { type: schema };

    return _.extend({
      type: 'Text',<commit_msg>Set editor initial value when creating a new field<commit_after>
//==================================================================================================
//FIELD
//==================================================================================================

Form.Field = Backbone.View.extend({

  template: _.template('\
    <div>\
      <label for="<%= editorId %>"><%= title %></label>\
      <div>\
        <span data-editor></span>\
        <div data-error></div>\
        <div><%= help %></div>\
      </div>\
    </div>\
  '),

  /**
   * CSS class name added to the field when there is a validation error
   */
  errorClassName: 'error',

  initialize: function(options) {
    options = options || {};

    //Store important data
    _.extend(this, _.pick(options, 'form', 'key', 'model', 'idPrefix'));

    //Override defaults
    _.extend(this, _.pick(options, 'template', 'errorClassName'));

    //Create the full field schema, merging defaults etc.
    this.schema = this.createSchema(options.schema);

    //Create editor
    this.editor = this.createEditor();

    //Set initial value
    this.setValue(options.value);
  },

  /**
   * Creates the full field schema, merging defaults etc.
   *
   * @param {Object|String} schema
   *
   * @return {Object}
   */
  createSchema: function(schema) {
    if (_.isString(schema)) schema = { type: schema };

    return _.extend({
      type: 'Text',
{'fraction_non_alphanumeric': 0.2900542495479204, 'fraction_numerical': 0.0, 'mean_word_length': 3.1345291479820627, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 33, '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': '4387287', 'n_tokens_mistral': 767, 'n_tokens_neox': 716, 'n_words': 200}