aboutsummaryrefslogtreecommitdiff
path: root/editor/prosemirror/prosemirror.ml
diff options
context:
space:
mode:
Diffstat (limited to 'editor/prosemirror/prosemirror.ml')
-rwxr-xr-xeditor/prosemirror/prosemirror.ml18
1 files changed, 14 insertions, 4 deletions
diff --git a/editor/prosemirror/prosemirror.ml b/editor/prosemirror/prosemirror.ml
index e97fa9b..e2758c7 100755
--- a/editor/prosemirror/prosemirror.ml
+++ b/editor/prosemirror/prosemirror.ml
@@ -112,6 +112,10 @@ module State = struct
include Bindings.State
+ type dispatch = (transaction Js.t -> unit)
+
+ type command = editor_state Js.t -> dispatch Js.opt -> bool Js.t
+
let configuration_prop
: unit -> configuration_prop Js_of_ocaml.Js.t
= fun () -> Js_of_ocaml.Js.Unsafe.obj [||]
@@ -176,6 +180,7 @@ module State = struct
let state = Jv.get t "state" in
Jv.call (Jv.get state "TextSelection") "create" Jv.Id.[|to_jv doc; Jv.of_int number|]
|> Jv.Id.of_jv
+
end
(* Editor view *)
@@ -249,13 +254,13 @@ module History = struct
|> Jv.Id.of_jv
let undo
- : t -> State.editor_state Js.t -> (State.transaction -> unit) -> bool
+ : t -> State.command
= fun t state fn ->
Jv.call (Jv.get t "history") "undo" [|Jv.Id.to_jv state; Jv.repr fn|]
|> Jv.Id.of_jv
let redo
- : t -> State.editor_state Js.t -> (State.transaction -> unit) -> bool
+ : t -> State.command
= fun t state fn ->
Jv.call (Jv.get t "history") "redo" [|Jv.Id.to_jv state; Jv.repr fn|]
|> Jv.Id.of_jv
@@ -264,7 +269,7 @@ end
module Keymap = struct
let keymap
- : t -> (string * (State.editor_state Js.t -> (State.transaction Js.t -> unit) -> bool)) array -> State.plugin Js.t
+ : t -> (string * State.command) array -> State.plugin Js.t
= fun t props ->
let props = Jv.obj @@ Array.map (fun (id, f) -> (id, Jv.repr f)) props in
Jv.call (Jv.get t "keymap") "keymap" [|props|]
@@ -275,11 +280,16 @@ end
module Commands = struct
let baseKeymap
- : t -> (string * (State.editor_state Js.t -> (State.transaction -> unit) -> bool)) array
+ : t -> (string * State.command) array
= fun t ->
Jv.get (Jv.get t "commands") "baseKeymap"
|> Jv.Id.of_jv
+ let set_block_type
+ : t -> Model.node_type Js.t -> < .. > Js.t -> State.command
+ = fun t node props ->
+ Jv.call (Jv.get t "commands") "setBlockType" Jv.Id.[| to_jv node ; to_jv props |]
+ |> Jv.Id.of_jv
end
(* Example Setup *)