@prosekit/core 0.6.1 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,6 +3,7 @@ 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
5
  import type { ContentMatch } from '@prosekit/pm/model';
6
+ import { config as default_alias_1 } from '@prosekit/dev/config-vitest';
6
7
  import type { DirectEditorProps } from '@prosekit/pm/view';
7
8
  import type { DOMEventMap } from '@prosekit/pm/view';
8
9
  import { DOMParser as DOMParser_2 } from '@prosekit/pm/model';
@@ -24,6 +25,7 @@ import { NodeType as NodeType_2 } from 'prosemirror-model';
24
25
  import { NodeView } from '@prosekit/pm/view';
25
26
  import { NodeViewConstructor } from '@prosekit/pm/view';
26
27
  import { Options } from 'tsup';
28
+ import type { ParseOptions } from '@prosekit/pm/model';
27
29
  import { Plugin as Plugin_2 } from '@prosekit/pm/state';
28
30
  import { ProseMirrorFragment } from '@prosekit/pm/model';
29
31
  import { ProseMirrorNode } from '@prosekit/pm/model';
@@ -71,6 +73,13 @@ export { addMark as addMark_alias_1 }
71
73
 
72
74
  export declare function applyAction(operator: Action): Command;
73
75
 
76
+ export declare const applyMarkForTest: ApplyMarkFunction;
77
+
78
+ /**
79
+ * @internal
80
+ */
81
+ export declare type ApplyMarkFunction = (mark: Mark, children: ProseMirrorNode[]) => ProseMirrorNode[];
82
+
74
83
  /**
75
84
  * @internal
76
85
  */
@@ -148,6 +157,8 @@ export declare function baseToggleMark(markType: MarkType, attrs?: Attrs | null,
148
157
  removeWhenPresent: boolean;
149
158
  }): Command;
150
159
 
160
+ export declare function buildNode(type: NodeType, args: [Attrs | NodeChild | null | undefined, ...NodeChild[]], createNode: CreateNodeFunction): ProseMirrorNode;
161
+
151
162
  export declare function cache<T>(fn: () => T): () => T;
152
163
 
153
164
  declare const canUseRegexLookbehind: () => boolean;
@@ -173,7 +184,14 @@ declare const clsx: (...args: Array<string | boolean | null | undefined>) => str
173
184
  export { clsx }
174
185
  export { clsx as clsx_alias_1 }
175
186
 
176
- export declare function collectNodes(content: NodeContent): ProseMirrorNode[];
187
+ /**
188
+ * Collects all nodes from a given content.
189
+ *
190
+ * @public
191
+ */
192
+ declare function collectNodes(content: NodeContent): ProseMirrorNode[];
193
+ export { collectNodes }
194
+ export { collectNodes as collectNodes_alias_1 }
177
195
 
178
196
  export declare function combineEventHandlers<Handler extends (...args: any[]) => boolean | void, Args extends Parameters<Handler> = Parameters<Handler>>(): readonly [(handlers: Handler[]) => void, (...args: Args) => boolean];
179
197
 
@@ -208,19 +226,35 @@ declare function createEditor<E extends Extension>(options: EditorOptions<E>): E
208
226
  export { createEditor }
209
227
  export { createEditor as createEditor_alias_1 }
210
228
 
211
- export declare function createMarkBuilder(getState: () => EditorState | null | undefined, type: MarkType): MarkBuilder;
229
+ /**
230
+ * @internal
231
+ */
232
+ export declare function createMarkBuilders(schema: Schema, getState: () => EditorState | null | undefined, applyMark?: ApplyMarkFunction): Record<string, MarkBuilder>;
233
+
234
+ /**
235
+ * @internal
236
+ */
237
+ export declare function createNodeBuilders(schema: Schema, getState: () => EditorState | null | undefined, createNode?: CreateNodeFunction): Record<string, NodeBuilder>;
238
+
239
+ export declare const createNodeForTest: CreateNodeFunction;
240
+
241
+ /**
242
+ * @internal
243
+ */
244
+ export declare type CreateNodeFunction = (type: NodeType, attrs: Attrs | null, children: ProseMirrorNode[]) => ProseMirrorNode;
212
245
 
213
- export declare function createNodeBuilder(getState: () => EditorState | null | undefined, type: NodeType): NodeBuilder;
246
+ /**
247
+ * @public
248
+ */
249
+ declare function createTestEditor<E extends Extension>(options: EditorOptions<E>): TestEditor<E>;
250
+ export { createTestEditor }
251
+ export { createTestEditor as createTestEditor_alias_1 }
214
252
 
215
253
  export declare function deepEquals<T>(a: T, b: T): boolean;
216
254
 
217
255
  export declare const default_alias: Options | Options[] | ((overrideOptions: Options) => Options | Options[] | Promise<Options | Options[]>);
218
256
 
219
- export declare const default_alias_1: {
220
- test: {
221
- environment: "jsdom";
222
- };
223
- };
257
+ export { default_alias_1 }
224
258
 
225
259
  /**
226
260
  * @internal
@@ -323,7 +357,7 @@ declare function defineBaseKeymap(options?: {
323
357
  * @default Priority.low
324
358
  */
325
359
  priority?: Priority;
326
- }): Extension<any>;
360
+ }): Extension<ExtensionTyping<any, any, any>>;
327
361
  export { defineBaseKeymap }
328
362
  export { defineBaseKeymap as defineBaseKeymap_alias_1 }
329
363
 
@@ -332,7 +366,7 @@ export { defineBaseKeymap as defineBaseKeymap_alias_1 }
332
366
  *
333
367
  * See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handleClick}
334
368
  */
335
- declare function defineClickHandler(handler: ClickHandler): Extension<any>;
369
+ declare function defineClickHandler(handler: ClickHandler): Extension<ExtensionTyping<any, any, any>>;
336
370
  export { defineClickHandler }
337
371
  export { defineClickHandler as defineClickHandler_alias_1 }
338
372
 
@@ -341,7 +375,7 @@ export { defineClickHandler as defineClickHandler_alias_1 }
341
375
  *
342
376
  * See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handleClickOn}
343
377
  */
344
- declare function defineClickOnHandler(handler: ClickOnHandler): Extension<any>;
378
+ declare function defineClickOnHandler(handler: ClickOnHandler): Extension<ExtensionTyping<any, any, any>>;
345
379
  export { defineClickOnHandler }
346
380
  export { defineClickOnHandler as defineClickOnHandler_alias_1 }
347
381
 
@@ -375,7 +409,7 @@ export { defineDoc as defineDoc_alias_1 }
375
409
  *
376
410
  * @public
377
411
  */
378
- declare function defineDocChangeHandler(handler: DocChangeHandler): Extension<any>;
412
+ declare function defineDocChangeHandler(handler: DocChangeHandler): Extension<ExtensionTyping<any, any, any>>;
379
413
  export { defineDocChangeHandler }
380
414
  export { defineDocChangeHandler as defineDocChangeHandler_alias_1 }
381
415
 
@@ -384,7 +418,7 @@ export { defineDocChangeHandler as defineDocChangeHandler_alias_1 }
384
418
  *
385
419
  * @public
386
420
  */
387
- declare function defineDOMEventHandler<Event extends keyof DOMEventMap = string>(event: Event, handler: DOMEventHandler<Event>): Extension<any>;
421
+ declare function defineDOMEventHandler<Event extends keyof DOMEventMap = string>(event: Event, handler: DOMEventHandler<Event>): Extension<ExtensionTyping<any, any, any>>;
388
422
  export { defineDOMEventHandler }
389
423
  export { defineDOMEventHandler as defineDOMEventHandler_alias_1 }
390
424
 
@@ -393,7 +427,7 @@ export { defineDOMEventHandler as defineDOMEventHandler_alias_1 }
393
427
  *
394
428
  * See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handleDoubleClick}
395
429
  */
396
- declare function defineDoubleClickHandler(handler: DoubleClickHandler): Extension<any>;
430
+ declare function defineDoubleClickHandler(handler: DoubleClickHandler): Extension<ExtensionTyping<any, any, any>>;
397
431
  export { defineDoubleClickHandler }
398
432
  export { defineDoubleClickHandler as defineDoubleClickHandler_alias_1 }
399
433
 
@@ -402,7 +436,7 @@ export { defineDoubleClickHandler as defineDoubleClickHandler_alias_1 }
402
436
  *
403
437
  * See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handleDoubleClickOn}
404
438
  */
