UNPKG

@mui/internal-docs-infra

Version:

MUI Infra - internal documentation creation tools.

38 lines 1.89 kB
/** * Per-line leading-whitespace utilities. Useful when copying text out * of a region whose first `N` columns are visually clipped (an indent * gutter, a line-number column, etc.) so the clipboard payload matches * what the user sees rather than including the hidden prefix. * * Each helper takes two budgets: * * - `firstLineCount` — the budget for the first line. Typically * `max(0, gutterWidth - selectionStartColumn)` so a selection that * begins mid-gutter only loses the gutter portion still inside the * selection. * - `restCount` — the budget for every line after a `\n`, normally the * full gutter width. */ /** * Strip leading whitespace per line from a plain-text string. Returns * the trimmed text. Up to `firstLineCount` characters of leading space * or tab are removed from the first line, and up to `restCount` from * every line after a `\n`. */ export declare const stripLeadingPerLine: (text: string, firstLineCount: number, restCount: number) => string; /** * Mirror of `stripLeadingPerLine` that returns *what was stripped* per * line, joined with `\n`. Useful for "lossless cut": the clipboard * payload omits the clipped prefix, but the underlying document keeps * it by re-inserting the extracted prefix string at the selection * location. */ export declare const extractLeadingPerLine: (text: string, firstLineCount: number, restCount: number) => string; /** * DOM-aware variant of `stripLeadingPerLine`: walks every text node * under `root` in document order and removes leading whitespace at the * start of each logical line. The budget refills to `restCount` after * every `\n` and is consumed across consecutive text nodes, so indent * nested inside multiple wrapper spans is still removed correctly. */ export declare const stripLeadingPerLineDom: (root: Node, firstLineCount: number, restCount: number) => void;