new Position()
A position is a logical location (zero-width, or "collapsed") in a post, typically between two characters in a section. Two positions (a head and a tail) make up a Range.
- Source:
Members
marker
Returns the marker at this position, in the backward direction (i.e., the marker to the left of the cursor if the cursor is on a marker boundary and text is left-to-right)
- Source:
Methods
(static) atPoint(x, y, editor) → {Position|null}
Parameters:
Name | Type | Description |
---|---|---|
x |
integer | x-position in current viewport |
y |
integer | y-position in current viewport |
editor |
Editor |
- Source:
Returns:
- Type
- Position | null
isHead() → {Boolean}
- Source:
Returns:
If this position is at the head of its section
- Type
- Boolean
isHeadOfPost() → {Boolean}
- Source:
Returns:
If this position is at the head of the post
- Type
- Boolean
isTail() → {Boolean}
- Source:
Returns:
If this position is at the tail of its section
- Type
- Boolean
isTailOfPost() → {Boolean}
- Source:
Returns:
If this position is at the tail of the post
- Type
- Boolean
markerIn(direction) → {Marker|undefined}
Returns the marker in direction
from this position.
If the position is in the middle of a marker, the direction is irrelevant.
Otherwise, if the position is at a boundary between two markers, returns the
marker to the left if direction
=== BACKWARD and the marker to the right
if direction
=== FORWARD (assuming left-to-right text direction).
Parameters:
Name | Type | Description |
---|---|---|
direction |
Direction |
- Source:
Returns:
- Type
- Marker | undefined
move(units) → {Position}
Move the position 1 unit in direction
.
Parameters:
Name | Type | Description |
---|---|---|
units |
Number | to move. > 0 moves right, < 0 moves left |
- Source:
Returns:
Return a new position one unit in the given direction. If the position is moving left and at the beginning of the post, the same position will be returned. Same if the position is moving right and at the end of the post.
- Type
- Position
moveWord(direction) → {Position}
Parameters:
Name | Type | Description |
---|---|---|
direction |
Number | (FORWARD or BACKWARD) |
- Source:
Returns:
The result of moving 1 "word" unit in direction
- Type
- Position
toRange(tailopt) → {Range}
Returns a range from this position to the given tail. If no explicit tail is given this returns a collapsed range focused on this position.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
tail |
Position |
<optional> |
this | The ending position |
- Source:
Returns:
- Type
- Range