Create a node selection. Does not verify the validity of its argument.
Readonly$anchorThe resolved anchor of the selection (the side that stays in place when the selection is modified).
Readonly$headThe resolved head of the selection (the side that moves when the selection is modified).
The selected node.
The ranges covered by the selection.
Controls whether, when a selection of this type is active in the
browser, the selected range should be visible to the user.
Defaults to true.
The resolved lower bound of the selection's main range.
The resolved upper bound of the selection's main range.
The selection's anchor, as an unresolved position.
Indicates whether the selection contains any content.
The lower bound of the selection's main range.
The selection's head.
The upper bound of the selection's main range.
Get the content of this selection as a slice.
Test whether the selection is the same as another selection.
Get a bookmark for this selection, which is a value that can be mapped without having access to a current document, and later resolved to a real selection for a given document again. (This is used mostly by the history to track and restore old selections.) The default implementation of this method just converts the selection to a text selection and returns the bookmark for that.
Map this selection through a mappable
thing. doc should be the new document to which we are mapping.
Replace the selection with a slice or, if no slice is given, delete the selection. Will append to the given transaction.
Optionalcontent: SliceReplace the selection with the given node, appending the changes to the given transaction.
Convert the selection to a JSON representation. When implementing
this for a custom selection class, make sure to give the object a
type property whose value matches the ID under which you
registered your class.
StaticatFind the cursor or leaf node selection closest to the end of the given document.
StaticatFind the cursor or leaf node selection closest to the start of
the given document. Will return an
AllSelection if no valid position
exists.
StaticcreateCreate a node selection from non-resolved positions.
StaticfindFind a valid cursor or leaf node selection starting at the given
position and searching back if dir is negative, and forward if
positive. When textOnly is true, only consider cursor
selections. Will return null when no valid selection position is
found.
OptionaltextOnly: booleanStaticfromDeserialize the JSON representation of a selection. Must be implemented for custom classes (as a static class method).
StaticisDetermines whether the given node may be selected as a node selection.
StaticjsonTo be able to deserialize selections from JSON, custom selection classes must register themselves with an ID string, so that they can be disambiguated. Try to pick something that's unlikely to clash with classes from other modules.
StaticnearFind a valid cursor or leaf node selection near the given
position. Searches forward first by default, but if bias is
negative, it will search backwards first.
Optionalbias: number
A node selection is a selection that points at a single node. All nodes marked selectable can be the target of a node selection. In such a selection,
fromandtopoint directly before and after the selected node,anchorequalsfrom, andheadequalsto..