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

I/6546: Implement remove column util #300

Merged
merged 13 commits into from
Apr 8, 2020
Merged

I/6546: Implement remove column util #300

merged 13 commits into from
Apr 8, 2020

Conversation

jodator
Copy link
Contributor

@jodator jodator commented Apr 7, 2020

Suggested merge commit message (convention)

Feature: Introduce TableUtils.removeColumns() method. Closes ckeditor/ckeditor5#6546. Closes ckeditor/ckeditor5#6439.


Additional information

  • Unfortunately this PR only fixes one of the recent table bugs.

@jodator jodator requested a review from niegowski April 7, 2020 14:31
@coveralls
Copy link

coveralls commented Apr 7, 2020

Coverage Status

Coverage increased (+0.0001%) to 99.939% when pulling dc9535d on i/6546 into 4fd49a9 on master.

function adjustHeadingColumns( table, removedColumnIndexes, writer ) {
const headingColumns = table.getAttribute( 'headingColumns' ) || 0;

if ( headingColumns && removedColumnIndexes.first <= headingColumns ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

removedColumnIndexes.first is an index and headingColumns is count (probably < is enough), if those are equal the resulting headingsRemoved will equal 0 so no change is needed.

@@ -418,7 +418,7 @@ describe( 'RemoveColumnCommand', () => {
] ) );
} );

it( 'should work property if the rowspan is in the first column (#1)', () => {
it( 'should work property if the rowspan is in the first column (the other cell in row is selected)', () => {
setData( model, modelTable( [
[ { rowspan: 2, contents: '00' }, '[]01' ],
[ '10' ]
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems to be 11.

] ) );
} );

it( 'should work property if the rowspan is in the first column (#2)', () => {
it( 'should work property if the rowspan is in the first column (the cell in row below is selected)', () => {
setData( model, modelTable( [
[ { rowspan: 2, contents: '00' }, '01' ],
[ '[]10' ]
Copy link
Contributor

Choose a reason for hiding this comment

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

It should be 11.

] ) );
} );

it( 'should work property if the rowspan is in the first column (#3)', () => {
it( 'should work property if the rowspan is in the first column (the cell with rowspan is selected)', () => {
setData( model, modelTable( [
[ { rowspan: 2, contents: '00[]' }, '01' ],
[ '10' ]
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be 11.

Comment on lines 1016 to 1021
[ { colspan: 4, contents: '00' }, '03' ],
[ { colspan: 3, contents: '10' }, '13' ],
[ { colspan: 2, contents: '20' }, '22', '23' ],
[ '30', { colspan: 2, contents: '31' }, '33' ],
[ '40', '41', '42', '43' ]
] ) );
Copy link
Contributor

Choose a reason for hiding this comment

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

This table seems invalid:

+----+----+----+----+----+
| 00                | 03 |
+----+----+----+----+----+
| 10           | 13 |
+----+----+----+----+
| 20      | 22 | 23 |
+----+----+----+----+
| 30 | 31      | 33 |
+----+----+----+----+
| 40 | 41 | 42 | 43 |
+----+----+----+----+

Comment on lines 1037 to 1039
[ { colspan: 3, contents: '00' }, '03' ],
[ { colspan: 2, contents: '10' }, '13' ],
[ '20', '21', '22', '23' ]
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems invalid table:

+----+----+----+----+
| 00           | 03 |
+----+----+----+----+
| 10      | 13 |
+----+----+----+----+
| 20 | 21 | 22 | 23 |
+----+----+----+----+

it( 'should remove column with rowspan (first column)', () => {
setData( model, modelTable( [
[ { rowspan: 2, contents: '00' }, '01' ],
[ '10' ]
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be 11.

[ '30', { colspan: 2, contents: '31' }, '33' ],
[ '40', '41', '42', '43' ]
[ { colspan: 4, contents: '00' }, '04' ],
[ { colspan: 3, contents: '10' }, '14' ],
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing 13.

[ '30', { colspan: 2, contents: '31' }, '33' ],
[ '40', '41', '42', '43' ]
[ { colspan: 4, contents: '00' }, '04' ],
[ { colspan: 3, contents: '10' }, '14' ],
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing 13.

src/tableutils.js Outdated Show resolved Hide resolved
@oleq oleq merged commit 396c6e9 into master Apr 8, 2020
@oleq oleq deleted the i/6546 branch April 8, 2020 12:16
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
4 participants