/** * 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 { CodeHighlightNode } from './CodeHighlightNode'; import type { LexicalNode, LineBreakNode, RangeSelection, TabNode } from 'lexical'; export declare function $getFirstCodeNodeOfLine(anchor: CodeHighlightNode | TabNode | LineBreakNode): CodeHighlightNode | TabNode | LineBreakNode; export declare function $getLastCodeNodeOfLine(anchor: CodeHighlightNode | TabNode | LineBreakNode): CodeHighlightNode | TabNode | LineBreakNode; /** * Determines the visual writing direction of a code line. * * Scans the line segments (CodeHighlightNode/TabNode) from start to end * and returns the first strong direction found ("ltr" or "rtl"). * If no strong character is found, falls back to the parent element's * direction. Returns null if indeterminate. */ export declare function $getCodeLineDirection(anchor: CodeHighlightNode | TabNode | LineBreakNode): 'ltr' | 'rtl' | null; export declare function $getStartOfCodeInLine(anchor: CodeHighlightNode | TabNode, offset: number): null | { node: CodeHighlightNode | TabNode | LineBreakNode; offset: number; }; export declare function $getEndOfCodeInLine(anchor: CodeHighlightNode | TabNode): CodeHighlightNode | TabNode; /** * Plain split of code text into CodeHighlightNodes (with no highlight * type) + LineBreakNodes + TabNodes. Used when the tokenizer opts out * of a default language so a previously highlighted block still * renders its `\n` / `\t` as real line breaks / tabs, while staying * compatible with the indent / shift-lines handlers that only accept * CodeHighlightNode + TabNode + LineBreakNode inside a CodeNode. */ export declare function $plainifyCodeContent(text: string): LexicalNode[]; /** * Strip up to `tabSize` leading spaces from a {@link CodeHighlightNode} that * starts a code line, to support outdenting space-indented code lines (e.g. * code formatted with prettier). Returns true if any spaces were stripped. * * Best-effort: a line with fewer than `tabSize` leading spaces has all of * them stripped, matching VS Code / IntelliJ behavior. * * Selection is preserved relative to line content. Anchor/focus offsets * pointing into `node` shift left by the number of stripped characters * (clamped to 0). The underlying TextNode mutation does not adjust * selection offsets that already point into the old text, so we patch * them up explicitly. */ export declare function $outdentLeadingSpaces(node: CodeHighlightNode, tabSize: number, selection: RangeSelection): boolean;