405
- declare function defineDoubleClickOnHandler(handler: DoubleClickOnHandler): Extension<any>;
439
+ declare function defineDoubleClickOnHandler(handler: DoubleClickOnHandler): Extension<ExtensionTyping<any, any, any>>;
406
440
  export { defineDoubleClickOnHandler }
407
441
  export { defineDoubleClickOnHandler as defineDoubleClickOnHandler_alias_1 }
408
442
 
@@ -411,7 +445,7 @@ export { defineDoubleClickOnHandler as defineDoubleClickOnHandler_alias_1 }
411
445
  *
412
446
  * See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handleDrop}
413
447
  */
414
- declare function defineDropHandler(handler: DropHandler): Extension<any>;
448
+ declare function defineDropHandler(handler: DropHandler): Extension<ExtensionTyping<any, any, any>>;
415
449
  export { defineDropHandler }
416
450
  export { defineDropHandler as defineDropHandler_alias_1 }
417
451
 
@@ -454,7 +488,7 @@ export { defineFacetPayload as defineFacetPayload_alias_1 }
454
488
  *
455
489
  * @public
456
490
  */
457
- declare function defineFocusChangeHandler(handler: FocusChangeHandler): Extension<any>;
491
+ declare function defineFocusChangeHandler(handler: FocusChangeHandler): Extension<ExtensionTyping<any, any, any>>;
458
492
  export { defineFocusChangeHandler }
459
493
  export { defineFocusChangeHandler as defineFocusChangeHandler_alias_1 }
460
494
 
@@ -477,7 +511,7 @@ export { defineHistory as defineHistory_alias_1 }
477
511
  *
478
512
  * See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handleKeyDown}
479
513
  */
480
- declare function defineKeyDownHandler(handler: KeyDownHandler): Extension<any>;
514
+ declare function defineKeyDownHandler(handler: KeyDownHandler): Extension<ExtensionTyping<any, any, any>>;
481
515
  export { defineKeyDownHandler }
482
516
  export { defineKeyDownHandler as defineKeyDownHandler_alias_1 }
483
517
 
@@ -493,7 +527,7 @@ export { defineKeymap as defineKeymap_alias_1 }
493
527
  *
494
528
  * See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handleKeyPress}
495
529
  */
496
- declare function defineKeyPressHandler(handler: KeyPressHandler): Extension<any>;
530
+ declare function defineKeyPressHandler(handler: KeyPressHandler): Extension<ExtensionTyping<any, any, any>>;
497
531
  export { defineKeyPressHandler }
498
532
  export { defineKeyPressHandler as defineKeyPressHandler_alias_1 }
499
533
 
@@ -520,7 +554,7 @@ export { defineMarkSpec as defineMarkSpec_alias_1 }
520
554
  *
521
555
  * @public
522
556
  */
523
- declare function defineMountHandler(handler: MountHandler): Extension<any>;
557
+ declare function defineMountHandler(handler: MountHandler): Extension<ExtensionTyping<any, any, any>>;
524
558
  export { defineMountHandler }
525
559
  export { defineMountHandler as defineMountHandler_alias_1 }
526
560
 
@@ -586,7 +620,7 @@ Commands: never;
586
620
  *
587
621
  * See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handlePaste}
588
622
  */
589
- declare function definePasteHandler(handler: PasteHandler): Extension<any>;
623
+ declare function definePasteHandler(handler: PasteHandler): Extension<ExtensionTyping<any, any, any>>;
590
624
  export { definePasteHandler }
591
625
  export { definePasteHandler as definePasteHandler_alias_1 }
592
626
 
@@ -609,10 +643,70 @@ export { definePlugin as definePlugin_alias_1 }
609
643
  *
610
644
  * See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handleScrollToSelection}
611
645
  */
612
- declare function defineScrollToSelectionHandler(handler: ScrollToSelectionHandler): Extension<any>;
646
+ declare function defineScrollToSelectionHandler(handler: ScrollToSelectionHandler): Extension<ExtensionTyping<any, any, any>>;
613
647
  export { defineScrollToSelectionHandler }
614
648
  export { defineScrollToSelectionHandler as defineScrollToSelectionHandler_alias_1 }
615
649
 
