Skip to main content

@lexical/code-shiki

Interfaces​

CodeShikiConfig​

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

Properties​

disabled​

disabled: boolean

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

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:441


Tokenizer​

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

Properties​

$tokenize​

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

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

Parameters​
this​

Tokenizer

codeNode​

CodeNode

language?​

string

Returns​

LexicalNode[]

defaultLanguage​

defaultLanguage: string | null

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

Language to fall back to when a CodeNode doesn't carry one. Set to null to opt out of the implicit fallback — code blocks without a language stay untouched (no data-language attribute, no syntax highlighting) so a markdown round-trip can preserve ``` with no info string.

defaultTheme​

defaultTheme: string

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

Type Aliases​

CodeHighlighterShikiConfig​

CodeHighlighterShikiConfig = Tokenizer

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

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:490

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:453

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:65

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:418

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