Is there a way to serialize selection along with editorState? #5357
-
|
Selection is part of editor state, I want to restore the selection from database when reloading. However, when serializing editor states using Is there a way to save and restore the selection in database? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
Lexical doesn't support it (Seems you've read the source code, so no need to explain that). |
Beta Was this translation helpful? Give feedback.
Lexical doesn't support it (Seems you've read the source code, so no need to explain that).
To ser/deser selection, the idea is pretty similar to what @lexical-yjs does (yjs is a state synchronization package, if you've used collaborative editor, you know that you are able to see other's cursor when editing your parts, that's what it do), so maybe you can refer to that package.
I'd recommend you to consider manage that state yourself. For example, register an update listener, whenever the selection changes, sync the state to your own state management module. When you serialize the state, just serialize your own states as well.