/** * 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 type { LexicalEditor } from 'lexical'; /** * @internal * Register the keyboard and command handlers that drive code-block * indentation: Tab / Shift+Tab, INDENT/OUTDENT_CONTENT_COMMAND, * INSERT_TAB_COMMAND, alt+arrow line shifting, and Home/End movement. * * Both `@lexical/code-shiki` and `@lexical/code-prism` use this via * {@link CodeIndentExtension}; callers using `registerCodeHighlighting` * will implicitly call this with tabSize of `undefined`. * * @param editor The editor to register on. * @param tabSize When set, OUTDENT_CONTENT_COMMAND (Shift+Tab) also strips * up to that many leading spaces from a code line. See * {@link $outdentLeadingSpaces}. */ export declare function registerCodeIndentation(editor: LexicalEditor, tabSize?: number, escapeWithArrows?: boolean): () => void; export interface CodeIndentConfig { /** * When true, the indent commands are not registered on the editor. * This signal can be flipped at runtime to enable or disable indent * handling without rebuilding the editor. */ disabled: boolean; /** * When set, treats that many leading spaces on a code line as one indent * level for the OUTDENT_CONTENT_COMMAND (Shift+Tab). See * {@link registerCodeIndentation}. When undefined (the default), only * TabNode removal is supported on outdent. * * Tab and INSERT_TAB_COMMAND continue to insert a TabNode regardless of * this option. */ tabSize: number | undefined; /** * When `true`, this enables the ability to exit a code block * that has no adjacent elements using the ArrowLeft/ArrowUp keys * if the cursor is at the beginning, or the ArrowRight/ArrowDown keys * if the cursor is at the end. * When `false` (default), pressing the arrow keys will not move the cursor * if there are no adjacent elements around the code block */ escapeWithArrows: boolean; } /** * Adds keyboard-driven indentation to code blocks (Tab / Shift+Tab, * alt+arrow line shifts, Home/End within a line). Both * {@link "@lexical/code-shiki".CodeShikiExtension} and * {@link "@lexical/code-prism".CodePrismExtension} declare this as a * dependency, so it is activated automatically alongside either * highlighter. * * Code blocks without syntax highlighting can use this extension on its * own. */ export declare const CodeIndentExtension: import("lexical").LexicalExtension, unknown>;