Feature: serialize EditorState to HTML in read-only mode
See original GitHub issueI’m storing EditorState
as the value for a RichTextInput (controlled input), and I want on form submission to:
- ✅ generate JSON from EditorState –
JSON.stringify
does it - ❌ generate HTML from EditorState and EditorConfig (styles) – I need an editor instance
Currently, to generate HTML from Lexical, I need to use Editor. update
with $generateHtmlfromNodes
, which has some issues:
- Not possible in
read-only
mode, - Generating HTML from the editor requires the caller of the method to have an Editor instance, where as an EditorState and EditorConfig should be sufficient
Pleasure to contribute code
I’m open to contributing to this project if this feature is a valid use case.
Issue Analytics
- State:
- Created a year ago
- Reactions:9
- Comments:19 (7 by maintainers)
Top Results From Across the Web
With Lexical, how do I set default initial text? - Stack Overflow
You can set default text by setting editorState to either a stringified JSON state, or a function that imperatively ...
Read more >Reference manual - ProseMirror
ProseMirror keeps all editor state (the things, basically, that would be required ... If you want to serialize the state of plugins, pass...
Read more >Reference Manual - CodeMirror
In its most basic form, an editor's state is made up of a current document and a selection. ... A function used to...
Read more >Top 5 rich-text React components | Sanity.io guide
Requires a parser to convert EditorState to HTML or any other markup. ... React-Quill also features an uncontrolled mode that uses ...
Read more >blob - Google Git
computeN(deps: readonly Slot<any>[], get: (state: EditorState) => readonly Input[]): ... A function used to serialize this field's content to JSON. Only.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
That’s a neat trick too!
@med8bra thanks you for your suggestion, but the same error pertains using OnChangePlugin from @lexical/react/LexicalOnChangePlugin, i.e. $generateHtmlFromNodes can only be called from editor.read or editor.update, and if I wrap it in that, it says " Cannot use method in read-only mode." even when I’m, not in read-only mode, if the editor has been in read-only mode at some point.