RichTextContainer.fromJson constructor

RichTextContainer.fromJson(
  1. JSONMap json
)

Implementation

factory RichTextContainer.fromJson(JSONMap json) {
  final type = json["type"];
  return switch (type) {
    "paragraph" => RichTextContainerParagraph.fromJson(json),
    "heading" => RichTextContainerHeading.fromJson(json),
    "blockquote" => RichTextContainerQuote.fromJson(json),
    "code_block" => RichTextContainerCode.fromJson(json),
    "horizontal_rule" => RichTextContainerLine(),
    "bullet_list" => RichTextContainerList.fromJson(json, isOrdered: false),
    "ordered_list" => RichTextContainerList.fromJson(json, isOrdered: true),
    "blok" => RichTextContainerBlok.fromJson(json),
    _ => UnrecognizedRichTextContainer(type, json),
  };
}