[BUGFIX] htmlArea RTE : Adding link problem with IE
authorStanislas Rolland <typo3@sjbr.ca>
Tue, 17 Jan 2012 22:58:04 +0000 (17:58 -0500)
committerStanislas Rolland <typo3@sjbr.ca>
Fri, 20 Jan 2012 22:06:00 +0000 (23:06 +0100)
Problem: Link may not be created on cell, list element or paragraph
when following element of same type already contains a link.
Solution: Fix selection breaking procedure

Change-Id: Ia35f4eb1f756eb5abc9d9d641e4b2fc1402cbb8f
Resolves: #31763
Releases: 4.5, 4.6, 4.7
Reviewed-on: http://review.typo3.org/7836
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
Reviewed-by: Jean-S├ębastien Gervais
Tested-by: Jean-S├ębastien Gervais
Reviewed-by: Helmut Hummel
Tested-by: Helmut Hummel
typo3/sysext/rtehtmlarea/htmlarea/plugins/TYPO3Link/typo3link.js

index 052bac6..97d840f 100644 (file)
@@ -237,11 +237,17 @@ HTMLArea.TYPO3Link = HTMLArea.Plugin.extend({
                                // Create new link
                        selection = this.editor._getSelection();
                        range = this.editor._createRange(selection);
-                               // Clean existing anchors otherwise Mozilla may create nested anchors while IE may update exisitng link
-                               // Selection may be lost when cleaning links
-                       var bookmark = this.editor.getBookmark(range);
-                       this.cleanAllLinks(node, range);
-                       this.editor.selectRange(this.editor.moveToBookmark(bookmark));
+                               // Clean existing anchors otherwise Mozilla may create nested anchors while IE may update existing link
+                       if (Ext.isIE) {
+                               this.cleanAllLinks(node, range);
+                       } else {
+                                       // Selection may be lost when cleaning links
+                                       // Note: In IE, the following procedure breaks the selection used by the execCommand
+                               var bookmark = this.editor.getBookmark(range);
+                               this.cleanAllLinks(node, range);
+                               var range = this.editor.moveToBookmark(bookmark);
+                               this.editor.selectRange(range);
+                       }
                        if (Ext.isGecko) {
                                this.editor.document.execCommand('CreateLink', false, encodeURI(theLink));
                        } else {