Fixed backspace at quote start
authorAlexander Ebert <ebert@woltlab.com>
Sat, 20 Jun 2015 13:16:21 +0000 (15:16 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Sat, 20 Jun 2015 13:16:21 +0000 (15:16 +0200)
wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js

index 63e9cfabf4b20c7395276a9c81a588d6f10d1ac3..7a8239c53f684465f9ebe5422ce98e0f59667ab5 100644 (file)
@@ -1738,6 +1738,23 @@ RedactorPlugins.wbbcode = function() {
                                                        if ($isEmpty) {
                                                                $preventAndSelectQuote = true;
                                                        }
+                                                       else {
+                                                               // check if caret is at the start of the quote
+                                                               var range = (this.selection.implicitRange === null) ? this.range : this.selection.implicitRange;
+                                                               if (range.startOffset === 0) {
+                                                                       var element = range.startContainer, prev;
+                                                                       while ((element = element.parentNode) !== null) {
+                                                                               prev = element.previousSibling;
+                                                                               if (prev !== null) {
+                                                                                       if (prev.nodeType === Node.ELEMENT_NODE && prev.nodeName === 'HEADER') {
+                                                                                               $preventAndSelectQuote = true;
+                                                                                       }
+                                                                                       
+                                                                                       break;
+                                                                               }
+                                                                       }
+                                                               }                                                               
+                                                       }
                                                }
                                                else {
                                                        var $range = (this.selection.implicitRange === null) ? this.range : this.selection.implicitRange;