@tiptap/extension-task-item 3.0.0 → 3.0.2-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (176) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +5 -1
  3. package/dist/index.cjs +32 -165
  4. package/dist/index.cjs.map +1 -1
  5. package/dist/index.d.cts +2 -0
  6. package/dist/index.d.ts +2 -0
  7. package/dist/index.js +9 -161
  8. package/dist/index.js.map +1 -1
  9. package/package.json +11 -11
  10. package/src/index.ts +3 -2
  11. package/dist/index.umd.js +0 -171
  12. package/dist/index.umd.js.map +0 -1
  13. package/dist/packages/core/src/CommandManager.d.ts +0 -20
  14. package/dist/packages/core/src/Editor.d.ts +0 -161
  15. package/dist/packages/core/src/EventEmitter.d.ts +0 -11
  16. package/dist/packages/core/src/Extension.d.ts +0 -343
  17. package/dist/packages/core/src/ExtensionManager.d.ts +0 -55
  18. package/dist/packages/core/src/InputRule.d.ts +0 -42
  19. package/dist/packages/core/src/Mark.d.ts +0 -451
  20. package/dist/packages/core/src/Node.d.ts +0 -611
  21. package/dist/packages/core/src/NodePos.d.ts +0 -44
  22. package/dist/packages/core/src/NodeView.d.ts +0 -31
  23. package/dist/packages/core/src/PasteRule.d.ts +0 -50
  24. package/dist/packages/core/src/Tracker.d.ts +0 -11
  25. package/dist/packages/core/src/commands/blur.d.ts +0 -13
  26. package/dist/packages/core/src/commands/clearContent.d.ts +0 -14
  27. package/dist/packages/core/src/commands/clearNodes.d.ts +0 -13
  28. package/dist/packages/core/src/commands/command.d.ts +0 -18
  29. package/dist/packages/core/src/commands/createParagraphNear.d.ts +0 -13
  30. package/dist/packages/core/src/commands/cut.d.ts +0 -20
  31. package/dist/packages/core/src/commands/deleteCurrentNode.d.ts +0 -13
  32. package/dist/packages/core/src/commands/deleteNode.d.ts +0 -15
  33. package/dist/packages/core/src/commands/deleteRange.d.ts +0 -14
  34. package/dist/packages/core/src/commands/deleteSelection.d.ts +0 -13
  35. package/dist/packages/core/src/commands/enter.d.ts +0 -13
  36. package/dist/packages/core/src/commands/exitCode.d.ts +0 -13
  37. package/dist/packages/core/src/commands/extendMarkRange.d.ts +0 -25
  38. package/dist/packages/core/src/commands/first.d.ts +0 -14
  39. package/dist/packages/core/src/commands/focus.d.ts +0 -27
  40. package/dist/packages/core/src/commands/forEach.d.ts +0 -14
  41. package/dist/packages/core/src/commands/index.d.ts +0 -55
  42. package/dist/packages/core/src/commands/insertContent.d.ts +0 -34
  43. package/dist/packages/core/src/commands/insertContentAt.d.ts +0 -47
  44. package/dist/packages/core/src/commands/join.d.ts +0 -41
  45. package/dist/packages/core/src/commands/joinItemBackward.d.ts +0 -13
  46. package/dist/packages/core/src/commands/joinItemForward.d.ts +0 -13
  47. package/dist/packages/core/src/commands/joinTextblockBackward.d.ts +0 -12
  48. package/dist/packages/core/src/commands/joinTextblockForward.d.ts +0 -12
  49. package/dist/packages/core/src/commands/keyboardShortcut.d.ts +0 -14
  50. package/dist/packages/core/src/commands/lift.d.ts +0 -17
  51. package/dist/packages/core/src/commands/liftEmptyBlock.d.ts +0 -13
  52. package/dist/packages/core/src/commands/liftListItem.d.ts +0 -15
  53. package/dist/packages/core/src/commands/newlineInCode.d.ts +0 -13
  54. package/dist/packages/core/src/commands/resetAttributes.d.ts +0 -16
  55. package/dist/packages/core/src/commands/scrollIntoView.d.ts +0 -13
  56. package/dist/packages/core/src/commands/selectAll.d.ts +0 -13
  57. package/dist/packages/core/src/commands/selectNodeBackward.d.ts +0 -13
  58. package/dist/packages/core/src/commands/selectNodeForward.d.ts +0 -13
  59. package/dist/packages/core/src/commands/selectParentNode.d.ts +0 -13
  60. package/dist/packages/core/src/commands/selectTextblockEnd.d.ts +0 -13
  61. package/dist/packages/core/src/commands/selectTextblockStart.d.ts +0 -13
  62. package/dist/packages/core/src/commands/setContent.d.ts +0 -40
  63. package/dist/packages/core/src/commands/setMark.d.ts +0 -15
  64. package/dist/packages/core/src/commands/setMeta.d.ts +0 -15
  65. package/dist/packages/core/src/commands/setNode.d.ts +0 -16
  66. package/dist/packages/core/src/commands/setNodeSelection.d.ts +0 -14
  67. package/dist/packages/core/src/commands/setTextSelection.d.ts +0 -14
  68. package/dist/packages/core/src/commands/sinkListItem.d.ts +0 -15
  69. package/dist/packages/core/src/commands/splitBlock.d.ts +0 -17
  70. package/dist/packages/core/src/commands/splitListItem.d.ts +0 -15
  71. package/dist/packages/core/src/commands/toggleList.d.ts +0 -18
  72. package/dist/packages/core/src/commands/toggleMark.d.ts +0 -30
  73. package/dist/packages/core/src/commands/toggleNode.d.ts +0 -17
  74. package/dist/packages/core/src/commands/toggleWrap.d.ts +0 -16
  75. package/dist/packages/core/src/commands/undoInputRule.d.ts +0 -13
  76. package/dist/packages/core/src/commands/unsetAllMarks.d.ts +0 -13
  77. package/dist/packages/core/src/commands/unsetMark.d.ts +0 -25
  78. package/dist/packages/core/src/commands/updateAttributes.d.ts +0 -24
  79. package/dist/packages/core/src/commands/wrapIn.d.ts +0 -16
  80. package/dist/packages/core/src/commands/wrapInList.d.ts +0 -16
  81. package/dist/packages/core/src/extensions/clipboardTextSerializer.d.ts +0 -5
  82. package/dist/packages/core/src/extensions/commands.d.ts +0 -3
  83. package/dist/packages/core/src/extensions/editable.d.ts +0 -2
  84. package/dist/packages/core/src/extensions/focusEvents.d.ts +0 -2
  85. package/dist/packages/core/src/extensions/index.d.ts +0 -6
  86. package/dist/packages/core/src/extensions/keymap.d.ts +0 -2
  87. package/dist/packages/core/src/extensions/tabindex.d.ts +0 -2
  88. package/dist/packages/core/src/helpers/combineTransactionSteps.d.ts +0 -10
  89. package/dist/packages/core/src/helpers/createChainableState.d.ts +0 -10
  90. package/dist/packages/core/src/helpers/createDocument.d.ts +0 -12
  91. package/dist/packages/core/src/helpers/createNodeFromContent.d.ts +0 -15
  92. package/dist/packages/core/src/helpers/defaultBlockAt.d.ts +0 -7
  93. package/dist/packages/core/src/helpers/findChildren.d.ts +0 -9
  94. package/dist/packages/core/src/helpers/findChildrenInRange.d.ts +0 -10
  95. package/dist/packages/core/src/helpers/findParentNode.d.ts +0 -16
  96. package/dist/packages/core/src/helpers/findParentNodeClosestToPos.d.ts +0 -17
  97. package/dist/packages/core/src/helpers/generateHTML.d.ts +0 -8
  98. package/dist/packages/core/src/helpers/generateJSON.d.ts +0 -8
  99. package/dist/packages/core/src/helpers/generateText.d.ts +0 -12
  100. package/dist/packages/core/src/helpers/getAttributes.d.ts +0 -9
  101. package/dist/packages/core/src/helpers/getAttributesFromExtensions.d.ts +0 -6
  102. package/dist/packages/core/src/helpers/getChangedRanges.d.ts +0 -11
  103. package/dist/packages/core/src/helpers/getDebugJSON.d.ts +0 -8
  104. package/dist/packages/core/src/helpers/getExtensionField.d.ts +0 -9
  105. package/dist/packages/core/src/helpers/getHTMLFromFragment.d.ts +0 -2
  106. package/dist/packages/core/src/helpers/getMarkAttributes.d.ts +0 -3
  107. package/dist/packages/core/src/helpers/getMarkRange.d.ts +0 -3
  108. package/dist/packages/core/src/helpers/getMarkType.d.ts +0 -2
  109. package/dist/packages/core/src/helpers/getMarksBetween.d.ts +0 -3
  110. package/dist/packages/core/src/helpers/getNodeAtPosition.d.ts +0 -11
  111. package/dist/packages/core/src/helpers/getNodeAttributes.d.ts +0 -3
  112. package/dist/packages/core/src/helpers/getNodeType.d.ts +0 -2
  113. package/dist/packages/core/src/helpers/getRenderedAttributes.d.ts +0 -3
  114. package/dist/packages/core/src/helpers/getSchema.d.ts +0 -4
  115. package/dist/packages/core/src/helpers/getSchemaByResolvedExtensions.d.ts +0 -10
  116. package/dist/packages/core/src/helpers/getSchemaTypeByName.d.ts +0 -8
  117. package/dist/packages/core/src/helpers/getSchemaTypeNameByName.d.ts +0 -8
  118. package/dist/packages/core/src/helpers/getSplittedAttributes.d.ts +0 -9
  119. package/dist/packages/core/src/helpers/getText.d.ts +0 -15
  120. package/dist/packages/core/src/helpers/getTextBetween.d.ts +0 -14
  121. package/dist/packages/core/src/helpers/getTextContentFromNodes.d.ts +0 -8
  122. package/dist/packages/core/src/helpers/getTextSerializersFromSchema.d.ts +0 -8
  123. package/dist/packages/core/src/helpers/index.d.ts +0 -50
  124. package/dist/packages/core/src/helpers/injectExtensionAttributesToParseRule.d.ts +0 -9
  125. package/dist/packages/core/src/helpers/isActive.d.ts +0 -2
  126. package/dist/packages/core/src/helpers/isAtEndOfNode.d.ts +0 -2
  127. package/dist/packages/core/src/helpers/isAtStartOfNode.d.ts +0 -2
  128. package/dist/packages/core/src/helpers/isExtensionRulesEnabled.d.ts +0 -2
  129. package/dist/packages/core/src/helpers/isList.d.ts +0 -2
  130. package/dist/packages/core/src/helpers/isMarkActive.d.ts +0 -3
  131. package/dist/packages/core/src/helpers/isNodeActive.d.ts +0 -3
  132. package/dist/packages/core/src/helpers/isNodeEmpty.d.ts +0 -2
  133. package/dist/packages/core/src/helpers/isNodeSelection.d.ts +0 -2
  134. package/dist/packages/core/src/helpers/isTextSelection.d.ts +0 -2
  135. package/dist/packages/core/src/helpers/posToDOMRect.d.ts +0 -2
  136. package/dist/packages/core/src/helpers/resolveFocusPosition.d.ts +0 -4
  137. package/dist/packages/core/src/helpers/selectionToInsertionEnd.d.ts +0 -2
  138. package/dist/packages/core/src/helpers/splitExtensions.d.ts +0 -9
  139. package/dist/packages/core/src/index.d.ts +0 -24
  140. package/dist/packages/core/src/inputRules/index.d.ts +0 -5
  141. package/dist/packages/core/src/inputRules/markInputRule.d.ts +0 -13
  142. package/dist/packages/core/src/inputRules/nodeInputRule.d.ts +0 -23
  143. package/dist/packages/core/src/inputRules/textInputRule.d.ts +0 -10
  144. package/dist/packages/core/src/inputRules/textblockTypeInputRule.d.ts +0 -15
  145. package/dist/packages/core/src/inputRules/wrappingInputRule.d.ts +0 -28
  146. package/dist/packages/core/src/pasteRules/index.d.ts +0 -3
  147. package/dist/packages/core/src/pasteRules/markPasteRule.d.ts +0 -13
  148. package/dist/packages/core/src/pasteRules/nodePasteRule.d.ts +0 -13
  149. package/dist/packages/core/src/pasteRules/textPasteRule.d.ts +0 -10
  150. package/dist/packages/core/src/style.d.ts +0 -1
  151. package/dist/packages/core/src/types.d.ts +0 -255
  152. package/dist/packages/core/src/utilities/callOrReturn.d.ts +0 -9
  153. package/dist/packages/core/src/utilities/createStyleTag.d.ts +0 -1
  154. package/dist/packages/core/src/utilities/deleteProps.d.ts +0 -6
  155. package/dist/packages/core/src/utilities/elementFromString.d.ts +0 -1
  156. package/dist/packages/core/src/utilities/escapeForRegEx.d.ts +0 -1
  157. package/dist/packages/core/src/utilities/findDuplicates.d.ts +0 -1
  158. package/dist/packages/core/src/utilities/fromString.d.ts +0 -1
  159. package/dist/packages/core/src/utilities/index.d.ts +0 -20
  160. package/dist/packages/core/src/utilities/isAndroid.d.ts +0 -1
  161. package/dist/packages/core/src/utilities/isEmptyObject.d.ts +0 -1
  162. package/dist/packages/core/src/utilities/isFunction.d.ts +0 -1
  163. package/dist/packages/core/src/utilities/isMacOS.d.ts +0 -1
  164. package/dist/packages/core/src/utilities/isNumber.d.ts +0 -1
  165. package/dist/packages/core/src/utilities/isPlainObject.d.ts +0 -1
  166. package/dist/packages/core/src/utilities/isRegExp.d.ts +0 -1
  167. package/dist/packages/core/src/utilities/isString.d.ts +0 -1
  168. package/dist/packages/core/src/utilities/isiOS.d.ts +0 -1
  169. package/dist/packages/core/src/utilities/mergeAttributes.d.ts +0 -1
  170. package/dist/packages/core/src/utilities/mergeDeep.d.ts +0 -1
  171. package/dist/packages/core/src/utilities/minMax.d.ts +0 -1
  172. package/dist/packages/core/src/utilities/objectIncludes.d.ts +0 -8
  173. package/dist/packages/core/src/utilities/removeDuplicates.d.ts +0 -8
  174. package/dist/packages/extension-task-item/src/index.d.ts +0 -3
  175. package/dist/packages/extension-task-item/src/task-item.d.ts +0 -38
  176. package/src/task-item.ts +0 -220
