瀏覽代碼

Merge branch 'master' into i/6125

Piotrek Koszuliński 5 年之前
父節點
當前提交
0770ce4824
共有 26 個文件被更改,包括 1505 次插入150 次删除
  1. 31 7
      packages/ckeditor5-table/src/tablecellproperties/commands/tablecellpropertycommand.js
  2. 3 4
      packages/ckeditor5-table/src/tablecellproperties/tablecellpropertiesediting.js
  3. 5 19
      packages/ckeditor5-table/src/tableclipboard.js
  4. 2 3
      packages/ckeditor5-table/src/tableproperties/tablepropertiesediting.js
  5. 75 2
      packages/ckeditor5-table/src/tableselection.js
  6. 1 1
      packages/ckeditor5-table/src/tableselection/croptable.js
  7. 10 5
      packages/ckeditor5-table/src/tableselection/mouseselectionhandler.js
  8. 31 0
      packages/ckeditor5-table/src/tableselection/utils.js
  9. 12 2
      packages/ckeditor5-table/src/ui/utils.js
  10. 18 7
      packages/ckeditor5-table/tests/manual/tableselection.html
  11. 3 0
      packages/ckeditor5-table/tests/manual/tableselection.js
  12. 107 1
      packages/ckeditor5-table/tests/tablecellproperties/commands/tablecellbackgroundcolorcommand.js
  13. 107 1
      packages/ckeditor5-table/tests/tablecellproperties/commands/tablecellbordercolorcommand.js
  14. 113 1
      packages/ckeditor5-table/tests/tablecellproperties/commands/tablecellborderstylecommand.js
  15. 113 1
      packages/ckeditor5-table/tests/tablecellproperties/commands/tablecellborderwidthcommand.js
  16. 107 1
      packages/ckeditor5-table/tests/tablecellproperties/commands/tablecellheightcommand.js
  17. 107 1
      packages/ckeditor5-table/tests/tablecellproperties/commands/tablecellhorizontalalignmentcommand.js
  18. 107 1
      packages/ckeditor5-table/tests/tablecellproperties/commands/tablecellpaddingcommand.js
  19. 107 1
      packages/ckeditor5-table/tests/tablecellproperties/commands/tablecellverticalalignmentcommand.js
  20. 107 1
      packages/ckeditor5-table/tests/tablecellproperties/commands/tablecellwidthcommand.js
  21. 15 1
      packages/ckeditor5-table/tests/tablecellproperties/tablecellpropertiesui.js
  22. 108 80
      packages/ckeditor5-table/tests/tableclipboard.js
  23. 173 0
      packages/ckeditor5-table/tests/tableselection-integration.js
  24. 42 2
      packages/ckeditor5-table/tests/tableselection/mouseselectionhandler.js
  25. 1 1
      packages/ckeditor5-table/theme/table.css
  26. 0 7
      packages/ckeditor5-table/theme/tableselection.css

+ 31 - 7
packages/ckeditor5-table/src/tablecellproperties/commands/tablecellpropertycommand.js

