@tiptap/core 2.5.0-beta.2 → 2.5.0-beta.3

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 (179) hide show
  1. package/dist/index.cjs +4534 -4538
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.js +4534 -4536
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.umd.js +4534 -4538
  6. package/dist/index.umd.js.map +1 -1
  7. package/dist/packages/core/src/CommandManager.d.ts +20 -20
  8. package/dist/packages/core/src/Editor.d.ts +161 -161
  9. package/dist/packages/core/src/EventEmitter.d.ts +11 -11
  10. package/dist/packages/core/src/Extension.d.ts +343 -342
  11. package/dist/packages/core/src/ExtensionManager.d.ts +55 -55
  12. package/dist/packages/core/src/InputRule.d.ts +42 -42
  13. package/dist/packages/core/src/Mark.d.ts +451 -450
  14. package/dist/packages/core/src/Node.d.ts +611 -609
  15. package/dist/packages/core/src/NodePos.d.ts +44 -44
  16. package/dist/packages/core/src/NodeView.d.ts +31 -31
  17. package/dist/packages/core/src/PasteRule.d.ts +50 -50
  18. package/dist/packages/core/src/Tracker.d.ts +11 -11
  19. package/dist/packages/core/src/commands/blur.d.ts +13 -13
  20. package/dist/packages/core/src/commands/clearContent.d.ts +14 -14
  21. package/dist/packages/core/src/commands/clearNodes.d.ts +13 -13
  22. package/dist/packages/core/src/commands/command.d.ts +18 -18
  23. package/dist/packages/core/src/commands/createParagraphNear.d.ts +13 -13
  24. package/dist/packages/core/src/commands/cut.d.ts +20 -20
  25. package/dist/packages/core/src/commands/deleteCurrentNode.d.ts +13 -13
  26. package/dist/packages/core/src/commands/deleteNode.d.ts +15 -15
  27. package/dist/packages/core/src/commands/deleteRange.d.ts +14 -14
  28. package/dist/packages/core/src/commands/deleteSelection.d.ts +13 -13
  29. package/dist/packages/core/src/commands/enter.d.ts +13 -13
  30. package/dist/packages/core/src/commands/exitCode.d.ts +13 -13
  31. package/dist/packages/core/src/commands/extendMarkRange.d.ts +25 -25
  32. package/dist/packages/core/src/commands/first.d.ts +14 -14
  33. package/dist/packages/core/src/commands/focus.d.ts +27 -27
  34. package/dist/packages/core/src/commands/forEach.d.ts +14 -14
  35. package/dist/packages/core/src/commands/index.d.ts +55 -55
  36. package/dist/packages/core/src/commands/insertContent.d.ts +34 -34
  37. package/dist/packages/core/src/commands/insertContentAt.d.ts +47 -47
  38. package/dist/packages/core/src/commands/join.d.ts +41 -41
  39. package/dist/packages/core/src/commands/joinItemBackward.d.ts +13 -13
  40. package/dist/packages/core/src/commands/joinItemForward.d.ts +13 -13
  41. package/dist/packages/core/src/commands/joinTextblockBackward.d.ts +12 -12
  42. package/dist/packages/core/src/commands/joinTextblockForward.d.ts +12 -12
  43. package/dist/packages/core/src/commands/keyboardShortcut.d.ts +14 -14
  44. package/dist/packages/core/src/commands/lift.d.ts +17 -17
  45. package/dist/packages/core/src/commands/liftEmptyBlock.d.ts +13 -13
  46. package/dist/packages/core/src/commands/liftListItem.d.ts +15 -15
  47. package/dist/packages/core/src/commands/newlineInCode.d.ts +13 -13
  48. package/dist/packages/core/src/commands/resetAttributes.d.ts +16 -16
  49. package/dist/packages/core/src/commands/scrollIntoView.d.ts +13 -13
  50. package/dist/packages/core/src/commands/selectAll.d.ts +13 -13
  51. package/dist/packages/core/src/commands/selectNodeBackward.d.ts +13 -13
  52. package/dist/packages/core/src/commands/selectNodeForward.d.ts +13 -13
  53. package/dist/packages/core/src/commands/selectParentNode.d.ts +13 -13
  54. package/dist/packages/core/src/commands/selectTextblockEnd.d.ts +13 -13
  55. package/dist/packages/core/src/commands/selectTextblockStart.d.ts +13 -13
  56. package/dist/packages/core/src/commands/setContent.d.ts +40 -40
  57. package/dist/packages/core/src/commands/setMark.d.ts +15 -15
  58. package/dist/packages/core/src/commands/setMeta.d.ts +15 -15
  59. package/dist/packages/core/src/commands/setNode.d.ts +16 -16
  60. package/dist/packages/core/src/commands/setNodeSelection.d.ts +14 -14
  61. package/dist/packages/core/src/commands/setTextSelection.d.ts +14 -14
  62. package/dist/packages/core/src/commands/sinkListItem.d.ts +15 -15
  63. package/dist/packages/core/src/commands/splitBlock.d.ts +17 -17
  64. package/dist/packages/core/src/commands/splitListItem.d.ts +15 -15
  65. package/dist/packages/core/src/commands/toggleList.d.ts +18 -18
  66. package/dist/packages/core/src/commands/toggleMark.d.ts +30 -30
  67. package/dist/packages/core/src/commands/toggleNode.d.ts +17 -17
  68. package/dist/packages/core/src/commands/toggleWrap.d.ts +16 -16
  69. package/dist/packages/core/src/commands/undoInputRule.d.ts +13 -13
  70. package/dist/packages/core/src/commands/unsetAllMarks.d.ts +13 -13
  71. package/dist/packages/core/src/commands/unsetMark.d.ts +25 -25
  72. package/dist/packages/core/src/commands/updateAttributes.d.ts +24 -24
  73. package/dist/packages/core/src/commands/wrapIn.d.ts +16 -16
  74. package/dist/packages/core/src/commands/wrapInList.d.ts +16 -16
  75. package/dist/packages/core/src/extensions/clipboardTextSerializer.d.ts +5 -5
  76. package/dist/packages/core/src/extensions/commands.d.ts +3 -3
  77. package/dist/packages/core/src/extensions/editable.d.ts +2 -2
  78. package/dist/packages/core/src/extensions/focusEvents.d.ts +2 -2
  79. package/dist/packages/core/src/extensions/index.d.ts +6 -6
  80. package/dist/packages/core/src/extensions/keymap.d.ts +2 -2
  81. package/dist/packages/core/src/extensions/tabindex.d.ts +2 -2
  82. package/dist/packages/core/src/helpers/combineTransactionSteps.d.ts +10 -10
  83. package/dist/packages/core/src/helpers/createChainableState.d.ts +10 -10
  84. package/dist/packages/core/src/helpers/createDocument.d.ts +12 -12
  85. package/dist/packages/core/src/helpers/createNodeFromContent.d.ts +15 -15
  86. package/dist/packages/core/src/helpers/defaultBlockAt.d.ts +7 -7
  87. package/dist/packages/core/src/helpers/findChildren.d.ts +9 -9
  88. package/dist/packages/core/src/helpers/findChildrenInRange.d.ts +10 -10
  89. package/dist/packages/core/src/helpers/findParentNode.d.ts +16 -16
  90. package/dist/packages/core/src/helpers/findParentNodeClosestToPos.d.ts +17 -17
  91. package/dist/packages/core/src/helpers/generateHTML.d.ts +8 -8
  92. package/dist/packages/core/src/helpers/generateJSON.d.ts +8 -8
  93. package/dist/packages/core/src/helpers/generateText.d.ts +12 -12
  94. package/dist/packages/core/src/helpers/getAttributes.d.ts +9 -9
  95. package/dist/packages/core/src/helpers/getAttributesFromExtensions.d.ts +6 -6
  96. package/dist/packages/core/src/helpers/getChangedRanges.d.ts +11 -11
  97. package/dist/packages/core/src/helpers/getDebugJSON.d.ts +8 -8
  98. package/dist/packages/core/src/helpers/getExtensionField.d.ts +9 -9
  99. package/dist/packages/core/src/helpers/getHTMLFromFragment.d.ts +2 -2
  100. package/dist/packages/core/src/helpers/getMarkAttributes.d.ts +3 -3
  101. package/dist/packages/core/src/helpers/getMarkRange.d.ts +3 -3
  102. package/dist/packages/core/src/helpers/getMarkType.d.ts +2 -2
  103. package/dist/packages/core/src/helpers/getMarksBetween.d.ts +3 -3
  104. package/dist/packages/core/src/helpers/getNodeAtPosition.d.ts +11 -11
  105. package/dist/packages/core/src/helpers/getNodeAttributes.d.ts +3 -3
  106. package/dist/packages/core/src/helpers/getNodeType.d.ts +2 -2
  107. package/dist/packages/core/src/helpers/getRenderedAttributes.d.ts +3 -3
  108. package/dist/packages/core/src/helpers/getSchema.d.ts +4 -4
  109. package/dist/packages/core/src/helpers/getSchemaByResolvedExtensions.d.ts +10 -10
  110. package/dist/packages/core/src/helpers/getSchemaTypeByName.d.ts +8 -8
  111. package/dist/packages/core/src/helpers/getSchemaTypeNameByName.d.ts +8 -8
  112. package/dist/packages/core/src/helpers/getSplittedAttributes.d.ts +9 -9
  113. package/dist/packages/core/src/helpers/getText.d.ts +15 -15
  114. package/dist/packages/core/src/helpers/getTextBetween.d.ts +14 -14
  115. package/dist/packages/core/src/helpers/getTextContentFromNodes.d.ts +8 -8
  116. package/dist/packages/core/src/helpers/getTextSerializersFromSchema.d.ts +8 -8
  117. package/dist/packages/core/src/helpers/index.d.ts +50 -50
  118. package/dist/packages/core/src/helpers/injectExtensionAttributesToParseRule.d.ts +9 -9
  119. package/dist/packages/core/src/helpers/isActive.d.ts +2 -2
  120. package/dist/packages/core/src/helpers/isAtEndOfNode.d.ts +2 -2
  121. package/dist/packages/core/src/helpers/isAtStartOfNode.d.ts +2 -2
  122. package/dist/packages/core/src/helpers/isExtensionRulesEnabled.d.ts +2 -2
  123. package/dist/packages/core/src/helpers/isList.d.ts +2 -2
  124. package/dist/packages/core/src/helpers/isMarkActive.d.ts +3 -3
  125. package/dist/packages/core/src/helpers/isNodeActive.d.ts +3 -3
  126. package/dist/packages/core/src/helpers/isNodeEmpty.d.ts +2 -2
  127. package/dist/packages/core/src/helpers/isNodeSelection.d.ts +2 -2
  128. package/dist/packages/core/src/helpers/isTextSelection.d.ts +2 -2
  129. package/dist/packages/core/src/helpers/posToDOMRect.d.ts +2 -2
  130. package/dist/packages/core/src/helpers/resolveFocusPosition.d.ts +4 -4
  131. package/dist/packages/core/src/helpers/selectionToInsertionEnd.d.ts +2 -2
  132. package/dist/packages/core/src/helpers/splitExtensions.d.ts +9 -9
  133. package/dist/packages/core/src/index.d.ts +24 -24
  134. package/dist/packages/core/src/inputRules/index.d.ts +5 -5
  135. package/dist/packages/core/src/inputRules/markInputRule.d.ts +13 -13
  136. package/dist/packages/core/src/inputRules/nodeInputRule.d.ts +23 -23
  137. package/dist/packages/core/src/inputRules/textInputRule.d.ts +10 -10
  138. package/dist/packages/core/src/inputRules/textblockTypeInputRule.d.ts +15 -15
  139. package/dist/packages/core/src/inputRules/wrappingInputRule.d.ts +28 -28
  140. package/dist/packages/core/src/pasteRules/index.d.ts +3 -3
  141. package/dist/packages/core/src/pasteRules/markPasteRule.d.ts +13 -13
  142. package/dist/packages/core/src/pasteRules/nodePasteRule.d.ts +13 -13
  143. package/dist/packages/core/src/pasteRules/textPasteRule.d.ts +10 -10
  144. package/dist/packages/core/src/style.d.ts +1 -1
  145. package/dist/packages/core/src/types.d.ts +250 -244
  146. package/dist/packages/core/src/utilities/callOrReturn.d.ts +9 -9
  147. package/dist/packages/core/src/utilities/createStyleTag.d.ts +1 -1
  148. package/dist/packages/core/src/utilities/deleteProps.d.ts +6 -6
  149. package/dist/packages/core/src/utilities/elementFromString.d.ts +1 -1
  150. package/dist/packages/core/src/utilities/escapeForRegEx.d.ts +1 -1
  151. package/dist/packages/core/src/utilities/findDuplicates.d.ts +1 -1
  152. package/dist/packages/core/src/utilities/fromString.d.ts +1 -1
  153. package/dist/packages/core/src/utilities/index.d.ts +20 -20
  154. package/dist/packages/core/src/utilities/isAndroid.d.ts +1 -1
  155. package/dist/packages/core/src/utilities/isEmptyObject.d.ts +1 -1
  156. package/dist/packages/core/src/utilities/isFunction.d.ts +1 -1
  157. package/dist/packages/core/src/utilities/isMacOS.d.ts +1 -1
  158. package/dist/packages/core/src/utilities/isNumber.d.ts +1 -1
  159. package/dist/packages/core/src/utilities/isPlainObject.d.ts +1 -1
  160. package/dist/packages/core/src/utilities/isRegExp.d.ts +1 -1
  161. package/dist/packages/core/src/utilities/isString.d.ts +1 -1
  162. package/dist/packages/core/src/utilities/isiOS.d.ts +1 -1
  163. package/dist/packages/core/src/utilities/mergeAttributes.d.ts +1 -1
  164. package/dist/packages/core/src/utilities/mergeDeep.d.ts +1 -1
  165. package/dist/packages/core/src/utilities/minMax.d.ts +1 -1
  166. package/dist/packages/core/src/utilities/objectIncludes.d.ts +8 -8
  167. package/dist/packages/core/src/utilities/removeDuplicates.d.ts +8 -8
  168. package/package.json +2 -2
  169. package/src/Extension.ts +3 -1
  170. package/src/ExtensionManager.ts +1 -1
  171. package/src/Mark.ts +3 -1
  172. package/src/Node.ts +4 -1
  173. package/src/commands/insertContentAt.ts +1 -1
  174. package/src/helpers/getAttributesFromExtensions.ts +2 -3
  175. package/src/helpers/getSchemaByResolvedExtensions.ts +4 -2
  176. package/src/helpers/injectExtensionAttributesToParseRule.ts +4 -4
  177. package/src/helpers/isNodeEmpty.ts +6 -3
  178. package/src/types.ts +6 -0
  179. package/src/utilities/mergeDeep.ts +3 -7
@@ -1,609 +1,611 @@
1
- import { DOMOutputSpec, Node as ProseMirrorNode, NodeSpec, NodeType } from '@tiptap/pm/model';
2
- import { Plugin, Transaction } from '@tiptap/pm/state';
3
- import { Editor } from './Editor.js';
4
- import { NodeConfig } from './index.js';
5
- import { InputRule } from './InputRule.js';
6
- import { PasteRule } from './PasteRule.js';
7
- import { Attributes, Extensions, GlobalAttributes, KeyboardShortcutCommand, NodeViewRenderer, ParentConfig, RawCommands } from './types.js';
8
- declare module '@tiptap/core' {
9
- interface NodeConfig<Options = any, Storage = any> {
10
- [key: string]: any;
11
- /**
12
- * The extension name - this must be unique.
13
- * It will be used to identify the extension.
14
- *
15
- * @example 'myExtension'
16
- */
17
- name: string;
18
- /**
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
23
- */
24
- priority?: number;
25
- /**
26
- * The default options for this extension.
27
- * @example
28
- * defaultOptions: {
29
- * myOption: 'foo',
30
- * myOtherOption: 10,
31
- * }
32
- */
33
- defaultOptions?: Options;
34
- /**
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
- * }
43
- */
44
- addOptions?: (this: {
45
- name: string;
46
- parent: Exclude<ParentConfig<NodeConfig<Options, Storage>>['addOptions'], undefined>;
47
- }) => Options;
48
- /**
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
- * }
56
- */
57
- addStorage?: (this: {
58
- name: string;
59
- options: Options;
60
- parent: Exclude<ParentConfig<NodeConfig<Options, Storage>>['addStorage'], undefined>;
61
- }) => Storage;
62
- /**
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
- * }
87
- */
88
- addGlobalAttributes?: (this: {
89
- name: string;
90
- options: Options;
91
- storage: Storage;
92
- parent: ParentConfig<NodeConfig<Options, Storage>>['addGlobalAttributes'];
93
- }) => GlobalAttributes | {};
94
- /**
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
- * }
103
- */
104
- addCommands?: (this: {
105
- name: string;
106
- options: Options;
107
- storage: Storage;
108
- editor: Editor;
109
- type: NodeType;
110
- parent: ParentConfig<NodeConfig<Options, Storage>>['addCommands'];
111
- }) => Partial<RawCommands>;
112
- /**
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
- * },
121
- */
122
- addKeyboardShortcuts?: (this: {
123
- name: string;
124
- options: Options;
125
- storage: Storage;
126
- editor: Editor;
127
- type: NodeType;
128
- parent: ParentConfig<NodeConfig<Options, Storage>>['addKeyboardShortcuts'];
129
- }) => {
130
- [key: string]: KeyboardShortcutCommand;
131
- };
132
- /**
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
- * },
144
- */
145
- addInputRules?: (this: {
146
- name: string;
147
- options: Options;
148
- storage: Storage;
149
- editor: Editor;
150
- type: NodeType;
151
- parent: ParentConfig<NodeConfig<Options, Storage>>['addInputRules'];
152
- }) => InputRule[];
153
- /**
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
- * },
165
- */
166
- addPasteRules?: (this: {
167
- name: string;
168
- options: Options;
169
- storage: Storage;
170
- editor: Editor;
171
- type: NodeType;
172
- parent: ParentConfig<NodeConfig<Options, Storage>>['addPasteRules'];
173
- }) => PasteRule[];
174
- /**
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
- * }
183
- */
184
- addProseMirrorPlugins?: (this: {
185
- name: string;
186
- options: Options;
187
- storage: Storage;
188
- editor: Editor;
189
- type: NodeType;
190
- parent: ParentConfig<NodeConfig<Options, Storage>>['addProseMirrorPlugins'];
191
- }) => Plugin[];
192
- /**
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
- * }
203
- */
204
- addExtensions?: (this: {
205
- name: string;
206
- options: Options;
207
- storage: Storage;
208
- parent: ParentConfig<NodeConfig<Options, Storage>>['addExtensions'];
209
- }) => Extensions;
210
- /**
211
- * This function extends the schema of the node.
212
- * @example
213
- * extendNodeSchema() {
214
- * return {
215
- * group: 'inline',
216
- * selectable: false,
217
- * }
218
- * }
219
- */
220
- extendNodeSchema?: ((this: {
221
- name: string;
222
- options: Options;
223
- storage: Storage;
224
- parent: ParentConfig<NodeConfig<Options, Storage>>['extendNodeSchema'];
225
- }, extension: Node) => Record<string, any>) | null;
226
- /**
227
- * This function extends the schema of the mark.
228
- * @example
229
- * extendMarkSchema() {
230
- * return {
231
- * group: 'inline',
232
- * selectable: false,
233
- * }
234
- * }
235
- */
236
- extendMarkSchema?: ((this: {
237
- name: string;
238
- options: Options;
239
- storage: Storage;
240
- parent: ParentConfig<NodeConfig<Options, Storage>>['extendMarkSchema'];
241
- editor?: Editor;
242
- }, extension: Node) => Record<string, any>) | null;
243
- /**
244
- * The editor is not ready yet.
245
- */
246
- onBeforeCreate?: ((this: {
247
- name: string;
248
- options: Options;
249
- storage: Storage;
250
- editor: Editor;
251
- type: NodeType;
252
- parent: ParentConfig<NodeConfig<Options, Storage>>['onBeforeCreate'];
253
- }) => void) | null;
254
- /**
255
- * The editor is ready.
256
- */
257
- onCreate?: ((this: {
258
- name: string;
259
- options: Options;
260
- storage: Storage;
261
- editor: Editor;
262
- type: NodeType;
263
- parent: ParentConfig<NodeConfig<Options, Storage>>['onCreate'];
264
- }) => void) | null;
265
- /**
266
- * The content has changed.
267
- */
268
- onUpdate?: ((this: {
269
- name: string;
270
- options: Options;
271
- storage: Storage;
272
- editor: Editor;
273
- type: NodeType;
274
- parent: ParentConfig<NodeConfig<Options, Storage>>['onUpdate'];
275
- }) => void) | null;
276
- /**
277
- * The selection has changed.
278
- */
279
- onSelectionUpdate?: ((this: {
280
- name: string;
281
- options: Options;
282
- storage: Storage;
283
- editor: Editor;
284
- type: NodeType;
285
- parent: ParentConfig<NodeConfig<Options, Storage>>['onSelectionUpdate'];
286
- }) => void) | null;
287
- /**
288
- * The editor state has changed.
289
- */
290
- onTransaction?: ((this: {
291
- name: string;
292
- options: Options;
293
- storage: Storage;
294
- editor: Editor;
295
- type: NodeType;
296
- parent: ParentConfig<NodeConfig<Options, Storage>>['onTransaction'];
297
- }, props: {
298
- transaction: Transaction;
299
- }) => void) | null;
300
- /**
301
- * The editor is focused.
302
- */
303
- onFocus?: ((this: {
304
- name: string;
305
- options: Options;
306
- storage: Storage;
307
- editor: Editor;
308
- type: NodeType;
309
- parent: ParentConfig<NodeConfig<Options, Storage>>['onFocus'];
310
- }, props: {
311
- event: FocusEvent;
312
- }) => void) | null;
313
- /**
314
- * The editor isn’t focused anymore.
315
- */
316
- onBlur?: ((this: {
317
- name: string;
318
- options: Options;
319
- storage: Storage;
320
- editor: Editor;
321
- type: NodeType;
322
- parent: ParentConfig<NodeConfig<Options, Storage>>['onBlur'];
323
- }, props: {
324
- event: FocusEvent;
325
- }) => void) | null;
326
- /**
327
- * The editor is destroyed.
328
- */
329
- onDestroy?: ((this: {
330
- name: string;
331
- options: Options;
332
- storage: Storage;
333
- editor: Editor;
334
- type: NodeType;
335
- parent: ParentConfig<NodeConfig<Options, Storage>>['onDestroy'];
336
- }) => void) | null;
337
- /**
338
- * Node View
339
- */
340
- addNodeView?: ((this: {
341
- name: string;
342
- options: Options;
343
- storage: Storage;
344
- editor: Editor;
345
- type: NodeType;
346
- parent: ParentConfig<NodeConfig<Options, Storage>>['addNodeView'];
347
- }) => NodeViewRenderer) | null;
348
- /**
349
- * Defines if this node should be a top level node (doc)
350
- * @default false
351
- * @example true
352
- */
353
- topNode?: boolean;
354
- /**
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*'
364
- */
365
- content?: NodeSpec['content'] | ((this: {
366
- name: string;
367
- options: Options;
368
- storage: Storage;
369
- parent: ParentConfig<NodeConfig<Options, Storage>>['content'];
370
- editor?: Editor;
371
- }) => NodeSpec['content']);
372
- /**
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'
380
- */
381
- marks?: NodeSpec['marks'] | ((this: {
382
- name: string;
383
- options: Options;
384
- storage: Storage;
385
- parent: ParentConfig<NodeConfig<Options, Storage>>['marks'];
386
- editor?: Editor;
387
- }) => NodeSpec['marks']);
388
- /**
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
399
- */
400
- group?: NodeSpec['group'] | ((this: {
401
- name: string;
402
- options: Options;
403
- storage: Storage;
404
- parent: ParentConfig<NodeConfig<Options, Storage>>['group'];
405
- editor?: Editor;
406
- }) => NodeSpec['group']);
407
- /**
408
- * Should be set to true for inline nodes. (Implied for text nodes.)
409
- */
410
- inline?: NodeSpec['inline'] | ((this: {
411
- name: string;
412
- options: Options;
413
- storage: Storage;
414
- parent: ParentConfig<NodeConfig<Options, Storage>>['inline'];
415
- editor?: Editor;
416
- }) => NodeSpec['inline']);
417
- /**
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
423
- */
424
- atom?: NodeSpec['atom'] | ((this: {
425
- name: string;
426
- options: Options;
427
- storage: Storage;
428
- parent: ParentConfig<NodeConfig<Options, Storage>>['atom'];
429
- editor?: Editor;
430
- }) => NodeSpec['atom']);
431
- /**
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
438
- */
439
- selectable?: NodeSpec['selectable'] | ((this: {
440
- name: string;
441
- options: Options;
442
- storage: Storage;
443
- parent: ParentConfig<NodeConfig<Options, Storage>>['selectable'];
444
- editor?: Editor;
445
- }) => NodeSpec['selectable']);
446
- /**
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
452
- */
453
- draggable?: NodeSpec['draggable'] | ((this: {
454
- name: string;
455
- options: Options;
456
- storage: Storage;
457
- parent: ParentConfig<NodeConfig<Options, Storage>>['draggable'];
458
- editor?: Editor;
459
- }) => NodeSpec['draggable']);
460
- /**
461
- * Can be used to indicate that this node contains code, which
462
- * causes some commands to behave differently.
463
- */
464
- code?: NodeSpec['code'] | ((this: {
465
- name: string;
466
- options: Options;
467
- storage: Storage;
468
- parent: ParentConfig<NodeConfig<Options, Storage>>['code'];
469
- editor?: Editor;
470
- }) => NodeSpec['code']);
471
- /**
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.
481
- */
482
- whitespace?: NodeSpec['whitespace'] | ((this: {
483
- name: string;
484
- options: Options;
485
- storage: Storage;
486
- parent: ParentConfig<NodeConfig<Options, Storage>>['whitespace'];
487
- editor?: Editor;
488
- }) => NodeSpec['whitespace']);
489
- /**
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
496
- */
497
- defining?: NodeSpec['defining'] | ((this: {
498
- name: string;
499
- options: Options;
500
- storage: Storage;
501
- parent: ParentConfig<NodeConfig<Options, Storage>>['defining'];
502
- editor?: Editor;
503
- }) => NodeSpec['defining']);
504
- /**
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.
509
- */
510
- isolating?: NodeSpec['isolating'] | ((this: {
511
- name: string;
512
- options: Options;
513
- storage: Storage;
514
- parent: ParentConfig<NodeConfig<Options, Storage>>['isolating'];
515
- editor?: Editor;
516
- }) => NodeSpec['isolating']);
517
- /**
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' } }]
526
- */
527
- parseHTML?: (this: {
528
- name: string;
529
- options: Options;
530
- storage: Storage;
531
- parent: ParentConfig<NodeConfig<Options, Storage>>['parseHTML'];
532
- editor?: Editor;
533
- }) => NodeSpec['parseDOM'];
534
- /**
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]
553
- */
554
- renderHTML?: ((this: {
555
- name: string;
556
- options: Options;
557
- storage: Storage;
558
- parent: ParentConfig<NodeConfig<Options, Storage>>['renderHTML'];
559
- editor?: Editor;
560
- }, props: {
561
- node: ProseMirrorNode;
562
- HTMLAttributes: Record<string, any>;
563
- }) => DOMOutputSpec) | null;
564
- /**
565
- * renders the node as text
566
- * @example renderText: () => 'foo
567
- */
568
- renderText?: ((this: {
569
- name: string;
570
- options: Options;
571
- storage: Storage;
572
- parent: ParentConfig<NodeConfig<Options, Storage>>['renderText'];
573
- editor?: Editor;
574
- }, props: {
575
- node: ProseMirrorNode;
576
- pos: number;
577
- parent: ProseMirrorNode;
578
- index: number;
579
- }) => string) | null;
580
- /**
581
- * Add attributes to the node
582
- * @example addAttributes: () => ({ class: 'foo' })
583
- */
584
- addAttributes?: (this: {
585
- name: string;
586
- options: Options;
587
- storage: Storage;
588
- parent: ParentConfig<NodeConfig<Options, Storage>>['addAttributes'];
589
- editor?: Editor;
590
- }) => Attributes | {};
591
- }
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
- */
597
- export declare class Node<Options = any, Storage = any> {
598
- type: string;
599
- name: string;
600
- parent: Node | null;
601
- child: Node | null;
602
- options: Options;
603
- storage: Storage;
604
- config: NodeConfig;
605
- constructor(config?: Partial<NodeConfig<Options, Storage>>);
606
- static create<O = any, S = any>(config?: Partial<NodeConfig<O, S>>): Node<O, S>;
607
- configure(options?: Partial<Options>): Node<Options, Storage>;
608
- extend<ExtendedOptions = Options, ExtendedStorage = Storage>(extendedConfig?: Partial<NodeConfig<ExtendedOptions, ExtendedStorage>>): Node<ExtendedOptions, ExtendedStorage>;
609
- }
1
+ import { DOMOutputSpec, Node as ProseMirrorNode, NodeSpec, NodeType } from '@tiptap/pm/model';
2
+ import { Plugin, Transaction } from '@tiptap/pm/state';
3
+ import { Editor } from './Editor.js';
4
+ import { NodeConfig } from './index.js';
5
+ import { InputRule } from './InputRule.js';
6
+ import { Mark } from './Mark.js';
7
+ import { PasteRule } from './PasteRule.js';
8
+ import { Attributes, Extensions, GlobalAttributes, KeyboardShortcutCommand, NodeViewRenderer, ParentConfig, RawCommands } from './types.js';
9
+ declare module '@tiptap/core' {
10
+ interface NodeConfig<Options = any, Storage = any> {
11
+ [key: string]: any;
12
+ /**
13
+ * The extension name - this must be unique.
14
+ * It will be used to identify the extension.
15
+ *
16
+ * @example 'myExtension'
17
+ */
18
+ name: string;
19
+ /**
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
24
+ */
25
+ priority?: number;
26
+ /**
27
+ * The default options for this extension.
28
+ * @example
29
+ * defaultOptions: {
30
+ * myOption: 'foo',
31
+ * myOtherOption: 10,
32
+ * }
33
+ */
34
+ defaultOptions?: Options;
35
+ /**
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
+ * }
44
+ */
45
+ addOptions?: (this: {
46
+ name: string;
47
+ parent: Exclude<ParentConfig<NodeConfig<Options, Storage>>['addOptions'], undefined>;
48
+ }) => Options;
49
+ /**
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
+ * }
57
+ */
58
+ addStorage?: (this: {
59
+ name: string;
60
+ options: Options;
61
+ parent: Exclude<ParentConfig<NodeConfig<Options, Storage>>['addStorage'], undefined>;
62
+ }) => Storage;
63
+ /**
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
+ * }
88
+ */
89
+ addGlobalAttributes?: (this: {
90
+ name: string;
91
+ options: Options;
92
+ storage: Storage;
93
+ extensions: (Node | Mark)[];
94
+ parent: ParentConfig<NodeConfig<Options, Storage>>['addGlobalAttributes'];
95
+ }) => GlobalAttributes;
96
+ /**
97
+ * This function adds commands to the editor
98
+ * @see https://tiptap.dev/guide/custom-extensions#keyboard-shortcuts
99
+ * @example
100
+ * addCommands() {
101
+ * return {
102
+ * myCommand: () => ({ chain }) => chain().setMark('type', 'foo').run(),
103
+ * }
104
+ * }
105
+ */
106
+ addCommands?: (this: {
107
+ name: string;
108
+ options: Options;
109
+ storage: Storage;
110
+ editor: Editor;
111
+ type: NodeType;
112
+ parent: ParentConfig<NodeConfig<Options, Storage>>['addCommands'];
113
+ }) => Partial<RawCommands>;
114
+ /**
115
+ * This function registers keyboard shortcuts.
116
+ * @see https://tiptap.dev/guide/custom-extensions#keyboard-shortcuts
117
+ * @example
118
+ * addKeyboardShortcuts() {
119
+ * return {
120
+ * 'Mod-l': () => this.editor.commands.toggleBulletList(),
121
+ * }
122
+ * },
123
+ */
124
+ addKeyboardShortcuts?: (this: {
125
+ name: string;
126
+ options: Options;
127
+ storage: Storage;
128
+ editor: Editor;
129
+ type: NodeType;
130
+ parent: ParentConfig<NodeConfig<Options, Storage>>['addKeyboardShortcuts'];
131
+ }) => {
132
+ [key: string]: KeyboardShortcutCommand;
133
+ };
134
+ /**
135
+ * This function adds input rules to the editor.
136
+ * @see https://tiptap.dev/guide/custom-extensions#input-rules
137
+ * @example
138
+ * addInputRules() {
139
+ * return [
140
+ * markInputRule({
141
+ * find: inputRegex,
142
+ * type: this.type,
143
+ * }),
144
+ * ]
145
+ * },
146
+ */
147
+ addInputRules?: (this: {
148
+ name: string;
149
+ options: Options;
150
+ storage: Storage;
151
+ editor: Editor;
152
+ type: NodeType;
153
+ parent: ParentConfig<NodeConfig<Options, Storage>>['addInputRules'];
154
+ }) => InputRule[];
155
+ /**
156
+ * This function adds paste rules to the editor.
157
+ * @see https://tiptap.dev/guide/custom-extensions#paste-rules
158
+ * @example
159
+ * addPasteRules() {
160
+ * return [
161
+ * markPasteRule({
162
+ * find: pasteRegex,
163
+ * type: this.type,
164
+ * }),
165
+ * ]
166
+ * },
167
+ */
168
+ addPasteRules?: (this: {
169
+ name: string;
170
+ options: Options;
171
+ storage: Storage;
172
+ editor: Editor;
173
+ type: NodeType;
174
+ parent: ParentConfig<NodeConfig<Options, Storage>>['addPasteRules'];
175
+ }) => PasteRule[];
176
+ /**
177
+ * This function adds Prosemirror plugins to the editor
178
+ * @see https://tiptap.dev/guide/custom-extensions#prosemirror-plugins
179
+ * @example
180
+ * addProseMirrorPlugins() {
181
+ * return [
182
+ * customPlugin(),
183
+ * ]
184
+ * }
185
+ */
186
+ addProseMirrorPlugins?: (this: {
187
+ name: string;
188
+ options: Options;
189
+ storage: Storage;
190
+ editor: Editor;
191
+ type: NodeType;
192
+ parent: ParentConfig<NodeConfig<Options, Storage>>['addProseMirrorPlugins'];
193
+ }) => Plugin[];
194
+ /**
195
+ * This function adds additional extensions to the editor. This is useful for
196
+ * building extension kits.
197
+ * @example
198
+ * addExtensions() {
199
+ * return [
200
+ * BulletList,
201
+ * OrderedList,
202
+ * ListItem
203
+ * ]
204
+ * }
205
+ */
206
+ addExtensions?: (this: {
207
+ name: string;
208
+ options: Options;
209
+ storage: Storage;
210
+ parent: ParentConfig<NodeConfig<Options, Storage>>['addExtensions'];
211
+ }) => Extensions;
212
+ /**
213
+ * This function extends the schema of the node.
214
+ * @example
215
+ * extendNodeSchema() {
216
+ * return {
217
+ * group: 'inline',
218
+ * selectable: false,
219
+ * }
220
+ * }
221
+ */
222
+ extendNodeSchema?: ((this: {
223
+ name: string;
224
+ options: Options;
225
+ storage: Storage;
226
+ parent: ParentConfig<NodeConfig<Options, Storage>>['extendNodeSchema'];
227
+ }, extension: Node) => Record<string, any>) | null;
228
+ /**
229
+ * This function extends the schema of the mark.
230
+ * @example
231
+ * extendMarkSchema() {
232
+ * return {
233
+ * group: 'inline',
234
+ * selectable: false,
235
+ * }
236
+ * }
237
+ */
238
+ extendMarkSchema?: ((this: {
239
+ name: string;
240
+ options: Options;
241
+ storage: Storage;
242
+ parent: ParentConfig<NodeConfig<Options, Storage>>['extendMarkSchema'];
243
+ editor?: Editor;
244
+ }, extension: Node) => Record<string, any>) | null;
245
+ /**
246
+ * The editor is not ready yet.
247
+ */
248
+ onBeforeCreate?: ((this: {
249
+ name: string;
250
+ options: Options;
251
+ storage: Storage;
252
+ editor: Editor;
253
+ type: NodeType;
254
+ parent: ParentConfig<NodeConfig<Options, Storage>>['onBeforeCreate'];
255
+ }) => void) | null;
256
+ /**
257
+ * The editor is ready.
258
+ */
259
+ onCreate?: ((this: {
260
+ name: string;
261
+ options: Options;
262
+ storage: Storage;
263
+ editor: Editor;
264
+ type: NodeType;
265
+ parent: ParentConfig<NodeConfig<Options, Storage>>['onCreate'];
266
+ }) => void) | null;
267
+ /**
268
+ * The content has changed.
269
+ */
270
+ onUpdate?: ((this: {
271
+ name: string;
272
+ options: Options;
273
+ storage: Storage;
274
+ editor: Editor;
275
+ type: NodeType;
276
+ parent: ParentConfig<NodeConfig<Options, Storage>>['onUpdate'];
277
+ }) => void) | null;
278
+ /**
279
+ * The selection has changed.
280
+ */
281
+ onSelectionUpdate?: ((this: {
282
+ name: string;
283
+ options: Options;
284
+ storage: Storage;
285
+ editor: Editor;
286
+ type: NodeType;
287
+ parent: ParentConfig<NodeConfig<Options, Storage>>['onSelectionUpdate'];
288
+ }) => void) | null;
289
+ /**
290
+ * The editor state has changed.
291
+ */
292
+ onTransaction?: ((this: {
293
+ name: string;
294
+ options: Options;
295
+ storage: Storage;
296
+ editor: Editor;
297
+ type: NodeType;
298
+ parent: ParentConfig<NodeConfig<Options, Storage>>['onTransaction'];
299
+ }, props: {
300
+ transaction: Transaction;
301
+ }) => void) | null;
302
+ /**
303
+ * The editor is focused.
304
+ */
305
+ onFocus?: ((this: {
306
+ name: string;
307
+ options: Options;
308
+ storage: Storage;
309
+ editor: Editor;
310
+ type: NodeType;
311
+ parent: ParentConfig<NodeConfig<Options, Storage>>['onFocus'];
312
+ }, props: {
313
+ event: FocusEvent;
314
+ }) => void) | null;
315
+ /**
316
+ * The editor isn’t focused anymore.
317
+ */
318
+ onBlur?: ((this: {
319
+ name: string;
320
+ options: Options;
321
+ storage: Storage;
322
+ editor: Editor;
323
+ type: NodeType;
324
+ parent: ParentConfig<NodeConfig<Options, Storage>>['onBlur'];
325
+ }, props: {
326
+ event: FocusEvent;
327
+ }) => void) | null;
328
+ /**
329
+ * The editor is destroyed.
330
+ */
331
+ onDestroy?: ((this: {
332
+ name: string;
333
+ options: Options;
334
+ storage: Storage;
335
+ editor: Editor;
336
+ type: NodeType;
337
+ parent: ParentConfig<NodeConfig<Options, Storage>>['onDestroy'];
338
+ }) => void) | null;
339
+ /**
340
+ * Node View
341
+ */
342
+ addNodeView?: ((this: {
343
+ name: string;
344
+ options: Options;
345
+ storage: Storage;
346
+ editor: Editor;
347
+ type: NodeType;
348
+ parent: ParentConfig<NodeConfig<Options, Storage>>['addNodeView'];
349
+ }) => NodeViewRenderer) | null;
350
+ /**
351
+ * Defines if this node should be a top level node (doc)
352
+ * @default false
353
+ * @example true
354
+ */
355
+ topNode?: boolean;
356
+ /**
357
+ * The content expression for this node, as described in the [schema
358
+ * guide](/docs/guide/#schema.content_expressions). When not given,
359
+ * the node does not allow any content.
360
+ *
361
+ * You can read more about it on the Prosemirror documentation here
362
+ * @see https://prosemirror.net/docs/guide/#schema.content_expressions
363
+ * @default undefined
364
+ * @example content: 'block+'
365
+ * @example content: 'headline paragraph block*'
366
+ */
367
+ content?: NodeSpec['content'] | ((this: {
368
+ name: string;
369
+ options: Options;
370
+ storage: Storage;
371
+ parent: ParentConfig<NodeConfig<Options, Storage>>['content'];
372
+ editor?: Editor;
373
+ }) => NodeSpec['content']);
374
+ /**
375
+ * The marks that are allowed inside of this node. May be a
376
+ * space-separated string referring to mark names or groups, `"_"`
377
+ * to explicitly allow all marks, or `""` to disallow marks. When
378
+ * not given, nodes with inline content default to allowing all
379
+ * marks, other nodes default to not allowing marks.
380
+ *
381
+ * @example marks: 'strong em'
382
+ */
383
+ marks?: NodeSpec['marks'] | ((this: {
384
+ name: string;
385
+ options: Options;
386
+ storage: Storage;
387
+ parent: ParentConfig<NodeConfig<Options, Storage>>['marks'];
388
+ editor?: Editor;
389
+ }) => NodeSpec['marks']);
390
+ /**
391
+ * The group or space-separated groups to which this node belongs,
392
+ * which can be referred to in the content expressions for the
393
+ * schema.
394
+ *
395
+ * By default Tiptap uses the groups 'block' and 'inline' for nodes. You
396
+ * can also use custom groups if you want to group specific nodes together
397
+ * and handle them in your schema.
398
+ * @example group: 'block'
399
+ * @example group: 'inline'
400
+ * @example group: 'customBlock' // this uses a custom group
401
+ */
402
+ group?: NodeSpec['group'] | ((this: {
403
+ name: string;
404
+ options: Options;
405
+ storage: Storage;
406
+ parent: ParentConfig<NodeConfig<Options, Storage>>['group'];
407
+ editor?: Editor;
408
+ }) => NodeSpec['group']);
409
+ /**
410
+ * Should be set to true for inline nodes. (Implied for text nodes.)
411
+ */
412
+ inline?: NodeSpec['inline'] | ((this: {
413
+ name: string;
414
+ options: Options;
415
+ storage: Storage;
416
+ parent: ParentConfig<NodeConfig<Options, Storage>>['inline'];
417
+ editor?: Editor;
418
+ }) => NodeSpec['inline']);
419
+ /**
420
+ * Can be set to true to indicate that, though this isn't a [leaf
421
+ * node](https://prosemirror.net/docs/ref/#model.NodeType.isLeaf), it doesn't have directly editable
422
+ * content and should be treated as a single unit in the view.
423
+ *
424
+ * @example atom: true
425
+ */
426
+ atom?: NodeSpec['atom'] | ((this: {
427
+ name: string;
428
+ options: Options;
429
+ storage: Storage;
430
+ parent: ParentConfig<NodeConfig<Options, Storage>>['atom'];
431
+ editor?: Editor;
432
+ }) => NodeSpec['atom']);
433
+ /**
434
+ * Controls whether nodes of this type can be selected as a [node
435
+ * selection](https://prosemirror.net/docs/ref/#state.NodeSelection). Defaults to true for non-text
436
+ * nodes.
437
+ *
438
+ * @default true
439
+ * @example selectable: false
440
+ */
441
+ selectable?: NodeSpec['selectable'] | ((this: {
442
+ name: string;
443
+ options: Options;
444
+ storage: Storage;
445
+ parent: ParentConfig<NodeConfig<Options, Storage>>['selectable'];
446
+ editor?: Editor;
447
+ }) => NodeSpec['selectable']);
448
+ /**
449
+ * Determines whether nodes of this type can be dragged without
450
+ * being selected. Defaults to false.
451
+ *
452
+ * @default: false
453
+ * @example: draggable: true
454
+ */
455
+ draggable?: NodeSpec['draggable'] | ((this: {
456
+ name: string;
457
+ options: Options;
458
+ storage: Storage;
459
+ parent: ParentConfig<NodeConfig<Options, Storage>>['draggable'];
460
+ editor?: Editor;
461
+ }) => NodeSpec['draggable']);
462
+ /**
463
+ * Can be used to indicate that this node contains code, which
464
+ * causes some commands to behave differently.
465
+ */
466
+ code?: NodeSpec['code'] | ((this: {
467
+ name: string;
468
+ options: Options;
469
+ storage: Storage;
470
+ parent: ParentConfig<NodeConfig<Options, Storage>>['code'];
471
+ editor?: Editor;
472
+ }) => NodeSpec['code']);
473
+ /**
474
+ * Controls way whitespace in this a node is parsed. The default is
475
+ * `"normal"`, which causes the [DOM parser](https://prosemirror.net/docs/ref/#model.DOMParser) to
476
+ * collapse whitespace in normal mode, and normalize it (replacing
477
+ * newlines and such with spaces) otherwise. `"pre"` causes the
478
+ * parser to preserve spaces inside the node. When this option isn't
479
+ * given, but [`code`](https://prosemirror.net/docs/ref/#model.NodeSpec.code) is true, `whitespace`
480
+ * will default to `"pre"`. Note that this option doesn't influence
481
+ * the way the node is rendered—that should be handled by `toDOM`
482
+ * and/or styling.
483
+ */
484
+ whitespace?: NodeSpec['whitespace'] | ((this: {
485
+ name: string;
486
+ options: Options;
487
+ storage: Storage;
488
+ parent: ParentConfig<NodeConfig<Options, Storage>>['whitespace'];
489
+ editor?: Editor;
490
+ }) => NodeSpec['whitespace']);
491
+ /**
492
+ * When enabled, enables both
493
+ * [`definingAsContext`](https://prosemirror.net/docs/ref/#model.NodeSpec.definingAsContext) and
494
+ * [`definingForContent`](https://prosemirror.net/docs/ref/#model.NodeSpec.definingForContent).
495
+ *
496
+ * @default false
497
+ * @example isolating: true
498
+ */
499
+ defining?: NodeSpec['defining'] | ((this: {
500
+ name: string;
501
+ options: Options;
502
+ storage: Storage;
503
+ parent: ParentConfig<NodeConfig<Options, Storage>>['defining'];
504
+ editor?: Editor;
505
+ }) => NodeSpec['defining']);
506
+ /**
507
+ * When enabled (default is false), the sides of nodes of this type
508
+ * count as boundaries that regular editing operations, like
509
+ * backspacing or lifting, won't cross. An example of a node that
510
+ * should probably have this enabled is a table cell.
511
+ */
512
+ isolating?: NodeSpec['isolating'] | ((this: {
513
+ name: string;
514
+ options: Options;
515
+ storage: Storage;
516
+ parent: ParentConfig<NodeConfig<Options, Storage>>['isolating'];
517
+ editor?: Editor;
518
+ }) => NodeSpec['isolating']);
519
+ /**
520
+ * Associates DOM parser information with this node, which can be
521
+ * used by [`DOMParser.fromSchema`](https://prosemirror.net/docs/ref/#model.DOMParser^fromSchema) to
522
+ * automatically derive a parser. The `node` field in the rules is
523
+ * implied (the name of this node will be filled in automatically).
524
+ * If you supply your own parser, you do not need to also specify
525
+ * parsing rules in your schema.
526
+ *
527
+ * @example parseHTML: [{ tag: 'div', attrs: { 'data-id': 'my-block' } }]
528
+ */
529
+ parseHTML?: (this: {
530
+ name: string;
531
+ options: Options;
532
+ storage: Storage;
533
+ parent: ParentConfig<NodeConfig<Options, Storage>>['parseHTML'];
534
+ editor?: Editor;
535
+ }) => NodeSpec['parseDOM'];
536
+ /**
537
+ * A description of a DOM structure. Can be either a string, which is
538
+ * interpreted as a text node, a DOM node, which is interpreted as
539
+ * itself, a `{dom, contentDOM}` object, or an array.
540
+ *
541
+ * An array describes a DOM element. The first value in the array
542
+ * should be a string—the name of the DOM element, optionally prefixed
543
+ * by a namespace URL and a space. If the second element is plain
544
+ * object, it is interpreted as a set of attributes for the element.
545
+ * Any elements after that (including the 2nd if it's not an attribute
546
+ * object) are interpreted as children of the DOM elements, and must
547
+ * either be valid `DOMOutputSpec` values, or the number zero.
548
+ *
549
+ * The number zero (pronounced “hole”) is used to indicate the place
550
+ * where a node's child nodes should be inserted. If it occurs in an
551
+ * output spec, it should be the only child element in its parent
552
+ * node.
553
+ *
554
+ * @example toDOM: ['div[data-id="my-block"]', { class: 'my-block' }, 0]
555
+ */
556
+ renderHTML?: ((this: {
557
+ name: string;
558
+ options: Options;
559
+ storage: Storage;
560
+ parent: ParentConfig<NodeConfig<Options, Storage>>['renderHTML'];
561
+ editor?: Editor;
562
+ }, props: {
563
+ node: ProseMirrorNode;
564
+ HTMLAttributes: Record<string, any>;
565
+ }) => DOMOutputSpec) | null;
566
+ /**
567
+ * renders the node as text
568
+ * @example renderText: () => 'foo
569
+ */
570
+ renderText?: ((this: {
571
+ name: string;
572
+ options: Options;
573
+ storage: Storage;
574
+ parent: ParentConfig<NodeConfig<Options, Storage>>['renderText'];
575
+ editor?: Editor;
576
+ }, props: {
577
+ node: ProseMirrorNode;
578
+ pos: number;
579
+ parent: ProseMirrorNode;
580
+ index: number;
581
+ }) => string) | null;
582
+ /**
583
+ * Add attributes to the node
584
+ * @example addAttributes: () => ({ class: 'foo' })
585
+ */
586
+ addAttributes?: (this: {
587
+ name: string;
588
+ options: Options;
589
+ storage: Storage;
590
+ parent: ParentConfig<NodeConfig<Options, Storage>>['addAttributes'];
591
+ editor?: Editor;
592
+ }) => Attributes | {};
593
+ }
594
+ }
595
+ /**
596
+ * The Node class is used to create custom node extensions.
597
+ * @see https://tiptap.dev/api/extensions#create-a-new-extension
598
+ */
599
+ export declare class Node<Options = any, Storage = any> {
600
+ type: string;
601
+ name: string;
602
+ parent: Node | null;
603
+ child: Node | null;
604
+ options: Options;
605
+ storage: Storage;
606
+ config: NodeConfig;
607
+ constructor(config?: Partial<NodeConfig<Options, Storage>>);
608
+ static create<O = any, S = any>(config?: Partial<NodeConfig<O, S>>): Node<O, S>;
609
+ configure(options?: Partial<Options>): Node<Options, Storage>;
610
+ extend<ExtendedOptions = Options, ExtendedStorage = Storage>(extendedConfig?: Partial<NodeConfig<ExtendedOptions, ExtendedStorage>>): Node<ExtendedOptions, ExtendedStorage>;
611
+ }