Skip to main content

@lexical/html

Interfaces

DOMExtensionOutput

Defined in: packages/lexical-html/src/index.ts:502

Properties

defaults

defaults: ContextRecord

Defined in: packages/lexical-html/src/index.ts:503

Type Aliases

AnyStateConfigPair

AnyStateConfigPair = StateConfigPair<any, any>

Defined in: packages/lexical-html/src/index.ts:500


StateConfigPair

StateConfigPair<K, V> = readonly [StateConfig<K, V>, V]

Defined in: packages/lexical-html/src/index.ts:495

Type Parameters

K

K extends string

V

V

Variables

DOMContextClipboard

const DOMContextClipboard: StateConfig<"@lexical/html/clipboard", boolean>

Defined in: packages/lexical-html/src/index.ts:491

true if the DOM is for or from the clipboard


DOMContextExport

const DOMContextExport: StateConfig<"@lexical/html/export", boolean>

Defined in: packages/lexical-html/src/index.ts:487

true if this is an export operation ($generateHtmlFromNodes)


DOMContextRoot

const DOMContextRoot: StateConfig<"@lexical/html/root", boolean>

Defined in: packages/lexical-html/src/index.ts:482

true if this is a whole document export operation ($generateDOMFromRoot)

Functions

$generateDOMFromNodes()

$generateDOMFromNodes<T>(container, selection, editor): T

Defined in: packages/lexical-html/src/index.ts:574

Type Parameters

T

T extends HTMLElement | DocumentFragment

Parameters

container

T

selection

null | BaseSelection

editor

LexicalEditor = ...

Returns

T


$generateDOMFromRoot()

$generateDOMFromRoot<T>(container, root): T

Defined in: packages/lexical-html/src/index.ts:595

Type Parameters

T

T extends HTMLElement | DocumentFragment

Parameters

container

T

root

LexicalNode = ...

Returns

T


$generateHtmlFromNodes()

$generateHtmlFromNodes(editor, selection): string

Defined in: packages/lexical-html/src/index.ts:89

Parameters

editor

LexicalEditor

selection

null | BaseSelection

Returns

string


$generateNodesFromDOM()

$generateNodesFromDOM(editor, dom): LexicalNode[]

Defined in: packages/lexical-html/src/index.ts:58

How you parse your html string to get a document is left up to you. In the browser you can use the native DOMParser API to generate a document (see clipboard.ts), but to use in a headless environment you can use JSDom or an equivalent library and pass in the document here.

Parameters

editor

LexicalEditor

dom

Document | ParentNode

Returns

LexicalNode[]


$getDOMContextValue()

$getDOMContextValue<K, V>(cfg, editor): V

Defined in: packages/lexical-html/src/index.ts:540

Type Parameters

K

K extends string

V

V

Parameters

cfg

StateConfig<K, V>

editor

LexicalEditor = ...

Returns

V


$withDOMContext()

$withDOMContext(cfg, editor): <T>(f) => T

Defined in: packages/lexical-html/src/index.ts:551

Parameters

cfg

Iterable<AnyStateConfigPair>

editor

LexicalEditor = ...

Returns

<T>(f): T

Type Parameters
T

T

Parameters
f

() => T

Returns

T


domOverride()

Call Signature

domOverride(nodes, config): DOMConfigMatch<LexicalNode>

Defined in: packages/lexical-html/src/index.ts:618

@NO_SIDE_EFFECTS

Parameters
nodes

"*"

config

Omit<DOMConfigMatch<LexicalNode>, "nodes">

Returns

DOMConfigMatch<LexicalNode>

Call Signature

domOverride<T>(nodes, config): DOMConfigMatch<T>

Defined in: packages/lexical-html/src/index.ts:622

@NO_SIDE_EFFECTS

Type Parameters
T

T extends LexicalNode

Parameters
nodes

readonly NodeMatch<T>[]

config

Omit<DOMConfigMatch<T>, "nodes">

Returns

DOMConfigMatch<T>


getContextValueFromRecord()

getContextValueFromRecord<K, V>(context, cfg): V

Defined in: packages/lexical-html/src/index.ts:532

Type Parameters

K

K extends string

V

V

Parameters

context

ContextRecord

cfg

StateConfig<K, V>

Returns

V