650
+ /**
651
+ * @internal
652
+ */
653
+ export declare function defineTestExtension(): Extension< {
654
+ Nodes: "text" | "doc" | "paragraph";
655
+ Marks: "bold";
656
+ Commands: {
657
+ undo: [];
658
+ redo: [];
659
+ insertText: [{
660
+ text: string;
661
+ from?: number;
662
+ to?: number;
663
+ }];
664
+ insertNode: [options: {
665
+ node: Node_2;
666
+ pos?: number;
667
+ type?: undefined;
668
+ attrs?: undefined;
669
+ } | {
670
+ node?: undefined;
671
+ pos?: number;
672
+ type: string;
673
+ attrs?: Attrs_2;
674
+ }];
675
+ removeNode: [options: {
676
+ type: string | NodeType_2;
677
+ pos?: number;
678
+ }];
679
+ wrap: [{
680
+ nodeType: NodeType_2;
681
+ attrs?: Attrs_2 | null;
682
+ }];
683
+ setBlockType: [options: {
684
+ type: NodeType_2 | string;
685
+ attrs?: Attrs_2 | null;
686
+ from?: number;
687
+ to?: number;
688
+ }];
689
+ setNodeAttrs: [options: {
690
+ type: string | NodeType_2 | string[] | NodeType_2[];
691
+ attrs: Attrs_2;
692
+ pos?: number;
693
+ }];
694
+ selectAll: [];
695
+ addMark: [options: {
696
+ type: string | MarkType_2;
697
+ attrs?: Attrs_2 | null;
698
+ from?: number;
699
+ to?: number;
700
+ }];
701
+ removeMark: [options: {
702
+ type: string | MarkType_2;
703
+ attrs?: Attrs_2 | null;
704
+ from?: number;
705
+ to?: number;
706
+ }];
707
+ };
708
+ }>;
709
+
616
710
  /**
617
711
  * @public
618
712
  */
@@ -629,7 +723,7 @@ export { defineText as defineText_alias_1 }
629
723
  *
630
724
  * See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handleTextInput}
631
725
  */
632
- declare function defineTextInputHandler(handler: TextInputHandler): Extension<any>;
726
+ declare function defineTextInputHandler(handler: TextInputHandler): Extension<ExtensionTyping<any, any, any>>;
633
727
  export { defineTextInputHandler }
634
728
  export { defineTextInputHandler as defineTextInputHandler_alias_1 }
635
729
 
@@ -638,7 +732,7 @@ export { defineTextInputHandler as defineTextInputHandler_alias_1 }
638
732
  *
639
733
  * See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handleTripleClick}
640
734
  */
641
- declare function defineTripleClickHandler(handler: TripleClickHandler): Extension<any>;
735
+ declare function defineTripleClickHandler(handler: TripleClickHandler): Extension<ExtensionTyping<any, any, any>>;
642
736
  export { defineTripleClickHandler }
643
737
  export { defineTripleClickHandler as defineTripleClickHandler_alias_1 }
644
738
 
@@ -647,7 +741,7 @@ export { defineTripleClickHandler as defineTripleClickHandler_alias_1 }
647
741
  *
