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

Added SelectRowCommand and SelectColumnCommand. #295

Merged
merged 12 commits into from
Apr 6, 2020
Merged

Added SelectRowCommand and SelectColumnCommand. #295

merged 12 commits into from
Apr 6, 2020

Conversation

niegowski
Copy link
Contributor

Suggested merge commit message (convention)

Feature: "Select entire column/row" added to table row/column dropdowns. Closes ckeditor/ckeditor5#6500.


Additional information

@coveralls
Copy link

coveralls commented Apr 1, 2020

Coverage Status

Coverage increased (+0.0007%) to 99.938% when pulling 302526b on i/6500 into a5a7d3e on master.

@jodator jodator self-requested a review April 2, 2020 08:36
@jodator jodator self-assigned this Apr 2, 2020
Copy link
Contributor

@jodator jodator left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM for the most part :) My remarks:

  1. Some questions about reducing number of loops (minor).
  2. The TableWalker for operating on rows isn't necessary.
  3. More tests for colspan and rowspan scenarios are needed even though we have 100% CC.
    1. I'd remove the 'entire' from the column/row buttons' titles.

@@ -4,11 +4,13 @@
"Insert column left": "Label for the insert table column to the left of the current one button.",
"Insert column right": "Label for the insert table column to the right of the current one button.",
"Delete column": "Label for the delete table column button.",
"Select entire column": "Label for the select table entire column button.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that we can drop "entire" from the title - this is for both commands.

Copy link
Contributor

@jodator jodator Apr 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Reinmar yay/no?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think it can be "select column".

In fact, it should be "select column" or "select columns" depending on the selection, but the same applies to the other labels (e.g. delete column) and we ignored this for the moment.

*
* The command is registered by {@link module:table/tableediting~TableEditing} as the `'selectTableColumn'` editor command.
*
* To select the column containing the selected cell, execute the command:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you update the docs to reflect that it can select multiple columns? (also in the row command)

*
* The command is registered by {@link module:table/tableediting~TableEditing} as the `'selectTableColumn'` editor command.
*
* To select the column containing the selected cell, execute the command:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you update the docs to reflect that it can select multiple columns? (also in the row command)


for ( const cellInfo of new TableWalker( findAncestor( 'table', firstCell ) ) ) {
if ( cellInfo.column >= startColumn && cellInfo.column <= endColumn ) {
cellsToSelect.push( cellInfo.cell );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if doing one less loop wouldn't be better. Here you can use model.createRangeOn() and have rangesToSelect array.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However I don't see any performance gain on 20 columns so maybe it is a bit a stretch here.

const table = findAncestor( 'table', referenceCells[ 0 ] );
const cellsToSelect = [];

for ( const cellInfo of new TableWalker( table, { startRow: rowIndexes.first, endRow: rowIndexes.last } ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd go with iterating over table.getChildren() or event for loop and retrieving rows by index from table. Then for every row select all children (table cells). The TableWalker is cool to deal with columns and spans when needed but here we have simpler solution as operations on row indexes is straightforward (those maps 1:1 even with rowspans). As opposite to working with columns indexes where there's no 1:1 mapping to columns.

tests/commands/selectrowcommand.js Outdated Show resolved Hide resolved
tests/commands/selectcolumncommand.js Outdated Show resolved Hide resolved
tests/commands/selectcolumncommand.js Outdated Show resolved Hide resolved
tests/commands/selectcolumncommand.js Outdated Show resolved Hide resolved
// + +----+----+----+----+
// | | 31 | 32 | 33 | 34 |
// +----+----+----+----+----+
setData( model, modelTable( [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly to the comment in column comand - please add more cases with rowspan.

@niegowski niegowski requested a review from jodator April 3, 2020 14:08
Copy link
Contributor

@jodator jodator left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@jodator jodator merged commit 729cc00 into master Apr 6, 2020
@jodator jodator deleted the i/6500 branch April 6, 2020 08:50
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add "select entire column" and "select entire row" options in the row/col dropdowns
4 participants