/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * */ import { CodeNode } from '@lexical/code-core'; import { type LexicalEditor, type LexicalNode } from 'lexical'; export interface Tokenizer { /** * Language to fall back to when a {@link 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. */ defaultLanguage: string | null; defaultTheme: string; $tokenize: (this: Tokenizer, codeNode: CodeNode, language?: string) => LexicalNode[]; } export declare const ShikiTokenizer: Tokenizer; /** * @internal * Register only the Shiki highlighting transforms and the gutter * mutation listener. No keyboard / indent handlers — those are the * responsibility of * {@link "@lexical/code-core".registerCodeIndentation} / * {@link "@lexical/code-core".CodeIndentExtension}. * * Used by {@link CodeShikiExtension}, whose `CodeIndentExtension` * dependency handles the indent side. The legacy * {@link registerCodeHighlighting} wrapper combines this helper with * `registerCodeIndentation` for direct callers that want the original * single-call setup. * * Exported for use by the package's own unit tests; not re-exported * from the package entry point. */ export declare function registerHighlightingOnly(editor: LexicalEditor, tokenizer: Tokenizer): () => void; /** * 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 * {@link CodeShikiExtension}. */ export declare function registerCodeHighlighting(editor: LexicalEditor, tokenizer?: Tokenizer): () => void; export interface CodeShikiConfig { /** * 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. */ disabled: boolean; tokenizer: Tokenizer; } /** * Add code highlighting support for code blocks with Shiki. * * {@link CodeExtension} is a dependency, so the required `CodeNode` and * `CodeHighlightNode` nodes are registered automatically. * {@link 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. */ export declare const CodeShikiExtension: import("lexical").LexicalExtension, unknown>; /** * @deprecated Use {@link CodeShikiExtension} instead. This type is a * flat alias for {@link Tokenizer} kept for backward compatibility with * {@link CodeHighlighterShikiExtension}. */ export type CodeHighlighterShikiConfig = Tokenizer; /** * @deprecated Use {@link CodeShikiExtension} instead. * * This is a thin backward-compatibility shim that preserves the original * flat {@link Tokenizer} config API. It depends on * {@link 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. */ export declare const CodeHighlighterShikiExtension: import("lexical").LexicalExtension;