Make the insertNewBlockAtCursor use the same block language/auto setting as the block that is being split

This commit is contained in:
Jonatan Heyman 2023-01-23 17:38:36 +01:00
parent 9987c01207
commit ed13baf4e4

View File

@ -15,8 +15,14 @@ export { moveLineDown, moveLineUp }
export const insertNewBlockAtCursor = ({ state, dispatch }) => {
if (state.readOnly)
return false
const delimText = "\n∞∞∞text-a\n"
const currentBlock = getActiveNoteBlock(state)
let delimText;
if (currentBlock) {
delimText = `\n∞∞∞${currentBlock.language.name}${currentBlock.language.auto ? "-a" : ""}\n`
} else {
delimText = "\n∞∞∞text-a\n"
}
dispatch(state.replaceSelection(delimText),
{
scrollIntoView: true,