diff options
author | Sébastien Dailly <sebastien@chimrod.com> | 2021-03-21 20:24:15 +0100 |
---|---|---|
committer | Sébastien Dailly <sebastien@dailly.me> | 2022-02-07 16:43:33 +0100 |
commit | 210a4d94836d07bb71cad46b3e670c1977cfe833 (patch) | |
tree | 406de4546a3530416a5672a16561fbd2b9bd627e /editor/editor.ml | |
parent | ccd68208146e87b9f185f543aadccc1110e72642 (diff) |
Updated PM examples
Diffstat (limited to 'editor/editor.ml')
-rwxr-xr-x | editor/editor.ml | 47 |
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 |