From ad2b5bc4082dd6d466ebb6a5a4a6d78f64a9b88f Mon Sep 17 00:00:00 2001 From: matthewlipski Date: Mon, 25 Nov 2024 17:13:19 +0100 Subject: [PATCH] Added table tab handling using PM command --- .../src/blocks/TableBlockContent/TableExtension.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/core/src/blocks/TableBlockContent/TableExtension.ts b/packages/core/src/blocks/TableBlockContent/TableExtension.ts index cd197a139..33b47c0c9 100644 --- a/packages/core/src/blocks/TableBlockContent/TableExtension.ts +++ b/packages/core/src/blocks/TableBlockContent/TableExtension.ts @@ -1,5 +1,5 @@ import { callOrReturn, Extension, getExtensionField } from "@tiptap/core"; -import { columnResizing, tableEditing } from "prosemirror-tables"; +import { columnResizing, goToNextCell, tableEditing } from "prosemirror-tables"; export const RESIZE_MIN_WIDTH = 35; export const EMPTY_CELL_WIDTH = 120; @@ -53,6 +53,17 @@ export const TableExtension = Extension.create({ selectionIsInTableParagraphNode ); }, + // Enables navigating cells using the tab key. + Tab: () => { + return this.editor.commands.command(({ state, dispatch, view }) => + goToNextCell(1)(state, dispatch, view) + ); + }, + "Shift-Tab": () => { + return this.editor.commands.command(({ state, dispatch, view }) => + goToNextCell(-1)(state, dispatch, view) + ); + }, }; },