@prosekit/core 0.0.0-next-20240715071354 → 0.0.0-next-20240724172520

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,59 @@ 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
+
151
+ /**
152
+ * @internal
153
+ */
154
+ declare type BaseCommandsExtension = Extension<{
155
+ Commands: {
156
+ insertText: [options: InsertTextOptions];
157
+ insertNode: [options: InsertNodeOptions];
158
+ removeNode: [options: RemoveNodeOptions];
159
+ wrap: [options: WrapOptions];
160
+ setBlockType: [options: SetBlockTypeOptions];
161
+ setNodeAttrs: [options: SetNodeAttrsOptions];
162
+ selectAll: [];
163
+ addMark: [options: AddMarkOptions];
164
+ removeMark: [options: RemoveMarkOptions];
165
+ unsetBlockType: [options?: UnsetBlockTypeOptions];
166
+ unsetMark: [options?: UnsetMarkOptions];
167
+ };
168
+ }>;
169
+ export { BaseCommandsExtension }
170
+ export { BaseCommandsExtension as BaseCommandsExtension_alias_1 }
171
+
111
172
  /**
112
173
  * @internal
113
174
  */
@@ -131,6 +192,17 @@ export declare abstract class BaseExtension<T extends ExtensionTyping = Extensio
131
192
  get schema(): Schema | null;
132
193
  }
133
194
 
195
+ /**
196
+ * @internal
197
+ */
198
+ declare type BaseKeymapExtension = Extension<{
199
+ Nodes: never;
200
+ Commands: never;
201
+ Keymap: never;
202
+ }>;
203
+ export { BaseKeymapExtension }
204
+ export { BaseKeymapExtension as BaseKeymapExtension_alias_1 }
205
+
134
206
  /**
135
207
  * Some basic props for custom node views.
136
208
  *
@@ -199,10 +271,19 @@ export { collectNodes as collectNodes_alias_1 }
199
271
 
200
272
  export declare function combineEventHandlers<Handler extends (...args: any[]) => boolean | void, Args extends Parameters<Handler> = Parameters<Handler>>(): readonly [(handlers: Handler[]) => void, (...args: Args) => boolean];
201
273
 
202
- export declare interface CommandApplier<Args extends any[] = any[]> {
274
+ /**
275
+ * A function to apply a command to the editor. It will return `true` if the command was applied, and `false` otherwise.
276
+ *
277
+ * It also has a `canApply` method to check if the command can be applied.
278
+ *
279
+ * @public
280
+ */
281
+ declare interface CommandAction<Args extends any[] = any[]> {
203
282
  (...args: Args): boolean;
204
283
  canApply(...args: Args): boolean;
205
284
  }
285
+ export { CommandAction }
286
+ export { CommandAction as CommandAction_alias_1 }
206
287
 
207
288
  export declare type CommandCreator<Args extends any[] = any[]> = (...arg: Args) => Command;
208
289
 
@@ -223,6 +304,13 @@ declare interface CommandTyping {
223
304
  export { CommandTyping }
224
305
  export { CommandTyping as CommandTyping_alias_1 }
225
306
 
307
+ /**
308
+ * @internal
309
+ */
310
+ declare function containsInlineNode(doc: ProseMirrorNode, from: number, to: number): boolean;
311
+ export { containsInlineNode }
312
+ export { containsInlineNode as containsInlineNode_alias_1 }
313
+
226
314
  /**
227
315
  * @public
228
316
  */
@@ -233,12 +321,12 @@ export { createEditor as createEditor_alias_1 }
233
321
  /**
234
322
  * @internal
235
323
  */
236
- export declare function createMarkBuilders(schema: Schema, getState: () => EditorState | null | undefined, applyMark?: ApplyMarkFunction): Record<string, MarkBuilder>;
324
+ export declare function createMarkActions(schema: Schema, getState: () => EditorState | null | undefined, applyMark?: ApplyMarkFunction): Record<string, MarkAction>;
237
325
 
238
326
  /**
239
327
  * @internal
240
328
  */
241
- export declare function createNodeBuilders(schema: Schema, getState: () => EditorState | null | undefined, createNode?: CreateNodeFunction): Record<string, NodeBuilder>;
329
+ export declare function createNodeActions(schema: Schema, getState: () => EditorState | null | undefined, createNode?: CreateNodeFunction): Record<string, NodeAction>;
242
330
 
243
331
  export declare const createNodeForTest: CreateNodeFunction;
244
332
 
@@ -292,27 +380,7 @@ export { DefaultStateOptions as DefaultStateOptions_alias_1 }
292
380
  *
293
381
  * @public
294
382
  */
295
- declare function defineBaseCommands(): Extension<{
296
- Commands: {
297
- insertText: [{
298
- text: string;
299
- from?: number;
300
- to?: number;
301
- }];
302
- insertNode: [options: InsertNodeOptions];
303
- removeNode: [options: RemoveNodeOptions];
304
- wrap: [WrapOptions];
305
- setBlockType: [options: SetBlockTypeOptions];
306
- setNodeAttrs: [options: SetNodeAttrsOptions];
307
- selectAll: [];
308
- addMark: [options: AddMarkOptions];
309
- removeMark: [options: RemoveMarkOptions];
310
- unsetBlockType: [options?: UnsetBlockTypeOptions | undefined];
311
- unsetMark: [options?: UnsetMarkOptions | undefined];
312
- };
313
- Nodes: never;
314
- Marks: never;
315
- }>;
383
+ declare function defineBaseCommands(): BaseCommandsExtension;
316
384
  export { defineBaseCommands }
317
385
  export { defineBaseCommands as defineBaseCommands_alias_1 }
318
386
 
@@ -328,7 +396,7 @@ declare function defineBaseKeymap(options?: {
328
396
  * @default Priority.low
329
397
  */
330
398
  priority?: Priority;
331
- }): Extension<ExtensionTyping<any, any, any>>;
399
+ }): BaseKeymapExtension;
332
400
  export { defineBaseKeymap }
