<commit_before>if (typeof RedactorPlugins === 'undefined') var RedactorPlugins = {};
RedactorPlugins.line_break = {

  init: function() {
    that = this;

    this.opts.keydownCallback =  function(obj, event) {
      if (event.which != 13) {
        return ;
      }

      // current_node = obj.getCurrentNode();
      // parent_node = obj.getParentNode();
      // bq_node = that.getMostTopBlockquote(current_node, parent_node);
      // console.log('blockquote', current_node, parent_node, bq_node);
      // if (!bq_node) {
      //   return;
      // }

      splitToken = '<div id="_$'+ (new Date()).getTime() + '$_"></div>';
      split_node = $(splitToken)[0]
      obj.insertNodeAtCaret(split_node);
      
      split_contents = obj.getCode().split(splitToken);
      

      obj.setCode(split_contents[0] + "</blockquote><br id=\"__\"><blockquote>" + split_contents[1]);

      /* get the <br id="__"> element and put cursor on it */
        node = that.$editor.find('#__')
        node.removeAttr('id');
        // obj.getSelection().selectNodeContents(node);
        // obj.getSelection().collapse(true);

      console.log('code', obj.getSelection());

    }

  },
  
  getMostTopBlockquote: function(n, r) {
    var last_bq = null;
    while (n) {
      if (n == r)
        break;
      if (n.nodeName === 'BLOCKQUOTE')
        last_bq = n;
      n = n.parentNode;
    }
    return last_bq;
  },

  getOpen: function (n, r) {
    // get the html "open-tag" of a node
    function getOpenTag(n) {
      var attr, copy;
      copy = n.cloneNode(false);
      copy.innerHTML = '';
      attr = ed.dom.getOuterHTML( copy )
               .replace(new RegExp( '<'  + copy.nodeName, "i"), '')
               .replace(new RegExp( '</' + copy.nodeName + '>', "i" ), '');
      return '<' + copy.nodeName.toLowerCase() + attr;
    };

    var result = '';
    while (n) {
      if (n == r)
        break;
      result = getOpenTag(n) + result;
      n = n.parentNode;
    }
    return result;
  }

}<commit_msg>positioning the caret<commit_after>if (typeof RedactorPlugins === 'undefined') var RedactorPlugins = {};
RedactorPlugins.line_break = {

  init: function() {
    that = this;

    this.opts.keydownCallback =  function(obj, event) {
      if (event.which != 13) {
        return ;
      }

      splitToken = '<div id="_$'+ (new Date()).getTime() + '$_"></div>';
      split_node = $(splitToken)[0]
      obj.insertNodeAtCaret(split_node);
      
      split_contents = obj.getCode().split(splitToken);
      obj.setCode(split_contents[0] + "</blockquote><br id=\"__\"><blockquote>" + split_contents[1]);

      /* get the <br id="__"> element and put cursor on it */
        el = that.$editor.find('#__');
        node = el.get(0);
        el.removeAttr('id');
        sel = obj.getSelection();
        range = sel.getRangeAt(0);
        range.collapse(false);
        range.selectNodeContents(node);
        range.collapse(false);
        sel.removeAllRanges();
        sel.addRange(range);

    }

  },
  
  getMostTopBlockquote: function(n, r) {
    var last_bq = null;
    while (n) {
      if (n == r)
        break;
      if (n.nodeName === 'BLOCKQUOTE')
        last_bq = n;
      n = n.parentNode;
    }
    return last_bq;
  },

  getOpen: function (n, r) {
    // get the html "open-tag" of a node
    function getOpenTag(n) {
      var attr, copy;
      copy = n.cloneNode(false);
      copy.innerHTML = '';
      attr = ed.dom.getOuterHTML( copy )
               .replace(new RegExp( '<'  + copy.nodeName, "i"), '')
               .replace(new RegExp( '</' + copy.nodeName + '>', "i" ), '');
      return '<' + copy.nodeName.toLowerCase() + attr;
    };

    var result = '';
    while (n) {
      if (n == r)
        break;
      result = getOpenTag(n) + result;
      n = n.parentNode;
    }
    return result;
  }

}
{'fraction_non_alphanumeric': 0.16757599376461418, 'fraction_numerical': 0.003117692907248636, 'mean_word_length': 2.1739488870568837, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 17, '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': '2710156', 'n_tokens_mistral': 1291, 'n_tokens_neox': 1274, 'n_words': 261}