Skip to content

Commit

Permalink
fix #741
Browse files Browse the repository at this point in the history
  • Loading branch information
jhchen committed Jun 20, 2016
1 parent e9cf8ee commit e5651c6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
1 change: 0 additions & 1 deletion blots/scroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ class Scroll extends Parchment.Scroll {
super.deleteAt(index, length);
if (last != null && first !== last && firstOffset > 0 &&
!(first instanceof BlockEmbed) && !(last instanceof BlockEmbed)) {
let lastChild = first.children.tail;
last.moveChildren(first);
last.remove();
}
Expand Down
8 changes: 8 additions & 0 deletions formats/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ class ListItem extends Block {
}
}

remove() {
if (this.prev == null && this.next == null) {
this.parent.remove();
} else {
super.remove();
}
}

replaceWith(name, value) {
this.parent.isolate(this.offset(this.parent), this.length());
if (name === List.blotName) {
Expand Down
6 changes: 6 additions & 0 deletions test/unit/formats/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,12 @@ describe('List', function() {
expect(this.container).toEqualHTML('<ol><li>0178</li></ol>');
});

it('delete partial', function() {
let editor = this.initialize(Editor, '<p>0123</p><ul><li>5678</li></ul>');
editor.deleteText(2, 5);
expect(this.container).toEqualHTML('<p>0178</p>');
});

it('nested list replacement', function() {
let editor = this.initialize(Editor, `
<ol>
Expand Down

0 comments on commit e5651c6

Please sign in to comment.