Best way to save lexical state for scalability #4878
-
Initially I tried saving the editor state as JSON in the DB but to render it I had to use lexical editor again which is very bad for performance. So I decided to save the HTML instead and just by keeping the lexical custom css outside the lexical module I can retain the styles and show the desired output without the heavy weight editor. But if we were to expand the functionality to support more advanced features like having a poll component, the generated HTML output becomes unusable outside the lexical context. Is there a way to generate the 2. HTML (refer the attached picture - The HTML that gets generated inside the lexical editor) from 1. HTML (refer the attached picture - The HTML that gets generated by $generateHtmlFromNodes(editor, null) which is then saved to the DB)? I need to show the poll component and other custom components outside of the lexical environment (so that the page can be lightweight) PS:- I think I might know the answer, it could be related to correctly configuring the exportDOM function to meet my needs right? But I wanted to know if there are any easier ways of doing this. Thank you for taking the time to read this. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Yes, that's right. You can export literally any HTML you want with that function.
Would be very interested to hear specific performance problems you encountered doing this. |
Beta Was this translation helpful? Give feedback.
Yes, that's right. You can export literally any HTML you want with that function.
Would be very interested to hear specific performance problems you encountered doing this.