summaryrefslogtreecommitdiff
path: root/editor/state
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@dailly.me>2022-02-07 15:49:48 +0100
committerSébastien Dailly <sebastien@dailly.me>2022-02-07 16:43:33 +0100
commit54f6e68c051afec0d20c349352feee5356e11b35 (patch)
treeb9cf8c7c64538728c9f6e864896c00d32641b834 /editor/state
parentfe2cced55e1b44dbae57e55fe0f459c85e7369cb (diff)
Update editor code
Diffstat (limited to 'editor/state')
-rwxr-xr-xeditor/state/dune1
-rwxr-xr-xeditor/state/state.ml3
-rwxr-xr-xeditor/state/state.mli16
3 files changed, 20 insertions, 0 deletions
diff --git a/editor/state/dune b/editor/state/dune
index dd405a1..b61174d 100755
--- a/editor/state/dune
+++ b/editor/state/dune
@@ -2,6 +2,7 @@
(name state)
(libraries
brr
+ application
prosemirror
plugins
)
diff --git a/editor/state/state.ml b/editor/state/state.ml
index 569f26c..649473c 100755
--- a/editor/state/state.ml
+++ b/editor/state/state.ml
@@ -14,6 +14,7 @@ type t =
; window : Brr.El.t list
; pm : PM.t
}
+type state = t
(** Compare two states together.
@@ -86,3 +87,5 @@ let init
; pm
}
+
+include Application.Make(struct type t = state end)
diff --git a/editor/state/state.mli b/editor/state/state.mli
index 6984067..20d5288 100755
--- a/editor/state/state.mli
+++ b/editor/state/state.mli
@@ -11,6 +11,7 @@ type t =
; pm : Prosemirror.t
}
+
val eq: t -> t -> bool
(** Update the title element according to the page. *)
@@ -26,3 +27,18 @@ val load_page
(** 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