Bug: Unable to find an active editor state when in editor.update callback fn #4172
-
I am trying to create a simple editor that allows for insertion of emojis from a dropdown menu using the Chat Composer components. I created a custom Lexical plugin to outline this functionality and simplified the menu (
Requiring the use of Paste's exported Lexical helpers is preventing me from submitting a request directly to Lexical. Can someone please point me in the right direction? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 6 replies
-
Disclaimer: This is a very experimental bot using OpenAI's GPT-4. The answers may not be correct, a human will review the answer and update it if necessary. Sorry, I don't know how to help with that. I did do a search though, and I managed to find these other Discussions that might be similar or related to your question. Give them a read to see if they answer your question. If they do, head back here and update this discussion and mark it as answered, pointing others to the related discussion:
|
Beta Was this translation helpful? Give feedback.
-
The error "Unable to find an active editor state" typically occurs when trying to access the editor state outside of the allowed synchronous context, such as within the For your
By following these practices, you should be able to avoid the "Unable to find an active editor state" error. If you continue to experience issues, double-check that all state interactions are correctly wrapped in the appropriate callbacks. |
Beta Was this translation helpful? Give feedback.
-
Hi @cfree, I would love to help you on this! I'm always interested about users' There are a few things to consider when creating a custom plugin (which is supported). The plugin must be placed within the Also, although the lexical exports come from paste they are just being passed up form the source library and some are renamed. You can view the exports here. In theory you should be able to use the Lexical library modules that are potentially missing without error but it has not been tested. Happy to work and debug this with you! |
Beta Was this translation helpful? Give feedback.
Hi @cfree this is one of the more advanced use cases we had had requested. I have been debugging this and found that the helper functions such as
$createTextNode
need to come from the Paste library and not the lexical import. However they are not currently exported so I will be creating a ticket to address this.What I am able to do though is interact with the editor state directly. I have forked your sandbox which can be found here. What I am doing here is getting the state, using the
toJSON
method and then manipulating the object. I then set the editor state to be the updated state and I can see it reflected. It may get complicated based on the number of paragraph nodes you have so I su…