瀏覽代碼

Document TableSelection properties.

Maciej Gołaszewski 5 年之前
父節點
當前提交
1966343fe5

+ 22 - 7
packages/ckeditor5-table/src/tableselection.js

@@ -42,7 +42,22 @@ export default class TableSelection extends Plugin {
 	constructor( editor ) {
 		super( editor );
 
-		this._isSelecting = false;
+		/**
+		 * A flag indicating that the 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.
+		 *
+		 * @readonly
+		 * @member {Boolean}
+		 */
+		this.isSelecting = false;
+
+		/**
+		 * A mouse selection handler.
+		 *
+		 * @private
+		 * @readonly
+		 * @member {module:table/tableselection/mouseselectionhandler~MouseSelectionHandler}
+		 */
 		this._mouseHandler = new MouseSelectionHandler( this, this.editor.editing );
 	}
 
@@ -53,7 +68,7 @@ export default class TableSelection extends Plugin {
 	 * @member {Boolean} #isSelectingAndSomethingElse
 	 */
 	get isSelectingAndSomethingElse() {
-		return this._isSelecting && this._startElement && this._endElement && this._startElement !== this._endElement;
+		return this.isSelecting && this._startElement && this._endElement && this._startElement !== this._endElement;
 	}
 
 	/**
@@ -85,7 +100,7 @@ export default class TableSelection extends Plugin {
 	startSelectingFrom( tableCell ) {
 		this.clearSelection();
 
-		this._isSelecting = true;
+		this.isSelecting = true;
 		this._startElement = tableCell;
 		this._endElement = tableCell;
 	}
@@ -102,7 +117,7 @@ export default class TableSelection extends Plugin {
 	 */
 	setSelectingTo( tableCell ) {
 		// Do not update if not in selection mode or no table cell is passed.
-		if ( !this._isSelecting || !tableCell ) {
+		if ( !this.isSelecting || !tableCell ) {
 			return;
 		}
 
@@ -129,11 +144,11 @@ export default class TableSelection extends Plugin {
 	 * @param {module:engine/model/element~Element} [tableCell]
 	 */
 	stopSelection( tableCell ) {
-		if ( this._isSelecting && tableCell && tableCell.parent.parent === this._startElement.parent.parent ) {
+		if ( this.isSelecting && tableCell && tableCell.parent.parent === this._startElement.parent.parent ) {
 			this._endElement = tableCell;
 		}
 
-		this._isSelecting = false;
+		this.isSelecting = false;
 		this._updateModelSelection();
 	}
 
@@ -149,7 +164,7 @@ export default class TableSelection extends Plugin {
 	clearSelection() {
 		this._startElement = undefined;
 		this._endElement = undefined;
-		this._isSelecting = false;
+		this.isSelecting = false;
 	}
 
 	/**

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

@@ -21,7 +21,7 @@ export function setupTableSelectionHighlighting( editor, tableSelection ) {
 		const viewWriter = conversionApi.writer;
 		const viewSelection = viewWriter.document.selection;
 
-		if ( tableSelection.isSelectingAndSomethingElse ) {
+		if ( tableSelection.isSelecting ) {
 			clearHighlightedTableCells( highlighted, view );
 
 			for ( const tableCell of tableSelection.getSelectedTableCells() ) {

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

@@ -86,7 +86,7 @@ export default class MouseSelectionHandler {
 	 * @private
 	 */
 	_handleMouseMove( domEventData ) {
-		if ( !this._tableSelection._isSelecting ) {
+		if ( !this._tableSelection.isSelecting ) {
 			return;
 		}
 
@@ -108,7 +108,7 @@ export default class MouseSelectionHandler {
 	 * @private
 	 */
 	_handleMouseUp( domEventData ) {
-		if ( !this._tableSelection._isSelecting ) {
+		if ( !this._tableSelection.isSelecting ) {
 			return;
 		}
 
@@ -126,7 +126,7 @@ export default class MouseSelectionHandler {
 	 * @private
 	 */
 	_handleMouseLeave() {
-		if ( !this._tableSelection._isSelecting ) {
+		if ( !this._tableSelection.isSelecting ) {
 			return;
 		}