@tiptap/extensions 3.20.1 → 3.20.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/package.json +5 -5
  2. package/src/placeholder/placeholder.ts +4 -0
  3. package/dist/character-count/index.cjs +0 -129
  4. package/dist/character-count/index.cjs.map +0 -1
  5. package/dist/character-count/index.d.cts +0 -62
  6. package/dist/character-count/index.d.ts +0 -62
  7. package/dist/character-count/index.js +0 -102
  8. package/dist/character-count/index.js.map +0 -1
  9. package/dist/drop-cursor/index.cjs +0 -47
  10. package/dist/drop-cursor/index.cjs.map +0 -1
  11. package/dist/drop-cursor/index.d.cts +0 -31
  12. package/dist/drop-cursor/index.d.ts +0 -31
  13. package/dist/drop-cursor/index.js +0 -20
  14. package/dist/drop-cursor/index.js.map +0 -1
  15. package/dist/focus/index.cjs +0 -95
  16. package/dist/focus/index.cjs.map +0 -1
  17. package/dist/focus/index.d.cts +0 -28
  18. package/dist/focus/index.d.ts +0 -28
  19. package/dist/focus/index.js +0 -68
  20. package/dist/focus/index.js.map +0 -1
  21. package/dist/gap-cursor/index.cjs +0 -51
  22. package/dist/gap-cursor/index.cjs.map +0 -1
  23. package/dist/gap-cursor/index.d.cts +0 -25
  24. package/dist/gap-cursor/index.d.ts +0 -25
  25. package/dist/gap-cursor/index.js +0 -24
  26. package/dist/gap-cursor/index.js.map +0 -1
  27. package/dist/index.cjs +0 -434
  28. package/dist/index.cjs.map +0 -1
  29. package/dist/index.d.cts +0 -284
  30. package/dist/index.d.ts +0 -284
  31. package/dist/index.js +0 -399
  32. package/dist/index.js.map +0 -1
  33. package/dist/placeholder/index.cjs +0 -96
  34. package/dist/placeholder/index.cjs.map +0 -1
  35. package/dist/placeholder/index.d.cts +0 -71
  36. package/dist/placeholder/index.d.ts +0 -71
  37. package/dist/placeholder/index.js +0 -68
  38. package/dist/placeholder/index.js.map +0 -1
  39. package/dist/selection/index.cjs +0 -63
  40. package/dist/selection/index.cjs.map +0 -1
  41. package/dist/selection/index.d.cts +0 -17
  42. package/dist/selection/index.d.ts +0 -17
  43. package/dist/selection/index.js +0 -36
  44. package/dist/selection/index.js.map +0 -1
  45. package/dist/trailing-node/index.cjs +0 -83
  46. package/dist/trailing-node/index.cjs.map +0 -1
  47. package/dist/trailing-node/index.d.cts +0 -28
  48. package/dist/trailing-node/index.d.ts +0 -28
  49. package/dist/trailing-node/index.js +0 -56
  50. package/dist/trailing-node/index.js.map +0 -1
  51. package/dist/undo-redo/index.cjs +0 -66
  52. package/dist/undo-redo/index.cjs.map +0 -1
  53. package/dist/undo-redo/index.d.cts +0 -44
  54. package/dist/undo-redo/index.d.ts +0 -44
  55. package/dist/undo-redo/index.js +0 -39
  56. package/dist/undo-redo/index.js.map +0 -1
