Przeglądaj źródła

Internal: Simplified schema usage.

Piotrek Koszuliński 8 lat temu
rodzic
commit
b8a70e1851

+ 2 - 2
packages/ckeditor5-basic-styles/src/boldengine.js

@@ -32,9 +32,9 @@ export default class BoldEngine extends Plugin {
 		const editing = editor.editing;
 
 		// Allow bold attribute on all inline nodes.
-		editor.document.schema.allow( { name: '$inline', attributes: [ BOLD ], inside: '$block' } );
+		editor.document.schema.allow( { name: '$inline', attributes: BOLD, inside: '$block' } );
 		// Temporary workaround. See https://github.com/ckeditor/ckeditor5/issues/477.
-		editor.document.schema.allow( { name: '$inline', attributes: [ BOLD ], inside: '$clipboardHolder' } );
+		editor.document.schema.allow( { name: '$inline', attributes: BOLD, inside: '$clipboardHolder' } );
 
 		// Build converter from model to view for data and editing pipelines.
 		buildModelConverter().for( data.modelToView, editing.modelToView )

+ 2 - 2
packages/ckeditor5-basic-styles/src/italicengine.js

@@ -32,9 +32,9 @@ export default class ItalicEngine extends Plugin {
 		const editing = editor.editing;
 
 		// Allow italic attribute on all inline nodes.
-		editor.document.schema.allow( { name: '$inline', attributes: [ ITALIC ], inside: '$block' } );
+		editor.document.schema.allow( { name: '$inline', attributes: ITALIC, inside: '$block' } );
 		// Temporary workaround. See https://github.com/ckeditor/ckeditor5/issues/477.
-		editor.document.schema.allow( { name: '$inline', attributes: [ ITALIC ], inside: '$clipboardHolder' } );
+		editor.document.schema.allow( { name: '$inline', attributes: ITALIC, inside: '$clipboardHolder' } );
 
 		// Build converter from model to view for data and editing pipelines.
 		buildModelConverter().for( data.modelToView, editing.modelToView )

+ 7 - 3
packages/ckeditor5-basic-styles/tests/boldengine.js

@@ -26,14 +26,18 @@ describe( 'BoldEngine', () => {
 		} );
 	} );
 
+	afterEach( () => {
+		return editor.destroy();
+	} );
+
 	it( 'should be loaded', () => {
 		expect( editor.plugins.get( BoldEngine ) ).to.be.instanceOf( BoldEngine );
 	} );
 
 	it( 'should set proper schema rules', () => {
-		expect( doc.schema.check( { name: '$inline', attributes: [ 'bold' ], inside: '$root' } ) ).to.be.false;
-		expect( doc.schema.check( { name: '$inline', attributes: [ 'bold' ], inside: '$block' } ) ).to.be.true;
-		expect( doc.schema.check( { name: '$inline', attributes: [ 'bold' ], inside: '$clipboardHolder' } ) ).to.be.true;
+		expect( doc.schema.check( { name: '$inline', attributes: 'bold', inside: '$root' } ) ).to.be.false;
+		expect( doc.schema.check( { name: '$inline', attributes: 'bold', inside: '$block' } ) ).to.be.true;
+		expect( doc.schema.check( { name: '$inline', attributes: 'bold', inside: '$clipboardHolder' } ) ).to.be.true;
 	} );
 
 	describe( 'command', () => {

+ 3 - 3
packages/ckeditor5-basic-styles/tests/italicengine.js

@@ -35,9 +35,9 @@ describe( 'ItalicEngine', () => {
 	} );
 
 	it( 'should set proper schema rules', () => {
-		expect( doc.schema.check( { name: '$inline', attributes: [ 'italic' ], inside: '$root' } ) ).to.be.false;
-		expect( doc.schema.check( { name: '$inline', attributes: [ 'italic' ], inside: '$block' } ) ).to.be.true;
-		expect( doc.schema.check( { name: '$inline', attributes: [ 'italic' ], inside: '$clipboardHolder' } ) ).to.be.true;
+		expect( doc.schema.check( { name: '$inline', attributes: 'italic', inside: '$root' } ) ).to.be.false;
+		expect( doc.schema.check( { name: '$inline', attributes: 'italic', inside: '$block' } ) ).to.be.true;
+		expect( doc.schema.check( { name: '$inline', attributes: 'italic', inside: '$clipboardHolder' } ) ).to.be.true;
 	} );
 
 	describe( 'command', () => {