1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-01-17 13:38:37 +01:00

only preventDefault if the input is actually a format action (#5113)

This commit is contained in:
Julian Benegas 2022-09-10 00:15:34 -03:00 committed by GitHub
parent 9815bdabdd
commit 16a9292aaf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -23,13 +23,15 @@ const HoveringMenuExample = () => {
renderLeaf={props => <Leaf {...props} />}
placeholder="Enter some text..."
onDOMBeforeInput={(event: InputEvent) => {
event.preventDefault()
switch (event.inputType) {
case 'formatBold':
event.preventDefault()
return toggleFormat(editor, 'bold')
case 'formatItalic':
event.preventDefault()
return toggleFormat(editor, 'italic')
case 'formatUnderline':
event.preventDefault()
return toggleFormat(editor, 'underlined')
}
}}