[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)
committerStanislas Rolland <typo3@sjbr.ca>
Mon, 24 Oct 2011 19:19:11 +0000 (21:19 +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: I630249ddf143c401706688a10867ddd33493f971
Resolves: #16217
Releases: 4.5, 4.6
Reviewed-on: http://review.typo3.org/6258
Reviewed-by: Xavier Perseguers
Tested-by: Xavier Perseguers
Reviewed-by: Stanislas Rolland
Tested-by: Stanislas Rolland
typo3/sysext/rtehtmlarea/htmlarea/htmlarea.js

index 54d40b5..1384527 100644 (file)
@@ -2325,7 +2325,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 '';
                }