[WIKI-557] fix: keyboard navigation in tables (#7428)

This commit is contained in:
Aaryan Khandelwal
2025-07-17 15:15:18 +05:30
committed by GitHub
parent 3783e34ae8
commit 48f1999c95

View File

@@ -219,23 +219,31 @@ export const Table = Node.create<TableOptions>({
addKeyboardShortcuts() {
return {
Tab: () => {
if (this.editor.isActive(CORE_EXTENSIONS.TABLE)) {
if (this.editor.isActive(CORE_EXTENSIONS.LIST_ITEM) || this.editor.isActive(CORE_EXTENSIONS.TASK_ITEM)) {
return false;
}
if (this.editor.commands.goToNextCell()) {
return true;
}
if (!this.editor.isActive(CORE_EXTENSIONS.TABLE)) return false;
if (!this.editor.can().addRowAfter()) {
return false;
}
return this.editor.chain().addRowAfter().goToNextCell().run();
if (this.editor.isActive(CORE_EXTENSIONS.LIST_ITEM) || this.editor.isActive(CORE_EXTENSIONS.TASK_ITEM)) {
return false;
}
return false;
if (this.editor.commands.goToNextCell()) {
return true;
}
if (!this.editor.can().addRowAfter()) {
return false;
}
return this.editor.chain().addRowAfter().goToNextCell().run();
},
"Shift-Tab": () => {
if (!this.editor.isActive(CORE_EXTENSIONS.TABLE)) return false;
if (this.editor.isActive(CORE_EXTENSIONS.LIST_ITEM) || this.editor.isActive(CORE_EXTENSIONS.TASK_ITEM)) {
return false;
}
return this.editor.commands.goToPreviousCell();
},
"Shift-Tab": () => this.editor.commands.goToPreviousCell(),
Backspace: handleDeleteKeyOnTable,
"Mod-Backspace": handleDeleteKeyOnTable,
Delete: handleDeleteKeyOnTable,