Skip to content

Commit fdd9202

Browse files
committed
fix joining line with empty line
when first line has more than one child, the second child fails to insert
1 parent cd9bcb3 commit fdd9202

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

blots/scroll.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import Parchment from 'parchment';
22
import Emitter from '../core/emitter';
33
import Block, { BlockEmbed } from './block';
4+
import Break from './break';
45
import Container from './container';
56
import CodeBlock from '../formats/code';
67

@@ -32,7 +33,8 @@ class Scroll extends Parchment.Scroll {
3233
if (last instanceof CodeBlock) {
3334
last.deleteAt(last.length() - 1, 1);
3435
}
35-
first.moveChildren(last, last.children.head);
36+
let ref = last.children.head instanceof Break ? null : last.children.head;
37+
first.moveChildren(last, ref);
3638
first.remove();
3739
}
3840
this.optimize();

test/unit/blots/block.js

+6
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ describe('Block', function() {
5252
expect(scroll.domNode).toEqualHTML('<h2>HelloWorld!</h2>');
5353
});
5454

55+
it('join line with empty', function() {
56+
let scroll = this.initialize(Scroll, '<p>Hello<strong>World</strong></p><p><br></p>');
57+
scroll.deleteAt(10, 1);
58+
expect(scroll.domNode).toEqualHTML('<p>Hello<strong>World</strong></p>');
59+
});
60+
5561
it('join empty lines', function() {
5662
let scroll = this.initialize(Scroll, '<h1><br></h1><p><br></p>');
5763
scroll.deleteAt(1, 1);

0 commit comments

Comments
 (0)