payload icon indicating copy to clipboard operation
payload copied to clipboard

[3.0] Lexical Block

Open mpresecan opened this issue 1 year ago • 0 comments

Link to reproduction

No response

Describe the Bug

According to the https://payloadcms.com/docs/rich-text/lexical#integrating-new-features, when testing taking the documentation code for integrating new features like adding block into the lexical editor, there are 2 typescript issues:

export default buildConfig({
  editor: lexicalEditor({
    features: ({ defaultFeatures }) => [
      ...defaultFeatures,
      LinkFeature({
        // Example showing how to customize the built-in fields
        // of the Link feature
        fields: [
          {
            name: 'rel',
            label: 'Rel Attribute',
            type: 'select',
            hasMany: true,
            options: ['noopener', 'noreferrer', 'nofollow'],
            admin: {
              description:
                  'The rel attribute defines the relationship between a linked resource and the current document. This is a custom link field.',
            },
          },
        ],
      }),
      UploadFeature({
        collections: {
          uploads: {
            // Example showing how to customize the built-in fields
            // of the Upload feature
            fields: [
              {
                name: 'caption',
                type: 'richText',
                editor: lexicalEditor(),
              },
            ],
          },
        },
      }),
      // This is incredibly powerful. You can re-use your Payload blocks
      // directly in the Lexical editor as follows:
      BlocksFeature({
        blocks: [
            developmentPlan as LexicalBlock
        ],
      }),
    ]
  }),
  ...
})
  1. issue: TS2322: Type ({defaultFeatures}: { defaultFeatures: FeatureProviderServer<unknown, unknown>[]; }) => (FeatureProviderServer<unknown, unknown> | FeatureProviderServer<LinkFeatureServerProps, ExclusiveLinkCollectionsProps> | FeatureProviderServer<...> | FeatureProviderServer<...>)[] is not assignable to type (({defaultFeatures,}: { defaultFeatures: FeatureProviderServer<unknown, unknown>[]; }) => FeatureProviderServer<unknown, unknown>[]) | FeatureProviderServer<unknown, unknown>[] | undefined

  2. issue: block given expect to be LexicalBlock but it is type of Block.

To Reproduce

Folow the documentation on https://payloadcms.com/docs/rich-text/lexical#integrating-new-features

Payload Version

3.0.

Adapters and Plugins

LexicalEditor

mpresecan avatar May 02 '24 11:05 mpresecan