How to make changes to node that cant be managed through lexical? #7988
-
|
Hi In react/lexical. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
|
This is done with a decoratornode. |
Beta Was this translation helpful? Give feedback.
-
|
ok thank you, I will try that :) |
Beta Was this translation helpful? Give feedback.
-
|
It's not really clear what you're trying to ask here, but there's always a way to get access to the editor instance. How you get it or save it depends on what context the code is running and what you're trying to do. From React code you'd be using useLexicalComposerContext, from a lexical update you'd use $getEditor (although you usually don't need a reference to the editor from an update). |
Beta Was this translation helpful? Give feedback.
This is done with a decoratornode.
Assuming you are using react.
You could create a new class that extends DecoratorNode<JSX.Element>
then it should have a decorate method (among others) that return a element.
This element is not managed by lexical, and you can make changes to it and its descendants (if it has any).
Also a common pattern is creating an other react component which is returned by decorate. this allows for complex behaviour, and as a central place to manage commands for that node.