Fixed caret position after pasting
authorAlexander Ebert <ebert@woltlab.com>
Sat, 26 Nov 2016 23:40:06 +0000 (00:40 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Sat, 26 Nov 2016 23:40:12 +0000 (00:40 +0100)
wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabPaste.js

index c328a41aad86ae6eb65a2a58b09a7aed7da160df..6c014904b61dd8119aa628b013c824c4b14d9377 100644 (file)
@@ -147,7 +147,14 @@ $.Redactor.prototype.WoltLabPaste = function() {
                                
                                var marker = elBySel('woltlab-selection-marker', this.$editor[0]);
                                if (marker) {
-                                       this.caret.end(marker.previousElementSibling || marker.parentNode);
+                                       var range = document.createRange();
+                                       range.setStartBefore(marker);
+                                       range.setEndBefore(marker);
+                                       
+                                       var selection = window.getSelection();
+                                       selection.removeAllRanges();
+                                       selection.addRange(range);
+                                       
                                        elRemove(marker);
                                }