Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Add tests case to increase CC when splitting inside list. #151

Merged
merged 3 commits into from
Aug 26, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions tests/listediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -3869,6 +3869,45 @@ describe( 'ListEditing', () => {
'<listItem listIndent="2" listType="bulleted">C</listItem>'
);
} );

// https://github.com/ckeditor/ckeditor5-list/issues/126#issuecomment-518206743
it( 'should properly handle split of list items with non-standard converters', () => {
setModelData( model,
'<listItem listType="bulleted" listIndent="0">A[]</listItem>' +
'<listItem listType="bulleted" listIndent="1">B</listItem>' +
'<listItem listType="bulleted" listIndent="2">C</listItem>'
);

editor.model.schema.register( 'splitBlock', { inheritAllFrom: '$block' } );

editor.conversion.for( 'downcast' ).elementToElement( { model: 'splitBlock', view: 'splitBlock' } );
editor.conversion.for( 'upcast' ).add( dispatcher => dispatcher.on( 'element:splitBlock', ( evt, data, conversionApi ) => {
conversionApi.consumable.consume( data.viewItem, { name: true } );

// Use split to allowed parent logic to simulate a non-standard use of `modelCursor` after split.
const splitBlock = conversionApi.writer.createElement( 'splitBlock' );
const splitResult = conversionApi.splitToAllowedParent( splitBlock, data.modelCursor );

conversionApi.writer.insert( splitBlock, splitResult.position );

data.modelRange = conversionApi.writer.createRangeOn( splitBlock );
data.modelCursor = conversionApi.writer.createPositionAfter( splitBlock );
} ) );

const clipboard = editor.plugins.get( 'Clipboard' );

clipboard.fire( 'inputTransformation', {
content: parseView( '<ul><li>a<splitBlock></splitBlock>b</li></ul>' )
} );

expect( getModelData( model, { withoutSelection: true } ) ).to.equal(
'<listItem listIndent="0" listType="bulleted">Aa</listItem>' +
'<splitBlock></splitBlock>' +
'<listItem listIndent="0" listType="bulleted">b</listItem>' +
'<listItem listIndent="1" listType="bulleted">B</listItem>' +
'<listItem listIndent="2" listType="bulleted">C</listItem>'
);
} );
} );

describe( 'other', () => {
Expand Down