8
0
Просмотр исходного кода

Registered TodoListCheckCommand in TodoListEditing.

Oskar Wróbel 6 лет назад
Родитель
Сommit
1a7416bf26

+ 1 - 1
packages/ckeditor5-list/src/todolistcheckedcommand.js → packages/ckeditor5-list/src/todolistcheckcommand.js

@@ -14,7 +14,7 @@ const attributeKey = 'todoListChecked';
 /**
  * @extends module:core/command~Command
  */
-export default class TodoListCheckedCommand extends Command {
+export default class TodoListCheckCommand extends Command {
 	/**
 	 * @param {module:core/editor/editor~Editor} editor
 	 */

+ 7 - 4
packages/ckeditor5-list/src/todolistediting.js

@@ -9,6 +9,7 @@
 
 import ListCommand from './listcommand';
 import ListEditing from './listediting';
+import TodoListCheckCommand from './todolistcheckcommand';
 
 import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
 
@@ -42,11 +43,16 @@ export default class TodoListEditing extends Plugin {
 		const { editing, data, model } = editor;
 		const viewDocument = editing.view.document;
 
+		// Extend schema.
 		model.schema.extend( 'listItem', {
 			allowAttributes: [ 'todoListChecked' ]
 		} );
 
-		// Converters.
+		// Register commands.
+		editor.commands.add( 'todoList', new ListCommand( editor, 'todo' ) );
+		editor.commands.add( 'todoListCheck', new TodoListCheckCommand( editor ) );
+
+		// Define converters.
 		editing.downcastDispatcher.on( 'insert:listItem', modelViewInsertion( model ), { priority: 'high' } );
 		editing.downcastDispatcher.on( 'insert:$text', modelViewTextInsertion, { priority: 'high' } );
 		data.downcastDispatcher.on( 'insert:listItem', dataModelViewInsertion( model ), { priority: 'high' } );
@@ -55,9 +61,6 @@ export default class TodoListEditing extends Plugin {
 		editing.downcastDispatcher.on( 'attribute:listType:listItem', modelViewChangeType( model ) );
 		editing.downcastDispatcher.on( 'attribute:todoListChecked:listItem', modelViewChangeChecked( model ) );
 
-		// Register command for todo list.
-		editor.commands.add( 'todoList', new ListCommand( editor, 'todo' ) );
-
 		// Move selection after a checkbox element.
 		viewDocument.registerPostFixer( writer => moveUIElementsAfterCheckmark( writer, getChangedCheckmarkElements( editing.view ) ) );
 

+ 3 - 3
packages/ckeditor5-list/tests/todolistcheckedcommand.js → packages/ckeditor5-list/tests/todolistcheckcommand.js

@@ -4,12 +4,12 @@
  */
 
 import TodoListEditing from '../src/todolistediting';
-import TodoListCheckedCommand from '../src/todolistcheckedcommand';
+import TodoListCheckCommand from '../src/todolistcheckcommand';
 
 import ModelTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/modeltesteditor';
 import { getData as getModelData, setData as setModelData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
 
-describe( 'TodoListCheckedCommand', () => {
+describe( 'TodoListCheckCommand', () => {
 	let editor, model, command;
 
 	beforeEach( () => {
@@ -20,7 +20,7 @@ describe( 'TodoListCheckedCommand', () => {
 			.then( newEditor => {
 				editor = newEditor;
 				model = editor.model;
-				command = new TodoListCheckedCommand( editor );
+				command = new TodoListCheckCommand( editor );
 			} );
 	} );