Is it possible to use HTML table within structured text?
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!
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 ![]()
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?
sure, I’m converting it ![]()
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 ![]()
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:
- Manage table header rows, footer rows, body rows
- Basic text formatting text inside cells (bold, italics, color, highlight, …)
- Insert links (external and internal links to records like in structured text)
- Insert image
- 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.
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 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.
Hello team,
Same here — while we really love this CMS, we still don’t understand why there isn’t a native table feature to create tables and format content (links, images, etc.).
It feels like a pretty basic functionality, especially since it’s already available for structured text.
Is it impossible to consider adding this?
I haven’t heard any recent news on this front (sorry), but I’ll check with the devs again to see if there’s any particular reason why we still don’t (can’t?) do this. Will update if I hear back!
OK, so I heard back from the devs… I have a bit of good & bad news to share!
Bad news first: We can’t promise anything yet. I must emphasize that this is not a planned feature announcement, just a discussion/evaluation we’ll have in the near future to see if some form of table editing might be feasible. It won’t be quick process (expect a few months at least), so if you need something sooner, one of the above workarounds (plugins or HTML editor) would be your best bet for now.
Good news is this: We hear you. This is one of those feature requests that keeps resurrecting itself every year or so
. Enough people keep asking about it that we’re willing to at least reconsider it and reevaluate whether it’s something we can add.
For context, the main initial reason we chose not to do this upfront is simply because it would’ve been quite the complex addition to our Structured Text format (DAST). Philosophically, we want Structured Text to be distinct from HTML on purpose. We want it to be a structured representation of content and data rather than declarative formatting the way HTML is. We didn’t want Structured Text to also hold formatting markup, since that is ideally the job of the frontend. But that said, in the real world there’s often a bit of a gray area there — we already have headings and bolding and such, after all.
The other reason is responsiveness (as in trying to make tables look nice on mobile viewports).
So we have to figure out a way to encode tabular content in some sort of table-like representation, inside the JSON of our existing format, without breaking format agnosticism. We have to be able to encode this table-like data in a way that could be rendered as a table (and usually will be), but the format also has to be flexible enough for it to rendered not like a table sometimes — like for mobile viewports or other kinds of devices.
This isn’t impossible, of course. You can already kinda do this with custom blocks (with each block being a row, and each field in the block being a column). There are also third-party solutions to the same problem, like MUI’s table component that similarly encodes each row as JSON (with a table being an array of row objects, and each row having its column/fields as properties in that object) — while still rendering into tables normally, with an optional list view for mobile. That’s just one example.
So all this just means it will take some thinking and design work, both on the output (schema) side, and also on the input side (the editor experience). I guess ideally it would be something that looks like a table to the editor (so they can easily copy & paste into it), gets encoded into something that isn’t a table (i.e. some sort of structured JSON), but then can be rendered back into a table OR something else on the frontend.
We’ll discuss all of this internally in the coming months. I personally really want to see this feature too, so hopefully it’s something we can add!
In the meantime, if you have any ideas or suggestions, or have seen other implementations you’ve either lived or disliked, please let us know too so we can consider those as well when we do our research.
By the way, this just reminded me of yet another workaround… you could inline a single-field block inside the structured text, with that one field being a HTML editor with the table. That would literally be a HTML table inside structured text, if you don’t care about semanticness and all that.
