1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-06 07:17:27 +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,12 +88,15 @@ class App extends React.Component {
// Return with no changes if it's not the "7" key with shift pressed. // Return with no changes if it's not the "7" key with shift pressed.
if (event.which != 55 || !event.shiftKey) return 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 const newState = state
.transform() .transform()
.insertText('and') .insertText('and')
.apply() .apply()
// Prevent the ampersand character from being inserted.
event.preventDefault()
// Return the new state, which will cause the editor to update it. // Return the new state, which will cause the editor to update it.
return newState return newState
} }