@tiptap/extensions 3.0.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/LICENSE.md +21 -0
- package/README.md +18 -0
- package/dist/character-count/index.cjs +129 -0
- package/dist/character-count/index.cjs.map +1 -0
- package/dist/character-count/index.d.cts +62 -0
- package/dist/character-count/index.d.ts +62 -0
- package/dist/character-count/index.js +102 -0
- package/dist/character-count/index.js.map +1 -0
- package/dist/drop-cursor/index.cjs +47 -0
- package/dist/drop-cursor/index.cjs.map +1 -0
- package/dist/drop-cursor/index.d.cts +31 -0
- package/dist/drop-cursor/index.d.ts +31 -0
- package/dist/drop-cursor/index.js +20 -0
- package/dist/drop-cursor/index.js.map +1 -0
- package/dist/focus/index.cjs +95 -0
- package/dist/focus/index.cjs.map +1 -0
- package/dist/focus/index.d.cts +28 -0
- package/dist/focus/index.d.ts +28 -0
- package/dist/focus/index.js +68 -0
- package/dist/focus/index.js.map +1 -0
- package/dist/gap-cursor/index.cjs +51 -0
- package/dist/gap-cursor/index.cjs.map +1 -0
- package/dist/gap-cursor/index.d.cts +25 -0
- package/dist/gap-cursor/index.d.ts +25 -0
- package/dist/gap-cursor/index.js +24 -0
- package/dist/gap-cursor/index.js.map +1 -0
- package/dist/index.cjs +421 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +272 -0
- package/dist/index.d.ts +272 -0
- package/dist/index.js +387 -0
- package/dist/index.js.map +1 -0
- package/dist/placeholder/index.cjs +88 -0
- package/dist/placeholder/index.cjs.map +1 -0
- package/dist/placeholder/index.d.cts +59 -0
- package/dist/placeholder/index.d.ts +59 -0
- package/dist/placeholder/index.js +61 -0
- package/dist/placeholder/index.js.map +1 -0
- package/dist/selection/index.cjs +63 -0
- package/dist/selection/index.cjs.map +1 -0
- package/dist/selection/index.d.cts +17 -0
- package/dist/selection/index.d.ts +17 -0
- package/dist/selection/index.js +36 -0
- package/dist/selection/index.js.map +1 -0
- package/dist/trailing-node/index.cjs +78 -0
- package/dist/trailing-node/index.cjs.map +1 -0
- package/dist/trailing-node/index.d.cts +28 -0
- package/dist/trailing-node/index.d.ts +28 -0
- package/dist/trailing-node/index.js +51 -0
- package/dist/trailing-node/index.js.map +1 -0
- package/dist/undo-redo/index.cjs +66 -0
- package/dist/undo-redo/index.cjs.map +1 -0
- package/dist/undo-redo/index.d.cts +44 -0
- package/dist/undo-redo/index.d.ts +44 -0
- package/dist/undo-redo/index.js +39 -0
- package/dist/undo-redo/index.js.map +1 -0
- package/package.json +114 -0
- package/src/character-count/character-count.ts +195 -0
- package/src/character-count/index.ts +1 -0
- package/src/drop-cursor/drop-cursor.ts +47 -0
- package/src/drop-cursor/index.ts +1 -0
- package/src/focus/focus.ts +110 -0
- package/src/focus/index.ts +1 -0
- package/src/gap-cursor/gap-cursor.ts +47 -0
- package/src/gap-cursor/index.ts +1 -0
- package/src/index.ts +8 -0
- package/src/placeholder/index.ts +1 -0
- package/src/placeholder/placeholder.ts +129 -0
- package/src/selection/index.ts +1 -0
- package/src/selection/selection.ts +51 -0
- package/src/trailing-node/index.ts +1 -0
- package/src/trailing-node/trailing-node.ts +84 -0
- package/src/undo-redo/index.ts +1 -0
- package/src/undo-redo/undo-redo.ts +86 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
import { Extension, ParentConfig, Editor } from '@tiptap/core';
|
|
2
|
+
import { Node } from '@tiptap/pm/model';
|
|
3
|
+
|
|
4
|
+
interface CharacterCountOptions {
|
|
5
|
+
/**
|
|
6
|
+
* The maximum number of characters that should be allowed. Defaults to `0`.
|
|
7
|
+
* @default null
|
|
8
|
+
* @example 180
|
|
9
|
+
*/
|
|
10
|
+
limit: number | null | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* The mode by which the size is calculated. If set to `textSize`, the textContent of the document is used.
|
|
13
|
+
* If set to `nodeSize`, the nodeSize of the document is used.
|
|
14
|
+
* @default 'textSize'
|
|
15
|
+
* @example 'textSize'
|
|
16
|
+
*/
|
|
17
|
+
mode: 'textSize' | 'nodeSize';
|
|
18
|
+
/**
|
|
19
|
+
* The text counter function to use. Defaults to a simple character count.
|
|
20
|
+
* @default (text) => text.length
|
|
21
|
+
* @example (text) => [...new Intl.Segmenter().segment(text)].length
|
|
22
|
+
*/
|
|
23
|
+
textCounter: (text: string) => number;
|
|
24
|
+
/**
|
|
25
|
+
* The word counter function to use. Defaults to a simple word count.
|
|
26
|
+
* @default (text) => text.split(' ').filter(word => word !== '').length
|
|
27
|
+
* @example (text) => text.split(/\s+/).filter(word => word !== '').length
|
|
28
|
+
*/
|
|
29
|
+
wordCounter: (text: string) => number;
|
|
30
|
+
}
|
|
31
|
+
interface CharacterCountStorage {
|
|
32
|
+
/**
|
|
33
|
+
* Get the number of characters for the current document.
|
|
34
|
+
* @param options The options for the character count. (optional)
|
|
35
|
+
* @param options.node The node to get the characters from. Defaults to the current document.
|
|
36
|
+
* @param options.mode The mode by which the size is calculated. If set to `textSize`, the textContent of the document is used.
|
|
37
|
+
*/
|
|
38
|
+
characters: (options?: {
|
|
39
|
+
node?: Node;
|
|
40
|
+
mode?: 'textSize' | 'nodeSize';
|
|
41
|
+
}) => number;
|
|
42
|
+
/**
|
|
43
|
+
* Get the number of words for the current document.
|
|
44
|
+
* @param options The options for the character count. (optional)
|
|
45
|
+
* @param options.node The node to get the words from. Defaults to the current document.
|
|
46
|
+
*/
|
|
47
|
+
words: (options?: {
|
|
48
|
+
node?: Node;
|
|
49
|
+
}) => number;
|
|
50
|
+
}
|
|
51
|
+
declare module '@tiptap/core' {
|
|
52
|
+
interface Storage {
|
|
53
|
+
characterCount: CharacterCountStorage;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* This extension allows you to count the characters and words of your document.
|
|
58
|
+
* @see https://tiptap.dev/api/extensions/character-count
|
|
59
|
+
*/
|
|
60
|
+
declare const CharacterCount: Extension<CharacterCountOptions, CharacterCountStorage>;
|
|
61
|
+
|
|
62
|
+
interface DropcursorOptions {
|
|
63
|
+
/**
|
|
64
|
+
* The color of the drop cursor
|
|
65
|
+
* @default 'currentColor'
|
|
66
|
+
* @example 'red'
|
|
67
|
+
*/
|
|
68
|
+
color: string | undefined;
|
|
69
|
+
/**
|
|
70
|
+
* The width of the drop cursor
|
|
71
|
+
* @default 1
|
|
72
|
+
* @example 2
|
|
73
|
+
*/
|
|
74
|
+
width: number | undefined;
|
|
75
|
+
/**
|
|
76
|
+
* The class of the drop cursor
|
|
77
|
+
* @default undefined
|
|
78
|
+
* @example 'drop-cursor'
|
|
79
|
+
*/
|
|
80
|
+
class: string | undefined;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* This extension allows you to add a drop cursor to your editor.
|
|
84
|
+
* A drop cursor is a line that appears when you drag and drop content
|
|
85
|
+
* in-between nodes.
|
|
86
|
+
* @see https://tiptap.dev/api/extensions/dropcursor
|
|
87
|
+
*/
|
|
88
|
+
declare const Dropcursor: Extension<DropcursorOptions, any>;
|
|
89
|
+
|
|
90
|
+
interface FocusOptions {
|
|
91
|
+
/**
|
|
92
|
+
* The class name that should be added to the focused node.
|
|
93
|
+
* @default 'has-focus'
|
|
94
|
+
* @example 'is-focused'
|
|
95
|
+
*/
|
|
96
|
+
className: string;
|
|
97
|
+
/**
|
|
98
|
+
* The mode by which the focused node is determined.
|
|
99
|
+
* - All: All nodes are marked as focused.
|
|
100
|
+
* - Deepest: Only the deepest node is marked as focused.
|
|
101
|
+
* - Shallowest: Only the shallowest node is marked as focused.
|
|
102
|
+
*
|
|
103
|
+
* @default 'all'
|
|
104
|
+
* @example 'deepest'
|
|
105
|
+
* @example 'shallowest'
|
|
106
|
+
*/
|
|
107
|
+
mode: 'all' | 'deepest' | 'shallowest';
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* This extension allows you to add a class to the focused node.
|
|
111
|
+
* @see https://www.tiptap.dev/api/extensions/focus
|
|
112
|
+
*/
|
|
113
|
+
declare const Focus: Extension<FocusOptions, any>;
|
|
114
|
+
|
|
115
|
+
declare module '@tiptap/core' {
|
|
116
|
+
interface NodeConfig<Options, Storage> {
|
|
117
|
+
/**
|
|
118
|
+
* A function to determine whether the gap cursor is allowed at the current position. Must return `true` or `false`.
|
|
119
|
+
* @default null
|
|
120
|
+
*/
|
|
121
|
+
allowGapCursor?: boolean | null | ((this: {
|
|
122
|
+
name: string;
|
|
123
|
+
options: Options;
|
|
124
|
+
storage: Storage;
|
|
125
|
+
parent: ParentConfig<NodeConfig<Options>>['allowGapCursor'];
|
|
126
|
+
}) => boolean | null);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* This extension allows you to add a gap cursor to your editor.
|
|
131
|
+
* A gap cursor is a cursor that appears when you click on a place
|
|
132
|
+
* where no content is present, for example inbetween nodes.
|
|
133
|
+
* @see https://tiptap.dev/api/extensions/gapcursor
|
|
134
|
+
*/
|
|
135
|
+
declare const Gapcursor: Extension<any, any>;
|
|
136
|
+
|
|
137
|
+
interface PlaceholderOptions {
|
|
138
|
+
/**
|
|
139
|
+
* **The class name for the empty editor**
|
|
140
|
+
* @default 'is-editor-empty'
|
|
141
|
+
*/
|
|
142
|
+
emptyEditorClass: string;
|
|
143
|
+
/**
|
|
144
|
+
* **The class name for empty nodes**
|
|
145
|
+
* @default 'is-empty'
|
|
146
|
+
*/
|
|
147
|
+
emptyNodeClass: string;
|
|
148
|
+
/**
|
|
149
|
+
* **The placeholder content**
|
|
150
|
+
*
|
|
151
|
+
* You can use a function to return a dynamic placeholder or a string.
|
|
152
|
+
* @default 'Write something …'
|
|
153
|
+
*/
|
|
154
|
+
placeholder: ((PlaceholderProps: {
|
|
155
|
+
editor: Editor;
|
|
156
|
+
node: Node;
|
|
157
|
+
pos: number;
|
|
158
|
+
hasAnchor: boolean;
|
|
159
|
+
}) => string) | string;
|
|
160
|
+
/**
|
|
161
|
+
* **Checks if the placeholder should be only shown when the editor is editable.**
|
|
162
|
+
*
|
|
163
|
+
* If true, the placeholder will only be shown when the editor is editable.
|
|
164
|
+
* If false, the placeholder will always be shown.
|
|
165
|
+
* @default true
|
|
166
|
+
*/
|
|
167
|
+
showOnlyWhenEditable: boolean;
|
|
168
|
+
/**
|
|
169
|
+
* **Checks if the placeholder should be only shown when the current node is empty.**
|
|
170
|
+
*
|
|
171
|
+
* If true, the placeholder will only be shown when the current node is empty.
|
|
172
|
+
* If false, the placeholder will be shown when any node is empty.
|
|
173
|
+
* @default true
|
|
174
|
+
*/
|
|
175
|
+
showOnlyCurrent: boolean;
|
|
176
|
+
/**
|
|
177
|
+
* **Controls if the placeholder should be shown for all descendents.**
|
|
178
|
+
*
|
|
179
|
+
* If true, the placeholder will be shown for all descendents.
|
|
180
|
+
* If false, the placeholder will only be shown for the current node.
|
|
181
|
+
* @default false
|
|
182
|
+
*/
|
|
183
|
+
includeChildren: boolean;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* This extension allows you to add a placeholder to your editor.
|
|
187
|
+
* A placeholder is a text that appears when the editor or a node is empty.
|
|
188
|
+
* @see https://www.tiptap.dev/api/extensions/placeholder
|
|
189
|
+
*/
|
|
190
|
+
declare const Placeholder: Extension<PlaceholderOptions, any>;
|
|
191
|
+
|
|
192
|
+
type SelectionOptions = {
|
|
193
|
+
/**
|
|
194
|
+
* The class name that should be added to the selected text.
|
|
195
|
+
* @default 'selection'
|
|
196
|
+
* @example 'is-selected'
|
|
197
|
+
*/
|
|
198
|
+
className: string;
|
|
199
|
+
};
|
|
200
|
+
/**
|
|
201
|
+
* This extension allows you to add a class to the selected text.
|
|
202
|
+
* @see https://www.tiptap.dev/api/extensions/selection
|
|
203
|
+
*/
|
|
204
|
+
declare const Selection: Extension<any, any>;
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Extension based on:
|
|
208
|
+
* - https://github.com/ueberdosis/tiptap/blob/v1/packages/tiptap-extensions/src/extensions/TrailingNode.js
|
|
209
|
+
* - https://github.com/remirror/remirror/blob/e0f1bec4a1e8073ce8f5500d62193e52321155b9/packages/prosemirror-trailing-node/src/trailing-node-plugin.ts
|
|
210
|
+
*/
|
|
211
|
+
interface TrailingNodeOptions {
|
|
212
|
+
/**
|
|
213
|
+
* The node type that should be inserted at the end of the document.
|
|
214
|
+
* @note the node will always be added to the `notAfter` lists to
|
|
215
|
+
* prevent an infinite loop.
|
|
216
|
+
* @default 'paragraph'
|
|
217
|
+
*/
|
|
218
|
+
node: string;
|
|
219
|
+
/**
|
|
220
|
+
* The node types after which the trailing node should not be inserted.
|
|
221
|
+
* @default ['paragraph']
|
|
222
|
+
*/
|
|
223
|
+
notAfter?: string | string[];
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* This extension allows you to add an extra node at the end of the document.
|
|
227
|
+
* @see https://www.tiptap.dev/api/extensions/trailing-node
|
|
228
|
+
*/
|
|
229
|
+
declare const TrailingNode: Extension<TrailingNodeOptions, any>;
|
|
230
|
+
|
|
231
|
+
interface UndoRedoOptions {
|
|
232
|
+
/**
|
|
233
|
+
* The amount of history events that are collected before the oldest events are discarded.
|
|
234
|
+
* @default 100
|
|
235
|
+
* @example 50
|
|
236
|
+
*/
|
|
237
|
+
depth: number;
|
|
238
|
+
/**
|
|
239
|
+
* The delay (in milliseconds) between changes after which a new group should be started.
|
|
240
|
+
* @default 500
|
|
241
|
+
* @example 1000
|
|
242
|
+
*/
|
|
243
|
+
newGroupDelay: number;
|
|
244
|
+
}
|
|
245
|
+
declare module '@tiptap/core' {
|
|
246
|
+
interface Commands<ReturnType> {
|
|
247
|
+
undoRedo: {
|
|
248
|
+
/**
|
|
249
|
+
* Undo recent changes
|
|
250
|
+
* @example editor.commands.undo()
|
|
251
|
+
*/
|
|
252
|
+
undo: () => ReturnType;
|
|
253
|
+
/**
|
|
254
|
+
* Reapply reverted changes
|
|
255
|
+
* @example editor.commands.redo()
|
|
256
|
+
*/
|
|
257
|
+
redo: () => ReturnType;
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* This extension allows you to undo and redo recent changes.
|
|
263
|
+
* @see https://www.tiptap.dev/api/extensions/undo-redo
|
|
264
|
+
*
|
|
265
|
+
* **Important**: If the `@tiptap/extension-collaboration` package is used, make sure to remove
|
|
266
|
+
* the `undo-redo` extension, as it is not compatible with the `collaboration` extension.
|
|
267
|
+
*
|
|
268
|
+
* `@tiptap/extension-collaboration` uses its own history implementation.
|
|
269
|
+
*/
|
|
270
|
+
declare const UndoRedo: Extension<UndoRedoOptions, any>;
|
|
271
|
+
|
|
272
|
+
export { CharacterCount, type CharacterCountOptions, type CharacterCountStorage, Dropcursor, type DropcursorOptions, Focus, type FocusOptions, Gapcursor, Placeholder, type PlaceholderOptions, Selection, type SelectionOptions, TrailingNode, type TrailingNodeOptions, UndoRedo, type UndoRedoOptions };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
import { Extension, ParentConfig, Editor } from '@tiptap/core';
|
|
2
|
+
import { Node } from '@tiptap/pm/model';
|
|
3
|
+
|
|
4
|
+
interface CharacterCountOptions {
|
|
5
|
+
/**
|
|
6
|
+
* The maximum number of characters that should be allowed. Defaults to `0`.
|
|
7
|
+
* @default null
|
|
8
|
+
* @example 180
|
|
9
|
+
*/
|
|
10
|
+
limit: number | null | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* The mode by which the size is calculated. If set to `textSize`, the textContent of the document is used.
|
|
13
|
+
* If set to `nodeSize`, the nodeSize of the document is used.
|
|
14
|
+
* @default 'textSize'
|
|
15
|
+
* @example 'textSize'
|
|
16
|
+
*/
|
|
17
|
+
mode: 'textSize' | 'nodeSize';
|
|
18
|
+
/**
|
|
19
|
+
* The text counter function to use. Defaults to a simple character count.
|
|
20
|
+
* @default (text) => text.length
|
|
21
|
+
* @example (text) => [...new Intl.Segmenter().segment(text)].length
|
|
22
|
+
*/
|
|
23
|
+
textCounter: (text: string) => number;
|
|
24
|
+
/**
|
|
25
|
+
* The word counter function to use. Defaults to a simple word count.
|
|
26
|
+
* @default (text) => text.split(' ').filter(word => word !== '').length
|
|
27
|
+
* @example (text) => text.split(/\s+/).filter(word => word !== '').length
|
|
28
|
+
*/
|
|
29
|
+
wordCounter: (text: string) => number;
|
|
30
|
+
}
|
|
31
|
+
interface CharacterCountStorage {
|
|
32
|
+
/**
|
|
33
|
+
* Get the number of characters for the current document.
|
|
34
|
+
* @param options The options for the character count. (optional)
|
|
35
|
+
* @param options.node The node to get the characters from. Defaults to the current document.
|
|
36
|
+
* @param options.mode The mode by which the size is calculated. If set to `textSize`, the textContent of the document is used.
|
|
37
|
+
*/
|
|
38
|
+
characters: (options?: {
|
|
39
|
+
node?: Node;
|
|
40
|
+
mode?: 'textSize' | 'nodeSize';
|
|
41
|
+
}) => number;
|
|
42
|
+
/**
|
|
43
|
+
* Get the number of words for the current document.
|
|
44
|
+
* @param options The options for the character count. (optional)
|
|
45
|
+
* @param options.node The node to get the words from. Defaults to the current document.
|
|
46
|
+
*/
|
|
47
|
+
words: (options?: {
|
|
48
|
+
node?: Node;
|
|
49
|
+
}) => number;
|
|
50
|
+
}
|
|
51
|
+
declare module '@tiptap/core' {
|
|
52
|
+
interface Storage {
|
|
53
|
+
characterCount: CharacterCountStorage;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* This extension allows you to count the characters and words of your document.
|
|
58
|
+
* @see https://tiptap.dev/api/extensions/character-count
|
|
59
|
+
*/
|
|
60
|
+
declare const CharacterCount: Extension<CharacterCountOptions, CharacterCountStorage>;
|
|
61
|
+
|
|
62
|
+
interface DropcursorOptions {
|
|
63
|
+
/**
|
|
64
|
+
* The color of the drop cursor
|
|
65
|
+
* @default 'currentColor'
|
|
66
|
+
* @example 'red'
|
|
67
|
+
*/
|
|
68
|
+
color: string | undefined;
|
|
69
|
+
/**
|
|
70
|
+
* The width of the drop cursor
|
|
71
|
+
* @default 1
|
|
72
|
+
* @example 2
|
|
73
|
+
*/
|
|
74
|
+
width: number | undefined;
|
|
75
|
+
/**
|
|
76
|
+
* The class of the drop cursor
|
|
77
|
+
* @default undefined
|
|
78
|
+
* @example 'drop-cursor'
|
|
79
|
+
*/
|
|
80
|
+
class: string | undefined;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* This extension allows you to add a drop cursor to your editor.
|
|
84
|
+
* A drop cursor is a line that appears when you drag and drop content
|
|
85
|
+
* in-between nodes.
|
|
86
|
+
* @see https://tiptap.dev/api/extensions/dropcursor
|
|
87
|
+
*/
|
|
88
|
+
declare const Dropcursor: Extension<DropcursorOptions, any>;
|
|
89
|
+
|
|
90
|
+
interface FocusOptions {
|
|
91
|
+
/**
|
|
92
|
+
* The class name that should be added to the focused node.
|
|
93
|
+
* @default 'has-focus'
|
|
94
|
+
* @example 'is-focused'
|
|
95
|
+
*/
|
|
96
|
+
className: string;
|
|
97
|
+
/**
|
|
98
|
+
* The mode by which the focused node is determined.
|
|
99
|
+
* - All: All nodes are marked as focused.
|
|
100
|
+
* - Deepest: Only the deepest node is marked as focused.
|
|
101
|
+
* - Shallowest: Only the shallowest node is marked as focused.
|
|
102
|
+
*
|
|
103
|
+
* @default 'all'
|
|
104
|
+
* @example 'deepest'
|
|
105
|
+
* @example 'shallowest'
|
|
106
|
+
*/
|
|
107
|
+
mode: 'all' | 'deepest' | 'shallowest';
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* This extension allows you to add a class to the focused node.
|
|
111
|
+
* @see https://www.tiptap.dev/api/extensions/focus
|
|
112
|
+
*/
|
|
113
|
+
declare const Focus: Extension<FocusOptions, any>;
|
|
114
|
+
|
|
115
|
+
declare module '@tiptap/core' {
|
|
116
|
+
interface NodeConfig<Options, Storage> {
|
|
117
|
+
/**
|
|
118
|
+
* A function to determine whether the gap cursor is allowed at the current position. Must return `true` or `false`.
|
|
119
|
+
* @default null
|
|
120
|
+
*/
|
|
121
|
+
allowGapCursor?: boolean | null | ((this: {
|
|
122
|
+
name: string;
|
|
123
|
+
options: Options;
|
|
124
|
+
storage: Storage;
|
|
125
|
+
parent: ParentConfig<NodeConfig<Options>>['allowGapCursor'];
|
|
126
|
+
}) => boolean | null);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* This extension allows you to add a gap cursor to your editor.
|
|
131
|
+
* A gap cursor is a cursor that appears when you click on a place
|
|
132
|
+
* where no content is present, for example inbetween nodes.
|
|
133
|
+
* @see https://tiptap.dev/api/extensions/gapcursor
|
|
134
|
+
*/
|
|
135
|
+
declare const Gapcursor: Extension<any, any>;
|
|
136
|
+
|
|
137
|
+
interface PlaceholderOptions {
|
|
138
|
+
/**
|
|
139
|
+
* **The class name for the empty editor**
|
|
140
|
+
* @default 'is-editor-empty'
|
|
141
|
+
*/
|
|
142
|
+
emptyEditorClass: string;
|
|
143
|
+
/**
|
|
144
|
+
* **The class name for empty nodes**
|
|
145
|
+
* @default 'is-empty'
|
|
146
|
+
*/
|
|
147
|
+
emptyNodeClass: string;
|
|
148
|
+
/**
|
|
149
|
+
* **The placeholder content**
|
|
150
|
+
*
|
|
151
|
+
* You can use a function to return a dynamic placeholder or a string.
|
|
152
|
+
* @default 'Write something …'
|
|
153
|
+
*/
|
|
154
|
+
placeholder: ((PlaceholderProps: {
|
|
155
|
+
editor: Editor;
|
|
156
|
+
node: Node;
|
|
157
|
+
pos: number;
|
|
158
|
+
hasAnchor: boolean;
|
|
159
|
+
}) => string) | string;
|
|
160
|
+
/**
|
|
161
|
+
* **Checks if the placeholder should be only shown when the editor is editable.**
|
|
162
|
+
*
|
|
163
|
+
* If true, the placeholder will only be shown when the editor is editable.
|
|
164
|
+
* If false, the placeholder will always be shown.
|
|
165
|
+
* @default true
|
|
166
|
+
*/
|
|
167
|
+
showOnlyWhenEditable: boolean;
|
|
168
|
+
/**
|
|
169
|
+
* **Checks if the placeholder should be only shown when the current node is empty.**
|
|
170
|
+
*
|
|
171
|
+
* If true, the placeholder will only be shown when the current node is empty.
|
|
172
|
+
* If false, the placeholder will be shown when any node is empty.
|
|
173
|
+
* @default true
|
|
174
|
+
*/
|
|
175
|
+
showOnlyCurrent: boolean;
|
|
176
|
+
/**
|
|
177
|
+
* **Controls if the placeholder should be shown for all descendents.**
|
|
178
|
+
*
|
|
179
|
+
* If true, the placeholder will be shown for all descendents.
|
|
180
|
+
* If false, the placeholder will only be shown for the current node.
|
|
181
|
+
* @default false
|
|
182
|
+
*/
|
|
183
|
+
includeChildren: boolean;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* This extension allows you to add a placeholder to your editor.
|
|
187
|
+
* A placeholder is a text that appears when the editor or a node is empty.
|
|
188
|
+
* @see https://www.tiptap.dev/api/extensions/placeholder
|
|
189
|
+
*/
|
|
190
|
+
declare const Placeholder: Extension<PlaceholderOptions, any>;
|
|
191
|
+
|
|
192
|
+
type SelectionOptions = {
|
|
193
|
+
/**
|
|
194
|
+
* The class name that should be added to the selected text.
|
|
195
|
+
* @default 'selection'
|
|
196
|
+
* @example 'is-selected'
|
|
197
|
+
*/
|
|
198
|
+
className: string;
|
|
199
|
+
};
|
|
200
|
+
/**
|
|
201
|
+
* This extension allows you to add a class to the selected text.
|
|
202
|
+
* @see https://www.tiptap.dev/api/extensions/selection
|
|
203
|
+
*/
|
|
204
|
+
declare const Selection: Extension<any, any>;
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Extension based on:
|
|
208
|
+
* - https://github.com/ueberdosis/tiptap/blob/v1/packages/tiptap-extensions/src/extensions/TrailingNode.js
|
|
209
|
+
* - https://github.com/remirror/remirror/blob/e0f1bec4a1e8073ce8f5500d62193e52321155b9/packages/prosemirror-trailing-node/src/trailing-node-plugin.ts
|
|
210
|
+
*/
|
|
211
|
+
interface TrailingNodeOptions {
|
|
212
|
+
/**
|
|
213
|
+
* The node type that should be inserted at the end of the document.
|
|
214
|
+
* @note the node will always be added to the `notAfter` lists to
|
|
215
|
+
* prevent an infinite loop.
|
|
216
|
+
* @default 'paragraph'
|
|
217
|
+
*/
|
|
218
|
+
node: string;
|
|
219
|
+
/**
|
|
220
|
+
* The node types after which the trailing node should not be inserted.
|
|
221
|
+
* @default ['paragraph']
|
|
222
|
+
*/
|
|
223
|
+
notAfter?: string | string[];
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* This extension allows you to add an extra node at the end of the document.
|
|
227
|
+
* @see https://www.tiptap.dev/api/extensions/trailing-node
|
|
228
|
+
*/
|
|
229
|
+
declare const TrailingNode: Extension<TrailingNodeOptions, any>;
|
|
230
|
+
|
|
231
|
+
interface UndoRedoOptions {
|
|
232
|
+
/**
|
|
233
|
+
* The amount of history events that are collected before the oldest events are discarded.
|
|
234
|
+
* @default 100
|
|
235
|
+
* @example 50
|
|
236
|
+
*/
|
|
237
|
+
depth: number;
|
|
238
|
+
/**
|
|
239
|
+
* The delay (in milliseconds) between changes after which a new group should be started.
|
|
240
|
+
* @default 500
|
|
241
|
+
* @example 1000
|
|
242
|
+
*/
|
|
243
|
+
newGroupDelay: number;
|
|
244
|
+
}
|
|
245
|
+
declare module '@tiptap/core' {
|
|
246
|
+
interface Commands<ReturnType> {
|
|
247
|
+
undoRedo: {
|
|
248
|
+
/**
|
|
249
|
+
* Undo recent changes
|
|
250
|
+
* @example editor.commands.undo()
|
|
251
|
+
*/
|
|
252
|
+
undo: () => ReturnType;
|
|
253
|
+
/**
|
|
254
|
+
* Reapply reverted changes
|
|
255
|
+
* @example editor.commands.redo()
|
|
256
|
+
*/
|
|
257
|
+
redo: () => ReturnType;
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* This extension allows you to undo and redo recent changes.
|
|
263
|
+
* @see https://www.tiptap.dev/api/extensions/undo-redo
|
|
264
|
+
*
|
|
265
|
+
* **Important**: If the `@tiptap/extension-collaboration` package is used, make sure to remove
|
|
266
|
+
* the `undo-redo` extension, as it is not compatible with the `collaboration` extension.
|
|
267
|
+
*
|
|
268
|
+
* `@tiptap/extension-collaboration` uses its own history implementation.
|
|
269
|
+
*/
|
|
270
|
+
declare const UndoRedo: Extension<UndoRedoOptions, any>;
|
|
271
|
+
|
|
272
|
+
export { CharacterCount, type CharacterCountOptions, type CharacterCountStorage, Dropcursor, type DropcursorOptions, Focus, type FocusOptions, Gapcursor, Placeholder, type PlaceholderOptions, Selection, type SelectionOptions, TrailingNode, type TrailingNodeOptions, UndoRedo, type UndoRedoOptions };
|