Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to convert to editorstate from HTML to prefill the textbox? #6

Closed
raj454raj opened this issue Apr 23, 2022 · 1 comment
Closed

Comments

@raj454raj
Copy link

If I have the HTML stored from the toHTML helper, how can I prefill the textbox by converting it to editorState object?

Kudos for such a great MUI project out of draft-wysiwyg! 馃帀

@raj454raj
Copy link
Author

Was able to achieve it with the following -

const htmlContent = ""<h1>hello</h1>"";
const blocksFromHTML = convertFromHTML(htmlContent);
const state = ContentState.createFromBlockArray(
  blocksFromHTML.contentBlocks,
  blocksFromHTML.entityMap,
);

setEditorState(MUIEditorState.createWithContent(config, state));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant