Selection extension type
A Selection
object represents the range of text selected by the user
or the current position of the caret. To obtain a Selection
object for
examination or manipulation, call window.getSelection
.
A user may make a selection from left to right (in document order) or right to left (reverse of document order). The anchor is where the user began the selection and the focus is where the user ends the selection. If you make a selection with a desktop mouse, the anchor is placed where you pressed the mouse button, and the focus is placed where you released the mouse button.
Note: Anchor and focus should not be confused with the start and end positions of a selection. The anchor can be placed before the focus or vice versa, depending on the direction you made your selection.
- on
- Implemented types
- Available extensions
Properties
- anchorNode → Node?
-
no setter
- anchorOffset → int
-
no setter
- direction → String
-
no setter
- focusNode → Node?
-
no setter
- focusOffset → int
-
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- isCollapsed → bool
-
no setter
- isDefinedAndNotNull → bool
-
Available on JSAny?, provided by the NullableUndefineableJSAnyExtension extension
no setter - isNull → bool
-
Available on JSAny?, provided by the NullableUndefineableJSAnyExtension extension
Whether this value corresponds to JavaScriptnull
.no setter - isTruthy → JSBoolean
-
Available on JSAny?, provided by the JSAnyOperatorExtension extension
The result of!!
in JavaScript.this
no setter - isUndefined → bool
-
Available on JSAny?, provided by the NullableUndefineableJSAnyExtension extension
Whether this value corresponds to JavaScriptundefined
.no setter - isUndefinedOrNull → bool
-
Available on JSAny?, provided by the NullableUndefineableJSAnyExtension extension
no setter - not → JSBoolean
-
Available on JSAny?, provided by the JSAnyOperatorExtension extension
The result of!
in JavaScript.this
no setter - rangeCount → int
-
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- type → String
-
no setter
Methods
-
add(
JSAny? any) → JSAny -
Available on JSAny?, provided by the JSAnyOperatorExtension extension
The result of
in JavaScript.this
+any
-
addRange(
Range range) → void -
The
Selection.addRange()
method adds a Range to a Selection. -
and(
JSAny? any) → JSAny? -
Available on JSAny?, provided by the JSAnyOperatorExtension extension
The result of
in JavaScript.this
&&any
-
callMethod<
R extends JSAny?> (JSAny method, [JSAny? arg1, JSAny? arg2, JSAny? arg3, JSAny? arg4]) → R -
Available on JSObject, provided by the JSObjectUnsafeUtilExtension extension
Callsmethod
on this JSObject with up to four arguments. -
callMethodVarArgs<
R extends JSAny?> (JSAny method, [List< JSAny?> ? arguments]) → R -
Available on JSObject, provided by the JSObjectUnsafeUtilExtension extension
Callsmethod
on this JSObject with a variable number ofarguments
. -
collapse(
Node? node, [int offset]) → void -
The
Selection.collapse()
method collapses the current selection to a single point. The document is not modified. If the content is focused and editable, the caret will blink there. -
collapseToEnd(
) → void -
The
Selection.collapseToEnd()
method collapses the selection to the end of the last range in the selection. If the content of the selection is focused and editable, the caret will blink there. -
collapseToStart(
) → void -
The
Selection.collapseToStart()
method collapses the selection to the start of the first range in the selection. If the content of the selection is focused and editable, the caret will blink there. -
containsNode(
Node node, [bool allowPartialContainment]) → bool -
The
Selection.containsNode()
method indicates whether a specified node is part of the selection. -
dartify(
) → Object? -
Available on JSAny?, provided by the JSAnyUtilityExtension extension
Converts a JavaScript value to the Dart equivalent if possible. -
delete(
JSAny property) → JSBoolean -
Available on JSObject, provided by the JSObjectUnsafeUtilExtension extension
Deletes the property with keyproperty
from this JSObject. -
deleteFromDocument(
) → void -
The
deleteFromDocument()
method of the Selection interface deletes the selected text from the document's DOM. -
divide(
JSAny? any) → JSAny -
Available on JSAny?, provided by the JSAnyOperatorExtension extension
The result of
in JavaScript.this
/any
-
empty(
) → void -
The
Selection.empty()
method removes all ranges from the selection, leaving the Selection.anchorNode and Selection.focusNode properties equal tonull
and nothing selected. When this method is called, aDocument/selectionchange_event
event is fired at the document. -
equals(
JSAny? any) → JSBoolean -
Available on JSAny?, provided by the JSAnyOperatorExtension extension
The result of
in JavaScript.this
==any
-
exponentiate(
JSAny? any) → JSAny -
Available on JSAny?, provided by the JSAnyOperatorExtension extension
The result of
in JavaScript.this
**any
-
extend(
Node node, [int offset]) → void -
The
Selection.extend()
method moves the focus of the selection to a specified point. The anchor of the selection does not move. The selection will be from the anchor to the new focus, regardless of direction. -
getComposedRanges(
ShadowRoot shadowRoots) → JSArray< StaticRange> -
getProperty<
R extends JSAny?> (JSAny property) → R -
Available on JSObject, provided by the JSObjectUnsafeUtilExtension extension
The value of the property keyproperty
of this JSObject. -
getRangeAt(
int index) → Range -
The
Selection.getRangeAt()
method returns a range object representing one of the ranges currently selected. -
greaterThan(
JSAny? any) → JSBoolean -
Available on JSAny?, provided by the JSAnyOperatorExtension extension
The result of
in JavaScript.this
>any
-
greaterThanOrEqualTo(
JSAny? any) → JSBoolean -
Available on JSAny?, provided by the JSAnyOperatorExtension extension
The result of
in JavaScript.this
>=any
-
has(
String property) → bool -
Available on JSObject, provided by the JSObjectUnsafeUtilExtension extension
Shorthand helper for hasProperty to check whether this JSObject contains the property keyproperty
, but takes and returns a Dart value. -
hasProperty(
JSAny property) → JSBoolean -
Available on JSObject, provided by the JSObjectUnsafeUtilExtension extension
Whether or not this JSObject contains the property keyproperty
. -
instanceof(
JSFunction constructor) → bool -
Available on JSAny?, provided by the JSAnyUtilityExtension extension
Whether thisJSAny?
is aninstanceof
constructor
. -
instanceOfString(
String constructorName) → bool -
Available on JSAny?, provided by the JSAnyUtilityExtension extension
Whether thisJSAny?
is aninstanceof
the constructor that is defined byconstructorName
, which is looked up in the globalContext. -
isA<
T extends JSAny?> () → bool -
Available on JSAny?, provided by the JSAnyUtilityExtension extension
Whether thisJSAny?
is an instance of the JavaScript type that is declared byT
. -
lessThan(
JSAny? any) → JSBoolean -
Available on JSAny?, provided by the JSAnyOperatorExtension extension
The result of
in JavaScript.this
<any
-
lessThanOrEqualTo(
JSAny? any) → JSBoolean -
Available on JSAny?, provided by the JSAnyOperatorExtension extension
The result of
in JavaScript.this
<=any
-
modify(
[String alter, String direction, String granularity]) → void -
The
Selection.modify()
method applies a change to the current selection or cursor position, using simple textual commands. -
modulo(
JSAny? any) → JSAny -
Available on JSAny?, provided by the JSAnyOperatorExtension extension
The result of
in JavaScript.this
%any
-
multiply(
JSAny? any) → JSAny -
Available on JSAny?, provided by the JSAnyOperatorExtension extension
The result of
in JavaScript.this
*any
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notEquals(
JSAny? any) → JSBoolean -
Available on JSAny?, provided by the JSAnyOperatorExtension extension
The result of
in JavaScript.this
!=any
-
or(
JSAny? any) → JSAny? -
Available on JSAny?, provided by the JSAnyOperatorExtension extension
The result of
in JavaScript.this
||any
-
removeAllRanges(
) → void -
The
Selection.removeAllRanges()
method removes all ranges from the selection, leaving the Selection.anchorNode and Selection.focusNode properties equal tonull
and nothing selected. When this method is called, aDocument/selectionchange_event
event is fired at the document. -
removeRange(
Range range) → void -
The
Selection.removeRange()
method removes a range from a selection. -
selectAllChildren(
Node node) → void -
The
Selection.selectAllChildren()
method adds all the children of the specified node to the selection. Previous selection is lost. -
setBaseAndExtent(
Node anchorNode, int anchorOffset, Node focusNode, int focusOffset) → void -
The
setBaseAndExtent()
method of the Selection interface sets the selection to be a range including all or parts of two specified DOM nodes, and any content located between them. -
setPosition(
Node? node, [int offset]) → void -
The
Selection.setPosition()
method collapses the current selection to a single point. The document is not modified. If the content is focused and editable, the caret will blink there. -
setProperty(
JSAny property, JSAny? value) → void -
Available on JSObject, provided by the JSObjectUnsafeUtilExtension extension
Write thevalue
of property keyproperty
of this JSObject. -
strictEquals(
JSAny? any) → JSBoolean -
Available on JSAny?, provided by the JSAnyOperatorExtension extension
The result of
in JavaScript.this
===any
-
strictNotEquals(
JSAny? any) → JSBoolean -
Available on JSAny?, provided by the JSAnyOperatorExtension extension
The result of
in JavaScript.this
!==any
-
subtract(
JSAny? any) → JSAny -
Available on JSAny?, provided by the JSAnyOperatorExtension extension
The result of
in JavaScript.this
-any
-
toString(
) → String -
A string representation of this object.
inherited
-
typeofEquals(
String typeString) → bool -
Available on JSAny?, provided by the JSAnyUtilityExtension extension
Whether the result oftypeof
on thisJSAny?
istypeString
. -
unsignedRightShift(
JSAny? any) → JSNumber -
Available on JSAny?, provided by the JSAnyOperatorExtension extension
The result of
in JavaScript.this
>>>any
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
-
operator [](
String property) → JSAny? -
Available on JSObject, provided by the JSObjectUnsafeUtilExtension extension
Shorthand helper for getProperty to get the value of the property keyproperty
of this JSObject, but takes and returns a Dart value. -
operator []=(
String property, JSAny? value) → void -
Available on JSObject, provided by the JSObjectUnsafeUtilExtension extension
Shorthand helper for setProperty to write thevalue
of the property keyproperty
of this JSObject, but takes a Dart value.