@@ -36,12 +36,11 @@ export default class TableCellPropertyCommand extends Command {
 	 */
 	 */
 	refresh() {
 	refresh() {
 		const editor = this.editor;
 		const editor = this.editor;
-		const selection = editor.model.document.selection;
 
 
-		const tableCell = findAncestor( 'tableCell', selection.getFirstPosition() );
+		const selectedTableCells = getSelectedTableCells( editor.model );
 
 
-		this.isEnabled = !!tableCell;
-		this.value = this._getAttribute( tableCell );
+		this.isEnabled = !!selectedTableCells.length;
+		this.value = this._getSingleValue( selectedTableCells );
 	}
 	}
 
 
 	/**
 	/**
@@ -56,12 +55,10 @@ export default class TableCellPropertyCommand extends Command {
 	 */
 	 */
 	execute( options = {} ) {
 	execute( options = {} ) {
 		const model = this.editor.model;
 		const model = this.editor.model;
-		const selection = model.document.selection;
 
 
 		const { value, batch } = options;
 		const { value, batch } = options;
 
 
-		const tableCells = Array.from( selection.getSelectedBlocks() )
-			.map( element => findAncestor( 'tableCell', model.createPositionAt( element, 0 ) ) );
+		const tableCells = getSelectedTableCells( model );
 		const valueToSet = this._getValueToSet( value );
 		const valueToSet = this._getValueToSet( value );
 
 
 		model.enqueueChange( batch || 'default', writer => {
 		model.enqueueChange( batch || 'default', writer => {
@@ -98,4 +95,31 @@ export default class TableCellPropertyCommand extends Command {
 	_getValueToSet( value ) {
 	_getValueToSet( value ) {
 		return value;
 		return value;
 	}
 	}
+
+	/**
+	 * Returns a single value for all selected table cells. If the value is the same for all cells,
+	 * it will be returned (`undefined` otherwise).
+	 *
+	 * @param {Array.<module:engine/model/element~Element>} tableCell
+	 * @returns {*}
+	 * @private
+	 */
+	_getSingleValue( tableCell ) {
+		const firstCellValue = this._getAttribute( tableCell[ 0 ] );
+
+		const everyCellHasAttribute = tableCell.every( tableCell => this._getAttribute( tableCell ) === firstCellValue );
+
+		return everyCellHasAttribute ? firstCellValue : undefined;
+	}
+}
+
+// Returns all selected table cells.
+// The implementation of this function is incorrect as it may return a single cell twice.
+// See https://github.com/ckeditor/ckeditor5/issues/6358.
+function getSelectedTableCells( model ) {
+	const selection = model.document.selection;
+
+	return Array.from( selection.getSelectedBlocks() )
+		.map( element => findAncestor( 'tableCell', model.createPositionAt( element, 0 ) ) )
+		.filter( tableCell => !!tableCell );
 }
 }

+ 3 - 4
packages/ckeditor5-table/src/tablecellproperties/tablecellpropertiesediting.js

@@ -69,9 +69,8 @@ export default class TableCellPropertiesEditing extends Plugin {
 		const editor = this.editor;
 		const editor = this.editor;
 		const schema = editor.model.schema;
 		const schema = editor.model.schema;
 		const conversion = editor.conversion;
 		const conversion = editor.conversion;
-		const viewDoc = editor.editing.view.document;
 
 
-		viewDoc.addStyleProcessorRules( addBorderRules );
+		editor.data.addStyleProcessorRules( addBorderRules );
 		enableBorderProperties( schema, conversion );
 		enableBorderProperties( schema, conversion );
 		editor.commands.add( 'tableCellBorderStyle', new TableCellBorderStyleCommand( editor ) );
 		editor.commands.add( 'tableCellBorderStyle', new TableCellBorderStyleCommand( editor ) );
 		editor.commands.add( 'tableCellBorderColor', new TableCellBorderColorCommand( editor ) );
 		editor.commands.add( 'tableCellBorderColor', new TableCellBorderColorCommand( editor ) );
@@ -86,11 +85,11 @@ export default class TableCellPropertiesEditing extends Plugin {
 		enableProperty( schema, conversion, 'height', 'height' );
 		enableProperty( schema, conversion, 'height', 'height' );
 		editor.commands.add( 'tableCellHeight', new TableCellHeightCommand( editor ) );
 		editor.commands.add( 'tableCellHeight', new TableCellHeightCommand( editor ) );
 
 
-		viewDoc.addStyleProcessorRules( addPaddingRules );
+		editor.data.addStyleProcessorRules( addPaddingRules );
 		enableProperty( schema, conversion, 'padding', 'padding' );
 		enableProperty( schema, conversion, 'padding', 'padding' );
 		editor.commands.add( 'tableCellPadding', new TableCellPaddingCommand( editor ) );
 		editor.commands.add( 'tableCellPadding', new TableCellPaddingCommand( editor ) );
 
 
-		viewDoc.addStyleProcessorRules( addBackgroundRules );
+		editor.data.addStyleProcessorRules( addBackgroundRules );
 		enableProperty( schema, conversion, 'backgroundColor', 'background-color' );
 		enableProperty( schema, conversion, 'backgroundColor', 'background-color' );
 		editor.commands.add( 'tableCellBackgroundColor', new TableCellBackgroundColorCommand( editor ) );
 		editor.commands.add( 'tableCellBackgroundColor', new TableCellBackgroundColorCommand( editor ) );
 
 

+ 5 - 19
packages/ckeditor5-table/src/tableclipboard.js

@@ -48,18 +48,18 @@ export default class TableClipboard extends Plugin {
 		 */
 		 */
 		this._tableSelection = editor.plugins.get( 'TableSelection' );
 		this._tableSelection = editor.plugins.get( 'TableSelection' );
 
 
-		this.listenTo( viewDocument, 'copy', ( evt, data ) => this._onCopy( evt, data ), { priority: 'normal' } );
-		this.listenTo( viewDocument, 'cut', ( evt, data ) => this._onCut( evt, data ), { priority: 'high' } );
+		this.listenTo( viewDocument, 'copy', ( evt, data ) => this._onCopyCut( evt, data ) );
+		this.listenTo( viewDocument, 'cut', ( evt, data ) => this._onCopyCut( evt, data ) );
 	}
 	}
 
 
 	/**
 	/**
-	 * A clipboard "copy" event handler.
+	 * Copies table content to a clipboard on "copy" & "cut" events.
 	 *
 	 *
 	 * @param {module:utils/eventinfo~EventInfo} evt An object containing information about the handled event.
 	 * @param {module:utils/eventinfo~EventInfo} evt An object containing information about the handled event.
 	 * @param {Object} data Clipboard event data.
 	 * @param {Object} data Clipboard event data.
 	 * @private
 	 * @private
 	 */
 	 */
-	_onCopy( evt, data ) {
+	_onCopyCut( evt, data ) {
 		const tableSelection = this._tableSelection;
 		const tableSelection = this._tableSelection;
 
 
 		if ( !tableSelection.hasMultiCellSelection ) {
 		if ( !tableSelection.hasMultiCellSelection ) {
@@ -72,7 +72,7 @@ export default class TableClipboard extends Plugin {
 		const dataController = this.editor.data;
 		const dataController = this.editor.data;
 		const viewDocument = this.editor.editing.view.document;
 		const viewDocument = this.editor.editing.view.document;
 
 
-		const content = dataController.toView( tableSelection.getSelectionAsFragment() );
+		const content = dataController.toView( this._tableSelection.getSelectionAsFragment() );
 
 
 		viewDocument.fire( 'clipboardOutput', {
 		viewDocument.fire( 'clipboardOutput', {
 			dataTransfer: data.dataTransfer,
 			dataTransfer: data.dataTransfer,
@@ -80,18 +80,4 @@ export default class TableClipboard extends Plugin {
 			method: evt.name
 			method: evt.name
 		} );
 		} );
 	}
 	}
-
-	/**
-	 * A clipboard "cut" event handler.
-	 *
-	 * @param {module:utils/eventinfo~EventInfo} evt An object containing information about the handled event.
-	 * @param {Object} data Clipboard event data.
-	 * @private
-	 */
-	_onCut( evt, data ) {
-		if ( this._tableSelection.hasMultiCellSelection ) {
-			data.preventDefault();
-			evt.stop();
-		}
-	}
 }
 }

+ 2 - 3
packages/ckeditor5-table/src/tableproperties/tablepropertiesediting.js

@@ -69,9 +69,8 @@ export default class TablePropertiesEditing extends Plugin {
 		const editor = this.editor;
 		const editor = this.editor;
 		const schema = editor.model.schema;
 		const schema = editor.model.schema;
 		const conversion = editor.conversion;
 		const conversion = editor.conversion;
-		const viewDoc = editor.editing.view.document;
 
 
-		viewDoc.addStyleProcessorRules( addBorderRules );
+		editor.data.addStyleProcessorRules( addBorderRules );
 		enableBorderProperties( schema, conversion );
 		enableBorderProperties( schema, conversion );
 		editor.commands.add( 'tableBorderColor', new TableBorderColorCommand( editor ) );
 		editor.commands.add( 'tableBorderColor', new TableBorderColorCommand( editor ) );
 		editor.commands.add( 'tableBorderStyle', new TableBorderStyleCommand( editor ) );
 		editor.commands.add( 'tableBorderStyle', new TableBorderStyleCommand( editor ) );
@@ -86,7 +85,7 @@ export default class TablePropertiesEditing extends Plugin {
 		enableTableToFigureProperty( schema, conversion, 'height', 'height' );
 		enableTableToFigureProperty( schema, conversion, 'height', 'height' );
 		editor.commands.add( 'tableHeight', new TableHeightCommand( editor ) );
 		editor.commands.add( 'tableHeight', new TableHeightCommand( editor ) );
 
 
-		viewDoc.addStyleProcessorRules( addBackgroundRules );
+		editor.data.addStyleProcessorRules( addBackgroundRules );
 		enableProperty( schema, conversion, 'backgroundColor', 'background-color' );
 		enableProperty( schema, conversion, 'backgroundColor', 'background-color' );
 		editor.commands.add( 'tableBackgroundColor', new TableBackgroundColorCommand( editor ) );
 		editor.commands.add( 'tableBackgroundColor', new TableBackgroundColorCommand( editor ) );
 	}
 	}

+ 75 - 2
packages/ckeditor5-table/src/tableselection.js

@@ -14,6 +14,7 @@ import TableUtils from './tableutils';
 import { setupTableSelectionHighlighting } from './tableselection/converters';
 import { setupTableSelectionHighlighting } from './tableselection/converters';
 import MouseSelectionHandler from './tableselection/mouseselectionhandler';
 import MouseSelectionHandler from './tableselection/mouseselectionhandler';
 import { findAncestor } from './commands/utils';
 import { findAncestor } from './commands/utils';
+import { clearTableCellsContents } from './tableselection/utils';
 import cropTable from './tableselection/croptable';
 import cropTable from './tableselection/croptable';
 
 
 import '../theme/tableselection.css';
 import '../theme/tableselection.css';
@@ -95,13 +96,38 @@ export default class TableSelection extends Plugin {
 	 */
 	 */
 	init() {
 	init() {
 		const editor = this.editor;
 		const editor = this.editor;
-		const selection = editor.model.document.selection;
+		const model = editor.model;
+		const selection = model.document.selection;
 
 
 		this._tableUtils = editor.plugins.get( 'TableUtils' );
 		this._tableUtils = editor.plugins.get( 'TableUtils' );
 
 
 		setupTableSelectionHighlighting( editor, this );
 		setupTableSelectionHighlighting( editor, this );
 
 
-		selection.on( 'change:range', () => this._clearSelectionOnExternalChange( selection ) );
+		this.listenTo( selection, 'change:range', () => this._clearSelectionOnExternalChange( selection ) );
+		this.listenTo( model, 'deleteContent', ( evt, args ) => this._handleDeleteContent( evt, args ), { priority: 'high' } );
+	}
+
+	/**
+	 * @inheritDoc
+	 */
+	afterInit() {
+		const editor = this.editor;
+
+		const deleteCommand = editor.commands.get( 'delete' );
+
+		if ( deleteCommand ) {
+			this.listenTo( deleteCommand, 'execute', event => {
+				this._handleDeleteCommand( event, { isForward: false } );
+			}, { priority: 'high' } );
+		}
+
+		const forwardDeleteCommand = editor.commands.get( 'forwardDelete' );
+
+		if ( forwardDeleteCommand ) {
+			this.listenTo( forwardDeleteCommand, 'execute', event => {
+				this._handleDeleteCommand( event, { isForward: true } );
+			}, { priority: 'high' } );
+		}
 	}
 	}
 
 
 	/**
 	/**
@@ -203,6 +229,7 @@ export default class TableSelection extends Plugin {
 	 * @returns {Iterable.<module:engine/model/element~Element>}
 	 * @returns {Iterable.<module:engine/model/element~Element>}
 	 */
 	 */
 	* getSelectedTableCells() {
 	* getSelectedTableCells() {
+		// TODO: this function should be removed. See https://github.com/ckeditor/ckeditor5/issues/6358
 		if ( !this.hasMultiCellSelection ) {
 		if ( !this.hasMultiCellSelection ) {
 			return;
 			return;
 		}
 		}
@@ -279,4 +306,50 @@ export default class TableSelection extends Plugin {
 			this.clearSelection();
 			this.clearSelection();
 		}
 		}
 	}
 	}
+
+	/**
+	 * It overrides default `model.deleteContent()` behavior over a selected table fragment.
+	 *
+	 * @private
+	 * @param {module:utils/eventinfo~EventInfo} event
+	 * @param {Array.<*>} args Delete content method arguments.
+	 */
+	_handleDeleteContent( event, args ) {
+		const [ selection ] = args;
+		const model = this.editor.model;
+
+		if ( this.hasMultiCellSelection && selection.is( 'documentSelection' ) ) {
+			event.stop();
+
+			clearTableCellsContents( model, this.getSelectedTableCells() );
+
+			model.change( writer => {
+				writer.setSelection( Array.from( this.getSelectedTableCells() ).pop(), 0 );
+			} );
+		}
+	}
+
+	/**
+	 * It overrides default `DeleteCommand` behavior over a selected table fragment.
+	 *
+	 * @private
+	 * @param {module:utils/eventinfo~EventInfo} event
+	 * @param {Object} options
+	 * @param {Boolean} options.isForward Whether it handles forward or backward delete.
+	 */
+	_handleDeleteCommand( event, options ) {
+		const model = this.editor.model;
+
+		if ( this.hasMultiCellSelection ) {
+			event.stop();
+
+			clearTableCellsContents( model, this.getSelectedTableCells() );
+
+			const tableCell = options.isForward ? this._startElement : this._endElement;
+
+			model.change( writer => {
+				writer.setSelection( tableCell, 0 );
+			} );
+		}
+	}
 }
 }

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

@@ -17,7 +17,7 @@ import { findAncestor } from '../commands/utils';
  *		tableSelection.startSelectingFrom( startCell )
  *		tableSelection.startSelectingFrom( startCell )
  *		tableSelection.setSelectingFrom( endCell )
  *		tableSelection.setSelectingFrom( endCell )
  *
  *
- *		const croppedTable = cropTable( tableSelection.getSelectedTableCells );
+ *		const croppedTable = cropTable( tableSelection.getSelectedTableCells() );
  *
  *
  * **Note**: This function is used also by {@link module:table/tableselection~TableSelection#getSelectionAsFragment}
  * **Note**: This function is used also by {@link module:table/tableselection~TableSelection#getSelectionAsFragment}
  *
  *

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

@@ -40,10 +40,11 @@ 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 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 a 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.
 		 *
 		 *
+		 * @private
 		 * @readonly
 		 * @readonly
 		 * @member {Boolean}
 		 * @member {Boolean}
 		 */
 		 */
-		this.isSelecting = false;
+		this._isSelecting = false;
 
 
 		/**
 		/**
 		 * Editing mapper.
 		 * Editing mapper.
@@ -77,12 +78,11 @@ export default class MouseSelectionHandler {
 
 
 		if ( !tableCell ) {
 		if ( !tableCell ) {
 			this._tableSelection.clearSelection();
 			this._tableSelection.clearSelection();
-			this._tableSelection.stopSelection();
 
 
 			return;
 			return;
 		}
 		}
 
 
-		this.isSelecting = true;
+		this._isSelecting = true;
 		this._tableSelection.startSelectingFrom( tableCell );
 		this._tableSelection.startSelectingFrom( tableCell );
 	}
 	}
 
 
@@ -95,12 +95,15 @@ export default class MouseSelectionHandler {
 	 * @private
 	 * @private
 	 */
 	 */
 	_handleMouseMove( domEventData ) {
 	_handleMouseMove( domEventData ) {
-		if ( !isButtonPressed( domEventData ) ) {
+		if ( !this._isSelecting || !isButtonPressed( domEventData ) ) {
 			this._tableSelection.stopSelection();
 			this._tableSelection.stopSelection();
 
 
 			return;
 			return;
 		}
 		}
 
 
+		// https://github.com/ckeditor/ckeditor5/issues/6114
+		domEventData.preventDefault();
+
 		const tableCell = this._getModelTableCellFromDomEvent( domEventData );
 		const tableCell = this._getModelTableCellFromDomEvent( domEventData );
 
 
 		if ( !tableCell ) {
 		if ( !tableCell ) {
@@ -119,10 +122,12 @@ export default class MouseSelectionHandler {
 	 * @private
 	 * @private
 	 */
 	 */
 	_handleMouseUp( domEventData ) {
 	_handleMouseUp( domEventData ) {
-		if ( !this.isSelecting ) {
+		if ( !this._isSelecting ) {
 			return;
 			return;
 		}
 		}
 
 
+		this._isSelecting = false;
+
 		const tableCell = this._getModelTableCellFromDomEvent( domEventData );
 		const tableCell = this._getModelTableCellFromDomEvent( domEventData );
 
 
 		// Selection can be stopped if table cell is undefined.
 		// Selection can be stopped if table cell is undefined.

+ 31 - 0
packages/ckeditor5-table/src/tableselection/utils.js

@@ -0,0 +1,31 @@
+/**
+ * @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
+ */
+
+/**
+ * @module table/tableselection/utils
+ */
+
+/**
+ * Clears contents of the passed table cells.
+ *
+ * This is to be used with table selection
+ *
+ *		tableSelection.startSelectingFrom( startCell )
+ *		tableSelection.setSelectingFrom( endCell )
+ *
+ *		clearTableCellsContents( editor.model, tableSelection.getSelectedTableCells() );
+ *
+ * **Note**: This function is used also by {@link module:table/tableselection~TableSelection#getSelectionAsFragment}
+ *
+ * @param {module:engine/model/model~Model} model
+ * @param {Iterable.<module:engine/model/element~Element>} tableCells
+ */
+export function clearTableCellsContents( model, tableCells ) {
+	model.change( writer => {
+		for ( const tableCell of tableCells ) {
+			model.deleteContent( writer.createSelection( tableCell, 'in' ) );
+		}
+	} );
+}

+ 12 - 2
packages/ckeditor5-table/src/ui/utils.js

@@ -81,8 +81,8 @@ export function getBalloonTablePositionData( editor ) {
  * @returns {module:utils/dom/position~Options}
  * @returns {module:utils/dom/position~Options}
  */
  */
 export function getBalloonCellPositionData( editor ) {
 export function getBalloonCellPositionData( editor ) {
-	const firstPosition = editor.model.document.selection.getFirstPosition();
-	const modelTableCell = findAncestor( 'tableCell', firstPosition );
+	// This is a bit naive. See https://github.com/ckeditor/ckeditor5/issues/6357.
+	const modelTableCell = getTableCellAtPosition( editor.model.document.selection.getFirstPosition() );
 	const viewTableCell = editor.editing.mapper.toViewElement( modelTableCell );
 	const viewTableCell = editor.editing.mapper.toViewElement( modelTableCell );
 
 
 	return {
 	return {
@@ -468,3 +468,13 @@ function colorConfigToColorGridDefinitions( colorConfig ) {
 		}
 		}
 	} ) );
 	} ) );
 }
 }
+
+// Returns the first selected table cell from a multi-cell or in-cell selection.
+//
+// @param {module:engine/model/position~Position} position Document position.
+// @returns {module:engine/model/element~Element}
+function getTableCellAtPosition( position ) {
+	const isTableCellSelected = position.nodeAfter && position.nodeAfter.is( 'tableCell' );
+
+	return isTableCellSelected ? position.nodeAfter : findAncestor( 'tableCell', position );
+}

+ 18 - 7
packages/ckeditor5-table/tests/manual/tableselection.html

@@ -12,6 +12,11 @@
 	.external-source td, .external-source th {
 	.external-source td, .external-source th {
 		border: solid 1px hsl(0, 0%, 85%);
 		border: solid 1px hsl(0, 0%, 85%);
 	}
 	}
+
+	/* It should not create entire viewport scroll. */
+	pre {
+		overflow: auto;
+	}
 </style>
 </style>
 
 
 <h3>A "content" test editor</h3>
 <h3>A "content" test editor</h3>
@@ -52,7 +57,13 @@
 					<td>k</td>
 					<td>k</td>
 					<td>l</td>
 					<td>l</td>
 					<td><strong>m</strong></td>
 					<td><strong>m</strong></td>
-					<td>n</td>
+					<td>
+						<p>n</p>
+						<figure class="image image-style-side">
+							<img src="sample.jpg" />
+							<figcaption>Caption!</figcaption>
+						</figure>
+					</td>
 					<td>o</td>
 					<td>o</td>
 				</tr>
 				</tr>
 				<tr>
 				<tr>
@@ -110,7 +121,7 @@
 					<td rowspan="4">02</td>
 					<td rowspan="4">02</td>
 					<td>03</td>
 					<td>03</td>
 					<td colspan="2" rowspan="7">04</td>
 					<td colspan="2" rowspan="7">04</td>
-					<td>07</td>
+					<td>06</td>
 					<td>07</td>
 					<td>07</td>
 					<td>08</td>
 					<td>08</td>
 				</tr>
 				</tr>
@@ -118,7 +129,7 @@
 					<td>10</td>
 					<td>10</td>
 					<td>11</td>
 					<td>11</td>
 					<td>13</td>
 					<td>13</td>
-					<td>17</td>
+					<td>16</td>
 					<td>17</td>
 					<td>17</td>
 					<td>18</td>
 					<td>18</td>
 				</tr>
 				</tr>
@@ -126,18 +137,18 @@
 					<td>20</td>
 					<td>20</td>
 					<td>21</td>
 					<td>21</td>
 					<td>23</td>
 					<td>23</td>
-					<td colspan="3">27</td>
+					<td colspan="3">26</td>
 				</tr>
 				</tr>
 				<tr>
 				<tr>
 					<td>30</td>
 					<td>30</td>
 					<td>31</td>
 					<td>31</td>
 					<td>33</td>
 					<td>33</td>
-					<td>37</td>
+					<td>36</td>
 					<td colspan="2">37</td>
 					<td colspan="2">37</td>
 				</tr>
 				</tr>
 				<tr>
 				<tr>
 					<td colspan="4">40</td>
 					<td colspan="4">40</td>
-					<td>47</td>
+					<td>46</td>
 					<td>47</td>
 					<td>47</td>
 					<td>48</td>
 					<td>48</td>
 				</tr>
 				</tr>
@@ -146,7 +157,7 @@
 					<td>51</td>
 					<td>51</td>
 					<td>52</td>
 					<td>52</td>
 					<td>53</td>
 					<td>53</td>
-					<td rowspan="4">57</td>
+					<td rowspan="4">56</td>
 					<td>57</td>
 					<td>57</td>
 					<td>58</td>
 					<td>58</td>
 				</tr>
 				</tr>

+ 3 - 0
packages/ckeditor5-table/tests/manual/tableselection.js

@@ -31,6 +31,9 @@ function createEditor( target, inspectorName ) {
 				'bulletedList', 'numberedList', 'blockQuote', '|',
 				'bulletedList', 'numberedList', 'blockQuote', '|',
 				'undo', 'redo'
 				'undo', 'redo'
 			],
 			],
+			image: {
+				toolbar: [ 'imageStyle:full', 'imageStyle:side', '|', 'imageTextAlternative' ]
+			},
 			table: {
 			table: {
 				contentToolbar: [ 'tableColumn', 'tableRow', 'mergeTableCells', 'tableProperties', 'tableCellProperties' ]
 				contentToolbar: [ 'tableColumn', 'tableRow', 'mergeTableCells', 'tableProperties', 'tableCellProperties' ]
 			}
 			}

+ 107 - 1
packages/ckeditor5-table/tests/tablecellproperties/commands/tablecellbackgroundcolorcommand.js

@@ -8,9 +8,10 @@ import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
 
 
 import { setData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
 import { setData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
 
 
-import { assertTableCellStyle, modelTable } from '../../_utils/utils';
+import { assertTableCellStyle, modelTable, viewTable } from '../../_utils/utils';
 import TableCellPropertiesEditing from '../../../src/tablecellproperties/tablecellpropertiesediting';
 import TableCellPropertiesEditing from '../../../src/tablecellproperties/tablecellpropertiesediting';
 import TableCellBackgroundColorCommand from '../../../src/tablecellproperties/commands/tablecellbackgroundcolorcommand';
 import TableCellBackgroundColorCommand from '../../../src/tablecellproperties/commands/tablecellbackgroundcolorcommand';
+import { assertEqualMarkup } from '@ckeditor/ckeditor5-utils/tests/_utils/utils';
 
 
 describe( 'table cell properties', () => {
 describe( 'table cell properties', () => {
 	describe( 'commands', () => {
 	describe( 'commands', () => {
@@ -54,6 +55,17 @@ describe( 'table cell properties', () => {
 						expect( command.isEnabled ).to.be.true;
 						expect( command.isEnabled ).to.be.true;
 					} );
 					} );
 				} );
 				} );
+
+				describe( 'multi-cell selection', () => {
+					it( 'should be true if the selection contains some table cells', () => {
+						setData( model, modelTable( [
+							[ { contents: '00', isSelected: true }, '01' ],
+							[ '10', { contents: '11', isSelected: true } ]
+						] ) );
+
+						expect( command.isEnabled ).to.be.true;
+					} );
+				} );
 			} );
 			} );
 
 
 			describe( 'value', () => {
 			describe( 'value', () => {
@@ -84,6 +96,68 @@ describe( 'table cell properties', () => {
 						expect( command.value ).to.equal( 'blue' );
 						expect( command.value ).to.equal( 'blue' );
 					} );
 					} );
 				} );
 				} );
+
+				describe( 'multi-cell selection', () => {
+					it( 'should be undefined if no table cell have the "backgroundColor" property', () => {
+						setData( model, modelTable( [
+							[
+								{ contents: '00', isSelected: true },
+								{ contents: '01', isSelected: true }
+							],
+							[
+								'10',
+								{ contents: '11', isSelected: true }
+							]
+						] ) );
+
+						expect( command.value ).to.be.undefined;
+					} );
+
+					it( 'should be undefined if only some table cells have the "backgroundColor" property', () => {
+						setData( model, modelTable( [
+							[
+								{ contents: '00', isSelected: true, backgroundColor: '#f00' },
+								{ contents: '01', isSelected: true }
+							],
+							[
+								'10',
+								{ contents: '11', isSelected: true, backgroundColor: '#f00' }
+							]
+						] ) );
+
+						expect( command.value ).to.be.undefined;
+					} );
+
+					it( 'should be undefined if one of selected table cells has a different "backgroundColor" property value', () => {
+						setData( model, modelTable( [
+							[
+								{ contents: '00', isSelected: true, backgroundColor: '#f00' },
+								{ contents: '01', isSelected: true, backgroundColor: 'pink' }
+							],
+							[
+								'10',
+								{ contents: '11', isSelected: true, backgroundColor: '#f00' }
+							]
+						] ) );
+
+						expect( command.value ).to.be.undefined;
+					} );
+
+					it( 'should be set if all table cell have the same "backgroundColor" property value', () => {
+						setData( model, modelTable( [
+							[
+								{ contents: '00', isSelected: true, backgroundColor: '#f00' },
+								{ contents: '01', isSelected: true, backgroundColor: '#f00' }
+							],
+							[
+								'10',
+								{ contents: '11', isSelected: true, backgroundColor: '#f00' }
+							]
+						] ) );
+
+						expect( command.value ).to.equal( '#f00' );
+					} );
+				} );
 			} );
 			} );
 
 
 			describe( 'execute()', () => {
 			describe( 'execute()', () => {
@@ -147,6 +221,38 @@ describe( 'table cell properties', () => {
 						assertTableCellStyle( editor, '' );
 						assertTableCellStyle( editor, '' );
 					} );
 					} );
 				} );
 				} );
+
+				describe( 'multi-cell selection', () => {
+					beforeEach( () => {
+						setData( model, modelTable( [
+							[ { contents: '00', isSelected: true }, '01' ],
+							[ '10', { contents: '11', isSelected: true } ]
+						] ) );
+					} );
+
+					it( 'should set the "backgroundColor" attribute value of selected table cells', () => {
+						command.execute( { value: '#f00' } );
+
+						assertEqualMarkup( editor.getData(), viewTable( [
+							[ { contents: '00', style: 'background-color:#f00;' }, '01' ],
+							[ '10', { contents: '11', style: 'background-color:#f00;' } ]
+						] ) );
+					} );
+
+					it( 'should remove "backgroundColor" from a selected table cell if no value is passed', () => {
+						setData( model, modelTable( [
+							[ { contents: '00', isSelected: true, backgroundColor: '#f00' }, '01' ],
+							[ '10', { contents: '11', isSelected: true, backgroundColor: '#f00' } ]
+						] ) );
+
+						command.execute();
+
+						assertEqualMarkup( editor.getData(), viewTable( [
+							[ '00', '01' ],
+							[ '10', '11' ]
+						] ) );
+					} );
+				} );
 			} );
 			} );
 		} );
 		} );
 	} );
 	} );

+ 107 - 1
packages/ckeditor5-table/tests/tablecellproperties/commands/tablecellbordercolorcommand.js

@@ -8,9 +8,10 @@ import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
 
 
 import { setData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
 import { setData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
 
 
-import { assertTableCellStyle, modelTable, setTableCellWithObjectAttributes } from '../../_utils/utils';
+import { assertTableCellStyle, modelTable, setTableCellWithObjectAttributes, viewTable } from '../../_utils/utils';
 import TableCellPropertiesEditing from '../../../src/tablecellproperties/tablecellpropertiesediting';
 import TableCellPropertiesEditing from '../../../src/tablecellproperties/tablecellpropertiesediting';
 import TableCellBorderColorCommand from '../../../src/tablecellproperties/commands/tablecellbordercolorcommand';
 import TableCellBorderColorCommand from '../../../src/tablecellproperties/commands/tablecellbordercolorcommand';
+import { assertEqualMarkup } from '@ckeditor/ckeditor5-utils/tests/_utils/utils';
 
 
 describe( 'table cell properties', () => {
 describe( 'table cell properties', () => {
 	describe( 'commands', () => {
 	describe( 'commands', () => {
@@ -54,6 +55,17 @@ describe( 'table cell properties', () => {
 						expect( command.isEnabled ).to.be.true;
 						expect( command.isEnabled ).to.be.true;
 					} );
 					} );
 				} );
 				} );
+
+				describe( 'multi-cell selection', () => {
+					it( 'should be true if the selection contains some table cells', () => {
+						setData( model, modelTable( [
+							[ { contents: '00', isSelected: true }, '01' ],
+							[ '10', { contents: '11', isSelected: true } ]
+						] ) );
+
+						expect( command.isEnabled ).to.be.true;
+					} );
+				} );
 			} );
 			} );
 
 
 			describe( 'value', () => {
 			describe( 'value', () => {
@@ -109,6 +121,68 @@ describe( 'table cell properties', () => {
 						expect( command.value ).to.equal( 'blue' );
 						expect( command.value ).to.equal( 'blue' );
 					} );
 					} );
 				} );
 				} );
+
+				describe( 'multi-cell selection', () => {
+					it( 'should be undefined if no table cells have the "borderColor" property', () => {
+						setData( model, modelTable( [
+							[
+								{ contents: '00', isSelected: true },
+								{ contents: '01', isSelected: true }
+							],
+							[
+								'10',
+								{ contents: '11', isSelected: true }
+							]
+						] ) );
+
+						expect( command.value ).to.be.undefined;
+					} );
+
+					it( 'should be undefined if only some table cells have the "borderColor" property', () => {
+						setData( model, modelTable( [
+							[
+								{ contents: '00', isSelected: true, borderColor: '#f00' },
+								{ contents: '01', isSelected: true }
+							],
+							[
+								'10',
+								{ contents: '11', isSelected: true, borderColor: '#f00' }
+							]
+						] ) );
+
+						expect( command.value ).to.be.undefined;
+					} );
+
+					it( 'should be undefined if one of selected table cells has a different "borderColor" property value', () => {
+						setData( model, modelTable( [
+							[
+								{ contents: '00', isSelected: true, borderColor: '#f00' },
+								{ contents: '01', isSelected: true, borderColor: 'pink' }
+							],
+							[
+								'10',
+								{ contents: '11', isSelected: true, borderColor: '#f00' }
+							]
+						] ) );
+
+						expect( command.value ).to.be.undefined;
+					} );
+
+					it( 'should be set if all table cells have the same "borderColor" property value', () => {
+						setData( model, modelTable( [
+							[
+								{ contents: '00', isSelected: true, borderColor: '#f00' },
+								{ contents: '01', isSelected: true, borderColor: '#f00' }
+							],
+							[
+								'10',
+								{ contents: '11', isSelected: true, borderColor: '#f00' }
+							]
+						] ) );
+
+						expect( command.value ).to.equal( '#f00' );
+					} );
+				} );
 			} );
 			} );
 
 
 			describe( 'execute()', () => {
 			describe( 'execute()', () => {
@@ -172,6 +246,38 @@ describe( 'table cell properties', () => {
 						assertTableCellStyle( editor, '' );
 						assertTableCellStyle( editor, '' );
 					} );
 					} );
 				} );
 				} );
+
+				describe( 'multi-cell selection', () => {
+					beforeEach( () => {
+						setData( model, modelTable( [
+							[ { contents: '00', isSelected: true }, '01' ],
+							[ '10', { contents: '11', isSelected: true } ]
+						] ) );
+					} );
+
+					it( 'should set the "borderColor" attribute value of selected table cells', () => {
+						command.execute( { value: '#f00' } );
+
+						assertEqualMarkup( editor.getData(), viewTable( [
+							[ { contents: '00', style: 'border-bottom:#f00;border-left:#f00;border-right:#f00;border-top:#f00;' }, '01' ],
+							[ '10', { contents: '11', style: 'border-bottom:#f00;border-left:#f00;border-right:#f00;border-top:#f00;' } ]
+						] ) );
+					} );
+
+					it( 'should remove "borderColor" from the selected table cell if no value is passed', () => {
+						setData( model, modelTable( [
+							[ { contents: '00', isSelected: true, borderColor: '#f00' }, '01' ],
+							[ '10', { contents: '11', isSelected: true, borderColor: '#f00' } ]
+						] ) );
+
+						command.execute();
+
+						assertEqualMarkup( editor.getData(), viewTable( [
+							[ '00', '01' ],
+							[ '10', '11' ]
+						] ) );
+					} );
+				} );
 			} );
 			} );
 		} );
 		} );
 	} );
 	} );

+ 113 - 1
packages/ckeditor5-table/tests/tablecellproperties/commands/tablecellborderstylecommand.js

@@ -8,9 +8,10 @@ import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
 
 
 import { setData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
 import { setData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
 
 
-import { assertTableCellStyle, modelTable, setTableCellWithObjectAttributes } from '../../_utils/utils';
+import { assertTableCellStyle, modelTable, setTableCellWithObjectAttributes, viewTable } from '../../_utils/utils';
 import TableCellPropertiesEditing from '../../../src/tablecellproperties/tablecellpropertiesediting';
 import TableCellPropertiesEditing from '../../../src/tablecellproperties/tablecellpropertiesediting';
 import TableCellBorderStyleCommand from '../../../src/tablecellproperties/commands/tablecellborderstylecommand';
 import TableCellBorderStyleCommand from '../../../src/tablecellproperties/commands/tablecellborderstylecommand';
+import { assertEqualMarkup } from '@ckeditor/ckeditor5-utils/tests/_utils/utils';
 
 
 describe( 'table cell properties', () => {
 describe( 'table cell properties', () => {
 	describe( 'commands', () => {
 	describe( 'commands', () => {
@@ -54,6 +55,17 @@ describe( 'table cell properties', () => {
 						expect( command.isEnabled ).to.be.true;
 						expect( command.isEnabled ).to.be.true;
 					} );
 					} );
 				} );
 				} );
+
+				describe( 'multi-cell selection', () => {
+					it( 'should be true if the selection contains some table cells', () => {
+						setData( model, modelTable( [
+							[ { contents: '00', isSelected: true }, '01' ],
+							[ '10', { contents: '11', isSelected: true } ]
+						] ) );
+
+						expect( command.isEnabled ).to.be.true;
+					} );
+				} );
 			} );
 			} );
 
 
 			describe( 'value', () => {
 			describe( 'value', () => {
@@ -109,6 +121,68 @@ describe( 'table cell properties', () => {
 						expect( command.value ).to.equal( 'ridge' );
 						expect( command.value ).to.equal( 'ridge' );
 					} );
 					} );
 				} );
 				} );
+
+				describe( 'multi-cell selection', () => {
+					it( 'should be undefined if no table cells have the "borderStyle" property', () => {
+						setData( model, modelTable( [
+							[
+								{ contents: '00', isSelected: true },
+								{ contents: '01', isSelected: true }
+							],
+							[
+								'10',
+								{ contents: '11', isSelected: true }
+							]
+						] ) );
+
+						expect( command.value ).to.be.undefined;
+					} );
+
+					it( 'should be undefined if only some table cells have the "borderStyle" property', () => {
+						setData( model, modelTable( [
+							[
+								{ contents: '00', isSelected: true, borderStyle: 'solid' },
+								{ contents: '01', isSelected: true }
+							],
+							[
+								'10',
+								{ contents: '11', isSelected: true, borderStyle: 'solid' }
+							]
+						] ) );
+
+						expect( command.value ).to.be.undefined;
+					} );
+
+					it( 'should be undefined if one of selected table cells has a different "borderStyle" property value', () => {
+						setData( model, modelTable( [
+							[
+								{ contents: '00', isSelected: true, borderStyle: 'solid' },
+								{ contents: '01', isSelected: true, borderStyle: 'ridge' }
+							],
+							[
+								'10',
+								{ contents: '11', isSelected: true, borderStyle: 'solid' }
+							]
+						] ) );
+
+						expect( command.value ).to.be.undefined;
+					} );
+
+					it( 'should be set if all table cells have the same "borderStyle" property value', () => {
+						setData( model, modelTable( [
+							[
+								{ contents: '00', isSelected: true, borderStyle: 'solid' },
+								{ contents: '01', isSelected: true, borderStyle: 'solid' }
+							],
+							[
+								'10',
+								{ contents: '11', isSelected: true, borderStyle: 'solid' }
+							]
+						] ) );
+
+						expect( command.value ).to.equal( 'solid' );
+					} );
+				} );
 			} );
 			} );
 
 
 			describe( 'execute()', () => {
 			describe( 'execute()', () => {
@@ -172,6 +246,44 @@ describe( 'table cell properties', () => {
 						assertTableCellStyle( editor, '' );
 						assertTableCellStyle( editor, '' );
 					} );
 					} );
 				} );
 				} );
