Like what we’re doing? Star us on GitHub!

How can I create a table?

peladococinero
4 months ago
26

Hi, it's me again, sorry lmao



Well, I am confused, because in Strapi there the label "table" like this:



How can I create a customize label?



Other example in Slate

image.png
  • jmikrut
    Payload Team
    4 months ago

    you can recreate that exact element from Slate, but I do think we need to add support for tables natively in Payload



    tables and rich text are tough. Generally what we do is just make a "markdown" field when we need tables and then draw out the markdown table. You can see that on our website

  • peladococinero
    4 months ago

    How can I make it?



    I mean, is with Slate package?

  • jmikrut
    Payload Team
    4 months ago

    All of the code for the Slate example is available right on that site above:



    https://github.com/ianstormtaylor/slate/blob/main/site/examples/tables.tsx
  • peladococinero
    4 months ago

    Sorry, I don't undestand



    I mean, I can put a table field in Rich text?

  • jmikrut
    Payload Team
    4 months ago

    it is technically possible to be able to put a table inside a rich text editor, but you need to manually extend Payload's rich text editor to be able to support that—using the code in the example above

  • peladococinero
    4 months ago

    Ahh, okey



    Thanks you!

  • tommygun
    4 months ago

    Hey @jmikrut 👋 Messaging here instead of starting a new thread on same topic - are there are any plans to add tables natively to Payload's richText field? Or otherwise make it easier to do so, with a new plugin system of some kind?



    Asking so I know whether it's worth me starting on a custom integration, or if I'd be better off waiting for Payload's own solution. Thanks! Loving Payload so far 😀

  • jmikrut
    Payload Team
    4 months ago

    that is a good question



    right now there is a separate thread going about how we might build in Lexical editor support, which has native tables that are super nice



    but regarding tables in Slate, we will absolutely be getting to that one way or another, although it could be some time yet before we tackle it. We have a LOT on our plate for Q1 2023

  • tommygun
    4 months ago

    Yes I've seen your roadmap! Exciting stuff 🥳 Thanks for confirming your plans.



    I've seen @Alessio 🍣 's PR for a Lexical integration. Super cool. I'd be excited to help test this as a plugin. Tables are the missing piece for the content workflow in my current project!

  • Alessio 🍣
    4 months ago

    Currently working on a plugin version!


    However, Meta's team currently has 2 table implementations: the basic one and the "experimental" one (which is way nicer).


    Since the experimental one changes what's outputted as json, I'm planning to wait until the experimental one is stable and use that one - until then disable the table plugin. Reason is future-proofing as if I use the standard table plugin now, I can't switch to the new one in the future as the data might break

  • tommygun
    4 months ago

    Sounds great, thanks! I'm watching the GH thread, looking forward to testing out your Lexical plugin 😀

  • roac
    2 weeks ago

    Hey Alessio have you managed to implement the the table. If you have would it be possible to share a gist of it

  • Alessio 🍣
    2 weeks ago

    Hey, just updated the plugin to better support tables!



    Check

    https://github.com/AlessioGr/payload-plugin-lexical/blob/master/demo/src/fields/customizedLexicalRichTextField.tsx#L37

    for an example for enabling them



    Still disabled by default since I dont know which table type to use (standard or experimental), but it's easy to enable it



    works very well though!

Open the post
Continue the discussion in Discord
Can't find what you're looking for?
Get help straight from the Payload team with an Enterprise License.Learn More