aboutsummaryrefslogtreecommitdiff
path: root/editor/state/state.mli
blob: 4376723fc628fd297c552bf58baf84256f06b9b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
module Js = Js_of_ocaml.Js
module Storage = Storage

type t =
  { editable : bool
  ; view : Prosemirror.View.editor_view Js.t
  ; last_backup: float
  ; page_id: Jstr.t option

  ; window : Brr.El.t list
  ; pm : Prosemirror.t
  }


val eq: t -> t -> bool

(** Update the title element according to the page. *)
val set_title
  : Storage.content Js.t -> unit

val state_of_storage
  : Prosemirror.t -> Storage.content Js.t -> Prosemirror.Model.schema Js.t -> Prosemirror.State.editor_state Js.t

val load_page
  : Jstr.t option -> t -> t

(** Create a new empty page, and load it *)
val new_page
  : Jstr.t option -> title:Jstr.t -> t -> t

(** Initialise a new state *)
val init
  : Prosemirror.t -> Prosemirror.View.editor_view Js.t -> float -> Jstr.t option ->  t

type state = t
module type Event = sig

  type t

  val update: t -> state -> state

end

type event = E : 'a * (module Event with type t = 'a) -> event

(** Simple helper for the main event loop *)
val run
  : ?eq:(t -> t -> bool) -> t -> event Note.E.t -> state Note.S.t