+
+				describe( 'multi-cell selection', () => {
+					beforeEach( () => {
+						setData( model, modelTable( [
+							[ { contents: '00', isSelected: true }, '01' ],
+							[ '10', { contents: '11', isSelected: true } ]
+						] ) );
+					} );
+
+					it( 'should set the "borderStyle" attribute value of selected table cells', () => {
+						command.execute( { value: 'solid' } );
+
+						assertEqualMarkup( editor.getData(), viewTable( [
+							[
+								{ contents: '00', style: 'border-bottom:solid;border-left:solid;border-right:solid;border-top:solid;' },
+								'01'
+							],
+							[
+								'10',
+								{ contents: '11', style: 'border-bottom:solid;border-left:solid;border-right:solid;border-top:solid;' }
+							]
+						] ) );
+					} );
+
+					it( 'should remove "borderStyle" from selected table cells if no value is passed', () => {
+						setData( model, modelTable( [
+							[ { contents: '00', isSelected: true, borderStyle: 'solid' }, '01' ],
+							[ '10', { contents: '11', isSelected: true, borderStyle: 'solid' } ]
+						] ) );
+
+						command.execute();
+
+						assertEqualMarkup( editor.getData(), viewTable( [
+							[ '00', '01' ],
+							[ '10', '11' ]
+						] ) );
+					} );
+				} );
 			} );
 			} );
 		} );
 		} );
 	} );
 	} );

+ 113 - 1
packages/ckeditor5-table/tests/tablecellproperties/commands/tablecellborderwidthcommand.js

@@ -8,9 +8,10 @@ import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
 
 
 import { setData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
 import { setData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
 
 
-import { assertTableCellStyle, modelTable, setTableCellWithObjectAttributes } from '../../_utils/utils';
+import { assertTableCellStyle, modelTable, setTableCellWithObjectAttributes, viewTable } from '../../_utils/utils';
 import TableCellPropertiesEditing from '../../../src/tablecellproperties/tablecellpropertiesediting';
 import TableCellPropertiesEditing from '../../../src/tablecellproperties/tablecellpropertiesediting';
 import TableCellBorderWidthCommand from '../../../src/tablecellproperties/commands/tablecellborderwidthcommand';
 import TableCellBorderWidthCommand from '../../../src/tablecellproperties/commands/tablecellborderwidthcommand';
+import { assertEqualMarkup } from '@ckeditor/ckeditor5-utils/tests/_utils/utils';
 
 
 describe( 'table cell properties', () => {
 describe( 'table cell properties', () => {
 	describe( 'commands', () => {
 	describe( 'commands', () => {
@@ -54,6 +55,17 @@ describe( 'table cell properties', () => {
 						expect( command.isEnabled ).to.be.true;
 						expect( command.isEnabled ).to.be.true;
 					} );
 					} );
 				} );
 				} );
+
+				describe( 'multi-cell selection', () => {
+					it( 'should be true if the selection contains some table cells', () => {
+						setData( model, modelTable( [
+							[ { contents: '00', isSelected: true }, '01' ],
+							[ '10', { contents: '11', isSelected: true } ]
+						] ) );
+
+						expect( command.isEnabled ).to.be.true;
+					} );
+				} );
 			} );
 			} );
 
 
 			describe( 'value', () => {
 			describe( 'value', () => {
@@ -109,6 +121,68 @@ describe( 'table cell properties', () => {
 						expect( command.value ).to.equal( '2em' );
 						expect( command.value ).to.equal( '2em' );
 					} );
 					} );
 				} );
 				} );
+
+				describe( 'multi-cell selection', () => {
+					it( 'should be undefined if no table cells have the "borderWidth" property', () => {
+						setData( model, modelTable( [
+							[
+								{ contents: '00', isSelected: true },
+								{ contents: '01', isSelected: true }
+							],
+							[
+								'10',
+								{ contents: '11', isSelected: true }
+							]
+						] ) );
+
+						expect( command.value ).to.be.undefined;
+					} );
+
+					it( 'should be undefined if only some table cells have the "borderWidth" property', () => {
+						setData( model, modelTable( [
+							[
+								{ contents: '00', isSelected: true, borderWidth: '1px' },
+								{ contents: '01', isSelected: true }
+							],
+							[
+								'10',
+								{ contents: '11', isSelected: true, borderWidth: '1px' }
+							]
+						] ) );
+
+						expect( command.value ).to.be.undefined;
+					} );
+
+					it( 'should be undefined if one of selected table cells has a different "borderWidth" property value', () => {
+						setData( model, modelTable( [
+							[
+								{ contents: '00', isSelected: true, borderWidth: '1px' },
+								{ contents: '01', isSelected: true, borderWidth: '20px' }
+							],
+							[
+								'10',
+								{ contents: '11', isSelected: true, borderWidth: '1px' }
+							]
+						] ) );
+
+						expect( command.value ).to.be.undefined;
+					} );
+
+					it( 'should be set if all table cells have the same "borderWidth" property value', () => {
+						setData( model, modelTable( [
+							[
+								{ contents: '00', isSelected: true, borderWidth: '1px' },
+								{ contents: '01', isSelected: true, borderWidth: '1px' }
+							],
+							[
+								'10',
+								{ contents: '11', isSelected: true, borderWidth: '1px' }
+							]
+						] ) );
+
+						expect( command.value ).to.equal( '1px' );
+					} );
+				} );
 			} );
 			} );
 
 
 			describe( 'execute()', () => {
 			describe( 'execute()', () => {
@@ -228,6 +302,44 @@ describe( 'table cell properties', () => {
 						assertTableCellStyle( editor, '' );
 						assertTableCellStyle( editor, '' );
 					} );
 					} );
 				} );
 				} );
+
+				describe( 'multi-cell selection', () => {
+					beforeEach( () => {
+						setData( model, modelTable( [
+							[ { contents: '00', isSelected: true }, '01' ],
+							[ '10', { contents: '11', isSelected: true } ]
+						] ) );
+					} );
+
+					it( 'should set the "borderWidth" attribute value of selected table cells', () => {
+						command.execute( { value: '1px' } );
+
+						assertEqualMarkup( editor.getData(), viewTable( [
+							[
+								{ contents: '00', style: 'border-bottom:1px;border-left:1px;border-right:1px;border-top:1px;' },
+								'01'
+							],
+							[
+								'10',
+								{ contents: '11', style: 'border-bottom:1px;border-left:1px;border-right:1px;border-top:1px;' }
+							]
+						] ) );
+					} );
+
+					it( 'should remove "borderWidth" from selected table cells if no value is passed', () => {
+						setData( model, modelTable( [
+							[ { contents: '00', isSelected: true, borderWidth: '1px' }, '01' ],
+							[ '10', { contents: '11', isSelected: true, borderWidth: '1px' } ]
+						] ) );
+
+						command.execute();
+
+						assertEqualMarkup( editor.getData(), viewTable( [
+							[ '00', '01' ],
+							[ '10', '11' ]
+						] ) );
+					} );
+				} );
 			} );
 			} );
 		} );
 		} );
 	} );
 	} );

+ 107 - 1
packages/ckeditor5-table/tests/tablecellproperties/commands/tablecellheightcommand.js

@@ -8,9 +8,10 @@ import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
 
 
 import { setData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
 import { setData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
 
 
-import { assertTableCellStyle, modelTable } from '../../_utils/utils';
+import { assertTableCellStyle, modelTable, viewTable } from '../../_utils/utils';
 import TableCellPropertiesEditing from '../../../src/tablecellproperties/tablecellpropertiesediting';
 import TableCellPropertiesEditing from '../../../src/tablecellproperties/tablecellpropertiesediting';
 import TableCellHeightCommand from '../../../src/tablecellproperties/commands/tablecellheightcommand';
 import TableCellHeightCommand from '../../../src/tablecellproperties/commands/tablecellheightcommand';
+import { assertEqualMarkup } from '@ckeditor/ckeditor5-utils/tests/_utils/utils';
 
 
 describe( 'table cell properties', () => {
 describe( 'table cell properties', () => {
 	describe( 'commands', () => {
 	describe( 'commands', () => {
@@ -54,6 +55,17 @@ describe( 'table cell properties', () => {
 						expect( command.isEnabled ).to.be.true;
 						expect( command.isEnabled ).to.be.true;
 					} );
 					} );
 				} );
 				} );
+
+				describe( 'multi-cell selection', () => {
+					it( 'should be true if the selection contains some table cells', () => {
+						setData( model, modelTable( [
+							[ { contents: '00', isSelected: true }, '01' ],
+							[ '10', { contents: '11', isSelected: true } ]
+						] ) );
+
+						expect( command.isEnabled ).to.be.true;
+					} );
+				} );
 			} );
 			} );
 
 
 			describe( 'value', () => {
 			describe( 'value', () => {
@@ -84,6 +96,68 @@ describe( 'table cell properties', () => {
 						expect( command.value ).to.equal( '100px' );
 						expect( command.value ).to.equal( '100px' );
 					} );
 					} );
 				} );
 				} );
+
+				describe( 'multi-cell selection', () => {
+					it( 'should be undefined if no table cell have the "height" property', () => {
+						setData( model, modelTable( [
+							[
+								{ contents: '00', isSelected: true },
+								{ contents: '01', isSelected: true }
+							],
+							[
+								'10',
+								{ contents: '11', isSelected: true }
+							]
+						] ) );
+
+						expect( command.value ).to.be.undefined;
+					} );
+
+					it( 'should be undefined if only some table cells have the "height" property', () => {
+						setData( model, modelTable( [
+							[
+								{ contents: '00', isSelected: true, height: '100px' },
+								{ contents: '01', isSelected: true }
+							],
+							[
+								'10',
+								{ contents: '11', isSelected: true, height: '100px' }
+							]
+						] ) );
+
+						expect( command.value ).to.be.undefined;
+					} );
+
+					it( 'should be undefined if one of selected table cells has a different "height" property value', () => {
+						setData( model, modelTable( [
+							[
+								{ contents: '00', isSelected: true, height: '100px' },
+								{ contents: '01', isSelected: true, height: '23px' }
+							],
+							[
+								'10',
+								{ contents: '11', isSelected: true, height: '100px' }
+							]
+						] ) );
+
+						expect( command.value ).to.be.undefined;
+					} );
+
+					it( 'should be set if all table cell have the same "height" property value', () => {
+						setData( model, modelTable( [
+							[
+								{ contents: '00', isSelected: true, height: '100px' },
+								{ contents: '01', isSelected: true, height: '100px' }
+							],
+							[
+								'10',
+								{ contents: '11', isSelected: true, height: '100px' }
+							]
+						] ) );
+
+						expect( command.value ).to.equal( '100px' );
+					} );
+				} );
 			} );
 			} );
 
 
 			describe( 'execute()', () => {
 			describe( 'execute()', () => {
@@ -203,6 +277,38 @@ describe( 'table cell properties', () => {
 						assertTableCellStyle( editor, '' );
 						assertTableCellStyle( editor, '' );
 					} );
 					} );
 				} );
 				} );
+
+				describe( 'multi-cell selection', () => {
+					beforeEach( () => {
+						setData( model, modelTable( [
+							[ { contents: '00', isSelected: true }, '01' ],
+							[ '10', { contents: '11', isSelected: true } ]
+						] ) );
+					} );
+
+					it( 'should set the "height" attribute value of selected table cells', () => {
+						command.execute( { value: '100px' } );
+
+						assertEqualMarkup( editor.getData(), viewTable( [
+							[ { contents: '00', style: 'height:100px;' }, '01' ],
+							[ '10', { contents: '11', style: 'height:100px;' } ]
+						] ) );
+					} );
+
+					it( 'should remove "height" from selected table cells if no value is passed', () => {
+						setData( model, modelTable( [
+							[ { contents: '00', isSelected: true, height: '100px' }, '01' ],
+							[ '10', { contents: '11', isSelected: true, height: '100px' } ]
+						] ) );
+
+						command.execute();
+
+						assertEqualMarkup( editor.getData(), viewTable( [
+							[ '00', '01' ],
+							[ '10', '11' ]
+						] ) );
+					} );
+				} );
 			} );
 			} );
 		} );
 		} );
 	} );
 	} );

+ 107 - 1
packages/ckeditor5-table/tests/tablecellproperties/commands/tablecellhorizontalalignmentcommand.js

@@ -8,9 +8,10 @@ import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
 
 
 import { setData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
 import { setData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
 
 
-import { assertTableCellStyle, modelTable } from '../../_utils/utils';
+import { assertTableCellStyle, modelTable, viewTable } from '../../_utils/utils';
 import TableCellPropertiesEditing from '../../../src/tablecellproperties/tablecellpropertiesediting';
 import TableCellPropertiesEditing from '../../../src/tablecellproperties/tablecellpropertiesediting';
 import TableCellHorizontalAlignmentCommand from '../../../src/tablecellproperties/commands/tablecellhorizontalalignmentcommand';
 import TableCellHorizontalAlignmentCommand from '../../../src/tablecellproperties/commands/tablecellhorizontalalignmentcommand';
+import { assertEqualMarkup } from '@ckeditor/ckeditor5-utils/tests/_utils/utils';
 
 
 describe( 'table cell properties', () => {
 describe( 'table cell properties', () => {
 	describe( 'commands', () => {
 	describe( 'commands', () => {
@@ -54,6 +55,17 @@ describe( 'table cell properties', () => {
 						expect( command.isEnabled ).to.be.true;
 						expect( command.isEnabled ).to.be.true;
 					} );
 					} );
 				} );
 				} );
+
+				describe( 'multi-cell selection', () => {
+					it( 'should be true if the selection contains some table cells', () => {
+						setData( model, modelTable( [
+							[ { contents: '00', isSelected: true }, '01' ],
+							[ '10', { contents: '11', isSelected: true } ]
+						] ) );
+
+						expect( command.isEnabled ).to.be.true;
+					} );
+				} );
 			} );
 			} );
 
 
 			describe( 'value', () => {
 			describe( 'value', () => {
@@ -84,6 +96,68 @@ describe( 'table cell properties', () => {
 						expect( command.value ).to.equal( 'center' );
 						expect( command.value ).to.equal( 'center' );
 					} );
 					} );
 				} );
 				} );
