@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,450 +1,451 @@
1
- import { DOMOutputSpec, Mark as ProseMirrorMark, MarkSpec, MarkType } from '@tiptap/pm/model';
2
- import { Plugin, Transaction } from '@tiptap/pm/state';
3
- import { Editor } from './Editor.js';
4
- import { MarkConfig } from './index.js';
5
- import { InputRule } from './InputRule.js';
6
- import { Node } from './Node.js';
7
- import { PasteRule } from './PasteRule.js';
8
- import { Attributes, Extensions, GlobalAttributes, KeyboardShortcutCommand, ParentConfig, RawCommands } from './types.js';
9
- declare module '@tiptap/core' {
10
- interface MarkConfig<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<MarkConfig<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<MarkConfig<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
- parent: ParentConfig<MarkConfig<Options, Storage>>['addGlobalAttributes'];
94
- }) => GlobalAttributes | {};
95
- /**
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
- * }
104
- */
105
- addCommands?: (this: {
106
- name: string;
107
- options: Options;
108
- storage: Storage;
109
- editor: Editor;
110
- type: MarkType;
111
- parent: ParentConfig<MarkConfig<Options, Storage>>['addCommands'];
112
- }) => Partial<RawCommands>;
113
- /**
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
- * },
122
- */
123
- addKeyboardShortcuts?: (this: {
124
- name: string;
125
- options: Options;
126
- storage: Storage;
127
- editor: Editor;
128
- type: MarkType;
129
- parent: ParentConfig<MarkConfig<Options, Storage>>['addKeyboardShortcuts'];
130
- }) => {
131
- [key: string]: KeyboardShortcutCommand;
132
- };
133
- /**
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
- * },
145
- */
146
- addInputRules?: (this: {
147
- name: string;
148
- options: Options;
149
- storage: Storage;
150
- editor: Editor;
151
- type: MarkType;
152
- parent: ParentConfig<MarkConfig<Options, Storage>>['addInputRules'];
153
- }) => InputRule[];
154
- /**
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
- * },
166
- */
167
- addPasteRules?: (this: {
168
- name: string;
169
- options: Options;
170
- storage: Storage;
171
- editor: Editor;
172
- type: MarkType;
173
- parent: ParentConfig<MarkConfig<Options, Storage>>['addPasteRules'];
174
- }) => PasteRule[];
175
- /**
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
- * }
184
- */
185
- addProseMirrorPlugins?: (this: {
186
- name: string;
187
- options: Options;
188
- storage: Storage;
189
- editor: Editor;
190
- type: MarkType;
191
- parent: ParentConfig<MarkConfig<Options, Storage>>['addProseMirrorPlugins'];
192
- }) => Plugin[];
193
- /**
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
- * }
204
- */
205
- addExtensions?: (this: {
206
- name: string;
207
- options: Options;
208
- storage: Storage;
209
- parent: ParentConfig<MarkConfig<Options, Storage>>['addExtensions'];
210
- }) => Extensions;
211
- /**
212
- * This function extends the schema of the node.
213
- * @example
214
- * extendNodeSchema() {
215
- * return {
216
- * group: 'inline',
217
- * selectable: false,
218
- * }
219
- * }
220
- */
221
- extendNodeSchema?: ((this: {
222
- name: string;
223
- options: Options;
224
- storage: Storage;
225
- parent: ParentConfig<MarkConfig<Options, Storage>>['extendNodeSchema'];
226
- }, extension: Node) => Record<string, any>) | null;
227
- /**
228
- * This function extends the schema of the mark.
229
- * @example
230
- * extendMarkSchema() {
231
- * return {
232
- * group: 'inline',
233
- * selectable: false,
234
- * }
235
- * }
236
- */
237
- extendMarkSchema?: ((this: {
238
- name: string;
239
- options: Options;
240
- storage: Storage;
241
- parent: ParentConfig<MarkConfig<Options, Storage>>['extendMarkSchema'];
242
- }, extension: Mark) => 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: MarkType;
252
- parent: ParentConfig<MarkConfig<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: MarkType;
263
- parent: ParentConfig<MarkConfig<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: MarkType;
274
- parent: ParentConfig<MarkConfig<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: MarkType;
285
- parent: ParentConfig<MarkConfig<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: MarkType;
296
- parent: ParentConfig<MarkConfig<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: MarkType;
309
- parent: ParentConfig<MarkConfig<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: MarkType;
322
- parent: ParentConfig<MarkConfig<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: MarkType;
335
- parent: ParentConfig<MarkConfig<Options, Storage>>['onDestroy'];
336
- }) => void) | null;
337
- /**
338
- * Keep mark after split node
339
- */
340
- keepOnSplit?: boolean | (() => boolean);
341
- /**
342
- * Inclusive
343
- */
344
- inclusive?: MarkSpec['inclusive'] | ((this: {
345
- name: string;
346
- options: Options;
347
- storage: Storage;
348
- parent: ParentConfig<MarkConfig<Options, Storage>>['inclusive'];
349
- editor?: Editor;
350
- }) => MarkSpec['inclusive']);
351
- /**
352
- * Excludes
353
- */
354
- excludes?: MarkSpec['excludes'] | ((this: {
355
- name: string;
356
- options: Options;
357
- storage: Storage;
358
- parent: ParentConfig<MarkConfig<Options, Storage>>['excludes'];
359
- editor?: Editor;
360
- }) => MarkSpec['excludes']);
361
- /**
362
- * Marks this Mark as exitable
363
- */
364
- exitable?: boolean | (() => boolean);
365
- /**
366
- * Group
367
- */
368
- group?: MarkSpec['group'] | ((this: {
369
- name: string;
370
- options: Options;
371
- storage: Storage;
372
- parent: ParentConfig<MarkConfig<Options, Storage>>['group'];
373
- editor?: Editor;
374
- }) => MarkSpec['group']);
375
- /**
376
- * Spanning
377
- */
378
- spanning?: MarkSpec['spanning'] | ((this: {
379
- name: string;
380
- options: Options;
381
- storage: Storage;
382
- parent: ParentConfig<MarkConfig<Options, Storage>>['spanning'];
383
- editor?: Editor;
384
- }) => MarkSpec['spanning']);
385
- /**
386
- * Code
387
- */
388
- code?: boolean | ((this: {
389
- name: string;
390
- options: Options;
391
- storage: Storage;
392
- parent: ParentConfig<MarkConfig<Options, Storage>>['code'];
393
- editor?: Editor;
394
- }) => boolean);
395
- /**
396
- * Parse HTML
397
- */
398
- parseHTML?: (this: {
399
- name: string;
400
- options: Options;
401
- storage: Storage;
402
- parent: ParentConfig<MarkConfig<Options, Storage>>['parseHTML'];
403
- editor?: Editor;
404
- }) => MarkSpec['parseDOM'];
405
- /**
406
- * Render HTML
407
- */
408
- renderHTML?: ((this: {
409
- name: string;
410
- options: Options;
411
- storage: Storage;
412
- parent: ParentConfig<MarkConfig<Options, Storage>>['renderHTML'];
413
- editor?: Editor;
414
- }, props: {
415
- mark: ProseMirrorMark;
416
- HTMLAttributes: Record<string, any>;
417
- }) => DOMOutputSpec) | null;
418
- /**
419
- * Attributes
420
- */
421
- addAttributes?: (this: {
422
- name: string;
423
- options: Options;
424
- storage: Storage;
425
- parent: ParentConfig<MarkConfig<Options, Storage>>['addAttributes'];
426
- editor?: Editor;
427
- }) => Attributes | {};
428
- }
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
- */
434
- export declare class Mark<Options = any, Storage = any> {
435
- type: string;
436
- name: string;
437
- parent: Mark | null;
438
- child: Mark | null;
439
- options: Options;
440
- storage: Storage;
441
- config: MarkConfig;
442
- constructor(config?: Partial<MarkConfig<Options, Storage>>);
443
- static create<O = any, S = any>(config?: Partial<MarkConfig<O, S>>): Mark<O, S>;
444
- configure(options?: Partial<Options>): Mark<Options, Storage>;
445
- extend<ExtendedOptions = Options, ExtendedStorage = Storage>(extendedConfig?: Partial<MarkConfig<ExtendedOptions, ExtendedStorage>>): Mark<ExtendedOptions, ExtendedStorage>;
446
- static handleExit({ editor, mark }: {
447
- editor: Editor;
448
- mark: Mark;
449
- }): boolean;
450
- }
1
+ import { DOMOutputSpec, Mark as ProseMirrorMark, MarkSpec, MarkType } from '@tiptap/pm/model';
2
+ import { Plugin, Transaction } from '@tiptap/pm/state';
3
+ import { Editor } from './Editor.js';
4
+ import { MarkConfig } from './index.js';
5
+ import { InputRule } from './InputRule.js';
6
+ import { Node } from './Node.js';
7
+ import { PasteRule } from './PasteRule.js';
8
+ import { Attributes, Extensions, GlobalAttributes, KeyboardShortcutCommand, ParentConfig, RawCommands } from './types.js';
9
+ declare module '@tiptap/core' {
10
+ interface MarkConfig<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<MarkConfig<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<MarkConfig<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<MarkConfig<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: MarkType;
112
+ parent: ParentConfig<MarkConfig<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: MarkType;
130
+ parent: ParentConfig<MarkConfig<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: MarkType;
153
+ parent: ParentConfig<MarkConfig<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: MarkType;
174
+ parent: ParentConfig<MarkConfig<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: MarkType;
192
+ parent: ParentConfig<MarkConfig<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<MarkConfig<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<MarkConfig<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<MarkConfig<Options, Storage>>['extendMarkSchema'];
243
+ }, extension: Mark) => Record<string, any>) | null;
244
+ /**
245
+ * The editor is not ready yet.
246
+ */
247
+ onBeforeCreate?: ((this: {
248
+ name: string;
249
+ options: Options;
250
+ storage: Storage;
251
+ editor: Editor;
252
+ type: MarkType;
253
+ parent: ParentConfig<MarkConfig<Options, Storage>>['onBeforeCreate'];
254
+ }) => void) | null;
255
+ /**
256
+ * The editor is ready.
257
+ */
258
+ onCreate?: ((this: {
259
+ name: string;
260
+ options: Options;
261
+ storage: Storage;
262
+ editor: Editor;
263
+ type: MarkType;
264
+ parent: ParentConfig<MarkConfig<Options, Storage>>['onCreate'];
265
+ }) => void) | null;
266
+ /**
267
+ * The content has changed.
268
+ */
269
+ onUpdate?: ((this: {
270
+ name: string;
271
+ options: Options;
272
+ storage: Storage;
273
+ editor: Editor;
274
+ type: MarkType;
275
+ parent: ParentConfig<MarkConfig<Options, Storage>>['onUpdate'];
276
+ }) => void) | null;
277
+ /**
278
+ * The selection has changed.
279
+ */
280
+ onSelectionUpdate?: ((this: {
281
+ name: string;
282
+ options: Options;
283
+ storage: Storage;
284
+ editor: Editor;
285
+ type: MarkType;
286
+ parent: ParentConfig<MarkConfig<Options, Storage>>['onSelectionUpdate'];
287
+ }) => void) | null;
288
+ /**
289
+ * The editor state has changed.
290
+ */
291
+ onTransaction?: ((this: {
292
+ name: string;
293
+ options: Options;
294
+ storage: Storage;
295
+ editor: Editor;
296
+ type: MarkType;
297
+ parent: ParentConfig<MarkConfig<Options, Storage>>['onTransaction'];
298
+ }, props: {
299
+ transaction: Transaction;
300
+ }) => void) | null;
301
+ /**
302
+ * The editor is focused.
303
+ */
304
+ onFocus?: ((this: {
305
+ name: string;
306
+ options: Options;
307
+ storage: Storage;
308
+ editor: Editor;
309
+ type: MarkType;
310
+ parent: ParentConfig<MarkConfig<Options, Storage>>['onFocus'];
311
+ }, props: {
312
+ event: FocusEvent;
313
+ }) => void) | null;
314
+ /**
315
+ * The editor isn’t focused anymore.
316
+ */
317
+ onBlur?: ((this: {
318
+ name: string;
319
+ options: Options;
320
+ storage: Storage;
321
+ editor: Editor;
322
+ type: MarkType;
323
+ parent: ParentConfig<MarkConfig<Options, Storage>>['onBlur'];
324
+ }, props: {
325
+ event: FocusEvent;
326
+ }) => void) | null;
327
+ /**
328
+ * The editor is destroyed.
329
+ */
330
+ onDestroy?: ((this: {
331
+ name: string;
332
+ options: Options;
333
+ storage: Storage;
334
+ editor: Editor;
335
+ type: MarkType;
336
+ parent: ParentConfig<MarkConfig<Options, Storage>>['onDestroy'];
337
+ }) => void) | null;
338
+ /**
339
+ * Keep mark after split node
340
+ */
341
+ keepOnSplit?: boolean | (() => boolean);
342
+ /**
343
+ * Inclusive
344
+ */
345
+ inclusive?: MarkSpec['inclusive'] | ((this: {
346
+ name: string;
347
+ options: Options;
348
+ storage: Storage;
349
+ parent: ParentConfig<MarkConfig<Options, Storage>>['inclusive'];
350
+ editor?: Editor;
351
+ }) => MarkSpec['inclusive']);
352
+ /**
353
+ * Excludes
354
+ */
355
+ excludes?: MarkSpec['excludes'] | ((this: {
356
+ name: string;
357
+ options: Options;
358
+ storage: Storage;
359
+ parent: ParentConfig<MarkConfig<Options, Storage>>['excludes'];
360
+ editor?: Editor;
361
+ }) => MarkSpec['excludes']);
362
+ /**
363
+ * Marks this Mark as exitable
364
+ */
365
+ exitable?: boolean | (() => boolean);
366
+ /**
367
+ * Group
368
+ */
369
+ group?: MarkSpec['group'] | ((this: {
370
+ name: string;
371
+ options: Options;
372
+ storage: Storage;
373
+ parent: ParentConfig<MarkConfig<Options, Storage>>['group'];
374
+ editor?: Editor;
375
+ }) => MarkSpec['group']);
376
+ /**
377
+ * Spanning
378
+ */
379
+ spanning?: MarkSpec['spanning'] | ((this: {
380
+ name: string;
381
+ options: Options;
382
+ storage: Storage;
383
+ parent: ParentConfig<MarkConfig<Options, Storage>>['spanning'];
384
+ editor?: Editor;
385
+ }) => MarkSpec['spanning']);
386
+ /**
387
+ * Code
388
+ */
389
+ code?: boolean | ((this: {
390
+ name: string;
391
+ options: Options;
392
+ storage: Storage;
393
+ parent: ParentConfig<MarkConfig<Options, Storage>>['code'];
394
+ editor?: Editor;
395
+ }) => boolean);
396
+ /**
397
+ * Parse HTML
398
+ */
399
+ parseHTML?: (this: {
400
+ name: string;
401
+ options: Options;
402
+ storage: Storage;
403
+ parent: ParentConfig<MarkConfig<Options, Storage>>['parseHTML'];
404
+ editor?: Editor;
405
+ }) => MarkSpec['parseDOM'];
406
+ /**
407
+ * Render HTML
408
+ */
409
+ renderHTML?: ((this: {
410
+ name: string;
411
+ options: Options;
412
+ storage: Storage;
413
+ parent: ParentConfig<MarkConfig<Options, Storage>>['renderHTML'];
414
+ editor?: Editor;
415
+ }, props: {
416
+ mark: ProseMirrorMark;
417
+ HTMLAttributes: Record<string, any>;
418
+ }) => DOMOutputSpec) | null;
419
+ /**
420
+ * Attributes
421
+ */
422
+ addAttributes?: (this: {
423
+ name: string;
424
+ options: Options;
425
+ storage: Storage;
426
+ parent: ParentConfig<MarkConfig<Options, Storage>>['addAttributes'];
427
+ editor?: Editor;
428
+ }) => Attributes | {};
429
+ }
430
+ }
431
+ /**
432
+ * The Mark class is used to create custom mark extensions.
433
+ * @see https://tiptap.dev/api/extensions#create-a-new-extension
434
+ */
435
+ export declare class Mark<Options = any, Storage = any> {
436
+ type: string;
437
+ name: string;
438
+ parent: Mark | null;
439
+ child: Mark | null;
440
+ options: Options;
441
+ storage: Storage;
442
+ config: MarkConfig;
443
+ constructor(config?: Partial<MarkConfig<Options, Storage>>);
444
+ static create<O = any, S = any>(config?: Partial<MarkConfig<O, S>>): Mark<O, S>;
445
+ configure(options?: Partial<Options>): Mark<Options, Storage>;
446
+ extend<ExtendedOptions = Options, ExtendedStorage = Storage>(extendedConfig?: Partial<MarkConfig<ExtendedOptions, ExtendedStorage>>): Mark<ExtendedOptions, ExtendedStorage>;
447
+ static handleExit({ editor, mark }: {
448
+ editor: Editor;
449
+ mark: Mark;
450
+ }): boolean;
451
+ }