@prosekit/core 0.0.0-next-20240724172520 → 0.0.0-next-20240901092634

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.
@@ -1,29 +1,30 @@
1
1
  import { AllSelection } from '@prosekit/pm/state';
2
- import { Attrs } from '@prosekit/pm/model';
3
- import { Attrs as Attrs_2 } from 'prosemirror-model';
2
+ import type { Attrs } from '@prosekit/pm/model';
4
3
  import { Command } from '@prosekit/pm/state';
5
4
  import type { ContentMatch } from '@prosekit/pm/model';
6
5
  import { config as default_alias_1 } from '@prosekit/dev/config-vitest';
7
6
  import type { DirectEditorProps } from '@prosekit/pm/view';
8
7
  import type { DOMEventMap } from '@prosekit/pm/view';
8
+ import type { DOMOutputSpec } from '@prosekit/pm/model';
9
9
  import { DOMParser as DOMParser_2 } from '@prosekit/pm/model';
10
10
  import { DOMSerializer } from '@prosekit/pm/model';
11
11
  import { EditorState } from '@prosekit/pm/state';
12
12
  import type { EditorStateConfig } from '@prosekit/pm/state';
13
13
  import { EditorView } from '@prosekit/pm/view';
14
+ import { Fragment } from '@prosekit/pm/model';
14
15
  import type { IsEqual } from 'type-fest';
15
16
  import { Mark } from '@prosekit/pm/model';
16
17
  import type { MarkSpec } from '@prosekit/pm/model';
17
- import { MarkType } from '@prosekit/pm/model';
18
+ import type { MarkType } from '@prosekit/pm/model';
18
19
  import type { Node as Node_2 } from '@prosekit/pm/model';
19
20
  import { NodeSelection } from '@prosekit/pm/state';
20
21
  import type { NodeSpec } from '@prosekit/pm/model';
21
- import { NodeType } from '@prosekit/pm/model';
22
+ import type { NodeType } from '@prosekit/pm/model';
22
23
  import { NodeType as NodeType_2 } from 'prosemirror-model';
23
24
  import type { NodeView } from '@prosekit/pm/view';
24
25
  import type { NodeViewConstructor } from '@prosekit/pm/view';
25
26
  import { Options } from 'tsup';
26
- import type { ParseOptions } from '@prosekit/pm/model';
27
+ import { ParseOptions } from '@prosekit/pm/model';
27
28
  import { Plugin as Plugin_2 } from '@prosekit/pm/state';
28
29
  import { ProseMirrorFragment } from '@prosekit/pm/model';
29
30
  import { ProseMirrorNode } from '@prosekit/pm/model';
@@ -33,7 +34,8 @@ import { SchemaSpec } from '@prosekit/pm/model';
33
34
  import { Selection as Selection_2 } from '@prosekit/pm/state';
34
35
  import { Selection as Selection_3 } from 'prosemirror-state';
35
36
  import type { Simplify } from 'type-fest';
36
- import type { Slice } from '@prosekit/pm/model';
37
+ import { Slice } from '@prosekit/pm/model';
38
+ import type { TagParseRule } from '@prosekit/pm/model';
37
39
  import { TextSelection } from '@prosekit/pm/state';
38
40
  import { Transaction } from '@prosekit/pm/state';
39
41
  import type { UnionToIntersection } from 'type-fest';
@@ -121,6 +123,12 @@ export declare function assertTypeEqual<T, U>(_val: IsEqual<T, U>): void;
121
123
  */
122
124
  export declare function assertTypeEqual_alias_1<T, U>(_val: IsEqual<T, U>): void;
123
125
 
126
+ declare interface AttrOptions {
127
+ attr: string;
128
+ toDOM?: (value: unknown) => [key: string, value: string] | null | undefined;
129
+ parseDOM?: (node: HTMLElement) => unknown;
130
+ }
131
+
124
132
  export declare function attrsMatch(nodeOrMark: ProseMirrorNode | Mark, attrs: Attrs): boolean;
125
133
 
126
134
  /**
@@ -159,6 +167,7 @@ declare type BaseCommandsExtension = Extension<{
159
167
  wrap: [options: WrapOptions];
160
168
  setBlockType: [options: SetBlockTypeOptions];
161
169
  setNodeAttrs: [options: SetNodeAttrsOptions];
170
+ insertDefaultBlock: [options?: InsertDefaultBlockOptions];
162
171
  selectAll: [];
163
172
  addMark: [options: AddMarkOptions];
164
173
  removeMark: [options: RemoveMarkOptions];
@@ -195,11 +204,7 @@ export declare abstract class BaseExtension<T extends ExtensionTyping = Extensio
195
204
  /**
196
205
  * @internal
197
206
  */
198
- declare type BaseKeymapExtension = Extension<{
199
- Nodes: never;
200
- Commands: never;
201
- Keymap: never;
202
- }>;
207
+ declare type BaseKeymapExtension = PlainExtension;
203
208
  export { BaseKeymapExtension }
204
209
  export { BaseKeymapExtension as BaseKeymapExtension_alias_1 }
205
210
 
@@ -229,9 +234,11 @@ declare interface BaseNodeViewOptions {
229
234
  export { BaseNodeViewOptions }
230
235
  export { BaseNodeViewOptions as BaseNodeViewOptions_alias_1 }
231
236
 
232
- export declare function baseToggleMark(markType: MarkType, attrs?: Attrs | null, options?: {
233
- removeWhenPresent: boolean;
234
- }): Command;
237
+ declare type BoldExtension = Extension<{
238
+ Marks: {
239
+ bold: Attrs;
240
+ };
241
+ }>;
235
242
 
236
243
  export declare function buildNode(type: NodeType, args: [Attrs | NodeChild | null | undefined, ...NodeChild[]], createNode: CreateNodeFunction): ProseMirrorNode;
237
244
 
@@ -260,26 +267,59 @@ declare const clsx: (...args: Array<string | boolean | null | undefined>) => str
260
267
  export { clsx }
261
268
  export { clsx as clsx_alias_1 }
262
269
 
270
+ declare type CodeBlockExtension = Extension<{
271
+ Nodes: {
272
+ codeBlock: {
273
+ language: string;
274
+ };
275
+ };
276
+ }>;
277
+
278
+ /**
279
+ * Collects all children of a node or a fragment, and returns them as an array.
280
+ *
281
+ * @public
282
+ */
283
+ declare function collectChildren(parent: ProseMirrorNode | Fragment): ProseMirrorNode[];
284
+ export { collectChildren }
285
+ export { collectChildren as collectChildren_alias_1 }
286
+
263
287
  /**
264
288
  * Collects all nodes from a given content.
265
289
  *
290
+ * @deprecated Use `collectChildren` instead.
291
+ *
266
292
  * @public
267
293
  */
268
294
  declare function collectNodes(content: NodeContent): ProseMirrorNode[];
269
295
  export { collectNodes }
270
296
  export { collectNodes as collectNodes_alias_1 }
271
297
 
272
- export declare function combineEventHandlers<Handler extends (...args: any[]) => boolean | void, Args extends Parameters<Handler> = Parameters<Handler>>(): readonly [(handlers: Handler[]) => void, (...args: Args) => boolean];
298
+ export declare function combineEventHandlers<Handler extends (...args: any[]) => boolean | void, Args extends Parameters<Handler> = Parameters<Handler>>(): readonly [(eventHandlers: Handler[]) => void, (...args: Args) => boolean];
273
299
 
274
300
  /**
275
301
  * A function to apply a command to the editor. It will return `true` if the command was applied, and `false` otherwise.
276
302
  *
277
- * It also has a `canApply` method to check if the command can be applied.
303
+ * It also has a `canExec` method to check if the command can be applied.
278
304
  *
279
305
  * @public
280
306
  */
281
307
  declare interface CommandAction<Args extends any[] = any[]> {
308
+ /**
309
+ * Execute the current command. Return `true` if the command was successfully
310
+ * executed, otherwise `false`.
311
+ */
282
312
  (...args: Args): boolean;
313
+ /**
314
+ * Check if the current command can be executed. Return `true` if the command
315
+ * can be executed, otherwise `false`.
316
+ */
317
+ canExec(...args: Args): boolean;
318
+ /**
319
+ * An alias for `canExec`.
320
+ *
321
+ * @deprecated Use `canExec` instead.
322
+ */
283
323
  canApply(...args: Args): boolean;
284
324
  }
285
325
  export { CommandAction }
@@ -321,12 +361,12 @@ export { createEditor as createEditor_alias_1 }
321
361
  /**
322
362
  * @internal
323
363
  */
324
- export declare function createMarkActions(schema: Schema, getState: () => EditorState | null | undefined, applyMark?: ApplyMarkFunction): Record<string, MarkAction>;
364
+ export declare function createMarkActions(schema: Schema, getState: GetStateFunction, applyMark?: ApplyMarkFunction): Record<string, MarkAction>;
325
365
 
326
366
  /**
327
367
  * @internal
328
368
  */
329
- export declare function createNodeActions(schema: Schema, getState: () => EditorState | null | undefined, createNode?: CreateNodeFunction): Record<string, NodeAction>;
369
+ export declare function createNodeActions(schema: Schema, getState: GetStateFunction, createNode?: CreateNodeFunction): Record<string, NodeAction>;
330
370
 
331
371
  export declare const createNodeForTest: CreateNodeFunction;
332
372
 
@@ -355,20 +395,32 @@ declare function defaultBlockAt(match: ContentMatch): NodeType_2 | null;
355
395
  export { defaultBlockAt }
356
396
  export { defaultBlockAt as defaultBlockAt_alias_1 }
357
397
 
398
+ /**
399
+ * @public
400
+ */
358
401
  declare interface DefaultStateOptions {
402
+ /**
403
+ * The starting document to use when creating the editor. It can be a
404
+ * ProseMirror node JSON object, a HTML string, or a HTML element instance.
405
+ */
406
+ defaultContent?: NodeJSON | string | HTMLElement;
359
407
  /**
360
408
  * A JSON object representing the starting document to use when creating the
361
409
  * editor.
410
+ *
411
+ * @deprecated Use `defaultContent` instead.
362
412
  */
363
413
  defaultDoc?: NodeJSON;
364
414
  /**
365
415
  * A HTML element or a HTML string representing the starting document to use
366
416
  * when creating the editor.
417
+ *
418
+ * @deprecated Use `defaultContent` instead.
367
419
  */
368
420
  defaultHTML?: string | HTMLElement;
369
421
  /**
370
422
  * A JSON object representing the starting selection to use when creating the
371
- * editor. It's only used when `defaultDoc` or `defaultHTML` is also provided.
423
+ * editor. It's only used when `defaultContent` is also provided.
372
424
  */
373
425
  defaultSelection?: SelectionJSON;
374
426
  }
@@ -426,7 +478,14 @@ declare function defineCommands<T extends Record<string, CommandCreator> = Recor
426
478
  export { defineCommands }
427
479
  export { defineCommands as defineCommands_alias_1 }
428
480
 
429
- declare function defineDefaultState({ defaultDoc, defaultHTML, defaultSelection, }: DefaultStateOptions): Extension;
481
+ /**
482
+ * Define a default state for the editor.
483
+ *
484
+ * @param options
485
+ *
486
+ * @public
487
+ */
488
+ declare function defineDefaultState({ defaultSelection, defaultContent, defaultDoc, defaultHTML, }: DefaultStateOptions): PlainExtension;
430
489
  export { defineDefaultState }
431
490
  export { defineDefaultState as defineDefaultState_alias_1 }
432
491
 
@@ -442,7 +501,7 @@ export { defineDoc as defineDoc_alias_1 }
442
501
  *
443
502
  * @public
444
503
  */
445
- declare function defineDocChangeHandler(handler: DocChangeHandler): Extension<ExtensionTyping<any, any, any>>;
504
+ declare function defineDocChangeHandler(handler: DocChangeHandler): PlainExtension;
446
505
  export { defineDocChangeHandler }
447
506
  export { defineDocChangeHandler as defineDocChangeHandler_alias_1 }
448
507
 
@@ -528,6 +587,8 @@ export { defineFocusChangeHandler as defineFocusChangeHandler_alias_1 }
528
587
  /**
529
588
  * Add undo/redo history to the editor.
530
589
  *
590
+ * @param options
591
+ *
531
592
  * @public
532
593
  */
533
594
  declare function defineHistory({ depth, newGroupDelay, }?: HistoryOptions): HistoryExtension;
@@ -546,7 +607,7 @@ export { defineKeyDownHandler as defineKeyDownHandler_alias_1 }
546
607
  /**
547
608
  * @public
548
609
  */
549
- declare function defineKeymap(keymap: Keymap): Extension;
610
+ declare function defineKeymap(keymap: Keymap): PlainExtension;
550
611
  export { defineKeymap }
551
612
  export { defineKeymap as defineKeymap_alias_1 }
552
613
 
@@ -586,7 +647,7 @@ export { defineMarkSpec as defineMarkSpec_alias_1 }
586
647
  *
587
648
  * @public
588
649
  */
589
- declare function defineMountHandler(handler: MountHandler): Extension<ExtensionTyping<any, any, any>>;
650
+ declare function defineMountHandler(handler: MountHandler): PlainExtension;
590
651
  export { defineMountHandler }
591
652
  export { defineMountHandler as defineMountHandler_alias_1 }
592
653
 
@@ -671,7 +732,7 @@ export { definePasteHandler as definePasteHandler_alias_1 }
671
732
  */
672
733
  declare function definePlugin(plugin: Plugin_2 | Plugin_2[] | ((context: {
673
734
  schema: Schema;
674
- }) => Plugin_2 | Plugin_2[])): PluginExtension;
735
+ }) => Plugin_2 | Plugin_2[])): PlainExtension;
675
736
  export { definePlugin }