+
+				describe( 'multi-cell selection', () => {
+					it( 'should be undefined if no table cells have the "horizontalAlignment" property', () => {
+						setData( model, modelTable( [
+							[
+								{ contents: '00', isSelected: true },
+								{ contents: '01', isSelected: true }
+							],
+							[
+								'10',
+								{ contents: '11', isSelected: true }
+							]
+						] ) );
+
+						expect( command.value ).to.be.undefined;
+					} );
+
+					it( 'should be undefined if only some table cells have the "horizontalAlignment" property', () => {
+						setData( model, modelTable( [
+							[
+								{ contents: '00', isSelected: true, horizontalAlignment: 'center' },
+								{ contents: '01', isSelected: true }
+							],
+							[
+								'10',
+								{ contents: '11', isSelected: true, horizontalAlignment: 'center' }
+							]
+						] ) );
+
+						expect( command.value ).to.be.undefined;
+					} );
+
+					it( 'should be undefined if one of selected table cells has a different "horizontalAlignment" property value', () => {
+						setData( model, modelTable( [
+							[
+								{ contents: '00', isSelected: true, horizontalAlignment: 'center' },
+								{ contents: '01', isSelected: true, horizontalAlignment: 'right' }
+							],
+							[
+								'10',
+								{ contents: '11', isSelected: true, horizontalAlignment: 'center' }
+							]
+						] ) );
+
+						expect( command.value ).to.be.undefined;
+					} );
+
+					it( 'should be set if all table cells have the same "horizontalAlignment" property value', () => {
+						setData( model, modelTable( [
+							[
+								{ contents: '00', isSelected: true, horizontalAlignment: 'center' },
+								{ contents: '01', isSelected: true, horizontalAlignment: 'center' }
+							],
+							[
+								'10',
+								{ contents: '11', isSelected: true, horizontalAlignment: 'center' }
+							]
+						] ) );
+
+						expect( command.value ).to.equal( 'center' );
+					} );
+				} );
 			} );
 			} );
 
 
 			describe( 'execute()', () => {
 			describe( 'execute()', () => {
@@ -147,6 +221,38 @@ describe( 'table cell properties', () => {
 						assertTableCellStyle( editor, '' );
 						assertTableCellStyle( editor, '' );
 					} );
 					} );
 				} );
 				} );
+
+				describe( 'multi-cell selection', () => {
+					beforeEach( () => {
+						setData( model, modelTable( [
+							[ { contents: '00', isSelected: true }, '01' ],
+							[ '10', { contents: '11', isSelected: true } ]
+						] ) );
+					} );
+
+					it( 'should set the "horizontalAlignment" attribute value of selected table cells', () => {
+						command.execute( { value: 'right' } );
+
+						assertEqualMarkup( editor.getData(), viewTable( [
+							[ { contents: '00', style: 'text-align:right;' }, '01' ],
+							[ '10', { contents: '11', style: 'text-align:right;' } ]
+						] ) );
+					} );
+
+					it( 'should remove the "horizontalAlignment" attribute from selected table cells if no value is passed', () => {
+						setData( model, modelTable( [
+							[ { contents: '00', isSelected: true, horizontalAlignment: 'right' }, '01' ],
+							[ '10', { contents: '11', isSelected: true, horizontalAlignment: 'right' } ]
+						] ) );
+
+						command.execute();
+
+						assertEqualMarkup( editor.getData(), viewTable( [
+							[ '00', '01' ],
+							[ '10', '11' ]
+						] ) );
+					} );
+				} );
 			} );
 			} );
 		} );
 		} );
 	} );
 	} );

+ 107 - 1
packages/ckeditor5-table/tests/tablecellproperties/commands/tablecellpaddingcommand.js

@@ -8,9 +8,10 @@ import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
 
 
 import { setData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
 import { setData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
 
 
-import { assertTableCellStyle, modelTable, setTableCellWithObjectAttributes } from '../../_utils/utils';
+import { assertTableCellStyle, modelTable, setTableCellWithObjectAttributes, viewTable } from '../../_utils/utils';
 import TableCellPropertiesEditing from '../../../src/tablecellproperties/tablecellpropertiesediting';
 import TableCellPropertiesEditing from '../../../src/tablecellproperties/tablecellpropertiesediting';
 import TableCellPaddingCommand from '../../../src/tablecellproperties/commands/tablecellpaddingcommand';
 import TableCellPaddingCommand from '../../../src/tablecellproperties/commands/tablecellpaddingcommand';
+import { assertEqualMarkup } from '@ckeditor/ckeditor5-utils/tests/_utils/utils';
 
 
 describe( 'table cell properties', () => {
 describe( 'table cell properties', () => {
 	describe( 'commands', () => {
 	describe( 'commands', () => {
@@ -54,6 +55,17 @@ describe( 'table cell properties', () => {
 						expect( command.isEnabled ).to.be.true;
 						expect( command.isEnabled ).to.be.true;
 					} );
 					} );
 				} );
 				} );
+
+				describe( 'multi-cell selection', () => {
+					it( 'should be true if the selection contains some table cells', () => {
+						setData( model, modelTable( [
+							[ { contents: '00', isSelected: true }, '01' ],
+							[ '10', { contents: '11', isSelected: true } ]
+						] ) );
+
+						expect( command.isEnabled ).to.be.true;
+					} );
+				} );
 			} );
 			} );
 
 
 			describe( 'value', () => {
 			describe( 'value', () => {
@@ -109,6 +121,68 @@ describe( 'table cell properties', () => {
 						expect( command.value ).to.equal( '2em' );
 						expect( command.value ).to.equal( '2em' );
 					} );
 					} );
 				} );
 				} );
+
+				describe( 'multi-cell selection', () => {
+					it( 'should be undefined if no table cells have the "padding" property', () => {
+						setData( model, modelTable( [
+							[
+								{ contents: '00', isSelected: true },
+								{ contents: '01', isSelected: true }
+							],
+							[
+								'10',
+								{ contents: '11', isSelected: true }
+							]
+						] ) );
+
+						expect( command.value ).to.be.undefined;
+					} );
+
+					it( 'should be undefined if only some table cells have the "padding" property', () => {
+						setData( model, modelTable( [
+							[
+								{ contents: '00', isSelected: true, padding: '2em' },
+								{ contents: '01', isSelected: true }
+							],
+							[
+								'10',
+								{ contents: '11', isSelected: true, padding: '2em' }
+							]
+						] ) );
+
+						expect( command.value ).to.be.undefined;
+					} );
+
+					it( 'should be undefined if one of selected table cells has a different "padding" property value', () => {
+						setData( model, modelTable( [
+							[
+								{ contents: '00', isSelected: true, padding: '2em' },
+								{ contents: '01', isSelected: true, padding: '3em' }
+							],
+							[
+								'10',
+								{ contents: '11', isSelected: true, padding: '2em' }
+							]
+						] ) );
+
+						expect( command.value ).to.be.undefined;
+					} );
+
+					it( 'should be set if all table cells have the same "padding" property value', () => {
+						setData( model, modelTable( [
+							[
+								{ contents: '00', isSelected: true, padding: '2em' },
+								{ contents: '01', isSelected: true, padding: '2em' }
+							],
+							[
+								'10',
+								{ contents: '11', isSelected: true, padding: '2em' }
+							]
+						] ) );
+
+						expect( command.value ).to.equal( '2em' );
+					} );
+				} );
 			} );
 			} );
 
 
 			describe( 'execute()', () => {
 			describe( 'execute()', () => {
@@ -228,6 +302,38 @@ describe( 'table cell properties', () => {
 						assertTableCellStyle( editor, '' );
 						assertTableCellStyle( editor, '' );
 					} );
 					} );
 				} );
 				} );
+
+				describe( 'multi-cell selection', () => {
+					beforeEach( () => {
+						setData( model, modelTable( [
+							[ { contents: '00', isSelected: true }, '01' ],
+							[ '10', { contents: '11', isSelected: true } ]
+						] ) );
+					} );
+
+					it( 'should set the "padding" attribute value of selected table cells', () => {
+						command.execute( { value: '25px' } );
+
+						assertEqualMarkup( editor.getData(), viewTable( [
+							[ { contents: '00', style: 'padding:25px;' }, '01' ],
+							[ '10', { contents: '11', style: 'padding:25px;' } ]
+						] ) );
+					} );
+
+					it( 'should remove "padding" from selected table cells if no value is passed', () => {
+						setData( model, modelTable( [
+							[ { contents: '00', isSelected: true, padding: '25px' }, '01' ],
+							[ '10', { contents: '11', isSelected: true, padding: '25px' } ]
+						] ) );
+
+						command.execute();
+
+						assertEqualMarkup( editor.getData(), viewTable( [
+							[ '00', '01' ],
+							[ '10', '11' ]
+						] ) );
+					} );
+				} );
 			} );
 			} );
 		} );
 		} );
 	} );
 	} );

+ 107 - 1
packages/ckeditor5-table/tests/tablecellproperties/commands/tablecellverticalalignmentcommand.js

@@ -8,9 +8,10 @@ import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
 
 
 import { setData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
 import { setData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
 
 
-import { assertTableCellStyle, modelTable } from '../../_utils/utils';
+import { assertTableCellStyle, modelTable, viewTable } from '../../_utils/utils';
 import TableCellPropertiesEditing from '../../../src/tablecellproperties/tablecellpropertiesediting';
 import TableCellPropertiesEditing from '../../../src/tablecellproperties/tablecellpropertiesediting';
 import TableCellVerticalAlignmentCommand from '../../../src/tablecellproperties/commands/tablecellverticalalignmentcommand';
 import TableCellVerticalAlignmentCommand from '../../../src/tablecellproperties/commands/tablecellverticalalignmentcommand';
+import { assertEqualMarkup } from '@ckeditor/ckeditor5-utils/tests/_utils/utils';
 
 
 describe( 'table cell properties', () => {
 describe( 'table cell properties', () => {
 	describe( 'commands', () => {
 	describe( 'commands', () => {
@@ -54,6 +55,17 @@ describe( 'table cell properties', () => {
 						expect( command.isEnabled ).to.be.true;
 						expect( command.isEnabled ).to.be.true;
 					} );
 					} );
 				} );
 				} );
+
+				describe( 'multi-cell selection', () => {
+					it( 'should be true if the selection contains some table cells', () => {
+						setData( model, modelTable( [
+							[ { contents: '00', isSelected: true }, '01' ],
+							[ '10', { contents: '11', isSelected: true } ]
+						] ) );
+
+						expect( command.isEnabled ).to.be.true;
+					} );
+				} );
 			} );
 			} );
 
 
 			describe( 'value', () => {
 			describe( 'value', () => {
@@ -84,6 +96,68 @@ describe( 'table cell properties', () => {
 						expect( command.value ).to.equal( 'bottom' );
 						expect( command.value ).to.equal( 'bottom' );
 					} );
 					} );
 				} );
 				} );
+
+				describe( 'multi-cell selection', () => {
+					it( 'should be undefined if no table cells have the "verticalAlignment" property', () => {
+						setData( model, modelTable( [
+							[
+								{ contents: '00', isSelected: true },
+								{ contents: '01', isSelected: true }
+							],
+							[
+								'10',
+								{ contents: '11', isSelected: true }
+							]
+						] ) );
+
+						expect( command.value ).to.be.undefined;
+					} );
+
+					it( 'should be undefined if only some table cells have the "verticalAlignment" property', () => {
+						setData( model, modelTable( [
+							[
+								{ contents: '00', isSelected: true, verticalAlignment: 'bottom' },
+								{ contents: '01', isSelected: true }
+							],
+							[
+								'10',
+								{ contents: '11', isSelected: true, verticalAlignment: 'bottom' }
+							]
+						] ) );
+
+						expect( command.value ).to.be.undefined;
+					} );
+
+					it( 'should be undefined if one of selected table cells has a different "verticalAlignment" property value', () => {
+						setData( model, modelTable( [
+							[
+								{ contents: '00', isSelected: true, verticalAlignment: 'bottom' },
+								{ contents: '01', isSelected: true, verticalAlignment: 'top' }
+							],
+							[
+								'10',
+								{ contents: '11', isSelected: true, verticalAlignment: 'bottom' }
+							]
+						] ) );
+
+						expect( command.value ).to.be.undefined;
+					} );
+
+					it( 'should be set if all table cells have the same "verticalAlignment" property value', () => {
+						setData( model, modelTable( [
+							[
+								{ contents: '00', isSelected: true, verticalAlignment: 'bottom' },
+								{ contents: '01', isSelected: true, verticalAlignment: 'bottom' }
+							],
+							[
+								'10',
+								{ contents: '11', isSelected: true, verticalAlignment: 'bottom' }
+							]
+						] ) );
+
+						expect( command.value ).to.equal( 'bottom' );
+					} );
+				} );
 			} );
 			} );
 
 
 			describe( 'execute()', () => {
 			describe( 'execute()', () => {
@@ -147,6 +221,38 @@ describe( 'table cell properties', () => {
 						assertTableCellStyle( editor, '' );
 						assertTableCellStyle( editor, '' );
 					} );
 					} );
 				} );
 				} );
+
+				describe( 'multi-cell selection', () => {
+					beforeEach( () => {
+						setData( model, modelTable( [
+							[ { contents: '00', isSelected: true }, '01' ],
+							[ '10', { contents: '11', isSelected: true } ]
+						] ) );
+					} );
+
+					it( 'should set the "verticalAlignment" attribute value of selected table cells', () => {
+						command.execute( { value: 'top' } );
+
+						assertEqualMarkup( editor.getData(), viewTable( [
+							[ { contents: '00', style: 'vertical-align:top;' }, '01' ],
+							[ '10', { contents: '11', style: 'vertical-align:top;' } ]
+						] ) );
+					} );
+
+					it( 'should remove "verticalAlignment" from selected table cells if no value is passed', () => {
+						setData( model, modelTable( [
+							[ { contents: '00', isSelected: true, verticalAlignment: 'top' }, '01' ],
+							[ '10', { contents: '11', isSelected: true, verticalAlignment: 'top' } ]
+						] ) );
+
+						command.execute();
+
+						assertEqualMarkup( editor.getData(), viewTable( [
+							[ '00', '01' ],
+							[ '10', '11' ]
+						] ) );
+					} );
+				} );
 			} );
 			} );
 		} );
 		} );
 	} );
 	} );

