Class: Range

Range

A logical range of a Post. Usually an instance of Range will be read from the Editor#range property, but it may be useful to instantiate a range directly when programmatically modifying a Post.

Constructor

new Range(head, tailopt, directionopt)

Parameters:
Name Type Attributes Default Description
head Position
tail Position <optional>
head
direction Direction <optional>
null
Source:

Members

direction

Properties:
Name Type Description
direction Direction
Source:
Properties:
Name Type Description
head Position
Source:

tail

Properties:
Name Type Description
tail Position
Source:

Methods

(static) create(headSection, headOffset, tailSectionopt, tailOffsetopt, directionopt) → {Range}

Shorthand to create a new range from a section(s) and offset(s). When given only a head section and offset, creates a collapsed range.

Parameters:
Name Type Attributes Default Description
headSection Section
headOffset number
tailSection Section <optional>
headSection
tailOffset number <optional>
headOffset
direction Direction <optional>
null
Source:
Returns:
Type
Range

extend(units) → {Range}

Expands the range 1 unit in the given direction If the range is expandable in the given direction, always returns a non-collapsed range.

Parameters:
Name Type Description
units Number

If units is > 0, the range is extended to the right, otherwise range is extended to the left.

Source:
Returns:
Type
Range

move(direction) → {Range}

Moves this range 1 unit in the given direction. If the range is collapsed, returns a collapsed range shifted by 1 unit, otherwise collapses this range to the position at the direction end of the range. Always returns a collapsed range.

Parameters:
Name Type Description
direction Direction
Source:
Returns:
Type
Range