333
401
  export { defineBaseKeymap as defineBaseKeymap_alias_1 }
334
402
 
@@ -354,8 +422,6 @@ declare function defineCommands<T extends Record<string, CommandCreator> = Recor
354
422
  Commands: {
355
423
  [K in keyof T]: Parameters<T[K]>;
356
424
  };
357
- Nodes: never;
358
- Marks: never;
359
425
  }>;
360
426
  export { defineCommands }
361
427
  export { defineCommands as defineCommands_alias_1 }
@@ -367,11 +433,7 @@ export { defineDefaultState as defineDefaultState_alias_1 }
367
433
  /**
368
434
  * @public
369
435
  */
370
- declare function defineDoc(): Extension< {
371
- Nodes: "doc";
372
- Marks: never;
373
- Commands: never;
374
- }>;
436
+ declare function defineDoc(): DocExtension;
375
437
  export { defineDoc }
376
438
  export { defineDoc as defineDoc_alias_1 }
377
439
 
@@ -468,14 +530,7 @@ export { defineFocusChangeHandler as defineFocusChangeHandler_alias_1 }
468
530
  *
469
531
  * @public
470
532
  */
471
- declare function defineHistory({ depth, newGroupDelay, }?: HistoryOptions): Extension< {
472
- Nodes: never;
473
- Marks: never;
474
- Commands: {
475
- readonly undo: [];
476
- readonly redo: [];
477
- };
478
- }>;
533
+ declare function defineHistory({ depth, newGroupDelay, }?: HistoryOptions): HistoryExtension;
479
534
  export { defineHistory }
480
535
  export { defineHistory as defineHistory_alias_1 }
481
536
 
@@ -507,17 +562,21 @@ export { defineKeyPressHandler as defineKeyPressHandler_alias_1 }
507
562
  /**
508
563
  * @public
509
564
  */
510
- declare function defineMarkAttr(options: MarkAttrOptions): Extension;
565
+ declare function defineMarkAttr<MarkType extends string = string, AttrName extends string = string, AttrType = any>(options: MarkAttrOptions<MarkType, AttrName, AttrType>): Extension<{
566
+ Marks: {
567
+ [K in MarkType]: AttrType;
568
+ };
569
+ }>;
511
570
  export { defineMarkAttr }
512
571
  export { defineMarkAttr as defineMarkAttr_alias_1 }
513
572
 
514
573
  /**
515
574
  * @public
516
575
  */
517
- declare function defineMarkSpec<Mark extends string>(options: MarkSpecOptions<Mark>): Extension<{
518
- Marks: Mark;
519
- Nodes: never;
520
- Commands: never;
576
+ declare function defineMarkSpec<Mark extends string, Attrs extends AnyAttrs = AnyAttrs>(options: MarkSpecOptions<Mark, Attrs>): Extension<{
577
+ Marks: {
578
+ [K in Mark]: Attrs;
579
+ };
521
580
  }>;
522
581
  export { defineMarkSpec }
523
582
  export { defineMarkSpec as defineMarkSpec_alias_1 }
@@ -536,7 +595,13 @@ export { defineMountHandler as defineMountHandler_alias_1 }
536
595
  *
537
596
  * @public
538
597
  */
539
- 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
+ }>;
540
605
  export { defineNodeAttr }
541
606
  export { defineNodeAttr as defineNodeAttr_alias_1 }
542
607
 
@@ -545,10 +610,10 @@ export { defineNodeAttr as defineNodeAttr_alias_1 }
545
610
  *
546
611
  * @public
547
612
  */
548
- declare function defineNodeSpec<Node extends string>(options: NodeSpecOptions<Node>): Extension<{
549
- Nodes: Node;
550
- Marks: never;
551
- Commands: never;
613
+ declare function defineNodeSpec<Node extends string, Attrs extends AnyAttrs = AnyAttrs>(options: NodeSpecOptions<Node, Attrs>): Extension<{
614
+ Nodes: {
615
+ [K in Node]: Attrs;
616
+ };
552
617
  }>;
553
618
  export { defineNodeSpec }
554
619
  export { defineNodeSpec as defineNodeSpec_alias_1 }
@@ -576,11 +641,7 @@ export { defineNodeViewFactory as defineNodeViewFactory_alias_1 }
576
641
  *
577
642
  * Defines a paragraph node spec as the highest priority, because it should be the default block node for most cases.
578
643
  */
579
- declare function defineParagraph(): Extension< {
580
- Nodes: "paragraph";
581
- Marks: never;
582
- Commands: never;
583
- }>;
644
+ declare function defineParagraph(): ParagraphExtension;
584
645
  export { defineParagraph }
585
646
  export { defineParagraph as defineParagraph_alias_1 }
586
647
 
@@ -589,11 +650,7 @@ export { defineParagraph as defineParagraph_alias_1 }
589
650
  *
590
651
  * Defines a paragraph node spec.
591
652
  */
592
- export declare function defineParagraphSpec(): Extension< {
593
- Nodes: "paragraph";
594
- Marks: never;
595
- Commands: never;
596
- }>;
653
+ export declare function defineParagraphSpec(): ParagraphSpecExtension;
597
654
 
598
655
  /**
599
656
  * @public
@@ -614,7 +671,7 @@ export { definePasteHandler as definePasteHandler_alias_1 }
614
671
  */
615
672
  declare function definePlugin(plugin: Plugin_2 | Plugin_2[] | ((context: {
616
673
  schema: Schema;
617
- }) => Plugin_2 | Plugin_2[])): Extension;
674
+ }) => Plugin_2 | Plugin_2[])): PluginExtension;
618
675
  export { definePlugin }
