Custom leaf in slate editor

default discord avatar
ilyas771
3 months ago
2

How to integrate custom leaf to slate editor? I have tried the one below



leaves: [


'bold',


'italic',


{


name: Leaf.name,


Button: Leaf.Button,


Leaf: Leaf.Leaf,


},


],


but it throws


Uncaught Error: The

useSlate

hook must be used inside the <Slate> component's context.


at useSlate (index.es.js:1659:1)


at Button (colorText.tsx:69:26)

  • default discord avatar
    markatomniux
    3 months ago

    are you using the LeafButton provided by Payload? What does that code look like

  • default discord avatar
    ilyas771
    3 months ago

    so you need a single version of slate, just importing from payload/node_modules/slate will work

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.