Browse Source

Prepare AttributeCommand for changes in Schema.

Szymon Cofalik 9 years ago
parent
commit
6c72453c26
2 changed files with 6 additions and 6 deletions
  1. 3 3
      src/command/attributecommand.js
  2. 3 3
      tests/command/attributecommand.js

+ 3 - 3
src/command/attributecommand.js

@@ -63,7 +63,7 @@ export default class AttributeCommand extends Command {
 
 		if ( selection.isCollapsed ) {
 			// Check whether schema allows for a test with `attributeKey` in caret position.
-			return schema.checkAtPosition( selection.getFirstPosition(), '$text', this.attributeKey );
+			return schema.check( { name: '$text', inside: selection.getFirstPosition(), attributes: this.attributeKey } );
 		} else {
 			const ranges = selection.getRanges();
 
@@ -78,7 +78,7 @@ export default class AttributeCommand extends Command {
 					// If returned item does not have name property, it is a treeModel.TextFragment.
 					const name = step.value.item.name || '$text';
 
-					if ( schema.checkAtPosition( last, name, this.attributeKey ) ) {
+					if ( schema.check( { name: name, inside: last, attributes: this.attributeKey } ) ) {
 						// If we found a node that is allowed to have the attribute, return true.
 						return true;
 					}
@@ -164,7 +164,7 @@ export default class AttributeCommand extends Command {
 			while ( !step.done ) {
 				const name = step.value.item.name || '$text';
 
-				if ( !this.editor.document.schema.checkAtPosition( last, name, this.attributeKey ) ) {
+				if ( !this.editor.document.schema.check( { name: name, inside: last, attributes: this.attributeKey } ) ) {
 					if ( !from.isEqual( last ) ) {
 						validRanges.push( new Range( from, last ) );
 					}

+ 3 - 3
tests/command/attributecommand.js

@@ -33,11 +33,11 @@ beforeEach( () => {
 	modelDoc.schema.allow( { name: '$block', inside: 'div' } );
 
 	// Bold text is allowed only in P.
-	modelDoc.schema.allow( { name: '$text', attribute: 'bold', inside: 'p' } );
-	modelDoc.schema.allow( { name: 'p', attribute: 'bold', inside: 'div' } );
+	modelDoc.schema.allow( { name: '$text', attributes: 'bold', inside: 'p' } );
+	modelDoc.schema.allow( { name: 'p', attributes: 'bold', inside: 'div' } );
 
 	// Disallow bold on image.
-	modelDoc.schema.disallow( { name: 'img', attribute: 'bold', inside: 'div' } );
+	modelDoc.schema.disallow( { name: 'img', attributes: 'bold', inside: 'div' } );
 } );
 
 afterEach( () => {