Home

# Library goog.editor.range

Function Summary
| `NormalizedCaretRange_(?goog.dom.AbstractRange range)` Saves the range using carets, but normalizes text nodes when carets are removed.

`expand(?goog.dom.AbstractRange range, ?Node= opt_stopNode) ⇒ ?goog.dom.AbstractRange`

Given a range, expand the range to include outer tags if the full contents of those tags are entirely selected. This essentially changes the dom position, but not the visible position of the range. Ex.
- foo
if "foo" is selected, instead of returning start and end nodes as the foo text node, return the li.

| `expandEndPointToContainer_(?goog.dom.AbstractRange range, ?goog.dom.RangeEndpoint endpoint, ?Node= opt_stopNode) ⇒ ?goog.dom.AbstractRange` Given a range, expands the start or end points as far out towards the range's common container (or stopNode, if provided) as possible, while perserving the same visible position.
| `getDeepEndPoint(?goog.dom.AbstractRange range, boolean atStart) ⇒ ?goog.editor.range.Point` Get the deepest point in the DOM that's equivalent to the endpoint of the given range.
| `intersectsTag(?goog.dom.AbstractRange range, ?goog.dom.TagName tagName) ⇒ boolean` Returns whether the given range intersects with any instance of the given tag.
| `isEditable(?goog.dom.AbstractRange range) ⇒ boolean` Checks if a range is completely inside an editable region.
| `narrow(?goog.dom.AbstractRange range, ?Element el) ⇒ ?goog.dom.AbstractRange` Given a range and an element, create a narrower range that is limited to the boundaries of the element. If the range starts (or ends) outside the element, the narrowed range's start point (or end point) will be the leftmost (or rightmost) leaf of the element.

`normalize(?goog.dom.AbstractRange range) ⇒ function (): (goog.dom.AbstractRange|null)`

Given a range in the current DOM, create a factory for a range that represents the same selection in a normalized DOM. The factory function should be invoked after the DOM is normalized. All browsers do a bad job preserving ranges across DOM normalization. The issue is best described in this 5-year-old bug report: https://bugzilla.mozilla.org/show_bug.cgi?id=191864 For most applications, this isn't a problem. The browsers do a good job handling un-normalized text, so there's usually no reason to normalize. The exception to this rule is the rich text editing commands execCommand and queryCommandValue, which will fail often if there are un-normalized text nodes. The factory function creates new ranges so that we can normalize the DOM without problems. It must be created before any normalization happens, and invoked after normalization happens.

| `normalizeNode(?Node node)` Normalizes the given node.
| `normalizeNodeIe_(?Node node)` Manually normalizes the node in IE, since native normalize in IE causes transient problems.
| `normalizePoint_(?goog.editor.range.Point point) ⇒ ?goog.editor.range.Point` Given a point in the current DOM, adjust it to represent the same point in a normalized DOM. See the comments on goog.editor.range.normalize for more context.

`placeCursorNextTo(?Node node, boolean toLeft) ⇒ ?goog.dom.AbstractRange`

Position the cursor immediately to the left or right of "node". In Firefox, the selection parent is outside of "node", so the cursor can effectively be moved to the end of a link node, without being considered inside of it. Note: This does not always work in WebKit. In particular, if you try to place a cursor to the right of a link, typing still puts you in the link. Bug: http://bugs.webkit.org/show_bug.cgi?id=17697

| `rangePreservingNormalize(?Node node, ?goog.dom.AbstractRange range) ⇒ ?goog.dom.AbstractRange` Normalizes the node, preserving a range of the document. May also normalize things outside the node, if it is more efficient to do so.
| `saveUsingNormalizedCarets(?goog.dom.AbstractRange range) ⇒ ?goog.dom.SavedCaretRange` Saves the range by inserting carets into the HTML. Unlike the regular saveUsingCarets, this SavedRange normalizes text nodes. Browsers have other bugs where they don't handle split text nodes in contentEditable regions right.
| `selectNodeStart(?Node node)` Cause the window's selection to be the start of this node.
| `selectionPreservingNormalize(?Node node)` Normalizes the node, preserving the selection of the document. May also normalize things outside the node, if it is more efficient to do so.