@tiptap/core 2.0.0-beta.204 → 2.0.0-beta.205
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/packages/core/src/commands/deleteCurrentNode.d.ts +12 -0
- package/dist/packages/core/src/commands/index.d.ts +2 -2
- package/dist/packages/core/src/commands/join.d.ts +33 -0
- package/dist/packages/core/src/types.d.ts +1 -0
- package/dist/tiptap-core.cjs +33 -2
- package/dist/tiptap-core.cjs.map +1 -1
- package/dist/tiptap-core.esm.js +34 -3
- package/dist/tiptap-core.esm.js.map +1 -1
- package/dist/tiptap-core.umd.js +33 -2
- package/dist/tiptap-core.umd.js.map +1 -1
- package/package.json +11 -2
- package/src/commands/deleteCurrentNode.ts +41 -0
- package/src/commands/index.ts +2 -2
- package/src/commands/join.ts +50 -0
- package/src/extensions/keymap.ts +1 -0
- package/src/types.ts +2 -0
- package/dist/packages/core/src/commands/joinBackward.d.ts +0 -12
- package/dist/packages/core/src/commands/joinForward.d.ts +0 -12
- package/src/commands/joinBackward.ts +0 -18
- package/src/commands/joinForward.ts +0 -18
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { RawCommands } from '../types';
|
|
2
|
+
declare module '@tiptap/core' {
|
|
3
|
+
interface Commands<ReturnType> {
|
|
4
|
+
deleteCurrentNode: {
|
|
5
|
+
/**
|
|
6
|
+
* Delete the node that currently has the selection anchor.
|
|
7
|
+
*/
|
|
8
|
+
deleteCurrentNode: () => ReturnType;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export declare const deleteCurrentNode: RawCommands['deleteCurrentNode'];
|
|
@@ -3,6 +3,7 @@ export * from './clearContent';
|
|
|
3
3
|
export * from './clearNodes';
|
|
4
4
|
export * from './command';
|
|
5
5
|
export * from './createParagraphNear';
|
|
6
|
+
export * from './deleteCurrentNode';
|
|
6
7
|
export * from './deleteNode';
|
|
7
8
|
export * from './deleteRange';
|
|
8
9
|
export * from './deleteSelection';
|
|
@@ -14,8 +15,7 @@ export * from './focus';
|
|
|
14
15
|
export * from './forEach';
|
|
15
16
|
export * from './insertContent';
|
|
16
17
|
export * from './insertContentAt';
|
|
17
|
-
export * from './
|
|
18
|
-
export * from './joinForward';
|
|
18
|
+
export * from './join';
|
|
19
19
|
export * from './keyboardShortcut';
|
|
20
20
|
export * from './lift';
|
|
21
21
|
export * from './liftEmptyBlock';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { RawCommands } from '../types';
|
|
2
|
+
declare module '@tiptap/core' {
|
|
3
|
+
interface Commands<ReturnType> {
|
|
4
|
+
joinUp: {
|
|
5
|
+
/**
|
|
6
|
+
* Join two nodes Up.
|
|
7
|
+
*/
|
|
8
|
+
joinUp: () => ReturnType;
|
|
9
|
+
};
|
|
10
|
+
joinDown: {
|
|
11
|
+
/**
|
|
12
|
+
* Join two nodes Down.
|
|
13
|
+
*/
|
|
14
|
+
joinDown: () => ReturnType;
|
|
15
|
+
};
|
|
16
|
+
joinBackward: {
|
|
17
|
+
/**
|
|
18
|
+
* Join two nodes Backwards.
|
|
19
|
+
*/
|
|
20
|
+
joinBackward: () => ReturnType;
|
|
21
|
+
};
|
|
22
|
+
joinForward: {
|
|
23
|
+
/**
|
|
24
|
+
* Join two nodes Forwards.
|
|
25
|
+
*/
|
|
26
|
+
joinForward: () => ReturnType;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export declare const joinUp: RawCommands['joinUp'];
|
|
31
|
+
export declare const joinDown: RawCommands['joinDown'];
|
|
32
|
+
export declare const joinBackward: RawCommands['joinBackward'];
|
|
33
|
+
export declare const joinForward: RawCommands['joinForward'];
|
package/dist/tiptap-core.cjs
CHANGED
|
@@ -1322,6 +1322,28 @@ const createParagraphNear = () => ({ state, dispatch }) => {
|
|
|
1322
1322
|
return prosemirrorCommands.createParagraphNear(state, dispatch);
|
|
1323
1323
|
};
|
|
1324
1324
|
|
|
1325
|
+
const deleteCurrentNode = () => ({ tr, dispatch }) => {
|
|
1326
|
+
const { selection } = tr;
|
|
1327
|
+
const currentNode = selection.$anchor.node();
|
|
1328
|
+
// if there is content inside the current node, break out of this command
|
|
1329
|
+
if (currentNode.content.size > 0) {
|
|
1330
|
+
return false;
|
|
1331
|
+
}
|
|
1332
|
+
const $pos = tr.selection.$anchor;
|
|
1333
|
+
for (let depth = $pos.depth; depth > 0; depth -= 1) {
|
|
1334
|
+
const node = $pos.node(depth);
|
|
1335
|
+
if (node.type === currentNode.type) {
|
|
1336
|
+
if (dispatch) {
|
|
1337
|
+
const from = $pos.before(depth);
|
|
1338
|
+
const to = $pos.after(depth);
|
|
1339
|
+
tr.delete(from, to).scrollIntoView();
|
|
1340
|
+
}
|
|
1341
|
+
return true;
|
|
1342
|
+
}
|
|
1343
|
+
}
|
|
1344
|
+
return false;
|
|
1345
|
+
};
|
|
1346
|
+
|
|
1325
1347
|
const deleteNode = typeOrName => ({ tr, state, dispatch }) => {
|
|
1326
1348
|
const type = getNodeType(typeOrName, state.schema);
|
|
1327
1349
|
const $pos = tr.selection.$anchor;
|
|
@@ -1678,10 +1700,15 @@ const insertContentAt = (position, value, options) => ({ tr, dispatch, editor })
|
|
|
1678
1700
|
return true;
|
|
1679
1701
|
};
|
|
1680
1702
|
|
|
1703
|
+
const joinUp = () => ({ state, dispatch }) => {
|
|
1704
|
+
return prosemirrorCommands.joinUp(state, dispatch);
|
|
1705
|
+
};
|
|
1706
|
+
const joinDown = () => ({ state, dispatch }) => {
|
|
1707
|
+
return prosemirrorCommands.joinDown(state, dispatch);
|
|
1708
|
+
};
|
|
1681
1709
|
const joinBackward = () => ({ state, dispatch }) => {
|
|
1682
1710
|
return prosemirrorCommands.joinBackward(state, dispatch);
|
|
1683
|
-
};
|
|
1684
|
-
|
|
1711
|
+
};
|
|
1685
1712
|
const joinForward = () => ({ state, dispatch }) => {
|
|
1686
1713
|
return prosemirrorCommands.joinForward(state, dispatch);
|
|
1687
1714
|
};
|
|
@@ -2949,6 +2976,7 @@ var commands = /*#__PURE__*/Object.freeze({
|
|
|
2949
2976
|
clearNodes: clearNodes,
|
|
2950
2977
|
command: command,
|
|
2951
2978
|
createParagraphNear: createParagraphNear,
|
|
2979
|
+
deleteCurrentNode: deleteCurrentNode,
|
|
2952
2980
|
deleteNode: deleteNode,
|
|
2953
2981
|
deleteRange: deleteRange,
|
|
2954
2982
|
deleteSelection: deleteSelection,
|
|
@@ -2960,6 +2988,8 @@ var commands = /*#__PURE__*/Object.freeze({
|
|
|
2960
2988
|
forEach: forEach,
|
|
2961
2989
|
insertContent: insertContent,
|
|
2962
2990
|
insertContentAt: insertContentAt,
|
|
2991
|
+
joinUp: joinUp,
|
|
2992
|
+
joinDown: joinDown,
|
|
2963
2993
|
joinBackward: joinBackward,
|
|
2964
2994
|
joinForward: joinForward,
|
|
2965
2995
|
keyboardShortcut: keyboardShortcut,
|
|
@@ -3076,6 +3106,7 @@ const Keymap = Extension.create({
|
|
|
3076
3106
|
]);
|
|
3077
3107
|
const handleDelete = () => this.editor.commands.first(({ commands }) => [
|
|
3078
3108
|
() => commands.deleteSelection(),
|
|
3109
|
+
() => commands.deleteCurrentNode(),
|
|
3079
3110
|
() => commands.joinForward(),
|
|
3080
3111
|
() => commands.selectNodeForward(),
|
|
3081
3112
|
]);
|