From 210a4d94836d07bb71cad46b3e670c1977cfe833 Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Sun, 21 Mar 2021 20:24:15 +0100 Subject: Updated PM examples --- editor/editor.ml | 47 ++++++++++++++++------------------------------- 1 file changed, 16 insertions(+), 31 deletions(-) (limited to 'editor/editor.ml') 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 -- cgit v1.2.3