@tiptap/core 3.0.0-next.3 → 3.0.0-next.4

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.
Files changed (128) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +5 -1
  3. package/dist/index.cjs +2402 -2540
  4. package/dist/index.cjs.map +1 -1
  5. package/dist/index.d.cts +1355 -1273
  6. package/dist/index.d.ts +1355 -1273
  7. package/dist/index.js +2408 -2562
  8. package/dist/index.js.map +1 -1
  9. package/package.json +9 -5
  10. package/src/CommandManager.ts +2 -9
  11. package/src/Editor.ts +87 -72
  12. package/src/EventEmitter.ts +7 -10
  13. package/src/Extension.ts +8 -14
  14. package/src/ExtensionManager.ts +26 -125
  15. package/src/InputRule.ts +35 -48
  16. package/src/Mark.ts +9 -9
  17. package/src/Node.ts +9 -9
  18. package/src/NodePos.ts +1 -3
  19. package/src/NodeView.ts +10 -20
  20. package/src/PasteRule.ts +43 -55
  21. package/src/Tracker.ts +7 -9
  22. package/src/commands/blur.ts +14 -12
  23. package/src/commands/clearContent.ts +6 -4
  24. package/src/commands/clearNodes.ts +32 -30
  25. package/src/commands/command.ts +1 -1
  26. package/src/commands/createParagraphNear.ts +5 -3
  27. package/src/commands/cut.ts +12 -10
  28. package/src/commands/deleteCurrentNode.ts +23 -21
  29. package/src/commands/deleteNode.ts +18 -16
  30. package/src/commands/deleteRange.ts +10 -8
  31. package/src/commands/deleteSelection.ts +5 -3
  32. package/src/commands/enter.ts +6 -4
  33. package/src/commands/exitCode.ts +5 -3
  34. package/src/commands/extendMarkRange.ts +14 -12
  35. package/src/commands/first.ts +2 -4
  36. package/src/commands/focus.ts +45 -48
  37. package/src/commands/forEach.ts +2 -2
  38. package/src/commands/insertContent.ts +12 -14
  39. package/src/commands/insertContentAt.ts +101 -98
  40. package/src/commands/join.ts +20 -12
  41. package/src/commands/joinItemBackward.ts +16 -18
  42. package/src/commands/joinItemForward.ts +16 -18
  43. package/src/commands/joinTextblockBackward.ts +5 -3
  44. package/src/commands/joinTextblockForward.ts +5 -3
  45. package/src/commands/keyboardShortcut.ts +29 -34
  46. package/src/commands/lift.ts +10 -8
  47. package/src/commands/liftEmptyBlock.ts +6 -4
  48. package/src/commands/liftListItem.ts +6 -4
  49. package/src/commands/newlineInCode.ts +5 -3
  50. package/src/commands/resetAttributes.ts +36 -41
  51. package/src/commands/scrollIntoView.ts +9 -7
  52. package/src/commands/selectAll.ts +10 -8
  53. package/src/commands/selectNodeBackward.ts +5 -3
  54. package/src/commands/selectNodeForward.ts +5 -3
  55. package/src/commands/selectParentNode.ts +5 -3
  56. package/src/commands/selectTextblockEnd.ts +5 -3
  57. package/src/commands/selectTextblockStart.ts +5 -3
  58. package/src/commands/setContent.ts +25 -25
  59. package/src/commands/setMark.ts +55 -57
  60. package/src/commands/setMeta.ts +7 -5
  61. package/src/commands/setNode.ts +32 -30
  62. package/src/commands/setNodeSelection.ts +11 -9
  63. package/src/commands/setTextSelection.ts +15 -13
  64. package/src/commands/sinkListItem.ts +6 -4
  65. package/src/commands/splitBlock.ts +67 -76
  66. package/src/commands/splitListItem.ts +93 -106
  67. package/src/commands/toggleList.ts +73 -71
  68. package/src/commands/toggleMark.ts +11 -9
  69. package/src/commands/toggleNode.ts +18 -16
  70. package/src/commands/toggleWrap.ts +10 -8
  71. package/src/commands/undoInputRule.ts +31 -29
  72. package/src/commands/unsetAllMarks.ts +16 -14
  73. package/src/commands/unsetMark.ts +27 -25
  74. package/src/commands/updateAttributes.ts +92 -100
  75. package/src/commands/wrapIn.ts +6 -4
  76. package/src/commands/wrapInList.ts +6 -4
  77. package/src/extensions/clipboardTextSerializer.ts +2 -4
  78. package/src/extensions/focusEvents.ts +2 -6
  79. package/src/extensions/keymap.ts +54 -50
  80. package/src/extensions/paste.ts +0 -1
  81. package/src/extensions/tabindex.ts +1 -1
  82. package/src/helpers/combineTransactionSteps.ts +1 -4
  83. package/src/helpers/createChainableState.ts +1 -4
  84. package/src/helpers/createDocument.ts +1 -3
  85. package/src/helpers/createNodeFromContent.ts +4 -10
  86. package/src/helpers/findChildrenInRange.ts +1 -5
  87. package/src/helpers/findParentNode.ts +3 -1
  88. package/src/helpers/flattenExtensions.ts +30 -0
  89. package/src/helpers/getAttributes.ts +1 -4
  90. package/src/helpers/getAttributesFromExtensions.ts +28 -37
  91. package/src/helpers/getChangedRanges.ts +13 -11
  92. package/src/helpers/getExtensionField.ts +1 -4
  93. package/src/helpers/getMarkAttributes.ts +1 -4
  94. package/src/helpers/getMarkRange.ts +5 -15
  95. package/src/helpers/getMarkType.ts +1 -3
  96. package/src/helpers/getNodeAttributes.ts +1 -4
  97. package/src/helpers/getNodeType.ts +1 -3
  98. package/src/helpers/getRenderedAttributes.ts +1 -3
  99. package/src/helpers/getSchema.ts +2 -2
  100. package/src/helpers/getSchemaByResolvedExtensions.ts +45 -77
  101. package/src/helpers/getSplittedAttributes.ts +4 -4
  102. package/src/helpers/getTextContentFromNodes.ts +8 -11
  103. package/src/helpers/index.ts +4 -0
  104. package/src/helpers/injectExtensionAttributesToParseRule.ts +1 -1
  105. package/src/helpers/isActive.ts +1 -5
  106. package/src/helpers/isExtensionRulesEnabled.ts +1 -3
  107. package/src/helpers/isNodeEmpty.ts +2 -2
  108. package/src/helpers/resolveExtensions.ts +25 -0
  109. package/src/helpers/resolveFocusPosition.ts +3 -14
  110. package/src/helpers/rewriteUnknownContent.ts +149 -0
  111. package/src/helpers/sortExtensions.ts +26 -0
  112. package/src/inputRules/markInputRule.ts +1 -5
  113. package/src/inputRules/nodeInputRule.ts +2 -9
  114. package/src/inputRules/textInputRule.ts +1 -4
  115. package/src/inputRules/textblockTypeInputRule.ts +2 -8
  116. package/src/inputRules/wrappingInputRule.ts +13 -19
  117. package/src/pasteRules/markPasteRule.ts +1 -3
  118. package/src/pasteRules/nodePasteRule.ts +2 -8
  119. package/src/pasteRules/textPasteRule.ts +1 -4
  120. package/src/types.ts +212 -172
  121. package/src/utilities/createStyleTag.ts +3 -1
  122. package/src/utilities/deleteProps.ts +7 -11
  123. package/src/utilities/findDuplicates.ts +4 -1
  124. package/src/utilities/isFunction.ts +1 -0
  125. package/src/utilities/isMacOS.ts +1 -3
  126. package/src/utilities/isiOS.ts +5 -10
  127. package/src/utilities/mergeAttributes.ts +16 -6
  128. package/src/utilities/removeDuplicates.ts +1 -3
package/dist/index.d.ts CHANGED
@@ -1,8 +1,7 @@
1
- import { EditorState, Plugin, Transaction, PluginKey, Selection, NodeSelection, TextSelection } from '@tiptap/pm/state';
2
- import { NodeType, NodeSpec, Node as Node$1, DOMOutputSpec, MarkType, MarkSpec, Mark as Mark$1, Slice, ParseOptions, Schema, ResolvedPos, Fragment, ContentMatch, ParseRule } from '@tiptap/pm/model';
1
+ import { Transaction, EditorState, Plugin, Selection, NodeSelection, TextSelection, PluginKey } from '@tiptap/pm/state';
2
+ import { Node as Node$1, NodeType as NodeType$1, NodeSpec, DOMOutputSpec, MarkType as MarkType$1, MarkSpec, Mark as Mark$1, Slice, ParseOptions, Fragment, Schema, ContentMatch, ResolvedPos, ParseRule } from '@tiptap/pm/model';
3
3
  import { NodeView as NodeView$1, EditorProps, EditorView, Decoration, DecorationAttrs, ViewMutationRecord, NodeViewConstructor } from '@tiptap/pm/view';
4
- import { Mappable, Transform } from '@tiptap/pm/transform';
5
- import * as prosemirror_model from 'prosemirror-model';
4
+ import { Transform, Mappable } from '@tiptap/pm/transform';
6
5
 
7
6
  type StringKeyOf<T> = Extract<keyof T, string>;
8
7
  type CallbackType<T extends Record<string, any>, EventName extends StringKeyOf<T>> = T[EventName] extends any[] ? T[EventName] : [T[EventName]];
@@ -16,6 +15,24 @@ declare class EventEmitter<T extends Record<string, any>> {
16
15
  removeAllListeners(): void;
17
16
  }
18
17
 
18
+ /**
19
+ * Returns a new `Transform` based on all steps of the passed transactions.
20
+ * @param oldDoc The Prosemirror node to start from
21
+ * @param transactions The transactions to combine
22
+ * @returns A new `Transform` with all steps of the passed transactions
23
+ */
24
+ declare function combineTransactionSteps(oldDoc: Node$1, transactions: Transaction[]): Transform;
25
+
26
+ /**
27
+ * Takes a Transaction & Editor State and turns it into a chainable state object
28
+ * @param config The transaction and state to create the chainable state from
29
+ * @returns A chainable Editor state object
30
+ */
31
+ declare function createChainableState(config: {
32
+ transaction: Transaction;
33
+ state: EditorState;
34
+ }): EditorState;
35
+
19
36
  type InputRuleMatch = {
20
37
  index: number;
21
38
  text: string;
@@ -206,7 +223,7 @@ declare module '@tiptap/core' {
206
223
  options: Options;
207
224
  storage: Storage;
208
225
  editor: Editor;
209
- type: NodeType;
226
+ type: NodeType$1;
210
227
  parent: ParentConfig<NodeConfig<Options, Storage>>['addCommands'];
211
228
  }) => Partial<RawCommands>;
212
229
  /**
@@ -224,7 +241,7 @@ declare module '@tiptap/core' {
224
241
  options: Options;
225
242
  storage: Storage;
226
243
  editor: Editor;
227
- type: NodeType;
244
+ type: NodeType$1;
228
245
  parent: ParentConfig<NodeConfig<Options, Storage>>['addKeyboardShortcuts'];
229
246
  }) => {
230
247
  [key: string]: KeyboardShortcutCommand;
@@ -247,7 +264,7 @@ declare module '@tiptap/core' {
247
264
  options: Options;
248
265
  storage: Storage;
249
266
  editor: Editor;
250
- type: NodeType;
267
+ type: NodeType$1;
251
268
  parent: ParentConfig<NodeConfig<Options, Storage>>['addInputRules'];
252
269
  }) => InputRule[];
253
270
  /**
@@ -268,7 +285,7 @@ declare module '@tiptap/core' {
268
285
  options: Options;
269
286
  storage: Storage;
270
287
  editor: Editor;
271
- type: NodeType;
288
+ type: NodeType$1;
272
289
  parent: ParentConfig<NodeConfig<Options, Storage>>['addPasteRules'];
273
290
  }) => PasteRule[];
274
291
  /**
@@ -286,7 +303,7 @@ declare module '@tiptap/core' {
286
303
  options: Options;
287
304
  storage: Storage;
288
305
  editor: Editor;
289
- type: NodeType;
306
+ type: NodeType$1;
290
307
  parent: ParentConfig<NodeConfig<Options, Storage>>['addProseMirrorPlugins'];
291
308
  }) => Plugin[];
292
309
  /**
@@ -348,7 +365,7 @@ declare module '@tiptap/core' {
348
365
  options: Options;
349
366
  storage: Storage;
350
367
  editor: Editor;
351
- type: NodeType;
368
+ type: NodeType$1;
352
369
  parent: ParentConfig<NodeConfig<Options, Storage>>['onBeforeCreate'];
353
370
  }) => void) | null;
354
371
  /**
@@ -359,7 +376,7 @@ declare module '@tiptap/core' {
359
376
  options: Options;
360
377
  storage: Storage;
361
378
  editor: Editor;
362
- type: NodeType;
379
+ type: NodeType$1;
363
380
  parent: ParentConfig<NodeConfig<Options, Storage>>['onCreate'];
364
381
  }) => void) | null;
365
382
  /**
@@ -370,7 +387,7 @@ declare module '@tiptap/core' {
370
387
  options: Options;
371
388
  storage: Storage;
372
389
  editor: Editor;
373
- type: NodeType;
390
+ type: NodeType$1;
374
391
  parent: ParentConfig<NodeConfig<Options, Storage>>['onUpdate'];
375
392
  }) => void) | null;
376
393
  /**
@@ -381,7 +398,7 @@ declare module '@tiptap/core' {
381
398
  options: Options;
382
399
  storage: Storage;
383
400
  editor: Editor;
384
- type: NodeType;
401
+ type: NodeType$1;
385
402
  parent: ParentConfig<NodeConfig<Options, Storage>>['onSelectionUpdate'];
386
403
  }) => void) | null;
387
404
  /**
@@ -392,7 +409,7 @@ declare module '@tiptap/core' {
392
409
  options: Options;
393
410
  storage: Storage;
394
411
  editor: Editor;
395
- type: NodeType;
412
+ type: NodeType$1;
396
413
  parent: ParentConfig<NodeConfig<Options, Storage>>['onTransaction'];
397
414
  }, props: {
398
415
  editor: Editor;
@@ -406,7 +423,7 @@ declare module '@tiptap/core' {
406
423
  options: Options;
407
424
  storage: Storage;
408
425
  editor: Editor;
409
- type: NodeType;
426
+ type: NodeType$1;
410
427
  parent: ParentConfig<NodeConfig<Options, Storage>>['onFocus'];
411
428
  }, props: {
412
429
  event: FocusEvent;
@@ -419,7 +436,7 @@ declare module '@tiptap/core' {
419
436
  options: Options;
420
437
  storage: Storage;
421
438
  editor: Editor;
422
- type: NodeType;
439
+ type: NodeType$1;
423
440
  parent: ParentConfig<NodeConfig<Options, Storage>>['onBlur'];
424
441
  }, props: {
425
442
  event: FocusEvent;
@@ -432,7 +449,7 @@ declare module '@tiptap/core' {
432
449
  options: Options;
433
450
  storage: Storage;
434
451
  editor: Editor;
435
- type: NodeType;
452
+ type: NodeType$1;
436
453
  parent: ParentConfig<NodeConfig<Options, Storage>>['onDestroy'];
437
454
  }) => void) | null;
438
455
  /**
@@ -443,7 +460,7 @@ declare module '@tiptap/core' {
443
460
  options: Options;
444
461
  storage: Storage;
445
462
  editor: Editor;
446
- type: NodeType;
463
+ type: NodeType$1;
447
464
  parent: ParentConfig<NodeConfig<Options, Storage>>['addNodeView'];
448
465
  }) => NodeViewRenderer) | null;
449
466
  /**
@@ -827,7 +844,7 @@ declare module '@tiptap/core' {
827
844
  options: Options;
828
845
  storage: Storage;
829
846
  editor: Editor;
830
- type: MarkType;
847
+ type: MarkType$1;
831
848
  parent: ParentConfig<MarkConfig<Options, Storage>>['addCommands'];
832
849
  }) => Partial<RawCommands>;
833
850
  /**
@@ -845,7 +862,7 @@ declare module '@tiptap/core' {
845
862
  options: Options;
846
863
  storage: Storage;
847
864
  editor: Editor;
848
- type: MarkType;
865
+ type: MarkType$1;
849
866
  parent: ParentConfig<MarkConfig<Options, Storage>>['addKeyboardShortcuts'];
850
867
  }) => {
851
868
  [key: string]: KeyboardShortcutCommand;
@@ -868,7 +885,7 @@ declare module '@tiptap/core' {
868
885
  options: Options;
869
886
  storage: Storage;
870
887
  editor: Editor;
871
- type: MarkType;
888
+ type: MarkType$1;
872
889
  parent: ParentConfig<MarkConfig<Options, Storage>>['addInputRules'];
873
890
  }) => InputRule[];
874
891
  /**
@@ -889,7 +906,7 @@ declare module '@tiptap/core' {
889
906
  options: Options;
890
907
  storage: Storage;
891
908
  editor: Editor;
892
- type: MarkType;
909
+ type: MarkType$1;
893
910
  parent: ParentConfig<MarkConfig<Options, Storage>>['addPasteRules'];
894
911
  }) => PasteRule[];
895
912
  /**
@@ -907,7 +924,7 @@ declare module '@tiptap/core' {
907
924
  options: Options;
908
925
  storage: Storage;
909
926
  editor: Editor;
910
- type: MarkType;
927
+ type: MarkType$1;
911
928
  parent: ParentConfig<MarkConfig<Options, Storage>>['addProseMirrorPlugins'];
912
929
  }) => Plugin[];
913
930
  /**
@@ -968,7 +985,7 @@ declare module '@tiptap/core' {
968
985
  options: Options;
969
986
  storage: Storage;
970
987
  editor: Editor;
971
- type: MarkType;
988
+ type: MarkType$1;
972
989
  parent: ParentConfig<MarkConfig<Options, Storage>>['onBeforeCreate'];
973
990
  }) => void) | null;
974
991
  /**
@@ -979,7 +996,7 @@ declare module '@tiptap/core' {
979
996
  options: Options;
980
997
  storage: Storage;
981
998
  editor: Editor;
982
- type: MarkType;
999
+ type: MarkType$1;
983
1000
  parent: ParentConfig<MarkConfig<Options, Storage>>['onCreate'];
984
1001
  }) => void) | null;
985
1002
  /**
@@ -990,7 +1007,7 @@ declare module '@tiptap/core' {
990
1007
  options: Options;
991
1008
  storage: Storage;
992
1009
  editor: Editor;
993
- type: MarkType;
1010
+ type: MarkType$1;
994
1011
  parent: ParentConfig<MarkConfig<Options, Storage>>['onUpdate'];
995
1012
  }) => void) | null;
996
1013
  /**
@@ -1001,7 +1018,7 @@ declare module '@tiptap/core' {
1001
1018
  options: Options;
1002
1019
  storage: Storage;
1003
1020
  editor: Editor;
1004
- type: MarkType;
1021
+ type: MarkType$1;
1005
1022
  parent: ParentConfig<MarkConfig<Options, Storage>>['onSelectionUpdate'];
1006
1023
  }) => void) | null;
1007
1024
  /**
@@ -1012,7 +1029,7 @@ declare module '@tiptap/core' {
1012
1029
  options: Options;
1013
1030
  storage: Storage;
1014
1031
  editor: Editor;
1015
- type: MarkType;
1032
+ type: MarkType$1;
1016
1033
  parent: ParentConfig<MarkConfig<Options, Storage>>['onTransaction'];
1017
1034
  }, props: {
1018
1035
  editor: Editor;
@@ -1026,7 +1043,7 @@ declare module '@tiptap/core' {
1026
1043
  options: Options;
1027
1044
  storage: Storage;
1028
1045
  editor: Editor;
1029
- type: MarkType;
1046
+ type: MarkType$1;
1030
1047
  parent: ParentConfig<MarkConfig<Options, Storage>>['onFocus'];
1031
1048
  }, props: {
1032
1049
  event: FocusEvent;
@@ -1039,7 +1056,7 @@ declare module '@tiptap/core' {
1039
1056
  options: Options;
1040
1057
  storage: Storage;
1041
1058
  editor: Editor;
1042
- type: MarkType;
1059
+ type: MarkType$1;
1043
1060
  parent: ParentConfig<MarkConfig<Options, Storage>>['onBlur'];
1044
1061
  }, props: {
1045
1062
  event: FocusEvent;
@@ -1052,7 +1069,7 @@ declare module '@tiptap/core' {
1052
1069
  options: Options;
1053
1070
  storage: Storage;
1054
1071
  editor: Editor;
1055
- type: MarkType;
1072
+ type: MarkType$1;
1056
1073
  parent: ParentConfig<MarkConfig<Options, Storage>>['onDestroy'];
1057
1074
  }) => void) | null;
1058
1075
  /**
@@ -1536,6 +1553,7 @@ interface EditorEvents {
1536
1553
  update: {
1537
1554
  editor: Editor;
1538
1555
  transaction: Transaction;
1556
+ appendedTransactions: Transaction[];
1539
1557
  };
1540
1558
  selectionUpdate: {
1541
1559
  editor: Editor;
@@ -1549,6 +1567,7 @@ interface EditorEvents {
1549
1567
  transaction: {
1550
1568
  editor: Editor;
1551
1569
  transaction: Transaction;
1570
+ appendedTransactions: Transaction[];
1552
1571
  };
1553
1572
  focus: {
1554
1573
  editor: Editor;
@@ -1645,6 +1664,45 @@ type JSONContent = {
1645
1664
  text?: string;
1646
1665
  [key: string]: any;
1647
1666
  };
1667
+ /**
1668
+ * A mark type is either a JSON representation of a mark or a Prosemirror mark instance
1669
+ */
1670
+ type MarkType<Type extends string | {
1671
+ name: string;
1672
+ } = any, Attributes extends undefined | Record<string, any> = any> = {
1673
+ type: Type;
1674
+ attrs: Attributes;
1675
+ };
1676
+ /**
1677
+ * A node type is either a JSON representation of a node or a Prosemirror node instance
1678
+ */
1679
+ type NodeType<Type extends string | {
1680
+ name: string;
1681
+ } = any, Attributes extends undefined | Record<string, any> = any, NodeMarkType extends MarkType = any, Content extends (NodeType | TextType)[] = any> = {
1682
+ type: Type;
1683
+ attrs: Attributes;
1684
+ content?: Content;
1685
+ marks?: NodeMarkType[];
1686
+ };
1687
+ /**
1688
+ * A node type is either a JSON representation of a doc node or a Prosemirror doc node instance
1689
+ */
1690
+ type DocumentType<TDocAttributes extends Record<string, any> | undefined = Record<string, any>, TContentType extends NodeType[] = NodeType[]> = Omit<NodeType<'doc', TDocAttributes, never, TContentType>, 'marks' | 'content'> & {
1691
+ content: TContentType;
1692
+ };
1693
+ /**
1694
+ * A node type is either a JSON representation of a text node or a Prosemirror text node instance
1695
+ */
1696
+ type TextType<TMarkType extends MarkType = MarkType> = {
1697
+ type: 'text';
1698
+ text: string;
1699
+ marks: TMarkType[];
1700
+ };
1701
+ /**
1702
+ * Describes the output of a `renderHTML` function in prosemirror
1703
+ * @see https://prosemirror.net/docs/ref/#model.DOMOutputSpec
1704
+ */
1705
+ type DOMOutputSpecArray = [string] | [string, Record<string, any>] | [string, 0] | [string, Record<string, any>, 0] | [string, Record<string, any>, DOMOutputSpecArray | 0] | [string, DOMOutputSpecArray];
1648
1706
  type Content = HTMLContent | JSONContent | JSONContent[] | null;
