Rich Text
model
Domain types, constants, and suit utilities.
The model barrel exports the canonical RichText domain types used across the application. These are the types stored in the database -- editor-specific formats (Plate/Slate) are internal implementation details.
import type { RichText, LocalizedRichText, Suit } from '@workspace/rich-text/model';
import { EMPTY_RICH_TEXT, SUITS, SUIT_TO_GLYPH } from '@workspace/rich-text/model';Types
RichText
The root type: an array of block nodes.
type RichText = RichBlockNode[];
type RichBlockNode = RichParagraphNode | RichListNode;Block Nodes
type RichParagraphNode = {
type: 'paragraph';
children: RichInlineNode[];
};
type RichListNode = {
type: 'list';
ordered: boolean;
children: RichListItemNode[];
};
type RichListItemNode = {
type: 'list-item';
children: RichInlineNode[];
};Inline Nodes
type RichInlineNode = RichTextNode | RichSuitNode;
type RichTextNode = {
type: 'text';
text: string;
bold?: boolean;
italic?: boolean;
};
type RichSuitNode = {
type: 'suit';
suit: Suit;
bold?: boolean;
italic?: boolean;
};
type Suit = 'S' | 'H' | 'D' | 'C';LocalizedRichText
type LocalizedRichText = Record<string, RichText>;
// e.g. { en: [...], fr: [...] }Constants
| Export | Type | Value |
|---|---|---|
EMPTY_RICH_TEXT | RichText | [] |
LINE_SEPARATOR | string | '\n' |
SUITS | Suit[] | ['S', 'H', 'D', 'C'] |
Suit Utilities
| Export | Type | Description |
|---|---|---|
SUIT_TO_GLYPH | Record<Suit, string> | { S: '\u2660', H: '\u2665', D: '\u2666', C: '\u2663' } |
GLYPH_TO_SUIT | Record<string, Suit> | Reverse mapping |
isSuitCode(s) | (s: string) => s is Suit | Type guard |