diff --git a/blots/scroll.js b/blots/scroll.js index d82f7733c6..eaac8b9297 100644 --- a/blots/scroll.js +++ b/blots/scroll.js @@ -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(); } diff --git a/formats/list.js b/formats/list.js index b6cef7e718..d9c43d1486 100644 --- a/formats/list.js +++ b/formats/list.js @@ -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) { diff --git a/test/unit/formats/list.js b/test/unit/formats/list.js index afa9e58325..964246304e 100644 --- a/test/unit/formats/list.js +++ b/test/unit/formats/list.js @@ -192,6 +192,12 @@ describe('List', function() { expect(this.container).toEqualHTML('
0123
0178
'); + }); + it('nested list replacement', function() { let editor = this.initialize(Editor, `