Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Renamed insertTableColumnBefore and insertTableColumnAfter commands t…
Browse files Browse the repository at this point in the history
…o insertTableColumnLeft and insertTableColumnRight.
  • Loading branch information
oleq committed Oct 30, 2018
1 parent 103434e commit 12abab5
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 35 deletions.
4 changes: 2 additions & 2 deletions docs/features/table.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ The {@link module:table/table~Table} plugin registers the following UI component
And the following commands:

* The `'insertTable'` command implemented by {@link module:table/commands/inserttablecommand~InsertTableCommand}.
* The `'insertTableColumnBefore'` command implemented by {@link module:table/commands/insertcolumncommand~InsertColumnCommand}.
* The `'insertTableColumnAfter'` command implemented by {@link module:table/commands/insertcolumncommand~InsertColumnCommand}.
* The `'insertTableColumnLeft'` command implemented by {@link module:table/commands/insertcolumncommand~InsertColumnCommand}.
* The `'insertTableColumnRight'` command implemented by {@link module:table/commands/insertcolumncommand~InsertColumnCommand}.
* The `'insertTableRowAbove'` command implemented by {@link module:table/commands/insertrowcommand~InsertRowCommand}.
* The `'insertTableRowBelow'` command implemented by {@link module:table/commands/insertrowcommand~InsertRowCommand}.
* The `'removeTableColumn'` command implemented by {@link module:table/commands/removecolumncommand~RemoveColumnCommand}.
Expand Down
24 changes: 12 additions & 12 deletions src/commands/insertcolumncommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ import TableUtils from '../tableutils';
/**
* The insert column command.
*
* The command is registered by {@link module:table/tableediting~TableEditing} as `'insertTableColumnBefore'` and
* `'insertTableColumnAfter'` editor commands.
* The command is registered by {@link module:table/tableediting~TableEditing} as `'insertTableColumnLeft'` and
* `'insertTableColumnRight'` editor commands.
*
* To insert a column before the selected cell, execute the following command:
* To insert a column to the left of the selected cell, execute the following command:
*
* editor.execute( 'insertTableColumnBefore' );
* editor.execute( 'insertTableColumnLeft' );
*
* To insert a column after the selected cell, execute the following command:
* To insert a column to the right of the selected cell, execute the following command:
*
* editor.execute( 'insertTableColumnAfter' );
* editor.execute( 'insertTableColumnRight' );
*
* @extends module:core/command~Command
*/
Expand All @@ -33,8 +33,8 @@ export default class InsertColumnCommand extends Command {
*
* @param {module:core/editor/editor~Editor} editor An editor on which this command will be used.
* @param {Object} options
* @param {String} [options.order="after"] The order of insertion relative to the column in which the caret is located.
* Possible values: `"after"` and `"before"`.
* @param {String} [options.order="right"] The order of insertion relative to the column in which the caret is located.
* Possible values: `"left"` and `"right"`.
*/
constructor( editor, options = {} ) {
super( editor );
Expand All @@ -45,7 +45,7 @@ export default class InsertColumnCommand extends Command {
* @readonly
* @member {String} module:table/commands/insertcolumncommand~InsertColumnCommand#order
*/
this.order = options.order || 'after';
this.order = options.order || 'right';
}

/**
Expand All @@ -62,8 +62,8 @@ export default class InsertColumnCommand extends Command {
/**
* Executes the command.
*
* Depending on the command's {@link #order} value, it inserts a column `'before'` or `'after'` the column in which the selection is
* set.
* Depending on the command's {@link #order} value, it inserts a column to the `'left'` or `'right'` of the column
* in which the selection is set.
*
* @fires execute
*/
Expand All @@ -78,7 +78,7 @@ export default class InsertColumnCommand extends Command {
const table = tableCell.parent.parent;

const { column } = tableUtils.getCellLocation( tableCell );
const insertAt = this.order === 'after' ? column + 1 : column;
const insertAt = this.order === 'right' ? column + 1 : column;

tableUtils.insertColumns( table, { columns: 1, at: insertAt } );
}
Expand Down
4 changes: 2 additions & 2 deletions src/tableediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ export default class TableEditing extends Plugin {
editor.commands.add( 'insertTable', new InsertTableCommand( editor ) );
editor.commands.add( 'insertTableRowAbove', new InsertRowCommand( editor, { order: 'above' } ) );
editor.commands.add( 'insertTableRowBelow', new InsertRowCommand( editor, { order: 'below' } ) );
editor.commands.add( 'insertTableColumnBefore', new InsertColumnCommand( editor, { order: 'before' } ) );
editor.commands.add( 'insertTableColumnAfter', new InsertColumnCommand( editor, { order: 'after' } ) );
editor.commands.add( 'insertTableColumnLeft', new InsertColumnCommand( editor, { order: 'left' } ) );
editor.commands.add( 'insertTableColumnRight', new InsertColumnCommand( editor, { order: 'right' } ) );

editor.commands.add( 'removeTableRow', new RemoveRowCommand( editor ) );
editor.commands.add( 'removeTableColumn', new RemoveColumnCommand( editor ) );
Expand Down
4 changes: 2 additions & 2 deletions src/tableui.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,14 @@ export default class TableUI extends Plugin {
{
type: 'button',
model: {
commandName: 'insertTableColumnBefore',
commandName: 'insertTableColumnLeft',
label: t( 'Insert column before' )
}
},
{
type: 'button',
model: {
commandName: 'insertTableColumnAfter',
commandName: 'insertTableColumnRight',
label: t( 'Insert column after' )
}
},
Expand Down
14 changes: 7 additions & 7 deletions tests/commands/insertcolumncommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe( 'InsertColumnCommand', () => {
return editor.destroy();
} );

describe( 'order=after', () => {
describe( 'order=right', () => {
beforeEach( () => {
command = new InsertColumnCommand( editor );
} );
Expand All @@ -49,7 +49,7 @@ describe( 'InsertColumnCommand', () => {
} );

describe( 'execute()', () => {
it( 'should insert column in given table after selection\'s column', () => {
it( 'should insert column in given table to the right of the selection\'s column', () => {
setData( model, modelTable( [
[ '11[]', '12' ],
[ '21', '22' ]
Expand All @@ -63,7 +63,7 @@ describe( 'InsertColumnCommand', () => {
] ) );
} );

it( 'should insert column in given table after selection\'s column (selection in block content)', () => {
it( 'should insert column in given table to the right of the selection\'s column (selection in block content)', () => {
setData( model, modelTable( [
[ '11', '<paragraph>12[]</paragraph>', '13' ]
] ) );
Expand Down Expand Up @@ -155,9 +155,9 @@ describe( 'InsertColumnCommand', () => {
} );
} );

describe( 'order=before', () => {
describe( 'order=left', () => {
beforeEach( () => {
command = new InsertColumnCommand( editor, { order: 'before' } );
command = new InsertColumnCommand( editor, { order: 'left' } );
} );

describe( 'isEnabled', () => {
Expand All @@ -173,7 +173,7 @@ describe( 'InsertColumnCommand', () => {
} );

describe( 'execute()', () => {
it( 'should insert column in given table before selection\'s column', () => {
it( 'should insert column in given table to the left of the selection\'s column', () => {
setData( model, modelTable( [
[ '11', '12[]' ],
[ '21', '22' ]
Expand All @@ -187,7 +187,7 @@ describe( 'InsertColumnCommand', () => {
] ) );
} );

it( 'should insert column in given table before selection\'s column (selection in block content)', () => {
it( 'should insert column in given table to the left of the selection\'s column (selection in block content)', () => {
setData( model, modelTable( [
[ '11', '<paragraph>12[]</paragraph>', '13' ]
] ) );
Expand Down
8 changes: 4 additions & 4 deletions tests/tableediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,12 @@ describe( 'TableEditing', () => {
expect( editor.commands.get( 'insertTableRowBelow' ) ).to.be.instanceOf( InsertRowCommand );
} );

it( 'adds insertColumnBefore command', () => {
expect( editor.commands.get( 'insertTableColumnBefore' ) ).to.be.instanceOf( InsertColumnCommand );
it( 'adds insertColumnLeft command', () => {
expect( editor.commands.get( 'insertTableColumnLeft' ) ).to.be.instanceOf( InsertColumnCommand );
} );

it( 'adds insertColumnAfter command', () => {
expect( editor.commands.get( 'insertTableColumnAfter' ) ).to.be.instanceOf( InsertColumnCommand );
it( 'adds insertColumnRight command', () => {
expect( editor.commands.get( 'insertTableColumnRight' ) ).to.be.instanceOf( InsertColumnCommand );
} );

it( 'adds removeRow command', () => {
Expand Down
12 changes: 6 additions & 6 deletions tests/tableui.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,13 +233,13 @@ describe( 'TableUI', () => {
const items = dropdown.listView.items;

const setColumnHeaderCommand = editor.commands.get( 'setTableColumnHeader' );
const insertColumnBeforeCommand = editor.commands.get( 'insertTableColumnBefore' );
const insertColumnAfterCommand = editor.commands.get( 'insertTableColumnAfter' );
const insertColumnLeftCommand = editor.commands.get( 'insertTableColumnLeft' );
const insertColumnRightCommand = editor.commands.get( 'insertTableColumnRight' );
const removeColumnCommand = editor.commands.get( 'removeTableColumn' );

setColumnHeaderCommand.isEnabled = true;
insertColumnBeforeCommand.isEnabled = true;
insertColumnAfterCommand.isEnabled = true;
insertColumnLeftCommand.isEnabled = true;
insertColumnRightCommand.isEnabled = true;
removeColumnCommand.isEnabled = true;

expect( items.first.children.first.isEnabled ).to.be.true;
Expand All @@ -253,12 +253,12 @@ describe( 'TableUI', () => {
expect( items.first.children.first.isEnabled ).to.be.false;
expect( dropdown.buttonView.isEnabled ).to.be.true;

insertColumnBeforeCommand.isEnabled = false;
insertColumnLeftCommand.isEnabled = false;

expect( items.get( 2 ).children.first.isEnabled ).to.be.false;
expect( dropdown.buttonView.isEnabled ).to.be.true;

insertColumnAfterCommand.isEnabled = false;
insertColumnRightCommand.isEnabled = false;
expect( items.get( 3 ).children.first.isEnabled ).to.be.false;

removeColumnCommand.isEnabled = false;
Expand Down

0 comments on commit 12abab5

Please sign in to comment.