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

Images in tables are droped and generate an invalid block #8

Closed mcasagrande18 closed 9 months ago

mcasagrande18 commented 2 years ago

When i convert a table with images inside the images are droped and is generated an invalid Slate block

Request:

curl -i -X POST http://localhost:5000/html -H "Accept: application/json" -H "Content-Type: application/json" --data-raw '{"html": "<table class=\"plain\"><tbody><tr><td><img alt=\"Punti di misura PM10\" class=\"image-inline\" height=\"347\" src=\"resolveuid/8a30d0c500e1524ddecbd4ea46f20a03\" width=\"333\" /><br /></td><td><p><img alt=\"Punti di misura PM2.5\" class=\"image-inline\" height=\"349\" src=\"resolveuid/787e747ce1c3d2cd7c2ecfcce5535021\" width=\"332\" /></p></td></tr></tbody></table>"}'

Response:

{
  "data": [
    {
      "@type": "slateTable",
      "table": {
        "basic": false,
        "celled": true,
        "compact": false,
        "fixed": true,
        "inverted": false,
        "rows": [
          {
            "cells": [
              {
                "key": "77mhv",
                "type": "data",
                "value": [
                  [],
                  {
                    "type": "p",
                    "children": [
                      {
                        "text": "\n"
                      }
                    ]
                  }
                ]
              },
              {
                "key": "3nkfj",
                "type": "data",
                "value": [
                  {
                    "type": "p",
                    "children": [
                      {
                        "text": ""
                      }
                    ]
                  }
                ]
              }
            ]
          }
        ],
        "striped": false
      }
    }
  ]
}

The value of cell 77mhv is invalid:

{
...
  "key": "77mhv",
  "type": "data",
  "value": [
    [],
    {
      "type": "p",
      "children": [
        {
          "text": "\n"
        }
      ]
    }
  ]
...
}

Error: react-beautiful-dnd.esm.js:158 Uncaught Error: [Slate] value is invalid! Expected a list of elementsbut got: [[],{"children":[{"text":"\n"}],"type":"p"}]

davisagli commented 9 months ago

This was fixed at some point; I just tested and the current result is:

{"data":[{"@type":"image","url":"resolveuid/8a30d0c500e1524ddecbd4ea46f20a03","alt":"Punti di misura PM10","title":"","align":"center","size":"l"},{"@type":"image","url":"resolveuid/787e747ce1c3d2cd7c2ecfcce5535021","alt":"Punti di misura PM2.5","title":"","align":"center","size":"l"}]}