mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-22 06:53:25 +02:00
Prevent backspace to move selection into table-cell (#345)
This commit is contained in:
committed by
Ian Storm Taylor
parent
447a6aace4
commit
8300fad52b
@@ -100,6 +100,20 @@ class Tables extends React.Component {
|
||||
*/
|
||||
|
||||
onKeyDown = (e, data, state) => {
|
||||
const { document, selection } = state
|
||||
const { startKey } = selection
|
||||
const startNode = document.getDescendant(startKey)
|
||||
|
||||
if (selection.isAtStartOf(startNode)) {
|
||||
const previous = document.getPreviousText(startNode)
|
||||
const prevBlock = document.getClosestBlock(previous)
|
||||
|
||||
if (prevBlock.type == 'table-cell') {
|
||||
e.preventDefault()
|
||||
return state
|
||||
}
|
||||
}
|
||||
|
||||
if (state.startBlock.type != 'table-cell') return
|
||||
switch (data.key) {
|
||||
case 'backspace': return this.onBackspace(e, state)
|
||||
|
Reference in New Issue
Block a user