1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-07-31 20:40:19 +02: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

View File

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