浏览代码

Apply suggestions from code review.

Co-Authored-By: Aleksander Nowodzinski <a.nowodzinski@cksource.com>
Maciej 5 年之前
父节点
当前提交
8504063bd0

+ 16 - 16
packages/ckeditor5-table/src/tableselection.js

@@ -17,7 +17,7 @@ import MouseSelectionHandler from './tableselection/mouseselectionhandler';
 /**
  * The table selection plugin.
  *
- * It introduces the ability to select table cells. Table selection is described by two nodes: start and end.
+ * It introduces the ability to select table cells. The table selection is described by two nodes: start and end.
  * Both are the oposite corners of an rectangle that spans over them.
  *
  * Consider a table:
@@ -31,10 +31,10 @@ import MouseSelectionHandler from './tableselection/mouseselectionhandler';
  *		2 | h | i     | j |
  *		  +---+---+---+---+
  *
- * Setting table selection start as table cell "b" and end as table cell "g" will select table cells: "b", "c", "d", "f", and "g".
- * The cells that spans over multiple rows or columns can extend over the selection rectangle. For instance setting a selection from
- * table cell "a" to table cell "i" will create a selection in which table cell "i" will be extended over a rectangular of the selected
- * cell: "a", "b", "e", "f", "h", and "i".
+ * Setting the table selection start in table cell "b" and the end in table cell "g" will select table cells: "b", "c", "d", "f", and "g".
+ * The cells that span over multiple rows or columns can extend over the selection rectangle. For instance, setting a selection from
+ * the table cell "a" to the table cell "i" will create a selection in which the table cell "i" will be (partially) outside the rectangle of selected
+ * cells: "a", "b", "e", "f", "h", and "i".
  *
  * @extends module:core/plugin~Plugin
  */
@@ -69,16 +69,16 @@ export default class TableSelection extends Plugin {
 		this._mouseHandler = new MouseSelectionHandler( this, this.editor.editing );
 
 		/**
-		 * A table utilities.
+		 * A reference to the table utilities used across the class.
 		 *
 		 * @private
 		 * @readonly
-		 * @member {module:table/tableutils~TableUtils}
+		 * @member {module:table/tableutils~TableUtils} #_tableUtils
 		 */
 	}
 
 	/**
-	 * Flag indicating that there are selected table cells and the selection has more than one table cell.
+	 * A flag indicating that there are selected table cells and the selection includes more than one table cell.
 	 *
 	 * @type {Boolean}
 	 */
@@ -109,7 +109,7 @@ export default class TableSelection extends Plugin {
 	}
 
 	/**
-	 * Starts a selection process.
+	 * Starts the selection process.
 	 *
 	 * This method enables the table selection process.
 	 *
@@ -151,13 +151,13 @@ export default class TableSelection extends Plugin {
 	}
 
 	/**
-	 * Stops selection process (but do not clear the current selection). The selecting process is ended but the selection in model remains.
+	 * Stops the selection process (but do not clear the current selection). The selection process is finished but the selection in the model remains.
 	 *
 	 *		editor.plugins.get( 'TableSelection' ).startSelectingFrom( startTableCell );
 	 *		editor.plugins.get( 'TableSelection' ).setSelectingTo( endTableCell );
 	 *		editor.plugins.get( 'TableSelection' ).stopSelection();
 	 *
-	 * To clear selection use {@link #clearSelection}.
+	 * To clear the selection use {@link #clearSelection}.
 	 *
 	 * @param {module:engine/model/element~Element} [tableCell]
 	 */
@@ -170,7 +170,7 @@ export default class TableSelection extends Plugin {
 	}
 
 	/**
-	 * Stops current selection process and clears table selection.
+	 * Stops the current selection process and clears the table selection in the model.
 	 *
 	 *		editor.plugins.get( 'TableSelection' ).startSelectingFrom( startTableCell );
 	 *		editor.plugins.get( 'TableSelection' ).setSelectingTo( endTableCell );
@@ -184,13 +184,13 @@ export default class TableSelection extends Plugin {
 	}
 
 	/**
-	 * Returns iterator for selected table cells.
+	 * Returns an iterator for selected table cells.
 	 *
 	 *		tableSelection.startSelectingFrom( startTableCell );
 	 *		tableSelection.stopSelection( endTableCell );
 	 *
 	 *		const selectedTableCells = Array.from( tableSelection.getSelectedTableCells() );
-	 *		// The above array will consist a rectangular table selection.
+	 *		// The above array will represent a rectangular table selection.
 	 *
 	 * @returns {Iterable.<module:engine/model/element~Element>}
 	 */
@@ -216,7 +216,7 @@ export default class TableSelection extends Plugin {
 	}
 
 	/**
-	 * Set proper model selection for currently selected table cells.
+	 * Synchronizes the model selection with currently selected table cells.
 	 *
 	 * @private
 	 */
