Lexical fields nested in other fields (e.g. groups, blocks, arrays) did not have their initial sub-field states generated, leading in multiple client-side fetches to fetch initial state when the page is loaded. Before: https://github.com/user-attachments/assets/c1d808ef-1bd3-4fb1-a9d6-d5ef81cef16d After: https://github.com/user-attachments/assets/0dcda515-ce68-4107-ba29-a08fff851ae3
69 lines
1.6 KiB
TypeScript
69 lines
1.6 KiB
TypeScript
import type { CollectionConfig } from 'payload'
|
|
|
|
import { BlocksFeature, lexicalEditor } from '@payloadcms/richtext-lexical'
|
|
|
|
export const LexicalInBlock: CollectionConfig = {
|
|
slug: 'LexicalInBlock',
|
|
fields: [
|
|
{
|
|
name: 'content',
|
|
type: 'richText',
|
|
editor: lexicalEditor({
|
|
features: [
|
|
BlocksFeature({
|
|
blocks: [
|
|
{
|
|
slug: 'blockInLexical',
|
|
fields: [
|
|
{
|
|
name: 'lexicalInBlock',
|
|
label: 'My Label',
|
|
type: 'richText',
|
|
required: true,
|
|
editor: lexicalEditor(),
|
|
admin: {
|
|
description: 'Some Description',
|
|
},
|
|
},
|
|
],
|
|
},
|
|
],
|
|
}),
|
|
],
|
|
}),
|
|
},
|
|
{
|
|
name: 'blocks',
|
|
type: 'blocks',
|
|
blocks: [
|
|
{
|
|
slug: 'lexicalInBlock2',
|
|
fields: [
|
|
{
|
|
name: 'lexical',
|
|
type: 'richText',
|
|
editor: lexicalEditor({
|
|
features: [
|
|
BlocksFeature({
|
|
inlineBlocks: [
|
|
{
|
|
slug: 'inlineBlockInLexical',
|
|
fields: [
|
|
{
|
|
name: 'text',
|
|
type: 'text',
|
|
},
|
|
],
|
|
},
|
|
],
|
|
}),
|
|
],
|
|
}),
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
],
|
|
}
|