-
Notifications
You must be signed in to change notification settings - Fork 40
T/1063: Introduce Selection#isEntireContentSelected( element )
#1064
Conversation
src/model/selection.js
Outdated
@@ -625,6 +625,20 @@ export default class Selection { | |||
} | |||
|
|||
/** | |||
* Checks whether the entire content in specified element is selected. |
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 description is not accurate. In such case, the <b>
's content is also fully selected:
<div>[x<b>y</b>z]</div>
It's hard to explain this in just one paragraph, but we should try with something like:
Checks whether the selection contains the entire content of the given element. This means that selection must start at a position {@link module:engine/model/position~Position#isTouching touching} the element's start and ends at position touching the element's end.
src/model/selection.js
Outdated
* @param {module:engine/model/element~Element} element | ||
* @returns {Boolean} | ||
*/ | ||
isEntireContentSelected( element ) { |
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 element should default to the root of the selection's root (this.anchor.root
will be fine).
@@ -1237,4 +1237,56 @@ describe( 'Selection', () => { | |||
} ); | |||
} ); | |||
} ); | |||
|
|||
describe( 'isEntireContentSelected()', () => { |
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.
Missing tests:
- empty content,
- empty selection at a boundary of non-empty content
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.
Added in 9ee9e12.
…er. Improved docs and tests.
I guess it's ready for review once again. |
Suggested merge commit message (convention)
Feature: Added
Selection#isEntireContentSelected( element )
. Closes ckeditor/ckeditor5#4137.