BlueprintRange

How to get BlueprintRange

ES2015+:

import BlueprintRange from 'fontoxml-blueprints/BlueprintRange'

ES5:

define([
	'fontoxml-blueprints/BlueprintRange'
], function (
	BlueprintRange
) {
});

Type: Class

Represents a range in a blueprint

A blueprint performs edits a vanilla range cannot respond to, examples are: edits in the order of start and end: a normal range will mirror itself, it will not mirror if the edits only took place in the blueprint.

Also, setStartBefore like functions will also not work.

Use this for using ranges in blueprints. Edits in the blueprint will affect this range.

Constructor

# Name Type Description
1. blueprint Blueprint

The blueprint in which to consider the range

Static methods

Name Description
createFromRange

Constructs a new BlueprintRange from the given Range.


  Arguments
# Name Type Description
1. blueprint Blueprint

The blueprint on which to create the range.

2. range Range | Null

A range.

  Returns

Type: BlueprintRange

The created blueprint range.

Properties

Name Type Description
collapsed Boolean
endContainer Node
endOffset Number

The offset of the end of this range

isEmpty Boolean

If true, this range is empty (there is no selection).

startContainer Node

The container of the start of this range

startOffset Number

The offset of the start of the range

Methods

Name Description
cloneRange

Create a new range with the same boundary points.


  Returns

Type: Range

The clone.

collapse

Collapses the Range to one of its boundary points.


  Arguments
# Name Type Description
1. toStart Boolean

Whether to collapse to the start (true) or the end (false)

findCommonAncestor

Find the common ancestor of this range, the first node under which the start and endContainer are contained


  Returns

Type: Node

The common ancestor of the range

selectNode

Sets the Range to contain the Node and its contents.


  Arguments
# Name Type Description
1. referenceNode Node

The node to set the range relative to

selectNodeContents

Sets the Range to contain the contents of a Node.


  Arguments
# Name Type Description
1. referenceNode Node

The node to select the contents of

setEnd

Sets the start position of a range to a given node and a given offset inside that node.


  Arguments
# Name Type Description
1. node Node

The node to end the range at

2. offset Number

The offset at which to end the range

setEndAfter

Sets the end position of this Range relative to another Node.


  Arguments
# Name Type Description
1. referenceNode Node

The node to set the range relative to

setEndBefore

Sets the end position of this Range relative to another Node.


  Arguments
# Name Type Description
1. referenceNode Node

The node to set the range relative to

setStart

Sets the start position of a range to a given node and a given offset inside that node.


  Arguments
# Name Type Description
1. node Node

The node to start from

2. offset Number

The offset at which to start the range

setStartAfter

Sets the start position of this Range relative to another Node.


  Arguments
# Name Type Description
1. referenceNode Node

The node to set the range relative to

setStartBefore

Sets the start position of this Range relative to another Node.


  Arguments
# Name Type Description
1. referenceNode Node

The node to set the range relative to