package/dist/index.d.cts DELETED
@@ -1,284 +0,0 @@
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. Use `false` to apply no color and rely only on class.
65
- * @default 'currentColor'
66
- * @example 'red'
67
- */
68
- color?: string | false;
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
- /**
138
- * Prepares the placeholder attribute by ensuring it is properly formatted.
139
- * @param attr - The placeholder attribute string.
140
- * @returns The prepared placeholder attribute string.
141
- */
142
- declare function preparePlaceholderAttribute(attr: string): string;
143
- interface PlaceholderOptions {
144
- /**
145
- * **The class name for the empty editor**
146
- * @default 'is-editor-empty'
147
- */
148
- emptyEditorClass: string;
149
- /**
150
- * **The class name for empty nodes**
151
- * @default 'is-empty'
152
- */
153
- emptyNodeClass: string;
154
- /**
155
- * **The data-attribute used for the placeholder label**
156
- * Will be prepended with `data-` and converted to kebab-case and cleaned of special characters.
157
- * @default 'placeholder'
158
- */
159
- dataAttribute: string;
160
- /**
161
- * **The placeholder content**
162
- *
163
- * You can use a function to return a dynamic placeholder or a string.
164
- * @default 'Write something …'
165
- */
166
- placeholder: ((PlaceholderProps: {
167
- editor: Editor;
168
- node: Node;
169
- pos: number;
170
- hasAnchor: boolean;
171
- }) => string) | string;
172
- /**
173
- * **Checks if the placeholder should be only shown when the editor is editable.**
174
- *
175
- * If true, the placeholder will only be shown when the editor is editable.
176
- * If false, the placeholder will always be shown.
177
- * @default true
178
- */
179
- showOnlyWhenEditable: boolean;
180
- /**
181
- * **Checks if the placeholder should be only shown when the current node is empty.**
182
- *
183
- * If true, the placeholder will only be shown when the current node is empty.
184
- * If false, the placeholder will be shown when any node is empty.
185
- * @default true
186
- */
187
- showOnlyCurrent: boolean;
188
- /**
189
- * **Controls if the placeholder should be shown for all descendents.**
190
- *
191
- * If true, the placeholder will be shown for all descendents.
192
- * If false, the placeholder will only be shown for the current node.
193
- * @default false
194
- */
195
- includeChildren: boolean;
196
- }
197
- /**
198
- * This extension allows you to add a placeholder to your editor.
199
- * A placeholder is a text that appears when the editor or a node is empty.
200
- * @see https://www.tiptap.dev/api/extensions/placeholder
201
- */
202
- declare const Placeholder: Extension<PlaceholderOptions, any>;
203
-
204
- type SelectionOptions = {
205
- /**
206
- * The class name that should be added to the selected text.
207
- * @default 'selection'
208
- * @example 'is-selected'
209
- */
210
- className: string;
211
- };
212
- /**
213
- * This extension allows you to add a class to the selected text.
214
- * @see https://www.tiptap.dev/api/extensions/selection
215
- */
216
- declare const Selection: Extension<SelectionOptions, any>;
217
-
218
- /**
219
- * Extension based on:
220
- * - https://github.com/ueberdosis/tiptap/blob/v1/packages/tiptap-extensions/src/extensions/TrailingNode.js
221
- * - https://github.com/remirror/remirror/blob/e0f1bec4a1e8073ce8f5500d62193e52321155b9/packages/prosemirror-trailing-node/src/trailing-node-plugin.ts
222
- */
223
- interface TrailingNodeOptions {
224
- /**
225
- * The node type that should be inserted at the end of the document.
226
- * @note the node will always be added to the `notAfter` lists to
227
- * prevent an infinite loop.
228
- * @default undefined
229
- */
230
- node?: string;
231
- /**
232
- * The node types after which the trailing node should not be inserted.
233
- * @default ['paragraph']
234
- */
235
- notAfter?: string | string[];
236
- }
237
- /**
238
- * This extension allows you to add an extra node at the end of the document.
239
- * @see https://www.tiptap.dev/api/extensions/trailing-node
240
- */
241
- declare const TrailingNode: Extension<TrailingNodeOptions, any>;
242
-
243
- interface UndoRedoOptions {
244
- /**
245
- * The amount of history events that are collected before the oldest events are discarded.
246
- * @default 100
247
- * @example 50
248
- */
249
- depth: number;
250
- /**
251
- * The delay (in milliseconds) between changes after which a new group should be started.
252
- * @default 500
253
- * @example 1000
254
- */
255
- newGroupDelay: number;
256
- }
257
- declare module '@tiptap/core' {
258
- interface Commands<ReturnType> {
259
- undoRedo: {
260
- /**
261
- * Undo recent changes
262
- * @example editor.commands.undo()
263
- */
264
- undo: () => ReturnType;
265
- /**
266
- * Reapply reverted changes
267
- * @example editor.commands.redo()
268
- */
269
- redo: () => ReturnType;
270
- };
271
- }
272
- }
273
- /**
274
- * This extension allows you to undo and redo recent changes.
275
- * @see https://www.tiptap.dev/api/extensions/undo-redo
276
- *
277
- * **Important**: If the `@tiptap/extension-collaboration` package is used, make sure to remove
278
- * the `undo-redo` extension, as it is not compatible with the `collaboration` extension.
279
- *
280
- * `@tiptap/extension-collaboration` uses its own history implementation.
281
- */
282
- declare const UndoRedo: Extension<UndoRedoOptions, any>;
283
-
284
- 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, preparePlaceholderAttribute };
package/dist/index.d.ts DELETED
@@ -1,284 +0,0 @@
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. Use `false` to apply no color and rely only on class.
65
- * @default 'currentColor'
66
- * @example 'red'
67
- */
68
- color?: string | false;
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
- /**
138
- * Prepares the placeholder attribute by ensuring it is properly formatted.
139
- * @param attr - The placeholder attribute string.
140
- * @returns The prepared placeholder attribute string.
141
- */
142
- declare function preparePlaceholderAttribute(attr: string): string;
143
- interface PlaceholderOptions {
144
- /**
145
- * **The class name for the empty editor**
146
- * @default 'is-editor-empty'
147
- */
148
- emptyEditorClass: string;
149
- /**
150
- * **The class name for empty nodes**
151
- * @default 'is-empty'
152
- */
153
- emptyNodeClass: string;
154
- /**
155
- * **The data-attribute used for the placeholder label**
156
- * Will be prepended with `data-` and converted to kebab-case and cleaned of special characters.
157
- * @default 'placeholder'
158
- */
159
- dataAttribute: string;
160
- /**
161
- * **The placeholder content**
162
- *
163
- * You can use a function to return a dynamic placeholder or a string.
164
- * @default 'Write something …'
165
- */
166
- placeholder: ((PlaceholderProps: {
167
- editor: Editor;
168
- node: Node;
169
- pos: number;
170
- hasAnchor: boolean;
171
- }) => string) | string;
172
- /**
173
- * **Checks if the placeholder should be only shown when the editor is editable.**
174
- *
175
- * If true, the placeholder will only be shown when the editor is editable.
176
- * If false, the placeholder will always be shown.
177
- * @default true
178
- */
179
- showOnlyWhenEditable: boolean;
180
- /**
181
- * **Checks if the placeholder should be only shown when the current node is empty.**
182
- *
183
- * If true, the placeholder will only be shown when the current node is empty.
184
- * If false, the placeholder will be shown when any node is empty.
185
- * @default true
186
- */
187
- showOnlyCurrent: boolean;
188
- /**
189
- * **Controls if the placeholder should be shown for all descendents.**
190
- *
191
- * If true, the placeholder will be shown for all descendents.
192
- * If false, the placeholder will only be shown for the current node.
193
- * @default false
194
- */
195
- includeChildren: boolean;
196
- }
197
- /**
198
- * This extension allows you to add a placeholder to your editor.
199
- * A placeholder is a text that appears when the editor or a node is empty.
200
- * @see https://www.tiptap.dev/api/extensions/placeholder
201
- */
202
- declare const Placeholder: Extension<PlaceholderOptions, any>;
203
-
204
- type SelectionOptions = {
205
- /**
206
- * The class name that should be added to the selected text.
207
- * @default 'selection'
208
- * @example 'is-selected'
209
- */
210
- className: string;
211
- };
212
- /**
213
- * This extension allows you to add a class to the selected text.
214
- * @see https://www.tiptap.dev/api/extensions/selection
215
- */
216
- declare const Selection: Extension<SelectionOptions, any>;
217
-
218
- /**
219
- * Extension based on:
220
- * - https://github.com/ueberdosis/tiptap/blob/v1/packages/tiptap-extensions/src/extensions/TrailingNode.js
221
- * - https://github.com/remirror/remirror/blob/e0f1bec4a1e8073ce8f5500d62193e52321155b9/packages/prosemirror-trailing-node/src/trailing-node-plugin.ts
222
- */
223
- interface TrailingNodeOptions {
224
- /**
225
- * The node type that should be inserted at the end of the document.
226
- * @note the node will always be added to the `notAfter` lists to
227
- * prevent an infinite loop.
228
- * @default undefined
229
- */
230
- node?: string;
231
- /**
232
- * The node types after which the trailing node should not be inserted.
233
- * @default ['paragraph']
234
- */
235
- notAfter?: string | string[];
236
- }
237
- /**
238
- * This extension allows you to add an extra node at the end of the document.
239
- * @see https://www.tiptap.dev/api/extensions/trailing-node
240
- */
241
- declare const TrailingNode: Extension<TrailingNodeOptions, any>;
242
-
243
- interface UndoRedoOptions {
244
- /**
245
- * The amount of history events that are collected before the oldest events are discarded.
246
- * @default 100
247
- * @example 50
248
- */
249
- depth: number;
250
- /**
251
- * The delay (in milliseconds) between changes after which a new group should be started.
252
- * @default 500
253
- * @example 1000
254
- */
255
- newGroupDelay: number;
256
- }
257
- declare module '@tiptap/core' {
258
- interface Commands<ReturnType> {
259
- undoRedo: {
260
- /**
261
- * Undo recent changes
262
- * @example editor.commands.undo()
263
- */
264
- undo: () => ReturnType;
265
- /**
266
- * Reapply reverted changes
267
- * @example editor.commands.redo()
268
- */
269
- redo: () => ReturnType;
270
- };
271
- }
272
- }
273
- /**
274
- * This extension allows you to undo and redo recent changes.
275
- * @see https://www.tiptap.dev/api/extensions/undo-redo
276
- *
277
- * **Important**: If the `@tiptap/extension-collaboration` package is used, make sure to remove
278
- * the `undo-redo` extension, as it is not compatible with the `collaboration` extension.
279
- *
280
- * `@tiptap/extension-collaboration` uses its own history implementation.
281
- */
282
- declare const UndoRedo: Extension<UndoRedoOptions, any>;
283
-
284
- 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, preparePlaceholderAttribute };