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

Commit

Permalink
Third batch of changes aligning schema use to the new API.
Browse files Browse the repository at this point in the history
  • Loading branch information
Reinmar committed Dec 30, 2017
1 parent 7d60465 commit 47ee5f8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/listcommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,5 +307,5 @@ function _fixType( blocks, isBackward, lowestIndent ) {
// @param {module:engine/model/schema~Schema} schema The schema of the document.
// @returns {Boolean}
function checkCanBecomeListItem( block, schema ) {
return schema.checkChild( block.parent, 'listItem' );
return schema.checkChild( block.parent, 'listItem' ) && !schema.isObject( block );
}
25 changes: 24 additions & 1 deletion tests/listcommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ describe( 'ListCommand', () => {
} );

// https://github.com/ckeditor/ckeditor5-list/issues/62
it( 'should not rename blocks which cannot become listItems', () => {
it( 'should not rename blocks which cannot become listItems (list item is not allowed in their parent)', () => {
model.schema.register( 'restricted' );
model.schema.extend( 'restricted', { allowIn: '$root' } );
model.schema.xdisallow( 'paragraph', { allowIn: 'restricted' } );
Expand All @@ -276,6 +276,29 @@ describe( 'ListCommand', () => {
);
} );

it( 'should not rename blocks which cannot become listItems (block is an object)', () => {
model.schema.register( 'image', {
isBlock: true,
isObject: true,
allowIn: '$root'
} );

setData(
model,
'<paragraph>a[bc</paragraph>' +
'<image></image>' +
'<paragraph>de]f</paragraph>'
);

command.execute();

expect( getData( model ) ).to.equal(
'<listItem indent="0" type="bulleted">a[bc</listItem>' +
'<image></image>' +
'<listItem indent="0" type="bulleted">de]f</listItem>'
);
} );

it( 'should rename closest block to listItem and set correct attributes', () => {
// From first paragraph to second paragraph.
// Command value=false, we are turning on list items.
Expand Down

0 comments on commit 47ee5f8

Please sign in to comment.