[BUGFIX] Leading and trailing blanks can't be edited by the RTE
authorStanislas Rolland <typo3@sjbr.ca>
Fri, 2 Sep 2011 21:08:14 +0000 (17:08 -0400)
committerXavier Perseguers <xavier@typo3.org>
Mon, 24 Oct 2011 18:59:00 +0000 (20:59 +0200)
This patch will:
1. collapse repeating spaces into a single one;
2. replace leading and trailing spaces with non-breaking spaces;
3. replace any space following > and any space preceding < by a
   non-breaking space.

Change-Id: I06a8996f23e050e2e30cc2548c9c1bbafd5b41f0
Resolves: #16217
Releases: 4.5, 4.6
Reviewed-on: http://review.typo3.org/4758
Reviewed-by: Björn Pedersen
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
Reviewed-by: Stefan Neufeind
Reviewed-by: Xavier Perseguers
Tested-by: Xavier Perseguers
typo3/sysext/rtehtmlarea/htmlarea/htmlarea.js

index a43707a..91229f3 100644 (file)
@@ -2230,7 +2230,14 @@ HTMLArea.Editor = Ext.extend(Ext.util.Observable, {
                        case 'wysiwyg':
                                return this.iframe.getHTML();
                        case 'textmode':
-                               return this.textArea.getValue();
+                                       // Collapse repeated spaces non-editable in wysiwyg
+                                       // Replace leading and trailing spaces non-editable in wysiwyg
+                               return this.textArea.getValue().
+                                       replace(/[\x20]+/g, '\x20').
+                                       replace(/^\x20/g, '&nbsp;').
+                                       replace(/\x20$/g, '&nbsp;').
+                                       replace(/>\x20/g, '>&nbsp;').
+                                       replace(/\x20</g, '&nbsp;<');
                        default:
                                return '';
                }