Skip to main content

@lexical/react/LexicalAutoEmbedPlugin

Functions​

LexicalAutoEmbedPlugin()​

LexicalAutoEmbedPlugin<TEmbedConfig>(__namedParameters): Element | null

Defined in: packages/lexical-react/src/LexicalAutoEmbedPlugin.tsx:115

Watches for pasted AutoLink nodes that match any of the provided embed configurations (e.g., YouTube, Twitter URLs). When a match is found, it shows a menu offering to replace the link with an embedded node.

You can pass a generic type to the plugin to extend EmbedConfig with additional data in EmbedMatchResult that will be passed to the callbacks

Type Parameters​

TEmbedConfig​

TEmbedConfig extends EmbedConfig<unknown, EmbedMatchResult<unknown>>

Parameters​

__namedParameters​

LexicalAutoEmbedPluginProps<TEmbedConfig>

Returns​

Element | null

Example​

Usage

interface CustomEmbedConfig extends EmbedConfig<{
domain: string;
oid?: string;
}> {
// Icon for display.
icon?: JSX.Element;
// Embed a Figma Project.
description?: string;
};

return (
<LexicalAutoEmbedPlugin<CustomEmbedConfig>
embedConfigs={EmbedConfigs}
getMenuOptions={getMenuOptions}
/>
);

References​

AutoEmbedOption​

Re-exports AutoEmbedOption


EmbedConfig​

Re-exports EmbedConfig


EmbedMatchResult​

Re-exports EmbedMatchResult


INSERT_EMBED_COMMAND​

Re-exports INSERT_EMBED_COMMAND


URL_MATCHER​

Re-exports URL_MATCHER