@tiptap/core 2.3.1 → 2.4.0

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 (185) hide show
  1. package/dist/index.cjs +290 -79
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.js +290 -79
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.umd.js +290 -79
  6. package/dist/index.umd.js.map +1 -1
  7. package/dist/packages/core/src/Extension.d.ts +129 -14
  8. package/dist/packages/core/src/ExtensionManager.d.ts +37 -0
  9. package/dist/packages/core/src/Mark.d.ts +129 -14
  10. package/dist/packages/core/src/Node.d.ts +226 -30
  11. package/dist/packages/core/src/NodeView.d.ts +4 -0
  12. package/dist/packages/core/src/PasteRule.d.ts +4 -0
  13. package/dist/packages/core/src/commands/blur.d.ts +1 -0
  14. package/dist/packages/core/src/commands/clearContent.d.ts +2 -0
  15. package/dist/packages/core/src/commands/clearNodes.d.ts +1 -0
  16. package/dist/packages/core/src/commands/command.d.ts +6 -0
  17. package/dist/packages/core/src/commands/createParagraphNear.d.ts +1 -0
  18. package/dist/packages/core/src/commands/cut.d.ts +5 -0
  19. package/dist/packages/core/src/commands/deleteCurrentNode.d.ts +1 -0
  20. package/dist/packages/core/src/commands/deleteNode.d.ts +3 -1
  21. package/dist/packages/core/src/commands/deleteRange.d.ts +2 -0
  22. package/dist/packages/core/src/commands/deleteSelection.d.ts +1 -0
  23. package/dist/packages/core/src/commands/enter.d.ts +1 -0
  24. package/dist/packages/core/src/commands/exitCode.d.ts +1 -0
  25. package/dist/packages/core/src/commands/extendMarkRange.d.ts +14 -2
  26. package/dist/packages/core/src/commands/first.d.ts +2 -0
  27. package/dist/packages/core/src/commands/focus.d.ts +14 -1
  28. package/dist/packages/core/src/commands/insertContent.d.ts +17 -1
  29. package/dist/packages/core/src/commands/insertContentAt.d.ts +20 -1
  30. package/dist/packages/core/src/commands/join.d.ts +12 -4
  31. package/dist/packages/core/src/commands/joinItemBackward.d.ts +2 -1
  32. package/dist/packages/core/src/commands/joinItemForward.d.ts +2 -1
  33. package/dist/packages/core/src/commands/keyboardShortcut.d.ts +2 -0
  34. package/dist/packages/core/src/commands/lift.d.ts +5 -1
  35. package/dist/packages/core/src/commands/liftEmptyBlock.d.ts +2 -1
  36. package/dist/packages/core/src/commands/liftListItem.d.ts +3 -1
  37. package/dist/packages/core/src/commands/newlineInCode.d.ts +1 -0
  38. package/dist/packages/core/src/commands/resetAttributes.d.ts +3 -0
  39. package/dist/packages/core/src/commands/scrollIntoView.d.ts +1 -0
  40. package/dist/packages/core/src/commands/selectAll.d.ts +1 -0
  41. package/dist/packages/core/src/commands/selectNodeBackward.d.ts +1 -0
  42. package/dist/packages/core/src/commands/selectNodeForward.d.ts +1 -0
  43. package/dist/packages/core/src/commands/selectParentNode.d.ts +1 -0
  44. package/dist/packages/core/src/commands/selectTextblockEnd.d.ts +1 -0
  45. package/dist/packages/core/src/commands/selectTextblockStart.d.ts +1 -0
  46. package/dist/packages/core/src/commands/setContent.d.ts +19 -1
  47. package/dist/packages/core/src/commands/setMark.d.ts +2 -0
  48. package/dist/packages/core/src/commands/setMeta.d.ts +3 -0
  49. package/dist/packages/core/src/commands/setNode.d.ts +3 -0
  50. package/dist/packages/core/src/commands/setNodeSelection.d.ts +2 -0
  51. package/dist/packages/core/src/commands/setTextSelection.d.ts +2 -0
  52. package/dist/packages/core/src/commands/sinkListItem.d.ts +2 -0
  53. package/dist/packages/core/src/commands/splitBlock.d.ts +3 -0
  54. package/dist/packages/core/src/commands/splitListItem.d.ts +2 -0
  55. package/dist/packages/core/src/commands/toggleList.d.ts +5 -0
  56. package/dist/packages/core/src/commands/toggleMark.d.ts +13 -1
  57. package/dist/packages/core/src/commands/toggleNode.d.ts +4 -0
  58. package/dist/packages/core/src/commands/toggleWrap.d.ts +3 -0
  59. package/dist/packages/core/src/commands/undoInputRule.d.ts +1 -0
  60. package/dist/packages/core/src/commands/unsetAllMarks.d.ts +1 -0
  61. package/dist/packages/core/src/commands/unsetMark.d.ts +8 -1
  62. package/dist/packages/core/src/commands/updateAttributes.d.ts +12 -1
  63. package/dist/packages/core/src/commands/wrapIn.d.ts +3 -0
  64. package/dist/packages/core/src/commands/wrapInList.d.ts +3 -0
  65. package/dist/packages/core/src/helpers/combineTransactionSteps.d.ts +3 -0
  66. package/dist/packages/core/src/helpers/createChainableState.d.ts +5 -0
  67. package/dist/packages/core/src/helpers/createDocument.d.ts +7 -0
  68. package/dist/packages/core/src/helpers/createNodeFromContent.d.ts +7 -0
  69. package/dist/packages/core/src/helpers/defaultBlockAt.d.ts +5 -0
  70. package/dist/packages/core/src/helpers/findChildren.d.ts +6 -0
  71. package/dist/packages/core/src/helpers/findChildrenInRange.d.ts +4 -0
  72. package/dist/packages/core/src/helpers/findParentNode.d.ts +8 -0
  73. package/dist/packages/core/src/helpers/findParentNodeClosestToPos.d.ts +9 -0
  74. package/dist/packages/core/src/helpers/generateHTML.d.ts +6 -0
  75. package/dist/packages/core/src/helpers/generateJSON.d.ts +6 -0
  76. package/dist/packages/core/src/helpers/generateText.d.ts +7 -0
  77. package/dist/packages/core/src/helpers/getAttributes.d.ts +6 -0
  78. package/dist/packages/core/src/helpers/getExtensionField.d.ts +7 -0
  79. package/dist/packages/core/src/helpers/getSchemaByResolvedExtensions.d.ts +6 -0
  80. package/dist/packages/core/src/helpers/getSchemaTypeByName.d.ts +6 -0
  81. package/dist/packages/core/src/helpers/getSchemaTypeNameByName.d.ts +6 -0
  82. package/dist/packages/core/src/helpers/getSplittedAttributes.d.ts +7 -0
  83. package/dist/packages/core/src/helpers/getText.d.ts +9 -0
  84. package/dist/packages/core/src/helpers/getTextBetween.d.ts +8 -0
  85. package/dist/packages/core/src/helpers/getTextContentFromNodes.d.ts +6 -0
  86. package/dist/packages/core/src/helpers/getTextSerializersFromSchema.d.ts +5 -0
  87. package/dist/packages/core/src/inputRules/markInputRule.d.ts +1 -0
  88. package/dist/packages/core/src/inputRules/nodeInputRule.d.ts +1 -0
  89. package/dist/packages/core/src/inputRules/textInputRule.d.ts +1 -0
  90. package/dist/packages/core/src/inputRules/textblockTypeInputRule.d.ts +1 -0
  91. package/dist/packages/core/src/inputRules/wrappingInputRule.d.ts +1 -0
  92. package/dist/packages/core/src/pasteRules/markPasteRule.d.ts +1 -0
  93. package/dist/packages/core/src/pasteRules/nodePasteRule.d.ts +1 -0
  94. package/dist/packages/core/src/pasteRules/textPasteRule.d.ts +1 -0
  95. package/package.json +2 -2
  96. package/src/Extension.ts +130 -14
  97. package/src/ExtensionManager.ts +117 -85
  98. package/src/Mark.ts +129 -14
  99. package/src/Node.ts +226 -30
  100. package/src/NodePos.ts +19 -18
  101. package/src/NodeView.ts +4 -0
  102. package/src/PasteRule.ts +4 -0
  103. package/src/commands/blur.ts +1 -0
  104. package/src/commands/clearContent.ts +2 -0
  105. package/src/commands/clearNodes.ts +1 -0
  106. package/src/commands/command.ts +6 -0
  107. package/src/commands/createParagraphNear.ts +1 -0
  108. package/src/commands/cut.ts +5 -0
  109. package/src/commands/deleteCurrentNode.ts +1 -0
  110. package/src/commands/deleteNode.ts +3 -1
  111. package/src/commands/deleteRange.ts +2 -0
  112. package/src/commands/deleteSelection.ts +1 -0
  113. package/src/commands/enter.ts +1 -0
  114. package/src/commands/exitCode.ts +1 -0
  115. package/src/commands/extendMarkRange.ts +12 -1
  116. package/src/commands/first.ts +2 -0
  117. package/src/commands/focus.ts +12 -0
  118. package/src/commands/insertContent.ts +16 -0
  119. package/src/commands/insertContentAt.ts +19 -0
  120. package/src/commands/join.ts +12 -4
  121. package/src/commands/joinItemBackward.ts +2 -1
  122. package/src/commands/joinItemForward.ts +2 -1
  123. package/src/commands/keyboardShortcut.ts +2 -0
  124. package/src/commands/lift.ts +5 -1
  125. package/src/commands/liftEmptyBlock.ts +2 -1
  126. package/src/commands/liftListItem.ts +3 -1
  127. package/src/commands/newlineInCode.ts +1 -0
  128. package/src/commands/resetAttributes.ts +3 -0
  129. package/src/commands/scrollIntoView.ts +1 -0
  130. package/src/commands/selectAll.ts +1 -0
  131. package/src/commands/selectNodeBackward.ts +1 -0
  132. package/src/commands/selectNodeForward.ts +1 -0
  133. package/src/commands/selectParentNode.ts +1 -0
  134. package/src/commands/selectTextblockEnd.ts +1 -0
  135. package/src/commands/selectTextblockStart.ts +1 -0
  136. package/src/commands/setContent.ts +17 -0
  137. package/src/commands/setMark.ts +2 -0
  138. package/src/commands/setMeta.ts +3 -0
  139. package/src/commands/setNode.ts +3 -0
  140. package/src/commands/setNodeSelection.ts +2 -0
  141. package/src/commands/setTextSelection.ts +2 -0
  142. package/src/commands/sinkListItem.ts +2 -0
  143. package/src/commands/splitBlock.ts +3 -0
  144. package/src/commands/splitListItem.ts +2 -0
  145. package/src/commands/toggleList.ts +5 -0
  146. package/src/commands/toggleMark.ts +12 -0
  147. package/src/commands/toggleNode.ts +4 -0
  148. package/src/commands/toggleWrap.ts +3 -0
  149. package/src/commands/undoInputRule.ts +1 -0
  150. package/src/commands/unsetAllMarks.ts +1 -0
  151. package/src/commands/unsetMark.ts +7 -0
  152. package/src/commands/updateAttributes.ts +10 -0
  153. package/src/commands/wrapIn.ts +3 -0
  154. package/src/commands/wrapInList.ts +3 -0
  155. package/src/extensions/keymap.ts +7 -1
  156. package/src/helpers/combineTransactionSteps.ts +3 -0
  157. package/src/helpers/createChainableState.ts +5 -0
  158. package/src/helpers/createDocument.ts +7 -0
  159. package/src/helpers/createNodeFromContent.ts +16 -3
  160. package/src/helpers/defaultBlockAt.ts +5 -0
  161. package/src/helpers/findChildren.ts +6 -0
  162. package/src/helpers/findChildrenInRange.ts +4 -0
  163. package/src/helpers/findParentNode.ts +8 -0
  164. package/src/helpers/findParentNodeClosestToPos.ts +9 -0
  165. package/src/helpers/generateHTML.ts +6 -0
  166. package/src/helpers/generateJSON.ts +6 -0
  167. package/src/helpers/generateText.ts +7 -0
  168. package/src/helpers/getAttributes.ts +6 -0
  169. package/src/helpers/getExtensionField.ts +7 -0
  170. package/src/helpers/getSchemaByResolvedExtensions.ts +6 -0
  171. package/src/helpers/getSchemaTypeByName.ts +6 -0
  172. package/src/helpers/getSchemaTypeNameByName.ts +6 -0
  173. package/src/helpers/getSplittedAttributes.ts +7 -0
  174. package/src/helpers/getText.ts +9 -0
  175. package/src/helpers/getTextBetween.ts +12 -10
  176. package/src/helpers/getTextContentFromNodes.ts +6 -0
  177. package/src/helpers/getTextSerializersFromSchema.ts +5 -0
  178. package/src/inputRules/markInputRule.ts +1 -0
  179. package/src/inputRules/nodeInputRule.ts +1 -0
  180. package/src/inputRules/textInputRule.ts +1 -0
  181. package/src/inputRules/textblockTypeInputRule.ts +1 -0
  182. package/src/inputRules/wrappingInputRule.ts +1 -0
  183. package/src/pasteRules/markPasteRule.ts +1 -0
  184. package/src/pasteRules/nodePasteRule.ts +1 -0
  185. package/src/pasteRules/textPasteRule.ts +1 -0
