aboutsummaryrefslogtreecommitdiff
path: root/editor/prosemirror/prosemirror.ml
diff options
context:
space:
mode:
Diffstat (limited to 'editor/prosemirror/prosemirror.ml')
-rwxr-xr-xeditor/prosemirror/prosemirror.ml74
1 files changed, 68 insertions, 6 deletions
diff --git a/editor/prosemirror/prosemirror.ml b/editor/prosemirror/prosemirror.ml
index e37cc3b..8c436a3 100755
--- a/editor/prosemirror/prosemirror.ml
+++ b/editor/prosemirror/prosemirror.ml
@@ -108,6 +108,16 @@ module Model = struct
: < dom: node Js.t Js.readonly_prop ; contentDOM : node Js.t Js.opt Js.readonly_prop > Js.t -> domOutputSpec Js.t
= of_
end
+
+ module ParseRule = struct
+
+ let tag
+ : Jstr.t -> parse_rule Js.t
+ = fun name ->
+ Jv.obj [| "tag", Jv.of_jstr name |]
+ |> Jv.Id.of_jv
+
+ end
end
module State = struct
@@ -115,12 +125,12 @@ module State = struct
include Bindings.State
let configuration_prop
- : unit -> configuration_prop Js_of_ocaml.Js.t
- = fun () -> Js_of_ocaml.Js.Unsafe.obj [||]
+ : unit -> configuration_prop Js.t
+ = fun () -> Js.Unsafe.obj [||]
let creation_prop
: unit -> creation_prop Js.t
- = fun () -> Js_of_ocaml.Js.Unsafe.obj [||]
+ = fun () -> Js.Unsafe.obj [||]
let create
: t -> creation_prop Js.t -> editor_state Js.t
@@ -131,13 +141,18 @@ module State = struct
|> Jv.Id.of_jv
let fromJSON
- : t -> configuration_prop Js_of_ocaml.Js.t -> Brr.Json.t -> editor_state Js.t
+ : t -> configuration_prop Js.t -> Brr.Json.t -> editor_state Js.t
= fun t config json ->
let state = Jv.get t "state" in
let editor_state = Jv.get state "EditorState" in
Jv.call editor_state "fromJSON" [|Jv.Id.to_jv config ; json |]
|> Jv.Id.of_jv
+ let selection_from
+ : selection Js.t -> Model.resolved_pos Js.t
+ = fun selection ->
+ Jv.Id.(of_jv @@ Jv.get (to_jv selection) "$from")
+
let selection_to
: selection Js.t -> Model.resolved_pos Js.t
= fun selection ->
@@ -183,6 +198,10 @@ module State = struct
: selection Js.t -> Model.resolved_pos Js.t Js.opt
= fun selection ->
Jv.Id.(of_jv @@ Jv.get (to_jv selection) "$cursor")
+
+ let create_str_meta_data
+ : Jstr.t -> 'a meta_data Js.t
+ = Obj.magic
end
(* Editor view *)
@@ -196,7 +215,7 @@ module View = struct
include Bindings.View
let direct_editor_props
: unit -> direct_editor_props Js.t
- = fun () -> Js_of_ocaml.Js.Unsafe.obj [||]
+ = fun () -> Js.Unsafe.obj [||]
let editor_view
: t -> El.t -> direct_editor_props Js.t -> editor_view Js.t
@@ -206,6 +225,26 @@ module View = struct
end
+module Transform = struct
+
+ include Bindings.Transform
+
+ let offset
+ : t -> int -> step_map Js.t
+ = fun t n ->
+ let stepmap = Jv.get (Jv.get t "transform") "StepMap" in
+ Jv.call stepmap "offset" [|Jv.Id.to_jv n|]
+ |> Jv.Id.of_jv
+
+ let insertPoint
+ : t -> Model.node Js.t -> pos:int -> Model.node_type Js.t -> int Js.opt
+ = fun t node ~pos node_t ->
+ let transform = Jv.get t "transform" in
+ Jv.call transform "insertPoint" Jv.Id.[|to_jv node ; to_jv pos; to_jv node_t|]
+ |> Jv.Id.of_jv
+
+end
+
module Commands = struct
type t = State.editor_state Js.t -> State.dispatch Js.opt -> bool Js.t
@@ -238,7 +277,7 @@ module History = struct
let history_prop
: unit -> history_prop Js.t
- = fun () -> Js_of_ocaml.Js.Unsafe.obj [||]
+ = fun () -> Js.Unsafe.obj [||]
let history
: t -> history_prop Js.t -> State.plugin Js.t
@@ -324,6 +363,22 @@ module SchemaList = struct
end
+module Menu = struct
+
+ include Bindings.Menu
+
+ let menuItemSpec
+ : unit -> menuItemSpec Js.t
+ = fun () -> Js.Unsafe.obj [||]
+
+ let menu_item
+ : t -> menuItemSpec Js.t -> menuItem Js.t
+ = fun t spec ->
+ let menu = Jv.get t "menu" in
+ Jv.new' (Jv.get menu "MenuItem") [| Jv.Id.to_jv spec |]
+ |> Jv.Id.of_jv
+
+end
(* Example Setup *)
@@ -343,4 +398,11 @@ module Example = struct
let setup = Jv.get t "example_setup" in
Jv.call setup "exampleSetup" [|Jv.Id.to_jv options|]
|> Jv.Id.of_jv
+
+ let buildMenuItems
+ : t -> Model.schema Js.t -> menuItems Js.t
+ = fun t schema ->
+ let setup = Jv.get t "example_setup" in
+ Jv.call setup "buildMenuItems" [|Jv.Id.to_jv schema|]
+ |> Jv.Id.of_jv
end