Fixed pasting of content with a trailing link
authorAlexander Ebert <ebert@woltlab.com>
Mon, 11 Sep 2017 14:28:00 +0000 (16:28 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 11 Sep 2017 14:28:00 +0000 (16:28 +0200)
wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabPaste.js

index 0a27bd45183af58e98a81ba5b02c85a7ab82688d..f0de39ad39c4cc0a1820c24eb0cb848b96e49556 100644 (file)
@@ -204,28 +204,14 @@ $.Redactor.prototype.WoltLabPaste = function() {
                                        }).bind(this));
                                }
                                
-                               // fix selection marker
-                               /*
-                               elBySelAll('.redactor-selection-marker', div, elRemove);
-                               div.appendChild(elCreate('woltlab-selection-marker'));
-                               */
-                               
                                mpInsert.call(this, div.innerHTML, data);
                                
-                               /*
-                               var marker = elBySel('woltlab-selection-marker', this.$editor[0]);
-                               if (marker) {
-                                       var range = document.createRange();
-                                       range.setStartBefore(marker);
-                                       range.setEndBefore(marker);
-                                       
-                                       var selection = window.getSelection();
-                                       selection.removeAllRanges();
-                                       selection.addRange(range);
-                                       
-                                       elRemove(marker);
+                               // check if the caret is now inside an <a> element, but at
+                               // the very last position
+                               var selection = window.getSelection();
+                               if (selection.rangeCount && selection.anchorNode.nodeName === 'A' && selection.anchorOffset === selection.anchorNode.childNodes.length) {
+                                       this.caret.after(selection.anchorNode);
                                }
-                               */
                                
                                if (pastedImages.length) {
                                        window.setTimeout((function () {