@vite-hub/realtime 0.0.3 → 0.1.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.
package/dist/vue.d.ts CHANGED
@@ -1,3819 +1,78 @@
1
- import { i as RealtimePerson, o as RealtimeWorkspaceChange, t as RealtimeCheckpoint } from "./types-BSDtKw5d.js";
2
- import { Extension, MappablePosition } from "@tiptap/core";
3
- import * as Y from "yjs";
4
- import { Doc, XmlFragment } from "yjs";
5
- import { MaybeRefOrGetter } from "vue";
6
- import { WebsocketProvider } from "y-websocket";
7
-
8
- //#region ../../node_modules/.pnpm/orderedmap@2.1.1/node_modules/orderedmap/dist/index.d.ts
9
- declare class OrderedMap<T = any> {
10
- private constructor(content: Array<string | T>);
11
- get(key: string): T | undefined;
12
- update(key: string, value: T, newKey?: string): OrderedMap<T>;
13
- remove(key: string): OrderedMap<T>;
14
- addToStart(key: string, value: T): OrderedMap<T>;
15
- addToEnd(key: string, value: T): OrderedMap<T>;
16
- addBefore(place: string, key: string, value: T): OrderedMap<T>;
17
- forEach(fn: (key: string, value: T) => any): void;
18
- prepend(map: MapLike<T>): OrderedMap<T>;
19
- append(map: MapLike<T>): OrderedMap<T>;
20
- subtract(map: MapLike<T>): OrderedMap<T>;
21
- toObject(): Record<string, T>;
22
- readonly size: number;
23
- static from<T>(map: MapLike<T>): OrderedMap<T>;
24
- }
25
- type MapLike<T = any> = Record<string, T> | OrderedMap<T>;
26
- //#endregion
27
- //#region ../../node_modules/.pnpm/prosemirror-model@1.25.11/node_modules/prosemirror-model/dist/index.d.ts
28
- /**
29
- A mark is a piece of information that can be attached to a node,
30
- such as it being emphasized, in code font, or a link. It has a
31
- type and optionally a set of attributes that provide further
32
- information (such as the target of the link). Marks are created
33
- through a `Schema`, which controls which types exist and which
34
- attributes they have.
35
- */
36
- declare class Mark {
37
- /**
38
- The type of this mark.
39
- */
40
- readonly type: MarkType;
41
- /**
42
- The attributes associated with this mark.
43
- */
44
- readonly attrs: Attrs;
45
- /**
46
- Given a set of marks, create a new set which contains this one as
47
- well, in the right position. If this mark is already in the set,
48
- the set itself is returned. If any marks that are set to be
49
- [exclusive](https://prosemirror.net/docs/ref/#model.MarkSpec.excludes) with this mark are present,
50
- those are replaced by this one.
51
- */
52
- addToSet(set: readonly Mark[]): readonly Mark[];
53
- /**
54
- Remove this mark from the given set, returning a new set. If this
55
- mark is not in the set, the set itself is returned.
56
- */
57
- removeFromSet(set: readonly Mark[]): readonly Mark[];
58
- /**
59
- Test whether this mark is in the given set of marks.
60
- */
61
- isInSet(set: readonly Mark[]): boolean;
62
- /**
63
- Test whether this mark has the same type and attributes as
64
- another mark.
65
- */
66
- eq(other: Mark): boolean;
67
- /**
68
- Convert this mark to a JSON-serializeable representation.
69
- */
70
- toJSON(): any;
71
- /**
72
- Deserialize a mark from JSON.
73
- */
74
- static fromJSON(schema: Schema, json: any): Mark;
75
- /**
76
- Test whether two sets of marks are identical.
77
- */
78
- static sameSet(a: readonly Mark[], b: readonly Mark[]): boolean;
79
- /**
80
- Create a properly sorted mark set from null, a single mark, or an
81
- unsorted array of marks.
82
- */
83
- static setFrom(marks?: Mark | readonly Mark[] | null): readonly Mark[];
84
- /**
85
- The empty set of marks.
86
- */
87
- static none: readonly Mark[];
88
- }
89
- /**
90
- A description of a DOM structure. Can be either a DOM element, a
91
- `{dom, contentDOM}` object, or an array.
92
-
93
- An array describes a DOM element. The first value in the array
94
- should be a string—the name of the DOM element, optionally
95
- prefixed by a namespace URL and a space. If the second element is
96
- plain object, it is interpreted as a set of attributes for the
97
- element. Any elements after that (including the 2nd if it's not an
98
- attribute object) are interpreted as children of the DOM elements,
99
- and must either be valid `DOMOutputSpec` values, strings (for text
100
- nodes), or the number zero.
101
-
102
- The number zero (pronounced “hole”) is used to indicate the place
103
- where a node's child nodes should be inserted. If it occurs in an
104
- output spec, it should be the only child element in its parent
105
- node.
106
- */
107
- type DOMOutputSpec = Element | {
108
- dom: Element;
109
- contentDOM?: Element;
110
- } | readonly [string, ...any[]];
111
- /**
112
- A DOM serializer knows how to convert ProseMirror nodes and
113
- marks of various types to DOM nodes.
114
- */
115
- declare class DOMSerializer {
116
- /**
117
- The node serialization functions.
118
- */
119
- readonly nodes: {
120
- [node: string]: (node: Node$1) => DOMOutputSpec;
121
- };
122
- /**
123
- The mark serialization functions.
124
- */
125
- readonly marks: {
126
- [mark: string]: (mark: Mark, inline: boolean) => DOMOutputSpec;
127
- };
128
- /**
129
- Create a serializer. `nodes` should map node names to functions
130
- that take a node and return a description of the corresponding
131
- DOM. `marks` does the same for mark names, but also gets an
132
- argument that tells it whether the mark's content is block or
133
- inline content (for typical use, it'll always be inline). A mark
134
- serializer may be `null` to indicate that marks of that type
135
- should not be serialized.
136
- */
137
- constructor(
138
- /**
139
- The node serialization functions.
140
- */
141
-
142
- nodes: {
143
- [node: string]: (node: Node$1) => DOMOutputSpec;
144
- },
145
- /**
146
- The mark serialization functions.
147
- */
148
-
149
- marks: {
150
- [mark: string]: (mark: Mark, inline: boolean) => DOMOutputSpec;
151
- });
152
- /**
153
- Serialize the content of this fragment to a DOM fragment. When
154
- not in the browser, the `document` option, containing a DOM
155
- document, should be passed so that the serializer can create
156
- nodes.
157
- */
158
- serializeFragment(fragment: Fragment, options?: {
159
- document?: Document;
160
- }, target?: HTMLElement | DocumentFragment): DocumentFragment | HTMLElement;
161
- /**
162
- Serialize this node to a DOM node. This can be useful when you
163
- need to serialize a part of a document, as opposed to the whole
164
- document. To serialize a whole document, use
165
- [`serializeFragment`](https://prosemirror.net/docs/ref/#model.DOMSerializer.serializeFragment) on
166
- its [content](https://prosemirror.net/docs/ref/#model.Node.content).
167
- */
168
- serializeNode(node: Node$1, options?: {
169
- document?: Document;
170
- }): HTMLElement | Text;
171
- /**
172
- Render an [output spec](https://prosemirror.net/docs/ref/#model.DOMOutputSpec) to a DOM node. If
173
- the spec has a hole (zero) in it, `contentDOM` will point at the
174
- node with the hole.
175
- */
176
- static renderSpec(doc: Document, structure: DOMOutputSpec, xmlNS?: string | null): {
177
- dom: HTMLElement;
178
- contentDOM?: HTMLElement;
179
- };
180
- /**
181
- Build a serializer using the [`toDOM`](https://prosemirror.net/docs/ref/#model.NodeSpec.toDOM)
182
- properties in a schema's node and mark specs.
183
- */
184
- static fromSchema(schema: Schema): DOMSerializer;
185
- /**
186
- Gather the serializers in a schema's node specs into an object.
187
- This can be useful as a base to build a custom serializer from.
188
- */
189
- static nodesFromSchema(schema: Schema): {
190
- [node: string]: (node: Node$1) => DOMOutputSpec;
191
- };
192
- /**
193
- Gather the serializers in a schema's mark specs into an object.
194
- */
195
- static marksFromSchema(schema: Schema): {
196
- [mark: string]: (mark: Mark, inline: boolean) => DOMOutputSpec;
197
- };
198
- }
199
- /**
200
- You can [_resolve_](https://prosemirror.net/docs/ref/#model.Node.resolve) a position to get more
201
- information about it. Objects of this class represent such a
202
- resolved position, providing various pieces of context
203
- information, and some helper methods.
204
-
205
- Throughout this interface, methods that take an optional `depth`
206
- parameter will interpret undefined as `this.depth` and negative
207
- numbers as `this.depth + value`.
208
- */
209
- declare class ResolvedPos {
210
- /**
211
- The position that was resolved.
212
- */
213
- readonly pos: number;
214
- /**
215
- The offset this position has into its parent node.
216
- */
217
- readonly parentOffset: number;
218
- /**
219
- The number of levels the parent node is from the root. If this
220
- position points directly into the root node, it is 0. If it
221
- points into a top-level paragraph, 1, and so on.
222
- */
223
- depth: number;
224
- /**
225
- The parent node that the position points into. Note that even if
226
- a position points into a text node, that node is not considered
227
- the parent—text nodes are ‘flat’ in this model, and have no content.
228
- */
229
- get parent(): Node$1;
230
- /**
231
- The root node in which the position was resolved.
232
- */
233
- get doc(): Node$1;
234
- /**
235
- The ancestor node at the given level. `p.node(p.depth)` is the
236
- same as `p.parent`.
237
- */
238
- node(depth?: number | null): Node$1;
239
- /**
240
- The index into the ancestor at the given level. If this points
241
- at the 3rd node in the 2nd paragraph on the top level, for
242
- example, `p.index(0)` is 1 and `p.index(1)` is 2.
243
- */
244
- index(depth?: number | null): number;
245
- /**
246
- The index pointing after this position into the ancestor at the
247
- given level.
248
- */
249
- indexAfter(depth?: number | null): number;
250
- /**
251
- The (absolute) position at the start of the node at the given
252
- level.
253
- */
254
- start(depth?: number | null): number;
255
- /**
256
- The (absolute) position at the end of the node at the given
257
- level.
258
- */
259
- end(depth?: number | null): number;
260
- /**
261
- The (absolute) position directly before the wrapping node at the
262
- given level, or, when `depth` is `this.depth + 1`, the original
263
- position.
264
- */
265
- before(depth?: number | null): number;
266
- /**
267
- The (absolute) position directly after the wrapping node at the
268
- given level, or the original position when `depth` is `this.depth + 1`.
269
- */
270
- after(depth?: number | null): number;
271
- /**
272
- When this position points into a text node, this returns the
273
- distance between the position and the start of the text node.
274
- Will be zero for positions that point between nodes.
275
- */
276
- get textOffset(): number;
277
- /**
278
- Get the node directly after the position, if any. If the position
279
- points into a text node, only the part of that node after the
280
- position is returned.
281
- */
282
- get nodeAfter(): Node$1 | null;
283
- /**
284
- Get the node directly before the position, if any. If the
285
- position points into a text node, only the part of that node
286
- before the position is returned.
287
- */
288
- get nodeBefore(): Node$1 | null;
289
- /**
290
- Get the position at the given index in the parent node at the
291
- given depth (which defaults to `this.depth`).
292
- */
293
- posAtIndex(index: number, depth?: number | null): number;
294
- /**
295
- Get the marks at this position, factoring in the surrounding
296
- marks' [`inclusive`](https://prosemirror.net/docs/ref/#model.MarkSpec.inclusive) property. If the
297
- position is at the start of a non-empty node, the marks of the
298
- node after it (if any) are returned.
299
- */
300
- marks(): readonly Mark[];
301
- /**
302
- Get the marks after the current position, if any, except those
303
- that are non-inclusive and not present at position `$end`. This
304
- is mostly useful for getting the set of marks to preserve after a
305
- deletion. Will return `null` if this position is at the end of
306
- its parent node or its parent node isn't a textblock (in which
307
- case no marks should be preserved).
308
- */
309
- marksAcross($end: ResolvedPos): readonly Mark[] | null;
310
- /**
311
- The depth up to which this position and the given (non-resolved)
312
- position share the same parent nodes.
313
- */
314
- sharedDepth(pos: number): number;
315
- /**
316
- Returns a range based on the place where this position and the
317
- given position diverge around block content. If both point into
318
- the same textblock, for example, a range around that textblock
319
- will be returned. If they point into different blocks, the range
320
- around those blocks in their shared ancestor is returned. You can
321
- pass in an optional predicate that will be called with a parent
322
- node to see if a range into that parent is acceptable.
323
- */
324
- blockRange(other?: ResolvedPos, pred?: (node: Node$1) => boolean): NodeRange | null;
325
- /**
326
- Query whether the given position shares the same parent node.
327
- */
328
- sameParent(other: ResolvedPos): boolean;
329
- /**
330
- Return the greater of this and the given position.
331
- */
332
- max(other: ResolvedPos): ResolvedPos;
333
- /**
334
- Return the smaller of this and the given position.
335
- */
336
- min(other: ResolvedPos): ResolvedPos;
337
- }
338
- /**
339
- Represents a flat range of content, i.e. one that starts and
340
- ends in the same node.
341
- */
342
- declare class NodeRange {
343
- /**
344
- A resolved position along the start of the content. May have a
345
- `depth` greater than this object's `depth` property, since
346
- these are the positions that were used to compute the range,
347
- not re-resolved positions directly at its boundaries.
348
- */
349
- readonly $from: ResolvedPos;
350
- /**
351
- A position along the end of the content. See
352
- caveat for [`$from`](https://prosemirror.net/docs/ref/#model.NodeRange.$from).
353
- */
354
- readonly $to: ResolvedPos;
355
- /**
356
- The depth of the node that this range points into.
357
- */
358
- readonly depth: number;
359
- /**
360
- Construct a node range. `$from` and `$to` should point into the
361
- same node until at least the given `depth`, since a node range
362
- denotes an adjacent set of nodes in a single parent node.
363
- */
364
- constructor(
365
- /**
366
- A resolved position along the start of the content. May have a
367
- `depth` greater than this object's `depth` property, since
368
- these are the positions that were used to compute the range,
369
- not re-resolved positions directly at its boundaries.
370
- */
371
-
372
- $from: ResolvedPos,
373
- /**
374
- A position along the end of the content. See
375
- caveat for [`$from`](https://prosemirror.net/docs/ref/#model.NodeRange.$from).
376
- */
377
-
378
- $to: ResolvedPos,
379
- /**
380
- The depth of the node that this range points into.
381
- */
382
-
383
- depth: number);
384
- /**
385
- The position at the start of the range.
386
- */
387
- get start(): number;
388
- /**
389
- The position at the end of the range.
390
- */
391
- get end(): number;
392
- /**
393
- The parent node that the range points into.
394
- */
395
- get parent(): Node$1;
396
- /**
397
- The start index of the range in the parent node.
398
- */
399
- get startIndex(): number;
400
- /**
401
- The end index of the range in the parent node.
402
- */
403
- get endIndex(): number;
404
- }
405
- /**
406
- Error type raised by [`Node.replace`](https://prosemirror.net/docs/ref/#model.Node.replace) when
407
- given an invalid replacement.
408
- */
409
- /**
410
- A slice represents a piece cut out of a larger document. It
411
- stores not only a fragment, but also the depth up to which nodes on
412
- both side are ‘open’ (cut through).
413
- */
414
- declare class Slice {
415
- /**
416
- The slice's content.
417
- */
418
- readonly content: Fragment;
419
- /**
420
- The open depth at the start of the fragment.
421
- */
422
- readonly openStart: number;
423
- /**
424
- The open depth at the end.
425
- */
426
- readonly openEnd: number;
427
- /**
428
- Create a slice. When specifying a non-zero open depth, you must
429
- make sure that there are nodes of at least that depth at the
430
- appropriate side of the fragment—i.e. if the fragment is an
431
- empty paragraph node, `openStart` and `openEnd` can't be greater
432
- than 1.
433
-
434
- It is not necessary for the content of open nodes to conform to
435
- the schema's content constraints, though it should be a valid
436
- start/end/middle for such a node, depending on which sides are
437
- open.
438
- */
439
- constructor(
440
- /**
441
- The slice's content.
442
- */
443
-
444
- content: Fragment,
445
- /**
446
- The open depth at the start of the fragment.
447
- */
448
-
449
- openStart: number,
450
- /**
451
- The open depth at the end.
452
- */
453
-
454
- openEnd: number);
455
- /**
456
- The size this slice would add when inserted into a document.
457
- */
458
- get size(): number;
459
- /**
460
- Tests whether this slice is equal to another slice.
461
- */
462
- eq(other: Slice): boolean;
463
- /**
464
- Convert a slice to a JSON-serializable representation.
465
- */
466
- toJSON(): any;
467
- /**
468
- Deserialize a slice from its JSON representation.
469
- */
470
- static fromJSON(schema: Schema, json: any): Slice;
471
- /**
472
- Create a slice from a fragment by taking the maximum possible
473
- open value on both side of the fragment.
474
- */
475
- static maxOpen(fragment: Fragment, openIsolating?: boolean): Slice;
476
- /**
477
- The empty slice.
478
- */
479
- static empty: Slice;
480
- }
481
- type DOMNode$1 = InstanceType<typeof window.Node>;
482
- /**
483
- These are the options recognized by the
484
- [`parse`](https://prosemirror.net/docs/ref/#model.DOMParser.parse) and
485
- [`parseSlice`](https://prosemirror.net/docs/ref/#model.DOMParser.parseSlice) methods.
486
- */
487
- interface ParseOptions {
488
- /**
489
- By default, whitespace is collapsed as per HTML's rules. Pass
490
- `true` to preserve whitespace, but normalize newlines to
491
- spaces or, if available, [line break replacements](https://prosemirror.net/docs/ref/#model.NodeSpec.linebreakReplacement),
492
- and `"full"` to preserve whitespace entirely.
493
- */
494
- preserveWhitespace?: boolean | "full";
495
- /**
496
- When given, the parser will, beside parsing the content,
497
- record the document positions of the given DOM positions. It
498
- will do so by writing to the objects, adding a `pos` property
499
- that holds the document position. DOM positions that are not
500
- in the parsed content will not be written to.
501
- */
502
- findPositions?: {
503
- node: DOMNode$1;
504
- offset: number;
505
- pos?: number;
506
- }[];
507
- /**
508
- The child node index to start parsing from.
509
- */
510
- from?: number;
511
- /**
512
- The child node index to stop parsing at.
513
- */
514
- to?: number;
515
- /**
516
- By default, the content is parsed into the schema's default
517
- [top node type](https://prosemirror.net/docs/ref/#model.Schema.topNodeType). You can pass this
518
- option to use the type and attributes from a different node
519
- as the top container.
520
- */
521
- topNode?: Node$1;
522
- /**
523
- Provide the starting content match that content parsed into the
524
- top node is matched against.
525
- */
526
- topMatch?: ContentMatch;
527
- /**
528
- A set of additional nodes to count as
529
- [context](https://prosemirror.net/docs/ref/#model.GenericParseRule.context) when parsing, above the
530
- given [top node](https://prosemirror.net/docs/ref/#model.ParseOptions.topNode).
531
- */
532
- context?: ResolvedPos;
533
- }
534
- /**
535
- Fields that may be present in both [tag](https://prosemirror.net/docs/ref/#model.TagParseRule) and
536
- [style](https://prosemirror.net/docs/ref/#model.StyleParseRule) parse rules.
537
- */
538
- interface GenericParseRule {
539
- /**
540
- Can be used to change the order in which the parse rules in a
541
- schema are tried. Those with higher priority come first. Rules
542
- without a priority are counted as having priority 50. This
543
- property is only meaningful in a schema—when directly
544
- constructing a parser, the order of the rule array is used.
545
- */
546
- priority?: number;
547
- /**
548
- By default, when a rule matches an element or style, no further
549
- rules get a chance to match it. By setting this to `false`, you
550
- indicate that even when this rule matches, other rules that come
551
- after it should also run.
552
- */
553
- consuming?: boolean;
554
- /**
555
- When given, restricts this rule to only match when the current
556
- context—the parent nodes into which the content is being
557
- parsed—matches this expression. Should contain one or more node
558
- names or node group names followed by single or double slashes.
559
- For example `"paragraph/"` means the rule only matches when the
560
- parent node is a paragraph, `"blockquote/paragraph/"` restricts
561
- it to be in a paragraph that is inside a blockquote, and
562
- `"section//"` matches any position inside a section—a double
563
- slash matches any sequence of ancestor nodes. To allow multiple
564
- different contexts, they can be separated by a pipe (`|`)
565
- character, as in `"blockquote/|list_item/"`.
566
- */
567
- context?: string;
568
- /**
569
- The name of the mark type to wrap the matched content in.
570
- */
571
- mark?: string;
572
- /**
573
- When true, ignore content that matches this rule. Any `<head>`,
574
- `<noscript>`, `<script>`, `<object>`, `<style>`, or `<title>`
575
- tags encountered are automatically ignored when no rules match
576
- them..
577
- */
578
- ignore?: boolean;
579
- /**
580
- When true, finding an element that matches this rule will close
581
- the current node.
582
- */
583
- closeParent?: boolean;
584
- /**
585
- When true, ignore the node that matches this rule, but do parse
586
- its content.
587
- */
588
- skip?: boolean;
589
- /**
590
- Attributes for the node or mark created by this rule. When
591
- `getAttrs` is provided, it takes precedence.
592
- */
593
- attrs?: Attrs;
594
- }
595
- /**
596
- Parse rule targeting a DOM element.
597
- */
598
- interface TagParseRule extends GenericParseRule {
599
- /**
600
- A CSS selector describing the kind of DOM elements to match.
601
- */
602
- tag: string;
603
- /**
604
- The namespace to match. Nodes are only matched when the
605
- namespace matches or this property is null.
606
- */
607
- namespace?: string;
608
- /**
609
- The name of the node type to create when this rule matches. Each
610
- rule should have either a `node`, `mark`, or `ignore` property
611
- (except when it appears in a [node](https://prosemirror.net/docs/ref/#model.NodeSpec.parseDOM) or
612
- [mark spec](https://prosemirror.net/docs/ref/#model.MarkSpec.parseDOM), in which case the `node`
613
- or `mark` property will be derived from its position).
614
- */
615
- node?: string;
616
- /**
617
- A function used to compute the attributes for the node or mark
618
- created by this rule. Can also be used to describe further
619
- conditions the DOM element or style must match. When it returns
620
- `false`, the rule won't match. When it returns null or undefined,
621
- that is interpreted as an empty/default set of attributes.
622
- */
623
- getAttrs?: (node: HTMLElement) => Attrs | false | null;
624
- /**
625
- For rules that produce non-leaf nodes, by default the content of
626
- the DOM element is parsed as content of the node. If the child
627
- nodes are in a descendent node, this may be a CSS selector
628
- string that the parser must use to find the actual content
629
- element, or a function that returns the actual content element
630
- to the parser.
631
- */
632
- contentElement?: string | HTMLElement | ((node: HTMLElement) => HTMLElement);
633
- /**
634
- Can be used to override the content of a matched node. When
635
- present, instead of parsing the node's child nodes, the result of
636
- this function is used.
637
- */
638
- getContent?: (node: DOMNode$1, schema: Schema) => Fragment;
639
- /**
640
- Controls whether whitespace should be preserved when parsing the
641
- content inside the matched element. `false` means whitespace may
642
- be collapsed, `true` means that whitespace should be preserved
643
- but newlines normalized to spaces, and `"full"` means that
644
- newlines should also be preserved.
645
- */
646
- preserveWhitespace?: boolean | "full";
647
- }
648
- /**
649
- A parse rule targeting a style property.
650
- */
651
- interface StyleParseRule extends GenericParseRule {
652
- /**
653
- A CSS property name to match. This rule will match inline styles
654
- that list that property. May also have the form
655
- `"property=value"`, in which case the rule only matches if the
656
- property's value exactly matches the given value. (For more
657
- complicated filters, use [`getAttrs`](https://prosemirror.net/docs/ref/#model.StyleParseRule.getAttrs)
658
- and return false to indicate that the match failed.) Rules
659
- matching styles may only produce [marks](https://prosemirror.net/docs/ref/#model.GenericParseRule.mark),
660
- not nodes.
661
- */
662
- style: string;
663
- /**
664
- Given to make TS see ParseRule as a tagged union @hide
665
- */
666
- tag?: undefined;
667
- /**
668
- Style rules can remove marks from the set of active marks.
669
- */
670
- clearMark?: (mark: Mark) => boolean;
671
- /**
672
- A function used to compute the attributes for the node or mark
673
- created by this rule. Called with the style's value.
674
- */
675
- getAttrs?: (node: string) => Attrs | false | null;
676
- }
677
- /**
678
- A value that describes how to parse a given DOM node or inline
679
- style as a ProseMirror node or mark.
680
- */
681
- type ParseRule = TagParseRule | StyleParseRule;
682
- /**
683
- A DOM parser represents a strategy for parsing DOM content into a
684
- ProseMirror document conforming to a given schema. Its behavior is
685
- defined by an array of [rules](https://prosemirror.net/docs/ref/#model.ParseRule).
686
- */
687
- declare class DOMParser {
688
- /**
689
- The schema into which the parser parses.
690
- */
691
- readonly schema: Schema;
692
- /**
693
- The set of [parse rules](https://prosemirror.net/docs/ref/#model.ParseRule) that the parser
694
- uses, in order of precedence.
695
- */
696
- readonly rules: readonly ParseRule[];
697
- /**
698
- Create a parser that targets the given schema, using the given
699
- parsing rules.
700
- */
701
- constructor(
702
- /**
703
- The schema into which the parser parses.
704
- */
705
- schema: Schema,
706
- /**
707
- The set of [parse rules](https://prosemirror.net/docs/ref/#model.ParseRule) that the parser
708
- uses, in order of precedence.
709
- */
710
- rules: readonly ParseRule[]);
711
- /**
712
- Parse a document from the content of a DOM node.
713
- */
714
- parse(dom: DOMNode$1, options?: ParseOptions): Node$1;
715
- /**
716
- Parses the content of the given DOM node, like
717
- [`parse`](https://prosemirror.net/docs/ref/#model.DOMParser.parse), and takes the same set of
718
- options. But unlike that method, which produces a whole node,
719
- this one returns a slice that is open at the sides, meaning that
720
- the schema constraints aren't applied to the start of nodes to
721
- the left of the input and the end of nodes at the end.
722
- */
723
- parseSlice(dom: DOMNode$1, options?: ParseOptions): Slice;
724
- /**
725
- Construct a DOM parser using the parsing rules listed in a
726
- schema's [node specs](https://prosemirror.net/docs/ref/#model.NodeSpec.parseDOM), reordered by
727
- [priority](https://prosemirror.net/docs/ref/#model.GenericParseRule.priority).
728
- */
729
- static fromSchema(schema: Schema): DOMParser;
730
- }
731
- /**
732
- An object holding the attributes of a node.
733
- */
734
- type Attrs = {
735
- readonly [attr: string]: any;
736
- };
737
- /**
738
- Node types are objects allocated once per `Schema` and used to
739
- [tag](https://prosemirror.net/docs/ref/#model.Node.type) `Node` instances. They contain information
740
- about the node type, such as its name and what kind of node it
741
- represents.
742
- */
743
- declare class NodeType {
744
- /**
745
- The name the node type has in this schema.
746
- */
747
- readonly name: string;
748
- /**
749
- A link back to the `Schema` the node type belongs to.
750
- */
751
- readonly schema: Schema;
752
- /**
753
- The spec that this type is based on
754
- */
755
- readonly spec: NodeSpec;
756
- /**
757
- True if this node type has inline content.
758
- */
759
- inlineContent: boolean;
760
- /**
761
- True if this is a block type
762
- */
763
- isBlock: boolean;
764
- /**
765
- True if this is the text node type.
766
- */
767
- isText: boolean;
768
- /**
769
- True if this is an inline type.
770
- */
771
- get isInline(): boolean;
772
- /**
773
- True if this is a textblock type, a block that contains inline
774
- content.
775
- */
776
- get isTextblock(): boolean;
777
- /**
778
- True for node types that allow no content.
779
- */
780
- get isLeaf(): boolean;
781
- /**
782
- True when this node is an atom, i.e. when it does not have
783
- directly editable content.
784
- */
785
- get isAtom(): boolean;
786
- /**
787
- Return true when this node type is part of the given
788
- [group](https://prosemirror.net/docs/ref/#model.NodeSpec.group).
789
- */
790
- isInGroup(group: string): boolean;
791
- /**
792
- The starting match of the node type's content expression.
793
- */
794
- contentMatch: ContentMatch;
795
- /**
796
- The set of marks allowed in this node. `null` means all marks
797
- are allowed.
798
- */
799
- markSet: readonly MarkType[] | null;
800
- /**
801
- The node type's [whitespace](https://prosemirror.net/docs/ref/#model.NodeSpec.whitespace) option.
802
- */
803
- get whitespace(): "pre" | "normal";
804
- /**
805
- Tells you whether this node type has any required attributes.
806
- */
807
- hasRequiredAttrs(): boolean;
808
- /**
809
- Indicates whether this node allows some of the same content as
810
- the given node type.
811
- */
812
- compatibleContent(other: NodeType): boolean;
813
- /**
814
- Create a `Node` of this type. The given attributes are
815
- checked and defaulted (you can pass `null` to use the type's
816
- defaults entirely, if no required attributes exist). `content`
817
- may be a `Fragment`, a node, an array of nodes, or
818
- `null`. Similarly `marks` may be `null` to default to the empty
819
- set of marks.
820
- */
821
- create(attrs?: Attrs | null, content?: Fragment | Node$1 | readonly Node$1[] | null, marks?: readonly Mark[]): Node$1;
822
- /**
823
- Like [`create`](https://prosemirror.net/docs/ref/#model.NodeType.create), but check the given content
824
- against the node type's content restrictions, and throw an error
825
- if it doesn't match.
826
- */
827
- createChecked(attrs?: Attrs | null, content?: Fragment | Node$1 | readonly Node$1[] | null, marks?: readonly Mark[]): Node$1;
828
- /**
829
- Like [`create`](https://prosemirror.net/docs/ref/#model.NodeType.create), but see if it is
830
- necessary to add nodes to the start or end of the given fragment
831
- to make it fit the node. If no fitting wrapping can be found,
832
- return null. Note that, due to the fact that required nodes can
833
- always be created, this will always succeed if you pass null or
834
- `Fragment.empty` as content.
835
- */
836
- createAndFill(attrs?: Attrs | null, content?: Fragment | Node$1 | readonly Node$1[] | null, marks?: readonly Mark[]): Node$1 | null;
837
- /**
838
- Returns true if the given fragment is valid content for this node
839
- type.
840
- */
841
- validContent(content: Fragment): boolean;
842
- /**
843
- Check whether the given mark type is allowed in this node.
844
- */
845
- allowsMarkType(markType: MarkType): boolean;
846
- /**
847
- Test whether the given set of marks are allowed in this node.
848
- */
849
- allowsMarks(marks: readonly Mark[]): boolean;
850
- /**
851
- Removes the marks that are not allowed in this node from the given set.
852
- */
853
- allowedMarks(marks: readonly Mark[]): readonly Mark[];
854
- }
855
- /**
856
- Like nodes, marks (which are associated with nodes to signify
857
- things like emphasis or being part of a link) are
858
- [tagged](https://prosemirror.net/docs/ref/#model.Mark.type) with type objects, which are
859
- instantiated once per `Schema`.
860
- */
861
- declare class MarkType {
862
- /**
863
- The name of the mark type.
864
- */
865
- readonly name: string;
866
- /**
867
- The schema that this mark type instance is part of.
868
- */
869
- readonly schema: Schema;
870
- /**
871
- The spec on which the type is based.
872
- */
873
- readonly spec: MarkSpec;
874
- /**
875
- Create a mark of this type. `attrs` may be `null` or an object
876
- containing only some of the mark's attributes. The others, if
877
- they have defaults, will be added.
878
- */
879
- create(attrs?: Attrs | null): Mark;
880
- /**
881
- When there is a mark of this type in the given set, a new set
882
- without it is returned. Otherwise, the input set is returned.
883
- */
884
- removeFromSet(set: readonly Mark[]): readonly Mark[];
885
- /**
886
- Tests whether there is a mark of this type in the given set.
887
- */
888
- isInSet(set: readonly Mark[]): Mark | undefined;
889
- /**
890
- Queries whether a given mark type is
891
- [excluded](https://prosemirror.net/docs/ref/#model.MarkSpec.excludes) by this one.
892
- */
893
- excludes(other: MarkType): boolean;
894
- }
895
- /**
896
- An object describing a schema, as passed to the [`Schema`](https://prosemirror.net/docs/ref/#model.Schema)
897
- constructor.
898
- */
899
- interface SchemaSpec<Nodes extends string = any, Marks extends string = any> {
900
- /**
901
- The node types in this schema. Maps names to
902
- [`NodeSpec`](https://prosemirror.net/docs/ref/#model.NodeSpec) objects that describe the node type
903
- associated with that name. Their order is significant—it
904
- determines which [parse rules](https://prosemirror.net/docs/ref/#model.NodeSpec.parseDOM) take
905
- precedence by default, and which nodes come first in a given
906
- [group](https://prosemirror.net/docs/ref/#model.NodeSpec.group).
907
- */
908
- nodes: { [name in Nodes]: NodeSpec } | OrderedMap<NodeSpec>;
909
- /**
910
- The mark types that exist in this schema. The order in which they
911
- are provided determines the order in which [mark
912
- sets](https://prosemirror.net/docs/ref/#model.Mark.addToSet) are sorted and in which [parse
913
- rules](https://prosemirror.net/docs/ref/#model.MarkSpec.parseDOM) are tried.
914
- */
915
- marks?: { [name in Marks]: MarkSpec } | OrderedMap<MarkSpec>;
916
- /**
917
- The name of the default top-level node for the schema. Defaults
918
- to `"doc"`.
919
- */
920
- topNode?: string;
921
- }
922
- /**
923
- A description of a node type, used when defining a schema.
924
- */
925
- interface NodeSpec {
926
- /**
927
- The content expression for this node, as described in the [schema
928
- guide](https://prosemirror.net/docs/guide/#schema.content_expressions). When not given,
929
- the node does not allow any content.
930
- */
931
- content?: string;
932
- /**
933
- The marks that are allowed inside of this node. May be a
934
- space-separated string referring to mark names or groups, `"_"`
935
- to explicitly allow all marks, or `""` to disallow marks. When
936
- not given, nodes with inline content default to allowing all
937
- marks, other nodes default to not allowing marks.
938
- */
939
- marks?: string;
940
- /**
941
- The group or space-separated groups to which this node belongs,
942
- which can be referred to in the content expressions for the
943
- schema.
944
- */
945
- group?: string;
946
- /**
947
- Should be set to true for inline nodes. (Implied for text nodes.)
948
- */
949
- inline?: boolean;
950
- /**
951
- Can be set to true to indicate that, though this isn't a [leaf
952
- node](https://prosemirror.net/docs/ref/#model.NodeType.isLeaf), it doesn't have directly editable
953
- content and should be treated as a single unit in the view.
954
- */
955
- atom?: boolean;
956
- /**
957
- The attributes that nodes of this type get.
958
- */
959
- attrs?: {
960
- [name: string]: AttributeSpec;
961
- };
962
- /**
963
- Controls whether nodes of this type can be selected as a [node
964
- selection](https://prosemirror.net/docs/ref/#state.NodeSelection). Defaults to true for non-text
965
- nodes.
966
- */
967
- selectable?: boolean;
968
- /**
969
- Determines whether nodes of this type can be dragged without
970
- being selected. Defaults to false.
971
- */
972
- draggable?: boolean;
973
- /**
974
- Can be used to indicate that this node contains code, which
975
- causes some commands to behave differently.
976
- */
977
- code?: boolean;
978
- /**
979
- Controls way whitespace in this a node is parsed. The default is
980
- `"normal"`, which causes the [DOM parser](https://prosemirror.net/docs/ref/#model.DOMParser) to
981
- collapse whitespace in normal mode, and normalize it (replacing
982
- newlines and such with spaces) otherwise. `"pre"` causes the
983
- parser to preserve spaces inside the node. When this option isn't
984
- given, but [`code`](https://prosemirror.net/docs/ref/#model.NodeSpec.code) is true, `whitespace`
985
- will default to `"pre"`. Note that this option doesn't influence
986
- the way the node is rendered—that should be handled by `toDOM`
987
- and/or styling.
988
- */
989
- whitespace?: "pre" | "normal";
990
- /**
991
- Determines whether this node is considered an important parent
992
- node during replace operations (such as paste). Non-defining (the
993
- default) nodes get dropped when their entire content is replaced,
994
- whereas defining nodes persist and wrap the inserted content.
995
- */
996
- definingAsContext?: boolean;
997
- /**
998
- In inserted content the defining parents of the content are
999
- preserved when possible. Typically, non-default-paragraph
1000
- textblock types, and possibly list items, are marked as defining.
1001
- */
1002
- definingForContent?: boolean;
1003
- /**
1004
- When enabled, enables both
1005
- [`definingAsContext`](https://prosemirror.net/docs/ref/#model.NodeSpec.definingAsContext) and
1006
- [`definingForContent`](https://prosemirror.net/docs/ref/#model.NodeSpec.definingForContent).
1007
- */
1008
- defining?: boolean;
1009
- /**
1010
- When enabled (default is false), the sides of nodes of this type
1011
- count as boundaries that regular editing operations, like
1012
- backspacing or lifting, won't cross. An example of a node that
1013
- should probably have this enabled is a table cell.
1014
- */
1015
- isolating?: boolean;
1016
- /**
1017
- Defines the default way a node of this type should be serialized
1018
- to DOM/HTML (as used by
1019
- [`DOMSerializer.fromSchema`](https://prosemirror.net/docs/ref/#model.DOMSerializer^fromSchema)).
1020
- Should return a DOM node or an [array
1021
- structure](https://prosemirror.net/docs/ref/#model.DOMOutputSpec) that describes one, with an
1022
- optional number zero (“hole”) in it to indicate where the node's
1023
- content should be inserted.
1024
-
1025
- For text nodes, the default is to create a text DOM node. Though
1026
- it is possible to create a serializer where text is rendered
1027
- differently, this is not supported inside the editor, so you
1028
- shouldn't override that in your text node spec.
1029
- */
1030
- toDOM?: (node: Node$1) => DOMOutputSpec;
1031
- /**
1032
- Associates DOM parser information with this node, which can be
1033
- used by [`DOMParser.fromSchema`](https://prosemirror.net/docs/ref/#model.DOMParser^fromSchema) to
1034
- automatically derive a parser. The `node` field in the rules is
1035
- implied (the name of this node will be filled in automatically).
1036
- If you supply your own parser, you do not need to also specify
1037
- parsing rules in your schema.
1038
- */
1039
- parseDOM?: readonly TagParseRule[];
1040
- /**
1041
- Defines the default way a node of this type should be serialized
1042
- to a string representation for debugging (e.g. in error messages).
1043
- */
1044
- toDebugString?: (node: Node$1) => string;
1045
- /**
1046
- Defines the default way a [leaf node](https://prosemirror.net/docs/ref/#model.NodeType.isLeaf) of
1047
- this type should be serialized to a string (as used by
1048
- [`Node.textBetween`](https://prosemirror.net/docs/ref/#model.Node.textBetween) and
1049
- [`Node.textContent`](https://prosemirror.net/docs/ref/#model.Node.textContent)).
1050
- */
1051
- leafText?: (node: Node$1) => string;
1052
- /**
1053
- A single inline node in a schema can be set to be a linebreak
1054
- equivalent. When converting between block types that support the
1055
- node and block types that don't but have
1056
- [`whitespace`](https://prosemirror.net/docs/ref/#model.NodeSpec.whitespace) set to `"pre"`,
1057
- [`setBlockType`](https://prosemirror.net/docs/ref/#transform.Transform.setBlockType) will convert
1058
- between newline characters to or from linebreak nodes as
1059
- appropriate.
1060
- */
1061
- linebreakReplacement?: boolean;
1062
- /**
1063
- Node specs may include arbitrary properties that can be read by
1064
- other code via [`NodeType.spec`](https://prosemirror.net/docs/ref/#model.NodeType.spec).
1065
- */
1066
- [key: string]: any;
1067
- }
1068
- /**
1069
- Used to define marks when creating a schema.
1070
- */
1071
- interface MarkSpec {
1072
- /**
1073
- The attributes that marks of this type get.
1074
- */
1075
- attrs?: {
1076
- [name: string]: AttributeSpec;
1077
- };
1078
- /**
1079
- Whether this mark should be active when the cursor is positioned
1080
- at its end (or at its start when that is also the start of the
1081
- parent node). Defaults to true.
1082
- */
1083
- inclusive?: boolean;
1084
- /**
1085
- Determines which other marks this mark can coexist with. Should
1086
- be a space-separated strings naming other marks or groups of marks.
1087
- When a mark is [added](https://prosemirror.net/docs/ref/#model.Mark.addToSet) to a set, all marks
1088
- that it excludes are removed in the process. If the set contains
1089
- any mark that excludes the new mark but is not, itself, excluded
1090
- by the new mark, the mark can not be added an the set. You can
1091
- use the value `"_"` to indicate that the mark excludes all
1092
- marks in the schema.
1093
-
1094
- Defaults to only being exclusive with marks of the same type. You
1095
- can set it to an empty string (or any string not containing the
1096
- mark's own name) to allow multiple marks of a given type to
1097
- coexist (as long as they have different attributes).
1098
- */
1099
- excludes?: string;
1100
- /**
1101
- The group or space-separated groups to which this mark belongs.
1102
- */
1103
- group?: string;
1104
- /**
1105
- Determines whether marks of this type can span multiple adjacent
1106
- nodes when serialized to DOM/HTML. Defaults to true.
1107
- */
1108
- spanning?: boolean;
1109
- /**
1110
- Marks the content of this span as being code, which causes some
1111
- commands and extensions to treat it differently.
1112
- */
1113
- code?: boolean;
1114
- /**
1115
- Defines the default way marks of this type should be serialized
1116
- to DOM/HTML. When the resulting spec contains a hole, that is
1117
- where the marked content is placed. Otherwise, it is appended to
1118
- the top node.
1119
- */
1120
- toDOM?: (mark: Mark, inline: boolean) => DOMOutputSpec;
1121
- /**
1122
- Associates DOM parser information with this mark (see the
1123
- corresponding [node spec field](https://prosemirror.net/docs/ref/#model.NodeSpec.parseDOM)). The
1124
- `mark` field in the rules is implied.
1125
- */
1126
- parseDOM?: readonly ParseRule[];
1127
- /**
1128
- Mark specs can include additional properties that can be
1129
- inspected through [`MarkType.spec`](https://prosemirror.net/docs/ref/#model.MarkType.spec) when
1130
- working with the mark.
1131
- */
1132
- [key: string]: any;
1133
- }
1134
- /**
1135
- Used to [define](https://prosemirror.net/docs/ref/#model.NodeSpec.attrs) attributes on nodes or
1136
- marks.
1137
- */
1138
- interface AttributeSpec {
1139
- /**
1140
- The default value for this attribute, to use when no explicit
1141
- value is provided. Attributes that have no default must be
1142
- provided whenever a node or mark of a type that has them is
1143
- created.
1144
- */
1145
- default?: any;
1146
- /**
1147
- A function or type name used to validate values of this
1148
- attribute. This will be used when deserializing the attribute
1149
- from JSON, and when running [`Node.check`](https://prosemirror.net/docs/ref/#model.Node.check).
1150
- When a function, it should raise an exception if the value isn't
1151
- of the expected type or shape. When a string, it should be a
1152
- `|`-separated string of primitive types (`"number"`, `"string"`,
1153
- `"boolean"`, `"null"`, and `"undefined"`), and the library will
1154
- raise an error when the value is not one of those types.
1155
- */
1156
- validate?: string | ((value: any) => void);
1157
- }
1158
- /**
1159
- A document schema. Holds [node](https://prosemirror.net/docs/ref/#model.NodeType) and [mark
1160
- type](https://prosemirror.net/docs/ref/#model.MarkType) objects for the nodes and marks that may
1161
- occur in conforming documents, and provides functionality for
1162
- creating and deserializing such documents.
1163
-
1164
- When given, the type parameters provide the names of the nodes and
1165
- marks in this schema.
1166
- */
1167
- declare class Schema<Nodes extends string = any, Marks extends string = any> {
1168
- /**
1169
- The [spec](https://prosemirror.net/docs/ref/#model.SchemaSpec) on which the schema is based,
1170
- with the added guarantee that its `nodes` and `marks`
1171
- properties are
1172
- [`OrderedMap`](https://code.haverbeke.berlin/marijn/orderedmap) instances
1173
- (not raw objects).
1174
- */
1175
- spec: {
1176
- nodes: OrderedMap<NodeSpec>;
1177
- marks: OrderedMap<MarkSpec>;
1178
- topNode?: string;
1179
- };
1180
- /**
1181
- An object mapping the schema's node names to node type objects.
1182
- */
1183
- nodes: { readonly [name in Nodes]: NodeType } & {
1184
- readonly [key: string]: NodeType;
1185
- };
1186
- /**
1187
- A map from mark names to mark type objects.
1188
- */
1189
- marks: { readonly [name in Marks]: MarkType } & {
1190
- readonly [key: string]: MarkType;
1191
- };
1192
- /**
1193
- The [linebreak
1194
- replacement](https://prosemirror.net/docs/ref/#model.NodeSpec.linebreakReplacement) node defined
1195
- in this schema, if any.
1196
- */
1197
- linebreakReplacement: NodeType | null;
1198
- /**
1199
- Construct a schema from a schema [specification](https://prosemirror.net/docs/ref/#model.SchemaSpec).
1200
- */
1201
- constructor(spec: SchemaSpec<Nodes, Marks>);
1202
- /**
1203
- The type of the [default top node](https://prosemirror.net/docs/ref/#model.SchemaSpec.topNode)
1204
- for this schema.
1205
- */
1206
- topNodeType: NodeType;
1207
- /**
1208
- An object for storing whatever values modules may want to
1209
- compute and cache per schema. (If you want to store something
1210
- in it, try to use property names unlikely to clash.)
1211
- */
1212
- cached: {
1213
- [key: string]: any;
1214
- };
1215
- /**
1216
- Create a node in this schema. The `type` may be a string or a
1217
- `NodeType` instance. Attributes will be extended with defaults,
1218
- `content` may be a `Fragment`, `null`, a `Node`, or an array of
1219
- nodes.
1220
- */
1221
- node(type: string | NodeType, attrs?: Attrs | null, content?: Fragment | Node$1 | readonly Node$1[], marks?: readonly Mark[]): Node$1;
1222
- /**
1223
- Create a text node in the schema. Empty text nodes are not
1224
- allowed.
1225
- */
1226
- text(text: string, marks?: readonly Mark[] | null): Node$1;
1227
- /**
1228
- Create a mark with the given type and attributes.
1229
- */
1230
- mark(type: string | MarkType, attrs?: Attrs | null): Mark;
1231
- /**
1232
- Deserialize a node from its JSON representation. This method is
1233
- bound.
1234
- */
1235
- nodeFromJSON: (json: any) => Node$1;
1236
- /**
1237
- Deserialize a mark from its JSON representation. This method is
1238
- bound.
1239
- */
1240
- markFromJSON: (json: any) => Mark;
1241
- }
1242
- /**
1243
- A fragment represents a node's collection of child nodes.
1244
-
1245
- Like nodes, fragments are persistent data structures, and you
1246
- should not mutate them or their content. Rather, you create new
1247
- instances whenever needed. The API tries to make this easy.
1248
- */
1249
- declare class Fragment {
1250
- /**
1251
- The child nodes in this fragment.
1252
- */
1253
- readonly content: readonly Node$1[];
1254
- /**
1255
- The size of the fragment, which is the total of the size of
1256
- its content nodes.
1257
- */
1258
- readonly size: number;
1259
- /**
1260
- Invoke a callback for all descendant nodes between the given two
1261
- positions (relative to start of this fragment). Doesn't descend
1262
- into a node when the callback returns `false`.
1263
- */
1264
- nodesBetween(from: number, to: number, f: (node: Node$1, start: number, parent: Node$1 | null, index: number) => boolean | void, nodeStart?: number, parent?: Node$1): void;
1265
- /**
1266
- Call the given callback for every descendant node. `pos` will be
1267
- relative to the start of the fragment. The callback may return
1268
- `false` to prevent traversal of a given node's children.
1269
- */
1270
- descendants(f: (node: Node$1, pos: number, parent: Node$1 | null, index: number) => boolean | void): void;
1271
- /**
1272
- Extract the text between `from` and `to`. See the same method on
1273
- [`Node`](https://prosemirror.net/docs/ref/#model.Node.textBetween).
1274
- */
1275
- textBetween(from: number, to: number, blockSeparator?: string | null, leafText?: string | null | ((leafNode: Node$1) => string)): string;
1276
- /**
1277
- Create a new fragment containing the combined content of this
1278
- fragment and the other.
1279
- */
1280
- append(other: Fragment): Fragment;
1281
- /**
1282
- Cut out the sub-fragment between the two given positions.
1283
- */
1284
- cut(from: number, to?: number): Fragment;
1285
- /**
1286
- Create a new fragment in which the node at the given index is
1287
- replaced by the given node.
1288
- */
1289
- replaceChild(index: number, node: Node$1): Fragment;
1290
- /**
1291
- Create a new fragment by prepending the given node to this
1292
- fragment.
1293
- */
1294
- addToStart(node: Node$1): Fragment;
1295
- /**
1296
- Create a new fragment by appending the given node to this
1297
- fragment.
1298
- */
1299
- addToEnd(node: Node$1): Fragment;
1300
- /**
1301
- Compare this fragment to another one.
1302
- */
1303
- eq(other: Fragment): boolean;
1304
- /**
1305
- The first child of the fragment, or `null` if it is empty.
1306
- */
1307
- get firstChild(): Node$1 | null;
1308
- /**
1309
- The last child of the fragment, or `null` if it is empty.
1310
- */
1311
- get lastChild(): Node$1 | null;
1312
- /**
1313
- The number of child nodes in this fragment.
1314
- */
1315
- get childCount(): number;
1316
- /**
1317
- Get the child node at the given index. Raise an error when the
1318
- index is out of range.
1319
- */
1320
- child(index: number): Node$1;
1321
- /**
1322
- Get the child node at the given index, if it exists.
1323
- */
1324
- maybeChild(index: number): Node$1 | null;
1325
- /**
1326
- Call `f` for every child node, passing the node, its offset
1327
- into this parent node, and its index.
1328
- */
1329
- forEach(f: (node: Node$1, offset: number, index: number) => void): void;
1330
- /**
1331
- Find the first position at which this fragment and another
1332
- fragment differ, or `null` if they are the same.
1333
- */
1334
- findDiffStart(other: Fragment, pos?: number): number | null;
1335
- /**
1336
- Find the first position, searching from the end, at which this
1337
- fragment and the given fragment differ, or `null` if they are
1338
- the same. Since this position will not be the same in both
1339
- nodes, an object with two separate positions is returned.
1340
- */
1341
- findDiffEnd(other: Fragment, pos?: number, otherPos?: number): {
1342
- a: number;
1343
- b: number;
1344
- } | null;
1345
- /**
1346
- Return a debugging string that describes this fragment.
1347
- */
1348
- toString(): string;
1349
- /**
1350
- Create a JSON-serializeable representation of this fragment.
1351
- */
1352
- toJSON(): any;
1353
- /**
1354
- Deserialize a fragment from its JSON representation.
1355
- */
1356
- static fromJSON(schema: Schema, value: any): Fragment;
1357
- /**
1358
- Build a fragment from an array of nodes. Ensures that adjacent
1359
- text nodes with the same marks are joined together.
1360
- */
1361
- static fromArray(array: readonly Node$1[]): Fragment;
1362
- /**
1363
- Create a fragment from something that can be interpreted as a
1364
- set of nodes. For `null`, it returns the empty fragment. For a
1365
- fragment, the fragment itself. For a node or array of nodes, a
1366
- fragment containing those nodes.
1367
- */
1368
- static from(nodes?: Fragment | Node$1 | readonly Node$1[] | null): Fragment;
1369
- /**
1370
- An empty fragment. Intended to be reused whenever a node doesn't
1371
- contain anything (rather than allocating a new empty fragment for
1372
- each leaf node).
1373
- */
1374
- static empty: Fragment;
1375
- }
1376
- type MatchEdge = {
1377
- type: NodeType;
1378
- next: ContentMatch;
1379
- };
1380
- /**
1381
- Instances of this class represent a match state of a node type's
1382
- [content expression](https://prosemirror.net/docs/ref/#model.NodeSpec.content), and can be used to
1383
- find out whether further content matches here, and whether a given
1384
- position is a valid end of the node.
1385
- */
1386
- declare class ContentMatch {
1387
- /**
1388
- True when this match state represents a valid end of the node.
1389
- */
1390
- readonly validEnd: boolean;
1391
- /**
1392
- Match a node type, returning a match after that node if
1393
- successful.
1394
- */
1395
- matchType(type: NodeType): ContentMatch | null;
1396
- /**
1397
- Try to match a fragment. Returns the resulting match when
1398
- successful.
1399
- */
1400
- matchFragment(frag: Fragment, start?: number, end?: number): ContentMatch | null;
1401
- /**
1402
- Get the first matching node type at this match position that can
1403
- be generated.
1404
- */
1405
- get defaultType(): NodeType | null;
1406
- /**
1407
- Try to match the given fragment, and if that fails, see if it can
1408
- be made to match by inserting nodes in front of it. When
1409
- successful, return a fragment of inserted nodes (which may be
1410
- empty if nothing had to be inserted). When `toEnd` is true, only
1411
- return a fragment if the resulting match goes to the end of the
1412
- content expression.
1413
- */
1414
- fillBefore(after: Fragment, toEnd?: boolean, startIndex?: number): Fragment | null;
1415
- /**
1416
- Find a set of wrapping node types that would allow a node of the
1417
- given type to appear at this position. The result may be empty
1418
- (when it fits directly) and will be null when no such wrapping
1419
- exists.
1420
- */
1421
- findWrapping(target: NodeType): readonly NodeType[] | null;
1422
- /**
1423
- The number of outgoing edges this node has in the finite
1424
- automaton that describes the content expression.
1425
- */
1426
- get edgeCount(): number;
1427
- /**
1428
- Get the _n_​th outgoing edge from this node in the finite
1429
- automaton that describes the content expression.
1430
- */
1431
- edge(n: number): MatchEdge;
1432
- }
1433
- /**
1434
- This class represents a node in the tree that makes up a
1435
- ProseMirror document. So a document is an instance of `Node`, with
1436
- children that are also instances of `Node`.
1437
-
1438
- Nodes are persistent data structures. Instead of changing them, you
1439
- create new ones with the content you want. Old ones keep pointing
1440
- at the old document shape. This is made cheaper by sharing
1441
- structure between the old and new data as much as possible, which a
1442
- tree shape like this (without back pointers) makes easy.
1443
-
1444
- **Do not** directly mutate the properties of a `Node` object. See
1445
- [the guide](https://prosemirror.net/docs/guide/#doc) for more information.
1446
- */
1447
- declare class Node$1 {
1448
- /**
1449
- The type of node that this is.
1450
- */
1451
- readonly type: NodeType;
1452
- /**
1453
- An object mapping attribute names to values. The kind of
1454
- attributes allowed and required are
1455
- [determined](https://prosemirror.net/docs/ref/#model.NodeSpec.attrs) by the node type.
1456
- */
1457
- readonly attrs: Attrs;
1458
- /**
1459
- The marks (things like whether it is emphasized or part of a
1460
- link) applied to this node.
1461
- */
1462
- readonly marks: readonly Mark[];
1463
- /**
1464
- A container holding the node's children.
1465
- */
1466
- readonly content: Fragment;
1467
- /**
1468
- The array of this node's child nodes.
1469
- */
1470
- get children(): readonly Node$1[];
1471
- /**
1472
- For text nodes, this contains the node's text content.
1473
- */
1474
- readonly text: string | undefined;
1475
- /**
1476
- The size of this node, as defined by the integer-based [indexing
1477
- scheme](https://prosemirror.net/docs/guide/#doc.indexing). For text nodes, this is the
1478
- amount of characters. For other leaf nodes, it is one. For
1479
- non-leaf nodes, it is the size of the content plus two (the
1480
- start and end token).
1481
- */
1482
- get nodeSize(): number;
1483
- /**
1484
- The number of children that the node has.
1485
- */
1486
- get childCount(): number;
1487
- /**
1488
- Get the child node at the given index. Raises an error when the
1489
- index is out of range.
1490
- */
1491
- child(index: number): Node$1;
1492
- /**
1493
- Get the child node at the given index, if it exists.
1494
- */
1495
- maybeChild(index: number): Node$1 | null;
1496
- /**
1497
- Call `f` for every child node, passing the node, its offset
1498
- into this parent node, and its index.
1499
- */
1500
- forEach(f: (node: Node$1, offset: number, index: number) => void): void;
1501
- /**
1502
- Invoke a callback for all descendant nodes recursively overlapping
1503
- the given two positions that are relative to start of this
1504
- node's content. This includes all ancestors of the nodes
1505
- containing the two positions. The callback is invoked with the
1506
- node, its position relative to the original node (method receiver),
1507
- its parent node, and its child index. When the callback returns
1508
- false for a given node, that node's children will not be
1509
- recursed over. The last parameter can be used to specify a
1510
- starting position to count from.
1511
- */
1512
- nodesBetween(from: number, to: number, f: (node: Node$1, pos: number, parent: Node$1 | null, index: number) => void | boolean, startPos?: number): void;
1513
- /**
1514
- Call the given callback for every descendant node. Doesn't
1515
- descend into a node when the callback returns `false`.
1516
- */
1517
- descendants(f: (node: Node$1, pos: number, parent: Node$1 | null, index: number) => void | boolean): void;
1518
- /**
1519
- Concatenates all the text nodes found in this fragment and its
1520
- children.
1521
- */
1522
- get textContent(): string;
1523
- /**
1524
- Get all text between positions `from` and `to`. When
1525
- `blockSeparator` is given, it will be inserted to separate text
1526
- from different block nodes. If `leafText` is given, it'll be
1527
- inserted for every non-text leaf node encountered, otherwise
1528
- [`leafText`](https://prosemirror.net/docs/ref/#model.NodeSpec.leafText) will be used.
1529
- */
1530
- textBetween(from: number, to: number, blockSeparator?: string | null, leafText?: null | string | ((leafNode: Node$1) => string)): string;
1531
- /**
1532
- Returns this node's first child, or `null` if there are no
1533
- children.
1534
- */
1535
- get firstChild(): Node$1 | null;
1536
- /**
1537
- Returns this node's last child, or `null` if there are no
1538
- children.
1539
- */
1540
- get lastChild(): Node$1 | null;
1541
- /**
1542
- Test whether two nodes represent the same piece of document.
1543
- */
1544
- eq(other: Node$1): boolean;
1545
- /**
1546
- Compare the markup (type, attributes, and marks) of this node to
1547
- those of another. Returns `true` if both have the same markup.
1548
- */
1549
- sameMarkup(other: Node$1): boolean;
1550
- /**
1551
- Check whether this node's markup correspond to the given type,
1552
- attributes, and marks.
1553
- */
1554
- hasMarkup(type: NodeType, attrs?: Attrs | null, marks?: readonly Mark[]): boolean;
1555
- /**
1556
- Create a new node with the same markup as this node, containing
1557
- the given content (or empty, if no content is given).
1558
- */
1559
- copy(content?: Fragment | null): Node$1;
1560
- /**
1561
- Create a copy of this node, with the given set of marks instead
1562
- of the node's own marks.
1563
- */
1564
- mark(marks: readonly Mark[]): Node$1;
1565
- /**
1566
- Create a copy of this node with only the content between the
1567
- given positions. If `to` is not given, it defaults to the end of
1568
- the node.
1569
- */
1570
- cut(from: number, to?: number): Node$1;
1571
- /**
1572
- Cut out the part of the document between the given positions, and
1573
- return it as a `Slice` object.
1574
- */
1575
- slice(from: number, to?: number, includeParents?: boolean): Slice;
1576
- /**
1577
- Replace the part of the document between the given positions with
1578
- the given slice. The slice must 'fit', meaning its open sides
1579
- must be able to connect to the surrounding content, and its
1580
- content nodes must be valid children for the node they are placed
1581
- into. If any of this is violated, an error of type
1582
- [`ReplaceError`](https://prosemirror.net/docs/ref/#model.ReplaceError) is thrown.
1583
- */
1584
- replace(from: number, to: number, slice: Slice): Node$1;
1585
- /**
1586
- Find the node directly after the given position.
1587
- */
1588
- nodeAt(pos: number): Node$1 | null;
1589
- /**
1590
- Find the (direct) child node after the given offset, if any,
1591
- and return it along with its index and offset relative to this
1592
- node.
1593
- */
1594
- childAfter(pos: number): {
1595
- node: Node$1 | null;
1596
- index: number;
1597
- offset: number;
1598
- };
1599
- /**
1600
- Find the (direct) child node before the given offset, if any,
1601
- and return it along with its index and offset relative to this
1602
- node.
1603
- */
1604
- childBefore(pos: number): {
1605
- node: Node$1 | null;
1606
- index: number;
1607
- offset: number;
1608
- };
1609
- /**
1610
- Resolve the given position in the document, returning an
1611
- [object](https://prosemirror.net/docs/ref/#model.ResolvedPos) with information about its context.
1612
- */
1613
- resolve(pos: number): ResolvedPos;
1614
- /**
1615
- Test whether a given mark or mark type occurs in this document
1616
- between the two given positions.
1617
- */
1618
- rangeHasMark(from: number, to: number, type: Mark | MarkType): boolean;
1619
- /**
1620
- True when this is a block (non-inline node)
1621
- */
1622
- get isBlock(): boolean;
1623
- /**
1624
- True when this is a textblock node, a block node with inline
1625
- content.
1626
- */
1627
- get isTextblock(): boolean;
1628
- /**
1629
- True when this node allows inline content.
1630
- */
1631
- get inlineContent(): boolean;
1632
- /**
1633
- True when this is an inline node (a text node or a node that can
1634
- appear among text).
1635
- */
1636
- get isInline(): boolean;
1637
- /**
1638
- True when this is a text node.
1639
- */
1640
- get isText(): boolean;
1641
- /**
1642
- True when this is a leaf node.
1643
- */
1644
- get isLeaf(): boolean;
1645
- /**
1646
- True when this is an atom, i.e. when it does not have directly
1647
- editable content. This is usually the same as `isLeaf`, but can
1648
- be configured with the [`atom` property](https://prosemirror.net/docs/ref/#model.NodeSpec.atom)
1649
- on a node's spec (typically used when the node is displayed as
1650
- an uneditable [node view](https://prosemirror.net/docs/ref/#view.NodeView)).
1651
- */
1652
- get isAtom(): boolean;
1653
- /**
1654
- Return a string representation of this node for debugging
1655
- purposes.
1656
- */
1657
- toString(): string;
1658
- /**
1659
- Get the content match in this node at the given index.
1660
- */
1661
- contentMatchAt(index: number): ContentMatch;
1662
- /**
1663
- Test whether replacing the range between `from` and `to` (by
1664
- child index) with the given replacement fragment (which defaults
1665
- to the empty fragment) would leave the node's content valid. You
1666
- can optionally pass `start` and `end` indices into the
1667
- replacement fragment.
1668
- */
1669
- canReplace(from: number, to: number, replacement?: Fragment, start?: number, end?: number): boolean;
1670
- /**
1671
- Test whether replacing the range `from` to `to` (by index) with
1672
- a node of the given type would leave the node's content valid.
1673
- */
1674
- canReplaceWith(from: number, to: number, type: NodeType, marks?: readonly Mark[]): boolean;
1675
- /**
1676
- Test whether the given node's content could be appended to this
1677
- node. If that node is empty, this will only return true if there
1678
- is at least one node type that can appear in both nodes (to avoid
1679
- merging completely incompatible nodes).
1680
- */
1681
- canAppend(other: Node$1): boolean;
1682
- /**
1683
- Check whether this node and its descendants conform to the
1684
- schema, and raise an exception when they do not.
1685
- */
1686
- check(): void;
1687
- /**
1688
- Return a JSON-serializeable representation of this node.
1689
- */
1690
- toJSON(): any;
1691
- /**
1692
- Deserialize a node from its JSON representation.
1693
- */
1694
- static fromJSON(schema: Schema, json: any): Node$1;
1695
- }
1696
- //#endregion
1697
- //#region ../../node_modules/.pnpm/prosemirror-transform@1.12.0/node_modules/prosemirror-transform/dist/index.d.ts
1698
- /**
1699
- There are several things that positions can be mapped through.
1700
- Such objects conform to this interface.
1701
- */
1702
- interface Mappable {
1703
- /**
1704
- Map a position through this object. When given, `assoc` (should
1705
- be -1 or 1, defaults to 1) determines with which side the
1706
- position is associated, which determines in which direction to
1707
- move when a chunk of content is inserted at the mapped position.
1708
- */
1709
- map: (pos: number, assoc?: number) => number;
1710
- /**
1711
- Map a position, and return an object containing additional
1712
- information about the mapping. The result's `deleted` field tells
1713
- you whether the position was deleted (completely enclosed in a
1714
- replaced range) during the mapping. When content on only one side
1715
- is deleted, the position itself is only considered deleted when
1716
- `assoc` points in the direction of the deleted content.
1717
- */
1718
- mapResult: (pos: number, assoc?: number) => MapResult;
1719
- }
1720
- /**
1721
- An object representing a mapped position with extra
1722
- information.
1723
- */
1724
- declare class MapResult {
1725
- /**
1726
- The mapped version of the position.
1727
- */
1728
- readonly pos: number;
1729
- /**
1730
- Tells you whether the position was deleted, that is, whether the
1731
- step removed the token on the side queried (via the `assoc`)
1732
- argument from the document.
1733
- */
1734
- get deleted(): boolean;
1735
- /**
1736
- Tells you whether the token before the mapped position was deleted.
1737
- */
1738
- get deletedBefore(): boolean;
1739
- /**
1740
- True when the token after the mapped position was deleted.
1741
- */
1742
- get deletedAfter(): boolean;
1743
- /**
1744
- Tells whether any of the steps mapped through deletes across the
1745
- position (including both the token before and after the
1746
- position).
1747
- */
1748
- get deletedAcross(): boolean;
1749
- }
1750
- /**
1751
- A map describing the deletions and insertions made by a step, which
1752
- can be used to find the correspondence between positions in the
1753
- pre-step version of a document and the same position in the
1754
- post-step version.
1755
- */
1756
- declare class StepMap implements Mappable {
1757
- /**
1758
- Create a position map. The modifications to the document are
1759
- represented as an array of numbers, in which each group of three
1760
- represents a modified chunk as `[start, oldSize, newSize]`.
1761
- */
1762
- constructor(
1763
- /**
1764
- @internal
1765
- */
1766
-
1767
- ranges: readonly number[],
1768
- /**
1769
- @internal
1770
- */
1771
-
1772
- inverted?: boolean);
1773
- mapResult(pos: number, assoc?: number): MapResult;
1774
- map(pos: number, assoc?: number): number;
1775
- /**
1776
- Calls the given function on each of the changed ranges included in
1777
- this map.
1778
- */
1779
- forEach(f: (oldStart: number, oldEnd: number, newStart: number, newEnd: number) => void): void;
1780
- /**
1781
- Create an inverted version of this map. The result can be used to
1782
- map positions in the post-step document to the pre-step document.
1783
- */
1784
- invert(): StepMap;
1785
- /**
1786
- Create a map that moves all positions by offset `n` (which may be
1787
- negative). This can be useful when applying steps meant for a
1788
- sub-document to a larger document, or vice-versa.
1789
- */
1790
- static offset(n: number): StepMap;
1791
- /**
1792
- A StepMap that contains no changed ranges.
1793
- */
1794
- static empty: StepMap;
1795
- }
1796
- /**
1797
- A mapping represents a pipeline of zero or more [step
1798
- maps](https://prosemirror.net/docs/ref/#transform.StepMap). It has special provisions for losslessly
1799
- handling mapping positions through a series of steps in which some
1800
- steps are inverted versions of earlier steps. (This comes up when
1801
- ‘[rebasing](https://prosemirror.net/docs/guide/#transform.rebasing)’ steps for
1802
- collaboration or history management.)
1803
- */
1804
- declare class Mapping implements Mappable {
1805
- /**
1806
- The starting position in the `maps` array, used when `map` or
1807
- `mapResult` is called.
1808
- */
1809
- from: number;
1810
- /**
1811
- The end position in the `maps` array.
1812
- */
1813
- to: number;
1814
- /**
1815
- Create a new mapping with the given position maps.
1816
- */
1817
- constructor(maps?: readonly StepMap[],
1818
- /**
1819
- @internal
1820
- */
1821
-
1822
- mirror?: number[] | undefined,
1823
- /**
1824
- The starting position in the `maps` array, used when `map` or
1825
- `mapResult` is called.
1826
- */
1827
-
1828
- from?: number,
1829
- /**
1830
- The end position in the `maps` array.
1831
- */
1832
-
1833
- to?: number);
1834
- /**
1835
- The step maps in this mapping.
1836
- */
1837
- get maps(): readonly StepMap[];
1838
- private _maps;
1839
- private ownData;
1840
- /**
1841
- Create a mapping that maps only through a part of this one.
1842
- */
1843
- slice(from?: number, to?: number): Mapping;
1844
- /**
1845
- Add a step map to the end of this mapping. If `mirrors` is
1846
- given, it should be the index of the step map that is the mirror
1847
- image of this one.
1848
- */
1849
- appendMap(map: StepMap, mirrors?: number): void;
1850
- /**
1851
- Add all the step maps in a given mapping to this one (preserving
1852
- mirroring information).
1853
- */
1854
- appendMapping(mapping: Mapping): void;
1855
- /**
1856
- Finds the offset of the step map that mirrors the map at the
1857
- given offset, in this mapping (as per the second argument to
1858
- `appendMap`).
1859
- */
1860
- getMirror(n: number): number | undefined;
1861
- /**
1862
- Append the inverse of the given mapping to this one.
1863
- */
1864
- appendMappingInverted(mapping: Mapping): void;
1865
- /**
1866
- Create an inverted version of this mapping.
1867
- */
1868
- invert(): Mapping;
1869
- /**
1870
- Map a position through this mapping.
1871
- */
1872
- map(pos: number, assoc?: number): number;
1873
- /**
1874
- Map a position through this mapping, returning a mapping
1875
- result.
1876
- */
1877
- mapResult(pos: number, assoc?: number): MapResult;
1878
- }
1879
- /**
1880
- A step object represents an atomic change. It generally applies
1881
- only to the document it was created for, since the positions
1882
- stored in it will only make sense for that document.
1883
-
1884
- New steps are defined by creating classes that extend `Step`,
1885
- overriding the `apply`, `invert`, `map`, `getMap` and `fromJSON`
1886
- methods, and registering your class with a unique
1887
- JSON-serialization identifier using
1888
- [`Step.jsonID`](https://prosemirror.net/docs/ref/#transform.Step^jsonID).
1889
- */
1890
- declare abstract class Step {
1891
- /**
1892
- Applies this step to the given document, returning a result
1893
- object that either indicates failure, if the step can not be
1894
- applied to this document, or indicates success by containing a
1895
- transformed document.
1896
- */
1897
- abstract apply(doc: Node$1): StepResult;
1898
- /**
1899
- Get the step map that represents the changes made by this step,
1900
- and which can be used to transform between positions in the old
1901
- and the new document.
1902
- */
1903
- getMap(): StepMap;
1904
- /**
1905
- Create an inverted version of this step. Needs the document as it
1906
- was before the step as argument.
1907
- */
1908
- abstract invert(doc: Node$1): Step;
1909
- /**
1910
- Map this step through a mappable thing, returning either a
1911
- version of that step with its positions adjusted, or `null` if
1912
- the step was entirely deleted by the mapping.
1913
- */
1914
- abstract map(mapping: Mappable): Step | null;
1915
- /**
1916
- Try to merge this step with another one, to be applied directly
1917
- after it. Returns the merged step when possible, null if the
1918
- steps can't be merged.
1919
- */
1920
- merge(other: Step): Step | null;
1921
- /**
1922
- Create a JSON-serializeable representation of this step. When
1923
- defining this for a custom subclass, make sure the result object
1924
- includes the step type's [JSON id](https://prosemirror.net/docs/ref/#transform.Step^jsonID) under
1925
- the `stepType` property.
1926
- */
1927
- abstract toJSON(): any;
1928
- /**
1929
- Deserialize a step from its JSON representation. Will call
1930
- through to the step class' own implementation of this method.
1931
- */
1932
- static fromJSON(schema: Schema, json: any): Step;
1933
- /**
1934
- To be able to serialize steps to JSON, each step needs a string
1935
- ID to attach to its JSON representation. Use this method to
1936
- register an ID for your step classes. Try to pick something
1937
- that's unlikely to clash with steps from other modules.
1938
- */
1939
- static jsonID(id: string, stepClass: {
1940
- fromJSON(schema: Schema, json: any): Step;
1941
- }): {
1942
- fromJSON(schema: Schema, json: any): Step;
1943
- };
1944
- }
1945
- /**
1946
- The result of [applying](https://prosemirror.net/docs/ref/#transform.Step.apply) a step. Contains either a
1947
- new document or a failure value.
1948
- */
1949
- declare class StepResult {
1950
- /**
1951
- The transformed document, if successful.
1952
- */
1953
- readonly doc: Node$1 | null;
1954
- /**
1955
- The failure message, if unsuccessful.
1956
- */
1957
- readonly failed: string | null;
1958
- /**
1959
- Create a successful step result.
1960
- */
1961
- static ok(doc: Node$1): StepResult;
1962
- /**
1963
- Create a failed step result.
1964
- */
1965
- static fail(message: string): StepResult;
1966
- /**
1967
- Call [`Node.replace`](https://prosemirror.net/docs/ref/#model.Node.replace) with the given
1968
- arguments. Create a successful result if it succeeds, and a
1969
- failed one if it throws a `ReplaceError`.
1970
- */
1971
- static fromReplace(doc: Node$1, from: number, to: number, slice: Slice): StepResult;
1972
- }
1973
- /**
1974
- Abstraction to build up and track an array of
1975
- [steps](https://prosemirror.net/docs/ref/#transform.Step) representing a document transformation.
1976
-
1977
- Most transforming methods return the `Transform` object itself, so
1978
- that they can be chained.
1979
- */
1980
- declare class Transform {
1981
- /**
1982
- The current document (the result of applying the steps in the
1983
- transform).
1984
- */
1985
- doc: Node$1;
1986
- /**
1987
- The steps in this transform.
1988
- */
1989
- readonly steps: Step[];
1990
- /**
1991
- The documents before each of the steps.
1992
- */
1993
- readonly docs: Node$1[];
1994
- /**
1995
- A mapping with the maps for each of the steps in this transform.
1996
- */
1997
- readonly mapping: Mapping;
1998
- /**
1999
- Create a transform that starts with the given document.
2000
- */
2001
- constructor(
2002
- /**
2003
- The current document (the result of applying the steps in the
2004
- transform).
2005
- */
2006
-
2007
- doc: Node$1);
2008
- /**
2009
- The starting document.
2010
- */
2011
- get before(): Node$1;
2012
- /**
2013
- Apply a new step in this transform, saving the result. Throws an
2014
- error when the step fails.
2015
- */
2016
- step(step: Step): this;
2017
- /**
2018
- Try to apply a step in this transformation, ignoring it if it
2019
- fails. Returns the step result.
2020
- */
2021
- maybeStep(step: Step): StepResult;
2022
- /**
2023
- True when the document has been changed (when there are any
2024
- steps).
2025
- */
2026
- get docChanged(): boolean;
2027
- /**
2028
- Return a single range, in post-transform document positions,
2029
- that covers all content changed by this transform. Returns null
2030
- if no replacements are made. Note that this will ignore changes
2031
- that add/remove marks without replacing the underlying content.
2032
- */
2033
- changedRange(): {
2034
- from: number;
2035
- to: number;
2036
- } | null;
2037
- /**
2038
- Replace the part of the document between `from` and `to` with the
2039
- given `slice`.
2040
- */
2041
- replace(from: number, to?: number, slice?: Slice): this;
2042
- /**
2043
- Replace the given range with the given content, which may be a
2044
- fragment, node, or array of nodes.
2045
- */
2046
- replaceWith(from: number, to: number, content: Fragment | Node$1 | readonly Node$1[]): this;
2047
- /**
2048
- Delete the content between the given positions.
2049
- */
2050
- delete(from: number, to: number): this;
2051
- /**
2052
- Insert the given content at the given position.
2053
- */
2054
- insert(pos: number, content: Fragment | Node$1 | readonly Node$1[]): this;
2055
- /**
2056
- Replace a range of the document with a given slice, using
2057
- `from`, `to`, and the slice's
2058
- [`openStart`](https://prosemirror.net/docs/ref/#model.Slice.openStart) property as hints, rather
2059
- than fixed start and end points. This method may grow the
2060
- replaced area or close open nodes in the slice in order to get a
2061
- fit that is more in line with WYSIWYG expectations, by dropping
2062
- fully covered parent nodes of the replaced region when they are
2063
- marked [non-defining as
2064
- context](https://prosemirror.net/docs/ref/#model.NodeSpec.definingAsContext), or including an
2065
- open parent node from the slice that _is_ marked as [defining
2066
- its content](https://prosemirror.net/docs/ref/#model.NodeSpec.definingForContent).
2067
-
2068
- This is the method, for example, to handle paste. The similar
2069
- [`replace`](https://prosemirror.net/docs/ref/#transform.Transform.replace) method is a more
2070
- primitive tool which will _not_ move the start and end of its given
2071
- range, and is useful in situations where you need more precise
2072
- control over what happens.
2073
- */
2074
- replaceRange(from: number, to: number, slice: Slice): this;
2075
- /**
2076
- Replace the given range with a node, but use `from` and `to` as
2077
- hints, rather than precise positions. When from and to are the same
2078
- and are at the start or end of a parent node in which the given
2079
- node doesn't fit, this method may _move_ them out towards a parent
2080
- that does allow the given node to be placed. When the given range
2081
- completely covers a parent node, this method may completely replace
2082
- that parent node.
2083
- */
2084
- replaceRangeWith(from: number, to: number, node: Node$1): this;
2085
- /**
2086
- Delete the given range, expanding it to cover fully covered
2087
- parent nodes until a valid replace is found.
2088
- */
2089
- deleteRange(from: number, to: number): this;
2090
- /**
2091
- Split the content in the given range off from its parent, if there
2092
- is sibling content before or after it, and move it up the tree to
2093
- the depth specified by `target`. You'll probably want to use
2094
- [`liftTarget`](https://prosemirror.net/docs/ref/#transform.liftTarget) to compute `target`, to make
2095
- sure the lift is valid.
2096
- */
2097
- lift(range: NodeRange, target: number): this;
2098
- /**
2099
- Join the blocks around the given position. If depth is 2, their
2100
- last and first siblings are also joined, and so on.
2101
- */
2102
- join(pos: number, depth?: number): this;
2103
- /**
2104
- Wrap the given [range](https://prosemirror.net/docs/ref/#model.NodeRange) in the given set of wrappers.
2105
- The wrappers are assumed to be valid in this position, and should
2106
- probably be computed with [`findWrapping`](https://prosemirror.net/docs/ref/#transform.findWrapping).
2107
- */
2108
- wrap(range: NodeRange, wrappers: readonly {
2109
- type: NodeType;
2110
- attrs?: Attrs | null;
2111
- }[]): this;
2112
- /**
2113
- Set the type of all textblocks (partly) between `from` and `to` to
2114
- the given node type with the given attributes.
2115
- */
2116
- setBlockType(from: number, to: number | undefined, type: NodeType, attrs?: Attrs | null | ((oldNode: Node$1) => Attrs)): this;
2117
- /**
2118
- Change the type, attributes, and/or marks of the node at `pos`.
2119
- When `type` isn't given, the existing node type is preserved,
2120
- */
2121
- setNodeMarkup(pos: number, type?: NodeType | null, attrs?: Attrs | null, marks?: readonly Mark[]): this;
2122
- /**
2123
- Set a single attribute on a given node to a new value.
2124
- The `pos` addresses the document content. Use `setDocAttribute`
2125
- to set attributes on the document itself.
2126
- */
2127
- setNodeAttribute(pos: number, attr: string, value: any): this;
2128
- /**
2129
- Set a single attribute on the document to a new value.
2130
- */
2131
- setDocAttribute(attr: string, value: any): this;
2132
- /**
2133
- Add a mark to the node at position `pos`.
2134
- */
2135
- addNodeMark(pos: number, mark: Mark): this;
2136
- /**
2137
- Remove a mark (or all marks of the given type) from the node at
2138
- position `pos`.
2139
- */
2140
- removeNodeMark(pos: number, mark: Mark | MarkType): this;
2141
- /**
2142
- Split the node at the given position, and optionally, if `depth` is
2143
- greater than one, any number of nodes above that. By default, the
2144
- parts split off will inherit the node type of the original node.
2145
- This can be changed by passing an array of types and attributes to
2146
- use after the split (with the outermost nodes coming first).
2147
- */
2148
- split(pos: number, depth?: number, typesAfter?: (null | {
2149
- type: NodeType;
2150
- attrs?: Attrs | null;
2151
- })[]): this;
2152
- /**
2153
- Add the given mark to the inline content between `from` and `to`.
2154
- */
2155
- addMark(from: number, to: number, mark: Mark): this;
2156
- /**
2157
- Remove marks from inline nodes between `from` and `to`. When
2158
- `mark` is a single mark, remove precisely that mark. When it is
2159
- a mark type, remove all marks of that type. When it is null,
2160
- remove all marks of any type.
2161
- */
2162
- removeMark(from: number, to: number, mark?: Mark | MarkType | null): this;
2163
- /**
2164
- Removes all marks and nodes from the content of the node at
2165
- `pos` that don't match the given new parent node type. Accepts
2166
- an optional starting [content match](https://prosemirror.net/docs/ref/#model.ContentMatch) as
2167
- third argument.
2168
- */
2169
- clearIncompatible(pos: number, parentType: NodeType, match?: ContentMatch): this;
2170
- }
2171
- /**
2172
- Try to find a target depth to which the content in the given range
2173
- can be lifted. Will not go across
2174
- [isolating](https://prosemirror.net/docs/ref/#model.NodeSpec.isolating) parent nodes.
2175
- */
2176
- //#endregion
2177
- //#region ../../node_modules/.pnpm/prosemirror-state@1.4.4/node_modules/prosemirror-state/dist/index.d.ts
2178
- /**
2179
- The type of object passed to
2180
- [`EditorState.create`](https://prosemirror.net/docs/ref/#state.EditorState^create).
2181
- */
2182
- interface EditorStateConfig {
2183
- /**
2184
- The schema to use (only relevant if no `doc` is specified).
2185
- */
2186
- schema?: Schema;
2187
- /**
2188
- The starting document. Either this or `schema` _must_ be
2189
- provided.
2190
- */
2191
- doc?: Node$1;
2192
- /**
2193
- A valid selection in the document.
2194
- */
2195
- selection?: Selection;
2196
- /**
2197
- The initial set of [stored marks](https://prosemirror.net/docs/ref/#state.EditorState.storedMarks).
2198
- */
2199
- storedMarks?: readonly Mark[] | null;
2200
- /**
2201
- The plugins that should be active in this state.
2202
- */
2203
- plugins?: readonly Plugin$1[];
2204
- }
2205
- /**
2206
- The state of a ProseMirror editor is represented by an object of
2207
- this type. A state is a persistent data structure—it isn't
2208
- updated, but rather a new state value is computed from an old one
2209
- using the [`apply`](https://prosemirror.net/docs/ref/#state.EditorState.apply) method.
2210
-
2211
- A state holds a number of built-in fields, and plugins can
2212
- [define](https://prosemirror.net/docs/ref/#state.PluginSpec.state) additional fields.
2213
- */
2214
- declare class EditorState {
2215
- /**
2216
- The current document.
2217
- */
2218
- doc: Node$1;
2219
- /**
2220
- The selection.
2221
- */
2222
- selection: Selection;
2223
- /**
2224
- A set of marks to apply to the next input. Will be null when
2225
- no explicit marks have been set.
2226
- */
2227
- storedMarks: readonly Mark[] | null;
2228
- /**
2229
- The schema of the state's document.
2230
- */
2231
- get schema(): Schema;
2232
- /**
2233
- The plugins that are active in this state.
2234
- */
2235
- get plugins(): readonly Plugin$1[];
2236
- /**
2237
- Apply the given transaction to produce a new state.
2238
- */
2239
- apply(tr: Transaction): EditorState;
2240
- /**
2241
- Verbose variant of [`apply`](https://prosemirror.net/docs/ref/#state.EditorState.apply) that
2242
- returns the precise transactions that were applied (which might
2243
- be influenced by the [transaction
2244
- hooks](https://prosemirror.net/docs/ref/#state.PluginSpec.filterTransaction) of
2245
- plugins) along with the new state.
2246
- */
2247
- applyTransaction(rootTr: Transaction): {
2248
- state: EditorState;
2249
- transactions: readonly Transaction[];
2250
- };
2251
- /**
2252
- Accessor that constructs and returns a new [transaction](https://prosemirror.net/docs/ref/#state.Transaction) from this state.
2253
- */
2254
- get tr(): Transaction;
2255
- /**
2256
- Create a new state.
2257
- */
2258
- static create(config: EditorStateConfig): EditorState;
2259
- /**
2260
- Create a new state based on this one, but with an adjusted set
2261
- of active plugins. State fields that exist in both sets of
2262
- plugins are kept unchanged. Those that no longer exist are
2263
- dropped, and those that are new are initialized using their
2264
- [`init`](https://prosemirror.net/docs/ref/#state.StateField.init) method, passing in the new
2265
- configuration object..
2266
- */
2267
- reconfigure(config: {
2268
- /**
2269
- New set of active plugins.
2270
- */
2271
- plugins?: readonly Plugin$1[];
2272
- }): EditorState;
2273
- /**
2274
- Serialize this state to JSON. If you want to serialize the state
2275
- of plugins, pass an object mapping property names to use in the
2276
- resulting JSON object to plugin objects. The argument may also be
2277
- a string or number, in which case it is ignored, to support the
2278
- way `JSON.stringify` calls `toString` methods.
2279
- */
2280
- toJSON(pluginFields?: {
2281
- [propName: string]: Plugin$1;
2282
- }): any;
2283
- /**
2284
- Deserialize a JSON representation of a state. `config` should
2285
- have at least a `schema` field, and should contain array of
2286
- plugins to initialize the state with. `pluginFields` can be used
2287
- to deserialize the state of plugins, by associating plugin
2288
- instances with the property names they use in the JSON object.
2289
- */
2290
- static fromJSON(config: {
2291
- /**
2292
- The schema to use.
2293
- */
2294
- schema: Schema;
2295
- /**
2296
- The set of active plugins.
2297
- */
2298
- plugins?: readonly Plugin$1[];
2299
- }, json: any, pluginFields?: {
2300
- [propName: string]: Plugin$1;
2301
- }): EditorState;
2302
- }
2303
- /**
2304
- This is the type passed to the [`Plugin`](https://prosemirror.net/docs/ref/#state.Plugin)
2305
- constructor. It provides a definition for a plugin.
2306
- */
2307
- interface PluginSpec<PluginState> {
2308
- /**
2309
- The [view props](https://prosemirror.net/docs/ref/#view.EditorProps) added by this plugin. Props
2310
- that are functions will be bound to have the plugin instance as
2311
- their `this` binding.
2312
- */
2313
- props?: EditorProps<Plugin$1<PluginState>>;
2314
- /**
2315
- Allows a plugin to define a [state field](https://prosemirror.net/docs/ref/#state.StateField), an
2316
- extra slot in the state object in which it can keep its own data.
2317
- */
2318
- state?: StateField<PluginState>;
2319
- /**
2320
- Can be used to make this a keyed plugin. You can have only one
2321
- plugin with a given key in a given state, but it is possible to
2322
- access the plugin's configuration and state through the key,
2323
- without having access to the plugin instance object.
2324
- */
2325
- key?: PluginKey$1;
2326
- /**
2327
- When the plugin needs to interact with the editor view, or
2328
- set something up in the DOM, use this field. The function
2329
- will be called when the plugin's state is associated with an
2330
- editor view.
2331
- */
2332
- view?: (view: EditorView) => PluginView;
2333
- /**
2334
- When present, this will be called before a transaction is
2335
- applied by the state, allowing the plugin to cancel it (by
2336
- returning false).
2337
- */
2338
- filterTransaction?: (tr: Transaction, state: EditorState) => boolean;
2339
- /**
2340
- Allows the plugin to append another transaction to be applied
2341
- after the given array of transactions. When another plugin
2342
- appends a transaction after this was called, it is called again
2343
- with the new state and new transactions—but only the new
2344
- transactions, i.e. it won't be passed transactions that it
2345
- already saw.
2346
- */
2347
- appendTransaction?: (transactions: readonly Transaction[], oldState: EditorState, newState: EditorState) => Transaction | null | undefined;
2348
- /**
2349
- Additional properties are allowed on plugin specs, which can be
2350
- read via [`Plugin.spec`](https://prosemirror.net/docs/ref/#state.Plugin.spec).
2351
- */
2352
- [key: string]: any;
2353
- }
2354
- /**
2355
- A stateful object that can be installed in an editor by a
2356
- [plugin](https://prosemirror.net/docs/ref/#state.PluginSpec.view).
2357
- */
2358
- type PluginView = {
2359
- /**
2360
- Called whenever the view's state is updated.
2361
- */
2362
- update?: (view: EditorView, prevState: EditorState) => void;
2363
- /**
2364
- Called when the view is destroyed or receives a state
2365
- with different plugins.
2366
- */
2367
- destroy?: () => void;
2368
- };
2369
- /**
2370
- Plugins bundle functionality that can be added to an editor.
2371
- They are part of the [editor state](https://prosemirror.net/docs/ref/#state.EditorState) and
2372
- may influence that state and the view that contains it.
2373
- */
2374
- declare class Plugin$1<PluginState = any> {
2375
- /**
2376
- The plugin's [spec object](https://prosemirror.net/docs/ref/#state.PluginSpec).
2377
- */
2378
- readonly spec: PluginSpec<PluginState>;
2379
- /**
2380
- Create a plugin.
2381
- */
2382
- constructor(
2383
- /**
2384
- The plugin's [spec object](https://prosemirror.net/docs/ref/#state.PluginSpec).
2385
- */
2386
-
2387
- spec: PluginSpec<PluginState>);
2388
- /**
2389
- The [props](https://prosemirror.net/docs/ref/#view.EditorProps) exported by this plugin.
2390
- */
2391
- readonly props: EditorProps<Plugin$1<PluginState>>;
2392
- /**
2393
- Extract the plugin's state field from an editor state.
2394
- */
2395
- getState(state: EditorState): PluginState | undefined;
2396
- }
2397
- /**
2398
- A plugin spec may provide a state field (under its
2399
- [`state`](https://prosemirror.net/docs/ref/#state.PluginSpec.state) property) of this type, which
2400
- describes the state it wants to keep. Functions provided here are
2401
- always called with the plugin instance as their `this` binding.
2402
- */
2403
- interface StateField<T> {
2404
- /**
2405
- Initialize the value of the field. `config` will be the object
2406
- passed to [`EditorState.create`](https://prosemirror.net/docs/ref/#state.EditorState^create). Note
2407
- that `instance` is a half-initialized state instance, and will
2408
- not have values for plugin fields initialized after this one.
2409
- */
2410
- init: (config: EditorStateConfig, instance: EditorState) => T;
2411
- /**
2412
- Apply the given transaction to this state field, producing a new
2413
- field value. Note that the `newState` argument is again a partially
2414
- constructed state does not yet contain the state from plugins
2415
- coming after this one.
2416
- */
2417
- apply: (tr: Transaction, value: T, oldState: EditorState, newState: EditorState) => T;
2418
- /**
2419
- Convert this field to JSON. Optional, can be left off to disable
2420
- JSON serialization for the field.
2421
- */
2422
- toJSON?: (value: T) => any;
2423
- /**
2424
- Deserialize the JSON representation of this field. Note that the
2425
- `state` argument is again a half-initialized state.
2426
- */
2427
- fromJSON?: (config: EditorStateConfig, value: any, state: EditorState) => T;
2428
- }
2429
- /**
2430
- A key is used to [tag](https://prosemirror.net/docs/ref/#state.PluginSpec.key) plugins in a way
2431
- that makes it possible to find them, given an editor state.
2432
- Assigning a key does mean only one plugin of that type can be
2433
- active in a state.
2434
- */
2435
- declare class PluginKey$1<PluginState = any> {
2436
- /**
2437
- Create a plugin key.
2438
- */
2439
- constructor(name?: string);
2440
- /**
2441
- Get the active plugin with this key, if any, from an editor
2442
- state.
2443
- */
2444
- get(state: EditorState): Plugin$1<PluginState> | undefined;
2445
- /**
2446
- Get the plugin's state from an editor state.
2447
- */
2448
- getState(state: EditorState): PluginState | undefined;
2449
- }
2450
- /**
2451
- Commands are functions that take a state and a an optional
2452
- transaction dispatch function and...
2453
-
2454
- - determine whether they apply to this state
2455
- - if not, return false
2456
- - if `dispatch` was passed, perform their effect, possibly by
2457
- passing a transaction to `dispatch`
2458
- - return true
2459
-
2460
- In some cases, the editor view is passed as a third argument.
2461
- */
2462
- /**
2463
- An editor state transaction, which can be applied to a state to
2464
- create an updated state. Use
2465
- [`EditorState.tr`](https://prosemirror.net/docs/ref/#state.EditorState.tr) to create an instance.
2466
-
2467
- Transactions track changes to the document (they are a subclass of
2468
- [`Transform`](https://prosemirror.net/docs/ref/#transform.Transform)), but also other state changes,
2469
- like selection updates and adjustments of the set of [stored
2470
- marks](https://prosemirror.net/docs/ref/#state.EditorState.storedMarks). In addition, you can store
2471
- metadata properties in a transaction, which are extra pieces of
2472
- information that client code or plugins can use to describe what a
2473
- transaction represents, so that they can update their [own
2474
- state](https://prosemirror.net/docs/ref/#state.StateField) accordingly.
2475
-
2476
- The [editor view](https://prosemirror.net/docs/ref/#view.EditorView) uses a few metadata
2477
- properties: it will attach a property `"pointer"` with the value
2478
- `true` to selection transactions directly caused by mouse or touch
2479
- input, a `"composition"` property holding an ID identifying the
2480
- composition that caused it to transactions caused by composed DOM
2481
- input, and a `"uiEvent"` property of that may be `"paste"`,
2482
- `"cut"`, or `"drop"`.
2483
- */
2484
- declare class Transaction extends Transform {
2485
- /**
2486
- The timestamp associated with this transaction, in the same
2487
- format as `Date.now()`.
2488
- */
2489
- time: number;
2490
- private curSelection;
2491
- private curSelectionFor;
2492
- private updated;
2493
- private meta;
2494
- /**
2495
- The stored marks set by this transaction, if any.
2496
- */
2497
- storedMarks: readonly Mark[] | null;
2498
- /**
2499
- The transaction's current selection. This defaults to the editor
2500
- selection [mapped](https://prosemirror.net/docs/ref/#state.Selection.map) through the steps in the
2501
- transaction, but can be overwritten with
2502
- [`setSelection`](https://prosemirror.net/docs/ref/#state.Transaction.setSelection).
2503
- */
2504
- get selection(): Selection;
2505
- /**
2506
- Update the transaction's current selection. Will determine the
2507
- selection that the editor gets when the transaction is applied.
2508
- */
2509
- setSelection(selection: Selection): this;
2510
- /**
2511
- Whether the selection was explicitly updated by this transaction.
2512
- */
2513
- get selectionSet(): boolean;
2514
- /**
2515
- Set the current stored marks.
2516
- */
2517
- setStoredMarks(marks: readonly Mark[] | null): this;
2518
- /**
2519
- Make sure the current stored marks or, if that is null, the marks
2520
- at the selection, match the given set of marks. Does nothing if
2521
- this is already the case.
2522
- */
2523
- ensureMarks(marks: readonly Mark[]): this;
2524
- /**
2525
- Add a mark to the set of stored marks.
2526
- */
2527
- addStoredMark(mark: Mark): this;
2528
- /**
2529
- Remove a mark or mark type from the set of stored marks.
2530
- */
2531
- removeStoredMark(mark: Mark | MarkType): this;
2532
- /**
2533
- Whether the stored marks were explicitly set for this transaction.
2534
- */
2535
- get storedMarksSet(): boolean;
2536
- /**
2537
- Update the timestamp for the transaction.
2538
- */
2539
- setTime(time: number): this;
2540
- /**
2541
- Replace the current selection with the given slice.
2542
- */
2543
- replaceSelection(slice: Slice): this;
2544
- /**
2545
- Replace the selection with the given node. When `inheritMarks` is
2546
- true and the content is inline, it inherits the marks from the
2547
- place where it is inserted.
2548
- */
2549
- replaceSelectionWith(node: Node$1, inheritMarks?: boolean): this;
2550
- /**
2551
- Delete the selection.
2552
- */
2553
- deleteSelection(): this;
2554
- /**
2555
- Replace the given range, or the selection if no range is given,
2556
- with a text node containing the given string.
2557
- */
2558
- insertText(text: string, from?: number, to?: number): this;
2559
- /**
2560
- Store a metadata property in this transaction, keyed either by
2561
- name or by plugin.
2562
- */
2563
- setMeta(key: string | Plugin$1 | PluginKey$1, value: any): this;
2564
- /**
2565
- Retrieve a metadata property for a given name or plugin.
2566
- */
2567
- getMeta(key: string | Plugin$1 | PluginKey$1): any;
2568
- /**
2569
- Returns true if this transaction doesn't contain any metadata,
2570
- and can thus safely be extended.
2571
- */
2572
- get isGeneric(): boolean;
2573
- /**
2574
- Indicate that the editor should scroll the selection into view
2575
- when updated to the state produced by this transaction.
2576
- */
2577
- scrollIntoView(): this;
2578
- /**
2579
- True when this transaction has had `scrollIntoView` called on it.
2580
- */
2581
- get scrolledIntoView(): boolean;
2582
- }
2583
- /**
2584
- Superclass for editor selections. Every selection type should
2585
- extend this. Should not be instantiated directly.
2586
- */
2587
- declare abstract class Selection {
2588
- /**
2589
- The resolved anchor of the selection (the side that stays in
2590
- place when the selection is modified).
2591
- */
2592
- readonly $anchor: ResolvedPos;
2593
- /**
2594
- The resolved head of the selection (the side that moves when
2595
- the selection is modified).
2596
- */
2597
- readonly $head: ResolvedPos;
2598
- /**
2599
- Initialize a selection with the head and anchor and ranges. If no
2600
- ranges are given, constructs a single range across `$anchor` and
2601
- `$head`.
2602
- */
2603
- constructor(
2604
- /**
2605
- The resolved anchor of the selection (the side that stays in
2606
- place when the selection is modified).
2607
- */
2608
-
2609
- $anchor: ResolvedPos,
2610
- /**
2611
- The resolved head of the selection (the side that moves when
2612
- the selection is modified).
2613
- */
2614
-
2615
- $head: ResolvedPos, ranges?: readonly SelectionRange[]);
2616
- /**
2617
- The ranges covered by the selection.
2618
- */
2619
- ranges: readonly SelectionRange[];
2620
- /**
2621
- The selection's anchor, as an unresolved position.
2622
- */
2623
- get anchor(): number;
2624
- /**
2625
- The selection's head.
2626
- */
2627
- get head(): number;
2628
- /**
2629
- The lower bound of the selection's main range.
2630
- */
2631
- get from(): number;
2632
- /**
2633
- The upper bound of the selection's main range.
2634
- */
2635
- get to(): number;
2636
- /**
2637
- The resolved lower bound of the selection's main range.
2638
- */
2639
- get $from(): ResolvedPos;
2640
- /**
2641
- The resolved upper bound of the selection's main range.
2642
- */
2643
- get $to(): ResolvedPos;
2644
- /**
2645
- Indicates whether the selection contains any content.
2646
- */
2647
- get empty(): boolean;
2648
- /**
2649
- Test whether the selection is the same as another selection.
2650
- */
2651
- abstract eq(selection: Selection): boolean;
2652
- /**
2653
- Map this selection through a [mappable](https://prosemirror.net/docs/ref/#transform.Mappable)
2654
- thing. `doc` should be the new document to which we are mapping.
2655
- */
2656
- abstract map(doc: Node$1, mapping: Mappable): Selection;
2657
- /**
2658
- Get the content of this selection as a slice.
2659
- */
2660
- content(): Slice;
2661
- /**
2662
- Replace the selection with a slice or, if no slice is given,
2663
- delete the selection. Will append to the given transaction.
2664
- */
2665
- replace(tr: Transaction, content?: Slice): void;
2666
- /**
2667
- Replace the selection with the given node, appending the changes
2668
- to the given transaction.
2669
- */
2670
- replaceWith(tr: Transaction, node: Node$1): void;
2671
- /**
2672
- Convert the selection to a JSON representation. When implementing
2673
- this for a custom selection class, make sure to give the object a
2674
- `type` property whose value matches the ID under which you
2675
- [registered](https://prosemirror.net/docs/ref/#state.Selection^jsonID) your class.
2676
- */
2677
- abstract toJSON(): any;
2678
- /**
2679
- Find a valid cursor or leaf node selection starting at the given
2680
- position and searching back if `dir` is negative, and forward if
2681
- positive. When `textOnly` is true, only consider cursor
2682
- selections. Will return null when no valid selection position is
2683
- found.
2684
- */
2685
- static findFrom($pos: ResolvedPos, dir: number, textOnly?: boolean): Selection | null;
2686
- /**
2687
- Find a valid cursor or leaf node selection near the given
2688
- position. Searches forward first by default, but if `bias` is
2689
- negative, it will search backwards first.
2690
- */
2691
- static near($pos: ResolvedPos, bias?: number): Selection;
2692
- /**
2693
- Find the cursor or leaf node selection closest to the start of
2694
- the given document. Will return an
2695
- [`AllSelection`](https://prosemirror.net/docs/ref/#state.AllSelection) if no valid position
2696
- exists.
2697
- */
2698
- static atStart(doc: Node$1): Selection;
2699
- /**
2700
- Find the cursor or leaf node selection closest to the end of the
2701
- given document.
2702
- */
2703
- static atEnd(doc: Node$1): Selection;
2704
- /**
2705
- Deserialize the JSON representation of a selection. Must be
2706
- implemented for custom classes (as a static class method).
2707
- */
2708
- static fromJSON(doc: Node$1, json: any): Selection;
2709
- /**
2710
- To be able to deserialize selections from JSON, custom selection
2711
- classes must register themselves with an ID string, so that they
2712
- can be disambiguated. Try to pick something that's unlikely to
2713
- clash with classes from other modules.
2714
- */
2715
- static jsonID(id: string, selectionClass: {
2716
- fromJSON: (doc: Node$1, json: any) => Selection;
2717
- }): {
2718
- fromJSON: (doc: Node$1, json: any) => Selection;
2719
- };
2720
- /**
2721
- Get a [bookmark](https://prosemirror.net/docs/ref/#state.SelectionBookmark) for this selection,
2722
- which is a value that can be mapped without having access to a
2723
- current document, and later resolved to a real selection for a
2724
- given document again. (This is used mostly by the history to
2725
- track and restore old selections.) The default implementation of
2726
- this method just converts the selection to a text selection and
2727
- returns the bookmark for that.
2728
- */
2729
- getBookmark(): SelectionBookmark;
2730
- /**
2731
- Controls whether, when a selection of this type is active in the
2732
- browser, the selected range should be visible to the user.
2733
- Defaults to `true`.
2734
- */
2735
- visible: boolean;
2736
- }
2737
- /**
2738
- A lightweight, document-independent representation of a selection.
2739
- You can define a custom bookmark type for a custom selection class
2740
- to make the history handle it well.
2741
- */
2742
- interface SelectionBookmark {
2743
- /**
2744
- Map the bookmark through a set of changes.
2745
- */
2746
- map: (mapping: Mappable) => SelectionBookmark;
2747
- /**
2748
- Resolve the bookmark to a real selection again. This may need to
2749
- do some error checking and may fall back to a default (usually
2750
- [`TextSelection.between`](https://prosemirror.net/docs/ref/#state.TextSelection^between)) if
2751
- mapping made the bookmark invalid.
2752
- */
2753
- resolve: (doc: Node$1) => Selection;
2754
- }
2755
- /**
2756
- Represents a selected range in a document.
2757
- */
2758
- declare class SelectionRange {
2759
- /**
2760
- The lower bound of the range.
2761
- */
2762
- readonly $from: ResolvedPos;
2763
- /**
2764
- The upper bound of the range.
2765
- */
2766
- readonly $to: ResolvedPos;
2767
- /**
2768
- Create a range.
2769
- */
2770
- constructor(
2771
- /**
2772
- The lower bound of the range.
2773
- */
2774
-
2775
- $from: ResolvedPos,
2776
- /**
2777
- The upper bound of the range.
2778
- */
2779
-
2780
- $to: ResolvedPos);
2781
- }
2782
- /**
2783
- A text selection represents a classical editor selection, with a
2784
- head (the moving side) and anchor (immobile side), both of which
2785
- point into textblock nodes. It can be empty (a regular cursor
2786
- position).
2787
- */
2788
- //#endregion
2789
- //#region ../../node_modules/.pnpm/prosemirror-view@1.42.1/node_modules/prosemirror-view/dist/index.d.ts
2790
- type DOMNode = InstanceType<typeof window.Node>;
2791
- type WidgetConstructor = ((view: EditorView, getPos: () => number | undefined) => DOMNode) | DOMNode;
2792
- /**
2793
- Decoration objects can be provided to the view through the
2794
- [`decorations` prop](https://prosemirror.net/docs/ref/#view.EditorProps.decorations). They come in
2795
- several variants—see the static members of this class for details.
2796
- */
2797
- declare class Decoration {
2798
- /**
2799
- The start position of the decoration.
2800
- */
2801
- readonly from: number;
2802
- /**
2803
- The end position. Will be the same as `from` for [widget
2804
- decorations](https://prosemirror.net/docs/ref/#view.Decoration^widget).
2805
- */
2806
- readonly to: number;
2807
- /**
2808
- Creates a widget decoration, which is a DOM node that's shown in
2809
- the document at the given position. It is recommended that you
2810
- delay rendering the widget by passing a function that will be
2811
- called when the widget is actually drawn in a view, but you can
2812
- also directly pass a DOM node. `getPos` can be used to find the
2813
- widget's current document position.
2814
- */
2815
- static widget(pos: number, toDOM: WidgetConstructor, spec?: {
2816
- /**
2817
- Controls which side of the document position this widget is
2818
- associated with. When negative, it is drawn before a cursor
2819
- at its position, and content inserted at that position ends
2820
- up after the widget. When zero (the default) or positive, the
2821
- widget is drawn after the cursor and content inserted there
2822
- ends up before the widget.
2823
-
2824
- When there are multiple widgets at a given position, their
2825
- `side` values determine the order in which they appear. Those
2826
- with lower values appear first. The ordering of widgets with
2827
- the same `side` value is unspecified.
2828
-
2829
- When `marks` is null, `side` also determines the marks that
2830
- the widget is wrapped in—those of the node before when
2831
- negative, those of the node after when positive.
2832
- */
2833
- side?: number;
2834
- /**
2835
- By default, the cursor, when at the position of the widget,
2836
- will be strictly kept on the side indicated by
2837
- [`side`](https://prosemirror.net/docs/ref/#view.Decoration^widget^spec.side). Set this to true
2838
- to allow the DOM selection to stay on the other side if the
2839
- client sets it there.
2840
-
2841
- **Note**: Mapping of this decoration, which decides on which
2842
- side insertions at its position appear, will still happen
2843
- according to `side`, and keyboard cursor motion will not,
2844
- without further custom handling, visit both sides of the
2845
- widget.
2846
- */
2847
- relaxedSide?: boolean;
2848
- /**
2849
- The precise set of marks to draw around the widget.
2850
- */
2851
- marks?: readonly Mark[];
2852
- /**
2853
- Can be used to control which DOM events, when they bubble out
2854
- of this widget, the editor view should ignore.
2855
- */
2856
- stopEvent?: (event: Event) => boolean;
2857
- /**
2858
- When set (defaults to false), selection changes inside the
2859
- widget are ignored, and don't cause ProseMirror to try and
2860
- re-sync the selection with its selection state.
2861
- */
2862
- ignoreSelection?: boolean;
2863
- /**
2864
- When comparing decorations of this type (in order to decide
2865
- whether it needs to be redrawn), ProseMirror will by default
2866
- compare the widget DOM node by identity. If you pass a key,
2867
- that key will be compared instead, which can be useful when
2868
- you generate decorations on the fly and don't want to store
2869
- and reuse DOM nodes. Make sure that any widgets with the same
2870
- key are interchangeable—if widgets differ in, for example,
2871
- the behavior of some event handler, they should get
2872
- different keys.
2873
- */
2874
- key?: string;
2875
- /**
2876
- Called when the widget decoration is removed or the editor is
2877
- destroyed.
2878
- */
2879
- destroy?: (node: DOMNode) => void;
2880
- /**
2881
- Specs allow arbitrary additional properties.
2882
- */
2883
- [key: string]: any;
2884
- }): Decoration;
2885
- /**
2886
- Creates an inline decoration, which adds the given attributes to
2887
- each inline node between `from` and `to`.
2888
- */
2889
- static inline(from: number, to: number, attrs: DecorationAttrs, spec?: {
2890
- /**
2891
- Determines how the left side of the decoration is
2892
- [mapped](https://prosemirror.net/docs/ref/#transform.Position_Mapping) when content is
2893
- inserted directly at that position. By default, the decoration
2894
- won't include the new content, but you can set this to `true`
2895
- to make it inclusive.
2896
- */
2897
- inclusiveStart?: boolean;
2898
- /**
2899
- Determines how the right side of the decoration is mapped.
2900
- See
2901
- [`inclusiveStart`](https://prosemirror.net/docs/ref/#view.Decoration^inline^spec.inclusiveStart).
2902
- */
2903
- inclusiveEnd?: boolean;
2904
- /**
2905
- Specs may have arbitrary additional properties.
2906
- */
2907
- [key: string]: any;
2908
- }): Decoration;
2909
- /**
2910
- Creates a node decoration. `from` and `to` should point precisely
2911
- before and after a node in the document. That node, and only that
2912
- node, will receive the given attributes.
2913
- */
2914
- static node(from: number, to: number, attrs: DecorationAttrs, spec?: any): Decoration;
2915
- /**
2916
- The spec provided when creating this decoration. Can be useful
2917
- if you've stored extra information in that object.
2918
- */
2919
- get spec(): any;
2920
- }
2921
- /**
2922
- A set of attributes to add to a decorated node. Most properties
2923
- simply directly correspond to DOM attributes of the same name,
2924
- which will be set to the property's value. These are exceptions:
2925
- */
2926
- type DecorationAttrs = {
2927
- /**
2928
- When non-null, the target node is wrapped in a DOM element of
2929
- this type (and the other attributes are applied to this element).
2930
- */
2931
- nodeName?: string;
2932
- /**
2933
- A CSS class name or a space-separated set of class names to be
2934
- _added_ to the classes that the node already had.
2935
- */
2936
- class?: string;
2937
- /**
2938
- A string of CSS to be _added_ to the node's existing `style` property.
2939
- */
2940
- style?: string;
2941
- /**
2942
- Any other properties are treated as regular DOM attributes.
2943
- */
2944
- [attribute: string]: string | undefined;
2945
- };
2946
- /**
2947
- An object that can [provide](https://prosemirror.net/docs/ref/#view.EditorProps.decorations)
2948
- decorations. Implemented by [`DecorationSet`](https://prosemirror.net/docs/ref/#view.DecorationSet),
2949
- and passed to [node views](https://prosemirror.net/docs/ref/#view.EditorProps.nodeViews).
2950
- */
2951
- interface DecorationSource {
2952
- /**
2953
- Map the set of decorations in response to a change in the
2954
- document.
2955
- */
2956
- map: (mapping: Mapping, node: Node$1) => DecorationSource;
2957
- /**
2958
- Extract a DecorationSource containing decorations for the given child node at the given offset.
2959
- */
2960
- forChild(offset: number, child: Node$1): DecorationSource;
2961
- /**
2962
- Call the given function for each decoration set in the group.
2963
- */
2964
- forEachSet(f: (set: DecorationSet) => void): void;
2965
- }
2966
- /**
2967
- A collection of [decorations](https://prosemirror.net/docs/ref/#view.Decoration), organized in such
2968
- a way that the drawing algorithm can efficiently use and compare
2969
- them. This is a persistent data structure—it is not modified,
2970
- updates create a new value.
2971
- */
2972
- declare class DecorationSet implements DecorationSource {
2973
- /**
2974
- Create a set of decorations, using the structure of the given
2975
- document. This will consume (modify) the `decorations` array, so
2976
- you must make a copy if you want need to preserve that.
2977
- */
2978
- static create(doc: Node$1, decorations: Decoration[]): DecorationSet;
2979
- /**
2980
- Find all decorations in this set which touch the given range
2981
- (including decorations that start or end directly at the
2982
- boundaries) and match the given predicate on their spec. When
2983
- `start` and `end` are omitted, all decorations in the set are
2984
- considered. When `predicate` isn't given, all decorations are
2985
- assumed to match.
2986
- */
2987
- find(start?: number, end?: number, predicate?: (spec: any) => boolean): Decoration[];
2988
- private findInner;
2989
- /**
2990
- Map the set of decorations in response to a change in the
2991
- document.
2992
- */
2993
- map(mapping: Mapping, doc: Node$1, options?: {
2994
- /**
2995
- When given, this function will be called for each decoration
2996
- that gets dropped as a result of the mapping, passing the
2997
- spec of that decoration.
2998
- */
2999
- onRemove?: (decorationSpec: any) => void;
3000
- }): DecorationSet;
3001
- /**
3002
- Add the given array of decorations to the ones in the set,
3003
- producing a new set. Consumes the `decorations` array. Needs
3004
- access to the current document to create the appropriate tree
3005
- structure.
3006
- */
3007
- add(doc: Node$1, decorations: Decoration[]): DecorationSet;
3008
- private addInner;
3009
- /**
3010
- Create a new set that contains the decorations in this set, minus
3011
- the ones in the given array.
3012
- */
3013
- remove(decorations: Decoration[]): DecorationSet;
3014
- private removeInner;
3015
- forChild(offset: number, node: Node$1): DecorationSet | DecorationGroup;
3016
- /**
3017
- The empty set of decorations.
3018
- */
3019
- static empty: DecorationSet;
3020
- forEachSet(f: (set: DecorationSet) => void): void;
3021
- }
3022
- declare class DecorationGroup implements DecorationSource {
3023
- readonly members: readonly DecorationSet[];
3024
- constructor(members: readonly DecorationSet[]);
3025
- map(mapping: Mapping, doc: Node$1): DecorationSource;
3026
- forChild(offset: number, child: Node$1): DecorationSource | DecorationSet;
3027
- eq(other: DecorationGroup): boolean;
3028
- locals(node: Node$1): readonly any[];
3029
- static from(members: readonly DecorationSource[]): DecorationSource;
3030
- forEachSet(f: (set: DecorationSet) => void): void;
3031
- }
3032
- declare global {
3033
- interface Node {}
3034
- }
3035
- /**
3036
- A ViewMutationRecord represents a DOM
3037
- [mutation](https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver)
3038
- or a selection change happens within the view. When the change is
3039
- a selection change, the record will have a `type` property of
3040
- `"selection"` (which doesn't occur for native mutation records).
3041
- */
3042
- type ViewMutationRecord = MutationRecord | {
3043
- type: "selection";
3044
- target: DOMNode;
3045
- };
3046
- /**
3047
- By default, document nodes are rendered using the result of the
3048
- [`toDOM`](https://prosemirror.net/docs/ref/#model.NodeSpec.toDOM) method of their spec, and managed
3049
- entirely by the editor. For some use cases, such as embedded
3050
- node-specific editing interfaces, you want more control over
3051
- the behavior of a node's in-editor representation, and need to
3052
- [define](https://prosemirror.net/docs/ref/#view.EditorProps.nodeViews) a custom node view.
3053
-
3054
- Objects returned as node views must conform to this interface.
3055
- */
3056
- interface NodeView {
3057
- /**
3058
- The outer DOM node that represents the document node.
3059
- */
3060
- dom: HTMLElement;
3061
- /**
3062
- The DOM node that should hold the node's content. Only meaningful
3063
- if the node view also defines a `dom` property and if its node
3064
- type is not a leaf node type. When this is present, ProseMirror
3065
- will take care of rendering the node's children into it. When it
3066
- is not present, the node view itself is responsible for rendering
3067
- (or deciding not to render) its child nodes.
3068
- */
3069
- contentDOM?: HTMLElement | null;
3070
- /**
3071
- When given, this will be called when the view is updating
3072
- itself. It will be given a node, an array of active decorations
3073
- around the node (which are automatically drawn, and the node
3074
- view may ignore if it isn't interested in them), and a
3075
- [decoration source](https://prosemirror.net/docs/ref/#view.DecorationSource) that represents any
3076
- decorations that apply to the content of the node (which again
3077
- may be ignored). It should return true if it was able to update
3078
- to that node, and false otherwise. If the node view has a
3079
- `contentDOM` property (or no `dom` property), updating its child
3080
- nodes will be handled by ProseMirror.
3081
- */
3082
- update?: (node: Node$1, decorations: readonly Decoration[], innerDecorations: DecorationSource) => boolean;
3083
- /**
3084
- By default, `update` will only be called when a node of the same
3085
- node type appears in this view's position. When you set this to
3086
- true, it will be called for any node, making it possible to have
3087
- a node view that representsmultiple types of nodes. You will
3088
- need to check the type of the nodes you get in `update` and
3089
- return `false` for types you cannot handle.
3090
- */
3091
- multiType?: boolean;
3092
- /**
3093
- Can be used to override the way the node's selected status (as a
3094
- node selection) is displayed.
3095
- */
3096
- selectNode?: () => void;
3097
- /**
3098
- When defining a `selectNode` method, you should also provide a
3099
- `deselectNode` method to remove the effect again.
3100
- */
3101
- deselectNode?: () => void;
3102
- /**
3103
- This will be called to handle setting the selection inside the
3104
- node. The `anchor` and `head` positions are relative to the start
3105
- of the node. By default, a DOM selection will be created between
3106
- the DOM positions corresponding to those positions, but if you
3107
- override it you can do something else.
3108
- */
3109
- setSelection?: (anchor: number, head: number, root: Document | ShadowRoot) => void;
3110
- /**
3111
- Can be used to prevent the editor view from trying to handle some
3112
- or all DOM events that bubble up from the node view. Events for
3113
- which this returns true are not handled by the editor.
3114
- */
3115
- stopEvent?: (event: Event) => boolean;
3116
- /**
3117
- Called when a [mutation](https://prosemirror.net/docs/ref/#view.ViewMutationRecord) happens within the
3118
- view. Return false if the editor should re-read the selection or re-parse
3119
- the range around the mutation, true if it can safely be ignored.
3120
- */
3121
- ignoreMutation?: (mutation: ViewMutationRecord) => boolean;
3122
- /**
3123
- Called when the node view is removed from the editor or the whole
3124
- editor is destroyed.
3125
- */
3126
- destroy?: () => void;
3127
- }
3128
- /**
3129
- By default, document marks are rendered using the result of the
3130
- [`toDOM`](https://prosemirror.net/docs/ref/#model.MarkSpec.toDOM) method of their spec, and managed entirely
3131
- by the editor. For some use cases, you want more control over the behavior
3132
- of a mark's in-editor representation, and need to
3133
- [define](https://prosemirror.net/docs/ref/#view.EditorProps.markViews) a custom mark view.
3134
-
3135
- Objects returned as mark views must conform to this interface.
3136
- */
3137
- interface MarkView {
3138
- /**
3139
- The outer DOM node that represents the document node.
3140
- */
3141
- dom: HTMLElement;
3142
- /**
3143
- The DOM node that should hold the mark's content. When this is not
3144
- present, the `dom` property is used as the content DOM.
3145
- */
3146
- contentDOM?: HTMLElement | null;
3147
- /**
3148
- When given, this is called when the view is updating itself. It
3149
- will be given a mark (of the same type as the current one). When it
3150
- returns true, the existing DOM is kept and reused (its content is
3151
- still managed by ProseMirror); when it returns false, the mark view
3152
- is rebuilt.
3153
- */
3154
- update?: (mark: Mark) => boolean;
3155
- /**
3156
- Called when a [mutation](https://prosemirror.net/docs/ref/#view.ViewMutationRecord) happens within the
3157
- view. Return false if the editor should re-read the selection or re-parse
3158
- the range around the mutation, true if it can safely be ignored.
3159
- */
3160
- ignoreMutation?: (mutation: ViewMutationRecord) => boolean;
3161
- /**
3162
- Called when the mark view is removed from the editor or the whole
3163
- editor is destroyed.
3164
- */
3165
- destroy?: () => void;
3166
- }
3167
- /**
3168
- An editor view manages the DOM structure that represents an
3169
- editable document. Its state and behavior are determined by its
3170
- [props](https://prosemirror.net/docs/ref/#view.DirectEditorProps).
3171
- */
3172
- declare class EditorView {
3173
- private directPlugins;
3174
- private _root;
3175
- private mounted;
3176
- private prevDirectPlugins;
3177
- private pluginViews;
3178
- /**
3179
- The view's current [state](https://prosemirror.net/docs/ref/#state.EditorState).
3180
- */
3181
- state: EditorState;
3182
- /**
3183
- Create a view. `place` may be a DOM node that the editor should
3184
- be appended to, a function that will place it into the document,
3185
- or an object whose `mount` property holds the node to use as the
3186
- document container. If it is `null`, the editor will not be
3187
- added to the document.
3188
- */
3189
- constructor(place: null | DOMNode | ((editor: HTMLElement) => void) | {
3190
- mount: HTMLElement;
3191
- }, props: DirectEditorProps);
3192
- /**
3193
- An editable DOM node containing the document. (You probably
3194
- should not directly interfere with its content.)
3195
- */
3196
- readonly dom: HTMLElement;
3197
- /**
3198
- Indicates whether the editor is currently [editable](https://prosemirror.net/docs/ref/#view.EditorProps.editable).
3199
- */
3200
- editable: boolean;
3201
- /**
3202
- When editor content is being dragged, this object contains
3203
- information about the dragged slice and whether it is being
3204
- copied or moved. At any other time, it is null.
3205
- */
3206
- dragging: null | {
3207
- slice: Slice;
3208
- move: boolean;
3209
- };
3210
- /**
3211
- Holds `true` when a
3212
- [composition](https://w3c.github.io/uievents/#events-compositionevents)
3213
- is active.
3214
- */
3215
- get composing(): boolean;
3216
- /**
3217
- The view's current [props](https://prosemirror.net/docs/ref/#view.EditorProps).
3218
- */
3219
- get props(): DirectEditorProps;
3220
- /**
3221
- Update the view's props. Will immediately cause an update to
3222
- the DOM.
3223
- */
3224
- update(props: DirectEditorProps): void;
3225
- /**
3226
- Update the view by updating existing props object with the object
3227
- given as argument. Equivalent to `view.update(Object.assign({},
3228
- view.props, props))`.
3229
- */
3230
- setProps(props: Partial<DirectEditorProps>): void;
3231
- /**
3232
- Update the editor's `state` prop, without touching any of the
3233
- other props.
3234
- */
3235
- updateState(state: EditorState): void;
3236
- private updateStateInner;
3237
- private destroyPluginViews;
3238
- private updatePluginViews;
3239
- private updateDraggedNode;
3240
- /**
3241
- Goes over the values of a prop, first those provided directly,
3242
- then those from plugins given to the view, then from plugins in
3243
- the state (in order), and calls `f` every time a non-undefined
3244
- value is found. When `f` returns a truthy value, that is
3245
- immediately returned. When `f` isn't provided, it is treated as
3246
- the identity function (the prop value is returned directly).
3247
- */
3248
- someProp<PropName extends keyof EditorProps, Result>(propName: PropName, f: (value: NonNullable<EditorProps[PropName]>) => Result): Result | undefined;
3249
- someProp<PropName extends keyof EditorProps>(propName: PropName): NonNullable<EditorProps[PropName]> | undefined;
3250
- /**
3251
- Query whether the view has focus.
3252
- */
3253
- hasFocus(): boolean;
3254
- /**
3255
- Focus the editor.
3256
- */
3257
- focus(): void;
3258
- /**
3259
- Get the document root in which the editor exists. This will
3260
- usually be the top-level `document`, but might be a [shadow
3261
- DOM](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Shadow_DOM)
3262
- root if the editor is inside one.
3263
- */
3264
- get root(): Document | ShadowRoot;
3265
- /**
3266
- When an existing editor view is moved to a new document or
3267
- shadow tree, call this to make it recompute its root.
3268
- */
3269
- updateRoot(): void;
3270
- /**
3271
- Given a pair of viewport coordinates, return the document
3272
- position that corresponds to them. May return null if the given
3273
- coordinates aren't inside of the editor. When an object is
3274
- returned, its `pos` property is the position nearest to the
3275
- coordinates, and its `inside` property holds the position of the
3276
- inner node that the position falls inside of, or -1 if it is at
3277
- the top level, not in any node.
3278
- */
3279
- posAtCoords(coords: {
3280
- left: number;
3281
- top: number;
3282
- }): {
3283
- pos: number;
3284
- inside: number;
3285
- } | null;
3286
- /**
3287
- Returns the viewport rectangle at a given document position.
3288
- `left` and `right` will be the same number, as this returns a
3289
- flat cursor-ish rectangle. If the position is between two things
3290
- that aren't directly adjacent, `side` determines which element
3291
- is used. When < 0, the element before the position is used,
3292
- otherwise the element after.
3293
- */
3294
- coordsAtPos(pos: number, side?: number): {
3295
- left: number;
3296
- right: number;
3297
- top: number;
3298
- bottom: number;
3299
- };
3300
- /**
3301
- Find the DOM position that corresponds to the given document
3302
- position. When `side` is negative, find the position as close as
3303
- possible to the content before the position. When positive,
3304
- prefer positions close to the content after the position. When
3305
- zero, prefer as shallow a position as possible.
3306
-
3307
- Note that you should **not** mutate the editor's internal DOM,
3308
- only inspect it (and even that is usually not necessary).
3309
- */
3310
- domAtPos(pos: number, side?: number): {
3311
- node: DOMNode;
3312
- offset: number;
3313
- };
3314
- /**
3315
- Find the DOM node that represents the document node after the
3316
- given position. May return `null` when the position doesn't point
3317
- in front of a node or if the node is inside an opaque node view.
3318
-
3319
- This is intended to be able to call things like
3320
- `getBoundingClientRect` on that DOM node. Do **not** mutate the
3321
- editor DOM directly, or add styling this way, since that will be
3322
- immediately overriden by the editor as it redraws the node.
3323
- */
3324
- nodeDOM(pos: number): DOMNode | null;
3325
- /**
3326
- Find the document position that corresponds to a given DOM
3327
- position. (Whenever possible, it is preferable to inspect the
3328
- document structure directly, rather than poking around in the
3329
- DOM, but sometimes—for example when interpreting an event
3330
- target—you don't have a choice.)
3331
-
3332
- The `bias` parameter can be used to influence which side of a DOM
3333
- node to use when the position is inside a leaf node.
3334
- */
3335
- posAtDOM(node: DOMNode, offset: number, bias?: number): number;
3336
- /**
3337
- Find out whether the selection is at the end of a textblock when
3338
- moving in a given direction. When, for example, given `"left"`,
3339
- it will return true if moving left from the current cursor
3340
- position would leave that position's parent textblock. Will apply
3341
- to the view's current state by default, but it is possible to
3342
- pass a different state.
3343
- */
3344
- endOfTextblock(dir: "up" | "down" | "left" | "right" | "forward" | "backward", state?: EditorState): boolean;
3345
- /**
3346
- Run the editor's paste logic with the given HTML string. The
3347
- `event`, if given, will be passed to the
3348
- [`handlePaste`](https://prosemirror.net/docs/ref/#view.EditorProps.handlePaste) hook.
3349
- */
3350
- pasteHTML(html: string, event?: ClipboardEvent): boolean;
3351
- /**
3352
- Run the editor's paste logic with the given plain-text input.
3353
- */
3354
- pasteText(text: string, event?: ClipboardEvent): boolean;
3355
- /**
3356
- Serialize the given slice as it would be if it was copied from
3357
- this editor. Returns a DOM element that contains a
3358
- representation of the slice as its children, a textual
3359
- representation, and the transformed slice (which can be
3360
- different from the given input due to hooks like
3361
- [`transformCopied`](https://prosemirror.net/docs/ref/#view.EditorProps.transformCopied)).
3362
- */
3363
- serializeForClipboard(slice: Slice): {
3364
- dom: HTMLElement;
3365
- text: string;
3366
- slice: Slice;
3367
- };
3368
- /**
3369
- Removes the editor from the DOM and destroys all [node
3370
- views](https://prosemirror.net/docs/ref/#view.NodeView).
3371
- */
3372
- destroy(): void;
3373
- /**
3374
- This is true when the view has been
3375
- [destroyed](https://prosemirror.net/docs/ref/#view.EditorView.destroy) (and thus should not be
3376
- used anymore).
3377
- */
3378
- get isDestroyed(): boolean;
3379
- /**
3380
- Used for testing.
3381
- */
3382
- dispatchEvent(event: Event): void;
3383
- /**
3384
- Dispatch a transaction. Will call
3385
- [`dispatchTransaction`](https://prosemirror.net/docs/ref/#view.DirectEditorProps.dispatchTransaction)
3386
- when given, and otherwise defaults to applying the transaction to
3387
- the current state and calling
3388
- [`updateState`](https://prosemirror.net/docs/ref/#view.EditorView.updateState) with the result.
3389
- This method is bound to the view instance, so that it can be
3390
- easily passed around.
3391
- */
3392
- dispatch: (tr: Transaction) => void;
3393
- }
3394
- /**
3395
- The type of function [provided](https://prosemirror.net/docs/ref/#view.EditorProps.nodeViews) to
3396
- create [node views](https://prosemirror.net/docs/ref/#view.NodeView).
3397
- */
3398
- type NodeViewConstructor = (node: Node$1, view: EditorView, getPos: () => number | undefined, decorations: readonly Decoration[], innerDecorations: DecorationSource) => NodeView;
3399
- /**
3400
- The function types [used](https://prosemirror.net/docs/ref/#view.EditorProps.markViews) to create
3401
- mark views.
3402
- */
3403
- type MarkViewConstructor = (mark: Mark, view: EditorView, inline: boolean) => MarkView;
3404
- /**
3405
- Helper type that maps event names to event object types, but
3406
- includes events that TypeScript's HTMLElementEventMap doesn't know
3407
- about.
3408
- */
3409
- interface DOMEventMap extends HTMLElementEventMap {
3410
- [event: string]: any;
3411
- }
3412
- /**
3413
- Props are configuration values that can be passed to an editor view
3414
- or included in a plugin. This interface lists the supported props.
3415
-
3416
- The various event-handling functions may all return `true` to
3417
- indicate that they handled the given event. The view will then take
3418
- care to call `preventDefault` on the event, except with
3419
- `handleDOMEvents`, where the handler itself is responsible for that.
3420
-
3421
- How a prop is resolved depends on the prop. Handler functions are
3422
- called one at a time, starting with the base props and then
3423
- searching through the plugins (in order of appearance) until one of
3424
- them returns true. For some props, the first plugin that yields a
3425
- value gets precedence.
3426
-
3427
- The optional type parameter refers to the type of `this` in prop
3428
- functions, and is used to pass in the plugin type when defining a
3429
- [plugin](https://prosemirror.net/docs/ref/#state.Plugin).
3430
- */
3431
- interface EditorProps<P = any> {
3432
- /**
3433
- Can be an object mapping DOM event type names to functions that
3434
- handle them. Such functions will be called before any handling
3435
- ProseMirror does of events fired on the editable DOM element.
3436
- Contrary to the other event handling props, when returning true
3437
- from such a function, you are responsible for calling
3438
- `preventDefault` yourself (or not, if you want to allow the
3439
- default behavior).
3440
- */
3441
- handleDOMEvents?: { [event in keyof DOMEventMap]?: (this: P, view: EditorView, event: DOMEventMap[event]) => boolean | void };
3442
- /**
3443
- Called when the editor receives a `keydown` event.
3444
- */
3445
- handleKeyDown?: (this: P, view: EditorView, event: KeyboardEvent) => boolean | void;
3446
- /**
3447
- Handler for `keypress` events.
3448
- */
3449
- handleKeyPress?: (this: P, view: EditorView, event: KeyboardEvent) => boolean | void;
3450
- /**
3451
- Whenever the user directly input text, this handler is called
3452
- before the input is applied. If it returns `true`, the default
3453
- behavior of actually inserting the text is suppressed.
3454
- */
3455
- handleTextInput?: (this: P, view: EditorView, from: number, to: number, text: string, deflt: () => Transaction) => boolean | void;
3456
- /**
3457
- Called for each node around a click, from the inside out. The
3458
- `direct` flag will be true for the inner node.
3459
- */
3460
- handleClickOn?: (this: P, view: EditorView, pos: number, node: Node$1, nodePos: number, event: MouseEvent, direct: boolean) => boolean | void;
3461
- /**
3462
- Called when the editor is clicked, after `handleClickOn` handlers
3463
- have been called.
3464
- */
3465
- handleClick?: (this: P, view: EditorView, pos: number, event: MouseEvent) => boolean | void;
3466
- /**
3467
- Called for each node around a double click.
3468
- */
3469
- handleDoubleClickOn?: (this: P, view: EditorView, pos: number, node: Node$1, nodePos: number, event: MouseEvent, direct: boolean) => boolean | void;
3470
- /**
3471
- Called when the editor is double-clicked, after `handleDoubleClickOn`.
3472
- */
3473
- handleDoubleClick?: (this: P, view: EditorView, pos: number, event: MouseEvent) => boolean | void;
3474
- /**
3475
- Called for each node around a triple click.
3476
- */
3477
- handleTripleClickOn?: (this: P, view: EditorView, pos: number, node: Node$1, nodePos: number, event: MouseEvent, direct: boolean) => boolean | void;
3478
- /**
3479
- Called when the editor is triple-clicked, after `handleTripleClickOn`.
3480
- */
3481
- handleTripleClick?: (this: P, view: EditorView, pos: number, event: MouseEvent) => boolean | void;
3482
- /**
3483
- Can be used to override the behavior of pasting. `slice` is the
3484
- pasted content parsed by the editor, but you can directly access
3485
- the event to get at the raw content.
3486
- */
3487
- handlePaste?: (this: P, view: EditorView, event: ClipboardEvent, slice: Slice) => boolean | void;
3488
- /**
3489
- Called when something is dropped on the editor. `moved` will be
3490
- true if this drop moves from the current selection (which should
3491
- thus be deleted).
3492
- */
3493
- handleDrop?: (this: P, view: EditorView, event: DragEvent, slice: Slice, moved: boolean) => boolean | void;
3494
- /**
3495
- Called when the view, after updating its state, tries to scroll
3496
- the selection into view. A handler function may return false to
3497
- indicate that it did not handle the scrolling and further
3498
- handlers or the default behavior should be tried.
3499
- */
3500
- handleScrollToSelection?: (this: P, view: EditorView) => boolean;
3501
- /**
3502
- Determines whether an in-editor drag event should copy or move
3503
- the selection. When not given, the event's `altKey` property is
3504
- used on macOS, `ctrlKey` on other platforms.
3505
- */
3506
- dragCopies?: (event: DragEvent) => boolean;
3507
- /**
3508
- Can be used to override the way a selection is created when
3509
- reading a DOM selection between the given anchor and head.
3510
- */
3511
- createSelectionBetween?: (this: P, view: EditorView, anchor: ResolvedPos, head: ResolvedPos) => Selection | null;
3512
- /**
3513
- The [parser](https://prosemirror.net/docs/ref/#model.DOMParser) to use when reading editor changes
3514
- from the DOM. Defaults to calling
3515
- [`DOMParser.fromSchema`](https://prosemirror.net/docs/ref/#model.DOMParser^fromSchema) on the
3516
- editor's schema.
3517
- */
3518
- domParser?: DOMParser;
3519
- /**
3520
- Can be used to transform pasted HTML text, _before_ it is parsed,
3521
- for example to clean it up.
3522
- */
3523
- transformPastedHTML?: (this: P, html: string, view: EditorView) => string;
3524
- /**
3525
- The [parser](https://prosemirror.net/docs/ref/#model.DOMParser) to use when reading content from
3526
- the clipboard. When not given, the value of the
3527
- [`domParser`](https://prosemirror.net/docs/ref/#view.EditorProps.domParser) prop is used.
3528
- */
3529
- clipboardParser?: DOMParser;
3530
- /**
3531
- Transform pasted plain text. The `plain` flag will be true when
3532
- the text is pasted as plain text.
3533
- */
3534
- transformPastedText?: (this: P, text: string, plain: boolean, view: EditorView) => string;
3535
- /**
3536
- A function to parse text from the clipboard into a document
3537
- slice. Called after
3538
- [`transformPastedText`](https://prosemirror.net/docs/ref/#view.EditorProps.transformPastedText).
3539
- The default behavior is to split the text into lines, wrap them
3540
- in `<p>` tags, and call
3541
- [`clipboardParser`](https://prosemirror.net/docs/ref/#view.EditorProps.clipboardParser) on it.
3542
- The `plain` flag will be true when the text is pasted as plain text.
3543
- */
3544
- clipboardTextParser?: (this: P, text: string, $context: ResolvedPos, plain: boolean, view: EditorView) => Slice;
3545
- /**
3546
- Can be used to transform pasted or dragged-and-dropped content
3547
- before it is applied to the document. The `plain` flag will be
3548
- true when the text is pasted as plain text.
3549
- */
3550
- transformPasted?: (this: P, slice: Slice, view: EditorView, plain: boolean) => Slice;
3551
- /**
3552
- Can be used to transform copied or cut content before it is
3553
- serialized to the clipboard.
3554
- */
3555
- transformCopied?: (this: P, slice: Slice, view: EditorView) => Slice;
3556
- /**
3557
- Allows you to pass custom rendering and behavior logic for
3558
- nodes. Should map node names to constructor functions that
3559
- produce a [`NodeView`](https://prosemirror.net/docs/ref/#view.NodeView) object implementing the
3560
- node's display behavior. The third argument `getPos` is a
3561
- function that can be called to get the node's current position,
3562
- which can be useful when creating transactions to update it.
3563
- Note that if the node is not in the document, the position
3564
- returned by this function will be `undefined`.
3565
-
3566
- `decorations` is an array of node or inline decorations that are
3567
- active around the node. They are automatically drawn in the
3568
- normal way, and you will usually just want to ignore this, but
3569
- they can also be used as a way to provide context information to
3570
- the node view without adding it to the document itself.
3571
-
3572
- `innerDecorations` holds the decorations for the node's content.
3573
- You can safely ignore this if your view has no content or a
3574
- `contentDOM` property, since the editor will draw the decorations
3575
- on the content. But if you, for example, want to create a nested
3576
- editor with the content, it may make sense to provide it with the
3577
- inner decorations.
3578
-
3579
- (For backwards compatibility reasons, [mark
3580
- views](https://prosemirror.net/docs/ref/#view.EditorProps.markViews) can also be included in this
3581
- object.)
3582
- */
3583
- nodeViews?: {
3584
- [node: string]: NodeViewConstructor;
3585
- };
3586
- /**
3587
- Pass custom mark rendering functions. Note that these cannot
3588
- provide the kind of dynamic behavior that [node
3589
- views](https://prosemirror.net/docs/ref/#view.NodeView) can—they just provide custom rendering
3590
- logic. The third argument indicates whether the mark's content
3591
- is inline.
3592
- */
3593
- markViews?: {
3594
- [mark: string]: MarkViewConstructor;
3595
- };
3596
- /**
3597
- The DOM serializer to use when putting content onto the
3598
- clipboard. If not given, the result of
3599
- [`DOMSerializer.fromSchema`](https://prosemirror.net/docs/ref/#model.DOMSerializer^fromSchema)
3600
- will be used. This object will only have its
3601
- [`serializeFragment`](https://prosemirror.net/docs/ref/#model.DOMSerializer.serializeFragment)
3602
- method called, and you may provide an alternative object type
3603
- implementing a compatible method.
3604
- */
3605
- clipboardSerializer?: DOMSerializer;
3606
- /**
3607
- A function that will be called to get the text for the current
3608
- selection when copying text to the clipboard. By default, the
3609
- editor will use [`textBetween`](https://prosemirror.net/docs/ref/#model.Node.textBetween) on the
3610
- selected range.
3611
- */
3612
- clipboardTextSerializer?: (this: P, content: Slice, view: EditorView) => string;
3613
- /**
3614
- A set of [document decorations](https://prosemirror.net/docs/ref/#view.Decoration) to show in the
3615
- view.
3616
- */
3617
- decorations?: (this: P, state: EditorState) => DecorationSource | null | undefined;
3618
- /**
3619
- When this returns false, the content of the view is not directly
3620
- editable.
3621
- */
3622
- editable?: (this: P, state: EditorState) => boolean;
3623
- /**
3624
- Control the DOM attributes of the editable element. May be either
3625
- an object or a function going from an editor state to an object.
3626
- By default, the element will get a class `"ProseMirror"`, and
3627
- will have its `contentEditable` attribute determined by the
3628
- [`editable` prop](https://prosemirror.net/docs/ref/#view.EditorProps.editable). Additional classes
3629
- provided here will be added to the class. For other attributes,
3630
- the value provided first (as in
3631
- [`someProp`](https://prosemirror.net/docs/ref/#view.EditorView.someProp)) will be used.
3632
- */
3633
- attributes?: {
3634
- [name: string]: string;
3635
- } | ((state: EditorState) => {
3636
- [name: string]: string;
3637
- });
3638
- /**
3639
- Determines the distance (in pixels) between the cursor and the
3640
- end of the visible viewport at which point, when scrolling the
3641
- cursor into view, scrolling takes place. Defaults to 0.
3642
- */
3643
- scrollThreshold?: number | {
3644
- top: number;
3645
- right: number;
3646
- bottom: number;
3647
- left: number;
3648
- };
3649
- /**
3650
- Determines the extra space (in pixels) that is left above or
3651
- below the cursor when it is scrolled into view. Defaults to 5.
3652
- */
3653
- scrollMargin?: number | {
3654
- top: number;
3655
- right: number;
3656
- bottom: number;
3657
- left: number;
3658
- };
3659
- }
3660
- /**
3661
- The props object given directly to the editor view supports some
3662
- fields that can't be used in plugins:
3663
- */
3664
- interface DirectEditorProps extends EditorProps {
3665
- /**
3666
- The current state of the editor.
3667
- */
3668
- state: EditorState;
3669
- /**
3670
- A set of plugins to use in the view, applying their [plugin
3671
- view](https://prosemirror.net/docs/ref/#state.PluginSpec.view) and
3672
- [props](https://prosemirror.net/docs/ref/#state.PluginSpec.props). Passing plugins with a state
3673
- component (a [state field](https://prosemirror.net/docs/ref/#state.PluginSpec.state) field or a
3674
- [transaction](https://prosemirror.net/docs/ref/#state.PluginSpec.filterTransaction) filter or
3675
- appender) will result in an error, since such plugins must be
3676
- present in the state to work.
3677
- */
3678
- plugins?: readonly Plugin$1[];
3679
- /**
3680
- The callback over which to send transactions (state updates)
3681
- produced by the view. If you specify this, you probably want to
3682
- make sure this ends up calling the view's
3683
- [`updateState`](https://prosemirror.net/docs/ref/#view.EditorView.updateState) method with a new
3684
- state that has the transaction
3685
- [applied](https://prosemirror.net/docs/ref/#state.EditorState.apply). The callback will be bound to have
3686
- the view instance as its `this` binding.
3687
- */
3688
- dispatchTransaction?: (tr: Transaction) => void;
3689
- }
3690
- //#endregion
3691
- //#region ../../node_modules/.pnpm/@tiptap+y-tiptap@3.0.8_prosemirror-model@1.25.11_prosemirror-state@1.4.4_prosemirror-vi_929d0cf90bfff81acbde9235d0a2d0eb/node_modules/@tiptap/y-tiptap/dist/src/plugins/undo-plugin.d.ts
3692
- declare function yUndoPlugin({
3693
- protectedNodes,
3694
- trackedOrigins,
3695
- undoManager
3696
- }?: {
3697
- protectedNodes?: Set<string>;
3698
- trackedOrigins?: any[];
3699
- undoManager?: any;
3700
- }): Plugin$1<{
3701
- undoManager: any;
3702
- prevSel: any;
3703
- hasUndoOps: boolean;
3704
- hasRedoOps: boolean;
3705
- }>;
3706
- //#endregion
3707
- //#region ../../node_modules/.pnpm/@tiptap+y-tiptap@3.0.8_prosemirror-model@1.25.11_prosemirror-state@1.4.4_prosemirror-vi_929d0cf90bfff81acbde9235d0a2d0eb/node_modules/@tiptap/y-tiptap/dist/src/plugins/sync-plugin.d.ts
3708
- declare function ySyncPlugin(yXmlFragment: Y.XmlFragment, {
3709
- colors,
3710
- colorMapping,
3711
- permanentUserData,
3712
- onFirstRender,
3713
- mapping
3714
- }?: YSyncOpts$1): any;
3715
- /**
3716
- * Either a node if type is YXmlElement or an Array of text nodes if YXmlText
3717
- */
3718
- type ProsemirrorMapping = Map<Y.AbstractType<any>, Node$1 | Array<Node$1>>;
3719
- type ColorDef = {
3720
- light: string;
3721
- dark: string;
3722
- };
3723
- type YSyncOpts$1 = {
3724
- colors?: Array<ColorDef>;
3725
- colorMapping?: Map<string, ColorDef>;
3726
- permanentUserData?: Y.PermanentUserData | null;
3727
- mapping?: ProsemirrorMapping;
3728
- /**
3729
- * Fired when the content from Yjs is initially rendered to ProseMirror
3730
- */
3731
- onFirstRender?: Function;
3732
- };
3733
- //#endregion
3734
- //#region ../../node_modules/.pnpm/@tiptap+extension-collaboration@3.29.2_@tiptap+core@3.29.2_@tiptap+pm@3.29.2__@tiptap+p_894d099a4ad840a9519abb2f14438fb9/node_modules/@tiptap/extension-collaboration/dist/index.d.ts
3735
- type YSyncOpts = Parameters<typeof ySyncPlugin>[1];
3736
- type YUndoOpts = Parameters<typeof yUndoPlugin>[0];
3737
- interface CollaborationStorage {
3738
- /**
3739
- * Whether collaboration is currently disabled.
3740
- * Disabling collaboration will prevent any changes from being synced with other users.
3741
- */
3742
- isDisabled: boolean;
3743
- }
3744
- declare module '@tiptap/core' {
3745
- interface Commands<ReturnType> {
3746
- collaboration: {
3747
- /**
3748
- * Undo recent changes
3749
- * @example editor.commands.undo()
3750
- */
3751
- undo: () => ReturnType;
3752
- /**
3753
- * Reapply reverted changes
3754
- * @example editor.commands.redo()
3755
- */
3756
- redo: () => ReturnType;
3757
- };
3758
- }
3759
- interface Storage {
3760
- collaboration: CollaborationStorage;
3761
- }
3762
- }
3763
- interface CollaborationOptions {
3764
- /**
3765
- * An initialized Y.js document.
3766
- * @example new Y.Doc()
3767
- */
3768
- document?: Doc | null;
3769
- /**
3770
- * Name of a Y.js fragment, can be changed to sync multiple fields with one Y.js document.
3771
- * @default 'default'
3772
- * @example 'my-custom-field'
3773
- */
3774
- field?: string;
3775
- /**
3776
- * A raw Y.js fragment, can be used instead of `document` and `field`.
3777
- * @example new Y.Doc().getXmlFragment('body')
3778
- */
3779
- fragment?: XmlFragment | null;
3780
- /**
3781
- * The collaboration provider.
3782
- * @default null
3783
- */
3784
- provider?: any | null;
3785
- /**
3786
- * Fired when the content from Yjs is initially rendered to Tiptap.
3787
- */
3788
- onFirstRender?: () => void;
3789
- /**
3790
- * Options for the Yjs sync plugin.
3791
- */
3792
- ySyncOptions?: YSyncOpts;
3793
- /**
3794
- * Options for the Yjs undo plugin.
3795
- */
3796
- yUndoOptions?: YUndoOpts;
3797
- }
3798
- /**
3799
- * This extension allows you to collaborate with others in real-time.
3800
- * @see https://tiptap.dev/api/extensions/collaboration
1
+ import { E as RealtimeUser, O as RealtimeWorkspaceChange, S as RealtimeResetReason, T as RealtimeSaved, _ as RealtimePerson, c as RealtimeDocumentStatus, l as RealtimeEditor, r as RealtimeCheckpoint, v as RealtimeReadOnlyReason, x as RealtimeRequestErrorCode } from "./types-Bw6-42Se.js";
2
+ import { i as readRealtimeYDoc } from "./document-CtY6umWY.js";
3
+ import { Awareness } from "y-protocols/awareness";
4
+ import { WebsocketProvider } from "y-websocket";
5
+ import * as Y from "yjs";
6
+ import { Result } from "@vite-hub/runtime";
7
+ import { AnyExtension, Extension } from "@tiptap/core";
8
+ import { MaybeRefOrGetter, Ref } from "vue";
9
+ import { DecorationAttrs } from "@tiptap/pm/view";
10
+ //#region src/caret.d.ts
11
+ /** A remote person as the caret sees them: the presence identity from awareness. */
12
+ interface RealtimeCaretUser {
13
+ color: string;
14
+ name: string;
15
+ [key: string]: unknown;
16
+ }
17
+ interface RealtimeCaretOptions {
18
+ awareness: Awareness | null;
19
+ /** Builds a remote caret. Defaults to TipTap's `collaboration-carets__caret` and `collaboration-carets__label`. */
20
+ render: (user: RealtimeCaretUser) => HTMLElement;
21
+ /** Decoration attributes for a remote selection. Defaults to `ProseMirror-yjs-selection` in the person's color. */
22
+ selectionRender: (user: RealtimeCaretUser) => DecorationAttrs;
23
+ }
24
+ /**
25
+ * Other people's carets and selections, drawn from the room's awareness. It renders what TipTap's CollaborationCaret
26
+ * renders, under the same extension name, but it uses Realtime's bundled y-tiptap: CollaborationCaret installed next to
27
+ * Realtime has its own copy, cannot find Realtime's sync plugin, and draws nothing. Presence identity stays Realtime's.
3801
28
  */
