-
I have the following use case: I'm using lexical to implement user mentions in my application. So far, I've adapted the mentions plugin to track whenever a new mention is selected (it adds the mention to a list). At this point the mention is a lexical decorator node.
I need to be able to track when the mention is removed because if the user deletes the mention node (e.g the user mentioned It seems like I need for a way to check that a given node has been or is about to be removed. Is there currently a way to do this? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
You can use a Mutation Listener for this: https://lexical.dev/docs/concepts/listeners#registermutationlistener |
Beta Was this translation helpful? Give feedback.
-
Thanks! Just I case someone else encounters this problem, this is how I solved it for my library:
I'm not certain where to unregister the listener, though. |
Beta Was this translation helpful? Give feedback.
-
@fdemian |
Beta Was this translation helpful? Give feedback.
You can use a Mutation Listener for this:
https://lexical.dev/docs/concepts/listeners#registermutationlistener