summaryrefslogtreecommitdiff
path: root/editor/state/state.ml
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@chimrod.com>2021-05-23 22:09:50 +0200
committerSébastien Dailly <sebastien@dailly.me>2022-02-07 16:43:33 +0100
commit1eeaf137bd30aff1bef34d05eeec686f6da8959d (patch)
tree63589546a32b72382e94f1ee16cf671cec911648 /editor/state/state.ml
parent97f3ac8054de22b94e4ae169dae33ed5b1b41a52 (diff)
Update editor
Diffstat (limited to 'editor/state/state.ml')
-rwxr-xr-xeditor/state/state.ml26
1 files changed, 22 insertions, 4 deletions
diff --git a/editor/state/state.ml b/editor/state/state.ml
index 48b4d58..569f26c 100755
--- a/editor/state/state.ml
+++ b/editor/state/state.ml
@@ -17,9 +17,7 @@ type t =
(** Compare two states together.
- The prosemirror elemens are ignored
-
-*)
+ The prosemirror elemens are ignored *)
let eq s1 s2 =
Stdlib.(==)
( s1.editable
@@ -66,5 +64,25 @@ let load_page
let editor_state = state_of_storage state.pm json state.view##.state##.schema in
let () = state.view##updateState editor_state
and () = set_title json in
- { state with page_id }
+
+ let last_backup =
+ Js.Opt.case json##.date
+ (fun () -> state.last_backup )
+ (fun v -> v) in
+
+ { state with page_id
+ ; last_backup }
+
+
+let init
+ : PM.t -> PM.View.editor_view Js.t -> float -> Jstr.t option -> t
+ = fun pm view last_backup page_id ->
+ { editable = true
+ ; view
+ ; last_backup
+ ; page_id
+
+ ; window = []
+ ; pm
+ }