@prosekit/core 0.0.0-next-20240505104851 → 0.0.0-next-20240531032056

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.
@@ -2,7 +2,6 @@ import { AllSelection } from '@prosekit/pm/state';
2
2
  import { Attrs } from '@prosekit/pm/model';
3
3
  import { Attrs as Attrs_2 } from 'prosemirror-model';
4
4
  import { Command } from '@prosekit/pm/state';
5
- import type { ConditionalExcept } from 'type-fest';
6
5
  import type { ContentMatch } from '@prosekit/pm/model';
7
6
  import type { DirectEditorProps } from '@prosekit/pm/view';
8
7
  import type { DOMEventMap } from '@prosekit/pm/view';
@@ -11,7 +10,6 @@ import { DOMSerializer } from '@prosekit/pm/model';
11
10
  import { EditorState } from '@prosekit/pm/state';
12
11
  import type { EditorStateConfig } from '@prosekit/pm/state';
13
12
  import { EditorView } from '@prosekit/pm/view';
14
- import type { EmptyObject } from 'type-fest';
15
13
  import type { IsEqual } from 'type-fest';
16
14
  import { Mark } from '@prosekit/pm/model';
17
15
  import type { MarkSpec } from '@prosekit/pm/model';
@@ -30,7 +28,7 @@ import { Plugin as Plugin_2 } from '@prosekit/pm/state';
30
28
  import { ProseMirrorFragment } from '@prosekit/pm/model';
31
29
  import { ProseMirrorNode } from '@prosekit/pm/model';
32
30
  import { Schema } from '@prosekit/pm/model';
33
- import type { SchemaSpec } from '@prosekit/pm/model';
31
+ import { SchemaSpec } from '@prosekit/pm/model';
34
32
  import { Selection as Selection_2 } from '@prosekit/pm/state';
35
33
  import { Selection as Selection_3 } from 'prosemirror-state';
36
34
  import type { Simplify } from 'type-fest';
@@ -72,6 +70,23 @@ export { addMark as addMark_alias_1 }
72
70
 
73
71
  export declare function applyAction(operator: Action): Command;
74
72
 
73
+ /**
74
+ * @internal
75
+ */
76
+ export declare function arrayRemove<T>(array: T[], item: T): void;
77
+
78
+ /**
79
+ * @internal
80
+ */
81
+ export declare function arraySubstract<T>(a: T[], b: T[]): T[];
82
+
83
+ /**
84
+ * @internal
85
+ */
86
+ declare function assert(condition: unknown, message?: string): asserts condition;
87
+ export { assert }
88
+ export { assert as assert_alias_1 }
89
+
75
90
  /**
76
91
  * Utility function assert that two types are equal in tests.
77
92
  */
@@ -79,26 +94,27 @@ export declare function assertTypeEqual<T, U>(_val: IsEqual<T, U>): void;
79
94
 
80
95
  export declare function attrsMatch(nodeOrMark: ProseMirrorNode | Mark, attrs: Attrs): boolean;
81
96
 
97
+ /**
98
+ * @internal
99
+ */
82
100
  export declare abstract class BaseExtension<T extends ExtensionTyping = ExtensionTyping> implements Extension<T> {
83
101
  extension: Extension | Extension[];
84
102
  priority?: Priority;
85
103
  _type?: T;
104
+ private trees;
86
105
  /**
87
106
  * @internal
88
- *
89
- * Whether this extension has payload that can be converted to a schema.
90
- *
91
- * Notice that this does not mean that the extension has a schema. For
92
- * example, a `FacetExtension` with a `schemaFacet` will return `true` for
93
- * this property, but will return `null` for `schema`.
94
107
  */
95
- abstract hasSchema: boolean;
108
+ abstract createTree(priority: Priority): FacetNode;
96
109
  /**
97
110
  * @internal
98
- *
99
- * The schema that this extension represents.
100
111
  */
101
- abstract schema: Schema | null;
112
+ getTree(priority?: Priority): FacetNode;
113
+ /**
114
+ * @internal
115
+ */
116
+ findFacetOutput<I, O>(facet: Facet<I, O>): Tuple5<O | null> | null;
117
+ get schema(): Schema | null;
102
118
  }
103
119
 
104
120
  /**
@@ -165,28 +181,24 @@ export declare interface CommandApplier<Args extends any[] = any[]> {
165
181
  canApply(...args: Args): boolean;
166
182
  }
167
183
 
168
- /**
169
- * @internal
170
- */
171
- declare interface CommandArgs {
172
- [name: string]: any[];
173
- }
174
- export { CommandArgs }
175
- export { CommandArgs as CommandArgs_alias_1 }
176
-
177
184
  export declare type CommandCreator<Args extends any[] = any[]> = (...arg: Args) => Command;
178
185
 
179
186
  export declare interface CommandCreators {
180
187
  [name: string]: CommandCreator;
181
188
  }
182
189
 
183
- export declare const commandFacet: Facet<CommandCreators, CommandCreators>;
190
+ export declare const commandFacet: Facet<CommandCreators, RootPayload>;
184
191
 
185
192
  export declare type CommandPayload = CommandCreators;
186
193
 
187
- export declare type Converters = ConverterTuple[];
188
-
189
- declare type ConverterTuple = Tuple5<FacetConverter | undefined>;
194
+ /**
195
+ * @internal
196
+ */
197
+ declare interface CommandTyping {
198
+ [name: string]: any[];
199
+ }
200
+ export { CommandTyping }
201
+ export { CommandTyping as CommandTyping_alias_1 }
190
202
 
