1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-16 04:04:06 +02:00

Add break in the Switch statement for Custom Formatting Walkthrough (#2550)

The Custom Formatting Walkthrough does not work as expected. When
Ctrl + B is pressed it applies both Bold and Code styles to the
content. This is because of the case statement running beyond
the Bold case due to the absence of a break keyword.
This commit is contained in:
Nandu
2019-01-21 21:27:43 -05:00
committed by Sunny Hirai
parent 43ee38e39d
commit 7a6de8725c

View File

@@ -72,12 +72,14 @@ class App extends React.Component {
case 'b': {
event.preventDefault()
editor.addMark('bold')
break
}
// When "`" is pressed, keep our existing code block logic.
case '`': {
const isCode = editor.value.blocks.some(block => block.type == 'code')
event.preventDefault()
editor.setBlocks(isCode ? 'paragraph' : 'code')
break
}
// Otherwise, let other plugins handle it.
default: {