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

We shouldn't handle selection of a single cell by the new rendering method.

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

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

@@ -69,6 +69,10 @@ export default class TableSelection extends Plugin {
 		 */
 	}
 
+	get hasMultiCellSelection() {
+		return this.isSelecting && this._startElement && this._endElement && this._startElement !== this._endElement;
+	}
+
 	/**
 	 * @inheritDoc
 	 */
@@ -177,7 +181,7 @@ export default class TableSelection extends Plugin {
 	 * @returns {Iterable.<module:engine/model/element~Element>}
 	 */
 	* getSelectedTableCells() {
-		if ( !this._startElement || !this._endElement ) {
+		if ( !this.hasMultiCellSelection ) {
 			return;
 		}
 
@@ -203,6 +207,10 @@ export default class TableSelection extends Plugin {
 	 * @private
 	 */
 	_updateModelSelection() {
+		if ( !this.hasMultiCellSelection ) {
+			return;
+		}
+
 		const editor = this.editor;
 		const model = editor.model;
 

+ 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.isSelecting ) {
+		if ( tableSelection.hasMultiCellSelection ) {
 			clearHighlightedTableCells( highlighted, view );
 
 			for ( const tableCell of tableSelection.getSelectedTableCells() ) {

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

@@ -68,8 +68,8 @@ export default class MouseSelectionHandler {
 		const tableCell = this._getModelTableCellFromDomEvent( domEventData );
 
 		if ( !tableCell ) {
-			this._tableSelection.stopSelection();
 			this._tableSelection.clearSelection();
+			this._tableSelection.stopSelection();
 
 			return;
 		}