@prosekit/core 0.7.2 → 0.7.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.
@@ -1,5 +1,6 @@
1
1
  import { AllSelection } from '@prosekit/pm/state';
2
2
  import { Attrs } from '@prosekit/pm/model';
3
+ import { Attrs as Attrs_2 } from 'prosemirror-model';
3
4
  import { Command } from '@prosekit/pm/state';
4
5
  import type { ContentMatch } from '@prosekit/pm/model';
5
6
  import { config as default_alias_1 } from '@prosekit/dev/config-vitest';
@@ -19,8 +20,8 @@ import { NodeSelection } from '@prosekit/pm/state';
19
20
  import type { NodeSpec } from '@prosekit/pm/model';
20
21
  import { NodeType } from '@prosekit/pm/model';
21
22
  import { NodeType as NodeType_2 } from 'prosemirror-model';
22
- import { NodeView } from '@prosekit/pm/view';
23
- import { NodeViewConstructor } from '@prosekit/pm/view';
23
+ import type { NodeView } from '@prosekit/pm/view';
24
+ import type { NodeViewConstructor } from '@prosekit/pm/view';
24
25
  import { Options } from 'tsup';
25
26
  import type { ParseOptions } from '@prosekit/pm/model';
26
27
  import { Plugin as Plugin_2 } from '@prosekit/pm/state';
@@ -75,6 +76,15 @@ declare interface AddMarkOptions {
75
76
  export { AddMarkOptions }
76
77
  export { AddMarkOptions as AddMarkOptions_alias_1 }
77
78
 
79
+ /**
80
+ * An object holding the attributes of a node.
81
+
82
+ * @public
83
+ */
84
+ declare type AnyAttrs = Attrs;
85
+ export { AnyAttrs }
86
+ export { AnyAttrs as AnyAttrs_alias_1 }
87
+
78
88
  export declare function applyAction(operator: Action): Command;
79
89
 
80
90
  export declare const applyMarkForTest: ApplyMarkFunction;
@@ -106,8 +116,38 @@ export { assert as assert_alias_1 }
106
116
  */
107
117
  export declare function assertTypeEqual<T, U>(_val: IsEqual<T, U>): void;
108
118
 
119
+ /**
120
+ * Utility function assert that two types are equal in tests.
121
+ */
122
+ export declare function assertTypeEqual_alias_1<T, U>(_val: IsEqual<T, U>): void;
123
+
109
124
  export declare function attrsMatch(nodeOrMark: ProseMirrorNode | Mark, attrs: Attrs): boolean;
110
125
 
126
+ /**
127
+ * @public
128
+ */
129
+ declare type AttrSpec<AttrType = any> = {
130
+ /**
131
+ * The default value for this attribute, to use when no explicit value is
132
+ * provided. Attributes that have no default must be provided whenever a node
133
+ * or mark of a type that has them is created.
134
+ */
135
+ default?: AttrType;
136
+ /**
137
+ * A function or type name used to validate values of this attribute. This
138
+ * will be used when deserializing the attribute from JSON, and when running
139
+ * [`Node.check`](https://prosemirror.net/docs/ref/#model.Node.check). When a
140
+ * function, it should raise an exception if the value isn't of the expected
141
+ * type or shape. When a string, it should be a `|`-separated string of
142
+ * primitive types (`"number"`, `"string"`, `"boolean"`, `"null"`, and
143
+ * `"undefined"`), and the library will raise an error when the value is not
144
+ * one of those types.
145
+ */
146
+ validate?: string | ((value: unknown) => void);
147
+ };
148
+ export { AttrSpec }
149
+ export { AttrSpec as AttrSpec_alias_1 }
150
+
111
151
  /**
112
152
  * @internal
113
153
  */
@@ -199,10 +239,19 @@ export { collectNodes as collectNodes_alias_1 }
199
239
 
200
240
  export declare function combineEventHandlers<Handler extends (...args: any[]) => boolean | void, Args extends Parameters<Handler> = Parameters<Handler>>(): readonly [(handlers: Handler[]) => void, (...args: Args) => boolean];
201
241
 
202
- export declare interface CommandApplier<Args extends any[] = any[]> {
242
+ /**
243
+ * A function to apply a command to the editor. It will return `true` if the command was applied, and `false` otherwise.
244
+ *
245
+ * It also has a `canApply` method to check if the command can be applied.
246
+ *
247
+ * @public
248
+ */
249
+ declare interface CommandAction<Args extends any[] = any[]> {
203
250
  (...args: Args): boolean;
204
251
  canApply(...args: Args): boolean;
205
252
  }
253
+ export { CommandAction }
254
+ export { CommandAction as CommandAction_alias_1 }
206
255
 
207
256
  export declare type CommandCreator<Args extends any[] = any[]> = (...arg: Args) => Command;
208
257
 
@@ -233,12 +282,12 @@ export { createEditor as createEditor_alias_1 }
233
282
  /**
234
283
  * @internal
235
284
  */
236
- export declare function createMarkBuilders(schema: Schema, getState: () => EditorState | null | undefined, applyMark?: ApplyMarkFunction): Record<string, MarkBuilder>;
285
+ export declare function createMarkActions(schema: Schema, getState: () => EditorState | null | undefined, applyMark?: ApplyMarkFunction): Record<string, MarkAction>;
237
286
 
238
287
  /**
239
288
  * @internal
240
289
  */
241
- export declare function createNodeBuilders(schema: Schema, getState: () => EditorState | null | undefined, createNode?: CreateNodeFunction): Record<string, NodeBuilder>;
290
+ export declare function createNodeActions(schema: Schema, getState: () => EditorState | null | undefined, createNode?: CreateNodeFunction): Record<string, NodeAction>;
242
291
 
243
292
  export declare const createNodeForTest: CreateNodeFunction;
244
293
 
@@ -368,7 +417,9 @@ export { defineDefaultState as defineDefaultState_alias_1 }
368
417
  * @public
369
418
  */
370
419
  declare function defineDoc(): Extension< {
371
- Nodes: "doc";
420
+ Nodes: {
421
+ doc: Attrs_2;
422
+ };
372
423
  Marks: never;
373
424
  Commands: never;
374
425
  }>;
@@ -465,13 +516,15 @@ export { defineFocusChangeHandler as defineFocusChangeHandler_alias_1 }
465
516
 
466
517
  /**
467
518
  * Add undo/redo history to the editor.
519
+ *
520
+ * @public
468
521
  */
469
- declare function defineHistory(): Extension< {
522
+ declare function defineHistory({ depth, newGroupDelay, }?: HistoryOptions): Extension< {
470
523
  Nodes: never;
471
524
  Marks: never;
472
525
  Commands: {
473
- undo: [];
474
- redo: [];
526
+ readonly undo: [];
527
+ readonly redo: [];
475
528
  };
476
529
  }>;
477
530
  export { defineHistory }
@@ -505,15 +558,23 @@ export { defineKeyPressHandler as defineKeyPressHandler_alias_1 }
505
558
  /**
506
559
  * @public
507
560
  */
508
- declare function defineMarkAttr(options: MarkAttrOptions): Extension;
561
+ declare function defineMarkAttr<MarkType extends string = string, AttrName extends string = string, AttrType = any>(options: MarkAttrOptions<MarkType, AttrName, AttrType>): Extension<{
562
+ Nodes: never;
563
+ Marks: {
564
+ [K in MarkType]: AttrType;
565
+ };
566
+ Commands: never;
567
+ }>;
509
568
  export { defineMarkAttr }
510
569
  export { defineMarkAttr as defineMarkAttr_alias_1 }
511
570
 
512
571
  /**
513
572
  * @public
514
573
  */
515
- declare function defineMarkSpec<Mark extends string>(options: MarkSpecOptions<Mark>): Extension<{
516
- Marks: Mark;
574
+ declare function defineMarkSpec<Mark extends string, Attrs extends AnyAttrs = AnyAttrs>(options: MarkSpecOptions<Mark, Attrs>): Extension<{
575
+ Marks: {
576
+ [K in Mark]: Attrs;
577
+ };
517
578
  Nodes: never;
518
579
  Commands: never;
519
580
  }>;
@@ -534,7 +595,15 @@ export { defineMountHandler as defineMountHandler_alias_1 }
534
595
  *
535
596
  * @public
536
597
  */
537
- declare function defineNodeAttr(options: NodeAttrOptions): Extension;
598
+ declare function defineNodeAttr<NodeType extends string = string, AttrName extends string = string, AttrType = any>(options: NodeAttrOptions<NodeType, AttrName, AttrType>): Extension<{
599
+ Nodes: {
600
+ [K in NodeType]: {
601
+ [K in AttrName]: AttrType;
602
+ };
603
+ };
604
+ Marks: never;
605
+ Commands: never;
606
+ }>;
538
607
  export { defineNodeAttr }
539
608
  export { defineNodeAttr as defineNodeAttr_alias_1 }
540
609
 
@@ -543,8 +612,10 @@ export { defineNodeAttr as defineNodeAttr_alias_1 }
543
612
  *
544
613
  * @public
545
614
  */
546
- declare function defineNodeSpec<Node extends string>(options: NodeSpecOptions<Node>): Extension<{
547
- Nodes: Node;
615
+ declare function defineNodeSpec<Node extends string, Attrs extends AnyAttrs = AnyAttrs>(options: NodeSpecOptions<Node, Attrs>): Extension<{
616
+ Nodes: {
617
+ [K in Node]: Attrs;
618
+ };
548
619
  Marks: never;
549
620
  Commands: never;
550
621
  }>;
@@ -575,7 +646,9 @@ export { defineNodeViewFactory as defineNodeViewFactory_alias_1 }
575
646
  * Defines a paragraph node spec as the highest priority, because it should be the default block node for most cases.
576
647
  */
577
648
  declare function defineParagraph(): Extension< {
578
- Nodes: "paragraph";
649
+ Nodes: {
650
+ paragraph: Attrs_2;
651
+ };
579
652
  Marks: never;
580
653
  Commands: never;
581
654
  }>;
@@ -588,7 +661,9 @@ export { defineParagraph as defineParagraph_alias_1 }
588
661
  * Defines a paragraph node spec.
589
662
  */
590
663
  export declare function defineParagraphSpec(): Extension< {
591
- Nodes: "paragraph";
664
+ Nodes: {
665
+ paragraph: Attrs_2;
666
+ };
592
667
  Marks: never;
593
668
  Commands: never;
594
669
  }>;
@@ -629,8 +704,16 @@ export { defineScrollToSelectionHandler as defineScrollToSelectionHandler_alias_
629
704
  * @internal
630
705
  */
631
706
  export declare function defineTestExtension(): Extension<{
632
- Nodes: "text" | "doc" | "paragraph" | "heading";
633
- Marks: "bold" | "italic";
707
+ Nodes: SimplifyDeeper< {
708
+ paragraph: Attrs_2;
709
+ doc: Attrs_2;
710
+ text: Attrs_2;
711
+ heading: Attrs_2;
712
+ }>;
713
+ Marks: SimplifyDeeper< {
714
+ bold: Attrs_2;
715
+ italic: Attrs_2;
716
+ }>;
634
717
  Commands: {
635
718
  insertText: [{
636
719
  text: string;
@@ -647,8 +730,8 @@ export declare function defineTestExtension(): Extension<{
647
730
  removeMark: [options: RemoveMarkOptions];
648
731
  unsetBlockType: [options?: UnsetBlockTypeOptions | undefined];
649
732
  unsetMark: [options?: UnsetMarkOptions | undefined];
650
- undo: [];
651
- redo: [];
733
+ readonly undo: [];
734
+ readonly redo: [];
652
735
  };
653
736
  }>;
654
737
 
@@ -656,7 +739,9 @@ export declare function defineTestExtension(): Extension<{
656
739
  * @public
657
740
  */
658
741
  declare function defineText(): Extension< {
659
- Nodes: "text";
742
+ Nodes: {
743
+ text: Attrs_2;
744
+ };
660
745
  Marks: never;
661
746
  Commands: never;
662
747
  }>;
@@ -809,11 +894,7 @@ declare class Editor<E extends Extension = any> {
809
894
  /**
810
895
  * The editor schema.
811
896
  */
812
- get schema(): Schema<ExtractNodes<E>, ExtractMarks<E>>;
813
- /**
814
- * All commands defined by the editor.
815
- */
816
- get commands(): ExtractCommandAppliers<E>;
897
+ get schema(): Schema<ExtractNodeNames<E>, ExtractMarkNames<E>>;
817
898
  /**
818
899
  * Whether the editor is focused.
819
900
  */
@@ -853,8 +934,18 @@ declare class Editor<E extends Extension = any> {
853
934
  * directly manipulate the editor's state.
854
935
  */
855
936
  updateState(state: EditorState): void;
856
- get nodes(): Record<ExtractNodes<E>, NodeBuilder>;
857
- get marks(): Record<ExtractMarks<E>, MarkBuilder>;
937
+ /**
938
+ * All {@link CommandAction}s defined by the editor.
939
+ */
940
+ get commands(): ExtractCommandActions<E>;
941
+ /**
942
+ * All {@link NodeAction}s defined by the editor.
943
+ */
944
+ get nodes(): ExtractNodeActions<E>;
945
+ /**
946
+ * All {@link MarkAction}s defined by the editor.
947
+ */
948
+ get marks(): ExtractMarkActions<E>;
858
949
  }
859
950
  export { Editor }
860
951
  export { Editor as Editor_alias_1 }
@@ -865,9 +956,9 @@ export { Editor as Editor_alias_1 }
865
956
  export declare class EditorInstance {
866
957
  view: EditorView | null;
867
958
  schema: Schema;
868
- nodeBuilders: Record<string, NodeBuilder>;
869
- markBuilders: Record<string, MarkBuilder>;
870
- commandAppliers: Record<string, CommandApplier>;
959
+ nodes: Record<string, NodeAction>;
960
+ marks: Record<string, MarkAction>;
961
+ commands: Record<string, CommandAction>;
871
962
  private tree;
872
963
  private directEditorProps;
873
964
  constructor(extension: Extension);
@@ -986,7 +1077,7 @@ export { Extension as Extension_alias_1 }
986
1077
  /**
987
1078
  * @internal
988
1079
  */
989
- declare interface ExtensionTyping<N extends string | never = never, M extends string | never = never, C extends CommandTyping | never = never> {
1080
+ declare interface ExtensionTyping<N extends NodeTyping | never = never, M extends MarkTyping | never = never, C extends CommandTyping | never = never> {
990
1081
  Nodes: N;
991
1082
  Marks: M;
992
1083
  Commands: C;
@@ -995,9 +1086,18 @@ export { ExtensionTyping }
995
1086
  export { ExtensionTyping as ExtensionTyping_alias_1 }
996
1087
 
997
1088
  /**
1089
+ * Extracts the {@link CommandAction}s from an extension type.
1090
+ *
998
1091
  * @public
999
1092
  */
1000
- declare type ExtractCommandAppliers<E extends Extension> = ToCommandApplier<ExtractCommands<E>>;
1093
+ declare type ExtractCommandActions<E extends Extension> = ToCommandAction<ExtractCommands<E>>;
1094
+ export { ExtractCommandActions }
1095
+ export { ExtractCommandActions as ExtractCommandActions_alias_1 }
1096
+
1097
+ /**
1098
+ * @deprecated Use `ExtractCommandActions` instead.
1099
+ */
1100
+ declare type ExtractCommandAppliers<E extends Extension> = ExtractCommandActions<E>;
1001
1101
  export { ExtractCommandAppliers }
1002
1102
  export { ExtractCommandAppliers as ExtractCommandAppliers_alias_1 }
1003
1103
 
@@ -1013,17 +1113,45 @@ export { ExtractCommandCreators as ExtractCommandCreators_alias_1 }
1013
1113
  */
1014
1114
  export declare type ExtractCommands<E extends Extension> = SimplifyUnion<ExtractTyping<E>['Commands']>;
1015
1115
 
1116
+ /**
1117
+ * Extracts the {@link MarkAction}s from an extension type.
1118
+ *
1119
+ * @public
1120
+ */
1121
+ declare type ExtractMarkActions<E extends Extension> = ToMarkAction<ExtractMarks<E>>;
1122
+ export { ExtractMarkActions }
1123
+ export { ExtractMarkActions as ExtractMarkActions_alias_1 }
1124
+
1016
1125
  /**
1017
1126
  * @public
1018
1127
  */
1019
- declare type ExtractMarks<E extends Extension> = ExtractTyping<E>['Marks'];
1128
+ export declare type ExtractMarkNames<E extends Extension> = PickStringLiteral<keyof ExtractMarks<E>>;
1129
+
1130
+ /**
1131
+ * @public
1132
+ */
1133
+ declare type ExtractMarks<E extends Extension> = SimplifyDeeper<SimplifyUnion<ExtractTyping<E>['Marks']>>;
1020
1134
  export { ExtractMarks }
1021
1135
  export { ExtractMarks as ExtractMarks_alias_1 }
1022
1136
 
1137
+ /**
1138
+ * Extracts the {@link NodeAction}s from an extension type.
1139
+ *
1140
+ * @public
1141
+ */
1142
+ declare type ExtractNodeActions<E extends Extension> = ToNodeAction<ExtractNodes<E>>;
1143
+ export { ExtractNodeActions }
1144
+ export { ExtractNodeActions as ExtractNodeActions_alias_1 }
1145
+
1146
+ /**
1147
+ * @public
1148
+ */
1149
+ export declare type ExtractNodeNames<E extends Extension> = PickStringLiteral<keyof ExtractNodes<E>>;
1150
+
1023
1151
  /**
1024
1152
  * @public
1025
1153
  */
1026
- declare type ExtractNodes<E extends Extension> = ExtractTyping<E>['Nodes'];
1154
+ declare type ExtractNodes<E extends Extension> = SimplifyDeeper<SimplifyUnion<ExtractTyping<E>['Nodes']>>;
1027
1155
  export { ExtractNodes }
1028
1156
  export { ExtractNodes as ExtractNodes_alias_1 }
1029
1157
 
@@ -1032,7 +1160,7 @@ export declare function extractTags(node: TaggedProseMirrorNode): Record<string,
1032
1160
  /**
1033
1161
  * @internal
1034
1162
  */
1035
- export declare type ExtractTyping<E extends Extension> = E extends Extension<ExtensionTyping<infer N, infer M, infer C>> ? ExtensionTyping<PickStringLiteral<N>, PickStringLiteral<M>, PickKnownCommandTyping<C>> : never;
1163
+ export declare type ExtractTyping<E extends Extension> = E extends Extension<ExtensionTyping<infer N, infer M, infer C>> ? ExtensionTyping<PickSubType<N, NodeTyping>, PickSubType<M, MarkTyping>, PickSubType<C, CommandTyping>> : never;
1036
1164
 
1037
1165
  /**
1038
1166
  * @internal
@@ -1171,6 +1299,30 @@ export declare type GroupedEntries<T extends Record<string, any>> = {
1171
1299
 
1172
1300
  export declare function groupEntries<T extends Record<string, any>>(entries: ObjectEntries<T>[]): GroupedEntries<T>;
1173
1301
 
1302
+ /**
1303
+ * Options for {@link defineHistory}.
1304
+ *
1305
+ * @public
1306
+ */
1307
+ declare interface HistoryOptions {
1308
+ /**
1309
+ * The amount of history events that are collected before the oldest events
1310
+ * are discarded.
1311
+ *
1312
+ * @default 200
1313
+ */
1314
+ depth?: number;
1315
+ /**
1316
+ * The delay in milliseconds between changes after which a new group should be
1317
+ * started.
1318
+ *
1319
+ * @default 250
1320
+ */
1321
+ newGroupDelay?: number;
1322
+ }
1323
+ export { HistoryOptions }
1324
+ export { HistoryOptions as HistoryOptions_alias_1 }
1325
+
1174
1326
  /**
1175
1327
  * @internal
1176
1328
  */
@@ -1401,23 +1553,39 @@ export { KeyPressHandler }
1401
1553
  export { KeyPressHandler as KeyPressHandler_alias_1 }
1402
1554
 
1403
1555
  /**
1556
+ * A function for creating a mark with optional attributes and any number of
1557
+ * children.
1558
+ *
1559
+ * It also has a `isActive` method for checking if the mark is active in the
1560
+ * current editor selection.
1561
+ *
1404
1562
  * @public
1405
1563
  */
1406
- declare interface MarkAttrOptions {
1564
+ declare interface MarkAction<Attrs extends AnyAttrs = AnyAttrs> {
1565
+ (attrs: Attrs | null, ...children: NodeChild[]): ProseMirrorNode[];
1566
+ (...children: NodeChild[]): ProseMirrorNode[];
1407
1567
  /**
1408
- * The name of the mark type.
1568
+ * Checks if the mark is active in the current editor selection. If the
1569
+ * optional `attrs` parameter is provided, it will check if the mark is active
1570
+ * with the given attributes.
1409
1571
  */
1410
- type: string;
1572
+ isActive: (attrs?: Attrs) => boolean;
1573
+ }
1574
+ export { MarkAction }
1575
+ export { MarkAction as MarkAction_alias_1 }
1576
+
1577
+ /**
1578
+ * @public
1579
+ */
1580
+ declare interface MarkAttrOptions<MarkName extends string = string, AttrName extends string = string, AttrType = any> extends AttrSpec<AttrType> {
1411
1581
  /**
1412
- * The name of the attribute.
1582
+ * The name of the mark type.
1413
1583
  */
1414
- attr: string;
1584
+ type: MarkName;
1415
1585
  /**
1416
- * The default value for this attribute, to use when no explicit value is
1417
- * provided. Attributes that have no default must be provided whenever a mark
1418
- * of a type that has them is created.
1586
+ * The name of the attribute.
1419
1587
  */
1420
- default?: any;
1588
+ attr: AttrName;
1421
1589
  /**
1422
1590
  * Returns the attribute key and value to be set on the DOM node.
1423
1591
  */
@@ -1431,25 +1599,39 @@ export { MarkAttrOptions }
1431
1599
  export { MarkAttrOptions as MarkAttrOptions_alias_1 }
1432
1600
 
1433
1601
  /**
1434
- * @public
1602
+ * @deprecated Use type {@link MarkAction} instead.
1435
1603
  */
1436
- declare interface MarkBuilder {
1437
- (attrs: Attrs | null, ...children: NodeChild[]): ProseMirrorNode[];
1438
- (...children: NodeChild[]): ProseMirrorNode[];
1439
- isActive: (attrs?: Attrs) => boolean;
1440
- }
1604
+ declare type MarkBuilder = MarkAction;
1441
1605
  export { MarkBuilder }
1442
1606
  export { MarkBuilder as MarkBuilder_alias_1 }
1443
1607
 
1444
1608
  /**
1445
1609
  * @public
1446
1610
  */
1447
- declare interface MarkSpecOptions<MarkName extends string = string> extends MarkSpec {
1611
+ declare interface MarkSpecOptions<MarkName extends string = string, Attrs extends AnyAttrs = AnyAttrs> extends MarkSpec {
1612
+ /**
1613
+ * The name of the mark type.
1614
+ */
1448
1615
  name: MarkName;
1616
+ /**
1617
+ * The attributes that marks of this type get.
1618
+ */
1619
+ attrs?: {
1620
+ [K in keyof Attrs]: AttrSpec<Attrs[K]>;
1621
+ };
1449
1622
  }
1450
1623
  export { MarkSpecOptions }
1451
1624
  export { MarkSpecOptions as MarkSpecOptions_alias_1 }
1452
1625
 
1626
+ /**
1627
+ * @internal
1628
+ */
1629
+ declare interface MarkTyping {
1630
+ [name: string]: Record<string, any>;
1631
+ }
1632
+ export { MarkTyping }
1633
+ export { MarkTyping as MarkTyping_alias_1 }
1634
+
1453
1635
  /**
1454
1636
  * @internal
1455
1637
  */
@@ -1469,23 +1651,39 @@ export { MountHandler }
1469
1651
  export { MountHandler as MountHandler_alias_1 }
1470
1652
 
1471
1653
  /**
1654
+ * A function for creating a node with optional attributes and any number of
1655
+ * children.
1656
+ *
1657
+ * It also has a `isActive` method for checking if the node is active in the
1658
+ * current editor selection.
1659
+ *
1472
1660
  * @public
1473
1661
  */
1474
- declare interface NodeAttrOptions {
1662
+ declare interface NodeAction<Attrs extends AnyAttrs = AnyAttrs> {
1663
+ (attrs: Attrs | null, ...children: NodeChild[]): ProseMirrorNode;
1664
+ (...children: NodeChild[]): ProseMirrorNode;
1475
1665
  /**
1476
- * The name of the node type.
1666
+ * Checks if the node is active in the current editor selection. If the
1667
+ * optional `attrs` parameter is provided, it will check if the node is active
1668
+ * with the given attributes.
1477
1669
  */
1478
- type: string;
1670
+ isActive: (attrs?: Attrs) => boolean;
1671
+ }
1672
+ export { NodeAction }
1673
+ export { NodeAction as NodeAction_alias_1 }
1674
+
1675
+ /**
1676
+ * @public
1677
+ */
1678
+ declare interface NodeAttrOptions<NodeName extends string = string, AttrName extends string = string, AttrType = any> extends AttrSpec<AttrType> {
1479
1679
  /**
1480
- * The name of the attribute.
1680
+ * The name of the node type.
1481
1681
  */
1482
- attr: string;
1682
+ type: NodeName;
1483
1683
  /**
1484
- * The default value for this attribute, to use when no explicit value is
1485
- * provided. Attributes that have no default must be provided whenever a node
1486
- * of a type that has them is created.
1684
+ * The name of the attribute.
1487
1685
  */
1488
- default?: any;
1686
+ attr: AttrName;
1489
1687
  /**
1490
1688
  * Whether the attribute should be kept when the node is split. Set it to
1491
1689
  * `true` if you want to inherit the attribute from the previous node when
@@ -1510,20 +1708,20 @@ export { NodeAttrOptions }
1510
1708
  export { NodeAttrOptions as NodeAttrOptions_alias_1 }
1511
1709
 
1512
1710
  /**
1513
- * @public
1711
+ * @deprecated Use type {@link NodeAction} instead.
1514
1712
  */
1515
- declare interface NodeBuilder {
1516
- (attrs: Attrs | null, ...children: NodeChild[]): ProseMirrorNode;
1517
- (...children: NodeChild[]): ProseMirrorNode;
1518
- isActive: (attrs?: Attrs) => boolean;
1519
- }
1713
+ declare type NodeBuilder = NodeAction;
1520
1714
  export { NodeBuilder }
1521
1715
  export { NodeBuilder as NodeBuilder_alias_1 }
1522
1716
 
1523
1717
  /**
1718
+ * Available children parameters for {@link NodeAction} and {@link MarkAction}.
1719
+ *
1524
1720
  * @public
1525
1721
  */
1526
- export declare type NodeChild = ProseMirrorNode | string | NodeChild[];
1722
+ declare type NodeChild = ProseMirrorNode | string | NodeChild[];
1723
+ export { NodeChild }
1724
+ export { NodeChild as NodeChild_alias_1 }
1527
1725
 
1528
1726
  /**
1529
1727
  * @public
@@ -1577,13 +1775,35 @@ export { NodeJSON as NodeJSON_alias_1 }
1577
1775
  /**
1578
1776
  * @public
1579
1777
  */
1580
- declare interface NodeSpecOptions<NodeName extends string = string> extends NodeSpec {
1778
+ declare interface NodeSpecOptions<NodeName extends string = string, Attrs extends AnyAttrs = AnyAttrs> extends NodeSpec {
1779
+ /**
1780
+ * The name of the node type.
1781
+ */
1581
1782
  name: NodeName;
1783
+ /**
1784
+ * Whether this is the top-level node type. Only one node type can be the
1785
+ * top-level node type in a schema.
1786
+ */
1582
1787
  topNode?: boolean;
1788
+ /**
1789
+ * The attributes that nodes of this type get.
1790
+ */
1791
+ attrs?: {
1792
+ [key in keyof Attrs]: AttrSpec<Attrs[key]>;
1793
+ };
1583
1794
  }
1584
1795
  export { NodeSpecOptions }
1585
1796
  export { NodeSpecOptions as NodeSpecOptions_alias_1 }
1586
1797
 
1798
+ /**
1799
+ * @internal
1800
+ */
1801
+ declare interface NodeTyping {
1802
+ [name: string]: Record<string, any>;
1803
+ }
1804
+ export { NodeTyping }
1805
+ export { NodeTyping as NodeTyping_alias_1 }
1806
+
1587
1807
  /**
1588
1808
  * @internal
1589
1809
  */
@@ -1648,14 +1868,14 @@ export declare type Payloads<T> = Tuple5<T[]>;
1648
1868
  /**
1649
1869
  * @internal
1650
1870
  */
1651
- export declare type PickKnownCommandTyping<T extends CommandTyping> = [
1652
- CommandTyping
1653
- ] extends [T] ? never : T;
1871
+ export declare type PickStringLiteral<T> = PickSubType<T, string>;
1654
1872
 
1655
1873
  /**
1656
1874
  * @internal
1657
1875
  */
1658
- export declare type PickStringLiteral<T extends string> = [string] extends [T] ? never : T;
1876
+ declare type PickSubType<Type, ParentType> = Type extends ParentType ? [ParentType] extends [Type] ? never : Type : never;
1877
+ export { PickSubType }
1878
+ export { PickSubType as PickSubType_alias_1 }
1659
1879
 
1660
1880
  /**
1661
1881
  * @internal
@@ -1873,8 +2093,16 @@ export declare function setupEditorExtension<E extends Extension>(options: Edito
1873
2093
  */
1874
2094
  export declare function setupTest(): {
1875
2095
  editor: TestEditor<Extension<{
1876
- Nodes: "text" | "doc" | "paragraph" | "heading";
1877
- Marks: "bold" | "italic";
2096
+ Nodes: SimplifyDeeper< {
2097
+ paragraph: Attrs_2;
2098
+ doc: Attrs_2;
2099
+ text: Attrs_2;
2100
+ heading: Attrs_2;
2101
+ }>;
2102
+ Marks: SimplifyDeeper< {
2103
+ bold: Attrs_2;
2104
+ italic: Attrs_2;
2105
+ }>;
1878
2106
  Commands: {
1879
2107
  insertText: [{
1880
2108
  text: string;
@@ -1891,12 +2119,32 @@ export declare function setupTest(): {
1891
2119
  removeMark: [options: RemoveMarkOptions];
1892
2120
  unsetBlockType: [options?: UnsetBlockTypeOptions | undefined];
1893
2121
  unsetMark: [options?: UnsetMarkOptions | undefined];
1894
- undo: [];
1895
- redo: [];
2122
+ readonly undo: [];
2123
+ readonly redo: [];
1896
2124
  };
1897
2125
  }>>;
1898
- n: Record<"text" | "doc" | "paragraph" | "heading", NodeBuilder>;
1899
- m: Record<"bold" | "italic", MarkBuilder>;
2126
+ n: ToNodeAction<SimplifyDeeper< {
2127
+ paragraph: {
2128
+ readonly [x: string]: any;
2129
+ };
2130
+ doc: {
2131
+ readonly [x: string]: any;
2132
+ };
2133
+ text: {
2134
+ readonly [x: string]: any;
2135
+ };
2136
+ heading: {
2137
+ readonly [x: string]: any;
2138
+ };
2139
+ }>>;
2140
+ m: ToMarkAction<SimplifyDeeper< {
2141
+ bold: {
2142
+ readonly [x: string]: any;
2143
+ };
2144
+ italic: {
2145
+ readonly [x: string]: any;
2146
+ };
2147
+ }>>;
1900
2148
  };
1901
2149
 
1902
2150
  /**
@@ -1904,9 +2152,18 @@ export declare function setupTest(): {
1904
2152
  */
1905
2153
  export declare function setupTestFromExtension<E extends Extension>(extension: E): {
1906
2154
  editor: TestEditor<E>;
1907
- n: Record<ExtractNodes<E>, NodeBuilder>;
1908
- m: Record<ExtractMarks<E>, MarkBuilder>;
2155
+ n: ExtractNodeActions<E>;
2156
+ m: ExtractMarkActions<E>;
2157
+ };
2158
+
2159
+ /**
2160
+ * @internal
2161
+ */
2162
+ declare type SimplifyDeeper<T> = {
2163
+ [KeyType in keyof T]: Simplify<T[KeyType]>;
1909
2164
  };
2165
+ export { SimplifyDeeper }
2166
+ export { SimplifyDeeper as SimplifyDeeper_alias_1 }
1910
2167
 
1911
2168
  /**
1912
2169
  * @internal
@@ -2008,8 +2265,8 @@ declare type TextInputHandler = (view: EditorView, from: number, to: number, tex
2008
2265
  export { TextInputHandler }
2009
2266
  export { TextInputHandler as TextInputHandler_alias_1 }
2010
2267
 
2011
- export declare type ToCommandApplier<T extends CommandTyping> = {
2012
- [K in keyof T]: CommandApplier<T[K]>;
2268
+ export declare type ToCommandAction<T extends CommandTyping> = {
2269
+ [K in keyof T]: CommandAction<T[K]>;
2013
2270
  };
2014
2271
 
2015
2272
  export declare type ToCommandCreators<T extends CommandTyping> = {
@@ -2061,6 +2318,24 @@ declare interface ToggleNodeOptions {
2061
2318
  export { ToggleNodeOptions }
2062
2319
  export { ToggleNodeOptions as ToggleNodeOptions_alias_1 }
2063
2320
 
2321
+ /**
2322
+ * @internal
2323
+ */
2324
+ declare type ToMarkAction<T extends MarkTyping> = {
2325
+ [K in keyof T]: MarkAction<T[K]>;
2326
+ };
2327
+ export { ToMarkAction }
2328
+ export { ToMarkAction as ToMarkAction_alias_1 }
2329
+
2330
+ /**
2331
+ * @internal
2332
+ */
2333
+ declare type ToNodeAction<T extends NodeTyping> = {
2334
+ [K in keyof T]: NodeAction<T[K]>;
2335
+ };
2336
+ export { ToNodeAction }
2337
+ export { ToNodeAction as ToNodeAction_alias_1 }
2338
+
2064
2339
  export declare function toReversed<T>(arr: T[]): T[];
2065
2340
 
2066
2341
  declare type TripleClickHandler = (view: EditorView, pos: number, event: MouseEvent) => boolean | void;