Rich text formatting
Per-segment formatting inside a single cell — bold, italic, underline, strikethrough, color, font family, font size — plus `@mention` chips.
Storage model
// libs/spreadsheet-state/types.ts
export type RichSharedString = {
text: string;
runs: TextFormatRun[];
};
export type SharedStringValue = string | RichSharedString;
export type SharedStrings = Map<string, SharedStringValue>;TextFormatRun
// libs/common-types/index.ts
export type TextFormatRun<
Format extends TextFormat = TextFormat,
M extends Mention = Mention,
> =
| {
startIndex: number;
endIndex: number;
format: Format;
nodeType: "text";
}
| {
startIndex: number;
endIndex: number;
nodeType: "mention";
mention: M;
};
export type TextFormat = {
color?: Color | string;
fontFamily?: string;
fontSize?: number;
bold?: boolean;
italic?: boolean;
strikethrough?: boolean;
underline?: boolean;
vertAlign?: "superscript" | "subscript";
};Rendering rich text
Editing rich text
Shortcut
Effect
XLSX round-trip
Caveats
Last updated