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

I/6545: Introduce TableUtils.removeRows() utility method. #297

Merged
merged 9 commits into from
Apr 7, 2020
Merged

Conversation

jodator
Copy link
Contributor

@jodator jodator commented Apr 3, 2020

Suggested merge commit message (convention)

Feature: Introduce TableUtils.removeRows() method. Closes ckeditor/ckeditor5#6545.


Additional information

This is a refactor needed for ckeditor/ckeditor5#6439 fix.

I've introduced a method in the same way as TableUtils.insertRows() and TableUtils.insertColumns() are constructed.

@coveralls
Copy link

coveralls commented Apr 3, 2020

Coverage Status

Coverage increased (+0.0001%) to 99.939% when pulling fe3c1df on i/6545 into fd1d5da on master.

Comment on lines 256 to 284
/**
* Removes a row from the given `table`.
*
* This method properly re-calculate table geometry including `rowspan` attribute of any table cell that is overlapping removed row
* and table headings values.
*
* editor.plugins.get( 'TableUtils' ).removeRows( table, { at: 1, rows: 2 } );
*
* Assuming the table on the left, the above code will transform it to the table on the right:
*
* row index
* ┌───┬───┬───┐ `at` = 1 ┌───┬───┬───┐
* 0 │ a │ b │ c │ `rows` = 2 │ a │ b │ c │ 0
* │ ├───┼───┤ │ ├───┼───┤
* 1 │ │ d │ e │ <-- remove from here │ │ i │ j │ 1
* │ ├───┼───┤ will give: ├───┼───┼───┤
* 2 │ │ g │ h │ │ k │ l │ m │ 2
* │ ├───┼───┤ └───┴───┴───┘
* 3 │ │ i │ j │
* ├───┼───┼───┤
* 4 │ k │ l │ m │
* └───┴───┴───┘
*
* @param {module:engine/model/element~Element} table
* @param {Object} options
* @param {Number} options.at The row index at which the removing rows will start.
* @param {Number} [options.rows=1] The number of rows to remove.
*/
removeRows( table, options ) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This one needs review. Rest of the PR is moving stuff around from RemoveRowComand - it's test are untouched so the whole logic works. New tests are for removing rows only.

src/tableutils.js Outdated Show resolved Hide resolved
src/tableutils.js Outdated Show resolved Hide resolved
src/tableutils.js Outdated Show resolved Hide resolved
src/tableutils.js Show resolved Hide resolved
Co-Authored-By: Aleksander Nowodzinski <a.nowodzinski@cksource.com>
Comment on lines 814 to 818
setData( model, modelTable( [
[ { rowspan: 3, contents: '00' }, { rowspan: 2, contents: '01' }, '02' ],
[ '12' ],
[ '22' ],
[ '30', '31', '32' ]
Copy link
Contributor

Choose a reason for hiding this comment

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

Cell 21 seems to be missing.

@jodator jodator requested a review from niegowski April 7, 2020 11:51
@oleq oleq merged commit c6770ba into master Apr 7, 2020
@oleq oleq deleted the i/6545 branch April 7, 2020 12:35
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.

Introduce method for removing row from table
4 participants