@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
@@ -9,26 +9,50 @@ declare module '@tiptap/core' {
9
9
  interface NodeConfig<Options = any, Storage = any> {
10
10
  [key: string]: any;
11
11
  /**
12
- * Name
12
+ * The extension name - this must be unique.
13
+ * It will be used to identify the extension.
14
+ *
15
+ * @example 'myExtension'
13
16
  */
14
17
  name: string;
15
18
  /**
16
- * Priority
19
+ * The priority of your extension. The higher, the later it will be called
20
+ * and will take precedence over other extensions with a lower priority.
21
+ * @default 1000
22
+ * @example 1001
17
23
  */
18
24
  priority?: number;
19
25
  /**
20
- * Default options
26
+ * The default options for this extension.
27
+ * @example
28
+ * defaultOptions: {
29
+ * myOption: 'foo',
30
+ * myOtherOption: 10,
31
+ * }
21
32
  */
22
33
  defaultOptions?: Options;
23
34
  /**
24
- * Default Options
35
+ * This method will add options to this extension
36
+ * @see https://tiptap.dev/guide/custom-extensions#settings
37
+ * @example
38
+ * addOptions() {
39
+ * return {
40
+ * myOption: 'foo',
41
+ * myOtherOption: 10,
42
+ * }
25
43
  */
26
44
  addOptions?: (this: {
27
45
  name: string;
28
46
  parent: Exclude<ParentConfig<NodeConfig<Options, Storage>>['addOptions'], undefined>;
29
47
  }) => Options;
30
48
  /**
31
- * Default Storage
49
+ * The default storage this extension can save data to.
50
+ * @see https://tiptap.dev/guide/custom-extensions#storage
51
+ * @example
52
+ * defaultStorage: {
53
+ * prefetchedUsers: [],
54
+ * loading: false,
55
+ * }
32
56
  */
33
57
  addStorage?: (this: {
34
58
  name: string;
@@ -36,7 +60,30 @@ declare module '@tiptap/core' {
36
60
  parent: Exclude<ParentConfig<NodeConfig<Options, Storage>>['addStorage'], undefined>;
37
61
  }) => Storage;
38
62
  /**
39
- * Global attributes
63
+ * This function adds globalAttributes to specific nodes.
64
+ * @see https://tiptap.dev/guide/custom-extensions#global-attributes
65
+ * @example
66
+ * addGlobalAttributes() {
67
+ * return [
68
+ * {
69
+ // Extend the following extensions
70
+ * types: [
71
+ * 'heading',
72
+ * 'paragraph',
73
+ * ],
74
+ * // … with those attributes
75
+ * attributes: {
76
+ * textAlign: {
77
+ * default: 'left',
78
+ * renderHTML: attributes => ({
79
+ * style: `text-align: ${attributes.textAlign}`,
80
+ * }),
81
+ * parseHTML: element => element.style.textAlign || 'left',
82
+ * },
83
+ * },
84
+ * },
85
+ * ]
86
+ * }
40
87
  */
41
88
  addGlobalAttributes?: (this: {
42
89
  name: string;
@@ -45,7 +92,14 @@ declare module '@tiptap/core' {
45
92
  parent: ParentConfig<NodeConfig<Options, Storage>>['addGlobalAttributes'];
46
93
  }) => GlobalAttributes | {};
47
94
  /**
48
- * Raw
95
+ * This function adds commands to the editor
96
+ * @see https://tiptap.dev/guide/custom-extensions#keyboard-shortcuts
97
+ * @example
98
+ * addCommands() {
99
+ * return {
100
+ * myCommand: () => ({ chain }) => chain().setMark('type', 'foo').run(),
101
+ * }
102
+ * }
49
103
  */
50
104
  addCommands?: (this: {
51
105
  name: string;
@@ -56,7 +110,14 @@ declare module '@tiptap/core' {
56
110
  parent: ParentConfig<NodeConfig<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;
@@ -69,7 +130,17 @@ declare module '@tiptap/core' {
69
130
  [key: string]: KeyboardShortcutCommand;
70
131
  };
71
132
  /**
72
- * Input rules
133
+ * This function adds input rules to the editor.
134
+ * @see https://tiptap.dev/guide/custom-extensions#input-rules
135
+ * @example
136
+ * addInputRules() {
137
+ * return [
138
+ * markInputRule({
139
+ * find: inputRegex,
140
+ * type: this.type,
141
+ * }),
142
+ * ]
143
+ * },
73
144
  */
74
145
  addInputRules?: (this: {
75
146
  name: string;
@@ -80,7 +151,17 @@ declare module '@tiptap/core' {
80
151
  parent: ParentConfig<NodeConfig<Options, Storage>>['addInputRules'];
81
152
  }) => InputRule[];
82
153
  /**
83
- * Paste rules
154
+ * This function adds paste rules to the editor.
155
+ * @see https://tiptap.dev/guide/custom-extensions#paste-rules
156
+ * @example
157
+ * addPasteRules() {
158
+ * return [
159
+ * markPasteRule({
160
+ * find: pasteRegex,
161
+ * type: this.type,
162
+ * }),
163
+ * ]
164
+ * },
84
165
  */
85
166
  addPasteRules?: (this: {
86
167
  name: string;
@@ -91,7 +172,14 @@ declare module '@tiptap/core' {
91
172
  parent: ParentConfig<NodeConfig<Options, Storage>>['addPasteRules'];
92
173
  }) => PasteRule[];
93
174
  /**
94
- * ProseMirror plugins
175
+ * This function adds Prosemirror plugins to the editor
176
+ * @see https://tiptap.dev/guide/custom-extensions#prosemirror-plugins
177
+ * @example
178
+ * addProseMirrorPlugins() {
179
+ * return [
180
+ * customPlugin(),
181
+ * ]
182
+ * }
95
183
  */
96
184
  addProseMirrorPlugins?: (this: {
97
185
  name: string;
@@ -102,7 +190,16 @@ declare module '@tiptap/core' {
102
190
  parent: ParentConfig<NodeConfig<Options, Storage>>['addProseMirrorPlugins'];
103
191
  }) => Plugin[];
104
192
  /**
105
- * Extensions
193
+ * This function adds additional extensions to the editor. This is useful for
194
+ * building extension kits.
195
+ * @example
196
+ * addExtensions() {
197
+ * return [
198
+ * BulletList,
199
+ * OrderedList,
200
+ * ListItem
201
+ * ]
202
+ * }
106
203
  */
107
204
  addExtensions?: (this: {
108
205
  name: string;
@@ -111,7 +208,14 @@ declare module '@tiptap/core' {
111
208
  parent: ParentConfig<NodeConfig<Options, Storage>>['addExtensions'];
112
209
  }) => Extensions;
113
210
  /**
114
- * Extend Node Schema
211
+ * This function extends the schema of the node.
212
+ * @example
213
+ * extendNodeSchema() {
214
+ * return {
215
+ * group: 'inline',
216
+ * selectable: false,
217
+ * }
218
+ * }
115
219
  */
116
220
  extendNodeSchema?: ((this: {
117
221
  name: string;
@@ -120,7 +224,14 @@ declare module '@tiptap/core' {
120
224
  parent: ParentConfig<NodeConfig<Options, Storage>>['extendNodeSchema'];
121
225
  }, extension: Node) => Record<string, any>) | null;
122
226
  /**
123
- * Extend Mark Schema
227
+ * This function extends the schema of the mark.
228
+ * @example
229
+ * extendMarkSchema() {
230
+ * return {
231
+ * group: 'inline',
232
+ * selectable: false,
233
+ * }
234
+ * }
124
235
  */
125
236
  extendMarkSchema?: ((this: {
126
237
  name: string;
@@ -235,11 +346,21 @@ declare module '@tiptap/core' {
235
346
  parent: ParentConfig<NodeConfig<Options, Storage>>['addNodeView'];
236
347
  }) => NodeViewRenderer) | null;
237
348
  /**
238
- * TopNode
349
+ * Defines if this node should be a top level node (doc)
350
+ * @default false
351
+ * @example true
239
352
  */
240
353
  topNode?: boolean;
241
354
  /**
242
- * Content
355
+ * The content expression for this node, as described in the [schema
356
+ * guide](/docs/guide/#schema.content_expressions). When not given,
357
+ * the node does not allow any content.
358
+ *
359
+ * You can read more about it on the Prosemirror documentation here
360
+ * @see https://prosemirror.net/docs/guide/#schema.content_expressions
361
+ * @default undefined
362
+ * @example content: 'block+'
363
+ * @example content: 'headline paragraph block*'
243
364
  */
244
365
  content?: NodeSpec['content'] | ((this: {
245
366
  name: string;
@@ -249,7 +370,13 @@ declare module '@tiptap/core' {
249
370
  editor?: Editor;
250
371
  }) => NodeSpec['content']);
251
372
  /**
252
- * Marks
373
+ * The marks that are allowed inside of this node. May be a
374
+ * space-separated string referring to mark names or groups, `"_"`
375
+ * to explicitly allow all marks, or `""` to disallow marks. When
376
+ * not given, nodes with inline content default to allowing all
377
+ * marks, other nodes default to not allowing marks.
378
+ *
379
+ * @example marks: 'strong em'
253
380
  */
254
381
  marks?: NodeSpec['marks'] | ((this: {
255
382
  name: string;
@@ -259,7 +386,16 @@ declare module '@tiptap/core' {
259
386
  editor?: Editor;
260
387
  }) => NodeSpec['marks']);
261
388
  /**
262
- * Group
389
+ * The group or space-separated groups to which this node belongs,
390
+ * which can be referred to in the content expressions for the
391
+ * schema.
392
+ *
393
+ * By default Tiptap uses the groups 'block' and 'inline' for nodes. You
394
+ * can also use custom groups if you want to group specific nodes together
395
+ * and handle them in your schema.
396
+ * @example group: 'block'
397
+ * @example group: 'inline'
398
+ * @example group: 'customBlock' // this uses a custom group
263
399
  */
264
400
  group?: NodeSpec['group'] | ((this: {
265
401
  name: string;
@@ -269,7 +405,7 @@ declare module '@tiptap/core' {
269
405
  editor?: Editor;
270
406
  }) => NodeSpec['group']);
271
407
  /**
272
- * Inline
408
+ * Should be set to true for inline nodes. (Implied for text nodes.)
273
409
  */
274
410
  inline?: NodeSpec['inline'] | ((this: {
275
411
  name: string;
@@ -279,7 +415,11 @@ declare module '@tiptap/core' {
279
415
  editor?: Editor;
280
416
  }) => NodeSpec['inline']);
281
417
  /**
282
- * Atom
418
+ * Can be set to true to indicate that, though this isn't a [leaf
419
+ * node](https://prosemirror.net/docs/ref/#model.NodeType.isLeaf), it doesn't have directly editable
420
+ * content and should be treated as a single unit in the view.
421
+ *
422
+ * @example atom: true
283
423
  */
284
424
  atom?: NodeSpec['atom'] | ((this: {
285
425
  name: string;
@@ -289,7 +429,12 @@ declare module '@tiptap/core' {
289
429
  editor?: Editor;
290
430
  }) => NodeSpec['atom']);
291
431
  /**
292
- * Selectable
432
+ * Controls whether nodes of this type can be selected as a [node
433
+ * selection](https://prosemirror.net/docs/ref/#state.NodeSelection). Defaults to true for non-text
434
+ * nodes.
435
+ *
436
+ * @default true
437
+ * @example selectable: false
293
438
  */
294
439
  selectable?: NodeSpec['selectable'] | ((this: {
295
440
  name: string;
@@ -299,7 +444,11 @@ declare module '@tiptap/core' {
299
444
  editor?: Editor;
300
445
  }) => NodeSpec['selectable']);
301
446
  /**
302
- * Draggable
447
+ * Determines whether nodes of this type can be dragged without
448
+ * being selected. Defaults to false.
449
+ *
450
+ * @default: false
451
+ * @example: draggable: true
303
452
  */
304
453
  draggable?: NodeSpec['draggable'] | ((this: {
305
454
  name: string;
@@ -309,7 +458,8 @@ declare module '@tiptap/core' {
309
458
  editor?: Editor;
310
459
  }) => NodeSpec['draggable']);
311
460
  /**
312
- * Code
461
+ * Can be used to indicate that this node contains code, which
462
+ * causes some commands to behave differently.
313
463
  */
314
464
  code?: NodeSpec['code'] | ((this: {
315
465
  name: string;
@@ -319,7 +469,15 @@ declare module '@tiptap/core' {
319
469
  editor?: Editor;
320
470
  }) => NodeSpec['code']);
321
471
  /**
322
- * Whitespace
472
+ * Controls way whitespace in this a node is parsed. The default is
473
+ * `"normal"`, which causes the [DOM parser](https://prosemirror.net/docs/ref/#model.DOMParser) to
474
+ * collapse whitespace in normal mode, and normalize it (replacing
475
+ * newlines and such with spaces) otherwise. `"pre"` causes the
476
+ * parser to preserve spaces inside the node. When this option isn't
477
+ * given, but [`code`](https://prosemirror.net/docs/ref/#model.NodeSpec.code) is true, `whitespace`
478
+ * will default to `"pre"`. Note that this option doesn't influence
479
+ * the way the node is rendered—that should be handled by `toDOM`
480
+ * and/or styling.
323
481
  */
324
482
  whitespace?: NodeSpec['whitespace'] | ((this: {
325
483
  name: string;
@@ -329,7 +487,12 @@ declare module '@tiptap/core' {
329
487
  editor?: Editor;
330
488
  }) => NodeSpec['whitespace']);
331
489
  /**
332
- * Defining
490
+ * When enabled, enables both
491
+ * [`definingAsContext`](https://prosemirror.net/docs/ref/#model.NodeSpec.definingAsContext) and
492
+ * [`definingForContent`](https://prosemirror.net/docs/ref/#model.NodeSpec.definingForContent).
493
+ *
494
+ * @default false
495
+ * @example isolating: true
333
496
  */
334
497
  defining?: NodeSpec['defining'] | ((this: {
335
498
  name: string;
@@ -339,7 +502,10 @@ declare module '@tiptap/core' {
339
502
  editor?: Editor;
340
503
  }) => NodeSpec['defining']);
341
504
  /**
342
- * Isolating
505
+ * When enabled (default is false), the sides of nodes of this type
506
+ * count as boundaries that regular editing operations, like
507
+ * backspacing or lifting, won't cross. An example of a node that
508
+ * should probably have this enabled is a table cell.
343
509
  */
344
510
  isolating?: NodeSpec['isolating'] | ((this: {
345
511
  name: string;
@@ -349,7 +515,14 @@ declare module '@tiptap/core' {
349
515
  editor?: Editor;
350
516
  }) => NodeSpec['isolating']);
351
517
  /**
352
- * Parse HTML
518
+ * Associates DOM parser information with this node, which can be
519
+ * used by [`DOMParser.fromSchema`](https://prosemirror.net/docs/ref/#model.DOMParser^fromSchema) to
520
+ * automatically derive a parser. The `node` field in the rules is
521
+ * implied (the name of this node will be filled in automatically).
522
+ * If you supply your own parser, you do not need to also specify
523
+ * parsing rules in your schema.
524
+ *
525
+ * @example parseHTML: [{ tag: 'div', attrs: { 'data-id': 'my-block' } }]
353
526
  */
354
527
  parseHTML?: (this: {
355
528
  name: string;
@@ -359,7 +532,24 @@ declare module '@tiptap/core' {
359
532
  editor?: Editor;
360
533
  }) => NodeSpec['parseDOM'];
361
534
  /**
362
- * Render HTML
535
+ * A description of a DOM structure. Can be either a string, which is
536
+ * interpreted as a text node, a DOM node, which is interpreted as
537
+ * itself, a `{dom, contentDOM}` object, or an array.
538
+ *
539
+ * An array describes a DOM element. The first value in the array
540
+ * should be a string—the name of the DOM element, optionally prefixed
541
+ * by a namespace URL and a space. If the second element is plain
542
+ * object, it is interpreted as a set of attributes for the element.
543
+ * Any elements after that (including the 2nd if it's not an attribute
544
+ * object) are interpreted as children of the DOM elements, and must
545
+ * either be valid `DOMOutputSpec` values, or the number zero.
546
+ *
547
+ * The number zero (pronounced “hole”) is used to indicate the place
548
+ * where a node's child nodes should be inserted. If it occurs in an
549
+ * output spec, it should be the only child element in its parent
550
+ * node.
551
+ *
552
+ * @example toDOM: ['div[data-id="my-block"]', { class: 'my-block' }, 0]
363
553
  */
364
554
  renderHTML?: ((this: {
365
555
  name: string;
@@ -372,7 +562,8 @@ declare module '@tiptap/core' {
372
562
  HTMLAttributes: Record<string, any>;
373
563
  }) => DOMOutputSpec) | null;
374
564
  /**
375
- * Render Text
565
+ * renders the node as text
566
+ * @example renderText: () => 'foo
376
567
  */
377
568
  renderText?: ((this: {
378
569
  name: string;
@@ -387,7 +578,8 @@ declare module '@tiptap/core' {
387
578
  index: number;
388
579
  }) => string) | null;
389
580
  /**
390
- * Add Attributes
581
+ * Add attributes to the node
582
+ * @example addAttributes: () => ({ class: 'foo' })
391
583
  */
392
584
  addAttributes?: (this: {
393
585
  name: string;
@@ -398,6 +590,10 @@ declare module '@tiptap/core' {
398
590
  }) => Attributes | {};
399
591
  }
400
592
  }
593
+ /**
594
+ * The Node class is used to create custom node extensions.
595
+ * @see https://tiptap.dev/api/extensions#create-a-new-extension
596
+ */
401
597
  export declare class Node<Options = any, Storage = any> {
402
598
  type: string;
403
599
  name: string;
@@ -3,6 +3,10 @@ import { NodeView as ProseMirrorNodeView } from '@tiptap/pm/view';
3
3
  import { Editor as CoreEditor } from './Editor.js';
4
4
  import { Node } from './Node.js';
5
5
  import { DecorationWithType, NodeViewRendererOptions, NodeViewRendererProps } from './types.js';
6
+ /**
7
+ * Node views are used to customize the rendered DOM structure of a node.
8
+ * @see https://tiptap.dev/guide/node-views
9
+ */
6
10
  export declare class NodeView<Component, NodeEditor extends CoreEditor = CoreEditor, Options extends NodeViewRendererOptions = NodeViewRendererOptions> implements ProseMirrorNodeView {
7
11
  component: Component;
8
12
  editor: NodeEditor;
@@ -9,6 +9,10 @@ export declare type PasteRuleMatch = {
9
9
  data?: Record<string, any>;
10
10
  };
11
11
  export declare type PasteRuleFinder = RegExp | ((text: string, event?: ClipboardEvent | null) => PasteRuleMatch[] | null | undefined);
12
+ /**
13
+ * Paste rules are used to react to pasted content.
14
+ * @see https://tiptap.dev/guide/custom-extensions/#paste-rules
15
+ */
12
16
  export declare class PasteRule {
13
17
  find: PasteRuleFinder;
14
18
  handler: (props: {
@@ -4,6 +4,7 @@ declare module '@tiptap/core' {
4
4
  blur: {
5
5
  /**
6
6
  * Removes focus from the editor.
7
+ * @example editor.commands.blur()
7
8
  */
8
9
  blur: () => ReturnType;
9
10
  };
@@ -4,6 +4,8 @@ declare module '@tiptap/core' {
4
4
  clearContent: {
5
5
  /**
6
6
  * Clear the whole document.
7
+ * @param emitUpdate Whether to emit an update event.
8
+ * @example editor.commands.clearContent()
7
9
  */
8
10
  clearContent: (emitUpdate?: boolean) => ReturnType;
9
11
  };
@@ -4,6 +4,7 @@ declare module '@tiptap/core' {
4
4
  clearNodes: {
5
5
  /**
6
6
  * Normalize nodes to a simple paragraph.
7
+ * @example editor.commands.clearNodes()
7
8
  */
8
9
  clearNodes: () => ReturnType;
9
10
  };
@@ -4,6 +4,12 @@ declare module '@tiptap/core' {
4
4
  command: {
5
5
  /**
6
6
  * Define a command inline.
7
+ * @param fn The command function.
8
+ * @example
9
+ * editor.commands.command(({ tr, state }) => {
10
+ * ...
11
+ * return true
12
+ * })
7
13
  */
8
14
  command: (fn: (props: Parameters<Command>[0]) => boolean) => ReturnType;
9
15
  };
@@ -4,6 +4,7 @@ declare module '@tiptap/core' {
4
4
  createParagraphNear: {
5
5
  /**
6
6
  * Create a paragraph nearby.
7
+ * @example editor.commands.createParagraphNear()
7
8
  */
8
9
  createParagraphNear: () => ReturnType;
9
10
  };
@@ -4,6 +4,11 @@ declare module '@tiptap/core' {
4
4
  cut: {
5
5
  /**
6
6
  * Cuts content from a range and inserts it at a given position.
7
+ * @param range The range to cut.
8
+ * @param range.from The start position of the range.
9
+ * @param range.to The end position of the range.
10
+ * @param targetPos The position to insert the content at.
11
+ * @example editor.commands.cut({ from: 1, to: 3 }, 5)
7
12
  */
8
13
  cut: ({ from, to }: {
9
14
  from: number;
@@ -4,6 +4,7 @@ declare module '@tiptap/core' {
4
4
  deleteCurrentNode: {
5
5
  /**
6
6
  * Delete the node that currently has the selection anchor.
7
+ * @example editor.commands.deleteCurrentNode()
7
8
  */
8
9
  deleteCurrentNode: () => ReturnType;
9
10
  };
@@ -4,7 +4,9 @@ declare module '@tiptap/core' {
4
4
  interface Commands<ReturnType> {
5
5
  deleteNode: {
6
6
  /**
7
- * Delete a node.
7
+ * Delete a node with a given type or name.
8
+ * @param typeOrName The type or name of the node.
9
+ * @example editor.commands.deleteNode('paragraph')
8
10
  */
9
11
  deleteNode: (typeOrName: string | NodeType) => ReturnType;
10
12
  };
@@ -4,6 +4,8 @@ declare module '@tiptap/core' {
4
4
  deleteRange: {
5
5
  /**
6
6
  * Delete a given range.
7
+ * @param range The range to delete.
8
+ * @example editor.commands.deleteRange({ from: 1, to: 3 })
7
9
  */
8
10
  deleteRange: (range: Range) => ReturnType;
9
11
  };
@@ -4,6 +4,7 @@ declare module '@tiptap/core' {
4
4
  deleteSelection: {
5
5
  /**
6
6
  * Delete the selection, if there is one.
7
+ * @example editor.commands.deleteSelection()
7
8
  */
8
9
  deleteSelection: () => ReturnType;
9
10
  };
@@ -4,6 +4,7 @@ declare module '@tiptap/core' {
4
4
  enter: {
5
5
  /**
6
6
  * Trigger enter.
7
+ * @example editor.commands.enter()
7
8
  */
8
9
  enter: () => ReturnType;
9
10
  };
@@ -4,6 +4,7 @@ declare module '@tiptap/core' {
4
4
  exitCode: {
5
5
  /**
6
6
  * Exit from a code block.
7
+ * @example editor.commands.exitCode()
7
8
  */
8
9
  exitCode: () => ReturnType;
9
10
  };
@@ -4,9 +4,21 @@ declare module '@tiptap/core' {
4
4
  interface Commands<ReturnType> {
5
5
  extendMarkRange: {
6
6
  /**
7
- * Extends the text selection to the current mark.
7
+ * Extends the text selection to the current mark by type or name.
8
+ * @param typeOrName The type or name of the mark.
9
+ * @param attributes The attributes of the mark.
10
+ * @example editor.commands.extendMarkRange('bold')
11
+ * @example editor.commands.extendMarkRange('mention', { userId: "1" })
8
12
  */
9
- extendMarkRange: (typeOrName: string | MarkType, attributes?: Record<string, any>) => ReturnType;
13
+ extendMarkRange: (
14
+ /**
15
+ * The type or name of the mark.
16
+ */
17
+ typeOrName: string | MarkType,
18
+ /**
19
+ * The attributes of the mark.
20
+ */
21
+ attributes?: Record<string, any>) => ReturnType;
10
22
  };
11
23
  }
12
24
  }
@@ -4,6 +4,8 @@ declare module '@tiptap/core' {
4
4
  first: {
5
5
  /**
6
6
  * Runs one command after the other and stops at the first which returns true.
7
+ * @param commands The commands to run.
8
+ * @example editor.commands.first([command1, command2])
7
9
  */
8
10
  first: (commands: Command[] | ((props: CommandProps) => Command[])) => ReturnType;
9
11
  };
@@ -4,8 +4,21 @@ declare module '@tiptap/core' {
4
4
  focus: {
5
5
  /**
6
6
  * Focus the editor at the given position.
7
+ * @param position The position to focus at.
8
+ * @param options.scrollIntoView Scroll the focused position into view after focusing
9
+ * @example editor.commands.focus()
10
+ * @example editor.commands.focus(32, { scrollIntoView: false })
7
11
  */
8
- focus: (position?: FocusPosition, options?: {
12
+ focus: (
13
+ /**
14
+ * The position to focus at.
15
+ */
16
+ position?: FocusPosition,
17
+ /**
18
+ * Optional options
19
+ * @default { scrollIntoView: true }
20
+ */
21
+ options?: {
9
22
  scrollIntoView?: boolean;
10
23
  }) => ReturnType;
11
24
  };