public class TextRange extends SimpleScriptable
TextRange
(IE only).Constructor and Description |
---|
TextRange()
Default constructor used to build the prototype.
|
TextRange(HTMLElement elt)
Constructs a text range around the provided element.
|
TextRange(org.w3c.dom.ranges.Range range)
Constructs a text range around the provided range.
|
Modifier and Type | Method and Description |
---|---|
void |
collapse(boolean toStart)
Collapses the range.
|
int |
compareEndPoints(String how,
TextRange sourceRange)
Compares an end point of a TextRange object with an end point of another range.
|
protected int |
constrainMoveBy(int moveBy,
int current,
int textLength)
Constrain the given amount to move the range by to the limits of the given current offset and text length.
|
Object |
duplicate()
Duplicates this TextRange instance.
|
String |
getBookmark()
Retrieves a bookmark (opaque string) that can be used with
moveToBookmark(java.lang.String)
to return to the same range. |
String |
getHtmlText()
Retrieves the HTML fragment contained within the range.
|
String |
getText()
Retrieves the text contained within the range.
|
boolean |
inRange(TextRange other)
Indicates if a range is contained in current one.
|
int |
move(String unit,
Object count)
Collapses the given text range and moves the empty range by the given number of units.
|
int |
moveEnd(String unit,
Object count)
Changes the end position of the range.
|
int |
moveStart(String unit,
Object count)
Changes the start position of the range.
|
boolean |
moveToBookmark(String bookmark)
Moves to a bookmark.
|
void |
moveToElementText(HTMLElement element)
Moves the text range so that the start and end positions of the range encompass
the text in the specified element.
|
Node |
parentElement()
Retrieves the parent element for the given text range.
|
void |
select()
Makes the current range the active selection.
|
void |
setEndPoint(String type,
TextRange other)
Sets the endpoint of the range based on the endpoint of another range..
|
void |
setText(String text)
Sets the text contained within the range.
|
clone, equivalentValues, get, getBrowserVersion, getDefaultValue, getDomNodeOrDie, getDomNodeOrNull, getPrototype, getScriptableFor, getStartingScope, getWindow, getWindow, getWithPreemption, has, hasInstance, initParentScope, isReadOnlySettable, makeScriptableFor, setCaseSensitive, setDomNode, setDomNode, setHtmlElement
defineFunctionProperties, defineProperty, getClassName, setClassName, setParentScope
applyDescriptorToAttributeBitset, associateValue, avoidObjectDetection, buildDataDescriptor, callMethod, callMethod, checkPropertyChange, checkPropertyDefinition, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineOwnProperties, defineOwnProperty, defineOwnProperty, defineProperty, defineProperty, defineProperty, delete, delete, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, get, get, getAllIds, getArrayPrototype, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getClassPrototype, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGetterOrSetter, getIds, getObjectPrototype, getOwnPropertyDescriptor, getParentScope, getProperty, getProperty, getPropertyIds, getPrototype, getSlot, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, getTypeOf, has, hasProperty, hasProperty, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGetterOrSetter, isSealed, isTrue, preventExtensions, put, put, putConst, putConstProperty, putProperty, putProperty, redefineProperty, sameValue, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setExternalArrayData, setGetterOrSetter, setPrototype, size
public TextRange()
public TextRange(HTMLElement elt)
elt
- the element to wrappublic TextRange(org.w3c.dom.ranges.Range range)
range
- the initial rangepublic String getText()
public void setText(String text)
text
- the text contained within the rangepublic String getHtmlText()
public Object duplicate()
public Node parentElement()
public void collapse(boolean toStart)
toStart
- indicates if collapse should be done to the startpublic void select()
public int moveStart(String unit, Object count)
unit
- specifies the units to movecount
- the number of units to movepublic int move(String unit, Object count)
unit
- specifies the units to movecount
- the number of units to movepublic int moveEnd(String unit, Object count)
unit
- specifies the units to movecount
- the number of units to movepublic void moveToElementText(HTMLElement element)
element
- the element to move topublic boolean inRange(TextRange other)
other
- the other rangetrue
if other
is contained within current rangepublic void setEndPoint(String type, TextRange other)
type
- end point transfer type. One of "StartToEnd", "StartToStart", "EndToStart" and "EndToEnd"other
- the other rangeprotected int constrainMoveBy(int moveBy, int current, int textLength)
moveBy
- the amount to move bycurrent
- the current indextextLength
- the text lengthpublic String getBookmark()
moveToBookmark(java.lang.String)
to return to the same range.
The current implementation return empty stringpublic boolean moveToBookmark(String bookmark)
bookmark
- the bookmarkfalse
Copyright © 2002–2016 Gargoyle Software Inc.. All rights reserved.