Constructor
new ve.Range([from], [to])
#
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
from |
number |
optional |
0 | Anchor offset |
to |
number |
optional |
from | Focus offset |
- Source:
Methods
containsOffset(offset) → {boolean}
#
Check if an offset is within the range.
Specifically we mean the whole element at a specific offset, so in effect this is the same as #containsRange( new ve.Range( offset, offset + 1 ) ).
Parameters:
Name | Type | Description |
---|---|---|
offset |
number | Offset to check |
- Source:
Returns:
If offset is within the range
- Type
- boolean
containsRange(range) → {boolean}
#
Check if another range is within the range.
Parameters:
Name | Type | Description |
---|---|---|
range |
ve.Range | Range to check |
- Source:
Returns:
If other range is within the range
- Type
- boolean
equals(other) → {boolean}
#
Check if two ranges are equal, taking direction into account.
Parameters:
Name | Type | Description |
---|---|---|
other |
ve.Range
|
null
|
- Source:
Returns:
- Type
- boolean
equalsSelection(other) → {boolean}
#
Check if two ranges are equal, ignoring direction.
Parameters:
Name | Type | Description |
---|---|---|
other |
ve.Range
|
null
|
- Source:
Returns:
- Type
- boolean
expand(other) → {ve.Range}
#
flip() → {ve.Range}
#
getLength() → {number}
#
isBackwards() → {boolean}
#
Check if the range is backwards, i.e. from > to
- Source:
Returns:
Range is backwards
- Type
- boolean
isCollapsed() → {boolean}
#
Check if the range is collapsed.
A collapsed range has equal start and end values making its length zero.
- Source:
Returns:
Range is collapsed
- Type
- boolean
overlapsRange(range) → {boolean}
#
Check if another range overlaps this one
This includes ranges which intersect this one, e.g. [1,3] & [2,4], and ranges which cover this one completely, e.g. [1,3] & [0,5], but not ranges which only touch, e.g. [0,2] & [2,4].
Parameters:
Name | Type | Description |
---|---|---|
range |
ve.Range | Range to check |
- Source:
Returns:
If other range overlaps this range
- Type
- boolean
Check if another range overlaps this one
This includes ranges which intersect this one, e.g.
toJSON([key]) → {Object}
#
Get a object summarizing the range for JSON serialization
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
key |
string |
optional |
Key in parent object |
- Source:
Returns:
Object for JSON serialization
- Type
- Object
touchesRange(range) → {boolean}
#
Check if another range is touching this one
This includes ranges which touch this one, e.g. [1,3] & [3,5], ranges which overlap this one, and ranges which cover this one completely, e.g. [1,3] & [0,5].
Useful for testing if two ranges can be joined (using #expand)
Parameters:
Name | Type | Description |
---|---|---|
range |
ve.Range | Range to check |
- Source:
Returns:
If other range touches this range
- Type
- boolean
Check if another range is touching this one
This includes ranges which touch this one, e.g.
translate(distance) → {ve.Range}
#
Get a range that's a translated version of this one.
Parameters:
Name | Type | Description |
---|---|---|
distance |
number | Distance to move range by |
- Source:
Returns:
New translated range
- Type
- ve.Range
truncate(limit) → {ve.Range}
#
Create a new range with a truncated length.
Parameters:
Name | Type | Description |
---|---|---|
limit |
number | Maximum length of new range (negative for left-side truncation) |
- Source:
Returns:
A new range
- Type
- ve.Range