This repository has been archived by the owner on Jun 26, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
I/6545: Introduce TableUtils.removeRows() utility method. #297
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jodator
commented
Apr 3, 2020
src/tableutils.js
Outdated
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 ) { |
There was a problem hiding this comment.
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.
oleq
reviewed
Apr 7, 2020
oleq
reviewed
Apr 7, 2020
oleq
reviewed
Apr 7, 2020
oleq
reviewed
Apr 7, 2020
Co-Authored-By: Aleksander Nowodzinski <a.nowodzinski@cksource.com>
niegowski
reviewed
Apr 7, 2020
tests/tableutils.js
Outdated
Comment on lines
814
to
818
setData( model, modelTable( [ | ||
[ { rowspan: 3, contents: '00' }, { rowspan: 2, contents: '01' }, '02' ], | ||
[ '12' ], | ||
[ '22' ], | ||
[ '30', '31', '32' ] |
There was a problem hiding this comment.
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.
niegowski
approved these changes
Apr 7, 2020
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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()
andTableUtils.insertColumns()
are constructed.