@docen/extensions 0.2.2 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1686 @@
1
+ import { Document as Document$1 } from "@tiptap/extension-document";
2
+ import { Text } from "@tiptap/extension-text";
3
+ import { Paragraph } from "@tiptap/extension-paragraph";
4
+ import { Heading } from "@tiptap/extension-heading";
5
+ import { Blockquote } from "@tiptap/extension-blockquote";
6
+ import { HorizontalRule } from "@tiptap/extension-horizontal-rule";
7
+ import { CodeBlockLowlight } from "@tiptap/extension-code-block-lowlight";
8
+ import { BulletList } from "@tiptap/extension-bullet-list";
9
+ import { OrderedList } from "@tiptap/extension-ordered-list";
10
+ import { ListItem } from "@tiptap/extension-list-item";
11
+ import { TaskList } from "@tiptap/extension-task-list";
12
+ import { TaskItem } from "@tiptap/extension-task-item";
13
+ import { Table, TableCell, TableHeader, TableRow } from "@tiptap/extension-table";
14
+ import { Image } from "@tiptap/extension-image";
15
+ import { HardBreak } from "@tiptap/extension-hard-break";
16
+ import { Details, DetailsContent, DetailsSummary } from "@tiptap/extension-details";
17
+ import { Emoji } from "@tiptap/extension-emoji";
18
+ import { Mention } from "@tiptap/extension-mention";
19
+ import { Mathematics } from "@tiptap/extension-mathematics";
20
+ import { Bold } from "@tiptap/extension-bold";
21
+ import { Italic } from "@tiptap/extension-italic";
22
+ import { Underline } from "@tiptap/extension-underline";
23
+ import { Strike } from "@tiptap/extension-strike";
24
+ import { Code } from "@tiptap/extension-code";
25
+ import { Link } from "@tiptap/extension-link";
26
+ import { Highlight } from "@tiptap/extension-highlight";
27
+ import { Subscript } from "@tiptap/extension-subscript";
28
+ import { Superscript } from "@tiptap/extension-superscript";
29
+ import { BackgroundColor, Color, FontFamily, FontSize, LineHeight, TextStyle } from "@tiptap/extension-text-style";
30
+ import { TextAlign } from "@tiptap/extension-text-align";
31
+ import { Extension, ParentConfig } from "@tiptap/core";
32
+ import { ListKeymap } from "@tiptap/extension-list";
33
+
34
+ //#region ../../node_modules/.pnpm/orderedmap@2.1.1/node_modules/orderedmap/dist/index.d.ts
35
+ declare class OrderedMap<T = any> {
36
+ private constructor(content: Array<string | T>);
37
+ get(key: string): T | undefined;
38
+ update(key: string, value: T, newKey?: string): OrderedMap<T>;
39
+ remove(key: string): OrderedMap<T>;
40
+ addToStart(key: string, value: T): OrderedMap<T>;
41
+ addToEnd(key: string, value: T): OrderedMap<T>;
42
+ addBefore(place: string, key: string, value: T): OrderedMap<T>;
43
+ forEach(fn: (key: string, value: T) => any): void;
44
+ prepend(map: MapLike<T>): OrderedMap<T>;
45
+ append(map: MapLike<T>): OrderedMap<T>;
46
+ subtract(map: MapLike<T>): OrderedMap<T>;
47
+ toObject(): Record<string, T>;
48
+ readonly size: number;
49
+ static from<T>(map: MapLike<T>): OrderedMap<T>;
50
+ }
51
+ type MapLike<T = any> = Record<string, T> | OrderedMap<T>;
52
+ //#endregion
53
+ //#region ../../node_modules/.pnpm/prosemirror-model@1.25.4/node_modules/prosemirror-model/dist/index.d.ts
54
+ /**
55
+ A mark is a piece of information that can be attached to a node,
56
+ such as it being emphasized, in code font, or a link. It has a
57
+ type and optionally a set of attributes that provide further
58
+ information (such as the target of the link). Marks are created
59
+ through a `Schema`, which controls which types exist and which
60
+ attributes they have.
61
+ */
62
+ declare class Mark {
63
+ /**
64
+ The type of this mark.
65
+ */
66
+ readonly type: MarkType;
67
+ /**
68
+ The attributes associated with this mark.
69
+ */
70
+ readonly attrs: Attrs;
71
+ /**
72
+ Given a set of marks, create a new set which contains this one as
73
+ well, in the right position. If this mark is already in the set,
74
+ the set itself is returned. If any marks that are set to be
75
+ [exclusive](https://prosemirror.net/docs/ref/#model.MarkSpec.excludes) with this mark are present,
76
+ those are replaced by this one.
77
+ */
78
+ addToSet(set: readonly Mark[]): readonly Mark[];
79
+ /**
80
+ Remove this mark from the given set, returning a new set. If this
81
+ mark is not in the set, the set itself is returned.
82
+ */
83
+ removeFromSet(set: readonly Mark[]): readonly Mark[];
84
+ /**
85
+ Test whether this mark is in the given set of marks.
86
+ */
87
+ isInSet(set: readonly Mark[]): boolean;
88
+ /**
89
+ Test whether this mark has the same type and attributes as
90
+ another mark.
91
+ */
92
+ eq(other: Mark): boolean;
93
+ /**
94
+ Convert this mark to a JSON-serializeable representation.
95
+ */
96
+ toJSON(): any;
97
+ /**
98
+ Deserialize a mark from JSON.
99
+ */
100
+ static fromJSON(schema: Schema, json: any): Mark;
101
+ /**
102
+ Test whether two sets of marks are identical.
103
+ */
104
+ static sameSet(a: readonly Mark[], b: readonly Mark[]): boolean;
105
+ /**
106
+ Create a properly sorted mark set from null, a single mark, or an
107
+ unsorted array of marks.
108
+ */
109
+ static setFrom(marks?: Mark | readonly Mark[] | null): readonly Mark[];
110
+ /**
111
+ The empty set of marks.
112
+ */
113
+ static none: readonly Mark[];
114
+ }
115
+ type DOMNode = InstanceType<typeof window.Node>;
116
+ /**
117
+ A description of a DOM structure. Can be either a string, which is
118
+ interpreted as a text node, a DOM node, which is interpreted as
119
+ itself, a `{dom, contentDOM}` object, or an array.
120
+
121
+ An array describes a DOM element. The first value in the array
122
+ should be a string—the name of the DOM element, optionally prefixed
123
+ by a namespace URL and a space. If the second element is plain
124
+ object, it is interpreted as a set of attributes for the element.
125
+ Any elements after that (including the 2nd if it's not an attribute
126
+ object) are interpreted as children of the DOM elements, and must
127
+ either be valid `DOMOutputSpec` values, or the number zero.
128
+
129
+ The number zero (pronounced “hole”) is used to indicate the place
130
+ where a node's child nodes should be inserted. If it occurs in an
131
+ output spec, it should be the only child element in its parent
132
+ node.
133
+ */
134
+ type DOMOutputSpec = string | DOMNode | {
135
+ dom: DOMNode;
136
+ contentDOM?: HTMLElement;
137
+ } | readonly [string, ...any[]];
138
+ /**
139
+ A DOM serializer knows how to convert ProseMirror nodes and
140
+ marks of various types to DOM nodes.
141
+ */
142
+ /**
143
+ You can [_resolve_](https://prosemirror.net/docs/ref/#model.Node.resolve) a position to get more
144
+ information about it. Objects of this class represent such a
145
+ resolved position, providing various pieces of context
146
+ information, and some helper methods.
147
+
148
+ Throughout this interface, methods that take an optional `depth`
149
+ parameter will interpret undefined as `this.depth` and negative
150
+ numbers as `this.depth + value`.
151
+ */
152
+ declare class ResolvedPos {
153
+ /**
154
+ The position that was resolved.
155
+ */
156
+ readonly pos: number;
157
+ /**
158
+ The offset this position has into its parent node.
159
+ */
160
+ readonly parentOffset: number;
161
+ /**
162
+ The number of levels the parent node is from the root. If this
163
+ position points directly into the root node, it is 0. If it
164
+ points into a top-level paragraph, 1, and so on.
165
+ */
166
+ depth: number;
167
+ /**
168
+ The parent node that the position points into. Note that even if
169
+ a position points into a text node, that node is not considered
170
+ the parent—text nodes are ‘flat’ in this model, and have no content.
171
+ */
172
+ get parent(): Node;
173
+ /**
174
+ The root node in which the position was resolved.
175
+ */
176
+ get doc(): Node;
177
+ /**
178
+ The ancestor node at the given level. `p.node(p.depth)` is the
179
+ same as `p.parent`.
180
+ */
181
+ node(depth?: number | null): Node;
182
+ /**
183
+ The index into the ancestor at the given level. If this points
184
+ at the 3rd node in the 2nd paragraph on the top level, for
185
+ example, `p.index(0)` is 1 and `p.index(1)` is 2.
186
+ */
187
+ index(depth?: number | null): number;
188
+ /**
189
+ The index pointing after this position into the ancestor at the
190
+ given level.
191
+ */
192
+ indexAfter(depth?: number | null): number;
193
+ /**
194
+ The (absolute) position at the start of the node at the given
195
+ level.
196
+ */
197
+ start(depth?: number | null): number;
198
+ /**
199
+ The (absolute) position at the end of the node at the given
200
+ level.
201
+ */
202
+ end(depth?: number | null): number;
203
+ /**
204
+ The (absolute) position directly before the wrapping node at the
205
+ given level, or, when `depth` is `this.depth + 1`, the original
206
+ position.
207
+ */
208
+ before(depth?: number | null): number;
209
+ /**
210
+ The (absolute) position directly after the wrapping node at the
211
+ given level, or the original position when `depth` is `this.depth + 1`.
212
+ */
213
+ after(depth?: number | null): number;
214
+ /**
215
+ When this position points into a text node, this returns the
216
+ distance between the position and the start of the text node.
217
+ Will be zero for positions that point between nodes.
218
+ */
219
+ get textOffset(): number;
220
+ /**
221
+ Get the node directly after the position, if any. If the position
222
+ points into a text node, only the part of that node after the
223
+ position is returned.
224
+ */
225
+ get nodeAfter(): Node | null;
226
+ /**
227
+ Get the node directly before the position, if any. If the
228
+ position points into a text node, only the part of that node
229
+ before the position is returned.
230
+ */
231
+ get nodeBefore(): Node | null;
232
+ /**
233
+ Get the position at the given index in the parent node at the
234
+ given depth (which defaults to `this.depth`).
235
+ */
236
+ posAtIndex(index: number, depth?: number | null): number;
237
+ /**
238
+ Get the marks at this position, factoring in the surrounding
239
+ marks' [`inclusive`](https://prosemirror.net/docs/ref/#model.MarkSpec.inclusive) property. If the
240
+ position is at the start of a non-empty node, the marks of the
241
+ node after it (if any) are returned.
242
+ */
243
+ marks(): readonly Mark[];
244
+ /**
245
+ Get the marks after the current position, if any, except those
246
+ that are non-inclusive and not present at position `$end`. This
247
+ is mostly useful for getting the set of marks to preserve after a
248
+ deletion. Will return `null` if this position is at the end of
249
+ its parent node or its parent node isn't a textblock (in which
250
+ case no marks should be preserved).
251
+ */
252
+ marksAcross($end: ResolvedPos): readonly Mark[] | null;
253
+ /**
254
+ The depth up to which this position and the given (non-resolved)
255
+ position share the same parent nodes.
256
+ */
257
+ sharedDepth(pos: number): number;
258
+ /**
259
+ Returns a range based on the place where this position and the
260
+ given position diverge around block content. If both point into
261
+ the same textblock, for example, a range around that textblock
262
+ will be returned. If they point into different blocks, the range
263
+ around those blocks in their shared ancestor is returned. You can
264
+ pass in an optional predicate that will be called with a parent
265
+ node to see if a range into that parent is acceptable.
266
+ */
267
+ blockRange(other?: ResolvedPos, pred?: (node: Node) => boolean): NodeRange | null;
268
+ /**
269
+ Query whether the given position shares the same parent node.
270
+ */
271
+ sameParent(other: ResolvedPos): boolean;
272
+ /**
273
+ Return the greater of this and the given position.
274
+ */
275
+ max(other: ResolvedPos): ResolvedPos;
276
+ /**
277
+ Return the smaller of this and the given position.
278
+ */
279
+ min(other: ResolvedPos): ResolvedPos;
280
+ }
281
+ /**
282
+ Represents a flat range of content, i.e. one that starts and
283
+ ends in the same node.
284
+ */
285
+ declare class NodeRange {
286
+ /**
287
+ A resolved position along the start of the content. May have a
288
+ `depth` greater than this object's `depth` property, since
289
+ these are the positions that were used to compute the range,
290
+ not re-resolved positions directly at its boundaries.
291
+ */
292
+ readonly $from: ResolvedPos;
293
+ /**
294
+ A position along the end of the content. See
295
+ caveat for [`$from`](https://prosemirror.net/docs/ref/#model.NodeRange.$from).
296
+ */
297
+ readonly $to: ResolvedPos;
298
+ /**
299
+ The depth of the node that this range points into.
300
+ */
301
+ readonly depth: number;
302
+ /**
303
+ Construct a node range. `$from` and `$to` should point into the
304
+ same node until at least the given `depth`, since a node range
305
+ denotes an adjacent set of nodes in a single parent node.
306
+ */
307
+ constructor(
308
+ /**
309
+ A resolved position along the start of the content. May have a
310
+ `depth` greater than this object's `depth` property, since
311
+ these are the positions that were used to compute the range,
312
+ not re-resolved positions directly at its boundaries.
313
+ */
314
+ $from: ResolvedPos,
315
+ /**
316
+ A position along the end of the content. See
317
+ caveat for [`$from`](https://prosemirror.net/docs/ref/#model.NodeRange.$from).
318
+ */
319
+ $to: ResolvedPos,
320
+ /**
321
+ The depth of the node that this range points into.
322
+ */
323
+ depth: number);
324
+ /**
325
+ The position at the start of the range.
326
+ */
327
+ get start(): number;
328
+ /**
329
+ The position at the end of the range.
330
+ */
331
+ get end(): number;
332
+ /**
333
+ The parent node that the range points into.
334
+ */
335
+ get parent(): Node;
336
+ /**
337
+ The start index of the range in the parent node.
338
+ */
339
+ get startIndex(): number;
340
+ /**
341
+ The end index of the range in the parent node.
342
+ */
343
+ get endIndex(): number;
344
+ }
345
+ /**
346
+ Error type raised by [`Node.replace`](https://prosemirror.net/docs/ref/#model.Node.replace) when
347
+ given an invalid replacement.
348
+ */
349
+ /**
350
+ A slice represents a piece cut out of a larger document. It
351
+ stores not only a fragment, but also the depth up to which nodes on
352
+ both side are ‘open’ (cut through).
353
+ */
354
+ declare class Slice {
355
+ /**
356
+ The slice's content.
357
+ */
358
+ readonly content: Fragment;
359
+ /**
360
+ The open depth at the start of the fragment.
361
+ */
362
+ readonly openStart: number;
363
+ /**
364
+ The open depth at the end.
365
+ */
366
+ readonly openEnd: number;
367
+ /**
368
+ Create a slice. When specifying a non-zero open depth, you must
369
+ make sure that there are nodes of at least that depth at the
370
+ appropriate side of the fragment—i.e. if the fragment is an
371
+ empty paragraph node, `openStart` and `openEnd` can't be greater
372
+ than 1.
373
+
374
+ It is not necessary for the content of open nodes to conform to
375
+ the schema's content constraints, though it should be a valid
376
+ start/end/middle for such a node, depending on which sides are
377
+ open.
378
+ */
379
+ constructor(
380
+ /**
381
+ The slice's content.
382
+ */
383
+ content: Fragment,
384
+ /**
385
+ The open depth at the start of the fragment.
386
+ */
387
+ openStart: number,
388
+ /**
389
+ The open depth at the end.
390
+ */
391
+ openEnd: number);
392
+ /**
393
+ The size this slice would add when inserted into a document.
394
+ */
395
+ get size(): number;
396
+ /**
397
+ Tests whether this slice is equal to another slice.
398
+ */
399
+ eq(other: Slice): boolean;
400
+ /**
401
+ Convert a slice to a JSON-serializable representation.
402
+ */
403
+ toJSON(): any;
404
+ /**
405
+ Deserialize a slice from its JSON representation.
406
+ */
407
+ static fromJSON(schema: Schema, json: any): Slice;
408
+ /**
409
+ Create a slice from a fragment by taking the maximum possible
410
+ open value on both side of the fragment.
411
+ */
412
+ static maxOpen(fragment: Fragment, openIsolating?: boolean): Slice;
413
+ /**
414
+ The empty slice.
415
+ */
416
+ static empty: Slice;
417
+ }
418
+ /**
419
+ These are the options recognized by the
420
+ [`parse`](https://prosemirror.net/docs/ref/#model.DOMParser.parse) and
421
+ [`parseSlice`](https://prosemirror.net/docs/ref/#model.DOMParser.parseSlice) methods.
422
+ */
423
+ /**
424
+ Fields that may be present in both [tag](https://prosemirror.net/docs/ref/#model.TagParseRule) and
425
+ [style](https://prosemirror.net/docs/ref/#model.StyleParseRule) parse rules.
426
+ */
427
+ interface GenericParseRule {
428
+ /**
429
+ Can be used to change the order in which the parse rules in a
430
+ schema are tried. Those with higher priority come first. Rules
431
+ without a priority are counted as having priority 50. This
432
+ property is only meaningful in a schema—when directly
433
+ constructing a parser, the order of the rule array is used.
434
+ */
435
+ priority?: number;
436
+ /**
437
+ By default, when a rule matches an element or style, no further
438
+ rules get a chance to match it. By setting this to `false`, you
439
+ indicate that even when this rule matches, other rules that come
440
+ after it should also run.
441
+ */
442
+ consuming?: boolean;
443
+ /**
444
+ When given, restricts this rule to only match when the current
445
+ context—the parent nodes into which the content is being
446
+ parsed—matches this expression. Should contain one or more node
447
+ names or node group names followed by single or double slashes.
448
+ For example `"paragraph/"` means the rule only matches when the
449
+ parent node is a paragraph, `"blockquote/paragraph/"` restricts
450
+ it to be in a paragraph that is inside a blockquote, and
451
+ `"section//"` matches any position inside a section—a double
452
+ slash matches any sequence of ancestor nodes. To allow multiple
453
+ different contexts, they can be separated by a pipe (`|`)
454
+ character, as in `"blockquote/|list_item/"`.
455
+ */
456
+ context?: string;
457
+ /**
458
+ The name of the mark type to wrap the matched content in.
459
+ */
460
+ mark?: string;
461
+ /**
462
+ When true, ignore content that matches this rule.
463
+ */
464
+ ignore?: boolean;
465
+ /**
466
+ When true, finding an element that matches this rule will close
467
+ the current node.
468
+ */
469
+ closeParent?: boolean;
470
+ /**
471
+ When true, ignore the node that matches this rule, but do parse
472
+ its content.
473
+ */
474
+ skip?: boolean;
475
+ /**
476
+ Attributes for the node or mark created by this rule. When
477
+ `getAttrs` is provided, it takes precedence.
478
+ */
479
+ attrs?: Attrs;
480
+ }
481
+ /**
482
+ Parse rule targeting a DOM element.
483
+ */
484
+ interface TagParseRule extends GenericParseRule {
485
+ /**
486
+ A CSS selector describing the kind of DOM elements to match.
487
+ */
488
+ tag: string;
489
+ /**
490
+ The namespace to match. Nodes are only matched when the
491
+ namespace matches or this property is null.
492
+ */
493
+ namespace?: string;
494
+ /**
495
+ The name of the node type to create when this rule matches. Each
496
+ rule should have either a `node`, `mark`, or `ignore` property
497
+ (except when it appears in a [node](https://prosemirror.net/docs/ref/#model.NodeSpec.parseDOM) or
498
+ [mark spec](https://prosemirror.net/docs/ref/#model.MarkSpec.parseDOM), in which case the `node`
499
+ or `mark` property will be derived from its position).
500
+ */
501
+ node?: string;
502
+ /**
503
+ A function used to compute the attributes for the node or mark
504
+ created by this rule. Can also be used to describe further
505
+ conditions the DOM element or style must match. When it returns
506
+ `false`, the rule won't match. When it returns null or undefined,
507
+ that is interpreted as an empty/default set of attributes.
508
+ */
509
+ getAttrs?: (node: HTMLElement) => Attrs | false | null;
510
+ /**
511
+ For rules that produce non-leaf nodes, by default the content of
512
+ the DOM element is parsed as content of the node. If the child
513
+ nodes are in a descendent node, this may be a CSS selector
514
+ string that the parser must use to find the actual content
515
+ element, or a function that returns the actual content element
516
+ to the parser.
517
+ */
518
+ contentElement?: string | HTMLElement | ((node: HTMLElement) => HTMLElement);
519
+ /**
520
+ Can be used to override the content of a matched node. When
521
+ present, instead of parsing the node's child nodes, the result of
522
+ this function is used.
523
+ */
524
+ getContent?: (node: DOMNode, schema: Schema) => Fragment;
525
+ /**
526
+ Controls whether whitespace should be preserved when parsing the
527
+ content inside the matched element. `false` means whitespace may
528
+ be collapsed, `true` means that whitespace should be preserved
529
+ but newlines normalized to spaces, and `"full"` means that
530
+ newlines should also be preserved.
531
+ */
532
+ preserveWhitespace?: boolean | "full";
533
+ }
534
+ /**
535
+ A parse rule targeting a style property.
536
+ */
537
+ interface StyleParseRule extends GenericParseRule {
538
+ /**
539
+ A CSS property name to match. This rule will match inline styles
540
+ that list that property. May also have the form
541
+ `"property=value"`, in which case the rule only matches if the
542
+ property's value exactly matches the given value. (For more
543
+ complicated filters, use [`getAttrs`](https://prosemirror.net/docs/ref/#model.StyleParseRule.getAttrs)
544
+ and return false to indicate that the match failed.) Rules
545
+ matching styles may only produce [marks](https://prosemirror.net/docs/ref/#model.GenericParseRule.mark),
546
+ not nodes.
547
+ */
548
+ style: string;
549
+ /**
550
+ Given to make TS see ParseRule as a tagged union @hide
551
+ */
552
+ tag?: undefined;
553
+ /**
554
+ Style rules can remove marks from the set of active marks.
555
+ */
556
+ clearMark?: (mark: Mark) => boolean;
557
+ /**
558
+ A function used to compute the attributes for the node or mark
559
+ created by this rule. Called with the style's value.
560
+ */
561
+ getAttrs?: (node: string) => Attrs | false | null;
562
+ }
563
+ /**
564
+ A value that describes how to parse a given DOM node or inline
565
+ style as a ProseMirror node or mark.
566
+ */
567
+ type ParseRule = TagParseRule | StyleParseRule;
568
+ /**
569
+ A DOM parser represents a strategy for parsing DOM content into a
570
+ ProseMirror document conforming to a given schema. Its behavior is
571
+ defined by an array of [rules](https://prosemirror.net/docs/ref/#model.ParseRule).
572
+ */
573
+ /**
574
+ An object holding the attributes of a node.
575
+ */
576
+ type Attrs = {
577
+ readonly [attr: string]: any;
578
+ };
579
+ /**
580
+ Node types are objects allocated once per `Schema` and used to
581
+ [tag](https://prosemirror.net/docs/ref/#model.Node.type) `Node` instances. They contain information
582
+ about the node type, such as its name and what kind of node it
583
+ represents.
584
+ */
585
+ declare class NodeType {
586
+ /**
587
+ The name the node type has in this schema.
588
+ */
589
+ readonly name: string;
590
+ /**
591
+ A link back to the `Schema` the node type belongs to.
592
+ */
593
+ readonly schema: Schema;
594
+ /**
595
+ The spec that this type is based on
596
+ */
597
+ readonly spec: NodeSpec;
598
+ /**
599
+ True if this node type has inline content.
600
+ */
601
+ inlineContent: boolean;
602
+ /**
603
+ True if this is a block type
604
+ */
605
+ isBlock: boolean;
606
+ /**
607
+ True if this is the text node type.
608
+ */
609
+ isText: boolean;
610
+ /**
611
+ True if this is an inline type.
612
+ */
613
+ get isInline(): boolean;
614
+ /**
615
+ True if this is a textblock type, a block that contains inline
616
+ content.
617
+ */
618
+ get isTextblock(): boolean;
619
+ /**
620
+ True for node types that allow no content.
621
+ */
622
+ get isLeaf(): boolean;
623
+ /**
624
+ True when this node is an atom, i.e. when it does not have
625
+ directly editable content.
626
+ */
627
+ get isAtom(): boolean;
628
+ /**
629
+ Return true when this node type is part of the given
630
+ [group](https://prosemirror.net/docs/ref/#model.NodeSpec.group).
631
+ */
632
+ isInGroup(group: string): boolean;
633
+ /**
634
+ The starting match of the node type's content expression.
635
+ */
636
+ contentMatch: ContentMatch;
637
+ /**
638
+ The set of marks allowed in this node. `null` means all marks
639
+ are allowed.
640
+ */
641
+ markSet: readonly MarkType[] | null;
642
+ /**
643
+ The node type's [whitespace](https://prosemirror.net/docs/ref/#model.NodeSpec.whitespace) option.
644
+ */
645
+ get whitespace(): "pre" | "normal";
646
+ /**
647
+ Tells you whether this node type has any required attributes.
648
+ */
649
+ hasRequiredAttrs(): boolean;
650
+ /**
651
+ Indicates whether this node allows some of the same content as
652
+ the given node type.
653
+ */
654
+ compatibleContent(other: NodeType): boolean;
655
+ /**
656
+ Create a `Node` of this type. The given attributes are
657
+ checked and defaulted (you can pass `null` to use the type's
658
+ defaults entirely, if no required attributes exist). `content`
659
+ may be a `Fragment`, a node, an array of nodes, or
660
+ `null`. Similarly `marks` may be `null` to default to the empty
661
+ set of marks.
662
+ */
663
+ create(attrs?: Attrs | null, content?: Fragment | Node | readonly Node[] | null, marks?: readonly Mark[]): Node;
664
+ /**
665
+ Like [`create`](https://prosemirror.net/docs/ref/#model.NodeType.create), but check the given content
666
+ against the node type's content restrictions, and throw an error
667
+ if it doesn't match.
668
+ */
669
+ createChecked(attrs?: Attrs | null, content?: Fragment | Node | readonly Node[] | null, marks?: readonly Mark[]): Node;
670
+ /**
671
+ Like [`create`](https://prosemirror.net/docs/ref/#model.NodeType.create), but see if it is
672
+ necessary to add nodes to the start or end of the given fragment
673
+ to make it fit the node. If no fitting wrapping can be found,
674
+ return null. Note that, due to the fact that required nodes can
675
+ always be created, this will always succeed if you pass null or
676
+ `Fragment.empty` as content.
677
+ */
678
+ createAndFill(attrs?: Attrs | null, content?: Fragment | Node | readonly Node[] | null, marks?: readonly Mark[]): Node | null;
679
+ /**
680
+ Returns true if the given fragment is valid content for this node
681
+ type.
682
+ */
683
+ validContent(content: Fragment): boolean;
684
+ /**
685
+ Check whether the given mark type is allowed in this node.
686
+ */
687
+ allowsMarkType(markType: MarkType): boolean;
688
+ /**
689
+ Test whether the given set of marks are allowed in this node.
690
+ */
691
+ allowsMarks(marks: readonly Mark[]): boolean;
692
+ /**
693
+ Removes the marks that are not allowed in this node from the given set.
694
+ */
695
+ allowedMarks(marks: readonly Mark[]): readonly Mark[];
696
+ }
697
+ /**
698
+ Like nodes, marks (which are associated with nodes to signify
699
+ things like emphasis or being part of a link) are
700
+ [tagged](https://prosemirror.net/docs/ref/#model.Mark.type) with type objects, which are
701
+ instantiated once per `Schema`.
702
+ */
703
+ declare class MarkType {
704
+ /**
705
+ The name of the mark type.
706
+ */
707
+ readonly name: string;
708
+ /**
709
+ The schema that this mark type instance is part of.
710
+ */
711
+ readonly schema: Schema;
712
+ /**
713
+ The spec on which the type is based.
714
+ */
715
+ readonly spec: MarkSpec;
716
+ /**
717
+ Create a mark of this type. `attrs` may be `null` or an object
718
+ containing only some of the mark's attributes. The others, if
719
+ they have defaults, will be added.
720
+ */
721
+ create(attrs?: Attrs | null): Mark;
722
+ /**
723
+ When there is a mark of this type in the given set, a new set
724
+ without it is returned. Otherwise, the input set is returned.
725
+ */
726
+ removeFromSet(set: readonly Mark[]): readonly Mark[];
727
+ /**
728
+ Tests whether there is a mark of this type in the given set.
729
+ */
730
+ isInSet(set: readonly Mark[]): Mark | undefined;
731
+ /**
732
+ Queries whether a given mark type is
733
+ [excluded](https://prosemirror.net/docs/ref/#model.MarkSpec.excludes) by this one.
734
+ */
735
+ excludes(other: MarkType): boolean;
736
+ }
737
+ /**
738
+ An object describing a schema, as passed to the [`Schema`](https://prosemirror.net/docs/ref/#model.Schema)
739
+ constructor.
740
+ */
741
+ interface SchemaSpec<Nodes extends string = any, Marks extends string = any> {
742
+ /**
743
+ The node types in this schema. Maps names to
744
+ [`NodeSpec`](https://prosemirror.net/docs/ref/#model.NodeSpec) objects that describe the node type
745
+ associated with that name. Their order is significant—it
746
+ determines which [parse rules](https://prosemirror.net/docs/ref/#model.NodeSpec.parseDOM) take
747
+ precedence by default, and which nodes come first in a given
748
+ [group](https://prosemirror.net/docs/ref/#model.NodeSpec.group).
749
+ */
750
+ nodes: { [name in Nodes]: NodeSpec } | OrderedMap<NodeSpec>;
751
+ /**
752
+ The mark types that exist in this schema. The order in which they
753
+ are provided determines the order in which [mark
754
+ sets](https://prosemirror.net/docs/ref/#model.Mark.addToSet) are sorted and in which [parse
755
+ rules](https://prosemirror.net/docs/ref/#model.MarkSpec.parseDOM) are tried.
756
+ */
757
+ marks?: { [name in Marks]: MarkSpec } | OrderedMap<MarkSpec>;
758
+ /**
759
+ The name of the default top-level node for the schema. Defaults
760
+ to `"doc"`.
761
+ */
762
+ topNode?: string;
763
+ }
764
+ /**
765
+ A description of a node type, used when defining a schema.
766
+ */
767
+ interface NodeSpec {
768
+ /**
769
+ The content expression for this node, as described in the [schema
770
+ guide](https://prosemirror.net/docs/guide/#schema.content_expressions). When not given,
771
+ the node does not allow any content.
772
+ */
773
+ content?: string;
774
+ /**
775
+ The marks that are allowed inside of this node. May be a
776
+ space-separated string referring to mark names or groups, `"_"`
777
+ to explicitly allow all marks, or `""` to disallow marks. When
778
+ not given, nodes with inline content default to allowing all
779
+ marks, other nodes default to not allowing marks.
780
+ */
781
+ marks?: string;
782
+ /**
783
+ The group or space-separated groups to which this node belongs,
784
+ which can be referred to in the content expressions for the
785
+ schema.
786
+ */
787
+ group?: string;
788
+ /**
789
+ Should be set to true for inline nodes. (Implied for text nodes.)
790
+ */
791
+ inline?: boolean;
792
+ /**
793
+ Can be set to true to indicate that, though this isn't a [leaf
794
+ node](https://prosemirror.net/docs/ref/#model.NodeType.isLeaf), it doesn't have directly editable
795
+ content and should be treated as a single unit in the view.
796
+ */
797
+ atom?: boolean;
798
+ /**
799
+ The attributes that nodes of this type get.
800
+ */
801
+ attrs?: {
802
+ [name: string]: AttributeSpec;
803
+ };
804
+ /**
805
+ Controls whether nodes of this type can be selected as a [node
806
+ selection](https://prosemirror.net/docs/ref/#state.NodeSelection). Defaults to true for non-text
807
+ nodes.
808
+ */
809
+ selectable?: boolean;
810
+ /**
811
+ Determines whether nodes of this type can be dragged without
812
+ being selected. Defaults to false.
813
+ */
814
+ draggable?: boolean;
815
+ /**
816
+ Can be used to indicate that this node contains code, which
817
+ causes some commands to behave differently.
818
+ */
819
+ code?: boolean;
820
+ /**
821
+ Controls way whitespace in this a node is parsed. The default is
822
+ `"normal"`, which causes the [DOM parser](https://prosemirror.net/docs/ref/#model.DOMParser) to
823
+ collapse whitespace in normal mode, and normalize it (replacing
824
+ newlines and such with spaces) otherwise. `"pre"` causes the
825
+ parser to preserve spaces inside the node. When this option isn't
826
+ given, but [`code`](https://prosemirror.net/docs/ref/#model.NodeSpec.code) is true, `whitespace`
827
+ will default to `"pre"`. Note that this option doesn't influence
828
+ the way the node is rendered—that should be handled by `toDOM`
829
+ and/or styling.
830
+ */
831
+ whitespace?: "pre" | "normal";
832
+ /**
833
+ Determines whether this node is considered an important parent
834
+ node during replace operations (such as paste). Non-defining (the
835
+ default) nodes get dropped when their entire content is replaced,
836
+ whereas defining nodes persist and wrap the inserted content.
837
+ */
838
+ definingAsContext?: boolean;
839
+ /**
840
+ In inserted content the defining parents of the content are
841
+ preserved when possible. Typically, non-default-paragraph
842
+ textblock types, and possibly list items, are marked as defining.
843
+ */
844
+ definingForContent?: boolean;
845
+ /**
846
+ When enabled, enables both
847
+ [`definingAsContext`](https://prosemirror.net/docs/ref/#model.NodeSpec.definingAsContext) and
848
+ [`definingForContent`](https://prosemirror.net/docs/ref/#model.NodeSpec.definingForContent).
849
+ */
850
+ defining?: boolean;
851
+ /**
852
+ When enabled (default is false), the sides of nodes of this type
853
+ count as boundaries that regular editing operations, like
854
+ backspacing or lifting, won't cross. An example of a node that
855
+ should probably have this enabled is a table cell.
856
+ */
857
+ isolating?: boolean;
858
+ /**
859
+ Defines the default way a node of this type should be serialized
860
+ to DOM/HTML (as used by
861
+ [`DOMSerializer.fromSchema`](https://prosemirror.net/docs/ref/#model.DOMSerializer^fromSchema)).
862
+ Should return a DOM node or an [array
863
+ structure](https://prosemirror.net/docs/ref/#model.DOMOutputSpec) that describes one, with an
864
+ optional number zero (“hole”) in it to indicate where the node's
865
+ content should be inserted.
866
+
867
+ For text nodes, the default is to create a text DOM node. Though
868
+ it is possible to create a serializer where text is rendered
869
+ differently, this is not supported inside the editor, so you
870
+ shouldn't override that in your text node spec.
871
+ */
872
+ toDOM?: (node: Node) => DOMOutputSpec;
873
+ /**
874
+ Associates DOM parser information with this node, which can be
875
+ used by [`DOMParser.fromSchema`](https://prosemirror.net/docs/ref/#model.DOMParser^fromSchema) to
876
+ automatically derive a parser. The `node` field in the rules is
877
+ implied (the name of this node will be filled in automatically).
878
+ If you supply your own parser, you do not need to also specify
879
+ parsing rules in your schema.
880
+ */
881
+ parseDOM?: readonly TagParseRule[];
882
+ /**
883
+ Defines the default way a node of this type should be serialized
884
+ to a string representation for debugging (e.g. in error messages).
885
+ */
886
+ toDebugString?: (node: Node) => string;
887
+ /**
888
+ Defines the default way a [leaf node](https://prosemirror.net/docs/ref/#model.NodeType.isLeaf) of
889
+ this type should be serialized to a string (as used by
890
+ [`Node.textBetween`](https://prosemirror.net/docs/ref/#model.Node.textBetween) and
891
+ [`Node.textContent`](https://prosemirror.net/docs/ref/#model.Node.textContent)).
892
+ */
893
+ leafText?: (node: Node) => string;
894
+ /**
895
+ A single inline node in a schema can be set to be a linebreak
896
+ equivalent. When converting between block types that support the
897
+ node and block types that don't but have
898
+ [`whitespace`](https://prosemirror.net/docs/ref/#model.NodeSpec.whitespace) set to `"pre"`,
899
+ [`setBlockType`](https://prosemirror.net/docs/ref/#transform.Transform.setBlockType) will convert
900
+ between newline characters to or from linebreak nodes as
901
+ appropriate.
902
+ */
903
+ linebreakReplacement?: boolean;
904
+ /**
905
+ Node specs may include arbitrary properties that can be read by
906
+ other code via [`NodeType.spec`](https://prosemirror.net/docs/ref/#model.NodeType.spec).
907
+ */
908
+ [key: string]: any;
909
+ }
910
+ /**
911
+ Used to define marks when creating a schema.
912
+ */
913
+ interface MarkSpec {
914
+ /**
915
+ The attributes that marks of this type get.
916
+ */
917
+ attrs?: {
918
+ [name: string]: AttributeSpec;
919
+ };
920
+ /**
921
+ Whether this mark should be active when the cursor is positioned
922
+ at its end (or at its start when that is also the start of the
923
+ parent node). Defaults to true.
924
+ */
925
+ inclusive?: boolean;
926
+ /**
927
+ Determines which other marks this mark can coexist with. Should
928
+ be a space-separated strings naming other marks or groups of marks.
929
+ When a mark is [added](https://prosemirror.net/docs/ref/#model.Mark.addToSet) to a set, all marks
930
+ that it excludes are removed in the process. If the set contains
931
+ any mark that excludes the new mark but is not, itself, excluded
932
+ by the new mark, the mark can not be added an the set. You can
933
+ use the value `"_"` to indicate that the mark excludes all
934
+ marks in the schema.
935
+
936
+ Defaults to only being exclusive with marks of the same type. You
937
+ can set it to an empty string (or any string not containing the
938
+ mark's own name) to allow multiple marks of a given type to
939
+ coexist (as long as they have different attributes).
940
+ */
941
+ excludes?: string;
942
+ /**
943
+ The group or space-separated groups to which this mark belongs.
944
+ */
945
+ group?: string;
946
+ /**
947
+ Determines whether marks of this type can span multiple adjacent
948
+ nodes when serialized to DOM/HTML. Defaults to true.
949
+ */
950
+ spanning?: boolean;
951
+ /**
952
+ Marks the content of this span as being code, which causes some
953
+ commands and extensions to treat it differently.
954
+ */
955
+ code?: boolean;
956
+ /**
957
+ Defines the default way marks of this type should be serialized
958
+ to DOM/HTML. When the resulting spec contains a hole, that is
959
+ where the marked content is placed. Otherwise, it is appended to
960
+ the top node.
961
+ */
962
+ toDOM?: (mark: Mark, inline: boolean) => DOMOutputSpec;
963
+ /**
964
+ Associates DOM parser information with this mark (see the
965
+ corresponding [node spec field](https://prosemirror.net/docs/ref/#model.NodeSpec.parseDOM)). The
966
+ `mark` field in the rules is implied.
967
+ */
968
+ parseDOM?: readonly ParseRule[];
969
+ /**
970
+ Mark specs can include additional properties that can be
971
+ inspected through [`MarkType.spec`](https://prosemirror.net/docs/ref/#model.MarkType.spec) when
972
+ working with the mark.
973
+ */
974
+ [key: string]: any;
975
+ }
976
+ /**
977
+ Used to [define](https://prosemirror.net/docs/ref/#model.NodeSpec.attrs) attributes on nodes or
978
+ marks.
979
+ */
980
+ interface AttributeSpec {
981
+ /**
982
+ The default value for this attribute, to use when no explicit
983
+ value is provided. Attributes that have no default must be
984
+ provided whenever a node or mark of a type that has them is
985
+ created.
986
+ */
987
+ default?: any;
988
+ /**
989
+ A function or type name used to validate values of this
990
+ attribute. This will be used when deserializing the attribute
991
+ from JSON, and when running [`Node.check`](https://prosemirror.net/docs/ref/#model.Node.check).
992
+ When a function, it should raise an exception if the value isn't
993
+ of the expected type or shape. When a string, it should be a
994
+ `|`-separated string of primitive types (`"number"`, `"string"`,
995
+ `"boolean"`, `"null"`, and `"undefined"`), and the library will
996
+ raise an error when the value is not one of those types.
997
+ */
998
+ validate?: string | ((value: any) => void);
999
+ }
1000
+ /**
1001
+ A document schema. Holds [node](https://prosemirror.net/docs/ref/#model.NodeType) and [mark
1002
+ type](https://prosemirror.net/docs/ref/#model.MarkType) objects for the nodes and marks that may
1003
+ occur in conforming documents, and provides functionality for
1004
+ creating and deserializing such documents.
1005
+
1006
+ When given, the type parameters provide the names of the nodes and
1007
+ marks in this schema.
1008
+ */
1009
+ declare class Schema<Nodes extends string = any, Marks extends string = any> {
1010
+ /**
1011
+ The [spec](https://prosemirror.net/docs/ref/#model.SchemaSpec) on which the schema is based,
1012
+ with the added guarantee that its `nodes` and `marks`
1013
+ properties are
1014
+ [`OrderedMap`](https://github.com/marijnh/orderedmap) instances
1015
+ (not raw objects).
1016
+ */
1017
+ spec: {
1018
+ nodes: OrderedMap<NodeSpec>;
1019
+ marks: OrderedMap<MarkSpec>;
1020
+ topNode?: string;
1021
+ };
1022
+ /**
1023
+ An object mapping the schema's node names to node type objects.
1024
+ */
1025
+ nodes: { readonly [name in Nodes]: NodeType } & {
1026
+ readonly [key: string]: NodeType;
1027
+ };
1028
+ /**
1029
+ A map from mark names to mark type objects.
1030
+ */
1031
+ marks: { readonly [name in Marks]: MarkType } & {
1032
+ readonly [key: string]: MarkType;
1033
+ };
1034
+ /**
1035
+ The [linebreak
1036
+ replacement](https://prosemirror.net/docs/ref/#model.NodeSpec.linebreakReplacement) node defined
1037
+ in this schema, if any.
1038
+ */
1039
+ linebreakReplacement: NodeType | null;
1040
+ /**
1041
+ Construct a schema from a schema [specification](https://prosemirror.net/docs/ref/#model.SchemaSpec).
1042
+ */
1043
+ constructor(spec: SchemaSpec<Nodes, Marks>);
1044
+ /**
1045
+ The type of the [default top node](https://prosemirror.net/docs/ref/#model.SchemaSpec.topNode)
1046
+ for this schema.
1047
+ */
1048
+ topNodeType: NodeType;
1049
+ /**
1050
+ An object for storing whatever values modules may want to
1051
+ compute and cache per schema. (If you want to store something
1052
+ in it, try to use property names unlikely to clash.)
1053
+ */
1054
+ cached: {
1055
+ [key: string]: any;
1056
+ };
1057
+ /**
1058
+ Create a node in this schema. The `type` may be a string or a
1059
+ `NodeType` instance. Attributes will be extended with defaults,
1060
+ `content` may be a `Fragment`, `null`, a `Node`, or an array of
1061
+ nodes.
1062
+ */
1063
+ node(type: string | NodeType, attrs?: Attrs | null, content?: Fragment | Node | readonly Node[], marks?: readonly Mark[]): Node;
1064
+ /**
1065
+ Create a text node in the schema. Empty text nodes are not
1066
+ allowed.
1067
+ */
1068
+ text(text: string, marks?: readonly Mark[] | null): Node;
1069
+ /**
1070
+ Create a mark with the given type and attributes.
1071
+ */
1072
+ mark(type: string | MarkType, attrs?: Attrs | null): Mark;
1073
+ /**
1074
+ Deserialize a node from its JSON representation. This method is
1075
+ bound.
1076
+ */
1077
+ nodeFromJSON: (json: any) => Node;
1078
+ /**
1079
+ Deserialize a mark from its JSON representation. This method is
1080
+ bound.
1081
+ */
1082
+ markFromJSON: (json: any) => Mark;
1083
+ }
1084
+ /**
1085
+ A fragment represents a node's collection of child nodes.
1086
+
1087
+ Like nodes, fragments are persistent data structures, and you
1088
+ should not mutate them or their content. Rather, you create new
1089
+ instances whenever needed. The API tries to make this easy.
1090
+ */
1091
+ declare class Fragment {
1092
+ /**
1093
+ The child nodes in this fragment.
1094
+ */
1095
+ readonly content: readonly Node[];
1096
+ /**
1097
+ The size of the fragment, which is the total of the size of
1098
+ its content nodes.
1099
+ */
1100
+ readonly size: number;
1101
+ /**
1102
+ Invoke a callback for all descendant nodes between the given two
1103
+ positions (relative to start of this fragment). Doesn't descend
1104
+ into a node when the callback returns `false`.
1105
+ */
1106
+ nodesBetween(from: number, to: number, f: (node: Node, start: number, parent: Node | null, index: number) => boolean | void, nodeStart?: number, parent?: Node): void;
1107
+ /**
1108
+ Call the given callback for every descendant node. `pos` will be
1109
+ relative to the start of the fragment. The callback may return
1110
+ `false` to prevent traversal of a given node's children.
1111
+ */
1112
+ descendants(f: (node: Node, pos: number, parent: Node | null, index: number) => boolean | void): void;
1113
+ /**
1114
+ Extract the text between `from` and `to`. See the same method on
1115
+ [`Node`](https://prosemirror.net/docs/ref/#model.Node.textBetween).
1116
+ */
1117
+ textBetween(from: number, to: number, blockSeparator?: string | null, leafText?: string | null | ((leafNode: Node) => string)): string;
1118
+ /**
1119
+ Create a new fragment containing the combined content of this
1120
+ fragment and the other.
1121
+ */
1122
+ append(other: Fragment): Fragment;
1123
+ /**
1124
+ Cut out the sub-fragment between the two given positions.
1125
+ */
1126
+ cut(from: number, to?: number): Fragment;
1127
+ /**
1128
+ Create a new fragment in which the node at the given index is
1129
+ replaced by the given node.
1130
+ */
1131
+ replaceChild(index: number, node: Node): Fragment;
1132
+ /**
1133
+ Create a new fragment by prepending the given node to this
1134
+ fragment.
1135
+ */
1136
+ addToStart(node: Node): Fragment;
1137
+ /**
1138
+ Create a new fragment by appending the given node to this
1139
+ fragment.
1140
+ */
1141
+ addToEnd(node: Node): Fragment;
1142
+ /**
1143
+ Compare this fragment to another one.
1144
+ */
1145
+ eq(other: Fragment): boolean;
1146
+ /**
1147
+ The first child of the fragment, or `null` if it is empty.
1148
+ */
1149
+ get firstChild(): Node | null;
1150
+ /**
1151
+ The last child of the fragment, or `null` if it is empty.
1152
+ */
1153
+ get lastChild(): Node | null;
1154
+ /**
1155
+ The number of child nodes in this fragment.
1156
+ */
1157
+ get childCount(): number;
1158
+ /**
1159
+ Get the child node at the given index. Raise an error when the
1160
+ index is out of range.
1161
+ */
1162
+ child(index: number): Node;
1163
+ /**
1164
+ Get the child node at the given index, if it exists.
1165
+ */
1166
+ maybeChild(index: number): Node | null;
1167
+ /**
1168
+ Call `f` for every child node, passing the node, its offset
1169
+ into this parent node, and its index.
1170
+ */
1171
+ forEach(f: (node: Node, offset: number, index: number) => void): void;
1172
+ /**
1173
+ Find the first position at which this fragment and another
1174
+ fragment differ, or `null` if they are the same.
1175
+ */
1176
+ findDiffStart(other: Fragment, pos?: number): number | null;
1177
+ /**
1178
+ Find the first position, searching from the end, at which this
1179
+ fragment and the given fragment differ, or `null` if they are
1180
+ the same. Since this position will not be the same in both
1181
+ nodes, an object with two separate positions is returned.
1182
+ */
1183
+ findDiffEnd(other: Fragment, pos?: number, otherPos?: number): {
1184
+ a: number;
1185
+ b: number;
1186
+ } | null;
1187
+ /**
1188
+ Return a debugging string that describes this fragment.
1189
+ */
1190
+ toString(): string;
1191
+ /**
1192
+ Create a JSON-serializeable representation of this fragment.
1193
+ */
1194
+ toJSON(): any;
1195
+ /**
1196
+ Deserialize a fragment from its JSON representation.
1197
+ */
1198
+ static fromJSON(schema: Schema, value: any): Fragment;
1199
+ /**
1200
+ Build a fragment from an array of nodes. Ensures that adjacent
1201
+ text nodes with the same marks are joined together.
1202
+ */
1203
+ static fromArray(array: readonly Node[]): Fragment;
1204
+ /**
1205
+ Create a fragment from something that can be interpreted as a
1206
+ set of nodes. For `null`, it returns the empty fragment. For a
1207
+ fragment, the fragment itself. For a node or array of nodes, a
1208
+ fragment containing those nodes.
1209
+ */
1210
+ static from(nodes?: Fragment | Node | readonly Node[] | null): Fragment;
1211
+ /**
1212
+ An empty fragment. Intended to be reused whenever a node doesn't
1213
+ contain anything (rather than allocating a new empty fragment for
1214
+ each leaf node).
1215
+ */
1216
+ static empty: Fragment;
1217
+ }
1218
+ type MatchEdge = {
1219
+ type: NodeType;
1220
+ next: ContentMatch;
1221
+ };
1222
+ /**
1223
+ Instances of this class represent a match state of a node type's
1224
+ [content expression](https://prosemirror.net/docs/ref/#model.NodeSpec.content), and can be used to
1225
+ find out whether further content matches here, and whether a given
1226
+ position is a valid end of the node.
1227
+ */
1228
+ declare class ContentMatch {
1229
+ /**
1230
+ True when this match state represents a valid end of the node.
1231
+ */
1232
+ readonly validEnd: boolean;
1233
+ /**
1234
+ Match a node type, returning a match after that node if
1235
+ successful.
1236
+ */
1237
+ matchType(type: NodeType): ContentMatch | null;
1238
+ /**
1239
+ Try to match a fragment. Returns the resulting match when
1240
+ successful.
1241
+ */
1242
+ matchFragment(frag: Fragment, start?: number, end?: number): ContentMatch | null;
1243
+ /**
1244
+ Get the first matching node type at this match position that can
1245
+ be generated.
1246
+ */
1247
+ get defaultType(): NodeType | null;
1248
+ /**
1249
+ Try to match the given fragment, and if that fails, see if it can
1250
+ be made to match by inserting nodes in front of it. When
1251
+ successful, return a fragment of inserted nodes (which may be
1252
+ empty if nothing had to be inserted). When `toEnd` is true, only
1253
+ return a fragment if the resulting match goes to the end of the
1254
+ content expression.
1255
+ */
1256
+ fillBefore(after: Fragment, toEnd?: boolean, startIndex?: number): Fragment | null;
1257
+ /**
1258
+ Find a set of wrapping node types that would allow a node of the
1259
+ given type to appear at this position. The result may be empty
1260
+ (when it fits directly) and will be null when no such wrapping
1261
+ exists.
1262
+ */
1263
+ findWrapping(target: NodeType): readonly NodeType[] | null;
1264
+ /**
1265
+ The number of outgoing edges this node has in the finite
1266
+ automaton that describes the content expression.
1267
+ */
1268
+ get edgeCount(): number;
1269
+ /**
1270
+ Get the _n_​th outgoing edge from this node in the finite
1271
+ automaton that describes the content expression.
1272
+ */
1273
+ edge(n: number): MatchEdge;
1274
+ }
1275
+ /**
1276
+ This class represents a node in the tree that makes up a
1277
+ ProseMirror document. So a document is an instance of `Node`, with
1278
+ children that are also instances of `Node`.
1279
+
1280
+ Nodes are persistent data structures. Instead of changing them, you
1281
+ create new ones with the content you want. Old ones keep pointing
1282
+ at the old document shape. This is made cheaper by sharing
1283
+ structure between the old and new data as much as possible, which a
1284
+ tree shape like this (without back pointers) makes easy.
1285
+
1286
+ **Do not** directly mutate the properties of a `Node` object. See
1287
+ [the guide](https://prosemirror.net/docs/guide/#doc) for more information.
1288
+ */
1289
+ declare class Node {
1290
+ /**
1291
+ The type of node that this is.
1292
+ */
1293
+ readonly type: NodeType;
1294
+ /**
1295
+ An object mapping attribute names to values. The kind of
1296
+ attributes allowed and required are
1297
+ [determined](https://prosemirror.net/docs/ref/#model.NodeSpec.attrs) by the node type.
1298
+ */
1299
+ readonly attrs: Attrs;
1300
+ /**
1301
+ The marks (things like whether it is emphasized or part of a
1302
+ link) applied to this node.
1303
+ */
1304
+ readonly marks: readonly Mark[];
1305
+ /**
1306
+ A container holding the node's children.
1307
+ */
1308
+ readonly content: Fragment;
1309
+ /**
1310
+ The array of this node's child nodes.
1311
+ */
1312
+ get children(): readonly Node[];
1313
+ /**
1314
+ For text nodes, this contains the node's text content.
1315
+ */
1316
+ readonly text: string | undefined;
1317
+ /**
1318
+ The size of this node, as defined by the integer-based [indexing
1319
+ scheme](https://prosemirror.net/docs/guide/#doc.indexing). For text nodes, this is the
1320
+ amount of characters. For other leaf nodes, it is one. For
1321
+ non-leaf nodes, it is the size of the content plus two (the
1322
+ start and end token).
1323
+ */
1324
+ get nodeSize(): number;
1325
+ /**
1326
+ The number of children that the node has.
1327
+ */
1328
+ get childCount(): number;
1329
+ /**
1330
+ Get the child node at the given index. Raises an error when the
1331
+ index is out of range.
1332
+ */
1333
+ child(index: number): Node;
1334
+ /**
1335
+ Get the child node at the given index, if it exists.
1336
+ */
1337
+ maybeChild(index: number): Node | null;
1338
+ /**
1339
+ Call `f` for every child node, passing the node, its offset
1340
+ into this parent node, and its index.
1341
+ */
1342
+ forEach(f: (node: Node, offset: number, index: number) => void): void;
1343
+ /**
1344
+ Invoke a callback for all descendant nodes recursively between
1345
+ the given two positions that are relative to start of this
1346
+ node's content. The callback is invoked with the node, its
1347
+ position relative to the original node (method receiver),
1348
+ its parent node, and its child index. When the callback returns
1349
+ false for a given node, that node's children will not be
1350
+ recursed over. The last parameter can be used to specify a
1351
+ starting position to count from.
1352
+ */
1353
+ nodesBetween(from: number, to: number, f: (node: Node, pos: number, parent: Node | null, index: number) => void | boolean, startPos?: number): void;
1354
+ /**
1355
+ Call the given callback for every descendant node. Doesn't
1356
+ descend into a node when the callback returns `false`.
1357
+ */
1358
+ descendants(f: (node: Node, pos: number, parent: Node | null, index: number) => void | boolean): void;
1359
+ /**
1360
+ Concatenates all the text nodes found in this fragment and its
1361
+ children.
1362
+ */
1363
+ get textContent(): string;
1364
+ /**
1365
+ Get all text between positions `from` and `to`. When
1366
+ `blockSeparator` is given, it will be inserted to separate text
1367
+ from different block nodes. If `leafText` is given, it'll be
1368
+ inserted for every non-text leaf node encountered, otherwise
1369
+ [`leafText`](https://prosemirror.net/docs/ref/#model.NodeSpec.leafText) will be used.
1370
+ */
1371
+ textBetween(from: number, to: number, blockSeparator?: string | null, leafText?: null | string | ((leafNode: Node) => string)): string;
1372
+ /**
1373
+ Returns this node's first child, or `null` if there are no
1374
+ children.
1375
+ */
1376
+ get firstChild(): Node | null;
1377
+ /**
1378
+ Returns this node's last child, or `null` if there are no
1379
+ children.
1380
+ */
1381
+ get lastChild(): Node | null;
1382
+ /**
1383
+ Test whether two nodes represent the same piece of document.
1384
+ */
1385
+ eq(other: Node): boolean;
1386
+ /**
1387
+ Compare the markup (type, attributes, and marks) of this node to
1388
+ those of another. Returns `true` if both have the same markup.
1389
+ */
1390
+ sameMarkup(other: Node): boolean;
1391
+ /**
1392
+ Check whether this node's markup correspond to the given type,
1393
+ attributes, and marks.
1394
+ */
1395
+ hasMarkup(type: NodeType, attrs?: Attrs | null, marks?: readonly Mark[]): boolean;
1396
+ /**
1397
+ Create a new node with the same markup as this node, containing
1398
+ the given content (or empty, if no content is given).
1399
+ */
1400
+ copy(content?: Fragment | null): Node;
1401
+ /**
1402
+ Create a copy of this node, with the given set of marks instead
1403
+ of the node's own marks.
1404
+ */
1405
+ mark(marks: readonly Mark[]): Node;
1406
+ /**
1407
+ Create a copy of this node with only the content between the
1408
+ given positions. If `to` is not given, it defaults to the end of
1409
+ the node.
1410
+ */
1411
+ cut(from: number, to?: number): Node;
1412
+ /**
1413
+ Cut out the part of the document between the given positions, and
1414
+ return it as a `Slice` object.
1415
+ */
1416
+ slice(from: number, to?: number, includeParents?: boolean): Slice;
1417
+ /**
1418
+ Replace the part of the document between the given positions with
1419
+ the given slice. The slice must 'fit', meaning its open sides
1420
+ must be able to connect to the surrounding content, and its
1421
+ content nodes must be valid children for the node they are placed
1422
+ into. If any of this is violated, an error of type
1423
+ [`ReplaceError`](https://prosemirror.net/docs/ref/#model.ReplaceError) is thrown.
1424
+ */
1425
+ replace(from: number, to: number, slice: Slice): Node;
1426
+ /**
1427
+ Find the node directly after the given position.
1428
+ */
1429
+ nodeAt(pos: number): Node | null;
1430
+ /**
1431
+ Find the (direct) child node after the given offset, if any,
1432
+ and return it along with its index and offset relative to this
1433
+ node.
1434
+ */
1435
+ childAfter(pos: number): {
1436
+ node: Node | null;
1437
+ index: number;
1438
+ offset: number;
1439
+ };
1440
+ /**
1441
+ Find the (direct) child node before the given offset, if any,
1442
+ and return it along with its index and offset relative to this
1443
+ node.
1444
+ */
1445
+ childBefore(pos: number): {
1446
+ node: Node | null;
1447
+ index: number;
1448
+ offset: number;
1449
+ };
1450
+ /**
1451
+ Resolve the given position in the document, returning an
1452
+ [object](https://prosemirror.net/docs/ref/#model.ResolvedPos) with information about its context.
1453
+ */
1454
+ resolve(pos: number): ResolvedPos;
1455
+ /**
1456
+ Test whether a given mark or mark type occurs in this document
1457
+ between the two given positions.
1458
+ */
1459
+ rangeHasMark(from: number, to: number, type: Mark | MarkType): boolean;
1460
+ /**
1461
+ True when this is a block (non-inline node)
1462
+ */
1463
+ get isBlock(): boolean;
1464
+ /**
1465
+ True when this is a textblock node, a block node with inline
1466
+ content.
1467
+ */
1468
+ get isTextblock(): boolean;
1469
+ /**
1470
+ True when this node allows inline content.
1471
+ */
1472
+ get inlineContent(): boolean;
1473
+ /**
1474
+ True when this is an inline node (a text node or a node that can
1475
+ appear among text).
1476
+ */
1477
+ get isInline(): boolean;
1478
+ /**
1479
+ True when this is a text node.
1480
+ */
1481
+ get isText(): boolean;
1482
+ /**
1483
+ True when this is a leaf node.
1484
+ */
1485
+ get isLeaf(): boolean;
1486
+ /**
1487
+ True when this is an atom, i.e. when it does not have directly
1488
+ editable content. This is usually the same as `isLeaf`, but can
1489
+ be configured with the [`atom` property](https://prosemirror.net/docs/ref/#model.NodeSpec.atom)
1490
+ on a node's spec (typically used when the node is displayed as
1491
+ an uneditable [node view](https://prosemirror.net/docs/ref/#view.NodeView)).
1492
+ */
1493
+ get isAtom(): boolean;
1494
+ /**
1495
+ Return a string representation of this node for debugging
1496
+ purposes.
1497
+ */
1498
+ toString(): string;
1499
+ /**
1500
+ Get the content match in this node at the given index.
1501
+ */
1502
+ contentMatchAt(index: number): ContentMatch;
1503
+ /**
1504
+ Test whether replacing the range between `from` and `to` (by
1505
+ child index) with the given replacement fragment (which defaults
1506
+ to the empty fragment) would leave the node's content valid. You
1507
+ can optionally pass `start` and `end` indices into the
1508
+ replacement fragment.
1509
+ */
1510
+ canReplace(from: number, to: number, replacement?: Fragment, start?: number, end?: number): boolean;
1511
+ /**
1512
+ Test whether replacing the range `from` to `to` (by index) with
1513
+ a node of the given type would leave the node's content valid.
1514
+ */
1515
+ canReplaceWith(from: number, to: number, type: NodeType, marks?: readonly Mark[]): boolean;
1516
+ /**
1517
+ Test whether the given node's content could be appended to this
1518
+ node. If that node is empty, this will only return true if there
1519
+ is at least one node type that can appear in both nodes (to avoid
1520
+ merging completely incompatible nodes).
1521
+ */
1522
+ canAppend(other: Node): boolean;
1523
+ /**
1524
+ Check whether this node and its descendants conform to the
1525
+ schema, and raise an exception when they do not.
1526
+ */
1527
+ check(): void;
1528
+ /**
1529
+ Return a JSON-serializeable representation of this node.
1530
+ */
1531
+ toJSON(): any;
1532
+ /**
1533
+ Deserialize a node from its JSON representation.
1534
+ */
1535
+ static fromJSON(schema: Schema, json: any): Node;
1536
+ }
1537
+ //#endregion
1538
+ //#region ../../node_modules/.pnpm/@tiptap+extensions@3.22.4_@_7a4cd59862ae01f7ca17ccb83d24fa36/node_modules/@tiptap/extensions/dist/index.d.ts
1539
+ interface CharacterCountStorage {
1540
+ /**
1541
+ * Get the number of characters for the current document.
1542
+ * @param options The options for the character count. (optional)
1543
+ * @param options.node The node to get the characters from. Defaults to the current document.
1544
+ * @param options.mode The mode by which the size is calculated. If set to `textSize`, the textContent of the document is used.
1545
+ */
1546
+ characters: (options?: {
1547
+ node?: Node;
1548
+ mode?: 'textSize' | 'nodeSize';
1549
+ }) => number;
1550
+ /**
1551
+ * Get the number of words for the current document.
1552
+ * @param options The options for the character count. (optional)
1553
+ * @param options.node The node to get the words from. Defaults to the current document.
1554
+ */
1555
+ words: (options?: {
1556
+ node?: Node;
1557
+ }) => number;
1558
+ }
1559
+ declare module '@tiptap/core' {
1560
+ interface Storage {
1561
+ characterCount: CharacterCountStorage;
1562
+ }
1563
+ }
1564
+ /**
1565
+ * This extension allows you to count the characters and words of your document.
1566
+ * @see https://tiptap.dev/api/extensions/character-count
1567
+ */
1568
+ interface DropcursorOptions {
1569
+ /**
1570
+ * The color of the drop cursor. Use `false` to apply no color and rely only on class.
1571
+ * @default 'currentColor'
1572
+ * @example 'red'
1573
+ */
1574
+ color?: string | false;
1575
+ /**
1576
+ * The width of the drop cursor
1577
+ * @default 1
1578
+ * @example 2
1579
+ */
1580
+ width: number | undefined;
1581
+ /**
1582
+ * The class of the drop cursor
1583
+ * @default undefined
1584
+ * @example 'drop-cursor'
1585
+ */
1586
+ class: string | undefined;
1587
+ }
1588
+ /**
1589
+ * This extension allows you to add a drop cursor to your editor.
1590
+ * A drop cursor is a line that appears when you drag and drop content
1591
+ * in-between nodes.
1592
+ * @see https://tiptap.dev/api/extensions/dropcursor
1593
+ */
1594
+ declare const Dropcursor: Extension<DropcursorOptions, any>;
1595
+ declare module '@tiptap/core' {
1596
+ interface NodeConfig<Options, Storage> {
1597
+ /**
1598
+ * A function to determine whether the gap cursor is allowed at the current position. Must return `true` or `false`.
1599
+ * @default null
1600
+ */
1601
+ allowGapCursor?: boolean | null | ((this: {
1602
+ name: string;
1603
+ options: Options;
1604
+ storage: Storage;
1605
+ parent: ParentConfig<NodeConfig<Options>>['allowGapCursor'];
1606
+ }) => boolean | null);
1607
+ }
1608
+ }
1609
+ /**
1610
+ * This extension allows you to add a gap cursor to your editor.
1611
+ * A gap cursor is a cursor that appears when you click on a place
1612
+ * where no content is present, for example inbetween nodes.
1613
+ * @see https://tiptap.dev/api/extensions/gapcursor
1614
+ */
1615
+ declare const Gapcursor: Extension<any, any>;
1616
+ /**
1617
+ * Prepares the placeholder attribute by ensuring it is properly formatted.
1618
+ * @param attr - The placeholder attribute string.
1619
+ * @returns The prepared placeholder attribute string.
1620
+ */
1621
+ /**
1622
+ * Extension based on:
1623
+ * - https://github.com/ueberdosis/tiptap/blob/v1/packages/tiptap-extensions/src/extensions/TrailingNode.js
1624
+ * - https://github.com/remirror/remirror/blob/e0f1bec4a1e8073ce8f5500d62193e52321155b9/packages/prosemirror-trailing-node/src/trailing-node-plugin.ts
1625
+ */
1626
+ interface TrailingNodeOptions {
1627
+ /**
1628
+ * The node type that should be inserted at the end of the document.
1629
+ * @note the node will always be added to the `notAfter` lists to
1630
+ * prevent an infinite loop.
1631
+ * @default undefined
1632
+ */
1633
+ node?: string;
1634
+ /**
1635
+ * The node types after which the trailing node should not be inserted.
1636
+ * @default ['paragraph']
1637
+ */
1638
+ notAfter?: string | string[];
1639
+ }
1640
+ /**
1641
+ * This extension allows you to add an extra node at the end of the document.
1642
+ * @see https://www.tiptap.dev/api/extensions/trailing-node
1643
+ */
1644
+ declare const TrailingNode: Extension<TrailingNodeOptions, any>;
1645
+ interface UndoRedoOptions {
1646
+ /**
1647
+ * The amount of history events that are collected before the oldest events are discarded.
1648
+ * @default 100
1649
+ * @example 50
1650
+ */
1651
+ depth: number;
1652
+ /**
1653
+ * The delay (in milliseconds) between changes after which a new group should be started.
1654
+ * @default 500
1655
+ * @example 1000
1656
+ */
1657
+ newGroupDelay: number;
1658
+ }
1659
+ declare module '@tiptap/core' {
1660
+ interface Commands<ReturnType> {
1661
+ undoRedo: {
1662
+ /**
1663
+ * Undo recent changes
1664
+ * @example editor.commands.undo()
1665
+ */
1666
+ undo: () => ReturnType;
1667
+ /**
1668
+ * Reapply reverted changes
1669
+ * @example editor.commands.redo()
1670
+ */
1671
+ redo: () => ReturnType;
1672
+ };
1673
+ }
1674
+ }
1675
+ /**
1676
+ * This extension allows you to undo and redo recent changes.
1677
+ * @see https://www.tiptap.dev/api/extensions/undo-redo
1678
+ *
1679
+ * **Important**: If the `@tiptap/extension-collaboration` package is used, make sure to remove
1680
+ * the `undo-redo` extension, as it is not compatible with the `collaboration` extension.
1681
+ *
1682
+ * `@tiptap/extension-collaboration` uses its own history implementation.
1683
+ */
1684
+ declare const UndoRedo: Extension<UndoRedoOptions, any>;
1685
+ //#endregion
1686
+ export { Subscript as A, TextStyle as B, ListItem as C, OrderedList as D, Mention as E, TableRow as F, UndoRedo as G, Dropcursor as H, TaskItem as I, TaskList as L, Table as M, TableCell as N, Paragraph as O, TableHeader as P, Text as R, Link as S, Mathematics as T, Gapcursor as U, Underline as V, TrailingNode as W, Highlight as _, Code as a, Italic as b, Details as c, Document$1 as d, Emoji as f, Heading as g, HardBreak as h, BulletList as i, Superscript as j, Strike as k, DetailsContent as l, FontSize as m, Blockquote as n, CodeBlockLowlight as o, FontFamily as p, Bold as r, Color as s, BackgroundColor as t, DetailsSummary as u, HorizontalRule as v, ListKeymap as w, LineHeight as x, Image as y, TextAlign as z };