When going through the documentation athttps://payloadcms.com/docs/rich-text/lexical
. There is a line saying: "The lexicalHTML() function creates a new field that automatically converts the referenced lexical richText field into HTML through an afterRead hook."
I'm not sure how to interpret the statement. Does it mean
1. I need to implement a serialization mechanism in
2. Or, Payload generates the content automatically.
Currently, what I see is this in the API call
, meaning no HTML is generated. Am I missing something?
You can use it in your collection as a field. You don't have to write a hook for it.
But I guess you can't use it in a group, array or collapsible.
through an afterRead hook.
That just means that behind-the-back, this lexicalHTML feature uses an afterRead hook. It's added automatically, so no action required from your side!
Only thing you have to do is to make sure that the first argument in the lexicalHTML function matches the field name
Might not work if the richtext field is in a group/array yet, that's true. Will have to look into that
Yes, my rich text is in a group. When I have time, I will play around with the implementation and open a GH issue if needed. In the meantime, I use the front end serializer as it has been working well since Slate.
The issue for this was opened on GitHub, so I will close this thread:https://github.com/payloadcms/payload/issues/4034