Skip to main content

Module: @lexical/utils

References

$splitNode

Re-exports $splitNode

Type Aliases

DFSNode

Ƭ DFSNode: Readonly<{ depth: number ; node: LexicalNode }>

Defined in

lexical-utils/src/index.ts:33


DOMNodeToLexicalConversion

Ƭ DOMNodeToLexicalConversion: (element: Node) => LexicalNode

Type declaration

▸ (element): LexicalNode

Parameters
NameType
elementNode
Returns

LexicalNode

Defined in

lexical-utils/src/index.ts:203


DOMNodeToLexicalConversionMap

Ƭ DOMNodeToLexicalConversionMap: Record<string, DOMNodeToLexicalConversion>

Defined in

lexical-utils/src/index.ts:205

Functions

$dfs

$dfs(startingNode?, endingNode?): DFSNode[]

Parameters

NameType
startingNode?LexicalNode
endingNode?LexicalNode

Returns

DFSNode[]

Defined in

lexical-utils/src/index.ts:115


$findMatchingParent

$findMatchingParent(startingNode, findFn): LexicalNode | null

Parameters

NameType
startingNodeLexicalNode
findFn(node: LexicalNode) => boolean

Returns

LexicalNode | null

Defined in

lexical-utils/src/index.ts:210


$getNearestBlockElementAncestorOrThrow

$getNearestBlockElementAncestorOrThrow(startNode): ElementNode

Parameters

NameType
startNodeLexicalNode

Returns

ElementNode

Defined in

lexical-utils/src/index.ts:184


$getNearestNodeOfType

$getNearestNodeOfType<T>(node, klass): T | null

Type parameters

NameType
Textends ElementNode<T>

Parameters

NameType
nodeLexicalNode
klassKlass<T>

Returns

T | null

Defined in

lexical-utils/src/index.ts:167


$insertNodeToNearestRoot

$insertNodeToNearestRoot<T>(node): T

Type parameters

NameType
Textends LexicalNode<T>

Parameters

NameType
nodeT

Returns

T

Defined in

lexical-utils/src/index.ts:335


$restoreEditorState

$restoreEditorState(editor, editorState): void

Parameters

NameType
editorLexicalEditor
editorStateEditorState

Returns

void

Defined in

lexical-utils/src/index.ts:310


$wrapNodeInElement

$wrapNodeInElement(node, createElementNode): ElementNode

Parameters

NameType
nodeLexicalNode
createElementNode() => ElementNode

Returns

ElementNode

Defined in

lexical-utils/src/index.ts:383


addClassNamesToElement

addClassNamesToElement(element, ...classNames): void

Parameters

NameType
elementHTMLElement
...classNames(undefined | null | string | boolean)[]

Returns

void

Defined in

lexical-utils/src/index.ts:38


isMimeType

isMimeType(file, acceptableMimeTypes): boolean

Parameters

NameType
fileFile
acceptableMimeTypesstring[]

Returns

boolean

Defined in

lexical-utils/src/index.ts:61


mediaFileReader

mediaFileReader(files, acceptableMimeTypes): Promise<{ file: File ; result: string }[]>

Lexical File Reader with:

  1. MIME type support
  2. batched results (HistoryPlugin compatibility)
  3. Order aware (respects the order when multiple Files are passed)

const filesResult = await mediaFileReader(files, ['image/']); filesResult.forEach(file => editor.dispatchCommand('INSERT_IMAGE', { src: file.result, }));

Parameters

NameType
filesFile[]
acceptableMimeTypesstring[]

Returns

Promise<{ file: File ; result: string }[]>

Defined in

lexical-utils/src/index.ts:84


mergeRegister

mergeRegister(...func): () => void

Parameters

NameType
...funcFunc[]

Returns

fn

▸ (): void

Returns

void

Defined in

lexical-utils/src/index.ts:229


registerNestedElementResolver

registerNestedElementResolver<N>(editor, targetNode, cloneNode, handleOverlap): () => void

Type parameters

NameType
Nextends ElementNode<N>

Parameters

NameType
editorLexicalEditor
targetNodeKlass<N>
cloneNode(from: N) => N
handleOverlap(from: N, to: N) => void

Returns

fn

▸ (): void

Returns

void

Defined in

lexical-utils/src/index.ts:235


removeClassNamesFromElement

removeClassNamesFromElement(element, ...classNames): void

Parameters

NameType
elementHTMLElement
...classNames(undefined | null | string | boolean)[]

Returns

void

Defined in

lexical-utils/src/index.ts:50