aboutsummaryrefslogtreecommitdiff
path: root/editor/editor.ml
diff options
context:
space:
mode:
Diffstat (limited to 'editor/editor.ml')
-rwxr-xr-xeditor/editor.ml47
1 files changed, 16 insertions, 31 deletions
diff --git a/editor/editor.ml b/editor/editor.ml
index 5aecef0..19480e2 100755
--- a/editor/editor.ml
+++ b/editor/editor.ml
@@ -58,13 +58,18 @@ let prosemirror id content =
let module PM = Prosemirror in
let pm = PM.v () in
+ let schema = (PM.SchemaBasic.schema pm) in
+ let schema = Footnotes.footnote_schema pm schema in
+
+ Console.(log [ schema ]);
+
let specs = PM.Model.schema_spec
(PM.SchemaList.add_list_nodes
pm
- ((PM.SchemaBasic.schema pm)##.spec##.nodes)
+ (schema##.spec##.nodes)
(Jstr.v "paragraph block*")
(Some (Jstr.v "block")))
- (Some (PM.SchemaBasic.schema pm)##.spec##.marks)
+ (Some schema##.spec##.marks)
None in
let mySchema = PM.Model.schema pm specs in
@@ -80,46 +85,26 @@ let prosemirror id content =
view##updateState state
);
+ let view' = (Footnotes.footnote_view pm) in
+
+ let nodes = PM.O.init
+ [| ("footnote", view') |] in
+ props##.nodeViews := nodes;
+
let view = PM.View.editor_view
pm
(Jv.Id.of_jv id)
props in
- view##setProps props;
+ Console.(log [Jstr.v "main view"; view]);
(* Attach an event on focus out *)
let _ = Brr_note.Evr.on_el
(Ev.focusout)
- (fun _ ->
-(*
- let props = view##.props in
- props##.editable := Js.wrap_callback (fun _ -> Js._false);
- view##update props;
-*)
- save_storage view
- )
+ (fun _ -> save_storage view)
(Jv.Id.of_jv id) in
-
-(*
- let default_editable = view##.props##.editable in
- let _ = Brr_note.Evr.on_el
- (Ev.dblclick)
- (fun e ->
- let target = Ev.target e in
- let (el:El.t) = Jv.Id.(of_jv @@ to_jv target) in
- if (view##.editable == Js._false && (El.tag_name el <> Jstr.v "a")) then (
- let props = view##.props in
- props##.editable := default_editable;
- view##update props;
- Console.(log [el]);
- El.set_has_focus true (Jv.Id.of_jv id);
- )
-
- )
- (Jv.Id.of_jv id) in
-*)
()
- | _, _-> Console.(error [str "No element with id '%s' '%s' found"; id ; content])
+ | _, _ -> Console.(error [str "No element with id '%s' '%s' found"; id ; content])
end