<commit_before>//= require editor

Editor.Formator.prototype.link = function(url) {
  this.editor.restoreRange();

  if (url !== undefined) {
    if (this.isWraped('a')) {
      document.getSelection().selectAllChildren($(this.commonAncestorContainer()).closest('a')[0]);
    }
    if (url !== '') {
      if (!/^http/.test(url)) {
        url = 'http://' + url;
      }
      this.exec('createLink', url);
    } else {
      this.exec('unlink');
    }
    Dialog.hide('#link-modal');
  } else {
    if (this.isWraped('a')) {
      link = $(this.commonAncestorContainer()).closest('a').attr('href');
    }
    Dialog.show('#link-modal');
    $('#link-modal').find('input[name=url]').focus();
  }
};

Editor.Formator.prototype.image = function(url) {
  this.editor.restoreRange();

  if (url !== undefined) {
    if (!/^http/.test(url)) {
      url = 'http://' + url;
    }
    this.exec('insertImage', url);
    Dialog.hide('#image-modal');
  } else {
    Dialog.show('#image-modal');
    $('#image-modal').find('input[name=url]').focus();
  }
};

var ArticleEdit = function() {
  this.editor = new Editor({
    toolbar: '#toolbar',
    editable: '#editarea article'
  });

  this.article = $('#editarea article');

  this.connect('#urlname-form', 'submit', this.saveUrlname);
  this.connect('#save-button', 'click', this.saveArticle);
  this.connect('#publish-button', 'click', this.publishArticle);
  this.connect('#draft-button', 'click', this.draftArticle);
  this.connect('#category-form', 'submit', this.saveCategory);
  this.connect('#new-category-form', 'submit', this.createCategory);<commit_msg>fix create link and image url val.<commit_after>//= require editor

Editor.Formator.prototype.link = function(url) {
  this.editor.restoreRange();

  if (url !== undefined) {
    if (this.isWraped('a')) {
      document.getSelection().selectAllChildren($(this.commonAncestorContainer()).closest('a')[0]);
    }
    if (url !== '') {
      if (!/^http/.test(url)) {
        url = 'http://' + url;
      }
      this.exec('createLink', url);
    } else {
      this.exec('unlink');
    }
    Dialog.hide('#link-modal');
  } else {
    var link = '';
    if (this.isWraped('a')) {
      link = $(this.commonAncestorContainer()).closest('a').attr('href');
    }
    Dialog.show('#link-modal');
    $('#link-modal').find('input[name=url]').val(link).focus();
  }
};

Editor.Formator.prototype.image = function(url) {
  this.editor.restoreRange();

  if (url !== undefined) {
    if (!/^http/.test(url)) {
      url = 'http://' + url;
    }
    this.exec('insertImage', url);
    Dialog.hide('#image-modal');
  } else {
    Dialog.show('#image-modal');
    $('#image-modal').find('input[name=url]').val('').focus();
  }
};

var ArticleEdit = function() {
  this.editor = new Editor({
    toolbar: '#toolbar',
    editable: '#editarea article'
  });

  this.article = $('#editarea article');

  this.connect('#urlname-form', 'submit', this.saveUrlname);
  this.connect('#save-button', 'click', this.saveArticle);
  this.connect('#publish-button', 'click', this.publishArticle);
  this.connect('#draft-button', 'click', this.draftArticle);
  this.connect('#category-form', 'submit', this.saveCategory);
  this.connect('#new-category-form', 'submit', this.createCategory);
{'fraction_non_alphanumeric': 0.2212362301101591, 'fraction_numerical': 0.0006119951040391676, 'mean_word_length': 3.540277777777778, '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': '928202', 'n_tokens_mistral': 1080, 'n_tokens_neox': 1067, 'n_words': 167}