@@ -1,611 +0,0 @@
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<any, any>;
610
- extend<ExtendedOptions = Options, ExtendedStorage = Storage>(extendedConfig?: Partial<NodeConfig<ExtendedOptions, ExtendedStorage>>): Node<ExtendedOptions, ExtendedStorage>;
611
- }
@@ -1,44 +0,0 @@
1
- import { Fragment, Node, ResolvedPos } from '@tiptap/pm/model';
2
- import { Editor } from './Editor.js';
3
- import { Content, Range } from './types.js';
4
- export declare class NodePos {
5
- private resolvedPos;
6
- private isBlock;
7
- private editor;
8
- private get name();
9
- constructor(pos: ResolvedPos, editor: Editor, isBlock?: boolean, node?: Node | null);
10
- private currentNode;
11
- get node(): Node;
12
- get element(): HTMLElement;
13
- actualDepth: number | null;
14
- get depth(): number;
15
- get pos(): number;
16
- get content(): Fragment;
17
- set content(content: Content);
18
- get attributes(): {
19
- [key: string]: any;
20
- };
21
- get textContent(): string;
22
- get size(): number;
23
- get from(): number;
24
- get range(): Range;
25
- get to(): number;
26
- get parent(): NodePos | null;
27
- get before(): NodePos | null;
28
- get after(): NodePos | null;
29
- get children(): NodePos[];
30
- get firstChild(): NodePos | null;
31
- get lastChild(): NodePos | null;
32
- closest(selector: string, attributes?: {
33
- [key: string]: any;
34
- }): NodePos | null;
35
- querySelector(selector: string, attributes?: {
36
- [key: string]: any;
37
- }): NodePos | null;
38
- querySelectorAll(selector: string, attributes?: {
39
- [key: string]: any;
40
- }, firstItemOnly?: boolean): NodePos[];
41
- setAttribute(attributes: {
42
- [key: string]: any;
43
- }): void;
44
- }
@@ -1,31 +0,0 @@
1
- import { Node as ProseMirrorNode } from '@tiptap/pm/model';
2
- import { NodeView as ProseMirrorNodeView } from '@tiptap/pm/view';
3
- import { Editor as CoreEditor } from './Editor.js';
4
- import { Node } from './Node.js';
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
- */
10
- export declare class NodeView<Component, NodeEditor extends CoreEditor = CoreEditor, Options extends NodeViewRendererOptions = NodeViewRendererOptions> implements ProseMirrorNodeView {
11
- component: Component;
12
- editor: NodeEditor;
13
- options: Options;
14
- extension: Node;
15
- node: ProseMirrorNode;
16
- decorations: DecorationWithType[];
17
- getPos: any;
18
- isDragging: boolean;
19
- constructor(component: Component, props: NodeViewRendererProps, options?: Partial<Options>);
20
- mount(): void;
21
- get dom(): HTMLElement;
22
- get contentDOM(): HTMLElement | null;
23
- onDragStart(event: DragEvent): void;
24
- stopEvent(event: Event): boolean;
25
- ignoreMutation(mutation: MutationRecord | {
26
- type: 'selection';
27
- target: Element;
28
- }): boolean;
29
- updateAttributes(attributes: {}): void;
30
- deleteNode(): void;
31
- }