Skip to content

How can I clean an Editor after successfully handle onSubmit function? #2843

Answered by thegreatercurve
dipto0321 asked this question in Q&A
Discussion options

You must be logged in to vote

You need access to the editor instance from your other component, by passing the MLCComposer provider up to a common parent, but you can then do something like the below to clear the editor state:

editor.update(() => {
  const root = $getRoot();
  root.clear();
});

We provide an importabl plugin called ClearEditorPlugin which will also handle this use case for you.

To clear the editor, you can call editor.dispatchCommand(CLEAR_EDITOR_COMMAND) from your other component.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@Hudson-AmalembaL
Comment options

@guru-keepspace
Comment options

Answer selected by thegreatercurve
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants