From 3f5e3dd53755dd67c24721afc62e32d2187e3583 Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Wed, 24 Feb 2021 20:51:43 +0100 Subject: Update editor code --- editor/prosemirror/prosemirror.mli | 65 ++++++++++++++++++++++++-------------- 1 file changed, 41 insertions(+), 24 deletions(-) (limited to 'editor/prosemirror/prosemirror.mli') diff --git a/editor/prosemirror/prosemirror.mli b/editor/prosemirror/prosemirror.mli index 7a723d3..eac895a 100755 --- a/editor/prosemirror/prosemirror.mli +++ b/editor/prosemirror/prosemirror.mli @@ -3,6 +3,8 @@ open Brr type t +type t' = t + val v : unit -> t @@ -57,13 +59,6 @@ module rec Model : sig end -and SchemaList : sig - - val add_list_nodes - : t -> Model.node_spec Bindings.ordered_map Js.t -> Jstr.t -> Jstr.t option -> Model.node_spec Bindings.ordered_map Js.t - -end - (* State *) and State : sig @@ -100,9 +95,8 @@ and State : sig val create_text_selection : t -> Model.node Js.t -> int -> text_selection Js.t - type dispatch = (transaction Js.t -> unit) - - type command = editor_state Js.t -> dispatch Js.opt -> bool Js.t + val cursor + : selection Js.t -> Model.resolved_pos Js.t Js.opt end @@ -126,16 +120,18 @@ and View : sig end -module SchemaBasic : sig +module Commands : sig - include module type of Bindings.SchemaBasic + type t = State.editor_state Js.t -> State.dispatch Js.opt -> bool Js.t - val schema - : t -> Model.schema Js.t + val baseKeymap + : t' -> (string * t) array - val nodes - : t -> nodes Js.t + val set_block_type + : t' -> Model.node_type Js.t -> < .. > Js.t Js.opt -> t + val toggle_mark + : t' -> Model.mark_type Js.t -> < .. > Js.t Js.opt -> t end @@ -150,26 +146,47 @@ module History : sig : t -> history_prop Js.t -> State.plugin Js.t val undo - : t -> State.command + : t -> Commands.t val redo - : t -> State.command + : t -> Commands.t end module Keymap : sig val keymap - : t -> (string * State.command) array -> State.plugin Js.t + : t -> (string * Commands.t) array -> State.plugin Js.t end -module Commands : sig +module InputRule : sig - val baseKeymap - : t -> (string * State.command) array + type input_rule - val set_block_type - : t -> Model.node_type Js.t -> < .. > Js.t -> State.command + (** Create a new input rule for the given regExp. *) + val create + : t -> Js.regExp Js.t -> fn:(State.editor_state Js.t -> Jstr.t Js.js_array Js.t -> from:int -> to_:int -> State.transaction Js.t Js.opt) Js.callback -> input_rule Js.t + + val to_plugin + : t -> input_rule Js.t Js.js_array Js.t -> State.plugin Js.t +end + +module SchemaBasic : sig + + include module type of Bindings.SchemaBasic + + val schema + : t -> Model.schema Js.t + + val nodes + : t -> nodes Js.t + +end + +module SchemaList : sig + + val add_list_nodes + : t -> Model.node_spec Bindings.ordered_map Js.t -> Jstr.t -> Jstr.t option -> Model.node_spec Bindings.ordered_map Js.t end -- cgit v1.2.3