aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@dailly.me>2021-12-02 21:36:42 +0100
committerSébastien Dailly <sebastien@dailly.me>2022-02-07 16:43:33 +0100
commite78c236a8d28784370f192a3410693c456dc628f (patch)
tree3898c5d140f7900a983d814cb9d29b7da9db9b09
parentf30e3eeb06bb932e6735868d404926cc7a9cd8aa (diff)
Added comment in editor event loop
-rwxr-xr-xeditor/actions/editor_actions.mli3
-rwxr-xr-xeditor/editor.ml11
-rwxr-xr-xeditor/prosemirror/prosemirror.ml1
3 files changed, 14 insertions, 1 deletions
diff --git a/editor/actions/editor_actions.mli b/editor/actions/editor_actions.mli
index a0a3c3b..65c10f3 100755
--- a/editor/actions/editor_actions.mli
+++ b/editor/actions/editor_actions.mli
@@ -8,7 +8,8 @@ val build
val get_event
: t -> State.event Note.event
-(** Finalize the creation, register the handler to state update, and return the dom elements.
+(** Finalize the creation, register the handler to state update, and return the
+ dom elements.
Raise an error if already completed. *)
val complete
diff --git a/editor/editor.ml b/editor/editor.ml
index 5883ec8..2441265 100755
--- a/editor/editor.ml
+++ b/editor/editor.ml
@@ -131,8 +131,14 @@ let app id content =
let init_state = State.init pm view last_backup page_id in
+ (* Initialize the buttons actions and get the associated events.
+ At this point, the HTML element is not yet created, and cannot be
+ inserted in the document.
+ *)
let side_elements = Editor_actions.build pm in
let btn_events = Editor_actions.get_event side_elements in
+
+ (* Create the main event loop with all the collected events *)
let app_state = State.run
~eq:State.eq
init_state
@@ -146,7 +152,12 @@ let app id content =
; btn_events
]) in
+ (* Get the html element associated with the buttons, and add it in the
+ page.
+ The state event is already created, and can be given in the html
+ creation in order to update the elements when the state change.
+ *)
let childs = Editor_actions.complete side_elements app_state in
let () = El.append_children sidebar childs in
let _ = Note.(Logr.hold (S.log app_state (fun _ -> ()))) in
diff --git a/editor/prosemirror/prosemirror.ml b/editor/prosemirror/prosemirror.ml
index e413084..c44d090 100755
--- a/editor/prosemirror/prosemirror.ml
+++ b/editor/prosemirror/prosemirror.ml
@@ -18,6 +18,7 @@ module Model = struct
module Fragment = struct
+ (** https://prosemirror.net/docs/ref/#model.Fragment^fromArray *)
let from_array
: t -> node Js.t Js.js_array Js.t -> fragment Js.t
= fun t elements ->