@prosekit/core 0.7.4 → 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
  *
@@ -272,6 +300,13 @@ declare interface CommandTyping {
272
300
  export { CommandTyping }
273
301
  export { CommandTyping as CommandTyping_alias_1 }
274
302
 
303
+ /**
304
+ * @internal
305
+ */
306
+ declare function containsInlineNode(doc: ProseMirrorNode, from: number, to: number): boolean;
307
+ export { containsInlineNode }
308
+ export { containsInlineNode as containsInlineNode_alias_1 }
309
+
275
310
  /**
276
311
  * @public
277
312
  */
@@ -341,27 +376,7 @@ export { DefaultStateOptions as DefaultStateOptions_alias_1 }
341
376
  *
342
377
  * @public
343
378
  */
344
- declare function defineBaseCommands(): Extension<{
345
- Commands: {
346
- insertText: [{
347
- text: string;
348
- from?: number;
349
- to?: number;
350
- }];
351
- insertNode: [options: InsertNodeOptions];
352
- removeNode: [options: RemoveNodeOptions];
353
- wrap: [WrapOptions];
354
- setBlockType: [options: SetBlockTypeOptions];
355
- setNodeAttrs: [options: SetNodeAttrsOptions];
356
- selectAll: [];
357
- addMark: [options: AddMarkOptions];
358
- removeMark: [options: RemoveMarkOptions];
359
- unsetBlockType: [options?: UnsetBlockTypeOptions | undefined];
360
- unsetMark: [options?: UnsetMarkOptions | undefined];
361
- };
362
- Nodes: never;
363
- Marks: never;
364
- }>;
379
+ declare function defineBaseCommands(): BaseCommandsExtension;
365
380
  export { defineBaseCommands }
366
381
  export { defineBaseCommands as defineBaseCommands_alias_1 }
367
382
 
@@ -377,7 +392,7 @@ declare function defineBaseKeymap(options?: {
377
392
  * @default Priority.low
378
393
  */
379
394
  priority?: Priority;
380
- }): Extension<ExtensionTyping<any, any, any>>;
395
+ }): BaseKeymapExtension;
381
396
  export { defineBaseKeymap }
382
397
  export { defineBaseKeymap as defineBaseKeymap_alias_1 }
383
398
 
@@ -403,26 +418,18 @@ declare function defineCommands<T extends Record<string, CommandCreator> = Recor
403
418
  Commands: {
404
419
  [K in keyof T]: Parameters<T[K]>;
405
420
  };
406
- Nodes: never;
407
- Marks: never;
408
421
  }>;
409
422
  export { defineCommands }
410
423
  export { defineCommands as defineCommands_alias_1 }
411
424
 
412
- declare function defineDefaultState({ defaultDoc, defaultHTML, defaultSelection, }: DefaultStateOptions): Extension;
425
+ declare function defineDefaultState({ defaultDoc, defaultHTML, defaultSelection, }: DefaultStateOptions): PlainExtension;
413
426
  export { defineDefaultState }
414
427
  export { defineDefaultState as defineDefaultState_alias_1 }
415
428
 
416
429
  /**
417
430
  * @public
418
431
  */
419
- declare function defineDoc(): Extension< {
420
- Nodes: {
421
- doc: Attrs_2;
422
- };
423
- Marks: never;
424
- Commands: never;
425
- }>;
432
+ declare function defineDoc(): DocExtension;
426
433
  export { defineDoc }
427
434
  export { defineDoc as defineDoc_alias_1 }
428
435
 
@@ -431,7 +438,7 @@ export { defineDoc as defineDoc_alias_1 }
431
438
  *
432
439
  * @public
433
440
  */
434
- declare function defineDocChangeHandler(handler: DocChangeHandler): Extension<ExtensionTyping<any, any, any>>;
441
+ declare function defineDocChangeHandler(handler: DocChangeHandler): PlainExtension;
435
442
  export { defineDocChangeHandler }
436
443
  export { defineDocChangeHandler as defineDocChangeHandler_alias_1 }
