diff --git a/src/model/utils/deletecontent.js b/src/model/utils/deletecontent.js index d3a627027..7dfa28579 100644 --- a/src/model/utils/deletecontent.js +++ b/src/model/utils/deletecontent.js @@ -118,10 +118,8 @@ function mergeBranches( writer, startPos, endPos ) { return; } - // If one of the positions is a root, then there's nothing more to merge (at least in the current state of implementation). - // Theoretically in this case we could unwrap the
: <$root>x[]
{}y
$root>, but we don't need to support it yet - // so let's just abort. - if ( !startParent.parent || !endParent.parent ) { + // If one of the positions is a limit element, then there's nothing to merge because we don't want to cross the limit boundaries. + if ( writer.model.schema.isLimit( startParent ) || writer.model.schema.isLimit( endParent ) ) { return; } diff --git a/tests/model/utils/deletecontent.js b/tests/model/utils/deletecontent.js index befef6e58..463d93880 100644 --- a/tests/model/utils/deletecontent.js +++ b/tests/model/utils/deletecontent.js @@ -772,6 +772,10 @@ describe( 'DataController utils', () => { schema.extend( '$block', { allowIn: 'blockLimit' } ); schema.register( 'paragraph', { inheritAllFrom: '$block' } ); + schema.register( 'blockQuote', { + allowWhere: '$block', + allowContentOf: '$root' + } ); } ); test( @@ -804,6 +808,60 @@ describe( 'DataController utils', () => { '' + + '' + + 'Foo ' + + '
' + + '' + + 'Foo[]Bar ' + + '
' + + '' + ); + + model.modifySelection( doc.selection, { direction: 'backward' } ); + deleteContent( model, doc.selection ); + + expect( getData( model ) ).to.equal( + '' + + ' ' + + '' + + '' + + 'Foo. ' + + '' + + '' + + 'Foo ' + + '[]Bar ' + + '
' + + '' + ); + } ); } ); describe( 'should leave a paragraph if the entire content was selected', () => {' + + ' ' + + '' + + '' + + 'Foo. ' + + '' + + '' + + 'Foo[]Bar ' + + '