/** * Rich text in a cell — different fonts on different parts of the same value. * * Typical flow: set the cell text, create a font with {@link Workbook.createFont}, * then apply it to a character span with * `cell.richText.characters(start, end).font = font`. * * Character indices are inclusive and 0-based. There is no public `setFont`; * assign through the `characters(...).font` property. * * Citations: * - `docs/api/RICH-TEXT-PROPOSAL.md` * - `docs/specs/rich-text.md` * - ECMA-376-1 §18.4; transitional `sml.xsd` `CT_RElt` / `CT_RPrElt` */ import { RichTextRun } from '../shared-strings/rich-text-xml'; import { Color as ColorValue, Font as FontInput, FontSchemeValue, UnderlineValue } from '../styles/styles-xml'; /** * Font settings for a span of rich text in a cell (typeface, size, bold, color, and so on). * * Create with {@link Workbook.createFont}, set the properties you need, then assign * the font to a character range. The assignment copies the current values; changing * this object later does not update text that already received the font. * * This is independent of the workbook styles table — it does not create a shared style font. */ export declare class Font { /** Font family name, such as `"Calibri"` or `"Arial"`. */ name: string | undefined; /** Font size in points. */ size: number | undefined; /** Whether the text is bold. */ bold: boolean | undefined; /** Whether the text is italic. */ italic: boolean | undefined; /** Underline style, or `true`/`false` for a simple underline on/off. */ underline: UnderlineValue | boolean | undefined; /** Whether the text is struck through. */ strike: boolean | undefined; /** Text color. */ color: ColorValue | undefined; /** Font family class used by Excel (optional advanced setting). */ family: number | undefined; /** Character set used by Excel (optional advanced setting). */ charset: number | undefined; /** Theme font scheme, when the run follows a theme font. */ scheme: FontSchemeValue | undefined; /** Superscript, subscript, or baseline vertical alignment. */ vertAlign: string | undefined; /** Whether outline (hollow) text is drawn. */ outline: boolean | undefined; /** Whether a shadow effect is applied. */ shadow: boolean | undefined; /** Whether condensed spacing is applied. */ condense: boolean | undefined; /** Whether extended spacing is applied. */ extend: boolean | undefined; /** * Snapshot current fields as a plain {@link FontInput}. * * @private */ toFontInput(): FontInput; /** * Populate fields from a {@link FontInput} snapshot. * * @private */ copyFromInput(input: FontInput | undefined): void; } /** * Host callbacks from {@link Cell} into worksheet SST / model. * * @private */ export interface RichTextCellHost { getPlainText(): string; getRuns(): RichTextRun[]; commitRuns(runs: ReadonlyArray): void; hasRichFormatting(): boolean; } /** * Rich text for one cell: the full string plus character ranges you can format. * * Obtained from {@link Cell.richText}. Use {@link text} for the whole value and * {@link characters} to bold, color, or otherwise style part of it. */ export declare class RichTextString { private readonly host; /** * @private */ constructor(host: RichTextCellHost); /** * The full cell text as plain characters (formatting ignored when reading). * * Setting replaces the entire value with one unformatted run, or clears it when empty. */ text: string; /** * Select a stretch of characters so you can read or set their font. * * Indices are 0-based and inclusive on both ends (for example, `characters(0, 2)` * covers the first three characters). * * @param start - First character index (inclusive). * @param end - Last character index (inclusive). * @returns A handle whose {@link RichTextCharacters.font} property gets or sets formatting. * @throws {@link InvalidArgumentError} when indices are invalid, `start` is greater than * `end`, the range is outside the text, or the cell text is empty. */ characters(start: number, end: number): RichTextCharacters; /** * Structured runs (snapshot). Prefer {@link characters} for mutation. * * @private */ getRuns(): RichTextRun[]; } /** * A selected range of characters inside a cell's rich text. * * Returned by {@link RichTextString.characters}. Assign {@link font} to format the span. */ export declare class RichTextCharacters { private readonly host; private readonly start; private readonly end; /** * @private */ constructor(host: RichTextCellHost, start: number, end: number); /** * Font applied to this character range. * * **Get:** returns a new {@link Font} for the first character in the range. If the * range mixes several fonts, only the first character's formatting is shown. * **Set:** copies the assigned {@link Font} (or plain font fields) onto every * character in the range and commits coalesced runs to the cell. */ font: Font | FontInput | undefined; } /** * True when runs carry any explicit character formatting. * * @private */ export declare function richRunsIndicateRichText(runs: ReadonlyArray): boolean; /** * Coalesce helper re-export for cell host. * * @private */ export declare function normalizeRichRuns(runs: ReadonlyArray): RichTextRun[];