}
});
+ // each `<td>` must at least contain \u200B, otherwise
+ // Firefox will be unable to place the caret inside
+ elBySelAll('td', div, function (td) {
+ if (td.childNodes.length === 0) {
+ td.innerHTML = '\u200B';
+ }
+ });
+
html = div.innerHTML;
return html;
var firefoxHandleBackspace = (function(e) {
var parent;
var block = this.selection.block();
- if (block.nodeName.indexOf('-') !== -1 && isEmpty(block)) {
+ if (!block) {
+ return;
+ }
+
+ if (block.nodeName === 'TD') {
+ var html = block.innerHTML;
+ if (html === '\u200B') {
+ // backspacing the `\u200B` will break Firefox
+ e.preventDefault();
+ }
+ else if (html === '') {
+ // Firefox already broke itself, try to recover
+ e.preventDefault();
+
+ block.innerHTML = '\u200B';
+ }
+ }
+ else if (block.nodeName.indexOf('-') !== -1 && isEmpty(block)) {
// backspacing an entire block
parent = block.parentNode;
parent.insertBefore(this.marker.get(), block.nextSibling);