676
737
  export { definePlugin as definePlugin_alias_1 }
677
738
 
@@ -687,29 +748,11 @@ export { defineScrollToSelectionHandler as defineScrollToSelectionHandler_alias_
687
748
  /**
688
749
  * @internal
689
750
  */
690
- export declare function defineTestExtension(): Union<readonly [BaseCommandsExtension, BaseKeymapExtension, DocExtension, HistoryExtension, Extension<{
691
- Nodes: {
692
- paragraph: Attrs_2;
693
- };
694
- }>, TextExtension, Extension<{
695
- Marks: {
696
- bold: Attrs_2;
697
- };
698
- }>, Extension<{
699
- Marks: {
700
- italic: Attrs_2;
701
- };
702
- }>, Extension<{
703
- Nodes: {
704
- heading: Attrs_2;
705
- };
706
- }>, Extension<{
751
+ export declare function defineTestExtension(): Union<readonly [BaseCommandsExtension, PlainExtension, DocExtension, HistoryExtension, Extension<{
707
752
  Nodes: {
708
- codeBlock: {
709
- language: string;
753
+ paragraph: Attrs;
710
754
  };
711
- };
712
- }>]>;
755
+ }>, TextExtension, BoldExtension, ItalicExtension, LinkExtension, HeadingExtension, CodeBlockExtension]>;
713
756
 
714
757
  /**
715
758
  * @public
@@ -750,7 +793,7 @@ export { defineTripleClickOnHandler as defineTripleClickOnHandler_alias_1 }
750
793
  *
751
794
  * @public
752
795
  */
753
- declare function defineUnmountHandler(handler: UnmountHandler): Extension<ExtensionTyping<any, any, any>>;
796
+ declare function defineUnmountHandler(handler: UnmountHandler): PlainExtension;
754
797
  export { defineUnmountHandler }
755
798
  export { defineUnmountHandler as defineUnmountHandler_alias_1 }
756
799
 
@@ -759,7 +802,7 @@ export { defineUnmountHandler as defineUnmountHandler_alias_1 }
759
802
  *
760
803
  * @public
761
804
  */
762
- declare function defineUpdateHandler(handler: UpdateHandler): Extension<ExtensionTyping<any, any, any>>;
805
+ declare function defineUpdateHandler(handler: UpdateHandler): PlainExtension;
763
806
  export { defineUpdateHandler }
764
807
  export { defineUpdateHandler as defineUpdateHandler_alias_1 }
765
808
 
@@ -855,15 +898,10 @@ export { DropHandler as DropHandler_alias_1 }
855
898
  */
856
899
  declare class Editor<E extends Extension = any> {
857
900
  private instance;
858
- private afterMounted;
859
901
  /**
860
902
  * @internal
861
903
  */
862
904
  constructor(instance: EditorInstance);
863
- /**
864
- * @internal
865
- */
866
- static create(instance: any): Editor<any>;
867
905
  /**
868
906
  * Whether the editor is mounted.
869
907
  */
@@ -876,6 +914,10 @@ declare class Editor<E extends Extension = any> {
876
914
  * The editor schema.
877
915
  */
878
916
  get schema(): Schema<ExtractNodeNames<E>, ExtractMarkNames<E>>;
917
+ /**
918
+ * The editor's current state.
919
+ */
920
+ get state(): EditorState;
879
921
  /**
880
922
  * Whether the editor is focused.
881
923
  */
@@ -884,28 +926,24 @@ declare class Editor<E extends Extension = any> {
884
926
  * Mount the editor to the given HTML element.
885
927
  * Pass `null` or `undefined` to unmount the editor.
886
928
  */
887
- mount(place: HTMLElement | null | undefined): void;
929
+ mount: (place: HTMLElement | null | undefined) => void;
888
930
  /**
889
931
  * Unmount the editor. This is equivalent to `mount(null)`.
890
932
  */
891
- unmount(): void;
933
+ unmount: () => void;
892
934
  /**
893
935
  * Focus the editor.
894
936
  */
895
- focus(): void;
937
+ focus: () => void;
896
938
  /**
897
939
  * Blur the editor.
898
940
  */
899
- blur(): void;
941
+ blur: () => void;
900
942
  /**
901
943
  * Register an extension to the editor. Return a function to unregister the
902
944
  * extension.
903
945
  */
904
- use(extension: Extension): VoidFunction;
905
- /**
906
- * The editor's current state.
907
- */
908
- get state(): EditorState;
946
+ use: (extension: Extension) => VoidFunction;
909
947
  /**
910
948
  * Update the editor's state.
911
949
  *
@@ -914,7 +952,32 @@ declare class Editor<E extends Extension = any> {
914
952
  * This is an advanced method. Use it only if you have a specific reason to
915
953
  * directly manipulate the editor's state.
916
954
  */
917
- updateState(state: EditorState): void;
955
+ updateState: (state: EditorState) => void;
956
+ /**
957
+ * Update the editor's document and selection.
958
+ *
959
+ * @param content - The new document to set. It can be one of the following:
960
+ * - A ProseMirror node instance
961
+ * - A ProseMirror node JSON object
962
+ * - An HTML string
963
+ * - An HTML element instance
964
+ * @param selection - Optional. Specifies the new selection. It can be one of the following:
965
+ * - A ProseMirror selection instance
966
+ * - A ProseMirror selection JSON object
967
+ * - The string "start" (to set selection at the beginning, default value)
968
+ * - The string "end" (to set selection at the end)
969
+ */
970
+ setContent: (content: ProseMirrorNode | NodeJSON | string | HTMLElement, selection?: SelectionJSON | Selection_2 | "start" | "end") => void;
971
+ /**
972
+ * Execute the given command. Return `true` if the command was successfully
973
+ * executed, otherwise `false`.
974
+ */
975
+ exec: (command: Command) => boolean;
976
+ /**
977
+ * Check if the given command can be executed. Return `true` if the command
978
+ * can be executed, otherwise `false`.
979
+ */
980
+ canExec: (command: Command) => boolean;
918
981
  /**
919
982
  * All {@link CommandAction}s defined by the editor.
920
983
  */
@@ -932,6 +995,8 @@ export { Editor }
932
995
  export { Editor as Editor_alias_1 }
933
996
 
934
997
  /**
998
+ * An internal class to make TypeScript generic type easier to use.
999
+ *
935
1000
  * @internal
936
1001
  */
937
1002
  export declare class EditorInstance {
@@ -942,16 +1007,22 @@ export declare class EditorInstance {
942
1007
  commands: Record<string, CommandAction>;
943
1008
  private tree;
944
1009
  private directEditorProps;
1010
+ private afterMounted;
945
1011
  constructor(extension: Extension);
946
1012
  getState: () => EditorState;
947
1013
  updateState(state: EditorState): void;
948
- updateExtension(extension: Extension, add: boolean): void;
1014
+ private dispatch;
1015
+ setContent(content: NodeJSON | string | HTMLElement | ProseMirrorNode, selection?: SelectionJSON | Selection_2 | 'start' | 'end'): void;
1016
+ private updateExtension;
1017
+ use(extension: Extension): VoidFunction;
949
1018
  mount(place: HTMLElement): void;
950
1019
  unmount(): void;
951
1020
  get mounted(): boolean;
952
1021
  get assertView(): EditorView;
953
1022
  definePlugins(plugins: readonly Plugin_2[]): void;
954
1023
  removePlugins(plugins: readonly Plugin_2[]): void;
1024
+ exec(command: Command): boolean;
1025
+ canExec(command: Command): boolean;
955
1026
  defineCommand<Args extends any[] = any[]>(name: string, commandCreator: CommandCreator<Args>): void;
956
1027
  removeCommand(name: string): void;
957
1028
  }
@@ -973,19 +1044,28 @@ declare interface EditorOptions<E extends Extension> {
973
1044
  * The extension to use when creating the editor.
974
1045
  */
975
1046
  extension: E;
1047
+ /**
1048
+ * The starting document to use when creating the editor. It can be a
1049
+ * ProseMirror node JSON object, a HTML string, or a HTML element instance.
1050
+ */
1051
+ defaultContent?: NodeJSON | string | HTMLElement;
976
1052
  /**
977
1053
  * A JSON object representing the starting document to use when creating the
978
1054
  * editor.
1055
+ *
1056
+ * @deprecated Use `defaultContent` instead.
979
1057
  */
980
1058
  defaultDoc?: NodeJSON;
981
1059
  /**
982
1060
  * A HTML element or a HTML string representing the starting document to use
983
1061
  * when creating the editor.
1062
+ *
1063
+ * @deprecated Use `defaultContent` instead.
984
1064
  */
985
1065
  defaultHTML?: string | HTMLElement;
986
1066
  /**
987
1067
  * A JSON object representing the starting selection to use when creating the
988
- * editor. It's only used when `defaultDoc` or `defaultHTML` is also provided.
1068
+ * editor. It's only used when `defaultContent` is also provided.
989
1069
  */
990
1070
  defaultSelection?: SelectionJSON;
991
1071
  }
@@ -1190,7 +1270,7 @@ export declare class FacetExtensionImpl<Input, Output> extends BaseExtension {
1190
1270
  /**
1191
1271
  * @internal
1192
1272
  */
1193
- createTree(priority: Priority): FacetNode<any, any>;
1273
+ createTree(priority: Priority): FacetNode;
1194
1274
  }
1195
1275
 
1196
1276
  export declare class FacetNode<I = any, O = any> {
@@ -1220,10 +1300,63 @@ export declare function findBrowserWindow(options?: {
1220
1300
  document?: Document;
1221
1301
  }): (Window & typeof globalThis) | null | undefined;
1222
1302
 
1223
- export declare function findParentNode(nodeType: NodeType, $pos: ResolvedPos): {
1224
- from: number | null;
1225
- to: number | null;
1226
- };
1303
+ /**
1304
+ * Find the closest parent node that satisfies the predicate.
1305
+ *
1306
+ * @public
1307
+ */
1308
+ declare function findParentNode(
1309
+ /**
1310
+ * The predicate to test the parent node.
1311
+ */
1312
+ predicate: (node: ProseMirrorNode) => boolean,
1313
+ /**
1314
+ * The position to start searching from.
1315
+ */
1316
+ $pos: ResolvedPos): FindParentNodeResult | undefined;
1317
+ export { findParentNode }
1318
+ export { findParentNode as findParentNode_alias_1 }
1319
+
1320
+ /**
1321
+ * Finds the closest parent node that matches the given node type.
1322
+ *
1323
+ * @public
1324
+ */
1325
+ declare function findParentNodeOfType(
1326
+ /**
1327
+ * The type of the node to find.
1328
+ */
1329
+ type: NodeType | string,
1330
+ /**
1331
+ * The position to start searching from.
1332
+ */
1333
+ $pos: ResolvedPos): FindParentNodeResult | undefined;
1334
+ export { findParentNodeOfType }
1335
+ export { findParentNodeOfType as findParentNodeOfType_alias_1 }
1336
+
1337
+ /**
1338
+ * @public
1339
+ */
1340
+ declare interface FindParentNodeResult {
1341
+ /**
1342
+ * The closest parent node that satisfies the predicate.
1343
+ */
1344
+ node: ProseMirrorNode;
1345
+ /**
1346
+ * The position directly before the node.
1347
+ */
1348
+ pos: number;
1349
+ /**
1350
+ * The position at the start of the node.
1351
+ */
1352
+ start: number;
1353
+ /**
1354
+ * The depth of the node.
1355
+ */
1356
+ depth: number;
1357
+ }
1358
+ export { FindParentNodeResult }
1359
+ export { FindParentNodeResult as FindParentNodeResult_alias_1 }
1227
1360
 
1228
1361
  /**
1229
1362
  * A function that is called when the editor gains or loses focus.
@@ -1246,6 +1379,14 @@ export declare function getBrowserWindow(options?: {
1246
1379
 
1247
1380
  export declare function getCustomSelection(state: EditorState, from?: number | null, to?: number | null): Selection_3;
1248
1381
 
1382
+ export declare function getEditorContentDoc(schema: Schema, content: NodeJSON | string | HTMLElement | ProseMirrorNode): ProseMirrorNode;
1383
+
1384
+ export declare function getEditorContentJSON(schema: Schema, content: NodeJSON | string | HTMLElement): NodeJSON;
1385
+
1386
+ export declare function getEditorContentNode(schema: Schema, content: NodeJSON | string | HTMLElement | ProseMirrorNode): ProseMirrorNode;
1387
+
1388
+ export declare function getEditorSelection(doc: ProseMirrorNode, selection: SelectionJSON | Selection_2 | 'start' | 'end'): Selection_2;
1389
+
1249
1390
  /**
1250
1391
  * Returns a unique id in the current process that can be used in various places.
1251
1392
  *
@@ -1274,11 +1415,19 @@ export { getNodeType as getNodeType_alias_1 }
1274
1415
  */
1275
1416
  export declare function getNodeTypes(schema: Schema, types: string | NodeType | string[] | NodeType[]): NodeType[];
1276
1417
 
1277
- export declare type GroupedEntries<T extends Record<string, any>> = {
1418
+ declare type GetStateFunction = () => EditorState | null | undefined;
1419
+
1420
+ export declare function groupBy<K extends PropertyKey, T>(items: Iterable<T>, keySelector: (item: T) => K): Partial<Record<K, T[]>>;
1421
+
1422
+ export declare function groupEntries<T extends Record<string, any>>(entries: ObjectEntries<T>[]): {
1278
1423
  [K in keyof T]?: T[K][];
1279
1424
  };
1280
1425
 
1281
- export declare function groupEntries<T extends Record<string, any>>(entries: ObjectEntries<T>[]): GroupedEntries<T>;
1426
+ declare type HeadingExtension = Extension<{
1427
+ Nodes: {
1428
+ heading: Attrs;
1429
+ };
1430
+ }>;
1282
1431
 
1283
1432
  /**
1284
1433
  * @internal
@@ -1341,6 +1490,31 @@ export { htmlFromNode as htmlFromNode_alias_1 }
1341
1490
 
1342
1491
  export declare function includesMark(marks: readonly Mark[], markType: MarkType, attrs?: Attrs | null): boolean;
1343
1492
 
1493
+ export declare function inputText(input: string): Promise<void>;
1494
+
1495
+ /**
1496
+ * Returns a command that inserts a default block after current selection or at
1497
+ * the given position.
1498
+ *
1499
+ * @public
1500
+ */
1501
+ declare function insertDefaultBlock(options?: InsertDefaultBlockOptions): Command;
1502
+ export { insertDefaultBlock }
1503
+ export { insertDefaultBlock as insertDefaultBlock_alias_1 }
1504
+
1505
+ /**
1506
+ * @public
1507
+ */
1508
+ declare interface InsertDefaultBlockOptions {
1509
+ /**
1510
+ * The position to insert the node at. By default it will insert after the
1511
+ * current selection.
1512
+ */
1513
+ pos?: number;
1514
+ }
1515
+ export { InsertDefaultBlockOptions }
1516
+ export { InsertDefaultBlockOptions as InsertDefaultBlockOptions_alias_1 }
1517
+
1344
1518
  /**
1345
1519
  * Returns a command that inserts the given node at the current selection or at
1346
1520
  * the given position.
@@ -1381,6 +1555,8 @@ declare interface InsertNodeOptions {
1381
1555
  export { InsertNodeOptions }
1382
1556
  export { InsertNodeOptions as InsertNodeOptions_alias_1 }
1383
1557
 
1558
+ export declare function insertOutputSpecAttrs(dom: DOMOutputSpec, attrs: Array<[key: string, value: string]>): DOMOutputSpec;
1559
+
1384
1560
  /**
1385
1561
  * Returns a command that inserts the given text.
1386
1562
  *
@@ -1398,7 +1574,9 @@ export declare type InsertTextOptions = {
1398
1574
  };
1399
1575
 
1400
1576
  /**
1401
- * @internal
1577
+ * Checks if the given object is a `AllSelection` instance.
1578
+ *
1579
+ * @public
1402
1580
  */
1403
1581
  declare function isAllSelection(sel: Selection_2): sel is AllSelection;
1404
1582
  export { isAllSelection }
@@ -1420,7 +1598,16 @@ declare function isAtBlockStart(state: EditorState, view?: EditorView): Resolved
1420
1598
  export { isAtBlockStart }
1421
1599
  export { isAtBlockStart as isAtBlockStart_alias_1 }
1422
1600
 
1423
- export declare function isElement(value: unknown): value is Element;
1601
+ export declare function isElement(el: unknown): el is Element;
1602
+
1603
+ /**
1604
+ * Checks if the given object is a `Fragment` instance.
1605
+ *
1606
+ * @public
1607
+ */
1608
+ declare function isFragment(fragment: unknown): fragment is Fragment;
1609
+ export { isFragment }
1610
+ export { isFragment as isFragment_alias_1 }
1424
1611
 
1425
1612
  /**
1426
1613
  * Check if the selection is in a code block.
@@ -1432,7 +1619,9 @@ export { isInCodeBlock }
1432
1619
  export { isInCodeBlock as isInCodeBlock_alias_1 }
1433
1620
 
1434
1621
  /**
1435
- * @internal
1622
+ * Checks if the given object is a `Mark` instance.
1623
+ *
1624
+ * @public
1436
1625
  */
1437
1626
  declare function isMark(mark: unknown): mark is Mark;
1438
1627
  export { isMark }
@@ -1459,21 +1648,46 @@ export { isMarkActive as isMarkActive_alias_1 }
1459
1648
  export declare function isNodeActive(state: EditorState, type: string | NodeType, attrs?: Attrs | null): boolean;
1460
1649
 
1461
1650
  /**
1462
- * @internal
1651
+ * Checks if the given object is a `NodeSelection` instance.
1652
+ *
1653
+ * @public
1463
1654
  */
1464
1655
  declare function isNodeSelection(sel: Selection_2): sel is NodeSelection;
1465
1656
  export { isNodeSelection }
1466
1657
  export { isNodeSelection as isNodeSelection_alias_1 }
1467
1658
 
1468
- export declare function isNotNull<T>(value: T | null | undefined): value is T;
1469
-
1470
1659
  /**
1471
1660
  * @internal
1472
1661
  */
1662
+ export declare function isNotNullish<T>(value: T | null | undefined | void): value is T;
1663
+
1664
+ export declare function isObject(v: unknown): v is Record<string, unknown>;
1665
+
1666
+ /**
1667
+ * Checks if the given object is a `ProseMirrorNode` instance.
1668
+ */
1473
1669
  declare function isProseMirrorNode(node: unknown): node is ProseMirrorNode;
1474
1670
  export { isProseMirrorNode }
1475
1671
  export { isProseMirrorNode as isProseMirrorNode_alias_1 }
1476
1672
 
1673
+ /**
1674
+ * Checks if the given object is a `Selection` instance.
1675
+ *
1676
+ * @public
1677
+ */
1678
+ declare function isSelection(sel: unknown): sel is Selection_2;
1679
+ export { isSelection }
1680
+ export { isSelection as isSelection_alias_1 }
1681
+
1682
+ /**
1683
+ * Checks if the given object is a `Slice` instance.
1684
+ *
1685
+ * @public
1686
+ */
1687
+ declare function isSlice(slice: unknown): slice is Slice;
1688
+ export { isSlice }
1689
+ export { isSlice as isSlice_alias_1 }
1690
+
1477
1691
  /**
1478
1692
  * Check if `subset` is a subset of `superset`.
1479
1693
  *
@@ -1482,12 +1696,20 @@ export { isProseMirrorNode as isProseMirrorNode_alias_1 }
1482
1696
  export declare function isSubset(subset: Record<string, unknown>, superset: Record<string, unknown>): boolean;
1483
1697
 
1484
1698
  /**
1485
- * @internal
1699
+ * Checks if the given object is a `TextSelection` instance.
1700
+ *
1701
+ * @public
1486
1702
  */
1487
1703
  declare function isTextSelection(sel: Selection_2): sel is TextSelection;
1488
1704
  export { isTextSelection }
1489
1705
  export { isTextSelection as isTextSelection_alias_1 }
1490
1706
 
1707
+ declare type ItalicExtension = Extension<{
1708
+ Marks: {
1709
+ italic: Attrs;
1710
+ };
1711
+ }>;
1712
+
1491
1713
  /**
1492
1714
  * Serialize a HTML element to a ProseMirror document JSON object.
1493
1715
  *
@@ -1560,6 +1782,16 @@ declare type KeyPressHandler = (view: EditorView, event: KeyboardEvent) => boole
1560
1782
  export { KeyPressHandler }
1561
1783
  export { KeyPressHandler as KeyPressHandler_alias_1 }
1562
1784
 
1785
+ declare interface LinkAttrs {
1786
+ href: string;
1787
+ }
1788
+
1789
+ declare type LinkExtension = Extension<{
1790
+ Marks: {
1791
+ link: LinkAttrs;
1792
+ };
1793
+ }>;
1794
+
1563
1795
  /**
1564
1796
  * A function for creating a mark with optional attributes and any number of
1565
1797
  * children.
@@ -1595,13 +1827,18 @@ declare interface MarkAttrOptions<MarkName extends string = string, AttrName ext
1595
1827
  */
1596
1828
  attr: AttrName;
1597
1829
  /**
1598
- * Returns the attribute key and value to be set on the DOM node.
1830
+ * Returns the attribute key and value to be set on the HTML element.
1831
+ *
1832
+ * If the returned `key` is `"style"`, the value is a string of CSS properties and will
1833
+ * be prepended to the existing `style` attribute on the DOM node.
1834
+ *
1835
+ * @param value - The value of the attribute of current ProseMirror node.
1599
1836
  */
1600
- toDOM?: (value: any) => [key: string, value: string] | null | void;
1837
+ toDOM?: (value: AttrType) => [key: string, value: string] | null | undefined;
1601
1838
  /**
1602
1839
  * Parses the attribute value from the DOM.
1603
1840
  */
1604
- parseDOM?: (node: HTMLElement) => any;
1841
+ parseDOM?: (node: HTMLElement) => AttrType;
1605
1842
  }
1606
1843
  export { MarkAttrOptions }
1607
1844
  export { MarkAttrOptions as MarkAttrOptions_alias_1 }
@@ -1647,6 +1884,12 @@ declare function maybeRun<T, R = T extends (...args: any[]) => void ? ReturnType
1647
1884
  export { maybeRun }
1648
1885
  export { maybeRun as maybeRun_alias_1 }
1649
1886
 
1887
+ export declare function mergeObjects<T extends object>(...objects: Array<Partial<T> | null | undefined>): Partial<T>;
1888
+
1889
+ export declare function mergeSpecs(a: NodeSpec, b: NodeSpec): NodeSpec;
1890
+
1891
+ export declare function mergeSpecs(a: MarkSpec, b: MarkSpec): MarkSpec;
1892
+
1650
1893
  /**
1651
1894
  * A function that is called when the editor view is mounted.
1652
1895
  *
@@ -1701,16 +1944,18 @@ declare interface NodeAttrOptions<NodeName extends string = string, AttrName ext
1701
1944
  */
1702
1945
  splittable?: boolean;
1703
1946
  /**
1704
- * Returns the attribute key and value to be set on the DOM node.
1947
+ * Returns the attribute key and value to be set on the HTML element.
1705
1948
  *
1706
- * If the `key` is `"style"`, the value is a string of CSS properties and will
1949
+ * If the returned `key` is `"style"`, the value is a string of CSS properties and will
1707
1950
  * be prepended to the existing `style` attribute on the DOM node.
1951
+ *
1952
+ * @param value - The value of the attribute of current ProseMirror node.
1708
1953
  */
1709
- toDOM?: (value: any) => [key: string, value: string] | null | void;
1954
+ toDOM?: (value: AttrType) => [key: string, value: string] | null | undefined;
1710
1955
  /**
1711
1956
  * Parses the attribute value from the DOM.
1712
1957
  */
1713
- parseDOM?: (node: HTMLElement) => any;
1958
+ parseDOM?: (node: HTMLElement) => AttrType;
1714
1959
  }
1715
1960
  export { NodeAttrOptions }
1716
1961
  export { NodeAttrOptions as NodeAttrOptions_alias_1 }
@@ -1733,6 +1978,8 @@ export { NodeChild as NodeChild_alias_1 }
1733
1978
 
1734
1979
  /**
1735
1980
  * @public
1981
+ *
1982
+ * @deprecated
1736
1983
  */
1737
1984
  declare type NodeContent = ProseMirrorNode | ProseMirrorFragment | NodeContent[];
1738
1985
  export { NodeContent }
@@ -1772,7 +2019,10 @@ export { nodeFromJSON as nodeFromJSON_alias_1 }
1772
2019
  */
1773
2020
  declare interface NodeJSON {
1774
2021
  type: string;
1775
- marks?: Array<any>;
2022
+ marks?: Array<{
2023
+ type: string;
2024
+ attrs?: Record<string, any>;
2025
+ }>;
1776
2026
  text?: string;
1777
2027
  content?: NodeJSON[];
1778
2028
  attrs?: Record<string, any>;
@@ -1902,15 +2152,17 @@ export { PickSubType }
1902
2152
  export { PickSubType as PickSubType_alias_1 }
1903
2153
 
1904
2154
  /**
2155
+ * An extension that does not define any nodes, marks, or commands.
2156
+ *
1905
2157
  * @internal
1906
2158
  */
1907
- declare type PluginExtension = Extension<{
2159
+ declare type PlainExtension = Extension<{
1908
2160
  Nodes: never;
1909
2161
  Marks: never;
1910
2162
  Commands: never;
1911
2163
  }>;
1912
- export { PluginExtension }
1913
- export { PluginExtension as PluginExtension_alias_1 }
2164
+ export { PlainExtension }
2165
+ export { PlainExtension as PlainExtension_alias_1 }
1914
2166
 
1915
2167
  /**
1916
2168
  * @internal
@@ -2004,13 +2256,16 @@ declare interface RemoveNodeOptions {
2004
2256
  */
2005
2257
  type: string | NodeType;
2006
2258
  /**
2007
- * The document position to start searching node. By default it will be the anchor position of current selection.
2259
+ * The document position to start searching node. By default it will be the
2260
+ * anchor position of current selection.
2008
2261
  */
2009
2262
  pos?: number;
2010
2263
  }
2011
2264
  export { RemoveNodeOptions }
2012
2265
  export { RemoveNodeOptions as RemoveNodeOptions_alias_1 }
2013
2266
 
2267
+ export declare function removeUndefinedValues<T extends object>(obj: T): T;
2268
+
2014
2269
  export declare const rootFacet: Facet<RootPayload, RootOutput>;
2015
2270
 
2016
2271
  export declare type RootOutput = {
@@ -2127,29 +2382,11 @@ export declare function setupEditorExtension<E extends Extension>(options: Edito
2127
2382
  * @internal
2128
2383
  */
2129
2384
  export declare function setupTest(): {
2130
- editor: TestEditor<Union<readonly [BaseCommandsExtension, BaseKeymapExtension, DocExtension, HistoryExtension, Extension<{
2385
+ editor: TestEditor<Union<readonly [BaseCommandsExtension, PlainExtension, DocExtension, HistoryExtension, Extension<{
2131
2386
  Nodes: {
2132
- paragraph: Attrs_2;
2133
- };
2134
- }>, TextExtension, Extension<{
2135
- Marks: {
2136
- bold: Attrs_2;
2387
+ paragraph: Attrs;
2137
2388
  };
2138
- }>, Extension<{
2139
- Marks: {
2140
- italic: Attrs_2;
2141
- };
2142
- }>, Extension<{
2143
- Nodes: {
2144
- heading: Attrs_2;
2145
- };
2146
- }>, Extension<{
2147
- Nodes: {
2148
- codeBlock: {
2149
- language: string;
2150
- };
2151
- };
2152
- }>]>>;
2389
+ }>, TextExtension, BoldExtension, ItalicExtension, LinkExtension, HeadingExtension, CodeBlockExtension]>>;
2153
2390
  m: ToMarkAction<SimplifyDeeper< {
2154
2391
  bold: {
2155
2392
  readonly [x: string]: any;
@@ -2157,6 +2394,9 @@ export declare function setupTest(): {
2157
2394
  italic: {
2158
2395
  readonly [x: string]: any;
2159
2396
  };
2397
+ link: {
2398
+ href: string;
2399
+ };
2160
2400
  }>>;
2161
2401
  n: {
2162
2402
  p: NodeAction< {
@@ -2171,12 +2411,12 @@ export declare function setupTest(): {
2171
2411
  text: NodeAction< {
2172
2412
  readonly [x: string]: any;
2173
2413
  }>;
2174
- codeBlock: NodeAction< {
2175
- language: string;
2176
- }>;
2177
2414
  heading: NodeAction< {
2178
2415
  readonly [x: string]: any;
2179
2416
  }>;
2417
+ codeBlock: NodeAction< {
2418
+ language: string;
2419
+ }>;
2180
2420
  };
2181
2421
  };
2182
2422
 
@@ -2320,9 +2560,11 @@ export declare type ToCommandCreators<T extends CommandTyping> = {
2320
2560
  /**
2321
2561
  * Returns a command that toggles the given mark with the given attributes.
2322
2562
  *
2563
+ * @param options
2564
+ *
2323
2565
  * @public
2324
2566
  */
2325
- declare function toggleMark({ type, attrs }: ToggleMarkOptions): Command;
2567
+ declare function toggleMark({ type, attrs, removeWhenPresent, enterInlineAtoms, }: ToggleMarkOptions): Command;
2326
2568
  export { toggleMark }
2327
2569
  export { toggleMark as toggleMark_alias_1 }
2328
2570
 
@@ -2330,8 +2572,30 @@ export { toggleMark as toggleMark_alias_1 }
2330
2572
  * @public
2331
2573
  */
2332
2574
  declare interface ToggleMarkOptions {
2575
+ /**
2576
+ * The mark type to toggle.
2577
+ */
2333
2578
  type: string | MarkType;
2579
+ /**
2580
+ * The optional attributes to set on the mark.
2581
+ */
2334
2582
  attrs?: Attrs | null;
2583
+ /**
2584
+ * Controls whether, when part of the selected range has the mark
2585
+ * already and part doesn't, the mark is removed (`true`) or added
2586
+ * (`false`).
2587
+ *
2588
+ * @default false
2589
+ */
2590
+ removeWhenPresent?: boolean;
2591
+ /**
2592
+ * Whether the command should act on the content of inline nodes marked as
2593
+ * [atoms](https://prosemirror.net/docs/ref/#model.NodeSpec.atom) that are
2594
+ * completely covered by a selection range.
2595
+ *
2596
+ * @default true
2597
+ */
2598
+ enterInlineAtoms?: boolean;
2335
2599
  }
2336
2600
  export { ToggleMarkOptions }
2337
2601
  export { ToggleMarkOptions as ToggleMarkOptions_alias_1 }
@@ -2340,6 +2604,8 @@ export { ToggleMarkOptions as ToggleMarkOptions_alias_1 }
2340
2604
  * Returns a command that set the selected textblocks to the given node type
2341
2605
  * with the given attributes.
2342
2606
  *
2607
+ * @param options
2608
+ *
2343
2609
  * @public
2344
2610
  */
2345
2611
  declare function toggleNode({ type, attrs }: ToggleNodeOptions): Command;
@@ -2407,7 +2673,8 @@ export { Union }
2407
2673
  export { Union as Union_alias_1 }
2408
2674
 
2409
2675
  /**
2410
- * Merge multiple extensions into one.
2676
+ * Merges multiple extensions into one. You can pass multiple extensions as
2677
+ * arguments or a single array containing multiple extensions.
2411
2678
  *
2412
2679
  * @throws If no extensions are provided.
2413
2680
  *
@@ -2415,6 +2682,17 @@ export { Union as Union_alias_1 }
2415
2682
  *
2416
2683
  * ```ts
2417
2684
  * function defineFancyNodes() {
2685
+ * return union(
2686
+ * defineFancyParagraph(),
2687
+ * defineFancyHeading(),
2688
+ * )
2689
+ * }
2690
+ * ```
2691
+ *
2692
+ * @example
2693
+ *
2694
+ * ```ts
2695
+ * function defineFancyNodes() {
2418
2696
  * return union([
2419
2697
  * defineFancyParagraph(),
2420
2698
  * defineFancyHeading(),
@@ -2570,12 +2848,13 @@ export { withSkipCodeBlock }
2570
2848
  export { withSkipCodeBlock as withSkipCodeBlock_alias_1 }
2571
2849
 
2572
2850
  /**
2573
- * Returns a command that wraps the selected textblock with the given node type
2574
- * with the given attributes.
2851
+ * Returns a command that wraps the selected textblock with the given node type.
2852
+ *
2853
+ * @param options
2575
2854
  *
2576
2855
  * @public
2577
2856
  */
2578
- declare function wrap({ nodeType, attrs }: WrapOptions): Command;
2857
+ declare function wrap(options: WrapOptions): Command;
2579
2858
  export { wrap }
2580
2859
  export { wrap as wrap_alias_1 }
2581
2860
 
@@ -2583,12 +2862,26 @@ export { wrap as wrap_alias_1 }
2583
2862
  * @public
2584
2863
  */
2585
2864
  declare interface WrapOptions {
2586
- nodeType: NodeType;
2865
+ /**
2866
+ * The node type to wrap the selected textblock with.
2867
+ */
2868
+ type: NodeType | string;
2869
+ /**
2870
+ * @deprecated Use `nodeSpec` instead.
2871
+ */
2872
+ nodeType?: NodeType;
2873
+ /**
2874
+ * Optional attributes to apply to the node.
2875
+ */
2587
2876
  attrs?: Attrs | null;
2588
2877
  }
2589
2878
  export { WrapOptions }
2590
2879
  export { WrapOptions as WrapOptions_alias_1 }
2591
2880
 
2881
+ export declare function wrapOutputSpecAttrs<T extends ProseMirrorNode | Mark, Args extends readonly unknown[]>(toDOM: (node: T, ...args: Args) => DOMOutputSpec, options: AttrOptions[]): (node: T, ...args: Args) => DOMOutputSpec;
2882
+
2883
+ export declare function wrapTagParseRuleAttrs(rule: TagParseRule, options: AttrOptions[]): TagParseRule;
2884
+
2592
2885
  export declare function zip<T, P>(a: T[], b: P[]): [T, P][];
2593
2886
 
2594
2887
  export { }