@prosekit/core 0.0.0-next-20240715062625 → 0.0.0-next-20240724155246
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.
- package/dist/_tsup-dts-rollup.d.ts +481 -125
- package/dist/{chunk-UDQXAK7F.js → chunk-MOSGJZHV.js} +58 -33
- package/dist/prosekit-core-test.js +5 -13
- package/dist/prosekit-core.d.ts +17 -1
- package/dist/prosekit-core.js +24 -29
- package/package.json +5 -5
@@ -1,5 +1,6 @@
|
|
1
1
|
import { AllSelection } from '@prosekit/pm/state';
|
2
2
|
import { Attrs } from '@prosekit/pm/model';
|
3
|
+
import { Attrs as Attrs_2 } from 'prosemirror-model';
|
3
4
|
import { Command } from '@prosekit/pm/state';
|
4
5
|
import type { ContentMatch } from '@prosekit/pm/model';
|
5
6
|
import { config as default_alias_1 } from '@prosekit/dev/config-vitest';
|
@@ -19,8 +20,8 @@ import { NodeSelection } from '@prosekit/pm/state';
|
|
19
20
|
import type { NodeSpec } from '@prosekit/pm/model';
|
20
21
|
import { NodeType } from '@prosekit/pm/model';
|
21
22
|
import { NodeType as NodeType_2 } from 'prosemirror-model';
|
22
|
-
import { NodeView } from '@prosekit/pm/view';
|
23
|
-
import { NodeViewConstructor } from '@prosekit/pm/view';
|
23
|
+
import type { NodeView } from '@prosekit/pm/view';
|
24
|
+
import type { NodeViewConstructor } from '@prosekit/pm/view';
|
24
25
|
import { Options } from 'tsup';
|
25
26
|
import type { ParseOptions } from '@prosekit/pm/model';
|
26
27
|
import { Plugin as Plugin_2 } from '@prosekit/pm/state';
|
@@ -75,6 +76,15 @@ declare interface AddMarkOptions {
|
|
75
76
|
export { AddMarkOptions }
|
76
77
|
export { AddMarkOptions as AddMarkOptions_alias_1 }
|
77
78
|
|
79
|
+
/**
|
80
|
+
* An object holding the attributes of a node.
|
81
|
+
|
82
|
+
* @public
|
83
|
+
*/
|
84
|
+
declare type AnyAttrs = Attrs;
|
85
|
+
export { AnyAttrs }
|
86
|
+
export { AnyAttrs as AnyAttrs_alias_1 }
|
87
|
+
|
78
88
|
export declare function applyAction(operator: Action): Command;
|
79
89
|
|
80
90
|
export declare const applyMarkForTest: ApplyMarkFunction;
|
@@ -106,8 +116,38 @@ export { assert as assert_alias_1 }
|
|
106
116
|
*/
|
107
117
|
export declare function assertTypeEqual<T, U>(_val: IsEqual<T, U>): void;
|
108
118
|
|
119
|
+
/**
|
120
|
+
* Utility function assert that two types are equal in tests.
|
121
|
+
*/
|
122
|
+
export declare function assertTypeEqual_alias_1<T, U>(_val: IsEqual<T, U>): void;
|
123
|
+
|
109
124
|
export declare function attrsMatch(nodeOrMark: ProseMirrorNode | Mark, attrs: Attrs): boolean;
|
110
125
|
|
126
|
+
/**
|
127
|
+
* @public
|
128
|
+
*/
|
129
|
+
declare type AttrSpec<AttrType = any> = {
|
130
|
+
/**
|
131
|
+
* The default value for this attribute, to use when no explicit value is
|
132
|
+
* provided. Attributes that have no default must be provided whenever a node
|
133
|
+
* or mark of a type that has them is created.
|
134
|
+
*/
|
135
|
+
default?: AttrType;
|
136
|
+
/**
|
137
|
+
* A function or type name used to validate values of this attribute. This
|
138
|
+
* will be used when deserializing the attribute from JSON, and when running
|
139
|
+
* [`Node.check`](https://prosemirror.net/docs/ref/#model.Node.check). When a
|
140
|
+
* function, it should raise an exception if the value isn't of the expected
|
141
|
+
* type or shape. When a string, it should be a `|`-separated string of
|
142
|
+
* primitive types (`"number"`, `"string"`, `"boolean"`, `"null"`, and
|
143
|
+
* `"undefined"`), and the library will raise an error when the value is not
|
144
|
+
* one of those types.
|
145
|
+
*/
|
146
|
+
validate?: string | ((value: unknown) => void);
|
147
|
+
};
|
148
|
+
export { AttrSpec }
|
149
|
+
export { AttrSpec as AttrSpec_alias_1 }
|
150
|
+
|
111
151
|
/**
|
112
152
|
* @internal
|
113
153
|
*/
|
@@ -199,10 +239,19 @@ export { collectNodes as collectNodes_alias_1 }
|
|
199
239
|
|
200
240
|
export declare function combineEventHandlers<Handler extends (...args: any[]) => boolean | void, Args extends Parameters<Handler> = Parameters<Handler>>(): readonly [(handlers: Handler[]) => void, (...args: Args) => boolean];
|
201
241
|
|
202
|
-
|
242
|
+
/**
|
243
|
+
* A function to apply a command to the editor. It will return `true` if the command was applied, and `false` otherwise.
|
244
|
+
*
|
245
|
+
* It also has a `canApply` method to check if the command can be applied.
|
246
|
+
*
|
247
|
+
* @public
|
248
|
+
*/
|
249
|
+
declare interface CommandAction<Args extends any[] = any[]> {
|
203
250
|
(...args: Args): boolean;
|
204
251
|
canApply(...args: Args): boolean;
|
205
252
|
}
|
253
|
+
export { CommandAction }
|
254
|
+
export { CommandAction as CommandAction_alias_1 }
|
206
255
|
|
207
256
|
export declare type CommandCreator<Args extends any[] = any[]> = (...arg: Args) => Command;
|
208
257
|
|
@@ -223,6 +272,13 @@ declare interface CommandTyping {
|
|
223
272
|
export { CommandTyping }
|
224
273
|
export { CommandTyping as CommandTyping_alias_1 }
|
225
274
|
|
275
|
+
/**
|
276
|
+
* @internal
|
277
|
+
*/
|
278
|
+
declare function containsInlineNode(doc: ProseMirrorNode, from: number, to: number): boolean;
|
279
|
+
export { containsInlineNode }
|
280
|
+
export { containsInlineNode as containsInlineNode_alias_1 }
|
281
|
+
|
226
282
|
/**
|
227
283
|
* @public
|
228
284
|
*/
|
@@ -233,12 +289,12 @@ export { createEditor as createEditor_alias_1 }
|
|
233
289
|
/**
|
234
290
|
* @internal
|
235
291
|
*/
|
236
|
-
export declare function
|
292
|
+
export declare function createMarkActions(schema: Schema, getState: () => EditorState | null | undefined, applyMark?: ApplyMarkFunction): Record<string, MarkAction>;
|
237
293
|
|
238
294
|
/**
|
239
295
|
* @internal
|
240
296
|
*/
|
241
|
-
export declare function
|
297
|
+
export declare function createNodeActions(schema: Schema, getState: () => EditorState | null | undefined, createNode?: CreateNodeFunction): Record<string, NodeAction>;
|
242
298
|
|
243
299
|
export declare const createNodeForTest: CreateNodeFunction;
|
244
300
|
|
@@ -368,7 +424,9 @@ export { defineDefaultState as defineDefaultState_alias_1 }
|
|
368
424
|
* @public
|
369
425
|
*/
|
370
426
|
declare function defineDoc(): Extension< {
|
371
|
-
Nodes:
|
427
|
+
Nodes: {
|
428
|
+
doc: Attrs_2;
|
429
|
+
};
|
372
430
|
Marks: never;
|
373
431
|
Commands: never;
|
374
432
|
}>;
|
@@ -468,14 +526,14 @@ export { defineFocusChangeHandler as defineFocusChangeHandler_alias_1 }
|
|
468
526
|
*
|
469
527
|
* @public
|
470
528
|
*/
|
471
|
-
declare function defineHistory({ depth, newGroupDelay, }?: HistoryOptions): Extension< {
|
472
|
-
Nodes: never;
|
473
|
-
Marks: never;
|
529
|
+
declare function defineHistory({ depth, newGroupDelay, }?: HistoryOptions): UnionExtension<readonly [Extension<ExtensionTyping<any, any, any>>, Extension<ExtensionTyping<any, any, any>>, Extension< {
|
474
530
|
Commands: {
|
475
531
|
readonly undo: [];
|
476
532
|
readonly redo: [];
|
477
533
|
};
|
478
|
-
|
534
|
+
Nodes: never;
|
535
|
+
Marks: never;
|
536
|
+
}>]>;
|
479
537
|
export { defineHistory }
|
480
538
|
export { defineHistory as defineHistory_alias_1 }
|
481
539
|
|
@@ -507,15 +565,23 @@ export { defineKeyPressHandler as defineKeyPressHandler_alias_1 }
|
|
507
565
|
/**
|
508
566
|
* @public
|
509
567
|
*/
|
510
|
-
declare function defineMarkAttr(options: MarkAttrOptions): Extension
|
568
|
+
declare function defineMarkAttr<MarkType extends string = string, AttrName extends string = string, AttrType = any>(options: MarkAttrOptions<MarkType, AttrName, AttrType>): Extension<{
|
569
|
+
Nodes: never;
|
570
|
+
Marks: {
|
571
|
+
[K in MarkType]: AttrType;
|
572
|
+
};
|
573
|
+
Commands: never;
|
574
|
+
}>;
|
511
575
|
export { defineMarkAttr }
|
512
576
|
export { defineMarkAttr as defineMarkAttr_alias_1 }
|
513
577
|
|
514
578
|
/**
|
515
579
|
* @public
|
516
580
|
*/
|
517
|
-
declare function defineMarkSpec<Mark extends string>(options: MarkSpecOptions<Mark>): Extension<{
|
518
|
-
Marks:
|
581
|
+
declare function defineMarkSpec<Mark extends string, Attrs extends AnyAttrs = AnyAttrs>(options: MarkSpecOptions<Mark, Attrs>): Extension<{
|
582
|
+
Marks: {
|
583
|
+
[K in Mark]: Attrs;
|
584
|
+
};
|
519
585
|
Nodes: never;
|
520
586
|
Commands: never;
|
521
587
|
}>;
|
@@ -536,7 +602,15 @@ export { defineMountHandler as defineMountHandler_alias_1 }
|
|
536
602
|
*
|
537
603
|
* @public
|
538
604
|
*/
|
539
|
-
declare function defineNodeAttr(options: NodeAttrOptions): Extension
|
605
|
+
declare function defineNodeAttr<NodeType extends string = string, AttrName extends string = string, AttrType = any>(options: NodeAttrOptions<NodeType, AttrName, AttrType>): Extension<{
|
606
|
+
Nodes: {
|
607
|
+
[K in NodeType]: {
|
608
|
+
[K in AttrName]: AttrType;
|
609
|
+
};
|
610
|
+
};
|
611
|
+
Marks: never;
|
612
|
+
Commands: never;
|
613
|
+
}>;
|
540
614
|
export { defineNodeAttr }
|
541
615
|
export { defineNodeAttr as defineNodeAttr_alias_1 }
|
542
616
|
|
@@ -545,8 +619,10 @@ export { defineNodeAttr as defineNodeAttr_alias_1 }
|
|
545
619
|
*
|
546
620
|
* @public
|
547
621
|
*/
|
548
|
-
declare function defineNodeSpec<Node extends string>(options: NodeSpecOptions<Node>): Extension<{
|
549
|
-
Nodes:
|
622
|
+
declare function defineNodeSpec<Node extends string, Attrs extends AnyAttrs = AnyAttrs>(options: NodeSpecOptions<Node, Attrs>): Extension<{
|
623
|
+
Nodes: {
|
624
|
+
[K in Node]: Attrs;
|
625
|
+
};
|
550
626
|
Marks: never;
|
551
627
|
Commands: never;
|
552
628
|
}>;
|
@@ -577,7 +653,9 @@ export { defineNodeViewFactory as defineNodeViewFactory_alias_1 }
|
|
577
653
|
* Defines a paragraph node spec as the highest priority, because it should be the default block node for most cases.
|
578
654
|
*/
|
579
655
|
declare function defineParagraph(): Extension< {
|
580
|
-
Nodes:
|
656
|
+
Nodes: {
|
657
|
+
paragraph: Attrs_2;
|
658
|
+
};
|
581
659
|
Marks: never;
|
582
660
|
Commands: never;
|
583
661
|
}>;
|
@@ -590,7 +668,9 @@ export { defineParagraph as defineParagraph_alias_1 }
|
|
590
668
|
* Defines a paragraph node spec.
|
591
669
|
*/
|
592
670
|
export declare function defineParagraphSpec(): Extension< {
|
593
|
-
Nodes:
|
671
|
+
Nodes: {
|
672
|
+
paragraph: Attrs_2;
|
673
|
+
};
|
594
674
|
Marks: never;
|
595
675
|
Commands: never;
|
596
676
|
}>;
|
@@ -630,35 +710,86 @@ export { defineScrollToSelectionHandler as defineScrollToSelectionHandler_alias_
|
|
630
710
|
/**
|
631
711
|
* @internal
|
632
712
|
*/
|
633
|
-
export declare function defineTestExtension(): Extension<{
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
713
|
+
export declare function defineTestExtension(): UnionExtension<readonly [Extension<{
|
714
|
+
Commands: {
|
715
|
+
insertText: [{
|
716
|
+
text: string;
|
717
|
+
from?: number;
|
718
|
+
to?: number;
|
719
|
+
}];
|
720
|
+
insertNode: [options: InsertNodeOptions];
|
721
|
+
removeNode: [options: RemoveNodeOptions];
|
722
|
+
wrap: [WrapOptions];
|
723
|
+
setBlockType: [options: SetBlockTypeOptions];
|
724
|
+
setNodeAttrs: [options: SetNodeAttrsOptions];
|
725
|
+
selectAll: [];
|
726
|
+
addMark: [options: AddMarkOptions];
|
727
|
+
removeMark: [options: RemoveMarkOptions];
|
728
|
+
unsetBlockType: [options?: UnsetBlockTypeOptions | undefined];
|
729
|
+
unsetMark: [options?: UnsetMarkOptions | undefined];
|
730
|
+
};
|
731
|
+
Nodes: never;
|
732
|
+
Marks: never;
|
733
|
+
}>, Extension<ExtensionTyping<any, any, any>>, Extension<{
|
734
|
+
Nodes: {
|
735
|
+
doc: Attrs_2;
|
736
|
+
};
|
737
|
+
Marks: never;
|
738
|
+
Commands: never;
|
739
|
+
}>, UnionExtension<readonly [Extension<ExtensionTyping<any, any, any>>, Extension<ExtensionTyping<any, any, any>>, Extension<{
|
740
|
+
Commands: {
|
741
|
+
readonly undo: [];
|
742
|
+
readonly redo: [];
|
743
|
+
};
|
744
|
+
Nodes: never;
|
745
|
+
Marks: never;
|
746
|
+
}>]>, Extension<{
|
747
|
+
Nodes: {
|
748
|
+
paragraph: Attrs_2;
|
749
|
+
};
|
750
|
+
Marks: never;
|
751
|
+
Commands: never;
|
752
|
+
}>, Extension<{
|
753
|
+
Nodes: {
|
754
|
+
text: Attrs_2;
|
755
|
+
};
|
756
|
+
Marks: never;
|
757
|
+
Commands: never;
|
758
|
+
}>, Extension<{
|
759
|
+
Marks: {
|
760
|
+
bold: Attrs_2;
|
761
|
+
};
|
762
|
+
Nodes: never;
|
763
|
+
Commands: never;
|
764
|
+
}>, Extension<{
|
765
|
+
Marks: {
|
766
|
+
italic: Attrs_2;
|
767
|
+
};
|
768
|
+
Nodes: never;
|
769
|
+
Commands: never;
|
770
|
+
}>, Extension<{
|
771
|
+
Nodes: {
|
772
|
+
heading: Attrs_2;
|
773
|
+
};
|
774
|
+
Marks: never;
|
775
|
+
Commands: never;
|
776
|
+
}>, Extension<{
|
777
|
+
Nodes: {
|
778
|
+
codeBlock: {
|
779
|
+
language: string;
|
780
|
+
};
|
781
|
+
};
|
782
|
+
Marks: never;
|
783
|
+
Commands: never;
|
784
|
+
}>]>;
|
656
785
|
|
657
786
|
/**
|
658
787
|
* @public
|
659
788
|
*/
|
660
789
|
declare function defineText(): Extension< {
|
661
|
-
Nodes:
|
790
|
+
Nodes: {
|
791
|
+
text: Attrs_2;
|
792
|
+
};
|
662
793
|
Marks: never;
|
663
794
|
Commands: never;
|
664
795
|
}>;
|
@@ -811,11 +942,7 @@ declare class Editor<E extends Extension = any> {
|
|
811
942
|
/**
|
812
943
|
* The editor schema.
|
813
944
|
*/
|
814
|
-
get schema(): Schema<
|
815
|
-
/**
|
816
|
-
* All commands defined by the editor.
|
817
|
-
*/
|
818
|
-
get commands(): ExtractCommandAppliers<E>;
|
945
|
+
get schema(): Schema<ExtractNodeNames<E>, ExtractMarkNames<E>>;
|
819
946
|
/**
|
820
947
|
* Whether the editor is focused.
|
821
948
|
*/
|
@@ -855,8 +982,18 @@ declare class Editor<E extends Extension = any> {
|
|
855
982
|
* directly manipulate the editor's state.
|
856
983
|
*/
|
857
984
|
updateState(state: EditorState): void;
|
858
|
-
|
859
|
-
|
985
|
+
/**
|
986
|
+
* All {@link CommandAction}s defined by the editor.
|
987
|
+
*/
|
988
|
+
get commands(): ExtractCommandActions<E>;
|
989
|
+
/**
|
990
|
+
* All {@link NodeAction}s defined by the editor.
|
991
|
+
*/
|
992
|
+
get nodes(): ExtractNodeActions<E>;
|
993
|
+
/**
|
994
|
+
* All {@link MarkAction}s defined by the editor.
|
995
|
+
*/
|
996
|
+
get marks(): ExtractMarkActions<E>;
|
860
997
|
}
|
861
998
|
export { Editor }
|
862
999
|
export { Editor as Editor_alias_1 }
|
@@ -867,9 +1004,9 @@ export { Editor as Editor_alias_1 }
|
|
867
1004
|
export declare class EditorInstance {
|
868
1005
|
view: EditorView | null;
|
869
1006
|
schema: Schema;
|
870
|
-
|
871
|
-
|
872
|
-
|
1007
|
+
nodes: Record<string, NodeAction>;
|
1008
|
+
marks: Record<string, MarkAction>;
|
1009
|
+
commands: Record<string, CommandAction>;
|
873
1010
|
private tree;
|
874
1011
|
private directEditorProps;
|
875
1012
|
constructor(extension: Extension);
|
@@ -988,7 +1125,7 @@ export { Extension as Extension_alias_1 }
|
|
988
1125
|
/**
|
989
1126
|
* @internal
|
990
1127
|
*/
|
991
|
-
declare interface ExtensionTyping<N extends
|
1128
|
+
declare interface ExtensionTyping<N extends NodeTyping | never = never, M extends MarkTyping | never = never, C extends CommandTyping | never = never> {
|
992
1129
|
Nodes: N;
|
993
1130
|
Marks: M;
|
994
1131
|
Commands: C;
|
@@ -997,9 +1134,18 @@ export { ExtensionTyping }
|
|
997
1134
|
export { ExtensionTyping as ExtensionTyping_alias_1 }
|
998
1135
|
|
999
1136
|
/**
|
1137
|
+
* Extracts the {@link CommandAction}s from an extension type.
|
1138
|
+
*
|
1000
1139
|
* @public
|
1001
1140
|
*/
|
1002
|
-
declare type
|
1141
|
+
declare type ExtractCommandActions<E extends Extension> = ToCommandAction<ExtractCommands<E>>;
|
1142
|
+
export { ExtractCommandActions }
|
1143
|
+
export { ExtractCommandActions as ExtractCommandActions_alias_1 }
|
1144
|
+
|
1145
|
+
/**
|
1146
|
+
* @deprecated Use `ExtractCommandActions` instead.
|
1147
|
+
*/
|
1148
|
+
declare type ExtractCommandAppliers<E extends Extension> = ExtractCommandActions<E>;
|
1003
1149
|
export { ExtractCommandAppliers }
|
1004
1150
|
export { ExtractCommandAppliers as ExtractCommandAppliers_alias_1 }
|
1005
1151
|
|
@@ -1015,17 +1161,45 @@ export { ExtractCommandCreators as ExtractCommandCreators_alias_1 }
|
|
1015
1161
|
*/
|
1016
1162
|
export declare type ExtractCommands<E extends Extension> = SimplifyUnion<ExtractTyping<E>['Commands']>;
|
1017
1163
|
|
1164
|
+
/**
|
1165
|
+
* Extracts the {@link MarkAction}s from an extension type.
|
1166
|
+
*
|
1167
|
+
* @public
|
1168
|
+
*/
|
1169
|
+
declare type ExtractMarkActions<E extends Extension> = ToMarkAction<ExtractMarks<E>>;
|
1170
|
+
export { ExtractMarkActions }
|
1171
|
+
export { ExtractMarkActions as ExtractMarkActions_alias_1 }
|
1172
|
+
|
1173
|
+
/**
|
1174
|
+
* @public
|
1175
|
+
*/
|
1176
|
+
export declare type ExtractMarkNames<E extends Extension> = PickStringLiteral<keyof ExtractMarks<E>>;
|
1177
|
+
|
1018
1178
|
/**
|
1019
1179
|
* @public
|
1020
1180
|
*/
|
1021
|
-
declare type ExtractMarks<E extends Extension> = ExtractTyping<E>['Marks']
|
1181
|
+
declare type ExtractMarks<E extends Extension> = SimplifyDeeper<SimplifyUnion<ExtractTyping<E>['Marks']>>;
|
1022
1182
|
export { ExtractMarks }
|
1023
1183
|
export { ExtractMarks as ExtractMarks_alias_1 }
|
1024
1184
|
|
1185
|
+
/**
|
1186
|
+
* Extracts the {@link NodeAction}s from an extension type.
|
1187
|
+
*
|
1188
|
+
* @public
|
1189
|
+
*/
|
1190
|
+
declare type ExtractNodeActions<E extends Extension> = ToNodeAction<ExtractNodes<E>>;
|
1191
|
+
export { ExtractNodeActions }
|
1192
|
+
export { ExtractNodeActions as ExtractNodeActions_alias_1 }
|
1193
|
+
|
1194
|
+
/**
|
1195
|
+
* @public
|
1196
|
+
*/
|
1197
|
+
export declare type ExtractNodeNames<E extends Extension> = PickStringLiteral<keyof ExtractNodes<E>>;
|
1198
|
+
|
1025
1199
|
/**
|
1026
1200
|
* @public
|
1027
1201
|
*/
|
1028
|
-
declare type ExtractNodes<E extends Extension> = ExtractTyping<E>['Nodes']
|
1202
|
+
declare type ExtractNodes<E extends Extension> = SimplifyDeeper<SimplifyUnion<ExtractTyping<E>['Nodes']>>;
|
1029
1203
|
export { ExtractNodes }
|
1030
1204
|
export { ExtractNodes as ExtractNodes_alias_1 }
|
1031
1205
|
|
@@ -1034,7 +1208,7 @@ export declare function extractTags(node: TaggedProseMirrorNode): Record<string,
|
|
1034
1208
|
/**
|
1035
1209
|
* @internal
|
1036
1210
|
*/
|
1037
|
-
export declare type ExtractTyping<E extends Extension> = E extends Extension<ExtensionTyping<infer N, infer M, infer C>> ? ExtensionTyping<
|
1211
|
+
export declare type ExtractTyping<E extends Extension> = E extends Extension<ExtensionTyping<infer N, infer M, infer C>> ? ExtensionTyping<PickSubType<N, NodeTyping>, PickSubType<M, MarkTyping>, PickSubType<C, CommandTyping>> : never;
|
1038
1212
|
|
1039
1213
|
/**
|
1040
1214
|
* @internal
|
@@ -1220,6 +1394,8 @@ declare function htmlFromNode(node: ProseMirrorNode, options?: DOMSerializerOpti
|
|
1220
1394
|
export { htmlFromNode }
|
1221
1395
|
export { htmlFromNode as htmlFromNode_alias_1 }
|
1222
1396
|
|
1397
|
+
export declare function includesMark(marks: readonly Mark[], markType: MarkType, attrs?: Attrs | null): boolean;
|
1398
|
+
|
1223
1399
|
/**
|
1224
1400
|
* Returns a command that inserts the given node at the current selection or at
|
1225
1401
|
* the given position.
|
@@ -1315,6 +1491,7 @@ export { isMark as isMark_alias_1 }
|
|
1315
1491
|
/**
|
1316
1492
|
* Returns true if the given mark is missing in some part of the range.
|
1317
1493
|
* Returns false if the entire range has the given mark.
|
1494
|
+
* Returns true if the mark is not allowed in the range.
|
1318
1495
|
*
|
1319
1496
|
* @internal
|
1320
1497
|
*/
|
@@ -1347,6 +1524,13 @@ declare function isProseMirrorNode(node: unknown): node is ProseMirrorNode;
|
|
1347
1524
|
export { isProseMirrorNode }
|
1348
1525
|
export { isProseMirrorNode as isProseMirrorNode_alias_1 }
|
1349
1526
|
|
1527
|
+
/**
|
1528
|
+
* Check if `subset` is a subset of `superset`.
|
1529
|
+
*
|
1530
|
+
* @internal
|
1531
|
+
*/
|
1532
|
+
export declare function isSubset(subset: Record<string, unknown>, superset: Record<string, unknown>): boolean;
|
1533
|
+
|
1350
1534
|
/**
|
1351
1535
|
* @internal
|
1352
1536
|
*/
|
@@ -1427,23 +1611,39 @@ export { KeyPressHandler }
|
|
1427
1611
|
export { KeyPressHandler as KeyPressHandler_alias_1 }
|
1428
1612
|
|
1429
1613
|
/**
|
1614
|
+
* A function for creating a mark with optional attributes and any number of
|
1615
|
+
* children.
|
1616
|
+
*
|
1617
|
+
* It also has a `isActive` method for checking if the mark is active in the
|
1618
|
+
* current editor selection.
|
1619
|
+
*
|
1430
1620
|
* @public
|
1431
1621
|
*/
|
1432
|
-
declare interface
|
1622
|
+
declare interface MarkAction<Attrs extends AnyAttrs = AnyAttrs> {
|
1623
|
+
(attrs: Attrs | null, ...children: NodeChild[]): ProseMirrorNode[];
|
1624
|
+
(...children: NodeChild[]): ProseMirrorNode[];
|
1433
1625
|
/**
|
1434
|
-
*
|
1626
|
+
* Checks if the mark is active in the current editor selection. If the
|
1627
|
+
* optional `attrs` parameter is provided, it will check if the mark is active
|
1628
|
+
* with the given attributes.
|
1435
1629
|
*/
|
1436
|
-
|
1630
|
+
isActive: (attrs?: Attrs) => boolean;
|
1631
|
+
}
|
1632
|
+
export { MarkAction }
|
1633
|
+
export { MarkAction as MarkAction_alias_1 }
|
1634
|
+
|
1635
|
+
/**
|
1636
|
+
* @public
|
1637
|
+
*/
|
1638
|
+
declare interface MarkAttrOptions<MarkName extends string = string, AttrName extends string = string, AttrType = any> extends AttrSpec<AttrType> {
|
1437
1639
|
/**
|
1438
|
-
* The name of the
|
1640
|
+
* The name of the mark type.
|
1439
1641
|
*/
|
1440
|
-
|
1642
|
+
type: MarkName;
|
1441
1643
|
/**
|
1442
|
-
* The
|
1443
|
-
* provided. Attributes that have no default must be provided whenever a mark
|
1444
|
-
* of a type that has them is created.
|
1644
|
+
* The name of the attribute.
|
1445
1645
|
*/
|
1446
|
-
|
1646
|
+
attr: AttrName;
|
1447
1647
|
/**
|
1448
1648
|
* Returns the attribute key and value to be set on the DOM node.
|
1449
1649
|
*/
|
@@ -1457,25 +1657,39 @@ export { MarkAttrOptions }
|
|
1457
1657
|
export { MarkAttrOptions as MarkAttrOptions_alias_1 }
|
1458
1658
|
|
1459
1659
|
/**
|
1460
|
-
* @
|
1660
|
+
* @deprecated Use type {@link MarkAction} instead.
|
1461
1661
|
*/
|
1462
|
-
declare
|
1463
|
-
(attrs: Attrs | null, ...children: NodeChild[]): ProseMirrorNode[];
|
1464
|
-
(...children: NodeChild[]): ProseMirrorNode[];
|
1465
|
-
isActive: (attrs?: Attrs) => boolean;
|
1466
|
-
}
|
1662
|
+
declare type MarkBuilder = MarkAction;
|
1467
1663
|
export { MarkBuilder }
|
1468
1664
|
export { MarkBuilder as MarkBuilder_alias_1 }
|
1469
1665
|
|
1470
1666
|
/**
|
1471
1667
|
* @public
|
1472
1668
|
*/
|
1473
|
-
declare interface MarkSpecOptions<MarkName extends string = string> extends MarkSpec {
|
1669
|
+
declare interface MarkSpecOptions<MarkName extends string = string, Attrs extends AnyAttrs = AnyAttrs> extends MarkSpec {
|
1670
|
+
/**
|
1671
|
+
* The name of the mark type.
|
1672
|
+
*/
|
1474
1673
|
name: MarkName;
|
1674
|
+
/**
|
1675
|
+
* The attributes that marks of this type get.
|
1676
|
+
*/
|
1677
|
+
attrs?: {
|
1678
|
+
[K in keyof Attrs]: AttrSpec<Attrs[K]>;
|
1679
|
+
};
|
1475
1680
|
}
|
1476
1681
|
export { MarkSpecOptions }
|
1477
1682
|
export { MarkSpecOptions as MarkSpecOptions_alias_1 }
|
1478
1683
|
|
1684
|
+
/**
|
1685
|
+
* @internal
|
1686
|
+
*/
|
1687
|
+
declare interface MarkTyping {
|
1688
|
+
[name: string]: Record<string, any>;
|
1689
|
+
}
|
1690
|
+
export { MarkTyping }
|
1691
|
+
export { MarkTyping as MarkTyping_alias_1 }
|
1692
|
+
|
1479
1693
|
/**
|
1480
1694
|
* @internal
|
1481
1695
|
*/
|
@@ -1495,23 +1709,39 @@ export { MountHandler }
|
|
1495
1709
|
export { MountHandler as MountHandler_alias_1 }
|
1496
1710
|
|
1497
1711
|
/**
|
1712
|
+
* A function for creating a node with optional attributes and any number of
|
1713
|
+
* children.
|
1714
|
+
*
|
1715
|
+
* It also has a `isActive` method for checking if the node is active in the
|
1716
|
+
* current editor selection.
|
1717
|
+
*
|
1498
1718
|
* @public
|
1499
1719
|
*/
|
1500
|
-
declare interface
|
1720
|
+
declare interface NodeAction<Attrs extends AnyAttrs = AnyAttrs> {
|
1721
|
+
(attrs: Attrs | null, ...children: NodeChild[]): ProseMirrorNode;
|
1722
|
+
(...children: NodeChild[]): ProseMirrorNode;
|
1501
1723
|
/**
|
1502
|
-
*
|
1724
|
+
* Checks if the node is active in the current editor selection. If the
|
1725
|
+
* optional `attrs` parameter is provided, it will check if the node is active
|
1726
|
+
* with the given attributes.
|
1503
1727
|
*/
|
1504
|
-
|
1728
|
+
isActive: (attrs?: Attrs) => boolean;
|
1729
|
+
}
|
1730
|
+
export { NodeAction }
|
1731
|
+
export { NodeAction as NodeAction_alias_1 }
|
1732
|
+
|
1733
|
+
/**
|
1734
|
+
* @public
|
1735
|
+
*/
|
1736
|
+
declare interface NodeAttrOptions<NodeName extends string = string, AttrName extends string = string, AttrType = any> extends AttrSpec<AttrType> {
|
1505
1737
|
/**
|
1506
|
-
* The name of the
|
1738
|
+
* The name of the node type.
|
1507
1739
|
*/
|
1508
|
-
|
1740
|
+
type: NodeName;
|
1509
1741
|
/**
|
1510
|
-
* The
|
1511
|
-
* provided. Attributes that have no default must be provided whenever a node
|
1512
|
-
* of a type that has them is created.
|
1742
|
+
* The name of the attribute.
|
1513
1743
|
*/
|
1514
|
-
|
1744
|
+
attr: AttrName;
|
1515
1745
|
/**
|
1516
1746
|
* Whether the attribute should be kept when the node is split. Set it to
|
1517
1747
|
* `true` if you want to inherit the attribute from the previous node when
|
@@ -1536,20 +1766,20 @@ export { NodeAttrOptions }
|
|
1536
1766
|
export { NodeAttrOptions as NodeAttrOptions_alias_1 }
|
1537
1767
|
|
1538
1768
|
/**
|
1539
|
-
* @
|
1769
|
+
* @deprecated Use type {@link NodeAction} instead.
|
1540
1770
|
*/
|
1541
|
-
declare
|
1542
|
-
(attrs: Attrs | null, ...children: NodeChild[]): ProseMirrorNode;
|
1543
|
-
(...children: NodeChild[]): ProseMirrorNode;
|
1544
|
-
isActive: (attrs?: Attrs) => boolean;
|
1545
|
-
}
|
1771
|
+
declare type NodeBuilder = NodeAction;
|
1546
1772
|
export { NodeBuilder }
|
1547
1773
|
export { NodeBuilder as NodeBuilder_alias_1 }
|
1548
1774
|
|
1549
1775
|
/**
|
1776
|
+
* Available children parameters for {@link NodeAction} and {@link MarkAction}.
|
1777
|
+
*
|
1550
1778
|
* @public
|
1551
1779
|
*/
|
1552
|
-
|
1780
|
+
declare type NodeChild = ProseMirrorNode | string | NodeChild[];
|
1781
|
+
export { NodeChild }
|
1782
|
+
export { NodeChild as NodeChild_alias_1 }
|
1553
1783
|
|
1554
1784
|
/**
|
1555
1785
|
* @public
|
@@ -1603,13 +1833,35 @@ export { NodeJSON as NodeJSON_alias_1 }
|
|
1603
1833
|
/**
|
1604
1834
|
* @public
|
1605
1835
|
*/
|
1606
|
-
declare interface NodeSpecOptions<NodeName extends string = string> extends NodeSpec {
|
1836
|
+
declare interface NodeSpecOptions<NodeName extends string = string, Attrs extends AnyAttrs = AnyAttrs> extends NodeSpec {
|
1837
|
+
/**
|
1838
|
+
* The name of the node type.
|
1839
|
+
*/
|
1607
1840
|
name: NodeName;
|
1841
|
+
/**
|
1842
|
+
* Whether this is the top-level node type. Only one node type can be the
|
1843
|
+
* top-level node type in a schema.
|
1844
|
+
*/
|
1608
1845
|
topNode?: boolean;
|
1846
|
+
/**
|
1847
|
+
* The attributes that nodes of this type get.
|
1848
|
+
*/
|
1849
|
+
attrs?: {
|
1850
|
+
[key in keyof Attrs]: AttrSpec<Attrs[key]>;
|
1851
|
+
};
|
1609
1852
|
}
|
1610
1853
|
export { NodeSpecOptions }
|
1611
1854
|
export { NodeSpecOptions as NodeSpecOptions_alias_1 }
|
1612
1855
|
|
1856
|
+
/**
|
1857
|
+
* @internal
|
1858
|
+
*/
|
1859
|
+
declare interface NodeTyping {
|
1860
|
+
[name: string]: Record<string, any>;
|
1861
|
+
}
|
1862
|
+
export { NodeTyping }
|
1863
|
+
export { NodeTyping as NodeTyping_alias_1 }
|
1864
|
+
|
1613
1865
|
/**
|
1614
1866
|
* @internal
|
1615
1867
|
*/
|
@@ -1674,14 +1926,14 @@ export declare type Payloads<T> = Tuple5<T[]>;
|
|
1674
1926
|
/**
|
1675
1927
|
* @internal
|
1676
1928
|
*/
|
1677
|
-
export declare type
|
1678
|
-
CommandTyping
|
1679
|
-
] extends [T] ? never : T;
|
1929
|
+
export declare type PickStringLiteral<T> = PickSubType<T, string>;
|
1680
1930
|
|
1681
1931
|
/**
|
1682
1932
|
* @internal
|
1683
1933
|
*/
|
1684
|
-
|
1934
|
+
declare type PickSubType<Type, ParentType> = Type extends ParentType ? [ParentType] extends [Type] ? never : Type : never;
|
1935
|
+
export { PickSubType }
|
1936
|
+
export { PickSubType as PickSubType_alias_1 }
|
1685
1937
|
|
1686
1938
|
/**
|
1687
1939
|
* @internal
|
@@ -1898,31 +2150,106 @@ export declare function setupEditorExtension<E extends Extension>(options: Edito
|
|
1898
2150
|
* @internal
|
1899
2151
|
*/
|
1900
2152
|
export declare function setupTest(): {
|
1901
|
-
editor: TestEditor<Extension<{
|
1902
|
-
|
1903
|
-
|
1904
|
-
|
1905
|
-
|
1906
|
-
|
1907
|
-
|
1908
|
-
|
1909
|
-
|
1910
|
-
|
1911
|
-
|
1912
|
-
|
1913
|
-
|
1914
|
-
|
1915
|
-
|
1916
|
-
|
1917
|
-
|
1918
|
-
|
1919
|
-
|
1920
|
-
|
1921
|
-
|
1922
|
-
|
2153
|
+
editor: TestEditor<UnionExtension<readonly [Extension<{
|
2154
|
+
Commands: {
|
2155
|
+
insertText: [{
|
2156
|
+
text: string;
|
2157
|
+
from?: number;
|
2158
|
+
to?: number;
|
2159
|
+
}];
|
2160
|
+
insertNode: [options: InsertNodeOptions];
|
2161
|
+
removeNode: [options: RemoveNodeOptions];
|
2162
|
+
wrap: [WrapOptions];
|
2163
|
+
setBlockType: [options: SetBlockTypeOptions];
|
2164
|
+
setNodeAttrs: [options: SetNodeAttrsOptions];
|
2165
|
+
selectAll: [];
|
2166
|
+
addMark: [options: AddMarkOptions];
|
2167
|
+
removeMark: [options: RemoveMarkOptions];
|
2168
|
+
unsetBlockType: [options?: UnsetBlockTypeOptions | undefined];
|
2169
|
+
unsetMark: [options?: UnsetMarkOptions | undefined];
|
2170
|
+
};
|
2171
|
+
Nodes: never;
|
2172
|
+
Marks: never;
|
2173
|
+
}>, Extension<ExtensionTyping<any, any, any>>, Extension<{
|
2174
|
+
Nodes: {
|
2175
|
+
doc: Attrs_2;
|
2176
|
+
};
|
2177
|
+
Marks: never;
|
2178
|
+
Commands: never;
|
2179
|
+
}>, UnionExtension<readonly [Extension<ExtensionTyping<any, any, any>>, Extension<ExtensionTyping<any, any, any>>, Extension<{
|
2180
|
+
Commands: {
|
2181
|
+
readonly undo: [];
|
2182
|
+
readonly redo: [];
|
2183
|
+
};
|
2184
|
+
Nodes: never;
|
2185
|
+
Marks: never;
|
2186
|
+
}>]>, Extension<{
|
2187
|
+
Nodes: {
|
2188
|
+
paragraph: Attrs_2;
|
2189
|
+
};
|
2190
|
+
Marks: never;
|
2191
|
+
Commands: never;
|
2192
|
+
}>, Extension<{
|
2193
|
+
Nodes: {
|
2194
|
+
text: Attrs_2;
|
2195
|
+
};
|
2196
|
+
Marks: never;
|
2197
|
+
Commands: never;
|
2198
|
+
}>, Extension<{
|
2199
|
+
Marks: {
|
2200
|
+
bold: Attrs_2;
|
2201
|
+
};
|
2202
|
+
Nodes: never;
|
2203
|
+
Commands: never;
|
2204
|
+
}>, Extension<{
|
2205
|
+
Marks: {
|
2206
|
+
italic: Attrs_2;
|
2207
|
+
};
|
2208
|
+
Nodes: never;
|
2209
|
+
Commands: never;
|
2210
|
+
}>, Extension<{
|
2211
|
+
Nodes: {
|
2212
|
+
heading: Attrs_2;
|
2213
|
+
};
|
2214
|
+
Marks: never;
|
2215
|
+
Commands: never;
|
2216
|
+
}>, Extension<{
|
2217
|
+
Nodes: {
|
2218
|
+
codeBlock: {
|
2219
|
+
language: string;
|
2220
|
+
};
|
2221
|
+
};
|
2222
|
+
Marks: never;
|
2223
|
+
Commands: never;
|
2224
|
+
}>]>>;
|
2225
|
+
m: ToMarkAction<SimplifyDeeper< {
|
2226
|
+
italic: {
|
2227
|
+
readonly [x: string]: any;
|
2228
|
+
};
|
2229
|
+
bold: {
|
2230
|
+
readonly [x: string]: any;
|
2231
|
+
};
|
1923
2232
|
}>>;
|
1924
|
-
n:
|
1925
|
-
|
2233
|
+
n: {
|
2234
|
+
p: NodeAction< {
|
2235
|
+
readonly [x: string]: any;
|
2236
|
+
}>;
|
2237
|
+
paragraph: NodeAction< {
|
2238
|
+
readonly [x: string]: any;
|
2239
|
+
}>;
|
2240
|
+
codeBlock: NodeAction< {
|
2241
|
+
language: string;
|
2242
|
+
}>;
|
2243
|
+
heading: NodeAction< {
|
2244
|
+
readonly [x: string]: any;
|
2245
|
+
}>;
|
2246
|
+
text: NodeAction< {
|
2247
|
+
readonly [x: string]: any;
|
2248
|
+
}>;
|
2249
|
+
doc: NodeAction< {
|
2250
|
+
readonly [x: string]: any;
|
2251
|
+
}>;
|
2252
|
+
};
|
1926
2253
|
};
|
1927
2254
|
|
1928
2255
|
/**
|
@@ -1930,9 +2257,18 @@ export declare function setupTest(): {
|
|
1930
2257
|
*/
|
1931
2258
|
export declare function setupTestFromExtension<E extends Extension>(extension: E): {
|
1932
2259
|
editor: TestEditor<E>;
|
1933
|
-
n:
|
1934
|
-
m:
|
2260
|
+
n: ExtractNodeActions<E>;
|
2261
|
+
m: ExtractMarkActions<E>;
|
2262
|
+
};
|
2263
|
+
|
2264
|
+
/**
|
2265
|
+
* @internal
|
2266
|
+
*/
|
2267
|
+
declare type SimplifyDeeper<T> = {
|
2268
|
+
[KeyType in keyof T]: Simplify<T[KeyType]>;
|
1935
2269
|
};
|
2270
|
+
export { SimplifyDeeper }
|
2271
|
+
export { SimplifyDeeper as SimplifyDeeper_alias_1 }
|
1936
2272
|
|
1937
2273
|
/**
|
1938
2274
|
* @internal
|
@@ -2034,8 +2370,8 @@ declare type TextInputHandler = (view: EditorView, from: number, to: number, tex
|
|
2034
2370
|
export { TextInputHandler }
|
2035
2371
|
export { TextInputHandler as TextInputHandler_alias_1 }
|
2036
2372
|
|
2037
|
-
export declare type
|
2038
|
-
[K in keyof T]:
|
2373
|
+
export declare type ToCommandAction<T extends CommandTyping> = {
|
2374
|
+
[K in keyof T]: CommandAction<T[K]>;
|
2039
2375
|
};
|
2040
2376
|
|
2041
2377
|
export declare type ToCommandCreators<T extends CommandTyping> = {
|
@@ -2087,6 +2423,24 @@ declare interface ToggleNodeOptions {
|
|
2087
2423
|
export { ToggleNodeOptions }
|
2088
2424
|
export { ToggleNodeOptions as ToggleNodeOptions_alias_1 }
|
2089
2425
|
|
2426
|
+
/**
|
2427
|
+
* @internal
|
2428
|
+
*/
|
2429
|
+
declare type ToMarkAction<T extends MarkTyping> = {
|
2430
|
+
[K in keyof T]: MarkAction<T[K]>;
|
2431
|
+
};
|
2432
|
+
export { ToMarkAction }
|
2433
|
+
export { ToMarkAction as ToMarkAction_alias_1 }
|
2434
|
+
|
2435
|
+
/**
|
2436
|
+
* @internal
|
2437
|
+
*/
|
2438
|
+
declare type ToNodeAction<T extends NodeTyping> = {
|
2439
|
+
[K in keyof T]: NodeAction<T[K]>;
|
2440
|
+
};
|
2441
|
+
export { ToNodeAction }
|
2442
|
+
export { ToNodeAction as ToNodeAction_alias_1 }
|
2443
|
+
|
2090
2444
|
export declare function toReversed<T>(arr: T[]): T[];
|
2091
2445
|
|
2092
2446
|
declare type TripleClickHandler = (view: EditorView, pos: number, event: MouseEvent) => boolean | void;
|
@@ -2120,18 +2474,20 @@ export declare type Tuple5<T> = [T, T, T, T, T];
|
|
2120
2474
|
*
|
2121
2475
|
* @public
|
2122
2476
|
*/
|
2123
|
-
declare function union<const
|
2477
|
+
declare function union<const Extensions extends readonly Extension[]>(...exts: Extensions): UnionExtension<Extensions>;
|
2478
|
+
|
2479
|
+
declare function union<const Extensions extends readonly Extension[]>(exts: Extensions): UnionExtension<Extensions>;
|
2124
2480
|
export { union }
|
2125
2481
|
export { union as union_alias_1 }
|
2126
2482
|
|
2127
2483
|
/**
|
2128
2484
|
* @internal
|
2129
2485
|
*/
|
2130
|
-
declare type UnionExtension<E extends
|
2486
|
+
declare type UnionExtension<E extends readonly Extension[]> = Extension<{
|
2131
2487
|
Nodes: ExtractNodes<E[number]>;
|
2132
2488
|
Marks: ExtractMarks<E[number]>;
|
2133
2489
|
Commands: ExtractCommands<E[number]>;
|
2134
|
-
}
|
2490
|
+
}>;
|
2135
2491
|
export { UnionExtension }
|
2136
2492
|
export { UnionExtension as UnionExtension_alias_1 }
|
2137
2493
|
|