648
742
  * See {@link https://prosemirror.net/docs/ref/#view.EditorProps.handleTripleClickOn}
649
743
  */
650
- declare function defineTripleClickOnHandler(handler: TripleClickOnHandler): Extension<any>;
744
+ declare function defineTripleClickOnHandler(handler: TripleClickOnHandler): Extension<ExtensionTyping<any, any, any>>;
651
745
  export { defineTripleClickOnHandler }
652
746
  export { defineTripleClickOnHandler as defineTripleClickOnHandler_alias_1 }
653
747
 
@@ -656,7 +750,7 @@ export { defineTripleClickOnHandler as defineTripleClickOnHandler_alias_1 }
656
750
  *
657
751
  * @public
658
752
  */
659
- declare function defineUnmountHandler(handler: UnmountHandler): Extension<any>;
753
+ declare function defineUnmountHandler(handler: UnmountHandler): Extension<ExtensionTyping<any, any, any>>;
660
754
  export { defineUnmountHandler }
661
755
  export { defineUnmountHandler as defineUnmountHandler_alias_1 }
662
756
 
@@ -665,7 +759,7 @@ export { defineUnmountHandler as defineUnmountHandler_alias_1 }
665
759
  *
666
760
  * @public
667
761
  */
668
- declare function defineUpdateHandler(handler: UpdateHandler): Extension<any>;
762
+ declare function defineUpdateHandler(handler: UpdateHandler): Extension<ExtensionTyping<any, any, any>>;
669
763
  export { defineUpdateHandler }
670
764
  export { defineUpdateHandler as defineUpdateHandler_alias_1 }
671
765
 
@@ -689,9 +783,9 @@ export declare class DOMDocumentNotFoundError extends ProseKitError {
689
783
  }
690
784
 
691
785
  /** @public */
692
- declare type DOMDocumentOptions = {
786
+ declare interface DOMDocumentOptions {
693
787
  document?: Document;
694
- };
788
+ }
695
789
  export { DOMDocumentOptions }
696
790
  export { DOMDocumentOptions as DOMDocumentOptions_alias_1 }
697
791
 
@@ -720,16 +814,16 @@ export declare type DOMEventPayload = [event: string, handler: DOMEventHandler];
720
814
  export declare type DOMNode = InstanceType<typeof window.Node>;
721
815
 
722
816
  /** @public */
723
- declare type DOMParserOptions = {
817
+ declare interface DOMParserOptions extends ParseOptions {
724
818
  DOMParser?: typeof DOMParser_2;
725
- };
819
+ }
726
820
  export { DOMParserOptions }
727
821
  export { DOMParserOptions as DOMParserOptions_alias_1 }
728
822
 
729
823
  /** @public */
730
- declare type DOMSerializerOptions = {
824
+ declare interface DOMSerializerOptions {
731
825
  DOMSerializer?: typeof DOMSerializer;
732
- };
826
+ }
733
827
  export { DOMSerializerOptions }
734
828
  export { DOMSerializerOptions as DOMSerializerOptions_alias_1 }
735
829
 
@@ -750,8 +844,11 @@ export { DropHandler as DropHandler_alias_1 }
750
844
  */
751
845
  declare class Editor<E extends Extension = any> {
752
846
  private instance;
753
- private constructor();
754
847
  private afterMounted;
848
+ /**
849
+ * @internal
850
+ */
851
+ constructor(instance: EditorInstance);
755
852
  /**
756
853
  * @internal
757
854
  */
@@ -768,6 +865,9 @@ declare class Editor<E extends Extension = any> {
768
865
  * The editor schema.
769
866
  */
770
867
  get schema(): Schema<ExtractNodes<E>, ExtractMarks<E>>;
868
+ /**
869
+ * All commands defined by the editor.
870
+ */
771
871
  get commands(): ExtractCommandAppliers<E>;
772
872
  /**
773
873
  * Whether the editor is focused.
@@ -790,14 +890,55 @@ declare class Editor<E extends Extension = any> {
790
890
  * Blur the editor.
791
891
  */
792
892
  blur(): void;
893
+ /**
894
+ * Register an extension to the editor. Return a function to unregister the
895
+ * extension.
896
+ */
793
897
  use(extension: Extension): VoidFunction;
898
+ /**
899
+ * The editor's current state.
900
+ */
794
901
  get state(): EditorState;
902
+ /**
903
+ * Update the editor's state.
904
+ *
905
+ * @remarks
906
+ *
907
+ * This is an advanced method. Use it only if you have a specific reason to
908
+ * directly manipulate the editor's state.
909
+ */
910
+ updateState(state: EditorState): void;
795
911
  get nodes(): Record<ExtractNodes<E>, NodeBuilder>;
796
912
  get marks(): Record<ExtractMarks<E>, MarkBuilder>;
797
913
  }
798
914
  export { Editor }
799
915
  export { Editor as Editor_alias_1 }
800
916
 
917
+ /**
918
+ * @internal
919
+ */
920
+ export declare class EditorInstance {
921
+ view: EditorView | null;
922
+ schema: Schema;
923
+ nodeBuilders: Record<string, NodeBuilder>;
924
+ markBuilders: Record<string, MarkBuilder>;
925
+ commandAppliers: Record<string, CommandApplier>;
926
+ private tree;
927
+ private directEditorProps;
928
+ constructor(extension: Extension);
929
+ getState: () => EditorState;
930
+ updateState(state: EditorState): void;
931
+ updateExtension(extension: Extension, add: boolean): void;
932
+ mount(place: HTMLElement): void;
933
+ unmount(): void;
934
+ get mounted(): boolean;
935
+ get assertView(): EditorView;
936
+ definePlugins(plugins: readonly Plugin_2[]): void;
937
+ removePlugins(plugins: readonly Plugin_2[]): void;
938
+ defineCommand<Args extends any[] = any[]>(name: string, commandCreator: CommandCreator<Args>): void;
939
+ removeCommand(name: string): void;
940
+ }
941
+
801
942
  /**
802
943
  * @internal
803
944
  */
@@ -876,7 +1017,7 @@ export { expandMark as expandMark_alias_1 }
876
1017
  /**
877
1018
  * @public
878
1019
  */
879
- declare interface Extension<T extends ExtensionTyping<any, any, any> = any> {
1020
+ declare interface Extension<T extends ExtensionTyping<any, any, any> = ExtensionTyping<any, any, any>> {
880
1021
  extension: Extension | Extension[];
881
1022
  priority?: Priority;
882
1023
  _type?: T;
@@ -934,6 +1075,8 @@ declare type ExtractNodes<E extends Extension> = ExtractTyping<E>['Nodes'];
934
1075
  export { ExtractNodes }
935
1076
  export { ExtractNodes as ExtractNodes_alias_1 }
936
1077
 
1078
+ export declare function extractTags(node: TaggedProseMirrorNode): Record<string, number>;
1079
+
937
1080
  /**
938
1081
  * @internal
939
1082
  */
@@ -1244,9 +1387,9 @@ export { jsonFromState }
1244
1387
  export { jsonFromState as jsonFromState_alias_1 }
1245
1388
 
1246
1389
  /** @public */
1247
- declare type JSONParserOptions = {
1390
+ declare interface JSONParserOptions {
1248
1391
  schema: Schema;
1249
- };
1392
+ }
1250
1393
  export { JSONParserOptions }
1251
1394
  export { JSONParserOptions as JSONParserOptions_alias_1 }
1252
1395
 
@@ -1311,11 +1454,16 @@ declare interface MarkAttrOptions {
1311
1454
  export { MarkAttrOptions }
1312
1455
  export { MarkAttrOptions as MarkAttrOptions_alias_1 }
1313
1456
 
1314
- export declare interface MarkBuilder {
1457
+ /**
1458
+ * @public
1459
+ */
1460
+ declare interface MarkBuilder {
1315
1461
  (attrs: Attrs | null, ...children: NodeChild[]): ProseMirrorNode[];
1316
1462
  (...children: NodeChild[]): ProseMirrorNode[];
1317
- isActive(attrs?: Attrs): boolean;
1463
+ isActive: (attrs?: Attrs) => boolean;
1318
1464
  }
1465
+ export { MarkBuilder }
1466
+ export { MarkBuilder as MarkBuilder_alias_1 }
1319
1467
 
1320
1468
  /**
1321
1469
  * @public
@@ -1385,15 +1533,28 @@ declare interface NodeAttrOptions {
1385
1533
  export { NodeAttrOptions }
1386
1534
  export { NodeAttrOptions as NodeAttrOptions_alias_1 }
1387
1535
 
1388
- export declare interface NodeBuilder {
1536
+ /**
1537
+ * @public
1538
+ */
1539
+ declare interface NodeBuilder {
1389
1540
  (attrs: Attrs | null, ...children: NodeChild[]): ProseMirrorNode;
1390
1541
  (...children: NodeChild[]): ProseMirrorNode;
1391
- isActive(attrs?: Attrs): boolean;
1542
+ isActive: (attrs?: Attrs) => boolean;
1392
1543
  }
1544
+ export { NodeBuilder }
1545
+ export { NodeBuilder as NodeBuilder_alias_1 }
1393
1546
 
1547
+ /**
1548
+ * @public
1549
+ */
1394
1550
  export declare type NodeChild = ProseMirrorNode | string | NodeChild[];
1395
1551
 
1396
- export declare type NodeContent = ProseMirrorNode | ProseMirrorFragment | NodeContent[];
1552
+ /**
1553
+ * @public
1554
+ */
1555
+ declare type NodeContent = ProseMirrorNode | ProseMirrorFragment | NodeContent[];
1556
+ export { NodeContent }
1557
+ export { NodeContent as NodeContent_alias_1 }
1397
1558
 
1398
1559
  /**
1399
1560
  * Parse a HTML element to a ProseMirror node.
@@ -1692,6 +1853,11 @@ export declare function setSelectionAround(tr: Transaction, pos: number): void;
1692
1853
  */
1693
1854
  export declare type Setter<T> = (value: T) => void;
1694
1855
 
1856
+ /**
1857
+ * @internal
1858
+ */
1859
+ export declare function setupEditorExtension<E extends Extension>(options: EditorOptions<E>): E;
1860
+
1695
1861
  /**
1696
1862
  * @internal
1697
1863
  */
@@ -1732,6 +1898,21 @@ export declare type StatePayload = (ctx: {
1732
1898
  schema: Schema;
1733
1899
  }) => EditorStateConfig;
1734
1900
 
1901
+ /**
1902
+ * A JSON representation of the prosemirror step.
1903
+ *
1904
+ * @public
1905
+ */
1906
+ declare interface StepJSON {
1907
+ /**
1908
+ * The type of the step.
1909
+ */
1910
+ stepType: string;
1911
+ [x: string]: unknown;
1912
+ }
1913
+ export { StepJSON }
1914
+ export { StepJSON as StepJSON_alias_1 }
1915
+
1735
1916
  /**
1736
1917
  * Takes two facet nodes and returns a new facet node containing inputs and
1737
1918
  * children from the first node but not the second.
@@ -1742,6 +1923,37 @@ export declare type StatePayload = (ctx: {
1742
1923
  */
1743
1924
  export declare function subtractFacetNode<I, O>(a: FacetNode<I, O>, b: FacetNode<I, O>): FacetNode<I, O>;
1744
1925
 
1926
+ export declare type TaggedProseMirrorNode = ProseMirrorNode & {
1927
+ tags?: Tags;
1928
+ };
1929
+
1930
+ declare type Tags = Record<string, number>;
1931
+
1932
+ /**
1933
+ * An editor for testing purposes.
1934
+ * @public
1935
+ */
1936
+ declare class TestEditor<E extends Extension = Extension> extends Editor<E> {
1937
+ constructor(instance: EditorInstance);
1938
+ /**
1939
+ * Set the editor state to the given document. You can use special tokens
1940
+ * `<a>` and `<b>` to set the anchor and head positions of the selection.
1941
+ *
1942
+ * @example
1943
+ *
1944
+ * ```ts
1945
+ * const editor = createTestEditor({ extension })
1946
+ * const n = editor.nodes
1947
+ * const doc = n.doc(n.paragraph('<a>Hello<b> world!'))
1948
+ * editor.set(doc) // "Hello" is selected.
1949
+ * ```
1950
+ */
1951
+ set(doc: ProseMirrorNode): void;
1952
+ dispatchEvent(event: Event): void;
1953
+ }
1954
+ export { TestEditor }
1955
+ export { TestEditor as TestEditor_alias_1 }
1956
+
1745
1957
  declare type TextInputHandler = (view: EditorView, from: number, to: number, text: string) => boolean | void;
1746
1958
  export { TextInputHandler }
1747
1959
  export { TextInputHandler as TextInputHandler_alias_1 }
@@ -1799,6 +2011,17 @@ export declare type Tuple5<T> = [T, T, T, T, T];
1799
2011
  *
1800
2012
  * @throws If no extensions are provided.
1801
2013
  *
2014
+ * @example
2015
+ *
2016
+ * ```ts
2017
+ * function defineFancyNodes() {
2018
+ * return union([
2019
+ * defineFancyParagraph(),
2020
+ * defineFancyHeading(),
2021
+ * ])
2022
+ * }
2023
+ * ```
2024
+ *
1802
2025
  * @public
1803
2026
  */
1804
2027
  declare function union<const E extends Extension | readonly Extension[]>(extension: E): UnionExtension<E>;
@@ -1870,6 +2093,15 @@ export declare type ViewPayload = Omit<DirectEditorProps, 'state'>;
1870
2093
  export declare function voidFunction(): void;
1871
2094
 
1872
2095
  /**
2096
+ * Return an new extension with the given priority.
2097
+ *
2098
+ * @example
2099
+ * ```ts
2100
+ * import { Priority, withPriority } from 'prosekit/core'
2101
+ *
2102
+ * const extension = withPriority(defineMyExtension(), Priority.high)
2103
+ * ```
2104
+ *
1873
2105
  * @public
1874
2106
  */
1875
2107
  declare function withPriority<T extends Extension>(extension: T, priority: Priority): T;