HTML Table in Structured Text

Is it possible to use HTML table within structured text?

1 Like

Hello @tarek

No, it is currently not possible to do it directly in the structured text. But you can do it in a multi-paragraph field with presentation set to HTML editor

If you want, you can create a block with a multi-paragraph HTML editor, and then you can use that block inside a structured text:

Hope this helps!

1 Like

Are there any plans for a beter headless table format?

HTML is not an option in some cases

Hello @K-user

What do you mean by a headless solution? Could you exemplify what the API response for a more headless table solution could be instead of the HTML structure?

Let us know!

I may not have the overview to see the complexity that you can see but I was thinking about a JSON object that contains the table heading and body.

It could be a simple array of arrays:

{
    "heading": [
        "column1 title",
        "column2 title"
    ],
    "body": [
        [
            "row 1 column1",
            "row 1 column2"
        ],
        [
            "row 2 column1",
            "row 2 column2"
        ]
    ]
}

Or if there need to be more info for each row / column an array of objects

{
    "heading": [
        {
            "text": "column1 title"
        },
        {
            "text": "column2 title"
        }
    ],
    "body": [
        {
            "items": [
                {
                    "text": "row 1 column1"
                },
                {
                    "text": "row 1 column2"
                }
            ]
        },
        {
            "items": [
                {
                    "text": "row 2 column1"
                },
                {
                    "text": "row 2 column2"
                }
            ]
        }
    ]
}

@K-user Thank you for the clarification!

In that case i think this plugin right here: Table Editor - Plugins - DatoCMS
Is exactly what you are looking for :slight_smile:

1 Like

That plugin is perfect. Im curiouse why it is no integrated functionality, expecially since the plugin isn’t third-party made but by Stefano?

Also if im not mistaken, this plugin is fairly new (two months old). I did not see this plugin/functionality comeup in the product change logs / updates. I would think that you guys are eager to add great functionality like this and notify all users thru the changelogs / product updates?

Anyways thanks for pointing out this plugin!

Thats great!

It is not integrated natively because we’re trying to keep the amount of native options to the absolute necessary to keep the UI simple and intuitive, and delegate the more complex customisation options and specific use-cases to optional plugins

We do blog posts to announce some of the new plugins, like this one: Plugins Roundup: What's possible with the new SDK - DatoCMS and only put the major native changes on the change-log, not to spam the users with notifications

Allright thx for clarifying.

I would love if this could turn into a feature request. I think a table editor is generally something that most people would need in a rich text editor. Especially one that can take advantage of the other features of the editor, like bold, italic, headings, etc. Any chance we can make this a feature request?

1 Like

sure, I’m converting it :slight_smile:

hey @jdesherlia have you seen this other plugin: Advanced Table Editor - Plugins - DatoCMS

I think this covers it well.

In general we won’t add an HTML table in the structured text as it defeats the purpose of the structured text field :slight_smile:

I’ll leave this open a bit more, but I think that plugins can cover well the need for advanced tables in JSON/HTML formats.

@mat_jack1 the ideal table solution would be an integrated table editor inside a structured text field. Basic table editor features which would solve most of the scenarios:

  1. Manage table header rows, footer rows, body rows
  2. Basic text formatting text inside cells (bold, italics, color, highlight, …)
  3. Insert links (external and internal links to records like in structured text)
  4. Insert image
  5. Merge cells and rows

Advanced features (not necessary in my opinion):

  • table width, border, className
  • cell width, border, className
  • row, cell background, className

If this would be backed with table rendering function in the <StructuredText /> component in react-dato-cms package would be awesome.

Existing table plugins are okay but solve some very simple or specific table scenarios.

8 Likes

Yup, this would fit several of our use cases perfectly as well, and we’ve been asked about this by clients migrating from Wordpress.

1 Like

+1 on this being part of Structured Text. This functionality is something our clients use a lot in other headless CMS solutions like Contentful. Sorry for using a 4-letter word here, I only reference it here cause I think it is a fine reference point for what we’d love to see in Dato. Dato structured text is sooooooo much better in just about every other area, it would be great to close the gap on tables.

While the JSON table plugin is cool, it doesn’t allow for any kind of formatting within the table, such as bold, or links.

2 Likes