Here is what I'm doing with CustomListNode.tsx so far that doesn't work.
import type { SerializedListNode } from '@payloadcms/richtext-lexical';
const CustomListNode: React.FC<{ node: SerializedListNode; children: React.ReactNode }> = ({ node, children }) => {
if (node.listType === 'bullet') {
return (
<ul className="list-disc ml-8 my-4 text-gray-800 dark:text-gray-200 leading-relaxed">
{children}
</ul>
);
}
if (node.listType === 'number') {
return (
<ol className="list-decimal ml-8 my-4 text-gray-800 dark:text-gray-200 leading-relaxed">
{children}
</ol>
);
}
return (
<ul className="list-none ml-8 my-4 text-gray-800 dark:text-gray-200 leading-relaxed">
{children}
</ul>
);
};
export default CustomListNode;
And try to use it in the Rich Text Renderer like this:
import React from 'react'
import { RichText } from '@payloadcms/richtext-lexical/react'
import type { DefaultNodeTypes, SerializedListNode } from '@payloadcms/richtext-lexical'
import type { SerializedEditorState } from '@payloadcms/richtext-lexical/lexical';
import type { JSXConvertersFunction } from '@payloadcms/richtext-lexical/react'
import CustomUploadNode from './CustomUploadNode';
import CustomListNode from './CustomListNode';
type NodeTypes = DefaultNodeTypes | SerializedListNode;
const jsxConverters: JSXConvertersFunction<NodeTypes> = ({ defaultConverters }) => ({
...defaultConverters,
upload: ({ node }) => <CustomUploadNode node={node} />,
list: ({ node, children }) => <CustomListNode node={node}>{children}</CustomListNode>,
})
interface RichTextRendererProps {
content: SerializedEditorState | null | undefined
}
const RichTextRenderer: React.FC<RichTextRendererProps> = ({ content }) => {
if (!content) return null
return <RichText data={content} converters={jsxConverters} />
}
export default RichTextRenderer