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

Renamed model attribute from listChecked to todoListChecked.

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

+ 4 - 1
packages/ckeditor5-list/src/listediting.js

@@ -57,7 +57,7 @@ export default class ListEditing extends Plugin {
 		// If there are blocks allowed inside list item, algorithms using `getSelectedBlocks()` will have to be modified.
 		editor.model.schema.register( 'listItem', {
 			inheritAllFrom: '$block',
-			allowAttributes: [ 'listType', 'listIndent', 'listChecked' ]
+			allowAttributes: [ 'listType', 'listIndent' ]
 		} );
 
 		// Converters.
@@ -175,6 +175,9 @@ export default class ListEditing extends Plugin {
 		editor.keystrokes.set( 'Shift+Tab', getCommandExecuter( 'outdentList' ) );
 	}
 
+	/**
+	 * @inheritDoc
+	 */
 	afterInit() {
 		const commands = this.editor.commands;
 

+ 7 - 7
packages/ckeditor5-list/src/todolistconverters.js

@@ -103,7 +103,7 @@ export function dataModelViewInsertion( model ) {
 			class: 'todo-list__checkmark'
 		} );
 
-		if ( data.item.getAttribute( 'listChecked' ) ) {
+		if ( data.item.getAttribute( 'todoListChecked' ) ) {
 			viewWriter.setAttribute( 'checked', 'checked', checkbox );
 		}
 
@@ -166,19 +166,19 @@ export function modelViewChangeType( model ) {
  */
 export function modelViewChangeChecked( model ) {
 	return ( evt, data, conversionApi ) => {
-		if ( !conversionApi.consumable.consume( data.item, 'attribute:listChecked' ) ) {
+		if ( !conversionApi.consumable.consume( data.item, 'attribute:todoListChecked' ) ) {
 			return;
 		}
 
 		const { mapper, writer: viewWriter } = conversionApi;
-		const isChecked = !!data.item.getAttribute( 'listChecked' );
+		const isChecked = !!data.item.getAttribute( 'todoListChecked' );
 		const viewItem = mapper.toViewElement( data.item );
 		const uiElement = findCheckmarkElement( viewItem, viewWriter );
 
 		viewWriter.insert(
 			viewWriter.createPositionAfter( uiElement ),
 			createCheckMarkElement( isChecked, viewWriter, isChecked => {
-				model.change( writer => writer.setAttribute( 'listChecked', isChecked, data.item ) );
+				model.change( writer => writer.setAttribute( 'todoListChecked', isChecked, data.item ) );
 			} )
 		);
 		viewWriter.remove( uiElement );
@@ -186,14 +186,14 @@ export function modelViewChangeChecked( model ) {
 }
 
 function addTodoElementsToListItem( modelItem, viewItem, viewWriter, model ) {
-	const isChecked = !!modelItem.getAttribute( 'listChecked' );
+	const isChecked = !!modelItem.getAttribute( 'todoListChecked' );
 
 	viewWriter.addClass( 'todo-list', viewItem.parent );
 
 	viewWriter.insert(
 		viewWriter.createPositionAt( viewItem, 0 ),
 		createCheckMarkElement( isChecked, viewWriter, isChecked => {
-			model.change( writer => writer.setAttribute( 'listChecked', isChecked, modelItem ) );
+			model.change( writer => writer.setAttribute( 'todoListChecked', isChecked, modelItem ) );
 		} )
 	);
 }
@@ -201,7 +201,7 @@ function addTodoElementsToListItem( modelItem, viewItem, viewWriter, model ) {
 function removeTodoElementsFromListItem( modelItem, viewItem, viewWriter, model ) {
 	viewWriter.removeClass( 'todo-list', viewItem.parent );
 	viewWriter.remove( viewItem.getChild( 0 ) );
-	model.change( writer => writer.removeAttribute( 'listChecked', modelItem ) );
+	model.change( writer => writer.removeAttribute( 'todoListChecked', modelItem ) );
 }
 
 function createCheckMarkElement( isChecked, viewWriter, onChange ) {

+ 6 - 6
packages/ckeditor5-list/src/todolistediting.js

@@ -41,7 +41,7 @@ export default class TodoListEditing extends Plugin {
 		const viewDocument = editing.view.document;
 
 		model.schema.extend( 'listItem', {
-			allowAttributes: [ 'listChecked' ]
+			allowAttributes: [ 'todoListChecked' ]
 		} );
 
 		// Converters.
@@ -51,7 +51,7 @@ export default class TodoListEditing extends Plugin {
 		data.downcastDispatcher.on( 'insert:$text', dataModelViewTextInsertion, { priority: 'high' } );
 
 		editing.downcastDispatcher.on( 'attribute:listType:listItem', modelViewChangeType( model ) );
-		editing.downcastDispatcher.on( 'attribute:listChecked:listItem', modelViewChangeChecked( model ) );
+		editing.downcastDispatcher.on( 'attribute:todoListChecked:listItem', modelViewChangeChecked( model ) );
 
 		// Register command for todo list.
 		editor.commands.add( 'todoList', new ListCommand( editor, 'todo' ) );
@@ -73,7 +73,7 @@ export default class TodoListEditing extends Plugin {
 		// <ul><li><checkbox/>Bar</li></ul>
 		editor.keystrokes.set( 'arrowleft', ( evt, stop ) => jumpOverCheckmarkOnLeftArrowKeyPress( stop, model ) );
 
-		// Remove `listChecked` attribute when a host element is no longer a todo list item.
+		// Remove `todoListChecked` attribute when a host element is no longer a todo list item.
 		const listItemsToFix = new Set();
 
 		this.listenTo( model, 'applyOperation', ( evt, args ) => {
@@ -81,7 +81,7 @@ export default class TodoListEditing extends Plugin {
 
 			if ( operation.type != 'changeAttribute' && operation.key != 'listType' && operation.oldValue == 'todoList' ) {
 				for ( const item of operation.range.getItems() ) {
-					if ( item.name == 'listItem' && item.hasAttribute( 'listChecked' ) ) {
+					if ( item.name == 'listItem' && item.hasAttribute( 'todoListChecked' ) ) {
 						listItemsToFix.add( item );
 					}
 				}
@@ -90,7 +90,7 @@ export default class TodoListEditing extends Plugin {
 			if ( operation.type == 'rename' && operation.oldName == 'listItem' ) {
 				const item = operation.position.nodeAfter;
 
-				if ( item.hasAttribute( 'listChecked' ) ) {
+				if ( item.hasAttribute( 'todoListChecked' ) ) {
 					listItemsToFix.add( item );
 				}
 			}
@@ -100,7 +100,7 @@ export default class TodoListEditing extends Plugin {
 			let hasChanged = false;
 
 			for ( const listItem of listItemsToFix ) {
-				writer.removeAttribute( 'listChecked', listItem );
+				writer.removeAttribute( 'todoListChecked', listItem );
 				hasChanged = true;
 			}