diff options
Diffstat (limited to 'editor/actions/import.ml')
-rwxr-xr-x | editor/actions/import.ml | 31 |
1 files changed, 31 insertions, 0 deletions
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) |