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

Minor code and API docs improvements.

Piotrek Koszuliński 9 лет назад
Родитель
Сommit
c0d212e2f2

+ 12 - 10
packages/ckeditor5-list/src/indentcommand.js

@@ -26,9 +26,11 @@ export default class IndentCommand extends Command {
 		/**
 		 * By how much the command will change list item's indent attribute.
 		 *
-		 * @readonly {Number} list.IndentCommand#indentBy
+		 * @readonly
+		 * @private
+		 * @member {Number} list.IndentCommand#_indentBy
 		 */
-		this.indentBy = indentDirection == 'forward' ? 1 : -1;
+		this._indentBy = indentDirection == 'forward' ? 1 : -1;
 
 		// Refresh command state after selection is changed or changes has been done to the document.
 		this.editor.document.selection.on( 'change:range', () => {
@@ -44,11 +46,11 @@ export default class IndentCommand extends Command {
 	 * @inheritDoc
 	 */
 	_doExecute() {
-		const document = this.editor.document;
-		const batch = document.batch();
-		const element = getClosestListItem( document.selection.getFirstPosition() );
+		const doc = this.editor.document;
+		const batch = doc.batch();
+		const element = getClosestListItem( doc.selection.getFirstPosition() );
 
-		document.enqueueChanges( () => {
+		doc.enqueueChanges( () => {
 			const oldIndent = element.getAttribute( 'indent' );
 
 			let itemsToChange = [ element ];
@@ -67,12 +69,12 @@ export default class IndentCommand extends Command {
 			// bases on that state and assumes that model is correct.
 			// Because of that, if the command outdented items, we will outdent them starting from the last item, as
 			// it is safer.
-			if ( this.indentBy < 0 ) {
+			if ( this._indentBy < 0 ) {
 				itemsToChange = itemsToChange.reverse();
 			}
 
 			for ( let item of itemsToChange ) {
-				const indent = item.getAttribute( 'indent' ) + this.indentBy;
+				const indent = item.getAttribute( 'indent' ) + this._indentBy;
 
 				// If indent is lower than 0, it means that the item got outdented when it was not indented.
 				// This means that we need to convert that list item to paragraph.
@@ -102,9 +104,9 @@ export default class IndentCommand extends Command {
 
 		const prev = listItem.previousSibling;
 		const oldIndent = listItem.getAttribute( 'indent' );
-		const newIndent = oldIndent + this.indentBy;
+		const newIndent = oldIndent + this._indentBy;
 
-		if ( this.indentBy > 0 ) {
+		if ( this._indentBy > 0 ) {
 			// If we are indenting, there are some conditions to meet.
 			// Cannot indent first list item.
 			if ( !prev || prev.name != 'listItem' ) {

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

@@ -33,8 +33,8 @@ export default class List extends Feature {
 	init() {
 		// Create two buttons and link them with numberedList and bulletedList commands.
 		const t = this.editor.t;
-		this._addButton( 'numberedList', 'numberedlist', t( 'Numbered List' ) );
-		this._addButton( 'bulletedList', 'bulletedlist', t( 'Bulleted List' ) );
+		this._addButton( 'numberedList', t( 'Numbered List' ) );
+		this._addButton( 'bulletedList', t( 'Bulleted List' ) );
 
 		// Overwrite default enter key behavior.
 		// If enter key is pressed with selection collapsed in empty list item, outdent it instead of breaking it.
@@ -76,14 +76,13 @@ export default class List extends Feature {
 	}
 
 	/**
-	 * Helper method for initializing a button and linking it with appropriate command.
+	 * Helper method for initializing a button and linking it with an appropriate command.
 	 *
 	 * @private
 	 * @param {String} commandName Name of the command.
-	 * @param {String} iconName Name of the icon resource.
 	 * @param {Object} label Button label.
 	 */
-	_addButton( commandName, iconName, label ) {
+	_addButton( commandName, label ) {
 		const editor = this.editor;
 		const command = editor.commands.get( commandName );
 
@@ -92,7 +91,7 @@ export default class List extends Feature {
 			isEnabled: true,
 			isOn: false,
 			label: label,
-			icon: iconName
+			icon: commandName.toLowerCase()
 		} );
 
 		// Bind button model to command.

+ 4 - 4
packages/ckeditor5-list/src/listcommand.js

@@ -31,20 +31,20 @@ export default class ListCommand extends Command {
 		this.type = type == 'bulleted' ? 'bulleted' : 'numbered';
 
 		/**
-		 * Flag indicating whether command is active, which means that selection starts in a list of same type.
+		 * Flag indicating whether the command is active, which means that selection starts in a list of the same type.
 		 *
 		 * @observable
 		 * @member {Boolean} list.ListCommand#value
 		 */
 		this.set( 'value', false );
 
-		// Listen on selection change and set's current command's value.
+		// Listen on selection change and sets current command's value.
 		this.listenTo( editor.document.selection, 'change:range', () => {
 			this.refreshValue();
 			this.refreshState();
 		} );
 
-		// Listen on changesDone model document and set's current command's value.
+		// Listen on changesDone model document and sets current command's value.
 		this.listenTo( editor.document, 'changesDone', () => {
 			this.refreshValue();
 			this.refreshState();
@@ -52,7 +52,7 @@ export default class ListCommand extends Command {
 	}
 
 	/**
-	 * Set's command's value basing on document selection.
+	 * Sets command's value based on the document selection.
 	 */
 	refreshValue() {
 		const position = this.editor.document.selection.getFirstPosition();