How to remove all nodes of a given type from editor #3499
chalecki
started this conversation in
Show and tell
Replies: 2 comments 3 replies
-
I’d look into using a Lexical mutation listener. That should let you store all the node keys for all |
Beta Was this translation helpful? Give feedback.
2 replies
-
I've ended up with this solution but I'm not sure if it's correct or optimal performance-wise 🤔
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey. I'm working on a custom plugin that allows adding references and abbreviations to the text editor. Each ref and abbr node has a unique ID and attribute
data-lexical-[reference/abbreviation
I already created nodes, components, and toolbar buttons for that. Everything works great but I've stuck with custom behavior I have to add.
The abbreviations and references list have to be stored outside the editor, in the database. They can be reused in all editors I have across the app. They can be updated via a custom listing page with action buttons. Each time I edit or delete a node it must be reflected in the editor. I already covered that part but I have no clue how I can approach removing all nodes of a given type.
From the screenshot above, imagine you want to remove all usages of
abbr 1
(AbbreviationNode
+uuid
). You click the three dots button and from there you click "Remove". And here are my questions:.remove()
method?Any ideas?
Cheers 🍻
Beta Was this translation helpful? Give feedback.
All reactions