Improved caret position for pasted lists
authorAlexander Ebert <ebert@woltlab.com>
Tue, 21 Nov 2017 19:19:02 +0000 (20:19 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 21 Nov 2017 19:19:02 +0000 (20:19 +0100)
wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabCaret.js

index 8515169f9db8155773f696bd1861814a48b778f0..475dfb0c5d6b52e06c5f5147d2c1948ded5987ca 100644 (file)
@@ -23,6 +23,13 @@ $.Redactor.prototype.WoltLabCaret = function() {
                        this.caret.end = (function (node) {
                                node = this.caret.prepare(node);
                                
+                               // handle trailing lists
+                               if (node.nodeName === 'OL' || node.nodeName === 'UL') {
+                                       node = node.lastElementChild;
+                                       
+                                       if (node === null) node = node.parentNode;
+                               }
+                               
                                var useCustomRange = false;
                                if (node.nodeType === Node.ELEMENT_NODE && node.lastChild && node.lastChild.nodeName === 'P') {
                                        useCustomRange = true;