I am trying to split a word into two words when I enter the space
bar. Every word in my text is an entity, so when I split a word in two, I need to update the text and create a new entity.
I am using the Modifier
module for both updates.
const editorStateAfterText =
EditorState.push(
editorState,
Modifier.insertText(
contentState,
selectionState,
' ',
),
command,
);
const editorStateAfterEntity =
EditorState.push(
editorStateAfterText,
Modifier.applyEntity(
contentState,
newSelectionState,
newEntityKey
),
command,
);
this.setState({editorState: editorStateAfterEntity})
I am trying to update the editor state with two operations at once. They both work if the other one is not present. When the two are present, it only updates the last one.
Is there any way to update the text (split the word) and add the new entity to the entityMap
?