-
Notifications
You must be signed in to change notification settings - Fork 17
Position of table cell properties balloon should be in relation to multiple selected cells. #291
Conversation
…ltiple selected cells.
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.
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
// @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 ) { |
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.
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.
The solution is good but some cod style issues to change:
- API usage - we have some methods for scenarios as first/last position or number of ranges in the selection.
- 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).
- The
else
block can be in most cases avoided.
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() ); |
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.
That's not needed at this point. You can use: editor.model.document.selection.rangeCount
in the if
below.
src/ui/utils.js
Outdated
positions: BALLOON_POSITIONS | ||
}; | ||
} else { | ||
const modelTableCell = getTableCellAtPosition( ranges[ 0 ].start ); |
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.
ranges[ 0 ].start
=> editor.document.selection.getFirstPosition()
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