Work-around for Firefox being unable to backspace tables
authorAlexander Ebert <ebert@woltlab.com>
Mon, 12 Feb 2018 11:30:52 +0000 (12:30 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 12 Feb 2018 11:30:52 +0000 (12:30 +0100)
wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js

index edfeafe41d4c9ea8358a258539bb0c088f8f6580..9c8866011f1148626b5ea47b48a0783b8e1ca605 100644 (file)
@@ -1953,6 +1953,27 @@ RedactorPlugins.wbbcode = function() {
                                                        
                                                        data.cancel = true;
                                                }
+                                               
+                                               // Firefox is unable to backspace an empty table
+                                               if (this.utils.browser('mozilla')) {
+                                                       var block = this.selection.getBlock();
+                                                       if (block && block.nodeName === 'TD') {
+                                                               var table = block.closest('table');
+                                                               var isEmpty = true;
+                                                               
+                                                               var tds = table.querySelectorAll('td');
+                                                               for (var i = 0, length = tds.length; i < length; i++) {
+                                                                       if (!this.utils.isEmpty(tds[i].innerHTML)) {
+                                                                               isEmpty = false;
+                                                                               break;
+                                                                       }
+                                                               }
+                                                               
+                                                               if (isEmpty) {
+                                                                       this.selection.selectElement(table);
+                                                               }
+                                                       }
+                                               }
                                        }
                                break;