<commit_before>(function($){
  
  elRTE.prototype.ui.prototype.buttons.sofa_image = function(rte, name) {
    this.constructor.prototype.constructor.call(this, rte, name);
    
    this.command = function(){
      
      var cms_dialog = jQuery(jQuery('#cms_dialog').get(0) || jQuery('<div id="cms_dialog"></div>'));
      cms_dialog.dialog({
        title         : rte.i18n('Image'),
        modal         : true,
        resizable     : false,
        width         : 800,
        closeOnEscape : true,
        autoOpen      : false
      });
      
      jQuery.ajax({
        url: '/' + $('meta[name="cms-admin-path"]').attr('content') + '/sites/' + $('meta[name="cms-site-id"]').attr('content') + '/dialog/image',
        success: function(data){
          cms_dialog.html(data);
          cms_dialog.dialog('open');
          $.CMS.enable_uploader();
        }<commit_msg>got image insertion to work<commit_after>(function($){
  
  elRTE.prototype.ui.prototype.buttons.sofa_image = function(rte, name) {
    this.constructor.prototype.constructor.call(this, rte, name);
    
    this.command = function(){
      
      var cms_dialog = jQuery(jQuery('#cms_dialog').get(0) || jQuery('<div id="cms_dialog"></div>'));
      cms_dialog.dialog({
        title         : rte.i18n('Image'),
        modal         : true,
        resizable     : false,
        width         : 800,
        closeOnEscape : true,
        autoOpen      : false
      });
      
      jQuery.ajax({
        url: '/' + $('meta[name="cms-admin-path"]').attr('content') + '/sites/' + $('meta[name="cms-site-id"]').attr('content') + '/dialog/image',
        success: function(data){
          cms_dialog.html(data);
          cms_dialog.dialog('open');
          $.CMS.enable_uploader();
          var opts = {
            rte   : rte,
            dialog: cms_dialog
          }
          $('#cms_dialog .uploaded_files img').click(opts, function(){
            var src = $(this).attr('src');
            opts.rte.history.add();
            var img = $(opts.rte.doc.createElement('img'));
            img.attr('src', src);
            opts.rte.selection.insertNode(img[0]);
            opts.rte.ui.update();
            opts.dialog.dialog('close');
          });
        }
{'fraction_non_alphanumeric': 0.17267467734757455, 'fraction_numerical': 0.005785491766800178, 'mean_word_length': 1.9814323607427056, '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': '7591737', 'n_tokens_mistral': 695, 'n_tokens_neox': 671, 'n_words': 102}