how to Serialize lexical editor in payloadcms?

default discord avatar
dasmergolast year
8

hello i added default lexical serializer to my payload project but have no idea where to call it?


can any one help me with this?



http://up44.ir/previews/8e60d31956d7c0510feb91aef198d914.png


http://up44.ir/previews/995b1ae90a3222376acb2b6d57af4d7c.png


i have so bad connection due to Iranian government censorship so i uploaded the images somewhere else -_-

  • default discord avatar
    linobino1last year

    You should call the serializer in your frontend. It's meant to serialize the data of a lexical field to html.

  • discord user avatar
    alessiogr
    last year

    What linobino1 said! An alternative solution would be serializing it directly in an AfterRead hook, so that you won't have to do it in the front end anymore / so that the frontend receives the full html string.



    Just gotta make sure not to do that for admin panel visits & only for API calls though, as that would unnecessary slow down the admin panel

  • default discord avatar
    58bitslast year

    @dasmergo Is your front end React? If so this might help....

    https://gist.github.com/58bits/a6dc5d7d2f7297c6816deb2131835c14


    It will be included in the Lexical plugin for Payload soon.

  • default discord avatar
    dasmergolast year

    thanks for your response, I'm using the mighty 😄 NextJS



    i think there is no difference for this purpose

  • default discord avatar
    58bitslast year

    It will be there as an example React serializer that you can use in any React frontend.

  • default discord avatar
    dasmergolast year

    nice

  • default discord avatar
    58bitslast year

    @dasmergo The example ReactSerializer can be found here...

    https://github.com/AlessioGr/payload-plugin-lexical/tree/develop/serialize-example

    - although not 100% complete, it might help in getting started.

  • default discord avatar
    dasmergolast year

    thanks

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

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