Skip to main content

Class: CodeNode

@lexical/code.CodeNode

Hierarchy

Constructors

constructor

new CodeNode(language?, key?): CodeNode

Parameters

NameType
language?null | string
key?string

Returns

CodeNode

Overrides

ElementNode.constructor

Defined in

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

Methods

canIndent

canIndent(): false

Returns

false

Overrides

ElementNode.canIndent

Defined in

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


collapseAtStart

collapseAtStart(): boolean

Returns

boolean

Overrides

ElementNode.collapseAtStart

Defined in

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


createDOM

createDOM(config): HTMLElement

Parameters

NameType
configEditorConfig

Returns

HTMLElement

Overrides

ElementNode.createDOM

Defined in

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


exportDOM

exportDOM(editor): DOMExportOutput

Parameters

NameType
editorLexicalEditor

Returns

DOMExportOutput

Overrides

ElementNode.exportDOM

Defined in

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


exportJSON

exportJSON(): SerializedCodeNode

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

SerializedCodeNode

Overrides

ElementNode.exportJSON

Defined in

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


getIsSyntaxHighlightSupported

getIsSyntaxHighlightSupported(): boolean

Returns

boolean

Defined in

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


getLanguage

getLanguage(): undefined | null | string

Returns

undefined | null | string

Defined in

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


insertNewAfter

insertNewAfter(selection, restoreSelection?): null | ParagraphNode | TabNode | CodeHighlightNode

Parameters

NameTypeDefault value
selectionRangeSelectionundefined
restoreSelectionbooleantrue

Returns

null | ParagraphNode | TabNode | CodeHighlightNode

Overrides

ElementNode.insertNewAfter

Defined in

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


setLanguage

setLanguage(language): void

Parameters

NameType
languagestring

Returns

void

Defined in

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


updateDOM

updateDOM(prevNode, dom, config): boolean

Parameters

NameType
prevNodeCodeNode
domHTMLElement
configEditorConfig

Returns

boolean

Overrides

ElementNode.updateDOM

Defined in

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


clone

clone(node): CodeNode

Parameters

NameType
nodeCodeNode

Returns

CodeNode

Overrides

ElementNode.clone

Defined in

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


getType

getType(): string

Returns

string

Overrides

ElementNode.getType

Defined in

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


importDOM

importDOM(): null | DOMConversionMap

Returns

null | DOMConversionMap

Overrides

ElementNode.importDOM

Defined in

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


importJSON

importJSON(serializedNode): CodeNode

Parameters

NameType
serializedNodeSerializedCodeNode

Returns

CodeNode

Overrides

ElementNode.importJSON

Defined in

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