summaryrefslogtreecommitdiff
path: root/editor/app.ml
diff options
context:
space:
mode:
Diffstat (limited to 'editor/app.ml')
-rwxr-xr-xeditor/app.ml46
1 files changed, 12 insertions, 34 deletions
diff --git a/editor/app.ml b/editor/app.ml
index aee396a..219ce80 100755
--- a/editor/app.ml
+++ b/editor/app.ml
@@ -1,5 +1,4 @@
open Brr
-module PM = Prosemirror
module Js = Js_of_ocaml.Js
type events =
@@ -7,8 +6,7 @@ type events =
| StoreEvent
| LoadEvent of Jstr.t option
| AddEvent
- | CloseEvent of Forms.Events.kind option
- | GEvent of Forms.Events.event
+ | ClosePopup of Forms.Events.event option
let key_of_title
: Jstr.t -> Jstr.t
@@ -20,12 +18,20 @@ let key_of_title
The function take a new event, and apply it to the current state. *)
let update
- : 'a option Note.E.send -> (events, State.t) Application.t
+ : Forms.Events.event option Note.E.send -> (events, State.t) Application.t
= fun close_sender event state ->
match event with
- | GEvent (Event (t, (module Handler))) ->
- Handler.on_close t state
+ | ClosePopup result ->
+ let state = match state.window with
+ | [] -> { state with window = [] }
+ | el::tl -> El.remove el
+ ; { state with window = tl } in
+ begin match result with
+ | None -> state
+ | Some (Event (t, (module Handler))) ->
+ Handler.on_close t state
+ end
| AddEvent ->
let title = Jstr.v "Nouvelle page" in
@@ -47,34 +53,6 @@ let update
{ state with window = popup::state.window}
end
- | CloseEvent res ->
-
- let state = match state.window with
- | [] -> { state with window = [] }
- | el::tl -> El.remove el
- ; { state with window = tl } in
-
- (* The actions is confirmed by the user. Handle the form result *)
- begin match res with
- (* Delete the current page, then load the home page *)
- | Some (Forms.Delete_page.DeletePage id) ->
- State.Storage.delete (fun () -> Some id);
- let json = State.Storage.load None in
- State.load_page None state json
- (* Add a new page *)
- | Some (Forms.Add_page.AddPage {title}) ->
- let page_id = key_of_title title in
- let new_date = (new%js Js.date_now)##getTime in
- let content_obj = object%js
- val content = Js.null
- val title = Js.some title
- val date = Js.some new_date
- end in
- State.load_page (Some page_id) state content_obj
-
- | _ -> state
- end
-
| StoreEvent ->
let title_element = Document.find_el_by_id G.document (Jstr.v "title") in