@@ -241,7 +241,7 @@ export default class TableSelection extends Plugin {
 	}
 
 	/**
-	 * Checks if selection has changed from an external source and it is required to clear internal state.
+	 * Checks if the selection has changed via an external change and if it is required to clear the internal state of the plugin.
 	 *
 	 * @param {module:engine/model/documentselection~DocumentSelection} selection
 	 * @private

+ 3 - 3
packages/ckeditor5-table/src/tableselection/converters.js

@@ -8,7 +8,7 @@
  */
 
 /**
- * Adds a visual highlight style to a selected table cells.
+ * Adds a visual highlight style to selected table cells.
  *
  * @param {module:core/editor/editor~Editor} editor
  * @param {module:table/tableselection~TableSelection} tableSelection
@@ -27,7 +27,7 @@ export function setupTableSelectionHighlighting( editor, tableSelection ) {
 			for ( const tableCell of tableSelection.getSelectedTableCells() ) {
 				const viewElement = conversionApi.mapper.toViewElement( tableCell );
 
-				viewWriter.addClass( 'selected', viewElement );
+				viewWriter.addClass( 'ck-editor__editable_selected', viewElement );
 				highlighted.add( viewElement );
 			}
 
@@ -43,7 +43,7 @@ function clearHighlightedTableCells( highlighted, view ) {
 
 	view.change( writer => {
 		for ( const previouslyHighlighted of previous ) {
-			writer.removeClass( 'selected', previouslyHighlighted );
+			writer.removeClass( 'ck-editor__editable_selected', previouslyHighlighted );
 		}
 	} );
 }

+ 10 - 10
packages/ckeditor5-table/src/tableselection/mouseselectionhandler.js

@@ -14,21 +14,21 @@ import { findAncestor } from '../commands/utils';
 import MouseEventsObserver from './mouseeventsobserver';
 
 /**
- * A mouse selection handler for table selection.
+ * A mouse selection handler class for the table selection.
  *
  * It registers the {@link module:table/tableselection/mouseeventsobserver~MouseEventsObserver} to observe view document mouse events
  * and invoke proper {@link module:table/tableselection~TableSelection} actions.
  */
 export default class MouseSelectionHandler {
 	/**
-	 * Creates instance of `MouseSelectionHandler`.
+	 * Creates an instance of the `MouseSelectionHandler`.
 	 *
 	 * @param {module:table/tableselection~TableSelection} tableSelection
 	 * @param {module:engine/controller/editingcontroller~EditingController} editing
 	 */
 	constructor( tableSelection, editing ) {
 		/**
-		 * Table selection.
+		 * The table selection plugin instance.
 		 *
 		 * @private
 		 * @readonly
@@ -38,7 +38,7 @@ export default class MouseSelectionHandler {
 
 		/**
 		 * A flag indicating that the mouse selection is "active". A selection is "active" if it was started and not yet finished.
-		 * A selection can be "active" for instance if user moves a mouse over a table while holding a mouse button down.
+		 * A selection can be "active", for instance, if a user moves a mouse over a table while holding a mouse button down.
 		 *
 		 * @readonly
 		 * @member {Boolean}
@@ -65,9 +65,9 @@ export default class MouseSelectionHandler {
 	}
 
 	/**
-	 * Handles starting a selection when "mousedown" event has table cell target.
+	 * Handles starting a selection when "mousedown" event has table cell as a DOM target.
 	 *
-	 * If no table cell in event target it will clear previous selection.
+	 * If there is no table cell in the event target, it will clear the previous selection.
 	 *
 	 * @param {module:engine/view/observer/domeventdata~DomEventData} domEventData
 	 * @private
@@ -87,9 +87,9 @@ export default class MouseSelectionHandler {
 	}
 
 	/**
-	 * Handles updating table selection when "mousemove" event has a table cell target.
+	 * Handles updating the table selection when the "mousemove" event has a table cell as a DOM target.
 	 *
-	 * Does nothing if no table cell in event target or selection is not started.
+	 * Does nothing if there is no table cell in event target or the selection has not been started yet.
 	 *
 	 * @param {module:engine/view/observer/domeventdata~DomEventData} domEventData
 	 * @private
@@ -111,9 +111,9 @@ export default class MouseSelectionHandler {
 	}
 
 	/**
-	 * Handles ending (not clearing) table selection on "mouseup" event.
+	 * Handles ending (not clearing) the table selection on the "mouseup" event.
 	 *
-	 * Does nothing if selection is not started.
+	 * Does nothing if the selection has not been started yet.
 	 *
 	 * @param {module:engine/view/observer/domeventdata~DomEventData} domEventData
 	 * @private

+ 1 - 1
packages/ckeditor5-table/tests/_utils/utils.js

@@ -328,7 +328,7 @@ export function assertTableCellStyle( editor, tableCellStyle ) {
 }
 
 /**
- * Helper method for asserting selected table cells.
+ * A helper method for asserting selected table cells.
  *
  * To check if a table has expected cells selected pass two dimensional array of truthy and falsy values:
  *