Explorar el Código

Aligned code with the engine changes.

Oskar Wróbel hace 8 años
padre
commit
101cf3642b

+ 9 - 9
packages/ckeditor5-basic-styles/src/attributecommand.js

@@ -55,10 +55,11 @@ export default class AttributeCommand extends Command {
 	 * Updates the command's {@link #value} and {@link #isEnabled} based on the current selection.
 	 */
 	refresh() {
-		const doc = this.editor.document;
+		const model = this.editor.model;
+		const doc = model.document;
 
 		this.value = doc.selection.hasAttribute( this.attributeKey );
-		this.isEnabled = doc.schema.checkAttributeInSelection( doc.selection, this.attributeKey );
+		this.isEnabled = model.schema.checkAttributeInSelection( doc.selection, this.attributeKey );
 	}
 
 	/**
@@ -80,14 +81,14 @@ export default class AttributeCommand extends Command {
 	 * @param {Boolean} [options.forceValue] If set, it will force the command behavior. If `true`, the command will apply the attribute,
 	 * otherwise the command will remove the attribute.
 	 * If not set, the command will look for its current value to decide what it should do.
-	 * @param {module:engine/model/batch~Batch} [options.batch] A batch to group undo steps.
 	 */
 	execute( options = {} ) {
-		const doc = this.editor.document;
+		const model = this.editor.model;
+		const doc = model.document;
 		const selection = doc.selection;
 		const value = ( options.forceValue === undefined ) ? !this.value : options.forceValue;
 
-		doc.enqueueChanges( () => {
+		model.enqueueChange( writer => {
 			if ( selection.isCollapsed ) {
 				if ( value ) {
 					selection.setAttribute( this.attributeKey, true );
@@ -95,14 +96,13 @@ export default class AttributeCommand extends Command {
 					selection.removeAttribute( this.attributeKey );
 				}
 			} else {
-				const ranges = doc.schema.getValidRanges( selection.getRanges(), this.attributeKey );
-				const batch = options.batch || doc.batch();
+				const ranges = model.schema.getValidRanges( selection.getRanges(), this.attributeKey );
 
 				for ( const range of ranges ) {
 					if ( value ) {
-						batch.setAttribute( this.attributeKey, value, range );
+						writer.setAttribute( this.attributeKey, value, range );
 					} else {
-						batch.removeAttribute( this.attributeKey, range );
+						writer.removeAttribute( this.attributeKey, range );
 					}
 				}
 			}

+ 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.model.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.model.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/codeengine.js

@@ -32,9 +32,9 @@ export default class CodeEngine extends Plugin {
 		const editing = editor.editing;
 
 		// Allow code attribute on all inline nodes.
-		editor.document.schema.allow( { name: '$inline', attributes: CODE, inside: '$block' } );
+		editor.model.schema.allow( { name: '$inline', attributes: CODE, inside: '$block' } );
 		// Temporary workaround. See https://github.com/ckeditor/ckeditor5/issues/477.
-		editor.document.schema.allow( { name: '$inline', attributes: CODE, inside: '$clipboardHolder' } );
+		editor.model.schema.allow( { name: '$inline', attributes: CODE, 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.model.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.model.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 )

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

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