@tiptap/core 2.3.2 → 2.5.0-beta.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 (186) hide show
  1. package/dist/index.cjs +277 -67
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.js +277 -67
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.umd.js +277 -67
  6. package/dist/index.umd.js.map +1 -1
  7. package/dist/packages/core/src/EventEmitter.d.ts +2 -2
  8. package/dist/packages/core/src/Extension.d.ts +129 -14
  9. package/dist/packages/core/src/ExtensionManager.d.ts +37 -0
  10. package/dist/packages/core/src/Mark.d.ts +129 -14
  11. package/dist/packages/core/src/Node.d.ts +226 -30
  12. package/dist/packages/core/src/NodeView.d.ts +4 -0
  13. package/dist/packages/core/src/PasteRule.d.ts +4 -0
  14. package/dist/packages/core/src/commands/blur.d.ts +1 -0
  15. package/dist/packages/core/src/commands/clearContent.d.ts +2 -0
  16. package/dist/packages/core/src/commands/clearNodes.d.ts +1 -0
  17. package/dist/packages/core/src/commands/command.d.ts +6 -0
  18. package/dist/packages/core/src/commands/createParagraphNear.d.ts +1 -0
  19. package/dist/packages/core/src/commands/cut.d.ts +5 -0
  20. package/dist/packages/core/src/commands/deleteCurrentNode.d.ts +1 -0
  21. package/dist/packages/core/src/commands/deleteNode.d.ts +3 -1
  22. package/dist/packages/core/src/commands/deleteRange.d.ts +2 -0
  23. package/dist/packages/core/src/commands/deleteSelection.d.ts +1 -0
  24. package/dist/packages/core/src/commands/enter.d.ts +1 -0
  25. package/dist/packages/core/src/commands/exitCode.d.ts +1 -0
  26. package/dist/packages/core/src/commands/extendMarkRange.d.ts +14 -2
  27. package/dist/packages/core/src/commands/first.d.ts +2 -0
  28. package/dist/packages/core/src/commands/focus.d.ts +14 -1
  29. package/dist/packages/core/src/commands/insertContent.d.ts +17 -1
  30. package/dist/packages/core/src/commands/insertContentAt.d.ts +20 -1
  31. package/dist/packages/core/src/commands/join.d.ts +12 -4
  32. package/dist/packages/core/src/commands/joinItemBackward.d.ts +2 -1
  33. package/dist/packages/core/src/commands/joinItemForward.d.ts +2 -1
  34. package/dist/packages/core/src/commands/keyboardShortcut.d.ts +2 -0
  35. package/dist/packages/core/src/commands/lift.d.ts +5 -1
  36. package/dist/packages/core/src/commands/liftEmptyBlock.d.ts +2 -1
  37. package/dist/packages/core/src/commands/liftListItem.d.ts +3 -1
  38. package/dist/packages/core/src/commands/newlineInCode.d.ts +1 -0
  39. package/dist/packages/core/src/commands/resetAttributes.d.ts +3 -0
  40. package/dist/packages/core/src/commands/scrollIntoView.d.ts +1 -0
  41. package/dist/packages/core/src/commands/selectAll.d.ts +1 -0
  42. package/dist/packages/core/src/commands/selectNodeBackward.d.ts +1 -0
  43. package/dist/packages/core/src/commands/selectNodeForward.d.ts +1 -0
  44. package/dist/packages/core/src/commands/selectParentNode.d.ts +1 -0
  45. package/dist/packages/core/src/commands/selectTextblockEnd.d.ts +1 -0
  46. package/dist/packages/core/src/commands/selectTextblockStart.d.ts +1 -0
  47. package/dist/packages/core/src/commands/setContent.d.ts +19 -1
  48. package/dist/packages/core/src/commands/setMark.d.ts +2 -0
  49. package/dist/packages/core/src/commands/setMeta.d.ts +3 -0
  50. package/dist/packages/core/src/commands/setNode.d.ts +3 -0
  51. package/dist/packages/core/src/commands/setNodeSelection.d.ts +2 -0
  52. package/dist/packages/core/src/commands/setTextSelection.d.ts +2 -0
  53. package/dist/packages/core/src/commands/sinkListItem.d.ts +2 -0
  54. package/dist/packages/core/src/commands/splitBlock.d.ts +3 -0
  55. package/dist/packages/core/src/commands/splitListItem.d.ts +2 -0
  56. package/dist/packages/core/src/commands/toggleList.d.ts +5 -0
  57. package/dist/packages/core/src/commands/toggleMark.d.ts +13 -1
  58. package/dist/packages/core/src/commands/toggleNode.d.ts +4 -0
  59. package/dist/packages/core/src/commands/toggleWrap.d.ts +3 -0
  60. package/dist/packages/core/src/commands/undoInputRule.d.ts +1 -0
  61. package/dist/packages/core/src/commands/unsetAllMarks.d.ts +1 -0
  62. package/dist/packages/core/src/commands/unsetMark.d.ts +8 -1
  63. package/dist/packages/core/src/commands/updateAttributes.d.ts +12 -1
  64. package/dist/packages/core/src/commands/wrapIn.d.ts +3 -0
  65. package/dist/packages/core/src/commands/wrapInList.d.ts +3 -0
  66. package/dist/packages/core/src/helpers/combineTransactionSteps.d.ts +3 -0
  67. package/dist/packages/core/src/helpers/createChainableState.d.ts +5 -0
  68. package/dist/packages/core/src/helpers/createDocument.d.ts +7 -0
  69. package/dist/packages/core/src/helpers/createNodeFromContent.d.ts +7 -0
  70. package/dist/packages/core/src/helpers/defaultBlockAt.d.ts +5 -0
  71. package/dist/packages/core/src/helpers/findChildren.d.ts +6 -0
  72. package/dist/packages/core/src/helpers/findChildrenInRange.d.ts +4 -0
  73. package/dist/packages/core/src/helpers/findParentNode.d.ts +8 -0
  74. package/dist/packages/core/src/helpers/findParentNodeClosestToPos.d.ts +9 -0
  75. package/dist/packages/core/src/helpers/generateHTML.d.ts +6 -0
  76. package/dist/packages/core/src/helpers/generateJSON.d.ts +6 -0
  77. package/dist/packages/core/src/helpers/generateText.d.ts +7 -0
  78. package/dist/packages/core/src/helpers/getAttributes.d.ts +6 -0
  79. package/dist/packages/core/src/helpers/getExtensionField.d.ts +7 -0
  80. package/dist/packages/core/src/helpers/getSchemaByResolvedExtensions.d.ts +6 -0
  81. package/dist/packages/core/src/helpers/getSchemaTypeByName.d.ts +6 -0
  82. package/dist/packages/core/src/helpers/getSchemaTypeNameByName.d.ts +6 -0
  83. package/dist/packages/core/src/helpers/getSplittedAttributes.d.ts +7 -0
  84. package/dist/packages/core/src/helpers/getText.d.ts +9 -0
  85. package/dist/packages/core/src/helpers/getTextBetween.d.ts +8 -0
  86. package/dist/packages/core/src/helpers/getTextContentFromNodes.d.ts +6 -0
  87. package/dist/packages/core/src/helpers/getTextSerializersFromSchema.d.ts +5 -0
  88. package/dist/packages/core/src/inputRules/markInputRule.d.ts +1 -0
  89. package/dist/packages/core/src/inputRules/nodeInputRule.d.ts +1 -0
  90. package/dist/packages/core/src/inputRules/textInputRule.d.ts +1 -0
  91. package/dist/packages/core/src/inputRules/textblockTypeInputRule.d.ts +1 -0
  92. package/dist/packages/core/src/inputRules/wrappingInputRule.d.ts +1 -0
  93. package/dist/packages/core/src/pasteRules/markPasteRule.d.ts +1 -0
  94. package/dist/packages/core/src/pasteRules/nodePasteRule.d.ts +1 -0
  95. package/dist/packages/core/src/pasteRules/textPasteRule.d.ts +1 -0
  96. package/package.json +2 -2
  97. package/src/EventEmitter.ts +2 -2
  98. package/src/Extension.ts +130 -14
  99. package/src/ExtensionManager.ts +117 -85
  100. package/src/Mark.ts +129 -14
  101. package/src/Node.ts +226 -30
  102. package/src/NodeView.ts +4 -0
  103. package/src/PasteRule.ts +4 -0
  104. package/src/commands/blur.ts +1 -0
  105. package/src/commands/clearContent.ts +2 -0
  106. package/src/commands/clearNodes.ts +1 -0
  107. package/src/commands/command.ts +6 -0
  108. package/src/commands/createParagraphNear.ts +1 -0
  109. package/src/commands/cut.ts +5 -0
  110. package/src/commands/deleteCurrentNode.ts +1 -0
  111. package/src/commands/deleteNode.ts +3 -1
  112. package/src/commands/deleteRange.ts +2 -0
  113. package/src/commands/deleteSelection.ts +1 -0
  114. package/src/commands/enter.ts +1 -0
  115. package/src/commands/exitCode.ts +1 -0
  116. package/src/commands/extendMarkRange.ts +12 -1
  117. package/src/commands/first.ts +2 -0
  118. package/src/commands/focus.ts +12 -0
  119. package/src/commands/insertContent.ts +16 -0
  120. package/src/commands/insertContentAt.ts +19 -0
  121. package/src/commands/join.ts +12 -4
  122. package/src/commands/joinItemBackward.ts +6 -3
  123. package/src/commands/joinItemForward.ts +2 -1
  124. package/src/commands/keyboardShortcut.ts +2 -0
  125. package/src/commands/lift.ts +5 -1
  126. package/src/commands/liftEmptyBlock.ts +2 -1
  127. package/src/commands/liftListItem.ts +3 -1
  128. package/src/commands/newlineInCode.ts +1 -0
  129. package/src/commands/resetAttributes.ts +3 -0
  130. package/src/commands/scrollIntoView.ts +1 -0
  131. package/src/commands/selectAll.ts +1 -0
  132. package/src/commands/selectNodeBackward.ts +1 -0
  133. package/src/commands/selectNodeForward.ts +1 -0
  134. package/src/commands/selectParentNode.ts +1 -0
  135. package/src/commands/selectTextblockEnd.ts +1 -0
  136. package/src/commands/selectTextblockStart.ts +1 -0
  137. package/src/commands/setContent.ts +17 -0
  138. package/src/commands/setMark.ts +2 -0
  139. package/src/commands/setMeta.ts +3 -0
  140. package/src/commands/setNode.ts +3 -0
  141. package/src/commands/setNodeSelection.ts +2 -0
  142. package/src/commands/setTextSelection.ts +2 -0
  143. package/src/commands/sinkListItem.ts +2 -0
  144. package/src/commands/splitBlock.ts +3 -0
  145. package/src/commands/splitListItem.ts +2 -0
  146. package/src/commands/toggleList.ts +5 -0
  147. package/src/commands/toggleMark.ts +12 -0
  148. package/src/commands/toggleNode.ts +4 -0
  149. package/src/commands/toggleWrap.ts +3 -0
  150. package/src/commands/undoInputRule.ts +1 -0
  151. package/src/commands/unsetAllMarks.ts +1 -0
  152. package/src/commands/unsetMark.ts +7 -0
  153. package/src/commands/updateAttributes.ts +10 -0
  154. package/src/commands/wrapIn.ts +3 -0
  155. package/src/commands/wrapInList.ts +3 -0
  156. package/src/extensions/keymap.ts +7 -1
  157. package/src/helpers/combineTransactionSteps.ts +3 -0
  158. package/src/helpers/createChainableState.ts +5 -0
  159. package/src/helpers/createDocument.ts +7 -0
  160. package/src/helpers/createNodeFromContent.ts +16 -3
  161. package/src/helpers/defaultBlockAt.ts +5 -0
  162. package/src/helpers/findChildren.ts +6 -0
  163. package/src/helpers/findChildrenInRange.ts +4 -0
  164. package/src/helpers/findParentNode.ts +8 -0
  165. package/src/helpers/findParentNodeClosestToPos.ts +9 -0
  166. package/src/helpers/generateHTML.ts +6 -0
  167. package/src/helpers/generateJSON.ts +6 -0
  168. package/src/helpers/generateText.ts +7 -0
  169. package/src/helpers/getAttributes.ts +6 -0
  170. package/src/helpers/getExtensionField.ts +7 -0
  171. package/src/helpers/getSchemaByResolvedExtensions.ts +6 -0
  172. package/src/helpers/getSchemaTypeByName.ts +6 -0
  173. package/src/helpers/getSchemaTypeNameByName.ts +6 -0
  174. package/src/helpers/getSplittedAttributes.ts +7 -0
  175. package/src/helpers/getText.ts +9 -0
  176. package/src/helpers/getTextBetween.ts +12 -10
  177. package/src/helpers/getTextContentFromNodes.ts +6 -0
  178. package/src/helpers/getTextSerializersFromSchema.ts +5 -0
  179. package/src/inputRules/markInputRule.ts +1 -0
  180. package/src/inputRules/nodeInputRule.ts +4 -1
  181. package/src/inputRules/textInputRule.ts +1 -0
  182. package/src/inputRules/textblockTypeInputRule.ts +1 -0
  183. package/src/inputRules/wrappingInputRule.ts +1 -0
  184. package/src/pasteRules/markPasteRule.ts +1 -0
  185. package/src/pasteRules/nodePasteRule.ts +1 -0
  186. package/src/pasteRules/textPasteRule.ts +1 -0
@@ -4,8 +4,8 @@ declare type CallbackFunction<T extends Record<string, any>, EventName extends S
4
4
  export declare class EventEmitter<T extends Record<string, any>> {
5
5
  private callbacks;
6
6
  on<EventName extends StringKeyOf<T>>(event: EventName, fn: CallbackFunction<T, EventName>): this;
7
- protected emit<EventName extends StringKeyOf<T>>(event: EventName, ...args: CallbackType<T, EventName>): this;
7
+ emit<EventName extends StringKeyOf<T>>(event: EventName, ...args: CallbackType<T, EventName>): this;
8
8
  off<EventName extends StringKeyOf<T>>(event: EventName, fn?: CallbackFunction<T, EventName>): this;
9
- protected removeAllListeners(): void;
9
+ removeAllListeners(): void;
10
10
  }
11
11
  export {};
@@ -10,26 +10,50 @@ declare module '@tiptap/core' {
10
10
  interface ExtensionConfig<Options = any, Storage = any> {
11
11
  [key: string]: any;
12
12
  /**
13
- * Name
13
+ * The extension name - this must be unique.
14
+ * It will be used to identify the extension.
15
+ *
16
+ * @example 'myExtension'
14
17
  */
15
18
  name: string;
16
19
  /**
17
- * Priority
20
+ * The priority of your extension. The higher, the later it will be called
21
+ * and will take precedence over other extensions with a lower priority.
22
+ * @default 1000
23
+ * @example 1001
18
24
  */
19
25
  priority?: number;
20
26
  /**
21
- * Default options
27
+ * The default options for this extension.
28
+ * @example
29
+ * defaultOptions: {
30
+ * myOption: 'foo',
31
+ * myOtherOption: 10,
32
+ * }
22
33
  */
23
34
  defaultOptions?: Options;
24
35
  /**
25
- * Default Options
36
+ * This method will add options to this extension
37
+ * @see https://tiptap.dev/guide/custom-extensions#settings
38
+ * @example
39
+ * addOptions() {
40
+ * return {
41
+ * myOption: 'foo',
42
+ * myOtherOption: 10,
43
+ * }
26
44
  */
27
45
  addOptions?: (this: {
28
46
  name: string;
29
47
  parent: Exclude<ParentConfig<ExtensionConfig<Options, Storage>>['addOptions'], undefined>;
30
48
  }) => Options;
31
49
  /**
32
- * Default Storage
50
+ * The default storage this extension can save data to.
51
+ * @see https://tiptap.dev/guide/custom-extensions#storage
52
+ * @example
53
+ * defaultStorage: {
54
+ * prefetchedUsers: [],
55
+ * loading: false,
56
+ * }
33
57
  */
34
58
  addStorage?: (this: {
35
59
  name: string;
@@ -37,7 +61,30 @@ declare module '@tiptap/core' {
37
61
  parent: Exclude<ParentConfig<ExtensionConfig<Options, Storage>>['addStorage'], undefined>;
38
62
  }) => Storage;
39
63
  /**
40
- * Global attributes
64
+ * This function adds globalAttributes to specific nodes.
65
+ * @see https://tiptap.dev/guide/custom-extensions#global-attributes
66
+ * @example
67
+ * addGlobalAttributes() {
68
+ * return [
69
+ * {
70
+ // Extend the following extensions
71
+ * types: [
72
+ * 'heading',
73
+ * 'paragraph',
74
+ * ],
75
+ * // … with those attributes
76
+ * attributes: {
77
+ * textAlign: {
78
+ * default: 'left',
79
+ * renderHTML: attributes => ({
80
+ * style: `text-align: ${attributes.textAlign}`,
81
+ * }),
82
+ * parseHTML: element => element.style.textAlign || 'left',
83
+ * },
84
+ * },
85
+ * },
86
+ * ]
87
+ * }
41
88
  */
42
89
  addGlobalAttributes?: (this: {
43
90
  name: string;
@@ -46,7 +93,14 @@ declare module '@tiptap/core' {
46
93
  parent: ParentConfig<ExtensionConfig<Options, Storage>>['addGlobalAttributes'];
47
94
  }) => GlobalAttributes | {};
48
95
  /**
49
- * Raw
96
+ * This function adds commands to the editor
97
+ * @see https://tiptap.dev/guide/custom-extensions#keyboard-shortcuts
98
+ * @example
99
+ * addCommands() {
100
+ * return {
101
+ * myCommand: () => ({ chain }) => chain().setMark('type', 'foo').run(),
102
+ * }
103
+ * }
50
104
  */
51
105
  addCommands?: (this: {
52
106
  name: string;
@@ -56,7 +110,14 @@ declare module '@tiptap/core' {
56
110
  parent: ParentConfig<ExtensionConfig<Options, Storage>>['addCommands'];
57
111
  }) => Partial<RawCommands>;
58
112
  /**
59
- * Keyboard shortcuts
113
+ * This function registers keyboard shortcuts.
114
+ * @see https://tiptap.dev/guide/custom-extensions#keyboard-shortcuts
115
+ * @example
116
+ * addKeyboardShortcuts() {
117
+ * return {
118
+ * 'Mod-l': () => this.editor.commands.toggleBulletList(),
119
+ * }
120
+ * },
60
121
  */
61
122
  addKeyboardShortcuts?: (this: {
62
123
  name: string;
@@ -68,7 +129,17 @@ declare module '@tiptap/core' {
68
129
  [key: string]: KeyboardShortcutCommand;
69
130
  };
70
131
  /**
71
- * Input rules
132
+ * This function adds input rules to the editor.
133
+ * @see https://tiptap.dev/guide/custom-extensions#input-rules
134
+ * @example
135
+ * addInputRules() {
136
+ * return [
137
+ * markInputRule({
138
+ * find: inputRegex,
139
+ * type: this.type,
140
+ * }),
141
+ * ]
142
+ * },
72
143
  */
73
144
  addInputRules?: (this: {
74
145
  name: string;
@@ -78,7 +149,17 @@ declare module '@tiptap/core' {
78
149
  parent: ParentConfig<ExtensionConfig<Options, Storage>>['addInputRules'];
79
150
  }) => InputRule[];
80
151
  /**
81
- * Paste rules
152
+ * This function adds paste rules to the editor.
153
+ * @see https://tiptap.dev/guide/custom-extensions#paste-rules
154
+ * @example
155
+ * addPasteRules() {
156
+ * return [
157
+ * markPasteRule({
158
+ * find: pasteRegex,
159
+ * type: this.type,
160
+ * }),
161
+ * ]
162
+ * },
82
163
  */
83
164
  addPasteRules?: (this: {
84
165
  name: string;
@@ -88,7 +169,14 @@ declare module '@tiptap/core' {
88
169
  parent: ParentConfig<ExtensionConfig<Options, Storage>>['addPasteRules'];
89
170
  }) => PasteRule[];
90
171
  /**
91
- * ProseMirror plugins
172
+ * This function adds Prosemirror plugins to the editor
173
+ * @see https://tiptap.dev/guide/custom-extensions#prosemirror-plugins
174
+ * @example
175
+ * addProseMirrorPlugins() {
176
+ * return [
177
+ * customPlugin(),
178
+ * ]
179
+ * }
92
180
  */
93
181
  addProseMirrorPlugins?: (this: {
94
182
  name: string;
@@ -98,7 +186,16 @@ declare module '@tiptap/core' {
98
186
  parent: ParentConfig<ExtensionConfig<Options, Storage>>['addProseMirrorPlugins'];
99
187
  }) => Plugin[];
100
188
  /**
101
- * Extensions
189
+ * This function adds additional extensions to the editor. This is useful for
190
+ * building extension kits.
191
+ * @example
192
+ * addExtensions() {
193
+ * return [
194
+ * BulletList,
195
+ * OrderedList,
196
+ * ListItem
197
+ * ]
198
+ * }
102
199
  */
103
200
  addExtensions?: (this: {
104
201
  name: string;
@@ -107,7 +204,14 @@ declare module '@tiptap/core' {
107
204
  parent: ParentConfig<ExtensionConfig<Options, Storage>>['addExtensions'];
108
205
  }) => Extensions;
109
206
  /**
110
- * Extend Node Schema
207
+ * This function extends the schema of the node.
208
+ * @example
209
+ * extendNodeSchema() {
210
+ * return {
211
+ * group: 'inline',
212
+ * selectable: false,
213
+ * }
214
+ * }
111
215
  */
112
216
  extendNodeSchema?: ((this: {
113
217
  name: string;
@@ -116,7 +220,14 @@ declare module '@tiptap/core' {
116
220
  parent: ParentConfig<ExtensionConfig<Options, Storage>>['extendNodeSchema'];
117
221
  }, extension: Node) => Record<string, any>) | null;
118
222
  /**
119
- * Extend Mark Schema
223
+ * This function extends the schema of the mark.
224
+ * @example
225
+ * extendMarkSchema() {
226
+ * return {
227
+ * group: 'inline',
228
+ * selectable: false,
229
+ * }
230
+ * }
120
231
  */
121
232
  extendMarkSchema?: ((this: {
122
233
  name: string;
@@ -212,6 +323,10 @@ declare module '@tiptap/core' {
212
323
  }) => void) | null;
213
324
  }
214
325
  }
326
+ /**
327
+ * The Extension class is the base class for all extensions.
328
+ * @see https://tiptap.dev/api/extensions#create-a-new-extension
329
+ */
215
330
  export declare class Extension<Options = any, Storage = any> {
216
331
  type: string;
217
332
  name: string;
@@ -8,11 +8,48 @@ export declare class ExtensionManager {
8
8
  extensions: Extensions;
9
9
  splittableMarks: string[];
10
10
  constructor(extensions: Extensions, editor: Editor);
11
+ /**
12
+ * Returns a flattened and sorted extension list while
13
+ * also checking for duplicated extensions and warns the user.
14
+ * @param extensions An array of Tiptap extensions
15
+ * @returns An flattened and sorted array of Tiptap extensions
16
+ */
11
17
  static resolve(extensions: Extensions): Extensions;
18
+ /**
19
+ * Create a flattened array of extensions by traversing the `addExtensions` field.
20
+ * @param extensions An array of Tiptap extensions
21
+ * @returns A flattened array of Tiptap extensions
22
+ */
12
23
  static flatten(extensions: Extensions): Extensions;
24
+ /**
25
+ * Sort extensions by priority.
26
+ * @param extensions An array of Tiptap extensions
27
+ * @returns A sorted array of Tiptap extensions by priority
28
+ */
13
29
  static sort(extensions: Extensions): Extensions;
30
+ /**
31
+ * Get all commands from the extensions.
32
+ * @returns An object with all commands where the key is the command name and the value is the command function
33
+ */
14
34
  get commands(): RawCommands;
35
+ /**
36
+ * Get all registered Prosemirror plugins from the extensions.
37
+ * @returns An array of Prosemirror plugins
38
+ */
15
39
  get plugins(): Plugin[];
40
+ /**
41
+ * Get all attributes from the extensions.
42
+ * @returns An array of attributes
43
+ */
16
44
  get attributes(): import("@tiptap/core").ExtensionAttribute[];
45
+ /**
46
+ * Get all node views from the extensions.
47
+ * @returns An object with all node views where the key is the node name and the value is the node view function
48
+ */
17
49
  get nodeViews(): any;
50
+ /**
51
+ * Go through all extensions, create extension storages & setup marks
52
+ * & bind editor event listener.
53
+ */
54
+ private setupExtensions;
18
55
  }
@@ -10,26 +10,50 @@ declare module '@tiptap/core' {
10
10
  interface MarkConfig<Options = any, Storage = any> {
11
11
  [key: string]: any;
12
12
  /**
13
- * Name
13
+ * The extension name - this must be unique.
14
+ * It will be used to identify the extension.
15
+ *
16
+ * @example 'myExtension'
14
17
  */
15
18
  name: string;
16
19
  /**
17
- * Priority
20
+ * The priority of your extension. The higher, the later it will be called
21
+ * and will take precedence over other extensions with a lower priority.
22
+ * @default 1000
23
+ * @example 1001
18
24
  */
19
25
  priority?: number;
20
26
  /**
21
- * Default options
27
+ * The default options for this extension.
28
+ * @example
29
+ * defaultOptions: {
30
+ * myOption: 'foo',
31
+ * myOtherOption: 10,
32
+ * }
22
33
  */
23
34
  defaultOptions?: Options;
24
35
  /**
25
- * Default Options
36
+ * This method will add options to this extension
37
+ * @see https://tiptap.dev/guide/custom-extensions#settings
38
+ * @example
39
+ * addOptions() {
40
+ * return {
41
+ * myOption: 'foo',
42
+ * myOtherOption: 10,
43
+ * }
26
44
  */
27
45
  addOptions?: (this: {
28
46
  name: string;
29
47
  parent: Exclude<ParentConfig<MarkConfig<Options, Storage>>['addOptions'], undefined>;
30
48
  }) => Options;
31
49
  /**
32
- * Default Storage
50
+ * The default storage this extension can save data to.
51
+ * @see https://tiptap.dev/guide/custom-extensions#storage
52
+ * @example
53
+ * defaultStorage: {
54
+ * prefetchedUsers: [],
55
+ * loading: false,
56
+ * }
33
57
  */
34
58
  addStorage?: (this: {
35
59
  name: string;
@@ -37,7 +61,30 @@ declare module '@tiptap/core' {
37
61
  parent: Exclude<ParentConfig<MarkConfig<Options, Storage>>['addStorage'], undefined>;
38
62
  }) => Storage;
39
63
  /**
40
- * Global attributes
64
+ * This function adds globalAttributes to specific nodes.
65
+ * @see https://tiptap.dev/guide/custom-extensions#global-attributes
66
+ * @example
67
+ * addGlobalAttributes() {
68
+ * return [
69
+ * {
70
+ // Extend the following extensions
71
+ * types: [
72
+ * 'heading',
73
+ * 'paragraph',
74
+ * ],
75
+ * // … with those attributes
76
+ * attributes: {
77
+ * textAlign: {
78
+ * default: 'left',
79
+ * renderHTML: attributes => ({
80
+ * style: `text-align: ${attributes.textAlign}`,
81
+ * }),
82
+ * parseHTML: element => element.style.textAlign || 'left',
83
+ * },
84
+ * },
85
+ * },
86
+ * ]
87
+ * }
41
88
  */
42
89
  addGlobalAttributes?: (this: {
43
90
  name: string;
@@ -46,7 +93,14 @@ declare module '@tiptap/core' {
46
93
  parent: ParentConfig<MarkConfig<Options, Storage>>['addGlobalAttributes'];
47
94
  }) => GlobalAttributes | {};
48
95
  /**
49
- * Raw
96
+ * This function adds commands to the editor
97
+ * @see https://tiptap.dev/guide/custom-extensions#keyboard-shortcuts
98
+ * @example
99
+ * addCommands() {
100
+ * return {
101
+ * myCommand: () => ({ chain }) => chain().setMark('type', 'foo').run(),
102
+ * }
103
+ * }
50
104
  */
51
105
  addCommands?: (this: {
52
106
  name: string;
@@ -57,7 +111,14 @@ declare module '@tiptap/core' {
57
111
  parent: ParentConfig<MarkConfig<Options, Storage>>['addCommands'];
58
112
  }) => Partial<RawCommands>;
59
113
  /**
60
- * Keyboard shortcuts
114
+ * This function registers keyboard shortcuts.
115
+ * @see https://tiptap.dev/guide/custom-extensions#keyboard-shortcuts
116
+ * @example
117
+ * addKeyboardShortcuts() {
118
+ * return {
119
+ * 'Mod-l': () => this.editor.commands.toggleBulletList(),
120
+ * }
121
+ * },
61
122
  */
62
123
  addKeyboardShortcuts?: (this: {
63
124
  name: string;
@@ -70,7 +131,17 @@ declare module '@tiptap/core' {
70
131
  [key: string]: KeyboardShortcutCommand;
71
132
  };
72
133
  /**
73
- * Input rules
134
+ * This function adds input rules to the editor.
135
+ * @see https://tiptap.dev/guide/custom-extensions#input-rules
136
+ * @example
137
+ * addInputRules() {
138
+ * return [
139
+ * markInputRule({
140
+ * find: inputRegex,
141
+ * type: this.type,
142
+ * }),
143
+ * ]
144
+ * },
74
145
  */
75
146
  addInputRules?: (this: {
76
147
  name: string;
@@ -81,7 +152,17 @@ declare module '@tiptap/core' {
81
152
  parent: ParentConfig<MarkConfig<Options, Storage>>['addInputRules'];
82
153
  }) => InputRule[];
83
154
  /**
84
- * Paste rules
155
+ * This function adds paste rules to the editor.
156
+ * @see https://tiptap.dev/guide/custom-extensions#paste-rules
157
+ * @example
158
+ * addPasteRules() {
159
+ * return [
160
+ * markPasteRule({
161
+ * find: pasteRegex,
162
+ * type: this.type,
163
+ * }),
164
+ * ]
165
+ * },
85
166
  */
86
167
  addPasteRules?: (this: {
87
168
  name: string;
@@ -92,7 +173,14 @@ declare module '@tiptap/core' {
92
173
  parent: ParentConfig<MarkConfig<Options, Storage>>['addPasteRules'];
93
174
  }) => PasteRule[];
94
175
  /**
95
- * ProseMirror plugins
176
+ * This function adds Prosemirror plugins to the editor
177
+ * @see https://tiptap.dev/guide/custom-extensions#prosemirror-plugins
178
+ * @example
179
+ * addProseMirrorPlugins() {
180
+ * return [
181
+ * customPlugin(),
182
+ * ]
183
+ * }
96
184
  */
97
185
  addProseMirrorPlugins?: (this: {
98
186
  name: string;
@@ -103,7 +191,16 @@ declare module '@tiptap/core' {
103
191
  parent: ParentConfig<MarkConfig<Options, Storage>>['addProseMirrorPlugins'];
104
192
  }) => Plugin[];
105
193
  /**
106
- * Extensions
194
+ * This function adds additional extensions to the editor. This is useful for
195
+ * building extension kits.
196
+ * @example
197
+ * addExtensions() {
198
+ * return [
199
+ * BulletList,
200
+ * OrderedList,
201
+ * ListItem
202
+ * ]
203
+ * }
107
204
  */
108
205
  addExtensions?: (this: {
109
206
  name: string;
@@ -112,7 +209,14 @@ declare module '@tiptap/core' {
112
209
  parent: ParentConfig<MarkConfig<Options, Storage>>['addExtensions'];
113
210
  }) => Extensions;
114
211
  /**
115
- * Extend Node Schema
212
+ * This function extends the schema of the node.
213
+ * @example
214
+ * extendNodeSchema() {
215
+ * return {
216
+ * group: 'inline',
217
+ * selectable: false,
218
+ * }
219
+ * }
116
220
  */
117
221
  extendNodeSchema?: ((this: {
118
222
  name: string;
@@ -121,7 +225,14 @@ declare module '@tiptap/core' {
121
225
  parent: ParentConfig<MarkConfig<Options, Storage>>['extendNodeSchema'];
122
226
  }, extension: Node) => Record<string, any>) | null;
123
227
  /**
124
- * Extend Mark Schema
228
+ * This function extends the schema of the mark.
229
+ * @example
230
+ * extendMarkSchema() {
231
+ * return {
232
+ * group: 'inline',
233
+ * selectable: false,
234
+ * }
235
+ * }
125
236
  */
126
237
  extendMarkSchema?: ((this: {
127
238
  name: string;
@@ -316,6 +427,10 @@ declare module '@tiptap/core' {
316
427
  }) => Attributes | {};
317
428
  }
318
429
  }
430
+ /**
431
+ * The Mark class is used to create custom mark extensions.
432
+ * @see https://tiptap.dev/api/extensions#create-a-new-extension
433
+ */
319
434
  export declare class Mark<Options = any, Storage = any> {
320
435
  type: string;
321
436
  name: string;