Roundtrip parse and encode for JSON ADF and WikiMarkupTransformer for all types

I would like to:

  1. Retrieve a description from Jira REST API v3.
  2. Convert ADF JSON to Wiki Markup.
  3. Make edits to the description.
  4. Convert Wiki Markup back to ADF JSON.
  5. Save the edited description using the API.

The process successfully handles most editor control types. However, there is an issue with certain types such as “expand,” “date,” and “status” where they are transformed into text instead of the correct type during the conversion from Wiki Markup to JSON.

Example:

API returns:

{
      "version": 1,
      "type": "doc",
      "content": [
        {
          "type": "expand",
          "attrs": {
            "title": "Expand title"
          },
          "content": [
            {
              "type": "paragraph",
              "content": [
                {
                  "type": "text",
                  "text": "Expand content"
                }
              ]
            }
          ]
        }
      ]
    }

Transforms to Wiki Markup using code:

  const jsonTransformer = new JSONTransformer();
  const transformer = new WikiMarkupTransformer(defaultSchema);
  return transformer.encode(jsonTransformer.parse(description));

Returns:

*Expand title*

Expand content

After reverse transformation:

  const jsonTransformer = new JSONTransformer();
  const transformer = new WikiMarkupTransformer(defaultSchema);
  return jsonTransformer.encode(transformer.parse(description));

Returns:

{
  "content": [
    {
      "content": [
        {
          "marks": [
            {
              "type": "strong"
            }
          ],
          "text": "Expand title",
          "type": "text"
        }
      ],
      "type": "paragraph"
    },
    {
      "content": [
        {
          "text": "Expand content",
          "type": "text"
        }
      ],
      "type": "paragraph"
    }
  ],
  "type": "doc",
  "version": 1
}

So that “expand” doesn’t work after editing.

Is it possible to fix that?