package quill

  1. Overview
  2. Docs

Module Brr_ext.Selection

Selection

Sourcetype t = Jv.t

The type for Selection objects. Represents the currently selected text or the caret position.

Sourceval of_jv : Jv.t -> t

of_jv jv converts the JavaScript value jv to a selection object.

Sourceval to_jv : t -> Jv.t

to_jv sel converts the selection object sel to its underlying JavaScript value.

Sourceval anchor_node : t -> Jv.t option

anchor_node sel is the anchor node of the selection sel (if any). This is the node where the user began the selection. Returns the raw JavaScript value (Jv.t) for the node.

Sourceval focus_node : t -> Jv.t option

focus_node sel is the focus node of the selection sel (if any). This is the node where the user ended the selection. Returns the raw JavaScript value (Jv.t) for the node.

Sourceval anchor_offset : t -> int

anchor_offset sel is the anchor offset of the selection sel. This is the offset within the anchor_node where the selection begins.

Sourceval focus_offset : t -> int

focus_offset sel is the focus offset of the selection sel. This is the offset within the focus_node where the selection ends.

Sourceval is_collapsed : t -> bool

is_collapsed sel gets the isCollapsed property of the selection sel. Returns true if the selection's start and end points are at the same position (i.e., it's a caret).

Sourceval range_count : t -> int

range_count sel is the range count of the selection sel. Typically, this is 1, even for a collapsed selection (caret).

Sourceval get_range_at : t -> int -> Range.t

get_range_at sel index gets the Range object at the specified index within the selection sel. Most selections only have one range (at index 0).

Sourceval add_range : t -> Range.t -> unit

add_range sel range adds the given range to the selection sel.

Sourceval remove_all_ranges : t -> unit

remove_all_ranges sel removes all ranges from the selection sel, effectively deselecting any selected text.

Sourceval collapse : t -> Jv.t -> int -> unit

collapse sel node_jv offset collapses the selection sel to a single point (caret) located at the specified offset within the node represented by the raw JavaScript value node_jv.

OCaml

Innovation. Community. Security.