Custom Leaf/Element in Slate

default discord avatar
pooledge
2 weeks ago
4

I've learned that Payload is moving to Lexical, but in the meanwhile, is there any full example of how to make these possible? I'm sort of in the dark here.



Let's say I'd need just a basic

Larger

and

Smaller

leafs to alter text size accordingly. Creating and assigning toolbar button is a breeze, but what's next? How to assign an

onClick

event to render a custom Leaf/Element inside the Editor?



If someone has done this previously I'd love to learn! Thx

  • default discord avatar
    notchr
    2 weeks ago

    @pooledge Have you seen any of the examples of customs leaf tags / buttons? I believe they exist in the different payload example repos. I've personally created a text color leaf at one point. Let me know if you can find any of those examples, if not, happy to find my old example

  • default discord avatar
    pooledge
    2 weeks ago

    @notchr any example helps, thank you!

  • default discord avatar
    notchr
    2 weeks ago

    @pooledge You may have to browser this thread a bit, but this was the discussion when I was building a custom color button

    https://discord.com/channels/967097582721572934/1085263676791062528/1088517710922661898
  • default discord avatar
    pooledge
    2 weeks ago

    Got it, thanks!

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.