29
+ export declare const RealtimeCaret: Extension<RealtimeCaretOptions, any>;
3802
30
  //#endregion
3803
31
  //#region src/vue.d.ts
3804
- type RealtimeStatus = "connected" | "connecting" | "disconnected";
3805
- interface UseRealtimeTiptapOptions {
32
+ export type RealtimeStatus = "connected" | "connecting" | "disconnected";
33
+ export interface RealtimeResetEvent {
34
+ /** Room seed the client reconnects to. */
35
+ epoch: string;
36
+ /** The document this client held before the reset, including edits the room did not save. Destroyed after listeners return. */
37
+ previous: Y.Doc;
38
+ /** `source-changed`: the stored document changed outside the room. `stale`: the room was re-seeded while this client was away. */
39
+ reason: RealtimeResetReason;
40
+ }
41
+ export interface UseRealtimeTiptapOptions {
42
+ /** Editor schema shared with the definition's `editor`. Defaults to the built-in Markdown kit. */
43
+ editor?: Pick<RealtimeEditor, "extensions">;
3806
44
  enabled?: MaybeRefOrGetter<boolean>;
45
+ /** Presence identity. Defaults to the ViteHub Auth session; pass `null` for an anonymous guest. */
46
+ identity?: MaybeRefOrGetter<RealtimeUser | null | undefined>;
47
+ /**
48
+ * Other people's carets and selections, in their presence color. Defaults to `true`. They use TipTap's
49
+ * CollaborationCaret classes (`collaboration-carets__caret`, `collaboration-carets__label`, `ProseMirror-yjs-selection`).
50
+ * Pass `{ render, selectionRender }` to change the markup, or `false` to leave the carets out.
51
+ */
52
+ carets?: boolean | Partial<Pick<RealtimeCaretOptions, "render" | "selectionRender">>;
53
+ onReset?: (event: RealtimeResetEvent) => void;
3807
54
  }
3808
- declare function useRealtimeTiptap(definition: string, documentId: MaybeRefOrGetter<string | undefined>, options?: UseRealtimeTiptapOptions): {
55
+ export declare function useRealtimeTiptap(definition: string, documentId: MaybeRefOrGetter<string | undefined>, options?: UseRealtimeTiptapOptions): {
3809
56
  document: import("vue").ShallowRef<Y.Doc | undefined, Y.Doc | undefined>;
3810
- extensions: import("vue").ComputedRef<(import("@tiptap/core").Extension<import("@tiptap/starter-kit").StarterKitOptions, any> | import("@tiptap/core").Node<any, any> | import("@tiptap/core").Node<import("@tiptap/extension-image").ImageOptions, any> | import("@tiptap/core").Extension<import("@tiptap/extension-table").TableKitOptions, any> | import("@tiptap/core").Extension<import("@tiptap/markdown").MarkdownExtensionOptions, import("@tiptap/markdown").MarkdownExtensionStorage> | import("vue").Raw<import("@tiptap/core").Extension<CollaborationOptions, CollaborationStorage>>)[]>;
57
+ extensions: import("vue").ComputedRef<AnyExtension[]>;
58
+ fields: import("vue").ComputedRef<Y.Map<unknown> | undefined>;
3811
59
  people: import("vue").ShallowRef<RealtimePerson[], RealtimePerson[]>;
3812
60
  provider: import("vue").ShallowRef<WebsocketProvider | undefined, WebsocketProvider | undefined>;
3813
- status: import("vue").Ref<RealtimeStatus, RealtimeStatus>;
3814
- synced: import("vue").Ref<boolean, boolean>;
61
+ /** The server rejects edits from this connection. `readOnlyReason` tells why; `saveStatus` holds the details. */
62
+ readOnly: import("vue").ComputedRef<boolean>;
63
+ readOnlyReason: Ref<RealtimeReadOnlyReason | null, RealtimeReadOnlyReason | null>;
64
+ refresh: () => Promise<Result<{
65
+ digest: string | null;
66
+ reseeded: boolean;
67
+ }, RealtimeRequestErrorCode>>;
68
+ onReset: (listener: (event: RealtimeResetEvent) => void) => () => void;
69
+ save: () => Promise<Result<RealtimeSaved, RealtimeRequestErrorCode>>;
70
+ saveStatus: import("vue").ShallowRef<RealtimeDocumentStatus | undefined, RealtimeDocumentStatus | undefined>;
71
+ saving: import("vue").ComputedRef<boolean>;
72
+ status: Ref<RealtimeStatus, RealtimeStatus>;
73
+ synced: Ref<boolean, boolean>;
3815
74
  history: {
3816
- checkpoint: () => Promise<RealtimeCheckpoint>;
75
+ checkpoint: () => Promise<Result<RealtimeCheckpoint, RealtimeRequestErrorCode>>;
3817
76
  pending: import("vue").ComputedRef<boolean>;
3818
77
  };
3819
78
  workspace: {
@@ -3823,4 +82,4 @@ declare function useRealtimeTiptap(definition: string, documentId: MaybeRefOrGet
3823
82
  destroy: () => void;
3824
83
  };
3825
84
  //#endregion
3826
- export { RealtimeStatus, UseRealtimeTiptapOptions, useRealtimeTiptap };
85
+ export { type RealtimeCaretOptions, type RealtimeCaretUser, type RealtimeRequestErrorCode, readRealtimeYDoc };