Skip to main content

@lexical/code-shiki

Interfaces

CodeShikiConfig

Defined in: packages/lexical-code-shiki/src/CodeHighlighterShiki.ts:415

Properties

disabled

disabled: boolean

Defined in: packages/lexical-code-shiki/src/CodeHighlighterShiki.ts:422

When true, the Shiki code highlighter is not registered on the editor. This signal can be flipped at runtime to enable or disable the highlighter, for example to switch between the Prism and Shiki highlighters without rebuilding the editor.

tokenizer

tokenizer: Tokenizer

Defined in: packages/lexical-code-shiki/src/CodeHighlighterShiki.ts:423


Tokenizer

Defined in: packages/lexical-code-shiki/src/CodeHighlighterShiki.ts:45

Properties

$tokenize

$tokenize: (this, codeNode, language?) => LexicalNode[]

Defined in: packages/lexical-code-shiki/src/CodeHighlighterShiki.ts:48

Parameters
this

Tokenizer

codeNode

CodeNode

language?

string

Returns

LexicalNode[]

defaultLanguage

defaultLanguage: string

Defined in: packages/lexical-code-shiki/src/CodeHighlighterShiki.ts:46

defaultTheme

defaultTheme: string

Defined in: packages/lexical-code-shiki/src/CodeHighlighterShiki.ts:47

Type Aliases

CodeHighlighterShikiConfig

CodeHighlighterShikiConfig = Tokenizer

Defined in: packages/lexical-code-shiki/src/CodeHighlighterShiki.ts:459

Deprecated

Use CodeShikiExtension instead. This type is a flat alias for Tokenizer kept for backward compatibility with CodeHighlighterShikiExtension.

Variables

CodeHighlighterShikiExtension

const CodeHighlighterShikiExtension: LexicalExtension<Tokenizer, "@lexical/code-shiki/legacy", unknown, void>

Defined in: packages/lexical-code-shiki/src/CodeHighlighterShiki.ts:472

Deprecated

Use CodeShikiExtension instead.

This is a thin backward-compatibility shim that preserves the original flat Tokenizer config API. It depends on CodeShikiExtension and routes its configured tokenizer to the underlying extension during init (before CodeShikiExtension builds), so consumers using configExtension(CodeHighlighterShikiExtension, customTokenizer) continue to work without modification.


CodeShikiExtension

const CodeShikiExtension: LexicalExtension<CodeShikiConfig, "@lexical/code-shiki", NamedSignalsOutput<CodeShikiConfig>, unknown>

Defined in: packages/lexical-code-shiki/src/CodeHighlighterShiki.ts:435

Add code highlighting support for code blocks with Shiki.

CodeExtension is a dependency, so the required CodeNode and CodeHighlightNode nodes are registered automatically. CodeIndentExtension is also a dependency, so Tab / Shift+Tab and the related keyboard handlers are activated automatically. Set tabSize on CodeIndentExtension to enable space-indent outdent.


ShikiTokenizer

const ShikiTokenizer: Tokenizer

Defined in: packages/lexical-code-shiki/src/CodeHighlighterShiki.ts:57

Functions

getCodeLanguageOptions()

getCodeLanguageOptions(): [string, string][]

Defined in: packages/lexical-code-shiki/src/FacadeShiki.ts:119

Returns

[string, string][]


getCodeThemeOptions()

getCodeThemeOptions(): [string, string][]

Defined in: packages/lexical-code-shiki/src/FacadeShiki.ts:122

Returns

[string, string][]


isCodeLanguageLoaded()

isCodeLanguageLoaded(language): boolean

Defined in: packages/lexical-code-shiki/src/FacadeShiki.ts:38

Parameters

language

string

Returns

boolean


loadCodeLanguage()

loadCodeLanguage(language, editor?, codeNodeKey?): Promise<void> | undefined

Defined in: packages/lexical-code-shiki/src/FacadeShiki.ts:51

Parameters

language

string

editor?

LexicalEditor

codeNodeKey?

string

Returns

Promise<void> | undefined


loadCodeTheme()

loadCodeTheme(theme, editor?, codeNodeKey?): Promise<void> | undefined

Defined in: packages/lexical-code-shiki/src/FacadeShiki.ts:97

Parameters

theme

string

editor?

LexicalEditor

codeNodeKey?

string

Returns

Promise<void> | undefined


normalizeCodeLanguage()

normalizeCodeLanguage(language): string

Defined in: packages/lexical-code-shiki/src/FacadeShiki.ts:126

Parameters

language

string

Returns

string


registerCodeHighlighting()

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

Defined in: packages/lexical-code-shiki/src/CodeHighlighterShiki.ts:400

Register the Shiki tokenizer-driven highlighting on the editor along with the indent / Tab / arrow-key keyboard handlers. This function is provided for legacy code that has not upgraded to using CodeShikiExtension.

Parameters

editor

LexicalEditor

tokenizer?

Tokenizer = ShikiTokenizer

Returns

() => void