[BUGFIX] htmlArea RTE: Cursor jumps to first letter with Chrome 22
authorStanislas Rolland <typo3@sjbr.ca>
Thu, 4 Oct 2012 16:54:03 +0000 (12:54 -0400)
committerStanislas Rolland <typo3@sjbr.ca>
Tue, 9 Oct 2012 13:59:24 +0000 (15:59 +0200)
Selection gets broken when bookmarks are inserted by undo/redo
mechanism in Google Chrome 22.

Change-Id: I7c4bf5a8cf080a26daf49649d8262da1bf18b979
Resolves: #41411
Releases: 4.5, 4.6, 4.7, 6.0
Reviewed-on: http://review.typo3.org/15334
Reviewed-by: Stanislas Rolland
Tested-by: Stanislas Rolland
typo3/sysext/rtehtmlarea/htmlarea/plugins/UndoRedo/undo-redo.js

index 0a6eeac..8ee6c56 100644 (file)
@@ -166,7 +166,8 @@ HTMLArea.UndoRedo = Ext.extend(HTMLArea.Plugin, {
                        if ((!Ext.isIE && !(Ext.isOpera && navigator.userAgent.toLowerCase().indexOf('presto/2.1') != -1)) || (Ext.isIE && selection.type.toLowerCase() != 'control')) {
                                        // Catch error in FF when the selection contains no usable range
                                try {
-                                       bookmark = this.editor.getBookmark(this.editor._createRange(selection));
+                                       var range = this.editor._createRange(selection);
+                                       bookmark = this.editor.getBookmark(range);
                                } catch (e) {
                                        bookmark = null;
                                }
@@ -174,9 +175,13 @@ HTMLArea.UndoRedo = Ext.extend(HTMLArea.Plugin, {
                                // Get the bookmarked html text and remove the bookmark
                        if (bookmark) {
                                bookmarkedText = this.editor.getInnerHTML();
+                                       // Working aroung buggy Google Chrome 22 (selection broken by inserted bookmark node)
+                               if (Ext.isChrome) {
+                                       this.editor.setHTML(bookmarkedText);
+                               }
                                var range = this.editor.moveToBookmark(bookmark);
                                        // Restore Firefox selection
-                               if (Ext.isGecko) {
+                               if (Ext.isGecko || Ext.isChrome) {
                                        this.editor.emptySelection(selection);
                                        this.editor.addRangeToSelection(selection, range);
                                }