Skip to content

Commit

Permalink
fix code block bug and add test
Browse files Browse the repository at this point in the history
  • Loading branch information
jhchen committed Aug 16, 2017
1 parent 760c478 commit 9bc217f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 0 additions & 3 deletions blots/scroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ class Scroll extends Parchment.Scroll {
super.deleteAt(index, length);
if (last != null && first !== last && offset > 0 &&
!(first instanceof BlockEmbed) && !(last instanceof BlockEmbed)) {
if (last instanceof CodeBlock) {
last.deleteAt(last.length() - 1, 1);
}
let ref = last.children.head instanceof Break ? null : last.children.head;
first.moveChildren(last, ref);
first.remove();
Expand Down
7 changes: 7 additions & 0 deletions test/unit/formats/code.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,13 @@ describe('Code', function() {
expect(editor.scroll.domNode).toEqualHTML('<p>0123</p>');
});

it('delete last', function() {
let editor = this.initialize(Editor, { html: '<p>0123</p><pre>\n</pre><p>5678</p>' });
editor.deleteText(4, 1);
expect(editor.getDelta()).toEqual(new Delta().insert('0123').insert('\n', { 'code-block': true }).insert('5678\n'));
expect(editor.scroll.domNode).toEqualHTML('<pre>0123</pre><p>5678</p>');
});

it('delete merge before', function() {
let editor = this.initialize(Editor, { html: '<h1>0123</h1><pre>4567\n</pre>' });
editor.deleteText(4, 1);
Expand Down

0 comments on commit 9bc217f

Please sign in to comment.