aboutsummaryrefslogtreecommitdiff
path: root/editor/prosemirror/prosemirror.mli
blob: 76545d26201827be713cdb21f55c00651b0c5d30 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
open Js_of_ocaml
open Brr

type t

type t' = t

val v
  : unit -> t

module O = Bindings.TypedObject

(* State *)

module rec State : sig

  include module type of Bindings.State

  val configuration_prop 
    : unit -> configuration_prop Js.t 

  val creation_prop 
    : unit -> creation_prop Js.t 

  val create
    : t -> creation_prop Js.t -> editor_state Js.t

  val fromJSON 
    : t -> configuration_prop Js.t -> Brr.Json.t -> editor_state Js.t

  val selection_from
    : selection Js.t -> Model.resolved_pos Js.t 

  val selection_to 
    : selection Js.t -> Model.resolved_pos Js.t 

  val selection_at_start
    : t-> Model.node Js.t -> selection Js.t

  val is_selectable 
    : t -> Model.node Js.t -> bool Js.t

  val node_selection
    : t -> Model.resolved_pos Js.t -> node_selection Js.t

  val create_node_selection 
    : t -> Model.node Js.t -> int -> node_selection Js.t

  val create_text_selection 
    : t -> Model.node Js.t -> int -> text_selection Js.t

  val cursor 
    : selection Js.t -> Model.resolved_pos Js.t Js.opt

  val create_str_meta_data 
    : Jstr.t -> 'a meta_data Js.t

end

(* Editor view *)

and View : sig

  module EditorProps : sig

    type t

  end

  include module type of Bindings.View

  val direct_editor_props 
    : unit -> direct_editor_props Js.t

  val editor_view
    : t -> El.t -> direct_editor_props Js.t -> editor_view Js.t

end

and  Model : sig

  include module type of Bindings.Model

  val schema_spec: 
    node_spec Bindings.ordered_map Js.t
    -> mark_spec Bindings.ordered_map Js.t option 
    -> string option 
    -> schema_spec Js.t

  val schema 
    : t -> schema_spec Js.t -> schema Js.t 

  module DOMParser : sig

    type parser

    val from_schema
      : t -> schema Js.t -> parser

    val parse
      : parser -> El.t -> node Js.t

  end

  val empty_fragment 
    : t -> fragment Js.t

  module Dom_output_spec : sig

    val v
      : ?attrs:< .. > -> string -> domOutputSpec Js.t list -> domOutputSpec Js.t

    (** Hole element inside an output_spec element *)
    val hole
      : domOutputSpec Js.t

    val of_el
      : Brr.El.t -> domOutputSpec Js.t

    val of_jstr
      : Jstr.t -> domOutputSpec Js.t

    val of_obj
      : < dom: node Js.t Js.readonly_prop ; contentDOM : node Js.t Js.opt Js.readonly_prop > Js.t -> domOutputSpec Js.t
  end

  module ParseRule : sig 

    val tag: Jstr.t -> parse_rule Js.t

  end

end

and Transform : sig 

  include module type of Bindings.Transform

  val offset
    : t -> int -> step_map Js.t

  val insertPoint 
    : t -> Model.node Js.t -> pos:int -> Model.node_type Js.t -> int Js.opt

end

module Commands : sig

  type t = State.editor_state Js.t -> State.dispatch Js.opt -> bool Js.t

  val baseKeymap 
    : t' -> (string * t) array

  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

module History : sig

  include module type of Bindings.History

  val history_prop 
    : unit -> history_prop Js.t

  val history 
    : t -> history_prop Js.t -> State.plugin Js.t

  val undo 
    : t -> Commands.t

  val redo
    : t -> Commands.t
end

module Keymap : sig

  val keymap
    : t -> (string * Commands.t) array -> State.plugin Js.t

end

module InputRule : sig

  type input_rule

  (** 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

module Menu : sig

  include module type of Bindings.Menu

  val menuItemSpec
    : unit -> menuItemSpec Js.t

  val menu_item
    : t -> menuItemSpec Js.t -> menuItem Js.t
end

(* Example Setup *)

module Example : sig

  include module type of Bindings.Example

  val options 
    : Model.schema Js.t -> options Js.t

  val example_setup
    : t -> options Js.t -> State.plugin Js.t Js.js_array Js.t

  val buildMenuItems 
    : t -> Model.schema Js.t -> menuItems Js.t
end