<commit_before>(function($) {

  function save($this, ed) {
    var text = ed.getContent();
    ed.destroy();
    ed.remove();
    $this.story_item('save', text);
  }

  wikimate.plugins.rdoc = {
    title: 'Rich Document',
    emit: function(div, item) {
      return div.html(item.text);
    },

    bind: function(div, item) {
      var $this = this;
      div.on('dblclick', function(e) {
        if ($this.story_item('editable')) {
          $this.story_item('edit');
        }
      });
    },

    edit: function(item) {
      var $this = this;
      var id = wikimate.utils.generateId();
      var textarea = $('<textarea/>').prop('id', id).text(item.text).appendTo(this.empty());
      tinymce.init({
        mode : "exact",
        elements: id,
        theme : "advanced",
        plugins : "autolink,save",
        theme_advanced_buttons3: 'save',
        theme_advanced_toolbar_location : "top",
        theme_advanced_toolbar_align : "left",
        // theme_advanced_statusbar_location : "bottom",
        auto_focus: id,
        save_onsavecallback: function(ed) {
          save($this, ed);
          return false;
        },
        setup: function(ed) {
          ed.onInit.add(function(ed, evt) {
            tinymce.dom.Event.add(ed.getDoc(), 'focusout', function(e) {
              _.defer(save, $this, ed);
            });
          });
        },
      });
      return this;
    }
  };
})(jQuery);
<commit_msg>fix tinymce error when destroying editor with some bold text<commit_after>(function($) {

  function save($this, ed) {
    var text = ed.getContent();
    ed.remove();
    ed.destroy();
    $this.story_item('save', text);
  }

  wikimate.plugins.rdoc = {
    title: 'Rich Document',
    emit: function(div, item) {
      return div.html(item.text);
    },

    bind: function(div, item) {
      var $this = this;
      div.on('dblclick', function(e) {
        if ($this.story_item('editable')) {
          $this.story_item('edit');
        }
      });
    },

    edit: function(item) {
      var $this = this;
      var id = wikimate.utils.generateId();
      var textarea = $('<textarea/>').prop('id', id).text(item.text).appendTo(this.empty());
      tinymce.init({
        mode : "exact",
        elements: id,
        theme : "advanced",
        plugins : "autolink,save",
        theme_advanced_buttons3: 'save',
        theme_advanced_toolbar_location : "top",
        theme_advanced_toolbar_align : "left",
        // theme_advanced_statusbar_location : "bottom",
        auto_focus: id,
        save_onsavecallback: function(ed) {
          save($this, ed);
          return false;
        },
        setup: function(ed) {
          ed.onInit.add(function(ed, evt) {
            tinymce.dom.Event.add(ed.getDoc(), 'focusout', function(e) {
              _.defer(save, $this, ed);
            });
          });
        },
      });
      return this;
    }
  };
})(jQuery);

{'fraction_non_alphanumeric': 0.16043880699348645, 'fraction_numerical': 0.0006856359273225917, 'mean_word_length': 2.0651260504201683, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '734056', 'n_tokens_mistral': 944, 'n_tokens_neox': 919, 'n_words': 171}