Bridge Training
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

ExportTypeValue
EMPTY_RICH_TEXTRichText[]
LINE_SEPARATORstring'\n'
SUITSSuit[]['S', 'H', 'D', 'C']

Suit Utilities

ExportTypeDescription
SUIT_TO_GLYPHRecord<Suit, string>{ S: '\u2660', H: '\u2665', D: '\u2666', C: '\u2663' }
GLYPH_TO_SUITRecord<string, Suit>Reverse mapping
isSuitCode(s)(s: string) => s is SuitType guard

On this page