RTD JSON format

This document describes the JSON format available through the OpenAPI and through the WebHare TypeScript APIs.

Build format

WebHare has an 'in-memory' and a 'build' format for Rich documents. In TypeScript these correspond to RTDBlock[] and RTDSource in jssdk/services/src/richdocument.ts.

The 'in-memory' format is a stricter, unambiguous format that corresponds to the minimal HTML syntax used interaly. The 'build' format offers shorter notation of various structures and is designed for use as an input format when manually building RTDs (especially in YAML). The build format is converted to the in-memory format when storing RTDs.

Eg the build format in YAML would support:

- h1: My heading
- p: A simple paragraph
- p:
  - "Click "
  - text: this link
    link:
      externalLink: "https://beta.webhare.net/" 

Where the corresponding in-memory format would be

[
  {
    "tag": "h1",
    "items": [
      {
        "text": "My heading"
      }
    ]
  },
  {
    "tag": "p",
    "items": [
      {
        "text": "A simple paragraph"
      }
    ]
  },
  {
    "tag": "p",
    "items": [
      {
        "text": "Click "
      },
      {
        "text": "this link",
        "link": {
          "_internal": null,
          "_external": "https://beta.webhare.net/",
          "_append": null
        }
      }
    ]
  }

RTD structure:

A RTD consists of an array of blocks. Each block is either a:

A paragraph consists of a tag (p, h1, h2...), an optional className and inline items:

  {
    "tag": "p",
    "className": "centered",
    "items": [
      {
        "text": "My heading"
      }
    ]
  }

Inline items themselves are an array consisting of either a

Each array element can have these textstyle properties. If present, they should be true. If not set, leave them out:

Each array element can additionaly have these link properties:

link should either be of the format: