Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file brr_ext.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311openBrrmoduleEv=structincludeEv(** Event type for the
{{:https://developer.mozilla.org/en-US/docs/Web/API/Document/selectionchange_event}
[selectionchange]} event, fired on the document when the current text
selection changes. *)letselectionchange:void=Type.create(Jstr.v"selectionchange")endmoduleEl=structincludeEl(** [inner_text el] gets the
{{:https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/innerText}
innerText} property of the element [el], representing the rendered text
content of the node and its descendants. *)letinner_text(el:El.t):Jstr.t=El.prop(El.Prop.jstr(Jstr.v"innerText"))el(** [text_content el] gets the
{{:https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent}
textContent} property of the element [el], representing the text content
of the node and its descendants. *)lettext_content(el:El.t):Jstr.t=El.prop(El.Prop.jstr(Jstr.v"textContent"))elendmodulerecSelection:sig(** {1 Selection} *)typet=Jv.t(** The type for
{{:https://developer.mozilla.org/en-US/docs/Web/API/Selection} Selection}
objects. Represents the currently selected text or the caret position. *)valof_jv:Jv.t->t(** [of_jv jv] converts the JavaScript value [jv] to a selection object. *)valto_jv:t->Jv.t(** [to_jv sel] converts the selection object [sel] to its underlying
JavaScript value. *)valanchor_node:t->Jv.toption(** [anchor_node sel] is the
{{:https://developer.mozilla.org/en-US/docs/Web/API/Selection/anchorNode}
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. *)valfocus_node:t->Jv.toption(** [focus_node sel] is the
{{:https://developer.mozilla.org/en-US/docs/Web/API/Selection/focusNode}
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. *)valanchor_offset:t->int(** [anchor_offset sel] is the
{{:https://developer.mozilla.org/en-US/docs/Web/API/Selection/anchorOffset}
anchor offset} of the selection [sel]. This is the offset within the
{!anchor_node} where the selection begins. *)valfocus_offset:t->int(** [focus_offset sel] is the
{{:https://developer.mozilla.org/en-US/docs/Web/API/Selection/focusOffset}
focus offset} of the selection [sel]. This is the offset within the
{!focus_node} where the selection ends. *)valis_collapsed:t->bool(** [is_collapsed sel] gets the
{{:https://developer.mozilla.org/en-US/docs/Web/API/Selection/isCollapsed}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). *)valrange_count:t->int(** [range_count sel] is the
{{:https://developer.mozilla.org/en-US/docs/Web/API/Selection/rangeCount}
range count} of the selection [sel]. Typically, this is 1, even for a
collapsed selection (caret). *)valget_range_at:t->int->Range.t(** [get_range_at sel index] gets the
{{:https://developer.mozilla.org/en-US/docs/Web/API/Selection/getRangeAt}
Range object} at the specified [index] within the selection [sel]. Most
selections only have one range (at index 0). *)valadd_range:t->Range.t->unit(** [add_range sel range]
{{:https://developer.mozilla.org/en-US/docs/Web/API/Selection/addRange}
adds} the given [range] to the selection [sel]. *)valremove_all_ranges:t->unit(** [remove_all_ranges sel]
{{:https://developer.mozilla.org/en-US/docs/Web/API/Selection/removeAllRanges}
removes all ranges} from the selection [sel], effectively deselecting any
selected text. *)valcollapse:t->Jv.t->int->unit(** [collapse sel node_jv offset]
{{:https://developer.mozilla.org/en-US/docs/Web/API/Selection/collapse}
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]. *)end=structtypet=Jv.tletof_jv(jv:Jv.t):t=jvletto_jv(sel:t):Jv.t=selletanchor_node(sel:t):Jv.toption=Jv.findsel"anchorNode"letfocus_node(sel:t):Jv.toption=Jv.findsel"focusNode"letanchor_offset(sel:t):int=Jv.Int.getsel"anchorOffset"letfocus_offset(sel:t):int=Jv.Int.getsel"focusOffset"letis_collapsed(sel:t):bool=Jv.Bool.getsel"isCollapsed"letrange_count(sel:t):int=Jv.Int.getsel"rangeCount"letget_range_at(sel:t)(index:int):Range.t=Range.of_jv@@Jv.callsel"getRangeAt"[|Jv.of_intindex|]letadd_range(sel:t)(range:Range.t):unit=Jv.callsel"addRange"[|Range.to_jvrange|]|>ignoreletremove_all_ranges(sel:t):unit=Jv.callsel"removeAllRanges"[||]|>ignoreletcollapse(sel:t)(node_jv:Jv.t)(offset:int):unit=Jv.callsel"collapse"[|node_jv;Jv.of_intoffset|]|>ignoreendandRange:sig(** {1 Range} *)typet(** The type for
{{:https://developer.mozilla.org/en-US/docs/Web/API/Range} Range} objects.
Represents a contiguous part of a document. *)valof_jv:Jv.t->t(** [of_jv jv] converts the JavaScript value [jv] to a range object. *)valto_jv:t->Jv.t(** [to_jv r] converts the range object [r] to its underlying JavaScript
value. *)valstart_container:t->Jv.t(** [start_container r] is the
{{:https://developer.mozilla.org/en-US/docs/Web/API/Range/startContainer}
start container} node of the range [r]. Returns the raw JavaScript value
([Jv.t]) for the node. *)valend_container:t->Jv.t(** [end_container r] is the
{{:https://developer.mozilla.org/en-US/docs/Web/API/Range/endContainer}
end container} node of the range [r]. Returns the raw JavaScript value
([Jv.t]) for the node. *)valcommon_ancestor_container:t->Jv.t(** [common_ancestor_container r] is the deepest node that contains both the
start and end containers of the range [r]. See
{{:https://developer.mozilla.org/en-US/docs/Web/API/Range/commonAncestorContainer}
commonAncestorContainer}. Returns the raw JavaScript value ([Jv.t]) for
the node. *)valstart_offset:t->int(** [start_offset r] is the offset within the {!start_container} where the
range [r] begins. See
{{:https://developer.mozilla.org/en-US/docs/Web/API/Range/startOffset}
startOffset}. *)valend_offset:t->int(** [end_offset r] is the offset within the {!end_container} where the range
[r] ends. See
{{:https://developer.mozilla.org/en-US/docs/Web/API/Range/endOffset}
endOffset}. *)valcollapsed:t->bool(** [collapsed r] is the
{{:https://developer.mozilla.org/en-US/docs/Web/API/Range/collapsed}
collapsed} state of the range [r]. Returns [true] if the range's start
and end points are the same. *)valset_start:t->Jv.t->int->unit(** [set_start r node_jv offset]
{{:https://developer.mozilla.org/en-US/docs/Web/API/Range/setStart} sets
the start} of the range [r] to [offset] within the node represented by
the raw JavaScript value [node_jv]. *)valset_end:t->Jv.t->int->unit(** [set_end r node_jv offset]
{{:https://developer.mozilla.org/en-US/docs/Web/API/Range/setEnd} sets the
end} of the range [r] to [offset] within the node represented by the raw
JavaScript value [node_jv]. *)valset_start_before:t->Jv.t->unit(** [set_start_before r node_jv]
{{:https://developer.mozilla.org/en-US/docs/Web/API/Range/setStartBefore}
sets the start} of the range [r] to be immediately before the node
represented by the raw JavaScript value [node_jv]. *)valset_start_after:t->Jv.t->unit(** [set_start_after r node_jv]
{{:https://developer.mozilla.org/en-US/docs/Web/API/Range/setStartAfter}
sets the start} of the range [r] to be immediately after the node
represented by the raw JavaScript value [node_jv]. *)valcollapse:t->bool->unit(** [collapse r to_start]
{{:https://developer.mozilla.org/en-US/docs/Web/API/Range/collapse}
collapses} the range [r] to one of its boundary points. If [to_start] is
[true], collapses to the start point; otherwise, collapses to the end
point. *)valselect_node:t->Jv.t->unit(** [select_node r node_jv]
{{:https://developer.mozilla.org/en-US/docs/Web/API/Range/selectNode} sets
the range [r]} to contain the node represented by the raw JavaScript
value [node_jv] and all of its contents. *)valselect_node_contents:t->Jv.t->unit(** [select_node_contents r node_jv]
{{:https://developer.mozilla.org/en-US/docs/Web/API/Range/selectNodeContents}
sets the range [r]} to contain the contents within the node represented
by the raw JavaScript value [node_jv]. *)valdelete_contents:t->unit(** [delete_contents r]
{{:https://developer.mozilla.org/en-US/docs/Web/API/Range/deleteContents}
deletes} the contents of the range [r]. This removes the selected text
from the document. *)valclone:t->t(** [clone r] creates a
{{:https://developer.mozilla.org/en-US/docs/Web/API/Range/cloneRange}
copy} of the range [r]. This is a new range object with the same start
and end points. *)valto_string:t->Jstr.t(** [to_string r] gets the
{{:https://developer.mozilla.org/en-US/docs/Web/API/Range/toString} string
representation} of the range [r]. This is the text content of the range.
*)end=structtypet=Jv.tletof_jv(jv:Jv.t):t=jvletto_jv(r:t):Jv.t=r(* These return Jv.t for nodes *)letstart_container(r:t):Jv.t=Jv.getr"startContainer"letend_container(r:t):Jv.t=Jv.getr"endContainer"letcommon_ancestor_container(r:t):Jv.t=Jv.getr"commonAncestorContainer"(* Getters for offsets/collapsed state *)letstart_offset(r:t):int=Jv.Int.getr"startOffset"letend_offset(r:t):int=Jv.Int.getr"endOffset"letcollapsed(r:t):bool=Jv.Bool.getr"collapsed"(* Setters take Jv.t for nodes *)letset_start(r:t)(node_jv:Jv.t)(offset:int):unit=Jv.callr"setStart"[|node_jv;Jv.of_intoffset|]|>ignoreletset_end(r:t)(node_jv:Jv.t)(offset:int):unit=Jv.callr"setEnd"[|node_jv;Jv.of_intoffset|]|>ignoreletset_start_before(r:t)(node_jv:Jv.t):unit=Jv.callr"setStartBefore"[|node_jv|]|>ignoreletset_start_after(r:t)(node_jv:Jv.t):unit=Jv.callr"setStartAfter"[|node_jv|]|>ignoreletcollapse(r:t)(to_start:bool):unit=Jv.callr"collapse"[|Jv.of_boolto_start|]|>ignoreletselect_node(r:t)(node_jv:Jv.t):unit=Jv.callr"selectNode"[|node_jv|]|>ignoreletselect_node_contents(r:t)(node_jv:Jv.t):unit=Jv.callr"selectNodeContents"[|node_jv|]|>ignoreletdelete_contents(r:t):unit=Jv.callr"deleteContents"[||]|>ignoreletclone(r:t):t=Jv.callr"cloneRange"[||]|>of_jvletto_string(r:t):Jstr.t=Jv.callr"toString"[||]|>Jv.to_jstrendmoduleWindow=structincludeWindow(** [get_selection window] gets the
{{:https://developer.mozilla.org/en-US/docs/Web/API/Window/getSelection}
selection} object for the given [window]. *)letget_selection(window:Window.t):Selection.toption=letsel=Jv.call(to_jvwindow)"getSelection"[||]inifJv.is_nullsel||Jv.is_undefinedselthenNoneelseSome(Selection.of_jvsel)endmoduleDocument=structincludeDocumentletcreate_range(doc:Document.t):Range.t=Jv.call(to_jvdoc)"createRange"[||]|>Range.of_jvletget_selection(doc:Document.t):Selection.toption=letsel=Jv.call(to_jvdoc)"getSelection"[||]inifJv.is_nullsel||Jv.is_undefinedselthenNoneelseSome(Selection.of_jvsel)end