Skip to main content

@lexical/react/LexicalAutoEmbedPluginUtils

Classes​

AutoEmbedOption​

Defined in: packages/lexical-react/src/LexicalAutoEmbedPluginUtils.ts:67

A MenuOption for the auto-embed menu, pairing a display title with an onSelect callback invoked when the user chooses to embed the detected URL.

Extends​

Constructors​

Constructor​

new AutoEmbedOption(title, options): AutoEmbedOption

Defined in: packages/lexical-react/src/LexicalAutoEmbedPluginUtils.ts:70

Parameters​
title​

string

options​
onSelect​

(targetNode) => void

Returns​

AutoEmbedOption

Overrides​

MenuOption.constructor

Properties​

icon?​

optional icon?: Element

Defined in: packages/lexical-react/src/LexicalMenuOption.ts:27

Inherited from​

MenuOption.icon

key​

key: string

Defined in: packages/lexical-react/src/LexicalMenuOption.ts:25

Inherited from​

MenuOption.key

onSelect​

onSelect: (targetNode) => void

Defined in: packages/lexical-react/src/LexicalAutoEmbedPluginUtils.ts:69

Parameters​
targetNode​

LexicalNode | null

Returns​

void

ref?​

optional ref?: RefObject<HTMLElement | null>

Defined in: packages/lexical-react/src/LexicalMenuOption.ts:26

Inherited from​

MenuOption.ref

title​

title: string

Defined in: packages/lexical-react/src/LexicalAutoEmbedPluginUtils.ts:68

Overrides​

MenuOption.title

Methods​

setRefElement()​

setRefElement(element): void

Defined in: packages/lexical-react/src/LexicalMenuOption.ts:36

Parameters​
element​

HTMLElement | null

Returns​

void

Inherited from​

MenuOption.setRefElement

Interfaces​

EmbedConfig​

Defined in: packages/lexical-react/src/LexicalAutoEmbedPluginUtils.ts:34

Describes a kind of embed (for example YouTube, a tweet, or Google Maps) that LexicalAutoEmbedPlugin can detect and insert. Each config has a type identifier, a parseUrl function that decides whether a URL matches and extracts its data, and an insertNode function that inserts the corresponding Lexical node.

Type Parameters​

TEmbedMatchResultData​

TEmbedMatchResultData = unknown

TEmbedMatchResult​

TEmbedMatchResult = EmbedMatchResult<TEmbedMatchResultData>

Properties​

insertNode​

insertNode: (editor, result) => void

Defined in: packages/lexical-react/src/LexicalAutoEmbedPluginUtils.ts:44

Parameters​
editor​

LexicalEditor

result​

TEmbedMatchResult

Returns​

void

parseUrl​

parseUrl: (text) => TEmbedMatchResult | Promise<TEmbedMatchResult | null> | null

Defined in: packages/lexical-react/src/LexicalAutoEmbedPluginUtils.ts:40

Parameters​
text​

string

Returns​

TEmbedMatchResult | Promise<TEmbedMatchResult | null> | null

type​

type: string

Defined in: packages/lexical-react/src/LexicalAutoEmbedPluginUtils.ts:38

Type Aliases​

EmbedMatchResult​

EmbedMatchResult<TEmbedMatchResult> = object

Defined in: packages/lexical-react/src/LexicalAutoEmbedPluginUtils.ts:21

The result of matching a URL for an embed: the matched url, an id identifying the embedded resource, and optional provider-specific data.

Type Parameters​

TEmbedMatchResult​

TEmbedMatchResult = unknown

Properties​

data?​

optional data?: TEmbedMatchResult

Defined in: packages/lexical-react/src/LexicalAutoEmbedPluginUtils.ts:24

id​

id: string

Defined in: packages/lexical-react/src/LexicalAutoEmbedPluginUtils.ts:23

url​

url: string

Defined in: packages/lexical-react/src/LexicalAutoEmbedPluginUtils.ts:22

Variables​

INSERT_EMBED_COMMAND​

const INSERT_EMBED_COMMAND: LexicalCommand<EmbedConfig["type"]>

Defined in: packages/lexical-react/src/LexicalAutoEmbedPluginUtils.ts:59

Command dispatched to start inserting an embed. Its payload is the type of the EmbedConfig to use; LexicalAutoEmbedPlugin listens for it and runs that config's URL detection flow.


URL_MATCHER​

const URL_MATCHER: RegExp

Defined in: packages/lexical-react/src/LexicalAutoEmbedPluginUtils.ts:51

A general-purpose regular expression for detecting URLs, provided as a convenience for implementing an EmbedConfig's parseUrl.