@prosekit/core 0.7.5 → 0.7.6

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.
@@ -148,6 +148,27 @@ declare type AttrSpec<AttrType = any> = {
148
148
  export { AttrSpec }
149
149
  export { AttrSpec as AttrSpec_alias_1 }
150
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
+
151
172
  /**
152
173
  * @internal
153
174
  */
@@ -171,6 +192,13 @@ export declare abstract class BaseExtension<T extends ExtensionTyping = Extensio
171
192
  get schema(): Schema | null;
172
193
  }
173
194
 
195
+ /**
196
+ * @internal
197
+ */
198
+ declare type BaseKeymapExtension = PlainExtension;
199
+ export { BaseKeymapExtension }
200
+ export { BaseKeymapExtension as BaseKeymapExtension_alias_1 }
201
+
174
202
  /**
175
203
  * Some basic props for custom node views.
176
204
  *
@@ -348,27 +376,7 @@ export { DefaultStateOptions as DefaultStateOptions_alias_1 }
348
376
  *
349
377
  * @public
350
378
  */
351
- declare function defineBaseCommands(): Extension<{
352
- Commands: {
353
- insertText: [{
354
- text: string;
355
- from?: number;
356
- to?: number;
357
- }];
358
- insertNode: [options: InsertNodeOptions];
359
- removeNode: [options: RemoveNodeOptions];
360
- wrap: [WrapOptions];
361
- setBlockType: [options: SetBlockTypeOptions];
362
- setNodeAttrs: [options: SetNodeAttrsOptions];
363
- selectAll: [];
364
- addMark: [options: AddMarkOptions];
365
- removeMark: [options: RemoveMarkOptions];
366
- unsetBlockType: [options?: UnsetBlockTypeOptions | undefined];
367
- unsetMark: [options?: UnsetMarkOptions | undefined];
368
- };
369
- Nodes: never;
370
- Marks: never;
371
- }>;
379
+ declare function defineBaseCommands(): BaseCommandsExtension;
372
380
  export { defineBaseCommands }
373
381
  export { defineBaseCommands as defineBaseCommands_alias_1 }
374
382
 
@@ -384,7 +392,7 @@ declare function defineBaseKeymap(options?: {
384
392
  * @default Priority.low
385
393
  */
386
394
  priority?: Priority;
387
- }): Extension<ExtensionTyping<any, any, any>>;
395
+ }): BaseKeymapExtension;
388
396
  export { defineBaseKeymap }
389
397
  export { defineBaseKeymap as defineBaseKeymap_alias_1 }
390
398
 
@@ -410,26 +418,18 @@ declare function defineCommands<T extends Record<string, CommandCreator> = Recor
410
418
  Commands: {
411
419
  [K in keyof T]: Parameters<T[K]>;
412
420
  };
413
- Nodes: never;
414
- Marks: never;
415
421
  }>;
416
422
  export { defineCommands }
417
423
  export { defineCommands as defineCommands_alias_1 }
418
424
 
419
- declare function defineDefaultState({ defaultDoc, defaultHTML, defaultSelection, }: DefaultStateOptions): Extension;
425
+ declare function defineDefaultState({ defaultDoc, defaultHTML, defaultSelection, }: DefaultStateOptions): PlainExtension;
420
426
  export { defineDefaultState }
421
427
  export { defineDefaultState as defineDefaultState_alias_1 }
422
428
 
423
429
  /**
424
430
  * @public
425
431
  */
426
- declare function defineDoc(): Extension< {
427
- Nodes: {
428
- doc: Attrs_2;
429
- };
430
- Marks: never;
431
- Commands: never;
432
- }>;
432
+ declare function defineDoc(): DocExtension;
433
433
  export { defineDoc }
434
434
  export { defineDoc as defineDoc_alias_1 }
435
435
 
@@ -438,7 +438,7 @@ export { defineDoc as defineDoc_alias_1 }
438
438
  *
439
439
  * @public
440
440
  */
441
- declare function defineDocChangeHandler(handler: DocChangeHandler): Extension<ExtensionTyping<any, any, any>>;
441
+ declare function defineDocChangeHandler(handler: DocChangeHandler): PlainExtension;
442
442
  export { defineDocChangeHandler }
443
443
  export { defineDocChangeHandler as defineDocChangeHandler_alias_1 }
444
444
 
@@ -526,14 +526,7 @@ export { defineFocusChangeHandler as defineFocusChangeHandler_alias_1 }
526
526
  *
527
527
  * @public
528
528
  */
529
- declare function defineHistory({ depth, newGroupDelay, }?: HistoryOptions): Extension< {
530
- Nodes: never;
531
- Marks: never;
532
- Commands: {
533
- readonly undo: [];
534
- readonly redo: [];
535
- };
536
- }>;
529
+ declare function defineHistory({ depth, newGroupDelay, }?: HistoryOptions): HistoryExtension;
537
530
  export { defineHistory }