+ 107 - 1
packages/ckeditor5-table/tests/tablecellproperties/commands/tablecellwidthcommand.js

@@ -8,9 +8,10 @@ import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
 
 
 import { setData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
 import { setData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
 
 
-import { assertTableCellStyle, modelTable } from '../../_utils/utils';
+import { assertTableCellStyle, modelTable, viewTable } from '../../_utils/utils';
 import TableCellPropertiesEditing from '../../../src/tablecellproperties/tablecellpropertiesediting';
 import TableCellPropertiesEditing from '../../../src/tablecellproperties/tablecellpropertiesediting';
 import TableCellWidthCommand from '../../../src/tablecellproperties/commands/tablecellwidthcommand';
 import TableCellWidthCommand from '../../../src/tablecellproperties/commands/tablecellwidthcommand';
+import { assertEqualMarkup } from '@ckeditor/ckeditor5-utils/tests/_utils/utils';
 
 
 describe( 'table cell properties', () => {
 describe( 'table cell properties', () => {
 	describe( 'commands', () => {
 	describe( 'commands', () => {
@@ -54,6 +55,17 @@ describe( 'table cell properties', () => {
 						expect( command.isEnabled ).to.be.true;
 						expect( command.isEnabled ).to.be.true;
 					} );
 					} );
 				} );
 				} );
+
+				describe( 'multi-cell selection', () => {
+					it( 'should be true if the selection contains some table cells', () => {
+						setData( model, modelTable( [
+							[ { contents: '00', isSelected: true }, '01' ],
+							[ '10', { contents: '11', isSelected: true } ]
+						] ) );
+
+						expect( command.isEnabled ).to.be.true;
+					} );
+				} );
 			} );
 			} );
 
 
 			describe( 'value', () => {
 			describe( 'value', () => {
@@ -84,6 +96,68 @@ describe( 'table cell properties', () => {
 						expect( command.value ).to.equal( '100px' );
 						expect( command.value ).to.equal( '100px' );
 					} );
 					} );
 				} );
 				} );
+
+				describe( 'multi-cell selection', () => {
+					it( 'should be undefined if no table cells have the "width" property', () => {
+						setData( model, modelTable( [
+							[
+								{ contents: '00', isSelected: true },
+								{ contents: '01', isSelected: true }
+							],
+							[
+								'10',
+								{ contents: '11', isSelected: true }
+							]
+						] ) );
+
+						expect( command.value ).to.be.undefined;
+					} );
+
+					it( 'should be undefined if only some table cells have the "width" property', () => {
+						setData( model, modelTable( [
+							[
+								{ contents: '00', isSelected: true, width: '100px' },
+								{ contents: '01', isSelected: true }
+							],
+							[
+								'10',
+								{ contents: '11', isSelected: true, width: '100px' }
+							]
+						] ) );
+
+						expect( command.value ).to.be.undefined;
+					} );
+
+					it( 'should be undefined if one of selected table cells has a different "width" property value', () => {
+						setData( model, modelTable( [
+							[
+								{ contents: '00', isSelected: true, width: '100px' },
+								{ contents: '01', isSelected: true, width: '25px' }
+							],
+							[
+								'10',
+								{ contents: '11', isSelected: true, width: '100px' }
+							]
+						] ) );
+
+						expect( command.value ).to.be.undefined;
+					} );
+
+					it( 'should be set if all table cells have the same "width" property value', () => {
+						setData( model, modelTable( [
+							[
+								{ contents: '00', isSelected: true, width: '100px' },
+								{ contents: '01', isSelected: true, width: '100px' }
+							],
+							[
+								'10',
+								{ contents: '11', isSelected: true, width: '100px' }
+							]
+						] ) );
+
+						expect( command.value ).to.equal( '100px' );
+					} );
+				} );
 			} );
 			} );
 
 
 			describe( 'execute()', () => {
 			describe( 'execute()', () => {
@@ -203,6 +277,38 @@ describe( 'table cell properties', () => {
 						assertTableCellStyle( editor, '' );
 						assertTableCellStyle( editor, '' );
 					} );
 					} );
 				} );
 				} );
+
+				describe( 'multi-cell selection', () => {
+					beforeEach( () => {
+						setData( model, modelTable( [
+							[ { contents: '00', isSelected: true }, '01' ],
+							[ '10', { contents: '11', isSelected: true } ]
+						] ) );
+					} );
+
+					it( 'should set the "width" attribute value of selected table cells', () => {
+						command.execute( { value: '25px' } );
+
+						assertEqualMarkup( editor.getData(), viewTable( [
+							[ { contents: '00', style: 'width:25px;' }, '01' ],
+							[ '10', { contents: '11', style: 'width:25px;' } ]
+						] ) );
+					} );
+
+					it( 'should remove "width" from selected table cells if no value is passed', () => {
+						setData( model, modelTable( [
+							[ { contents: '00', isSelected: true, width: '25px' }, '01' ],
+							[ '10', { contents: '11', isSelected: true, width: '25px' } ]
+						] ) );
+
+						command.execute();
+
+						assertEqualMarkup( editor.getData(), viewTable( [
+							[ '00', '01' ],
+							[ '10', '11' ]
+						] ) );
+					} );
+				} );
 			} );
 			} );
 		} );
 		} );
 	} );
 	} );

+ 15 - 1
packages/ckeditor5-table/tests/tablecellproperties/tablecellpropertiesui.js

@@ -8,7 +8,7 @@
 import ClassicTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/classictesteditor';
 import ClassicTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/classictesteditor';
 import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
 import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
 import { keyCodes } from '@ckeditor/ckeditor5-utils/src/keyboard';
 import { keyCodes } from '@ckeditor/ckeditor5-utils/src/keyboard';
-import { getData as getModelData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
+import { getData as getModelData, setData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
 
 
 import Undo from '@ckeditor/ckeditor5-undo/src/undo';
 import Undo from '@ckeditor/ckeditor5-undo/src/undo';
 import Batch from '@ckeditor/ckeditor5-engine/src/model/batch';
 import Batch from '@ckeditor/ckeditor5-engine/src/model/batch';
@@ -21,6 +21,7 @@ import TableCellPropertiesEditing from '../../src/tablecellproperties/tablecellp
 import TableCellPropertiesUI from '../../src/tablecellproperties/tablecellpropertiesui';
 import TableCellPropertiesUI from '../../src/tablecellproperties/tablecellpropertiesui';
 import TableCellPropertiesUIView from '../../src/tablecellproperties/ui/tablecellpropertiesview';
 import TableCellPropertiesUIView from '../../src/tablecellproperties/ui/tablecellpropertiesview';
 import { defaultColors } from '../../src/ui/utils';
 import { defaultColors } from '../../src/ui/utils';
+import { modelTable } from '../_utils/utils';
 
 
 describe( 'table cell properties', () => {
 describe( 'table cell properties', () => {
 	describe( 'TableCellPropertiesUI', () => {
 	describe( 'TableCellPropertiesUI', () => {
@@ -529,6 +530,19 @@ describe( 'table cell properties', () => {
 				expect( firstBatch ).to.not.equal( secondBatch );
 				expect( firstBatch ).to.not.equal( secondBatch );
 			} );
 			} );
 
 
+			it( 'should show the ui for multi-cell selection', () => {
+				setData( editor.model, modelTable( [ [ '01', '02' ] ] ) );
+				editor.model.change( writer => {
+					writer.setSelection( [
+						writer.createRangeOn( editor.model.document.getRoot().getNodeByPath( [ 0, 0, 0 ] ) ),
+						writer.createRangeOn( editor.model.document.getRoot().getNodeByPath( [ 0, 0, 1 ] ) )
+					], 0 );
+				} );
+
+				tableCellPropertiesButton.fire( 'execute' );
+				expect( contextualBalloon.visibleView ).to.equal( tableCellPropertiesView );
+			} );
+
 			describe( 'initial data', () => {
 			describe( 'initial data', () => {
 				it( 'should be set from the command values', () => {
 				it( 'should be set from the command values', () => {
 					editor.commands.get( 'tableCellBorderStyle' ).value = 'a';
 					editor.commands.get( 'tableCellBorderStyle' ).value = 'a';

+ 108 - 80
packages/ckeditor5-table/tests/tableclipboard.js

@@ -5,14 +5,13 @@
 
 
 import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
 import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
 import VirtualTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/virtualtesteditor';
 import VirtualTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/virtualtesteditor';
-import { setData as setModelData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
+import { getData as getModelData, setData as setModelData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
 
 
 import TableEditing from '../src/tableediting';
 import TableEditing from '../src/tableediting';
 import { modelTable, viewTable } from './_utils/utils';
 import { modelTable, viewTable } from './_utils/utils';
 import Clipboard from '@ckeditor/ckeditor5-clipboard/src/clipboard';
 import Clipboard from '@ckeditor/ckeditor5-clipboard/src/clipboard';
-import ViewDocumentFragment from '@ckeditor/ckeditor5-engine/src/view/documentfragment';
-import { stringify as stringifyView } from '@ckeditor/ckeditor5-engine/src/dev-utils/view';
 import TableClipboard from '../src/tableclipboard';
 import TableClipboard from '../src/tableclipboard';
+import { assertEqualMarkup } from '@ckeditor/ckeditor5-utils/tests/_utils/utils';
 
 
 describe( 'table clipboard', () => {
 describe( 'table clipboard', () => {
 	let editor, model, modelRoot, tableSelection, viewDocument;
 	let editor, model, modelRoot, tableSelection, viewDocument;
@@ -40,7 +39,7 @@ describe( 'table clipboard', () => {
 
 
 	describe( 'Clipboard integration', () => {
 	describe( 'Clipboard integration', () => {
 		describe( 'copy', () => {
 		describe( 'copy', () => {
-			it( 'should to nothing for normal selection in table', () => {
+			it( 'should do nothing for normal selection in table', () => {
 				const dataTransferMock = createDataTransfer();
 				const dataTransferMock = createDataTransfer();
 				const spy = sinon.spy();
 				const spy = sinon.spy();
 
 
@@ -54,35 +53,26 @@ describe( 'table clipboard', () => {
 				sinon.assert.calledOnce( spy );
 				sinon.assert.calledOnce( spy );
 			} );
 			} );
 
 
-			it( 'should copy selected table cells as standalone table', done => {
-				const dataTransferMock = createDataTransfer();
+			it( 'should copy selected table cells as a standalone table', () => {
 				const preventDefaultSpy = sinon.spy();
 				const preventDefaultSpy = sinon.spy();
 
 
 				tableSelection.startSelectingFrom( modelRoot.getNodeByPath( [ 0, 0, 1 ] ) );
 				tableSelection.startSelectingFrom( modelRoot.getNodeByPath( [ 0, 0, 1 ] ) );
 				tableSelection.setSelectingTo( modelRoot.getNodeByPath( [ 0, 1, 2 ] ) );
 				tableSelection.setSelectingTo( modelRoot.getNodeByPath( [ 0, 1, 2 ] ) );
 
 
-				viewDocument.on( 'clipboardOutput', ( evt, data ) => {
-					expect( preventDefaultSpy.calledOnce ).to.be.true;
-					expect( data.method ).to.equal( 'copy' );
-
-					expect( data.dataTransfer ).to.equal( dataTransferMock );
-
-					expect( data.content ).is.instanceOf( ViewDocumentFragment );
-					expect( stringifyView( data.content ) ).to.equal( viewTable( [
-						[ '01', '02' ],
-						[ '11', '12' ]
-					] ) );
-
-					done();
-				} );
-
-				viewDocument.fire( 'copy', {
-					dataTransfer: dataTransferMock,
+				const data = {
+					dataTransfer: createDataTransfer(),
 					preventDefault: preventDefaultSpy
 					preventDefault: preventDefaultSpy
-				} );
+				};
+				viewDocument.fire( 'copy', data );
+
+				sinon.assert.calledOnce( preventDefaultSpy );
+				expect( data.dataTransfer.getData( 'text/html' ) ).to.equal( viewTable( [
+					[ '01', '02' ],
+					[ '11', '12' ]
+				] ) );
 			} );
 			} );
 
 
-			it( 'should trim selected table to a selection rectangle (inner cell with colspan, no colspan after trim)', done => {
+			it( 'should trim selected table to a selection rectangle (inner cell with colspan, no colspan after trim)', () => {
 				setModelData( model, modelTable( [
 				setModelData( model, modelTable( [
 					[ '00[]', '01', '02' ],
 					[ '00[]', '01', '02' ],
 					[ '10', { contents: '11', colspan: 2 } ],
 					[ '10', { contents: '11', colspan: 2 } ],
@@ -92,14 +82,14 @@ describe( 'table clipboard', () => {
 				tableSelection.startSelectingFrom( modelRoot.getNodeByPath( [ 0, 0, 0 ] ) );
 				tableSelection.startSelectingFrom( modelRoot.getNodeByPath( [ 0, 0, 0 ] ) );
 				tableSelection.setSelectingTo( modelRoot.getNodeByPath( [ 0, 2, 1 ] ) );
 				tableSelection.setSelectingTo( modelRoot.getNodeByPath( [ 0, 2, 1 ] ) );
 
 
-				assertClipboardCopy( viewTable( [
+				assertClipboardContentOnMethod( 'copy', viewTable( [
 					[ '00', '01' ],
 					[ '00', '01' ],
 					[ '10', '11' ],
 					[ '10', '11' ],
 					[ '20', '21' ]
 					[ '20', '21' ]
-				] ), done );
+				] ) );
 			} );
 			} );
 
 
-			it( 'should trim selected table to a selection rectangle (inner cell with colspan, has colspan after trim)', done => {
+			it( 'should trim selected table to a selection rectangle (inner cell with colspan, has colspan after trim)', () => {
 				setModelData( model, modelTable( [
 				setModelData( model, modelTable( [
 					[ '00[]', '01', '02' ],
 					[ '00[]', '01', '02' ],
 					[ { contents: '10', colspan: 3 } ],
 					[ { contents: '10', colspan: 3 } ],
@@ -109,14 +99,14 @@ describe( 'table clipboard', () => {
 				tableSelection.startSelectingFrom( modelRoot.getNodeByPath( [ 0, 0, 0 ] ) );
 				tableSelection.startSelectingFrom( modelRoot.getNodeByPath( [ 0, 0, 0 ] ) );
 				tableSelection.setSelectingTo( modelRoot.getNodeByPath( [ 0, 2, 1 ] ) );
 				tableSelection.setSelectingTo( modelRoot.getNodeByPath( [ 0, 2, 1 ] ) );
 
 
-				assertClipboardCopy( viewTable( [
+				assertClipboardContentOnMethod( 'copy', viewTable( [
 					[ '00', '01' ],
 					[ '00', '01' ],
 					[ { contents: '10', colspan: 2 } ],
 					[ { contents: '10', colspan: 2 } ],
 					[ '20', '21' ]
 					[ '20', '21' ]
-				] ), done );
+				] ) );
 			} );
 			} );
 
 
-			it( 'should trim selected table to a selection rectangle (inner cell with rowspan, no colspan after trim)', done => {
+			it( 'should trim selected table to a selection rectangle (inner cell with rowspan, no colspan after trim)', () => {
 				setModelData( model, modelTable( [
 				setModelData( model, modelTable( [
 					[ '00[]', '01', '02' ],
 					[ '00[]', '01', '02' ],
 					[ '10', { contents: '11', rowspan: 2 }, '12' ],
 					[ '10', { contents: '11', rowspan: 2 }, '12' ],
@@ -126,13 +116,13 @@ describe( 'table clipboard', () => {
 				tableSelection.startSelectingFrom( modelRoot.getNodeByPath( [ 0, 0, 0 ] ) );
 				tableSelection.startSelectingFrom( modelRoot.getNodeByPath( [ 0, 0, 0 ] ) );
 				tableSelection.setSelectingTo( modelRoot.getNodeByPath( [ 0, 1, 2 ] ) );
 				tableSelection.setSelectingTo( modelRoot.getNodeByPath( [ 0, 1, 2 ] ) );
 
 
-				assertClipboardCopy( viewTable( [
+				assertClipboardContentOnMethod( 'copy', viewTable( [
 					[ '00', '01', '02' ],
 					[ '00', '01', '02' ],
 					[ '10', '11', '12' ]
 					[ '10', '11', '12' ]
-				] ), done );
+				] ) );
 			} );
 			} );
 
 
-			it( 'should trim selected table to a selection rectangle (inner cell with rowspan, has rowspan after trim)', done => {
+			it( 'should trim selected table to a selection rectangle (inner cell with rowspan, has rowspan after trim)', () => {
 				setModelData( model, modelTable( [
 				setModelData( model, modelTable( [
 					[ '00[]', { contents: '01', rowspan: 3 }, '02' ],
 					[ '00[]', { contents: '01', rowspan: 3 }, '02' ],
 					[ '10', '12' ],
 					[ '10', '12' ],
@@ -142,13 +132,13 @@ describe( 'table clipboard', () => {
 				tableSelection.startSelectingFrom( modelRoot.getNodeByPath( [ 0, 0, 0 ] ) );
 				tableSelection.startSelectingFrom( modelRoot.getNodeByPath( [ 0, 0, 0 ] ) );
 				tableSelection.setSelectingTo( modelRoot.getNodeByPath( [ 0, 1, 1 ] ) );
 				tableSelection.setSelectingTo( modelRoot.getNodeByPath( [ 0, 1, 1 ] ) );
 
 
-				assertClipboardCopy( viewTable( [
+				assertClipboardContentOnMethod( 'copy', viewTable( [
 					[ '00', { contents: '01', rowspan: 2 }, '02' ],
 					[ '00', { contents: '01', rowspan: 2 }, '02' ],
 					[ '10', '12' ]
 					[ '10', '12' ]
-				] ), done );
+				] ) );
 			} );
 			} );
 
 
-			it( 'should prepend spanned columns with empty cells (outside cell with colspan)', done => {
+			it( 'should prepend spanned columns with empty cells (outside cell with colspan)', () => {
 				setModelData( model, modelTable( [
 				setModelData( model, modelTable( [
 					[ '00[]', '01', '02' ],
 					[ '00[]', '01', '02' ],
 					[ { contents: '10', colspan: 2 }, '12' ],
 					[ { contents: '10', colspan: 2 }, '12' ],
@@ -158,14 +148,14 @@ describe( 'table clipboard', () => {
 				tableSelection.startSelectingFrom( modelRoot.getNodeByPath( [ 0, 0, 1 ] ) );
 				tableSelection.startSelectingFrom( modelRoot.getNodeByPath( [ 0, 0, 1 ] ) );
 				tableSelection.setSelectingTo( modelRoot.getNodeByPath( [ 0, 2, 2 ] ) );
 				tableSelection.setSelectingTo( modelRoot.getNodeByPath( [ 0, 2, 2 ] ) );
 
 
-				assertClipboardCopy( viewTable( [
+				assertClipboardContentOnMethod( 'copy', viewTable( [
 					[ '01', '02' ],
 					[ '01', '02' ],
-					[ '', '12' ],
+					[ '&nbsp;', '12' ],
 					[ '21', '22' ]
 					[ '21', '22' ]
-				] ), done );
+				] ) );
 			} );
 			} );
 
 
-			it( 'should prepend spanned columns with empty cells (outside cell with rowspan)', done => {
+			it( 'should prepend spanned columns with empty cells (outside cell with rowspan)', () => {
 				setModelData( model, modelTable( [
 				setModelData( model, modelTable( [
 					[ '00[]', { contents: '01', rowspan: 2 }, '02' ],
 					[ '00[]', { contents: '01', rowspan: 2 }, '02' ],
 					[ '10', '12' ],
 					[ '10', '12' ],
@@ -175,13 +165,13 @@ describe( 'table clipboard', () => {
 				tableSelection.startSelectingFrom( modelRoot.getNodeByPath( [ 0, 1, 0 ] ) );
 				tableSelection.startSelectingFrom( modelRoot.getNodeByPath( [ 0, 1, 0 ] ) );
 				tableSelection.setSelectingTo( modelRoot.getNodeByPath( [ 0, 2, 2 ] ) );
 				tableSelection.setSelectingTo( modelRoot.getNodeByPath( [ 0, 2, 2 ] ) );
 
 
-				assertClipboardCopy( viewTable( [
-					[ '10', '', '12' ],
+				assertClipboardContentOnMethod( 'copy', viewTable( [
+					[ '10', '&nbsp;', '12' ],
 					[ '20', '21', '22' ]
 					[ '20', '21', '22' ]
-				] ), done );
+				] ) );
 			} );
 			} );
 
 
-			it( 'should fix selected table to a selection rectangle (hardcore case)', done => {
+			it( 'should fix selected table to a selection rectangle (hardcore case)', () => {
 				// This test check how previous simple rules run together (mixed prepending and trimming).
 				// This test check how previous simple rules run together (mixed prepending and trimming).
 				// In the example below a selection is set from cell "32" to "88"
 				// In the example below a selection is set from cell "32" to "88"
 				//
 				//
@@ -222,17 +212,17 @@ describe( 'table clipboard', () => {
 				tableSelection.startSelectingFrom( modelRoot.getNodeByPath( [ 0, 2, 1 ] ) );
 				tableSelection.startSelectingFrom( modelRoot.getNodeByPath( [ 0, 2, 1 ] ) );
 				tableSelection.setSelectingTo( modelRoot.getNodeByPath( [ 0, 7, 6 ] ) );
 				tableSelection.setSelectingTo( modelRoot.getNodeByPath( [ 0, 7, 6 ] ) );
 
 
-				assertClipboardCopy( viewTable( [
-					[ '21', '', '23', '', '', { contents: '27', colspan: 2 } ],
-					[ '31', '', '33', '', '', '37', '37' ],
-					[ '', '', '', '', '', '47', '47' ],
-					[ '51', '52', '53', '', '', { contents: '57', rowspan: 3 }, '57' ],
-					[ { contents: '61', colspan: 3 }, '', '', '', '67' ],
+				assertClipboardContentOnMethod( 'copy', viewTable( [
+					[ '21', '&nbsp;', '23', '&nbsp;', '&nbsp;', { contents: '27', colspan: 2 } ],
+					[ '31', '&nbsp;', '33', '&nbsp;', '&nbsp;', '37', '37' ],
+					[ '&nbsp;', '&nbsp;', '&nbsp;', '&nbsp;', '&nbsp;', '47', '47' ],
+					[ '51', '52', '53', '&nbsp;', '&nbsp;', { contents: '57', rowspan: 3 }, '57' ],
+					[ { contents: '61', colspan: 3 }, '&nbsp;', '&nbsp;', '&nbsp;', '67' ],
 					[ '71', '72', '73', '74', '75', '77' ]
 					[ '71', '72', '73', '74', '75', '77' ]
-				] ), done );
+				] ) );
 			} );
 			} );
 
 
-			it( 'should update table heading attributes (selection with headings)', done => {
+			it( 'should update table heading attributes (selection with headings)', () => {
 				setModelData( model, modelTable( [
 				setModelData( model, modelTable( [
 					[ '00', '01', '02', '03', '04' ],
 					[ '00', '01', '02', '03', '04' ],
 					[ '10', '11', '12', '13', '14' ],
 					[ '10', '11', '12', '13', '14' ],
@@ -244,14 +234,14 @@ describe( 'table clipboard', () => {
 				tableSelection.startSelectingFrom( modelRoot.getNodeByPath( [ 0, 1, 1 ] ) );
 				tableSelection.startSelectingFrom( modelRoot.getNodeByPath( [ 0, 1, 1 ] ) );
 				tableSelection.setSelectingTo( modelRoot.getNodeByPath( [ 0, 3, 3 ] ) );
 				tableSelection.setSelectingTo( modelRoot.getNodeByPath( [ 0, 3, 3 ] ) );
 
 
-				assertClipboardCopy( viewTable( [
+				assertClipboardContentOnMethod( 'copy', viewTable( [
 					[ '11', '12', '13' ],
 					[ '11', '12', '13' ],
 					[ '21', '22', '23' ],
 					[ '21', '22', '23' ],
 					[ { contents: '31', isHeading: true }, '32', '33' ] // TODO: bug in viewTable
 					[ { contents: '31', isHeading: true }, '32', '33' ] // TODO: bug in viewTable
-				], { headingRows: 2, headingColumns: 1 } ), done );
+				], { headingRows: 2, headingColumns: 1 } ) );
 			} );
 			} );
 
 
-			it( 'should update table heading attributes (selection without headings)', done => {
+			it( 'should update table heading attributes (selection without headings)', () => {
 				setModelData( model, modelTable( [
 				setModelData( model, modelTable( [
 					[ '00', '01', '02', '03', '04' ],
 					[ '00', '01', '02', '03', '04' ],
 					[ '10', '11', '12', '13', '14' ],
 					[ '10', '11', '12', '13', '14' ],
@@ -263,60 +253,98 @@ describe( 'table clipboard', () => {
 				tableSelection.startSelectingFrom( modelRoot.getNodeByPath( [ 0, 3, 2 ] ) );
 				tableSelection.startSelectingFrom( modelRoot.getNodeByPath( [ 0, 3, 2 ] ) );
 				tableSelection.setSelectingTo( modelRoot.getNodeByPath( [ 0, 4, 4 ] ) );
 				tableSelection.setSelectingTo( modelRoot.getNodeByPath( [ 0, 4, 4 ] ) );
 
 
-				assertClipboardCopy( viewTable( [
+				assertClipboardContentOnMethod( 'copy', viewTable( [
 					[ '32', '33', '34' ],
 					[ '32', '33', '34' ],
 					[ '42', '43', '44' ]
 					[ '42', '43', '44' ]
-				] ), done );
+				] ) );
 			} );
 			} );
 		} );
 		} );
 
 
 		describe( 'cut', () => {
 		describe( 'cut', () => {
-			it( 'is disabled for multi-range selection over a table', () => {
+			it( 'should not block clipboardOutput if no multi-cell selection', () => {
+				setModelData( model, modelTable( [
+					[ '[00]', '01', '02' ],
+					[ '10', '11', '12' ],
+					[ '20', '21', '22' ]
+				] ) );
+
 				const dataTransferMock = createDataTransfer();
 				const dataTransferMock = createDataTransfer();
-				const preventDefaultSpy = sinon.spy();
-				const spy = sinon.spy();
 
 
-				viewDocument.on( 'clipboardOutput', spy );
+				viewDocument.fire( 'cut', {
+					dataTransfer: dataTransferMock,
+					preventDefault: sinon.spy()
+				} );
 
 
-				tableSelection.startSelectingFrom( modelRoot.getNodeByPath( [ 0, 0, 1 ] ) );
-				tableSelection.setSelectingTo( modelRoot.getNodeByPath( [ 0, 1, 2 ] ) );
+				expect( dataTransferMock.getData( 'text/html' ) ).to.equal( '00' );
+			} );
+
+			it( 'should be preventable', () => {
+				tableSelection.startSelectingFrom( modelRoot.getNodeByPath( [ 0, 0, 0 ] ) );
+				tableSelection.setSelectingTo( modelRoot.getNodeByPath( [ 0, 1, 1 ] ) );
+
+				viewDocument.on( 'clipboardOutput', evt => evt.stop(), { priority: 'high' } );
 
 
 				viewDocument.fire( 'cut', {
 				viewDocument.fire( 'cut', {
-					dataTransfer: dataTransferMock,
-					preventDefault: preventDefaultSpy
+					dataTransfer: createDataTransfer(),
+					preventDefault: sinon.spy()
 				} );
 				} );
 
 
-				sinon.assert.notCalled( spy );
-				sinon.assert.calledOnce( preventDefaultSpy );
+				assertEqualMarkup( getModelData( model ), modelTable( [
+					[ { contents: '00', isSelected: true }, { contents: '01', isSelected: true }, '02' ],
+					[ { contents: '10', isSelected: true }, { contents: '11', isSelected: true }, '12' ],
+					[ '20', '21', '22' ]
+				] ) );
 			} );
 			} );
 
 
-			it( 'is not disabled normal selection over a table', () => {
-				const dataTransferMock = createDataTransfer();
+			it( 'is clears selected table cells', () => {
 				const spy = sinon.spy();
 				const spy = sinon.spy();
 
 
 				viewDocument.on( 'clipboardOutput', spy );
 				viewDocument.on( 'clipboardOutput', spy );
 
 
+				tableSelection.startSelectingFrom( modelRoot.getNodeByPath( [ 0, 0, 0 ] ) );
+				tableSelection.setSelectingTo( modelRoot.getNodeByPath( [ 0, 1, 1 ] ) );
+
 				viewDocument.fire( 'cut', {
 				viewDocument.fire( 'cut', {
-					dataTransfer: dataTransferMock,
+					dataTransfer: createDataTransfer(),
 					preventDefault: sinon.spy()
 					preventDefault: sinon.spy()
 				} );
 				} );
 
 
-				sinon.assert.calledOnce( spy );
+				assertEqualMarkup( getModelData( model ), modelTable( [
+					[ '', '', '02' ],
+					[ '', '[]', '12' ],
+					[ '20', '21', '22' ]
+				] ) );
 			} );
 			} );
-		} );
-	} );
 
 
-	function assertClipboardCopy( expectedViewTable, callback ) {
-		viewDocument.on( 'clipboardOutput', ( evt, data ) => {
-			expect( stringifyView( data.content ) ).to.equal( expectedViewTable );
+			it( 'should copy selected table cells as a standalone table', () => {
+				const preventDefaultSpy = sinon.spy();
+
+				tableSelection.startSelectingFrom( modelRoot.getNodeByPath( [ 0, 0, 1 ] ) );
+				tableSelection.setSelectingTo( modelRoot.getNodeByPath( [ 0, 1, 2 ] ) );
+
+				const data = {
+					dataTransfer: createDataTransfer(),
+					preventDefault: preventDefaultSpy
+				};
+				viewDocument.fire( 'cut', data );
 
 
-			callback();
+				sinon.assert.calledOnce( preventDefaultSpy );
+				expect( data.dataTransfer.getData( 'text/html' ) ).to.equal( viewTable( [
+					[ '01', '02' ],
+					[ '11', '12' ]
+				] ) );
+			} );
 		} );
 		} );
+	} );
 
 
-		viewDocument.fire( 'copy', {
+	function assertClipboardContentOnMethod( method, expectedViewTable ) {
+		const data = {
 			dataTransfer: createDataTransfer(),
 			dataTransfer: createDataTransfer(),
 			preventDefault: sinon.spy()
 			preventDefault: sinon.spy()
-		} );
+		};
+		viewDocument.fire( method, data );
+
+		expect( data.dataTransfer.getData( 'text/html' ) ).to.equal( expectedViewTable );
 	}
 	}
 
 
 	function createDataTransfer() {
 	function createDataTransfer() {

+ 173 - 0
packages/ckeditor5-table/tests/tableselection-integration.js

@@ -0,0 +1,173 @@
+/**
+ * @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
+ */
+
+/* globals document */
+
+import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
+import { getData as getModelData, setData as setModelData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
+
+import TableEditing from '../src/tableediting';
+import TableSelection from '../src/tableselection';
+import { modelTable } from './_utils/utils';
+import { assertEqualMarkup } from '@ckeditor/ckeditor5-utils/tests/_utils/utils';
+import DomEventData from '@ckeditor/ckeditor5-engine/src/view/observer/domeventdata';
+import Delete from '@ckeditor/ckeditor5-typing/src/delete';
+import ClassicTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/classictesteditor';
+import { getCode } from '@ckeditor/ckeditor5-utils/src/keyboard';
+import Input from '@ckeditor/ckeditor5-typing/src/input';
+import ViewText from '@ckeditor/ckeditor5-engine/src/view/text';
+
+describe( 'table selection', () => {
+	let editor, model, tableSelection, modelRoot, element, viewDocument;
+
+	describe( 'TableSelection - input integration', () => {
+		afterEach( async () => {
+			element.remove();
+			await editor.destroy();
+		} );
+
+		describe( 'on delete', () => {
+			beforeEach( async () => {
+				await setupEditor( [ Delete ] );
+			} );
+
+			it( 'should clear contents of the selected table cells and put selection in last cell on backward delete', () => {
+				tableSelection.startSelectingFrom( modelRoot.getNodeByPath( [ 0, 0, 0 ] ) );
+				tableSelection.setSelectingTo( modelRoot.getNodeByPath( [ 0, 1, 1 ] ) );
+
+				const domEventData = new DomEventData( viewDocument, {
+					preventDefault: sinon.spy()
+				}, {
+					direction: 'backward',
+					unit: 'character',
+					sequence: 1
+				} );
+				viewDocument.fire( 'delete', domEventData );
+
+				assertEqualMarkup( getModelData( model ), modelTable( [
+					[ '', '', '13' ],
+					[ '', '[]', '23' ],
+					[ '31', '32', '33' ]
+				] ) );
+			} );
+
+			it( 'should clear contents of the selected table cells and put selection in last cell on forward delete', () => {
+				tableSelection.startSelectingFrom( modelRoot.getNodeByPath( [ 0, 0, 0 ] ) );
+				tableSelection.setSelectingTo( modelRoot.getNodeByPath( [ 0, 1, 1 ] ) );
+
+				const domEventData = new DomEventData( viewDocument, {
+					preventDefault: sinon.spy()
+				}, {
+					direction: 'forward',
+					unit: 'character',
+					sequence: 1
+				} );
+				viewDocument.fire( 'delete', domEventData );
+
+				assertEqualMarkup( getModelData( model ), modelTable( [
+					[ '[]', '', '13' ],
+					[ '', '', '23' ],
+					[ '31', '32', '33' ]
+				] ) );
+			} );
+
+			it( 'should not interfere with default key handler if no table selection', () => {
+				setModelData( model, modelTable( [
+					[ '11[]', '12', '13' ],
+					[ '21', '22', '23' ],
+					[ '31', '32', '33' ]
+				] ) );
+
+				const domEventData = new DomEventData( viewDocument, {
+					preventDefault: sinon.spy()
+				}, {
+					direction: 'backward',
+					unit: 'character',
+					sequence: 1
+				} );
+				viewDocument.fire( 'delete', domEventData );
+
+				assertEqualMarkup( getModelData( model ), modelTable( [
+					[ '1[]', '12', '13' ],
+					[ '21', '22', '23' ],
+					[ '31', '32', '33' ]
+				] ) );
+			} );
+		} );
+
+		describe( 'on user input', () => {
+			beforeEach( async () => {
+				await setupEditor( [ Input ] );
+			} );
+
+			it( 'should clear contents of the selected table cells and put selection in last cell on user input', () => {
+				tableSelection.startSelectingFrom( modelRoot.getNodeByPath( [ 0, 0, 0 ] ) );
+				tableSelection.setSelectingTo( modelRoot.getNodeByPath( [ 0, 1, 1 ] ) );
+
+				viewDocument.fire( 'keydown', { keyCode: getCode( 'x' ) } );
+
+				//                                      figure       table         tbody         tr            td            span
+				const viewSpan = viewDocument.getRoot().getChild( 0 ).getChild( 1 ).getChild( 0 ).getChild( 1 ).getChild( 1 ).getChild( 0 );
+
+				viewDocument.fire( 'mutations', [
+					{
+						type: 'children',
+						oldChildren: [],
+						newChildren: [ new ViewText( viewDocument, 'x' ) ],
+						node: viewSpan
+					}
+				] );
+
+				assertEqualMarkup( getModelData( model ), modelTable( [
+					[ '', '', '13' ],
+					[ '', 'x[]', '23' ],
+					[ '31', '32', '33' ]
+				] ) );
+			} );
+
+			it( 'should not interfere with default key handler if no table selection', () => {
+				viewDocument.fire( 'keydown', { keyCode: getCode( 'x' ) } );
+
+				//                                      figure       table         tbody         tr            td            span
+				const viewSpan = viewDocument.getRoot().getChild( 0 ).getChild( 1 ).getChild( 0 ).getChild( 0 ).getChild( 0 ).getChild( 0 );
+
+				viewDocument.fire( 'mutations', [
+					{
+						type: 'children',
+						oldChildren: [],
+						newChildren: [ new ViewText( viewDocument, 'x' ) ],
+						node: viewSpan
+					}
+				] );
+
+				assertEqualMarkup( getModelData( model ), modelTable( [
+					[ 'x[]11', '12', '13' ],
+					[ '21', '22', '23' ],
+					[ '31', '32', '33' ]
+				] ) );
+			} );
+		} );
+	} );
+
+	async function setupEditor( plugins ) {
+		element = document.createElement( 'div' );
+		document.body.appendChild( element );
+
+		editor = await ClassicTestEditor.create( element, {
+			plugins: [ TableEditing, TableSelection, Paragraph, ...plugins ]
+		} );
+
+		model = editor.model;
+		modelRoot = model.document.getRoot();
+		viewDocument = editor.editing.view.document;
+		tableSelection = editor.plugins.get( TableSelection );
+
+		setModelData( model, modelTable( [
+			[ '[]11', '12', '13' ],
+			[ '21', '22', '23' ],
+			[ '31', '32', '33' ]
+		] ) );
+	}
+} );

+ 42 - 2
packages/ckeditor5-table/tests/tableselection/mouseselectionhandler.js

@@ -12,10 +12,13 @@ import { assertEqualMarkup } from '@ckeditor/ckeditor5-utils/tests/_utils/utils'
 import TableEditing from '../../src/tableediting';
 import TableEditing from '../../src/tableediting';
 import TableSelection from '../../src/tableselection';
 import TableSelection from '../../src/tableselection';
 import { assertSelectedCells, modelTable, viewTable } from '../_utils/utils';
 import { assertSelectedCells, modelTable, viewTable } from '../_utils/utils';
+import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
 
 
 describe( 'table selection', () => {
 describe( 'table selection', () => {
 	let editor, model, view, viewDoc;
 	let editor, model, view, viewDoc;
 
 
+	testUtils.createSinonSandbox();
+
 	beforeEach( async () => {
 	beforeEach( async () => {
 		editor = await VirtualTestEditor.create( {
 		editor = await VirtualTestEditor.create( {
 			plugins: [ TableEditing, TableSelection, Paragraph ]
 			plugins: [ TableEditing, TableSelection, Paragraph ]
@@ -418,6 +421,41 @@ describe( 'table selection', () => {
 				[ '10', '11' ]
 				[ '10', '11' ]
 			], { asWidget: true } ) + '<p>{}foo</p>' );
 			], { asWidget: true } ) + '<p>{}foo</p>' );
 		} );
 		} );
+
+		// https://github.com/ckeditor/ckeditor5/issues/6353
+		it( 'should do nothing on successive "mouseup" events beyond the table after the selection was fininished', () => {
+			const spy = testUtils.sinon.spy( editor.plugins.get( 'TableSelection' ), 'stopSelection' );
+
+			setModelData( model, modelTable( [
+				[ '[]00', '01' ],
+				[ '10', '11' ]
+			] ) );
+
+			pressMouseButtonOver( getTableCell( '00' ) );
+			movePressedMouseOver( getTableCell( '11' ) );
+			releaseMouseButtonOver( getTableCell( '11' ) );
+
+			sinon.assert.calledOnce( spy );
+
+			pressMouseButtonOver( viewDoc.getRoot() );
+			releaseMouseButtonOver( viewDoc.getRoot() );
+
+			sinon.assert.calledOnce( spy );
+		} );
+
+		// https://github.com/ckeditor/ckeditor5/issues/6114
+		it( 'should prevent default the "mousemove" event to prevent the native DOM selection from changing', () => {
+			setModelData( model, modelTable( [
+				[ '[]00', '01' ],
+				[ '10', '11' ]
+			] ) );
+
+			pressMouseButtonOver( getTableCell( '00' ) );
+			const domEvtData = movePressedMouseOver( getTableCell( '11' ) );
+			releaseMouseButtonOver( getTableCell( '11' ) );
+
+			sinon.assert.calledOnce( domEvtData.preventDefault );
+		} );
 	} );
 	} );
 
 
 	function getTableCell( data ) {
 	function getTableCell( data ) {
@@ -437,7 +475,7 @@ describe( 'table selection', () => {
 	}
 	}
 
 
 	function movePressedMouseOver( target ) {
 	function movePressedMouseOver( target ) {
-		moveMouseOver( target, mouseButtonPressed );
+		return moveMouseOver( target, mouseButtonPressed );
 	}
 	}
 
 
 	function moveReleasedMouseOver( target ) {
 	function moveReleasedMouseOver( target ) {
@@ -445,7 +483,7 @@ describe( 'table selection', () => {
 	}
 	}
 
 
 	function moveMouseOver( target, ...decorators ) {
 	function moveMouseOver( target, ...decorators ) {
-		fireEvent( view, 'mousemove', addTarget( target ), ...decorators );
+		return fireEvent( view, 'mousemove', addTarget( target ), ...decorators );
 	}
 	}
 
 
 	function releaseMouseButtonOver( target ) {
 	function releaseMouseButtonOver( target ) {
@@ -481,5 +519,7 @@ describe( 'table selection', () => {
 		}
 		}
 
 
 		viewDoc.fire( eventName, domEvtDataStub );
 		viewDoc.fire( eventName, domEvtDataStub );
+
+		return domEvtDataStub;
 	}
 	}
 } );
 } );

+ 1 - 1
packages/ckeditor5-table/theme/table.css

@@ -26,7 +26,7 @@
 		& th {
 		& th {
 			min-width: 2em;
 			min-width: 2em;
 			padding: .4em;
 			padding: .4em;
-			border-color: hsl(0, 0%, 85%);
+			border-color: hsl(0, 0%, 75%);
 		}
 		}
 
 
 		& th {
 		& th {

+ 0 - 7
packages/ckeditor5-table/theme/tableselection.css

@@ -8,10 +8,3 @@
  * it acts as a message to the builder telling that it should look for the corresponding styles
  * it acts as a message to the builder telling that it should look for the corresponding styles
  * **in the theme** when compiling the editor.
  * **in the theme** when compiling the editor.
  */
  */
-
-.ck.ck-editor__editable .table table {
-	& td.ck-editor__editable_selected,
-	& th.ck-editor__editable_selected {
-		box-shadow: inset 0 0 0 1px var(--ck-color-focus-border);
-	}
-}