@@ -1,4 +1,11 @@
1
1
  import { Extensions, JSONContent, TextSerializer } from '../types.js';
2
+ /**
3
+ * Generate raw text from a JSONContent
4
+ * @param doc The JSONContent to generate text from
5
+ * @param extensions The extensions to use for the schema
6
+ * @param options Options for the text generation f.e. blockSeparator or textSerializers
7
+ * @returns The generated text
8
+ */
2
9
  export declare function generateText(doc: JSONContent, extensions: Extensions, options?: {
3
10
  blockSeparator?: string;
4
11
  textSerializers?: Record<string, TextSerializer>;
@@ -1,3 +1,9 @@
1
1
  import { MarkType, NodeType } from '@tiptap/pm/model';
2
2
  import { EditorState } from '@tiptap/pm/state';
3
+ /**
4
+ * Get node or mark attributes by type or name on the current editor state
5
+ * @param state The current editor state
6
+ * @param typeOrName The node or mark type or name
7
+ * @returns The attributes of the node or mark or an empty object
8
+ */
3
9
  export declare function getAttributes(state: EditorState, typeOrName: string | NodeType | MarkType): Record<string, any>;
@@ -1,2 +1,9 @@
1
1
  import { AnyExtension, MaybeThisParameterType, RemoveThis } from '../types.js';
2
+ /**
3
+ * Returns a field from an extension
4
+ * @param extension The Tiptap extension
5
+ * @param field The field, for example `renderHTML` or `priority`
6
+ * @param context The context object that should be passed as `this` into the function
7
+ * @returns The field value
8
+ */
2
9
  export declare function getExtensionField<T = any>(extension: AnyExtension, field: string, context?: Omit<MaybeThisParameterType<T>, 'parent'>): RemoveThis<T>;
@@ -1,4 +1,10 @@
1
1
  import { Schema } from '@tiptap/pm/model';
2
2
  import { Editor } from '../index.js';
3
3
  import { Extensions } from '../types.js';
4
+ /**
5
+ * Creates a new Prosemirror schema based on the given extensions.
6
+ * @param extensions An array of Tiptap extensions
7
+ * @param editor The editor instance
8
+ * @returns A Prosemirror schema
9
+ */
4
10
  export declare function getSchemaByResolvedExtensions(extensions: Extensions, editor?: Editor): Schema;
@@ -1,2 +1,8 @@
1
1
  import { MarkType, NodeType, Schema } from '@tiptap/pm/model';
2
+ /**
3
+ * Tries to get a node or mark type by its name.
4
+ * @param name The name of the node or mark type
5
+ * @param schema The Prosemiror schema to search in
6
+ * @returns The node or mark type, or null if it doesn't exist
7
+ */
2
8
  export declare function getSchemaTypeByName(name: string, schema: Schema): NodeType | MarkType | null;
@@ -1,2 +1,8 @@
1
1
  import { Schema } from '@tiptap/pm/model';
2
+ /**
3
+ * Get the type of a schema item by its name.
4
+ * @param name The name of the schema item
5
+ * @param schema The Prosemiror schema to search in
6
+ * @returns The type of the schema item (`node` or `mark`), or null if it doesn't exist
7
+ */
2
8
  export declare function getSchemaTypeNameByName(name: string, schema: Schema): 'node' | 'mark' | null;
@@ -1,2 +1,9 @@
1
1
  import { ExtensionAttribute } from '../types.js';
2
+ /**
3
+ * Return attributes of an extension that should be splitted by keepOnSplit flag
4
+ * @param extensionAttributes Array of extension attributes
5
+ * @param typeName The type of the extension
6
+ * @param attributes The attributes of the extension
7
+ * @returns The splitted attributes
8
+ */
2
9
  export declare function getSplittedAttributes(extensionAttributes: ExtensionAttribute[], typeName: string, attributes: Record<string, any>): Record<string, any>;
@@ -1,5 +1,14 @@
1
1
  import { Node as ProseMirrorNode } from '@tiptap/pm/model';
2
2
  import { TextSerializer } from '../types.js';
3
+ /**
4
+ * Gets the text of a Prosemirror node
5
+ * @param node The Prosemirror node
6
+ * @param options Options for the text serializer & block separator
7
+ * @returns The text of the node
8
+ * @example ```js
9
+ * const text = getText(node, { blockSeparator: '\n' })
10
+ * ```
11
+ */
3
12
  export declare function getText(node: ProseMirrorNode, options?: {
4
13
  blockSeparator?: string;
5
14
  textSerializers?: Record<string, TextSerializer>;
@@ -1,5 +1,13 @@
1
1
  import { Node as ProseMirrorNode } from '@tiptap/pm/model';
2
2
  import { Range, TextSerializer } from '../types.js';
3
+ /**
4
+ * Gets the text between two positions in a Prosemirror node
5
+ * and serializes it using the given text serializers and block separator (see getText)
6
+ * @param startNode The Prosemirror node to start from
7
+ * @param range The range of the text to get
8
+ * @param options Options for the text serializer & block separator
9
+ * @returns The text between the two positions
10
+ */
3
11
  export declare function getTextBetween(startNode: ProseMirrorNode, range: Range, options?: {
4
12
  blockSeparator?: string;
5
13
  textSerializers?: Record<string, TextSerializer>;
@@ -1,2 +1,8 @@
1
1
  import { ResolvedPos } from '@tiptap/pm/model';
2
+ /**
3
+ * Returns the text content of a resolved prosemirror position
4
+ * @param $from The resolved position to get the text content from
5
+ * @param maxMatch The maximum number of characters to match
6
+ * @returns The text content
7
+ */
2
8
  export declare const getTextContentFromNodes: ($from: ResolvedPos, maxMatch?: number) => string;
@@ -1,3 +1,8 @@
1
1
  import { Schema } from '@tiptap/pm/model';
2
2
  import { TextSerializer } from '../types.js';
3
+ /**
4
+ * Find text serializers `toText` in a Prosemirror schema
5
+ * @param schema The Prosemirror schema to search in
6
+ * @returns A record of text serializers by node name
7
+ */
3
8
  export declare function getTextSerializersFromSchema(schema: Schema): Record<string, TextSerializer>;
@@ -4,6 +4,7 @@ import { ExtendedRegExpMatchArray } from '../types.js';
4
4
  /**
5
5
  * Build an input rule that adds a mark when the
6
6
  * matched text is typed into it.
7
+ * @see https://tiptap.dev/guide/custom-extensions/#input-rules
7
8
  */
8
9
  export declare function markInputRule(config: {
9
10
  find: InputRuleFinder;
@@ -4,6 +4,7 @@ import { ExtendedRegExpMatchArray } from '../types.js';
4
4
  /**
5
5
  * Build an input rule that adds a node when the
6
6
  * matched text is typed into it.
7
+ * @see https://tiptap.dev/guide/custom-extensions/#input-rules
7
8
  */
8
9
  export declare function nodeInputRule(config: {
9
10
  /**
@@ -2,6 +2,7 @@ import { InputRule, InputRuleFinder } from '../InputRule.js';
2
2
  /**
3
3
  * Build an input rule that replaces text when the
4
4
  * matched text is typed into it.
5
+ * @see https://tiptap.dev/guide/custom-extensions/#input-rules
5
6
  */
6
7
  export declare function textInputRule(config: {
7
8
  find: InputRuleFinder;
@@ -6,6 +6,7 @@ import { ExtendedRegExpMatchArray } from '../types.js';
6
6
  * matched text is typed into it. When using a regular expresion you’ll
7
7
  * probably want the regexp to start with `^`, so that the pattern can
8
8
  * only occur at the start of a textblock.
9
+ * @see https://tiptap.dev/guide/custom-extensions/#input-rules
9
10
  */
10
11
  export declare function textblockTypeInputRule(config: {
11
12
  find: InputRuleFinder;
@@ -15,6 +15,7 @@ import { ExtendedRegExpMatchArray } from '../types.js';
15
15
  * two nodes. You can pass a join predicate, which takes a regular
16
16
  * expression match and the node before the wrapped node, and can
17
17
  * return a boolean to indicate whether a join should happen.
18
+ * @see https://tiptap.dev/guide/custom-extensions/#input-rules
18
19
  */
19
20
  export declare function wrappingInputRule(config: {
20
21
  find: InputRuleFinder;
@@ -4,6 +4,7 @@ import { ExtendedRegExpMatchArray } from '../types.js';
4
4
  /**
5
5
  * Build an paste rule that adds a mark when the
6
6
  * matched text is pasted into it.
7
+ * @see https://tiptap.dev/guide/custom-extensions/#paste-rules
7
8
  */
8
9
  export declare function markPasteRule(config: {
9
10
  find: PasteRuleFinder;
@@ -4,6 +4,7 @@ import { ExtendedRegExpMatchArray } from '../types.js';
4
4
  /**
5
5
  * Build an paste rule that adds a node when the
6
6
  * matched text is pasted into it.
7
+ * @see https://tiptap.dev/guide/custom-extensions/#paste-rules
7
8
  */
8
9
  export declare function nodePasteRule(config: {
9
10
  find: PasteRuleFinder;
@@ -2,6 +2,7 @@ import { PasteRule, PasteRuleFinder } from '../PasteRule.js';
2
2
  /**
3
3
  * Build an paste rule that replaces text when the
4
4
  * matched text is pasted into it.
5
+ * @see https://tiptap.dev/guide/custom-extensions/#paste-rules
5
6
  */
6
7
  export declare function textPasteRule(config: {
7
8
  find: PasteRuleFinder;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tiptap/core",
3
3
  "description": "headless rich text editor",
4
- "version": "2.3.1",
4
+ "version": "2.4.0",
5
5
  "homepage": "https://tiptap.dev",
6
6
  "keywords": [
7
7
  "tiptap",
@@ -32,7 +32,7 @@
32
32
  "dist"
33
33
  ],
34
34
  "devDependencies": {
35
- "@tiptap/pm": "^2.3.1"
35
+ "@tiptap/pm": "^2.4.0"
36
36
  },
37
37
  "peerDependencies": {
38
38
  "@tiptap/pm": "^2.0.0"
package/src/Extension.ts CHANGED
@@ -23,22 +23,40 @@ declare module '@tiptap/core' {
23
23
  [key: string]: any
24
24
 
25
25
  /**
26
- * Name
26
+ * The extension name - this must be unique.
27
+ * It will be used to identify the extension.
28
+ *
29
+ * @example 'myExtension'
27
30
  */
28
31
  name: string
29
32
 
30
33
  /**
31
- * Priority
34
+ * The priority of your extension. The higher, the later it will be called
35
+ * and will take precedence over other extensions with a lower priority.
36
+ * @default 1000
37
+ * @example 1001
32
38
  */
33
39
  priority?: number
34
40
 
35
41
  /**
36
- * Default options
42
+ * The default options for this extension.
43
+ * @example
44
+ * defaultOptions: {
45
+ * myOption: 'foo',
46
+ * myOtherOption: 10,
47
+ * }
37
48
  */
38
49
  defaultOptions?: Options
39
50
 
40
51
  /**
41
- * Default Options
52
+ * This method will add options to this extension
53
+ * @see https://tiptap.dev/guide/custom-extensions#settings
54
+ * @example
55
+ * addOptions() {
56
+ * return {
57
+ * myOption: 'foo',
58
+ * myOtherOption: 10,
59
+ * }
42
60
  */
43
61
  addOptions?: (this: {
44
62
  name: string
@@ -46,7 +64,13 @@ declare module '@tiptap/core' {
46
64
  }) => Options
47
65
 
48
66
  /**
49
- * Default Storage
67
+ * The default storage this extension can save data to.
68
+ * @see https://tiptap.dev/guide/custom-extensions#storage
69
+ * @example
70
+ * defaultStorage: {
71
+ * prefetchedUsers: [],
72
+ * loading: false,
73
+ * }
50
74
  */
51
75
  addStorage?: (this: {
52
76
  name: string
@@ -55,7 +79,30 @@ declare module '@tiptap/core' {
55
79
  }) => Storage
56
80
 
57
81
  /**
58
- * Global attributes
82
+ * This function adds globalAttributes to specific nodes.
83
+ * @see https://tiptap.dev/guide/custom-extensions#global-attributes
84
+ * @example
85
+ * addGlobalAttributes() {
86
+ * return [
87
+ * {
88
+ // Extend the following extensions
89
+ * types: [
90
+ * 'heading',
91
+ * 'paragraph',
92
+ * ],
93
+ * // … with those attributes
94
+ * attributes: {
95
+ * textAlign: {
96
+ * default: 'left',
97
+ * renderHTML: attributes => ({
98
+ * style: `text-align: ${attributes.textAlign}`,
99
+ * }),
100
+ * parseHTML: element => element.style.textAlign || 'left',
101
+ * },
102
+ * },
103
+ * },
104
+ * ]
105
+ * }
59
106
  */
60
107
  addGlobalAttributes?: (this: {
61
108
  name: string
@@ -65,7 +112,14 @@ declare module '@tiptap/core' {
65
112
  }) => GlobalAttributes | {}
66
113
 
67
114
  /**
68
- * Raw
115
+ * This function adds commands to the editor
116
+ * @see https://tiptap.dev/guide/custom-extensions#keyboard-shortcuts
117
+ * @example
118
+ * addCommands() {
119
+ * return {
120
+ * myCommand: () => ({ chain }) => chain().setMark('type', 'foo').run(),
121
+ * }
122
+ * }
69
123
  */
70
124
  addCommands?: (this: {
71
125
  name: string
@@ -76,7 +130,14 @@ declare module '@tiptap/core' {
76
130
  }) => Partial<RawCommands>
77
131
 
78
132
  /**
79
- * Keyboard shortcuts
133
+ * This function registers keyboard shortcuts.
134
+ * @see https://tiptap.dev/guide/custom-extensions#keyboard-shortcuts
135
+ * @example
136
+ * addKeyboardShortcuts() {
137
+ * return {
138
+ * 'Mod-l': () => this.editor.commands.toggleBulletList(),
139
+ * }
140
+ * },
80
141
  */
81
142
  addKeyboardShortcuts?: (this: {
82
143
  name: string
@@ -89,7 +150,17 @@ declare module '@tiptap/core' {
89
150
  }
90
151
 
91
152
  /**
92
- * Input rules
153
+ * This function adds input rules to the editor.
154
+ * @see https://tiptap.dev/guide/custom-extensions#input-rules
155
+ * @example
156
+ * addInputRules() {
157
+ * return [
158
+ * markInputRule({
159
+ * find: inputRegex,
160
+ * type: this.type,
161
+ * }),
162
+ * ]
163
+ * },
93
164
  */
94
165
  addInputRules?: (this: {
95
166
  name: string
@@ -100,7 +171,17 @@ declare module '@tiptap/core' {
100
171
  }) => InputRule[]
101
172
 
102
173
  /**
103
- * Paste rules
174
+ * This function adds paste rules to the editor.
175
+ * @see https://tiptap.dev/guide/custom-extensions#paste-rules
176
+ * @example
177
+ * addPasteRules() {
178
+ * return [
179
+ * markPasteRule({
180
+ * find: pasteRegex,
181
+ * type: this.type,
182
+ * }),
183
+ * ]
184
+ * },
104
185
  */
105
186
  addPasteRules?: (this: {
106
187
  name: string
@@ -111,7 +192,14 @@ declare module '@tiptap/core' {
111
192
  }) => PasteRule[]
112
193
 
113
194
  /**
114
- * ProseMirror plugins
195
+ * This function adds Prosemirror plugins to the editor
196
+ * @see https://tiptap.dev/guide/custom-extensions#prosemirror-plugins
197
+ * @example
198
+ * addProseMirrorPlugins() {
199
+ * return [
200
+ * customPlugin(),
201
+ * ]
202
+ * }
115
203
  */
116
204
  addProseMirrorPlugins?: (this: {
117
205
  name: string
@@ -122,7 +210,16 @@ declare module '@tiptap/core' {
122
210
  }) => Plugin[]
123
211
 
124
212
  /**
125
- * Extensions
213
+ * This function adds additional extensions to the editor. This is useful for
214
+ * building extension kits.
215
+ * @example
216
+ * addExtensions() {
217
+ * return [
218
+ * BulletList,
219
+ * OrderedList,
220
+ * ListItem
221
+ * ]
222
+ * }
126
223
  */
127
224
  addExtensions?: (this: {
128
225
  name: string
@@ -132,7 +229,14 @@ declare module '@tiptap/core' {
132
229
  }) => Extensions
133
230
 
134
231
  /**
135
- * Extend Node Schema
232
+ * This function extends the schema of the node.
233
+ * @example
234
+ * extendNodeSchema() {
235
+ * return {
236
+ * group: 'inline',
237
+ * selectable: false,
238
+ * }
239
+ * }
136
240
  */
137
241
  extendNodeSchema?:
138
242
  | ((
@@ -147,7 +251,14 @@ declare module '@tiptap/core' {
147
251
  | null
148
252
 
149
253
  /**
150
- * Extend Mark Schema
254
+ * This function extends the schema of the mark.
255
+ * @example
256
+ * extendMarkSchema() {
257
+ * return {
258
+ * group: 'inline',
259
+ * selectable: false,
260
+ * }
261
+ * }
151
262
  */
152
263
  extendMarkSchema?:
153
264
  | ((
@@ -282,6 +393,10 @@ declare module '@tiptap/core' {
282
393
  }
283
394
  }
284
395
 
396
+ /**
397
+ * The Extension class is the base class for all extensions.
398
+ * @see https://tiptap.dev/api/extensions#create-a-new-extension
399
+ */
285
400
  export class Extension<Options = any, Storage = any> {
286
401
  type = 'extension'
287
402
 
@@ -342,6 +457,7 @@ export class Extension<Options = any, Storage = any> {
342
457
  // with different calls of `configure`
343
458
  const extension = this.extend()
344
459
 
460
+ extension.parent = this.parent
345
461
  extension.options = mergeDeep(this.options as Record<string, any>, options) as Options
346
462
 
347
463
  extension.storage = callOrReturn(