|
|
@@ -223,6 +223,24 @@ describe( 'DataController utils', () => {
|
|
|
expect( doc.getRoot().getChild( 0 ).getChild( 1 ) ).to.equal( content );
|
|
|
} );
|
|
|
|
|
|
+ it( 'should use the selection set by deleteContent()', () => {
|
|
|
+ model.on( 'deleteContent', evt => {
|
|
|
+ evt.stop();
|
|
|
+
|
|
|
+ model.change( writer => {
|
|
|
+ writer.setSelection( root.getChild( 0 ), 'end' );
|
|
|
+ } );
|
|
|
+ }, { priority: 'high' } );
|
|
|
+
|
|
|
+ model.schema.register( 'paragraph', { inheritAllFrom: '$block' } );
|
|
|
+
|
|
|
+ setData( model, '<paragraph>[fo]o</paragraph>' );
|
|
|
+
|
|
|
+ insertHelper( 'xyz' );
|
|
|
+
|
|
|
+ expect( getData( model ) ).to.equal( '<paragraph>fooxyz[]</paragraph>' );
|
|
|
+ } );
|
|
|
+
|
|
|
describe( 'in simple scenarios', () => {
|
|
|
beforeEach( () => {
|
|
|
model = new Model();
|
|
|
@@ -697,6 +715,32 @@ describe( 'DataController utils', () => {
|
|
|
'<listItem>]o</listItem>'
|
|
|
);
|
|
|
} );
|
|
|
+
|
|
|
+ // See ckeditor5#2010.
|
|
|
+ it( 'should handle bQ+p over bQ+p insertion', () => {
|
|
|
+ model.schema.register( 'blockQuote', {
|
|
|
+ allowWhere: '$block',
|
|
|
+ allowContentOf: '$root'
|
|
|
+ } );
|
|
|
+
|
|
|
+ setData( model, '<blockQuote><paragraph>[foo</paragraph></blockQuote><paragraph>bar]</paragraph>' );
|
|
|
+
|
|
|
+ const affectedRange = insertHelper( '<blockQuote><paragraph>xxx</paragraph></blockQuote><paragraph>yyy</paragraph>' );
|
|
|
+
|
|
|
+ expect( getData( model ) ).to.equal(
|
|
|
+ '<blockQuote>' +
|
|
|
+ '<paragraph>xxx</paragraph>' +
|
|
|
+ '</blockQuote>' +
|
|
|
+ '<paragraph>yyy[]</paragraph>'
|
|
|
+ );
|
|
|
+
|
|
|
+ expect( stringify( root, affectedRange ) ).to.equal(
|
|
|
+ '[<blockQuote>' +
|
|
|
+ '<paragraph>xxx</paragraph>' +
|
|
|
+ '</blockQuote>' +
|
|
|
+ '<paragraph>yyy</paragraph>]'
|
|
|
+ );
|
|
|
+ } );
|
|
|
} );
|
|
|
|
|
|
describe( 'mixed content to block', () => {
|
|
|
@@ -1275,11 +1319,11 @@ describe( 'DataController utils', () => {
|
|
|
it( 'should not remove empty elements when not-allowed element is paste', () => {
|
|
|
setData( model, '<wrapper><limit><paragraph>[]</paragraph></limit></wrapper>' );
|
|
|
|
|
|
- // pasted content is forbidden in current selection
|
|
|
+ // Pasted content is forbidden in current selection.
|
|
|
const affectedRange = insertHelper( '<wrapper><limit><paragraph>foo</paragraph></limit></wrapper>' );
|
|
|
|
|
|
expect( getData( model ) ).to.equal( '<wrapper><limit>[]<paragraph></paragraph></limit></wrapper>' );
|
|
|
- expect( stringify( root, affectedRange ) ).to.equal( '<wrapper><limit><paragraph>[]</paragraph></limit></wrapper>' );
|
|
|
+ expect( stringify( root, affectedRange ) ).to.equal( '<wrapper><limit>[]<paragraph></paragraph></limit></wrapper>' );
|
|
|
} );
|
|
|
|
|
|
it( 'should correctly paste allowed nodes', () => {
|