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:
committed by
Ian Storm Taylor
parent
e0be76a240
commit
da10eaeca9
@@ -88,11 +88,14 @@ 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
|
||||||
|
Reference in New Issue
Block a user