Explorar el Código

Other: Update schema use to match the new API.

Maciej Gołaszewski hace 8 años
padre
commit
95fc14439e

+ 2 - 4
packages/ckeditor5-font/src/fontfamily/fontfamilyediting.js

@@ -87,10 +87,8 @@ export default class FontFamilyEditing extends Plugin {
 		const data = editor.data;
 		const data = editor.data;
 		const editing = editor.editing;
 		const editing = editor.editing;
 
 
-		// Allow highlight attribute on all elements
-		editor.model.schema.allow( { name: '$inline', attributes: 'fontFamily', inside: '$block' } );
-		// Temporary workaround. See https://github.com/ckeditor/ckeditor5/issues/477.
-		editor.model.schema.allow( { name: '$inline', attributes: 'fontFamily', inside: '$clipboardHolder' } );
+		// Allow fontFamily attribute on text nodes.
+		editor.model.schema.extend( '$text', { allowAttributes: 'fontFamily' } );
 
 
 		// Get configured font family options without "default" option.
 		// Get configured font family options without "default" option.
 		const fontFamilyOptions = this.configuredOptions.filter( item => item.model );
 		const fontFamilyOptions = this.configuredOptions.filter( item => item.model );

+ 2 - 4
packages/ckeditor5-font/src/fontsize/fontsizeediting.js

@@ -86,10 +86,8 @@ export default class FontSizeEditing extends Plugin {
 	init() {
 	init() {
 		const editor = this.editor;
 		const editor = this.editor;
 
 
-		// Allow fontSize attribute on all elements.
-		editor.model.schema.allow( { name: '$inline', attributes: 'fontSize', inside: '$block' } );
-		// Temporary workaround. See https://github.com/ckeditor/ckeditor5/issues/477.
-		editor.model.schema.allow( { name: '$inline', attributes: 'fontSize', inside: '$clipboardHolder' } );
+		// Allow fontSize attribute on text nodes.
+		editor.model.schema.extend( '$text', { allowAttributes: 'fontSize' } );
 	}
 	}
 }
 }
 
 

+ 2 - 2
packages/ckeditor5-font/tests/fontcommand.js

@@ -21,8 +21,8 @@ describe( 'FontCommand', () => {
 				command = new FontCommand( editor, 'font' );
 				command = new FontCommand( editor, 'font' );
 				editor.commands.add( 'font', command );
 				editor.commands.add( 'font', command );
 
 
-				model.schema.registerItem( 'paragraph', '$block' );
-				model.schema.allow( { name: '$inline', attributes: 'font', inside: '$block' } );
+				model.schema.register( 'paragraph', { inheritAllFrom: '$block' } );
+				model.schema.extend( '$text', { allowAttributes: 'font' } );
 			} );
 			} );
 	} );
 	} );
 
 

+ 4 - 2
packages/ckeditor5-font/tests/fontfamily/fontfamilyediting.js

@@ -30,8 +30,10 @@ describe( 'FontFamilyEditing', () => {
 	} );
 	} );
 
 
 	it( 'should set proper schema rules', () => {
 	it( 'should set proper schema rules', () => {
-		expect( editor.model.schema.check( { name: '$inline', attributes: 'fontFamily', inside: '$block' } ) ).to.be.true;
-		expect( editor.model.schema.check( { name: '$inline', attributes: 'fontFamily', inside: '$clipboardHolder' } ) ).to.be.true;
+		expect( editor.model.schema.checkAttribute( [ '$block', '$text' ], 'fontFamily' ) ).to.be.true;
+		expect( editor.model.schema.checkAttribute( [ '$clipboardHolder', '$text' ], 'fontFamily' ) ).to.be.true;
+
+		expect( editor.model.schema.checkAttribute( [ '$block' ], 'fontFamily' ) ).to.be.false;
 	} );
 	} );
 
 
 	describe( 'config', () => {
 	describe( 'config', () => {

+ 4 - 2
packages/ckeditor5-font/tests/fontsize/fontsizeediting.js

@@ -30,8 +30,10 @@ describe( 'FontSizeEditing', () => {
 	} );
 	} );
 
 
 	it( 'should set proper schema rules', () => {
 	it( 'should set proper schema rules', () => {
-		expect( editor.model.schema.check( { name: '$inline', attributes: 'fontSize', inside: '$block' } ) ).to.be.true;
-		expect( editor.model.schema.check( { name: '$inline', attributes: 'fontSize', inside: '$clipboardHolder' } ) ).to.be.true;
+		expect( editor.model.schema.checkAttribute( [ '$block', '$text' ], 'fontSize' ) ).to.be.true;
+		expect( editor.model.schema.checkAttribute( [ '$clipboardHolder', '$text' ], 'fontSize' ) ).to.be.true;
+
+		expect( editor.model.schema.checkAttribute( [ '$block' ], 'fontSize' ) ).to.be.false;
 	} );
 	} );
 
 
 	describe( 'config', () => {
 	describe( 'config', () => {