Skip to content

Commit a7bf806

Browse files
feat: Tab key handling for tables (simple) (TypeCellOS#1275)
1 parent 3ef7218 commit a7bf806

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

packages/core/src/blocks/TableBlockContent/TableExtension.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { callOrReturn, Extension, getExtensionField } from "@tiptap/core";
2-
import { columnResizing, tableEditing } from "prosemirror-tables";
2+
import { columnResizing, goToNextCell, tableEditing } from "prosemirror-tables";
33

44
export const RESIZE_MIN_WIDTH = 35;
55
export const EMPTY_CELL_WIDTH = 120;
@@ -53,6 +53,17 @@ export const TableExtension = Extension.create({
5353
selectionIsInTableParagraphNode
5454
);
5555
},
56+
// Enables navigating cells using the tab key.
57+
Tab: () => {
58+
return this.editor.commands.command(({ state, dispatch, view }) =>
59+
goToNextCell(1)(state, dispatch, view)
60+
);
61+
},
62+
"Shift-Tab": () => {
63+
return this.editor.commands.command(({ state, dispatch, view }) =>
64+
goToNextCell(-1)(state, dispatch, view)
65+
);
66+
},
5667
};
5768
},
5869

0 commit comments

Comments
 (0)