summaryrefslogtreecommitdiff
path: root/editor/actions/import.ml
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@dailly.me>2022-02-07 15:27:05 +0100
committerSébastien Dailly <sebastien@dailly.me>2022-02-07 16:43:33 +0100
commit28417d795a6922c3df3c2c0aea78a51648b0428e (patch)
tree28af6bd86e2127003855574b4c777efa1cd07207 /editor/actions/import.ml
parent72e3b16bbd258e63f047392c973ba5e8f0a823c8 (diff)
Added import button in editor
Diffstat (limited to 'editor/actions/import.ml')
-rwxr-xr-xeditor/actions/import.ml31
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)