Explorar el Código

Merge pull request #208 from ckeditor/t/207

Change execute( forceValue ) to execute( options )
Szymon Cofalik hace 6 años
padre
commit
989ab734a0

+ 5 - 4
packages/ckeditor5-table/src/commands/setheadercolumncommand.js

@@ -61,10 +61,11 @@ export default class SetHeaderColumnCommand extends Command {
 	 * When the selection is already in a header column, it will set `headingColumns` so the heading section will end before that column.
 	 * When the selection is already in a header column, it will set `headingColumns` so the heading section will end before that column.
 	 *
 	 *
 	 * @fires execute
 	 * @fires execute
-	 * @params {Boolean} [forceValue] If set, the command will set (`true`) or unset (`false`) header columns according to `forceValue`
-	 * parameter instead of the current model state.
+	 * @param {Object} [options]
+	 * @param {Boolean} [options.forceValue] If set, the command will set (`true`) or unset (`false`) header columns according to
+	 * `forceValue` parameter instead of the current model state.
 	 */
 	 */
-	execute( forceValue = null ) {
+	execute( options = {} ) {
 		const model = this.editor.model;
 		const model = this.editor.model;
 		const doc = model.document;
 		const doc = model.document;
 		const selection = doc.selection;
 		const selection = doc.selection;
@@ -77,7 +78,7 @@ export default class SetHeaderColumnCommand extends Command {
 
 
 		const { column: selectionColumn } = tableUtils.getCellLocation( tableCell );
 		const { column: selectionColumn } = tableUtils.getCellLocation( tableCell );
 
 
-		if ( forceValue === this.value ) {
+		if ( options.forceValue === this.value ) {
 			return;
 			return;
 		}
 		}
 
 

+ 4 - 3
packages/ckeditor5-table/src/commands/setheaderrowcommand.js

@@ -60,10 +60,11 @@ export default class SetHeaderRowCommand extends Command {
 	 * When the selection is already in a header row, it will set `headingRows` so the heading section will end before that row.
 	 * When the selection is already in a header row, it will set `headingRows` so the heading section will end before that row.
 	 *
 	 *
 	 * @fires execute
 	 * @fires execute
-	 * @params {Boolean} [forceValue] If set, the command will set (`true`) or unset (`false`) header rows according to `forceValue`
+	 * @param {Object} options
+	 * @param {Boolean} [options.forceValue] If set, the command will set (`true`) or unset (`false`) header rows according to `forceValue`
 	 * parameter instead of the current model state.
 	 * parameter instead of the current model state.
 	 */
 	 */
-	execute( forceValue = null ) {
+	execute( options = {} ) {
 		const model = this.editor.model;
 		const model = this.editor.model;
 		const doc = model.document;
 		const doc = model.document;
 		const selection = doc.selection;
 		const selection = doc.selection;
@@ -76,7 +77,7 @@ export default class SetHeaderRowCommand extends Command {
 		const currentHeadingRows = table.getAttribute( 'headingRows' ) || 0;
 		const currentHeadingRows = table.getAttribute( 'headingRows' ) || 0;
 		const selectionRow = tableRow.index;
 		const selectionRow = tableRow.index;
 
 
-		if ( forceValue === this.value ) {
+		if ( options.forceValue === this.value ) {
 			return;
 			return;
 		}
 		}
 
 

+ 2 - 2
packages/ckeditor5-table/tests/commands/setheadercolumncommand.js

@@ -121,7 +121,7 @@ describe( 'SetHeaderColumnCommand', () => {
 				[ '00', '01[]', '02', '03' ]
 				[ '00', '01[]', '02', '03' ]
 			], { headingColumns: 3 } ) );
 			], { headingColumns: 3 } ) );
 
 
-			command.execute( true );
+			command.execute( { forceValue: true } );
 
 
 			expect( formatTable( getData( model ) ) ).to.equal( formattedModelTable( [
 			expect( formatTable( getData( model ) ) ).to.equal( formattedModelTable( [
 				[ '00', '01[]', '02', '03' ]
 				[ '00', '01[]', '02', '03' ]
@@ -133,7 +133,7 @@ describe( 'SetHeaderColumnCommand', () => {
 				[ '00', '01[]', '02', '03' ]
 				[ '00', '01[]', '02', '03' ]
 			], { headingColumns: 1 } ) );
 			], { headingColumns: 1 } ) );
 
 
-			command.execute( false );
+			command.execute( { forceValue: false } );
 
 
 			expect( formatTable( getData( model ) ) ).to.equal( formattedModelTable( [
 			expect( formatTable( getData( model ) ) ).to.equal( formattedModelTable( [
 				[ '00', '01[]', '02', '03' ]
 				[ '00', '01[]', '02', '03' ]

+ 2 - 2
packages/ckeditor5-table/tests/commands/setheaderrowcommand.js

@@ -171,7 +171,7 @@ describe( 'SetHeaderRowCommand', () => {
 				[ '30' ]
 				[ '30' ]
 			], { headingRows: 3 } ) );
 			], { headingRows: 3 } ) );
 
 
-			command.execute( true );
+			command.execute( { forceValue: true } );
 
 
 			expect( formatTable( getData( model ) ) ).to.equal( formattedModelTable( [
 			expect( formatTable( getData( model ) ) ).to.equal( formattedModelTable( [
 				[ '00' ],
 				[ '00' ],
@@ -189,7 +189,7 @@ describe( 'SetHeaderRowCommand', () => {
 				[ '30' ]
 				[ '30' ]
 			], { headingRows: 1 } ) );
 			], { headingRows: 1 } ) );
 
 
-			command.execute( false );
+			command.execute( { forceValue: false } );
 
 
 			expect( formatTable( getData( model ) ) ).to.equal( formattedModelTable( [
 			expect( formatTable( getData( model ) ) ).to.equal( formattedModelTable( [
 				[ '00' ],
 				[ '00' ],