Skip to content

Remove node on click? #3093

Answered by acywatson
martinshaw asked this question in Q&A
Oct 1, 2022 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

Yea, you won't be able to do that.

The canonical way to add event listeners to nodes is to use a Mutation Listener: https://lexical.dev/docs/concepts/listeners#registermutationlistener

When the node is created, use getElementByKey to get the underlying DOM node and add a listener. Remove it when the node is destroyed.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@martinshaw
Comment options

Answer selected by martinshaw
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants