浏览代码

Table commands should operate on single table.

Maciej Gołaszewski 5 年之前
父节点
当前提交
63507aeff1

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

@@ -51,7 +51,7 @@ export default class TableCellPropertyCommand extends Command {
 	 * @param {Object} [options]
 	 * @param {*} [options.value] If set the command will set the attribute on selected table cells.
 	 * If it is not set the command will remove the attribute from selected table cells.
-	 * @param {module:engine/model/batch~Batch} [options.batch]
+	 * @param {module:engine/model/batch~Batch} [options.batch] Pass batch instance to the command for creating single undo step.
 	 */
 	execute( options = {} ) {
 		const model = this.editor.model;

+ 6 - 5
packages/ckeditor5-table/src/tableproperties/commands/tablepropertycommand.js

@@ -49,7 +49,9 @@ export default class TablePropertyCommand extends Command {
 	 *
 	 * @fires execute
 	 * @param {Object} [options]
-	 * @param {Boolean} [options.value] If set the command will set width. If width is not set the command will remove the attribute.
+	 * @param {*} [options.value] If set the command will set the attribute on selected table.
+	 * If it is not set the command will remove the attribute from selected table.
+	 * @param {module:engine/model/batch~Batch} [options.batch] Pass batch instance to the command for creating single undo step.
 	 */
 	execute( options = {} ) {
 		const model = this.editor.model;
@@ -57,14 +59,13 @@ export default class TablePropertyCommand extends Command {
 
 		const { value, batch } = options;
 
-		const tables = Array.from( selection.getSelectedBlocks() )
-			.map( element => findAncestor( 'table', model.createPositionAt( element, 0 ) ) );
+		const table = findAncestor( 'table', selection.getFirstPosition() );
 
 		model.enqueueChange( batch || 'default', writer => {
 			if ( value ) {
-				tables.forEach( table => writer.setAttribute( this.attributeName, value, table ) );
+				writer.setAttribute( this.attributeName, value, table );
 			} else {
-				tables.forEach( table => writer.removeAttribute( this.attributeName, table ) );
+				writer.removeAttribute( this.attributeName, table );
 			}
 		} );
 	}