Skip to main content

@lexical/link

Classes​

AutoLinkNode​

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:487

Extends​

Constructors​

Constructor​

new AutoLinkNode(url?, attributes?, key?): AutoLinkNode

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:492

Parameters​
url?​

string = ''

attributes?​

AutoLinkAttributes = {}

key?​

string

Returns​

AutoLinkNode

Overrides​

LinkNode.constructor

Properties​

__isUnlinked​

__isUnlinked: boolean

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:490

Indicates whether the autolink was ever unlinked. *

Methods​

$config()​

$config(): BaseStaticNodeConfig & object & StaticNodeTypeAccessor<"link"> & StaticNodeConfigAccessor<{ extends: typeof ElementNode; importDOM: { a: () => object; }; }> & object & StaticNodeTypeAccessor<"autolink"> & StaticNodeConfigAccessor<{ extends: typeof LinkNode; }>

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:509

Override this to implement the new static node configuration protocol, this method is called directly on the prototype and must not depend on anything initialized in the constructor. Generally it should be a trivial implementation.

Returns​

BaseStaticNodeConfig & object & StaticNodeTypeAccessor<"link"> & StaticNodeConfigAccessor<{ extends: typeof ElementNode; importDOM: { a: () => object; }; }> & object & StaticNodeTypeAccessor<"autolink"> & StaticNodeConfigAccessor<{ extends: typeof LinkNode; }>

Example​
class MyNode extends TextNode {
$config() {
return this.config('my-node', {extends: TextNode});
}
}
Overrides​

LinkNode.$config

afterCloneFrom()​

afterCloneFrom(prevNode): void

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:504

Perform any state updates on the clone of prevNode that are not already handled by the constructor call in the static clone method. If you have state to update in your clone that is not handled directly by the constructor, it is advisable to override this method but it is required to include a call to super.afterCloneFrom(prevNode) in your implementation. This is only intended to be called by $cloneWithProperties function or via a super call.

Parameters​
prevNode​

this

Returns​

void

Example​
class ClassesTextNode extends TextNode {
// Not shown: static getType, static importJSON, exportJSON, createDOM, updateDOM
__classes = new Set<string>();
static clone(node: ClassesTextNode): ClassesTextNode {
// The inherited TextNode constructor is used here, so
// classes is not set by this method.
return new ClassesTextNode(node.__text, node.__key);
}
afterCloneFrom(node: this): void {
// This calls TextNode.afterCloneFrom and LexicalNode.afterCloneFrom
// for necessary state updates
super.afterCloneFrom(node);
this.__addClasses(node.__classes);
}
// This method is a private implementation detail, it is not
// suitable for the public API because it does not call getWritable
__addClasses(classNames: Iterable<string>): this {
for (const className of classNames) {
this.__classes.add(className);
}
return this;
}
addClass(...classNames: string[]): this {
return this.getWritable().__addClasses(classNames);
}
removeClass(...classNames: string[]): this {
const node = this.getWritable();
for (const className of classNames) {
this.__classes.delete(className);
}
return this;
}
getClasses(): Set<string> {
return this.getLatest().__classes;
}
}
Overrides​

LinkNode.afterCloneFrom

canBeEmpty()​

canBeEmpty(): boolean

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:278

Returns​

boolean

Inherited from​

LinkNode.canBeEmpty

canInsertTextAfter()​

canInsertTextAfter(): false

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:274

Returns​

false

Inherited from​

LinkNode.canInsertTextAfter

canInsertTextBefore()​

canInsertTextBefore(): false

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:270

Returns​

false

Inherited from​

LinkNode.canInsertTextBefore

createDOM()​

createDOM(config): LinkHTMLElementType

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:527

Called during the reconciliation process to determine which nodes to insert into the DOM for this Lexical Node.

This method must return exactly one HTMLElement. Nested elements are not supported.

Do not attempt to update the Lexical EditorState during this phase of the update lifecycle.

Parameters​
config​

EditorConfig

Returns​

LinkHTMLElementType

Overrides​