619
676
  export { definePlugin as definePlugin_alias_1 }
620
677
 
@@ -630,38 +687,34 @@ export { defineScrollToSelectionHandler as defineScrollToSelectionHandler_alias_
630
687
  /**
631
688
  * @internal
632
689
  */
633
- export declare function defineTestExtension(): Extension<{
634
- Nodes: "text" | "doc" | "paragraph" | "heading";
635
- Marks: "bold" | "italic";
636
- Commands: {
637
- insertText: [{
638
- text: string;
639
- from?: number;
640
- to?: number;
641
- }];
642
- insertNode: [options: InsertNodeOptions];
643
- removeNode: [options: RemoveNodeOptions];
644
- wrap: [WrapOptions];
645
- setBlockType: [options: SetBlockTypeOptions];
646
- setNodeAttrs: [options: SetNodeAttrsOptions];
647
- selectAll: [];
648
- addMark: [options: AddMarkOptions];
649
- removeMark: [options: RemoveMarkOptions];
650
- unsetBlockType: [options?: UnsetBlockTypeOptions | undefined];
651
- unsetMark: [options?: UnsetMarkOptions | undefined];
652
- readonly undo: [];
653
- readonly redo: [];
654
- };
655
- }>;
690
+ export declare function defineTestExtension(): Union<readonly [BaseCommandsExtension, BaseKeymapExtension, DocExtension, HistoryExtension, Extension<{
691
+ Nodes: {
692
+ paragraph: Attrs_2;
693
+ };
694
+ }>, TextExtension, Extension<{
695
+ Marks: {
696
+ bold: Attrs_2;
697
+ };
698
+ }>, Extension<{
699
+ Marks: {
700
+ italic: Attrs_2;
701
+ };
702
+ }>, Extension<{
703
+ Nodes: {
704
+ heading: Attrs_2;
705
+ };
706
+ }>, Extension<{
707
+ Nodes: {
708
+ codeBlock: {
709
+ language: string;
710
+ };
711
+ };
712
+ }>]>;
656
713
 
657
714
  /**
658
715
  * @public
659
716
  */
660
- declare function defineText(): Extension< {
661
- Nodes: "text";
662
- Marks: never;
663
- Commands: never;
664
- }>;
717
+ declare function defineText(): TextExtension;
665
718
  export { defineText }
666
719
  export { defineText as defineText_alias_1 }
667
720
 
@@ -722,6 +775,17 @@ declare type DocChangeHandler = (view: EditorView, prevState: EditorState) => vo
722
775
  export { DocChangeHandler }
723
776
  export { DocChangeHandler as DocChangeHandler_alias_1 }
724
777
 
778
+ /**
779
+ * @internal
780
+ */
781
+ declare type DocExtension = Extension<{
782
+ Nodes: {
783
+ doc: Attrs;
784
+ };
785
+ }>;
786
+ export { DocExtension }
787
+ export { DocExtension as DocExtension_alias_1 }
788
+
725
789
  /**
726
790
  * @internal
727
791
  */
@@ -811,11 +875,7 @@ declare class Editor<E extends Extension = any> {
811
875
  /**
812
876
  * The editor schema.
813
877
  */
814
- get schema(): Schema<ExtractNodes<E>, ExtractMarks<E>>;
815
- /**
816
- * All commands defined by the editor.
817
- */
818
- get commands(): ExtractCommandAppliers<E>;
878
+ get schema(): Schema<ExtractNodeNames<E>, ExtractMarkNames<E>>;
819
879
  /**
820
880
  * Whether the editor is focused.
821
881
  */
@@ -855,8 +915,18 @@ declare class Editor<E extends Extension = any> {
855
915
  * directly manipulate the editor's state.
856
916
  */
857
917
  updateState(state: EditorState): void;
858
- get nodes(): Record<ExtractNodes<E>, NodeBuilder>;
859
- get marks(): Record<ExtractMarks<E>, MarkBuilder>;
918
+ /**
919
+ * All {@link CommandAction}s defined by the editor.
920
+ */
921
+ get commands(): ExtractCommandActions<E>;
922
+ /**
923
+ * All {@link NodeAction}s defined by the editor.
924
+ */
925
+ get nodes(): ExtractNodeActions<E>;
926
+ /**
927
+ * All {@link MarkAction}s defined by the editor.
928
+ */
929
+ get marks(): ExtractMarkActions<E>;
860
930
  }
861
931
  export { Editor }
862
932
  export { Editor as Editor_alias_1 }
@@ -867,9 +937,9 @@ export { Editor as Editor_alias_1 }
867
937
  export declare class EditorInstance {
868
938
  view: EditorView | null;
869
939
  schema: Schema;
870
- nodeBuilders: Record<string, NodeBuilder>;
871
- markBuilders: Record<string, MarkBuilder>;
872
- commandAppliers: Record<string, CommandApplier>;
940
+ nodes: Record<string, NodeAction>;
941
+ marks: Record<string, MarkAction>;
942
+ commands: Record<string, CommandAction>;
873
943
  private tree;
874
944
  private directEditorProps;
875
945
  constructor(extension: Extension);
@@ -988,18 +1058,27 @@ export { Extension as Extension_alias_1 }
988
1058
  /**
989
1059
  * @internal
990
1060
  */
991
- declare interface ExtensionTyping<N extends string | never = never, M extends string | never = never, C extends CommandTyping | never = never> {
992
- Nodes: N;
993
- Marks: M;
994
- Commands: C;
1061
+ declare interface ExtensionTyping<N extends NodeTyping | never = never, M extends MarkTyping | never = never, C extends CommandTyping | never = never> {
1062
+ Nodes?: N;
1063
+ Marks?: M;
1064
+ Commands?: C;
995
1065
  }
996
1066
  export { ExtensionTyping }
997
1067
  export { ExtensionTyping as ExtensionTyping_alias_1 }
998
1068
 
999
1069
  /**
1070
+ * Extracts the {@link CommandAction}s from an extension type.
1071
+ *
1000
1072
  * @public
1001
1073
  */
1002
- declare type ExtractCommandAppliers<E extends Extension> = ToCommandApplier<ExtractCommands<E>>;
1074
+ declare type ExtractCommandActions<E extends Extension> = ToCommandAction<ExtractCommands<E>>;
1075
+ export { ExtractCommandActions }
1076
+ export { ExtractCommandActions as ExtractCommandActions_alias_1 }
1077
+
1078
+ /**
1079
+ * @deprecated Use `ExtractCommandActions` instead.
1080
+ */
1081
+ declare type ExtractCommandAppliers<E extends Extension> = ExtractCommandActions<E>;
1003
1082
  export { ExtractCommandAppliers }
1004
1083
  export { ExtractCommandAppliers as ExtractCommandAppliers_alias_1 }
1005
1084
 
@@ -1015,17 +1094,45 @@ export { ExtractCommandCreators as ExtractCommandCreators_alias_1 }
1015
1094
  */
1016
1095
  export declare type ExtractCommands<E extends Extension> = SimplifyUnion<ExtractTyping<E>['Commands']>;
1017
1096
 
1097
+ /**
1098
+ * Extracts the {@link MarkAction}s from an extension type.
1099
+ *
1100
+ * @public
1101
+ */
1102
+ declare type ExtractMarkActions<E extends Extension> = ToMarkAction<ExtractMarks<E>>;
1103
+ export { ExtractMarkActions }
1104
+ export { ExtractMarkActions as ExtractMarkActions_alias_1 }
1105
+
1106
+ /**
1107
+ * @public
1108
+ */
1109
+ export declare type ExtractMarkNames<E extends Extension> = PickStringLiteral<keyof ExtractMarks<E>>;
1110
+
1018
1111
  /**
1019
1112
  * @public
1020
1113
  */
1021
- declare type ExtractMarks<E extends Extension> = ExtractTyping<E>['Marks'];
1114
+ declare type ExtractMarks<E extends Extension> = SimplifyDeeper<SimplifyUnion<ExtractTyping<E>['Marks']>>;
1022
1115
  export { ExtractMarks }
1023
1116
  export { ExtractMarks as ExtractMarks_alias_1 }
1024
1117
 
1025
1118
  /**
1119
+ * Extracts the {@link NodeAction}s from an extension type.
1120
+ *
1026
1121
  * @public
1027
1122
  */
1028
- declare type ExtractNodes<E extends Extension> = ExtractTyping<E>['Nodes'];
1123
+ declare type ExtractNodeActions<E extends Extension> = ToNodeAction<ExtractNodes<E>>;
1124
+ export { ExtractNodeActions }
1125
+ export { ExtractNodeActions as ExtractNodeActions_alias_1 }
1126
+
1127
+ /**
1128
+ * @public
1129
+ */
1130
+ export declare type ExtractNodeNames<E extends Extension> = PickStringLiteral<keyof ExtractNodes<E>>;
1131
+
1132
+ /**
1133
+ * @public
1134
+ */
1135
+ declare type ExtractNodes<E extends Extension> = SimplifyDeeper<SimplifyUnion<ExtractTyping<E>['Nodes']>>;
1029
1136
  export { ExtractNodes }
1030
1137
  export { ExtractNodes as ExtractNodes_alias_1 }
1031
1138
 
@@ -1034,7 +1141,7 @@ export declare function extractTags(node: TaggedProseMirrorNode): Record<string,
1034
1141
  /**
1035
1142
  * @internal
1036
1143
  */
1037
- 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;
1144
+ 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;
1038
1145
 
1039
1146
  /**
1040
1147
  * @internal
@@ -1173,6 +1280,18 @@ export declare type GroupedEntries<T extends Record<string, any>> = {
1173
1280
 
1174
1281
  export declare function groupEntries<T extends Record<string, any>>(entries: ObjectEntries<T>[]): GroupedEntries<T>;
1175
1282
 
1283
+ /**
1284
+ * @internal
1285
+ */
1286
+ declare type HistoryExtension = Extension<{
1287
+ Commands: {
1288
+ undo: [];
1289
+ redo: [];
1290
+ };
1291
+ }>;
1292
+ export { HistoryExtension }
1293
+ export { HistoryExtension as HistoryExtension_alias_1 }
1294
+
1176
1295
  /**
1177
1296
  * Options for {@link defineHistory}.
1178
1297
  *
@@ -1220,6 +1339,8 @@ declare function htmlFromNode(node: ProseMirrorNode, options?: DOMSerializerOpti
1220
1339
  export { htmlFromNode }
1221
1340
  export { htmlFromNode as htmlFromNode_alias_1 }
1222
1341
 
1342
+ export declare function includesMark(marks: readonly Mark[], markType: MarkType, attrs?: Attrs | null): boolean;
1343
+
1223
1344
  /**
1224
1345
  * Returns a command that inserts the given node at the current selection or at
1225
1346
  * the given position.
@@ -1265,11 +1386,16 @@ export { InsertNodeOptions as InsertNodeOptions_alias_1 }
1265
1386
  *
1266
1387
  * @public
1267
1388
  */
1268
- export declare function insertText({ text, from, to, }: {
1389
+ export declare function insertText({ text, from, to }: InsertTextOptions): Command;
1390
+
1391
+ /**
1392
+ * @public
1393
+ */
1394
+ export declare type InsertTextOptions = {
1269
1395
  text: string;
1270
1396
  from?: number;
1271
1397
  to?: number;
1272
- }): Command;
1398
+ };
1273
1399
 
1274
1400
  /**
1275
1401
  * @internal
@@ -1315,6 +1441,7 @@ export { isMark as isMark_alias_1 }
1315
1441
  /**
1316
1442
  * Returns true if the given mark is missing in some part of the range.
1317
1443
  * Returns false if the entire range has the given mark.
1444
+ * Returns true if the mark is not allowed in the range.
1318
1445
  *
1319
1446
  * @internal
1320
1447
  */
@@ -1347,6 +1474,13 @@ declare function isProseMirrorNode(node: unknown): node is ProseMirrorNode;
1347
1474
  export { isProseMirrorNode }
1348
1475
  export { isProseMirrorNode as isProseMirrorNode_alias_1 }
1349
1476
 
1477
+ /**
1478
+ * Check if `subset` is a subset of `superset`.
1479
+ *
1480
+ * @internal
1481
+ */
1482
+ export declare function isSubset(subset: Record<string, unknown>, superset: Record<string, unknown>): boolean;
1483
+
1350
1484
  /**
1351
1485
  * @internal
1352
1486
  */
@@ -1427,23 +1561,39 @@ export { KeyPressHandler }
1427
1561
  export { KeyPressHandler as KeyPressHandler_alias_1 }
1428
1562
 
1429
1563
  /**
1564
+ * A function for creating a mark with optional attributes and any number of
1565
+ * children.
1566
+ *
1567
+ * It also has a `isActive` method for checking if the mark is active in the
1568
+ * current editor selection.
1569
+ *
1430
1570
  * @public
1431
1571
  */
1432
- declare interface MarkAttrOptions {
1572
+ declare interface MarkAction<Attrs extends AnyAttrs = AnyAttrs> {
1573
+ (attrs: Attrs | null, ...children: NodeChild[]): ProseMirrorNode[];
1574
+ (...children: NodeChild[]): ProseMirrorNode[];
1433
1575
  /**
1434
- * The name of the mark type.
1576
+ * Checks if the mark is active in the current editor selection. If the
1577
+ * optional `attrs` parameter is provided, it will check if the mark is active
1578
+ * with the given attributes.
1435
1579
  */
1436
- type: string;
1580
+ isActive: (attrs?: Attrs) => boolean;
1581
+ }
1582
+ export { MarkAction }
1583
+ export { MarkAction as MarkAction_alias_1 }
1584
+
1585
+ /**
1586
+ * @public
1587
+ */
1588
+ declare interface MarkAttrOptions<MarkName extends string = string, AttrName extends string = string, AttrType = any> extends AttrSpec<AttrType> {
1437
1589
  /**
1438
- * The name of the attribute.
1590
+ * The name of the mark type.
1439
1591
  */
1440
- attr: string;
1592
+ type: MarkName;
1441
1593
  /**
1442
- * The default value for this attribute, to use when no explicit value is
1443
- * provided. Attributes that have no default must be provided whenever a mark
1444
- * of a type that has them is created.
1594
+ * The name of the attribute.
1445
1595
  */
1446
- default?: any;
1596
+ attr: AttrName;
1447
1597
  /**
1448
1598
  * Returns the attribute key and value to be set on the DOM node.
1449
1599
  */
@@ -1457,25 +1607,39 @@ export { MarkAttrOptions }
1457
1607
  export { MarkAttrOptions as MarkAttrOptions_alias_1 }
1458
1608
 
1459
1609
  /**
1460
- * @public
1610
+ * @deprecated Use type {@link MarkAction} instead.
1461
1611
  */
1462
- declare interface MarkBuilder {
1463
- (attrs: Attrs | null, ...children: NodeChild[]): ProseMirrorNode[];
1464
- (...children: NodeChild[]): ProseMirrorNode[];
1465
- isActive: (attrs?: Attrs) => boolean;
1466
- }
1612
+ declare type MarkBuilder = MarkAction;
1467
1613
  export { MarkBuilder }
1468
1614
  export { MarkBuilder as MarkBuilder_alias_1 }
1469
1615
 
1470
1616
  /**
1471
1617
  * @public
1472
1618
  */
1473
- declare interface MarkSpecOptions<MarkName extends string = string> extends MarkSpec {
1619
+ declare interface MarkSpecOptions<MarkName extends string = string, Attrs extends AnyAttrs = AnyAttrs> extends MarkSpec {
1620
+ /**
1621
+ * The name of the mark type.
1622
+ */
1474
1623
  name: MarkName;
1624
+ /**
1625
+ * The attributes that marks of this type get.
1626
+ */
1627
+ attrs?: {
1628
+ [K in keyof Attrs]: AttrSpec<Attrs[K]>;
1629
+ };
1475
1630
  }
1476
1631
  export { MarkSpecOptions }
1477
1632
  export { MarkSpecOptions as MarkSpecOptions_alias_1 }
1478
1633
 
1634
+ /**
1635
+ * @internal
1636
+ */
1637
+ declare interface MarkTyping {
1638
+ [name: string]: Record<string, any>;
1639
+ }
1640
+ export { MarkTyping }
1641
+ export { MarkTyping as MarkTyping_alias_1 }
1642
+
1479
1643
  /**
1480
1644
  * @internal
1481
1645
  */
@@ -1495,23 +1659,39 @@ export { MountHandler }
1495
1659
  export { MountHandler as MountHandler_alias_1 }
1496
1660
 
1497
1661
  /**
1662
+ * A function for creating a node with optional attributes and any number of
1663
+ * children.
1664
+ *
1665
+ * It also has a `isActive` method for checking if the node is active in the
1666
+ * current editor selection.
1667
+ *
1498
1668
  * @public
1499
1669
  */
1500
- declare interface NodeAttrOptions {
1670
+ declare interface NodeAction<Attrs extends AnyAttrs = AnyAttrs> {
1671
+ (attrs: Attrs | null, ...children: NodeChild[]): ProseMirrorNode;
1672
+ (...children: NodeChild[]): ProseMirrorNode;
1501
1673
  /**
1502
- * The name of the node type.
1674
+ * Checks if the node is active in the current editor selection. If the
1675
+ * optional `attrs` parameter is provided, it will check if the node is active
1676
+ * with the given attributes.
1503
1677
  */
1504
- type: string;
1678
+ isActive: (attrs?: Attrs) => boolean;
1679
+ }
1680
+ export { NodeAction }
1681
+ export { NodeAction as NodeAction_alias_1 }
1682
+
1683
+ /**
1684
+ * @public
1685
+ */
1686
+ declare interface NodeAttrOptions<NodeName extends string = string, AttrName extends string = string, AttrType = any> extends AttrSpec<AttrType> {
1505
1687
  /**
1506
- * The name of the attribute.
1688
+ * The name of the node type.
1507
1689
  */
1508
- attr: string;
1690
+ type: NodeName;
1509
1691
  /**
1510
- * The default value for this attribute, to use when no explicit value is
1511
- * provided. Attributes that have no default must be provided whenever a node
1512
- * of a type that has them is created.
1692
+ * The name of the attribute.
1513
1693
  */
1514
- default?: any;
1694
+ attr: AttrName;
1515
1695
  /**
1516
1696
  * Whether the attribute should be kept when the node is split. Set it to
1517
1697
  * `true` if you want to inherit the attribute from the previous node when
@@ -1536,20 +1716,20 @@ export { NodeAttrOptions }
1536
1716
  export { NodeAttrOptions as NodeAttrOptions_alias_1 }
1537
1717
 
1538
1718
  /**
1539
- * @public
1719
+ * @deprecated Use type {@link NodeAction} instead.
1540
1720
  */
1541
- declare interface NodeBuilder {
1542
- (attrs: Attrs | null, ...children: NodeChild[]): ProseMirrorNode;
1543
- (...children: NodeChild[]): ProseMirrorNode;
1544
- isActive: (attrs?: Attrs) => boolean;
1545
- }
1721
+ declare type NodeBuilder = NodeAction;
1546
1722
  export { NodeBuilder }
1547
1723
  export { NodeBuilder as NodeBuilder_alias_1 }
1548
1724
 
1549
1725
  /**
1726
+ * Available children parameters for {@link NodeAction} and {@link MarkAction}.
1727
+ *
1550
1728
  * @public
1551
1729
  */
1552
- export declare type NodeChild = ProseMirrorNode | string | NodeChild[];
1730
+ declare type NodeChild = ProseMirrorNode | string | NodeChild[];
1731
+ export { NodeChild }
1732
+ export { NodeChild as NodeChild_alias_1 }
1553
1733
 
1554
1734
  /**
1555
1735
  * @public
@@ -1603,13 +1783,35 @@ export { NodeJSON as NodeJSON_alias_1 }
1603
1783
  /**
1604
1784
  * @public
1605
1785
  */
1606
- declare interface NodeSpecOptions<NodeName extends string = string> extends NodeSpec {
1786
+ declare interface NodeSpecOptions<NodeName extends string = string, Attrs extends AnyAttrs = AnyAttrs> extends NodeSpec {
1787
+ /**
1788
+ * The name of the node type.
1789
+ */
1607
1790
  name: NodeName;
1791
+ /**
1792
+ * Whether this is the top-level node type. Only one node type can be the
1793
+ * top-level node type in a schema.
1794
+ */
1608
1795
  topNode?: boolean;
1796
+ /**
1797
+ * The attributes that nodes of this type get.
1798
+ */
1799
+ attrs?: {
1800
+ [key in keyof Attrs]: AttrSpec<Attrs[key]>;
1801
+ };
1609
1802
  }
1610
1803
  export { NodeSpecOptions }
1611
1804
  export { NodeSpecOptions as NodeSpecOptions_alias_1 }
1612
1805
 
1806
+ /**
1807
+ * @internal
1808
+ */
1809
+ declare interface NodeTyping {
1810
+ [name: string]: Record<string, any>;
1811
+ }
1812
+ export { NodeTyping }
1813
+ export { NodeTyping as NodeTyping_alias_1 }
1814
+
1613
1815
  /**
1614
1816
  * @internal
1615
1817
  */
@@ -1662,6 +1864,22 @@ export declare type ObjectEntries<T extends Record<string, any>> = {
1662
1864
 
1663
1865
  export declare function objectEqual<T>(a: T, b: T): boolean;
1664
1866
 
1867
+ /**
1868
+ * @internal
1869
+ */
1870
+ declare type ParagraphExtension = ParagraphSpecExtension;
1871
+ export { ParagraphExtension }
1872
+ export { ParagraphExtension as ParagraphExtension_alias_1 }
1873
+
1874
+ /**
1875
+ * @internal
1876
+ */
1877
+ declare type ParagraphSpecExtension = Extension<{
1878
+ Nodes: {
1879
+ paragraph: Attrs;
1880
+ };
1881
+ }>;
1882
+
1665
1883
  declare type PasteHandler = (view: EditorView, event: ClipboardEvent, slice: Slice) => boolean | void;
1666
1884
  export { PasteHandler }
1667
1885
  export { PasteHandler as PasteHandler_alias_1 }
@@ -1674,14 +1892,25 @@ export declare type Payloads<T> = Tuple5<T[]>;
1674
1892
  /**
1675
1893
  * @internal
1676
1894
  */
1677
- export declare type PickKnownCommandTyping<T extends CommandTyping> = [
1678
- CommandTyping
1679
- ] extends [T] ? never : T;
1895
+ export declare type PickStringLiteral<T> = PickSubType<T, string>;
1680
1896
 
1681
1897
  /**
1682
1898
  * @internal
1683
1899
  */
1684
- export declare type PickStringLiteral<T extends string> = [string] extends [T] ? never : T;
1900
+ declare type PickSubType<Type, ParentType> = Type extends ParentType ? [ParentType] extends [Type] ? never : Type : never;
1901
+ export { PickSubType }
1902
+ export { PickSubType as PickSubType_alias_1 }
1903
+
1904
+ /**
1905
+ * @internal
1906
+ */
1907
+ declare type PluginExtension = Extension<{
1908
+ Nodes: never;
1909
+ Marks: never;
1910
+ Commands: never;
1911
+ }>;
1912
+ export { PluginExtension }
1913
+ export { PluginExtension as PluginExtension_alias_1 }
1685
1914
 
1686
1915
  /**
1687
1916
  * @internal
@@ -1898,31 +2127,57 @@ export declare function setupEditorExtension<E extends Extension>(options: Edito
1898
2127
  * @internal
1899
2128
  */
1900
2129
  export declare function setupTest(): {
1901
- editor: TestEditor<Extension<{
1902
- Nodes: "text" | "doc" | "paragraph" | "heading";
1903
- Marks: "bold" | "italic";
1904
- Commands: {
1905
- insertText: [{
1906
- text: string;
1907
- from?: number;
1908
- to?: number;
1909
- }];
1910
- insertNode: [options: InsertNodeOptions];
1911
- removeNode: [options: RemoveNodeOptions];
1912
- wrap: [WrapOptions];
1913
- setBlockType: [options: SetBlockTypeOptions];
1914
- setNodeAttrs: [options: SetNodeAttrsOptions];
1915
- selectAll: [];
1916
- addMark: [options: AddMarkOptions];
1917
- removeMark: [options: RemoveMarkOptions];
1918
- unsetBlockType: [options?: UnsetBlockTypeOptions | undefined];
1919
- unsetMark: [options?: UnsetMarkOptions | undefined];
1920
- readonly undo: [];
1921
- readonly redo: [];
1922
- };
2130
+ editor: TestEditor<Union<readonly [BaseCommandsExtension, BaseKeymapExtension, DocExtension, HistoryExtension, Extension<{
2131
+ Nodes: {
2132
+ paragraph: Attrs_2;
2133
+ };
2134
+ }>, TextExtension, Extension<{
2135
+ Marks: {
2136
+ bold: Attrs_2;
2137
+ };
2138
+ }>, Extension<{
2139
+ Marks: {
2140
+ italic: Attrs_2;
2141
+ };
2142
+ }>, Extension<{
2143
+ Nodes: {
2144
+ heading: Attrs_2;
2145
+ };
2146
+ }>, Extension<{
2147
+ Nodes: {
2148
+ codeBlock: {
2149
+ language: string;
2150
+ };
2151
+ };
2152
+ }>]>>;
2153
+ m: ToMarkAction<SimplifyDeeper< {
2154
+ bold: {
2155
+ readonly [x: string]: any;
2156
+ };
2157
+ italic: {
2158
+ readonly [x: string]: any;
2159
+ };
1923
2160
  }>>;
1924
- n: Record<"text" | "doc" | "paragraph" | "heading", NodeBuilder>;
1925
- m: Record<"bold" | "italic", MarkBuilder>;
2161
+ n: {
2162
+ p: NodeAction< {
2163
+ readonly [x: string]: any;
2164
+ }>;
2165
+ doc: NodeAction< {
2166
+ readonly [x: string]: any;
2167
+ }>;
2168
+ paragraph: NodeAction< {
2169
+ readonly [x: string]: any;
2170
+ }>;
2171
+ text: NodeAction< {
2172
+ readonly [x: string]: any;
2173
+ }>;
2174
+ codeBlock: NodeAction< {
2175
+ language: string;
2176
+ }>;
2177
+ heading: NodeAction< {
2178
+ readonly [x: string]: any;
2179
+ }>;
2180
+ };
1926
2181
  };
1927
2182
 
1928
2183
  /**
@@ -1930,14 +2185,23 @@ export declare function setupTest(): {
1930
2185
  */
1931
2186
  export declare function setupTestFromExtension<E extends Extension>(extension: E): {
1932
2187
  editor: TestEditor<E>;
1933
- n: Record<ExtractNodes<E>, NodeBuilder>;
1934
- m: Record<ExtractMarks<E>, MarkBuilder>;
2188
+ n: ExtractNodeActions<E>;
2189
+ m: ExtractMarkActions<E>;
2190
+ };
2191
+
2192
+ /**
2193
+ * @internal
2194
+ */
2195
+ declare type SimplifyDeeper<T> = {
2196
+ [KeyType in keyof T]: Simplify<T[KeyType]>;
1935
2197
  };
2198
+ export { SimplifyDeeper }
2199
+ export { SimplifyDeeper as SimplifyDeeper_alias_1 }
1936
2200
 
1937
2201
  /**
1938
2202
  * @internal
1939
2203
  */
1940
- declare type SimplifyUnion<T> = Simplify<UnionToIntersection<T>>;
2204
+ declare type SimplifyUnion<T> = Simplify<UnionToIntersection<T extends undefined ? never : T>>;
1941
2205
  export { SimplifyUnion }
1942
2206
  export { SimplifyUnion as SimplifyUnion_alias_1 }
1943
2207
 
@@ -2030,12 +2294,23 @@ declare class TestEditor<E extends Extension = Extension> extends Editor<E> {
2030
2294
  export { TestEditor }
2031
2295
  export { TestEditor as TestEditor_alias_1 }
2032
2296
 
2297
+ /**
2298
+ * @internal
2299
+ */
2300
+ declare type TextExtension = Extension<{
2301
+ Nodes: {
2302
+ text: Attrs;
2303
+ };
2304
+ }>;
2305
+ export { TextExtension }
2306
+ export { TextExtension as TextExtension_alias_1 }
2307
+
2033
2308
  declare type TextInputHandler = (view: EditorView, from: number, to: number, text: string) => boolean | void;
2034
2309
  export { TextInputHandler }
2035
2310
  export { TextInputHandler as TextInputHandler_alias_1 }
2036
2311
 
2037
- export declare type ToCommandApplier<T extends CommandTyping> = {
2038
- [K in keyof T]: CommandApplier<T[K]>;
2312
+ export declare type ToCommandAction<T extends CommandTyping> = {
2313
+ [K in keyof T]: CommandAction<T[K]>;
2039
2314
  };
2040
2315
 
2041
2316
  export declare type ToCommandCreators<T extends CommandTyping> = {
@@ -2087,6 +2362,24 @@ declare interface ToggleNodeOptions {
2087
2362
  export { ToggleNodeOptions }
2088
2363
  export { ToggleNodeOptions as ToggleNodeOptions_alias_1 }
2089
2364
 
2365
+ /**
2366
+ * @internal
2367
+ */
2368
+ declare type ToMarkAction<T extends MarkTyping> = {
2369
+ [K in keyof T]: MarkAction<T[K]>;
2370
+ };
2371
+ export { ToMarkAction }
2372
+ export { ToMarkAction as ToMarkAction_alias_1 }
2373
+
2374
+ /**
2375
+ * @internal
2376
+ */
2377
+ declare type ToNodeAction<T extends NodeTyping> = {
2378
+ [K in keyof T]: NodeAction<T[K]>;
2379
+ };
2380
+ export { ToNodeAction }
2381
+ export { ToNodeAction as ToNodeAction_alias_1 }
2382
+
2090
2383
  export declare function toReversed<T>(arr: T[]): T[];
2091
2384
 
2092
2385
  declare type TripleClickHandler = (view: EditorView, pos: number, event: MouseEvent) => boolean | void;
@@ -2102,6 +2395,17 @@ export { TripleClickOnHandler as TripleClickOnHandler_alias_1 }
2102
2395
  */
2103
2396
  export declare type Tuple5<T> = [T, T, T, T, T];
2104
2397
 
2398
+ /**
2399
+ * @internal
2400
+ */
2401
+ declare type Union<E extends readonly Extension[]> = Extension<{
2402
+ Nodes: ExtractNodes<E[number]>;
2403
+ Marks: ExtractMarks<E[number]>;
2404
+ Commands: ExtractCommands<E[number]>;
2405
+ }>;
2406
+ export { Union }
2407
+ export { Union as Union_alias_1 }
2408
+
2105
2409
  /**
2106
2410
  * Merge multiple extensions into one.
2107
2411
  *
@@ -2120,11 +2424,14 @@ export declare type Tuple5<T> = [T, T, T, T, T];
2120
2424
  *
2121
2425
  * @public
2122
2426
  */
2123
- declare function union<const E extends Extension | readonly Extension[]>(extension: E): UnionExtension<E>;
2427
+ declare function union<const E extends readonly Extension[]>(...exts: E): Union<E>;
2428
+
2429
+ declare function union<const E extends readonly Extension[]>(exts: E): Union<E>;
2124
2430
  export { union }
2125
2431
  export { union as union_alias_1 }
2126
2432
 
2127
2433
  /**
2434
+ * @deprecated Use `Union` instead.
2128
2435
  * @internal
2129
2436
  */
2130
2437
  declare type UnionExtension<E extends Extension | readonly Extension[]> = E extends readonly Extension[] ? Extension<{