bitcrowd / tickety-tick

A browser extension that helps you name branches and write better commit messages
MIT License
57 stars 10 forks source link

Error: unsupported node type "expand" #348

Closed agatheblues closed 1 year ago

agatheblues commented 1 year ago

💥 The extension is broken when the jira ticket description contains "expand" blocks:

image

Tickety-Tick revision: 8714b5142d40c0c2d5f2a51bf867f2702463ed25

Error: unsupported node type "expand"
k@moz-extension://62840645-b92c-7f48-b68c-d0a2ba9de16f/content.js:2:16432
C@moz-extension://62840645-b92c-7f48-b68c-d0a2ba9de16f/content.js:2:16486
F@moz-extension://62840645-b92c-7f48-b68c-d0a2ba9de16f/content.js:2:16731
yt</o<@moz-extension://62840645-b92c-7f48-b68c-d0a2ba9de16f/content.js:2:56500
yt<@moz-extension://62840645-b92c-7f48-b68c-d0a2ba9de16f/content.js:2:56587

Happened on Firefox 103.0

pmeinhardt commented 1 year ago

This’ll require an update to https://github.com/bitcrowd/mdast-util-from-adf, adding support for this node type (as suggested in the error message). I didn’t know expand nodes were a thing in Jira tickets before. 💡

I am still on a bike trip, away from my computer, so I won’t be fixing this before I get back home in about 2 weeks maybe. I am hoping the pointer might help you out though. ❤️

Feel free to @mention or otherwise ping me if I can be of further assistance in the meantime. 🏓

Kind greetings 👋

pmeinhardt commented 1 year ago

Here's an example document you can throw at Atlassian's document viewer:

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

I derived the structure and required attributes from the current (v24.0.0) ADF JSON schema.

The Atlassian viewer renders this with a toggle <button> expanding/collapsing an associated <div>. A more semantically sound approach might convert this to <details> and <summary> nodes which GitHub can render as well.

Example:

<details>
<summary>Summary</summary>
Expanded content…
</details>

Rendered example:

Summary Expanded content…
pmeinhardt commented 1 year ago

I'll take a look at updating the mdast-util-from-adf package. ✌️

klappradla commented 1 year ago

Seems like the package where mdast-util-from-adf gets its definitions from also has recent updates: https://www.npmjs.com/package/@atlaskit/adf-schema

I cannot reach their bitbucket repository though 🙈

pmeinhardt commented 1 year ago

Seems like the package where mdast-util-from-adf gets its definitions from also has recent updates: https://www.npmjs.com/package/@atlaskit/adf-schema

I cannot reach their bitbucket repository though 🙈

You can browse the source (including a changelog) here: https://unpkg.com/browse/@atlaskit/adf-schema@24.0.1/

(A rather long) PS: Sorry, I did not find enough time and motivation yet to update mdast-util-from-adf. I've investigated though and after jotting down my findings I am thinking we might just not represent expand nodes in the conversion output. Any expand's child nodes will still be converted, but the expand itself would not have any counterpart in the MDAST tree. This would fix this issue here and could be iterated on later if ever needed. Happy about comments & thoughts. ❤️

klappradla commented 1 year ago

No worries @pmeinhardt 🤗

As the adapter is also broken for Jira server instances (see #349), my current plan of attack would be to release a "fix" version which does not include ADF to .md and then release a "fix all Jiras" later. Asking users to go back to previous versions is a bit too much with browser extensions 😉