From 28417d795a6922c3df3c2c0aea78a51648b0428e Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Mon, 7 Feb 2022 15:27:05 +0100 Subject: Added import button in editor --- editor/actions/import.ml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 editor/actions/import.ml (limited to 'editor/actions/import.ml') diff --git a/editor/actions/import.ml b/editor/actions/import.ml new file mode 100755 index 0000000..fd4bef8 --- /dev/null +++ b/editor/actions/import.ml @@ -0,0 +1,31 @@ +module Js = Js_of_ocaml.Js + +module M = struct + + type t = Forms.Selector.t + + let update + : t -> State.t -> State.t + = fun t state -> + match t with + | None -> state + | Some file -> + (* Back to UTF-16 *) + let content = file.Forms.Selector.content in + Brr.Console.(log [content] ); + match State.Storage.of_json content with + | Error _ -> state + | Ok _obj -> + State.load_page state.State.page_id state +end + +let create () = + let title = Jstr.v "Importer des notes" in + let ev = Elements.Popup.create + ~title + ~form:(Some (Forms.Selector.create ())) in + Note.E.map + (fun v -> State.E + ( v + , (module M : State.Event with type t = M.t ))) + (Note.E.Option.on_some ev) -- cgit v1.2.3