191
203
  /**
192
204
  * @public
@@ -199,6 +211,8 @@ export declare function createMarkBuilder(getState: () => EditorState | null | u
199
211
 
200
212
  export declare function createNodeBuilder(getState: () => EditorState | null | undefined, type: NodeType): NodeBuilder;
201
213
 
214
+ export declare function deepEquals<T>(a: T, b: T): boolean;
215
+
202
216
  export declare const default_alias: Options | Options[] | ((overrideOptions: Options) => Options | Options[] | Promise<Options | Options[]>);
203
217
 
204
218
  export declare const default_alias_1: {
@@ -240,7 +254,7 @@ export { DefaultStateOptions as DefaultStateOptions_alias_1 }
240
254
  * @public
241
255
  */
242
256
  declare function defineBaseCommands(): Extension<{
243
- COMMAND_ARGS: {
257
+ Commands: {
244
258
  insertText: [{
245
259
  text: string;
246
260
  from?: number | undefined;
@@ -268,7 +282,7 @@ declare function defineBaseCommands(): Extension<{
268
282
  to?: number | undefined;
269
283
  }];
270
284
  setNodeAttrs: [options: {
271
- type: string | NodeType_2;
285
+ type: string | NodeType_2 | string[] | NodeType_2[];
272
286
  attrs: Attrs_2;
273
287
  pos?: number | undefined;
274
288
  }];
@@ -286,6 +300,8 @@ declare function defineBaseCommands(): Extension<{
286
300
  to?: number | undefined;
287
301
  }];
288
302
  };
303
+ Nodes: never;
304
+ Marks: never;
289
305
  }>;
290
306
  export { defineBaseCommands }
291
307
  export { defineBaseCommands as defineBaseCommands_alias_1 }
@@ -302,7 +318,7 @@ declare function defineBaseKeymap(options?: {
302
318
  * @default Priority.low
303
319
  */
304
320
  priority?: Priority;
305
- }): Extension<ExtensionTyping<string, string, CommandArgs>>;
321
+ }): Extension<any>;
306
322
  export { defineBaseKeymap }
307
323
  export { defineBaseKeymap as defineBaseKeymap_alias_1 }
308
324
 
@@ -311,7 +327,7 @@ export { defineBaseKeymap as defineBaseKeymap_alias_1 }
311
327
  *
312
328
  * See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handleClick}
313
329
  */
314
- declare function defineClickHandler(handler: ClickHandler): Extension<ExtensionTyping<string, string, CommandArgs>>;
330
+ declare function defineClickHandler(handler: ClickHandler): Extension<any>;
315
331
  export { defineClickHandler }
316
332
  export { defineClickHandler as defineClickHandler_alias_1 }
317
333
 
@@ -320,14 +336,16 @@ export { defineClickHandler as defineClickHandler_alias_1 }
320
336
  *
321
337
  * See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handleClickOn}
322
338
  */
323
- declare function defineClickOnHandler(handler: ClickOnHandler): Extension<ExtensionTyping<string, string, CommandArgs>>;
339
+ declare function defineClickOnHandler(handler: ClickOnHandler): Extension<any>;
324
340
  export { defineClickOnHandler }
325
341
  export { defineClickOnHandler as defineClickOnHandler_alias_1 }
326
342
 
327
343
  declare function defineCommands<T extends Record<string, CommandCreator> = Record<string, CommandCreator>>(commands: T): Extension<{
328
- COMMAND_ARGS: {
344
+ Commands: {
329
345
  [K in keyof T]: Parameters<T[K]>;
330
346
  };
347
+ Nodes: never;
348
+ Marks: never;
331
349
  }>;
332
350
  export { defineCommands }
333
351
  export { defineCommands as defineCommands_alias_1 }
@@ -340,7 +358,9 @@ export { defineDefaultState as defineDefaultState_alias_1 }
340
358
  * @public
341
359
  */
342
360
  declare function defineDoc(): Extension< {
343
- NODES: "doc";
361
+ Nodes: "doc";
362
+ Marks: never;
363
+ Commands: never;
344
364
  }>;
345
365
  export { defineDoc }
346
366
  export { defineDoc as defineDoc_alias_1 }
@@ -350,7 +370,7 @@ export { defineDoc as defineDoc_alias_1 }
350
370
  *
351
371
  * @public
352
372
  */
353
- declare function defineDocChangeHandler(handler: DocChangeHandler): Extension<ExtensionTyping<string, string, CommandArgs>>;
373
+ declare function defineDocChangeHandler(handler: DocChangeHandler): Extension<any>;
354
374
  export { defineDocChangeHandler }
355
375
  export { defineDocChangeHandler as defineDocChangeHandler_alias_1 }
356
376
 
@@ -359,7 +379,7 @@ export { defineDocChangeHandler as defineDocChangeHandler_alias_1 }
359
379
  *
360
380
  * @public
361
381
  */
362
- declare function defineDOMEventHandler<Event extends keyof DOMEventMap = string>(event: Event, handler: DOMEventHandler<Event>): Extension<ExtensionTyping<string, string, CommandArgs>>;
382
+ declare function defineDOMEventHandler<Event extends keyof DOMEventMap = string>(event: Event, handler: DOMEventHandler<Event>): Extension<any>;
363
383
  export { defineDOMEventHandler }
364
384
  export { defineDOMEventHandler as defineDOMEventHandler_alias_1 }
365
385
 
@@ -368,7 +388,7 @@ export { defineDOMEventHandler as defineDOMEventHandler_alias_1 }
368
388
  *
369
389
  * See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handleDoubleClick}
370
390
  */
371
- declare function defineDoubleClickHandler(handler: DoubleClickHandler): Extension<ExtensionTyping<string, string, CommandArgs>>;
391
+ declare function defineDoubleClickHandler(handler: DoubleClickHandler): Extension<any>;
372
392
  export { defineDoubleClickHandler }
373
393
  export { defineDoubleClickHandler as defineDoubleClickHandler_alias_1 }
374
394
 
@@ -377,7 +397,7 @@ export { defineDoubleClickHandler as defineDoubleClickHandler_alias_1 }
377
397
  *
378
398
  * See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handleDoubleClickOn}
379
399
  */
380
- declare function defineDoubleClickOnHandler(handler: DoubleClickOnHandler): Extension<ExtensionTyping<string, string, CommandArgs>>;
400
+ declare function defineDoubleClickOnHandler(handler: DoubleClickOnHandler): Extension<any>;
381
401
  export { defineDoubleClickOnHandler }
382
402
  export { defineDoubleClickOnHandler as defineDoubleClickOnHandler_alias_1 }
383
403
 
@@ -386,16 +406,50 @@ export { defineDoubleClickOnHandler as defineDoubleClickOnHandler_alias_1 }
386
406
  *
387
407
  * See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handleDrop}
388
408
  */
389
- declare function defineDropHandler(handler: DropHandler): Extension<ExtensionTyping<string, string, CommandArgs>>;
409
+ declare function defineDropHandler(handler: DropHandler): Extension<any>;
390
410
  export { defineDropHandler }
391
411
  export { defineDropHandler as defineDropHandler_alias_1 }
392
412
 
413
+ /**
414
+ * @internal
415
+ */
416
+ declare function defineFacet<Input, Output>(options: {
417
+ /**
418
+ * The parent facet in the tree.
419
+ */
420
+ parent: Facet<Output, any>;
421
+ /**
422
+ * Set this to true if you only want to keep one facet payload. For example,
423
+ * this facet corresponds to a ProseMirror plugin with a key.
424
+ */
425
+ singleton?: boolean;
426
+ /**
427
+ * A reducer is a function that accepts an array of input and produce a single
428
+ * output.
429
+ */
430
+ reducer?: FacetReducer<Input, Output>;
431
+ /**
432
+ * A callback function that returns a reducer. This is useful if you want to
433
+ * store something in the closure.
434
+ */
435
+ reduce?: () => FacetReducer<Input, Output>;
436
+ }): Facet<Input, Output>;
437
+ export { defineFacet }
438
+ export { defineFacet as defineFacet_alias_1 }
439
+
440
+ /**
441
+ * @internal
442
+ */
443
+ declare function defineFacetPayload<Input>(facet: Facet<Input, any>, payloads: Input[]): Extension;
444
+ export { defineFacetPayload }
445
+ export { defineFacetPayload as defineFacetPayload_alias_1 }
446
+
393
447
  /**
394
448
  * Registers a event handler that is called when the editor gains or loses focus.
395
449
  *
396
450
  * @public
397
451
  */
398
- declare function defineFocusChangeHandler(handler: FocusChangeHandler): Extension<ExtensionTyping<string, string, CommandArgs>>;
452
+ declare function defineFocusChangeHandler(handler: FocusChangeHandler): Extension<any>;
399
453
  export { defineFocusChangeHandler }
400
454
  export { defineFocusChangeHandler as defineFocusChangeHandler_alias_1 }
401
455
 
@@ -403,9 +457,10 @@ export { defineFocusChangeHandler as defineFocusChangeHandler_alias_1 }
403
457
  * Add undo/redo history to the editor.
404
458
  */
405
459
  declare function defineHistory(): Extension< {
406
- COMMAND_ARGS: {
407
- undo: [];
408
- redo: [];
460
+ Nodes: any;
461
+ Marks: any;
462
+ Commands: {
463
+ [x: string]: any;
409
464
  };
410
465
  }>;
411
466
  export { defineHistory }
@@ -416,7 +471,7 @@ export { defineHistory as defineHistory_alias_1 }
416
471
  *
417
472
  * See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handleKeyDown}
418
473
  */
419
- declare function defineKeyDownHandler(handler: KeyDownHandler): Extension<ExtensionTyping<string, string, CommandArgs>>;
474
+ declare function defineKeyDownHandler(handler: KeyDownHandler): Extension<any>;
420
475
  export { defineKeyDownHandler }
421
476
  export { defineKeyDownHandler as defineKeyDownHandler_alias_1 }
422
477
 
@@ -432,7 +487,7 @@ export { defineKeymap as defineKeymap_alias_1 }
432
487
  *
433
488
  * See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handleKeyPress}
434
489
  */
435
- declare function defineKeyPressHandler(handler: KeyPressHandler): Extension<ExtensionTyping<string, string, CommandArgs>>;
490
+ declare function defineKeyPressHandler(handler: KeyPressHandler): Extension<any>;
436
491
  export { defineKeyPressHandler }
437
492
  export { defineKeyPressHandler as defineKeyPressHandler_alias_1 }
438
493
 
@@ -447,7 +502,9 @@ export { defineMarkAttr as defineMarkAttr_alias_1 }
447
502
  * @public
448
503
  */
449
504
  declare function defineMarkSpec<Mark extends string>(options: MarkSpecOptions<Mark>): Extension<{
450
- MARKS: Mark;
505
+ Marks: Mark;
506
+ Nodes: never;
507
+ Commands: never;
451
508
  }>;
452
509
  export { defineMarkSpec }
453
510
  export { defineMarkSpec as defineMarkSpec_alias_1 }
@@ -457,7 +514,7 @@ export { defineMarkSpec as defineMarkSpec_alias_1 }
457
514
  *
458
515
  * @public
459
516
  */
460
- declare function defineMountHandler(handler: MountHandler): Extension<ExtensionTyping<string, string, CommandArgs>>;
517
+ declare function defineMountHandler(handler: MountHandler): Extension<any>;
461
518
  export { defineMountHandler }
462
519
  export { defineMountHandler as defineMountHandler_alias_1 }
463
520
 
@@ -475,8 +532,10 @@ export { defineNodeAttr as defineNodeAttr_alias_1 }
475
532
  *
476
533
  * @public
477
534
  */
478
- declare function defineNodeSpec<NodeName extends string>(options: NodeSpecOptions<NodeName>): Extension<{
479
- NODES: NodeName;
535
+ declare function defineNodeSpec<Node extends string>(options: NodeSpecOptions<Node>): Extension<{
536
+ Nodes: Node;
537
+ Marks: never;
538
+ Commands: never;
480
539
  }>;
481
540
  export { defineNodeSpec }
482
541
  export { defineNodeSpec as defineNodeSpec_alias_1 }
@@ -498,7 +557,9 @@ export { defineNodeViewFactory as defineNodeViewFactory_alias_1 }
498
557
  * Defines a paragraph node spec as the highest priority, because it should be the default block node for most cases.
499
558
  */
500
559
  declare function defineParagraph(): Extension< {
501
- NODES: "paragraph";
560
+ Nodes: "paragraph";
561
+ Marks: never;
562
+ Commands: never;
502
563
  }>;
503
564
  export { defineParagraph }
504
565
  export { defineParagraph as defineParagraph_alias_1 }
@@ -509,7 +570,9 @@ export { defineParagraph as defineParagraph_alias_1 }
509
570
  * Defines a paragraph node spec.
510
571
  */
511
572
  export declare function defineParagraphSpec(): Extension< {
512
- NODES: "paragraph";
573
+ Nodes: "paragraph";
574
+ Marks: never;
575
+ Commands: never;
513
576
  }>;
514
577
 
515
578
  /**
@@ -517,7 +580,7 @@ NODES: "paragraph";
517
580
  *
518
581
  * See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handlePaste}
519
582
  */
520
- declare function definePasteHandler(handler: PasteHandler): Extension<ExtensionTyping<string, string, CommandArgs>>;
583
+ declare function definePasteHandler(handler: PasteHandler): Extension<any>;
521
584
  export { definePasteHandler }
522
585
  export { definePasteHandler as definePasteHandler_alias_1 }
523
586
 
@@ -540,7 +603,7 @@ export { definePlugin as definePlugin_alias_1 }
540
603
  *
541
604
  * See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handleScrollToSelection}
542
605
  */
543
- declare function defineScrollToSelectionHandler(handler: ScrollToSelectionHandler): Extension<ExtensionTyping<string, string, CommandArgs>>;
606
+ declare function defineScrollToSelectionHandler(handler: ScrollToSelectionHandler): Extension<any>;
544
607
  export { defineScrollToSelectionHandler }
545
608
  export { defineScrollToSelectionHandler as defineScrollToSelectionHandler_alias_1 }
546
609
 
@@ -548,7 +611,9 @@ export { defineScrollToSelectionHandler as defineScrollToSelectionHandler_alias_
548
611
  * @public
549
612
  */
550
613
  declare function defineText(): Extension< {
551
- NODES: "text";
614
+ Nodes: "text";
615
+ Marks: never;
616
+ Commands: never;
552
617
  }>;
553
618
  export { defineText }
554
619
  export { defineText as defineText_alias_1 }
@@ -558,7 +623,7 @@ export { defineText as defineText_alias_1 }
558
623
  *
559
624
  * See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handleTextInput}
560
625
  */
561
- declare function defineTextInputHandler(handler: TextInputHandler): Extension<ExtensionTyping<string, string, CommandArgs>>;
626
+ declare function defineTextInputHandler(handler: TextInputHandler): Extension<any>;
562
627
  export { defineTextInputHandler }
563
628
  export { defineTextInputHandler as defineTextInputHandler_alias_1 }
564
629
 
@@ -567,7 +632,7 @@ export { defineTextInputHandler as defineTextInputHandler_alias_1 }
567
632
  *
568
633
  * See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handleTripleClick}
569
634
  */
570
- declare function defineTripleClickHandler(handler: TripleClickHandler): Extension<ExtensionTyping<string, string, CommandArgs>>;
635
+ declare function defineTripleClickHandler(handler: TripleClickHandler): Extension<any>;
571
636
  export { defineTripleClickHandler }
572
637
  export { defineTripleClickHandler as defineTripleClickHandler_alias_1 }
573
638
 
@@ -576,7 +641,7 @@ export { defineTripleClickHandler as defineTripleClickHandler_alias_1 }
576
641
  *
577
642
  * See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handleTripleClickOn}
578
643
  */
579
- declare function defineTripleClickOnHandler(handler: TripleClickOnHandler): Extension<ExtensionTyping<string, string, CommandArgs>>;
644
+ declare function defineTripleClickOnHandler(handler: TripleClickOnHandler): Extension<any>;
580
645
  export { defineTripleClickOnHandler }
581
646
  export { defineTripleClickOnHandler as defineTripleClickOnHandler_alias_1 }
582
647
 
@@ -585,7 +650,7 @@ export { defineTripleClickOnHandler as defineTripleClickOnHandler_alias_1 }
585
650
  *
586
651
  * @public
587
652
  */
588
- declare function defineUnmountHandler(handler: UnmountHandler): Extension<ExtensionTyping<string, string, CommandArgs>>;
653
+ declare function defineUnmountHandler(handler: UnmountHandler): Extension<any>;
589
654
  export { defineUnmountHandler }
