I'm trying to modify the features available in Lexical and not seeing expected results:
- As expected, removing
defaultFeaturescorrectly removes all features
- Including a simple additional one, like
FixedToolbarFeature, does
notrender the fixed toolbar
- Including
BlocksFeaturealso has no effect
There is very little going on in this new, proof-of-concept Payload installation... what might be wrong?
export const Pages: CollectionConfig = {
slug: 'pages',
admin: {
useAsTitle: 'name',
group: 'Site',
},
fields: [
{
name: 'name',
type: 'text',
},
{
name: 'test',
type: 'richText',
editor: lexicalEditor({
features: ({ defaultFeatures }) => [
...defaultFeatures,
BlocksFeature({
blocks: [TextBlurbBlock],
}),
FixedToolbarFeature(),
],
}),
},
...what Payload version are you using? Could you share the repo?
i'm on 3.19. i haven't published this repo yet as I'm only evaluating payload
the payload config is totally stock aside from my collections
I would test this on 3.27.0 - it definitely works fine for me there
I solved this. The issue was that my types and/or import map were out of date.
These had started to drift because I:
- Configured a field to use a custom component, which I later relocated without updating the config
- Installed postcss and started sprinkling css module imports throughout the code, which upset the type generator
I still need to figure out how to make the generator play well with postcss, but I at least have my lexical features now.
I'm a little unclear as to whether payload sometimes/always/never runs the generators automatically. When I first started out it all seemed to work automatically and silently. At some point it started to
failsilently...
Yea I don't think we throw any errors if it fails during runtime. You might only see them if you manually run
pnpm payload generate:importmap.
Installed postcss and started sprinkling css module imports throughout the code, which upset the type generator
The reason you're seeing it fail is due to you importing client-only modules (=> css files) into your Payload Config. The payload config is expected to be node-safe, and importing client-only modules is not.
In order for this to work correctly, you will have to make sure to only import client modules, like css files, from other client files. Those client files can then be imported safely into your Payload Config using string import paths.
Thanks
@360823574644129795Star
Discord
online
Get dedicated engineering support directly from the Payload team.