The goog.dom.MultiRange Class

goog.dom.MultiRange
> goog.dom.AbstractMultiRange
> goog.dom.AbstractRange

goog.dom.MultiRange()

Creates a new multi part range with no properties. Do not use this constructor: use one of the goog.dom.Range.createFrom* methods instead.

.__iterator__()

.clone()

returns {goog.dom.MultiRange}
A clone of this range.

.collapse(toAnchor)

Collapses this range to a single point, either the first or last point depending on the parameter. This will result in the number of ranges in this multi range becoming 1.

toAnchor {boolean}
Whether to collapse to the anchor.

.containsNode(node, opt_allowPartial)

Inherited from goog.dom.AbstractRange .

Tests if this range contains the given node.

node {Node}
The node to test for.
opt_allowPartial {boolean=}
If not set or false, the node must be entirely contained in the selection for this function to return true.
returns {boolean}
Whether this range contains the given node.

.containsRange(range, opt_allowPartial)

Inherited from goog.dom.AbstractMultiRange .

Tests if this range contains the given range.

range {goog.dom.AbstractRange}
The range to test.
opt_allowPartial {boolean=}
If true, the range can be partially contained in the selection, otherwise the range must be entirely contained.
returns {boolean}
Whether this range contains the given range.

.createFromBrowserRanges(browserRanges)

Creates a new range wrapper from the given browser ranges. Do not use this method directly - please use goog.dom.Range.createFrom* instead.

browserRanges {Array.<Range>}
The browser ranges.
returns {goog.dom.MultiRange}
A range wrapper object.

.createFromBrowserSelection(selection)

Creates a new range wrapper from the given browser selection object. Do not use this method directly - please use goog.dom.Range.createFrom* instead.

selection {Selection}
The browser selection object.
returns {goog.dom.MultiRange}
A range wrapper object.

.createFromTextRanges(textRanges)

Creates a new range wrapper from the given goog.dom.TextRange objects. Do not use this method directly - please use goog.dom.Range.createFrom* instead.

textRanges {Array.<goog.dom.TextRange>}
The text range objects.
returns {goog.dom.MultiRange}
A range wrapper object.

.getAnchorNode()

Inherited from goog.dom.AbstractRange .

returns {Node}
The element or text node the range is anchored at.

.getAnchorOffset()

Inherited from goog.dom.AbstractRange .

returns {number}
The offset into the node the range is anchored at. For text nodes, this is an offset into the node value. For elements, this is an offset into the childNodes array.

.getBrowserRangeObject()

.getContainer()

.getContainerElement()

Inherited from goog.dom.AbstractRange .

Returns the deepest element in the tree that contains the entire range.

returns {Element}
The deepest element that contains the entire range.

.getDocument()

Inherited from goog.dom.AbstractRange .

returns {Document}
The document this selection is a part of.

.getEndNode()

.getEndOffset()

.getFocusNode()

Inherited from goog.dom.AbstractRange .

returns {Node}
The element or text node the range is focused at - i.e. where the cursor is.

.getFocusOffset()

Inherited from goog.dom.AbstractRange .

returns {number}
The offset into the node the range is focused at - i.e. where the cursor is. For text nodes, this is an offset into the node value. For elements, this is an offset into the childNodes array.

.getHtmlFragment()

.getPastableHtml()

.getSortedRanges()

returns {Array.<goog.dom.TextRange>}
An array of sub-ranges, sorted by start point.

.getStartNode()

.getStartOffset()

.getText()

.getTextRange()

.getTextRangeCount()

.getTextRanges()

Inherited from goog.dom.AbstractRange .

Gets an array of all text ranges this range is comprised of. For non-multi ranges, returns a single element array containing this.

returns {Array.<goog.dom.TextRange>}
Array of text ranges.

.getType()

.getValidHtml()

.getWindow()

Inherited from goog.dom.AbstractRange .

returns {Window}
The window this selection is a part of.

.insertNode(node, before)

Inherited from goog.dom.AbstractMultiRange .

Inserts a node before (or after) the range. The range may be disrupted beyond recovery because of the way this splits nodes.

node {Node}
The node to insert.
before {boolean}
True to insert before, false to insert after.
returns {Node}
The node added to the document. This may be different than the node parameter because on IE we have to clone it.

.isCollapsed()

.isRangeInDocument()

.isReversed()

Inherited from goog.dom.AbstractRange .

returns {boolean}
Whether the selection is reversed.

.removeContents()

.replaceContentsWithNode(node)

Inherited from goog.dom.AbstractRange .

Replaces the range contents with (possibly a copy of) the given node. The range may be disrupted beyond recovery because of the way this splits nodes.

node {Node}
The node to insert.
returns {Node}
The node added to the document. This may be different than the node parameter because on IE we have to clone it.

.saveUsingCarets()

Inherited from goog.dom.AbstractRange .

Saves the range using HTML carets. As long as the carets remained in the HTML, the range can be restored...even when the HTML is copied across documents.

returns {goog.dom.SavedCaretRange?}
A range representation that can be restored as long as carets are not removed. Returns null if carets could not be created.

.saveUsingDom()

.select()

.setBrowserRangeObject()

.surroundWithNodes(startNode, endNode)

Inherited from goog.dom.AbstractMultiRange .

Surrounds this range with the two given nodes. The range may be disrupted beyond recovery because of the way this splits nodes.

startNode {Element}
The node to insert at the start.
endNode {Element}
The node to insert at the end.