range.js
No description.

File Location

/goog/editor/range.js

Classes

goog.editor.range.NormalizedCaretRange_
Saves the range using carets, but normalizes text nodes when carets are removed.
goog.editor.range.Point
One endpoint of a range, represented as a Node and and offset.

Public Protected Private

Global Functions

goog.editor.range.Point.createDeepestPoint(nodeoffsetopt_trendLeftopt_stopOnChildlessElement) !goog.editor.range.Point
Construct the deepest possible point in the DOM that's equivalent to the given point, expressed as a node and an offset.
Arguments:
node : Node
The node containing the point.
offset : number
The offset of the point from the node.
opt_trendLeft : boolean=
Notice that a (node, offset) pair may be equivalent to more than one descendent (node, offset) pair in the DOM. By default, we trend rightward. If this parameter is true, then we trend leftward. The tendency to fall rightward by default is for consistency with other range APIs (like placeCursorNextTo).
opt_stopOnChildlessElement : boolean=
If true, and we encounter a Node which is an Element that cannot have children, we return a Point based on its parent rather than that Node itself.
Returns: !goog.editor.range.Point  A new point.
code »
goog.editor.range.expand(rangeopt_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.
    Arguments:
    range : goog.dom.AbstractRange
    The range.
    opt_stopNode : Node=
    Optional node to stop expanding past.
    Returns: !goog.dom.AbstractRange  The expanded range.
    code »
    goog.editor.range.expandEndPointToContainer_(rangeendpointopt_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.
    Arguments:
    range : goog.dom.AbstractRange
    The range to expand.
    endpoint : goog.dom.RangeEndpoint
    The endpoint to expand.
    opt_stopNode : Node=
    Optional node to stop expanding past.
    Returns: !goog.dom.AbstractRange  The expanded range.
    code »
    goog.editor.range.getDeepEndPoint(rangeatStart) !goog.editor.range.Point
    Get the deepest point in the DOM that's equivalent to the endpoint of the given range.
    Arguments:
    range : goog.dom.AbstractRange
    A range.
    atStart : boolean
    True for the start point, false for the end point.
    Returns: !goog.editor.range.Point  The end point, expressed as a node and an offset.
    code »
    goog.editor.range.Point.getPointAtEndOfNode(node) !goog.editor.range.Point
    Construct a point at the very end of the given node.
    Arguments:
    node : Node
    The node to create a point for.
    Returns: !goog.editor.range.Point  A new point.
    code »
    goog.editor.range.intersectsTag(rangetagName) boolean
    Returns whether the given range intersects with any instance of the given tag.
    Arguments:
    range : goog.dom.AbstractRange
    The range to check.
    tagName : goog.dom.TagName
    The name of the tag.
    Returns: boolean  Whether the given range intersects with any instance of the given tag.
    code »
    goog.editor.range.isEditable(range) boolean
    Checks if a range is completely inside an editable region.
    Arguments:
    range : goog.dom.AbstractRange
    The range to test.
    Returns: boolean  Whether the range is completely inside an editable region.
    code »
    goog.editor.range.narrow&isElement()
    No description.
    code »
    goog.editor.range.Point.isTerminalElement_(node) boolean
    Return true if the specified node is an Element that is not expected to have children. The createDeepestPoint() method should not traverse into such elements.
    Arguments:
    node : Node
    .
    Returns: boolean  True if the node is an Element that does not contain child nodes (e.g. BR, IMG).
    code »
    goog.editor.range.narrow(rangeel) 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.
    Arguments:
    range : goog.dom.AbstractRange
    The range.
    el : Element
    The element to limit the range to.
    Returns: goog.dom.AbstractRange  A new narrowed range, or null if the element does not contain any part of the given range.
    code »
    goog.editor.range.normalize(range) function(): goog.dom.AbstractRange
    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.
    Arguments:
    range : goog.dom.AbstractRange
    The range to normalize. It may become invalid after body.normalize() is called.
    Returns: function(): goog.dom.AbstractRange  A factory for a normalized range. Should be called after body.normalize() is called.
    code »
    goog.editor.range.normalizeNode(node)
    Normalizes the given node.
    Arguments:
    node : Node
    The node to normalize.
    code »
    goog.editor.range.normalizeNodeIe_(node)
    Manually normalizes the node in IE, since native normalize in IE causes transient problems.
    Arguments:
    node : Node
    The node to normalize.
    code »
    goog.editor.range.normalizePoint_(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.
    Arguments:
    point : goog.editor.range.Point
    A point in the document.
    Returns: !goog.editor.range.Point  The same point, for easy chaining.
    code »
    goog.editor.range.placeCursorNextTo(nodetoLeft) !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
    Arguments:
    node : Node
    The node to position the cursor relative to.
    toLeft : boolean
    True to place it to the left, false to the right.
    Returns: !goog.dom.AbstractRange  The newly selected range.
    code »
    goog.editor.range.rangePreservingNormalize&rangeFactory()
    No description.
    code »
    goog.editor.range.rangePreservingNormalize(noderange) ?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.
    Arguments:
    node : Node
    The node to normalize.
    range : ?goog.dom.AbstractRange
    The range to normalize.
    Returns: ?goog.dom.AbstractRange  The range, adjusted for normalization.
    code »
    goog.editor.range.saveUsingNormalizedCarets(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.
    Arguments:
    range : goog.dom.AbstractRange
    The abstract range object.
    Returns: !goog.dom.SavedCaretRange  A saved caret range that normalizes text nodes.
    code »
    goog.editor.range.selectNodeStart(node)
    Cause the window's selection to be the start of this node.
    Arguments:
    node : Node
    The node to select the start of.
    code »
    goog.editor.range.selectionPreservingNormalize(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.
    Arguments:
    node : Node
    The node to normalize.
    code »

    Directory editor

    File Reference