437
444
 
@@ -519,14 +526,7 @@ export { defineFocusChangeHandler as defineFocusChangeHandler_alias_1 }
519
526
  *
520
527
  * @public
521
528
  */
522
- declare function defineHistory({ depth, newGroupDelay, }?: HistoryOptions): Extension< {
523
- Nodes: never;
524
- Marks: never;
525
- Commands: {
526
- readonly undo: [];
527
- readonly redo: [];
528
- };
529
- }>;
529
+ declare function defineHistory({ depth, newGroupDelay, }?: HistoryOptions): HistoryExtension;
530
530
  export { defineHistory }
531
531
  export { defineHistory as defineHistory_alias_1 }
532
532
 
@@ -542,7 +542,7 @@ export { defineKeyDownHandler as defineKeyDownHandler_alias_1 }
542
542
  /**
543
543
  * @public
544
544
  */
545
- declare function defineKeymap(keymap: Keymap): Extension;
545
+ declare function defineKeymap(keymap: Keymap): PlainExtension;
546
546
  export { defineKeymap }
547
547
  export { defineKeymap as defineKeymap_alias_1 }
548
548
 
@@ -559,11 +559,9 @@ export { defineKeyPressHandler as defineKeyPressHandler_alias_1 }
559
559
  * @public
560
560
  */
561
561
  declare function defineMarkAttr<MarkType extends string = string, AttrName extends string = string, AttrType = any>(options: MarkAttrOptions<MarkType, AttrName, AttrType>): Extension<{
562
- Nodes: never;
563
562
  Marks: {
564
563
  [K in MarkType]: AttrType;
565
564
  };
566
- Commands: never;
567
565
  }>;
568
566
  export { defineMarkAttr }
569
567
  export { defineMarkAttr as defineMarkAttr_alias_1 }
@@ -575,8 +573,6 @@ declare function defineMarkSpec<Mark extends string, Attrs extends AnyAttrs = An
575
573
  Marks: {
576
574
  [K in Mark]: Attrs;
577
575
  };
578
- Nodes: never;
579
- Commands: never;
580
576
  }>;
581
577
  export { defineMarkSpec }
582
578
  export { defineMarkSpec as defineMarkSpec_alias_1 }
@@ -586,7 +582,7 @@ export { defineMarkSpec as defineMarkSpec_alias_1 }
586
582
  *
587
583
  * @public
588
584
  */
589
- declare function defineMountHandler(handler: MountHandler): Extension<ExtensionTyping<any, any, any>>;
585
+ declare function defineMountHandler(handler: MountHandler): PlainExtension;
590
586
  export { defineMountHandler }
591
587
  export { defineMountHandler as defineMountHandler_alias_1 }
592
588
 
@@ -601,8 +597,6 @@ declare function defineNodeAttr<NodeType extends string = string, AttrName exten
601
597
  [K in AttrName]: AttrType;
602
598
  };
603
599
  };
604
- Marks: never;
605
- Commands: never;
606
600
  }>;
607
601
  export { defineNodeAttr }
608
602
  export { defineNodeAttr as defineNodeAttr_alias_1 }
@@ -616,8 +610,6 @@ declare function defineNodeSpec<Node extends string, Attrs extends AnyAttrs = An
616
610
  Nodes: {
617
611
  [K in Node]: Attrs;
618
612
  };
619
- Marks: never;
620
- Commands: never;
621
613
  }>;
622
614
  export { defineNodeSpec }
623
615
  export { defineNodeSpec as defineNodeSpec_alias_1 }
@@ -645,13 +637,7 @@ export { defineNodeViewFactory as defineNodeViewFactory_alias_1 }
645
637
  *
646
638
  * Defines a paragraph node spec as the highest priority, because it should be the default block node for most cases.
647
639
  */
648
- declare function defineParagraph(): Extension< {
649
- Nodes: {
650
- paragraph: Attrs_2;
651
- };
652
- Marks: never;
653
- Commands: never;
654
- }>;
640
+ declare function defineParagraph(): ParagraphExtension;
655
641
  export { defineParagraph }
656
642
  export { defineParagraph as defineParagraph_alias_1 }
657
643
 
@@ -660,13 +646,7 @@ export { defineParagraph as defineParagraph_alias_1 }
660
646
  *
661
647
  * Defines a paragraph node spec.
662
648
  */
663
- export declare function defineParagraphSpec(): Extension< {
664
- Nodes: {
665
- paragraph: Attrs_2;
666
- };
667
- Marks: never;
668
- Commands: never;
669
- }>;
649
+ export declare function defineParagraphSpec(): ParagraphSpecExtension;
670
650
 
671
651
  /**
672
652
  * @public
@@ -687,7 +667,7 @@ export { definePasteHandler as definePasteHandler_alias_1 }
687
667
  */
688
668
  declare function definePlugin(plugin: Plugin_2 | Plugin_2[] | ((context: {
689
669
  schema: Schema;
690
- }) => Plugin_2 | Plugin_2[])): Extension;
670
+ }) => Plugin_2 | Plugin_2[])): PlainExtension;
691
671
  export { definePlugin }
692
672
  export { definePlugin as definePlugin_alias_1 }
693
673
 
@@ -703,48 +683,34 @@ export { defineScrollToSelectionHandler as defineScrollToSelectionHandler_alias_
703
683
  /**
704
684
  * @internal
705
685
  */
706
- export declare function defineTestExtension(): Extension<{
707
- Nodes: SimplifyDeeper< {
708
- paragraph: Attrs_2;
709
- doc: Attrs_2;
710
- text: Attrs_2;
711
- heading: Attrs_2;
712
- }>;
713
- Marks: SimplifyDeeper< {
714
- bold: Attrs_2;
715
- italic: Attrs_2;
716
- }>;
717
- Commands: {
718
- insertText: [{
719
- text: string;
720
- from?: number;
721
- to?: number;
722
- }];
723
- insertNode: [options: InsertNodeOptions];
724
- removeNode: [options: RemoveNodeOptions];
725
- wrap: [WrapOptions];
726
- setBlockType: [options: SetBlockTypeOptions];
727
- setNodeAttrs: [options: SetNodeAttrsOptions];
728
- selectAll: [];
729
- addMark: [options: AddMarkOptions];
730
- removeMark: [options: RemoveMarkOptions];
731
- unsetBlockType: [options?: UnsetBlockTypeOptions | undefined];
732
- unsetMark: [options?: UnsetMarkOptions | undefined];
733
- readonly undo: [];
734
- readonly redo: [];
735
- };
736
- }>;
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
+ }>]>;
737
709
 
738
710
  /**
739
711
  * @public
740
712
  */
741
- declare function defineText(): Extension< {
742
- Nodes: {
743
- text: Attrs_2;
744
- };
745
- Marks: never;
746
- Commands: never;
747
- }>;
713
+ declare function defineText(): TextExtension;
748
714
  export { defineText }
749
715
  export { defineText as defineText_alias_1 }
750
716
 
@@ -780,7 +746,7 @@ export { defineTripleClickOnHandler as defineTripleClickOnHandler_alias_1 }
780
746
  *
781
747
  * @public
782
748
  */
783
- declare function defineUnmountHandler(handler: UnmountHandler): Extension<ExtensionTyping<any, any, any>>;
749
+ declare function defineUnmountHandler(handler: UnmountHandler): PlainExtension;
784
750
  export { defineUnmountHandler }
785
751
  export { defineUnmountHandler as defineUnmountHandler_alias_1 }
786
752
 
@@ -789,7 +755,7 @@ export { defineUnmountHandler as defineUnmountHandler_alias_1 }
789
755
  *
790
756
  * @public
791
757
  */
792
- declare function defineUpdateHandler(handler: UpdateHandler): Extension<ExtensionTyping<any, any, any>>;
758
+ declare function defineUpdateHandler(handler: UpdateHandler): PlainExtension;
793
759
  export { defineUpdateHandler }
