浏览代码

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

Piotrek Koszuliński 8 年之前
父节点
当前提交
0fe5b04f4b

+ 1 - 13
packages/ckeditor5-alignment/src/alignmentediting.js

@@ -55,7 +55,7 @@ export default class AlignmentEditing extends Plugin {
 		const enabledStyles = editor.config.get( 'alignment.styles' );
 
 		// Allow alignment attribute on all blocks.
-		schema.allow( { name: '$block', attributes: 'alignment' } );
+		schema.extend( '$block', { allowAttributes: 'alignment' } );
 
 		data.modelToView.on( 'attribute:alignment', convertStyle() );
 		editing.modelToView.on( 'attribute:alignment', convertStyle() );
@@ -82,18 +82,6 @@ export default class AlignmentEditing extends Plugin {
 				editor.commands.add( commandNameFromStyle( style ), new AlignmentCommand( editor, style, isDefault( style ) ) );
 			} );
 	}
-
-	/**
-	 * @inheritDoc
-	 */
-	afterInit() {
-		const schema = this.editor.model.schema;
-
-		// Disallow alignment on caption elements.
-		if ( schema.hasItem( 'caption' ) ) {
-			schema.disallow( { name: 'caption', attributes: 'alignment' } );
-		}
-	}
 }
 
 /**

+ 2 - 3
packages/ckeditor5-alignment/tests/alignmentcommand.js

@@ -24,9 +24,8 @@ describe( 'AlignmentCommand', () => {
 				editor.commands.add( 'alignCenter', command );
 				editor.commands.add( 'alignLeft', defaultAlignmentCommand );
 
-				model.schema.registerItem( 'paragraph', '$block' );
-
-				model.schema.allow( { name: '$block', inside: '$root', attributes: 'alignment' } );
+				model.schema.register( 'paragraph', { inheritAllFrom: '$block' } );
+				model.schema.extend( '$block', { allowAttributes: 'alignment' } );
 			} );
 	} );