mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-17 12:41:44 +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:
@@ -72,12 +72,14 @@ class App extends React.Component {
|
|||||||
case 'b': {
|
case 'b': {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
editor.addMark('bold')
|
editor.addMark('bold')
|
||||||
|
break
|
||||||
}
|
}
|
||||||
// When "`" is pressed, keep our existing code block logic.
|
// When "`" is pressed, keep our existing code block logic.
|
||||||
case '`': {
|
case '`': {
|
||||||
const isCode = editor.value.blocks.some(block => block.type == 'code')
|
const isCode = editor.value.blocks.some(block => block.type == 'code')
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
editor.setBlocks(isCode ? 'paragraph' : 'code')
|
editor.setBlocks(isCode ? 'paragraph' : 'code')
|
||||||
|
break
|
||||||
}
|
}
|
||||||
// Otherwise, let other plugins handle it.
|
// Otherwise, let other plugins handle it.
|
||||||
default: {
|
default: {
|
||||||
|
Reference in New Issue
Block a user