@tiptap/extension-list 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/bullet-list/index.cjs +93 -0
- package/dist/bullet-list/index.cjs.map +1 -0
- package/dist/bullet-list/index.d.cts +51 -0
- package/dist/bullet-list/index.d.ts +51 -0
- package/dist/bullet-list/index.js +65 -0
- package/dist/bullet-list/index.js.map +1 -0
- package/dist/index.cjs +714 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +288 -0
- package/dist/index.d.ts +288 -0
- package/dist/index.js +683 -0
- package/dist/index.js.map +1 -0
- package/dist/item/index.cjs +62 -0
- package/dist/item/index.cjs.map +1 -0
- package/dist/item/index.d.cts +29 -0
- package/dist/item/index.d.ts +29 -0
- package/dist/item/index.js +35 -0
- package/dist/item/index.js.map +1 -0
- package/dist/keymap/index.cjs +308 -0
- package/dist/keymap/index.cjs.map +1 -0
- package/dist/keymap/index.d.cts +63 -0
- package/dist/keymap/index.d.ts +63 -0
- package/dist/keymap/index.js +286 -0
- package/dist/keymap/index.js.map +1 -0
- package/dist/kit/index.cjs +692 -0
- package/dist/kit/index.cjs.map +1 -0
- package/dist/kit/index.d.cts +200 -0
- package/dist/kit/index.d.ts +200 -0
- package/dist/kit/index.js +673 -0
- package/dist/kit/index.js.map +1 -0
- package/dist/ordered-list/index.cjs +113 -0
- package/dist/ordered-list/index.cjs.map +1 -0
- package/dist/ordered-list/index.d.cts +52 -0
- package/dist/ordered-list/index.d.ts +52 -0
- package/dist/ordered-list/index.js +85 -0
- package/dist/ordered-list/index.js.map +1 -0
- package/dist/task-item/index.cjs +177 -0
- package/dist/task-item/index.cjs.map +1 -0
- package/dist/task-item/index.d.cts +41 -0
- package/dist/task-item/index.d.ts +41 -0
- package/dist/task-item/index.js +149 -0
- package/dist/task-item/index.js.map +1 -0
- package/dist/task-list/index.cjs +69 -0
- package/dist/task-list/index.cjs.map +1 -0
- package/dist/task-list/index.d.cts +34 -0
- package/dist/task-list/index.d.ts +34 -0
- package/dist/task-list/index.js +42 -0
- package/dist/task-list/index.js.map +1 -0
- package/package.json +106 -0
- package/src/bullet-list/bullet-list.ts +126 -0
- package/src/bullet-list/index.ts +1 -0
- package/src/index.ts +7 -0
- package/src/item/index.ts +1 -0
- package/src/item/list-item.ts +64 -0
- package/src/keymap/index.ts +2 -0
- package/src/keymap/list-keymap.ts +106 -0
- package/src/keymap/listHelpers/findListItemPos.ts +30 -0
- package/src/keymap/listHelpers/getNextListDepth.ts +16 -0
- package/src/keymap/listHelpers/handleBackspace.ts +85 -0
- package/src/keymap/listHelpers/handleDelete.ts +44 -0
- package/src/keymap/listHelpers/hasListBefore.ts +15 -0
- package/src/keymap/listHelpers/hasListItemAfter.ts +17 -0
- package/src/keymap/listHelpers/hasListItemBefore.ts +17 -0
- package/src/keymap/listHelpers/index.ts +10 -0
- package/src/keymap/listHelpers/listItemHasSubList.ts +21 -0
- package/src/keymap/listHelpers/nextListIsDeeper.ts +19 -0
- package/src/keymap/listHelpers/nextListIsHigher.ts +19 -0
- package/src/kit/index.ts +81 -0
- package/src/ordered-list/index.ts +1 -0
- package/src/ordered-list/ordered-list.ts +151 -0
- package/src/task-item/index.ts +1 -0
- package/src/task-item/task-item.ts +220 -0
- package/src/task-list/index.ts +1 -0
- package/src/task-list/task-list.ts +79 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
import { Node, Extension, Editor } from '@tiptap/core';
|
|
2
|
+
import * as _tiptap_pm_model from '@tiptap/pm/model';
|
|
3
|
+
import { NodeType, Node as Node$1 } from '@tiptap/pm/model';
|
|
4
|
+
import { EditorState } from '@tiptap/pm/state';
|
|
5
|
+
|
|
6
|
+
interface BulletListOptions {
|
|
7
|
+
/**
|
|
8
|
+
* The node name for the list items
|
|
9
|
+
* @default 'listItem'
|
|
10
|
+
* @example 'paragraph'
|
|
11
|
+
*/
|
|
12
|
+
itemTypeName: string;
|
|
13
|
+
/**
|
|
14
|
+
* HTML attributes to add to the bullet list element
|
|
15
|
+
* @default {}
|
|
16
|
+
* @example { class: 'foo' }
|
|
17
|
+
*/
|
|
18
|
+
HTMLAttributes: Record<string, any>;
|
|
19
|
+
/**
|
|
20
|
+
* Keep the marks when splitting the list
|
|
21
|
+
* @default false
|
|
22
|
+
* @example true
|
|
23
|
+
*/
|
|
24
|
+
keepMarks: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Keep the attributes when splitting the list
|
|
27
|
+
* @default false
|
|
28
|
+
* @example true
|
|
29
|
+
*/
|
|
30
|
+
keepAttributes: boolean;
|
|
31
|
+
}
|
|
32
|
+
declare module '@tiptap/core' {
|
|
33
|
+
interface Commands<ReturnType> {
|
|
34
|
+
bulletList: {
|
|
35
|
+
/**
|
|
36
|
+
* Toggle a bullet list
|
|
37
|
+
*/
|
|
38
|
+
toggleBulletList: () => ReturnType;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Matches a bullet list to a dash or asterisk.
|
|
44
|
+
*/
|
|
45
|
+
declare const bulletListInputRegex: RegExp;
|
|
46
|
+
/**
|
|
47
|
+
* This extension allows you to create bullet lists.
|
|
48
|
+
* This requires the ListItem extension
|
|
49
|
+
* @see https://tiptap.dev/api/nodes/bullet-list
|
|
50
|
+
* @see https://tiptap.dev/api/nodes/list-item.
|
|
51
|
+
*/
|
|
52
|
+
declare const BulletList: Node<BulletListOptions, any>;
|
|
53
|
+
|
|
54
|
+
interface ListItemOptions {
|
|
55
|
+
/**
|
|
56
|
+
* The HTML attributes for a list item node.
|
|
57
|
+
* @default {}
|
|
58
|
+
* @example { class: 'foo' }
|
|
59
|
+
*/
|
|
60
|
+
HTMLAttributes: Record<string, any>;
|
|
61
|
+
/**
|
|
62
|
+
* The node type for bulletList nodes
|
|
63
|
+
* @default 'bulletList'
|
|
64
|
+
* @example 'myCustomBulletList'
|
|
65
|
+
*/
|
|
66
|
+
bulletListTypeName: string;
|
|
67
|
+
/**
|
|
68
|
+
* The node type for orderedList nodes
|
|
69
|
+
* @default 'orderedList'
|
|
70
|
+
* @example 'myCustomOrderedList'
|
|
71
|
+
*/
|
|
72
|
+
orderedListTypeName: string;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* This extension allows you to create list items.
|
|
76
|
+
* @see https://www.tiptap.dev/api/nodes/list-item
|
|
77
|
+
*/
|
|
78
|
+
declare const ListItem: Node<ListItemOptions, any>;
|
|
79
|
+
|
|
80
|
+
type ListKeymapOptions = {
|
|
81
|
+
/**
|
|
82
|
+
* An array of list types. This is used for item and wrapper list matching.
|
|
83
|
+
* @default []
|
|
84
|
+
* @example [{ itemName: 'listItem', wrapperNames: ['bulletList', 'orderedList'] }]
|
|
85
|
+
*/
|
|
86
|
+
listTypes: Array<{
|
|
87
|
+
itemName: string;
|
|
88
|
+
wrapperNames: string[];
|
|
89
|
+
}>;
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* This extension registers custom keymaps to change the behaviour of the backspace and delete keys.
|
|
93
|
+
* By default Prosemirror keyhandling will always lift or sink items so paragraphs are joined into
|
|
94
|
+
* the adjacent or previous list item. This extension will prevent this behaviour and instead will
|
|
95
|
+
* try to join paragraphs from two list items into a single list item.
|
|
96
|
+
* @see https://www.tiptap.dev/api/extensions/list-keymap
|
|
97
|
+
*/
|
|
98
|
+
declare const ListKeymap: Extension<ListKeymapOptions, any>;
|
|
99
|
+
|
|
100
|
+
declare const findListItemPos: (typeOrName: string | NodeType, state: EditorState) => {
|
|
101
|
+
$pos: _tiptap_pm_model.ResolvedPos;
|
|
102
|
+
depth: number;
|
|
103
|
+
} | null;
|
|
104
|
+
|
|
105
|
+
declare const getNextListDepth: (typeOrName: string, state: EditorState) => number | false;
|
|
106
|
+
|
|
107
|
+
declare const handleBackspace: (editor: Editor, name: string, parentListTypes: string[]) => boolean;
|
|
108
|
+
|
|
109
|
+
declare const handleDelete: (editor: Editor, name: string) => boolean;
|
|
110
|
+
|
|
111
|
+
declare const hasListBefore: (editorState: EditorState, name: string, parentListTypes: string[]) => boolean;
|
|
112
|
+
|
|
113
|
+
declare const hasListItemAfter: (typeOrName: string, state: EditorState) => boolean;
|
|
114
|
+
|
|
115
|
+
declare const hasListItemBefore: (typeOrName: string, state: EditorState) => boolean;
|
|
116
|
+
|
|
117
|
+
declare const listItemHasSubList: (typeOrName: string, state: EditorState, node?: Node$1) => boolean;
|
|
118
|
+
|
|
119
|
+
declare const nextListIsDeeper: (typeOrName: string, state: EditorState) => boolean;
|
|
120
|
+
|
|
121
|
+
declare const nextListIsHigher: (typeOrName: string, state: EditorState) => boolean;
|
|
122
|
+
|
|
123
|
+
declare const index_findListItemPos: typeof findListItemPos;
|
|
124
|
+
declare const index_getNextListDepth: typeof getNextListDepth;
|
|
125
|
+
declare const index_handleBackspace: typeof handleBackspace;
|
|
126
|
+
declare const index_handleDelete: typeof handleDelete;
|
|
127
|
+
declare const index_hasListBefore: typeof hasListBefore;
|
|
128
|
+
declare const index_hasListItemAfter: typeof hasListItemAfter;
|
|
129
|
+
declare const index_hasListItemBefore: typeof hasListItemBefore;
|
|
130
|
+
declare const index_listItemHasSubList: typeof listItemHasSubList;
|
|
131
|
+
declare const index_nextListIsDeeper: typeof nextListIsDeeper;
|
|
132
|
+
declare const index_nextListIsHigher: typeof nextListIsHigher;
|
|
133
|
+
declare namespace index {
|
|
134
|
+
export { index_findListItemPos as findListItemPos, index_getNextListDepth as getNextListDepth, index_handleBackspace as handleBackspace, index_handleDelete as handleDelete, index_hasListBefore as hasListBefore, index_hasListItemAfter as hasListItemAfter, index_hasListItemBefore as hasListItemBefore, index_listItemHasSubList as listItemHasSubList, index_nextListIsDeeper as nextListIsDeeper, index_nextListIsHigher as nextListIsHigher };
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
interface OrderedListOptions {
|
|
138
|
+
/**
|
|
139
|
+
* The node type name for list items.
|
|
140
|
+
* @default 'listItem'
|
|
141
|
+
* @example 'myListItem'
|
|
142
|
+
*/
|
|
143
|
+
itemTypeName: string;
|
|
144
|
+
/**
|
|
145
|
+
* The HTML attributes for an ordered list node.
|
|
146
|
+
* @default {}
|
|
147
|
+
* @example { class: 'foo' }
|
|
148
|
+
*/
|
|
149
|
+
HTMLAttributes: Record<string, any>;
|
|
150
|
+
/**
|
|
151
|
+
* Keep the marks when splitting a list item.
|
|
152
|
+
* @default false
|
|
153
|
+
* @example true
|
|
154
|
+
*/
|
|
155
|
+
keepMarks: boolean;
|
|
156
|
+
/**
|
|
157
|
+
* Keep the attributes when splitting a list item.
|
|
158
|
+
* @default false
|
|
159
|
+
* @example true
|
|
160
|
+
*/
|
|
161
|
+
keepAttributes: boolean;
|
|
162
|
+
}
|
|
163
|
+
declare module '@tiptap/core' {
|
|
164
|
+
interface Commands<ReturnType> {
|
|
165
|
+
orderedList: {
|
|
166
|
+
/**
|
|
167
|
+
* Toggle an ordered list
|
|
168
|
+
* @example editor.commands.toggleOrderedList()
|
|
169
|
+
*/
|
|
170
|
+
toggleOrderedList: () => ReturnType;
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Matches an ordered list to a 1. on input (or any number followed by a dot).
|
|
176
|
+
*/
|
|
177
|
+
declare const orderedListInputRegex: RegExp;
|
|
178
|
+
/**
|
|
179
|
+
* This extension allows you to create ordered lists.
|
|
180
|
+
* This requires the ListItem extension
|
|
181
|
+
* @see https://www.tiptap.dev/api/nodes/ordered-list
|
|
182
|
+
* @see https://www.tiptap.dev/api/nodes/list-item
|
|
183
|
+
*/
|
|
184
|
+
declare const OrderedList: Node<OrderedListOptions, any>;
|
|
185
|
+
|
|
186
|
+
interface TaskItemOptions {
|
|
187
|
+
/**
|
|
188
|
+
* A callback function that is called when the checkbox is clicked while the editor is in readonly mode.
|
|
189
|
+
* @param node The prosemirror node of the task item
|
|
190
|
+
* @param checked The new checked state
|
|
191
|
+
* @returns boolean
|
|
192
|
+
*/
|
|
193
|
+
onReadOnlyChecked?: (node: Node$1, checked: boolean) => boolean;
|
|
194
|
+
/**
|
|
195
|
+
* Controls whether the task items can be nested or not.
|
|
196
|
+
* @default false
|
|
197
|
+
* @example true
|
|
198
|
+
*/
|
|
199
|
+
nested: boolean;
|
|
200
|
+
/**
|
|
201
|
+
* HTML attributes to add to the task item element.
|
|
202
|
+
* @default {}
|
|
203
|
+
* @example { class: 'foo' }
|
|
204
|
+
*/
|
|
205
|
+
HTMLAttributes: Record<string, any>;
|
|
206
|
+
/**
|
|
207
|
+
* The node type for taskList nodes
|
|
208
|
+
* @default 'taskList'
|
|
209
|
+
* @example 'myCustomTaskList'
|
|
210
|
+
*/
|
|
211
|
+
taskListTypeName: string;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Matches a task item to a - [ ] on input.
|
|
215
|
+
*/
|
|
216
|
+
declare const inputRegex: RegExp;
|
|
217
|
+
/**
|
|
218
|
+
* This extension allows you to create task items.
|
|
219
|
+
* @see https://www.tiptap.dev/api/nodes/task-item
|
|
220
|
+
*/
|
|
221
|
+
declare const TaskItem: Node<TaskItemOptions, any>;
|
|
222
|
+
|
|
223
|
+
interface TaskListOptions {
|
|
224
|
+
/**
|
|
225
|
+
* The node type name for a task item.
|
|
226
|
+
* @default 'taskItem'
|
|
227
|
+
* @example 'myCustomTaskItem'
|
|
228
|
+
*/
|
|
229
|
+
itemTypeName: string;
|
|
230
|
+
/**
|
|
231
|
+
* The HTML attributes for a task list node.
|
|
232
|
+
* @default {}
|
|
233
|
+
* @example { class: 'foo' }
|
|
234
|
+
*/
|
|
235
|
+
HTMLAttributes: Record<string, any>;
|
|
236
|
+
}
|
|
237
|
+
declare module '@tiptap/core' {
|
|
238
|
+
interface Commands<ReturnType> {
|
|
239
|
+
taskList: {
|
|
240
|
+
/**
|
|
241
|
+
* Toggle a task list
|
|
242
|
+
* @example editor.commands.toggleTaskList()
|
|
243
|
+
*/
|
|
244
|
+
toggleTaskList: () => ReturnType;
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* This extension allows you to create task lists.
|
|
250
|
+
* @see https://www.tiptap.dev/api/nodes/task-list
|
|
251
|
+
*/
|
|
252
|
+
declare const TaskList: Node<TaskListOptions, any>;
|
|
253
|
+
|
|
254
|
+
interface ListKitOptions {
|
|
255
|
+
/**
|
|
256
|
+
* If set to false, the bulletList extension will not be registered
|
|
257
|
+
* @example table: false
|
|
258
|
+
*/
|
|
259
|
+
bulletList: Partial<BulletListOptions> | false;
|
|
260
|
+
/**
|
|
261
|
+
* If set to false, the listItem extension will not be registered
|
|
262
|
+
*/
|
|
263
|
+
listItem: Partial<ListItemOptions> | false;
|
|
264
|
+
/**
|
|
265
|
+
* If set to false, the listKeymap extension will not be registered
|
|
266
|
+
*/
|
|
267
|
+
listKeymap: Partial<ListKeymapOptions> | false;
|
|
268
|
+
/**
|
|
269
|
+
* If set to false, the orderedList extension will not be registered
|
|
270
|
+
*/
|
|
271
|
+
orderedList: Partial<OrderedListOptions> | false;
|
|
272
|
+
/**
|
|
273
|
+
* If set to false, the taskItem extension will not be registered
|
|
274
|
+
*/
|
|
275
|
+
taskItem: Partial<TaskItemOptions> | false;
|
|
276
|
+
/**
|
|
277
|
+
* If set to false, the taskList extension will not be registered
|
|
278
|
+
*/
|
|
279
|
+
taskList: Partial<TaskListOptions> | false;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* The table kit is a collection of table editor extensions.
|
|
283
|
+
*
|
|
284
|
+
* It’s a good starting point for building your own table in Tiptap.
|
|
285
|
+
*/
|
|
286
|
+
declare const ListKit: Extension<ListKitOptions, any>;
|
|
287
|
+
|
|
288
|
+
export { BulletList, type BulletListOptions, ListItem, type ListItemOptions, ListKeymap, type ListKeymapOptions, ListKit, type ListKitOptions, OrderedList, type OrderedListOptions, TaskItem, type TaskItemOptions, TaskList, type TaskListOptions, bulletListInputRegex, inputRegex, index as listHelpers, orderedListInputRegex };
|