diff options
author | Sébastien Dailly <sebastien@chimrod.com> | 2021-06-04 22:56:27 +0200 |
---|---|---|
committer | Sébastien Dailly <sebastien@dailly.me> | 2022-02-07 16:43:33 +0100 |
commit | da1d9ad1c49f31fc9031fd1bc6661dad3600e40c (patch) | |
tree | d7684f047f6101b57c631c3c80448fc7ae2aa5ca /editor/prosemirror | |
parent | f7dc93dab194472329d74c056c4730b41e98d650 (diff) |
Added markdown output
Diffstat (limited to 'editor/prosemirror')
-rwxr-xr-x | editor/prosemirror/bindings.ml | 19 | ||||
-rwxr-xr-x | editor/prosemirror/prosemirror.ml | 12 | ||||
-rwxr-xr-x | editor/prosemirror/prosemirror.mli | 7 |
3 files changed, 34 insertions, 4 deletions
diff --git a/editor/prosemirror/bindings.ml b/editor/prosemirror/bindings.ml index 49c0904..7f6d82f 100755 --- a/editor/prosemirror/bindings.ml +++ b/editor/prosemirror/bindings.ml @@ -116,6 +116,9 @@ module Classes = struct class type mark = object ('this) + method _type + : mark_type t readonly_prop + method attrs : 'a TypedObject.t prop @@ -127,7 +130,7 @@ module Classes = struct end - class type node_spec = object ('this) + and node_spec = object ('this) method content : Jstr.t opt prop @@ -258,12 +261,18 @@ module Classes = struct method marks: mark_type t TypedObject.t readonly_prop - method typoNodeType: + method topNodeType: node_type t readonly_prop method text: - Jstr.t -> node t meth + Jstr.t -> mark t js_array t opt -> node t meth + + (** [node t attrs fragment ] Will create a node with the type [t] and + attributes [attrs]. The content will always be a fragment. + You can create a fragment from an array on node with the function + [Model.Fragment.from_array] + *) method node: Jstr.t -> < .. > t opt -> fragment t opt -> mark t js_array t opt -> node t meth @@ -348,7 +357,9 @@ module Classes = struct : (node t -> pos:int -> node t -> bool t) callback -> unit meth method forEach - : (node t -> offset:int -> index:int -> unit) callback -> unit meth + : (node t -> offset:int -> index:int -> unit) callback -> unit meth + (** Call [f] for every child node, passing the node, its offset into + this parent node, and its index. *) end diff --git a/editor/prosemirror/prosemirror.ml b/editor/prosemirror/prosemirror.ml index 48dbfd0..e413084 100755 --- a/editor/prosemirror/prosemirror.ml +++ b/editor/prosemirror/prosemirror.ml @@ -16,6 +16,18 @@ module Model = struct include Bindings.Model + module Fragment = struct + + let from_array + : t -> node Js.t Js.js_array Js.t -> fragment Js.t + = fun t elements -> + let model = Jv.get t "model" in + let class_ = Jv.get model "Fragment" in + Jv.call (Jv.Id.to_jv class_ ) "fromArray" [|Jv.Id.to_jv elements |] + |> Jv.Id.of_jv + + end + module Mark = struct let _set_from diff --git a/editor/prosemirror/prosemirror.mli b/editor/prosemirror/prosemirror.mli index 506ab89..dd8d5de 100755 --- a/editor/prosemirror/prosemirror.mli +++ b/editor/prosemirror/prosemirror.mli @@ -90,6 +90,13 @@ and Model : sig val schema : t -> schema_spec Js.t -> schema Js.t + module Fragment : sig + + val from_array + : t -> node Js.t Js.js_array Js.t -> fragment Js.t + + end + module Mark : sig val set_from_mark |