summaryrefslogtreecommitdiff
path: root/editor/prosemirror/bindings.ml
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@chimrod.com>2021-02-24 20:51:43 +0100
committerSébastien Dailly <sebastien@dailly.me>2022-02-07 16:43:33 +0100
commit3f5e3dd53755dd67c24721afc62e32d2187e3583 (patch)
tree16d4e694a1adeb83abcaea12da8fb0a16a11ed00 /editor/prosemirror/bindings.ml
parent274789e733c46e7e20fc1dc918a7251b0206b3d2 (diff)
Update editor code
Diffstat (limited to 'editor/prosemirror/bindings.ml')
-rwxr-xr-xeditor/prosemirror/bindings.ml194
1 files changed, 130 insertions, 64 deletions
diff --git a/editor/prosemirror/bindings.ml b/editor/prosemirror/bindings.ml
index cb5a47c..4b95b73 100755
--- a/editor/prosemirror/bindings.ml
+++ b/editor/prosemirror/bindings.ml
@@ -92,7 +92,15 @@ module Model = struct
end
- type mark
+ class type mark = object ('this)
+
+ method eq:
+ 'this t -> bool t meth
+
+ method isInSet:
+ mark t js_array t -> mark t opt meth
+
+ end
type node_spec
@@ -100,6 +108,8 @@ module Model = struct
type slice
+ type depth = int opt
+
class type resolved_pos = object ('this)
method pos:
@@ -115,10 +125,13 @@ module Model = struct
node t readonly_prop
method node:
- int -> node t meth
+ depth -> node t meth
method index:
- int -> int meth
+ depth -> int meth
+
+ method after:
+ depth -> int meth
method nodeAfter:
node t opt readonly_prop
@@ -142,7 +155,7 @@ module Model = struct
and mark_spec = object ('this)
method toDOM:
- (node t -> domOutputSpec t) callback writeonly_prop
+ (node t -> domOutputSpec t) callback prop
method inclusive:
bool t prop
@@ -185,6 +198,9 @@ module Model = struct
method node:
Jstr.t -> < .. > t opt -> fragment t opt -> mark t js_array t opt -> node t meth
+ method mark_type:
+ mark_type t -> < .. > t opt -> mark t meth
+
end
and node_type = object ('this)
@@ -204,7 +220,7 @@ module Model = struct
content_match t readonly_prop
method hasRequiredAttrs:
- unit -> bool meth
+ unit -> bool t meth
method create_withFragment:
< .. > t -> fragment t opt -> mark t opt -> node t meth
@@ -226,6 +242,9 @@ module Model = struct
method spec:
mark_spec t readonly_prop
+ method isInSet:
+ mark t js_array t -> mark t opt meth
+
end
(** Common signature between fragment and node *)
@@ -245,7 +264,7 @@ module Model = struct
(** Get the child node at the given index, if it exists. *)
method eq:
- 'this t -> bool meth
+ 'this t -> bool t meth
(** Compare this element to another one. *)
method cut:
@@ -309,7 +328,7 @@ module Model = struct
mark t js_array t readonly_prop
method sameMarkupd:
- node t -> bool meth
+ node t -> bool t meth
method text:
Jstr.t opt prop
@@ -359,39 +378,97 @@ module Transform = struct
method step:
step t -> 'this t meth
+ method addMark:
+ from:int -> to_:int -> Model.mark t -> 'this t meth
+
+ method delete:
+ from:int -> to_:int -> 'this t meth
+
method insert:
- int -> Model.node t -> 'this t meth
+ pos:int -> Model.node t -> 'this t meth
method replaceRangeWith:
- int -> int -> Model.node t -> 'this t meth
+ from:int -> to_:int -> Model.node t -> 'this t meth
method setBlockType:
- int -> int -> Model.node_type t -> < .. > t -> 'this t meth
+ from:int -> to_:int -> Model.node_type t -> < .. > t -> 'this t meth
end
end
-(**
- The class is defined outside of the module View for prevent recursive
- declaration.
+module Classes = struct
-*)
-class type _editor_props = object ('this)
-end
+ (** View *)
+ class type editor_props = object ('this)
+ method editable:
+ (editor_state t -> bool t) callback prop
+ end
-module State = struct
+ and direct_editor_props = object ('this)
- class type plugin = object ('this)
+ inherit editor_props
- method props : _editor_props t readonly_prop
+ method state:
+ editor_state t writeonly_prop
+ (** The call back is called with this = instance of editor_view *)
+ method dispatchTransaction:
+ (editor_view t, transaction t -> unit) meth_callback writeonly_prop
end
- class type selection = object ('this)
+ and editor_view = object ('this)
+
+ method state:
+ editor_state t readonly_prop
+
+ method dom:
+ Brr.El.t readonly_prop prop
+
+ method editable:
+ bool t readonly_prop
+
+ method props:
+ direct_editor_props t readonly_prop
+
+ method update:
+ direct_editor_props t -> unit meth
+
+ method setProps:
+ direct_editor_props t -> unit meth
+
+ method updateState:
+ editor_state t -> unit meth
+
+ method posAtCoords:
+ < left: float prop ; top: float prop > t -> < pos: int prop; inside: int prop> t meth
+
+ method coordsAtPos:
+ int -> int opt -> < left: float prop; right: float prop; top: float prop; bottom: float prop > t meth
+
+ method dispatch:
+ transaction t -> unit meth
+
+ end
+
+ (** State *)
+
+ and plugin = object ('this)
+
+ method props : editor_props t opt prop
+
+ method view:
+ (editor_view t -> < .. > t) callback opt prop
+
+ method filterTransaction:
+ (transaction t -> editor_state t -> bool t) opt prop
+
+ end
+
+ and selection = object ('this)
method from:
int readonly_prop
@@ -399,6 +476,12 @@ module State = struct
method _to:
int readonly_prop
+ method empty:
+ bool t readonly_prop
+
+ method eq:
+ 'this t -> bool t meth
+
method content:
unit -> Model.slice t meth
@@ -474,13 +557,15 @@ module State = struct
method before:
Model.node t readonly_prop
+ method insertText:
+ Jstr.t -> from:int opt -> to_:int opt -> 'this t meth
+
method scrollIntoView :
unit -> 'this t meth
-
end
- class type configuration_prop = object ('this)
+ and configuration_prop = object ('this)
method schema:
Model.schema t opt prop
@@ -490,7 +575,7 @@ module State = struct
end
- class type creation_prop = object ('this)
+ and creation_prop = object ('this)
inherit configuration_prop
@@ -505,7 +590,7 @@ module State = struct
end
- class type editor_state = object ('this)
+ and editor_state = object ('this)
method doc :
Model.node t readonly_prop
@@ -538,45 +623,37 @@ module State = struct
end
-module View = struct
-
- class type editor_props = _editor_props
-
- class type direct_editor_props = object ('this)
-
- inherit editor_props
+module State = struct
- method state:
- State.editor_state t writeonly_prop
+ class type plugin = Classes.plugin
+ class type selection = Classes.selection
+ class type text_selection = Classes.text_selection
+ class type node_selection = Classes.node_selection
+ class type transaction = Classes.transaction
+ class type configuration_prop = Classes.configuration_prop
+ class type creation_prop = Classes.creation_prop
+ class type editor_state = Classes.editor_state
- (** The call back is called with this = instance of editor_view *)
- method dispatchTransaction:
- (editor_view t, State.transaction t -> unit) meth_callback writeonly_prop
+ type dispatch = (Classes.transaction t -> unit)
+end
- end
+module View = struct
- and editor_view = object ('this)
+ class type editor_props = Classes.editor_props
- method state:
- State.editor_state t readonly_prop
+ class type direct_editor_props = Classes.direct_editor_props
- method dom:
- Brr.El.t readonly_prop prop
+ class type editor_view = Classes.editor_view
- method editable:
- bool readonly_prop prop
+end
- method update:
- direct_editor_props t -> unit meth
+module History = struct
- method setProps:
- direct_editor_props t -> unit meth
+ class type history_prop = object ('this)
- method updateState:
- State.editor_state t -> unit meth
+ method depth: int opt prop
- method dispatch:
- State.transaction t -> unit meth
+ method newGroupDelay: int opt prop
end
@@ -633,18 +710,6 @@ module SchemaBasic = struct
end
-module History = struct
-
- class type history_prop = object ('this)
-
- method depth: int opt prop
-
- method newGroupDelay: int opt prop
-
- end
-
-end
-
module Example = struct
class type options = object ('this)
@@ -662,4 +727,5 @@ module Example = struct
bool t opt prop
end
+
end