plone / blocks-conversion-tool

A tool to convert HTML (as used in Plone Classic) to Blocks (as used on Volto)
7 stars 5 forks source link

Error when Editing Converted Empty `<b></b>` Tags in Volto #30

Closed shogunbr closed 1 year ago

shogunbr commented 1 year ago

When converting an HTML that contains an empty <b></b> tag into Slate format, like this: <p>foo<b></b></p> It generates the following JSON structure:

{
  "data": [
    {
      "@type": "slate",
      "value": [
        {
          "type": "p",
          "children": [
            {
              "text": "foo"
            },
            {
              "type": "strong",
              "children": []
            }
          ]
        }
      ],
      "plaintext": "foo"
    }
  ]
}

While it is displayed correctly in Volto, attempting to edit it triggers an error:

Sorry, something went wrong with your request 
Cannot get the end point in the node at path [0] because it has no end text node.

However, this issue does not occur when converting an empty <strong></strong> tag. <p>foo<strong></strong></p> The corresponding JSON structure for that case includes an empty text node within the <strong> tag:

{
  "data": [
    {
      "@type": "slate",
      "value": [
        {
          "type": "p",
          "children": [
            {
              "text": "foo"
            },
            {
              "type": "strong",
              "children": [
                {
                  "text": ""
                }
              ]
            }
          ]
        }
      ],
      "plaintext": "foo"
    }
  ]
}

Please note that the issue occurs specifically with the empty <b></b> tag and not with the empty <strong></strong> tag.