Merge remote-tracking branch 'refs/remotes/origin/3.0'
authorAlexander Ebert <ebert@woltlab.com>
Wed, 14 Feb 2018 12:26:24 +0000 (13:26 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Wed, 14 Feb 2018 12:26:24 +0000 (13:26 +0100)
1  2 
wcfsetup/install/files/acp/templates/smileyList.tpl
wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabKeydown.js

index 306f8341f753ca70d15d0f6f6a965f9a95e7d6f5,5e30fe427b8509597901346442e0b1dece5b2276..8099d1ae7f3dda9c3a8b32ea2ab17bfa8dece0c0
@@@ -47,59 -47,64 +47,81 @@@ $.Redactor.prototype.WoltLabKeydown = f
                                
                                // delete the current line on backspace and delete, if it is empty, and move
                                // the caret into the adjacent element, rather than pulling content out
 -                              if (e.which === this.keyCode.BACKSPACE || e.which === this.keyCode.DELETE) {
 +                              if (e.originalEvent.which === this.keyCode.BACKSPACE || e.originalEvent.which === this.keyCode.DELETE) {
                                        if (selection.isCollapsed) {
 -                                              var range = selection.getRangeAt(0);
 -                                              var container = range.startContainer;
 -                                              if (container.nodeType === Node.TEXT_NODE) container = container.parentNode;
 -                                              if (container.nodeName === 'P' && container.childNodes.length === 1 && container.childNodes[0].textContent === '\u200B') {
 -                                                      // simple comparison to check that at least one sibling is not null
 -                                                      if (container.previousElementSibling !== container.nextElementSibling) {
 -                                                              var caretEnd = null, caretStart = null;
 -                                                              
 -                                                              if (e.which === this.keyCode.BACKSPACE) {
 -                                                                      if (container.previousElementSibling === null) {
 -                                                                              caretStart = container.nextElementSibling;
 +                                              var container = this.selection.block();
 +                                              if (container.nodeName === 'P') {
 +                                                      // check if we're merging "adjacent" lists
 +                                                      if (this.list.combineAfterAndBefore(container)) {
 +                                                              e.originalEvent.preventDefault();
 +                                                              return;
 +                                                      }
 +                                                      else if (this.utils.isEmpty(container.innerHTML)) {
 +                                                              // simple comparison to check that at least one sibling is not null
 +                                                              if (container.previousElementSibling !== container.nextElementSibling) {
 +                                                                      var caretEnd = null, caretStart = null;
 +                                                                      
 +                                                                      if (e.originalEvent.which === this.keyCode.BACKSPACE) {
 +                                                                              if (container.previousElementSibling === null) {
 +                                                                                      caretStart = container.nextElementSibling;
 +                                                                              }
 +                                                                              else {
 +                                                                                      caretEnd = container.previousElementSibling;
 +                                                                              }
                                                                        }
                                                                        else {
 -                                                                              caretEnd = container.previousElementSibling;
 +                                                                              if (container.nextElementSibling === null) {
 +                                                                                      caretEnd = container.previousElementSibling;
 +                                                                              }
 +                                                                              else {
 +                                                                                      caretStart = container.nextElementSibling;
 +                                                                              }
                                                                        }
 -                                                              }
 -                                                              else {
 -                                                                      if (container.nextElementSibling === null) {
 -                                                                              caretEnd = container.previousElementSibling;
 +                                                                      
 +                                                                      elRemove(container);
 +                                                                      
 +                                                                      if (caretStart === null) {
 +                                                                              if (caretEnd.nodeName === 'OL' || caretEnd.nodeName === 'UL') {
 +                                                                                      caretEnd = caretEnd.lastElementChild;
 +                                                                              }
 +                                                                              
 +                                                                              this.caret.end(caretEnd);
                                                                        }
                                                                        else {
 -                                                                              caretStart = container.nextElementSibling;
 +                                                                              if (caretStart.nodeName === 'OL' || caretStart.nodeName === 'UL') {
 +                                                                                      caretStart = caretStart.firstElementChild;
 +                                                                              }
 +                                                                              
 +                                                                              this.caret.start(caretStart);
                                                                        }
 +                                                                      
 +                                                                      e.originalEvent.preventDefault();
 +                                                                      return;
                                                                }
 -                                                              
 -                                                              elRemove(container);
 -                                                              
 -                                                              if (caretStart === null) this.caret.end(caretEnd);
 -                                                              else this.caret.start(caretStart);
 -                                                              
 -                                                              e.preventDefault();
 -                                                              return;
                                                        }
                                                }
+                                               else if (this.detect.isWebkit() && container.nodeName === 'LI' && e.which === this.keyCode.DELETE) {
+                                                       // check if caret is at the end of the list item, and if there is an adjacent list item
+                                                       var anchorNode = selection.anchorNode;
+                                                       if (anchorNode.nodeType === Node.TEXT_NODE && anchorNode.textContent.length === selection.anchorOffset && anchorNode.parentNode.lastChild === anchorNode) {
+                                                               var nextItem = container.nextElementSibling;
+                                                               if (nextItem && nextItem.nodeName === 'LI') {
+                                                                       this.buffer.set();
+                                                                       
+                                                                       this.selection.save();
+                                                                       
+                                                                       while (nextItem.childNodes.length) {
+                                                                               container.appendChild(nextItem.childNodes[0]);
+                                                                       }
+                                                                       elRemove(nextItem);
+                                                                       
+                                                                       this.selection.restore();
+                                                                       
+                                                                       e.preventDefault();
+                                                                       return;
+                                                               }
+                                                       }
+                                               }
                                        }
                                }