···11import { EditorView, basicSetup } from "codemirror"
22-import { EditorState } from "@codemirror/state"
33-import { hoverTooltip } from "@codemirror/view"
22+import { EditorState, RangeSet } from "@codemirror/state"
33+import { hoverTooltip, Decoration, WidgetType } from "@codemirror/view"
44import * as lint from "@codemirror/lint"
55import * as autocomplete from "@codemirror/autocomplete"
66import * as dark from "@codemirror/theme-one-dark"
···10101111joo_global_object.__CM__view = EditorView;
1212joo_global_object.__CM__state = EditorState;
1313+joo_global_object.__CM__rangeSet = RangeSet;
1414+joo_global_object.__CM__decoration = Decoration;
1515+joo_global_object.__CM__widgetType = WidgetType;
1316joo_global_object.__CM__lint = lint;
1417joo_global_object.__CM__autocomplete = autocomplete;
1518joo_global_object.__CM__hoverTooltip = hoverTooltip;
+1
src/code_mirror.ml
···11module Editor = Editor
22module Text = Text
33module Extension = Extension
44+module Decoration = Decoration
+50
src/decoration.ml
···11+module Widget = struct
22+ type t = Jv.t
33+44+ include (Jv.Id : Jv.CONV with type t := t)
55+66+ let widget_type = Jv.get Jv.global "__CM__widgetType"
77+88+ let make to_dom =
99+ let w = Jv.new' widget_type [||] in
1010+ Jv.set w "toDOM" (Jv.callback ~arity:1 (fun _view -> to_dom ()));
1111+ w
1212+end
1313+1414+type t = Jv.t
1515+1616+include (Jv.Id : Jv.CONV with type t := t)
1717+1818+let decoration = Jv.get Jv.global "__CM__decoration"
1919+2020+let widget ?block ?side w =
2121+ let block =
2222+ match block with None -> [] | Some b -> [ ("block", Jv.of_bool b) ]
2323+ in
2424+ let side =
2525+ match side with None -> [] | Some s -> [ ("side", Jv.of_int s) ]
2626+ in
2727+ let spec =
2828+ Jv.obj (Array.of_list (("widget", Widget.to_jv w) :: (block @ side)))
2929+ in
3030+ Jv.call decoration "widget" [| spec |] |> of_jv
3131+3232+module Range = struct
3333+ type t = Jv.t
3434+3535+ include (Jv.Id : Jv.CONV with type t := t)
3636+end
3737+3838+let range ~from ~to_ t =
3939+ Jv.call t "range" [| Jv.of_int from; Jv.of_int to_ |] |> Range.of_jv
4040+4141+module Range_set = struct
4242+ type t = Jv.t
4343+4444+ include (Jv.Id : Jv.CONV with type t := t)
4545+4646+ let range_set = Jv.get Jv.global "__CM__rangeSet"
4747+4848+ let of' ranges =
4949+ Jv.call range_set "of" [| Jv.of_array Range.to_jv ranges |] |> of_jv
5050+end
+29
src/decoration.mli
···11+module Widget : sig
22+ type t
33+44+ include Jv.CONV with type t := t
55+66+ val make : (unit -> Brr.El.t) -> t
77+end
88+99+type t
1010+1111+include Jv.CONV with type t := t
1212+1313+val widget : ?block:bool -> ?side:int -> Widget.t -> t
1414+1515+module Range : sig
1616+ type t
1717+1818+ include Jv.CONV with type t := t
1919+end
2020+2121+val range : from:int -> to_:int -> t -> Range.t
2222+2323+module Range_set : sig
2424+ type t
2525+2626+ include Jv.CONV with type t := t
2727+2828+ val of' : Range.t array -> t
2929+end
+10-1
src/editor.ml
···108108109109 let dom t = Jv.get t "dom" |> Brr.El.of_jv
110110111111- let update_listener _ : (Update.t -> unit, Jv.t) State.facet =
111111+ let update_listener () : (Update.t -> unit, Jv.t) State.facet =
112112 let module F = State.FacetMaker (Func (Update)) in
113113 let jv = Jv.get g "updateListener" in
114114 Facet ((module F), F.of_jv jv)
115115+116116+ let decorations () : (Decoration.Range_set.t, Jv.t) State.facet =
117117+ let module F = State.FacetMaker (Decoration.Range_set) in
118118+ let jv = Jv.get g "decorations" in
119119+ Facet ((module F), F.of_jv jv)
120120+121121+ let request_measure t =
122122+ let _ = Jv.call t "requestMeasure" [||] in
123123+ ()
115124116125 let line_wrapping () = Jv.get g "lineWrapping" |> Extension.of_jv
117126
+2
src/editor.mli
···81818282 val dom : t -> Brr.El.t
8383 val update_listener : unit -> (Update.t -> unit, Jv.t) State.facet
8484+ val decorations : unit -> (Decoration.Range_set.t, Jv.t) State.facet
8585+ val request_measure : t -> unit
8486 val line_wrapping : unit -> Extension.t
8587 val set_doc : t -> Jstr.t -> unit
8688end