Created
May 2, 2020 11:26
-
-
Save Katerina198b/f43bcb702db99bef40ddb1be481bc6df to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function addEmptyBlock(editorState) { | |
const newBlock = new ContentBlock({ | |
key: genKey(), | |
type: 'unstyled', | |
text: '', | |
characterList: List(), | |
}); | |
const contentState = editorState.getCurrentContent(); | |
const newBlockMap = contentState.getBlockMap().set(newBlock.key, newBlock); | |
const editorWithBlock = EditorState.push( | |
editorState, | |
ContentState.createFromBlockArray(newBlockMap.toArray()) | |
); | |
return EditorState.moveFocusToEnd(editorWithBlock); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment