@tiptap/core 2.3.2 → 2.5.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +277 -67
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +277 -67
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +277 -67
- package/dist/index.umd.js.map +1 -1
- package/dist/packages/core/src/EventEmitter.d.ts +2 -2
- package/dist/packages/core/src/Extension.d.ts +129 -14
- package/dist/packages/core/src/ExtensionManager.d.ts +37 -0
- package/dist/packages/core/src/Mark.d.ts +129 -14
- package/dist/packages/core/src/Node.d.ts +226 -30
- package/dist/packages/core/src/NodeView.d.ts +4 -0
- package/dist/packages/core/src/PasteRule.d.ts +4 -0
- package/dist/packages/core/src/commands/blur.d.ts +1 -0
- package/dist/packages/core/src/commands/clearContent.d.ts +2 -0
- package/dist/packages/core/src/commands/clearNodes.d.ts +1 -0
- package/dist/packages/core/src/commands/command.d.ts +6 -0
- package/dist/packages/core/src/commands/createParagraphNear.d.ts +1 -0
- package/dist/packages/core/src/commands/cut.d.ts +5 -0
- package/dist/packages/core/src/commands/deleteCurrentNode.d.ts +1 -0
- package/dist/packages/core/src/commands/deleteNode.d.ts +3 -1
- package/dist/packages/core/src/commands/deleteRange.d.ts +2 -0
- package/dist/packages/core/src/commands/deleteSelection.d.ts +1 -0
- package/dist/packages/core/src/commands/enter.d.ts +1 -0
- package/dist/packages/core/src/commands/exitCode.d.ts +1 -0
- package/dist/packages/core/src/commands/extendMarkRange.d.ts +14 -2
- package/dist/packages/core/src/commands/first.d.ts +2 -0
- package/dist/packages/core/src/commands/focus.d.ts +14 -1
- package/dist/packages/core/src/commands/insertContent.d.ts +17 -1
- package/dist/packages/core/src/commands/insertContentAt.d.ts +20 -1
- package/dist/packages/core/src/commands/join.d.ts +12 -4
- package/dist/packages/core/src/commands/joinItemBackward.d.ts +2 -1
- package/dist/packages/core/src/commands/joinItemForward.d.ts +2 -1
- package/dist/packages/core/src/commands/keyboardShortcut.d.ts +2 -0
- package/dist/packages/core/src/commands/lift.d.ts +5 -1
- package/dist/packages/core/src/commands/liftEmptyBlock.d.ts +2 -1
- package/dist/packages/core/src/commands/liftListItem.d.ts +3 -1
- package/dist/packages/core/src/commands/newlineInCode.d.ts +1 -0
- package/dist/packages/core/src/commands/resetAttributes.d.ts +3 -0
- package/dist/packages/core/src/commands/scrollIntoView.d.ts +1 -0
- package/dist/packages/core/src/commands/selectAll.d.ts +1 -0
- package/dist/packages/core/src/commands/selectNodeBackward.d.ts +1 -0
- package/dist/packages/core/src/commands/selectNodeForward.d.ts +1 -0
- package/dist/packages/core/src/commands/selectParentNode.d.ts +1 -0
- package/dist/packages/core/src/commands/selectTextblockEnd.d.ts +1 -0
- package/dist/packages/core/src/commands/selectTextblockStart.d.ts +1 -0
- package/dist/packages/core/src/commands/setContent.d.ts +19 -1
- package/dist/packages/core/src/commands/setMark.d.ts +2 -0
- package/dist/packages/core/src/commands/setMeta.d.ts +3 -0
- package/dist/packages/core/src/commands/setNode.d.ts +3 -0
- package/dist/packages/core/src/commands/setNodeSelection.d.ts +2 -0
- package/dist/packages/core/src/commands/setTextSelection.d.ts +2 -0
- package/dist/packages/core/src/commands/sinkListItem.d.ts +2 -0
- package/dist/packages/core/src/commands/splitBlock.d.ts +3 -0
- package/dist/packages/core/src/commands/splitListItem.d.ts +2 -0
- package/dist/packages/core/src/commands/toggleList.d.ts +5 -0
- package/dist/packages/core/src/commands/toggleMark.d.ts +13 -1
- package/dist/packages/core/src/commands/toggleNode.d.ts +4 -0
- package/dist/packages/core/src/commands/toggleWrap.d.ts +3 -0
- package/dist/packages/core/src/commands/undoInputRule.d.ts +1 -0
- package/dist/packages/core/src/commands/unsetAllMarks.d.ts +1 -0
- package/dist/packages/core/src/commands/unsetMark.d.ts +8 -1
- package/dist/packages/core/src/commands/updateAttributes.d.ts +12 -1
- package/dist/packages/core/src/commands/wrapIn.d.ts +3 -0
- package/dist/packages/core/src/commands/wrapInList.d.ts +3 -0
- package/dist/packages/core/src/helpers/combineTransactionSteps.d.ts +3 -0
- package/dist/packages/core/src/helpers/createChainableState.d.ts +5 -0
- package/dist/packages/core/src/helpers/createDocument.d.ts +7 -0
- package/dist/packages/core/src/helpers/createNodeFromContent.d.ts +7 -0
- package/dist/packages/core/src/helpers/defaultBlockAt.d.ts +5 -0
- package/dist/packages/core/src/helpers/findChildren.d.ts +6 -0
- package/dist/packages/core/src/helpers/findChildrenInRange.d.ts +4 -0
- package/dist/packages/core/src/helpers/findParentNode.d.ts +8 -0
- package/dist/packages/core/src/helpers/findParentNodeClosestToPos.d.ts +9 -0
- package/dist/packages/core/src/helpers/generateHTML.d.ts +6 -0
- package/dist/packages/core/src/helpers/generateJSON.d.ts +6 -0
- package/dist/packages/core/src/helpers/generateText.d.ts +7 -0
- package/dist/packages/core/src/helpers/getAttributes.d.ts +6 -0
- package/dist/packages/core/src/helpers/getExtensionField.d.ts +7 -0
- package/dist/packages/core/src/helpers/getSchemaByResolvedExtensions.d.ts +6 -0
- package/dist/packages/core/src/helpers/getSchemaTypeByName.d.ts +6 -0
- package/dist/packages/core/src/helpers/getSchemaTypeNameByName.d.ts +6 -0
- package/dist/packages/core/src/helpers/getSplittedAttributes.d.ts +7 -0
- package/dist/packages/core/src/helpers/getText.d.ts +9 -0
- package/dist/packages/core/src/helpers/getTextBetween.d.ts +8 -0
- package/dist/packages/core/src/helpers/getTextContentFromNodes.d.ts +6 -0
- package/dist/packages/core/src/helpers/getTextSerializersFromSchema.d.ts +5 -0
- package/dist/packages/core/src/inputRules/markInputRule.d.ts +1 -0
- package/dist/packages/core/src/inputRules/nodeInputRule.d.ts +1 -0
- package/dist/packages/core/src/inputRules/textInputRule.d.ts +1 -0
- package/dist/packages/core/src/inputRules/textblockTypeInputRule.d.ts +1 -0
- package/dist/packages/core/src/inputRules/wrappingInputRule.d.ts +1 -0
- package/dist/packages/core/src/pasteRules/markPasteRule.d.ts +1 -0
- package/dist/packages/core/src/pasteRules/nodePasteRule.d.ts +1 -0
- package/dist/packages/core/src/pasteRules/textPasteRule.d.ts +1 -0
- package/package.json +2 -2
- package/src/EventEmitter.ts +2 -2
- package/src/Extension.ts +130 -14
- package/src/ExtensionManager.ts +117 -85
- package/src/Mark.ts +129 -14
- package/src/Node.ts +226 -30
- package/src/NodeView.ts +4 -0
- package/src/PasteRule.ts +4 -0
- package/src/commands/blur.ts +1 -0
- package/src/commands/clearContent.ts +2 -0
- package/src/commands/clearNodes.ts +1 -0
- package/src/commands/command.ts +6 -0
- package/src/commands/createParagraphNear.ts +1 -0
- package/src/commands/cut.ts +5 -0
- package/src/commands/deleteCurrentNode.ts +1 -0
- package/src/commands/deleteNode.ts +3 -1
- package/src/commands/deleteRange.ts +2 -0
- package/src/commands/deleteSelection.ts +1 -0
- package/src/commands/enter.ts +1 -0
- package/src/commands/exitCode.ts +1 -0
- package/src/commands/extendMarkRange.ts +12 -1
- package/src/commands/first.ts +2 -0
- package/src/commands/focus.ts +12 -0
- package/src/commands/insertContent.ts +16 -0
- package/src/commands/insertContentAt.ts +19 -0
- package/src/commands/join.ts +12 -4
- package/src/commands/joinItemBackward.ts +6 -3
- package/src/commands/joinItemForward.ts +2 -1
- package/src/commands/keyboardShortcut.ts +2 -0
- package/src/commands/lift.ts +5 -1
- package/src/commands/liftEmptyBlock.ts +2 -1
- package/src/commands/liftListItem.ts +3 -1
- package/src/commands/newlineInCode.ts +1 -0
- package/src/commands/resetAttributes.ts +3 -0
- package/src/commands/scrollIntoView.ts +1 -0
- package/src/commands/selectAll.ts +1 -0
- package/src/commands/selectNodeBackward.ts +1 -0
- package/src/commands/selectNodeForward.ts +1 -0
- package/src/commands/selectParentNode.ts +1 -0
- package/src/commands/selectTextblockEnd.ts +1 -0
- package/src/commands/selectTextblockStart.ts +1 -0
- package/src/commands/setContent.ts +17 -0
- package/src/commands/setMark.ts +2 -0
- package/src/commands/setMeta.ts +3 -0
- package/src/commands/setNode.ts +3 -0
- package/src/commands/setNodeSelection.ts +2 -0
- package/src/commands/setTextSelection.ts +2 -0
- package/src/commands/sinkListItem.ts +2 -0
- package/src/commands/splitBlock.ts +3 -0
- package/src/commands/splitListItem.ts +2 -0
- package/src/commands/toggleList.ts +5 -0
- package/src/commands/toggleMark.ts +12 -0
- package/src/commands/toggleNode.ts +4 -0
- package/src/commands/toggleWrap.ts +3 -0
- package/src/commands/undoInputRule.ts +1 -0
- package/src/commands/unsetAllMarks.ts +1 -0
- package/src/commands/unsetMark.ts +7 -0
- package/src/commands/updateAttributes.ts +10 -0
- package/src/commands/wrapIn.ts +3 -0
- package/src/commands/wrapInList.ts +3 -0
- package/src/extensions/keymap.ts +7 -1
- package/src/helpers/combineTransactionSteps.ts +3 -0
- package/src/helpers/createChainableState.ts +5 -0
- package/src/helpers/createDocument.ts +7 -0
- package/src/helpers/createNodeFromContent.ts +16 -3
- package/src/helpers/defaultBlockAt.ts +5 -0
- package/src/helpers/findChildren.ts +6 -0
- package/src/helpers/findChildrenInRange.ts +4 -0
- package/src/helpers/findParentNode.ts +8 -0
- package/src/helpers/findParentNodeClosestToPos.ts +9 -0
- package/src/helpers/generateHTML.ts +6 -0
- package/src/helpers/generateJSON.ts +6 -0
- package/src/helpers/generateText.ts +7 -0
- package/src/helpers/getAttributes.ts +6 -0
- package/src/helpers/getExtensionField.ts +7 -0
- package/src/helpers/getSchemaByResolvedExtensions.ts +6 -0
- package/src/helpers/getSchemaTypeByName.ts +6 -0
- package/src/helpers/getSchemaTypeNameByName.ts +6 -0
- package/src/helpers/getSplittedAttributes.ts +7 -0
- package/src/helpers/getText.ts +9 -0
- package/src/helpers/getTextBetween.ts +12 -10
- package/src/helpers/getTextContentFromNodes.ts +6 -0
- package/src/helpers/getTextSerializersFromSchema.ts +5 -0
- package/src/inputRules/markInputRule.ts +1 -0
- package/src/inputRules/nodeInputRule.ts +4 -1
- package/src/inputRules/textInputRule.ts +1 -0
- package/src/inputRules/textblockTypeInputRule.ts +1 -0
- package/src/inputRules/wrappingInputRule.ts +1 -0
- package/src/pasteRules/markPasteRule.ts +1 -0
- package/src/pasteRules/nodePasteRule.ts +1 -0
- package/src/pasteRules/textPasteRule.ts +1 -0
package/src/Node.ts
CHANGED
|
@@ -26,22 +26,40 @@ declare module '@tiptap/core' {
|
|
|
26
26
|
[key: string]: any
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
29
|
+
* The extension name - this must be unique.
|
|
30
|
+
* It will be used to identify the extension.
|
|
31
|
+
*
|
|
32
|
+
* @example 'myExtension'
|
|
30
33
|
*/
|
|
31
34
|
name: string
|
|
32
35
|
|
|
33
36
|
/**
|
|
34
|
-
*
|
|
37
|
+
* The priority of your extension. The higher, the later it will be called
|
|
38
|
+
* and will take precedence over other extensions with a lower priority.
|
|
39
|
+
* @default 1000
|
|
40
|
+
* @example 1001
|
|
35
41
|
*/
|
|
36
42
|
priority?: number
|
|
37
43
|
|
|
38
44
|
/**
|
|
39
|
-
*
|
|
45
|
+
* The default options for this extension.
|
|
46
|
+
* @example
|
|
47
|
+
* defaultOptions: {
|
|
48
|
+
* myOption: 'foo',
|
|
49
|
+
* myOtherOption: 10,
|
|
50
|
+
* }
|
|
40
51
|
*/
|
|
41
52
|
defaultOptions?: Options
|
|
42
53
|
|
|
43
54
|
/**
|
|
44
|
-
*
|
|
55
|
+
* This method will add options to this extension
|
|
56
|
+
* @see https://tiptap.dev/guide/custom-extensions#settings
|
|
57
|
+
* @example
|
|
58
|
+
* addOptions() {
|
|
59
|
+
* return {
|
|
60
|
+
* myOption: 'foo',
|
|
61
|
+
* myOtherOption: 10,
|
|
62
|
+
* }
|
|
45
63
|
*/
|
|
46
64
|
addOptions?: (this: {
|
|
47
65
|
name: string
|
|
@@ -49,7 +67,13 @@ declare module '@tiptap/core' {
|
|
|
49
67
|
}) => Options
|
|
50
68
|
|
|
51
69
|
/**
|
|
52
|
-
*
|
|
70
|
+
* The default storage this extension can save data to.
|
|
71
|
+
* @see https://tiptap.dev/guide/custom-extensions#storage
|
|
72
|
+
* @example
|
|
73
|
+
* defaultStorage: {
|
|
74
|
+
* prefetchedUsers: [],
|
|
75
|
+
* loading: false,
|
|
76
|
+
* }
|
|
53
77
|
*/
|
|
54
78
|
addStorage?: (this: {
|
|
55
79
|
name: string
|
|
@@ -58,7 +82,30 @@ declare module '@tiptap/core' {
|
|
|
58
82
|
}) => Storage
|
|
59
83
|
|
|
60
84
|
/**
|
|
61
|
-
*
|
|
85
|
+
* This function adds globalAttributes to specific nodes.
|
|
86
|
+
* @see https://tiptap.dev/guide/custom-extensions#global-attributes
|
|
87
|
+
* @example
|
|
88
|
+
* addGlobalAttributes() {
|
|
89
|
+
* return [
|
|
90
|
+
* {
|
|
91
|
+
// Extend the following extensions
|
|
92
|
+
* types: [
|
|
93
|
+
* 'heading',
|
|
94
|
+
* 'paragraph',
|
|
95
|
+
* ],
|
|
96
|
+
* // … with those attributes
|
|
97
|
+
* attributes: {
|
|
98
|
+
* textAlign: {
|
|
99
|
+
* default: 'left',
|
|
100
|
+
* renderHTML: attributes => ({
|
|
101
|
+
* style: `text-align: ${attributes.textAlign}`,
|
|
102
|
+
* }),
|
|
103
|
+
* parseHTML: element => element.style.textAlign || 'left',
|
|
104
|
+
* },
|
|
105
|
+
* },
|
|
106
|
+
* },
|
|
107
|
+
* ]
|
|
108
|
+
* }
|
|
62
109
|
*/
|
|
63
110
|
addGlobalAttributes?: (this: {
|
|
64
111
|
name: string
|
|
@@ -68,7 +115,14 @@ declare module '@tiptap/core' {
|
|
|
68
115
|
}) => GlobalAttributes | {}
|
|
69
116
|
|
|
70
117
|
/**
|
|
71
|
-
*
|
|
118
|
+
* This function adds commands to the editor
|
|
119
|
+
* @see https://tiptap.dev/guide/custom-extensions#keyboard-shortcuts
|
|
120
|
+
* @example
|
|
121
|
+
* addCommands() {
|
|
122
|
+
* return {
|
|
123
|
+
* myCommand: () => ({ chain }) => chain().setMark('type', 'foo').run(),
|
|
124
|
+
* }
|
|
125
|
+
* }
|
|
72
126
|
*/
|
|
73
127
|
addCommands?: (this: {
|
|
74
128
|
name: string
|
|
@@ -80,7 +134,14 @@ declare module '@tiptap/core' {
|
|
|
80
134
|
}) => Partial<RawCommands>
|
|
81
135
|
|
|
82
136
|
/**
|
|
83
|
-
*
|
|
137
|
+
* This function registers keyboard shortcuts.
|
|
138
|
+
* @see https://tiptap.dev/guide/custom-extensions#keyboard-shortcuts
|
|
139
|
+
* @example
|
|
140
|
+
* addKeyboardShortcuts() {
|
|
141
|
+
* return {
|
|
142
|
+
* 'Mod-l': () => this.editor.commands.toggleBulletList(),
|
|
143
|
+
* }
|
|
144
|
+
* },
|
|
84
145
|
*/
|
|
85
146
|
addKeyboardShortcuts?: (this: {
|
|
86
147
|
name: string
|
|
@@ -94,7 +155,17 @@ declare module '@tiptap/core' {
|
|
|
94
155
|
}
|
|
95
156
|
|
|
96
157
|
/**
|
|
97
|
-
*
|
|
158
|
+
* This function adds input rules to the editor.
|
|
159
|
+
* @see https://tiptap.dev/guide/custom-extensions#input-rules
|
|
160
|
+
* @example
|
|
161
|
+
* addInputRules() {
|
|
162
|
+
* return [
|
|
163
|
+
* markInputRule({
|
|
164
|
+
* find: inputRegex,
|
|
165
|
+
* type: this.type,
|
|
166
|
+
* }),
|
|
167
|
+
* ]
|
|
168
|
+
* },
|
|
98
169
|
*/
|
|
99
170
|
addInputRules?: (this: {
|
|
100
171
|
name: string
|
|
@@ -106,7 +177,17 @@ declare module '@tiptap/core' {
|
|
|
106
177
|
}) => InputRule[]
|
|
107
178
|
|
|
108
179
|
/**
|
|
109
|
-
*
|
|
180
|
+
* This function adds paste rules to the editor.
|
|
181
|
+
* @see https://tiptap.dev/guide/custom-extensions#paste-rules
|
|
182
|
+
* @example
|
|
183
|
+
* addPasteRules() {
|
|
184
|
+
* return [
|
|
185
|
+
* markPasteRule({
|
|
186
|
+
* find: pasteRegex,
|
|
187
|
+
* type: this.type,
|
|
188
|
+
* }),
|
|
189
|
+
* ]
|
|
190
|
+
* },
|
|
110
191
|
*/
|
|
111
192
|
addPasteRules?: (this: {
|
|
112
193
|
name: string
|
|
@@ -118,7 +199,14 @@ declare module '@tiptap/core' {
|
|
|
118
199
|
}) => PasteRule[]
|
|
119
200
|
|
|
120
201
|
/**
|
|
121
|
-
*
|
|
202
|
+
* This function adds Prosemirror plugins to the editor
|
|
203
|
+
* @see https://tiptap.dev/guide/custom-extensions#prosemirror-plugins
|
|
204
|
+
* @example
|
|
205
|
+
* addProseMirrorPlugins() {
|
|
206
|
+
* return [
|
|
207
|
+
* customPlugin(),
|
|
208
|
+
* ]
|
|
209
|
+
* }
|
|
122
210
|
*/
|
|
123
211
|
addProseMirrorPlugins?: (this: {
|
|
124
212
|
name: string
|
|
@@ -130,7 +218,16 @@ declare module '@tiptap/core' {
|
|
|
130
218
|
}) => Plugin[]
|
|
131
219
|
|
|
132
220
|
/**
|
|
133
|
-
*
|
|
221
|
+
* This function adds additional extensions to the editor. This is useful for
|
|
222
|
+
* building extension kits.
|
|
223
|
+
* @example
|
|
224
|
+
* addExtensions() {
|
|
225
|
+
* return [
|
|
226
|
+
* BulletList,
|
|
227
|
+
* OrderedList,
|
|
228
|
+
* ListItem
|
|
229
|
+
* ]
|
|
230
|
+
* }
|
|
134
231
|
*/
|
|
135
232
|
addExtensions?: (this: {
|
|
136
233
|
name: string
|
|
@@ -140,7 +237,14 @@ declare module '@tiptap/core' {
|
|
|
140
237
|
}) => Extensions
|
|
141
238
|
|
|
142
239
|
/**
|
|
143
|
-
*
|
|
240
|
+
* This function extends the schema of the node.
|
|
241
|
+
* @example
|
|
242
|
+
* extendNodeSchema() {
|
|
243
|
+
* return {
|
|
244
|
+
* group: 'inline',
|
|
245
|
+
* selectable: false,
|
|
246
|
+
* }
|
|
247
|
+
* }
|
|
144
248
|
*/
|
|
145
249
|
extendNodeSchema?:
|
|
146
250
|
| ((
|
|
@@ -155,7 +259,14 @@ declare module '@tiptap/core' {
|
|
|
155
259
|
| null
|
|
156
260
|
|
|
157
261
|
/**
|
|
158
|
-
*
|
|
262
|
+
* This function extends the schema of the mark.
|
|
263
|
+
* @example
|
|
264
|
+
* extendMarkSchema() {
|
|
265
|
+
* return {
|
|
266
|
+
* group: 'inline',
|
|
267
|
+
* selectable: false,
|
|
268
|
+
* }
|
|
269
|
+
* }
|
|
159
270
|
*/
|
|
160
271
|
extendMarkSchema?:
|
|
161
272
|
| ((
|
|
@@ -312,12 +423,22 @@ declare module '@tiptap/core' {
|
|
|
312
423
|
| null
|
|
313
424
|
|
|
314
425
|
/**
|
|
315
|
-
*
|
|
426
|
+
* Defines if this node should be a top level node (doc)
|
|
427
|
+
* @default false
|
|
428
|
+
* @example true
|
|
316
429
|
*/
|
|
317
430
|
topNode?: boolean
|
|
318
431
|
|
|
319
432
|
/**
|
|
320
|
-
*
|
|
433
|
+
* The content expression for this node, as described in the [schema
|
|
434
|
+
* guide](/docs/guide/#schema.content_expressions). When not given,
|
|
435
|
+
* the node does not allow any content.
|
|
436
|
+
*
|
|
437
|
+
* You can read more about it on the Prosemirror documentation here
|
|
438
|
+
* @see https://prosemirror.net/docs/guide/#schema.content_expressions
|
|
439
|
+
* @default undefined
|
|
440
|
+
* @example content: 'block+'
|
|
441
|
+
* @example content: 'headline paragraph block*'
|
|
321
442
|
*/
|
|
322
443
|
content?:
|
|
323
444
|
| NodeSpec['content']
|
|
@@ -330,7 +451,13 @@ declare module '@tiptap/core' {
|
|
|
330
451
|
}) => NodeSpec['content'])
|
|
331
452
|
|
|
332
453
|
/**
|
|
333
|
-
*
|
|
454
|
+
* The marks that are allowed inside of this node. May be a
|
|
455
|
+
* space-separated string referring to mark names or groups, `"_"`
|
|
456
|
+
* to explicitly allow all marks, or `""` to disallow marks. When
|
|
457
|
+
* not given, nodes with inline content default to allowing all
|
|
458
|
+
* marks, other nodes default to not allowing marks.
|
|
459
|
+
*
|
|
460
|
+
* @example marks: 'strong em'
|
|
334
461
|
*/
|
|
335
462
|
marks?:
|
|
336
463
|
| NodeSpec['marks']
|
|
@@ -343,7 +470,16 @@ declare module '@tiptap/core' {
|
|
|
343
470
|
}) => NodeSpec['marks'])
|
|
344
471
|
|
|
345
472
|
/**
|
|
346
|
-
*
|
|
473
|
+
* The group or space-separated groups to which this node belongs,
|
|
474
|
+
* which can be referred to in the content expressions for the
|
|
475
|
+
* schema.
|
|
476
|
+
*
|
|
477
|
+
* By default Tiptap uses the groups 'block' and 'inline' for nodes. You
|
|
478
|
+
* can also use custom groups if you want to group specific nodes together
|
|
479
|
+
* and handle them in your schema.
|
|
480
|
+
* @example group: 'block'
|
|
481
|
+
* @example group: 'inline'
|
|
482
|
+
* @example group: 'customBlock' // this uses a custom group
|
|
347
483
|
*/
|
|
348
484
|
group?:
|
|
349
485
|
| NodeSpec['group']
|
|
@@ -356,7 +492,7 @@ declare module '@tiptap/core' {
|
|
|
356
492
|
}) => NodeSpec['group'])
|
|
357
493
|
|
|
358
494
|
/**
|
|
359
|
-
*
|
|
495
|
+
* Should be set to true for inline nodes. (Implied for text nodes.)
|
|
360
496
|
*/
|
|
361
497
|
inline?:
|
|
362
498
|
| NodeSpec['inline']
|
|
@@ -369,7 +505,11 @@ declare module '@tiptap/core' {
|
|
|
369
505
|
}) => NodeSpec['inline'])
|
|
370
506
|
|
|
371
507
|
/**
|
|
372
|
-
*
|
|
508
|
+
* Can be set to true to indicate that, though this isn't a [leaf
|
|
509
|
+
* node](https://prosemirror.net/docs/ref/#model.NodeType.isLeaf), it doesn't have directly editable
|
|
510
|
+
* content and should be treated as a single unit in the view.
|
|
511
|
+
*
|
|
512
|
+
* @example atom: true
|
|
373
513
|
*/
|
|
374
514
|
atom?:
|
|
375
515
|
| NodeSpec['atom']
|
|
@@ -382,7 +522,12 @@ declare module '@tiptap/core' {
|
|
|
382
522
|
}) => NodeSpec['atom'])
|
|
383
523
|
|
|
384
524
|
/**
|
|
385
|
-
*
|
|
525
|
+
* Controls whether nodes of this type can be selected as a [node
|
|
526
|
+
* selection](https://prosemirror.net/docs/ref/#state.NodeSelection). Defaults to true for non-text
|
|
527
|
+
* nodes.
|
|
528
|
+
*
|
|
529
|
+
* @default true
|
|
530
|
+
* @example selectable: false
|
|
386
531
|
*/
|
|
387
532
|
selectable?:
|
|
388
533
|
| NodeSpec['selectable']
|
|
@@ -395,7 +540,11 @@ declare module '@tiptap/core' {
|
|
|
395
540
|
}) => NodeSpec['selectable'])
|
|
396
541
|
|
|
397
542
|
/**
|
|
398
|
-
*
|
|
543
|
+
* Determines whether nodes of this type can be dragged without
|
|
544
|
+
* being selected. Defaults to false.
|
|
545
|
+
*
|
|
546
|
+
* @default: false
|
|
547
|
+
* @example: draggable: true
|
|
399
548
|
*/
|
|
400
549
|
draggable?:
|
|
401
550
|
| NodeSpec['draggable']
|
|
@@ -408,7 +557,8 @@ declare module '@tiptap/core' {
|
|
|
408
557
|
}) => NodeSpec['draggable'])
|
|
409
558
|
|
|
410
559
|
/**
|
|
411
|
-
*
|
|
560
|
+
* Can be used to indicate that this node contains code, which
|
|
561
|
+
* causes some commands to behave differently.
|
|
412
562
|
*/
|
|
413
563
|
code?:
|
|
414
564
|
| NodeSpec['code']
|
|
@@ -421,7 +571,15 @@ declare module '@tiptap/core' {
|
|
|
421
571
|
}) => NodeSpec['code'])
|
|
422
572
|
|
|
423
573
|
/**
|
|
424
|
-
*
|
|
574
|
+
* Controls way whitespace in this a node is parsed. The default is
|
|
575
|
+
* `"normal"`, which causes the [DOM parser](https://prosemirror.net/docs/ref/#model.DOMParser) to
|
|
576
|
+
* collapse whitespace in normal mode, and normalize it (replacing
|
|
577
|
+
* newlines and such with spaces) otherwise. `"pre"` causes the
|
|
578
|
+
* parser to preserve spaces inside the node. When this option isn't
|
|
579
|
+
* given, but [`code`](https://prosemirror.net/docs/ref/#model.NodeSpec.code) is true, `whitespace`
|
|
580
|
+
* will default to `"pre"`. Note that this option doesn't influence
|
|
581
|
+
* the way the node is rendered—that should be handled by `toDOM`
|
|
582
|
+
* and/or styling.
|
|
425
583
|
*/
|
|
426
584
|
whitespace?:
|
|
427
585
|
| NodeSpec['whitespace']
|
|
@@ -434,7 +592,12 @@ declare module '@tiptap/core' {
|
|
|
434
592
|
}) => NodeSpec['whitespace'])
|
|
435
593
|
|
|
436
594
|
/**
|
|
437
|
-
*
|
|
595
|
+
* When enabled, enables both
|
|
596
|
+
* [`definingAsContext`](https://prosemirror.net/docs/ref/#model.NodeSpec.definingAsContext) and
|
|
597
|
+
* [`definingForContent`](https://prosemirror.net/docs/ref/#model.NodeSpec.definingForContent).
|
|
598
|
+
*
|
|
599
|
+
* @default false
|
|
600
|
+
* @example isolating: true
|
|
438
601
|
*/
|
|
439
602
|
defining?:
|
|
440
603
|
| NodeSpec['defining']
|
|
@@ -447,7 +610,10 @@ declare module '@tiptap/core' {
|
|
|
447
610
|
}) => NodeSpec['defining'])
|
|
448
611
|
|
|
449
612
|
/**
|
|
450
|
-
*
|
|
613
|
+
* When enabled (default is false), the sides of nodes of this type
|
|
614
|
+
* count as boundaries that regular editing operations, like
|
|
615
|
+
* backspacing or lifting, won't cross. An example of a node that
|
|
616
|
+
* should probably have this enabled is a table cell.
|
|
451
617
|
*/
|
|
452
618
|
isolating?:
|
|
453
619
|
| NodeSpec['isolating']
|
|
@@ -460,7 +626,14 @@ declare module '@tiptap/core' {
|
|
|
460
626
|
}) => NodeSpec['isolating'])
|
|
461
627
|
|
|
462
628
|
/**
|
|
463
|
-
*
|
|
629
|
+
* Associates DOM parser information with this node, which can be
|
|
630
|
+
* used by [`DOMParser.fromSchema`](https://prosemirror.net/docs/ref/#model.DOMParser^fromSchema) to
|
|
631
|
+
* automatically derive a parser. The `node` field in the rules is
|
|
632
|
+
* implied (the name of this node will be filled in automatically).
|
|
633
|
+
* If you supply your own parser, you do not need to also specify
|
|
634
|
+
* parsing rules in your schema.
|
|
635
|
+
*
|
|
636
|
+
* @example parseHTML: [{ tag: 'div', attrs: { 'data-id': 'my-block' } }]
|
|
464
637
|
*/
|
|
465
638
|
parseHTML?: (this: {
|
|
466
639
|
name: string
|
|
@@ -471,7 +644,24 @@ declare module '@tiptap/core' {
|
|
|
471
644
|
}) => NodeSpec['parseDOM']
|
|
472
645
|
|
|
473
646
|
/**
|
|
474
|
-
*
|
|
647
|
+
* A description of a DOM structure. Can be either a string, which is
|
|
648
|
+
* interpreted as a text node, a DOM node, which is interpreted as
|
|
649
|
+
* itself, a `{dom, contentDOM}` object, or an array.
|
|
650
|
+
*
|
|
651
|
+
* An array describes a DOM element. The first value in the array
|
|
652
|
+
* should be a string—the name of the DOM element, optionally prefixed
|
|
653
|
+
* by a namespace URL and a space. If the second element is plain
|
|
654
|
+
* object, it is interpreted as a set of attributes for the element.
|
|
655
|
+
* Any elements after that (including the 2nd if it's not an attribute
|
|
656
|
+
* object) are interpreted as children of the DOM elements, and must
|
|
657
|
+
* either be valid `DOMOutputSpec` values, or the number zero.
|
|
658
|
+
*
|
|
659
|
+
* The number zero (pronounced “hole”) is used to indicate the place
|
|
660
|
+
* where a node's child nodes should be inserted. If it occurs in an
|
|
661
|
+
* output spec, it should be the only child element in its parent
|
|
662
|
+
* node.
|
|
663
|
+
*
|
|
664
|
+
* @example toDOM: ['div[data-id="my-block"]', { class: 'my-block' }, 0]
|
|
475
665
|
*/
|
|
476
666
|
renderHTML?:
|
|
477
667
|
| ((
|
|
@@ -490,7 +680,8 @@ declare module '@tiptap/core' {
|
|
|
490
680
|
| null
|
|
491
681
|
|
|
492
682
|
/**
|
|
493
|
-
*
|
|
683
|
+
* renders the node as text
|
|
684
|
+
* @example renderText: () => 'foo
|
|
494
685
|
*/
|
|
495
686
|
renderText?:
|
|
496
687
|
| ((
|
|
@@ -511,7 +702,8 @@ declare module '@tiptap/core' {
|
|
|
511
702
|
| null
|
|
512
703
|
|
|
513
704
|
/**
|
|
514
|
-
* Add
|
|
705
|
+
* Add attributes to the node
|
|
706
|
+
* @example addAttributes: () => ({ class: 'foo' })
|
|
515
707
|
*/
|
|
516
708
|
addAttributes?: (this: {
|
|
517
709
|
name: string
|
|
@@ -523,6 +715,10 @@ declare module '@tiptap/core' {
|
|
|
523
715
|
}
|
|
524
716
|
}
|
|
525
717
|
|
|
718
|
+
/**
|
|
719
|
+
* The Node class is used to create custom node extensions.
|
|
720
|
+
* @see https://tiptap.dev/api/extensions#create-a-new-extension
|
|
721
|
+
*/
|
|
526
722
|
export class Node<Options = any, Storage = any> {
|
|
527
723
|
type = 'node'
|
|
528
724
|
|
package/src/NodeView.ts
CHANGED
|
@@ -8,6 +8,10 @@ import { DecorationWithType, NodeViewRendererOptions, NodeViewRendererProps } fr
|
|
|
8
8
|
import { isAndroid } from './utilities/isAndroid.js'
|
|
9
9
|
import { isiOS } from './utilities/isiOS.js'
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Node views are used to customize the rendered DOM structure of a node.
|
|
13
|
+
* @see https://tiptap.dev/guide/node-views
|
|
14
|
+
*/
|
|
11
15
|
export class NodeView<
|
|
12
16
|
Component,
|
|
13
17
|
NodeEditor extends CoreEditor = CoreEditor,
|
package/src/PasteRule.ts
CHANGED
|
@@ -23,6 +23,10 @@ export type PasteRuleMatch = {
|
|
|
23
23
|
|
|
24
24
|
export type PasteRuleFinder = RegExp | ((text: string, event?: ClipboardEvent | null) => PasteRuleMatch[] | null | undefined)
|
|
25
25
|
|
|
26
|
+
/**
|
|
27
|
+
* Paste rules are used to react to pasted content.
|
|
28
|
+
* @see https://tiptap.dev/guide/custom-extensions/#paste-rules
|
|
29
|
+
*/
|
|
26
30
|
export class PasteRule {
|
|
27
31
|
find: PasteRuleFinder
|
|
28
32
|
|
package/src/commands/blur.ts
CHANGED
package/src/commands/command.ts
CHANGED
|
@@ -5,6 +5,12 @@ declare module '@tiptap/core' {
|
|
|
5
5
|
command: {
|
|
6
6
|
/**
|
|
7
7
|
* Define a command inline.
|
|
8
|
+
* @param fn The command function.
|
|
9
|
+
* @example
|
|
10
|
+
* editor.commands.command(({ tr, state }) => {
|
|
11
|
+
* ...
|
|
12
|
+
* return true
|
|
13
|
+
* })
|
|
8
14
|
*/
|
|
9
15
|
command: (fn: (props: Parameters<Command>[0]) => boolean) => ReturnType,
|
|
10
16
|
}
|
package/src/commands/cut.ts
CHANGED
|
@@ -7,6 +7,11 @@ declare module '@tiptap/core' {
|
|
|
7
7
|
cut: {
|
|
8
8
|
/**
|
|
9
9
|
* Cuts content from a range and inserts it at a given position.
|
|
10
|
+
* @param range The range to cut.
|
|
11
|
+
* @param range.from The start position of the range.
|
|
12
|
+
* @param range.to The end position of the range.
|
|
13
|
+
* @param targetPos The position to insert the content at.
|
|
14
|
+
* @example editor.commands.cut({ from: 1, to: 3 }, 5)
|
|
10
15
|
*/
|
|
11
16
|
cut: ({ from, to }: { from: number, to: number }, targetPos: number) => ReturnType,
|
|
12
17
|
}
|
|
@@ -7,7 +7,9 @@ declare module '@tiptap/core' {
|
|
|
7
7
|
interface Commands<ReturnType> {
|
|
8
8
|
deleteNode: {
|
|
9
9
|
/**
|
|
10
|
-
* Delete a node.
|
|
10
|
+
* Delete a node with a given type or name.
|
|
11
|
+
* @param typeOrName The type or name of the node.
|
|
12
|
+
* @example editor.commands.deleteNode('paragraph')
|
|
11
13
|
*/
|
|
12
14
|
deleteNode: (typeOrName: string | NodeType) => ReturnType,
|
|
13
15
|
}
|
package/src/commands/enter.ts
CHANGED
package/src/commands/exitCode.ts
CHANGED
|
@@ -9,10 +9,21 @@ declare module '@tiptap/core' {
|
|
|
9
9
|
interface Commands<ReturnType> {
|
|
10
10
|
extendMarkRange: {
|
|
11
11
|
/**
|
|
12
|
-
* Extends the text selection to the current mark.
|
|
12
|
+
* Extends the text selection to the current mark by type or name.
|
|
13
|
+
* @param typeOrName The type or name of the mark.
|
|
14
|
+
* @param attributes The attributes of the mark.
|
|
15
|
+
* @example editor.commands.extendMarkRange('bold')
|
|
16
|
+
* @example editor.commands.extendMarkRange('mention', { userId: "1" })
|
|
13
17
|
*/
|
|
14
18
|
extendMarkRange: (
|
|
19
|
+
/**
|
|
20
|
+
* The type or name of the mark.
|
|
21
|
+
*/
|
|
15
22
|
typeOrName: string | MarkType,
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The attributes of the mark.
|
|
26
|
+
*/
|
|
16
27
|
attributes?: Record<string, any>,
|
|
17
28
|
) => ReturnType
|
|
18
29
|
}
|
package/src/commands/first.ts
CHANGED
|
@@ -5,6 +5,8 @@ declare module '@tiptap/core' {
|
|
|
5
5
|
first: {
|
|
6
6
|
/**
|
|
7
7
|
* Runs one command after the other and stops at the first which returns true.
|
|
8
|
+
* @param commands The commands to run.
|
|
9
|
+
* @example editor.commands.first([command1, command2])
|
|
8
10
|
*/
|
|
9
11
|
first: (commands: Command[] | ((props: CommandProps) => Command[])) => ReturnType,
|
|
10
12
|
}
|
package/src/commands/focus.ts
CHANGED
|
@@ -8,9 +8,21 @@ declare module '@tiptap/core' {
|
|
|
8
8
|
focus: {
|
|
9
9
|
/**
|
|
10
10
|
* Focus the editor at the given position.
|
|
11
|
+
* @param position The position to focus at.
|
|
12
|
+
* @param options.scrollIntoView Scroll the focused position into view after focusing
|
|
13
|
+
* @example editor.commands.focus()
|
|
14
|
+
* @example editor.commands.focus(32, { scrollIntoView: false })
|
|
11
15
|
*/
|
|
12
16
|
focus: (
|
|
17
|
+
/**
|
|
18
|
+
* The position to focus at.
|
|
19
|
+
*/
|
|
13
20
|
position?: FocusPosition,
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Optional options
|
|
24
|
+
* @default { scrollIntoView: true }
|
|
25
|
+
*/
|
|
14
26
|
options?: {
|
|
15
27
|
scrollIntoView?: boolean,
|
|
16
28
|
},
|
|
@@ -7,11 +7,27 @@ declare module '@tiptap/core' {
|
|
|
7
7
|
insertContent: {
|
|
8
8
|
/**
|
|
9
9
|
* Insert a node or string of HTML at the current position.
|
|
10
|
+
* @example editor.commands.insertContent('<h1>Example</h1>')
|
|
11
|
+
* @example editor.commands.insertContent('<h1>Example</h1>', { updateSelection: false })
|
|
10
12
|
*/
|
|
11
13
|
insertContent: (
|
|
14
|
+
/**
|
|
15
|
+
* The ProseMirror content to insert.
|
|
16
|
+
*/
|
|
12
17
|
value: Content,
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Optional options
|
|
21
|
+
*/
|
|
13
22
|
options?: {
|
|
23
|
+
/**
|
|
24
|
+
* Options for parsing the content.
|
|
25
|
+
*/
|
|
14
26
|
parseOptions?: ParseOptions
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Whether to update the selection after inserting the content.
|
|
30
|
+
*/
|
|
15
31
|
updateSelection?: boolean
|
|
16
32
|
applyInputRules?: boolean
|
|
17
33
|
applyPasteRules?: boolean
|