Suppose I inserted a new custom block like
const insertBlock = () => {
const contentState = editorState.getCurrentContent();
const contentStateWithEntity = contentState.createEntity(
"EDITORELEMENT",
"MUTABLE",
{
a: "b"
}
);
const entityKey = contentStateWithEntity.getLastCreatedEntityKey();
const newEditorState = EditorState.set(editorState, {
currentContent: contentStateWithEntity
});
setEditorState(
AtomicBlockUtils.insertAtomicBlock(newEditorState, entityKey, "text")
);
};
const EditorElement: React.FC = (props: any) => {
return (
<div className="EditorElement">
<EditorBlock {...props} />
</div>
);
};
How do I auto-focus this new block right after inserting it?
Tried many solution using forceSelection, focus but they didn't work