538
531
  export { defineHistory as defineHistory_alias_1 }
539
532
 
@@ -549,7 +542,7 @@ export { defineKeyDownHandler as defineKeyDownHandler_alias_1 }
549
542
  /**
550
543
  * @public
551
544
  */
552
- declare function defineKeymap(keymap: Keymap): Extension;
545
+ declare function defineKeymap(keymap: Keymap): PlainExtension;
553
546
  export { defineKeymap }
554
547
  export { defineKeymap as defineKeymap_alias_1 }
555
548
 
@@ -566,11 +559,9 @@ export { defineKeyPressHandler as defineKeyPressHandler_alias_1 }
566
559
  * @public
567
560
  */
568
561
  declare function defineMarkAttr<MarkType extends string = string, AttrName extends string = string, AttrType = any>(options: MarkAttrOptions<MarkType, AttrName, AttrType>): Extension<{
569
- Nodes: never;
570
562
  Marks: {
571
563
  [K in MarkType]: AttrType;
572
564
  };
573
- Commands: never;
574
565
  }>;
575
566
  export { defineMarkAttr }
576
567
  export { defineMarkAttr as defineMarkAttr_alias_1 }
@@ -582,8 +573,6 @@ declare function defineMarkSpec<Mark extends string, Attrs extends AnyAttrs = An
582
573
  Marks: {
583
574
  [K in Mark]: Attrs;
584
575
  };
585
- Nodes: never;
586
- Commands: never;
587
576
  }>;
588
577
  export { defineMarkSpec }
589
578
  export { defineMarkSpec as defineMarkSpec_alias_1 }
@@ -593,7 +582,7 @@ export { defineMarkSpec as defineMarkSpec_alias_1 }
593
582
  *
594
583
  * @public
595
584
  */
596
- declare function defineMountHandler(handler: MountHandler): Extension<ExtensionTyping<any, any, any>>;
585
+ declare function defineMountHandler(handler: MountHandler): PlainExtension;
597
586
  export { defineMountHandler }
598
587
  export { defineMountHandler as defineMountHandler_alias_1 }
599
588
 
@@ -608,8 +597,6 @@ declare function defineNodeAttr<NodeType extends string = string, AttrName exten
608
597
  [K in AttrName]: AttrType;
609
598
  };
610
599
  };
611
- Marks: never;
612
- Commands: never;
613
600
  }>;
614
601
  export { defineNodeAttr }
615
602
  export { defineNodeAttr as defineNodeAttr_alias_1 }
@@ -623,8 +610,6 @@ declare function defineNodeSpec<Node extends string, Attrs extends AnyAttrs = An
623
610
  Nodes: {
624
611
  [K in Node]: Attrs;
625
612
  };
626
- Marks: never;
627
- Commands: never;
628
613
  }>;
629
614
  export { defineNodeSpec }
630
615
  export { defineNodeSpec as defineNodeSpec_alias_1 }
@@ -652,13 +637,7 @@ export { defineNodeViewFactory as defineNodeViewFactory_alias_1 }
652
637
  *
653
638
  * Defines a paragraph node spec as the highest priority, because it should be the default block node for most cases.
654
639
  */
655
- declare function defineParagraph(): Extension< {
656
- Nodes: {
657
- paragraph: Attrs_2;
658
- };
659
- Marks: never;
660
- Commands: never;
661
- }>;
640
+ declare function defineParagraph(): ParagraphExtension;
662
641
  export { defineParagraph }
663
642
  export { defineParagraph as defineParagraph_alias_1 }
664
643
 
@@ -667,13 +646,7 @@ export { defineParagraph as defineParagraph_alias_1 }
667
646
  *
668
647
  * Defines a paragraph node spec.
669
648
  */
670
- export declare function defineParagraphSpec(): Extension< {
671
- Nodes: {
672
- paragraph: Attrs_2;
673
- };
674
- Marks: never;
675
- Commands: never;
676
- }>;
649
+ export declare function defineParagraphSpec(): ParagraphSpecExtension;
677
650
 
678
651
  /**
679
652
  * @public
@@ -694,7 +667,7 @@ export { definePasteHandler as definePasteHandler_alias_1 }
694
667
  */
695
668
  declare function definePlugin(plugin: Plugin_2 | Plugin_2[] | ((context: {
696
669
  schema: Schema;
697
- }) => Plugin_2 | Plugin_2[])): Extension;
670
+ }) => Plugin_2 | Plugin_2[])): PlainExtension;
698
671
  export { definePlugin }
699
672
  export { definePlugin as definePlugin_alias_1 }
700
673
 
@@ -710,51 +683,34 @@ export { defineScrollToSelectionHandler as defineScrollToSelectionHandler_alias_
710
683
  /**
711
684
  * @internal
712
685
  */
713
- export declare function defineTestExtension(): Extension<{
714
- Nodes: SimplifyDeeper< {
715
- paragraph: Attrs_2;
716
- doc: Attrs_2;
717
- text: Attrs_2;
718
- heading: Attrs_2;
719
- codeBlock: {
720
- language: string;
721
- };
722
- }>;
723
- Marks: SimplifyDeeper< {
724
- bold: Attrs_2;
725
- italic: Attrs_2;
726
- }>;
727
- Commands: {
728
- insertText: [{
729
- text: string;
730
- from?: number;
731
- to?: number;
732
- }];
733
- insertNode: [options: InsertNodeOptions];
734
- removeNode: [options: RemoveNodeOptions];
735
- wrap: [WrapOptions];
736
- setBlockType: [options: SetBlockTypeOptions];
737
- setNodeAttrs: [options: SetNodeAttrsOptions];
738
- selectAll: [];
739
- addMark: [options: AddMarkOptions];
740
- removeMark: [options: RemoveMarkOptions];
741
- unsetBlockType: [options?: UnsetBlockTypeOptions | undefined];
742
- unsetMark: [options?: UnsetMarkOptions | undefined];
743
- readonly undo: [];
744
- readonly redo: [];
745
- };
746
- }>;
686
+ export declare function defineTestExtension(): Union<readonly [BaseCommandsExtension, PlainExtension, DocExtension, HistoryExtension, Extension<{
687
+ Nodes: {
688
+ paragraph: Attrs_2;
689
+ };
690
+ }>, TextExtension, Extension<{
691
+ Marks: {
692
+ bold: Attrs_2;
693
+ };
694
+ }>, Extension<{
695
+ Marks: {
696
+ italic: Attrs_2;
697
+ };
698
+ }>, Extension<{
699
+ Nodes: {
700
+ heading: Attrs_2;
701
+ };
702
+ }>, Extension<{
703
+ Nodes: {
704
+ codeBlock: {
705
+ language: string;
706
+ };
707
+ };
708
+ }>]>;
747
709
 
748
710
  /**
749
711
  * @public
750
712
  */
751
- declare function defineText(): Extension< {
752
- Nodes: {
753
- text: Attrs_2;
754
- };
755
- Marks: never;
756
- Commands: never;
757
- }>;
713
+ declare function defineText(): TextExtension;
758
714
  export { defineText }
759
715
  export { defineText as defineText_alias_1 }
760
716
 
@@ -790,7 +746,7 @@ export { defineTripleClickOnHandler as defineTripleClickOnHandler_alias_1 }
790
746
  *
791
747
  * @public
792
748
  */
793
- declare function defineUnmountHandler(handler: UnmountHandler): Extension<ExtensionTyping<any, any, any>>;
749
+ declare function defineUnmountHandler(handler: UnmountHandler): PlainExtension;
794
750
  export { defineUnmountHandler }
795
751
  export { defineUnmountHandler as defineUnmountHandler_alias_1 }
796
752
 
@@ -799,7 +755,7 @@ export { defineUnmountHandler as defineUnmountHandler_alias_1 }
799
755
  *
800
756
  * @public
801
757
  */
802
- declare function defineUpdateHandler(handler: UpdateHandler): Extension<ExtensionTyping<any, any, any>>;
758
+ declare function defineUpdateHandler(handler: UpdateHandler): PlainExtension;
803
759
  export { defineUpdateHandler }
804
760
  export { defineUpdateHandler as defineUpdateHandler_alias_1 }
805
761
 
@@ -815,6 +771,17 @@ declare type DocChangeHandler = (view: EditorView, prevState: EditorState) => vo
815
771
  export { DocChangeHandler }
816
772
  export { DocChangeHandler as DocChangeHandler_alias_1 }
817
773
 
774
+ /**
775
+ * @internal
776
+ */
777
+ declare type DocExtension = Extension<{
778
+ Nodes: {
779
+ doc: Attrs;
780
+ };
781
+ }>;
782
+ export { DocExtension }
783
+ export { DocExtension as DocExtension_alias_1 }
784
+
818
785
  /**
819
786
  * @internal
820
787
  */
@@ -892,7 +859,7 @@ declare class Editor<E extends Extension = any> {
892
859
  /**
893
860
  * @internal
894
861
  */
895
- static create(instance: any): Editor<any>;
862
+ static create(instance: any): Editor;
896
863
  /**
897
864
  * Whether the editor is mounted.
898
865
  */
@@ -1088,9 +1055,9 @@ export { Extension as Extension_alias_1 }
1088
1055
  * @internal
1089
1056
  */
1090
1057
  declare interface ExtensionTyping<N extends NodeTyping | never = never, M extends MarkTyping | never = never, C extends CommandTyping | never = never> {
1091
- Nodes: N;
1092
- Marks: M;
1093
- Commands: C;
1058
+ Nodes?: N;
1059
+ Marks?: M;
1060
+ Commands?: C;
1094
1061
  }
1095
1062
  export { ExtensionTyping }
1096
1063
  export { ExtensionTyping as ExtensionTyping_alias_1 }
@@ -1219,7 +1186,7 @@ export declare class FacetExtensionImpl<Input, Output> extends BaseExtension {
1219
1186
  /**
1220
1187
  * @internal
1221
1188
  */
1222
- createTree(priority: Priority): FacetNode<any, any>;
1189
+ createTree(priority: Priority): FacetNode;
1223
1190
  }
1224
1191
 
1225
1192
  export declare class FacetNode<I = any, O = any> {
@@ -1309,6 +1276,18 @@ export declare type GroupedEntries<T extends Record<string, any>> = {
1309
1276
 
1310
1277
  export declare function groupEntries<T extends Record<string, any>>(entries: ObjectEntries<T>[]): GroupedEntries<T>;
1311
1278
 
1279
+ /**
1280
+ * @internal
1281
+ */
1282
+ declare type HistoryExtension = Extension<{
1283
+ Commands: {
1284
+ undo: [];
1285
+ redo: [];
1286
+ };
1287
+ }>;
1288
+ export { HistoryExtension }
1289
+ export { HistoryExtension as HistoryExtension_alias_1 }
1290
+
1312
1291
  /**
1313
1292
  * Options for {@link defineHistory}.
1314
1293
  *
@@ -1403,11 +1382,16 @@ export { InsertNodeOptions as InsertNodeOptions_alias_1 }
1403
1382
  *
1404
1383
  * @public
1405
1384
  */
1406
- export declare function insertText({ text, from, to, }: {
1385
+ export declare function insertText({ text, from, to }: InsertTextOptions): Command;
1386
+
1387
+ /**
1388
+ * @public
1389
+ */
1390
+ export declare type InsertTextOptions = {
1407
1391
  text: string;
1408
1392
  from?: number;
1409
1393
  to?: number;
1410
- }): Command;
1394
+ };
1411
1395
 
1412
1396
  /**
1413
1397
  * @internal
@@ -1876,6 +1860,22 @@ export declare type ObjectEntries<T extends Record<string, any>> = {
1876
1860
 
1877
1861
  export declare function objectEqual<T>(a: T, b: T): boolean;
1878
1862
 
1863
+ /**
1864
+ * @internal
1865
+ */
1866
+ declare type ParagraphExtension = ParagraphSpecExtension;
1867
+ export { ParagraphExtension }
1868
+ export { ParagraphExtension as ParagraphExtension_alias_1 }
1869
+
1870
+ /**
1871
+ * @internal
1872
+ */
1873
+ declare type ParagraphSpecExtension = Extension<{
1874
+ Nodes: {
1875
+ paragraph: Attrs;
1876
+ };
1877
+ }>;
1878
+
1879
1879
  declare type PasteHandler = (view: EditorView, event: ClipboardEvent, slice: Slice) => boolean | void;
1880
1880
  export { PasteHandler }
1881
1881
  export { PasteHandler as PasteHandler_alias_1 }
@@ -1897,6 +1897,19 @@ declare type PickSubType<Type, ParentType> = Type extends ParentType ? [ParentTy
1897
1897
  export { PickSubType }
1898
1898
  export { PickSubType as PickSubType_alias_1 }
1899
1899
 
1900
+ /**
1901
+ * An extension that does not define any nodes, marks, or commands.
1902
+ *
1903
+ * @internal
1904
+ */
1905
+ declare type PlainExtension = Extension<{
1906
+ Nodes: never;
1907
+ Marks: never;
1908
+ Commands: never;
1909
+ }>;
1910
+ export { PlainExtension }
1911
+ export { PlainExtension as PlainExtension_alias_1 }
1912
+
1900
1913
  /**
1901
1914
  * @internal
1902
1915
  */
@@ -2112,40 +2125,29 @@ export declare function setupEditorExtension<E extends Extension>(options: Edito
2112
2125
  * @internal
2113
2126
  */
2114
2127
  export declare function setupTest(): {
2115
- editor: TestEditor<Extension<{
2116
- Nodes: SimplifyDeeper< {
2117
- paragraph: Attrs_2;
2118
- doc: Attrs_2;
2119
- text: Attrs_2;
2120
- heading: Attrs_2;
2121
- codeBlock: {
2122
- language: string;
2123
- };
2124
- }>;
2125
- Marks: SimplifyDeeper< {
2126
- bold: Attrs_2;
2127
- italic: Attrs_2;
2128
- }>;
2129
- Commands: {
2130
- insertText: [{
2131
- text: string;
2132
- from?: number;
2133
- to?: number;
2134
- }];
2135
- insertNode: [options: InsertNodeOptions];
2136
- removeNode: [options: RemoveNodeOptions];
2137
- wrap: [WrapOptions];
2138
- setBlockType: [options: SetBlockTypeOptions];
2139
- setNodeAttrs: [options: SetNodeAttrsOptions];
2140
- selectAll: [];
2141
- addMark: [options: AddMarkOptions];
2142
- removeMark: [options: RemoveMarkOptions];
2143
- unsetBlockType: [options?: UnsetBlockTypeOptions | undefined];
2144
- unsetMark: [options?: UnsetMarkOptions | undefined];
2145
- readonly undo: [];
2146
- readonly redo: [];
2147
- };
2148
- }>>;
2128
+ editor: TestEditor<Union<readonly [BaseCommandsExtension, PlainExtension, DocExtension, HistoryExtension, Extension<{
2129
+ Nodes: {
2130
+ paragraph: Attrs_2;
2131
+ };
2132
+ }>, TextExtension, Extension<{
2133
+ Marks: {
2134
+ bold: Attrs_2;
2135
+ };
2136
+ }>, Extension<{
2137
+ Marks: {
2138
+ italic: Attrs_2;
2139
+ };
2140
+ }>, Extension<{
2141
+ Nodes: {
2142
+ heading: Attrs_2;
2143
+ };
2144
+ }>, Extension<{
2145
+ Nodes: {
2146
+ codeBlock: {
2147
+ language: string;
2148
+ };
2149
+ };
2150
+ }>]>>;
2149
2151
  m: ToMarkAction<SimplifyDeeper< {
2150
2152
  bold: {
2151
2153
  readonly [x: string]: any;
@@ -2158,21 +2160,21 @@ export declare function setupTest(): {
2158
2160
  p: NodeAction< {
2159
2161
  readonly [x: string]: any;
2160
2162
  }>;
2161
- paragraph: NodeAction< {
2162
- readonly [x: string]: any;
2163
- }>;
2164
2163
  doc: NodeAction< {
2165
2164
  readonly [x: string]: any;
2166
2165
  }>;
2167
- text: NodeAction< {
2166
+ paragraph: NodeAction< {
2168
2167
  readonly [x: string]: any;
2169
2168
  }>;
2170
- heading: NodeAction< {
2169
+ text: NodeAction< {
2171
2170
  readonly [x: string]: any;
2172
2171
  }>;
2173
2172
  codeBlock: NodeAction< {
2174
2173
  language: string;
2175
2174
  }>;
2175
+ heading: NodeAction< {
2176
+ readonly [x: string]: any;
2177
+ }>;
2176
2178
  };
2177
2179
  };
2178
2180
 
@@ -2197,7 +2199,7 @@ export { SimplifyDeeper as SimplifyDeeper_alias_1 }
2197
2199
  /**
2198
2200
  * @internal
2199
2201
  */
2200
- declare type SimplifyUnion<T> = Simplify<UnionToIntersection<T>>;
2202
+ declare type SimplifyUnion<T> = Simplify<UnionToIntersection<T extends undefined ? never : T>>;
2201
2203
  export { SimplifyUnion }
2202
2204
  export { SimplifyUnion as SimplifyUnion_alias_1 }
2203
2205
 
@@ -2290,6 +2292,17 @@ declare class TestEditor<E extends Extension = Extension> extends Editor<E> {
2290
2292
  export { TestEditor }
2291
2293
  export { TestEditor as TestEditor_alias_1 }
2292
2294
 
2295
+ /**
2296
+ * @internal
2297
+ */
2298
+ declare type TextExtension = Extension<{
2299
+ Nodes: {
2300
+ text: Attrs;
2301
+ };
2302
+ }>;
2303
+ export { TextExtension }
2304
+ export { TextExtension as TextExtension_alias_1 }
2305
+
2293
2306
  declare type TextInputHandler = (view: EditorView, from: number, to: number, text: string) => boolean | void;
2294
2307
  export { TextInputHandler }
2295
2308
  export { TextInputHandler as TextInputHandler_alias_1 }
@@ -2380,6 +2393,17 @@ export { TripleClickOnHandler as TripleClickOnHandler_alias_1 }
2380
2393
  */
2381
2394
  export declare type Tuple5<T> = [T, T, T, T, T];
2382
2395
 
2396
+ /**
2397
+ * @internal
2398
+ */
2399
+ declare type Union<E extends readonly Extension[]> = Extension<{
2400
+ Nodes: ExtractNodes<E[number]>;
2401
+ Marks: ExtractMarks<E[number]>;
2402
+ Commands: ExtractCommands<E[number]>;
2403
+ }>;
2404
+ export { Union }
2405
+ export { Union as Union_alias_1 }
2406
+
2383
2407
  /**
2384
2408
  * Merge multiple extensions into one.
2385
2409
  *
@@ -2398,11 +2422,14 @@ export declare type Tuple5<T> = [T, T, T, T, T];
2398
2422
  *
2399
2423
  * @public
2400
2424
  */
2401
- declare function union<const E extends Extension | readonly Extension[]>(extension: E): UnionExtension<E>;
2425
+ declare function union<const E extends readonly Extension[]>(...exts: E): Union<E>;
2426
+
2427
+ declare function union<const E extends readonly Extension[]>(exts: E): Union<E>;
2402
2428
  export { union }
2403
2429
  export { union as union_alias_1 }
2404
2430
 
2405
2431
  /**
2432
+ * @deprecated Use `Union` instead.
2406
2433
  * @internal
2407
2434
  */
2408
2435
  declare type UnionExtension<E extends Extension | readonly Extension[]> = E extends readonly Extension[] ? Extension<{
@@ -610,12 +610,10 @@ var UnionExtensionImpl = class extends BaseExtension {
610
610
  };
611
611
 
612
612
  // src/editor/union.ts
613
- function union(extension) {
614
- const array = Array.isArray(extension) ? extension : [extension];
615
- assert(array.length > 0, "At least one extension is required");
616
- return new UnionExtensionImpl(
617
- array
618
- );
613
+ function union(...exts) {
614
+ const extensions = exts.flat();
615
+ assert(extensions.length > 0, "At least one extension is required");
616
+ return new UnionExtensionImpl(extensions);
619
617
  }
620
618
 
621
619
  // src/editor/editor.ts
@@ -5,7 +5,7 @@ import {
5
5
  createMarkActions,
6
6
  createNodeActions,
7
7
  setupEditorExtension
8
- } from "./chunk-M267LRMB.js";
8
+ } from "./chunk-MOSGJZHV.js";
9
9
 
10
10
  // src/test/test-editor.ts
11
11
  import { EditorState, NodeSelection, TextSelection } from "@prosekit/pm/state";
@@ -36,9 +36,11 @@ export { EditorNotFoundError_alias_1 as EditorNotFoundError } from './_tsup-dts-
36
36
  export { ProseKitError_alias_1 as ProseKitError } from './_tsup-dts-rollup';
37
37
  export { defineBaseCommands } from './_tsup-dts-rollup';
38
38
  export { defineCommands } from './_tsup-dts-rollup';
39
+ export { BaseCommandsExtension } from './_tsup-dts-rollup';
39
40
  export { defineDefaultState } from './_tsup-dts-rollup';
40
41
  export { DefaultStateOptions } from './_tsup-dts-rollup';
41
42
  export { defineDoc } from './_tsup-dts-rollup';
43
+ export { DocExtension } from './_tsup-dts-rollup';
42
44
  export { defineDocChangeHandler } from './_tsup-dts-rollup';
43
45
  export { DocChangeHandler } from './_tsup-dts-rollup';
44
46
  export { defineDOMEventHandler } from './_tsup-dts-rollup';
@@ -76,12 +78,14 @@ export { MountHandler } from './_tsup-dts-rollup';
76
78
  export { UnmountHandler } from './_tsup-dts-rollup';
77
79
  export { UpdateHandler } from './_tsup-dts-rollup';
78
80
  export { defineHistory } from './_tsup-dts-rollup';
81
+ export { HistoryExtension } from './_tsup-dts-rollup';
79
82
  export { HistoryOptions } from './_tsup-dts-rollup';
80
83
  export { defineKeymap } from './_tsup-dts-rollup';
81
84
  export { keymapFacet } from './_tsup-dts-rollup';
82
85
  export { Keymap } from './_tsup-dts-rollup';
83
86
  export { KeymapPayload } from './_tsup-dts-rollup';
84
87
  export { defineBaseKeymap } from './_tsup-dts-rollup';
88
+ export { BaseKeymapExtension } from './_tsup-dts-rollup';
85
89
  export { defineMarkAttr } from './_tsup-dts-rollup';
86
90
  export { defineMarkSpec } from './_tsup-dts-rollup';
87
91
  export { MarkAttrOptions } from './_tsup-dts-rollup';
@@ -97,10 +101,12 @@ export { defineNodeViewFactory } from './_tsup-dts-rollup';
97
101
  export { NodeViewComponentOptions } from './_tsup-dts-rollup';
98
102
  export { NodeViewFactoryOptions } from './_tsup-dts-rollup';
99
103
  export { defineParagraph } from './_tsup-dts-rollup';
104
+ export { ParagraphExtension } from './_tsup-dts-rollup';
100
105
  export { definePlugin } from './_tsup-dts-rollup';
101
106
  export { pluginFacet } from './_tsup-dts-rollup';
102
107
  export { PluginPayload } from './_tsup-dts-rollup';
103
108
  export { defineText } from './_tsup-dts-rollup';
109
+ export { TextExtension } from './_tsup-dts-rollup';
104
110
  export { defineFacet } from './_tsup-dts-rollup';
105
111
  export { Facet } from './_tsup-dts-rollup';
106
112
  export { defineFacetPayload } from './_tsup-dts-rollup';
@@ -116,6 +122,8 @@ export { ExtractMarkActions } from './_tsup-dts-rollup';
116
122
  export { ExtractMarks } from './_tsup-dts-rollup';
117
123
  export { ExtractNodeActions } from './_tsup-dts-rollup';
118
124
  export { ExtractNodes } from './_tsup-dts-rollup';
125
+ export { PlainExtension } from './_tsup-dts-rollup';
126
+ export { Union } from './_tsup-dts-rollup';
119
127
  export { UnionExtension } from './_tsup-dts-rollup';
120
128
  export { CommandAction } from './_tsup-dts-rollup';
121
129
  export { CommandTyping } from './_tsup-dts-rollup';
@@ -35,7 +35,7 @@ import {
35
35
  stateFromJSON,
36
36
  toReversed,
37
37
  union
38
- } from "./chunk-M267LRMB.js";
38
+ } from "./chunk-MOSGJZHV.js";
39
39
 
40
40
  // src/commands/add-mark.ts
41
41
  import "@prosekit/pm/model";
@@ -453,11 +453,7 @@ function withPriority(extension, priority) {
453
453
  }
454
454
 
455
455
  // src/commands/insert-text.ts
456
- function insertText({
457
- text,
458
- from,
459
- to
460
- }) {
456
+ function insertText({ text, from, to }) {
461
457
  return (state, dispatch) => {
462
458
  if (text) {
463
459
  dispatch == null ? void 0 : dispatch(state.tr.insertText(text, from, to));
@@ -545,16 +541,16 @@ function defineNodeAttr(options) {
545
541
  }
546
542
  var nodeSpecFacet = defineFacet({
547
543
  reducer: (payloads) => {
548
- let nodes = OrderedMap2.from({});
544
+ let specs = OrderedMap2.from({});
549
545
  let topNodeName = void 0;
550
546
  const specPayloads = payloads.map((input) => input[0]).filter(isNotNull);
551
547
  const attrPayloads = payloads.map((input) => input[1]).filter(isNotNull);
552
548
  for (const { name, topNode, ...spec } of specPayloads) {
553
- assert(!nodes.get(name), `Node type ${name} can only be defined once`);
549
+ assert(!specs.get(name), `Node type ${name} can only be defined once`);
554
550
  if (topNode) {
555
551
  topNodeName = name;
556
552
  }
557
- nodes = nodes.addToStart(name, spec);
553
+ specs = specs.addToStart(name, spec);
558
554
  }
559
555
  for (const {
560
556
  type,
@@ -564,7 +560,7 @@ var nodeSpecFacet = defineFacet({
564
560
  toDOM,
565
561
  parseDOM
566
562
  } of attrPayloads) {
567
- const spec = nodes.get(type);
563
+ const spec = specs.get(type);
568
564
  assert(spec, `Node type ${type} must be defined`);
569
565
  if (!spec.attrs) {
570
566
  spec.attrs = {};
@@ -629,7 +625,7 @@ var nodeSpecFacet = defineFacet({
629
625
  }
630
626
  }
631
627
  }
632
- return { nodes, topNode: topNodeName };
628
+ return { nodes: specs, topNode: topNodeName };
633
629
  },
634
630
  parent: schemaSpecFacet,
635
631
  singleton: true
@@ -663,17 +659,17 @@ import { PluginKey, ProseMirrorPlugin as ProseMirrorPlugin2 } from "@prosekit/pm
663
659
  import "@prosekit/pm/model";
664
660
  import { Plugin } from "@prosekit/pm/state";
665
661
  function definePlugin(plugin) {
666
- if (plugin instanceof Plugin) {
667
- return defineFacetPayload(pluginFacet, [() => [plugin]]);
668
- }
669
- if (Array.isArray(plugin) && plugin.every((p) => p instanceof Plugin)) {
670
- return defineFacetPayload(pluginFacet, [() => plugin]);
662
+ if (plugin instanceof Plugin || Array.isArray(plugin) && plugin.every((p) => p instanceof Plugin)) {
663
+ return definePluginPayload(() => plugin);
671
664
  }
672
665
  if (typeof plugin === "function") {
673
- return defineFacetPayload(pluginFacet, [plugin]);
666
+ return definePluginPayload(plugin);
674
667
  }
675
668
  throw new TypeError("Invalid plugin");
676
669
  }
670
+ function definePluginPayload(payload) {
671
+ return defineFacetPayload(pluginFacet, [payload]);
672
+ }
677
673
  var pluginFacet = defineFacet({
678
674
  reducer: (payloads) => {
679
675
  return ({ schema }) => {
@@ -698,13 +694,16 @@ var pluginFacet = defineFacet({
698
694
 
699
695
  // src/extensions/events/plugin-view.ts
700
696
  function defineMountHandler(handler) {
701
- return defineFacetPayload(pluginViewFacet, [["mount", handler]]);
697
+ return definePluginViewFacetPayload(["mount", handler]);
702
698
  }
703
699
  function defineUpdateHandler(handler) {
704
- return defineFacetPayload(pluginViewFacet, [["update", handler]]);
700
+ return definePluginViewFacetPayload(["update", handler]);
705
701
  }
706
702
  function defineUnmountHandler(handler) {
707
- return defineFacetPayload(pluginViewFacet, [["unmount", handler]]);
703
+ return definePluginViewFacetPayload(["unmount", handler]);
704
+ }
705
+ function definePluginViewFacetPayload(input) {
706
+ return defineFacetPayload(pluginViewFacet, [input]);
708
707
  }
709
708
  var pluginViewFacet = defineFacet({
710
709
  reduce: () => {
@@ -1058,10 +1057,14 @@ var customBaseKeymap = {
1058
1057
  function defineBaseKeymap(options) {
1059
1058
  var _a;
1060
1059
  const priority = (_a = options == null ? void 0 : options.priority) != null ? _a : 1 /* low */;
1061
- return withPriority(defineKeymap(customBaseKeymap), priority);
1060
+ return withPriority(
1061
+ defineKeymap(customBaseKeymap),
1062
+ priority
1063
+ );
1062
1064
  }
1063
1065
 
1064
1066
  // src/extensions/mark-spec.ts
1067
+ import OrderedMap3 from "orderedmap";
1065
1068
  function defineMarkSpec(options) {
1066
1069
  const payload = [options, void 0];
1067
1070
  return defineFacetPayload(markSpecFacet, [payload]);
@@ -1072,14 +1075,12 @@ function defineMarkAttr(options) {
1072
1075
  }
1073
1076
  var markSpecFacet = defineFacet({
1074
1077
  reducer: (payloads) => {
1075
- const marks = {};
1078
+ let specs = OrderedMap3.from({});
1076
1079
  const specPayloads = payloads.map((input) => input[0]).filter(isNotNull);
1077
1080
  const attrPayloads = payloads.map((input) => input[1]).filter(isNotNull);
1078
1081
  for (const { name, ...spec } of specPayloads) {
1079
- if (marks[name]) {
1080
- throw new ProseKitError(`Mark type ${name} has already been defined`);
1081
- }
1082
- marks[name] = spec;
1082
+ assert(!specs.get(name), `Mark type ${name} can only be defined once`);
1083
+ specs = specs.addToStart(name, spec);
1083
1084
  }
1084
1085
  for (const {
1085
1086
  type,
@@ -1088,12 +1089,8 @@ var markSpecFacet = defineFacet({
1088
1089
  toDOM,
1089
1090
  parseDOM
1090
1091
  } of attrPayloads) {
1091
- const spec = marks[type];
1092
- if (!spec) {
1093
- throw new ProseKitError(
1094
- `Mark type ${type} must be defined before defining attributes`
1095
- );
1096
- }
1092
+ const spec = specs.get(type);
1093
+ assert(spec, `Mark type ${type} must be defined`);
1097
1094
  if (!spec.attrs) {
1098
1095
  spec.attrs = {};
1099
1096
  }
@@ -1146,7 +1143,7 @@ var markSpecFacet = defineFacet({
1146
1143
  }
1147
1144
  }
1148
1145
  }
1149
- return { marks, nodes: {} };
1146
+ return { marks: specs, nodes: {} };
1150
1147
  },
1151
1148
  parent: schemaSpecFacet,
1152
1149
  singleton: true
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@prosekit/core",
3
3
  "type": "module",
4
- "version": "0.7.5",
4
+ "version": "0.7.6",
5
5
  "private": false,
6
6
  "author": {
7
7
  "name": "ocavue",
@@ -43,13 +43,13 @@
43
43
  "clsx": "^2.1.1",
44
44
  "orderedmap": "^2.1.1",
45
45
  "prosemirror-splittable": "^0.1.1",
46
- "type-fest": "^4.22.1",
46
+ "type-fest": "^4.23.0",
47
47
  "@prosekit/pm": "^0.1.7"
48
48
  },
49
49
  "devDependencies": {
50
- "tsup": "^8.1.2",
50
+ "tsup": "^8.2.2",
51
51
  "typescript": "^5.5.3",
52
- "vitest": "^2.0.3",
52
+ "vitest": "^2.0.4",
53
53
  "@prosekit/dev": "0.0.0"
54
54
  },
55
55
  "scripts": {