LinkNode.createDOM

exportJSON()​

exportJSON(): SerializedAutoLinkNode

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:554

Controls how the this node is serialized to JSON. This is important for copy and paste between Lexical editors sharing the same namespace. It's also important if you're serializing to JSON for persistent storage somewhere. See Serialization & Deserialization.

Returns​

SerializedAutoLinkNode

Overrides​

LinkNode.exportJSON

extractWithChild()​

extractWithChild(child, selection, destination): boolean

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:286

Parameters​
child​

LexicalNode

selection​

BaseSelection

destination​

"clone" | "html"

Returns​

boolean

Inherited from​

LinkNode.extractWithChild

getIsUnlinked()​

getIsUnlinked(): boolean

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:517

Returns​

boolean

getRel()​

getRel(): string | null

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:241

Returns​

string | null

Inherited from​

LinkNode.getRel

getTarget()​

getTarget(): string | null

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:231

Returns​

string | null

Inherited from​

LinkNode.getTarget

getTitle()​

getTitle(): string | null

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:251

Returns​

string | null

Inherited from​

LinkNode.getTitle

getURL()​

getURL(): string

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:221

Returns​

string

Inherited from​

LinkNode.getURL

insertNewAfter()​

insertNewAfter(_, restoreSelection?): ElementNode | null

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:261

Parameters​
_​

RangeSelection

restoreSelection?​

boolean = true

Returns​

ElementNode | null

Inherited from​

LinkNode.insertNewAfter

isEmailURI()​

isEmailURI(): boolean

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:305

Returns​

boolean

Inherited from​

LinkNode.isEmailURI

isInline()​

isInline(): true

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:282

If the method is overridden and returns true, ensure that canBeEmpty() returns false for the inline node to work correctly

Returns​

true

Inherited from​

LinkNode.isInline

isWebSiteURI()​

isWebSiteURI(): boolean

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:309

Returns​

boolean

Inherited from​

LinkNode.isWebSiteURI

sanitizeUrl()​

sanitizeUrl(url): string

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:166

Parameters​
url​

string

Returns​

string

Inherited from​

LinkNode.sanitizeUrl

setIsUnlinked()​

setIsUnlinked(value): this

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:521

Parameters​
value​

boolean

Returns​

this

setRel()​

setRel(rel): this

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:245

Parameters​
rel​

string | null

Returns​

this

Inherited from​

LinkNode.setRel

setTarget()​

setTarget(target): this

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:235

Parameters​
target​

string | null

Returns​

this

Inherited from​

LinkNode.setTarget

setTitle()​

setTitle(title): this

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:255

Parameters​
title​

string | null

Returns​

this

Inherited from​

LinkNode.setTitle

setURL()​

setURL(url): this

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:225

Parameters​
url​

string

Returns​

this

Inherited from​

LinkNode.setURL

shouldMergeAdjacentLink(_otherLink): boolean

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:513

Parameters​

LinkNode

Returns​

boolean

Overrides​

LinkNode.shouldMergeAdjacentLink

updateDOM()​

updateDOM(prevNode, anchor, config): boolean

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:535

Called when a node changes and should update the DOM in whatever way is necessary to make it align with any changes that might have happened during the update.

Returning "true" here will cause lexical to unmount and recreate the DOM node (by calling createDOM). You would need to do this if the element tag changes, for instance.

Parameters​
prevNode​

this

anchor​

LinkHTMLElementType

config​

EditorConfig

Returns​

boolean

Overrides​

LinkNode.updateDOM

updateFromJSON()​

updateFromJSON(serializedNode): this

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:546

Update this LexicalNode instance from serialized JSON. It's recommended to implement as much logic as possible in this method instead of the static importJSON method, so that the functionality can be inherited in subclasses.

The LexicalUpdateJSON utility type should be used to ignore any type, version, or children properties in the JSON so that the extended JSON from subclasses are acceptable parameters for the super call.

If overridden, this method must call super.

Parameters​
serializedNode​

