@tiptap/extension-list-keymap 3.0.0-next.3 → 3.0.0-next.5
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 +5 -1
- package/dist/index.cjs +11 -285
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -63
- package/dist/index.d.ts +2 -63
- package/dist/index.js +7 -286
- package/dist/index.js.map +1 -1
- package/package.json +10 -6
- package/src/index.ts +2 -3
- package/src/list-keymap.ts +0 -106
- package/src/listHelpers/findListItemPos.ts +0 -30
- package/src/listHelpers/getNextListDepth.ts +0 -16
- package/src/listHelpers/handleBackspace.ts +0 -80
- package/src/listHelpers/handleDelete.ts +0 -46
- package/src/listHelpers/hasListBefore.ts +0 -15
- package/src/listHelpers/hasListItemAfter.ts +0 -17
- package/src/listHelpers/hasListItemBefore.ts +0 -17
- package/src/listHelpers/index.ts +0 -10
- package/src/listHelpers/listItemHasSubList.ts +0 -21
- package/src/listHelpers/nextListIsDeeper.ts +0 -19
- package/src/listHelpers/nextListIsHigher.ts +0 -19
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025, Tiptap GmbH
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
# @tiptap/extension-list-keymap
|
|
2
|
+
|
|
2
3
|
[](https://www.npmjs.com/package/@tiptap/extension-list-keymap)
|
|
3
4
|
[](https://npmcharts.com/compare/tiptap?minimal=true)
|
|
4
5
|
[](https://www.npmjs.com/package/@tiptap/extension-list-keymap)
|
|
5
6
|
[](https://github.com/sponsors/ueberdosis)
|
|
6
7
|
|
|
7
8
|
## Introduction
|
|
8
|
-
|
|
9
|
+
|
|
10
|
+
Tiptap is a headless wrapper around [ProseMirror](https://ProseMirror.net) – a toolkit for building rich text WYSIWYG editors, which is already in use at many well-known companies such as _New York Times_, _The Guardian_ or _Atlassian_.
|
|
9
11
|
|
|
10
12
|
## Official Documentation
|
|
13
|
+
|
|
11
14
|
Documentation can be found on the [Tiptap website](https://tiptap.dev).
|
|
12
15
|
|
|
13
16
|
## License
|
|
17
|
+
|
|
14
18
|
Tiptap is open sourced software licensed under the [MIT license](https://github.com/ueberdosis/tiptap/blob/main/LICENSE.md).
|
package/dist/index.cjs
CHANGED
|
@@ -18,295 +18,21 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
|
|
20
20
|
// src/index.ts
|
|
21
|
-
var
|
|
22
|
-
__export(
|
|
23
|
-
ListKeymap: () => ListKeymap,
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
ListKeymap: () => import_extension_list2.ListKeymap,
|
|
24
|
+
ListKeymapOptions: () => import_extension_list2.ListKeymapOptions,
|
|
25
|
+
default: () => index_default,
|
|
26
|
+
listHelpers: () => import_extension_list2.listHelpers
|
|
26
27
|
});
|
|
27
|
-
module.exports = __toCommonJS(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
var
|
|
31
|
-
|
|
32
|
-
// src/listHelpers/index.ts
|
|
33
|
-
var listHelpers_exports = {};
|
|
34
|
-
__export(listHelpers_exports, {
|
|
35
|
-
findListItemPos: () => findListItemPos,
|
|
36
|
-
getNextListDepth: () => getNextListDepth,
|
|
37
|
-
handleBackspace: () => handleBackspace,
|
|
38
|
-
handleDelete: () => handleDelete,
|
|
39
|
-
hasListBefore: () => hasListBefore,
|
|
40
|
-
hasListItemAfter: () => hasListItemAfter,
|
|
41
|
-
hasListItemBefore: () => hasListItemBefore,
|
|
42
|
-
listItemHasSubList: () => listItemHasSubList,
|
|
43
|
-
nextListIsDeeper: () => nextListIsDeeper,
|
|
44
|
-
nextListIsHigher: () => nextListIsHigher
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
// src/listHelpers/findListItemPos.ts
|
|
48
|
-
var import_core = require("@tiptap/core");
|
|
49
|
-
var findListItemPos = (typeOrName, state) => {
|
|
50
|
-
const { $from } = state.selection;
|
|
51
|
-
const nodeType = (0, import_core.getNodeType)(typeOrName, state.schema);
|
|
52
|
-
let currentNode = null;
|
|
53
|
-
let currentDepth = $from.depth;
|
|
54
|
-
let currentPos = $from.pos;
|
|
55
|
-
let targetDepth = null;
|
|
56
|
-
while (currentDepth > 0 && targetDepth === null) {
|
|
57
|
-
currentNode = $from.node(currentDepth);
|
|
58
|
-
if (currentNode.type === nodeType) {
|
|
59
|
-
targetDepth = currentDepth;
|
|
60
|
-
} else {
|
|
61
|
-
currentDepth -= 1;
|
|
62
|
-
currentPos -= 1;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
if (targetDepth === null) {
|
|
66
|
-
return null;
|
|
67
|
-
}
|
|
68
|
-
return { $pos: state.doc.resolve(currentPos), depth: targetDepth };
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
// src/listHelpers/getNextListDepth.ts
|
|
72
|
-
var import_core2 = require("@tiptap/core");
|
|
73
|
-
var getNextListDepth = (typeOrName, state) => {
|
|
74
|
-
const listItemPos = findListItemPos(typeOrName, state);
|
|
75
|
-
if (!listItemPos) {
|
|
76
|
-
return false;
|
|
77
|
-
}
|
|
78
|
-
const [, depth] = (0, import_core2.getNodeAtPosition)(state, typeOrName, listItemPos.$pos.pos + 4);
|
|
79
|
-
return depth;
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
// src/listHelpers/handleBackspace.ts
|
|
83
|
-
var import_core4 = require("@tiptap/core");
|
|
84
|
-
|
|
85
|
-
// src/listHelpers/hasListBefore.ts
|
|
86
|
-
var hasListBefore = (editorState, name, parentListTypes) => {
|
|
87
|
-
const { $anchor } = editorState.selection;
|
|
88
|
-
const previousNodePos = Math.max(0, $anchor.pos - 2);
|
|
89
|
-
const previousNode = editorState.doc.resolve(previousNodePos).node();
|
|
90
|
-
if (!previousNode || !parentListTypes.includes(previousNode.type.name)) {
|
|
91
|
-
return false;
|
|
92
|
-
}
|
|
93
|
-
return true;
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
// src/listHelpers/hasListItemBefore.ts
|
|
97
|
-
var hasListItemBefore = (typeOrName, state) => {
|
|
98
|
-
var _a;
|
|
99
|
-
const { $anchor } = state.selection;
|
|
100
|
-
const $targetPos = state.doc.resolve($anchor.pos - 2);
|
|
101
|
-
if ($targetPos.index() === 0) {
|
|
102
|
-
return false;
|
|
103
|
-
}
|
|
104
|
-
if (((_a = $targetPos.nodeBefore) == null ? void 0 : _a.type.name) !== typeOrName) {
|
|
105
|
-
return false;
|
|
106
|
-
}
|
|
107
|
-
return true;
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
// src/listHelpers/listItemHasSubList.ts
|
|
111
|
-
var import_core3 = require("@tiptap/core");
|
|
112
|
-
var listItemHasSubList = (typeOrName, state, node) => {
|
|
113
|
-
if (!node) {
|
|
114
|
-
return false;
|
|
115
|
-
}
|
|
116
|
-
const nodeType = (0, import_core3.getNodeType)(typeOrName, state.schema);
|
|
117
|
-
let hasSubList = false;
|
|
118
|
-
node.descendants((child) => {
|
|
119
|
-
if (child.type === nodeType) {
|
|
120
|
-
hasSubList = true;
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
return hasSubList;
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
// src/listHelpers/handleBackspace.ts
|
|
127
|
-
var handleBackspace = (editor, name, parentListTypes) => {
|
|
128
|
-
if (editor.commands.undoInputRule()) {
|
|
129
|
-
return true;
|
|
130
|
-
}
|
|
131
|
-
if (editor.state.selection.from !== editor.state.selection.to) {
|
|
132
|
-
return false;
|
|
133
|
-
}
|
|
134
|
-
if (!(0, import_core4.isNodeActive)(editor.state, name) && hasListBefore(editor.state, name, parentListTypes)) {
|
|
135
|
-
const { $anchor } = editor.state.selection;
|
|
136
|
-
const $listPos = editor.state.doc.resolve($anchor.before() - 1);
|
|
137
|
-
const listDescendants = [];
|
|
138
|
-
$listPos.node().descendants((node, pos) => {
|
|
139
|
-
if (node.type.name === name) {
|
|
140
|
-
listDescendants.push({ node, pos });
|
|
141
|
-
}
|
|
142
|
-
});
|
|
143
|
-
const lastItem = listDescendants.at(-1);
|
|
144
|
-
if (!lastItem) {
|
|
145
|
-
return false;
|
|
146
|
-
}
|
|
147
|
-
const $lastItemPos = editor.state.doc.resolve($listPos.start() + lastItem.pos + 1);
|
|
148
|
-
return editor.chain().cut({ from: $anchor.start() - 1, to: $anchor.end() + 1 }, $lastItemPos.end()).joinForward().run();
|
|
149
|
-
}
|
|
150
|
-
if (!(0, import_core4.isNodeActive)(editor.state, name)) {
|
|
151
|
-
return false;
|
|
152
|
-
}
|
|
153
|
-
if (!(0, import_core4.isAtStartOfNode)(editor.state)) {
|
|
154
|
-
return false;
|
|
155
|
-
}
|
|
156
|
-
const listItemPos = findListItemPos(name, editor.state);
|
|
157
|
-
if (!listItemPos) {
|
|
158
|
-
return false;
|
|
159
|
-
}
|
|
160
|
-
const $prev = editor.state.doc.resolve(listItemPos.$pos.pos - 2);
|
|
161
|
-
const prevNode = $prev.node(listItemPos.depth);
|
|
162
|
-
const previousListItemHasSubList = listItemHasSubList(name, editor.state, prevNode);
|
|
163
|
-
if (hasListItemBefore(name, editor.state) && !previousListItemHasSubList) {
|
|
164
|
-
return editor.commands.joinItemBackward();
|
|
165
|
-
}
|
|
166
|
-
return editor.chain().liftListItem(name).run();
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
// src/listHelpers/handleDelete.ts
|
|
170
|
-
var import_core5 = require("@tiptap/core");
|
|
171
|
-
|
|
172
|
-
// src/listHelpers/nextListIsDeeper.ts
|
|
173
|
-
var nextListIsDeeper = (typeOrName, state) => {
|
|
174
|
-
const listDepth = getNextListDepth(typeOrName, state);
|
|
175
|
-
const listItemPos = findListItemPos(typeOrName, state);
|
|
176
|
-
if (!listItemPos || !listDepth) {
|
|
177
|
-
return false;
|
|
178
|
-
}
|
|
179
|
-
if (listDepth > listItemPos.depth) {
|
|
180
|
-
return true;
|
|
181
|
-
}
|
|
182
|
-
return false;
|
|
183
|
-
};
|
|
184
|
-
|
|
185
|
-
// src/listHelpers/nextListIsHigher.ts
|
|
186
|
-
var nextListIsHigher = (typeOrName, state) => {
|
|
187
|
-
const listDepth = getNextListDepth(typeOrName, state);
|
|
188
|
-
const listItemPos = findListItemPos(typeOrName, state);
|
|
189
|
-
if (!listItemPos || !listDepth) {
|
|
190
|
-
return false;
|
|
191
|
-
}
|
|
192
|
-
if (listDepth < listItemPos.depth) {
|
|
193
|
-
return true;
|
|
194
|
-
}
|
|
195
|
-
return false;
|
|
196
|
-
};
|
|
197
|
-
|
|
198
|
-
// src/listHelpers/handleDelete.ts
|
|
199
|
-
var handleDelete = (editor, name) => {
|
|
200
|
-
if (!(0, import_core5.isNodeActive)(editor.state, name)) {
|
|
201
|
-
return false;
|
|
202
|
-
}
|
|
203
|
-
if (!(0, import_core5.isAtEndOfNode)(editor.state, name)) {
|
|
204
|
-
return false;
|
|
205
|
-
}
|
|
206
|
-
const { selection } = editor.state;
|
|
207
|
-
const { $from, $to } = selection;
|
|
208
|
-
if (!selection.empty && $from.sameParent($to)) {
|
|
209
|
-
return false;
|
|
210
|
-
}
|
|
211
|
-
if (nextListIsDeeper(name, editor.state)) {
|
|
212
|
-
return editor.chain().focus(editor.state.selection.from + 4).lift(name).joinBackward().run();
|
|
213
|
-
}
|
|
214
|
-
if (nextListIsHigher(name, editor.state)) {
|
|
215
|
-
return editor.chain().joinForward().joinBackward().run();
|
|
216
|
-
}
|
|
217
|
-
return editor.commands.joinItemForward();
|
|
218
|
-
};
|
|
219
|
-
|
|
220
|
-
// src/listHelpers/hasListItemAfter.ts
|
|
221
|
-
var hasListItemAfter = (typeOrName, state) => {
|
|
222
|
-
var _a;
|
|
223
|
-
const { $anchor } = state.selection;
|
|
224
|
-
const $targetPos = state.doc.resolve($anchor.pos - $anchor.parentOffset - 2);
|
|
225
|
-
if ($targetPos.index() === $targetPos.parent.childCount - 1) {
|
|
226
|
-
return false;
|
|
227
|
-
}
|
|
228
|
-
if (((_a = $targetPos.nodeAfter) == null ? void 0 : _a.type.name) !== typeOrName) {
|
|
229
|
-
return false;
|
|
230
|
-
}
|
|
231
|
-
return true;
|
|
232
|
-
};
|
|
233
|
-
|
|
234
|
-
// src/list-keymap.ts
|
|
235
|
-
var ListKeymap = import_core6.Extension.create({
|
|
236
|
-
name: "listKeymap",
|
|
237
|
-
addOptions() {
|
|
238
|
-
return {
|
|
239
|
-
listTypes: [
|
|
240
|
-
{
|
|
241
|
-
itemName: "listItem",
|
|
242
|
-
wrapperNames: ["bulletList", "orderedList"]
|
|
243
|
-
},
|
|
244
|
-
{
|
|
245
|
-
itemName: "taskItem",
|
|
246
|
-
wrapperNames: ["taskList"]
|
|
247
|
-
}
|
|
248
|
-
]
|
|
249
|
-
};
|
|
250
|
-
},
|
|
251
|
-
addKeyboardShortcuts() {
|
|
252
|
-
return {
|
|
253
|
-
Delete: ({ editor }) => {
|
|
254
|
-
let handled = false;
|
|
255
|
-
this.options.listTypes.forEach(({ itemName }) => {
|
|
256
|
-
if (editor.state.schema.nodes[itemName] === void 0) {
|
|
257
|
-
return;
|
|
258
|
-
}
|
|
259
|
-
if (handleDelete(editor, itemName)) {
|
|
260
|
-
handled = true;
|
|
261
|
-
}
|
|
262
|
-
});
|
|
263
|
-
return handled;
|
|
264
|
-
},
|
|
265
|
-
"Mod-Delete": ({ editor }) => {
|
|
266
|
-
let handled = false;
|
|
267
|
-
this.options.listTypes.forEach(({ itemName }) => {
|
|
268
|
-
if (editor.state.schema.nodes[itemName] === void 0) {
|
|
269
|
-
return;
|
|
270
|
-
}
|
|
271
|
-
if (handleDelete(editor, itemName)) {
|
|
272
|
-
handled = true;
|
|
273
|
-
}
|
|
274
|
-
});
|
|
275
|
-
return handled;
|
|
276
|
-
},
|
|
277
|
-
Backspace: ({ editor }) => {
|
|
278
|
-
let handled = false;
|
|
279
|
-
this.options.listTypes.forEach(({ itemName, wrapperNames }) => {
|
|
280
|
-
if (editor.state.schema.nodes[itemName] === void 0) {
|
|
281
|
-
return;
|
|
282
|
-
}
|
|
283
|
-
if (handleBackspace(editor, itemName, wrapperNames)) {
|
|
284
|
-
handled = true;
|
|
285
|
-
}
|
|
286
|
-
});
|
|
287
|
-
return handled;
|
|
288
|
-
},
|
|
289
|
-
"Mod-Backspace": ({ editor }) => {
|
|
290
|
-
let handled = false;
|
|
291
|
-
this.options.listTypes.forEach(({ itemName, wrapperNames }) => {
|
|
292
|
-
if (editor.state.schema.nodes[itemName] === void 0) {
|
|
293
|
-
return;
|
|
294
|
-
}
|
|
295
|
-
if (handleBackspace(editor, itemName, wrapperNames)) {
|
|
296
|
-
handled = true;
|
|
297
|
-
}
|
|
298
|
-
});
|
|
299
|
-
return handled;
|
|
300
|
-
}
|
|
301
|
-
};
|
|
302
|
-
}
|
|
303
|
-
});
|
|
304
|
-
|
|
305
|
-
// src/index.ts
|
|
306
|
-
var src_default = ListKeymap;
|
|
28
|
+
module.exports = __toCommonJS(index_exports);
|
|
29
|
+
var import_extension_list = require("@tiptap/extension-list");
|
|
30
|
+
var import_extension_list2 = require("@tiptap/extension-list");
|
|
31
|
+
var index_default = import_extension_list.ListKeymap;
|
|
307
32
|
// Annotate the CommonJS export names for ESM import in node:
|
|
308
33
|
0 && (module.exports = {
|
|
309
34
|
ListKeymap,
|
|
35
|
+
ListKeymapOptions,
|
|
310
36
|
listHelpers
|
|
311
37
|
});
|
|
312
38
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/list-keymap.ts","../src/listHelpers/index.ts","../src/listHelpers/findListItemPos.ts","../src/listHelpers/getNextListDepth.ts","../src/listHelpers/handleBackspace.ts","../src/listHelpers/hasListBefore.ts","../src/listHelpers/hasListItemBefore.ts","../src/listHelpers/listItemHasSubList.ts","../src/listHelpers/handleDelete.ts","../src/listHelpers/nextListIsDeeper.ts","../src/listHelpers/nextListIsHigher.ts","../src/listHelpers/hasListItemAfter.ts"],"sourcesContent":["import { ListKeymap } from './list-keymap.js'\n\nexport * from './list-keymap.js'\nexport * as listHelpers from './listHelpers/index.js'\n\nexport default ListKeymap\n","import { Extension } from '@tiptap/core'\n\nimport { handleBackspace, handleDelete } from './listHelpers/index.js'\n\nexport type ListKeymapOptions = {\n /**\n * An array of list types. This is used for item and wrapper list matching.\n * @default []\n * @example [{ itemName: 'listItem', wrapperNames: ['bulletList', 'orderedList'] }]\n */\n listTypes: Array<{\n itemName: string,\n wrapperNames: string[],\n }>\n}\n\n/**\n * This extension registers custom keymaps to change the behaviour of the backspace and delete keys.\n * By default Prosemirror keyhandling will always lift or sink items so paragraphs are joined into\n * the adjacent or previous list item. This extension will prevent this behaviour and instead will\n * try to join paragraphs from two list items into a single list item.\n * @see https://www.tiptap.dev/api/extensions/list-keymap\n */\nexport const ListKeymap = Extension.create<ListKeymapOptions>({\n name: 'listKeymap',\n\n addOptions() {\n return {\n listTypes: [\n {\n itemName: 'listItem',\n wrapperNames: ['bulletList', 'orderedList'],\n },\n {\n itemName: 'taskItem',\n wrapperNames: ['taskList'],\n },\n ],\n }\n },\n\n addKeyboardShortcuts() {\n return {\n Delete: ({ editor }) => {\n let handled = false\n\n this.options.listTypes.forEach(({ itemName }) => {\n if (editor.state.schema.nodes[itemName] === undefined) {\n return\n }\n\n if (handleDelete(editor, itemName)) {\n handled = true\n }\n })\n\n return handled\n },\n 'Mod-Delete': ({ editor }) => {\n let handled = false\n\n this.options.listTypes.forEach(({ itemName }) => {\n if (editor.state.schema.nodes[itemName] === undefined) {\n return\n }\n\n if (handleDelete(editor, itemName)) {\n handled = true\n }\n })\n\n return handled\n },\n Backspace: ({ editor }) => {\n let handled = false\n\n this.options.listTypes.forEach(({ itemName, wrapperNames }) => {\n if (editor.state.schema.nodes[itemName] === undefined) {\n return\n }\n\n if (handleBackspace(editor, itemName, wrapperNames)) {\n handled = true\n }\n })\n\n return handled\n },\n 'Mod-Backspace': ({ editor }) => {\n let handled = false\n\n this.options.listTypes.forEach(({ itemName, wrapperNames }) => {\n if (editor.state.schema.nodes[itemName] === undefined) {\n return\n }\n\n if (handleBackspace(editor, itemName, wrapperNames)) {\n handled = true\n }\n })\n\n return handled\n },\n }\n },\n})\n","export * from './findListItemPos.js'\nexport * from './getNextListDepth.js'\nexport * from './handleBackspace.js'\nexport * from './handleDelete.js'\nexport * from './hasListBefore.js'\nexport * from './hasListItemAfter.js'\nexport * from './hasListItemBefore.js'\nexport * from './listItemHasSubList.js'\nexport * from './nextListIsDeeper.js'\nexport * from './nextListIsHigher.js'\n","import { getNodeType } from '@tiptap/core'\nimport { NodeType } from '@tiptap/pm/model'\nimport { EditorState } from '@tiptap/pm/state'\n\nexport const findListItemPos = (typeOrName: string | NodeType, state: EditorState) => {\n const { $from } = state.selection\n const nodeType = getNodeType(typeOrName, state.schema)\n\n let currentNode = null\n let currentDepth = $from.depth\n let currentPos = $from.pos\n let targetDepth: number | null = null\n\n while (currentDepth > 0 && targetDepth === null) {\n currentNode = $from.node(currentDepth)\n\n if (currentNode.type === nodeType) {\n targetDepth = currentDepth\n } else {\n currentDepth -= 1\n currentPos -= 1\n }\n }\n\n if (targetDepth === null) {\n return null\n }\n\n return { $pos: state.doc.resolve(currentPos), depth: targetDepth }\n}\n","import { getNodeAtPosition } from '@tiptap/core'\nimport { EditorState } from '@tiptap/pm/state'\n\nimport { findListItemPos } from './findListItemPos.js'\n\nexport const getNextListDepth = (typeOrName: string, state: EditorState) => {\n const listItemPos = findListItemPos(typeOrName, state)\n\n if (!listItemPos) {\n return false\n }\n\n const [, depth] = getNodeAtPosition(state, typeOrName, listItemPos.$pos.pos + 4)\n\n return depth\n}\n","import { Editor, isAtStartOfNode, isNodeActive } from '@tiptap/core'\nimport { Node } from '@tiptap/pm/model'\n\nimport { findListItemPos } from './findListItemPos.js'\nimport { hasListBefore } from './hasListBefore.js'\nimport { hasListItemBefore } from './hasListItemBefore.js'\nimport { listItemHasSubList } from './listItemHasSubList.js'\n\nexport const handleBackspace = (editor: Editor, name: string, parentListTypes: string[]) => {\n // this is required to still handle the undo handling\n if (editor.commands.undoInputRule()) {\n return true\n }\n\n // if the selection is not collapsed\n // we can rely on the default backspace behavior\n if (editor.state.selection.from !== editor.state.selection.to) {\n return false\n }\n\n // if the current item is NOT inside a list item &\n // the previous item is a list (orderedList or bulletList)\n // move the cursor into the list and delete the current item\n if (!isNodeActive(editor.state, name) && hasListBefore(editor.state, name, parentListTypes)) {\n const { $anchor } = editor.state.selection\n\n const $listPos = editor.state.doc.resolve($anchor.before() - 1)\n\n const listDescendants: Array<{ node: Node, pos: number }> = []\n\n $listPos.node().descendants((node, pos) => {\n if (node.type.name === name) {\n listDescendants.push({ node, pos })\n }\n })\n\n const lastItem = listDescendants.at(-1)\n\n if (!lastItem) {\n return false\n }\n\n const $lastItemPos = editor.state.doc.resolve($listPos.start() + lastItem.pos + 1)\n\n return editor.chain().cut({ from: $anchor.start() - 1, to: $anchor.end() + 1 }, $lastItemPos.end()).joinForward().run()\n }\n\n // if the cursor is not inside the current node type\n // do nothing and proceed\n if (!isNodeActive(editor.state, name)) {\n return false\n }\n\n // if the cursor is not at the start of a node\n // do nothing and proceed\n if (!isAtStartOfNode(editor.state)) {\n return false\n }\n\n const listItemPos = findListItemPos(name, editor.state)\n\n if (!listItemPos) {\n return false\n }\n\n const $prev = editor.state.doc.resolve(listItemPos.$pos.pos - 2)\n const prevNode = $prev.node(listItemPos.depth)\n\n const previousListItemHasSubList = listItemHasSubList(name, editor.state, prevNode)\n\n // if the previous item is a list item and doesn't have a sublist, join the list items\n if (hasListItemBefore(name, editor.state) && !previousListItemHasSubList) {\n return editor.commands.joinItemBackward()\n }\n\n // otherwise in the end, a backspace should\n // always just lift the list item if\n // joining / merging is not possible\n return editor.chain().liftListItem(name).run()\n}\n","import { EditorState } from '@tiptap/pm/state'\n\nexport const hasListBefore = (editorState: EditorState, name: string, parentListTypes: string[]) => {\n const { $anchor } = editorState.selection\n\n const previousNodePos = Math.max(0, $anchor.pos - 2)\n\n const previousNode = editorState.doc.resolve(previousNodePos).node()\n\n if (!previousNode || !parentListTypes.includes(previousNode.type.name)) {\n return false\n }\n\n return true\n}\n","import { EditorState } from '@tiptap/pm/state'\n\nexport const hasListItemBefore = (typeOrName: string, state: EditorState): boolean => {\n const { $anchor } = state.selection\n\n const $targetPos = state.doc.resolve($anchor.pos - 2)\n\n if ($targetPos.index() === 0) {\n return false\n }\n\n if ($targetPos.nodeBefore?.type.name !== typeOrName) {\n return false\n }\n\n return true\n}\n","import { getNodeType } from '@tiptap/core'\nimport { Node } from '@tiptap/pm/model'\nimport { EditorState } from '@tiptap/pm/state'\n\nexport const listItemHasSubList = (typeOrName: string, state: EditorState, node?: Node) => {\n if (!node) {\n return false\n }\n\n const nodeType = getNodeType(typeOrName, state.schema)\n\n let hasSubList = false\n\n node.descendants(child => {\n if (child.type === nodeType) {\n hasSubList = true\n }\n })\n\n return hasSubList\n}\n","import { Editor, isAtEndOfNode, isNodeActive } from '@tiptap/core'\n\nimport { nextListIsDeeper } from './nextListIsDeeper.js'\nimport { nextListIsHigher } from './nextListIsHigher.js'\n\nexport const handleDelete = (editor: Editor, name: string) => {\n // if the cursor is not inside the current node type\n // do nothing and proceed\n if (!isNodeActive(editor.state, name)) {\n return false\n }\n\n // if the cursor is not at the end of a node\n // do nothing and proceed\n if (!isAtEndOfNode(editor.state, name)) {\n return false\n }\n\n // if the selection is not collapsed, or not within a single node\n // do nothing and proceed\n const { selection } = editor.state\n const { $from, $to } = selection\n\n if (!selection.empty && $from.sameParent($to)) {\n return false\n }\n\n // check if the next node is a list with a deeper depth\n if (nextListIsDeeper(name, editor.state)) {\n return editor\n .chain()\n .focus(editor.state.selection.from + 4)\n .lift(name)\n .joinBackward()\n .run()\n }\n\n if (nextListIsHigher(name, editor.state)) {\n return editor.chain()\n .joinForward()\n .joinBackward()\n .run()\n }\n\n return editor.commands.joinItemForward()\n}\n","import { EditorState } from '@tiptap/pm/state'\n\nimport { findListItemPos } from './findListItemPos.js'\nimport { getNextListDepth } from './getNextListDepth.js'\n\nexport const nextListIsDeeper = (typeOrName: string, state: EditorState) => {\n const listDepth = getNextListDepth(typeOrName, state)\n const listItemPos = findListItemPos(typeOrName, state)\n\n if (!listItemPos || !listDepth) {\n return false\n }\n\n if (listDepth > listItemPos.depth) {\n return true\n }\n\n return false\n}\n","import { EditorState } from '@tiptap/pm/state'\n\nimport { findListItemPos } from './findListItemPos.js'\nimport { getNextListDepth } from './getNextListDepth.js'\n\nexport const nextListIsHigher = (typeOrName: string, state: EditorState) => {\n const listDepth = getNextListDepth(typeOrName, state)\n const listItemPos = findListItemPos(typeOrName, state)\n\n if (!listItemPos || !listDepth) {\n return false\n }\n\n if (listDepth < listItemPos.depth) {\n return true\n }\n\n return false\n}\n","import { EditorState } from '@tiptap/pm/state'\n\nexport const hasListItemAfter = (typeOrName: string, state: EditorState): boolean => {\n const { $anchor } = state.selection\n\n const $targetPos = state.doc.resolve($anchor.pos - $anchor.parentOffset - 2)\n\n if ($targetPos.index() === $targetPos.parent.childCount - 1) {\n return false\n }\n\n if ($targetPos.nodeAfter?.type.name !== typeOrName) {\n return false\n }\n\n return true\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,eAA0B;;;ACA1B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,kBAA4B;AAIrB,IAAM,kBAAkB,CAAC,YAA+B,UAAuB;AACpF,QAAM,EAAE,MAAM,IAAI,MAAM;AACxB,QAAM,eAAW,yBAAY,YAAY,MAAM,MAAM;AAErD,MAAI,cAAc;AAClB,MAAI,eAAe,MAAM;AACzB,MAAI,aAAa,MAAM;AACvB,MAAI,cAA6B;AAEjC,SAAO,eAAe,KAAK,gBAAgB,MAAM;AAC/C,kBAAc,MAAM,KAAK,YAAY;AAErC,QAAI,YAAY,SAAS,UAAU;AACjC,oBAAc;AAAA,IAChB,OAAO;AACL,sBAAgB;AAChB,oBAAc;AAAA,IAChB;AAAA,EACF;AAEA,MAAI,gBAAgB,MAAM;AACxB,WAAO;AAAA,EACT;AAEA,SAAO,EAAE,MAAM,MAAM,IAAI,QAAQ,UAAU,GAAG,OAAO,YAAY;AACnE;;;AC7BA,IAAAC,eAAkC;AAK3B,IAAM,mBAAmB,CAAC,YAAoB,UAAuB;AAC1E,QAAM,cAAc,gBAAgB,YAAY,KAAK;AA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ACF,CAAC;AAED,eAAO;AAAA,MACT;AAAA,MACA,WAAW,CAAC,EAAE,OAAO,MAAM;AACzB,YAAI,UAAU;AAEd,aAAK,QAAQ,UAAU,QAAQ,CAAC,EAAE,UAAU,aAAa,MAAM;AAC7D,cAAI,OAAO,MAAM,OAAO,MAAM,QAAQ,MAAM,QAAW;AACrD;AAAA,UACF;AAEA,cAAI,gBAAgB,QAAQ,UAAU,YAAY,GAAG;AACnD,sBAAU;AAAA,UACZ;AAAA,QACF,CAAC;AAED,eAAO;AAAA,MACT;AAAA,MACA,iBAAiB,CAAC,EAAE,OAAO,MAAM;AAC/B,YAAI,UAAU;AAEd,aAAK,QAAQ,UAAU,QAAQ,CAAC,EAAE,UAAU,aAAa,MAAM;AAC7D,cAAI,OAAO,MAAM,OAAO,MAAM,QAAQ,MAAM,QAAW;AACrD;AAAA,UACF;AAEA,cAAI,gBAAgB,QAAQ,UAAU,YAAY,GAAG;AACnD,sBAAU;AAAA,UACZ;AAAA,QACF,CAAC;AAED,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACF,CAAC;;;ADpGD,IAAO,cAAQ;","names":["import_core","import_core","import_core","import_core","import_core"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { ListKeymap } from '@tiptap/extension-list'\n\nexport { listHelpers, ListKeymap, ListKeymapOptions } from '@tiptap/extension-list'\n\nexport default ListKeymap\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAA2B;AAE3B,IAAAA,yBAA2D;AAE3D,IAAO,gBAAQ;","names":["import_extension_list"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,63 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { NodeType, Node } from '@tiptap/pm/model';
|
|
4
|
-
import { EditorState } from '@tiptap/pm/state';
|
|
5
|
-
|
|
6
|
-
type ListKeymapOptions = {
|
|
7
|
-
/**
|
|
8
|
-
* An array of list types. This is used for item and wrapper list matching.
|
|
9
|
-
* @default []
|
|
10
|
-
* @example [{ itemName: 'listItem', wrapperNames: ['bulletList', 'orderedList'] }]
|
|
11
|
-
*/
|
|
12
|
-
listTypes: Array<{
|
|
13
|
-
itemName: string;
|
|
14
|
-
wrapperNames: string[];
|
|
15
|
-
}>;
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* This extension registers custom keymaps to change the behaviour of the backspace and delete keys.
|
|
19
|
-
* By default Prosemirror keyhandling will always lift or sink items so paragraphs are joined into
|
|
20
|
-
* the adjacent or previous list item. This extension will prevent this behaviour and instead will
|
|
21
|
-
* try to join paragraphs from two list items into a single list item.
|
|
22
|
-
* @see https://www.tiptap.dev/api/extensions/list-keymap
|
|
23
|
-
*/
|
|
24
|
-
declare const ListKeymap: Extension<ListKeymapOptions, any>;
|
|
25
|
-
|
|
26
|
-
declare const findListItemPos: (typeOrName: string | NodeType, state: EditorState) => {
|
|
27
|
-
$pos: prosemirror_model.ResolvedPos;
|
|
28
|
-
depth: number;
|
|
29
|
-
} | null;
|
|
30
|
-
|
|
31
|
-
declare const getNextListDepth: (typeOrName: string, state: EditorState) => number | false;
|
|
32
|
-
|
|
33
|
-
declare const handleBackspace: (editor: Editor, name: string, parentListTypes: string[]) => boolean;
|
|
34
|
-
|
|
35
|
-
declare const handleDelete: (editor: Editor, name: string) => boolean;
|
|
36
|
-
|
|
37
|
-
declare const hasListBefore: (editorState: EditorState, name: string, parentListTypes: string[]) => boolean;
|
|
38
|
-
|
|
39
|
-
declare const hasListItemAfter: (typeOrName: string, state: EditorState) => boolean;
|
|
40
|
-
|
|
41
|
-
declare const hasListItemBefore: (typeOrName: string, state: EditorState) => boolean;
|
|
42
|
-
|
|
43
|
-
declare const listItemHasSubList: (typeOrName: string, state: EditorState, node?: Node) => boolean;
|
|
44
|
-
|
|
45
|
-
declare const nextListIsDeeper: (typeOrName: string, state: EditorState) => boolean;
|
|
46
|
-
|
|
47
|
-
declare const nextListIsHigher: (typeOrName: string, state: EditorState) => boolean;
|
|
48
|
-
|
|
49
|
-
declare const index_findListItemPos: typeof findListItemPos;
|
|
50
|
-
declare const index_getNextListDepth: typeof getNextListDepth;
|
|
51
|
-
declare const index_handleBackspace: typeof handleBackspace;
|
|
52
|
-
declare const index_handleDelete: typeof handleDelete;
|
|
53
|
-
declare const index_hasListBefore: typeof hasListBefore;
|
|
54
|
-
declare const index_hasListItemAfter: typeof hasListItemAfter;
|
|
55
|
-
declare const index_hasListItemBefore: typeof hasListItemBefore;
|
|
56
|
-
declare const index_listItemHasSubList: typeof listItemHasSubList;
|
|
57
|
-
declare const index_nextListIsDeeper: typeof nextListIsDeeper;
|
|
58
|
-
declare const index_nextListIsHigher: typeof nextListIsHigher;
|
|
59
|
-
declare namespace index {
|
|
60
|
-
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 };
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export { ListKeymap, type ListKeymapOptions, ListKeymap as default, index as listHelpers };
|
|
1
|
+
import { ListKeymap } from '@tiptap/extension-list';
|
|
2
|
+
export { ListKeymap, ListKeymapOptions, ListKeymap as default, listHelpers } from '@tiptap/extension-list';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,63 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { NodeType, Node } from '@tiptap/pm/model';
|
|
4
|
-
import { EditorState } from '@tiptap/pm/state';
|
|
5
|
-
|
|
6
|
-
type ListKeymapOptions = {
|
|
7
|
-
/**
|
|
8
|
-
* An array of list types. This is used for item and wrapper list matching.
|
|
9
|
-
* @default []
|
|
10
|
-
* @example [{ itemName: 'listItem', wrapperNames: ['bulletList', 'orderedList'] }]
|
|
11
|
-
*/
|
|
12
|
-
listTypes: Array<{
|
|
13
|
-
itemName: string;
|
|
14
|
-
wrapperNames: string[];
|
|
15
|
-
}>;
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* This extension registers custom keymaps to change the behaviour of the backspace and delete keys.
|
|
19
|
-
* By default Prosemirror keyhandling will always lift or sink items so paragraphs are joined into
|
|
20
|
-
* the adjacent or previous list item. This extension will prevent this behaviour and instead will
|
|
21
|
-
* try to join paragraphs from two list items into a single list item.
|
|
22
|
-
* @see https://www.tiptap.dev/api/extensions/list-keymap
|
|
23
|
-
*/
|
|
24
|
-
declare const ListKeymap: Extension<ListKeymapOptions, any>;
|
|
25
|
-
|
|
26
|
-
declare const findListItemPos: (typeOrName: string | NodeType, state: EditorState) => {
|
|
27
|
-
$pos: prosemirror_model.ResolvedPos;
|
|
28
|
-
depth: number;
|
|
29
|
-
} | null;
|
|
30
|
-
|
|
31
|
-
declare const getNextListDepth: (typeOrName: string, state: EditorState) => number | false;
|
|
32
|
-
|
|
33
|
-
declare const handleBackspace: (editor: Editor, name: string, parentListTypes: string[]) => boolean;
|
|
34
|
-
|
|
35
|
-
declare const handleDelete: (editor: Editor, name: string) => boolean;
|
|
36
|
-
|
|
37
|
-
declare const hasListBefore: (editorState: EditorState, name: string, parentListTypes: string[]) => boolean;
|
|
38
|
-
|
|
39
|
-
declare const hasListItemAfter: (typeOrName: string, state: EditorState) => boolean;
|
|
40
|
-
|
|
41
|
-
declare const hasListItemBefore: (typeOrName: string, state: EditorState) => boolean;
|
|
42
|
-
|
|
43
|
-
declare const listItemHasSubList: (typeOrName: string, state: EditorState, node?: Node) => boolean;
|
|
44
|
-
|
|
45
|
-
declare const nextListIsDeeper: (typeOrName: string, state: EditorState) => boolean;
|
|
46
|
-
|
|
47
|
-
declare const nextListIsHigher: (typeOrName: string, state: EditorState) => boolean;
|
|
48
|
-
|
|
49
|
-
declare const index_findListItemPos: typeof findListItemPos;
|
|
50
|
-
declare const index_getNextListDepth: typeof getNextListDepth;
|
|
51
|
-
declare const index_handleBackspace: typeof handleBackspace;
|
|
52
|
-
declare const index_handleDelete: typeof handleDelete;
|
|
53
|
-
declare const index_hasListBefore: typeof hasListBefore;
|
|
54
|
-
declare const index_hasListItemAfter: typeof hasListItemAfter;
|
|
55
|
-
declare const index_hasListItemBefore: typeof hasListItemBefore;
|
|
56
|
-
declare const index_listItemHasSubList: typeof listItemHasSubList;
|
|
57
|
-
declare const index_nextListIsDeeper: typeof nextListIsDeeper;
|
|
58
|
-
declare const index_nextListIsHigher: typeof nextListIsHigher;
|
|
59
|
-
declare namespace index {
|
|
60
|
-
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 };
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export { ListKeymap, type ListKeymapOptions, ListKeymap as default, index as listHelpers };
|
|
1
|
+
import { ListKeymap } from '@tiptap/extension-list';
|
|
2
|
+
export { ListKeymap, ListKeymapOptions, ListKeymap as default, listHelpers } from '@tiptap/extension-list';
|