@depup/prosemirror-state 1.4.4-depup.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,709 @@
1
+ import { Schema, Node, Mark, MarkType, Slice, ResolvedPos } from 'prosemirror-model';
2
+ import { Transform, Mappable } from 'prosemirror-transform';
3
+ import { EditorProps, EditorView } from 'prosemirror-view';
4
+
5
+ /**
6
+ The type of object passed to
7
+ [`EditorState.create`](https://prosemirror.net/docs/ref/#state.EditorState^create).
8
+ */
9
+ interface EditorStateConfig {
10
+ /**
11
+ The schema to use (only relevant if no `doc` is specified).
12
+ */
13
+ schema?: Schema;
14
+ /**
15
+ The starting document. Either this or `schema` _must_ be
16
+ provided.
17
+ */
18
+ doc?: Node;
19
+ /**
20
+ A valid selection in the document.
21
+ */
22
+ selection?: Selection;
23
+ /**
24
+ The initial set of [stored marks](https://prosemirror.net/docs/ref/#state.EditorState.storedMarks).
25
+ */
26
+ storedMarks?: readonly Mark[] | null;
27
+ /**
28
+ The plugins that should be active in this state.
29
+ */
30
+ plugins?: readonly Plugin[];
31
+ }
32
+ /**
33
+ The state of a ProseMirror editor is represented by an object of
34
+ this type. A state is a persistent data structure—it isn't
35
+ updated, but rather a new state value is computed from an old one
36
+ using the [`apply`](https://prosemirror.net/docs/ref/#state.EditorState.apply) method.
37
+
38
+ A state holds a number of built-in fields, and plugins can
39
+ [define](https://prosemirror.net/docs/ref/#state.PluginSpec.state) additional fields.
40
+ */
41
+ declare class EditorState {
42
+ /**
43
+ The current document.
44
+ */
45
+ doc: Node;
46
+ /**
47
+ The selection.
48
+ */
49
+ selection: Selection;
50
+ /**
51
+ A set of marks to apply to the next input. Will be null when
52
+ no explicit marks have been set.
53
+ */
54
+ storedMarks: readonly Mark[] | null;
55
+ /**
56
+ The schema of the state's document.
57
+ */
58
+ get schema(): Schema;
59
+ /**
60
+ The plugins that are active in this state.
61
+ */
62
+ get plugins(): readonly Plugin[];
63
+ /**
64
+ Apply the given transaction to produce a new state.
65
+ */
66
+ apply(tr: Transaction): EditorState;
67
+ /**
68
+ Verbose variant of [`apply`](https://prosemirror.net/docs/ref/#state.EditorState.apply) that
69
+ returns the precise transactions that were applied (which might
70
+ be influenced by the [transaction
71
+ hooks](https://prosemirror.net/docs/ref/#state.PluginSpec.filterTransaction) of
72
+ plugins) along with the new state.
73
+ */
74
+ applyTransaction(rootTr: Transaction): {
75
+ state: EditorState;
76
+ transactions: readonly Transaction[];
77
+ };
78
+ /**
79
+ Accessor that constructs and returns a new [transaction](https://prosemirror.net/docs/ref/#state.Transaction) from this state.
80
+ */
81
+ get tr(): Transaction;
82
+ /**
83
+ Create a new state.
84
+ */
85
+ static create(config: EditorStateConfig): EditorState;
86
+ /**
87
+ Create a new state based on this one, but with an adjusted set
88
+ of active plugins. State fields that exist in both sets of
89
+ plugins are kept unchanged. Those that no longer exist are
90
+ dropped, and those that are new are initialized using their
91
+ [`init`](https://prosemirror.net/docs/ref/#state.StateField.init) method, passing in the new
92
+ configuration object..
93
+ */
94
+ reconfigure(config: {
95
+ /**
96
+ New set of active plugins.
97
+ */
98
+ plugins?: readonly Plugin[];
99
+ }): EditorState;
100
+ /**
101
+ Serialize this state to JSON. If you want to serialize the state
102
+ of plugins, pass an object mapping property names to use in the
103
+ resulting JSON object to plugin objects. The argument may also be
104
+ a string or number, in which case it is ignored, to support the
105
+ way `JSON.stringify` calls `toString` methods.
106
+ */
107
+ toJSON(pluginFields?: {
108
+ [propName: string]: Plugin;
109
+ }): any;
110
+ /**
111
+ Deserialize a JSON representation of a state. `config` should
112
+ have at least a `schema` field, and should contain array of
113
+ plugins to initialize the state with. `pluginFields` can be used
114
+ to deserialize the state of plugins, by associating plugin
115
+ instances with the property names they use in the JSON object.
116
+ */
117
+ static fromJSON(config: {
118
+ /**
119
+ The schema to use.
120
+ */
121
+ schema: Schema;
122
+ /**
123
+ The set of active plugins.
124
+ */
125
+ plugins?: readonly Plugin[];
126
+ }, json: any, pluginFields?: {
127
+ [propName: string]: Plugin;
128
+ }): EditorState;
129
+ }
130
+
131
+ /**
132
+ This is the type passed to the [`Plugin`](https://prosemirror.net/docs/ref/#state.Plugin)
133
+ constructor. It provides a definition for a plugin.
134
+ */
135
+ interface PluginSpec<PluginState> {
136
+ /**
137
+ The [view props](https://prosemirror.net/docs/ref/#view.EditorProps) added by this plugin. Props
138
+ that are functions will be bound to have the plugin instance as
139
+ their `this` binding.
140
+ */
141
+ props?: EditorProps<Plugin<PluginState>>;
142
+ /**
143
+ Allows a plugin to define a [state field](https://prosemirror.net/docs/ref/#state.StateField), an
144
+ extra slot in the state object in which it can keep its own data.
145
+ */
146
+ state?: StateField<PluginState>;
147
+ /**
148
+ Can be used to make this a keyed plugin. You can have only one
149
+ plugin with a given key in a given state, but it is possible to
150
+ access the plugin's configuration and state through the key,
151
+ without having access to the plugin instance object.
152
+ */
153
+ key?: PluginKey;
154
+ /**
155
+ When the plugin needs to interact with the editor view, or
156
+ set something up in the DOM, use this field. The function
157
+ will be called when the plugin's state is associated with an
158
+ editor view.
159
+ */
160
+ view?: (view: EditorView) => PluginView;
161
+ /**
162
+ When present, this will be called before a transaction is
163
+ applied by the state, allowing the plugin to cancel it (by
164
+ returning false).
165
+ */
166
+ filterTransaction?: (tr: Transaction, state: EditorState) => boolean;
167
+ /**
168
+ Allows the plugin to append another transaction to be applied
169
+ after the given array of transactions. When another plugin
170
+ appends a transaction after this was called, it is called again
171
+ with the new state and new transactions—but only the new
172
+ transactions, i.e. it won't be passed transactions that it
173
+ already saw.
174
+ */
175
+ appendTransaction?: (transactions: readonly Transaction[], oldState: EditorState, newState: EditorState) => Transaction | null | undefined;
176
+ /**
177
+ Additional properties are allowed on plugin specs, which can be
178
+ read via [`Plugin.spec`](https://prosemirror.net/docs/ref/#state.Plugin.spec).
179
+ */
180
+ [key: string]: any;
181
+ }
182
+ /**
183
+ A stateful object that can be installed in an editor by a
184
+ [plugin](https://prosemirror.net/docs/ref/#state.PluginSpec.view).
185
+ */
186
+ type PluginView = {
187
+ /**
188
+ Called whenever the view's state is updated.
189
+ */
190
+ update?: (view: EditorView, prevState: EditorState) => void;
191
+ /**
192
+ Called when the view is destroyed or receives a state
193
+ with different plugins.
194
+ */
195
+ destroy?: () => void;
196
+ };
197
+ /**
198
+ Plugins bundle functionality that can be added to an editor.
199
+ They are part of the [editor state](https://prosemirror.net/docs/ref/#state.EditorState) and
200
+ may influence that state and the view that contains it.
201
+ */
202
+ declare class Plugin<PluginState = any> {
203
+ /**
204
+ The plugin's [spec object](https://prosemirror.net/docs/ref/#state.PluginSpec).
205
+ */
206
+ readonly spec: PluginSpec<PluginState>;
207
+ /**
208
+ Create a plugin.
209
+ */
210
+ constructor(
211
+ /**
212
+ The plugin's [spec object](https://prosemirror.net/docs/ref/#state.PluginSpec).
213
+ */
214
+ spec: PluginSpec<PluginState>);
215
+ /**
216
+ The [props](https://prosemirror.net/docs/ref/#view.EditorProps) exported by this plugin.
217
+ */
218
+ readonly props: EditorProps<Plugin<PluginState>>;
219
+ /**
220
+ Extract the plugin's state field from an editor state.
221
+ */
222
+ getState(state: EditorState): PluginState | undefined;
223
+ }
224
+ /**
225
+ A plugin spec may provide a state field (under its
226
+ [`state`](https://prosemirror.net/docs/ref/#state.PluginSpec.state) property) of this type, which
227
+ describes the state it wants to keep. Functions provided here are
228
+ always called with the plugin instance as their `this` binding.
229
+ */
230
+ interface StateField<T> {
231
+ /**
232
+ Initialize the value of the field. `config` will be the object
233
+ passed to [`EditorState.create`](https://prosemirror.net/docs/ref/#state.EditorState^create). Note
234
+ that `instance` is a half-initialized state instance, and will
235
+ not have values for plugin fields initialized after this one.
236
+ */
237
+ init: (config: EditorStateConfig, instance: EditorState) => T;
238
+ /**
239
+ Apply the given transaction to this state field, producing a new
240
+ field value. Note that the `newState` argument is again a partially
241
+ constructed state does not yet contain the state from plugins
242
+ coming after this one.
243
+ */
244
+ apply: (tr: Transaction, value: T, oldState: EditorState, newState: EditorState) => T;
245
+ /**
246
+ Convert this field to JSON. Optional, can be left off to disable
247
+ JSON serialization for the field.
248
+ */
249
+ toJSON?: (value: T) => any;
250
+ /**
251
+ Deserialize the JSON representation of this field. Note that the
252
+ `state` argument is again a half-initialized state.
253
+ */
254
+ fromJSON?: (config: EditorStateConfig, value: any, state: EditorState) => T;
255
+ }
256
+ /**
257
+ A key is used to [tag](https://prosemirror.net/docs/ref/#state.PluginSpec.key) plugins in a way
258
+ that makes it possible to find them, given an editor state.
259
+ Assigning a key does mean only one plugin of that type can be
260
+ active in a state.
261
+ */
262
+ declare class PluginKey<PluginState = any> {
263
+ /**
264
+ Create a plugin key.
265
+ */
266
+ constructor(name?: string);
267
+ /**
268
+ Get the active plugin with this key, if any, from an editor
269
+ state.
270
+ */
271
+ get(state: EditorState): Plugin<PluginState> | undefined;
272
+ /**
273
+ Get the plugin's state from an editor state.
274
+ */
275
+ getState(state: EditorState): PluginState | undefined;
276
+ }
277
+
278
+ /**
279
+ Commands are functions that take a state and a an optional
280
+ transaction dispatch function and...
281
+
282
+ - determine whether they apply to this state
283
+ - if not, return false
284
+ - if `dispatch` was passed, perform their effect, possibly by
285
+ passing a transaction to `dispatch`
286
+ - return true
287
+
288
+ In some cases, the editor view is passed as a third argument.
289
+ */
290
+ type Command = (state: EditorState, dispatch?: (tr: Transaction) => void, view?: EditorView) => boolean;
291
+ /**
292
+ An editor state transaction, which can be applied to a state to
293
+ create an updated state. Use
294
+ [`EditorState.tr`](https://prosemirror.net/docs/ref/#state.EditorState.tr) to create an instance.
295
+
296
+ Transactions track changes to the document (they are a subclass of
297
+ [`Transform`](https://prosemirror.net/docs/ref/#transform.Transform)), but also other state changes,
298
+ like selection updates and adjustments of the set of [stored
299
+ marks](https://prosemirror.net/docs/ref/#state.EditorState.storedMarks). In addition, you can store
300
+ metadata properties in a transaction, which are extra pieces of
301
+ information that client code or plugins can use to describe what a
302
+ transaction represents, so that they can update their [own
303
+ state](https://prosemirror.net/docs/ref/#state.StateField) accordingly.
304
+
305
+ The [editor view](https://prosemirror.net/docs/ref/#view.EditorView) uses a few metadata
306
+ properties: it will attach a property `"pointer"` with the value
307
+ `true` to selection transactions directly caused by mouse or touch
308
+ input, a `"composition"` property holding an ID identifying the
309
+ composition that caused it to transactions caused by composed DOM
310
+ input, and a `"uiEvent"` property of that may be `"paste"`,
311
+ `"cut"`, or `"drop"`.
312
+ */
313
+ declare class Transaction extends Transform {
314
+ /**
315
+ The timestamp associated with this transaction, in the same
316
+ format as `Date.now()`.
317
+ */
318
+ time: number;
319
+ private curSelection;
320
+ private curSelectionFor;
321
+ private updated;
322
+ private meta;
323
+ /**
324
+ The stored marks set by this transaction, if any.
325
+ */
326
+ storedMarks: readonly Mark[] | null;
327
+ /**
328
+ The transaction's current selection. This defaults to the editor
329
+ selection [mapped](https://prosemirror.net/docs/ref/#state.Selection.map) through the steps in the
330
+ transaction, but can be overwritten with
331
+ [`setSelection`](https://prosemirror.net/docs/ref/#state.Transaction.setSelection).
332
+ */
333
+ get selection(): Selection;
334
+ /**
335
+ Update the transaction's current selection. Will determine the
336
+ selection that the editor gets when the transaction is applied.
337
+ */
338
+ setSelection(selection: Selection): this;
339
+ /**
340
+ Whether the selection was explicitly updated by this transaction.
341
+ */
342
+ get selectionSet(): boolean;
343
+ /**
344
+ Set the current stored marks.
345
+ */
346
+ setStoredMarks(marks: readonly Mark[] | null): this;
347
+ /**
348
+ Make sure the current stored marks or, if that is null, the marks
349
+ at the selection, match the given set of marks. Does nothing if
350
+ this is already the case.
351
+ */
352
+ ensureMarks(marks: readonly Mark[]): this;
353
+ /**
354
+ Add a mark to the set of stored marks.
355
+ */
356
+ addStoredMark(mark: Mark): this;
357
+ /**
358
+ Remove a mark or mark type from the set of stored marks.
359
+ */
360
+ removeStoredMark(mark: Mark | MarkType): this;
361
+ /**
362
+ Whether the stored marks were explicitly set for this transaction.
363
+ */
364
+ get storedMarksSet(): boolean;
365
+ /**
366
+ Update the timestamp for the transaction.
367
+ */
368
+ setTime(time: number): this;
369
+ /**
370
+ Replace the current selection with the given slice.
371
+ */
372
+ replaceSelection(slice: Slice): this;
373
+ /**
374
+ Replace the selection with the given node. When `inheritMarks` is
375
+ true and the content is inline, it inherits the marks from the
376
+ place where it is inserted.
377
+ */
378
+ replaceSelectionWith(node: Node, inheritMarks?: boolean): this;
379
+ /**
380
+ Delete the selection.
381
+ */
382
+ deleteSelection(): this;
383
+ /**
384
+ Replace the given range, or the selection if no range is given,
385
+ with a text node containing the given string.
386
+ */
387
+ insertText(text: string, from?: number, to?: number): this;
388
+ /**
389
+ Store a metadata property in this transaction, keyed either by
390
+ name or by plugin.
391
+ */
392
+ setMeta(key: string | Plugin | PluginKey, value: any): this;
393
+ /**
394
+ Retrieve a metadata property for a given name or plugin.
395
+ */
396
+ getMeta(key: string | Plugin | PluginKey): any;
397
+ /**
398
+ Returns true if this transaction doesn't contain any metadata,
399
+ and can thus safely be extended.
400
+ */
401
+ get isGeneric(): boolean;
402
+ /**
403
+ Indicate that the editor should scroll the selection into view
404
+ when updated to the state produced by this transaction.
405
+ */
406
+ scrollIntoView(): this;
407
+ /**
408
+ True when this transaction has had `scrollIntoView` called on it.
409
+ */
410
+ get scrolledIntoView(): boolean;
411
+ }
412
+
413
+ /**
414
+ Superclass for editor selections. Every selection type should
415
+ extend this. Should not be instantiated directly.
416
+ */
417
+ declare abstract class Selection {
418
+ /**
419
+ The resolved anchor of the selection (the side that stays in
420
+ place when the selection is modified).
421
+ */
422
+ readonly $anchor: ResolvedPos;
423
+ /**
424
+ The resolved head of the selection (the side that moves when
425
+ the selection is modified).
426
+ */
427
+ readonly $head: ResolvedPos;
428
+ /**
429
+ Initialize a selection with the head and anchor and ranges. If no
430
+ ranges are given, constructs a single range across `$anchor` and
431
+ `$head`.
432
+ */
433
+ constructor(
434
+ /**
435
+ The resolved anchor of the selection (the side that stays in
436
+ place when the selection is modified).
437
+ */
438
+ $anchor: ResolvedPos,
439
+ /**
440
+ The resolved head of the selection (the side that moves when
441
+ the selection is modified).
442
+ */
443
+ $head: ResolvedPos, ranges?: readonly SelectionRange[]);
444
+ /**
445
+ The ranges covered by the selection.
446
+ */
447
+ ranges: readonly SelectionRange[];
448
+ /**
449
+ The selection's anchor, as an unresolved position.
450
+ */
451
+ get anchor(): number;
452
+ /**
453
+ The selection's head.
454
+ */
455
+ get head(): number;
456
+ /**
457
+ The lower bound of the selection's main range.
458
+ */
459
+ get from(): number;
460
+ /**
461
+ The upper bound of the selection's main range.
462
+ */
463
+ get to(): number;
464
+ /**
465
+ The resolved lower bound of the selection's main range.
466
+ */
467
+ get $from(): ResolvedPos;
468
+ /**
469
+ The resolved upper bound of the selection's main range.
470
+ */
471
+ get $to(): ResolvedPos;
472
+ /**
473
+ Indicates whether the selection contains any content.
474
+ */
475
+ get empty(): boolean;
476
+ /**
477
+ Test whether the selection is the same as another selection.
478
+ */
479
+ abstract eq(selection: Selection): boolean;
480
+ /**
481
+ Map this selection through a [mappable](https://prosemirror.net/docs/ref/#transform.Mappable)
482
+ thing. `doc` should be the new document to which we are mapping.
483
+ */
484
+ abstract map(doc: Node, mapping: Mappable): Selection;
485
+ /**
486
+ Get the content of this selection as a slice.
487
+ */
488
+ content(): Slice;
489
+ /**
490
+ Replace the selection with a slice or, if no slice is given,
491
+ delete the selection. Will append to the given transaction.
492
+ */
493
+ replace(tr: Transaction, content?: Slice): void;
494
+ /**
495
+ Replace the selection with the given node, appending the changes
496
+ to the given transaction.
497
+ */
498
+ replaceWith(tr: Transaction, node: Node): void;
499
+ /**
500
+ Convert the selection to a JSON representation. When implementing
501
+ this for a custom selection class, make sure to give the object a
502
+ `type` property whose value matches the ID under which you
503
+ [registered](https://prosemirror.net/docs/ref/#state.Selection^jsonID) your class.
504
+ */
505
+ abstract toJSON(): any;
506
+ /**
507
+ Find a valid cursor or leaf node selection starting at the given
508
+ position and searching back if `dir` is negative, and forward if
509
+ positive. When `textOnly` is true, only consider cursor
510
+ selections. Will return null when no valid selection position is
511
+ found.
512
+ */
513
+ static findFrom($pos: ResolvedPos, dir: number, textOnly?: boolean): Selection | null;
514
+ /**
515
+ Find a valid cursor or leaf node selection near the given
516
+ position. Searches forward first by default, but if `bias` is
517
+ negative, it will search backwards first.
518
+ */
519
+ static near($pos: ResolvedPos, bias?: number): Selection;
520
+ /**
521
+ Find the cursor or leaf node selection closest to the start of
522
+ the given document. Will return an
523
+ [`AllSelection`](https://prosemirror.net/docs/ref/#state.AllSelection) if no valid position
524
+ exists.
525
+ */
526
+ static atStart(doc: Node): Selection;
527
+ /**
528
+ Find the cursor or leaf node selection closest to the end of the
529
+ given document.
530
+ */
531
+ static atEnd(doc: Node): Selection;
532
+ /**
533
+ Deserialize the JSON representation of a selection. Must be
534
+ implemented for custom classes (as a static class method).
535
+ */
536
+ static fromJSON(doc: Node, json: any): Selection;
537
+ /**
538
+ To be able to deserialize selections from JSON, custom selection
539
+ classes must register themselves with an ID string, so that they
540
+ can be disambiguated. Try to pick something that's unlikely to
541
+ clash with classes from other modules.
542
+ */
543
+ static jsonID(id: string, selectionClass: {
544
+ fromJSON: (doc: Node, json: any) => Selection;
545
+ }): {
546
+ fromJSON: (doc: Node, json: any) => Selection;
547
+ };
548
+ /**
549
+ Get a [bookmark](https://prosemirror.net/docs/ref/#state.SelectionBookmark) for this selection,
550
+ which is a value that can be mapped without having access to a
551
+ current document, and later resolved to a real selection for a
552
+ given document again. (This is used mostly by the history to
553
+ track and restore old selections.) The default implementation of
554
+ this method just converts the selection to a text selection and
555
+ returns the bookmark for that.
556
+ */
557
+ getBookmark(): SelectionBookmark;
558
+ /**
559
+ Controls whether, when a selection of this type is active in the
560
+ browser, the selected range should be visible to the user.
561
+ Defaults to `true`.
562
+ */
563
+ visible: boolean;
564
+ }
565
+ /**
566
+ A lightweight, document-independent representation of a selection.
567
+ You can define a custom bookmark type for a custom selection class
568
+ to make the history handle it well.
569
+ */
570
+ interface SelectionBookmark {
571
+ /**
572
+ Map the bookmark through a set of changes.
573
+ */
574
+ map: (mapping: Mappable) => SelectionBookmark;
575
+ /**
576
+ Resolve the bookmark to a real selection again. This may need to
577
+ do some error checking and may fall back to a default (usually
578
+ [`TextSelection.between`](https://prosemirror.net/docs/ref/#state.TextSelection^between)) if
579
+ mapping made the bookmark invalid.
580
+ */
581
+ resolve: (doc: Node) => Selection;
582
+ }
583
+ /**
584
+ Represents a selected range in a document.
585
+ */
586
+ declare class SelectionRange {
587
+ /**
588
+ The lower bound of the range.
589
+ */
590
+ readonly $from: ResolvedPos;
591
+ /**
592
+ The upper bound of the range.
593
+ */
594
+ readonly $to: ResolvedPos;
595
+ /**
596
+ Create a range.
597
+ */
598
+ constructor(
599
+ /**
600
+ The lower bound of the range.
601
+ */
602
+ $from: ResolvedPos,
603
+ /**
604
+ The upper bound of the range.
605
+ */
606
+ $to: ResolvedPos);
607
+ }
608
+ /**
609
+ A text selection represents a classical editor selection, with a
610
+ head (the moving side) and anchor (immobile side), both of which
611
+ point into textblock nodes. It can be empty (a regular cursor
612
+ position).
613
+ */
614
+ declare class TextSelection extends Selection {
615
+ /**
616
+ Construct a text selection between the given points.
617
+ */
618
+ constructor($anchor: ResolvedPos, $head?: ResolvedPos);
619
+ /**
620
+ Returns a resolved position if this is a cursor selection (an
621
+ empty text selection), and null otherwise.
622
+ */
623
+ get $cursor(): ResolvedPos | null;
624
+ map(doc: Node, mapping: Mappable): Selection;
625
+ replace(tr: Transaction, content?: Slice): void;
626
+ eq(other: Selection): boolean;
627
+ getBookmark(): TextBookmark;
628
+ toJSON(): any;
629
+ /**
630
+ Create a text selection from non-resolved positions.
631
+ */
632
+ static create(doc: Node, anchor: number, head?: number): TextSelection;
633
+ /**
634
+ Return a text selection that spans the given positions or, if
635
+ they aren't text positions, find a text selection near them.
636
+ `bias` determines whether the method searches forward (default)
637
+ or backwards (negative number) first. Will fall back to calling
638
+ [`Selection.near`](https://prosemirror.net/docs/ref/#state.Selection^near) when the document
639
+ doesn't contain a valid text position.
640
+ */
641
+ static between($anchor: ResolvedPos, $head: ResolvedPos, bias?: number): Selection;
642
+ }
643
+ declare class TextBookmark {
644
+ readonly anchor: number;
645
+ readonly head: number;
646
+ constructor(anchor: number, head: number);
647
+ map(mapping: Mappable): TextBookmark;
648
+ resolve(doc: Node): Selection;
649
+ }
650
+ /**
651
+ A node selection is a selection that points at a single node. All
652
+ nodes marked [selectable](https://prosemirror.net/docs/ref/#model.NodeSpec.selectable) can be the
653
+ target of a node selection. In such a selection, `from` and `to`
654
+ point directly before and after the selected node, `anchor` equals
655
+ `from`, and `head` equals `to`..
656
+ */
657
+ declare class NodeSelection extends Selection {
658
+ /**
659
+ Create a node selection. Does not verify the validity of its
660
+ argument.
661
+ */
662
+ constructor($pos: ResolvedPos);
663
+ /**
664
+ The selected node.
665
+ */
666
+ node: Node;
667
+ map(doc: Node, mapping: Mappable): Selection;
668
+ content(): Slice;
669
+ eq(other: Selection): boolean;
670
+ toJSON(): any;
671
+ getBookmark(): NodeBookmark;
672
+ /**
673
+ Create a node selection from non-resolved positions.
674
+ */
675
+ static create(doc: Node, from: number): NodeSelection;
676
+ /**
677
+ Determines whether the given node may be selected as a node
678
+ selection.
679
+ */
680
+ static isSelectable(node: Node): boolean;
681
+ }
682
+ declare class NodeBookmark {
683
+ readonly anchor: number;
684
+ constructor(anchor: number);
685
+ map(mapping: Mappable): TextBookmark | NodeBookmark;
686
+ resolve(doc: Node): Selection | NodeSelection;
687
+ }
688
+ /**
689
+ A selection type that represents selecting the whole document
690
+ (which can not necessarily be expressed with a text selection, when
691
+ there are for example leaf block nodes at the start or end of the
692
+ document).
693
+ */
694
+ declare class AllSelection extends Selection {
695
+ /**
696
+ Create an all-selection over the given document.
697
+ */
698
+ constructor(doc: Node);
699
+ replace(tr: Transaction, content?: Slice): void;
700
+ toJSON(): any;
701
+ map(doc: Node): AllSelection;
702
+ eq(other: Selection): boolean;
703
+ getBookmark(): {
704
+ map(): any;
705
+ resolve(doc: Node): AllSelection;
706
+ };
707
+ }
708
+
709
+ export { AllSelection, type Command, EditorState, type EditorStateConfig, NodeSelection, Plugin, PluginKey, type PluginSpec, type PluginView, Selection, type SelectionBookmark, SelectionRange, type StateField, TextSelection, Transaction };