Skip to main content

Module: @lexical/code

Classes

Type Aliases

SerializedCodeNode

Ƭ SerializedCodeNode: Spread<{ language: string | null | undefined }, SerializedElementNode>

Defined in

packages/lexical-code/src/CodeNode.ts:44

Variables

CODE_LANGUAGE_FRIENDLY_NAME_MAP

Const CODE_LANGUAGE_FRIENDLY_NAME_MAP: Record<string, string>

Defined in

packages/lexical-code/src/CodeHighlightNode.ts:44


CODE_LANGUAGE_MAP

Const CODE_LANGUAGE_MAP: Record<string, string>

Defined in

packages/lexical-code/src/CodeHighlightNode.ts:64


DEFAULT_CODE_LANGUAGE

Const DEFAULT_CODE_LANGUAGE: "javascript"

Defined in

packages/lexical-code/src/CodeHighlightNode.ts:35


PrismTokenizer

Const PrismTokenizer: Tokenizer

Defined in

packages/lexical-code/src/CodeHighlighter.ts:69

Functions

$createCodeHighlightNode

$createCodeHighlightNode(text, highlightType?): CodeHighlightNode

Parameters

NameType
textstring
highlightType?null | string

Returns

CodeHighlightNode

Defined in

packages/lexical-code/src/CodeHighlightNode.ts:214


$createCodeNode

$createCodeNode(language?): CodeNode

Parameters

NameType
language?null | string

Returns

CodeNode

Defined in

packages/lexical-code/src/CodeNode.ts:343


$isCodeHighlightNode

$isCodeHighlightNode(node): node is CodeHighlightNode

Parameters

NameType
nodeundefined | null | LexicalNode | CodeHighlightNode

Returns

node is CodeHighlightNode

Defined in

packages/lexical-code/src/CodeHighlightNode.ts:221


$isCodeNode

$isCodeNode(node): node is CodeNode

Parameters

NameType
nodeundefined | null | LexicalNode

Returns

node is CodeNode

Defined in

packages/lexical-code/src/CodeNode.ts:349


getCodeLanguages

getCodeLanguages(): string[]

Returns

string[]

Defined in

packages/lexical-code/src/CodeHighlightNode.ts:86


getDefaultCodeLanguage

getDefaultCodeLanguage(): string

Returns

string

Defined in

packages/lexical-code/src/CodeHighlightNode.ts:84


getEndOfCodeInLine

getEndOfCodeInLine(anchor): CodeHighlightNode | TabNode

Parameters

NameType
anchorTabNode | CodeHighlightNode

Returns

CodeHighlightNode | TabNode

Defined in

packages/lexical-code/src/CodeHighlighter.ts:193


getFirstCodeNodeOfLine

getFirstCodeNodeOfLine(anchor): null | CodeHighlightNode | TabNode | LineBreakNode

Parameters

NameType
anchorLineBreakNode | TabNode | CodeHighlightNode

Returns

null | CodeHighlightNode | TabNode | LineBreakNode

Defined in

packages/lexical-code/src/CodeHighlightNode.ts:227


getLanguageFriendlyName

getLanguageFriendlyName(lang): string

Parameters

NameType
langstring

Returns

string

Defined in

packages/lexical-code/src/CodeHighlightNode.ts:79


getLastCodeNodeOfLine

getLastCodeNodeOfLine(anchor): CodeHighlightNode | TabNode | LineBreakNode

Parameters

NameType
anchorLineBreakNode | TabNode | CodeHighlightNode

Returns

CodeHighlightNode | TabNode | LineBreakNode

Defined in

packages/lexical-code/src/CodeHighlightNode.ts:239


getStartOfCodeInLine

getStartOfCodeInLine(anchor, offset): null | { node: CodeHighlightNode | TabNode | LineBreakNode ; offset: number }

Parameters

NameType
anchorTabNode | CodeHighlightNode
offsetnumber

Returns

null | { node: CodeHighlightNode | TabNode | LineBreakNode ; offset: number }

Defined in

packages/lexical-code/src/CodeHighlighter.ts:80


normalizeCodeLang

normalizeCodeLang(lang): string

Parameters

NameType
langstring

Returns

string

Defined in

packages/lexical-code/src/CodeHighlightNode.ts:75


registerCodeHighlighting

registerCodeHighlighting(editor, tokenizer?): () => void

Parameters

NameType
editorLexicalEditor
tokenizer?Tokenizer

Returns

fn

▸ (): void

Returns

void

Defined in

packages/lexical-code/src/CodeHighlighter.ts:808