Skip to content

Commit

Permalink
Fast backspace bug
Browse files Browse the repository at this point in the history
  • Loading branch information
xdan committed Feb 5, 2018
1 parent 23efb87 commit 3d76d42
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/plugins/backspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ export function backspace(editor: Jodit) {
const startOffsetInRange: number = range.startContainer.nodeType === Node.TEXT_NODE ? range.startOffset : 0;
let startOffset: number = startOffsetInRange;

if (!Dom.isOrContains(editor.editor, textNode) || textNode === editor.editor) {
return;
}

if (textNode && textNode.nodeType === Node.TEXT_NODE && textNode.nodeValue) {
let value: string = textNode.nodeValue,
increment: number = toLeft ? -1 : 1;
Expand Down
3 changes: 2 additions & 1 deletion test/tests/editorTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,12 +355,13 @@ describe('Jodit Editor Tests', function() {

expect(editor.container.querySelectorAll('.jodit_placeholder').length && editor.container.querySelector('.jodit_placeholder').style.display === 'block').to.be.equal(true);

editor.selection.insertNode(Jodit.modules.Dom.create('text', 'test', editor.editorDocument))
editor.selection.insertNode(Jodit.modules.Dom.create('text', 'test', editor.editorDocument));
expect(editor.container.querySelectorAll('.jodit_placeholder').length && editor.container.querySelector('.jodit_placeholder').style.display === 'none').to.be.equal(true);
});
it("Placeholder's fontsize", function () {
var area = appendTestArea();
var editor = new Jodit(area);

editor.editor.style.fontSize = '12px';
simulateEvent('keydown', Jodit.KEY_BACKSPACE, editor.editor);
expect(editor.container.querySelectorAll('.jodit_placeholder').length && editor.container.querySelector('.jodit_placeholder').style.fontSize === '12px').to.be.equal(true);
Expand Down

0 comments on commit 3d76d42

Please sign in to comment.