How can I create a table?

default discord avatar
peladococinero
10 months ago
29

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

  • discord user avatar
    jmikrut
    Payload Team
    10 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

  • default discord avatar
    peladococinero
    10 months ago

    How can I make it?



    I mean, is with Slate package?

  • discord user avatar
    jmikrut
    Payload Team
    10 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
  • default discord avatar
    peladococinero
    10 months ago

    Sorry, I don't undestand



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

  • discord user avatar
    jmikrut
    Payload Team
    10 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

  • default discord avatar
    peladococinero
    10 months ago

    Ahh, okey



    Thanks you!

  • default discord avatar
    tommygun
    10 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 πŸ˜€

  • discord user avatar
    jmikrut
    Payload Team
    10 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

  • default discord avatar
    tommygun
    10 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!

  • default discord avatar
    Alessio 🍣
    10 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

  • default discord avatar
    tommygun
    10 months ago

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

  • default discord avatar
    roac
    6 months ago

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

  • default discord avatar
    Alessio 🍣
    6 months 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!

  • default discord avatar
    roac
    5 months ago

    @Alessio 🍣 is there any issue if I use the experimental table ?

  • default discord avatar
    Alessio 🍣
    5 months ago

    eh I don't think it works that well, I'd personally just use the normal table



    Keep in mind not to use any tables if you have more than 2 richtext fields on one single page (e.g. through the blocks fields) though. There's a lexical bug which glitches them out - will be fixed prob in the next lexical version

Open the post
Continue the discussion in Discord
Like what we're doing?
Star us on GitHub!

Star

Connect with the Payload Community on Discord

Discord

online

Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.