794
760
  export { defineUpdateHandler as defineUpdateHandler_alias_1 }
795
761
 
@@ -805,6 +771,17 @@ declare type DocChangeHandler = (view: EditorView, prevState: EditorState) => vo
805
771
  export { DocChangeHandler }
806
772
  export { DocChangeHandler as DocChangeHandler_alias_1 }
807
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
+
808
785
  /**
809
786
  * @internal
810
787
  */
@@ -882,7 +859,7 @@ declare class Editor<E extends Extension = any> {
882
859
  /**
883
860
  * @internal
884
861
  */
885
- static create(instance: any): Editor<any>;
862
+ static create(instance: any): Editor;
886
863
  /**
887
864
  * Whether the editor is mounted.
888
865
  */
@@ -1078,9 +1055,9 @@ export { Extension as Extension_alias_1 }
1078
1055
  * @internal
1079
1056
  */
1080
1057
  declare interface ExtensionTyping<N extends NodeTyping | never = never, M extends MarkTyping | never = never, C extends CommandTyping | never = never> {
1081
- Nodes: N;
1082
- Marks: M;
1083
- Commands: C;
1058
+ Nodes?: N;
1059
+ Marks?: M;
1060
+ Commands?: C;
1084
1061
  }
1085
1062
  export { ExtensionTyping }
1086
1063
  export { ExtensionTyping as ExtensionTyping_alias_1 }
@@ -1209,7 +1186,7 @@ export declare class FacetExtensionImpl<Input, Output> extends BaseExtension {
1209
1186
  /**
1210
1187
  * @internal
1211
1188
  */
1212
- createTree(priority: Priority): FacetNode<any, any>;
1189
+ createTree(priority: Priority): FacetNode;
1213
1190
  }
1214
1191
 
1215
1192
  export declare class FacetNode<I = any, O = any> {
@@ -1299,6 +1276,18 @@ export declare type GroupedEntries<T extends Record<string, any>> = {
1299
1276
 
1300
1277
  export declare function groupEntries<T extends Record<string, any>>(entries: ObjectEntries<T>[]): GroupedEntries<T>;
1301
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
+
1302
1291
  /**
1303
1292
  * Options for {@link defineHistory}.
1304
1293
  *
@@ -1346,6 +1335,8 @@ declare function htmlFromNode(node: ProseMirrorNode, options?: DOMSerializerOpti
1346
1335
  export { htmlFromNode }
1347
1336
  export { htmlFromNode as htmlFromNode_alias_1 }
1348
1337
 
1338
+ export declare function includesMark(marks: readonly Mark[], markType: MarkType, attrs?: Attrs | null): boolean;
1339
+
1349
1340
  /**
1350
1341
  * Returns a command that inserts the given node at the current selection or at
1351
1342
  * the given position.
@@ -1391,11 +1382,16 @@ export { InsertNodeOptions as InsertNodeOptions_alias_1 }
1391
1382
  *
1392
1383
  * @public
1393
1384
  */
1394
- 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 = {
1395
1391
  text: string;
1396
1392
  from?: number;
1397
1393
  to?: number;
1398
- }): Command;
1394
+ };
1399
1395
 
1400
1396
  /**
1401
1397
  * @internal
@@ -1441,6 +1437,7 @@ export { isMark as isMark_alias_1 }
1441
1437
  /**
1442
1438
  * Returns true if the given mark is missing in some part of the range.
1443
1439
  * Returns false if the entire range has the given mark.
1440
+ * Returns true if the mark is not allowed in the range.
1444
1441
  *
1445
1442
  * @internal
1446
1443
  */
@@ -1473,6 +1470,13 @@ declare function isProseMirrorNode(node: unknown): node is ProseMirrorNode;
1473
1470
  export { isProseMirrorNode }
1474
1471
  export { isProseMirrorNode as isProseMirrorNode_alias_1 }
1475
1472
 
1473
+ /**
1474
+ * Check if `subset` is a subset of `superset`.
1475
+ *
1476
+ * @internal
1477
+ */
1478
+ export declare function isSubset(subset: Record<string, unknown>, superset: Record<string, unknown>): boolean;
1479
+
1476
1480
  /**
1477
1481
  * @internal
1478
1482
  */
@@ -1856,6 +1860,22 @@ export declare type ObjectEntries<T extends Record<string, any>> = {
1856
1860
 
1857
1861
  export declare function objectEqual<T>(a: T, b: T): boolean;
1858
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
+
1859
1879
  declare type PasteHandler = (view: EditorView, event: ClipboardEvent, slice: Slice) => boolean | void;
1860
1880
  export { PasteHandler }
1861
1881
  export { PasteHandler as PasteHandler_alias_1 }
@@ -1877,6 +1897,19 @@ declare type PickSubType<Type, ParentType> = Type extends ParentType ? [ParentTy
1877
1897
  export { PickSubType }
1878
1898
  export { PickSubType as PickSubType_alias_1 }
1879
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
+
1880
1913
  /**
1881
1914
  * @internal
1882
1915
  */
@@ -2092,51 +2125,29 @@ export declare function setupEditorExtension<E extends Extension>(options: Edito
2092
2125
  * @internal
2093
2126
  */
2094
2127
  export declare function setupTest(): {
2095
- editor: TestEditor<Extension<{
2096
- Nodes: SimplifyDeeper< {
2097
- paragraph: Attrs_2;
2098
- doc: Attrs_2;
2099
- text: Attrs_2;
2100
- heading: Attrs_2;
2101
- }>;
2102
- Marks: SimplifyDeeper< {
2103
- bold: Attrs_2;
2104
- italic: Attrs_2;
2105
- }>;
2106
- Commands: {
2107
- insertText: [{
2108
- text: string;
2109
- from?: number;
2110
- to?: number;
2111
- }];
2112
- insertNode: [options: InsertNodeOptions];
2113
- removeNode: [options: RemoveNodeOptions];
2114
- wrap: [WrapOptions];
2115
- setBlockType: [options: SetBlockTypeOptions];
2116
- setNodeAttrs: [options: SetNodeAttrsOptions];
2117
- selectAll: [];
2118
- addMark: [options: AddMarkOptions];
2119
- removeMark: [options: RemoveMarkOptions];
2120
- unsetBlockType: [options?: UnsetBlockTypeOptions | undefined];
2121
- unsetMark: [options?: UnsetMarkOptions | undefined];
2122
- readonly undo: [];
2123
- readonly redo: [];
2124
- };
2125
- }>>;
2126
- n: ToNodeAction<SimplifyDeeper< {
2127
- paragraph: {
2128
- readonly [x: string]: any;
2128
+ editor: TestEditor<Union<readonly [BaseCommandsExtension, PlainExtension, DocExtension, HistoryExtension, Extension<{
2129
+ Nodes: {
2130
+ paragraph: Attrs_2;
2129
2131
  };
2130
- doc: {
2131
- readonly [x: string]: any;
2132
+ }>, TextExtension, Extension<{
2133
+ Marks: {
2134
+ bold: Attrs_2;
2132
2135
  };
2133
- text: {
2134
- readonly [x: string]: any;
2136
+ }>, Extension<{
2137
+ Marks: {
2138
+ italic: Attrs_2;
2135
2139
  };
2136
- heading: {
2137
- readonly [x: string]: any;
2140
+ }>, Extension<{
2141
+ Nodes: {
2142
+ heading: Attrs_2;
2138
2143
  };
2139
- }>>;
2144
+ }>, Extension<{
2145
+ Nodes: {
2146
+ codeBlock: {
2147
+ language: string;
2148
+ };
2149
+ };
2150
+ }>]>>;
2140
2151
  m: ToMarkAction<SimplifyDeeper< {
2141
2152
  bold: {
2142
2153
  readonly [x: string]: any;
@@ -2145,6 +2156,26 @@ export declare function setupTest(): {
2145
2156
  readonly [x: string]: any;
2146
2157
  };
2147
2158
  }>>;
2159
+ n: {
2160
+ p: NodeAction< {
2161
+ readonly [x: string]: any;
2162
+ }>;
2163
+ doc: NodeAction< {
2164
+ readonly [x: string]: any;
2165
+ }>;
2166
+ paragraph: NodeAction< {
2167
+ readonly [x: string]: any;
2168
+ }>;
2169
+ text: NodeAction< {
2170
+ readonly [x: string]: any;
2171
+ }>;
2172
+ codeBlock: NodeAction< {
2173
+ language: string;
2174
+ }>;
2175
+ heading: NodeAction< {
2176
+ readonly [x: string]: any;
2177
+ }>;
2178
+ };
2148
2179
  };
2149
2180
 
2150
2181
  /**
@@ -2168,7 +2199,7 @@ export { SimplifyDeeper as SimplifyDeeper_alias_1 }
2168
2199
  /**
2169
2200
  * @internal
2170
2201
  */
2171
- declare type SimplifyUnion<T> = Simplify<UnionToIntersection<T>>;
2202
+ declare type SimplifyUnion<T> = Simplify<UnionToIntersection<T extends undefined ? never : T>>;
2172
2203
  export { SimplifyUnion }
2173
2204
  export { SimplifyUnion as SimplifyUnion_alias_1 }
2174
2205
 
@@ -2261,6 +2292,17 @@ declare class TestEditor<E extends Extension = Extension> extends Editor<E> {
2261
2292
  export { TestEditor }
2262
2293
  export { TestEditor as TestEditor_alias_1 }
2263
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
+
2264
2306
  declare type TextInputHandler = (view: EditorView, from: number, to: number, text: string) => boolean | void;
2265
2307
  export { TextInputHandler }
2266
2308
  export { TextInputHandler as TextInputHandler_alias_1 }
@@ -2351,6 +2393,17 @@ export { TripleClickOnHandler as TripleClickOnHandler_alias_1 }
2351
2393
  */
2352
2394
  export declare type Tuple5<T> = [T, T, T, T, T];
2353
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
+
2354
2407
  /**
2355
2408
  * Merge multiple extensions into one.
2356
2409
  *
@@ -2369,11 +2422,14 @@ export declare type Tuple5<T> = [T, T, T, T, T];
2369
2422
  *
2370
2423
  * @public
2371
2424
  */
2372
- 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>;
2373
2428
  export { union }
2374
2429
  export { union as union_alias_1 }
2375
2430
 
2376
2431
  /**
2432
+ * @deprecated Use `Union` instead.
2377
2433
  * @internal
2378
2434
  */
2379
2435
  declare type UnionExtension<E extends Extension | readonly Extension[]> = E extends readonly Extension[] ? Extension<{
@@ -512,15 +512,36 @@ function defineDefaultState({
512
512
  ]);
513
513
  }
514
514
 
515
+ // src/utils/is-subset.ts
516
+ function isSubset(subset, superset) {
517
+ return Object.keys(subset).every((key) => subset[key] === superset[key]);
518
+ }
519
+
520
+ // src/utils/includes-mark.ts
521
+ function includesMark(marks, markType, attrs) {
522
+ attrs = attrs || {};
523
+ return marks.some((mark) => {
524
+ return mark.type === markType && isSubset(attrs, mark.attrs);
525
+ });
526
+ }
527
+
515
528
  // src/utils/is-mark-absent.ts
516
529
  function isMarkAbsent(node, from, to, markType, attrs) {
517
- const mark = attrs ? markType.create(attrs) : markType;
518
530
  let missing = false;
531
+ let available = false;
519
532
  node.nodesBetween(from, to, (node2, pos, parent) => {
520
- if (missing) return false;
521
- missing = !mark.isInSet(node2.marks) && !!parent && parent.type.allowsMarkType(markType);
533
+ if (missing) {
534
+ return false;
535
+ }
536
+ const allowed = (parent == null ? void 0 : parent.type.allowsMarkType(markType)) && !node2.marks.some((m) => m.type !== markType && m.type.excludes(markType));
537
+ if (allowed) {
538
+ available = true;
539
+ if (!includesMark(node2.marks, markType, attrs)) {
540
+ missing = true;
541
+ }
542
+ }
522
543
  });
523
- return missing;
544
+ return available ? missing : true;
524
545
  }
525
546
 
526
547
  // src/utils/is-mark-active.ts
@@ -528,8 +549,8 @@ function isMarkActive(state, type, attrs) {
528
549
  const { from, $from, to, empty } = state.selection;
529
550
  const markType = getMarkType(state.schema, type);
530
551
  if (empty) {
531
- const mark = attrs ? markType.create(attrs) : markType;
532
- return !!mark.isInSet(state.storedMarks || $from.marks());
552
+ const marks = state.storedMarks || $from.marks();
553
+ return includesMark(marks, markType, attrs);
533
554
  } else {
534
555
  return !isMarkAbsent(state.doc, from, to, markType, attrs);
535
556
  }
@@ -589,12 +610,10 @@ var UnionExtensionImpl = class extends BaseExtension {
589
610
  };
590
611
 
591
612
  // src/editor/union.ts
592
- function union(extension) {
593
- const array = Array.isArray(extension) ? extension : [extension];
594
- assert(array.length > 0, "At least one extension is required");
595
- return new UnionExtensionImpl(
596
- array
597
- );
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);
598
617
  }
599
618
 
600
619
  // src/editor/editor.ts
@@ -5,7 +5,7 @@ import {
5
5
  createMarkActions,
6
6
  createNodeActions,
7
7
  setupEditorExtension
8
- } from "./chunk-52BNHWWJ.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';
@@ -136,6 +144,7 @@ export { canUseRegexLookbehind } from './_tsup-dts-rollup';
136
144
  export { clsx } from './_tsup-dts-rollup';
137
145
  export { collectNodes } from './_tsup-dts-rollup';
138
146
  export { NodeContent } from './_tsup-dts-rollup';
147
+ export { containsInlineNode } from './_tsup-dts-rollup';
139
148
  export { defaultBlockAt } from './_tsup-dts-rollup';
140
149
  export { isApple } from './_tsup-dts-rollup';
141
150
  export { _getId } from './_tsup-dts-rollup';
@@ -35,7 +35,7 @@ import {
35
35
  stateFromJSON,
36
36
  toReversed,
37
37
  union
38
- } from "./chunk-52BNHWWJ.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
@@ -1274,6 +1271,16 @@ function collectNodes(content) {
1274
1271
  throw new ProseKitError(`Invalid node content: ${typeof content}`);
1275
1272
  }
1276
1273
 
1274
+ // src/utils/contains-inline-node.ts
1275
+ function containsInlineNode(doc, from, to) {
1276
+ let found = false;
1277
+ doc.nodesBetween(from, to, (node) => {
1278
+ if (found) return false;
1279
+ if (node.isInline) found = true;
1280
+ });
1281
+ return found;
1282
+ }
1283
+
1277
1284
  // src/utils/default-block-at.ts
1278
1285
  function defaultBlockAt(match) {
1279
1286
  for (let i = 0; i < match.edgeCount; i++) {
@@ -1335,6 +1342,7 @@ export {
1335
1342
  canUseRegexLookbehind,
1336
1343
  clsx,
1337
1344
  collectNodes,
1345
+ containsInlineNode,
1338
1346
  createEditor,
1339
1347
  defaultBlockAt,
1340
1348
  defineBaseCommands,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@prosekit/core",
3
3
  "type": "module",
4
- "version": "0.7.4",
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",
47
- "@prosekit/pm": "^0.1.6"
46
+ "type-fest": "^4.23.0",
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": {