8
0
Просмотр исходного кода

Second batch of changes updating schema use to match the new API.

Piotrek Koszuliński 8 лет назад
Родитель
Сommit
29c3d09169

+ 1 - 8
packages/ckeditor5-alignment/src/alignmentcommand.js

@@ -98,14 +98,7 @@ export default class AlignmentCommand extends Command {
 	 * @private
 	 */
 	_canBeAligned( block ) {
-		const schema = this.editor.model.schema;
-
-		// Check if adding alignment attribute to selected block is allowed.
-		return schema.check( {
-			name: block.name,
-			// Apparently I must pass current attributes as otherwise adding alignment on listItem will fail.
-			attributes: [ ...block.getAttributeKeys(), 'alignment' ]
-		} );
+		return this.editor.model.schema.checkAttribute( block, 'alignment' );
 	}
 
 	/**

+ 7 - 5
packages/ckeditor5-alignment/tests/alignmentediting.js

@@ -40,7 +40,7 @@ describe( 'AlignmentEditing', () => {
 	} );
 
 	it( 'allows for alignment in $blocks', () => {
-		expect( model.schema.check( { name: '$block', inside: '$root', attributes: 'alignment' } ) ).to.be.true;
+		expect( model.schema.checkAttribute( [ '$root', '$block' ], 'alignment' ) ).to.be.true;
 	} );
 
 	describe( 'integration', () => {
@@ -56,19 +56,21 @@ describe( 'AlignmentEditing', () => {
 		} );
 
 		it( 'is allowed on paragraph', () => {
-			expect( model.schema.check( { name: 'paragraph', attributes: 'alignment' } ) ).to.be.true;
+			expect( model.schema.checkAttribute( [ '$root', 'paragraph' ], 'alignment' ) ).to.be.true;
 		} );
 
 		it( 'is allowed on listItem', () => {
-			expect( model.schema.check( { name: 'listItem', attributes: [ 'type', 'indent', 'alignment' ] } ) ).to.be.true;
+			expect( model.schema.checkAttribute( [ '$root', 'listItem' ], 'type' ) ).to.be.true;
+			expect( model.schema.checkAttribute( [ '$root', 'listItem' ], 'indent' ) ).to.be.true;
+			expect( model.schema.checkAttribute( [ '$root', 'listItem' ], 'alignment' ) ).to.be.true;
 		} );
 
 		it( 'is allowed on heading', () => {
-			expect( model.schema.check( { name: 'heading1', attributes: 'alignment' } ) ).to.be.true;
+			expect( model.schema.checkAttribute( [ '$root', 'heading1' ], 'alignment' ) ).to.be.true;
 		} );
 
 		it( 'is disallowed on caption', () => {
-			expect( model.schema.check( { name: 'caption', attributes: 'alignment' } ) ).to.be.false;
+			expect( model.schema.checkAttribute( [ '$root', 'image', 'caption' ], 'alignment' ) ).to.be.false;
 		} );
 	} );