How can I clean an Editor after successfully handle onSubmit function? #2843
|
In my react app, I have created a component name RichTextEditor using lexical. Now I want to clean the Editor from a different component. No idea how to do it. I have checked for question regarding this clean. But it's not clear for me how to implement it. Thanks |
Answered by
thegreatercurve
Aug 18, 2022
Replies: 1 comment 3 replies
|
You need access to the editor instance from your other component, by passing the editor.update(() => {
const root = $getRoot();
root.clear();
});We provide an importabl plugin called To clear the editor, you can call |
3 replies
Answer selected by
thegreatercurve
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You need access to the editor instance from your other component, by passing the
MLCComposerprovider up to a common parent, but you can then do something like the below to clear the editor state:We provide an importabl plugin called
ClearEditorPluginwhich will also handle this use case for you.To clear the editor, you can call
editor.dispatchCommand(CLEAR_EDITOR_COMMAND)from your other component.