-
I know that I can register my node through the initial config: <LexicalComposer initialConfig={{ nodes: [MyNode] }}> But I'd like to know if it's possible to do that after the first render and inside a plugin. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
All nodes have to registered on composer creation as conditionals nodes can cause the editor to crash or misbehave when trying to restore content on it. In fact, this used to be the previous API for node registration ( For example, you copy-paste NodeA created by plugin A. Plugin A is unmounted, NodeA is unregistered and you paste your clipboard contents, editor will crash because NodeA no longer exists. Side note: the above is not possible between two Lexical editors living on different surfaces because of the For this reason, you want to register all nodes at once even if you're not using them or might only use later. FWIW, nodes tend to be lightweight while the plugins, which can be deferred, can often be loaded at a later point in time. |
Beta Was this translation helpful? Give feedback.
All nodes have to registered on composer creation as conditionals nodes can cause the editor to crash or misbehave when trying to restore content on it. In fact, this used to be the previous API for node registration (
editor.registerNode
).For example, you copy-paste NodeA created by plugin A. Plugin A is unmounted, NodeA is unregistered and you paste your clipboard contents, editor will crash because NodeA no longer exists.
Side note: the above is not possible between two Lexical editors living on different surfaces because of the
namespace
, a unique identifier that tells Lexical to fall back to HTML or plain text.For this reason, you want to register all nodes at once even if you're no…