aboutsummaryrefslogtreecommitdiff
path: root/editor/prosemirror/bindings.ml
diff options
context:
space:
mode:
Diffstat (limited to 'editor/prosemirror/bindings.ml')
-rwxr-xr-xeditor/prosemirror/bindings.ml262
1 files changed, 229 insertions, 33 deletions
diff --git a/editor/prosemirror/bindings.ml b/editor/prosemirror/bindings.ml
index 08db819..f6d4223 100755
--- a/editor/prosemirror/bindings.ml
+++ b/editor/prosemirror/bindings.ml
@@ -1,5 +1,47 @@
open Js_of_ocaml.Js
+module TypedObject : sig
+
+ type 'a t
+
+ val get
+ : 'a t -> Jv.prop -> 'a option
+
+ val get'
+ : 'a t -> Jv.prop' -> 'a option
+
+ val set
+ : 'a t -> Jv.prop -> 'a -> unit
+
+ val set'
+ : 'a t -> Jv.prop' -> 'a -> unit
+
+end = struct
+
+ type 'a t = Jv.t
+
+ let get
+ : 'a t -> Jv.prop -> 'a
+ = fun t prop ->
+ Jv.to_option Jv.Id.of_jv (Jv.get t prop)
+
+ let get'
+ : 'a t -> Jv.prop' -> 'a
+ = fun t prop ->
+ Jv.to_option Jv.Id.of_jv (Jv.get' t prop)
+
+ let set
+ : 'a t -> Jv.prop -> 'a -> unit
+ = fun o prop v ->
+ Jv.set o prop (Jv.Id.to_jv v)
+
+ let set'
+ : 'a t -> Jv.prop' -> 'a -> unit
+ = fun o prop v ->
+ Jv.set' o prop (Jv.Id.to_jv v)
+
+end
+
class type ['a] ordered_map = object ('this)
method get:
@@ -21,63 +63,131 @@ end
module Model = struct
+ type domOutputSpec
+
+ class type _node_props = object ('this)
+
+ method inlineContent:
+ bool readonly_prop
+ (** True if this node type has inline content. *)
+
+ method isBlock:
+ bool readonly_prop
+
+ method isText:
+ bool readonly_prop
+
+ method isInline:
+ bool readonly_prop
+
+ method isTextblock:
+ bool readonly_prop
+
+ method isLeaf:
+ bool readonly_prop
+
+ method isAtom:
+ bool readonly_prop
+
+ end
+
+
type mark
type node_spec
- type mark_spec
+ type content_match
- class type schema_spec = object ('this)
+ type slice
- method nodes:
- node_spec ordered_map t readonly_prop
+ class type resolved_pos = object ('this)
+
+ method pos:
+ int readonly_prop
+
+ method depth:
+ int readonly_prop
+
+ method parent:
+ node t readonly_prop
+
+ method doc:
+ node t readonly_prop
+
+ method node:
+ int -> node t meth
+
+ method index:
+ int -> int meth
+
+ method nodeAfter:
+ node t opt readonly_prop
+
+ method nodeBefore:
+ node t opt readonly_prop
method marks:
- mark_spec ordered_map t readonly_prop
+ unit -> mark t js_array t meth
- method topNode:
- Jstr.t opt readonly_prop
+ method sameParent:
+ 'this -> bool t meth
+ method max:
+ 'this -> 'this t meth
+
+ method min:
+ 'this -> 'this t meth
end
- class type schema = object ('this)
+ and mark_spec = object ('this)
- method spec:
- schema_spec t prop
+ method toDOM:
+ (node t -> domOutputSpec t) callback writeonly_prop
+
+ method inclusive:
+ bool t prop
+
+ method spanning:
+ bool t prop
end
- type content_match
+ and schema_spec = object ('this)
- type slice
+ method nodes:
+ node_spec ordered_map t readonly_prop
- class type _node_props = object ('this)
+ method marks:
+ mark_spec ordered_map t readonly_prop
- method inlineContent:
- bool readonly_prop
- (** True if this node type has inline content. *)
+ method topNode:
+ Jstr.t opt readonly_prop
- method isBlock:
- bool readonly_prop
+ end
- method isText:
- bool readonly_prop
+ and schema = object ('this)
- method isInline:
- bool readonly_prop
+ method spec:
+ schema_spec t prop
- method isTextblock:
- bool readonly_prop
+ method nodes:
+ node_type t TypedObject.t readonly_prop
- method isLeaf:
- bool readonly_prop
+ method marks:
+ mark_type t TypedObject.t readonly_prop
- method isAtom:
- bool readonly_prop
+ method typoNodeType:
+ node_type t readonly_prop
+
+ method text:
+ Jstr.t -> node t meth
+
+ method node:
+ Jstr.t -> < .. > t opt -> fragment t opt -> mark t js_array t opt -> node t meth
end
- class type node_type = object ('this)
+ and node_type = object ('this)
inherit _node_props
@@ -96,13 +206,30 @@ module Model = struct
method hasRequiredAttrs:
unit -> bool meth
+ method create_withFragment:
+ < .. > t -> fragment t opt -> mark t opt -> node t meth
+
end
- class type mark_type = object ('this)
+ (** Signature for MarkType class
+
+ https://prosemirror.net/docs/ref/#model.MarkType
+ *)
+ and mark_type = object ('this)
+
+ method name:
+ Jstr.t readonly_prop
+
+ method schema:
+ schema t readonly_prop
+
+ method spec:
+ mark_spec t readonly_prop
+
end
(** Common signature between fragment and node *)
- class type _element = object ('this)
+ and _element = object ('this)
method childCount:
int readonly_prop
@@ -164,16 +291,29 @@ module Model = struct
node_type t readonly_prop
method attrs:
- < .. > t readonly_prop
+ < .. > t prop
method content:
- fragment t readonly_prop
+ fragment t prop
+
+ method copy:
+ fragment t -> 'this t meth
+
+ method resolve:
+ int -> resolved_pos t meth
+
+ method nodeAt:
+ int -> 'this t opt meth
method marks:
mark t js_array t readonly_prop
method sameMarkupd:
node t -> bool meth
+
+ method text:
+ Jstr.t opt prop
+
end
end
@@ -219,6 +359,12 @@ module Transform = struct
method step:
step t -> 'this t meth
+ method insert:
+ int -> Model.node t -> 'this t meth
+
+ method replaceRangeWith:
+ int -> int -> Model.node t -> 'this t meth
+
end
end
@@ -244,12 +390,33 @@ module State = struct
class type selection = object ('this)
+ method from:
+ int readonly_prop
+
+ method _to:
+ int readonly_prop
+
method content:
unit -> Model.slice t meth
method replace:
transaction t -> Model.slice t -> unit meth
+ method replaceWith:
+ transaction t -> Model.node t -> unit meth
+
+ end
+
+ and text_selection = object ('this)
+
+ inherit selection
+
+ end
+
+ and node_selection = object ('this)
+
+ inherit selection
+
end
and transaction = object ('this)
@@ -295,12 +462,19 @@ module State = struct
method replaceSelection:
Model.slice t -> 'this t meth
+ method replaceSelectionWith:
+ Model.node t -> bool t -> 'this t meth
+
method selectionSet:
bool readonly_prop
method before:
Model.node t readonly_prop
+ method scrollIntoView :
+ unit -> 'this t meth
+
+
end
class type configuration_prop = object ('this)
@@ -398,6 +572,9 @@ module View = struct
method updateState:
State.editor_state t -> unit meth
+ method dispatch:
+ State.transaction t -> unit meth
+
end
end
@@ -464,3 +641,22 @@ module History = struct
end
end
+
+module Example = struct
+
+ class type options = object ('this)
+
+ method schema:
+ Model.schema t prop
+
+ method menuBar:
+ bool opt prop
+
+ method floatingMenu:
+ bool opt prop
+
+ method history:
+ bool opt prop
+
+ end
+end