When using LexicalComposer, the initialConfig accepts an editorState parameter that can be used to pass in some initial content. If this initialContent is a complex html string, I am not clear how to parse it. For a simple string, I have it like below (everything works fine here):
const initialState = () => {
const paragraph = $createParagraphNode();
const text = $createTextNode(initialContent);
paragraph.append(text);
const root = $getRoot().append(paragraph);
root.selectEnd()}
const initialConfig = {
namespace: 'HTMLEditor',
theme: editorTheme,
onError: (error: Error) => {
throw error;
},
editorState: initialState}
Which I then pass in to LexicalComposer. If the string I pass in is NOT a simple string, but rather some html content in the form of a string, and if I do NOT know ahead of time exactly what will be passed in (i.e. I want to parse existing html content created elsewhere) how do I do it? I can't use $generateNodesFromDOM because my editor hasn't yet been initialized.