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

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

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

+ 1 - 1
packages/ckeditor5-heading/src/headingengine.js

@@ -58,7 +58,7 @@ export default class HeadingEngine extends Plugin {
 			// Skip paragraph - it is defined in required Paragraph feature.
 			if ( option.modelElement !== defaultModelElement ) {
 				// Schema.
-				editor.model.schema.registerItem( option.modelElement, '$block' );
+				editor.model.schema.register( option.modelElement, '$block' );
 
 				// Build converter from model to view for data and editing pipelines.
 				buildModelConverter().for( data.modelToView, editing.modelToView )

+ 12 - 12
packages/ckeditor5-heading/tests/headingcommand.js

@@ -27,16 +27,16 @@ describe( 'HeadingCommand', () => {
 			schema = model.schema;
 
 			editor.commands.add( 'paragraph', new ParagraphCommand( editor ) );
-			schema.registerItem( 'paragraph', '$block' );
+			schema.register( 'paragraph', { inheritAllFrom: '$block' } );
 
 			for ( const option of options ) {
 				commands[ option.modelElement ] = new HeadingCommand( editor, option.modelElement );
-				schema.registerItem( option.modelElement, '$block' );
+				schema.register( option.modelElement, '$block' );
 			}
 
-			schema.registerItem( 'notBlock' );
-			schema.allow( { name: 'notBlock', inside: '$root' } );
-			schema.allow( { name: '$text', inside: 'notBlock' } );
+			schema.register( 'notBlock' );
+			schema.extend( 'notBlock', { allowIn: '$root' } );
+			schema.extend( '$text', { allowIn: 'notBlock' } );
 
 			root = document.getRoot();
 		} );
@@ -113,12 +113,12 @@ describe( 'HeadingCommand', () => {
 
 		// https://github.com/ckeditor/ckeditor5-heading/issues/73
 		it( 'should not rename blocks which cannot become headings', () => {
-			schema.registerItem( 'restricted' );
-			schema.allow( { name: 'restricted', inside: '$root' } );
-			schema.disallow( { name: 'heading1', inside: 'restricted' } );
+			schema.register( 'restricted' );
+			schema.extend( 'restricted', { allowIn: '$root' } );
+			schema.dis.extend( 'heading1', { allowIn: 'restricted' } );
 
-			schema.registerItem( 'fooBlock', '$block' );
-			schema.allow( { name: 'fooBlock', inside: 'restricted' } );
+			schema.register( 'fooBlock', { inheritAllFrom: '$block' } );
+			schema.extend( 'fooBlock', { allowIn: 'restricted' } );
 
 			setData(
 				model,
@@ -166,8 +166,8 @@ describe( 'HeadingCommand', () => {
 			} );
 
 			it( 'converts topmost blocks', () => {
-				schema.registerItem( 'inlineImage', '$inline' );
-				schema.allow( { name: '$text', inside: 'inlineImage' } );
+				schema.register( 'inlineImage', { allowWhere: '$text' } );
+				schema.extend( '$text', { allowIn: 'inlineImage' } );
 
 				setData( model, '<paragraph><inlineImage>foo[]</inlineImage>bar</paragraph>' );
 				commands.heading1.execute();

+ 11 - 11
packages/ckeditor5-heading/tests/headingengine.js

@@ -33,18 +33,18 @@ describe( 'HeadingEngine', () => {
 	} );
 
 	it( 'should set proper schema rules', () => {
-		expect( model.schema.hasItem( 'heading1' ) ).to.be.true;
-		expect( model.schema.hasItem( 'heading2' ) ).to.be.true;
-		expect( model.schema.hasItem( 'heading3' ) ).to.be.true;
+		expect( model.schema.isRegistered( 'heading1' ) ).to.be.true;
+		expect( model.schema.isRegistered( 'heading2' ) ).to.be.true;
+		expect( model.schema.isRegistered( 'heading3' ) ).to.be.true;
 
 		expect( model.schema.check( { name: 'heading1', inside: '$root' } ) ).to.be.true;
-		expect( model.schema.check( { name: '$inline', inside: 'heading1' } ) ).to.be.true;
+		expect( model.schema.check( { name: '$text', inside: 'heading1' } ) ).to.be.true;
 
 		expect( model.schema.check( { name: 'heading2', inside: '$root' } ) ).to.be.true;
-		expect( model.schema.check( { name: '$inline', inside: 'heading2' } ) ).to.be.true;
+		expect( model.schema.check( { name: '$text', inside: 'heading2' } ) ).to.be.true;
 
 		expect( model.schema.check( { name: 'heading3', inside: '$root' } ) ).to.be.true;
-		expect( model.schema.check( { name: '$inline', inside: 'heading3' } ) ).to.be.true;
+		expect( model.schema.check( { name: '$text', inside: 'heading3' } ) ).to.be.true;
 	} );
 
 	it( 'should register #commands', () => {
@@ -114,12 +114,12 @@ describe( 'HeadingEngine', () => {
 						expect( editor.commands.get( 'h4' ) ).to.be.instanceOf( HeadingCommand );
 						expect( editor.commands.get( 'paragraph' ) ).to.be.instanceOf( ParagraphCommand );
 
-						expect( model.schema.hasItem( 'paragraph' ) ).to.be.true;
-						expect( model.schema.hasItem( 'h4' ) ).to.be.true;
+						expect( model.schema.isRegistered( 'paragraph' ) ).to.be.true;
+						expect( model.schema.isRegistered( 'h4' ) ).to.be.true;
 
-						expect( model.schema.hasItem( 'heading1' ) ).to.be.false;
-						expect( model.schema.hasItem( 'heading2' ) ).to.be.false;
-						expect( model.schema.hasItem( 'heading3' ) ).to.be.false;
+						expect( model.schema.isRegistered( 'heading1' ) ).to.be.false;
+						expect( model.schema.isRegistered( 'heading2' ) ).to.be.false;
+						expect( model.schema.isRegistered( 'heading3' ) ).to.be.false;
 					} );
 			} );
 		} );