Strip empty `<kbd>` on backspace in Safari/Firefox
authorAlexander Ebert <ebert@woltlab.com>
Wed, 4 Jan 2017 16:32:56 +0000 (17:32 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Wed, 4 Jan 2017 16:35:05 +0000 (17:35 +0100)
wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabKeydown.js

index fd514ffce86cf5dbf865639309c2a2be3200d658..a8c10a080995e64137863f25167882707388bd5e 100644 (file)
@@ -94,6 +94,13 @@ $.Redactor.prototype.WoltLabKeydown = function() {
                                        this.core.editor().find('*[style]').not('span, img, #redactor-image-box, #redactor-image-editter').removeAttr('style');
                                        
                                        this.keydown.formatEmpty(e);
+                                       
+                                       // strip empty <kbd>
+                                       var current = this.selection.current();
+                                       if (current.nodeName === 'KBD' && current.innerHTML.length === 0) {
+                                               elRemove(current);
+                                       }
+                                       
                                        this.code.syncFire = true;
                                        
                                }, this), 1);