Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversion creates broken tables #31

Closed
pbauer opened this issue Jul 3, 2023 · 2 comments · Fixed by #32
Closed

Conversion creates broken tables #31

pbauer opened this issue Jul 3, 2023 · 2 comments · Fixed by #32

Comments

@pbauer
Copy link
Member

pbauer commented Jul 3, 2023

Converting tables with bold text or with line-breaks creates tables that look ok but cannot be edited.

<table class="plain">
  <tbody>
    <tr><td><b>Text1</b></td></tr>
  </tbody>
</table>

creates

{
  '@type': 'slateTable',
  table: {
    basic: false,
    celled: true,
    compact: false,
    fixed: true,
    inverted: false,
    rows: [
      {
        key: '82dl4',
        cells: [
          {
            key: 'd74tq',
            type: 'data',
            value: [
              { type: 'strong', children: [ { text: 'Text1' } ] }
            ]
          }
        ]
      }
    ],
    striped: false
  }
}

This cell renders ok and seems editable because you can click in it but on entering any character it is emptied.

<table class="plain">
  <tbody>
    <tr><td><br/>Text</td></tr>
  </tbody>
</table>
{
  '@type': 'slateTable',
  table: {
    basic: false,
    celled: true,
    compact: false,
    fixed: true,
    inverted: false,
    rows: [
      {
        key: '7c9fn',
        cells: [
          {
            key: 'lkg0',
            type: 'data',
            value: [ { text: '\nText' } ]
          }
        ]
      }
    ],
    striped: false
  }
}

This cell renders ok but upon clicking in it when editing it throws: this.props.value[0].children is undefined

@pbauer
Copy link
Member Author

pbauer commented Jul 3, 2023

The values are miss-formed. When I create the same manually the correct values seems to be:

For the first case the p around the strong is missing:

'value': [
{
 'type': 'p',
 'children': [
  {
   'type': 'strong',
   'children': [
    {
     'text': 'Text'
    }
   ]
  }
 ]

The second is only data instead of a p with children:

'value': [
{
 'type': 'p',
 'children': [
  {
   'text': ''
  }
 ]
},
{
 'type': 'p',
 'children': [
  {
   'text': 'Text'
  }
 ]
}
]

@pbauer
Copy link
Member Author

pbauer commented Jul 3, 2023

Here is a complete config with 2 broken and 2 ok tables prepared to be manually pasted into the respective schema-fields:

blocks:

{
 "6069c003-923f-49a4-a947-46709dd612e1": {
  "@type": "title"
 },
 "d8e990c6-05f9-4b64-a398-e08e33e726c4": {
  "@type": "slateTable",
  "table": {
   "basic": false,
   "celled": true,
   "compact": false,
   "fixed": true,
   "inverted": false,
   "rows": [
    {
     "key": "82dl4",
     "cells": [
      {
       "key": "d74tq",
       "type": "data",
       "value": [
        {
         "type": "strong",
         "children": [
          {
           "text": "Text1 broken"
          }
         ]
        }
       ]
      }
     ]
    }
   ],
   "striped": false
  }
 },
 "db76c67a-1deb-45ff-ac7a-14033b1f9d1a": {
  "@type": "slateTable",
  "table": {
   "basic": false,
   "celled": true,
   "compact": false,
   "fixed": true,
   "inverted": false,
   "rows": [
    {
     "key": "7c9fn",
     "cells": [
      {
       "key": "lkg0",
       "type": "data",
       "value": [
        {
         "text": "\nText2 broken"
        }
       ]
      }
     ]
    }
   ],
   "striped": false
  }
 },
 "faf49c27-953d-499f-91a7-d01a26341017": {
  "@type": "slateTable",
  "table": {
   "basic": false,
   "celled": true,
   "compact": false,
   "fixed": true,
   "inverted": false,
   "rows": [
    {
     "key": "82dl4",
     "cells": [
      {
       "key": "d74tq",
       "type": "data",
       "value": [
        {
         "type": "p",
         "children": [
          {
           "type": "strong",
           "children": [
            {
             "text": "Text3 ok"
            }
           ]
          }
         ]
        }
       ]
      }
     ],
     "striped": false
    }
   ]
  }
 },
 "faf49c27-953d-499f-91a7-d01a26341018": {
  "@type": "slateTable",
  "table": {
   "basic": false,
   "celled": true,
   "compact": false,
   "fixed": true,
   "inverted": false,
   "rows": [
    {
     "key": "7c9fn",
     "cells": [
      {
       "key": "lkg0",
       "type": "data",
       "value": [
        {
         "type": "p",
         "children": [
          {
           "text": ""
          }
         ]
        },
        {
         "type": "p",
         "children": [
          {
           "text": "Text4 ok"
          }
         ]
        }
       ]
      }
     ]
    }
   ],
   "striped": false
  }
 }
}

blocks_layout:

{
 "items": [
  "6069c003-923f-49a4-a947-46709dd612e1",
  "d8e990c6-05f9-4b64-a398-e08e33e726c4",
  "db76c67a-1deb-45ff-ac7a-14033b1f9d1a",
  "faf49c27-953d-499f-91a7-d01a26341017",
  "faf49c27-953d-499f-91a7-d01a26341018"
 ]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant