Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

TextSelection

A text selection represents a classical editor selection, with a head (the moving side) and anchor (immobile side), both of which point into textblock nodes. It can be empty (a regular cursor position).

class TextSelection extends Selection {
constructor($anchor: ResolvedPos, $head?: ResolvedPos);
get $cursor(): ResolvedPos | null;
 
eq(other: Selection): boolean;
getBookmark(): TextBookmark;
map(doc: Node, mapping: Mappable): Selection;
replace(tr: Transaction, content?: Slice): void;
toJSON(): any;
 
static between(
$anchor: ResolvedPos,
$head: ResolvedPos,
bias?: number,
): Selection;
static create(
doc: Node,
anchor: number,
head?: number,
): TextSelection;
}

§Extends

§
Selection
[src]

§Constructors

§
new TextSelection($anchor: ResolvedPos, $head?: ResolvedPos)
[src]

Construct a text selection between the given points.

§Properties

§
$cursor: ResolvedPos | null readonly
[src]

Returns a resolved position if this is a cursor selection (an empty text selection), and null otherwise.

§Methods

§
eq(other: Selection): boolean
[src]
§
getBookmark(): TextBookmark
[src]
§
map(doc: Node, mapping: Mappable): Selection
[src]
§
replace(tr: Transaction, content?: Slice): void
[src]
§
toJSON(): any
[src]

§Static Methods

§
between($anchor: ResolvedPos, $head: ResolvedPos, bias?: number): Selection
[src]

Return a text selection that spans the given positions or, if they aren't text positions, find a text selection near them. bias determines whether the method searches forward (default) or backwards (negative number) first. Will fall back to calling Selection.near when the document doesn't contain a valid text position.

§
create(doc: Node, anchor: number, head?: number): TextSelection
[src]

Create a text selection from non-resolved positions.