Fixed setting caret before/after tables
authorAlexander Ebert <ebert@woltlab.com>
Mon, 5 Sep 2016 13:15:13 +0000 (15:15 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 5 Sep 2016 13:15:19 +0000 (15:15 +0200)
wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabCaret.js

index 6b00feb703e57629ce4021e1c0afc03fd7aa2e24..7077de0e0a5f0df92964ee532b86911aa2030495 100644 (file)
@@ -146,7 +146,18 @@ $.Redactor.prototype.WoltLabCaret = function() {
                        
                        var block = this.selection.block();
                        if (block === false) {
-                               return;
+                               // check if the caret is now in a <p> before a <table>
+                               // which also happens to be the last element
+                               if (this.selection.current() === this.$editor[0]) {
+                                       var node = this.$editor[0].childNodes[this.selection.get().anchorOffset];
+                                       if (node.nodeType === Node.ELEMENT_NODE && node.nodeName === 'TABLE') {
+                                               block = node;
+                                       }
+                               }
+                               
+                               if (block === false) {
+                                       return;
+                               }
                        }
                        
                        // get block element that received the click