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

Position of table cell properties balloon should be in relation to multiple selected cells. #291

Merged
merged 3 commits into from
Mar 30, 2020

Conversation

niegowski
Copy link
Contributor

Suggested merge commit message (convention)

Other: Position of table cell properties balloon should be in relation to multiple selected cells. Closes ckeditor/ckeditor5#6357.


Additional information

@coveralls
Copy link

coveralls commented Mar 27, 2020

Coverage Status

Coverage increased (+0.0003%) to 99.936% when pulling d5ddad1 on i/6357 into ebbebe4 on master.

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.

The coverage dropped for added code so something isn't fully tested or the code have superfluous checks.

Please check what's a case here.

src/ui/utils.js Outdated Show resolved Hide resolved
src/ui/utils.js Outdated
// @param {Array.<module:utils/dom/rect~Rect>|Array.<*>} list List of `Rect`s or any list to map by `mapFn`.
// @param {Function} [mapFn] Mapping function for list elements.
// @returns {module:utils/dom/rect~Rect}
function createBoundingRect( list, mapFn = null ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The null default value isn't tested (coverage dropped):

The other branch is below.

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.

The solution is good but some cod style issues to change:

  1. API usage - we have some methods for scenarios as first/last position or number of ranges in the selection.
  2. Although helper method and it is a private code it looks like it might be promoted to general API (not yet I think) so it must be simplified and be focused on doing one thing (calculating sum of rects).
  3. The else block can be in most cases avoided.

src/ui/utils.js Outdated Show resolved Hide resolved
src/ui/utils.js Outdated
const viewTableCell = editor.editing.mapper.toViewElement( modelTableCell );
const mapper = editor.editing.mapper;
const domConverter = editor.editing.view.domConverter;
const ranges = Array.from( editor.model.document.selection.getRanges() );
Copy link
Contributor

Choose a reason for hiding this comment

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

That's not needed at this point. You can use: editor.model.document.selection.rangeCount in the if below.

src/ui/utils.js Show resolved Hide resolved
src/ui/utils.js Outdated Show resolved Hide resolved
src/ui/utils.js Outdated
positions: BALLOON_POSITIONS
};
} else {
const modelTableCell = getTableCellAtPosition( ranges[ 0 ].start );
Copy link
Contributor

Choose a reason for hiding this comment

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

src/ui/utils.js Show resolved Hide resolved
@jodator jodator merged commit e2dff56 into master Mar 30, 2020
@jodator jodator deleted the i/6357 branch March 30, 2020 12:12
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.

Position table cell properties balloon in relation to multiple-cell
3 participants