Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

Customizing Lexical Nodes with the new RichText Component

default discord avatar
showmaticlast year
2

When using the RichText component imported from

@payloadcms/richtext-lexical/react

, how do you customize the standard nodes that have children? Before, in the

serialize.tsx

file, you had functions that provided

serializedChilden
<p className='col-start-2 mb-4' key={index}>
  {serializedChildren}
</p>

But how would you add the children in this instance?



What I currently have:


const jsxConverters: JSXConvertersFunction = ({ defaultConverters }) => ({
  ...defaultConverters,
  paragraph: ({ node }) => {
    return <p>{whatGoesHere?}</p>;
  },
  blocks: {
    accordion: ({ node }) => (
      <Accordion {...(node.fields as AccordionProps)} />
    )
  }
});
  • default discord avatar
    artur.krelast year
    const text = nodesToJSX({ nodes: node.children }).join("");
  • default discord avatar
    showmaticlast year

    where does

    nodesToJSX()

    come from?



    @486176901946408961

    nvm, I found it. Thank you very much.

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.