590
655
  export { defineUnmountHandler as defineUnmountHandler_alias_1 }
591
656
 
@@ -594,7 +659,7 @@ export { defineUnmountHandler as defineUnmountHandler_alias_1 }
594
659
  *
595
660
  * @public
596
661
  */
597
- declare function defineUpdateHandler(handler: UpdateHandler): Extension<ExtensionTyping<string, string, CommandArgs>>;
662
+ declare function defineUpdateHandler(handler: UpdateHandler): Extension<any>;
598
663
  export { defineUpdateHandler }
599
664
  export { defineUpdateHandler as defineUpdateHandler_alias_1 }
600
665
 
@@ -788,10 +853,6 @@ declare function elementFromNode(node: ProseMirrorNode, options?: DOMSerializerO
788
853
  export { elementFromNode }
789
854
  export { elementFromNode as elementFromNode_alias_1 }
790
855
 
791
- declare type EmptyValue = undefined | null | EmptyObject;
792
-
793
- export declare type ExceptEmptyValue<T> = ConditionalExcept<T, EmptyValue>;
794
-
795
856
  /**
796
857
  * Expands the selection to include the entire mark at the current position.
797
858
  *
@@ -809,7 +870,7 @@ export { expandMark as expandMark_alias_1 }
809
870
  /**
810
871
  * @public
811
872
  */
812
- declare interface Extension<T extends ExtensionTyping = ExtensionTyping> {
873
+ declare interface Extension<T extends ExtensionTyping<any, any, any> = any> {
813
874
  extension: Extension | Extension[];
814
875
  priority?: Priority;
815
876
  _type?: T;
@@ -826,10 +887,10 @@ export { Extension as Extension_alias_1 }
826
887
  /**
827
888
  * @internal
828
889
  */
829
- declare interface ExtensionTyping<Node extends string = string, Mark extends string = string, Commands extends CommandArgs = CommandArgs> {
830
- NODES?: Node;
831
- MARKS?: Mark;
832
- COMMAND_ARGS?: Commands;
890
+ declare interface ExtensionTyping<N extends string | never = never, M extends string | never = never, C extends CommandTyping | never = never> {
891
+ Nodes: N;
892
+ Marks: M;
893
+ Commands: C;
833
894
  }
834
895
  export { ExtensionTyping }
835
896
  export { ExtensionTyping as ExtensionTyping_alias_1 }
@@ -837,56 +898,47 @@ export { ExtensionTyping as ExtensionTyping_alias_1 }
837
898
  /**
838
899
  * @public
839
900
  */
840
- declare type ExtractCommandAppliers<E extends Extension> = ToCommandApplier<ExtractCommandArgs<E>>;
901
+ declare type ExtractCommandAppliers<E extends Extension> = ToCommandApplier<ExtractCommands<E>>;
841
902
  export { ExtractCommandAppliers }
842
903
  export { ExtractCommandAppliers as ExtractCommandAppliers_alias_1 }
843
904
 
844
- /**
845
- * @internal
846
- */
847
- export declare type ExtractCommandArgs<E extends Extension> = ExtractCommandArgsFromTyping<ExtractTyping<E>>;
848
-
849
- export declare type ExtractCommandArgsFromTyping<T extends ExtensionTyping> = ExtractKey<T, 'COMMAND_ARGS'>;
850
-
851
905
  /**
852
906
  * @public
853
907
  */
854
- declare type ExtractCommandCreators<E extends Extension> = ToCommandCreators<ExtractCommandArgs<E>>;
908
+ declare type ExtractCommandCreators<E extends Extension> = ToCommandCreators<ExtractCommands<E>>;
855
909
  export { ExtractCommandCreators }
856
910
  export { ExtractCommandCreators as ExtractCommandCreators_alias_1 }
857
911
 
858
912
  /**
859
- * @intneral
913
+ * @internal
860
914
  */
861
- export declare type ExtractKey<T, K extends string> = Extract<T, Record<K, any>>[K];
915
+ export declare type ExtractCommands<E extends Extension> = SimplifyUnion<ExtractTyping<E>['Commands']>;
862
916
 
863
917
  /**
864
918
  * @public
865
919
  */
866
- declare type ExtractMarks<E extends Extension> = ExtractMarksFromTyping<ExtractTyping<E>>;
920
+ declare type ExtractMarks<E extends Extension> = ExtractTyping<E>['Marks'];
867
921
  export { ExtractMarks }
868
922
  export { ExtractMarks as ExtractMarks_alias_1 }
869
923
 
870
- export declare type ExtractMarksFromTyping<T extends ExtensionTyping> = ExtractKey<T, 'MARKS'>;
871
-
872
924
  /**
873
925
  * @public
874
926
  */
875
- declare type ExtractNodes<E extends Extension> = ExtractNodesFromTyping<ExtractTyping<E>>;
927
+ declare type ExtractNodes<E extends Extension> = ExtractTyping<E>['Nodes'];
876
928
  export { ExtractNodes }
877
929
  export { ExtractNodes as ExtractNodes_alias_1 }
878
930
 
879
- export declare type ExtractNodesFromTyping<T extends ExtensionTyping> = ExtractKey<T, 'NODES'>;
880
-
881
931
  /**
882
932
  * @internal
883
933
  */
884
934
  export declare type ExtractTyping<E extends Extension> = E extends Extension<infer T> ? T : never;
885
935
 
886
936
  /**
887
- * @public
937
+ * @internal
888
938
  */
889
939
  declare class Facet<Input, Output> {
940
+ private _reducer?;
941
+ private _reduce?;
890
942
  /**
891
943
  * @internal
892
944
  */
@@ -894,61 +946,61 @@ declare class Facet<Input, Output> {
894
946
  /**
895
947
  * @internal
896
948
  */
897
- readonly converter: () => FacetConverter<Input, Output>;
898
- /**
899
- * @internal
900
- */
901
- readonly next: Facet<Output, any> | null;
949
+ readonly parent: Facet<Output, any> | null;
902
950
  /**
903
951
  * @internal
904
952
  */
905
953
  readonly singleton: boolean;
906
954
  /**
955
+ * A index path to retrieve the current facet in a tree from the root.
956
+ *
907
957
  * @internal
908
958
  */
909
- isSchema: boolean;
910
- private constructor();
911
- static define<Input, Output>({ converter, convert, next, singleton, }: FacetOptions<Input, Output>): Facet<Input, Output>;
959
+ readonly path: number[];
912
960
  /**
913
961
  * @internal
914
962
  */
915
- static defineRootFacet<Input>(options: Omit<FacetOptions<Input, Input>, 'next'>): Facet<Input, Input>;
916
- extension(payloads: Input[]): Extension;
963
+ constructor(parent: Facet<Output, any> | null, singleton: boolean, _reducer?: FacetReducer<Input, Output> | undefined, _reduce?: (() => FacetReducer<Input, Output>) | undefined);
964
+ get reducer(): FacetReducer<Input, Output>;
917
965
  }
918
966
  export { Facet }
919
967
  export { Facet as Facet_alias_1 }
920
968
 
921
969
  /**
922
- * @public
923
- */
924
- export declare interface FacetConverter<Input = any, Output = any> {
925
- create: (inputs: Input[]) => Output;
926
- update: (inputs: Input[]) => Output | null;
927
- }
928
-
929
- /**
930
- * @public
970
+ * @internal
931
971
  */
932
972
  export declare class FacetExtensionImpl<Input, Output> extends BaseExtension {
933
973
  readonly facet: Facet<Input, Output>;
934
974
  readonly payloads: Input[];
935
975
  extension: Extension;
936
- hasSchema: boolean;
937
- schema: null;
976
+ /**
977
+ * @internal
978
+ */
938
979
  constructor(facet: Facet<Input, Output>, payloads: Input[]);
980
+ /**
981
+ * @internal
982
+ */
983
+ createTree(priority: Priority): FacetNode<any, any>;
984
+ }
985
+
986
+ export declare class FacetNode<I = any, O = any> {
987
+ readonly facet: Facet<I, O>;
988
+ readonly inputs: Tuple5<I[] | null>;
989
+ readonly children: Map<number, FacetNode>;
990
+ reducers: Tuple5<FacetReducer<I, O> | null>;
991
+ output: Tuple5<O | null> | null;
992
+ constructor(facet: Facet<I, O>, inputs?: Tuple5<I[] | null>, children?: Map<number, FacetNode>);
993
+ private calcOutput;
994
+ getOutput(): Tuple5<O | null>;
995
+ getSingletonOutput(): O | null;
996
+ getRootOutput(): RootOutput;
997
+ isRoot(): boolean;
939
998
  }
940
999
 
941
1000
  /**
942
- * @public
1001
+ * @internal
943
1002
  */
944
- declare interface FacetOptions<Input, Output> {
945
- convert?: (payloads: Input[]) => Output;
946
- converter?: () => FacetConverter<Input, Output>;
947
- next: Facet<Output, any>;
948
- singleton?: boolean;
949
- }
950
- export { FacetOptions }
951
- export { FacetOptions as FacetOptions_alias_1 }
1003
+ export declare type FacetReducer<Input, Output> = (input: Input[]) => Output;
952
1004
 
953
1005
  export declare function findBrowserDocument(options?: {
954
1006
  document?: Document;
@@ -979,8 +1031,6 @@ export declare function getBrowserWindow(options?: {
979
1031
 
980
1032
  export declare function getCustomSelection(state: EditorState, from?: number | null, to?: number | null): Selection_3;
981
1033
 
982
- export declare function getFacetCount(): number;
983
-
984
1034
  /**
985
1035
  * Returns a unique id in the current process that can be used in various places.
986
1036
  *
@@ -1004,6 +1054,11 @@ declare function getNodeType(schema: Schema, type: string | NodeType): NodeType;
1004
1054
  export { getNodeType }
1005
1055
  export { getNodeType as getNodeType_alias_1 }
1006
1056
 
1057
+ /**
1058
+ * @internal
1059
+ */
1060
+ export declare function getNodeTypes(schema: Schema, types: string | NodeType | string[] | NodeType[]): NodeType[];
1061
+
1007
1062
  export declare type GroupedEntries<T extends Record<string, any>> = {
1008
1063
  [K in keyof T]?: T[K][];
1009
1064
  };
@@ -1296,8 +1351,19 @@ declare interface NodeAttrOptions {
1296
1351
  * of a type that has them is created.
1297
1352
  */
1298
1353
  default?: any;
1354
+ /**
1355
+ * Whether the attribute should be kept when the node is split. Set it to
1356
+ * `true` if you want to inherit the attribute from the previous node when
1357
+ * splitting the node by pressing `Enter`.
1358
+ *
1359
+ * @default undefined
1360
+ */
1361
+ splittable?: boolean;
1299
1362
  /**
1300
1363
  * Returns the attribute key and value to be set on the DOM node.
1364
+ *
1365
+ * If the `key` is `"style"`, the value is a string of CSS properties and will
1366
+ * be prepended to the existing `style` attribute on the DOM node.
1301
1367
  */
1302
1368
  toDOM?: (value: any) => [key: string, value: string] | null | void;
1303
1369
  /**
@@ -1420,11 +1486,10 @@ declare type PasteHandler = (view: EditorView, event: ClipboardEvent, slice: Sli
1420
1486
  export { PasteHandler }
1421
1487
  export { PasteHandler as PasteHandler_alias_1 }
1422
1488
 
1423
- declare type Payload = unknown;
1424
-
1425
- export declare type Payloads = PayloadTuple[];
1426
-
1427
- declare type PayloadTuple = Tuple5<Payload[]>;
1489
+ /**
1490
+ * @internal
1491
+ */
1492
+ export declare type Payloads<T> = Tuple5<T[]>;
1428
1493
 
1429
1494
  /**
1430
1495
  * @internal
@@ -1436,9 +1501,9 @@ export { pluginFacet as pluginFacet_alias_1 }
1436
1501
  /**
1437
1502
  * @internal
1438
1503
  */
1439
- declare type PluginPayload = (context: {
1504
+ declare type PluginPayload = Plugin_2 | Plugin_2[] | ((context: {
1440
1505
  schema: Schema;
1441
- }) => Plugin_2 | Plugin_2[];
1506
+ }) => Plugin_2 | Plugin_2[]);
1442
1507
  export { PluginPayload }
1443
1508
  export { PluginPayload as PluginPayload_alias_1 }
1444
1509
 
@@ -1448,11 +1513,11 @@ export { PluginPayload as PluginPayload_alias_1 }
1448
1513
  * @public
1449
1514
  */
1450
1515
  declare enum Priority {
1451
- lowest = 4,
1452
- low = 3,
1516
+ lowest = 0,
1517
+ low = 1,
1453
1518
  default = 2,
1454
- high = 1,
1455
- highest = 0
1519
+ high = 3,
1520
+ highest = 4
1456
1521
  }
1457
1522
  export { Priority }
1458
1523
  export { Priority as Priority_alias_1 }
@@ -1493,9 +1558,27 @@ declare function removeMark(options: {
1493
1558
  export { removeMark }
1494
1559
  export { removeMark as removeMark_alias_1 }
1495
1560
 
1496
- export declare const schemaFacet: Facet<SchemaPayload, SchemaPayload>;
1561
+ export declare const rootFacet: Facet<RootPayload, RootOutput>;
1497
1562
 
1498
- export declare type SchemaPayload = SchemaSpec;
1563
+ export declare type RootOutput = {
1564
+ schema?: Schema | null;
1565
+ commands?: CommandCreators;
1566
+ state?: EditorStateConfig;
1567
+ view?: Omit<DirectEditorProps, 'state'>;
1568
+ };
1569
+
1570
+ export declare type RootPayload = {
1571
+ schema?: Schema | null;
1572
+ commands?: CommandCreators;
1573
+ state?: (ctx: {
1574
+ schema: Schema;
1575
+ }) => EditorStateConfig;
1576
+ view?: Omit<DirectEditorProps, 'state'>;
1577
+ };
1578
+
1579
+ export declare const schemaFacet: Facet<SchemaSpec<any, any>, RootPayload>;
1580
+
1581
+ export declare const schemaSpecFacet: Facet<SchemaSpec<any, any>, SchemaSpec<any, any>>;
1499
1582
 
1500
1583
  declare type ScrollToSelectionHandler = (view: EditorView) => boolean;
1501
1584
  export { ScrollToSelectionHandler }
@@ -1547,7 +1630,7 @@ declare function setNodeAttrs(options: {
1547
1630
  *
1548
1631
  * If current node is not of this type, the command will do nothing.
1549
1632
  */
1550
- type: string | NodeType;
1633
+ type: string | NodeType | string[] | NodeType[];
1551
1634
  /**
1552
1635
  * The attributes to set.
1553
1636
  */
@@ -1568,17 +1651,6 @@ export declare function setSelectionAround(tr: Transaction, pos: number): void;
1568
1651
  */
1569
1652
  export declare type Setter<T> = (value: T) => void;
1570
1653
 
1571
- /**
1572
- * @internal
1573
- */
1574
- declare type SimplifyExtension<E extends Extension | Extension[]> = E extends Extension[] ? Extension<ExceptEmptyValue<{
1575
- NODES: ExtractNodes<E[number]>;
1576
- MARKS: ExtractMarks<E[number]>;
1577
- COMMAND_ARGS: SimplifyUnion<ExtractCommandArgs<E[number]>>;
1578
- }>> : E;
1579
- export { SimplifyExtension }
1580
- export { SimplifyExtension as SimplifyExtension_alias_1 }
1581
-
1582
1654
  /**
1583
1655
  * @intneral
1584
1656
  */
@@ -1586,7 +1658,7 @@ declare type SimplifyUnion<T> = Simplify<UnionToIntersection<T>>;
1586
1658
  export { SimplifyUnion }
1587
1659
  export { SimplifyUnion as SimplifyUnion_alias_1 }
1588
1660
 
1589
- export declare const stateFacet: Facet<StatePayload, StatePayload>;
1661
+ export declare const stateFacet: Facet<StatePayload, RootPayload>;
1590
1662
 
1591
1663
  /**
1592
1664
  * Parse a JSON object to a ProseMirror state.
@@ -1619,19 +1691,17 @@ export declare type StatePayload = (ctx: {
1619
1691
  schema: Schema;
1620
1692
  }) => EditorStateConfig;
1621
1693
 
1694
+ export declare function subtractFacetNode<I, O>(a: FacetNode<I, O>, b: FacetNode<I, O>): FacetNode<I, O>;
1695
+
1622
1696
  declare type TextInputHandler = (view: EditorView, from: number, to: number, text: string) => boolean | void;
1623
1697
  export { TextInputHandler }
1624
1698
  export { TextInputHandler as TextInputHandler_alias_1 }
1625
1699
 
1626
- export declare type ToCommandApplier<T extends CommandArgs> = {
1700
+ export declare type ToCommandApplier<T extends CommandTyping> = {
1627
1701
  [K in keyof T]: CommandApplier<T[K]>;
1628
1702
  };
1629
1703
 
1630
- export declare type ToCommandArgs<T extends CommandCreators> = {
1631
- [K in keyof T]: Parameters<T[K]>;
1632
- };
1633
-
1634
- export declare type ToCommandCreators<T extends CommandArgs> = {
1704
+ export declare type ToCommandCreators<T extends CommandTyping> = {
1635
1705
  [K in keyof T]: CommandCreator<T[K]>;
1636
1706
  };
1637
1707
 
@@ -1660,6 +1730,8 @@ declare function toggleNode({ type, attrs, }: {
1660
1730
  export { toggleNode }
1661
1731
  export { toggleNode as toggleNode_alias_1 }
1662
1732
 
1733
+ export declare function toReversed<T>(arr: T[]): T[];
1734
+
1663
1735
  declare type TripleClickHandler = (view: EditorView, pos: number, event: MouseEvent) => boolean | void;
1664
1736
  export { TripleClickHandler }
1665
1737
  export { TripleClickHandler as TripleClickHandler_alias_1 }
@@ -1668,26 +1740,45 @@ declare type TripleClickOnHandler = (view: EditorView, pos: number, node: Node_3
1668
1740
  export { TripleClickOnHandler }
1669
1741
  export { TripleClickOnHandler as TripleClickOnHandler_alias_1 }
1670
1742
 
1671
- declare type Tuple5<T> = [T, T, T, T, T];
1743
+ /**
1744
+ * @internal
1745
+ */
1746
+ export declare type Tuple5<T> = [T, T, T, T, T];
1672
1747
 
1673
1748
  /**
1674
1749
  * Merge multiple extensions into one.
1675
1750
  *
1676
1751
  * @public
1677
1752
  */
1678
- declare function union<E extends Extension | Extension[]>(extension: E): SimplifyExtension<E>;
1753
+ declare function union<E extends Extension | Extension[]>(extension: E): UnionExtension<E>;
1679
1754
  export { union }
1680
1755
  export { union as union_alias_1 }
1681
1756
 
1757
+ /**
1758
+ * @internal
1759
+ */
1760
+ declare type UnionExtension<E extends Extension | Extension[]> = E extends Extension[] ? Extension<{
1761
+ Nodes: ExtractNodes<E[number]>;
1762
+ Marks: ExtractMarks<E[number]>;
1763
+ Commands: ExtractCommands<E[number]>;
1764
+ }> : E;
1765
+ export { UnionExtension }
1766
+ export { UnionExtension as UnionExtension_alias_1 }
1767
+
1682
1768
  export declare class UnionExtensionImpl<T extends ExtensionTyping = ExtensionTyping> extends BaseExtension<T> implements Extension<T> {
1683
1769
  extension: BaseExtension[];
1684
- private _schema;
1685
- private hasSchemaCount;
1770
+ /**
1771
+ * @internal
1772
+ */
1686
1773
  constructor(extension?: BaseExtension[]);
1687
- get hasSchema(): boolean;
1688
- get schema(): Schema | null;
1774
+ /**
1775
+ * @internal
1776
+ */
1777
+ createTree(priority: Priority): FacetNode;
1689
1778
  }
1690
1779
 
1780
+ export declare function unionFacetNode<I, O>(a: FacetNode<I, O>, b: FacetNode<I, O>): FacetNode<I, O>;
1781
+
1691
1782
  export declare function uniqPush<T>(prev: readonly T[], next: readonly T[]): T[];
1692
1783
 
1693
1784
  export declare function uniqRemove<T>(prev: T[], next: T[]): T[];
@@ -1701,13 +1792,6 @@ declare type UnmountHandler = () => void;
1701
1792
  export { UnmountHandler }
1702
1793
  export { UnmountHandler as UnmountHandler_alias_1 }
1703
1794
 
1704
- export declare function updateExtension(prevInputs: Payloads, prevConverters: Converters, extension: Extension, mode: 'add' | 'remove'): {
1705
- schemaInput: SchemaPayload | null;
1706
- stateInput: StatePayload | null;
1707
- viewInput: ViewPayload | null;
1708
- commandInput: CommandCreators | null;
1709
- };
1710
-
1711
1795
  /**
1712
1796
  * A function that is called when the editor state is updated.
1713
1797
  *
@@ -1720,7 +1804,7 @@ declare type UpdateHandler = (view: EditorView, prevState: EditorState) => void;
1720
1804
  export { UpdateHandler }
1721
1805
  export { UpdateHandler as UpdateHandler_alias_1 }
1722
1806
 
1723
- export declare const viewFacet: Facet<ViewPayload, ViewPayload>;
1807
+ export declare const viewFacet: Facet<ViewPayload, RootPayload>;
1724
1808
 
1725
1809
  export declare type ViewPayload = Omit<DirectEditorProps, 'state'>;
1726
1810
 
@@ -1751,4 +1835,6 @@ export declare function wrap({ nodeType, attrs, }: {
1751
1835
  attrs?: Attrs | null;
1752
1836
  }): Command;
1753
1837
 
1838
+ export declare function zip<T, P>(a: T[], b: P[]): [T, P][];
1839
+
1754
1840
  export { }