Lexical nested fields are currently not set-up to handle access control on the client properly. Despite that, we were passing parent permissions to `RenderFields`, which causes certain fields to not show up if the document does not have `create` permission.
52 lines
1.1 KiB
TypeScript
52 lines
1.1 KiB
TypeScript
import type { CollectionConfig } from 'payload'
|
|
|
|
import { defaultEditorFeatures, lexicalEditor, LinkFeature } from '@payloadcms/richtext-lexical'
|
|
|
|
import { lexicalAccessControlSlug } from '../../slugs.js'
|
|
|
|
export const LexicalAccessControl: CollectionConfig = {
|
|
slug: lexicalAccessControlSlug,
|
|
access: {
|
|
read: () => true,
|
|
create: () => false,
|
|
},
|
|
admin: {
|
|
useAsTitle: 'title',
|
|
},
|
|
fields: [
|
|
{
|
|
name: 'title',
|
|
type: 'text',
|
|
},
|
|
{
|
|
name: 'richText',
|
|
type: 'richText',
|
|
editor: lexicalEditor({
|
|
features: [
|
|
...defaultEditorFeatures,
|
|
LinkFeature({
|
|
fields: ({ defaultFields }) => [
|
|
...defaultFields,
|
|
{
|
|
name: 'blocks',
|
|
type: 'blocks',
|
|
blocks: [
|
|
{
|
|
slug: 'block',
|
|
fields: [
|
|
{
|
|
name: 'text',
|
|
type: 'text',
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
],
|
|
}),
|
|
],
|
|
}),
|
|
},
|
|
],
|
|
}
|