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

T/1063: Introduce Selection#isEntireContentSelected( element ) #1064

Merged
merged 4 commits into from
Aug 15, 2017
Merged

Conversation

pomek
Copy link
Member

@pomek pomek commented Aug 10, 2017

Suggested merge commit message (convention)

Feature: Added Selection#isEntireContentSelected( element ). Closes ckeditor/ckeditor5#4137.

@pomek pomek requested a review from Reinmar August 10, 2017 07:30
@@ -625,6 +625,20 @@ export default class Selection {
}

/**
* Checks whether the entire content in specified element is selected.
Copy link
Member

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.

* @param {module:engine/model/element~Element} element
* @returns {Boolean}
*/
isEntireContentSelected( element ) {
Copy link
Member

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()', () => {
Copy link
Member

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

Copy link
Member Author

@pomek pomek Aug 10, 2017

Choose a reason for hiding this comment

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

Added in 9ee9e12.

@pomek
Copy link
Member Author

pomek commented Aug 10, 2017

I guess it's ready for review once again.

@Reinmar Reinmar merged commit 1902d7a into master Aug 15, 2017
@Reinmar Reinmar deleted the t/1063 branch August 15, 2017 15:09
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 Selection#isEntireContentSelected( element )
2 participants