1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-04-21 05:42:00 +02:00

Prevent an unexpected ampersand (#604)

This commit is contained in:
Michael Plotke 2017-02-16 13:12:38 -05:00 committed by Ian Storm Taylor
parent e0be76a240
commit da10eaeca9

View File

@ -88,11 +88,14 @@ class App extends React.Component {
// Return with no changes if it's not the "7" key with shift pressed.
if (event.which != 55 || !event.shiftKey) return
// Otherwise, transform the state by insert "and" at the cursor's position.
// Otherwise, transform the state by inserting "and" at the cursor's position.
const newState = state
.transform()
.insertText('and')
.apply()
// Prevent the ampersand character from being inserted.
event.preventDefault()
// Return the new state, which will cause the editor to update it.
return newState