Opened 8 years ago

Closed 8 years ago

#569 closed defect (wontfix)

Newline automatically added to blank Xinha field

Reported by: paulb Owned by: gogo
Priority: normal Milestone: Version 1.0
Component: Xinha Core Version: trunk
Severity: major Keywords:
Cc:

Description

From the nightly build on Oct 25th, 2005 (but its been in there since at least April) - Create a Xinha field with nothing inside the textarea (i.e. the empty string). If you switch to TEXT mode you will see that there is already a newline in the field. If you save the field, it will not be the empty string. Note you do not have to switch to TEXT mode first to make this happen - I'm just explaining how you see this bug.

Change History (4)

comment:1 Changed 8 years ago by eric3d@…

  • Severity changed from normal to major

This also effects editing content that is already in a HTMLarea (textarea) window. For example a textarea window is fed data from PHP (using echo) and the Xinha editor replaces the textarea tag, then when you edit something, automatically a newline is added, this occurs even in another xinha editor within the same page. Maked maintaining data consistancy very difficult.

comment:2 Changed 8 years ago by gocher

change the following lines in htmlarea.js:

    // onsubmit get the HTMLArea content and update original textarea.
    HTMLArea.prependDom0Event
    (
      this._textArea.form,
      'submit',
      function() {editor._textArea.value = editor.outwardHtml(editor.getHTML()); return true;}
    );


to:

    // onsubmit get the HTMLArea content and update original textarea.
    HTMLArea.prependDom0Event
    (
      this._textArea.form,
      'submit',
      function() {
        editor._textArea.value = editor.outwardHtml(editor.getHTML());
        editor._textArea.value = editor._textArea.value.replace(/^[\r\n]+|\s+$/, '');//replace leading linefeeds
        if(editor._textArea.value=='<br />') editor._textArea.value='';//replace newline br in empty textArea
        return true;
      }
    );

and both problems are fixed!

comment:3 Changed 8 years ago by gocher

A better way is to replace empty paragraphs too, because in Firefox you get <br /> as result and in IE you get <p>&mbsp;</p>!

    // onsubmit get the HTMLArea content and update original textarea.
    HTMLArea.prependDom0Event
    (
      this._textArea.form,
      'submit',
      function() {
        editor._textArea.value = editor.outwardHtml(editor.getHTML());
        editor._textArea.value = editor._textArea.value.replace(/^[\r\n]+|\s+$/, '');//replace leading linefeeds
        if(editor._textArea.value.replace(/[<p>|<\/p>| |<br \/>|\r|\n]/gi,'')=='') editor._textArea.value='';
        return true;
      }
    );

comment:4 Changed 8 years ago by gogo

  • Resolution set to wontfix
  • Status changed from new to closed

I don't like these solutions, the reason being that who are we to say if the user really doesn't want a br etc there. I'm closing WONTFIX, for two reasons, first is as I say above, second is that this is a minor thing that people could clean up on the server side if they really really wanted.

Note: See TracTickets for help on using tickets.