@tiptap/core 2.0.0-beta.204 → 2.0.0-beta.206

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.
@@ -1316,6 +1316,28 @@
1316
1316
  return prosemirrorCommands.createParagraphNear(state, dispatch);
1317
1317
  };
1318
1318
 
1319
+ const deleteCurrentNode = () => ({ tr, dispatch }) => {
1320
+ const { selection } = tr;
1321
+ const currentNode = selection.$anchor.node();
1322
+ // if there is content inside the current node, break out of this command
1323
+ if (currentNode.content.size > 0) {
1324
+ return false;
1325
+ }
1326
+ const $pos = tr.selection.$anchor;
1327
+ for (let depth = $pos.depth; depth > 0; depth -= 1) {
1328
+ const node = $pos.node(depth);
1329
+ if (node.type === currentNode.type) {
1330
+ if (dispatch) {
1331
+ const from = $pos.before(depth);
1332
+ const to = $pos.after(depth);
1333
+ tr.delete(from, to).scrollIntoView();
1334
+ }
1335
+ return true;
1336
+ }
1337
+ }
1338
+ return false;
1339
+ };
1340
+
1319
1341
  const deleteNode = typeOrName => ({ tr, state, dispatch }) => {
1320
1342
  const type = getNodeType(typeOrName, state.schema);
1321
1343
  const $pos = tr.selection.$anchor;
@@ -1672,10 +1694,15 @@
1672
1694
  return true;
1673
1695
  };
1674
1696
 
1697
+ const joinUp = () => ({ state, dispatch }) => {
1698
+ return prosemirrorCommands.joinUp(state, dispatch);
1699
+ };
1700
+ const joinDown = () => ({ state, dispatch }) => {
1701
+ return prosemirrorCommands.joinDown(state, dispatch);
1702
+ };
1675
1703
  const joinBackward = () => ({ state, dispatch }) => {
1676
1704
  return prosemirrorCommands.joinBackward(state, dispatch);
1677
- };
1678
-
1705
+ };
1679
1706
  const joinForward = () => ({ state, dispatch }) => {
1680
1707
  return prosemirrorCommands.joinForward(state, dispatch);
1681
1708
  };
@@ -2943,6 +2970,7 @@
2943
2970
  clearNodes: clearNodes,
2944
2971
  command: command,
2945
2972
  createParagraphNear: createParagraphNear,
2973
+ deleteCurrentNode: deleteCurrentNode,
2946
2974
  deleteNode: deleteNode,
2947
2975
  deleteRange: deleteRange,
2948
2976
  deleteSelection: deleteSelection,
@@ -2954,6 +2982,8 @@
2954
2982
  forEach: forEach,
2955
2983
  insertContent: insertContent,
2956
2984
  insertContentAt: insertContentAt,
2985
+ joinUp: joinUp,
2986
+ joinDown: joinDown,
2957
2987
  joinBackward: joinBackward,
2958
2988
  joinForward: joinForward,
2959
2989
  keyboardShortcut: keyboardShortcut,
@@ -3070,6 +3100,7 @@
3070
3100
  ]);
3071
3101
  const handleDelete = () => this.editor.commands.first(({ commands }) => [
3072
3102
  () => commands.deleteSelection(),
3103
+ () => commands.deleteCurrentNode(),
3073
3104
  () => commands.joinForward(),
3074
3105
  () => commands.selectNodeForward(),
3075
3106
  ]);