Module: @lexical/utils
References
$splitNode
Re-exports $splitNode
Type Aliases
DFSNode
Ƭ DFSNode: Readonly
<{ depth
: number
; node
: LexicalNode
}>
Defined in
lexical-utils/src/index.ts:34
DOMNodeToLexicalConversion
Ƭ DOMNodeToLexicalConversion: (element
: Node
) => LexicalNode
Type declaration
▸ (element
): LexicalNode
Parameters
Name | Type |
---|---|
element | Node |
Returns
Defined in
lexical-utils/src/index.ts:204
DOMNodeToLexicalConversionMap
Ƭ DOMNodeToLexicalConversionMap: Record
<string
, DOMNodeToLexicalConversion
>
Defined in
lexical-utils/src/index.ts:206
Functions
$dfs
▸ $dfs(startingNode?
, endingNode?
): DFSNode
[]
Parameters
Name | Type |
---|---|
startingNode? | LexicalNode |
endingNode? | LexicalNode |
Returns
DFSNode
[]
Defined in
lexical-utils/src/index.ts:116
$findMatchingParent
▸ $findMatchingParent(startingNode
, findFn
): LexicalNode
| null
Parameters
Name | Type |
---|---|
startingNode | LexicalNode |
findFn | (node : LexicalNode ) => boolean |
Returns
LexicalNode
| null
Defined in
lexical-utils/src/index.ts:211
$getNearestBlockElementAncestorOrThrow
▸ $getNearestBlockElementAncestorOrThrow(startNode
): ElementNode
Parameters
Name | Type |
---|---|
startNode | LexicalNode |
Returns
Defined in
lexical-utils/src/index.ts:185
$getNearestNodeOfType
▸ $getNearestNodeOfType<T
>(node
, klass
): T
| null
Type parameters
Name | Type |
---|---|
T | extends ElementNode <T > |
Parameters
Name | Type |
---|---|
node | LexicalNode |
klass | Klass <T > |
Returns
T
| null
Defined in
lexical-utils/src/index.ts:168
$insertNodeToNearestRoot
▸ $insertNodeToNearestRoot<T
>(node
): T
Type parameters
Name | Type |
---|---|
T | extends LexicalNode <T > |
Parameters
Name | Type |
---|---|
node | T |
Returns
T
Defined in
lexical-utils/src/index.ts:336
$restoreEditorState
▸ $restoreEditorState(editor
, editorState
): void
Parameters
Name | Type |
---|---|
editor | LexicalEditor |
editorState | EditorState |
Returns
void
Defined in
lexical-utils/src/index.ts:311
$wrapNodeInElement
▸ $wrapNodeInElement(node
, createElementNode
): ElementNode
Parameters
Name | Type |
---|---|
node | LexicalNode |
createElementNode | () => ElementNode |
Returns
Defined in
lexical-utils/src/index.ts:386
addClassNamesToElement
▸ addClassNamesToElement(element
, ...classNames
): void
Parameters
Name | Type |
---|---|
element | HTMLElement |
...classNames | (undefined | null | string | boolean )[] |
Returns
void
Defined in
lexical-utils/src/index.ts:39
isHTMLAnchorElement
▸ isHTMLAnchorElement(x
): x is HTMLAnchorElement
Parameters
Name | Type |
---|---|
x | Node |
Returns
x is HTMLAnchorElement
Defined in
lexical-utils/src/index.ts:396
isHTMLElement
▸ isHTMLElement(x
): x is HTMLElement
Parameters
Name | Type |
---|---|
x | EventTarget | Node |
Returns
x is HTMLElement
Defined in
lexical-utils/src/index.ts:400
isMimeType
▸ isMimeType(file
, acceptableMimeTypes
): boolean
Parameters
Name | Type |
---|---|
file | File |
acceptableMimeTypes | string [] |
Returns
boolean
Defined in
lexical-utils/src/index.ts:62
mediaFileReader
▸ mediaFileReader(files
, acceptableMimeTypes
): Promise
<{ file
: File
; result
: string
}[]>
Lexical File Reader with:
- MIME type support
- batched results (HistoryPlugin compatibility)
- 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
Name | Type |
---|---|
files | File [] |
acceptableMimeTypes | string [] |
Returns
Promise
<{ file
: File
; result
: string
}[]>
Defined in
lexical-utils/src/index.ts:85
mergeRegister
▸ mergeRegister(...func
): () => void
Parameters
Name | Type |
---|---|
...func | Func [] |
Returns
fn
▸ (): void
Returns
void
Defined in
lexical-utils/src/index.ts:230
registerNestedElementResolver
▸ registerNestedElementResolver<N
>(editor
, targetNode
, cloneNode
, handleOverlap
): () => void
Type parameters
Name | Type |
---|---|
N | extends ElementNode <N > |
Parameters
Name | Type |
---|---|
editor | LexicalEditor |
targetNode | Klass <N > |
cloneNode | (from : N ) => N |
handleOverlap | (from : N , to : N ) => void |
Returns
fn
▸ (): void
Returns
void
Defined in
lexical-utils/src/index.ts:236
removeClassNamesFromElement
▸ removeClassNamesFromElement(element
, ...classNames
): void
Parameters
Name | Type |
---|---|
element | HTMLElement |
...classNames | (undefined | null | string | boolean )[] |
Returns
void
Defined in
lexical-utils/src/index.ts:51