1649
1707
  type CommandProps = {
1650
1708
  editor: Editor;
@@ -1663,6 +1721,7 @@ type KeyboardShortcutCommand = (props: {
1663
1721
  }) => boolean;
1664
1722
  type Attribute = {
1665
1723
  default?: any;
1724
+ validate?: string | ((value: any) => void);
1666
1725
  rendered?: boolean;
1667
1726
  renderHTML?: ((attributes: Record<string, any>) => Record<string, any> | null) | null;
1668
1727
  parseHTML?: ((element: HTMLElement) => any | null) | null;
@@ -1675,7 +1734,7 @@ type Attributes = {
1675
1734
  type ExtensionAttribute = {
1676
1735
  type: string;
1677
1736
  name: string;
1678
- attribute: Required<Attribute>;
1737
+ attribute: Required<Omit<Attribute, 'validate'>> & Pick<Attribute, 'validate'>;
1679
1738
  };
1680
1739
  type GlobalAttributes = {
1681
1740
  /**
@@ -1774,7 +1833,7 @@ interface NodeViewRendererProps {
1774
1833
  }
1775
1834
  type NodeViewRenderer = (props: NodeViewRendererProps) => NodeView$1;
1776
1835
  type AnyCommands = Record<string, (...args: any[]) => Command>;
1777
- type UnionCommands<T = Command> = UnionToIntersection<ValuesOf<Pick<Commands<T>, KeysWithTypeOf<Commands<T>, {}>>>>;
1836
+ type UnionCommands<T = Command> = UnionToIntersection<ValuesOf<Pick<Commands<T>, KeysWithTypeOf<Commands<T>, object>>>>;
1778
1837
  type RawCommands = {
1779
1838
  [Item in keyof UnionCommands]: UnionCommands<Command>[Item];
1780
1839
  };
@@ -1821,849 +1880,728 @@ type ExtendedRegExpMatchArray = RegExpMatchArray & {
1821
1880
  };
1822
1881
  type Dispatch = ((args?: any) => any) | undefined;
1823
1882
 
1824
- declare class ExtensionManager {
1825
- editor: Editor;
1826
- schema: Schema;
1827
- extensions: Extensions;
1828
- splittableMarks: string[];
1829
- constructor(extensions: Extensions, editor: Editor);
1830
- /**
1831
- * Returns a flattened and sorted extension list while
1832
- * also checking for duplicated extensions and warns the user.
1833
- * @param extensions An array of Tiptap extensions
1834
- * @returns An flattened and sorted array of Tiptap extensions
1835
- */
1836
- static resolve(extensions: Extensions): Extensions;
1837
- /**
1838
- * Create a flattened array of extensions by traversing the `addExtensions` field.
1839
- * @param extensions An array of Tiptap extensions
1840
- * @returns A flattened array of Tiptap extensions
1841
- */
1842
- static flatten(extensions: Extensions): Extensions;
1843
- /**
1844
- * Sort extensions by priority.
1845
- * @param extensions An array of Tiptap extensions
1846
- * @returns A sorted array of Tiptap extensions by priority
1847
- */
1848
- static sort(extensions: Extensions): Extensions;
1849
- /**
1850
- * Get all commands from the extensions.
1851
- * @returns An object with all commands where the key is the command name and the value is the command function
1852
- */
1853
- get commands(): RawCommands;
1854
- /**
1855
- * Get all registered Prosemirror plugins from the extensions.
1856
- * @returns An array of Prosemirror plugins
1857
- */
1858
- get plugins(): Plugin[];
1859
- /**
1860
- * Get all attributes from the extensions.
1861
- * @returns An array of attributes
1862
- */
1863
- get attributes(): ExtensionAttribute[];
1864
- /**
1865
- * Get all node views from the extensions.
1866
- * @returns An object with all node views where the key is the node name and the value is the node view function
1867
- */
1868
- get nodeViews(): Record<string, NodeViewConstructor>;
1869
- /**
1870
- * Go through all extensions, create extension storages & setup marks
1871
- * & bind editor event listener.
1872
- */
1873
- private setupExtensions;
1874
- }
1875
-
1876
- declare class NodePos {
1877
- private resolvedPos;
1878
- private isBlock;
1879
- private editor;
1880
- private get name();
1881
- constructor(pos: ResolvedPos, editor: Editor, isBlock?: boolean, node?: Node$1 | null);
1882
- private currentNode;
1883
- get node(): Node$1;
1884
- get element(): HTMLElement;
1885
- actualDepth: number | null;
1886
- get depth(): number;
1887
- get pos(): number;
1888
- get content(): Fragment;
1889
- set content(content: Content);
1890
- get attributes(): {
1891
- [key: string]: any;
1892
- };
1893
- get textContent(): string;
1894
- get size(): number;
1895
- get from(): number;
1896
- get range(): Range;
1897
- get to(): number;
1898
- get parent(): NodePos | null;
1899
- get before(): NodePos | null;
1900
- get after(): NodePos | null;
1901
- get children(): NodePos[];
1902
- get firstChild(): NodePos | null;
1903
- get lastChild(): NodePos | null;
1904
- closest(selector: string, attributes?: {
1905
- [key: string]: any;
1906
- }): NodePos | null;
1907
- querySelector(selector: string, attributes?: {
1908
- [key: string]: any;
1909
- }): NodePos | null;
1910
- querySelectorAll(selector: string, attributes?: {
1911
- [key: string]: any;
1912
- }, firstItemOnly?: boolean): NodePos[];
1913
- setAttribute(attributes: {
1914
- [key: string]: any;
1915
- }): void;
1916
- }
1883
+ /**
1884
+ * Create a new Prosemirror document node from content.
1885
+ * @param content The JSON or HTML content to create the document from
1886
+ * @param schema The Prosemirror schema to use for the document
1887
+ * @param parseOptions Options for the parser
1888
+ * @returns The created Prosemirror document node
1889
+ */
1890
+ declare function createDocument(content: Content | Node$1 | Fragment, schema: Schema, parseOptions?: ParseOptions, options?: {
1891
+ errorOnInvalidContent?: boolean;
1892
+ }): Node$1;
1917
1893
 
1918
- type ClipboardTextSerializerOptions = {
1919
- blockSeparator?: string;
1894
+ type CreateNodeFromContentOptions = {
1895
+ slice?: boolean;
1896
+ parseOptions?: ParseOptions;
1897
+ errorOnInvalidContent?: boolean;
1920
1898
  };
1921
- declare const ClipboardTextSerializer: Extension<ClipboardTextSerializerOptions, any>;
1899
+ /**
1900
+ * Takes a JSON or HTML content and creates a Prosemirror node or fragment from it.
1901
+ * @param content The JSON or HTML content to create the node from
1902
+ * @param schema The Prosemirror schema to use for the node
1903
+ * @param options Options for the parser
1904
+ * @returns The created Prosemirror node or fragment
1905
+ */
1906
+ declare function createNodeFromContent(content: Content | Node$1 | Fragment, schema: Schema, options?: CreateNodeFromContentOptions): Node$1 | Fragment;
1922
1907
 
1923
- declare module '@tiptap/core' {
1924
- interface Commands<ReturnType> {
1925
- blur: {
1926
- /**
1927
- * Removes focus from the editor.
1928
- * @example editor.commands.blur()
1929
- */
1930
- blur: () => ReturnType;
1931
- };
1932
- }
1933
- }
1908
+ /**
1909
+ * Gets the default block type at a given match
1910
+ * @param match The content match to get the default block type from
1911
+ * @returns The default block type or null
1912
+ */
1913
+ declare function defaultBlockAt(match: ContentMatch): NodeType$1 | null;
1934
1914
 
1935
- declare module '@tiptap/core' {
1936
- interface Commands<ReturnType> {
1937
- clearContent: {
1938
- /**
1939
- * Clear the whole document.
1940
- * @param emitUpdate Whether to emit an update event.
1941
- * @example editor.commands.clearContent()
1942
- */
1943
- clearContent: (emitUpdate?: boolean) => ReturnType;
1944
- };
1945
- }
1946
- }
1915
+ /**
1916
+ * Find children inside a Prosemirror node that match a predicate.
1917
+ * @param node The Prosemirror node to search in
1918
+ * @param predicate The predicate to match
1919
+ * @returns An array of nodes with their positions
1920
+ */
1921
+ declare function findChildren(node: Node$1, predicate: Predicate): NodeWithPos[];
1947
1922
 
1948
- declare module '@tiptap/core' {
1949
- interface Commands<ReturnType> {
1950
- clearNodes: {
1951
- /**
1952
- * Normalize nodes to a simple paragraph.
1953
- * @example editor.commands.clearNodes()
1954
- */
1955
- clearNodes: () => ReturnType;
1956
- };
1957
- }
1958
- }
1923
+ /**
1924
+ * Same as `findChildren` but searches only within a `range`.
1925
+ * @param node The Prosemirror node to search in
1926
+ * @param range The range to search in
1927
+ * @param predicate The predicate to match
1928
+ * @returns An array of nodes with their positions
1929
+ */
1930
+ declare function findChildrenInRange(node: Node$1, range: Range, predicate: Predicate): NodeWithPos[];
1959
1931
 
1960
- declare module '@tiptap/core' {
1961
- interface Commands<ReturnType> {
1962
- command: {
1963
- /**
1964
- * Define a command inline.
1965
- * @param fn The command function.
1966
- * @example
1967
- * editor.commands.command(({ tr, state }) => {
1968
- * ...
1969
- * return true
1970
- * })
1971
- */
1972
- command: (fn: (props: Parameters<Command>[0]) => boolean) => ReturnType;
1973
- };
1974
- }
1975
- }
1932
+ /**
1933
+ * Finds the closest parent node to a resolved position that matches a predicate.
1934
+ * @param $pos The resolved position to search from
1935
+ * @param predicate The predicate to match
1936
+ * @returns The closest parent node to the resolved position that matches the predicate
1937
+ * @example ```js
1938
+ * findParentNodeClosestToPos($from, node => node.type.name === 'paragraph')
1939
+ * ```
1940
+ */
1941
+ declare function findParentNodeClosestToPos($pos: ResolvedPos, predicate: Predicate): {
1942
+ pos: number;
1943
+ start: number;
1944
+ depth: number;
1945
+ node: Node$1;
1946
+ } | undefined;
1976
1947
 
1977
- declare module '@tiptap/core' {
1978
- interface Commands<ReturnType> {
1979
- createParagraphNear: {
1980
- /**
1981
- * Create a paragraph nearby.
1982
- * @example editor.commands.createParagraphNear()
1983
- */
1984
- createParagraphNear: () => ReturnType;
1985
- };
1986
- }
1987
- }
1948
+ /**
1949
+ * Finds the closest parent node to the current selection that matches a predicate.
1950
+ * @param predicate The predicate to match
1951
+ * @returns A command that finds the closest parent node to the current selection that matches the predicate
1952
+ * @example ```js
1953
+ * findParentNode(node => node.type.name === 'paragraph')
1954
+ * ```
1955
+ */
1956
+ declare function findParentNode(predicate: Predicate): (selection: Selection) => ReturnType<typeof findParentNodeClosestToPos>;
1988
1957
 
1989
- declare module '@tiptap/core' {
1990
- interface Commands<ReturnType> {
1991
- cut: {
1992
- /**
1993
- * Cuts content from a range and inserts it at a given position.
1994
- * @param range The range to cut.
1995
- * @param range.from The start position of the range.
1996
- * @param range.to The end position of the range.
1997
- * @param targetPos The position to insert the content at.
1998
- * @example editor.commands.cut({ from: 1, to: 3 }, 5)
1999
- */
2000
- cut: ({ from, to }: {
2001
- from: number;
2002
- to: number;
2003
- }, targetPos: number) => ReturnType;
2004
- };
2005
- }
2006
- }
1958
+ /**
1959
+ * Create a flattened array of extensions by traversing the `addExtensions` field.
1960
+ * @param extensions An array of Tiptap extensions
1961
+ * @returns A flattened array of Tiptap extensions
1962
+ */
1963
+ declare function flattenExtensions(extensions: Extensions): Extensions;
2007
1964
 
2008
- declare module '@tiptap/core' {
2009
- interface Commands<ReturnType> {
2010
- deleteCurrentNode: {
2011
- /**
2012
- * Delete the node that currently has the selection anchor.
2013
- * @example editor.commands.deleteCurrentNode()
2014
- */
2015
- deleteCurrentNode: () => ReturnType;
2016
- };
2017
- }
2018
- }
1965
+ /**
1966
+ * Generate HTML from a JSONContent
1967
+ * @param doc The JSONContent to generate HTML from
1968
+ * @param extensions The extensions to use for the schema
1969
+ * @returns The generated HTML
1970
+ */
1971
+ declare function generateHTML(doc: JSONContent, extensions: Extensions): string;
2019
1972
 
2020
- declare module '@tiptap/core' {
2021
- interface Commands<ReturnType> {
2022
- deleteNode: {
2023
- /**
2024
- * Delete a node with a given type or name.
2025
- * @param typeOrName The type or name of the node.
2026
- * @example editor.commands.deleteNode('paragraph')
2027
- */
2028
- deleteNode: (typeOrName: string | NodeType) => ReturnType;
2029
- };
2030
- }
2031
- }
1973
+ /**
1974
+ * Generate JSONContent from HTML
1975
+ * @param html The HTML to generate JSONContent from
1976
+ * @param extensions The extensions to use for the schema
1977
+ * @returns The generated JSONContent
1978
+ */
1979
+ declare function generateJSON(html: string, extensions: Extensions): Record<string, any>;
2032
1980
 
2033
- declare module '@tiptap/core' {
2034
- interface Commands<ReturnType> {
2035
- deleteRange: {
2036
- /**
2037
- * Delete a given range.
2038
- * @param range The range to delete.
2039
- * @example editor.commands.deleteRange({ from: 1, to: 3 })
2040
- */
2041
- deleteRange: (range: Range) => ReturnType;
2042
- };
2043
- }
2044
- }
1981
+ /**
1982
+ * Generate raw text from a JSONContent
1983
+ * @param doc The JSONContent to generate text from
1984
+ * @param extensions The extensions to use for the schema
1985
+ * @param options Options for the text generation f.e. blockSeparator or textSerializers
1986
+ * @returns The generated text
1987
+ */
1988
+ declare function generateText(doc: JSONContent, extensions: Extensions, options?: {
1989
+ blockSeparator?: string;
1990
+ textSerializers?: Record<string, TextSerializer>;
1991
+ }): string;
2045
1992
 
2046
- declare module '@tiptap/core' {
2047
- interface Commands<ReturnType> {
2048
- deleteSelection: {
2049
- /**
2050
- * Delete the selection, if there is one.
2051
- * @example editor.commands.deleteSelection()
2052
- */
2053
- deleteSelection: () => ReturnType;
2054
- };
2055
- }
2056
- }
1993
+ /**
1994
+ * Get node or mark attributes by type or name on the current editor state
1995
+ * @param state The current editor state
1996
+ * @param typeOrName The node or mark type or name
1997
+ * @returns The attributes of the node or mark or an empty object
1998
+ */
1999
+ declare function getAttributes(state: EditorState, typeOrName: string | NodeType$1 | MarkType$1): Record<string, any>;
2057
2000
 
2058
- declare module '@tiptap/core' {
2059
- interface Commands<ReturnType> {
2060
- enter: {
2061
- /**
2062
- * Trigger enter.
2063
- * @example editor.commands.enter()
2064
- */
2065
- enter: () => ReturnType;
2066
- };
2067
- }
2068
- }
2001
+ /**
2002
+ * Get a list of all extension attributes defined in `addAttribute` and `addGlobalAttribute`.
2003
+ * @param extensions List of extensions
2004
+ */
2005
+ declare function getAttributesFromExtensions(extensions: Extensions): ExtensionAttribute[];
2069
2006
 
2070
- declare module '@tiptap/core' {
2071
- interface Commands<ReturnType> {
2072
- exitCode: {
2073
- /**
2074
- * Exit from a code block.
2075
- * @example editor.commands.exitCode()
2076
- */
2077
- exitCode: () => ReturnType;
2078
- };
2079
- }
2080
- }
2007
+ type ChangedRange = {
2008
+ oldRange: Range;
2009
+ newRange: Range;
2010
+ };
2011
+ /**
2012
+ * Returns a list of changed ranges
2013
+ * based on the first and last state of all steps.
2014
+ */
2015
+ declare function getChangedRanges(transform: Transform): ChangedRange[];
2081
2016
 
2082
- declare module '@tiptap/core' {
2083
- interface Commands<ReturnType> {
2084
- extendMarkRange: {
2085
- /**
2086
- * Extends the text selection to the current mark by type or name.
2087
- * @param typeOrName The type or name of the mark.
2088
- * @param attributes The attributes of the mark.
2089
- * @example editor.commands.extendMarkRange('bold')
2090
- * @example editor.commands.extendMarkRange('mention', { userId: "1" })
2091
- */
2092
- extendMarkRange: (
2093
- /**
2094
- * The type or name of the mark.
2095
- */
2096
- typeOrName: string | MarkType,
2097
- /**
2098
- * The attributes of the mark.
2099
- */
2100
- attributes?: Record<string, any>) => ReturnType;
2101
- };
2102
- }
2017
+ interface DebugJSONContent extends JSONContent {
2018
+ from: number;
2019
+ to: number;
2103
2020
  }
2021
+ declare function getDebugJSON(node: Node$1, startOffset?: number): DebugJSONContent;
2104
2022
 
2105
- declare module '@tiptap/core' {
2106
- interface Commands<ReturnType> {
2107
- first: {
2108
- /**
2109
- * Runs one command after the other and stops at the first which returns true.
2110
- * @param commands The commands to run.
2111
- * @example editor.commands.first([command1, command2])
2112
- */
2113
- first: (commands: Command[] | ((props: CommandProps) => Command[])) => ReturnType;
2114
- };
2115
- }
2116
- }
2023
+ /**
2024
+ * Returns a field from an extension
2025
+ * @param extension The Tiptap extension
2026
+ * @param field The field, for example `renderHTML` or `priority`
2027
+ * @param context The context object that should be passed as `this` into the function
2028
+ * @returns The field value
2029
+ */
2030
+ declare function getExtensionField<T = any>(extension: AnyExtension, field: string, context?: Omit<MaybeThisParameterType<T>, 'parent'>): RemoveThis<T>;
2117
2031
 
2118
- declare module '@tiptap/core' {
2119
- interface Commands<ReturnType> {
2120
- focus: {
2121
- /**
2122
- * Focus the editor at the given position.
2123
- * @param position The position to focus at.
2124
- * @param options.scrollIntoView Scroll the focused position into view after focusing
2125
- * @example editor.commands.focus()
2126
- * @example editor.commands.focus(32, { scrollIntoView: false })
2127
- */
2128
- focus: (
2129
- /**
2130
- * The position to focus at.
2131
- */
2132
- position?: FocusPosition,
2133
- /**
2134
- * Optional options
2135
- * @default { scrollIntoView: true }
2136
- */
2137
- options?: {
2138
- scrollIntoView?: boolean;
2139
- }) => ReturnType;
2140
- };
2141
- }
2142
- }
2032
+ declare function getHTMLFromFragment(fragment: Fragment, schema: Schema): string;
2143
2033
 
2144
- declare module '@tiptap/core' {
2145
- interface Commands<ReturnType> {
2146
- forEach: {
2147
- /**
2148
- * Loop through an array of items.
2149
- */
2150
- forEach: <T>(items: T[], fn: (item: T, props: CommandProps & {
2151
- index: number;
2152
- }) => boolean) => ReturnType;
2153
- };
2154
- }
2155
- }
2034
+ declare function getMarkAttributes(state: EditorState, typeOrName: string | MarkType$1): Record<string, any>;
2156
2035
 
2157
- declare module '@tiptap/core' {
2158
- interface Commands<ReturnType> {
2159
- insertContent: {
2160
- /**
2161
- * Insert a node or string of HTML at the current position.
2162
- * @example editor.commands.insertContent('<h1>Example</h1>')
2163
- * @example editor.commands.insertContent('<h1>Example</h1>', { updateSelection: false })
2164
- */
2165
- insertContent: (
2166
- /**
2167
- * The ProseMirror content to insert.
2168
- */
2169
- value: Content | Node$1 | Fragment,
2170
- /**
2171
- * Optional options
2172
- */
2173
- options?: {
2174
- /**
2175
- * Options for parsing the content.
2176
- */
2177
- parseOptions?: ParseOptions;
2178
- /**
2179
- * Whether to update the selection after inserting the content.
2180
- */
2181
- updateSelection?: boolean;
2182
- applyInputRules?: boolean;
2183
- applyPasteRules?: boolean;
2184
- }) => ReturnType;
2185
- };
2186
- }
2187
- }
2036
+ /**
2037
+ * Get the range of a mark at a resolved position.
2038
+ */
2039
+ declare function getMarkRange(
2040
+ /**
2041
+ * The position to get the mark range for.
2042
+ */
2043
+ $pos: ResolvedPos,
2044
+ /**
2045
+ * The mark type to get the range for.
2046
+ */
2047
+ type: MarkType$1,
2048
+ /**
2049
+ * The attributes to match against.
2050
+ * If not provided, only the first mark at the position will be matched.
2051
+ */
2052
+ attributes?: Record<string, any>): Range | void;
2188
2053
 
2189
- declare module '@tiptap/core' {
2190
- interface Commands<ReturnType> {
2191
- insertContentAt: {
2192
- /**
2193
- * Insert a node or string of HTML at a specific position.
2194
- * @example editor.commands.insertContentAt(0, '<h1>Example</h1>')
2195
- */
2196
- insertContentAt: (
2197
- /**
2198
- * The position to insert the content at.
2199
- */
2200
- position: number | Range,
2201
- /**
2202
- * The ProseMirror content to insert.
2203
- */
2204
- value: Content | Node$1 | Fragment,
2205
- /**
2206
- * Optional options
2207
- */
2208
- options?: {
2209
- /**
2210
- * Options for parsing the content.
2211
- */
2212
- parseOptions?: ParseOptions;
2213
- /**
2214
- * Whether to update the selection after inserting the content.
2215
- */
2216
- updateSelection?: boolean;
2217
- /**
2218
- * Whether to apply input rules after inserting the content.
2219
- */
2220
- applyInputRules?: boolean;
2221
- /**
2222
- * Whether to apply paste rules after inserting the content.
2223
- */
2224
- applyPasteRules?: boolean;
2225
- /**
2226
- * Whether to throw an error if the content is invalid.
2227
- */
2228
- errorOnInvalidContent?: boolean;
2229
- }) => ReturnType;
2230
- };
2231
- }
2232
- }
2233
-
2234
- declare module '@tiptap/core' {
2235
- interface Commands<ReturnType> {
2236
- joinUp: {
2237
- /**
2238
- * Join the selected block or, if there is a text selection, the closest ancestor block of the selection that can be joined, with the sibling above it.
2239
- * @example editor.commands.joinUp()
2240
- */
2241
- joinUp: () => ReturnType;
2242
- };
2243
- joinDown: {
2244
- /**
2245
- * Join the selected block, or the closest ancestor of the selection that can be joined, with the sibling after it.
2246
- * @example editor.commands.joinDown()
2247
- */
2248
- joinDown: () => ReturnType;
2249
- };
2250
- joinBackward: {
2251
- /**
2252
- * If the selection is empty and at the start of a textblock, try to reduce the distance between that block and the one before it—if there's a block directly before it that can be joined, join them.
2253
- * If not, try to move the selected block closer to the next one in the document structure by lifting it out of its
2254
- * parent or moving it into a parent of the previous block. Will use the view for accurate (bidi-aware) start-of-textblock detection if given.
2255
- * @example editor.commands.joinBackward()
2256
- */
2257
- joinBackward: () => ReturnType;
2258
- };
2259
- joinForward: {
2260
- /**
2261
- * If the selection is empty and the cursor is at the end of a textblock, try to reduce or remove the boundary between that block and the one after it,
2262
- * either by joining them or by moving the other block closer to this one in the tree structure.
2263
- * Will use the view for accurate start-of-textblock detection if given.
2264
- * @example editor.commands.joinForward()
2265
- */
2266
- joinForward: () => ReturnType;
2267
- };
2268
- }
2269
- }
2054
+ declare function getMarksBetween(from: number, to: number, doc: Node$1): MarkRange[];
2270
2055
 
2271
- declare module '@tiptap/core' {
2272
- interface Commands<ReturnType> {
2273
- joinItemBackward: {
2274
- /**
2275
- * Join two items backward.
2276
- * @example editor.commands.joinItemBackward()
2277
- */
2278
- joinItemBackward: () => ReturnType;
2279
- };
2280
- }
2281
- }
2056
+ declare function getMarkType(nameOrType: string | MarkType$1, schema: Schema): MarkType$1;
2282
2057
 
2283
- declare module '@tiptap/core' {
2284
- interface Commands<ReturnType> {
2285
- joinItemForward: {
2286
- /**
2287
- * Join two items Forwards.
2288
- * @example editor.commands.joinItemForward()
2289
- */
2290
- joinItemForward: () => ReturnType;
2291
- };
2292
- }
2293
- }
2058
+ /**
2059
+ * Finds the first node of a given type or name in the current selection.
2060
+ * @param state The editor state.
2061
+ * @param typeOrName The node type or name.
2062
+ * @param pos The position to start searching from.
2063
+ * @param maxDepth The maximum depth to search.
2064
+ * @returns The node and the depth as an array.
2065
+ */
2066
+ declare const getNodeAtPosition: (state: EditorState, typeOrName: string | NodeType$1, pos: number, maxDepth?: number) => [Node$1 | null, number];
2294
2067
 
2295
- declare module '@tiptap/core' {
2296
- interface Commands<ReturnType> {
2297
- joinTextblockBackward: {
2298
- /**
2299
- * A more limited form of joinBackward that only tries to join the current textblock to the one before it, if the cursor is at the start of a textblock.
2300
- */
2301
- joinTextblockBackward: () => ReturnType;
2302
- };
2303
- }
2304
- }
2068
+ declare function getNodeAttributes(state: EditorState, typeOrName: string | NodeType$1): Record<string, any>;
2305
2069
 
2306
- declare module '@tiptap/core' {
2307
- interface Commands<ReturnType> {
2308
- joinTextblockForward: {
2309
- /**
2310
- * A more limited form of joinForward that only tries to join the current textblock to the one after it, if the cursor is at the end of a textblock.
2311
- */
2312
- joinTextblockForward: () => ReturnType;
2313
- };
2314
- }
2315
- }
2070
+ declare function getNodeType(nameOrType: string | NodeType$1, schema: Schema): NodeType$1;
2316
2071
 
2317
- declare module '@tiptap/core' {
2318
- interface Commands<ReturnType> {
2319
- keyboardShortcut: {
2320
- /**
2321
- * Trigger a keyboard shortcut.
2322
- * @param name The name of the keyboard shortcut.
2323
- * @example editor.commands.keyboardShortcut('Mod-b')
2324
- */
2325
- keyboardShortcut: (name: string) => ReturnType;
2326
- };
2327
- }
2328
- }
2072
+ declare function getRenderedAttributes(nodeOrMark: Node$1 | Mark$1, extensionAttributes: ExtensionAttribute[]): Record<string, any>;
2329
2073
 
2330
- declare module '@tiptap/core' {
2331
- interface Commands<ReturnType> {
2332
- lift: {
2333
- /**
2334
- * Removes an existing wrap if possible lifting the node out of it
2335
- * @param typeOrName The type or name of the node.
2336
- * @param attributes The attributes of the node.
2337
- * @example editor.commands.lift('paragraph')
2338
- * @example editor.commands.lift('heading', { level: 1 })
2339
- */
2340
- lift: (typeOrName: string | NodeType, attributes?: Record<string, any>) => ReturnType;
2341
- };
2342
- }
2343
- }
2074
+ declare function getSchema(extensions: Extensions, editor?: Editor): Schema;
2344
2075
 
2345
- declare module '@tiptap/core' {
2346
- interface Commands<ReturnType> {
2347
- liftEmptyBlock: {
2348
- /**
2349
- * If the cursor is in an empty textblock that can be lifted, lift the block.
2350
- * @example editor.commands.liftEmptyBlock()
2351
- */
2352
- liftEmptyBlock: () => ReturnType;
2353
- };
2354
- }
2355
- }
2076
+ /**
2077
+ * Creates a new Prosemirror schema based on the given extensions.
2078
+ * @param extensions An array of Tiptap extensions
2079
+ * @param editor The editor instance
2080
+ * @returns A Prosemirror schema
2081
+ */
2082
+ declare function getSchemaByResolvedExtensions(extensions: Extensions, editor?: Editor): Schema;
2356
2083
 
2357
- declare module '@tiptap/core' {
2358
- interface Commands<ReturnType> {
2359
- liftListItem: {
2360
- /**
2361
- * Create a command to lift the list item around the selection up into a wrapping list.
2362
- * @param typeOrName The type or name of the node.
2363
- * @example editor.commands.liftListItem('listItem')
2364
- */
2365
- liftListItem: (typeOrName: string | NodeType) => ReturnType;
2366
- };
2367
- }
2368
- }
2084
+ /**
2085
+ * Tries to get a node or mark type by its name.
2086
+ * @param name The name of the node or mark type
2087
+ * @param schema The Prosemiror schema to search in
2088
+ * @returns The node or mark type, or null if it doesn't exist
2089
+ */
2090
+ declare function getSchemaTypeByName(name: string, schema: Schema): NodeType$1 | MarkType$1 | null;
2369
2091
 
2370
- declare module '@tiptap/core' {
2371
- interface Commands<ReturnType> {
2372
- newlineInCode: {
2373
- /**
2374
- * Add a newline character in code.
2375
- * @example editor.commands.newlineInCode()
2376
- */
2377
- newlineInCode: () => ReturnType;
2378
- };
2379
- }
2380
- }
2092
+ /**
2093
+ * Get the type of a schema item by its name.
2094
+ * @param name The name of the schema item
2095
+ * @param schema The Prosemiror schema to search in
2096
+ * @returns The type of the schema item (`node` or `mark`), or null if it doesn't exist
2097
+ */
2098
+ declare function getSchemaTypeNameByName(name: string, schema: Schema): 'node' | 'mark' | null;
2381
2099
 
2382
- declare module '@tiptap/core' {
2383
- interface Commands<ReturnType> {
2384
- resetAttributes: {
2385
- /**
2386
- * Resets some node attributes to the default value.
2387
- * @param typeOrName The type or name of the node.
2388
- * @param attributes The attributes of the node to reset.
2389
- * @example editor.commands.resetAttributes('heading', 'level')
2390
- */
2391
- resetAttributes: (typeOrName: string | NodeType | MarkType, attributes: string | string[]) => ReturnType;
2392
- };
2393
- }
2394
- }
2100
+ /**
2101
+ * Return attributes of an extension that should be splitted by keepOnSplit flag
2102
+ * @param extensionAttributes Array of extension attributes
2103
+ * @param typeName The type of the extension
2104
+ * @param attributes The attributes of the extension
2105
+ * @returns The splitted attributes
2106
+ */
2107
+ declare function getSplittedAttributes(extensionAttributes: ExtensionAttribute[], typeName: string, attributes: Record<string, any>): Record<string, any>;
2395
2108
 
2396
- declare module '@tiptap/core' {
2397
- interface Commands<ReturnType> {
2398
- scrollIntoView: {
2399
- /**
2400
- * Scroll the selection into view.
2401
- * @example editor.commands.scrollIntoView()
2402
- */
2403
- scrollIntoView: () => ReturnType;
2404
- };
2405
- }
2406
- }
2109
+ /**
2110
+ * Gets the text of a Prosemirror node
2111
+ * @param node The Prosemirror node
2112
+ * @param options Options for the text serializer & block separator
2113
+ * @returns The text of the node
2114
+ * @example ```js
2115
+ * const text = getText(node, { blockSeparator: '\n' })
2116
+ * ```
2117
+ */
2118
+ declare function getText(node: Node$1, options?: {
2119
+ blockSeparator?: string;
2120
+ textSerializers?: Record<string, TextSerializer>;
2121
+ }): string;
2407
2122
 
2408
- declare module '@tiptap/core' {
2409
- interface Commands<ReturnType> {
2410
- selectAll: {
2411
- /**
2412
- * Select the whole document.
2413
- * @example editor.commands.selectAll()
2123
+ /**
2124
+ * Gets the text between two positions in a Prosemirror node
2125
+ * and serializes it using the given text serializers and block separator (see getText)
2126
+ * @param startNode The Prosemirror node to start from
2127
+ * @param range The range of the text to get
2128
+ * @param options Options for the text serializer & block separator
2129
+ * @returns The text between the two positions
2130
+ */
2131
+ declare function getTextBetween(startNode: Node$1, range: Range, options?: {
2132
+ blockSeparator?: string;
2133
+ textSerializers?: Record<string, TextSerializer>;
2134
+ }): string;
2135
+
2136
+ /**
2137
+ * Returns the text content of a resolved prosemirror position
2138
+ * @param $from The resolved position to get the text content from
2139
+ * @param maxMatch The maximum number of characters to match
2140
+ * @returns The text content
2141
+ */
2142
+ declare const getTextContentFromNodes: ($from: ResolvedPos, maxMatch?: number) => string;
2143
+
2144
+ /**
2145
+ * Find text serializers `toText` in a Prosemirror schema
2146
+ * @param schema The Prosemirror schema to search in
2147
+ * @returns A record of text serializers by node name
2148
+ */
2149
+ declare function getTextSerializersFromSchema(schema: Schema): Record<string, TextSerializer>;
2150
+
2151
+ /**
2152
+ * This function merges extension attributes into parserule attributes (`attrs` or `getAttrs`).
2153
+ * Cancels when `getAttrs` returned `false`.
2154
+ * @param parseRule ProseMirror ParseRule
2155
+ * @param extensionAttributes List of attributes to inject
2156
+ */
2157
+ declare function injectExtensionAttributesToParseRule(parseRule: ParseRule, extensionAttributes: ExtensionAttribute[]): ParseRule;
2158
+
2159
+ declare function isActive(state: EditorState, name: string | null, attributes?: Record<string, any>): boolean;
2160
+
2161
+ declare const isAtEndOfNode: (state: EditorState, nodeType?: string) => boolean;
2162
+
2163
+ declare const isAtStartOfNode: (state: EditorState) => boolean;
2164
+
2165
+ declare function isExtensionRulesEnabled(extension: AnyExtension, enabled: EnableRules): boolean;
2166
+
2167
+ declare function isList(name: string, extensions: Extensions): boolean;
2168
+
2169
+ declare function isMarkActive(state: EditorState, typeOrName: MarkType$1 | string | null, attributes?: Record<string, any>): boolean;
2170
+
2171
+ declare function isNodeActive(state: EditorState, typeOrName: NodeType$1 | string | null, attributes?: Record<string, any>): boolean;
2172
+
2173
+ /**
2174
+ * Returns true if the given prosemirror node is empty.
2175
+ */
2176
+ declare function isNodeEmpty(node: Node$1, { checkChildren, ignoreWhitespace, }?: {
2177
+ /**
2178
+ * When true (default), it will also check if all children are empty.
2179
+ */
2180
+ checkChildren?: boolean;
2181
+ /**
2182
+ * When true, it will ignore whitespace when checking for emptiness.
2183
+ */
2184
+ ignoreWhitespace?: boolean;
2185
+ }): boolean;
2186
+
2187
+ declare function isNodeSelection(value: unknown): value is NodeSelection;
2188
+
2189
+ declare function isTextSelection(value: unknown): value is TextSelection;
2190
+
2191
+ declare function posToDOMRect(view: EditorView, from: number, to: number): DOMRect;
2192
+
2193
+ /**
2194
+ * Returns a flattened and sorted extension list while
2195
+ * also checking for duplicated extensions and warns the user.
2196
+ * @param extensions An array of Tiptap extensions
2197
+ * @returns An flattened and sorted array of Tiptap extensions
2198
+ */
2199
+ declare function resolveExtensions(extensions: Extensions): Extensions;
2200
+
2201
+ declare function resolveFocusPosition(doc: Node$1, position?: FocusPosition): Selection | null;
2202
+
2203
+ type RewriteUnknownContentOptions = {
2204
+ /**
2205
+ * If true, unknown nodes will be treated as paragraphs
2206
+ * @default true
2207
+ */
2208
+ fallbackToParagraph?: boolean;
2209
+ };
2210
+ /**
2211
+ * Rewrite unknown nodes and marks within JSON content
2212
+ * Allowing for user within the editor
2213
+ */
2214
+ declare function rewriteUnknownContent(
2215
+ /**
2216
+ * The JSON content to clean of unknown nodes and marks
2217
+ */
2218
+ json: JSONContent,
2219
+ /**
2220
+ * The schema to use for validation
2221
+ */
2222
+ schema: Schema,
2223
+ /**
2224
+ * Options for the cleaning process
2225
+ */
2226
+ options?: RewriteUnknownContentOptions): {
2227
+ /**
2228
+ * The cleaned JSON content
2229
+ */
2230
+ json: JSONContent | null;
2231
+ /**
2232
+ * The array of nodes and marks that were rewritten
2233
+ */
2234
+ rewrittenContent: {
2235
+ /**
2236
+ * The original JSON content that was rewritten
2237
+ */
2238
+ original: JSONContent;
2239
+ /**
2240
+ * The name of the node or mark that was unsupported
2241
+ */
2242
+ unsupported: string;
2243
+ }[];
2244
+ };
2245
+
2246
+ declare function selectionToInsertionEnd(tr: Transaction, startLen: number, bias: number): void;
2247
+
2248
+ /**
2249
+ * Sort extensions by priority.
2250
+ * @param extensions An array of Tiptap extensions
2251
+ * @returns A sorted array of Tiptap extensions by priority
2252
+ */
2253
+ declare function sortExtensions(extensions: Extensions): Extensions;
2254
+
2255
+ declare function splitExtensions(extensions: Extensions): {
2256
+ baseExtensions: Extension<any, any>[];
2257
+ nodeExtensions: Node<any, any>[];
2258
+ markExtensions: Mark<any, any>[];
2259
+ };
2260
+
2261
+ declare class ExtensionManager {
2262
+ editor: Editor;
2263
+ schema: Schema;
2264
+ extensions: Extensions;
2265
+ splittableMarks: string[];
2266
+ constructor(extensions: Extensions, editor: Editor);
2267
+ static resolve: typeof resolveExtensions;
2268
+ static sort: typeof sortExtensions;
2269
+ static flatten: typeof flattenExtensions;
2270
+ /**
2271
+ * Get all commands from the extensions.
2272
+ * @returns An object with all commands where the key is the command name and the value is the command function
2273
+ */
2274
+ get commands(): RawCommands;
2275
+ /**
2276
+ * Get all registered Prosemirror plugins from the extensions.
2277
+ * @returns An array of Prosemirror plugins
2278
+ */
2279
+ get plugins(): Plugin[];
2280
+ /**
2281
+ * Get all attributes from the extensions.
2282
+ * @returns An array of attributes
2283
+ */
2284
+ get attributes(): ExtensionAttribute[];
2285
+ /**
2286
+ * Get all node views from the extensions.
2287
+ * @returns An object with all node views where the key is the node name and the value is the node view function
2288
+ */
2289
+ get nodeViews(): Record<string, NodeViewConstructor>;
2290
+ /**
2291
+ * Go through all extensions, create extension storages & setup marks
2292
+ * & bind editor event listener.
2293
+ */
2294
+ private setupExtensions;
2295
+ }
2296
+
2297
+ declare class NodePos {
2298
+ private resolvedPos;
2299
+ private isBlock;
2300
+ private editor;
2301
+ private get name();
2302
+ constructor(pos: ResolvedPos, editor: Editor, isBlock?: boolean, node?: Node$1 | null);
2303
+ private currentNode;
2304
+ get node(): Node$1;
2305
+ get element(): HTMLElement;
2306
+ actualDepth: number | null;
2307
+ get depth(): number;
2308
+ get pos(): number;
2309
+ get content(): Fragment;
2310
+ set content(content: Content);
2311
+ get attributes(): {
2312
+ [key: string]: any;
2313
+ };
2314
+ get textContent(): string;
2315
+ get size(): number;
2316
+ get from(): number;
2317
+ get range(): Range;
2318
+ get to(): number;
2319
+ get parent(): NodePos | null;
2320
+ get before(): NodePos | null;
2321
+ get after(): NodePos | null;
2322
+ get children(): NodePos[];
2323
+ get firstChild(): NodePos | null;
2324
+ get lastChild(): NodePos | null;
2325
+ closest(selector: string, attributes?: {
2326
+ [key: string]: any;
2327
+ }): NodePos | null;
2328
+ querySelector(selector: string, attributes?: {
2329
+ [key: string]: any;
2330
+ }): NodePos | null;
2331
+ querySelectorAll(selector: string, attributes?: {
2332
+ [key: string]: any;
2333
+ }, firstItemOnly?: boolean): NodePos[];
2334
+ setAttribute(attributes: {
2335
+ [key: string]: any;
2336
+ }): void;
2337
+ }
2338
+
2339
+ type ClipboardTextSerializerOptions = {
2340
+ blockSeparator?: string;
2341
+ };
2342
+ declare const ClipboardTextSerializer: Extension<ClipboardTextSerializerOptions, any>;
2343
+
2344
+ declare module '@tiptap/core' {
2345
+ interface Commands<ReturnType> {
2346
+ blur: {
2347
+ /**
2348
+ * Removes focus from the editor.
2349
+ * @example editor.commands.blur()
2414
2350
  */
2415
- selectAll: () => ReturnType;
2351
+ blur: () => ReturnType;
2416
2352
  };
2417
2353
  }
2418
2354
  }
2419
2355
 
2420
2356
  declare module '@tiptap/core' {
2421
2357
  interface Commands<ReturnType> {
2422
- selectNodeBackward: {
2358
+ clearContent: {
2423
2359
  /**
2424
- * Select a node backward.
2425
- * @example editor.commands.selectNodeBackward()
2360
+ * Clear the whole document.
2361
+ * @param emitUpdate Whether to emit an update event.
2362
+ * @example editor.commands.clearContent()
2426
2363
  */
2427
- selectNodeBackward: () => ReturnType;
2364
+ clearContent: (emitUpdate?: boolean) => ReturnType;
2428
2365
  };
2429
2366
  }
2430
2367
  }
2431
2368
 
2432
2369
  declare module '@tiptap/core' {
2433
2370
  interface Commands<ReturnType> {
2434
- selectNodeForward: {
2371
+ clearNodes: {
2435
2372
  /**
2436
- * Select a node forward.
2437
- * @example editor.commands.selectNodeForward()
2373
+ * Normalize nodes to a simple paragraph.
2374
+ * @example editor.commands.clearNodes()
2438
2375
  */
2439
- selectNodeForward: () => ReturnType;
2376
+ clearNodes: () => ReturnType;
2440
2377
  };
2441
2378
  }
2442
2379
  }
2443
2380
 
2444
2381
  declare module '@tiptap/core' {
2445
2382
  interface Commands<ReturnType> {
2446
- selectParentNode: {
2383
+ command: {
2447
2384
  /**
2448
- * Select the parent node.
2449
- * @example editor.commands.selectParentNode()
2385
+ * Define a command inline.
2386
+ * @param fn The command function.
2387
+ * @example
2388
+ * editor.commands.command(({ tr, state }) => {
2389
+ * ...
2390
+ * return true
2391
+ * })
2450
2392
  */
2451
- selectParentNode: () => ReturnType;
2393
+ command: (fn: (props: Parameters<Command>[0]) => boolean) => ReturnType;
2452
2394
  };
2453
2395
  }
2454
2396
  }
2455
2397
 
2456
2398
  declare module '@tiptap/core' {
2457
2399
  interface Commands<ReturnType> {
2458
- selectTextblockEnd: {
2400
+ createParagraphNear: {
2459
2401
  /**
2460
- * Moves the cursor to the end of current text block.
2461
- * @example editor.commands.selectTextblockEnd()
2402
+ * Create a paragraph nearby.
2403
+ * @example editor.commands.createParagraphNear()
2462
2404
  */
2463
- selectTextblockEnd: () => ReturnType;
2405
+ createParagraphNear: () => ReturnType;
2464
2406
  };
2465
2407
  }
2466
2408
  }
2467
2409
 
2468
2410
  declare module '@tiptap/core' {
2469
2411
  interface Commands<ReturnType> {
2470
- selectTextblockStart: {
2412
+ cut: {
2471
2413
  /**
2472
- * Moves the cursor to the start of current text block.
2473
- * @example editor.commands.selectTextblockStart()
2414
+ * Cuts content from a range and inserts it at a given position.
2415
+ * @param range The range to cut.
2416
+ * @param range.from The start position of the range.
2417
+ * @param range.to The end position of the range.
2418
+ * @param targetPos The position to insert the content at.
2419
+ * @example editor.commands.cut({ from: 1, to: 3 }, 5)
2474
2420
  */
2475
- selectTextblockStart: () => ReturnType;
2421
+ cut: ({ from, to }: {
2422
+ from: number;
2423
+ to: number;
2424
+ }, targetPos: number) => ReturnType;
2476
2425
  };
2477
2426
  }
2478
2427
  }
2479
2428
 
2480
2429
  declare module '@tiptap/core' {
2481
2430
  interface Commands<ReturnType> {
2482
- setContent: {
2431
+ deleteCurrentNode: {
2483
2432
  /**
2484
- * Replace the whole document with new content.
2485
- * @param content The new content.
2486
- * @param emitUpdate Whether to emit an update event.
2487
- * @param parseOptions Options for parsing the content.
2488
- * @example editor.commands.setContent('<p>Example text</p>')
2489
- */
2490
- setContent: (
2491
- /**
2492
- * The new content.
2493
- */
2494
- content: Content | Fragment | Node$1,
2495
- /**
2496
- * Whether to emit an update event.
2497
- * @default false
2498
- */
2499
- emitUpdate?: boolean,
2500
- /**
2501
- * Options for parsing the content.
2502
- * @default {}
2503
- */
2504
- parseOptions?: ParseOptions,
2505
- /**
2506
- * Options for `setContent`.
2433
+ * Delete the node that currently has the selection anchor.
2434
+ * @example editor.commands.deleteCurrentNode()
2507
2435
  */
2508
- options?: {
2509
- /**
2510
- * Whether to throw an error if the content is invalid.
2511
- */
2512
- errorOnInvalidContent?: boolean;
2513
- }) => ReturnType;
2436
+ deleteCurrentNode: () => ReturnType;
2514
2437
  };
2515
2438
  }
2516
2439
  }
2517
2440
 
2518
2441
  declare module '@tiptap/core' {
2519
2442
  interface Commands<ReturnType> {
2520
- setMark: {
2443
+ deleteNode: {
2521
2444
  /**
2522
- * Add a mark with new attributes.
2523
- * @param typeOrName The mark type or name.
2524
- * @example editor.commands.setMark('bold', { level: 1 })
2445
+ * Delete a node with a given type or name.
2446
+ * @param typeOrName The type or name of the node.
2447
+ * @example editor.commands.deleteNode('paragraph')
2525
2448
  */
2526
- setMark: (typeOrName: string | MarkType, attributes?: Record<string, any>) => ReturnType;
2449
+ deleteNode: (typeOrName: string | NodeType$1) => ReturnType;
2527
2450
  };
2528
2451
  }
2529
2452
  }
2530
2453
 
2531
2454
  declare module '@tiptap/core' {
2532
2455
  interface Commands<ReturnType> {
2533
- setMeta: {
2456
+ deleteRange: {
2534
2457
  /**
2535
- * Store a metadata property in the current transaction.
2536
- * @param key The key of the metadata property.
2537
- * @param value The value to store.
2538
- * @example editor.commands.setMeta('foo', 'bar')
2458
+ * Delete a given range.
2459
+ * @param range The range to delete.
2460
+ * @example editor.commands.deleteRange({ from: 1, to: 3 })
2539
2461
  */
2540
- setMeta: (key: string | Plugin | PluginKey, value: any) => ReturnType;
2462
+ deleteRange: (range: Range) => ReturnType;
2541
2463
  };
2542
2464
  }
2543
2465
  }
2544
2466
 
2545
2467
  declare module '@tiptap/core' {
2546
2468
  interface Commands<ReturnType> {
2547
- setNode: {
2469
+ deleteSelection: {
2548
2470
  /**
2549
- * Replace a given range with a node.
2550
- * @param typeOrName The type or name of the node
2551
- * @param attributes The attributes of the node
2552
- * @example editor.commands.setNode('paragraph')
2471
+ * Delete the selection, if there is one.
2472
+ * @example editor.commands.deleteSelection()
2553
2473
  */
2554
- setNode: (typeOrName: string | NodeType, attributes?: Record<string, any>) => ReturnType;
2474
+ deleteSelection: () => ReturnType;
2555
2475
  };
2556
2476
  }
2557
2477
  }
2558
2478
 
2559
2479
  declare module '@tiptap/core' {
2560
2480
  interface Commands<ReturnType> {
2561
- setNodeSelection: {
2481
+ enter: {
2562
2482
  /**
2563
- * Creates a NodeSelection.
2564
- * @param position - Position of the node.
2565
- * @example editor.commands.setNodeSelection(10)
2483
+ * Trigger enter.
2484
+ * @example editor.commands.enter()
2566
2485
  */
2567
- setNodeSelection: (position: number) => ReturnType;
2486
+ enter: () => ReturnType;
2568
2487
  };
2569
2488
  }
2570
2489
  }
2571
2490
 
2572
2491
  declare module '@tiptap/core' {
2573
2492
  interface Commands<ReturnType> {
2574
- setTextSelection: {
2493
+ exitCode: {
2575
2494
  /**
2576
- * Creates a TextSelection.
2577
- * @param position The position of the selection.
2578
- * @example editor.commands.setTextSelection(10)
2495
+ * Exit from a code block.
2496
+ * @example editor.commands.exitCode()
2579
2497
  */
2580
- setTextSelection: (position: number | Range) => ReturnType;
2498
+ exitCode: () => ReturnType;
2581
2499
  };
2582
2500
  }
2583
2501
  }
2584
2502
 
2585
2503
  declare module '@tiptap/core' {
2586
2504
  interface Commands<ReturnType> {
2587
- sinkListItem: {
2505
+ extendMarkRange: {
2588
2506
  /**
2589
- * Sink the list item down into an inner list.
2590
- * @param typeOrName The type or name of the node.
2591
- * @example editor.commands.sinkListItem('listItem')
2507
+ * Extends the text selection to the current mark by type or name.
2508
+ * @param typeOrName The type or name of the mark.
2509
+ * @param attributes The attributes of the mark.
2510
+ * @example editor.commands.extendMarkRange('bold')
2511
+ * @example editor.commands.extendMarkRange('mention', { userId: "1" })
2512
+ */
2513
+ extendMarkRange: (
2514
+ /**
2515
+ * The type or name of the mark.
2592
2516
  */
2593
- sinkListItem: (typeOrName: string | NodeType) => ReturnType;
2517
+ typeOrName: string | MarkType$1,
2518
+ /**
2519
+ * The attributes of the mark.
2520
+ */
2521
+ attributes?: Record<string, any>) => ReturnType;
2594
2522
  };
2595
2523
  }
2596
2524
  }
2597
2525
 
2598
2526
  declare module '@tiptap/core' {
2599
2527
  interface Commands<ReturnType> {
2600
- splitBlock: {
2528
+ first: {
2601
2529
  /**
2602
- * Forks a new node from an existing node.
2603
- * @param options.keepMarks Keep marks from the previous node.
2604
- * @example editor.commands.splitBlock()
2605
- * @example editor.commands.splitBlock({ keepMarks: true })
2530
+ * Runs one command after the other and stops at the first which returns true.
2531
+ * @param commands The commands to run.
2532
+ * @example editor.commands.first([command1, command2])
2606
2533
  */
2607
- splitBlock: (options?: {
2608
- keepMarks?: boolean;
2609
- }) => ReturnType;
2534
+ first: (commands: Command[] | ((props: CommandProps) => Command[])) => ReturnType;
2610
2535
  };
2611
2536
  }
2612
2537
  }
2613
2538
 
2614
2539
  declare module '@tiptap/core' {
2615
2540
  interface Commands<ReturnType> {
2616
- splitListItem: {
2541
+ focus: {
2617
2542
  /**
2618
- * Splits one list item into two list items.
2619
- * @param typeOrName The type or name of the node.
2620
- * @param overrideAttrs The attributes to ensure on the new node.
2621
- * @example editor.commands.splitListItem('listItem')
2543
+ * Focus the editor at the given position.
2544
+ * @param position The position to focus at.
2545
+ * @param options.scrollIntoView Scroll the focused position into view after focusing
2546
+ * @example editor.commands.focus()
2547
+ * @example editor.commands.focus(32, { scrollIntoView: false })
2548
+ */
2549
+ focus: (
2550
+ /**
2551
+ * The position to focus at.
2622
2552
  */
2623
- splitListItem: (typeOrName: string | NodeType, overrideAttrs?: Record<string, any>) => ReturnType;
2553
+ position?: FocusPosition,
2554
+ /**
2555
+ * Optional options
2556
+ * @default { scrollIntoView: true }
2557
+ */
2558
+ options?: {
2559
+ scrollIntoView?: boolean;
2560
+ }) => ReturnType;
2624
2561
  };
2625
2562
  }
2626
2563
  }
2627
2564
 
2628
2565
  declare module '@tiptap/core' {
2629
2566
  interface Commands<ReturnType> {
2630
- toggleList: {
2567
+ forEach: {
2631
2568
  /**
2632
- * Toggle between different list types.
2633
- * @param listTypeOrName The type or name of the list.
2634
- * @param itemTypeOrName The type or name of the list item.
2635
- * @param keepMarks Keep marks when toggling.
2636
- * @param attributes Attributes for the new list.
2637
- * @example editor.commands.toggleList('bulletList', 'listItem')
2569
+ * Loop through an array of items.
2638
2570
  */
2639
- toggleList: (listTypeOrName: string | NodeType, itemTypeOrName: string | NodeType, keepMarks?: boolean, attributes?: Record<string, any>) => ReturnType;
2571
+ forEach: <T>(items: T[], fn: (item: T, props: CommandProps & {
2572
+ index: number;
2573
+ }) => boolean) => ReturnType;
2640
2574
  };
2641
2575
  }
2642
2576
  }
2643
2577
 
2644
2578
  declare module '@tiptap/core' {
2645
2579
  interface Commands<ReturnType> {
2646
- toggleMark: {
2580
+ insertContent: {
2647
2581
  /**
2648
- * Toggle a mark on and off.
2649
- * @param typeOrName The mark type or name.
2650
- * @param attributes The attributes of the mark.
2651
- * @param options.extendEmptyMarkRange Removes the mark even across the current selection. Defaults to `false`.
2652
- * @example editor.commands.toggleMark('bold')
2582
+ * Insert a node or string of HTML at the current position.
2583
+ * @example editor.commands.insertContent('<h1>Example</h1>')
2584
+ * @example editor.commands.insertContent('<h1>Example</h1>', { updateSelection: false })
2653
2585
  */
2654
- toggleMark: (
2586
+ insertContent: (
2655
2587
  /**
2656
- * The mark type or name.
2588
+ * The ProseMirror content to insert.
2657
2589
  */
2658
- typeOrName: string | MarkType,
2590
+ value: Content | Node$1 | Fragment,
2659
2591
  /**
2660
- * The attributes of the mark.
2592
+ * Optional options
2661
2593
  */
2662
- attributes?: Record<string, any>, options?: {
2594
+ options?: {
2663
2595
  /**
2664
- * Removes the mark even across the current selection. Defaults to `false`.
2596
+ * Options for parsing the content.
2665
2597
  */
2666
- extendEmptyMarkRange?: boolean;
2598
+ parseOptions?: ParseOptions;
2599
+ /**
2600
+ * Whether to update the selection after inserting the content.
2601
+ */
2602
+ updateSelection?: boolean;
2603
+ applyInputRules?: boolean;
2604
+ applyPasteRules?: boolean;
2667
2605
  }) => ReturnType;
2668
2606
  };
2669
2607
  }
@@ -2671,670 +2609,811 @@ declare module '@tiptap/core' {
2671
2609
 
2672
2610
  declare module '@tiptap/core' {
2673
2611
  interface Commands<ReturnType> {
2674
- toggleNode: {
2612
+ insertContentAt: {
2675
2613
  /**
2676
- * Toggle a node with another node.
2677
- * @param typeOrName The type or name of the node.
2678
- * @param toggleTypeOrName The type or name of the node to toggle.
2679
- * @param attributes The attributes of the node.
2680
- * @example editor.commands.toggleNode('heading', 'paragraph')
2614
+ * Insert a node or string of HTML at a specific position.
2615
+ * @example editor.commands.insertContentAt(0, '<h1>Example</h1>')
2616
+ */
2617
+ insertContentAt: (
2618
+ /**
2619
+ * The position to insert the content at.
2620
+ */
2621
+ position: number | Range,
2622
+ /**
2623
+ * The ProseMirror content to insert.
2624
+ */
2625
+ value: Content | Node$1 | Fragment,
2626
+ /**
2627
+ * Optional options
2681
2628
  */
2682
- toggleNode: (typeOrName: string | NodeType, toggleTypeOrName: string | NodeType, attributes?: Record<string, any>) => ReturnType;
2629
+ options?: {
2630
+ /**
2631
+ * Options for parsing the content.
2632
+ */
2633
+ parseOptions?: ParseOptions;
2634
+ /**
2635
+ * Whether to update the selection after inserting the content.
2636
+ */
2637
+ updateSelection?: boolean;
2638
+ /**
2639
+ * Whether to apply input rules after inserting the content.
2640
+ */
2641
+ applyInputRules?: boolean;
2642
+ /**
2643
+ * Whether to apply paste rules after inserting the content.
2644
+ */
2645
+ applyPasteRules?: boolean;
2646
+ /**
2647
+ * Whether to throw an error if the content is invalid.
2648
+ */
2649
+ errorOnInvalidContent?: boolean;
2650
+ }) => ReturnType;
2683
2651
  };
2684
2652
  }
2685
2653
  }
2686
2654
 
2687
2655
  declare module '@tiptap/core' {
2688
2656
  interface Commands<ReturnType> {
2689
- toggleWrap: {
2657
+ joinUp: {
2690
2658
  /**
2691
- * Wraps nodes in another node, or removes an existing wrap.
2692
- * @param typeOrName The type or name of the node.
2693
- * @param attributes The attributes of the node.
2694
- * @example editor.commands.toggleWrap('blockquote')
2659
+ * Join the selected block or, if there is a text selection, the closest ancestor block of the selection that can be joined, with the sibling above it.
2660
+ * @example editor.commands.joinUp()
2661
+ */
2662
+ joinUp: () => ReturnType;
2663
+ };
2664
+ joinDown: {
2665
+ /**
2666
+ * Join the selected block, or the closest ancestor of the selection that can be joined, with the sibling after it.
2667
+ * @example editor.commands.joinDown()
2668
+ */
2669
+ joinDown: () => ReturnType;
2670
+ };
2671
+ joinBackward: {
2672
+ /**
2673
+ * If the selection is empty and at the start of a textblock, try to reduce the distance between that block and the one before it—if there's a block directly before it that can be joined, join them.
2674
+ * If not, try to move the selected block closer to the next one in the document structure by lifting it out of its
2675
+ * parent or moving it into a parent of the previous block. Will use the view for accurate (bidi-aware) start-of-textblock detection if given.
2676
+ * @example editor.commands.joinBackward()
2677
+ */
2678
+ joinBackward: () => ReturnType;
2679
+ };
2680
+ joinForward: {
2681
+ /**
2682
+ * If the selection is empty and the cursor is at the end of a textblock, try to reduce or remove the boundary between that block and the one after it,
2683
+ * either by joining them or by moving the other block closer to this one in the tree structure.
2684
+ * Will use the view for accurate start-of-textblock detection if given.
2685
+ * @example editor.commands.joinForward()
2695
2686
  */
2696
- toggleWrap: (typeOrName: string | NodeType, attributes?: Record<string, any>) => ReturnType;
2687
+ joinForward: () => ReturnType;
2697
2688
  };
2698
2689
  }
2699
2690
  }
2700
2691
 
2701
2692
  declare module '@tiptap/core' {
2702
2693
  interface Commands<ReturnType> {
2703
- undoInputRule: {
2694
+ joinItemBackward: {
2704
2695
  /**
2705
- * Undo an input rule.
2706
- * @example editor.commands.undoInputRule()
2696
+ * Join two items backward.
2697
+ * @example editor.commands.joinItemBackward()
2707
2698
  */
2708
- undoInputRule: () => ReturnType;
2699
+ joinItemBackward: () => ReturnType;
2709
2700
  };
2710
2701
  }
2711
2702
  }
2712
2703
 
2713
2704
  declare module '@tiptap/core' {
2714
2705
  interface Commands<ReturnType> {
2715
- unsetAllMarks: {
2706
+ joinItemForward: {
2716
2707
  /**
2717
- * Remove all marks in the current selection.
2718
- * @example editor.commands.unsetAllMarks()
2708
+ * Join two items Forwards.
2709
+ * @example editor.commands.joinItemForward()
2719
2710
  */
2720
- unsetAllMarks: () => ReturnType;
2711
+ joinItemForward: () => ReturnType;
2721
2712
  };
2722
2713
  }
2723
2714
  }
2724
2715
 
2725
2716
  declare module '@tiptap/core' {
2726
2717
  interface Commands<ReturnType> {
2727
- unsetMark: {
2728
- /**
2729
- * Remove all marks in the current selection.
2730
- * @param typeOrName The mark type or name.
2731
- * @param options.extendEmptyMarkRange Removes the mark even across the current selection. Defaults to `false`.
2732
- * @example editor.commands.unsetMark('bold')
2733
- */
2734
- unsetMark: (
2718
+ joinTextblockBackward: {
2735
2719
  /**
2736
- * The mark type or name.
2720
+ * A more limited form of joinBackward that only tries to join the current textblock to the one before it, if the cursor is at the start of a textblock.
2737
2721
  */
2738
- typeOrName: string | MarkType, options?: {
2739
- /**
2740
- * Removes the mark even across the current selection. Defaults to `false`.
2741
- */
2742
- extendEmptyMarkRange?: boolean;
2743
- }) => ReturnType;
2722
+ joinTextblockBackward: () => ReturnType;
2744
2723
  };
2745
2724
  }
2746
2725
  }
2747
2726
 
2748
2727
  declare module '@tiptap/core' {
2749
2728
  interface Commands<ReturnType> {
2750
- updateAttributes: {
2751
- /**
2752
- * Update attributes of a node or mark.
2753
- * @param typeOrName The type or name of the node or mark.
2754
- * @param attributes The attributes of the node or mark.
2755
- * @example editor.commands.updateAttributes('mention', { userId: "2" })
2756
- */
2757
- updateAttributes: (
2758
- /**
2759
- * The type or name of the node or mark.
2760
- */
2761
- typeOrName: string | NodeType | MarkType,
2729
+ joinTextblockForward: {
2762
2730
  /**
2763
- * The attributes of the node or mark.
2731
+ * A more limited form of joinForward that only tries to join the current textblock to the one after it, if the cursor is at the end of a textblock.
2764
2732
  */
2765
- attributes: Record<string, any>) => ReturnType;
2733
+ joinTextblockForward: () => ReturnType;
2766
2734
  };
2767
2735
  }
2768
2736
  }
2769
2737
 
2770
2738
  declare module '@tiptap/core' {
2771
2739
  interface Commands<ReturnType> {
2772
- wrapIn: {
2740
+ keyboardShortcut: {
2773
2741
  /**
2774
- * Wraps nodes in another node.
2775
- * @param typeOrName The type or name of the node.
2776
- * @param attributes The attributes of the node.
2777
- * @example editor.commands.wrapIn('blockquote')
2742
+ * Trigger a keyboard shortcut.
2743
+ * @param name The name of the keyboard shortcut.
2744
+ * @example editor.commands.keyboardShortcut('Mod-b')
2778
2745
  */
2779
- wrapIn: (typeOrName: string | NodeType, attributes?: Record<string, any>) => ReturnType;
2746
+ keyboardShortcut: (name: string) => ReturnType;
2780
2747
  };
2781
2748
  }
2782
2749
  }
2783
2750
 
2784
2751
  declare module '@tiptap/core' {
2785
2752
  interface Commands<ReturnType> {
2786
- wrapInList: {
2753
+ lift: {
2787
2754
  /**
2788
- * Wrap a node in a list.
2755
+ * Removes an existing wrap if possible lifting the node out of it
2789
2756
  * @param typeOrName The type or name of the node.
2790
2757
  * @param attributes The attributes of the node.
2791
- * @example editor.commands.wrapInList('bulletList')
2758
+ * @example editor.commands.lift('paragraph')
2759
+ * @example editor.commands.lift('heading', { level: 1 })
2792
2760
  */
2793
- wrapInList: (typeOrName: string | NodeType, attributes?: Record<string, any>) => ReturnType;
2761
+ lift: (typeOrName: string | NodeType$1, attributes?: Record<string, any>) => ReturnType;
2794
2762
  };
2795
2763
  }
2796
2764
  }
2797
2765
 
2798
- declare const Commands$1: Extension<any, any>;
2799
-
2800
- declare const Drop: Extension<any, any>;
2801
-
2802
- declare const Editable: Extension<any, any>;
2803
-
2804
- declare const FocusEvents: Extension<any, any>;
2805
-
2806
- declare const Keymap: Extension<any, any>;
2807
-
2808
- declare const Paste: Extension<any, any>;
2809
-
2810
- declare const Tabindex: Extension<any, any>;
2811
-
2812
- declare const index_ClipboardTextSerializer: typeof ClipboardTextSerializer;
2813
- declare const index_Drop: typeof Drop;
2814
- declare const index_Editable: typeof Editable;
2815
- declare const index_FocusEvents: typeof FocusEvents;
2816
- declare const index_Keymap: typeof Keymap;
2817
- declare const index_Paste: typeof Paste;
2818
- declare const index_Tabindex: typeof Tabindex;
2819
- declare namespace index {
2820
- export { index_ClipboardTextSerializer as ClipboardTextSerializer, Commands$1 as Commands, index_Drop as Drop, index_Editable as Editable, index_FocusEvents as FocusEvents, index_Keymap as Keymap, index_Paste as Paste, index_Tabindex as Tabindex };
2821
- }
2822
-
2823
- interface TiptapEditorHTMLElement extends HTMLElement {
2824
- editor?: Editor;
2825
- }
2826
- declare class Editor extends EventEmitter<EditorEvents> {
2827
- private commandManager;
2828
- extensionManager: ExtensionManager;
2829
- private css;
2830
- schema: Schema;
2831
- view: EditorView;
2832
- isFocused: boolean;
2833
- /**
2834
- * The editor is considered initialized after the `create` event has been emitted.
2835
- */
2836
- isInitialized: boolean;
2837
- extensionStorage: Record<string, any>;
2838
- /**
2839
- * A unique ID for this editor instance.
2840
- */
2841
- instanceId: string;
2842
- options: EditorOptions;
2843
- constructor(options?: Partial<EditorOptions>);
2844
- /**
2845
- * Returns the editor storage.
2846
- */
2847
- get storage(): Record<string, any>;
2848
- /**
2849
- * An object of all registered commands.
2850
- */
2851
- get commands(): SingleCommands;
2852
- /**
2853
- * Create a command chain to call multiple commands at once.
2854
- */
2855
- chain(): ChainedCommands;
2856
- /**
2857
- * Check if a command or a command chain can be executed. Without executing it.
2858
- */
2859
- can(): CanCommands;
2860
- /**
2861
- * Inject CSS styles.
2862
- */
2863
- private injectCSS;
2864
- /**
2865
- * Update editor options.
2866
- *
2867
- * @param options A list of options
2868
- */
2869
- setOptions(options?: Partial<EditorOptions>): void;
2870
- /**
2871
- * Update editable state of the editor.
2872
- */
2873
- setEditable(editable: boolean, emitUpdate?: boolean): void;
2874
- /**
2875
- * Returns whether the editor is editable.
2876
- */
2877
- get isEditable(): boolean;
2878
- /**
2879
- * Returns the editor state.
2880
- */
2881
- get state(): EditorState;
2882
- /**
2883
- * Register a ProseMirror plugin.
2884
- *
2885
- * @param plugin A ProseMirror plugin
2886
- * @param handlePlugins Control how to merge the plugin into the existing plugins.
2887
- * @returns The new editor state
2888
- */
2889
- registerPlugin(plugin: Plugin, handlePlugins?: (newPlugin: Plugin, plugins: Plugin[]) => Plugin[]): EditorState;
2890
- /**
2891
- * Unregister a ProseMirror plugin.
2892
- *
2893
- * @param nameOrPluginKeyToRemove The plugins name
2894
- * @returns The new editor state or undefined if the editor is destroyed
2895
- */
2896
- unregisterPlugin(nameOrPluginKeyToRemove: string | PluginKey | (string | PluginKey)[]): EditorState | undefined;
2897
- /**
2898
- * Creates an extension manager.
2899
- */
2900
- private createExtensionManager;
2901
- /**
2902
- * Creates an command manager.
2903
- */
2904
- private createCommandManager;
2905
- /**
2906
- * Creates a ProseMirror schema.
2907
- */
2908
- private createSchema;
2909
- /**
2910
- * Creates a ProseMirror view.
2911
- */
2912
- private createView;
2913
- /**
2914
- * Creates all node views.
2915
- */
2916
- createNodeViews(): void;
2917
- /**
2918
- * Prepend class name to element.
2919
- */
2920
- prependClass(): void;
2921
- isCapturingTransaction: boolean;
2922
- private capturedTransaction;
2923
- captureTransaction(fn: Function): Transaction | null;
2924
- /**
2925
- * The callback over which to send transactions (state updates) produced by the view.
2926
- *
2927
- * @param transaction An editor state transaction
2928
- */
2929
- private dispatchTransaction;
2930
- /**
2931
- * Get attributes of the currently selected node or mark.
2932
- */
2933
- getAttributes(nameOrType: string | NodeType | MarkType): Record<string, any>;
2934
- /**
2935
- * Returns if the currently selected node or mark is active.
2936
- *
2937
- * @param name Name of the node or mark
2938
- * @param attributes Attributes of the node or mark
2939
- */
2940
- isActive(name: string, attributes?: {}): boolean;
2941
- isActive(attributes: {}): boolean;
2942
- /**
2943
- * Get the document as JSON.
2944
- */
2945
- getJSON(): JSONContent;
2946
- /**
2947
- * Get the document as HTML.
2948
- */
2949
- getHTML(): string;
2950
- /**
2951
- * Get the document as text.
2952
- */
2953
- getText(options?: {
2954
- blockSeparator?: string;
2955
- textSerializers?: Record<string, TextSerializer>;
2956
- }): string;
2957
- /**
2958
- * Check if there is no content.
2959
- */
2960
- get isEmpty(): boolean;
2961
- /**
2962
- * Get the number of characters for the current document.
2963
- *
2964
- * @deprecated
2965
- */
2966
- getCharacterCount(): number;
2967
- /**
2968
- * Destroy the editor.
2969
- */
2970
- destroy(): void;
2971
- /**
2972
- * Check if the editor is already destroyed.
2973
- */
2974
- get isDestroyed(): boolean;
2975
- $node(selector: string, attributes?: {
2976
- [key: string]: any;
2977
- }): NodePos | null;
2978
- $nodes(selector: string, attributes?: {
2979
- [key: string]: any;
2980
- }): NodePos[] | null;
2981
- $pos(pos: number): NodePos;
2982
- get $doc(): NodePos;
2983
- }
2984
-
2985
- declare class CommandManager {
2986
- editor: Editor;
2987
- rawCommands: AnyCommands;
2988
- customState?: EditorState;
2989
- constructor(props: {
2990
- editor: Editor;
2991
- state?: EditorState;
2992
- });
2993
- get hasCustomState(): boolean;
2994
- get state(): EditorState;
2995
- get commands(): SingleCommands;
2996
- get chain(): () => ChainedCommands;
2997
- get can(): () => CanCommands;
2998
- createChain(startTr?: Transaction, shouldDispatch?: boolean): ChainedCommands;
2999
- createCan(startTr?: Transaction): CanCommands;
3000
- buildProps(tr: Transaction, shouldDispatch?: boolean): CommandProps;
2766
+ declare module '@tiptap/core' {
2767
+ interface Commands<ReturnType> {
2768
+ liftEmptyBlock: {
2769
+ /**
2770
+ * If the cursor is in an empty textblock that can be lifted, lift the block.
2771
+ * @example editor.commands.liftEmptyBlock()
2772
+ */
2773
+ liftEmptyBlock: () => ReturnType;
2774
+ };
2775
+ }
3001
2776
  }
3002
2777
 
3003
- /**
3004
- * Returns a new `Transform` based on all steps of the passed transactions.
3005
- * @param oldDoc The Prosemirror node to start from
3006
- * @param transactions The transactions to combine
3007
- * @returns A new `Transform` with all steps of the passed transactions
3008
- */
3009
- declare function combineTransactionSteps(oldDoc: Node$1, transactions: Transaction[]): Transform;
3010
-
3011
- /**
3012
- * Takes a Transaction & Editor State and turns it into a chainable state object
3013
- * @param config The transaction and state to create the chainable state from
3014
- * @returns A chainable Editor state object
3015
- */
3016
- declare function createChainableState(config: {
3017
- transaction: Transaction;
3018
- state: EditorState;
3019
- }): EditorState;
3020
-
3021
- /**
3022
- * Create a new Prosemirror document node from content.
3023
- * @param content The JSON or HTML content to create the document from
3024
- * @param schema The Prosemirror schema to use for the document
3025
- * @param parseOptions Options for the parser
3026
- * @returns The created Prosemirror document node
3027
- */
3028
- declare function createDocument(content: Content | Node$1 | Fragment, schema: Schema, parseOptions?: ParseOptions, options?: {
3029
- errorOnInvalidContent?: boolean;
3030
- }): Node$1;
3031
-
3032
- type CreateNodeFromContentOptions = {
3033
- slice?: boolean;
3034
- parseOptions?: ParseOptions;
3035
- errorOnInvalidContent?: boolean;
3036
- };
3037
- /**
3038
- * Takes a JSON or HTML content and creates a Prosemirror node or fragment from it.
3039
- * @param content The JSON or HTML content to create the node from
3040
- * @param schema The Prosemirror schema to use for the node
3041
- * @param options Options for the parser
3042
- * @returns The created Prosemirror node or fragment
3043
- */
3044
- declare function createNodeFromContent(content: Content | Node$1 | Fragment, schema: Schema, options?: CreateNodeFromContentOptions): Node$1 | Fragment;
3045
-
3046
- /**
3047
- * Gets the default block type at a given match
3048
- * @param match The content match to get the default block type from
3049
- * @returns The default block type or null
3050
- */
3051
- declare function defaultBlockAt(match: ContentMatch): NodeType | null;
3052
-
3053
- /**
3054
- * Find children inside a Prosemirror node that match a predicate.
3055
- * @param node The Prosemirror node to search in
3056
- * @param predicate The predicate to match
3057
- * @returns An array of nodes with their positions
3058
- */
3059
- declare function findChildren(node: Node$1, predicate: Predicate): NodeWithPos[];
3060
-
3061
- /**
3062
- * Same as `findChildren` but searches only within a `range`.
3063
- * @param node The Prosemirror node to search in
3064
- * @param range The range to search in
3065
- * @param predicate The predicate to match
3066
- * @returns An array of nodes with their positions
3067
- */
3068
- declare function findChildrenInRange(node: Node$1, range: Range, predicate: Predicate): NodeWithPos[];
3069
-
3070
- /**
3071
- * Finds the closest parent node to the current selection that matches a predicate.
3072
- * @param predicate The predicate to match
3073
- * @returns A command that finds the closest parent node to the current selection that matches the predicate
3074
- * @example ```js
3075
- * findParentNode(node => node.type.name === 'paragraph')
3076
- * ```
3077
- */
3078
- declare function findParentNode(predicate: Predicate): (selection: Selection) => {
3079
- pos: number;
3080
- start: number;
3081
- depth: number;
3082
- node: prosemirror_model.Node;
3083
- } | undefined;
3084
-
3085
- /**
3086
- * Finds the closest parent node to a resolved position that matches a predicate.
3087
- * @param $pos The resolved position to search from
3088
- * @param predicate The predicate to match
3089
- * @returns The closest parent node to the resolved position that matches the predicate
3090
- * @example ```js
3091
- * findParentNodeClosestToPos($from, node => node.type.name === 'paragraph')
3092
- * ```
3093
- */
3094
- declare function findParentNodeClosestToPos($pos: ResolvedPos, predicate: Predicate): {
3095
- pos: number;
3096
- start: number;
3097
- depth: number;
3098
- node: Node$1;
3099
- } | undefined;
2778
+ declare module '@tiptap/core' {
2779
+ interface Commands<ReturnType> {
2780
+ liftListItem: {
2781
+ /**
2782
+ * Create a command to lift the list item around the selection up into a wrapping list.
2783
+ * @param typeOrName The type or name of the node.
2784
+ * @example editor.commands.liftListItem('listItem')
2785
+ */
2786
+ liftListItem: (typeOrName: string | NodeType$1) => ReturnType;
2787
+ };
2788
+ }
2789
+ }
3100
2790
 
3101
- /**
3102
- * Generate HTML from a JSONContent
3103
- * @param doc The JSONContent to generate HTML from
3104
- * @param extensions The extensions to use for the schema
3105
- * @returns The generated HTML
3106
- */
3107
- declare function generateHTML(doc: JSONContent, extensions: Extensions): string;
2791
+ declare module '@tiptap/core' {
2792
+ interface Commands<ReturnType> {
2793
+ newlineInCode: {
2794
+ /**
2795
+ * Add a newline character in code.
2796
+ * @example editor.commands.newlineInCode()
2797
+ */
2798
+ newlineInCode: () => ReturnType;
2799
+ };
2800
+ }
2801
+ }
3108
2802
 
3109
- /**
3110
- * Generate JSONContent from HTML
3111
- * @param html The HTML to generate JSONContent from
3112
- * @param extensions The extensions to use for the schema
3113
- * @returns The generated JSONContent
3114
- */
3115
- declare function generateJSON(html: string, extensions: Extensions): Record<string, any>;
2803
+ declare module '@tiptap/core' {
2804
+ interface Commands<ReturnType> {
2805
+ resetAttributes: {
2806
+ /**
2807
+ * Resets some node attributes to the default value.
2808
+ * @param typeOrName The type or name of the node.
2809
+ * @param attributes The attributes of the node to reset.
2810
+ * @example editor.commands.resetAttributes('heading', 'level')
2811
+ */
2812
+ resetAttributes: (typeOrName: string | NodeType$1 | MarkType$1, attributes: string | string[]) => ReturnType;
2813
+ };
2814
+ }
2815
+ }
3116
2816
 
3117
- /**
3118
- * Generate raw text from a JSONContent
3119
- * @param doc The JSONContent to generate text from
3120
- * @param extensions The extensions to use for the schema
3121
- * @param options Options for the text generation f.e. blockSeparator or textSerializers
3122
- * @returns The generated text
3123
- */
3124
- declare function generateText(doc: JSONContent, extensions: Extensions, options?: {
3125
- blockSeparator?: string;
3126
- textSerializers?: Record<string, TextSerializer>;
3127
- }): string;
2817
+ declare module '@tiptap/core' {
2818
+ interface Commands<ReturnType> {
2819
+ scrollIntoView: {
2820
+ /**
2821
+ * Scroll the selection into view.
2822
+ * @example editor.commands.scrollIntoView()
2823
+ */
2824
+ scrollIntoView: () => ReturnType;
2825
+ };
2826
+ }
2827
+ }
3128
2828
 
3129
- /**
3130
- * Get node or mark attributes by type or name on the current editor state
3131
- * @param state The current editor state
3132
- * @param typeOrName The node or mark type or name
3133
- * @returns The attributes of the node or mark or an empty object
3134
- */
3135
- declare function getAttributes(state: EditorState, typeOrName: string | NodeType | MarkType): Record<string, any>;
2829
+ declare module '@tiptap/core' {
2830
+ interface Commands<ReturnType> {
2831
+ selectAll: {
2832
+ /**
2833
+ * Select the whole document.
2834
+ * @example editor.commands.selectAll()
2835
+ */
2836
+ selectAll: () => ReturnType;
2837
+ };
2838
+ }
2839
+ }
3136
2840
 
3137
- /**
3138
- * Get a list of all extension attributes defined in `addAttribute` and `addGlobalAttribute`.
3139
- * @param extensions List of extensions
3140
- */
3141
- declare function getAttributesFromExtensions(extensions: Extensions): ExtensionAttribute[];
2841
+ declare module '@tiptap/core' {
2842
+ interface Commands<ReturnType> {
2843
+ selectNodeBackward: {
2844
+ /**
2845
+ * Select a node backward.
2846
+ * @example editor.commands.selectNodeBackward()
2847
+ */
2848
+ selectNodeBackward: () => ReturnType;
2849
+ };
2850
+ }
2851
+ }
3142
2852
 
3143
- type ChangedRange = {
3144
- oldRange: Range;
3145
- newRange: Range;
3146
- };
3147
- /**
3148
- * Returns a list of changed ranges
3149
- * based on the first and last state of all steps.
3150
- */
3151
- declare function getChangedRanges(transform: Transform): ChangedRange[];
2853
+ declare module '@tiptap/core' {
2854
+ interface Commands<ReturnType> {
2855
+ selectNodeForward: {
2856
+ /**
2857
+ * Select a node forward.
2858
+ * @example editor.commands.selectNodeForward()
2859
+ */
2860
+ selectNodeForward: () => ReturnType;
2861
+ };
2862
+ }
2863
+ }
3152
2864
 
3153
- interface DebugJSONContent extends JSONContent {
3154
- from: number;
3155
- to: number;
2865
+ declare module '@tiptap/core' {
2866
+ interface Commands<ReturnType> {
2867
+ selectParentNode: {
2868
+ /**
2869
+ * Select the parent node.
2870
+ * @example editor.commands.selectParentNode()
2871
+ */
2872
+ selectParentNode: () => ReturnType;
2873
+ };
2874
+ }
3156
2875
  }
3157
- declare function getDebugJSON(node: Node$1, startOffset?: number): DebugJSONContent;
3158
2876
 
3159
- /**
3160
- * Returns a field from an extension
3161
- * @param extension The Tiptap extension
3162
- * @param field The field, for example `renderHTML` or `priority`
3163
- * @param context The context object that should be passed as `this` into the function
3164
- * @returns The field value
3165
- */
3166
- declare function getExtensionField<T = any>(extension: AnyExtension, field: string, context?: Omit<MaybeThisParameterType<T>, 'parent'>): RemoveThis<T>;
2877
+ declare module '@tiptap/core' {
2878
+ interface Commands<ReturnType> {
2879
+ selectTextblockEnd: {
2880
+ /**
2881
+ * Moves the cursor to the end of current text block.
2882
+ * @example editor.commands.selectTextblockEnd()
2883
+ */
2884
+ selectTextblockEnd: () => ReturnType;
2885
+ };
2886
+ }
2887
+ }
3167
2888
 
3168
- declare function getHTMLFromFragment(fragment: Fragment, schema: Schema): string;
2889
+ declare module '@tiptap/core' {
2890
+ interface Commands<ReturnType> {
2891
+ selectTextblockStart: {
2892
+ /**
2893
+ * Moves the cursor to the start of current text block.
2894
+ * @example editor.commands.selectTextblockStart()
2895
+ */
2896
+ selectTextblockStart: () => ReturnType;
2897
+ };
2898
+ }
2899
+ }
2900
+
2901
+ declare module '@tiptap/core' {
2902
+ interface Commands<ReturnType> {
2903
+ setContent: {
2904
+ /**
2905
+ * Replace the whole document with new content.
2906
+ * @param content The new content.
2907
+ * @param emitUpdate Whether to emit an update event.
2908
+ * @param parseOptions Options for parsing the content.
2909
+ * @example editor.commands.setContent('<p>Example text</p>')
2910
+ */
2911
+ setContent: (
2912
+ /**
2913
+ * The new content.
2914
+ */
2915
+ content: Content | Fragment | Node$1,
2916
+ /**
2917
+ * Whether to emit an update event.
2918
+ * @default false
2919
+ */
2920
+ emitUpdate?: boolean,
2921
+ /**
2922
+ * Options for parsing the content.
2923
+ * @default {}
2924
+ */
2925
+ parseOptions?: ParseOptions,
2926
+ /**
2927
+ * Options for `setContent`.
2928
+ */
2929
+ options?: {
2930
+ /**
2931
+ * Whether to throw an error if the content is invalid.
2932
+ */
2933
+ errorOnInvalidContent?: boolean;
2934
+ }) => ReturnType;
2935
+ };
2936
+ }
2937
+ }
3169
2938
 
3170
- declare function getMarkAttributes(state: EditorState, typeOrName: string | MarkType): Record<string, any>;
2939
+ declare module '@tiptap/core' {
2940
+ interface Commands<ReturnType> {
2941
+ setMark: {
2942
+ /**
2943
+ * Add a mark with new attributes.
2944
+ * @param typeOrName The mark type or name.
2945
+ * @example editor.commands.setMark('bold', { level: 1 })
2946
+ */
2947
+ setMark: (typeOrName: string | MarkType$1, attributes?: Record<string, any>) => ReturnType;
2948
+ };
2949
+ }
2950
+ }
3171
2951
 
3172
- /**
3173
- * Get the range of a mark at a resolved position.
3174
- */
3175
- declare function getMarkRange(
3176
- /**
3177
- * The position to get the mark range for.
3178
- */
3179
- $pos: ResolvedPos,
3180
- /**
3181
- * The mark type to get the range for.
3182
- */
3183
- type: MarkType,
3184
- /**
3185
- * The attributes to match against.
3186
- * If not provided, only the first mark at the position will be matched.
3187
- */
3188
- attributes?: Record<string, any>): Range | void;
2952
+ declare module '@tiptap/core' {
2953
+ interface Commands<ReturnType> {
2954
+ setMeta: {
2955
+ /**
2956
+ * Store a metadata property in the current transaction.
2957
+ * @param key The key of the metadata property.
2958
+ * @param value The value to store.
2959
+ * @example editor.commands.setMeta('foo', 'bar')
2960
+ */
2961
+ setMeta: (key: string | Plugin | PluginKey, value: any) => ReturnType;
2962
+ };
2963
+ }
2964
+ }
3189
2965
 
3190
- declare function getMarksBetween(from: number, to: number, doc: Node$1): MarkRange[];
2966
+ declare module '@tiptap/core' {
2967
+ interface Commands<ReturnType> {
2968
+ setNode: {
2969
+ /**
2970
+ * Replace a given range with a node.
2971
+ * @param typeOrName The type or name of the node
2972
+ * @param attributes The attributes of the node
2973
+ * @example editor.commands.setNode('paragraph')
2974
+ */
2975
+ setNode: (typeOrName: string | NodeType$1, attributes?: Record<string, any>) => ReturnType;
2976
+ };
2977
+ }
2978
+ }
3191
2979
 
3192
- declare function getMarkType(nameOrType: string | MarkType, schema: Schema): MarkType;
2980
+ declare module '@tiptap/core' {
2981
+ interface Commands<ReturnType> {
2982
+ setNodeSelection: {
2983
+ /**
2984
+ * Creates a NodeSelection.
2985
+ * @param position - Position of the node.
2986
+ * @example editor.commands.setNodeSelection(10)
2987
+ */
2988
+ setNodeSelection: (position: number) => ReturnType;
2989
+ };
2990
+ }
2991
+ }
3193
2992
 
3194
- /**
3195
- * Finds the first node of a given type or name in the current selection.
3196
- * @param state The editor state.
3197
- * @param typeOrName The node type or name.
3198
- * @param pos The position to start searching from.
3199
- * @param maxDepth The maximum depth to search.
3200
- * @returns The node and the depth as an array.
3201
- */
3202
- declare const getNodeAtPosition: (state: EditorState, typeOrName: string | NodeType, pos: number, maxDepth?: number) => [Node$1 | null, number];
2993
+ declare module '@tiptap/core' {
2994
+ interface Commands<ReturnType> {
2995
+ setTextSelection: {
2996
+ /**
2997
+ * Creates a TextSelection.
2998
+ * @param position The position of the selection.
2999
+ * @example editor.commands.setTextSelection(10)
3000
+ */
3001
+ setTextSelection: (position: number | Range) => ReturnType;
3002
+ };
3003
+ }
3004
+ }
3203
3005
 
3204
- declare function getNodeAttributes(state: EditorState, typeOrName: string | NodeType): Record<string, any>;
3006
+ declare module '@tiptap/core' {
3007
+ interface Commands<ReturnType> {
3008
+ sinkListItem: {
3009
+ /**
3010
+ * Sink the list item down into an inner list.
3011
+ * @param typeOrName The type or name of the node.
3012
+ * @example editor.commands.sinkListItem('listItem')
3013
+ */
3014
+ sinkListItem: (typeOrName: string | NodeType$1) => ReturnType;
3015
+ };
3016
+ }
3017
+ }
3205
3018
 
3206
- declare function getNodeType(nameOrType: string | NodeType, schema: Schema): NodeType;
3019
+ declare module '@tiptap/core' {
3020
+ interface Commands<ReturnType> {
3021
+ splitBlock: {
3022
+ /**
3023
+ * Forks a new node from an existing node.
3024
+ * @param options.keepMarks Keep marks from the previous node.
3025
+ * @example editor.commands.splitBlock()
3026
+ * @example editor.commands.splitBlock({ keepMarks: true })
3027
+ */
3028
+ splitBlock: (options?: {
3029
+ keepMarks?: boolean;
3030
+ }) => ReturnType;
3031
+ };
3032
+ }
3033
+ }
3207
3034
 
3208
- declare function getRenderedAttributes(nodeOrMark: Node$1 | Mark$1, extensionAttributes: ExtensionAttribute[]): Record<string, any>;
3035
+ declare module '@tiptap/core' {
3036
+ interface Commands<ReturnType> {
3037
+ splitListItem: {
3038
+ /**
3039
+ * Splits one list item into two list items.
3040
+ * @param typeOrName The type or name of the node.
3041
+ * @param overrideAttrs The attributes to ensure on the new node.
3042
+ * @example editor.commands.splitListItem('listItem')
3043
+ */
3044
+ splitListItem: (typeOrName: string | NodeType$1, overrideAttrs?: Record<string, any>) => ReturnType;
3045
+ };
3046
+ }
3047
+ }
3209
3048
 
3210
- declare function getSchema(extensions: Extensions, editor?: Editor): Schema;
3049
+ declare module '@tiptap/core' {
3050
+ interface Commands<ReturnType> {
3051
+ toggleList: {
3052
+ /**
3053
+ * Toggle between different list types.
3054
+ * @param listTypeOrName The type or name of the list.
3055
+ * @param itemTypeOrName The type or name of the list item.
3056
+ * @param keepMarks Keep marks when toggling.
3057
+ * @param attributes Attributes for the new list.
3058
+ * @example editor.commands.toggleList('bulletList', 'listItem')
3059
+ */
3060
+ toggleList: (listTypeOrName: string | NodeType$1, itemTypeOrName: string | NodeType$1, keepMarks?: boolean, attributes?: Record<string, any>) => ReturnType;
3061
+ };
3062
+ }
3063
+ }
3211
3064
 
3212
- /**
3213
- * Creates a new Prosemirror schema based on the given extensions.
3214
- * @param extensions An array of Tiptap extensions
3215
- * @param editor The editor instance
3216
- * @returns A Prosemirror schema
3217
- */
3218
- declare function getSchemaByResolvedExtensions(extensions: Extensions, editor?: Editor): Schema;
3065
+ declare module '@tiptap/core' {
3066
+ interface Commands<ReturnType> {
3067
+ toggleMark: {
3068
+ /**
3069
+ * Toggle a mark on and off.
3070
+ * @param typeOrName The mark type or name.
3071
+ * @param attributes The attributes of the mark.
3072
+ * @param options.extendEmptyMarkRange Removes the mark even across the current selection. Defaults to `false`.
3073
+ * @example editor.commands.toggleMark('bold')
3074
+ */
3075
+ toggleMark: (
3076
+ /**
3077
+ * The mark type or name.
3078
+ */
3079
+ typeOrName: string | MarkType$1,
3080
+ /**
3081
+ * The attributes of the mark.
3082
+ */
3083
+ attributes?: Record<string, any>, options?: {
3084
+ /**
3085
+ * Removes the mark even across the current selection. Defaults to `false`.
3086
+ */
3087
+ extendEmptyMarkRange?: boolean;
3088
+ }) => ReturnType;
3089
+ };
3090
+ }
3091
+ }
3219
3092
 
3220
- /**
3221
- * Tries to get a node or mark type by its name.
3222
- * @param name The name of the node or mark type
3223
- * @param schema The Prosemiror schema to search in
3224
- * @returns The node or mark type, or null if it doesn't exist
3225
- */
3226
- declare function getSchemaTypeByName(name: string, schema: Schema): NodeType | MarkType | null;
3093
+ declare module '@tiptap/core' {
3094
+ interface Commands<ReturnType> {
3095
+ toggleNode: {
3096
+ /**
3097
+ * Toggle a node with another node.
3098
+ * @param typeOrName The type or name of the node.
3099
+ * @param toggleTypeOrName The type or name of the node to toggle.
3100
+ * @param attributes The attributes of the node.
3101
+ * @example editor.commands.toggleNode('heading', 'paragraph')
3102
+ */
3103
+ toggleNode: (typeOrName: string | NodeType$1, toggleTypeOrName: string | NodeType$1, attributes?: Record<string, any>) => ReturnType;
3104
+ };
3105
+ }
3106
+ }
3227
3107
 
3228
- /**
3229
- * Get the type of a schema item by its name.
3230
- * @param name The name of the schema item
3231
- * @param schema The Prosemiror schema to search in
3232
- * @returns The type of the schema item (`node` or `mark`), or null if it doesn't exist
3233
- */
3234
- declare function getSchemaTypeNameByName(name: string, schema: Schema): 'node' | 'mark' | null;
3108
+ declare module '@tiptap/core' {
3109
+ interface Commands<ReturnType> {
3110
+ toggleWrap: {
3111
+ /**
3112
+ * Wraps nodes in another node, or removes an existing wrap.
3113
+ * @param typeOrName The type or name of the node.
3114
+ * @param attributes The attributes of the node.
3115
+ * @example editor.commands.toggleWrap('blockquote')
3116
+ */
3117
+ toggleWrap: (typeOrName: string | NodeType$1, attributes?: Record<string, any>) => ReturnType;
3118
+ };
3119
+ }
3120
+ }
3235
3121
 
3236
- /**
3237
- * Return attributes of an extension that should be splitted by keepOnSplit flag
3238
- * @param extensionAttributes Array of extension attributes
3239
- * @param typeName The type of the extension
3240
- * @param attributes The attributes of the extension
3241
- * @returns The splitted attributes
3242
- */
3243
- declare function getSplittedAttributes(extensionAttributes: ExtensionAttribute[], typeName: string, attributes: Record<string, any>): Record<string, any>;
3122
+ declare module '@tiptap/core' {
3123
+ interface Commands<ReturnType> {
3124
+ undoInputRule: {
3125
+ /**
3126
+ * Undo an input rule.
3127
+ * @example editor.commands.undoInputRule()
3128
+ */
3129
+ undoInputRule: () => ReturnType;
3130
+ };
3131
+ }
3132
+ }
3244
3133
 
3245
- /**
3246
- * Gets the text of a Prosemirror node
3247
- * @param node The Prosemirror node
3248
- * @param options Options for the text serializer & block separator
3249
- * @returns The text of the node
3250
- * @example ```js
3251
- * const text = getText(node, { blockSeparator: '\n' })
3252
- * ```
3253
- */
3254
- declare function getText(node: Node$1, options?: {
3255
- blockSeparator?: string;
3256
- textSerializers?: Record<string, TextSerializer>;
3257
- }): string;
3134
+ declare module '@tiptap/core' {
3135
+ interface Commands<ReturnType> {
3136
+ unsetAllMarks: {
3137
+ /**
3138
+ * Remove all marks in the current selection.
3139
+ * @example editor.commands.unsetAllMarks()
3140
+ */
3141
+ unsetAllMarks: () => ReturnType;
3142
+ };
3143
+ }
3144
+ }
3258
3145
 
3259
- /**
3260
- * Gets the text between two positions in a Prosemirror node
3261
- * and serializes it using the given text serializers and block separator (see getText)
3262
- * @param startNode The Prosemirror node to start from
3263
- * @param range The range of the text to get
3264
- * @param options Options for the text serializer & block separator
3265
- * @returns The text between the two positions
3266
- */
3267
- declare function getTextBetween(startNode: Node$1, range: Range, options?: {
3268
- blockSeparator?: string;
3269
- textSerializers?: Record<string, TextSerializer>;
3270
- }): string;
3146
+ declare module '@tiptap/core' {
3147
+ interface Commands<ReturnType> {
3148
+ unsetMark: {
3149
+ /**
3150
+ * Remove all marks in the current selection.
3151
+ * @param typeOrName The mark type or name.
3152
+ * @param options.extendEmptyMarkRange Removes the mark even across the current selection. Defaults to `false`.
3153
+ * @example editor.commands.unsetMark('bold')
3154
+ */
3155
+ unsetMark: (
3156
+ /**
3157
+ * The mark type or name.
3158
+ */
3159
+ typeOrName: string | MarkType$1, options?: {
3160
+ /**
3161
+ * Removes the mark even across the current selection. Defaults to `false`.
3162
+ */
3163
+ extendEmptyMarkRange?: boolean;
3164
+ }) => ReturnType;
3165
+ };
3166
+ }
3167
+ }
3271
3168
 
3272
- /**
3273
- * Returns the text content of a resolved prosemirror position
3274
- * @param $from The resolved position to get the text content from
3275
- * @param maxMatch The maximum number of characters to match
3276
- * @returns The text content
3277
- */
3278
- declare const getTextContentFromNodes: ($from: ResolvedPos, maxMatch?: number) => string;
3169
+ declare module '@tiptap/core' {
3170
+ interface Commands<ReturnType> {
3171
+ updateAttributes: {
3172
+ /**
3173
+ * Update attributes of a node or mark.
3174
+ * @param typeOrName The type or name of the node or mark.
3175
+ * @param attributes The attributes of the node or mark.
3176
+ * @example editor.commands.updateAttributes('mention', { userId: "2" })
3177
+ */
3178
+ updateAttributes: (
3179
+ /**
3180
+ * The type or name of the node or mark.
3181
+ */
3182
+ typeOrName: string | NodeType$1 | MarkType$1,
3183
+ /**
3184
+ * The attributes of the node or mark.
3185
+ */
3186
+ attributes: Record<string, any>) => ReturnType;
3187
+ };
3188
+ }
3189
+ }
3279
3190
 
3280
- /**
3281
- * Find text serializers `toText` in a Prosemirror schema
3282
- * @param schema The Prosemirror schema to search in
3283
- * @returns A record of text serializers by node name
3284
- */
3285
- declare function getTextSerializersFromSchema(schema: Schema): Record<string, TextSerializer>;
3191
+ declare module '@tiptap/core' {
3192
+ interface Commands<ReturnType> {
3193
+ wrapIn: {
3194
+ /**
3195
+ * Wraps nodes in another node.
3196
+ * @param typeOrName The type or name of the node.
3197
+ * @param attributes The attributes of the node.
3198
+ * @example editor.commands.wrapIn('blockquote')
3199
+ */
3200
+ wrapIn: (typeOrName: string | NodeType$1, attributes?: Record<string, any>) => ReturnType;
3201
+ };
3202
+ }
3203
+ }
3286
3204
 
3287
- /**
3288
- * This function merges extension attributes into parserule attributes (`attrs` or `getAttrs`).
3289
- * Cancels when `getAttrs` returned `false`.
3290
- * @param parseRule ProseMirror ParseRule
3291
- * @param extensionAttributes List of attributes to inject
3292
- */
3293
- declare function injectExtensionAttributesToParseRule(parseRule: ParseRule, extensionAttributes: ExtensionAttribute[]): ParseRule;
3205
+ declare module '@tiptap/core' {
3206
+ interface Commands<ReturnType> {
3207
+ wrapInList: {
3208
+ /**
3209
+ * Wrap a node in a list.
3210
+ * @param typeOrName The type or name of the node.
3211
+ * @param attributes The attributes of the node.
3212
+ * @example editor.commands.wrapInList('bulletList')
3213
+ */
3214
+ wrapInList: (typeOrName: string | NodeType$1, attributes?: Record<string, any>) => ReturnType;
3215
+ };
3216
+ }
3217
+ }
3294
3218
 
3295
- declare function isActive(state: EditorState, name: string | null, attributes?: Record<string, any>): boolean;
3219
+ declare const Commands$1: Extension<any, any>;
3296
3220
 
3297
- declare const isAtEndOfNode: (state: EditorState, nodeType?: string) => boolean;
3221
+ declare const Drop: Extension<any, any>;
3298
3222
 
3299
- declare const isAtStartOfNode: (state: EditorState) => boolean;
3223
+ declare const Editable: Extension<any, any>;
3300
3224
 
3301
- declare function isExtensionRulesEnabled(extension: AnyExtension, enabled: EnableRules): boolean;
3225
+ declare const FocusEvents: Extension<any, any>;
3302
3226
 
3303
- declare function isList(name: string, extensions: Extensions): boolean;
3227
+ declare const Keymap: Extension<any, any>;
3304
3228
 
3305
- declare function isMarkActive(state: EditorState, typeOrName: MarkType | string | null, attributes?: Record<string, any>): boolean;
3229
+ declare const Paste: Extension<any, any>;
3306
3230
 
3307
- declare function isNodeActive(state: EditorState, typeOrName: NodeType | string | null, attributes?: Record<string, any>): boolean;
3231
+ declare const Tabindex: Extension<any, any>;
3308
3232
 
3309
- /**
3310
- * Returns true if the given prosemirror node is empty.
3311
- */
3312
- declare function isNodeEmpty(node: Node$1, { checkChildren, ignoreWhitespace, }?: {
3233
+ declare const index_ClipboardTextSerializer: typeof ClipboardTextSerializer;
3234
+ declare const index_Drop: typeof Drop;
3235
+ declare const index_Editable: typeof Editable;
3236
+ declare const index_FocusEvents: typeof FocusEvents;
3237
+ declare const index_Keymap: typeof Keymap;
3238
+ declare const index_Paste: typeof Paste;
3239
+ declare const index_Tabindex: typeof Tabindex;
3240
+ declare namespace index {
3241
+ export { index_ClipboardTextSerializer as ClipboardTextSerializer, Commands$1 as Commands, index_Drop as Drop, index_Editable as Editable, index_FocusEvents as FocusEvents, index_Keymap as Keymap, index_Paste as Paste, index_Tabindex as Tabindex };
3242
+ }
3243
+
3244
+ interface TiptapEditorHTMLElement extends HTMLElement {
3245
+ editor?: Editor;
3246
+ }
3247
+ declare class Editor extends EventEmitter<EditorEvents> {
3248
+ private commandManager;
3249
+ extensionManager: ExtensionManager;
3250
+ private css;
3251
+ schema: Schema;
3252
+ view: EditorView;
3253
+ isFocused: boolean;
3313
3254
  /**
3314
- * When true (default), it will also check if all children are empty.
3255
+ * The editor is considered initialized after the `create` event has been emitted.
3315
3256
  */
3316
- checkChildren?: boolean;
3257
+ isInitialized: boolean;
3258
+ extensionStorage: Record<string, any>;
3317
3259
  /**
3318
- * When true, it will ignore whitespace when checking for emptiness.
3260
+ * A unique ID for this editor instance.
3319
3261
  */
3320
- ignoreWhitespace?: boolean;
3321
- }): boolean;
3322
-
3323
- declare function isNodeSelection(value: unknown): value is NodeSelection;
3324
-
3325
- declare function isTextSelection(value: unknown): value is TextSelection;
3326
-
3327
- declare function posToDOMRect(view: EditorView, from: number, to: number): DOMRect;
3328
-
3329
- declare function resolveFocusPosition(doc: Node$1, position?: FocusPosition): Selection | null;
3330
-
3331
- declare function selectionToInsertionEnd(tr: Transaction, startLen: number, bias: number): void;
3262
+ instanceId: string;
3263
+ options: EditorOptions;
3264
+ constructor(options?: Partial<EditorOptions>);
3265
+ /**
3266
+ * Returns the editor storage.
3267
+ */
3268
+ get storage(): Record<string, any>;
3269
+ /**
3270
+ * An object of all registered commands.
3271
+ */
3272
+ get commands(): SingleCommands;
3273
+ /**
3274
+ * Create a command chain to call multiple commands at once.
3275
+ */
3276
+ chain(): ChainedCommands;
3277
+ /**
3278
+ * Check if a command or a command chain can be executed. Without executing it.
3279
+ */
3280
+ can(): CanCommands;
3281
+ /**
3282
+ * Inject CSS styles.
3283
+ */
3284
+ private injectCSS;
3285
+ /**
3286
+ * Update editor options.
3287
+ *
3288
+ * @param options A list of options
3289
+ */
3290
+ setOptions(options?: Partial<EditorOptions>): void;
3291
+ /**
3292
+ * Update editable state of the editor.
3293
+ */
3294
+ setEditable(editable: boolean, emitUpdate?: boolean): void;
3295
+ /**
3296
+ * Returns whether the editor is editable.
3297
+ */
3298
+ get isEditable(): boolean;
3299
+ /**
3300
+ * Returns the editor state.
3301
+ */
3302
+ get state(): EditorState;
3303
+ /**
3304
+ * Register a ProseMirror plugin.
3305
+ *
3306
+ * @param plugin A ProseMirror plugin
3307
+ * @param handlePlugins Control how to merge the plugin into the existing plugins.
3308
+ * @returns The new editor state
3309
+ */
3310
+ registerPlugin(plugin: Plugin, handlePlugins?: (newPlugin: Plugin, plugins: Plugin[]) => Plugin[]): EditorState;
3311
+ /**
3312
+ * Unregister a ProseMirror plugin.
3313
+ *
3314
+ * @param nameOrPluginKeyToRemove The plugins name
3315
+ * @returns The new editor state or undefined if the editor is destroyed
3316
+ */
3317
+ unregisterPlugin(nameOrPluginKeyToRemove: string | PluginKey | (string | PluginKey)[]): EditorState | undefined;
3318
+ /**
3319
+ * Creates an extension manager.
3320
+ */
3321
+ private createExtensionManager;
3322
+ /**
3323
+ * Creates an command manager.
3324
+ */
3325
+ private createCommandManager;
3326
+ /**
3327
+ * Creates a ProseMirror schema.
3328
+ */
3329
+ private createSchema;
3330
+ /**
3331
+ * Creates a ProseMirror view.
3332
+ */
3333
+ private createView;
3334
+ /**
3335
+ * Creates all node views.
3336
+ */
3337
+ createNodeViews(): void;
3338
+ /**
3339
+ * Prepend class name to element.
3340
+ */
3341
+ prependClass(): void;
3342
+ isCapturingTransaction: boolean;
3343
+ private capturedTransaction;
3344
+ captureTransaction(fn: () => void): Transaction | null;
3345
+ /**
3346
+ * The callback over which to send transactions (state updates) produced by the view.
3347
+ *
3348
+ * @param transaction An editor state transaction
3349
+ */
3350
+ private dispatchTransaction;
3351
+ /**
3352
+ * Get attributes of the currently selected node or mark.
3353
+ */
3354
+ getAttributes(nameOrType: string | NodeType$1 | MarkType$1): Record<string, any>;
3355
+ /**
3356
+ * Returns if the currently selected node or mark is active.
3357
+ *
3358
+ * @param name Name of the node or mark
3359
+ * @param attributes Attributes of the node or mark
3360
+ */
3361
+ isActive(name: string, attributes?: {}): boolean;
3362
+ isActive(attributes: {}): boolean;
3363
+ /**
3364
+ * Get the document as JSON.
3365
+ */
3366
+ getJSON(): DocumentType<Record<string, any> | undefined, NodeType<string, undefined | Record<string, any>, any, (NodeType | TextType)[]>[]>;
3367
+ /**
3368
+ * Get the document as HTML.
3369
+ */
3370
+ getHTML(): string;
3371
+ /**
3372
+ * Get the document as text.
3373
+ */
3374
+ getText(options?: {
3375
+ blockSeparator?: string;
3376
+ textSerializers?: Record<string, TextSerializer>;
3377
+ }): string;
3378
+ /**
3379
+ * Check if there is no content.
3380
+ */
3381
+ get isEmpty(): boolean;
3382
+ /**
3383
+ * Destroy the editor.
3384
+ */
3385
+ destroy(): void;
3386
+ /**
3387
+ * Check if the editor is already destroyed.
3388
+ */
3389
+ get isDestroyed(): boolean;
3390
+ $node(selector: string, attributes?: {
3391
+ [key: string]: any;
3392
+ }): NodePos | null;
3393
+ $nodes(selector: string, attributes?: {
3394
+ [key: string]: any;
3395
+ }): NodePos[] | null;
3396
+ $pos(pos: number): NodePos;
3397
+ get $doc(): NodePos;
3398
+ }
3332
3399
 
3333
- declare function splitExtensions(extensions: Extensions): {
3334
- baseExtensions: Extension<any, any>[];
3335
- nodeExtensions: Node<any, any>[];
3336
- markExtensions: Mark<any, any>[];
3337
- };
3400
+ declare class CommandManager {
3401
+ editor: Editor;
3402
+ rawCommands: AnyCommands;
3403
+ customState?: EditorState;
3404
+ constructor(props: {
3405
+ editor: Editor;
3406
+ state?: EditorState;
3407
+ });
3408
+ get hasCustomState(): boolean;
3409
+ get state(): EditorState;
3410
+ get commands(): SingleCommands;
3411
+ get chain(): () => ChainedCommands;
3412
+ get can(): () => CanCommands;
3413
+ createChain(startTr?: Transaction, shouldDispatch?: boolean): ChainedCommands;
3414
+ createCan(startTr?: Transaction): CanCommands;
3415
+ buildProps(tr: Transaction, shouldDispatch?: boolean): CommandProps;
3416
+ }
3338
3417
 
3339
3418
  /**
3340
3419
  * Build an input rule that adds a mark when the
@@ -3343,7 +3422,7 @@ declare function splitExtensions(extensions: Extensions): {
3343
3422
  */
3344
3423
  declare function markInputRule(config: {
3345
3424
  find: InputRuleFinder;
3346
- type: MarkType;
3425
+ type: MarkType$1;
3347
3426
  getAttributes?: Record<string, any> | ((match: ExtendedRegExpMatchArray) => Record<string, any>) | false | null;
3348
3427
  }): InputRule;
3349
3428
 
@@ -3360,7 +3439,7 @@ declare function nodeInputRule(config: {
3360
3439
  /**
3361
3440
  * The node type to add.
3362
3441
  */
3363
- type: NodeType;
3442
+ type: NodeType$1;
3364
3443
  /**
3365
3444
  * A function that returns the attributes for the node
3366
3445
  * can also be an object of attributes
@@ -3377,7 +3456,7 @@ declare function nodeInputRule(config: {
3377
3456
  */
3378
3457
  declare function textblockTypeInputRule(config: {
3379
3458
  find: InputRuleFinder;
3380
- type: NodeType;
3459
+ type: NodeType$1;
3381
3460
  getAttributes?: Record<string, any> | ((match: ExtendedRegExpMatchArray) => Record<string, any>) | false | null;
3382
3461
  }): InputRule;
3383
3462
 
@@ -3408,7 +3487,7 @@ declare function textInputRule(config: {
3408
3487
  */
3409
3488
  declare function wrappingInputRule(config: {
3410
3489
  find: InputRuleFinder;
3411
- type: NodeType;
3490
+ type: NodeType$1;
3412
3491
  keepMarks?: boolean;
3413
3492
  keepAttributes?: boolean;
3414
3493
  editor?: Editor;
@@ -3461,7 +3540,7 @@ declare class NodeView<Component, NodeEditor extends Editor = Editor, Options ex
3461
3540
  */
3462
3541
  declare function markPasteRule(config: {
3463
3542
  find: PasteRuleFinder;
3464
- type: MarkType;
3543
+ type: MarkType$1;
3465
3544
  getAttributes?: Record<string, any> | ((match: ExtendedRegExpMatchArray, event: ClipboardEvent) => Record<string, any>) | false | null;
3466
3545
  }): PasteRule;
3467
3546
 
@@ -3472,7 +3551,7 @@ declare function markPasteRule(config: {
3472
3551
  */
3473
3552
  declare function nodePasteRule(config: {
3474
3553
  find: PasteRuleFinder;
3475
- type: NodeType;
3554
+ type: NodeType$1;
3476
3555
  getAttributes?: Record<string, any> | ((match: ExtendedRegExpMatchArray, event: ClipboardEvent) => Record<string, any>) | false | null;
3477
3556
  getContent?: JSONContent[] | ((attrs: Record<string, any>) => JSONContent[]) | false | null;
3478
3557
  }): PasteRule;
@@ -3520,7 +3599,10 @@ declare function elementFromString(value: string): HTMLElement;
3520
3599
 
3521
3600
  declare function escapeForRegEx(string: string): string;
3522
3601
 
3523
- declare function findDuplicates(items: any[]): any[];
3602
+ /**
3603
+ * Find duplicates in an array.
3604
+ */
3605
+ declare function findDuplicates<T>(items: T[]): T[];
3524
3606
 
3525
3607
  declare function fromString(value: any): any;
3526
3608
 
@@ -3573,4 +3655,4 @@ interface NodeConfig<Options = any, Storage = any> {
3573
3655
  interface MarkConfig<Options = any, Storage = any> {
3574
3656
  }
3575
3657
 
3576
- export { type AnyCommands, type AnyConfig, type AnyExtension, type Attribute, type Attributes, type CanCommands, type ChainedCommands, type ChangedRange, type Command, CommandManager, type CommandProps, type CommandSpec, type Commands, type Content, type CreateNodeFromContentOptions, type DOMNode, type DecorationType, type DecorationWithType, type Diff, type Dispatch, Editor, type EditorEvents, type EditorOptions, type EnableRules, type ExtendedRegExpMatchArray, Extension, type ExtensionAttribute, type ExtensionConfig, type Extensions, type FocusPosition, type GlobalAttributes, type HTMLContent, InputRule, type InputRuleFinder, type InputRuleMatch, type JSONContent, type KeyboardShortcutCommand, type KeysWithTypeOf, Mark, type MarkConfig, type MarkRange, type MaybeReturnType, type MaybeThisParameterType, Node, type NodeConfig, NodePos, type NodeRange, NodeView, type NodeViewProps, type NodeViewRenderer, type NodeViewRendererOptions, type NodeViewRendererProps, type NodeWithPos, type Overwrite, type ParentConfig, PasteRule, type PasteRuleFinder, type PasteRuleMatch, type PickValue, type Predicate, type Primitive, type Range, type RawCommands, type RemoveThis, type SingleCommands, type TextSerializer, type TiptapEditorHTMLElement, Tracker, type TrackerResult, type UnionCommands, type UnionToIntersection, type ValuesOf, callOrReturn, combineTransactionSteps, createChainableState, createDocument, createNodeFromContent, createStyleTag, defaultBlockAt, deleteProps, elementFromString, escapeForRegEx, index as extensions, findChildren, findChildrenInRange, findDuplicates, findParentNode, findParentNodeClosestToPos, fromString, generateHTML, generateJSON, generateText, getAttributes, getAttributesFromExtensions, getChangedRanges, getDebugJSON, getExtensionField, getHTMLFromFragment, getMarkAttributes, getMarkRange, getMarkType, getMarksBetween, getNodeAtPosition, getNodeAttributes, getNodeType, getRenderedAttributes, getSchema, getSchemaByResolvedExtensions, getSchemaTypeByName, getSchemaTypeNameByName, getSplittedAttributes, getText, getTextBetween, getTextContentFromNodes, getTextSerializersFromSchema, injectExtensionAttributesToParseRule, inputRulesPlugin, isActive, isAtEndOfNode, isAtStartOfNode, isEmptyObject, isExtensionRulesEnabled, isFunction, isList, isMacOS, isMarkActive, isNodeActive, isNodeEmpty, isNodeSelection, isNumber, isPlainObject, isRegExp, isString, isTextSelection, isiOS, markInputRule, markPasteRule, mergeAttributes, mergeDeep, minMax, nodeInputRule, nodePasteRule, objectIncludes, pasteRulesPlugin, posToDOMRect, removeDuplicates, resolveFocusPosition, selectionToInsertionEnd, splitExtensions, textInputRule, textPasteRule, textblockTypeInputRule, wrappingInputRule };
3658
+ export { type AnyCommands, type AnyConfig, type AnyExtension, type Attribute, type Attributes, type CanCommands, type ChainedCommands, type ChangedRange, type Command, CommandManager, type CommandProps, type CommandSpec, type Commands, type Content, type CreateNodeFromContentOptions, type DOMNode, type DOMOutputSpecArray, type DecorationType, type DecorationWithType, type Diff, type Dispatch, type DocumentType, Editor, type EditorEvents, type EditorOptions, type EnableRules, type ExtendedRegExpMatchArray, Extension, type ExtensionAttribute, type ExtensionConfig, type Extensions, type FocusPosition, type GlobalAttributes, type HTMLContent, InputRule, type InputRuleFinder, type InputRuleMatch, type JSONContent, type KeyboardShortcutCommand, type KeysWithTypeOf, Mark, type MarkConfig, type MarkRange, type MarkType, type MaybeReturnType, type MaybeThisParameterType, Node, type NodeConfig, NodePos, type NodeRange, type NodeType, NodeView, type NodeViewProps, type NodeViewRenderer, type NodeViewRendererOptions, type NodeViewRendererProps, type NodeWithPos, type Overwrite, type ParentConfig, PasteRule, type PasteRuleFinder, type PasteRuleMatch, type PickValue, type Predicate, type Primitive, type Range, type RawCommands, type RemoveThis, type SingleCommands, type TextSerializer, type TextType, type TiptapEditorHTMLElement, Tracker, type TrackerResult, type UnionCommands, type UnionToIntersection, type ValuesOf, callOrReturn, combineTransactionSteps, createChainableState, createDocument, createNodeFromContent, createStyleTag, defaultBlockAt, deleteProps, elementFromString, escapeForRegEx, index as extensions, findChildren, findChildrenInRange, findDuplicates, findParentNode, findParentNodeClosestToPos, flattenExtensions, fromString, generateHTML, generateJSON, generateText, getAttributes, getAttributesFromExtensions, getChangedRanges, getDebugJSON, getExtensionField, getHTMLFromFragment, getMarkAttributes, getMarkRange, getMarkType, getMarksBetween, getNodeAtPosition, getNodeAttributes, getNodeType, getRenderedAttributes, getSchema, getSchemaByResolvedExtensions, getSchemaTypeByName, getSchemaTypeNameByName, getSplittedAttributes, getText, getTextBetween, getTextContentFromNodes, getTextSerializersFromSchema, injectExtensionAttributesToParseRule, inputRulesPlugin, isActive, isAtEndOfNode, isAtStartOfNode, isEmptyObject, isExtensionRulesEnabled, isFunction, isList, isMacOS, isMarkActive, isNodeActive, isNodeEmpty, isNodeSelection, isNumber, isPlainObject, isRegExp, isString, isTextSelection, isiOS, markInputRule, markPasteRule, mergeAttributes, mergeDeep, minMax, nodeInputRule, nodePasteRule, objectIncludes, pasteRulesPlugin, posToDOMRect, removeDuplicates, resolveExtensions, resolveFocusPosition, rewriteUnknownContent, selectionToInsertionEnd, sortExtensions, splitExtensions, textInputRule, textPasteRule, textblockTypeInputRule, wrappingInputRule };