[BUGFIX] htmlArea RTE : Adding link problem with IE
authorStanislas Rolland <typo3@sjbr.ca>
Fri, 20 Jan 2012 22:17:42 +0000 (17:17 -0500)
committerStanislas Rolland <typo3@sjbr.ca>
Fri, 20 Jan 2012 22:18:54 +0000 (23:18 +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: I914bededa9f431e4f1f61af3597d31468a000e0c
Resolves: #31763
Releases: 4.5, 4.6, 4.7
Reviewed-on: http://review.typo3.org/8618
Reviewed-by: Stanislas Rolland
Tested-by: Stanislas Rolland
typo3/sysext/rtehtmlarea/htmlarea/plugins/TYPO3Link/typo3link.js

index a4e4043..a1f2190 100644 (file)
@@ -230,11 +230,17 @@ HTMLArea.TYPO3Link = Ext.extend(HTMLArea.Plugin, {
                                // 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 {