Browse Source

Added missing schema tests and docs.

Piotrek Koszuliński 9 years ago
parent
commit
bd649569e4

+ 7 - 5
packages/ckeditor5-engine/src/model/schema.js

@@ -251,7 +251,11 @@ export default class Schema {
 	 */
 	 */
 	constructor() {
 	constructor() {
 		/**
 		/**
-		 * TODO
+		 * Names of elements which have "object" nature. This means that these
+		 * elements should be treated as whole, never merged, can be selected from outside, etc.
+		 * Just like images, placeholder widgets, etc.
+		 *
+		 * @member {Set.<String>} engine.model.Schema#objects
 		 */
 		 */
 		this.objects = new Set();
 		this.objects = new Set();
 
 
@@ -284,10 +288,8 @@ export default class Schema {
 		// Create an "all allowed" context in the schema for processing the pasted content.
 		// Create an "all allowed" context in the schema for processing the pasted content.
 		// Read: https://github.com/ckeditor/ckeditor5-engine/issues/638#issuecomment-255086588
 		// Read: https://github.com/ckeditor/ckeditor5-engine/issues/638#issuecomment-255086588
 
 
-		if ( !this.hasItem( '$clipboardHolder' ) ) {
-			this.registerItem( '$clipboardHolder', '$root' );
-			this.allow( { name: '$text', inside: '$clipboardHolder' } );
-		}
+		this.registerItem( '$clipboardHolder', '$root' );
+		this.allow( { name: '$inline', inside: '$clipboardHolder' } );
 	}
 	}
 
 
 	/**
 	/**

+ 18 - 0
packages/ckeditor5-engine/tests/model/schema/schema.js

@@ -39,6 +39,24 @@ describe( 'constructor', () => {
 	it( 'should allow inline in block', () => {
 	it( 'should allow inline in block', () => {
 		expect( schema.check( { name: '$inline', inside: [ '$block' ] } ) ).to.be.true;
 		expect( schema.check( { name: '$inline', inside: [ '$block' ] } ) ).to.be.true;
 	} );
 	} );
+
+	it( 'should create the objects set', () => {
+		expect( schema.objects ).to.be.instanceOf( Set );
+	} );
+
+	describe( '$clipboardHolder', () => {
+		it( 'should allow $block', () => {
+			expect( schema.check( { name: '$block', inside: [ '$clipboardHolder' ] } ) ).to.be.true;
+		} );
+
+		it( 'should allow $inline', () => {
+			expect( schema.check( { name: '$inline', inside: [ '$clipboardHolder' ] } ) ).to.be.true;
+		} );
+
+		it( 'should allow $text', () => {
+			expect( schema.check( { name: '$text', inside: [ '$clipboardHolder' ] } ) ).to.be.true;
+		} );
+	} );
 } );
 } );
 
 
 describe( 'registerItem', () => {
 describe( 'registerItem', () => {