LexicalUpdateJSON<SerializedAutoLinkNode>

Returns​

this

Example​
class MyTextNode extends TextNode {
// ...
static importJSON(serializedNode: SerializedMyTextNode): MyTextNode {
return $createMyTextNode()
.updateFromJSON(serializedNode);
}
updateFromJSON(
serializedNode: LexicalUpdateJSON<SerializedMyTextNode>,
): this {
return super.updateFromJSON(serializedNode)
.setMyProperty(serializedNode.myProperty);
}
}
Overrides​

LinkNode.updateFromJSON

updateLinkDOM()​

updateLinkDOM(prevNode, anchor, config): void

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:125

Parameters​
prevNode​

AutoLinkNode | null

anchor​

LinkHTMLElementType

config​

EditorConfig

Returns​

void

Inherited from​

LinkNode.updateLinkDOM


LinkNode​

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:75

Extends​

Extended by​

Constructors​

Constructor​

new LinkNode(url?, attributes?, key?): LinkNode

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:97

Parameters​
url?​

string = ''

attributes?​

LinkAttributes = {}

key?​

string

Returns​

LinkNode

Overrides​

ElementNode.constructor

Methods​

$config()​

$config(): BaseStaticNodeConfig & object & StaticNodeTypeAccessor<"link"> & StaticNodeConfigAccessor<{ extends: typeof ElementNode; importDOM: { a: () => object; }; }>

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:85

Override this to implement the new static node configuration protocol, this method is called directly on the prototype and must not depend on anything initialized in the constructor. Generally it should be a trivial implementation.

Returns​

BaseStaticNodeConfig & object & StaticNodeTypeAccessor<"link"> & StaticNodeConfigAccessor<{ extends: typeof ElementNode; importDOM: { a: () => object; }; }>

Example​
class MyNode extends TextNode {
$config() {
return this.config('my-node', {extends: TextNode});
}
}
Overrides​

ElementNode.$config

afterCloneFrom()​

afterCloneFrom(prevNode): void

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:110

Perform any state updates on the clone of prevNode that are not already handled by the constructor call in the static clone method. If you have state to update in your clone that is not handled directly by the constructor, it is advisable to override this method but it is required to include a call to super.afterCloneFrom(prevNode) in your implementation. This is only intended to be called by $cloneWithProperties function or via a super call.

Parameters​
prevNode​

this

Returns​

void

Example​
class ClassesTextNode extends TextNode {
// Not shown: static getType, static importJSON, exportJSON, createDOM, updateDOM
__classes = new Set<string>();
static clone(node: ClassesTextNode): ClassesTextNode {
// The inherited TextNode constructor is used here, so
// classes is not set by this method.
return new ClassesTextNode(node.__text, node.__key);
}
afterCloneFrom(node: this): void {
// This calls TextNode.afterCloneFrom and LexicalNode.afterCloneFrom
// for necessary state updates
super.afterCloneFrom(node);
this.__addClasses(node.__classes);
}
// This method is a private implementation detail, it is not
// suitable for the public API because it does not call getWritable
__addClasses(classNames: Iterable<string>): this {
for (const className of classNames) {
this.__classes.add(className);
}
return this;
}
addClass(...classNames: string[]): this {
return this.getWritable().__addClasses(classNames);
}
removeClass(...classNames: string[]): this {
const node = this.getWritable();
for (const className of classNames) {
this.__classes.delete(className);
}
return this;
}
getClasses(): Set<string> {
return this.getLatest().__classes;
}
}
Overrides​

ElementNode.afterCloneFrom

canBeEmpty()​

canBeEmpty(): boolean

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:278

Returns​

boolean

Overrides​

ElementNode.canBeEmpty

canInsertTextAfter()​

canInsertTextAfter(): false

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:274

Returns​

false

Overrides​

ElementNode.canInsertTextAfter

canInsertTextBefore()​

canInsertTextBefore(): false

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:270

Returns​

false

Overrides​

ElementNode.canInsertTextBefore

createDOM()​

createDOM(config): LinkHTMLElementType

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:118

Called during the reconciliation process to determine which nodes to insert into the DOM for this Lexical Node.

This method must return exactly one HTMLElement. Nested elements are not supported.

Do not attempt to update the Lexical EditorState during this phase of the update lifecycle.

Parameters​
config​

EditorConfig

Returns​

LinkHTMLElementType

Overrides​

ElementNode.createDOM

exportJSON()​

exportJSON(): SerializedLinkNode | SerializedAutoLinkNode

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:211

Controls how the this node is serialized to JSON. This is important for copy and paste between Lexical editors sharing the same namespace. It's also important if you're serializing to JSON for persistent storage somewhere. See Serialization & Deserialization.

Returns​

SerializedLinkNode | SerializedAutoLinkNode

Overrides​

ElementNode.exportJSON

extractWithChild()​

extractWithChild(child, selection, destination): boolean

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:286

Parameters​
child​

LexicalNode

selection​

BaseSelection

destination​

"clone" | "html"

Returns​

boolean

Overrides​

ElementNode.extractWithChild

getRel()​

getRel(): string | null

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:241

Returns​

string | null

getTarget()​

getTarget(): string | null

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:231

Returns​

string | null

getTitle()​

getTitle(): string | null

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:251

Returns​

string | null

getURL()​

getURL(): string

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:221

Returns​

string

insertNewAfter()​

insertNewAfter(_, restoreSelection?): ElementNode | null

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:261

Parameters​
_​

RangeSelection

restoreSelection?​

boolean = true

Returns​

ElementNode | null

Overrides​

ElementNode.insertNewAfter

isEmailURI()​

isEmailURI(): boolean

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:305

Returns​

boolean

isInline()​

isInline(): true

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:282

If the method is overridden and returns true, ensure that canBeEmpty() returns false for the inline node to work correctly

Returns​

true

Overrides​

ElementNode.isInline

isWebSiteURI()​

isWebSiteURI(): boolean

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:309

Returns​

boolean

sanitizeUrl()​

sanitizeUrl(url): string

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:166

Parameters​
url​

string

Returns​

string

setRel()​

setRel(rel): this

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:245

Parameters​
rel​

string | null

Returns​

this

setTarget()​

setTarget(target): this

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:235

Parameters​
target​

string | null

Returns​

this

setTitle()​

setTitle(title): this

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:255

Parameters​
title​

string | null

Returns​

this

setURL()​

setURL(url): this

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:225

Parameters​
url​

string

Returns​

this

shouldMergeAdjacentLink(otherLink): boolean

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:314

Parameters​

LinkNode

Returns​

boolean

updateDOM()​

updateDOM(prevNode, anchor, config): boolean

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:148

Called when a node changes and should update the DOM in whatever way is necessary to make it align with any changes that might have happened during the update.

Returning "true" here will cause lexical to unmount and recreate the DOM node (by calling createDOM). You would need to do this if the element tag changes, for instance.

Parameters​
prevNode​

this

anchor​

LinkHTMLElementType

config​

EditorConfig

Returns​

boolean

Overrides​

ElementNode.updateDOM

updateFromJSON()​

updateFromJSON(serializedNode): this

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:157

Update this LexicalNode instance from serialized JSON. It's recommended to implement as much logic as possible in this method instead of the static importJSON method, so that the functionality can be inherited in subclasses.

The LexicalUpdateJSON utility type should be used to ignore any type, version, or children properties in the JSON so that the extended JSON from subclasses are acceptable parameters for the super call.

If overridden, this method must call super.

Parameters​
serializedNode​

LexicalUpdateJSON<SerializedLinkNode>

Returns​

this

Example​
class MyTextNode extends TextNode {
// ...
static importJSON(serializedNode: SerializedMyTextNode): MyTextNode {
return $createMyTextNode()
.updateFromJSON(serializedNode);
}
updateFromJSON(
serializedNode: LexicalUpdateJSON<SerializedMyTextNode>,
): this {
return super.updateFromJSON(serializedNode)
.setMyProperty(serializedNode.myProperty);
}
}
Overrides​

ElementNode.updateFromJSON

updateLinkDOM()​

updateLinkDOM(prevNode, anchor, config): void

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:125

Parameters​
prevNode​

LinkNode | null

anchor​

LinkHTMLElementType

config​

EditorConfig

Returns​

void

Interfaces​

AutoLinkAnnounceExtensionConfig​

Defined in: packages/lexical-link/src/AutoLinkAnnounceExtension.ts:15

Properties​

created​

created: string

Defined in: packages/lexical-link/src/AutoLinkAnnounceExtension.ts:17

Announced when typing turns text into a link.

createdMany​

createdMany: string

Defined in: packages/lexical-link/src/AutoLinkAnnounceExtension.ts:22

Announced when several links appear at once, as pasting a block of text can. %s is replaced with how many.

destroyed​

destroyed: string

Defined in: packages/lexical-link/src/AutoLinkAnnounceExtension.ts:24

Announced when an automatic link stops being a link.

destroyedMany​

destroyedMany: string

Defined in: packages/lexical-link/src/AutoLinkAnnounceExtension.ts:29

Announced when several links go at once, as deleting a selection that spans them does. %s is replaced with how many.

disabled​

disabled: boolean

Defined in: packages/lexical-link/src/AutoLinkAnnounceExtension.ts:34

When true, automatic links are not announced. Toggle at runtime via the output signal. Default false.


AutoLinkConfig​

Defined in: packages/lexical-link/src/LexicalAutoLinkExtension.ts:601

Properties​

changeHandlers​

changeHandlers: ChangeHandler[]

Defined in: packages/lexical-link/src/LexicalAutoLinkExtension.ts:602

excludeParents​

excludeParents: (parent) => boolean[]

Defined in: packages/lexical-link/src/LexicalAutoLinkExtension.ts:603

Parameters​
parent​

ElementNode

Returns​

boolean

matchers​

matchers: LinkMatcher[]

Defined in: packages/lexical-link/src/LexicalAutoLinkExtension.ts:604

separatorRegex​

separatorRegex: RegExp

Defined in: packages/lexical-link/src/LexicalAutoLinkExtension.ts:610

The regular expression used to determine whether surrounding characters count as separators when validating auto-link boundaries. Defaults to /[.,;\s]/.


ClickableLinkConfig​

Defined in: packages/lexical-link/src/ClickableLinkExtension.ts:42

Properties​

disabled​

disabled: boolean

Defined in: packages/lexical-link/src/ClickableLinkExtension.ts:46

Disable this extension when true (default false)

newTab​

newTab: boolean

Defined in: packages/lexical-link/src/ClickableLinkExtension.ts:44

Open clicked links in a new tab when true (default false)

Type Aliases​

AutoLinkAttributes​

AutoLinkAttributes = Partial<Spread<LinkAttributes, { isUnlinked?: boolean; }>>

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:53


ChangeHandler​

ChangeHandler = (url, prevUrl) => void

Defined in: packages/lexical-link/src/LexicalAutoLinkExtension.ts:43

A callback invoked when the auto-link plugin creates, updates, or removes an automatic link. It receives the new url and the prevUrl; either may be null when a link is added or removed.

Parameters​

url​

string | null

prevUrl​

string | null

Returns​

void


LinkAttributes​

LinkAttributes = object

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:47

Properties​

rel?​

optional rel?: null | string

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:48

target?​

optional target?: null | string

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:49

title?​

optional title?: null | string

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:50


LinkMatcher​

LinkMatcher = (text) => LinkMatcherResult | null

Defined in: packages/lexical-link/src/LexicalAutoLinkExtension.ts:61

A function that inspects a piece of text and returns a LinkMatcherResult for the first URL it recognizes, or null if none is found. Used by the auto-link plugin to detect links as the user types.

Parameters​

text​

string

Returns​

LinkMatcherResult | null


SerializedAutoLinkNode​

SerializedAutoLinkNode = Spread<{ isUnlinked: boolean; }, SerializedLinkNode>

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:478


SerializedLinkNode​

SerializedLinkNode = Spread<{ url: string; }, Spread<LinkAttributes, SerializedElementNode>>

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:57

Variables​

AutoLinkAnnounceExtension​

const AutoLinkAnnounceExtension: LexicalExtension<AutoLinkAnnounceExtensionConfig, "@lexical/link/AutoLinkAnnounce", NamedSignalsOutput<AutoLinkAnnounceExtensionConfig>, unknown>

Defined in: packages/lexical-link/src/AutoLinkAnnounceExtension.ts:50

Announces automatic links through the AriaLiveRegionExtension sink.

Typing a web address turns it into a link on its own, partway through typing it, with no keystroke to confirm and nothing inserted. A screen reader says nothing, so the user has no way to know a link now exists.

A creation paired with a destruction in the same update is not announced. Every keystroke that extends an address rebuilds the link — the old node destroyed and a new one created at once — so announcing every creation would say "Link" at www.example.c, again at o, and again at m. Only a creation on its own is a link that was not there a moment ago.


autoLinkEmailMatcher​

const autoLinkEmailMatcher: LinkMatcher

Defined in: packages/lexical-link/src/LexicalAutoLinkExtension.ts:132

A ready-to-use LinkMatcher for email addresses. Bounded quantifiers keep matching linear-time; the limits comfortably exceed RFC 5321 maximums.


AutoLinkExtension​

const AutoLinkExtension: LexicalExtension<AutoLinkConfig, "@lexical/link/AutoLink", unknown, unknown>

Defined in: packages/lexical-link/src/LexicalAutoLinkExtension.ts:698

An extension to automatically create AutoLinkNode from text that matches the configured matchers. For ready-to-use matchers see autoLinkUrlMatcher (Unicode URL detection with parenthesis balancing) and autoLinkEmailMatcher (email addresses). To build a custom matcher from a RegExp, see createLinkMatcherWithRegExp.

The given matchers and changeHandlers will be merged by concatenating the configured arrays.


autoLinkUrlMatcher​

const autoLinkUrlMatcher: LinkMatcher

Defined in: packages/lexical-link/src/LexicalAutoLinkExtension.ts:102

A ready-to-use LinkMatcher for URLs with full Unicode support (\\p{L}, \\p{N}). Handles parenthesis balancing so that Wikipedia-style URLs like https://en.wikipedia.org/wiki/Fish_(disambiguation) are matched correctly even when wrapped in prose parentheses.


ClickableLinkExtension​

const ClickableLinkExtension: LexicalExtension<ClickableLinkConfig, "@lexical/link/ClickableLink", NamedSignalsOutput<ClickableLinkConfig>, unknown>

Defined in: packages/lexical-link/src/ClickableLinkExtension.ts:145

Normally in a Lexical editor the CLICK_COMMAND on a LinkNode will cause the selection to change instead of opening a link. This extension can be used to restore the default behavior, e.g. when the editor is not editable.


LinkExtension​

const LinkExtension: LexicalExtension<LinkConfig, "@lexical/link/Link", NamedSignalsOutput<LinkConfig>, unknown>

Defined in: packages/lexical-link/src/LexicalLinkExtension.ts:157

Provides LinkNode, an implementation of TOGGLE_LINK_COMMAND, and a PASTE_COMMAND listener to wrap selected nodes in a link when a URL is pasted and validateUrl is defined.


LinkImportExtension​

const LinkImportExtension: LexicalExtension<ExtensionConfigBase, "@lexical/link/Import", unknown, unknown>

Defined in: packages/lexical-link/src/LexicalLinkExtension.ts:197

Experimental

Bundles LinkImportRules together with the runtime LinkExtension.

Deprecated​

LinkExtension now registers LinkImportRules (and CoreImportExtension) itself — depend on it directly instead.


LinkImportRules​

const LinkImportRules: DOMImportRule<ElementSelectorBuilder<HTMLAnchorElement, Record<string, never>>>[]

Defined in: packages/lexical-link/src/LinkImportExtension.ts:48

Experimental

Import rules for LinkNode.

Registered by LinkExtension itself (together with CoreImportExtension), so any editor that uses the link extension can import <a> through the DOMImportExtension pipeline without further configuration.


const TOGGLE_LINK_COMMAND: LexicalCommand<string | object & LinkAttributes | null>

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:594

Functions​

$createAutoLinkNode()​

$createAutoLinkNode(url?, attributes?): AutoLinkNode

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:576

Takes a URL and creates an AutoLinkNode. AutoLinkNodes are generally automatically generated during typing, which is especially useful when a button to generate a LinkNode is not practical.

Parameters​

url?​

string = ''

The URL the LinkNode should direct to.

attributes?​

Partial<Spread<LinkAttributes, { isUnlinked?: boolean; }>>

Optional HTML a tag attributes. { target, rel, title }

Returns​

AutoLinkNode

The LinkNode.


$createLinkNode()​

$createLinkNode(url?, attributes?): LinkNode

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:460

Takes a URL and creates a LinkNode.

Parameters​

url?​

string = ''

The URL the LinkNode should direct to.

attributes?​

LinkAttributes

Optional HTML a tag attributes { target, rel, title }

Returns​

LinkNode

The LinkNode.


$isAutoLinkNode()​

$isAutoLinkNode(node): node is AutoLinkNode

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:588

Determines if node is an AutoLinkNode.

Parameters​

node​

LexicalNode | null | undefined

The node to be checked.

Returns​

node is AutoLinkNode

true if node is an AutoLinkNode, false otherwise.


$isLinkNode()​

$isLinkNode(node): node is LinkNode

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:472

Determines if node is a LinkNode.

Parameters​

node​

LexicalNode | null | undefined

The node to be checked.

Returns​

node is LinkNode

true if node is a LinkNode, false otherwise.


$toggleLink(urlOrAttributes, attributes?): void

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:723

Generates or updates a LinkNode. It can also delete a LinkNode if the URL is null, but saves any children and brings them up to the parent node.

Parameters​

urlOrAttributes​

string | LinkAttributes & object | null

The URL the link directs to, or an attributes object with an url property

attributes?​

LinkAttributes = {}

Optional HTML a tag attributes. { target, rel, title }

Returns​

void


createLinkMatcherWithRegExp()​

createLinkMatcherWithRegExp(regExp, urlTransformer?): (text) => { index: number; length: number; text: string; url: string; } | null

Defined in: packages/lexical-link/src/LexicalAutoLinkExtension.ts:72

Builds a LinkMatcher from a regular expression. The matched text is used as the link URL, optionally rewritten by urlTransformer (for example to prepend a protocol). Pass the result to the auto-link plugin's matchers.

Parameters​

regExp​

RegExp

urlTransformer?​

(text) => string

Returns​

A matcher that reports the first match of regExp in the text.

@NO_SIDE_EFFECTS

(text) => { index: number; length: number; text: string; url: string; } | null


formatUrl()​

formatUrl(url): string

Defined in: packages/lexical-link/src/LexicalLinkNode.ts:926

Formats a URL string by adding appropriate protocol if missing

Parameters​

url​

string

URL to format

Returns​

string

Formatted URL with appropriate protocol


registerAutoLink(editor, config?): () => void

Defined in: packages/lexical-link/src/LexicalAutoLinkExtension.ts:620

Parameters​

editor​

LexicalEditor

config?​

Partial<AutoLinkConfig> & Omit<AutoLinkConfig, "separatorRegex"> = defaultConfig

Returns​

() => void


registerClickableLink(editor, stores, eventOptions?): () => void

Defined in: packages/lexical-link/src/ClickableLinkExtension.ts:49

Parameters​

editor​

LexicalEditor

stores​

NamedSignalsOutput<ClickableLinkConfig>

eventOptions?​

Pick<AddEventListenerOptions, "signal"> = {}

Returns​

() => void