Function: getPeerDependencyFromEditor()
getPeerDependencyFromEditor<
Extension
>(editor
,extensionName
):LexicalExtensionDependency
<Extension
> |undefined
Get the finalized config and output of an Extension that was used to build the editor by name.
This can be used from the implementation of a LexicalNode or in other situation where you have an editor reference but it's not easy to pass the config around. Use this version if you do not have a concrete reference to the Extension for some reason (e.g. it is an optional peer dependency, or you are avoiding a circular import).
Both the explicit Extension type and the name are required.
Type Parameters
• Extension extends AnyLexicalExtension
= never
Parameters
• editor: LexicalEditor
The editor that may have been built using extension
• extensionName: Extension
["name"
]
The name of the Extension
Returns
LexicalExtensionDependency
<Extension
> | undefined
The config and output of the Extension or undefined
Example
import type { EmojiExtension } from "@etrepum/lexical-emoji-extension";
getPeerDependencyFromEditor<typeof EmojiExtension>(editor, "@etrepum/lexical-emoji-extension/Emoji");