ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Rich Text Editor - line breaks disappear

May 17, 2012 6:58am

Subscribe [37]
  • #31 / May 17, 2013 4:15pm

    Pascal Kriete

    2589 posts

    @tenfastfeet It doesn’t look like you’re on 2.6.1 if that’s the code you’re commenting out. We made significant headway on this in 2.6.1. Would you mind grabbing the update to see if that solves your issues?

    @geertdeg Do you have an example of code that breaks for you, as well as the browser it happens in?

  • #32 / May 21, 2013 8:34pm

    tenfastfeet

    4 posts

    Well, just updated to 6.1… pretty vanilla install going on here and the editor is barely usable.  I can’t give certain text a heading tag, erroneous formatting is inserted upon save, single line and paragraph breaks are inserted at random… can I just have the old editor back please?  Or why not use a free tried-and-true editor from the open source community.

  • #33 / May 23, 2013 12:42am

    geertdeg

    4 posts

    @tenfastfeet It doesn’t look like you’re on 2.6.1 if that’s the code you’re commenting out. We made significant headway on this in 2.6.1. Would you mind grabbing the update to see if that solves your issues?

    @geertdeg Do you have an example of code that breaks for you, as well as the browser it happens in?

    I’m starting from a new 2.6.1 installation and it simply doesn’t work. It’s really frustrating, leaving merely other options than to buy the Wygwam extension or migrating clients to WordPress, Drupal or Modx. It’s since 2.5 that Ellislab promises us a Wysiwyg editor and it has never worked. This is disappointing for paid software. I’m using Safari 6.03, OS X 10.8

  • #34 / May 23, 2013 12:28pm

    philfreo

    50 posts

    I can confirm there’s definitely a problem here on 2.6.1.

  • #35 / Jun 01, 2013 11:56am

    Panos S.

    58 posts

    This is just embarasing. Please fix this.

  • #36 / Jun 07, 2013 11:43am

    Boxhead

    13 posts

    I think in the publish/edit pages the RTE is getting the formatting correct. The problem I’m having with it now is that when that particular field is output in a temple it strips out all tags completely. Other HTML tags do remain in the output content. The tags do show in ‘code view’ on the publish/edit pages.

    Running EE v2.6.1 from a fresh install, no other 3rd party modules/plugins to interfere.

    Any thoughts?

    Perhaps this issue is somewhat unrelated to the original topic of this forum post. If so please do move it or set-up a new post.

    Thanks

  • #37 / Jun 18, 2013 2:36pm

    I had been using redactee, but that stopped working after updating EE - it seems to be abandoned. Tried out the EE rich text editor and experienced the same awful stuff as everyone else. The code actually looks fine as I’m editing it, but upon hitting submit it breaks it all, strips paragraphs, etc. This, plus its terrible setup for multiple environments, and every other problem I run into really makes me wish I hadn’t chosen EE for multiple projects. At this point, it’s just embarrassing.

  • #38 / Jun 24, 2013 4:37am

    Please solve the problem, is orrible!!

  • #39 / Jul 23, 2013 3:20am

    Agreed, I have had 4 clients contact me telling me its not working… oh yes Ellislabs, this isn’t just embarrassing for you, but VERY embarrassing for ME!

    14 months since this thread started, and still it doesn’t work correctly!

  • #40 / Jul 31, 2013 10:51am

    unlockdemocracy

    1 posts

    Good to see it isn’t just me. Sigh. Plan B…

  • #41 / Aug 05, 2013 5:13am

    fogcity

    260 posts

    I also see this and cannot ship the site (or buy the EE2 license to do so) until this is fixed.

  • #42 / Aug 12, 2013 12:02pm

    Jordan Moore

    45 posts

    BUMP.

    Yeah, looks like this bug has been around for a while and it’s affecting a lot of people. Any ETA on a fix?

  • #43 / Sep 20, 2013 12:47pm

    jpwdesigns

    12 posts

    This seriously is ridiculous. No amount of flaming could express the fail here. Getting ready to rewrite this function save_field. Will post if i get it worked out.

  • #44 / Sep 20, 2013 3:00pm

    jpwdesigns

    12 posts

    There we go.

    Notice, I had to remove the lines that had code string replace in order to get it to post in the forum. You’ll not want to copy past this directly. But you can see what I did.


    The RTE also adds   so i’ve got a plugin emtpypstripper.php (google it) that is working for me and I just added   $result = str_replace(’ ’, ’ ‘, $result);
    before output.

    /**
      * Save RTE field
      *
      * Use to clean up RTE content prior to DB insertion
      * 
      * @param string $data the RTE html content
      * 
      * @return string   the cleaned up RTE html content
      */
     public function save_field($data)
     {
      if (ee()->session->userdata('rte_enabled') != 'y' 
       OR ee()->config->item('rte_enabled') != 'y')
      {
       return $data;
      }
      
      // If the editor was saved empty, save nothing to database
      // so it behaves as expected with conditional tags
      if ($this->is_empty($data))
      {
       return NULL;
      }
    
      // I don't see any reason to have   going on. EE keeps adding it in. Maybe via the js RTE.
      // Oh and if you are doing layout by     then you're doing it wrong.
      $data = str_replace(' ', ' ', $data);
      $data = htmlspecialchars_decode($data, ENT_QUOTES);
    
      // decode double encoded code chunks
      if (preg_match_all("/\[code\](.+?)\[\/code\]/si", $data, $matches))
      {
       $i = 0;
       foreach ($matches[1] as $chunk)
       {
        $chunk = trim($chunk);
        $chunk = html_entity_decode($chunk, ENT_QUOTES, 'UTF-8');
        $i++;
       }
      }
    
      return $data;
     }
     
     // ------------------------------------------------------------------------
    
     /**
      * Display an RTE field
      * 
      * @param string $data       the RTE html content
      * @param string $field_name the field name for the RTE field
      * @param array $settings   field settings:
      *      field_ta_rows - the number of textarea rows
      *      field_text_direction - ltr or rtl
      *      field_fmt - xhtml, br or none
      * 
      * @return string 
      */
    public function display_field($data, $field_name, $settings)
     {
      ee()->load->helper('form');
      
      $field = array(
       'name' => $field_name,
       'id' => $field_name,
       'rows' => $settings['field_ta_rows'],
       'dir' => $settings['field_text_direction']
      );
    
    
      // form prepped nonsense
      $data = htmlspecialchars_decode($data, ENT_QUOTES);
      $code_marker = unique_marker('code');
      $code_chunks = array();
    
      // removed xhtml. Don't want that.
      $field_ft = '';
    
      // remove code chunks
      if (preg_match_all("/\[code\](.+?)\[\/code\]/si", $data, $matches))
      {
       foreach ($matches[1] as $i => $chunk)
       {
        $code_chunks[] = trim($chunk);
        $data = str_replace($matches[0][$i], $code_marker.$i, $data);
       }
      }
    
      // Check the RTE module and user's preferences
      if (ee()->session->userdata('rte_enabled') == 'y' 
       AND ee()->config->item('rte_enabled') == 'y')
      {
       $field['class'] = 'WysiHat-field';
    
       foreach ($code_chunks as &$chunk)
       {
        $chunk = htmlentities($chunk, ENT_QUOTES, 'UTF-8');
       }
    
       // Removed xhtml. Don't want it on RTE.
      }
    
      // put code chunks back
      foreach ($code_chunks as $i => $chunk)
      {
      }
      
      // Swap {filedir_x} with the real URL. It will be converted back
      // upon submit by the RTE Image tool.
      ee()->load->model('file_upload_preferences_model');
      $dirs = ee()->file_upload_preferences_model->get_file_upload_preferences(ee()->session->userdata('group_id'));
      
      foreach($dirs as $d)
      {
       // tag to replace
       $filedir = "{filedir_{$d['id']}}";
    
       $data = str_replace($filedir, $d['url'], $data);
      }
     
      $data = htmlspecialchars($data, ENT_QUOTES);
      // Get rid of  
      $data = str_replace(' ', ' ', $data);
      $field['value'] = $data;
      
      return form_textarea($field);
     }
  • #45 / Nov 14, 2013 5:42am

    ArneG

    9 posts

    Thanks that

    $data = str_replace(' ', ' ', $data);

    seems to do the trick…

    crazy that this isn’t fixed

     

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases