@lexical/code-shiki
Interfaces
CodeShikiConfig
Defined in: packages/lexical-code-shiki/src/CodeHighlighterShiki.ts:441
Properties
disabled
disabled:
boolean
Defined in: packages/lexical-code-shiki/src/CodeHighlighterShiki.ts:448
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:449
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
codeNode
language?
string
Returns
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:485
Deprecated
Use CodeShikiExtension instead. This type is a flat alias for Tokenizer kept for backward compatibility with CodeHighlighterShikiExtension.
Variables
CodeHighlighterShikiExtension
constCodeHighlighterShikiExtension:LexicalExtension<Tokenizer,"@lexical/code-shiki/legacy",unknown,void>
Defined in: packages/lexical-code-shiki/src/CodeHighlighterShiki.ts:498
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
constCodeShikiExtension:LexicalExtension<CodeShikiConfig,"@lexical/code-shiki",NamedSignalsOutput<CodeShikiConfig>,unknown>
Defined in: packages/lexical-code-shiki/src/CodeHighlighterShiki.ts:461
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
constShikiTokenizer: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:137
Returns
[string, string][]
getCodeThemeOptions()
getCodeThemeOptions(): [
string,string][]
Defined in: packages/lexical-code-shiki/src/FacadeShiki.ts:140
Returns
[string, string][]
isCodeLanguageLoaded()
isCodeLanguageLoaded(
language):boolean
Defined in: packages/lexical-code-shiki/src/FacadeShiki.ts:43
Parameters
language
string
Returns
boolean
loadCodeLanguage()
loadCodeLanguage(
language,editor?,codeNodeKey?):Promise<void> |undefined
Defined in: packages/lexical-code-shiki/src/FacadeShiki.ts:69
Loads a syntax highlighting grammar for the given language via Shiki. If the language is already loaded or is not supported, the call is a no-op.
When both editor and codeNodeKey are passed, the corresponding
CodeNode is updated to enable syntax highlighting once the
language becomes available
Parameters
language
string
language identifier (e.g. "typescript", "diff-js")
editor?
Lexical editor instance to update after the language loads.
codeNodeKey?
string
Key of the CodeNode to mark as syntax-highlight-supported.
Returns
Promise<void> | undefined
A Promise that resolves when the language is ready,
or undefined if the language was already loaded or is not supported.
loadCodeTheme()
loadCodeTheme(
theme,editor?,codeNodeKey?):Promise<void> |undefined
Defined in: packages/lexical-code-shiki/src/FacadeShiki.ts:115
Parameters
theme
string
editor?
codeNodeKey?
string
Returns
Promise<void> | undefined
normalizeCodeLanguage()
normalizeCodeLanguage(
language):string
Defined in: packages/lexical-code-shiki/src/FacadeShiki.ts:144
Parameters
language
string
Returns
string
registerCodeHighlighting()
registerCodeHighlighting(
editor,tokenizer?): () =>void
Defined in: packages/lexical-code-shiki/src/CodeHighlighterShiki.ts:426
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
tokenizer?
Tokenizer = ShikiTokenizer
Returns
() => void