add cell navigation and keyboard shortcuts
This commit is contained in:
@@ -3,7 +3,7 @@ import { Command, Node, mergeAttributes } from '@tiptap/core'
|
|||||||
import {
|
import {
|
||||||
tableEditing,
|
tableEditing,
|
||||||
columnResizing,
|
columnResizing,
|
||||||
// goToNextCell,
|
goToNextCell,
|
||||||
addColumnBefore,
|
addColumnBefore,
|
||||||
addColumnAfter,
|
addColumnAfter,
|
||||||
deleteColumn,
|
deleteColumn,
|
||||||
@@ -129,6 +129,29 @@ export const Table = Node.create({
|
|||||||
// console.log('setCellAttr')
|
// console.log('setCellAttr')
|
||||||
// return setCellAttr(name, value)
|
// return setCellAttr(name, value)
|
||||||
// },
|
// },
|
||||||
|
goToNextCell: (): Command => ({ state, dispatch }) => {
|
||||||
|
return goToNextCell(1)(state, dispatch)
|
||||||
|
},
|
||||||
|
goToPreviousCell: (): Command => ({ state, dispatch }) => {
|
||||||
|
return goToNextCell(-1)(state, dispatch)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
addKeyboardShortcuts() {
|
||||||
|
return {
|
||||||
|
Tab: () => {
|
||||||
|
if (this.editor.commands.goToNextCell()) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.editor.commands.addRowAfter()) {
|
||||||
|
return this.editor.commands.goToNextCell()
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
},
|
||||||
|
'Shift-Tab': () => this.editor.commands.goToPreviousCell(),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user