From c6265278f05aa4d3af60e420f2d4d13e4bce8ad7 Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Fri, 3 Dec 2021 04:19:53 +0100 Subject: Removed the application mecanism from the state module --- editor/actions/add_page.ml | 8 +++++--- editor/actions/delete_page.ml | 7 ++++--- editor/actions/dune | 1 + editor/actions/editor_actions.ml | 11 ++++++----- editor/actions/editor_actions.mli | 2 +- editor/actions/export.ml | 7 ++++--- editor/actions/import.ml | 5 +++-- editor/actions/to_markdown.ml | 8 +++++--- 8 files changed, 29 insertions(+), 20 deletions(-) (limited to 'editor/actions') diff --git a/editor/actions/add_page.ml b/editor/actions/add_page.ml index fcad87f..5e52d43 100755 --- a/editor/actions/add_page.ml +++ b/editor/actions/add_page.ml @@ -1,4 +1,5 @@ module Js = Js_of_ocaml.Js +module App = Editor_app module M = struct @@ -16,9 +17,10 @@ module M = struct State.new_page ~title (Some page_id) state end + (** Create a new element *) let create - : unit -> State.event Note.event + : unit -> App.event Note.event = fun () -> let title = Jstr.v "Nouvelle page" in let form = Forms.Add_page.create () in @@ -34,9 +36,9 @@ let create () in Note.E.map - (fun v -> State.E + (fun v -> App.E (v - , (module M : State.Event with type t = M.t ))) + , (module M : App.Event with type t = M.t ))) (* Option.on_some trigger the event only when the pop up is validated. Closing the popup doesn't do anything. *) diff --git a/editor/actions/delete_page.ml b/editor/actions/delete_page.ml index fbd4fde..7fa609b 100755 --- a/editor/actions/delete_page.ml +++ b/editor/actions/delete_page.ml @@ -1,3 +1,4 @@ +module App = Editor_app module M = struct type t = unit @@ -14,7 +15,7 @@ module M = struct end let create - : unit -> State.event Note.event + : unit -> App.event Note.event = fun () -> let title = Jstr.v "Confirmation" and message = @@ -26,7 +27,7 @@ let create () in Note.E.map - (fun v -> State.E + (fun v -> App.E ( v - , (module M : State.Event with type t = M.t ))) + , (module M : App.Event with type t = M.t ))) (Note.E.Option.on_some ev) diff --git a/editor/actions/dune b/editor/actions/dune index 10279dd..6406828 100755 --- a/editor/actions/dune +++ b/editor/actions/dune @@ -8,6 +8,7 @@ blog forms state + editor_app ) (preprocess (pps js_of_ocaml-ppx)) ) diff --git a/editor/actions/editor_actions.ml b/editor/actions/editor_actions.ml index 518e0c7..48974c0 100755 --- a/editor/actions/editor_actions.ml +++ b/editor/actions/editor_actions.ml @@ -1,6 +1,7 @@ open StdLabels open Brr open Brr_note +module App = Editor_app module Js = Js_of_ocaml.Js @@ -9,7 +10,7 @@ module Js = Js_of_ocaml.Js let note_id_attribute = Jstr.v "data-note-id" type t = - { ev : State.event Note.event + { ev : App.event Note.event ; childs : El.t list ; ul : El.t ; mutable completed : bool @@ -108,7 +109,7 @@ let build let redirect_handler = - (module Load_page.M : State.Event with type t = Load_page.M.t ) in + (module Load_page.M : App.Event with type t = Load_page.M.t ) in let ul = El.ul [] in @@ -127,14 +128,14 @@ let build Note.E.select [ Evr.on_el Ev.click - (fun _ -> State.E (None, redirect_handler)) + (fun _ -> App.E (None, redirect_handler)) home_button ; Evr.on_el Ev.click (fun ev -> let el = Jv.Id.of_jv @@ Jv.Id.to_jv @@ Ev.target ev in let name = El.at note_id_attribute el in - State.E (name, redirect_handler)) + App.E (name, redirect_handler)) ul ] in let childs = @@ -163,7 +164,7 @@ let build ; completed = false } let get_event - : t -> State.event Note.event + : t -> App.event Note.event = fun {ev; _} -> ev (** Collect all the notes in the cache and return them into links. *) diff --git a/editor/actions/editor_actions.mli b/editor/actions/editor_actions.mli index 65c10f3..b1ac054 100755 --- a/editor/actions/editor_actions.mli +++ b/editor/actions/editor_actions.mli @@ -6,7 +6,7 @@ val build (** Get the events triggered by the actions buttons *) val get_event - : t -> State.event Note.event + : t -> Editor_app.event Note.event (** Finalize the creation, register the handler to state update, and return the dom elements. diff --git a/editor/actions/export.ml b/editor/actions/export.ml index 71e3b64..657e0da 100755 --- a/editor/actions/export.ml +++ b/editor/actions/export.ml @@ -1,4 +1,5 @@ module Js = Js_of_ocaml.Js +module App = Editor_app module M = struct @@ -31,8 +32,8 @@ end (** Create a new element *) let create - : unit -> State.event + : unit -> App.event = fun () -> - State.E + App.E ( () - , (module M : State.Event with type t = M.t )) + , (module M : App.Event with type t = M.t )) diff --git a/editor/actions/import.ml b/editor/actions/import.ml index 13ed938..c847ed3 100755 --- a/editor/actions/import.ml +++ b/editor/actions/import.ml @@ -1,4 +1,5 @@ module Js = Js_of_ocaml.Js +module App = Editor_app let uncheck_import = fun ~previous ~update -> @@ -53,7 +54,7 @@ let create () = in Note.E.map - (fun v -> State.E + (fun v -> App.E ( v - , (module M : State.Event with type t = M.t ))) + , (module M : App.Event with type t = M.t ))) (Note.E.Option.on_some ev) diff --git a/editor/actions/to_markdown.ml b/editor/actions/to_markdown.ml index c1ac774..80191f9 100755 --- a/editor/actions/to_markdown.ml +++ b/editor/actions/to_markdown.ml @@ -1,5 +1,7 @@ module Js = Js_of_ocaml.Js module PM = Prosemirror +module App = Editor_app + type buffer = Jstr.t Js.js_array Js.t type f = (buffer -> PM.Model.node Js.t -> unit) @@ -287,8 +289,8 @@ end (** Create a new element *) let create - : PM.t -> State.event + : PM.t -> App.event = fun pm -> - State.E + App.E ( pm - , (module ToMarkdown : State.Event with type t = ToMarkdown.t )) + , (module ToMarkdown : App.Event with type t = ToMarkdown.t )) -- cgit v1.2.3