Skip to content

Commit

Permalink
Revert "Merge pull request yabwe#1187 from yabwe/fix-backspace-in-fir…
Browse files Browse the repository at this point in the history
…st-empty-paragraph"

This reverts commit cc4e764, reversing
changes made to 7d30f19.
  • Loading branch information
keillera committed May 11, 2018
1 parent 9156a11 commit 37e3e1b
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 27 deletions.
16 changes: 0 additions & 16 deletions spec/content.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -652,22 +652,6 @@ describe('Content TestCase', function () {
expect(this.el.innerHTML).toMatch(/^<p>lorem ipsum<\/p><ul><li>(<br>)?<\/li><li>lorem ipsum<\/li><\/ul>$/);
});
});

describe('within an empty paragraph which is the first element of the editor', function () {
it('should delete the paragraph and place the caret to the next paragraph', function () {
this.el.innerHTML = '<p class=""><br></p><p>test</p>';
var editor = this.newMediumEditor('.editor'),
target = editor.elements[0].querySelector('p'),
range;
placeCursorInsideElement(target, 0);
fireEvent(target, 'keydown', {
keyCode: MediumEditor.util.keyCode.BACKSPACE
});
expect(this.el.innerHTML).toBe('<p>test</p>');
range = document.getSelection().getRangeAt(0);
expect(range.commonAncestorContainer.textContent).toBe('test');
});
});
});

describe('with header tags', function () {
Expand Down
11 changes: 0 additions & 11 deletions src/js/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,17 +152,6 @@
MediumEditor.selection.moveCursor(this.options.ownerDocument, p);

event.preventDefault();
} else if (MediumEditor.util.isKey(event, MediumEditor.util.keyCode.BACKSPACE) &&
MediumEditor.util.isMediumEditorElement(node.parentElement) &&
!node.previousElementSibling &&
node.nextElementSibling &&
isEmpty.test(node.innerHTML)) {

// when cursor is in the first element, it's empty and user presses backspace,
// do delete action instead to get rid of the first element and move caret to 2nd
event.preventDefault();
MediumEditor.selection.moveCursor(this.options.ownerDocument, node.nextSibling);
node.parentElement.removeChild(node);
}
}

Expand Down

0 comments on commit 37e3e1b

Please sign in to comment.