Skip to content

Feature: Allow passing prop of type SerializedEditorState as editorState in LexicalComposer initialConfig #3732

Open
@Amethystix

Description

@Amethystix

Hi team! I'm working on a project using lexical, and found that although I'm storing my editor state as JSON in my database, since my ORM converts the editor state to an object when I query for it, the type I have that I pass into the default editor state is SerializedEditorState, and I have to stringify this object every single time, despite the fact that editor.parseEditorState being used on this default state can accept the SerializedEditorState type.

I would be happy to contribute this myself, as I see it looks to be a simple change to LexicalComposer.tsx (unless I'm off-base here, and there's some other complexities; am pretty new to this library)

While on the subject, just wanted to mention that passing in an invalid JSON string causes an unhandled Exception to be thrown, and I was wondering if there might be a more graceful way of handling an invalid editor state (perhaps just assuming no default editor state exists and starting anew?)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions