[wp-trac] [WordPress Trac] #37066: Enter after a break line being removed when switching to editor text mode

WordPress Trac noreply at wordpress.org
Tue Jan 31 23:02:17 UTC 2017


#37066: Enter after a break line being removed when switching to editor text mode
--------------------------+-----------------------------
 Reporter:  rellect       |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Future Release
Component:  TinyMCE       |     Version:  4.5.2
 Severity:  minor         |  Resolution:
 Keywords:  has-patch     |     Focuses:  administration
--------------------------+-----------------------------
Changes (by rellect):

 * keywords:  needs-patch => has-patch


Comment:

 The problem was with the following regex (in editor.js):
 {{{
 html = html.replace( /\s*<br ?\/?>\s*/gi, '\n' );
 }}}
 At this point of the code, all <p> tags are already replaced with \n
 And the above regex strips all whitespaces before and after the <br>s,
 which also removed the break lines separating the paragraphs.

 The fix I've included in the patch is:
 {{{
 html = html.replace( /\s*?(\n)?\s*<br ?\/?>\s*/gi, '$1\n' );
 }}}
 Specificaly {{{\s*?(\n)?\s*}}} - this will look for one new line within
 the whitespace, and append it back to the string.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/37066#comment:7>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list