payloadcms / payload

Payload is the open-source, fullstack Next.js framework, giving you instant backend superpowers. Get a full TypeScript backend and admin panel instantly. Use Payload as a headless CMS or for building powerful applications.
https://payloadcms.com
MIT License
25.52k stars 1.62k forks source link

Lexical editor config is discregarded when used within a Block #8303

Closed PavelGolodoniuc closed 1 month ago

PavelGolodoniuc commented 1 month ago

Link to reproduction

No response

Describe the Bug

If you have a Block that is allowed within a Lexical editor that itself has a richText field with a Lexical editor, that block's lexical editor always uses default configuration regardless of what you provide it.

To Reproduce

export const Columns: Block = {
    slug: "columns",
    labels: {
        singular: "Columns",
        plural: "Columns",
    },
    fields: [
        {
            name: "style",
            type: "select",
            options: [
                {
                    label: "Two-column split (6:6)",
                    value: "dual-6-6",
                },
                {
                    label: "Two-column split (5:1:6)",
                    value: "dual-5-1-6",
                },
                {
                    label: "Two-column split (4:1:7)",
                    value: "dual-4-1-7",
                },
                {
                    label: "Two-column split (7:1:4)",
                    value: "dual-7-1-4",
                },
            ],
        },
        {
            name: "colOne",
            label: "First column content",
            type: "richText",
            editor: lexicalEditor(defaultConfig),     // <-------------- PROBLEM IS HERE
        },
        {
            name: "colTwo",
            label: "Second column content",
            type: "richText",
            editor: lexicalEditor(defaultConfig),     // <-------------- PROBLEM IS HERE
            admin: {
                condition: (_data: any, siblingData: any) => !(<string>siblingData?.style).startsWith("single"),
            },
        },
    ],
};

In the example above, both editors, defined as editor: lexicalEditor(defaultConfig) completely disregard defaultConfig.

Payload Version

2.28.0

Adapters and Plugins

"@payloadcms/richtext-lexical": "^0.11.3"

zeitchef commented 1 month ago

I'm facing a similar problem on v3 beta.107 - crashes the admin backend with the following error:

Screenshot 2024-09-23 at 13 43 57

I've already created a separate issue.

AlessioGr commented 1 month ago

We currently do not have the capacity to fix this issue in 2.0 and are focusing on security and critical issues for 2.0. If this is still an issue in payload 3.0, please open a separate issue. There have been tons of improvements in regards to blocks & lexical, and the issue is likely already fixed there :)

This is likely unrelated to https://github.com/payloadcms/payload/issues/8274, as 2.0 does not have import maps

github-actions[bot] commented 1 month ago

This issue has been automatically locked. Please open a new issue if this issue persists with any additional detail.