import type { FormulaTextSegment } from "../hooks/features/formula/gridFormulaReferenceHighlights.js"; /** * The class on each colored reference token `` inside the formula editor. * Shared with the in-grid overlay's theming/test selector. */ export declare const FORMULA_REFERENCE_TOKEN_CLASS = "MuiDataGrid-formulaReferenceToken"; /** * The class on each muted syntax `` (operators, punctuation, the leading * `=`) inside the formula editor. Colored through CSS rather than an inline * style — unlike a reference token, there is exactly one color. */ export declare const FORMULA_SYNTAX_TOKEN_CLASS = "MuiDataGrid-formulaSyntaxToken"; /** * A character range within `root.textContent`. Collapsed (`start === end`) when it * is a plain caret. */ export interface FormulaEditorSelection { start: number; end: number; } /** * The character offset of the collapsed caret within `root.textContent`, or * `null` when there is no selection or it sits outside `root`. The editable * splits its text across one text node per segment, so the offset is the length * of all text from the start of `root` up to the caret — measured with a range * so it is correct whether the caret sits in a text node, between two ``s, * or in the empty root. */ export declare function getCaretOffset(root: HTMLElement): number | null; /** * Places the collapsed caret `offset` characters into `root.textContent`. Walks * the text nodes summing their lengths; an offset on a boundary between two * adjacent ``s lands at the end of the earlier text node (the text-node * form). An offset past the end clamps to the end of the last text node; an empty * editable places the caret in the root itself. */ export declare function setCaretOffset(root: HTMLElement, offset: number): void; /** * The character range of the current selection within `root.textContent`, or * `null` when there is no selection or it sits outside `root`. Captures both edges * so a non-collapsed selection survives a rebuild (not just the caret position). */ export declare function getSelectionOffsets(root: HTMLElement): FormulaEditorSelection | null; /** * Restores a character range within `root.textContent`. A collapsed range places a * plain caret. */ export declare function setSelectionOffsets(root: HTMLElement, selection: FormulaEditorSelection): void; /** * Strips line breaks so the editor stays single-line. Applied to typed input and * pasted text — `contenteditable` would otherwise insert `
`/`
` on Enter * and embed newlines on paste. */ export declare function normalizeSingleLine(text: string): string; /** * Scrolls the editable so the current caret is visible, on both axes. The browser * reveals the caret on its own only for native typing — a caret placed * programmatically (edit entry, a session resume after a remount, an accepted * suggestion) can land outside the visible box of a long formula that scrolls * internally: horizontally while the editor is single-line, and vertically once it * wraps and hits its line cap. Delta-based on client rects, so it is * direction-agnostic (works in RTL). A zero rect (no layout — jsdom — or an empty * editable) is left alone. */ export declare function scrollCaretIntoView(root: HTMLElement): void; /** * Imperatively rebuilds the editable's children from `segments`: a flat run of * text nodes (plain gaps), colored ``s (reference tokens) and muted * ``s (syntax runs), no block elements. The editable has no * React-controlled children, so this never fights React reconciliation (the * React-contenteditable pattern). An empty `segments` leaves the editable * empty — the caret then goes into the root via `setCaretOffset`. */ export declare function renderSegments(root: HTMLElement, segments: FormulaTextSegment[]): void;